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