@salty-css/core 0.0.1-alpha.254 → 0.0.1-alpha.256

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.
@@ -1,11 +1,11 @@
1
1
  import * as St from "esbuild";
2
- import { execSync as vt } from "child_process";
2
+ import { execSync as Vt } from "child_process";
3
3
  import { d as K, t as J } from "./dash-case-DBThphLm.js";
4
4
  import { join as r, parse as tt } from "path";
5
- import { existsSync as ut, writeFileSync as j, mkdirSync as H, readFileSync as _, statSync as Et, readdirSync as Ot } from "fs";
5
+ import { existsSync as mt, mkdirSync as H, statSync as Et, readdirSync as Ot, readFileSync as v, writeFileSync as j } from "fs";
6
6
  import { readFile as Ct } from "fs/promises";
7
- import { p as ft, a as Mt } from "./parse-styles-BBLk1gXe.js";
8
- import { createLogger as Rt, format as rt, transports as Jt } from "winston";
7
+ import { p as ft, a as Mt } from "./parse-styles-CzXGidPn.js";
8
+ import { createLogger as Rt, transports as Jt, format as rt } from "winston";
9
9
  import { mergeObjects as I, mergeFactories as zt } from "./css/merge.js";
10
10
  import { d as Wt } from "./define-templates-4A2yHcMF.js";
11
11
  import lt from "typescript";
@@ -14,8 +14,8 @@ const jt = async (t, e = []) => {
14
14
  const s = [], n = {};
15
15
  for (const [o, i] of Object.entries(t))
16
16
  if (typeof i != "function") if (i && typeof i == "object") {
17
- const a = o.trim(), m = await jt(i, [...e, a]);
18
- s.push(m);
17
+ const a = o.trim(), p = await jt(i, [...e, a]);
18
+ s.push(p);
19
19
  } else
20
20
  n[o] = i;
21
21
  if (Object.keys(n).length) {
@@ -30,7 +30,7 @@ const jt = async (t, e = []) => {
30
30
  }), [...s]) : [], Pt = (t) => {
31
31
  if (!t || t === "/") throw new Error("Could not find package.json file");
32
32
  const e = r(t, "package.json");
33
- return ut(e) ? e : Pt(r(t, ".."));
33
+ return mt(e) ? e : Pt(r(t, ".."));
34
34
  }, Ht = async (t) => {
35
35
  const e = Pt(t);
36
36
  return await Ct(e, "utf-8").then(JSON.parse).catch(() => {
@@ -105,40 +105,40 @@ const Kt = {
105
105
  const o = setTimeout(() => {
106
106
  n(new Error("Timeout"));
107
107
  }, 100), i = lt.createSourceFile("temp.ts", t, lt.ScriptTarget.Latest, !0);
108
- function a(m) {
109
- if (lt.isVariableDeclaration(m) && m.name.getText() === e) {
110
- const w = m.getStart(), p = m.getEnd();
111
- clearTimeout(o), s([w, p]);
108
+ function a(p) {
109
+ if (lt.isVariableDeclaration(p) && p.name.getText() === e) {
110
+ const w = p.getStart(), u = p.getEnd();
111
+ clearTimeout(o), s([w, u]);
112
112
  }
113
- m.forEachChild(a);
113
+ p.forEachChild(a);
114
114
  }
115
115
  a(i);
116
- }), v = {
116
+ }), V = {
117
117
  externalModules: [],
118
118
  rcFile: void 0,
119
119
  destDir: void 0
120
120
  }, Dt = (t) => {
121
- if (v.externalModules.length > 0) return v.externalModules;
122
- const s = _(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
121
+ if (V.externalModules.length > 0) return V.externalModules;
122
+ const s = v(t, "utf8").match(/externalModules:\s?\[(.*)\]/);
123
123
  if (!s) return [];
124
124
  const n = s[1].split(",").map((o) => o.replace(/['"`]/g, "").trim());
125
- return v.externalModules = n, n;
125
+ return V.externalModules = n, n;
126
126
  }, z = async (t) => {
127
- if (v.destDir) return v.destDir;
128
- const e = await pt(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
129
- return v.destDir = s, s;
130
- }, kt = ["salty", "css", "styles", "styled"], Bt = (t = []) => new RegExp(`\\.(${[...kt, ...t].join("|")})\\.`), mt = (t, e = []) => Bt(e).test(t), Tt = async (t) => {
131
- if (v.rcFile) return v.rcFile;
127
+ if (V.destDir) return V.destDir;
128
+ const e = await ut(t), s = r(t, (e == null ? void 0 : e.saltygenDir) || "saltygen");
129
+ return V.destDir = s, s;
130
+ }, kt = ["salty", "css", "styles", "styled"], Bt = (t = []) => new RegExp(`\\.(${[...kt, ...t].join("|")})\\.`), pt = (t, e = []) => Bt(e).test(t), Tt = async (t) => {
131
+ if (V.rcFile) return V.rcFile;
132
132
  if (t === "/") throw new Error("Could not find .saltyrc.json file");
133
133
  const e = r(t, ".saltyrc.json"), s = await Ct(e, "utf-8").then(JSON.parse).catch(() => {
134
134
  });
135
- return s ? (v.rcFile = s, s) : Tt(r(t, ".."));
136
- }, pt = async (t) => {
135
+ return s ? (V.rcFile = s, s) : Tt(r(t, ".."));
136
+ }, ut = async (t) => {
137
137
  var n, o;
138
138
  const e = await Tt(t), s = (n = e.projects) == null ? void 0 : n.find((i) => t.endsWith(i.dir || ""));
139
139
  return s || ((o = e.projects) == null ? void 0 : o.find((i) => i.dir === e.defaultProject));
140
140
  }, Lt = async (t) => {
141
- const e = await pt(t), s = await z(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = r(s, "salty.config.js"), i = await Nt(t), a = Dt(n);
141
+ const e = await ut(t), s = await z(t), n = r(t, (e == null ? void 0 : e.configDir) || "", "salty.config.ts"), o = r(s, "salty.config.js"), i = await Nt(t), a = Dt(n);
142
142
  await St.build({
143
143
  entryPoints: [n],
144
144
  minify: !0,
@@ -148,7 +148,7 @@ const Kt = {
148
148
  format: i,
149
149
  external: a
150
150
  });
151
- const m = Date.now(), { config: w } = await import(`${o}?t=${m}`);
151
+ const p = Date.now(), { config: w } = await import(`${o}?t=${p}`);
152
152
  return { config: w, path: o };
153
153
  }, qt = async (t, e) => {
154
154
  var ht, wt;
@@ -166,9 +166,9 @@ const Kt = {
166
166
  });
167
167
  })
168
168
  );
169
- const { config: o, path: i } = await Lt(t), a = { ...o }, { mediaQueries: m } = n;
170
- a.mediaQueries = Object.fromEntries(m.map(([h, S]) => [`@${h}`, S]));
171
- const w = m.map(([h]) => `'@${h}'`).join(" | "), p = /* @__PURE__ */ new Set(), c = async (h, S = []) => {
169
+ const { config: o, path: i } = await Lt(t), a = { ...o }, { mediaQueries: p } = n;
170
+ a.mediaQueries = Object.fromEntries(p.map(([h, S]) => [`@${h}`, S]));
171
+ const w = p.map(([h]) => `'@${h}'`).join(" | "), u = /* @__PURE__ */ new Set(), c = async (h, S = []) => {
172
172
  if (!h) return [];
173
173
  const q = Object.entries(h).map(async ([P, R]) => {
174
174
  const A = async (T) => {
@@ -177,7 +177,7 @@ const Kt = {
177
177
  if (typeof T == "function") return await A(await T());
178
178
  if (typeof T == "object") return await c(T, [...S, P]);
179
179
  const at = xt(P), it = K(P), ct = [...S, at].join(".");
180
- p.add(`"${ct}"`);
180
+ u.add(`"${ct}"`);
181
181
  const Y = [...S.map(K), it].join("-"), $t = Mt(T);
182
182
  return $t ? `--${Y}: ${$t.transformed};` : `--${Y}: ${T};`;
183
183
  };
@@ -201,19 +201,19 @@ const Kt = {
201
201
  return (await Promise.all(R)).flat();
202
202
  });
203
203
  return (await Promise.all(S)).flat();
204
- }, g = (h) => ({ ...h, responsive: void 0, conditional: void 0 }), u = (h) => n.variables.map((S) => h === "static" ? g(S._current) : S._current[h]), C = I(g(o.variables), u("static")), x = await c(C), D = I((ht = o.variables) == null ? void 0 : ht.responsive, u("responsive")), E = await y(D), W = I((wt = o.variables) == null ? void 0 : wt.conditional, u("conditional")), U = await d(W), gt = r(s, "css/_variables.css"), O = `:root { ${x.join("")} ${E.join("")} } ${U.join("")}`;
204
+ }, g = (h) => ({ ...h, responsive: void 0, conditional: void 0 }), m = (h) => n.variables.map((S) => h === "static" ? g(S._current) : S._current[h]), C = I(g(o.variables), m("static")), x = await c(C), D = I((ht = o.variables) == null ? void 0 : ht.responsive, m("responsive")), E = await y(D), W = I((wt = o.variables) == null ? void 0 : wt.conditional, m("conditional")), U = await d(W), gt = r(s, "css/_variables.css"), O = `:root { ${x.join("")} ${E.join("")} } ${U.join("")}`;
205
205
  j(gt, O), a.staticVariables = C;
206
206
  const st = r(s, "css/_global.css"), f = I(o.global, n.globalStyles), $ = await ft(f, "");
207
207
  j(st, `@layer global { ${$} }`);
208
208
  const b = r(s, "css/_reset.css"), F = o.reset === "none" ? {} : typeof o.reset == "object" ? o.reset : Kt, N = await ft(F, "");
209
209
  j(b, `@layer reset { ${N} }`);
210
- const V = r(s, "css/_templates.css"), M = I(o.templates, n.templates), Q = await jt(M), B = Gt(M);
211
- j(V, `@layer templates { ${Q} }`), a.templates = M;
210
+ const _ = r(s, "css/_templates.css"), M = I(o.templates, n.templates), Q = await jt(M), B = Gt(M);
211
+ j(_, `@layer templates { ${Q} }`), a.templates = M;
212
212
  const X = o.templates ? [Wt(o.templates)._setPath(`config;;${i}`)] : [], nt = zt(n.templates, X);
213
213
  a.templatePaths = Object.fromEntries(Object.entries(nt).map(([h, S]) => [h, S._path]));
214
- const L = r(s, "types/css-tokens.d.ts"), _t = `
214
+ const L = r(s, "types/css-tokens.d.ts"), vt = `
215
215
  // Variable types
216
- type VariableTokens = ${[...p].join("|")};
216
+ type VariableTokens = ${[...u].join("|")};
217
217
  type PropertyValueToken = \`{\${VariableTokens}}\`;
218
218
 
219
219
  // Template types
@@ -225,22 +225,22 @@ const Kt = {
225
225
  // Media query types
226
226
  type MediaQueryKeys = ${w || "''"};
227
227
  `;
228
- j(L, _t);
229
- const Vt = r(s, "cache/config-cache.json");
230
- j(Vt, JSON.stringify(a, null, 2));
228
+ j(L, vt);
229
+ const _t = r(s, "cache/config-cache.json");
230
+ j(_t, JSON.stringify(a, null, 2));
231
231
  }, bt = (t) => t.replace(/styled\(([^"'`{,]+),/g, (e, s) => {
232
232
  if (/^['"`]/.test(s)) return e;
233
233
  const o = new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);
234
234
  if (!o.test(t)) return e;
235
235
  const a = o.exec(t);
236
236
  if (a) {
237
- const m = a.at(1);
238
- if (kt.some((p) => m == null ? void 0 : m.includes(p))) return e;
237
+ const p = a.at(1);
238
+ if (kt.some((u) => p == null ? void 0 : p.includes(u))) return e;
239
239
  }
240
240
  return "styled('div',";
241
241
  }), At = (t, e) => {
242
242
  try {
243
- const s = _(r(e, "saltygen/cache/config-cache.json"), "utf8");
243
+ const s = v(r(e, "saltygen/cache/config-cache.json"), "utf8");
244
244
  return s ? `globalThis.saltyConfig = ${s};
245
245
 
246
246
  ${t}` : `globalThis.saltyConfig = {};
@@ -251,11 +251,11 @@ ${t}`;
251
251
  }
252
252
  }, et = async (t, e, s) => {
253
253
  const n = J(e), o = r(s, "./temp");
254
- ut(o) || H(o);
254
+ mt(o) || H(o);
255
255
  const i = tt(e);
256
- let a = _(e, "utf8");
256
+ let a = v(e, "utf8");
257
257
  a = bt(a), a = At(a, t);
258
- const m = r(s, "js", n + ".js"), w = await pt(t), p = r(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), c = Dt(p), y = await Nt(t);
258
+ const p = r(s, "js", n + ".js"), w = await ut(t), u = r(t, (w == null ? void 0 : w.configDir) || "", "salty.config.ts"), c = Dt(u), y = await Nt(t);
259
259
  await St.build({
260
260
  stdin: {
261
261
  contents: a,
@@ -266,7 +266,7 @@ ${t}`;
266
266
  minify: !1,
267
267
  treeShaking: !0,
268
268
  bundle: !0,
269
- outfile: m,
269
+ outfile: p,
270
270
  format: y,
271
271
  target: ["node20"],
272
272
  keepNames: !0,
@@ -275,9 +275,9 @@ ${t}`;
275
275
  plugins: [
276
276
  {
277
277
  name: "test",
278
- setup: (u) => {
279
- u.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (C) => {
280
- const x = _(C.path, "utf8");
278
+ setup: (m) => {
279
+ m.onLoad({ filter: /.*\.css|salty|styles|styled\.ts/ }, (C) => {
280
+ const x = v(C.path, "utf8");
281
281
  return { contents: bt(x), loader: "ts" };
282
282
  });
283
283
  }
@@ -285,9 +285,9 @@ ${t}`;
285
285
  ]
286
286
  });
287
287
  const d = Date.now();
288
- return { contents: await import(`${m}?t=${d}`), outputFilePath: m };
288
+ return { contents: await import(`${p}?t=${d}`), outputFilePath: p };
289
289
  }, Ut = async (t) => {
290
- const e = await z(t), s = r(e, "cache/config-cache.json"), n = _(s, "utf8");
290
+ const e = await z(t), s = r(e, "cache/config-cache.json"), n = v(s, "utf8");
291
291
  if (!n) throw new Error("Could not find config cache file");
292
292
  return JSON.parse(n);
293
293
  }, dt = async (t) => {
@@ -303,20 +303,20 @@ ${t}`;
303
303
  try {
304
304
  const n = Date.now();
305
305
  e ? Z.info("Generating CSS in production mode! 🔥") : Z.info("Generating CSS in development mode! 🚀");
306
- const o = [], i = [], a = await z(t), m = r(a, "index.css");
306
+ const o = [], i = [], a = await z(t), p = r(a, "index.css");
307
307
  s && (() => {
308
- ut(a) && vt("rm -rf " + a), H(a, { recursive: !0 }), H(r(a, "css")), H(r(a, "types")), H(r(a, "js")), H(r(a, "cache"));
308
+ mt(a) && Vt("rm -rf " + a), H(a, { recursive: !0 }), H(r(a, "css")), H(r(a, "types")), H(r(a, "js")), H(r(a, "cache"));
309
309
  })();
310
- const p = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
310
+ const u = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
311
311
  async function y(f) {
312
312
  const $ = ["node_modules", "saltygen"], b = Et(f);
313
313
  if (b.isDirectory()) {
314
314
  const l = Ot(f);
315
315
  if ($.some((N) => f.includes(N))) return;
316
316
  await Promise.all(l.map((N) => y(r(f, N))));
317
- } else if (b.isFile() && mt(f)) {
318
- p.add(f);
319
- const F = _(f, "utf8");
317
+ } else if (b.isFile() && pt(f)) {
318
+ u.add(f);
319
+ const F = v(f, "utf8");
320
320
  /define[\w\d]+\(/.test(F) && c.add(f);
321
321
  }
322
322
  }
@@ -327,7 +327,7 @@ ${t}`;
327
327
  classNames: []
328
328
  };
329
329
  await Promise.all(
330
- [...p].map(async (f) => {
330
+ [...u].map(async (f) => {
331
331
  const { contents: $ } = await et(t, f, a);
332
332
  for (let [b, l] of Object.entries($))
333
333
  l instanceof Promise && (l = await l), l.isKeyframes ? d.keyframes.push({
@@ -350,10 +350,10 @@ ${t}`;
350
350
  const { value: $ } = f, b = `a_${$.animationName}.css`, l = `css/${b}`, F = r(a, l);
351
351
  o.push(b), j(F, $.css);
352
352
  }
353
- const u = {};
353
+ const m = {};
354
354
  for (const f of d.components) {
355
355
  const { src: $, name: b } = f;
356
- u[$] || (u[$] = []);
356
+ m[$] || (m[$] = []);
357
357
  const l = f.generator._withBuildContext({
358
358
  callerName: b,
359
359
  isProduction: e,
@@ -363,12 +363,12 @@ ${t}`;
363
363
  const F = await l.css;
364
364
  if (!F) continue;
365
365
  i[l.priority].push(l.cssFileName);
366
- const N = `css/${l.cssFileName}`, V = r(a, N);
367
- j(V, F), g.importStrategy === "component" && u[$].push(l.cssFileName);
366
+ const N = `css/${l.cssFileName}`, _ = r(a, N);
367
+ j(_, F), g.importStrategy === "component" && m[$].push(l.cssFileName);
368
368
  }
369
369
  for (const f of d.classNames) {
370
370
  const { src: $, name: b } = f;
371
- u[$] || (u[$] = []);
371
+ m[$] || (m[$] = []);
372
372
  const l = f.generator._withBuildContext({
373
373
  callerName: b,
374
374
  isProduction: e,
@@ -376,13 +376,13 @@ ${t}`;
376
376
  }), F = await l.css;
377
377
  if (!F) continue;
378
378
  i[l.priority] || (i[l.priority] = []), i[l.priority].push(l.cssFileName);
379
- const N = `css/${l.cssFileName}`, V = r(a, N);
380
- j(V, F), g.importStrategy === "component" && u[$].push(l.cssFileName);
379
+ const N = `css/${l.cssFileName}`, _ = r(a, N);
380
+ j(_, F), g.importStrategy === "component" && m[$].push(l.cssFileName);
381
381
  }
382
- g.importStrategy === "component" && Object.entries(u).forEach(([f, $]) => {
382
+ g.importStrategy === "component" && Object.entries(m).forEach(([f, $]) => {
383
383
  const b = $.map((M) => `@import url('./${M}');`).join(`
384
- `), l = J(f, 6), F = tt(f), N = K(F.name), V = r(a, `css/f_${N}-${l}.css`);
385
- j(V, b || "/* Empty file */");
384
+ `), l = J(f, 6), F = tt(f), N = K(F.name), _ = r(a, `css/f_${N}-${l}.css`);
385
+ j(_, b || "/* Empty file */");
386
386
  });
387
387
  const C = o.map((f) => `@import url('./css/${f}');`).join(`
388
388
  `);
@@ -394,7 +394,7 @@ ${t}`;
394
394
 
395
395
  ${["_variables.css", "_reset.css", "_global.css", "_templates.css"].filter((f) => {
396
396
  try {
397
- return _(r(a, "css", f), "utf8").length > 0;
397
+ return v(r(a, "css", f), "utf8").length > 0;
398
398
  } catch {
399
399
  return !1;
400
400
  }
@@ -407,20 +407,20 @@ ${C}`;
407
407
  const f = i.reduce(($, b, l) => {
408
408
  const F = b.reduce((Q, B) => {
409
409
  var ot;
410
- const X = r(a, "css", B), nt = _(X, "utf8"), L = ((ot = /.*-([^-]+)-\d+.css/.exec(B)) == null ? void 0 : ot.at(1)) || J(X, 6);
410
+ const X = r(a, "css", B), nt = v(X, "utf8"), L = ((ot = /.*-([^-]+)-\d+.css/.exec(B)) == null ? void 0 : ot.at(1)) || J(X, 6);
411
411
  return Q.includes(L) ? Q : `${Q}
412
412
  /*start:${L}-${B}*/
413
413
  ${nt}
414
414
  /*end:${L}*/
415
415
  `;
416
- }, ""), N = `l_${l}.css`, V = r(a, "css", N), M = `@layer l${l} { ${F}
416
+ }, ""), N = `l_${l}.css`, _ = r(a, "css", N), M = `@layer l${l} { ${F}
417
417
  }`;
418
- return j(V, M), `${$}
418
+ return j(_, M), `${$}
419
419
  @import url('./css/${N}');`;
420
420
  }, "");
421
421
  U += f;
422
422
  }
423
- j(m, U);
423
+ j(p, U);
424
424
  const O = Date.now() - n, st = O < 200 ? "🔥" : O < 500 ? "🚀" : O < 1e3 ? "🎉" : O < 2e3 ? "🚗" : O < 5e3 ? "🤔" : "🥴";
425
425
  Z.info(`Generated CSS in ${O}ms! ${st}`);
426
426
  } catch (n) {
@@ -429,28 +429,28 @@ ${nt}
429
429
  }, le = async (t, e, s = yt()) => {
430
430
  try {
431
431
  const n = await z(t);
432
- if (mt(e)) {
433
- const i = [], a = await dt(t), { contents: m } = await et(t, e, n);
434
- for (const [w, p] of Object.entries(m)) {
435
- if (p.isKeyframes && p.css) {
436
- const C = `css/${`a_${p.animationName}.css`}`, x = r(n, C);
437
- j(x, await p.css);
432
+ if (pt(e)) {
433
+ const i = [], a = await dt(t), { contents: p } = await et(t, e, n);
434
+ for (const [w, u] of Object.entries(p)) {
435
+ if (u.isKeyframes && u.css) {
436
+ const C = `css/${`a_${u.animationName}.css`}`, x = r(n, C);
437
+ j(x, await u.css);
438
438
  continue;
439
439
  }
440
- if (p.isClassName) {
441
- const u = p.generator._withBuildContext({
440
+ if (u.isClassName) {
441
+ const m = u.generator._withBuildContext({
442
442
  callerName: w,
443
443
  isProduction: s,
444
444
  config: a
445
- }), C = await u.css;
445
+ }), C = await m.css;
446
446
  if (!C) continue;
447
- i[u.priority] || (i[u.priority] = []), i[u.priority].push(u.cssFileName);
448
- const x = `css/${u.cssFileName}`, D = r(n, x);
447
+ i[m.priority] || (i[m.priority] = []), i[m.priority].push(m.cssFileName);
448
+ const x = `css/${m.cssFileName}`, D = r(n, x);
449
449
  j(D, C);
450
450
  continue;
451
451
  }
452
- if (!p.generator) continue;
453
- const c = p.generator._withBuildContext({
452
+ if (!u.generator) continue;
453
+ const c = u.generator._withBuildContext({
454
454
  callerName: w,
455
455
  isProduction: s,
456
456
  config: a
@@ -460,14 +460,14 @@ ${nt}
460
460
  j(g, y), i[c.priority] || (i[c.priority] = []), i[c.priority].push(c.cssFileName);
461
461
  }
462
462
  if (a.importStrategy !== "component")
463
- i.forEach((w, p) => {
464
- const c = `l_${p}.css`, y = r(n, "css", c);
465
- let d = _(y, "utf8");
463
+ i.forEach((w, u) => {
464
+ const c = `l_${u}.css`, y = r(n, "css", c);
465
+ let d = v(y, "utf8");
466
466
  w.forEach((g) => {
467
467
  var D;
468
- const u = r(n, "css", g), C = ((D = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : D.at(1)) || J(u, 6);
468
+ const m = r(n, "css", g), C = ((D = /.*-([^-]+)-\d+.css/.exec(g)) == null ? void 0 : D.at(1)) || J(m, 6);
469
469
  if (!d.includes(C)) {
470
- const E = _(u, "utf8"), W = `/*start:${C}-${g}*/
470
+ const E = v(m, "utf8"), W = `/*start:${C}-${g}*/
471
471
  ${E}
472
472
  /*end:${C}*/
473
473
  `;
@@ -479,7 +479,7 @@ ${W}
479
479
  });
480
480
  else {
481
481
  const w = i.flat().map((g) => `@import url('./${g}');`).join(`
482
- `), p = J(e, 6), c = tt(e), y = K(c.name), d = r(n, `css/f_${y}-${p}.css`);
482
+ `), u = J(e, 6), c = tt(e), y = K(c.name), d = r(n, `css/f_${y}-${u}.css`);
483
483
  j(d, w || "/* Empty file */");
484
484
  }
485
485
  }
@@ -490,16 +490,16 @@ ${W}
490
490
  var n, o;
491
491
  try {
492
492
  const i = await z(t);
493
- if (mt(e)) {
494
- const m = _(e, "utf8"), w = await dt(t), { contents: p } = await et(t, e, i);
495
- let c = m;
496
- for (const [y, d] of Object.entries(p)) {
493
+ if (pt(e)) {
494
+ const p = v(e, "utf8"), w = await dt(t), { contents: u } = await et(t, e, i);
495
+ let c = p;
496
+ for (const [y, d] of Object.entries(u)) {
497
497
  if (d.isKeyframes || !d.generator) continue;
498
498
  const g = d.generator._withBuildContext({
499
499
  callerName: y,
500
500
  isProduction: s,
501
501
  config: w
502
- }), [u, C] = await Qt(c, y), x = c.slice(u, C);
502
+ }), [m, C] = await Qt(c, y), x = c.slice(m, C);
503
503
  if (d.isClassName) {
504
504
  const D = c, E = ` ${y} = className("${g.classNames}")`;
505
505
  c = c.replace(x, E), D === c && console.error("Minimize file failed to change content", { name: y });
@@ -527,7 +527,7 @@ export {
527
527
  qt as d,
528
528
  et as e,
529
529
  re as g,
530
- mt as i,
530
+ pt as i,
531
531
  Z as l,
532
532
  fe as m,
533
533
  kt as s
@@ -1,7 +1,7 @@
1
- "use strict";const Te=require("esbuild"),Oe=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),c=require("path"),l=require("fs"),we=require("fs/promises"),Z=require("./parse-styles-bvJ5u1by.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),Ee=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Ve(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 Se=Ve(Te),je=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,a]of Object.entries(e))if(typeof a!="function")if(a&&typeof a=="object"){const i=o.trim(),d=await je(a,[...t,i]);s.push(d)}else n[o]=a;if(Object.keys(n).length){const o=t.map(D.dashCase).join("-"),a="t_"+D.toHash(o,4),i=await Z.parseAndJoinStyles(n,`.${o}, .${a}`);s.push(i)}return s.join(`
2
- `)},ve=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=be(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},be=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?be(o,a,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:$e(c.join(e,".."))},Re=async e=>{const t=$e(e);return await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Me=async e=>{const t=await Re(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Me(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-Bh0Rdc9S.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Je=e=>{B.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"}},qe=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),a=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function i(d){if(ce.isVariableDeclaration(d)&&d.name.getText()===t){const S=d.getStart(),m=d.getEnd();clearTimeout(o),s([S,m])}d.forEachChild(i)}i(a)}),E={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(E.externalModules.length>0)return E.externalModules;const s=l.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return E.externalModules=n,n},z=async e=>{if(E.destDir)return E.destDir;const t=await fe(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return E.destDir=s,s},le=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...le,...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=c.join(e,".saltyrc.json"),s=await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(E.rcFile=s,s):xe(c.join(e,".."))},fe=async e=>{var n,o;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},He=async e=>{const t=await fe(e),s=await z(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),a=await Fe(e),i=Pe(n);await Se.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const d=Date.now(),{config:S}=await import(`${o}?t=${d}`);return{config:S,path:o}},ke=async(e,t)=>{var me,ye;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:$,outputFilePath:K}=await U(e,w,s);Object.entries($).forEach(([_,P])=>{P.isMedia?n.mediaQueries.push([_,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${_};;${K}`))})}));const{config:o,path:a}=await He(e),i={...o},{mediaQueries:d}=n;i.mediaQueries=Object.fromEntries(d.map(([w,$])=>[`@${w}`,$]));const S=d.map(([w])=>`'@${w}'`).join(" | "),m=new Set,r=async(w,$=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await r(T,[...$,P]);const oe=Ce(P),ie=D.dashCase(P),ae=[...$,oe].join(".");m.add(`"${ae}"`);const Y=[...$.map(D.dashCase),ie].join("-"),ge=Z.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const $=Object.entries(w).map(async([_,P])=>{const M=await r(P);return _==="base"?M.join(""):i.mediaQueries[_]?`${i.mediaQueries[_]} { ${M.join("")} }`:`${_} { ${M.join("")} }`});return(await Promise.all($)).flat()},y=async w=>{if(!w)return[];const $=Object.entries(w).map(async([_,P])=>{const M=Object.entries(P).map(async([T,oe])=>{const ie=await r(oe,[_]),ae=`.${_}-${T}, [data-${_}="${T}"]`,Y=ie.join("");return`${ae} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all($)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map($=>w==="static"?h($._current):$._current[w]),F=J.mergeObjects(h(o.variables),p("static")),x=await r(F),k=J.mergeObjects((me=o.variables)==null?void 0:me.responsive,p("responsive")),V=await g(k),q=J.mergeObjects((ye=o.variables)==null?void 0:ye.conditional,p("conditional")),A=await y(q),de=c.join(s,"css/_variables.css"),v=`:root { ${x.join("")} ${V.join("")} } ${A.join("")}`;l.writeFileSync(de,v),i.staticVariables=F;const te=c.join(s,"css/_global.css"),u=J.mergeObjects(o.global,n.globalStyles),j=await Z.parseAndJoinStyles(u,"");l.writeFileSync(te,`@layer global { ${j} }`);const b=c.join(s,"css/_reset.css"),C=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ze,N=await Z.parseAndJoinStyles(C,"");l.writeFileSync(b,`@layer reset { ${N} }`);const O=c.join(s,"css/_templates.css"),R=J.mergeObjects(o.templates,n.templates),W=await je(R),I=ve(R);l.writeFileSync(O,`@layer templates { ${W} }`),i.templates=R;const X=o.templates?[Ee.defineTemplates(o.templates)._setPath(`config;;${a}`)]:[],se=J.mergeFactories(n.templates,X);i.templatePaths=Object.fromEntries(Object.entries(se).map(([w,$])=>[w,$._path]));const G=c.join(s,"types/css-tokens.d.ts"),De=`
1
+ "use strict";const Te=require("esbuild"),ve=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),c=require("path"),l=require("fs"),we=require("fs/promises"),Z=require("./parse-styles-BFumiqfk.cjs"),Q=require("winston"),J=require("./css/merge.cjs"),Oe=require("./define-templates-Cunsb_Tr.cjs"),ce=require("typescript");var re=typeof document<"u"?document.currentScript:null;function Ee(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Se=Ee(Te),je=async(e,t=[])=>{if(!e)return"";const s=[],n={};for(const[o,a]of Object.entries(e))if(typeof a!="function")if(a&&typeof a=="object"){const i=o.trim(),m=await je(a,[...t,i]);s.push(m)}else n[o]=a;if(Object.keys(n).length){const o=t.map(D.dashCase).join("-"),a="t_"+D.toHash(o,4),i=await Z.parseAndJoinStyles(n,`.${o}, .${a}`);s.push(i)}return s.join(`
2
+ `)},Ve=e=>e?Object.entries(e).reduce((t,[s,n])=>(typeof n=="function"?t[s]="any":typeof n=="object"&&(t[s]=be(n).map(o=>`"${o}"`).join(" | ")),t),{}):{},be=(e,t="",s=new Set)=>e?(Object.entries(e).forEach(([n,o])=>{const a=t?`${t}.${n}`:n;return typeof o=="object"?be(o,a,s):s.add(t)}),[...s]):[],$e=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=c.join(e,"package.json");return l.existsSync(t)?t:$e(c.join(e,".."))},Re=async e=>{const t=$e(e);return await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},Me=async e=>{const t=await Re(e);if(t)return t.type};let H;const Fe=async e=>{if(H)return H;const t=await Me(e);return t==="module"?H="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:re&&re.tagName.toUpperCase()==="SCRIPT"&&re.src||new URL("index-Df5O3s28.cjs",document.baseURI).href).endsWith(".cjs"))&&(H="cjs"),H||"esm"},B=Q.createLogger({level:"debug",format:Q.format.combine(Q.format.colorize(),Q.format.cli()),transports:[new Q.transports.Console({})]}),Je=e=>{B.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"}},qe=(e,t)=>new Promise((s,n)=>{const o=setTimeout(()=>{n(new Error("Timeout"))},100),a=ce.createSourceFile("temp.ts",e,ce.ScriptTarget.Latest,!0);function i(m){if(ce.isVariableDeclaration(m)&&m.name.getText()===t){const S=m.getStart(),d=m.getEnd();clearTimeout(o),s([S,d])}m.forEachChild(i)}i(a)}),O={externalModules:[],rcFile:void 0,destDir:void 0},Pe=e=>{if(O.externalModules.length>0)return O.externalModules;const s=l.readFileSync(e,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!s)return[];const n=s[1].split(",").map(o=>o.replace(/['"`]/g,"").trim());return O.externalModules=n,n},z=async e=>{if(O.destDir)return O.destDir;const t=await fe(e),s=c.join(e,(t==null?void 0:t.saltygenDir)||"saltygen");return O.destDir=s,s},le=["salty","css","styles","styled"],Ne=(e=[])=>new RegExp(`\\.(${[...le,...e].join("|")})\\.`),ee=(e,t=[])=>Ne(t).test(e),xe=async e=>{if(O.rcFile)return O.rcFile;if(e==="/")throw new Error("Could not find .saltyrc.json file");const t=c.join(e,".saltyrc.json"),s=await we.readFile(t,"utf-8").then(JSON.parse).catch(()=>{});return s?(O.rcFile=s,s):xe(c.join(e,".."))},fe=async e=>{var n,o;const t=await xe(e),s=(n=t.projects)==null?void 0:n.find(a=>e.endsWith(a.dir||""));return s||((o=t.projects)==null?void 0:o.find(a=>a.dir===t.defaultProject))},He=async e=>{const t=await fe(e),s=await z(e),n=c.join(e,(t==null?void 0:t.configDir)||"","salty.config.ts"),o=c.join(s,"salty.config.js"),a=await Fe(e),i=Pe(n);await Se.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:a,external:i});const m=Date.now(),{config:S}=await import(`${o}?t=${m}`);return{config:S,path:o}},ke=async(e,t)=>{var de,ye;const s=await z(e),n={mediaQueries:[],globalStyles:[],variables:[],templates:[]};await Promise.all([...t].map(async w=>{const{contents:$,outputFilePath:K}=await U(e,w,s);Object.entries($).forEach(([_,P])=>{P.isMedia?n.mediaQueries.push([_,P]):P.isGlobalDefine?n.globalStyles.push(P):P.isDefineVariables?n.variables.push(P):P.isDefineTemplates&&n.templates.push(P._setPath(`${_};;${K}`))})}));const{config:o,path:a}=await He(e),i={...o},{mediaQueries:m}=n;i.mediaQueries=Object.fromEntries(m.map(([w,$])=>[`@${w}`,$]));const S=m.map(([w])=>`'@${w}'`).join(" | "),d=new Set,r=async(w,$=[])=>{if(!w)return[];const K=Object.entries(w).map(async([P,M])=>{const L=async T=>{if(!T)return;if(T instanceof Promise)return await L(await T);if(typeof T=="function")return await L(await T());if(typeof T=="object")return await r(T,[...$,P]);const oe=Ce(P),ie=D.dashCase(P),ae=[...$,oe].join(".");d.add(`"${ae}"`);const Y=[...$.map(D.dashCase),ie].join("-"),ge=Z.parseVariableTokens(T);return ge?`--${Y}: ${ge.transformed};`:`--${Y}: ${T};`};return await L(M)});return(await Promise.all(K)).flat()},g=async w=>{if(!w)return[];const $=Object.entries(w).map(async([_,P])=>{const M=await r(P);return _==="base"?M.join(""):i.mediaQueries[_]?`${i.mediaQueries[_]} { ${M.join("")} }`:`${_} { ${M.join("")} }`});return(await Promise.all($)).flat()},y=async w=>{if(!w)return[];const $=Object.entries(w).map(async([_,P])=>{const M=Object.entries(P).map(async([T,oe])=>{const ie=await r(oe,[_]),ae=`.${_}-${T}, [data-${_}="${T}"]`,Y=ie.join("");return`${ae} { ${Y} }`});return(await Promise.all(M)).flat()});return(await Promise.all($)).flat()},h=w=>({...w,responsive:void 0,conditional:void 0}),p=w=>n.variables.map($=>w==="static"?h($._current):$._current[w]),F=J.mergeObjects(h(o.variables),p("static")),x=await r(F),k=J.mergeObjects((de=o.variables)==null?void 0:de.responsive,p("responsive")),E=await g(k),q=J.mergeObjects((ye=o.variables)==null?void 0:ye.conditional,p("conditional")),A=await y(q),me=c.join(s,"css/_variables.css"),V=`:root { ${x.join("")} ${E.join("")} } ${A.join("")}`;l.writeFileSync(me,V),i.staticVariables=F;const te=c.join(s,"css/_global.css"),u=J.mergeObjects(o.global,n.globalStyles),j=await Z.parseAndJoinStyles(u,"");l.writeFileSync(te,`@layer global { ${j} }`);const b=c.join(s,"css/_reset.css"),C=o.reset==="none"?{}:typeof o.reset=="object"?o.reset:ze,N=await Z.parseAndJoinStyles(C,"");l.writeFileSync(b,`@layer reset { ${N} }`);const v=c.join(s,"css/_templates.css"),R=J.mergeObjects(o.templates,n.templates),W=await je(R),I=Ve(R);l.writeFileSync(v,`@layer templates { ${W} }`),i.templates=R;const X=o.templates?[Oe.defineTemplates(o.templates)._setPath(`config;;${a}`)]:[],se=J.mergeFactories(n.templates,X);i.templatePaths=Object.fromEntries(Object.entries(se).map(([w,$])=>[w,$._path]));const G=c.join(s,"types/css-tokens.d.ts"),De=`
3
3
  // Variable types
4
- type VariableTokens = ${[...m].join("|")};
4
+ type VariableTokens = ${[...d].join("|")};
5
5
  type PropertyValueToken = \`{\${VariableTokens}}\`;
6
6
 
7
7
  // Template types
@@ -12,12 +12,12 @@
12
12
 
13
13
  // Media query types
14
14
  type MediaQueryKeys = ${S||"''"};
15
- `;l.writeFileSync(G,De);const _e=c.join(s,"cache/config-cache.json");l.writeFileSync(_e,JSON.stringify(i,null,2))},he=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const d=i.at(1);if(le.some(m=>d==null?void 0:d.includes(m)))return t}return"styled('div',"}),We=(e,t)=>{try{const s=l.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
15
+ `;l.writeFileSync(G,De);const _e=c.join(s,"cache/config-cache.json");l.writeFileSync(_e,JSON.stringify(i,null,2))},he=e=>e.replace(/styled\(([^"'`{,]+),/g,(t,s)=>{if(/^['"`]/.test(s))return t;const o=new RegExp(`import[^;]*${s}[,\\s{][^;]*from\\s?([^{};]+);`);if(!o.test(e))return t;const i=o.exec(e);if(i){const m=i.at(1);if(le.some(d=>m==null?void 0:m.includes(d)))return t}return"styled('div',"}),We=(e,t)=>{try{const s=l.readFileSync(c.join(t,"saltygen/cache/config-cache.json"),"utf8");return s?`globalThis.saltyConfig = ${s};
16
16
 
17
17
  ${e}`:`globalThis.saltyConfig = {};
18
18
 
19
- ${e}`}catch{return e}},U=async(e,t,s)=>{const n=D.toHash(t),o=c.join(s,"./temp");l.existsSync(o)||l.mkdirSync(o);const a=c.parse(t);let i=l.readFileSync(t,"utf8");i=he(i),i=We(i,e);const d=c.join(s,"js",n+".js"),S=await fe(e),m=c.join(e,(S==null?void 0:S.configDir)||"","salty.config.ts"),r=Pe(m),g=await Fe(e);await Se.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:d,format:g,target:["node20"],keepNames:!0,external:r,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},F=>{const x=l.readFileSync(F.path,"utf8");return{contents:he(x),loader:"ts"}})}}]});const y=Date.now();return{contents:await import(`${d}?t=${y}`),outputFilePath:d}},Ie=async e=>{const t=await z(e),s=c.join(t,"cache/config-cache.json"),n=l.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ue=async e=>{const t=await Ie(e),s=await z(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return J.mergeObjects(a,t)},pe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ge=async(e,t=pe(),s=!0)=>{try{const n=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await z(e),d=c.join(i,"index.css");s&&(()=>{l.existsSync(i)&&Oe.execSync("rm -rf "+i),l.mkdirSync(i,{recursive:!0}),l.mkdirSync(c.join(i,"css")),l.mkdirSync(c.join(i,"types")),l.mkdirSync(c.join(i,"js")),l.mkdirSync(c.join(i,"cache"))})();const m=new Set,r=new Set;async function g(u){const j=["node_modules","saltygen"],b=l.statSync(u);if(b.isDirectory()){const f=l.readdirSync(u);if(j.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>g(c.join(u,N))))}else if(b.isFile()&&ee(u)){m.add(u);const C=l.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&r.add(u)}}await g(e),await ke(e,r);const y={keyframes:[],components:[],classNames:[]};await Promise.all([...m].map(async u=>{const{contents:j}=await U(e,u,i);for(let[b,f]of Object.entries(j))f instanceof Promise&&(f=await f),f.isKeyframes?y.keyframes.push({value:f,src:u,name:b}):f.isClassName?y.classNames.push({...f,src:u,name:b}):f.generator&&y.components.push({...f,src:u,name:b})}));const h=await ue(e);for(const u of y.keyframes){const{value:j}=u,b=`a_${j.animationName}.css`,f=`css/${b}`,C=c.join(i,f);o.push(b),l.writeFileSync(C,j.css)}const p={};for(const u of y.components){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h});a[f.priority]||(a[f.priority]=[]);const C=await f.css;if(!C)continue;a[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=c.join(i,N);l.writeFileSync(O,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}for(const u of y.classNames){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h}),C=await f.css;if(!C)continue;a[f.priority]||(a[f.priority]=[]),a[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,O=c.join(i,N);l.writeFileSync(O,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(p).forEach(([u,j])=>{const b=j.map(R=>`@import url('./${R}');`).join(`
20
- `),f=D.toHash(u,6),C=c.parse(u),N=D.dashCase(C.name),O=c.join(i,`css/f_${N}-${f}.css`);l.writeFileSync(O,b||"/* Empty file */")});const F=o.map(u=>`@import url('./css/${u}');`).join(`
19
+ ${e}`}catch{return e}},U=async(e,t,s)=>{const n=D.toHash(t),o=c.join(s,"./temp");l.existsSync(o)||l.mkdirSync(o);const a=c.parse(t);let i=l.readFileSync(t,"utf8");i=he(i),i=We(i,e);const m=c.join(s,"js",n+".js"),S=await fe(e),d=c.join(e,(S==null?void 0:S.configDir)||"","salty.config.ts"),r=Pe(d),g=await Fe(e);await Se.build({stdin:{contents:i,sourcefile:a.base,resolveDir:a.dir,loader:"tsx"},minify:!1,treeShaking:!0,bundle:!0,outfile:m,format:g,target:["node20"],keepNames:!0,external:r,packages:"external",plugins:[{name:"test",setup:p=>{p.onLoad({filter:/.*\.css|salty|styles|styled\.ts/},F=>{const x=l.readFileSync(F.path,"utf8");return{contents:he(x),loader:"ts"}})}}]});const y=Date.now();return{contents:await import(`${m}?t=${y}`),outputFilePath:m}},Ie=async e=>{const t=await z(e),s=c.join(t,"cache/config-cache.json"),n=l.readFileSync(s,"utf8");if(!n)throw new Error("Could not find config cache file");return JSON.parse(n)},ue=async e=>{const t=await Ie(e),s=await z(e),n=c.join(s,"salty.config.js"),o=Date.now(),{config:a}=await import(`${n}?t=${o}`);return J.mergeObjects(a,t)},pe=()=>{try{return process.env.NODE_ENV==="production"}catch{return!1}},Ge=async(e,t=pe(),s=!0)=>{try{const n=Date.now();t?B.info("Generating CSS in production mode! 🔥"):B.info("Generating CSS in development mode! 🚀");const o=[],a=[],i=await z(e),m=c.join(i,"index.css");s&&(()=>{l.existsSync(i)&&ve.execSync("rm -rf "+i),l.mkdirSync(i,{recursive:!0}),l.mkdirSync(c.join(i,"css")),l.mkdirSync(c.join(i,"types")),l.mkdirSync(c.join(i,"js")),l.mkdirSync(c.join(i,"cache"))})();const d=new Set,r=new Set;async function g(u){const j=["node_modules","saltygen"],b=l.statSync(u);if(b.isDirectory()){const f=l.readdirSync(u);if(j.some(N=>u.includes(N)))return;await Promise.all(f.map(N=>g(c.join(u,N))))}else if(b.isFile()&&ee(u)){d.add(u);const C=l.readFileSync(u,"utf8");/define[\w\d]+\(/.test(C)&&r.add(u)}}await g(e),await ke(e,r);const y={keyframes:[],components:[],classNames:[]};await Promise.all([...d].map(async u=>{const{contents:j}=await U(e,u,i);for(let[b,f]of Object.entries(j))f instanceof Promise&&(f=await f),f.isKeyframes?y.keyframes.push({value:f,src:u,name:b}):f.isClassName?y.classNames.push({...f,src:u,name:b}):f.generator&&y.components.push({...f,src:u,name:b})}));const h=await ue(e);for(const u of y.keyframes){const{value:j}=u,b=`a_${j.animationName}.css`,f=`css/${b}`,C=c.join(i,f);o.push(b),l.writeFileSync(C,j.css)}const p={};for(const u of y.components){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h});a[f.priority]||(a[f.priority]=[]);const C=await f.css;if(!C)continue;a[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,v=c.join(i,N);l.writeFileSync(v,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}for(const u of y.classNames){const{src:j,name:b}=u;p[j]||(p[j]=[]);const f=u.generator._withBuildContext({callerName:b,isProduction:t,config:h}),C=await f.css;if(!C)continue;a[f.priority]||(a[f.priority]=[]),a[f.priority].push(f.cssFileName);const N=`css/${f.cssFileName}`,v=c.join(i,N);l.writeFileSync(v,C),h.importStrategy==="component"&&p[j].push(f.cssFileName)}h.importStrategy==="component"&&Object.entries(p).forEach(([u,j])=>{const b=j.map(R=>`@import url('./${R}');`).join(`
20
+ `),f=D.toHash(u,6),C=c.parse(u),N=D.dashCase(C.name),v=c.join(i,`css/f_${N}-${f}.css`);l.writeFileSync(v,b||"/* Empty file */")});const F=o.map(u=>`@import url('./css/${u}');`).join(`
21
21
  `);let A=`/*!
22
22
  * Generated with Salty CSS (https://salty-css.dev)
23
23
  * Do not edit this file directly
@@ -30,13 +30,13 @@ ${F}`;if(h.importStrategy!=="component"){const u=a.reduce((j,b,f)=>{const C=b.re
30
30
  /*start:${G}-${I}*/
31
31
  ${se}
32
32
  /*end:${G}*/
33
- `},""),N=`l_${f}.css`,O=c.join(i,"css",N),R=`@layer l${f} { ${C}
34
- }`;return l.writeFileSync(O,R),`${j}
35
- @import url('./css/${N}');`},"");A+=u}l.writeFileSync(d,A);const v=Date.now()-n,te=v<200?"🔥":v<500?"🚀":v<1e3?"🎉":v<2e3?"🚗":v<5e3?"🤔":"🥴";B.info(`Generated CSS in ${v}ms! ${te}`)}catch(n){console.error(n)}},Ke=async(e,t,s=pe())=>{try{const n=await z(e);if(ee(t)){const a=[],i=await ue(e),{contents:d}=await U(e,t,n);for(const[S,m]of Object.entries(d)){if(m.isKeyframes&&m.css){const F=`css/${`a_${m.animationName}.css`}`,x=c.join(n,F);l.writeFileSync(x,await m.css);continue}if(m.isClassName){const p=m.generator._withBuildContext({callerName:S,isProduction:s,config:i}),F=await p.css;if(!F)continue;a[p.priority]||(a[p.priority]=[]),a[p.priority].push(p.cssFileName);const x=`css/${p.cssFileName}`,k=c.join(n,x);l.writeFileSync(k,F);continue}if(!m.generator)continue;const r=m.generator._withBuildContext({callerName:S,isProduction:s,config:i}),g=await r.css;if(!g)continue;const y=`css/${r.cssFileName}`,h=c.join(n,y);l.writeFileSync(h,g),a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName)}if(i.importStrategy!=="component")a.forEach((S,m)=>{const r=`l_${m}.css`,g=c.join(n,"css",r);let y=l.readFileSync(g,"utf8");S.forEach(h=>{var k;const p=c.join(n,"css",h),F=((k=/.*-([^-]+)-\d+.css/.exec(h))==null?void 0:k.at(1))||D.toHash(p,6);if(!y.includes(F)){const V=l.readFileSync(p,"utf8"),q=`/*start:${F}-${h}*/
36
- ${V}
33
+ `},""),N=`l_${f}.css`,v=c.join(i,"css",N),R=`@layer l${f} { ${C}
34
+ }`;return l.writeFileSync(v,R),`${j}
35
+ @import url('./css/${N}');`},"");A+=u}l.writeFileSync(m,A);const V=Date.now()-n,te=V<200?"🔥":V<500?"🚀":V<1e3?"🎉":V<2e3?"🚗":V<5e3?"🤔":"🥴";B.info(`Generated CSS in ${V}ms! ${te}`)}catch(n){console.error(n)}},Ke=async(e,t,s=pe())=>{try{const n=await z(e);if(ee(t)){const a=[],i=await ue(e),{contents:m}=await U(e,t,n);for(const[S,d]of Object.entries(m)){if(d.isKeyframes&&d.css){const F=`css/${`a_${d.animationName}.css`}`,x=c.join(n,F);l.writeFileSync(x,await d.css);continue}if(d.isClassName){const p=d.generator._withBuildContext({callerName:S,isProduction:s,config:i}),F=await p.css;if(!F)continue;a[p.priority]||(a[p.priority]=[]),a[p.priority].push(p.cssFileName);const x=`css/${p.cssFileName}`,k=c.join(n,x);l.writeFileSync(k,F);continue}if(!d.generator)continue;const r=d.generator._withBuildContext({callerName:S,isProduction:s,config:i}),g=await r.css;if(!g)continue;const y=`css/${r.cssFileName}`,h=c.join(n,y);l.writeFileSync(h,g),a[r.priority]||(a[r.priority]=[]),a[r.priority].push(r.cssFileName)}if(i.importStrategy!=="component")a.forEach((S,d)=>{const r=`l_${d}.css`,g=c.join(n,"css",r);let y=l.readFileSync(g,"utf8");S.forEach(h=>{var k;const p=c.join(n,"css",h),F=((k=/.*-([^-]+)-\d+.css/.exec(h))==null?void 0:k.at(1))||D.toHash(p,6);if(!y.includes(F)){const E=l.readFileSync(p,"utf8"),q=`/*start:${F}-${h}*/
36
+ ${E}
37
37
  /*end:${F}*/
38
38
  `;y=`${y.replace(/\}$/,"")}
39
39
  ${q}
40
40
  }`}}),l.writeFileSync(g,y)});else{const S=a.flat().map(h=>`@import url('./${h}');`).join(`
41
- `),m=D.toHash(t,6),r=c.parse(t),g=D.dashCase(r.name),y=c.join(n,`css/f_${g}-${m}.css`);l.writeFileSync(y,S||"/* Empty file */")}}}catch(n){console.error(n)}},Le=async(e,t,s=pe())=>{var n,o;try{const a=await z(e);if(ee(t)){const d=l.readFileSync(t,"utf8"),S=await ue(e),{contents:m}=await U(e,t,a);let r=d;for(const[g,y]of Object.entries(m)){if(y.isKeyframes||!y.generator)continue;const h=y.generator._withBuildContext({callerName:g,isProduction:s,config:S}),[p,F]=await qe(r,g),x=r.slice(p,F);if(y.isClassName){const k=r,V=` ${g} = className("${h.classNames}")`;r=r.replace(x,V),k===r&&console.error("Minimize file failed to change content",{name:g})}if(x.includes("styled")){const k=(o=(n=/styled\(([^,]+),/.exec(x))==null?void 0:n.at(1))==null?void 0:o.trim(),V=r,q=` ${g} = styled(${k}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;r=r.replace(x,q),V===r&&console.error("Minimize file failed to change content",{name:g,tagName:k})}}if(S.importStrategy==="component"){const g=D.toHash(t,6),y=c.parse(t);r=`import '../../saltygen/css/${`f_${D.dashCase(y.name)}-${g}.css`}';
41
+ `),d=D.toHash(t,6),r=c.parse(t),g=D.dashCase(r.name),y=c.join(n,`css/f_${g}-${d}.css`);l.writeFileSync(y,S||"/* Empty file */")}}}catch(n){console.error(n)}},Le=async(e,t,s=pe())=>{var n,o;try{const a=await z(e);if(ee(t)){const m=l.readFileSync(t,"utf8"),S=await ue(e),{contents:d}=await U(e,t,a);let r=m;for(const[g,y]of Object.entries(d)){if(y.isKeyframes||!y.generator)continue;const h=y.generator._withBuildContext({callerName:g,isProduction:s,config:S}),[p,F]=await qe(r,g),x=r.slice(p,F);if(y.isClassName){const k=r,E=` ${g} = className("${h.classNames}")`;r=r.replace(x,E),k===r&&console.error("Minimize file failed to change content",{name:g})}if(x.includes("styled")){const k=(o=(n=/styled\(([^,]+),/.exec(x))==null?void 0:n.at(1))==null?void 0:o.trim(),E=r,q=` ${g} = styled(${k}, "${h.classNames}", ${JSON.stringify(h.clientProps)})`;r=r.replace(x,q),E===r&&console.error("Minimize file failed to change content",{name:g,tagName:k})}}if(S.importStrategy==="component"){const g=D.toHash(t,6),y=c.parse(t);r=`import '../../saltygen/css/${`f_${D.dashCase(y.name)}-${g}.css`}';
42
42
  ${r}`}return r=r.replace("@salty-css/react/class-name","@salty-css/react/class-name-client"),r=r.replace("{ styled }","{ styledClient as styled }"),r=r.replace("@salty-css/react/styled","@salty-css/react/styled-client"),r}}catch(a){console.error("Error in minimizeFile:",a)}};exports.compileSaltyFile=U;exports.generateConfigStyles=ke;exports.generateCss=Ge;exports.generateFile=Ke;exports.isSaltyFile=ee;exports.logError=Je;exports.logger=B;exports.minimizeFile=Le;exports.saltyFileExtensions=le;exports.saltyFileRegExp=Ne;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.254",
3
+ "version": "0.0.1-alpha.256",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -0,0 +1,5 @@
1
+ "use strict";const S=require("./dash-case-BJEkFEGQ.cjs"),U=o=>r=>{if(typeof r!="string"||!o)return;let t=r;const l=[];return Object.values(o).forEach(n=>{const{pattern:h,transform:w}=n;t=t.replace(h,v=>{const{value:x,css:E}=w(v);return E&&l.push(E),x})}),{transformed:t,additionalCss:l}},N=o=>r=>typeof r!="string"||!/\{[^{}]+\}/g.test(r)?void 0:{transformed:r.replace(/\{([^{}]+)\}/g,(...n)=>{const h=S.dashCase(n[1].replaceAll(".","-"));return h.startsWith("-")?`-${h}`:`var(--${h})`})},k=N(),q=["top","right","bottom","left","min-width",/.*width.*/,/^[^line]*height.*/,/padding.*/,/margin.*/,/border.*/,/inset.*/,/.*radius.*/,/.*spacing.*/,/.*gap.*/,/.*indent.*/,/.*offset.*/,/.*size.*/,/.*thickness.*/,/.*font-size.*/],J=(o,r,t)=>{if(q.some(n=>typeof n=="string"?n===o:n.test(o))){const n=(t==null?void 0:t.defaultUnit)||"px";return`${r}${n}`}return`${r}`},M=["Webkit","Moz","ms","O"],Q=o=>o.startsWith("-")?o:M.some(r=>o.startsWith(r))?`-${S.dashCase(o)}`:S.dashCase(o),y=async(o,r="",t,l=!1)=>{if(!o)throw new Error("No styles provided to parseStyles function!");const n=new Set,h=Object.entries(o),w=async([f,s])=>{var C;const e=f.trim().replace(/^\?+/g,""),b=Q(e),u=(i,c=";")=>`${b}:${i}${c}`,P={scope:r,config:t};if(typeof s=="function")return w([f,s(P)]);if(s instanceof Promise)return w([f,await s]);if(t!=null&&t.templates&&t.templatePaths[e])try{const[i,c]=t.templatePaths[e].split(";;"),a=await import(c),d=c.includes("salty.config"),p=d?a[i].templates:a[i],$=d?p[e]:p.params[e];if(p&&typeof $=="function"){const j=await $(s),[m]=await y(j,"");return m}}catch(i){console.error(`Error loading template "${e}" from path "${t.templatePaths[e]}"`,i);return}if(t!=null&&t.templates&&t.templates[e]){if(l)return;const c=s.split(".").reduce((a,d)=>a[d],t.templates[e]);if(c){const[a]=await y(c,"");return a}console.warn(`Template "${e}" with path of "${s}" was not found in config!`);return}if(typeof s=="object"){if(!s)return;if(s.isColor)return u(s.toString());if(e==="defaultVariants")return;if(e==="variants"){const a=Object.entries(s);for(const[d,p]of a){if(!p)continue;const $=Object.entries(p);for(const[j,m]of $){if(!m)continue;const O=`${r}.${d}-${j}`;(await y(m,O,t)).forEach(z=>n.add(z))}}return}if(e==="compoundVariants"){for(const a of s){const{css:d,...p}=a,$=Object.entries(p).reduce((m,[O,W])=>`${m}.${O}-${W}`,r);(await y(d,$,t)).forEach(m=>n.add(m))}return}if(e.startsWith("@")){const a=((C=t==null?void 0:t.mediaQueries)==null?void 0:C[e])||e,d=await T(s,r,t),p=`${a} { ${d} }`;n.add(p);return}const i=f.includes("&")?e.replaceAll("&",r):e.startsWith(":")?`${r}${e}`:`${r} ${e}`;(await y(s,i,t)).forEach(a=>n.add(a));return}if(typeof s=="number"){const i=J(b,s,t);return u(i)}if(typeof s!="string")if("toString"in s)s=s.toString();else throw new Error(`Invalid value type for property ${b}`);return u(s)},v=h.map(w),{modifiers:x}=t||{},E=[N(),U(x)],A=(await Promise.all(v).then(f=>Promise.all(f.map(s=>E.reduce(async(e,b)=>{const u=await e;if(!u)return u;const P=await b(u);if(!P)return u;const{transformed:C,additionalCss:i}=P;let c="";if(i)for(const a of i)c+=await T(a,"");return`${c}${C}`},Promise.resolve(s)))))).filter(f=>f!==void 0).join(`
2
+ `);if(!A.trim())return Array.from(n);const V=r?`${r} {
3
+ ${A}
4
+ }`:A;return n.has(V)?Array.from(n):[V,...n]},T=async(o,r,t,l=!1)=>(await y(o,r,t,l)).join(`
5
+ `);exports.parseAndJoinStyles=T;exports.parseVariableTokens=k;