@salty-css/webpack 0.0.1-alpha.143 → 0.0.1-alpha.144
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-Djn2gdM4.js → index-B1xbIfxW.js} +67 -67
- package/{index-FU38Ls1z.cjs → index-DlrBgmCh.cjs} +13 -13
- 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
@@ -38,9 +38,9 @@ const jt = (t, e) => {
|
|
38
38
|
if (!c) return l;
|
39
39
|
if (r === "variants")
|
40
40
|
return Object.entries(c).forEach(([f, y]) => {
|
41
|
-
y && Object.entries(y).forEach(([
|
42
|
-
if (!
|
43
|
-
const T = `${e}.${f}-${
|
41
|
+
y && Object.entries(y).forEach(([x, w]) => {
|
42
|
+
if (!w) return;
|
43
|
+
const T = `${e}.${f}-${x}`, N = M(w, T);
|
44
44
|
n.push(N);
|
45
45
|
});
|
46
46
|
}), l;
|
@@ -48,7 +48,7 @@ const jt = (t, e) => {
|
|
48
48
|
return l;
|
49
49
|
if (r === "compoundVariants")
|
50
50
|
return c.forEach((f) => {
|
51
|
-
const { css: y, ...
|
51
|
+
const { css: y, ...x } = f, w = Object.entries(x).reduce((N, [d, h]) => `${N}.${d}-${h}`, e), T = M(y, w);
|
52
52
|
n.push(T);
|
53
53
|
}), l;
|
54
54
|
if (r.startsWith("@")) {
|
@@ -59,23 +59,23 @@ const jt = (t, e) => {
|
|
59
59
|
}`;
|
60
60
|
return n.push(y), l;
|
61
61
|
}
|
62
|
-
const u = g.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`,
|
63
|
-
return n.push(
|
62
|
+
const u = g.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`, j = M(c, u);
|
63
|
+
return n.push(j), l;
|
64
64
|
}
|
65
|
-
const p = r.startsWith("-") ? r : A(r), m = (u,
|
66
|
-
if (typeof c == "number") return
|
65
|
+
const p = r.startsWith("-") ? r : A(r), m = (u, j = ";") => l = `${l}${u}${j}`, S = (u) => m(`${p}:${u}`);
|
66
|
+
if (typeof c == "number") return S(c);
|
67
67
|
if (typeof c != "string")
|
68
68
|
if ("toString" in c) c = c.toString();
|
69
69
|
else return l;
|
70
|
-
const { modifiers: b } = {},
|
70
|
+
const { modifiers: b } = {}, k = function* () {
|
71
71
|
yield tt(c), yield jt(c, b);
|
72
72
|
}();
|
73
|
-
for (const { result: u, additionalCss:
|
74
|
-
c = u,
|
73
|
+
for (const { result: u, additionalCss: j = [] } of k)
|
74
|
+
c = u, j.forEach((f) => {
|
75
75
|
const y = M(f, "");
|
76
76
|
m(y, "");
|
77
77
|
});
|
78
|
-
return
|
78
|
+
return S(c);
|
79
79
|
}, "");
|
80
80
|
return i ? e ? [`${e} { ${i} }`, ...n].join(`
|
81
81
|
`) : i : n.join(`
|
@@ -193,39 +193,39 @@ const kt = {
|
|
193
193
|
const l = Date.now(), { config: g } = await import(`${n}?t=${l}`);
|
194
194
|
return g;
|
195
195
|
}, Tt = async (t) => {
|
196
|
-
const e = await Pt(t), s = /* @__PURE__ */ new Set(), n = (d, h = []) => d ? Object.entries(d).flatMap(([
|
196
|
+
const e = await Pt(t), s = /* @__PURE__ */ new Set(), n = (d, h = []) => d ? Object.entries(d).flatMap(([C, $]) => {
|
197
197
|
if (!$) return;
|
198
|
-
if (typeof $ == "object") return n($, [...h,
|
199
|
-
const _ = rt(
|
198
|
+
if (typeof $ == "object") return n($, [...h, C]);
|
199
|
+
const _ = rt(C), R = A(C), E = [...h, _].join(".");
|
200
200
|
s.add(`"${E}"`);
|
201
201
|
const D = [...h.map(A), R].join("-"), { result: O } = tt($);
|
202
202
|
return `--${D}: ${O};`;
|
203
|
-
}) : [], i = (d) => d ? Object.entries(d).flatMap(([h,
|
204
|
-
const $ = n(
|
203
|
+
}) : [], i = (d) => d ? Object.entries(d).flatMap(([h, C]) => {
|
204
|
+
const $ = n(C);
|
205
205
|
return h === "base" ? $.join("") : `${h} { ${$.join("")} }`;
|
206
|
-
}) : [], o = (d) => d ? Object.entries(d).flatMap(([h,
|
206
|
+
}) : [], o = (d) => d ? Object.entries(d).flatMap(([h, C]) => Object.entries(C).flatMap(([$, _]) => {
|
207
207
|
const R = n(_, [h]), E = `.${h}-${$}, [data-${h}="${$}"]`, D = R.join("");
|
208
208
|
return `${E} { ${D} }`;
|
209
209
|
})) : [], l = n(e.variables), g = i(e.responsiveVariables), c = o(e.conditionalVariables), r = Z(t), p = a(r, "css/_variables.css"), m = `:root { ${l.join("")} ${g.join("")} } ${c.join("")}`;
|
210
210
|
P(p, m);
|
211
|
-
const
|
212
|
-
P(
|
213
|
-
const
|
214
|
-
P(
|
215
|
-
const f = a(r, "css/_templates.css"), y = et(e.templates),
|
211
|
+
const S = a(r, "css/_global.css"), b = M(e.global, "");
|
212
|
+
P(S, `@layer global { ${b} }`);
|
213
|
+
const F = a(r, "css/_reset.css"), u = e.reset === "none" ? {} : typeof e.reset == "object" ? e.reset : kt, j = M(u, "");
|
214
|
+
P(F, `@layer reset { ${j} }`);
|
215
|
+
const f = a(r, "css/_templates.css"), y = et(e.templates), x = xt(e.templates);
|
216
216
|
P(f, y);
|
217
|
-
const
|
217
|
+
const w = a(r, "types/css-tokens.d.ts"), N = `
|
218
218
|
// Variable types
|
219
219
|
type VariableTokens = ${[...s].join("|")};
|
220
220
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
221
221
|
|
222
222
|
// Template types
|
223
223
|
type TemplateTokens = {
|
224
|
-
${Object.entries(
|
224
|
+
${Object.entries(x).map(([d, h]) => `${d}?: ${h}`).join(`
|
225
225
|
`)}
|
226
226
|
}
|
227
227
|
`;
|
228
|
-
P(
|
228
|
+
P(w, N);
|
229
229
|
}, Q = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
230
230
|
if (/^['"`]/.test(s)) return e;
|
231
231
|
const i = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
@@ -262,10 +262,10 @@ const kt = {
|
|
262
262
|
plugins: [
|
263
263
|
{
|
264
264
|
name: "test",
|
265
|
-
setup: (
|
266
|
-
|
267
|
-
const
|
268
|
-
return { contents: Q(
|
265
|
+
setup: (S) => {
|
266
|
+
S.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (b) => {
|
267
|
+
const F = V(b.path, "utf8");
|
268
|
+
return { contents: Q(F), loader: "ts" };
|
269
269
|
});
|
270
270
|
}
|
271
271
|
}
|
@@ -292,12 +292,12 @@ const kt = {
|
|
292
292
|
})(), await Tt(t);
|
293
293
|
const c = await U(t);
|
294
294
|
async function r(f, y) {
|
295
|
-
const
|
296
|
-
if (
|
295
|
+
const x = ["node_modules", "saltygen"], w = gt(f);
|
296
|
+
if (w.isDirectory()) {
|
297
297
|
const T = yt(f);
|
298
|
-
if (
|
298
|
+
if (x.some((d) => f.includes(d))) return;
|
299
299
|
await Promise.all(T.map((d) => r(a(f, d), a(y, d))));
|
300
|
-
} else if (
|
300
|
+
} else if (w.isFile() && G(f)) {
|
301
301
|
const N = await q(t, f, o), d = [];
|
302
302
|
Object.entries(N).forEach(([E, D]) => {
|
303
303
|
if (D.isKeyframes && D.css) {
|
@@ -316,14 +316,14 @@ const kt = {
|
|
316
316
|
P(ft, O.css);
|
317
317
|
});
|
318
318
|
const h = d.map((E) => `@import url('./${E}');`).join(`
|
319
|
-
`),
|
319
|
+
`), C = W(f, 6), $ = B(f), _ = A($.name), R = a(o, `css/f_${_}-${C}.css`);
|
320
320
|
P(R, h);
|
321
321
|
}
|
322
322
|
}
|
323
323
|
await r(t, o);
|
324
324
|
const p = n.map((f) => `@import url('./css/${f}');`).join(`
|
325
325
|
`);
|
326
|
-
let
|
326
|
+
let F = `@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
327
327
|
|
328
328
|
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
|
329
329
|
try {
|
@@ -335,24 +335,24 @@ ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) =
|
|
335
335
|
`)}
|
336
336
|
${p}`;
|
337
337
|
if (c.importStrategy !== "component") {
|
338
|
-
const f = i.reduce((y,
|
339
|
-
const T =
|
338
|
+
const f = i.reduce((y, x, w) => {
|
339
|
+
const T = x.reduce((C, $) => {
|
340
340
|
const _ = a(o, "css", $), R = V(_, "utf8"), E = W(_, 6);
|
341
|
-
return `${
|
341
|
+
return `${C}
|
342
342
|
/*start:${E}*/
|
343
343
|
${R}
|
344
344
|
/*end:${E}*/
|
345
345
|
`;
|
346
|
-
}, ""), N = `l_${
|
346
|
+
}, ""), N = `l_${w}.css`, d = a(o, "css", N), h = `@layer l${w} { ${T}
|
347
347
|
}`;
|
348
348
|
return P(d, h), `${y}
|
349
349
|
@import url('./css/${N}');`;
|
350
350
|
}, "");
|
351
|
-
|
351
|
+
F += f;
|
352
352
|
}
|
353
|
-
P(l,
|
354
|
-
const u = Date.now() - s,
|
355
|
-
I.info(`Generated CSS in ${u}ms! ${
|
353
|
+
P(l, F);
|
354
|
+
const u = Date.now() - s, j = u < 200 ? "🔥" : u < 500 ? "🚀" : u < 1e3 ? "🎉" : u < 2e3 ? "🚗" : u < 5e3 ? "🤔" : "🥴";
|
355
|
+
I.info(`Generated CSS in ${u}ms! ${j}`);
|
356
356
|
} catch (s) {
|
357
357
|
console.error(s);
|
358
358
|
}
|
@@ -363,7 +363,7 @@ ${R}
|
|
363
363
|
const o = [], l = await U(t), g = await q(t, e, s);
|
364
364
|
Object.entries(g).forEach(([r, p]) => {
|
365
365
|
if (p.isKeyframes && p.css) {
|
366
|
-
const
|
366
|
+
const k = `css/${`a_${p.animationName}.css`}`, u = a(s, k);
|
367
367
|
P(u, p.css);
|
368
368
|
return;
|
369
369
|
}
|
@@ -371,26 +371,26 @@ ${R}
|
|
371
371
|
const m = p.generator._withBuildContext({
|
372
372
|
name: r,
|
373
373
|
config: l
|
374
|
-
}),
|
374
|
+
}), S = `css/${m.cssFileName}`, b = a(s, S);
|
375
375
|
P(b, m.css), o[m.priority] || (o[m.priority] = []), o[m.priority].push(m.cssFileName);
|
376
376
|
});
|
377
377
|
const c = V(n, "utf8").split(`
|
378
378
|
`);
|
379
379
|
l.importStrategy !== "component" && o.forEach((r, p) => {
|
380
|
-
const m = `l_${p}.css`,
|
381
|
-
let b = V(
|
382
|
-
r.forEach((
|
383
|
-
const
|
384
|
-
if (
|
385
|
-
const f = V(
|
380
|
+
const m = `l_${p}.css`, S = a(s, "css", m);
|
381
|
+
let b = V(S, "utf8");
|
382
|
+
r.forEach((F) => {
|
383
|
+
const k = a(s, "css", F), u = W(k, 6);
|
384
|
+
if (!b.includes(u)) {
|
385
|
+
const f = V(k, "utf8"), y = W(k, 6), x = `/*start:${y}*/
|
386
386
|
${f}
|
387
387
|
/*end:${y}*/
|
388
388
|
`;
|
389
389
|
b = `${b.replace(/\}$/, "")}
|
390
|
-
${
|
390
|
+
${x}
|
391
391
|
}`;
|
392
392
|
}
|
393
|
-
}), P(
|
393
|
+
}), P(S, b);
|
394
394
|
});
|
395
395
|
}
|
396
396
|
} catch (s) {
|
@@ -405,28 +405,28 @@ ${C}
|
|
405
405
|
const g = await U(t), c = await q(t, e, n);
|
406
406
|
let r = o;
|
407
407
|
if (Object.entries(c).forEach(([p, m]) => {
|
408
|
-
var
|
408
|
+
var C;
|
409
409
|
if (m.isKeyframes || !m.generator) return;
|
410
|
-
const
|
410
|
+
const S = m.generator._withBuildContext({
|
411
411
|
name: p,
|
412
412
|
config: g,
|
413
413
|
prod: s
|
414
414
|
}), b = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
|
415
415
|
if (!b) return console.error("Could not find the original declaration");
|
416
|
-
const
|
417
|
-
if (!
|
418
|
-
const { index: u } =
|
419
|
-
let
|
420
|
-
const f = setTimeout(() =>
|
421
|
-
let y = 0,
|
422
|
-
for (; !
|
416
|
+
const F = (C = b.at(1)) == null ? void 0 : C.trim(), k = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(r);
|
417
|
+
if (!k) return console.error("Could not find the original declaration");
|
418
|
+
const { index: u } = k;
|
419
|
+
let j = !1;
|
420
|
+
const f = setTimeout(() => j = !0, 5e3);
|
421
|
+
let y = 0, x = !1, w = 0;
|
422
|
+
for (; !x && !j; ) {
|
423
423
|
const $ = r[u + y];
|
424
|
-
$ === "(" &&
|
424
|
+
$ === "(" && w++, $ === ")" && w--, w === 0 && $ === ")" && (x = !0), y > r.length && (j = !0), y++;
|
425
425
|
}
|
426
|
-
if (!
|
426
|
+
if (!j) clearTimeout(f);
|
427
427
|
else throw new Error("Failed to find the end of the styled call and timed out");
|
428
|
-
const T = u + y, N = r.slice(u, T), d = r, h = ` ${p} = styled(${
|
429
|
-
r = r.replace(N, h), d === r && console.error("Minimize file failed to change content", { name: p, tagName:
|
428
|
+
const T = u + y, N = r.slice(u, T), d = r, h = ` ${p} = styled(${F}, "${S.classNames}", ${JSON.stringify(S.props)});`;
|
429
|
+
r = r.replace(N, h), d === r && console.error("Minimize file failed to change content", { name: p, tagName: F });
|
430
430
|
}), g.importStrategy === "component") {
|
431
431
|
const p = W(e, 6), m = B(e);
|
432
432
|
r = `import '../../saltygen/css/${`f_${A(m.name)}-${p}.css`}';
|
@@ -1,37 +1,37 @@
|
|
1
|
-
"use strict";const pe=require("esbuild"),de=require("child_process"),c=require("path"),l=require("fs"),X=require("fs/promises"),J=require("winston");var I=typeof document<"u"?document.currentScript:null;function ye(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 Y=ye(pe),G=e=>String.fromCharCode(e+(e>25?39:97)),ge=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=G(n%52)+s;return s=G(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},me=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},z=(e,t=5)=>{const s=me(5381,JSON.stringify(e))>>>0;return ge(s,t)};function V(e){return e?typeof e!="string"?V(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 he=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:o}=n;e=e.replace(i,f=>{const{value:g,css:a}=o(f);return a&&s.push(a),g})}),{result:e,additionalCss:s}},Q=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:e},M=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((f,[g,a])=>{const r=g.trim();if(typeof a=="function"&&(a=a()),typeof a=="object"){if(!a)return f;if(r==="variants")return Object.entries(a).forEach(([u,m])=>{m&&Object.entries(m).forEach(([
|
1
|
+
"use strict";const pe=require("esbuild"),de=require("child_process"),c=require("path"),l=require("fs"),X=require("fs/promises"),J=require("winston");var I=typeof document<"u"?document.currentScript:null;function ye(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 Y=ye(pe),G=e=>String.fromCharCode(e+(e>25?39:97)),ge=(e,t)=>{let s="",n;for(n=Math.abs(e);n>52;n=n/52|0)s=G(n%52)+s;return s=G(n%52)+s,s.length<t?s=s.padStart(t,"a"):s.length>t&&(s=s.slice(-t)),s},me=(e,t)=>{let s=t.length;for(;s;)e=e*33^t.charCodeAt(--s);return e},z=(e,t=5)=>{const s=me(5381,JSON.stringify(e))>>>0;return ge(s,t)};function V(e){return e?typeof e!="string"?V(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 he=(e,t)=>{if(typeof e!="string")return{result:e};if(!t)return{result:e};const s=[];return Object.values(t).forEach(n=>{const{pattern:i,transform:o}=n;e=e.replace(i,f=>{const{value:g,css:a}=o(f);return a&&s.push(a),g})}),{result:e,additionalCss:s}},Q=e=>typeof e!="string"?{result:e}:/\{[^{}]+\}/g.test(e)?{result:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V(n[1].replaceAll(".","-"))})`)}:{result:e},M=(e,t,s)=>{if(!e)return"";const n=[],i=Object.entries(e).reduce((f,[g,a])=>{const r=g.trim();if(typeof a=="function"&&(a=a()),typeof a=="object"){if(!a)return f;if(r==="variants")return Object.entries(a).forEach(([u,m])=>{m&&Object.entries(m).forEach(([C,w])=>{if(!w)return;const T=`${t}.${u}-${C}`,N=M(w,T);n.push(N)})}),f;if(r==="defaultVariants")return f;if(r==="compoundVariants")return a.forEach(u=>{const{css:m,...C}=u,w=Object.entries(C).reduce((N,[y,$])=>`${N}.${y}-${$}`,t),T=M(m,w);n.push(T)}),f;if(r.startsWith("@")){const u=M(a,t),m=`${r} {
|
2
2
|
${u.replace(`
|
3
3
|
`,`
|
4
4
|
`)}
|
5
|
-
}`;return n.push(m),f}const d=g.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,
|
5
|
+
}`;return n.push(m),f}const d=g.includes("&")?r.replace("&",t):r.startsWith(":")?`${t}${r}`:`${t} ${r}`,F=M(a,d);return n.push(F),f}const p=r.startsWith("-")?r:V(r),h=(d,F=";")=>f=`${f}${d}${F}`,b=d=>h(`${p}:${d}`);if(typeof a=="number")return b(a);if(typeof a!="string")if("toString"in a)a=a.toString();else return f;const{modifiers:j}={},P=function*(){yield Q(a),yield he(a,j)}();for(const{result:d,additionalCss:F=[]}of P)a=d,F.forEach(u=>{const m=M(u,"");h(m,"")});return b(a)},"");return i?t?[`${t} { ${i} }`,...n].join(`
|
6
6
|
`):i:n.join(`
|
7
7
|
`)},v=(e,t=[])=>{if(!e)return"";const s=[],n={};if(Object.entries(e).forEach(([i,o])=>{if(typeof o=="object"){if(!o)return;const f=i.trim(),g=v(o,[...t,f]);s.push(g)}else n[i]=o}),Object.keys(n).length){const i=t.map(V).join("-"),o=M(n,`.${i}`);s.push(o)}return s.join(`
|
8
|
-
`)},$e=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ee(n).map(i=>`"${i}"`).join(" | ")),t),{}),ee=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?ee(i,o,s):s.add(t)}),[...s]):[],te=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:te(c.join(e,".."))},Se=async e=>{const t=te(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},je=async e=>{const t=await Se(e);if(t)return t.type};let A;const se=async e=>{if(A)return A;const t=await je(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-
|
8
|
+
`)},$e=e=>Object.entries(e).reduce((t,[s,n])=>(typeof n=="object"&&(t[s]=ee(n).map(i=>`"${i}"`).join(" | ")),t),{}),ee=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,i])=>{const o=t?`${t}.${n}`:n;return typeof i=="object"?ee(i,o,s):s.add(t)}),[...s]):[],te=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:te(c.join(e,".."))},Se=async e=>{const t=te(e);return await X.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},je=async e=>{const t=await Se(e);if(t)return t.type};let A;const se=async e=>{if(A)return A;const t=await je(e);return t==="module"?A="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-DlrBgmCh.cjs",document.baseURI).href).endsWith(".cjs"))&&(A="cjs"),A||"esm"},Z=J.createLogger({level:"debug",format:J.format.combine(J.format.colorize(),J.format.cli()),transports:[new J.transports.Console({})]});function ne(e){return e?typeof e!="string"?ne(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 be={"*, *::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={externalModules:[]},oe=e=>{if(H.externalModules.length>0)return H.externalModules;const t=c.join(e,"salty.config.ts"),n=l.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const i=n[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return H.externalModules=i,i},W=e=>c.join(e,"./saltygen"),re=["salty","css","styles","styled"],ie=(e=[])=>new RegExp(`\\.(${[...re,...e].join("|")})\\.`),q=(e,t=[])=>ie(t).test(e),we=async e=>{const t=W(e),s=c.join(e,"salty.config.ts"),n=c.join(t,"salty.config.js"),i=await se(e),o=oe(e);await Y.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:i,external:o});const f=Date.now(),{config:g}=await import(`${n}?t=${f}`);return g},Fe=async e=>{const t=await we(e),s=new Set,n=(y,$=[])=>y?Object.entries(y).flatMap(([x,S])=>{if(!S)return;if(typeof S=="object")return n(S,[...$,x]);const O=ne(x),R=V(x),_=[...$,O].join(".");s.add(`"${_}"`);const E=[...$.map(V),R].join("-"),{result:D}=Q(S);return`--${E}: ${D};`}):[],i=y=>y?Object.entries(y).flatMap(([$,x])=>{const S=n(x);return $==="base"?S.join(""):`${$} { ${S.join("")} }`}):[],o=y=>y?Object.entries(y).flatMap(([$,x])=>Object.entries(x).flatMap(([S,O])=>{const R=n(O,[$]),_=`.${$}-${S}, [data-${$}="${S}"]`,E=R.join("");return`${_} { ${E} }`})):[],f=n(t.variables),g=i(t.responsiveVariables),a=o(t.conditionalVariables),r=W(e),p=c.join(r,"css/_variables.css"),h=`:root { ${f.join("")} ${g.join("")} } ${a.join("")}`;l.writeFileSync(p,h);const b=c.join(r,"css/_global.css"),j=M(t.global,"");l.writeFileSync(b,`@layer global { ${j} }`);const k=c.join(r,"css/_reset.css"),d=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:be,F=M(d,"");l.writeFileSync(k,`@layer reset { ${F} }`);const u=c.join(r,"css/_templates.css"),m=v(t.templates),C=$e(t.templates);l.writeFileSync(u,m);const w=c.join(r,"types/css-tokens.d.ts"),N=`
|
9
9
|
// Variable types
|
10
10
|
type VariableTokens = ${[...s].join("|")};
|
11
11
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
12
12
|
|
13
13
|
// Template types
|
14
14
|
type TemplateTokens = {
|
15
|
-
${Object.entries(
|
15
|
+
${Object.entries(C).map(([y,$])=>`${y}?: ${$}`).join(`
|
16
16
|
`)}
|
17
17
|
}
|
18
|
-
`;l.writeFileSync(
|
19
|
-
`),
|
20
|
-
`);let
|
18
|
+
`;l.writeFileSync(w,N)},U=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const i=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!i.test(e))return t;const f=i.exec(e);if(f){const g=f.at(1);if(re.some(r=>g==null?void 0:g.includes(r)))return t}return"styled('div',"}),L=async(e,t,s)=>{const n=z(t),i=c.join(s,"./temp");l.existsSync(i)||l.mkdirSync(i);const o=c.parse(t);let f=l.readFileSync(t,"utf8");f=U(f);const g=c.join(s,"js",n+".js"),a=oe(e),r=await se(e);await Y.build({stdin:{contents:f,sourcefile:o.base,resolveDir:o.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:g,format:r,target:["node20"],keepNames:!0,external:a,packages:"external",plugins:[{name:"test",setup:b=>{b.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},j=>{const k=l.readFileSync(j.path,"utf8");return{contents:U(k),loader:"ts"}})}}]});const p=Date.now();return await import(`${g}?t=${p}`)},B=async e=>{const t=W(e),s=c.join(t,"salty.config.js"),n=Date.now(),{config:i}=await import(`${s}?t=${n}`);return i},ce=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ce=async(e,t=ce())=>{try{const s=Date.now();t?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const n=[],i=[],o=W(e),f=c.join(o,"index.css");(()=>{l.existsSync(o)&&de.execSync("rm -rf "+o),l.mkdirSync(o),l.mkdirSync(c.join(o,"css")),l.mkdirSync(c.join(o,"types"))})(),await Fe(e);const a=await B(e);async function r(u,m){const C=["node_modules","saltygen"],w=l.statSync(u);if(w.isDirectory()){const T=l.readdirSync(u);if(C.some(y=>u.includes(y)))return;await Promise.all(T.map(y=>r(c.join(u,y),c.join(m,y))))}else if(w.isFile()&&q(u)){const N=await L(e,u,o),y=[];Object.entries(N).forEach(([_,E])=>{if(E.isKeyframes&&E.css){const K=`a_${E.animationName}.css`,fe=`css/${K}`,ue=c.join(o,fe);n.push(K),l.writeFileSync(ue,E.css);return}if(!E.generator)return;const D=E.generator._withBuildContext({name:_,config:a,prod:t});i[D.priority]||(i[D.priority]=[]),i[D.priority].push(D.cssFileName),y.push(D.cssFileName);const ae=`css/${D.cssFileName}`,le=c.join(o,ae);l.writeFileSync(le,D.css)});const $=y.map(_=>`@import url('./${_}');`).join(`
|
19
|
+
`),x=z(u,6),S=c.parse(u),O=V(S.name),R=c.join(o,`css/f_${O}-${x}.css`);l.writeFileSync(R,$)}}await r(e,o);const p=n.map(u=>`@import url('./css/${u}');`).join(`
|
20
|
+
`);let k=`@layer reset, global, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
21
21
|
|
22
22
|
${["_variables.css","_reset.css","_global.css","_templates.css"].filter(u=>{try{return l.readFileSync(c.join(o,"css",u),"utf8").length>0}catch{return!1}}).map(u=>`@import url('./css/${u}');`).join(`
|
23
23
|
`)}
|
24
|
-
${p}`;if(a.importStrategy!=="component"){const u=i.reduce((m,
|
24
|
+
${p}`;if(a.importStrategy!=="component"){const u=i.reduce((m,C,w)=>{const T=C.reduce((x,S)=>{const O=c.join(o,"css",S),R=l.readFileSync(O,"utf8"),_=z(O,6);return`${x}
|
25
25
|
/*start:${_}*/
|
26
26
|
${R}
|
27
27
|
/*end:${_}*/
|
28
|
-
`},""),N=`l_${
|
28
|
+
`},""),N=`l_${w}.css`,y=c.join(o,"css",N),$=`@layer l${w} { ${T}
|
29
29
|
}`;return l.writeFileSync(y,$),`${m}
|
30
|
-
@import url('./css/${N}');`},"");
|
31
|
-
`);f.importStrategy!=="component"&&o.forEach((r,p)=>{const h=`l_${p}.css`,
|
30
|
+
@import url('./css/${N}');`},"");k+=u}l.writeFileSync(f,k);const d=Date.now()-s,F=d<200?"🔥":d<500?"🚀":d<1e3?"🎉":d<2e3?"🚗":d<5e3?"🤔":"🥴";Z.info(`Generated CSS in ${d}ms! ${F}`)}catch(s){console.error(s)}},xe=async(e,t)=>{try{const s=c.join(e,"./saltygen"),n=c.join(s,"index.css");if(q(t)){const o=[],f=await B(e),g=await L(e,t,s);Object.entries(g).forEach(([r,p])=>{if(p.isKeyframes&&p.css){const P=`css/${`a_${p.animationName}.css`}`,d=c.join(s,P);l.writeFileSync(d,p.css);return}if(!p.generator)return;const h=p.generator._withBuildContext({name:r,config:f}),b=`css/${h.cssFileName}`,j=c.join(s,b);l.writeFileSync(j,h.css),o[h.priority]||(o[h.priority]=[]),o[h.priority].push(h.cssFileName)});const a=l.readFileSync(n,"utf8").split(`
|
31
|
+
`);f.importStrategy!=="component"&&o.forEach((r,p)=>{const h=`l_${p}.css`,b=c.join(s,"css",h);let j=l.readFileSync(b,"utf8");r.forEach(k=>{const P=c.join(s,"css",k),d=z(P,6);if(!j.includes(d)){const u=l.readFileSync(P,"utf8"),m=z(P,6),C=`/*start:${m}*/
|
32
32
|
${u}
|
33
33
|
/*end:${m}*/
|
34
34
|
`;j=`${j.replace(/\}$/,"")}
|
35
|
-
${
|
36
|
-
}`}}),l.writeFileSync(
|
35
|
+
${C}
|
36
|
+
}`}}),l.writeFileSync(b,j)})}}catch(s){console.error(s)}},ke=async(e,t,s=ce())=>{try{const n=c.join(e,"./saltygen");if(q(t)){const o=l.readFileSync(t,"utf8");o.replace(/^(?!export\s)const\s.*/gm,p=>`export ${p}`)!==o&&await X.writeFile(t,o);const g=await B(e),a=await L(e,t,n);let r=o;if(Object.entries(a).forEach(([p,h])=>{var x;if(h.isKeyframes||!h.generator)return;const b=h.generator._withBuildContext({name:p,config:g,prod:s}),j=new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(o);if(!j)return console.error("Could not find the original declaration");const k=(x=j.at(1))==null?void 0:x.trim(),P=new RegExp(`\\s${p}[=\\s]+styled\\(`,"g").exec(r);if(!P)return console.error("Could not find the original declaration");const{index:d}=P;let F=!1;const u=setTimeout(()=>F=!0,5e3);let m=0,C=!1,w=0;for(;!C&&!F;){const S=r[d+m];S==="("&&w++,S===")"&&w--,w===0&&S===")"&&(C=!0),m>r.length&&(F=!0),m++}if(!F)clearTimeout(u);else throw new Error("Failed to find the end of the styled call and timed out");const T=d+m,N=r.slice(d,T),y=r,$=` ${p} = styled(${k}, "${b.classNames}", ${JSON.stringify(b.props)});`;r=r.replace(N,$),y===r&&console.error("Minimize file failed to change content",{name:p,tagName:k})}),g.importStrategy==="component"){const p=z(t,6),h=c.parse(t);r=`import '../../saltygen/css/${`f_${V(h.name)}-${p}.css`}';
|
37
37
|
${r}`}return r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=Ce;exports.generateFile=xe;exports.minimizeFile=ke;exports.saltyFileRegExp=ie;
|
package/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),u=require("./index-DlrBgmCh.cjs"),r=(e,s,o=!1,n=!1)=>{var a,l,t;(l=(a=e.module)==null?void 0:a.rules)==null||l.push({test:u.saltyFileRegExp(),use:[{loader:p.resolve(__dirname,n?"./loader.cjs":"./loader.js"),options:{dir:s}}]}),o||(t=e.plugins)==null||t.push({apply:i=>{i.hooks.afterPlugins.tap({name:"generateCss"},async()=>{await u.generateCss(s)})}})};exports.default=r;exports.saltyPlugin=r;
|
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { resolve as n } from "path";
|
2
|
-
import { s as u, g as i } from "./index-
|
2
|
+
import { s as u, g as i } from "./index-B1xbIfxW.js";
|
3
3
|
const g = (s, e, o = !1, r = !1) => {
|
4
4
|
var a, l, t;
|
5
5
|
(l = (a = s.module) == null ? void 0 : a.rules) == null || l.push({
|
package/loader.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const i=require("./index-
|
1
|
+
"use strict";const i=require("./index-DlrBgmCh.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.144",
|
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.144",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|