@salty-css/webpack 0.0.1-alpha.202 → 0.0.1-alpha.203

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,7 +1,7 @@
1
1
  import * as ht from "esbuild";
2
2
  import { execSync as Dt } from "child_process";
3
3
  import { join as u, parse as tt } from "path";
4
- import { existsSync as at, writeFileSync as k, readFileSync as V, mkdirSync as Z, statSync as _t, readdirSync as Et } from "fs";
4
+ import { existsSync as at, writeFileSync as k, readFileSync as V, mkdirSync as v, statSync as _t, readdirSync as Et } from "fs";
5
5
  import { readFile as yt, writeFile as Tt } from "fs/promises";
6
6
  import { createLogger as Ot, format as rt, transports as Vt } from "winston";
7
7
  const mt = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Mt = (t, e) => {
@@ -12,7 +12,7 @@ const mt = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Mt = (t, e) => {
12
12
  let s = e.length;
13
13
  for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
14
14
  return t;
15
- }, H = (t, e = 5) => {
15
+ }, I = (t, e = 5) => {
16
16
  const s = Rt(5381, JSON.stringify(t)) >>> 0;
17
17
  return Mt(s, e);
18
18
  };
@@ -51,10 +51,10 @@ const Jt = (t) => (e) => {
51
51
  /.*size.*/,
52
52
  /.*thickness.*/,
53
53
  /.*font-size.*/
54
- ], At = (t, e, s) => zt.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, Zt = ["Webkit", "Moz", "ms", "O"], It = (t) => t.startsWith("-") ? t : Zt.some((e) => t.startsWith(e)) ? `-${M(t)}` : M(t), Y = async (t, e = "", s) => {
54
+ ], At = (t, e, s) => zt.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, vt = ["Webkit", "Moz", "ms", "O"], Zt = (t) => t.startsWith("-") ? t : vt.some((e) => t.startsWith(e)) ? `-${M(t)}` : M(t), Y = async (t, e = "", s) => {
55
55
  if (!t) throw new Error("No styles provided to parseStyles function!");
56
56
  const n = /* @__PURE__ */ new Set(), i = Object.entries(t).map(async ([g, r]) => {
57
- const d = g.trim(), h = It(d), x = (N, T = ";") => `${h}:${N}${T}`;
57
+ const d = g.trim(), h = Zt(d), x = (N, T = ";") => `${h}:${N}${T}`;
58
58
  if (typeof r == "function" && (r = r({ scope: e, config: s })), r instanceof Promise && (r = await r), typeof r == "object") {
59
59
  if (!r) return;
60
60
  if (r.isColor) return x(r.toString());
@@ -118,33 +118,32 @@ const Jt = (t) => (e) => {
118
118
  `), bt = async (t, e = []) => {
119
119
  if (!t) return "";
120
120
  const s = [], n = {};
121
- if (Object.entries(t).forEach(async ([o, i]) => {
122
- if (typeof i == "function") return console.log("Function found", o);
123
- if (typeof i == "object") {
124
- if (!i) return;
121
+ for (const [o, i] of Object.entries(t))
122
+ if (typeof i == "function") console.log("Function found", o);
123
+ else if (i && typeof i == "object") {
125
124
  const c = o.trim(), p = await bt(i, [...e, c]);
126
125
  s.push(p);
127
126
  } else
128
127
  n[o] = i;
129
- }), Object.keys(n).length) {
128
+ if (Object.keys(n).length) {
130
129
  const o = e.map(M).join("-"), i = await L(n, `.${o}`);
131
130
  s.push(i);
132
131
  }
133
132
  return s.join(`
134
133
  `);
135
- }, Ht = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = wt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, wt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
134
+ }, It = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = wt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, wt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
136
135
  const i = e ? `${e}.${n}` : n;
137
136
  return typeof o == "object" ? wt(o, i, s) : s.add(e);
138
137
  }), [...s]) : [], Ct = (t) => {
139
138
  if (!t || t === "/") throw new Error("Could not find package.json file");
140
139
  const e = u(t, "package.json");
141
140
  return at(e) ? e : Ct(u(t, ".."));
142
- }, vt = async (t) => {
141
+ }, Ht = async (t) => {
143
142
  const e = Ct(t);
144
143
  return await yt(e, "utf-8").then(JSON.parse).catch(() => {
145
144
  });
146
145
  }, Bt = async (t) => {
147
- const e = await vt(t);
146
+ const e = await Ht(t);
148
147
  if (e)
149
148
  return e.type;
150
149
  };
@@ -207,7 +206,7 @@ const Gt = {
207
206
  fontSize: "100%",
208
207
  lineHeight: "1.15em"
209
208
  }
210
- }, I = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), Kt = (...t) => t.flat().reduce((e, s) => ({ ...e, ...s._children }), {}), W = {
209
+ }, Z = (...t) => t.flat().reduce((e, s) => s != null && s._current ? { ...e, ...s._current } : { ...e, ...s }, {}), Kt = (...t) => t.flat().reduce((e, s) => ({ ...e, ...s._children }), {}), W = {
211
210
  externalModules: [],
212
211
  rcFile: void 0,
213
212
  destDir: void 0
@@ -273,14 +272,14 @@ const Gt = {
273
272
  }) : [], a = (w) => w ? Object.entries(w).flatMap(([C, J]) => Object.entries(J).flatMap(([E, O]) => {
274
273
  const nt = p(O, [C]), ot = `.${C}-${E}, [data-${C}="${E}"]`, X = nt.join("");
275
274
  return `${ot} { ${X} }`;
276
- })) : [], $ = (w) => ({ ...w, responsive: void 0, conditional: void 0 }), g = (w) => n.variables.map((C) => w === "static" ? $(C._current) : C._current[w]), r = I($(o.variables), g("static")), d = p(r), h = I((ut = o.variables) == null ? void 0 : ut.responsive, g("responsive")), x = y(h), D = I((dt = o.variables) == null ? void 0 : dt.conditional, g("conditional")), N = a(D), T = u(s, "css/_variables.css"), S = `:root { ${d.join("")} ${x.join("")} } ${N.join("")}`;
275
+ })) : [], $ = (w) => ({ ...w, responsive: void 0, conditional: void 0 }), g = (w) => n.variables.map((C) => w === "static" ? $(C._current) : C._current[w]), r = Z($(o.variables), g("static")), d = p(r), h = Z((ut = o.variables) == null ? void 0 : ut.responsive, g("responsive")), x = y(h), D = Z((dt = o.variables) == null ? void 0 : dt.conditional, g("conditional")), N = a(D), T = u(s, "css/_variables.css"), S = `:root { ${d.join("")} ${x.join("")} } ${N.join("")}`;
277
276
  k(T, S), i.staticVariables = r;
278
- const _ = u(s, "css/_global.css"), F = I(o.global, n.globalStyles), R = await L(F, "");
277
+ const _ = u(s, "css/_global.css"), F = Z(o.global, n.globalStyles), R = await L(F, "");
279
278
  k(_, `@layer global { ${R} }`);
280
279
  const l = u(s, "css/_reset.css"), b = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Gt, f = await L(b, "");
281
280
  k(l, `@layer reset { ${f} }`);
282
- const j = u(s, "css/_templates.css"), P = I(o.templates, n.templates), v = await bt(P), B = Ht(P);
283
- k(j, v), i.templates = P;
281
+ const j = u(s, "css/_templates.css"), P = Z(o.templates, n.templates), H = await bt(P), B = It(P);
282
+ k(j, H), i.templates = P;
284
283
  const G = Kt(n.templates);
285
284
  i.templatePaths = Object.fromEntries(
286
285
  Object.entries(G).map(([w, C]) => [w, C._path || "nope"])
@@ -326,8 +325,8 @@ ${t}`;
326
325
  return t;
327
326
  }
328
327
  }, et = async (t, e, s) => {
329
- const n = H(e), o = u(s, "./temp");
330
- at(o) || Z(o);
328
+ const n = I(e), o = u(s, "./temp");
329
+ at(o) || v(o);
331
330
  const i = tt(e);
332
331
  let c = V(e, "utf8");
333
332
  c = gt(c), c = Ut(c, t);
@@ -368,7 +367,7 @@ ${t}`;
368
367
  return JSON.parse(n);
369
368
  }, ft = async (t) => {
370
369
  const e = await Xt(t), s = await z(t), n = u(s, "salty.config.js"), o = Date.now(), { config: i } = await import(`${n}?t=${o}`);
371
- return I(i, e);
370
+ return Z(i, e);
372
371
  }, Pt = () => {
373
372
  try {
374
373
  return process.env.NODE_ENV === "production";
@@ -381,7 +380,7 @@ ${t}`;
381
380
  e ? it.info("Generating CSS in production mode! 🔥") : it.info("Generating CSS in development mode! 🚀");
382
381
  const o = [], i = [], c = await z(t), p = u(c, "index.css");
383
382
  s && (() => {
384
- at(c) && Dt("rm -rf " + c), Z(c, { recursive: !0 }), Z(u(c, "css")), Z(u(c, "types")), Z(u(c, "js")), Z(u(c, "cache"));
383
+ at(c) && Dt("rm -rf " + c), v(c, { recursive: !0 }), v(u(c, "css")), v(u(c, "types")), v(u(c, "js")), v(u(c, "cache"));
385
384
  })();
386
385
  const a = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Set();
387
386
  async function g(l) {
@@ -450,8 +449,8 @@ ${t}`;
450
449
  }
451
450
  d.importStrategy === "component" && Object.entries(h).forEach(([l, m]) => {
452
451
  const b = m.map((B) => `@import url('./${B}');`).join(`
453
- `), f = H(l, 6), j = tt(l), P = M(j.name), v = u(c, `css/f_${P}-${f}.css`);
454
- k(v, b);
452
+ `), f = I(l, 6), j = tt(l), P = M(j.name), H = u(c, `css/f_${P}-${f}.css`);
453
+ k(H, b);
455
454
  });
456
455
  const x = o.map((l) => `@import url('./css/${l}');`).join(`
457
456
  `);
@@ -470,15 +469,15 @@ ${x}`;
470
469
  const l = i.reduce((m, b, f) => {
471
470
  const j = b.reduce((G, K) => {
472
471
  var U;
473
- const Q = u(c, "css", K), st = V(Q, "utf8"), q = ((U = /.*-([^-]+)-\d+.css/.exec(K)) == null ? void 0 : U.at(1)) || H(Q, 6);
472
+ const Q = u(c, "css", K), st = V(Q, "utf8"), q = ((U = /.*-([^-]+)-\d+.css/.exec(K)) == null ? void 0 : U.at(1)) || I(Q, 6);
474
473
  return G.includes(q) ? G : `${G}
475
474
  /*start:${q}*/
476
475
  ${st}
477
476
  /*end:${q}*/
478
477
  `;
479
- }, ""), P = `l_${f}.css`, v = u(c, "css", P), B = `@layer l${f} { ${j}
478
+ }, ""), P = `l_${f}.css`, H = u(c, "css", P), B = `@layer l${f} { ${j}
480
479
  }`;
481
- return k(v, B), `${m}
480
+ return k(H, B), `${m}
482
481
  @import url('./css/${P}');`;
483
482
  }, "");
484
483
  S += l;
@@ -521,7 +520,7 @@ ${st}
521
520
  let g = V($, "utf8");
522
521
  p.forEach((r) => {
523
522
  var D;
524
- const d = u(s, "css", r), h = ((D = /.*-([^-]+)-\d+.css/.exec(r)) == null ? void 0 : D.at(1)) || H(d, 6);
523
+ const d = u(s, "css", r), h = ((D = /.*-([^-]+)-\d+.css/.exec(r)) == null ? void 0 : D.at(1)) || I(d, 6);
525
524
  if (!g.includes(h)) {
526
525
  const N = V(d, "utf8"), T = `/*start:${h}*/
527
526
  ${N}
@@ -535,7 +534,7 @@ ${T}
535
534
  });
536
535
  else {
537
536
  const p = o.flat().map((r) => `@import url('./${r}');`).join(`
538
- `), y = H(e, 6), a = tt(e), $ = M(a.name), g = u(s, `css/f_${$}-${y}.css`);
537
+ `), y = I(e, 6), a = tt(e), $ = M(a.name), g = u(s, `css/f_${$}-${y}.css`);
539
538
  k(g, p);
540
539
  }
541
540
  }
@@ -574,7 +573,7 @@ ${T}
574
573
  const R = D + S, l = a.slice(D, R), m = a, b = ` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;
575
574
  a = a.replace(l, b), m === a && console.error("Minimize file failed to change content", { name: $, tagName: h });
576
575
  }), p.importStrategy === "component") {
577
- const $ = H(e, 6), g = tt(e);
576
+ const $ = I(e, 6), g = tt(e);
578
577
  a = `import '../../saltygen/css/${`f_${M(g.name)}-${$}.css`}';
579
578
  ${a}`;
580
579
  }
@@ -1,40 +1,40 @@
1
- "use strict";const Pe=require("esbuild"),ke=require("child_process"),a=require("path"),u=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 me=_e(Pe),ue=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=ue(n%52)+s;return s=ue(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Oe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},I=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(s,t)};function V(e){return e?typeof e!="string"?V(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 Ee=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:l}=o;s=s.replace(i,m=>{const{value:w,css:c}=l(m);return c&&n.push(c),w})}),{transformed:s,additionalCss:n}},ye=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${V(o[1].replaceAll(".","-"))})`)},Te=ye(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(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))?`-${V(e)}`:V(e),X=async(e,t="",s)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const n=new Set,i=Object.entries(e).map(async([g,r])=>{const p=g.trim(),h=ze(p),N=(P,E=";")=>`${h}:${P}${E}`;if(typeof r=="function"&&(r=r({scope:t,config:s})),r instanceof Promise&&(r=await r),typeof r=="object"){if(!r)return;if(r.isColor)return N(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const F=Object.entries(r);for(const[D,x]of F){if(!x)return;const M=Object.entries(x);for(const[f,y]of M){if(!y)return;const b=`${t}.${D}-${f}`;(await X(y,b,s)).forEach(C=>n.add(C))}}return}if(p==="compoundVariants"){for(const F of r){const{css:D,...x}=F,M=Object.entries(x).reduce((y,[b,d])=>`${y}.${b}-${d}`,t);(await X(D,M,s)).forEach(y=>n.add(y))}return}if(p.startsWith("@")){const F=p,D=await B(r,t,s),x=`${F} { ${D} }`;n.add(x);return}const P=g.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,P,s)).forEach(F=>n.add(F));return}if(typeof r=="number"){const P=Me(h,r);return N(P)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${h}`);return N(r)}),{modifiers:l}={},m=[ye(),Ee(l)],c=(await Promise.all(i).then(g=>Promise.all(g.map(r=>m.reduce(async(p,h)=>{const N=await p;if(!N)return N;const _=await h(N);if(!_)return N;const{transformed:P,additionalCss:E}=_;let F="";if(E)for(const D of E)F+=await B(D,"");return`${F}${P}`},Promise.resolve(r)))))).join(`
1
+ "use strict";const Pe=require("esbuild"),ke=require("child_process"),a=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 me=_e(Pe),de=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=de(n%52)+s;return s=de(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Oe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},A=(e,t=5)=>{const s=Oe(5381,JSON.stringify(e))>>>0;return De(s,t)};function V(e){return e?typeof e!="string"?V(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const Te=e=>t=>{if(typeof t!="string"||!e)return;let s=t;const n=[];return Object.values(e).forEach(o=>{const{pattern:i,transform:l}=o;s=s.replace(i,m=>{const{value:w,css:c}=l(m);return c&&n.push(c),w})}),{transformed:s,additionalCss:n}},ye=e=>t=>typeof t!="string"||!/\{[^{}]+\}/g.test(t)?void 0:{transformed:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${V(o[1].replaceAll(".","-"))})`)},Ee=ye(),Ve=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Me=(e,t,s)=>Ve.some(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))?`-${V(e)}`:V(e),X=async(e,t="",s)=>{if(!e)throw new Error("No styles provided to parseStyles function!");const n=new Set,i=Object.entries(e).map(async([g,r])=>{const p=g.trim(),h=ze(p),N=(P,T=";")=>`${h}:${P}${T}`;if(typeof r=="function"&&(r=r({scope:t,config:s})),r instanceof Promise&&(r=await r),typeof r=="object"){if(!r)return;if(r.isColor)return N(r.toString());if(p==="defaultVariants")return;if(p==="variants"){const F=Object.entries(r);for(const[D,x]of F){if(!x)return;const M=Object.entries(x);for(const[f,y]of M){if(!y)return;const b=`${t}.${D}-${f}`;(await X(y,b,s)).forEach(C=>n.add(C))}}return}if(p==="compoundVariants"){for(const F of r){const{css:D,...x}=F,M=Object.entries(x).reduce((y,[b,u])=>`${y}.${b}-${u}`,t);(await X(D,M,s)).forEach(y=>n.add(y))}return}if(p.startsWith("@")){const F=p,D=await B(r,t,s),x=`${F} { ${D} }`;n.add(x);return}const P=g.includes("&")?p.replace("&",t):p.startsWith(":")?`${t}${p}`:`${t} ${p}`;(await X(r,P,s)).forEach(F=>n.add(F));return}if(typeof r=="number"){const P=Me(h,r);return N(P)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${h}`);return N(r)}),{modifiers:l}={},m=[ye(),Te(l)],c=(await Promise.all(i).then(g=>Promise.all(g.map(r=>m.reduce(async(p,h)=>{const N=await p;if(!N)return N;const _=await h(N);if(!_)return N;const{transformed:P,additionalCss:T}=_;let F="";if(T)for(const D of T)F+=await B(D,"");return`${F}${P}`},Promise.resolve(r)))))).join(`
2
2
  `);if(!c.trim())return n;const $=t?`${t} { ${c} }`:c;return n.add($),n},B=async(e,t,s)=>[...await X(e,t,s)].join(`
3
- `),ge=async(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(async([o,i])=>{if(typeof i=="function")return console.log("Function found",o);if(typeof i=="object"){if(!i)return;const l=o.trim(),m=await ge(i,[...t,l]);s.push(m)}else n[o]=i}),Object.keys(n).length){const o=t.map(V).join("-"),i=await B(n,`.${o}`);s.push(i)}return s.join(`
4
- `)},Je=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=he(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},he=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?he(o,i,s):s.add(t)}),[...s]):[],we=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return u.existsSync(t)?t:we(a.join(e,".."))},We=async e=>{const t=we(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Ae=async e=>{const t=await We(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await Ae(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-9FkG6tDd.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function be(e){return e?typeof e!="string"?be(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Ie={"*, *::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"}},A=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),Ze=(...e)=>e.flat().reduce((t,s)=>({...t,...s._children}),{}),z={externalModules:[],rcFile:void 0,destDir:void 0},Se=e=>{if(z.externalModules.length>0)return z.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 z.externalModules=n,n},J=async e=>{if(z.destDir)return z.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},je=["salty","css","styles","styled"],Fe=(e=[])=>new RegExp(`\\.(${[...je,...e].join("|")})\\.`),Y=(e,t=[])=>Fe(t).test(e),Ce=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Ce(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ce(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},qe=async e=>{const t=await ce(e),s=await J(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await $e(e),l=Se(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:l});const m=Date.now(),{config:w}=await import(`${o}?t=${m}`);return w},ve=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:j,outputFilePath:R}=await ee(e,S,s);Object.entries(j).forEach(([O,T])=>{T.isMedia?n.mediaQueries.push([O,T]):T.isGlobalDefine?n.globalStyles.push(T):T.isDefineVariables?n.variables.push(T):T.isDefineTemplates&&n.templates.push(T._setPath(R))})}));const o=await qe(e),i={...o},l=new Set,m=(S,j=[])=>S?Object.entries(S).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return m(O,[...j,R]);const T=be(R),se=V(R),ne=[...j,T].join(".");l.add(`"${ne}"`);const U=[...j.map(V),se].join("-"),de=Te(O);return de?`--${U}: ${de.transformed};`:`--${U}: ${O};`}):[],w=S=>S?Object.entries(S).flatMap(([j,R])=>{const O=m(R);return j==="base"?O.join(""):`${j} { ${O.join("")} }`}):[],c=S=>S?Object.entries(S).flatMap(([j,R])=>Object.entries(R).flatMap(([O,T])=>{const se=m(T,[j]),ne=`.${j}-${O}, [data-${j}="${O}"]`,U=se.join("");return`${ne} { ${U} }`})):[],$=S=>({...S,responsive:void 0,conditional:void 0}),g=S=>n.variables.map(j=>S==="static"?$(j._current):j._current[S]),r=A($(o.variables),g("static")),p=m(r),h=A((le=o.variables)==null?void 0:le.responsive,g("responsive")),N=w(h),_=A((fe=o.variables)==null?void 0:fe.conditional,g("conditional")),P=c(_),E=a.join(s,"css/_variables.css"),F=`:root { ${p.join("")} ${N.join("")} } ${P.join("")}`;u.writeFileSync(E,F),i.staticVariables=r;const D=a.join(s,"css/_global.css"),x=A(o.global,n.globalStyles),M=await B(x,"");u.writeFileSync(D,`@layer global { ${M} }`);const f=a.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ie,d=await B(b,"");u.writeFileSync(f,`@layer reset { ${d} }`);const C=a.join(s,"css/_templates.css"),k=A(o.templates,n.templates),Z=await ge(k),q=Je(k);u.writeFileSync(C,Z),i.templates=k;const v=Ze(n.templates);i.templatePaths=Object.fromEntries(Object.entries(v).map(([S,j])=>[S,j._path||"nope"]));const{mediaQueries:H}=n;i.mediaQueries=Object.fromEntries(H.map(([S,j])=>[`@${S}`,j]));const G=H.map(([S])=>`'@${S}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
3
+ `),ge=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,i]of Object.entries(e))if(typeof i=="function")console.log("Function found",o);else if(i&&typeof i=="object"){const l=o.trim(),m=await ge(i,[...t,l]);s.push(m)}else n[o]=i;if(Object.keys(n).length){const o=t.map(V).join("-"),i=await B(n,`.${o}`);s.push(i)}return s.join(`
4
+ `)},Je=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=he(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},he=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const i=t?`${t}.${n}`:n;return typeof o=="object"?he(o,i,s):s.add(t)}),[...s]):[],we=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=a.join(e,"package.json");return d.existsSync(t)?t:we(a.join(e,".."))},We=async e=>{const t=we(e);return await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ve=async e=>{const t=await We(e);if(t)return t.type};let W;const $e=async e=>{if(W)return W;const t=await ve(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("index-BvNnzbqp.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},re=L.createLogger({level:"debug",format:L.format.combine(L.format.colorize(),L.format.cli()),transports:[new L.transports.Console({})]});function be(e){return e?typeof e!="string"?be(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const Ae={"*, *::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"}},v=(...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}),{}),z={externalModules:[],rcFile:void 0,destDir:void 0},Se=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},J=async e=>{if(z.destDir)return z.destDir;const t=await ce(e),s=a.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return z.destDir=s,s},je=["salty","css","styles","styled"],Fe=(e=[])=>new RegExp(`\\.(${[...je,...e].join("|")})\\.`),Y=(e,t=[])=>Fe(t).test(e),Ce=async e=>{if(z.rcFile)return z.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=a.join(e,".saltyrc.json"),s=await ie.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Ce(a.join(e,".."))},ce=async e=>{var n,o;const t=await Ce(e),s=(n=t.projects)==null?void 0:n.find(i=>e.endsWith(i.dir||""));return s||((o=t.projects)==null?void 0:o.find(i=>i.dir===t.defaultProject))},Ze=async e=>{const t=await ce(e),s=await J(e),n=a.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=a.join(s,"salty.config.js"),i=await $e(e),l=Se(n);await me.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:i,external:l});const m=Date.now(),{config:w}=await import(`${o}?t=${m}`);return w},qe=async(e,t)=>{var le,fe;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async S=>{const{contents:j,outputFilePath:R}=await ee(e,S,s);Object.entries(j).forEach(([O,E])=>{E.isMedia?n.mediaQueries.push([O,E]):E.isGlobalDefine?n.globalStyles.push(E):E.isDefineVariables?n.variables.push(E):E.isDefineTemplates&&n.templates.push(E._setPath(R))})}));const o=await Ze(e),i={...o},l=new Set,m=(S,j=[])=>S?Object.entries(S).flatMap(([R,O])=>{if(!O)return;if(typeof O=="object")return m(O,[...j,R]);const E=be(R),se=V(R),ne=[...j,E].join(".");l.add(`"${ne}"`);const U=[...j.map(V),se].join("-"),ue=Ee(O);return ue?`--${U}: ${ue.transformed};`:`--${U}: ${O};`}):[],w=S=>S?Object.entries(S).flatMap(([j,R])=>{const O=m(R);return j==="base"?O.join(""):`${j} { ${O.join("")} }`}):[],c=S=>S?Object.entries(S).flatMap(([j,R])=>Object.entries(R).flatMap(([O,E])=>{const se=m(E,[j]),ne=`.${j}-${O}, [data-${j}="${O}"]`,U=se.join("");return`${ne} { ${U} }`})):[],$=S=>({...S,responsive:void 0,conditional:void 0}),g=S=>n.variables.map(j=>S==="static"?$(j._current):j._current[S]),r=v($(o.variables),g("static")),p=m(r),h=v((le=o.variables)==null?void 0:le.responsive,g("responsive")),N=w(h),_=v((fe=o.variables)==null?void 0:fe.conditional,g("conditional")),P=c(_),T=a.join(s,"css/_variables.css"),F=`:root { ${p.join("")} ${N.join("")} } ${P.join("")}`;d.writeFileSync(T,F),i.staticVariables=r;const D=a.join(s,"css/_global.css"),x=v(o.global,n.globalStyles),M=await B(x,"");d.writeFileSync(D,`@layer global { ${M} }`);const f=a.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ae,u=await B(b,"");d.writeFileSync(f,`@layer reset { ${u} }`);const C=a.join(s,"css/_templates.css"),k=v(o.templates,n.templates),I=await ge(k),Z=Je(k);d.writeFileSync(C,I),i.templates=k;const q=Ie(n.templates);i.templatePaths=Object.fromEntries(Object.entries(q).map(([S,j])=>[S,j._path||"nope"]));const{mediaQueries:H}=n;i.mediaQueries=Object.fromEntries(H.map(([S,j])=>[`@${S}`,j]));const G=H.map(([S])=>`'@${S}'`).join(" | "),te=a.join(s,"types/css-tokens.d.ts"),Q=`
5
5
  // Variable types
6
6
  type VariableTokens = ${[...l].join("|")};
7
7
  type PropertyValueToken = \`{\${VariableTokens}}\`;
8
8
 
9
9
  // Template types
10
10
  type TemplateTokens = {
11
- ${Object.entries(q).map(([S,j])=>`${S}?: ${j}`).join(`
11
+ ${Object.entries(Z).map(([S,j])=>`${S}?: ${j}`).join(`
12
12
  `)}
13
13
  }
14
14
 
15
15
  // Media query types
16
16
  type MediaQueryKeys = ${G||"''"};
17
- `;u.writeFileSync(te,Q);const Ne=a.join(s,"cache/config-cache.json");u.writeFileSync(Ne,JSON.stringify(i,null,2))},pe=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 l=o.exec(e);if(l){const m=l.at(1);if(je.some(c=>m==null?void 0:m.includes(c)))return t}return"styled('div',"}),He=(e,t)=>{try{const s=u.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
17
+ `;d.writeFileSync(te,Q);const Ne=a.join(s,"cache/config-cache.json");d.writeFileSync(Ne,JSON.stringify(i,null,2))},pe=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const l=o.exec(e);if(l){const m=l.at(1);if(je.some(c=>m==null?void 0:m.includes(c)))return t}return"styled('div',"}),He=(e,t)=>{try{const s=d.readFileSync(a.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
18
18
 
19
19
  ${e}`:`globalThis.saltyConfig = {};
20
20
 
21
- ${e}`}catch{return e}},ee=async(e,t,s)=>{const n=I(t),o=a.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=a.parse(t);let l=u.readFileSync(t,"utf8");l=pe(l),l=He(l,e);const m=a.join(s,"js",n+".js"),w=await ce(e),c=a.join(e,(w==null?void 0:w.configDir)||"","salty.config.ts"),$=Se(c),g=await $e(e);await me.build({stdin:{contents:l,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:$,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},N=>{const _=u.readFileSync(N.path,"utf8");return{contents:pe(_),loader:"ts"}})}}]});const r=Date.now();return{contents:await import(`${m}?t=${r}`),outputFilePath:m}},Le=async e=>{const t=await J(e),s=a.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)},ae=async e=>{const t=await Le(e),s=await J(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return A(i,t)},xe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=xe(),s=!0)=>{try{const n=Date.now();t?re.info("Generating CSS in production mode! 🔥"):re.info("Generating CSS in development mode! 🚀");const o=[],i=[],l=await J(e),m=a.join(l,"index.css");s&&(()=>{u.existsSync(l)&&ke.execSync("rm -rf "+l),u.mkdirSync(l,{recursive:!0}),u.mkdirSync(a.join(l,"css")),u.mkdirSync(a.join(l,"types")),u.mkdirSync(a.join(l,"js")),u.mkdirSync(a.join(l,"cache"))})();const c=new Set,$=new Set;async function g(f){const y=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(y.some(k=>f.includes(k)))return;await Promise.all(d.map(k=>g(a.join(f,k))))}else if(b.isFile()&&Y(f)){c.add(f);const C=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&$.add(f)}}await g(e),await ve(e,$);const r={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const{contents:y}=await ee(e,f,l);Object.entries(y).forEach(([b,d])=>{d.isKeyframes?r.keyframes.push({value:d,src:f,name:b}):d.isClassName?r.classNames.push({...d,src:f,name:b}):d.generator&&r.components.push({...d,src:f,name:b})})}));const p=await ae(e);for(const f of r.keyframes){const{value:y}=f,b=`a_${y.animationName}.css`,d=`css/${b}`,C=a.join(l,d);o.push(b),u.writeFileSync(C,y.css)}const h={};for(const f of r.components){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[d.priority]||(i[d.priority]=[]),i[d.priority].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}for(const f of r.classNames){const{src:y,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[0].push(d.cssFileName);const C=`css/${d.cssFileName}`,k=a.join(l,C);u.writeFileSync(k,await d.css),p.importStrategy==="component"&&(h[y]?h[y].push(d.cssFileName):h[y]=[d.cssFileName])}p.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const b=y.map(q=>`@import url('./${q}');`).join(`
22
- `),d=I(f,6),C=a.parse(f),k=V(C.name),Z=a.join(l,`css/f_${k}-${d}.css`);u.writeFileSync(Z,b)});const N=o.map(f=>`@import url('./css/${f}');`).join(`
21
+ ${e}`}catch{return e}},ee=async(e,t,s)=>{const n=A(t),o=a.join(s,"./temp");d.existsSync(o)||d.mkdirSync(o);const i=a.parse(t);let l=d.readFileSync(t,"utf8");l=pe(l),l=He(l,e);const m=a.join(s,"js",n+".js"),w=await ce(e),c=a.join(e,(w==null?void 0:w.configDir)||"","salty.config.ts"),$=Se(c),g=await $e(e);await me.build({stdin:{contents:l,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:$,packages:"external",plugins:[{name:"test",setup:h=>{h.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},N=>{const _=d.readFileSync(N.path,"utf8");return{contents:pe(_),loader:"ts"}})}}]});const r=Date.now();return{contents:await import(`${m}?t=${r}`),outputFilePath:m}},Le=async e=>{const t=await J(e),s=a.join(t,"cache/config-cache.json"),n=d.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ae=async e=>{const t=await Le(e),s=await J(e),n=a.join(s,"salty.config.js"),o=Date.now(),{config:i}=await import(`${n}?t=${o}`);return v(i,t)},xe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Be=async(e,t=xe(),s=!0)=>{try{const n=Date.now();t?re.info("Generating CSS in production mode! 🔥"):re.info("Generating CSS in development mode! 🚀");const o=[],i=[],l=await J(e),m=a.join(l,"index.css");s&&(()=>{d.existsSync(l)&&ke.execSync("rm -rf "+l),d.mkdirSync(l,{recursive:!0}),d.mkdirSync(a.join(l,"css")),d.mkdirSync(a.join(l,"types")),d.mkdirSync(a.join(l,"js")),d.mkdirSync(a.join(l,"cache"))})();const c=new Set,$=new Set;async function g(f){const y=["node_modules","saltygen"],b=d.statSync(f);if(b.isDirectory()){const u=d.readdirSync(f);if(y.some(k=>f.includes(k)))return;await Promise.all(u.map(k=>g(a.join(f,k))))}else if(b.isFile()&&Y(f)){c.add(f);const C=d.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&$.add(f)}}await g(e),await qe(e,$);const r={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const{contents:y}=await ee(e,f,l);Object.entries(y).forEach(([b,u])=>{u.isKeyframes?r.keyframes.push({value:u,src:f,name:b}):u.isClassName?r.classNames.push({...u,src:f,name:b}):u.generator&&r.components.push({...u,src:f,name:b})})}));const p=await ae(e);for(const f of r.keyframes){const{value:y}=f,b=`a_${y.animationName}.css`,u=`css/${b}`,C=a.join(l,u);o.push(b),d.writeFileSync(C,y.css)}const h={};for(const f of r.components){const{src:y,name:b}=f,u=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[u.priority]||(i[u.priority]=[]),i[u.priority].push(u.cssFileName);const C=`css/${u.cssFileName}`,k=a.join(l,C);d.writeFileSync(k,await u.css),p.importStrategy==="component"&&(h[y]?h[y].push(u.cssFileName):h[y]=[u.cssFileName])}for(const f of r.classNames){const{src:y,name:b}=f,u=f.generator._withBuildContext({callerName:b,isProduction:t,config:p});i[0].push(u.cssFileName);const C=`css/${u.cssFileName}`,k=a.join(l,C);d.writeFileSync(k,await u.css),p.importStrategy==="component"&&(h[y]?h[y].push(u.cssFileName):h[y]=[u.cssFileName])}p.importStrategy==="component"&&Object.entries(h).forEach(([f,y])=>{const b=y.map(Z=>`@import url('./${Z}');`).join(`
22
+ `),u=A(f,6),C=a.parse(f),k=V(C.name),I=a.join(l,`css/f_${k}-${u}.css`);d.writeFileSync(I,b)});const N=o.map(f=>`@import url('./css/${f}');`).join(`
23
23
  `);let F=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
24
24
 
25
- ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(a.join(l,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
25
+ ${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return d.readFileSync(a.join(l,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
26
26
  `)}
27
- ${N}`;if(p.importStrategy!=="component"){const f=i.reduce((y,b,d)=>{const C=b.reduce((v,H)=>{var Q;const G=a.join(l,"css",H),te=u.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:Q.at(1))||I(G,6);return v.includes(K)?v:`${v}
27
+ ${N}`;if(p.importStrategy!=="component"){const f=i.reduce((y,b,u)=>{const C=b.reduce((q,H)=>{var Q;const G=a.join(l,"css",H),te=d.readFileSync(G,"utf8"),K=((Q=/.*-([^-]+)-\d+.css/.exec(H))==null?void 0:Q.at(1))||A(G,6);return q.includes(K)?q:`${q}
28
28
  /*start:${K}*/
29
29
  ${te}
30
30
  /*end:${K}*/
31
- `},""),k=`l_${d}.css`,Z=a.join(l,"css",k),q=`@layer l${d} { ${C}
32
- }`;return u.writeFileSync(Z,q),`${y}
33
- @import url('./css/${k}');`},"");F+=f}u.writeFileSync(m,F);const x=Date.now()-n,M=x<200?"🔥":x<500?"🚀":x<1e3?"🎉":x<2e3?"🚗":x<5e3?"🤔":"🥴";re.info(`Generated CSS in ${x}ms! ${M}`)}catch(n){console.error(n)}},Ge=async(e,t)=>{try{const s=await J(e);if(Y(t)){const o=[],i=await ae(e),{contents:l}=await ee(e,t,s);for(const[m,w]of Object.entries(l)){if(w.isKeyframes&&w.css){const p=`css/${`a_${w.animationName}.css`}`,h=a.join(s,p);u.writeFileSync(h,await w.css);return}if(w.isClassName){const r=w.factory._withBuildContext({name:m});o[0].push(r.cssFileName);const p=`css/${r.cssFileName}`,h=a.join(s,p);u.writeFileSync(h,await r.css)}if(!w.generator)return;const c=w.generator._withBuildContext({name:m,config:i}),$=`css/${c.cssFileName}`,g=a.join(s,$);u.writeFileSync(g,await c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}if(i.importStrategy!=="component")o.forEach((m,w)=>{const c=`l_${w}.css`,$=a.join(s,"css",c);let g=u.readFileSync($,"utf8");m.forEach(r=>{var _;const p=a.join(s,"css",r),h=((_=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:_.at(1))||I(p,6);if(!g.includes(h)){const P=u.readFileSync(p,"utf8"),E=`/*start:${h}*/
31
+ `},""),k=`l_${u}.css`,I=a.join(l,"css",k),Z=`@layer l${u} { ${C}
32
+ }`;return d.writeFileSync(I,Z),`${y}
33
+ @import url('./css/${k}');`},"");F+=f}d.writeFileSync(m,F);const x=Date.now()-n,M=x<200?"🔥":x<500?"🚀":x<1e3?"🎉":x<2e3?"🚗":x<5e3?"🤔":"🥴";re.info(`Generated CSS in ${x}ms! ${M}`)}catch(n){console.error(n)}},Ge=async(e,t)=>{try{const s=await J(e);if(Y(t)){const o=[],i=await ae(e),{contents:l}=await ee(e,t,s);for(const[m,w]of Object.entries(l)){if(w.isKeyframes&&w.css){const p=`css/${`a_${w.animationName}.css`}`,h=a.join(s,p);d.writeFileSync(h,await w.css);return}if(w.isClassName){const r=w.factory._withBuildContext({name:m});o[0].push(r.cssFileName);const p=`css/${r.cssFileName}`,h=a.join(s,p);d.writeFileSync(h,await r.css)}if(!w.generator)return;const c=w.generator._withBuildContext({name:m,config:i}),$=`css/${c.cssFileName}`,g=a.join(s,$);d.writeFileSync(g,await c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}if(i.importStrategy!=="component")o.forEach((m,w)=>{const c=`l_${w}.css`,$=a.join(s,"css",c);let g=d.readFileSync($,"utf8");m.forEach(r=>{var _;const p=a.join(s,"css",r),h=((_=/.*-([^-]+)-\d+.css/.exec(r))==null?void 0:_.at(1))||A(p,6);if(!g.includes(h)){const P=d.readFileSync(p,"utf8"),T=`/*start:${h}*/
34
34
  ${P}
35
35
  /*end:${h}*/
36
36
  `;g=`${g.replace(/\}$/,"")}
37
- ${E}
38
- }`}}),u.writeFileSync($,g)});else{const m=o.flat().map(r=>`@import url('./${r}');`).join(`
39
- `),w=I(t,6),c=a.parse(t),$=V(c.name),g=a.join(s,`css/f_${$}-${w}.css`);u.writeFileSync(g,m)}}}catch(s){console.error(s)}},Ke=async(e,t,s=xe())=>{try{const n=await J(e);if(Y(t)){const i=u.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,$=>`export ${$}`)!==i&&await ie.writeFile(t,i);const m=await ae(e),{contents:w}=await ee(e,t,n);let c=i;if(Object.entries(w).forEach(([$,g])=>{var d;if(g.isKeyframes||!g.generator)return;const r=g.generator._withBuildContext({name:$,config:m,prod:s}),p=new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!p)return console.error("Could not find the original declaration");const h=(d=p.at(1))==null?void 0:d.trim(),N=new RegExp(`\\s${$}[=\\s]+styled\\(`,"g").exec(c);if(!N)return console.error("Could not find the original declaration");const{index:_}=N;let P=!1;const E=setTimeout(()=>P=!0,5e3);let F=0,D=!1,x=0;for(;!D&&!P;){const C=c[_+F];C==="("&&x++,C===")"&&x--,x===0&&C===")"&&(D=!0),F>c.length&&(P=!0),F++}if(!P)clearTimeout(E);else throw new Error("Failed to find the end of the styled call and timed out");const M=_+F,f=c.slice(_,M),y=c,b=` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;c=c.replace(f,b),y===c&&console.error("Minimize file failed to change content",{name:$,tagName:h})}),m.importStrategy==="component"){const $=I(t,6),g=a.parse(t);c=`import '../../saltygen/css/${`f_${V(g.name)}-${$}.css`}';
37
+ ${T}
38
+ }`}}),d.writeFileSync($,g)});else{const m=o.flat().map(r=>`@import url('./${r}');`).join(`
39
+ `),w=A(t,6),c=a.parse(t),$=V(c.name),g=a.join(s,`css/f_${$}-${w}.css`);d.writeFileSync(g,m)}}}catch(s){console.error(s)}},Ke=async(e,t,s=xe())=>{try{const n=await J(e);if(Y(t)){const i=d.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,$=>`export ${$}`)!==i&&await ie.writeFile(t,i);const m=await ae(e),{contents:w}=await ee(e,t,n);let c=i;if(Object.entries(w).forEach(([$,g])=>{var u;if(g.isKeyframes||!g.generator)return;const r=g.generator._withBuildContext({name:$,config:m,prod:s}),p=new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!p)return console.error("Could not find the original declaration");const h=(u=p.at(1))==null?void 0:u.trim(),N=new RegExp(`\\s${$}[=\\s]+styled\\(`,"g").exec(c);if(!N)return console.error("Could not find the original declaration");const{index:_}=N;let P=!1;const T=setTimeout(()=>P=!0,5e3);let F=0,D=!1,x=0;for(;!D&&!P;){const C=c[_+F];C==="("&&x++,C===")"&&x--,x===0&&C===")"&&(D=!0),F>c.length&&(P=!0),F++}if(!P)clearTimeout(T);else throw new Error("Failed to find the end of the styled call and timed out");const M=_+F,f=c.slice(_,M),y=c,b=` ${$} = styled(${h}, "${r.classNames}", ${JSON.stringify(r.clientProps)});`;c=c.replace(f,b),y===c&&console.error("Minimize file failed to change content",{name:$,tagName:h})}),m.importStrategy==="component"){const $=A(t,6),g=a.parse(t);c=`import '../../saltygen/css/${`f_${V(g.name)}-${$}.css`}';
40
40
  ${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=Be;exports.generateFile=Ge;exports.isSaltyFile=Y;exports.minimizeFile=Ke;exports.saltyFileRegExp=Fe;
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-9FkG6tDd.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-BvNnzbqp.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-kVXKDkbs.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-BhdhQhTB.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-9FkG6tDd.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-BvNnzbqp.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-kVXKDkbs.js";
1
+ import { a as e, m as i } from "./index-BhdhQhTB.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.202",
3
+ "version": "0.0.1-alpha.203",
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.202",
37
+ "@salty-css/core": "^0.0.1-alpha.203",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }