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