@salty-css/webpack 0.0.1-alpha.206 → 0.0.1-alpha.208

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