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