@salty-css/webpack 0.0.1-alpha.203 → 0.0.1-alpha.205

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.
@@ -119,8 +119,7 @@ const Jt = (t) => (e) => {
119
119
  if (!t) return "";
120
120
  const s = [], n = {};
121
121
  for (const [o, i] of Object.entries(t))
122
- if (typeof i == "function") console.log("Function found", o);
123
- else if (i && typeof i == "object") {
122
+ if (typeof i != "function") if (i && typeof i == "object") {
124
123
  const c = o.trim(), p = await bt(i, [...e, c]);
125
124
  s.push(p);
126
125
  } else
@@ -131,7 +130,7 @@ const Jt = (t) => (e) => {
131
130
  }
132
131
  return s.join(`
133
132
  `);
134
- }, It = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = wt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, wt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
133
+ }, It = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = wt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, wt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
135
134
  const i = e ? `${e}.${n}` : n;
136
135
  return typeof o == "object" ? wt(o, i, s) : s.add(e);
137
136
  }), [...s]) : [], Ct = (t) => {
@@ -0,0 +1,40 @@
1
+ "use strict";const Pe=require("esbuild"),ke=require("child_process"),a=require("path"),u=require("fs"),ie=require("fs/promises"),L=require("winston");var oe=typeof document<"u"?document.currentScript:null;function _e(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 me=_e(Pe),ue=e=>String.fromCharCode(e+(e>25?39:97)),De=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ue(n%52)+s;return s=ue(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Oe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},v=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(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 Te=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:l}=o;s=s.replace(i,m=>{const{value:w,css:c}=l(m);return c&&n.push(c),w})}),{transformed:s,additionalCss:n}},ye=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${V(o[1].replaceAll(".","-"))})`)},Ee=ye(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Re=["Webkit","Moz","ms","O"],ze=e=>e.startsWith("-")?e:Re.some(t=>e.startsWith(t))?`-${V(e)}`:V(e),X=async(e,t="",s)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const n=new Set,i=Object.entries(e).map(async([g,r])=>{const p=g.trim(),h=ze(p),N=(P,T=";")=>`${h}:${P}${T}`;if(typeof r=="function"&&(r=r({scope:t,config:s})),r instanceof Promise&&(r=await r),typeof r=="object"){if(!r)return;if(r.isColor)return N(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const F=Object.entries(r);for(const[D,x]of F){if(!x)return;const M=Object.entries(x);for(const[f,y]of M){if(!y)return;const b=`${t}.${D}-${f}`;(await X(y,b,s)).forEach(C=>n.add(C))}}return}if(p==="compoundVariants"){for(const F of r){const{css:D,...x}=F,M=Object.entries(x).reduce((y,[b,d])=>`${y}.${b}-${d}`,t);(await X(D,M,s)).forEach(y=>n.add(y))}return}if(p.startsWith("@")){const F=p,D=await B(r,t,s),x=`${F} { ${D} }`;n.add(x);return}const P=g.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,P,s)).forEach(F=>n.add(F));return}if(typeof r=="number"){const P=Me(h,r);return N(P)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${h}`);return N(r)}),{modifiers:l}={},m=[ye(),Te(l)],c=(await Promise.all(i).then(g=>Promise.all(g.map(r=>m.reduce(async(p,h)=>{const N=await p;if(!N)return N;const _=await h(N);if(!_)return N;const{transformed:P,additionalCss:T}=_;let F="";if(T)for(const D of T)F+=await B(D,"");return`${F}${P}`},Promise.resolve(r)))))).join(`
2
+ `);if(!c.trim())return n;const $=t?`${t} { ${c} }`:c;return n.add($),n},B=async(e,t,s)=>[...await X(e,t,s)].join(`
3
+ `),ge=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i!="function")if(i&&typeof i=="object"){const l=o.trim(),m=await ge(i,[...t,l]);s.push(m)}else n[o]=i;if(Object.keys(n).length){const o=t.map(V).join("-"),i=await B(n,`.${o}`);s.push(i)}return s.join(`
4
+ `)},Je=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=he(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},he=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?he(o,i,s):s.add(t)}),[...s]):[],we=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return u.existsSync(t)?t:we(a.join(e,".."))},We=async e=>{const t=we(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ae=async e=>{const t=await We(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await Ae(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-DJ94M3fE.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function be(e){return e?typeof e!="string"?be(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 ve={"*, *::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"}},A=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ie=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),z={externalModules:[],rcFile:void 0,destDir:void 0},Se=e=>{if(z.externalModules.length>0)return z.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return z.externalModules=n,n},J=async e=>{if(z.destDir)return z.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},je=["salty","css","styles","styled"],Fe=(e=[])=>new RegExp(`\\.(${[...je,...e].join("|")})\\.`),Y=(e,t=[])=>Fe(t).test(e),Ce=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Ce(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ce(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Ze=async e=>{const t=await ce(e),s=await J(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await $e(e),l=Se(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:l});const m=Date.now(),{config:w}=await import(`${o}?t=${m}`);return w},qe=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:j,outputFilePath:R}=await ee(e,S,s);Object.entries(j).forEach(([O,E])=>{E.isMedia?n.mediaQueries.push([O,E]):E.isGlobalDefine?n.globalStyles.push(E):E.isDefineVariables?n.variables.push(E):E.isDefineTemplates&&n.templates.push(E._setPath(R))})}));const o=await Ze(e),i={...o},l=new Set,m=(S,j=[])=>S?Object.entries(S).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return m(O,[...j,R]);const E=be(R),se=V(R),ne=[...j,E].join(".");l.add(`"${ne}"`);const U=[...j.map(V),se].join("-"),de=Ee(O);return de?`--${U}: ${de.transformed};`:`--${U}: ${O};`}):[],w=S=>S?Object.entries(S).flatMap(([j,R])=>{const O=m(R);return j==="base"?O.join(""):`${j} { ${O.join("")} }`}):[],c=S=>S?Object.entries(S).flatMap(([j,R])=>Object.entries(R).flatMap(([O,E])=>{const se=m(E,[j]),ne=`.${j}-${O}, [data-${j}="${O}"]`,U=se.join("");return`${ne} { ${U} }`})):[],$=S=>({...S,responsive:void 0,conditional:void 0}),g=S=>n.variables.map(j=>S==="static"?$(j._current):j._current[S]),r=A($(o.variables),g("static")),p=m(r),h=A((le=o.variables)==null?void 0:le.responsive,g("responsive")),N=w(h),_=A((fe=o.variables)==null?void 0:fe.conditional,g("conditional")),P=c(_),T=a.join(s,"css/_variables.css"),F=`:root { ${p.join("")} ${N.join("")} } ${P.join("")}`;u.writeFileSync(T,F),i.staticVariables=r;const D=a.join(s,"css/_global.css"),x=A(o.global,n.globalStyles),M=await B(x,"");u.writeFileSync(D,`@layer global { ${M} }`);const f=a.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ve,d=await B(b,"");u.writeFileSync(f,`@layer reset { ${d} }`);const C=a.join(s,"css/_templates.css"),k=A(o.templates,n.templates),I=await ge(k),Z=Je(k);u.writeFileSync(C,I),i.templates=k;const q=Ie(n.templates);i.templatePaths=Object.fromEntries(Object.entries(q).map(([S,j])=>[S,j._path||"nope"]));const{mediaQueries:H}=n;i.mediaQueries=Object.fromEntries(H.map(([S,j])=>[`@${S}`,j]));const G=H.map(([S])=>`'@${S}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
5
+ // Variable types
6
+ type VariableTokens = ${[...l].join("|")};
7
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
8
+
9
+ // Template types
10
+ type TemplateTokens = {
11
+ ${Object.entries(Z).map(([S,j])=>`${S}?: ${j}`).join(`
12
+ `)}
13
+ }
14
+
15
+ // Media query types
16
+ type MediaQueryKeys = ${G||"''"};
17
+ `;u.writeFileSync(te,Q);const Ne=a.join(s,"cache/config-cache.json");u.writeFileSync(Ne,JSON.stringify(i,null,2))},pe=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const l=o.exec(e);if(l){const m=l.at(1);if(je.some(c=>m==null?void 0:m.includes(c)))return t}return"styled('div',"}),He=(e,t)=>{try{const s=u.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
18
+
19
+ ${e}`:`globalThis.saltyConfig = {};
20
+
21
+ ${e}`}catch{return e}},ee=async(e,t,s)=>{const n=v(t),o=a.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=a.parse(t);let l=u.readFileSync(t,"utf8");l=pe(l),l=He(l,e);const m=a.join(s,"js",n+".js"),w=await ce(e),c=a.join(e,(w==null?void 0:w.configDir)||"","salty.config.ts"),$=Se(c),g=await $e(e);await me.build({stdin:{contents:l,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:$,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},N=>{const _=u.readFileSync(N.path,"utf8");return{contents:pe(_),loader:"ts"}})}}]});const r=Date.now();return{contents:await import(`${m}?t=${r}`),outputFilePath:m}},Le=async e=>{const t=await J(e),s=a.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)},ae=async e=>{const t=await Le(e),s=await J(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return A(i,t)},xe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=xe(),s=!0)=>{try{const n=Date.now();t?re.info("Generating CSS in production mode! 🔥"):re.info("Generating CSS in development mode! 🚀");const o=[],i=[],l=await J(e),m=a.join(l,"index.css");s&&(()=>{u.existsSync(l)&&ke.execSync("rm -rf "+l),u.mkdirSync(l,{recursive:!0}),u.mkdirSync(a.join(l,"css")),u.mkdirSync(a.join(l,"types")),u.mkdirSync(a.join(l,"js")),u.mkdirSync(a.join(l,"cache"))})();const c=new Set,$=new Set;async function g(f){const y=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(y.some(k=>f.includes(k)))return;await Promise.all(d.map(k=>g(a.join(f,k))))}else if(b.isFile()&&Y(f)){c.add(f);const C=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&$.add(f)}}await g(e),await qe(e,$);const r={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const{contents:y}=await ee(e,f,l);Object.entries(y).forEach(([b,d])=>{d.isKeyframes?r.keyframes.push({value:d,src:f,name:b}):d.isClassName?r.classNames.push({...d,src:f,name:b}):d.generator&&r.components.push({...d,src:f,name:b})})}));const p=await ae(e);for(const f of r.keyframes){const{value:y}=f,b=`a_${y.animationName}.css`,d=`css/${b}`,C=a.join(l,d);o.push(b),u.writeFileSync(C,y.css)}const h={};for(const f of r.components){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}for(const f of r.classNames){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[0].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}p.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const b=y.map(Z=>`@import url('./${Z}');`).join(`
22
+ `),d=v(f,6),C=a.parse(f),k=V(C.name),I=a.join(l,`css/f_${k}-${d}.css`);u.writeFileSync(I,b)});const N=o.map(f=>`@import url('./css/${f}');`).join(`
23
+ `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
24
+
25
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(a.join(l,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
26
+ `)}
27
+ ${N}`;if(p.importStrategy!=="component"){const f=i.reduce((y,b,d)=>{const C=b.reduce((q,H)=>{var Q;const G=a.join(l,"css",H),te=u.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:Q.at(1))||v(G,6);return q.includes(K)?q:`${q}
28
+ /*start:${K}*/
29
+ ${te}
30
+ /*end:${K}*/
31
+ `},""),k=`l_${d}.css`,I=a.join(l,"css",k),Z=`@layer l${d} { ${C}
32
+ }`;return u.writeFileSync(I,Z),`${y}
33
+ @import url('./css/${k}');`},"");F+=f}u.writeFileSync(m,F);const x=Date.now()-n,M=x<200?"🔥":x<500?"🚀":x<1e3?"🎉":x<2e3?"🚗":x<5e3?"🤔":"🥴";re.info(`Generated CSS in ${x}ms! ${M}`)}catch(n){console.error(n)}},Ge=async(e,t)=>{try{const s=await J(e);if(Y(t)){const o=[],i=await ae(e),{contents:l}=await ee(e,t,s);for(const[m,w]of Object.entries(l)){if(w.isKeyframes&&w.css){const p=`css/${`a_${w.animationName}.css`}`,h=a.join(s,p);u.writeFileSync(h,await w.css);return}if(w.isClassName){const r=w.factory._withBuildContext({name:m});o[0].push(r.cssFileName);const p=`css/${r.cssFileName}`,h=a.join(s,p);u.writeFileSync(h,await r.css)}if(!w.generator)return;const c=w.generator._withBuildContext({name:m,config:i}),$=`css/${c.cssFileName}`,g=a.join(s,$);u.writeFileSync(g,await c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}if(i.importStrategy!=="component")o.forEach((m,w)=>{const c=`l_${w}.css`,$=a.join(s,"css",c);let g=u.readFileSync($,"utf8");m.forEach(r=>{var _;const p=a.join(s,"css",r),h=((_=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:_.at(1))||v(p,6);if(!g.includes(h)){const P=u.readFileSync(p,"utf8"),T=`/*start:${h}*/
34
+ ${P}
35
+ /*end:${h}*/
36
+ `;g=`${g.replace(/\}$/,"")}
37
+ ${T}
38
+ }`}}),u.writeFileSync($,g)});else{const m=o.flat().map(r=>`@import url('./${r}');`).join(`
39
+ `),w=v(t,6),c=a.parse(t),$=V(c.name),g=a.join(s,`css/f_${$}-${w}.css`);u.writeFileSync(g,m)}}}catch(s){console.error(s)}},Ke=async(e,t,s=xe())=>{try{const n=await J(e);if(Y(t)){const i=u.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,$=>`export ${$}`)!==i&&await ie.writeFile(t,i);const m=await ae(e),{contents:w}=await ee(e,t,n);let c=i;if(Object.entries(w).forEach(([$,g])=>{var d;if(g.isKeyframes||!g.generator)return;const r=g.generator._withBuildContext({name:$,config:m,prod:s}),p=new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!p)return console.error("Could not find the original declaration");const h=(d=p.at(1))==null?void 0:d.trim(),N=new RegExp(`\\s${$}[=\\s]+styled\\(`,"g").exec(c);if(!N)return console.error("Could not find the original declaration");const{index:_}=N;let P=!1;const T=setTimeout(()=>P=!0,5e3);let F=0,D=!1,x=0;for(;!D&&!P;){const C=c[_+F];C==="("&&x++,C===")"&&x--,x===0&&C===")"&&(D=!0),F>c.length&&(P=!0),F++}if(!P)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const M=_+F,f=c.slice(_,M),y=c,b=` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;c=c.replace(f,b),y===c&&console.error("Minimize file failed to change content",{name:$,tagName:h})}),m.importStrategy==="component"){const $=v(t,6),g=a.parse(t);c=`import '../../saltygen/css/${`f_${V(g.name)}-${$}.css`}';
40
+ ${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Fe;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-BvNnzbqp.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-DJ94M3fE.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as d } from "path";
2
- import { i as f, s as p, g as u, a as y } from "./index-BhdhQhTB.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-Bap_89L2.js";
3
3
  import { readFile as g } from "fs/promises";
4
4
  import { watch as m } from "fs";
5
5
  const w = async (s) => {
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-BvNnzbqp.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
1
+ "use strict";const i=require("./index-DJ94M3fE.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
package/loader.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, m as i } from "./index-BhdhQhTB.js";
1
+ import { a as e, m as i } from "./index-Bap_89L2.js";
2
2
  async function s() {
3
3
  const { dir: t } = this.getOptions(), { resourcePath: a } = this;
4
4
  return await e(t, a), await i(t, a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/webpack",
3
- "version": "0.0.1-alpha.203",
3
+ "version": "0.0.1-alpha.205",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.0.1-alpha.203",
37
+ "@salty-css/core": "^0.0.1-alpha.205",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }
@@ -1,40 +0,0 @@
1
- "use strict";const Pe=require("esbuild"),ke=require("child_process"),a=require("path"),d=require("fs"),ie=require("fs/promises"),L=require("winston");var oe=typeof document<"u"?document.currentScript:null;function _e(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 me=_e(Pe),de=e=>String.fromCharCode(e+(e>25?39:97)),De=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=de(n%52)+s;return s=de(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Oe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},A=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(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 Te=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:l}=o;s=s.replace(i,m=>{const{value:w,css:c}=l(m);return c&&n.push(c),w})}),{transformed:s,additionalCss:n}},ye=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${V(o[1].replaceAll(".","-"))})`)},Ee=ye(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Re=["Webkit","Moz","ms","O"],ze=e=>e.startsWith("-")?e:Re.some(t=>e.startsWith(t))?`-${V(e)}`:V(e),X=async(e,t="",s)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const n=new Set,i=Object.entries(e).map(async([g,r])=>{const p=g.trim(),h=ze(p),N=(P,T=";")=>`${h}:${P}${T}`;if(typeof r=="function"&&(r=r({scope:t,config:s})),r instanceof Promise&&(r=await r),typeof r=="object"){if(!r)return;if(r.isColor)return N(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const F=Object.entries(r);for(const[D,x]of F){if(!x)return;const M=Object.entries(x);for(const[f,y]of M){if(!y)return;const b=`${t}.${D}-${f}`;(await X(y,b,s)).forEach(C=>n.add(C))}}return}if(p==="compoundVariants"){for(const F of r){const{css:D,...x}=F,M=Object.entries(x).reduce((y,[b,u])=>`${y}.${b}-${u}`,t);(await X(D,M,s)).forEach(y=>n.add(y))}return}if(p.startsWith("@")){const F=p,D=await B(r,t,s),x=`${F} { ${D} }`;n.add(x);return}const P=g.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,P,s)).forEach(F=>n.add(F));return}if(typeof r=="number"){const P=Me(h,r);return N(P)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${h}`);return N(r)}),{modifiers:l}={},m=[ye(),Te(l)],c=(await Promise.all(i).then(g=>Promise.all(g.map(r=>m.reduce(async(p,h)=>{const N=await p;if(!N)return N;const _=await h(N);if(!_)return N;const{transformed:P,additionalCss:T}=_;let F="";if(T)for(const D of T)F+=await B(D,"");return`${F}${P}`},Promise.resolve(r)))))).join(`
2
- `);if(!c.trim())return n;const $=t?`${t} { ${c} }`:c;return n.add($),n},B=async(e,t,s)=>[...await X(e,t,s)].join(`
3
- `),ge=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i=="function")console.log("Function found",o);else if(i&&typeof i=="object"){const l=o.trim(),m=await ge(i,[...t,l]);s.push(m)}else n[o]=i;if(Object.keys(n).length){const o=t.map(V).join("-"),i=await B(n,`.${o}`);s.push(i)}return s.join(`
4
- `)},Je=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=he(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},he=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?he(o,i,s):s.add(t)}),[...s]):[],we=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return d.existsSync(t)?t:we(a.join(e,".."))},We=async e=>{const t=we(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ve=async e=>{const t=await We(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await ve(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-BvNnzbqp.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function be(e){return e?typeof e!="string"?be(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 Ae={"*, *::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"}},v=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ie=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),z={externalModules:[],rcFile:void 0,destDir:void 0},Se=e=>{if(z.externalModules.length>0)return z.externalModules;const s=d.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return z.externalModules=n,n},J=async e=>{if(z.destDir)return z.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},je=["salty","css","styles","styled"],Fe=(e=[])=>new RegExp(`\\.(${[...je,...e].join("|")})\\.`),Y=(e,t=[])=>Fe(t).test(e),Ce=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Ce(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ce(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Ze=async e=>{const t=await ce(e),s=await J(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await $e(e),l=Se(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:l});const m=Date.now(),{config:w}=await import(`${o}?t=${m}`);return w},qe=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:j,outputFilePath:R}=await ee(e,S,s);Object.entries(j).forEach(([O,E])=>{E.isMedia?n.mediaQueries.push([O,E]):E.isGlobalDefine?n.globalStyles.push(E):E.isDefineVariables?n.variables.push(E):E.isDefineTemplates&&n.templates.push(E._setPath(R))})}));const o=await Ze(e),i={...o},l=new Set,m=(S,j=[])=>S?Object.entries(S).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return m(O,[...j,R]);const E=be(R),se=V(R),ne=[...j,E].join(".");l.add(`"${ne}"`);const U=[...j.map(V),se].join("-"),ue=Ee(O);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${O};`}):[],w=S=>S?Object.entries(S).flatMap(([j,R])=>{const O=m(R);return j==="base"?O.join(""):`${j} { ${O.join("")} }`}):[],c=S=>S?Object.entries(S).flatMap(([j,R])=>Object.entries(R).flatMap(([O,E])=>{const se=m(E,[j]),ne=`.${j}-${O}, [data-${j}="${O}"]`,U=se.join("");return`${ne} { ${U} }`})):[],$=S=>({...S,responsive:void 0,conditional:void 0}),g=S=>n.variables.map(j=>S==="static"?$(j._current):j._current[S]),r=v($(o.variables),g("static")),p=m(r),h=v((le=o.variables)==null?void 0:le.responsive,g("responsive")),N=w(h),_=v((fe=o.variables)==null?void 0:fe.conditional,g("conditional")),P=c(_),T=a.join(s,"css/_variables.css"),F=`:root { ${p.join("")} ${N.join("")} } ${P.join("")}`;d.writeFileSync(T,F),i.staticVariables=r;const D=a.join(s,"css/_global.css"),x=v(o.global,n.globalStyles),M=await B(x,"");d.writeFileSync(D,`@layer global { ${M} }`);const f=a.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ae,u=await B(b,"");d.writeFileSync(f,`@layer reset { ${u} }`);const C=a.join(s,"css/_templates.css"),k=v(o.templates,n.templates),I=await ge(k),Z=Je(k);d.writeFileSync(C,I),i.templates=k;const q=Ie(n.templates);i.templatePaths=Object.fromEntries(Object.entries(q).map(([S,j])=>[S,j._path||"nope"]));const{mediaQueries:H}=n;i.mediaQueries=Object.fromEntries(H.map(([S,j])=>[`@${S}`,j]));const G=H.map(([S])=>`'@${S}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
5
- // Variable types
6
- type VariableTokens = ${[...l].join("|")};
7
- type PropertyValueToken = \`{\${VariableTokens}}\`;
8
-
9
- // Template types
10
- type TemplateTokens = {
11
- ${Object.entries(Z).map(([S,j])=>`${S}?: ${j}`).join(`
12
- `)}
13
- }
14
-
15
- // Media query types
16
- type MediaQueryKeys = ${G||"''"};
17
- `;d.writeFileSync(te,Q);const Ne=a.join(s,"cache/config-cache.json");d.writeFileSync(Ne,JSON.stringify(i,null,2))},pe=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const l=o.exec(e);if(l){const m=l.at(1);if(je.some(c=>m==null?void 0:m.includes(c)))return t}return"styled('div',"}),He=(e,t)=>{try{const s=d.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
18
-
19
- ${e}`:`globalThis.saltyConfig = {};
20
-
21
- ${e}`}catch{return e}},ee=async(e,t,s)=>{const n=A(t),o=a.join(s,"./temp");d.existsSync(o)||d.mkdirSync(o);const i=a.parse(t);let l=d.readFileSync(t,"utf8");l=pe(l),l=He(l,e);const m=a.join(s,"js",n+".js"),w=await ce(e),c=a.join(e,(w==null?void 0:w.configDir)||"","salty.config.ts"),$=Se(c),g=await $e(e);await me.build({stdin:{contents:l,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:$,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},N=>{const _=d.readFileSync(N.path,"utf8");return{contents:pe(_),loader:"ts"}})}}]});const r=Date.now();return{contents:await import(`${m}?t=${r}`),outputFilePath:m}},Le=async e=>{const t=await J(e),s=a.join(t,"cache/config-cache.json"),n=d.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Le(e),s=await J(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return v(i,t)},xe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=xe(),s=!0)=>{try{const n=Date.now();t?re.info("Generating CSS in production mode! 🔥"):re.info("Generating CSS in development mode! 🚀");const o=[],i=[],l=await J(e),m=a.join(l,"index.css");s&&(()=>{d.existsSync(l)&&ke.execSync("rm -rf "+l),d.mkdirSync(l,{recursive:!0}),d.mkdirSync(a.join(l,"css")),d.mkdirSync(a.join(l,"types")),d.mkdirSync(a.join(l,"js")),d.mkdirSync(a.join(l,"cache"))})();const c=new Set,$=new Set;async function g(f){const y=["node_modules","saltygen"],b=d.statSync(f);if(b.isDirectory()){const u=d.readdirSync(f);if(y.some(k=>f.includes(k)))return;await Promise.all(u.map(k=>g(a.join(f,k))))}else if(b.isFile()&&Y(f)){c.add(f);const C=d.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&$.add(f)}}await g(e),await qe(e,$);const r={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const{contents:y}=await ee(e,f,l);Object.entries(y).forEach(([b,u])=>{u.isKeyframes?r.keyframes.push({value:u,src:f,name:b}):u.isClassName?r.classNames.push({...u,src:f,name:b}):u.generator&&r.components.push({...u,src:f,name:b})})}));const p=await ae(e);for(const f of r.keyframes){const{value:y}=f,b=`a_${y.animationName}.css`,u=`css/${b}`,C=a.join(l,u);o.push(b),d.writeFileSync(C,y.css)}const h={};for(const f of r.components){const{src:y,name:b}=f,u=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[u.priority]||(i[u.priority]=[]),i[u.priority].push(u.cssFileName);const C=`css/${u.cssFileName}`,k=a.join(l,C);d.writeFileSync(k,await u.css),p.importStrategy==="component"&&(h[y]?h[y].push(u.cssFileName):h[y]=[u.cssFileName])}for(const f of r.classNames){const{src:y,name:b}=f,u=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[0].push(u.cssFileName);const C=`css/${u.cssFileName}`,k=a.join(l,C);d.writeFileSync(k,await u.css),p.importStrategy==="component"&&(h[y]?h[y].push(u.cssFileName):h[y]=[u.cssFileName])}p.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const b=y.map(Z=>`@import url('./${Z}');`).join(`
22
- `),u=A(f,6),C=a.parse(f),k=V(C.name),I=a.join(l,`css/f_${k}-${u}.css`);d.writeFileSync(I,b)});const N=o.map(f=>`@import url('./css/${f}');`).join(`
23
- `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
24
-
25
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return d.readFileSync(a.join(l,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
26
- `)}
27
- ${N}`;if(p.importStrategy!=="component"){const f=i.reduce((y,b,u)=>{const C=b.reduce((q,H)=>{var Q;const G=a.join(l,"css",H),te=d.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:Q.at(1))||A(G,6);return q.includes(K)?q:`${q}
28
- /*start:${K}*/
29
- ${te}
30
- /*end:${K}*/
31
- `},""),k=`l_${u}.css`,I=a.join(l,"css",k),Z=`@layer l${u} { ${C}
32
- }`;return d.writeFileSync(I,Z),`${y}
33
- @import url('./css/${k}');`},"");F+=f}d.writeFileSync(m,F);const x=Date.now()-n,M=x<200?"🔥":x<500?"🚀":x<1e3?"🎉":x<2e3?"🚗":x<5e3?"🤔":"🥴";re.info(`Generated CSS in ${x}ms! ${M}`)}catch(n){console.error(n)}},Ge=async(e,t)=>{try{const s=await J(e);if(Y(t)){const o=[],i=await ae(e),{contents:l}=await ee(e,t,s);for(const[m,w]of Object.entries(l)){if(w.isKeyframes&&w.css){const p=`css/${`a_${w.animationName}.css`}`,h=a.join(s,p);d.writeFileSync(h,await w.css);return}if(w.isClassName){const r=w.factory._withBuildContext({name:m});o[0].push(r.cssFileName);const p=`css/${r.cssFileName}`,h=a.join(s,p);d.writeFileSync(h,await r.css)}if(!w.generator)return;const c=w.generator._withBuildContext({name:m,config:i}),$=`css/${c.cssFileName}`,g=a.join(s,$);d.writeFileSync(g,await c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}if(i.importStrategy!=="component")o.forEach((m,w)=>{const c=`l_${w}.css`,$=a.join(s,"css",c);let g=d.readFileSync($,"utf8");m.forEach(r=>{var _;const p=a.join(s,"css",r),h=((_=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:_.at(1))||A(p,6);if(!g.includes(h)){const P=d.readFileSync(p,"utf8"),T=`/*start:${h}*/
34
- ${P}
35
- /*end:${h}*/
36
- `;g=`${g.replace(/\}$/,"")}
37
- ${T}
38
- }`}}),d.writeFileSync($,g)});else{const m=o.flat().map(r=>`@import url('./${r}');`).join(`
39
- `),w=A(t,6),c=a.parse(t),$=V(c.name),g=a.join(s,`css/f_${$}-${w}.css`);d.writeFileSync(g,m)}}}catch(s){console.error(s)}},Ke=async(e,t,s=xe())=>{try{const n=await J(e);if(Y(t)){const i=d.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,$=>`export ${$}`)!==i&&await ie.writeFile(t,i);const m=await ae(e),{contents:w}=await ee(e,t,n);let c=i;if(Object.entries(w).forEach(([$,g])=>{var u;if(g.isKeyframes||!g.generator)return;const r=g.generator._withBuildContext({name:$,config:m,prod:s}),p=new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!p)return console.error("Could not find the original declaration");const h=(u=p.at(1))==null?void 0:u.trim(),N=new RegExp(`\\s${$}[=\\s]+styled\\(`,"g").exec(c);if(!N)return console.error("Could not find the original declaration");const{index:_}=N;let P=!1;const T=setTimeout(()=>P=!0,5e3);let F=0,D=!1,x=0;for(;!D&&!P;){const C=c[_+F];C==="("&&x++,C===")"&&x--,x===0&&C===")"&&(D=!0),F>c.length&&(P=!0),F++}if(!P)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const M=_+F,f=c.slice(_,M),y=c,b=` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;c=c.replace(f,b),y===c&&console.error("Minimize file failed to change content",{name:$,tagName:h})}),m.importStrategy==="component"){const $=A(t,6),g=a.parse(t);c=`import '../../saltygen/css/${`f_${V(g.name)}-${$}.css`}';
40
- ${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Fe;