@salty-css/core 0.0.1-alpha.300 → 0.0.1-alpha.301

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 (79) hide show
  1. package/.saltyrc.schema.json +1 -1
  2. package/bin/index.cjs +3 -1
  3. package/bin/index.js +2 -2
  4. package/bin/main.cjs +445 -11
  5. package/bin/main.js +405 -224
  6. package/cache/resolve-dynamic-config-cache.cjs +13 -1
  7. package/cache/resolve-dynamic-config-cache.js +10 -8
  8. package/compiler/index.cjs +774 -1
  9. package/compiler/index.d.ts +3 -0
  10. package/compiler/index.js +754 -20
  11. package/config/index.cjs +16 -1
  12. package/config/index.js +14 -12
  13. package/css/index.cjs +12 -1
  14. package/css/index.js +10 -10
  15. package/css/keyframes.cjs +49 -1
  16. package/css/keyframes.js +44 -34
  17. package/css/media.cjs +93 -1
  18. package/css/media.js +54 -49
  19. package/css/merge.cjs +15 -1
  20. package/css/merge.js +13 -3
  21. package/css/token.cjs +4 -1
  22. package/css/token.js +2 -2
  23. package/dash-case-Cz8wwE9a.cjs +32 -0
  24. package/dash-case-NMk0mXyT.js +33 -0
  25. package/define-templates-CVhhgPnd.js +60 -0
  26. package/define-templates-Deq1aCbN.cjs +59 -0
  27. package/factories/index.cjs +37 -1
  28. package/factories/index.js +27 -20
  29. package/generators/index.cjs +121 -1
  30. package/generators/index.js +82 -49
  31. package/helpers/index.cjs +53 -1
  32. package/helpers/index.js +40 -1170
  33. package/helpers-DM2fbDDz.js +18 -0
  34. package/helpers-wv74jTRI.cjs +18 -0
  35. package/index-ByR0nfaf.cjs +4 -0
  36. package/index-DKz1QXqs.js +4 -0
  37. package/package.json +1 -1
  38. package/parse-styles-CqBQc3eQ.js +232 -0
  39. package/parse-styles-D-p_guRO.cjs +231 -0
  40. package/parsers/index.cjs +57 -2
  41. package/parsers/index.js +55 -30
  42. package/pascal-case-By_l58S-.cjs +7 -0
  43. package/pascal-case-F3Usi5Wf.js +8 -0
  44. package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
  45. package/react-styled-file-U02jek-B.cjs +11 -0
  46. package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
  47. package/{react-vanilla-file-CCXbsjIb.js → react-vanilla-file-D9px70iK.js} +2 -2
  48. package/salty.config-DjosWdPw.js +4 -0
  49. package/salty.config-cqavVm2t.cjs +4 -0
  50. package/server/index.cjs +4 -1
  51. package/server/index.js +2 -2
  52. package/should-restart-5jI-bzz0.js +18 -0
  53. package/should-restart-DoaGoD5T.cjs +17 -0
  54. package/util/index.cjs +13 -1
  55. package/util/index.js +10 -8
  56. package/viewport-clamp-CEmzmcSj.cjs +10 -0
  57. package/viewport-clamp-K553uXu3.js +11 -0
  58. package/dash-case-BJEkFEGQ.cjs +0 -1
  59. package/dash-case-DBThphLm.js +0 -19
  60. package/define-templates-4A2yHcMF.js +0 -52
  61. package/define-templates-Cunsb_Tr.cjs +0 -1
  62. package/helpers-CC5pFyba.cjs +0 -1
  63. package/helpers-nHqH4L9L.js +0 -11
  64. package/index-84Wroia-.cjs +0 -1
  65. package/index-CituHO0U.js +0 -524
  66. package/index-D_732b92.js +0 -4
  67. package/index-ol1Q_xul.cjs +0 -41
  68. package/parse-styles-B1E0JeC7.cjs +0 -5
  69. package/parse-styles-y_-drahL.js +0 -161
  70. package/pascal-case-BQpR5PdN.js +0 -6
  71. package/pascal-case-iWoaJWwT.cjs +0 -1
  72. package/react-styled-file-Dkubsz-U.cjs +0 -8
  73. package/react-vanilla-file-CG_WJLam.cjs +0 -15
  74. package/salty.config-BhBY_oOk.js +0 -10
  75. package/salty.config-Dk6ZcCxI.cjs +0 -7
  76. package/should-restart-C6VJ-qaY.js +0 -12
  77. package/should-restart-DAhvRrtu.cjs +0 -1
  78. package/viewport-clamp-CaYwREKc.js +0 -7
  79. package/viewport-clamp-mq_DFtRR.cjs +0 -1
package/index-CituHO0U.js DELETED
@@ -1,524 +0,0 @@
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-y_-drahL.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
- };
package/index-D_732b92.js DELETED
@@ -1,4 +0,0 @@
1
- const t = "/* Empty */";
2
- export {
3
- t as default
4
- };
@@ -1,41 +0,0 @@
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-B1E0JeC7.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-ol1Q_xul.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;
@@ -1,5 +0,0 @@
1
- "use strict";const x=require("./dash-case-BJEkFEGQ.cjs"),I=require("./viewport-clamp-mq_DFtRR.cjs"),U=o=>s=>{if(typeof s!="string"||!o)return;let t=s;const m=[];return Object.values(o).forEach(e=>{const{pattern:d,transform:f}=e;t=t.replace(d,E=>{const{value:S,css:P}=f(E);return P&&m.push(P),S})}),{transformed:t,additionalCss:m}},A=o=>s=>typeof s!="string"||!/\{[^{}]+\}/g.test(s)?void 0:{transformed:s.replace(/\{([^{}]+)\}/g,(...e)=>{const d=x.dashCase(e[1].replaceAll(".","-"));return o&&!o.includes(d)&&console.warn(`Token ${d} might not exist`),d.startsWith("-")?`-${d}`:`var(--${d})`})},M=A(),N=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],k=(o,s,t)=>{if(N.some(e=>typeof e=="string"?e===o:e.test(o))){const e=(t==null?void 0:t.defaultUnit)||"px";if(e.startsWith("viewport-clamp:"))try{const f=e.split(":")[1];return I.defineViewportClamp({screenSize:parseInt(f)})(Number(s))}catch(f){throw console.error(f),new Error(`Invalid viewport-clamp value: ${e}`)}return`${s}${e}`}return`${s}`},J=["Webkit","Moz","ms","O"],Q=o=>o.startsWith("-")?o:J.some(s=>o.startsWith(s))?`-${x.dashCase(o)}`:x.dashCase(o),y=async(o,s="",t,m=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const e=new Set,d=Object.entries(o),f=async([h,r])=>{var V;const n=h.trim().replace(/^\?+/g,""),v=Q(n),$=(a,l=";")=>`${v}:${a}${l}`,j={scope:s,config:t};if(typeof r=="function")return f([h,r(j)]);if(r instanceof Promise)return f([h,await r]);if(t!=null&&t.templates&&t.templatePaths[n])try{const[a,l]=t.templatePaths[n].split(";;"),i=await import(l),c=l.includes("salty.config"),p=c?i[a].templates:i[a],w=c?p[n]:p.params[n];if(p&&typeof w=="function"){const b=await w(r),[u]=await y(b,"");return u}}catch(a){console.error(`Error loading template "${n}" from path "${t.templatePaths[n]}"`,a);return}if(t!=null&&t.templates&&t.templates[n]){if(m)return;const l=r.split(".").reduce((i,c)=>i[c],t.templates[n]);if(l){const[i]=await y(l,"");return i}console.warn(`Template "${n}" with path of "${r}" was not found in config!`);return}if(typeof r=="object"){if(!r)return;if(r.isColor)return $(r.toString());if(n==="defaultVariants")return;if(n==="variants"){const i=Object.entries(r);for(const[c,p]of i){if(!p)continue;const w=Object.entries(p);for(const[b,u]of w){if(!u)continue;const C=`${s}.${c}-${b}`;(await y(u,C,t)).forEach(q=>e.add(q))}}return}if(n==="compoundVariants"){for(const i of r){const{css:c,...p}=i,w=Object.entries(p).reduce((u,[C,O])=>`${u}.${C}-${O}`,s);(await y(c,w,t)).forEach(u=>e.add(u))}return}if(n==="anyOfVariants"){for(const i of r){const{css:c,...p}=i,w=Object.entries(p).map(([C,O])=>`.${C}-${O}`),b=`${s}:where(${w.join(", ")})`;console.log(`Union variant scope: ${b}`),(await y(c,b,t)).forEach(C=>e.add(C))}return}if(n.startsWith("@")){const i=((V=t==null?void 0:t.mediaQueries)==null?void 0:V[n])||n,c=await W(r,s,t),p=`${i} { ${c} }`;e.add(p);return}const a=h.includes("&")?n.replaceAll("&",s):n.startsWith(":")?`${s}${n}`:`${s} ${n}`;(await y(r,a,t)).forEach(i=>e.add(i));return}if(typeof r=="number"){const a=k(v,r,t);return $(a)}if(typeof r!="string")if("toString"in r)r=r.toString();else throw new Error(`Invalid value type for property ${v}`);return $(r)},E=d.map(f),{modifiers:S}=t||{},P=[A(),U(S)],T=(await Promise.all(E).then(h=>Promise.all(h.map(r=>P.reduce(async(n,v)=>{const $=await n;if(!$)return $;const j=await v($);if(!j)return $;const{transformed:V,additionalCss:a}=j;let l="";if(a)for(const i of a)l+=await W(i,"");return`${l}${V}`},Promise.resolve(r)))))).filter(h=>h!==void 0).join(`
2
- `);if(!T.trim())return Array.from(e);const z=s?`${s} {
3
- ${T}
4
- }`:T;return e.has(z)?Array.from(e):[z,...e]},W=async(o,s,t,m=!1)=>(await y(o,s,t,m)).join(`
5
- `);exports.parseAndJoinStyles=W;exports.parseStyles=y;exports.parseValueModifiers=U;exports.parseValueTokens=A;exports.parseVariableTokens=M;