@cssxio/unplugin 0.10.0 → 0.11.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 +32 -20
- package/dist/chunk-3C7SCOHD.js +11 -0
- package/dist/chunk-5W5F6RBE.js +3 -0
- package/dist/chunk-663P2VZO.js +3 -0
- package/dist/chunk-7X733NFU.js +1 -0
- package/dist/chunk-AJOXGQDA.js +1 -0
- package/dist/chunk-ART2XI6B.js +5 -0
- package/dist/chunk-GPHROS5Y.js +1 -0
- package/dist/chunk-NTKLI2V7.js +1 -0
- package/dist/chunk-URWMD4HY.js +1 -0
- package/dist/chunk-V4DGCZJC.js +2 -0
- package/dist/chunk-VJ4HYXVU.js +1 -0
- package/dist/compile-cssx-stylesheet-CAnWFXMM.d.cts +17 -0
- package/dist/compile-cssx-stylesheet-CnatguKL.d.ts +17 -0
- package/dist/development-runtime.cjs +212 -0
- package/dist/development-runtime.d.cts +181 -0
- package/dist/development-runtime.d.ts +181 -0
- package/dist/development-runtime.js +196 -0
- package/dist/esbuild.cjs +14 -102
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +19 -102
- package/dist/index.d.cts +12 -56
- package/dist/index.d.ts +12 -56
- package/dist/index.js +1 -1
- package/dist/module-cssx-data-CtlcR7CZ.d.ts +12 -0
- package/dist/module-cssx-data-DfZiLJQL.d.cts +12 -0
- package/dist/next-development-server-CBPFB9EC.d.cts +17 -0
- package/dist/next-development-server-CBPFB9EC.d.ts +17 -0
- package/dist/next-loader.cjs +15 -14
- package/dist/next-loader.d.cts +3 -1
- package/dist/next-loader.d.ts +3 -1
- package/dist/next-loader.js +5 -4
- package/dist/next.cjs +1 -1
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +1 -1
- package/dist/{options-DkqShf7w.d.ts → options-BbhZj-Sb.d.cts} +4 -0
- package/dist/{options-DkqShf7w.d.cts → options-BbhZj-Sb.d.ts} +4 -0
- package/dist/rollup.cjs +17 -101
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +17 -101
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/stylesheet-types-mSM1XaBK.d.cts +40 -0
- package/dist/stylesheet-types-mSM1XaBK.d.ts +40 -0
- package/dist/transform-runtime.cjs +12 -0
- package/dist/transform-runtime.d.cts +71 -0
- package/dist/transform-runtime.d.ts +71 -0
- package/dist/transform-runtime.js +2 -0
- package/dist/vite.cjs +17 -101
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +17 -101
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +13 -3
- package/dist/chunk-5R7RC6XB.js +0 -13
- package/dist/chunk-KEHM5MVZ.js +0 -91
- package/dist/chunk-OHZUHF4D.js +0 -1
package/README.md
CHANGED
|
@@ -27,7 +27,9 @@ export default withCSSX(
|
|
|
27
27
|
);
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
CSSX defaults to serial `s…x` names and a persisted `.cssx/classnames.json` manifest in `withCSSX
|
|
30
|
+
CSSX defaults to serial `s…x` names and a persisted `.cssx/classnames.json` manifest in production `withCSSX` builds. Development uses source-addressed composite names based on module identity and CSSX call order, so changing literal text or its length leaves existing selectors stable. Development skips class-name compression, manifest writes, and reusable-fragment planning and caches project metadata so an existing source file is transformed again only when it changes. Next.js 16 projects can select either bundler with `next dev --webpack` / `next build --webpack`, or `next dev --turbopack` / `next build --turbopack`. MDX source files are compiled by the helper; install `@mdx-js/mdx` when a project contains `.md` or `.mdx` files. Configure serializable remark, rehype, or recma plugins with `mdx`. Use `sourceRoots` for linked workspace packages outside the project root.
|
|
31
|
+
|
|
32
|
+
`withCSSX` detects Next.js development versus production mode. Other adapters infer development from `NODE_ENV=development`, an active Vite server, a development compiler mode, or Rollup watch mode. esbuild has no standard mode signal, so set `mode: 'development'` explicitly. `mode: 'production'` disables development behavior.
|
|
31
33
|
|
|
32
34
|
`withCSSX` composes with a synchronous `webpack(config)` callback. It throws a clear error if an existing callback returns a Promise, since Next.js invokes that hook synchronously.
|
|
33
35
|
|
|
@@ -118,24 +120,26 @@ const stylesheet = await compileCssxStylesheet([
|
|
|
118
120
|
|
|
119
121
|
## Options
|
|
120
122
|
|
|
121
|
-
| Option
|
|
122
|
-
|
|
|
123
|
-
| `importSource`
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
136
|
-
| `
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
123
|
+
| Option | Default | What it does |
|
|
124
|
+
| ------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
125
|
+
| `importSource` | `@cssxio/cssx` | Module specifier that identifies source files to transform. A source file must contain this text and have a JavaScript or TypeScript extension. |
|
|
126
|
+
| `mode` | inferred | Selects `development` or `production` behavior. esbuild requires an explicit development mode. |
|
|
127
|
+
| `cssFileName` | `cssx.css` | Relative CSS output path. It must be non-empty, end in `.css`, and stay within the bundler output directory. `[hash]` is replaced with a stable hash of the generated CSS. |
|
|
128
|
+
| `naming` | `serial` | Selects generated composite naming: `serial`, `hash`, or source-addressed `source`. Independent of compiler coordination. |
|
|
129
|
+
| `coordination` | `memory` | Coordinates assignments within one adapter instance (`memory`) or through a persisted manifest (`manifest`). |
|
|
130
|
+
| `manifestPath` | — | JSON file used when `coordination: 'manifest'`. Independent compiler workers must share this path. |
|
|
131
|
+
| `className` | serial `s…x` | Controls atomic naming format, prefix, suffix, and hash length. Respected by compiler allocators used in every adapter. |
|
|
132
|
+
| `classNameAllocator` | — | Custom allocator for in-process integrations. Omit `className` when supplying one; manifest coordination uses CSSX's persisted allocator instead. |
|
|
133
|
+
| `stableClassNames` | `false` | Deprecated compatibility alias for `naming: 'source'`; emits source-addressed `d…` composites and overrides serial composite output. |
|
|
134
|
+
| `stableClassNameStrategy` | `source-location` | Chooses source location identities or module-order identities for source-addressed composites. Development adapters select `module-order`. |
|
|
135
|
+
| `debug` | `false` | Prints a concise output summary or writes a class/source/selector diagnostic JSON report. |
|
|
136
|
+
| `sourceRoots` | project root | Additional source directories included in project metadata scans, such as linked workspace packages. |
|
|
137
|
+
| `sourceMap` | `true` | Whether to generate a separate CSS source map. Development defaults to `false` to keep warm updates lighter; set `sourceMap: true` to include development CSS maps. |
|
|
138
|
+
| `layer` | — | CSS layer name that wraps generated CSS. It must be a single valid layer identifier, such as `cssx`. |
|
|
139
|
+
| `theme` | — | Inline CSSX `@theme` source used while transforming and compiling CSS. The theme is compiled into generated rules; it does not add a global stylesheet. |
|
|
140
|
+
| `themeFile` | — | Path, relative to the current working directory, to a CSSX `@theme` file. It is reread when CSS is generated; Rollup-compatible adapters register it as a watched dependency. Do not use it with `theme`. |
|
|
141
|
+
| `darkMode` | `media` | Activates `dark:` utilities with the system color-scheme media query (`media`), `[data-theme=dark]` (`selector`), or a `.dark` ancestor (`class`). Use the selector that matches your theme controller. |
|
|
142
|
+
| `preflight` | `true` | Adds Tailwind-compatible browser baseline rules before utilities. Set it to `false` only when the application deliberately owns a different global reset. |
|
|
139
143
|
|
|
140
144
|
The universal adapter validates options when it is created. `theme` and `themeFile` cannot be used together. Invalid CSS paths and layer names fail the build before CSS is emitted.
|
|
141
145
|
|
|
@@ -154,7 +158,15 @@ The Rollup-compatible adapters retain transformed module metadata until `generat
|
|
|
154
158
|
|
|
155
159
|
When `sourceMap` is enabled and source locations are available, generated CSS has a separate `.css.map` file and a source-map comment. Each mapping points to the source module location of the static utility string that created the rule. `transformCssxModule` can accept and return JavaScript source maps for build tools that provide a compatible input map.
|
|
156
160
|
|
|
157
|
-
During
|
|
161
|
+
During development, all adapters use a cached source coordinator and push stylesheet revisions over a development-only event stream independently of JavaScript bundle completion. Vite serves its event stream beneath the configured base path; Next.js, Webpack, Rspack, Rollup watch, and explicitly enabled esbuild development builds use a loopback transport. The injected browser bridge replaces the stylesheet automatically, preserving page state and avoiding a manual refresh. Keep the generated stylesheet in the initial document so CSS is present before the first update. Development watchers and browser transport are omitted from production builds.
|
|
162
|
+
|
|
163
|
+
CSS source maps are off by default during development to reduce stylesheet compilation time and memory use. Set `sourceMap: true` when you need to debug generated CSS mappings; production keeps the default source map behavior.
|
|
164
|
+
|
|
165
|
+
Resource use is bounded during development. The shared project scanner opens at most 16 directory watchers per process. Vite and esbuild use a native fast path capped at eight additional directory watchers; they watch directories rather than individual files and fall back to the bundler watcher if native watching fails or reaches the cap. Vite coalesces duplicate notifications and stylesheet compiles, transforms at most four changed modules concurrently, and caps distinct in-flight paths at 256. Rollup prepares CSS-only updates in its existing `watchChange` hook before scheduling the rebuild and serializes at most 256 pending changed modules through one queue. The scanner caps pending paths at 256, coalesces overflow into one reconciliation, and processes changed modules sequentially. Stopped coordinators release their metadata cache; at most eight inactive project snapshots are retained. Fixed-size digests avoid retaining full source text for edit checks. Vite keeps at most 64 prepared digests; Rollup and esbuild each cap prepared transforms at 64 entries and 16 MiB of estimated retained transform data. The Next.js stylesheet stream accepts at most 64 browser clients per app and keeps only the newest update queued for a slow client.
|
|
166
|
+
|
|
167
|
+
If a Vite-powered SSR framework skips Vite's HTML transform hook, CSSX injects its bridge in the rendered response. The fallback buffers at most 1 MiB and 4,096 chunks per response, with at most eight responses buffered at once; oversized or excess responses pass through without injection.
|
|
168
|
+
|
|
169
|
+
The 100 ms goal measures a warm existing-style save until the changed computed style is visible after the next animation frame. It does not include cold startup, newly introduced call sites, JavaScript edits, full-theme changes, or composition-structure changes. Run `pnpm benchmark:dev-hmr` for the cached compiler benchmark and `pnpm test:hmr` for browser save-to-visible benchmarks across esbuild, Rollup, Webpack, and Rspack. Vite and Next.js browser benchmarks run in the visual test matrix. Compiler timing alone is not a browser save-to-visible measurement.
|
|
158
170
|
|
|
159
171
|
With esbuild, `outdir` places CSS below that directory. `outfile` places it beside the output file. Without either option, it is placed below the working directory. With `write: false`, CSS and its map are appended to esbuild's in-memory `outputFiles`; otherwise they are written to disk. A later esbuild build removes CSS files that CSSX wrote when no utilities remain.
|
|
160
172
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as ee,b as te,d as se,h as L}from"./chunk-GPHROS5Y.js";import{createClassNameAllocator as Je}from"@cssxio/compiler";function k(s){let t=[],e=/\bsx\s*\(/g;for(let r of s.matchAll(e)){let o=r.index,a=s.indexOf("(",o),l=0,u="";for(let m=a;m<s.length;m+=1){let c=s[m];if(u){c==="\\"?m+=1:c===u&&(u="");continue}if(c==='"'||c==="'"||c==="`")u=c;else if(c==="(")l+=1;else if(c===")"&&--l===0){t.push({start:o,end:m+1,code:s.slice(o,m+1)}),e.lastIndex=m+1;break}}}return t}function j(s,t){return{code:s,rules:t.flatMap(e=>e.rules),candidates:Object.assign({},...t.map(e=>e.candidates)),composites:Object.assign({},...t.map(e=>e.composites)),atomicClasses:[...new Set(t.flatMap(e=>e.atomicClasses))],origins:Object.assign({},...t.map(e=>e.origins)),cssOnlySignature:s}}function J(s){let t="const style = ",e=s.indexOf(t)+t.length,r=s.indexOf(";",e);return s.slice(e,r)}async function re(s,t,e,r,o={}){let a=k(s);if(a.length===0)return null;let l=e.classNameAllocator??Je(),u=e.importSource??"@cssxio/cssx",m=[],c=s;for(let d of[...a].reverse()){let n=await r(`import { sx } from ${JSON.stringify(u)};
|
|
2
|
+
const style = ${d.code};`,`${t}.ts`,{...e,classNameAllocator:l},void 0,o),i=J(n.code);c=`${c.slice(0,d.start)}${i}${c.slice(d.end)}`,m.push({...n,atomicClasses:[],origins:{}})}return j(c,m)}import{createClassNameAllocator as _e}from"@cssxio/compiler";import{parse as Ve}from"@vue/compiler-sfc";function _(s,t){let e=s.split(`
|
|
3
|
+
`).slice(0,t.line).reduce((r,o)=>r+o.length+1,0);return Math.min(s.length,e+t.column)}function V(s,t){let e=Math.min(s.length,t),r=s.slice(0,e).split(`
|
|
4
|
+
`).length-1,o=s.lastIndexOf(`
|
|
5
|
+
`,e-1)+1;return{line:r,column:e-o}}function q(s,t,e){let r={},o=s.slice(t);for(let[a,l]of Object.entries(e))r[a]=V(s,t+_(o,l));return r}function oe(s,t,e,r,o){let a={};for(let[l,u]of Object.entries(o)){let m=_(e,u);a[l]=V(s,t+Math.max(0,m-r))}return a}function ne(s){return s.slice(1,-1).replace(/\\(['"\\bnfrtv])/g,(t,e)=>({b:"\b",n:`
|
|
6
|
+
`,f:"\f",r:"\r",t:" ",v:"\v"})[e]??e)}function ae(s,t){if(!t)return s;let e=t==='"'?"'":'"';return s.replace(/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g,r=>{let o=r[0]==='"'?JSON.parse(r):ne(r),a=JSON.stringify(o);return e==='"'?a:`'${a.slice(1,-1).replaceAll("'","\\'")}'`})}function ie(s,t){let e=-1,r;for(let o=0;o<t;o++){let a=s[o];if(r){a===r&&(r=void 0);continue}if(a==="<"&&/[A-Za-z]/.test(s[o+1])){e=o;continue}e!==-1&&(a===">"?e=-1:(a==='"'||a==="'")&&(r=a))}return r}async function ce(s,t,e,r,o,a={}){let l=k(s);if(l.length===0)return null;let u=e.importSource??"@cssxio/cssx",m=[],c=s;for(let d of[...l].reverse()){let n=`import { sx } from ${JSON.stringify(u)};
|
|
7
|
+
const style = `,i=`${n}${d.code};`,f=await o(i,`${t}.cssx-vue-template.ts`,{...e,classNameAllocator:r},void 0,a),p=ae(J(f.code),ie(s,d.start));c=`${c.slice(0,d.start)}${p}${c.slice(d.end)}`,m.push({...f,origins:oe(s,d.start,i,n.length,f.origins)})}return j(c,m)}async function le(s,t,e,r,o={}){let a=t.split("?",1).join(""),l=Ve(s,{filename:a});if(l.errors.length>0)throw new Error(l.errors[0].message);let u=e.classNameAllocator??_e(),m=[],c=[];for(let i of[l.descriptor.script,l.descriptor.scriptSetup]){if(!i?.content.includes(e.importSource??"@cssxio/cssx"))continue;let f=i.lang==="js"||i.lang==="jsx"||i.lang==="tsx"?i.lang:"ts",p=await r(i.content,`${a}.cssx-vue-script.${f}`,{...e,classNameAllocator:u},void 0,o);m.push({start:i.loc.start.offset,end:i.loc.end.offset,code:p.code}),c.push({...p,origins:q(s,i.loc.start.offset,p.origins)})}let d=l.descriptor.template;if(d?.content.includes("sx")){let i=await ce(d.content,a,e,u,r,o);i&&(m.push({start:d.loc.start.offset,end:d.loc.end.offset,code:i.code}),c.push({...i,origins:q(s,d.loc.start.offset,i.origins)}))}if(m.length===0)return null;let n=s;for(let i of m.sort((f,p)=>p.start-f.start))n=`${n.slice(0,i.start)}${i.code}${n.slice(i.end)}`;return j(n,c)}import{transformAsync as Xe}from"@babel/core";import De from"@cssxio/babel-plugin";import{compileUtilities as We,createSelectorAliases as ze}from"@cssxio/compiler";function me(s){return{className:`cssx-${se(s)}`,css:s}}function ue(s,t){return s&&t?`@layer ${t}{${s}}`:s}async function de(s,t,e,r,o={}){let a=e.importSource??"@cssxio/cssx",l=await te(e),u=await Xe(s,{babelrc:!1,configFile:!1,filename:t,parserOpts:{plugins:["jsx","typescript"]},plugins:[[De,{importSource:a,classNameAllocator:e.classNameAllocator,theme:l,reusabilityBudget:e.reusabilityBudget,stableClassNames:e.stableClassNames,stableClassNameStrategy:e.stableClassNameStrategy,stableClassNameFileName:e.stableClassNameFileName,darkMode:e.darkMode}]],sourceMaps:!0,...r?{inputSourceMap:r}:{}}),m=u.metadata,{candidates:c,origins:d,composites:n,atomicClasses:i,cssOnlySignature:f}=m.cssx,p=Object.keys(c),h=o.compileCss===!1||p.length===0?"":(await We(p,O=>c[O],l,ze(n),new Set(i),{darkMode:e.darkMode})).css;return{code:u.code,rules:h?[me(ue(h,e.layer))]:[],candidates:c,composites:n,atomicClasses:i,origins:d,cssOnlySignature:f,map:u.map}}var Le=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".vue"]);async function M(s,t,e={},r,o={}){ee(e);let a=e.importSource??"@cssxio/cssx",l=t.split("?",1).join("");return!Le.has(l.slice(l.lastIndexOf(".")))||!s.includes(a)?null:l.endsWith(".astro")?re(s,t,e,M,o):l.endsWith(".vue")?le(s,t,e,M,o):de(s,l,e,r,o)}function ps(s,t){if(!s||typeof s!="object")return;let e=s.getCombinedSourcemap;if(typeof e!="function")return;let r=e.call(s);if(!r||typeof r!="object")return;let o=r;if(!(o.version!==3||!Array.isArray(o.sources)||typeof o.mappings!="string"))return{version:o.version,sources:[...o.sources],names:[...o.names??[]],mappings:o.mappings,file:o.file??t.split("?",1).join(""),...o.sourceRoot?{sourceRoot:o.sourceRoot}:{},...o.sourcesContent?{sourcesContent:[...o.sourcesContent]}:{}}}import{createRequire as qe}from"module";import{resolve as Be}from"path";import{pathToFileURL as fe}from"url";async function X(s,t,e={}){let r=qe(Be(t,"package.json")),o;try{o=r.resolve("@mdx-js/mdx")}catch{throw new Error("CSSX Next MDX support requires @mdx-js/mdx to be installed in the Next.js project.")}let a=await import(fe(o).href),l=async u=>Promise.all((u??[]).map(async m=>{let[c,d]=typeof m=="string"?[m,void 0]:m,n=r.resolve(c),i=await import(fe(n).href),f=i.default??i;return d===void 0?f:[f,d]}));return String(await a.compile(s,{outputFormat:"program",development:e.development??!1,remarkPlugins:await l(e.remarkPlugins),rehypePlugins:await l(e.rehypePlugins),recmaPlugins:await l(e.recmaPlugins)}))}import{realpathSync as pe}from"fs";import{realpath as Ue}from"fs/promises";import{basename as ge,dirname as xe,join as Qe,resolve as B}from"path";async function bs(s){return Ue(s).catch(()=>B(s))}function S(s){let t=B(s);try{return pe.native(t)}catch{let e=xe(t),r=ge(t);for(;;)try{return B(pe.native(e),r)}catch{let o=xe(e);if(o===e)return t;r=Qe(ge(e),r),e=o}}}import{relative as Ge,resolve as ye,sep as He}from"path";function D(s,t,e){let r=e?S(s):ye(s),o=e?S(t):ye(t);return Ge(r,o).replaceAll(He,"/")}import{createClassNameAllocator as Ce,restoreClassNameAllocator as Ke,snapshotClassNameAllocator as he}from"@cssxio/compiler";import{mkdir as Ye,open as Ze,readFile as Ne,rename as et,rm as $,stat as we,writeFile as tt}from"fs/promises";import{dirname as st,resolve as rt}from"path";var Se=20,Oe=5*6e4;async function Pe(s,t,e){let r=rt(s),o=`${r}.lock`,a=Date.now(),l,u=0;for(;!l;){await Ye(st(r),{recursive:!0});let m;try{m=await Ze(o,"wx")}catch(c){let d=c.code;if(d!=="EEXIST"){if(d!=="EACCES"&&d!=="EPERM")throw c;try{await we(o)}catch(n){if(n.code==="ENOENT"){if(u+=1,u>1)throw c;await new Promise(i=>setTimeout(i,Se));continue}throw n}}if(u=0,await ot(o))continue;if(Date.now()-a>=Oe)throw new Error(`Timed out waiting for CSSX class-name manifest lock: ${o}`);await new Promise(n=>setTimeout(n,Se));continue}try{await m.writeFile(`${process.pid}
|
|
8
|
+
${Date.now()}
|
|
9
|
+
`)}catch(c){throw await m.close().catch(()=>{}),await $(o,{force:!0}).catch(()=>{}),c}l=m}try{let m=await nt(r,t),c=await e(m),d=he(m),n=`${r}.${process.pid}.${Date.now()}.tmp`;try{await tt(n,`${JSON.stringify(d,null,2)}
|
|
10
|
+
`,"utf8"),await et(n,r)}catch(i){throw await $(n,{force:!0}).catch(()=>{}),i}return c}finally{await l.close(),await $(o,{force:!0})}}async function ot(s){try{let t=await we(s),e;try{e=await Ne(s,"utf8")}catch(a){let l=a.code;if(l==="EACCES"||l==="EPERM")return!1;throw a}let[r]=e.split(`
|
|
11
|
+
`),o=Number(r);if(Number.isSafeInteger(o)&&o>0)try{return process.kill(o,0),!1}catch(a){return a.code!=="ESRCH"?!1:(await $(s,{force:!0}),!0)}return Date.now()-t.mtimeMs<Oe?!1:(await $(s,{force:!0}),!0)}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function nt(s,t){try{let e=JSON.parse(await Ne(s,"utf8")),r=he(Ce(t)).options;if(JSON.stringify(e.options)!==JSON.stringify(r))throw new Error("CSSX class-name manifest options do not match the active compiler options.");return Ke(e)}catch(e){if(e.code==="ENOENT")return Ce(t);throw e}}import{readdir as at}from"fs/promises";import{isAbsolute as it,join as ct,relative as be,resolve as U,sep as Ee}from"path";var lt=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".mdx",".md"]),Re=new Set([".git",".next",".open-next",".output",".turbo",".vercel","build","coverage","dist","node_modules","out","storybook-static"]);function Q(s,t=[]){let e=U(s),r=t.map(a=>U(a)).find(a=>{let l=be(a,e);return l===""||!l.startsWith(`..${Ee}`)&&l!==".."&&!it(l)});return(r?be(r,e):e).split(Ee).some(a=>Re.has(a))}async function Te(s,t=[]){let e=[],r=[s,...t],o=new Set;for(;r.length>0;){let a=r.pop(),l=U(a);if(!o.has(l)){o.add(l);for(let u of await at(a,{withFileTypes:!0})){let m=ct(a,u.name);if(u.isDirectory()){Re.has(u.name)||r.push(m);continue}u.isFile()&<.has(m.slice(m.lastIndexOf(".")))&&e.push(m)}}}return e.sort()}import{createClassNameAllocator as mt}from"@cssxio/compiler";import{watch as ut}from"fs";import{readFile as W,readdir as dt,stat as G}from"fs/promises";import{dirname as Me,extname as Ae,resolve as A}from"path";async function $e(s,t){let e=S(s),r=await Te(e,t.sourceRoots?.map(d=>S(A(e,d)))),o={...t};delete o.coordination,delete o.manifestPath,delete o.classNameAllocator;let a=async d=>{let n=[];for(let i of r){let f=await W(i,"utf8"),p=/\.(?:md|mdx)$/i.test(i);if(p&&!f.includes(t.importSource??"@cssxio/cssx"))continue;let h=p?await X(f,e,t.mdx):f,O=t.stableClassNames||t.naming==="source",C=await M(h,p?`${i}.tsx`:i,{...o,classNameAllocator:d,stableClassNames:O,...O?{stableClassNameFileName:D(e,i,t.mode==="development")}:{}},void 0,{compileCss:!1});C&&n.push({id:i,candidates:C.candidates,composites:C.composites,atomicClasses:C.atomicClasses,origins:C.origins})}return n};if(t.coordination==="manifest")return Pe(t.manifestPath,L(t),a);let l=T(e,t),u=Fe(s,t),m=v.get(l);if(m)return await m,$e(s,t);let c=(async()=>{let d=new Set;for(let n of r){let i;try{i=await G(n,{bigint:!0})}catch(E){if(E.code!=="ENOENT")throw E;u.signatures.delete(n),u.modules.delete(n);continue}let f=`${i.dev}:${i.ino}:${i.size}:${i.mtimeNs}:${i.ctimeNs}`;if(u.signatures.get(n)===f){d.add(n);continue}let p;try{p=await W(n,"utf8")}catch(E){if(E.code!=="ENOENT")throw E;u.signatures.delete(n),u.modules.delete(n);continue}d.add(n);let h=/\.(?:md|mdx)$/i.test(n),O=p.includes(t.importSource??"@cssxio/cssx");if(h&&!O){u.modules.delete(n),u.signatures.set(n,f);continue}let C=h?await X(p,e,t.mdx):p,P=t.stableClassNames||t.naming==="source",b=await M(C,h?`${n}.tsx`:n,{...o,classNameAllocator:u.allocator,stableClassNames:P,...P?{stableClassNameFileName:D(e,n,t.mode==="development")}:{}},void 0,{compileCss:!1});b?u.modules.set(n,{id:n,candidates:b.candidates,composites:b.composites,atomicClasses:b.atomicClasses,origins:b.origins}):u.modules.delete(n),u.signatures.set(n,f)}for(let n of u.signatures.keys())d.has(n)||(u.signatures.delete(n),u.modules.delete(n));return[...u.modules.values()].sort((n,i)=>n.id.localeCompare(i.id))})();v.set(l,c);try{return await c}finally{v.delete(l)}}function Qs(s,t){return Fe(s,t).allocator}async function Gs(s,t,e,r,o){if(e.coordination==="manifest")return!1;let a=T(s,e),l=v.get(a);l&&await l;let u=y.get(a);if(!u)return!1;let m=S(t),c;try{let n=await G(m,{bigint:!0});if(o!==void 0&&await W(m,"utf8")!==o)return!1;c=`${n.dev}:${n.ino}:${n.size}:${n.mtimeNs}:${n.ctimeNs}`}catch(n){if(n.code==="ENOENT"){let i=y.get(a);return i?.signatures.delete(m),i?.modules.delete(m)??!1}throw n}let d=u.modules.has(m);return r?u.modules.set(m,{id:m,candidates:r.candidates,composites:r.composites,atomicClasses:r.atomicClasses,origins:r.origins}):u.modules.delete(m),u.signatures.set(m,c),d||r!==null}function ft(s,t){let e=y.get(T(s,t));return e?[...e.modules.values()].sort((r,o)=>r.id.localeCompare(o.id)):void 0}function Hs(s,t){H.add(T(s,t))}function Ks(s,t){let e=T(s,t);H.delete(e),I.get(e)?.stop(),y.delete(e)}function T(s,t){let e={...t};return delete e.coordination,delete e.manifestPath,delete e.classNameAllocator,`${S(s)}\0${JSON.stringify(e)}`}function Fe(s,t){let e=T(s,t),r=y.get(e);return r||(r={allocator:t.classNameAllocator??mt(L(t)),modules:new Map,signatures:new Map},y.set(e,r),pt(e)),r}function pt(s){if(!(y.size<=ve))for(let t of y.keys()){if(y.size<=ve)return;t!==s&&!H.has(t)&&!I.has(t)&&y.delete(t)}}var y=new Map,v=new Map,H=new Set,ve=8,gt=256,je=16,F=0,xt=new Set([".js",".jsx",".ts",".tsx",".cjs",".cjsx",".cts",".ctsx",".mjs",".mjsx",".mts",".mtsx",".astro",".md",".mdx"]);async function Ys(s,t,e,r=()=>!1){let o=S(s),a=T(o,t),l=I.get(a);if(l)return Promise.resolve(l.stop);let u=v.get(a);u&&await u;let m=t.sourceRoots?.map(x=>A(o,x))??[],c=new Map,d=new Set,n=!1,i=!1,f,p=!1,h=!1,O=!1,C=!1,P=x=>{if(!(i||d.has(x))){if(d.size>=gt){d.clear(),i=!0;return}d.add(x),v.has(a)&&(n=!0)}},b=(x=0)=>{f&&clearTimeout(f),f=setTimeout(()=>{f=void 0,Ie()},x)},E=async()=>{let x=await Ct(o,m,[...y.get(a)?.modules.values()??[]],t.themeFile?A(o,t.themeFile):void 0);if(p)return;let z=new Set(x);for(let[N,g]of c)z.has(N)||(g.close(),c.delete(N),F--);for(let N of x){if(c.has(N))continue;if(F>=je){O||(O=!0,console.warn(`CSSX: development source watcher reached the ${je}-directory limit.`));continue}let g;try{g=ut(N,(w,Y)=>{if(p)return;if(Y===null){i=!0,b(8);return}let R=A(N,Y.toString());if(Q(R,m)||r(R))return;if(Ae(R)===".css"&&S(R)===S(A(o,t.themeFile??""))){P(R),b();return}let Z=Ae(R);if(w==="rename"&&Z==="")i=!0;else if(St(Z))P(R);else return;let ke=y.get(a)?.signatures.has(S(R))??!1;b(w==="rename"&&!ke?8:0)})}catch(w){C||(C=!0,console.warn(`CSSX: development source watcher could not watch ${N}: ${w instanceof Error?w.message:String(w)}`));continue}g.on("error",w=>{c.get(N)===g&&(c.delete(N),F--,g.close(),console.warn(`CSSX: development source watcher stopped for ${N}: ${w.message}`))}),g.unref(),c.set(N,g),F++}},Ie=async()=>{if(p||h)return;h=!0;let x=[...d],z=i,N=n;d.clear(),i=!1,n=!1;try{if(z){let g=await $e(o,t);if(p){y.delete(a);return}await E(),p||await e(g)}else{let g=N;for(let w of x)t.themeFile&&S(w)===S(A(o,t.themeFile))?g=!0:g=await yt(o,w,t)||g;if(g&&!p){let w=ft(o,t);await e(w)}}}catch(g){p||console.warn(`CSSX: development source update failed: ${g instanceof Error?g.message:String(g)}`)}finally{h=!1,(i||d.size>0)&&!f&&b()}},K=()=>{p=!0,f&&clearTimeout(f),d.clear(),i=!1,n=!1;for(let x of c.values())x.close(),F--;c.clear(),I.delete(a),y.delete(a)};return I.set(a,{stop:K}),await E().catch(x=>{console.warn(`CSSX: development source watcher could not start: ${x instanceof Error?x.message:String(x)}`)}),K}async function yt(s,t,e){let r=S(t),o=T(s,e),a=y.get(o),l=a?.signatures.get(r),u=a?.modules.has(r)??!1,m=v.get(o);m&&await m;let c=y.get(o);if(!c)return!1;let d=c.modules.has(r);try{let n=await G(r,{bigint:!0}),i=`${n.dev}:${n.ino}:${n.size}:${n.mtimeNs}:${n.ctimeNs}`;if(c.signatures.get(r)===i)return l!==i;let f=await W(r,"utf8"),p=/\.(?:md|mdx)$/i.test(r);if(p&&!f.includes(e.importSource??"@cssxio/cssx"))return c.modules.delete(r),c.signatures.set(r,i),d;let h=p?await X(f,s,e.mdx):f,O=e.stableClassNames||e.naming==="source",C={...e};delete C.coordination,delete C.manifestPath,delete C.classNameAllocator;let P=await M(h,p?`${r}.tsx`:r,{...C,classNameAllocator:c.allocator,stableClassNames:O,...O?{stableClassNameFileName:D(s,r,e.mode==="development")}:{}},void 0,{compileCss:!1});return P?c.modules.set(r,{id:r,candidates:P.candidates,composites:P.composites,atomicClasses:P.atomicClasses,origins:P.origins}):c.modules.delete(r),c.signatures.set(r,i),d||P!==null}catch(n){if(n.code==="ENOENT")return c.signatures.delete(r),c.modules.delete(r),d||u;throw n}}async function Ct(s,t,e,r){let o=new Set([s,...t,...e.map(l=>Me(l.id)),...r?[Me(r)]:[]]),a=[];for(let l of o){let u=A(l);if(!Q(u,t))try{await dt(u),a.push(u)}catch(m){if(m.code==="ENOENT")continue;throw m}}return a}function St(s){return xt.has(s)}var I=new Map;export{X as a,bs as b,D as c,Pe as d,Q as e,M as f,ps as g,$e as h,Qs as i,Gs as j,ft as k,Hs as l,Ks as m,Ys as n};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as A,b as se}from"./chunk-7X733NFU.js";import{a as b,c as q}from"./chunk-663P2VZO.js";import{c as te}from"./chunk-AJOXGQDA.js";import{b as z,c as G,d as K,e as Q,f as Z,h as ee}from"./chunk-3C7SCOHD.js";import{a as V,b as M,e as U,f as Y,h as _,i as j}from"./chunk-GPHROS5Y.js";import{createClassNameAllocator as pe}from"@cssxio/compiler";import{Buffer as ae}from"buffer";import{mkdir as he,readFile as oe,unlink as ie,writeFile as le}from"fs/promises";import{basename as ce,dirname as ge,resolve as F}from"path";async function ne(r,o){let i=await M(o);return b(r.map(([,u])=>u),i,o.layer,o.sourceMap??!0,o.darkMode,o.preflight)}function re(r){return/\.tsx?$/.test(r)?"ts":"js"}var ye=/\.[cm]?[jt]sx?$/,Se=64,me=16*1024*1024;function we(r={}){if(V(r),r.classNameAllocator&&r.className)throw new Error("CSSX classNameAllocator owns naming. Omit className when supplying a custom allocator.");let o=new Map,i=r.mode==="development",u=r.classNameAllocator??pe(i?{...r.className,variant:"random"}:_(r)),p,v;return{name:"@cssxio/unplugin",setup(d){let l=d.initialOptions.absWorkingDir??process.cwd(),B=r.sourceRoots?.map(e=>F(l,e)),h=j(r);d.initialOptions.metafile=!0;let f,g,k=0,N=0,R,H,D,E=-1,$,C,P=new Map,L=new WeakMap,S=new Map,T=0,x=e=>{let s=S.get(e);s&&(T-=s.size,S.delete(e))},de=(e,s,t)=>{let n=(s.length+t.code.length)*2;if(n>me){x(e);return}for(x(e);S.size>=Se||T+n>me;){let a=S.keys().next().value;if(a===void 0)break;x(a)}S.set(e,{sourceSignature:A(s),result:t,size:n}),T+=n},X=(e,s)=>{if(!s){let m=o.delete(e);return P.delete(e),x(e),C?.unwatch(e),m}let t={id:e,candidates:s.candidates,composites:s.composites,atomicClasses:s.atomicClasses,origins:s.origins},n=JSON.stringify([t.candidates,t.composites,t.atomicClasses,t.origins]),a=o.get(e),y=a===void 0||L.get(a)!==n;return L.set(t,n),o.set(e,t),P.set(e,s.cssOnlySignature),te({...t,rules:[]})?C?.watch(e):C?.unwatch(e),y},J=async e=>{let s=await g;if(!s||!f)return;let t=q(e,"generated.css");t!==H&&(await s.publishNextDevelopmentStylesheet(f,t),H=t)},I=()=>!i||k===0||!g?Promise.resolve():(N++,R||(R=new Promise(e=>setImmediate(e)).then(async()=>{let e=-1;do{e=N;let s=await M(r,l),t=await b([...o.values()],s,h.layer,h.sourceMap,r.darkMode,r.preflight);D=t,E=e,$=s,await J(t)}while(e!==N)}).catch(e=>{console.warn(`CSSX: esbuild stylesheet update failed: ${e instanceof Error?e.message:String(e)}`)}).finally(()=>{R=void 0})),R),fe=async e=>{if(!f)return;let s=P.get(e);if(s)try{let t=await oe(e,"utf8");if(S.get(e)?.sourceSignature===A(t))return;let n=await ue(t,e,l,r,i,u);if(!n||n.cssOnlySignature!==s){x(e);return}let a=X(e,n);de(e,t,n),a&&await I()}catch(t){t.code!=="ENOENT"&&console.warn(`CSSX: esbuild stylesheet update failed: ${t instanceof Error?t.message:String(t)}`)}};if(i){let e=F(l,".cssx/esbuild.css");C=se(fe,void 0,"esbuild watcher"),g=import("@cssxio/unplugin/internal/development-runtime").then(s=>(f=s.startNextDevelopmentServer(l,e),s)),g=g.catch(s=>{console.warn(`CSSX: esbuild development runtime failed: ${String(s)}`)}),d.onDispose(()=>{g?.then(s=>s?.stopNextDevelopmentServer(l)),C?.close(),C=void 0,S.clear(),T=0,P.clear(),f=void 0})}d.onLoad({filter:ye},async({path:e})=>{let s=await g;if(Q(e,B))return;let t=await oe(e,"utf8"),n=await z(e),a=S.get(n),y=i&&a?.sourceSignature===A(t),m=y?a.result:await ue(t,e,l,r,i,u);if(y&&x(n),!m){let O=i?X(n,null):o.delete(n);i&&O&&await I();return}let w=i?X(n,m):!0;return i||o.set(n,{id:n,candidates:m.candidates,composites:m.composites,atomicClasses:m.atomicClasses,origins:m.origins}),i&&k>0&&w&&!y&&await I(),{contents:f?`${m.code}
|
|
2
|
+
${s?.nextDevelopmentStylesheetHmr(f,r.cssFileName??"cssx.css")}`:m.code,loader:re(e),...r.themeFile?{watchFiles:[F(l,r.themeFile)]}:{}}}),d.onEnd(async e=>{if(k++,e.errors?.length||!e.metafile)return;let s=new Set(await Promise.all(Object.keys(e.metafile.inputs).map(c=>z(F(l,c))))),t=!1;for(let c of o.keys())s.has(c)||(o.delete(c),P.delete(c),x(c),C?.unwatch(c),t=!0);t&&(E=-1);let n;if(i){await R;let c=await M(r,l);n=!t&&D!==void 0&&E===N&&$===c?D:await b([...o.values()],c,h.layer,h.sourceMap,r.darkMode,r.preflight),D=n,E=N,$=c;try{await J(n)}catch(W){console.warn(`CSSX: esbuild stylesheet update failed: ${W instanceof Error?W.message:String(W)}`)}}else{let c=r.coordination==="manifest"?(await ee(l,r)).map(O=>[O.id,O]):[...o];n=await ne(c,r)}let a=Y(l,d.initialOptions,U(r.cssFileName??"cssx.css",n.css));if(!n.css){p&&await ie(p).catch(()=>{}),v&&await ie(v).catch(()=>{}),p=void 0,v=void 0;return}let y=n.map?`${n.css}
|
|
3
|
+
/*# sourceMappingURL=${ce(a)}.map */`:n.css,m=`${a}.map`,w=n.map?JSON.stringify({...n.map,file:ce(a)}):void 0;if(d.initialOptions.write===!1){if(!e.outputFiles)return;if(e.outputFiles.some(c=>c.path===a))throw new Error(`CSSX CSS asset collision at "${a}".`);e.outputFiles.push({path:a,contents:ae.from(y),hash:"",text:y}),w&&e.outputFiles.push({path:m,contents:ae.from(w),hash:"",text:w});return}await he(ge(a),{recursive:!0}),await le(a,y),w&&await le(m,w),p=a,v=w?m:void 0})}}}async function ue(r,o,i,u,p,v){let d=p||u.stableClassNames||u.naming==="source",l=p?j(u):void 0,h={...{...l??u,stableClassNames:d,className:l?l.className:_(u),...d?{stableClassNameFileName:G(i,o,p)}:{},classNameAllocator:v}};delete h.coordination,delete h.manifestPath;let f=g=>Z(r,o,{...h,classNameAllocator:g},void 0,{compileCss:!1});return!p&&u.coordination==="manifest"?K(u.manifestPath,h.className,f):f(v)}export{we as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{compileUtilities as k,createSelectorAliases as j}from"@cssxio/compiler";var M='*,::before,::after,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-text-size-adjust:100%;tab-size:4;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:transparent;opacity:1}button,select{text-transform:none}button,input:where([type="button"],[type="reset"],[type="submit"]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit}textarea{resize:vertical}::placeholder{opacity:1}button,[role="button"]{cursor:pointer}:disabled{cursor:default}[hidden]:where(:not([hidden="until-found"])){display:none!important}';function C(t,i){let o=i.split(`
|
|
2
|
+
`);return{line:t.line+o.length-1,column:o.at(-1).length+t.column*+(o.length===1)}}var $="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function f(t){let i="",o=t<0?-t<<1|1:t<<1;do{let r=o&31;o>>>=5,o&&(r|=32),i+=$[r]}while(o);return i}function w(t){let i=Array.from({length:Math.max(0,...t.map(e=>e.line))+1},()=>[]),o=0,r=0,p=0,c=0,s=0;for(let e of t)s*=+(e.line===c),c=e.line,i[e.line]?.push(`${f(e.column-s)}${f(e.source-o)}${f(e.originalLine-r)}${f(e.originalColumn-p)}`),s=e.column,o=e.source,r=e.originalLine,p=e.originalColumn;return i.map(e=>e.join(",")).join(";")}function v(t,i,o){let r=[...new Set(i.map(e=>o.get(e.candidate)?.id).filter(e=>!!e))].sort();if(r.length===0)return;let p=new Map(r.map((e,l)=>[e,l])),c=[],s=C({line:0,column:0},t);for(let e of i){let l=o.get(e.candidate);l&&c.push({...s,source:p.get(l.id),originalLine:l.line,originalColumn:l.column}),s=C(s,e.css)}return{version:3,sources:r,names:[],mappings:w(c)}}async function T(t,i,o,r=!0,p,c=!0){let s=Object.create(null),e=Object.create(null),l=new Set,y=!0,g=new Map;for(let a of[...t].sort((n,u)=>n.id.localeCompare(u.id))){for(let[n,u]of Object.entries(a.candidates))if(n in s||(s[n]=u),a.id&&!g.has(n)){let d=a.origins?.[n];g.set(n,{id:a.id,line:d?.line??0,column:d?.column??0})}for(let[n,u]of Object.entries(a.composites??{})){let d=e[n];if(d&&d.join(" ")!==u.join(" "))throw new Error(`CSSX composite class collision for "${n}".`);e[n]=u}a.atomicClasses===void 0&&(y=!1);for(let n of a.atomicClasses??[])l.add(n)}let x=Object.keys(s).sort(),m=c?M:"";if(x.length===0)return{css:m&&o?`@layer ${o}{${m}}`:m};let h=await k(x,a=>s[a],i,j(e),y?l:void 0,{darkMode:p}),b=o?`@layer ${o}{`:"",L=`${b}${m}${h.css}${b?"}":""}`,S=r?v(`${b}${m}${h.prefixCss}`,h.entries,g):void 0;return{css:L,...S?{map:S}:{}}}import{basename as O}from"path";function _(t,i){return t.map?`${t.css}
|
|
3
|
+
/*# sourceMappingURL=${O(i)}.map */`:t.css}function B(t,i){return JSON.stringify({...t,file:i})}export{T as a,B as b,_ as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{watch as x}from"fs";import{dirname as T,resolve as u}from"path";var D=8,E=256,f=0;function B(a,w=x,v="Vite's watcher"){let o=new Map,i=new Map,n=new Map,g=!1,p=t=>{let e=n.get(t);e&&(clearTimeout(e),n.delete(t))},d=(t,e)=>{if(o.get(t)===e){o.delete(t),f--,e.watcher.close();for(let r of e.ids)i.delete(r),p(r);e.ids.clear()}},W=t=>{n.has(t)||n.size>=E||n.set(t,setTimeout(()=>{n.delete(t),a(t)},2))},m=t=>{g=!0;for(let[e,r]of o)d(e,r);console.warn(`CSSX: native source watcher failed; using ${v}: ${t.message}`)};return{close:()=>{for(let[t,e]of o)d(t,e);i.clear();for(let t of n.values())clearTimeout(t);n.clear()},unwatch:t=>{let e=u(t);p(e);let r=i.get(e);if(!r)return;i.delete(e);let s=o.get(r);s?.ids.delete(e),s&&s.ids.size===0&&d(r,s)},watch:t=>{let e=u(t);if(g||i.has(e))return;let r=T(e),s=o.get(r);if(!s){if(f>=D)return;try{let c=new Set,y=w(r,{persistent:!1},(S,l)=>{let C=l===null?[...c]:[u(r,l.toString())].filter(h=>c.has(h));for(let h of C)W(h)});s={watcher:y,ids:c},o.set(r,s),f++,y.on("error",S=>{o.get(r)===s&&m(S)})}catch(c){m(c instanceof Error?c:new Error(String(c)));return}}s.ids.add(e),i.set(e,r)}}}import{createHash as M}from"crypto";function $(a){return M("sha256").update(a).digest("hex")}export{$ as a,B as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s="@cssxio/unplugin/rules";function t(){return{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""}}function o(e){return e.rules.length>0||Object.keys(e.candidates).length>0||Object.keys(e.composites??{}).length>0}export{s as a,t as b,o as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as g,b as $,c as x}from"./chunk-663P2VZO.js";import{a as T}from"./chunk-NTKLI2V7.js";import{h as H,l as k,m as P,n as E}from"./chunk-3C7SCOHD.js";import{b as C}from"./chunk-GPHROS5Y.js";import{Buffer as M}from"buffer";import{mkdirSync as j}from"fs";import{readFile as v}from"fs/promises";import{createServer as B}from"http";import{dirname as F,resolve as h}from"path";var S=new Map,D=new Map,G=64;function oe(e,t){let r=h(e),i=S.get(r);if(i)return i.references++,i.connection;let l=T(r,t),o=new Set,a=h(t);j(F(a),{recursive:!0});let s={connection:l,stylesheetFile:a,revision:0,ready:!1,clients:o,blockedClients:new Set,references:1},d=B((c,n)=>{let f=new URL(c.url??"/","http://127.0.0.1").pathname,u=`/${l.token}`;if(c.method==="OPTIONS"){n.writeHead(204,m()),n.end();return}if(c.method==="POST"&&f===`${u}/publish`){J(c).then(p=>c.headers["x-cssx-inline"]==="1"?p:v(a,"utf8")).then(p=>{O(s,p),n.writeHead(204,m()),n.end()},()=>{n.writeHead(503,m()),n.end()});return}if(c.method==="GET"&&f===`${u}/ready`){n.writeHead(s.ready?200:503,m()),n.end();return}if(c.method==="GET"&&f===`${u}/events`){if(o.size>=G){n.writeHead(503,{...m(),"Retry-After":"1"}),n.end();return}n.writeHead(200,{...m(),"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache, no-transform",Connection:"keep-alive"}),o.add(n),R(s,n),c.on("close",()=>{o.delete(n),s.blockedClients.delete(n)});return}if(c.method==="GET"&&f===`${u}/stylesheet`){(s.latestCss===void 0?v(a,"utf8"):Promise.resolve(s.latestCss)).then(p=>{n.writeHead(200,{...m(),"Content-Type":"text/css; charset=utf-8","Cache-Control":"no-store"}),n.end(p)},()=>{n.writeHead(503,{...m(),"Cache-Control":"no-store"}),n.end("CSSX development stylesheet is not ready.")});return}if(c.method==="GET"&&f===`${u}/generated.css.map`){v(`${a}.map`,"utf8").then(p=>{n.writeHead(200,{...m(),"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),n.end(p)},()=>{n.writeHead(404,m()),n.end()});return}n.writeHead(404,m()),n.end()});return d.on("error",c=>{console.warn(`CSSX: development stylesheet transport unavailable on port ${l.port}: ${c.message}`)}),s.server=d,d.listen(l.port,"127.0.0.1"),d.unref(),S.set(r,s),D.set(b(l),s),l}function ie(e){let t=S.get(h(e));if(t){if(t.references>1){t.references--;return}for(let r of t.clients)r.end();t.blockedClients.clear(),t.server?.close(),S.delete(h(e)),D.delete(b(t.connection))}}async function N(e,t){let r=D.get(b(e));if(r){let a=t??await v(r.stylesheetFile,"utf8");O(r,a);return}let i=`http://127.0.0.1:${e.port}/${e.token}/publish`,l={method:"POST",...t===void 0?{}:{body:t,headers:{"X-CSSX-Inline":"1"}}},o;for(let a=0;a<20;a++){try{let s=await fetch(i,l);if(s.status===204)return;o=new Error(`Unexpected HTTP status ${s.status}.`)}catch(s){o=s}await new Promise(s=>setTimeout(s,25))}throw new Error(`CSSX development stylesheet transport did not become available: ${String(o)}`)}function J(e){return new Promise((t,r)=>{let i=[];e.on("data",l=>i.push(M.from(l))),e.on("end",()=>t(M.concat(i).toString("utf8"))),e.on("error",r)})}async function se(e){let t=`http://127.0.0.1:${e.port}/${e.token}/ready`;for(let r=0;r<300;r++){try{if((await fetch(t,{cache:"no-store"})).ok)return}catch{}await new Promise(i=>setTimeout(i,100))}throw new Error("CSSX Next.js development stylesheet did not become ready within 30 seconds.")}function O(e,t){if(e.ready&&e.latestCss===t)return;e.revision++,e.ready=!0,e.latestCss=t;let r=`data: ${JSON.stringify({revision:e.revision,css:t})}
|
|
2
|
+
|
|
3
|
+
`;for(let i of e.clients)I(e,i,r)}function R(e,t){I(e,t,`data: ${JSON.stringify({revision:e.revision,css:e.latestCss})}
|
|
4
|
+
|
|
5
|
+
`)}function I(e,t,r){e.blockedClients.has(t)||t.write(r)||(e.blockedClients.add(t),t.once("drain",()=>{e.blockedClients.delete(t),e.clients.has(t)&&R(e,t)}))}function b(e){return`${e.port}:${e.token}`}function m(){return{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type, X-CSSX-Inline"}}import{randomUUID as L}from"crypto";import{mkdir as U,readFile as W,rename as _,unlink as z,writeFile as K}from"fs/promises";import{dirname as V,resolve as Q}from"path";var w=new Map;function Se(e,t,r,i,l){let o=Q(e),a=w.get(o);if(a)return a;let s=(async()=>{k(o,r);let d;try{let c=await H(o,r),n=await Y(o,t,r,c);await N(i,n),d=await E(o,r,async u=>{let p=await C(r,o),A=await g(u,p,r.layer,r.sourceMap,r.darkMode,r.preflight),y=x(A,"generated.css");y!==n&&(await N(i,y),n=y)},l);let f=!1;return()=>{f||(f=!0,d?.(),P(o,r),w.delete(o))}}catch(c){throw d?.(),P(o,r),c}})();return w.set(o,s),s.catch(d=>{console.warn(`CSSX: Next development coordinator could not start: ${d instanceof Error?d.message:String(d)}`),w.delete(o)}),s}async function Y(e,t,r,i){let l=await C(r,e),o=await g(i,l,r.layer,r.sourceMap,r.darkMode,r.preflight);await U(V(t),{recursive:!0});let a=x(o,"generated.css");return await X(t,a),o.map&&await X(`${t}.map`,$(o.map,"generated.css")),a}async function X(e,t){try{if(await W(e,"utf8")===t)return!1}catch(i){if(i.code!=="ENOENT")throw i}let r=`${e}.${process.pid}.${L()}.tmp`;try{return await K(r,t),await _(r,e),!0}catch(i){throw await z(r).catch(()=>{}),i}}export{oe as a,ie as b,N as c,se as d,Se as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAbsolute as u,normalize as c,sep as f}from"path";function a(e){if(!e||u(e))throw new Error("cssFileName must be a non-empty relative path.");let r=c(e);if(r===".."||r.startsWith(`..${f}`))throw new Error("cssFileName must not escape the bundler output directory.");if(!r.endsWith(".css"))throw new Error("cssFileName must end in .css.");return r}function g(e){if(e.mode!==void 0&&e.mode!=="development"&&e.mode!=="production")throw new Error('CSSX mode must be "development" or "production".');if(e.stableClassNameStrategy!==void 0&&e.stableClassNameStrategy!=="source-location"&&e.stableClassNameStrategy!=="module-order")throw new Error('CSSX stableClassNameStrategy must be "source-location" or "module-order".');if(e.sourceRoots&&e.sourceRoots.some(t=>typeof t!="string"||!t.trim()))throw new Error("CSSX sourceRoots must contain non-empty file-system paths.");let r=e.debug;if(r===null||r!==void 0&&typeof r!="boolean"&&(typeof r!="object"||typeof r.reportFile!="string"||!r.reportFile))throw new Error("CSSX debug must be a boolean or an object with a reportFile path.");if(e.naming!==void 0&&!["serial","hash","source"].includes(e.naming))throw new Error('CSSX naming must be "serial", "hash", or "source".');if(e.coordination!==void 0&&!["memory","manifest"].includes(e.coordination))throw new Error('CSSX coordination must be "memory" or "manifest".');if(e.stableClassNames&&e.naming&&e.naming!=="source")throw new Error('CSSX stableClassNames selects source naming and conflicts with naming. Use naming: "source".');if(e.stableClassNames&&e.coordination==="manifest")throw new Error("CSSX stableClassNames already selects source naming; remove it to use manifest coordination.");if(e.naming==="hash"&&e.className?.variant==="serial")throw new Error('CSSX naming: "hash" conflicts with className.variant: "serial".');if(e.naming==="serial"&&e.className?.variant==="random")throw new Error('CSSX naming: "serial" conflicts with className.variant: "random".');if(e.coordination==="manifest"&&!e.manifestPath)throw new Error('CSSX coordination: "manifest" requires manifestPath.');if(e.manifestPath&&e.coordination!=="manifest")throw new Error('CSSX manifestPath requires coordination: "manifest".');if(e.coordination==="manifest"&&e.classNameAllocator)throw new Error("CSSX manifest coordination cannot use a custom classNameAllocator.");if(e.theme!==void 0&&e.themeFile!==void 0)throw new Error("CSSX accepts either theme or themeFile, not both.");if(e.layer!==void 0&&!/^[A-Za-z_-][A-Za-z0-9_-]*$/.test(e.layer))throw new Error("CSSX layer must be a valid CSS layer identifier.");if(e.sourceMap!==void 0&&typeof e.sourceMap!="boolean")throw new Error("CSSX sourceMap must be a boolean.");if(e.darkMode!==void 0&&e.darkMode!=="media"&&e.darkMode!=="selector"&&e.darkMode!=="class")throw new Error('CSSX darkMode must be "media", "selector", or "class".');if(e.preflight!==void 0&&typeof e.preflight!="boolean")throw new Error("CSSX preflight must be a boolean.");if(e.reusabilityBudget!==void 0&&e.reusabilityBudget!=="auto"&&(!Number.isFinite(e.reusabilityBudget)||e.reusabilityBudget<0||e.reusabilityBudget>100))throw new Error('CSSX reusabilityBudget must be "auto" or a number from 0 through 100.');a(e.cssFileName??"cssx.css")}import{readFile as h,stat as y}from"fs/promises";import{resolve as b}from"path";var d=new Map;async function C(e,r=process.cwd()){if(e.themeFile===void 0)return e.theme;let t=b(r,e.themeFile),n=await y(t,{bigint:!0}),i=`${n.dev}:${n.ino}:${n.size}:${n.mtimeNs}:${n.ctimeNs}`,l=d.get(t);if(l?.signature===i)return l.source;let m=await h(t,"utf8");return d.set(t,{signature:i,source:m}),m}function w(e){return e.replaceAll("\\","/").split("?",1).join("")}function o(e){let r=2166136261;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return(r>>>0).toString(36)}function p(e,r){return a(e).replaceAll("[hash]",o(r))}import{dirname as S,resolve as s}from"path";function N(e,r,t){return r.outdir?s(e,r.outdir,t):r.outfile?s(S(s(e,r.outfile)),t):s(e,t)}import{sep as x}from"path";function v(e,r){return`${e&&e!=="/"?`/${E(e)}`:""}/${a(r).replaceAll(x,"/")}`}function E(e){let r=0,t=e.length;for(;e.charCodeAt(r)===47;)r++;for(;t>r&&e.charCodeAt(t-1)===47;)t--;return e.slice(r,t)}function W(e){let r=e.naming==="hash"?"random":e.naming==="serial"?"serial":void 0;if(r&&e.className?.variant&&e.className.variant!==r)throw new Error(`CSSX naming: "${e.naming}" conflicts with className.variant: "${e.className.variant}".`);return{...e.className,...r?{variant:r}:{}}}function Z(e){return{...e,mode:"development",sourceMap:e.sourceMap??!1,naming:"source",stableClassNames:!0,stableClassNameStrategy:"module-order",reusabilityBudget:0,className:{...e.className,variant:"random"},classNameAllocator:void 0,coordination:"memory",manifestPath:void 0}}function U(e,r={}){return e.mode!==void 0?e.mode==="development":process.env.NODE_ENV==="development"||r.watchMode===!0||r.bundlerMode==="development"||r.viteDevServer===!0}export{g as a,C as b,w as c,o as d,p as e,N as f,v as g,W as h,Z as i,U as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as o}from"path";function m(n,t){let e=o(n);return{port:r(e),token:i(`${e}:${t}`)}}function r(n){let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return 4e4+(t>>>0)%2e4}function i(n){let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(36)}export{m as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function b(c,g,t){let p=t.naming??(t.stableClassNames?"source":t.className?.variant==="random"?"hash":t.className?.variant??"serial"),f=t.stableClassNames?"stableClassNames compatibility option selects source-addressed composites":t.naming?"explicit naming option":t.className?.variant?"className.variant option":"default serial naming",i=new Map,m=new Map;for(let e of[...c].sort((n,s)=>n.id.localeCompare(s.id))){let n=new Map;for(let[s,o]of Object.entries(e.candidates)){let r=m.get(s)??new Set;r.add(o),m.set(s,r);let a=i.get(o)??{module:e.id,utilities:new Set,line:e.origins?.[s]?.line??0,column:e.origins?.[s]?.column??0};a.utilities.add(s),i.set(o,a);let l=n.get(o)??[];l.push(s),n.set(o,l)}for(let[s,o]of Object.entries(e.composites??{})){let r=o.flatMap(d=>n.get(d)??[]),a=r[0],l=i.get(s)??{module:e.id,utilities:new Set,line:a?e.origins?.[a]?.line??0:0,column:a?e.origins?.[a]?.column??0:0};for(let d of r)l.utilities.add(d);i.set(s,l)}for(let s of e.atomicClasses??[])i.has(s)||i.set(s,{module:e.id,utilities:new Set,line:0,column:0})}let y=[...i].sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>({className:e,module:n.module,utilities:[...n.utilities].sort(),line:n.line+1,column:n.column+1,selectorFound:new RegExp(`\\.${C(e)}(?:[^A-Za-z0-9_-]|$)`).test(g)})),u=[...m].filter(([,e])=>e.size>1).map(([e])=>e).sort();return{version:1,naming:{mode:p,reason:f},coordination:{mode:t.coordination??"memory",...t.coordination==="manifest"&&t.manifestPath?{manifestPath:t.manifestPath}:{}},classes:y,serverClientMappings:{status:u.length>0?"mismatch":t.coordination==="manifest"?"manifest-shared":"consistent-in-process",conflicts:u}}}function C(c){return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{b as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as G,b as j,c as q,e as K}from"./chunk-ART2XI6B.js";import{a as Y}from"./chunk-URWMD4HY.js";import{a as b,b as E,c as D}from"./chunk-663P2VZO.js";import{a as z}from"./chunk-VJ4HYXVU.js";import{a as F,b as T}from"./chunk-AJOXGQDA.js";import{h as N,k as L}from"./chunk-3C7SCOHD.js";import{a as W,b as _,c as M,e as P,f as X,h as B,i as k,j as O}from"./chunk-GPHROS5Y.js";import{createClassNameAllocator as ie}from"@cssxio/compiler";import{createUnplugin as he}from"unplugin";import{Buffer as ae}from"buffer";import{mkdir as le,unlink as de,writeFile as ue}from"fs/promises";import{basename as ce,dirname as me,resolve as J}from"path";function Q(e){let{options:i,cssFileName:d,sourceMap:v,dataById:r,getTheme:u}=e,g,o=process.cwd(),y,h,a,S=i.mode==="development",n=S?k(i):i;return{config(s){s.metafile=!0},setup(s){if(o=s.initialOptions.absWorkingDir??process.cwd(),S){let c=J(o,".cssx/esbuild.css");a=import("@cssxio/unplugin/internal/development-runtime").then(m=>{y=m.startNextDevelopmentServer(o,c),h=m.startDevelopmentCoordinator(o,c,n,y),h.catch(f=>{console.warn(`CSSX: esbuild development coordinator failed: ${String(f)}`)})}),a.catch(m=>{console.warn(`CSSX: esbuild development coordinator failed: ${String(m)}`)}),s.onDispose(()=>{a?.then(async()=>{await h?.then(f=>f(),()=>{});let{stopNextDevelopmentServer:m}=await import("@cssxio/unplugin/internal/development-runtime");m(o)},async()=>{let{stopNextDevelopmentServer:m}=await import("@cssxio/unplugin/internal/development-runtime");m(o)}),y=void 0})}s.onEnd(async c=>{if(c.errors?.length||!c.metafile)return;let m=new Set(Object.keys(c.metafile.inputs).map(l=>J(o,l)));for(let l of r.keys())m.has(l)||r.delete(l);let f=!S&&i.coordination==="manifest"?await N(o,i):[...r.values()],x=await b(f,await u(),n.layer,v,n.darkMode,n.preflight),p=X(o,s.initialOptions,P(d,x.css));if(!x.css){g&&await de(g).catch(()=>{}),g=void 0;return}let t=D(x,ce(p));if(s.initialOptions.write===!1){let l=c.outputFiles;if(!l)return;let C={path:p,contents:ae.from(t),hash:"",text:t};if(l.some(w=>w.path===p))throw new Error(`CSSX CSS asset collision at "${p}".`);l.push(C);return}await le(me(p),{recursive:!0}),await ue(p,t),g=p})},getWorkingDirectory:()=>o,getDevelopmentHmrConnection:async()=>(await a,y)}}function Z(e,i=()=>!1,d){return async function(r){let u=this.environment;if(!u)return;let g=r.modules,o=g.filter(n=>{let s=e.get(M(n.id??""));return!!(s&&s.cssOnlySignature)});if(o.length===0)return;let y=typeof r.read=="function"?await r.read():void 0,h=new Set(y===void 0?[]:o.filter(n=>i(M(n.id),y))),a=new Map(o.map(n=>[n,e.get(M(n.id)).cssOnlySignature]));if(d){for(let n of o)if(!(y===void 0?await d(n.id):await d(n.id,y)))if(n.url)await u.transformRequest(n.url);else continue}else for(let n of o)!h.has(n)&&n.url&&await u.transformRequest(n.url);if(o.every(n=>{let s=e.get(M(n.id));return!!(s&&s.cssOnlySignature===a.get(n))}))return g.filter(n=>!o.includes(n))}}import{resolve as ge}from"path";import{mkdir as pe,writeFile as fe}from"fs/promises";import{dirname as ye,resolve as ve}from"path";function ee(e,i){let d=new Map,v=[];for(let r of i)r.id?d.set(r.id,r):v.push(r);for(let r of e)r.id?d.set(r.id,r):v.push(r);return[...d.values(),...v]}function te(e,i){let d=e.buildInfo?.[i];if(!d||typeof d!="object")return;let{id:v,candidates:r,composites:u,atomicClasses:g,origins:o}=d;return{id:typeof v=="string"?v:"",candidates:r&&typeof r=="object"?r:{},composites:u&&typeof u=="object"?u:{},...Array.isArray(g)?{atomicClasses:g}:{},origins:o&&typeof o=="object"?o:{}}}function oe(e,i,d,v,r,u,g,o,y=!0,h,a,S){let n=e.name??e.options?.name;n==="server"||n==="edge-server"||e.hooks.thisCompilation.tap("@cssxio/unplugin",s=>{s.hooks.processAssets.tapPromise({name:"@cssxio/unplugin",stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},async()=>{let c=h?await h():ee([...s.modules].map(p=>te(p,u)).filter(p=>p!==void 0),g?.values()??[]),m=await b(c,await d(),v,r,o,y);if(a?.debug){let p=Y(c,m.css,a);if(a.debug===!0)console.info(`CSSX: ${p.naming.mode} naming; ${p.classes.filter(t=>t.selectorFound).length}/${p.classes.length} generated classes have selectors; compiler mappings ${p.serverClientMappings.status}${p.serverClientMappings.conflicts.length?` (${p.serverClientMappings.conflicts.length} utility conflicts)`:""}.`);else{let t=ve(e.context,a.debug.reportFile);await pe(ye(t),{recursive:!0}),await fe(t,`${JSON.stringify(p,null,2)}
|
|
2
|
+
`,"utf8")}}if(!m.css){await S?.(D(m,i));return}let f=P(i,m.css),x=D(m,f);if(s.getAsset?.(f))throw new Error(`CSSX CSS asset collision at "${f}".`);if(await S?.(x),s.emitAsset(f,new e.webpack.sources.RawSource(x)),m.map){let p=`${f}.map`;if(s.getAsset?.(p))throw new Error(`CSSX CSS map asset collision at "${p}".`);s.emitAsset(p,new e.webpack.sources.RawSource(E(m.map,f)))}})})}function $({compiler:e,options:i,cssFileName:d,sourceMap:v,getTheme:r}){let u=z(e.context,i),g=O(i,{watchMode:e.watchMode,bundlerMode:e.options?.mode}),o=g?k(i):i,y=o.sourceMap??v,h;if(g){let a=0;e.hooks?.watchRun?.tap("@cssxio/unplugin",S=>{a++;for(let f of S.removedFiles??[])u.transformedDataById.delete(M(f));if(process.env.NODE_ENV==="test"||h)return;let n=ge(e.context,".cssx/native.css"),s=G(e.context,n);u.developmentHmr=s,h=K(e.context,n,o,s);let c=0,m;u.notifyDevelopmentStylesheet=()=>a<=1||u.developmentHmr!==s?Promise.resolve():(c++,m||(m=new Promise(f=>setImmediate(f)).then(async()=>{let f=-1;do{f=c;let x=L(e.context,o),p=await b(x??[...u.transformedDataById.values()],await r(),o.layer,y,o.darkMode,o.preflight),t=D(p,"generated.css");u.developmentHmr===s&&u.developmentStylesheet!==t&&(await q(s,t),u.developmentStylesheet=t)}while(f!==c)}).catch(f=>{console.warn(`CSSX: native development stylesheet update failed: ${f instanceof Error?f.message:String(f)}`)}).finally(()=>{m=void 0})),m),h.catch(f=>{console.warn(`CSSX: native development coordinator failed: ${String(f)}`)})})}g&&e.hooks?.watchClose?.tap("@cssxio/unplugin",()=>{h?.then(a=>{a(),j(e.context),u.developmentHmr=void 0,u.developmentStylesheet=void 0},()=>{j(e.context),u.developmentHmr=void 0,u.developmentStylesheet=void 0}),u.notifyDevelopmentStylesheet=void 0}),oe(e,d,r,o.layer,y,F,u.transformedDataById,o.darkMode,o.preflight,!g&&(i.stableClassNames||i.naming==="source"||i.coordination==="manifest")?()=>N(e.context,i):void 0,o)}function re(e){if(!e||typeof e!="object")return T();let{id:i,rules:d,candidates:v,composites:r,atomicClasses:u,origins:g,cssOnlySignature:o}=e;return{id:typeof i=="string"?i:"",rules:Array.isArray(d)?d:[],candidates:v&&typeof v=="object"?v:{},composites:r&&typeof r=="object"?r:{},...Array.isArray(u)?{atomicClasses:u}:{},origins:g&&typeof g=="object"?g:{},cssOnlySignature:typeof o=="string"?o:""}}function ne(e){return!e||typeof e!="object"?T():re(e[F])}function se(e){return async function(i,d){let{framework:v,options:r,cssFileName:u,sourceMap:g,rollupDataById:o,getTheme:y}=e,h=O(r,{watchMode:this.meta?.watchMode})?k(r):r,a=new Set(Object.values(d).flatMap(c=>c.type==="chunk"?Object.keys(c.modules??{}):[]).map(M));if(v!=="vite")for(let c of o.keys())a.has(c)||o.delete(c);let S=h.coordination==="manifest"?await N(process.cwd(),h):v==="vite"?[...o.values()]:[...a].map(c=>{let m=ne(this.getModuleInfo(c)?.meta);return Object.keys(m.candidates).length>0?m:o.get(c)??m}),n=await b(S,await y(),h.layer,g,h.darkMode,h.preflight);if(!n.css)return;let s=P(u,n.css);if(Object.hasOwn(d,s))throw new Error(`CSSX CSS asset collision at "${s}".`);if(this.emitFile({type:"asset",fileName:s,source:D(n,s)}),n.map){let c=`${s}.map`;if(Object.hasOwn(d,c))throw new Error(`CSSX CSS map asset collision at "${c}".`);this.emitFile({type:"asset",fileName:c,source:E(n.map,s)})}}}var U=/\.(?:[cm]?[jt]sx?|astro|vue|mdx?)(?=\?|$)/,Se=(e={},i)=>{if(W(e),e.classNameAllocator&&e.className)throw new Error("CSSX classNameAllocator owns naming. Omit className when supplying a custom allocator.");let d=e.cssFileName??"cssx.css",v=e.sourceMap??!0,r=new Map,u=e.classNameAllocator??ie(B(e)),g=e.classNameAllocator??ie(B(k(e))),o=new Map,y,h,a,S=process.cwd(),n,s=()=>_(e,S),c=Q({options:e,cssFileName:d,sourceMap:v,dataById:o,getTheme:s}),m=se({framework:i.framework,options:e,cssFileName:d,sourceMap:v,rollupDataById:r,getTheme:s}),f=()=>y?.notifyStyles()??Promise.resolve(),x=()=>a?.then(t=>t.notifyStyles())??Promise.resolve(),p=()=>(h??=import("@cssxio/unplugin/internal/transform-runtime").then(({createTransformHandler:t})=>t({framework:i.framework,options:e,classNameAllocator:u,developmentClassNameAllocator:g,isViteDevServerActive:()=>y?.isActive()??!1,rollupDataById:r,esbuildDataById:o,cssFileName:d,getEsbuildWorkingDirectory:c.getWorkingDirectory,notifyViteStyles:f,notifyDevelopmentStyles:x,getDevelopmentHmrConnection:i.framework==="esbuild"?c.getDevelopmentHmrConnection:()=>a?.then(l=>l.getConnection())})),h);return{name:"@cssxio/unplugin",enforce:"pre",transform:{filter:{id:U},handler:async function(t,l){let C=await p(),w=this.meta?.watchMode;if(i.framework==="rollup"&&w&&a){let I=await a,V=I.takePrepared(l,t);if(V.handled)return I.onTransformed(l),V.result}let H=y?.isPrepared(l,t)??!1,R=await C.call({...this,skipViteStylesheetPush:H},t,l);return i.framework==="vite"?y?.onTransformed(l,t):i.framework==="rollup"&&w&&a&&(await a).onTransformed(l),R}},async watchChange(t,l){let C=M(t);if(l.event==="delete"){r.delete(C),y?.delete(C),await a?.then(w=>w.delete(C)),i.framework==="vite"?await f():await x();return}if(i.framework==="rollup"&&a&&l.event==="update"&&U.test(t)){await a.then(w=>w.updateCssOnlySource(t));return}i.framework!=="vite"||!y?.isActive()||l.event!=="update"||!U.test(t)||await y.updateCssOnlySource(t)},rollup:{generateBundle:m,buildStart(){let t=this.meta.watchMode;if(O(e,{watchMode:t})&&t&&!a){let l=k(e);a=import("@cssxio/unplugin/internal/development-runtime").then(C=>C.createRollupDevelopmentRuntime({cssFileName:d,root:process.cwd(),dataById:r,getTheme:s,options:l,sourceMap:l.sourceMap,transformSource:(w,H)=>p().then(R=>R.call({meta:{watchMode:!0},skipRollupStylesheetPush:!0},w,H))}))}t&&a&&a.then(l=>l.buildStart()).catch(l=>{console.warn(`CSSX: Rollup development coordinator failed: ${String(l)}`)})},async buildEnd(){await a?.then(t=>t.buildEnd())},async closeWatcher(){await a?.then(t=>t.closeWatcher(),()=>{}),a=void 0}},vite:{generateBundle:m,configResolved(t){n=t.command,S=t.root??S},async configureServer(t){if(n==="build"||e.mode==="production"||process.env.NODE_ENV==="production")return;let l=k(e),{createViteDevelopmentRuntime:C}=await import("@cssxio/unplugin/internal/development-runtime");S=t.config.root??process.cwd(),y=C(t,{cssFileName:d,root:S,sourceMap:l.sourceMap,options:l,rollupDataById:r,getTheme:s},r,(w,H)=>p().then(R=>R.call({meta:{watchMode:!0},skipViteStylesheetPush:!0},w,H)))},transformIndexHtml:{order:"pre",async handler(t,l){if(!l.server||n==="build"||e.mode==="production"||process.env.NODE_ENV==="production")return;let{viteDevelopmentStylesheetHmr:C}=await import("@cssxio/unplugin/internal/development-runtime");return[{tag:"script",attrs:{type:"module","data-cssx-vite-hmr":!0},children:C(d),injectTo:"body"}]}},hotUpdate:{order:"pre",handler:Z(r,void 0,(t,l)=>y?.updateCssOnlySource(t,l)??Promise.resolve(!1))}},...i.framework==="webpack"?{webpack(t){$({compiler:t,options:e,cssFileName:d,sourceMap:v,getTheme:s})}}:{},...i.framework==="rspack"?{rspack(t){$({compiler:t,options:e,cssFileName:d,sourceMap:v,getTheme:s})}}:{},...i.framework==="esbuild"?{esbuild:{config:c.config,setup:c.setup}}:{}}},A=he(Se),ht=A.vite,St=A.rollup,Ct=A.webpack,wt=A.rspack,Ce=A;export{Se as a,A as b,ht as c,St as d,Ct as e,wt as f,Ce as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as o,i as s}from"./chunk-GPHROS5Y.js";import{createClassNameAllocator as n}from"@cssxio/compiler";function r(a,e){return`${a}\0${JSON.stringify(e)}`}var i=new Map;function u(a,e){let l=r(a,e),t=i.get(l);return t||(t={classNameAllocator:e.classNameAllocator??n(o(e)),developmentClassNameAllocator:e.classNameAllocator??n(o(s(e))),transformedDataById:new Map},i.set(l,t)),t}export{u as a};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DarkMode } from '@cssxio/compiler';
|
|
2
|
+
import { C as CssxSourceModule, a as CssxStylesheet } from './stylesheet-types-mSM1XaBK.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds one stylesheet from source module data.
|
|
6
|
+
*
|
|
7
|
+
* @param data CSSX data from source modules.
|
|
8
|
+
* @param theme Optional CSS theme input.
|
|
9
|
+
* @param layer Optional CSS layer for the output.
|
|
10
|
+
* @param sourceMap Whether to generate a CSS source map.
|
|
11
|
+
* @param darkMode Controls how the `dark` variant is activated.
|
|
12
|
+
* @param preflight Whether to add the browser baseline before utility rules.
|
|
13
|
+
* @returns The generated CSS and its source map when source locations exist.
|
|
14
|
+
*/
|
|
15
|
+
declare function compileCssxStylesheet(data: readonly CssxSourceModule[], theme?: string, layer?: string, sourceMap?: boolean, darkMode?: DarkMode, preflight?: boolean): Promise<CssxStylesheet>;
|
|
16
|
+
|
|
17
|
+
export { compileCssxStylesheet as c };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DarkMode } from '@cssxio/compiler';
|
|
2
|
+
import { C as CssxSourceModule, a as CssxStylesheet } from './stylesheet-types-mSM1XaBK.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds one stylesheet from source module data.
|
|
6
|
+
*
|
|
7
|
+
* @param data CSSX data from source modules.
|
|
8
|
+
* @param theme Optional CSS theme input.
|
|
9
|
+
* @param layer Optional CSS layer for the output.
|
|
10
|
+
* @param sourceMap Whether to generate a CSS source map.
|
|
11
|
+
* @param darkMode Controls how the `dark` variant is activated.
|
|
12
|
+
* @param preflight Whether to add the browser baseline before utility rules.
|
|
13
|
+
* @returns The generated CSS and its source map when source locations exist.
|
|
14
|
+
*/
|
|
15
|
+
declare function compileCssxStylesheet(data: readonly CssxSourceModule[], theme?: string, layer?: string, sourceMap?: boolean, darkMode?: DarkMode, preflight?: boolean): Promise<CssxStylesheet>;
|
|
16
|
+
|
|
17
|
+
export { compileCssxStylesheet as c };
|