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

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