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