@salty-css/webpack 0.0.1-alpha.207 → 0.0.1-alpha.209

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.
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-C2eoLLSc.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-BG0kLkBd.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-CSE05P-J.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-B3z-tgrO.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-C2eoLLSc.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-BG0kLkBd.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-CSE05P-J.js";
1
+ import { a as e, m as i } from "./index-B3z-tgrO.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.207",
3
+ "version": "0.0.1-alpha.209",
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.207",
37
+ "@salty-css/core": "^0.0.1-alpha.209",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }
@@ -1,40 +0,0 @@
1
- "use strict";const xe=require("esbuild"),ke=require("child_process"),a=require("path"),d=require("fs"),re=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 ye=_e(xe),pe=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=pe(n%52)+s;return s=pe(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},W=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(s,t)};function M(e){return e?typeof e!="string"?M(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const Te=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:c}=o;s=s.replace(i,h=>{const{value:F,css:l}=c(h);return l&&n.push(l),F})}),{transformed:s,additionalCss:n}},ge=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${M(o[1].replaceAll(".","-"))})`)},Ee=ge(),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))?`-${M(e)}`:M(e),X=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,c=Object.entries(e).map(async([y,r])=>{const p=y.trim(),b=ze(p),C=(O,_=";")=>`${b}:${O}${_}`;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 C(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const D=Object.entries(r);for(const[P,E]of D){if(!E)return;const f=Object.entries(E);for(const[w,g]of f){if(!g)return;const u=`${t}.${P}-${w}`;(await X(g,u,s)).forEach(x=>o.add(x))}}return}if(p==="compoundVariants"){for(const D of r){const{css:P,...E}=D,f=Object.entries(E).reduce((g,[u,S])=>`${g}.${u}-${S}`,t);(await X(P,f,s)).forEach(g=>o.add(g))}return}if(p.startsWith("@")){const D=p,P=await B(r,t,s),E=`${D} { ${P} }`;o.add(E);return}const O=y.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,O,s)).forEach(D=>o.add(D));return}if(typeof r=="number"){const O=Me(b,r);return C(O)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${b}`);return C(r)}),{modifiers:h}={},F=[ge(),Te(h)],m=(await Promise.all(c).then(y=>Promise.all(y.map(r=>F.reduce(async(p,b)=>{const C=await p;if(!C)return C;const k=await b(C);if(!k)return C;const{transformed:O,additionalCss:_}=k;let D="";if(_)for(const P of _)D+=await B(P,"");return`${D}${O}`},Promise.resolve(r)))))).join(`
2
- `);if(!m.trim())return o;const $=t?`${t} { ${m} }`:m;return o.add($),o},B=async(e,t,s,n=!1)=>[...await X(e,t,s,n)].join(`
3
- `),he=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 c=o.trim(),h=await he(i,[...t,c]);s.push(h)}else n[o]=i;if(Object.keys(n).length){const o=t.map(M).join("-"),i="t_"+W(o,4),c=await B(n,`.${o}, .${i}`);s.push(c)}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]=we(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},we=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?we(o,i,s):s.add(t)}),[...s]):[],$e=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:$e(a.join(e,".."))},We=async e=>{const t=$e(e);return await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ae=async e=>{const t=await We(e);if(t)return t.type};let I;const be=async e=>{if(I)return I;const t=await Ae(e);return t==="module"?I="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-C2eoLLSc.cjs",document.baseURI).href).endsWith(".cjs"))&&(I="cjs"),I||"esm"},ie=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function Se(e){return e?typeof e!="string"?Se(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"}},Z=(...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}),{}),J={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(J.externalModules.length>0)return J.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 J.externalModules=n,n},A=async e=>{if(J.destDir)return J.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return J.destDir=s,s},Fe=["salty","css","styles","styled"],Ce=(e=[])=>new RegExp(`\\.(${[...Fe,...e].join("|")})\\.`),Y=(e,t=[])=>Ce(t).test(e),Ne=async e=>{if(J.rcFile)return J.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(J.rcFile=s,s):Ne(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ne(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 A(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await be(e),c=je(n);await ye.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:c});const h=Date.now(),{config:F}=await import(`${o}?t=${h}`);return F},qe=async(e,t)=>{var fe,ue;const s=await A(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async j=>{const{contents:N,outputFilePath:z}=await ee(e,j,s);Object.entries(N).forEach(([T,V])=>{V.isMedia?n.mediaQueries.push([T,V]):V.isGlobalDefine?n.globalStyles.push(V):V.isDefineVariables?n.variables.push(V):V.isDefineTemplates&&n.templates.push(V._setPath(z))})}));const o=await Ze(e),i={...o},c=new Set,h=(j,N=[])=>j?Object.entries(j).flatMap(([z,T])=>{if(!T)return;if(typeof T=="object")return h(T,[...N,z]);const V=Se(z),se=M(z),ne=[...N,V].join(".");c.add(`"${ne}"`);const U=[...N.map(M),se].join("-"),de=Ee(T);return de?`--${U}: ${de.transformed};`:`--${U}: ${T};`}):[],F=j=>j?Object.entries(j).flatMap(([N,z])=>{const T=h(z);return N==="base"?T.join(""):`${N} { ${T.join("")} }`}):[],l=j=>j?Object.entries(j).flatMap(([N,z])=>Object.entries(z).flatMap(([T,V])=>{const se=h(V,[N]),ne=`.${N}-${T}, [data-${N}="${T}"]`,U=se.join("");return`${ne} { ${U} }`})):[],m=j=>({...j,responsive:void 0,conditional:void 0}),$=j=>n.variables.map(N=>j==="static"?m(N._current):N._current[j]),y=Z(m(o.variables),$("static")),r=h(y),p=Z((fe=o.variables)==null?void 0:fe.responsive,$("responsive")),b=F(p),C=Z((ue=o.variables)==null?void 0:ue.conditional,$("conditional")),k=l(C),O=a.join(s,"css/_variables.css"),_=`:root { ${r.join("")} ${b.join("")} } ${k.join("")}`;d.writeFileSync(O,_),i.staticVariables=y;const D=a.join(s,"css/_global.css"),P=Z(o.global,n.globalStyles),E=await B(P,"");d.writeFileSync(D,`@layer global { ${E} }`);const f=a.join(s,"css/_reset.css"),g=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ve,u=await B(g,"");d.writeFileSync(f,`@layer reset { ${u} }`);const S=a.join(s,"css/_templates.css"),x=Z(o.templates,n.templates),R=await he(x),q=Je(x);d.writeFileSync(S,`@layer templates { ${R} }`),i.templates=x;const H=Ie(n.templates);i.templatePaths=Object.fromEntries(Object.entries(H).map(([j,N])=>[j,N._path]));const{mediaQueries:v}=n;i.mediaQueries=Object.fromEntries(v.map(([j,N])=>[`@${j}`,N]));const G=v.map(([j])=>`'@${j}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
5
- // Variable types
6
- type VariableTokens = ${[...c].join("|")};
7
- type PropertyValueToken = \`{\${VariableTokens}}\`;
8
-
9
- // Template types
10
- type TemplateTokens = {
11
- ${Object.entries(q).map(([j,N])=>`${j}?: ${N}`).join(`
12
- `)}
13
- }
14
-
15
- // Media query types
16
- type MediaQueryKeys = ${G||"''"};
17
- `;d.writeFileSync(te,Q);const Pe=a.join(s,"cache/config-cache.json");d.writeFileSync(Pe,JSON.stringify(i,null,2))},me=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 c=o.exec(e);if(c){const h=c.at(1);if(Fe.some(l=>h==null?void 0:h.includes(l)))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=W(t),o=a.join(s,"./temp");d.existsSync(o)||d.mkdirSync(o);const i=a.parse(t);let c=d.readFileSync(t,"utf8");c=me(c),c=He(c,e);const h=a.join(s,"js",n+".js"),F=await ce(e),l=a.join(e,(F==null?void 0:F.configDir)||"","salty.config.ts"),m=je(l),$=await be(e);await ye.build({stdin:{contents:c,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:h,format:$,target:["node20"],keepNames:!0,external:m,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},b=>{const C=d.readFileSync(b.path,"utf8");return{contents:me(C),loader:"ts"}})}}]});const y=Date.now();return{contents:await import(`${h}?t=${y}`),outputFilePath:h}},Le=async e=>{const t=await A(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 A(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return Z(i,t)},le=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=le(),s=!0)=>{try{const n=Date.now();t?ie.info("Generating CSS in production mode! 🔥"):ie.info("Generating CSS in development mode! 🚀");const o=[],i=[],c=await A(e),h=a.join(c,"index.css");s&&(()=>{d.existsSync(c)&&ke.execSync("rm -rf "+c),d.mkdirSync(c,{recursive:!0}),d.mkdirSync(a.join(c,"css")),d.mkdirSync(a.join(c,"types")),d.mkdirSync(a.join(c,"js")),d.mkdirSync(a.join(c,"cache"))})();const l=new Set,m=new Set;async function $(f){const w=["node_modules","saltygen"],g=d.statSync(f);if(g.isDirectory()){const u=d.readdirSync(f);if(w.some(x=>f.includes(x)))return;await Promise.all(u.map(x=>$(a.join(f,x))))}else if(g.isFile()&&Y(f)){l.add(f);const S=d.readFileSync(f,"utf8");/define[\w\d]+\(/.test(S)&&m.add(f)}}await $(e),await qe(e,m);const y={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async f=>{const{contents:w}=await ee(e,f,c);Object.entries(w).forEach(([g,u])=>{u.isKeyframes?y.keyframes.push({value:u,src:f,name:g}):u.isClassName?y.classNames.push({...u,src:f,name:g}):u.generator&&y.components.push({...u,src:f,name:g})})}));const r=await ae(e);for(const f of y.keyframes){const{value:w}=f,g=`a_${w.animationName}.css`,u=`css/${g}`,S=a.join(c,u);o.push(g),d.writeFileSync(S,w.css)}const p={};for(const f of y.components){const{src:w,name:g}=f,u=f.generator._withBuildContext({callerName:g,isProduction:t,config:r});i[u.priority]||(i[u.priority]=[]);const S=await u.css;if(!S)continue;i[u.priority].push(u.cssFileName);const x=`css/${u.cssFileName}`,R=a.join(c,x);d.writeFileSync(R,S),r.importStrategy==="component"&&(p[w]?p[w].push(u.cssFileName):p[w]=[u.cssFileName])}for(const f of y.classNames){const{src:w,name:g}=f,u=f.generator._withBuildContext({callerName:g,isProduction:t,config:r}),S=await u.css;if(!S)continue;i[0].push(u.cssFileName);const x=`css/${u.cssFileName}`,R=a.join(c,x);d.writeFileSync(R,S),r.importStrategy==="component"&&(p[w]?p[w].push(u.cssFileName):p[w]=[u.cssFileName])}r.importStrategy==="component"&&Object.entries(p).forEach(([f,w])=>{const g=w.map(q=>`@import url('./${q}');`).join(`
22
- `),u=W(f,6),S=a.parse(f),x=M(S.name),R=a.join(c,`css/f_${x}-${u}.css`);d.writeFileSync(R,g)});const b=o.map(f=>`@import url('./css/${f}');`).join(`
23
- `);let _=`@layer reset, global, templates, 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(c,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
26
- `)}
27
- ${b}`;if(r.importStrategy!=="component"){const f=i.reduce((w,g,u)=>{const S=g.reduce((H,v)=>{var Q;const G=a.join(c,"css",v),te=d.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(v))==null?void 0:Q.at(1))||W(G,6);return H.includes(K)?H:`${H}
28
- /*start:${K}-${v}*/
29
- ${te}
30
- /*end:${K}*/
31
- `},""),x=`l_${u}.css`,R=a.join(c,"css",x),q=`@layer l${u} { ${S}
32
- }`;return d.writeFileSync(R,q),`${w}
33
- @import url('./css/${x}');`},"");_+=f}d.writeFileSync(h,_);const P=Date.now()-n,E=P<200?"🔥":P<500?"🚀":P<1e3?"🎉":P<2e3?"🚗":P<5e3?"🤔":"🥴";ie.info(`Generated CSS in ${P}ms! ${E}`)}catch(n){console.error(n)}},Ge=async(e,t,s=le())=>{try{const n=await A(e);if(Y(t)){const i=[],c=await ae(e),{contents:h}=await ee(e,t,n);for(const[F,l]of Object.entries(h)){if(l.isKeyframes&&l.css){const b=`css/${`a_${l.animationName}.css`}`,C=a.join(n,b);d.writeFileSync(C,await l.css);return}if(l.isClassName){const p=l.generator._withBuildContext({callerName:F,isProduction:s,config:c}),b=await p.css;if(!b)continue;i[0].push(p.cssFileName);const C=`css/${p.cssFileName}`,k=a.join(n,C);d.writeFileSync(k,b)}if(!l.generator)return;const m=l.generator._withBuildContext({callerName:F,isProduction:s,config:c}),$=await m.css;if(!$)continue;const y=`css/${m.cssFileName}`,r=a.join(n,y);d.writeFileSync(r,$),i[m.priority]||(i[m.priority]=[]),i[m.priority].push(m.cssFileName)}if(c.importStrategy!=="component")i.forEach((F,l)=>{const m=`l_${l}.css`,$=a.join(n,"css",m);let y=d.readFileSync($,"utf8");F.forEach(r=>{var k;const p=a.join(n,"css",r),b=((k=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:k.at(1))||W(p,6);if(!y.includes(b)){const O=d.readFileSync(p,"utf8"),_=`/*start:${b}-${r}*/
34
- ${O}
35
- /*end:${b}*/
36
- `;y=`${y.replace(/\}$/,"")}
37
- ${_}
38
- }`}}),d.writeFileSync($,y)});else{const F=i.flat().map(r=>`@import url('./${r}');`).join(`
39
- `),l=W(t,6),m=a.parse(t),$=M(m.name),y=a.join(n,`css/f_${$}-${l}.css`);d.writeFileSync(y,F)}}}catch(n){console.error(n)}},Ke=async(e,t,s=le())=>{try{const n=await A(e);if(Y(t)){const i=d.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,m=>`export ${m}`)!==i&&await re.writeFile(t,i);const h=await ae(e),{contents:F}=await ee(e,t,n);let l=i;if(Object.entries(F).forEach(([m,$])=>{var u;if($.isKeyframes||!$.generator)return;const y=$.generator._withBuildContext({callerName:m,isProduction:s,config:h}),r=new RegExp(`\\s${m}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!r)return console.error("Could not find the original declaration");const p=(u=r.at(1))==null?void 0:u.trim(),b=new RegExp(`\\s${m}[=\\s]+styled\\(`,"g").exec(l);if(!b)return console.error("Could not find the original declaration");const{index:C}=b;let k=!1;const O=setTimeout(()=>k=!0,5e3);let _=0,D=!1,P=0;for(;!D&&!k;){const S=l[C+_];S==="("&&P++,S===")"&&P--,P===0&&S===")"&&(D=!0),_>l.length&&(k=!0),_++}if(!k)clearTimeout(O);else throw new Error("Failed to find the end of the styled call and timed out");const E=C+_,f=l.slice(C,E),w=l,g=` ${m} = styled(${p}, "${y.classNames}", ${JSON.stringify(y.clientProps)});`;l=l.replace(f,g),w===l&&console.error("Minimize file failed to change content",{name:m,tagName:p})}),h.importStrategy==="component"){const m=W(t,6),$=a.parse(t);l=`import '../../saltygen/css/${`f_${M($.name)}-${m}.css`}';
40
- ${l}`}return l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Ce;