@salty-css/vite 0.0.1-alpha.232 → 0.0.1-alpha.234

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +18 -18
  2. package/index.js +276 -256
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,42 +1,42 @@
1
- "use strict";var Dt=Object.defineProperty;var Ot=(e,t,s)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var tt=(e,t,s)=>Ot(e,typeof t!="symbol"?t+"":t,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Et=require("esbuild"),Vt=require("child_process"),c=require("path"),f=require("fs"),ct=require("fs/promises"),K=require("winston"),rt=require("typescript");var it=typeof document<"u"?document.currentScript:null;function Mt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const wt=Mt(Et),yt=e=>String.fromCharCode(e+(e>25?39:97)),vt=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=yt(n%52)+s;return s=yt(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Rt=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},J=(e,t=5)=>{const s=Rt(5381,JSON.stringify(e))>>>0;return vt(s,t)};function v(e){return e?typeof e!="string"?v(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const At=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:i}=o;s=s.replace(r,y=>{const{value:g,css:h}=i(y);return h&&n.push(h),g})}),{transformed:s,additionalCss:n}},$t=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${v(o[1].replaceAll(".","-"))})`)},zt=$t(),Jt=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Wt=(e,t,s)=>Jt.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Zt=["Webkit","Moz","ms","O"],qt=e=>e.startsWith("-")?e:Zt.some(t=>e.startsWith(t))?`-${v(e)}`:v(e),et=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,r=Object.entries(e),i=async([p,d])=>{const b=p.trim(),N=qt(b),x=(M,T=";")=>`${N}:${M}${T}`,E={scope:t,config:s};if(typeof d=="function")return i([p,d(E)]);if(d instanceof Promise)return i([p,await d]);if(typeof d=="object"){if(!d)return;if(d.isColor)return x(d.toString());if(b==="defaultVariants")return;if(b==="variants"){const k=Object.entries(d);for(const[a,$]of k){if(!$)return;const C=Object.entries($);for(const[l,j]of C){if(!j)return;const _=`${t}.${a}-${l}`;(await et(j,_,s)).forEach(z=>o.add(z))}}return}if(b==="compoundVariants"){for(const k of d){const{css:a,...$}=k,C=Object.entries($).reduce((j,[_,D])=>`${j}.${_}-${D}`,t);(await et(a,C,s)).forEach(j=>o.add(j))}return}if(b.startsWith("@")){const k=b,a=await U(d,t,s),$=`${k} { ${a} }`;o.add($);return}const M=p.includes("&")?b.replace("&",t):b.startsWith(":")?`${t}${b}`:`${t} ${b}`;(await et(d,M,s)).forEach(k=>o.add(k));return}if(typeof d=="number"){const M=Wt(N,d);return x(M)}if(typeof d!="string")if("toString"in d)d=d.toString();else throw new Error(`Invalid value type for property ${N}`);return x(d)},y=r.map(i),{modifiers:g}={},h=[$t(),At(g)],w=(await Promise.all(y).then(p=>Promise.all(p.map(d=>h.reduce(async(b,N)=>{const x=await b;if(!x)return x;const E=await N(x);if(!E)return x;const{transformed:M,additionalCss:T}=E;let k="";if(T)for(const a of T)k+=await U(a,"");return`${k}${M}`},Promise.resolve(d)))))).filter(p=>p!==void 0).join(`
1
+ "use strict";var Rt=Object.defineProperty;var Mt=(e,t,s)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var nt=(e,t,s)=>Mt(e,typeof t!="symbol"?t+"":t,s);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const vt=require("esbuild"),At=require("child_process"),c=require("path"),f=require("fs"),dt=require("fs/promises"),Q=require("winston"),lt=require("typescript");var ft=typeof document<"u"?document.currentScript:null;function zt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const jt=zt(vt),bt=e=>String.fromCharCode(e+(e>25?39:97)),Jt=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=bt(n%52)+s;return s=bt(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Wt=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},J=(e,t=5)=>{const s=Wt(5381,JSON.stringify(e))>>>0;return Jt(s,t)};function v(e){return e?typeof e!="string"?v(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const Zt=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:i}=o;s=s.replace(r,y=>{const{value:g,css:h}=i(y);return h&&n.push(h),g})}),{transformed:s,additionalCss:n}},Ft=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${v(o[1].replaceAll(".","-"))})`)},qt=Ft(),It=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Ht=(e,t,s)=>It.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Lt=["Webkit","Moz","ms","O"],Gt=e=>e.startsWith("-")?e:Lt.some(t=>e.startsWith(t))?`-${v(e)}`:v(e),ot=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,r=Object.entries(e),i=async([p,d])=>{const $=p.trim(),P=Gt($),x=(R,k=";")=>`${P}:${R}${k}`,E={scope:t,config:s};if(typeof d=="function")return i([p,d(E)]);if(d instanceof Promise)return i([p,await d]);if(typeof d=="object"){if(!d)return;if(d.isColor)return x(d.toString());if($==="defaultVariants")return;if($==="variants"){const D=Object.entries(d);for(const[a,b]of D){if(!b)return;const C=Object.entries(b);for(const[l,j]of C){if(!j)return;const N=`${t}.${a}-${l}`;(await ot(j,N,s)).forEach(z=>o.add(z))}}return}if($==="compoundVariants"){for(const D of d){const{css:a,...b}=D,C=Object.entries(b).reduce((j,[N,O])=>`${j}.${N}-${O}`,t);(await ot(a,C,s)).forEach(j=>o.add(j))}return}if($.startsWith("@")){const D=$,a=await B(d,t,s),b=`${D} { ${a} }`;o.add(b);return}const R=p.includes("&")?$.replace("&",t):$.startsWith(":")?`${t}${$}`:`${t} ${$}`;(await ot(d,R,s)).forEach(D=>o.add(D));return}if(typeof d=="number"){const R=Ht(P,d);return x(R)}if(typeof d!="string")if("toString"in d)d=d.toString();else throw new Error(`Invalid value type for property ${P}`);return x(d)},y=r.map(i),{modifiers:g}={},h=[Ft(),Zt(g)],w=(await Promise.all(y).then(p=>Promise.all(p.map(d=>h.reduce(async($,P)=>{const x=await $;if(!x)return x;const E=await P(x);if(!E)return x;const{transformed:R,additionalCss:k}=E;let D="";if(k)for(const a of k)D+=await B(a,"");return`${D}${R}`},Promise.resolve(d)))))).filter(p=>p!==void 0).join(`
2
2
  `);if(!w.trim())return Array.from(o);const m=t?`${t} {
3
3
  ${w}
4
- }`:w;return o.has(m)?Array.from(o):[m,...o]},U=async(e,t,s,n=!1)=>(await et(e,t,s,n)).join(`
5
- `),bt=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,r]of Object.entries(e))if(typeof r!="function")if(r&&typeof r=="object"){const i=o.trim(),y=await bt(r,[...t,i]);s.push(y)}else n[o]=r;if(Object.keys(n).length){const o=t.map(v).join("-"),r="t_"+J(o,4),i=await U(n,`.${o}, .${r}`);s.push(i)}return s.join(`
6
- `)},It=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=St(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},St=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?St(o,r,s):s.add(t)}),[...s]):[],jt=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return f.existsSync(t)?t:jt(c.join(e,".."))},Ht=async e=>{const t=jt(e);return await ct.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Lt=async e=>{const t=await Ht(e);if(t)return t.type};let Z;const Ft=async e=>{if(Z)return Z;const t=await Lt(e);return t==="module"?Z="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:it&&it.tagName.toUpperCase()==="SCRIPT"&&it.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(Z="cjs"),Z||"esm"},at=K.createLogger({level:"debug",format:K.format.combine(K.format.colorize(),K.format.cli()),transports:[new K.transports.Console({})]});function Ct(e){return e?typeof e!="string"?Ct(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Gt={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},q=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Kt=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{});class Ut{constructor(t){tt(this,"_path");this.params=t}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(t){return this._path=t,this}}class Qt{constructor(t){tt(this,"_path");tt(this,"templates",[]);this.params=t,Object.entries(t).forEach(([s,n])=>{this.templates.push(new Ut({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(t=>[t.params.name,t]))}get isDefineTemplates(){return!0}_setPath(t){return this._path=t,this.templates.forEach(s=>s._setPath(t)),this}}const Bt=e=>new Qt(e),Xt=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),r=rt.createSourceFile("temp.ts",e,rt.ScriptTarget.Latest,!0);function i(y){if(rt.isVariableDeclaration(y)&&y.name.getText()===t){const g=y.getStart(),h=y.getEnd();clearTimeout(o),s([g,h])}y.forEachChild(i)}i(r)}),A={externalModules:[],rcFile:void 0,destDir:void 0},Pt=e=>{if(A.externalModules.length>0)return A.externalModules;const s=f.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return A.externalModules=n,n},W=async e=>{if(A.destDir)return A.destDir;const t=await lt(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return A.destDir=s,s},Nt=["salty","css","styles","styled"],Yt=(e=[])=>new RegExp(`\\.(${[...Nt,...e].join("|")})\\.`),I=(e,t=[])=>Yt(t).test(e),_t=async e=>{if(A.rcFile)return A.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await ct.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(A.rcFile=s,s):_t(c.join(e,".."))},lt=async e=>{var n,o;const t=await _t(e),s=(n=t.projects)==null?void 0:n.find(r=>e.endsWith(r.dir||""));return s||((o=t.projects)==null?void 0:o.find(r=>r.dir===t.defaultProject))},te=async e=>{const t=await lt(e),s=await W(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),r=await Ft(e),i=Pt(n);await wt.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:i});const y=Date.now(),{config:g}=await import(`${o}?t=${y}`);return{config:g,path:o}},ee=async(e,t)=>{var dt,pt;const s=await W(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async F=>{const{contents:P,outputFilePath:R}=await st(e,F,s);Object.entries(P).forEach(([O,V])=>{V.isMedia?n.mediaQueries.push([O,V]):V.isGlobalDefine?n.globalStyles.push(V):V.isDefineVariables?n.variables.push(V):V.isDefineTemplates&&n.templates.push(V._setPath(`${O};;${R}`))})}));const{config:o,path:r}=await te(e),i={...o},y=new Set,g=(F,P=[])=>F?Object.entries(F).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return g(O,[...P,R]);const V=Ct(R),nt=v(R),ot=[...P,V].join(".");y.add(`"${ot}"`);const Y=[...P.map(v),nt].join("-"),mt=zt(O);return mt?`--${Y}: ${mt.transformed};`:`--${Y}: ${O};`}):[],h=F=>F?Object.entries(F).flatMap(([P,R])=>{const O=g(R);return P==="base"?O.join(""):`${P} { ${O.join("")} }`}):[],u=F=>F?Object.entries(F).flatMap(([P,R])=>Object.entries(R).flatMap(([O,V])=>{const nt=g(V,[P]),ot=`.${P}-${O}, [data-${P}="${O}"]`,Y=nt.join("");return`${ot} { ${Y} }`})):[],w=F=>({...F,responsive:void 0,conditional:void 0}),m=F=>n.variables.map(P=>F==="static"?w(P._current):P._current[F]),S=q(w(o.variables),m("static")),p=g(S),d=q((dt=o.variables)==null?void 0:dt.responsive,m("responsive")),b=h(d),N=q((pt=o.variables)==null?void 0:pt.conditional,m("conditional")),x=u(N),E=c.join(s,"css/_variables.css"),M=`:root { ${p.join("")} ${b.join("")} } ${x.join("")}`;f.writeFileSync(E,M),i.staticVariables=S;const T=c.join(s,"css/_global.css"),k=q(o.global,n.globalStyles),a=await U(k,"");f.writeFileSync(T,`@layer global { ${a} }`);const $=c.join(s,"css/_reset.css"),l=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Gt,j=await U(l,"");f.writeFileSync($,`@layer reset { ${j} }`);const _=c.join(s,"css/_templates.css"),D=q(o.templates,n.templates),z=await bt(D),H=It(D);f.writeFileSync(_,`@layer templates { ${z} }`),i.templates=D;const L=o.templates?[Bt(o.templates)._setPath(`config;;${r}`)]:[],Q=Kt(n.templates,L);i.templatePaths=Object.fromEntries(Object.entries(Q).map(([F,P])=>[F,P._path]));const{mediaQueries:B}=n;i.mediaQueries=Object.fromEntries(B.map(([F,P])=>[`@${F}`,P]));const G=B.map(([F])=>`'@${F}'`).join(" | "),X=c.join(s,"types/css-tokens.d.ts"),Tt=`
4
+ }`:w;return o.has(m)?Array.from(o):[m,...o]},B=async(e,t,s,n=!1)=>(await ot(e,t,s,n)).join(`
5
+ `),Ct=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,r]of Object.entries(e))if(typeof r!="function")if(r&&typeof r=="object"){const i=o.trim(),y=await Ct(r,[...t,i]);s.push(y)}else n[o]=r;if(Object.keys(n).length){const o=t.map(v).join("-"),r="t_"+J(o,4),i=await B(n,`.${o}, .${r}`);s.push(i)}return s.join(`
6
+ `)},Kt=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=Pt(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},Pt=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?Pt(o,r,s):s.add(t)}),[...s]):[],Nt=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return f.existsSync(t)?t:Nt(c.join(e,".."))},Ut=async e=>{const t=Nt(e);return await dt.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Qt=async e=>{const t=await Ut(e);if(t)return t.type};let q;const _t=async e=>{if(q)return q;const t=await Qt(e);return t==="module"?q="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.tagName.toUpperCase()==="SCRIPT"&&ft.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(q="cjs"),q||"esm"},ut=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]});function xt(e){return e?typeof e!="string"?xt(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Bt={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},I=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Xt=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{});class Yt{constructor(t){nt(this,"_path");this.params=t}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(t){return this._path=t,this}}class te{constructor(t){nt(this,"_path");nt(this,"templates",[]);this.params=t,Object.entries(t).forEach(([s,n])=>{this.templates.push(new Yt({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(t=>[t.params.name,t]))}get isDefineTemplates(){return!0}_setPath(t){return this._path=t,this.templates.forEach(s=>s._setPath(t)),this}}const ee=e=>new te(e),se=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),r=lt.createSourceFile("temp.ts",e,lt.ScriptTarget.Latest,!0);function i(y){if(lt.isVariableDeclaration(y)&&y.name.getText()===t){const g=y.getStart(),h=y.getEnd();clearTimeout(o),s([g,h])}y.forEachChild(i)}i(r)}),A={externalModules:[],rcFile:void 0,destDir:void 0},Tt=e=>{if(A.externalModules.length>0)return A.externalModules;const s=f.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return A.externalModules=n,n},W=async e=>{if(A.destDir)return A.destDir;const t=await pt(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return A.destDir=s,s},kt=["salty","css","styles","styled"],ne=(e=[])=>new RegExp(`\\.(${[...kt,...e].join("|")})\\.`),H=(e,t=[])=>ne(t).test(e),Dt=async e=>{if(A.rcFile)return A.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await dt.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(A.rcFile=s,s):Dt(c.join(e,".."))},pt=async e=>{var n,o;const t=await Dt(e),s=(n=t.projects)==null?void 0:n.find(r=>e.endsWith(r.dir||""));return s||((o=t.projects)==null?void 0:o.find(r=>r.dir===t.defaultProject))},oe=async e=>{const t=await pt(e),s=await W(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),r=await _t(e),i=Tt(n);await jt.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:i});const y=Date.now(),{config:g}=await import(`${o}?t=${y}`);return{config:g,path:o}},re=async(e,t)=>{var ht,gt;const s=await W(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async F=>{const{contents:_,outputFilePath:U}=await rt(e,F,s);Object.entries(_).forEach(([M,T])=>{T.isMedia?n.mediaQueries.push([M,T]):T.isGlobalDefine?n.globalStyles.push(T):T.isDefineVariables?n.variables.push(T):T.isDefineTemplates&&n.templates.push(T._setPath(`${M};;${U}`))})}));const{config:o,path:r}=await oe(e),i={...o},y=new Set,g=async(F,_=[])=>{if(!F)return[];const U=Object.entries(F).map(async([T,Z])=>{const et=async V=>{if(!V)return;if(V instanceof Promise)return await et(await V);if(typeof V=="function")return await et(await V());if(typeof V=="object")return await g(V,[..._,T]);const it=xt(T),at=v(T),ct=[..._,it].join(".");y.add(`"${ct}"`);const st=[..._.map(v),at].join("-"),wt=qt(V);return wt?`--${st}: ${wt.transformed};`:`--${st}: ${V};`};return await et(Z)});return(await Promise.all(U)).flat()},h=async F=>{if(!F)return[];const _=Object.entries(F).map(async([M,T])=>{const Z=await g(T);return M==="base"?Z.join(""):`${M} { ${Z.join("")} }`});return(await Promise.all(_)).flat()},u=async F=>{if(!F)return[];const _=Object.entries(F).map(async([M,T])=>{const Z=Object.entries(T).map(async([V,it])=>{const at=await g(it,[M]),ct=`.${M}-${V}, [data-${M}="${V}"]`,st=at.join("");return`${ct} { ${st} }`});return(await Promise.all(Z)).flat()});return(await Promise.all(_)).flat()},w=F=>({...F,responsive:void 0,conditional:void 0}),m=F=>n.variables.map(_=>F==="static"?w(_._current):_._current[F]),S=I(w(o.variables),m("static")),p=await g(S),d=I((ht=o.variables)==null?void 0:ht.responsive,m("responsive")),$=await h(d),P=I((gt=o.variables)==null?void 0:gt.conditional,m("conditional")),x=await u(P),E=c.join(s,"css/_variables.css"),R=`:root { ${p.join("")} ${$.join("")} } ${x.join("")}`;f.writeFileSync(E,R),i.staticVariables=S;const k=c.join(s,"css/_global.css"),D=I(o.global,n.globalStyles),a=await B(D,"");f.writeFileSync(k,`@layer global { ${a} }`);const b=c.join(s,"css/_reset.css"),l=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Bt,j=await B(l,"");f.writeFileSync(b,`@layer reset { ${j} }`);const N=c.join(s,"css/_templates.css"),O=I(o.templates,n.templates),z=await Ct(O),L=Kt(O);f.writeFileSync(N,`@layer templates { ${z} }`),i.templates=O;const G=o.templates?[ee(o.templates)._setPath(`config;;${r}`)]:[],X=Xt(n.templates,G);i.templatePaths=Object.fromEntries(Object.entries(X).map(([F,_])=>[F,_._path]));const{mediaQueries:Y}=n;i.mediaQueries=Object.fromEntries(Y.map(([F,_])=>[`@${F}`,_]));const K=Y.map(([F])=>`'@${F}'`).join(" | "),tt=c.join(s,"types/css-tokens.d.ts"),Et=`
7
7
  // Variable types
8
8
  type VariableTokens = ${[...y].join("|")};
9
9
  type PropertyValueToken = \`{\${VariableTokens}}\`;
10
10
 
11
11
  // Template types
12
12
  type TemplateTokens = {
13
- ${Object.entries(H).map(([F,P])=>`${F}?: ${P}`).join(`
13
+ ${Object.entries(L).map(([F,_])=>`${F}?: ${_}`).join(`
14
14
  `)}
15
15
  }
16
16
 
17
17
  // Media query types
18
- type MediaQueryKeys = ${G||"''"};
19
- `;f.writeFileSync(X,Tt);const kt=c.join(s,"cache/config-cache.json");f.writeFileSync(kt,JSON.stringify(i,null,2))},ht=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const y=i.at(1);if(Nt.some(h=>y==null?void 0:y.includes(h)))return t}return"styled('div',"}),se=(e,t)=>{try{const s=f.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
18
+ type MediaQueryKeys = ${K||"''"};
19
+ `;f.writeFileSync(tt,Et);const Vt=c.join(s,"cache/config-cache.json");f.writeFileSync(Vt,JSON.stringify(i,null,2))},$t=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const y=i.at(1);if(kt.some(h=>y==null?void 0:y.includes(h)))return t}return"styled('div',"}),ie=(e,t)=>{try{const s=f.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
20
20
 
21
21
  ${e}`:`globalThis.saltyConfig = {};
22
22
 
23
- ${e}`}catch{return e}},st=async(e,t,s)=>{const n=J(t),o=c.join(s,"./temp");f.existsSync(o)||f.mkdirSync(o);const r=c.parse(t);let i=f.readFileSync(t,"utf8");i=ht(i),i=se(i,e);const y=c.join(s,"js",n+".js"),g=await lt(e),h=c.join(e,(g==null?void 0:g.configDir)||"","salty.config.ts"),u=Pt(h),w=await Ft(e);await wt.build({stdin:{contents:i,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:w,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},d=>{const b=f.readFileSync(d.path,"utf8");return{contents:ht(b),loader:"ts"}})}}]});const m=Date.now();return{contents:await import(`${y}?t=${m}`),outputFilePath:y}},ne=async e=>{const t=await W(e),s=c.join(t,"cache/config-cache.json"),n=f.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ft=async e=>{const t=await ne(e),s=await W(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:r}=await import(`${n}?t=${o}`);return q(r,t)},ut=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},oe=async(e,t=ut(),s=!0)=>{try{const n=Date.now();t?at.info("Generating CSS in production mode! 🔥"):at.info("Generating CSS in development mode! 🚀");const o=[],r=[],i=await W(e),y=c.join(i,"index.css");s&&(()=>{f.existsSync(i)&&Vt.execSync("rm -rf "+i),f.mkdirSync(i,{recursive:!0}),f.mkdirSync(c.join(i,"css")),f.mkdirSync(c.join(i,"types")),f.mkdirSync(c.join(i,"js")),f.mkdirSync(c.join(i,"cache"))})();const h=new Set,u=new Set;async function w(a){const $=["node_modules","saltygen"],C=f.statSync(a);if(C.isDirectory()){const l=f.readdirSync(a);if($.some(_=>a.includes(_)))return;await Promise.all(l.map(_=>w(c.join(a,_))))}else if(C.isFile()&&I(a)){h.add(a);const j=f.readFileSync(a,"utf8");/define[\w\d]+\(/.test(j)&&u.add(a)}}await w(e),await ee(e,u);const m={keyframes:[],components:[],classNames:[]};await Promise.all([...h].map(async a=>{const{contents:$}=await st(e,a,i);for(let[C,l]of Object.entries($))l instanceof Promise&&(l=await l),l.isKeyframes?m.keyframes.push({value:l,src:a,name:C}):l.isClassName?m.classNames.push({...l,src:a,name:C}):l.generator&&m.components.push({...l,src:a,name:C})}));const S=await ft(e);for(const a of m.keyframes){const{value:$}=a,C=`a_${$.animationName}.css`,l=`css/${C}`,j=c.join(i,l);o.push(C),f.writeFileSync(j,$.css)}const p={};for(const a of m.components){const{src:$,name:C}=a;p[$]||(p[$]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:t,config:S});r[l.priority]||(r[l.priority]=[]);const j=await l.css;if(!j)continue;r[l.priority].push(l.cssFileName);const _=`css/${l.cssFileName}`,D=c.join(i,_);f.writeFileSync(D,j),S.importStrategy==="component"&&p[$].push(l.cssFileName)}for(const a of m.classNames){const{src:$,name:C}=a;p[$]||(p[$]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:t,config:S}),j=await l.css;if(!j)continue;r[l.priority]||(r[l.priority]=[]),r[l.priority].push(l.cssFileName);const _=`css/${l.cssFileName}`,D=c.join(i,_);f.writeFileSync(D,j),S.importStrategy==="component"&&p[$].push(l.cssFileName)}S.importStrategy==="component"&&Object.entries(p).forEach(([a,$])=>{const C=$.map(z=>`@import url('./${z}');`).join(`
24
- `),l=J(a,6),j=c.parse(a),_=v(j.name),D=c.join(i,`css/f_${_}-${l}.css`);f.writeFileSync(D,C||"/* Empty file */")});const d=o.map(a=>`@import url('./css/${a}');`).join(`
23
+ ${e}`}catch{return e}},rt=async(e,t,s)=>{const n=J(t),o=c.join(s,"./temp");f.existsSync(o)||f.mkdirSync(o);const r=c.parse(t);let i=f.readFileSync(t,"utf8");i=$t(i),i=ie(i,e);const y=c.join(s,"js",n+".js"),g=await pt(e),h=c.join(e,(g==null?void 0:g.configDir)||"","salty.config.ts"),u=Tt(h),w=await _t(e);await jt.build({stdin:{contents:i,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:w,target:["node20"],keepNames:!0,external:u,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},d=>{const $=f.readFileSync(d.path,"utf8");return{contents:$t($),loader:"ts"}})}}]});const m=Date.now();return{contents:await import(`${y}?t=${m}`),outputFilePath:y}},ae=async e=>{const t=await W(e),s=c.join(t,"cache/config-cache.json"),n=f.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},mt=async e=>{const t=await ae(e),s=await W(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:r}=await import(`${n}?t=${o}`);return I(r,t)},yt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ce=async(e,t=yt(),s=!0)=>{try{const n=Date.now();t?ut.info("Generating CSS in production mode! 🔥"):ut.info("Generating CSS in development mode! 🚀");const o=[],r=[],i=await W(e),y=c.join(i,"index.css");s&&(()=>{f.existsSync(i)&&At.execSync("rm -rf "+i),f.mkdirSync(i,{recursive:!0}),f.mkdirSync(c.join(i,"css")),f.mkdirSync(c.join(i,"types")),f.mkdirSync(c.join(i,"js")),f.mkdirSync(c.join(i,"cache"))})();const h=new Set,u=new Set;async function w(a){const b=["node_modules","saltygen"],C=f.statSync(a);if(C.isDirectory()){const l=f.readdirSync(a);if(b.some(N=>a.includes(N)))return;await Promise.all(l.map(N=>w(c.join(a,N))))}else if(C.isFile()&&H(a)){h.add(a);const j=f.readFileSync(a,"utf8");/define[\w\d]+\(/.test(j)&&u.add(a)}}await w(e),await re(e,u);const m={keyframes:[],components:[],classNames:[]};await Promise.all([...h].map(async a=>{const{contents:b}=await rt(e,a,i);for(let[C,l]of Object.entries(b))l instanceof Promise&&(l=await l),l.isKeyframes?m.keyframes.push({value:l,src:a,name:C}):l.isClassName?m.classNames.push({...l,src:a,name:C}):l.generator&&m.components.push({...l,src:a,name:C})}));const S=await mt(e);for(const a of m.keyframes){const{value:b}=a,C=`a_${b.animationName}.css`,l=`css/${C}`,j=c.join(i,l);o.push(C),f.writeFileSync(j,b.css)}const p={};for(const a of m.components){const{src:b,name:C}=a;p[b]||(p[b]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:t,config:S});r[l.priority]||(r[l.priority]=[]);const j=await l.css;if(!j)continue;r[l.priority].push(l.cssFileName);const N=`css/${l.cssFileName}`,O=c.join(i,N);f.writeFileSync(O,j),S.importStrategy==="component"&&p[b].push(l.cssFileName)}for(const a of m.classNames){const{src:b,name:C}=a;p[b]||(p[b]=[]);const l=a.generator._withBuildContext({callerName:C,isProduction:t,config:S}),j=await l.css;if(!j)continue;r[l.priority]||(r[l.priority]=[]),r[l.priority].push(l.cssFileName);const N=`css/${l.cssFileName}`,O=c.join(i,N);f.writeFileSync(O,j),S.importStrategy==="component"&&p[b].push(l.cssFileName)}S.importStrategy==="component"&&Object.entries(p).forEach(([a,b])=>{const C=b.map(z=>`@import url('./${z}');`).join(`
24
+ `),l=J(a,6),j=c.parse(a),N=v(j.name),O=c.join(i,`css/f_${N}-${l}.css`);f.writeFileSync(O,C||"/* Empty file */")});const d=o.map(a=>`@import url('./css/${a}');`).join(`
25
25
  `);let E=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
26
26
 
27
27
  ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return f.readFileSync(c.join(i,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
28
28
  `)}
29
- ${d}`;if(S.importStrategy!=="component"){const a=r.reduce(($,C,l)=>{const j=C.reduce((H,L)=>{var X;const Q=c.join(i,"css",L),B=f.readFileSync(Q,"utf8"),G=((X=/.*-([^-]+)-\d+.css/.exec(L))==null?void 0:X.at(1))||J(Q,6);return H.includes(G)?H:`${H}
30
- /*start:${G}-${L}*/
31
- ${B}
32
- /*end:${G}*/
33
- `},""),_=`l_${l}.css`,D=c.join(i,"css",_),z=`@layer l${l} { ${j}
34
- }`;return f.writeFileSync(D,z),`${$}
35
- @import url('./css/${_}');`},"");E+=a}f.writeFileSync(y,E);const T=Date.now()-n,k=T<200?"🔥":T<500?"🚀":T<1e3?"🎉":T<2e3?"🚗":T<5e3?"🤔":"🥴";at.info(`Generated CSS in ${T}ms! ${k}`)}catch(n){console.error(n)}},re=async(e,t,s=ut())=>{try{const n=await W(e);if(I(t)){const r=[],i=await ft(e),{contents:y}=await st(e,t,n);for(const[g,h]of Object.entries(y)){if(h.isKeyframes&&h.css){const d=`css/${`a_${h.animationName}.css`}`,b=c.join(n,d);f.writeFileSync(b,await h.css);return}if(h.isClassName){const p=h.generator._withBuildContext({callerName:g,isProduction:s,config:i}),d=await p.css;if(!d)continue;r[p.priority]||(r[p.priority]=[]),r[p.priority].push(p.cssFileName);const b=`css/${p.cssFileName}`,N=c.join(n,b);f.writeFileSync(N,d)}if(!h.generator)return;const u=h.generator._withBuildContext({callerName:g,isProduction:s,config:i}),w=await u.css;if(!w)continue;const m=`css/${u.cssFileName}`,S=c.join(n,m);f.writeFileSync(S,w),r[u.priority]||(r[u.priority]=[]),r[u.priority].push(u.cssFileName)}if(i.importStrategy!=="component")r.forEach((g,h)=>{const u=`l_${h}.css`,w=c.join(n,"css",u);let m=f.readFileSync(w,"utf8");g.forEach(S=>{var N;const p=c.join(n,"css",S),d=((N=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:N.at(1))||J(p,6);if(!m.includes(d)){const x=f.readFileSync(p,"utf8"),E=`/*start:${d}-${S}*/
29
+ ${d}`;if(S.importStrategy!=="component"){const a=r.reduce((b,C,l)=>{const j=C.reduce((L,G)=>{var tt;const X=c.join(i,"css",G),Y=f.readFileSync(X,"utf8"),K=((tt=/.*-([^-]+)-\d+.css/.exec(G))==null?void 0:tt.at(1))||J(X,6);return L.includes(K)?L:`${L}
30
+ /*start:${K}-${G}*/
31
+ ${Y}
32
+ /*end:${K}*/
33
+ `},""),N=`l_${l}.css`,O=c.join(i,"css",N),z=`@layer l${l} { ${j}
34
+ }`;return f.writeFileSync(O,z),`${b}
35
+ @import url('./css/${N}');`},"");E+=a}f.writeFileSync(y,E);const k=Date.now()-n,D=k<200?"🔥":k<500?"🚀":k<1e3?"🎉":k<2e3?"🚗":k<5e3?"🤔":"🥴";ut.info(`Generated CSS in ${k}ms! ${D}`)}catch(n){console.error(n)}},le=async(e,t,s=yt())=>{try{const n=await W(e);if(H(t)){const r=[],i=await mt(e),{contents:y}=await rt(e,t,n);for(const[g,h]of Object.entries(y)){if(h.isKeyframes&&h.css){const d=`css/${`a_${h.animationName}.css`}`,$=c.join(n,d);f.writeFileSync($,await h.css);return}if(h.isClassName){const p=h.generator._withBuildContext({callerName:g,isProduction:s,config:i}),d=await p.css;if(!d)continue;r[p.priority]||(r[p.priority]=[]),r[p.priority].push(p.cssFileName);const $=`css/${p.cssFileName}`,P=c.join(n,$);f.writeFileSync(P,d)}if(!h.generator)return;const u=h.generator._withBuildContext({callerName:g,isProduction:s,config:i}),w=await u.css;if(!w)continue;const m=`css/${u.cssFileName}`,S=c.join(n,m);f.writeFileSync(S,w),r[u.priority]||(r[u.priority]=[]),r[u.priority].push(u.cssFileName)}if(i.importStrategy!=="component")r.forEach((g,h)=>{const u=`l_${h}.css`,w=c.join(n,"css",u);let m=f.readFileSync(w,"utf8");g.forEach(S=>{var P;const p=c.join(n,"css",S),d=((P=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:P.at(1))||J(p,6);if(!m.includes(d)){const x=f.readFileSync(p,"utf8"),E=`/*start:${d}-${S}*/
36
36
  ${x}
37
37
  /*end:${d}*/
38
38
  `;m=`${m.replace(/\}$/,"")}
39
39
  ${E}
40
40
  }`}}),f.writeFileSync(w,m)});else{const g=r.flat().map(S=>`@import url('./${S}');`).join(`
41
- `),h=J(t,6),u=c.parse(t),w=v(u.name),m=c.join(n,`css/f_${w}-${h}.css`);f.writeFileSync(m,g||"/* Empty file */")}}}catch(n){console.error(n)}},ie=async(e,t,s=ut())=>{var n,o;try{const r=await W(e);if(I(t)){const y=f.readFileSync(t,"utf8"),g=await ft(e),{contents:h}=await st(e,t,r);let u=y;for(const[w,m]of Object.entries(h)){if(m.isKeyframes||!m.generator)continue;const S=m.generator._withBuildContext({callerName:w,isProduction:s,config:g}),[p,d]=await Xt(u,w),b=u.slice(p,d);if(m.isClassName){const N=u,x=` ${w} = className("${S.classNames}")`;u=u.replace(b,x),N===u&&console.error("Minimize file failed to change content",{name:w})}if(b.includes("styled")){const N=(o=(n=/styled\(([^,]+),/.exec(b))==null?void 0:n.at(1))==null?void 0:o.trim(),x=u,E=` ${w} = styled(${N}, "${S.classNames}", ${JSON.stringify(S.clientProps)})`;u=u.replace(b,E),x===u&&console.error("Minimize file failed to change content",{name:w,tagName:N})}}if(g.importStrategy==="component"){const w=J(t,6),m=c.parse(t);u=`import '../../saltygen/css/${`f_${v(m.name)}-${w}.css`}';
42
- ${u}`}return u=u.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),u=u.replace("{ styled }","{ styledClient as styled }"),u=u.replace("@salty-css/react/styled","@salty-css/react/styled-client"),u}}catch(r){console.error("Error in minimizeFile:",r)}},gt=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!I(e))return!1;const n=await ct.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},xt=e=>({name:"stylegen",buildStart:()=>oe(e),load:async t=>{if(I(t))return await ie(e,t)},handleHotUpdate:async({file:t,server:s})=>{await gt(t)&&s.restart()},watchChange:{handler:async t=>{I(t)&&(await gt(t)||await re(e,t))}}});exports.default=xt;exports.saltyPlugin=xt;
41
+ `),h=J(t,6),u=c.parse(t),w=v(u.name),m=c.join(n,`css/f_${w}-${h}.css`);f.writeFileSync(m,g||"/* Empty file */")}}}catch(n){console.error(n)}},fe=async(e,t,s=yt())=>{var n,o;try{const r=await W(e);if(H(t)){const y=f.readFileSync(t,"utf8"),g=await mt(e),{contents:h}=await rt(e,t,r);let u=y;for(const[w,m]of Object.entries(h)){if(m.isKeyframes||!m.generator)continue;const S=m.generator._withBuildContext({callerName:w,isProduction:s,config:g}),[p,d]=await se(u,w),$=u.slice(p,d);if(m.isClassName){const P=u,x=` ${w} = className("${S.classNames}")`;u=u.replace($,x),P===u&&console.error("Minimize file failed to change content",{name:w})}if($.includes("styled")){const P=(o=(n=/styled\(([^,]+),/.exec($))==null?void 0:n.at(1))==null?void 0:o.trim(),x=u,E=` ${w} = styled(${P}, "${S.classNames}", ${JSON.stringify(S.clientProps)})`;u=u.replace($,E),x===u&&console.error("Minimize file failed to change content",{name:w,tagName:P})}}if(g.importStrategy==="component"){const w=J(t,6),m=c.parse(t);u=`import '../../saltygen/css/${`f_${v(m.name)}-${w}.css`}';
42
+ ${u}`}return u=u.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),u=u.replace("{ styled }","{ styledClient as styled }"),u=u.replace("@salty-css/react/styled","@salty-css/react/styled-client"),u}}catch(r){console.error("Error in minimizeFile:",r)}},St=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!H(e))return!1;const n=await dt.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},Ot=e=>({name:"stylegen",buildStart:()=>ce(e),load:async t=>{if(H(t))return await fe(e,t)},handleHotUpdate:async({file:t,server:s})=>{await St(t)&&s.restart()},watchChange:{handler:async t=>{H(t)&&(await St(t)||await le(e,t))}}});exports.default=Ot;exports.saltyPlugin=Ot;
package/index.js CHANGED
@@ -1,40 +1,40 @@
1
- var Ot = Object.defineProperty;
2
- var Vt = (e, t, s) => t in e ? Ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var et = (e, t, s) => Vt(e, typeof t != "symbol" ? t + "" : t, s);
4
- import * as Ct from "esbuild";
5
- import { execSync as Mt } from "child_process";
6
- import { join as u, parse as nt } from "path";
7
- import { existsSync as ft, mkdirSync as I, statSync as vt, readdirSync as Rt, readFileSync as M, writeFileSync as x } from "fs";
8
- import { readFile as ut } from "fs/promises";
9
- import { createLogger as At, format as at, transports as Jt } from "winston";
10
- import ct from "typescript";
11
- const $t = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), zt = (e, t) => {
1
+ var vt = Object.defineProperty;
2
+ var At = (e, t, s) => t in e ? vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var ot = (e, t, s) => At(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import * as Pt from "esbuild";
5
+ import { execSync as Jt } from "child_process";
6
+ import { join as u, parse as at } from "path";
7
+ import { existsSync as mt, mkdirSync as G, statSync as zt, readdirSync as Wt, readFileSync as M, writeFileSync as x } from "fs";
8
+ import { readFile as ht } from "fs/promises";
9
+ import { createLogger as Zt, format as ut, transports as Ht } from "winston";
10
+ import pt from "typescript";
11
+ const St = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), It = (e, t) => {
12
12
  let s = "", n;
13
- for (n = Math.abs(e); n > 52; n = n / 52 | 0) s = $t(n % 52) + s;
14
- return s = $t(n % 52) + s, s.length < t ? s = s.padStart(t, "a") : s.length > t && (s = s.slice(-t)), s;
15
- }, Wt = (e, t) => {
13
+ for (n = Math.abs(e); n > 52; n = n / 52 | 0) s = St(n % 52) + s;
14
+ return s = St(n % 52) + s, s.length < t ? s = s.padStart(t, "a") : s.length > t && (s = s.slice(-t)), s;
15
+ }, Gt = (e, t) => {
16
16
  let s = t.length;
17
17
  for (; s; ) e = e * 33 ^ t.charCodeAt(--s);
18
18
  return e;
19
19
  }, W = (e, t = 5) => {
20
- const s = Wt(5381, JSON.stringify(e)) >>> 0;
21
- return zt(s, t);
20
+ const s = Gt(5381, JSON.stringify(e)) >>> 0;
21
+ return It(s, t);
22
22
  };
23
- function R(e) {
24
- return e ? typeof e != "string" ? R(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "-" : "") + t.toLowerCase()) : "";
23
+ function A(e) {
24
+ return e ? typeof e != "string" ? A(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "-" : "") + t.toLowerCase()) : "";
25
25
  }
26
- const Zt = (e) => (t) => {
26
+ const Kt = (e) => (t) => {
27
27
  if (typeof t != "string" || !e) return;
28
28
  let s = t;
29
29
  const n = [];
30
30
  return Object.values(e).forEach((o) => {
31
- const { pattern: r, transform: i } = o;
31
+ const { pattern: r, transform: a } = o;
32
32
  s = s.replace(r, (m) => {
33
- const { value: y, css: h } = i(m);
33
+ const { value: y, css: h } = a(m);
34
34
  return h && n.push(h), y;
35
35
  });
36
36
  }), { transformed: s, additionalCss: n };
37
- }, St = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) => `var(--${R(o[1].replaceAll(".", "-"))})`) }, Ht = St(), It = [
37
+ }, Nt = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) => `var(--${A(o[1].replaceAll(".", "-"))})`) }, Lt = Nt(), Qt = [
38
38
  "top",
39
39
  "right",
40
40
  "bottom",
@@ -55,65 +55,65 @@ const Zt = (e) => (t) => {
55
55
  /.*size.*/,
56
56
  /.*thickness.*/,
57
57
  /.*font-size.*/
58
- ], Gt = (e, t, s) => It.some((o) => typeof o == "string" ? o === e : o.test(e)) ? `${t}px` : `${t}`, Kt = ["Webkit", "Moz", "ms", "O"], Lt = (e) => e.startsWith("-") ? e : Kt.some((t) => e.startsWith(t)) ? `-${R(e)}` : R(e), st = async (e, t = "", s, n = !1) => {
58
+ ], Bt = (e, t, s) => Qt.some((o) => typeof o == "string" ? o === e : o.test(e)) ? `${t}px` : `${t}`, Ut = ["Webkit", "Moz", "ms", "O"], qt = (e) => e.startsWith("-") ? e : Ut.some((t) => e.startsWith(t)) ? `-${A(e)}` : A(e), rt = async (e, t = "", s, n = !1) => {
59
59
  if (!e) throw new Error("No styles provided to parseStyles function!");
60
- const o = /* @__PURE__ */ new Set(), r = Object.entries(e), i = async ([p, f]) => {
61
- const w = p.trim(), P = Lt(w), _ = (v, T = ";") => `${P}:${v}${T}`, O = { scope: t, config: s };
62
- if (typeof f == "function") return i([p, f(O)]);
63
- if (f instanceof Promise) return i([p, await f]);
60
+ const o = /* @__PURE__ */ new Set(), r = Object.entries(e), a = async ([p, f]) => {
61
+ const $ = p.trim(), F = qt($), _ = (R, D = ";") => `${F}:${R}${D}`, O = { scope: t, config: s };
62
+ if (typeof f == "function") return a([p, f(O)]);
63
+ if (f instanceof Promise) return a([p, await f]);
64
64
  if (typeof f == "object") {
65
65
  if (!f) return;
66
66
  if (f.isColor) return _(f.toString());
67
- if (w === "defaultVariants") return;
68
- if (w === "variants") {
69
- const D = Object.entries(f);
70
- for (const [a, $] of D) {
71
- if (!$) return;
72
- const j = Object.entries($);
67
+ if ($ === "defaultVariants") return;
68
+ if ($ === "variants") {
69
+ const k = Object.entries(f);
70
+ for (const [i, w] of k) {
71
+ if (!w) return;
72
+ const j = Object.entries(w);
73
73
  for (const [c, C] of j) {
74
74
  if (!C) return;
75
- const N = `${t}.${a}-${c}`;
76
- (await st(C, N, s)).forEach((z) => o.add(z));
75
+ const P = `${t}.${i}-${c}`;
76
+ (await rt(C, P, s)).forEach((z) => o.add(z));
77
77
  }
78
78
  }
79
79
  return;
80
80
  }
81
- if (w === "compoundVariants") {
82
- for (const D of f) {
83
- const { css: a, ...$ } = D, j = Object.entries($).reduce((C, [N, k]) => `${C}.${N}-${k}`, t);
84
- (await st(a, j, s)).forEach((C) => o.add(C));
81
+ if ($ === "compoundVariants") {
82
+ for (const k of f) {
83
+ const { css: i, ...w } = k, j = Object.entries(w).reduce((C, [P, E]) => `${C}.${P}-${E}`, t);
84
+ (await rt(i, j, s)).forEach((C) => o.add(C));
85
85
  }
86
86
  return;
87
87
  }
88
- if (w.startsWith("@")) {
89
- const D = w, a = await U(f, t, s), $ = `${D} { ${a} }`;
90
- o.add($);
88
+ if ($.startsWith("@")) {
89
+ const k = $, i = await X(f, t, s), w = `${k} { ${i} }`;
90
+ o.add(w);
91
91
  return;
92
92
  }
93
- const v = p.includes("&") ? w.replace("&", t) : w.startsWith(":") ? `${t}${w}` : `${t} ${w}`;
94
- (await st(f, v, s)).forEach((D) => o.add(D));
93
+ const R = p.includes("&") ? $.replace("&", t) : $.startsWith(":") ? `${t}${$}` : `${t} ${$}`;
94
+ (await rt(f, R, s)).forEach((k) => o.add(k));
95
95
  return;
96
96
  }
97
97
  if (typeof f == "number") {
98
- const v = Gt(P, f);
99
- return _(v);
98
+ const R = Bt(F, f);
99
+ return _(R);
100
100
  }
101
101
  if (typeof f != "string")
102
102
  if ("toString" in f) f = f.toString();
103
- else throw new Error(`Invalid value type for property ${P}`);
103
+ else throw new Error(`Invalid value type for property ${F}`);
104
104
  return _(f);
105
- }, m = r.map(i), { modifiers: y } = {}, h = [St(), Zt(y)], g = (await Promise.all(m).then((p) => Promise.all(
106
- p.map((f) => h.reduce(async (w, P) => {
107
- const _ = await w;
105
+ }, m = r.map(a), { modifiers: y } = {}, h = [Nt(), Kt(y)], g = (await Promise.all(m).then((p) => Promise.all(
106
+ p.map((f) => h.reduce(async ($, F) => {
107
+ const _ = await $;
108
108
  if (!_) return _;
109
- const O = await P(_);
109
+ const O = await F(_);
110
110
  if (!O) return _;
111
- const { transformed: v, additionalCss: T } = O;
112
- let D = "";
113
- if (T)
114
- for (const a of T)
115
- D += await U(a, "");
116
- return `${D}${v}`;
111
+ const { transformed: R, additionalCss: D } = O;
112
+ let k = "";
113
+ if (D)
114
+ for (const i of D)
115
+ k += await X(i, "");
116
+ return `${k}${R}`;
117
117
  }, Promise.resolve(f)))
118
118
  ))).filter((p) => p !== void 0).join(`
119
119
  `);
@@ -122,52 +122,52 @@ const Zt = (e) => (t) => {
122
122
  ${g}
123
123
  }` : g;
124
124
  return o.has(d) ? Array.from(o) : [d, ...o];
125
- }, U = async (e, t, s, n = !1) => (await st(e, t, s, n)).join(`
126
- `), jt = async (e, t = []) => {
125
+ }, X = async (e, t, s, n = !1) => (await rt(e, t, s, n)).join(`
126
+ `), _t = async (e, t = []) => {
127
127
  if (!e) return "";
128
128
  const s = [], n = {};
129
129
  for (const [o, r] of Object.entries(e))
130
130
  if (typeof r != "function") if (r && typeof r == "object") {
131
- const i = o.trim(), m = await jt(r, [...t, i]);
131
+ const a = o.trim(), m = await _t(r, [...t, a]);
132
132
  s.push(m);
133
133
  } else
134
134
  n[o] = r;
135
135
  if (Object.keys(n).length) {
136
- const o = t.map(R).join("-"), r = "t_" + W(o, 4), i = await U(n, `.${o}, .${r}`);
137
- s.push(i);
136
+ const o = t.map(A).join("-"), r = "t_" + W(o, 4), a = await X(n, `.${o}, .${r}`);
137
+ s.push(a);
138
138
  }
139
139
  return s.join(`
140
140
  `);
141
- }, Qt = (e) => e ? Object.entries(e).reduce((t, [s, n]) => (typeof n == "function" ? t[s] = "any" : typeof n == "object" && (t[s] = Ft(n).map((o) => `"${o}"`).join(" | ")), t), {}) : {}, Ft = (e, t = "", s = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([n, o]) => {
141
+ }, Xt = (e) => e ? Object.entries(e).reduce((t, [s, n]) => (typeof n == "function" ? t[s] = "any" : typeof n == "object" && (t[s] = xt(n).map((o) => `"${o}"`).join(" | ")), t), {}) : {}, xt = (e, t = "", s = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([n, o]) => {
142
142
  const r = t ? `${t}.${n}` : n;
143
- return typeof o == "object" ? Ft(o, r, s) : s.add(t);
144
- }), [...s]) : [], Pt = (e) => {
143
+ return typeof o == "object" ? xt(o, r, s) : s.add(t);
144
+ }), [...s]) : [], Tt = (e) => {
145
145
  if (!e || e === "/") throw new Error("Could not find package.json file");
146
146
  const t = u(e, "package.json");
147
- return ft(t) ? t : Pt(u(e, ".."));
148
- }, Bt = async (e) => {
149
- const t = Pt(e);
150
- return await ut(t, "utf-8").then(JSON.parse).catch(() => {
147
+ return mt(t) ? t : Tt(u(e, ".."));
148
+ }, Yt = async (e) => {
149
+ const t = Tt(e);
150
+ return await ht(t, "utf-8").then(JSON.parse).catch(() => {
151
151
  });
152
- }, Ut = async (e) => {
153
- const t = await Bt(e);
152
+ }, te = async (e) => {
153
+ const t = await Yt(e);
154
154
  if (t)
155
155
  return t.type;
156
156
  };
157
- let H;
158
- const Nt = async (e) => {
159
- if (H) return H;
160
- const t = await Ut(e);
161
- return t === "module" ? H = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (H = "cjs"), H || "esm";
162
- }, lt = At({
157
+ let I;
158
+ const Dt = async (e) => {
159
+ if (I) return I;
160
+ const t = await te(e);
161
+ return t === "module" ? I = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (I = "cjs"), I || "esm";
162
+ }, dt = Zt({
163
163
  level: "debug",
164
- format: at.combine(at.colorize(), at.cli()),
165
- transports: [new Jt.Console({})]
164
+ format: ut.combine(ut.colorize(), ut.cli()),
165
+ transports: [new Ht.Console({})]
166
166
  });
167
- function _t(e) {
168
- return e ? typeof e != "string" ? _t(String(e)) : e.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "." : "") + t.toLowerCase()) : "";
167
+ function kt(e) {
168
+ return e ? typeof e != "string" ? kt(String(e)) : e.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "." : "") + t.toLowerCase()) : "";
169
169
  }
170
- const qt = {
170
+ const ee = {
171
171
  /** Set box model to border-box */
172
172
  "*, *::before, *::after": {
173
173
  boxSizing: "border-box"
@@ -213,10 +213,10 @@ const qt = {
213
213
  fontSize: "100%",
214
214
  lineHeight: "1.15em"
215
215
  }
216
- }, G = (...e) => e.flat().reduce((t, s) => s != null && s._current ? { ...t, ...s._current } : { ...t, ...s }, {}), Xt = (...e) => e.flat().reduce((t, s) => ({ ...t, ...s._children }), {});
217
- class Yt {
216
+ }, K = (...e) => e.flat().reduce((t, s) => s != null && s._current ? { ...t, ...s._current } : { ...t, ...s }, {}), se = (...e) => e.flat().reduce((t, s) => ({ ...t, ...s._children }), {});
217
+ class ne {
218
218
  constructor(t) {
219
- et(this, "_path");
219
+ ot(this, "_path");
220
220
  this.params = t;
221
221
  }
222
222
  get _current() {
@@ -229,13 +229,13 @@ class Yt {
229
229
  return this._path = t, this;
230
230
  }
231
231
  }
232
- class te {
232
+ class oe {
233
233
  constructor(t) {
234
- et(this, "_path");
235
- et(this, "templates", []);
234
+ ot(this, "_path");
235
+ ot(this, "templates", []);
236
236
  this.params = t, Object.entries(t).forEach(([s, n]) => {
237
237
  this.templates.push(
238
- new Yt({
238
+ new ne({
239
239
  name: s,
240
240
  template: n
241
241
  })
@@ -257,23 +257,23 @@ class te {
257
257
  return this._path = t, this.templates.forEach((s) => s._setPath(t)), this;
258
258
  }
259
259
  }
260
- const ee = (e) => new te(e), se = (e, t) => new Promise((s, n) => {
260
+ const re = (e) => new oe(e), ae = (e, t) => new Promise((s, n) => {
261
261
  const o = setTimeout(() => {
262
262
  n(new Error("Timeout"));
263
- }, 100), r = ct.createSourceFile("temp.ts", e, ct.ScriptTarget.Latest, !0);
264
- function i(m) {
265
- if (ct.isVariableDeclaration(m) && m.name.getText() === t) {
263
+ }, 100), r = pt.createSourceFile("temp.ts", e, pt.ScriptTarget.Latest, !0);
264
+ function a(m) {
265
+ if (pt.isVariableDeclaration(m) && m.name.getText() === t) {
266
266
  const y = m.getStart(), h = m.getEnd();
267
267
  clearTimeout(o), s([y, h]);
268
268
  }
269
- m.forEachChild(i);
269
+ m.forEachChild(a);
270
270
  }
271
- i(r);
271
+ a(r);
272
272
  }), J = {
273
273
  externalModules: [],
274
274
  rcFile: void 0,
275
275
  destDir: void 0
276
- }, xt = (e) => {
276
+ }, Et = (e) => {
277
277
  if (J.externalModules.length > 0) return J.externalModules;
278
278
  const s = M(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
279
279
  if (!s) return [];
@@ -281,33 +281,33 @@ const ee = (e) => new te(e), se = (e, t) => new Promise((s, n) => {
281
281
  return J.externalModules = n, n;
282
282
  }, Z = async (e) => {
283
283
  if (J.destDir) return J.destDir;
284
- const t = await pt(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
284
+ const t = await yt(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
285
285
  return J.destDir = s, s;
286
- }, Tt = ["salty", "css", "styles", "styled"], ne = (e = []) => new RegExp(`\\.(${[...Tt, ...e].join("|")})\\.`), K = (e, t = []) => ne(t).test(e), Dt = async (e) => {
286
+ }, Ot = ["salty", "css", "styles", "styled"], ie = (e = []) => new RegExp(`\\.(${[...Ot, ...e].join("|")})\\.`), L = (e, t = []) => ie(t).test(e), Vt = async (e) => {
287
287
  if (J.rcFile) return J.rcFile;
288
288
  if (e === "/") throw new Error("Could not find .saltyrc.json file");
289
- const t = u(e, ".saltyrc.json"), s = await ut(t, "utf-8").then(JSON.parse).catch(() => {
289
+ const t = u(e, ".saltyrc.json"), s = await ht(t, "utf-8").then(JSON.parse).catch(() => {
290
290
  });
291
- return s ? (J.rcFile = s, s) : Dt(u(e, ".."));
292
- }, pt = async (e) => {
291
+ return s ? (J.rcFile = s, s) : Vt(u(e, ".."));
292
+ }, yt = async (e) => {
293
293
  var n, o;
294
- const t = await Dt(e), s = (n = t.projects) == null ? void 0 : n.find((r) => e.endsWith(r.dir || ""));
294
+ const t = await Vt(e), s = (n = t.projects) == null ? void 0 : n.find((r) => e.endsWith(r.dir || ""));
295
295
  return s || ((o = t.projects) == null ? void 0 : o.find((r) => r.dir === t.defaultProject));
296
- }, oe = async (e) => {
297
- const t = await pt(e), s = await Z(e), n = u(e, (t == null ? void 0 : t.configDir) || "", "salty.config.ts"), o = u(s, "salty.config.js"), r = await Nt(e), i = xt(n);
298
- await Ct.build({
296
+ }, ce = async (e) => {
297
+ const t = await yt(e), s = await Z(e), n = u(e, (t == null ? void 0 : t.configDir) || "", "salty.config.ts"), o = u(s, "salty.config.js"), r = await Dt(e), a = Et(n);
298
+ await Pt.build({
299
299
  entryPoints: [n],
300
300
  minify: !0,
301
301
  treeShaking: !0,
302
302
  bundle: !0,
303
303
  outfile: o,
304
304
  format: r,
305
- external: i
305
+ external: a
306
306
  });
307
307
  const m = Date.now(), { config: y } = await import(`${o}?t=${m}`);
308
308
  return { config: y, path: o };
309
- }, re = async (e, t) => {
310
- var ht, yt;
309
+ }, le = async (e, t) => {
310
+ var $t, bt;
311
311
  const s = await Z(e), n = {
312
312
  mediaQueries: [],
313
313
  globalStyles: [],
@@ -316,65 +316,85 @@ const ee = (e) => new te(e), se = (e, t) => new Promise((s, n) => {
316
316
  };
317
317
  await Promise.all(
318
318
  [...t].map(async (S) => {
319
- const { contents: F, outputFilePath: A } = await ot(e, S, s);
320
- Object.entries(F).forEach(([E, V]) => {
321
- V.isMedia ? n.mediaQueries.push([E, V]) : V.isGlobalDefine ? n.globalStyles.push(V) : V.isDefineVariables ? n.variables.push(V) : V.isDefineTemplates && n.templates.push(V._setPath(`${E};;${A}`));
319
+ const { contents: N, outputFilePath: q } = await it(e, S, s);
320
+ Object.entries(N).forEach(([v, T]) => {
321
+ T.isMedia ? n.mediaQueries.push([v, T]) : T.isGlobalDefine ? n.globalStyles.push(T) : T.isDefineVariables ? n.variables.push(T) : T.isDefineTemplates && n.templates.push(T._setPath(`${v};;${q}`));
322
322
  });
323
323
  })
324
324
  );
325
- const { config: o, path: r } = await oe(e), i = { ...o }, m = /* @__PURE__ */ new Set(), y = (S, F = []) => S ? Object.entries(S).flatMap(([A, E]) => {
326
- if (!E) return;
327
- if (typeof E == "object") return y(E, [...F, A]);
328
- const V = _t(A), rt = R(A), it = [...F, V].join(".");
329
- m.add(`"${it}"`);
330
- const tt = [...F.map(R), rt].join("-"), gt = Ht(E);
331
- return gt ? `--${tt}: ${gt.transformed};` : `--${tt}: ${E};`;
332
- }) : [], h = (S) => S ? Object.entries(S).flatMap(([F, A]) => {
333
- const E = y(A);
334
- return F === "base" ? E.join("") : `${F} { ${E.join("")} }`;
335
- }) : [], l = (S) => S ? Object.entries(S).flatMap(([F, A]) => Object.entries(A).flatMap(([E, V]) => {
336
- const rt = y(V, [F]), it = `.${F}-${E}, [data-${F}="${E}"]`, tt = rt.join("");
337
- return `${it} { ${tt} }`;
338
- })) : [], g = (S) => ({ ...S, responsive: void 0, conditional: void 0 }), d = (S) => n.variables.map((F) => S === "static" ? g(F._current) : F._current[S]), b = G(g(o.variables), d("static")), p = y(b), f = G((ht = o.variables) == null ? void 0 : ht.responsive, d("responsive")), w = h(f), P = G((yt = o.variables) == null ? void 0 : yt.conditional, d("conditional")), _ = l(P), O = u(s, "css/_variables.css"), v = `:root { ${p.join("")} ${w.join("")} } ${_.join("")}`;
339
- x(O, v), i.staticVariables = b;
340
- const T = u(s, "css/_global.css"), D = G(o.global, n.globalStyles), a = await U(D, "");
341
- x(T, `@layer global { ${a} }`);
342
- const $ = u(s, "css/_reset.css"), c = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : qt, C = await U(c, "");
343
- x($, `@layer reset { ${C} }`);
344
- const N = u(s, "css/_templates.css"), k = G(o.templates, n.templates), z = await jt(k), L = Qt(k);
345
- x(N, `@layer templates { ${z} }`), i.templates = k;
346
- const Q = o.templates ? [ee(o.templates)._setPath(`config;;${r}`)] : [], q = Xt(n.templates, Q);
347
- i.templatePaths = Object.fromEntries(Object.entries(q).map(([S, F]) => [S, F._path]));
348
- const { mediaQueries: X } = n;
349
- i.mediaQueries = Object.fromEntries(X.map(([S, F]) => [`@${S}`, F]));
350
- const B = X.map(([S]) => `'@${S}'`).join(" | "), Y = u(s, "types/css-tokens.d.ts"), kt = `
325
+ const { config: o, path: r } = await ce(e), a = { ...o }, m = /* @__PURE__ */ new Set(), y = async (S, N = []) => {
326
+ if (!S) return [];
327
+ const q = Object.entries(S).map(async ([T, H]) => {
328
+ const st = async (V) => {
329
+ if (!V) return;
330
+ if (V instanceof Promise) return await st(await V);
331
+ if (typeof V == "function") return await st(await V());
332
+ if (typeof V == "object") return await y(V, [...N, T]);
333
+ const ct = kt(T), lt = A(T), ft = [...N, ct].join(".");
334
+ m.add(`"${ft}"`);
335
+ const nt = [...N.map(A), lt].join("-"), Ct = Lt(V);
336
+ return Ct ? `--${nt}: ${Ct.transformed};` : `--${nt}: ${V};`;
337
+ };
338
+ return await st(H);
339
+ });
340
+ return (await Promise.all(q)).flat();
341
+ }, h = async (S) => {
342
+ if (!S) return [];
343
+ const N = Object.entries(S).map(async ([v, T]) => {
344
+ const H = await y(T);
345
+ return v === "base" ? H.join("") : `${v} { ${H.join("")} }`;
346
+ });
347
+ return (await Promise.all(N)).flat();
348
+ }, l = async (S) => {
349
+ if (!S) return [];
350
+ const N = Object.entries(S).map(async ([v, T]) => {
351
+ const H = Object.entries(T).map(async ([V, ct]) => {
352
+ const lt = await y(ct, [v]), ft = `.${v}-${V}, [data-${v}="${V}"]`, nt = lt.join("");
353
+ return `${ft} { ${nt} }`;
354
+ });
355
+ return (await Promise.all(H)).flat();
356
+ });
357
+ return (await Promise.all(N)).flat();
358
+ }, g = (S) => ({ ...S, responsive: void 0, conditional: void 0 }), d = (S) => n.variables.map((N) => S === "static" ? g(N._current) : N._current[S]), b = K(g(o.variables), d("static")), p = await y(b), f = K(($t = o.variables) == null ? void 0 : $t.responsive, d("responsive")), $ = await h(f), F = K((bt = o.variables) == null ? void 0 : bt.conditional, d("conditional")), _ = await l(F), O = u(s, "css/_variables.css"), R = `:root { ${p.join("")} ${$.join("")} } ${_.join("")}`;
359
+ x(O, R), a.staticVariables = b;
360
+ const D = u(s, "css/_global.css"), k = K(o.global, n.globalStyles), i = await X(k, "");
361
+ x(D, `@layer global { ${i} }`);
362
+ const w = u(s, "css/_reset.css"), c = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : ee, C = await X(c, "");
363
+ x(w, `@layer reset { ${C} }`);
364
+ const P = u(s, "css/_templates.css"), E = K(o.templates, n.templates), z = await _t(E), Q = Xt(E);
365
+ x(P, `@layer templates { ${z} }`), a.templates = E;
366
+ const B = o.templates ? [re(o.templates)._setPath(`config;;${r}`)] : [], Y = se(n.templates, B);
367
+ a.templatePaths = Object.fromEntries(Object.entries(Y).map(([S, N]) => [S, N._path]));
368
+ const { mediaQueries: tt } = n;
369
+ a.mediaQueries = Object.fromEntries(tt.map(([S, N]) => [`@${S}`, N]));
370
+ const U = tt.map(([S]) => `'@${S}'`).join(" | "), et = u(s, "types/css-tokens.d.ts"), Mt = `
351
371
  // Variable types
352
372
  type VariableTokens = ${[...m].join("|")};
353
373
  type PropertyValueToken = \`{\${VariableTokens}}\`;
354
374
 
355
375
  // Template types
356
376
  type TemplateTokens = {
357
- ${Object.entries(L).map(([S, F]) => `${S}?: ${F}`).join(`
377
+ ${Object.entries(Q).map(([S, N]) => `${S}?: ${N}`).join(`
358
378
  `)}
359
379
  }
360
380
 
361
381
  // Media query types
362
- type MediaQueryKeys = ${B || "''"};
382
+ type MediaQueryKeys = ${U || "''"};
363
383
  `;
364
- x(Y, kt);
365
- const Et = u(s, "cache/config-cache.json");
366
- x(Et, JSON.stringify(i, null, 2));
367
- }, wt = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
384
+ x(et, Mt);
385
+ const Rt = u(s, "cache/config-cache.json");
386
+ x(Rt, JSON.stringify(a, null, 2));
387
+ }, jt = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
368
388
  if (/^['"`]/.test(s)) return t;
369
389
  const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
370
390
  if (!o.test(e)) return t;
371
- const i = o.exec(e);
372
- if (i) {
373
- const m = i.at(1);
374
- if (Tt.some((h) => m == null ? void 0 : m.includes(h))) return t;
391
+ const a = o.exec(e);
392
+ if (a) {
393
+ const m = a.at(1);
394
+ if (Ot.some((h) => m == null ? void 0 : m.includes(h))) return t;
375
395
  }
376
396
  return "styled('div',";
377
- }), ie = (e, t) => {
397
+ }), fe = (e, t) => {
378
398
  try {
379
399
  const s = M(u(t, "saltygen/cache/config-cache.json"), "utf8");
380
400
  return s ? `globalThis.saltyConfig = ${s};
@@ -385,16 +405,16 @@ ${e}`;
385
405
  } catch {
386
406
  return e;
387
407
  }
388
- }, ot = async (e, t, s) => {
408
+ }, it = async (e, t, s) => {
389
409
  const n = W(t), o = u(s, "./temp");
390
- ft(o) || I(o);
391
- const r = nt(t);
392
- let i = M(t, "utf8");
393
- i = wt(i), i = ie(i, e);
394
- const m = u(s, "js", n + ".js"), y = await pt(e), h = u(e, (y == null ? void 0 : y.configDir) || "", "salty.config.ts"), l = xt(h), g = await Nt(e);
395
- await Ct.build({
410
+ mt(o) || G(o);
411
+ const r = at(t);
412
+ let a = M(t, "utf8");
413
+ a = jt(a), a = fe(a, e);
414
+ const m = u(s, "js", n + ".js"), y = await yt(e), h = u(e, (y == null ? void 0 : y.configDir) || "", "salty.config.ts"), l = Et(h), g = await Dt(e);
415
+ await Pt.build({
396
416
  stdin: {
397
- contents: i,
417
+ contents: a,
398
418
  sourcefile: r.base,
399
419
  resolveDir: r.dir,
400
420
  loader: "tsx"
@@ -413,8 +433,8 @@ ${e}`;
413
433
  name: "test",
414
434
  setup: (p) => {
415
435
  p.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (f) => {
416
- const w = M(f.path, "utf8");
417
- return { contents: wt(w), loader: "ts" };
436
+ const $ = M(f.path, "utf8");
437
+ return { contents: jt($), loader: "ts" };
418
438
  });
419
439
  }
420
440
  }
@@ -422,75 +442,75 @@ ${e}`;
422
442
  });
423
443
  const d = Date.now();
424
444
  return { contents: await import(`${m}?t=${d}`), outputFilePath: m };
425
- }, ae = async (e) => {
445
+ }, ue = async (e) => {
426
446
  const t = await Z(e), s = u(t, "cache/config-cache.json"), n = M(s, "utf8");
427
447
  if (!n) throw new Error("Could not find config cache file");
428
448
  return JSON.parse(n);
429
- }, dt = async (e) => {
430
- const t = await ae(e), s = await Z(e), n = u(s, "salty.config.js"), o = Date.now(), { config: r } = await import(`${n}?t=${o}`);
431
- return G(r, t);
432
- }, mt = () => {
449
+ }, gt = async (e) => {
450
+ const t = await ue(e), s = await Z(e), n = u(s, "salty.config.js"), o = Date.now(), { config: r } = await import(`${n}?t=${o}`);
451
+ return K(r, t);
452
+ }, wt = () => {
433
453
  try {
434
454
  return process.env.NODE_ENV === "production";
435
455
  } catch {
436
456
  return !1;
437
457
  }
438
- }, ce = async (e, t = mt(), s = !0) => {
458
+ }, pe = async (e, t = wt(), s = !0) => {
439
459
  try {
440
460
  const n = Date.now();
441
- t ? lt.info("Generating CSS in production mode! 🔥") : lt.info("Generating CSS in development mode! 🚀");
442
- const o = [], r = [], i = await Z(e), m = u(i, "index.css");
461
+ t ? dt.info("Generating CSS in production mode! 🔥") : dt.info("Generating CSS in development mode! 🚀");
462
+ const o = [], r = [], a = await Z(e), m = u(a, "index.css");
443
463
  s && (() => {
444
- ft(i) && Mt("rm -rf " + i), I(i, { recursive: !0 }), I(u(i, "css")), I(u(i, "types")), I(u(i, "js")), I(u(i, "cache"));
464
+ mt(a) && Jt("rm -rf " + a), G(a, { recursive: !0 }), G(u(a, "css")), G(u(a, "types")), G(u(a, "js")), G(u(a, "cache"));
445
465
  })();
446
466
  const h = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
447
- async function g(a) {
448
- const $ = ["node_modules", "saltygen"], j = vt(a);
467
+ async function g(i) {
468
+ const w = ["node_modules", "saltygen"], j = zt(i);
449
469
  if (j.isDirectory()) {
450
- const c = Rt(a);
451
- if ($.some((N) => a.includes(N))) return;
452
- await Promise.all(c.map((N) => g(u(a, N))));
453
- } else if (j.isFile() && K(a)) {
454
- h.add(a);
455
- const C = M(a, "utf8");
456
- /define[\w\d]+\(/.test(C) && l.add(a);
470
+ const c = Wt(i);
471
+ if (w.some((P) => i.includes(P))) return;
472
+ await Promise.all(c.map((P) => g(u(i, P))));
473
+ } else if (j.isFile() && L(i)) {
474
+ h.add(i);
475
+ const C = M(i, "utf8");
476
+ /define[\w\d]+\(/.test(C) && l.add(i);
457
477
  }
458
478
  }
459
- await g(e), await re(e, l);
479
+ await g(e), await le(e, l);
460
480
  const d = {
461
481
  keyframes: [],
462
482
  components: [],
463
483
  classNames: []
464
484
  };
465
485
  await Promise.all(
466
- [...h].map(async (a) => {
467
- const { contents: $ } = await ot(e, a, i);
468
- for (let [j, c] of Object.entries($))
486
+ [...h].map(async (i) => {
487
+ const { contents: w } = await it(e, i, a);
488
+ for (let [j, c] of Object.entries(w))
469
489
  c instanceof Promise && (c = await c), c.isKeyframes ? d.keyframes.push({
470
490
  value: c,
471
- src: a,
491
+ src: i,
472
492
  name: j
473
493
  }) : c.isClassName ? d.classNames.push({
474
494
  ...c,
475
- src: a,
495
+ src: i,
476
496
  name: j
477
497
  }) : c.generator && d.components.push({
478
498
  ...c,
479
- src: a,
499
+ src: i,
480
500
  name: j
481
501
  });
482
502
  })
483
503
  );
484
- const b = await dt(e);
485
- for (const a of d.keyframes) {
486
- const { value: $ } = a, j = `a_${$.animationName}.css`, c = `css/${j}`, C = u(i, c);
487
- o.push(j), x(C, $.css);
504
+ const b = await gt(e);
505
+ for (const i of d.keyframes) {
506
+ const { value: w } = i, j = `a_${w.animationName}.css`, c = `css/${j}`, C = u(a, c);
507
+ o.push(j), x(C, w.css);
488
508
  }
489
509
  const p = {};
490
- for (const a of d.components) {
491
- const { src: $, name: j } = a;
492
- p[$] || (p[$] = []);
493
- const c = a.generator._withBuildContext({
510
+ for (const i of d.components) {
511
+ const { src: w, name: j } = i;
512
+ p[w] || (p[w] = []);
513
+ const c = i.generator._withBuildContext({
494
514
  callerName: j,
495
515
  isProduction: t,
496
516
  config: b
@@ -499,102 +519,102 @@ ${e}`;
499
519
  const C = await c.css;
500
520
  if (!C) continue;
501
521
  r[c.priority].push(c.cssFileName);
502
- const N = `css/${c.cssFileName}`, k = u(i, N);
503
- x(k, C), b.importStrategy === "component" && p[$].push(c.cssFileName);
522
+ const P = `css/${c.cssFileName}`, E = u(a, P);
523
+ x(E, C), b.importStrategy === "component" && p[w].push(c.cssFileName);
504
524
  }
505
- for (const a of d.classNames) {
506
- const { src: $, name: j } = a;
507
- p[$] || (p[$] = []);
508
- const c = a.generator._withBuildContext({
525
+ for (const i of d.classNames) {
526
+ const { src: w, name: j } = i;
527
+ p[w] || (p[w] = []);
528
+ const c = i.generator._withBuildContext({
509
529
  callerName: j,
510
530
  isProduction: t,
511
531
  config: b
512
532
  }), C = await c.css;
513
533
  if (!C) continue;
514
534
  r[c.priority] || (r[c.priority] = []), r[c.priority].push(c.cssFileName);
515
- const N = `css/${c.cssFileName}`, k = u(i, N);
516
- x(k, C), b.importStrategy === "component" && p[$].push(c.cssFileName);
535
+ const P = `css/${c.cssFileName}`, E = u(a, P);
536
+ x(E, C), b.importStrategy === "component" && p[w].push(c.cssFileName);
517
537
  }
518
- b.importStrategy === "component" && Object.entries(p).forEach(([a, $]) => {
519
- const j = $.map((z) => `@import url('./${z}');`).join(`
520
- `), c = W(a, 6), C = nt(a), N = R(C.name), k = u(i, `css/f_${N}-${c}.css`);
521
- x(k, j || "/* Empty file */");
538
+ b.importStrategy === "component" && Object.entries(p).forEach(([i, w]) => {
539
+ const j = w.map((z) => `@import url('./${z}');`).join(`
540
+ `), c = W(i, 6), C = at(i), P = A(C.name), E = u(a, `css/f_${P}-${c}.css`);
541
+ x(E, j || "/* Empty file */");
522
542
  });
523
- const f = o.map((a) => `@import url('./css/${a}');`).join(`
543
+ const f = o.map((i) => `@import url('./css/${i}');`).join(`
524
544
  `);
525
545
  let O = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
526
546
 
527
- ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((a) => {
547
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((i) => {
528
548
  try {
529
- return M(u(i, "css", a), "utf8").length > 0;
549
+ return M(u(a, "css", i), "utf8").length > 0;
530
550
  } catch {
531
551
  return !1;
532
552
  }
533
- }).map((a) => `@import url('./css/${a}');`).join(`
553
+ }).map((i) => `@import url('./css/${i}');`).join(`
534
554
  `)}
535
555
  ${f}`;
536
556
  if (b.importStrategy !== "component") {
537
- const a = r.reduce(($, j, c) => {
538
- const C = j.reduce((L, Q) => {
539
- var Y;
540
- const q = u(i, "css", Q), X = M(q, "utf8"), B = ((Y = /.*-([^-]+)-\d+.css/.exec(Q)) == null ? void 0 : Y.at(1)) || W(q, 6);
541
- return L.includes(B) ? L : `${L}
542
- /*start:${B}-${Q}*/
543
- ${X}
544
- /*end:${B}*/
557
+ const i = r.reduce((w, j, c) => {
558
+ const C = j.reduce((Q, B) => {
559
+ var et;
560
+ const Y = u(a, "css", B), tt = M(Y, "utf8"), U = ((et = /.*-([^-]+)-\d+.css/.exec(B)) == null ? void 0 : et.at(1)) || W(Y, 6);
561
+ return Q.includes(U) ? Q : `${Q}
562
+ /*start:${U}-${B}*/
563
+ ${tt}
564
+ /*end:${U}*/
545
565
  `;
546
- }, ""), N = `l_${c}.css`, k = u(i, "css", N), z = `@layer l${c} { ${C}
566
+ }, ""), P = `l_${c}.css`, E = u(a, "css", P), z = `@layer l${c} { ${C}
547
567
  }`;
548
- return x(k, z), `${$}
549
- @import url('./css/${N}');`;
568
+ return x(E, z), `${w}
569
+ @import url('./css/${P}');`;
550
570
  }, "");
551
- O += a;
571
+ O += i;
552
572
  }
553
573
  x(m, O);
554
- const T = Date.now() - n, D = T < 200 ? "🔥" : T < 500 ? "🚀" : T < 1e3 ? "🎉" : T < 2e3 ? "🚗" : T < 5e3 ? "🤔" : "🥴";
555
- lt.info(`Generated CSS in ${T}ms! ${D}`);
574
+ const D = Date.now() - n, k = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
575
+ dt.info(`Generated CSS in ${D}ms! ${k}`);
556
576
  } catch (n) {
557
577
  console.error(n);
558
578
  }
559
- }, le = async (e, t, s = mt()) => {
579
+ }, de = async (e, t, s = wt()) => {
560
580
  try {
561
581
  const n = await Z(e);
562
- if (K(t)) {
563
- const r = [], i = await dt(e), { contents: m } = await ot(e, t, n);
582
+ if (L(t)) {
583
+ const r = [], a = await gt(e), { contents: m } = await it(e, t, n);
564
584
  for (const [y, h] of Object.entries(m)) {
565
585
  if (h.isKeyframes && h.css) {
566
- const f = `css/${`a_${h.animationName}.css`}`, w = u(n, f);
567
- x(w, await h.css);
586
+ const f = `css/${`a_${h.animationName}.css`}`, $ = u(n, f);
587
+ x($, await h.css);
568
588
  return;
569
589
  }
570
590
  if (h.isClassName) {
571
591
  const p = h.generator._withBuildContext({
572
592
  callerName: y,
573
593
  isProduction: s,
574
- config: i
594
+ config: a
575
595
  }), f = await p.css;
576
596
  if (!f) continue;
577
597
  r[p.priority] || (r[p.priority] = []), r[p.priority].push(p.cssFileName);
578
- const w = `css/${p.cssFileName}`, P = u(n, w);
579
- x(P, f);
598
+ const $ = `css/${p.cssFileName}`, F = u(n, $);
599
+ x(F, f);
580
600
  }
581
601
  if (!h.generator) return;
582
602
  const l = h.generator._withBuildContext({
583
603
  callerName: y,
584
604
  isProduction: s,
585
- config: i
605
+ config: a
586
606
  }), g = await l.css;
587
607
  if (!g) continue;
588
608
  const d = `css/${l.cssFileName}`, b = u(n, d);
589
609
  x(b, g), r[l.priority] || (r[l.priority] = []), r[l.priority].push(l.cssFileName);
590
610
  }
591
- if (i.importStrategy !== "component")
611
+ if (a.importStrategy !== "component")
592
612
  r.forEach((y, h) => {
593
613
  const l = `l_${h}.css`, g = u(n, "css", l);
594
614
  let d = M(g, "utf8");
595
615
  y.forEach((b) => {
596
- var P;
597
- const p = u(n, "css", b), f = ((P = /.*-([^-]+)-\d+.css/.exec(b)) == null ? void 0 : P.at(1)) || W(p, 6);
616
+ var F;
617
+ const p = u(n, "css", b), f = ((F = /.*-([^-]+)-\d+.css/.exec(b)) == null ? void 0 : F.at(1)) || W(p, 6);
598
618
  if (!d.includes(f)) {
599
619
  const _ = M(p, "utf8"), O = `/*start:${f}-${b}*/
600
620
  ${_}
@@ -608,19 +628,19 @@ ${O}
608
628
  });
609
629
  else {
610
630
  const y = r.flat().map((b) => `@import url('./${b}');`).join(`
611
- `), h = W(t, 6), l = nt(t), g = R(l.name), d = u(n, `css/f_${g}-${h}.css`);
631
+ `), h = W(t, 6), l = at(t), g = A(l.name), d = u(n, `css/f_${g}-${h}.css`);
612
632
  x(d, y || "/* Empty file */");
613
633
  }
614
634
  }
615
635
  } catch (n) {
616
636
  console.error(n);
617
637
  }
618
- }, fe = async (e, t, s = mt()) => {
638
+ }, me = async (e, t, s = wt()) => {
619
639
  var n, o;
620
640
  try {
621
641
  const r = await Z(e);
622
- if (K(t)) {
623
- const m = M(t, "utf8"), y = await dt(e), { contents: h } = await ot(e, t, r);
642
+ if (L(t)) {
643
+ const m = M(t, "utf8"), y = await gt(e), { contents: h } = await it(e, t, r);
624
644
  let l = m;
625
645
  for (const [g, d] of Object.entries(h)) {
626
646
  if (d.isKeyframes || !d.generator) continue;
@@ -628,19 +648,19 @@ ${O}
628
648
  callerName: g,
629
649
  isProduction: s,
630
650
  config: y
631
- }), [p, f] = await se(l, g), w = l.slice(p, f);
651
+ }), [p, f] = await ae(l, g), $ = l.slice(p, f);
632
652
  if (d.isClassName) {
633
- const P = l, _ = ` ${g} = className("${b.classNames}")`;
634
- l = l.replace(w, _), P === l && console.error("Minimize file failed to change content", { name: g });
653
+ const F = l, _ = ` ${g} = className("${b.classNames}")`;
654
+ l = l.replace($, _), F === l && console.error("Minimize file failed to change content", { name: g });
635
655
  }
636
- if (w.includes("styled")) {
637
- const P = (o = (n = /styled\(([^,]+),/.exec(w)) == null ? void 0 : n.at(1)) == null ? void 0 : o.trim(), _ = l, O = ` ${g} = styled(${P}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;
638
- l = l.replace(w, O), _ === l && console.error("Minimize file failed to change content", { name: g, tagName: P });
656
+ if ($.includes("styled")) {
657
+ const F = (o = (n = /styled\(([^,]+),/.exec($)) == null ? void 0 : n.at(1)) == null ? void 0 : o.trim(), _ = l, O = ` ${g} = styled(${F}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;
658
+ l = l.replace($, O), _ === l && console.error("Minimize file failed to change content", { name: g, tagName: F });
639
659
  }
640
660
  }
641
661
  if (y.importStrategy === "component") {
642
- const g = W(t, 6), d = nt(t);
643
- l = `import '../../saltygen/css/${`f_${R(d.name)}-${g}.css`}';
662
+ const g = W(t, 6), d = at(t);
663
+ l = `import '../../saltygen/css/${`f_${A(d.name)}-${g}.css`}';
644
664
  ${l}`;
645
665
  }
646
666
  return l = l.replace("@salty-css/react/class-name", "@salty-css/react/class-name-client"), l = l.replace("{ styled }", "{ styledClient as styled }"), l = l.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), l;
@@ -648,29 +668,29 @@ ${l}`;
648
668
  } catch (r) {
649
669
  console.error("Error in minimizeFile:", r);
650
670
  }
651
- }, bt = async (e) => {
671
+ }, Ft = async (e) => {
652
672
  if (!e || e.includes("node_modules") || e.includes("saltygen")) return !1;
653
673
  if (e.includes("salty.config")) return !0;
654
- if (!K(e)) return !1;
655
- const n = await ut(e, "utf-8");
674
+ if (!L(e)) return !1;
675
+ const n = await ht(e, "utf-8");
656
676
  return !!/.+define[A-Z]\w+/.test(n);
657
- }, we = (e) => ({
677
+ }, je = (e) => ({
658
678
  name: "stylegen",
659
- buildStart: () => ce(e),
679
+ buildStart: () => pe(e),
660
680
  load: async (t) => {
661
- if (K(t))
662
- return await fe(e, t);
681
+ if (L(t))
682
+ return await me(e, t);
663
683
  },
664
684
  handleHotUpdate: async ({ file: t, server: s }) => {
665
- await bt(t) && s.restart();
685
+ await Ft(t) && s.restart();
666
686
  },
667
687
  watchChange: {
668
688
  handler: async (t) => {
669
- K(t) && (await bt(t) || await le(e, t));
689
+ L(t) && (await Ft(t) || await de(e, t));
670
690
  }
671
691
  }
672
692
  });
673
693
  export {
674
- we as default,
675
- we as saltyPlugin
694
+ je as default,
695
+ je as saltyPlugin
676
696
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.232",
3
+ "version": "0.0.1-alpha.234",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,6 +34,6 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.232"
37
+ "@salty-css/core": "^0.0.1-alpha.234"
38
38
  }
39
39
  }