@styleframe/loader 2.1.0 → 2.3.0

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.
package/dist/index.js CHANGED
@@ -2,164 +2,193 @@ import { stat, rm, mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { validateInstanceLicense, getLicenseKeyFromEnv } from "@styleframe/license";
4
4
  import { loadConfig, watchConfig } from "c12";
5
- const N = ["charset", "import", "namespace"], R$1 = ["layer"], D$1 = ({ name: e }) => `[data-theme="${e}"]`, I = ({
5
+ const N = ["charset", "import", "namespace"], L$1 = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, I$1 = ({
6
6
  name: e,
7
7
  value: t,
8
- modifiers: n
9
- }) => `._${[...n, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
10
- function L(e, t) {
8
+ modifiers: r
9
+ }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, w = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
10
+ function U(e, t) {
11
11
  return `@${e}${t ? " " : ""}${t}`;
12
12
  }
13
- const P$1 = /\d/, M$1 = ["-", "_", "/", "."];
14
- function $$1(e = "") {
15
- if (!P$1.test(e))
13
+ const _$1 = /\d/, P$1 = ["-", "_", "/", "."];
14
+ function M(e = "") {
15
+ if (!_$1.test(e))
16
16
  return e !== e.toLowerCase();
17
17
  }
18
- function U$1(e, t) {
19
- const n = M$1, r = [];
18
+ function $$1(e, t) {
19
+ const r = P$1, n = [];
20
20
  if (!e || typeof e != "string")
21
- return r;
22
- let c = "", a, i;
23
- for (const s of e) {
24
- const o = n.includes(s);
25
- if (o === true) {
26
- r.push(c), c = "", a = void 0;
21
+ return n;
22
+ let o = "", s, i;
23
+ for (const a of e) {
24
+ const c = r.includes(a);
25
+ if (c === true) {
26
+ n.push(o), o = "", s = void 0;
27
27
  continue;
28
28
  }
29
- const u = $$1(s);
29
+ const u = M(a);
30
30
  if (i === false) {
31
- if (a === false && u === true) {
32
- r.push(c), c = s, a = u;
31
+ if (s === false && u === true) {
32
+ n.push(o), o = a, s = u;
33
33
  continue;
34
34
  }
35
- if (a === true && u === false && c.length > 1) {
36
- const f = c.at(-1);
37
- r.push(c.slice(0, Math.max(0, c.length - 1))), c = f + s, a = u;
35
+ if (s === true && u === false && o.length > 1) {
36
+ const f = o.at(-1);
37
+ n.push(o.slice(0, Math.max(0, o.length - 1))), o = f + a, s = u;
38
38
  continue;
39
39
  }
40
40
  }
41
- c += s, a = u, i = o;
41
+ o += a, s = u, i = c;
42
42
  }
43
- return r.push(c), r;
43
+ return n.push(o), n;
44
44
  }
45
- function _$1(e, t) {
46
- return e ? (Array.isArray(e) ? e : U$1(e)).map((n) => n.toLowerCase()).join("-") : "";
45
+ function k(e) {
46
+ return e ? e[0].toUpperCase() + e.slice(1) : "";
47
47
  }
48
- function k$1(e) {
48
+ function x$1(e) {
49
+ return e ? e[0].toLowerCase() + e.slice(1) : "";
50
+ }
51
+ function V$1(e, t) {
52
+ return e ? (Array.isArray(e) ? e : $$1(e)).map((r) => k(r)).join("") : "";
53
+ }
54
+ function K(e, t) {
55
+ return x$1(V$1(e || ""));
56
+ }
57
+ function q$1(e, t) {
58
+ return e ? (Array.isArray(e) ? e : $$1(e)).map((r) => r.toLowerCase()).join("-") : "";
59
+ }
60
+ function z$1(e) {
49
61
  return ` ${e}`;
50
62
  }
51
- function V(e) {
63
+ function H(e) {
52
64
  return e.split(`
53
- `).map((t) => k$1(t)).join(`
65
+ `).map((t) => z$1(t)).join(`
54
66
  `);
55
67
  }
56
- function x(e) {
57
- return _$1(e);
68
+ function Q$1(e) {
69
+ return e === e.toUpperCase();
70
+ }
71
+ function Z$1(e) {
72
+ return K(e);
58
73
  }
59
- function K$1(e) {
60
- return x(e);
74
+ function J$1(e) {
75
+ return q$1(e);
61
76
  }
62
- function B$1(e, t) {
63
- return `${e.startsWith("--") ? e : K$1(e)}: ${t};`;
77
+ function W$1(e) {
78
+ return J$1(e);
64
79
  }
65
- function q$1(e) {
80
+ function O(e, t) {
81
+ return `${e.startsWith("--") ? e : W$1(e)}: ${t};`;
82
+ }
83
+ function G$1(e) {
66
84
  return `{${e.length > 0 ? `
67
- ` : ""}${e.map((t) => `${V(`${t}`)}
85
+ ` : ""}${e.map((t) => `${H(`${t}`)}
68
86
  `).join("")}}`;
69
87
  }
70
- function O$1(e) {
88
+ function B(e) {
71
89
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
72
90
  }
73
- function z$1(e, t) {
74
- return B$1(O$1(e), t);
91
+ function Y$1(e, t) {
92
+ return O(B(e), t);
75
93
  }
76
- function H$1(e, t) {
77
- return `var(${O$1(e)}${t ? `, ${t}` : ""})`;
94
+ function X$1(e, t) {
95
+ return `var(${B(e)}${t ? `, ${t}` : ""})`;
78
96
  }
79
- function C$1(e, t) {
80
- return `${e} ${q$1(t)}`;
97
+ function v$1(e, t) {
98
+ return `${e} ${G$1(t)}`;
81
99
  }
82
- function Q$1(e) {
83
- return function(n, r) {
84
- return Object.entries(n).map(([c, a]) => B$1(c, e(a, r)));
100
+ function ee$1(e) {
101
+ return function(r, n) {
102
+ return Object.entries(r).map(([o, s]) => O(o, e(s, n)));
85
103
  };
86
104
  }
87
105
  function E$1(e) {
88
- return function(n, r) {
89
- const a = (r.variables?.name ?? w)({ name: n.name });
90
- return z$1(a, e(n.value, r));
106
+ return function(r, n) {
107
+ const s = (n.variables?.name ?? w)({ name: r.name });
108
+ return Y$1(s, e(r.value, n));
91
109
  };
92
110
  }
93
- function S$1(e) {
94
- const t = E$1(e), n = Q$1(e);
95
- return function(c, a, i) {
96
- const { variables: s, declarations: o, children: u } = a, f = c === ":root", l = (s ?? []).map(
111
+ function C$1(e) {
112
+ const t = E$1(e), r = ee$1(e);
113
+ return function(o, s, i) {
114
+ const { variables: a, declarations: c, children: u } = s, f = o === ":root", l = (a ?? []).map(
97
115
  (A2) => t(A2, i)
98
- ), m2 = n(
99
- o ?? {},
116
+ ), m = r(
117
+ c ?? {},
100
118
  i
101
119
  ), y = (u ?? []).map(
102
120
  (A2) => e(A2, i)
103
- ), d = l.length > 0, h = m2.length > 0, v = y.length > 0;
104
- return f ? `${d || h ? C$1(c, [
121
+ ), p2 = l.length > 0, b = m.length > 0, S2 = y.length > 0;
122
+ return f ? `${p2 || b ? v$1(o, [
105
123
  ...l,
106
- ...d && h ? [""] : [],
107
- ...m2
108
- ]) : ""}${v && (d || h) ? `
124
+ ...p2 && b ? [""] : [],
125
+ ...m
126
+ ]) : ""}${S2 && (p2 || b) ? `
109
127
 
110
128
  ` : ""}${y.join(`
111
129
 
112
- `)}` : C$1(c, [
130
+ `)}` : v$1(o, [
113
131
  ...l,
114
- ...d && (v || h) ? [""] : [],
115
- ...m2,
116
- ...h && v ? [""] : [],
132
+ ...p2 && (S2 || b) ? [""] : [],
133
+ ...m,
134
+ ...b && S2 ? [""] : [],
117
135
  ...y.flatMap(
118
136
  (A2, F2) => F2 === y.length - 1 ? [A2] : [A2, ""]
119
137
  )
120
138
  ]);
121
139
  };
122
140
  }
123
- function Z(e) {
124
- const t = S$1(e);
125
- return function(r, c) {
126
- const a = N.includes(r.identifier), i = R$1.includes(
127
- r.identifier
128
- ), s = Object.keys(r.declarations).length > 0, o = r.variables.length > 0, u = r.children.length > 0, f = L(r.identifier, r.rule);
129
- return a || i && !(s || o || u) ? `${f};` : t(f, r, c);
141
+ function te$1(e) {
142
+ const t = C$1(e);
143
+ return function(n, o) {
144
+ const s = N.includes(n.identifier), i = L$1.includes(
145
+ n.identifier
146
+ ), a = Object.keys(n.declarations).length > 0, c = n.variables.length > 0, u = n.children.length > 0, f = U(n.identifier, n.rule);
147
+ return s || i && !(a || c || u) ? `${f};` : t(f, n, o);
130
148
  };
131
149
  }
132
- function W$1(e) {
150
+ function re$1(e) {
151
+ return function(r, n) {
152
+ return r.value.map((o) => e(o, n)).join("").trim();
153
+ };
154
+ }
155
+ function ne$1(e) {
133
156
  return typeof e == "object" && e !== null;
134
157
  }
135
- function b$1(e, t) {
136
- return W$1(e) && "type" in e && e.type === t;
158
+ function h(e, t) {
159
+ return ne$1(e) && "type" in e && e.type === t;
137
160
  }
138
- function J$1(e) {
139
- return b$1(e, "variable");
161
+ function oe(e) {
162
+ return h(e, "variable");
140
163
  }
141
- function G$1(e) {
142
- return b$1(e, "reference");
164
+ function ce$1(e) {
165
+ return h(e, "reference");
143
166
  }
144
- function Y$1(e) {
145
- return b$1(e, "selector");
167
+ function ue$1(e) {
168
+ return h(e, "selector");
146
169
  }
147
- function X$1(e) {
148
- return b$1(e, "at-rule");
170
+ function ie(e) {
171
+ return h(e, "at-rule");
149
172
  }
150
- function ee(e) {
151
- return b$1(e, "utility");
173
+ function se(e) {
174
+ return h(e, "utility");
152
175
  }
153
- function te(e) {
154
- return b$1(e, "css");
176
+ function ae$1(e) {
177
+ return h(e, "css");
178
+ }
179
+ function le$1(e) {
180
+ return h(e, "theme");
155
181
  }
156
- function ne(e) {
157
- return b$1(e, "theme");
182
+ function T$1(e) {
183
+ return h(e, "root");
158
184
  }
159
- function re(e) {
160
- return b$1(e, "root");
185
+ function fe$1(e) {
186
+ return h(e, "recipe");
161
187
  }
162
- function g$1(e) {
188
+ function me$1(e) {
189
+ return e.charAt(0).toUpperCase() + e.slice(1);
190
+ }
191
+ function g(e) {
163
192
  if (e instanceof Buffer)
164
193
  return Buffer.from(e);
165
194
  const t = e.constructor;
@@ -169,225 +198,245 @@ function g$1(e) {
169
198
  e.byteLength / e.BYTES_PER_ELEMENT || 1
170
199
  );
171
200
  }
172
- function oe(e) {
201
+ function pe$1(e) {
173
202
  if (e = e || {}, e.circular)
174
- return ue$1(e);
203
+ return ye$1(e);
175
204
  const t = /* @__PURE__ */ new Map();
176
205
  if (t.set(Date, (i) => new Date(i)), t.set(
177
206
  Map,
178
- (i, s) => new Map(r(Array.from(i), s))
207
+ (i, a) => new Map(n(Array.from(i), a))
179
208
  ), t.set(
180
209
  Set,
181
- (i, s) => new Set(r(Array.from(i), s))
210
+ (i, a) => new Set(n(Array.from(i), a))
182
211
  ), e.constructorHandlers)
183
212
  for (const i of e.constructorHandlers)
184
213
  t.set(i[0], i[1]);
185
- let n;
186
- return e.proto ? a : c;
187
- function r(i, s) {
188
- const o = Object.keys(i), u = Array.from({ length: o.length });
189
- for (let f = 0; f < o.length; f++) {
190
- const l = o[f], m2 = i[l];
191
- typeof m2 != "object" || m2 === null ? u[l] = m2 : m2.constructor !== Object && (n = t.get(m2.constructor)) ? u[l] = n(m2, s) : ArrayBuffer.isView(m2) ? u[l] = g$1(m2) : u[l] = s(m2);
214
+ let r;
215
+ return e.proto ? s : o;
216
+ function n(i, a) {
217
+ const c = Object.keys(i), u = Array.from({ length: c.length });
218
+ for (let f = 0; f < c.length; f++) {
219
+ const l = c[f], m = i[l];
220
+ typeof m != "object" || m === null ? u[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? u[l] = r(m, a) : ArrayBuffer.isView(m) ? u[l] = g(m) : u[l] = a(m);
192
221
  }
193
222
  return u;
194
223
  }
195
- function c(i) {
224
+ function o(i) {
196
225
  if (typeof i != "object" || i === null) return i;
197
- if (Array.isArray(i)) return r(i, c);
198
- if (i.constructor !== Object && (n = t.get(i.constructor)))
199
- return n(i, c);
200
- const s = {};
201
- for (const o in i) {
202
- if (Object.hasOwnProperty.call(i, o) === false) continue;
203
- const u = i[o];
204
- typeof u != "object" || u === null ? s[o] = u : u.constructor !== Object && (n = t.get(u.constructor)) ? s[o] = n(u, c) : ArrayBuffer.isView(u) ? s[o] = g$1(u) : s[o] = c(u);
226
+ if (Array.isArray(i)) return n(i, o);
227
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
228
+ return r(i, o);
229
+ const a = {};
230
+ for (const c in i) {
231
+ if (Object.hasOwnProperty.call(i, c) === false) continue;
232
+ const u = i[c];
233
+ typeof u != "object" || u === null ? a[c] = u : u.constructor !== Object && (r = t.get(u.constructor)) ? a[c] = r(u, o) : ArrayBuffer.isView(u) ? a[c] = g(u) : a[c] = o(u);
205
234
  }
206
- return s;
235
+ return a;
207
236
  }
208
- function a(i) {
237
+ function s(i) {
209
238
  if (typeof i != "object" || i === null) return i;
210
- if (Array.isArray(i)) return r(i, a);
211
- if (i.constructor !== Object && (n = t.get(i.constructor)))
212
- return n(i, a);
213
- const s = {};
214
- for (const o in i) {
215
- const u = i[o];
216
- typeof u != "object" || u === null ? s[o] = u : u.constructor !== Object && (n = t.get(u.constructor)) ? s[o] = n(u, a) : ArrayBuffer.isView(u) ? s[o] = g$1(u) : s[o] = a(u);
239
+ if (Array.isArray(i)) return n(i, s);
240
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
241
+ return r(i, s);
242
+ const a = {};
243
+ for (const c in i) {
244
+ const u = i[c];
245
+ typeof u != "object" || u === null ? a[c] = u : u.constructor !== Object && (r = t.get(u.constructor)) ? a[c] = r(u, s) : ArrayBuffer.isView(u) ? a[c] = g(u) : a[c] = s(u);
217
246
  }
218
- return s;
247
+ return a;
219
248
  }
220
249
  }
221
- function ue$1(e) {
222
- const t = [], n = [], r = /* @__PURE__ */ new Map();
223
- if (r.set(Date, (o) => new Date(o)), r.set(
250
+ function ye$1(e) {
251
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
252
+ if (n.set(Date, (c) => new Date(c)), n.set(
224
253
  Map,
225
- (o, u) => new Map(a(Array.from(o), u))
226
- ), r.set(
254
+ (c, u) => new Map(s(Array.from(c), u))
255
+ ), n.set(
227
256
  Set,
228
- (o, u) => new Set(a(Array.from(o), u))
257
+ (c, u) => new Set(s(Array.from(c), u))
229
258
  ), e.constructorHandlers)
230
- for (const o of e.constructorHandlers)
231
- r.set(o[0], o[1]);
232
- let c;
233
- return e.proto ? s : i;
234
- function a(o, u) {
235
- const f = Object.keys(o), l = Array.from({ length: f.length });
236
- for (let m2 = 0; m2 < f.length; m2++) {
237
- const y = f[m2], d = o[y];
238
- if (typeof d != "object" || d === null)
239
- l[y] = d;
240
- else if (d.constructor !== Object && (c = r.get(d.constructor)))
241
- l[y] = c(d, u);
242
- else if (ArrayBuffer.isView(d))
243
- l[y] = g$1(d);
259
+ for (const c of e.constructorHandlers)
260
+ n.set(c[0], c[1]);
261
+ let o;
262
+ return e.proto ? a : i;
263
+ function s(c, u) {
264
+ const f = Object.keys(c), l = Array.from({ length: f.length });
265
+ for (let m = 0; m < f.length; m++) {
266
+ const y = f[m], p2 = c[y];
267
+ if (typeof p2 != "object" || p2 === null)
268
+ l[y] = p2;
269
+ else if (p2.constructor !== Object && (o = n.get(p2.constructor)))
270
+ l[y] = o(p2, u);
271
+ else if (ArrayBuffer.isView(p2))
272
+ l[y] = g(p2);
244
273
  else {
245
- const h = t.indexOf(d);
246
- h !== -1 ? l[y] = n[h] : l[y] = u(d);
274
+ const b = t.indexOf(p2);
275
+ b !== -1 ? l[y] = r[b] : l[y] = u(p2);
247
276
  }
248
277
  }
249
278
  return l;
250
279
  }
251
- function i(o) {
252
- if (typeof o != "object" || o === null) return o;
253
- if (Array.isArray(o)) return a(o, i);
254
- if (o.constructor !== Object && (c = r.get(o.constructor)))
255
- return c(o, i);
280
+ function i(c) {
281
+ if (typeof c != "object" || c === null) return c;
282
+ if (Array.isArray(c)) return s(c, i);
283
+ if (c.constructor !== Object && (o = n.get(c.constructor)))
284
+ return o(c, i);
256
285
  const u = {};
257
- t.push(o), n.push(u);
258
- for (const f in o) {
259
- if (Object.hasOwnProperty.call(o, f) === false) continue;
260
- const l = o[f];
286
+ t.push(c), r.push(u);
287
+ for (const f in c) {
288
+ if (Object.hasOwnProperty.call(c, f) === false) continue;
289
+ const l = c[f];
261
290
  if (typeof l != "object" || l === null)
262
291
  u[f] = l;
263
- else if (l.constructor !== Object && (c = r.get(l.constructor)))
264
- u[f] = c(l, i);
292
+ else if (l.constructor !== Object && (o = n.get(l.constructor)))
293
+ u[f] = o(l, i);
265
294
  else if (ArrayBuffer.isView(l))
266
- u[f] = g$1(l);
295
+ u[f] = g(l);
267
296
  else {
268
- const m2 = t.indexOf(l);
269
- m2 !== -1 ? u[f] = n[m2] : u[f] = i(l);
297
+ const m = t.indexOf(l);
298
+ m !== -1 ? u[f] = r[m] : u[f] = i(l);
270
299
  }
271
300
  }
272
- return t.pop(), n.pop(), u;
301
+ return t.pop(), r.pop(), u;
273
302
  }
274
- function s(o) {
275
- if (typeof o != "object" || o === null) return o;
276
- if (Array.isArray(o)) return a(o, s);
277
- if (o.constructor !== Object && (c = r.get(o.constructor)))
278
- return c(o, s);
303
+ function a(c) {
304
+ if (typeof c != "object" || c === null) return c;
305
+ if (Array.isArray(c)) return s(c, a);
306
+ if (c.constructor !== Object && (o = n.get(c.constructor)))
307
+ return o(c, a);
279
308
  const u = {};
280
- t.push(o), n.push(u);
281
- for (const f in o) {
282
- const l = o[f];
309
+ t.push(c), r.push(u);
310
+ for (const f in c) {
311
+ const l = c[f];
283
312
  if (typeof l != "object" || l === null)
284
313
  u[f] = l;
285
- else if (l.constructor !== Object && (c = r.get(l.constructor)))
286
- u[f] = c(l, s);
314
+ else if (l.constructor !== Object && (o = n.get(l.constructor)))
315
+ u[f] = o(l, a);
287
316
  else if (ArrayBuffer.isView(l))
288
- u[f] = g$1(l);
317
+ u[f] = g(l);
289
318
  else {
290
- const m2 = t.indexOf(l);
291
- m2 !== -1 ? u[f] = n[m2] : u[f] = s(l);
319
+ const m = t.indexOf(l);
320
+ m !== -1 ? u[f] = r[m] : u[f] = a(l);
292
321
  }
293
322
  }
294
- return t.pop(), n.pop(), u;
323
+ return t.pop(), r.pop(), u;
295
324
  }
296
325
  }
297
- oe();
298
- function ce(e) {
299
- return function(n, r) {
300
- return n.value.map((c) => e(c, r)).join("").trim();
301
- };
302
- }
303
- function ie(e) {
304
- return function(n, r) {
305
- return n != null ? `${n}` : "";
326
+ pe$1();
327
+ function de$1(e) {
328
+ return function(r, n) {
329
+ return r != null ? `${r}` : "";
306
330
  };
307
331
  }
308
- function se(e) {
309
- return function(n, r) {
310
- const a = (r.variables?.name ?? w)({ name: n.name });
311
- return H$1(
312
- a,
313
- n.fallback ? e(n.fallback, r) : void 0
332
+ function he(e) {
333
+ return function(r, n) {
334
+ const s = (n.variables?.name ?? w)({ name: r.name });
335
+ return X$1(
336
+ s,
337
+ r.fallback ? e(r.fallback, n) : void 0
314
338
  );
315
339
  };
316
340
  }
317
- function ae(e) {
318
- const t = S$1(e);
319
- return function(r, c) {
320
- return r.themes.reduce(
321
- (a, i) => (a.push(e(i, c)), a),
322
- [t(":root", r, c)]
341
+ function be(e) {
342
+ const t = C$1(e);
343
+ return function(n, o) {
344
+ return n.themes.reduce(
345
+ (s, i) => (s.push(e(i, o)), s),
346
+ [t(":root", n, o)]
323
347
  // Default theme (root)
324
348
  ).join(`
325
349
 
326
350
  `);
327
351
  };
328
352
  }
329
- function le(e) {
330
- const t = S$1(e);
331
- return function(r, c) {
332
- return t(r.query, r, c);
353
+ function Ae(e) {
354
+ const t = C$1(e);
355
+ return function(n, o) {
356
+ return t(n.query, n, o);
333
357
  };
334
358
  }
335
- function fe(e) {
336
- const t = S$1(e);
337
- return function(r, c) {
338
- const i = (c.theme?.selector ?? D$1)({ name: r.name });
339
- return t(i, r, c);
359
+ function ge(e) {
360
+ const t = C$1(e);
361
+ return function(n, o) {
362
+ const i = (o.themes?.selector ?? D)({ name: n.name });
363
+ return t(i, n, o);
340
364
  };
341
365
  }
342
- function me(e) {
343
- const t = S$1(e);
344
- return function(r, c) {
345
- const a = [], s = (c.utilities?.selector ?? I)({
346
- name: r.name,
347
- value: r.value,
348
- modifiers: r.modifiers
366
+ function Ce(e) {
367
+ const t = C$1(e);
368
+ return function(n, o) {
369
+ const s = [], a = (o.utilities?.selector ?? I$1)({
370
+ name: n.name,
371
+ value: n.value,
372
+ modifiers: n.modifiers
349
373
  });
350
- return a.push(t(s, r, c)), a.join(`
374
+ return s.push(t(a, n, o)), s.join(`
351
375
 
352
376
  `);
353
377
  };
354
378
  }
355
- function p$1(e, t) {
356
- const n = ae(p$1), r = le(p$1), c = me(p$1), a = Z(p$1), i = fe(p$1), s = E$1(p$1), o = se(p$1), u = ce(p$1), f = ie();
379
+ function d(e, t) {
380
+ const r = be(d), n = Ae(d), o = Ce(d), s = te$1(d), i = ge(d), a = E$1(d), c = he(d), u = re$1(d), f = de$1();
357
381
  switch (true) {
358
- case Y$1(e):
359
- return r(e, t);
360
- case ee(e):
361
- return c(e, t);
362
- case X$1(e):
363
- return a(e, t);
364
- case re(e):
382
+ case ue$1(e):
365
383
  return n(e, t);
366
- case ne(e):
367
- return i(e, t);
368
- case J$1(e):
369
- return s(e, t);
370
- case G$1(e):
384
+ case se(e):
371
385
  return o(e, t);
372
- case te(e):
386
+ case ie(e):
387
+ return s(e, t);
388
+ case T$1(e):
389
+ return r(e, t);
390
+ case le$1(e):
391
+ return i(e, t);
392
+ case oe(e):
393
+ return a(e, t);
394
+ case ce$1(e):
395
+ return c(e, t);
396
+ case ae$1(e):
373
397
  return u(e, t);
374
398
  default:
375
399
  return f(e, t);
376
400
  }
377
401
  }
378
- function T$1(e, t) {
402
+ function Se(e) {
403
+ return function(r, n) {
404
+ let o = Z$1(r.name);
405
+ r.name[0] && Q$1(r.name[0]) && (o = me$1(o));
406
+ const s = `${o}Recipe`, i = r._runtime ?? {};
407
+ return `const ${s} = ${JSON.stringify(
408
+ i,
409
+ null,
410
+ 4
411
+ )} as const satisfies RecipeRuntime;
412
+
413
+ export const ${o} = createRecipe("${r.name}", ${s});
414
+ `;
415
+ };
416
+ }
417
+ function je(e) {
418
+ return function(r, n) {
419
+ return r.recipes.length > 0 ? `import { createRecipe } from '@styleframe/runtime';
420
+ import type { RecipeRuntime } from '@styleframe/runtime';
421
+
422
+ ${e(r.recipes, n)}` : "";
423
+ };
424
+ }
425
+ function j$1(e, t) {
426
+ const r = je(j$1), n = Se();
379
427
  switch (true) {
380
428
  case Array.isArray(e):
381
- return e.map((n) => T$1(n)).join(`
429
+ return e.map((o) => j$1(o, t)).join(`
382
430
  `);
383
- // case isRecipe(instance):
384
- // return consumeRecipe(instance, options);
385
- // break;
431
+ case T$1(e):
432
+ return r(e, t);
433
+ case fe$1(e):
434
+ return n(e, t);
386
435
  default:
387
436
  return "";
388
437
  }
389
438
  }
390
- const de = `-----BEGIN PUBLIC KEY-----
439
+ const ve = `-----BEGIN PUBLIC KEY-----
391
440
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
392
441
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
393
442
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -395,12 +444,12 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
395
444
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
396
445
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
397
446
  GwIDAQAB
398
- -----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
399
- async function he(e) {
400
- const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), n = Uint8Array.from(atob(t), (r) => r.charCodeAt(0));
447
+ -----END PUBLIC KEY-----`, Re$1 = "__licenseRequired", we = "__licenseValidated";
448
+ async function $e(e) {
449
+ const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
401
450
  return await crypto.subtle.importKey(
402
451
  "spki",
403
- n,
452
+ r,
404
453
  {
405
454
  name: "RSASSA-PKCS1-v1_5",
406
455
  hash: "SHA-256"
@@ -409,32 +458,32 @@ async function he(e) {
409
458
  ["verify"]
410
459
  );
411
460
  }
412
- async function be({
461
+ async function Oe({
413
462
  payload: e,
414
463
  signature: t
415
464
  }) {
416
- const n = new TextEncoder().encode(e), r = Uint8Array.from(
465
+ const r = new TextEncoder().encode(e), n = Uint8Array.from(
417
466
  atob(t),
418
- (a) => a.charCodeAt(0)
419
- ), c = await he(de);
467
+ (s) => s.charCodeAt(0)
468
+ ), o = await $e(ve);
420
469
  if (!await crypto.subtle.verify(
421
470
  { name: "RSASSA-PKCS1-v1_5" },
422
- c,
423
- r,
424
- n
471
+ o,
472
+ n,
473
+ r
425
474
  ))
426
475
  throw new Error(
427
476
  "License validation failed: Invalid signature detected. The license may have been modified or corrupted."
428
477
  );
429
478
  return JSON.parse(e);
430
479
  }
431
- function Ae(e) {
432
- return Object.prototype.hasOwnProperty.call(e, ye);
480
+ function Be(e) {
481
+ return Object.prototype.hasOwnProperty.call(e, Re$1);
433
482
  }
434
- async function ge(e) {
483
+ async function Ee(e) {
435
484
  const t = Object.getOwnPropertyDescriptor(
436
485
  e,
437
- pe
486
+ we
438
487
  );
439
488
  if (!t?.value)
440
489
  return {
@@ -443,8 +492,8 @@ async function ge(e) {
443
492
  environment: "",
444
493
  valid: false
445
494
  };
446
- const n = t.value;
447
- if (typeof n != "object" || n === null || !("payload" in n) || !("signature" in n) || typeof n.payload != "string" || typeof n.signature != "string")
495
+ const r = t.value;
496
+ if (typeof r != "object" || r === null || !("payload" in r) || !("signature" in r) || typeof r.payload != "string" || typeof r.signature != "string")
448
497
  return {
449
498
  key: "",
450
499
  instanceId: "",
@@ -452,8 +501,8 @@ async function ge(e) {
452
501
  valid: false
453
502
  };
454
503
  try {
455
- return await be(
456
- n
504
+ return await Oe(
505
+ r
457
506
  );
458
507
  } catch {
459
508
  return {
@@ -464,7 +513,7 @@ async function ge(e) {
464
513
  };
465
514
  }
466
515
  }
467
- function Se(e) {
516
+ function Te(e) {
468
517
  const t = Math.floor(Math.random() * 100);
469
518
  e.root.children.push({
470
519
  type: "selector",
@@ -488,31 +537,36 @@ function Se(e) {
488
537
  }
489
538
  });
490
539
  }
491
- function j(e, t = "") {
540
+ function R$1(e, t = "") {
492
541
  return {
493
542
  name: e,
494
543
  content: t
495
544
  };
496
545
  }
497
- async function Ce(e, {
546
+ async function Ne(e, {
498
547
  type: t = "all",
499
- consumers: n = { css: p$1, ts: T$1 }
548
+ consumers: r = { css: d, ts: j$1 }
500
549
  } = {}) {
501
- const r = { files: [] }, c = e.options;
502
- if (Ae(e)) {
503
- const s = await ge(e);
504
- (!s.valid || s.instanceId !== e.id) && Se(e);
550
+ const n = { files: [] }, o = e.options;
551
+ if (Be(e)) {
552
+ const s = await Ee(e);
553
+ (!s.valid || s.instanceId !== e.id) && Te(e);
505
554
  }
506
- const { recipes: a, ...i } = e.root;
507
555
  if (t === "all" || t === "css") {
508
- const s = j("index.css", n.css(i, c));
509
- r.files.push(s);
556
+ const s = R$1(
557
+ "index.css",
558
+ r.css(e.root, o)
559
+ );
560
+ n.files.push(s);
510
561
  }
511
562
  if (t === "all" || t === "ts") {
512
- const s = j("index.ts", n.ts([], c));
513
- r.files.push(s);
563
+ const s = R$1(
564
+ "index.ts",
565
+ r.ts(e.root, o)
566
+ );
567
+ n.files.push(s);
514
568
  }
515
- return r;
569
+ return n;
516
570
  }
517
571
  async function directoryExists(path2) {
518
572
  try {
@@ -528,7 +582,7 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
528
582
  environment: process.env.NODE_ENV || "development",
529
583
  isBuild: true
530
584
  });
531
- const output = await Ce(instance, transpiler);
585
+ const output = await Ne(instance, transpiler);
532
586
  const outputDirExists = await directoryExists(outputDir);
533
587
  if (clean && outputDirExists) {
534
588
  await rm(outputDir, { recursive: true });
@@ -543,40 +597,58 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
543
597
  await writeFile(filePath, file.content);
544
598
  }
545
599
  }
546
- function k(e, r) {
547
- return function(t, ...i) {
548
- return {
549
- type: "css",
550
- value: t.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
551
- };
552
- };
553
- }
554
- function M(e) {
600
+ function S(e) {
555
601
  return typeof e == "object" && e !== null;
556
602
  }
557
603
  function p(e, r) {
558
- return M(e) && "type" in e && e.type === r;
604
+ return S(e) && "type" in e && e.type === r;
559
605
  }
560
- function B(e) {
606
+ function L(e) {
561
607
  return p(e, "variable");
562
608
  }
563
- function F(e) {
609
+ function A(e) {
564
610
  return p(e, "reference");
565
611
  }
566
- function T(e) {
612
+ function q(e) {
613
+ return p(e, "modifier");
614
+ }
615
+ function E(e) {
567
616
  return p(e, "css");
568
617
  }
569
- function _(e) {
618
+ function G(e) {
570
619
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
571
620
  }
572
- function O(e) {
573
- return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(O);
621
+ function $(e) {
622
+ return G(e) || A(e) || E(e) || Array.isArray(e) && e.every($);
623
+ }
624
+ function I(e) {
625
+ return S(e) && "children" in e && "declarations" in e && "variables" in e;
626
+ }
627
+ function z(e = (r) => r) {
628
+ return (r) => {
629
+ let n = r, t;
630
+ if (typeof n == "string" && n[0] === "@") {
631
+ const i = n.slice(1);
632
+ t = e(i), n = {
633
+ type: "reference",
634
+ name: i
635
+ };
636
+ } else A(n) ? t = e(n.name) : t = `[${r}]`;
637
+ return {
638
+ [t]: n
639
+ };
640
+ };
574
641
  }
575
- function C(e) {
576
- return M(e) && "children" in e && "declarations" in e && "variables" in e;
642
+ function W(e, r) {
643
+ return function(t, ...i) {
644
+ return {
645
+ type: "css",
646
+ value: t.reduce((o, u, s) => (o.push(u), s < i.length && o.push(i[s]), o), [])
647
+ };
648
+ };
577
649
  }
578
- function R(e, r) {
579
- return function(t, i, s) {
650
+ function C(e, r) {
651
+ return function(t, i, c) {
580
652
  const o = {
581
653
  type: "at-rule",
582
654
  identifier: t,
@@ -584,25 +656,25 @@ function R(e, r) {
584
656
  declarations: {},
585
657
  variables: [],
586
658
  children: []
587
- }, u = b(o, r);
588
- return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
659
+ }, u = v(o, r);
660
+ return typeof c == "function" ? o.declarations = c(u) ?? {} : c && (o.declarations = c), V(o.declarations, u), e.children.push(o), o;
589
661
  };
590
662
  }
591
- function S(e, r) {
592
- const n = R(e, r);
593
- return function(i, s) {
594
- return n("media", i, s);
663
+ function Y(e, r) {
664
+ const n = C(e, r);
665
+ return function(i, c) {
666
+ return n("media", i, c);
595
667
  };
596
668
  }
597
- function E(e, r) {
598
- const n = R(e, r);
599
- return function(i, s) {
600
- return n("keyframes", i, s);
669
+ function Z(e, r) {
670
+ const n = C(e, r);
671
+ return function(i, c) {
672
+ return n("keyframes", i, c);
601
673
  };
602
674
  }
603
- function P(e, r) {
675
+ function J(e, r) {
604
676
  return function(t, i) {
605
- return B(t) ? {
677
+ return L(t) ? {
606
678
  type: "reference",
607
679
  name: t.name,
608
680
  fallback: i
@@ -613,56 +685,56 @@ function P(e, r) {
613
685
  };
614
686
  };
615
687
  }
616
- function D(e, r) {
688
+ function Q(e, r) {
617
689
  return function(t, i) {
618
- const s = {
690
+ const c = {
619
691
  type: "selector",
620
692
  query: t,
621
693
  declarations: {},
622
694
  variables: [],
623
695
  children: []
624
- }, o = b(s, r);
625
- return typeof i == "function" ? s.declarations = i(o) ?? {} : C(i) ? (s.variables = i.variables, s.declarations = i.declarations, s.children = i.children) : s.declarations = i, g(s.declarations, o), e.children.push(s), s;
696
+ }, o = v(c, r);
697
+ return typeof i == "function" ? c.declarations = i(o) ?? {} : I(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, V(c.declarations, o), e.children.push(c), c;
626
698
  };
627
699
  }
628
- function H(e, r) {
629
- return function(t, i, s = {
700
+ function X(e, r) {
701
+ return function(t, i, c = {
630
702
  default: false
631
703
  }) {
632
704
  const o = typeof t == "string" ? t : t.name, u = e.variables.find(
633
705
  (f) => f.name === o
634
706
  );
635
- if (s.default && u)
707
+ if (c.default && u)
636
708
  return u;
637
709
  if (u)
638
710
  return u.value = i, u;
639
- const c = {
711
+ const s = {
640
712
  type: "variable",
641
713
  name: o,
642
714
  value: i
643
715
  };
644
- return e.variables.push(c), c;
716
+ return e.variables.push(s), s;
645
717
  };
646
718
  }
647
- function b(e, r) {
648
- const n = H(e), t = D(e, r), i = R(e, r), s = E(r, r), o = S(e, r), u = P(), c = k();
719
+ function v(e, r) {
720
+ const n = X(e), t = Q(e, r), i = C(e, r), c = Z(r, r), o = Y(e, r), u = J(), s = W();
649
721
  return {
650
722
  variable: n,
651
723
  selector: t,
652
- keyframes: s,
724
+ keyframes: c,
653
725
  atRule: i,
654
726
  media: o,
655
727
  ref: u,
656
- css: c
728
+ css: s
657
729
  };
658
730
  }
659
- function g(e, r) {
731
+ function V(e, r) {
660
732
  for (const n in e)
661
733
  if (n.startsWith("@")) {
662
734
  const t = e[n];
663
- if (typeof t == "object" && t !== null && !O(t)) {
664
- const i = n.replace(/^@(\w+).*/, "$1"), s = n.replace(`@${i}`, "").trim();
665
- r.atRule(i, s, t), delete e[n];
735
+ if (typeof t == "object" && t !== null && !$(t)) {
736
+ const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
737
+ r.atRule(i, c, t), delete e[n];
666
738
  }
667
739
  } else if (/^[.&:]/.test(n)) {
668
740
  const t = e[n];
@@ -670,7 +742,7 @@ function g(e, r) {
670
742
  }
671
743
  return e;
672
744
  }
673
- function m(e) {
745
+ function j(e) {
674
746
  if (e instanceof Buffer)
675
747
  return Buffer.from(e);
676
748
  const r = e.constructor;
@@ -680,9 +752,9 @@ function m(e) {
680
752
  e.byteLength / e.BYTES_PER_ELEMENT || 1
681
753
  );
682
754
  }
683
- function K(e) {
755
+ function ee(e) {
684
756
  if (e = e || {}, e.circular)
685
- return U(e);
757
+ return te(e);
686
758
  const r = /* @__PURE__ */ new Map();
687
759
  if (r.set(Date, (o) => new Date(o)), r.set(
688
760
  Map,
@@ -694,12 +766,12 @@ function K(e) {
694
766
  for (const o of e.constructorHandlers)
695
767
  r.set(o[0], o[1]);
696
768
  let n;
697
- return e.proto ? s : i;
769
+ return e.proto ? c : i;
698
770
  function t(o, u) {
699
- const c = Object.keys(o), f = Array.from({ length: c.length });
700
- for (let a = 0; a < c.length; a++) {
701
- const l = c[a], y = o[l];
702
- typeof y != "object" || y === null ? f[l] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[l] = n(y, u) : ArrayBuffer.isView(y) ? f[l] = m(y) : f[l] = u(y);
771
+ const s = Object.keys(o), f = Array.from({ length: s.length });
772
+ for (let l = 0; l < s.length; l++) {
773
+ const a = s[l], y = o[a];
774
+ typeof y != "object" || y === null ? f[a] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[a] = n(y, u) : ArrayBuffer.isView(y) ? f[a] = j(y) : f[a] = u(y);
703
775
  }
704
776
  return f;
705
777
  }
@@ -709,153 +781,161 @@ function K(e) {
709
781
  if (o.constructor !== Object && (n = r.get(o.constructor)))
710
782
  return n(o, i);
711
783
  const u = {};
712
- for (const c in o) {
713
- if (Object.hasOwnProperty.call(o, c) === false) continue;
714
- const f = o[c];
715
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, i) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = i(f);
784
+ for (const s in o) {
785
+ if (Object.hasOwnProperty.call(o, s) === false) continue;
786
+ const f = o[s];
787
+ typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[s] = n(f, i) : ArrayBuffer.isView(f) ? u[s] = j(f) : u[s] = i(f);
716
788
  }
717
789
  return u;
718
790
  }
719
- function s(o) {
791
+ function c(o) {
720
792
  if (typeof o != "object" || o === null) return o;
721
- if (Array.isArray(o)) return t(o, s);
793
+ if (Array.isArray(o)) return t(o, c);
722
794
  if (o.constructor !== Object && (n = r.get(o.constructor)))
723
- return n(o, s);
795
+ return n(o, c);
724
796
  const u = {};
725
- for (const c in o) {
726
- const f = o[c];
727
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
797
+ for (const s in o) {
798
+ const f = o[s];
799
+ typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[s] = n(f, c) : ArrayBuffer.isView(f) ? u[s] = j(f) : u[s] = c(f);
728
800
  }
729
801
  return u;
730
802
  }
731
803
  }
732
- function U(e) {
804
+ function te(e) {
733
805
  const r = [], n = [], t = /* @__PURE__ */ new Map();
734
- if (t.set(Date, (c) => new Date(c)), t.set(
806
+ if (t.set(Date, (s) => new Date(s)), t.set(
735
807
  Map,
736
- (c, f) => new Map(s(Array.from(c), f))
808
+ (s, f) => new Map(c(Array.from(s), f))
737
809
  ), t.set(
738
810
  Set,
739
- (c, f) => new Set(s(Array.from(c), f))
811
+ (s, f) => new Set(c(Array.from(s), f))
740
812
  ), e.constructorHandlers)
741
- for (const c of e.constructorHandlers)
742
- t.set(c[0], c[1]);
813
+ for (const s of e.constructorHandlers)
814
+ t.set(s[0], s[1]);
743
815
  let i;
744
816
  return e.proto ? u : o;
745
- function s(c, f) {
746
- const a = Object.keys(c), l = Array.from({ length: a.length });
747
- for (let y = 0; y < a.length; y++) {
748
- const h = a[y], d = c[h];
749
- if (typeof d != "object" || d === null)
750
- l[h] = d;
751
- else if (d.constructor !== Object && (i = t.get(d.constructor)))
752
- l[h] = i(d, f);
753
- else if (ArrayBuffer.isView(d))
754
- l[h] = m(d);
817
+ function c(s, f) {
818
+ const l = Object.keys(s), a = Array.from({ length: l.length });
819
+ for (let y = 0; y < l.length; y++) {
820
+ const m = l[y], d2 = s[m];
821
+ if (typeof d2 != "object" || d2 === null)
822
+ a[m] = d2;
823
+ else if (d2.constructor !== Object && (i = t.get(d2.constructor)))
824
+ a[m] = i(d2, f);
825
+ else if (ArrayBuffer.isView(d2))
826
+ a[m] = j(d2);
755
827
  else {
756
- const v = r.indexOf(d);
757
- v !== -1 ? l[h] = n[v] : l[h] = f(d);
828
+ const h2 = r.indexOf(d2);
829
+ h2 !== -1 ? a[m] = n[h2] : a[m] = f(d2);
758
830
  }
759
831
  }
760
- return l;
832
+ return a;
761
833
  }
762
- function o(c) {
763
- if (typeof c != "object" || c === null) return c;
764
- if (Array.isArray(c)) return s(c, o);
765
- if (c.constructor !== Object && (i = t.get(c.constructor)))
766
- return i(c, o);
834
+ function o(s) {
835
+ if (typeof s != "object" || s === null) return s;
836
+ if (Array.isArray(s)) return c(s, o);
837
+ if (s.constructor !== Object && (i = t.get(s.constructor)))
838
+ return i(s, o);
767
839
  const f = {};
768
- r.push(c), n.push(f);
769
- for (const a in c) {
770
- if (Object.hasOwnProperty.call(c, a) === false) continue;
771
- const l = c[a];
772
- if (typeof l != "object" || l === null)
773
- f[a] = l;
774
- else if (l.constructor !== Object && (i = t.get(l.constructor)))
775
- f[a] = i(l, o);
776
- else if (ArrayBuffer.isView(l))
777
- f[a] = m(l);
840
+ r.push(s), n.push(f);
841
+ for (const l in s) {
842
+ if (Object.hasOwnProperty.call(s, l) === false) continue;
843
+ const a = s[l];
844
+ if (typeof a != "object" || a === null)
845
+ f[l] = a;
846
+ else if (a.constructor !== Object && (i = t.get(a.constructor)))
847
+ f[l] = i(a, o);
848
+ else if (ArrayBuffer.isView(a))
849
+ f[l] = j(a);
778
850
  else {
779
- const y = r.indexOf(l);
780
- y !== -1 ? f[a] = n[y] : f[a] = o(l);
851
+ const y = r.indexOf(a);
852
+ y !== -1 ? f[l] = n[y] : f[l] = o(a);
781
853
  }
782
854
  }
783
855
  return r.pop(), n.pop(), f;
784
856
  }
785
- function u(c) {
786
- if (typeof c != "object" || c === null) return c;
787
- if (Array.isArray(c)) return s(c, u);
788
- if (c.constructor !== Object && (i = t.get(c.constructor)))
789
- return i(c, u);
857
+ function u(s) {
858
+ if (typeof s != "object" || s === null) return s;
859
+ if (Array.isArray(s)) return c(s, u);
860
+ if (s.constructor !== Object && (i = t.get(s.constructor)))
861
+ return i(s, u);
790
862
  const f = {};
791
- r.push(c), n.push(f);
792
- for (const a in c) {
793
- const l = c[a];
794
- if (typeof l != "object" || l === null)
795
- f[a] = l;
796
- else if (l.constructor !== Object && (i = t.get(l.constructor)))
797
- f[a] = i(l, u);
798
- else if (ArrayBuffer.isView(l))
799
- f[a] = m(l);
863
+ r.push(s), n.push(f);
864
+ for (const l in s) {
865
+ const a = s[l];
866
+ if (typeof a != "object" || a === null)
867
+ f[l] = a;
868
+ else if (a.constructor !== Object && (i = t.get(a.constructor)))
869
+ f[l] = i(a, u);
870
+ else if (ArrayBuffer.isView(a))
871
+ f[l] = j(a);
800
872
  else {
801
- const y = r.indexOf(l);
802
- y !== -1 ? f[a] = n[y] : f[a] = u(l);
873
+ const y = r.indexOf(a);
874
+ y !== -1 ? f[l] = n[y] : f[l] = u(a);
803
875
  }
804
876
  }
805
877
  return r.pop(), n.pop(), f;
806
878
  }
807
879
  }
808
- const A = K();
809
- function $(e, r = 8) {
880
+ const R = ee();
881
+ function ne(e, r = 8) {
810
882
  const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
811
883
  let t = "";
812
884
  for (let i = 0; i < r; i++) {
813
- const s = Math.floor(Math.random() * n.length);
814
- t += n[s];
885
+ const c = Math.floor(Math.random() * n.length);
886
+ t += n[c];
815
887
  }
816
888
  return e ? `${e}${t}` : t;
817
889
  }
818
- function q(e) {
890
+ function re(e, r) {
891
+ const n = e.modifiers.find(
892
+ (t) => t.key.includes(r)
893
+ );
894
+ if (!n)
895
+ throw new Error(`Modifier "${r}" not found`);
896
+ return n;
897
+ }
898
+ function ce(e) {
819
899
  const r = [];
820
900
  function n(t, i) {
821
901
  i.length > 0 && r.push([...i].sort());
822
- for (let s = t; s < e.length; s++) {
823
- const o = e[s];
902
+ for (let c = t; c < e.length; c++) {
903
+ const o = e[c];
824
904
  if (o)
825
905
  if (o.length === 1 && o[0])
826
- n(s + 1, [...i, o[0]]);
906
+ n(c + 1, [...i, o[0]]);
827
907
  else
828
908
  for (const u of o)
829
- n(s + 1, [...i, u]);
909
+ n(c + 1, [...i, u]);
830
910
  }
831
911
  }
832
912
  return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
833
913
  }
834
- function z(e, r, n) {
914
+ function fe(e, r, n) {
835
915
  const t = {
836
916
  ...e,
837
917
  modifiers: [...n.keys()]
838
- }, i = b(t, r);
839
- for (const s of n.values())
840
- s.factory({
918
+ }, i = v(t, r);
919
+ for (const c of n.values())
920
+ c.factory({
841
921
  ...i,
842
- declarations: A(t.declarations),
843
- variables: A(t.variables),
844
- children: A(t.children)
845
- }), g(t.declarations, i);
922
+ declarations: R(t.declarations),
923
+ variables: R(t.variables),
924
+ children: R(t.children)
925
+ }), V(t.declarations, i);
846
926
  return t;
847
927
  }
848
- function W(e, r) {
928
+ function ue(e, r) {
849
929
  return function(t, i) {
850
- const s = {
930
+ const c = {
851
931
  type: "modifier",
852
932
  key: Array.isArray(t) ? t : [t],
853
933
  factory: i
854
934
  };
855
- return r.modifiers.push(s), s;
935
+ return r.modifiers.push(c), c;
856
936
  };
857
937
  }
858
- function Y() {
938
+ function ae() {
859
939
  return {
860
940
  type: "root",
861
941
  declarations: {},
@@ -867,111 +947,243 @@ function Y() {
867
947
  themes: []
868
948
  };
869
949
  }
870
- function G(e, r, n) {
871
- const t = r.map((s) => s.key);
872
- return q(t).map((s) => {
873
- const o = /* @__PURE__ */ new Map();
874
- for (const u of s) {
875
- const c = r.find(
876
- (f) => f.key.includes(u)
877
- );
878
- c && o.set(u, c);
879
- }
880
- return z(e, n, o);
881
- });
882
- }
883
- function J(e, r) {
884
- return function(t, i) {
885
- const s = {
950
+ function le(e, r) {
951
+ return function(t, i, c = {}) {
952
+ const o = {
886
953
  type: "utility",
887
954
  name: t,
888
- factory: i
889
- };
890
- return r.utilities.push(s), (o, u = []) => {
891
- for (const [c, f] of Object.entries(o)) {
892
- const a = {
893
- type: "utility",
894
- name: t,
895
- value: c,
896
- declarations: {},
897
- variables: [],
898
- children: [],
899
- modifiers: []
900
- }, l = b(
901
- a,
902
- r
903
- );
904
- a.declarations = i({
905
- ...l,
906
- value: f
907
- }) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
908
- ...G(a, u, r)
909
- );
955
+ factory: i,
956
+ values: [],
957
+ autogenerate: c.autogenerate ?? z(),
958
+ create: (u, s = []) => {
959
+ let f = u;
960
+ if (Array.isArray(u)) {
961
+ f = {};
962
+ for (const l of u) {
963
+ const a = o.autogenerate(l);
964
+ f = {
965
+ ...f,
966
+ ...a
967
+ };
968
+ }
969
+ }
970
+ for (const [l, a] of Object.entries(f)) {
971
+ const y = o.values.find(
972
+ (h2) => h2.key === l && h2.modifiers.length === 0
973
+ ), m = {
974
+ type: "utility",
975
+ name: t,
976
+ value: l,
977
+ declarations: {},
978
+ variables: [],
979
+ children: [],
980
+ modifiers: []
981
+ }, d2 = v(
982
+ m,
983
+ r
984
+ );
985
+ if (m.declarations = i({
986
+ ...d2,
987
+ value: a
988
+ }) ?? {}, V(m.declarations, d2), y || (o.values.push({
989
+ key: l,
990
+ value: a,
991
+ modifiers: []
992
+ }), e.children.push(m)), s && s.length > 0) {
993
+ const h2 = s.map((b) => b.key), H2 = ce(h2).filter((b) => !o.values.find(
994
+ (g2) => g2.key === l && g2.modifiers.length === b.length && g2.modifiers.every((w2) => b.includes(w2))
995
+ )).reduce((b, g2) => {
996
+ const w2 = /* @__PURE__ */ new Map();
997
+ for (const K2 of g2) {
998
+ const k2 = s.find(
999
+ (N2) => N2.key.includes(K2)
1000
+ );
1001
+ k2 && q(k2) && w2.set(K2, k2);
1002
+ }
1003
+ return o.values.push({
1004
+ key: l,
1005
+ value: a,
1006
+ modifiers: g2
1007
+ }), b.push(fe(m, r, w2)), b;
1008
+ }, []);
1009
+ e.children.push(...H2);
1010
+ }
1011
+ }
910
1012
  }
911
1013
  };
1014
+ return r.utilities.push(o), o.create;
912
1015
  };
913
1016
  }
914
- function Q(e, r) {
1017
+ function ye(e, r) {
915
1018
  return function(t, i) {
916
- const s = r.themes.find((c) => c.name === t), o = s ?? {
1019
+ const c = r.themes.find((s) => s.name === t), o = c ?? {
917
1020
  type: "theme",
918
1021
  name: t,
919
1022
  declarations: {},
920
1023
  variables: [],
921
1024
  children: []
922
1025
  };
923
- s || r.themes.push(o);
924
- const u = b(o, r);
1026
+ c || r.themes.push(o);
1027
+ const u = v(o, r);
925
1028
  return i && i(u), o;
926
1029
  };
927
1030
  }
928
- function X(e, r) {
929
- return function(t, i, s, o) {
930
- const u = {
1031
+ function de(e, r) {
1032
+ return function(t) {
1033
+ const i = {
931
1034
  type: "recipe",
932
- name: t,
933
- defaults: i,
934
- variants: s,
935
- ...o
1035
+ ...t
936
1036
  };
937
- return r.recipes.push(u), u;
1037
+ return i._runtime = me(i, r), pe(i, r), r.recipes.push(i), i;
1038
+ };
1039
+ }
1040
+ function _(e, r) {
1041
+ const n = e.autogenerate(r);
1042
+ return Object.keys(n)[0] ?? "default";
1043
+ }
1044
+ function F(e, r) {
1045
+ const n = {};
1046
+ for (const [t, i] of Object.entries(e))
1047
+ if (P(i)) {
1048
+ const c = {};
1049
+ for (const [o, u] of Object.entries(i)) {
1050
+ const s = T(r, o);
1051
+ s && (c[o] = _(
1052
+ s,
1053
+ u
1054
+ ));
1055
+ }
1056
+ n[t] = c;
1057
+ } else if (typeof i == "boolean")
1058
+ n[t] = i;
1059
+ else {
1060
+ const c = T(r, t);
1061
+ c && (n[t] = _(c, i));
1062
+ }
1063
+ return n;
1064
+ }
1065
+ function me(e, r) {
1066
+ const n = {};
1067
+ if (e.base && (n.base = F(e.base, r)), e.variants) {
1068
+ const t = {};
1069
+ for (const [i, c] of Object.entries(e.variants)) {
1070
+ const o = {};
1071
+ for (const [u, s] of Object.entries(
1072
+ c
1073
+ ))
1074
+ s == null ? o[u] = null : o[u] = F(
1075
+ s,
1076
+ r
1077
+ );
1078
+ t[i] = o;
1079
+ }
1080
+ n.variants = t;
1081
+ }
1082
+ return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
1083
+ match: { ...t.match },
1084
+ css: F(t.css, r)
1085
+ }))), n;
1086
+ }
1087
+ function P(e) {
1088
+ return !A(e) && typeof e == "object" && e !== null;
1089
+ }
1090
+ function x(e, r) {
1091
+ const n = (t, i, c) => {
1092
+ let o = r.get(t);
1093
+ o || (o = [], r.set(t, o)), o.push({ value: i, modifiers: c });
938
1094
  };
1095
+ for (const [t, i] of Object.entries(e))
1096
+ if (P(i)) {
1097
+ const c = t.split(":");
1098
+ for (const [o, u] of Object.entries(i))
1099
+ n(o, u, c);
1100
+ } else
1101
+ n(t, i, []);
1102
+ }
1103
+ function T(e, r) {
1104
+ const n = e.utilities.find((i) => i.name === r);
1105
+ if (n)
1106
+ return n;
1107
+ const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
1108
+ return e.utilities.find((i) => i.name === t);
1109
+ }
1110
+ function pe(e, r) {
1111
+ const n = /* @__PURE__ */ new Map();
1112
+ if (e.base && x(e.base, n), e.variants)
1113
+ for (const i of Object.values(e.variants))
1114
+ for (const c of Object.values(i))
1115
+ x(
1116
+ c,
1117
+ n
1118
+ );
1119
+ if (e.compoundVariants)
1120
+ for (const i of e.compoundVariants)
1121
+ i.css && x(i.css, n);
1122
+ const t = /* @__PURE__ */ new Map();
1123
+ for (const [i, c] of n) {
1124
+ const o = T(r, i);
1125
+ if (!o) {
1126
+ console.warn(
1127
+ `[styleframe] Utility "${i}" not found in registry. Skipping.`
1128
+ );
1129
+ continue;
1130
+ }
1131
+ for (const u of c) {
1132
+ const s = [];
1133
+ for (const f of u.modifiers) {
1134
+ if (!t.has(f))
1135
+ try {
1136
+ t.set(f, re(r, f));
1137
+ } catch {
1138
+ console.warn(
1139
+ `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
1140
+ ), t.set(f, null);
1141
+ }
1142
+ const l = t.get(f);
1143
+ l && s.push(l);
1144
+ }
1145
+ o.create(
1146
+ [u.value],
1147
+ s.length > 0 ? s : void 0
1148
+ );
1149
+ }
1150
+ }
939
1151
  }
940
- function ue(e) {
941
- const r = $("sf-"), n = Y(), t = { ...e }, i = J(n, n), s = W(n, n), o = X(n, n), u = Q(n, n), { variable: c, selector: f, atRule: a, keyframes: l, media: y, ref: h, css: d } = b(n, n);
1152
+ function Re(e) {
1153
+ const r = ne("sf-"), n = ae(), t = { ...e }, i = le(n, n), c = ue(n, n), o = de(n, n), u = ye(n, n), { variable: s, selector: f, atRule: l, keyframes: a, media: y, ref: m, css: d2 } = v(n, n);
942
1154
  return {
943
1155
  id: r,
944
1156
  root: n,
945
- variable: c,
1157
+ variable: s,
946
1158
  selector: f,
947
1159
  utility: i,
948
- modifier: s,
1160
+ modifier: c,
949
1161
  recipe: o,
950
1162
  theme: u,
951
- atRule: a,
952
- keyframes: l,
1163
+ atRule: l,
1164
+ keyframes: a,
953
1165
  media: y,
954
- ref: h,
955
- css: d,
1166
+ ref: m,
1167
+ css: d2,
956
1168
  options: t
957
1169
  };
958
1170
  }
959
1171
  async function loadConfiguration({
960
1172
  cwd = process.cwd(),
961
- name = "styleframe"
1173
+ configFile = "styleframe.config"
962
1174
  } = {}) {
963
1175
  const { config } = await loadConfig({
964
1176
  cwd,
965
- name,
966
- defaults: ue()
1177
+ configFile,
1178
+ defaults: Re()
967
1179
  });
968
1180
  return config;
969
1181
  }
970
1182
  async function loadConfigurationFromPath(entry) {
971
1183
  const entryPath = path.resolve(entry);
972
1184
  const cwd = path.dirname(entryPath);
973
- const name = path.basename(entryPath).replace(/(\.config)?(\.ts)?$/, "");
974
- return await loadConfiguration({ cwd, name });
1185
+ const configFile = path.basename(entryPath).replace(/(\.ts)?$/, "");
1186
+ return await loadConfiguration({ cwd, configFile });
975
1187
  }
976
1188
  async function watchConfiguration({
977
1189
  cwd = process.cwd()