@salty-css/webpack 0.0.1-alpha.205 → 0.0.1-alpha.207

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