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
package/dist/chunks/tw4.cjs
CHANGED
|
@@ -4,17 +4,17 @@ const promises = require('node:fs/promises');
|
|
|
4
4
|
const node_url = require('node:url');
|
|
5
5
|
const exsolve = require('exsolve');
|
|
6
6
|
const pathe = require('pathe');
|
|
7
|
-
const module$1 = require('../shared/nuxt-og-image.
|
|
7
|
+
const module$1 = require('../shared/nuxt-og-image.CdpC3njh.cjs');
|
|
8
8
|
require('node:crypto');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('@nuxt/kit');
|
|
11
11
|
require('defu');
|
|
12
12
|
require('fnv1a-64');
|
|
13
13
|
require('nuxt-site-config/kit');
|
|
14
|
+
require('nuxtseo-shared/kit');
|
|
14
15
|
require('pkg-types');
|
|
15
16
|
require('std-env');
|
|
16
17
|
require('oxc-walker');
|
|
17
|
-
require('nuxtseo-shared/kit');
|
|
18
18
|
require('../../dist/runtime/logger.js');
|
|
19
19
|
require('chrome-launcher');
|
|
20
20
|
require('nypm');
|
package/dist/chunks/tw4.mjs
CHANGED
|
@@ -2,17 +2,17 @@ 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,
|
|
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';
|
|
6
6
|
import 'node:crypto';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import '@nuxt/kit';
|
|
9
9
|
import 'defu';
|
|
10
10
|
import 'fnv1a-64';
|
|
11
11
|
import 'nuxt-site-config/kit';
|
|
12
|
+
import 'nuxtseo-shared/kit';
|
|
12
13
|
import 'pkg-types';
|
|
13
14
|
import 'std-env';
|
|
14
15
|
import 'oxc-walker';
|
|
15
|
-
import 'nuxtseo-shared/kit';
|
|
16
16
|
import '../../dist/runtime/logger.js';
|
|
17
17
|
import 'chrome-launcher';
|
|
18
18
|
import 'nypm';
|
package/dist/chunks/uno.cjs
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
const promises = require('node:fs/promises');
|
|
4
4
|
const defu = require('defu');
|
|
5
5
|
const logger_js = require('../../dist/runtime/logger.js');
|
|
6
|
-
const module$1 = require('../shared/nuxt-og-image.
|
|
6
|
+
const module$1 = require('../shared/nuxt-og-image.CdpC3njh.cjs');
|
|
7
7
|
require('node:crypto');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('node:url');
|
|
10
10
|
require('@nuxt/kit');
|
|
11
11
|
require('fnv1a-64');
|
|
12
12
|
require('nuxt-site-config/kit');
|
|
13
|
+
require('nuxtseo-shared/kit');
|
|
13
14
|
require('pathe');
|
|
14
15
|
require('pkg-types');
|
|
15
16
|
require('std-env');
|
|
16
17
|
require('oxc-walker');
|
|
17
|
-
require('nuxtseo-shared/kit');
|
|
18
18
|
require('chrome-launcher');
|
|
19
19
|
require('nypm');
|
|
20
20
|
require('nuxtseo-shared/devtools');
|
|
@@ -42,6 +42,8 @@ const RE_HEIGHT_ATTR = /\bheight=['"](\d+)['"]/;
|
|
|
42
42
|
const RE_SVG_BODY = /<svg[^>]*>([\s\S]*)<\/svg>/;
|
|
43
43
|
let unoConfig = null;
|
|
44
44
|
let rootDir = null;
|
|
45
|
+
let unocssCorePath;
|
|
46
|
+
let unocssConfigPath;
|
|
45
47
|
let generator = null;
|
|
46
48
|
let pendingGenerator = null;
|
|
47
49
|
let cachedExtracted = null;
|
|
@@ -60,6 +62,15 @@ function clearUnoCache() {
|
|
|
60
62
|
pendingGenerator = null;
|
|
61
63
|
cachedExtracted = null;
|
|
62
64
|
}
|
|
65
|
+
function setUnoModulePaths(options) {
|
|
66
|
+
const nextCorePath = options?.unocssCorePath;
|
|
67
|
+
const nextConfigPath = options?.unocssConfigPath;
|
|
68
|
+
if (nextCorePath === unocssCorePath && nextConfigPath === unocssConfigPath)
|
|
69
|
+
return;
|
|
70
|
+
unocssCorePath = nextCorePath;
|
|
71
|
+
unocssConfigPath = nextConfigPath;
|
|
72
|
+
clearUnoCache();
|
|
73
|
+
}
|
|
63
74
|
async function getGenerator() {
|
|
64
75
|
if (generator)
|
|
65
76
|
return generator;
|
|
@@ -68,17 +79,18 @@ async function getGenerator() {
|
|
|
68
79
|
pendingGenerator = (async () => {
|
|
69
80
|
let loadedConfig;
|
|
70
81
|
try {
|
|
71
|
-
const { loadConfig } = await
|
|
82
|
+
const { loadConfig } = await module$1.importOptionalPeer("@unocss/config", unocssConfigPath, "UnoCSS class extraction with OG images");
|
|
72
83
|
const result = await loadConfig(rootDir || process.cwd());
|
|
73
84
|
loadedConfig = result.config;
|
|
74
85
|
} catch (e) {
|
|
75
|
-
|
|
86
|
+
if (!unoConfig)
|
|
87
|
+
logger_js.logger.warn("[og-image UnoCSS] Failed to load uno.config.ts:", e.message);
|
|
76
88
|
}
|
|
77
89
|
const finalConfig = loadedConfig ? defu.defu(unoConfig || {}, loadedConfig) : unoConfig;
|
|
78
90
|
if (!finalConfig) {
|
|
79
91
|
throw new Error("UnoCSS config not found. Ensure uno.config.ts exists or @unocss/nuxt is loaded.");
|
|
80
92
|
}
|
|
81
|
-
const { createGenerator } = await
|
|
93
|
+
const { createGenerator } = await module$1.importOptionalPeer("@unocss/core", unocssCorePath, "UnoCSS class extraction with OG images");
|
|
82
94
|
generator = await createGenerator(finalConfig);
|
|
83
95
|
return generator;
|
|
84
96
|
})();
|
|
@@ -116,6 +128,7 @@ function resolveUserVars(extracted, rootAttrs) {
|
|
|
116
128
|
return module$1.resolveExtractedVars(extracted, rootAttrs);
|
|
117
129
|
}
|
|
118
130
|
function createUnoProvider(options) {
|
|
131
|
+
setUnoModulePaths(options);
|
|
119
132
|
return {
|
|
120
133
|
name: "unocss",
|
|
121
134
|
async resolveClassesToStyles(classes, context, rootAttrs) {
|
|
@@ -227,6 +240,8 @@ function createUnoProvider(options) {
|
|
|
227
240
|
};
|
|
228
241
|
}
|
|
229
242
|
|
|
243
|
+
exports.importResolvedModule = module$1.importResolvedModule;
|
|
244
|
+
exports.resolveOptionalModulePath = module$1.resolveOptionalModulePath;
|
|
230
245
|
exports.clearUnoCache = clearUnoCache;
|
|
231
246
|
exports.clearUnoUserVarsCache = clearUnoUserVarsCache;
|
|
232
247
|
exports.createUnoProvider = createUnoProvider;
|
package/dist/chunks/uno.mjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
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, g as extractVarsFromCss, h as resolveExtractedVars } from '../shared/nuxt-og-image.
|
|
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';
|
|
5
6
|
import 'node:crypto';
|
|
6
7
|
import 'node:fs';
|
|
7
8
|
import 'node:url';
|
|
8
9
|
import '@nuxt/kit';
|
|
9
10
|
import 'fnv1a-64';
|
|
10
11
|
import 'nuxt-site-config/kit';
|
|
12
|
+
import 'nuxtseo-shared/kit';
|
|
11
13
|
import 'pathe';
|
|
12
14
|
import 'pkg-types';
|
|
13
15
|
import 'std-env';
|
|
14
16
|
import 'oxc-walker';
|
|
15
|
-
import 'nuxtseo-shared/kit';
|
|
16
17
|
import 'chrome-launcher';
|
|
17
18
|
import 'nypm';
|
|
18
19
|
import 'nuxtseo-shared/devtools';
|
|
@@ -40,6 +41,8 @@ const RE_HEIGHT_ATTR = /\bheight=['"](\d+)['"]/;
|
|
|
40
41
|
const RE_SVG_BODY = /<svg[^>]*>([\s\S]*)<\/svg>/;
|
|
41
42
|
let unoConfig = null;
|
|
42
43
|
let rootDir = null;
|
|
44
|
+
let unocssCorePath;
|
|
45
|
+
let unocssConfigPath;
|
|
43
46
|
let generator = null;
|
|
44
47
|
let pendingGenerator = null;
|
|
45
48
|
let cachedExtracted = null;
|
|
@@ -58,6 +61,15 @@ function clearUnoCache() {
|
|
|
58
61
|
pendingGenerator = null;
|
|
59
62
|
cachedExtracted = null;
|
|
60
63
|
}
|
|
64
|
+
function setUnoModulePaths(options) {
|
|
65
|
+
const nextCorePath = options?.unocssCorePath;
|
|
66
|
+
const nextConfigPath = options?.unocssConfigPath;
|
|
67
|
+
if (nextCorePath === unocssCorePath && nextConfigPath === unocssConfigPath)
|
|
68
|
+
return;
|
|
69
|
+
unocssCorePath = nextCorePath;
|
|
70
|
+
unocssConfigPath = nextConfigPath;
|
|
71
|
+
clearUnoCache();
|
|
72
|
+
}
|
|
61
73
|
async function getGenerator() {
|
|
62
74
|
if (generator)
|
|
63
75
|
return generator;
|
|
@@ -66,17 +78,18 @@ async function getGenerator() {
|
|
|
66
78
|
pendingGenerator = (async () => {
|
|
67
79
|
let loadedConfig;
|
|
68
80
|
try {
|
|
69
|
-
const { loadConfig } = await
|
|
81
|
+
const { loadConfig } = await importOptionalPeer("@unocss/config", unocssConfigPath, "UnoCSS class extraction with OG images");
|
|
70
82
|
const result = await loadConfig(rootDir || process.cwd());
|
|
71
83
|
loadedConfig = result.config;
|
|
72
84
|
} catch (e) {
|
|
73
|
-
|
|
85
|
+
if (!unoConfig)
|
|
86
|
+
logger.warn("[og-image UnoCSS] Failed to load uno.config.ts:", e.message);
|
|
74
87
|
}
|
|
75
88
|
const finalConfig = loadedConfig ? defu(unoConfig || {}, loadedConfig) : unoConfig;
|
|
76
89
|
if (!finalConfig) {
|
|
77
90
|
throw new Error("UnoCSS config not found. Ensure uno.config.ts exists or @unocss/nuxt is loaded.");
|
|
78
91
|
}
|
|
79
|
-
const { createGenerator } = await
|
|
92
|
+
const { createGenerator } = await importOptionalPeer("@unocss/core", unocssCorePath, "UnoCSS class extraction with OG images");
|
|
80
93
|
generator = await createGenerator(finalConfig);
|
|
81
94
|
return generator;
|
|
82
95
|
})();
|
|
@@ -114,6 +127,7 @@ function resolveUserVars(extracted, rootAttrs) {
|
|
|
114
127
|
return resolveExtractedVars(extracted, rootAttrs);
|
|
115
128
|
}
|
|
116
129
|
function createUnoProvider(options) {
|
|
130
|
+
setUnoModulePaths(options);
|
|
117
131
|
return {
|
|
118
132
|
name: "unocss",
|
|
119
133
|
async resolveClassesToStyles(classes, context, rootAttrs) {
|
package/dist/cli.cjs
CHANGED
|
@@ -364,7 +364,10 @@ async function checkNuxtConfig(rootDir) {
|
|
|
364
364
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
365
365
|
hasNuxtFontsInPkg = !!(pkg.dependencies?.["@nuxt/fonts"] || pkg.devDependencies?.["@nuxt/fonts"]);
|
|
366
366
|
}
|
|
367
|
-
const config = await kit.loadNuxtConfig({ cwd: rootDir }).catch(() =>
|
|
367
|
+
const config = await kit.loadNuxtConfig({ cwd: rootDir }).catch((error) => {
|
|
368
|
+
p__namespace.log.warn(`Could not inspect Nuxt config: ${error.message}`);
|
|
369
|
+
return null;
|
|
370
|
+
});
|
|
368
371
|
if (!config)
|
|
369
372
|
return { hasDeprecatedFonts: false, hasNuxtFonts: hasNuxtFontsInPkg, hasDefaultsComponent: false, defaultComponentName: null, nitroPreset: null, deprecatedConfigKeys: [] };
|
|
370
373
|
const ogImageConfig = config.ogImage;
|
|
@@ -545,7 +548,10 @@ function migrateV6Components(componentsToRename, defaultRenderer, dryRun) {
|
|
|
545
548
|
}
|
|
546
549
|
}
|
|
547
550
|
async function detectDeploymentTarget(rootDir) {
|
|
548
|
-
const config = await kit.loadNuxtConfig({ cwd: rootDir }).catch(() =>
|
|
551
|
+
const config = await kit.loadNuxtConfig({ cwd: rootDir }).catch((error) => {
|
|
552
|
+
p__namespace.log.warn(`Could not detect deployment target: ${error.message}`);
|
|
553
|
+
return null;
|
|
554
|
+
});
|
|
549
555
|
return config?.nitro?.preset || null;
|
|
550
556
|
}
|
|
551
557
|
async function installRendererDeps(renderers, isEdge) {
|
package/dist/cli.mjs
CHANGED
|
@@ -347,7 +347,10 @@ async function checkNuxtConfig(rootDir) {
|
|
|
347
347
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
348
348
|
hasNuxtFontsInPkg = !!(pkg.dependencies?.["@nuxt/fonts"] || pkg.devDependencies?.["@nuxt/fonts"]);
|
|
349
349
|
}
|
|
350
|
-
const config = await loadNuxtConfig({ cwd: rootDir }).catch(() =>
|
|
350
|
+
const config = await loadNuxtConfig({ cwd: rootDir }).catch((error) => {
|
|
351
|
+
p.log.warn(`Could not inspect Nuxt config: ${error.message}`);
|
|
352
|
+
return null;
|
|
353
|
+
});
|
|
351
354
|
if (!config)
|
|
352
355
|
return { hasDeprecatedFonts: false, hasNuxtFonts: hasNuxtFontsInPkg, hasDefaultsComponent: false, defaultComponentName: null, nitroPreset: null, deprecatedConfigKeys: [] };
|
|
353
356
|
const ogImageConfig = config.ogImage;
|
|
@@ -528,7 +531,10 @@ function migrateV6Components(componentsToRename, defaultRenderer, dryRun) {
|
|
|
528
531
|
}
|
|
529
532
|
}
|
|
530
533
|
async function detectDeploymentTarget(rootDir) {
|
|
531
|
-
const config = await loadNuxtConfig({ cwd: rootDir }).catch(() =>
|
|
534
|
+
const config = await loadNuxtConfig({ cwd: rootDir }).catch((error) => {
|
|
535
|
+
p.log.warn(`Could not detect deployment target: ${error.message}`);
|
|
536
|
+
return null;
|
|
537
|
+
});
|
|
532
538
|
return config?.nitro?.preset || null;
|
|
533
539
|
}
|
|
534
540
|
async function installRendererDeps(renderers, isEdge) {
|
|
@@ -17,7 +17,10 @@ export const isFallbackMode = computed(() => connectionState.value === 'fallback
|
|
|
17
17
|
// Fallback fetch for localhost:3000
|
|
18
18
|
async function tryFallbackConnection() {
|
|
19
19
|
const fallbackUrl = 'http://localhost:3000'
|
|
20
|
-
const res = await fetch(`${fallbackUrl}/_og/debug.json`).catch(() =>
|
|
20
|
+
const res = await fetch(`${fallbackUrl}/_og/debug.json`).catch(() => {
|
|
21
|
+
// An unreachable fallback host means the devtools connection has failed.
|
|
22
|
+
return null
|
|
23
|
+
})
|
|
21
24
|
if (res?.ok) {
|
|
22
25
|
appFetch.value = ((url: string, opts?: any) => fetch(`${fallbackUrl}${url}`, opts).then(r => r.json())) as any
|
|
23
26
|
base.value = '/'
|
package/dist/module.cjs
CHANGED
|
@@ -8,11 +8,11 @@ require('@nuxt/kit');
|
|
|
8
8
|
require('defu');
|
|
9
9
|
require('fnv1a-64');
|
|
10
10
|
require('nuxt-site-config/kit');
|
|
11
|
+
require('nuxtseo-shared/kit');
|
|
11
12
|
require('pathe');
|
|
12
13
|
require('pkg-types');
|
|
13
14
|
require('std-env');
|
|
14
|
-
const module$1 = require('./shared/nuxt-og-image.
|
|
15
|
-
require('nuxtseo-shared/kit');
|
|
15
|
+
const module$1 = require('./shared/nuxt-og-image.CdpC3njh.cjs');
|
|
16
16
|
require('../dist/runtime/logger.js');
|
|
17
17
|
require('oxc-walker');
|
|
18
18
|
require('chrome-launcher');
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,11 +6,11 @@ import '@nuxt/kit';
|
|
|
6
6
|
import 'defu';
|
|
7
7
|
import 'fnv1a-64';
|
|
8
8
|
import 'nuxt-site-config/kit';
|
|
9
|
+
import 'nuxtseo-shared/kit';
|
|
9
10
|
import 'pathe';
|
|
10
11
|
import 'pkg-types';
|
|
11
12
|
import 'std-env';
|
|
12
|
-
export {
|
|
13
|
-
import 'nuxtseo-shared/kit';
|
|
13
|
+
export { n as default } from './shared/nuxt-og-image.BIbfn5xQ.mjs';
|
|
14
14
|
import '../dist/runtime/logger.js';
|
|
15
15
|
import 'oxc-walker';
|
|
16
16
|
import 'chrome-launcher';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
|
+
export default _default;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
|
|
2
|
+
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TemplateParamsPlugin } from "@unhead/vue/plugins";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
-
import {
|
|
4
|
-
import { parseURL
|
|
3
|
+
import { createNitroRouteRuleMatcher } from "nuxtseo-shared/server";
|
|
4
|
+
import { parseURL } from "ufo";
|
|
5
5
|
import { toValue } from "vue";
|
|
6
6
|
import { defineNuxtPlugin, useRequestEvent } from "#app";
|
|
7
7
|
import { withSiteUrl } from "#site-config/app/composables";
|
|
@@ -60,14 +60,8 @@ export const routeRuleOgImage = defineNuxtPlugin((nuxtApp) => {
|
|
|
60
60
|
const path = parseURL(e?.path || "").pathname;
|
|
61
61
|
if (isInternalRoute(path))
|
|
62
62
|
return;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
const matchedRules = _routeRulesMatcher.matchAll(
|
|
67
|
-
withoutBase(path.split("?")?.[0] || "", ssrContext?.runtimeConfig?.app.baseURL || "")
|
|
68
|
-
).reverse();
|
|
69
|
-
const combinedRules = defu({}, ...matchedRules);
|
|
70
|
-
let routeRules = combinedRules?.ogImage;
|
|
63
|
+
const matchRouteRules = createNitroRouteRuleMatcher(ssrContext?.runtimeConfig || {});
|
|
64
|
+
let routeRules = matchRouteRules(path).ogImage;
|
|
71
65
|
if (typeof routeRules === "undefined")
|
|
72
66
|
return;
|
|
73
67
|
if (routeRules === false) {
|
package/dist/runtime/logger.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { createConsola } from "consola";
|
|
2
1
|
import { colorize } from "consola/utils";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tag: "@nuxtjs/og-image"
|
|
6
|
-
}
|
|
7
|
-
});
|
|
2
|
+
import { createModuleLogger } from "nuxtseo-shared/utils";
|
|
3
|
+
export const logger = createModuleLogger("@nuxtjs/og-image");
|
|
8
4
|
export const gray = (s) => colorize("gray", s);
|
package/dist/runtime/pure.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export declare function extractSocialPreviewTags(html: string): [Record<string,
|
|
|
3
3
|
export declare function detectBase64MimeType(data: string): string;
|
|
4
4
|
export declare function toBase64Image(data: string | ArrayBuffer): string;
|
|
5
5
|
export declare function withoutQuery(path: string): string | undefined;
|
|
6
|
-
export declare function getExtension(path: string): string;
|
package/dist/runtime/pure.js
CHANGED
|
@@ -65,8 +65,3 @@ export function toBase64Image(data) {
|
|
|
65
65
|
export function withoutQuery(path) {
|
|
66
66
|
return path.split("?")[0];
|
|
67
67
|
}
|
|
68
|
-
export function getExtension(path) {
|
|
69
|
-
path = withoutQuery(path);
|
|
70
|
-
const lastSegment = path.split("/").pop() || path;
|
|
71
|
-
return lastSegment.split(".").pop() || lastSegment;
|
|
72
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
1
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
2
2
|
interface Browser {
|
|
3
3
|
connected: boolean;
|
|
4
4
|
newPage: () => Promise<any>;
|
|
@@ -6,5 +6,4 @@ interface Browser {
|
|
|
6
6
|
on: (event: string, handler: () => void) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare function createBrowser(event?: H3Event): Promise<Browser>;
|
|
9
|
-
export declare function disposeBrowser(): Promise<void>;
|
|
10
9
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getCloudflareEnv } from "../../../util/cloudflare.js";
|
|
1
2
|
import { withTimeout } from "../../../util/withTimeout.js";
|
|
2
3
|
import { useOgImageRuntimeConfig } from "../../../utils.js";
|
|
3
4
|
let puppeteer;
|
|
@@ -20,7 +21,7 @@ export async function createBrowser(event) {
|
|
|
20
21
|
"[Nuxt OG Image] Browser binding name not configured. Set `ogImage.browser.binding` in nuxt.config."
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
|
-
const binding = event?.
|
|
24
|
+
const binding = getCloudflareEnv(event)?.[bindingName];
|
|
24
25
|
if (!binding) {
|
|
25
26
|
throw new Error(
|
|
26
27
|
`[Nuxt OG Image] Cloudflare browser binding "${bindingName}" not found. Ensure it's configured in wrangler.toml and the request has cloudflare context.`
|
|
@@ -45,11 +46,3 @@ export async function createBrowser(event) {
|
|
|
45
46
|
browserPromise = null;
|
|
46
47
|
return browser;
|
|
47
48
|
}
|
|
48
|
-
export async function disposeBrowser() {
|
|
49
|
-
if (browser) {
|
|
50
|
-
await browser.close().catch((err) => {
|
|
51
|
-
void err;
|
|
52
|
-
});
|
|
53
|
-
browser = null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
1
|
import { withBase } from "ufo";
|
|
2
|
+
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { getSiteConfig } from "#site-config/server/composables";
|
|
4
4
|
import { getCloudflareAssets } from "../../../util/cloudflareAssets.js";
|
|
5
5
|
import { fetchLocalAsset } from "../../../util/fetchLocalAsset.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { getRequestURL } from "h3";
|
|
3
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
4
2
|
import { join } from "pathe";
|
|
5
3
|
import { withBase } from "ufo";
|
|
4
|
+
import { getRequestURL } from "#nuxtseo/h3";
|
|
5
|
+
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
6
6
|
import { buildDir, rootDir } from "#og-image-virtual/build-dir.mjs";
|
|
7
7
|
import { getSiteConfig } from "#site-config/server/composables";
|
|
8
8
|
import { getFetchTimeout } from "../../../util/fetchTimeout.js";
|
|
@@ -10,11 +10,23 @@ import { fetchWithRedirectValidation } from "../../../util/ssrf.js";
|
|
|
10
10
|
import { useOgImageRuntimeConfig } from "../../../utils.js";
|
|
11
11
|
import { fetchSpecialFontUrl, isDataFontUrl, isExternalFontUrl } from "./external-url.js";
|
|
12
12
|
let fontUrlMapping;
|
|
13
|
+
async function readOptionalFile(path) {
|
|
14
|
+
return readFile(path).catch((error) => {
|
|
15
|
+
if (error.code === "ENOENT")
|
|
16
|
+
return null;
|
|
17
|
+
throw error;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async function fetchOptionalFont(url, timeout) {
|
|
21
|
+
return fetch(url, { signal: AbortSignal.timeout(timeout) }).catch(() => {
|
|
22
|
+
return null;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
13
25
|
async function loadFontUrlMapping() {
|
|
14
26
|
if (fontUrlMapping)
|
|
15
27
|
return fontUrlMapping;
|
|
16
|
-
const content = await
|
|
17
|
-
fontUrlMapping = content ? JSON.parse(content) : {};
|
|
28
|
+
const content = await readOptionalFile(join(buildDir, "cache", "og-image", "font-urls.json"));
|
|
29
|
+
fontUrlMapping = content ? JSON.parse(content.toString("utf-8")) : {};
|
|
18
30
|
return fontUrlMapping;
|
|
19
31
|
}
|
|
20
32
|
export async function resolve(event, font) {
|
|
@@ -22,7 +34,7 @@ export async function resolve(event, font) {
|
|
|
22
34
|
const runtimeConfig = useOgImageRuntimeConfig();
|
|
23
35
|
const timeout = getFetchTimeout(runtimeConfig);
|
|
24
36
|
if (font.absolutePath) {
|
|
25
|
-
const data = await
|
|
37
|
+
const data = await readOptionalFile(font.absolutePath);
|
|
26
38
|
if (data?.length)
|
|
27
39
|
return data;
|
|
28
40
|
}
|
|
@@ -31,31 +43,31 @@ export async function resolve(event, font) {
|
|
|
31
43
|
if (import.meta.prerender) {
|
|
32
44
|
if (path.startsWith("/_og-static-fonts/")) {
|
|
33
45
|
const filename2 = path.slice("/_og-static-fonts/".length);
|
|
34
|
-
const cached = await
|
|
46
|
+
const cached = await readOptionalFile(join(buildDir, "cache", "og-image", "fonts-ttf", filename2)) || await readOptionalFile(join(rootDir, ".output", "public", "_og-static-fonts", filename2));
|
|
35
47
|
if (cached?.length)
|
|
36
48
|
return cached;
|
|
37
49
|
}
|
|
38
50
|
if (path.startsWith("/_fonts/")) {
|
|
39
51
|
const filename2 = path.slice("/_fonts/".length);
|
|
40
|
-
const cached = await
|
|
52
|
+
const cached = await readOptionalFile(join(rootDir, ".output", "public", "_fonts", filename2));
|
|
41
53
|
if (cached?.length)
|
|
42
54
|
return cached;
|
|
43
55
|
const mapping = await loadFontUrlMapping();
|
|
44
56
|
if (mapping[filename2]) {
|
|
45
|
-
const res = await
|
|
57
|
+
const res = await fetchOptionalFont(mapping[filename2], timeout);
|
|
46
58
|
if (res?.ok)
|
|
47
59
|
return Buffer.from(await res.arrayBuffer());
|
|
48
60
|
}
|
|
49
61
|
throw new Error(`Font ${filename2} not found in mapping or cache`);
|
|
50
62
|
}
|
|
51
63
|
const filename = path.slice(1);
|
|
52
|
-
const data = await
|
|
64
|
+
const data = await readOptionalFile(join(rootDir, "public", filename)) || await readOptionalFile(join(rootDir, ".output", "public", filename));
|
|
53
65
|
if (data?.length)
|
|
54
66
|
return data;
|
|
55
67
|
}
|
|
56
68
|
if (path.startsWith("/_og-static-fonts/")) {
|
|
57
69
|
const filename = path.slice("/_og-static-fonts/".length);
|
|
58
|
-
const cached = await
|
|
70
|
+
const cached = await readOptionalFile(join(buildDir, "cache", "og-image", "fonts-ttf", filename));
|
|
59
71
|
if (cached?.length)
|
|
60
72
|
return cached;
|
|
61
73
|
}
|
|
@@ -63,14 +75,14 @@ export async function resolve(event, font) {
|
|
|
63
75
|
const filename = path.slice("/_fonts/".length);
|
|
64
76
|
const mapping = await loadFontUrlMapping();
|
|
65
77
|
if (mapping[filename]) {
|
|
66
|
-
const res = await
|
|
78
|
+
const res = await fetchOptionalFont(mapping[filename], timeout);
|
|
67
79
|
if (res?.ok)
|
|
68
80
|
return Buffer.from(await res.arrayBuffer());
|
|
69
81
|
}
|
|
70
82
|
}
|
|
71
83
|
if (import.meta.dev) {
|
|
72
84
|
const filename = path.slice(1);
|
|
73
|
-
const data = await
|
|
85
|
+
const data = await readOptionalFile(join(rootDir, "public", filename));
|
|
74
86
|
if (data?.length)
|
|
75
87
|
return data;
|
|
76
88
|
}
|
|
@@ -79,7 +91,9 @@ export async function resolve(event, font) {
|
|
|
79
91
|
const reqUrl = getRequestURL(event);
|
|
80
92
|
const origin = `${reqUrl.protocol}//${reqUrl.host}`;
|
|
81
93
|
const target = new URL(withBase(path, app.baseURL), origin);
|
|
82
|
-
const ab = await fetchWithRedirectValidation(target.href, { timeout, trustedHost: target.host }).catch(() =>
|
|
94
|
+
const ab = await fetchWithRedirectValidation(target.href, { timeout, trustedHost: target.host }).catch(() => {
|
|
95
|
+
return null;
|
|
96
|
+
});
|
|
83
97
|
if (ab) {
|
|
84
98
|
return Buffer.from(ab);
|
|
85
99
|
}
|
|
@@ -32,7 +32,9 @@ export function resolveSameOriginFontUrl(path, siteUrl) {
|
|
|
32
32
|
}
|
|
33
33
|
export async function fetchSpecialFontUrl(path, siteUrl, timeout) {
|
|
34
34
|
if (isDataFontUrl(path)) {
|
|
35
|
-
const res = await fetch(path.trimStart(), { signal: AbortSignal.timeout(timeout) }).catch(() =>
|
|
35
|
+
const res = await fetch(path.trimStart(), { signal: AbortSignal.timeout(timeout) }).catch(() => {
|
|
36
|
+
return null;
|
|
37
|
+
});
|
|
36
38
|
if (res?.ok)
|
|
37
39
|
return Buffer.from(await res.arrayBuffer());
|
|
38
40
|
throw new Error("[Nuxt OG Image] Invalid data: font URL.");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
1
|
import { withBase } from "ufo";
|
|
2
|
+
import { 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";
|
|
@@ -15,7 +15,9 @@ export async function resolve(event, font) {
|
|
|
15
15
|
if (path && (isDataFontUrl(path) || isExternalFontUrl(path)))
|
|
16
16
|
return fetchSpecialFontUrl(path, getSiteConfig(event).url, timeout);
|
|
17
17
|
const target = new URL(fullPath, origin);
|
|
18
|
-
const ab = await fetchWithRedirectValidation(target.href, { timeout, trustedHost: target.host }).catch(() =>
|
|
18
|
+
const ab = await fetchWithRedirectValidation(target.href, { timeout, trustedHost: target.host }).catch(() => {
|
|
19
|
+
return null;
|
|
20
|
+
});
|
|
19
21
|
if (ab) {
|
|
20
22
|
return Buffer.from(ab);
|
|
21
23
|
}
|