@cssxio/unplugin 0.2.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.
@@ -0,0 +1,149 @@
1
+ import * as _webpack from 'webpack';
2
+ import * as _unplugin from 'unplugin';
3
+ import { UnpluginFactory } from 'unplugin';
4
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.cjs';
5
+ import { DarkMode, CssxRule, ClassNameAllocator } from '@cssxio/compiler';
6
+ import { transformAsync } from '@babel/core';
7
+ export { default as esbuild } from './esbuild.cjs';
8
+ import 'esbuild';
9
+
10
+ /** The source location of one utility string. */
11
+ interface CssxCandidateOrigin {
12
+ /** Zero-based line number in the source module. */
13
+ readonly line: number;
14
+ /** Zero-based column number in the source module. */
15
+ readonly column: number;
16
+ }
17
+ /** CSSX data collected from one source module. */
18
+ interface CssxSourceModule {
19
+ /** Stable source module ID. */
20
+ readonly id: string;
21
+ /** Maps utility strings to generated class names. */
22
+ readonly candidates: Readonly<Record<string, string>>;
23
+ /** Maps composite classes to their winning atomic classes. */
24
+ readonly composites?: Readonly<Record<string, readonly string[]>>;
25
+ /** Atomic classes required by compiled styles that survive to runtime. */
26
+ readonly atomicClasses?: readonly string[];
27
+ /** Maps utility strings to source locations when they are available. */
28
+ readonly origins?: Readonly<Record<string, CssxCandidateOrigin>>;
29
+ }
30
+ /** A source map for generated CSS. */
31
+ interface CssxSourceMap {
32
+ /** Source map format version. */
33
+ readonly version: 3;
34
+ /** Source module IDs referenced by the map. */
35
+ readonly sources: readonly string[];
36
+ /** CSSX does not emit named source map entries. */
37
+ readonly names: readonly [];
38
+ /** Encoded source map segments for generated rules. */
39
+ readonly mappings: string;
40
+ }
41
+ /** A generated stylesheet and its optional source map. */
42
+ interface CssxStylesheet {
43
+ /** Generated, deduplicated CSS. */
44
+ readonly css: string;
45
+ /** Source map for generated CSS when source locations are available. */
46
+ readonly map?: CssxSourceMap;
47
+ }
48
+ /**
49
+ * Builds one stylesheet from source module data.
50
+ *
51
+ * @param data CSSX data from source modules.
52
+ * @param theme Optional CSS theme input.
53
+ * @param layer Optional CSS layer for the output.
54
+ * @param sourceMap Whether to generate a CSS source map.
55
+ * @param darkMode Controls how the `dark` variant is activated.
56
+ * @returns The generated CSS and its source map when source locations exist.
57
+ */
58
+ declare function compileCssxStylesheet(data: readonly CssxSourceModule[], theme?: string, layer?: string, sourceMap?: boolean, darkMode?: DarkMode): Promise<CssxStylesheet>;
59
+
60
+ /** The result of transforming one source module. */
61
+ interface TransformResult {
62
+ /** JavaScript source after the CSSX transform. */
63
+ readonly code: string;
64
+ /** Compiled utility rules collected from this module. */
65
+ readonly rules: readonly CssxRule[];
66
+ /** Maps utility strings to generated class names. */
67
+ readonly candidates: Readonly<Record<string, string>>;
68
+ /** Maps composite classes to their winning atomic classes. */
69
+ readonly composites: Readonly<Record<string, readonly string[]>>;
70
+ /** Atomic classes required by compiled styles that survive to runtime. */
71
+ readonly atomicClasses: readonly string[];
72
+ /** Maps utility strings to their locations in the source module. */
73
+ readonly origins: Readonly<Record<string, CssxCandidateOrigin>>;
74
+ /** Source with CSSX utility literals removed, used to identify CSS-only edits. */
75
+ readonly cssOnlySignature: string;
76
+ /** Source map that continues a map supplied by an earlier transform. */
77
+ readonly map?: NonNullable<Awaited<ReturnType<typeof transformAsync>>>['map'];
78
+ }
79
+ /** A source map accepted from a build tool. */
80
+ interface IncomingSourceMap {
81
+ /** Source map format version. CSSX accepts version 3. */
82
+ readonly version: number;
83
+ /** Source file names referenced by the map. */
84
+ readonly sources: string[];
85
+ /** Original identifier names referenced by the map. */
86
+ readonly names: string[];
87
+ /** Optional prefix for source file names. */
88
+ readonly sourceRoot?: string;
89
+ /** Optional source file contents. */
90
+ readonly sourcesContent?: string[];
91
+ /** Encoded source map segments. */
92
+ readonly mappings: string;
93
+ /** Name of the generated file. */
94
+ readonly file: string;
95
+ }
96
+ /**
97
+ * Transforms one source module that imports CSSX.
98
+ *
99
+ * @param code Source code to transform.
100
+ * @param id The source module ID.
101
+ * @param options Adapter options.
102
+ * @param inputSourceMap An optional source map from an earlier transform.
103
+ * @returns The transformed module, or null when the module does not use CSSX.
104
+ */
105
+ declare function transformCssxModule(code: string, id: string, options?: CssxPluginOptions & {
106
+ readonly classNameAllocator?: ClassNameAllocator;
107
+ readonly stableClassNames?: boolean;
108
+ }, inputSourceMap?: IncomingSourceMap): Promise<TransformResult | null>;
109
+
110
+ /**
111
+ * Low-level factory used by Unplugin to create a CSSX adapter for one build tool.
112
+ *
113
+ * @param options CSSX adapter options.
114
+ * @param meta Unplugin metadata that identifies the active build tool.
115
+ * @returns The hooks and lifecycle handlers for that build tool.
116
+ */
117
+ declare const unpluginFactory: UnpluginFactory<CssxPluginOptions | undefined>;
118
+ /** Universal adapter instance that exposes factories for every supported build tool. */
119
+ declare const unplugin: _unplugin.UnpluginInstance<CssxPluginOptions | undefined, boolean>;
120
+ /**
121
+ * Callable factory that creates the CSSX adapter for Vite.
122
+ *
123
+ * @param options CSSX adapter options.
124
+ * @returns The Vite plugin.
125
+ */
126
+ declare const vite: (options?: CssxPluginOptions | undefined) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
127
+ /**
128
+ * Callable factory that creates the CSSX adapter for Rollup.
129
+ *
130
+ * @param options CSSX adapter options.
131
+ * @returns The Rollup plugin.
132
+ */
133
+ declare const rollup: (options?: CssxPluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
134
+ /**
135
+ * Callable factory that creates the CSSX adapter for webpack.
136
+ *
137
+ * @param options CSSX adapter options.
138
+ * @returns The webpack plugin.
139
+ */
140
+ declare const webpack: (options?: CssxPluginOptions | undefined) => _webpack.WebpackPluginInstance;
141
+ /**
142
+ * Callable factory that creates the CSSX adapter for Rspack.
143
+ *
144
+ * @param options CSSX adapter options.
145
+ * @returns The Rspack plugin.
146
+ */
147
+ declare const rspack: (options?: CssxPluginOptions | undefined) => _unplugin.RspackPluginInstance;
148
+
149
+ export { type CssxCandidateOrigin, CssxPluginOptions, type CssxSourceMap, type CssxSourceModule, type CssxStylesheet, type IncomingSourceMap, type TransformResult, compileCssxStylesheet, unplugin as default, rollup, rspack, transformCssxModule, unplugin, unpluginFactory, vite, webpack };
@@ -0,0 +1,149 @@
1
+ import * as _webpack from 'webpack';
2
+ import * as _unplugin from 'unplugin';
3
+ import { UnpluginFactory } from 'unplugin';
4
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.js';
5
+ import { DarkMode, CssxRule, ClassNameAllocator } from '@cssxio/compiler';
6
+ import { transformAsync } from '@babel/core';
7
+ export { default as esbuild } from './esbuild.js';
8
+ import 'esbuild';
9
+
10
+ /** The source location of one utility string. */
11
+ interface CssxCandidateOrigin {
12
+ /** Zero-based line number in the source module. */
13
+ readonly line: number;
14
+ /** Zero-based column number in the source module. */
15
+ readonly column: number;
16
+ }
17
+ /** CSSX data collected from one source module. */
18
+ interface CssxSourceModule {
19
+ /** Stable source module ID. */
20
+ readonly id: string;
21
+ /** Maps utility strings to generated class names. */
22
+ readonly candidates: Readonly<Record<string, string>>;
23
+ /** Maps composite classes to their winning atomic classes. */
24
+ readonly composites?: Readonly<Record<string, readonly string[]>>;
25
+ /** Atomic classes required by compiled styles that survive to runtime. */
26
+ readonly atomicClasses?: readonly string[];
27
+ /** Maps utility strings to source locations when they are available. */
28
+ readonly origins?: Readonly<Record<string, CssxCandidateOrigin>>;
29
+ }
30
+ /** A source map for generated CSS. */
31
+ interface CssxSourceMap {
32
+ /** Source map format version. */
33
+ readonly version: 3;
34
+ /** Source module IDs referenced by the map. */
35
+ readonly sources: readonly string[];
36
+ /** CSSX does not emit named source map entries. */
37
+ readonly names: readonly [];
38
+ /** Encoded source map segments for generated rules. */
39
+ readonly mappings: string;
40
+ }
41
+ /** A generated stylesheet and its optional source map. */
42
+ interface CssxStylesheet {
43
+ /** Generated, deduplicated CSS. */
44
+ readonly css: string;
45
+ /** Source map for generated CSS when source locations are available. */
46
+ readonly map?: CssxSourceMap;
47
+ }
48
+ /**
49
+ * Builds one stylesheet from source module data.
50
+ *
51
+ * @param data CSSX data from source modules.
52
+ * @param theme Optional CSS theme input.
53
+ * @param layer Optional CSS layer for the output.
54
+ * @param sourceMap Whether to generate a CSS source map.
55
+ * @param darkMode Controls how the `dark` variant is activated.
56
+ * @returns The generated CSS and its source map when source locations exist.
57
+ */
58
+ declare function compileCssxStylesheet(data: readonly CssxSourceModule[], theme?: string, layer?: string, sourceMap?: boolean, darkMode?: DarkMode): Promise<CssxStylesheet>;
59
+
60
+ /** The result of transforming one source module. */
61
+ interface TransformResult {
62
+ /** JavaScript source after the CSSX transform. */
63
+ readonly code: string;
64
+ /** Compiled utility rules collected from this module. */
65
+ readonly rules: readonly CssxRule[];
66
+ /** Maps utility strings to generated class names. */
67
+ readonly candidates: Readonly<Record<string, string>>;
68
+ /** Maps composite classes to their winning atomic classes. */
69
+ readonly composites: Readonly<Record<string, readonly string[]>>;
70
+ /** Atomic classes required by compiled styles that survive to runtime. */
71
+ readonly atomicClasses: readonly string[];
72
+ /** Maps utility strings to their locations in the source module. */
73
+ readonly origins: Readonly<Record<string, CssxCandidateOrigin>>;
74
+ /** Source with CSSX utility literals removed, used to identify CSS-only edits. */
75
+ readonly cssOnlySignature: string;
76
+ /** Source map that continues a map supplied by an earlier transform. */
77
+ readonly map?: NonNullable<Awaited<ReturnType<typeof transformAsync>>>['map'];
78
+ }
79
+ /** A source map accepted from a build tool. */
80
+ interface IncomingSourceMap {
81
+ /** Source map format version. CSSX accepts version 3. */
82
+ readonly version: number;
83
+ /** Source file names referenced by the map. */
84
+ readonly sources: string[];
85
+ /** Original identifier names referenced by the map. */
86
+ readonly names: string[];
87
+ /** Optional prefix for source file names. */
88
+ readonly sourceRoot?: string;
89
+ /** Optional source file contents. */
90
+ readonly sourcesContent?: string[];
91
+ /** Encoded source map segments. */
92
+ readonly mappings: string;
93
+ /** Name of the generated file. */
94
+ readonly file: string;
95
+ }
96
+ /**
97
+ * Transforms one source module that imports CSSX.
98
+ *
99
+ * @param code Source code to transform.
100
+ * @param id The source module ID.
101
+ * @param options Adapter options.
102
+ * @param inputSourceMap An optional source map from an earlier transform.
103
+ * @returns The transformed module, or null when the module does not use CSSX.
104
+ */
105
+ declare function transformCssxModule(code: string, id: string, options?: CssxPluginOptions & {
106
+ readonly classNameAllocator?: ClassNameAllocator;
107
+ readonly stableClassNames?: boolean;
108
+ }, inputSourceMap?: IncomingSourceMap): Promise<TransformResult | null>;
109
+
110
+ /**
111
+ * Low-level factory used by Unplugin to create a CSSX adapter for one build tool.
112
+ *
113
+ * @param options CSSX adapter options.
114
+ * @param meta Unplugin metadata that identifies the active build tool.
115
+ * @returns The hooks and lifecycle handlers for that build tool.
116
+ */
117
+ declare const unpluginFactory: UnpluginFactory<CssxPluginOptions | undefined>;
118
+ /** Universal adapter instance that exposes factories for every supported build tool. */
119
+ declare const unplugin: _unplugin.UnpluginInstance<CssxPluginOptions | undefined, boolean>;
120
+ /**
121
+ * Callable factory that creates the CSSX adapter for Vite.
122
+ *
123
+ * @param options CSSX adapter options.
124
+ * @returns The Vite plugin.
125
+ */
126
+ declare const vite: (options?: CssxPluginOptions | undefined) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
127
+ /**
128
+ * Callable factory that creates the CSSX adapter for Rollup.
129
+ *
130
+ * @param options CSSX adapter options.
131
+ * @returns The Rollup plugin.
132
+ */
133
+ declare const rollup: (options?: CssxPluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
134
+ /**
135
+ * Callable factory that creates the CSSX adapter for webpack.
136
+ *
137
+ * @param options CSSX adapter options.
138
+ * @returns The webpack plugin.
139
+ */
140
+ declare const webpack: (options?: CssxPluginOptions | undefined) => _webpack.WebpackPluginInstance;
141
+ /**
142
+ * Callable factory that creates the CSSX adapter for Rspack.
143
+ *
144
+ * @param options CSSX adapter options.
145
+ * @returns The Rspack plugin.
146
+ */
147
+ declare const rspack: (options?: CssxPluginOptions | undefined) => _unplugin.RspackPluginInstance;
148
+
149
+ export { type CssxCandidateOrigin, CssxPluginOptions, type CssxSourceMap, type CssxSourceModule, type CssxStylesheet, type IncomingSourceMap, type TransformResult, compileCssxStylesheet, unplugin as default, rollup, rspack, transformCssxModule, unplugin, unpluginFactory, vite, webpack };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-NTRHNWKR.js";export{a as compileCssxStylesheet,i as default,j as esbuild,f as rollup,h as rspack,b as transformCssxModule,d as unplugin,c as unpluginFactory,e as vite,g as webpack};
@@ -0,0 +1,23 @@
1
+ import { ReusabilityBudget, DarkMode } from '@cssxio/compiler';
2
+
3
+ /** Options for a CSSX bundler adapter. */
4
+ interface CssxPluginOptions {
5
+ /** Module specifier that identifies source files using the CSSX runtime. */
6
+ readonly importSource?: string;
7
+ /** Relative output path for extracted CSS. The default is `cssx.css`. */
8
+ readonly cssFileName?: string;
9
+ /** Whether to generate a CSS source map. The default is `true`. */
10
+ readonly sourceMap?: boolean;
11
+ /** CSSX `@theme` source applied while transforming and compiling CSS. */
12
+ readonly theme?: string;
13
+ /** Path to a CSSX `@theme` file. Cannot be used with `theme`. */
14
+ readonly themeFile?: string;
15
+ /** Optional CSS layer that wraps the generated CSS. */
16
+ readonly layer?: string;
17
+ /** Controls how aggressively static styles share generated class fragments. */
18
+ readonly reusabilityBudget?: ReusabilityBudget;
19
+ /** Activates `dark` variants with a media query or a `[data-theme=dark]` selector. */
20
+ readonly darkMode?: DarkMode;
21
+ }
22
+
23
+ export type { CssxPluginOptions as C };
@@ -0,0 +1,23 @@
1
+ import { ReusabilityBudget, DarkMode } from '@cssxio/compiler';
2
+
3
+ /** Options for a CSSX bundler adapter. */
4
+ interface CssxPluginOptions {
5
+ /** Module specifier that identifies source files using the CSSX runtime. */
6
+ readonly importSource?: string;
7
+ /** Relative output path for extracted CSS. The default is `cssx.css`. */
8
+ readonly cssFileName?: string;
9
+ /** Whether to generate a CSS source map. The default is `true`. */
10
+ readonly sourceMap?: boolean;
11
+ /** CSSX `@theme` source applied while transforming and compiling CSS. */
12
+ readonly theme?: string;
13
+ /** Path to a CSSX `@theme` file. Cannot be used with `theme`. */
14
+ readonly themeFile?: string;
15
+ /** Optional CSS layer that wraps the generated CSS. */
16
+ readonly layer?: string;
17
+ /** Controls how aggressively static styles share generated class fragments. */
18
+ readonly reusabilityBudget?: ReusabilityBudget;
19
+ /** Activates `dark` variants with a media query or a `[data-theme=dark]` selector. */
20
+ readonly darkMode?: DarkMode;
21
+ }
22
+
23
+ export type { CssxPluginOptions as C };
@@ -0,0 +1,92 @@
1
+ "use strict";var se=Object.create;var P=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!ie.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=re(t,s))||r.enumerable});return e};var de=(e,t,n)=>(n=e!=null?se(ae(e)):{},V(t||!e||!e.__esModule?P(n,"default",{value:e,enumerable:!0}):n,e)),ce=e=>V(P({},"__esModule",{value:!0}),e);var Pe={};le(Pe,{default:()=>Ne});module.exports=ce(Pe);var Z=require("@cssxio/compiler"),Q=require("unplugin"),Y=require("buffer"),R=require("fs/promises"),w=require("path");var $=require("@cssxio/compiler"),W=require("path");async function k(e,t,n,r=!0,s){let m=Object.create(null),d=Object.create(null),o=new Set,l=!0,y=new Map;for(let g of[...e].sort((c,i)=>c.id.localeCompare(i.id))){for(let[c,i]of Object.entries(g.candidates))if(c in m||(m[c]=i),g.id&&!y.has(c)){let u=g.origins?.[c];y.set(c,{id:g.id,line:u?.line??0,column:u?.column??0})}for(let[c,i]of Object.entries(g.composites??{})){let u=d[c];if(u&&u.join(" ")!==i.join(" "))throw new Error(`CSSX composite class collision for "${c}".`);d[c]=i}g.atomicClasses===void 0&&(l=!1);for(let c of g.atomicClasses??[])o.add(c)}let C=Object.keys(m).sort();if(C.length===0)return{css:""};let h=await(0,$.compileUtilities)(C,g=>m[g],t,(0,$.createSelectorAliases)(d),l?o:void 0,{darkMode:s}),a=h.css&&n?`@layer ${n}{`:"",f=`${a}${h.css}${a?"}":""}`,p=r?ue(`${a}${h.prefixCss}`,h.entries,y):void 0;return{css:f,...p?{map:p}:{}}}function v(e,t){return e.map?`${e.css}
2
+ /*# sourceMappingURL=${(0,W.basename)(t)}.map */`:e.css}function O(e,t){return JSON.stringify({...e,file:t})}function ue(e,t,n){let r=[...new Set(t.map(o=>n.get(o.candidate)?.id).filter(o=>!!o))].sort();if(r.length===0)return;let s=new Map(r.map((o,l)=>[o,l])),m=[],d=_({line:0,column:0},e);for(let o of t){let l=n.get(o.candidate);l&&m.push({...d,source:s.get(l.id),originalLine:l.line,originalColumn:l.column}),d=_(d,o.css)}return{version:3,sources:r,names:[],mappings:me(m)}}function _(e,t){let n=t.split(`
3
+ `);return{line:e.line+n.length-1,column:n.at(-1).length+e.column*+(n.length===1)}}function me(e){let t=Array.from({length:Math.max(0,...e.map(o=>o.line))+1},()=>[]),n=0,r=0,s=0,m=0,d=0;for(let o of e)d*=+(o.line===m),m=o.line,t[o.line]?.push(`${L(o.column-d)}${L(o.source-n)}${L(o.originalLine-r)}${L(o.originalColumn-s)}`),d=o.column,n=o.source,r=o.originalLine,s=o.originalColumn;return t.map(o=>o.join(",")).join(";")}var pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function L(e){let t="",n=e<0?-e<<1|1:e<<1;do{let r=n&31;n>>>=5,n&&(r|=32),t+=pe[r]}while(n);return t}var X=require("fs/promises"),S=require("path");async function I(e){return e.themeFile===void 0?e.theme:(0,X.readFile)((0,S.resolve)(process.cwd(),e.themeFile),"utf8")}function j(e){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")throw new Error('CSSX darkMode must be "media" or "selector".');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.');T(e.cssFileName??"cssx.css")}function U(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function A(e,t){return T(e).replaceAll("[hash]",U(t))}function E(e,t){return`${e&&e!=="/"?`/${e.replace(/^\/+|\/+$/g,"")}`:""}/${T(t).replaceAll(S.sep,"/")}`}function q(e,t,n){return t.outdir?(0,S.resolve)(e,t.outdir,n):t.outfile?(0,S.resolve)((0,S.dirname)((0,S.resolve)(e,t.outfile)),n):(0,S.resolve)(e,n)}function b(e){return e.split("?",1).join("")}function T(e){if(!e||(0,S.isAbsolute)(e))throw new Error("cssFileName must be a non-empty relative path.");let t=(0,S.normalize)(e);if(t===".."||t.startsWith(`..${S.sep}`))throw new Error("cssFileName must not escape the bundler output directory.");if(!t.endsWith(".css"))throw new Error("cssFileName must end in .css.");return t}function z(e,t,n){let r=e.getNativeBuildContext?.();if(!r||r.framework!=="webpack"&&r.framework!=="rspack")return;let s=r.loaderContext?._module;if(!s)return;let m=s.buildInfo??(s.buildInfo={});m[n]=t}function B(e,t,n,r,s,m,d,o){e.hooks.thisCompilation.tap("@cssxio/unplugin",l=>{l.hooks.processAssets.tapPromise({name:"@cssxio/unplugin",stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},async()=>{let y=[...l.modules].map(a=>fe(a,m,d)),C=await k(y.some(a=>Object.keys(a.candidates).length>0)?y:[...d?.values()??[]],await n(),r,s,o);if(!C.css)return;let h=A(t,C.css);if(l.getAsset?.(h))throw new Error(`CSSX CSS asset collision at "${h}".`);if(l.emitAsset(h,new e.webpack.sources.RawSource(v(C,h))),C.map){let a=`${h}.map`;if(l.getAsset?.(a))throw new Error(`CSSX CSS map asset collision at "${a}".`);l.emitAsset(a,new e.webpack.sources.RawSource(O(C.map,h)))}})})}function fe(e,t,n){let r=e.buildInfo?.[t];if(!r||typeof r!="object")return n?.get(e.resource?.split("?",1)[0]??"")??{id:"",candidates:{},composites:{},origins:{}};let{id:s,candidates:m,composites:d,atomicClasses:o,origins:l}=r;return{id:typeof s=="string"?s:"",candidates:m&&typeof m=="object"?m:{},composites:d&&typeof d=="object"?d:{},...Array.isArray(o)?{atomicClasses:o}:{},origins:l&&typeof l=="object"?l:{}}}var G=require("@babel/core"),J=de(require("@cssxio/babel-plugin"),1),M=require("@cssxio/compiler");var ye=/\.(?:[cm]?[jt]sx?|astro)(?:\?.*)?$/,ge=/\.astro(?:\?.*)?$/;async function D(e,t,n={},r){j(n);let s=n.importSource??"@cssxio/cssx";if(!ye.test(t)||!e.includes(s))return null;if(ge.test(t))return he(e,t,n);let m=await I(n),d=await(0,G.transformAsync)(e,{babelrc:!1,configFile:!1,filename:t.split("?",1).join(""),parserOpts:{plugins:["jsx","typescript"]},plugins:[[J.default,{importSource:s,classNameAllocator:n.classNameAllocator,theme:m,reusabilityBudget:n.reusabilityBudget,stableClassNames:n.stableClassNames,darkMode:n.darkMode}]],sourceMaps:!0,...r?{inputSourceMap:r}:{}}),o=d.metadata,{candidates:l,origins:y,composites:C,atomicClasses:h,cssOnlySignature:a}=o.cssx,f=Object.keys(l),p=f.length===0?"":(await(0,M.compileUtilities)(f,g=>l[g],m,(0,M.createSelectorAliases)(C),new Set(h),{darkMode:n.darkMode})).css;return{code:d.code,rules:p?[Se(be(p,n.layer))]:[],candidates:l,composites:C,atomicClasses:h,origins:y,cssOnlySignature:a,map:d.map}}async function he(e,t,n){let r=Ce(e);if(r.length===0)return null;let s=n.classNameAllocator??(0,M.createClassNameAllocator)(),m=n.importSource??"@cssxio/cssx",d={},o={},l=[],y=e;for(let C of[...r].reverse()){let h=await D(`import { sx } from ${JSON.stringify(m)};
4
+ const style = ${C.code};`,`${t}.ts`,{...n,classNameAllocator:s}),a=xe(h.code);y=`${y.slice(0,C.start)}${a}${y.slice(C.end)}`,Object.assign(d,h.candidates),Object.assign(o,h.composites),l.push(...h.rules)}return{code:y,rules:l,candidates:d,composites:o,atomicClasses:[],origins:{},cssOnlySignature:y}}function Ce(e){let t=[],n=/\bsx\s*\(/g;for(let r of e.matchAll(n)){let s=r.index,m=e.indexOf("(",s),d=0,o="";for(let l=m;l<e.length;l+=1){let y=e[l];if(o){y==="\\"?l+=1:y===o&&(o="");continue}if(y==='"'||y==="'"||y==="`")o=y;else if(y==="(")d+=1;else if(y===")"&&--d===0){t.push({start:s,end:l+1,code:e.slice(s,l+1)}),n.lastIndex=l+1;break}}}return t}function xe(e){let t="const style = ",n=e.indexOf(t)+t.length,r=e.indexOf(";",n);return e.slice(n,r)}function K(e,t){if(!e||typeof e!="object")return;let n=e.getCombinedSourcemap;if(typeof n!="function")return;let r=n.call(e);if(!r||typeof r!="object")return;let s=r;if(!(s.version!==3||!Array.isArray(s.sources)||typeof s.mappings!="string"))return{version:s.version,sources:[...s.sources],names:[...s.names??[]],mappings:s.mappings,file:s.file??t.split("?",1).join(""),...s.sourceRoot?{sourceRoot:s.sourceRoot}:{},...s.sourcesContent?{sourcesContent:[...s.sourcesContent]}:{}}}function Se(e){return{className:`cssx-${U(e)}`,css:e}}function be(e,t){return e&&t?`@layer ${t}{${e}}`:e}function H(e,t,n=Date.now()){e.ws.send({type:"update",updates:[{type:"css-update",path:t,acceptedPath:t,timestamp:n}]})}var N="@cssxio/unplugin/rules",we=/\.(?:[cm]?[jt]sx?|astro)(?:\?.*)?$/;function ke(e,t,n){let r=new Set;for(let s of t)e.moduleGraph?.invalidateModule(s,r,n,!0);for(let s of r){if(!s.id)continue;let m=e.runner?.evaluatedModules?.getModuleById(s.id);m&&e.runner?.evaluatedModules?.invalidateModule(m)}}function ve(e){return!e||typeof e!="object"?{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""}:Me(e[N])}function Me(e){if(!e||typeof e!="object")return{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""};let{id:t,rules:n,candidates:r,composites:s,atomicClasses:m,origins:d,cssOnlySignature:o}=e;return{id:typeof t=="string"?t:"",rules:Array.isArray(n)?n:[],candidates:r&&typeof r=="object"?r:{},composites:s&&typeof s=="object"?s:{},...Array.isArray(m)?{atomicClasses:m}:{},origins:d&&typeof d=="object"?d:{},cssOnlySignature:typeof o=="string"?o:""}}var Re=(e={},t)=>{j(e);let n=e.cssFileName??"cssx.css",r=e.sourceMap??!0,s=new Map,m=(0,Z.createClassNameAllocator)(),d=new Map,o,l=process.cwd(),y,C=()=>I(e),h=async function(a,f){let p=new Set(Object.values(f).flatMap(u=>u.type==="chunk"?Object.keys(u.modules??{}):[]).map(b));if(t.framework!=="vite")for(let u of s.keys())p.has(u)||s.delete(u);let g=t.framework==="vite"?[...s.values()]:[...p].map(u=>{let x=ve(this.getModuleInfo(u)?.meta);return Object.keys(x.candidates).length>0?x:s.get(u)??x}),c=await k(g,await C(),e.layer,r,e.darkMode);if(!c.css)return;let i=A(n,c.css);if(Object.hasOwn(f,i))throw new Error(`CSSX CSS asset collision at "${i}".`);if(this.emitFile({type:"asset",fileName:i,source:v(c,i)}),c.map){let u=`${i}.map`;if(Object.hasOwn(f,u))throw new Error(`CSSX CSS map asset collision at "${u}".`);this.emitFile({type:"asset",fileName:u,source:O(c.map,i)})}};return{name:"@cssxio/unplugin",enforce:"pre",transform:{filter:{id:we},async handler(a,f){e.themeFile&&this.addWatchFile?.((0,w.resolve)(process.cwd(),e.themeFile));let p=await D(a,f,{...e,classNameAllocator:m},K(this,f)),g={id:b(f),rules:p?.rules??[],candidates:p?.candidates??{},composites:p?.composites??{},atomicClasses:p?.atomicClasses??[],origins:p?.origins??{},cssOnlySignature:p?.cssOnlySignature??""};z(this,g,N);let c=b(f);(p||c===f)&&(s.set(c,g),d.set((0,w.resolve)(l,c),g)),t.framework==="vite"&&y&&H(y,E("/",n));let i=p?.code??a;return{code:(t.framework==="webpack"||t.framework==="rspack")&&p?`${i}
5
+ ${Oe(n)}`:i,meta:{[N]:g},...p?.map?{map:p.map}:{}}}},watchChange(a,f){f.event==="delete"&&s.delete(b(a))},rollup:{generateBundle:h},vite:{generateBundle:h,configureServer(a){y=a;let f=E(a.config.base,n),p=E("/",n);a.watcher?.on("unlink",g=>{s.delete(b(g)),H(a,p)}),a.middlewares.use((g,c,i)=>{let u=g.url?.split("?",1)[0];if(u!==f&&(u!==`${f}.map`||!r))return i();C().then(x=>k([...s.values()],x,e.layer,r,e.darkMode)).then(x=>{if(u===`${f}.map`){c.setHeader("Content-Type","application/json; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(x.map?O(x.map,n):"");return}c.setHeader("Content-Type","text/css; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(v(x,n))}).catch(x=>{c.setHeader("Content-Type","text/plain; charset=utf-8"),c.end(x instanceof Error?x.message:"Unable to compile CSSX development stylesheet.")})})},hotUpdate:{order:"pre",async handler(a){let f=this.environment;if(!f||f.name==="client")return;let p=a.modules.filter(i=>{let u=s.get(b(i.id??""));return!!(u&&u.cssOnlySignature&&u.atomicClasses?.length===0)});if(p.length===0)return;let g=new Map(p.map(i=>[i,s.get(b(i.id)).cssOnlySignature]));for(let i of p)i.url&&await f.transformRequest(i.url);if(p.every(i=>{let u=s.get(b(i.id));return!!(u&&u.atomicClasses.length===0&&u.cssOnlySignature===g.get(i))}))return ke(f,p,a.timestamp),a.modules.filter(i=>!p.includes(i))}}},...t.framework==="webpack"?{webpack(a){B(a,n,C,e.layer,r,N,s,e.darkMode)}}:{},...t.framework==="rspack"?{rspack(a){B(a,n,C,e.layer,r,N,s,e.darkMode)}}:{},...t.framework==="esbuild"?{esbuild:{config(a){a.metafile=!0},setup(a){let f=a.initialOptions.absWorkingDir??process.cwd();l=f,a.onEnd(async p=>{if(!p.metafile)return;let g=new Set(Object.keys(p.metafile.inputs).map(x=>(0,w.resolve)(f,x)));for(let x of d.keys())g.has(x)||d.delete(x);let c=await k([...d.values()],await C(),e.layer,r,e.darkMode),i=q(f,a.initialOptions,A(n,c.css));if(!c.css){o&&await(0,R.unlink)(o).catch(()=>{}),o=void 0;return}let u=v(c,(0,w.basename)(i));if(a.initialOptions.write===!1){let x=p.outputFiles;if(!x)return;let te={path:i,contents:Y.Buffer.from(u),hash:"",text:u};if(x.findIndex(ne=>ne.path===i)!==-1)throw new Error(`CSSX CSS asset collision at "${i}".`);x.push(te);return}await(0,R.mkdir)((0,w.dirname)(i),{recursive:!0}),await(0,R.writeFile)(i,u),o=i})}}}:{}}},F=(0,Q.createUnplugin)(Re);function Oe(e){return`if (typeof document !== "undefined" && typeof module !== "undefined" && module.hot) {
6
+ const key = "__cssxStylesheetHmr";
7
+ const state = globalThis[key] || (globalThis[key] = { revision: 0, staged: [], replacements: [] });
8
+ const stylesheetLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
9
+ new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
10
+ );
11
+ const nextLink = stylesheetLink && (() => {
12
+ const path = new URL(stylesheetLink.href, document.baseURI).pathname;
13
+ return path.includes("/_next/");
14
+ })();
15
+ if (!state.installed) {
16
+ state.installed = true;
17
+ state.stage = () => {
18
+ const revision = ++state.revision;
19
+ state.staged = [];
20
+ state.replacements = [];
21
+ const links = [...document.querySelectorAll('link[rel="stylesheet"]')].filter((link) =>
22
+ new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
23
+ );
24
+ return Promise.all(
25
+ links.map(
26
+ (link) =>
27
+ new Promise((resolve) => {
28
+ const replacement = link.cloneNode();
29
+ const url = new URL(link.href, document.baseURI);
30
+ url.searchParams.set("cssx", String(revision));
31
+ replacement.href = url.href;
32
+ const finish = (loaded) => {
33
+ replacement.removeEventListener("load", onLoad);
34
+ replacement.removeEventListener("error", onError);
35
+ if (loaded) {
36
+ state.staged.push(link);
37
+ if (state.removeOnLoad) link.remove();
38
+ }
39
+ else replacement.remove();
40
+ resolve();
41
+ };
42
+ const onLoad = () => finish(true);
43
+ const onError = () => finish(false);
44
+ replacement.addEventListener("load", onLoad);
45
+ replacement.addEventListener("error", onError);
46
+ state.replacements.push(replacement);
47
+ link.after(replacement);
48
+ }),
49
+ ),
50
+ );
51
+ };
52
+ module.hot.addStatusHandler((status) => {
53
+ if (status === "prepare" || status === "dispose") {
54
+ return state.stage();
55
+ }
56
+ if (status === "idle") {
57
+ for (const link of state.staged) link.remove();
58
+ state.staged = [];
59
+ state.replacements = [];
60
+ }
61
+ if (status === "abort" || status === "fail") {
62
+ for (const replacement of state.replacements) replacement.remove();
63
+ state.staged = [];
64
+ state.replacements = [];
65
+ }
66
+ });
67
+ if (nextLink) module.hot.accept(() => void state.stage());
68
+ for (const updateKey of Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith("webpackHotUpdate"))) {
69
+ const update = globalThis[updateKey];
70
+ if (typeof update !== "function") continue;
71
+ globalThis[updateKey] = function (...args) {
72
+ void state.stage();
73
+ return update.apply(this, args);
74
+ };
75
+ }
76
+ if (stylesheetLink) {
77
+ state.removeOnLoad = Boolean(nextLink);
78
+ const refresh = async () => {
79
+ try {
80
+ const url = new URL(stylesheetLink.href, document.baseURI);
81
+ url.searchParams.set("cssx-probe", String(Date.now()));
82
+ const css = await fetch(url.href, { cache: "no-store" }).then((response) => response.text());
83
+ if (state.css && state.css !== css) void state.stage();
84
+ state.css = css;
85
+ } catch {
86
+ }
87
+ };
88
+ void refresh();
89
+ state.poll = setInterval(() => void refresh(), 500);
90
+ }
91
+ }
92
+ }`}var qe=F.vite,ee=F.rollup,ze=F.webpack,Ge=F.rspack;var Ae=ee,Ne=Ae;
@@ -0,0 +1,13 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.cjs';
3
+ import '@cssxio/compiler';
4
+
5
+ /**
6
+ * Creates the CSSX adapter for Rollup.
7
+ *
8
+ * @param options CSSX adapter options.
9
+ * @returns The Rollup plugin.
10
+ */
11
+ declare const cssxRollup: (options?: CssxPluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
12
+
13
+ export { cssxRollup as default };
@@ -0,0 +1,13 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.js';
3
+ import '@cssxio/compiler';
4
+
5
+ /**
6
+ * Creates the CSSX adapter for Rollup.
7
+ *
8
+ * @param options CSSX adapter options.
9
+ * @returns The Rollup plugin.
10
+ */
11
+ declare const cssxRollup: (options?: CssxPluginOptions | undefined) => _unplugin.RollupPlugin<any> | _unplugin.RollupPlugin<any>[];
12
+
13
+ export { cssxRollup as default };
package/dist/rollup.js ADDED
@@ -0,0 +1 @@
1
+ import{f as o}from"./chunk-NTRHNWKR.js";var l=o,r=l;export{r as default};
@@ -0,0 +1,92 @@
1
+ "use strict";var se=Object.create;var P=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!ie.call(e,s)&&s!==n&&P(e,s,{get:()=>t[s],enumerable:!(r=re(t,s))||r.enumerable});return e};var de=(e,t,n)=>(n=e!=null?se(ae(e)):{},V(t||!e||!e.__esModule?P(n,"default",{value:e,enumerable:!0}):n,e)),ce=e=>V(P({},"__esModule",{value:!0}),e);var Pe={};le(Pe,{default:()=>Ne});module.exports=ce(Pe);var Z=require("@cssxio/compiler"),Q=require("unplugin"),Y=require("buffer"),R=require("fs/promises"),w=require("path");var $=require("@cssxio/compiler"),W=require("path");async function k(e,t,n,r=!0,s){let m=Object.create(null),d=Object.create(null),o=new Set,l=!0,y=new Map;for(let g of[...e].sort((c,i)=>c.id.localeCompare(i.id))){for(let[c,i]of Object.entries(g.candidates))if(c in m||(m[c]=i),g.id&&!y.has(c)){let u=g.origins?.[c];y.set(c,{id:g.id,line:u?.line??0,column:u?.column??0})}for(let[c,i]of Object.entries(g.composites??{})){let u=d[c];if(u&&u.join(" ")!==i.join(" "))throw new Error(`CSSX composite class collision for "${c}".`);d[c]=i}g.atomicClasses===void 0&&(l=!1);for(let c of g.atomicClasses??[])o.add(c)}let C=Object.keys(m).sort();if(C.length===0)return{css:""};let h=await(0,$.compileUtilities)(C,g=>m[g],t,(0,$.createSelectorAliases)(d),l?o:void 0,{darkMode:s}),a=h.css&&n?`@layer ${n}{`:"",f=`${a}${h.css}${a?"}":""}`,p=r?ue(`${a}${h.prefixCss}`,h.entries,y):void 0;return{css:f,...p?{map:p}:{}}}function v(e,t){return e.map?`${e.css}
2
+ /*# sourceMappingURL=${(0,W.basename)(t)}.map */`:e.css}function O(e,t){return JSON.stringify({...e,file:t})}function ue(e,t,n){let r=[...new Set(t.map(o=>n.get(o.candidate)?.id).filter(o=>!!o))].sort();if(r.length===0)return;let s=new Map(r.map((o,l)=>[o,l])),m=[],d=_({line:0,column:0},e);for(let o of t){let l=n.get(o.candidate);l&&m.push({...d,source:s.get(l.id),originalLine:l.line,originalColumn:l.column}),d=_(d,o.css)}return{version:3,sources:r,names:[],mappings:me(m)}}function _(e,t){let n=t.split(`
3
+ `);return{line:e.line+n.length-1,column:n.at(-1).length+e.column*+(n.length===1)}}function me(e){let t=Array.from({length:Math.max(0,...e.map(o=>o.line))+1},()=>[]),n=0,r=0,s=0,m=0,d=0;for(let o of e)d*=+(o.line===m),m=o.line,t[o.line]?.push(`${L(o.column-d)}${L(o.source-n)}${L(o.originalLine-r)}${L(o.originalColumn-s)}`),d=o.column,n=o.source,r=o.originalLine,s=o.originalColumn;return t.map(o=>o.join(",")).join(";")}var pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function L(e){let t="",n=e<0?-e<<1|1:e<<1;do{let r=n&31;n>>>=5,n&&(r|=32),t+=pe[r]}while(n);return t}var X=require("fs/promises"),S=require("path");async function I(e){return e.themeFile===void 0?e.theme:(0,X.readFile)((0,S.resolve)(process.cwd(),e.themeFile),"utf8")}function j(e){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")throw new Error('CSSX darkMode must be "media" or "selector".');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.');T(e.cssFileName??"cssx.css")}function U(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function A(e,t){return T(e).replaceAll("[hash]",U(t))}function E(e,t){return`${e&&e!=="/"?`/${e.replace(/^\/+|\/+$/g,"")}`:""}/${T(t).replaceAll(S.sep,"/")}`}function q(e,t,n){return t.outdir?(0,S.resolve)(e,t.outdir,n):t.outfile?(0,S.resolve)((0,S.dirname)((0,S.resolve)(e,t.outfile)),n):(0,S.resolve)(e,n)}function b(e){return e.split("?",1).join("")}function T(e){if(!e||(0,S.isAbsolute)(e))throw new Error("cssFileName must be a non-empty relative path.");let t=(0,S.normalize)(e);if(t===".."||t.startsWith(`..${S.sep}`))throw new Error("cssFileName must not escape the bundler output directory.");if(!t.endsWith(".css"))throw new Error("cssFileName must end in .css.");return t}function z(e,t,n){let r=e.getNativeBuildContext?.();if(!r||r.framework!=="webpack"&&r.framework!=="rspack")return;let s=r.loaderContext?._module;if(!s)return;let m=s.buildInfo??(s.buildInfo={});m[n]=t}function B(e,t,n,r,s,m,d,o){e.hooks.thisCompilation.tap("@cssxio/unplugin",l=>{l.hooks.processAssets.tapPromise({name:"@cssxio/unplugin",stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},async()=>{let y=[...l.modules].map(a=>fe(a,m,d)),C=await k(y.some(a=>Object.keys(a.candidates).length>0)?y:[...d?.values()??[]],await n(),r,s,o);if(!C.css)return;let h=A(t,C.css);if(l.getAsset?.(h))throw new Error(`CSSX CSS asset collision at "${h}".`);if(l.emitAsset(h,new e.webpack.sources.RawSource(v(C,h))),C.map){let a=`${h}.map`;if(l.getAsset?.(a))throw new Error(`CSSX CSS map asset collision at "${a}".`);l.emitAsset(a,new e.webpack.sources.RawSource(O(C.map,h)))}})})}function fe(e,t,n){let r=e.buildInfo?.[t];if(!r||typeof r!="object")return n?.get(e.resource?.split("?",1)[0]??"")??{id:"",candidates:{},composites:{},origins:{}};let{id:s,candidates:m,composites:d,atomicClasses:o,origins:l}=r;return{id:typeof s=="string"?s:"",candidates:m&&typeof m=="object"?m:{},composites:d&&typeof d=="object"?d:{},...Array.isArray(o)?{atomicClasses:o}:{},origins:l&&typeof l=="object"?l:{}}}var G=require("@babel/core"),J=de(require("@cssxio/babel-plugin"),1),M=require("@cssxio/compiler");var ye=/\.(?:[cm]?[jt]sx?|astro)(?:\?.*)?$/,ge=/\.astro(?:\?.*)?$/;async function D(e,t,n={},r){j(n);let s=n.importSource??"@cssxio/cssx";if(!ye.test(t)||!e.includes(s))return null;if(ge.test(t))return he(e,t,n);let m=await I(n),d=await(0,G.transformAsync)(e,{babelrc:!1,configFile:!1,filename:t.split("?",1).join(""),parserOpts:{plugins:["jsx","typescript"]},plugins:[[J.default,{importSource:s,classNameAllocator:n.classNameAllocator,theme:m,reusabilityBudget:n.reusabilityBudget,stableClassNames:n.stableClassNames,darkMode:n.darkMode}]],sourceMaps:!0,...r?{inputSourceMap:r}:{}}),o=d.metadata,{candidates:l,origins:y,composites:C,atomicClasses:h,cssOnlySignature:a}=o.cssx,f=Object.keys(l),p=f.length===0?"":(await(0,M.compileUtilities)(f,g=>l[g],m,(0,M.createSelectorAliases)(C),new Set(h),{darkMode:n.darkMode})).css;return{code:d.code,rules:p?[Se(be(p,n.layer))]:[],candidates:l,composites:C,atomicClasses:h,origins:y,cssOnlySignature:a,map:d.map}}async function he(e,t,n){let r=Ce(e);if(r.length===0)return null;let s=n.classNameAllocator??(0,M.createClassNameAllocator)(),m=n.importSource??"@cssxio/cssx",d={},o={},l=[],y=e;for(let C of[...r].reverse()){let h=await D(`import { sx } from ${JSON.stringify(m)};
4
+ const style = ${C.code};`,`${t}.ts`,{...n,classNameAllocator:s}),a=xe(h.code);y=`${y.slice(0,C.start)}${a}${y.slice(C.end)}`,Object.assign(d,h.candidates),Object.assign(o,h.composites),l.push(...h.rules)}return{code:y,rules:l,candidates:d,composites:o,atomicClasses:[],origins:{},cssOnlySignature:y}}function Ce(e){let t=[],n=/\bsx\s*\(/g;for(let r of e.matchAll(n)){let s=r.index,m=e.indexOf("(",s),d=0,o="";for(let l=m;l<e.length;l+=1){let y=e[l];if(o){y==="\\"?l+=1:y===o&&(o="");continue}if(y==='"'||y==="'"||y==="`")o=y;else if(y==="(")d+=1;else if(y===")"&&--d===0){t.push({start:s,end:l+1,code:e.slice(s,l+1)}),n.lastIndex=l+1;break}}}return t}function xe(e){let t="const style = ",n=e.indexOf(t)+t.length,r=e.indexOf(";",n);return e.slice(n,r)}function K(e,t){if(!e||typeof e!="object")return;let n=e.getCombinedSourcemap;if(typeof n!="function")return;let r=n.call(e);if(!r||typeof r!="object")return;let s=r;if(!(s.version!==3||!Array.isArray(s.sources)||typeof s.mappings!="string"))return{version:s.version,sources:[...s.sources],names:[...s.names??[]],mappings:s.mappings,file:s.file??t.split("?",1).join(""),...s.sourceRoot?{sourceRoot:s.sourceRoot}:{},...s.sourcesContent?{sourcesContent:[...s.sourcesContent]}:{}}}function Se(e){return{className:`cssx-${U(e)}`,css:e}}function be(e,t){return e&&t?`@layer ${t}{${e}}`:e}function H(e,t,n=Date.now()){e.ws.send({type:"update",updates:[{type:"css-update",path:t,acceptedPath:t,timestamp:n}]})}var N="@cssxio/unplugin/rules",we=/\.(?:[cm]?[jt]sx?|astro)(?:\?.*)?$/;function ke(e,t,n){let r=new Set;for(let s of t)e.moduleGraph?.invalidateModule(s,r,n,!0);for(let s of r){if(!s.id)continue;let m=e.runner?.evaluatedModules?.getModuleById(s.id);m&&e.runner?.evaluatedModules?.invalidateModule(m)}}function ve(e){return!e||typeof e!="object"?{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""}:Me(e[N])}function Me(e){if(!e||typeof e!="object")return{id:"",rules:[],candidates:{},composites:{},origins:{},cssOnlySignature:""};let{id:t,rules:n,candidates:r,composites:s,atomicClasses:m,origins:d,cssOnlySignature:o}=e;return{id:typeof t=="string"?t:"",rules:Array.isArray(n)?n:[],candidates:r&&typeof r=="object"?r:{},composites:s&&typeof s=="object"?s:{},...Array.isArray(m)?{atomicClasses:m}:{},origins:d&&typeof d=="object"?d:{},cssOnlySignature:typeof o=="string"?o:""}}var Re=(e={},t)=>{j(e);let n=e.cssFileName??"cssx.css",r=e.sourceMap??!0,s=new Map,m=(0,Z.createClassNameAllocator)(),d=new Map,o,l=process.cwd(),y,C=()=>I(e),h=async function(a,f){let p=new Set(Object.values(f).flatMap(u=>u.type==="chunk"?Object.keys(u.modules??{}):[]).map(b));if(t.framework!=="vite")for(let u of s.keys())p.has(u)||s.delete(u);let g=t.framework==="vite"?[...s.values()]:[...p].map(u=>{let x=ve(this.getModuleInfo(u)?.meta);return Object.keys(x.candidates).length>0?x:s.get(u)??x}),c=await k(g,await C(),e.layer,r,e.darkMode);if(!c.css)return;let i=A(n,c.css);if(Object.hasOwn(f,i))throw new Error(`CSSX CSS asset collision at "${i}".`);if(this.emitFile({type:"asset",fileName:i,source:v(c,i)}),c.map){let u=`${i}.map`;if(Object.hasOwn(f,u))throw new Error(`CSSX CSS map asset collision at "${u}".`);this.emitFile({type:"asset",fileName:u,source:O(c.map,i)})}};return{name:"@cssxio/unplugin",enforce:"pre",transform:{filter:{id:we},async handler(a,f){e.themeFile&&this.addWatchFile?.((0,w.resolve)(process.cwd(),e.themeFile));let p=await D(a,f,{...e,classNameAllocator:m},K(this,f)),g={id:b(f),rules:p?.rules??[],candidates:p?.candidates??{},composites:p?.composites??{},atomicClasses:p?.atomicClasses??[],origins:p?.origins??{},cssOnlySignature:p?.cssOnlySignature??""};z(this,g,N);let c=b(f);(p||c===f)&&(s.set(c,g),d.set((0,w.resolve)(l,c),g)),t.framework==="vite"&&y&&H(y,E("/",n));let i=p?.code??a;return{code:(t.framework==="webpack"||t.framework==="rspack")&&p?`${i}
5
+ ${Oe(n)}`:i,meta:{[N]:g},...p?.map?{map:p.map}:{}}}},watchChange(a,f){f.event==="delete"&&s.delete(b(a))},rollup:{generateBundle:h},vite:{generateBundle:h,configureServer(a){y=a;let f=E(a.config.base,n),p=E("/",n);a.watcher?.on("unlink",g=>{s.delete(b(g)),H(a,p)}),a.middlewares.use((g,c,i)=>{let u=g.url?.split("?",1)[0];if(u!==f&&(u!==`${f}.map`||!r))return i();C().then(x=>k([...s.values()],x,e.layer,r,e.darkMode)).then(x=>{if(u===`${f}.map`){c.setHeader("Content-Type","application/json; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(x.map?O(x.map,n):"");return}c.setHeader("Content-Type","text/css; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(v(x,n))}).catch(x=>{c.setHeader("Content-Type","text/plain; charset=utf-8"),c.end(x instanceof Error?x.message:"Unable to compile CSSX development stylesheet.")})})},hotUpdate:{order:"pre",async handler(a){let f=this.environment;if(!f||f.name==="client")return;let p=a.modules.filter(i=>{let u=s.get(b(i.id??""));return!!(u&&u.cssOnlySignature&&u.atomicClasses?.length===0)});if(p.length===0)return;let g=new Map(p.map(i=>[i,s.get(b(i.id)).cssOnlySignature]));for(let i of p)i.url&&await f.transformRequest(i.url);if(p.every(i=>{let u=s.get(b(i.id));return!!(u&&u.atomicClasses.length===0&&u.cssOnlySignature===g.get(i))}))return ke(f,p,a.timestamp),a.modules.filter(i=>!p.includes(i))}}},...t.framework==="webpack"?{webpack(a){B(a,n,C,e.layer,r,N,s,e.darkMode)}}:{},...t.framework==="rspack"?{rspack(a){B(a,n,C,e.layer,r,N,s,e.darkMode)}}:{},...t.framework==="esbuild"?{esbuild:{config(a){a.metafile=!0},setup(a){let f=a.initialOptions.absWorkingDir??process.cwd();l=f,a.onEnd(async p=>{if(!p.metafile)return;let g=new Set(Object.keys(p.metafile.inputs).map(x=>(0,w.resolve)(f,x)));for(let x of d.keys())g.has(x)||d.delete(x);let c=await k([...d.values()],await C(),e.layer,r,e.darkMode),i=q(f,a.initialOptions,A(n,c.css));if(!c.css){o&&await(0,R.unlink)(o).catch(()=>{}),o=void 0;return}let u=v(c,(0,w.basename)(i));if(a.initialOptions.write===!1){let x=p.outputFiles;if(!x)return;let te={path:i,contents:Y.Buffer.from(u),hash:"",text:u};if(x.findIndex(ne=>ne.path===i)!==-1)throw new Error(`CSSX CSS asset collision at "${i}".`);x.push(te);return}await(0,R.mkdir)((0,w.dirname)(i),{recursive:!0}),await(0,R.writeFile)(i,u),o=i})}}}:{}}},F=(0,Q.createUnplugin)(Re);function Oe(e){return`if (typeof document !== "undefined" && typeof module !== "undefined" && module.hot) {
6
+ const key = "__cssxStylesheetHmr";
7
+ const state = globalThis[key] || (globalThis[key] = { revision: 0, staged: [], replacements: [] });
8
+ const stylesheetLink = [...document.querySelectorAll('link[rel="stylesheet"]')].find((link) =>
9
+ new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
10
+ );
11
+ const nextLink = stylesheetLink && (() => {
12
+ const path = new URL(stylesheetLink.href, document.baseURI).pathname;
13
+ return path.includes("/_next/");
14
+ })();
15
+ if (!state.installed) {
16
+ state.installed = true;
17
+ state.stage = () => {
18
+ const revision = ++state.revision;
19
+ state.staged = [];
20
+ state.replacements = [];
21
+ const links = [...document.querySelectorAll('link[rel="stylesheet"]')].filter((link) =>
22
+ new URL(link.href, document.baseURI).pathname.endsWith(${JSON.stringify(`/${e}`)}),
23
+ );
24
+ return Promise.all(
25
+ links.map(
26
+ (link) =>
27
+ new Promise((resolve) => {
28
+ const replacement = link.cloneNode();
29
+ const url = new URL(link.href, document.baseURI);
30
+ url.searchParams.set("cssx", String(revision));
31
+ replacement.href = url.href;
32
+ const finish = (loaded) => {
33
+ replacement.removeEventListener("load", onLoad);
34
+ replacement.removeEventListener("error", onError);
35
+ if (loaded) {
36
+ state.staged.push(link);
37
+ if (state.removeOnLoad) link.remove();
38
+ }
39
+ else replacement.remove();
40
+ resolve();
41
+ };
42
+ const onLoad = () => finish(true);
43
+ const onError = () => finish(false);
44
+ replacement.addEventListener("load", onLoad);
45
+ replacement.addEventListener("error", onError);
46
+ state.replacements.push(replacement);
47
+ link.after(replacement);
48
+ }),
49
+ ),
50
+ );
51
+ };
52
+ module.hot.addStatusHandler((status) => {
53
+ if (status === "prepare" || status === "dispose") {
54
+ return state.stage();
55
+ }
56
+ if (status === "idle") {
57
+ for (const link of state.staged) link.remove();
58
+ state.staged = [];
59
+ state.replacements = [];
60
+ }
61
+ if (status === "abort" || status === "fail") {
62
+ for (const replacement of state.replacements) replacement.remove();
63
+ state.staged = [];
64
+ state.replacements = [];
65
+ }
66
+ });
67
+ if (nextLink) module.hot.accept(() => void state.stage());
68
+ for (const updateKey of Object.getOwnPropertyNames(globalThis).filter((name) => name.startsWith("webpackHotUpdate"))) {
69
+ const update = globalThis[updateKey];
70
+ if (typeof update !== "function") continue;
71
+ globalThis[updateKey] = function (...args) {
72
+ void state.stage();
73
+ return update.apply(this, args);
74
+ };
75
+ }
76
+ if (stylesheetLink) {
77
+ state.removeOnLoad = Boolean(nextLink);
78
+ const refresh = async () => {
79
+ try {
80
+ const url = new URL(stylesheetLink.href, document.baseURI);
81
+ url.searchParams.set("cssx-probe", String(Date.now()));
82
+ const css = await fetch(url.href, { cache: "no-store" }).then((response) => response.text());
83
+ if (state.css && state.css !== css) void state.stage();
84
+ state.css = css;
85
+ } catch {
86
+ }
87
+ };
88
+ void refresh();
89
+ state.poll = setInterval(() => void refresh(), 500);
90
+ }
91
+ }
92
+ }`}var qe=F.vite,ze=F.rollup,Ge=F.webpack,ee=F.rspack;var Ae=ee,Ne=Ae;
@@ -0,0 +1,13 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.cjs';
3
+ import '@cssxio/compiler';
4
+
5
+ /**
6
+ * Creates the CSSX adapter for Rspack.
7
+ *
8
+ * @param options CSSX adapter options.
9
+ * @returns The Rspack plugin.
10
+ */
11
+ declare const cssxRspack: (options?: CssxPluginOptions | undefined) => _unplugin.RspackPluginInstance;
12
+
13
+ export { cssxRspack as default };
@@ -0,0 +1,13 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { C as CssxPluginOptions } from './options-CHY4_3I-.js';
3
+ import '@cssxio/compiler';
4
+
5
+ /**
6
+ * Creates the CSSX adapter for Rspack.
7
+ *
8
+ * @param options CSSX adapter options.
9
+ * @returns The Rspack plugin.
10
+ */
11
+ declare const cssxRspack: (options?: CssxPluginOptions | undefined) => _unplugin.RspackPluginInstance;
12
+
13
+ export { cssxRspack as default };