nuxt-og-image 6.7.4 → 6.7.6
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/chunks/tw4.cjs +2 -2
- package/dist/chunks/tw4.mjs +2 -2
- package/dist/chunks/uno.cjs +20 -5
- package/dist/chunks/uno.mjs +19 -5
- package/dist/cli.cjs +8 -2
- package/dist/cli.mjs +8 -2
- package/dist/devtools/lib/og-image/rpc.ts +4 -1
- package/dist/module.cjs +2 -2
- package/dist/module.json +2 -2
- package/dist/module.mjs +2 -2
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.d.ts +2 -1
- package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +3 -1
- package/dist/runtime/app/plugins/route-rule-og-image.server.d.ts +2 -1
- package/dist/runtime/app/plugins/route-rule-og-image.server.js +3 -1
- package/dist/runtime/app/utils/plugins.js +4 -10
- package/dist/runtime/logger.js +2 -6
- package/dist/runtime/pure.d.ts +0 -1
- package/dist/runtime/pure.js +0 -5
- package/dist/runtime/server/og-image/bindings/browser/chrome-launcher.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/browser/cloudflare.d.ts +1 -2
- package/dist/runtime/server/og-image/bindings/browser/cloudflare.js +2 -9
- package/dist/runtime/server/og-image/bindings/browser/on-demand.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/browser/playwright.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.js +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +27 -13
- package/dist/runtime/server/og-image/bindings/font-assets/external-url.js +3 -1
- package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/node.js +4 -2
- package/dist/runtime/server/og-image/bindings/resvg/node-dev.js +18 -64
- package/dist/runtime/server/og-image/bindings/takumi/node-dev.js +26 -83
- package/dist/runtime/server/og-image/bindings/worker-queue.d.ts +34 -0
- package/dist/runtime/server/og-image/bindings/worker-queue.js +150 -0
- package/dist/runtime/server/og-image/browser/renderer.js +1 -1
- package/dist/runtime/server/og-image/context.d.ts +1 -1
- package/dist/runtime/server/og-image/context.js +2 -3
- package/dist/runtime/server/og-image/core/plugins/imageSrc.js +1 -1
- package/dist/runtime/server/og-image/core/transforms/emojis/local.d.ts +2 -17
- package/dist/runtime/server/og-image/core/transforms/emojis/local.js +1 -1
- package/dist/runtime/server/og-image/devtools.d.ts +1 -1
- package/dist/runtime/server/og-image/devtools.js +1 -1
- package/dist/runtime/server/og-image/fonts.d.ts +1 -1
- package/dist/runtime/server/og-image/fonts.js +3 -1
- package/dist/runtime/server/og-image/templates/html.js +1 -1
- package/dist/runtime/server/plugins/prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/prerender.js +2 -2
- package/dist/runtime/server/routes/__zero-runtime/image.d.ts +1 -1
- package/dist/runtime/server/routes/__zero-runtime/image.js +1 -1
- package/dist/runtime/server/routes/debug.json.d.ts +1 -10
- package/dist/runtime/server/routes/debug.json.js +1 -1
- package/dist/runtime/server/routes/image.d.ts +1 -1
- package/dist/runtime/server/routes/image.js +1 -1
- package/dist/runtime/server/routes/resolve.d.ts +1 -1
- package/dist/runtime/server/routes/resolve.js +1 -1
- package/dist/runtime/server/util/cache.d.ts +1 -6
- package/dist/runtime/server/util/cache.js +2 -2
- package/dist/runtime/server/util/cloudflare.d.ts +3 -0
- package/dist/runtime/server/util/cloudflare.js +17 -0
- package/dist/runtime/server/util/cloudflareAssets.d.ts +1 -1
- package/dist/runtime/server/util/cloudflareAssets.js +8 -5
- package/dist/runtime/server/util/encoding.d.ts +0 -1
- package/dist/runtime/server/util/encoding.js +0 -7
- package/dist/runtime/server/util/eventHandlers.d.ts +1 -1
- package/dist/runtime/server/util/eventHandlers.js +1 -1
- package/dist/runtime/server/util/fetchLocalAsset.d.ts +1 -1
- package/dist/runtime/server/util/kit.d.ts +7 -4
- package/dist/runtime/server/util/kit.js +4 -19
- package/dist/runtime/server/util/logger.js +2 -6
- package/dist/runtime/server/util/options.js +1 -1
- package/dist/runtime/server/util/query.d.ts +1 -1
- package/dist/runtime/server/util/timings.d.ts +0 -3
- package/dist/runtime/server/util/timings.js +0 -3
- package/dist/runtime/server/utils.d.ts +1 -1
- package/dist/runtime/server/utils.js +7 -4
- package/dist/runtime/types.d.ts +11 -9
- package/dist/shared/{nuxt-og-image.Bv8VSGTj.mjs → nuxt-og-image.BIbfn5xQ.mjs} +146 -108
- package/dist/shared/{nuxt-og-image.BRBtdkUp.cjs → nuxt-og-image.CdpC3njh.cjs} +148 -107
- package/package.json +57 -48
- package/types/virtual.d.ts +15 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function toRecord(value) {
|
|
2
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
3
|
+
}
|
|
4
|
+
export function getCloudflareEnv(event) {
|
|
5
|
+
const runtime = event && "runtime" in event ? toRecord(event.runtime) : void 0;
|
|
6
|
+
const runtimeCloudflare = toRecord(runtime?.cloudflare);
|
|
7
|
+
const runtimeEnv = toRecord(runtimeCloudflare?.env);
|
|
8
|
+
if (runtimeEnv)
|
|
9
|
+
return runtimeEnv;
|
|
10
|
+
const contextCloudflare = toRecord(event?.context.cloudflare);
|
|
11
|
+
const contextEnv = toRecord(contextCloudflare?.env);
|
|
12
|
+
if (contextEnv)
|
|
13
|
+
return contextEnv;
|
|
14
|
+
const platform = toRecord(event?.context._platform);
|
|
15
|
+
const platformCloudflare = toRecord(platform?.cloudflare);
|
|
16
|
+
return toRecord(platformCloudflare?.env);
|
|
17
|
+
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getRequestURL } from "#nuxtseo/h3";
|
|
2
|
+
import { getCloudflareEnv } from "./cloudflare.js";
|
|
2
3
|
export function getCloudflareAssets(event) {
|
|
3
|
-
const assets = event
|
|
4
|
-
return assets && typeof assets.fetch === "function" ? assets : void 0;
|
|
4
|
+
const assets = getCloudflareEnv(event)?.ASSETS || event.context.ASSETS;
|
|
5
|
+
return typeof assets === "object" && assets !== null && "fetch" in assets && typeof assets.fetch === "function" ? assets : void 0;
|
|
5
6
|
}
|
|
6
7
|
export async function tryCloudflareAssetsFetch(event, path, signal) {
|
|
7
8
|
const assets = getCloudflareAssets(event);
|
|
8
9
|
if (!assets)
|
|
9
10
|
return;
|
|
10
|
-
const origin =
|
|
11
|
+
const origin = getRequestURL(event).origin;
|
|
11
12
|
const url = new URL(path, origin).href;
|
|
12
|
-
const res = await assets.fetch(url, signal ? { signal } : void 0).catch(() =>
|
|
13
|
+
const res = await assets.fetch(url, signal ? { signal } : void 0).catch(() => {
|
|
14
|
+
return null;
|
|
15
|
+
});
|
|
13
16
|
if (!res || !res.ok)
|
|
14
17
|
return;
|
|
15
18
|
return res.arrayBuffer();
|
|
@@ -20,10 +20,3 @@ export function decodeHtml(html) {
|
|
|
20
20
|
return String.fromCharCode(Number.parseInt(int));
|
|
21
21
|
}).replace(RE_AMP, "&");
|
|
22
22
|
}
|
|
23
|
-
export function decodeObjectHtmlEntities(obj) {
|
|
24
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
25
|
-
if (typeof value === "string")
|
|
26
|
-
obj[key] = decodeHtml(value);
|
|
27
|
-
});
|
|
28
|
-
return obj;
|
|
29
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
1
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
2
2
|
export declare function imageEventHandler(e: H3Event): Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError, getRequestHost, H3Error, setHeader } from "h3";
|
|
1
|
+
import { createError, getRequestHost, H3Error, setHeader } from "#nuxtseo/h3";
|
|
2
2
|
import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
|
|
3
3
|
import { logger } from "../../logger.js";
|
|
4
4
|
import { getBuildCachedImage, setBuildCachedImage } from "../og-image/cache/buildCache.js";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
import type { NitroRouteRules } from 'nitropack';
|
|
3
1
|
import type { NuxtIslandResponse } from 'nuxt/app';
|
|
4
|
-
|
|
2
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
3
|
+
import type { OgImageOptions } from '../../types.js';
|
|
4
|
+
interface OgImageRouteRules {
|
|
5
|
+
ogImage?: false | OgImageOptions & Record<string, any>;
|
|
6
|
+
}
|
|
5
7
|
export declare function fetchIsland(e: H3Event, component: string, props: Record<string, any>, timeout?: number): Promise<NuxtIslandResponse>;
|
|
6
|
-
export declare function createNitroRouteRuleMatcher(): ((path: string) =>
|
|
8
|
+
export declare function createNitroRouteRuleMatcher(): ((path: string) => OgImageRouteRules);
|
|
9
|
+
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRuntimeConfig } from "
|
|
3
|
-
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
4
|
-
import { withoutBase, withoutTrailingSlash } from "ufo";
|
|
1
|
+
import { createNitroRouteRuleMatcher as createRouteRuleMatcher } from "nuxtseo-shared/server";
|
|
2
|
+
import { fetchWithEvent, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
5
3
|
import { getIslandHash } from "#og-image/island-hash";
|
|
6
|
-
export { withoutQuery } from "nuxtseo-shared/utils";
|
|
7
4
|
export function fetchIsland(e, component, props, timeout) {
|
|
8
5
|
const hashId = getIslandHash({ name: component, props });
|
|
9
6
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
|
10
|
-
return e
|
|
7
|
+
return fetchWithEvent(e, `/__nuxt_island/${component}_${hashId}.json`, {
|
|
11
8
|
params: {
|
|
12
9
|
props: JSON.stringify(props)
|
|
13
10
|
},
|
|
@@ -16,17 +13,5 @@ export function fetchIsland(e, component, props, timeout) {
|
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
15
|
export function createNitroRouteRuleMatcher() {
|
|
19
|
-
|
|
20
|
-
const _routeRulesMatcher = toRouteMatcher(
|
|
21
|
-
createRadixRouter({
|
|
22
|
-
routes: Object.fromEntries(
|
|
23
|
-
Object.entries(nitro?.routeRules || {}).map(([path, rules]) => [withoutTrailingSlash(path), rules])
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
return (path) => {
|
|
28
|
-
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
29
|
-
withoutBase(withoutTrailingSlash(path.split("?")[0]), app.baseURL)
|
|
30
|
-
).reverse());
|
|
31
|
-
};
|
|
16
|
+
return createRouteRuleMatcher(useRuntimeConfig());
|
|
32
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError } from "h3";
|
|
1
|
+
import { createError } from "#nuxtseo/h3";
|
|
2
2
|
import { componentNames } from "#og-image-virtual/component-names.mjs";
|
|
3
3
|
const RENDERER_SUFFIXES = ["satori", "browser", "takumi"];
|
|
4
4
|
const RE_RENDERER_SUFFIX_DOT = /\.?(satori|browser|takumi)$/i;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
1
|
import { joinURL } from "ufo";
|
|
2
|
+
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { componentNames } from "#og-image-virtual/component-names.mjs";
|
|
4
4
|
import { buildOgImageUrl } from "../shared.js";
|
|
5
|
+
import { getCloudflareEnv } from "./util/cloudflare.js";
|
|
5
6
|
export function getOgImagePath(_pagePath, _options) {
|
|
6
7
|
const baseURL = useRuntimeConfig().app.baseURL;
|
|
7
8
|
const { defaults, security } = useOgImageRuntimeConfig();
|
|
@@ -20,9 +21,11 @@ export function getOgImagePath(_pagePath, _options) {
|
|
|
20
21
|
}
|
|
21
22
|
export function useOgImageRuntimeConfig(e) {
|
|
22
23
|
const c = useRuntimeConfig(e);
|
|
23
|
-
const moduleCfg = c["nuxt-og-image"]
|
|
24
|
-
const cloudflareEnv = e
|
|
25
|
-
const
|
|
24
|
+
const moduleCfg = c["nuxt-og-image"];
|
|
25
|
+
const cloudflareEnv = getCloudflareEnv(e);
|
|
26
|
+
const runtimeSecret = c.ogImage?.secret;
|
|
27
|
+
const cloudflareSecret = cloudflareEnv?.NUXT_OG_IMAGE_SECRET;
|
|
28
|
+
const overrideSecret = typeof runtimeSecret === "string" && runtimeSecret ? runtimeSecret : typeof cloudflareSecret === "string" ? cloudflareSecret : void 0;
|
|
26
29
|
const security = overrideSecret ? { ...moduleCfg.security || {}, secret: overrideSecret } : moduleCfg.security;
|
|
27
30
|
return {
|
|
28
31
|
defaults: {},
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { ResvgRenderOptions } from '@resvg/resvg-js';
|
|
2
2
|
import type { AllowedComponentProps, Component, ComponentCustomProps, VNodeProps } from '@vue/runtime-core';
|
|
3
|
-
import type { H3Error, H3Event } from 'h3';
|
|
4
|
-
import type { Hookable } from 'hookable';
|
|
5
|
-
import type { NitroRuntimeHooks } from 'nitropack/types';
|
|
6
3
|
import type { SatoriOptions } from 'satori';
|
|
7
4
|
import type { JpegOptions, SharpOptions } from 'sharp';
|
|
8
5
|
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
6
|
+
import type { H3Error, H3Event } from '#nuxtseo/h3';
|
|
9
7
|
import type { Timings } from './server/util/timings.js';
|
|
10
|
-
interface NitroApp {
|
|
11
|
-
hooks: Hookable<NitroRuntimeHooks>;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}
|
|
14
8
|
export interface OgImageRenderEventContext {
|
|
15
9
|
e: H3Event;
|
|
16
10
|
extension: 'png' | 'jpeg' | 'jpg' | 'webp' | 'svg' | 'html' | 'json';
|
|
@@ -22,10 +16,19 @@ export interface OgImageRenderEventContext {
|
|
|
22
16
|
publicStoragePath: string;
|
|
23
17
|
runtimeConfig: OgImageRuntimeConfig;
|
|
24
18
|
timings: Timings;
|
|
25
|
-
_nitro:
|
|
19
|
+
_nitro: ReturnType<typeof import('#nuxtseo/nitro').useNitroApp>;
|
|
26
20
|
}
|
|
27
21
|
export type IconifyEmojiIconSets = 'twemoji' | 'noto' | 'fluent-emoji' | 'fluent-emoji-flat' | 'fluent-emoji-high-contrast' | 'noto-v1' | 'emojione' | 'emojione-monotone' | 'emojione-v1' | 'streamline-emojis' | 'openmoji';
|
|
28
22
|
export type EmojiStrategy = 'auto' | 'local' | 'fetch';
|
|
23
|
+
export interface OgImageIconsData {
|
|
24
|
+
icons: Record<string, {
|
|
25
|
+
body: string;
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
}>;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}
|
|
29
32
|
export interface OgImageRuntimeConfig {
|
|
30
33
|
version: string;
|
|
31
34
|
satoriOptions: SatoriOptions;
|
|
@@ -298,4 +301,3 @@ export interface SocialPreviewMetaData {
|
|
|
298
301
|
export interface RouteRulesOgImage extends Partial<OgImageOptions> {
|
|
299
302
|
[key: string]: any;
|
|
300
303
|
}
|
|
301
|
-
export {};
|