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