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,9 @@
|
|
|
1
|
+
import { Launcher } from "chrome-launcher";
|
|
2
|
+
import playwrightCore from "playwright-core";
|
|
3
|
+
const chromePath = Launcher.getFirstInstallation();
|
|
4
|
+
export async function createBrowser() {
|
|
5
|
+
return playwrightCore.chromium.launch({
|
|
6
|
+
headless: true,
|
|
7
|
+
executablePath: chromePath
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createConsola } from "consola";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import playwrightCore from "playwright-core";
|
|
4
|
+
let installedChromium = false;
|
|
5
|
+
let installChromiumPromise;
|
|
6
|
+
export async function createBrowser() {
|
|
7
|
+
if (installChromiumPromise)
|
|
8
|
+
await installChromiumPromise;
|
|
9
|
+
if (!installedChromium) {
|
|
10
|
+
installChromiumPromise = new Promise((_resolve) => {
|
|
11
|
+
const logger = createConsola().withTag("Nuxt OG Image");
|
|
12
|
+
logger.info("Installing Chromium install for og:image generation...");
|
|
13
|
+
const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
|
|
14
|
+
stdio: "pipe"
|
|
15
|
+
});
|
|
16
|
+
if (installChromeProcess.stderr) {
|
|
17
|
+
installChromeProcess.stderr.pipe(process.stderr);
|
|
18
|
+
}
|
|
19
|
+
if (installChromeProcess.stdout) {
|
|
20
|
+
installChromeProcess.stdout.pipe(process.stdout);
|
|
21
|
+
}
|
|
22
|
+
new Promise((resolve) => {
|
|
23
|
+
installChromeProcess.on("exit", (e) => {
|
|
24
|
+
if (e !== 0)
|
|
25
|
+
logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
|
|
26
|
+
resolve();
|
|
27
|
+
});
|
|
28
|
+
}).then(() => {
|
|
29
|
+
installChromeProcess.kill();
|
|
30
|
+
logger.info("Installed Chromium install for og:image generation.");
|
|
31
|
+
_resolve();
|
|
32
|
+
});
|
|
33
|
+
}).then(() => {
|
|
34
|
+
installedChromium = true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return await playwrightCore.chromium.launch({
|
|
38
|
+
headless: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
initWasmPromise: Promise<void>;
|
|
3
|
+
Resvg: new (svg: Uint8Array | string, options?: import("@resvg/resvg-wasm").ResvgRenderOptions) => {
|
|
4
|
+
free(): void;
|
|
5
|
+
render(): {
|
|
6
|
+
free(): void;
|
|
7
|
+
asPng(): Uint8Array;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
readonly pixels: Uint8Array;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
};
|
|
12
|
+
toString(): string;
|
|
13
|
+
innerBBox(): {
|
|
14
|
+
free(): void;
|
|
15
|
+
height: number;
|
|
16
|
+
width: number;
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | undefined;
|
|
20
|
+
getBBox(): {
|
|
21
|
+
free(): void;
|
|
22
|
+
height: number;
|
|
23
|
+
width: number;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
cropByBBox(bbox: {
|
|
28
|
+
free(): void;
|
|
29
|
+
height: number;
|
|
30
|
+
width: number;
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
}): void;
|
|
34
|
+
imagesToResolve(): any[];
|
|
35
|
+
resolveImage(href: string, buffer: Uint8Array): void;
|
|
36
|
+
readonly height: number;
|
|
37
|
+
readonly width: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
initWasmPromise: Promise<void>;
|
|
3
|
+
Resvg: new (svg: Uint8Array | string, options?: import("@resvg/resvg-wasm").ResvgRenderOptions) => {
|
|
4
|
+
free(): void;
|
|
5
|
+
render(): {
|
|
6
|
+
free(): void;
|
|
7
|
+
asPng(): Uint8Array;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
readonly pixels: Uint8Array;
|
|
10
|
+
readonly width: number;
|
|
11
|
+
};
|
|
12
|
+
toString(): string;
|
|
13
|
+
innerBBox(): {
|
|
14
|
+
free(): void;
|
|
15
|
+
height: number;
|
|
16
|
+
width: number;
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | undefined;
|
|
20
|
+
getBBox(): {
|
|
21
|
+
free(): void;
|
|
22
|
+
height: number;
|
|
23
|
+
width: number;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
cropByBBox(bbox: {
|
|
28
|
+
free(): void;
|
|
29
|
+
height: number;
|
|
30
|
+
width: number;
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
}): void;
|
|
34
|
+
imagesToResolve(): any[];
|
|
35
|
+
resolveImage(href: string, buffer: Uint8Array): void;
|
|
36
|
+
readonly height: number;
|
|
37
|
+
readonly width: number;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _satori, { init } from "satori/wasm";
|
|
2
|
+
import initYoga from "yoga-wasm-web";
|
|
3
|
+
import { readWasmFile } from "../../../util/wasm.js";
|
|
4
|
+
const wasm = readWasmFile("yoga-wasm-web/dist/yoga.wasm").then(async (yoga) => await initYoga(yoga));
|
|
5
|
+
export default {
|
|
6
|
+
initWasmPromise: new Promise((resolve) => {
|
|
7
|
+
wasm.then((yoga) => {
|
|
8
|
+
init(yoga);
|
|
9
|
+
resolve();
|
|
10
|
+
});
|
|
11
|
+
}),
|
|
12
|
+
satori: _satori
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { init } from "satori";
|
|
2
|
+
import _satori from "satori/wasm";
|
|
3
|
+
import initYoga from "yoga-wasm-web";
|
|
4
|
+
const wasm = import("yoga-wasm-web/dist/yoga.wasm?module").then(async (yoga) => await initYoga(yoga.default || yoga));
|
|
5
|
+
export default {
|
|
6
|
+
initWasmPromise: new Promise((resolve) => {
|
|
7
|
+
wasm.then((yoga) => {
|
|
8
|
+
init(yoga);
|
|
9
|
+
resolve();
|
|
10
|
+
});
|
|
11
|
+
}),
|
|
12
|
+
satori: _satori
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Storage } from 'unstorage';
|
|
2
|
+
import type { OgImageOptions } from '../../../types.js';
|
|
3
|
+
export declare const htmlPayloadCache: Storage<{
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
value: OgImageOptions;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const prerenderOptionsCache: Storage<OgImageOptions> | undefined;
|
|
8
|
+
export declare const fontCache: Storage<BufferSource>;
|
|
9
|
+
export declare const emojiCache: Storage<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createStorage } from "unstorage";
|
|
2
|
+
import lruCacheDriver from "unstorage/drivers/lru-cache";
|
|
3
|
+
export const htmlPayloadCache = createStorage({
|
|
4
|
+
// short cache time so we don't need many entries at runtime
|
|
5
|
+
driver: lruCacheDriver({ max: import.meta.prerender ? 1e4 : 50 })
|
|
6
|
+
});
|
|
7
|
+
export const prerenderOptionsCache = import.meta.prerender ? createStorage({
|
|
8
|
+
driver: lruCacheDriver({ max: 1e4 })
|
|
9
|
+
}) : void 0;
|
|
10
|
+
export const fontCache = createStorage({
|
|
11
|
+
driver: lruCacheDriver({ max: 10 })
|
|
12
|
+
});
|
|
13
|
+
export const emojiCache = createStorage({
|
|
14
|
+
driver: lruCacheDriver({ max: 1e3 })
|
|
15
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Storage } from 'unstorage';
|
|
2
|
+
import type { OgImageOptions } from '../../../types.js';
|
|
3
|
+
export declare const htmlPayloadCache: Storage<{
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
value: OgImageOptions;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const prerenderOptionsCache: Storage<OgImageOptions> | undefined;
|
|
8
|
+
export declare const fontCache: Storage<OgImageOptions<"NuxtSeo">>;
|
|
9
|
+
export declare const emojiCache: Storage<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createStorage } from "unstorage";
|
|
2
|
+
import memoryDriver from "unstorage/drivers/memory";
|
|
3
|
+
const storage = createStorage({
|
|
4
|
+
driver: memoryDriver()
|
|
5
|
+
});
|
|
6
|
+
export const htmlPayloadCache = storage;
|
|
7
|
+
export const prerenderOptionsCache = storage;
|
|
8
|
+
export const fontCache = storage;
|
|
9
|
+
export const emojiCache = storage;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createBrowser } from "#og-image/bindings/chromium";
|
|
2
|
+
import { createError } from "h3";
|
|
3
|
+
import { createScreenshot } from "./screenshot.js";
|
|
4
|
+
const ChromiumRenderer = {
|
|
5
|
+
name: "chromium",
|
|
6
|
+
supportedFormats: ["png", "jpeg", "jpg"],
|
|
7
|
+
async debug() {
|
|
8
|
+
return {};
|
|
9
|
+
},
|
|
10
|
+
async createImage(ctx) {
|
|
11
|
+
const browser = await createBrowser();
|
|
12
|
+
const screenshot = await createScreenshot(ctx, browser).catch((e) => e);
|
|
13
|
+
await browser.close();
|
|
14
|
+
if (screenshot instanceof Error) {
|
|
15
|
+
return createError({
|
|
16
|
+
statusCode: 400,
|
|
17
|
+
cause: screenshot,
|
|
18
|
+
statusMessage: `[Nuxt OG Image] Failed to create screenshot ${screenshot.message}.`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return screenshot;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export default ChromiumRenderer;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Buffer } from 'node:buffer';
|
|
2
|
+
import type { Browser } from 'playwright-core';
|
|
3
|
+
import type { OgImageRenderEventContext } from '../../../types.js';
|
|
4
|
+
export declare function createScreenshot({ basePath, e, options, extension }: OgImageRenderEventContext, browser: Browser): Promise<Buffer>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useNitroOrigin } from "#site-config/server/composables";
|
|
2
|
+
import { joinURL, withQuery } from "ufo";
|
|
3
|
+
import { toValue } from "vue";
|
|
4
|
+
import { useOgImageRuntimeConfig } from "../../utils.js";
|
|
5
|
+
export async function createScreenshot({ basePath, e, options, extension }, browser) {
|
|
6
|
+
const { colorPreference } = useOgImageRuntimeConfig();
|
|
7
|
+
const path = options.component === "PageScreenshot" ? basePath : joinURL("/__og-image__/image", basePath, `og.html`);
|
|
8
|
+
const page = await browser.newPage({
|
|
9
|
+
colorScheme: colorPreference || "no-preference",
|
|
10
|
+
baseURL: useNitroOrigin(e)
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
if (import.meta.prerender && !options.html) {
|
|
14
|
+
options.html = await e.$fetch(path).catch(() => void 0);
|
|
15
|
+
}
|
|
16
|
+
await page.setViewportSize({
|
|
17
|
+
width: toValue(options.width) || 1200,
|
|
18
|
+
height: toValue(options.height) || 630
|
|
19
|
+
});
|
|
20
|
+
if (options.html) {
|
|
21
|
+
const html = options.html;
|
|
22
|
+
await page.evaluate((html2) => {
|
|
23
|
+
document.open("text/html");
|
|
24
|
+
document.write(html2);
|
|
25
|
+
document.close();
|
|
26
|
+
}, html);
|
|
27
|
+
await page.waitForLoadState("networkidle");
|
|
28
|
+
} else {
|
|
29
|
+
await page.goto(withQuery(path, options.props), {
|
|
30
|
+
timeout: 1e4,
|
|
31
|
+
waitUntil: "networkidle"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const screenshotOptions = {
|
|
35
|
+
timeout: 1e4,
|
|
36
|
+
animations: "disabled",
|
|
37
|
+
type: extension === "png" ? "png" : "jpeg"
|
|
38
|
+
};
|
|
39
|
+
const _options = options.screenshot || {};
|
|
40
|
+
if (_options.delay)
|
|
41
|
+
await page.waitForTimeout(_options.delay);
|
|
42
|
+
if (_options.mask) {
|
|
43
|
+
await page.evaluate((mask) => {
|
|
44
|
+
for (const el of document.querySelectorAll(mask))
|
|
45
|
+
el.style.display = "none";
|
|
46
|
+
}, _options.mask);
|
|
47
|
+
}
|
|
48
|
+
if (_options.selector)
|
|
49
|
+
return await page.locator(_options.selector).screenshot(screenshotOptions);
|
|
50
|
+
return await page.screenshot(screenshotOptions);
|
|
51
|
+
} finally {
|
|
52
|
+
await page.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { H3Error, H3Event } from 'h3';
|
|
2
|
+
import type { OgImageOptions, OgImageRenderEventContext } from '../../types.js';
|
|
3
|
+
export declare function resolvePathCacheKey(e: H3Event, path: string): string;
|
|
4
|
+
export declare function resolveContext(e: H3Event): Promise<H3Error | OgImageRenderEventContext>;
|
|
5
|
+
export declare function extractAndNormaliseOgImageOptions(html: string): OgImageOptions | false;
|