@salty-css/core 0.0.1-alpha.19 → 0.0.1-alpha.190

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