@salty-css/webpack 0.0.1-alpha.106 → 0.0.1-alpha.107

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 L from "esbuild";
2
2
  import { execSync as ot } from "child_process";
3
3
  import { join as f, parse as rt } from "path";
4
- import { existsSync as W, writeFileSync as P, readFileSync as N, mkdirSync as J, statSync as ct, readdirSync as it } from "fs";
4
+ import { existsSync as W, writeFileSync as P, readFileSync as N, mkdirSync as J, statSync as it, readdirSync as ct } from "fs";
5
5
  import { readFile as at, writeFile as lt } from "fs/promises";
6
6
  import { createLogger as ft, format as R, transports as pt } from "winston";
7
7
  const H = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), ut = (t, e) => {
@@ -24,21 +24,21 @@ const dt = (t, e) => {
24
24
  if (!e) return { result: t };
25
25
  const s = [];
26
26
  return Object.values(e).forEach((n) => {
27
- const { pattern: o, transform: c } = n;
27
+ const { pattern: o, transform: i } = n;
28
28
  t = t.replace(o, (g) => {
29
- const { value: a, css: h } = c(g);
29
+ const { value: a, css: h } = i(g);
30
30
  return h && s.push(h), a;
31
31
  });
32
32
  }), { result: t, additionalCss: s };
33
33
  }, q = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) } : { result: t }, D = (t, e, s, n) => {
34
34
  if (!t) return "";
35
- const o = [], c = Object.entries(t).reduce((a, [h, r]) => {
35
+ const o = [], i = Object.entries(t).reduce((a, [h, r]) => {
36
36
  const u = h.trim();
37
37
  if (typeof r == "function" && (r = r()), typeof r == "object") {
38
38
  if (!r) return a;
39
39
  if (u === "variants")
40
- return Object.entries(r).forEach(([j, i]) => {
41
- i && Object.entries(i).forEach(([p, y]) => {
40
+ return Object.entries(r).forEach(([j, c]) => {
41
+ c && Object.entries(c).forEach(([p, y]) => {
42
42
  if (!y) return;
43
43
  const m = `${e}.${j}-${p}`, F = D(y, m);
44
44
  o.push(F);
@@ -48,16 +48,16 @@ const dt = (t, e) => {
48
48
  return a;
49
49
  if (u === "compoundVariants")
50
50
  return r.forEach((j) => {
51
- const { css: i, ...p } = j, y = Object.entries(p).reduce((F, [w, S]) => `${F}.${w}-${S}`, e), m = D(i, y);
51
+ const { css: c, ...p } = j, y = Object.entries(p).reduce((F, [w, S]) => `${F}.${w}-${S}`, e), m = D(c, y);
52
52
  o.push(m);
53
53
  }), a;
54
54
  if (u.startsWith("@")) {
55
- const j = D(r, e), i = `${u} {
55
+ const j = D(r, e), c = `${u} {
56
56
  ${j.replace(`
57
57
  `, `
58
58
  `)}
59
59
  }`;
60
- return o.push(i), a;
60
+ return o.push(c), a;
61
61
  }
62
62
  const d = h.includes("&") ? u.replace("&", e) : u.startsWith(":") ? `${e}${u}` : `${e} ${u}`, b = D(r, d);
63
63
  return o.push(b), a;
@@ -72,36 +72,36 @@ const dt = (t, e) => {
72
72
  }();
73
73
  for (const { result: d, additionalCss: b = [] } of T)
74
74
  r = d, b.forEach((j) => {
75
- const i = D(j, "");
76
- k(i, "");
75
+ const c = D(j, "");
76
+ k(c, "");
77
77
  });
78
78
  return C(r);
79
79
  }, "");
80
- if (!c) return o.join(`
80
+ if (!i) return o.join(`
81
81
  `);
82
- if (!e) return c;
82
+ if (!e) return i;
83
83
  let g = "";
84
- return g = `${e} { ${c} }`, [g, ...o].join(`
84
+ return g = `${e} { ${i} }`, [g, ...o].join(`
85
85
  `);
86
86
  }, U = (t, e = []) => {
87
87
  if (!t) return "";
88
88
  const s = [], n = {};
89
- if (Object.entries(t).forEach(([o, c]) => {
90
- if (typeof c == "object") {
91
- if (!c) return;
92
- const g = o.trim(), a = U(c, [...e, g]);
89
+ if (Object.entries(t).forEach(([o, i]) => {
90
+ if (typeof i == "object") {
91
+ if (!i) return;
92
+ const g = o.trim(), a = U(i, [...e, g]);
93
93
  s.push(a);
94
94
  } else
95
- n[o] = c;
95
+ n[o] = i;
96
96
  }), Object.keys(n).length) {
97
- const o = e.map(V).join("-"), c = D(n, `.${o}`);
98
- s.push(c);
97
+ const o = e.map(V).join("-"), i = D(n, `.${o}`);
98
+ s.push(i);
99
99
  }
100
100
  return s.join(`
101
101
  `);
102
102
  }, yt = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = X(n).map((o) => `"${o}"`).join(" | ")), e), {}), X = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
103
- const c = e ? `${e}.${n}` : n;
104
- return typeof o == "object" ? X(o, c, s) : s.add(e);
103
+ const i = e ? `${e}.${n}` : n;
104
+ return typeof o == "object" ? X(o, i, s) : s.add(e);
105
105
  }), [...s]) : [], Y = (t) => {
106
106
  if (!t || t === "/") throw new Error("Could not find package.json file");
107
107
  const e = f(t, "package.json");
@@ -130,10 +130,10 @@ const Q = async (t) => {
130
130
  if (_.externalModules.length > 0) return _.externalModules;
131
131
  const e = f(t, "salty.config.ts"), n = N(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
132
132
  if (!n) return [];
133
- const o = n[1].split(",").map((c) => c.replace(/['"`]/g, "").trim());
133
+ const o = n[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
134
134
  return _.externalModules = o, o;
135
135
  }, A = (t) => f(t, "./saltygen"), $t = ["salty", "css", "styles", "styled"], bt = (t = []) => new RegExp(`\\.(${[...$t, ...t].join("|")})\\.`), I = (t, e = []) => bt(e).test(t), jt = async (t) => {
136
- const e = A(t), s = f(t, "salty.config.ts"), n = f(e, "salty.config.js"), o = await Q(t), c = v(t);
136
+ const e = A(t), s = f(t, "salty.config.ts"), n = f(e, "salty.config.js"), o = await Q(t), i = v(t);
137
137
  await L.build({
138
138
  entryPoints: [s],
139
139
  minify: !0,
@@ -141,30 +141,30 @@ const Q = async (t) => {
141
141
  bundle: !0,
142
142
  outfile: n,
143
143
  format: o,
144
- external: c
144
+ external: i
145
145
  });
146
146
  const g = Date.now(), { config: a } = await import(`${n}?t=${g}`);
147
147
  return a;
148
148
  }, wt = async (t) => {
149
- const e = await jt(t), s = /* @__PURE__ */ new Set(), n = (i, p = []) => i ? Object.entries(i).flatMap(([y, m]) => {
149
+ const e = await jt(t), s = /* @__PURE__ */ new Set(), n = (c, p = []) => c ? Object.entries(c).flatMap(([y, m]) => {
150
150
  if (!m) return;
151
151
  if (typeof m == "object") return n(m, [...p, y]);
152
152
  const F = [...p, y].join(".");
153
153
  s.add(`"${F}"`);
154
154
  const w = [...p.map(V), V(y)].join("-"), { result: S } = q(m);
155
155
  return `--${w}: ${S};`;
156
- }) : [], o = (i) => i ? Object.entries(i).flatMap(([p, y]) => {
156
+ }) : [], o = (c) => c ? Object.entries(c).flatMap(([p, y]) => {
157
157
  const m = n(y);
158
158
  return p === "base" ? m.join("") : `${p} { ${m.join("")} }`;
159
- }) : [], c = (i) => i ? Object.entries(i).flatMap(([p, y]) => Object.entries(y).flatMap(([m, F]) => {
159
+ }) : [], i = (c) => c ? Object.entries(c).flatMap(([p, y]) => Object.entries(y).flatMap(([m, F]) => {
160
160
  const w = n(F, [p]), S = `.${p}-${m}, [data-${p}="${m}"]`, E = w.join("");
161
161
  return `${S} { ${E} }`;
162
- })) : [], g = n(e.variables), a = o(e.responsiveVariables), h = c(e.conditionalVariables), r = A(t), u = f(r, "css/variables.css"), $ = `:root { ${g.join("")} ${a.join("")} } ${h.join("")}`;
162
+ })) : [], g = n(e.variables), a = o(e.responsiveVariables), h = i(e.conditionalVariables), r = A(t), u = f(r, "css/variables.css"), $ = `:root { ${g.join("")} ${a.join("")} } ${h.join("")}`;
163
163
  P(u, $);
164
164
  const k = f(r, "css/global.css"), C = D(e.global, "");
165
165
  P(k, C);
166
166
  const l = f(r, "css/templates.css"), x = U(e.templates), T = yt(e.templates);
167
- console.log(T), P(l, x);
167
+ P(l, x);
168
168
  const d = f(r, "types/css-tokens.d.ts"), j = `
169
169
  // Variable types
170
170
  type VariableTokens = ${[...s].join("|")};
@@ -172,7 +172,7 @@ const Q = async (t) => {
172
172
 
173
173
  // Template types
174
174
  type TemplateTokens = {
175
- ${Object.entries(T).map(([i, p]) => `${i}?: ${p}`).join(`
175
+ ${Object.entries(T).map(([c, p]) => `${c}?: ${p}`).join(`
176
176
  `)}
177
177
  }
178
178
  `;
@@ -180,15 +180,15 @@ const Q = async (t) => {
180
180
  }, Z = async (t, e, s) => {
181
181
  const n = B(e), o = f(s, "./temp");
182
182
  W(o) || J(o);
183
- const c = rt(e);
183
+ const i = rt(e);
184
184
  let g = N(e, "utf8");
185
185
  g = g.replace(/styled\([^"'`{,]+,/g, "styled('div',");
186
186
  const a = f(s, "js", n + ".js"), h = v(t), r = await Q(t);
187
187
  await L.build({
188
188
  stdin: {
189
189
  contents: g,
190
- sourcefile: c.base,
191
- resolveDir: c.dir,
190
+ sourcefile: i.base,
191
+ resolveDir: i.dir,
192
192
  loader: "ts"
193
193
  },
194
194
  minify: !1,
@@ -215,19 +215,19 @@ const Q = async (t) => {
215
215
  }, Tt = async (t, e = tt()) => {
216
216
  try {
217
217
  e ? K.info("Generating CSS in production mode! 🔥") : K.info("Generating CSS in development mode! 🚀");
218
- const s = [], n = [], o = A(t), c = f(o, "index.css");
218
+ const s = [], n = [], o = A(t), i = f(o, "index.css");
219
219
  (() => {
220
220
  W(o) && ot("rm -rf " + o), J(o), J(f(o, "css")), J(f(o, "types"));
221
221
  })(), await wt(t);
222
222
  const a = await z(t);
223
223
  async function h(l, x) {
224
- const T = ["node_modules", "saltygen"], d = ct(l);
224
+ const T = ["node_modules", "saltygen"], d = it(l);
225
225
  if (d.isDirectory()) {
226
- const b = it(l);
227
- if (T.some((i) => l.includes(i))) return;
228
- await Promise.all(b.map((i) => h(f(l, i), f(x, i))));
226
+ const b = ct(l);
227
+ if (T.some((c) => l.includes(c))) return;
228
+ await Promise.all(b.map((c) => h(f(l, c), f(x, c))));
229
229
  } else if (d.isFile() && I(l)) {
230
- const j = await Z(t, l, o), i = [];
230
+ const j = await Z(t, l, o), c = [];
231
231
  Object.entries(j).forEach(([F, w]) => {
232
232
  if (w.isKeyframes && w.css) {
233
233
  const G = `${w.animationName}.css`, st = `css/${G}`, nt = f(o, st);
@@ -240,11 +240,11 @@ const Q = async (t) => {
240
240
  config: a,
241
241
  prod: e
242
242
  }), E = `${S.hash}-${S.priority}.css`;
243
- n[S.priority] || (n[S.priority] = []), n[S.priority].push(E), i.push(E);
243
+ n[S.priority] || (n[S.priority] = []), n[S.priority].push(E), c.push(E);
244
244
  const M = `css/${E}`, et = f(o, M);
245
245
  P(et, S.css);
246
246
  });
247
- const p = i.map((F) => `@import url('./${F}');`).join(`
247
+ const p = c.map((F) => `@import url('./${F}');`).join(`
248
248
  `), y = B(l, 6), m = f(o, `css/${y}.css`);
249
249
  P(m, p);
250
250
  }
@@ -268,7 +268,7 @@ ${r}`;
268
268
  `);
269
269
  C += l;
270
270
  }
271
- P(c, C);
271
+ P(i, C);
272
272
  } catch (s) {
273
273
  console.error(s);
274
274
  }
@@ -297,10 +297,10 @@ ${r}`;
297
297
  try {
298
298
  const n = f(t, "./saltygen");
299
299
  if (I(e)) {
300
- const c = N(e, "utf8");
301
- c.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== c && await lt(e, c);
300
+ const i = N(e, "utf8");
301
+ i.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== i && await lt(e, i);
302
302
  const a = await z(t), h = await Z(t, e, n);
303
- let r = c;
303
+ let r = i;
304
304
  Object.entries(h).forEach(([$, k]) => {
305
305
  var E;
306
306
  if (k.isKeyframes || !k.generator) return;
@@ -308,21 +308,21 @@ ${r}`;
308
308
  name: $,
309
309
  config: a,
310
310
  prod: s
311
- }), l = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
311
+ }), l = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
312
312
  if (!l) return console.error("Could not find the original declaration");
313
313
  const x = (E = l.at(1)) == null ? void 0 : E.trim(), T = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(r);
314
314
  if (!T) return console.error("Could not find the original declaration");
315
315
  const { index: d } = T;
316
316
  let b = !1;
317
317
  const j = setTimeout(() => b = !0, 5e3);
318
- let i = 0, p = !1, y = 0;
318
+ let c = 0, p = !1, y = 0;
319
319
  for (; !p && !b; ) {
320
- const M = r[d + i];
321
- M === "(" && y++, M === ")" && y--, y === 0 && M === ")" && (p = !0), i > r.length && (b = !0), i++;
320
+ const M = r[d + c];
321
+ M === "(" && y++, M === ")" && y--, y === 0 && M === ")" && (p = !0), c > r.length && (b = !0), c++;
322
322
  }
323
323
  if (!b) clearTimeout(j);
324
324
  else throw new Error("Failed to find the end of the styled call and timed out");
325
- const m = d + i, F = r.slice(d, m), w = r, S = ` ${$} = styled(${x}, "${C.classNames}", ${JSON.stringify(C.props)});`;
325
+ const m = d + c, F = r.slice(d, m), w = r, S = ` ${$} = styled(${x}, "${C.classNames}", ${JSON.stringify(C.props)});`;
326
326
  r = r.replace(F, S), w === r && console.error("Minimize file failed to change content", { name: $, tagName: x });
327
327
  });
328
328
  const u = B(e, 6);
@@ -1,11 +1,11 @@
1
- "use strict";const ot=require("esbuild"),rt=require("child_process"),l=require("path"),u=require("fs"),L=require("fs/promises"),V=require("winston");var J=typeof document<"u"?document.currentScript:null;function it(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const U=it(ot),B=t=>String.fromCharCode(t+(t>25?39:97)),ct=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=B(n%52)+s;return s=B(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},at=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},A=(t,e=3)=>{const s=at(5381,JSON.stringify(t))>>>0;return ct(s,e)};function M(t){return t?typeof t!="string"?M(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const lt=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:i}=n;t=t.replace(o,g=>{const{value:a,css:j}=i(g);return j&&s.push(j),a})}),{result:t,additionalCss:s}},G=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,e,s,n)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((a,[j,r])=>{const d=j.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(d==="variants")return Object.entries(r).forEach(([S,c])=>{c&&Object.entries(c).forEach(([p,m])=>{if(!m)return;const h=`${e}.${S}-${p}`,T=D(m,h);o.push(T)})}),a;if(d==="defaultVariants")return a;if(d==="compoundVariants")return r.forEach(S=>{const{css:c,...p}=S,m=Object.entries(p).reduce((T,[w,F])=>`${T}.${w}-${F}`,e),h=D(c,m);o.push(h)}),a;if(d.startsWith("@")){const S=D(r,e),c=`${d} {
1
+ "use strict";const ot=require("esbuild"),rt=require("child_process"),l=require("path"),u=require("fs"),L=require("fs/promises"),V=require("winston");var J=typeof document<"u"?document.currentScript:null;function it(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const U=it(ot),B=t=>String.fromCharCode(t+(t>25?39:97)),ct=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=B(n%52)+s;return s=B(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},at=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},A=(t,e=3)=>{const s=at(5381,JSON.stringify(t))>>>0;return ct(s,e)};function M(t){return t?typeof t!="string"?M(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const lt=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:i}=n;t=t.replace(o,y=>{const{value:a,css:j}=i(y);return j&&s.push(j),a})}),{result:t,additionalCss:s}},G=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:t},D=(t,e,s,n)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((a,[j,r])=>{const d=j.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(d==="variants")return Object.entries(r).forEach(([S,c])=>{c&&Object.entries(c).forEach(([p,m])=>{if(!m)return;const h=`${e}.${S}-${p}`,T=D(m,h);o.push(T)})}),a;if(d==="defaultVariants")return a;if(d==="compoundVariants")return r.forEach(S=>{const{css:c,...p}=S,m=Object.entries(p).reduce((T,[w,F])=>`${T}.${w}-${F}`,e),h=D(c,m);o.push(h)}),a;if(d.startsWith("@")){const S=D(r,e),c=`${d} {
2
2
  ${S.replace(`
3
3
  `,`
4
4
  `)}
5
- }`;return o.push(c),a}const y=j.includes("&")?d.replace("&",e):d.startsWith(":")?`${e}${d}`:`${e} ${d}`,$=D(r,y);return o.push($),a}const b=d.startsWith("-")?d:M(d),k=(y,$=";")=>a=`${a}${y}${$}`,C=y=>k(`${b}:${y}`);if(typeof r=="number")return C(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:f}={},P=function*(){yield G(r),yield lt(r,f)}();for(const{result:y,additionalCss:$=[]}of P)r=y,$.forEach(S=>{const c=D(S,"");k(c,"")});return C(r)},"");if(!i)return o.join(`
6
- `);if(!e)return i;let g="";return g=`${e} { ${i} }`,[g,...o].join(`
7
- `)},H=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const g=o.trim(),a=H(i,[...e,g]);s.push(a)}else n[o]=i}),Object.keys(n).length){const o=e.map(M).join("-"),i=D(n,`.${o}`);s.push(i)}return s.join(`
8
- `)},ft=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=K(n).map(o=>`"${o}"`).join(" | ")),e),{}),K=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?K(o,i,s):s.add(e)}),[...s]):[],X=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=l.join(t,"package.json");return u.existsSync(e)?e:X(l.join(t,".."))},ut=async t=>{const e=X(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},pt=async t=>{const e=await ut(t);if(e)return e.type};let E;const Y=async t=>{if(E)return E;const e=await pt(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-DXoH-sE3.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},Z=V.createLogger({level:"debug",format:V.format.combine(V.format.colorize(),V.format.cli()),transports:[new V.transports.Console({})]}),R={externalModules:[]},Q=t=>{if(R.externalModules.length>0)return R.externalModules;const e=l.join(t,"salty.config.ts"),n=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return R.externalModules=o,o},_=t=>l.join(t,"./saltygen"),dt=["salty","css","styles","styled"],v=(t=[])=>new RegExp(`\\.(${[...dt,...t].join("|")})\\.`),q=(t,e=[])=>v(e).test(t),gt=async t=>{const e=_(t),s=l.join(t,"salty.config.ts"),n=l.join(e,"salty.config.js"),o=await Y(t),i=Q(t);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:i});const g=Date.now(),{config:a}=await import(`${n}?t=${g}`);return a},yt=async t=>{const e=await gt(t),s=new Set,n=(c,p=[])=>c?Object.entries(c).flatMap(([m,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...p,m]);const T=[...p,m].join(".");s.add(`"${T}"`);const w=[...p.map(M),M(m)].join("-"),{result:F}=G(h);return`--${w}: ${F};`}):[],o=c=>c?Object.entries(c).flatMap(([p,m])=>{const h=n(m);return p==="base"?h.join(""):`${p} { ${h.join("")} }`}):[],i=c=>c?Object.entries(c).flatMap(([p,m])=>Object.entries(m).flatMap(([h,T])=>{const w=n(T,[p]),F=`.${p}-${h}, [data-${p}="${h}"]`,O=w.join("");return`${F} { ${O} }`})):[],g=n(e.variables),a=o(e.responsiveVariables),j=i(e.conditionalVariables),r=_(t),d=l.join(r,"css/variables.css"),b=`:root { ${g.join("")} ${a.join("")} } ${j.join("")}`;u.writeFileSync(d,b);const k=l.join(r,"css/global.css"),C=D(e.global,"");u.writeFileSync(k,C);const f=l.join(r,"css/templates.css"),x=H(e.templates),P=ft(e.templates);console.log(P),u.writeFileSync(f,x);const y=l.join(r,"types/css-tokens.d.ts"),S=`
5
+ }`;return o.push(c),a}const g=j.includes("&")?d.replace("&",e):d.startsWith(":")?`${e}${d}`:`${e} ${d}`,$=D(r,g);return o.push($),a}const b=d.startsWith("-")?d:M(d),k=(g,$=";")=>a=`${a}${g}${$}`,C=g=>k(`${b}:${g}`);if(typeof r=="number")return C(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:f}={},P=function*(){yield G(r),yield lt(r,f)}();for(const{result:g,additionalCss:$=[]}of P)r=g,$.forEach(S=>{const c=D(S,"");k(c,"")});return C(r)},"");if(!i)return o.join(`
6
+ `);if(!e)return i;let y="";return y=`${e} { ${i} }`,[y,...o].join(`
7
+ `)},H=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const y=o.trim(),a=H(i,[...e,y]);s.push(a)}else n[o]=i}),Object.keys(n).length){const o=e.map(M).join("-"),i=D(n,`.${o}`);s.push(i)}return s.join(`
8
+ `)},ft=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=K(n).map(o=>`"${o}"`).join(" | ")),e),{}),K=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?K(o,i,s):s.add(e)}),[...s]):[],X=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=l.join(t,"package.json");return u.existsSync(e)?e:X(l.join(t,".."))},ut=async t=>{const e=X(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},pt=async t=>{const e=await ut(t);if(e)return e.type};let E;const Y=async t=>{if(E)return E;const e=await pt(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-DfOEZJUz.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},Z=V.createLogger({level:"debug",format:V.format.combine(V.format.colorize(),V.format.cli()),transports:[new V.transports.Console({})]}),R={externalModules:[]},Q=t=>{if(R.externalModules.length>0)return R.externalModules;const e=l.join(t,"salty.config.ts"),n=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const o=n[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return R.externalModules=o,o},_=t=>l.join(t,"./saltygen"),dt=["salty","css","styles","styled"],v=(t=[])=>new RegExp(`\\.(${[...dt,...t].join("|")})\\.`),q=(t,e=[])=>v(e).test(t),yt=async t=>{const e=_(t),s=l.join(t,"salty.config.ts"),n=l.join(e,"salty.config.js"),o=await Y(t),i=Q(t);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:o,external:i});const y=Date.now(),{config:a}=await import(`${n}?t=${y}`);return a},gt=async t=>{const e=await yt(t),s=new Set,n=(c,p=[])=>c?Object.entries(c).flatMap(([m,h])=>{if(!h)return;if(typeof h=="object")return n(h,[...p,m]);const T=[...p,m].join(".");s.add(`"${T}"`);const w=[...p.map(M),M(m)].join("-"),{result:F}=G(h);return`--${w}: ${F};`}):[],o=c=>c?Object.entries(c).flatMap(([p,m])=>{const h=n(m);return p==="base"?h.join(""):`${p} { ${h.join("")} }`}):[],i=c=>c?Object.entries(c).flatMap(([p,m])=>Object.entries(m).flatMap(([h,T])=>{const w=n(T,[p]),F=`.${p}-${h}, [data-${p}="${h}"]`,O=w.join("");return`${F} { ${O} }`})):[],y=n(e.variables),a=o(e.responsiveVariables),j=i(e.conditionalVariables),r=_(t),d=l.join(r,"css/variables.css"),b=`:root { ${y.join("")} ${a.join("")} } ${j.join("")}`;u.writeFileSync(d,b);const k=l.join(r,"css/global.css"),C=D(e.global,"");u.writeFileSync(k,C);const f=l.join(r,"css/templates.css"),x=H(e.templates),P=ft(e.templates);u.writeFileSync(f,x);const g=l.join(r,"types/css-tokens.d.ts"),S=`
9
9
  // Variable types
10
10
  type VariableTokens = ${[...s].join("|")};
11
11
  type PropertyValueToken = \`{\${VariableTokens}}\`;
@@ -15,14 +15,14 @@
15
15
  ${Object.entries(P).map(([c,p])=>`${c}?: ${p}`).join(`
16
16
  `)}
17
17
  }
18
- `;u.writeFileSync(y,S)},I=async(t,e,s)=>{const n=A(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=l.parse(e);let g=u.readFileSync(e,"utf8");g=g.replace(/styled\([^"'`{,]+,/g,"styled('div',");const a=l.join(s,"js",n+".js"),j=Q(t),r=await Y(t);await U.build({stdin:{contents:g,sourcefile:i.base,resolveDir:i.dir,loader:"ts"},minify:!1,treeShaking:!0,bundle:!0,outfile:a,format:r,target:["node20"],keepNames:!0,external:j,packages:"external"});const d=Date.now();return await import(`${a}?t=${d}`)},z=async t=>{const e=_(t),s=l.join(e,"salty.config.js"),{config:n}=await import(s);return n},tt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},mt=async(t,e=tt())=>{try{e?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const s=[],n=[],o=_(t),i=l.join(o,"index.css");(()=>{u.existsSync(o)&&rt.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(l.join(o,"css")),u.mkdirSync(l.join(o,"types"))})(),await yt(t);const a=await z(t);async function j(f,x){const P=["node_modules","saltygen"],y=u.statSync(f);if(y.isDirectory()){const $=u.readdirSync(f);if(P.some(c=>f.includes(c)))return;await Promise.all($.map(c=>j(l.join(f,c),l.join(x,c))))}else if(y.isFile()&&q(f)){const S=await I(t,f,o),c=[];Object.entries(S).forEach(([T,w])=>{if(w.isKeyframes&&w.css){const W=`${w.animationName}.css`,st=`css/${W}`,nt=l.join(o,st);s.push(W),u.writeFileSync(nt,w.css);return}if(!w.generator)return;const F=w.generator._withBuildContext({name:T,config:a,prod:e}),O=`${F.hash}-${F.priority}.css`;n[F.priority]||(n[F.priority]=[]),n[F.priority].push(O),c.push(O);const N=`css/${O}`,et=l.join(o,N);u.writeFileSync(et,F.css)});const p=c.map(T=>`@import url('./${T}');`).join(`
18
+ `;u.writeFileSync(g,S)},I=async(t,e,s)=>{const n=A(e),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const i=l.parse(e);let y=u.readFileSync(e,"utf8");y=y.replace(/styled\([^"'`{,]+,/g,"styled('div',");const a=l.join(s,"js",n+".js"),j=Q(t),r=await Y(t);await U.build({stdin:{contents:y,sourcefile:i.base,resolveDir:i.dir,loader:"ts"},minify:!1,treeShaking:!0,bundle:!0,outfile:a,format:r,target:["node20"],keepNames:!0,external:j,packages:"external"});const d=Date.now();return await import(`${a}?t=${d}`)},z=async t=>{const e=_(t),s=l.join(e,"salty.config.js"),{config:n}=await import(s);return n},tt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},mt=async(t,e=tt())=>{try{e?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const s=[],n=[],o=_(t),i=l.join(o,"index.css");(()=>{u.existsSync(o)&&rt.execSync("rm -rf "+o),u.mkdirSync(o),u.mkdirSync(l.join(o,"css")),u.mkdirSync(l.join(o,"types"))})(),await gt(t);const a=await z(t);async function j(f,x){const P=["node_modules","saltygen"],g=u.statSync(f);if(g.isDirectory()){const $=u.readdirSync(f);if(P.some(c=>f.includes(c)))return;await Promise.all($.map(c=>j(l.join(f,c),l.join(x,c))))}else if(g.isFile()&&q(f)){const S=await I(t,f,o),c=[];Object.entries(S).forEach(([T,w])=>{if(w.isKeyframes&&w.css){const W=`${w.animationName}.css`,st=`css/${W}`,nt=l.join(o,st);s.push(W),u.writeFileSync(nt,w.css);return}if(!w.generator)return;const F=w.generator._withBuildContext({name:T,config:a,prod:e}),O=`${F.hash}-${F.priority}.css`;n[F.priority]||(n[F.priority]=[]),n[F.priority].push(O),c.push(O);const N=`css/${O}`,et=l.join(o,N);u.writeFileSync(et,F.css)});const p=c.map(T=>`@import url('./${T}');`).join(`
19
19
  `),m=A(f,6),h=l.join(o,`css/${m}.css`);u.writeFileSync(h,p)}}await j(t,o);const r=s.map(f=>`@import url('./css/${f}');`).join(`
20
20
  `);let C=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
21
21
 
22
22
  ${["variables.css","global.css","templates.css"].filter(f=>{try{return u.readFileSync(l.join(o,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
23
23
  `)}
24
24
  ${r}`;if(a.importStrategy!=="component"){const f=n.flat().map(x=>`@import url('./css/${x}');`).join(`
25
- `);C+=f}u.writeFileSync(i,C)}catch(s){console.error(s)}},ht=async(t,e)=>{try{const s=[],n=l.join(t,"./saltygen"),o=l.join(n,"index.css");if(q(e)){const g=await z(t),a=await I(t,e,n);Object.entries(a).forEach(([k,C])=>{if(!C.generator)return;const f=C.generator._withBuildContext({name:k,config:g}),x=`${f.hash}-${f.priority}.css`,P=`css/${x}`,y=l.join(n,P);s.push(x),u.writeFileSync(y,f.css)});const j=u.readFileSync(o,"utf8").split(`
25
+ `);C+=f}u.writeFileSync(i,C)}catch(s){console.error(s)}},ht=async(t,e)=>{try{const s=[],n=l.join(t,"./saltygen"),o=l.join(n,"index.css");if(q(e)){const y=await z(t),a=await I(t,e,n);Object.entries(a).forEach(([k,C])=>{if(!C.generator)return;const f=C.generator._withBuildContext({name:k,config:y}),x=`${f.hash}-${f.priority}.css`,P=`css/${x}`,g=l.join(n,P);s.push(x),u.writeFileSync(g,f.css)});const j=u.readFileSync(o,"utf8").split(`
26
26
  `),r=s.map(k=>`@import url('../saltygen/css/${k}');`),b=[...new Set([...j,...r])].join(`
27
- `);u.writeFileSync(o,b)}}catch(s){console.error(s)}},jt=async(t,e,s=tt())=>{try{const n=l.join(t,"./saltygen");if(q(e)){const i=u.readFileSync(e,"utf8");i.replace(/^(?!export\s)const\s.*/gm,b=>`export ${b}`)!==i&&await L.writeFile(e,i);const a=await z(t),j=await I(t,e,n);let r=i;Object.entries(j).forEach(([b,k])=>{var O;if(k.isKeyframes||!k.generator)return;const C=k.generator._withBuildContext({name:b,config:a,prod:s}),f=new RegExp(`\\s${b}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!f)return console.error("Could not find the original declaration");const x=(O=f.at(1))==null?void 0:O.trim(),P=new RegExp(`\\s${b}[=\\s]+styled\\(`,"g").exec(r);if(!P)return console.error("Could not find the original declaration");const{index:y}=P;let $=!1;const S=setTimeout(()=>$=!0,5e3);let c=0,p=!1,m=0;for(;!p&&!$;){const N=r[y+c];N==="("&&m++,N===")"&&m--,m===0&&N===")"&&(p=!0),c>r.length&&($=!0),c++}if(!$)clearTimeout(S);else throw new Error("Failed to find the end of the styled call and timed out");const h=y+c,T=r.slice(y,h),w=r,F=` ${b} = styled(${x}, "${C.classNames}", ${JSON.stringify(C.props)});`;r=r.replace(T,F),w===r&&console.error("Minimize file failed to change content",{name:b,tagName:x})});const d=A(e,6);return a.importStrategy==="component"&&(r=`import '../../saltygen/css/${d}.css';
27
+ `);u.writeFileSync(o,b)}}catch(s){console.error(s)}},jt=async(t,e,s=tt())=>{try{const n=l.join(t,"./saltygen");if(q(e)){const i=u.readFileSync(e,"utf8");i.replace(/^(?!export\s)const\s.*/gm,b=>`export ${b}`)!==i&&await L.writeFile(e,i);const a=await z(t),j=await I(t,e,n);let r=i;Object.entries(j).forEach(([b,k])=>{var O;if(k.isKeyframes||!k.generator)return;const C=k.generator._withBuildContext({name:b,config:a,prod:s}),f=new RegExp(`\\s${b}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!f)return console.error("Could not find the original declaration");const x=(O=f.at(1))==null?void 0:O.trim(),P=new RegExp(`\\s${b}[=\\s]+styled\\(`,"g").exec(r);if(!P)return console.error("Could not find the original declaration");const{index:g}=P;let $=!1;const S=setTimeout(()=>$=!0,5e3);let c=0,p=!1,m=0;for(;!p&&!$;){const N=r[g+c];N==="("&&m++,N===")"&&m--,m===0&&N===")"&&(p=!0),c>r.length&&($=!0),c++}if(!$)clearTimeout(S);else throw new Error("Failed to find the end of the styled call and timed out");const h=g+c,T=r.slice(g,h),w=r,F=` ${b} = styled(${x}, "${C.classNames}", ${JSON.stringify(C.props)});`;r=r.replace(T,F),w===r&&console.error("Minimize file failed to change content",{name:b,tagName:x})});const d=A(e,6);return a.importStrategy==="component"&&(r=`import '../../saltygen/css/${d}.css';
28
28
  ${r}`),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=mt;exports.generateFile=ht;exports.minimizeFile=jt;exports.saltyFileRegExp=v;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-DXoH-sE3.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-DfOEZJUz.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve as n } from "path";
2
- import { s as u, g as i } from "./index-CVnjXsoa.js";
2
+ import { s as u, g as i } from "./index-D6f6VgWV.js";
3
3
  const g = (s, e, o = !1, r = !1) => {
4
4
  var a, l, t;
5
5
  (l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
package/loader.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./index-DXoH-sE3.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-DfOEZJUz.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-CVnjXsoa.js";
1
+ import { a as e, m as i } from "./index-D6f6VgWV.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.106",
3
+ "version": "0.0.1-alpha.107",
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.106",
37
+ "@salty-css/core": "^0.0.1-alpha.107",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }