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

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