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.
Files changed (80) hide show
  1. package/dist/chunks/tw4.cjs +2 -2
  2. package/dist/chunks/tw4.mjs +2 -2
  3. package/dist/chunks/uno.cjs +20 -5
  4. package/dist/chunks/uno.mjs +19 -5
  5. package/dist/cli.cjs +8 -2
  6. package/dist/cli.mjs +8 -2
  7. package/dist/devtools/lib/og-image/rpc.ts +4 -1
  8. package/dist/module.cjs +2 -2
  9. package/dist/module.json +2 -2
  10. package/dist/module.mjs +2 -2
  11. package/dist/runtime/app/plugins/og-image-canonical-urls.server.d.ts +2 -1
  12. package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +3 -1
  13. package/dist/runtime/app/plugins/route-rule-og-image.server.d.ts +2 -1
  14. package/dist/runtime/app/plugins/route-rule-og-image.server.js +3 -1
  15. package/dist/runtime/app/utils/plugins.js +4 -10
  16. package/dist/runtime/logger.js +2 -6
  17. package/dist/runtime/pure.d.ts +0 -1
  18. package/dist/runtime/pure.js +0 -5
  19. package/dist/runtime/server/og-image/bindings/browser/chrome-launcher.d.ts +1 -1
  20. package/dist/runtime/server/og-image/bindings/browser/cloudflare.d.ts +1 -2
  21. package/dist/runtime/server/og-image/bindings/browser/cloudflare.js +2 -9
  22. package/dist/runtime/server/og-image/bindings/browser/on-demand.d.ts +1 -1
  23. package/dist/runtime/server/og-image/bindings/browser/playwright.d.ts +1 -1
  24. package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.d.ts +1 -1
  25. package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.js +1 -1
  26. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.d.ts +1 -1
  27. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +27 -13
  28. package/dist/runtime/server/og-image/bindings/font-assets/external-url.js +3 -1
  29. package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +1 -1
  30. package/dist/runtime/server/og-image/bindings/font-assets/node.js +4 -2
  31. package/dist/runtime/server/og-image/bindings/resvg/node-dev.js +18 -64
  32. package/dist/runtime/server/og-image/bindings/takumi/node-dev.js +26 -83
  33. package/dist/runtime/server/og-image/bindings/worker-queue.d.ts +34 -0
  34. package/dist/runtime/server/og-image/bindings/worker-queue.js +150 -0
  35. package/dist/runtime/server/og-image/browser/renderer.js +1 -1
  36. package/dist/runtime/server/og-image/context.d.ts +1 -1
  37. package/dist/runtime/server/og-image/context.js +2 -3
  38. package/dist/runtime/server/og-image/core/plugins/imageSrc.js +1 -1
  39. package/dist/runtime/server/og-image/core/transforms/emojis/local.d.ts +2 -17
  40. package/dist/runtime/server/og-image/core/transforms/emojis/local.js +1 -1
  41. package/dist/runtime/server/og-image/devtools.d.ts +1 -1
  42. package/dist/runtime/server/og-image/devtools.js +1 -1
  43. package/dist/runtime/server/og-image/fonts.d.ts +1 -1
  44. package/dist/runtime/server/og-image/fonts.js +3 -1
  45. package/dist/runtime/server/og-image/templates/html.js +1 -1
  46. package/dist/runtime/server/plugins/prerender.d.ts +1 -1
  47. package/dist/runtime/server/plugins/prerender.js +2 -2
  48. package/dist/runtime/server/routes/__zero-runtime/image.d.ts +1 -1
  49. package/dist/runtime/server/routes/__zero-runtime/image.js +1 -1
  50. package/dist/runtime/server/routes/debug.json.d.ts +1 -10
  51. package/dist/runtime/server/routes/debug.json.js +1 -1
  52. package/dist/runtime/server/routes/image.d.ts +1 -1
  53. package/dist/runtime/server/routes/image.js +1 -1
  54. package/dist/runtime/server/routes/resolve.d.ts +1 -1
  55. package/dist/runtime/server/routes/resolve.js +1 -1
  56. package/dist/runtime/server/util/cache.d.ts +1 -6
  57. package/dist/runtime/server/util/cache.js +2 -2
  58. package/dist/runtime/server/util/cloudflare.d.ts +3 -0
  59. package/dist/runtime/server/util/cloudflare.js +17 -0
  60. package/dist/runtime/server/util/cloudflareAssets.d.ts +1 -1
  61. package/dist/runtime/server/util/cloudflareAssets.js +8 -5
  62. package/dist/runtime/server/util/encoding.d.ts +0 -1
  63. package/dist/runtime/server/util/encoding.js +0 -7
  64. package/dist/runtime/server/util/eventHandlers.d.ts +1 -1
  65. package/dist/runtime/server/util/eventHandlers.js +1 -1
  66. package/dist/runtime/server/util/fetchLocalAsset.d.ts +1 -1
  67. package/dist/runtime/server/util/kit.d.ts +7 -4
  68. package/dist/runtime/server/util/kit.js +4 -19
  69. package/dist/runtime/server/util/logger.js +2 -6
  70. package/dist/runtime/server/util/options.js +1 -1
  71. package/dist/runtime/server/util/query.d.ts +1 -1
  72. package/dist/runtime/server/util/timings.d.ts +0 -3
  73. package/dist/runtime/server/util/timings.js +0 -3
  74. package/dist/runtime/server/utils.d.ts +1 -1
  75. package/dist/runtime/server/utils.js +7 -4
  76. package/dist/runtime/types.d.ts +11 -9
  77. package/dist/shared/{nuxt-og-image.Bv8VSGTj.mjs → nuxt-og-image.BIbfn5xQ.mjs} +146 -108
  78. package/dist/shared/{nuxt-og-image.BRBtdkUp.cjs → nuxt-og-image.CdpC3njh.cjs} +148 -107
  79. package/package.json +57 -48
  80. package/types/virtual.d.ts +15 -0
@@ -3,15 +3,15 @@ import * as fs from 'node:fs';
3
3
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, rmSync } from 'node:fs';
4
4
  import { readdir, readFile, writeFile, mkdir } from 'node:fs/promises';
5
5
  import { pathToFileURL } from 'node:url';
6
- import { resolvePath, useNuxt, addTemplate, updateTemplates, addTypeTemplate, defineNuxtModule, createResolver, addImports, hasNuxtModule, hasNuxtModuleCompatibility, getNuxtModuleVersion, addVitePlugin, addBuildPlugin, addServerHandler, addPlugin, addComponentsDir, getNuxtVersion, addServerPlugin } from '@nuxt/kit';
6
+ import { resolvePath, useNuxt, addTemplate, updateTemplates, directoryToURL, tryResolveModule, addTypeTemplate, defineNuxtModule, createResolver, addImports, hasNuxtModule, hasNuxtModuleCompatibility, getNuxtModuleVersion, addVitePlugin, addBuildPlugin, addServerHandler, addPlugin, addComponentsDir, getNuxtVersion, addServerPlugin } from '@nuxt/kit';
7
7
  import { defu } from 'defu';
8
8
  import { fnv1a64Base36 } from 'fnv1a-64';
9
9
  import { installNuxtSiteConfig } from 'nuxt-site-config/kit';
10
+ import { resolveNitroPreset, renderNitroTypeAugmentations, setupNitroRuntimeCompatibility, getNuxtModuleOptions, isNuxtGenerate } from 'nuxtseo-shared/kit';
10
11
  import { basename, join, dirname, relative, isAbsolute, resolve } from 'pathe';
11
12
  import { readPackageJSON } from 'pkg-types';
12
13
  import { isCI, isAgent, hasTTY } from 'std-env';
13
14
  import { parseAndWalk } from 'oxc-walker';
14
- import { resolveNitroPreset, getNuxtModuleOptions, isNuxtGenerate } from 'nuxtseo-shared/kit';
15
15
  import { logger } from '../../dist/runtime/logger.js';
16
16
  import { Launcher } from 'chrome-launcher';
17
17
  import { detectPackageManager, addDependency } from 'nypm';
@@ -42,7 +42,9 @@ function checkLocalChrome() {
42
42
  return hasChromeLocally;
43
43
  }
44
44
  async function hasResolvableDependency(dep) {
45
- return await resolvePath(dep, { fallbackToOriginal: true }).catch(() => null).then((r) => r && r !== dep);
45
+ return await resolvePath(dep, { fallbackToOriginal: true }).catch(() => {
46
+ return null;
47
+ }).then((r) => r && r !== dep);
46
48
  }
47
49
  const VALID_RENDERER_SUFFIXES = ["satori", "browser", "takumi"];
48
50
  const RE_RENDERER_SUFFIX_CI = /\.?(satori|browser|takumi)$/i;
@@ -306,23 +308,32 @@ async function setupBuildHandler(config, resolve, getDetectedRenderers, getCompa
306
308
  nuxt.options.nitro.storage = nuxt.options.nitro.storage || {};
307
309
  if (typeof config.runtimeCacheStorage === "object")
308
310
  nuxt.options.nitro.storage["nuxt-og-image"] = config.runtimeCacheStorage;
309
- nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
310
- const mockCode = `import proxy from 'mocked-exports/proxy';export default proxy;export * from 'mocked-exports/proxy';`;
311
- nitroConfig.virtual = nitroConfig.virtual || {};
312
- nitroConfig.virtual["playwright-core"] = mockCode;
313
- nitroConfig.virtual.electron = mockCode;
314
- nitroConfig.virtual["electron/index"] = mockCode;
315
- nitroConfig.virtual["electron/index.js"] = mockCode;
316
- nitroConfig.virtual.bufferutil = mockCode;
317
- nitroConfig.virtual["utf-8-validate"] = mockCode;
318
- nitroConfig.virtual["chromium-bidi"] = mockCode;
319
- nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper"] = mockCode;
320
- nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js"] = mockCode;
321
- nitroConfig.virtual.queue = mockCode;
311
+ const nitroConfig = nuxt.options.nitro;
312
+ const mockCode = `import proxy from 'mocked-exports/proxy';export default proxy;export * from 'mocked-exports/proxy';`;
313
+ nitroConfig.virtual = nitroConfig.virtual || {};
314
+ nitroConfig.virtual["playwright-core"] = mockCode;
315
+ nitroConfig.virtual.electron = mockCode;
316
+ nitroConfig.virtual["electron/index"] = mockCode;
317
+ nitroConfig.virtual["electron/index.js"] = mockCode;
318
+ nitroConfig.virtual.bufferutil = mockCode;
319
+ nitroConfig.virtual["utf-8-validate"] = mockCode;
320
+ nitroConfig.virtual["chromium-bidi"] = mockCode;
321
+ nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper"] = mockCode;
322
+ nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js"] = mockCode;
323
+ nitroConfig.virtual.queue = mockCode;
324
+ await applyNitroPresetCompatibility(nitroConfig, {
325
+ compatibility: config.compatibility?.runtime,
326
+ resolve,
327
+ detectedRenderers: getDetectedRenderers(),
328
+ metadata: getCompatibilityMeta()
322
329
  });
323
330
  nuxt.hooks.hook("nitro:init", async (nitro) => {
324
- const renderers = getDetectedRenderers();
325
- await applyNitroPresetCompatibility(nitro.options, { compatibility: config.compatibility?.runtime, resolve, detectedRenderers: renderers, metadata: getCompatibilityMeta() });
331
+ await applyNitroPresetCompatibility(nitro.options, {
332
+ compatibility: config.compatibility?.runtime,
333
+ resolve,
334
+ detectedRenderers: getDetectedRenderers(),
335
+ metadata: getCompatibilityMeta()
336
+ });
326
337
  const target = resolveOgImagePreset(nitro.options);
327
338
  const normalizedTarget = target.replace(RE_LEGACY_SUFFIX, "");
328
339
  const isEdgePreset = ["cloudflare", "cloudflare-pages", "cloudflare-pages-static", "cloudflare-module", "cloudflare-durable", "vercel-edge", "netlify-edge"].includes(normalizedTarget);
@@ -647,10 +658,10 @@ async function validateProviderSetup(renderer, compatibility) {
647
658
  return { valid: issues.length === 0, issues };
648
659
  }
649
660
 
650
- function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = useNuxt()) {
651
- nuxt.hooks.hook("nitro:init", async (nitro) => {
661
+ async function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = useNuxt()) {
662
+ const applyCompatibility = async (nitroConfig) => {
652
663
  const detectedRenderers = new Set(getDetectedRenderers());
653
- const targetCompatibility = getPresetNitroPresetCompatibility(resolveOgImagePreset(nitro.options));
664
+ const targetCompatibility = getPresetNitroPresetCompatibility(resolveOgImagePreset(nitroConfig));
654
665
  for (const renderer of ["satori", "takumi", "browser"]) {
655
666
  if (!detectedRenderers.has(renderer)) {
656
667
  const binding = getRecommendedBinding(renderer, targetCompatibility);
@@ -659,8 +670,10 @@ function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilit
659
670
  detectedRenderers.add(renderer);
660
671
  }
661
672
  }
662
- await applyNitroPresetCompatibility(nitro.options, { compatibility: options.compatibility?.dev, resolve, detectedRenderers, metadata: getCompatibilityMeta() });
663
- });
673
+ await applyNitroPresetCompatibility(nitroConfig, { compatibility: options.compatibility?.dev, resolve, detectedRenderers, metadata: getCompatibilityMeta() });
674
+ };
675
+ await applyCompatibility(nuxt.options.nitro);
676
+ nuxt.hooks.hook("nitro:init", (nitro) => applyCompatibility(nitro.options));
664
677
  }
665
678
 
666
679
  const RE_TILDE_SLASH = /^~\//;
@@ -893,7 +906,6 @@ const RE_QUOTES = /^['"]|['"]$/g;
893
906
  const RE_WIDTH_VALUE = /width:([^;}]+)/;
894
907
  const RE_CALC_VAR_MULTIPLY = /calc\(var\((--[\w-]+)\)\s*\*\s*([\d.]+)\)/;
895
908
  const RE_NUMERIC_WITH_UNIT = /([\d.]+)(rem|px|em|%)/;
896
- const RE_EXTREME_VALUE = /^(-?[\d.]+e\+?\d+)(px|rem|em|%)$/;
897
909
  const RE_CSS_KEYWORD = /^(?:initial|inherit|unset|revert|revert-layer)$/;
898
910
  const RE_UNRESOLVED_VAR = /var\((--[\w-]+)/g;
899
911
  const RE_INVALID_CALC = /calc\(\s*[*/]/;
@@ -1503,18 +1515,6 @@ function convertLogicalProperties(styles) {
1503
1515
  }
1504
1516
  }
1505
1517
  }
1506
- function clampExtremeValues(styles) {
1507
- for (const [prop, value] of Object.entries(styles)) {
1508
- if (!value.includes("e+") && !value.includes("e38"))
1509
- continue;
1510
- const match = value.match(RE_EXTREME_VALUE);
1511
- if (match?.[1] && match?.[2]) {
1512
- const num = Number.parseFloat(match[1]);
1513
- if (Math.abs(num) > 9999)
1514
- styles[prop] = `9999${match[2]}`;
1515
- }
1516
- }
1517
- }
1518
1518
  function stripGradientColorSpace(value) {
1519
1519
  return value.replace(GRADIENT_COLOR_SPACE_RE, "");
1520
1520
  }
@@ -1562,7 +1562,6 @@ async function postProcessStyles(rawStyles, vars, resolveVar, context) {
1562
1562
  }
1563
1563
  convertIndividualTransforms(styles);
1564
1564
  convertLogicalProperties(styles);
1565
- clampExtremeValues(styles);
1566
1565
  return Object.keys(styles).length ? styles : null;
1567
1566
  }
1568
1567
  function walkTemplateAst(nodes, visitor) {
@@ -1965,7 +1964,9 @@ async function parseFontsFromTemplate(nuxt, options) {
1965
1964
  async function downloadFontFile(url, destPath) {
1966
1965
  if (existsSync(destPath))
1967
1966
  return true;
1968
- const res = await fetch(url).catch(() => null);
1967
+ const res = await fetch(url).catch(() => {
1968
+ return null;
1969
+ });
1969
1970
  if (!res?.ok)
1970
1971
  return false;
1971
1972
  await writeFile(destPath, Buffer.from(await res.arrayBuffer()));
@@ -2191,7 +2192,7 @@ async function downloadStaticFonts(options) {
2191
2192
  results.push(...familyResults);
2192
2193
  }
2193
2194
  }
2194
- if (unresolvedFamilies.length > 0) {
2195
+ if (options.warnOnMissingStaticFonts !== false && unresolvedFamilies.length > 0) {
2195
2196
  const providerList = fontlessCtx.providerNames.join(", ") || "none";
2196
2197
  const localFonts = await listLocalPublicFontFiles(options.nuxt).catch(() => []);
2197
2198
  const matchedLocal = unresolvedFamilies.map((family) => {
@@ -2323,7 +2324,8 @@ async function convertWoff2ToTtf(options) {
2323
2324
  families,
2324
2325
  nuxt,
2325
2326
  logger,
2326
- fontSubsets
2327
+ fontSubsets,
2328
+ warnOnMissingStaticFonts
2327
2329
  });
2328
2330
  for (const font of downloaded) {
2329
2331
  const key = `${font.family}-${font.weight}-${font.style}`;
@@ -2462,6 +2464,34 @@ function setupGenerateHandler(_options, resolve, _getDetectedRenderers, nuxt = u
2462
2464
  });
2463
2465
  }
2464
2466
 
2467
+ async function resolveOptionalModulePath(id, rootDir, fallbackPackages = []) {
2468
+ const rootUrl = directoryToURL(rootDir);
2469
+ const direct = await tryResolveModule(id, rootUrl);
2470
+ if (direct)
2471
+ return direct;
2472
+ for (const pkg of fallbackPackages) {
2473
+ const pkgJson = await tryResolveModule(`${pkg}/package.json`, rootUrl);
2474
+ if (!pkgJson)
2475
+ continue;
2476
+ const nested = await tryResolveModule(id, directoryToURL(dirname(pkgJson)));
2477
+ if (nested)
2478
+ return nested;
2479
+ }
2480
+ }
2481
+ async function importResolvedModule(id, resolvedPath) {
2482
+ return await (resolvedPath ? import(pathToFileURL(resolvedPath).href) : import(id));
2483
+ }
2484
+ async function importOptionalPeer(id, resolvedPath, usage) {
2485
+ try {
2486
+ return await importResolvedModule(id, resolvedPath);
2487
+ } catch (cause) {
2488
+ throw new Error(
2489
+ `[nuxt-og-image] Missing optional peer dependency "${id}". Install it to use ${usage}.`,
2490
+ { cause }
2491
+ );
2492
+ }
2493
+ }
2494
+
2465
2495
  const ONE_WEEK_MS = 7 * 24 * 60 * 60 * 1e3;
2466
2496
  function setupPrerenderHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = useNuxt()) {
2467
2497
  nuxt.hooks.hook("nitro:init", async (nitro) => {
@@ -2606,7 +2636,7 @@ const TreeShakeComposablesPlugin = createUnplugin(() => {
2606
2636
  },
2607
2637
  transform(code, id) {
2608
2638
  const s = new MagicString(code);
2609
- if (id.endsWith("components.islands.mjs")) ; else {
2639
+ if (!id.endsWith("components.islands.mjs")) {
2610
2640
  const strippedCode = stripLiteral(code);
2611
2641
  if (!COMPOSABLE_RE.test(code)) {
2612
2642
  return;
@@ -3203,7 +3233,9 @@ const iconCache = /* @__PURE__ */ new Map();
3203
3233
  async function loadIconSet(prefix) {
3204
3234
  if (iconCache.has(prefix))
3205
3235
  return iconCache.get(prefix);
3206
- const icons = await import(`@iconify-json/${prefix}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => null);
3236
+ const icons = await import(`@iconify-json/${prefix}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => {
3237
+ return null;
3238
+ });
3207
3239
  iconCache.set(prefix, icons);
3208
3240
  if (iconCache.size > 20)
3209
3241
  iconCache.delete(iconCache.keys().next().value);
@@ -3387,7 +3419,9 @@ const AssetTransformPlugin = createUnplugin((options) => {
3387
3419
  let hasChanges = false;
3388
3420
  if (options.emojiSet && RE_MATCH_EMOJIS.test(template)) {
3389
3421
  if (!emojiIcons) {
3390
- emojiIcons = options.emojiIcons ?? await import(`@iconify-json/${options.emojiSet}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => null);
3422
+ emojiIcons = options.emojiIcons ?? await import(`@iconify-json/${options.emojiSet}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => {
3423
+ return null;
3424
+ });
3391
3425
  }
3392
3426
  RE_MATCH_EMOJIS.lastIndex = 0;
3393
3427
  const allEmojis = /* @__PURE__ */ new Set();
@@ -3677,7 +3711,9 @@ const AssetTransformPlugin = createUnplugin((options) => {
3677
3711
  } else {
3678
3712
  continue;
3679
3713
  }
3680
- const fileBuffer = await readFile(resolvedPath).catch(() => null);
3714
+ const fileBuffer = await readFile(resolvedPath).catch(() => {
3715
+ return null;
3716
+ });
3681
3717
  if (!fileBuffer)
3682
3718
  continue;
3683
3719
  const mimeType = getMimeType(ext);
@@ -4061,7 +4097,6 @@ ${importStatements}
4061
4097
  const warnings = [];
4062
4098
  const counts = {
4063
4099
  config: /* @__PURE__ */ new Map(),
4064
- composable: /* @__PURE__ */ new Map(),
4065
4100
  component: /* @__PURE__ */ new Map()
4066
4101
  };
4067
4102
  let hasEmitted = false;
@@ -4083,13 +4118,6 @@ const REMOVED_CONFIG = {
4083
4118
  "defaults.renderer": "Removed (renderer determined by component filename suffix)",
4084
4119
  "defaults.component": "Removed (rename component to OgImage/Default.{renderer}.vue)"
4085
4120
  };
4086
- const DEPRECATED_COMPOSABLES$1 = {
4087
- defineOgImageComponent: "defineOgImage()",
4088
- defineOgImageStatic: "defineOgImage()",
4089
- defineOgImageDynamic: "defineOgImage()",
4090
- defineOgImageCached: "defineOgImage()",
4091
- defineOgImageWithoutCache: "defineOgImage()"
4092
- };
4093
4121
  function addWarning(warning) {
4094
4122
  const countMap = counts[warning.type];
4095
4123
  const current = countMap.get(warning.code) || 0;
@@ -4119,13 +4147,13 @@ function addComponentWarning(componentPath) {
4119
4147
  });
4120
4148
  }
4121
4149
  function hasWarnings() {
4122
- return warnings.length > 0 || counts.config.size > 0 || counts.composable.size > 0 || counts.component.size > 0;
4150
+ return warnings.length > 0 || counts.config.size > 0 || counts.component.size > 0;
4123
4151
  }
4124
4152
  function emitWarnings() {
4125
4153
  if (hasEmitted || !hasWarnings())
4126
4154
  return;
4127
4155
  hasEmitted = true;
4128
- const totalIssues = [...counts.config.values()].reduce((a, b) => a + b, 0) + [...counts.composable.values()].reduce((a, b) => a + b, 0) + [...counts.component.values()].reduce((a, b) => a + b, 0);
4156
+ const totalIssues = [...counts.config.values()].reduce((a, b) => a + b, 0) + [...counts.component.values()].reduce((a, b) => a + b, 0);
4129
4157
  const body = [
4130
4158
  formatWarnings(),
4131
4159
  "",
@@ -4162,17 +4190,6 @@ function formatWarnings() {
4162
4190
  }
4163
4191
  lines.push("");
4164
4192
  }
4165
- if (counts.composable.size > 0) {
4166
- lines.push("Deprecated composables:");
4167
- for (const [name, count] of counts.composable) {
4168
- const replacement = DEPRECATED_COMPOSABLES$1[name];
4169
- const suffix = count > 1 ? ` (\xD7${count})` : "";
4170
- lines.push(` \u2022 ${name}()${suffix}`);
4171
- if (replacement)
4172
- lines.push(` \u2192 Use: ${replacement}`);
4173
- }
4174
- lines.push("");
4175
- }
4176
4193
  if (counts.component.size > 0) {
4177
4194
  const componentCount = [...counts.component.values()].reduce((a, b) => a + b, 0);
4178
4195
  lines.push(`Components missing renderer suffix: ${componentCount}`);
@@ -4454,7 +4471,7 @@ function getComponentTypeExpression(component, nuxt) {
4454
4471
  return `typeof import('${relativeComponentPath}')['default']`;
4455
4472
  }
4456
4473
  function registerTypeTemplates(ctx) {
4457
- const { nuxt, config, componentCtx } = ctx;
4474
+ const { nuxt, config, componentCtx, nitroCompatibility } = ctx;
4458
4475
  nuxt.hook("prepare:types", ({ tsConfig }) => {
4459
4476
  tsConfig.include = tsConfig.include || [];
4460
4477
  tsConfig.include.push("./module/nuxt-og-image-components.d.ts");
@@ -4505,7 +4522,7 @@ ${lines.join("\n")}
4505
4522
  getContents: (data) => {
4506
4523
  const typesPath = relative(resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), resolve("runtime/types"));
4507
4524
  return `declare module '#og-image-virtual/public-assets.mjs' {
4508
- import type { H3Event } from 'h3'
4525
+ import type { H3Event } from '#nuxtseo/h3'
4509
4526
  import type { FontConfig } from '${typesPath}'
4510
4527
  export function resolve(event: H3Event, font: FontConfig): Promise<BufferSource>
4511
4528
  }
@@ -4584,7 +4601,7 @@ declare module '#og-image-virtual/tw4-theme.mjs' {
4584
4601
  getContents: (data) => {
4585
4602
  const typesPath = relative(resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), resolve("runtime/types"));
4586
4603
  return `declare module '#og-image/bindings/browser' {
4587
- import type { H3Event } from 'h3'
4604
+ import type { H3Event } from '#nuxtseo/h3'
4588
4605
  export function createBrowser(event?: H3Event): Promise<any>
4589
4606
  }
4590
4607
 
@@ -4644,40 +4661,34 @@ declare module '#og-image-cache' {
4644
4661
  filename: "types/og-image-augments.d.ts",
4645
4662
  getContents: (data) => {
4646
4663
  const typesPath = relative(resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), resolve("runtime/types"));
4664
+ const nitroAugmentations = renderNitroTypeAugmentations(nitroCompatibility, {
4665
+ nitroInterfaces: {
4666
+ NitroApp: `_ogImageCacheBackendWarned?: boolean
4667
+ _ogImageIconsData?: OgImageIconsData`,
4668
+ NitroRuntimeConfig: `'nuxt-og-image': OgImageRuntimeConfig
4669
+ ogImage?: {
4670
+ secret?: string
4671
+ }`
4672
+ },
4673
+ routeRules: "ogImage?: false | OgImageOptions & Record<string, any>",
4674
+ routeConfig: "ogImage?: false | OgImageOptions & Record<string, any>",
4675
+ runtimeHooks: `'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
4676
+ 'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>`,
4677
+ eventContext: `_nitro?: {
4678
+ routeRules?: import('${nitroCompatibility.nitroTypesModule}').NitroRouteRules
4679
+ }
4680
+ _ogImagePrerenderPaths?: Map<string, string>`
4681
+ });
4647
4682
  return `/// <reference path="./og-image-virtual.d.ts" />
4648
4683
  /// <reference path="./og-image-bindings.d.ts" />
4649
- import type { OgImageOptions, OgImageRenderEventContext, VNode } from '${typesPath}'
4684
+ import type { OgImageIconsData, OgImageOptions, OgImageRenderEventContext, OgImageRuntimeConfig, VNode } from '${typesPath}'
4650
4685
 
4651
- declare module 'nitropack' {
4652
- interface NitroRouteRules {
4653
- ogImage?: false | OgImageOptions & Record<string, any>
4654
- }
4655
- interface NitroRouteConfig {
4656
- ogImage?: false | OgImageOptions & Record<string, any>
4657
- }
4658
- interface NitroRuntimeHooks {
4659
- 'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
4660
- 'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>
4661
- }
4662
- }
4663
-
4664
- declare module 'nitropack/types' {
4665
- interface NitroRouteRules {
4666
- ogImage?: false | OgImageOptions & Record<string, any>
4667
- }
4668
- interface NitroRouteConfig {
4669
- ogImage?: false | OgImageOptions & Record<string, any>
4670
- }
4671
- interface NitroRuntimeHooks {
4672
- 'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
4673
- 'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>
4674
- }
4675
- }
4686
+ ${nitroAugmentations}
4676
4687
 
4677
4688
  export {}
4678
4689
  `;
4679
4690
  }
4680
- });
4691
+ }, { nitro: true, nuxt: true });
4681
4692
  }
4682
4693
 
4683
4694
  const RE_INLINE_CONFIG = /const\s+inlineConfig\s*=\s*(\{[\s\S]*?\n\})/;
@@ -4685,14 +4696,16 @@ const RE_PASCAL_TO_KEBAB = /([a-z])([A-Z])/g;
4685
4696
  const RE_TILDE_PREFIX = /^~\//;
4686
4697
  const IS_MODULE_DEVELOPMENT = import.meta.filename.endsWith(".ts");
4687
4698
  async function findPackageVersionFromEntry(pkg, resolver) {
4688
- const entry = await resolver.resolvePath(pkg, { fallbackToOriginal: false }).catch(() => null);
4699
+ const entry = await resolver.resolvePath(pkg, { fallbackToOriginal: false }).catch(() => {
4700
+ return null;
4701
+ });
4689
4702
  if (!entry || entry === pkg)
4690
4703
  return;
4691
4704
  let dir = dirname(entry);
4692
4705
  while (dir && dir !== dirname(dir)) {
4693
4706
  const pkgPath = join(dir, "package.json");
4694
4707
  if (existsSync(pkgPath)) {
4695
- const pkgJson = await readPackageJSON(pkgPath).catch(() => null);
4708
+ const pkgJson = await readPackageJSON(pkgPath);
4696
4709
  if (pkgJson?.name === pkg)
4697
4710
  return pkgJson.version;
4698
4711
  }
@@ -4790,6 +4803,12 @@ const module$1 = defineNuxtModule({
4790
4803
  });
4791
4804
  return;
4792
4805
  }
4806
+ const nitroCompatibility = setupNitroRuntimeCompatibility(nuxt);
4807
+ const setRuntimeAlias = (id, path) => {
4808
+ nuxt.options.alias[id] = path;
4809
+ nuxt.options.nitro.alias ||= {};
4810
+ nuxt.options.nitro.alias[id] = path;
4811
+ };
4793
4812
  if (config.enabled && !nuxt.options.ssr) {
4794
4813
  logger.warn("Nuxt OG Image is enabled but SSR is disabled.\n\nYou should enable SSR (`ssr: true`) or disable the module (`ogImage: { enabled: false }`).");
4795
4814
  return;
@@ -4815,7 +4834,13 @@ const module$1 = defineNuxtModule({
4815
4834
  if (!nuxt.options.dev || config.zeroRuntime || !hasServerRuntime)
4816
4835
  return;
4817
4836
  if (signing.optOut) {
4818
- logger.warn("OG image URL signing is disabled (`security.secret: false`). Anyone can craft arbitrary image generation requests.");
4837
+ logger.warn([
4838
+ "OG image URL signing is disabled (`security.secret: false`).",
4839
+ "Attackers can craft image requests and poison the cache so your real OG image URLs serve attacker-controlled content (content spoofing).",
4840
+ "Signing will be required in v7 whenever runtime image generation is enabled. Leave signing on, or set an explicit secret:",
4841
+ " NUXT_OG_IMAGE_SECRET=<secret>",
4842
+ " Generate one with: npx nuxt-og-image generate-secret"
4843
+ ].join("\n"));
4819
4844
  } else if (signing.generated) {
4820
4845
  logger.warn([
4821
4846
  "OG image URLs are signed with an auto-generated secret that changes every build.",
@@ -4860,8 +4885,7 @@ Or pin to a specific version in package.json:
4860
4885
  break;
4861
4886
  }
4862
4887
  }
4863
- nuxt.options.alias["#og-image"] = resolve("./runtime");
4864
- nuxt.options.alias["#og-image-cache"] = resolve("./runtime/server/og-image/cache/lru");
4888
+ setRuntimeAlias("#og-image-cache", resolve("./runtime/server/og-image/cache/lru"));
4865
4889
  const preset = resolveOgImagePreset(nuxt.options.nitro);
4866
4890
  const targetCompatibility = getPresetNitroPresetCompatibility(preset);
4867
4891
  const runtimeCompatibilityMeta = {};
@@ -4882,11 +4906,11 @@ Or pin to a specific version in package.json:
4882
4906
  let buildEmojiSet;
4883
4907
  if (config.defaults.emojis === false) {
4884
4908
  logger.debug("Emoji support disabled.");
4885
- nuxt.options.alias["#og-image/emoji-transform"] = resolve("./runtime/server/og-image/core/transforms/emojis/noop");
4909
+ setRuntimeAlias("#og-image/emoji-transform", resolve("./runtime/server/og-image/core/transforms/emojis/noop"));
4886
4910
  buildEmojiSet = void 0;
4887
4911
  } else {
4888
4912
  buildEmojiSet = config.defaults.emojis || "noto";
4889
- nuxt.options.alias["#og-image/emoji-transform"] = resolve("./runtime/server/og-image/core/transforms/emojis/fetch");
4913
+ setRuntimeAlias("#og-image/emoji-transform", resolve("./runtime/server/og-image/core/transforms/emojis/fetch"));
4890
4914
  }
4891
4915
  const { detectCssProvider } = await Promise.resolve().then(function () { return cssProvider; });
4892
4916
  const cssFramework = detectCssProvider(nuxt);
@@ -4894,6 +4918,10 @@ Or pin to a specific version in package.json:
4894
4918
  if (cssFramework === "unocss") {
4895
4919
  logger.debug("UnoCSS detected, using UnoCSS provider for OG image styling");
4896
4920
  const { setUnoConfig, setUnoRootDir, createUnoProvider } = await import('../chunks/uno.mjs');
4921
+ const [unocssCorePath, unocssConfigPath] = await Promise.all([
4922
+ resolveOptionalModulePath("@unocss/core", nuxt.options.rootDir, ["@unocss/nuxt", "unocss"]),
4923
+ resolveOptionalModulePath("@unocss/config", nuxt.options.rootDir, ["@unocss/nuxt", "unocss"])
4924
+ ]);
4897
4925
  setUnoRootDir(nuxt.options.rootDir);
4898
4926
  nuxt.hook("unocss:config", (config2) => {
4899
4927
  setUnoConfig(config2);
@@ -4905,12 +4933,16 @@ Or pin to a specific version in package.json:
4905
4933
  config2.content.pipeline.exclude.push(...excludePatterns);
4906
4934
  });
4907
4935
  cssProvider$1 = createUnoProvider({
4936
+ unocssCorePath,
4937
+ unocssConfigPath,
4908
4938
  async resolveCssPath() {
4909
4939
  for (const cssEntry of nuxt.options.css) {
4910
4940
  const cssPath = typeof cssEntry === "string" ? cssEntry : cssEntry?.src;
4911
4941
  if (!cssPath || !cssPath.endsWith(".css"))
4912
4942
  continue;
4913
- const resolved = await resolver.resolvePath(cssPath).catch(() => null);
4943
+ const resolved = await resolver.resolvePath(cssPath).catch(() => {
4944
+ return null;
4945
+ });
4914
4946
  if (!resolved || !existsSync(resolved))
4915
4947
  continue;
4916
4948
  return resolved;
@@ -4999,7 +5031,9 @@ Or pin to a specific version in package.json:
4999
5031
  const cssPath = typeof cssEntry === "string" ? cssEntry : cssEntry?.src;
5000
5032
  if (!cssPath || !cssPath.endsWith(".css"))
5001
5033
  continue;
5002
- const resolved = await resolver.resolvePath(cssPath).catch(() => null);
5034
+ const resolved = await resolver.resolvePath(cssPath).catch(() => {
5035
+ return null;
5036
+ });
5003
5037
  if (!resolved || !existsSync(resolved))
5004
5038
  continue;
5005
5039
  const content = await readFile(resolved, "utf-8");
@@ -5104,7 +5138,7 @@ ${familyInfo}`);
5104
5138
  });
5105
5139
  if (!nuxt.options.dev) {
5106
5140
  addBuildPlugin(TreeShakeComposablesPlugin, { server: true, client: true, build: true });
5107
- nuxt.options.alias["#og-image-cache"] = resolve("./runtime/server/og-image/cache/mock");
5141
+ setRuntimeAlias("#og-image-cache", resolve("./runtime/server/og-image/cache/mock"));
5108
5142
  }
5109
5143
  }
5110
5144
  const basePath = config.zeroRuntime ? "./runtime/server/routes/__zero-runtime" : "./runtime/server/routes";
@@ -5670,7 +5704,8 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
5670
5704
  registerTypeTemplates({
5671
5705
  nuxt,
5672
5706
  config,
5673
- componentCtx: ogImageComponentCtx
5707
+ componentCtx: ogImageComponentCtx,
5708
+ nitroCompatibility
5674
5709
  });
5675
5710
  const cacheEnabled = typeof config.runtimeCacheStorage !== "undefined" && config.runtimeCacheStorage !== false;
5676
5711
  const cacheVersion = config.cacheVersion === false ? "" : config.cacheVersion ?? version;
@@ -5774,7 +5809,7 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
5774
5809
  const getDetectedRenderers = () => ogImageComponentCtx.detectedRenderers;
5775
5810
  const getCompatibilityMeta = () => runtimeCompatibilityMeta;
5776
5811
  if (nuxt.options.dev) {
5777
- setupDevHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
5812
+ await setupDevHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
5778
5813
  setupDevToolsUI(config, resolve, nuxt, cssFramework || "none");
5779
5814
  const useNitro = new Promise((resolveNitro) => {
5780
5815
  nuxt.hooks.hook("nitro:init", resolveNitro);
@@ -5810,6 +5845,9 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
5810
5845
  } else if (nuxt.options.build) {
5811
5846
  await setupBuildHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
5812
5847
  }
5848
+ setRuntimeAlias("#og-image/app", resolve("./runtime/app"));
5849
+ setRuntimeAlias("#og-image/shared", resolve("./runtime/shared"));
5850
+ setRuntimeAlias("#og-image/types", resolve("./runtime/types"));
5813
5851
  if (nuxt.options.build)
5814
5852
  addServerPlugin(resolve("./runtime/server/plugins/prerender"));
5815
5853
  setupPrerenderHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
@@ -5821,4 +5859,4 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
5821
5859
  }
5822
5860
  });
5823
5861
 
5824
- export { extractCssVars as a, extractPropertyInitialValues as b, extractUniversalVars as c, extractPerClassVars as d, extractVariantBaseClasses as e, extractClassStyles as f, extractVarsFromCss as g, resolveExtractedVars as h, resolveVarsDeep as i, loadLightningCss as l, module$1 as m, postProcessStyles as p, resolveVariantPrefixes as r, simplifyCss as s };
5862
+ export { extractCssVars as a, extractPropertyInitialValues as b, extractUniversalVars as c, extractPerClassVars as d, extractVariantBaseClasses as e, extractClassStyles as f, extractVarsFromCss as g, resolveExtractedVars as h, importOptionalPeer as i, importResolvedModule as j, resolveOptionalModulePath as k, resolveVarsDeep as l, loadLightningCss as m, module$1 as n, postProcessStyles as p, resolveVariantPrefixes as r, simplifyCss as s };