@salty-css/webpack 0.0.1-alpha.197 → 0.0.1-alpha.198
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-C9v7qh0X.js → index-BJ1K4K_a.js} +93 -69
- package/index-C9E2t-Dq.cjs +41 -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-8DV1l-xe.cjs +0 -41
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as pt from "esbuild";
|
2
|
-
import { execSync as
|
3
|
-
import { join as f, parse as
|
4
|
-
import { existsSync as it, writeFileSync as P, readFileSync as T, mkdirSync as H, statSync as
|
2
|
+
import { execSync as xt } from "child_process";
|
3
|
+
import { join as f, parse as Q } from "path";
|
4
|
+
import { existsSync as it, writeFileSync as P, readFileSync as T, mkdirSync as H, statSync as Nt, readdirSync as Pt } from "fs";
|
5
5
|
import { readFile as dt, writeFile as kt } from "fs/promises";
|
6
6
|
import { createLogger as Dt, format as ot, transports as _t } from "winston";
|
7
7
|
const ft = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), Et = (t, e) => {
|
@@ -30,7 +30,28 @@ const Vt = (t, e) => {
|
|
30
30
|
return r && s.push(r), p;
|
31
31
|
});
|
32
32
|
}), { result: t, additionalCss: s };
|
33
|
-
}, gt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${J(n[1].replaceAll(".", "-"))})`) } : { result: t },
|
33
|
+
}, gt = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${J(n[1].replaceAll(".", "-"))})`) } : { result: t }, Ot = [
|
34
|
+
"top",
|
35
|
+
"right",
|
36
|
+
"bottom",
|
37
|
+
"left",
|
38
|
+
"min-width",
|
39
|
+
/.*width.*/,
|
40
|
+
/^[^line]*height.*/,
|
41
|
+
// Exclude line-height
|
42
|
+
/padding.*/,
|
43
|
+
/margin.*/,
|
44
|
+
/border.*/,
|
45
|
+
/inset.*/,
|
46
|
+
/.*radius.*/,
|
47
|
+
/.*spacing.*/,
|
48
|
+
/.*gap.*/,
|
49
|
+
/.*indent.*/,
|
50
|
+
/.*offset.*/,
|
51
|
+
/.*size.*/,
|
52
|
+
/.*thickness.*/,
|
53
|
+
/.*font-size.*/
|
54
|
+
], Mt = (t, e, s) => Ot.some((o) => typeof o == "string" ? o === t : o.test(t)) ? `${e}px` : `${e}`, z = (t, e, s) => {
|
34
55
|
if (!t) return "";
|
35
56
|
const n = [], o = Object.entries(t).reduce((i, [p, r]) => {
|
36
57
|
const c = p.trim(), g = c.startsWith("-") ? c : J(c), h = (w, k = ";") => i = `${i}${w}${k}`, d = (w) => h(`${g}:${w}`);
|
@@ -42,7 +63,7 @@ const Vt = (t, e) => {
|
|
42
63
|
return Object.entries(r).forEach(([_, S]) => {
|
43
64
|
S && Object.entries(S).forEach(([O, j]) => {
|
44
65
|
if (!j) return;
|
45
|
-
const M = `${e}.${_}-${O}`, l =
|
66
|
+
const M = `${e}.${_}-${O}`, l = z(j, M);
|
46
67
|
n.push(l);
|
47
68
|
});
|
48
69
|
}), i;
|
@@ -50,21 +71,24 @@ const Vt = (t, e) => {
|
|
50
71
|
return i;
|
51
72
|
if (c === "compoundVariants")
|
52
73
|
return r.forEach((_) => {
|
53
|
-
const { css: S, ...O } = _, j = Object.entries(O).reduce((l, [m, $]) => `${l}.${m}-${$}`, e), M =
|
74
|
+
const { css: S, ...O } = _, j = Object.entries(O).reduce((l, [m, $]) => `${l}.${m}-${$}`, e), M = z(S, j);
|
54
75
|
n.push(M);
|
55
76
|
}), i;
|
56
77
|
if (c.startsWith("@")) {
|
57
|
-
const _ =
|
78
|
+
const _ = z(r, e), S = `${c} {
|
58
79
|
${_.replace(`
|
59
80
|
`, `
|
60
81
|
`)}
|
61
82
|
}`;
|
62
83
|
return n.push(S), i;
|
63
84
|
}
|
64
|
-
const w = p.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k =
|
85
|
+
const w = p.includes("&") ? c.replace("&", e) : c.startsWith(":") ? `${e}${c}` : `${e} ${c}`, k = z(r, w);
|
65
86
|
return n.push(k), i;
|
66
87
|
}
|
67
|
-
if (typeof r == "number")
|
88
|
+
if (typeof r == "number") {
|
89
|
+
const w = Mt(g, r);
|
90
|
+
return d(w);
|
91
|
+
}
|
68
92
|
if (typeof r != "string")
|
69
93
|
if ("toString" in r) r = r.toString();
|
70
94
|
else return i;
|
@@ -73,7 +97,7 @@ const Vt = (t, e) => {
|
|
73
97
|
}();
|
74
98
|
for (const { result: w, additionalCss: k = [] } of E)
|
75
99
|
r = w, k.forEach((_) => {
|
76
|
-
const S =
|
100
|
+
const S = z(_, "");
|
77
101
|
h(S, "");
|
78
102
|
});
|
79
103
|
return d(r);
|
@@ -92,31 +116,31 @@ const Vt = (t, e) => {
|
|
92
116
|
} else
|
93
117
|
n[o] = a;
|
94
118
|
}), Object.keys(n).length) {
|
95
|
-
const o = e.map(J).join("-"), a =
|
119
|
+
const o = e.map(J).join("-"), a = z(n, `.${o}`);
|
96
120
|
s.push(a);
|
97
121
|
}
|
98
122
|
return s.join(`
|
99
123
|
`);
|
100
|
-
},
|
124
|
+
}, Rt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = mt(n).map((o) => `"${o}"`).join(" | ")), e), {}) : {}, mt = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
101
125
|
const a = e ? `${e}.${n}` : n;
|
102
126
|
return typeof o == "object" ? mt(o, a, s) : s.add(e);
|
103
127
|
}), [...s]) : [], yt = (t) => {
|
104
128
|
if (!t || t === "/") throw new Error("Could not find package.json file");
|
105
129
|
const e = f(t, "package.json");
|
106
130
|
return it(e) ? e : yt(f(t, ".."));
|
107
|
-
},
|
131
|
+
}, Jt = async (t) => {
|
108
132
|
const e = yt(t);
|
109
133
|
return await dt(e, "utf-8").then(JSON.parse).catch(() => {
|
110
134
|
});
|
111
|
-
},
|
112
|
-
const e = await
|
135
|
+
}, zt = async (t) => {
|
136
|
+
const e = await Jt(t);
|
113
137
|
if (e)
|
114
138
|
return e.type;
|
115
139
|
};
|
116
140
|
let Z;
|
117
141
|
const $t = async (t) => {
|
118
142
|
if (Z) return Z;
|
119
|
-
const e = await
|
143
|
+
const e = await zt(t);
|
120
144
|
return e === "module" ? Z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (Z = "cjs"), Z || "esm";
|
121
145
|
}, rt = Dt({
|
122
146
|
level: "debug",
|
@@ -126,7 +150,7 @@ const $t = async (t) => {
|
|
126
150
|
function bt(t) {
|
127
151
|
return t ? typeof t != "string" ? bt(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
128
152
|
}
|
129
|
-
const
|
153
|
+
const At = {
|
130
154
|
/** Set box model to border-box */
|
131
155
|
"*, *::before, *::after": {
|
132
156
|
boxSizing: "border-box"
|
@@ -182,11 +206,11 @@ const Jt = {
|
|
182
206
|
if (!s) return [];
|
183
207
|
const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
|
184
208
|
return R.externalModules = n, n;
|
185
|
-
},
|
209
|
+
}, A = async (t) => {
|
186
210
|
if (R.destDir) return R.destDir;
|
187
211
|
const e = await at(t), s = f(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
188
212
|
return R.destDir = s, s;
|
189
|
-
}, St = ["salty", "css", "styles", "styled"],
|
213
|
+
}, St = ["salty", "css", "styles", "styled"], Wt = (t = []) => new RegExp(`\\.(${[...St, ...t].join("|")})\\.`), ct = (t, e = []) => Wt(e).test(t), Ct = async (t) => {
|
190
214
|
if (R.rcFile) return R.rcFile;
|
191
215
|
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
192
216
|
const e = f(t, ".saltyrc.json"), s = await dt(e, "utf-8").then(JSON.parse).catch(() => {
|
@@ -196,8 +220,8 @@ const Jt = {
|
|
196
220
|
var n, o;
|
197
221
|
const e = await Ct(t), s = (n = e.projects) == null ? void 0 : n.find((a) => t.endsWith(a.dir || ""));
|
198
222
|
return s || ((o = e.projects) == null ? void 0 : o.find((a) => a.dir === e.defaultProject));
|
199
|
-
},
|
200
|
-
const e = await at(t), s = await
|
223
|
+
}, Zt = async (t) => {
|
224
|
+
const e = await at(t), s = await A(t), n = f(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = f(s, "salty.config.js"), a = await $t(t), i = wt(n);
|
201
225
|
await pt.build({
|
202
226
|
entryPoints: [n],
|
203
227
|
minify: !0,
|
@@ -209,55 +233,55 @@ const Jt = {
|
|
209
233
|
});
|
210
234
|
const p = Date.now(), { config: r } = await import(`${o}?t=${p}`);
|
211
235
|
return r;
|
212
|
-
},
|
213
|
-
var
|
214
|
-
const s = await
|
236
|
+
}, Ht = async (t, e) => {
|
237
|
+
var W, U;
|
238
|
+
const s = await A(t), n = {
|
215
239
|
mediaQueries: [],
|
216
240
|
globalStyles: [],
|
217
241
|
variables: [],
|
218
242
|
templates: []
|
219
243
|
};
|
220
244
|
await Promise.all(
|
221
|
-
[...e].map(async (
|
222
|
-
const
|
223
|
-
Object.values(
|
245
|
+
[...e].map(async (x) => {
|
246
|
+
const N = await X(t, x, s);
|
247
|
+
Object.values(N).forEach((D) => {
|
224
248
|
D.isMedia ? n.mediaQueries.push(D) : D.isGlobalDefine ? n.globalStyles.push(D) : D.isDefineVariables ? n.variables.push(D) : D.isDefineTemplates && n.templates.push(D);
|
225
249
|
});
|
226
250
|
})
|
227
251
|
);
|
228
|
-
const o = await
|
252
|
+
const o = await Zt(t), a = { ...o }, i = /* @__PURE__ */ new Set(), p = (x, N = []) => x ? Object.entries(x).flatMap(([D, V]) => {
|
229
253
|
if (!V) return;
|
230
|
-
if (typeof V == "object") return p(V, [...
|
231
|
-
const tt = bt(D), et = J(D), st = [...
|
254
|
+
if (typeof V == "object") return p(V, [...N, D]);
|
255
|
+
const tt = bt(D), et = J(D), st = [...N, tt].join(".");
|
232
256
|
i.add(`"${st}"`);
|
233
|
-
const nt = [...
|
257
|
+
const nt = [...N.map(J), et].join("-"), { result: Ft } = gt(V);
|
234
258
|
return `--${nt}: ${Ft};`;
|
235
|
-
}) : [], r = (
|
259
|
+
}) : [], r = (x) => x ? Object.entries(x).flatMap(([N, D]) => {
|
236
260
|
const V = p(D);
|
237
|
-
return
|
238
|
-
}) : [], c = (
|
239
|
-
const et = p(tt, [
|
261
|
+
return N === "base" ? V.join("") : `${N} { ${V.join("")} }`;
|
262
|
+
}) : [], c = (x) => x ? Object.entries(x).flatMap(([N, D]) => Object.entries(D).flatMap(([V, tt]) => {
|
263
|
+
const et = p(tt, [N]), st = `.${N}-${V}, [data-${N}="${V}"]`, nt = et.join("");
|
240
264
|
return `${st} { ${nt} }`;
|
241
|
-
})) : [], g = (
|
265
|
+
})) : [], g = (x) => ({ ...x, responsive: void 0, conditional: void 0 }), h = (x) => n.variables.map((N) => x === "static" ? g(N._current) : N._current[x]), d = I(g(o.variables), h("static")), b = p(d), y = I((W = o.variables) == null ? void 0 : W.responsive, h("responsive")), E = r(y), w = I((U = o.variables) == null ? void 0 : U.conditional, h("conditional")), k = c(w), _ = f(s, "css/_variables.css"), S = `:root { ${b.join("")} ${E.join("")} } ${k.join("")}`;
|
242
266
|
P(_, S), a.staticVariables = d;
|
243
|
-
const O = f(s, "css/_global.css"), j = I(o.global, n.globalStyles), M =
|
267
|
+
const O = f(s, "css/_global.css"), j = I(o.global, n.globalStyles), M = z(j, "");
|
244
268
|
P(O, `@layer global { ${M} }`);
|
245
|
-
const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset :
|
269
|
+
const l = f(s, "css/_reset.css"), $ = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : At, u = z($, "");
|
246
270
|
P(l, `@layer reset { ${u} }`);
|
247
|
-
const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), G = ht(F), L =
|
271
|
+
const C = f(s, "css/_templates.css"), F = I(o.templates, n.templates), G = ht(F), L = Rt(F);
|
248
272
|
P(C, G), a.templates = F;
|
249
|
-
const K = f(s, "types/css-tokens.d.ts"),
|
273
|
+
const K = f(s, "types/css-tokens.d.ts"), q = `
|
250
274
|
// Variable types
|
251
275
|
type VariableTokens = ${[...i].join("|")};
|
252
276
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
253
277
|
|
254
278
|
// Template types
|
255
279
|
type TemplateTokens = {
|
256
|
-
${Object.entries(L).map(([
|
280
|
+
${Object.entries(L).map(([x, N]) => `${x}?: ${N}`).join(`
|
257
281
|
`)}
|
258
282
|
}
|
259
283
|
`;
|
260
|
-
P(K,
|
284
|
+
P(K, q);
|
261
285
|
const v = f(s, "cache/config-cache.json");
|
262
286
|
P(v, JSON.stringify(a, null, 2));
|
263
287
|
}, ut = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
@@ -270,7 +294,7 @@ const Jt = {
|
|
270
294
|
if (St.some((c) => p == null ? void 0 : p.includes(c))) return e;
|
271
295
|
}
|
272
296
|
return "styled('div',";
|
273
|
-
}),
|
297
|
+
}), It = (t, e) => {
|
274
298
|
try {
|
275
299
|
const s = T(f(e, "saltygen/cache/config-cache.json"), "utf8");
|
276
300
|
return s ? `globalThis.saltyConfig = ${s};
|
@@ -284,9 +308,9 @@ ${t}`;
|
|
284
308
|
}, X = async (t, e, s) => {
|
285
309
|
const n = B(e), o = f(s, "./temp");
|
286
310
|
it(o) || H(o);
|
287
|
-
const a =
|
311
|
+
const a = Q(e);
|
288
312
|
let i = T(e, "utf8");
|
289
|
-
i = ut(i), i =
|
313
|
+
i = ut(i), i = It(i, t);
|
290
314
|
const p = f(s, "js", n + ".js"), r = await at(t), c = f(t, (r == null ? void 0 : r.configDir) || "", "salty.config.ts"), g = wt(c), h = await $t(t);
|
291
315
|
await pt.build({
|
292
316
|
stdin: {
|
@@ -318,12 +342,12 @@ ${t}`;
|
|
318
342
|
});
|
319
343
|
const d = Date.now();
|
320
344
|
return await import(`${p}?t=${d}`);
|
321
|
-
},
|
322
|
-
const e = await
|
345
|
+
}, Bt = async (t) => {
|
346
|
+
const e = await A(t), s = f(e, "cache/config-cache.json"), n = T(s, "utf8");
|
323
347
|
if (!n) throw new Error("Could not find config cache file");
|
324
348
|
return JSON.parse(n);
|
325
349
|
}, lt = async (t) => {
|
326
|
-
const e = await
|
350
|
+
const e = await Bt(t), s = await A(t), n = f(s, "salty.config.js"), o = Date.now(), { config: a } = await import(`${n}?t=${o}`);
|
327
351
|
return I(a, e);
|
328
352
|
}, jt = () => {
|
329
353
|
try {
|
@@ -331,17 +355,17 @@ ${t}`;
|
|
331
355
|
} catch {
|
332
356
|
return !1;
|
333
357
|
}
|
334
|
-
},
|
358
|
+
}, Qt = async (t, e = jt(), s = !0) => {
|
335
359
|
try {
|
336
360
|
const n = Date.now();
|
337
361
|
e ? rt.info("Generating CSS in production mode! 🔥") : rt.info("Generating CSS in development mode! 🚀");
|
338
|
-
const o = [], a = [], i = await
|
362
|
+
const o = [], a = [], i = await A(t), p = f(i, "index.css");
|
339
363
|
s && (() => {
|
340
|
-
it(i) &&
|
364
|
+
it(i) && xt("rm -rf " + i), H(i, { recursive: !0 }), H(f(i, "css")), H(f(i, "types")), H(f(i, "js")), H(f(i, "cache"));
|
341
365
|
})();
|
342
366
|
const c = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
|
343
367
|
async function h(l) {
|
344
|
-
const m = ["node_modules", "saltygen"], $ =
|
368
|
+
const m = ["node_modules", "saltygen"], $ = Nt(l);
|
345
369
|
if ($.isDirectory()) {
|
346
370
|
const u = Pt(l);
|
347
371
|
if (m.some((F) => l.includes(F))) return;
|
@@ -352,7 +376,7 @@ ${t}`;
|
|
352
376
|
/define[\w\d]+\(/.test(C) && g.add(l);
|
353
377
|
}
|
354
378
|
}
|
355
|
-
await h(t), await
|
379
|
+
await h(t), await Ht(t, g);
|
356
380
|
const d = {
|
357
381
|
keyframes: [],
|
358
382
|
components: [],
|
@@ -406,7 +430,7 @@ ${t}`;
|
|
406
430
|
}
|
407
431
|
b.importStrategy === "component" && Object.entries(y).forEach(([l, m]) => {
|
408
432
|
const $ = m.map((L) => `@import url('./${L}');`).join(`
|
409
|
-
`), u = B(l, 6), C =
|
433
|
+
`), u = B(l, 6), C = Q(l), F = J(C.name), G = f(i, `css/f_${F}-${u}.css`);
|
410
434
|
P(G, $);
|
411
435
|
});
|
412
436
|
const E = o.map((l) => `@import url('./css/${l}');`).join(`
|
@@ -425,12 +449,12 @@ ${E}`;
|
|
425
449
|
if (b.importStrategy !== "component") {
|
426
450
|
const l = a.reduce((m, $, u) => {
|
427
451
|
const C = $.reduce((K, Y) => {
|
428
|
-
var
|
429
|
-
const
|
430
|
-
return K.includes(
|
431
|
-
/*start:${
|
452
|
+
var U;
|
453
|
+
const q = f(i, "css", Y), v = T(q, "utf8"), W = ((U = /.*-([^-]+)-\d+.css/.exec(Y)) == null ? void 0 : U.at(1)) || B(q, 6);
|
454
|
+
return K.includes(W) ? K : `${K}
|
455
|
+
/*start:${W}*/
|
432
456
|
${v}
|
433
|
-
/*end:${
|
457
|
+
/*end:${W}*/
|
434
458
|
`;
|
435
459
|
}, ""), F = `l_${u}.css`, G = f(i, "css", F), L = `@layer l${u} { ${C}
|
436
460
|
}`;
|
@@ -445,9 +469,9 @@ ${v}
|
|
445
469
|
} catch (n) {
|
446
470
|
console.error(n);
|
447
471
|
}
|
448
|
-
},
|
472
|
+
}, Xt = async (t, e) => {
|
449
473
|
try {
|
450
|
-
const s = await
|
474
|
+
const s = await A(t);
|
451
475
|
if (ct(e)) {
|
452
476
|
const o = [], a = await lt(t), i = await X(t, e, s);
|
453
477
|
if (Object.entries(i).forEach(([p, r]) => {
|
@@ -490,16 +514,16 @@ ${_}
|
|
490
514
|
});
|
491
515
|
else {
|
492
516
|
const p = o.flat().map((d) => `@import url('./${d}');`).join(`
|
493
|
-
`), r = B(e, 6), c =
|
517
|
+
`), r = B(e, 6), c = Q(e), g = J(c.name), h = f(s, `css/f_${g}-${r}.css`);
|
494
518
|
P(h, p);
|
495
519
|
}
|
496
520
|
}
|
497
521
|
} catch (s) {
|
498
522
|
console.error(s);
|
499
523
|
}
|
500
|
-
},
|
524
|
+
}, Yt = async (t, e, s = jt()) => {
|
501
525
|
try {
|
502
|
-
const n = await
|
526
|
+
const n = await A(t);
|
503
527
|
if (ct(e)) {
|
504
528
|
const a = T(e, "utf8");
|
505
529
|
a.replace(/^(?!export\s)const\s.*/gm, (g) => `export ${g}`) !== a && await kt(e, a);
|
@@ -529,7 +553,7 @@ ${_}
|
|
529
553
|
const M = w + S, l = c.slice(w, M), m = c, $ = ` ${g} = styled(${y}, "${d.classNames}", ${JSON.stringify(d.clientProps)});`;
|
530
554
|
c = c.replace(l, $), m === c && console.error("Minimize file failed to change content", { name: g, tagName: y });
|
531
555
|
}), p.importStrategy === "component") {
|
532
|
-
const g = B(e, 6), h =
|
556
|
+
const g = B(e, 6), h = Q(e);
|
533
557
|
c = `import '../../saltygen/css/${`f_${J(h.name)}-${g}.css`}';
|
534
558
|
${c}`;
|
535
559
|
}
|
@@ -540,9 +564,9 @@ ${c}`;
|
|
540
564
|
}
|
541
565
|
};
|
542
566
|
export {
|
543
|
-
|
544
|
-
|
567
|
+
Xt as a,
|
568
|
+
Qt as g,
|
545
569
|
ct as i,
|
546
|
-
|
547
|
-
|
570
|
+
Yt as m,
|
571
|
+
Wt as s
|
548
572
|
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";const Fe=require("esbuild"),Ce=require("child_process"),l=require("path"),u=require("fs"),re=require("fs/promises"),G=require("winston");var ne=typeof document<"u"?document.currentScript:null;function xe(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 fe=xe(Fe),ae=e=>String.fromCharCode(e+(e>25?39:97)),Ne=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ae(n%52)+s;return s=ae(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},Pe=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=Pe(5381,JSON.stringify(e))>>>0;return Ne(s,t)};function M(e){return e?typeof e!="string"?M(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 ke=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:a}=n;e=e.replace(o,i=>{const{value:p,css:r}=a(i);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ue=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},De=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],_e=(e,t,s)=>De.some(o=>typeof o=="string"?o===e:o.test(e))?`${t}px`:`${t}`,z=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((i,[p,r])=>{const c=p.trim(),y=c.startsWith("-")?c:M(c),h=(j,k=";")=>i=`${i}${j}${k}`,g=j=>h(`${y}:${j}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(r.isColor)return g(r.toString()),i;if(c==="variants")return Object.entries(r).forEach(([_,w])=>{w&&Object.entries(w).forEach(([O,C])=>{if(!C)return;const V=`${t}.${_}-${O}`,f=z(C,V);n.push(f)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(_=>{const{css:w,...O}=_,C=Object.entries(O).reduce((f,[m,$])=>`${f}.${m}-${$}`,t),V=z(w,C);n.push(V)}),i;if(c.startsWith("@")){const _=z(r,t),w=`${c} {
|
2
|
+
${_.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return n.push(w),i}const j=p.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,k=z(r,j);return n.push(k),i}if(typeof r=="number"){const j=_e(y,r);return g(j)}if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:b}={},T=function*(){yield ue(r),yield ke(r,b)}();for(const{result:j,additionalCss:k=[]}of T)r=j,k.forEach(_=>{const w=z(_,"");h(w,"")});return g(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
|
6
|
+
`):o:n.join(`
|
7
|
+
`)},de=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=de(a,[...t,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=t.map(M).join("-"),a=z(n,`.${o}`);s.push(a)}return s.join(`
|
8
|
+
`)},Te=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?pe(o,a,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ge(l.join(e,".."))},Ee=async e=>{const t=ge(e);return await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Oe=async e=>{const t=await Ee(e);if(t)return t.type};let W;const ye=async e=>{if(W)return W;const t=await Oe(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-C9E2t-Dq.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},oe=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]});function he(e){return e?typeof e!="string"?he(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 Ve={"*, *::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"}},I=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),R={externalModules:[],rcFile:void 0,destDir:void 0},me=e=>{if(R.externalModules.length>0)return R.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return R.externalModules=n,n},J=async e=>{if(R.destDir)return R.destDir;const t=await ie(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},Se=["salty","css","styles","styled"],$e=(e=[])=>new RegExp(`\\.(${[...Se,...e].join("|")})\\.`),K=(e,t=[])=>$e(t).test(e),be=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):be(l.join(e,".."))},ie=async e=>{var n,o;const t=await be(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},Re=async e=>{const t=await ie(e),s=await J(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await ye(e),i=me(n);await fe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const p=Date.now(),{config:r}=await import(`${o}?t=${p}`);return r},Me=async(e,t)=>{var A,B;const s=await J(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async N=>{const P=await Q(e,N,s);Object.values(P).forEach(D=>{D.isMedia?n.mediaQueries.push(D):D.isGlobalDefine?n.globalStyles.push(D):D.isDefineVariables?n.variables.push(D):D.isDefineTemplates&&n.templates.push(D)})}));const o=await Re(e),a={...o},i=new Set,p=(N,P=[])=>N?Object.entries(N).flatMap(([D,E])=>{if(!E)return;if(typeof E=="object")return p(E,[...P,D]);const v=he(D),ee=M(D),te=[...P,v].join(".");i.add(`"${te}"`);const se=[...P.map(M),ee].join("-"),{result:we}=ue(E);return`--${se}: ${we};`}):[],r=N=>N?Object.entries(N).flatMap(([P,D])=>{const E=p(D);return P==="base"?E.join(""):`${P} { ${E.join("")} }`}):[],c=N=>N?Object.entries(N).flatMap(([P,D])=>Object.entries(D).flatMap(([E,v])=>{const ee=p(v,[P]),te=`.${P}-${E}, [data-${P}="${E}"]`,se=ee.join("");return`${te} { ${se} }`})):[],y=N=>({...N,responsive:void 0,conditional:void 0}),h=N=>n.variables.map(P=>N==="static"?y(P._current):P._current[N]),g=I(y(o.variables),h("static")),b=p(g),S=I((A=o.variables)==null?void 0:A.responsive,h("responsive")),T=r(S),j=I((B=o.variables)==null?void 0:B.conditional,h("conditional")),k=c(j),_=l.join(s,"css/_variables.css"),w=`:root { ${b.join("")} ${T.join("")} } ${k.join("")}`;u.writeFileSync(_,w),a.staticVariables=g;const O=l.join(s,"css/_global.css"),C=I(o.global,n.globalStyles),V=z(C,"");u.writeFileSync(O,`@layer global { ${V} }`);const f=l.join(s,"css/_reset.css"),$=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ve,d=z($,"");u.writeFileSync(f,`@layer reset { ${d} }`);const F=l.join(s,"css/_templates.css"),x=I(o.templates,n.templates),q=de(x),H=Te(x);u.writeFileSync(F,q),a.templates=x;const L=l.join(s,"types/css-tokens.d.ts"),U=`
|
9
|
+
// Variable types
|
10
|
+
type VariableTokens = ${[...i].join("|")};
|
11
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
|
+
|
13
|
+
// Template types
|
14
|
+
type TemplateTokens = {
|
15
|
+
${Object.entries(H).map(([N,P])=>`${N}?: ${P}`).join(`
|
16
|
+
`)}
|
17
|
+
}
|
18
|
+
`;u.writeFileSync(L,U);const Y=l.join(s,"cache/config-cache.json");u.writeFileSync(Y,JSON.stringify(a,null,2))},le=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const p=i.at(1);if(Se.some(c=>p==null?void 0:p.includes(c)))return t}return"styled('div',"}),ze=(e,t)=>{try{const s=u.readFileSync(l.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
19
|
+
|
20
|
+
${e}`:`globalThis.saltyConfig = {};
|
21
|
+
|
22
|
+
${e}`}catch{return e}},Q=async(e,t,s)=>{const n=Z(t),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(t);let i=u.readFileSync(t,"utf8");i=le(i),i=ze(i,e);const p=l.join(s,"js",n+".js"),r=await ie(e),c=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=me(c),h=await ye(e);await fe.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:h,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:S=>{S.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const j=u.readFileSync(T.path,"utf8");return{contents:le(j),loader:"ts"}})}}]});const g=Date.now();return await import(`${p}?t=${g}`)},Je=async e=>{const t=await J(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ce=async e=>{const t=await Je(e),s=await J(e),n=l.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return I(a,t)},je=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ae=async(e,t=je(),s=!0)=>{try{const n=Date.now();t?oe.info("Generating CSS in production mode! 🔥"):oe.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await J(e),p=l.join(i,"index.css");s&&(()=>{u.existsSync(i)&&Ce.execSync("rm -rf "+i),u.mkdirSync(i,{recursive:!0}),u.mkdirSync(l.join(i,"css")),u.mkdirSync(l.join(i,"types")),u.mkdirSync(l.join(i,"js")),u.mkdirSync(l.join(i,"cache"))})();const c=new Set,y=new Set;async function h(f){const m=["node_modules","saltygen"],$=u.statSync(f);if($.isDirectory()){const d=u.readdirSync(f);if(m.some(x=>f.includes(x)))return;await Promise.all(d.map(x=>h(l.join(f,x))))}else if($.isFile()&&K(f)){c.add(f);const F=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&y.add(f)}}await h(e),await Me(e,y);const g={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const m=await Q(e,f,i);Object.entries(m).forEach(([$,d])=>{d.isKeyframes?g.keyframes.push({value:d,src:f,name:$}):d.isClassName?g.classNames.push({...d,src:f,name:$}):d.generator&&g.components.push({...d,src:f,name:$})})}));const b=await ce(e);for(const f of g.keyframes){const{value:m}=f,$=`a_${m.animationName}.css`,d=`css/${$}`,F=l.join(i,d);o.push($),u.writeFileSync(F,m.css)}const S={};for(const f of g.components){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}for(const f of g.classNames){const{src:m,name:$}=f,d=f.generator._withBuildContext({callerName:$,isProduction:t,config:b});a[0].push(d.cssFileName);const F=`css/${d.cssFileName}`,x=l.join(i,F);u.writeFileSync(x,d.css),b.importStrategy==="component"&&(S[m]?S[m].push(d.cssFileName):S[m]=[d.cssFileName])}b.importStrategy==="component"&&Object.entries(S).forEach(([f,m])=>{const $=m.map(H=>`@import url('./${H}');`).join(`
|
23
|
+
`),d=Z(f,6),F=l.parse(f),x=M(F.name),q=l.join(i,`css/f_${x}-${d}.css`);u.writeFileSync(q,$)});const T=o.map(f=>`@import url('./css/${f}');`).join(`
|
24
|
+
`);let w=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
25
|
+
|
26
|
+
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(i,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
27
|
+
`)}
|
28
|
+
${T}`;if(b.importStrategy!=="component"){const f=a.reduce((m,$,d)=>{const F=$.reduce((L,X)=>{var B;const U=l.join(i,"css",X),Y=u.readFileSync(U,"utf8"),A=((B=/.*-([^-]+)-\d+.css/.exec(X))==null?void 0:B.at(1))||Z(U,6);return L.includes(A)?L:`${L}
|
29
|
+
/*start:${A}*/
|
30
|
+
${Y}
|
31
|
+
/*end:${A}*/
|
32
|
+
`},""),x=`l_${d}.css`,q=l.join(i,"css",x),H=`@layer l${d} { ${F}
|
33
|
+
}`;return u.writeFileSync(q,H),`${m}
|
34
|
+
@import url('./css/${x}');`},"");w+=f}u.writeFileSync(p,w);const C=Date.now()-n,V=C<200?"🔥":C<500?"🚀":C<1e3?"🎉":C<2e3?"🚗":C<5e3?"🤔":"🥴";oe.info(`Generated CSS in ${C}ms! ${V}`)}catch(n){console.error(n)}},We=async(e,t)=>{try{const s=await J(e);if(K(t)){const o=[],a=await ce(e),i=await Q(e,t,s);if(Object.entries(i).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const b=`css/${`a_${r.animationName}.css`}`,S=l.join(s,b);u.writeFileSync(S,r.css);return}if(r.isClassName){const g=r.factory._withBuildContext({name:p});o[0].push(g.cssFileName);const b=`css/${g.cssFileName}`,S=l.join(s,b);u.writeFileSync(S,g.css)}if(!r.generator)return;const c=r.generator._withBuildContext({name:p,config:a}),y=`css/${c.cssFileName}`,h=l.join(s,y);u.writeFileSync(h,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),a.importStrategy!=="component")o.forEach((p,r)=>{const c=`l_${r}.css`,y=l.join(s,"css",c);let h=u.readFileSync(y,"utf8");p.forEach(g=>{var j;const b=l.join(s,"css",g),S=((j=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:j.at(1))||Z(b,6);if(!h.includes(S)){const k=u.readFileSync(b,"utf8"),_=`/*start:${S}*/
|
35
|
+
${k}
|
36
|
+
/*end:${S}*/
|
37
|
+
`;h=`${h.replace(/\}$/,"")}
|
38
|
+
${_}
|
39
|
+
}`}}),u.writeFileSync(y,h)});else{const p=o.flat().map(g=>`@import url('./${g}');`).join(`
|
40
|
+
`),r=Z(t,6),c=l.parse(t),y=M(c.name),h=l.join(s,`css/f_${y}-${r}.css`);u.writeFileSync(h,p)}}}catch(s){console.error(s)}},Ie=async(e,t,s=je())=>{try{const n=await J(e);if(K(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==a&&await re.writeFile(t,a);const p=await ce(e),r=await Q(e,t,n);let c=a;if(Object.entries(r).forEach(([y,h])=>{var d;if(h.isKeyframes||!h.generator)return;const g=h.generator._withBuildContext({name:y,config:p,prod:s}),b=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!b)return console.error("Could not find the original declaration");const S=(d=b.at(1))==null?void 0:d.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:j}=T;let k=!1;const _=setTimeout(()=>k=!0,5e3);let w=0,O=!1,C=0;for(;!O&&!k;){const F=c[j+w];F==="("&&C++,F===")"&&C--,C===0&&F===")"&&(O=!0),w>c.length&&(k=!0),w++}if(!k)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const V=j+w,f=c.slice(j,V),m=c,$=` ${y} = styled(${S}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;c=c.replace(f,$),m===c&&console.error("Minimize file failed to change content",{name:y,tagName:S})}),p.importStrategy==="component"){const y=Z(t,6),h=l.parse(t);c=`import '../../saltygen/css/${`f_${M(h.name)}-${y}.css`}';
|
41
|
+
${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Ae;exports.generateFile=We;exports.isSaltyFile=K;exports.minimizeFile=Ie;exports.saltyFileRegExp=$e;
|
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-C9E2t-Dq.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 a=await y.readFile(e,"utf-8");return!!/.+define[A-Z]\w+/.test(a)},c=(e,s,l=!1,a=!1)=>{var n,u,i;(u=(n=e.module)==null?void 0:n.rules)==null||u.push({test:t.saltyFileRegExp(),use:[{loader:d.resolve(__dirname,a?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),l||(i=e.plugins)==null||i.push({apply:f=>{let o=!1;f.hooks.watchRun.tapPromise({name:"generateCss"},async()=>{o||(o=!0,await t.generateCss(s),g.watch(s,{recursive:!0},async(h,r)=>{await p(r)?await t.generateCss(s,!1,!1):t.isSaltyFile(r)&&await t.generateFile(s,r)}))})}})};exports.default=c;exports.saltyPlugin=c;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as d } from "path";
|
2
|
-
import { i as f, s as p, g as u, a as y } from "./index-
|
2
|
+
import { i as f, s as p, g as u, a as y } from "./index-BJ1K4K_a.js";
|
3
3
|
import { readFile as g } from "fs/promises";
|
4
4
|
import { watch as m } from "fs";
|
5
5
|
const w = async (s) => {
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-C9E2t-Dq.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.198",
|
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.198",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|
package/index-8DV1l-xe.cjs
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
"use strict";const Fe=require("esbuild"),Ce=require("child_process"),l=require("path"),u=require("fs"),re=require("fs/promises"),G=require("winston");var ne=typeof document<"u"?document.currentScript:null;function Ne(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 fe=Ne(Fe),ae=e=>String.fromCharCode(e+(e>25?39:97)),xe=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=ae(n%52)+s;return s=ae(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},ke=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},Z=(e,t=5)=>{const s=ke(5381,JSON.stringify(e))>>>0;return xe(s,t)};function M(e){return e?typeof e!="string"?M(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 Pe=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:o,transform:a}=n;e=e.replace(o,i=>{const{value:p,css:r}=a(i);return r&&s.push(r),p})}),{result:e,additionalCss:s}},ue=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:e},J=(e,t,s)=>{if(!e)return"";const n=[],o=Object.entries(e).reduce((i,[p,r])=>{const c=p.trim(),y=c.startsWith("-")?c:M(c),m=(j,P=";")=>i=`${i}${j}${P}`,g=j=>m(`${y}:${j}`);if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return i;if(r.isColor)return g(r.toString()),i;if(c==="variants")return Object.entries(r).forEach(([_,w])=>{w&&Object.entries(w).forEach(([O,C])=>{if(!C)return;const V=`${t}.${_}-${O}`,f=J(C,V);n.push(f)})}),i;if(c==="defaultVariants")return i;if(c==="compoundVariants")return r.forEach(_=>{const{css:w,...O}=_,C=Object.entries(O).reduce((f,[h,b])=>`${f}.${h}-${b}`,t),V=J(w,C);n.push(V)}),i;if(c.startsWith("@")){const _=J(r,t),w=`${c} {
|
2
|
-
${_.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return n.push(w),i}const j=p.includes("&")?c.replace("&",t):c.startsWith(":")?`${t}${c}`:`${t} ${c}`,P=J(r,j);return n.push(P),i}if(typeof r=="number")return g(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return i;const{modifiers:$}={},T=function*(){yield ue(r),yield Pe(r,$)}();for(const{result:j,additionalCss:P=[]}of T)r=j,P.forEach(_=>{const w=J(_,"");m(w,"")});return g(r)},"");return o?t?[`${t} { ${o} }`,...n].join(`
|
6
|
-
`):o:n.join(`
|
7
|
-
`)},de=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([o,a])=>{if(typeof a=="object"){if(!a)return;const i=o.trim(),p=de(a,[...t,i]);s.push(p)}else n[o]=a}),Object.keys(n).length){const o=t.map(M).join("-"),a=J(n,`.${o}`);s.push(a)}return s.join(`
|
8
|
-
`)},De=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=pe(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},pe=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?pe(o,a,s):s.add(t)}),[...s]):[],ge=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=l.join(e,"package.json");return u.existsSync(t)?t:ge(l.join(e,".."))},_e=async e=>{const t=ge(e);return await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Te=async e=>{const t=await _e(e);if(t)return t.type};let W;const ye=async e=>{if(W)return W;const t=await Te(e);return t==="module"?W="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:ne&&ne.tagName.toUpperCase()==="SCRIPT"&&ne.src||new URL("index-8DV1l-xe.cjs",document.baseURI).href).endsWith(".cjs"))&&(W="cjs"),W||"esm"},oe=G.createLogger({level:"debug",format:G.format.combine(G.format.colorize(),G.format.cli()),transports:[new G.transports.Console({})]});function me(e){return e?typeof e!="string"?me(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 Ee={"*, *::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"}},I=(...e)=>e.flat().reduce((t,s)=>s!=null&&s._current?{...t,...s._current}:{...t,...s},{}),R={externalModules:[],rcFile:void 0,destDir:void 0},he=e=>{if(R.externalModules.length>0)return R.externalModules;const s=u.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return R.externalModules=n,n},z=async e=>{if(R.destDir)return R.destDir;const t=await ie(e),s=l.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return R.destDir=s,s},Se=["salty","css","styles","styled"],be=(e=[])=>new RegExp(`\\.(${[...Se,...e].join("|")})\\.`),U=(e,t=[])=>be(t).test(e),$e=async e=>{if(R.rcFile)return R.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=l.join(e,".saltyrc.json"),s=await re.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(R.rcFile=s,s):$e(l.join(e,".."))},ie=async e=>{var n,o;const t=await $e(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},Oe=async e=>{const t=await ie(e),s=await z(e),n=l.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=l.join(s,"salty.config.js"),a=await ye(e),i=he(n);await fe.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const p=Date.now(),{config:r}=await import(`${o}?t=${p}`);return r},Ve=async(e,t)=>{var A,B;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async x=>{const k=await Q(e,x,s);Object.values(k).forEach(D=>{D.isMedia?n.mediaQueries.push(D):D.isGlobalDefine?n.globalStyles.push(D):D.isDefineVariables?n.variables.push(D):D.isDefineTemplates&&n.templates.push(D)})}));const o=await Oe(e),a={...o},i=new Set,p=(x,k=[])=>x?Object.entries(x).flatMap(([D,E])=>{if(!E)return;if(typeof E=="object")return p(E,[...k,D]);const v=me(D),ee=M(D),te=[...k,v].join(".");i.add(`"${te}"`);const se=[...k.map(M),ee].join("-"),{result:we}=ue(E);return`--${se}: ${we};`}):[],r=x=>x?Object.entries(x).flatMap(([k,D])=>{const E=p(D);return k==="base"?E.join(""):`${k} { ${E.join("")} }`}):[],c=x=>x?Object.entries(x).flatMap(([k,D])=>Object.entries(D).flatMap(([E,v])=>{const ee=p(v,[k]),te=`.${k}-${E}, [data-${k}="${E}"]`,se=ee.join("");return`${te} { ${se} }`})):[],y=x=>({...x,responsive:void 0,conditional:void 0}),m=x=>n.variables.map(k=>x==="static"?y(k._current):k._current[x]),g=I(y(o.variables),m("static")),$=p(g),S=I((A=o.variables)==null?void 0:A.responsive,m("responsive")),T=r(S),j=I((B=o.variables)==null?void 0:B.conditional,m("conditional")),P=c(j),_=l.join(s,"css/_variables.css"),w=`:root { ${$.join("")} ${T.join("")} } ${P.join("")}`;u.writeFileSync(_,w),a.staticVariables=g;const O=l.join(s,"css/_global.css"),C=I(o.global,n.globalStyles),V=J(C,"");u.writeFileSync(O,`@layer global { ${V} }`);const f=l.join(s,"css/_reset.css"),b=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:Ee,d=J(b,"");u.writeFileSync(f,`@layer reset { ${d} }`);const F=l.join(s,"css/_templates.css"),N=I(o.templates,n.templates),q=de(N),H=De(N);u.writeFileSync(F,q),a.templates=N;const L=l.join(s,"types/css-tokens.d.ts"),K=`
|
9
|
-
// Variable types
|
10
|
-
type VariableTokens = ${[...i].join("|")};
|
11
|
-
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
|
-
|
13
|
-
// Template types
|
14
|
-
type TemplateTokens = {
|
15
|
-
${Object.entries(H).map(([x,k])=>`${x}?: ${k}`).join(`
|
16
|
-
`)}
|
17
|
-
}
|
18
|
-
`;u.writeFileSync(L,K);const Y=l.join(s,"cache/config-cache.json");u.writeFileSync(Y,JSON.stringify(a,null,2))},le=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const p=i.at(1);if(Se.some(c=>p==null?void 0:p.includes(c)))return t}return"styled('div',"}),Re=(e,t)=>{try{const s=u.readFileSync(l.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
|
19
|
-
|
20
|
-
${e}`:`globalThis.saltyConfig = {};
|
21
|
-
|
22
|
-
${e}`}catch{return e}},Q=async(e,t,s)=>{const n=Z(t),o=l.join(s,"./temp");u.existsSync(o)||u.mkdirSync(o);const a=l.parse(t);let i=u.readFileSync(t,"utf8");i=le(i),i=Re(i,e);const p=l.join(s,"js",n+".js"),r=await ie(e),c=l.join(e,(r==null?void 0:r.configDir)||"","salty.config.ts"),y=he(c),m=await ye(e);await fe.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:p,format:m,target:["node20"],keepNames:!0,external:y,packages:"external",plugins:[{name:"test",setup:S=>{S.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},T=>{const j=u.readFileSync(T.path,"utf8");return{contents:le(j),loader:"ts"}})}}]});const g=Date.now();return await import(`${p}?t=${g}`)},Me=async e=>{const t=await z(e),s=l.join(t,"cache/config-cache.json"),n=u.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ce=async e=>{const t=await Me(e),s=await z(e),n=l.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return I(a,t)},je=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Je=async(e,t=je(),s=!0)=>{try{const n=Date.now();t?oe.info("Generating CSS in production mode! 🔥"):oe.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await z(e),p=l.join(i,"index.css");s&&(()=>{u.existsSync(i)&&Ce.execSync("rm -rf "+i),u.mkdirSync(i,{recursive:!0}),u.mkdirSync(l.join(i,"css")),u.mkdirSync(l.join(i,"types")),u.mkdirSync(l.join(i,"js")),u.mkdirSync(l.join(i,"cache"))})();const c=new Set,y=new Set;async function m(f){const h=["node_modules","saltygen"],b=u.statSync(f);if(b.isDirectory()){const d=u.readdirSync(f);if(h.some(N=>f.includes(N)))return;await Promise.all(d.map(N=>m(l.join(f,N))))}else if(b.isFile()&&U(f)){c.add(f);const F=u.readFileSync(f,"utf8");/define[\w\d]+\(/.test(F)&&y.add(f)}}await m(e),await Ve(e,y);const g={keyframes:[],components:[],classNames:[]};await Promise.all([...c].map(async f=>{const h=await Q(e,f,i);Object.entries(h).forEach(([b,d])=>{d.isKeyframes?g.keyframes.push({value:d,src:f,name:b}):d.isClassName?g.classNames.push({...d,src:f,name:b}):d.generator&&g.components.push({...d,src:f,name:b})})}));const $=await ce(e);for(const f of g.keyframes){const{value:h}=f,b=`a_${h.animationName}.css`,d=`css/${b}`,F=l.join(i,d);o.push(b),u.writeFileSync(F,h.css)}const S={};for(const f of g.components){const{src:h,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:$});a[d.priority]||(a[d.priority]=[]),a[d.priority].push(d.cssFileName);const F=`css/${d.cssFileName}`,N=l.join(i,F);u.writeFileSync(N,d.css),$.importStrategy==="component"&&(S[h]?S[h].push(d.cssFileName):S[h]=[d.cssFileName])}for(const f of g.classNames){const{src:h,name:b}=f,d=f.generator._withBuildContext({callerName:b,isProduction:t,config:$});a[0].push(d.cssFileName);const F=`css/${d.cssFileName}`,N=l.join(i,F);u.writeFileSync(N,d.css),$.importStrategy==="component"&&(S[h]?S[h].push(d.cssFileName):S[h]=[d.cssFileName])}$.importStrategy==="component"&&Object.entries(S).forEach(([f,h])=>{const b=h.map(H=>`@import url('./${H}');`).join(`
|
23
|
-
`),d=Z(f,6),F=l.parse(f),N=M(F.name),q=l.join(i,`css/f_${N}-${d}.css`);u.writeFileSync(q,b)});const T=o.map(f=>`@import url('./css/${f}');`).join(`
|
24
|
-
`);let w=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
25
|
-
|
26
|
-
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(f=>{try{return u.readFileSync(l.join(i,"css",f),"utf8").length>0}catch{return!1}}).map(f=>`@import url('./css/${f}');`).join(`
|
27
|
-
`)}
|
28
|
-
${T}`;if($.importStrategy!=="component"){const f=a.reduce((h,b,d)=>{const F=b.reduce((L,X)=>{var B;const K=l.join(i,"css",X),Y=u.readFileSync(K,"utf8"),A=((B=/.*-([^-]+)-\d+.css/.exec(X))==null?void 0:B.at(1))||Z(K,6);return L.includes(A)?L:`${L}
|
29
|
-
/*start:${A}*/
|
30
|
-
${Y}
|
31
|
-
/*end:${A}*/
|
32
|
-
`},""),N=`l_${d}.css`,q=l.join(i,"css",N),H=`@layer l${d} { ${F}
|
33
|
-
}`;return u.writeFileSync(q,H),`${h}
|
34
|
-
@import url('./css/${N}');`},"");w+=f}u.writeFileSync(p,w);const C=Date.now()-n,V=C<200?"🔥":C<500?"🚀":C<1e3?"🎉":C<2e3?"🚗":C<5e3?"🤔":"🥴";oe.info(`Generated CSS in ${C}ms! ${V}`)}catch(n){console.error(n)}},ze=async(e,t)=>{try{const s=await z(e);if(U(t)){const o=[],a=await ce(e),i=await Q(e,t,s);if(Object.entries(i).forEach(([p,r])=>{if(r.isKeyframes&&r.css){const $=`css/${`a_${r.animationName}.css`}`,S=l.join(s,$);u.writeFileSync(S,r.css);return}if(r.isClassName){const g=r.factory._withBuildContext({name:p});o[0].push(g.cssFileName);const $=`css/${g.cssFileName}`,S=l.join(s,$);u.writeFileSync(S,g.css)}if(!r.generator)return;const c=r.generator._withBuildContext({name:p,config:a}),y=`css/${c.cssFileName}`,m=l.join(s,y);u.writeFileSync(m,c.css),o[c.priority]||(o[c.priority]=[]),o[c.priority].push(c.cssFileName)}),a.importStrategy!=="component")o.forEach((p,r)=>{const c=`l_${r}.css`,y=l.join(s,"css",c);let m=u.readFileSync(y,"utf8");p.forEach(g=>{var j;const $=l.join(s,"css",g),S=((j=/.*-([^-]+)-\d+.css/.exec(g))==null?void 0:j.at(1))||Z($,6);if(!m.includes(S)){const P=u.readFileSync($,"utf8"),_=`/*start:${S}*/
|
35
|
-
${P}
|
36
|
-
/*end:${S}*/
|
37
|
-
`;m=`${m.replace(/\}$/,"")}
|
38
|
-
${_}
|
39
|
-
}`}}),u.writeFileSync(y,m)});else{const p=o.flat().map(g=>`@import url('./${g}');`).join(`
|
40
|
-
`),r=Z(t,6),c=l.parse(t),y=M(c.name),m=l.join(s,`css/f_${y}-${r}.css`);u.writeFileSync(m,p)}}}catch(s){console.error(s)}},Ae=async(e,t,s=je())=>{try{const n=await z(e);if(U(t)){const a=u.readFileSync(t,"utf8");a.replace(/^(?!export\s)const\s.*/gm,y=>`export ${y}`)!==a&&await re.writeFile(t,a);const p=await ce(e),r=await Q(e,t,n);let c=a;if(Object.entries(r).forEach(([y,m])=>{var d;if(m.isKeyframes||!m.generator)return;const g=m.generator._withBuildContext({name:y,config:p,prod:s}),$=new RegExp(`\\s${y}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const S=(d=$.at(1))==null?void 0:d.trim(),T=new RegExp(`\\s${y}[=\\s]+styled\\(`,"g").exec(c);if(!T)return console.error("Could not find the original declaration");const{index:j}=T;let P=!1;const _=setTimeout(()=>P=!0,5e3);let w=0,O=!1,C=0;for(;!O&&!P;){const F=c[j+w];F==="("&&C++,F===")"&&C--,C===0&&F===")"&&(O=!0),w>c.length&&(P=!0),w++}if(!P)clearTimeout(_);else throw new Error("Failed to find the end of the styled call and timed out");const V=j+w,f=c.slice(j,V),h=c,b=` ${y} = styled(${S}, "${g.classNames}", ${JSON.stringify(g.clientProps)});`;c=c.replace(f,b),h===c&&console.error("Minimize file failed to change content",{name:y,tagName:S})}),p.importStrategy==="component"){const y=Z(t,6),m=l.parse(t);c=`import '../../saltygen/css/${`f_${M(m.name)}-${y}.css`}';
|
41
|
-
${c}`}return c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Je;exports.generateFile=ze;exports.isSaltyFile=U;exports.minimizeFile=Ae;exports.saltyFileRegExp=be;
|