Sharp would be compatible with Hono, it just might not be compatible with Workers. Have you tried th
Sharp would be compatible with Hono, it just might not be compatible with Workers. Have you tried the Sharp WASM version?
import { Resvg, ResvgRenderOptions, initWasm } from '@resvg/resvg-wasm';
import wasmModule from '@resvg/resvg-wasm/index_bg.wasm';
export const generateImage = async (text: string) => {
console.log(text, "this is the text");
const svg = ;
try {
await initWasm(wasmModule);
} catch (error) {
console.error('Resvg wasm not initialized');
throw error;
}
const opts: ResvgRenderOptions = {
background: "white", // Optional: set background color
fitTo: {
mode: "width",
value: 600, // Adjust based on your needs
},
font: {
loadSystemFonts: true, // Disable system fonts if you're using custom fonts
},
};
const resvg = new Resvg(svg, opts);
console.log(resvg, "this is the resvg");
const pngData = resvg.render();
const pngBuffer = pngData.asPng();
return pngBuffer;
};fontBuffer is a raw ttffs of course, but worth a try)
import { DurableObject } from "cloudflare:workers";Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'@cloudflare/workers work?


import { Resvg, ResvgRenderOptions, initWasm } from '@resvg/resvg-wasm';
import wasmModule from '@resvg/resvg-wasm/index_bg.wasm';
export const generateImage = async (text: string) => {
console.log(text, "this is the text");
const svg = ;
try {
await initWasm(wasmModule);
} catch (error) {
console.error('Resvg wasm not initialized');
throw error;
}
const opts: ResvgRenderOptions = {
background: "white", // Optional: set background color
fitTo: {
mode: "width",
value: 600, // Adjust based on your needs
},
font: {
loadSystemFonts: true, // Disable system fonts if you're using custom fonts
},
};
const resvg = new Resvg(svg, opts);
console.log(resvg, "this is the resvg");
const pngData = resvg.render();
const pngBuffer = pngData.asPng();
return pngBuffer;
};font: {
fontsBuffers: [fontBuffer], //
},Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'cloudflare:'