nuxt-og-image 6.0.0-beta.9 → 6.0.0
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 +10 -4
- package/dist/chunks/css-provider.cjs +108 -0
- package/dist/chunks/css-provider.mjs +102 -0
- package/dist/chunks/tw4.cjs +413 -0
- package/dist/chunks/tw4.mjs +404 -0
- package/dist/chunks/uno.cjs +234 -0
- package/dist/chunks/uno.mjs +228 -0
- package/dist/cli.cjs +395 -76
- package/dist/cli.mjs +381 -62
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/8X6NW5_o.js +181 -0
- package/dist/client/_nuxt/B4AI0zo1.js +3860 -0
- package/dist/client/_nuxt/BBg_LgdD.js +1 -0
- package/dist/client/_nuxt/BSXU-Wzx.js +1 -0
- package/dist/client/_nuxt/BUiggg2R.js +1 -0
- package/dist/client/_nuxt/BWFB7PcA.js +3 -0
- package/dist/client/_nuxt/CAH4zhLz.js +1 -0
- package/dist/client/_nuxt/D2sXT63a.js +1 -0
- package/dist/client/_nuxt/DLWTHHHk.js +2 -0
- package/dist/client/_nuxt/Dkvb1DQl.js +1 -0
- package/dist/client/_nuxt/DoBtCwhp.js +1 -0
- package/dist/client/_nuxt/IFrameLoader.D3_OtGCw.css +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/9d10b447-cded-4d38-a6ff-e768102fc1f3.json +1 -0
- package/dist/client/_nuxt/entry.Ci4bU1tp.css +2 -0
- package/dist/client/_nuxt/error-404.C4vS2Bge.css +1 -0
- package/dist/client/_nuxt/error-500.Y0QISy38.css +1 -0
- package/dist/client/_nuxt/pages.JfmTAseD.css +1 -0
- package/dist/client/_nuxt/templates.DAFgwCzd.css +1 -0
- package/dist/client/_payload.json +1 -1
- package/dist/client/debug/_payload.json +1 -1
- package/dist/client/debug/index.html +1 -1
- package/dist/client/docs/_payload.json +1 -1
- package/dist/client/docs/index.html +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/templates/_payload.json +1 -1
- package/dist/client/templates/index.html +1 -1
- package/dist/module.cjs +11 -10
- package/dist/module.d.cts +16 -21
- package/dist/module.d.mts +16 -21
- package/dist/module.d.ts +16 -21
- package/dist/module.json +1 -1
- package/dist/module.mjs +11 -10
- package/dist/runtime/app/components/Templates/Community/{Newspaper.satori.vue.d.ts → BlogPost.takumi.d.vue.ts} +12 -3
- package/dist/runtime/app/components/Templates/Community/BlogPost.takumi.vue +52 -0
- package/dist/runtime/app/components/Templates/Community/{Retro.satori.d.vue.ts → BlogPost.takumi.vue.d.ts} +11 -2
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue +14 -16
- package/dist/runtime/app/components/Templates/Community/Brutalist.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/Docs.takumi.d.vue.ts +22 -0
- package/dist/runtime/app/components/Templates/Community/Docs.takumi.vue +72 -0
- package/dist/runtime/app/components/Templates/Community/Docs.takumi.vue.d.ts +22 -0
- package/dist/runtime/app/components/Templates/Community/Frame.satori.d.vue.ts +2 -4
- package/dist/runtime/app/components/Templates/Community/Frame.satori.vue +21 -17
- package/dist/runtime/app/components/Templates/Community/Frame.satori.vue.d.ts +2 -4
- package/dist/runtime/app/components/Templates/Community/Nuxt.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/Nuxt.satori.vue +22 -18
- package/dist/runtime/app/components/Templates/Community/Nuxt.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.d.vue.ts +1 -1
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue +11 -12
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.satori.vue.d.ts +1 -1
- package/dist/runtime/app/components/Templates/Community/{Retro.satori.vue.d.ts → NuxtSeo.takumi.d.vue.ts} +8 -4
- package/dist/runtime/app/components/Templates/Community/NuxtSeo.takumi.vue +69 -0
- package/dist/runtime/app/components/Templates/Community/{Newspaper.satori.d.vue.ts → NuxtSeo.takumi.vue.d.ts} +8 -4
- package/dist/runtime/app/components/Templates/Community/Pergel.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/Pergel.satori.vue +6 -63
- package/dist/runtime/app/components/Templates/Community/Pergel.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/ProductCard.takumi.d.vue.ts +20 -0
- package/dist/runtime/app/components/Templates/Community/ProductCard.takumi.vue +63 -0
- package/dist/runtime/app/components/Templates/Community/ProductCard.takumi.vue.d.ts +20 -0
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue +10 -9
- package/dist/runtime/app/components/Templates/Community/SaaS.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue +12 -8
- package/dist/runtime/app/components/Templates/Community/SimpleBlog.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/UnJs.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/UnJs.satori.vue +16 -15
- package/dist/runtime/app/components/Templates/Community/UnJs.satori.vue.d.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.d.vue.ts +2 -0
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue +8 -4
- package/dist/runtime/app/components/Templates/Community/WithEmoji.satori.vue.d.ts +2 -0
- package/dist/runtime/app/composables/_defineOgImageRaw.d.ts +1 -1
- package/dist/runtime/app/composables/_defineOgImageRaw.js +6 -5
- package/dist/runtime/app/composables/defineOgImage.d.ts +4 -4
- package/dist/runtime/app/composables/defineOgImage.js +21 -6
- package/dist/runtime/app/composables/defineOgImageComponent.d.ts +2 -2
- package/dist/runtime/app/composables/defineOgImageComponent.js +2 -1
- package/dist/runtime/app/composables/defineOgImageScreenshot.js +3 -3
- package/dist/runtime/app/composables/mock.d.ts +3 -3
- package/dist/runtime/app/composables/mock.js +4 -3
- package/dist/runtime/app/utils.d.ts +6 -3
- package/dist/runtime/app/utils.js +34 -7
- package/dist/runtime/public/_og-fonts/inter-400-latin.ttf +0 -0
- package/dist/runtime/public/_og-fonts/inter-700-latin.ttf +0 -0
- package/dist/runtime/pure.d.ts +2 -3
- package/dist/runtime/pure.js +16 -49
- package/dist/runtime/server/og-image/bindings/browser/chrome-launcher.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/{chromium → browser}/chrome-launcher.js +1 -1
- package/dist/runtime/server/og-image/bindings/browser/cloudflare.d.ts +10 -0
- package/dist/runtime/server/og-image/bindings/browser/cloudflare.js +52 -0
- package/dist/runtime/server/og-image/bindings/browser/on-demand.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/browser/on-demand.js +32 -0
- package/dist/runtime/server/og-image/bindings/browser/playwright.d.ts +3 -0
- package/dist/runtime/server/og-image/bindings/{chromium → browser}/playwright.js +1 -1
- package/dist/runtime/server/og-image/bindings/font-assets/cloudflare.js +8 -9
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +47 -13
- package/dist/runtime/server/og-image/bindings/resvg/node-dev.js +45 -8
- package/dist/runtime/server/og-image/bindings/resvg/wasm.js +2 -1
- package/dist/runtime/server/og-image/bindings/satori/wasm-fs.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/satori/wasm-fs.js +2 -2
- package/dist/runtime/server/og-image/bindings/satori/wasm.d.ts +1 -1
- package/dist/runtime/server/og-image/bindings/satori/wasm.js +3 -5
- package/dist/runtime/server/og-image/bindings/takumi/node-dev.d.ts +6 -0
- package/dist/runtime/server/og-image/bindings/takumi/node-dev.js +153 -0
- package/dist/runtime/server/og-image/bindings/takumi/node.d.ts +2 -1
- package/dist/runtime/server/og-image/bindings/takumi/node.js +3 -2
- package/dist/runtime/server/og-image/bindings/takumi/wasm.d.ts +2 -1
- package/dist/runtime/server/og-image/bindings/takumi/wasm.js +3 -2
- package/dist/runtime/server/og-image/browser/renderer.d.ts +3 -0
- package/dist/runtime/server/og-image/{chromium → browser}/renderer.js +5 -5
- package/dist/runtime/server/og-image/browser/screenshot.js +115 -0
- package/dist/runtime/server/og-image/cache/buildCache.js +1 -1
- package/dist/runtime/server/og-image/cache/lru.d.ts +11 -2
- package/dist/runtime/server/og-image/cache/lru.js +16 -3
- package/dist/runtime/server/og-image/context.js +12 -11
- package/dist/runtime/server/og-image/core/plugins/encoding.d.ts +2 -0
- package/dist/runtime/server/og-image/{satori → core}/plugins/encoding.js +2 -2
- package/dist/runtime/server/og-image/core/plugins/imageSrc.d.ts +2 -0
- package/dist/runtime/server/og-image/{satori → core}/plugins/imageSrc.js +34 -16
- package/dist/runtime/server/og-image/core/plugins/styleDirectives.d.ts +2 -0
- package/dist/runtime/server/og-image/core/plugins/styleDirectives.js +158 -0
- package/dist/runtime/server/og-image/core/plugins.d.ts +3 -0
- package/dist/runtime/server/og-image/{satori/utils.js → core/plugins.js} +3 -3
- package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/emoji-utils.js +3 -2
- package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/index.js +6 -3
- package/dist/runtime/server/og-image/core/vnodes.d.ts +11 -0
- package/dist/runtime/server/og-image/core/vnodes.js +170 -0
- package/dist/runtime/server/og-image/devtools.d.ts +2 -2
- package/dist/runtime/server/og-image/fonts.d.ts +34 -2
- package/dist/runtime/server/og-image/fonts.js +153 -21
- package/dist/runtime/server/og-image/instances.d.ts +3 -3
- package/dist/runtime/server/og-image/instances.js +6 -6
- package/dist/runtime/server/og-image/satori/instances.d.ts +3 -4
- package/dist/runtime/server/og-image/satori/instances.js +25 -13
- package/dist/runtime/server/og-image/satori/plugins/classes.d.ts +1 -1
- package/dist/runtime/server/og-image/satori/plugins/classes.js +4 -3
- package/dist/runtime/server/og-image/satori/plugins/emojis.d.ts +1 -1
- package/dist/runtime/server/og-image/satori/plugins/emojis.js +8 -49
- package/dist/runtime/server/og-image/satori/plugins/flex.d.ts +1 -1
- package/dist/runtime/server/og-image/satori/plugins/flex.js +9 -21
- package/dist/runtime/server/og-image/satori/plugins/nuxt-icon.d.ts +1 -1
- package/dist/runtime/server/og-image/satori/plugins/nuxt-icon.js +2 -2
- package/dist/runtime/server/og-image/satori/renderer.d.ts +6 -2
- package/dist/runtime/server/og-image/satori/renderer.js +71 -24
- package/dist/runtime/server/og-image/satori/vnodes.d.ts +1 -0
- package/dist/runtime/server/og-image/satori/vnodes.js +9 -86
- package/dist/runtime/server/og-image/takumi/instances.d.ts +2 -1
- package/dist/runtime/server/og-image/takumi/instances.js +8 -2
- package/dist/runtime/server/og-image/takumi/nodes.d.ts +2 -2
- package/dist/runtime/server/og-image/takumi/nodes.js +97 -67
- package/dist/runtime/server/og-image/takumi/renderer.js +79 -28
- package/dist/runtime/server/og-image/takumi/sanitize.d.ts +1 -0
- package/dist/runtime/server/og-image/takumi/sanitize.js +20 -0
- package/dist/runtime/server/og-image/templates/html.js +44 -76
- package/dist/runtime/server/og-image/unicode-range.d.ts +12 -0
- package/dist/runtime/server/og-image/unicode-range.js +64 -0
- package/dist/runtime/server/og-image/utils/css.d.ts +14 -0
- package/dist/runtime/server/og-image/utils/css.js +80 -0
- package/dist/runtime/server/og-image/utils/image-detector.d.ts +8 -0
- package/dist/runtime/server/og-image/utils/image-detector.js +30 -0
- package/dist/runtime/server/plugins/prerender.js +4 -2
- package/dist/runtime/server/routes/debug.json.d.ts +2 -0
- package/dist/runtime/server/routes/debug.json.js +5 -1
- package/dist/runtime/server/util/auto-eject.d.ts +3 -1
- package/dist/runtime/server/util/auto-eject.js +8 -3
- package/dist/runtime/server/util/cache.js +2 -2
- package/dist/runtime/server/util/encoding.js +17 -3
- package/dist/runtime/server/util/eventHandlers.js +25 -8
- package/dist/runtime/server/util/options.d.ts +2 -2
- package/dist/runtime/server/util/options.js +103 -27
- package/dist/runtime/shared/urlEncoding.d.ts +3 -3
- package/dist/runtime/shared/urlEncoding.js +49 -18
- package/dist/runtime/shared.d.ts +1 -2
- package/dist/runtime/shared.js +10 -30
- package/dist/runtime/types.d.ts +55 -30
- package/dist/shared/nuxt-og-image.BYpTHg51.mjs +4904 -0
- package/dist/shared/nuxt-og-image.CJa2KCie.mjs +189 -0
- package/dist/shared/nuxt-og-image.CMYbz66P.cjs +193 -0
- package/dist/shared/nuxt-og-image.Dxgo_zuB.cjs +4935 -0
- package/package.json +65 -69
- package/types/virtual.d.ts +23 -24
- package/dist/chunks/tw4-classes.cjs +0 -114
- package/dist/chunks/tw4-classes.mjs +0 -111
- package/dist/chunks/tw4-generator.cjs +0 -128
- package/dist/chunks/tw4-generator.mjs +0 -126
- package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-995OEiyou9G2dJsMNn9aLuHTFlgwosm_9gD5SQUWR40.woff +0 -0
- package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-D6hedAgqRfOCLZzaShnyeAvlEnMzk4Wm7g9WDKWFHIc.woff +0 -0
- package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-vrK12kZ24WGUghky9YxsOZpLH8Tt4jMU8XIvzgLQ6DU.woff +0 -0
- package/dist/client/_nuxt/BBvImjI6.js +0 -3
- package/dist/client/_nuxt/BMajWU4Q.js +0 -2
- package/dist/client/_nuxt/BUylUlrk.js +0 -1
- package/dist/client/_nuxt/BUzwbfnX.js +0 -1
- package/dist/client/_nuxt/CA8OCsNm.js +0 -3864
- package/dist/client/_nuxt/Ce8yDyoA.js +0 -1
- package/dist/client/_nuxt/CiQnSy_v.js +0 -1
- package/dist/client/_nuxt/Cw_-Nae1.js +0 -184
- package/dist/client/_nuxt/DjZxf_BC.js +0 -1
- package/dist/client/_nuxt/E3Kc5QfQ.js +0 -1
- package/dist/client/_nuxt/IFrameLoader.Dg-moXnW.css +0 -1
- package/dist/client/_nuxt/builds/meta/983ec4d1-f781-4b2a-9e0c-8ce2c1a7325c.json +0 -1
- package/dist/client/_nuxt/entry.B9b3CR8Q.css +0 -2
- package/dist/client/_nuxt/error-404.5HU6rnuR.css +0 -1
- package/dist/client/_nuxt/error-500.CFwtvM7B.css +0 -1
- package/dist/client/_nuxt/pages.-2MlM8jh.css +0 -1
- package/dist/client/_nuxt/templates.DxDxFWm_.css +0 -1
- package/dist/runtime/app/components/OgImage/OgImageScreenshot.d.ts +0 -3
- package/dist/runtime/app/components/OgImage/OgImageScreenshot.js +0 -10
- package/dist/runtime/app/components/Templates/Community/Newspaper.satori.vue +0 -70
- package/dist/runtime/app/components/Templates/Community/Retro.satori.vue +0 -64
- package/dist/runtime/server/og-image/bindings/chromium/chrome-launcher.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/chromium/on-demand.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/chromium/on-demand.js +0 -40
- package/dist/runtime/server/og-image/bindings/chromium/playwright.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/css-inline/node.d.ts +0 -8
- package/dist/runtime/server/og-image/bindings/css-inline/node.js +0 -7
- package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.d.ts +0 -8
- package/dist/runtime/server/og-image/bindings/css-inline/wasm-fs.js +0 -8
- package/dist/runtime/server/og-image/bindings/css-inline/wasm.d.ts +0 -8
- package/dist/runtime/server/og-image/bindings/css-inline/wasm.js +0 -7
- package/dist/runtime/server/og-image/bindings/satori/0-15-wasm.d.ts +0 -6
- package/dist/runtime/server/og-image/bindings/satori/0-15-wasm.js +0 -10
- package/dist/runtime/server/og-image/chromium/renderer.d.ts +0 -3
- package/dist/runtime/server/og-image/chromium/screenshot.js +0 -55
- package/dist/runtime/server/og-image/satori/plugins/encoding.d.ts +0 -2
- package/dist/runtime/server/og-image/satori/plugins/imageSrc.d.ts +0 -2
- package/dist/runtime/server/og-image/satori/plugins/twClasses.d.ts +0 -2
- package/dist/runtime/server/og-image/satori/plugins/twClasses.js +0 -55
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.d.ts +0 -3
- package/dist/runtime/server/og-image/satori/transforms/inlineCss.js +0 -51
- package/dist/runtime/server/og-image/satori/utils.d.ts +0 -3
- package/dist/shared/nuxt-og-image.BApzvntB.mjs +0 -3046
- package/dist/shared/nuxt-og-image.iRmZUmN7.cjs +0 -3071
- /package/dist/client/_nuxt/{0kYTU2a7.js → BPy_hmvs.js} +0 -0
- /package/dist/client/_nuxt/{E8AZ6HoH.js → BZnE4-DX.js} +0 -0
- /package/dist/client/_nuxt/{D9eL2h5z.js → C5vodK0q.js} +0 -0
- /package/dist/client/_nuxt/{PONEy9N-.js → CvTomaKs.js} +0 -0
- /package/dist/client/_nuxt/{DVnX3Z-O.js → Jhg7QtmN.js} +0 -0
- /package/dist/runtime/server/og-image/{chromium → browser}/screenshot.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/emoji-names-minimal.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/emoji-names-minimal.js +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/emoji-utils.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/fetch.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/fetch.js +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/index.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/local.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/local.js +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/noop.d.ts +0 -0
- /package/dist/runtime/server/og-image/{satori → core}/transforms/emojis/noop.js +0 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[![License][license-src]][license-href]
|
|
8
8
|
[![Nuxt][nuxt-src]][nuxt-href]
|
|
9
9
|
|
|
10
|
-
Nuxt OG Image allows you to easily generate OG Images using either Vue components or
|
|
10
|
+
Nuxt OG Image allows you to easily generate OG Images using either Vue components or screenshots of your pages.
|
|
11
11
|
|
|
12
12
|
OG Images are known to improve click-through rates on social media.
|
|
13
13
|
|
|
@@ -28,9 +28,9 @@ 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) or [Takumi](https://github.com/kane50613/takumi): Tailwind / UnoCSS with your theme, Google fonts, 6 emoji families and more
|
|
31
|
+
- ▲ Render using [Satori](https://github.com/vercel/satori) or [Takumi](https://github.com/kane50613/takumi): Tailwind / [UnoCSS](https://unocss.dev) with your theme, Google fonts, 6 emoji families and more.
|
|
32
32
|
- 🤖 Or prerender using the Browser: Supporting painless, complex templates
|
|
33
|
-
- 📸 Feeling lazy?
|
|
33
|
+
- 📸 Feeling lazy? 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
|
|
35
35
|
|
|
36
36
|
## Installation
|
|
@@ -41,6 +41,12 @@ Install `nuxt-og-image` dependency to your project:
|
|
|
41
41
|
npx nuxi@latest module add og-image
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
> [!TIP]
|
|
45
|
+
> Generate an Agent Skill for this package using [skilld](https://github.com/harlan-zw/skilld):
|
|
46
|
+
> ```bash
|
|
47
|
+
> npx skilld add nuxt-og-image
|
|
48
|
+
> ```
|
|
49
|
+
|
|
44
50
|
## Documentation
|
|
45
51
|
|
|
46
52
|
[📖 Read the full documentation](https://nuxtseo.com/og-image/getting-started/installation) for more information.
|
|
@@ -53,7 +59,7 @@ npx nuxi@latest module add og-image
|
|
|
53
59
|
|
|
54
60
|
<p align="center">
|
|
55
61
|
<a href="https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg">
|
|
56
|
-
<img src='https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg'/>
|
|
62
|
+
<img src='https://raw.githubusercontent.com/harlan-zw/static/main/sponsors.svg' alt='Sponsors'/>
|
|
57
63
|
</a>
|
|
58
64
|
</p>
|
|
59
65
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const exsolve = require('exsolve');
|
|
4
|
+
|
|
5
|
+
const VARIANT_PREFIX_RE = /^((?:sm|md|lg|xl|2xl|dark):)(.+)$/;
|
|
6
|
+
const CSS_PROP_TO_UTILITY_PREFIX = {
|
|
7
|
+
"background-color": "bg",
|
|
8
|
+
"color": "text",
|
|
9
|
+
"border-color": "border",
|
|
10
|
+
"font-size": "text",
|
|
11
|
+
"font-weight": "font",
|
|
12
|
+
"line-height": "leading",
|
|
13
|
+
"letter-spacing": "tracking",
|
|
14
|
+
"opacity": "opacity",
|
|
15
|
+
"width": "w",
|
|
16
|
+
"height": "h",
|
|
17
|
+
"max-width": "max-w",
|
|
18
|
+
"max-height": "max-h",
|
|
19
|
+
"min-width": "min-w",
|
|
20
|
+
"min-height": "min-h",
|
|
21
|
+
"border-radius": "rounded",
|
|
22
|
+
"gap": "gap",
|
|
23
|
+
"padding": "p",
|
|
24
|
+
"padding-top": "pt",
|
|
25
|
+
"padding-right": "pr",
|
|
26
|
+
"padding-bottom": "pb",
|
|
27
|
+
"padding-left": "pl",
|
|
28
|
+
"margin": "m",
|
|
29
|
+
"margin-top": "mt",
|
|
30
|
+
"margin-right": "mr",
|
|
31
|
+
"margin-bottom": "mb",
|
|
32
|
+
"margin-left": "ml",
|
|
33
|
+
"display": ""
|
|
34
|
+
};
|
|
35
|
+
function stylesToArbitraryClass(styles) {
|
|
36
|
+
const entries = Object.entries(styles);
|
|
37
|
+
if (entries.length !== 1)
|
|
38
|
+
return void 0;
|
|
39
|
+
const [prop, value] = entries[0];
|
|
40
|
+
if (prop === "display")
|
|
41
|
+
return value === "none" ? "hidden" : value;
|
|
42
|
+
const prefix = CSS_PROP_TO_UTILITY_PREFIX[prop];
|
|
43
|
+
if (!prefix)
|
|
44
|
+
return void 0;
|
|
45
|
+
return `${prefix}-[${value}]`;
|
|
46
|
+
}
|
|
47
|
+
function extractVariantBaseClasses(classes) {
|
|
48
|
+
const baseClasses = /* @__PURE__ */ new Set();
|
|
49
|
+
for (const cls of classes) {
|
|
50
|
+
const m = cls.match(VARIANT_PREFIX_RE);
|
|
51
|
+
if (m?.[2])
|
|
52
|
+
baseClasses.add(m[2]);
|
|
53
|
+
}
|
|
54
|
+
return baseClasses;
|
|
55
|
+
}
|
|
56
|
+
function resolveVariantPrefixes(classes, resolvedStyles) {
|
|
57
|
+
const prefixOverrideProps = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const cls of classes) {
|
|
59
|
+
const prefixMatch = cls.match(VARIANT_PREFIX_RE);
|
|
60
|
+
if (prefixMatch) {
|
|
61
|
+
const baseStyles = resolvedStyles.get(prefixMatch[2]);
|
|
62
|
+
if (baseStyles) {
|
|
63
|
+
for (const prop of Object.keys(baseStyles))
|
|
64
|
+
prefixOverrideProps.add(prop);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const result = {};
|
|
69
|
+
for (const cls of classes) {
|
|
70
|
+
const prefixMatch = cls.match(VARIANT_PREFIX_RE);
|
|
71
|
+
if (prefixMatch) {
|
|
72
|
+
const [, prefix, baseClass] = prefixMatch;
|
|
73
|
+
const baseStyles = resolvedStyles.get(baseClass);
|
|
74
|
+
if (baseStyles) {
|
|
75
|
+
const arbitrary = stylesToArbitraryClass(baseStyles);
|
|
76
|
+
result[cls] = arbitrary ? `${prefix}${arbitrary}` : cls;
|
|
77
|
+
} else {
|
|
78
|
+
result[cls] = cls;
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const styles = resolvedStyles.get(cls);
|
|
83
|
+
if (styles) {
|
|
84
|
+
const hasConflict = Object.keys(styles).some((prop) => prefixOverrideProps.has(prop));
|
|
85
|
+
if (hasConflict) {
|
|
86
|
+
const arbitrary = stylesToArbitraryClass(styles);
|
|
87
|
+
result[cls] = arbitrary || cls;
|
|
88
|
+
} else {
|
|
89
|
+
result[cls] = styles;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
function detectCssProvider(nuxt) {
|
|
96
|
+
const modules = nuxt.options.modules.flat();
|
|
97
|
+
if (modules.some((m) => typeof m === "string" && m.includes("@unocss/nuxt")))
|
|
98
|
+
return "unocss";
|
|
99
|
+
if (exsolve.resolveModulePath("tailwindcss", { from: nuxt.options.rootDir, try: true }))
|
|
100
|
+
return "tailwind";
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.VARIANT_PREFIX_RE = VARIANT_PREFIX_RE;
|
|
105
|
+
exports.detectCssProvider = detectCssProvider;
|
|
106
|
+
exports.extractVariantBaseClasses = extractVariantBaseClasses;
|
|
107
|
+
exports.resolveVariantPrefixes = resolveVariantPrefixes;
|
|
108
|
+
exports.stylesToArbitraryClass = stylesToArbitraryClass;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { resolveModulePath } from 'exsolve';
|
|
2
|
+
|
|
3
|
+
const VARIANT_PREFIX_RE = /^((?:sm|md|lg|xl|2xl|dark):)(.+)$/;
|
|
4
|
+
const CSS_PROP_TO_UTILITY_PREFIX = {
|
|
5
|
+
"background-color": "bg",
|
|
6
|
+
"color": "text",
|
|
7
|
+
"border-color": "border",
|
|
8
|
+
"font-size": "text",
|
|
9
|
+
"font-weight": "font",
|
|
10
|
+
"line-height": "leading",
|
|
11
|
+
"letter-spacing": "tracking",
|
|
12
|
+
"opacity": "opacity",
|
|
13
|
+
"width": "w",
|
|
14
|
+
"height": "h",
|
|
15
|
+
"max-width": "max-w",
|
|
16
|
+
"max-height": "max-h",
|
|
17
|
+
"min-width": "min-w",
|
|
18
|
+
"min-height": "min-h",
|
|
19
|
+
"border-radius": "rounded",
|
|
20
|
+
"gap": "gap",
|
|
21
|
+
"padding": "p",
|
|
22
|
+
"padding-top": "pt",
|
|
23
|
+
"padding-right": "pr",
|
|
24
|
+
"padding-bottom": "pb",
|
|
25
|
+
"padding-left": "pl",
|
|
26
|
+
"margin": "m",
|
|
27
|
+
"margin-top": "mt",
|
|
28
|
+
"margin-right": "mr",
|
|
29
|
+
"margin-bottom": "mb",
|
|
30
|
+
"margin-left": "ml",
|
|
31
|
+
"display": ""
|
|
32
|
+
};
|
|
33
|
+
function stylesToArbitraryClass(styles) {
|
|
34
|
+
const entries = Object.entries(styles);
|
|
35
|
+
if (entries.length !== 1)
|
|
36
|
+
return void 0;
|
|
37
|
+
const [prop, value] = entries[0];
|
|
38
|
+
if (prop === "display")
|
|
39
|
+
return value === "none" ? "hidden" : value;
|
|
40
|
+
const prefix = CSS_PROP_TO_UTILITY_PREFIX[prop];
|
|
41
|
+
if (!prefix)
|
|
42
|
+
return void 0;
|
|
43
|
+
return `${prefix}-[${value}]`;
|
|
44
|
+
}
|
|
45
|
+
function extractVariantBaseClasses(classes) {
|
|
46
|
+
const baseClasses = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const cls of classes) {
|
|
48
|
+
const m = cls.match(VARIANT_PREFIX_RE);
|
|
49
|
+
if (m?.[2])
|
|
50
|
+
baseClasses.add(m[2]);
|
|
51
|
+
}
|
|
52
|
+
return baseClasses;
|
|
53
|
+
}
|
|
54
|
+
function resolveVariantPrefixes(classes, resolvedStyles) {
|
|
55
|
+
const prefixOverrideProps = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const cls of classes) {
|
|
57
|
+
const prefixMatch = cls.match(VARIANT_PREFIX_RE);
|
|
58
|
+
if (prefixMatch) {
|
|
59
|
+
const baseStyles = resolvedStyles.get(prefixMatch[2]);
|
|
60
|
+
if (baseStyles) {
|
|
61
|
+
for (const prop of Object.keys(baseStyles))
|
|
62
|
+
prefixOverrideProps.add(prop);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const result = {};
|
|
67
|
+
for (const cls of classes) {
|
|
68
|
+
const prefixMatch = cls.match(VARIANT_PREFIX_RE);
|
|
69
|
+
if (prefixMatch) {
|
|
70
|
+
const [, prefix, baseClass] = prefixMatch;
|
|
71
|
+
const baseStyles = resolvedStyles.get(baseClass);
|
|
72
|
+
if (baseStyles) {
|
|
73
|
+
const arbitrary = stylesToArbitraryClass(baseStyles);
|
|
74
|
+
result[cls] = arbitrary ? `${prefix}${arbitrary}` : cls;
|
|
75
|
+
} else {
|
|
76
|
+
result[cls] = cls;
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const styles = resolvedStyles.get(cls);
|
|
81
|
+
if (styles) {
|
|
82
|
+
const hasConflict = Object.keys(styles).some((prop) => prefixOverrideProps.has(prop));
|
|
83
|
+
if (hasConflict) {
|
|
84
|
+
const arbitrary = stylesToArbitraryClass(styles);
|
|
85
|
+
result[cls] = arbitrary || cls;
|
|
86
|
+
} else {
|
|
87
|
+
result[cls] = styles;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
function detectCssProvider(nuxt) {
|
|
94
|
+
const modules = nuxt.options.modules.flat();
|
|
95
|
+
if (modules.some((m) => typeof m === "string" && m.includes("@unocss/nuxt")))
|
|
96
|
+
return "unocss";
|
|
97
|
+
if (resolveModulePath("tailwindcss", { from: nuxt.options.rootDir, try: true }))
|
|
98
|
+
return "tailwind";
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { VARIANT_PREFIX_RE, detectCssProvider, extractVariantBaseClasses, resolveVariantPrefixes, stylesToArbitraryClass };
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const promises = require('node:fs/promises');
|
|
4
|
+
const exsolve = require('exsolve');
|
|
5
|
+
const pathe = require('pathe');
|
|
6
|
+
const cssProvider = require('./css-provider.cjs');
|
|
7
|
+
const module$1 = require('../shared/nuxt-og-image.Dxgo_zuB.cjs');
|
|
8
|
+
require('node:fs');
|
|
9
|
+
require('@nuxt/kit');
|
|
10
|
+
require('defu');
|
|
11
|
+
require('nuxt-site-config/kit');
|
|
12
|
+
require('ohash');
|
|
13
|
+
require('pkg-types');
|
|
14
|
+
require('node:crypto');
|
|
15
|
+
require('oxc-walker');
|
|
16
|
+
require('std-env');
|
|
17
|
+
require('../../dist/runtime/logger.js');
|
|
18
|
+
require('chrome-launcher');
|
|
19
|
+
require('nypm');
|
|
20
|
+
require('@nuxt/devtools-kit');
|
|
21
|
+
require('unstorage');
|
|
22
|
+
require('unstorage/drivers/fs-lite');
|
|
23
|
+
require('../../dist/runtime/server/og-image/utils/css.js');
|
|
24
|
+
require('node:url');
|
|
25
|
+
require('magic-string');
|
|
26
|
+
require('strip-literal');
|
|
27
|
+
require('ufo');
|
|
28
|
+
require('unplugin');
|
|
29
|
+
require('@vue/compiler-sfc');
|
|
30
|
+
require('ofetch');
|
|
31
|
+
require('ultrahtml');
|
|
32
|
+
require('../../dist/runtime/server/og-image/core/transforms/emojis/emoji-utils.js');
|
|
33
|
+
require('../shared/nuxt-og-image.CMYbz66P.cjs');
|
|
34
|
+
require('magicast');
|
|
35
|
+
require('magicast/helpers');
|
|
36
|
+
|
|
37
|
+
const RE_GRADIENT_STOP_PREFIX = /^(from|via|to)-/;
|
|
38
|
+
const RE_COLOR_SHADE = /^(.+)-(\d+)$/;
|
|
39
|
+
const RE_CSS_COLOR_VALUE = /color:([^;}]+)/;
|
|
40
|
+
const RE_TO_DIRECTION = /^to-(?:[tblr]|tl|tr|bl|br)$/;
|
|
41
|
+
const RE_FONT_VAR = /--font-([\w-]+)\s*:/g;
|
|
42
|
+
let compile;
|
|
43
|
+
let twColors;
|
|
44
|
+
async function loadTw4Deps() {
|
|
45
|
+
if (!compile) {
|
|
46
|
+
const [, tailwindModule, colorsModule] = await Promise.all([
|
|
47
|
+
module$1.loadLightningCss(),
|
|
48
|
+
import('tailwindcss'),
|
|
49
|
+
import('tailwindcss/colors')
|
|
50
|
+
]);
|
|
51
|
+
compile = tailwindModule.compile;
|
|
52
|
+
twColors = colorsModule.default || colorsModule;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function createModuleLoader(baseDir) {
|
|
56
|
+
return async (id, base) => {
|
|
57
|
+
const resolved = exsolve.resolveModulePath(id, { from: base || baseDir });
|
|
58
|
+
if (resolved) {
|
|
59
|
+
const module2 = await import(resolved).then((m) => m.default || m);
|
|
60
|
+
return { path: resolved, base: pathe.dirname(resolved), module: module2 };
|
|
61
|
+
}
|
|
62
|
+
const relativePath = pathe.join(base || baseDir, id);
|
|
63
|
+
const module = await import(relativePath).then((m) => m.default || m).catch(() => ({}));
|
|
64
|
+
return { path: relativePath, base: pathe.dirname(relativePath), module };
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function createStylesheetLoader(baseDir) {
|
|
68
|
+
return async (id, base) => {
|
|
69
|
+
if (id === "tailwindcss") {
|
|
70
|
+
const twPath = exsolve.resolveModulePath("tailwindcss/index.css", { from: baseDir });
|
|
71
|
+
if (twPath) {
|
|
72
|
+
const content = await promises.readFile(twPath, "utf-8").catch(() => "");
|
|
73
|
+
if (content)
|
|
74
|
+
return { path: twPath, base: pathe.dirname(twPath), content };
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
path: "virtual:tailwindcss",
|
|
78
|
+
base,
|
|
79
|
+
content: "@layer theme, base, components, utilities;\n@layer utilities { @tailwind utilities; }"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (id.startsWith("./") || id.startsWith("../")) {
|
|
83
|
+
const resolved2 = pathe.join(base || baseDir, id);
|
|
84
|
+
const content = await promises.readFile(resolved2, "utf-8").catch(() => "");
|
|
85
|
+
return { path: resolved2, base: pathe.dirname(resolved2), content };
|
|
86
|
+
}
|
|
87
|
+
const resolved = exsolve.resolveModulePath(id, { from: base || baseDir, conditions: ["style"] });
|
|
88
|
+
if (resolved) {
|
|
89
|
+
const content = await promises.readFile(resolved, "utf-8").catch(() => "");
|
|
90
|
+
return { path: resolved, base: pathe.dirname(resolved), content };
|
|
91
|
+
}
|
|
92
|
+
return { path: id, base, content: "" };
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function buildNuxtUiVars(vars, nuxtUiColors) {
|
|
96
|
+
const colors = twColors;
|
|
97
|
+
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
98
|
+
for (const [semantic, colorName] of Object.entries(nuxtUiColors)) {
|
|
99
|
+
for (const shade of shades) {
|
|
100
|
+
const varName = `--ui-color-${semantic}-${shade}`;
|
|
101
|
+
const value = colors[colorName]?.[shade];
|
|
102
|
+
if (value && !vars.has(varName))
|
|
103
|
+
vars.set(varName, value);
|
|
104
|
+
}
|
|
105
|
+
if (!vars.has(`--ui-${semantic}`))
|
|
106
|
+
vars.set(`--ui-${semantic}`, colors[colorName]?.[500] || "");
|
|
107
|
+
}
|
|
108
|
+
const neutral = nuxtUiColors.neutral || "slate";
|
|
109
|
+
const neutralColors = colors[neutral];
|
|
110
|
+
const semanticVars = {
|
|
111
|
+
// Dark mode text colors (inverted from light mode)
|
|
112
|
+
"--ui-text-dimmed": neutralColors?.[500] || "",
|
|
113
|
+
"--ui-text-muted": neutralColors?.[400] || "",
|
|
114
|
+
"--ui-text-toned": neutralColors?.[300] || "",
|
|
115
|
+
"--ui-text": neutralColors?.[200] || "",
|
|
116
|
+
"--ui-text-highlighted": "#ffffff",
|
|
117
|
+
"--ui-text-inverted": neutralColors?.[900] || "",
|
|
118
|
+
// Dark mode backgrounds
|
|
119
|
+
"--ui-bg": neutralColors?.[900] || "",
|
|
120
|
+
"--ui-bg-muted": neutralColors?.[800] || "",
|
|
121
|
+
"--ui-bg-elevated": neutralColors?.[800] || "",
|
|
122
|
+
"--ui-bg-accented": neutralColors?.[700] || "",
|
|
123
|
+
"--ui-bg-inverted": "#ffffff",
|
|
124
|
+
// Dark mode borders
|
|
125
|
+
"--ui-border": neutralColors?.[800] || "",
|
|
126
|
+
"--ui-border-muted": neutralColors?.[700] || "",
|
|
127
|
+
"--ui-border-accented": neutralColors?.[700] || "",
|
|
128
|
+
"--ui-border-inverted": "#ffffff"
|
|
129
|
+
};
|
|
130
|
+
for (const [name, value] of Object.entries(semanticVars)) {
|
|
131
|
+
if (value)
|
|
132
|
+
vars.set(name, value);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
let cachedCompiler = null;
|
|
136
|
+
let cachedCssPath = null;
|
|
137
|
+
let cachedVars = null;
|
|
138
|
+
let pendingCompiler = null;
|
|
139
|
+
const resolvedStyleCache = /* @__PURE__ */ new Map();
|
|
140
|
+
function clearTw4UserVarsCache() {
|
|
141
|
+
cachedVars = null;
|
|
142
|
+
resolvedStyleCache.clear();
|
|
143
|
+
}
|
|
144
|
+
function clearTw4Cache() {
|
|
145
|
+
cachedCompiler = null;
|
|
146
|
+
cachedCssPath = null;
|
|
147
|
+
cachedVars = null;
|
|
148
|
+
pendingCompiler = null;
|
|
149
|
+
resolvedStyleCache.clear();
|
|
150
|
+
}
|
|
151
|
+
async function getCompiler(cssPath, nuxtUiColors) {
|
|
152
|
+
if (cachedCompiler && cachedCssPath === cssPath)
|
|
153
|
+
return { compiler: cachedCompiler, vars: cachedVars };
|
|
154
|
+
if (pendingCompiler)
|
|
155
|
+
return pendingCompiler;
|
|
156
|
+
pendingCompiler = (async () => {
|
|
157
|
+
await loadTw4Deps();
|
|
158
|
+
const userCss = await promises.readFile(cssPath, "utf-8");
|
|
159
|
+
const baseDir = pathe.dirname(cssPath);
|
|
160
|
+
const compiler = await compile(userCss, {
|
|
161
|
+
loadStylesheet: createStylesheetLoader(baseDir),
|
|
162
|
+
loadModule: createModuleLoader(baseDir)
|
|
163
|
+
});
|
|
164
|
+
const vars = /* @__PURE__ */ new Map();
|
|
165
|
+
if (nuxtUiColors)
|
|
166
|
+
buildNuxtUiVars(vars, nuxtUiColors);
|
|
167
|
+
cachedCompiler = compiler;
|
|
168
|
+
cachedCssPath = cssPath;
|
|
169
|
+
cachedVars = vars;
|
|
170
|
+
resolvedStyleCache.clear();
|
|
171
|
+
return { compiler, vars };
|
|
172
|
+
})();
|
|
173
|
+
const p = pendingCompiler;
|
|
174
|
+
p.finally(() => {
|
|
175
|
+
pendingCompiler = null;
|
|
176
|
+
});
|
|
177
|
+
return p;
|
|
178
|
+
}
|
|
179
|
+
async function parseCssOutput(rawCss, vars) {
|
|
180
|
+
const css = await module$1.simplifyCss(rawCss);
|
|
181
|
+
for (const [name, value] of module$1.extractCssVars(css)) {
|
|
182
|
+
if (!vars.has(name))
|
|
183
|
+
vars.set(name, value);
|
|
184
|
+
}
|
|
185
|
+
for (const [name, value] of module$1.extractUniversalVars(css)) {
|
|
186
|
+
if (!vars.has(name))
|
|
187
|
+
vars.set(name, value);
|
|
188
|
+
}
|
|
189
|
+
const perClassVars = module$1.extractPerClassVars(css);
|
|
190
|
+
const classes = module$1.extractClassStyles(css, { skipPrefixes: ["--"], merge: true });
|
|
191
|
+
return { classes, perClassVars };
|
|
192
|
+
}
|
|
193
|
+
const LINEAR_GRADIENT_DIRECTIONS = {
|
|
194
|
+
"bg-gradient-to-t": "to top",
|
|
195
|
+
"bg-gradient-to-tr": "to top right",
|
|
196
|
+
"bg-gradient-to-r": "to right",
|
|
197
|
+
"bg-gradient-to-br": "to bottom right",
|
|
198
|
+
"bg-gradient-to-b": "to bottom",
|
|
199
|
+
"bg-gradient-to-bl": "to bottom left",
|
|
200
|
+
"bg-gradient-to-l": "to left",
|
|
201
|
+
"bg-gradient-to-tl": "to top left"
|
|
202
|
+
};
|
|
203
|
+
const RADIAL_GRADIENT_SHAPES = {
|
|
204
|
+
"bg-radial": "circle at center",
|
|
205
|
+
"bg-radial-at-t": "circle at top",
|
|
206
|
+
"bg-radial-at-tr": "circle at top right",
|
|
207
|
+
"bg-radial-at-r": "circle at right",
|
|
208
|
+
"bg-radial-at-br": "circle at bottom right",
|
|
209
|
+
"bg-radial-at-b": "circle at bottom",
|
|
210
|
+
"bg-radial-at-bl": "circle at bottom left",
|
|
211
|
+
"bg-radial-at-l": "circle at left",
|
|
212
|
+
"bg-radial-at-tl": "circle at top left",
|
|
213
|
+
"bg-radial-at-c": "circle at center"
|
|
214
|
+
};
|
|
215
|
+
async function resolveGradientColor(cls, vars) {
|
|
216
|
+
const colorName = cls.replace(RE_GRADIENT_STOP_PREFIX, "");
|
|
217
|
+
const shadeMatch = colorName.match(RE_COLOR_SHADE);
|
|
218
|
+
if (shadeMatch?.[1] && shadeMatch?.[2]) {
|
|
219
|
+
const varName2 = `--color-${shadeMatch[1]}-${shadeMatch[2]}`;
|
|
220
|
+
const value2 = vars.get(varName2);
|
|
221
|
+
if (value2) {
|
|
222
|
+
const resolved = await module$1.resolveVarsDeep(value2, vars);
|
|
223
|
+
if (!resolved.includes("var(")) {
|
|
224
|
+
const simplified = await module$1.simplifyCss(`.x{color:${resolved}}`);
|
|
225
|
+
return simplified.match(RE_CSS_COLOR_VALUE)?.[1]?.trim() ?? resolved;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const varName = `--color-${colorName}`;
|
|
230
|
+
const value = vars.get(varName);
|
|
231
|
+
if (value) {
|
|
232
|
+
const resolved = await module$1.resolveVarsDeep(value, vars);
|
|
233
|
+
if (!resolved.includes("var(")) {
|
|
234
|
+
const simplified = await module$1.simplifyCss(`.x{color:${resolved}}`);
|
|
235
|
+
return simplified.match(RE_CSS_COLOR_VALUE)?.[1]?.trim() ?? resolved;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
async function buildGradient(classes, vars) {
|
|
241
|
+
const linearDir = classes.find((c) => LINEAR_GRADIENT_DIRECTIONS[c]);
|
|
242
|
+
const radialShape = classes.find((c) => RADIAL_GRADIENT_SHAPES[c]);
|
|
243
|
+
const fromClass = classes.find((c) => c.startsWith("from-"));
|
|
244
|
+
const viaClass = classes.find((c) => c.startsWith("via-"));
|
|
245
|
+
const toClass = classes.find((c) => c.startsWith("to-") && !RE_TO_DIRECTION.test(c));
|
|
246
|
+
if (!linearDir && !radialShape)
|
|
247
|
+
return null;
|
|
248
|
+
if (!fromClass && !toClass)
|
|
249
|
+
return null;
|
|
250
|
+
const fromColor = fromClass ? await resolveGradientColor(fromClass, vars) : null;
|
|
251
|
+
const viaColor = viaClass ? await resolveGradientColor(viaClass, vars) : null;
|
|
252
|
+
const toColor = toClass ? await resolveGradientColor(toClass, vars) : null;
|
|
253
|
+
if (!fromColor && !toColor)
|
|
254
|
+
return null;
|
|
255
|
+
const stops = [fromColor, viaColor, toColor].filter(Boolean).join(", ");
|
|
256
|
+
const colorClasses = [fromClass, viaClass, toClass].filter((c) => !!c);
|
|
257
|
+
if (linearDir) {
|
|
258
|
+
const direction = LINEAR_GRADIENT_DIRECTIONS[linearDir];
|
|
259
|
+
return {
|
|
260
|
+
gradientClass: linearDir,
|
|
261
|
+
value: `linear-gradient(${direction}, ${stops})`,
|
|
262
|
+
colorClasses
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
if (radialShape) {
|
|
266
|
+
const shape = RADIAL_GRADIENT_SHAPES[radialShape];
|
|
267
|
+
return {
|
|
268
|
+
gradientClass: radialShape,
|
|
269
|
+
value: `radial-gradient(${shape}, ${stops})`,
|
|
270
|
+
colorClasses
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
async function resolveClassesToStyles(classes, options, context) {
|
|
276
|
+
const { compiler, vars } = await getCompiler(options.cssPath, options.nuxtUiColors);
|
|
277
|
+
const uncached = classes.filter((c) => !resolvedStyleCache.has(c));
|
|
278
|
+
if (uncached.length > 0) {
|
|
279
|
+
const outputCss = compiler.build(uncached);
|
|
280
|
+
const { classes: parsedClasses, perClassVars } = await parseCssOutput(outputCss, vars);
|
|
281
|
+
for (const [className, rawStyles] of parsedClasses) {
|
|
282
|
+
const classVars = perClassVars.get(className);
|
|
283
|
+
const mergedVars = classVars ? new Map([...vars, ...classVars]) : vars;
|
|
284
|
+
const styles = await module$1.postProcessStyles(rawStyles, mergedVars, void 0, context);
|
|
285
|
+
if (!styles && className.startsWith("bg-gradient-")) {
|
|
286
|
+
resolvedStyleCache.set(className, rawStyles);
|
|
287
|
+
} else {
|
|
288
|
+
resolvedStyleCache.set(className, styles);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
for (const c of uncached) {
|
|
292
|
+
if (!resolvedStyleCache.has(c))
|
|
293
|
+
resolvedStyleCache.set(c, null);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const result = {};
|
|
297
|
+
for (const cls of classes) {
|
|
298
|
+
const resolved = resolvedStyleCache.get(cls);
|
|
299
|
+
if (resolved)
|
|
300
|
+
result[cls] = resolved;
|
|
301
|
+
}
|
|
302
|
+
const gradient = await buildGradient(classes, vars);
|
|
303
|
+
if (gradient) {
|
|
304
|
+
result[gradient.gradientClass] = { "background-image": gradient.value };
|
|
305
|
+
for (const colorClass of gradient.colorClasses) {
|
|
306
|
+
result[colorClass] = {};
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
async function extractTw4Metadata(options) {
|
|
312
|
+
const { compiler, vars } = await getCompiler(options.cssPath, options.nuxtUiColors);
|
|
313
|
+
const userCss = await promises.readFile(options.cssPath, "utf-8");
|
|
314
|
+
const fontCandidates = Array.from(userCss.matchAll(RE_FONT_VAR), (m) => `font-${m[1]}`);
|
|
315
|
+
const themeCss = compiler.build(fontCandidates);
|
|
316
|
+
await parseCssOutput(themeCss, vars);
|
|
317
|
+
const fontVars = {};
|
|
318
|
+
const breakpoints = {};
|
|
319
|
+
const colors = {};
|
|
320
|
+
for (const [name, value] of vars) {
|
|
321
|
+
const resolvedValue = await module$1.resolveVarsDeep(value, vars);
|
|
322
|
+
if (name.startsWith("--font-")) {
|
|
323
|
+
fontVars[name.slice(2)] = resolvedValue;
|
|
324
|
+
} else if (name.startsWith("--breakpoint-")) {
|
|
325
|
+
const px = Number.parseInt(resolvedValue.replace("px", ""), 10);
|
|
326
|
+
if (!Number.isNaN(px))
|
|
327
|
+
breakpoints[name.slice(13)] = px;
|
|
328
|
+
} else if (name.startsWith("--color-") && !resolvedValue.includes("var(")) {
|
|
329
|
+
const colorPath = name.slice(8);
|
|
330
|
+
const shadeMatch = colorPath.match(RE_COLOR_SHADE);
|
|
331
|
+
const simplified = await module$1.simplifyCss(`.x{color:${resolvedValue}}`);
|
|
332
|
+
const hexValue = simplified.match(RE_CSS_COLOR_VALUE)?.[1]?.trim() ?? resolvedValue;
|
|
333
|
+
if (shadeMatch) {
|
|
334
|
+
const [, colorName, shade] = shadeMatch;
|
|
335
|
+
if (colorName) {
|
|
336
|
+
if (!colors[colorName])
|
|
337
|
+
colors[colorName] = {};
|
|
338
|
+
if (typeof colors[colorName] === "object")
|
|
339
|
+
colors[colorName][shade] = hexValue;
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
colors[colorPath] = hexValue;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return { fontVars, breakpoints, colors };
|
|
347
|
+
}
|
|
348
|
+
function createTw4Provider(options) {
|
|
349
|
+
let cssPath;
|
|
350
|
+
let initPromise;
|
|
351
|
+
let initialized = false;
|
|
352
|
+
async function init() {
|
|
353
|
+
if (initialized)
|
|
354
|
+
return;
|
|
355
|
+
if (initPromise)
|
|
356
|
+
return initPromise;
|
|
357
|
+
initPromise = (async () => {
|
|
358
|
+
cssPath = await options.resolveCssPath();
|
|
359
|
+
if (!cssPath) {
|
|
360
|
+
initialized = true;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const content = await promises.readFile(cssPath, "utf-8");
|
|
364
|
+
if (!content.includes("@theme") && !content.includes('@import "tailwindcss"'))
|
|
365
|
+
cssPath = void 0;
|
|
366
|
+
initialized = true;
|
|
367
|
+
})();
|
|
368
|
+
return initPromise;
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
name: "tailwind",
|
|
372
|
+
async resolveClassesToStyles(classes, context) {
|
|
373
|
+
await init();
|
|
374
|
+
if (!cssPath)
|
|
375
|
+
return {};
|
|
376
|
+
const baseClasses = cssProvider.extractVariantBaseClasses(classes);
|
|
377
|
+
const classesToResolve = [.../* @__PURE__ */ new Set([...classes, ...baseClasses])];
|
|
378
|
+
const nuxtUiColors = await options.loadNuxtUiColors();
|
|
379
|
+
const tw4Resolved = await resolveClassesToStyles(classesToResolve, {
|
|
380
|
+
cssPath,
|
|
381
|
+
nuxtUiColors
|
|
382
|
+
}, context);
|
|
383
|
+
const resolvedMap = new Map(Object.entries(tw4Resolved));
|
|
384
|
+
return cssProvider.resolveVariantPrefixes(classes, resolvedMap);
|
|
385
|
+
},
|
|
386
|
+
async extractMetadata() {
|
|
387
|
+
await init();
|
|
388
|
+
if (!cssPath)
|
|
389
|
+
return { fontVars: {}, breakpoints: {}, colors: {} };
|
|
390
|
+
const nuxtUiColors = await options.loadNuxtUiColors();
|
|
391
|
+
return extractTw4Metadata({ cssPath, nuxtUiColors });
|
|
392
|
+
},
|
|
393
|
+
async getVars() {
|
|
394
|
+
await init();
|
|
395
|
+
if (!cssPath)
|
|
396
|
+
return /* @__PURE__ */ new Map();
|
|
397
|
+
const nuxtUiColors = await options.loadNuxtUiColors();
|
|
398
|
+
const { vars } = await getCompiler(cssPath, nuxtUiColors);
|
|
399
|
+
return vars;
|
|
400
|
+
},
|
|
401
|
+
clearUserVarsCache: clearTw4UserVarsCache,
|
|
402
|
+
clearCache: clearTw4Cache
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
exports.buildNuxtUiVars = buildNuxtUiVars;
|
|
407
|
+
exports.clearTw4Cache = clearTw4Cache;
|
|
408
|
+
exports.clearTw4UserVarsCache = clearTw4UserVarsCache;
|
|
409
|
+
exports.createModuleLoader = createModuleLoader;
|
|
410
|
+
exports.createStylesheetLoader = createStylesheetLoader;
|
|
411
|
+
exports.createTw4Provider = createTw4Provider;
|
|
412
|
+
exports.extractTw4Metadata = extractTw4Metadata;
|
|
413
|
+
exports.resolveClassesToStyles = resolveClassesToStyles;
|