nuxt-og-image 5.1.10 → 5.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/200.html +1 -0
- package/dist/client/404.html +1 -0
- package/dist/client/_nuxt/B8PEiB0p.js +1 -0
- package/dist/client/_nuxt/CD9VIl4i.js +4062 -0
- package/dist/client/_nuxt/CI_lqgv7.js +1 -0
- package/dist/client/_nuxt/CVO1_9PV.js +1 -0
- package/dist/client/_nuxt/Cp-IABpG.js +1 -0
- package/dist/client/_nuxt/D0r3Knsf.js +1 -0
- package/dist/client/_nuxt/Dz8kdfgF.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -0
- package/dist/client/_nuxt/builds/meta/71b0f7ea-9aae-4c28-bbd9-8eea71b82dfb.json +1 -0
- package/dist/client/_nuxt/entry.DNM8P-MU.css +1 -0
- package/dist/client/_nuxt/error-404.C2mGI6Vt.css +1 -0
- package/dist/client/_nuxt/error-500.ClHbVBiL.css +1 -0
- package/dist/client/_nuxt/l5rcX3cq.js +8 -0
- package/dist/client/index.html +1 -0
- package/dist/content.cjs +22 -0
- package/dist/content.d.cts +46 -0
- package/dist/content.d.mts +46 -0
- package/dist/content.d.ts +46 -0
- package/dist/content.mjs +18 -0
- package/dist/module.cjs +1027 -0
- package/dist/module.d.cts +109 -0
- package/dist/module.d.mts +109 -0
- package/dist/module.d.ts +109 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +1007 -0
- package/dist/runtime/app/components/OgImage/OgImage.d.ts +3 -0
- package/dist/runtime/app/components/OgImage/OgImage.js +10 -0
- package/dist/runtime/app/components/OgImage/OgImageScreenshot.d.ts +3 -0
- package/dist/runtime/app/components/OgImage/OgImageScreenshot.js +10 -0
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.d.vue.ts +13 -0
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue +22 -0
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue.d.ts +13 -0
- package/dist/runtime/app/components/Templates/Community/Frame.d.vue.ts +21 -0
- package/dist/runtime/app/components/Templates/Community/Frame.vue +58 -0
- package/dist/runtime/app/components/Templates/Community/Frame.vue.d.ts +21 -0
- package/dist/runtime/app/components/Templates/Community/Nuxt.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Nuxt.vue +179 -0
- package/dist/runtime/app/components/Templates/Community/Nuxt.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.d.vue.ts +15 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue +103 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue.d.ts +15 -0
- package/dist/runtime/app/components/Templates/Community/Pergel.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Pergel.vue +98 -0
- package/dist/runtime/app/components/Templates/Community/Pergel.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.d.vue.ts +9 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue +27 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue.d.ts +9 -0
- package/dist/runtime/app/components/Templates/Community/UnJs.d.vue.ts +21 -0
- package/dist/runtime/app/components/Templates/Community/UnJs.vue +99 -0
- package/dist/runtime/app/components/Templates/Community/UnJs.vue.d.ts +21 -0
- package/dist/runtime/app/components/Templates/Community/Wave.d.vue.ts +11 -0
- package/dist/runtime/app/components/Templates/Community/Wave.vue +28 -0
- package/dist/runtime/app/components/Templates/Community/Wave.vue.d.ts +11 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.d.vue.ts +13 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.vue +21 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.vue.d.ts +13 -0
- package/dist/runtime/app/composables/defineOgImage.d.ts +2 -0
- package/dist/runtime/app/composables/defineOgImage.js +43 -0
- package/dist/runtime/app/composables/defineOgImageComponent.d.ts +3 -0
- package/dist/runtime/app/composables/defineOgImageComponent.js +8 -0
- package/dist/runtime/app/composables/defineOgImageScreenshot.d.ts +2 -0
- package/dist/runtime/app/composables/defineOgImageScreenshot.js +14 -0
- package/dist/runtime/app/composables/mock.d.ts +5 -0
- package/dist/runtime/app/composables/mock.js +20 -0
- package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.d.ts +2 -0
- package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.js +9 -0
- package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.d.ts +2 -0
- package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.js +9 -0
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.d.ts +2 -0
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +7 -0
- package/dist/runtime/app/plugins/route-rule-og-image.server.d.ts +2 -0
- package/dist/runtime/app/plugins/route-rule-og-image.server.js +7 -0
- package/dist/runtime/app/utils/plugins.d.ts +3 -0
- package/dist/runtime/app/utils/plugins.js +92 -0
- package/dist/runtime/app/utils.d.ts +7 -0
- package/dist/runtime/app/utils.js +94 -0
- package/dist/runtime/assets/Inter-normal-400.ttf.base64 +1 -0
- package/dist/runtime/assets/Inter-normal-700.ttf.base64 +1 -0
- package/dist/runtime/logger.d.ts +2 -0
- package/dist/runtime/logger.js +8 -0
- package/dist/runtime/mock/empty.d.ts +2 -0
- package/dist/runtime/mock/empty.js +2 -0
- package/dist/runtime/mock/proxy-cjs.d.ts +2 -0
- package/dist/runtime/mock/proxy-cjs.js +2 -0
- package/dist/runtime/server/og-image/bindings/chromium/chrome-launcher.d.ts +2 -0
- package/dist/runtime/server/og-image/bindings/chromium/chrome-launcher.js +9 -0
- package/dist/runtime/server/og-image/bindings/chromium/on-demand.d.ts +2 -0
- package/dist/runtime/server/og-image/bindings/chromium/on-demand.js +40 -0
- package/dist/runtime/server/og-image/bindings/chromium/playwright.d.ts +2 -0
- package/dist/runtime/server/og-image/bindings/chromium/playwright.js +6 -0
- package/dist/runtime/server/og-image/bindings/css-inline/node.d.ts +8 -0
- package/dist/runtime/server/og-image/bindings/css-inline/node.js +7 -0
- package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.d.ts +7 -0
- package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.js +8 -0
- package/dist/runtime/server/og-image/bindings/css-inline/wasm.d.ts +7 -0
- package/dist/runtime/server/og-image/bindings/css-inline/wasm.js +7 -0
- package/dist/runtime/server/og-image/bindings/resvg/node.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/resvg/node.js +5 -0
- package/dist/runtime/server/og-image/bindings/resvg/wasm-fs.d.ts +40 -0
- package/dist/runtime/server/og-image/bindings/resvg/wasm-fs.js +6 -0
- package/dist/runtime/server/og-image/bindings/resvg/wasm.d.ts +40 -0
- package/dist/runtime/server/og-image/bindings/resvg/wasm.js +5 -0
- package/dist/runtime/server/og-image/bindings/satori/node.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/satori/node.js +5 -0
- package/dist/runtime/server/og-image/bindings/satori/wasm-fs.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/satori/wasm-fs.js +13 -0
- package/dist/runtime/server/og-image/bindings/satori/wasm.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/satori/wasm.js +13 -0
- package/dist/runtime/server/og-image/bindings/sharp/node.d.ts +2 -0
- package/dist/runtime/server/og-image/bindings/sharp/node.js +2 -0
- package/dist/runtime/server/og-image/cache/lru.d.ts +9 -0
- package/dist/runtime/server/og-image/cache/lru.js +15 -0
- package/dist/runtime/server/og-image/cache/mock.d.ts +9 -0
- package/dist/runtime/server/og-image/cache/mock.js +9 -0
- package/dist/runtime/server/og-image/chromium/renderer.d.ts +3 -0
- package/dist/runtime/server/og-image/chromium/renderer.js +24 -0
- package/dist/runtime/server/og-image/chromium/screenshot.d.ts +4 -0
- package/dist/runtime/server/og-image/chromium/screenshot.js +54 -0
- package/dist/runtime/server/og-image/context.d.ts +5 -0
- package/dist/runtime/server/og-image/context.js +283 -0
- package/dist/runtime/server/og-image/instances.d.ts +2 -0
- package/dist/runtime/server/og-image/instances.js +10 -0
- package/dist/runtime/server/og-image/satori/font.d.ts +3 -0
- package/dist/runtime/server/og-image/satori/font.js +40 -0
- package/dist/runtime/server/og-image/satori/instances.d.ts +41 -0
- package/dist/runtime/server/og-image/satori/instances.js +23 -0
- package/dist/runtime/server/og-image/satori/plugins/classes.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/classes.js +17 -0
- package/dist/runtime/server/og-image/satori/plugins/emojis.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/emojis.js +28 -0
- package/dist/runtime/server/og-image/satori/plugins/encoding.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/encoding.js +17 -0
- package/dist/runtime/server/og-image/satori/plugins/flex.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/flex.js +60 -0
- package/dist/runtime/server/og-image/satori/plugins/imageSrc.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/imageSrc.js +107 -0
- package/dist/runtime/server/og-image/satori/plugins/nuxt-icon.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/nuxt-icon.js +20 -0
- package/dist/runtime/server/og-image/satori/plugins/unocss.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/plugins/unocss.js +55 -0
- package/dist/runtime/server/og-image/satori/renderer.d.ts +4 -0
- package/dist/runtime/server/og-image/satori/renderer.js +123 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis.d.ts +3 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis.js +3595 -0
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.d.ts +3 -0
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.js +51 -0
- package/dist/runtime/server/og-image/satori/utils.d.ts +3 -0
- package/dist/runtime/server/og-image/satori/utils.js +24 -0
- package/dist/runtime/server/og-image/satori/vnodes.d.ts +2 -0
- package/dist/runtime/server/og-image/satori/vnodes.js +40 -0
- package/dist/runtime/server/og-image/templates/html.d.ts +2 -0
- package/dist/runtime/server/og-image/templates/html.js +112 -0
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.d.ts +2 -0
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.js +9 -0
- package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +2 -0
- package/dist/runtime/server/plugins/nuxt-content-v2.js +5 -0
- package/dist/runtime/server/plugins/prerender.d.ts +2 -0
- package/dist/runtime/server/plugins/prerender.js +38 -0
- package/dist/runtime/server/routes/__zero-runtime/font.d.ts +2 -0
- package/dist/runtime/server/routes/__zero-runtime/font.js +8 -0
- package/dist/runtime/server/routes/__zero-runtime/image.d.ts +2 -0
- package/dist/runtime/server/routes/__zero-runtime/image.js +8 -0
- package/dist/runtime/server/routes/debug.json.d.ts +7 -0
- package/dist/runtime/server/routes/debug.json.js +15 -0
- package/dist/runtime/server/routes/font.d.ts +2 -0
- package/dist/runtime/server/routes/font.js +3 -0
- package/dist/runtime/server/routes/image.d.ts +2 -0
- package/dist/runtime/server/routes/image.js +3 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/util/cache.d.ts +10 -0
- package/dist/runtime/server/util/cache.js +74 -0
- package/dist/runtime/server/util/encoding.d.ts +3 -0
- package/dist/runtime/server/util/encoding.js +15 -0
- package/dist/runtime/server/util/eventHandlers.d.ts +3 -0
- package/dist/runtime/server/util/eventHandlers.js +156 -0
- package/dist/runtime/server/util/kit.d.ts +6 -0
- package/dist/runtime/server/util/kit.js +32 -0
- package/dist/runtime/server/util/logger.d.ts +1 -0
- package/dist/runtime/server/util/logger.js +6 -0
- package/dist/runtime/server/util/options.d.ts +2 -0
- package/dist/runtime/server/util/options.js +18 -0
- package/dist/runtime/server/util/plugins.d.ts +2 -0
- package/dist/runtime/server/util/plugins.js +56 -0
- package/dist/runtime/server/util/wasm.d.ts +2 -0
- package/dist/runtime/server/util/wasm.js +16 -0
- package/dist/runtime/server/utils.d.ts +4 -0
- package/dist/runtime/server/utils.js +20 -0
- package/dist/runtime/shared.d.ts +15 -0
- package/dist/runtime/shared.js +132 -0
- package/dist/runtime/types.d.ts +187 -0
- package/dist/runtime/types.js +0 -0
- package/dist/types.d.mts +9 -0
- package/package.json +32 -32
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { logger } from "../../../util/logger.js";
|
|
2
|
+
import { defineSatoriTransformer } from "../utils.js";
|
|
3
|
+
export default defineSatoriTransformer([
|
|
4
|
+
// need to make sure parent div has flex for the emoji to render inline
|
|
5
|
+
{
|
|
6
|
+
filter: (node) => node.type === "span" && node.props?.class?.includes("iconify"),
|
|
7
|
+
transform: (node, e) => {
|
|
8
|
+
if (import.meta.dev) {
|
|
9
|
+
logger.warn(`When using the Nuxt Icon components in \`${e.options.component}\` you must provide \`mode="svg"\` to ensure correct rendering.`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
// need to make sure parent div has flex for the emoji to render inline
|
|
14
|
+
{
|
|
15
|
+
filter: (node) => node.type === "svg" && node.props?.class?.includes("iconify"),
|
|
16
|
+
transform: (node) => {
|
|
17
|
+
node.props.class = String(node.props.class).split(" ").filter((c) => !c.startsWith("iconify")).join(" ");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineSatoriTransformer } from "../utils.js";
|
|
2
|
+
function safeSplit(s) {
|
|
3
|
+
const [key, value] = s.split(":");
|
|
4
|
+
return [String(key || "").trim(), String(value || "").trim()];
|
|
5
|
+
}
|
|
6
|
+
export default defineSatoriTransformer({
|
|
7
|
+
filter: (node) => !!node.props?.class,
|
|
8
|
+
transform: async (node, ctx) => {
|
|
9
|
+
const classes = node.props.class || "";
|
|
10
|
+
const styles = node.props.style || {};
|
|
11
|
+
const replacedClasses = /* @__PURE__ */ new Set();
|
|
12
|
+
for (const token of classes.split(" ").filter((c) => c.trim())) {
|
|
13
|
+
const parsedToken = await ctx.unocss.parseToken(token);
|
|
14
|
+
if (parsedToken) {
|
|
15
|
+
const inlineStyles = String(parsedToken?.[0]?.[2]).split(";").filter((s) => !!s?.trim());
|
|
16
|
+
const vars = {
|
|
17
|
+
"--color-gray-50": "249 250 251",
|
|
18
|
+
"--color-gray-100": "243 244 246",
|
|
19
|
+
"--color-gray-200": "229 231 235",
|
|
20
|
+
"--color-gray-300": "209 213 219",
|
|
21
|
+
"--color-gray-400": "156 163 175",
|
|
22
|
+
"--color-gray-500": "107 114 128",
|
|
23
|
+
"--color-gray-600": "75 85 99",
|
|
24
|
+
"--color-gray-700": "55 65 81",
|
|
25
|
+
"--color-gray-800": "31 41 55",
|
|
26
|
+
"--color-gray-900": "17 24 39",
|
|
27
|
+
"--color-gray-950": "3 7 18"
|
|
28
|
+
};
|
|
29
|
+
inlineStyles.filter((s) => s.startsWith("--")).forEach((s) => {
|
|
30
|
+
const [key, value] = safeSplit(s);
|
|
31
|
+
vars[key] = value;
|
|
32
|
+
});
|
|
33
|
+
inlineStyles.filter((s) => !s.startsWith("--")).forEach((s) => {
|
|
34
|
+
const [key, value] = safeSplit(s);
|
|
35
|
+
const camelCasedKey = key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
36
|
+
if (!styles[camelCasedKey])
|
|
37
|
+
styles[camelCasedKey] = value.replace(/var\((.*?)\)/g, (_, k) => vars[k.trim()]);
|
|
38
|
+
if (styles[camelCasedKey] && styles[camelCasedKey].includes("/")) {
|
|
39
|
+
const [rgb, opacity] = styles[camelCasedKey].split("/");
|
|
40
|
+
if (rgb && opacity) {
|
|
41
|
+
if (opacity.trim() === "1)")
|
|
42
|
+
styles[camelCasedKey] = rgb.replace(/(\d+) (\d+) (\d+).*/, (_, r, g, b) => `${r}, ${g}, ${b})`);
|
|
43
|
+
else
|
|
44
|
+
styles[camelCasedKey] = `${rgb.replace("rgb", "rgba").replaceAll(" ", ", ")}${opacity.trim()}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
replacedClasses.add(token);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
node.props.class = classes.split(" ").filter((c) => !replacedClasses.has(c)).join(" ");
|
|
52
|
+
node.props.tw = classes.split(" ").filter((c) => !replacedClasses.has(c)).join(" ");
|
|
53
|
+
node.props.style = styles;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { fontCache } from "#og-image-cache";
|
|
2
|
+
import { theme } from "#og-image-virtual/unocss-config.mjs";
|
|
3
|
+
import compatibility from "#og-image/compatibility";
|
|
4
|
+
import { defu } from "defu";
|
|
5
|
+
import { sendError } from "h3";
|
|
6
|
+
import { normaliseFontInput } from "../../../shared.js";
|
|
7
|
+
import { useOgImageRuntimeConfig } from "../../utils.js";
|
|
8
|
+
import { loadFont } from "./font.js";
|
|
9
|
+
import { useResvg, useSatori, useSharp } from "./instances.js";
|
|
10
|
+
import { createVNodes } from "./vnodes.js";
|
|
11
|
+
const fontPromises = {};
|
|
12
|
+
async function resolveFonts(event) {
|
|
13
|
+
const { fonts } = useOgImageRuntimeConfig();
|
|
14
|
+
const normalisedFonts = normaliseFontInput([...event.options.fonts || [], ...fonts]);
|
|
15
|
+
const localFontPromises = [];
|
|
16
|
+
const preloadedFonts = [];
|
|
17
|
+
if (fontCache) {
|
|
18
|
+
for (const font of normalisedFonts) {
|
|
19
|
+
if (await fontCache.hasItem(font.cacheKey)) {
|
|
20
|
+
font.data = await fontCache.getItemRaw(font.cacheKey) || void 0;
|
|
21
|
+
preloadedFonts.push(font);
|
|
22
|
+
} else {
|
|
23
|
+
if (!fontPromises[font.cacheKey]) {
|
|
24
|
+
fontPromises[font.cacheKey] = loadFont(event, font).then(async (_font) => {
|
|
25
|
+
if (_font?.data)
|
|
26
|
+
await fontCache?.setItemRaw(_font.cacheKey, _font.data);
|
|
27
|
+
return _font;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
localFontPromises.push(fontPromises[font.cacheKey]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const awaitedFonts = await Promise.all(localFontPromises);
|
|
35
|
+
return [...preloadedFonts, ...awaitedFonts].map((_f) => {
|
|
36
|
+
return { name: _f.name, data: _f.data, style: _f.style, weight: Number(_f.weight) };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export async function createSvg(event) {
|
|
40
|
+
const { options } = event;
|
|
41
|
+
const { satoriOptions: _satoriOptions } = useOgImageRuntimeConfig();
|
|
42
|
+
const [satori, vnodes, fonts] = await Promise.all([
|
|
43
|
+
useSatori(),
|
|
44
|
+
createVNodes(event),
|
|
45
|
+
resolveFonts(event)
|
|
46
|
+
]);
|
|
47
|
+
await event._nitro.hooks.callHook("nuxt-og-image:satori:vnodes", vnodes, event);
|
|
48
|
+
const satoriOptions = defu(options.satori, _satoriOptions, {
|
|
49
|
+
fonts,
|
|
50
|
+
tailwindConfig: { theme },
|
|
51
|
+
embedFont: true,
|
|
52
|
+
width: options.width,
|
|
53
|
+
height: options.height
|
|
54
|
+
});
|
|
55
|
+
return satori(vnodes, satoriOptions).catch((err) => {
|
|
56
|
+
return sendError(event.e, err, import.meta.dev);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async function createPng(event) {
|
|
60
|
+
const { resvgOptions } = useOgImageRuntimeConfig();
|
|
61
|
+
const svg = await createSvg(event);
|
|
62
|
+
if (!svg)
|
|
63
|
+
throw new Error("Failed to create SVG");
|
|
64
|
+
const Resvg = await useResvg();
|
|
65
|
+
const resvg = new Resvg(svg, defu(
|
|
66
|
+
event.options.resvg,
|
|
67
|
+
resvgOptions
|
|
68
|
+
));
|
|
69
|
+
const pngData = resvg.render();
|
|
70
|
+
return pngData.asPng();
|
|
71
|
+
}
|
|
72
|
+
async function createJpeg(event) {
|
|
73
|
+
const { sharpOptions } = useOgImageRuntimeConfig();
|
|
74
|
+
if (compatibility.sharp === false) {
|
|
75
|
+
if (import.meta.dev) {
|
|
76
|
+
throw new Error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime.");
|
|
77
|
+
} else {
|
|
78
|
+
console.error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime. Falling back to png.");
|
|
79
|
+
}
|
|
80
|
+
return createPng(event);
|
|
81
|
+
}
|
|
82
|
+
const svg = await createSvg(event);
|
|
83
|
+
if (!svg) {
|
|
84
|
+
throw new Error("Failed to create SVG for JPEG rendering.");
|
|
85
|
+
}
|
|
86
|
+
const svgBuffer = Buffer.from(svg);
|
|
87
|
+
const sharp = await useSharp().catch(() => {
|
|
88
|
+
if (import.meta.dev) {
|
|
89
|
+
throw new Error("Sharp dependency could not be loaded. Please check you have it installed and are using a compatible runtime.");
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
});
|
|
93
|
+
if (!sharp) {
|
|
94
|
+
console.error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime. Falling back to png.");
|
|
95
|
+
return createPng(event);
|
|
96
|
+
}
|
|
97
|
+
const options = defu(event.options.sharp, sharpOptions);
|
|
98
|
+
return sharp(svgBuffer, options).jpeg(options).toBuffer();
|
|
99
|
+
}
|
|
100
|
+
const SatoriRenderer = {
|
|
101
|
+
name: "satori",
|
|
102
|
+
supportedFormats: ["png", "jpeg", "jpg", "json"],
|
|
103
|
+
async createImage(e) {
|
|
104
|
+
switch (e.extension) {
|
|
105
|
+
case "png":
|
|
106
|
+
return createPng(e);
|
|
107
|
+
case "jpeg":
|
|
108
|
+
case "jpg":
|
|
109
|
+
return createJpeg(e);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
async debug(e) {
|
|
113
|
+
const [vnodes, svg] = await Promise.all([
|
|
114
|
+
createVNodes(e),
|
|
115
|
+
createSvg(e)
|
|
116
|
+
]);
|
|
117
|
+
return {
|
|
118
|
+
vnodes,
|
|
119
|
+
svg
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export default SatoriRenderer;
|