nuxt-og-image 3.0.0-rc.30 → 3.0.0-rc.31
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 +52 -50
- package/dist/client/404.html +52 -50
- package/dist/client/_nuxt/{IconCSS.CZ8ZjA39.js → IconCSS.V7-3N1ew.js} +1 -1
- package/dist/client/_nuxt/IconCSS.avVk0m4D.css +1 -0
- package/dist/client/_nuxt/{angular-html.ngCY688K.js → angular-html.ulaXK71i.js} +1 -1
- package/dist/client/_nuxt/{angular-ts.JfRveWw0.js → angular-ts.CpB8xVpe.js} +2 -2
- package/dist/client/_nuxt/{apl.ojEktQcO.js → apl.XB4V8Q_3.js} +1 -1
- package/dist/client/_nuxt/{astro.bVipJGkW.js → astro.5Up4Y-tq.js} +1 -1
- package/dist/client/_nuxt/{blade.HvKjdph-.js → blade.dLd1FX1V.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/e8c2abb1-c2da-455e-a7e8-26f4f28b10f9.json +1 -0
- package/dist/client/_nuxt/{cobol.DIpfQcy2.js → cobol.yHzQax91.js} +1 -1
- package/dist/client/_nuxt/{coffee.09Ode5TL.js → coffee.UjKhX0iS.js} +1 -1
- package/dist/client/_nuxt/{crystal.KqWgScGa.js → crystal.ePodXjZr.js} +1 -1
- package/dist/client/_nuxt/{csharp.SlsguwGx.js → csharp.xHVQI8QI.js} +5 -4
- package/dist/client/_nuxt/{elixir.Q1fiwhg2.js → elixir.dYoE9A9d.js} +1 -1
- package/dist/client/_nuxt/{entry.OczI2MjB.css → entry.DjkITzvC.css} +1 -1
- package/dist/client/_nuxt/{entry.v1zp98GR.js → entry.LuO6Nylf.js} +59 -59
- package/dist/client/_nuxt/{erb.K_ppY6Ln.js → erb.vCu37omy.js} +1 -1
- package/dist/client/_nuxt/{error-404.VV5ycc25.js → error-404.DE_aZn4X.js} +1 -1
- package/dist/client/_nuxt/{error-500.VNY3c4OJ.js → error-500.4nIEY5y_.js} +1 -1
- package/dist/client/_nuxt/fortran-fixed-form.5oVt_150.js +1 -0
- package/dist/client/_nuxt/fortran-free-form.l6j6vfmD.js +1 -0
- package/dist/client/_nuxt/fsharp.5TASvPJ1.js +1 -0
- package/dist/client/_nuxt/glimmer-js.8faD3vw8.js +13 -0
- package/dist/client/_nuxt/glimmer-ts.I8Eofu1P.js +13 -0
- package/dist/client/_nuxt/go.U2NlzxIl.js +1 -0
- package/dist/client/_nuxt/{graphql.Mw2TwDQV.js → graphql.aYTh5yPU.js} +1 -1
- package/dist/client/_nuxt/{hack.8bxbrxw3.js → hack.9pFjhnG2.js} +1 -1
- package/dist/client/_nuxt/{haml.9njXWWYk.js → haml.DYCf5dhF.js} +1 -1
- package/dist/client/_nuxt/{handlebars.e6aZXt-Z.js → handlebars.Z9TIkDUw.js} +1 -1
- package/dist/client/_nuxt/{html.q2IluNCo.js → html.ZVb9jHrO.js} +1 -1
- package/dist/client/_nuxt/{http.suDZEQUg.js → http.McgS7Vpm.js} +1 -1
- package/dist/client/_nuxt/{imba.Shm_xfQD.js → imba.guICF3zN.js} +1 -1
- package/dist/client/_nuxt/{javascript.4rbEI_qn.js → javascript.JMZ6uy5M.js} +1 -1
- package/dist/client/_nuxt/{jinja.E4nwqofd.js → jinja.H2a5aKFq.js} +1 -1
- package/dist/client/_nuxt/{jison.gkHJeffy.js → jison.hEN1Pilr.js} +1 -1
- package/dist/client/_nuxt/{jsx.O5ZRGASz.js → jsx.3LZ_BoLB.js} +1 -1
- package/dist/client/_nuxt/{julia.ku4F-e-8.js → julia.zN5MNt1V.js} +2 -2
- package/dist/client/_nuxt/latex.Pwsy_OsJ.js +3 -0
- package/dist/client/_nuxt/{liquid.O0W9gNJ1.js → liquid.UuwAmqmc.js} +1 -1
- package/dist/client/_nuxt/{marko.sELZHXF6.js → marko.gbQhFTQa.js} +1 -1
- package/dist/client/_nuxt/{nim.OZ1TiK9r.js → nim.16czfBCm.js} +1 -1
- package/dist/client/_nuxt/{perl.CaKiGeyl.js → perl._x09KDDb.js} +1 -1
- package/dist/client/_nuxt/{php.Q2jqa0n_.js → php.2PDLwZAX.js} +1 -1
- package/dist/client/_nuxt/{pug.dmyiUMO7.js → pug.ieZS468c.js} +1 -1
- package/dist/client/_nuxt/{razor.X4IfBpol.js → razor.wPI2afgP.js} +1 -1
- package/dist/client/_nuxt/{rst.GKtlS3h3.js → rst.Nzb5IGfi.js} +1 -1
- package/dist/client/_nuxt/{ruby.P9eGVNW4.js → ruby.oOCDDplm.js} +1 -1
- package/dist/client/_nuxt/rust.yNm59Dur.js +1 -0
- package/dist/client/_nuxt/{svelte.6zdtIlwM.js → svelte.j-bqdsch.js} +1 -1
- package/dist/client/_nuxt/{tsx.vbVEYvAd.js → tsx.7LxggtAE.js} +1 -1
- package/dist/client/_nuxt/{twig.h5iAhXmS.js → twig.p6WenPmw.js} +1 -1
- package/dist/client/_nuxt/{typescript.IWNmnGsa.js → typescript.HpdcmTOD.js} +1 -1
- package/dist/client/_nuxt/{vue-html.B2XvVFLk.js → vue-html.TGyjH-sv.js} +1 -1
- package/dist/client/_nuxt/{vue.CmUal76M.js → vue.AKvPdve9.js} +1 -1
- package/dist/client/index.html +52 -50
- package/dist/module.d.mts +6 -0
- package/dist/module.d.ts +6 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +97 -44
- package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/wasm-fs.mjs +1 -1
- package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/wasm.mjs +1 -1
- package/dist/runtime/{core → nitro/og-image}/bindings/resvg/wasm-fs.mjs +1 -1
- package/dist/runtime/{core → nitro/og-image}/bindings/resvg/wasm.mjs +1 -1
- package/dist/runtime/{core → nitro/og-image}/bindings/satori/wasm-fs.mjs +1 -1
- package/dist/runtime/{core → nitro/og-image}/bindings/satori/wasm.mjs +1 -1
- package/dist/runtime/nitro/og-image/cache.d.ts +7 -0
- package/dist/runtime/{core/cache/htmlPayload.mjs → nitro/og-image/cache.mjs} +3 -0
- package/dist/runtime/{core/renderers → nitro/og-image}/chromium/screenshot.mjs +1 -1
- package/dist/runtime/nitro/og-image/context.d.ts +5 -0
- package/dist/runtime/nitro/og-image/context.mjs +177 -0
- package/dist/runtime/nitro/og-image/instances.d.ts +2 -0
- package/dist/runtime/nitro/og-image/instances.mjs +10 -0
- package/dist/runtime/{core/font/fetch.d.ts → nitro/og-image/satori/font.d.ts} +1 -1
- package/dist/runtime/nitro/og-image/satori/font.mjs +32 -0
- package/dist/runtime/{core/renderers → nitro/og-image}/satori/instances.d.ts +0 -2
- package/dist/runtime/{core/renderers → nitro/og-image}/satori/instances.mjs +0 -10
- package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/encoding.mjs +1 -1
- package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/imageSrc.mjs +2 -4
- package/dist/runtime/{core/renderers/satori/index.mjs → nitro/og-image/satori/renderer.mjs} +24 -12
- package/dist/runtime/{core/html/applyEmojis.d.ts → nitro/og-image/satori/transforms/emojis.d.ts} +3 -1
- package/dist/runtime/{core/html/applyEmojis.mjs → nitro/og-image/satori/transforms/emojis.mjs} +6 -2
- package/dist/runtime/{core/html/applyInlineCss.d.ts → nitro/og-image/satori/transforms/inlineCss.d.ts} +1 -1
- package/dist/runtime/{core/html/applyInlineCss.mjs → nitro/og-image/satori/transforms/inlineCss.mjs} +1 -1
- package/dist/runtime/{core/renderers → nitro/og-image}/satori/vnodes.mjs +5 -5
- package/dist/runtime/nitro/og-image/templates/html.d.ts +2 -0
- package/dist/runtime/{core/html/devIframeTemplate.mjs → nitro/og-image/templates/html.mjs} +15 -8
- package/dist/runtime/nitro/plugins/nuxt-content.mjs +1 -1
- package/dist/runtime/nitro/plugins/prerender.mjs +4 -5
- package/dist/runtime/nitro/routes/{__og-image__/debug.json.d.ts → debug.json.d.ts} +1 -1
- package/dist/runtime/nitro/routes/{__og-image__/debug.json.mjs → debug.json.mjs} +1 -1
- package/dist/runtime/nitro/routes/{__og-image__/font-[name]-[weight].[extension].mjs → font.mjs} +2 -9
- package/dist/runtime/nitro/routes/{__og-image__/image.mjs → image.mjs} +6 -10
- package/dist/runtime/{cache.d.ts → nitro/util/cache.d.ts} +1 -1
- package/dist/runtime/nitro/util/encoding.d.ts +3 -0
- package/dist/runtime/nitro/util/encoding.mjs +15 -0
- package/dist/runtime/nitro/util/kit.d.ts +6 -0
- package/dist/runtime/nitro/{kit.mjs → util/kit.mjs} +9 -0
- package/dist/runtime/{components → nuxt/components}/OgImage/OgImage.d.ts +1 -1
- package/dist/runtime/{components → nuxt/components}/OgImage/OgImageScreenshot.d.ts +1 -1
- package/dist/runtime/{components → nuxt/components}/Templates/Community/NuxtSeo.vue +1 -1
- package/dist/runtime/{composables → nuxt/composables}/defineOgImage.d.ts +1 -1
- package/dist/runtime/{composables → nuxt/composables}/defineOgImage.mjs +3 -3
- package/dist/runtime/{composables → nuxt/composables}/defineOgImageComponent.d.ts +1 -1
- package/dist/runtime/{composables → nuxt/composables}/defineOgImageScreenshot.d.ts +1 -1
- package/dist/runtime/nuxt/composables/mock.d.ts +0 -0
- package/dist/runtime/nuxt/composables/mock.mjs +6 -0
- package/dist/runtime/nuxt/plugins/og-image-canonical-urls.server.mjs +1 -1
- package/dist/runtime/nuxt/plugins/route-rule-og-image.server.mjs +1 -1
- package/dist/runtime/nuxt/utils.d.ts +1 -1
- package/dist/runtime/nuxt/utils.mjs +1 -1
- package/dist/runtime/{utils.pure.d.ts → pure.d.ts} +1 -0
- package/dist/runtime/{utils.pure.mjs → pure.mjs} +10 -0
- package/dist/runtime/{utils.d.ts → shared.d.ts} +1 -1
- package/dist/runtime/{utils.mjs → shared.mjs} +1 -1
- package/dist/runtime/types.d.ts +4 -0
- package/package.json +13 -11
- package/dist/client/_nuxt/IconCSS.UISSK5sv.css +0 -1
- package/dist/client/_nuxt/builds/meta/bb98bdc4-cb43-44eb-b961-cca8b9050d48.json +0 -1
- package/dist/client/_nuxt/fsharp.37PDbGQ_.js +0 -1
- package/dist/client/_nuxt/glimmer-js.OxCy_kio.js +0 -1
- package/dist/client/_nuxt/glimmer-ts.ZLbawe8H.js +0 -1
- package/dist/client/_nuxt/go.2bJKq9hO.js +0 -1
- package/dist/client/_nuxt/latex.6xV8tHRw.js +0 -3
- package/dist/client/_nuxt/rust.FLHuhIzG.js +0 -1
- package/dist/runtime/core/cache/emojis.d.ts +0 -1
- package/dist/runtime/core/cache/emojis.mjs +0 -5
- package/dist/runtime/core/cache/fonts.d.ts +0 -3
- package/dist/runtime/core/cache/fonts.mjs +0 -6
- package/dist/runtime/core/cache/htmlPayload.d.ts +0 -5
- package/dist/runtime/core/cache/prerender.d.ts +0 -2
- package/dist/runtime/core/cache/prerender.mjs +0 -5
- package/dist/runtime/core/env/assets.d.ts +0 -1
- package/dist/runtime/core/env/assets.mjs +0 -11
- package/dist/runtime/core/font/fetch.mjs +0 -39
- package/dist/runtime/core/html/devIframeTemplate.d.ts +0 -2
- package/dist/runtime/core/html/fetchIsland.d.ts +0 -3
- package/dist/runtime/core/html/fetchIsland.mjs +0 -17
- package/dist/runtime/core/options/extract.d.ts +0 -4
- package/dist/runtime/core/options/extract.mjs +0 -58
- package/dist/runtime/core/options/fetch.d.ts +0 -3
- package/dist/runtime/core/options/fetch.mjs +0 -32
- package/dist/runtime/core/utils/resolveRendererContext.d.ts +0 -3
- package/dist/runtime/core/utils/resolveRendererContext.mjs +0 -92
- package/dist/runtime/nitro/kit.d.ts +0 -3
- package/dist/runtime/nitro/utils.d.ts +0 -2
- package/dist/runtime/nitro/utils.mjs +0 -16
- package/dist/runtime/server/assets/inter-latin-ext-400-normal.woff +0 -0
- package/dist/runtime/server/assets/inter-latin-ext-700-normal.woff +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/chrome-launcher.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/chrome-launcher.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/on-demand.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/on-demand.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/playwright.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/chromium/playwright.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/node.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/node.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/wasm-fs.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/css-inline/wasm.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/resvg/node.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/resvg/node.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/resvg/wasm-fs.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/resvg/wasm.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/satori/node.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/satori/node.mjs +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/satori/wasm-fs.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/satori/wasm.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/sharp/node.d.ts +0 -0
- /package/dist/runtime/{core → nitro/og-image}/bindings/sharp/node.mjs +0 -0
- /package/dist/runtime/{core/renderers/chromium/index.d.ts → nitro/og-image/chromium/renderer.d.ts} +0 -0
- /package/dist/runtime/{core/renderers/chromium/index.mjs → nitro/og-image/chromium/renderer.mjs} +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/chromium/screenshot.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/emojis.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/emojis.mjs +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/encoding.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/flex.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/flex.mjs +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/imageSrc.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/twClasses.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/twClasses.mjs +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/unocss.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/plugins/unocss.mjs +0 -0
- /package/dist/runtime/{core/renderers/satori/index.d.ts → nitro/og-image/satori/renderer.d.ts} +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/utils.d.ts +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/utils.mjs +0 -0
- /package/dist/runtime/{core/renderers → nitro/og-image}/satori/vnodes.d.ts +0 -0
- /package/dist/runtime/nitro/routes/{__og-image__/font-[name]-[weight].[extension].d.ts → font.d.ts} +0 -0
- /package/dist/runtime/nitro/routes/{__og-image__/image.d.ts → image.d.ts} +0 -0
- /package/dist/runtime/{cache.mjs → nitro/util/cache.mjs} +0 -0
- /package/dist/runtime/{core/utils → nitro/util}/wasm.d.ts +0 -0
- /package/dist/runtime/{core/utils → nitro/util}/wasm.mjs +0 -0
- /package/dist/runtime/{components → nuxt/components}/OgImage/OgImage.mjs +0 -0
- /package/dist/runtime/{components → nuxt/components}/OgImage/OgImageScreenshot.mjs +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/BrandedLogo.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/Nuxt.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/Pergel.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/SimpleBlog.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/UnJs.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/Wave.vue +0 -0
- /package/dist/runtime/{components → nuxt/components}/Templates/Community/WithEmoji.vue +0 -0
- /package/dist/runtime/{composables → nuxt/composables}/defineOgImageComponent.mjs +0 -0
- /package/dist/runtime/{composables → nuxt/composables}/defineOgImageScreenshot.mjs +0 -0
|
@@ -4,3 +4,6 @@ export const htmlPayloadCache = createStorage({
|
|
|
4
4
|
// short cache time so we don't need many entries at runtime
|
|
5
5
|
driver: lruCacheDriver({ max: import.meta.prerender ? 1e3 : 50 })
|
|
6
6
|
});
|
|
7
|
+
export const prerenderOptionsCache = import.meta.prerender ? createStorage({
|
|
8
|
+
driver: lruCacheDriver({ max: 1e3 })
|
|
9
|
+
}) : void 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { joinURL, withQuery } from "ufo";
|
|
2
|
-
import { useOgImageRuntimeConfig } from "../../../
|
|
2
|
+
import { useOgImageRuntimeConfig } from "../../../shared.mjs";
|
|
3
3
|
import { useNitroOrigin } from "#imports";
|
|
4
4
|
export async function createScreenshot({ basePath, e, options, extension }, browser) {
|
|
5
5
|
const { colorPreference } = useOgImageRuntimeConfig();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { H3Error, H3Event } from 'h3';
|
|
2
|
+
import type { OgImageOptions, OgImageRenderEventContext } from '../../types';
|
|
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;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { parseURL, withQuery, withoutLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
2
|
+
import { createError, getQuery } from "h3";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
import { normalizeKey } from "unstorage";
|
|
5
|
+
import { hash } from "ohash";
|
|
6
|
+
import { separateProps, useOgImageRuntimeConfig } from "../../shared.mjs";
|
|
7
|
+
import { createNitroRouteRuleMatcher } from "../util/kit.mjs";
|
|
8
|
+
import { decodeObjectHtmlEntities } from "../util/encoding.mjs";
|
|
9
|
+
import { htmlPayloadCache, prerenderOptionsCache } from "./cache.mjs";
|
|
10
|
+
import { useChromiumRenderer, useSatoriRenderer } from "./instances.mjs";
|
|
11
|
+
import { useNitroApp } from "#internal/nitro";
|
|
12
|
+
export function resolvePathCacheKey(e, path) {
|
|
13
|
+
const siteConfig = e.context.siteConfig.get();
|
|
14
|
+
const basePath = withoutTrailingSlash(withoutLeadingSlash(normalizeKey(path || e.path)));
|
|
15
|
+
return [
|
|
16
|
+
!basePath || basePath === "/" ? "index" : basePath,
|
|
17
|
+
hash([
|
|
18
|
+
basePath,
|
|
19
|
+
siteConfig.url,
|
|
20
|
+
hash(getQuery(e))
|
|
21
|
+
])
|
|
22
|
+
].join(":");
|
|
23
|
+
}
|
|
24
|
+
export async function resolveContext(e) {
|
|
25
|
+
const runtimeConfig = useOgImageRuntimeConfig();
|
|
26
|
+
const path = parseURL(e.path).pathname;
|
|
27
|
+
const extension = path.split(".").pop();
|
|
28
|
+
if (!extension) {
|
|
29
|
+
return createError({
|
|
30
|
+
statusCode: 400,
|
|
31
|
+
statusMessage: `[Nuxt OG Image] Missing OG Image type.`
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (!["png", "jpeg", "jpg", "svg", "html", "json"].includes(extension)) {
|
|
35
|
+
return createError({
|
|
36
|
+
statusCode: 400,
|
|
37
|
+
statusMessage: `[Nuxt OG Image] Unknown OG Image type ${extension}.`
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
let queryParams = { ...getQuery(e) };
|
|
41
|
+
queryParams.props = JSON.parse(queryParams.props || "{}");
|
|
42
|
+
queryParams = separateProps(queryParams);
|
|
43
|
+
let basePath = withoutTrailingSlash(
|
|
44
|
+
path.replace(`/__og-image__/image`, "").replace(`/og.${extension}`, "")
|
|
45
|
+
);
|
|
46
|
+
if (queryParams._query)
|
|
47
|
+
basePath = withQuery(basePath, JSON.parse(queryParams._query));
|
|
48
|
+
const isDebugJsonPayload = extension === "json" && runtimeConfig.debug;
|
|
49
|
+
const key = resolvePathCacheKey(e, basePath);
|
|
50
|
+
let options = queryParams.options;
|
|
51
|
+
if (!options) {
|
|
52
|
+
if (import.meta.prerender)
|
|
53
|
+
options = await prerenderOptionsCache?.getItem(key);
|
|
54
|
+
if (!options) {
|
|
55
|
+
const payload = await fetchPathHtmlAndExtractOptions(e, basePath, key);
|
|
56
|
+
if (payload instanceof Error)
|
|
57
|
+
return payload;
|
|
58
|
+
options = payload;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
delete queryParams.options;
|
|
62
|
+
const routeRuleMatcher = createNitroRouteRuleMatcher();
|
|
63
|
+
const routeRules = routeRuleMatcher(basePath);
|
|
64
|
+
if (typeof routeRules.ogImage === "undefined" && !options) {
|
|
65
|
+
return createError({
|
|
66
|
+
statusCode: 400,
|
|
67
|
+
statusMessage: "The route is missing the Nuxt OG Image payload or route rules."
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const ogImageRouteRules = separateProps(routeRules.ogImage);
|
|
71
|
+
options = defu(queryParams, ogImageRouteRules, options, runtimeConfig.defaults);
|
|
72
|
+
if (!options) {
|
|
73
|
+
return createError({
|
|
74
|
+
statusCode: 404,
|
|
75
|
+
statusMessage: "[Nuxt OG Image] OG Image not found."
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
let renderer;
|
|
79
|
+
switch (options.renderer) {
|
|
80
|
+
case "satori":
|
|
81
|
+
renderer = await useSatoriRenderer();
|
|
82
|
+
break;
|
|
83
|
+
case "chromium":
|
|
84
|
+
renderer = await useChromiumRenderer();
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (!renderer || renderer.__unenv__) {
|
|
88
|
+
throw createError({
|
|
89
|
+
statusCode: 400,
|
|
90
|
+
statusMessage: `[Nuxt OG Image] Renderer ${options.renderer} is missing.`
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const ctx = {
|
|
94
|
+
e,
|
|
95
|
+
key,
|
|
96
|
+
renderer,
|
|
97
|
+
isDebugJsonPayload,
|
|
98
|
+
extension,
|
|
99
|
+
basePath,
|
|
100
|
+
options,
|
|
101
|
+
_nitro: useNitroApp()
|
|
102
|
+
};
|
|
103
|
+
await ctx._nitro.hooks.callHook("nuxt-og-image:context", ctx);
|
|
104
|
+
return ctx;
|
|
105
|
+
}
|
|
106
|
+
export function extractAndNormaliseOgImageOptions(html) {
|
|
107
|
+
const htmlPayload = html.match(/<script.+id="nuxt-og-image-options"[^>]*>(.+?)<\/script>/)?.[1];
|
|
108
|
+
if (!htmlPayload)
|
|
109
|
+
return false;
|
|
110
|
+
let options;
|
|
111
|
+
try {
|
|
112
|
+
const payload2 = JSON.parse(htmlPayload);
|
|
113
|
+
Object.entries(payload2).forEach(([key, value]) => {
|
|
114
|
+
if (!value)
|
|
115
|
+
delete payload2[key];
|
|
116
|
+
});
|
|
117
|
+
options = payload2;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
if (import.meta.dev)
|
|
120
|
+
console.warn("Failed to parse #nuxt-og-image-options", e, options);
|
|
121
|
+
}
|
|
122
|
+
if (!options)
|
|
123
|
+
return false;
|
|
124
|
+
const description = html.match(/<meta[^>]+name="description"[^>]*>/)?.[0];
|
|
125
|
+
if (description) {
|
|
126
|
+
const [, content] = description.match(/content="([^"]+)"/) || [];
|
|
127
|
+
if (content && !options.props.description)
|
|
128
|
+
options.props.description = content;
|
|
129
|
+
}
|
|
130
|
+
const payload = decodeObjectHtmlEntities(options);
|
|
131
|
+
if (import.meta.dev) {
|
|
132
|
+
const socialPreview = {};
|
|
133
|
+
const socialMetaTags = html.match(/<meta[^>]+(property|name)="(twitter|og):([^"]+)"[^>]*>/g);
|
|
134
|
+
if (socialMetaTags) {
|
|
135
|
+
socialMetaTags.forEach((tag) => {
|
|
136
|
+
const [, , type, key] = tag.match(/(property|name)="(twitter|og):([^"]+)"/);
|
|
137
|
+
const value = tag.match(/content="([^"]+)"/)?.[1];
|
|
138
|
+
if (!value)
|
|
139
|
+
return;
|
|
140
|
+
if (!socialPreview[type])
|
|
141
|
+
socialPreview[type] = {};
|
|
142
|
+
socialPreview[type][key] = value;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
payload.socialPreview = socialPreview;
|
|
146
|
+
}
|
|
147
|
+
return payload;
|
|
148
|
+
}
|
|
149
|
+
async function fetchPathHtmlAndExtractOptions(e, path, key) {
|
|
150
|
+
const cachedHtmlPayload = await htmlPayloadCache.getItem(key);
|
|
151
|
+
if (cachedHtmlPayload && cachedHtmlPayload.expiresAt < Date.now())
|
|
152
|
+
return cachedHtmlPayload.value;
|
|
153
|
+
let html;
|
|
154
|
+
try {
|
|
155
|
+
html = await e.$fetch(path);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
return createError({
|
|
158
|
+
statusCode: 500,
|
|
159
|
+
statusMessage: `[Nuxt OG Image] Failed to read the path ${path} for og-image extraction. ${err.message}.`
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (typeof html !== "string") {
|
|
163
|
+
return createError({
|
|
164
|
+
statusCode: 500,
|
|
165
|
+
statusMessage: `[Nuxt OG Image] Got invalid response from ${path} for og-image extraction.`
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const payload = extractAndNormaliseOgImageOptions(html);
|
|
169
|
+
if (payload) {
|
|
170
|
+
await htmlPayloadCache.setItem(key, {
|
|
171
|
+
// 60 minutes for prerender, 10 seconds for runtime
|
|
172
|
+
expiresAt: Date.now() + 1e3 * (import.meta.prerender ? 60 * 60 : 10),
|
|
173
|
+
value: payload
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return payload;
|
|
177
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const satoriRendererInstance = { instance: void 0 };
|
|
2
|
+
const chromiumRendererInstance = { instance: void 0 };
|
|
3
|
+
export async function useSatoriRenderer() {
|
|
4
|
+
satoriRendererInstance.instance = satoriRendererInstance.instance || await import("#nuxt-og-image/renderers/satori").then((m) => m.default);
|
|
5
|
+
return satoriRendererInstance.instance;
|
|
6
|
+
}
|
|
7
|
+
export async function useChromiumRenderer() {
|
|
8
|
+
chromiumRendererInstance.instance = chromiumRendererInstance.instance || await import("#nuxt-og-image/renderers/chromium").then((m) => m.default);
|
|
9
|
+
return chromiumRendererInstance.instance;
|
|
10
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { OgImageRenderEventContext, ResolvedFontConfig } from '
|
|
1
|
+
import type { OgImageRenderEventContext, ResolvedFontConfig } from '../../../types';
|
|
2
2
|
export declare function loadFont({ e }: OgImageRenderEventContext, font: ResolvedFontConfig): Promise<ResolvedFontConfig>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { setHeader } from "h3";
|
|
2
|
+
import { prefixStorage } from "unstorage";
|
|
3
|
+
import { getExtension } from "../../../pure.mjs";
|
|
4
|
+
import { useNitroOrigin, useStorage } from "#imports";
|
|
5
|
+
const assets = prefixStorage(useStorage(), "/assets");
|
|
6
|
+
export async function loadFont({ e }, font) {
|
|
7
|
+
const { name, weight } = font;
|
|
8
|
+
if (font.data)
|
|
9
|
+
return font;
|
|
10
|
+
if (font.key && await assets.hasItem(font.key)) {
|
|
11
|
+
setHeader(e, "Content-Type", `font/${getExtension(font.path)}`);
|
|
12
|
+
const fontData = await assets.getItemRaw(font.key);
|
|
13
|
+
font.data = Buffer.from(fontData, "base64");
|
|
14
|
+
return font;
|
|
15
|
+
}
|
|
16
|
+
let data;
|
|
17
|
+
if (font.path) {
|
|
18
|
+
data = await e.$fetch(font.path, {
|
|
19
|
+
baseURL: useNitroOrigin(e),
|
|
20
|
+
responseType: "arrayBuffer"
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
data = await e.$fetch(`/__og-image__/font/${name}/${weight}.ttf`, {
|
|
24
|
+
responseType: "arrayBuffer",
|
|
25
|
+
query: {
|
|
26
|
+
font
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
font.data = data;
|
|
31
|
+
return font;
|
|
32
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type _satori from 'satori';
|
|
2
|
-
export declare function useSatoriRenderer(): Promise<import("../../../types").Renderer>;
|
|
3
|
-
export declare function useChromiumRenderer(): Promise<import("../../../types").Renderer>;
|
|
4
2
|
export declare function useResvg(): Promise<new (svg: string | Uint8Array, options?: import("@resvg/resvg-wasm").ResvgRenderOptions | undefined) => {
|
|
5
3
|
free(): void;
|
|
6
4
|
render(): {
|
|
@@ -2,16 +2,6 @@ const cssInlineInstance = { instance: void 0 };
|
|
|
2
2
|
const sharpInstance = { instance: void 0 };
|
|
3
3
|
const resvgInstance = { instance: void 0 };
|
|
4
4
|
const satoriInstance = { instance: void 0 };
|
|
5
|
-
const satoriRendererInstance = { instance: void 0 };
|
|
6
|
-
const chromiumRendererInstance = { instance: void 0 };
|
|
7
|
-
export async function useSatoriRenderer() {
|
|
8
|
-
satoriRendererInstance.instance = satoriRendererInstance.instance || await import("#nuxt-og-image/renderers/satori").then((m) => m.default);
|
|
9
|
-
return satoriRendererInstance.instance;
|
|
10
|
-
}
|
|
11
|
-
export async function useChromiumRenderer() {
|
|
12
|
-
chromiumRendererInstance.instance = chromiumRendererInstance.instance || await import("#nuxt-og-image/renderers/chromium").then((m) => m.default);
|
|
13
|
-
return chromiumRendererInstance.instance;
|
|
14
|
-
}
|
|
15
5
|
export async function useResvg() {
|
|
16
6
|
resvgInstance.instance = resvgInstance.instance || await import("#nuxt-og-image/bindings/resvg").then((m) => m.default);
|
|
17
7
|
await resvgInstance.instance.initWasmPromise;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Buffer } from "node:buffer";
|
|
2
1
|
import { withBase } from "ufo";
|
|
3
2
|
import sizeOf from "image-size";
|
|
4
3
|
import { defineSatoriTransformer } from "../utils.mjs";
|
|
5
|
-
import { toBase64Image } from "
|
|
6
|
-
import { useStorage } from "#
|
|
7
|
-
import { useNitroOrigin } from "#imports";
|
|
4
|
+
import { toBase64Image } from "../../../../pure.mjs";
|
|
5
|
+
import { useNitroOrigin, useStorage } from "#imports";
|
|
8
6
|
export default defineSatoriTransformer([
|
|
9
7
|
// fix <img src="">
|
|
10
8
|
{
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { createStorage } from "unstorage";
|
|
3
|
+
import lruCacheDriver from "unstorage/drivers/lru-cache";
|
|
4
|
+
import { normaliseFontInput, useOgImageRuntimeConfig } from "../../../shared.mjs";
|
|
5
|
+
import { loadFont } from "./font.mjs";
|
|
5
6
|
import { createVNodes } from "./vnodes.mjs";
|
|
6
7
|
import { useResvg, useSatori, useSharp } from "./instances.mjs";
|
|
7
8
|
import { theme } from "#nuxt-og-image/unocss-config.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const fontPromises = {};
|
|
10
|
+
const fontCache = createStorage({
|
|
11
|
+
driver: lruCacheDriver({ max: 10 })
|
|
12
|
+
});
|
|
13
|
+
async function resolveFonts(event) {
|
|
14
|
+
const { fonts } = useOgImageRuntimeConfig();
|
|
13
15
|
const normalisedFonts = normaliseFontInput([...event.options.fonts || [], ...fonts]);
|
|
14
16
|
const localFontPromises = [];
|
|
15
17
|
const preloadedFonts = [];
|
|
@@ -29,11 +31,21 @@ export async function createSvg(event) {
|
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
const awaitedFonts = await Promise.all(localFontPromises);
|
|
32
|
-
|
|
34
|
+
return [...preloadedFonts, ...awaitedFonts].map((_f) => {
|
|
35
|
+
return { name: _f.name, data: _f.data, style: _f.style, weight: Number(_f.weight) };
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export async function createSvg(event) {
|
|
39
|
+
const { options } = event;
|
|
40
|
+
const { satoriOptions: _satoriOptions } = useOgImageRuntimeConfig();
|
|
41
|
+
const [satori, vnodes, fonts] = await Promise.all([
|
|
42
|
+
useSatori(),
|
|
43
|
+
createVNodes(event),
|
|
44
|
+
resolveFonts(event)
|
|
45
|
+
]);
|
|
46
|
+
await event._nitro.hooks.callHook("nuxt-og-image:satori:vnodes", vnodes, event);
|
|
33
47
|
const satoriOptions = defu(options.satori, _satoriOptions, {
|
|
34
|
-
fonts
|
|
35
|
-
return { name: _f.name, data: _f.data, style: _f.style, weight: Number(_f.weight) };
|
|
36
|
-
}),
|
|
48
|
+
fonts,
|
|
37
49
|
tailwindConfig: { theme },
|
|
38
50
|
embedFont: true,
|
|
39
51
|
width: options.width,
|
package/dist/runtime/{core/html/applyEmojis.d.ts → nitro/og-image/satori/transforms/emojis.d.ts}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { NuxtIslandResponse } from 'nuxt/dist/core/runtime/nitro/renderer';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Storage } from 'unstorage';
|
|
3
|
+
import type { OgImageRenderEventContext } from '../../../../types';
|
|
4
|
+
export declare const emojiCache: Storage<string>;
|
|
3
5
|
export declare function applyEmojis(ctx: OgImageRenderEventContext, island: NuxtIslandResponse): Promise<string | boolean>;
|
package/dist/runtime/{core/html/applyEmojis.mjs → nitro/og-image/satori/transforms/emojis.mjs}
RENAMED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import defaultCharMap from "@iconify-json/noto/chars.json";
|
|
2
|
-
import {
|
|
2
|
+
import { createStorage } from "unstorage";
|
|
3
|
+
import lruCacheDriver from "unstorage/drivers/lru-cache";
|
|
4
|
+
export const emojiCache = createStorage({
|
|
5
|
+
driver: lruCacheDriver({ max: 1e3 })
|
|
6
|
+
});
|
|
3
7
|
const RE_MATCH_EMOJIS = /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
4
8
|
export async function applyEmojis(ctx, island) {
|
|
5
9
|
const html = island.html;
|
|
@@ -15,7 +19,7 @@ export async function applyEmojis(ctx, island) {
|
|
|
15
19
|
if (await emojiCache.hasItem(key))
|
|
16
20
|
svg = await emojiCache.getItem(key);
|
|
17
21
|
if (!svg) {
|
|
18
|
-
svg = await
|
|
22
|
+
svg = await $fetch(`https://api.iconify.design/${ctx.options.emojis}/${emoji}.svg`, {
|
|
19
23
|
responseType: "text"
|
|
20
24
|
});
|
|
21
25
|
if (svg === "404")
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { NuxtIslandResponse } from 'nuxt/dist/core/runtime/nitro/renderer';
|
|
2
|
-
import type { OgImageRenderEventContext } from '
|
|
2
|
+
import type { OgImageRenderEventContext } from '../../../../types';
|
|
3
3
|
export declare function applyInlineCss({ e }: OgImageRenderEventContext, island: NuxtIslandResponse): Promise<boolean>;
|
package/dist/runtime/{core/html/applyInlineCss.mjs → nitro/og-image/satori/transforms/inlineCss.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCssInline } from "../
|
|
1
|
+
import { useCssInline } from "../instances.mjs";
|
|
2
2
|
import { useNitroOrigin } from "#imports";
|
|
3
3
|
import cssInline from "#nuxt-og-image/bindings/css-inline";
|
|
4
4
|
export async function applyInlineCss({ e }, island) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { html as convertHtmlToSatori } from "satori-html";
|
|
2
|
-
import { fetchIsland } from "../../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { fetchIsland } from "../../util/kit.mjs";
|
|
3
|
+
import { htmlDecodeQuotes } from "../../util/encoding.mjs";
|
|
4
|
+
import { applyInlineCss } from "./transforms/inlineCss.mjs";
|
|
5
|
+
import { applyEmojis } from "./transforms/emojis.mjs";
|
|
6
6
|
import { walkSatoriTree } from "./utils.mjs";
|
|
7
7
|
import unocss from "./plugins/unocss.mjs";
|
|
8
8
|
import emojis from "./plugins/emojis.mjs";
|
|
@@ -13,7 +13,7 @@ import encoding from "./plugins/encoding.mjs";
|
|
|
13
13
|
export async function createVNodes(ctx) {
|
|
14
14
|
let html = ctx.options.html;
|
|
15
15
|
if (!html) {
|
|
16
|
-
const island = await fetchIsland(ctx);
|
|
16
|
+
const island = await fetchIsland(ctx.e, ctx.options.component, typeof ctx.options.props !== "undefined" ? ctx.options.props : ctx.options);
|
|
17
17
|
island.html = htmlDecodeQuotes(island.html);
|
|
18
18
|
await applyInlineCss(ctx, island);
|
|
19
19
|
await applyEmojis(ctx, island);
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { createHeadCore } from "@unhead/vue";
|
|
2
2
|
import { renderSSRHead } from "@unhead/ssr";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { fetchIsland } from "
|
|
3
|
+
import { createError } from "h3";
|
|
4
|
+
import { normaliseFontInput, useOgImageRuntimeConfig } from "../../../shared.mjs";
|
|
5
|
+
import { fetchIsland } from "../../util/kit.mjs";
|
|
6
|
+
import { applyEmojis } from "../satori/transforms/emojis.mjs";
|
|
6
7
|
import { theme } from "#nuxt-og-image/unocss-config.mjs";
|
|
7
|
-
export async function
|
|
8
|
+
export async function html(ctx) {
|
|
8
9
|
const { options } = ctx;
|
|
9
10
|
const { fonts } = useOgImageRuntimeConfig();
|
|
10
|
-
|
|
11
|
+
if (!options.component) {
|
|
12
|
+
throw createError({
|
|
13
|
+
statusCode: 500,
|
|
14
|
+
statusMessage: `[Nuxt OG Image] Rendering an invalid component. Received options: ${JSON.stringify(options)}.`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const island = await fetchIsland(ctx.e, ctx.options.component, typeof ctx.options.props !== "undefined" ? ctx.options.props : ctx.options);
|
|
11
18
|
const head = createHeadCore();
|
|
12
19
|
head.push(island.head);
|
|
13
20
|
let defaultFontFamily = "sans-serif";
|
|
@@ -16,7 +23,7 @@ export async function devIframeTemplate(ctx) {
|
|
|
16
23
|
if (firstFont)
|
|
17
24
|
defaultFontFamily = firstFont.name;
|
|
18
25
|
await applyEmojis(ctx, island);
|
|
19
|
-
let
|
|
26
|
+
let html2 = island.html;
|
|
20
27
|
const googleFonts = {};
|
|
21
28
|
fonts.filter((font) => !font.path).forEach((font) => {
|
|
22
29
|
if (!googleFonts[font.name])
|
|
@@ -99,11 +106,11 @@ svg[data-emoji] {
|
|
|
99
106
|
})
|
|
100
107
|
]
|
|
101
108
|
});
|
|
102
|
-
|
|
109
|
+
html2 = html2.replaceAll(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
|
|
103
110
|
const headChunk = await renderSSRHead(head);
|
|
104
111
|
return `<!DOCTYPE html>
|
|
105
112
|
<html ${headChunk.htmlAttrs}>
|
|
106
113
|
<head>${headChunk.headTags}</head>
|
|
107
|
-
<body ${headChunk.bodyAttrs}>${headChunk.bodyTagsOpen}<div data-v-inspector-ignore="true" style="position: relative; display: flex; margin: 0 auto; width: ${options.width}px; height: ${options.height}px; overflow: hidden;">${
|
|
114
|
+
<body ${headChunk.bodyAttrs}>${headChunk.bodyTagsOpen}<div data-v-inspector-ignore="true" style="position: relative; display: flex; margin: 0 auto; width: ${options.width}px; height: ${options.height}px; overflow: hidden;">${html2}</div>${headChunk.bodyTags}</body>
|
|
108
115
|
</html>`;
|
|
109
116
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
-
import { getOgImagePath, useOgImageRuntimeConfig } from "../../
|
|
3
|
+
import { getOgImagePath, useOgImageRuntimeConfig } from "../../shared.mjs";
|
|
4
4
|
export default defineNitroPlugin((nitroApp) => {
|
|
5
5
|
const { isNuxtContentDocumentDriven, defaults } = useOgImageRuntimeConfig();
|
|
6
6
|
nitroApp.hooks.hook("content:file:afterParse", async (content) => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { parseURL } from "ufo";
|
|
2
2
|
import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";
|
|
3
|
-
import { extractAndNormaliseOgImageOptions } from "
|
|
4
|
-
import { prerenderOptionsCache } from "
|
|
5
|
-
import { isInternalRoute } from "../../
|
|
6
|
-
import {
|
|
7
|
-
import { createNitroRouteRuleMatcher } from "../kit.mjs";
|
|
3
|
+
import { extractAndNormaliseOgImageOptions, resolvePathCacheKey } from "../og-image/context.mjs";
|
|
4
|
+
import { prerenderOptionsCache } from "../og-image/cache.mjs";
|
|
5
|
+
import { isInternalRoute } from "../../pure.mjs";
|
|
6
|
+
import { createNitroRouteRuleMatcher } from "../util/kit.mjs";
|
|
8
7
|
export default defineNitroPlugin(async (nitro) => {
|
|
9
8
|
if (!import.meta.prerender)
|
|
10
9
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
2
2
|
componentNames: any;
|
|
3
|
-
runtimeConfig: import("
|
|
3
|
+
runtimeConfig: import("../../types").OgImageRuntimeConfig;
|
|
4
4
|
compatibility: any;
|
|
5
5
|
}>>;
|
|
6
6
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler, setHeader } from "h3";
|
|
2
|
-
import { useOgImageRuntimeConfig } from "
|
|
2
|
+
import { useOgImageRuntimeConfig } from "../../shared.mjs";
|
|
3
3
|
import compatibility from "#nuxt-og-image/compatibility";
|
|
4
4
|
import { componentNames } from "#nuxt-og-image/component-names.mjs";
|
|
5
5
|
export default defineEventHandler(async (e) => {
|
package/dist/runtime/nitro/routes/{__og-image__/font-[name]-[weight].[extension].mjs → font.mjs}
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { createError, defineEventHandler, getQuery, proxyRequest, sendRedirect
|
|
1
|
+
import { createError, defineEventHandler, getQuery, proxyRequest, sendRedirect } from "h3";
|
|
2
2
|
import { parseURL } from "ufo";
|
|
3
|
-
import {
|
|
4
|
-
import { assets } from "#internal/nitro/virtual/server-assets";
|
|
3
|
+
import { normaliseFontInput, useOgImageRuntimeConfig } from "../../shared.mjs";
|
|
5
4
|
export default defineEventHandler(async (e) => {
|
|
6
5
|
const path = parseURL(e.path).pathname;
|
|
7
6
|
const [_name, _weight] = path.split("/font/")[1].split(".")[0].split("/");
|
|
@@ -25,12 +24,6 @@ export default defineEventHandler(async (e) => {
|
|
|
25
24
|
statusMessage: `[Nuxt OG Image] Font ${name}:${weight} not found`
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
if (import.meta.dev || import.meta.prerender) {
|
|
29
|
-
if (font.key && await assets.hasItem(font.key)) {
|
|
30
|
-
setHeader(e, "Content-Type", `font/${getExtension(font.path)}`);
|
|
31
|
-
return assets.getItemRaw(font.key);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
27
|
const css = await globalThis.$fetch(`https://fonts.googleapis.com/css2?family=${name}:wght@${weight}`, {
|
|
35
28
|
headers: {
|
|
36
29
|
// Make sure it returns TTF.
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { H3Error, createError, defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useOgImageBufferCache } from "../../../cache.mjs";
|
|
7
|
-
import { useOgImageRuntimeConfig } from "../../../utils.mjs";
|
|
2
|
+
import { useOgImageBufferCache } from "../util/cache.mjs";
|
|
3
|
+
import { useOgImageRuntimeConfig } from "../../shared.mjs";
|
|
4
|
+
import { resolveContext } from "../og-image/context.mjs";
|
|
5
|
+
import { html } from "../og-image/templates/html.mjs";
|
|
8
6
|
export default defineEventHandler(async (e) => {
|
|
9
|
-
const ctx = await
|
|
7
|
+
const ctx = await resolveContext(e);
|
|
10
8
|
if (ctx instanceof H3Error)
|
|
11
9
|
return ctx;
|
|
12
10
|
const { isDebugJsonPayload, extension, options, renderer } = ctx;
|
|
@@ -18,8 +16,6 @@ export default defineEventHandler(async (e) => {
|
|
|
18
16
|
compatibilityHints.push("Converting PNGs to JPEGs requires Sharp which only runs on Node based systems.");
|
|
19
17
|
if (options.renderer === "chromium")
|
|
20
18
|
compatibilityHints.push("Using Chromium to generate images is only supported in Node based environments. It's recommended to only use this if you're prerendering");
|
|
21
|
-
if (options.component !== "PageScreenshot" && await applyInlineCss(ctx, await fetchIsland(ctx)))
|
|
22
|
-
compatibilityHints.push("Inlining CSS is not supported on Cloudflare.");
|
|
23
19
|
setHeader(e, "Content-Type", "application/json");
|
|
24
20
|
return {
|
|
25
21
|
siteConfig: {
|
|
@@ -34,7 +30,7 @@ export default defineEventHandler(async (e) => {
|
|
|
34
30
|
switch (extension) {
|
|
35
31
|
case "html":
|
|
36
32
|
setHeader(e, "Content-Type", `text/html`);
|
|
37
|
-
return
|
|
33
|
+
return html(ctx);
|
|
38
34
|
case "svg":
|
|
39
35
|
if (!debug && !import.meta.dev) {
|
|
40
36
|
return createError({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type H3Error } from 'h3';
|
|
2
|
-
import type { OgImageRenderEventContext } from '
|
|
2
|
+
import type { OgImageRenderEventContext } from '../../types';
|
|
3
3
|
export declare function useOgImageBufferCache(ctx: OgImageRenderEventContext, options: {
|
|
4
4
|
baseCacheKey: string | false;
|
|
5
5
|
cacheMaxAgeSeconds?: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function htmlDecodeQuotes(html) {
|
|
2
|
+
return html.replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'");
|
|
3
|
+
}
|
|
4
|
+
export function decodeHtml(html) {
|
|
5
|
+
return html.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#([0-9]+);/g, (full, int) => {
|
|
6
|
+
return String.fromCharCode(Number.parseInt(int));
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function decodeObjectHtmlEntities(obj) {
|
|
10
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
11
|
+
if (typeof value === "string")
|
|
12
|
+
obj[key] = decodeHtml(value);
|
|
13
|
+
});
|
|
14
|
+
return obj;
|
|
15
|
+
}
|