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

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.
@@ -0,0 +1,652 @@
1
+ var Et = Object.defineProperty;
2
+ var Tt = (e, t, s) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var tt = (e, t, s) => Tt(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import * as $t from "esbuild";
5
+ import { execSync as Ot } from "child_process";
6
+ import { join as u, parse as st } from "path";
7
+ import { existsSync as ct, writeFileSync as k, readFileSync as M, mkdirSync as I, statSync as Vt, readdirSync as Mt } from "fs";
8
+ import { readFile as bt, writeFile as Rt } from "fs/promises";
9
+ import { createLogger as At, format as it, transports as Jt } from "winston";
10
+ const gt = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), Wt = (e, t) => {
11
+ let s = "", n;
12
+ for (n = Math.abs(e); n > 52; n = n / 52 | 0) s = gt(n % 52) + s;
13
+ return s = gt(n % 52) + s, s.length < t ? s = s.padStart(t, "a") : s.length > t && (s = s.slice(-t)), s;
14
+ }, zt = (e, t) => {
15
+ let s = t.length;
16
+ for (; s; ) e = e * 33 ^ t.charCodeAt(--s);
17
+ return e;
18
+ }, z = (e, t = 5) => {
19
+ const s = zt(5381, JSON.stringify(e)) >>> 0;
20
+ return Wt(s, t);
21
+ };
22
+ function A(e) {
23
+ return e ? typeof e != "string" ? A(String(e)) : e.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "-" : "") + t.toLowerCase()) : "";
24
+ }
25
+ const vt = (e) => (t) => {
26
+ if (typeof t != "string" || !e) return;
27
+ let s = t;
28
+ const n = [];
29
+ return Object.values(e).forEach((o) => {
30
+ const { pattern: r, transform: i } = o;
31
+ s = s.replace(r, (y) => {
32
+ const { value: $, css: l } = i(y);
33
+ return l && n.push(l), $;
34
+ });
35
+ }), { transformed: s, additionalCss: n };
36
+ }, wt = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) => `var(--${A(o[1].replaceAll(".", "-"))})`) }, Zt = wt(), It = [
37
+ "top",
38
+ "right",
39
+ "bottom",
40
+ "left",
41
+ "min-width",
42
+ /.*width.*/,
43
+ /^[^line]*height.*/,
44
+ // Exclude line-height
45
+ /padding.*/,
46
+ /margin.*/,
47
+ /border.*/,
48
+ /inset.*/,
49
+ /.*radius.*/,
50
+ /.*spacing.*/,
51
+ /.*gap.*/,
52
+ /.*indent.*/,
53
+ /.*offset.*/,
54
+ /.*size.*/,
55
+ /.*thickness.*/,
56
+ /.*font-size.*/
57
+ ], Ht = (e, t, s) => It.some((o) => typeof o == "string" ? o === e : o.test(e)) ? `${t}px` : `${t}`, Bt = ["Webkit", "Moz", "ms", "O"], Gt = (e) => e.startsWith("-") ? e : Bt.some((t) => e.startsWith(t)) ? `-${A(e)}` : A(e), et = async (e, t = "", s, n = !1) => {
58
+ if (!e) throw new Error("No styles provided to parseStyles function!");
59
+ const o = /* @__PURE__ */ new Set(), i = Object.entries(e).map(async ([m, a]) => {
60
+ const p = m.trim(), x = Gt(p), F = (N, V = ";") => `${x}:${N}${V}`;
61
+ if (typeof a == "function" && (a = a({ scope: t, config: s })), a instanceof Promise && (a = await a), typeof a == "object") {
62
+ if (!a) return;
63
+ if (a.isColor) return F(a.toString());
64
+ if (p === "defaultVariants") return;
65
+ if (p === "variants") {
66
+ const C = Object.entries(a);
67
+ for (const [E, c] of C) {
68
+ if (!c) return;
69
+ const h = Object.entries(c);
70
+ for (const [S, f] of h) {
71
+ if (!f) return;
72
+ const w = `${t}.${E}-${S}`;
73
+ (await et(f, w, s)).forEach((T) => o.add(T));
74
+ }
75
+ }
76
+ return;
77
+ }
78
+ if (p === "compoundVariants") {
79
+ for (const C of a) {
80
+ const { css: E, ...c } = C, h = Object.entries(c).reduce((f, [w, _]) => `${f}.${w}-${_}`, t);
81
+ (await et(E, h, s)).forEach((f) => o.add(f));
82
+ }
83
+ return;
84
+ }
85
+ if (p.startsWith("@")) {
86
+ const C = p, E = await Q(a, t, s), c = `${C} { ${E} }`;
87
+ o.add(c);
88
+ return;
89
+ }
90
+ const N = m.includes("&") ? p.replace("&", t) : p.startsWith(":") ? `${t}${p}` : `${t} ${p}`;
91
+ (await et(a, N, s)).forEach((C) => o.add(C));
92
+ return;
93
+ }
94
+ if (typeof a == "number") {
95
+ const N = Ht(x, a);
96
+ return F(N);
97
+ }
98
+ if (typeof a != "string")
99
+ if ("toString" in a) a = a.toString();
100
+ else throw new Error(`Invalid value type for property ${x}`);
101
+ return F(a);
102
+ }), { modifiers: y } = {}, $ = [wt(), vt(y)], d = (await Promise.all(i).then((m) => Promise.all(
103
+ m.map((a) => $.reduce(async (p, x) => {
104
+ const F = await p;
105
+ if (!F) return F;
106
+ const R = await x(F);
107
+ if (!R) return F;
108
+ const { transformed: N, additionalCss: V } = R;
109
+ let C = "";
110
+ if (V)
111
+ for (const E of V)
112
+ C += await Q(E, "");
113
+ return `${C}${N}`;
114
+ }, Promise.resolve(a)))
115
+ ))).filter((m) => m !== void 0).join(`
116
+ `);
117
+ if (!d.trim()) return Array.from(o);
118
+ const b = t ? `${t} {
119
+ ${d}
120
+ }` : d;
121
+ return o.has(b) ? Array.from(o) : [b, ...o];
122
+ }, Q = async (e, t, s, n = !1) => (await et(e, t, s, n)).join(`
123
+ `), Ct = async (e, t = []) => {
124
+ if (!e) return "";
125
+ const s = [], n = {};
126
+ for (const [o, r] of Object.entries(e))
127
+ if (typeof r != "function") if (r && typeof r == "object") {
128
+ const i = o.trim(), y = await Ct(r, [...t, i]);
129
+ s.push(y);
130
+ } else
131
+ n[o] = r;
132
+ if (Object.keys(n).length) {
133
+ const o = t.map(A).join("-"), r = "t_" + z(o, 4), i = await Q(n, `.${o}, .${r}`);
134
+ s.push(i);
135
+ }
136
+ return s.join(`
137
+ `);
138
+ }, Kt = (e) => e ? Object.entries(e).reduce((t, [s, n]) => (typeof n == "function" ? t[s] = "any" : typeof n == "object" && (t[s] = St(n).map((o) => `"${o}"`).join(" | ")), t), {}) : {}, St = (e, t = "", s = /* @__PURE__ */ new Set()) => e ? (Object.entries(e).forEach(([n, o]) => {
139
+ const r = t ? `${t}.${n}` : n;
140
+ return typeof o == "object" ? St(o, r, s) : s.add(t);
141
+ }), [...s]) : [], jt = (e) => {
142
+ if (!e || e === "/") throw new Error("Could not find package.json file");
143
+ const t = u(e, "package.json");
144
+ return ct(t) ? t : jt(u(e, ".."));
145
+ }, Lt = async (e) => {
146
+ const t = jt(e);
147
+ return await bt(t, "utf-8").then(JSON.parse).catch(() => {
148
+ });
149
+ }, Qt = async (e) => {
150
+ const t = await Lt(e);
151
+ if (t)
152
+ return t.type;
153
+ };
154
+ let Z;
155
+ const Ft = async (e) => {
156
+ if (Z) return Z;
157
+ const t = await Qt(e);
158
+ return t === "module" ? Z = "esm" : (t === "commonjs" || import.meta.url.endsWith(".cjs")) && (Z = "cjs"), Z || "esm";
159
+ }, at = At({
160
+ level: "debug",
161
+ format: it.combine(it.colorize(), it.cli()),
162
+ transports: [new Jt.Console({})]
163
+ });
164
+ function Pt(e) {
165
+ return e ? typeof e != "string" ? Pt(String(e)) : e.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (t, s) => (s > 0 ? "." : "") + t.toLowerCase()) : "";
166
+ }
167
+ const qt = {
168
+ /** Set box model to border-box */
169
+ "*, *::before, *::after": {
170
+ boxSizing: "border-box"
171
+ },
172
+ /** Remove default margin and padding */
173
+ "*": {
174
+ margin: 0
175
+ },
176
+ /** Remove adjust font properties */
177
+ html: {
178
+ lineHeight: 1.15,
179
+ textSizeAdjust: "100%",
180
+ WebkitFontSmoothing: "antialiased"
181
+ },
182
+ /** Make media elements responsive */
183
+ "img, picture, video, canvas, svg": {
184
+ display: "block",
185
+ maxWidth: "100%"
186
+ },
187
+ /** Avoid overflow of text */
188
+ "p, h1, h2, h3, h4, h5, h6": {
189
+ overflowWrap: "break-word"
190
+ },
191
+ /** Improve text wrapping */
192
+ p: {
193
+ textWrap: "pretty"
194
+ },
195
+ "h1, h2, h3, h4, h5, h6": {
196
+ textWrap: "balance"
197
+ },
198
+ /** Improve link color */
199
+ a: {
200
+ color: "currentColor"
201
+ },
202
+ /** Improve button line height */
203
+ button: {
204
+ lineHeight: "1em",
205
+ color: "currentColor"
206
+ },
207
+ /** Improve form elements */
208
+ "input, optgroup, select, textarea": {
209
+ fontFamily: "inherit",
210
+ fontSize: "100%",
211
+ lineHeight: "1.15em"
212
+ }
213
+ }, H = (...e) => e.flat().reduce((t, s) => s != null && s._current ? { ...t, ...s._current } : { ...t, ...s }, {}), Ut = (...e) => e.flat().reduce((t, s) => ({ ...t, ...s._children }), {});
214
+ class Xt {
215
+ constructor(t) {
216
+ tt(this, "_path");
217
+ this.params = t;
218
+ }
219
+ get _current() {
220
+ return this.params.template;
221
+ }
222
+ get isDefineTemplate() {
223
+ return !0;
224
+ }
225
+ _setPath(t) {
226
+ return this._path = t, this;
227
+ }
228
+ }
229
+ class Yt {
230
+ constructor(t) {
231
+ tt(this, "_path");
232
+ tt(this, "templates", []);
233
+ this.params = t, Object.entries(t).forEach(([s, n]) => {
234
+ this.templates.push(
235
+ new Xt({
236
+ name: s,
237
+ template: n
238
+ })
239
+ );
240
+ });
241
+ }
242
+ get _current() {
243
+ return this.params;
244
+ }
245
+ get _children() {
246
+ return Object.fromEntries(
247
+ this.templates.map((t) => [t.params.name, t])
248
+ );
249
+ }
250
+ get isDefineTemplates() {
251
+ return !0;
252
+ }
253
+ _setPath(t) {
254
+ return this._path = t, this.templates.forEach((s) => s._setPath(t)), this;
255
+ }
256
+ }
257
+ const te = (e) => new Yt(e), W = {
258
+ externalModules: [],
259
+ rcFile: void 0,
260
+ destDir: void 0
261
+ }, xt = (e) => {
262
+ if (W.externalModules.length > 0) return W.externalModules;
263
+ const s = M(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
264
+ if (!s) return [];
265
+ const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
266
+ return W.externalModules = n, n;
267
+ }, v = async (e) => {
268
+ if (W.destDir) return W.destDir;
269
+ const t = await ft(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
270
+ return W.destDir = s, s;
271
+ }, Nt = ["salty", "css", "styles", "styled"], ee = (e = []) => new RegExp(`\\.(${[...Nt, ...e].join("|")})\\.`), lt = (e, t = []) => ee(t).test(e), _t = async (e) => {
272
+ if (W.rcFile) return W.rcFile;
273
+ if (e === "/") throw new Error("Could not find .saltyrc.json file");
274
+ const t = u(e, ".saltyrc.json"), s = await bt(t, "utf-8").then(JSON.parse).catch(() => {
275
+ });
276
+ return s ? (W.rcFile = s, s) : _t(u(e, ".."));
277
+ }, ft = async (e) => {
278
+ var n, o;
279
+ const t = await _t(e), s = (n = t.projects) == null ? void 0 : n.find((r) => e.endsWith(r.dir || ""));
280
+ return s || ((o = t.projects) == null ? void 0 : o.find((r) => r.dir === t.defaultProject));
281
+ }, se = async (e) => {
282
+ const t = await ft(e), s = await v(e), n = u(e, (t == null ? void 0 : t.configDir) || "", "salty.config.ts"), o = u(s, "salty.config.js"), r = await Ft(e), i = xt(n);
283
+ await $t.build({
284
+ entryPoints: [n],
285
+ minify: !0,
286
+ treeShaking: !0,
287
+ bundle: !0,
288
+ outfile: o,
289
+ format: r,
290
+ external: i
291
+ });
292
+ const y = Date.now(), { config: $ } = await import(`${o}?t=${y}`);
293
+ return { config: $, path: o };
294
+ }, ne = async (e, t) => {
295
+ var pt, mt;
296
+ const s = await v(e), n = {
297
+ mediaQueries: [],
298
+ globalStyles: [],
299
+ variables: [],
300
+ templates: []
301
+ };
302
+ await Promise.all(
303
+ [...t].map(async (j) => {
304
+ const { contents: P, outputFilePath: J } = await nt(e, j, s);
305
+ Object.entries(P).forEach(([D, O]) => {
306
+ 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};;${J}`));
307
+ });
308
+ })
309
+ );
310
+ const { config: o, path: r } = await se(e), i = { ...o }, y = /* @__PURE__ */ new Set(), $ = (j, P = []) => j ? Object.entries(j).flatMap(([J, D]) => {
311
+ if (!D) return;
312
+ if (typeof D == "object") return $(D, [...P, J]);
313
+ const O = Pt(J), ot = A(J), rt = [...P, O].join(".");
314
+ y.add(`"${rt}"`);
315
+ const Y = [...P.map(A), ot].join("-"), ht = Zt(D);
316
+ return ht ? `--${Y}: ${ht.transformed};` : `--${Y}: ${D};`;
317
+ }) : [], l = (j) => j ? Object.entries(j).flatMap(([P, J]) => {
318
+ const D = $(J);
319
+ return P === "base" ? D.join("") : `${P} { ${D.join("")} }`;
320
+ }) : [], d = (j) => j ? Object.entries(j).flatMap(([P, J]) => Object.entries(J).flatMap(([D, O]) => {
321
+ const ot = $(O, [P]), rt = `.${P}-${D}, [data-${P}="${D}"]`, Y = ot.join("");
322
+ return `${rt} { ${Y} }`;
323
+ })) : [], b = (j) => ({ ...j, responsive: void 0, conditional: void 0 }), g = (j) => n.variables.map((P) => j === "static" ? b(P._current) : P._current[j]), m = H(b(o.variables), g("static")), a = $(m), p = H((pt = o.variables) == null ? void 0 : pt.responsive, g("responsive")), x = l(p), F = H((mt = o.variables) == null ? void 0 : mt.conditional, g("conditional")), R = d(F), N = u(s, "css/_variables.css"), V = `:root { ${a.join("")} ${x.join("")} } ${R.join("")}`;
324
+ k(N, V), i.staticVariables = m;
325
+ const C = u(s, "css/_global.css"), E = H(o.global, n.globalStyles), c = await Q(E, "");
326
+ k(C, `@layer global { ${c} }`);
327
+ const h = u(s, "css/_reset.css"), f = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : qt, w = await Q(f, "");
328
+ k(h, `@layer reset { ${w} }`);
329
+ const _ = u(s, "css/_templates.css"), T = H(o.templates, n.templates), B = await Ct(T), G = Kt(T);
330
+ k(_, `@layer templates { ${B} }`), i.templates = T;
331
+ const K = o.templates ? [te(o.templates)._setPath(`config;;${r}`)] : [], q = Ut(n.templates, K);
332
+ i.templatePaths = Object.fromEntries(Object.entries(q).map(([j, P]) => [j, P._path]));
333
+ const { mediaQueries: U } = n;
334
+ i.mediaQueries = Object.fromEntries(U.map(([j, P]) => [`@${j}`, P]));
335
+ const L = U.map(([j]) => `'@${j}'`).join(" | "), X = u(s, "types/css-tokens.d.ts"), kt = `
336
+ // Variable types
337
+ type VariableTokens = ${[...y].join("|")};
338
+ type PropertyValueToken = \`{\${VariableTokens}}\`;
339
+
340
+ // Template types
341
+ type TemplateTokens = {
342
+ ${Object.entries(G).map(([j, P]) => `${j}?: ${P}`).join(`
343
+ `)}
344
+ }
345
+
346
+ // Media query types
347
+ type MediaQueryKeys = ${L || "''"};
348
+ `;
349
+ k(X, kt);
350
+ const Dt = u(s, "cache/config-cache.json");
351
+ k(Dt, JSON.stringify(i, null, 2));
352
+ }, yt = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
353
+ if (/^['"`]/.test(s)) return t;
354
+ const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
355
+ if (!o.test(e)) return t;
356
+ const i = o.exec(e);
357
+ if (i) {
358
+ const y = i.at(1);
359
+ if (Nt.some((l) => y == null ? void 0 : y.includes(l))) return t;
360
+ }
361
+ return "styled('div',";
362
+ }), oe = (e, t) => {
363
+ try {
364
+ const s = M(u(t, "saltygen/cache/config-cache.json"), "utf8");
365
+ return s ? `globalThis.saltyConfig = ${s};
366
+
367
+ ${e}` : `globalThis.saltyConfig = {};
368
+
369
+ ${e}`;
370
+ } catch {
371
+ return e;
372
+ }
373
+ }, nt = async (e, t, s) => {
374
+ const n = z(t), o = u(s, "./temp");
375
+ ct(o) || I(o);
376
+ const r = st(t);
377
+ let i = M(t, "utf8");
378
+ i = yt(i), i = oe(i, e);
379
+ const y = u(s, "js", n + ".js"), $ = await ft(e), l = u(e, ($ == null ? void 0 : $.configDir) || "", "salty.config.ts"), d = xt(l), b = await Ft(e);
380
+ await $t.build({
381
+ stdin: {
382
+ contents: i,
383
+ sourcefile: r.base,
384
+ resolveDir: r.dir,
385
+ loader: "tsx"
386
+ },
387
+ minify: !1,
388
+ treeShaking: !0,
389
+ bundle: !0,
390
+ outfile: y,
391
+ format: b,
392
+ target: ["node20"],
393
+ keepNames: !0,
394
+ external: d,
395
+ packages: "external",
396
+ plugins: [
397
+ {
398
+ name: "test",
399
+ setup: (a) => {
400
+ a.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (p) => {
401
+ const x = M(p.path, "utf8");
402
+ return { contents: yt(x), loader: "ts" };
403
+ });
404
+ }
405
+ }
406
+ ]
407
+ });
408
+ const g = Date.now();
409
+ return { contents: await import(`${y}?t=${g}`), outputFilePath: y };
410
+ }, re = async (e) => {
411
+ const t = await v(e), s = u(t, "cache/config-cache.json"), n = M(s, "utf8");
412
+ if (!n) throw new Error("Could not find config cache file");
413
+ return JSON.parse(n);
414
+ }, ut = async (e) => {
415
+ const t = await re(e), s = await v(e), n = u(s, "salty.config.js"), o = Date.now(), { config: r } = await import(`${n}?t=${o}`);
416
+ return H(r, t);
417
+ }, dt = () => {
418
+ try {
419
+ return process.env.NODE_ENV === "production";
420
+ } catch {
421
+ return !1;
422
+ }
423
+ }, pe = async (e, t = dt(), s = !0) => {
424
+ try {
425
+ const n = Date.now();
426
+ t ? at.info("Generating CSS in production mode! 🔥") : at.info("Generating CSS in development mode! 🚀");
427
+ const o = [], r = [], i = await v(e), y = u(i, "index.css");
428
+ s && (() => {
429
+ ct(i) && Ot("rm -rf " + i), I(i, { recursive: !0 }), I(u(i, "css")), I(u(i, "types")), I(u(i, "js")), I(u(i, "cache"));
430
+ })();
431
+ const l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
432
+ async function b(c) {
433
+ const h = ["node_modules", "saltygen"], S = Vt(c);
434
+ if (S.isDirectory()) {
435
+ const f = Mt(c);
436
+ if (h.some((_) => c.includes(_))) return;
437
+ await Promise.all(f.map((_) => b(u(c, _))));
438
+ } else if (S.isFile() && lt(c)) {
439
+ l.add(c);
440
+ const w = M(c, "utf8");
441
+ /define[\w\d]+\(/.test(w) && d.add(c);
442
+ }
443
+ }
444
+ await b(e), await ne(e, d);
445
+ const g = {
446
+ keyframes: [],
447
+ components: [],
448
+ classNames: []
449
+ };
450
+ await Promise.all(
451
+ [...l].map(async (c) => {
452
+ const { contents: h } = await nt(e, c, i);
453
+ Object.entries(h).forEach(([S, f]) => {
454
+ f.isKeyframes ? g.keyframes.push({
455
+ value: f,
456
+ src: c,
457
+ name: S
458
+ }) : f.isClassName ? g.classNames.push({
459
+ ...f,
460
+ src: c,
461
+ name: S
462
+ }) : f.generator && g.components.push({
463
+ ...f,
464
+ src: c,
465
+ name: S
466
+ });
467
+ });
468
+ })
469
+ );
470
+ const m = await ut(e);
471
+ for (const c of g.keyframes) {
472
+ const { value: h } = c, S = `a_${h.animationName}.css`, f = `css/${S}`, w = u(i, f);
473
+ o.push(S), k(w, h.css);
474
+ }
475
+ const a = {};
476
+ for (const c of g.components) {
477
+ const { src: h, name: S } = c;
478
+ a[h] || (a[h] = []);
479
+ const f = c.generator._withBuildContext({
480
+ callerName: S,
481
+ isProduction: t,
482
+ config: m
483
+ });
484
+ r[f.priority] || (r[f.priority] = []);
485
+ const w = await f.css;
486
+ if (!w) continue;
487
+ r[f.priority].push(f.cssFileName);
488
+ const _ = `css/${f.cssFileName}`, T = u(i, _);
489
+ k(T, w), m.importStrategy === "component" && a[h].push(f.cssFileName);
490
+ }
491
+ for (const c of g.classNames) {
492
+ const { src: h, name: S } = c;
493
+ a[h] || (a[h] = []);
494
+ const f = c.generator._withBuildContext({
495
+ callerName: S,
496
+ isProduction: t,
497
+ config: m
498
+ }), w = await f.css;
499
+ if (!w) continue;
500
+ r[0].push(f.cssFileName);
501
+ const _ = `css/${f.cssFileName}`, T = u(i, _);
502
+ k(T, w), m.importStrategy === "component" && a[h].push(f.cssFileName);
503
+ }
504
+ m.importStrategy === "component" && Object.entries(a).forEach(([c, h]) => {
505
+ const S = h.map((B) => `@import url('./${B}');`).join(`
506
+ `), f = z(c, 6), w = st(c), _ = A(w.name), T = u(i, `css/f_${_}-${f}.css`);
507
+ k(T, S || "/* Empty file */");
508
+ });
509
+ const p = o.map((c) => `@import url('./css/${c}');`).join(`
510
+ `);
511
+ let N = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
512
+
513
+ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((c) => {
514
+ try {
515
+ return M(u(i, "css", c), "utf8").length > 0;
516
+ } catch {
517
+ return !1;
518
+ }
519
+ }).map((c) => `@import url('./css/${c}');`).join(`
520
+ `)}
521
+ ${p}`;
522
+ if (m.importStrategy !== "component") {
523
+ const c = r.reduce((h, S, f) => {
524
+ const w = S.reduce((G, K) => {
525
+ var X;
526
+ const q = u(i, "css", K), U = M(q, "utf8"), L = ((X = /.*-([^-]+)-\d+.css/.exec(K)) == null ? void 0 : X.at(1)) || z(q, 6);
527
+ return G.includes(L) ? G : `${G}
528
+ /*start:${L}-${K}*/
529
+ ${U}
530
+ /*end:${L}*/
531
+ `;
532
+ }, ""), _ = `l_${f}.css`, T = u(i, "css", _), B = `@layer l${f} { ${w}
533
+ }`;
534
+ return k(T, B), `${h}
535
+ @import url('./css/${_}');`;
536
+ }, "");
537
+ N += c;
538
+ }
539
+ k(y, N);
540
+ const C = Date.now() - n, E = C < 200 ? "🔥" : C < 500 ? "🚀" : C < 1e3 ? "🎉" : C < 2e3 ? "🚗" : C < 5e3 ? "🤔" : "🥴";
541
+ at.info(`Generated CSS in ${C}ms! ${E}`);
542
+ } catch (n) {
543
+ console.error(n);
544
+ }
545
+ }, me = async (e, t, s = dt()) => {
546
+ try {
547
+ const n = await v(e);
548
+ if (lt(t)) {
549
+ const r = [], i = await ut(e), { contents: y } = await nt(e, t, n);
550
+ for (const [$, l] of Object.entries(y)) {
551
+ if (l.isKeyframes && l.css) {
552
+ const p = `css/${`a_${l.animationName}.css`}`, x = u(n, p);
553
+ k(x, await l.css);
554
+ return;
555
+ }
556
+ if (l.isClassName) {
557
+ const a = l.generator._withBuildContext({
558
+ callerName: $,
559
+ isProduction: s,
560
+ config: i
561
+ }), p = await a.css;
562
+ if (!p) continue;
563
+ r[0].push(a.cssFileName);
564
+ const x = `css/${a.cssFileName}`, F = u(n, x);
565
+ k(F, p);
566
+ }
567
+ if (!l.generator) return;
568
+ const d = l.generator._withBuildContext({
569
+ callerName: $,
570
+ isProduction: s,
571
+ config: i
572
+ }), b = await d.css;
573
+ if (!b) continue;
574
+ const g = `css/${d.cssFileName}`, m = u(n, g);
575
+ k(m, b), r[d.priority] || (r[d.priority] = []), r[d.priority].push(d.cssFileName);
576
+ }
577
+ if (i.importStrategy !== "component")
578
+ r.forEach(($, l) => {
579
+ const d = `l_${l}.css`, b = u(n, "css", d);
580
+ let g = M(b, "utf8");
581
+ $.forEach((m) => {
582
+ var F;
583
+ const a = u(n, "css", m), p = ((F = /.*-([^-]+)-\d+.css/.exec(m)) == null ? void 0 : F.at(1)) || z(a, 6);
584
+ if (!g.includes(p)) {
585
+ const R = M(a, "utf8"), N = `/*start:${p}-${m}*/
586
+ ${R}
587
+ /*end:${p}*/
588
+ `;
589
+ g = `${g.replace(/\}$/, "")}
590
+ ${N}
591
+ }`;
592
+ }
593
+ }), k(b, g);
594
+ });
595
+ else {
596
+ const $ = r.flat().map((m) => `@import url('./${m}');`).join(`
597
+ `), l = z(t, 6), d = st(t), b = A(d.name), g = u(n, `css/f_${b}-${l}.css`);
598
+ k(g, $ || "/* Empty file */");
599
+ }
600
+ }
601
+ } catch (n) {
602
+ console.error(n);
603
+ }
604
+ }, he = async (e, t, s = dt()) => {
605
+ try {
606
+ const n = await v(e);
607
+ if (lt(t)) {
608
+ const r = M(t, "utf8");
609
+ r.replace(/^(?!export\s)const\s.*/gm, (d) => `export ${d}`) !== r && await Rt(t, r);
610
+ const y = await ut(e), { contents: $ } = await nt(e, t, n);
611
+ let l = r;
612
+ if (Object.entries($).forEach(([d, b]) => {
613
+ var f;
614
+ if (b.isKeyframes || !b.generator) return;
615
+ const g = b.generator._withBuildContext({
616
+ callerName: d,
617
+ isProduction: s,
618
+ config: y
619
+ }), m = new RegExp(`\\s${d}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(r);
620
+ if (!m) return console.error("Could not find the original declaration");
621
+ const a = (f = m.at(1)) == null ? void 0 : f.trim(), p = new RegExp(`\\s${d}[=\\s]+styled\\(`, "g").exec(l);
622
+ if (!p) return console.error("Could not find the original declaration");
623
+ const { index: x } = p;
624
+ let F = !1;
625
+ const R = setTimeout(() => F = !0, 5e3);
626
+ let N = 0, V = !1, C = 0;
627
+ for (; !V && !F; ) {
628
+ const w = l[x + N];
629
+ w === "(" && C++, w === ")" && C--, C === 0 && w === ")" && (V = !0), N > l.length && (F = !0), N++;
630
+ }
631
+ if (!F) clearTimeout(R);
632
+ else throw new Error("Failed to find the end of the styled call and timed out");
633
+ const E = x + N, c = l.slice(x, E), h = l, S = ` ${d} = styled(${a}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;
634
+ l = l.replace(c, S), h === l && console.error("Minimize file failed to change content", { name: d, tagName: a });
635
+ }), y.importStrategy === "component") {
636
+ const d = z(t, 6), b = st(t);
637
+ l = `import '../../saltygen/css/${`f_${A(b.name)}-${d}.css`}';
638
+ ${l}`;
639
+ }
640
+ return l = l.replace("{ styled }", "{ styledClient as styled }"), l = l.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), l;
641
+ }
642
+ } catch (n) {
643
+ console.error("Error in minimizeFile:", n);
644
+ }
645
+ };
646
+ export {
647
+ me as a,
648
+ pe as g,
649
+ lt as i,
650
+ he as m,
651
+ ee as s
652
+ };
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-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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-C1yuKgNW.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-C3XjWftB.js";
2
+ import { i as f, s as p, g as u, a as y } from "./index-DblUSN58.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-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;
1
+ "use strict";const i=require("./index-C1yuKgNW.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-C3XjWftB.js";
1
+ import { a as e, m as i } from "./index-DblUSN58.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.210",
3
+ "version": "0.0.1-alpha.211",
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.210",
37
+ "@salty-css/core": "^0.0.1-alpha.211",
38
38
  "webpack": ">=5.x"
39
39
  }
40
40
  }