@salty-css/webpack 0.0.1-alpha.226 → 0.0.1-alpha.228

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-DHuI5JGu.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 i,n,u;(n=(i=e.module)==null?void 0:i.rules)==null||n.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(u=e.plugins)==null||u.push({apply:f=>{let o=!1;f.hooks.beforeCompile.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-CQi9eOGj.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 r=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(r)},c=(e,s,l=!1,r=!1)=>{var i,u,n;(u=(i=e.module)==null?void 0:i.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,r?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(n=e.plugins)==null||n.push({apply:f=>{let o=!1;f.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(q,a)=>{await p(a)?await t.generateCss(s,!1,!1):t.isSaltyFile(a)&&await t.generateFile(s,a)}))})}})};exports.default=c;exports.saltyPlugin=c;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as p } from "path";
2
- import { i as f, s as d, g as u, a as y } from "./index-DimebhYU.js";
2
+ import { i as f, s as d, g as u, a as y } from "./index-DjGfC538.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-DHuI5JGu.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-CQi9eOGj.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-DimebhYU.js";
1
+ import { a as e, m as i } from "./index-DjGfC538.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.226",
3
+ "version": "0.0.1-alpha.228",
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.226",
37
+ "@salty-css/core": "^0.0.1-alpha.228",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }
@@ -1,42 +0,0 @@
1
- "use strict";var kt=Object.defineProperty;var Dt=(e,t,s)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Y=(e,t,s)=>Dt(e,typeof t!="symbol"?t+"":t,s);const Tt=require("esbuild"),Et=require("child_process"),f=require("path"),d=require("fs"),at=require("fs/promises"),B=require("winston");var rt=typeof document<"u"?document.currentScript:null;function Ot(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 ht=Ot(Tt),mt=e=>String.fromCharCode(e+(e>25?39:97)),Vt=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=mt(n%52)+s;return s=mt(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Mt=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},J=(e,t=5)=>{const s=Mt(5381,JSON.stringify(e))>>>0;return Vt(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 Rt=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:i}=o;s=s.replace(r,$=>{const{value:b,css:l}=i($);return l&&n.push(l),b})}),{transformed:s,additionalCss:n}},gt=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${R(o[1].replaceAll(".","-"))})`)},vt=gt(),zt=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],At=(e,t,s)=>zt.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Jt=["Webkit","Moz","ms","O"],Wt=e=>e.startsWith("-")?e:Jt.some(t=>e.startsWith(t))?`-${R(e)}`:R(e),tt=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,r=Object.entries(e),i=async([p,u])=>{const w=p.trim(),x=Wt(w),T=(V,_=";")=>`${x}:${V}${_}`,k={scope:t,config:s};if(typeof u=="function")return i([p,u(k)]);if(u instanceof Promise)return i([p,await u]);if(typeof u=="object"){if(!u)return;if(u.isColor)return T(u.toString());if(w==="defaultVariants")return;if(w==="variants"){const D=Object.entries(u);for(const[a,m]of D){if(!m)return;const j=Object.entries(m);for(const[c,g]of j){if(!g)return;const N=`${t}.${a}-${c}`;(await tt(g,N,s)).forEach(A=>o.add(A))}}return}if(w==="compoundVariants"){for(const D of u){const{css:a,...m}=D,j=Object.entries(m).reduce((g,[N,E])=>`${g}.${N}-${E}`,t);(await tt(a,j,s)).forEach(g=>o.add(g))}return}if(w.startsWith("@")){const D=w,a=await G(u,t,s),m=`${D} { ${a} }`;o.add(m);return}const V=p.includes("&")?w.replace("&",t):w.startsWith(":")?`${t}${w}`:`${t} ${w}`;(await tt(u,V,s)).forEach(D=>o.add(D));return}if(typeof u=="number"){const V=At(x,u);return T(V)}if(typeof u!="string")if("toString"in u)u=u.toString();else throw new Error(`Invalid value type for property ${x}`);return T(u)},$=r.map(i),{modifiers:b}={},l=[gt(),Rt(b)],S=(await Promise.all($).then(p=>Promise.all(p.map(u=>l.reduce(async(w,x)=>{const T=await w;if(!T)return T;const k=await x(T);if(!k)return T;const{transformed:V,additionalCss:_}=k;let D="";if(_)for(const a of _)D+=await G(a,"");return`${D}${V}`},Promise.resolve(u)))))).filter(p=>p!==void 0).join(`
2
- `);if(!S.trim())return Array.from(o);const h=t?`${t} {
3
- ${S}
4
- }`:S;return o.has(h)?Array.from(o):[h,...o]},G=async(e,t,s,n=!1)=>(await tt(e,t,s,n)).join(`
5
- `),wt=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,r]of Object.entries(e))if(typeof r!="function")if(r&&typeof r=="object"){const i=o.trim(),$=await wt(r,[...t,i]);s.push($)}else n[o]=r;if(Object.keys(n).length){const o=t.map(R).join("-"),r="t_"+J(o,4),i=await G(n,`.${o}, .${r}`);s.push(i)}return s.join(`
6
- `)},It=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=$t(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},$t=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?$t(o,r,s):s.add(t)}),[...s]):[],bt=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=f.join(e,"package.json");return d.existsSync(t)?t:bt(f.join(e,".."))},Zt=async e=>{const t=bt(e);return await at.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},qt=async e=>{const t=await Zt(e);if(t)return t.type};let I;const St=async e=>{if(I)return I;const t=await qt(e);return t==="module"?I="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:rt&&rt.tagName.toUpperCase()==="SCRIPT"&&rt.src||new URL("index-DHuI5JGu.cjs",document.baseURI).href).endsWith(".cjs"))&&(I="cjs"),I||"esm"},it=B.createLogger({level:"debug",format:B.format.combine(B.format.colorize(),B.format.cli()),transports:[new B.transports.Console({})]});function jt(e){return e?typeof e!="string"?jt(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 Ht={"*, *::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},{}),Lt=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{});class Bt{constructor(t){Y(this,"_path");this.params=t}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(t){return this._path=t,this}}class Gt{constructor(t){Y(this,"_path");Y(this,"templates",[]);this.params=t,Object.entries(t).forEach(([s,n])=>{this.templates.push(new Bt({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(t=>[t.params.name,t]))}get isDefineTemplates(){return!0}_setPath(t){return this._path=t,this.templates.forEach(s=>s._setPath(t)),this}}const Kt=e=>new Gt(e),z={externalModules:[],rcFile:void 0,destDir:void 0},Ft=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},W=async e=>{if(z.destDir)return z.destDir;const t=await ct(e),s=f.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},Ct=["salty","css","styles","styled"],Pt=(e=[])=>new RegExp(`\\.(${[...Ct,...e].join("|")})\\.`),et=(e,t=[])=>Pt(t).test(e),xt=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=f.join(e,".saltyrc.json"),s=await at.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):xt(f.join(e,".."))},ct=async e=>{var n,o;const t=await xt(e),s=(n=t.projects)==null?void 0:n.find(r=>e.endsWith(r.dir||""));return s||((o=t.projects)==null?void 0:o.find(r=>r.dir===t.defaultProject))},Qt=async e=>{const t=await ct(e),s=await W(e),n=f.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=f.join(s,"salty.config.js"),r=await St(e),i=Ft(n);await ht.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:i});const $=Date.now(),{config:b}=await import(`${o}?t=${$}`);return{config:b,path:o}},Ut=async(e,t)=>{var ut,dt;const s=await W(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async C=>{const{contents:P,outputFilePath:v}=await st(e,C,s);Object.entries(P).forEach(([O,M])=>{M.isMedia?n.mediaQueries.push([O,M]):M.isGlobalDefine?n.globalStyles.push(M):M.isDefineVariables?n.variables.push(M):M.isDefineTemplates&&n.templates.push(M._setPath(`${O};;${v}`))})}));const{config:o,path:r}=await Qt(e),i={...o},$=new Set,b=(C,P=[])=>C?Object.entries(C).flatMap(([v,O])=>{if(!O)return;if(typeof O=="object")return b(O,[...P,v]);const M=jt(v),nt=R(v),ot=[...P,M].join(".");$.add(`"${ot}"`);const X=[...P.map(R),nt].join("-"),pt=vt(O);return pt?`--${X}: ${pt.transformed};`:`--${X}: ${O};`}):[],l=C=>C?Object.entries(C).flatMap(([P,v])=>{const O=b(v);return P==="base"?O.join(""):`${P} { ${O.join("")} }`}):[],y=C=>C?Object.entries(C).flatMap(([P,v])=>Object.entries(v).flatMap(([O,M])=>{const nt=b(M,[P]),ot=`.${P}-${O}, [data-${P}="${O}"]`,X=nt.join("");return`${ot} { ${X} }`})):[],S=C=>({...C,responsive:void 0,conditional:void 0}),h=C=>n.variables.map(P=>C==="static"?S(P._current):P._current[C]),F=Z(S(o.variables),h("static")),p=b(F),u=Z((ut=o.variables)==null?void 0:ut.responsive,h("responsive")),w=l(u),x=Z((dt=o.variables)==null?void 0:dt.conditional,h("conditional")),T=y(x),k=f.join(s,"css/_variables.css"),V=`:root { ${p.join("")} ${w.join("")} } ${T.join("")}`;d.writeFileSync(k,V),i.staticVariables=F;const _=f.join(s,"css/_global.css"),D=Z(o.global,n.globalStyles),a=await G(D,"");d.writeFileSync(_,`@layer global { ${a} }`);const m=f.join(s,"css/_reset.css"),c=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ht,g=await G(c,"");d.writeFileSync(m,`@layer reset { ${g} }`);const N=f.join(s,"css/_templates.css"),E=Z(o.templates,n.templates),A=await wt(E),q=It(E);d.writeFileSync(N,`@layer templates { ${A} }`),i.templates=E;const H=o.templates?[Kt(o.templates)._setPath(`config;;${r}`)]:[],K=Lt(n.templates,H);i.templatePaths=Object.fromEntries(Object.entries(K).map(([C,P])=>[C,P._path]));const{mediaQueries:Q}=n;i.mediaQueries=Object.fromEntries(Q.map(([C,P])=>[`@${C}`,P]));const L=Q.map(([C])=>`'@${C}'`).join(" | "),U=f.join(s,"types/css-tokens.d.ts"),Nt=`
7
- // Variable types
8
- type VariableTokens = ${[...$].join("|")};
9
- type PropertyValueToken = \`{\${VariableTokens}}\`;
10
-
11
- // Template types
12
- type TemplateTokens = {
13
- ${Object.entries(q).map(([C,P])=>`${C}?: ${P}`).join(`
14
- `)}
15
- }
16
-
17
- // Media query types
18
- type MediaQueryKeys = ${L||"''"};
19
- `;d.writeFileSync(U,Nt);const _t=f.join(s,"cache/config-cache.json");d.writeFileSync(_t,JSON.stringify(i,null,2))},yt=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 i=o.exec(e);if(i){const $=i.at(1);if(Ct.some(l=>$==null?void 0:$.includes(l)))return t}return"styled('div',"}),Xt=(e,t)=>{try{const s=d.readFileSync(f.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
20
-
21
- ${e}`:`globalThis.saltyConfig = {};
22
-
23
- ${e}`}catch{return e}},st=async(e,t,s)=>{const n=J(t),o=f.join(s,"./temp");d.existsSync(o)||d.mkdirSync(o);const r=f.parse(t);let i=d.readFileSync(t,"utf8");i=yt(i),i=Xt(i,e);const $=f.join(s,"js",n+".js"),b=await ct(e),l=f.join(e,(b==null?void 0:b.configDir)||"","salty.config.ts"),y=Ft(l),S=await St(e);await ht.build({stdin:{contents:i,sourcefile:r.base,resolveDir:r.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:$,format:S,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},u=>{const w=d.readFileSync(u.path,"utf8");return{contents:yt(w),loader:"ts"}})}}]});const h=Date.now();return{contents:await import(`${$}?t=${h}`),outputFilePath:$}},Yt=async e=>{const t=await W(e),s=f.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)},lt=async e=>{const t=await Yt(e),s=await W(e),n=f.join(s,"salty.config.js"),o=Date.now(),{config:r}=await import(`${n}?t=${o}`);return Z(r,t)},ft=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},te=async(e,t=ft(),s=!0)=>{try{const n=Date.now();t?it.info("Generating CSS in production mode! 🔥"):it.info("Generating CSS in development mode! 🚀");const o=[],r=[],i=await W(e),$=f.join(i,"index.css");s&&(()=>{d.existsSync(i)&&Et.execSync("rm -rf "+i),d.mkdirSync(i,{recursive:!0}),d.mkdirSync(f.join(i,"css")),d.mkdirSync(f.join(i,"types")),d.mkdirSync(f.join(i,"js")),d.mkdirSync(f.join(i,"cache"))})();const l=new Set,y=new Set;async function S(a){const m=["node_modules","saltygen"],j=d.statSync(a);if(j.isDirectory()){const c=d.readdirSync(a);if(m.some(N=>a.includes(N)))return;await Promise.all(c.map(N=>S(f.join(a,N))))}else if(j.isFile()&&et(a)){l.add(a);const g=d.readFileSync(a,"utf8");/define[\w\d]+\(/.test(g)&&y.add(a)}}await S(e),await Ut(e,y);const h={keyframes:[],components:[],classNames:[]};await Promise.all([...l].map(async a=>{const{contents:m}=await st(e,a,i);for(let[j,c]of Object.entries(m))c instanceof Promise&&(c=await c),c.isKeyframes?h.keyframes.push({value:c,src:a,name:j}):c.isClassName?h.classNames.push({...c,src:a,name:j}):c.generator&&h.components.push({...c,src:a,name:j})}));const F=await lt(e);for(const a of h.keyframes){const{value:m}=a,j=`a_${m.animationName}.css`,c=`css/${j}`,g=f.join(i,c);o.push(j),d.writeFileSync(g,m.css)}const p={};for(const a of h.components){const{src:m,name:j}=a;p[m]||(p[m]=[]);const c=a.generator._withBuildContext({callerName:j,isProduction:t,config:F});r[c.priority]||(r[c.priority]=[]);const g=await c.css;if(!g)continue;r[c.priority].push(c.cssFileName);const N=`css/${c.cssFileName}`,E=f.join(i,N);d.writeFileSync(E,g),F.importStrategy==="component"&&p[m].push(c.cssFileName)}for(const a of h.classNames){const{src:m,name:j}=a;p[m]||(p[m]=[]);const c=a.generator._withBuildContext({callerName:j,isProduction:t,config:F}),g=await c.css;if(!g)continue;r[c.priority]||(r[c.priority]=[]),r[c.priority].push(c.cssFileName);const N=`css/${c.cssFileName}`,E=f.join(i,N);d.writeFileSync(E,g),F.importStrategy==="component"&&p[m].push(c.cssFileName)}F.importStrategy==="component"&&Object.entries(p).forEach(([a,m])=>{const j=m.map(A=>`@import url('./${A}');`).join(`
24
- `),c=J(a,6),g=f.parse(a),N=R(g.name),E=f.join(i,`css/f_${N}-${c}.css`);d.writeFileSync(E,j||"/* Empty file */")});const u=o.map(a=>`@import url('./css/${a}');`).join(`
25
- `);let k=`@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
26
-
27
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(a=>{try{return d.readFileSync(f.join(i,"css",a),"utf8").length>0}catch{return!1}}).map(a=>`@import url('./css/${a}');`).join(`
28
- `)}
29
- ${u}`;if(F.importStrategy!=="component"){const a=r.reduce((m,j,c)=>{const g=j.reduce((q,H)=>{var U;const K=f.join(i,"css",H),Q=d.readFileSync(K,"utf8"),L=((U=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:U.at(1))||J(K,6);return q.includes(L)?q:`${q}
30
- /*start:${L}-${H}*/
31
- ${Q}
32
- /*end:${L}*/
33
- `},""),N=`l_${c}.css`,E=f.join(i,"css",N),A=`@layer l${c} { ${g}
34
- }`;return d.writeFileSync(E,A),`${m}
35
- @import url('./css/${N}');`},"");k+=a}d.writeFileSync($,k);const _=Date.now()-n,D=_<200?"🔥":_<500?"🚀":_<1e3?"🎉":_<2e3?"🚗":_<5e3?"🤔":"🥴";it.info(`Generated CSS in ${_}ms! ${D}`)}catch(n){console.error(n)}},ee=async(e,t,s=ft())=>{try{const n=await W(e);if(et(t)){const r=[],i=await lt(e),{contents:$}=await st(e,t,n);for(const[b,l]of Object.entries($)){if(l.isKeyframes&&l.css){const u=`css/${`a_${l.animationName}.css`}`,w=f.join(n,u);d.writeFileSync(w,await l.css);return}if(l.isClassName){const p=l.generator._withBuildContext({callerName:b,isProduction:s,config:i}),u=await p.css;if(!u)continue;r[p.priority]||(r[p.priority]=[]),r[p.priority].push(p.cssFileName);const w=`css/${p.cssFileName}`,x=f.join(n,w);d.writeFileSync(x,u)}if(!l.generator)return;const y=l.generator._withBuildContext({callerName:b,isProduction:s,config:i}),S=await y.css;if(!S)continue;const h=`css/${y.cssFileName}`,F=f.join(n,h);d.writeFileSync(F,S),r[y.priority]||(r[y.priority]=[]),r[y.priority].push(y.cssFileName)}if(i.importStrategy!=="component")r.forEach((b,l)=>{const y=`l_${l}.css`,S=f.join(n,"css",y);let h=d.readFileSync(S,"utf8");b.forEach(F=>{var x;const p=f.join(n,"css",F),u=((x=/.*-([^-]+)-\d+.css/.exec(F))==null?void 0:x.at(1))||J(p,6);if(!h.includes(u)){const T=d.readFileSync(p,"utf8"),k=`/*start:${u}-${F}*/
36
- ${T}
37
- /*end:${u}*/
38
- `;h=`${h.replace(/\}$/,"")}
39
- ${k}
40
- }`}}),d.writeFileSync(S,h)});else{const b=r.flat().map(F=>`@import url('./${F}');`).join(`
41
- `),l=J(t,6),y=f.parse(t),S=R(y.name),h=f.join(n,`css/f_${S}-${l}.css`);d.writeFileSync(h,b||"/* Empty file */")}}}catch(n){console.error(n)}},se=async(e,t,s=ft())=>{try{const n=await W(e);if(et(t)){const r=d.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==r&&await at.writeFile(t,r);const $=await lt(e),{contents:b}=await st(e,t,n);let l=r;if(Object.entries(b).forEach(([y,S])=>{var c;if(S.isKeyframes||!S.generator)return;const h=S.generator._withBuildContext({callerName:y,isProduction:s,config:$}),F=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!F)return console.error("Could not find the original declaration");const p=(c=F.at(1))==null?void 0:c.trim(),u=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(l);if(!u)return console.error("Could not find the original declaration");const{index:w}=u;let x=!1;const T=setTimeout(()=>x=!0,5e3);let k=0,V=!1,_=0;for(;!V&&!x;){const g=l[w+k];g==="("&&_++,g===")"&&_--,_===0&&g===")"&&(V=!0),k>l.length&&(x=!0),k++}if(!x)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const D=w+k,a=l.slice(w,D),m=l,j=` ${y} = styled(${p}, "${h.classNames}", ${JSON.stringify(h.clientProps)});`;l=l.replace(a,j),m===l&&console.error("Minimize file failed to change content",{name:y,tagName:p})}),$.importStrategy==="component"){const y=J(t,6),S=f.parse(t);l=`import '../../saltygen/css/${`f_${R(S.name)}-${y}.css`}';
42
- ${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=te;exports.generateFile=ee;exports.isSaltyFile=et;exports.minimizeFile=se;exports.saltyFileRegExp=Pt;