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/README.md CHANGED
@@ -28,7 +28,7 @@ need this module.
28
28
 
29
29
  - ✨ Create an `og:image` using the built-in templates or make your own with Vue components
30
30
  - 🎨 Design and test your `og:image` in the Nuxt DevTools OG Image Playground with full HMR
31
- - ▲ Render using [Satori](https://github.com/vercel/satori): Tailwind / UnoCSS with your theme, Google fonts, 6 emoji families supported and more!
31
+ - ▲ Render using [Satori](https://github.com/vercel/satori) or [Takumi](https://github.com/kane50613/takumi): Tailwind / UnoCSS with your theme, Google fonts, 6 emoji families and more!
32
32
  - 🤖 Or prerender using the Browser: Supporting painless, complex templates
33
33
  - 📸 Feeling lazy? Just generate screenshots for every page: hide elements, wait for animations, and more
34
34
  - ⚙️ Works on the edge: Vercel Edge, Netlify Edge and Cloudflare Workers
package/bin/cli.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('../dist/cli.mjs')
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ const promises = require('node:fs/promises');
4
+ const compilerSfc = require('@vue/compiler-sfc');
5
+ const tinyglobby = require('tinyglobby');
6
+ const module$1 = require('../shared/nuxt-og-image.iluFGbPR.cjs');
7
+ require('node:fs');
8
+ require('@nuxt/kit');
9
+ require('defu');
10
+ require('jiti');
11
+ require('nuxt-site-config/kit');
12
+ require('ohash');
13
+ require('pathe');
14
+ require('pkg-types');
15
+ require('std-env');
16
+ require('node:crypto');
17
+ require('nypm');
18
+ require('../../dist/runtime/logger.js');
19
+ require('chrome-launcher');
20
+ require('node:path');
21
+ require('@nuxt/devtools-kit');
22
+ require('node:url');
23
+ require('magic-string');
24
+ require('strip-literal');
25
+ require('ufo');
26
+ require('unplugin');
27
+ require('postcss');
28
+ require('postcss-calc');
29
+ require('tailwindcss');
30
+ require('culori');
31
+ require('exsolve');
32
+ require('tailwindcss/colors');
33
+ require('../../dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js');
34
+ require('magicast');
35
+ require('magicast/helpers');
36
+
37
+ const ELEMENT_NODE = 1;
38
+ const ATTRIBUTE_NODE = 6;
39
+ const DIRECTIVE_NODE = 7;
40
+ function extractClassesFromVue(code) {
41
+ const { descriptor } = compilerSfc.parse(code);
42
+ if (!descriptor.template?.ast)
43
+ return [];
44
+ const classes = [];
45
+ module$1.walkTemplateAst(descriptor.template.ast.children, (node) => {
46
+ if (node.type !== ELEMENT_NODE)
47
+ return;
48
+ const el = node;
49
+ for (const prop of el.props) {
50
+ if (prop.type === ATTRIBUTE_NODE && prop.name === "class" && prop.value) {
51
+ for (const cls of prop.value.content.split(/\s+/)) {
52
+ if (cls && !cls.includes("{") && !cls.includes("$"))
53
+ classes.push(cls);
54
+ }
55
+ }
56
+ if (prop.type === DIRECTIVE_NODE && prop.name === "bind" && prop.arg?.type === 4 && prop.arg.content === "class") {
57
+ const expr = prop.exp;
58
+ if (expr?.type === 4) {
59
+ const content = expr.content;
60
+ extractClassesFromExpression(content, classes);
61
+ }
62
+ }
63
+ }
64
+ });
65
+ return classes;
66
+ }
67
+ function extractClassesFromExpression(expr, classes) {
68
+ for (const match of expr.matchAll(/['"`]([\w:.\-/]+)['"`]/g)) {
69
+ const cls = match[1];
70
+ if (cls && !cls.includes("{") && !cls.includes("$") && !cls.includes("/"))
71
+ classes.push(cls);
72
+ }
73
+ }
74
+ async function scanComponentClasses(componentDirs, srcDir, logger) {
75
+ const classes = /* @__PURE__ */ new Set();
76
+ const patterns = componentDirs.map((dir) => `**/${dir}/**/*.vue`);
77
+ const files = await tinyglobby.glob(patterns, {
78
+ cwd: srcDir,
79
+ absolute: true,
80
+ ignore: ["**/node_modules/**"]
81
+ });
82
+ for (const file of files) {
83
+ logger?.debug(`TW4: Scanning component ${file}`);
84
+ }
85
+ const contents = await Promise.all(
86
+ files.map((file) => promises.readFile(file, "utf-8").catch(() => null))
87
+ );
88
+ for (const content of contents) {
89
+ if (!content)
90
+ continue;
91
+ for (const cls of extractClassesFromVue(content))
92
+ classes.add(cls);
93
+ }
94
+ return classes;
95
+ }
96
+ function filterProcessableClasses(classes) {
97
+ const processable = [];
98
+ const responsivePrefixes = ["sm:", "md:", "lg:", "xl:", "2xl:"];
99
+ for (const cls of classes) {
100
+ if (responsivePrefixes.some((p) => cls.startsWith(p))) {
101
+ const baseClass = cls.replace(/^(sm|md|lg|xl|2xl):/, "");
102
+ if (baseClass)
103
+ processable.push(baseClass);
104
+ continue;
105
+ }
106
+ if (cls.includes("hover:") || cls.includes("focus:") || cls.includes("active:"))
107
+ continue;
108
+ if (cls.startsWith("dark:"))
109
+ continue;
110
+ processable.push(cls);
111
+ }
112
+ return [...new Set(processable)];
113
+ }
114
+
115
+ exports.filterProcessableClasses = filterProcessableClasses;
116
+ exports.scanComponentClasses = scanComponentClasses;
@@ -0,0 +1,113 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { parse } from '@vue/compiler-sfc';
3
+ import { glob } from 'tinyglobby';
4
+ import { w as walkTemplateAst } from '../shared/nuxt-og-image.D-QhzI76.mjs';
5
+ import 'node:fs';
6
+ import '@nuxt/kit';
7
+ import 'defu';
8
+ import 'jiti';
9
+ import 'nuxt-site-config/kit';
10
+ import 'ohash';
11
+ import 'pathe';
12
+ import 'pkg-types';
13
+ import 'std-env';
14
+ import 'node:crypto';
15
+ import 'nypm';
16
+ import '../../dist/runtime/logger.js';
17
+ import 'chrome-launcher';
18
+ import 'node:path';
19
+ import '@nuxt/devtools-kit';
20
+ import 'node:url';
21
+ import 'magic-string';
22
+ import 'strip-literal';
23
+ import 'ufo';
24
+ import 'unplugin';
25
+ import 'postcss';
26
+ import 'postcss-calc';
27
+ import 'tailwindcss';
28
+ import 'culori';
29
+ import 'exsolve';
30
+ import 'tailwindcss/colors';
31
+ import '../../dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js';
32
+ import 'magicast';
33
+ import 'magicast/helpers';
34
+
35
+ const ELEMENT_NODE = 1;
36
+ const ATTRIBUTE_NODE = 6;
37
+ const DIRECTIVE_NODE = 7;
38
+ function extractClassesFromVue(code) {
39
+ const { descriptor } = parse(code);
40
+ if (!descriptor.template?.ast)
41
+ return [];
42
+ const classes = [];
43
+ walkTemplateAst(descriptor.template.ast.children, (node) => {
44
+ if (node.type !== ELEMENT_NODE)
45
+ return;
46
+ const el = node;
47
+ for (const prop of el.props) {
48
+ if (prop.type === ATTRIBUTE_NODE && prop.name === "class" && prop.value) {
49
+ for (const cls of prop.value.content.split(/\s+/)) {
50
+ if (cls && !cls.includes("{") && !cls.includes("$"))
51
+ classes.push(cls);
52
+ }
53
+ }
54
+ if (prop.type === DIRECTIVE_NODE && prop.name === "bind" && prop.arg?.type === 4 && prop.arg.content === "class") {
55
+ const expr = prop.exp;
56
+ if (expr?.type === 4) {
57
+ const content = expr.content;
58
+ extractClassesFromExpression(content, classes);
59
+ }
60
+ }
61
+ }
62
+ });
63
+ return classes;
64
+ }
65
+ function extractClassesFromExpression(expr, classes) {
66
+ for (const match of expr.matchAll(/['"`]([\w:.\-/]+)['"`]/g)) {
67
+ const cls = match[1];
68
+ if (cls && !cls.includes("{") && !cls.includes("$") && !cls.includes("/"))
69
+ classes.push(cls);
70
+ }
71
+ }
72
+ async function scanComponentClasses(componentDirs, srcDir, logger) {
73
+ const classes = /* @__PURE__ */ new Set();
74
+ const patterns = componentDirs.map((dir) => `**/${dir}/**/*.vue`);
75
+ const files = await glob(patterns, {
76
+ cwd: srcDir,
77
+ absolute: true,
78
+ ignore: ["**/node_modules/**"]
79
+ });
80
+ for (const file of files) {
81
+ logger?.debug(`TW4: Scanning component ${file}`);
82
+ }
83
+ const contents = await Promise.all(
84
+ files.map((file) => readFile(file, "utf-8").catch(() => null))
85
+ );
86
+ for (const content of contents) {
87
+ if (!content)
88
+ continue;
89
+ for (const cls of extractClassesFromVue(content))
90
+ classes.add(cls);
91
+ }
92
+ return classes;
93
+ }
94
+ function filterProcessableClasses(classes) {
95
+ const processable = [];
96
+ const responsivePrefixes = ["sm:", "md:", "lg:", "xl:", "2xl:"];
97
+ for (const cls of classes) {
98
+ if (responsivePrefixes.some((p) => cls.startsWith(p))) {
99
+ const baseClass = cls.replace(/^(sm|md|lg|xl|2xl):/, "");
100
+ if (baseClass)
101
+ processable.push(baseClass);
102
+ continue;
103
+ }
104
+ if (cls.includes("hover:") || cls.includes("focus:") || cls.includes("active:"))
105
+ continue;
106
+ if (cls.startsWith("dark:"))
107
+ continue;
108
+ processable.push(cls);
109
+ }
110
+ return [...new Set(processable)];
111
+ }
112
+
113
+ export { filterProcessableClasses, scanComponentClasses };
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ const promises = require('node:fs/promises');
4
+ const pathe = require('pathe');
5
+ const postcss = require('postcss');
6
+ const postcssCalc = require('postcss-calc');
7
+ const postcssCustomProperties = require('postcss-custom-properties');
8
+ const tailwindcss = require('tailwindcss');
9
+ const module$1 = require('../shared/nuxt-og-image.iluFGbPR.cjs');
10
+ require('node:fs');
11
+ require('@nuxt/kit');
12
+ require('defu');
13
+ require('jiti');
14
+ require('nuxt-site-config/kit');
15
+ require('ohash');
16
+ require('pkg-types');
17
+ require('std-env');
18
+ require('node:crypto');
19
+ require('nypm');
20
+ require('../../dist/runtime/logger.js');
21
+ require('chrome-launcher');
22
+ require('node:path');
23
+ require('@nuxt/devtools-kit');
24
+ require('node:url');
25
+ require('magic-string');
26
+ require('strip-literal');
27
+ require('ufo');
28
+ require('unplugin');
29
+ require('culori');
30
+ require('exsolve');
31
+ require('tailwindcss/colors');
32
+ require('../../dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js');
33
+ require('@vue/compiler-sfc');
34
+ require('magicast');
35
+ require('magicast/helpers');
36
+
37
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
38
+
39
+ const postcss__default = /*#__PURE__*/_interopDefaultCompat(postcss);
40
+ const postcssCalc__default = /*#__PURE__*/_interopDefaultCompat(postcssCalc);
41
+ const postcssCustomProperties__default = /*#__PURE__*/_interopDefaultCompat(postcssCustomProperties);
42
+
43
+ function buildVarsCSS(vars, nuxtUiColors) {
44
+ if (nuxtUiColors)
45
+ module$1.buildNuxtUiVars(vars, nuxtUiColors);
46
+ const lines = [":root {"];
47
+ for (const [name, value] of vars) {
48
+ lines.push(` ${name}: ${value};`);
49
+ }
50
+ lines.push("}");
51
+ return lines.join("\n");
52
+ }
53
+ function extractVars(css) {
54
+ const vars = /* @__PURE__ */ new Map();
55
+ const root = postcss__default.parse(css);
56
+ root.walkDecls((decl) => {
57
+ if (decl.prop.startsWith("--")) {
58
+ vars.set(decl.prop, decl.value);
59
+ }
60
+ });
61
+ return vars;
62
+ }
63
+ function parseClassStyles(css) {
64
+ const classMap = /* @__PURE__ */ new Map();
65
+ const root = postcss__default.parse(css);
66
+ root.walkRules((rule) => {
67
+ const selector = rule.selector;
68
+ if (!selector.startsWith("."))
69
+ return;
70
+ const className = module$1.decodeCssClassName(selector);
71
+ if (className.includes(":") && !className.match(/^[\w-]+$/))
72
+ return;
73
+ if (className.includes(" ") || className.includes(">") || className.includes("+"))
74
+ return;
75
+ const styles = classMap.get(className) || {};
76
+ rule.walkDecls((decl) => {
77
+ if (decl.prop.startsWith("--"))
78
+ return;
79
+ const camelProp = decl.prop.replace(/-([a-z])/g, (_, l) => l.toUpperCase());
80
+ styles[camelProp] = decl.value;
81
+ });
82
+ if (Object.keys(styles).length > 0) {
83
+ classMap.set(className, styles);
84
+ }
85
+ });
86
+ return classMap;
87
+ }
88
+ async function generateStyleMap(options) {
89
+ const { cssPath, classes, nuxtUiColors } = options;
90
+ if (classes.length === 0) {
91
+ return { classes: /* @__PURE__ */ new Map(), vars: /* @__PURE__ */ new Map() };
92
+ }
93
+ const cssContent = await promises.readFile(cssPath, "utf-8");
94
+ const baseDir = pathe.dirname(cssPath);
95
+ const compiler = await tailwindcss.compile(cssContent, {
96
+ base: baseDir,
97
+ loadStylesheet: module$1.createStylesheetLoader(baseDir)
98
+ });
99
+ const rawCSS = compiler.build(classes);
100
+ const vars = extractVars(rawCSS);
101
+ const varsCSS = buildVarsCSS(vars, nuxtUiColors);
102
+ const fullCSS = `${varsCSS}
103
+ ${rawCSS}`;
104
+ const result = await postcss__default([
105
+ postcssCustomProperties__default({
106
+ preserve: false
107
+ // Remove var() after resolving
108
+ }),
109
+ postcssCalc__default({})
110
+ // Evaluate calc() expressions
111
+ ]).process(fullCSS, { from: void 0 });
112
+ const resolvedCSS = result.css;
113
+ const hexCSS = module$1.convertOklchToHex(resolvedCSS);
114
+ const classMap = parseClassStyles(hexCSS);
115
+ return { classes: classMap, vars };
116
+ }
117
+
118
+ exports.generateStyleMap = generateStyleMap;
@@ -0,0 +1,110 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { dirname } from 'pathe';
3
+ import postcss from 'postcss';
4
+ import postcssCalc from 'postcss-calc';
5
+ import postcssCustomProperties from 'postcss-custom-properties';
6
+ import { compile } from 'tailwindcss';
7
+ import { c as createStylesheetLoader, a as convertOklchToHex, b as buildNuxtUiVars, d as decodeCssClassName } from '../shared/nuxt-og-image.D-QhzI76.mjs';
8
+ import 'node:fs';
9
+ import '@nuxt/kit';
10
+ import 'defu';
11
+ import 'jiti';
12
+ import 'nuxt-site-config/kit';
13
+ import 'ohash';
14
+ import 'pkg-types';
15
+ import 'std-env';
16
+ import 'node:crypto';
17
+ import 'nypm';
18
+ import '../../dist/runtime/logger.js';
19
+ import 'chrome-launcher';
20
+ import 'node:path';
21
+ import '@nuxt/devtools-kit';
22
+ import 'node:url';
23
+ import 'magic-string';
24
+ import 'strip-literal';
25
+ import 'ufo';
26
+ import 'unplugin';
27
+ import 'culori';
28
+ import 'exsolve';
29
+ import 'tailwindcss/colors';
30
+ import '../../dist/runtime/server/og-image/satori/transforms/emojis/emoji-utils.js';
31
+ import '@vue/compiler-sfc';
32
+ import 'magicast';
33
+ import 'magicast/helpers';
34
+
35
+ function buildVarsCSS(vars, nuxtUiColors) {
36
+ if (nuxtUiColors)
37
+ buildNuxtUiVars(vars, nuxtUiColors);
38
+ const lines = [":root {"];
39
+ for (const [name, value] of vars) {
40
+ lines.push(` ${name}: ${value};`);
41
+ }
42
+ lines.push("}");
43
+ return lines.join("\n");
44
+ }
45
+ function extractVars(css) {
46
+ const vars = /* @__PURE__ */ new Map();
47
+ const root = postcss.parse(css);
48
+ root.walkDecls((decl) => {
49
+ if (decl.prop.startsWith("--")) {
50
+ vars.set(decl.prop, decl.value);
51
+ }
52
+ });
53
+ return vars;
54
+ }
55
+ function parseClassStyles(css) {
56
+ const classMap = /* @__PURE__ */ new Map();
57
+ const root = postcss.parse(css);
58
+ root.walkRules((rule) => {
59
+ const selector = rule.selector;
60
+ if (!selector.startsWith("."))
61
+ return;
62
+ const className = decodeCssClassName(selector);
63
+ if (className.includes(":") && !className.match(/^[\w-]+$/))
64
+ return;
65
+ if (className.includes(" ") || className.includes(">") || className.includes("+"))
66
+ return;
67
+ const styles = classMap.get(className) || {};
68
+ rule.walkDecls((decl) => {
69
+ if (decl.prop.startsWith("--"))
70
+ return;
71
+ const camelProp = decl.prop.replace(/-([a-z])/g, (_, l) => l.toUpperCase());
72
+ styles[camelProp] = decl.value;
73
+ });
74
+ if (Object.keys(styles).length > 0) {
75
+ classMap.set(className, styles);
76
+ }
77
+ });
78
+ return classMap;
79
+ }
80
+ async function generateStyleMap(options) {
81
+ const { cssPath, classes, nuxtUiColors } = options;
82
+ if (classes.length === 0) {
83
+ return { classes: /* @__PURE__ */ new Map(), vars: /* @__PURE__ */ new Map() };
84
+ }
85
+ const cssContent = await readFile(cssPath, "utf-8");
86
+ const baseDir = dirname(cssPath);
87
+ const compiler = await compile(cssContent, {
88
+ base: baseDir,
89
+ loadStylesheet: createStylesheetLoader(baseDir)
90
+ });
91
+ const rawCSS = compiler.build(classes);
92
+ const vars = extractVars(rawCSS);
93
+ const varsCSS = buildVarsCSS(vars, nuxtUiColors);
94
+ const fullCSS = `${varsCSS}
95
+ ${rawCSS}`;
96
+ const result = await postcss([
97
+ postcssCustomProperties({
98
+ preserve: false
99
+ // Remove var() after resolving
100
+ }),
101
+ postcssCalc({})
102
+ // Evaluate calc() expressions
103
+ ]).process(fullCSS, { from: void 0 });
104
+ const resolvedCSS = result.css;
105
+ const hexCSS = convertOklchToHex(resolvedCSS);
106
+ const classMap = parseClassStyles(hexCSS);
107
+ return { classes: classMap, vars };
108
+ }
109
+
110
+ export { generateStyleMap };