@salty-css/core 0.0.1-alpha.29 → 0.0.1-alpha.292

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