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
|
@@ -8,11 +8,11 @@ const kit = require('@nuxt/kit');
|
|
|
8
8
|
const defu = require('defu');
|
|
9
9
|
const fnv1a64 = require('fnv1a-64');
|
|
10
10
|
const kit$2 = require('nuxt-site-config/kit');
|
|
11
|
+
const kit$1 = require('nuxtseo-shared/kit');
|
|
11
12
|
const pathe = require('pathe');
|
|
12
13
|
const pkgTypes = require('pkg-types');
|
|
13
14
|
const stdEnv = require('std-env');
|
|
14
15
|
const oxcWalker = require('oxc-walker');
|
|
15
|
-
const kit$1 = require('nuxtseo-shared/kit');
|
|
16
16
|
const logger_js = require('../../dist/runtime/logger.js');
|
|
17
17
|
const chromeLauncher = require('chrome-launcher');
|
|
18
18
|
const nypm = require('nypm');
|
|
@@ -62,7 +62,9 @@ function checkLocalChrome() {
|
|
|
62
62
|
return hasChromeLocally;
|
|
63
63
|
}
|
|
64
64
|
async function hasResolvableDependency(dep) {
|
|
65
|
-
return await kit.resolvePath(dep, { fallbackToOriginal: true }).catch(() =>
|
|
65
|
+
return await kit.resolvePath(dep, { fallbackToOriginal: true }).catch(() => {
|
|
66
|
+
return null;
|
|
67
|
+
}).then((r) => r && r !== dep);
|
|
66
68
|
}
|
|
67
69
|
const VALID_RENDERER_SUFFIXES = ["satori", "browser", "takumi"];
|
|
68
70
|
const RE_RENDERER_SUFFIX_CI = /\.?(satori|browser|takumi)$/i;
|
|
@@ -326,23 +328,32 @@ async function setupBuildHandler(config, resolve, getDetectedRenderers, getCompa
|
|
|
326
328
|
nuxt.options.nitro.storage = nuxt.options.nitro.storage || {};
|
|
327
329
|
if (typeof config.runtimeCacheStorage === "object")
|
|
328
330
|
nuxt.options.nitro.storage["nuxt-og-image"] = config.runtimeCacheStorage;
|
|
329
|
-
nuxt.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
331
|
+
const nitroConfig = nuxt.options.nitro;
|
|
332
|
+
const mockCode = `import proxy from 'mocked-exports/proxy';export default proxy;export * from 'mocked-exports/proxy';`;
|
|
333
|
+
nitroConfig.virtual = nitroConfig.virtual || {};
|
|
334
|
+
nitroConfig.virtual["playwright-core"] = mockCode;
|
|
335
|
+
nitroConfig.virtual.electron = mockCode;
|
|
336
|
+
nitroConfig.virtual["electron/index"] = mockCode;
|
|
337
|
+
nitroConfig.virtual["electron/index.js"] = mockCode;
|
|
338
|
+
nitroConfig.virtual.bufferutil = mockCode;
|
|
339
|
+
nitroConfig.virtual["utf-8-validate"] = mockCode;
|
|
340
|
+
nitroConfig.virtual["chromium-bidi"] = mockCode;
|
|
341
|
+
nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper"] = mockCode;
|
|
342
|
+
nitroConfig.virtual["chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js"] = mockCode;
|
|
343
|
+
nitroConfig.virtual.queue = mockCode;
|
|
344
|
+
await applyNitroPresetCompatibility(nitroConfig, {
|
|
345
|
+
compatibility: config.compatibility?.runtime,
|
|
346
|
+
resolve,
|
|
347
|
+
detectedRenderers: getDetectedRenderers(),
|
|
348
|
+
metadata: getCompatibilityMeta()
|
|
342
349
|
});
|
|
343
350
|
nuxt.hooks.hook("nitro:init", async (nitro) => {
|
|
344
|
-
|
|
345
|
-
|
|
351
|
+
await applyNitroPresetCompatibility(nitro.options, {
|
|
352
|
+
compatibility: config.compatibility?.runtime,
|
|
353
|
+
resolve,
|
|
354
|
+
detectedRenderers: getDetectedRenderers(),
|
|
355
|
+
metadata: getCompatibilityMeta()
|
|
356
|
+
});
|
|
346
357
|
const target = resolveOgImagePreset(nitro.options);
|
|
347
358
|
const normalizedTarget = target.replace(RE_LEGACY_SUFFIX, "");
|
|
348
359
|
const isEdgePreset = ["cloudflare", "cloudflare-pages", "cloudflare-pages-static", "cloudflare-module", "cloudflare-durable", "vercel-edge", "netlify-edge"].includes(normalizedTarget);
|
|
@@ -667,10 +678,10 @@ async function validateProviderSetup(renderer, compatibility) {
|
|
|
667
678
|
return { valid: issues.length === 0, issues };
|
|
668
679
|
}
|
|
669
680
|
|
|
670
|
-
function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = kit.useNuxt()) {
|
|
671
|
-
|
|
681
|
+
async function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = kit.useNuxt()) {
|
|
682
|
+
const applyCompatibility = async (nitroConfig) => {
|
|
672
683
|
const detectedRenderers = new Set(getDetectedRenderers());
|
|
673
|
-
const targetCompatibility = getPresetNitroPresetCompatibility(resolveOgImagePreset(
|
|
684
|
+
const targetCompatibility = getPresetNitroPresetCompatibility(resolveOgImagePreset(nitroConfig));
|
|
674
685
|
for (const renderer of ["satori", "takumi", "browser"]) {
|
|
675
686
|
if (!detectedRenderers.has(renderer)) {
|
|
676
687
|
const binding = getRecommendedBinding(renderer, targetCompatibility);
|
|
@@ -679,8 +690,10 @@ function setupDevHandler(options, resolve, getDetectedRenderers, getCompatibilit
|
|
|
679
690
|
detectedRenderers.add(renderer);
|
|
680
691
|
}
|
|
681
692
|
}
|
|
682
|
-
await applyNitroPresetCompatibility(
|
|
683
|
-
}
|
|
693
|
+
await applyNitroPresetCompatibility(nitroConfig, { compatibility: options.compatibility?.dev, resolve, detectedRenderers, metadata: getCompatibilityMeta() });
|
|
694
|
+
};
|
|
695
|
+
await applyCompatibility(nuxt.options.nitro);
|
|
696
|
+
nuxt.hooks.hook("nitro:init", (nitro) => applyCompatibility(nitro.options));
|
|
684
697
|
}
|
|
685
698
|
|
|
686
699
|
const RE_TILDE_SLASH = /^~\//;
|
|
@@ -913,7 +926,6 @@ const RE_QUOTES = /^['"]|['"]$/g;
|
|
|
913
926
|
const RE_WIDTH_VALUE = /width:([^;}]+)/;
|
|
914
927
|
const RE_CALC_VAR_MULTIPLY = /calc\(var\((--[\w-]+)\)\s*\*\s*([\d.]+)\)/;
|
|
915
928
|
const RE_NUMERIC_WITH_UNIT = /([\d.]+)(rem|px|em|%)/;
|
|
916
|
-
const RE_EXTREME_VALUE = /^(-?[\d.]+e\+?\d+)(px|rem|em|%)$/;
|
|
917
929
|
const RE_CSS_KEYWORD = /^(?:initial|inherit|unset|revert|revert-layer)$/;
|
|
918
930
|
const RE_UNRESOLVED_VAR = /var\((--[\w-]+)/g;
|
|
919
931
|
const RE_INVALID_CALC = /calc\(\s*[*/]/;
|
|
@@ -1523,18 +1535,6 @@ function convertLogicalProperties(styles) {
|
|
|
1523
1535
|
}
|
|
1524
1536
|
}
|
|
1525
1537
|
}
|
|
1526
|
-
function clampExtremeValues(styles) {
|
|
1527
|
-
for (const [prop, value] of Object.entries(styles)) {
|
|
1528
|
-
if (!value.includes("e+") && !value.includes("e38"))
|
|
1529
|
-
continue;
|
|
1530
|
-
const match = value.match(RE_EXTREME_VALUE);
|
|
1531
|
-
if (match?.[1] && match?.[2]) {
|
|
1532
|
-
const num = Number.parseFloat(match[1]);
|
|
1533
|
-
if (Math.abs(num) > 9999)
|
|
1534
|
-
styles[prop] = `9999${match[2]}`;
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
1538
|
function stripGradientColorSpace(value) {
|
|
1539
1539
|
return value.replace(css_js.GRADIENT_COLOR_SPACE_RE, "");
|
|
1540
1540
|
}
|
|
@@ -1582,7 +1582,6 @@ async function postProcessStyles(rawStyles, vars, resolveVar, context) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
convertIndividualTransforms(styles);
|
|
1584
1584
|
convertLogicalProperties(styles);
|
|
1585
|
-
clampExtremeValues(styles);
|
|
1586
1585
|
return Object.keys(styles).length ? styles : null;
|
|
1587
1586
|
}
|
|
1588
1587
|
function walkTemplateAst(nodes, visitor) {
|
|
@@ -1985,7 +1984,9 @@ async function parseFontsFromTemplate(nuxt, options) {
|
|
|
1985
1984
|
async function downloadFontFile(url, destPath) {
|
|
1986
1985
|
if (fs.existsSync(destPath))
|
|
1987
1986
|
return true;
|
|
1988
|
-
const res = await fetch(url).catch(() =>
|
|
1987
|
+
const res = await fetch(url).catch(() => {
|
|
1988
|
+
return null;
|
|
1989
|
+
});
|
|
1989
1990
|
if (!res?.ok)
|
|
1990
1991
|
return false;
|
|
1991
1992
|
await promises.writeFile(destPath, Buffer.from(await res.arrayBuffer()));
|
|
@@ -2211,7 +2212,7 @@ async function downloadStaticFonts(options) {
|
|
|
2211
2212
|
results.push(...familyResults);
|
|
2212
2213
|
}
|
|
2213
2214
|
}
|
|
2214
|
-
if (unresolvedFamilies.length > 0) {
|
|
2215
|
+
if (options.warnOnMissingStaticFonts !== false && unresolvedFamilies.length > 0) {
|
|
2215
2216
|
const providerList = fontlessCtx.providerNames.join(", ") || "none";
|
|
2216
2217
|
const localFonts = await listLocalPublicFontFiles(options.nuxt).catch(() => []);
|
|
2217
2218
|
const matchedLocal = unresolvedFamilies.map((family) => {
|
|
@@ -2343,7 +2344,8 @@ async function convertWoff2ToTtf(options) {
|
|
|
2343
2344
|
families,
|
|
2344
2345
|
nuxt,
|
|
2345
2346
|
logger,
|
|
2346
|
-
fontSubsets
|
|
2347
|
+
fontSubsets,
|
|
2348
|
+
warnOnMissingStaticFonts
|
|
2347
2349
|
});
|
|
2348
2350
|
for (const font of downloaded) {
|
|
2349
2351
|
const key = `${font.family}-${font.weight}-${font.style}`;
|
|
@@ -2482,6 +2484,34 @@ function setupGenerateHandler(_options, resolve, _getDetectedRenderers, nuxt = k
|
|
|
2482
2484
|
});
|
|
2483
2485
|
}
|
|
2484
2486
|
|
|
2487
|
+
async function resolveOptionalModulePath(id, rootDir, fallbackPackages = []) {
|
|
2488
|
+
const rootUrl = kit.directoryToURL(rootDir);
|
|
2489
|
+
const direct = await kit.tryResolveModule(id, rootUrl);
|
|
2490
|
+
if (direct)
|
|
2491
|
+
return direct;
|
|
2492
|
+
for (const pkg of fallbackPackages) {
|
|
2493
|
+
const pkgJson = await kit.tryResolveModule(`${pkg}/package.json`, rootUrl);
|
|
2494
|
+
if (!pkgJson)
|
|
2495
|
+
continue;
|
|
2496
|
+
const nested = await kit.tryResolveModule(id, kit.directoryToURL(pathe.dirname(pkgJson)));
|
|
2497
|
+
if (nested)
|
|
2498
|
+
return nested;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
async function importResolvedModule(id, resolvedPath) {
|
|
2502
|
+
return await (resolvedPath ? import(node_url.pathToFileURL(resolvedPath).href) : import(id));
|
|
2503
|
+
}
|
|
2504
|
+
async function importOptionalPeer(id, resolvedPath, usage) {
|
|
2505
|
+
try {
|
|
2506
|
+
return await importResolvedModule(id, resolvedPath);
|
|
2507
|
+
} catch (cause) {
|
|
2508
|
+
throw new Error(
|
|
2509
|
+
`[nuxt-og-image] Missing optional peer dependency "${id}". Install it to use ${usage}.`,
|
|
2510
|
+
{ cause }
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2485
2515
|
const ONE_WEEK_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
2486
2516
|
function setupPrerenderHandler(options, resolve, getDetectedRenderers, getCompatibilityMeta = () => ({}), nuxt = kit.useNuxt()) {
|
|
2487
2517
|
nuxt.hooks.hook("nitro:init", async (nitro) => {
|
|
@@ -2626,7 +2656,7 @@ const TreeShakeComposablesPlugin = unplugin.createUnplugin(() => {
|
|
|
2626
2656
|
},
|
|
2627
2657
|
transform(code, id) {
|
|
2628
2658
|
const s = new MagicString__default(code);
|
|
2629
|
-
if (id.endsWith("components.islands.mjs"))
|
|
2659
|
+
if (!id.endsWith("components.islands.mjs")) {
|
|
2630
2660
|
const strippedCode = stripLiteral.stripLiteral(code);
|
|
2631
2661
|
if (!COMPOSABLE_RE.test(code)) {
|
|
2632
2662
|
return;
|
|
@@ -3223,7 +3253,9 @@ const iconCache = /* @__PURE__ */ new Map();
|
|
|
3223
3253
|
async function loadIconSet(prefix) {
|
|
3224
3254
|
if (iconCache.has(prefix))
|
|
3225
3255
|
return iconCache.get(prefix);
|
|
3226
|
-
const icons = await import(`@iconify-json/${prefix}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() =>
|
|
3256
|
+
const icons = await import(`@iconify-json/${prefix}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => {
|
|
3257
|
+
return null;
|
|
3258
|
+
});
|
|
3227
3259
|
iconCache.set(prefix, icons);
|
|
3228
3260
|
if (iconCache.size > 20)
|
|
3229
3261
|
iconCache.delete(iconCache.keys().next().value);
|
|
@@ -3407,7 +3439,9 @@ const AssetTransformPlugin = unplugin.createUnplugin((options) => {
|
|
|
3407
3439
|
let hasChanges = false;
|
|
3408
3440
|
if (options.emojiSet && emojiUtils_js.RE_MATCH_EMOJIS.test(template)) {
|
|
3409
3441
|
if (!emojiIcons) {
|
|
3410
|
-
emojiIcons = options.emojiIcons ?? await import(`@iconify-json/${options.emojiSet}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() =>
|
|
3442
|
+
emojiIcons = options.emojiIcons ?? await import(`@iconify-json/${options.emojiSet}/icons.json`, { with: { type: 'json' } }).then((m) => m.default).catch(() => {
|
|
3443
|
+
return null;
|
|
3444
|
+
});
|
|
3411
3445
|
}
|
|
3412
3446
|
emojiUtils_js.RE_MATCH_EMOJIS.lastIndex = 0;
|
|
3413
3447
|
const allEmojis = /* @__PURE__ */ new Set();
|
|
@@ -3697,7 +3731,9 @@ const AssetTransformPlugin = unplugin.createUnplugin((options) => {
|
|
|
3697
3731
|
} else {
|
|
3698
3732
|
continue;
|
|
3699
3733
|
}
|
|
3700
|
-
const fileBuffer = await promises.readFile(resolvedPath).catch(() =>
|
|
3734
|
+
const fileBuffer = await promises.readFile(resolvedPath).catch(() => {
|
|
3735
|
+
return null;
|
|
3736
|
+
});
|
|
3701
3737
|
if (!fileBuffer)
|
|
3702
3738
|
continue;
|
|
3703
3739
|
const mimeType = getMimeType(ext);
|
|
@@ -4081,7 +4117,6 @@ ${importStatements}
|
|
|
4081
4117
|
const warnings = [];
|
|
4082
4118
|
const counts = {
|
|
4083
4119
|
config: /* @__PURE__ */ new Map(),
|
|
4084
|
-
composable: /* @__PURE__ */ new Map(),
|
|
4085
4120
|
component: /* @__PURE__ */ new Map()
|
|
4086
4121
|
};
|
|
4087
4122
|
let hasEmitted = false;
|
|
@@ -4103,13 +4138,6 @@ const REMOVED_CONFIG = {
|
|
|
4103
4138
|
"defaults.renderer": "Removed (renderer determined by component filename suffix)",
|
|
4104
4139
|
"defaults.component": "Removed (rename component to OgImage/Default.{renderer}.vue)"
|
|
4105
4140
|
};
|
|
4106
|
-
const DEPRECATED_COMPOSABLES$1 = {
|
|
4107
|
-
defineOgImageComponent: "defineOgImage()",
|
|
4108
|
-
defineOgImageStatic: "defineOgImage()",
|
|
4109
|
-
defineOgImageDynamic: "defineOgImage()",
|
|
4110
|
-
defineOgImageCached: "defineOgImage()",
|
|
4111
|
-
defineOgImageWithoutCache: "defineOgImage()"
|
|
4112
|
-
};
|
|
4113
4141
|
function addWarning(warning) {
|
|
4114
4142
|
const countMap = counts[warning.type];
|
|
4115
4143
|
const current = countMap.get(warning.code) || 0;
|
|
@@ -4139,13 +4167,13 @@ function addComponentWarning(componentPath) {
|
|
|
4139
4167
|
});
|
|
4140
4168
|
}
|
|
4141
4169
|
function hasWarnings() {
|
|
4142
|
-
return warnings.length > 0 || counts.config.size > 0 || counts.
|
|
4170
|
+
return warnings.length > 0 || counts.config.size > 0 || counts.component.size > 0;
|
|
4143
4171
|
}
|
|
4144
4172
|
function emitWarnings() {
|
|
4145
4173
|
if (hasEmitted || !hasWarnings())
|
|
4146
4174
|
return;
|
|
4147
4175
|
hasEmitted = true;
|
|
4148
|
-
const totalIssues = [...counts.config.values()].reduce((a, b) => a + b, 0) + [...counts.
|
|
4176
|
+
const totalIssues = [...counts.config.values()].reduce((a, b) => a + b, 0) + [...counts.component.values()].reduce((a, b) => a + b, 0);
|
|
4149
4177
|
const body = [
|
|
4150
4178
|
formatWarnings(),
|
|
4151
4179
|
"",
|
|
@@ -4182,17 +4210,6 @@ function formatWarnings() {
|
|
|
4182
4210
|
}
|
|
4183
4211
|
lines.push("");
|
|
4184
4212
|
}
|
|
4185
|
-
if (counts.composable.size > 0) {
|
|
4186
|
-
lines.push("Deprecated composables:");
|
|
4187
|
-
for (const [name, count] of counts.composable) {
|
|
4188
|
-
const replacement = DEPRECATED_COMPOSABLES$1[name];
|
|
4189
|
-
const suffix = count > 1 ? ` (\xD7${count})` : "";
|
|
4190
|
-
lines.push(` \u2022 ${name}()${suffix}`);
|
|
4191
|
-
if (replacement)
|
|
4192
|
-
lines.push(` \u2192 Use: ${replacement}`);
|
|
4193
|
-
}
|
|
4194
|
-
lines.push("");
|
|
4195
|
-
}
|
|
4196
4213
|
if (counts.component.size > 0) {
|
|
4197
4214
|
const componentCount = [...counts.component.values()].reduce((a, b) => a + b, 0);
|
|
4198
4215
|
lines.push(`Components missing renderer suffix: ${componentCount}`);
|
|
@@ -4474,7 +4491,7 @@ function getComponentTypeExpression(component, nuxt) {
|
|
|
4474
4491
|
return `typeof import('${relativeComponentPath}')['default']`;
|
|
4475
4492
|
}
|
|
4476
4493
|
function registerTypeTemplates(ctx) {
|
|
4477
|
-
const { nuxt, config, componentCtx } = ctx;
|
|
4494
|
+
const { nuxt, config, componentCtx, nitroCompatibility } = ctx;
|
|
4478
4495
|
nuxt.hook("prepare:types", ({ tsConfig }) => {
|
|
4479
4496
|
tsConfig.include = tsConfig.include || [];
|
|
4480
4497
|
tsConfig.include.push("./module/nuxt-og-image-components.d.ts");
|
|
@@ -4525,7 +4542,7 @@ ${lines.join("\n")}
|
|
|
4525
4542
|
getContents: (data) => {
|
|
4526
4543
|
const typesPath = pathe.relative(pathe.resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), pathe.resolve("runtime/types"));
|
|
4527
4544
|
return `declare module '#og-image-virtual/public-assets.mjs' {
|
|
4528
|
-
import type { H3Event } from 'h3'
|
|
4545
|
+
import type { H3Event } from '#nuxtseo/h3'
|
|
4529
4546
|
import type { FontConfig } from '${typesPath}'
|
|
4530
4547
|
export function resolve(event: H3Event, font: FontConfig): Promise<BufferSource>
|
|
4531
4548
|
}
|
|
@@ -4604,7 +4621,7 @@ declare module '#og-image-virtual/tw4-theme.mjs' {
|
|
|
4604
4621
|
getContents: (data) => {
|
|
4605
4622
|
const typesPath = pathe.relative(pathe.resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), pathe.resolve("runtime/types"));
|
|
4606
4623
|
return `declare module '#og-image/bindings/browser' {
|
|
4607
|
-
import type { H3Event } from 'h3'
|
|
4624
|
+
import type { H3Event } from '#nuxtseo/h3'
|
|
4608
4625
|
export function createBrowser(event?: H3Event): Promise<any>
|
|
4609
4626
|
}
|
|
4610
4627
|
|
|
@@ -4664,40 +4681,34 @@ declare module '#og-image-cache' {
|
|
|
4664
4681
|
filename: "types/og-image-augments.d.ts",
|
|
4665
4682
|
getContents: (data) => {
|
|
4666
4683
|
const typesPath = pathe.relative(pathe.resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "types"), pathe.resolve("runtime/types"));
|
|
4684
|
+
const nitroAugmentations = kit$1.renderNitroTypeAugmentations(nitroCompatibility, {
|
|
4685
|
+
nitroInterfaces: {
|
|
4686
|
+
NitroApp: `_ogImageCacheBackendWarned?: boolean
|
|
4687
|
+
_ogImageIconsData?: OgImageIconsData`,
|
|
4688
|
+
NitroRuntimeConfig: `'nuxt-og-image': OgImageRuntimeConfig
|
|
4689
|
+
ogImage?: {
|
|
4690
|
+
secret?: string
|
|
4691
|
+
}`
|
|
4692
|
+
},
|
|
4693
|
+
routeRules: "ogImage?: false | OgImageOptions & Record<string, any>",
|
|
4694
|
+
routeConfig: "ogImage?: false | OgImageOptions & Record<string, any>",
|
|
4695
|
+
runtimeHooks: `'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
|
|
4696
|
+
'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>`,
|
|
4697
|
+
eventContext: `_nitro?: {
|
|
4698
|
+
routeRules?: import('${nitroCompatibility.nitroTypesModule}').NitroRouteRules
|
|
4699
|
+
}
|
|
4700
|
+
_ogImagePrerenderPaths?: Map<string, string>`
|
|
4701
|
+
});
|
|
4667
4702
|
return `/// <reference path="./og-image-virtual.d.ts" />
|
|
4668
4703
|
/// <reference path="./og-image-bindings.d.ts" />
|
|
4669
|
-
import type { OgImageOptions, OgImageRenderEventContext, VNode } from '${typesPath}'
|
|
4704
|
+
import type { OgImageIconsData, OgImageOptions, OgImageRenderEventContext, OgImageRuntimeConfig, VNode } from '${typesPath}'
|
|
4670
4705
|
|
|
4671
|
-
|
|
4672
|
-
interface NitroRouteRules {
|
|
4673
|
-
ogImage?: false | OgImageOptions & Record<string, any>
|
|
4674
|
-
}
|
|
4675
|
-
interface NitroRouteConfig {
|
|
4676
|
-
ogImage?: false | OgImageOptions & Record<string, any>
|
|
4677
|
-
}
|
|
4678
|
-
interface NitroRuntimeHooks {
|
|
4679
|
-
'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
|
|
4680
|
-
'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>
|
|
4681
|
-
}
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4684
|
-
declare module 'nitropack/types' {
|
|
4685
|
-
interface NitroRouteRules {
|
|
4686
|
-
ogImage?: false | OgImageOptions & Record<string, any>
|
|
4687
|
-
}
|
|
4688
|
-
interface NitroRouteConfig {
|
|
4689
|
-
ogImage?: false | OgImageOptions & Record<string, any>
|
|
4690
|
-
}
|
|
4691
|
-
interface NitroRuntimeHooks {
|
|
4692
|
-
'nuxt-og-image:context': (ctx: OgImageRenderEventContext) => void | Promise<void>
|
|
4693
|
-
'nuxt-og-image:satori:vnodes': (vnodes: VNode, ctx: OgImageRenderEventContext) => void | Promise<void>
|
|
4694
|
-
}
|
|
4695
|
-
}
|
|
4706
|
+
${nitroAugmentations}
|
|
4696
4707
|
|
|
4697
4708
|
export {}
|
|
4698
4709
|
`;
|
|
4699
4710
|
}
|
|
4700
|
-
});
|
|
4711
|
+
}, { nitro: true, nuxt: true });
|
|
4701
4712
|
}
|
|
4702
4713
|
|
|
4703
4714
|
const RE_INLINE_CONFIG = /const\s+inlineConfig\s*=\s*(\{[\s\S]*?\n\})/;
|
|
@@ -4705,14 +4716,16 @@ const RE_PASCAL_TO_KEBAB = /([a-z])([A-Z])/g;
|
|
|
4705
4716
|
const RE_TILDE_PREFIX = /^~\//;
|
|
4706
4717
|
const IS_MODULE_DEVELOPMENT = undefined.endsWith(".ts");
|
|
4707
4718
|
async function findPackageVersionFromEntry(pkg, resolver) {
|
|
4708
|
-
const entry = await resolver.resolvePath(pkg, { fallbackToOriginal: false }).catch(() =>
|
|
4719
|
+
const entry = await resolver.resolvePath(pkg, { fallbackToOriginal: false }).catch(() => {
|
|
4720
|
+
return null;
|
|
4721
|
+
});
|
|
4709
4722
|
if (!entry || entry === pkg)
|
|
4710
4723
|
return;
|
|
4711
4724
|
let dir = pathe.dirname(entry);
|
|
4712
4725
|
while (dir && dir !== pathe.dirname(dir)) {
|
|
4713
4726
|
const pkgPath = pathe.join(dir, "package.json");
|
|
4714
4727
|
if (fs.existsSync(pkgPath)) {
|
|
4715
|
-
const pkgJson = await pkgTypes.readPackageJSON(pkgPath)
|
|
4728
|
+
const pkgJson = await pkgTypes.readPackageJSON(pkgPath);
|
|
4716
4729
|
if (pkgJson?.name === pkg)
|
|
4717
4730
|
return pkgJson.version;
|
|
4718
4731
|
}
|
|
@@ -4790,7 +4803,7 @@ const module$1 = kit.defineNuxtModule({
|
|
|
4790
4803
|
await onUpgrade(nuxt, options, previousVersion);
|
|
4791
4804
|
},
|
|
4792
4805
|
async setup(config, nuxt) {
|
|
4793
|
-
const _resolver = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/nuxt-og-image.
|
|
4806
|
+
const _resolver = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/nuxt-og-image.CdpC3njh.cjs', document.baseURI).href)));
|
|
4794
4807
|
const fixSharedPath = (p) => {
|
|
4795
4808
|
return p.replace(/\/shared\/runtime(\/|$)/, "/runtime$1").replace(/\/shared\/client(\/|$)/, "/client$1").replace(/\/shared\/devtools(\/|$)/, "/devtools$1");
|
|
4796
4809
|
};
|
|
@@ -4810,6 +4823,12 @@ const module$1 = kit.defineNuxtModule({
|
|
|
4810
4823
|
});
|
|
4811
4824
|
return;
|
|
4812
4825
|
}
|
|
4826
|
+
const nitroCompatibility = kit$1.setupNitroRuntimeCompatibility(nuxt);
|
|
4827
|
+
const setRuntimeAlias = (id, path) => {
|
|
4828
|
+
nuxt.options.alias[id] = path;
|
|
4829
|
+
nuxt.options.nitro.alias ||= {};
|
|
4830
|
+
nuxt.options.nitro.alias[id] = path;
|
|
4831
|
+
};
|
|
4813
4832
|
if (config.enabled && !nuxt.options.ssr) {
|
|
4814
4833
|
logger_js.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 }`).");
|
|
4815
4834
|
return;
|
|
@@ -4835,7 +4854,13 @@ const module$1 = kit.defineNuxtModule({
|
|
|
4835
4854
|
if (!nuxt.options.dev || config.zeroRuntime || !hasServerRuntime)
|
|
4836
4855
|
return;
|
|
4837
4856
|
if (signing.optOut) {
|
|
4838
|
-
logger_js.logger.warn(
|
|
4857
|
+
logger_js.logger.warn([
|
|
4858
|
+
"OG image URL signing is disabled (`security.secret: false`).",
|
|
4859
|
+
"Attackers can craft image requests and poison the cache so your real OG image URLs serve attacker-controlled content (content spoofing).",
|
|
4860
|
+
"Signing will be required in v7 whenever runtime image generation is enabled. Leave signing on, or set an explicit secret:",
|
|
4861
|
+
" NUXT_OG_IMAGE_SECRET=<secret>",
|
|
4862
|
+
" Generate one with: npx nuxt-og-image generate-secret"
|
|
4863
|
+
].join("\n"));
|
|
4839
4864
|
} else if (signing.generated) {
|
|
4840
4865
|
logger_js.logger.warn([
|
|
4841
4866
|
"OG image URLs are signed with an auto-generated secret that changes every build.",
|
|
@@ -4880,8 +4905,7 @@ Or pin to a specific version in package.json:
|
|
|
4880
4905
|
break;
|
|
4881
4906
|
}
|
|
4882
4907
|
}
|
|
4883
|
-
|
|
4884
|
-
nuxt.options.alias["#og-image-cache"] = resolve("./runtime/server/og-image/cache/lru");
|
|
4908
|
+
setRuntimeAlias("#og-image-cache", resolve("./runtime/server/og-image/cache/lru"));
|
|
4885
4909
|
const preset = resolveOgImagePreset(nuxt.options.nitro);
|
|
4886
4910
|
const targetCompatibility = getPresetNitroPresetCompatibility(preset);
|
|
4887
4911
|
const runtimeCompatibilityMeta = {};
|
|
@@ -4902,11 +4926,11 @@ Or pin to a specific version in package.json:
|
|
|
4902
4926
|
let buildEmojiSet;
|
|
4903
4927
|
if (config.defaults.emojis === false) {
|
|
4904
4928
|
logger_js.logger.debug("Emoji support disabled.");
|
|
4905
|
-
|
|
4929
|
+
setRuntimeAlias("#og-image/emoji-transform", resolve("./runtime/server/og-image/core/transforms/emojis/noop"));
|
|
4906
4930
|
buildEmojiSet = void 0;
|
|
4907
4931
|
} else {
|
|
4908
4932
|
buildEmojiSet = config.defaults.emojis || "noto";
|
|
4909
|
-
|
|
4933
|
+
setRuntimeAlias("#og-image/emoji-transform", resolve("./runtime/server/og-image/core/transforms/emojis/fetch"));
|
|
4910
4934
|
}
|
|
4911
4935
|
const { detectCssProvider } = await Promise.resolve().then(function () { return cssProvider; });
|
|
4912
4936
|
const cssFramework = detectCssProvider(nuxt);
|
|
@@ -4914,6 +4938,10 @@ Or pin to a specific version in package.json:
|
|
|
4914
4938
|
if (cssFramework === "unocss") {
|
|
4915
4939
|
logger_js.logger.debug("UnoCSS detected, using UnoCSS provider for OG image styling");
|
|
4916
4940
|
const { setUnoConfig, setUnoRootDir, createUnoProvider } = await import('../chunks/uno.cjs');
|
|
4941
|
+
const [unocssCorePath, unocssConfigPath] = await Promise.all([
|
|
4942
|
+
resolveOptionalModulePath("@unocss/core", nuxt.options.rootDir, ["@unocss/nuxt", "unocss"]),
|
|
4943
|
+
resolveOptionalModulePath("@unocss/config", nuxt.options.rootDir, ["@unocss/nuxt", "unocss"])
|
|
4944
|
+
]);
|
|
4917
4945
|
setUnoRootDir(nuxt.options.rootDir);
|
|
4918
4946
|
nuxt.hook("unocss:config", (config2) => {
|
|
4919
4947
|
setUnoConfig(config2);
|
|
@@ -4925,12 +4953,16 @@ Or pin to a specific version in package.json:
|
|
|
4925
4953
|
config2.content.pipeline.exclude.push(...excludePatterns);
|
|
4926
4954
|
});
|
|
4927
4955
|
cssProvider$1 = createUnoProvider({
|
|
4956
|
+
unocssCorePath,
|
|
4957
|
+
unocssConfigPath,
|
|
4928
4958
|
async resolveCssPath() {
|
|
4929
4959
|
for (const cssEntry of nuxt.options.css) {
|
|
4930
4960
|
const cssPath = typeof cssEntry === "string" ? cssEntry : cssEntry?.src;
|
|
4931
4961
|
if (!cssPath || !cssPath.endsWith(".css"))
|
|
4932
4962
|
continue;
|
|
4933
|
-
const resolved = await resolver.resolvePath(cssPath).catch(() =>
|
|
4963
|
+
const resolved = await resolver.resolvePath(cssPath).catch(() => {
|
|
4964
|
+
return null;
|
|
4965
|
+
});
|
|
4934
4966
|
if (!resolved || !fs.existsSync(resolved))
|
|
4935
4967
|
continue;
|
|
4936
4968
|
return resolved;
|
|
@@ -5019,7 +5051,9 @@ Or pin to a specific version in package.json:
|
|
|
5019
5051
|
const cssPath = typeof cssEntry === "string" ? cssEntry : cssEntry?.src;
|
|
5020
5052
|
if (!cssPath || !cssPath.endsWith(".css"))
|
|
5021
5053
|
continue;
|
|
5022
|
-
const resolved = await resolver.resolvePath(cssPath).catch(() =>
|
|
5054
|
+
const resolved = await resolver.resolvePath(cssPath).catch(() => {
|
|
5055
|
+
return null;
|
|
5056
|
+
});
|
|
5023
5057
|
if (!resolved || !fs.existsSync(resolved))
|
|
5024
5058
|
continue;
|
|
5025
5059
|
const content = await promises.readFile(resolved, "utf-8");
|
|
@@ -5124,7 +5158,7 @@ ${familyInfo}`);
|
|
|
5124
5158
|
});
|
|
5125
5159
|
if (!nuxt.options.dev) {
|
|
5126
5160
|
kit.addBuildPlugin(TreeShakeComposablesPlugin, { server: true, client: true, build: true });
|
|
5127
|
-
|
|
5161
|
+
setRuntimeAlias("#og-image-cache", resolve("./runtime/server/og-image/cache/mock"));
|
|
5128
5162
|
}
|
|
5129
5163
|
}
|
|
5130
5164
|
const basePath = config.zeroRuntime ? "./runtime/server/routes/__zero-runtime" : "./runtime/server/routes";
|
|
@@ -5690,7 +5724,8 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
|
|
|
5690
5724
|
registerTypeTemplates({
|
|
5691
5725
|
nuxt,
|
|
5692
5726
|
config,
|
|
5693
|
-
componentCtx: ogImageComponentCtx
|
|
5727
|
+
componentCtx: ogImageComponentCtx,
|
|
5728
|
+
nitroCompatibility
|
|
5694
5729
|
});
|
|
5695
5730
|
const cacheEnabled = typeof config.runtimeCacheStorage !== "undefined" && config.runtimeCacheStorage !== false;
|
|
5696
5731
|
const cacheVersion = config.cacheVersion === false ? "" : config.cacheVersion ?? version;
|
|
@@ -5794,7 +5829,7 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
|
|
|
5794
5829
|
const getDetectedRenderers = () => ogImageComponentCtx.detectedRenderers;
|
|
5795
5830
|
const getCompatibilityMeta = () => runtimeCompatibilityMeta;
|
|
5796
5831
|
if (nuxt.options.dev) {
|
|
5797
|
-
setupDevHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
|
|
5832
|
+
await setupDevHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
|
|
5798
5833
|
setupDevToolsUI(config, resolve, nuxt, cssFramework || "none");
|
|
5799
5834
|
const useNitro = new Promise((resolveNitro) => {
|
|
5800
5835
|
nuxt.hooks.hook("nitro:init", resolveNitro);
|
|
@@ -5830,6 +5865,9 @@ export const rootDir = ${JSON.stringify(nuxt.options.rootDir)}`;
|
|
|
5830
5865
|
} else if (nuxt.options.build) {
|
|
5831
5866
|
await setupBuildHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
|
|
5832
5867
|
}
|
|
5868
|
+
setRuntimeAlias("#og-image/app", resolve("./runtime/app"));
|
|
5869
|
+
setRuntimeAlias("#og-image/shared", resolve("./runtime/shared"));
|
|
5870
|
+
setRuntimeAlias("#og-image/types", resolve("./runtime/types"));
|
|
5833
5871
|
if (nuxt.options.build)
|
|
5834
5872
|
kit.addServerPlugin(resolve("./runtime/server/plugins/prerender"));
|
|
5835
5873
|
setupPrerenderHandler(config, resolver, getDetectedRenderers, getCompatibilityMeta);
|
|
@@ -5848,10 +5886,13 @@ exports.extractPropertyInitialValues = extractPropertyInitialValues;
|
|
|
5848
5886
|
exports.extractUniversalVars = extractUniversalVars;
|
|
5849
5887
|
exports.extractVariantBaseClasses = extractVariantBaseClasses;
|
|
5850
5888
|
exports.extractVarsFromCss = extractVarsFromCss;
|
|
5889
|
+
exports.importOptionalPeer = importOptionalPeer;
|
|
5890
|
+
exports.importResolvedModule = importResolvedModule;
|
|
5851
5891
|
exports.loadLightningCss = loadLightningCss;
|
|
5852
5892
|
exports.module = module$1;
|
|
5853
5893
|
exports.postProcessStyles = postProcessStyles;
|
|
5854
5894
|
exports.resolveExtractedVars = resolveExtractedVars;
|
|
5895
|
+
exports.resolveOptionalModulePath = resolveOptionalModulePath;
|
|
5855
5896
|
exports.resolveVariantPrefixes = resolveVariantPrefixes;
|
|
5856
5897
|
exports.resolveVarsDeep = resolveVarsDeep;
|
|
5857
5898
|
exports.simplifyCss = simplifyCss;
|