nuxt-og-image 5.1.13 → 6.0.0-beta.1
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/bin/cli.mjs +2 -0
- package/dist/chunks/tw4-classes.cjs +116 -0
- package/dist/chunks/tw4-classes.mjs +113 -0
- package/dist/chunks/tw4-generator.cjs +118 -0
- package/dist/chunks/tw4-generator.mjs +110 -0
- package/dist/cli.cjs +333 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +330 -0
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_fonts/0xp3SbCWC1OhX7q1-uF6kilMZFm-alJNkUtkLTPCy_A-tN9KwPUWhhXvtqh74sU9FIkI4W6hsbm85r0X24hjOfM.woff2 +0 -0
- package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-D6hedAgqRfOCLZzaShnyeAvlEnMzk4Wm7g9WDKWFHIc.woff +0 -0
- package/dist/client/_fonts/4HA9tc4y8BVQeLXvLn3JgQqilAj1xrAnUSprQGHIPSw-ZPswEL_UDOYaxTLQDUySPjoOHDxhD83pD19HMfKfK9s.woff2 +0 -0
- package/dist/client/_fonts/Bmul3LaKlc7BUKqJHE_UmEoF40Sg_2ga52yJjwyDcKs-TnYmYl1DNYkiWMu0Vx49DakCPBuiCCj9zoLIuQjUdKY.woff2 +0 -0
- package/dist/client/_fonts/DfgmjWGpWte3Q3a54Nevr_BYmMM5YEJXRI1CdI2VwO0-ox5RadQfCyVTmKl_hubTaIJjtRw9oaQz2GDBeZR6l1M.woff2 +0 -0
- package/dist/client/_fonts/Lc_5lWuBuZcZ166p1-s-mnGkMJwIYJE_QDCkws8iCkI-r45Qbm2hCykrfOZ0kowz__uTTTUOPDN9hz34QcRNTY4.woff2 +0 -0
- package/dist/client/_fonts/iEvApgDRmzKzNqOYocBTrmcHZmuGAJloawKDP1S0nyE-T3oc_9We24QGwfw5naik4cM0g7VxylWVaQwKm4dy3cw.woff2 +0 -0
- package/dist/client/_nuxt/0kYTU2a7.js +2 -0
- package/dist/client/_nuxt/B0QDx5EE.js +2 -0
- package/dist/client/_nuxt/BKqzYw6x.js +3 -0
- package/dist/client/_nuxt/C-Ivr2Rl.js +1 -0
- package/dist/client/_nuxt/CLgn8DCr.js +1 -0
- package/dist/client/_nuxt/CwWm-XE3.js +1 -0
- package/dist/client/_nuxt/D9eL2h5z.js +1 -0
- package/dist/client/_nuxt/DJXHIJSq.js +1 -0
- package/dist/client/_nuxt/DVnX3Z-O.js +1 -0
- package/dist/client/_nuxt/DXObZt09.js +184 -0
- package/dist/client/_nuxt/Dxi6QG7I.js +1 -0
- package/dist/client/_nuxt/E8AZ6HoH.js +1 -0
- package/dist/client/_nuxt/IFrameLoader.CGrV1TpP.css +1 -0
- package/dist/client/_nuxt/JAMwWy1K.js +3864 -0
- package/dist/client/_nuxt/OSectionBlock.BVHnMsIr.css +1 -0
- package/dist/client/_nuxt/PONEy9N-.js +1 -0
- package/dist/client/_nuxt/UdkqSAsD.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/5205806b-8e5a-41ea-90c0-9cd83a75fc0a.json +1 -0
- package/dist/client/_nuxt/entry.BEExJd9R.css +2 -0
- package/dist/client/_nuxt/error-404.B79WD2X-.css +1 -0
- package/dist/client/_nuxt/error-500.DT3Sd0Wu.css +1 -0
- package/dist/client/_nuxt/pages.eW3hi7XF.css +1 -0
- package/dist/client/_nuxt/templates.dUiUBaip.css +1 -0
- package/dist/client/_payload.json +1 -0
- package/dist/client/debug/_payload.json +1 -0
- package/dist/client/debug/index.html +1 -0
- package/dist/client/docs/_payload.json +1 -0
- package/dist/client/docs/index.html +1 -0
- package/dist/client/fonts/HubotSans-Regular.woff2 +0 -0
- package/dist/client/index.html +1 -1
- package/dist/client/templates/_payload.json +1 -0
- package/dist/client/templates/index.html +1 -0
- package/dist/module.cjs +36 -1027
- package/dist/module.d.cts +63 -25
- package/dist/module.d.mts +63 -25
- package/dist/module.d.ts +63 -25
- package/dist/module.json +1 -1
- package/dist/module.mjs +32 -1009
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.d.vue.ts +14 -0
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue +51 -0
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue.d.ts +14 -0
- package/dist/runtime/app/components/Templates/Community/{Frame.vue.d.ts → Frame.satori.d.vue.ts} +2 -2
- package/dist/runtime/app/components/Templates/Community/Frame.satori.vue +71 -0
- package/dist/runtime/app/components/Templates/Community/{Frame.d.vue.ts → Frame.satori.vue.d.ts} +2 -2
- package/dist/runtime/app/components/Templates/Community/Newspaper.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Newspaper.satori.vue +70 -0
- package/dist/runtime/app/components/Templates/Community/Newspaper.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Nuxt.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/{Nuxt.vue → Nuxt.satori.vue} +3 -3
- package/dist/runtime/app/components/Templates/Community/Nuxt.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue +69 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Pergel.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/{Pergel.vue → Pergel.satori.vue} +14 -11
- package/dist/runtime/app/components/Templates/Community/Pergel.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Retro.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/Retro.satori.vue +64 -0
- package/dist/runtime/app/components/Templates/Community/Retro.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.d.vue.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue +60 -0
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue.d.ts +12 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.d.vue.ts +9 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue +38 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue.d.ts +9 -0
- package/dist/runtime/app/components/Templates/Community/{UnJs.d.vue.ts → UnJs.satori.d.vue.ts} +2 -2
- package/dist/runtime/app/components/Templates/Community/{UnJs.vue → UnJs.satori.vue} +41 -33
- package/dist/runtime/app/components/Templates/Community/{UnJs.vue.d.ts → UnJs.satori.vue.d.ts} +2 -2
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.d.vue.ts +13 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue +27 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue.d.ts +13 -0
- package/dist/runtime/app/composables/_defineOgImageRaw.d.ts +6 -0
- package/dist/runtime/app/composables/_defineOgImageRaw.js +70 -0
- package/dist/runtime/app/composables/defineOgImage.d.ts +14 -2
- package/dist/runtime/app/composables/defineOgImage.js +13 -42
- package/dist/runtime/app/composables/defineOgImageComponent.d.ts +5 -1
- package/dist/runtime/app/composables/defineOgImageComponent.js +4 -5
- package/dist/runtime/app/composables/defineOgImageScreenshot.d.ts +1 -1
- package/dist/runtime/app/composables/defineOgImageScreenshot.js +2 -2
- package/dist/runtime/app/composables/mock.d.ts +7 -4
- package/dist/runtime/app/composables/mock.js +4 -4
- package/dist/runtime/app/utils/plugins.js +22 -28
- package/dist/runtime/app/utils.d.ts +15 -1
- package/dist/runtime/app/utils.js +74 -46
- package/dist/runtime/pure.d.ts +7 -0
- package/dist/runtime/pure.js +105 -0
- package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.d.ts +3 -2
- package/dist/runtime/server/og-image/bindings/css-inline/wasm.d.ts +3 -2
- package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.js +22 -0
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +49 -0
- package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/font-assets/node.js +14 -0
- package/dist/runtime/server/og-image/bindings/resvg/node-dev.d.ts +5 -0
- package/dist/runtime/server/og-image/bindings/resvg/node-dev.js +70 -0
- package/dist/runtime/server/og-image/bindings/takumi/node.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/takumi/node.js +5 -0
- package/dist/runtime/server/og-image/bindings/takumi/wasm.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/takumi/wasm.js +6 -0
- package/dist/runtime/server/og-image/cache/buildCache.d.ts +16 -0
- package/dist/runtime/server/og-image/cache/buildCache.js +48 -0
- package/dist/runtime/server/og-image/cache/lru.d.ts +2 -2
- package/dist/runtime/server/og-image/cache/lru.js +3 -3
- package/dist/runtime/server/og-image/cache/mock.d.ts +1 -2
- package/dist/runtime/server/og-image/cache/mock.js +0 -1
- package/dist/runtime/server/og-image/chromium/screenshot.js +4 -3
- package/dist/runtime/server/og-image/context.d.ts +2 -3
- package/dist/runtime/server/og-image/context.js +55 -193
- package/dist/runtime/server/og-image/devtools.d.ts +10 -0
- package/dist/runtime/server/og-image/devtools.js +74 -0
- package/dist/runtime/server/og-image/fonts.d.ts +6 -0
- package/dist/runtime/server/og-image/fonts.js +41 -0
- package/dist/runtime/server/og-image/instances.d.ts +1 -0
- package/dist/runtime/server/og-image/instances.js +5 -0
- package/dist/runtime/server/og-image/satori/instances.d.ts +1 -36
- package/dist/runtime/server/og-image/satori/plugins/emojis.js +83 -4
- package/dist/runtime/server/og-image/satori/plugins/encoding.js +11 -1
- package/dist/runtime/server/og-image/satori/plugins/imageSrc.js +5 -1
- package/dist/runtime/server/og-image/satori/plugins/twClasses.js +35 -0
- package/dist/runtime/server/og-image/satori/renderer.js +16 -53
- package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-names-minimal.d.ts +1 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-names-minimal.js +223 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.d.ts +45 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js +13 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/fetch.d.ts +6 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/fetch.js +38 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/index.d.ts +7 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/index.js +64 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/local.d.ts +7 -0
- package/dist/runtime/server/og-image/satori/transforms/emojis/local.js +32 -0
- package/dist/runtime/server/og-image/satori/utils.js +5 -4
- package/dist/runtime/server/og-image/satori/vnodes.js +7 -6
- package/dist/runtime/server/og-image/takumi/instances.d.ts +1 -0
- package/dist/runtime/server/og-image/takumi/instances.js +6 -0
- package/dist/runtime/server/og-image/takumi/nodes.d.ts +12 -0
- package/dist/runtime/server/og-image/takumi/nodes.js +86 -0
- package/dist/runtime/server/og-image/takumi/renderer.d.ts +3 -0
- package/dist/runtime/server/og-image/takumi/renderer.js +45 -0
- package/dist/runtime/server/og-image/templates/html.js +32 -23
- package/dist/runtime/server/plugins/prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/prerender.js +17 -7
- package/dist/runtime/server/util/auto-eject.d.ts +2 -0
- package/dist/runtime/server/util/auto-eject.js +30 -0
- package/dist/runtime/server/util/eventHandlers.d.ts +0 -1
- package/dist/runtime/server/util/eventHandlers.js +15 -85
- package/dist/runtime/server/util/options.d.ts +7 -2
- package/dist/runtime/server/util/options.js +40 -6
- package/dist/runtime/server/utils.d.ts +6 -2
- package/dist/runtime/server/utils.js +12 -8
- package/dist/runtime/shared/urlEncoding.d.ts +64 -0
- package/dist/runtime/shared/urlEncoding.js +194 -0
- package/dist/runtime/shared.d.ts +4 -9
- package/dist/runtime/shared.js +31 -50
- package/dist/runtime/types.d.ts +71 -25
- package/dist/shared/nuxt-og-image.DroaQ3v-.cjs +2852 -0
- package/dist/shared/nuxt-og-image.HMyihp-D.mjs +2825 -0
- package/dist/types.d.mts +2 -0
- package/package.json +105 -43
- package/types/virtual.d.ts +7 -1
- package/dist/client/_nuxt/B3LgXoKV.js +0 -2
- package/dist/client/_nuxt/B8PEiB0p.js +0 -1
- package/dist/client/_nuxt/CPsbVDfV.js +0 -1
- package/dist/client/_nuxt/CVO1_9PV.js +0 -1
- package/dist/client/_nuxt/CjQm5wk3.js +0 -4029
- package/dist/client/_nuxt/Cp-IABpG.js +0 -1
- package/dist/client/_nuxt/D0TMZt8T.js +0 -1
- package/dist/client/_nuxt/D0r3Knsf.js +0 -1
- package/dist/client/_nuxt/builds/meta/eb2c0390-3125-4af7-b189-e76a7dfe3017.json +0 -1
- package/dist/client/_nuxt/entry.cdy4VsCK.css +0 -1
- package/dist/client/_nuxt/error-404.Cu4JbXd7.css +0 -1
- package/dist/client/_nuxt/error-500.B79uceR7.css +0 -1
- package/dist/runtime/app/components/OgImage/OgImage.d.ts +0 -3
- package/dist/runtime/app/components/OgImage/OgImage.js +0 -10
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.d.vue.ts +0 -13
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue +0 -22
- package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue.d.ts +0 -13
- package/dist/runtime/app/components/Templates/Community/Frame.vue +0 -58
- package/dist/runtime/app/components/Templates/Community/Nuxt.d.vue.ts +0 -12
- package/dist/runtime/app/components/Templates/Community/Nuxt.vue.d.ts +0 -12
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.d.vue.ts +0 -15
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue +0 -103
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue.d.ts +0 -15
- package/dist/runtime/app/components/Templates/Community/Pergel.d.vue.ts +0 -12
- package/dist/runtime/app/components/Templates/Community/Pergel.vue.d.ts +0 -12
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.d.vue.ts +0 -9
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue +0 -27
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue.d.ts +0 -9
- package/dist/runtime/app/components/Templates/Community/Wave.d.vue.ts +0 -11
- package/dist/runtime/app/components/Templates/Community/Wave.vue +0 -28
- package/dist/runtime/app/components/Templates/Community/Wave.vue.d.ts +0 -11
- package/dist/runtime/app/components/Templates/Community/WithEmoji.d.vue.ts +0 -13
- package/dist/runtime/app/components/Templates/Community/WithEmoji.vue +0 -21
- package/dist/runtime/app/components/Templates/Community/WithEmoji.vue.d.ts +0 -13
- package/dist/runtime/assets/Inter-normal-400.ttf.base64 +0 -1
- package/dist/runtime/assets/Inter-normal-700.ttf.base64 +0 -1
- package/dist/runtime/server/og-image/satori/font.d.ts +0 -3
- package/dist/runtime/server/og-image/satori/font.js +0 -40
- package/dist/runtime/server/og-image/satori/plugins/unocss.js +0 -55
- package/dist/runtime/server/og-image/satori/transforms/emojis.d.ts +0 -3
- package/dist/runtime/server/og-image/satori/transforms/emojis.js +0 -3595
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.d.ts +0 -2
- package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.js +0 -9
- package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +0 -2
- package/dist/runtime/server/plugins/nuxt-content-v2.js +0 -5
- package/dist/runtime/server/routes/__zero-runtime/font.d.ts +0 -2
- package/dist/runtime/server/routes/__zero-runtime/font.js +0 -8
- package/dist/runtime/server/routes/font.d.ts +0 -2
- package/dist/runtime/server/routes/font.js +0 -3
- package/dist/runtime/server/util/plugins.d.ts +0 -2
- package/dist/runtime/server/util/plugins.js +0 -56
- /package/dist/runtime/server/og-image/satori/plugins/{unocss.d.ts → twClasses.d.ts} +0 -0
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const node_child_process = require('node:child_process');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const node_path = require('node:path');
|
|
7
|
+
const node_readline = require('node:readline');
|
|
8
|
+
const node_url = require('node:url');
|
|
9
|
+
|
|
10
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
|
+
async function confirm(message) {
|
|
12
|
+
const rl = node_readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
13
|
+
return new Promise((resolve2) => {
|
|
14
|
+
rl.question(`${message} (y/N) `, (answer) => {
|
|
15
|
+
rl.close();
|
|
16
|
+
resolve2(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const __dirname$1 = node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
|
|
21
|
+
const communityDir = node_path.resolve(__dirname$1, "runtime/app/components/Templates/Community");
|
|
22
|
+
const defaultComponentDirs = ["OgImage", "OgImageCommunity", "og-image", "OgImageTemplate"];
|
|
23
|
+
const RENDERER_DEPS = {
|
|
24
|
+
satori: ["satori", "@resvg/resvg-js"],
|
|
25
|
+
chromium: ["playwright-core"],
|
|
26
|
+
takumi: ["@aspect-build/aspect", "linkedom"]
|
|
27
|
+
};
|
|
28
|
+
function getBaseName(filename) {
|
|
29
|
+
return filename.replace(/\.(satori|chromium|takumi)\.vue$/, "");
|
|
30
|
+
}
|
|
31
|
+
function hasRendererSuffix(filename) {
|
|
32
|
+
return /\.(?:satori|chromium|takumi)\.vue$/.test(filename);
|
|
33
|
+
}
|
|
34
|
+
function listTemplates() {
|
|
35
|
+
const templates = fs.readdirSync(communityDir).filter((f) => f.endsWith(".vue")).map(getBaseName);
|
|
36
|
+
console.log("\nAvailable community templates:");
|
|
37
|
+
templates.forEach((t) => console.log(` - ${t}`));
|
|
38
|
+
console.log("\nUsage: npx nuxt-og-image eject <template-name>\n");
|
|
39
|
+
}
|
|
40
|
+
function findTemplateFile(name) {
|
|
41
|
+
const files = fs.readdirSync(communityDir).filter((f) => f.endsWith(".vue"));
|
|
42
|
+
const match = files.find((f) => getBaseName(f) === name);
|
|
43
|
+
return match || null;
|
|
44
|
+
}
|
|
45
|
+
function ejectTemplate(name, targetDir) {
|
|
46
|
+
const templateFile = findTemplateFile(name);
|
|
47
|
+
if (!templateFile) {
|
|
48
|
+
console.error(`Template "${name}" not found.`);
|
|
49
|
+
listTemplates();
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
const templatePath = node_path.join(communityDir, templateFile);
|
|
53
|
+
const outputDir = node_path.resolve(targetDir, "components", "OgImage");
|
|
54
|
+
if (!fs.existsSync(outputDir))
|
|
55
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
56
|
+
const outputPath = node_path.join(outputDir, templateFile);
|
|
57
|
+
if (fs.existsSync(outputPath)) {
|
|
58
|
+
console.error(`File already exists: ${outputPath}`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
const content = fs.readFileSync(templatePath, "utf-8");
|
|
62
|
+
fs.writeFileSync(outputPath, content, "utf-8");
|
|
63
|
+
console.log(`\u2713 Ejected "${name}" to ${outputPath}`);
|
|
64
|
+
}
|
|
65
|
+
function findOgImageComponents(dir) {
|
|
66
|
+
const components = [];
|
|
67
|
+
for (const componentDir of defaultComponentDirs) {
|
|
68
|
+
const ogImageDir = node_path.join(dir, "components", componentDir);
|
|
69
|
+
if (fs.existsSync(ogImageDir)) {
|
|
70
|
+
const files = fs.readdirSync(ogImageDir, { withFileTypes: true });
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
if (file.isFile() && file.name.endsWith(".vue"))
|
|
73
|
+
components.push(node_path.join(ogImageDir, file.name));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return components;
|
|
78
|
+
}
|
|
79
|
+
function globFiles(dir, pattern, exclude = []) {
|
|
80
|
+
const results = [];
|
|
81
|
+
function walk(currentDir) {
|
|
82
|
+
if (!fs.existsSync(currentDir))
|
|
83
|
+
return;
|
|
84
|
+
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
85
|
+
for (const entry of entries) {
|
|
86
|
+
const fullPath = node_path.join(currentDir, entry.name);
|
|
87
|
+
if (exclude.some((re) => re.test(fullPath)))
|
|
88
|
+
continue;
|
|
89
|
+
if (entry.isDirectory()) {
|
|
90
|
+
walk(fullPath);
|
|
91
|
+
} else if (entry.isFile() && pattern.test(entry.name)) {
|
|
92
|
+
results.push(fullPath);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
walk(dir);
|
|
97
|
+
return results;
|
|
98
|
+
}
|
|
99
|
+
function migrateDefineOgImageApi(dryRun) {
|
|
100
|
+
const cwd = process.cwd();
|
|
101
|
+
const excludePatterns = [
|
|
102
|
+
/node_modules/,
|
|
103
|
+
/\.nuxt/,
|
|
104
|
+
/\.output/,
|
|
105
|
+
/dist/
|
|
106
|
+
];
|
|
107
|
+
const files = globFiles(cwd, /\.(?:vue|ts|tsx|js|jsx)$/, excludePatterns);
|
|
108
|
+
const changes = [];
|
|
109
|
+
for (const file of files) {
|
|
110
|
+
let content = fs.readFileSync(file, "utf-8");
|
|
111
|
+
let modified = false;
|
|
112
|
+
let changeCount = 0;
|
|
113
|
+
if (/defineOgImageComponent\s*\(/.test(content)) {
|
|
114
|
+
content = content.replace(/defineOgImageComponent\s*\(/g, "defineOgImage(");
|
|
115
|
+
modified = true;
|
|
116
|
+
changeCount++;
|
|
117
|
+
}
|
|
118
|
+
const defineOgImageRegex = /defineOgImage\s*\(\s*(\{[\s\S]*?\})\s*\)/g;
|
|
119
|
+
content = content.replace(defineOgImageRegex, (match, inner) => {
|
|
120
|
+
const componentMatch = inner.match(/component\s*:\s*['"]([^'"]+)['"]/);
|
|
121
|
+
const rendererMatch = inner.match(/renderer\s*:\s*['"]([^'"]+)['"]/);
|
|
122
|
+
const propsMatch = inner.match(/props\s*:\s*(\{[^}]*\})/);
|
|
123
|
+
if (!componentMatch && rendererMatch && rendererMatch[1] === "chromium") {
|
|
124
|
+
const remaining = inner.replace(/renderer\s*:\s*['"][^'"]+['"]\s*,?\s*/g, "").replace(/,\s*$/, "").trim();
|
|
125
|
+
modified = true;
|
|
126
|
+
changeCount++;
|
|
127
|
+
if (remaining) {
|
|
128
|
+
return `defineOgImageScreenshot({ ${remaining} })`;
|
|
129
|
+
}
|
|
130
|
+
return `defineOgImageScreenshot()`;
|
|
131
|
+
}
|
|
132
|
+
if (componentMatch || rendererMatch) {
|
|
133
|
+
const componentName = componentMatch ? componentMatch[1] : "NuxtSeo";
|
|
134
|
+
const props = propsMatch ? propsMatch[1] : "{}";
|
|
135
|
+
const otherOptions = [];
|
|
136
|
+
const lines = inner.split(/,(?![^{]*\})/).map((s) => s.trim());
|
|
137
|
+
for (const line of lines) {
|
|
138
|
+
if (!line)
|
|
139
|
+
continue;
|
|
140
|
+
if (/^component\s*:/.test(line))
|
|
141
|
+
continue;
|
|
142
|
+
if (/^props\s*:/.test(line))
|
|
143
|
+
continue;
|
|
144
|
+
if (/^renderer\s*:/.test(line))
|
|
145
|
+
continue;
|
|
146
|
+
otherOptions.push(line);
|
|
147
|
+
}
|
|
148
|
+
modified = true;
|
|
149
|
+
changeCount++;
|
|
150
|
+
if (otherOptions.length > 0) {
|
|
151
|
+
return `defineOgImage('${componentName}', ${props}, { ${otherOptions.join(", ")} })`;
|
|
152
|
+
}
|
|
153
|
+
return `defineOgImage('${componentName}', ${props})`;
|
|
154
|
+
}
|
|
155
|
+
return match;
|
|
156
|
+
});
|
|
157
|
+
if (modified) {
|
|
158
|
+
changes.push({ file, count: changeCount });
|
|
159
|
+
if (!dryRun) {
|
|
160
|
+
fs.writeFileSync(file, content, "utf-8");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (changes.length === 0) {
|
|
165
|
+
console.log("\u2713 No defineOgImage calls need migration.");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
console.log(`
|
|
169
|
+
Found ${changes.length} file(s) with changes:
|
|
170
|
+
`);
|
|
171
|
+
for (const { file, count } of changes) {
|
|
172
|
+
const relPath = file.replace(`${cwd}/`, "");
|
|
173
|
+
console.log(` ${relPath} (${count} change${count > 1 ? "s" : ""})`);
|
|
174
|
+
}
|
|
175
|
+
if (dryRun) {
|
|
176
|
+
console.log("\n[Dry run - no changes made]");
|
|
177
|
+
console.log(`
|
|
178
|
+
Run without --dry-run to apply changes.`);
|
|
179
|
+
} else {
|
|
180
|
+
console.log(`
|
|
181
|
+
\u2713 Migration complete. ${changes.length} file(s) updated.`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function migrateV6(dryRun, defaultRenderer = "satori") {
|
|
185
|
+
const cwd = process.cwd();
|
|
186
|
+
const dirs = [cwd];
|
|
187
|
+
if (fs.existsSync(node_path.join(cwd, "app")))
|
|
188
|
+
dirs.push(node_path.join(cwd, "app"));
|
|
189
|
+
const layersDir = node_path.join(cwd, "layers");
|
|
190
|
+
if (fs.existsSync(layersDir)) {
|
|
191
|
+
const layerDirs = fs.readdirSync(layersDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => node_path.join(layersDir, d.name));
|
|
192
|
+
dirs.push(...layerDirs);
|
|
193
|
+
}
|
|
194
|
+
const toRename = [];
|
|
195
|
+
for (const dir of dirs) {
|
|
196
|
+
const components = findOgImageComponents(dir);
|
|
197
|
+
for (const filepath of components) {
|
|
198
|
+
const filename = filepath.split("/").pop();
|
|
199
|
+
if (!hasRendererSuffix(filename)) {
|
|
200
|
+
const newName = filename.replace(".vue", `.${defaultRenderer}.vue`);
|
|
201
|
+
toRename.push({
|
|
202
|
+
from: filepath,
|
|
203
|
+
to: filepath.replace(filename, newName)
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (toRename.length === 0) {
|
|
209
|
+
console.log("\u2713 All OG Image components already have renderer suffixes.");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
console.log(`
|
|
213
|
+
Found ${toRename.length} component(s) to rename:
|
|
214
|
+
`);
|
|
215
|
+
for (const { from, to } of toRename) {
|
|
216
|
+
const fromName = from.split("/").pop();
|
|
217
|
+
const toName = to.split("/").pop();
|
|
218
|
+
console.log(` ${fromName} \u2192 ${toName}`);
|
|
219
|
+
}
|
|
220
|
+
if (dryRun) {
|
|
221
|
+
console.log("\n[Dry run - no changes made]");
|
|
222
|
+
console.log(`
|
|
223
|
+
Run without --dry-run to apply changes.`);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
console.log("");
|
|
227
|
+
for (const { from, to } of toRename) {
|
|
228
|
+
fs.renameSync(from, to);
|
|
229
|
+
console.log(`\u2713 Renamed ${from.split("/").pop()}`);
|
|
230
|
+
}
|
|
231
|
+
console.log(`
|
|
232
|
+
\u2713 Migration complete. ${toRename.length} file(s) renamed.`);
|
|
233
|
+
}
|
|
234
|
+
function enableRenderer(renderer) {
|
|
235
|
+
const deps = RENDERER_DEPS[renderer];
|
|
236
|
+
if (!deps) {
|
|
237
|
+
console.error(`Unknown renderer: ${renderer}`);
|
|
238
|
+
console.log("Available renderers: satori, chromium, takumi");
|
|
239
|
+
process.exit(1);
|
|
240
|
+
}
|
|
241
|
+
console.log(`Installing dependencies for ${renderer} renderer:`);
|
|
242
|
+
console.log(` ${deps.join(", ")}
|
|
243
|
+
`);
|
|
244
|
+
const cwd = process.cwd();
|
|
245
|
+
let pm = "npm";
|
|
246
|
+
if (fs.existsSync(node_path.join(cwd, "pnpm-lock.yaml")))
|
|
247
|
+
pm = "pnpm";
|
|
248
|
+
else if (fs.existsSync(node_path.join(cwd, "yarn.lock")))
|
|
249
|
+
pm = "yarn";
|
|
250
|
+
else if (fs.existsSync(node_path.join(cwd, "bun.lockb")))
|
|
251
|
+
pm = "bun";
|
|
252
|
+
const installCmd = pm === "npm" ? `${pm} install` : `${pm} add`;
|
|
253
|
+
const cmd = `${installCmd} ${deps.join(" ")}`;
|
|
254
|
+
console.log(`Running: ${cmd}
|
|
255
|
+
`);
|
|
256
|
+
node_child_process.execSync(cmd, { stdio: "inherit", cwd });
|
|
257
|
+
console.log(`
|
|
258
|
+
\u2713 ${renderer} renderer enabled.`);
|
|
259
|
+
}
|
|
260
|
+
const args = process.argv.slice(2);
|
|
261
|
+
const command = args[0];
|
|
262
|
+
if (command === "eject") {
|
|
263
|
+
const templateName = args[1];
|
|
264
|
+
if (!templateName) {
|
|
265
|
+
console.error("Please specify a template name.");
|
|
266
|
+
listTemplates();
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
const cwd = process.cwd();
|
|
270
|
+
const targetDir = fs.existsSync(node_path.join(cwd, "app")) ? node_path.join(cwd, "app") : cwd;
|
|
271
|
+
ejectTemplate(templateName, targetDir);
|
|
272
|
+
} else if (command === "list") {
|
|
273
|
+
listTemplates();
|
|
274
|
+
} else if (command === "migrate") {
|
|
275
|
+
const version = args[1];
|
|
276
|
+
if (version !== "v6") {
|
|
277
|
+
console.error("Usage: npx nuxt-og-image migrate v6 [--dry-run] [--renderer <satori|chromium|takumi>]");
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
const dryRun = args.includes("--dry-run") || args.includes("-d");
|
|
281
|
+
const skipConfirm = args.includes("--yes") || args.includes("-y");
|
|
282
|
+
const rendererIdx = args.indexOf("--renderer");
|
|
283
|
+
const renderer = rendererIdx !== -1 ? args[rendererIdx + 1] || "satori" : "satori";
|
|
284
|
+
if (!["satori", "chromium", "takumi"].includes(renderer)) {
|
|
285
|
+
console.error(`Invalid renderer: ${renderer}. Must be satori, chromium, or takumi.`);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
console.log("nuxt-og-image v6 Migration\n");
|
|
289
|
+
console.log("This will:");
|
|
290
|
+
console.log(" 1. Rename OgImage components to include renderer suffix (.satori.vue, etc.)");
|
|
291
|
+
console.log(" 2. Update defineOgImage() calls to new component-first API");
|
|
292
|
+
console.log("");
|
|
293
|
+
console.log("\x1B[33m\u26A0 WARNING: This modifies files directly and could break your code.\x1B[0m");
|
|
294
|
+
console.log("\x1B[33m Make sure you have committed or backed up your changes first.\x1B[0m");
|
|
295
|
+
console.log("");
|
|
296
|
+
if (dryRun) {
|
|
297
|
+
console.log("[Dry run mode - no files will be modified]\n");
|
|
298
|
+
migrateV6(true, renderer);
|
|
299
|
+
console.log("");
|
|
300
|
+
migrateDefineOgImageApi(true);
|
|
301
|
+
} else if (skipConfirm) {
|
|
302
|
+
migrateV6(false, renderer);
|
|
303
|
+
console.log("");
|
|
304
|
+
migrateDefineOgImageApi(false);
|
|
305
|
+
} else {
|
|
306
|
+
confirm("Continue with migration?").then((confirmed) => {
|
|
307
|
+
if (!confirmed) {
|
|
308
|
+
console.log("Migration cancelled.");
|
|
309
|
+
process.exit(0);
|
|
310
|
+
}
|
|
311
|
+
console.log("");
|
|
312
|
+
migrateV6(false, renderer);
|
|
313
|
+
console.log("");
|
|
314
|
+
migrateDefineOgImageApi(false);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
} else if (command === "enable") {
|
|
318
|
+
const renderer = args[1];
|
|
319
|
+
if (!renderer) {
|
|
320
|
+
console.error("Usage: npx nuxt-og-image enable <renderer>");
|
|
321
|
+
console.log("Available renderers: satori, chromium, takumi");
|
|
322
|
+
process.exit(1);
|
|
323
|
+
}
|
|
324
|
+
enableRenderer(renderer);
|
|
325
|
+
} else {
|
|
326
|
+
console.log("nuxt-og-image CLI\n");
|
|
327
|
+
console.log("Commands:");
|
|
328
|
+
console.log(" list List available community templates");
|
|
329
|
+
console.log(" eject <name> Eject a community template to your project");
|
|
330
|
+
console.log(" migrate v6 Migrate to v6 (component suffixes + new API)");
|
|
331
|
+
console.log(" Options: --dry-run, --renderer <satori|chromium|takumi>");
|
|
332
|
+
console.log(" enable <renderer> Install dependencies for a renderer (satori, chromium, takumi)");
|
|
333
|
+
}
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from 'node:child_process';
|
|
3
|
+
import { existsSync, readdirSync, mkdirSync, readFileSync, writeFileSync, renameSync } from 'node:fs';
|
|
4
|
+
import { dirname, resolve, join } from 'node:path';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
async function confirm(message) {
|
|
9
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
10
|
+
return new Promise((resolve2) => {
|
|
11
|
+
rl.question(`${message} (y/N) `, (answer) => {
|
|
12
|
+
rl.close();
|
|
13
|
+
resolve2(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const __dirname$1 = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const communityDir = resolve(__dirname$1, "runtime/app/components/Templates/Community");
|
|
19
|
+
const defaultComponentDirs = ["OgImage", "OgImageCommunity", "og-image", "OgImageTemplate"];
|
|
20
|
+
const RENDERER_DEPS = {
|
|
21
|
+
satori: ["satori", "@resvg/resvg-js"],
|
|
22
|
+
chromium: ["playwright-core"],
|
|
23
|
+
takumi: ["@aspect-build/aspect", "linkedom"]
|
|
24
|
+
};
|
|
25
|
+
function getBaseName(filename) {
|
|
26
|
+
return filename.replace(/\.(satori|chromium|takumi)\.vue$/, "");
|
|
27
|
+
}
|
|
28
|
+
function hasRendererSuffix(filename) {
|
|
29
|
+
return /\.(?:satori|chromium|takumi)\.vue$/.test(filename);
|
|
30
|
+
}
|
|
31
|
+
function listTemplates() {
|
|
32
|
+
const templates = readdirSync(communityDir).filter((f) => f.endsWith(".vue")).map(getBaseName);
|
|
33
|
+
console.log("\nAvailable community templates:");
|
|
34
|
+
templates.forEach((t) => console.log(` - ${t}`));
|
|
35
|
+
console.log("\nUsage: npx nuxt-og-image eject <template-name>\n");
|
|
36
|
+
}
|
|
37
|
+
function findTemplateFile(name) {
|
|
38
|
+
const files = readdirSync(communityDir).filter((f) => f.endsWith(".vue"));
|
|
39
|
+
const match = files.find((f) => getBaseName(f) === name);
|
|
40
|
+
return match || null;
|
|
41
|
+
}
|
|
42
|
+
function ejectTemplate(name, targetDir) {
|
|
43
|
+
const templateFile = findTemplateFile(name);
|
|
44
|
+
if (!templateFile) {
|
|
45
|
+
console.error(`Template "${name}" not found.`);
|
|
46
|
+
listTemplates();
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const templatePath = join(communityDir, templateFile);
|
|
50
|
+
const outputDir = resolve(targetDir, "components", "OgImage");
|
|
51
|
+
if (!existsSync(outputDir))
|
|
52
|
+
mkdirSync(outputDir, { recursive: true });
|
|
53
|
+
const outputPath = join(outputDir, templateFile);
|
|
54
|
+
if (existsSync(outputPath)) {
|
|
55
|
+
console.error(`File already exists: ${outputPath}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const content = readFileSync(templatePath, "utf-8");
|
|
59
|
+
writeFileSync(outputPath, content, "utf-8");
|
|
60
|
+
console.log(`\u2713 Ejected "${name}" to ${outputPath}`);
|
|
61
|
+
}
|
|
62
|
+
function findOgImageComponents(dir) {
|
|
63
|
+
const components = [];
|
|
64
|
+
for (const componentDir of defaultComponentDirs) {
|
|
65
|
+
const ogImageDir = join(dir, "components", componentDir);
|
|
66
|
+
if (existsSync(ogImageDir)) {
|
|
67
|
+
const files = readdirSync(ogImageDir, { withFileTypes: true });
|
|
68
|
+
for (const file of files) {
|
|
69
|
+
if (file.isFile() && file.name.endsWith(".vue"))
|
|
70
|
+
components.push(join(ogImageDir, file.name));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return components;
|
|
75
|
+
}
|
|
76
|
+
function globFiles(dir, pattern, exclude = []) {
|
|
77
|
+
const results = [];
|
|
78
|
+
function walk(currentDir) {
|
|
79
|
+
if (!existsSync(currentDir))
|
|
80
|
+
return;
|
|
81
|
+
const entries = readdirSync(currentDir, { withFileTypes: true });
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
const fullPath = join(currentDir, entry.name);
|
|
84
|
+
if (exclude.some((re) => re.test(fullPath)))
|
|
85
|
+
continue;
|
|
86
|
+
if (entry.isDirectory()) {
|
|
87
|
+
walk(fullPath);
|
|
88
|
+
} else if (entry.isFile() && pattern.test(entry.name)) {
|
|
89
|
+
results.push(fullPath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
walk(dir);
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
function migrateDefineOgImageApi(dryRun) {
|
|
97
|
+
const cwd = process.cwd();
|
|
98
|
+
const excludePatterns = [
|
|
99
|
+
/node_modules/,
|
|
100
|
+
/\.nuxt/,
|
|
101
|
+
/\.output/,
|
|
102
|
+
/dist/
|
|
103
|
+
];
|
|
104
|
+
const files = globFiles(cwd, /\.(?:vue|ts|tsx|js|jsx)$/, excludePatterns);
|
|
105
|
+
const changes = [];
|
|
106
|
+
for (const file of files) {
|
|
107
|
+
let content = readFileSync(file, "utf-8");
|
|
108
|
+
let modified = false;
|
|
109
|
+
let changeCount = 0;
|
|
110
|
+
if (/defineOgImageComponent\s*\(/.test(content)) {
|
|
111
|
+
content = content.replace(/defineOgImageComponent\s*\(/g, "defineOgImage(");
|
|
112
|
+
modified = true;
|
|
113
|
+
changeCount++;
|
|
114
|
+
}
|
|
115
|
+
const defineOgImageRegex = /defineOgImage\s*\(\s*(\{[\s\S]*?\})\s*\)/g;
|
|
116
|
+
content = content.replace(defineOgImageRegex, (match, inner) => {
|
|
117
|
+
const componentMatch = inner.match(/component\s*:\s*['"]([^'"]+)['"]/);
|
|
118
|
+
const rendererMatch = inner.match(/renderer\s*:\s*['"]([^'"]+)['"]/);
|
|
119
|
+
const propsMatch = inner.match(/props\s*:\s*(\{[^}]*\})/);
|
|
120
|
+
if (!componentMatch && rendererMatch && rendererMatch[1] === "chromium") {
|
|
121
|
+
const remaining = inner.replace(/renderer\s*:\s*['"][^'"]+['"]\s*,?\s*/g, "").replace(/,\s*$/, "").trim();
|
|
122
|
+
modified = true;
|
|
123
|
+
changeCount++;
|
|
124
|
+
if (remaining) {
|
|
125
|
+
return `defineOgImageScreenshot({ ${remaining} })`;
|
|
126
|
+
}
|
|
127
|
+
return `defineOgImageScreenshot()`;
|
|
128
|
+
}
|
|
129
|
+
if (componentMatch || rendererMatch) {
|
|
130
|
+
const componentName = componentMatch ? componentMatch[1] : "NuxtSeo";
|
|
131
|
+
const props = propsMatch ? propsMatch[1] : "{}";
|
|
132
|
+
const otherOptions = [];
|
|
133
|
+
const lines = inner.split(/,(?![^{]*\})/).map((s) => s.trim());
|
|
134
|
+
for (const line of lines) {
|
|
135
|
+
if (!line)
|
|
136
|
+
continue;
|
|
137
|
+
if (/^component\s*:/.test(line))
|
|
138
|
+
continue;
|
|
139
|
+
if (/^props\s*:/.test(line))
|
|
140
|
+
continue;
|
|
141
|
+
if (/^renderer\s*:/.test(line))
|
|
142
|
+
continue;
|
|
143
|
+
otherOptions.push(line);
|
|
144
|
+
}
|
|
145
|
+
modified = true;
|
|
146
|
+
changeCount++;
|
|
147
|
+
if (otherOptions.length > 0) {
|
|
148
|
+
return `defineOgImage('${componentName}', ${props}, { ${otherOptions.join(", ")} })`;
|
|
149
|
+
}
|
|
150
|
+
return `defineOgImage('${componentName}', ${props})`;
|
|
151
|
+
}
|
|
152
|
+
return match;
|
|
153
|
+
});
|
|
154
|
+
if (modified) {
|
|
155
|
+
changes.push({ file, count: changeCount });
|
|
156
|
+
if (!dryRun) {
|
|
157
|
+
writeFileSync(file, content, "utf-8");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (changes.length === 0) {
|
|
162
|
+
console.log("\u2713 No defineOgImage calls need migration.");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
console.log(`
|
|
166
|
+
Found ${changes.length} file(s) with changes:
|
|
167
|
+
`);
|
|
168
|
+
for (const { file, count } of changes) {
|
|
169
|
+
const relPath = file.replace(`${cwd}/`, "");
|
|
170
|
+
console.log(` ${relPath} (${count} change${count > 1 ? "s" : ""})`);
|
|
171
|
+
}
|
|
172
|
+
if (dryRun) {
|
|
173
|
+
console.log("\n[Dry run - no changes made]");
|
|
174
|
+
console.log(`
|
|
175
|
+
Run without --dry-run to apply changes.`);
|
|
176
|
+
} else {
|
|
177
|
+
console.log(`
|
|
178
|
+
\u2713 Migration complete. ${changes.length} file(s) updated.`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function migrateV6(dryRun, defaultRenderer = "satori") {
|
|
182
|
+
const cwd = process.cwd();
|
|
183
|
+
const dirs = [cwd];
|
|
184
|
+
if (existsSync(join(cwd, "app")))
|
|
185
|
+
dirs.push(join(cwd, "app"));
|
|
186
|
+
const layersDir = join(cwd, "layers");
|
|
187
|
+
if (existsSync(layersDir)) {
|
|
188
|
+
const layerDirs = readdirSync(layersDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join(layersDir, d.name));
|
|
189
|
+
dirs.push(...layerDirs);
|
|
190
|
+
}
|
|
191
|
+
const toRename = [];
|
|
192
|
+
for (const dir of dirs) {
|
|
193
|
+
const components = findOgImageComponents(dir);
|
|
194
|
+
for (const filepath of components) {
|
|
195
|
+
const filename = filepath.split("/").pop();
|
|
196
|
+
if (!hasRendererSuffix(filename)) {
|
|
197
|
+
const newName = filename.replace(".vue", `.${defaultRenderer}.vue`);
|
|
198
|
+
toRename.push({
|
|
199
|
+
from: filepath,
|
|
200
|
+
to: filepath.replace(filename, newName)
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (toRename.length === 0) {
|
|
206
|
+
console.log("\u2713 All OG Image components already have renderer suffixes.");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
console.log(`
|
|
210
|
+
Found ${toRename.length} component(s) to rename:
|
|
211
|
+
`);
|
|
212
|
+
for (const { from, to } of toRename) {
|
|
213
|
+
const fromName = from.split("/").pop();
|
|
214
|
+
const toName = to.split("/").pop();
|
|
215
|
+
console.log(` ${fromName} \u2192 ${toName}`);
|
|
216
|
+
}
|
|
217
|
+
if (dryRun) {
|
|
218
|
+
console.log("\n[Dry run - no changes made]");
|
|
219
|
+
console.log(`
|
|
220
|
+
Run without --dry-run to apply changes.`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
console.log("");
|
|
224
|
+
for (const { from, to } of toRename) {
|
|
225
|
+
renameSync(from, to);
|
|
226
|
+
console.log(`\u2713 Renamed ${from.split("/").pop()}`);
|
|
227
|
+
}
|
|
228
|
+
console.log(`
|
|
229
|
+
\u2713 Migration complete. ${toRename.length} file(s) renamed.`);
|
|
230
|
+
}
|
|
231
|
+
function enableRenderer(renderer) {
|
|
232
|
+
const deps = RENDERER_DEPS[renderer];
|
|
233
|
+
if (!deps) {
|
|
234
|
+
console.error(`Unknown renderer: ${renderer}`);
|
|
235
|
+
console.log("Available renderers: satori, chromium, takumi");
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
console.log(`Installing dependencies for ${renderer} renderer:`);
|
|
239
|
+
console.log(` ${deps.join(", ")}
|
|
240
|
+
`);
|
|
241
|
+
const cwd = process.cwd();
|
|
242
|
+
let pm = "npm";
|
|
243
|
+
if (existsSync(join(cwd, "pnpm-lock.yaml")))
|
|
244
|
+
pm = "pnpm";
|
|
245
|
+
else if (existsSync(join(cwd, "yarn.lock")))
|
|
246
|
+
pm = "yarn";
|
|
247
|
+
else if (existsSync(join(cwd, "bun.lockb")))
|
|
248
|
+
pm = "bun";
|
|
249
|
+
const installCmd = pm === "npm" ? `${pm} install` : `${pm} add`;
|
|
250
|
+
const cmd = `${installCmd} ${deps.join(" ")}`;
|
|
251
|
+
console.log(`Running: ${cmd}
|
|
252
|
+
`);
|
|
253
|
+
execSync(cmd, { stdio: "inherit", cwd });
|
|
254
|
+
console.log(`
|
|
255
|
+
\u2713 ${renderer} renderer enabled.`);
|
|
256
|
+
}
|
|
257
|
+
const args = process.argv.slice(2);
|
|
258
|
+
const command = args[0];
|
|
259
|
+
if (command === "eject") {
|
|
260
|
+
const templateName = args[1];
|
|
261
|
+
if (!templateName) {
|
|
262
|
+
console.error("Please specify a template name.");
|
|
263
|
+
listTemplates();
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
const cwd = process.cwd();
|
|
267
|
+
const targetDir = existsSync(join(cwd, "app")) ? join(cwd, "app") : cwd;
|
|
268
|
+
ejectTemplate(templateName, targetDir);
|
|
269
|
+
} else if (command === "list") {
|
|
270
|
+
listTemplates();
|
|
271
|
+
} else if (command === "migrate") {
|
|
272
|
+
const version = args[1];
|
|
273
|
+
if (version !== "v6") {
|
|
274
|
+
console.error("Usage: npx nuxt-og-image migrate v6 [--dry-run] [--renderer <satori|chromium|takumi>]");
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
const dryRun = args.includes("--dry-run") || args.includes("-d");
|
|
278
|
+
const skipConfirm = args.includes("--yes") || args.includes("-y");
|
|
279
|
+
const rendererIdx = args.indexOf("--renderer");
|
|
280
|
+
const renderer = rendererIdx !== -1 ? args[rendererIdx + 1] || "satori" : "satori";
|
|
281
|
+
if (!["satori", "chromium", "takumi"].includes(renderer)) {
|
|
282
|
+
console.error(`Invalid renderer: ${renderer}. Must be satori, chromium, or takumi.`);
|
|
283
|
+
process.exit(1);
|
|
284
|
+
}
|
|
285
|
+
console.log("nuxt-og-image v6 Migration\n");
|
|
286
|
+
console.log("This will:");
|
|
287
|
+
console.log(" 1. Rename OgImage components to include renderer suffix (.satori.vue, etc.)");
|
|
288
|
+
console.log(" 2. Update defineOgImage() calls to new component-first API");
|
|
289
|
+
console.log("");
|
|
290
|
+
console.log("\x1B[33m\u26A0 WARNING: This modifies files directly and could break your code.\x1B[0m");
|
|
291
|
+
console.log("\x1B[33m Make sure you have committed or backed up your changes first.\x1B[0m");
|
|
292
|
+
console.log("");
|
|
293
|
+
if (dryRun) {
|
|
294
|
+
console.log("[Dry run mode - no files will be modified]\n");
|
|
295
|
+
migrateV6(true, renderer);
|
|
296
|
+
console.log("");
|
|
297
|
+
migrateDefineOgImageApi(true);
|
|
298
|
+
} else if (skipConfirm) {
|
|
299
|
+
migrateV6(false, renderer);
|
|
300
|
+
console.log("");
|
|
301
|
+
migrateDefineOgImageApi(false);
|
|
302
|
+
} else {
|
|
303
|
+
confirm("Continue with migration?").then((confirmed) => {
|
|
304
|
+
if (!confirmed) {
|
|
305
|
+
console.log("Migration cancelled.");
|
|
306
|
+
process.exit(0);
|
|
307
|
+
}
|
|
308
|
+
console.log("");
|
|
309
|
+
migrateV6(false, renderer);
|
|
310
|
+
console.log("");
|
|
311
|
+
migrateDefineOgImageApi(false);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
} else if (command === "enable") {
|
|
315
|
+
const renderer = args[1];
|
|
316
|
+
if (!renderer) {
|
|
317
|
+
console.error("Usage: npx nuxt-og-image enable <renderer>");
|
|
318
|
+
console.log("Available renderers: satori, chromium, takumi");
|
|
319
|
+
process.exit(1);
|
|
320
|
+
}
|
|
321
|
+
enableRenderer(renderer);
|
|
322
|
+
} else {
|
|
323
|
+
console.log("nuxt-og-image CLI\n");
|
|
324
|
+
console.log("Commands:");
|
|
325
|
+
console.log(" list List available community templates");
|
|
326
|
+
console.log(" eject <name> Eject a community template to your project");
|
|
327
|
+
console.log(" migrate v6 Migrate to v6 (component suffixes + new API)");
|
|
328
|
+
console.log(" Options: --dry-run, --renderer <satori|chromium|takumi>");
|
|
329
|
+
console.log(" enable <renderer> Install dependencies for a renderer (satori, chromium, takumi)");
|
|
330
|
+
}
|
package/dist/client/200.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.
|
|
1
|
+
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script type="importmap">{"imports":{"#entry":"/__nuxt-og-image/_nuxt/DXObZt09.js"}}</script><link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.BEExJd9R.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/DXObZt09.js"><link rel="preload" as="font" crossorigin href="/__nuxt-og-image/fonts/HubotSans-Regular.woff2"><script type="module" src="/__nuxt-og-image/_nuxt/DXObZt09.js" crossorigin></script><script>"use strict";(()=>{const t=window,e=document.documentElement,c=["dark","light"],n=getStorageValue("localStorage","nuxt-color-mode")||"system";let i=n==="system"?u():n;const r=e.getAttribute("data-color-mode-forced");r&&(i=r),l(i),t["__NUXT_COLOR_MODE__"]={preference:n,value:i,getColorScheme:u,addColorScheme:l,removeColorScheme:d};function l(o){const s=""+o+"",a="";e.classList?e.classList.add(s):e.className+=" "+s,a&&e.setAttribute("data-"+a,o)}function d(o){const s=""+o+"",a="";e.classList?e.classList.remove(s):e.className=e.className.replace(new RegExp(s,"g"),""),a&&e.removeAttribute("data-"+a)}function f(o){return t.matchMedia("(prefers-color-scheme"+o+")")}function u(){if(t.matchMedia&&f("").media!=="not all"){for(const o of c)if(f(":"+o).matches)return o}return"light"}})();function getStorageValue(t,e){switch(t){case"localStorage":return window.localStorage.getItem(e);case"sessionStorage":return window.sessionStorage.getItem(e);case"cookie":return getCookie(e);default:return null}}function getCookie(t){const c=("; "+window.document.cookie).split("; "+t+"=");if(c.length===2)return c.pop()?.split(";").shift()}</script></head><body><div id="__nuxt" class="isolate"></div><div id="teleports"></div><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-og-image",buildId:"5205806b-8e5a-41ea-90c0-9cd83a75fc0a",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1769156794534,false]</script></body></html>
|