@salty-css/webpack 0.0.1-alpha.198 → 0.0.1-alpha.199

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.
@@ -1,11 +1,11 @@
1
- "use strict";const Fe=require("esbuild"),Ce=require("child_process"),l=require("path"),u=require("fs"),re=require("fs/promises"),G=require("winston");var ne=typeof document<"u"?document.currentScript:null;function xe(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 fe=xe(Fe),ae=e=>String.fromCharCode(e+(e>25?39:97)),Ne=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ae(n%52)+s;return s=ae(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Pe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=Pe(5381,JSON.stringify(e))>>>0;return Ne(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 ke=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:a}=n;e=e.replace(o,i=>{const{value:p,css:r}=a(i);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ue=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},De=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],_e=(e,t,s)=>De.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,z=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((i,[p,r])=>{const c=p.trim(),y=c.startsWith("-")?c:M(c),h=(j,k=";")=>i=`${i}${j}${k}`,g=j=>h(`${y}:${j}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(r.isColor)return g(r.toString()),i;if(c==="variants")return Object.entries(r).forEach(([_,w])=>{w&&Object.entries(w).forEach(([O,C])=>{if(!C)return;const V=`${t}.${_}-${O}`,f=z(C,V);n.push(f)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(_=>{const{css:w,...O}=_,C=Object.entries(O).reduce((f,[m,$])=>`${f}.${m}-${$}`,t),V=z(w,C);n.push(V)}),i;if(c.startsWith("@")){const _=z(r,t),w=`${c} {
1
+ "use strict";const Fe=require("esbuild"),Ce=require("child_process"),l=require("path"),u=require("fs"),re=require("fs/promises"),G=require("winston");var ne=typeof document<"u"?document.currentScript:null;function xe(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 fe=xe(Fe),ae=e=>String.fromCharCode(e+(e>25?39:97)),Ne=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ae(n%52)+s;return s=ae(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Pe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=Pe(5381,JSON.stringify(e))>>>0;return Ne(s,t)};function E(e){return e?typeof e!="string"?E(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 ke=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:a}=n;e=e.replace(o,i=>{const{value:p,css:r}=a(i);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ue=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${E(n[1].replaceAll(".","-"))})`)}:{result:e},De=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],_e=(e,t,s)=>De.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Te=["Webkit","Moz","ms","O"],Oe=e=>e.startsWith("-")?e:Te.some(t=>e.startsWith(t))?`-${E(e)}`:E(e),z=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((i,[p,r])=>{const c=p.trim(),h=Oe(c),y=(j,k=";")=>i=`${i}${j}${k}`,g=j=>y(`${h}:${j}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(r.isColor)return g(r.toString()),i;if(c==="variants")return Object.entries(r).forEach(([_,w])=>{w&&Object.entries(w).forEach(([V,C])=>{if(!C)return;const M=`${t}.${_}-${V}`,f=z(C,M);n.push(f)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(_=>{const{css:w,...V}=_,C=Object.entries(V).reduce((f,[m,$])=>`${f}.${m}-${$}`,t),M=z(w,C);n.push(M)}),i;if(c.startsWith("@")){const _=z(r,t),w=`${c} {
2
2
  ${_.replace(`
3
3
  `,`
4
4
  `)}
5
- }`;return n.push(w),i}const j=p.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,k=z(r,j);return n.push(k),i}if(typeof r=="number"){const j=_e(y,r);return g(j)}if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:b}={},T=function*(){yield ue(r),yield ke(r,b)}();for(const{result:j,additionalCss:k=[]}of T)r=j,k.forEach(_=>{const w=z(_,"");h(w,"")});return g(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
5
+ }`;return n.push(w),i}const j=p.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,k=z(r,j);return n.push(k),i}if(typeof r=="number"){const j=_e(h,r);return g(j)}if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:b}={},T=function*(){yield ue(r),yield ke(r,b)}();for(const{result:j,additionalCss:k=[]}of T)r=j,k.forEach(_=>{const w=z(_,"");y(w,"")});return g(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
6
6
  `):o:n.join(`
7
- `)},de=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=de(a,[...t,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=t.map(M).join("-"),a=z(n,`.${o}`);s.push(a)}return s.join(`
8
- `)},Te=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?pe(o,a,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ge(l.join(e,".."))},Ee=async e=>{const t=ge(e);return await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await Ee(e);if(t)return t.type};let W;const ye=async e=>{if(W)return W;const t=await Oe(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-C9E2t-Dq.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},oe=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]});function he(e){return e?typeof e!="string"?he(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},{}),R={externalModules:[],rcFile:void 0,destDir:void 0},me=e=>{if(R.externalModules.length>0)return R.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 R.externalModules=n,n},J=async e=>{if(R.destDir)return R.destDir;const t=await ie(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},Se=["salty","css","styles","styled"],$e=(e=[])=>new RegExp(`\\.(${[...Se,...e].join("|")})\\.`),K=(e,t=[])=>$e(t).test(e),be=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):be(l.join(e,".."))},ie=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},Re=async e=>{const t=await ie(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await ye(e),i=me(n);await fe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const p=Date.now(),{config:r}=await import(`${o}?t=${p}`);return r},Me=async(e,t)=>{var A,B;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async N=>{const P=await Q(e,N,s);Object.values(P).forEach(D=>{D.isMedia?n.mediaQueries.push(D):D.isGlobalDefine?n.globalStyles.push(D):D.isDefineVariables?n.variables.push(D):D.isDefineTemplates&&n.templates.push(D)})}));const o=await Re(e),a={...o},i=new Set,p=(N,P=[])=>N?Object.entries(N).flatMap(([D,E])=>{if(!E)return;if(typeof E=="object")return p(E,[...P,D]);const v=he(D),ee=M(D),te=[...P,v].join(".");i.add(`"${te}"`);const se=[...P.map(M),ee].join("-"),{result:we}=ue(E);return`--${se}: ${we};`}):[],r=N=>N?Object.entries(N).flatMap(([P,D])=>{const E=p(D);return P==="base"?E.join(""):`${P} { ${E.join("")} }`}):[],c=N=>N?Object.entries(N).flatMap(([P,D])=>Object.entries(D).flatMap(([E,v])=>{const ee=p(v,[P]),te=`.${P}-${E}, [data-${P}="${E}"]`,se=ee.join("");return`${te} { ${se} }`})):[],y=N=>({...N,responsive:void 0,conditional:void 0}),h=N=>n.variables.map(P=>N==="static"?y(P._current):P._current[N]),g=I(y(o.variables),h("static")),b=p(g),S=I((A=o.variables)==null?void 0:A.responsive,h("responsive")),T=r(S),j=I((B=o.variables)==null?void 0:B.conditional,h("conditional")),k=c(j),_=l.join(s,"css/_variables.css"),w=`:root { ${b.join("")} ${T.join("")} } ${k.join("")}`;u.writeFileSync(_,w),a.staticVariables=g;const O=l.join(s,"css/_global.css"),C=I(o.global,n.globalStyles),V=z(C,"");u.writeFileSync(O,`@layer global { ${V} }`);const f=l.join(s,"css/_reset.css"),$=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ve,d=z($,"");u.writeFileSync(f,`@layer reset { ${d} }`);const F=l.join(s,"css/_templates.css"),x=I(o.templates,n.templates),q=de(x),H=Te(x);u.writeFileSync(F,q),a.templates=x;const L=l.join(s,"types/css-tokens.d.ts"),U=`
7
+ `)},de=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=de(a,[...t,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=t.map(E).join("-"),a=z(n,`.${o}`);s.push(a)}return s.join(`
8
+ `)},Ee=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?pe(o,a,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ge(l.join(e,".."))},Ve=async e=>{const t=ge(e);return await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Me=async e=>{const t=await Ve(e);if(t)return t.type};let A;const he=async e=>{if(A)return A;const t=await Me(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-4tHA_qgT.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},oe=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]});function ye(e){return e?typeof e!="string"?ye(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 Re={"*, *::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},{}),R={externalModules:[],rcFile:void 0,destDir:void 0},me=e=>{if(R.externalModules.length>0)return R.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 R.externalModules=n,n},J=async e=>{if(R.destDir)return R.destDir;const t=await ie(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},Se=["salty","css","styles","styled"],$e=(e=[])=>new RegExp(`\\.(${[...Se,...e].join("|")})\\.`),K=(e,t=[])=>$e(t).test(e),be=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):be(l.join(e,".."))},ie=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},ze=async e=>{const t=await ie(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await he(e),i=me(n);await fe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const p=Date.now(),{config:r}=await import(`${o}?t=${p}`);return r},Je=async(e,t)=>{var W,B;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async N=>{const P=await Q(e,N,s);Object.values(P).forEach(D=>{D.isMedia?n.mediaQueries.push(D):D.isGlobalDefine?n.globalStyles.push(D):D.isDefineVariables?n.variables.push(D):D.isDefineTemplates&&n.templates.push(D)})}));const o=await ze(e),a={...o},i=new Set,p=(N,P=[])=>N?Object.entries(N).flatMap(([D,O])=>{if(!O)return;if(typeof O=="object")return p(O,[...P,D]);const v=ye(D),ee=E(D),te=[...P,v].join(".");i.add(`"${te}"`);const se=[...P.map(E),ee].join("-"),{result:we}=ue(O);return`--${se}: ${we};`}):[],r=N=>N?Object.entries(N).flatMap(([P,D])=>{const O=p(D);return P==="base"?O.join(""):`${P} { ${O.join("")} }`}):[],c=N=>N?Object.entries(N).flatMap(([P,D])=>Object.entries(D).flatMap(([O,v])=>{const ee=p(v,[P]),te=`.${P}-${O}, [data-${P}="${O}"]`,se=ee.join("");return`${te} { ${se} }`})):[],h=N=>({...N,responsive:void 0,conditional:void 0}),y=N=>n.variables.map(P=>N==="static"?h(P._current):P._current[N]),g=I(h(o.variables),y("static")),b=p(g),S=I((W=o.variables)==null?void 0:W.responsive,y("responsive")),T=r(S),j=I((B=o.variables)==null?void 0:B.conditional,y("conditional")),k=c(j),_=l.join(s,"css/_variables.css"),w=`:root { ${b.join("")} ${T.join("")} } ${k.join("")}`;u.writeFileSync(_,w),a.staticVariables=g;const V=l.join(s,"css/_global.css"),C=I(o.global,n.globalStyles),M=z(C,"");u.writeFileSync(V,`@layer global { ${M} }`);const f=l.join(s,"css/_reset.css"),$=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Re,d=z($,"");u.writeFileSync(f,`@layer reset { ${d} }`);const F=l.join(s,"css/_templates.css"),x=I(o.templates,n.templates),q=de(x),H=Ee(x);u.writeFileSync(F,q),a.templates=x;const L=l.join(s,"types/css-tokens.d.ts"),U=`
9
9
  // Variable types
10
10
  type VariableTokens = ${[...i].join("|")};
11
11
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -15,27 +15,27 @@
15
15
  ${Object.entries(H).map(([N,P])=>`${N}?: ${P}`).join(`
16
16
  `)}
17
17
  }
18
- `;u.writeFileSync(L,U);const Y=l.join(s,"cache/config-cache.json");u.writeFileSync(Y,JSON.stringify(a,null,2))},le=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 p=i.at(1);if(Se.some(c=>p==null?void 0:p.includes(c)))return t}return"styled('div',"}),ze=(e,t)=>{try{const s=u.readFileSync(l.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
18
+ `;u.writeFileSync(L,U);const Y=l.join(s,"cache/config-cache.json");u.writeFileSync(Y,JSON.stringify(a,null,2))},le=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 p=i.at(1);if(Se.some(c=>p==null?void 0:p.includes(c)))return t}return"styled('div',"}),We=(e,t)=>{try{const s=u.readFileSync(l.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
19
19
 
20
20
  ${e}`:`globalThis.saltyConfig = {};
21
21
 
22
- ${e}`}catch{return e}},Q=async(e,t,s)=>{const n=Z(t),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(t);let i=u.readFileSync(t,"utf8");i=le(i),i=ze(i,e);const p=l.join(s,"js",n+".js"),r=await ie(e),c=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=me(c),h=await ye(e);await fe.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:h,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:S=>{S.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const j=u.readFileSync(T.path,"utf8");return{contents:le(j),loader:"ts"}})}}]});const g=Date.now();return await import(`${p}?t=${g}`)},Je=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ce=async e=>{const t=await Je(e),s=await J(e),n=l.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return I(a,t)},je=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ae=async(e,t=je(),s=!0)=>{try{const n=Date.now();t?oe.info("Generating CSS in production mode! 🔥"):oe.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await J(e),p=l.join(i,"index.css");s&&(()=>{u.existsSync(i)&&Ce.execSync("rm -rf "+i),u.mkdirSync(i,{recursive:!0}),u.mkdirSync(l.join(i,"css")),u.mkdirSync(l.join(i,"types")),u.mkdirSync(l.join(i,"js")),u.mkdirSync(l.join(i,"cache"))})();const c=new Set,y=new Set;async function h(f){const m=["node_modules","saltygen"],$=u.statSync(f);if($.isDirectory()){const d=u.readdirSync(f);if(m.some(x=>f.includes(x)))return;await Promise.all(d.map(x=>h(l.join(f,x))))}else if($.isFile()&&K(f)){c.add(f);const F=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&y.add(f)}}await h(e),await Me(e,y);const g={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const m=await Q(e,f,i);Object.entries(m).forEach(([$,d])=>{d.isKeyframes?g.keyframes.push({value:d,src:f,name:$}):d.isClassName?g.classNames.push({...d,src:f,name:$}):d.generator&&g.components.push({...d,src:f,name:$})})}));const b=await ce(e);for(const f of g.keyframes){const{value:m}=f,$=`a_${m.animationName}.css`,d=`css/${$}`,F=l.join(i,d);o.push($),u.writeFileSync(F,m.css)}const S={};for(const f of g.components){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}for(const f of g.classNames){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[0].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}b.importStrategy==="component"&&Object.entries(S).forEach(([f,m])=>{const $=m.map(H=>`@import url('./${H}');`).join(`
23
- `),d=Z(f,6),F=l.parse(f),x=M(F.name),q=l.join(i,`css/f_${x}-${d}.css`);u.writeFileSync(q,$)});const T=o.map(f=>`@import url('./css/${f}');`).join(`
22
+ ${e}`}catch{return e}},Q=async(e,t,s)=>{const n=Z(t),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(t);let i=u.readFileSync(t,"utf8");i=le(i),i=We(i,e);const p=l.join(s,"js",n+".js"),r=await ie(e),c=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),h=me(c),y=await he(e);await fe.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:y,target:["node20"],keepNames:!0,external:h,packages:"external",plugins:[{name:"test",setup:S=>{S.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const j=u.readFileSync(T.path,"utf8");return{contents:le(j),loader:"ts"}})}}]});const g=Date.now();return await import(`${p}?t=${g}`)},Ae=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ce=async e=>{const t=await Ae(e),s=await J(e),n=l.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return I(a,t)},je=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ie=async(e,t=je(),s=!0)=>{try{const n=Date.now();t?oe.info("Generating CSS in production mode! 🔥"):oe.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await J(e),p=l.join(i,"index.css");s&&(()=>{u.existsSync(i)&&Ce.execSync("rm -rf "+i),u.mkdirSync(i,{recursive:!0}),u.mkdirSync(l.join(i,"css")),u.mkdirSync(l.join(i,"types")),u.mkdirSync(l.join(i,"js")),u.mkdirSync(l.join(i,"cache"))})();const c=new Set,h=new Set;async function y(f){const m=["node_modules","saltygen"],$=u.statSync(f);if($.isDirectory()){const d=u.readdirSync(f);if(m.some(x=>f.includes(x)))return;await Promise.all(d.map(x=>y(l.join(f,x))))}else if($.isFile()&&K(f)){c.add(f);const F=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&h.add(f)}}await y(e),await Je(e,h);const g={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const m=await Q(e,f,i);Object.entries(m).forEach(([$,d])=>{d.isKeyframes?g.keyframes.push({value:d,src:f,name:$}):d.isClassName?g.classNames.push({...d,src:f,name:$}):d.generator&&g.components.push({...d,src:f,name:$})})}));const b=await ce(e);for(const f of g.keyframes){const{value:m}=f,$=`a_${m.animationName}.css`,d=`css/${$}`,F=l.join(i,d);o.push($),u.writeFileSync(F,m.css)}const S={};for(const f of g.components){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}for(const f of g.classNames){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[0].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}b.importStrategy==="component"&&Object.entries(S).forEach(([f,m])=>{const $=m.map(H=>`@import url('./${H}');`).join(`
23
+ `),d=Z(f,6),F=l.parse(f),x=E(F.name),q=l.join(i,`css/f_${x}-${d}.css`);u.writeFileSync(q,$)});const T=o.map(f=>`@import url('./css/${f}');`).join(`
24
24
  `);let w=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
25
25
 
26
26
  ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(i,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
27
27
  `)}
28
- ${T}`;if(b.importStrategy!=="component"){const f=a.reduce((m,$,d)=>{const F=$.reduce((L,X)=>{var B;const U=l.join(i,"css",X),Y=u.readFileSync(U,"utf8"),A=((B=/.*-([^-]+)-\d+.css/.exec(X))==null?void 0:B.at(1))||Z(U,6);return L.includes(A)?L:`${L}
29
- /*start:${A}*/
28
+ ${T}`;if(b.importStrategy!=="component"){const f=a.reduce((m,$,d)=>{const F=$.reduce((L,X)=>{var B;const U=l.join(i,"css",X),Y=u.readFileSync(U,"utf8"),W=((B=/.*-([^-]+)-\d+.css/.exec(X))==null?void 0:B.at(1))||Z(U,6);return L.includes(W)?L:`${L}
29
+ /*start:${W}*/
30
30
  ${Y}
31
- /*end:${A}*/
31
+ /*end:${W}*/
32
32
  `},""),x=`l_${d}.css`,q=l.join(i,"css",x),H=`@layer l${d} { ${F}
33
33
  }`;return u.writeFileSync(q,H),`${m}
34
- @import url('./css/${x}');`},"");w+=f}u.writeFileSync(p,w);const C=Date.now()-n,V=C<200?"🔥":C<500?"🚀":C<1e3?"🎉":C<2e3?"🚗":C<5e3?"🤔":"🥴";oe.info(`Generated CSS in ${C}ms! ${V}`)}catch(n){console.error(n)}},We=async(e,t)=>{try{const s=await J(e);if(K(t)){const o=[],a=await ce(e),i=await Q(e,t,s);if(Object.entries(i).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const b=`css/${`a_${r.animationName}.css`}`,S=l.join(s,b);u.writeFileSync(S,r.css);return}if(r.isClassName){const g=r.factory._withBuildContext({name:p});o[0].push(g.cssFileName);const b=`css/${g.cssFileName}`,S=l.join(s,b);u.writeFileSync(S,g.css)}if(!r.generator)return;const c=r.generator._withBuildContext({name:p,config:a}),y=`css/${c.cssFileName}`,h=l.join(s,y);u.writeFileSync(h,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),a.importStrategy!=="component")o.forEach((p,r)=>{const c=`l_${r}.css`,y=l.join(s,"css",c);let h=u.readFileSync(y,"utf8");p.forEach(g=>{var j;const b=l.join(s,"css",g),S=((j=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:j.at(1))||Z(b,6);if(!h.includes(S)){const k=u.readFileSync(b,"utf8"),_=`/*start:${S}*/
34
+ @import url('./css/${x}');`},"");w+=f}u.writeFileSync(p,w);const C=Date.now()-n,M=C<200?"🔥":C<500?"🚀":C<1e3?"🎉":C<2e3?"🚗":C<5e3?"🤔":"🥴";oe.info(`Generated CSS in ${C}ms! ${M}`)}catch(n){console.error(n)}},Ze=async(e,t)=>{try{const s=await J(e);if(K(t)){const o=[],a=await ce(e),i=await Q(e,t,s);if(Object.entries(i).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const b=`css/${`a_${r.animationName}.css`}`,S=l.join(s,b);u.writeFileSync(S,r.css);return}if(r.isClassName){const g=r.factory._withBuildContext({name:p});o[0].push(g.cssFileName);const b=`css/${g.cssFileName}`,S=l.join(s,b);u.writeFileSync(S,g.css)}if(!r.generator)return;const c=r.generator._withBuildContext({name:p,config:a}),h=`css/${c.cssFileName}`,y=l.join(s,h);u.writeFileSync(y,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),a.importStrategy!=="component")o.forEach((p,r)=>{const c=`l_${r}.css`,h=l.join(s,"css",c);let y=u.readFileSync(h,"utf8");p.forEach(g=>{var j;const b=l.join(s,"css",g),S=((j=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:j.at(1))||Z(b,6);if(!y.includes(S)){const k=u.readFileSync(b,"utf8"),_=`/*start:${S}*/
35
35
  ${k}
36
36
  /*end:${S}*/
37
- `;h=`${h.replace(/\}$/,"")}
37
+ `;y=`${y.replace(/\}$/,"")}
38
38
  ${_}
39
- }`}}),u.writeFileSync(y,h)});else{const p=o.flat().map(g=>`@import url('./${g}');`).join(`
40
- `),r=Z(t,6),c=l.parse(t),y=M(c.name),h=l.join(s,`css/f_${y}-${r}.css`);u.writeFileSync(h,p)}}}catch(s){console.error(s)}},Ie=async(e,t,s=je())=>{try{const n=await J(e);if(K(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==a&&await re.writeFile(t,a);const p=await ce(e),r=await Q(e,t,n);let c=a;if(Object.entries(r).forEach(([y,h])=>{var d;if(h.isKeyframes||!h.generator)return;const g=h.generator._withBuildContext({name:y,config:p,prod:s}),b=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!b)return console.error("Could not find the original declaration");const S=(d=b.at(1))==null?void 0:d.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:j}=T;let k=!1;const _=setTimeout(()=>k=!0,5e3);let w=0,O=!1,C=0;for(;!O&&!k;){const F=c[j+w];F==="("&&C++,F===")"&&C--,C===0&&F===")"&&(O=!0),w>c.length&&(k=!0),w++}if(!k)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const V=j+w,f=c.slice(j,V),m=c,$=` ${y} = styled(${S}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;c=c.replace(f,$),m===c&&console.error("Minimize file failed to change content",{name:y,tagName:S})}),p.importStrategy==="component"){const y=Z(t,6),h=l.parse(t);c=`import '../../saltygen/css/${`f_${M(h.name)}-${y}.css`}';
41
- ${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=Ae;exports.generateFile=We;exports.isSaltyFile=K;exports.minimizeFile=Ie;exports.saltyFileRegExp=$e;
39
+ }`}}),u.writeFileSync(h,y)});else{const p=o.flat().map(g=>`@import url('./${g}');`).join(`
40
+ `),r=Z(t,6),c=l.parse(t),h=E(c.name),y=l.join(s,`css/f_${h}-${r}.css`);u.writeFileSync(y,p)}}}catch(s){console.error(s)}},qe=async(e,t,s=je())=>{try{const n=await J(e);if(K(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,h=>`export ${h}`)!==a&&await re.writeFile(t,a);const p=await ce(e),r=await Q(e,t,n);let c=a;if(Object.entries(r).forEach(([h,y])=>{var d;if(y.isKeyframes||!y.generator)return;const g=y.generator._withBuildContext({name:h,config:p,prod:s}),b=new RegExp(`\\s${h}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!b)return console.error("Could not find the original declaration");const S=(d=b.at(1))==null?void 0:d.trim(),T=new RegExp(`\\s${h}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:j}=T;let k=!1;const _=setTimeout(()=>k=!0,5e3);let w=0,V=!1,C=0;for(;!V&&!k;){const F=c[j+w];F==="("&&C++,F===")"&&C--,C===0&&F===")"&&(V=!0),w>c.length&&(k=!0),w++}if(!k)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const M=j+w,f=c.slice(j,M),m=c,$=` ${h} = styled(${S}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;c=c.replace(f,$),m===c&&console.error("Minimize file failed to change content",{name:h,tagName:S})}),p.importStrategy==="component"){const h=Z(t,6),y=l.parse(t);c=`import '../../saltygen/css/${`f_${E(y.name)}-${h}.css`}';
41
+ ${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=Ie;exports.generateFile=Ze;exports.isSaltyFile=K;exports.minimizeFile=qe;exports.saltyFileRegExp=$e;
@@ -16,10 +16,10 @@ const ft = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Et = (t, e) => {
16
16
  const s = Tt(5381, JSON.stringify(t)) >>> 0;
17
17
  return Et(s, e);
18
18
  };
19
- function J(t) {
20
- return t ? typeof t != "string" ? J(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
19
+ function V(t) {
20
+ return t ? typeof t != "string" ? V(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
21
21
  }
22
- const Vt = (t, e) => {
22
+ const Ot = (t, e) => {
23
23
  if (typeof t != "string") return { result: t };
24
24
  if (!e) return { result: t };
25
25
  const s = [];
@@ -30,7 +30,7 @@ const Vt = (t, e) => {
30
30
  return r && s.push(r), p;
31
31
  });
32
32
  }), { result: t, additionalCss: s };
33
- }, gt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${J(n[1].replaceAll(".", "-"))})`) } : { result: t }, Ot = [
33
+ }, gt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, Vt = [
34
34
  "top",
35
35
  "right",
36
36
  "bottom",
@@ -51,19 +51,19 @@ const Vt = (t, e) => {
51
51
  /.*size.*/,
52
52
  /.*thickness.*/,
53
53
  /.*font-size.*/
54
- ], Mt = (t, e, s) => Ot.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, z = (t, e, s) => {
54
+ ], Mt = (t, e, s) => Vt.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, Rt = ["Webkit", "Moz", "ms", "O"], Jt = (t) => t.startsWith("-") ? t : Rt.some((e) => t.startsWith(e)) ? `-${V(t)}` : V(t), W = (t, e, s) => {
55
55
  if (!t) return "";
56
56
  const n = [], o = Object.entries(t).reduce((i, [p, r]) => {
57
- const c = p.trim(), g = c.startsWith("-") ? c : J(c), h = (w, k = ";") => i = `${i}${w}${k}`, d = (w) => h(`${g}:${w}`);
57
+ const c = p.trim(), g = Jt(c), h = (w, k = ";") => i = `${i}${w}${k}`, d = (w) => h(`${g}:${w}`);
58
58
  if (typeof r == "function" && (r = r()), typeof r == "object") {
59
59
  if (!r) return i;
60
60
  if (r.isColor)
61
61
  return d(r.toString()), i;
62
62
  if (c === "variants")
63
63
  return Object.entries(r).forEach(([_, S]) => {
64
- S && Object.entries(S).forEach(([O, j]) => {
64
+ S && Object.entries(S).forEach(([M, j]) => {
65
65
  if (!j) return;
66
- const M = `${e}.${_}-${O}`, l = z(j, M);
66
+ const R = `${e}.${_}-${M}`, l = W(j, R);
67
67
  n.push(l);
68
68
  });
69
69
  }), i;
@@ -71,18 +71,18 @@ const Vt = (t, e) => {
71
71
  return i;
72
72
  if (c === "compoundVariants")
73
73
  return r.forEach((_) => {
74
- const { css: S, ...O } = _, j = Object.entries(O).reduce((l, [m, $]) => `${l}.${m}-${$}`, e), M = z(S, j);
75
- n.push(M);
74
+ const { css: S, ...M } = _, j = Object.entries(M).reduce((l, [m, $]) => `${l}.${m}-${$}`, e), R = W(S, j);
75
+ n.push(R);
76
76
  }), i;
77
77
  if (c.startsWith("@")) {
78
- const _ = z(r, e), S = `${c} {
78
+ const _ = W(r, e), S = `${c} {
79
79
  ${_.replace(`
80
80
  `, `
81
81
  `)}
82
82
  }`;
83
83
  return n.push(S), i;
84
84
  }
85
- const w = p.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k = z(r, w);
85
+ const w = p.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k = W(r, w);
86
86
  return n.push(k), i;
87
87
  }
88
88
  if (typeof r == "number") {
@@ -93,11 +93,11 @@ const Vt = (t, e) => {
93
93
  if ("toString" in r) r = r.toString();
94
94
  else return i;
95
95
  const { modifiers: b } = {}, E = function* () {
96
- yield gt(r), yield Vt(r, b);
96
+ yield gt(r), yield Ot(r, b);
97
97
  }();
98
98
  for (const { result: w, additionalCss: k = [] } of E)
99
99
  r = w, k.forEach((_) => {
100
- const S = z(_, "");
100
+ const S = W(_, "");
101
101
  h(S, "");
102
102
  });
103
103
  return d(r);
@@ -116,31 +116,31 @@ const Vt = (t, e) => {
116
116
  } else
117
117
  n[o] = a;
118
118
  }), Object.keys(n).length) {
119
- const o = e.map(J).join("-"), a = z(n, `.${o}`);
119
+ const o = e.map(V).join("-"), a = W(n, `.${o}`);
120
120
  s.push(a);
121
121
  }
122
122
  return s.join(`
123
123
  `);
124
- }, Rt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = mt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, mt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
124
+ }, Wt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = mt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, mt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
125
125
  const a = e ? `${e}.${n}` : n;
126
126
  return typeof o == "object" ? mt(o, a, s) : s.add(e);
127
127
  }), [...s]) : [], yt = (t) => {
128
128
  if (!t || t === "/") throw new Error("Could not find package.json file");
129
129
  const e = f(t, "package.json");
130
130
  return it(e) ? e : yt(f(t, ".."));
131
- }, Jt = async (t) => {
131
+ }, zt = async (t) => {
132
132
  const e = yt(t);
133
133
  return await dt(e, "utf-8").then(JSON.parse).catch(() => {
134
134
  });
135
- }, zt = async (t) => {
136
- const e = await Jt(t);
135
+ }, At = async (t) => {
136
+ const e = await zt(t);
137
137
  if (e)
138
138
  return e.type;
139
139
  };
140
140
  let Z;
141
141
  const $t = async (t) => {
142
142
  if (Z) return Z;
143
- const e = await zt(t);
143
+ const e = await At(t);
144
144
  return e === "module" ? Z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (Z = "cjs"), Z || "esm";
145
145
  }, rt = Dt({
146
146
  level: "debug",
@@ -150,7 +150,7 @@ const $t = async (t) => {
150
150
  function bt(t) {
151
151
  return t ? typeof t != "string" ? bt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
152
152
  }
153
- const At = {
153
+ const Zt = {
154
154
  /** Set box model to border-box */
155
155
  "*, *::before, *::after": {
156
156
  boxSizing: "border-box"
@@ -196,32 +196,32 @@ const At = {
196
196
  fontSize: "100%",
197
197
  lineHeight: "1.15em"
198
198
  }
199
- }, I = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), R = {
199
+ }, I = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), J = {
200
200
  externalModules: [],
201
201
  rcFile: void 0,
202
202
  destDir: void 0
203
203
  }, wt = (t) => {
204
- if (R.externalModules.length > 0) return R.externalModules;
204
+ if (J.externalModules.length > 0) return J.externalModules;
205
205
  const s = T(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
206
206
  if (!s) return [];
207
207
  const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
208
- return R.externalModules = n, n;
209
- }, A = async (t) => {
210
- if (R.destDir) return R.destDir;
208
+ return J.externalModules = n, n;
209
+ }, z = async (t) => {
210
+ if (J.destDir) return J.destDir;
211
211
  const e = await at(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
212
- return R.destDir = s, s;
213
- }, St = ["salty", "css", "styles", "styled"], Wt = (t = []) => new RegExp(`\\.(${[...St, ...t].join("|")})\\.`), ct = (t, e = []) => Wt(e).test(t), Ct = async (t) => {
214
- if (R.rcFile) return R.rcFile;
212
+ return J.destDir = s, s;
213
+ }, St = ["salty", "css", "styles", "styled"], Ht = (t = []) => new RegExp(`\\.(${[...St, ...t].join("|")})\\.`), ct = (t, e = []) => Ht(e).test(t), Ct = async (t) => {
214
+ if (J.rcFile) return J.rcFile;
215
215
  if (t === "/") throw new Error("Could not find .saltyrc.json file");
216
216
  const e = f(t, ".saltyrc.json"), s = await dt(e, "utf-8").then(JSON.parse).catch(() => {
217
217
  });
218
- return s ? (R.rcFile = s, s) : Ct(f(t, ".."));
218
+ return s ? (J.rcFile = s, s) : Ct(f(t, ".."));
219
219
  }, at = async (t) => {
220
220
  var n, o;
221
221
  const e = await Ct(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
222
222
  return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
223
- }, Zt = async (t) => {
224
- const e = await at(t), s = await A(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = f(s, "salty.config.js"), a = await $t(t), i = wt(n);
223
+ }, It = async (t) => {
224
+ const e = await at(t), s = await z(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = f(s, "salty.config.js"), a = await $t(t), i = wt(n);
225
225
  await pt.build({
226
226
  entryPoints: [n],
227
227
  minify: !0,
@@ -233,9 +233,9 @@ const At = {
233
233
  });
234
234
  const p = Date.now(), { config: r } = await import(`${o}?t=${p}`);
235
235
  return r;
236
- }, Ht = async (t, e) => {
237
- var W, U;
238
- const s = await A(t), n = {
236
+ }, Bt = async (t, e) => {
237
+ var A, U;
238
+ const s = await z(t), n = {
239
239
  mediaQueries: [],
240
240
  globalStyles: [],
241
241
  variables: [],
@@ -249,26 +249,26 @@ const At = {
249
249
  });
250
250
  })
251
251
  );
252
- const o = await Zt(t), a = { ...o }, i = /* @__PURE__ */ new Set(), p = (x, N = []) => x ? Object.entries(x).flatMap(([D, V]) => {
253
- if (!V) return;
254
- if (typeof V == "object") return p(V, [...N, D]);
255
- const tt = bt(D), et = J(D), st = [...N, tt].join(".");
252
+ const o = await It(t), a = { ...o }, i = /* @__PURE__ */ new Set(), p = (x, N = []) => x ? Object.entries(x).flatMap(([D, O]) => {
253
+ if (!O) return;
254
+ if (typeof O == "object") return p(O, [...N, D]);
255
+ const tt = bt(D), et = V(D), st = [...N, tt].join(".");
256
256
  i.add(`"${st}"`);
257
- const nt = [...N.map(J), et].join("-"), { result: Ft } = gt(V);
257
+ const nt = [...N.map(V), et].join("-"), { result: Ft } = gt(O);
258
258
  return `--${nt}: ${Ft};`;
259
259
  }) : [], r = (x) => x ? Object.entries(x).flatMap(([N, D]) => {
260
- const V = p(D);
261
- return N === "base" ? V.join("") : `${N} { ${V.join("")} }`;
262
- }) : [], c = (x) => x ? Object.entries(x).flatMap(([N, D]) => Object.entries(D).flatMap(([V, tt]) => {
263
- const et = p(tt, [N]), st = `.${N}-${V}, [data-${N}="${V}"]`, nt = et.join("");
260
+ const O = p(D);
261
+ return N === "base" ? O.join("") : `${N} { ${O.join("")} }`;
262
+ }) : [], c = (x) => x ? Object.entries(x).flatMap(([N, D]) => Object.entries(D).flatMap(([O, tt]) => {
263
+ const et = p(tt, [N]), st = `.${N}-${O}, [data-${N}="${O}"]`, nt = et.join("");
264
264
  return `${st} { ${nt} }`;
265
- })) : [], g = (x) => ({ ...x, responsive: void 0, conditional: void 0 }), h = (x) => n.variables.map((N) => x === "static" ? g(N._current) : N._current[x]), d = I(g(o.variables), h("static")), b = p(d), y = I((W = o.variables) == null ? void 0 : W.responsive, h("responsive")), E = r(y), w = I((U = o.variables) == null ? void 0 : U.conditional, h("conditional")), k = c(w), _ = f(s, "css/_variables.css"), S = `:root { ${b.join("")} ${E.join("")} } ${k.join("")}`;
265
+ })) : [], g = (x) => ({ ...x, responsive: void 0, conditional: void 0 }), h = (x) => n.variables.map((N) => x === "static" ? g(N._current) : N._current[x]), d = I(g(o.variables), h("static")), b = p(d), y = I((A = o.variables) == null ? void 0 : A.responsive, h("responsive")), E = r(y), w = I((U = o.variables) == null ? void 0 : U.conditional, h("conditional")), k = c(w), _ = f(s, "css/_variables.css"), S = `:root { ${b.join("")} ${E.join("")} } ${k.join("")}`;
266
266
  P(_, S), a.staticVariables = d;
267
- const O = f(s, "css/_global.css"), j = I(o.global, n.globalStyles), M = z(j, "");
268
- P(O, `@layer global { ${M} }`);
269
- const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : At, u = z($, "");
267
+ const M = f(s, "css/_global.css"), j = I(o.global, n.globalStyles), R = W(j, "");
268
+ P(M, `@layer global { ${R} }`);
269
+ const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Zt, u = W($, "");
270
270
  P(l, `@layer reset { ${u} }`);
271
- const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), G = ht(F), L = Rt(F);
271
+ const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), G = ht(F), L = Wt(F);
272
272
  P(C, G), a.templates = F;
273
273
  const K = f(s, "types/css-tokens.d.ts"), q = `
274
274
  // Variable types
@@ -294,7 +294,7 @@ const At = {
294
294
  if (St.some((c) => p == null ? void 0 : p.includes(c))) return e;
295
295
  }
296
296
  return "styled('div',";
297
- }), It = (t, e) => {
297
+ }), Gt = (t, e) => {
298
298
  try {
299
299
  const s = T(f(e, "saltygen/cache/config-cache.json"), "utf8");
300
300
  return s ? `globalThis.saltyConfig = ${s};
@@ -310,7 +310,7 @@ ${t}`;
310
310
  it(o) || H(o);
311
311
  const a = Q(e);
312
312
  let i = T(e, "utf8");
313
- i = ut(i), i = It(i, t);
313
+ i = ut(i), i = Gt(i, t);
314
314
  const p = f(s, "js", n + ".js"), r = await at(t), c = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), g = wt(c), h = await $t(t);
315
315
  await pt.build({
316
316
  stdin: {
@@ -342,12 +342,12 @@ ${t}`;
342
342
  });
343
343
  const d = Date.now();
344
344
  return await import(`${p}?t=${d}`);
345
- }, Bt = async (t) => {
346
- const e = await A(t), s = f(e, "cache/config-cache.json"), n = T(s, "utf8");
345
+ }, Lt = async (t) => {
346
+ const e = await z(t), s = f(e, "cache/config-cache.json"), n = T(s, "utf8");
347
347
  if (!n) throw new Error("Could not find config cache file");
348
348
  return JSON.parse(n);
349
349
  }, lt = async (t) => {
350
- const e = await Bt(t), s = await A(t), n = f(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
350
+ const e = await Lt(t), s = await z(t), n = f(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
351
351
  return I(a, e);
352
352
  }, jt = () => {
353
353
  try {
@@ -355,11 +355,11 @@ ${t}`;
355
355
  } catch {
356
356
  return !1;
357
357
  }
358
- }, Qt = async (t, e = jt(), s = !0) => {
358
+ }, Yt = async (t, e = jt(), s = !0) => {
359
359
  try {
360
360
  const n = Date.now();
361
361
  e ? rt.info("Generating CSS in production mode! 🔥") : rt.info("Generating CSS in development mode! 🚀");
362
- const o = [], a = [], i = await A(t), p = f(i, "index.css");
362
+ const o = [], a = [], i = await z(t), p = f(i, "index.css");
363
363
  s && (() => {
364
364
  it(i) && xt("rm -rf " + i), H(i, { recursive: !0 }), H(f(i, "css")), H(f(i, "types")), H(f(i, "js")), H(f(i, "cache"));
365
365
  })();
@@ -376,7 +376,7 @@ ${t}`;
376
376
  /define[\w\d]+\(/.test(C) && g.add(l);
377
377
  }
378
378
  }
379
- await h(t), await Ht(t, g);
379
+ await h(t), await Bt(t, g);
380
380
  const d = {
381
381
  keyframes: [],
382
382
  components: [],
@@ -430,7 +430,7 @@ ${t}`;
430
430
  }
431
431
  b.importStrategy === "component" && Object.entries(y).forEach(([l, m]) => {
432
432
  const $ = m.map((L) => `@import url('./${L}');`).join(`
433
- `), u = B(l, 6), C = Q(l), F = J(C.name), G = f(i, `css/f_${F}-${u}.css`);
433
+ `), u = B(l, 6), C = Q(l), F = V(C.name), G = f(i, `css/f_${F}-${u}.css`);
434
434
  P(G, $);
435
435
  });
436
436
  const E = o.map((l) => `@import url('./css/${l}');`).join(`
@@ -450,11 +450,11 @@ ${E}`;
450
450
  const l = a.reduce((m, $, u) => {
451
451
  const C = $.reduce((K, Y) => {
452
452
  var U;
453
- const q = f(i, "css", Y), v = T(q, "utf8"), W = ((U = /.*-([^-]+)-\d+.css/.exec(Y)) == null ? void 0 : U.at(1)) || B(q, 6);
454
- return K.includes(W) ? K : `${K}
455
- /*start:${W}*/
453
+ const q = f(i, "css", Y), v = T(q, "utf8"), A = ((U = /.*-([^-]+)-\d+.css/.exec(Y)) == null ? void 0 : U.at(1)) || B(q, 6);
454
+ return K.includes(A) ? K : `${K}
455
+ /*start:${A}*/
456
456
  ${v}
457
- /*end:${W}*/
457
+ /*end:${A}*/
458
458
  `;
459
459
  }, ""), F = `l_${u}.css`, G = f(i, "css", F), L = `@layer l${u} { ${C}
460
460
  }`;
@@ -464,14 +464,14 @@ ${v}
464
464
  S += l;
465
465
  }
466
466
  P(p, S);
467
- const j = Date.now() - n, M = j < 200 ? "🔥" : j < 500 ? "🚀" : j < 1e3 ? "🎉" : j < 2e3 ? "🚗" : j < 5e3 ? "🤔" : "🥴";
468
- rt.info(`Generated CSS in ${j}ms! ${M}`);
467
+ const j = Date.now() - n, R = j < 200 ? "🔥" : j < 500 ? "🚀" : j < 1e3 ? "🎉" : j < 2e3 ? "🚗" : j < 5e3 ? "🤔" : "🥴";
468
+ rt.info(`Generated CSS in ${j}ms! ${R}`);
469
469
  } catch (n) {
470
470
  console.error(n);
471
471
  }
472
- }, Xt = async (t, e) => {
472
+ }, vt = async (t, e) => {
473
473
  try {
474
- const s = await A(t);
474
+ const s = await z(t);
475
475
  if (ct(e)) {
476
476
  const o = [], a = await lt(t), i = await X(t, e, s);
477
477
  if (Object.entries(i).forEach(([p, r]) => {
@@ -514,16 +514,16 @@ ${_}
514
514
  });
515
515
  else {
516
516
  const p = o.flat().map((d) => `@import url('./${d}');`).join(`
517
- `), r = B(e, 6), c = Q(e), g = J(c.name), h = f(s, `css/f_${g}-${r}.css`);
517
+ `), r = B(e, 6), c = Q(e), g = V(c.name), h = f(s, `css/f_${g}-${r}.css`);
518
518
  P(h, p);
519
519
  }
520
520
  }
521
521
  } catch (s) {
522
522
  console.error(s);
523
523
  }
524
- }, Yt = async (t, e, s = jt()) => {
524
+ }, te = async (t, e, s = jt()) => {
525
525
  try {
526
- const n = await A(t);
526
+ const n = await z(t);
527
527
  if (ct(e)) {
528
528
  const a = T(e, "utf8");
529
529
  a.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== a && await kt(e, a);
@@ -543,18 +543,18 @@ ${_}
543
543
  const { index: w } = E;
544
544
  let k = !1;
545
545
  const _ = setTimeout(() => k = !0, 5e3);
546
- let S = 0, O = !1, j = 0;
547
- for (; !O && !k; ) {
546
+ let S = 0, M = !1, j = 0;
547
+ for (; !M && !k; ) {
548
548
  const C = c[w + S];
549
- C === "(" && j++, C === ")" && j--, j === 0 && C === ")" && (O = !0), S > c.length && (k = !0), S++;
549
+ C === "(" && j++, C === ")" && j--, j === 0 && C === ")" && (M = !0), S > c.length && (k = !0), S++;
550
550
  }
551
551
  if (!k) clearTimeout(_);
552
552
  else throw new Error("Failed to find the end of the styled call and timed out");
553
- const M = w + S, l = c.slice(w, M), m = c, $ = ` ${g} = styled(${y}, "${d.classNames}", ${JSON.stringify(d.clientProps)});`;
553
+ const R = w + S, l = c.slice(w, R), m = c, $ = ` ${g} = styled(${y}, "${d.classNames}", ${JSON.stringify(d.clientProps)});`;
554
554
  c = c.replace(l, $), m === c && console.error("Minimize file failed to change content", { name: g, tagName: y });
555
555
  }), p.importStrategy === "component") {
556
556
  const g = B(e, 6), h = Q(e);
557
- c = `import '../../saltygen/css/${`f_${J(h.name)}-${g}.css`}';
557
+ c = `import '../../saltygen/css/${`f_${V(h.name)}-${g}.css`}';
558
558
  ${c}`;
559
559
  }
560
560
  return c = c.replace("{ styled }", "{ styledClient as styled }"), c = c.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), c;
@@ -564,9 +564,9 @@ ${c}`;
564
564
  }
565
565
  };
566
566
  export {
567
- Xt as a,
568
- Qt as g,
567
+ vt as a,
568
+ Yt as g,
569
569
  ct as i,
570
- Yt as m,
571
- Wt as s
570
+ te as m,
571
+ Ht as s
572
572
  };
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-C9E2t-Dq.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-4tHA_qgT.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-BJ1K4K_a.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-CPyuEBBL.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-C9E2t-Dq.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-4tHA_qgT.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-BJ1K4K_a.js";
1
+ import { a as e, m as i } from "./index-CPyuEBBL.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.198",
3
+ "version": "0.0.1-alpha.199",
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.198",
37
+ "@salty-css/core": "^0.0.1-alpha.199",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }