@salty-css/vite 0.0.1-alpha.255 → 0.0.1-alpha.257

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