@salty-css/vite 0.0.1-alpha.179 → 0.0.1-alpha.180

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