@salty-css/webpack 0.0.1-alpha.120 → 0.0.1-alpha.122
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-Cp7uNPK9.js +390 -0
- package/index-DYblhpWE.cjs +28 -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-C85_DMmG.cjs +0 -28
- package/index-DAmJ383d.js +0 -388
@@ -0,0 +1,390 @@
|
|
1
|
+
import * as Y from "esbuild";
|
2
|
+
import { execSync as ct } from "child_process";
|
3
|
+
import { join as f, parse as B } from "path";
|
4
|
+
import { existsSync as I, writeFileSync as T, readFileSync as J, mkdirSync as W, statSync as at, readdirSync as lt } from "fs";
|
5
|
+
import { readFile as ft, writeFile as pt } from "fs/promises";
|
6
|
+
import { createLogger as ut, format as Z, transports as dt } from "winston";
|
7
|
+
const U = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), gt = (t, e) => {
|
8
|
+
let s = "", n;
|
9
|
+
for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = U(n % 52) + s;
|
10
|
+
return s = U(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
+
}, yt = (t, e) => {
|
12
|
+
let s = e.length;
|
13
|
+
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
|
+
return t;
|
15
|
+
}, K = (t, e = 5) => {
|
16
|
+
const s = yt(5381, JSON.stringify(t)) >>> 0;
|
17
|
+
return gt(s, e);
|
18
|
+
};
|
19
|
+
function O(t) {
|
20
|
+
return t ? typeof t != "string" ? O(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
|
21
|
+
}
|
22
|
+
const mt = (t, e) => {
|
23
|
+
if (typeof t != "string") return { result: t };
|
24
|
+
if (!e) return { result: t };
|
25
|
+
const s = [];
|
26
|
+
return Object.values(e).forEach((n) => {
|
27
|
+
const { pattern: r, transform: i } = n;
|
28
|
+
t = t.replace(r, (d) => {
|
29
|
+
const { value: c, css: b } = i(d);
|
30
|
+
return b && s.push(b), c;
|
31
|
+
});
|
32
|
+
}), { result: t, additionalCss: s };
|
33
|
+
}, Q = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: t }, D = (t, e, s, n) => {
|
34
|
+
if (!t) return "";
|
35
|
+
const r = [], i = Object.entries(t).reduce((c, [b, o]) => {
|
36
|
+
const a = b.trim();
|
37
|
+
if (typeof o == "function" && (o = o()), typeof o == "object") {
|
38
|
+
if (!o) return c;
|
39
|
+
if (a === "variants")
|
40
|
+
return Object.entries(o).forEach(([h, p]) => {
|
41
|
+
p && Object.entries(p).forEach(([C, N]) => {
|
42
|
+
if (!N) return;
|
43
|
+
const E = `${e}.${h}-${C}`, g = D(N, E);
|
44
|
+
r.push(g);
|
45
|
+
});
|
46
|
+
}), c;
|
47
|
+
if (a === "defaultVariants")
|
48
|
+
return c;
|
49
|
+
if (a === "compoundVariants")
|
50
|
+
return o.forEach((h) => {
|
51
|
+
const { css: p, ...C } = h, N = Object.entries(C).reduce((g, [y, $]) => `${g}.${y}-${$}`, e), E = D(p, N);
|
52
|
+
r.push(E);
|
53
|
+
}), c;
|
54
|
+
if (a.startsWith("@")) {
|
55
|
+
const h = D(o, e), p = `${a} {
|
56
|
+
${h.replace(`
|
57
|
+
`, `
|
58
|
+
`)}
|
59
|
+
}`;
|
60
|
+
return r.push(p), c;
|
61
|
+
}
|
62
|
+
const m = b.includes("&") ? a.replace("&", e) : a.startsWith(":") ? `${e}${a}` : `${e} ${a}`, F = D(o, m);
|
63
|
+
return r.push(F), c;
|
64
|
+
}
|
65
|
+
const j = a.startsWith("-") ? a : O(a), w = (m, F = ";") => c = `${c}${m}${F}`, S = (m) => w(`${j}:${m}`);
|
66
|
+
if (typeof o == "number") return S(o);
|
67
|
+
if (typeof o != "string")
|
68
|
+
if ("toString" in o) o = o.toString();
|
69
|
+
else return c;
|
70
|
+
const { modifiers: l } = {}, k = function* () {
|
71
|
+
yield Q(o), yield mt(o, l);
|
72
|
+
}();
|
73
|
+
for (const { result: m, additionalCss: F = [] } of k)
|
74
|
+
o = m, F.forEach((h) => {
|
75
|
+
const p = D(h, "");
|
76
|
+
w(p, "");
|
77
|
+
});
|
78
|
+
return S(o);
|
79
|
+
}, "");
|
80
|
+
if (!i) return r.join(`
|
81
|
+
`);
|
82
|
+
if (!e) return i;
|
83
|
+
let d = "";
|
84
|
+
return d = `${e} { ${i} }`, [d, ...r].join(`
|
85
|
+
`);
|
86
|
+
}, v = (t, e = []) => {
|
87
|
+
if (!t) return "";
|
88
|
+
const s = [], n = {};
|
89
|
+
if (Object.entries(t).forEach(([r, i]) => {
|
90
|
+
if (typeof i == "object") {
|
91
|
+
if (!i) return;
|
92
|
+
const d = r.trim(), c = v(i, [...e, d]);
|
93
|
+
s.push(c);
|
94
|
+
} else
|
95
|
+
n[r] = i;
|
96
|
+
}), Object.keys(n).length) {
|
97
|
+
const r = e.map(O).join("-"), i = D(n, `.${r}`);
|
98
|
+
s.push(i);
|
99
|
+
}
|
100
|
+
return s.join(`
|
101
|
+
`);
|
102
|
+
}, ht = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = tt(n).map((r) => `"${r}"`).join(" | ")), e), {}), tt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, r]) => {
|
103
|
+
const i = e ? `${e}.${n}` : n;
|
104
|
+
return typeof r == "object" ? tt(r, i, s) : s.add(e);
|
105
|
+
}), [...s]) : [], et = (t) => {
|
106
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
107
|
+
const e = f(t, "package.json");
|
108
|
+
return I(e) ? e : et(f(t, ".."));
|
109
|
+
}, bt = async (t) => {
|
110
|
+
const e = et(t);
|
111
|
+
return await ft(e, "utf-8").then(JSON.parse).catch(() => {
|
112
|
+
});
|
113
|
+
}, $t = async (t) => {
|
114
|
+
const e = await bt(t);
|
115
|
+
if (e)
|
116
|
+
return e.type;
|
117
|
+
};
|
118
|
+
let M;
|
119
|
+
const st = async (t) => {
|
120
|
+
if (M) return M;
|
121
|
+
const e = await $t(t);
|
122
|
+
return e === "module" ? M = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
123
|
+
}, X = ut({
|
124
|
+
level: "debug",
|
125
|
+
format: Z.combine(Z.colorize(), Z.cli()),
|
126
|
+
transports: [new dt.Console({})]
|
127
|
+
});
|
128
|
+
function nt(t) {
|
129
|
+
return t ? typeof t != "string" ? nt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
130
|
+
}
|
131
|
+
const St = {
|
132
|
+
/** Set box model to border-box */
|
133
|
+
"*, *::before, *::after": {
|
134
|
+
boxSizing: "border-box"
|
135
|
+
},
|
136
|
+
/** Remove default margin and padding */
|
137
|
+
"*": {
|
138
|
+
margin: 0
|
139
|
+
},
|
140
|
+
/** Remove adjust font properties */
|
141
|
+
html: {
|
142
|
+
lineHeight: 1.15,
|
143
|
+
textSizeAdjust: "100%",
|
144
|
+
WebkitFontSmoothing: "antialiased"
|
145
|
+
},
|
146
|
+
/** Make media elements responsive */
|
147
|
+
"img, picture, video, canvas, svg": {
|
148
|
+
display: "block",
|
149
|
+
maxWidth: "100%"
|
150
|
+
},
|
151
|
+
/** Avoid overflow of text */
|
152
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
153
|
+
overflowWrap: "break-word"
|
154
|
+
},
|
155
|
+
/** Improve text wrapping */
|
156
|
+
p: {
|
157
|
+
textWrap: "pretty"
|
158
|
+
},
|
159
|
+
"h1, h2, h3, h4, h5, h6": {
|
160
|
+
textWrap: "balance"
|
161
|
+
},
|
162
|
+
/** Improve button line height */
|
163
|
+
button: {
|
164
|
+
lineHeight: "1em"
|
165
|
+
},
|
166
|
+
/** Improve form elements */
|
167
|
+
"input, optgroup, select, textarea": {
|
168
|
+
fontFamily: "inherit",
|
169
|
+
fontSize: "100%",
|
170
|
+
lineHeight: "1.15em"
|
171
|
+
}
|
172
|
+
}, H = {
|
173
|
+
externalModules: []
|
174
|
+
}, ot = (t) => {
|
175
|
+
if (H.externalModules.length > 0) return H.externalModules;
|
176
|
+
const e = f(t, "salty.config.ts"), n = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
177
|
+
if (!n) return [];
|
178
|
+
const r = n[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
179
|
+
return H.externalModules = r, r;
|
180
|
+
}, z = (t) => f(t, "./saltygen"), jt = ["salty", "css", "styles", "styled"], wt = (t = []) => new RegExp(`\\.(${[...jt, ...t].join("|")})\\.`), G = (t, e = []) => wt(e).test(t), Ft = async (t) => {
|
181
|
+
const e = z(t), s = f(t, "salty.config.ts"), n = f(e, "salty.config.js"), r = await st(t), i = ot(t);
|
182
|
+
await Y.build({
|
183
|
+
entryPoints: [s],
|
184
|
+
minify: !0,
|
185
|
+
treeShaking: !0,
|
186
|
+
bundle: !0,
|
187
|
+
outfile: n,
|
188
|
+
format: r,
|
189
|
+
external: i
|
190
|
+
});
|
191
|
+
const d = Date.now(), { config: c } = await import(`${n}?t=${d}`);
|
192
|
+
return c;
|
193
|
+
}, xt = async (t) => {
|
194
|
+
const e = await Ft(t), s = /* @__PURE__ */ new Set(), n = (g, y = []) => g ? Object.entries(g).flatMap(([$, u]) => {
|
195
|
+
if (!u) return;
|
196
|
+
if (typeof u == "object") return n(u, [...y, $]);
|
197
|
+
const P = nt($), _ = O($), A = [...y, P].join(".");
|
198
|
+
s.add(`"${A}"`);
|
199
|
+
const V = [...y.map(O), _].join("-"), { result: R } = Q(u);
|
200
|
+
return `--${V}: ${R};`;
|
201
|
+
}) : [], r = (g) => g ? Object.entries(g).flatMap(([y, $]) => {
|
202
|
+
const u = n($);
|
203
|
+
return y === "base" ? u.join("") : `${y} { ${u.join("")} }`;
|
204
|
+
}) : [], i = (g) => g ? Object.entries(g).flatMap(([y, $]) => Object.entries($).flatMap(([u, P]) => {
|
205
|
+
const _ = n(P, [y]), A = `.${y}-${u}, [data-${y}="${u}"]`, V = _.join("");
|
206
|
+
return `${A} { ${V} }`;
|
207
|
+
})) : [], d = n(e.variables), c = r(e.responsiveVariables), b = i(e.conditionalVariables), o = z(t), a = f(o, "css/_variables.css"), j = `:root { ${d.join("")} ${c.join("")} } ${b.join("")}`;
|
208
|
+
T(a, j);
|
209
|
+
const w = f(o, "css/_global.css"), S = D(e.global, "");
|
210
|
+
T(w, `@layer global { ${S} }`);
|
211
|
+
const l = f(o, "css/_reset.css"), k = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : St, m = D(k, "");
|
212
|
+
T(l, `@layer reset { ${m} }`);
|
213
|
+
const F = f(o, "css/_templates.css"), h = v(e.templates), p = ht(e.templates);
|
214
|
+
T(F, h);
|
215
|
+
const C = f(o, "types/css-tokens.d.ts"), E = `
|
216
|
+
// Variable types
|
217
|
+
type VariableTokens = ${[...s].join("|")};
|
218
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
219
|
+
|
220
|
+
// Template types
|
221
|
+
type TemplateTokens = {
|
222
|
+
${Object.entries(p).map(([g, y]) => `${g}?: ${y}`).join(`
|
223
|
+
`)}
|
224
|
+
}
|
225
|
+
`;
|
226
|
+
T(C, E);
|
227
|
+
}, L = async (t, e, s) => {
|
228
|
+
const n = K(e), r = f(s, "./temp");
|
229
|
+
I(r) || W(r);
|
230
|
+
const i = B(e);
|
231
|
+
let d = J(e, "utf8");
|
232
|
+
d = d.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
233
|
+
const c = f(s, "js", n + ".js"), b = ot(t), o = await st(t);
|
234
|
+
await Y.build({
|
235
|
+
stdin: {
|
236
|
+
contents: d,
|
237
|
+
sourcefile: i.base,
|
238
|
+
resolveDir: i.dir,
|
239
|
+
loader: "tsx"
|
240
|
+
},
|
241
|
+
minify: !1,
|
242
|
+
treeShaking: !0,
|
243
|
+
bundle: !0,
|
244
|
+
outfile: c,
|
245
|
+
format: o,
|
246
|
+
target: ["node20"],
|
247
|
+
keepNames: !0,
|
248
|
+
external: b,
|
249
|
+
packages: "external"
|
250
|
+
});
|
251
|
+
const a = Date.now();
|
252
|
+
return await import(`${c}?t=${a}`);
|
253
|
+
}, q = async (t) => {
|
254
|
+
const e = z(t), s = f(e, "salty.config.js"), { config: n } = await import(s);
|
255
|
+
return n;
|
256
|
+
}, rt = () => {
|
257
|
+
try {
|
258
|
+
return process.env.NODE_ENV === "production";
|
259
|
+
} catch {
|
260
|
+
return !1;
|
261
|
+
}
|
262
|
+
}, Et = async (t, e = rt()) => {
|
263
|
+
try {
|
264
|
+
e ? X.info("Generating CSS in production mode! 🔥") : X.info("Generating CSS in development mode! 🚀");
|
265
|
+
const s = [], n = [], r = z(t), i = f(r, "index.css");
|
266
|
+
(() => {
|
267
|
+
I(r) && ct("rm -rf " + r), W(r), W(f(r, "css")), W(f(r, "types"));
|
268
|
+
})(), await xt(t);
|
269
|
+
const c = await q(t);
|
270
|
+
async function b(l, x) {
|
271
|
+
const k = ["node_modules", "saltygen"], m = at(l);
|
272
|
+
if (m.isDirectory()) {
|
273
|
+
const F = lt(l);
|
274
|
+
if (k.some((p) => l.includes(p))) return;
|
275
|
+
await Promise.all(F.map((p) => b(f(l, p), f(x, p))));
|
276
|
+
} else if (m.isFile() && G(l)) {
|
277
|
+
const h = await L(t, l, r), p = [];
|
278
|
+
Object.entries(h).forEach(([$, u]) => {
|
279
|
+
if (u.isKeyframes && u.css) {
|
280
|
+
const V = `a_${u.animationName}.css`, R = `css/${V}`, it = f(r, R);
|
281
|
+
s.push(V), T(it, u.css);
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
if (!u.generator) return;
|
285
|
+
const P = u.generator._withBuildContext({
|
286
|
+
name: $,
|
287
|
+
config: c,
|
288
|
+
prod: e
|
289
|
+
});
|
290
|
+
n[P.priority] || (n[P.priority] = []), n[P.priority].push(P.cssFileName), p.push(P.cssFileName);
|
291
|
+
const _ = `css/${P.cssFileName}`, A = f(r, _);
|
292
|
+
T(A, P.css);
|
293
|
+
});
|
294
|
+
const C = p.map(($) => `@import url('./${$}');`).join(`
|
295
|
+
`), N = K(l, 6), E = B(l), g = O(E.name), y = f(r, `css/f_${g}-${N}.css`);
|
296
|
+
T(y, C);
|
297
|
+
}
|
298
|
+
}
|
299
|
+
await b(t, r);
|
300
|
+
const o = s.map((l) => `@import url('./css/${l}');`).join(`
|
301
|
+
`);
|
302
|
+
let S = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
303
|
+
|
304
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
305
|
+
try {
|
306
|
+
return J(f(r, "css", l), "utf8").length > 0;
|
307
|
+
} catch {
|
308
|
+
return !1;
|
309
|
+
}
|
310
|
+
}).map((l) => `@import url('./css/${l}');`).join(`
|
311
|
+
`)}
|
312
|
+
${o}`;
|
313
|
+
if (c.importStrategy !== "component") {
|
314
|
+
const l = n.flat().map((x) => `@import url('./css/${x}');`).join(`
|
315
|
+
`);
|
316
|
+
S += l;
|
317
|
+
}
|
318
|
+
T(i, S);
|
319
|
+
} catch (s) {
|
320
|
+
console.error(s);
|
321
|
+
}
|
322
|
+
}, Dt = async (t, e) => {
|
323
|
+
try {
|
324
|
+
const s = [], n = f(t, "./saltygen"), r = f(n, "index.css");
|
325
|
+
if (G(e)) {
|
326
|
+
const d = await q(t), c = await L(t, e, n);
|
327
|
+
Object.entries(c).forEach(([w, S]) => {
|
328
|
+
if (!S.generator) return;
|
329
|
+
const l = S.generator._withBuildContext({
|
330
|
+
name: w,
|
331
|
+
config: d
|
332
|
+
}), x = `css/${l.cssFileName}`, k = f(n, x);
|
333
|
+
s.push(l.cssFileName), T(k, l.css);
|
334
|
+
});
|
335
|
+
const b = J(r, "utf8").split(`
|
336
|
+
`), o = s.map((w) => `@import url('../saltygen/css/${w}');`), j = [.../* @__PURE__ */ new Set([...b, ...o])].join(`
|
337
|
+
`);
|
338
|
+
T(r, j);
|
339
|
+
}
|
340
|
+
} catch (s) {
|
341
|
+
console.error(s);
|
342
|
+
}
|
343
|
+
}, Ot = async (t, e, s = rt()) => {
|
344
|
+
try {
|
345
|
+
const n = f(t, "./saltygen");
|
346
|
+
if (G(e)) {
|
347
|
+
const i = J(e, "utf8");
|
348
|
+
i.replace(/^(?!export\s)const\s.*/gm, (a) => `export ${a}`) !== i && await pt(e, i);
|
349
|
+
const c = await q(t), b = await L(t, e, n);
|
350
|
+
let o = i;
|
351
|
+
if (Object.entries(b).forEach(([a, j]) => {
|
352
|
+
var $;
|
353
|
+
if (j.isKeyframes || !j.generator) return;
|
354
|
+
const w = j.generator._withBuildContext({
|
355
|
+
name: a,
|
356
|
+
config: c,
|
357
|
+
prod: s
|
358
|
+
}), S = new RegExp(`\\s${a}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
|
359
|
+
if (!S) return console.error("Could not find the original declaration");
|
360
|
+
const l = ($ = S.at(1)) == null ? void 0 : $.trim(), x = new RegExp(`\\s${a}[=\\s]+styled\\(`, "g").exec(o);
|
361
|
+
if (!x) return console.error("Could not find the original declaration");
|
362
|
+
const { index: k } = x;
|
363
|
+
let m = !1;
|
364
|
+
const F = setTimeout(() => m = !0, 5e3);
|
365
|
+
let h = 0, p = !1, C = 0;
|
366
|
+
for (; !p && !m; ) {
|
367
|
+
const u = o[k + h];
|
368
|
+
u === "(" && C++, u === ")" && C--, C === 0 && u === ")" && (p = !0), h > o.length && (m = !0), h++;
|
369
|
+
}
|
370
|
+
if (!m) clearTimeout(F);
|
371
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
372
|
+
const N = k + h, E = o.slice(k, N), g = o, y = ` ${a} = styled(${l}, "${w.classNames}", ${JSON.stringify(w.props)});`;
|
373
|
+
o = o.replace(E, y), g === o && console.error("Minimize file failed to change content", { name: a, tagName: l });
|
374
|
+
}), c.importStrategy === "component") {
|
375
|
+
const a = K(e, 6), j = B(e);
|
376
|
+
o = `import '../../saltygen/css/${`f_${O(j.name)}-${a}.css`}';
|
377
|
+
${o}`;
|
378
|
+
}
|
379
|
+
return o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
380
|
+
}
|
381
|
+
} catch (n) {
|
382
|
+
console.error("Error in minimizeFile:", n);
|
383
|
+
}
|
384
|
+
};
|
385
|
+
export {
|
386
|
+
Dt as a,
|
387
|
+
Et as g,
|
388
|
+
Ot as m,
|
389
|
+
wt as s
|
390
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";const ie=require("esbuild"),ce=require("child_process"),c=require("path"),u=require("fs"),U=require("fs/promises"),R=require("winston");var W=typeof document<"u"?document.currentScript:null;function ae(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const G=ae(ie),L=e=>String.fromCharCode(e+(e>25?39:97)),le=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=L(n%52)+s;return s=L(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},fe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},q=(e,t=5)=>{const s=fe(5381,JSON.stringify(e))>>>0;return le(s,t)};function D(e){return e?typeof e!="string"?D(String(e)):e.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?"-":"")+t.toLowerCase()):""}const ue=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:r,transform:i}=n;e=e.replace(r,g=>{const{value:a,css:j}=i(g);return j&&s.push(j),a})}),{result:e,additionalCss:s}},X=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${D(n[1].replaceAll(".","-"))})`)}:{result:e},_=(e,t,s,n)=>{if(!e)return"";const r=[],i=Object.entries(e).reduce((a,[j,o])=>{const l=j.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return a;if(l==="variants")return Object.entries(o).forEach(([b,p])=>{p&&Object.entries(p).forEach(([P,N])=>{if(!N)return;const O=`${t}.${b}-${P}`,y=_(N,O);r.push(y)})}),a;if(l==="defaultVariants")return a;if(l==="compoundVariants")return o.forEach(b=>{const{css:p,...P}=b,N=Object.entries(P).reduce((y,[m,S])=>`${y}.${m}-${S}`,t),O=_(p,N);r.push(O)}),a;if(l.startsWith("@")){const b=_(o,t),p=`${l} {
|
2
|
+
${b.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return r.push(p),a}const h=j.includes("&")?l.replace("&",t):l.startsWith(":")?`${t}${l}`:`${t} ${l}`,x=_(o,h);return r.push(x),a}const w=l.startsWith("-")?l:D(l),F=(h,x=";")=>a=`${a}${h}${x}`,$=h=>F(`${w}:${h}`);if(typeof o=="number")return $(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return a;const{modifiers:f}={},C=function*(){yield X(o),yield ue(o,f)}();for(const{result:h,additionalCss:x=[]}of C)o=h,x.forEach(b=>{const p=_(b,"");F(p,"")});return $(o)},"");if(!i)return r.join(`
|
6
|
+
`);if(!t)return i;let g="";return g=`${t} { ${i} }`,[g,...r].join(`
|
7
|
+
`)},Y=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([r,i])=>{if(typeof i=="object"){if(!i)return;const g=r.trim(),a=Y(i,[...t,g]);s.push(a)}else n[r]=i}),Object.keys(n).length){const r=t.map(D).join("-"),i=_(n,`.${r}`);s.push(i)}return s.join(`
|
8
|
+
`)},pe=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=Q(n).map(r=>`"${r}"`).join(" | ")),t),{}),Q=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,r])=>{const i=t?`${t}.${n}`:n;return typeof r=="object"?Q(r,i,s):s.add(t)}),[...s]):[],v=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return u.existsSync(t)?t:v(c.join(e,".."))},de=async e=>{const t=v(e);return await U.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ge=async e=>{const t=await de(e);if(t)return t.type};let M;const ee=async e=>{if(M)return M;const t=await ge(e);return t==="module"?M="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:W&&W.tagName.toUpperCase()==="SCRIPT"&&W.src||new URL("index-DYblhpWE.cjs",document.baseURI).href).endsWith(".cjs"))&&(M="cjs"),M||"esm"},K=R.createLogger({level:"debug",format:R.format.combine(R.format.colorize(),R.format.cli()),transports:[new R.transports.Console({})]});function te(e){return e?typeof e!="string"?te(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,s)=>(s>0?".":"")+t.toLowerCase()):""}const ye={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},Z={externalModules:[]},se=e=>{if(Z.externalModules.length>0)return Z.externalModules;const t=c.join(e,"salty.config.ts"),n=u.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const r=n[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return Z.externalModules=r,r},z=e=>c.join(e,"./saltygen"),me=["salty","css","styles","styled"],ne=(e=[])=>new RegExp(`\\.(${[...me,...e].join("|")})\\.`),I=(e,t=[])=>ne(t).test(e),he=async e=>{const t=z(e),s=c.join(e,"salty.config.ts"),n=c.join(t,"salty.config.js"),r=await ee(e),i=se(e);await G.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:r,external:i});const g=Date.now(),{config:a}=await import(`${n}?t=${g}`);return a},be=async e=>{const t=await he(e),s=new Set,n=(y,m=[])=>y?Object.entries(y).flatMap(([S,d])=>{if(!d)return;if(typeof d=="object")return n(d,[...m,S]);const T=te(S),V=D(S),A=[...m,T].join(".");s.add(`"${A}"`);const E=[...m.map(D),V].join("-"),{result:J}=X(d);return`--${E}: ${J};`}):[],r=y=>y?Object.entries(y).flatMap(([m,S])=>{const d=n(S);return m==="base"?d.join(""):`${m} { ${d.join("")} }`}):[],i=y=>y?Object.entries(y).flatMap(([m,S])=>Object.entries(S).flatMap(([d,T])=>{const V=n(T,[m]),A=`.${m}-${d}, [data-${m}="${d}"]`,E=V.join("");return`${A} { ${E} }`})):[],g=n(t.variables),a=r(t.responsiveVariables),j=i(t.conditionalVariables),o=z(e),l=c.join(o,"css/_variables.css"),w=`:root { ${g.join("")} ${a.join("")} } ${j.join("")}`;u.writeFileSync(l,w);const F=c.join(o,"css/_global.css"),$=_(t.global,"");u.writeFileSync(F,`@layer global { ${$} }`);const f=c.join(o,"css/_reset.css"),C=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:ye,h=_(C,"");u.writeFileSync(f,`@layer reset { ${h} }`);const x=c.join(o,"css/_templates.css"),b=Y(t.templates),p=pe(t.templates);u.writeFileSync(x,b);const P=c.join(o,"types/css-tokens.d.ts"),O=`
|
9
|
+
// Variable types
|
10
|
+
type VariableTokens = ${[...s].join("|")};
|
11
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
|
+
|
13
|
+
// Template types
|
14
|
+
type TemplateTokens = {
|
15
|
+
${Object.entries(p).map(([y,m])=>`${y}?: ${m}`).join(`
|
16
|
+
`)}
|
17
|
+
}
|
18
|
+
`;u.writeFileSync(P,O)},H=async(e,t,s)=>{const n=q(t),r=c.join(s,"./temp");u.existsSync(r)||u.mkdirSync(r);const i=c.parse(t);let g=u.readFileSync(t,"utf8");g=g.replace(/styled\([^"'`{,]+,/g,"styled('div',");const a=c.join(s,"js",n+".js"),j=se(e),o=await ee(e);await G.build({stdin:{contents:g,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:a,format:o,target:["node20"],keepNames:!0,external:j,packages:"external"});const l=Date.now();return await import(`${a}?t=${l}`)},B=async e=>{const t=z(e),s=c.join(t,"salty.config.js"),{config:n}=await import(s);return n},oe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},je=async(e,t=oe())=>{try{t?K.info("Generating CSS in production mode! 🔥"):K.info("Generating CSS in development mode! 🚀");const s=[],n=[],r=z(e),i=c.join(r,"index.css");(()=>{u.existsSync(r)&&ce.execSync("rm -rf "+r),u.mkdirSync(r),u.mkdirSync(c.join(r,"css")),u.mkdirSync(c.join(r,"types"))})(),await be(e);const a=await B(e);async function j(f,k){const C=["node_modules","saltygen"],h=u.statSync(f);if(h.isDirectory()){const x=u.readdirSync(f);if(C.some(p=>f.includes(p)))return;await Promise.all(x.map(p=>j(c.join(f,p),c.join(k,p))))}else if(h.isFile()&&I(f)){const b=await H(e,f,r),p=[];Object.entries(b).forEach(([S,d])=>{if(d.isKeyframes&&d.css){const E=`a_${d.animationName}.css`,J=`css/${E}`,re=c.join(r,J);s.push(E),u.writeFileSync(re,d.css);return}if(!d.generator)return;const T=d.generator._withBuildContext({name:S,config:a,prod:t});n[T.priority]||(n[T.priority]=[]),n[T.priority].push(T.cssFileName),p.push(T.cssFileName);const V=`css/${T.cssFileName}`,A=c.join(r,V);u.writeFileSync(A,T.css)});const P=p.map(S=>`@import url('./${S}');`).join(`
|
19
|
+
`),N=q(f,6),O=c.parse(f),y=D(O.name),m=c.join(r,`css/f_${y}-${N}.css`);u.writeFileSync(m,P)}}await j(e,r);const o=s.map(f=>`@import url('./css/${f}');`).join(`
|
20
|
+
`);let $=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
|
+
|
22
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(c.join(r,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
23
|
+
`)}
|
24
|
+
${o}`;if(a.importStrategy!=="component"){const f=n.flat().map(k=>`@import url('./css/${k}');`).join(`
|
25
|
+
`);$+=f}u.writeFileSync(i,$)}catch(s){console.error(s)}},Se=async(e,t)=>{try{const s=[],n=c.join(e,"./saltygen"),r=c.join(n,"index.css");if(I(t)){const g=await B(e),a=await H(e,t,n);Object.entries(a).forEach(([F,$])=>{if(!$.generator)return;const f=$.generator._withBuildContext({name:F,config:g}),k=`css/${f.cssFileName}`,C=c.join(n,k);s.push(f.cssFileName),u.writeFileSync(C,f.css)});const j=u.readFileSync(r,"utf8").split(`
|
26
|
+
`),o=s.map(F=>`@import url('../saltygen/css/${F}');`),w=[...new Set([...j,...o])].join(`
|
27
|
+
`);u.writeFileSync(r,w)}}catch(s){console.error(s)}},$e=async(e,t,s=oe())=>{try{const n=c.join(e,"./saltygen");if(I(t)){const i=u.readFileSync(t,"utf8");i.replace(/^(?!export\s)const\s.*/gm,l=>`export ${l}`)!==i&&await U.writeFile(t,i);const a=await B(e),j=await H(e,t,n);let o=i;if(Object.entries(j).forEach(([l,w])=>{var S;if(w.isKeyframes||!w.generator)return;const F=w.generator._withBuildContext({name:l,config:a,prod:s}),$=new RegExp(`\\s${l}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!$)return console.error("Could not find the original declaration");const f=(S=$.at(1))==null?void 0:S.trim(),k=new RegExp(`\\s${l}[=\\s]+styled\\(`,"g").exec(o);if(!k)return console.error("Could not find the original declaration");const{index:C}=k;let h=!1;const x=setTimeout(()=>h=!0,5e3);let b=0,p=!1,P=0;for(;!p&&!h;){const d=o[C+b];d==="("&&P++,d===")"&&P--,P===0&&d===")"&&(p=!0),b>o.length&&(h=!0),b++}if(!h)clearTimeout(x);else throw new Error("Failed to find the end of the styled call and timed out");const N=C+b,O=o.slice(C,N),y=o,m=` ${l} = styled(${f}, "${F.classNames}", ${JSON.stringify(F.props)});`;o=o.replace(O,m),y===o&&console.error("Minimize file failed to change content",{name:l,tagName:f})}),a.importStrategy==="component"){const l=q(t,6),w=c.parse(t);o=`import '../../saltygen/css/${`f_${D(w.name)}-${l}.css`}';
|
28
|
+
${o}`}return o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=je;exports.generateFile=Se;exports.minimizeFile=$e;exports.saltyFileRegExp=ne;
|
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-DYblhpWE.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as n } from "path";
|
2
|
-
import { s as u, g as i } from "./index-
|
2
|
+
import { s as u, g as i } from "./index-Cp7uNPK9.js";
|
3
3
|
const g = (s, e, o = !1, r = !1) => {
|
4
4
|
var a, l, t;
|
5
5
|
(l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-DYblhpWE.cjs");async function n(){const{dir:e}=this.getOptions(),{resourcePath:t}=this;return await i.generateFile(e,t),await i.minimizeFile(e,t)}module.exports=n;
|
package/loader.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/webpack",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.122",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
}
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@salty-css/core": "^0.0.1-alpha.
|
37
|
+
"@salty-css/core": "^0.0.1-alpha.122",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|
package/index-C85_DMmG.cjs
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";const rt=require("esbuild"),it=require("child_process"),a=require("path"),f=require("fs"),U=require("fs/promises"),_=require("winston");var Z=typeof document<"u"?document.currentScript:null;function ct(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const G=ct(rt),L=t=>String.fromCharCode(t+(t>25?39:97)),at=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=L(n%52)+s;return s=L(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},lt=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},q=(t,e=5)=>{const s=lt(5381,JSON.stringify(t))>>>0;return at(s,e)};function V(t){return t?typeof t!="string"?V(String(t)):t.replace(/[\s.]/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const ft=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:r,transform:i}=n;t=t.replace(r,y=>{const{value:c,css:j}=i(y);return j&&s.push(j),c})}),{result:t,additionalCss:s}},X=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:t},E=(t,e,s,n)=>{if(!t)return"";const r=[],i=Object.entries(t).reduce((c,[j,o])=>{const d=j.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return c;if(d==="variants")return Object.entries(o).forEach(([w,u])=>{u&&Object.entries(u).forEach(([P,C])=>{if(!C)return;const O=`${e}.${w}-${P}`,g=E(C,O);r.push(g)})}),c;if(d==="defaultVariants")return c;if(d==="compoundVariants")return o.forEach(w=>{const{css:u,...P}=w,C=Object.entries(P).reduce((g,[p,m])=>`${g}.${p}-${m}`,e),O=E(u,C);r.push(O)}),c;if(d.startsWith("@")){const w=E(o,e),u=`${d} {
|
2
|
-
${w.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return r.push(u),c}const h=j.includes("&")?d.replace("&",e):d.startsWith(":")?`${e}${d}`:`${e} ${d}`,$=E(o,h);return r.push($),c}const S=d.startsWith("-")?d:V(d),F=(h,$=";")=>c=`${c}${h}${$}`,x=h=>F(`${S}:${h}`);if(typeof o=="number")return x(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return c;const{modifiers:l}={},T=function*(){yield X(o),yield ft(o,l)}();for(const{result:h,additionalCss:$=[]}of T)o=h,$.forEach(w=>{const u=E(w,"");F(u,"")});return x(o)},"");if(!i)return r.join(`
|
6
|
-
`);if(!e)return i;let y="";return y=`${e} { ${i} }`,[y,...r].join(`
|
7
|
-
`)},Y=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([r,i])=>{if(typeof i=="object"){if(!i)return;const y=r.trim(),c=Y(i,[...e,y]);s.push(c)}else n[r]=i}),Object.keys(n).length){const r=e.map(V).join("-"),i=E(n,`.${r}`);s.push(i)}return s.join(`
|
8
|
-
`)},ut=t=>Object.entries(t).reduce((e,[s,n])=>(typeof n=="object"&&(e[s]=Q(n).map(r=>`"${r}"`).join(" | ")),e),{}),Q=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,r])=>{const i=e?`${e}.${n}`:n;return typeof r=="object"?Q(r,i,s):s.add(e)}),[...s]):[],v=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=a.join(t,"package.json");return f.existsSync(e)?e:v(a.join(t,".."))},pt=async t=>{const e=v(t);return await U.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},dt=async t=>{const e=await pt(t);if(e)return e.type};let N;const tt=async t=>{if(N)return N;const e=await dt(t);return e==="module"?N="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:Z&&Z.tagName.toUpperCase()==="SCRIPT"&&Z.src||new URL("index-C85_DMmG.cjs",document.baseURI).href).endsWith(".cjs"))&&(N="cjs"),N||"esm"},K=_.createLogger({level:"debug",format:_.format.combine(_.format.colorize(),_.format.cli()),transports:[new _.transports.Console({})]});function et(t){return t?typeof t!="string"?et(String(t)):t.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?".":"")+e.toLowerCase()):""}const gt={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},z={externalModules:[]},st=t=>{if(z.externalModules.length>0)return z.externalModules;const e=a.join(t,"salty.config.ts"),n=f.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const r=n[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return z.externalModules=r,r},J=t=>a.join(t,"./saltygen"),yt=["salty","css","styles","styled"],nt=(t=[])=>new RegExp(`\\.(${[...yt,...t].join("|")})\\.`),I=(t,e=[])=>nt(e).test(t),ht=async t=>{const e=J(t),s=a.join(t,"salty.config.ts"),n=a.join(e,"salty.config.js"),r=await tt(t),i=st(t);await G.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:r,external:i});const y=Date.now(),{config:c}=await import(`${n}?t=${y}`);return c},mt=async t=>{const e=await ht(t),s=new Set,n=(g,p=[])=>g?Object.entries(g).flatMap(([m,b])=>{if(!b)return;if(typeof b=="object")return n(b,[...p,m]);const D=et(m),A=V(m),M=[...p,D].join(".");s.add(`"${M}"`);const R=[...p.map(V),A].join("-"),{result:W}=X(b);return`--${R}: ${W};`}):[],r=g=>g?Object.entries(g).flatMap(([p,m])=>{const b=n(m);return p==="base"?b.join(""):`${p} { ${b.join("")} }`}):[],i=g=>g?Object.entries(g).flatMap(([p,m])=>Object.entries(m).flatMap(([b,D])=>{const A=n(D,[p]),M=`.${p}-${b}, [data-${p}="${b}"]`,R=A.join("");return`${M} { ${R} }`})):[],y=n(e.variables),c=r(e.responsiveVariables),j=i(e.conditionalVariables),o=J(t),d=a.join(o,"css/variables.css"),S=`:root { ${y.join("")} ${c.join("")} } ${j.join("")}`;f.writeFileSync(d,S);const F=a.join(o,"css/global.css"),x=E(e.global,"");f.writeFileSync(F,`@layer global { ${x} }`);const l=a.join(o,"css/reset.css"),T=e.reset==="none"?{}:typeof e.reset=="object"?e.reset:gt,h=E(T,"");f.writeFileSync(l,`@layer reset { ${h} }`);const $=a.join(o,"css/templates.css"),w=Y(e.templates),u=ut(e.templates);f.writeFileSync($,w);const P=a.join(o,"types/css-tokens.d.ts"),O=`
|
9
|
-
// Variable types
|
10
|
-
type VariableTokens = ${[...s].join("|")};
|
11
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
|
-
|
13
|
-
// Template types
|
14
|
-
type TemplateTokens = {
|
15
|
-
${Object.entries(u).map(([g,p])=>`${g}?: ${p}`).join(`
|
16
|
-
`)}
|
17
|
-
}
|
18
|
-
`;f.writeFileSync(P,O)},H=async(t,e,s)=>{const n=q(e),r=a.join(s,"./temp");f.existsSync(r)||f.mkdirSync(r);const i=a.parse(e);let y=f.readFileSync(e,"utf8");y=y.replace(/styled\([^"'`{,]+,/g,"styled('div',");const c=a.join(s,"js",n+".js"),j=st(t),o=await tt(t);await G.build({stdin:{contents:y,sourcefile:i.base,resolveDir:i.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:c,format:o,target:["node20"],keepNames:!0,external:j,packages:"external"});const d=Date.now();return await import(`${c}?t=${d}`)},B=async t=>{const e=J(t),s=a.join(e,"salty.config.js"),{config:n}=await import(s);return n},ot=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},bt=async(t,e=ot())=>{try{e?K.info("Generating CSS in production mode! 🔥"):K.info("Generating CSS in development mode! 🚀");const s=[],n=[],r=J(t),i=a.join(r,"index.css");(()=>{f.existsSync(r)&&it.execSync("rm -rf "+r),f.mkdirSync(r),f.mkdirSync(a.join(r,"css")),f.mkdirSync(a.join(r,"types"))})(),await mt(t);const c=await B(t);async function j(l,k){const T=["node_modules","saltygen"],h=f.statSync(l);if(h.isDirectory()){const $=f.readdirSync(l);if(T.some(u=>l.includes(u)))return;await Promise.all($.map(u=>j(a.join(l,u),a.join(k,u))))}else if(h.isFile()&&I(l)){const w=await H(t,l,r),u=[];Object.entries(w).forEach(([g,p])=>{if(p.isKeyframes&&p.css){const M=`${p.animationName}.css`,R=`css/${M}`,W=a.join(r,R);s.push(M),f.writeFileSync(W,p.css);return}if(!p.generator)return;const m=p.generator._withBuildContext({name:g,config:c,prod:e}),b=`${m.hash}-${m.priority}.css`;n[m.priority]||(n[m.priority]=[]),n[m.priority].push(b),u.push(b);const D=`css/${b}`,A=a.join(r,D);f.writeFileSync(A,m.css)});const P=u.map(g=>`@import url('./${g}');`).join(`
|
19
|
-
`),C=q(l,6),O=a.join(r,`css/${C}.css`);f.writeFileSync(O,P)}}await j(t,r);const o=s.map(l=>`@import url('./css/${l}');`).join(`
|
20
|
-
`);let x=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
|
-
|
22
|
-
${["variables.css","reset.css","global.css","templates.css"].filter(l=>{try{return f.readFileSync(a.join(r,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
23
|
-
`)}
|
24
|
-
${o}`;if(c.importStrategy!=="component"){const l=n.flat().map(k=>`@import url('./css/${k}');`).join(`
|
25
|
-
`);x+=l}f.writeFileSync(i,x)}catch(s){console.error(s)}},jt=async(t,e)=>{try{const s=[],n=a.join(t,"./saltygen"),r=a.join(n,"index.css");if(I(e)){const y=await B(t),c=await H(t,e,n);Object.entries(c).forEach(([F,x])=>{if(!x.generator)return;const l=x.generator._withBuildContext({name:F,config:y}),k=`${l.hash}-${l.priority}.css`,T=`css/${k}`,h=a.join(n,T);s.push(k),f.writeFileSync(h,l.css)});const j=f.readFileSync(r,"utf8").split(`
|
26
|
-
`),o=s.map(F=>`@import url('../saltygen/css/${F}');`),S=[...new Set([...j,...o])].join(`
|
27
|
-
`);f.writeFileSync(r,S)}}catch(s){console.error(s)}},St=async(t,e,s=ot())=>{try{const n=a.join(t,"./saltygen");if(I(e)){const i=f.readFileSync(e,"utf8");i.replace(/^(?!export\s)const\s.*/gm,S=>`export ${S}`)!==i&&await U.writeFile(e,i);const c=await B(t),j=await H(t,e,n);let o=i;Object.entries(j).forEach(([S,F])=>{var b;if(F.isKeyframes||!F.generator)return;const x=F.generator._withBuildContext({name:S,config:c,prod:s}),l=new RegExp(`\\s${S}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(i);if(!l)return console.error("Could not find the original declaration");const k=(b=l.at(1))==null?void 0:b.trim(),T=new RegExp(`\\s${S}[=\\s]+styled\\(`,"g").exec(o);if(!T)return console.error("Could not find the original declaration");const{index:h}=T;let $=!1;const w=setTimeout(()=>$=!0,5e3);let u=0,P=!1,C=0;for(;!P&&!$;){const D=o[h+u];D==="("&&C++,D===")"&&C--,C===0&&D===")"&&(P=!0),u>o.length&&($=!0),u++}if(!$)clearTimeout(w);else throw new Error("Failed to find the end of the styled call and timed out");const O=h+u,g=o.slice(h,O),p=o,m=` ${S} = styled(${k}, "${x.classNames}", ${JSON.stringify(x.props)});`;o=o.replace(g,m),p===o&&console.error("Minimize file failed to change content",{name:S,tagName:k})});const d=q(e,6);return c.importStrategy==="component"&&(o=`import '../../saltygen/css/${d}.css';
|
28
|
-
${o}`),o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=bt;exports.generateFile=jt;exports.minimizeFile=St;exports.saltyFileRegExp=nt;
|
package/index-DAmJ383d.js
DELETED
@@ -1,388 +0,0 @@
|
|
1
|
-
import * as X from "esbuild";
|
2
|
-
import { execSync as rt } from "child_process";
|
3
|
-
import { join as a, parse as it } from "path";
|
4
|
-
import { existsSync as B, writeFileSync as F, readFileSync as W, mkdirSync as R, statSync as ct, readdirSync as at } from "fs";
|
5
|
-
import { readFile as lt, writeFile as ft } from "fs/promises";
|
6
|
-
import { createLogger as pt, format as _, transports as ut } from "winston";
|
7
|
-
const q = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), gt = (t, e) => {
|
8
|
-
let s = "", n;
|
9
|
-
for (n = Math.abs(t); n > 52; n = n / 52 | 0) s = q(n % 52) + s;
|
10
|
-
return s = q(n % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
-
}, dt = (t, e) => {
|
12
|
-
let s = e.length;
|
13
|
-
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
|
-
return t;
|
15
|
-
}, I = (t, e = 5) => {
|
16
|
-
const s = dt(5381, JSON.stringify(t)) >>> 0;
|
17
|
-
return gt(s, e);
|
18
|
-
};
|
19
|
-
function N(t) {
|
20
|
-
return t ? typeof t != "string" ? N(String(t)) : t.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
|
21
|
-
}
|
22
|
-
const yt = (t, e) => {
|
23
|
-
if (typeof t != "string") return { result: t };
|
24
|
-
if (!e) return { result: t };
|
25
|
-
const s = [];
|
26
|
-
return Object.values(e).forEach((n) => {
|
27
|
-
const { pattern: r, transform: i } = n;
|
28
|
-
t = t.replace(r, (d) => {
|
29
|
-
const { value: c, css: b } = i(d);
|
30
|
-
return b && s.push(b), c;
|
31
|
-
});
|
32
|
-
}), { result: t, additionalCss: s };
|
33
|
-
}, Y = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${N(n[1].replaceAll(".", "-"))})`) } : { result: t }, O = (t, e, s, n) => {
|
34
|
-
if (!t) return "";
|
35
|
-
const r = [], i = Object.entries(t).reduce((c, [b, o]) => {
|
36
|
-
const u = b.trim();
|
37
|
-
if (typeof o == "function" && (o = o()), typeof o == "object") {
|
38
|
-
if (!o) return c;
|
39
|
-
if (u === "variants")
|
40
|
-
return Object.entries(o).forEach(([j, f]) => {
|
41
|
-
f && Object.entries(f).forEach(([P, C]) => {
|
42
|
-
if (!C) return;
|
43
|
-
const E = `${e}.${j}-${P}`, g = O(C, E);
|
44
|
-
r.push(g);
|
45
|
-
});
|
46
|
-
}), c;
|
47
|
-
if (u === "defaultVariants")
|
48
|
-
return c;
|
49
|
-
if (u === "compoundVariants")
|
50
|
-
return o.forEach((j) => {
|
51
|
-
const { css: f, ...P } = j, C = Object.entries(P).reduce((g, [p, h]) => `${g}.${p}-${h}`, e), E = O(f, C);
|
52
|
-
r.push(E);
|
53
|
-
}), c;
|
54
|
-
if (u.startsWith("@")) {
|
55
|
-
const j = O(o, e), f = `${u} {
|
56
|
-
${j.replace(`
|
57
|
-
`, `
|
58
|
-
`)}
|
59
|
-
}`;
|
60
|
-
return r.push(f), c;
|
61
|
-
}
|
62
|
-
const y = b.includes("&") ? u.replace("&", e) : u.startsWith(":") ? `${e}${u}` : `${e} ${u}`, S = O(o, y);
|
63
|
-
return r.push(S), c;
|
64
|
-
}
|
65
|
-
const $ = u.startsWith("-") ? u : N(u), w = (y, S = ";") => c = `${c}${y}${S}`, x = (y) => w(`${$}:${y}`);
|
66
|
-
if (typeof o == "number") return x(o);
|
67
|
-
if (typeof o != "string")
|
68
|
-
if ("toString" in o) o = o.toString();
|
69
|
-
else return c;
|
70
|
-
const { modifiers: l } = {}, T = function* () {
|
71
|
-
yield Y(o), yield yt(o, l);
|
72
|
-
}();
|
73
|
-
for (const { result: y, additionalCss: S = [] } of T)
|
74
|
-
o = y, S.forEach((j) => {
|
75
|
-
const f = O(j, "");
|
76
|
-
w(f, "");
|
77
|
-
});
|
78
|
-
return x(o);
|
79
|
-
}, "");
|
80
|
-
if (!i) return r.join(`
|
81
|
-
`);
|
82
|
-
if (!e) return i;
|
83
|
-
let d = "";
|
84
|
-
return d = `${e} { ${i} }`, [d, ...r].join(`
|
85
|
-
`);
|
86
|
-
}, Q = (t, e = []) => {
|
87
|
-
if (!t) return "";
|
88
|
-
const s = [], n = {};
|
89
|
-
if (Object.entries(t).forEach(([r, i]) => {
|
90
|
-
if (typeof i == "object") {
|
91
|
-
if (!i) return;
|
92
|
-
const d = r.trim(), c = Q(i, [...e, d]);
|
93
|
-
s.push(c);
|
94
|
-
} else
|
95
|
-
n[r] = i;
|
96
|
-
}), Object.keys(n).length) {
|
97
|
-
const r = e.map(N).join("-"), i = O(n, `.${r}`);
|
98
|
-
s.push(i);
|
99
|
-
}
|
100
|
-
return s.join(`
|
101
|
-
`);
|
102
|
-
}, ht = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = v(n).map((r) => `"${r}"`).join(" | ")), e), {}), v = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, r]) => {
|
103
|
-
const i = e ? `${e}.${n}` : n;
|
104
|
-
return typeof r == "object" ? v(r, i, s) : s.add(e);
|
105
|
-
}), [...s]) : [], tt = (t) => {
|
106
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
107
|
-
const e = a(t, "package.json");
|
108
|
-
return B(e) ? e : tt(a(t, ".."));
|
109
|
-
}, mt = async (t) => {
|
110
|
-
const e = tt(t);
|
111
|
-
return await lt(e, "utf-8").then(JSON.parse).catch(() => {
|
112
|
-
});
|
113
|
-
}, bt = async (t) => {
|
114
|
-
const e = await mt(t);
|
115
|
-
if (e)
|
116
|
-
return e.type;
|
117
|
-
};
|
118
|
-
let M;
|
119
|
-
const et = async (t) => {
|
120
|
-
if (M) return M;
|
121
|
-
const e = await bt(t);
|
122
|
-
return e === "module" ? M = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (M = "cjs"), M || "esm";
|
123
|
-
}, U = pt({
|
124
|
-
level: "debug",
|
125
|
-
format: _.combine(_.colorize(), _.cli()),
|
126
|
-
transports: [new ut.Console({})]
|
127
|
-
});
|
128
|
-
function st(t) {
|
129
|
-
return t ? typeof t != "string" ? st(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
130
|
-
}
|
131
|
-
const $t = {
|
132
|
-
/** Set box model to border-box */
|
133
|
-
"*, *::before, *::after": {
|
134
|
-
boxSizing: "border-box"
|
135
|
-
},
|
136
|
-
/** Remove default margin and padding */
|
137
|
-
"*": {
|
138
|
-
margin: 0
|
139
|
-
},
|
140
|
-
/** Remove adjust font properties */
|
141
|
-
html: {
|
142
|
-
lineHeight: 1.15,
|
143
|
-
textSizeAdjust: "100%",
|
144
|
-
WebkitFontSmoothing: "antialiased"
|
145
|
-
},
|
146
|
-
/** Make media elements responsive */
|
147
|
-
"img, picture, video, canvas, svg": {
|
148
|
-
display: "block",
|
149
|
-
maxWidth: "100%"
|
150
|
-
},
|
151
|
-
/** Avoid overflow of text */
|
152
|
-
"p, h1, h2, h3, h4, h5, h6": {
|
153
|
-
overflowWrap: "break-word"
|
154
|
-
},
|
155
|
-
/** Improve text wrapping */
|
156
|
-
p: {
|
157
|
-
textWrap: "pretty"
|
158
|
-
},
|
159
|
-
"h1, h2, h3, h4, h5, h6": {
|
160
|
-
textWrap: "balance"
|
161
|
-
},
|
162
|
-
/** Improve button line height */
|
163
|
-
button: {
|
164
|
-
lineHeight: "1em"
|
165
|
-
},
|
166
|
-
/** Improve form elements */
|
167
|
-
"input, optgroup, select, textarea": {
|
168
|
-
fontFamily: "inherit",
|
169
|
-
fontSize: "100%",
|
170
|
-
lineHeight: "1.15em"
|
171
|
-
}
|
172
|
-
}, H = {
|
173
|
-
externalModules: []
|
174
|
-
}, nt = (t) => {
|
175
|
-
if (H.externalModules.length > 0) return H.externalModules;
|
176
|
-
const e = a(t, "salty.config.ts"), n = W(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
177
|
-
if (!n) return [];
|
178
|
-
const r = n[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
179
|
-
return H.externalModules = r, r;
|
180
|
-
}, Z = (t) => a(t, "./saltygen"), St = ["salty", "css", "styles", "styled"], jt = (t = []) => new RegExp(`\\.(${[...St, ...t].join("|")})\\.`), K = (t, e = []) => jt(e).test(t), wt = async (t) => {
|
181
|
-
const e = Z(t), s = a(t, "salty.config.ts"), n = a(e, "salty.config.js"), r = await et(t), i = nt(t);
|
182
|
-
await X.build({
|
183
|
-
entryPoints: [s],
|
184
|
-
minify: !0,
|
185
|
-
treeShaking: !0,
|
186
|
-
bundle: !0,
|
187
|
-
outfile: n,
|
188
|
-
format: r,
|
189
|
-
external: i
|
190
|
-
});
|
191
|
-
const d = Date.now(), { config: c } = await import(`${n}?t=${d}`);
|
192
|
-
return c;
|
193
|
-
}, xt = async (t) => {
|
194
|
-
const e = await wt(t), s = /* @__PURE__ */ new Set(), n = (g, p = []) => g ? Object.entries(g).flatMap(([h, m]) => {
|
195
|
-
if (!m) return;
|
196
|
-
if (typeof m == "object") return n(m, [...p, h]);
|
197
|
-
const D = st(h), A = N(h), V = [...p, D].join(".");
|
198
|
-
s.add(`"${V}"`);
|
199
|
-
const J = [...p.map(N), A].join("-"), { result: z } = Y(m);
|
200
|
-
return `--${J}: ${z};`;
|
201
|
-
}) : [], r = (g) => g ? Object.entries(g).flatMap(([p, h]) => {
|
202
|
-
const m = n(h);
|
203
|
-
return p === "base" ? m.join("") : `${p} { ${m.join("")} }`;
|
204
|
-
}) : [], i = (g) => g ? Object.entries(g).flatMap(([p, h]) => Object.entries(h).flatMap(([m, D]) => {
|
205
|
-
const A = n(D, [p]), V = `.${p}-${m}, [data-${p}="${m}"]`, J = A.join("");
|
206
|
-
return `${V} { ${J} }`;
|
207
|
-
})) : [], d = n(e.variables), c = r(e.responsiveVariables), b = i(e.conditionalVariables), o = Z(t), u = a(o, "css/variables.css"), $ = `:root { ${d.join("")} ${c.join("")} } ${b.join("")}`;
|
208
|
-
F(u, $);
|
209
|
-
const w = a(o, "css/global.css"), x = O(e.global, "");
|
210
|
-
F(w, `@layer global { ${x} }`);
|
211
|
-
const l = a(o, "css/reset.css"), T = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : $t, y = O(T, "");
|
212
|
-
F(l, `@layer reset { ${y} }`);
|
213
|
-
const S = a(o, "css/templates.css"), j = Q(e.templates), f = ht(e.templates);
|
214
|
-
F(S, j);
|
215
|
-
const P = a(o, "types/css-tokens.d.ts"), E = `
|
216
|
-
// Variable types
|
217
|
-
type VariableTokens = ${[...s].join("|")};
|
218
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
219
|
-
|
220
|
-
// Template types
|
221
|
-
type TemplateTokens = {
|
222
|
-
${Object.entries(f).map(([g, p]) => `${g}?: ${p}`).join(`
|
223
|
-
`)}
|
224
|
-
}
|
225
|
-
`;
|
226
|
-
F(P, E);
|
227
|
-
}, G = async (t, e, s) => {
|
228
|
-
const n = I(e), r = a(s, "./temp");
|
229
|
-
B(r) || R(r);
|
230
|
-
const i = it(e);
|
231
|
-
let d = W(e, "utf8");
|
232
|
-
d = d.replace(/styled\([^"'`{,]+,/g, "styled('div',");
|
233
|
-
const c = a(s, "js", n + ".js"), b = nt(t), o = await et(t);
|
234
|
-
await X.build({
|
235
|
-
stdin: {
|
236
|
-
contents: d,
|
237
|
-
sourcefile: i.base,
|
238
|
-
resolveDir: i.dir,
|
239
|
-
loader: "tsx"
|
240
|
-
},
|
241
|
-
minify: !1,
|
242
|
-
treeShaking: !0,
|
243
|
-
bundle: !0,
|
244
|
-
outfile: c,
|
245
|
-
format: o,
|
246
|
-
target: ["node20"],
|
247
|
-
keepNames: !0,
|
248
|
-
external: b,
|
249
|
-
packages: "external"
|
250
|
-
});
|
251
|
-
const u = Date.now();
|
252
|
-
return await import(`${c}?t=${u}`);
|
253
|
-
}, L = async (t) => {
|
254
|
-
const e = Z(t), s = a(e, "salty.config.js"), { config: n } = await import(s);
|
255
|
-
return n;
|
256
|
-
}, ot = () => {
|
257
|
-
try {
|
258
|
-
return process.env.NODE_ENV === "production";
|
259
|
-
} catch {
|
260
|
-
return !1;
|
261
|
-
}
|
262
|
-
}, Et = async (t, e = ot()) => {
|
263
|
-
try {
|
264
|
-
e ? U.info("Generating CSS in production mode! 🔥") : U.info("Generating CSS in development mode! 🚀");
|
265
|
-
const s = [], n = [], r = Z(t), i = a(r, "index.css");
|
266
|
-
(() => {
|
267
|
-
B(r) && rt("rm -rf " + r), R(r), R(a(r, "css")), R(a(r, "types"));
|
268
|
-
})(), await xt(t);
|
269
|
-
const c = await L(t);
|
270
|
-
async function b(l, k) {
|
271
|
-
const T = ["node_modules", "saltygen"], y = ct(l);
|
272
|
-
if (y.isDirectory()) {
|
273
|
-
const S = at(l);
|
274
|
-
if (T.some((f) => l.includes(f))) return;
|
275
|
-
await Promise.all(S.map((f) => b(a(l, f), a(k, f))));
|
276
|
-
} else if (y.isFile() && K(l)) {
|
277
|
-
const j = await G(t, l, r), f = [];
|
278
|
-
Object.entries(j).forEach(([g, p]) => {
|
279
|
-
if (p.isKeyframes && p.css) {
|
280
|
-
const V = `${p.animationName}.css`, J = `css/${V}`, z = a(r, J);
|
281
|
-
s.push(V), F(z, p.css);
|
282
|
-
return;
|
283
|
-
}
|
284
|
-
if (!p.generator) return;
|
285
|
-
const h = p.generator._withBuildContext({
|
286
|
-
name: g,
|
287
|
-
config: c,
|
288
|
-
prod: e
|
289
|
-
}), m = `${h.hash}-${h.priority}.css`;
|
290
|
-
n[h.priority] || (n[h.priority] = []), n[h.priority].push(m), f.push(m);
|
291
|
-
const D = `css/${m}`, A = a(r, D);
|
292
|
-
F(A, h.css);
|
293
|
-
});
|
294
|
-
const P = f.map((g) => `@import url('./${g}');`).join(`
|
295
|
-
`), C = I(l, 6), E = a(r, `css/${C}.css`);
|
296
|
-
F(E, P);
|
297
|
-
}
|
298
|
-
}
|
299
|
-
await b(t, r);
|
300
|
-
const o = s.map((l) => `@import url('./css/${l}');`).join(`
|
301
|
-
`);
|
302
|
-
let x = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
303
|
-
|
304
|
-
${["variables.css", "reset.css", "global.css", "templates.css"].filter((l) => {
|
305
|
-
try {
|
306
|
-
return W(a(r, "css", l), "utf8").length > 0;
|
307
|
-
} catch {
|
308
|
-
return !1;
|
309
|
-
}
|
310
|
-
}).map((l) => `@import url('./css/${l}');`).join(`
|
311
|
-
`)}
|
312
|
-
${o}`;
|
313
|
-
if (c.importStrategy !== "component") {
|
314
|
-
const l = n.flat().map((k) => `@import url('./css/${k}');`).join(`
|
315
|
-
`);
|
316
|
-
x += l;
|
317
|
-
}
|
318
|
-
F(i, x);
|
319
|
-
} catch (s) {
|
320
|
-
console.error(s);
|
321
|
-
}
|
322
|
-
}, Dt = async (t, e) => {
|
323
|
-
try {
|
324
|
-
const s = [], n = a(t, "./saltygen"), r = a(n, "index.css");
|
325
|
-
if (K(e)) {
|
326
|
-
const d = await L(t), c = await G(t, e, n);
|
327
|
-
Object.entries(c).forEach(([w, x]) => {
|
328
|
-
if (!x.generator) return;
|
329
|
-
const l = x.generator._withBuildContext({
|
330
|
-
name: w,
|
331
|
-
config: d
|
332
|
-
}), k = `${l.hash}-${l.priority}.css`, T = `css/${k}`, y = a(n, T);
|
333
|
-
s.push(k), F(y, l.css);
|
334
|
-
});
|
335
|
-
const b = W(r, "utf8").split(`
|
336
|
-
`), o = s.map((w) => `@import url('../saltygen/css/${w}');`), $ = [.../* @__PURE__ */ new Set([...b, ...o])].join(`
|
337
|
-
`);
|
338
|
-
F(r, $);
|
339
|
-
}
|
340
|
-
} catch (s) {
|
341
|
-
console.error(s);
|
342
|
-
}
|
343
|
-
}, Ot = async (t, e, s = ot()) => {
|
344
|
-
try {
|
345
|
-
const n = a(t, "./saltygen");
|
346
|
-
if (K(e)) {
|
347
|
-
const i = W(e, "utf8");
|
348
|
-
i.replace(/^(?!export\s)const\s.*/gm, ($) => `export ${$}`) !== i && await ft(e, i);
|
349
|
-
const c = await L(t), b = await G(t, e, n);
|
350
|
-
let o = i;
|
351
|
-
Object.entries(b).forEach(([$, w]) => {
|
352
|
-
var m;
|
353
|
-
if (w.isKeyframes || !w.generator) return;
|
354
|
-
const x = w.generator._withBuildContext({
|
355
|
-
name: $,
|
356
|
-
config: c,
|
357
|
-
prod: s
|
358
|
-
}), l = new RegExp(`\\s${$}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
|
359
|
-
if (!l) return console.error("Could not find the original declaration");
|
360
|
-
const k = (m = l.at(1)) == null ? void 0 : m.trim(), T = new RegExp(`\\s${$}[=\\s]+styled\\(`, "g").exec(o);
|
361
|
-
if (!T) return console.error("Could not find the original declaration");
|
362
|
-
const { index: y } = T;
|
363
|
-
let S = !1;
|
364
|
-
const j = setTimeout(() => S = !0, 5e3);
|
365
|
-
let f = 0, P = !1, C = 0;
|
366
|
-
for (; !P && !S; ) {
|
367
|
-
const D = o[y + f];
|
368
|
-
D === "(" && C++, D === ")" && C--, C === 0 && D === ")" && (P = !0), f > o.length && (S = !0), f++;
|
369
|
-
}
|
370
|
-
if (!S) clearTimeout(j);
|
371
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
372
|
-
const E = y + f, g = o.slice(y, E), p = o, h = ` ${$} = styled(${k}, "${x.classNames}", ${JSON.stringify(x.props)});`;
|
373
|
-
o = o.replace(g, h), p === o && console.error("Minimize file failed to change content", { name: $, tagName: k });
|
374
|
-
});
|
375
|
-
const u = I(e, 6);
|
376
|
-
return c.importStrategy === "component" && (o = `import '../../saltygen/css/${u}.css';
|
377
|
-
${o}`), o = o.replace("{ styled }", "{ styledClient as styled }"), o = o.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), o;
|
378
|
-
}
|
379
|
-
} catch (n) {
|
380
|
-
console.error("Error in minimizeFile:", n);
|
381
|
-
}
|
382
|
-
};
|
383
|
-
export {
|
384
|
-
Dt as a,
|
385
|
-
Et as g,
|
386
|
-
Ot as m,
|
387
|
-
jt as s
|
388
|
-
};
|