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

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 +12 -12
  2. package/index.js +150 -150
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var vt=Object.defineProperty;var Mt=(t,e,s)=>e in t?vt(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=(D,J=";")=>`${P}:${D}${J}`,V={scope:e,config:s};if(typeof u=="function")return r([p,u(V)]);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[R,f]of N){if(!f)continue;const S=Object.entries(f);for(const[F,a]of S){if(!a)continue;const C=`${e}.${R}-${F}`;(await nt(a,C,s)).forEach(v=>o.add(v))}}return}if(w==="compoundVariants"){for(const N of u){const{css:R,...f}=N,S=Object.entries(f).reduce((a,[C,_])=>`${a}.${C}-${_}`,e);(await nt(R,S,s)).forEach(a=>o.add(a))}return}if(w.startsWith("@")){const N=w,R=await Y(u,e,s),f=`${N} { ${R} }`;o.add(f);return}const D=p.includes("&")?w.replaceAll("&",e):w.startsWith(":")?`${e}${w}`:`${e} ${w}`;(await nt(u,D,s)).forEach(N=>o.add(N));return}if(typeof u=="number"){const D=Lt(P,u);return T(D)}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 V=await P(T);if(!V)return T;const{transformed:D,additionalCss:J}=V;let N="";if(J)for(const R of J)N+=await Y(R,"");return`${N}${D}`},Promise.resolve(u)))))).filter(p=>p!==void 0).join(`
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
2
  `);if(!g.trim())return Array.from(o);const h=e?`${e} {
3
3
  ${g}
4
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
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},Dt=["salty","css","styles","styled"],oe=(t=[])=>new RegExp(`\\.(${[...Dt,...t].join("|")})\\.`),L=(t,e=[])=>oe(e).test(t),Ot=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):Ot(c.join(t,".."))},mt=async t=>{var n,o;const e=await Ot(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(([O,k])=>{k.isMedia?n.mediaQueries.push([O,k]):k.isGlobalDefine?n.globalStyles.push(k):k.isDefineVariables?n.variables.push(k):k.isDefineTemplates&&n.templates.push(k._setPath(`${O};;${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 E=>{if(!E)return;if(E instanceof Promise)return await B(await E);if(typeof E=="function")return await B(await E());if(typeof E=="object")return await l(E,[...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(E);return $t?`--${et}: ${$t.transformed};`:`--${et}: ${E};`};return await B(A)});return(await Promise.all(Z)).flat()},g=async j=>{if(!j)return[];const x=Object.entries(j).map(async([O,k])=>{const A=await l(k);return O==="base"?A.join(""):r.mediaQueries[O]?`${r.mediaQueries[O]} { ${A.join("")} }`:`${O} { ${A.join("")} }`});return(await Promise.all(x)).flat()},h=async j=>{if(!j)return[];const x=Object.entries(j).map(async([O,k])=>{const A=Object.entries(k).map(async([E,at])=>{const ct=await l(at,[O]),lt=`.${O}-${E}, [data-${O}="${E}"]`,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),V=G((wt=o.variables)==null?void 0:wt.conditional,p("conditional")),D=await h(V),J=c.join(s,"css/_variables.css"),N=`:root { ${w.join("")} ${T.join("")} } ${D.join("")}`;d.writeFileSync(J,N),r.staticVariables=u;const R=c.join(s,"css/_global.css"),f=G(o.global,n.globalStyles),S=await Y(f,"");d.writeFileSync(R,`@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 v=c.join(s,"css/_templates.css"),W=G(o.templates,n.templates),Q=await Pt(W),K=Ut(W);d.writeFileSync(v,`@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"),Vt=`
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=`
7
7
  // Variable types
8
8
  type VariableTokens = ${[...m].join("|")};
9
9
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -16,13 +16,13 @@
16
16
 
17
17
  // Media query types
18
18
  type MediaQueryKeys = ${$||"''"};
19
- `;d.writeFileSync(U,Vt);const Rt=c.join(s,"cache/config-cache.json");d.writeFileSync(Rt,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(Dt.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};
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};
20
20
 
21
21
  ${t}`:`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}`,v=c.join(r,_);d.writeFileSync(v,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}`,v=c.join(r,_);d.writeFileSync(v,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),v=c.join(r,`css/f_${_}-${a}.css`);d.writeFileSync(v,F||"/* Empty file */")});const u=o.map(f=>`@import url('./css/${f}');`).join(`
25
- `);let D=`/*!
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=`/*!
26
26
  * Generated with Salty CSS (https://salty-css.dev)
27
27
  * Do not edit this file directly
28
28
  */
@@ -34,13 +34,13 @@ ${u}`;if(b.importStrategy!=="component"){const f=i.reduce((S,F,a)=>{const C=F.re
34
34
  /*start:${U}-${K}*/
35
35
  ${it}
36
36
  /*end:${U}*/
37
- `},""),_=`l_${a}.css`,v=c.join(r,"css",_),W=`@layer l${a} { ${C}
38
- }`;return d.writeFileSync(v,W),`${S}
39
- @import url('./css/${_}');`},"");D+=f}d.writeFileSync(y,D);const N=Date.now()-n,R=N<200?"🔥":N<500?"🚀":N<1e3?"🎉":N<2e3?"🚗":N<5e3?"🤔":"🥴";dt.info(`Generated CSS in ${N}ms! ${R}`)}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"),V=`/*start:${u}-${b}*/
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
40
  ${T}
41
41
  /*end:${u}*/
42
42
  `;h=`${h.replace(/\}$/,"")}
43
- ${V}
43
+ ${E}
44
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,V=` ${g} = styled(${P}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;l=l.replace(w,V),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))},Et=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=Et;exports.saltyPlugin=Et;
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;
package/index.js CHANGED
@@ -4,10 +4,10 @@ var nt = (e, t, s) => Wt(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  import * as Nt from "esbuild";
5
5
  import { execSync as zt } 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 v, writeFileSync as T } from "fs";
7
+ import { existsSync as ht, mkdirSync as K, statSync as At, readdirSync as Ht, readFileSync as R, writeFileSync as T } from "fs";
8
8
  import { readFile as yt } from "fs/promises";
9
- import { createLogger as Gt, format as dt, transports as It } from "winston";
10
- import pt from "typescript";
9
+ import { createLogger as Gt, transports as It, format as pt } from "winston";
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;
13
13
  for (n = Math.abs(e); n > 52; n = n / 52 | 0) s = jt(n % 52) + s;
@@ -29,9 +29,9 @@ const Lt = (e) => (t) => {
29
29
  const n = [];
30
30
  return Object.values(e).forEach((o) => {
31
31
  const { pattern: r, transform: a } = o;
32
- s = s.replace(r, (m) => {
33
- const { value: w, css: p } = a(m);
34
- return p && n.push(p), w;
32
+ s = s.replace(r, (d) => {
33
+ const { value: w, css: m } = a(d);
34
+ return m && n.push(m), w;
35
35
  });
36
36
  }), { transformed: s, additionalCss: n };
37
37
  }, _t = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) => {
@@ -60,65 +60,65 @@ const Lt = (e) => (t) => {
60
60
  /.*font-size.*/
61
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) => {
62
62
  if (!e) throw new Error("No styles provided to parseStyles function!");
63
- const o = /* @__PURE__ */ new Set(), r = Object.entries(e), a = async ([d, f]) => {
64
- const g = d.trim(), F = Xt(g), x = (k, z = ";") => `${F}:${k}${z}`, V = { scope: t, config: s };
65
- if (typeof f == "function") return a([d, f(V)]);
66
- if (f instanceof Promise) return a([d, await f]);
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]);
67
67
  if (typeof f == "object") {
68
68
  if (!f) return;
69
69
  if (f.isColor) return x(f.toString());
70
70
  if (g === "defaultVariants") return;
71
71
  if (g === "variants") {
72
72
  const P = Object.entries(f);
73
- for (const [M, l] of P) {
73
+ for (const [V, l] of P) {
74
74
  if (!l) continue;
75
75
  const $ = Object.entries(l);
76
76
  for (const [C, i] of $) {
77
77
  if (!i) continue;
78
- const j = `${t}.${M}-${C}`;
79
- (await ot(i, j, s)).forEach((R) => o.add(R));
78
+ const j = `${t}.${V}-${C}`;
79
+ (await ot(i, j, s)).forEach((M) => o.add(M));
80
80
  }
81
81
  }
82
82
  return;
83
83
  }
84
84
  if (g === "compoundVariants") {
85
85
  for (const P of f) {
86
- const { css: M, ...l } = P, $ = Object.entries(l).reduce((i, [j, N]) => `${i}.${j}-${N}`, t);
87
- (await ot(M, $, s)).forEach((i) => o.add(i));
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));
88
88
  }
89
89
  return;
90
90
  }
91
91
  if (g.startsWith("@")) {
92
- const P = g, M = await tt(f, t, s), l = `${P} { ${M} }`;
92
+ const P = g, V = await tt(f, t, s), l = `${P} { ${V} }`;
93
93
  o.add(l);
94
94
  return;
95
95
  }
96
- const k = d.includes("&") ? g.replaceAll("&", t) : g.startsWith(":") ? `${t}${g}` : `${t} ${g}`;
97
- (await ot(f, k, s)).forEach((P) => o.add(P));
96
+ const D = p.includes("&") ? g.replaceAll("&", t) : g.startsWith(":") ? `${t}${g}` : `${t} ${g}`;
97
+ (await ot(f, D, s)).forEach((P) => o.add(P));
98
98
  return;
99
99
  }
100
100
  if (typeof f == "number") {
101
- const k = Ut(F, f);
102
- return x(k);
101
+ const D = Ut(F, f);
102
+ return x(D);
103
103
  }
104
104
  if (typeof f != "string")
105
105
  if ("toString" in f) f = f.toString();
106
106
  else throw new Error(`Invalid value type for property ${F}`);
107
107
  return x(f);
108
- }, m = r.map(a), { modifiers: w } = {}, p = [_t(), Lt(w)], y = (await Promise.all(m).then((d) => Promise.all(
109
- d.map((f) => p.reduce(async (g, 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
110
  const x = await g;
111
111
  if (!x) return x;
112
- const V = await F(x);
113
- if (!V) return x;
114
- const { transformed: k, additionalCss: z } = V;
112
+ const O = await F(x);
113
+ if (!O) return x;
114
+ const { transformed: D, additionalCss: z } = O;
115
115
  let P = "";
116
116
  if (z)
117
- for (const M of z)
118
- P += await tt(M, "");
119
- return `${P}${k}`;
117
+ for (const V of z)
118
+ P += await tt(V, "");
119
+ return `${P}${D}`;
120
120
  }, Promise.resolve(f)))
121
- ))).filter((d) => d !== void 0).join(`
121
+ ))).filter((p) => p !== void 0).join(`
122
122
  `);
123
123
  if (!y.trim()) return Array.from(o);
124
124
  const h = t ? `${t} {
@@ -131,8 +131,8 @@ const Lt = (e) => (t) => {
131
131
  const s = [], n = {};
132
132
  for (const [o, r] of Object.entries(e))
133
133
  if (typeof r != "function") if (r && typeof r == "object") {
134
- const a = o.trim(), m = await xt(r, [...t, a]);
135
- s.push(m);
134
+ const a = o.trim(), d = await xt(r, [...t, a]);
135
+ s.push(d);
136
136
  } else
137
137
  n[o] = r;
138
138
  if (Object.keys(n).length) {
@@ -144,12 +144,12 @@ const Lt = (e) => (t) => {
144
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
145
  const r = t ? `${t}.${n}` : n;
146
146
  return typeof o == "object" ? Tt(o, r, s) : s.add(t);
147
- }), [...s]) : [], Dt = (e) => {
147
+ }), [...s]) : [], vt = (e) => {
148
148
  if (!e || e === "/") throw new Error("Could not find package.json file");
149
149
  const t = u(e, "package.json");
150
- return ht(t) ? t : Dt(u(e, ".."));
150
+ return ht(t) ? t : vt(u(e, ".."));
151
151
  }, te = async (e) => {
152
- const t = Dt(e);
152
+ const t = vt(e);
153
153
  return await yt(t, "utf-8").then(JSON.parse).catch(() => {
154
154
  });
155
155
  }, ee = async (e) => {
@@ -158,17 +158,17 @@ const Lt = (e) => (t) => {
158
158
  return t.type;
159
159
  };
160
160
  let Q;
161
- const kt = async (e) => {
161
+ const Dt = async (e) => {
162
162
  if (Q) return Q;
163
163
  const t = await ee(e);
164
164
  return t === "module" ? Q = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (Q = "cjs"), Q || "esm";
165
- }, mt = Gt({
165
+ }, dt = Gt({
166
166
  level: "debug",
167
- format: dt.combine(dt.colorize(), dt.cli()),
167
+ format: pt.combine(pt.colorize(), pt.cli()),
168
168
  transports: [new It.Console({})]
169
169
  });
170
- function Et(e) {
171
- return e ? typeof e != "string" ? Et(String(e)) : e.replace(/[^\d\w]/g, ".") : "";
170
+ function kt(e) {
171
+ return e ? typeof e != "string" ? kt(String(e)) : e.replace(/[^\d\w]/g, ".") : "";
172
172
  }
173
173
  const se = {
174
174
  /** Set box model to border-box */
@@ -263,22 +263,22 @@ class re {
263
263
  const ae = (e) => new re(e), ie = (e, t) => new Promise((s, n) => {
264
264
  const o = setTimeout(() => {
265
265
  n(new Error("Timeout"));
266
- }, 100), r = pt.createSourceFile("temp.ts", e, pt.ScriptTarget.Latest, !0);
267
- function a(m) {
268
- if (pt.isVariableDeclaration(m) && m.name.getText() === t) {
269
- const w = m.getStart(), p = m.getEnd();
270
- clearTimeout(o), s([w, p]);
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]);
271
271
  }
272
- m.forEachChild(a);
272
+ d.forEachChild(a);
273
273
  }
274
274
  a(r);
275
275
  }), W = {
276
276
  externalModules: [],
277
277
  rcFile: void 0,
278
278
  destDir: void 0
279
- }, Ot = (e) => {
279
+ }, Et = (e) => {
280
280
  if (W.externalModules.length > 0) return W.externalModules;
281
- const s = v(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
281
+ const s = R(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
282
282
  if (!s) return [];
283
283
  const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
284
284
  return W.externalModules = n, n;
@@ -286,18 +286,18 @@ const ae = (e) => new re(e), ie = (e, t) => new Promise((s, n) => {
286
286
  if (W.destDir) return W.destDir;
287
287
  const t = await gt(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
288
288
  return W.destDir = s, s;
289
- }, Vt = ["salty", "css", "styles", "styled"], ce = (e = []) => new RegExp(`\\.(${[...Vt, ...e].join("|")})\\.`), Z = (e, t = []) => ce(t).test(e), Mt = async (e) => {
289
+ }, Ot = ["salty", "css", "styles", "styled"], ce = (e = []) => new RegExp(`\\.(${[...Ot, ...e].join("|")})\\.`), Z = (e, t = []) => ce(t).test(e), Vt = async (e) => {
290
290
  if (W.rcFile) return W.rcFile;
291
291
  if (e === "/") throw new Error("Could not find .saltyrc.json file");
292
292
  const t = u(e, ".saltyrc.json"), s = await yt(t, "utf-8").then(JSON.parse).catch(() => {
293
293
  });
294
- return s ? (W.rcFile = s, s) : Mt(u(e, ".."));
294
+ return s ? (W.rcFile = s, s) : Vt(u(e, ".."));
295
295
  }, gt = async (e) => {
296
296
  var n, o;
297
- const t = await Mt(e), s = (n = t.projects) == null ? void 0 : n.find((r) => e.endsWith(r.dir || ""));
297
+ const t = await Vt(e), s = (n = t.projects) == null ? void 0 : n.find((r) => e.endsWith(r.dir || ""));
298
298
  return s || ((o = t.projects) == null ? void 0 : o.find((r) => r.dir === t.defaultProject));
299
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 kt(e), a = Ot(n);
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);
301
301
  await Nt.build({
302
302
  entryPoints: [n],
303
303
  minify: !0,
@@ -307,7 +307,7 @@ const ae = (e) => new re(e), ie = (e, t) => new Promise((s, n) => {
307
307
  format: r,
308
308
  external: a
309
309
  });
310
- const m = Date.now(), { config: w } = await import(`${o}?t=${m}`);
310
+ const d = Date.now(), { config: w } = await import(`${o}?t=${d}`);
311
311
  return { config: w, path: o };
312
312
  }, fe = async (e, t) => {
313
313
  var bt, St;
@@ -320,59 +320,59 @@ const ae = (e) => new re(e), ie = (e, t) => new Promise((s, n) => {
320
320
  await Promise.all(
321
321
  [...t].map(async (S) => {
322
322
  const { contents: _, outputFilePath: X } = await at(e, S, s);
323
- Object.entries(_).forEach(([E, D]) => {
324
- D.isMedia ? n.mediaQueries.push([E, D]) : D.isGlobalDefine ? n.globalStyles.push(D) : D.isDefineVariables ? n.variables.push(D) : D.isDefineTemplates && n.templates.push(D._setPath(`${E};;${X}`));
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}`));
325
325
  });
326
326
  })
327
327
  );
328
- const { config: o, path: r } = await le(e), a = { ...o }, { mediaQueries: m } = n;
329
- a.mediaQueries = Object.fromEntries(m.map(([S, _]) => [`@${S}`, _]));
330
- const w = m.map(([S]) => `'@${S}'`).join(" | "), p = /* @__PURE__ */ new Set(), c = async (S, _ = []) => {
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, _ = []) => {
331
331
  if (!S) return [];
332
- const X = Object.entries(S).map(async ([D, H]) => {
333
- const Y = async (O) => {
334
- if (!O) return;
335
- if (O instanceof Promise) return await Y(await O);
336
- if (typeof O == "function") return await Y(await O());
337
- if (typeof O == "object") return await c(O, [..._, D]);
338
- const lt = Et(D), ft = J(D), ut = [..._, lt].join(".");
339
- p.add(`"${ut}"`);
340
- const st = [..._.map(J), ft].join("-"), Ct = Zt(O);
341
- return Ct ? `--${st}: ${Ct.transformed};` : `--${st}: ${O};`;
332
+ const X = Object.entries(S).map(async ([v, H]) => {
333
+ const Y = async (E) => {
334
+ if (!E) return;
335
+ if (E instanceof Promise) return await Y(await E);
336
+ 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);
341
+ return Ct ? `--${st}: ${Ct.transformed};` : `--${st}: ${E};`;
342
342
  };
343
343
  return await Y(H);
344
344
  });
345
345
  return (await Promise.all(X)).flat();
346
346
  }, y = async (S) => {
347
347
  if (!S) return [];
348
- const _ = Object.entries(S).map(async ([E, D]) => {
349
- const H = await c(D);
350
- return E === "base" ? H.join("") : a.mediaQueries[E] ? `${a.mediaQueries[E]} { ${H.join("")} }` : `${E} { ${H.join("")} }`;
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("")} }`;
351
351
  });
352
352
  return (await Promise.all(_)).flat();
353
353
  }, h = async (S) => {
354
354
  if (!S) return [];
355
- const _ = Object.entries(S).map(async ([E, D]) => {
356
- const H = Object.entries(D).map(async ([O, lt]) => {
357
- const ft = await c(lt, [E]), ut = `.${E}-${O}, [data-${E}="${O}"]`, st = ft.join("");
355
+ const _ = Object.entries(S).map(async ([k, v]) => {
356
+ const H = Object.entries(v).map(async ([E, lt]) => {
357
+ const ft = await c(lt, [k]), ut = `.${k}-${E}, [data-${k}="${E}"]`, st = ft.join("");
358
358
  return `${ut} { ${st} }`;
359
359
  });
360
360
  return (await Promise.all(H)).flat();
361
361
  });
362
362
  return (await Promise.all(_)).flat();
363
- }, b = (S) => ({ ...S, responsive: void 0, conditional: void 0 }), d = (S) => n.variables.map((_) => S === "static" ? b(_._current) : _._current[S]), f = L(b(o.variables), d("static")), g = await c(f), F = L((bt = o.variables) == null ? void 0 : bt.responsive, d("responsive")), x = await y(F), V = L((St = o.variables) == null ? void 0 : St.conditional, d("conditional")), k = await h(V), z = u(s, "css/_variables.css"), P = `:root { ${g.join("")} ${x.join("")} } ${k.join("")}`;
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
364
  T(z, P), a.staticVariables = f;
365
- const M = u(s, "css/_global.css"), l = L(o.global, n.globalStyles), $ = await tt(l, "");
366
- T(M, `@layer global { ${$} }`);
365
+ const V = u(s, "css/_global.css"), l = L(o.global, n.globalStyles), $ = await tt(l, "");
366
+ T(V, `@layer global { ${$} }`);
367
367
  const C = u(s, "css/_reset.css"), j = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : se, N = await tt(j, "");
368
368
  T(C, `@layer reset { ${N} }`);
369
- const R = u(s, "css/_templates.css"), A = L(o.templates, n.templates), B = await xt(A), U = Yt(A);
370
- T(R, `@layer templates { ${B} }`), a.templates = A;
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
371
  const et = o.templates ? [ae(o.templates)._setPath(`config;;${r}`)] : [], it = ne(n.templates, et);
372
372
  a.templatePaths = Object.fromEntries(Object.entries(it).map(([S, _]) => [S, _._path]));
373
- const q = u(s, "types/css-tokens.d.ts"), Rt = `
373
+ const q = u(s, "types/css-tokens.d.ts"), Mt = `
374
374
  // Variable types
375
- type VariableTokens = ${[...p].join("|")};
375
+ type VariableTokens = ${[...m].join("|")};
376
376
  type PropertyValueToken = \`{\${VariableTokens}}\`;
377
377
 
378
378
  // Template types
@@ -384,22 +384,22 @@ const ae = (e) => new re(e), ie = (e, t) => new Promise((s, n) => {
384
384
  // Media query types
385
385
  type MediaQueryKeys = ${w || "''"};
386
386
  `;
387
- T(q, Rt);
388
- const vt = u(s, "cache/config-cache.json");
389
- T(vt, JSON.stringify(a, null, 2));
387
+ T(q, Mt);
388
+ const Rt = u(s, "cache/config-cache.json");
389
+ T(Rt, JSON.stringify(a, null, 2));
390
390
  }, Ft = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
391
391
  if (/^['"`]/.test(s)) return t;
392
392
  const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
393
393
  if (!o.test(e)) return t;
394
394
  const a = o.exec(e);
395
395
  if (a) {
396
- const m = a.at(1);
397
- if (Vt.some((p) => m == null ? void 0 : m.includes(p))) return t;
396
+ const d = a.at(1);
397
+ if (Ot.some((m) => d == null ? void 0 : d.includes(m))) return t;
398
398
  }
399
399
  return "styled('div',";
400
400
  }), ue = (e, t) => {
401
401
  try {
402
- const s = v(u(t, "saltygen/cache/config-cache.json"), "utf8");
402
+ const s = R(u(t, "saltygen/cache/config-cache.json"), "utf8");
403
403
  return s ? `globalThis.saltyConfig = ${s};
404
404
 
405
405
  ${e}` : `globalThis.saltyConfig = {};
@@ -412,9 +412,9 @@ ${e}`;
412
412
  const n = G(t), o = u(s, "./temp");
413
413
  ht(o) || K(o);
414
414
  const r = rt(t);
415
- let a = v(t, "utf8");
415
+ let a = R(t, "utf8");
416
416
  a = Ft(a), a = ue(a, e);
417
- const m = u(s, "js", n + ".js"), w = await gt(e), p = u(e, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), c = Ot(p), y = await kt(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);
418
418
  await Nt.build({
419
419
  stdin: {
420
420
  contents: a,
@@ -425,7 +425,7 @@ ${e}`;
425
425
  minify: !1,
426
426
  treeShaking: !0,
427
427
  bundle: !0,
428
- outfile: m,
428
+ outfile: d,
429
429
  format: y,
430
430
  target: ["node20"],
431
431
  keepNames: !0,
@@ -434,9 +434,9 @@ ${e}`;
434
434
  plugins: [
435
435
  {
436
436
  name: "test",
437
- setup: (d) => {
438
- d.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (f) => {
439
- const g = v(f.path, "utf8");
437
+ setup: (p) => {
438
+ p.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (f) => {
439
+ const g = R(f.path, "utf8");
440
440
  return { contents: Ft(g), loader: "ts" };
441
441
  });
442
442
  }
@@ -444,13 +444,13 @@ ${e}`;
444
444
  ]
445
445
  });
446
446
  const h = Date.now();
447
- return { contents: await import(`${m}?t=${h}`), outputFilePath: m };
448
- }, de = async (e) => {
449
- const t = await I(e), s = u(t, "cache/config-cache.json"), n = v(s, "utf8");
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");
450
450
  if (!n) throw new Error("Could not find config cache file");
451
451
  return JSON.parse(n);
452
452
  }, wt = async (e) => {
453
- const t = await de(e), s = await I(e), n = u(s, "salty.config.js"), o = Date.now(), { config: r } = await import(`${n}?t=${o}`);
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
454
  return L(r, t);
455
455
  }, $t = () => {
456
456
  try {
@@ -458,15 +458,15 @@ ${e}`;
458
458
  } catch {
459
459
  return !1;
460
460
  }
461
- }, pe = async (e, t = $t(), s = !0) => {
461
+ }, me = async (e, t = $t(), s = !0) => {
462
462
  try {
463
463
  const n = Date.now();
464
- t ? mt.info("Generating CSS in production mode! 🔥") : mt.info("Generating CSS in development mode! 🚀");
465
- const o = [], r = [], a = await I(e), m = u(a, "index.css");
464
+ 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");
466
466
  s && (() => {
467
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"));
468
468
  })();
469
- const p = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
469
+ const m = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
470
470
  async function y(l) {
471
471
  const $ = ["node_modules", "saltygen"], C = At(l);
472
472
  if (C.isDirectory()) {
@@ -474,8 +474,8 @@ ${e}`;
474
474
  if ($.some((N) => l.includes(N))) return;
475
475
  await Promise.all(i.map((N) => y(u(l, N))));
476
476
  } else if (C.isFile() && Z(l)) {
477
- p.add(l);
478
- const j = v(l, "utf8");
477
+ m.add(l);
478
+ const j = R(l, "utf8");
479
479
  /define[\w\d]+\(/.test(j) && c.add(l);
480
480
  }
481
481
  }
@@ -486,7 +486,7 @@ ${e}`;
486
486
  classNames: []
487
487
  };
488
488
  await Promise.all(
489
- [...p].map(async (l) => {
489
+ [...m].map(async (l) => {
490
490
  const { contents: $ } = await at(e, l, a);
491
491
  for (let [C, i] of Object.entries($))
492
492
  i instanceof Promise && (i = await i), i.isKeyframes ? h.keyframes.push({
@@ -509,10 +509,10 @@ ${e}`;
509
509
  const { value: $ } = l, C = `a_${$.animationName}.css`, i = `css/${C}`, j = u(a, i);
510
510
  o.push(C), T(j, $.css);
511
511
  }
512
- const d = {};
512
+ const p = {};
513
513
  for (const l of h.components) {
514
514
  const { src: $, name: C } = l;
515
- d[$] || (d[$] = []);
515
+ p[$] || (p[$] = []);
516
516
  const i = l.generator._withBuildContext({
517
517
  callerName: C,
518
518
  isProduction: t,
@@ -522,12 +522,12 @@ ${e}`;
522
522
  const j = await i.css;
523
523
  if (!j) continue;
524
524
  r[i.priority].push(i.cssFileName);
525
- const N = `css/${i.cssFileName}`, R = u(a, N);
526
- T(R, j), b.importStrategy === "component" && d[$].push(i.cssFileName);
525
+ const N = `css/${i.cssFileName}`, M = u(a, N);
526
+ T(M, j), b.importStrategy === "component" && p[$].push(i.cssFileName);
527
527
  }
528
528
  for (const l of h.classNames) {
529
529
  const { src: $, name: C } = l;
530
- d[$] || (d[$] = []);
530
+ p[$] || (p[$] = []);
531
531
  const i = l.generator._withBuildContext({
532
532
  callerName: C,
533
533
  isProduction: t,
@@ -535,17 +535,17 @@ ${e}`;
535
535
  }), j = await i.css;
536
536
  if (!j) continue;
537
537
  r[i.priority] || (r[i.priority] = []), r[i.priority].push(i.cssFileName);
538
- const N = `css/${i.cssFileName}`, R = u(a, N);
539
- T(R, j), b.importStrategy === "component" && d[$].push(i.cssFileName);
538
+ const N = `css/${i.cssFileName}`, M = u(a, N);
539
+ T(M, j), b.importStrategy === "component" && p[$].push(i.cssFileName);
540
540
  }
541
- b.importStrategy === "component" && Object.entries(d).forEach(([l, $]) => {
541
+ b.importStrategy === "component" && Object.entries(p).forEach(([l, $]) => {
542
542
  const C = $.map((A) => `@import url('./${A}');`).join(`
543
- `), i = G(l, 6), j = rt(l), N = J(j.name), R = u(a, `css/f_${N}-${i}.css`);
544
- T(R, C || "/* Empty file */");
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 */");
545
545
  });
546
546
  const f = o.map((l) => `@import url('./css/${l}');`).join(`
547
547
  `);
548
- let k = `/*!
548
+ let D = `/*!
549
549
  * Generated with Salty CSS (https://salty-css.dev)
550
550
  * Do not edit this file directly
551
551
  */
@@ -553,7 +553,7 @@ ${e}`;
553
553
 
554
554
  ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
555
555
  try {
556
- return v(u(a, "css", l), "utf8").length > 0;
556
+ return R(u(a, "css", l), "utf8").length > 0;
557
557
  } catch {
558
558
  return !1;
559
559
  }
@@ -566,50 +566,50 @@ ${f}`;
566
566
  const l = r.reduce(($, C, i) => {
567
567
  const j = C.reduce((B, U) => {
568
568
  var ct;
569
- const et = u(a, "css", U), it = v(et, "utf8"), q = ((ct = /.*-([^-]+)-\d+.css/.exec(U)) == null ? void 0 : ct.at(1)) || G(et, 6);
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);
570
570
  return B.includes(q) ? B : `${B}
571
571
  /*start:${q}-${U}*/
572
572
  ${it}
573
573
  /*end:${q}*/
574
574
  `;
575
- }, ""), N = `l_${i}.css`, R = u(a, "css", N), A = `@layer l${i} { ${j}
575
+ }, ""), N = `l_${i}.css`, M = u(a, "css", N), A = `@layer l${i} { ${j}
576
576
  }`;
577
- return T(R, A), `${$}
577
+ return T(M, A), `${$}
578
578
  @import url('./css/${N}');`;
579
579
  }, "");
580
- k += l;
580
+ D += l;
581
581
  }
582
- T(m, k);
583
- const P = Date.now() - n, M = P < 200 ? "🔥" : P < 500 ? "🚀" : P < 1e3 ? "🎉" : P < 2e3 ? "🚗" : P < 5e3 ? "🤔" : "🥴";
584
- mt.info(`Generated CSS in ${P}ms! ${M}`);
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}`);
585
585
  } catch (n) {
586
586
  console.error(n);
587
587
  }
588
- }, me = async (e, t, s = $t()) => {
588
+ }, de = async (e, t, s = $t()) => {
589
589
  try {
590
590
  const n = await I(e);
591
591
  if (Z(t)) {
592
- const r = [], a = await wt(e), { contents: m } = await at(e, t, n);
593
- for (const [w, p] of Object.entries(m)) {
594
- if (p.isKeyframes && p.css) {
595
- const f = `css/${`a_${p.animationName}.css`}`, g = u(n, f);
596
- T(g, await p.css);
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);
597
597
  continue;
598
598
  }
599
- if (p.isClassName) {
600
- const d = p.generator._withBuildContext({
599
+ if (m.isClassName) {
600
+ const p = m.generator._withBuildContext({
601
601
  callerName: w,
602
602
  isProduction: s,
603
603
  config: a
604
- }), f = await d.css;
604
+ }), f = await p.css;
605
605
  if (!f) continue;
606
- r[d.priority] || (r[d.priority] = []), r[d.priority].push(d.cssFileName);
607
- const g = `css/${d.cssFileName}`, F = u(n, g);
606
+ r[p.priority] || (r[p.priority] = []), r[p.priority].push(p.cssFileName);
607
+ const g = `css/${p.cssFileName}`, F = u(n, g);
608
608
  T(F, f);
609
609
  continue;
610
610
  }
611
- if (!p.generator) continue;
612
- const c = p.generator._withBuildContext({
611
+ if (!m.generator) continue;
612
+ const c = m.generator._withBuildContext({
613
613
  callerName: w,
614
614
  isProduction: s,
615
615
  config: a
@@ -619,26 +619,26 @@ ${it}
619
619
  T(b, y), r[c.priority] || (r[c.priority] = []), r[c.priority].push(c.cssFileName);
620
620
  }
621
621
  if (a.importStrategy !== "component")
622
- r.forEach((w, p) => {
623
- const c = `l_${p}.css`, y = u(n, "css", c);
624
- let h = v(y, "utf8");
622
+ r.forEach((w, m) => {
623
+ const c = `l_${m}.css`, y = u(n, "css", c);
624
+ let h = R(y, "utf8");
625
625
  w.forEach((b) => {
626
626
  var F;
627
- const d = u(n, "css", b), f = ((F = /.*-([^-]+)-\d+.css/.exec(b)) == null ? void 0 : F.at(1)) || G(d, 6);
627
+ const p = u(n, "css", b), f = ((F = /.*-([^-]+)-\d+.css/.exec(b)) == null ? void 0 : F.at(1)) || G(p, 6);
628
628
  if (!h.includes(f)) {
629
- const x = v(d, "utf8"), V = `/*start:${f}-${b}*/
629
+ const x = R(p, "utf8"), O = `/*start:${f}-${b}*/
630
630
  ${x}
631
631
  /*end:${f}*/
632
632
  `;
633
633
  h = `${h.replace(/\}$/, "")}
634
- ${V}
634
+ ${O}
635
635
  }`;
636
636
  }
637
637
  }), T(y, h);
638
638
  });
639
639
  else {
640
640
  const w = r.flat().map((b) => `@import url('./${b}');`).join(`
641
- `), p = G(t, 6), c = rt(t), y = J(c.name), h = u(n, `css/f_${y}-${p}.css`);
641
+ `), m = G(t, 6), c = rt(t), y = J(c.name), h = u(n, `css/f_${y}-${m}.css`);
642
642
  T(h, w || "/* Empty file */");
643
643
  }
644
644
  }
@@ -650,22 +650,22 @@ ${V}
650
650
  try {
651
651
  const r = await I(e);
652
652
  if (Z(t)) {
653
- const m = v(t, "utf8"), w = await wt(e), { contents: p } = await at(e, t, r);
654
- let c = m;
655
- for (const [y, h] of Object.entries(p)) {
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)) {
656
656
  if (h.isKeyframes || !h.generator) continue;
657
657
  const b = h.generator._withBuildContext({
658
658
  callerName: y,
659
659
  isProduction: s,
660
660
  config: w
661
- }), [d, f] = await ie(c, y), g = c.slice(d, f);
661
+ }), [p, f] = await ie(c, y), g = c.slice(p, f);
662
662
  if (h.isClassName) {
663
663
  const F = c, x = ` ${y} = className("${b.classNames}")`;
664
664
  c = c.replace(g, x), F === c && console.error("Minimize file failed to change content", { name: y });
665
665
  }
666
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, V = ` ${y} = styled(${F}, "${b.classNames}", ${JSON.stringify(b.clientProps)})`;
668
- c = c.replace(g, V), x === c && console.error("Minimize file failed to change content", { name: y, tagName: F });
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 });
669
669
  }
670
670
  }
671
671
  if (w.importStrategy === "component") {
@@ -686,7 +686,7 @@ ${c}`;
686
686
  return !!(/.+define[A-Z]\w+/.test(n) || /.+keyframes\(.+/.test(n));
687
687
  }, je = (e) => ({
688
688
  name: "stylegen",
689
- buildStart: () => pe(e),
689
+ buildStart: () => me(e),
690
690
  load: async (t) => {
691
691
  if (Z(t))
692
692
  return await he(e, t);
@@ -696,7 +696,7 @@ ${c}`;
696
696
  },
697
697
  watchChange: {
698
698
  handler: async (t, s) => {
699
- Z(t) && s.event !== "delete" && (await Pt(t) || await me(e, t));
699
+ Z(t) && s.event !== "delete" && (await Pt(t) || await de(e, t));
700
700
  }
701
701
  }
702
702
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.254",
3
+ "version": "0.0.1-alpha.255",
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.254"
37
+ "@salty-css/core": "^0.0.1-alpha.255"
38
38
  }
39
39
  }