@salty-css/webpack 0.0.1-alpha.204 → 0.0.1-alpha.206

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