@salty-css/vite 0.0.1-alpha.194 → 0.0.1-alpha.195

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 +19 -19
  2. package/index.js +205 -205
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1,37 +1,37 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const $e=require("esbuild"),be=require("child_process"),l=require("path"),u=require("fs"),K=require("fs/promises"),q=require("winston");var v=typeof document<"u"?document.currentScript:null;function we(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 ce=we($e),oe=e=>String.fromCharCode(e+(e>25?39:97)),Fe=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=oe(n%52)+s;return s=oe(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Ce=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},z=(e,t=5)=>{const s=Ce(5381,JSON.stringify(e))>>>0;return Fe(s,t)};function M(e){return e?typeof e!="string"?M(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 Ne=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:a}=n;e=e.replace(i,c=>{const{value:p,css:r}=a(c);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ae=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},R=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((c,[p,r])=>{const o=p.trim(),h=o.startsWith("-")?o:M(o),g=(F,N=";")=>c=`${c}${F}${N}`,y=F=>g(`${h}:${F}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return c;if(r.isColor)return y(r.toString()),c;if(o==="variants")return Object.entries(r).forEach(([_,$])=>{$&&Object.entries($).forEach(([O,f])=>{if(!f)return;const m=`${t}.${_}-${O}`,b=R(f,m);n.push(b)})}),c;if(o==="defaultVariants")return c;if(o==="compoundVariants")return r.forEach(_=>{const{css:$,...O}=_,f=Object.entries(O).reduce((b,[d,x])=>`${b}.${d}-${x}`,t),m=R($,f);n.push(m)}),c;if(o.startsWith("@")){const _=R(r,t),$=`${o} {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Fe=require("esbuild"),Ce=require("child_process"),l=require("path"),u=require("fs"),K=require("fs/promises"),B=require("winston");var te=typeof document<"u"?document.currentScript:null;function Ne(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 fe=Ne(Fe),ce=e=>String.fromCharCode(e+(e>25?39:97)),xe=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ce(n%52)+s;return s=ce(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},ke=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},z=(e,t=5)=>{const s=ke(5381,JSON.stringify(e))>>>0;return xe(s,t)};function V(e){return e?typeof e!="string"?V(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const Pe=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:a}=n;e=e.replace(i,c=>{const{value:p,css:r}=a(c);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ue=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:e},M=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((c,[p,r])=>{const o=p.trim(),h=o.startsWith("-")?o:V(o),g=(b,F=";")=>c=`${c}${b}${F}`,y=b=>g(`${h}:${b}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return c;if(r.isColor)return y(r.toString()),c;if(o==="variants")return Object.entries(r).forEach(([_,j])=>{j&&Object.entries(j).forEach(([T,f])=>{if(!f)return;const S=`${t}.${_}-${T}`,w=M(f,S);n.push(w)})}),c;if(o==="defaultVariants")return c;if(o==="compoundVariants")return r.forEach(_=>{const{css:j,...T}=_,f=Object.entries(T).reduce((w,[d,C])=>`${w}.${d}-${C}`,t),S=M(j,f);n.push(S)}),c;if(o.startsWith("@")){const _=M(r,t),j=`${o} {
2
2
  ${_.replace(`
3
3
  `,`
4
4
  `)}
5
- }`;return n.push($),c}const F=p.includes("&")?o.replace("&",t):o.startsWith(":")?`${t}${o}`:`${t} ${o}`,N=R(r,F);return n.push(N),c}if(typeof r=="number")return y(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return c;const{modifiers:j}={},D=function*(){yield ae(r),yield Ne(r,j)}();for(const{result:F,additionalCss:N=[]}of D)r=F,N.forEach(_=>{const $=R(_,"");g($,"")});return y(r)},"");return i?t?[`${t} { ${i} }`,...n].join(`
5
+ }`;return n.push(j),c}const b=p.includes("&")?o.replace("&",t):o.startsWith(":")?`${t}${o}`:`${t} ${o}`,F=M(r,b);return n.push(F),c}if(typeof r=="number")return y(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return c;const{modifiers:N}={},D=function*(){yield ue(r),yield Pe(r,N)}();for(const{result:b,additionalCss:F=[]}of D)r=b,F.forEach(_=>{const j=M(_,"");g(j,"")});return y(r)},"");return i?t?[`${t} { ${i} }`,...n].join(`
6
6
  `):i:n.join(`
7
- `)},le=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,a])=>{if(typeof a=="object"){if(!a)return;const c=i.trim(),p=le(a,[...t,c]);s.push(p)}else n[i]=a}),Object.keys(n).length){const i=t.map(M).join("-"),a=R(n,`.${i}`);s.push(a)}return s.join(`
8
- `)},xe=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=fe(n).map(i=>`"${i}"`).join(" | ")),t),{}):{},fe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const a=t?`${t}.${n}`:n;return typeof i=="object"?fe(i,a,s):s.add(t)}),[...s]):[],ue=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ue(l.join(e,".."))},ke=async e=>{const t=ue(e);return await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Pe=async e=>{const t=await ke(e);if(t)return t.type};let A;const de=async e=>{if(A)return A;const t=await Pe(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:v&&v.tagName.toUpperCase()==="SCRIPT"&&v.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},ee=q.createLogger({level:"debug",format:q.format.combine(q.format.colorize(),q.format.cli()),transports:[new q.transports.Console({})]});function pe(e){return e?typeof e!="string"?pe(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 _e={"*, *::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"}},W=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),E={externalModules:[],rcFile:void 0,destDir:void 0},ye=e=>{if(E.externalModules.length>0)return E.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return E.externalModules=n,n},J=async e=>{if(E.destDir)return E.destDir;const t=await te(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},ge=["salty","css","styles","styled"],De=(e=[])=>new RegExp(`\\.(${[...ge,...e].join("|")})\\.`),Z=(e,t=[])=>De(t).test(e),he=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):he(l.join(e,".."))},te=async e=>{var n,i;const t=await he(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((i=t.projects)==null?void 0:i.find(a=>a.dir===t.defaultProject))},Te=async e=>{const t=await te(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),i=l.join(s,"salty.config.js"),a=await de(e),c=ye(n);await ce.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:a,external:c});const p=Date.now(),{config:r}=await import(`${i}?t=${p}`);return r},Oe=async(e,t)=>{var H,G;const s=await Te(e),n={...s},i=new Set,a=(C,k=[])=>C?Object.entries(C).flatMap(([V,T])=>{if(!T)return;if(typeof T=="object")return a(T,[...k,V]);const U=pe(V),Q=M(V),X=[...k,U].join(".");i.add(`"${X}"`);const Y=[...k.map(M),Q].join("-"),{result:je}=ae(T);return`--${Y}: ${je};`}):[],c=C=>C?Object.entries(C).flatMap(([k,V])=>{const T=a(V);return k==="base"?T.join(""):`${k} { ${T.join("")} }`}):[],p=C=>C?Object.entries(C).flatMap(([k,V])=>Object.entries(V).flatMap(([T,U])=>{const Q=a(U,[k]),X=`.${k}-${T}, [data-${k}="${T}"]`,Y=Q.join("");return`${X} { ${Y} }`})):[],r=C=>({...C,responsive:void 0,conditional:void 0}),o=C=>t.variables.map(k=>C==="static"?r(k._current):k._current[C]),h=a(W(r(s.variables),o("static"))),g=c(W((H=s.variables)==null?void 0:H.responsive,o("responsive"))),y=p(W((G=s.variables)==null?void 0:G.conditional,o("conditional"))),j=await J(e),P=l.join(j,"css/_variables.css"),D=`:root { ${h.join("")} ${g.join("")} } ${y.join("")}`;u.writeFileSync(P,D);const F=l.join(j,"css/_global.css"),N=W(s.global,t.globalStyles),_=R(N,"");u.writeFileSync(F,`@layer global { ${_} }`);const $=l.join(j,"css/_reset.css"),f=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:_e,m=R(f,"");u.writeFileSync($,`@layer reset { ${m} }`);const b=l.join(j,"css/_templates.css"),d=W(s.templates,t.templates),x=le(d),w=xe(d);u.writeFileSync(b,x),n.templates=d;const S=l.join(j,"types/css-tokens.d.ts"),I=`
7
+ `)},de=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,a])=>{if(typeof a=="object"){if(!a)return;const c=i.trim(),p=de(a,[...t,c]);s.push(p)}else n[i]=a}),Object.keys(n).length){const i=t.map(V).join("-"),a=M(n,`.${i}`);s.push(a)}return s.join(`
8
+ `)},_e=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(i=>`"${i}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const a=t?`${t}.${n}`:n;return typeof i=="object"?pe(i,a,s):s.add(t)}),[...s]):[],ye=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ye(l.join(e,".."))},De=async e=>{const t=ye(e);return await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Te=async e=>{const t=await De(e);if(t)return t.type};let A;const ge=async e=>{if(A)return A;const t=await Te(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:te&&te.tagName.toUpperCase()==="SCRIPT"&&te.src||new URL("index.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},se=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]});function he(e){return e?typeof e!="string"?he(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 Oe={"*, *::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"}},W=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),E={externalModules:[],rcFile:void 0,destDir:void 0},me=e=>{if(E.externalModules.length>0)return E.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return E.externalModules=n,n},J=async e=>{if(E.destDir)return E.destDir;const t=await ne(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},Se=["salty","css","styles","styled"],Ee=(e=[])=>new RegExp(`\\.(${[...Se,...e].join("|")})\\.`),Z=(e,t=[])=>Ee(t).test(e),be=async e=>{if(E.rcFile)return E.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await K.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):be(l.join(e,".."))},ne=async e=>{var n,i;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((i=t.projects)==null?void 0:i.find(a=>a.dir===t.defaultProject))},Ve=async e=>{const t=await ne(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),i=l.join(s,"salty.config.js"),a=await ge(e),c=me(n);await fe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:a,external:c});const p=Date.now(),{config:r}=await import(`${i}?t=${p}`);return r},Me=async(e,t)=>{var L,ie;const s=await Ve(e),n={...s},i=new Set,a=(k,P=[])=>k?Object.entries(k).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return a(O,[...P,R]);const X=he(R),Y=V(R),v=[...P,X].join(".");i.add(`"${v}"`);const ee=[...P.map(V),Y].join("-"),{result:we}=ue(O);return`--${ee}: ${we};`}):[],c=k=>k?Object.entries(k).flatMap(([P,R])=>{const O=a(R);return P==="base"?O.join(""):`${P} { ${O.join("")} }`}):[],p=k=>k?Object.entries(k).flatMap(([P,R])=>Object.entries(R).flatMap(([O,X])=>{const Y=a(X,[P]),v=`.${P}-${O}, [data-${P}="${O}"]`,ee=Y.join("");return`${v} { ${ee} }`})):[],r=k=>({...k,responsive:void 0,conditional:void 0}),o=k=>t.variables.map(P=>k==="static"?r(P._current):P._current[k]),h=W(r(s.variables),o("static")),g=a(h),y=W((L=s.variables)==null?void 0:L.responsive,o("responsive")),N=c(y),x=W((ie=s.variables)==null?void 0:ie.conditional,o("conditional")),D=p(x),b=await J(e),F=l.join(b,"css/_variables.css"),_=`:root { ${g.join("")} ${N.join("")} } ${D.join("")}`;u.writeFileSync(F,_),n.staticVariables=h;const j=l.join(b,"css/_global.css"),T=W(s.global,t.globalStyles),f=M(T,"");u.writeFileSync(j,`@layer global { ${f} }`);const S=l.join(b,"css/_reset.css"),d=s.reset==="none"?{}:typeof s.reset=="object"?s.reset:Oe,C=M(d,"");u.writeFileSync(S,`@layer reset { ${C} }`);const $=l.join(b,"css/_templates.css"),m=W(s.templates,t.templates),I=de(m),H=_e(m);u.writeFileSync($,I),n.templates=m;const G=l.join(b,"types/css-tokens.d.ts"),Q=`
9
9
  // Variable types
10
10
  type VariableTokens = ${[...i].join("|")};
11
11
  type PropertyValueToken = \`{\${VariableTokens}}\`;
12
12
 
13
13
  // Template types
14
14
  type TemplateTokens = {
15
- ${Object.entries(w).map(([C,k])=>`${C}?: ${k}`).join(`
15
+ ${Object.entries(H).map(([k,P])=>`${k}?: ${P}`).join(`
16
16
  `)}
17
17
  }
18
- `;u.writeFileSync(S,I);const B=l.join(j,"cache/config-cache.json");u.writeFileSync(B,JSON.stringify(n,null,2))},re=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return t;const c=i.exec(e);if(c){const p=c.at(1);if(ge.some(o=>p==null?void 0:p.includes(o)))return t}return"styled('div',"}),se=async(e,t,s)=>{const n=z(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const a=l.parse(t);let c=u.readFileSync(t,"utf8");c=re(c);const p=l.join(s,"js",n+".js"),r=await te(e),o=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),h=ye(o),g=await de(e);await ce.build({stdin:{contents:c,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:g,target:["node20"],keepNames:!0,external:h,packages:"external",plugins:[{name:"test",setup:P=>{P.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},D=>{const F=u.readFileSync(D.path,"utf8");return{contents:re(F),loader:"ts"}})}}]});const y=Date.now();return await import(`${p}?t=${y}`)},Ee=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ne=async e=>{const t=await Ee(e),s=await J(e),n=l.join(s,"salty.config.js"),i=Date.now(),{config:a}=await import(`${n}?t=${i}`);return W(a,t)},me=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Me=async(e,t=me(),s=!0)=>{try{const n=Date.now();t?ee.info("Generating CSS in production mode! 🔥"):ee.info("Generating CSS in development mode! 🚀");const i=[],a=[],c=await J(e),p=l.join(c,"index.css");s&&(()=>{u.existsSync(c)&&be.execSync("rm -rf "+c),u.mkdirSync(c,{recursive:!0}),u.mkdirSync(l.join(c,"css")),u.mkdirSync(l.join(c,"types")),u.mkdirSync(l.join(c,"js")),u.mkdirSync(l.join(c,"cache"))})();const o={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function h(f){const m=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(m.some(w=>f.includes(w)))return;await Promise.all(d.map(w=>h(l.join(f,w))))}else if(b.isFile()&&Z(f)){const x=await se(e,f,c);Object.entries(x).forEach(([w,S])=>{S.isKeyframes?o.keyframes.push({value:S,src:f,name:w}):S.isMedia?o.mediaQueries.push(S):S.isGlobalDefine?o.globalStyles.push(S):S.isDefineVariables?o.variables.push(S):S.isDefineTemplates?o.templates.push(S):S.isClassName?o.classNames.push({...S,src:f,name:w}):S.generator&&o.components.push({...S,src:f,name:w})})}}await h(e),await Oe(e,o);const g=await ne(e);for(const f of o.keyframes){const{value:m}=f,b=`a_${m.animationName}.css`,d=`css/${b}`,x=l.join(c,d);i.push(b),u.writeFileSync(x,m.css)}const y={};for(const f of o.components){const{src:m,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:g});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const x=`css/${d.cssFileName}`,w=l.join(c,x);u.writeFileSync(w,d.css),g.importStrategy==="component"&&(y[m]?y[m].push(d.cssFileName):y[m]=[d.cssFileName])}for(const f of o.classNames){const{src:m,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:g});a[0].push(d.cssFileName);const x=`css/${d.cssFileName}`,w=l.join(c,x);u.writeFileSync(w,d.css),g.importStrategy==="component"&&(y[m]?y[m].push(d.cssFileName):y[m]=[d.cssFileName])}g.importStrategy==="component"&&Object.entries(y).forEach(([f,m])=>{const b=m.map(L=>`@import url('./${L}');`).join(`
19
- `),d=z(f,6),x=l.parse(f),w=M(x.name),S=l.join(c,`css/f_${w}-${d}.css`);u.writeFileSync(S,b)});const j=i.map(f=>`@import url('./css/${f}');`).join(`
20
- `);let N=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
18
+ `;u.writeFileSync(G,Q);const q=l.join(b,"cache/config-cache.json");u.writeFileSync(q,JSON.stringify(n,null,2))},ae=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return t;const c=i.exec(e);if(c){const p=c.at(1);if(Se.some(o=>p==null?void 0:p.includes(o)))return t}return"styled('div',"}),oe=async(e,t,s)=>{const n=z(t),i=l.join(s,"./temp");u.existsSync(i)||u.mkdirSync(i);const a=l.parse(t);let c=u.readFileSync(t,"utf8");c=ae(c);const p=l.join(s,"js",n+".js"),r=await ne(e),o=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),h=me(o),g=await ge(e);await fe.build({stdin:{contents:c,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:g,target:["node20"],keepNames:!0,external:h,packages:"external",plugins:[{name:"test",setup:x=>{x.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},D=>{const b=u.readFileSync(D.path,"utf8");return{contents:ae(b),loader:"ts"}})}}]});const y=Date.now();return await import(`${p}?t=${y}`)},Re=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},re=async e=>{const t=await Re(e),s=await J(e),n=l.join(s,"salty.config.js"),i=Date.now(),{config:a}=await import(`${n}?t=${i}`);return W(a,t)},je=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Je=async(e,t=je(),s=!0)=>{try{const n=Date.now();t?se.info("Generating CSS in production mode! 🔥"):se.info("Generating CSS in development mode! 🚀");const i=[],a=[],c=await J(e),p=l.join(c,"index.css");s&&(()=>{u.existsSync(c)&&Ce.execSync("rm -rf "+c),u.mkdirSync(c,{recursive:!0}),u.mkdirSync(l.join(c,"css")),u.mkdirSync(l.join(c,"types")),u.mkdirSync(l.join(c,"js")),u.mkdirSync(l.join(c,"cache"))})();const o={keyframes:[],mediaQueries:[],globalStyles:[],variables:[],templates:[],components:[],classNames:[]};async function h(f){const S=["node_modules","saltygen"],w=u.statSync(f);if(w.isDirectory()){const d=u.readdirSync(f);if(S.some($=>f.includes($)))return;await Promise.all(d.map($=>h(l.join(f,$))))}else if(w.isFile()&&Z(f)){const C=await oe(e,f,c);Object.entries(C).forEach(([$,m])=>{m.isKeyframes?o.keyframes.push({value:m,src:f,name:$}):m.isMedia?o.mediaQueries.push(m):m.isGlobalDefine?o.globalStyles.push(m):m.isDefineVariables?o.variables.push(m):m.isDefineTemplates?o.templates.push(m):m.isClassName?o.classNames.push({...m,src:f,name:$}):m.generator&&o.components.push({...m,src:f,name:$})})}}await h(e),await Me(e,o);const g=await re(e);for(const f of o.keyframes){const{value:S}=f,w=`a_${S.animationName}.css`,d=`css/${w}`,C=l.join(c,d);i.push(w),u.writeFileSync(C,S.css)}const y={};for(const f of o.components){const{src:S,name:w}=f,d=f.generator._withBuildContext({callerName:w,isProduction:t,config:g});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const C=`css/${d.cssFileName}`,$=l.join(c,C);u.writeFileSync($,d.css),g.importStrategy==="component"&&(y[S]?y[S].push(d.cssFileName):y[S]=[d.cssFileName])}for(const f of o.classNames){const{src:S,name:w}=f,d=f.generator._withBuildContext({callerName:w,isProduction:t,config:g});a[0].push(d.cssFileName);const C=`css/${d.cssFileName}`,$=l.join(c,C);u.writeFileSync($,d.css),g.importStrategy==="component"&&(y[S]?y[S].push(d.cssFileName):y[S]=[d.cssFileName])}g.importStrategy==="component"&&Object.entries(y).forEach(([f,S])=>{const w=S.map(I=>`@import url('./${I}');`).join(`
19
+ `),d=z(f,6),C=l.parse(f),$=V(C.name),m=l.join(c,`css/f_${$}-${d}.css`);u.writeFileSync(m,w)});const N=i.map(f=>`@import url('./css/${f}');`).join(`
20
+ `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
21
 
22
22
  ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(c,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
23
23
  `)}
24
- ${j}`;if(g.importStrategy!=="component"){const f=a.reduce((m,b,d)=>{const x=b.reduce((I,B)=>{var k;const H=l.join(c,"css",B),G=u.readFileSync(H,"utf8"),C=((k=/.*-([^-]+)-\d+.css/.exec(B))==null?void 0:k.at(1))||z(H,6);return I.includes(C)?I:`${I}
25
- /*start:${C}*/
26
- ${G}
27
- /*end:${C}*/
28
- `},""),w=`l_${d}.css`,S=l.join(c,"css",w),L=`@layer l${d} { ${x}
29
- }`;return u.writeFileSync(S,L),`${m}
30
- @import url('./css/${w}');`},"");N+=f}u.writeFileSync(p,N);const $=Date.now()-n,O=$<200?"🔥":$<500?"🚀":$<1e3?"🎉":$<2e3?"🚗":$<5e3?"🤔":"🥴";ee.info(`Generated CSS in ${$}ms! ${O}`)}catch(n){console.error(n)}},Re=async(e,t)=>{try{const s=await J(e);if(Z(t)){const i=[],a=await ne(e),c=await se(e,t,s);if(Object.entries(c).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const j=`css/${`a_${r.animationName}.css`}`,P=l.join(s,j);u.writeFileSync(P,r.css);return}if(r.isClassName){const y=r.factory._withBuildContext({name:p});i[0].push(y.cssFileName);const j=`css/${y.cssFileName}`,P=l.join(s,j);u.writeFileSync(P,y.css)}if(!r.generator)return;const o=r.generator._withBuildContext({name:p,config:a}),h=`css/${o.cssFileName}`,g=l.join(s,h);u.writeFileSync(g,o.css),i[o.priority]||(i[o.priority]=[]),i[o.priority].push(o.cssFileName)}),a.importStrategy!=="component")i.forEach((p,r)=>{const o=`l_${r}.css`,h=l.join(s,"css",o);let g=u.readFileSync(h,"utf8");p.forEach(y=>{var F;const j=l.join(s,"css",y),P=((F=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:F.at(1))||z(j,6);if(!g.includes(P)){const N=u.readFileSync(j,"utf8"),_=`/*start:${P}*/
31
- ${N}
32
- /*end:${P}*/
24
+ ${N}`;if(g.importStrategy!=="component"){const f=a.reduce((S,w,d)=>{const C=w.reduce((H,G)=>{var L;const U=l.join(c,"css",G),Q=u.readFileSync(U,"utf8"),q=((L=/.*-([^-]+)-\d+.css/.exec(G))==null?void 0:L.at(1))||z(U,6);return H.includes(q)?H:`${H}
25
+ /*start:${q}*/
26
+ ${Q}
27
+ /*end:${q}*/
28
+ `},""),$=`l_${d}.css`,m=l.join(c,"css",$),I=`@layer l${d} { ${C}
29
+ }`;return u.writeFileSync(m,I),`${S}
30
+ @import url('./css/${$}');`},"");F+=f}u.writeFileSync(p,F);const j=Date.now()-n,T=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";se.info(`Generated CSS in ${j}ms! ${T}`)}catch(n){console.error(n)}},Ae=async(e,t)=>{try{const s=await J(e);if(Z(t)){const i=[],a=await re(e),c=await oe(e,t,s);if(Object.entries(c).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const N=`css/${`a_${r.animationName}.css`}`,x=l.join(s,N);u.writeFileSync(x,r.css);return}if(r.isClassName){const y=r.factory._withBuildContext({name:p});i[0].push(y.cssFileName);const N=`css/${y.cssFileName}`,x=l.join(s,N);u.writeFileSync(x,y.css)}if(!r.generator)return;const o=r.generator._withBuildContext({name:p,config:a}),h=`css/${o.cssFileName}`,g=l.join(s,h);u.writeFileSync(g,o.css),i[o.priority]||(i[o.priority]=[]),i[o.priority].push(o.cssFileName)}),a.importStrategy!=="component")i.forEach((p,r)=>{const o=`l_${r}.css`,h=l.join(s,"css",o);let g=u.readFileSync(h,"utf8");p.forEach(y=>{var b;const N=l.join(s,"css",y),x=((b=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:b.at(1))||z(N,6);if(!g.includes(x)){const F=u.readFileSync(N,"utf8"),_=`/*start:${x}*/
31
+ ${F}
32
+ /*end:${x}*/
33
33
  `;g=`${g.replace(/\}$/,"")}
34
34
  ${_}
35
35
  }`}}),u.writeFileSync(h,g)});else{const p=i.flat().map(y=>`@import url('./${y}');`).join(`
36
- `),r=z(t,6),o=l.parse(t),h=M(o.name),g=l.join(s,`css/f_${h}-${r}.css`);u.writeFileSync(g,p)}}}catch(s){console.error(s)}},Ve=async(e,t,s=me())=>{try{const n=await J(e);if(Z(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,h=>`export ${h}`)!==a&&await K.writeFile(t,a);const p=await ne(e),r=await se(e,t,n);let o=a;if(Object.entries(r).forEach(([h,g])=>{var w;if(g.isKeyframes||!g.generator)return;const y=g.generator._withBuildContext({name:h,config:p,prod:s}),j=new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!j)return console.error("Could not find the original declaration");const P=(w=j.at(1))==null?void 0:w.trim(),D=new RegExp(`\\s${h}[=\\s]+styled\\(`,"g").exec(o);if(!D)return console.error("Could not find the original declaration");const{index:F}=D;let N=!1;const _=setTimeout(()=>N=!0,5e3);let $=0,O=!1,f=0;for(;!O&&!N;){const S=o[F+$];S==="("&&f++,S===")"&&f--,f===0&&S===")"&&(O=!0),$>o.length&&(N=!0),$++}if(!N)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const m=F+$,b=o.slice(F,m),d=o,x=` ${h} = styled(${P}, "${y.classNames}", ${JSON.stringify(y.clientProps)});`;o=o.replace(b,x),d===o&&console.error("Minimize file failed to change content",{name:h,tagName:P})}),p.importStrategy==="component"){const h=z(t,6),g=l.parse(t);o=`import '../../saltygen/css/${`f_${M(g.name)}-${h}.css`}';
37
- ${o}`}return o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}},ie=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!Z(e))return!1;const n=await K.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},Se=e=>({name:"stylegen",buildStart:()=>Me(e),load:async t=>{if(Z(t))return await Ve(e,t)},handleHotUpdate:async({file:t,server:s})=>{await ie(t)&&await s.restart()},watchChange:{handler:async t=>{Z(t)&&(await ie(t)||await Re(e,t))}}});exports.default=Se;exports.saltyPlugin=Se;
36
+ `),r=z(t,6),o=l.parse(t),h=V(o.name),g=l.join(s,`css/f_${h}-${r}.css`);u.writeFileSync(g,p)}}}catch(s){console.error(s)}},We=async(e,t,s=je())=>{try{const n=await J(e);if(Z(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,h=>`export ${h}`)!==a&&await K.writeFile(t,a);const p=await re(e),r=await oe(e,t,n);let o=a;if(Object.entries(r).forEach(([h,g])=>{var $;if(g.isKeyframes||!g.generator)return;const y=g.generator._withBuildContext({name:h,config:p,prod:s}),N=new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!N)return console.error("Could not find the original declaration");const x=($=N.at(1))==null?void 0:$.trim(),D=new RegExp(`\\s${h}[=\\s]+styled\\(`,"g").exec(o);if(!D)return console.error("Could not find the original declaration");const{index:b}=D;let F=!1;const _=setTimeout(()=>F=!0,5e3);let j=0,T=!1,f=0;for(;!T&&!F;){const m=o[b+j];m==="("&&f++,m===")"&&f--,f===0&&m===")"&&(T=!0),j>o.length&&(F=!0),j++}if(!F)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const S=b+j,w=o.slice(b,S),d=o,C=` ${h} = styled(${x}, "${y.classNames}", ${JSON.stringify(y.clientProps)});`;o=o.replace(w,C),d===o&&console.error("Minimize file failed to change content",{name:h,tagName:x})}),p.importStrategy==="component"){const h=z(t,6),g=l.parse(t);o=`import '../../saltygen/css/${`f_${V(g.name)}-${h}.css`}';
37
+ ${o}`}return o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}},le=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!Z(e))return!1;const n=await K.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(n)},$e=e=>({name:"stylegen",buildStart:()=>Je(e),load:async t=>{if(Z(t))return await We(e,t)},handleHotUpdate:async({file:t,server:s})=>{await le(t)&&await s.restart()},watchChange:{handler:async t=>{Z(t)&&(await le(t)||await Ae(e,t))}}});exports.default=$e;exports.saltyPlugin=$e;
package/index.js CHANGED
@@ -1,25 +1,25 @@
1
- import * as ft from "esbuild";
2
- import { execSync as Ct } from "child_process";
1
+ import * as dt from "esbuild";
2
+ import { execSync as Nt } from "child_process";
3
3
  import { join as f, parse as Q } from "path";
4
- import { existsSync as st, mkdirSync as z, statSync as jt, readdirSync as Ft, writeFileSync as k, readFileSync as V } from "fs";
5
- import { readFile as nt, writeFile as Nt } from "fs/promises";
6
- import { createLogger as xt, format as tt, transports as kt } from "winston";
7
- const ct = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Pt = (t, e) => {
4
+ import { existsSync as ot, mkdirSync as z, statSync as xt, readdirSync as kt, writeFileSync as N, readFileSync as O } from "fs";
5
+ import { readFile as rt, writeFile as Pt } from "fs/promises";
6
+ import { createLogger as Dt, format as st, transports as _t } from "winston";
7
+ const ft = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Et = (t, e) => {
8
8
  let s = "", n;
9
- for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = ct(n % 52) + s;
10
- return s = ct(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
11
- }, Dt = (t, e) => {
9
+ for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = ft(n % 52) + s;
10
+ return s = ft(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
11
+ }, Tt = (t, e) => {
12
12
  let s = e.length;
13
13
  for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
14
14
  return t;
15
15
  }, H = (t, e = 5) => {
16
- const s = Dt(5381, JSON.stringify(t)) >>> 0;
17
- return Pt(s, e);
16
+ const s = Tt(5381, JSON.stringify(t)) >>> 0;
17
+ return Et(s, e);
18
18
  };
19
19
  function M(t) {
20
20
  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()) : "";
21
21
  }
22
- const Et = (t, e) => {
22
+ const Vt = (t, e) => {
23
23
  if (typeof t != "string") return { result: t };
24
24
  if (!e) return { result: t };
25
25
  const s = [];
@@ -30,28 +30,28 @@ const Et = (t, e) => {
30
30
  return r && s.push(r), p;
31
31
  });
32
32
  }), { result: t, additionalCss: s };
33
- }, ut = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${M(n[1].replaceAll(".", "-"))})`) } : { result: t }, R = (t, e, s) => {
33
+ }, gt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${M(n[1].replaceAll(".", "-"))})`) } : { result: t }, R = (t, e, s) => {
34
34
  if (!t) return "";
35
35
  const n = [], i = Object.entries(t).reduce((c, [p, r]) => {
36
- const o = p.trim(), h = o.startsWith("-") ? o : M(o), g = (C, F = ";") => c = `${c}${C}${F}`, d = (C) => g(`${h}:${C}`);
36
+ const o = p.trim(), h = o.startsWith("-") ? o : M(o), g = ($, C = ";") => c = `${c}${$}${C}`, d = ($) => g(`${h}:${$}`);
37
37
  if (typeof r == "function" && (r = r()), typeof r == "object") {
38
38
  if (!r) return c;
39
39
  if (r.isColor)
40
40
  return d(r.toString()), c;
41
41
  if (o === "variants")
42
42
  return Object.entries(r).forEach(([D, b]) => {
43
- b && Object.entries(b).forEach(([T, l]) => {
43
+ b && Object.entries(b).forEach(([E, l]) => {
44
44
  if (!l) return;
45
- const m = `${e}.${D}-${T}`, w = R(l, m);
46
- n.push(w);
45
+ const y = `${e}.${D}-${E}`, S = R(l, y);
46
+ n.push(S);
47
47
  });
48
48
  }), c;
49
49
  if (o === "defaultVariants")
50
50
  return c;
51
51
  if (o === "compoundVariants")
52
52
  return r.forEach((D) => {
53
- const { css: b, ...T } = D, l = Object.entries(T).reduce((w, [u, N]) => `${w}.${u}-${N}`, e), m = R(b, l);
54
- n.push(m);
53
+ const { css: b, ...E } = D, l = Object.entries(E).reduce((S, [u, j]) => `${S}.${u}-${j}`, e), y = R(b, l);
54
+ n.push(y);
55
55
  }), c;
56
56
  if (o.startsWith("@")) {
57
57
  const D = R(r, e), b = `${o} {
@@ -61,18 +61,18 @@ const Et = (t, e) => {
61
61
  }`;
62
62
  return n.push(b), c;
63
63
  }
64
- const C = p.includes("&") ? o.replace("&", e) : o.startsWith(":") ? `${e}${o}` : `${e} ${o}`, F = R(r, C);
65
- return n.push(F), c;
64
+ const $ = p.includes("&") ? o.replace("&", e) : o.startsWith(":") ? `${e}${o}` : `${e} ${o}`, C = R(r, $);
65
+ return n.push(C), c;
66
66
  }
67
67
  if (typeof r == "number") return d(r);
68
68
  if (typeof r != "string")
69
69
  if ("toString" in r) r = r.toString();
70
70
  else return c;
71
- const { modifiers: $ } = {}, E = function* () {
72
- yield ut(r), yield Et(r, $);
71
+ const { modifiers: F } = {}, _ = function* () {
72
+ yield gt(r), yield Vt(r, F);
73
73
  }();
74
- for (const { result: C, additionalCss: F = [] } of E)
75
- r = C, F.forEach((D) => {
74
+ for (const { result: $, additionalCss: C = [] } of _)
75
+ r = $, C.forEach((D) => {
76
76
  const b = R(D, "");
77
77
  g(b, "");
78
78
  });
@@ -81,13 +81,13 @@ const Et = (t, e) => {
81
81
  return i ? e ? [`${e} { ${i} }`, ...n].join(`
82
82
  `) : i : n.join(`
83
83
  `);
84
- }, pt = (t, e = []) => {
84
+ }, ht = (t, e = []) => {
85
85
  if (!t) return "";
86
86
  const s = [], n = {};
87
87
  if (Object.entries(t).forEach(([i, a]) => {
88
88
  if (typeof a == "object") {
89
89
  if (!a) return;
90
- const c = i.trim(), p = pt(a, [...e, c]);
90
+ const c = i.trim(), p = ht(a, [...e, c]);
91
91
  s.push(p);
92
92
  } else
93
93
  n[i] = a;
@@ -97,36 +97,36 @@ const Et = (t, e) => {
97
97
  }
98
98
  return s.join(`
99
99
  `);
100
- }, _t = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = dt(n).map((i) => `"${i}"`).join(" | ")), e), {}) : {}, dt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
100
+ }, Ot = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = mt(n).map((i) => `"${i}"`).join(" | ")), e), {}) : {}, mt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, i]) => {
101
101
  const a = e ? `${e}.${n}` : n;
102
- return typeof i == "object" ? dt(i, a, s) : s.add(e);
103
- }), [...s]) : [], gt = (t) => {
102
+ return typeof i == "object" ? mt(i, a, s) : s.add(e);
103
+ }), [...s]) : [], yt = (t) => {
104
104
  if (!t || t === "/") throw new Error("Could not find package.json file");
105
105
  const e = f(t, "package.json");
106
- return st(e) ? e : gt(f(t, ".."));
107
- }, Tt = async (t) => {
108
- const e = gt(t);
109
- return await nt(e, "utf-8").then(JSON.parse).catch(() => {
106
+ return ot(e) ? e : yt(f(t, ".."));
107
+ }, Mt = async (t) => {
108
+ const e = yt(t);
109
+ return await rt(e, "utf-8").then(JSON.parse).catch(() => {
110
110
  });
111
- }, Ot = async (t) => {
112
- const e = await Tt(t);
111
+ }, Rt = async (t) => {
112
+ const e = await Mt(t);
113
113
  if (e)
114
114
  return e.type;
115
115
  };
116
116
  let W;
117
- const ht = async (t) => {
117
+ const $t = async (t) => {
118
118
  if (W) return W;
119
- const e = await Ot(t);
119
+ const e = await Rt(t);
120
120
  return e === "module" ? W = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (W = "cjs"), W || "esm";
121
- }, et = xt({
121
+ }, nt = Dt({
122
122
  level: "debug",
123
- format: tt.combine(tt.colorize(), tt.cli()),
124
- transports: [new kt.Console({})]
123
+ format: st.combine(st.colorize(), st.cli()),
124
+ transports: [new _t.Console({})]
125
125
  });
126
- function mt(t) {
127
- return t ? typeof t != "string" ? mt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
126
+ function bt(t) {
127
+ return t ? typeof t != "string" ? bt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
128
128
  }
129
- const Vt = {
129
+ const Jt = {
130
130
  /** Set box model to border-box */
131
131
  "*, *::before, *::after": {
132
132
  boxSizing: "border-box"
@@ -172,33 +172,33 @@ const Vt = {
172
172
  fontSize: "100%",
173
173
  lineHeight: "1.15em"
174
174
  }
175
- }, Z = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), O = {
175
+ }, Z = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), V = {
176
176
  externalModules: [],
177
177
  rcFile: void 0,
178
178
  destDir: void 0
179
- }, yt = (t) => {
180
- if (O.externalModules.length > 0) return O.externalModules;
181
- const s = V(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
179
+ }, wt = (t) => {
180
+ if (V.externalModules.length > 0) return V.externalModules;
181
+ const s = O(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
182
182
  if (!s) return [];
183
183
  const n = s[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
184
- return O.externalModules = n, n;
184
+ return V.externalModules = n, n;
185
185
  }, A = async (t) => {
186
- if (O.destDir) return O.destDir;
187
- const e = await ot(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
188
- return O.destDir = s, s;
189
- }, $t = ["salty", "css", "styles", "styled"], Mt = (t = []) => new RegExp(`\\.(${[...$t, ...t].join("|")})\\.`), I = (t, e = []) => Mt(e).test(t), bt = async (t) => {
190
- if (O.rcFile) return O.rcFile;
186
+ if (V.destDir) return V.destDir;
187
+ const e = await it(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
188
+ return V.destDir = s, s;
189
+ }, St = ["salty", "css", "styles", "styled"], At = (t = []) => new RegExp(`\\.(${[...St, ...t].join("|")})\\.`), I = (t, e = []) => At(e).test(t), Ct = async (t) => {
190
+ if (V.rcFile) return V.rcFile;
191
191
  if (t === "/") throw new Error("Could not find .saltyrc.json file");
192
- const e = f(t, ".saltyrc.json"), s = await nt(e, "utf-8").then(JSON.parse).catch(() => {
192
+ const e = f(t, ".saltyrc.json"), s = await rt(e, "utf-8").then(JSON.parse).catch(() => {
193
193
  });
194
- return s ? (O.rcFile = s, s) : bt(f(t, ".."));
195
- }, ot = async (t) => {
194
+ return s ? (V.rcFile = s, s) : Ct(f(t, ".."));
195
+ }, it = async (t) => {
196
196
  var n, i;
197
- const e = await bt(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
197
+ const e = await Ct(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
198
198
  return s || ((i = e.projects) == null ? void 0 : i.find((a) => a.dir === e.defaultProject));
199
- }, Rt = async (t) => {
200
- const e = await ot(t), s = await A(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), i = f(s, "salty.config.js"), a = await ht(t), c = yt(n);
201
- await ft.build({
199
+ }, Wt = async (t) => {
200
+ const e = await it(t), s = await A(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), i = f(s, "salty.config.js"), a = await $t(t), c = wt(n);
201
+ await dt.build({
202
202
  entryPoints: [n],
203
203
  minify: !0,
204
204
  treeShaking: !0,
@@ -209,61 +209,61 @@ const Vt = {
209
209
  });
210
210
  const p = Date.now(), { config: r } = await import(`${i}?t=${p}`);
211
211
  return r;
212
- }, Jt = async (t, e) => {
213
- var G, q;
214
- const s = await Rt(t), n = { ...s }, i = /* @__PURE__ */ new Set(), a = (j, x = []) => j ? Object.entries(j).flatMap(([J, _]) => {
215
- if (!_) return;
216
- if (typeof _ == "object") return a(_, [...x, J]);
217
- const U = mt(J), X = M(J), Y = [...x, U].join(".");
218
- i.add(`"${Y}"`);
219
- const v = [...x.map(M), X].join("-"), { result: St } = ut(_);
220
- return `--${v}: ${St};`;
221
- }) : [], c = (j) => j ? Object.entries(j).flatMap(([x, J]) => {
222
- const _ = a(J);
223
- return x === "base" ? _.join("") : `${x} { ${_.join("")} }`;
224
- }) : [], p = (j) => j ? Object.entries(j).flatMap(([x, J]) => Object.entries(J).flatMap(([_, U]) => {
225
- const X = a(U, [x]), Y = `.${x}-${_}, [data-${x}="${_}"]`, v = X.join("");
226
- return `${Y} { ${v} }`;
227
- })) : [], r = (j) => ({ ...j, responsive: void 0, conditional: void 0 }), o = (j) => e.variables.map((x) => j === "static" ? r(x._current) : x._current[j]), h = a(Z(r(s.variables), o("static"))), g = c(Z((G = s.variables) == null ? void 0 : G.responsive, o("responsive"))), d = p(Z((q = s.variables) == null ? void 0 : q.conditional, o("conditional"))), $ = await A(t), P = f($, "css/_variables.css"), E = `:root { ${h.join("")} ${g.join("")} } ${d.join("")}`;
228
- k(P, E);
229
- const C = f($, "css/_global.css"), F = Z(s.global, e.globalStyles), D = R(F, "");
230
- k(C, `@layer global { ${D} }`);
231
- const b = f($, "css/_reset.css"), l = s.reset === "none" ? {} : typeof s.reset == "object" ? s.reset : Vt, m = R(l, "");
232
- k(b, `@layer reset { ${m} }`);
233
- const w = f($, "css/_templates.css"), u = Z(s.templates, e.templates), N = pt(u), S = _t(u);
234
- k(w, N), n.templates = u;
235
- const y = f($, "types/css-tokens.d.ts"), B = `
212
+ }, zt = async (t, e) => {
213
+ var K, lt;
214
+ const s = await Wt(t), n = { ...s }, i = /* @__PURE__ */ new Set(), a = (k, P = []) => k ? Object.entries(k).flatMap(([J, T]) => {
215
+ if (!T) return;
216
+ if (typeof T == "object") return a(T, [...P, J]);
217
+ const Y = bt(J), v = M(J), tt = [...P, Y].join(".");
218
+ i.add(`"${tt}"`);
219
+ const et = [...P.map(M), v].join("-"), { result: Ft } = gt(T);
220
+ return `--${et}: ${Ft};`;
221
+ }) : [], c = (k) => k ? Object.entries(k).flatMap(([P, J]) => {
222
+ const T = a(J);
223
+ return P === "base" ? T.join("") : `${P} { ${T.join("")} }`;
224
+ }) : [], p = (k) => k ? Object.entries(k).flatMap(([P, J]) => Object.entries(J).flatMap(([T, Y]) => {
225
+ const v = a(Y, [P]), tt = `.${P}-${T}, [data-${P}="${T}"]`, et = v.join("");
226
+ return `${tt} { ${et} }`;
227
+ })) : [], r = (k) => ({ ...k, responsive: void 0, conditional: void 0 }), o = (k) => e.variables.map((P) => k === "static" ? r(P._current) : P._current[k]), h = Z(r(s.variables), o("static")), g = a(h), d = Z((K = s.variables) == null ? void 0 : K.responsive, o("responsive")), F = c(d), x = Z((lt = s.variables) == null ? void 0 : lt.conditional, o("conditional")), _ = p(x), $ = await A(t), C = f($, "css/_variables.css"), D = `:root { ${g.join("")} ${F.join("")} } ${_.join("")}`;
228
+ N(C, D), n.staticVariables = h;
229
+ const b = f($, "css/_global.css"), E = Z(s.global, e.globalStyles), l = R(E, "");
230
+ N(b, `@layer global { ${l} }`);
231
+ const y = f($, "css/_reset.css"), u = s.reset === "none" ? {} : typeof s.reset == "object" ? s.reset : Jt, j = R(u, "");
232
+ N(y, `@layer reset { ${j} }`);
233
+ const w = f($, "css/_templates.css"), m = Z(s.templates, e.templates), B = ht(m), G = Ot(m);
234
+ N(w, B), n.templates = m;
235
+ const q = f($, "types/css-tokens.d.ts"), X = `
236
236
  // Variable types
237
237
  type VariableTokens = ${[...i].join("|")};
238
238
  type PropertyValueToken = \`{\${VariableTokens}}\`;
239
239
 
240
240
  // Template types
241
241
  type TemplateTokens = {
242
- ${Object.entries(S).map(([j, x]) => `${j}?: ${x}`).join(`
242
+ ${Object.entries(G).map(([k, P]) => `${k}?: ${P}`).join(`
243
243
  `)}
244
244
  }
245
245
  `;
246
- k(y, B);
247
- const K = f($, "cache/config-cache.json");
248
- k(K, JSON.stringify(n, null, 2));
249
- }, at = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
246
+ N(q, X);
247
+ const L = f($, "cache/config-cache.json");
248
+ N(L, JSON.stringify(n, null, 2));
249
+ }, ut = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
250
250
  if (/^['"`]/.test(s)) return e;
251
251
  const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
252
252
  if (!i.test(t)) return e;
253
253
  const c = i.exec(t);
254
254
  if (c) {
255
255
  const p = c.at(1);
256
- if ($t.some((o) => p == null ? void 0 : p.includes(o))) return e;
256
+ if (St.some((o) => p == null ? void 0 : p.includes(o))) return e;
257
257
  }
258
258
  return "styled('div',";
259
- }), rt = async (t, e, s) => {
259
+ }), ct = async (t, e, s) => {
260
260
  const n = H(e), i = f(s, "./temp");
261
- st(i) || z(i);
261
+ ot(i) || z(i);
262
262
  const a = Q(e);
263
- let c = V(e, "utf8");
264
- c = at(c);
265
- const p = f(s, "js", n + ".js"), r = await ot(t), o = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), h = yt(o), g = await ht(t);
266
- await ft.build({
263
+ let c = O(e, "utf8");
264
+ c = ut(c);
265
+ const p = f(s, "js", n + ".js"), r = await it(t), o = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), h = wt(o), g = await $t(t);
266
+ await dt.build({
267
267
  stdin: {
268
268
  contents: c,
269
269
  sourcefile: a.base,
@@ -282,10 +282,10 @@ const Vt = {
282
282
  plugins: [
283
283
  {
284
284
  name: "test",
285
- setup: (P) => {
286
- P.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (E) => {
287
- const C = V(E.path, "utf8");
288
- return { contents: at(C), loader: "ts" };
285
+ setup: (x) => {
286
+ x.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (_) => {
287
+ const $ = O(_.path, "utf8");
288
+ return { contents: ut($), loader: "ts" };
289
289
  });
290
290
  }
291
291
  }
@@ -293,26 +293,26 @@ const Vt = {
293
293
  });
294
294
  const d = Date.now();
295
295
  return await import(`${p}?t=${d}`);
296
- }, At = async (t) => {
297
- const e = await A(t), s = f(e, "cache/config-cache.json"), n = V(s, "utf8");
296
+ }, Zt = async (t) => {
297
+ const e = await A(t), s = f(e, "cache/config-cache.json"), n = O(s, "utf8");
298
298
  if (!n) throw new Error("Could not find config cache file");
299
299
  return JSON.parse(n);
300
- }, it = async (t) => {
301
- const e = await At(t), s = await A(t), n = f(s, "salty.config.js"), i = Date.now(), { config: a } = await import(`${n}?t=${i}`);
300
+ }, at = async (t) => {
301
+ const e = await Zt(t), s = await A(t), n = f(s, "salty.config.js"), i = Date.now(), { config: a } = await import(`${n}?t=${i}`);
302
302
  return Z(a, e);
303
- }, wt = () => {
303
+ }, jt = () => {
304
304
  try {
305
305
  return process.env.NODE_ENV === "production";
306
306
  } catch {
307
307
  return !1;
308
308
  }
309
- }, Wt = async (t, e = wt(), s = !0) => {
309
+ }, Ht = async (t, e = jt(), s = !0) => {
310
310
  try {
311
311
  const n = Date.now();
312
- e ? et.info("Generating CSS in production mode! 🔥") : et.info("Generating CSS in development mode! 🚀");
312
+ e ? nt.info("Generating CSS in production mode! 🔥") : nt.info("Generating CSS in development mode! 🚀");
313
313
  const i = [], a = [], c = await A(t), p = f(c, "index.css");
314
314
  s && (() => {
315
- st(c) && Ct("rm -rf " + c), z(c, { recursive: !0 }), z(f(c, "css")), z(f(c, "types")), z(f(c, "js")), z(f(c, "cache"));
315
+ ot(c) && Nt("rm -rf " + c), z(c, { recursive: !0 }), z(f(c, "css")), z(f(c, "types")), z(f(c, "js")), z(f(c, "cache"));
316
316
  })();
317
317
  const o = {
318
318
  keyframes: [],
@@ -324,107 +324,107 @@ const Vt = {
324
324
  classNames: []
325
325
  };
326
326
  async function h(l) {
327
- const m = ["node_modules", "saltygen"], w = jt(l);
328
- if (w.isDirectory()) {
329
- const u = Ft(l);
330
- if (m.some((S) => l.includes(S))) return;
331
- await Promise.all(u.map((S) => h(f(l, S))));
332
- } else if (w.isFile() && I(l)) {
333
- const N = await rt(t, l, c);
334
- Object.entries(N).forEach(([S, y]) => {
335
- y.isKeyframes ? o.keyframes.push({
336
- value: y,
327
+ const y = ["node_modules", "saltygen"], S = xt(l);
328
+ if (S.isDirectory()) {
329
+ const u = kt(l);
330
+ if (y.some((w) => l.includes(w))) return;
331
+ await Promise.all(u.map((w) => h(f(l, w))));
332
+ } else if (S.isFile() && I(l)) {
333
+ const j = await ct(t, l, c);
334
+ Object.entries(j).forEach(([w, m]) => {
335
+ m.isKeyframes ? o.keyframes.push({
336
+ value: m,
337
337
  src: l,
338
- name: S
339
- }) : y.isMedia ? o.mediaQueries.push(y) : y.isGlobalDefine ? o.globalStyles.push(y) : y.isDefineVariables ? o.variables.push(y) : y.isDefineTemplates ? o.templates.push(y) : y.isClassName ? o.classNames.push({
340
- ...y,
338
+ name: w
339
+ }) : m.isMedia ? o.mediaQueries.push(m) : m.isGlobalDefine ? o.globalStyles.push(m) : m.isDefineVariables ? o.variables.push(m) : m.isDefineTemplates ? o.templates.push(m) : m.isClassName ? o.classNames.push({
340
+ ...m,
341
341
  src: l,
342
- name: S
343
- }) : y.generator && o.components.push({
344
- ...y,
342
+ name: w
343
+ }) : m.generator && o.components.push({
344
+ ...m,
345
345
  src: l,
346
- name: S
346
+ name: w
347
347
  });
348
348
  });
349
349
  }
350
350
  }
351
- await h(t), await Jt(t, o);
352
- const g = await it(t);
351
+ await h(t), await zt(t, o);
352
+ const g = await at(t);
353
353
  for (const l of o.keyframes) {
354
- const { value: m } = l, w = `a_${m.animationName}.css`, u = `css/${w}`, N = f(c, u);
355
- i.push(w), k(N, m.css);
354
+ const { value: y } = l, S = `a_${y.animationName}.css`, u = `css/${S}`, j = f(c, u);
355
+ i.push(S), N(j, y.css);
356
356
  }
357
357
  const d = {};
358
358
  for (const l of o.components) {
359
- const { src: m, name: w } = l, u = l.generator._withBuildContext({
360
- callerName: w,
359
+ const { src: y, name: S } = l, u = l.generator._withBuildContext({
360
+ callerName: S,
361
361
  isProduction: e,
362
362
  config: g
363
363
  });
364
364
  a[u.priority] || (a[u.priority] = []), a[u.priority].push(u.cssFileName);
365
- const N = `css/${u.cssFileName}`, S = f(c, N);
366
- k(S, u.css), g.importStrategy === "component" && (d[m] ? d[m].push(u.cssFileName) : d[m] = [u.cssFileName]);
365
+ const j = `css/${u.cssFileName}`, w = f(c, j);
366
+ N(w, u.css), g.importStrategy === "component" && (d[y] ? d[y].push(u.cssFileName) : d[y] = [u.cssFileName]);
367
367
  }
368
368
  for (const l of o.classNames) {
369
- const { src: m, name: w } = l, u = l.generator._withBuildContext({
370
- callerName: w,
369
+ const { src: y, name: S } = l, u = l.generator._withBuildContext({
370
+ callerName: S,
371
371
  isProduction: e,
372
372
  config: g
373
373
  });
374
374
  a[0].push(u.cssFileName);
375
- const N = `css/${u.cssFileName}`, S = f(c, N);
376
- k(S, u.css), g.importStrategy === "component" && (d[m] ? d[m].push(u.cssFileName) : d[m] = [u.cssFileName]);
375
+ const j = `css/${u.cssFileName}`, w = f(c, j);
376
+ N(w, u.css), g.importStrategy === "component" && (d[y] ? d[y].push(u.cssFileName) : d[y] = [u.cssFileName]);
377
377
  }
378
- g.importStrategy === "component" && Object.entries(d).forEach(([l, m]) => {
379
- const w = m.map((L) => `@import url('./${L}');`).join(`
380
- `), u = H(l, 6), N = Q(l), S = M(N.name), y = f(c, `css/f_${S}-${u}.css`);
381
- k(y, w);
378
+ g.importStrategy === "component" && Object.entries(d).forEach(([l, y]) => {
379
+ const S = y.map((B) => `@import url('./${B}');`).join(`
380
+ `), u = H(l, 6), j = Q(l), w = M(j.name), m = f(c, `css/f_${w}-${u}.css`);
381
+ N(m, S);
382
382
  });
383
- const $ = i.map((l) => `@import url('./css/${l}');`).join(`
383
+ const F = i.map((l) => `@import url('./css/${l}');`).join(`
384
384
  `);
385
- let F = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
385
+ let C = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
386
386
 
387
387
  ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
388
388
  try {
389
- return V(f(c, "css", l), "utf8").length > 0;
389
+ return O(f(c, "css", l), "utf8").length > 0;
390
390
  } catch {
391
391
  return !1;
392
392
  }
393
393
  }).map((l) => `@import url('./css/${l}');`).join(`
394
394
  `)}
395
- ${$}`;
395
+ ${F}`;
396
396
  if (g.importStrategy !== "component") {
397
- const l = a.reduce((m, w, u) => {
398
- const N = w.reduce((B, K) => {
399
- var x;
400
- const G = f(c, "css", K), q = V(G, "utf8"), j = ((x = /.*-([^-]+)-\d+.css/.exec(K)) == null ? void 0 : x.at(1)) || H(G, 6);
401
- return B.includes(j) ? B : `${B}
402
- /*start:${j}*/
403
- ${q}
404
- /*end:${j}*/
397
+ const l = a.reduce((y, S, u) => {
398
+ const j = S.reduce((G, q) => {
399
+ var K;
400
+ const U = f(c, "css", q), X = O(U, "utf8"), L = ((K = /.*-([^-]+)-\d+.css/.exec(q)) == null ? void 0 : K.at(1)) || H(U, 6);
401
+ return G.includes(L) ? G : `${G}
402
+ /*start:${L}*/
403
+ ${X}
404
+ /*end:${L}*/
405
405
  `;
406
- }, ""), S = `l_${u}.css`, y = f(c, "css", S), L = `@layer l${u} { ${N}
406
+ }, ""), w = `l_${u}.css`, m = f(c, "css", w), B = `@layer l${u} { ${j}
407
407
  }`;
408
- return k(y, L), `${m}
409
- @import url('./css/${S}');`;
408
+ return N(m, B), `${y}
409
+ @import url('./css/${w}');`;
410
410
  }, "");
411
- F += l;
411
+ C += l;
412
412
  }
413
- k(p, F);
414
- const b = Date.now() - n, T = b < 200 ? "🔥" : b < 500 ? "🚀" : b < 1e3 ? "🎉" : b < 2e3 ? "🚗" : b < 5e3 ? "🤔" : "🥴";
415
- et.info(`Generated CSS in ${b}ms! ${T}`);
413
+ N(p, C);
414
+ const b = Date.now() - n, E = b < 200 ? "🔥" : b < 500 ? "🚀" : b < 1e3 ? "🎉" : b < 2e3 ? "🚗" : b < 5e3 ? "🤔" : "🥴";
415
+ nt.info(`Generated CSS in ${b}ms! ${E}`);
416
416
  } catch (n) {
417
417
  console.error(n);
418
418
  }
419
- }, zt = async (t, e) => {
419
+ }, It = async (t, e) => {
420
420
  try {
421
421
  const s = await A(t);
422
422
  if (I(e)) {
423
- const i = [], a = await it(t), c = await rt(t, e, s);
423
+ const i = [], a = await at(t), c = await ct(t, e, s);
424
424
  if (Object.entries(c).forEach(([p, r]) => {
425
425
  if (r.isKeyframes && r.css) {
426
- const $ = `css/${`a_${r.animationName}.css`}`, P = f(s, $);
427
- k(P, r.css);
426
+ const F = `css/${`a_${r.animationName}.css`}`, x = f(s, F);
427
+ N(x, r.css);
428
428
  return;
429
429
  }
430
430
  if (r.isClassName) {
@@ -432,73 +432,73 @@ ${q}
432
432
  name: p
433
433
  });
434
434
  i[0].push(d.cssFileName);
435
- const $ = `css/${d.cssFileName}`, P = f(s, $);
436
- k(P, d.css);
435
+ const F = `css/${d.cssFileName}`, x = f(s, F);
436
+ N(x, d.css);
437
437
  }
438
438
  if (!r.generator) return;
439
439
  const o = r.generator._withBuildContext({
440
440
  name: p,
441
441
  config: a
442
442
  }), h = `css/${o.cssFileName}`, g = f(s, h);
443
- k(g, o.css), i[o.priority] || (i[o.priority] = []), i[o.priority].push(o.cssFileName);
443
+ N(g, o.css), i[o.priority] || (i[o.priority] = []), i[o.priority].push(o.cssFileName);
444
444
  }), a.importStrategy !== "component")
445
445
  i.forEach((p, r) => {
446
446
  const o = `l_${r}.css`, h = f(s, "css", o);
447
- let g = V(h, "utf8");
447
+ let g = O(h, "utf8");
448
448
  p.forEach((d) => {
449
- var C;
450
- const $ = f(s, "css", d), P = ((C = /.*-([^-]+)-\d+.css/.exec(d)) == null ? void 0 : C.at(1)) || H($, 6);
451
- if (!g.includes(P)) {
452
- const F = V($, "utf8"), D = `/*start:${P}*/
453
- ${F}
454
- /*end:${P}*/
449
+ var $;
450
+ const F = f(s, "css", d), x = (($ = /.*-([^-]+)-\d+.css/.exec(d)) == null ? void 0 : $.at(1)) || H(F, 6);
451
+ if (!g.includes(x)) {
452
+ const C = O(F, "utf8"), D = `/*start:${x}*/
453
+ ${C}
454
+ /*end:${x}*/
455
455
  `;
456
456
  g = `${g.replace(/\}$/, "")}
457
457
  ${D}
458
458
  }`;
459
459
  }
460
- }), k(h, g);
460
+ }), N(h, g);
461
461
  });
462
462
  else {
463
463
  const p = i.flat().map((d) => `@import url('./${d}');`).join(`
464
464
  `), r = H(e, 6), o = Q(e), h = M(o.name), g = f(s, `css/f_${h}-${r}.css`);
465
- k(g, p);
465
+ N(g, p);
466
466
  }
467
467
  }
468
468
  } catch (s) {
469
469
  console.error(s);
470
470
  }
471
- }, Zt = async (t, e, s = wt()) => {
471
+ }, Bt = async (t, e, s = jt()) => {
472
472
  try {
473
473
  const n = await A(t);
474
474
  if (I(e)) {
475
- const a = V(e, "utf8");
476
- a.replace(/^(?!export\s)const\s.*/gm, (h) => `export ${h}`) !== a && await Nt(e, a);
477
- const p = await it(t), r = await rt(t, e, n);
475
+ const a = O(e, "utf8");
476
+ a.replace(/^(?!export\s)const\s.*/gm, (h) => `export ${h}`) !== a && await Pt(e, a);
477
+ const p = await at(t), r = await ct(t, e, n);
478
478
  let o = a;
479
479
  if (Object.entries(r).forEach(([h, g]) => {
480
- var S;
480
+ var w;
481
481
  if (g.isKeyframes || !g.generator) return;
482
482
  const d = g.generator._withBuildContext({
483
483
  name: h,
484
484
  config: p,
485
485
  prod: s
486
- }), $ = new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
487
- if (!$) return console.error("Could not find the original declaration");
488
- const P = (S = $.at(1)) == null ? void 0 : S.trim(), E = new RegExp(`\\s${h}[=\\s]+styled\\(`, "g").exec(o);
489
- if (!E) return console.error("Could not find the original declaration");
490
- const { index: C } = E;
491
- let F = !1;
492
- const D = setTimeout(() => F = !0, 5e3);
493
- let b = 0, T = !1, l = 0;
494
- for (; !T && !F; ) {
495
- const y = o[C + b];
496
- y === "(" && l++, y === ")" && l--, l === 0 && y === ")" && (T = !0), b > o.length && (F = !0), b++;
486
+ }), F = new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(a);
487
+ if (!F) return console.error("Could not find the original declaration");
488
+ const x = (w = F.at(1)) == null ? void 0 : w.trim(), _ = new RegExp(`\\s${h}[=\\s]+styled\\(`, "g").exec(o);
489
+ if (!_) return console.error("Could not find the original declaration");
490
+ const { index: $ } = _;
491
+ let C = !1;
492
+ const D = setTimeout(() => C = !0, 5e3);
493
+ let b = 0, E = !1, l = 0;
494
+ for (; !E && !C; ) {
495
+ const m = o[$ + b];
496
+ m === "(" && l++, m === ")" && l--, l === 0 && m === ")" && (E = !0), b > o.length && (C = !0), b++;
497
497
  }
498
- if (!F) clearTimeout(D);
498
+ if (!C) clearTimeout(D);
499
499
  else throw new Error("Failed to find the end of the styled call and timed out");
500
- const m = C + b, w = o.slice(C, m), u = o, N = ` ${h} = styled(${P}, "${d.classNames}", ${JSON.stringify(d.clientProps)});`;
501
- o = o.replace(w, N), u === o && console.error("Minimize file failed to change content", { name: h, tagName: P });
500
+ const y = $ + b, S = o.slice($, y), u = o, j = ` ${h} = styled(${x}, "${d.classNames}", ${JSON.stringify(d.clientProps)});`;
501
+ o = o.replace(S, j), u === o && console.error("Minimize file failed to change content", { name: h, tagName: x });
502
502
  }), p.importStrategy === "component") {
503
503
  const h = H(e, 6), g = Q(e);
504
504
  o = `import '../../saltygen/css/${`f_${M(g.name)}-${h}.css`}';
@@ -509,29 +509,29 @@ ${o}`;
509
509
  } catch (n) {
510
510
  console.error("Error in minimizeFile:", n);
511
511
  }
512
- }, lt = async (t) => {
512
+ }, pt = async (t) => {
513
513
  if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
514
514
  if (t.includes("salty.config")) return !0;
515
515
  if (!I(t)) return !1;
516
- const n = await nt(t, "utf-8");
516
+ const n = await rt(t, "utf-8");
517
517
  return !!/.+define[A-Z]\w+/.test(n);
518
- }, Kt = (t) => ({
518
+ }, Ut = (t) => ({
519
519
  name: "stylegen",
520
- buildStart: () => Wt(t),
520
+ buildStart: () => Ht(t),
521
521
  load: async (e) => {
522
522
  if (I(e))
523
- return await Zt(t, e);
523
+ return await Bt(t, e);
524
524
  },
525
525
  handleHotUpdate: async ({ file: e, server: s }) => {
526
- await lt(e) && await s.restart();
526
+ await pt(e) && await s.restart();
527
527
  },
528
528
  watchChange: {
529
529
  handler: async (e) => {
530
- I(e) && (await lt(e) || await zt(t, e));
530
+ I(e) && (await pt(e) || await It(t, e));
531
531
  }
532
532
  }
533
533
  });
534
534
  export {
535
- Kt as default,
536
- Kt as saltyPlugin
535
+ Ut as default,
536
+ Ut as saltyPlugin
537
537
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/vite",
3
- "version": "0.0.1-alpha.194",
3
+ "version": "0.0.1-alpha.195",
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.194"
37
+ "@salty-css/core": "^0.0.1-alpha.195"
38
38
  }
39
39
  }