@salty-css/webpack 0.0.1-alpha.250 → 0.0.1-alpha.252
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-DGrPV3kl.js → index-BKx-Znt3.js} +89 -86
- package/{index-CVxTKQjD.cjs → index-CCi9INHt.cjs} +14 -14
- 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
@@ -2,9 +2,9 @@ var Jt = Object.defineProperty;
|
|
2
2
|
var Rt = (e, t, s) => t in e ? Jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
3
|
var st = (e, t, s) => Rt(e, typeof t != "symbol" ? t + "" : t, s);
|
4
4
|
import * as Pt from "esbuild";
|
5
|
-
import { execSync as
|
5
|
+
import { execSync as Wt } from "child_process";
|
6
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
|
7
|
+
import { existsSync as dt, writeFileSync as T, readFileSync as J, mkdirSync as K, statSync as zt, readdirSync as At } from "fs";
|
8
8
|
import { readFile as Ft } from "fs/promises";
|
9
9
|
import { createLogger as Gt, format as ut, transports as Ht } from "winston";
|
10
10
|
import pt from "typescript";
|
@@ -28,13 +28,16 @@ const Kt = (e) => (t) => {
|
|
28
28
|
let s = t;
|
29
29
|
const n = [];
|
30
30
|
return Object.values(e).forEach((o) => {
|
31
|
-
const { pattern:
|
32
|
-
s = s.replace(
|
33
|
-
const { value: $, css: m } =
|
31
|
+
const { pattern: r, transform: i } = o;
|
32
|
+
s = s.replace(r, (d) => {
|
33
|
+
const { value: $, css: m } = i(d);
|
34
34
|
return m && n.push(m), $;
|
35
35
|
});
|
36
36
|
}), { transformed: s, additionalCss: n };
|
37
|
-
}, Nt = (e) => (t) => typeof t != "string" || !/\{[^{}]+\}/g.test(t) ? void 0 : { transformed: t.replace(/\{([^{}]+)\}/g, (...o) =>
|
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 = [
|
38
41
|
"top",
|
39
42
|
"right",
|
40
43
|
"bottom",
|
@@ -57,10 +60,10 @@ const Kt = (e) => (t) => {
|
|
57
60
|
/.*font-size.*/
|
58
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) => {
|
59
62
|
if (!e) throw new Error("No styles provided to parseStyles function!");
|
60
|
-
const o = /* @__PURE__ */ new Set(),
|
61
|
-
const g = p.trim(), P = Ut(g), _ = (k,
|
62
|
-
if (typeof f == "function") return
|
63
|
-
if (f instanceof Promise) return
|
63
|
+
const o = /* @__PURE__ */ new Set(), r = Object.entries(e), i = async ([p, f]) => {
|
64
|
+
const g = p.trim(), P = Ut(g), _ = (k, z = ";") => `${P}:${k}${z}`, V = { scope: t, config: s };
|
65
|
+
if (typeof f == "function") return i([p, f(V)]);
|
66
|
+
if (f instanceof Promise) return i([p, await f]);
|
64
67
|
if (typeof f == "object") {
|
65
68
|
if (!f) return;
|
66
69
|
if (f.isColor) return _(f.toString());
|
@@ -90,7 +93,7 @@ const Kt = (e) => (t) => {
|
|
90
93
|
o.add(l);
|
91
94
|
return;
|
92
95
|
}
|
93
|
-
const k = p.includes("&") ? g.
|
96
|
+
const k = p.includes("&") ? g.replaceAll("&", t) : g.startsWith(":") ? `${t}${g}` : `${t} ${g}`;
|
94
97
|
(await nt(f, k, s)).forEach((F) => o.add(F));
|
95
98
|
return;
|
96
99
|
}
|
@@ -102,16 +105,16 @@ const Kt = (e) => (t) => {
|
|
102
105
|
if ("toString" in f) f = f.toString();
|
103
106
|
else throw new Error(`Invalid value type for property ${P}`);
|
104
107
|
return _(f);
|
105
|
-
}, d =
|
108
|
+
}, d = r.map(i), { modifiers: $ } = {}, m = [Nt(), Kt($)], y = (await Promise.all(d).then((p) => Promise.all(
|
106
109
|
p.map((f) => m.reduce(async (g, P) => {
|
107
110
|
const _ = await g;
|
108
111
|
if (!_) return _;
|
109
112
|
const V = await P(_);
|
110
113
|
if (!V) return _;
|
111
|
-
const { transformed: k, additionalCss:
|
114
|
+
const { transformed: k, additionalCss: z } = V;
|
112
115
|
let F = "";
|
113
|
-
if (
|
114
|
-
for (const M of
|
116
|
+
if (z)
|
117
|
+
for (const M of z)
|
115
118
|
F += await Y(M, "");
|
116
119
|
return `${F}${k}`;
|
117
120
|
}, Promise.resolve(f)))
|
@@ -126,21 +129,21 @@ const Kt = (e) => (t) => {
|
|
126
129
|
`), xt = async (e, t = []) => {
|
127
130
|
if (!e) return "";
|
128
131
|
const s = [], n = {};
|
129
|
-
for (const [o,
|
130
|
-
if (typeof
|
131
|
-
const
|
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]);
|
132
135
|
s.push(d);
|
133
136
|
} else
|
134
|
-
n[o] =
|
137
|
+
n[o] = r;
|
135
138
|
if (Object.keys(n).length) {
|
136
|
-
const o = t.map(R).join("-"),
|
137
|
-
s.push(
|
139
|
+
const o = t.map(R).join("-"), r = "t_" + H(o, 4), i = await Y(n, `.${o}, .${r}`);
|
140
|
+
s.push(i);
|
138
141
|
}
|
139
142
|
return s.join(`
|
140
143
|
`);
|
141
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]) => {
|
142
|
-
const
|
143
|
-
return typeof o == "object" ? _t(o,
|
145
|
+
const r = t ? `${t}.${n}` : n;
|
146
|
+
return typeof o == "object" ? _t(o, r, s) : s.add(t);
|
144
147
|
}), [...s]) : [], Tt = (e) => {
|
145
148
|
if (!e || e === "/") throw new Error("Could not find package.json file");
|
146
149
|
const t = u(e, "package.json");
|
@@ -260,49 +263,49 @@ class oe {
|
|
260
263
|
const re = (e) => new oe(e), ie = (e, t) => new Promise((s, n) => {
|
261
264
|
const o = setTimeout(() => {
|
262
265
|
n(new Error("Timeout"));
|
263
|
-
}, 100),
|
264
|
-
function
|
266
|
+
}, 100), r = pt.createSourceFile("temp.ts", e, pt.ScriptTarget.Latest, !0);
|
267
|
+
function i(d) {
|
265
268
|
if (pt.isVariableDeclaration(d) && d.name.getText() === t) {
|
266
269
|
const $ = d.getStart(), m = d.getEnd();
|
267
270
|
clearTimeout(o), s([$, m]);
|
268
271
|
}
|
269
|
-
d.forEachChild(
|
272
|
+
d.forEachChild(i);
|
270
273
|
}
|
271
|
-
r
|
272
|
-
}),
|
274
|
+
i(r);
|
275
|
+
}), W = {
|
273
276
|
externalModules: [],
|
274
277
|
rcFile: void 0,
|
275
278
|
destDir: void 0
|
276
279
|
}, Et = (e) => {
|
277
|
-
if (
|
280
|
+
if (W.externalModules.length > 0) return W.externalModules;
|
278
281
|
const s = J(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
279
282
|
if (!s) return [];
|
280
283
|
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
281
|
-
return
|
284
|
+
return W.externalModules = n, n;
|
282
285
|
}, I = async (e) => {
|
283
|
-
if (
|
286
|
+
if (W.destDir) return W.destDir;
|
284
287
|
const t = await yt(e), s = u(e, (t == null ? void 0 : t.saltygenDir) || "saltygen");
|
285
|
-
return
|
288
|
+
return W.destDir = s, s;
|
286
289
|
}, Ot = ["salty", "css", "styles", "styled"], ae = (e = []) => new RegExp(`\\.(${[...Ot, ...e].join("|")})\\.`), ht = (e, t = []) => ae(t).test(e), Vt = async (e) => {
|
287
|
-
if (
|
290
|
+
if (W.rcFile) return W.rcFile;
|
288
291
|
if (e === "/") throw new Error("Could not find .saltyrc.json file");
|
289
292
|
const t = u(e, ".saltyrc.json"), s = await Ft(t, "utf-8").then(JSON.parse).catch(() => {
|
290
293
|
});
|
291
|
-
return s ? (
|
294
|
+
return s ? (W.rcFile = s, s) : Vt(u(e, ".."));
|
292
295
|
}, yt = async (e) => {
|
293
296
|
var n, o;
|
294
|
-
const t = await Vt(e), s = (n = t.projects) == null ? void 0 : n.find((
|
295
|
-
return s || ((o = t.projects) == null ? void 0 : o.find((
|
297
|
+
const t = await Vt(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));
|
296
299
|
}, ce = async (e) => {
|
297
|
-
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"),
|
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 = Et(n);
|
298
301
|
await Pt.build({
|
299
302
|
entryPoints: [n],
|
300
303
|
minify: !0,
|
301
304
|
treeShaking: !0,
|
302
305
|
bundle: !0,
|
303
306
|
outfile: o,
|
304
|
-
format:
|
305
|
-
external:
|
307
|
+
format: r,
|
308
|
+
external: i
|
306
309
|
});
|
307
310
|
const d = Date.now(), { config: $ } = await import(`${o}?t=${d}`);
|
308
311
|
return { config: $, path: o };
|
@@ -322,8 +325,8 @@ const re = (e) => new oe(e), ie = (e, t) => new Promise((s, n) => {
|
|
322
325
|
});
|
323
326
|
})
|
324
327
|
);
|
325
|
-
const { config: o, path:
|
326
|
-
|
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]));
|
327
330
|
const $ = d.map(([S]) => `'@${S}'`).join(" | "), m = /* @__PURE__ */ new Set(), c = async (S, x = []) => {
|
328
331
|
if (!S) return [];
|
329
332
|
const U = Object.entries(S).map(async ([D, G]) => {
|
@@ -344,7 +347,7 @@ const re = (e) => new oe(e), ie = (e, t) => new Promise((s, n) => {
|
|
344
347
|
if (!S) return [];
|
345
348
|
const x = Object.entries(S).map(async ([E, D]) => {
|
346
349
|
const G = await c(D);
|
347
|
-
return E === "base" ? G.join("") :
|
350
|
+
return E === "base" ? G.join("") : i.mediaQueries[E] ? `${i.mediaQueries[E]} { ${G.join("")} }` : `${E} { ${G.join("")} }`;
|
348
351
|
});
|
349
352
|
return (await Promise.all(x)).flat();
|
350
353
|
}, h = async (S) => {
|
@@ -357,16 +360,16 @@ const re = (e) => new oe(e), ie = (e, t) => new Promise((s, n) => {
|
|
357
360
|
return (await Promise.all(G)).flat();
|
358
361
|
});
|
359
362
|
return (await Promise.all(x)).flat();
|
360
|
-
}, 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), V = L((bt = o.variables) == null ? void 0 : bt.conditional, p("conditional")), k = await h(V),
|
361
|
-
T(
|
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), V = L((bt = o.variables) == null ? void 0 : bt.conditional, p("conditional")), k = await h(V), z = u(s, "css/_variables.css"), F = `:root { ${g.join("")} ${_.join("")} } ${k.join("")}`;
|
364
|
+
T(z, F), i.staticVariables = f;
|
362
365
|
const M = u(s, "css/_global.css"), l = L(o.global, n.globalStyles), w = await Y(l, "");
|
363
366
|
T(M, `@layer global { ${w} }`);
|
364
367
|
const C = u(s, "css/_reset.css"), j = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : ee, N = await Y(j, "");
|
365
368
|
T(C, `@layer reset { ${N} }`);
|
366
369
|
const v = u(s, "css/_templates.css"), A = L(o.templates, n.templates), B = await xt(A), Z = Xt(A);
|
367
|
-
T(v, `@layer templates { ${B} }`),
|
368
|
-
const tt = o.templates ? [re(o.templates)._setPath(`config;;${
|
369
|
-
|
370
|
+
T(v, `@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]));
|
370
373
|
const q = u(s, "types/css-tokens.d.ts"), Mt = `
|
371
374
|
// Variable types
|
372
375
|
type VariableTokens = ${[...m].join("|")};
|
@@ -383,14 +386,14 @@ const re = (e) => new oe(e), ie = (e, t) => new Promise((s, n) => {
|
|
383
386
|
`;
|
384
387
|
T(q, Mt);
|
385
388
|
const vt = u(s, "cache/config-cache.json");
|
386
|
-
T(vt, JSON.stringify(
|
389
|
+
T(vt, JSON.stringify(i, null, 2));
|
387
390
|
}, jt = (e) => e.replace(/styled\(([^"'`{,]+),/g, (t, s) => {
|
388
391
|
if (/^['"`]/.test(s)) return t;
|
389
392
|
const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
390
393
|
if (!o.test(e)) return t;
|
391
|
-
const
|
392
|
-
if (
|
393
|
-
const d =
|
394
|
+
const i = o.exec(e);
|
395
|
+
if (i) {
|
396
|
+
const d = i.at(1);
|
394
397
|
if (Ot.some((m) => d == null ? void 0 : d.includes(m))) return t;
|
395
398
|
}
|
396
399
|
return "styled('div',";
|
@@ -408,15 +411,15 @@ ${e}`;
|
|
408
411
|
}, rt = async (e, t, s) => {
|
409
412
|
const n = H(t), o = u(s, "./temp");
|
410
413
|
dt(o) || K(o);
|
411
|
-
const
|
412
|
-
let
|
413
|
-
|
414
|
+
const r = ot(t);
|
415
|
+
let i = J(t, "utf8");
|
416
|
+
i = jt(i), i = fe(i, e);
|
414
417
|
const d = u(s, "js", n + ".js"), $ = await yt(e), m = u(e, ($ == null ? void 0 : $.configDir) || "", "salty.config.ts"), c = Et(m), y = await Dt(e);
|
415
418
|
await Pt.build({
|
416
419
|
stdin: {
|
417
|
-
contents:
|
418
|
-
sourcefile:
|
419
|
-
resolveDir:
|
420
|
+
contents: i,
|
421
|
+
sourcefile: r.base,
|
422
|
+
resolveDir: r.dir,
|
420
423
|
loader: "tsx"
|
421
424
|
},
|
422
425
|
minify: !1,
|
@@ -447,8 +450,8 @@ ${e}`;
|
|
447
450
|
if (!n) throw new Error("Could not find config cache file");
|
448
451
|
return JSON.parse(n);
|
449
452
|
}, gt = async (e) => {
|
450
|
-
const t = await ue(e), s = await I(e), n = u(s, "salty.config.js"), o = Date.now(), { config:
|
451
|
-
return L(
|
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);
|
452
455
|
}, $t = () => {
|
453
456
|
try {
|
454
457
|
return process.env.NODE_ENV === "production";
|
@@ -459,13 +462,13 @@ ${e}`;
|
|
459
462
|
try {
|
460
463
|
const n = Date.now();
|
461
464
|
t ? mt.info("Generating CSS in production mode! 🔥") : mt.info("Generating CSS in development mode! 🚀");
|
462
|
-
const o = [],
|
465
|
+
const o = [], r = [], i = await I(e), d = u(i, "index.css");
|
463
466
|
s && (() => {
|
464
|
-
dt(
|
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"));
|
465
468
|
})();
|
466
469
|
const m = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
|
467
470
|
async function y(l) {
|
468
|
-
const w = ["node_modules", "saltygen"], C =
|
471
|
+
const w = ["node_modules", "saltygen"], C = zt(l);
|
469
472
|
if (C.isDirectory()) {
|
470
473
|
const a = At(l);
|
471
474
|
if (w.some((N) => l.includes(N))) return;
|
@@ -484,7 +487,7 @@ ${e}`;
|
|
484
487
|
};
|
485
488
|
await Promise.all(
|
486
489
|
[...m].map(async (l) => {
|
487
|
-
const { contents: w } = await rt(e, l,
|
490
|
+
const { contents: w } = await rt(e, l, i);
|
488
491
|
for (let [C, a] of Object.entries(w))
|
489
492
|
a instanceof Promise && (a = await a), a.isKeyframes ? h.keyframes.push({
|
490
493
|
value: a,
|
@@ -503,7 +506,7 @@ ${e}`;
|
|
503
506
|
);
|
504
507
|
const b = await gt(e);
|
505
508
|
for (const l of h.keyframes) {
|
506
|
-
const { value: w } = l, C = `a_${w.animationName}.css`, a = `css/${C}`, j = u(
|
509
|
+
const { value: w } = l, C = `a_${w.animationName}.css`, a = `css/${C}`, j = u(i, a);
|
507
510
|
o.push(C), T(j, w.css);
|
508
511
|
}
|
509
512
|
const p = {};
|
@@ -515,11 +518,11 @@ ${e}`;
|
|
515
518
|
isProduction: t,
|
516
519
|
config: b
|
517
520
|
});
|
518
|
-
|
521
|
+
r[a.priority] || (r[a.priority] = []);
|
519
522
|
const j = await a.css;
|
520
523
|
if (!j) continue;
|
521
|
-
|
522
|
-
const N = `css/${a.cssFileName}`, v = u(
|
524
|
+
r[a.priority].push(a.cssFileName);
|
525
|
+
const N = `css/${a.cssFileName}`, v = u(i, N);
|
523
526
|
T(v, j), b.importStrategy === "component" && p[w].push(a.cssFileName);
|
524
527
|
}
|
525
528
|
for (const l of h.classNames) {
|
@@ -531,13 +534,13 @@ ${e}`;
|
|
531
534
|
config: b
|
532
535
|
}), j = await a.css;
|
533
536
|
if (!j) continue;
|
534
|
-
|
535
|
-
const N = `css/${a.cssFileName}`, v = u(
|
537
|
+
r[a.priority] || (r[a.priority] = []), r[a.priority].push(a.cssFileName);
|
538
|
+
const N = `css/${a.cssFileName}`, v = u(i, N);
|
536
539
|
T(v, j), b.importStrategy === "component" && p[w].push(a.cssFileName);
|
537
540
|
}
|
538
541
|
b.importStrategy === "component" && Object.entries(p).forEach(([l, w]) => {
|
539
542
|
const C = w.map((A) => `@import url('./${A}');`).join(`
|
540
|
-
`), a = H(l, 6), j = ot(l), N = R(j.name), v = u(
|
543
|
+
`), a = H(l, 6), j = ot(l), N = R(j.name), v = u(i, `css/f_${N}-${a}.css`);
|
541
544
|
T(v, C || "/* Empty file */");
|
542
545
|
});
|
543
546
|
const f = o.map((l) => `@import url('./css/${l}');`).join(`
|
@@ -550,7 +553,7 @@ ${e}`;
|
|
550
553
|
|
551
554
|
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) => {
|
552
555
|
try {
|
553
|
-
return J(u(
|
556
|
+
return J(u(i, "css", l), "utf8").length > 0;
|
554
557
|
} catch {
|
555
558
|
return !1;
|
556
559
|
}
|
@@ -560,16 +563,16 @@ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((l) =
|
|
560
563
|
)}
|
561
564
|
${f}`;
|
562
565
|
if (b.importStrategy !== "component") {
|
563
|
-
const l =
|
566
|
+
const l = r.reduce((w, C, a) => {
|
564
567
|
const j = C.reduce((B, Z) => {
|
565
568
|
var at;
|
566
|
-
const tt = u(
|
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);
|
567
570
|
return B.includes(q) ? B : `${B}
|
568
571
|
/*start:${q}-${Z}*/
|
569
572
|
${it}
|
570
573
|
/*end:${q}*/
|
571
574
|
`;
|
572
|
-
}, ""), N = `l_${a}.css`, v = u(
|
575
|
+
}, ""), N = `l_${a}.css`, v = u(i, "css", N), A = `@layer l${a} { ${j}
|
573
576
|
}`;
|
574
577
|
return T(v, A), `${w}
|
575
578
|
@import url('./css/${N}');`;
|
@@ -586,7 +589,7 @@ ${it}
|
|
586
589
|
try {
|
587
590
|
const n = await I(e);
|
588
591
|
if (ht(t)) {
|
589
|
-
const
|
592
|
+
const r = [], i = await gt(e), { contents: d } = await rt(e, t, n);
|
590
593
|
for (const [$, m] of Object.entries(d)) {
|
591
594
|
if (m.isKeyframes && m.css) {
|
592
595
|
const f = `css/${`a_${m.animationName}.css`}`, g = u(n, f);
|
@@ -597,10 +600,10 @@ ${it}
|
|
597
600
|
const p = m.generator._withBuildContext({
|
598
601
|
callerName: $,
|
599
602
|
isProduction: s,
|
600
|
-
config:
|
603
|
+
config: i
|
601
604
|
}), f = await p.css;
|
602
605
|
if (!f) continue;
|
603
|
-
|
606
|
+
r[p.priority] || (r[p.priority] = []), r[p.priority].push(p.cssFileName);
|
604
607
|
const g = `css/${p.cssFileName}`, P = u(n, g);
|
605
608
|
T(P, f);
|
606
609
|
continue;
|
@@ -609,14 +612,14 @@ ${it}
|
|
609
612
|
const c = m.generator._withBuildContext({
|
610
613
|
callerName: $,
|
611
614
|
isProduction: s,
|
612
|
-
config:
|
615
|
+
config: i
|
613
616
|
}), y = await c.css;
|
614
617
|
if (!y) continue;
|
615
618
|
const h = `css/${c.cssFileName}`, b = u(n, h);
|
616
|
-
T(b, y),
|
619
|
+
T(b, y), r[c.priority] || (r[c.priority] = []), r[c.priority].push(c.cssFileName);
|
617
620
|
}
|
618
|
-
if (
|
619
|
-
|
621
|
+
if (i.importStrategy !== "component")
|
622
|
+
r.forEach(($, m) => {
|
620
623
|
const c = `l_${m}.css`, y = u(n, "css", c);
|
621
624
|
let h = J(y, "utf8");
|
622
625
|
$.forEach((b) => {
|
@@ -634,7 +637,7 @@ ${V}
|
|
634
637
|
}), T(y, h);
|
635
638
|
});
|
636
639
|
else {
|
637
|
-
const $ =
|
640
|
+
const $ = r.flat().map((b) => `@import url('./${b}');`).join(`
|
638
641
|
`), m = H(t, 6), c = ot(t), y = R(c.name), h = u(n, `css/f_${y}-${m}.css`);
|
639
642
|
T(h, $ || "/* Empty file */");
|
640
643
|
}
|
@@ -645,9 +648,9 @@ ${V}
|
|
645
648
|
}, Se = async (e, t, s = $t()) => {
|
646
649
|
var n, o;
|
647
650
|
try {
|
648
|
-
const
|
651
|
+
const r = await I(e);
|
649
652
|
if (ht(t)) {
|
650
|
-
const d = J(t, "utf8"), $ = await gt(e), { contents: m } = await rt(e, t,
|
653
|
+
const d = J(t, "utf8"), $ = await gt(e), { contents: m } = await rt(e, t, r);
|
651
654
|
let c = d;
|
652
655
|
for (const [y, h] of Object.entries(m)) {
|
653
656
|
if (h.isKeyframes || !h.generator) continue;
|
@@ -672,8 +675,8 @@ ${c}`;
|
|
672
675
|
}
|
673
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;
|
674
677
|
}
|
675
|
-
} catch (
|
676
|
-
console.error("Error in minimizeFile:",
|
678
|
+
} catch (r) {
|
679
|
+
console.error("Error in minimizeFile:", r);
|
677
680
|
}
|
678
681
|
};
|
679
682
|
export {
|
@@ -1,9 +1,9 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var Mt=Object.defineProperty;var vt=(t,e,s)=>e in t?Mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var et=(t,e,s)=>vt(t,typeof e!="symbol"?e+"":e,s);const Rt=require("esbuild"),zt=require("child_process"),c=require("path"),d=require("fs"),St=require("fs/promises"),Z=require("winston"),ft=require("typescript");var ut=typeof document<"u"?document.currentScript:null;function Jt(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 jt=Jt(Rt),$t=t=>String.fromCharCode(t+(t>25?39:97)),Wt=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=$t(n%52)+s;return s=$t(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},At=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},q=(t,e=5)=>{const s=At(5381,JSON.stringify(t))>>>0;return Wt(s,e)};function R(t){return t?typeof t!="string"?R(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 qt=t=>e=>{if(typeof e!="string"||!t)return;let s=e;const n=[];return Object.values(t).forEach(i=>{const{pattern:o,transform:r}=i;s=s.replace(o,y=>{const{value:$,css:m}=r(y);return m&&n.push(m),$})}),{transformed:s,additionalCss:n}},Ft=t=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...i)=>{const o=R(i[1].replaceAll(".","-"));return o.startsWith("-")?`-${o}`:`var(--${o})`})},It=Ft(),Gt=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],Ht=(t,e,s)=>Gt.some(i=>typeof i=="string"?i===t:i.test(t))?`${e}px`:`${e}`,Lt=["Webkit","Moz","ms","O"],Qt=t=>t.startsWith("-")?t:Lt.some(e=>t.startsWith(e))?`-${R(t)}`:R(t),st=async(t,e="",s,n=!1)=>{if(!t)throw new Error("No styles provided to parseStyles function!");const i=new Set,o=Object.entries(t),r=async([p,u])=>{const w=p.trim(),P=Qt(w),T=(D,J=";")=>`${P}:${D}${J}`,V={scope:e,config:s};if(typeof u=="function")return r([p,u(V)]);if(u instanceof Promise)return r([p,await u]);if(typeof u=="object"){if(!u)return;if(u.isColor)return T(u.toString());if(w==="defaultVariants")return;if(w==="variants"){const N=Object.entries(u);for(const[M,f]of N){if(!f)continue;const b=Object.entries(f);for(const[F,a]of b){if(!a)continue;const C=`${e}.${M}-${F}`;(await st(a,C,s)).forEach(v=>i.add(v))}}return}if(w==="compoundVariants"){for(const N of u){const{css:M,...f}=N,b=Object.entries(f).reduce((a,[C,_])=>`${a}.${C}-${_}`,e);(await st(M,b,s)).forEach(a=>i.add(a))}return}if(w.startsWith("@")){const N=w,M=await X(u,e,s),f=`${N} { ${M} }`;i.add(f);return}const D=p.includes("&")?w.replaceAll("&",e):w.startsWith(":")?`${e}${w}`:`${e} ${w}`;(await st(u,D,s)).forEach(N=>i.add(N));return}if(typeof u=="number"){const D=Ht(P,u);return T(D)}if(typeof u!="string")if("toString"in u)u=u.toString();else throw new Error(`Invalid value type for property ${P}`);return T(u)},y=o.map(r),{modifiers:$}={},m=[Ft(),qt($)],g=(await Promise.all(y).then(p=>Promise.all(p.map(u=>m.reduce(async(w,P)=>{const T=await w;if(!T)return T;const V=await P(T);if(!V)return T;const{transformed:D,additionalCss:J}=V;let N="";if(J)for(const M of J)N+=await X(M,"");return`${N}${D}`},Promise.resolve(u)))))).filter(p=>p!==void 0).join(`
|
2
2
|
`);if(!g.trim())return Array.from(i);const h=e?`${e} {
|
3
3
|
${g}
|
4
4
|
}`:g;return i.has(h)?Array.from(i):[h,...i]},X=async(t,e,s,n=!1)=>(await st(t,e,s,n)).join(`
|
5
|
-
`),Ct=async(t,e=[])=>{if(!t)return"";const s=[],n={};for(const[i,
|
6
|
-
`)},Kt=t=>t?Object.entries(t).reduce((e,[s,n])=>(typeof n=="function"?e[s]="any":typeof n=="object"&&(e[s]=Pt(n).map(i=>`"${i}"`).join(" | ")),e),{}):{},Pt=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,i])=>{const
|
5
|
+
`),Ct=async(t,e=[])=>{if(!t)return"";const s=[],n={};for(const[i,o]of Object.entries(t))if(typeof o!="function")if(o&&typeof o=="object"){const r=i.trim(),y=await Ct(o,[...e,r]);s.push(y)}else n[i]=o;if(Object.keys(n).length){const i=e.map(R).join("-"),o="t_"+q(i,4),r=await X(n,`.${i}, .${o}`);s.push(r)}return s.join(`
|
6
|
+
`)},Kt=t=>t?Object.entries(t).reduce((e,[s,n])=>(typeof n=="function"?e[s]="any":typeof n=="object"&&(e[s]=Pt(n).map(i=>`"${i}"`).join(" | ")),e),{}):{},Pt=(t,e="",s=new Set)=>t?(Object.entries(t).forEach(([n,i])=>{const o=e?`${e}.${n}`:n;return typeof i=="object"?Pt(i,o,s):s.add(e)}),[...s]):[],Nt=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=c.join(t,"package.json");return d.existsSync(e)?e:Nt(c.join(t,".."))},Ut=async t=>{const e=Nt(t);return await St.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},Bt=async t=>{const e=await Ut(t);if(e)return e.type};let G;const _t=async t=>{if(G)return G;const e=await Bt(t);return e==="module"?G="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ut&&ut.tagName.toUpperCase()==="SCRIPT"&&ut.src||new URL("index-CCi9INHt.cjs",document.baseURI).href).endsWith(".cjs"))&&(G="cjs"),G||"esm"},dt=Z.createLogger({level:"debug",format:Z.format.combine(Z.format.colorize(),Z.format.cli()),transports:[new Z.transports.Console({})]});function xt(t){return t?typeof t!="string"?xt(String(t)):t.replace(/[^\d\w]/g,"."):""}const Zt={"*, *::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"},a:{color:"currentColor"},button:{lineHeight:"1em",color:"currentColor"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},H=(...t)=>t.flat().reduce((e,s)=>s!=null&&s._current?{...e,...s._current}:{...e,...s},{}),Xt=(...t)=>t.flat().reduce((e,s)=>({...e,...s._children}),{});class Yt{constructor(e){et(this,"_path");this.params=e}get _current(){return this.params.template}get isDefineTemplate(){return!0}_setPath(e){return this._path=e,this}}class te{constructor(e){et(this,"_path");et(this,"templates",[]);this.params=e,Object.entries(e).forEach(([s,n])=>{this.templates.push(new Yt({name:s,template:n}))})}get _current(){return this.params}get _children(){return Object.fromEntries(this.templates.map(e=>[e.params.name,e]))}get isDefineTemplates(){return!0}_setPath(e){return this._path=e,this.templates.forEach(s=>s._setPath(e)),this}}const ee=t=>new te(t),se=(t,e)=>new Promise((s,n)=>{const i=setTimeout(()=>{n(new Error("Timeout"))},100),o=ft.createSourceFile("temp.ts",t,ft.ScriptTarget.Latest,!0);function r(y){if(ft.isVariableDeclaration(y)&&y.name.getText()===e){const $=y.getStart(),m=y.getEnd();clearTimeout(i),s([$,m])}y.forEachChild(r)}r(o)}),z={externalModules:[],rcFile:void 0,destDir:void 0},Tt=t=>{if(z.externalModules.length>0)return z.externalModules;const s=d.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(i=>i.replace(/['"`]/g,"").trim());return z.externalModules=n,n},I=async t=>{if(z.destDir)return z.destDir;const e=await pt(t),s=c.join(t,(e==null?void 0:e.saltygenDir)||"saltygen");return z.destDir=s,s},kt=["salty","css","styles","styled"],Dt=(t=[])=>new RegExp(`\\.(${[...kt,...t].join("|")})\\.`),nt=(t,e=[])=>Dt(e).test(t),Et=async t=>{if(z.rcFile)return z.rcFile;if(t==="/")throw new Error("Could not find .saltyrc.json file");const e=c.join(t,".saltyrc.json"),s=await St.readFile(e,"utf-8").then(JSON.parse).catch(()=>{});return s?(z.rcFile=s,s):Et(c.join(t,".."))},pt=async t=>{var n,i;const e=await Et(t),s=(n=e.projects)==null?void 0:n.find(o=>t.endsWith(o.dir||""));return s||((i=e.projects)==null?void 0:i.find(o=>o.dir===e.defaultProject))},ne=async t=>{const e=await pt(t),s=await I(t),n=c.join(t,(e==null?void 0:e.configDir)||"","salty.config.ts"),i=c.join(s,"salty.config.js"),o=await _t(t),r=Tt(n);await jt.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:i,format:o,external:r});const y=Date.now(),{config:$}=await import(`${i}?t=${y}`);return{config:$,path:i}},ie=async(t,e)=>{var ht,gt;const s=await I(t),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...e].map(async j=>{const{contents:x,outputFilePath:U}=await it(t,j,s);Object.entries(x).forEach(([E,k])=>{k.isMedia?n.mediaQueries.push([E,k]):k.isGlobalDefine?n.globalStyles.push(k):k.isDefineVariables?n.variables.push(k):k.isDefineTemplates&&n.templates.push(k._setPath(`${E};;${U}`))})}));const{config:i,path:o}=await ne(t),r={...i},{mediaQueries:y}=n;r.mediaQueries=Object.fromEntries(y.map(([j,x])=>[`@${j}`,x]));const $=y.map(([j])=>`'@${j}'`).join(" | "),m=new Set,l=async(j,x=[])=>{if(!j)return[];const U=Object.entries(j).map(async([k,A])=>{const B=async O=>{if(!O)return;if(O instanceof Promise)return await B(await O);if(typeof O=="function")return await B(await O());if(typeof O=="object")return await l(O,[...x,k]);const at=xt(k),ct=R(k),lt=[...x,at].join(".");m.add(`"${lt}"`);const tt=[...x.map(R),ct].join("-"),wt=It(O);return wt?`--${tt}: ${wt.transformed};`:`--${tt}: ${O};`};return await B(A)});return(await Promise.all(U)).flat()},g=async j=>{if(!j)return[];const x=Object.entries(j).map(async([E,k])=>{const A=await l(k);return E==="base"?A.join(""):r.mediaQueries[E]?`${r.mediaQueries[E]} { ${A.join("")} }`:`${E} { ${A.join("")} }`});return(await Promise.all(x)).flat()},h=async j=>{if(!j)return[];const x=Object.entries(j).map(async([E,k])=>{const A=Object.entries(k).map(async([O,at])=>{const ct=await l(at,[E]),lt=`.${E}-${O}, [data-${E}="${O}"]`,tt=ct.join("");return`${lt} { ${tt} }`});return(await Promise.all(A)).flat()});return(await Promise.all(x)).flat()},S=j=>({...j,responsive:void 0,conditional:void 0}),p=j=>n.variables.map(x=>j==="static"?S(x._current):x._current[j]),u=H(S(i.variables),p("static")),w=await l(u),P=H((ht=i.variables)==null?void 0:ht.responsive,p("responsive")),T=await g(P),V=H((gt=i.variables)==null?void 0:gt.conditional,p("conditional")),D=await h(V),J=c.join(s,"css/_variables.css"),N=`:root { ${w.join("")} ${T.join("")} } ${D.join("")}`;d.writeFileSync(J,N),r.staticVariables=u;const M=c.join(s,"css/_global.css"),f=H(i.global,n.globalStyles),b=await X(f,"");d.writeFileSync(M,`@layer global { ${b} }`);const F=c.join(s,"css/_reset.css"),C=i.reset==="none"?{}:typeof i.reset=="object"?i.reset:Zt,_=await X(C,"");d.writeFileSync(F,`@layer reset { ${_} }`);const v=c.join(s,"css/_templates.css"),W=H(i.templates,n.templates),L=await Ct(W),Q=Kt(W);d.writeFileSync(v,`@layer templates { ${L} }`),r.templates=W;const Y=i.templates?[ee(i.templates)._setPath(`config;;${o}`)]:[],ot=Xt(n.templates,Y);r.templatePaths=Object.fromEntries(Object.entries(ot).map(([j,x])=>[j,x._path]));const K=c.join(s,"types/css-tokens.d.ts"),Ot=`
|
7
7
|
// Variable types
|
8
8
|
type VariableTokens = ${[...m].join("|")};
|
9
9
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
@@ -16,31 +16,31 @@
|
|
16
16
|
|
17
17
|
// Media query types
|
18
18
|
type MediaQueryKeys = ${$||"''"};
|
19
|
-
`;d.writeFileSync(K,Ot);const Vt=c.join(s,"cache/config-cache.json");d.writeFileSync(Vt,JSON.stringify(
|
19
|
+
`;d.writeFileSync(K,Ot);const Vt=c.join(s,"cache/config-cache.json");d.writeFileSync(Vt,JSON.stringify(r,null,2))},bt=t=>t.replace(/styled\(([^"'`{,]+),/g,(e,s)=>{if(/^['"`]/.test(s))return e;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(t))return e;const r=i.exec(t);if(r){const y=r.at(1);if(kt.some(m=>y==null?void 0:y.includes(m)))return e}return"styled('div',"}),oe=(t,e)=>{try{const s=d.readFileSync(c.join(e,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
20
20
|
|
21
21
|
${t}`:`globalThis.saltyConfig = {};
|
22
22
|
|
23
|
-
${t}`}catch{return t}},it=async(t,e,s)=>{const n=q(e),i=c.join(s,"./temp");d.existsSync(i)||d.mkdirSync(i);const
|
24
|
-
`),a=q(f,6),C=c.parse(f),_=R(C.name),
|
23
|
+
${t}`}catch{return t}},it=async(t,e,s)=>{const n=q(e),i=c.join(s,"./temp");d.existsSync(i)||d.mkdirSync(i);const o=c.parse(e);let r=d.readFileSync(e,"utf8");r=bt(r),r=oe(r,t);const y=c.join(s,"js",n+".js"),$=await pt(t),m=c.join(t,($==null?void 0:$.configDir)||"","salty.config.ts"),l=Tt(m),g=await _t(t);await jt.build({stdin:{contents:r,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:y,format:g,target:["node20"],keepNames:!0,external:l,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},u=>{const w=d.readFileSync(u.path,"utf8");return{contents:bt(w),loader:"ts"}})}}]});const h=Date.now();return{contents:await import(`${y}?t=${h}`),outputFilePath:y}},re=async t=>{const e=await I(t),s=c.join(e,"cache/config-cache.json"),n=d.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},mt=async t=>{const e=await re(t),s=await I(t),n=c.join(s,"salty.config.js"),i=Date.now(),{config:o}=await import(`${n}?t=${i}`);return H(o,e)},yt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},ae=async(t,e=yt(),s=!0)=>{try{const n=Date.now();e?dt.info("Generating CSS in production mode! 🔥"):dt.info("Generating CSS in development mode! 🚀");const i=[],o=[],r=await I(t),y=c.join(r,"index.css");s&&(()=>{d.existsSync(r)&&zt.execSync("rm -rf "+r),d.mkdirSync(r,{recursive:!0}),d.mkdirSync(c.join(r,"css")),d.mkdirSync(c.join(r,"types")),d.mkdirSync(c.join(r,"js")),d.mkdirSync(c.join(r,"cache"))})();const m=new Set,l=new Set;async function g(f){const b=["node_modules","saltygen"],F=d.statSync(f);if(F.isDirectory()){const a=d.readdirSync(f);if(b.some(_=>f.includes(_)))return;await Promise.all(a.map(_=>g(c.join(f,_))))}else if(F.isFile()&&nt(f)){m.add(f);const C=d.readFileSync(f,"utf8");/define[\w\d]+\(/.test(C)&&l.add(f)}}await g(t),await ie(t,l);const h={keyframes:[],components:[],classNames:[]};await Promise.all([...m].map(async f=>{const{contents:b}=await it(t,f,r);for(let[F,a]of Object.entries(b))a instanceof Promise&&(a=await a),a.isKeyframes?h.keyframes.push({value:a,src:f,name:F}):a.isClassName?h.classNames.push({...a,src:f,name:F}):a.generator&&h.components.push({...a,src:f,name:F})}));const S=await mt(t);for(const f of h.keyframes){const{value:b}=f,F=`a_${b.animationName}.css`,a=`css/${F}`,C=c.join(r,a);i.push(F),d.writeFileSync(C,b.css)}const p={};for(const f of h.components){const{src:b,name:F}=f;p[b]||(p[b]=[]);const a=f.generator._withBuildContext({callerName:F,isProduction:e,config:S});o[a.priority]||(o[a.priority]=[]);const C=await a.css;if(!C)continue;o[a.priority].push(a.cssFileName);const _=`css/${a.cssFileName}`,v=c.join(r,_);d.writeFileSync(v,C),S.importStrategy==="component"&&p[b].push(a.cssFileName)}for(const f of h.classNames){const{src:b,name:F}=f;p[b]||(p[b]=[]);const a=f.generator._withBuildContext({callerName:F,isProduction:e,config:S}),C=await a.css;if(!C)continue;o[a.priority]||(o[a.priority]=[]),o[a.priority].push(a.cssFileName);const _=`css/${a.cssFileName}`,v=c.join(r,_);d.writeFileSync(v,C),S.importStrategy==="component"&&p[b].push(a.cssFileName)}S.importStrategy==="component"&&Object.entries(p).forEach(([f,b])=>{const F=b.map(W=>`@import url('./${W}');`).join(`
|
24
|
+
`),a=q(f,6),C=c.parse(f),_=R(C.name),v=c.join(r,`css/f_${_}-${a}.css`);d.writeFileSync(v,F||"/* Empty file */")});const u=i.map(f=>`@import url('./css/${f}');`).join(`
|
25
25
|
`);let D=`/*!
|
26
26
|
* Generated with Salty CSS (https://salty-css.dev)
|
27
27
|
* Do not edit this file directly
|
28
28
|
*/
|
29
29
|
@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
30
30
|
|
31
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return d.readFileSync(c.join(
|
31
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return d.readFileSync(c.join(r,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
32
32
|
`)}
|
33
|
-
${u}`;if(S.importStrategy!=="component"){const f=
|
33
|
+
${u}`;if(S.importStrategy!=="component"){const f=o.reduce((b,F,a)=>{const C=F.reduce((L,Q)=>{var rt;const Y=c.join(r,"css",Q),ot=d.readFileSync(Y,"utf8"),K=((rt=/.*-([^-]+)-\d+.css/.exec(Q))==null?void 0:rt.at(1))||q(Y,6);return L.includes(K)?L:`${L}
|
34
34
|
/*start:${K}-${Q}*/
|
35
35
|
${ot}
|
36
36
|
/*end:${K}*/
|
37
|
-
`},""),_=`l_${a}.css`,
|
38
|
-
}`;return d.writeFileSync(
|
39
|
-
@import url('./css/${_}');`},"");D+=f}d.writeFileSync(y,D);const N=Date.now()-n,
|
37
|
+
`},""),_=`l_${a}.css`,v=c.join(r,"css",_),W=`@layer l${a} { ${C}
|
38
|
+
}`;return d.writeFileSync(v,W),`${b}
|
39
|
+
@import url('./css/${_}');`},"");D+=f}d.writeFileSync(y,D);const N=Date.now()-n,M=N<200?"🔥":N<500?"🚀":N<1e3?"🎉":N<2e3?"🚗":N<5e3?"🤔":"🥴";dt.info(`Generated CSS in ${N}ms! ${M}`)}catch(n){console.error(n)}},ce=async(t,e,s=yt())=>{try{const n=await I(t);if(nt(e)){const o=[],r=await mt(t),{contents:y}=await it(t,e,n);for(const[$,m]of Object.entries(y)){if(m.isKeyframes&&m.css){const u=`css/${`a_${m.animationName}.css`}`,w=c.join(n,u);d.writeFileSync(w,await m.css);continue}if(m.isClassName){const p=m.generator._withBuildContext({callerName:$,isProduction:s,config:r}),u=await p.css;if(!u)continue;o[p.priority]||(o[p.priority]=[]),o[p.priority].push(p.cssFileName);const w=`css/${p.cssFileName}`,P=c.join(n,w);d.writeFileSync(P,u);continue}if(!m.generator)continue;const l=m.generator._withBuildContext({callerName:$,isProduction:s,config:r}),g=await l.css;if(!g)continue;const h=`css/${l.cssFileName}`,S=c.join(n,h);d.writeFileSync(S,g),o[l.priority]||(o[l.priority]=[]),o[l.priority].push(l.cssFileName)}if(r.importStrategy!=="component")o.forEach(($,m)=>{const l=`l_${m}.css`,g=c.join(n,"css",l);let h=d.readFileSync(g,"utf8");$.forEach(S=>{var P;const p=c.join(n,"css",S),u=((P=/.*-([^-]+)-\d+.css/.exec(S))==null?void 0:P.at(1))||q(p,6);if(!h.includes(u)){const T=d.readFileSync(p,"utf8"),V=`/*start:${u}-${S}*/
|
40
40
|
${T}
|
41
41
|
/*end:${u}*/
|
42
42
|
`;h=`${h.replace(/\}$/,"")}
|
43
43
|
${V}
|
44
|
-
}`}}),d.writeFileSync(g,h)});else{const $=
|
45
|
-
`),m=q(e,6),l=c.parse(e),g=R(l.name),h=c.join(n,`css/f_${g}-${m}.css`);d.writeFileSync(h,$||"/* Empty file */")}}}catch(n){console.error(n)}},le=async(t,e,s=yt())=>{var n,i;try{const
|
46
|
-
${l}`}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}}catch(
|
44
|
+
}`}}),d.writeFileSync(g,h)});else{const $=o.flat().map(S=>`@import url('./${S}');`).join(`
|
45
|
+
`),m=q(e,6),l=c.parse(e),g=R(l.name),h=c.join(n,`css/f_${g}-${m}.css`);d.writeFileSync(h,$||"/* Empty file */")}}}catch(n){console.error(n)}},le=async(t,e,s=yt())=>{var n,i;try{const o=await I(t);if(nt(e)){const y=d.readFileSync(e,"utf8"),$=await mt(t),{contents:m}=await it(t,e,o);let l=y;for(const[g,h]of Object.entries(m)){if(h.isKeyframes||!h.generator)continue;const S=h.generator._withBuildContext({callerName:g,isProduction:s,config:$}),[p,u]=await se(l,g),w=l.slice(p,u);if(h.isClassName){const P=l,T=` ${g} = className("${S.classNames}")`;l=l.replace(w,T),P===l&&console.error("Minimize file failed to change content",{name:g})}if(w.includes("styled")){const P=(i=(n=/styled\(([^,]+),/.exec(w))==null?void 0:n.at(1))==null?void 0:i.trim(),T=l,V=` ${g} = styled(${P}, "${S.classNames}", ${JSON.stringify(S.clientProps)})`;l=l.replace(w,V),T===l&&console.error("Minimize file failed to change content",{name:g,tagName:P})}}if($.importStrategy==="component"){const g=q(e,6),h=c.parse(e);l=`import '../../saltygen/css/${`f_${R(h.name)}-${g}.css`}';
|
46
|
+
${l}`}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}}catch(o){console.error("Error in minimizeFile:",o)}};exports.generateCss=ae;exports.generateFile=ce;exports.isSaltyFile=nt;exports.minimizeFile=le;exports.saltyFileRegExp=Dt;
|
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("path"),t=require("./index-CCi9INHt.cjs"),y=require("fs/promises"),g=require("fs"),p=async e=>{if(!e||e.includes("node_modules")||e.includes("saltygen"))return!1;if(e.includes("salty.config"))return!0;if(!t.isSaltyFile(e))return!1;const r=await y.readFile(e,"utf-8");return!!(/.+define[A-Z]\w+/.test(r)||/.+keyframes\(.+/.test(r))},c=(e,s,l=!1,r=!1)=>{var i,n,u;(n=(i=e.module)==null?void 0:i.rules)==null||n.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,r?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(u=e.plugins)==null||u.push({apply:f=>{let o=!1;f.hooks.beforeCompile.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,a)=>{await p(a)?await t.generateCss(s,!1,!1):t.isSaltyFile(a)&&await t.generateFile(s,a)}))})}})};exports.default=c;exports.saltyPlugin=c;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as p } from "path";
|
2
|
-
import { i as f, s as y, g as u, a as d } from "./index-
|
2
|
+
import { i as f, s as y, g as u, a as d } from "./index-BKx-Znt3.js";
|
3
3
|
import { readFile as g } from "fs/promises";
|
4
4
|
import { watch as m } from "fs";
|
5
5
|
const w = async (e) => {
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-CCi9INHt.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.252",
|
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.252",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|