nuxt-og-image 5.1.13 → 6.0.0-beta.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.
Files changed (233) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.mjs +2 -0
  3. package/dist/chunks/tw4-classes.cjs +116 -0
  4. package/dist/chunks/tw4-classes.mjs +113 -0
  5. package/dist/chunks/tw4-generator.cjs +118 -0
  6. package/dist/chunks/tw4-generator.mjs +110 -0
  7. package/dist/cli.cjs +433 -0
  8. package/dist/cli.d.cts +1 -0
  9. package/dist/cli.d.mts +1 -0
  10. package/dist/cli.d.ts +1 -0
  11. package/dist/cli.mjs +416 -0
  12. package/dist/client/200.html +1 -1
  13. package/dist/client/404.html +1 -1
  14. package/dist/client/_fonts/0xp3SbCWC1OhX7q1-uF6kilMZFm-alJNkUtkLTPCy_A-tN9KwPUWhhXvtqh74sU9FIkI4W6hsbm85r0X24hjOfM.woff2 +0 -0
  15. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-D6hedAgqRfOCLZzaShnyeAvlEnMzk4Wm7g9WDKWFHIc.woff +0 -0
  16. package/dist/client/_fonts/4HA9tc4y8BVQeLXvLn3JgQqilAj1xrAnUSprQGHIPSw-ZPswEL_UDOYaxTLQDUySPjoOHDxhD83pD19HMfKfK9s.woff2 +0 -0
  17. package/dist/client/_fonts/Bmul3LaKlc7BUKqJHE_UmEoF40Sg_2ga52yJjwyDcKs-TnYmYl1DNYkiWMu0Vx49DakCPBuiCCj9zoLIuQjUdKY.woff2 +0 -0
  18. package/dist/client/_fonts/DfgmjWGpWte3Q3a54Nevr_BYmMM5YEJXRI1CdI2VwO0-ox5RadQfCyVTmKl_hubTaIJjtRw9oaQz2GDBeZR6l1M.woff2 +0 -0
  19. package/dist/client/_fonts/Lc_5lWuBuZcZ166p1-s-mnGkMJwIYJE_QDCkws8iCkI-r45Qbm2hCykrfOZ0kowz__uTTTUOPDN9hz34QcRNTY4.woff2 +0 -0
  20. package/dist/client/_fonts/iEvApgDRmzKzNqOYocBTrmcHZmuGAJloawKDP1S0nyE-T3oc_9We24QGwfw5naik4cM0g7VxylWVaQwKm4dy3cw.woff2 +0 -0
  21. package/dist/client/_nuxt/0kYTU2a7.js +2 -0
  22. package/dist/client/_nuxt/B0QDx5EE.js +2 -0
  23. package/dist/client/_nuxt/BKqzYw6x.js +3 -0
  24. package/dist/client/_nuxt/C-Ivr2Rl.js +1 -0
  25. package/dist/client/_nuxt/CLgn8DCr.js +1 -0
  26. package/dist/client/_nuxt/CwWm-XE3.js +1 -0
  27. package/dist/client/_nuxt/D9eL2h5z.js +1 -0
  28. package/dist/client/_nuxt/DJXHIJSq.js +1 -0
  29. package/dist/client/_nuxt/DVnX3Z-O.js +1 -0
  30. package/dist/client/_nuxt/DXObZt09.js +184 -0
  31. package/dist/client/_nuxt/Dxi6QG7I.js +1 -0
  32. package/dist/client/_nuxt/E8AZ6HoH.js +1 -0
  33. package/dist/client/_nuxt/IFrameLoader.CGrV1TpP.css +1 -0
  34. package/dist/client/_nuxt/JAMwWy1K.js +3864 -0
  35. package/dist/client/_nuxt/OSectionBlock.BVHnMsIr.css +1 -0
  36. package/dist/client/_nuxt/PONEy9N-.js +1 -0
  37. package/dist/client/_nuxt/UdkqSAsD.js +1 -0
  38. package/dist/client/_nuxt/builds/latest.json +1 -1
  39. package/dist/client/_nuxt/builds/meta/8e2df3bd-1df7-4172-a3c9-b46cdb9070e5.json +1 -0
  40. package/dist/client/_nuxt/entry.BEExJd9R.css +2 -0
  41. package/dist/client/_nuxt/error-404.B79WD2X-.css +1 -0
  42. package/dist/client/_nuxt/error-500.DT3Sd0Wu.css +1 -0
  43. package/dist/client/_nuxt/pages.eW3hi7XF.css +1 -0
  44. package/dist/client/_nuxt/templates.dUiUBaip.css +1 -0
  45. package/dist/client/_payload.json +1 -0
  46. package/dist/client/debug/_payload.json +1 -0
  47. package/dist/client/debug/index.html +1 -0
  48. package/dist/client/docs/_payload.json +1 -0
  49. package/dist/client/docs/index.html +1 -0
  50. package/dist/client/fonts/HubotSans-Regular.woff2 +0 -0
  51. package/dist/client/index.html +1 -1
  52. package/dist/client/templates/_payload.json +1 -0
  53. package/dist/client/templates/index.html +1 -0
  54. package/dist/module.cjs +36 -1027
  55. package/dist/module.d.cts +63 -25
  56. package/dist/module.d.mts +63 -25
  57. package/dist/module.d.ts +63 -25
  58. package/dist/module.json +1 -1
  59. package/dist/module.mjs +32 -1009
  60. package/dist/runtime/app/components/Templates/Community/Brutalist.satori.d.vue.ts +14 -0
  61. package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue +51 -0
  62. package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue.d.ts +14 -0
  63. package/dist/runtime/app/components/Templates/Community/{Frame.vue.d.ts → Frame.satori.d.vue.ts} +2 -2
  64. package/dist/runtime/app/components/Templates/Community/Frame.satori.vue +71 -0
  65. package/dist/runtime/app/components/Templates/Community/{Frame.d.vue.ts → Frame.satori.vue.d.ts} +2 -2
  66. package/dist/runtime/app/components/Templates/Community/Newspaper.satori.d.vue.ts +12 -0
  67. package/dist/runtime/app/components/Templates/Community/Newspaper.satori.vue +70 -0
  68. package/dist/runtime/app/components/Templates/Community/Newspaper.satori.vue.d.ts +12 -0
  69. package/dist/runtime/app/components/Templates/Community/Nuxt.satori.d.vue.ts +12 -0
  70. package/dist/runtime/app/components/Templates/Community/{Nuxt.vue → Nuxt.satori.vue} +3 -3
  71. package/dist/runtime/app/components/Templates/Community/Nuxt.satori.vue.d.ts +12 -0
  72. package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.d.vue.ts +12 -0
  73. package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue +69 -0
  74. package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue.d.ts +12 -0
  75. package/dist/runtime/app/components/Templates/Community/Pergel.satori.d.vue.ts +12 -0
  76. package/dist/runtime/app/components/Templates/Community/{Pergel.vue → Pergel.satori.vue} +14 -11
  77. package/dist/runtime/app/components/Templates/Community/Pergel.satori.vue.d.ts +12 -0
  78. package/dist/runtime/app/components/Templates/Community/Retro.satori.d.vue.ts +12 -0
  79. package/dist/runtime/app/components/Templates/Community/Retro.satori.vue +64 -0
  80. package/dist/runtime/app/components/Templates/Community/Retro.satori.vue.d.ts +12 -0
  81. package/dist/runtime/app/components/Templates/Community/SaaS.satori.d.vue.ts +12 -0
  82. package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue +60 -0
  83. package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue.d.ts +12 -0
  84. package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.d.vue.ts +9 -0
  85. package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue +38 -0
  86. package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue.d.ts +9 -0
  87. package/dist/runtime/app/components/Templates/Community/{UnJs.d.vue.ts → UnJs.satori.d.vue.ts} +2 -2
  88. package/dist/runtime/app/components/Templates/Community/{UnJs.vue → UnJs.satori.vue} +41 -33
  89. package/dist/runtime/app/components/Templates/Community/{UnJs.vue.d.ts → UnJs.satori.vue.d.ts} +2 -2
  90. package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.d.vue.ts +13 -0
  91. package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue +27 -0
  92. package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue.d.ts +13 -0
  93. package/dist/runtime/app/composables/_defineOgImageRaw.d.ts +6 -0
  94. package/dist/runtime/app/composables/_defineOgImageRaw.js +70 -0
  95. package/dist/runtime/app/composables/defineOgImage.d.ts +14 -2
  96. package/dist/runtime/app/composables/defineOgImage.js +13 -42
  97. package/dist/runtime/app/composables/defineOgImageComponent.d.ts +5 -1
  98. package/dist/runtime/app/composables/defineOgImageComponent.js +4 -5
  99. package/dist/runtime/app/composables/defineOgImageScreenshot.d.ts +1 -1
  100. package/dist/runtime/app/composables/defineOgImageScreenshot.js +2 -2
  101. package/dist/runtime/app/composables/mock.d.ts +7 -4
  102. package/dist/runtime/app/composables/mock.js +4 -4
  103. package/dist/runtime/app/utils/plugins.js +22 -28
  104. package/dist/runtime/app/utils.d.ts +15 -1
  105. package/dist/runtime/app/utils.js +74 -46
  106. package/dist/runtime/pure.d.ts +7 -0
  107. package/dist/runtime/pure.js +105 -0
  108. package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.d.ts +3 -2
  109. package/dist/runtime/server/og-image/bindings/css-inline/wasm.d.ts +3 -2
  110. package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.d.ts +3 -0
  111. package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.js +22 -0
  112. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.d.ts +3 -0
  113. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +49 -0
  114. package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +3 -0
  115. package/dist/runtime/server/og-image/bindings/font-assets/node.js +14 -0
  116. package/dist/runtime/server/og-image/bindings/resvg/node-dev.d.ts +5 -0
  117. package/dist/runtime/server/og-image/bindings/resvg/node-dev.js +70 -0
  118. package/dist/runtime/server/og-image/bindings/takumi/node.d.ts +6 -0
  119. package/dist/runtime/server/og-image/bindings/takumi/node.js +5 -0
  120. package/dist/runtime/server/og-image/bindings/takumi/wasm.d.ts +6 -0
  121. package/dist/runtime/server/og-image/bindings/takumi/wasm.js +6 -0
  122. package/dist/runtime/server/og-image/cache/buildCache.d.ts +16 -0
  123. package/dist/runtime/server/og-image/cache/buildCache.js +48 -0
  124. package/dist/runtime/server/og-image/cache/lru.d.ts +2 -2
  125. package/dist/runtime/server/og-image/cache/lru.js +3 -3
  126. package/dist/runtime/server/og-image/cache/mock.d.ts +1 -2
  127. package/dist/runtime/server/og-image/cache/mock.js +0 -1
  128. package/dist/runtime/server/og-image/chromium/screenshot.js +4 -3
  129. package/dist/runtime/server/og-image/context.d.ts +2 -3
  130. package/dist/runtime/server/og-image/context.js +55 -193
  131. package/dist/runtime/server/og-image/devtools.d.ts +10 -0
  132. package/dist/runtime/server/og-image/devtools.js +74 -0
  133. package/dist/runtime/server/og-image/fonts.d.ts +6 -0
  134. package/dist/runtime/server/og-image/fonts.js +41 -0
  135. package/dist/runtime/server/og-image/instances.d.ts +1 -0
  136. package/dist/runtime/server/og-image/instances.js +5 -0
  137. package/dist/runtime/server/og-image/satori/instances.d.ts +1 -36
  138. package/dist/runtime/server/og-image/satori/plugins/emojis.js +83 -4
  139. package/dist/runtime/server/og-image/satori/plugins/encoding.js +11 -1
  140. package/dist/runtime/server/og-image/satori/plugins/imageSrc.js +5 -1
  141. package/dist/runtime/server/og-image/satori/plugins/twClasses.js +35 -0
  142. package/dist/runtime/server/og-image/satori/renderer.js +16 -53
  143. package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-names-minimal.d.ts +1 -0
  144. package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-names-minimal.js +223 -0
  145. package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.d.ts +45 -0
  146. package/dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js +13 -0
  147. package/dist/runtime/server/og-image/satori/transforms/emojis/fetch.d.ts +6 -0
  148. package/dist/runtime/server/og-image/satori/transforms/emojis/fetch.js +38 -0
  149. package/dist/runtime/server/og-image/satori/transforms/emojis/index.d.ts +7 -0
  150. package/dist/runtime/server/og-image/satori/transforms/emojis/index.js +64 -0
  151. package/dist/runtime/server/og-image/satori/transforms/emojis/local.d.ts +7 -0
  152. package/dist/runtime/server/og-image/satori/transforms/emojis/local.js +32 -0
  153. package/dist/runtime/server/og-image/satori/utils.js +5 -4
  154. package/dist/runtime/server/og-image/satori/vnodes.js +7 -6
  155. package/dist/runtime/server/og-image/takumi/instances.d.ts +1 -0
  156. package/dist/runtime/server/og-image/takumi/instances.js +6 -0
  157. package/dist/runtime/server/og-image/takumi/nodes.d.ts +12 -0
  158. package/dist/runtime/server/og-image/takumi/nodes.js +86 -0
  159. package/dist/runtime/server/og-image/takumi/renderer.d.ts +3 -0
  160. package/dist/runtime/server/og-image/takumi/renderer.js +45 -0
  161. package/dist/runtime/server/og-image/templates/html.js +32 -23
  162. package/dist/runtime/server/plugins/prerender.d.ts +1 -1
  163. package/dist/runtime/server/plugins/prerender.js +17 -7
  164. package/dist/runtime/server/util/auto-eject.d.ts +2 -0
  165. package/dist/runtime/server/util/auto-eject.js +30 -0
  166. package/dist/runtime/server/util/eventHandlers.d.ts +0 -1
  167. package/dist/runtime/server/util/eventHandlers.js +15 -85
  168. package/dist/runtime/server/util/options.d.ts +7 -2
  169. package/dist/runtime/server/util/options.js +40 -6
  170. package/dist/runtime/server/utils.d.ts +6 -2
  171. package/dist/runtime/server/utils.js +12 -8
  172. package/dist/runtime/shared/urlEncoding.d.ts +64 -0
  173. package/dist/runtime/shared/urlEncoding.js +194 -0
  174. package/dist/runtime/shared.d.ts +4 -9
  175. package/dist/runtime/shared.js +31 -50
  176. package/dist/runtime/types.d.ts +71 -25
  177. package/dist/shared/nuxt-og-image.D-QhzI76.mjs +2831 -0
  178. package/dist/shared/nuxt-og-image.iluFGbPR.cjs +2858 -0
  179. package/dist/types.d.mts +2 -0
  180. package/package.json +108 -44
  181. package/types/virtual.d.ts +7 -1
  182. package/dist/client/_nuxt/B3LgXoKV.js +0 -2
  183. package/dist/client/_nuxt/B8PEiB0p.js +0 -1
  184. package/dist/client/_nuxt/CPsbVDfV.js +0 -1
  185. package/dist/client/_nuxt/CVO1_9PV.js +0 -1
  186. package/dist/client/_nuxt/CjQm5wk3.js +0 -4029
  187. package/dist/client/_nuxt/Cp-IABpG.js +0 -1
  188. package/dist/client/_nuxt/D0TMZt8T.js +0 -1
  189. package/dist/client/_nuxt/D0r3Knsf.js +0 -1
  190. package/dist/client/_nuxt/builds/meta/eb2c0390-3125-4af7-b189-e76a7dfe3017.json +0 -1
  191. package/dist/client/_nuxt/entry.cdy4VsCK.css +0 -1
  192. package/dist/client/_nuxt/error-404.Cu4JbXd7.css +0 -1
  193. package/dist/client/_nuxt/error-500.B79uceR7.css +0 -1
  194. package/dist/runtime/app/components/OgImage/OgImage.d.ts +0 -3
  195. package/dist/runtime/app/components/OgImage/OgImage.js +0 -10
  196. package/dist/runtime/app/components/Templates/Community/BrandedLogo.d.vue.ts +0 -13
  197. package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue +0 -22
  198. package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue.d.ts +0 -13
  199. package/dist/runtime/app/components/Templates/Community/Frame.vue +0 -58
  200. package/dist/runtime/app/components/Templates/Community/Nuxt.d.vue.ts +0 -12
  201. package/dist/runtime/app/components/Templates/Community/Nuxt.vue.d.ts +0 -12
  202. package/dist/runtime/app/components/Templates/Community/NuxtSeo.d.vue.ts +0 -15
  203. package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue +0 -103
  204. package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue.d.ts +0 -15
  205. package/dist/runtime/app/components/Templates/Community/Pergel.d.vue.ts +0 -12
  206. package/dist/runtime/app/components/Templates/Community/Pergel.vue.d.ts +0 -12
  207. package/dist/runtime/app/components/Templates/Community/SimpleBlog.d.vue.ts +0 -9
  208. package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue +0 -27
  209. package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue.d.ts +0 -9
  210. package/dist/runtime/app/components/Templates/Community/Wave.d.vue.ts +0 -11
  211. package/dist/runtime/app/components/Templates/Community/Wave.vue +0 -28
  212. package/dist/runtime/app/components/Templates/Community/Wave.vue.d.ts +0 -11
  213. package/dist/runtime/app/components/Templates/Community/WithEmoji.d.vue.ts +0 -13
  214. package/dist/runtime/app/components/Templates/Community/WithEmoji.vue +0 -21
  215. package/dist/runtime/app/components/Templates/Community/WithEmoji.vue.d.ts +0 -13
  216. package/dist/runtime/assets/Inter-normal-400.ttf.base64 +0 -1
  217. package/dist/runtime/assets/Inter-normal-700.ttf.base64 +0 -1
  218. package/dist/runtime/server/og-image/satori/font.d.ts +0 -3
  219. package/dist/runtime/server/og-image/satori/font.js +0 -40
  220. package/dist/runtime/server/og-image/satori/plugins/unocss.js +0 -55
  221. package/dist/runtime/server/og-image/satori/transforms/emojis.d.ts +0 -3
  222. package/dist/runtime/server/og-image/satori/transforms/emojis.js +0 -3595
  223. package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.d.ts +0 -2
  224. package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.js +0 -9
  225. package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +0 -2
  226. package/dist/runtime/server/plugins/nuxt-content-v2.js +0 -5
  227. package/dist/runtime/server/routes/__zero-runtime/font.d.ts +0 -2
  228. package/dist/runtime/server/routes/__zero-runtime/font.js +0 -8
  229. package/dist/runtime/server/routes/font.d.ts +0 -2
  230. package/dist/runtime/server/routes/font.js +0 -3
  231. package/dist/runtime/server/util/plugins.d.ts +0 -2
  232. package/dist/runtime/server/util/plugins.js +0 -56
  233. /package/dist/runtime/server/og-image/satori/plugins/{unocss.d.ts → twClasses.d.ts} +0 -0
package/dist/cli.cjs ADDED
@@ -0,0 +1,433 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const node_path = require('node:path');
6
+ const node_url = require('node:url');
7
+ const p = require('@clack/prompts');
8
+ const magicast = require('magicast');
9
+ const nypm = require('nypm');
10
+
11
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
+ function _interopNamespaceCompat(e) {
13
+ if (e && typeof e === 'object' && 'default' in e) return e;
14
+ const n = Object.create(null);
15
+ if (e) {
16
+ for (const k in e) {
17
+ n[k] = e[k];
18
+ }
19
+ }
20
+ n.default = e;
21
+ return n;
22
+ }
23
+
24
+ const p__namespace = /*#__PURE__*/_interopNamespaceCompat(p);
25
+
26
+ 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))));
27
+ const communityDir = node_path.resolve(__dirname$1, "runtime/app/components/Templates/Community");
28
+ const defaultComponentDirs = ["OgImage", "OgImageCommunity", "og-image", "OgImageTemplate"];
29
+ const RENDERERS = [
30
+ {
31
+ name: "satori",
32
+ label: "Satori",
33
+ description: "SVG-based renderer - fast, works everywhere (recommended)",
34
+ deps: ["satori", "@resvg/resvg-js"]
35
+ },
36
+ {
37
+ name: "takumi",
38
+ label: "Takumi",
39
+ description: "Rust-based high-performance renderer",
40
+ deps: ["@takumi-rs/core"]
41
+ },
42
+ {
43
+ name: "chromium",
44
+ label: "Chromium",
45
+ description: "Browser screenshot renderer - pixel-perfect but slower",
46
+ deps: ["playwright-core"]
47
+ }
48
+ ];
49
+ function getBaseName(filename) {
50
+ return filename.replace(/\.(satori|chromium|takumi)\.vue$/, "");
51
+ }
52
+ function hasRendererSuffix(filename) {
53
+ return /\.(?:satori|chromium|takumi)\.vue$/.test(filename);
54
+ }
55
+ function listTemplates() {
56
+ const templates = fs.readdirSync(communityDir).filter((f) => f.endsWith(".vue")).map(getBaseName);
57
+ console.log("\nAvailable community templates:");
58
+ templates.forEach((t) => console.log(` - ${t}`));
59
+ console.log("\nUsage: npx nuxt-og-image eject <template-name>\n");
60
+ }
61
+ function findTemplateFile(name) {
62
+ const files = fs.readdirSync(communityDir).filter((f) => f.endsWith(".vue"));
63
+ const match = files.find((f) => getBaseName(f) === name);
64
+ return match || null;
65
+ }
66
+ function ejectTemplate(name, targetDir) {
67
+ const templateFile = findTemplateFile(name);
68
+ if (!templateFile) {
69
+ p__namespace.log.error(`Template "${name}" not found.`);
70
+ listTemplates();
71
+ process.exit(1);
72
+ }
73
+ const templatePath = node_path.join(communityDir, templateFile);
74
+ const outputDir = node_path.resolve(targetDir, "components", "OgImage");
75
+ if (!fs.existsSync(outputDir))
76
+ fs.mkdirSync(outputDir, { recursive: true });
77
+ const outputPath = node_path.join(outputDir, templateFile);
78
+ if (fs.existsSync(outputPath)) {
79
+ p__namespace.log.error(`File already exists: ${outputPath}`);
80
+ process.exit(1);
81
+ }
82
+ const content = fs.readFileSync(templatePath, "utf-8");
83
+ fs.writeFileSync(outputPath, content, "utf-8");
84
+ p__namespace.log.success(`Ejected "${name}" to ${outputPath}`);
85
+ }
86
+ function findOgImageComponents(dir) {
87
+ const components = [];
88
+ for (const componentDir of defaultComponentDirs) {
89
+ const ogImageDir = node_path.join(dir, "components", componentDir);
90
+ if (fs.existsSync(ogImageDir)) {
91
+ const files = fs.readdirSync(ogImageDir, { withFileTypes: true });
92
+ for (const file of files) {
93
+ if (file.isFile() && file.name.endsWith(".vue"))
94
+ components.push(node_path.join(ogImageDir, file.name));
95
+ }
96
+ }
97
+ }
98
+ return components;
99
+ }
100
+ function globFiles(dir, pattern, exclude = []) {
101
+ const results = [];
102
+ function walk(currentDir) {
103
+ if (!fs.existsSync(currentDir))
104
+ return;
105
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
106
+ for (const entry of entries) {
107
+ const fullPath = node_path.join(currentDir, entry.name);
108
+ if (exclude.some((re) => re.test(fullPath)))
109
+ continue;
110
+ if (entry.isDirectory()) {
111
+ walk(fullPath);
112
+ } else if (entry.isFile() && pattern.test(entry.name)) {
113
+ results.push(fullPath);
114
+ }
115
+ }
116
+ }
117
+ walk(dir);
118
+ return results;
119
+ }
120
+ async function checkNuxtConfig(rootDir) {
121
+ const configPaths = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
122
+ let configPath = null;
123
+ for (const _p of configPaths) {
124
+ const fullPath = node_path.join(rootDir, _p);
125
+ if (fs.existsSync(fullPath)) {
126
+ configPath = fullPath;
127
+ break;
128
+ }
129
+ }
130
+ if (!configPath)
131
+ return { hasDeprecatedFonts: false, hasNuxtFonts: false, configPath: null };
132
+ const mod = await magicast.loadFile(configPath).catch(() => null);
133
+ if (!mod)
134
+ return { hasDeprecatedFonts: false, hasNuxtFonts: false, configPath };
135
+ const config = mod.exports.default;
136
+ const hasDeprecatedFonts = !!config?.ogImage?.fonts;
137
+ const modules = config?.modules || [];
138
+ const hasNuxtFonts = modules.some(
139
+ (m) => typeof m === "string" && m === "@nuxt/fonts" || Array.isArray(m) && m[0] === "@nuxt/fonts"
140
+ );
141
+ return { hasDeprecatedFonts, hasNuxtFonts, configPath };
142
+ }
143
+ async function checkMigrationNeeded(rootDir) {
144
+ const result = {
145
+ needsComponentRename: false,
146
+ needsFontsMigration: false,
147
+ needsNuxtFonts: false,
148
+ componentsToRename: []
149
+ };
150
+ const dirs = [rootDir];
151
+ if (fs.existsSync(node_path.join(rootDir, "app")))
152
+ dirs.push(node_path.join(rootDir, "app"));
153
+ const layersDir = node_path.join(rootDir, "layers");
154
+ if (fs.existsSync(layersDir)) {
155
+ const layerDirs = fs.readdirSync(layersDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => node_path.join(layersDir, d.name));
156
+ dirs.push(...layerDirs);
157
+ }
158
+ for (const dir of dirs) {
159
+ const components = findOgImageComponents(dir);
160
+ for (const filepath of components) {
161
+ const filename = filepath.split("/").pop();
162
+ if (!hasRendererSuffix(filename)) {
163
+ result.componentsToRename.push({ from: filepath, to: "" });
164
+ }
165
+ }
166
+ }
167
+ result.needsComponentRename = result.componentsToRename.length > 0;
168
+ const configCheck = await checkNuxtConfig(rootDir);
169
+ result.needsFontsMigration = configCheck.hasDeprecatedFonts;
170
+ result.needsNuxtFonts = !configCheck.hasNuxtFonts;
171
+ return result;
172
+ }
173
+ function migrateDefineOgImageApi(dryRun) {
174
+ const cwd = process.cwd();
175
+ const excludePatterns = [/node_modules/, /\.nuxt/, /\.output/, /dist/];
176
+ const files = globFiles(cwd, /\.(?:vue|ts|tsx|js|jsx)$/, excludePatterns);
177
+ const changes = [];
178
+ for (const file of files) {
179
+ let content = fs.readFileSync(file, "utf-8");
180
+ let modified = false;
181
+ let changeCount = 0;
182
+ if (/defineOgImageComponent\s*\(/.test(content)) {
183
+ content = content.replace(/defineOgImageComponent\s*\(/g, "defineOgImage(");
184
+ modified = true;
185
+ changeCount++;
186
+ }
187
+ const defineOgImageRegex = /defineOgImage\s*\(\s*(\{[\s\S]*?\})\s*\)/g;
188
+ content = content.replace(defineOgImageRegex, (match, inner) => {
189
+ const componentMatch = inner.match(/component\s*:\s*['"]([^'"]+)['"]/);
190
+ const rendererMatch = inner.match(/renderer\s*:\s*['"]([^'"]+)['"]/);
191
+ const propsMatch = inner.match(/props\s*:\s*(\{[^}]*\})/);
192
+ if (!componentMatch && rendererMatch && rendererMatch[1] === "chromium") {
193
+ const remaining = inner.replace(/renderer\s*:\s*['"][^'"]+['"]\s*,?\s*/g, "").replace(/,\s*$/, "").trim();
194
+ modified = true;
195
+ changeCount++;
196
+ return remaining ? `defineOgImageScreenshot({ ${remaining} })` : `defineOgImageScreenshot()`;
197
+ }
198
+ if (componentMatch || rendererMatch) {
199
+ const componentName = componentMatch ? componentMatch[1] : "NuxtSeo";
200
+ const props = propsMatch ? propsMatch[1] : "{}";
201
+ const otherOptions = [];
202
+ const lines = inner.split(/,(?![^{]*\})/).map((s) => s.trim());
203
+ for (const line of lines) {
204
+ if (!line)
205
+ continue;
206
+ if (/^component\s*:/.test(line))
207
+ continue;
208
+ if (/^props\s*:/.test(line))
209
+ continue;
210
+ if (/^renderer\s*:/.test(line))
211
+ continue;
212
+ otherOptions.push(line);
213
+ }
214
+ modified = true;
215
+ changeCount++;
216
+ if (otherOptions.length > 0) {
217
+ return `defineOgImage('${componentName}', ${props}, { ${otherOptions.join(", ")} })`;
218
+ }
219
+ return `defineOgImage('${componentName}', ${props})`;
220
+ }
221
+ return match;
222
+ });
223
+ if (modified) {
224
+ changes.push({ file, count: changeCount });
225
+ if (!dryRun) {
226
+ fs.writeFileSync(file, content, "utf-8");
227
+ }
228
+ }
229
+ }
230
+ return { changes };
231
+ }
232
+ function migrateV6Components(componentsToRename, defaultRenderer, dryRun) {
233
+ for (const item of componentsToRename) {
234
+ const filename = item.from.split("/").pop();
235
+ const newName = filename.replace(".vue", `.${defaultRenderer}.vue`);
236
+ item.to = item.from.replace(filename, newName);
237
+ }
238
+ if (dryRun) {
239
+ console.log("\nWould rename:");
240
+ for (const { from, to } of componentsToRename) {
241
+ console.log(` ${from.split("/").pop()} \u2192 ${to.split("/").pop()}`);
242
+ }
243
+ return;
244
+ }
245
+ for (const { from, to } of componentsToRename) {
246
+ fs.renameSync(from, to);
247
+ console.log(`\u2713 Renamed ${from.split("/").pop()}`);
248
+ }
249
+ }
250
+ async function installRendererDeps(renderers) {
251
+ const cwd = process.cwd();
252
+ const pm = await nypm.detectPackageManager(cwd);
253
+ const pmName = pm?.name || "npm";
254
+ const allDeps = [];
255
+ for (const renderer of renderers) {
256
+ const def = RENDERERS.find((r) => r.name === renderer);
257
+ if (def) {
258
+ allDeps.push(...def.deps);
259
+ }
260
+ }
261
+ if (allDeps.length === 0)
262
+ return;
263
+ const spinner = p__namespace.spinner();
264
+ spinner.start(`Installing dependencies with ${pmName}...`);
265
+ for (const dep of allDeps) {
266
+ await nypm.addDependency(dep, { cwd, dev: false }).catch(() => {
267
+ spinner.stop(`Failed to install ${dep}`);
268
+ p__namespace.log.warn(`Run manually: ${pmName} add ${dep}`);
269
+ });
270
+ }
271
+ spinner.stop("Dependencies installed");
272
+ }
273
+ async function installNuxtFonts() {
274
+ const cwd = process.cwd();
275
+ const spinner = p__namespace.spinner();
276
+ spinner.start("Adding @nuxt/fonts module...");
277
+ const { execa } = await import('execa');
278
+ await execa("npx", ["nuxi", "module", "add", "@nuxt/fonts"], { cwd }).then(() => {
279
+ spinner.stop("@nuxt/fonts module added");
280
+ }).catch(() => {
281
+ spinner.stop("Failed to add @nuxt/fonts");
282
+ p__namespace.log.warn("Run manually: npx nuxi module add @nuxt/fonts");
283
+ });
284
+ }
285
+ async function runMigrate(args2) {
286
+ const dryRun = args2.includes("--dry-run") || args2.includes("-d");
287
+ const skipConfirm = args2.includes("--yes") || args2.includes("-y");
288
+ const rendererIdx = args2.indexOf("--renderer");
289
+ const cliRenderer = rendererIdx !== -1 ? args2[rendererIdx + 1] : null;
290
+ if (cliRenderer && !["satori", "chromium", "takumi"].includes(cliRenderer)) {
291
+ console.error(`Invalid renderer: ${cliRenderer}. Must be satori, chromium, or takumi.`);
292
+ process.exit(1);
293
+ }
294
+ p__namespace.intro("nuxt-og-image v6 Migration");
295
+ const cwd = process.cwd();
296
+ const migrationCheck = await checkMigrationNeeded(cwd);
297
+ const noComponentWork = !migrationCheck.needsComponentRename;
298
+ const noFontsWork = !migrationCheck.needsFontsMigration && !migrationCheck.needsNuxtFonts;
299
+ if (noComponentWork && noFontsWork) {
300
+ console.log("\u2713 All OG Image components already have renderer suffixes.");
301
+ p__namespace.outro("Done");
302
+ return;
303
+ }
304
+ const tasks = [];
305
+ if (migrationCheck.needsComponentRename) {
306
+ tasks.push(`Rename ${migrationCheck.componentsToRename.length} component(s) to include renderer suffix`);
307
+ }
308
+ if (migrationCheck.needsFontsMigration) {
309
+ tasks.push("Migrate ogImage.fonts to @nuxt/fonts config");
310
+ }
311
+ if (migrationCheck.needsNuxtFonts) {
312
+ tasks.push("Install @nuxt/fonts module");
313
+ }
314
+ tasks.push("Update defineOgImage() calls to new API");
315
+ p__namespace.note(tasks.map((t) => `\u2022 ${t}`).join("\n"), "Migration tasks");
316
+ if (dryRun) {
317
+ p__namespace.log.warn("[Dry run mode - no changes will be made]");
318
+ }
319
+ let selectedRenderers;
320
+ if (skipConfirm) {
321
+ selectedRenderers = cliRenderer ? [cliRenderer] : ["satori"];
322
+ } else {
323
+ const confirmed = await p__namespace.confirm({
324
+ message: "This will modify files. Continue?",
325
+ initialValue: false
326
+ });
327
+ if (p__namespace.isCancel(confirmed) || !confirmed) {
328
+ p__namespace.cancel("Migration cancelled");
329
+ process.exit(0);
330
+ }
331
+ const rendererSelection = await p__namespace.multiselect({
332
+ message: "Which renderers do you want to use?",
333
+ options: RENDERERS.map((r) => ({
334
+ value: r.name,
335
+ label: r.label,
336
+ hint: r.description
337
+ })),
338
+ initialValues: ["satori"],
339
+ required: true
340
+ });
341
+ if (p__namespace.isCancel(rendererSelection)) {
342
+ p__namespace.cancel("Migration cancelled");
343
+ process.exit(0);
344
+ }
345
+ selectedRenderers = rendererSelection;
346
+ if (!dryRun) {
347
+ const installDeps = await p__namespace.confirm({
348
+ message: "Install renderer dependencies?",
349
+ initialValue: true
350
+ });
351
+ if (!p__namespace.isCancel(installDeps) && installDeps) {
352
+ await installRendererDeps(selectedRenderers);
353
+ }
354
+ }
355
+ }
356
+ if (migrationCheck.needsComponentRename) {
357
+ console.log("\nRenaming components...");
358
+ migrateV6Components(migrationCheck.componentsToRename, selectedRenderers[0] || "satori", dryRun);
359
+ }
360
+ console.log("\nMigrating defineOgImage calls...");
361
+ const apiChanges = migrateDefineOgImageApi(dryRun);
362
+ if (apiChanges.changes.length > 0) {
363
+ for (const { file, count } of apiChanges.changes) {
364
+ const relPath = file.replace(`${cwd}/`, "");
365
+ console.log(` ${relPath} (${count} change${count > 1 ? "s" : ""})`);
366
+ }
367
+ } else {
368
+ console.log(" No API changes needed");
369
+ }
370
+ if (migrationCheck.needsNuxtFonts && !dryRun && !skipConfirm) {
371
+ const addFonts = await p__namespace.confirm({
372
+ message: "@nuxt/fonts is recommended for custom fonts. Add it?",
373
+ initialValue: true
374
+ });
375
+ if (!p__namespace.isCancel(addFonts) && addFonts) {
376
+ await installNuxtFonts();
377
+ }
378
+ }
379
+ if (dryRun) {
380
+ console.log("\n[Dry run - no changes made]");
381
+ console.log("Run without --dry-run to apply changes.");
382
+ }
383
+ p__namespace.outro(dryRun ? "Dry run complete" : "Migration complete!");
384
+ }
385
+ async function runEnable(renderer) {
386
+ const def = RENDERERS.find((r) => r.name === renderer);
387
+ if (!def) {
388
+ p__namespace.log.error(`Unknown renderer: ${renderer}`);
389
+ p__namespace.log.info(`Available: ${RENDERERS.map((r) => r.name).join(", ")}`);
390
+ process.exit(1);
391
+ }
392
+ p__namespace.intro(`Enable ${def.label} renderer`);
393
+ await installRendererDeps([renderer]);
394
+ p__namespace.outro("Done");
395
+ }
396
+ const args = process.argv.slice(2);
397
+ const command = args[0];
398
+ if (command === "eject") {
399
+ const templateName = args[1];
400
+ if (!templateName) {
401
+ p__namespace.log.error("Please specify a template name.");
402
+ listTemplates();
403
+ process.exit(1);
404
+ }
405
+ const cwd = process.cwd();
406
+ const targetDir = fs.existsSync(node_path.join(cwd, "app")) ? node_path.join(cwd, "app") : cwd;
407
+ ejectTemplate(templateName, targetDir);
408
+ } else if (command === "list") {
409
+ listTemplates();
410
+ } else if (command === "migrate") {
411
+ const version = args[1];
412
+ if (version !== "v6") {
413
+ p__namespace.log.error("Usage: npx nuxt-og-image migrate v6 [--dry-run] [--yes] [--renderer <satori|chromium|takumi>]");
414
+ process.exit(1);
415
+ }
416
+ runMigrate(args);
417
+ } else if (command === "enable") {
418
+ const renderer = args[1];
419
+ if (!renderer) {
420
+ p__namespace.log.error("Usage: npx nuxt-og-image enable <renderer>");
421
+ p__namespace.log.info(`Available: ${RENDERERS.map((r) => r.name).join(", ")}`);
422
+ process.exit(1);
423
+ }
424
+ runEnable(renderer);
425
+ } else {
426
+ console.log("nuxt-og-image CLI\n");
427
+ console.log("Commands:");
428
+ console.log(" list List available community templates");
429
+ console.log(" eject <name> Eject a community template to your project");
430
+ console.log(" migrate v6 Migrate to v6 (component suffixes + new API)");
431
+ console.log(" Options: --dry-run, --yes, --renderer <satori|chromium|takumi>");
432
+ console.log(" enable <renderer> Install dependencies for a renderer (satori, chromium, takumi)");
433
+ }
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
+