nuxt-og-image 6.0.0 → 6.0.2
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/README.md +1 -1
- package/dist/chunks/tw4.cjs +1 -1
- package/dist/chunks/tw4.mjs +1 -1
- package/dist/chunks/uno.cjs +1 -1
- package/dist/chunks/uno.mjs +1 -1
- package/dist/cli.cjs +188 -119
- package/dist/cli.mjs +188 -119
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/BB_ao4y0.js +181 -0
- package/dist/client/_nuxt/BG25oXSp.js +3 -0
- package/dist/client/_nuxt/CA0JEQNP.js +1 -0
- package/dist/client/_nuxt/CAkieT7G.js +1 -0
- package/dist/client/_nuxt/CeFUJIya.js +3860 -0
- package/dist/client/_nuxt/CyEUhafz.js +1 -0
- package/dist/client/_nuxt/DJJ9-pPr.js +1 -0
- package/dist/client/_nuxt/DxQS3Z2e.js +1 -0
- package/dist/client/_nuxt/HkJuN7bp.js +1 -0
- package/dist/client/_nuxt/PRAc7tB1.js +2 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/e9dc8e1d-2778-400b-a935-6be7b9e4f920.json +1 -0
- package/dist/client/_nuxt/{entry.Ci4bU1tp.css → entry.BVvgcEPR.css} +1 -1
- package/dist/client/_nuxt/error-404.DX13NYg9.css +1 -0
- package/dist/client/_nuxt/error-500.BQapBT4V.css +1 -0
- package/dist/client/debug/index.html +1 -1
- package/dist/client/docs/index.html +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/templates/index.html +1 -1
- package/dist/module.cjs +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/app/utils.js +1 -1
- package/dist/runtime/server/og-image/core/vnodes.js +3 -1
- package/dist/runtime/server/og-image/fonts.d.ts +23 -2
- package/dist/runtime/server/og-image/fonts.js +34 -1
- package/dist/runtime/server/og-image/satori/renderer.js +14 -8
- package/dist/runtime/server/og-image/satori/vnodes.js +35 -0
- package/dist/runtime/server/og-image/takumi/instances.d.ts +2 -1
- package/dist/runtime/server/og-image/takumi/nodes.d.ts +2 -11
- package/dist/runtime/server/og-image/takumi/nodes.js +35 -25
- package/dist/runtime/server/og-image/takumi/renderer.js +10 -13
- package/dist/runtime/server/og-image/unicode-range.d.ts +5 -7
- package/dist/runtime/server/og-image/unicode-range.js +12 -27
- package/dist/shared/{nuxt-og-image.Dxgo_zuB.cjs → nuxt-og-image.Bo99TlIa.cjs} +56 -29
- package/dist/shared/{nuxt-og-image.BYpTHg51.mjs → nuxt-og-image.fzu6dYsO.mjs} +55 -28
- package/package.json +20 -18
- package/dist/client/_nuxt/8X6NW5_o.js +0 -181
- package/dist/client/_nuxt/B4AI0zo1.js +0 -3860
- package/dist/client/_nuxt/BSXU-Wzx.js +0 -1
- package/dist/client/_nuxt/BUiggg2R.js +0 -1
- package/dist/client/_nuxt/BWFB7PcA.js +0 -3
- package/dist/client/_nuxt/CAH4zhLz.js +0 -1
- package/dist/client/_nuxt/D2sXT63a.js +0 -1
- package/dist/client/_nuxt/DLWTHHHk.js +0 -2
- package/dist/client/_nuxt/Dkvb1DQl.js +0 -1
- package/dist/client/_nuxt/DoBtCwhp.js +0 -1
- package/dist/client/_nuxt/builds/meta/9d10b447-cded-4d38-a6ff-e768102fc1f3.json +0 -1
- package/dist/client/_nuxt/error-404.C4vS2Bge.css +0 -1
- package/dist/client/_nuxt/error-500.Y0QISy38.css +0 -1
- package/dist/client/_payload.json +0 -1
- package/dist/client/debug/_payload.json +0 -1
- package/dist/client/docs/_payload.json +0 -1
- package/dist/client/templates/_payload.json +0 -1
- package/dist/runtime/server/og-image/takumi/sanitize.d.ts +0 -1
- package/dist/runtime/server/og-image/takumi/sanitize.js +0 -20
package/README.md
CHANGED
package/dist/chunks/tw4.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const promises = require('node:fs/promises');
|
|
|
4
4
|
const exsolve = require('exsolve');
|
|
5
5
|
const pathe = require('pathe');
|
|
6
6
|
const cssProvider = require('./css-provider.cjs');
|
|
7
|
-
const module$1 = require('../shared/nuxt-og-image.
|
|
7
|
+
const module$1 = require('../shared/nuxt-og-image.Bo99TlIa.cjs');
|
|
8
8
|
require('node:fs');
|
|
9
9
|
require('@nuxt/kit');
|
|
10
10
|
require('defu');
|
package/dist/chunks/tw4.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { resolveModulePath } from 'exsolve';
|
|
3
3
|
import { dirname, join } from 'pathe';
|
|
4
4
|
import { extractVariantBaseClasses, resolveVariantPrefixes } from './css-provider.mjs';
|
|
5
|
-
import { g as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, l as loadLightningCss, e as extractCssVars, b as extractUniversalVars, c as extractPerClassVars, d as extractClassStyles } from '../shared/nuxt-og-image.
|
|
5
|
+
import { g as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, l as loadLightningCss, e as extractCssVars, b as extractUniversalVars, c as extractPerClassVars, d as extractClassStyles } from '../shared/nuxt-og-image.fzu6dYsO.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import '@nuxt/kit';
|
|
8
8
|
import 'defu';
|
package/dist/chunks/uno.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const promises = require('node:fs/promises');
|
|
|
4
4
|
const defu = require('defu');
|
|
5
5
|
const logger_js = require('../../dist/runtime/logger.js');
|
|
6
6
|
const cssProvider = require('./css-provider.cjs');
|
|
7
|
-
const module$1 = require('../shared/nuxt-og-image.
|
|
7
|
+
const module$1 = require('../shared/nuxt-og-image.Bo99TlIa.cjs');
|
|
8
8
|
require('exsolve');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('@nuxt/kit');
|
package/dist/chunks/uno.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { logger } from '../../dist/runtime/logger.js';
|
|
4
4
|
import { extractVariantBaseClasses, resolveVariantPrefixes } from './css-provider.mjs';
|
|
5
|
-
import { s as simplifyCss, e as extractCssVars, a as extractPropertyInitialValues, b as extractUniversalVars, c as extractPerClassVars, d as extractClassStyles, p as postProcessStyles, f as extractVarsFromCss, r as resolveExtractedVars } from '../shared/nuxt-og-image.
|
|
5
|
+
import { s as simplifyCss, e as extractCssVars, a as extractPropertyInitialValues, b as extractUniversalVars, c as extractPerClassVars, d as extractClassStyles, p as postProcessStyles, f as extractVarsFromCss, r as resolveExtractedVars } from '../shared/nuxt-og-image.fzu6dYsO.mjs';
|
|
6
6
|
import 'exsolve';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import '@nuxt/kit';
|
package/dist/cli.cjs
CHANGED
|
@@ -6,7 +6,9 @@ const node_url = require('node:url');
|
|
|
6
6
|
const p = require('@clack/prompts');
|
|
7
7
|
const kit = require('@nuxt/kit');
|
|
8
8
|
const nypm = require('nypm');
|
|
9
|
+
const oxcWalker = require('oxc-walker');
|
|
9
10
|
const pathe = require('pathe');
|
|
11
|
+
const ultrahtml = require('ultrahtml');
|
|
10
12
|
const fonts = require('./shared/nuxt-og-image.CMYbz66P.cjs');
|
|
11
13
|
require('magicast');
|
|
12
14
|
require('magicast/helpers');
|
|
@@ -32,37 +34,137 @@ const communityDir = pathe.resolve(__dirname$1, "runtime/app/components/Template
|
|
|
32
34
|
const RE_RENDERER_SUFFIX = /\.(satori|browser|takumi)\.vue$/;
|
|
33
35
|
const RE_ANY_RENDERER_SUFFIX = /\.(?:satori|browser|takumi|chromium)\.vue$/;
|
|
34
36
|
const RE_CHROMIUM_SUFFIX = /\.chromium\.vue$/;
|
|
35
|
-
const RE_ATTR = /:(\w+)="([^"]*)"|(\w+)="([^"]*)"|(\w+)/g;
|
|
36
37
|
const RE_EXCLUDE_NODE_MODULES = /node_modules/;
|
|
37
38
|
const RE_EXCLUDE_NUXT = /\.nuxt/;
|
|
38
39
|
const RE_EXCLUDE_OUTPUT = /\.output/;
|
|
39
40
|
const RE_EXCLUDE_DATA = /\.data/;
|
|
40
41
|
const RE_EXCLUDE_DIST = /dist/;
|
|
41
42
|
const RE_VUE_OR_SCRIPT = /\.(?:vue|ts|tsx|js|jsx)$/;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
43
|
+
const DEPRECATED_COMPOSABLE_NAMES = /* @__PURE__ */ new Set([
|
|
44
|
+
"defineOgImageComponent",
|
|
45
|
+
"defineOgImageStatic",
|
|
46
|
+
"defineOgImageDynamic",
|
|
47
|
+
"defineOgImageCached",
|
|
48
|
+
"defineOgImageWithoutCache"
|
|
49
|
+
]);
|
|
50
|
+
const ALL_OG_IMAGE_COMPOSABLES = /* @__PURE__ */ new Set([
|
|
51
|
+
"defineOgImage",
|
|
52
|
+
...DEPRECATED_COMPOSABLE_NAMES
|
|
53
|
+
]);
|
|
54
|
+
function collectScriptReplacements(code, filename) {
|
|
55
|
+
const replacements = [];
|
|
56
|
+
oxcWalker.parseAndWalk(code, filename, (node) => {
|
|
57
|
+
if (node.type === "ImportDeclaration") {
|
|
58
|
+
const source = node.source;
|
|
59
|
+
const sourceValue = source?.value;
|
|
60
|
+
if (sourceValue === "#nuxt-og-image-utils") {
|
|
61
|
+
replacements.push({ start: source.start + 1, end: source.end - 1, text: "#og-image/shared" });
|
|
62
|
+
} else if (sourceValue === "#og-image/shared") {
|
|
63
|
+
const specifiers = node.specifiers || [];
|
|
64
|
+
const hasRuntimeConfig = specifiers.some((s) => {
|
|
65
|
+
const imported = s.imported || s.local;
|
|
66
|
+
return imported?.name === "useOgImageRuntimeConfig";
|
|
67
|
+
});
|
|
68
|
+
if (hasRuntimeConfig) {
|
|
69
|
+
replacements.push({ start: source.start + 1, end: source.end - 1, text: "#og-image/app/utils" });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (node.type !== "CallExpression")
|
|
75
|
+
return;
|
|
76
|
+
const callee = node.callee;
|
|
77
|
+
const calleeName = callee?.name;
|
|
78
|
+
if (!calleeName || !ALL_OG_IMAGE_COMPOSABLES.has(calleeName))
|
|
79
|
+
return;
|
|
80
|
+
const args2 = node.arguments || [];
|
|
81
|
+
if (args2.length === 1 && args2[0]?.type === "ObjectExpression") {
|
|
82
|
+
const objArg = args2[0];
|
|
83
|
+
const properties = (objArg.properties || []).filter(
|
|
84
|
+
(p2) => p2.type === "ObjectProperty" || p2.type === "Property"
|
|
85
|
+
);
|
|
86
|
+
const findProp = (name) => properties.find(
|
|
87
|
+
(p2) => p2.key?.name === name
|
|
88
|
+
);
|
|
89
|
+
const urlProp = findProp("url");
|
|
90
|
+
const componentProp = findProp("component");
|
|
91
|
+
const rendererProp = findProp("renderer");
|
|
92
|
+
const propsProp = findProp("props");
|
|
93
|
+
if (urlProp) {
|
|
94
|
+
const urlValue = code.slice(urlProp.value.start, urlProp.value.end);
|
|
95
|
+
const ogPropMap = {
|
|
96
|
+
width: "ogImageWidth",
|
|
97
|
+
height: "ogImageHeight",
|
|
98
|
+
alt: "ogImageAlt",
|
|
99
|
+
type: "ogImageType"
|
|
100
|
+
};
|
|
101
|
+
const seoMetaProps = [`ogImage: ${urlValue}`];
|
|
102
|
+
for (const prop of properties) {
|
|
103
|
+
if (prop === urlProp)
|
|
104
|
+
continue;
|
|
105
|
+
const keyName = prop.key?.name;
|
|
106
|
+
const mappedName = ogPropMap[keyName];
|
|
107
|
+
if (mappedName) {
|
|
108
|
+
seoMetaProps.push(`${mappedName}: ${code.slice(prop.value.start, prop.value.end)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const text = `useSeoMeta({ ${seoMetaProps.join(", ")} })`;
|
|
112
|
+
replacements.push({ start: node.start, end: node.end, text });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!componentProp && rendererProp) {
|
|
116
|
+
const rendererValue = code.slice(rendererProp.value.start, rendererProp.value.end).trim();
|
|
117
|
+
if (rendererValue === "'chromium'" || rendererValue === '"chromium"') {
|
|
118
|
+
const otherProps = properties.filter((p2) => p2 !== rendererProp);
|
|
119
|
+
const text = otherProps.length > 0 ? `defineOgImageScreenshot({ ${otherProps.map((p2) => code.slice(p2.start, p2.end)).join(", ")} })` : `defineOgImageScreenshot()`;
|
|
120
|
+
replacements.push({ start: node.start, end: node.end, text });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (componentProp || rendererProp) {
|
|
125
|
+
const componentName = componentProp ? code.slice(componentProp.value.start, componentProp.value.end) : "'NuxtSeo'";
|
|
126
|
+
const propsValue = propsProp ? code.slice(propsProp.value.start, propsProp.value.end) : "{}";
|
|
127
|
+
const otherProps = properties.filter(
|
|
128
|
+
(p2) => p2 !== componentProp && p2 !== rendererProp && p2 !== propsProp
|
|
129
|
+
);
|
|
130
|
+
const text = otherProps.length > 0 ? `defineOgImage(${componentName}, ${propsValue}, { ${otherProps.map((p2) => code.slice(p2.start, p2.end)).join(", ")} })` : `defineOgImage(${componentName}, ${propsValue})`;
|
|
131
|
+
replacements.push({ start: node.start, end: node.end, text });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (DEPRECATED_COMPOSABLE_NAMES.has(calleeName)) {
|
|
136
|
+
replacements.push({ start: callee.start, end: callee.end, text: "defineOgImage" });
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return replacements;
|
|
140
|
+
}
|
|
141
|
+
function parseSfcBlocks(code) {
|
|
142
|
+
const scripts = [];
|
|
143
|
+
let template = null;
|
|
144
|
+
const ast = ultrahtml.parse(code);
|
|
145
|
+
ultrahtml.walkSync(ast, (node) => {
|
|
146
|
+
if (node.type !== ultrahtml.ELEMENT_NODE || !("name" in node))
|
|
147
|
+
return;
|
|
148
|
+
const el = node;
|
|
149
|
+
if (el.name === "script" && el.loc) {
|
|
150
|
+
const start = el.loc[0].end;
|
|
151
|
+
const end = el.loc[1].start;
|
|
152
|
+
scripts.push({ content: code.slice(start, end), offset: start });
|
|
153
|
+
} else if (el.name === "template" && el.loc) {
|
|
154
|
+
const start = el.loc[0].end;
|
|
155
|
+
const end = el.loc[1].start;
|
|
156
|
+
template = { content: code.slice(start, end), offset: start };
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return { scripts, template };
|
|
160
|
+
}
|
|
161
|
+
function applyReplacements(code, replacements) {
|
|
162
|
+
const sorted = replacements.toSorted((a, b) => b.start - a.start);
|
|
163
|
+
for (const r of sorted) {
|
|
164
|
+
code = code.slice(0, r.start) + r.text + code.slice(r.end);
|
|
165
|
+
}
|
|
166
|
+
return code;
|
|
167
|
+
}
|
|
66
168
|
const defaultComponentDirs = ["OgImage", "OgImageCommunity", "og-image", "OgImageTemplate"];
|
|
67
169
|
const RENDERERS = [
|
|
68
170
|
{
|
|
@@ -325,20 +427,38 @@ async function checkMigrationNeeded(rootDir) {
|
|
|
325
427
|
result.usedCommunityTemplates = detectCommunityTemplateUsage(rootDir);
|
|
326
428
|
return result;
|
|
327
429
|
}
|
|
328
|
-
function attrsToProps(
|
|
329
|
-
if (!attrs)
|
|
330
|
-
return "";
|
|
430
|
+
function attrsToProps(attributes) {
|
|
331
431
|
const props = [];
|
|
332
|
-
for (const
|
|
333
|
-
if (
|
|
334
|
-
props.push(`${
|
|
335
|
-
else if (
|
|
336
|
-
props.push(`${
|
|
337
|
-
else
|
|
338
|
-
props.push(`${
|
|
432
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
433
|
+
if (key.startsWith(":")) {
|
|
434
|
+
props.push(`${key.slice(1)}: ${value}`);
|
|
435
|
+
} else if (value === "") {
|
|
436
|
+
props.push(`${key}: true`);
|
|
437
|
+
} else {
|
|
438
|
+
props.push(`${key}: '${value}'`);
|
|
439
|
+
}
|
|
339
440
|
}
|
|
340
441
|
return props.length ? `{ ${props.join(", ")} }` : "";
|
|
341
442
|
}
|
|
443
|
+
function collectTemplateReplacements(templateHtml) {
|
|
444
|
+
const replacements = [];
|
|
445
|
+
const ast = ultrahtml.parse(templateHtml);
|
|
446
|
+
ultrahtml.walkSync(ast, (node) => {
|
|
447
|
+
if (node.type !== ultrahtml.ELEMENT_NODE || !("name" in node))
|
|
448
|
+
return;
|
|
449
|
+
const el = node;
|
|
450
|
+
if (el.name !== "OgImage" && el.name !== "OgImageScreenshot")
|
|
451
|
+
return;
|
|
452
|
+
const isScreenshot = el.name === "OgImageScreenshot";
|
|
453
|
+
const composable = isScreenshot ? "defineOgImageScreenshot" : "defineOgImage";
|
|
454
|
+
const propsStr = attrsToProps(el.attributes);
|
|
455
|
+
const start = el.loc[0].start;
|
|
456
|
+
const end = el.loc[1].end;
|
|
457
|
+
const text = propsStr ? `<!-- Migrated: use ${composable}(${propsStr}) in <script setup> -->` : `<!-- Migrated: use ${composable}() in <script setup> -->`;
|
|
458
|
+
replacements.push({ start, end, text });
|
|
459
|
+
});
|
|
460
|
+
return replacements;
|
|
461
|
+
}
|
|
342
462
|
function migrateDefineOgImageApi(dryRun) {
|
|
343
463
|
const cwd = process.cwd();
|
|
344
464
|
const excludePatterns = [RE_EXCLUDE_NODE_MODULES, RE_EXCLUDE_NUXT, RE_EXCLUDE_OUTPUT, RE_EXCLUDE_DATA, RE_EXCLUDE_DIST];
|
|
@@ -346,97 +466,45 @@ function migrateDefineOgImageApi(dryRun) {
|
|
|
346
466
|
const changes = [];
|
|
347
467
|
for (const file of files) {
|
|
348
468
|
let content = fs.readFileSync(file, "utf-8");
|
|
469
|
+
if (!content.includes("defineOgImage") && !content.includes("OgImage") && !content.includes("#nuxt-og-image-utils") && !content.includes("useOgImageRuntimeConfig")) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
349
472
|
let modified = false;
|
|
350
473
|
let changeCount = 0;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
changeCount++;
|
|
366
|
-
const propsStr = attrsToProps(attrs.trim());
|
|
367
|
-
return propsStr ? `<!-- Migrated: use defineOgImage(${propsStr}) in <script setup> -->` : `<!-- Migrated: use defineOgImage() in <script setup> -->`;
|
|
368
|
-
});
|
|
369
|
-
content = content.replace(RE_OG_IMAGE_OPEN_CLOSE, (_match, attrs) => {
|
|
370
|
-
modified = true;
|
|
371
|
-
changeCount++;
|
|
372
|
-
const propsStr = attrsToProps(attrs.trim());
|
|
373
|
-
return propsStr ? `<!-- Migrated: use defineOgImage(${propsStr}) in <script setup> -->` : `<!-- Migrated: use defineOgImage() in <script setup> -->`;
|
|
374
|
-
});
|
|
375
|
-
if (RE_DEFINE_OG_IMAGE_COMPONENT.test(content)) {
|
|
376
|
-
content = content.replace(RE_DEFINE_OG_IMAGE_COMPONENT_GLOBAL, "defineOgImage(");
|
|
377
|
-
modified = true;
|
|
378
|
-
changeCount++;
|
|
379
|
-
}
|
|
380
|
-
for (const [re] of [
|
|
381
|
-
[RE_DEFINE_OG_IMAGE_STATIC],
|
|
382
|
-
[RE_DEFINE_OG_IMAGE_DYNAMIC],
|
|
383
|
-
[RE_DEFINE_OG_IMAGE_CACHED],
|
|
384
|
-
[RE_DEFINE_OG_IMAGE_WITHOUT_CACHE]
|
|
385
|
-
]) {
|
|
386
|
-
if (re.test(content)) {
|
|
387
|
-
re.lastIndex = 0;
|
|
388
|
-
content = content.replace(re, "defineOgImage(");
|
|
389
|
-
modified = true;
|
|
390
|
-
changeCount++;
|
|
474
|
+
if (file.endsWith(".vue")) {
|
|
475
|
+
const { scripts, template } = parseSfcBlocks(content);
|
|
476
|
+
if (template && content.includes("OgImage")) {
|
|
477
|
+
const replacements = collectTemplateReplacements(template.content);
|
|
478
|
+
if (replacements.length > 0) {
|
|
479
|
+
const adjusted = replacements.map((r) => ({
|
|
480
|
+
start: r.start + template.offset,
|
|
481
|
+
end: r.end + template.offset,
|
|
482
|
+
text: r.text
|
|
483
|
+
}));
|
|
484
|
+
content = applyReplacements(content, adjusted);
|
|
485
|
+
modified = true;
|
|
486
|
+
changeCount += replacements.length;
|
|
487
|
+
}
|
|
391
488
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
489
|
+
const allReplacements = [];
|
|
490
|
+
for (const script of scripts) {
|
|
491
|
+
const replacements = collectScriptReplacements(script.content, file);
|
|
492
|
+
for (const r of replacements) {
|
|
493
|
+
allReplacements.push({ start: r.start + script.offset, end: r.end + script.offset, text: r.text });
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (allReplacements.length > 0) {
|
|
497
|
+
content = applyReplacements(content, allReplacements);
|
|
399
498
|
modified = true;
|
|
400
|
-
changeCount
|
|
401
|
-
return remaining ? `defineOgImageScreenshot(${remaining})` : `defineOgImageScreenshot()`;
|
|
499
|
+
changeCount += allReplacements.length;
|
|
402
500
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const lines = inner.split(RE_COMMA_NOT_IN_BRACES).map((s) => s.trim());
|
|
408
|
-
for (const line of lines) {
|
|
409
|
-
if (!line)
|
|
410
|
-
continue;
|
|
411
|
-
if (RE_LINE_COMPONENT.test(line))
|
|
412
|
-
continue;
|
|
413
|
-
if (RE_LINE_PROPS.test(line))
|
|
414
|
-
continue;
|
|
415
|
-
if (RE_LINE_RENDERER.test(line))
|
|
416
|
-
continue;
|
|
417
|
-
otherOptions.push(line);
|
|
418
|
-
}
|
|
501
|
+
} else {
|
|
502
|
+
const replacements = collectScriptReplacements(content, file);
|
|
503
|
+
if (replacements.length > 0) {
|
|
504
|
+
content = applyReplacements(content, replacements);
|
|
419
505
|
modified = true;
|
|
420
|
-
changeCount
|
|
421
|
-
if (otherOptions.length > 0) {
|
|
422
|
-
return `defineOgImage('${componentName}', ${props}, { ${otherOptions.join(", ")} })`;
|
|
423
|
-
}
|
|
424
|
-
return `defineOgImage('${componentName}', ${props})`;
|
|
506
|
+
changeCount += replacements.length;
|
|
425
507
|
}
|
|
426
|
-
return match;
|
|
427
|
-
});
|
|
428
|
-
if (content.includes("#nuxt-og-image-utils")) {
|
|
429
|
-
content = content.replace(RE_NUXT_OG_IMAGE_UTILS_GLOBAL, "#og-image/shared");
|
|
430
|
-
modified = true;
|
|
431
|
-
changeCount++;
|
|
432
|
-
}
|
|
433
|
-
if (RE_IMPORT_USE_OG_IMAGE_RUNTIME_CONFIG.test(content)) {
|
|
434
|
-
content = content.replace(
|
|
435
|
-
RE_IMPORT_USE_OG_IMAGE_RUNTIME_CONFIG_GLOBAL,
|
|
436
|
-
"$1#og-image/app/utils$2"
|
|
437
|
-
);
|
|
438
|
-
modified = true;
|
|
439
|
-
changeCount++;
|
|
440
508
|
}
|
|
441
509
|
if (modified) {
|
|
442
510
|
changes.push({ file, count: changeCount });
|
|
@@ -548,6 +616,7 @@ async function runMigrate(args2) {
|
|
|
548
616
|
}
|
|
549
617
|
tasks.push("Migrate deprecated composables (defineOgImageStatic, etc.) to defineOgImage()");
|
|
550
618
|
tasks.push("Migrate <OgImage> and <OgImageScreenshot> components to composables");
|
|
619
|
+
tasks.push("Migrate defineOgImage({ url }) to useSeoMeta({ ogImage })");
|
|
551
620
|
tasks.push("Update defineOgImage() calls to new API");
|
|
552
621
|
p__namespace.note(tasks.map((t) => `\u2022 ${t}`).join("\n"), "Migration tasks");
|
|
553
622
|
if (dryRun) {
|