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

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