resvg wasm remove fs and path

This commit is contained in:
Shivam Meena
2023-06-07 21:47:54 +05:30
parent 3306bf03b3
commit b65f12d3a2
4 changed files with 9 additions and 137 deletions

View File

@@ -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), {