mirror of
https://github.com/LukeHagar/sveltekit-og.git
synced 2025-12-08 20:57:45 +00:00
resvg wasm remove fs and path
This commit is contained in:
@@ -2,14 +2,6 @@ import satori, { type SatoriOptions } from 'satori';
|
||||
import type { SvelteComponent } from 'svelte';
|
||||
import toReactElement from './toReactElement';
|
||||
import {Resvg as wasmSvg, initWasm, type ResvgRenderOptions} from "@resvg/resvg-wasm"
|
||||
import {readFileSync} from "fs"
|
||||
import { dirname } from "path"
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
|
||||
|
||||
const fontFile = await fetch('https://sveltekit-og.ethercorps.io/noto-sans.ttf');
|
||||
const fontData: ArrayBuffer = await fontFile.arrayBuffer();
|
||||
@@ -19,11 +11,9 @@ const initReSvg = async () => {
|
||||
const indexWasmRes = await fetch('https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm');
|
||||
const buffer = await indexWasmRes.arrayBuffer();
|
||||
await initWasm(buffer);
|
||||
// await initWasm( readFileSync( __dirname + "/resvg.wasm" ));
|
||||
initialized = true;
|
||||
};
|
||||
|
||||
|
||||
const ImageResponse = async (htmlTemplate: string, optionsByUser: ImageResponseOptions) => {
|
||||
const options = Object.assign({ width: 1200, height: 630, debug: !1 }, optionsByUser);
|
||||
const svg = await satori(toReactElement(htmlTemplate), {
|
||||
|
||||
Reference in New Issue
Block a user