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

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.
@@ -61,12 +61,12 @@ const At = (t) => (e) => {
61
61
  if (p === "defaultVariants") return;
62
62
  if (p === "variants") {
63
63
  const C = Object.entries(i);
64
- for (const [E, c] of C) {
64
+ for (const [_, c] of C) {
65
65
  if (!c) return;
66
66
  const h = Object.entries(c);
67
67
  for (const [b, f] of h) {
68
68
  if (!f) return;
69
- const w = `${e}.${E}-${b}`;
69
+ const w = `${e}.${_}-${b}`;
70
70
  (await Y(f, w, s)).forEach((V) => o.add(V));
71
71
  }
72
72
  }
@@ -74,13 +74,13 @@ const At = (t) => (e) => {
74
74
  }
75
75
  if (p === "compoundVariants") {
76
76
  for (const C of i) {
77
- const { css: E, ...c } = C, h = Object.entries(c).reduce((f, [w, P]) => `${f}.${w}-${P}`, e);
78
- (await Y(E, h, s)).forEach((f) => o.add(f));
77
+ const { css: _, ...c } = C, h = Object.entries(c).reduce((f, [w, P]) => `${f}.${w}-${P}`, e);
78
+ (await Y(_, h, s)).forEach((f) => o.add(f));
79
79
  }
80
80
  return;
81
81
  }
82
82
  if (p.startsWith("@")) {
83
- const C = p, E = await L(i, e, s), c = `${C} { ${E} }`;
83
+ const C = p, _ = await L(i, e, s), c = `${C} { ${_} }`;
84
84
  o.add(c);
85
85
  return;
86
86
  }
@@ -105,8 +105,8 @@ const At = (t) => (e) => {
105
105
  const { transformed: k, additionalCss: O } = R;
106
106
  let C = "";
107
107
  if (O)
108
- for (const E of O)
109
- C += await L(E, "");
108
+ for (const _ of O)
109
+ C += await L(_, "");
110
110
  return `${C}${k}`;
111
111
  }, Promise.resolve(i)))
112
112
  ))).filter((m) => m !== void 0).join(`
@@ -255,28 +255,28 @@ const Gt = {
255
255
  await Promise.all(
256
256
  [...e].map(async (S) => {
257
257
  const { contents: x, outputFilePath: J } = await et(t, S, s);
258
- Object.entries(x).forEach(([_, T]) => {
259
- T.isMedia ? n.mediaQueries.push([_, T]) : T.isGlobalDefine ? n.globalStyles.push(T) : T.isDefineVariables ? n.variables.push(T) : T.isDefineTemplates && n.templates.push(T._setPath(J));
258
+ Object.entries(x).forEach(([E, T]) => {
259
+ T.isMedia ? n.mediaQueries.push([E, T]) : T.isGlobalDefine ? n.globalStyles.push(T) : T.isDefineVariables ? n.variables.push(T) : T.isDefineTemplates && n.templates.push(T._setPath(`${E};;${J}`));
260
260
  });
261
261
  })
262
262
  );
263
- const o = await Qt(t), r = { ...o }, a = /* @__PURE__ */ new Set(), g = (S, x = []) => S ? Object.entries(S).flatMap(([J, _]) => {
264
- if (!_) return;
265
- if (typeof _ == "object") return g(_, [...x, J]);
263
+ const o = await Qt(t), r = { ...o }, a = /* @__PURE__ */ new Set(), g = (S, x = []) => S ? Object.entries(S).flatMap(([J, E]) => {
264
+ if (!E) return;
265
+ if (typeof E == "object") return g(E, [...x, J]);
266
266
  const T = Ft(J), nt = A(J), ot = [...x, T].join(".");
267
267
  a.add(`"${ot}"`);
268
- const X = [...x.map(A), nt].join("-"), mt = Jt(_);
269
- return mt ? `--${X}: ${mt.transformed};` : `--${X}: ${_};`;
268
+ const X = [...x.map(A), nt].join("-"), mt = Jt(E);
269
+ return mt ? `--${X}: ${mt.transformed};` : `--${X}: ${E};`;
270
270
  }) : [], j = (S) => S ? Object.entries(S).flatMap(([x, J]) => {
271
- const _ = g(J);
272
- return x === "base" ? _.join("") : `${x} { ${_.join("")} }`;
273
- }) : [], l = (S) => S ? Object.entries(S).flatMap(([x, J]) => Object.entries(J).flatMap(([_, T]) => {
274
- const nt = g(T, [x]), ot = `.${x}-${_}, [data-${x}="${_}"]`, X = nt.join("");
271
+ const E = g(J);
272
+ return x === "base" ? E.join("") : `${x} { ${E.join("")} }`;
273
+ }) : [], l = (S) => S ? Object.entries(S).flatMap(([x, J]) => Object.entries(J).flatMap(([E, T]) => {
274
+ const nt = g(T, [x]), ot = `.${x}-${E}, [data-${x}="${E}"]`, X = nt.join("");
275
275
  return `${ot} { ${X} }`;
276
276
  })) : [], d = (S) => ({ ...S, responsive: void 0, conditional: void 0 }), y = (S) => n.variables.map((x) => S === "static" ? d(x._current) : x._current[S]), $ = B(d(o.variables), y("static")), m = g($), i = B((dt = o.variables) == null ? void 0 : dt.responsive, y("responsive")), p = j(i), N = B((pt = o.variables) == null ? void 0 : pt.conditional, y("conditional")), F = l(N), R = u(s, "css/_variables.css"), k = `:root { ${m.join("")} ${p.join("")} } ${F.join("")}`;
277
277
  D(R, k), r.staticVariables = $;
278
- const O = u(s, "css/_global.css"), C = B(o.global, n.globalStyles), E = await L(C, "");
279
- D(O, `@layer global { ${E} }`);
278
+ const O = u(s, "css/_global.css"), C = B(o.global, n.globalStyles), _ = await L(C, "");
279
+ D(O, `@layer global { ${_} }`);
280
280
  const c = u(s, "css/_reset.css"), b = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Gt, f = await L(b, "");
281
281
  D(c, `@layer reset { ${f} }`);
282
282
  const w = u(s, "css/_templates.css"), P = B(o.templates, n.templates), V = await wt(P), G = It(P);
@@ -490,8 +490,8 @@ ${st}
490
490
  k += c;
491
491
  }
492
492
  D(g, k);
493
- const C = Date.now() - n, E = C < 200 ? "🔥" : C < 500 ? "🚀" : C < 1e3 ? "🎉" : C < 2e3 ? "🚗" : C < 5e3 ? "🤔" : "🥴";
494
- it.info(`Generated CSS in ${C}ms! ${E}`);
493
+ const C = Date.now() - n, _ = C < 200 ? "🔥" : C < 500 ? "🚀" : C < 1e3 ? "🎉" : C < 2e3 ? "🚗" : C < 5e3 ? "🤔" : "🥴";
494
+ it.info(`Generated CSS in ${C}ms! ${_}`);
495
495
  } catch (n) {
496
496
  console.error(n);
497
497
  }
@@ -583,7 +583,7 @@ ${k}
583
583
  }
584
584
  if (!F) clearTimeout(R);
585
585
  else throw new Error("Failed to find the end of the styled call and timed out");
586
- const E = N + k, c = l.slice(N, E), h = l, b = ` ${d} = styled(${i}, "${$.classNames}", ${JSON.stringify($.clientProps)});`;
586
+ const _ = N + k, c = l.slice(N, _), h = l, b = ` ${d} = styled(${i}, "${$.classNames}", ${JSON.stringify($.clientProps)});`;
587
587
  l = l.replace(c, b), h === l && console.error("Minimize file failed to change content", { name: d, tagName: i });
588
588
  }), g.importStrategy === "component") {
589
589
  const d = z(e, 6), y = tt(e);
@@ -1,9 +1,9 @@
1
- "use strict";const Ne=require("esbuild"),ke=require("child_process"),l=require("path"),d=require("fs"),ie=require("fs/promises"),L=require("winston");var oe=typeof document<"u"?document.currentScript:null;function _e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ye=_e(Ne),pe=e=>String.fromCharCode(e+(e>25?39:97)),De=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=pe(n%52)+s;return s=pe(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Ee=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},J=(e,t=5)=>{const s=Ee(5381,JSON.stringify(e))>>>0;return De(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 Oe=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:a}=o;s=s.replace(r,g=>{const{value:C,css:f}=a(g);return f&&n.push(f),C})}),{transformed:s,additionalCss:n}},ge=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${R(o[1].replaceAll(".","-"))})`)},Te=ge(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Re=["Webkit","Moz","ms","O"],ze=e=>e.startsWith("-")?e:Re.some(t=>e.startsWith(t))?`-${R(e)}`:R(e),X=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,a=Object.entries(e).map(async([y,i])=>{const m=y.trim(),k=ze(m),x=(_,T=";")=>`${k}:${_}${T}`;if(typeof i=="function"&&(i=i({scope:t,config:s})),i instanceof Promise&&(i=await i),typeof i=="object"){if(!i)return;if(i.isColor)return x(i.toString());if(m==="defaultVariants")return;if(m==="variants"){const j=Object.entries(i);for(const[D,c]of j){if(!c)return;const h=Object.entries(c);for(const[b,u]of h){if(!u)return;const S=`${t}.${D}-${b}`;(await X(u,S,s)).forEach(V=>o.add(V))}}return}if(m==="compoundVariants"){for(const j of i){const{css:D,...c}=j,h=Object.entries(c).reduce((u,[S,N])=>`${u}.${S}-${N}`,t);(await X(D,h,s)).forEach(u=>o.add(u))}return}if(m.startsWith("@")){const j=m,D=await B(i,t,s),c=`${j} { ${D} }`;o.add(c);return}const _=y.includes("&")?m.replace("&",t):m.startsWith(":")?`${t}${m}`:`${t} ${m}`;(await X(i,_,s)).forEach(j=>o.add(j));return}if(typeof i=="number"){const _=Me(k,i);return x(_)}if(typeof i!="string")if("toString"in i)i=i.toString();else throw new Error(`Invalid value type for property ${k}`);return x(i)}),{modifiers:g}={},C=[ge(),Oe(g)],p=(await Promise.all(a).then(y=>Promise.all(y.map(i=>C.reduce(async(m,k)=>{const x=await m;if(!x)return x;const M=await k(x);if(!M)return x;const{transformed:_,additionalCss:T}=M;let j="";if(T)for(const D of T)j+=await B(D,"");return`${j}${_}`},Promise.resolve(i)))))).filter(y=>y!==void 0).join(`
1
+ "use strict";const Ne=require("esbuild"),ke=require("child_process"),l=require("path"),d=require("fs"),ie=require("fs/promises"),L=require("winston");var oe=typeof document<"u"?document.currentScript:null;function _e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const ye=_e(Ne),pe=e=>String.fromCharCode(e+(e>25?39:97)),De=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=pe(n%52)+s;return s=pe(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Ee=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},J=(e,t=5)=>{const s=Ee(5381,JSON.stringify(e))>>>0;return De(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 Oe=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:r,transform:a}=o;s=s.replace(r,g=>{const{value:C,css:f}=a(g);return f&&n.push(f),C})}),{transformed:s,additionalCss:n}},ge=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${R(o[1].replaceAll(".","-"))})`)},Te=ge(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,Re=["Webkit","Moz","ms","O"],ze=e=>e.startsWith("-")?e:Re.some(t=>e.startsWith(t))?`-${R(e)}`:R(e),X=async(e,t="",s,n=!1)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const o=new Set,a=Object.entries(e).map(async([y,i])=>{const m=y.trim(),k=ze(m),x=(_,T=";")=>`${k}:${_}${T}`;if(typeof i=="function"&&(i=i({scope:t,config:s})),i instanceof Promise&&(i=await i),typeof i=="object"){if(!i)return;if(i.isColor)return x(i.toString());if(m==="defaultVariants")return;if(m==="variants"){const j=Object.entries(i);for(const[E,c]of j){if(!c)return;const h=Object.entries(c);for(const[b,u]of h){if(!u)return;const S=`${t}.${E}-${b}`;(await X(u,S,s)).forEach(V=>o.add(V))}}return}if(m==="compoundVariants"){for(const j of i){const{css:E,...c}=j,h=Object.entries(c).reduce((u,[S,N])=>`${u}.${S}-${N}`,t);(await X(E,h,s)).forEach(u=>o.add(u))}return}if(m.startsWith("@")){const j=m,E=await B(i,t,s),c=`${j} { ${E} }`;o.add(c);return}const _=y.includes("&")?m.replace("&",t):m.startsWith(":")?`${t}${m}`:`${t} ${m}`;(await X(i,_,s)).forEach(j=>o.add(j));return}if(typeof i=="number"){const _=Me(k,i);return x(_)}if(typeof i!="string")if("toString"in i)i=i.toString();else throw new Error(`Invalid value type for property ${k}`);return x(i)}),{modifiers:g}={},C=[ge(),Oe(g)],p=(await Promise.all(a).then(y=>Promise.all(y.map(i=>C.reduce(async(m,k)=>{const x=await m;if(!x)return x;const M=await k(x);if(!M)return x;const{transformed:_,additionalCss:T}=M;let j="";if(T)for(const E of T)j+=await B(E,"");return`${j}${_}`},Promise.resolve(i)))))).filter(y=>y!==void 0).join(`
2
2
  `);if(!p.trim())return Array.from(o);const w=t?`${t} {
3
3
  ${p}
4
4
  }`:p;return o.has(w)?Array.from(o):[w,...o]},B=async(e,t,s,n=!1)=>(await X(e,t,s,n)).join(`
5
5
  `),he=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 a=o.trim(),g=await he(r,[...t,a]);s.push(g)}else n[o]=r;if(Object.keys(n).length){const o=t.map(R).join("-"),r="t_"+J(o,4),a=await B(n,`.${o}, .${r}`);s.push(a)}return s.join(`
6
- `)},Ae=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=we(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},we=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?we(o,r,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return d.existsSync(t)?t:$e(l.join(e,".."))},Je=async e=>{const t=$e(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},We=async e=>{const t=await Je(e);if(t)return t.type};let I;const be=async e=>{if(I)return I;const t=await We(e);return t==="module"?I="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-BG0kLkBd.cjs",document.baseURI).href).endsWith(".cjs"))&&(I="cjs"),I||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function Se(e){return e?typeof e!="string"?Se(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const ve={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},Z=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ie=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),A={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(A.externalModules.length>0)return A.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 A.externalModules=n,n},W=async e=>{if(A.destDir)return A.destDir;const t=await ae(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return A.destDir=s,s},Fe=["salty","css","styles","styled"],Ce=(e=[])=>new RegExp(`\\.(${[...Fe,...e].join("|")})\\.`),Y=(e,t=[])=>Ce(t).test(e),xe=async e=>{if(A.rcFile)return A.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(A.rcFile=s,s):xe(l.join(e,".."))},ae=async e=>{var n,o;const t=await xe(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))},Ze=async e=>{const t=await ae(e),s=await W(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),r=await be(e),a=je(n);await ye.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:a});const g=Date.now(),{config:C}=await import(`${o}?t=${g}`);return C},qe=async(e,t)=>{var fe,ue;const s=await W(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async F=>{const{contents:P,outputFilePath:z}=await ee(e,F,s);Object.entries(P).forEach(([E,O])=>{O.isMedia?n.mediaQueries.push([E,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(z))})}));const o=await Ze(e),r={...o},a=new Set,g=(F,P=[])=>F?Object.entries(F).flatMap(([z,E])=>{if(!E)return;if(typeof E=="object")return g(E,[...P,z]);const O=Se(z),se=R(z),ne=[...P,O].join(".");a.add(`"${ne}"`);const U=[...P.map(R),se].join("-"),de=Te(E);return de?`--${U}: ${de.transformed};`:`--${U}: ${E};`}):[],C=F=>F?Object.entries(F).flatMap(([P,z])=>{const E=g(z);return P==="base"?E.join(""):`${P} { ${E.join("")} }`}):[],f=F=>F?Object.entries(F).flatMap(([P,z])=>Object.entries(z).flatMap(([E,O])=>{const se=g(O,[P]),ne=`.${P}-${E}, [data-${P}="${E}"]`,U=se.join("");return`${ne} { ${U} }`})):[],p=F=>({...F,responsive:void 0,conditional:void 0}),w=F=>n.variables.map(P=>F==="static"?p(P._current):P._current[F]),$=Z(p(o.variables),w("static")),y=g($),i=Z((fe=o.variables)==null?void 0:fe.responsive,w("responsive")),m=C(i),k=Z((ue=o.variables)==null?void 0:ue.conditional,w("conditional")),x=f(k),M=l.join(s,"css/_variables.css"),_=`:root { ${y.join("")} ${m.join("")} } ${x.join("")}`;d.writeFileSync(M,_),r.staticVariables=$;const T=l.join(s,"css/_global.css"),j=Z(o.global,n.globalStyles),D=await B(j,"");d.writeFileSync(T,`@layer global { ${D} }`);const c=l.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ve,u=await B(b,"");d.writeFileSync(c,`@layer reset { ${u} }`);const S=l.join(s,"css/_templates.css"),N=Z(o.templates,n.templates),V=await he(N),q=Ae(N);d.writeFileSync(S,`@layer templates { ${V} }`),r.templates=N;const H=Ie(n.templates);r.templatePaths=Object.fromEntries(Object.entries(H).map(([F,P])=>[F,P._path]));const{mediaQueries:v}=n;r.mediaQueries=Object.fromEntries(v.map(([F,P])=>[`@${F}`,P]));const G=v.map(([F])=>`'@${F}'`).join(" | "),te=l.join(s,"types/css-tokens.d.ts"),Q=`
6
+ `)},Ae=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=we(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},we=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const r=t?`${t}.${n}`:n;return typeof o=="object"?we(o,r,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return d.existsSync(t)?t:$e(l.join(e,".."))},Je=async e=>{const t=$e(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},We=async e=>{const t=await Je(e);if(t)return t.type};let I;const be=async e=>{if(I)return I;const t=await We(e);return t==="module"?I="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-DkYpiTkg.cjs",document.baseURI).href).endsWith(".cjs"))&&(I="cjs"),I||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function Se(e){return e?typeof e!="string"?Se(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const ve={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},Z=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ie=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),A={externalModules:[],rcFile:void 0,destDir:void 0},je=e=>{if(A.externalModules.length>0)return A.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 A.externalModules=n,n},W=async e=>{if(A.destDir)return A.destDir;const t=await ae(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return A.destDir=s,s},Fe=["salty","css","styles","styled"],Ce=(e=[])=>new RegExp(`\\.(${[...Fe,...e].join("|")})\\.`),Y=(e,t=[])=>Ce(t).test(e),xe=async e=>{if(A.rcFile)return A.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(A.rcFile=s,s):xe(l.join(e,".."))},ae=async e=>{var n,o;const t=await xe(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))},Ze=async e=>{const t=await ae(e),s=await W(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),r=await be(e),a=je(n);await ye.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:r,external:a});const g=Date.now(),{config:C}=await import(`${o}?t=${g}`);return C},qe=async(e,t)=>{var fe,ue;const s=await W(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async F=>{const{contents:P,outputFilePath:z}=await ee(e,F,s);Object.entries(P).forEach(([D,O])=>{O.isMedia?n.mediaQueries.push([D,O]):O.isGlobalDefine?n.globalStyles.push(O):O.isDefineVariables?n.variables.push(O):O.isDefineTemplates&&n.templates.push(O._setPath(`${D};;${z}`))})}));const o=await Ze(e),r={...o},a=new Set,g=(F,P=[])=>F?Object.entries(F).flatMap(([z,D])=>{if(!D)return;if(typeof D=="object")return g(D,[...P,z]);const O=Se(z),se=R(z),ne=[...P,O].join(".");a.add(`"${ne}"`);const U=[...P.map(R),se].join("-"),de=Te(D);return de?`--${U}: ${de.transformed};`:`--${U}: ${D};`}):[],C=F=>F?Object.entries(F).flatMap(([P,z])=>{const D=g(z);return P==="base"?D.join(""):`${P} { ${D.join("")} }`}):[],f=F=>F?Object.entries(F).flatMap(([P,z])=>Object.entries(z).flatMap(([D,O])=>{const se=g(O,[P]),ne=`.${P}-${D}, [data-${P}="${D}"]`,U=se.join("");return`${ne} { ${U} }`})):[],p=F=>({...F,responsive:void 0,conditional:void 0}),w=F=>n.variables.map(P=>F==="static"?p(P._current):P._current[F]),$=Z(p(o.variables),w("static")),y=g($),i=Z((fe=o.variables)==null?void 0:fe.responsive,w("responsive")),m=C(i),k=Z((ue=o.variables)==null?void 0:ue.conditional,w("conditional")),x=f(k),M=l.join(s,"css/_variables.css"),_=`:root { ${y.join("")} ${m.join("")} } ${x.join("")}`;d.writeFileSync(M,_),r.staticVariables=$;const T=l.join(s,"css/_global.css"),j=Z(o.global,n.globalStyles),E=await B(j,"");d.writeFileSync(T,`@layer global { ${E} }`);const c=l.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ve,u=await B(b,"");d.writeFileSync(c,`@layer reset { ${u} }`);const S=l.join(s,"css/_templates.css"),N=Z(o.templates,n.templates),V=await he(N),q=Ae(N);d.writeFileSync(S,`@layer templates { ${V} }`),r.templates=N;const H=Ie(n.templates);r.templatePaths=Object.fromEntries(Object.entries(H).map(([F,P])=>[F,P._path]));const{mediaQueries:v}=n;r.mediaQueries=Object.fromEntries(v.map(([F,P])=>[`@${F}`,P]));const G=v.map(([F])=>`'@${F}'`).join(" | "),te=l.join(s,"types/css-tokens.d.ts"),Q=`
7
7
  // Variable types
8
8
  type VariableTokens = ${[...a].join("|")};
9
9
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -32,11 +32,11 @@ ${te}
32
32
  /*end:${K}*/
33
33
  `},""),N=`l_${u}.css`,V=l.join(a,"css",N),q=`@layer l${u} { ${S}
34
34
  }`;return d.writeFileSync(V,q),`${h}
35
- @import url('./css/${N}');`},"");_+=c}d.writeFileSync(g,_);const j=Date.now()-n,D=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";re.info(`Generated CSS in ${j}ms! ${D}`)}catch(n){console.error(n)}},Ge=async(e,t,s=le())=>{try{const n=await W(e);if(Y(t)){const r=[],a=await ce(e),{contents:g}=await ee(e,t,n);for(const[C,f]of Object.entries(g)){if(f.isKeyframes&&f.css){const m=`css/${`a_${f.animationName}.css`}`,k=l.join(n,m);d.writeFileSync(k,await f.css);return}if(f.isClassName){const i=f.generator._withBuildContext({callerName:C,isProduction:s,config:a}),m=await i.css;if(!m)continue;r[0].push(i.cssFileName);const k=`css/${i.cssFileName}`,x=l.join(n,k);d.writeFileSync(x,m)}if(!f.generator)return;const p=f.generator._withBuildContext({callerName:C,isProduction:s,config:a}),w=await p.css;if(!w)continue;const $=`css/${p.cssFileName}`,y=l.join(n,$);d.writeFileSync(y,w),r[p.priority]||(r[p.priority]=[]),r[p.priority].push(p.cssFileName)}if(a.importStrategy!=="component")r.forEach((C,f)=>{const p=`l_${f}.css`,w=l.join(n,"css",p);let $=d.readFileSync(w,"utf8");C.forEach(y=>{var x;const i=l.join(n,"css",y),m=((x=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:x.at(1))||J(i,6);if(!$.includes(m)){const M=d.readFileSync(i,"utf8"),_=`/*start:${m}-${y}*/
35
+ @import url('./css/${N}');`},"");_+=c}d.writeFileSync(g,_);const j=Date.now()-n,E=j<200?"🔥":j<500?"🚀":j<1e3?"🎉":j<2e3?"🚗":j<5e3?"🤔":"🥴";re.info(`Generated CSS in ${j}ms! ${E}`)}catch(n){console.error(n)}},Ge=async(e,t,s=le())=>{try{const n=await W(e);if(Y(t)){const r=[],a=await ce(e),{contents:g}=await ee(e,t,n);for(const[C,f]of Object.entries(g)){if(f.isKeyframes&&f.css){const m=`css/${`a_${f.animationName}.css`}`,k=l.join(n,m);d.writeFileSync(k,await f.css);return}if(f.isClassName){const i=f.generator._withBuildContext({callerName:C,isProduction:s,config:a}),m=await i.css;if(!m)continue;r[0].push(i.cssFileName);const k=`css/${i.cssFileName}`,x=l.join(n,k);d.writeFileSync(x,m)}if(!f.generator)return;const p=f.generator._withBuildContext({callerName:C,isProduction:s,config:a}),w=await p.css;if(!w)continue;const $=`css/${p.cssFileName}`,y=l.join(n,$);d.writeFileSync(y,w),r[p.priority]||(r[p.priority]=[]),r[p.priority].push(p.cssFileName)}if(a.importStrategy!=="component")r.forEach((C,f)=>{const p=`l_${f}.css`,w=l.join(n,"css",p);let $=d.readFileSync(w,"utf8");C.forEach(y=>{var x;const i=l.join(n,"css",y),m=((x=/.*-([^-]+)-\d+.css/.exec(y))==null?void 0:x.at(1))||J(i,6);if(!$.includes(m)){const M=d.readFileSync(i,"utf8"),_=`/*start:${m}-${y}*/
36
36
  ${M}
37
37
  /*end:${m}*/
38
38
  `;$=`${$.replace(/\}$/,"")}
39
39
  ${_}
40
40
  }`}}),d.writeFileSync(w,$)});else{const C=r.flat().map(y=>`@import url('./${y}');`).join(`
41
- `),f=J(t,6),p=l.parse(t),w=R(p.name),$=l.join(n,`css/f_${w}-${f}.css`);d.writeFileSync($,C||"/* Empty file */")}}}catch(n){console.error(n)}},Ke=async(e,t,s=le())=>{try{const n=await W(e);if(Y(t)){const r=d.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,p=>`export ${p}`)!==r&&await ie.writeFile(t,r);const g=await ce(e),{contents:C}=await ee(e,t,n);let f=r;if(Object.entries(C).forEach(([p,w])=>{var u;if(w.isKeyframes||!w.generator)return;const $=w.generator._withBuildContext({callerName:p,isProduction:s,config:g}),y=new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!y)return console.error("Could not find the original declaration");const i=(u=y.at(1))==null?void 0:u.trim(),m=new RegExp(`\\s${p}[=\\s]+styled\\(`,"g").exec(f);if(!m)return console.error("Could not find the original declaration");const{index:k}=m;let x=!1;const M=setTimeout(()=>x=!0,5e3);let _=0,T=!1,j=0;for(;!T&&!x;){const S=f[k+_];S==="("&&j++,S===")"&&j--,j===0&&S===")"&&(T=!0),_>f.length&&(x=!0),_++}if(!x)clearTimeout(M);else throw new Error("Failed to find the end of the styled call and timed out");const D=k+_,c=f.slice(k,D),h=f,b=` ${p} = styled(${i}, "${$.classNames}", ${JSON.stringify($.clientProps)});`;f=f.replace(c,b),h===f&&console.error("Minimize file failed to change content",{name:p,tagName:i})}),g.importStrategy==="component"){const p=J(t,6),w=l.parse(t);f=`import '../../saltygen/css/${`f_${R(w.name)}-${p}.css`}';
41
+ `),f=J(t,6),p=l.parse(t),w=R(p.name),$=l.join(n,`css/f_${w}-${f}.css`);d.writeFileSync($,C||"/* Empty file */")}}}catch(n){console.error(n)}},Ke=async(e,t,s=le())=>{try{const n=await W(e);if(Y(t)){const r=d.readFileSync(t,"utf8");r.replace(/^(?!export\s)const\s.*/gm,p=>`export ${p}`)!==r&&await ie.writeFile(t,r);const g=await ce(e),{contents:C}=await ee(e,t,n);let f=r;if(Object.entries(C).forEach(([p,w])=>{var u;if(w.isKeyframes||!w.generator)return;const $=w.generator._withBuildContext({callerName:p,isProduction:s,config:g}),y=new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(r);if(!y)return console.error("Could not find the original declaration");const i=(u=y.at(1))==null?void 0:u.trim(),m=new RegExp(`\\s${p}[=\\s]+styled\\(`,"g").exec(f);if(!m)return console.error("Could not find the original declaration");const{index:k}=m;let x=!1;const M=setTimeout(()=>x=!0,5e3);let _=0,T=!1,j=0;for(;!T&&!x;){const S=f[k+_];S==="("&&j++,S===")"&&j--,j===0&&S===")"&&(T=!0),_>f.length&&(x=!0),_++}if(!x)clearTimeout(M);else throw new Error("Failed to find the end of the styled call and timed out");const E=k+_,c=f.slice(k,E),h=f,b=` ${p} = styled(${i}, "${$.classNames}", ${JSON.stringify($.clientProps)});`;f=f.replace(c,b),h===f&&console.error("Minimize file failed to change content",{name:p,tagName:i})}),g.importStrategy==="component"){const p=J(t,6),w=l.parse(t);f=`import '../../saltygen/css/${`f_${R(w.name)}-${p}.css`}';
42
42
  ${f}`}return f=f.replace("{ styled }","{ styledClient as styled }"),f=f.replace("@salty-css/react/styled","@salty-css/react/styled-client"),f}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Ce;
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-BG0kLkBd.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-DkYpiTkg.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-B3z-tgrO.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-C3XjWftB.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-BG0kLkBd.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
1
+ "use strict";const i=require("./index-DkYpiTkg.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-B3z-tgrO.js";
1
+ import { a as e, m as i } from "./index-C3XjWftB.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.209",
3
+ "version": "0.0.1-alpha.210",
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.209",
37
+ "@salty-css/core": "^0.0.1-alpha.210",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }