nuxt-og-image 6.7.6 → 6.7.7

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.
Files changed (32) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/chunks/decode.mjs +1087 -0
  3. package/dist/chunks/tw4.mjs +1 -1
  4. package/dist/chunks/uno.mjs +2 -2
  5. package/dist/module.d.ts +1 -1
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +1 -1
  8. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +5 -6
  9. package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +1 -1
  10. package/dist/runtime/server/og-image/bindings/font-assets/node.js +2 -3
  11. package/dist/runtime/server/og-image/browser/screenshot.js +2 -1
  12. package/dist/runtime/server/og-image/font-source.d.ts +3 -12
  13. package/dist/runtime/server/og-image/font-source.js +1 -4
  14. package/dist/runtime/server/og-image/fonts.d.ts +0 -7
  15. package/dist/runtime/server/og-image/fonts.js +1 -1
  16. package/dist/runtime/server/og-image/takumi/renderer.js +2 -2
  17. package/dist/runtime/server/routes/resolve.js +2 -1
  18. package/dist/runtime/server/util/fetchLocalAsset.d.ts +1 -1
  19. package/dist/runtime/server/util/fetchLocalAsset.js +2 -1
  20. package/dist/runtime/types.d.ts +1 -1
  21. package/dist/shared/{nuxt-og-image.BIbfn5xQ.mjs → nuxt-og-image.BMHzg1Vz.mjs} +227 -76
  22. package/package.json +21 -22
  23. package/dist/chunks/tw4.cjs +0 -493
  24. package/dist/chunks/uno.cjs +0 -249
  25. package/dist/cli.cjs +0 -1345
  26. package/dist/cli.d.cts +0 -1
  27. package/dist/content.cjs +0 -21
  28. package/dist/content.d.cts +0 -16
  29. package/dist/module.cjs +0 -39
  30. package/dist/module.d.cts +0 -219
  31. package/dist/shared/nuxt-og-image.CMYbz66P.cjs +0 -193
  32. package/dist/shared/nuxt-og-image.CdpC3njh.cjs +0 -5898
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import { resolveModulePath } from 'exsolve';
4
4
  import { dirname, join } from 'pathe';
5
- import { e as extractVariantBaseClasses, r as resolveVariantPrefixes, h as resolveExtractedVars, l as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, m as loadLightningCss, a as extractCssVars, c as extractUniversalVars, d as extractPerClassVars, g as extractVarsFromCss, f as extractClassStyles } from '../shared/nuxt-og-image.BIbfn5xQ.mjs';
5
+ import { e as extractVariantBaseClasses, r as resolveVariantPrefixes, h as resolveExtractedVars, l as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, m as loadLightningCss, a as extractCssVars, c as extractUniversalVars, d as extractPerClassVars, g as extractVarsFromCss, f as extractClassStyles } from '../shared/nuxt-og-image.BMHzg1Vz.mjs';
6
6
  import 'node:crypto';
7
7
  import 'node:fs';
8
8
  import '@nuxt/kit';
@@ -1,8 +1,8 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { defu } from 'defu';
3
3
  import { logger } from '../../dist/runtime/logger.js';
4
- import { e as extractVariantBaseClasses, s as simplifyCss, a as extractCssVars, b as extractPropertyInitialValues, c as extractUniversalVars, d as extractPerClassVars, f as extractClassStyles, p as postProcessStyles, r as resolveVariantPrefixes, i as importOptionalPeer, g as extractVarsFromCss, h as resolveExtractedVars } from '../shared/nuxt-og-image.BIbfn5xQ.mjs';
5
- export { j as importResolvedModule, k as resolveOptionalModulePath } from '../shared/nuxt-og-image.BIbfn5xQ.mjs';
4
+ import { e as extractVariantBaseClasses, s as simplifyCss, a as extractCssVars, b as extractPropertyInitialValues, c as extractUniversalVars, d as extractPerClassVars, f as extractClassStyles, p as postProcessStyles, r as resolveVariantPrefixes, i as importOptionalPeer, g as extractVarsFromCss, h as resolveExtractedVars } from '../shared/nuxt-og-image.BMHzg1Vz.mjs';
5
+ export { j as importResolvedModule, k as resolveOptionalModulePath } from '../shared/nuxt-og-image.BMHzg1Vz.mjs';
6
6
  import 'node:crypto';
7
7
  import 'node:fs';
8
8
  import 'node:url';
package/dist/module.d.ts CHANGED
@@ -215,5 +215,5 @@ interface ModuleHooks {
215
215
  }
216
216
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
217
217
 
218
- export = _default;
218
+ export { _default as default };
219
219
  export type { ModuleHooks, ModuleOptions };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.16.0"
5
5
  },
6
6
  "configKey": "ogImage",
7
- "version": "6.7.6",
7
+ "version": "6.7.7",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -10,7 +10,7 @@ import 'nuxtseo-shared/kit';
10
10
  import 'pathe';
11
11
  import 'pkg-types';
12
12
  import 'std-env';
13
- export { n as default } from './shared/nuxt-og-image.BIbfn5xQ.mjs';
13
+ export { n as default } from './shared/nuxt-og-image.BMHzg1Vz.mjs';
14
14
  import '../dist/runtime/logger.js';
15
15
  import 'oxc-walker';
16
16
  import 'chrome-launcher';
@@ -2,8 +2,8 @@ import { readFile } from "node:fs/promises";
2
2
  import { join } from "pathe";
3
3
  import { withBase } from "ufo";
4
4
  import { getRequestURL } from "#nuxtseo/h3";
5
- import { useRuntimeConfig } from "#nuxtseo/nitro";
6
- import { buildDir, rootDir } from "#og-image-virtual/build-dir.mjs";
5
+ import { fetchWithEvent, useRuntimeConfig } from "#nuxtseo/nitro";
6
+ import { buildDir, rootDir, staticFontCacheDir } from "#og-image-virtual/build-dir.mjs";
7
7
  import { getSiteConfig } from "#site-config/server/composables";
8
8
  import { getFetchTimeout } from "../../../util/fetchTimeout.js";
9
9
  import { fetchWithRedirectValidation } from "../../../util/ssrf.js";
@@ -43,7 +43,7 @@ export async function resolve(event, font) {
43
43
  if (import.meta.prerender) {
44
44
  if (path.startsWith("/_og-static-fonts/")) {
45
45
  const filename2 = path.slice("/_og-static-fonts/".length);
46
- const cached = await readOptionalFile(join(buildDir, "cache", "og-image", "fonts-ttf", filename2)) || await readOptionalFile(join(rootDir, ".output", "public", "_og-static-fonts", filename2));
46
+ const cached = await readOptionalFile(join(staticFontCacheDir, filename2)) || await readOptionalFile(join(rootDir, ".output", "public", "_og-static-fonts", filename2));
47
47
  if (cached?.length)
48
48
  return cached;
49
49
  }
@@ -67,7 +67,7 @@ export async function resolve(event, font) {
67
67
  }
68
68
  if (path.startsWith("/_og-static-fonts/")) {
69
69
  const filename = path.slice("/_og-static-fonts/".length);
70
- const cached = await readOptionalFile(join(buildDir, "cache", "og-image", "fonts-ttf", filename));
70
+ const cached = await readOptionalFile(join(staticFontCacheDir, filename));
71
71
  if (cached?.length)
72
72
  return cached;
73
73
  }
@@ -99,8 +99,7 @@ export async function resolve(event, font) {
99
99
  }
100
100
  }
101
101
  const fullPath = withBase(path, app.baseURL);
102
- const fetchArrayBuffer = event.$fetch;
103
- const arrayBuffer = await fetchArrayBuffer(fullPath, {
102
+ const arrayBuffer = await fetchWithEvent(event, fullPath, {
104
103
  responseType: "arrayBuffer",
105
104
  timeout
106
105
  });
@@ -1,3 +1,3 @@
1
1
  import type { H3Event } from '#nuxtseo/h3';
2
2
  import type { FontConfig } from '../../../../types.js';
3
- export declare function resolve(event: H3Event, font: FontConfig): Promise<Buffer<ArrayBufferLike>>;
3
+ export declare function resolve(event: H3Event, font: FontConfig): Promise<Buffer<any>>;
@@ -1,5 +1,5 @@
1
1
  import { withBase } from "ufo";
2
- import { useRuntimeConfig } from "#nuxtseo/nitro";
2
+ import { fetchWithEvent, useRuntimeConfig } from "#nuxtseo/nitro";
3
3
  import { getNitroOrigin, getSiteConfig } from "#site-config/server/composables";
4
4
  import { getFetchTimeout } from "../../../util/fetchTimeout.js";
5
5
  import { fetchWithRedirectValidation } from "../../../util/ssrf.js";
@@ -21,8 +21,7 @@ export async function resolve(event, font) {
21
21
  if (ab) {
22
22
  return Buffer.from(ab);
23
23
  }
24
- const fetchArrayBuffer = event.$fetch;
25
- const arrayBuffer = await fetchArrayBuffer(fullPath, {
24
+ const arrayBuffer = await fetchWithEvent(event, fullPath, {
26
25
  responseType: "arrayBuffer",
27
26
  timeout
28
27
  });
@@ -1,5 +1,6 @@
1
1
  import { withQuery } from "ufo";
2
2
  import { toValue } from "vue";
3
+ import { fetchWithEvent } from "#nuxtseo/nitro";
3
4
  import { getNitroOrigin } from "#site-config/server/composables";
4
5
  import { buildOgImageUrl } from "../../../shared.js";
5
6
  import { getFetchTimeout } from "../../util/fetchTimeout.js";
@@ -77,7 +78,7 @@ export async function createScreenshot({ basePath, e, options, extension, timing
77
78
  logger.warn("The `html` option is deprecated and will be removed in the next major version. Use a Vue component instead.");
78
79
  }
79
80
  if (import.meta.prerender && !options.html) {
80
- options.html = await timings.measure("html-fetch", () => e.$fetch(path, { timeout: getFetchTimeout(runtimeConfig) }).catch((err) => {
81
+ options.html = await timings.measure("html-fetch", () => fetchWithEvent(e, path, { timeout: getFetchTimeout(runtimeConfig) }).catch((err) => {
81
82
  void err;
82
83
  return void 0;
83
84
  }));
@@ -3,24 +3,15 @@ export declare function fontFormat(src: string): FontFormat;
3
3
  /**
4
4
  * Pick the src to actually load for a parsed font entry.
5
5
  *
6
- * - When `preferStatic` is set (takumi), prefers the full static satoriSrc over a subset WOFF2
7
- * primary src. @nuxt/fonts CSS often ships only the latin subset for a family, so using the
8
- * subset would hide non-latin glyphs (devanagari, CJK) the static file covers.
9
- * - Variable fonts (entries carrying `weightRange`) are an exception: the per-weight static
10
- * `satoriSrc` would discard the wght axis, leaving the runtime to stair-step requested
11
- * weights through whatever weights fontless happened to download (e.g. requested 400 maps
12
- * to the closest available static, often 100 or 700, with a hard jump in the middle).
13
- * Keep the variable WOFF2 primary src so takumi can vary the axis at render time.
14
- * - Otherwise, uses the primary src when the renderer can parse its format, falling back to
15
- * satoriSrc as a static alternative when the primary format is unsupported (satori + WOFF2).
6
+ * Uses the primary source when the renderer supports it, preserving WOFF2
7
+ * subsets and variable axes for Takumi. Otherwise it uses the Satori fallback.
16
8
  *
17
9
  * Returns null when no src on this entry can be parsed by the renderer.
18
10
  */
19
11
  export declare function selectFontSource(f: {
20
12
  src: string;
21
13
  satoriSrc?: string;
22
- weightRange?: [number, number];
23
- }, supportedFormats: Set<FontFormat>, preferStatic: boolean): {
14
+ }, supportedFormats: Set<FontFormat>): {
24
15
  src: string;
25
16
  isStaticFallback: boolean;
26
17
  } | null;
@@ -7,12 +7,9 @@ export function fontFormat(src) {
7
7
  return "otf";
8
8
  return "ttf";
9
9
  }
10
- export function selectFontSource(f, supportedFormats, preferStatic) {
10
+ export function selectFontSource(f, supportedFormats) {
11
11
  const primarySupported = supportedFormats.has(fontFormat(f.src));
12
12
  const satoriSupported = !!(f.satoriSrc && supportedFormats.has(fontFormat(f.satoriSrc)));
13
- const isVariable = !!f.weightRange;
14
- if (preferStatic && !isVariable && satoriSupported && f.satoriSrc !== f.src)
15
- return { src: f.satoriSrc, isStaticFallback: true };
16
13
  if (primarySupported)
17
14
  return { src: f.src, isStaticFallback: false };
18
15
  if (satoriSupported)
@@ -16,13 +16,6 @@ export interface LoadFontsOptions {
16
16
  fontFamilyOverride?: string;
17
17
  /** Codepoints present in the template — fonts whose unicodeRange doesn't intersect are skipped */
18
18
  codepoints?: Set<number>;
19
- /**
20
- * Prefer the static satoriSrc (full TTF/WOFF from fontless) over the primary src
21
- * (subset WOFF2 from @nuxt/fonts) when both are usable. Takumi uses this so non-Latin
22
- * glyphs (devanagari, CJK, etc.) render — @nuxt/fonts CSS often only ships latin
23
- * subsets for a family, but the fontless static file contains the full glyph set.
24
- */
25
- preferStatic?: boolean;
26
19
  }
27
20
  export declare function loadAllFontsDebug(component?: string): {
28
21
  component: string | undefined;
@@ -97,7 +97,7 @@ export async function loadAllFonts(event, options) {
97
97
  }
98
98
  const resolved = [];
99
99
  for (const f of fonts) {
100
- const selection = selectFontSource(f, options.supportedFormats, options.preferStatic ?? false);
100
+ const selection = selectFontSource(f, options.supportedFormats);
101
101
  if (selection)
102
102
  resolved.push({ font: f, ...selection });
103
103
  }
@@ -187,7 +187,7 @@ async function createImage(event, format) {
187
187
  const { fontFamilyOverride, defaultFont } = getDefaultFontFamily(options);
188
188
  const nodes = await createTakumiNodes(event);
189
189
  const codepoints = extractCodepoints(nodes);
190
- const fonts = await timings.measure("font-load", () => loadFontsForRenderer(event, { supportedFormats: /* @__PURE__ */ new Set(["ttf", "woff2"]), preferStatic: true, component: options.component, fontFamilyOverride: fontFamilyOverride || defaultFont, codepoints }));
190
+ const fonts = await timings.measure("font-load", () => loadFontsForRenderer(event, { supportedFormats: /* @__PURE__ */ new Set(["ttf", "woff2"]), component: options.component, fontFamilyOverride: fontFamilyOverride || defaultFont, codepoints }));
191
191
  const fontEntries = dedupeFontsByBinary(fonts);
192
192
  const hookTimeout = event.runtimeConfig.security?.renderTimeout ?? 15e3;
193
193
  await withTimeout(
@@ -293,7 +293,7 @@ const TakumiRenderer = {
293
293
  async debug(e) {
294
294
  const [vnodes, fonts] = await Promise.all([
295
295
  createTakumiNodes(e),
296
- loadFontsForRenderer(e, { supportedFormats: /* @__PURE__ */ new Set(["ttf", "woff2"]), preferStatic: true, component: e.options.component })
296
+ loadFontsForRenderer(e, { supportedFormats: /* @__PURE__ */ new Set(["ttf", "woff2"]), component: e.options.component })
297
297
  ]);
298
298
  return {
299
299
  vnodes,
@@ -1,5 +1,6 @@
1
1
  import { parseURL, withLeadingSlash, withQuery } from "ufo";
2
2
  import { createError, defineEventHandler, getRequestHost, sendRedirect } from "#nuxtseo/h3";
3
+ import { fetchWithEvent } from "#nuxtseo/nitro";
3
4
  import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
4
5
  import { isInternalRoute } from "../../shared.js";
5
6
  import { getEventQuery } from "../util/query.js";
@@ -98,7 +99,7 @@ export default defineEventHandler(async (event) => {
98
99
  forwardQuery[k] = v;
99
100
  }
100
101
  const fetchPath = withQuery(withLeadingSlash(targetPath), forwardQuery);
101
- const html = await event.$fetch(fetchPath, {
102
+ const html = await fetchWithEvent(event, fetchPath, {
102
103
  headers: { accept: "text/html" },
103
104
  responseType: "text"
104
105
  }).catch((err) => {
@@ -14,7 +14,7 @@ export interface FetchLocalAssetOptions {
14
14
  /**
15
15
  * Resolve a same-origin asset path to bytes, trying (in order):
16
16
  * 1. Cloudflare Workers ASSETS binding
17
- * 2. Nitro localFetch (`event.$fetch`) — resolves dynamic routes too
17
+ * 2. Nitro localFetch through the event-aware bridge, which resolves dynamic routes too
18
18
  * 3. External `$fetch` to the Nitro origin (opt-in)
19
19
  *
20
20
  * All steps share a single `AbortSignal.timeout(fetchTimeout)` so a broken
@@ -1,4 +1,5 @@
1
1
  import { $fetch } from "ofetch";
2
+ import { fetchWithEvent } from "#nuxtseo/nitro";
2
3
  import { getNitroOrigin } from "#site-config/server/composables";
3
4
  import { tryCloudflareAssetsFetch } from "./cloudflareAssets.js";
4
5
  export async function fetchLocalAsset(event, path, options) {
@@ -18,7 +19,7 @@ export async function fetchLocalAsset(event, path, options) {
18
19
  }));
19
20
  if (result || expired)
20
21
  return result;
21
- result = await race(event.$fetch(path, {
22
+ result = await race(fetchWithEvent(event, path, {
22
23
  responseType: "arrayBuffer",
23
24
  signal: deadline,
24
25
  timeout: fetchTimeout,
@@ -214,7 +214,7 @@ export interface FontConfig {
214
214
  weight: number;
215
215
  style: 'normal' | 'italic';
216
216
  src: string;
217
- /** TTF path for Satori (converted from WOFF2 if needed). Falls back to src if not set. */
217
+ /** Static source for renderers that cannot use the primary font. Falls back to src if not set. */
218
218
  satoriSrc?: string;
219
219
  localPath: string;
220
220
  /** Absolute filesystem path for statically bundled fonts. */