@salty-css/core 0.0.1-alpha.217 → 0.0.1-alpha.219
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/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +1 -1
- package/index-CNuRN2e-.cjs +38 -0
- package/index-ClF7lS_W.js +502 -0
- package/package.json +1 -1
- package/parse-styles-3N79AOBO.cjs +5 -0
- package/parse-styles-Bo7fQ_SV.js +134 -0
- package/server/index.cjs +1 -1
- package/server/index.js +1 -1
- package/index-B6M9WK93.cjs +0 -38
- package/index-B_bv7TCc.js +0 -503
- package/parse-styles-C6OYNcYI.cjs +0 -5
- package/parse-styles-Cc_Ir3PV.js +0 -132
@@ -0,0 +1,502 @@
|
|
1
|
+
import * as gt from "esbuild";
|
2
|
+
import { execSync as Nt } from "child_process";
|
3
|
+
import { d as B, t as M } from "./dash-case-DBThphLm.js";
|
4
|
+
import { join as c, parse as tt } from "path";
|
5
|
+
import { existsSync as it, writeFileSync as F, mkdirSync as W, readFileSync as v, statSync as kt, readdirSync as Dt } from "fs";
|
6
|
+
import { readFile as yt, writeFile as _t } from "fs/promises";
|
7
|
+
import { p as at, a as Tt } from "./parse-styles-Bo7fQ_SV.js";
|
8
|
+
import { createLogger as Et, format as ot, transports as vt } from "winston";
|
9
|
+
import { mergeObjects as I, mergeFactories as Ot } from "./css/merge.js";
|
10
|
+
import { d as Vt } from "./define-templates-4A2yHcMF.js";
|
11
|
+
const ht = async (t, e = []) => {
|
12
|
+
if (!t) return "";
|
13
|
+
const s = [], n = {};
|
14
|
+
for (const [a, o] of Object.entries(t))
|
15
|
+
if (typeof o != "function") if (o && typeof o == "object") {
|
16
|
+
const i = a.trim(), h = await ht(o, [...e, i]);
|
17
|
+
s.push(h);
|
18
|
+
} else
|
19
|
+
n[a] = o;
|
20
|
+
if (Object.keys(n).length) {
|
21
|
+
const a = e.map(B).join("-"), o = "t_" + M(a, 4), i = await at(n, `.${a}, .${o}`);
|
22
|
+
s.push(i);
|
23
|
+
}
|
24
|
+
return s.join(`
|
25
|
+
`);
|
26
|
+
}, Mt = (t) => t ? Object.entries(t).reduce((e, [s, n]) => (typeof n == "function" ? e[s] = "any" : typeof n == "object" && (e[s] = $t(n).map((a) => `"${a}"`).join(" | ")), e), {}) : {}, $t = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, a]) => {
|
27
|
+
const o = e ? `${e}.${n}` : n;
|
28
|
+
return typeof a == "object" ? $t(a, o, s) : s.add(e);
|
29
|
+
}), [...s]) : [], bt = (t) => {
|
30
|
+
if (!t || t === "/") throw new Error("Could not find package.json file");
|
31
|
+
const e = c(t, "package.json");
|
32
|
+
return it(e) ? e : bt(c(t, ".."));
|
33
|
+
}, Rt = async (t) => {
|
34
|
+
const e = bt(t);
|
35
|
+
return await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
36
|
+
});
|
37
|
+
}, Jt = async (t) => {
|
38
|
+
const e = await Rt(t);
|
39
|
+
if (e)
|
40
|
+
return e.type;
|
41
|
+
};
|
42
|
+
let z;
|
43
|
+
const wt = async (t) => {
|
44
|
+
if (z) return z;
|
45
|
+
const e = await Jt(t);
|
46
|
+
return e === "module" ? z = "esm" : (e === "commonjs" || import.meta.url.endsWith(".cjs")) && (z = "cjs"), z || "esm";
|
47
|
+
}, Y = Et({
|
48
|
+
level: "debug",
|
49
|
+
format: ot.combine(ot.colorize(), ot.cli()),
|
50
|
+
transports: [new vt.Console({})]
|
51
|
+
}), ee = (t) => {
|
52
|
+
Y.error(t);
|
53
|
+
};
|
54
|
+
function St(t) {
|
55
|
+
return t ? typeof t != "string" ? St(String(t)) : t.replace(/[\s-]/g, ".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (e, s) => (s > 0 ? "." : "") + e.toLowerCase()) : "";
|
56
|
+
}
|
57
|
+
const zt = {
|
58
|
+
/** Set box model to border-box */
|
59
|
+
"*, *::before, *::after": {
|
60
|
+
boxSizing: "border-box"
|
61
|
+
},
|
62
|
+
/** Remove default margin and padding */
|
63
|
+
"*": {
|
64
|
+
margin: 0
|
65
|
+
},
|
66
|
+
/** Remove adjust font properties */
|
67
|
+
html: {
|
68
|
+
lineHeight: 1.15,
|
69
|
+
textSizeAdjust: "100%",
|
70
|
+
WebkitFontSmoothing: "antialiased"
|
71
|
+
},
|
72
|
+
/** Make media elements responsive */
|
73
|
+
"img, picture, video, canvas, svg": {
|
74
|
+
display: "block",
|
75
|
+
maxWidth: "100%"
|
76
|
+
},
|
77
|
+
/** Avoid overflow of text */
|
78
|
+
"p, h1, h2, h3, h4, h5, h6": {
|
79
|
+
overflowWrap: "break-word"
|
80
|
+
},
|
81
|
+
/** Improve text wrapping */
|
82
|
+
p: {
|
83
|
+
textWrap: "pretty"
|
84
|
+
},
|
85
|
+
"h1, h2, h3, h4, h5, h6": {
|
86
|
+
textWrap: "balance"
|
87
|
+
},
|
88
|
+
/** Improve link color */
|
89
|
+
a: {
|
90
|
+
color: "currentColor"
|
91
|
+
},
|
92
|
+
/** Improve button line height */
|
93
|
+
button: {
|
94
|
+
lineHeight: "1em",
|
95
|
+
color: "currentColor"
|
96
|
+
},
|
97
|
+
/** Improve form elements */
|
98
|
+
"input, optgroup, select, textarea": {
|
99
|
+
fontFamily: "inherit",
|
100
|
+
fontSize: "100%",
|
101
|
+
lineHeight: "1.15em"
|
102
|
+
}
|
103
|
+
}, V = {
|
104
|
+
externalModules: [],
|
105
|
+
rcFile: void 0,
|
106
|
+
destDir: void 0
|
107
|
+
}, Ct = (t) => {
|
108
|
+
if (V.externalModules.length > 0) return V.externalModules;
|
109
|
+
const s = v(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
|
110
|
+
if (!s) return [];
|
111
|
+
const n = s[1].split(",").map((a) => a.replace(/['"`]/g, "").trim());
|
112
|
+
return V.externalModules = n, n;
|
113
|
+
}, R = async (t) => {
|
114
|
+
if (V.destDir) return V.destDir;
|
115
|
+
const e = await ct(t), s = c(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
|
116
|
+
return V.destDir = s, s;
|
117
|
+
}, jt = ["salty", "css", "styles", "styled"], Wt = (t = []) => new RegExp(`\\.(${[...jt, ...t].join("|")})\\.`), rt = (t, e = []) => Wt(e).test(t), Ft = async (t) => {
|
118
|
+
if (V.rcFile) return V.rcFile;
|
119
|
+
if (t === "/") throw new Error("Could not find .saltyrc.json file");
|
120
|
+
const e = c(t, ".saltyrc.json"), s = await yt(e, "utf-8").then(JSON.parse).catch(() => {
|
121
|
+
});
|
122
|
+
return s ? (V.rcFile = s, s) : Ft(c(t, ".."));
|
123
|
+
}, ct = async (t) => {
|
124
|
+
var n, a;
|
125
|
+
const e = await Ft(t), s = (n = e.projects) == null ? void 0 : n.find((o) => t.endsWith(o.dir || ""));
|
126
|
+
return s || ((a = e.projects) == null ? void 0 : a.find((o) => o.dir === e.defaultProject));
|
127
|
+
}, It = async (t) => {
|
128
|
+
const e = await ct(t), s = await R(t), n = c(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), a = c(s, "salty.config.js"), o = await wt(t), i = Ct(n);
|
129
|
+
await gt.build({
|
130
|
+
entryPoints: [n],
|
131
|
+
minify: !0,
|
132
|
+
treeShaking: !0,
|
133
|
+
bundle: !0,
|
134
|
+
outfile: a,
|
135
|
+
format: o,
|
136
|
+
external: i
|
137
|
+
});
|
138
|
+
const h = Date.now(), { config: $ } = await import(`${a}?t=${h}`);
|
139
|
+
return { config: $, path: a };
|
140
|
+
}, Bt = async (t, e) => {
|
141
|
+
var pt, ut;
|
142
|
+
const s = await R(t), n = {
|
143
|
+
mediaQueries: [],
|
144
|
+
globalStyles: [],
|
145
|
+
variables: [],
|
146
|
+
templates: []
|
147
|
+
};
|
148
|
+
await Promise.all(
|
149
|
+
[...e].map(async (g) => {
|
150
|
+
const { contents: w, outputFilePath: O } = await et(t, g, s);
|
151
|
+
Object.entries(w).forEach(([x, _]) => {
|
152
|
+
_.isMedia ? n.mediaQueries.push([x, _]) : _.isGlobalDefine ? n.globalStyles.push(_) : _.isDefineVariables ? n.variables.push(_) : _.isDefineTemplates && n.templates.push(_._setPath(`${x};;${O}`));
|
153
|
+
});
|
154
|
+
})
|
155
|
+
);
|
156
|
+
const { config: a, path: o } = await It(t), i = { ...a }, h = /* @__PURE__ */ new Set(), $ = (g, w = []) => g ? Object.entries(g).flatMap(([O, x]) => {
|
157
|
+
if (!x) return;
|
158
|
+
if (typeof x == "object") return $(x, [...w, O]);
|
159
|
+
const _ = St(O), st = B(O), nt = [...w, _].join(".");
|
160
|
+
h.add(`"${nt}"`);
|
161
|
+
const X = [...w.map(B), st].join("-"), dt = Tt(x);
|
162
|
+
return dt ? `--${X}: ${dt.transformed};` : `--${X}: ${x};`;
|
163
|
+
}) : [], l = (g) => g ? Object.entries(g).flatMap(([w, O]) => {
|
164
|
+
const x = $(O);
|
165
|
+
return w === "base" ? x.join("") : `${w} { ${x.join("")} }`;
|
166
|
+
}) : [], p = (g) => g ? Object.entries(g).flatMap(([w, O]) => Object.entries(O).flatMap(([x, _]) => {
|
167
|
+
const st = $(_, [w]), nt = `.${w}-${x}, [data-${w}="${x}"]`, X = st.join("");
|
168
|
+
return `${nt} { ${X} }`;
|
169
|
+
})) : [], b = (g) => ({ ...g, responsive: void 0, conditional: void 0 }), u = (g) => n.variables.map((w) => g === "static" ? b(w._current) : w._current[g]), y = I(b(a.variables), u("static")), d = $(y), j = I((pt = a.variables) == null ? void 0 : pt.responsive, u("responsive")), N = l(j), k = I((ut = a.variables) == null ? void 0 : ut.conditional, u("conditional")), J = p(k), T = c(s, "css/_variables.css"), G = `:root { ${d.join("")} ${N.join("")} } ${J.join("")}`;
|
170
|
+
F(T, G), i.staticVariables = y;
|
171
|
+
const D = c(s, "css/_global.css"), H = I(a.global, n.globalStyles), f = await at(H, "");
|
172
|
+
F(D, `@layer global { ${f} }`);
|
173
|
+
const m = c(s, "css/_reset.css"), r = a.reset === "none" ? {} : typeof a.reset == "object" ? a.reset : zt, C = await at(r, "");
|
174
|
+
F(m, `@layer reset { ${C} }`);
|
175
|
+
const P = c(s, "css/_templates.css"), E = I(a.templates, n.templates), K = await ht(E), A = Mt(E);
|
176
|
+
F(P, `@layer templates { ${K} }`), i.templates = E;
|
177
|
+
const L = a.templates ? [Vt(a.templates)._setPath(`config;;${o}`)] : [], Z = Ot(n.templates, L);
|
178
|
+
i.templatePaths = Object.fromEntries(Object.entries(Z).map(([g, w]) => [g, w._path]));
|
179
|
+
const { mediaQueries: q } = n;
|
180
|
+
i.mediaQueries = Object.fromEntries(q.map(([g, w]) => [`@${g}`, w]));
|
181
|
+
const Q = q.map(([g]) => `'@${g}'`).join(" | "), U = c(s, "types/css-tokens.d.ts"), Pt = `
|
182
|
+
// Variable types
|
183
|
+
type VariableTokens = ${[...h].join("|")};
|
184
|
+
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
185
|
+
|
186
|
+
// Template types
|
187
|
+
type TemplateTokens = {
|
188
|
+
${Object.entries(A).map(([g, w]) => `${g}?: ${w}`).join(`
|
189
|
+
`)}
|
190
|
+
}
|
191
|
+
|
192
|
+
// Media query types
|
193
|
+
type MediaQueryKeys = ${Q || "''"};
|
194
|
+
`;
|
195
|
+
F(U, Pt);
|
196
|
+
const xt = c(s, "cache/config-cache.json");
|
197
|
+
F(xt, JSON.stringify(i, null, 2));
|
198
|
+
}, mt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
|
199
|
+
if (/^['"`]/.test(s)) return e;
|
200
|
+
const a = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
|
201
|
+
if (!a.test(t)) return e;
|
202
|
+
const i = a.exec(t);
|
203
|
+
if (i) {
|
204
|
+
const h = i.at(1);
|
205
|
+
if (jt.some((l) => h == null ? void 0 : h.includes(l))) return e;
|
206
|
+
}
|
207
|
+
return "styled('div',";
|
208
|
+
}), Gt = (t, e) => {
|
209
|
+
try {
|
210
|
+
const s = v(c(e, "saltygen/cache/config-cache.json"), "utf8");
|
211
|
+
return s ? `globalThis.saltyConfig = ${s};
|
212
|
+
|
213
|
+
${t}` : `globalThis.saltyConfig = {};
|
214
|
+
|
215
|
+
${t}`;
|
216
|
+
} catch {
|
217
|
+
return t;
|
218
|
+
}
|
219
|
+
}, et = async (t, e, s) => {
|
220
|
+
const n = M(e), a = c(s, "./temp");
|
221
|
+
it(a) || W(a);
|
222
|
+
const o = tt(e);
|
223
|
+
let i = v(e, "utf8");
|
224
|
+
i = mt(i), i = Gt(i, t);
|
225
|
+
const h = c(s, "js", n + ".js"), $ = await ct(t), l = c(t, ($ == null ? void 0 : $.configDir) || "", "salty.config.ts"), p = Ct(l), b = await wt(t);
|
226
|
+
await gt.build({
|
227
|
+
stdin: {
|
228
|
+
contents: i,
|
229
|
+
sourcefile: o.base,
|
230
|
+
resolveDir: o.dir,
|
231
|
+
loader: "tsx"
|
232
|
+
},
|
233
|
+
minify: !1,
|
234
|
+
treeShaking: !0,
|
235
|
+
bundle: !0,
|
236
|
+
outfile: h,
|
237
|
+
format: b,
|
238
|
+
target: ["node20"],
|
239
|
+
keepNames: !0,
|
240
|
+
external: p,
|
241
|
+
packages: "external",
|
242
|
+
plugins: [
|
243
|
+
{
|
244
|
+
name: "test",
|
245
|
+
setup: (d) => {
|
246
|
+
d.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (j) => {
|
247
|
+
const N = v(j.path, "utf8");
|
248
|
+
return { contents: mt(N), loader: "ts" };
|
249
|
+
});
|
250
|
+
}
|
251
|
+
}
|
252
|
+
]
|
253
|
+
});
|
254
|
+
const u = Date.now();
|
255
|
+
return { contents: await import(`${h}?t=${u}`), outputFilePath: h };
|
256
|
+
}, Ht = async (t) => {
|
257
|
+
const e = await R(t), s = c(e, "cache/config-cache.json"), n = v(s, "utf8");
|
258
|
+
if (!n) throw new Error("Could not find config cache file");
|
259
|
+
return JSON.parse(n);
|
260
|
+
}, lt = async (t) => {
|
261
|
+
const e = await Ht(t), s = await R(t), n = c(s, "salty.config.js"), a = Date.now(), { config: o } = await import(`${n}?t=${a}`);
|
262
|
+
return I(o, e);
|
263
|
+
}, ft = () => {
|
264
|
+
try {
|
265
|
+
return process.env.NODE_ENV === "production";
|
266
|
+
} catch {
|
267
|
+
return !1;
|
268
|
+
}
|
269
|
+
}, se = async (t, e = ft(), s = !0) => {
|
270
|
+
try {
|
271
|
+
const n = Date.now();
|
272
|
+
e ? Y.info("Generating CSS in production mode! 🔥") : Y.info("Generating CSS in development mode! 🚀");
|
273
|
+
const a = [], o = [], i = await R(t), h = c(i, "index.css");
|
274
|
+
s && (() => {
|
275
|
+
it(i) && Nt("rm -rf " + i), W(i, { recursive: !0 }), W(c(i, "css")), W(c(i, "types")), W(c(i, "js")), W(c(i, "cache"));
|
276
|
+
})();
|
277
|
+
const l = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
|
278
|
+
async function b(f) {
|
279
|
+
const m = ["node_modules", "saltygen"], S = kt(f);
|
280
|
+
if (S.isDirectory()) {
|
281
|
+
const r = Dt(f);
|
282
|
+
if (m.some((P) => f.includes(P))) return;
|
283
|
+
await Promise.all(r.map((P) => b(c(f, P))));
|
284
|
+
} else if (S.isFile() && rt(f)) {
|
285
|
+
l.add(f);
|
286
|
+
const C = v(f, "utf8");
|
287
|
+
/define[\w\d]+\(/.test(C) && p.add(f);
|
288
|
+
}
|
289
|
+
}
|
290
|
+
await b(t), await Bt(t, p);
|
291
|
+
const u = {
|
292
|
+
keyframes: [],
|
293
|
+
components: [],
|
294
|
+
classNames: []
|
295
|
+
};
|
296
|
+
await Promise.all(
|
297
|
+
[...l].map(async (f) => {
|
298
|
+
const { contents: m } = await et(t, f, i);
|
299
|
+
for (let [S, r] of Object.entries(m))
|
300
|
+
r instanceof Promise && (r = await r), r.isKeyframes ? u.keyframes.push({
|
301
|
+
value: r,
|
302
|
+
src: f,
|
303
|
+
name: S
|
304
|
+
}) : r.isClassName ? u.classNames.push({
|
305
|
+
...r,
|
306
|
+
src: f,
|
307
|
+
name: S
|
308
|
+
}) : r.generator && u.components.push({
|
309
|
+
...r,
|
310
|
+
src: f,
|
311
|
+
name: S
|
312
|
+
});
|
313
|
+
})
|
314
|
+
);
|
315
|
+
const y = await lt(t);
|
316
|
+
for (const f of u.keyframes) {
|
317
|
+
const { value: m } = f, S = `a_${m.animationName}.css`, r = `css/${S}`, C = c(i, r);
|
318
|
+
a.push(S), F(C, m.css);
|
319
|
+
}
|
320
|
+
const d = {};
|
321
|
+
for (const f of u.components) {
|
322
|
+
const { src: m, name: S } = f;
|
323
|
+
d[m] || (d[m] = []);
|
324
|
+
const r = f.generator._withBuildContext({
|
325
|
+
callerName: S,
|
326
|
+
isProduction: e,
|
327
|
+
config: y
|
328
|
+
});
|
329
|
+
o[r.priority] || (o[r.priority] = []);
|
330
|
+
const C = await r.css;
|
331
|
+
if (!C) continue;
|
332
|
+
o[r.priority].push(r.cssFileName);
|
333
|
+
const P = `css/${r.cssFileName}`, E = c(i, P);
|
334
|
+
F(E, C), y.importStrategy === "component" && d[m].push(r.cssFileName);
|
335
|
+
}
|
336
|
+
for (const f of u.classNames) {
|
337
|
+
const { src: m, name: S } = f;
|
338
|
+
d[m] || (d[m] = []);
|
339
|
+
const r = f.generator._withBuildContext({
|
340
|
+
callerName: S,
|
341
|
+
isProduction: e,
|
342
|
+
config: y
|
343
|
+
}), C = await r.css;
|
344
|
+
if (!C) continue;
|
345
|
+
o[r.priority] || (o[r.priority] = []), o[r.priority].push(r.cssFileName);
|
346
|
+
const P = `css/${r.cssFileName}`, E = c(i, P);
|
347
|
+
F(E, C), y.importStrategy === "component" && d[m].push(r.cssFileName);
|
348
|
+
}
|
349
|
+
y.importStrategy === "component" && Object.entries(d).forEach(([f, m]) => {
|
350
|
+
const S = m.map((K) => `@import url('./${K}');`).join(`
|
351
|
+
`), r = M(f, 6), C = tt(f), P = B(C.name), E = c(i, `css/f_${P}-${r}.css`);
|
352
|
+
F(E, S || "/* Empty file */");
|
353
|
+
});
|
354
|
+
const j = a.map((f) => `@import url('./css/${f}');`).join(`
|
355
|
+
`);
|
356
|
+
let T = `@layer reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
357
|
+
|
358
|
+
${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
|
359
|
+
try {
|
360
|
+
return v(c(i, "css", f), "utf8").length > 0;
|
361
|
+
} catch {
|
362
|
+
return !1;
|
363
|
+
}
|
364
|
+
}).map((f) => `@import url('./css/${f}');`).join(`
|
365
|
+
`)}
|
366
|
+
${j}`;
|
367
|
+
if (y.importStrategy !== "component") {
|
368
|
+
const f = o.reduce((m, S, r) => {
|
369
|
+
const C = S.reduce((A, L) => {
|
370
|
+
var U;
|
371
|
+
const Z = c(i, "css", L), q = v(Z, "utf8"), Q = ((U = /.*-([^-]+)-\d+.css/.exec(L)) == null ? void 0 : U.at(1)) || M(Z, 6);
|
372
|
+
return A.includes(Q) ? A : `${A}
|
373
|
+
/*start:${Q}-${L}*/
|
374
|
+
${q}
|
375
|
+
/*end:${Q}*/
|
376
|
+
`;
|
377
|
+
}, ""), P = `l_${r}.css`, E = c(i, "css", P), K = `@layer l${r} { ${C}
|
378
|
+
}`;
|
379
|
+
return F(E, K), `${m}
|
380
|
+
@import url('./css/${P}');`;
|
381
|
+
}, "");
|
382
|
+
T += f;
|
383
|
+
}
|
384
|
+
F(h, T);
|
385
|
+
const D = Date.now() - n, H = D < 200 ? "🔥" : D < 500 ? "🚀" : D < 1e3 ? "🎉" : D < 2e3 ? "🚗" : D < 5e3 ? "🤔" : "🥴";
|
386
|
+
Y.info(`Generated CSS in ${D}ms! ${H}`);
|
387
|
+
} catch (n) {
|
388
|
+
console.error(n);
|
389
|
+
}
|
390
|
+
}, ne = async (t, e, s = ft()) => {
|
391
|
+
try {
|
392
|
+
const n = await R(t);
|
393
|
+
if (rt(e)) {
|
394
|
+
const o = [], i = await lt(t), { contents: h } = await et(t, e, n);
|
395
|
+
for (const [$, l] of Object.entries(h)) {
|
396
|
+
if (l.isKeyframes && l.css) {
|
397
|
+
const j = `css/${`a_${l.animationName}.css`}`, N = c(n, j);
|
398
|
+
F(N, await l.css);
|
399
|
+
return;
|
400
|
+
}
|
401
|
+
if (l.isClassName) {
|
402
|
+
const d = l.generator._withBuildContext({
|
403
|
+
callerName: $,
|
404
|
+
isProduction: s,
|
405
|
+
config: i
|
406
|
+
}), j = await d.css;
|
407
|
+
if (!j) continue;
|
408
|
+
o[d.priority] || (o[d.priority] = []), o[d.priority].push(d.cssFileName);
|
409
|
+
const N = `css/${d.cssFileName}`, k = c(n, N);
|
410
|
+
F(k, j);
|
411
|
+
}
|
412
|
+
if (!l.generator) return;
|
413
|
+
const p = l.generator._withBuildContext({
|
414
|
+
callerName: $,
|
415
|
+
isProduction: s,
|
416
|
+
config: i
|
417
|
+
}), b = await p.css;
|
418
|
+
if (!b) continue;
|
419
|
+
const u = `css/${p.cssFileName}`, y = c(n, u);
|
420
|
+
F(y, b), o[p.priority] || (o[p.priority] = []), o[p.priority].push(p.cssFileName);
|
421
|
+
}
|
422
|
+
if (i.importStrategy !== "component")
|
423
|
+
o.forEach(($, l) => {
|
424
|
+
const p = `l_${l}.css`, b = c(n, "css", p);
|
425
|
+
let u = v(b, "utf8");
|
426
|
+
$.forEach((y) => {
|
427
|
+
var k;
|
428
|
+
const d = c(n, "css", y), j = ((k = /.*-([^-]+)-\d+.css/.exec(y)) == null ? void 0 : k.at(1)) || M(d, 6);
|
429
|
+
if (!u.includes(j)) {
|
430
|
+
const J = v(d, "utf8"), T = `/*start:${j}-${y}*/
|
431
|
+
${J}
|
432
|
+
/*end:${j}*/
|
433
|
+
`;
|
434
|
+
u = `${u.replace(/\}$/, "")}
|
435
|
+
${T}
|
436
|
+
}`;
|
437
|
+
}
|
438
|
+
}), F(b, u);
|
439
|
+
});
|
440
|
+
else {
|
441
|
+
const $ = o.flat().map((y) => `@import url('./${y}');`).join(`
|
442
|
+
`), l = M(e, 6), p = tt(e), b = B(p.name), u = c(n, `css/f_${b}-${l}.css`);
|
443
|
+
F(u, $ || "/* Empty file */");
|
444
|
+
}
|
445
|
+
}
|
446
|
+
} catch (n) {
|
447
|
+
console.error(n);
|
448
|
+
}
|
449
|
+
}, oe = async (t, e, s = ft()) => {
|
450
|
+
try {
|
451
|
+
const n = await R(t);
|
452
|
+
if (rt(e)) {
|
453
|
+
const o = v(e, "utf8");
|
454
|
+
o.replace(/^(?!export\s)const\s.*/gm, (p) => `export ${p}`) !== o && await _t(e, o);
|
455
|
+
const h = await lt(t), { contents: $ } = await et(t, e, n);
|
456
|
+
let l = o;
|
457
|
+
if (Object.entries($).forEach(([p, b]) => {
|
458
|
+
var r;
|
459
|
+
if (b.isKeyframes || !b.generator) return;
|
460
|
+
const u = b.generator._withBuildContext({
|
461
|
+
callerName: p,
|
462
|
+
isProduction: s,
|
463
|
+
config: h
|
464
|
+
}), y = new RegExp(`\\s${p}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(o);
|
465
|
+
if (!y) return console.error("Could not find the original declaration");
|
466
|
+
const d = (r = y.at(1)) == null ? void 0 : r.trim(), j = new RegExp(`\\s${p}[=\\s]+styled\\(`, "g").exec(l);
|
467
|
+
if (!j) return console.error("Could not find the original declaration");
|
468
|
+
const { index: N } = j;
|
469
|
+
let k = !1;
|
470
|
+
const J = setTimeout(() => k = !0, 5e3);
|
471
|
+
let T = 0, G = !1, D = 0;
|
472
|
+
for (; !G && !k; ) {
|
473
|
+
const C = l[N + T];
|
474
|
+
C === "(" && D++, C === ")" && D--, D === 0 && C === ")" && (G = !0), T > l.length && (k = !0), T++;
|
475
|
+
}
|
476
|
+
if (!k) clearTimeout(J);
|
477
|
+
else throw new Error("Failed to find the end of the styled call and timed out");
|
478
|
+
const H = N + T, f = l.slice(N, H), m = l, S = ` ${p} = styled(${d}, "${u.classNames}", ${JSON.stringify(u.clientProps)});`;
|
479
|
+
l = l.replace(f, S), m === l && console.error("Minimize file failed to change content", { name: p, tagName: d });
|
480
|
+
}), h.importStrategy === "component") {
|
481
|
+
const p = M(e, 6), b = tt(e);
|
482
|
+
l = `import '../../saltygen/css/${`f_${B(b.name)}-${p}.css`}';
|
483
|
+
${l}`;
|
484
|
+
}
|
485
|
+
return l = l.replace("{ styled }", "{ styledClient as styled }"), l = l.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), l;
|
486
|
+
}
|
487
|
+
} catch (n) {
|
488
|
+
console.error("Error in minimizeFile:", n);
|
489
|
+
}
|
490
|
+
};
|
491
|
+
export {
|
492
|
+
ee as a,
|
493
|
+
Wt as b,
|
494
|
+
Bt as c,
|
495
|
+
et as d,
|
496
|
+
ne as e,
|
497
|
+
se as g,
|
498
|
+
rt as i,
|
499
|
+
Y as l,
|
500
|
+
oe as m,
|
501
|
+
jt as s
|
502
|
+
};
|
package/package.json
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";const V=require("./dash-case-BJEkFEGQ.cjs"),k=a=>e=>{if(typeof e!="string"||!a)return;let t=e;const u=[];return Object.values(a).forEach(n=>{const{pattern:b,transform:y}=n;t=t.replace(b,x=>{const{value:O,css:E}=y(x);return E&&u.push(E),O})}),{transformed:t,additionalCss:u}},z=a=>e=>typeof e!="string"||!/\{[^{}]+\}/g.test(e)?void 0:{transformed:e.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${V.dashCase(n[1].replaceAll(".","-"))})`)},q=z(),J=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],M=(a,e,t)=>{if(J.some(n=>typeof n=="string"?n===a:n.test(a))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${e}${n}`}return`${e}`},Q=["Webkit","Moz","ms","O"],_=a=>a.startsWith("-")?a:Q.some(e=>a.startsWith(e))?`-${V.dashCase(a)}`:V.dashCase(a),$=async(a,e="",t,u=!1)=>{if(!a)throw new Error("No styles provided to parseStyles function!");const n=new Set,b=Object.entries(a),y=async([p,s])=>{var C;const r=p.trim(),w=_(r),l=(i,d=";")=>`${w}:${i}${d}`,P={scope:e,config:t};if(typeof s=="function")return y([p,s(P)]);if(s instanceof Promise)return y([p,await s]);if(t!=null&&t.templates&&t.templatePaths[r])try{const[i,d]=t.templatePaths[r].split(";;"),o=await import(d),c=d.includes("salty.config"),f=c?o[i].templates:o[i],h=c?f[r]:f.params[r];if(f&&typeof h=="function"){const j=await h(s),[m]=await $(j,"");return m}}catch(i){console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`,i);return}if(t!=null&&t.templates&&t.templates[r]){if(u)return;const d=s.split(".").reduce((o,c)=>o[c],t.templates[r]);if(d){const[o]=await $(d,"");return o}console.warn(`Template "${r}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return l(s.toString());if(r==="defaultVariants")return;if(r==="variants"){const o=Object.entries(s);for(const[c,f]of o){if(!f)return;const h=Object.entries(f);for(const[j,m]of h){if(!m)return;const T=`${e}.${c}-${j}`;(await $(m,T,t)).forEach(U=>n.add(U))}}return}if(r==="compoundVariants"){for(const o of s){const{css:c,...f}=o,h=Object.entries(f).reduce((m,[T,N])=>`${m}.${T}-${N}`,e);(await $(c,h,t)).forEach(m=>n.add(m))}return}if(r.startsWith("@")){const o=((C=t==null?void 0:t.mediaQueries)==null?void 0:C[r])||r,c=await A(s,e,t),f=`${o} { ${c} }`;n.add(f);return}const i=p.includes("&")?r.replace("&",e):r.startsWith(":")?`${e}${r}`:`${e} ${r}`;(await $(s,i,t)).forEach(o=>n.add(o));return}if(typeof s=="number"){const i=M(w,s,t);return l(i)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${w}`);return l(s)},x=b.map(y),{modifiers:O}=t||{},E=[z(),k(O)],S=(await Promise.all(x).then(p=>Promise.all(p.map(s=>E.reduce(async(r,w)=>{const l=await r;if(!l)return l;const P=await w(l);if(!P)return l;const{transformed:C,additionalCss:i}=P;let d="";if(i)for(const o of i)d+=await A(o,"");return`${d}${C}`},Promise.resolve(s)))))).filter(p=>p!==void 0).join(`
|
2
|
+
`);if(!S.trim())return Array.from(n);const W=e?`${e} {
|
3
|
+
${S}
|
4
|
+
}`:S;return n.has(W)?Array.from(n):[W,...n]},A=async(a,e,t,u=!1)=>(await $(a,e,t,u)).join(`
|
5
|
+
`);exports.parseAndJoinStyles=A;exports.parseVariableTokens=q;
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import { d as V } from "./dash-case-DBThphLm.js";
|
2
|
+
const M = (o) => (e) => {
|
3
|
+
if (typeof e != "string" || !o) return;
|
4
|
+
let t = e;
|
5
|
+
const p = [];
|
6
|
+
return Object.values(o).forEach((n) => {
|
7
|
+
const { pattern: b, transform: y } = n;
|
8
|
+
t = t.replace(b, (C) => {
|
9
|
+
const { value: O, css: E } = y(C);
|
10
|
+
return E && p.push(E), O;
|
11
|
+
});
|
12
|
+
}), { transformed: t, additionalCss: p };
|
13
|
+
}, z = (o) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) }, B = z(), Q = [
|
14
|
+
"top",
|
15
|
+
"right",
|
16
|
+
"bottom",
|
17
|
+
"left",
|
18
|
+
"min-width",
|
19
|
+
/.*width.*/,
|
20
|
+
/^[^line]*height.*/,
|
21
|
+
// Exclude line-height
|
22
|
+
/padding.*/,
|
23
|
+
/margin.*/,
|
24
|
+
/border.*/,
|
25
|
+
/inset.*/,
|
26
|
+
/.*radius.*/,
|
27
|
+
/.*spacing.*/,
|
28
|
+
/.*gap.*/,
|
29
|
+
/.*indent.*/,
|
30
|
+
/.*offset.*/,
|
31
|
+
/.*size.*/,
|
32
|
+
/.*thickness.*/,
|
33
|
+
/.*font-size.*/
|
34
|
+
], _ = (o, e, t) => {
|
35
|
+
if (Q.some((n) => typeof n == "string" ? n === o : n.test(o))) {
|
36
|
+
const n = (t == null ? void 0 : t.defaultUnit) || "px";
|
37
|
+
return `${e}${n}`;
|
38
|
+
}
|
39
|
+
return `${e}`;
|
40
|
+
}, k = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : k.some((e) => o.startsWith(e)) ? `-${V(o)}` : V(o), $ = async (o, e = "", t, p = !1) => {
|
41
|
+
if (!o) throw new Error("No styles provided to parseStyles function!");
|
42
|
+
const n = /* @__PURE__ */ new Set(), b = Object.entries(o), y = async ([u, s]) => {
|
43
|
+
var j;
|
44
|
+
const r = u.trim(), w = q(r), l = (i, d = ";") => `${w}:${i}${d}`, P = { scope: e, config: t };
|
45
|
+
if (typeof s == "function") return y([u, s(P)]);
|
46
|
+
if (s instanceof Promise) return y([u, await s]);
|
47
|
+
if (t != null && t.templates && t.templatePaths[r])
|
48
|
+
try {
|
49
|
+
const [i, d] = t.templatePaths[r].split(";;"), a = await import(d), c = d.includes("salty.config"), f = c ? a[i].templates : a[i], h = c ? f[r] : f.params[r];
|
50
|
+
if (f && typeof h == "function") {
|
51
|
+
const x = await h(s), [m] = await $(x, "");
|
52
|
+
return m;
|
53
|
+
}
|
54
|
+
} catch (i) {
|
55
|
+
console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`, i);
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
if (t != null && t.templates && t.templates[r]) {
|
59
|
+
if (p) return;
|
60
|
+
const d = s.split(".").reduce((a, c) => a[c], t.templates[r]);
|
61
|
+
if (d) {
|
62
|
+
const [a] = await $(d, "");
|
63
|
+
return a;
|
64
|
+
}
|
65
|
+
console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
if (typeof s == "object") {
|
69
|
+
if (!s) return;
|
70
|
+
if (s.isColor) return l(s.toString());
|
71
|
+
if (r === "defaultVariants") return;
|
72
|
+
if (r === "variants") {
|
73
|
+
const a = Object.entries(s);
|
74
|
+
for (const [c, f] of a) {
|
75
|
+
if (!f) return;
|
76
|
+
const h = Object.entries(f);
|
77
|
+
for (const [x, m] of h) {
|
78
|
+
if (!m) return;
|
79
|
+
const T = `${e}.${c}-${x}`;
|
80
|
+
(await $(m, T, t)).forEach((U) => n.add(U));
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (r === "compoundVariants") {
|
86
|
+
for (const a of s) {
|
87
|
+
const { css: c, ...f } = a, h = Object.entries(f).reduce((m, [T, A]) => `${m}.${T}-${A}`, e);
|
88
|
+
(await $(c, h, t)).forEach((m) => n.add(m));
|
89
|
+
}
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
if (r.startsWith("@")) {
|
93
|
+
const a = ((j = t == null ? void 0 : t.mediaQueries) == null ? void 0 : j[r]) || r, c = await N(s, e, t), f = `${a} { ${c} }`;
|
94
|
+
n.add(f);
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
const i = u.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
|
98
|
+
(await $(s, i, t)).forEach((a) => n.add(a));
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
if (typeof s == "number") {
|
102
|
+
const i = _(w, s, t);
|
103
|
+
return l(i);
|
104
|
+
}
|
105
|
+
if (typeof s != "string")
|
106
|
+
if ("toString" in s) s = s.toString();
|
107
|
+
else throw new Error(`Invalid value type for property ${w}`);
|
108
|
+
return l(s);
|
109
|
+
}, C = b.map(y), { modifiers: O } = t || {}, E = [z(), M(O)], S = (await Promise.all(C).then((u) => Promise.all(
|
110
|
+
u.map((s) => E.reduce(async (r, w) => {
|
111
|
+
const l = await r;
|
112
|
+
if (!l) return l;
|
113
|
+
const P = await w(l);
|
114
|
+
if (!P) return l;
|
115
|
+
const { transformed: j, additionalCss: i } = P;
|
116
|
+
let d = "";
|
117
|
+
if (i)
|
118
|
+
for (const a of i)
|
119
|
+
d += await N(a, "");
|
120
|
+
return `${d}${j}`;
|
121
|
+
}, Promise.resolve(s)))
|
122
|
+
))).filter((u) => u !== void 0).join(`
|
123
|
+
`);
|
124
|
+
if (!S.trim()) return Array.from(n);
|
125
|
+
const W = e ? `${e} {
|
126
|
+
${S}
|
127
|
+
}` : S;
|
128
|
+
return n.has(W) ? Array.from(n) : [W, ...n];
|
129
|
+
}, N = async (o, e, t, p = !1) => (await $(o, e, t, p)).join(`
|
130
|
+
`);
|
131
|
+
export {
|
132
|
+
B as a,
|
133
|
+
N as p
|
134
|
+
};
|
package/server/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-CNuRN2e-.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
|
package/server/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { readFile as r } from "fs/promises";
|
2
|
-
import { i as e } from "../index-
|
2
|
+
import { i as e } from "../index-ClF7lS_W.js";
|
3
3
|
const f = async (t) => {
|
4
4
|
if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
|
5
5
|
if (t.includes("salty.config")) return !0;
|