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