@salty-css/core 0.0.1-alpha.24 → 0.0.1-alpha.241

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