@salty-css/webpack 0.0.1-alpha.85 → 0.0.1-alpha.86
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-41n1R3xS.js +317 -0
- package/index-BTFjlOua.cjs +18 -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-CHPHy_LU.js +0 -315
- package/index-CZ6C_--G.cjs +0 -18
@@ -0,0 +1,317 @@
|
|
1
|
+
import * as K from "esbuild";
|
2
|
+
import { execSync as nt } from "child_process";
|
3
|
+
import { join as f } from "path";
|
4
|
+
import { existsSync as L, writeFileSync as E, readFileSync as V, mkdirSync as A, statSync as ot, readdirSync as rt } from "fs";
|
5
|
+
import { readFile as ct, writeFile as it } from "fs/promises";
|
6
|
+
import { createLogger as at, format as R, transports as lt } from "winston";
|
7
|
+
const G = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), ft = (t, e) => {
|
8
|
+
let s = "", o;
|
9
|
+
for (o = Math.abs(t); o > 52; o = o / 52 | 0) s = G(o % 52) + s;
|
10
|
+
return s = G(o % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
+
}, pt = (t, e) => {
|
12
|
+
let s = e.length;
|
13
|
+
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
|
+
return t;
|
15
|
+
}, W = (t, e = 3) => {
|
16
|
+
const s = pt(5381, JSON.stringify(t)) >>> 0;
|
17
|
+
return ft(s, e);
|
18
|
+
};
|
19
|
+
function N(t) {
|
20
|
+
return t ? typeof t != "string" ? N(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
|
21
|
+
}
|
22
|
+
const ut = (t, e) => {
|
23
|
+
if (typeof t != "string") return { result: t };
|
24
|
+
if (!e) return { result: t };
|
25
|
+
const s = [];
|
26
|
+
return Object.values(e).forEach((o) => {
|
27
|
+
const { pattern: r, transform: i } = o;
|
28
|
+
t = t.replace(r, (y) => {
|
29
|
+
const { value: a, css: h } = i(y);
|
30
|
+
return h && s.push(h), a;
|
31
|
+
});
|
32
|
+
}), { result: t, additionalCss: s };
|
33
|
+
}, q = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...o) => `var(--${N(o[1].replaceAll(".", "-"))})`) } : { result: t }, D = (t, e, s, o) => {
|
34
|
+
if (!t) return "";
|
35
|
+
const r = [], i = Object.entries(t).reduce((a, [h, n]) => {
|
36
|
+
const g = h.trim();
|
37
|
+
if (typeof n == "function" && (n = n()), typeof n == "object") {
|
38
|
+
if (!n) return a;
|
39
|
+
if (g === "variants")
|
40
|
+
return Object.entries(n).forEach(([p, c]) => {
|
41
|
+
c && Object.entries(c).forEach(([m, u]) => {
|
42
|
+
if (!u) return;
|
43
|
+
const x = `${e}.${p}-${m}`, C = D(u, x);
|
44
|
+
r.push(C);
|
45
|
+
});
|
46
|
+
}), a;
|
47
|
+
if (g === "defaultVariants")
|
48
|
+
return a;
|
49
|
+
if (g === "compoundVariants")
|
50
|
+
return n.forEach((p) => {
|
51
|
+
const { css: c, ...m } = p, u = Object.entries(m).reduce((C, [j, k]) => `${C}.${j}-${k}`, e), x = D(c, u);
|
52
|
+
r.push(x);
|
53
|
+
}), a;
|
54
|
+
if (g.startsWith("@")) {
|
55
|
+
const p = D(n, e), c = `${g} {
|
56
|
+
${p.replace(`
|
57
|
+
`, `
|
58
|
+
`)}
|
59
|
+
}`;
|
60
|
+
return r.push(c), a;
|
61
|
+
}
|
62
|
+
const d = h.includes("&") ? g.replace("&", e) : g.startsWith(":") ? `${e}${g}` : `${e} ${g}`, $ = D(n, d);
|
63
|
+
return r.push($), a;
|
64
|
+
}
|
65
|
+
const b = g.startsWith("-") ? g : N(g), w = (d, $ = ";") => a = `${a}${d}${$}`, F = (d) => w(`${b}:${d}`);
|
66
|
+
if (typeof n == "number") return F(n);
|
67
|
+
if (typeof n != "string")
|
68
|
+
if ("toString" in n) n = n.toString();
|
69
|
+
else return a;
|
70
|
+
const { modifiers: l } = {}, P = function* () {
|
71
|
+
yield q(n), yield ut(n, l);
|
72
|
+
}();
|
73
|
+
for (const { result: d, additionalCss: $ = [] } of P)
|
74
|
+
n = d, $.forEach((p) => {
|
75
|
+
const c = D(p, "");
|
76
|
+
w(c, "");
|
77
|
+
});
|
78
|
+
return F(n);
|
79
|
+
}, "");
|
80
|
+
if (!i) return r.join(`
|
81
|
+
`);
|
82
|
+
if (!e) return i;
|
83
|
+
let y = "";
|
84
|
+
return y = `${e} { ${i} }`, [y, ...r].join(`
|
85
|
+
`);
|
86
|
+
}, U = (t, e = []) => {
|
87
|
+
if (!t) return "";
|
88
|
+
const s = [], o = {};
|
89
|
+
if (Object.entries(t).forEach(([r, i]) => {
|
90
|
+
if (typeof i == "object") {
|
91
|
+
if (!i) return;
|
92
|
+
const y = r.trim(), a = U(i, [...e, y]);
|
93
|
+
s.push(a);
|
94
|
+
} else
|
95
|
+
o[r] = i;
|
96
|
+
}), Object.keys(o).length) {
|
97
|
+
const r = e.map(N).join("-"), i = D(o, `.${r}`);
|
98
|
+
s.push(i);
|
99
|
+
}
|
100
|
+
return s.join(`
|
101
|
+
`);
|
102
|
+
}, X = (t) => {
|
103
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
104
|
+
const e = f(t, "package.json");
|
105
|
+
return L(e) ? e : X(f(t, ".."));
|
106
|
+
}, gt = async (t) => {
|
107
|
+
const e = X(t);
|
108
|
+
return await ct(e, "utf-8").then(JSON.parse).catch(() => {
|
109
|
+
});
|
110
|
+
}, dt = async (t) => {
|
111
|
+
const e = await gt(t);
|
112
|
+
if (e)
|
113
|
+
return e.type;
|
114
|
+
};
|
115
|
+
let T;
|
116
|
+
const Y = async (t) => {
|
117
|
+
if (T) return T;
|
118
|
+
const e = await dt(t);
|
119
|
+
return e === "module" ? T = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (T = "cjs"), T || "esm";
|
120
|
+
}, H = at({
|
121
|
+
level: "debug",
|
122
|
+
format: R.combine(R.colorize(), R.cli()),
|
123
|
+
transports: [new lt.Console({})]
|
124
|
+
}), _ = {
|
125
|
+
externalModules: []
|
126
|
+
}, Q = (t) => {
|
127
|
+
if (_.externalModules.length > 0) return _.externalModules;
|
128
|
+
const e = f(t, "salty.config.ts"), o = V(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
129
|
+
if (!o) return [];
|
130
|
+
const r = o[1].split(",").map((i) => i.replace(/['"`]/g, "").trim());
|
131
|
+
return _.externalModules = r, r;
|
132
|
+
}, J = (t) => f(t, "./saltygen"), yt = ["salty", "css", "styles", "styled"], mt = (t = []) => new RegExp(`\\.(${[...yt, ...t].join("|")})\\.`), B = (t, e = []) => mt(e).test(t), ht = async (t) => {
|
133
|
+
const e = J(t), s = f(t, "salty.config.ts"), o = f(e, "salty.config.js"), r = await Y(t), i = Q(t);
|
134
|
+
await K.build({
|
135
|
+
entryPoints: [s],
|
136
|
+
minify: !0,
|
137
|
+
treeShaking: !0,
|
138
|
+
bundle: !0,
|
139
|
+
outfile: o,
|
140
|
+
format: r,
|
141
|
+
external: i
|
142
|
+
});
|
143
|
+
const y = Date.now(), { config: a } = await import(`${o}?t=${y}`);
|
144
|
+
return a;
|
145
|
+
}, $t = async (t) => {
|
146
|
+
const e = await ht(t), s = /* @__PURE__ */ new Set(), o = (p, c = []) => p ? Object.entries(p).flatMap(([m, u]) => {
|
147
|
+
if (!u) return;
|
148
|
+
if (typeof u == "object") return o(u, [...c, m]);
|
149
|
+
const x = [...c, m].join(".");
|
150
|
+
s.add(`"${x}"`);
|
151
|
+
const C = [...c.map(N), N(m)].join("-"), { result: j } = q(u);
|
152
|
+
return `--${C}: ${j};`;
|
153
|
+
}) : [], r = (p) => p ? Object.entries(p).flatMap(([c, m]) => {
|
154
|
+
const u = o(m);
|
155
|
+
return c === "base" ? u.join("") : `${c} { ${u.join("")} }`;
|
156
|
+
}) : [], i = (p) => p ? Object.entries(p).flatMap(([c, m]) => Object.entries(m).flatMap(([u, x]) => {
|
157
|
+
const C = o(x, [c]), j = `.${c}-${u}, [data-${c}="${u}"]`, k = C.join("");
|
158
|
+
return `${j} { ${k} }`;
|
159
|
+
})) : [], y = o(e.variables), a = r(e.responsiveVariables), h = i(e.conditionalVariables), n = J(t), g = f(n, "css/variables.css"), b = `:root { ${y.join("")} ${a.join("")} } ${h.join("")}`;
|
160
|
+
E(g, b);
|
161
|
+
const w = f(n, "types/css-tokens.d.ts"), l = `type VariableTokens = ${[...s].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
162
|
+
E(w, l);
|
163
|
+
const S = f(n, "css/global.css"), P = D(e.global, "");
|
164
|
+
E(S, P);
|
165
|
+
const d = f(n, "css/templates.css"), $ = U(e.templates);
|
166
|
+
E(d, $);
|
167
|
+
}, I = async (t, e, s) => {
|
168
|
+
const o = W(e), r = f(s, "js", o + ".js"), i = await Y(t), y = Q(t);
|
169
|
+
await K.build({
|
170
|
+
entryPoints: [e],
|
171
|
+
minify: !0,
|
172
|
+
treeShaking: !0,
|
173
|
+
bundle: !0,
|
174
|
+
outfile: r,
|
175
|
+
format: i,
|
176
|
+
target: ["es2022"],
|
177
|
+
keepNames: !0,
|
178
|
+
external: y
|
179
|
+
});
|
180
|
+
const a = Date.now();
|
181
|
+
return await import(`${r}?t=${a}`);
|
182
|
+
}, Z = async (t) => {
|
183
|
+
const e = J(t), s = f(e, "salty.config.js"), { config: o } = await import(s);
|
184
|
+
return o;
|
185
|
+
}, v = () => {
|
186
|
+
try {
|
187
|
+
return process.env.NODE_ENV === "production";
|
188
|
+
} catch {
|
189
|
+
return !1;
|
190
|
+
}
|
191
|
+
}, Ft = async (t, e = v()) => {
|
192
|
+
try {
|
193
|
+
e ? H.info("Generating CSS in production mode! 🔥") : H.info("Generating CSS in development mode! 🚀");
|
194
|
+
const s = [], o = [], r = J(t), i = f(r, "index.css");
|
195
|
+
(() => {
|
196
|
+
L(r) && nt("rm -rf " + r), A(r), A(f(r, "css")), A(f(r, "types"));
|
197
|
+
})(), await $t(t);
|
198
|
+
const a = await Z(t);
|
199
|
+
async function h(l, S) {
|
200
|
+
const P = ["node_modules", "saltygen"], d = ot(l);
|
201
|
+
if (d.isDirectory()) {
|
202
|
+
const $ = rt(l);
|
203
|
+
if (P.some((c) => l.includes(c))) return;
|
204
|
+
await Promise.all($.map((c) => h(f(l, c), f(S, c))));
|
205
|
+
} else if (d.isFile() && B(l)) {
|
206
|
+
const p = await I(t, l, r), c = [];
|
207
|
+
Object.entries(p).forEach(([C, j]) => {
|
208
|
+
if (j.isKeyframes && j.css) {
|
209
|
+
const z = `${j.animationName}.css`, et = `css/${z}`, st = f(r, et);
|
210
|
+
s.push(z), E(st, j.css);
|
211
|
+
return;
|
212
|
+
}
|
213
|
+
if (!j.generator) return;
|
214
|
+
const k = j.generator._withBuildContext({
|
215
|
+
name: C,
|
216
|
+
config: a,
|
217
|
+
prod: e
|
218
|
+
}), M = `${k.hash}-${k.priority}.css`;
|
219
|
+
o[k.priority] || (o[k.priority] = []), o[k.priority].push(M), c.push(M);
|
220
|
+
const O = `css/${M}`, tt = f(r, O);
|
221
|
+
E(tt, k.css);
|
222
|
+
});
|
223
|
+
const m = c.map((C) => `@import url('./${C}');`).join(`
|
224
|
+
`), u = W(l, 6), x = f(r, `css/${u}.css`);
|
225
|
+
E(x, m);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
await h(t, r);
|
229
|
+
const n = s.map((l) => `@import url('./css/${l}');`).join(`
|
230
|
+
`);
|
231
|
+
let F = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
232
|
+
|
233
|
+
${["variables.css", "global.css", "templates.css"].filter((l) => {
|
234
|
+
try {
|
235
|
+
return V(f(r, "css", l), "utf8").length > 0;
|
236
|
+
} catch {
|
237
|
+
return !1;
|
238
|
+
}
|
239
|
+
}).map((l) => `@import url('./css/${l}');`).join(`
|
240
|
+
`)}
|
241
|
+
${n}`;
|
242
|
+
if (a.importStrategy !== "component") {
|
243
|
+
const l = o.flat().map((S) => `@import url('./css/${S}');`).join(`
|
244
|
+
`);
|
245
|
+
F += l;
|
246
|
+
}
|
247
|
+
E(i, F);
|
248
|
+
} catch (s) {
|
249
|
+
console.error(s);
|
250
|
+
}
|
251
|
+
}, kt = async (t, e) => {
|
252
|
+
try {
|
253
|
+
const s = [], o = f(t, "./saltygen"), r = f(o, "index.css");
|
254
|
+
if (B(e)) {
|
255
|
+
const y = await Z(t), a = await I(t, e, o);
|
256
|
+
Object.entries(a).forEach(([w, F]) => {
|
257
|
+
if (!F.generator) return;
|
258
|
+
const l = F.generator._withBuildContext({
|
259
|
+
name: w,
|
260
|
+
config: y
|
261
|
+
}), S = `${l.hash}-${l.priority}.css`, P = `css/${S}`, d = f(o, P);
|
262
|
+
s.push(S), E(d, l.css);
|
263
|
+
});
|
264
|
+
const h = V(r, "utf8").split(`
|
265
|
+
`), n = s.map((w) => `@import url('../saltygen/css/${w}');`), b = [.../* @__PURE__ */ new Set([...h, ...n])].join(`
|
266
|
+
`);
|
267
|
+
E(r, b);
|
268
|
+
}
|
269
|
+
} catch (s) {
|
270
|
+
console.error(s);
|
271
|
+
}
|
272
|
+
}, xt = async (t, e, s = v()) => {
|
273
|
+
try {
|
274
|
+
const o = f(t, "./saltygen");
|
275
|
+
if (B(e)) {
|
276
|
+
const i = V(e, "utf8");
|
277
|
+
i.replace(/^(?!export\s)const\s.*/gm, (b) => `export ${b}`) !== i && await it(e, i);
|
278
|
+
const a = await Z(t), h = await I(t, e, o);
|
279
|
+
let n = i;
|
280
|
+
Object.entries(h).forEach(([b, w]) => {
|
281
|
+
var M;
|
282
|
+
if (w.isKeyframes || !w.generator) return;
|
283
|
+
const F = w.generator._withBuildContext({
|
284
|
+
name: b,
|
285
|
+
config: a,
|
286
|
+
prod: s
|
287
|
+
}), l = new RegExp(`\\s${b}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(i);
|
288
|
+
if (!l) return console.error("Could not find the original declaration");
|
289
|
+
const S = (M = l.at(1)) == null ? void 0 : M.trim(), P = new RegExp(`\\s${b}[=\\s]+styled\\(`, "g").exec(n);
|
290
|
+
if (!P) return console.error("Could not find the original declaration");
|
291
|
+
const { index: d } = P;
|
292
|
+
let $ = !1;
|
293
|
+
const p = setTimeout(() => $ = !0, 5e3);
|
294
|
+
let c = 0, m = !1, u = 0;
|
295
|
+
for (; !m && !$; ) {
|
296
|
+
const O = n[d + c];
|
297
|
+
O === "(" && u++, O === ")" && u--, u === 0 && O === ")" && (m = !0), c > n.length && ($ = !0), c++;
|
298
|
+
}
|
299
|
+
if (!$) clearTimeout(p);
|
300
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
301
|
+
const x = d + c, C = n.slice(d, x), j = n, k = ` ${b} = styled(${S}, "${F.classNames}", ${JSON.stringify(F.props)});`;
|
302
|
+
n = n.replace(C, k), j === n && console.error("Minimize file failed to change content", { name: b, tagName: S });
|
303
|
+
});
|
304
|
+
const g = W(e, 6);
|
305
|
+
return a.importStrategy === "component" && (n = `import '../../saltygen/css/${g}.css';
|
306
|
+
${n}`), n = n.replace("{ styled }", "{ styledClient as styled }"), n = n.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), n;
|
307
|
+
}
|
308
|
+
} catch (o) {
|
309
|
+
console.error("Error in minimizeFile:", o);
|
310
|
+
}
|
311
|
+
};
|
312
|
+
export {
|
313
|
+
kt as a,
|
314
|
+
Ft as g,
|
315
|
+
xt as m,
|
316
|
+
mt as s
|
317
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";const nt=require("esbuild"),ot=require("child_process"),f=require("path"),d=require("fs"),L=require("fs/promises"),V=require("winston");var J=typeof document<"u"?document.currentScript:null;function rt(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 U=rt(nt),B=t=>String.fromCharCode(t+(t>25?39:97)),it=(t,e)=>{let s="",n;for(n=Math.abs(t);n>52;n=n/52|0)s=B(n%52)+s;return s=B(n%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},ct=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},A=(t,e=3)=>{const s=ct(5381,JSON.stringify(t))>>>0;return it(s,e)};function M(t){return t?typeof t!="string"?M(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 at=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(n=>{const{pattern:r,transform:c}=n;t=t.replace(r,m=>{const{value:a,css:j}=c(m);return j&&s.push(j),a})}),{result:t,additionalCss:s}},G=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${M(n[1].replaceAll(".","-"))})`)}:{result:t},T=(t,e,s,n)=>{if(!t)return"";const r=[],c=Object.entries(t).reduce((a,[j,o])=>{const g=j.trim();if(typeof o=="function"&&(o=o()),typeof o=="object"){if(!o)return a;if(g==="variants")return Object.entries(o).forEach(([u,i])=>{i&&Object.entries(i).forEach(([h,p])=>{if(!p)return;const P=`${e}.${u}-${h}`,C=T(p,P);r.push(C)})}),a;if(g==="defaultVariants")return a;if(g==="compoundVariants")return o.forEach(u=>{const{css:i,...h}=u,p=Object.entries(h).reduce((C,[S,x])=>`${C}.${S}-${x}`,e),P=T(i,p);r.push(P)}),a;if(g.startsWith("@")){const u=T(o,e),i=`${g} {
|
2
|
+
${u.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return r.push(i),a}const y=j.includes("&")?g.replace("&",e):g.startsWith(":")?`${e}${g}`:`${e} ${g}`,$=T(o,y);return r.push($),a}const b=g.startsWith("-")?g:M(g),w=(y,$=";")=>a=`${a}${y}${$}`,k=y=>w(`${b}:${y}`);if(typeof o=="number")return k(o);if(typeof o!="string")if("toString"in o)o=o.toString();else return a;const{modifiers:l}={},O=function*(){yield G(o),yield at(o,l)}();for(const{result:y,additionalCss:$=[]}of O)o=y,$.forEach(u=>{const i=T(u,"");w(i,"")});return k(o)},"");if(!c)return r.join(`
|
6
|
+
`);if(!e)return c;let m="";return m=`${e} { ${c} }`,[m,...r].join(`
|
7
|
+
`)},H=(t,e=[])=>{if(!t)return"";const s=[],n={};if(Object.entries(t).forEach(([r,c])=>{if(typeof c=="object"){if(!c)return;const m=r.trim(),a=H(c,[...e,m]);s.push(a)}else n[r]=c}),Object.keys(n).length){const r=e.map(M).join("-"),c=T(n,`.${r}`);s.push(c)}return s.join(`
|
8
|
+
`)},K=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=f.join(t,"package.json");return d.existsSync(e)?e:K(f.join(t,".."))},lt=async t=>{const e=K(t);return await L.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},ft=async t=>{const e=await lt(t);if(e)return e.type};let E;const X=async t=>{if(E)return E;const e=await ft(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("index-BTFjlOua.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},Z=V.createLogger({level:"debug",format:V.format.combine(V.format.colorize(),V.format.cli()),transports:[new V.transports.Console({})]}),R={externalModules:[]},Y=t=>{if(R.externalModules.length>0)return R.externalModules;const e=f.join(t,"salty.config.ts"),n=d.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!n)return[];const r=n[1].split(",").map(c=>c.replace(/['"`]/g,"").trim());return R.externalModules=r,r},_=t=>f.join(t,"./saltygen"),ut=["salty","css","styles","styled"],Q=(t=[])=>new RegExp(`\\.(${[...ut,...t].join("|")})\\.`),q=(t,e=[])=>Q(e).test(t),pt=async t=>{const e=_(t),s=f.join(t,"salty.config.ts"),n=f.join(e,"salty.config.js"),r=await X(t),c=Y(t);await U.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:r,external:c});const m=Date.now(),{config:a}=await import(`${n}?t=${m}`);return a},dt=async t=>{const e=await pt(t),s=new Set,n=(u,i=[])=>u?Object.entries(u).flatMap(([h,p])=>{if(!p)return;if(typeof p=="object")return n(p,[...i,h]);const P=[...i,h].join(".");s.add(`"${P}"`);const C=[...i.map(M),M(h)].join("-"),{result:S}=G(p);return`--${C}: ${S};`}):[],r=u=>u?Object.entries(u).flatMap(([i,h])=>{const p=n(h);return i==="base"?p.join(""):`${i} { ${p.join("")} }`}):[],c=u=>u?Object.entries(u).flatMap(([i,h])=>Object.entries(h).flatMap(([p,P])=>{const C=n(P,[i]),S=`.${i}-${p}, [data-${i}="${p}"]`,x=C.join("");return`${S} { ${x} }`})):[],m=n(e.variables),a=r(e.responsiveVariables),j=c(e.conditionalVariables),o=_(t),g=f.join(o,"css/variables.css"),b=`:root { ${m.join("")} ${a.join("")} } ${j.join("")}`;d.writeFileSync(g,b);const w=f.join(o,"types/css-tokens.d.ts"),l=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;d.writeFileSync(w,l);const F=f.join(o,"css/global.css"),O=T(e.global,"");d.writeFileSync(F,O);const y=f.join(o,"css/templates.css"),$=H(e.templates);d.writeFileSync(y,$)},I=async(t,e,s)=>{const n=A(e),r=f.join(s,"js",n+".js"),c=await X(t),m=Y(t);await U.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:r,format:c,target:["es2022"],keepNames:!0,external:m});const a=Date.now();return await import(`${r}?t=${a}`)},z=async t=>{const e=_(t),s=f.join(e,"salty.config.js"),{config:n}=await import(s);return n},v=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},gt=async(t,e=v())=>{try{e?Z.info("Generating CSS in production mode! 🔥"):Z.info("Generating CSS in development mode! 🚀");const s=[],n=[],r=_(t),c=f.join(r,"index.css");(()=>{d.existsSync(r)&&ot.execSync("rm -rf "+r),d.mkdirSync(r),d.mkdirSync(f.join(r,"css")),d.mkdirSync(f.join(r,"types"))})(),await dt(t);const a=await z(t);async function j(l,F){const O=["node_modules","saltygen"],y=d.statSync(l);if(y.isDirectory()){const $=d.readdirSync(l);if(O.some(i=>l.includes(i)))return;await Promise.all($.map(i=>j(f.join(l,i),f.join(F,i))))}else if(y.isFile()&&q(l)){const u=await I(t,l,r),i=[];Object.entries(u).forEach(([C,S])=>{if(S.isKeyframes&&S.css){const W=`${S.animationName}.css`,et=`css/${W}`,st=f.join(r,et);s.push(W),d.writeFileSync(st,S.css);return}if(!S.generator)return;const x=S.generator._withBuildContext({name:C,config:a,prod:e}),D=`${x.hash}-${x.priority}.css`;n[x.priority]||(n[x.priority]=[]),n[x.priority].push(D),i.push(D);const N=`css/${D}`,tt=f.join(r,N);d.writeFileSync(tt,x.css)});const h=i.map(C=>`@import url('./${C}');`).join(`
|
9
|
+
`),p=A(l,6),P=f.join(r,`css/${p}.css`);d.writeFileSync(P,h)}}await j(t,r);const o=s.map(l=>`@import url('./css/${l}');`).join(`
|
10
|
+
`);let k=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
11
|
+
|
12
|
+
${["variables.css","global.css","templates.css"].filter(l=>{try{return d.readFileSync(f.join(r,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
13
|
+
`)}
|
14
|
+
${o}`;if(a.importStrategy!=="component"){const l=n.flat().map(F=>`@import url('./css/${F}');`).join(`
|
15
|
+
`);k+=l}d.writeFileSync(c,k)}catch(s){console.error(s)}},yt=async(t,e)=>{try{const s=[],n=f.join(t,"./saltygen"),r=f.join(n,"index.css");if(q(e)){const m=await z(t),a=await I(t,e,n);Object.entries(a).forEach(([w,k])=>{if(!k.generator)return;const l=k.generator._withBuildContext({name:w,config:m}),F=`${l.hash}-${l.priority}.css`,O=`css/${F}`,y=f.join(n,O);s.push(F),d.writeFileSync(y,l.css)});const j=d.readFileSync(r,"utf8").split(`
|
16
|
+
`),o=s.map(w=>`@import url('../saltygen/css/${w}');`),b=[...new Set([...j,...o])].join(`
|
17
|
+
`);d.writeFileSync(r,b)}}catch(s){console.error(s)}},mt=async(t,e,s=v())=>{try{const n=f.join(t,"./saltygen");if(q(e)){const c=d.readFileSync(e,"utf8");c.replace(/^(?!export\s)const\s.*/gm,b=>`export ${b}`)!==c&&await L.writeFile(e,c);const a=await z(t),j=await I(t,e,n);let o=c;Object.entries(j).forEach(([b,w])=>{var D;if(w.isKeyframes||!w.generator)return;const k=w.generator._withBuildContext({name:b,config:a,prod:s}),l=new RegExp(`\\s${b}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(c);if(!l)return console.error("Could not find the original declaration");const F=(D=l.at(1))==null?void 0:D.trim(),O=new RegExp(`\\s${b}[=\\s]+styled\\(`,"g").exec(o);if(!O)return console.error("Could not find the original declaration");const{index:y}=O;let $=!1;const u=setTimeout(()=>$=!0,5e3);let i=0,h=!1,p=0;for(;!h&&!$;){const N=o[y+i];N==="("&&p++,N===")"&&p--,p===0&&N===")"&&(h=!0),i>o.length&&($=!0),i++}if(!$)clearTimeout(u);else throw new Error("Failed to find the end of the styled call and timed out");const P=y+i,C=o.slice(y,P),S=o,x=` ${b} = styled(${F}, "${k.classNames}", ${JSON.stringify(k.props)});`;o=o.replace(C,x),S===o&&console.error("Minimize file failed to change content",{name:b,tagName:F})});const g=A(e,6);return a.importStrategy==="component"&&(o=`import '../../saltygen/css/${g}.css';
|
18
|
+
${o}`),o=o.replace("{ styled }","{ styledClient as styled }"),o=o.replace("@salty-css/react/styled","@salty-css/react/styled-client"),o}}catch(n){console.error("Error in minimizeFile:",n)}};exports.generateCss=gt;exports.generateFile=yt;exports.minimizeFile=mt;exports.saltyFileRegExp=Q;
|
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-BTFjlOua.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-41n1R3xS.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-BTFjlOua.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.86",
|
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.86",
|
38
38
|
"webpack": ">=5.x"
|
39
39
|
}
|
40
40
|
}
|
package/index-CHPHy_LU.js
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
import * as H from "esbuild";
|
2
|
-
import { execSync as st } from "child_process";
|
3
|
-
import { join as f } from "path";
|
4
|
-
import { existsSync as K, writeFileSync as E, readFileSync as O, mkdirSync as J, statSync as nt, readdirSync as ot } from "fs";
|
5
|
-
import { readFile as rt, writeFile as ct } from "fs/promises";
|
6
|
-
import { createLogger as it, format as A, transports as at } from "winston";
|
7
|
-
const z = (t) => String.fromCharCode(t + (t > 25 ? 39 : 97)), lt = (t, e) => {
|
8
|
-
let s = "", o;
|
9
|
-
for (o = Math.abs(t); o > 52; o = o / 52 | 0) s = z(o % 52) + s;
|
10
|
-
return s = z(o % 52) + s, s.length < e ? s = s.padStart(e, "a") : s.length > e && (s = s.slice(-e)), s;
|
11
|
-
}, ft = (t, e) => {
|
12
|
-
let s = e.length;
|
13
|
-
for (; s; ) t = t * 33 ^ e.charCodeAt(--s);
|
14
|
-
return t;
|
15
|
-
}, R = (t, e = 3) => {
|
16
|
-
const s = ft(5381, JSON.stringify(t)) >>> 0;
|
17
|
-
return lt(s, e);
|
18
|
-
};
|
19
|
-
function T(t) {
|
20
|
-
return t ? typeof t != "string" ? T(String(t)) : t.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "-" : "") + e.toLowerCase()) : "";
|
21
|
-
}
|
22
|
-
const pt = (t, e) => {
|
23
|
-
if (typeof t != "string") return { result: t };
|
24
|
-
if (!e) return { result: t };
|
25
|
-
const s = [];
|
26
|
-
return Object.values(e).forEach((o) => {
|
27
|
-
const { pattern: n, transform: p } = o;
|
28
|
-
t = t.replace(n, (m) => {
|
29
|
-
const { value: a, css: i } = p(m);
|
30
|
-
return i && s.push(i), a;
|
31
|
-
});
|
32
|
-
}), { result: t, additionalCss: s };
|
33
|
-
}, L = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...o) => `var(--${T(o[1].replaceAll(".", "-"))})`) } : { result: t }, M = (t, e, s, o) => {
|
34
|
-
if (!t) return "";
|
35
|
-
const n = [], p = Object.entries(t).reduce((a, [i, r]) => {
|
36
|
-
const u = i.trim();
|
37
|
-
if (typeof r == "function" && (r = r()), typeof r == "object") {
|
38
|
-
if (!r) return a;
|
39
|
-
if (u === "variants")
|
40
|
-
return Object.entries(r).forEach(([g, c]) => {
|
41
|
-
c && Object.entries(c).forEach(([h, y]) => {
|
42
|
-
if (!y) return;
|
43
|
-
const x = `${e}.${g}-${h}`, w = M(y, x);
|
44
|
-
n.push(w);
|
45
|
-
});
|
46
|
-
}), a;
|
47
|
-
if (u === "defaultVariants")
|
48
|
-
return a;
|
49
|
-
if (u === "compoundVariants")
|
50
|
-
return r.forEach((g) => {
|
51
|
-
const { css: c, ...h } = g, y = Object.entries(h).reduce((w, [$, S]) => `${w}.${$}-${S}`, e), x = M(c, y);
|
52
|
-
n.push(x);
|
53
|
-
}), a;
|
54
|
-
if (u.startsWith("@")) {
|
55
|
-
const g = M(r, e), c = `${u} {
|
56
|
-
${g.replace(`
|
57
|
-
`, `
|
58
|
-
`)}
|
59
|
-
}`;
|
60
|
-
return n.push(c), a;
|
61
|
-
}
|
62
|
-
const d = i.includes("&") ? u.replace("&", e) : u.startsWith(":") ? `${e}${u}` : `${e} ${u}`, F = M(r, d);
|
63
|
-
return n.push(F), a;
|
64
|
-
}
|
65
|
-
const P = u.startsWith("-") ? u : T(u), b = (d, F = ";") => a = `${a}${d}${F}`, C = (d) => b(`${P}:${d}`);
|
66
|
-
if (typeof r == "number") return C(r);
|
67
|
-
if (typeof r != "string")
|
68
|
-
if ("toString" in r) r = r.toString();
|
69
|
-
else return a;
|
70
|
-
const { modifiers: l } = {}, k = function* () {
|
71
|
-
yield L(r), yield pt(r, l);
|
72
|
-
}();
|
73
|
-
for (const { result: d, additionalCss: F = [] } of k)
|
74
|
-
r = d, F.forEach((g) => {
|
75
|
-
const c = M(g, "");
|
76
|
-
b(c, "");
|
77
|
-
});
|
78
|
-
return C(r);
|
79
|
-
}, "");
|
80
|
-
if (!p) return n.join(`
|
81
|
-
`);
|
82
|
-
if (!e) return p;
|
83
|
-
let m = "";
|
84
|
-
return m = `${e} { ${p} }`, [m, ...n].join(`
|
85
|
-
`);
|
86
|
-
}, q = (t, e = []) => {
|
87
|
-
if (!t) return "";
|
88
|
-
const s = [], o = {};
|
89
|
-
if (Object.entries(t).forEach(([n, p]) => {
|
90
|
-
if (typeof p == "object") {
|
91
|
-
if (!p) return;
|
92
|
-
const m = n.trim(), a = q(p, [...e, m]);
|
93
|
-
s.push(a);
|
94
|
-
} else
|
95
|
-
o[n] = p;
|
96
|
-
}), Object.keys(o).length) {
|
97
|
-
const n = e.map(T).join("-"), p = M(o, `.${n}`);
|
98
|
-
s.push(p);
|
99
|
-
}
|
100
|
-
return s.join(`
|
101
|
-
`);
|
102
|
-
}, U = (t) => {
|
103
|
-
if (!t || t === "/") throw new Error("Could not find package.json file");
|
104
|
-
const e = f(t, "package.json");
|
105
|
-
return K(e) ? e : U(f(t, ".."));
|
106
|
-
}, ut = async (t) => {
|
107
|
-
const e = U(t);
|
108
|
-
return await rt(e, "utf-8").then(JSON.parse).catch(() => {
|
109
|
-
});
|
110
|
-
}, gt = async (t) => {
|
111
|
-
const e = await ut(t);
|
112
|
-
if (e)
|
113
|
-
return e.type;
|
114
|
-
};
|
115
|
-
let N;
|
116
|
-
const X = async (t) => {
|
117
|
-
if (N) return N;
|
118
|
-
const e = await gt(t);
|
119
|
-
return e === "module" ? N = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (N = "cjs"), N || "esm";
|
120
|
-
}, G = it({
|
121
|
-
level: "debug",
|
122
|
-
format: A.combine(A.colorize(), A.cli()),
|
123
|
-
transports: [new at.Console({})]
|
124
|
-
}), _ = {
|
125
|
-
externalModules: []
|
126
|
-
}, Y = (t) => {
|
127
|
-
if (_.externalModules.length > 0) return _.externalModules;
|
128
|
-
const e = f(t, "salty.config.ts"), o = O(e, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
129
|
-
if (!o) return [];
|
130
|
-
const n = o[1].split(",").map((p) => p.replace(/['"`]/g, "").trim());
|
131
|
-
return _.externalModules = n, n;
|
132
|
-
}, V = (t) => f(t, "./saltygen"), dt = ["salty", "css", "styles", "styled"], yt = (t = []) => new RegExp(`\\.(${[...dt, ...t].join("|")})\\.`), W = (t, e = []) => yt(e).test(t), mt = async (t) => {
|
133
|
-
const e = V(t), s = f(t, "salty.config.ts"), o = f(e, "salty.config.js"), n = await X(t), p = Y(t);
|
134
|
-
await H.build({
|
135
|
-
entryPoints: [s],
|
136
|
-
minify: !0,
|
137
|
-
treeShaking: !0,
|
138
|
-
bundle: !0,
|
139
|
-
outfile: o,
|
140
|
-
format: n,
|
141
|
-
external: p
|
142
|
-
});
|
143
|
-
const m = Date.now(), { config: a } = await import(`${o}?t=${m}`);
|
144
|
-
return a;
|
145
|
-
}, ht = async (t) => {
|
146
|
-
const e = await mt(t), s = /* @__PURE__ */ new Set(), o = (g, c = []) => g ? Object.entries(g).flatMap(([h, y]) => {
|
147
|
-
if (!y) return;
|
148
|
-
if (typeof y == "object") return o(y, [...c, h]);
|
149
|
-
const x = [...c, h].join(".");
|
150
|
-
s.add(`"${x}"`);
|
151
|
-
const w = [...c.map(T), T(h)].join("-"), { result: $ } = L(y);
|
152
|
-
return `--${w}: ${$};`;
|
153
|
-
}) : [], n = (g) => g ? Object.entries(g).flatMap(([c, h]) => {
|
154
|
-
const y = o(h);
|
155
|
-
return c === "base" ? y.join("") : `${c} { ${y.join("")} }`;
|
156
|
-
}) : [], p = (g) => g ? Object.entries(g).flatMap(([c, h]) => Object.entries(h).flatMap(([y, x]) => {
|
157
|
-
const w = o(x, [c]), $ = `.${c}-${y}, [data-${c}="${y}"]`, S = w.join("");
|
158
|
-
return `${$} { ${S} }`;
|
159
|
-
})) : [], m = o(e.variables), a = n(e.responsiveVariables), i = p(e.conditionalVariables), r = V(t), u = f(r, "css/variables.css"), P = `:root { ${m.join("")} ${a.join("")} } ${i.join("")}`;
|
160
|
-
E(u, P);
|
161
|
-
const b = f(r, "types/css-tokens.d.ts"), l = `type VariableTokens = ${[...s].join("|") || '""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
162
|
-
E(b, l);
|
163
|
-
const j = f(r, "css/global.css"), k = M(e.global, "");
|
164
|
-
E(j, k);
|
165
|
-
const d = f(r, "css/templates.css"), F = q(e.templates);
|
166
|
-
E(d, F);
|
167
|
-
}, B = async (t, e, s) => {
|
168
|
-
const o = R(e), n = f(s, "js", o + ".js"), p = await X(t), m = Y(t);
|
169
|
-
await H.build({
|
170
|
-
entryPoints: [e],
|
171
|
-
minify: !0,
|
172
|
-
treeShaking: !0,
|
173
|
-
bundle: !0,
|
174
|
-
outfile: n,
|
175
|
-
format: p,
|
176
|
-
target: ["es2022"],
|
177
|
-
keepNames: !0,
|
178
|
-
external: m
|
179
|
-
});
|
180
|
-
const a = Date.now();
|
181
|
-
return await import(`${n}?t=${a}`);
|
182
|
-
}, I = async (t) => {
|
183
|
-
const e = V(t), s = f(e, "salty.config.js"), { config: o } = await import(s);
|
184
|
-
return o;
|
185
|
-
}, $t = () => {
|
186
|
-
try {
|
187
|
-
return process.env.NODE_ENV === "production";
|
188
|
-
} catch {
|
189
|
-
return !1;
|
190
|
-
}
|
191
|
-
}, Ft = async (t, e = $t()) => {
|
192
|
-
try {
|
193
|
-
e ? G.info("Generating CSS in production mode! 🔥") : G.info("Generating CSS in development mode! 🚀");
|
194
|
-
const s = [], o = [], n = V(t), p = f(n, "index.css");
|
195
|
-
(() => {
|
196
|
-
K(n) && st("rm -rf " + n), J(n), J(f(n, "css")), J(f(n, "types"));
|
197
|
-
})(), await ht(t);
|
198
|
-
const a = await I(t);
|
199
|
-
async function i(l, j) {
|
200
|
-
const k = ["node_modules", "saltygen"], d = nt(l);
|
201
|
-
if (d.isDirectory()) {
|
202
|
-
const F = ot(l);
|
203
|
-
if (k.some((c) => l.includes(c))) return;
|
204
|
-
await Promise.all(F.map((c) => i(f(l, c), f(j, c))));
|
205
|
-
} else if (d.isFile() && W(l)) {
|
206
|
-
const g = await B(t, l, n), c = [];
|
207
|
-
Object.entries(g).forEach(([w, $]) => {
|
208
|
-
if ($.isKeyframes && $.css) {
|
209
|
-
const Z = `${$.animationName}.css`, tt = `css/${Z}`, et = f(n, tt);
|
210
|
-
s.push(Z), E(et, $.css);
|
211
|
-
return;
|
212
|
-
}
|
213
|
-
if (!$.generator) return;
|
214
|
-
const S = $.generator._withBuildContext({
|
215
|
-
name: w,
|
216
|
-
config: a
|
217
|
-
}), D = `${S.hash}-${S.priority}.css`;
|
218
|
-
o[S.priority] || (o[S.priority] = []), o[S.priority].push(D), c.push(D);
|
219
|
-
const Q = `css/${D}`, v = f(n, Q);
|
220
|
-
E(v, S.css);
|
221
|
-
});
|
222
|
-
const h = c.map((w) => `@import url('./${w}');`).join(`
|
223
|
-
`), y = R(l, 6), x = f(n, `css/${y}.css`);
|
224
|
-
E(x, h);
|
225
|
-
}
|
226
|
-
}
|
227
|
-
await i(t, n);
|
228
|
-
const r = s.map((l) => `@import url('./css/${l}');`).join(`
|
229
|
-
`);
|
230
|
-
let C = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
231
|
-
|
232
|
-
${["variables.css", "global.css", "templates.css"].filter((l) => {
|
233
|
-
try {
|
234
|
-
return O(f(n, "css", l), "utf8").length > 0;
|
235
|
-
} catch {
|
236
|
-
return !1;
|
237
|
-
}
|
238
|
-
}).map((l) => `@import url('./css/${l}');`).join(`
|
239
|
-
`)}
|
240
|
-
${r}`;
|
241
|
-
if (a.importStrategy !== "component") {
|
242
|
-
const l = o.flat().map((j) => `@import url('./css/${j}');`).join(`
|
243
|
-
`);
|
244
|
-
C += l;
|
245
|
-
}
|
246
|
-
E(p, C);
|
247
|
-
} catch (s) {
|
248
|
-
console.error(s);
|
249
|
-
}
|
250
|
-
}, kt = async (t, e) => {
|
251
|
-
try {
|
252
|
-
const s = [], o = f(t, "./saltygen"), n = f(o, "index.css");
|
253
|
-
if (W(e)) {
|
254
|
-
const m = await I(t), a = await B(t, e, o);
|
255
|
-
Object.entries(a).forEach(([b, C]) => {
|
256
|
-
if (!C.generator) return;
|
257
|
-
const l = C.generator._withBuildContext({
|
258
|
-
name: b,
|
259
|
-
config: m
|
260
|
-
}), j = `${l.hash}-${l.priority}.css`, k = `css/${j}`, d = f(o, k);
|
261
|
-
s.push(j), E(d, l.css);
|
262
|
-
});
|
263
|
-
const i = O(n, "utf8").split(`
|
264
|
-
`), r = s.map((b) => `@import url('../saltygen/css/${b}');`), P = [.../* @__PURE__ */ new Set([...i, ...r])].join(`
|
265
|
-
`);
|
266
|
-
E(n, P);
|
267
|
-
}
|
268
|
-
} catch (s) {
|
269
|
-
console.error(s);
|
270
|
-
}
|
271
|
-
}, xt = async (t, e) => {
|
272
|
-
try {
|
273
|
-
const s = f(t, "./saltygen");
|
274
|
-
if (W(e)) {
|
275
|
-
const n = O(e, "utf8");
|
276
|
-
n.replace(/^(?!export\s)const\s.*/gm, (u) => `export ${u}`) !== n && await ct(e, n);
|
277
|
-
const m = await I(t), a = await B(t, e, s);
|
278
|
-
let i = n;
|
279
|
-
Object.entries(a).forEach(([u, P]) => {
|
280
|
-
var S;
|
281
|
-
if (P.isKeyframes || !P.generator) return;
|
282
|
-
const b = P.generator._withBuildContext({
|
283
|
-
name: u,
|
284
|
-
config: m
|
285
|
-
}), C = new RegExp(`\\s${u}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(n);
|
286
|
-
if (!C) return console.error("Could not find the original declaration");
|
287
|
-
const l = (S = C.at(1)) == null ? void 0 : S.trim(), j = new RegExp(`\\s${u}[=\\s]+styled\\(`, "g").exec(i);
|
288
|
-
if (!j) return console.error("Could not find the original declaration");
|
289
|
-
const { index: k } = j;
|
290
|
-
let d = !1;
|
291
|
-
const F = setTimeout(() => d = !0, 5e3);
|
292
|
-
let g = 0, c = !1, h = 0;
|
293
|
-
for (; !c && !d; ) {
|
294
|
-
const D = i[k + g];
|
295
|
-
D === "(" && h++, D === ")" && h--, h === 0 && D === ")" && (c = !0), g > i.length && (d = !0), g++;
|
296
|
-
}
|
297
|
-
if (!d) clearTimeout(F);
|
298
|
-
else throw new Error("Failed to find the end of the styled call and timed out");
|
299
|
-
const y = k + g, x = i.slice(k, y), w = i, $ = ` ${u} = styled(${l}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;
|
300
|
-
i = i.replace(x, $), w === i && console.error("Minimize file failed to change content", { name: u, tagName: l });
|
301
|
-
});
|
302
|
-
const r = R(e, 6);
|
303
|
-
return m.importStrategy === "component" && (i = `import '../../saltygen/css/${r}.css';
|
304
|
-
${i}`), i = i.replace("{ styled }", "{ styledClient as styled }"), i = i.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), i;
|
305
|
-
}
|
306
|
-
} catch (s) {
|
307
|
-
console.error("Error in minimizeFile:", s);
|
308
|
-
}
|
309
|
-
};
|
310
|
-
export {
|
311
|
-
kt as a,
|
312
|
-
Ft as g,
|
313
|
-
xt as m,
|
314
|
-
yt as s
|
315
|
-
};
|
package/index-CZ6C_--G.cjs
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";const st=require("esbuild"),nt=require("child_process"),f=require("path"),g=require("fs"),Z=require("fs/promises"),M=require("winston");var _=typeof document<"u"?document.currentScript:null;function ot(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const L=ot(st),W=t=>String.fromCharCode(t+(t>25?39:97)),rt=(t,e)=>{let s="",o;for(o=Math.abs(t);o>52;o=o/52|0)s=W(o%52)+s;return s=W(o%52)+s,s.length<e?s=s.padStart(e,"a"):s.length>e&&(s=s.slice(-e)),s},it=(t,e)=>{let s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return t},R=(t,e=3)=>{const s=it(5381,JSON.stringify(t))>>>0;return rt(s,e)};function N(t){return t?typeof t!="string"?N(String(t)):t.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(e,s)=>(s>0?"-":"")+e.toLowerCase()):""}const ct=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const s=[];return Object.values(e).forEach(o=>{const{pattern:n,transform:u}=o;t=t.replace(n,h=>{const{value:a,css:c}=u(h);return c&&s.push(c),a})}),{result:t,additionalCss:s}},U=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...o)=>`var(--${N(o[1].replaceAll(".","-"))})`)}:{result:t},D=(t,e,s,o)=>{if(!t)return"";const n=[],u=Object.entries(t).reduce((a,[c,r])=>{const p=c.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return a;if(p==="variants")return Object.entries(r).forEach(([d,i])=>{i&&Object.entries(i).forEach(([j,m])=>{if(!m)return;const P=`${e}.${d}-${j}`,w=D(m,P);n.push(w)})}),a;if(p==="defaultVariants")return a;if(p==="compoundVariants")return r.forEach(d=>{const{css:i,...j}=d,m=Object.entries(j).reduce((w,[$,F])=>`${w}.${$}-${F}`,e),P=D(i,m);n.push(P)}),a;if(p.startsWith("@")){const d=D(r,e),i=`${p} {
|
2
|
-
${d.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return n.push(i),a}const y=c.includes("&")?p.replace("&",e):p.startsWith(":")?`${e}${p}`:`${e} ${p}`,k=D(r,y);return n.push(k),a}const O=p.startsWith("-")?p:N(p),b=(y,k=";")=>a=`${a}${y}${k}`,C=y=>b(`${O}:${y}`);if(typeof r=="number")return C(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return a;const{modifiers:l}={},x=function*(){yield U(r),yield ct(r,l)}();for(const{result:y,additionalCss:k=[]}of x)r=y,k.forEach(d=>{const i=D(d,"");b(i,"")});return C(r)},"");if(!u)return n.join(`
|
6
|
-
`);if(!e)return u;let h="";return h=`${e} { ${u} }`,[h,...n].join(`
|
7
|
-
`)},G=(t,e=[])=>{if(!t)return"";const s=[],o={};if(Object.entries(t).forEach(([n,u])=>{if(typeof u=="object"){if(!u)return;const h=n.trim(),a=G(u,[...e,h]);s.push(a)}else o[n]=u}),Object.keys(o).length){const n=e.map(N).join("-"),u=D(o,`.${n}`);s.push(u)}return s.join(`
|
8
|
-
`)},H=t=>{if(!t||t==="/")throw new Error("Could not find package.json file");const e=f.join(t,"package.json");return g.existsSync(e)?e:H(f.join(t,".."))},at=async t=>{const e=H(t);return await Z.readFile(e,"utf-8").then(JSON.parse).catch(()=>{})},lt=async t=>{const e=await at(t);if(e)return e.type};let E;const K=async t=>{if(E)return E;const e=await lt(t);return e==="module"?E="esm":(e==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:_&&_.tagName.toUpperCase()==="SCRIPT"&&_.src||new URL("index-CZ6C_--G.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},B=M.createLogger({level:"debug",format:M.format.combine(M.format.colorize(),M.format.cli()),transports:[new M.transports.Console({})]}),J={externalModules:[]},X=t=>{if(J.externalModules.length>0)return J.externalModules;const e=f.join(t,"salty.config.ts"),o=g.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const n=o[1].split(",").map(u=>u.replace(/['"`]/g,"").trim());return J.externalModules=n,n},V=t=>f.join(t,"./saltygen"),ft=["salty","css","styles","styled"],Y=(t=[])=>new RegExp(`\\.(${[...ft,...t].join("|")})\\.`),A=(t,e=[])=>Y(e).test(t),ut=async t=>{const e=V(t),s=f.join(t,"salty.config.ts"),o=f.join(e,"salty.config.js"),n=await K(t),u=X(t);await L.build({entryPoints:[s],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:n,external:u});const h=Date.now(),{config:a}=await import(`${o}?t=${h}`);return a},pt=async t=>{const e=await ut(t),s=new Set,o=(d,i=[])=>d?Object.entries(d).flatMap(([j,m])=>{if(!m)return;if(typeof m=="object")return o(m,[...i,j]);const P=[...i,j].join(".");s.add(`"${P}"`);const w=[...i.map(N),N(j)].join("-"),{result:$}=U(m);return`--${w}: ${$};`}):[],n=d=>d?Object.entries(d).flatMap(([i,j])=>{const m=o(j);return i==="base"?m.join(""):`${i} { ${m.join("")} }`}):[],u=d=>d?Object.entries(d).flatMap(([i,j])=>Object.entries(j).flatMap(([m,P])=>{const w=o(P,[i]),$=`.${i}-${m}, [data-${i}="${m}"]`,F=w.join("");return`${$} { ${F} }`})):[],h=o(e.variables),a=n(e.responsiveVariables),c=u(e.conditionalVariables),r=V(t),p=f.join(r,"css/variables.css"),O=`:root { ${h.join("")} ${a.join("")} } ${c.join("")}`;g.writeFileSync(p,O);const b=f.join(r,"types/css-tokens.d.ts"),l=`type VariableTokens = ${[...s].join("|")||'""'}; type PropertyValueToken = \`{\${VariableTokens}}\``;g.writeFileSync(b,l);const S=f.join(r,"css/global.css"),x=D(e.global,"");g.writeFileSync(S,x);const y=f.join(r,"css/templates.css"),k=G(e.templates);g.writeFileSync(y,k)},q=async(t,e,s)=>{const o=R(e),n=f.join(s,"js",o+".js"),u=await K(t),h=X(t);await L.build({entryPoints:[e],minify:!0,treeShaking:!0,bundle:!0,outfile:n,format:u,target:["es2022"],keepNames:!0,external:h});const a=Date.now();return await import(`${n}?t=${a}`)},I=async t=>{const e=V(t),s=f.join(e,"salty.config.js"),{config:o}=await import(s);return o},dt=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},gt=async(t,e=dt())=>{try{e?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const s=[],o=[],n=V(t),u=f.join(n,"index.css");(()=>{g.existsSync(n)&&nt.execSync("rm -rf "+n),g.mkdirSync(n),g.mkdirSync(f.join(n,"css")),g.mkdirSync(f.join(n,"types"))})(),await pt(t);const a=await I(t);async function c(l,S){const x=["node_modules","saltygen"],y=g.statSync(l);if(y.isDirectory()){const k=g.readdirSync(l);if(x.some(i=>l.includes(i)))return;await Promise.all(k.map(i=>c(f.join(l,i),f.join(S,i))))}else if(y.isFile()&&A(l)){const d=await q(t,l,n),i=[];Object.entries(d).forEach(([w,$])=>{if($.isKeyframes&&$.css){const z=`${$.animationName}.css`,tt=`css/${z}`,et=f.join(n,tt);s.push(z),g.writeFileSync(et,$.css);return}if(!$.generator)return;const F=$.generator._withBuildContext({name:w,config:a}),T=`${F.hash}-${F.priority}.css`;o[F.priority]||(o[F.priority]=[]),o[F.priority].push(T),i.push(T);const Q=`css/${T}`,v=f.join(n,Q);g.writeFileSync(v,F.css)});const j=i.map(w=>`@import url('./${w}');`).join(`
|
9
|
-
`),m=R(l,6),P=f.join(n,`css/${m}.css`);g.writeFileSync(P,j)}}await c(t,n);const r=s.map(l=>`@import url('./css/${l}');`).join(`
|
10
|
-
`);let C=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
11
|
-
|
12
|
-
${["variables.css","global.css","templates.css"].filter(l=>{try{return g.readFileSync(f.join(n,"css",l),"utf8").length>0}catch{return!1}}).map(l=>`@import url('./css/${l}');`).join(`
|
13
|
-
`)}
|
14
|
-
${r}`;if(a.importStrategy!=="component"){const l=o.flat().map(S=>`@import url('./css/${S}');`).join(`
|
15
|
-
`);C+=l}g.writeFileSync(u,C)}catch(s){console.error(s)}},yt=async(t,e)=>{try{const s=[],o=f.join(t,"./saltygen"),n=f.join(o,"index.css");if(A(e)){const h=await I(t),a=await q(t,e,o);Object.entries(a).forEach(([b,C])=>{if(!C.generator)return;const l=C.generator._withBuildContext({name:b,config:h}),S=`${l.hash}-${l.priority}.css`,x=`css/${S}`,y=f.join(o,x);s.push(S),g.writeFileSync(y,l.css)});const c=g.readFileSync(n,"utf8").split(`
|
16
|
-
`),r=s.map(b=>`@import url('../saltygen/css/${b}');`),O=[...new Set([...c,...r])].join(`
|
17
|
-
`);g.writeFileSync(n,O)}}catch(s){console.error(s)}},mt=async(t,e)=>{try{const s=f.join(t,"./saltygen");if(A(e)){const n=g.readFileSync(e,"utf8");n.replace(/^(?!export\s)const\s.*/gm,p=>`export ${p}`)!==n&&await Z.writeFile(e,n);const h=await I(t),a=await q(t,e,s);let c=n;Object.entries(a).forEach(([p,O])=>{var F;if(O.isKeyframes||!O.generator)return;const b=O.generator._withBuildContext({name:p,config:h}),C=new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(n);if(!C)return console.error("Could not find the original declaration");const l=(F=C.at(1))==null?void 0:F.trim(),S=new RegExp(`\\s${p}[=\\s]+styled\\(`,"g").exec(c);if(!S)return console.error("Could not find the original declaration");const{index:x}=S;let y=!1;const k=setTimeout(()=>y=!0,5e3);let d=0,i=!1,j=0;for(;!i&&!y;){const T=c[x+d];T==="("&&j++,T===")"&&j--,j===0&&T===")"&&(i=!0),d>c.length&&(y=!0),d++}if(!y)clearTimeout(k);else throw new Error("Failed to find the end of the styled call and timed out");const m=x+d,P=c.slice(x,m),w=c,$=` ${p} = styled(${l}, "${b.classNames}", "${b._callerName}", ${JSON.stringify(b.props)});`;c=c.replace(P,$),w===c&&console.error("Minimize file failed to change content",{name:p,tagName:l})});const r=R(e,6);return h.importStrategy==="component"&&(c=`import '../../saltygen/css/${r}.css';
|
18
|
-
${c}`),c=c.replace("{ styled }","{ styledClient as styled }"),c=c.replace("@salty-css/react/styled","@salty-css/react/styled-client"),c}}catch(s){console.error("Error in minimizeFile:",s)}};exports.generateCss=gt;exports.generateFile=yt;exports.minimizeFile=mt;exports.saltyFileRegExp=Y;
|