@styleframe/loader 2.4.0 → 3.0.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,195 +2,195 @@ 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 { watch } from "chokidar";
5
- import { createJiti } from "jiti";
6
5
  import { existsSync } from "node:fs";
7
- const F$1 = ["charset", "import", "namespace"], L$1 = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, x$1 = ({
6
+ import { createJiti } from "jiti";
7
+ const P$1 = ["charset", "import", "namespace"], U = ["layer"], k = ({ name: e }) => `[data-theme="${e}"]`, M = ({
8
8
  name: e,
9
9
  value: t,
10
10
  modifiers: r
11
- }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, w = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
12
- function I$1(e, t) {
11
+ }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, O = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
12
+ function V$1(e, t) {
13
13
  return `@${e}${t ? " " : ""}${t}`;
14
14
  }
15
- const U = /\d/, P$1 = ["-", "_", "/", "."];
16
- function M(e = "") {
17
- if (!U.test(e))
15
+ const K$1 = /\d/, q = ["-", "_", "/", "."];
16
+ function z$1(e = "") {
17
+ if (!K$1.test(e))
18
18
  return e !== e.toLowerCase();
19
19
  }
20
- function N(e, t) {
21
- const r = P$1, n = [];
20
+ function _$1(e, t) {
21
+ const r = q, o = [];
22
22
  if (!e || typeof e != "string")
23
- return n;
24
- let o = "", s, u;
23
+ return o;
24
+ let n = "", s, u;
25
25
  for (const a of e) {
26
26
  const c = r.includes(a);
27
27
  if (c === true) {
28
- n.push(o), o = "", s = void 0;
28
+ o.push(n), n = "", s = void 0;
29
29
  continue;
30
30
  }
31
- const i = M(a);
31
+ const i = z$1(a);
32
32
  if (u === false) {
33
33
  if (s === false && i === true) {
34
- n.push(o), o = a, s = i;
34
+ o.push(n), n = a, s = i;
35
35
  continue;
36
36
  }
37
- if (s === true && i === false && o.length > 1) {
38
- const f = o.at(-1);
39
- n.push(o.slice(0, Math.max(0, o.length - 1))), o = f + a, s = i;
37
+ if (s === true && i === false && n.length > 1) {
38
+ const f = n.at(-1);
39
+ o.push(n.slice(0, Math.max(0, n.length - 1))), n = f + a, s = i;
40
40
  continue;
41
41
  }
42
42
  }
43
- o += a, s = i, u = c;
43
+ n += a, s = i, u = c;
44
44
  }
45
- return n.push(o), n;
45
+ return o.push(n), o;
46
46
  }
47
- function k(e) {
47
+ function H(e) {
48
48
  return e ? e[0].toUpperCase() + e.slice(1) : "";
49
49
  }
50
- function V$1(e) {
50
+ function Q$1(e) {
51
51
  return e ? e[0].toLowerCase() + e.slice(1) : "";
52
52
  }
53
- function q$1(e, t) {
54
- return e ? (Array.isArray(e) ? e : N(e)).map((r) => k(r)).join("") : "";
53
+ function J$1(e, t) {
54
+ return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => H(r)).join("") : "";
55
55
  }
56
- function K(e, t) {
57
- return V$1(q$1(e || ""));
56
+ function Z$1(e, t) {
57
+ return Q$1(J$1(e || ""));
58
58
  }
59
- function z$1(e, t) {
60
- return e ? (Array.isArray(e) ? e : N(e)).map((r) => r.toLowerCase()).join("-") : "";
59
+ function W(e, t) {
60
+ return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => r.toLowerCase()).join("-") : "";
61
61
  }
62
- function H(e) {
62
+ function G$1(e) {
63
63
  return ` ${e}`;
64
64
  }
65
- function Q$1(e) {
65
+ function Y$1(e) {
66
66
  return e.split(`
67
- `).map((t) => H(t)).join(`
67
+ `).map((t) => G$1(t)).join(`
68
68
  `);
69
69
  }
70
- function J$1(e) {
70
+ function x$1(e) {
71
71
  return e === e.toUpperCase();
72
72
  }
73
- function Z$1(e) {
74
- return K(e);
73
+ function T$1(e) {
74
+ return Z$1(e);
75
75
  }
76
- function W$1(e) {
77
- return z$1(e);
76
+ function X$1(e) {
77
+ return W(e);
78
78
  }
79
- function G$1(e) {
80
- return W$1(e);
79
+ function ee$1(e) {
80
+ return X$1(e);
81
81
  }
82
- function O(e, t) {
83
- return `${e.startsWith("--") ? e : G$1(e)}: ${t};`;
82
+ function B(e, t) {
83
+ return `${e.startsWith("--") ? e : ee$1(e)}: ${t};`;
84
84
  }
85
- function Y$1(e) {
85
+ function te$1(e) {
86
86
  return `{${e.length > 0 ? `
87
- ` : ""}${e.map((t) => `${Q$1(`${t}`)}
87
+ ` : ""}${e.map((t) => `${Y$1(`${t}`)}
88
88
  `).join("")}}`;
89
89
  }
90
90
  function E$1(e) {
91
91
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
92
92
  }
93
- function X$1(e, t) {
94
- return O(E$1(e), t);
93
+ function re$1(e, t) {
94
+ return B(E$1(e), t);
95
95
  }
96
- function ee$1(e, t) {
96
+ function ne$1(e, t) {
97
97
  return `var(${E$1(e)}${t ? `, ${t}` : ""})`;
98
98
  }
99
- function R$1(e, t) {
100
- return `${e} ${Y$1(t)}`;
99
+ function w(e, t) {
100
+ return `${e} ${te$1(t)}`;
101
101
  }
102
- function te$1(e) {
103
- return function(r, n) {
104
- return Object.entries(r).map(([o, s]) => O(o, e(s, n)));
102
+ function oe(e) {
103
+ return function(r, o) {
104
+ return Object.entries(r).map(([n, s]) => B(n, e(s, o)));
105
105
  };
106
106
  }
107
- function B(e) {
108
- return function(r, n) {
109
- const s = (n.variables?.name ?? w)({ name: r.name });
110
- return X$1(s, e(r.value, n));
107
+ function F$1(e) {
108
+ return function(r, o) {
109
+ const s = (o.variables?.name ?? O)({ name: r.name });
110
+ return re$1(s, e(r.value, o));
111
111
  };
112
112
  }
113
113
  function S$1(e) {
114
- const t = B(e), r = te$1(e);
115
- return function(o, s, u) {
116
- const { variables: a, declarations: c, children: i } = s, f = o === ":root", l = (a ?? []).map(
117
- (A2) => t(A2, u)
114
+ const t = F$1(e), r = oe(e);
115
+ return function(n, s, u) {
116
+ const { variables: a, declarations: c, children: i } = s, f = n === ":root", l = (a ?? []).map(
117
+ (g) => t(g, u)
118
118
  ), m = r(
119
119
  c ?? {},
120
120
  u
121
121
  ), y = (i ?? []).map(
122
- (A2) => e(A2, u)
123
- ), p2 = l.length > 0, b = m.length > 0, C2 = y.length > 0;
124
- return f ? `${p2 || b ? R$1(o, [
122
+ (g) => e(g, u)
123
+ ), p = l.length > 0, b = m.length > 0, j2 = y.length > 0;
124
+ return f ? `${p || b ? w(n, [
125
125
  ...l,
126
- ...p2 && b ? [""] : [],
126
+ ...p && b ? [""] : [],
127
127
  ...m
128
- ]) : ""}${C2 && (p2 || b) ? `
128
+ ]) : ""}${j2 && (p || b) ? `
129
129
 
130
130
  ` : ""}${y.join(`
131
131
 
132
- `)}` : R$1(o, [
132
+ `)}` : w(n, [
133
133
  ...l,
134
- ...p2 && (C2 || b) ? [""] : [],
134
+ ...p && (j2 || b) ? [""] : [],
135
135
  ...m,
136
- ...b && C2 ? [""] : [],
136
+ ...b && j2 ? [""] : [],
137
137
  ...y.flatMap(
138
- (A2, _2) => _2 === y.length - 1 ? [A2] : [A2, ""]
138
+ (g, I2) => I2 === y.length - 1 ? [g] : [g, ""]
139
139
  )
140
140
  ]);
141
141
  };
142
142
  }
143
- function re$1(e) {
143
+ function ce(e) {
144
144
  const t = S$1(e);
145
- return function(n, o) {
146
- const s = F$1.includes(n.identifier), u = L$1.includes(
147
- n.identifier
148
- ), a = Object.keys(n.declarations).length > 0, c = n.variables.length > 0, i = n.children.length > 0, f = I$1(n.identifier, n.rule);
149
- return s || u && !(a || c || i) ? `${f};` : t(f, n, o);
145
+ return function(o, n) {
146
+ const s = P$1.includes(o.identifier), u = U.includes(
147
+ o.identifier
148
+ ), a = Object.keys(o.declarations).length > 0, c = o.variables.length > 0, i = o.children.length > 0, f = V$1(o.identifier, o.rule);
149
+ return s || u && !(a || c || i) ? `${f};` : t(f, o, n);
150
150
  };
151
151
  }
152
- function ne$1(e) {
153
- return function(r, n) {
154
- return r.value.map((o) => e(o, n)).join("").trim();
152
+ function ue$1(e) {
153
+ return function(r, o) {
154
+ return r.value.map((n) => e(n, o)).join("").trim();
155
155
  };
156
156
  }
157
- function oe(e) {
157
+ function se$1(e) {
158
158
  return typeof e == "object" && e !== null;
159
159
  }
160
- function h(e, t) {
161
- return oe(e) && "type" in e && e.type === t;
160
+ function h$1(e, t) {
161
+ return se$1(e) && "type" in e && e.type === t;
162
162
  }
163
- function ce$1(e) {
164
- return h(e, "variable");
163
+ function ie$1(e) {
164
+ return h$1(e, "variable");
165
165
  }
166
- function ue$1(e) {
167
- return h(e, "reference");
166
+ function ae$1(e) {
167
+ return h$1(e, "reference");
168
168
  }
169
- function v$1(e) {
170
- return h(e, "selector");
169
+ function C$1(e) {
170
+ return h$1(e, "selector");
171
171
  }
172
- function ie(e) {
173
- return h(e, "at-rule");
172
+ function le$1(e) {
173
+ return h$1(e, "at-rule");
174
174
  }
175
- function se(e) {
176
- return h(e, "utility");
175
+ function fe(e) {
176
+ return h$1(e, "utility");
177
177
  }
178
- function ae$1(e) {
179
- return h(e, "css");
178
+ function me$1(e) {
179
+ return h$1(e, "css");
180
180
  }
181
- function le$1(e) {
182
- return h(e, "theme");
181
+ function pe$1(e) {
182
+ return h$1(e, "theme");
183
183
  }
184
- function T$1(e) {
185
- return h(e, "root");
184
+ function N(e) {
185
+ return h$1(e, "root");
186
186
  }
187
- function fe$1(e) {
188
- return h(e, "recipe");
187
+ function D$1(e) {
188
+ return h$1(e, "recipe");
189
189
  }
190
- function me$1(e) {
190
+ function L$1(e) {
191
191
  return e.charAt(0).toUpperCase() + e.slice(1);
192
192
  }
193
- function g(e) {
193
+ function A$1(e) {
194
194
  if (e instanceof Buffer)
195
195
  return Buffer.from(e);
196
196
  const t = e.constructor;
@@ -200,81 +200,81 @@ function g(e) {
200
200
  e.byteLength / e.BYTES_PER_ELEMENT || 1
201
201
  );
202
202
  }
203
- function pe$1(e) {
203
+ function ye$1(e) {
204
204
  if (e = e || {}, e.circular)
205
- return ye$1(e);
205
+ return de$1(e);
206
206
  const t = /* @__PURE__ */ new Map();
207
207
  if (t.set(Date, (u) => new Date(u)), t.set(
208
208
  Map,
209
- (u, a) => new Map(n(Array.from(u), a))
209
+ (u, a) => new Map(o(Array.from(u), a))
210
210
  ), t.set(
211
211
  Set,
212
- (u, a) => new Set(n(Array.from(u), a))
212
+ (u, a) => new Set(o(Array.from(u), a))
213
213
  ), e.constructorHandlers)
214
214
  for (const u of e.constructorHandlers)
215
215
  t.set(u[0], u[1]);
216
216
  let r;
217
- return e.proto ? s : o;
218
- function n(u, a) {
217
+ return e.proto ? s : n;
218
+ function o(u, a) {
219
219
  const c = Object.keys(u), i = Array.from({ length: c.length });
220
220
  for (let f = 0; f < c.length; f++) {
221
221
  const l = c[f], m = u[l];
222
- typeof m != "object" || m === null ? i[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? i[l] = r(m, a) : ArrayBuffer.isView(m) ? i[l] = g(m) : i[l] = a(m);
222
+ typeof m != "object" || m === null ? i[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? i[l] = r(m, a) : ArrayBuffer.isView(m) ? i[l] = A$1(m) : i[l] = a(m);
223
223
  }
224
224
  return i;
225
225
  }
226
- function o(u) {
226
+ function n(u) {
227
227
  if (typeof u != "object" || u === null) return u;
228
- if (Array.isArray(u)) return n(u, o);
228
+ if (Array.isArray(u)) return o(u, n);
229
229
  if (u.constructor !== Object && (r = t.get(u.constructor)))
230
- return r(u, o);
230
+ return r(u, n);
231
231
  const a = {};
232
232
  for (const c in u) {
233
233
  if (Object.hasOwnProperty.call(u, c) === false) continue;
234
234
  const i = u[c];
235
- typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, o) : ArrayBuffer.isView(i) ? a[c] = g(i) : a[c] = o(i);
235
+ typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, n) : ArrayBuffer.isView(i) ? a[c] = A$1(i) : a[c] = n(i);
236
236
  }
237
237
  return a;
238
238
  }
239
239
  function s(u) {
240
240
  if (typeof u != "object" || u === null) return u;
241
- if (Array.isArray(u)) return n(u, s);
241
+ if (Array.isArray(u)) return o(u, s);
242
242
  if (u.constructor !== Object && (r = t.get(u.constructor)))
243
243
  return r(u, s);
244
244
  const a = {};
245
245
  for (const c in u) {
246
246
  const i = u[c];
247
- typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, s) : ArrayBuffer.isView(i) ? a[c] = g(i) : a[c] = s(i);
247
+ typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, s) : ArrayBuffer.isView(i) ? a[c] = A$1(i) : a[c] = s(i);
248
248
  }
249
249
  return a;
250
250
  }
251
251
  }
252
- function ye$1(e) {
253
- const t = [], r = [], n = /* @__PURE__ */ new Map();
254
- if (n.set(Date, (c) => new Date(c)), n.set(
252
+ function de$1(e) {
253
+ const t = [], r = [], o = /* @__PURE__ */ new Map();
254
+ if (o.set(Date, (c) => new Date(c)), o.set(
255
255
  Map,
256
256
  (c, i) => new Map(s(Array.from(c), i))
257
- ), n.set(
257
+ ), o.set(
258
258
  Set,
259
259
  (c, i) => new Set(s(Array.from(c), i))
260
260
  ), e.constructorHandlers)
261
261
  for (const c of e.constructorHandlers)
262
- n.set(c[0], c[1]);
263
- let o;
262
+ o.set(c[0], c[1]);
263
+ let n;
264
264
  return e.proto ? a : u;
265
265
  function s(c, i) {
266
266
  const f = Object.keys(c), l = Array.from({ length: f.length });
267
267
  for (let m = 0; m < f.length; m++) {
268
- const y = f[m], p2 = c[y];
269
- if (typeof p2 != "object" || p2 === null)
270
- l[y] = p2;
271
- else if (p2.constructor !== Object && (o = n.get(p2.constructor)))
272
- l[y] = o(p2, i);
273
- else if (ArrayBuffer.isView(p2))
274
- l[y] = g(p2);
268
+ const y = f[m], p = c[y];
269
+ if (typeof p != "object" || p === null)
270
+ l[y] = p;
271
+ else if (p.constructor !== Object && (n = o.get(p.constructor)))
272
+ l[y] = n(p, i);
273
+ else if (ArrayBuffer.isView(p))
274
+ l[y] = A$1(p);
275
275
  else {
276
- const b = t.indexOf(p2);
277
- b !== -1 ? l[y] = r[b] : l[y] = i(p2);
276
+ const b = t.indexOf(p);
277
+ b !== -1 ? l[y] = r[b] : l[y] = i(p);
278
278
  }
279
279
  }
280
280
  return l;
@@ -282,8 +282,8 @@ function ye$1(e) {
282
282
  function u(c) {
283
283
  if (typeof c != "object" || c === null) return c;
284
284
  if (Array.isArray(c)) return s(c, u);
285
- if (c.constructor !== Object && (o = n.get(c.constructor)))
286
- return o(c, u);
285
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
286
+ return n(c, u);
287
287
  const i = {};
288
288
  t.push(c), r.push(i);
289
289
  for (const f in c) {
@@ -291,10 +291,10 @@ function ye$1(e) {
291
291
  const l = c[f];
292
292
  if (typeof l != "object" || l === null)
293
293
  i[f] = l;
294
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
295
- i[f] = o(l, u);
294
+ else if (l.constructor !== Object && (n = o.get(l.constructor)))
295
+ i[f] = n(l, u);
296
296
  else if (ArrayBuffer.isView(l))
297
- i[f] = g(l);
297
+ i[f] = A$1(l);
298
298
  else {
299
299
  const m = t.indexOf(l);
300
300
  m !== -1 ? i[f] = r[m] : i[f] = u(l);
@@ -305,18 +305,18 @@ function ye$1(e) {
305
305
  function a(c) {
306
306
  if (typeof c != "object" || c === null) return c;
307
307
  if (Array.isArray(c)) return s(c, a);
308
- if (c.constructor !== Object && (o = n.get(c.constructor)))
309
- return o(c, a);
308
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
309
+ return n(c, a);
310
310
  const i = {};
311
311
  t.push(c), r.push(i);
312
312
  for (const f in c) {
313
313
  const l = c[f];
314
314
  if (typeof l != "object" || l === null)
315
315
  i[f] = l;
316
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
317
- i[f] = o(l, a);
316
+ else if (l.constructor !== Object && (n = o.get(l.constructor)))
317
+ i[f] = n(l, a);
318
318
  else if (ArrayBuffer.isView(l))
319
- i[f] = g(l);
319
+ i[f] = A$1(l);
320
320
  else {
321
321
  const m = t.indexOf(l);
322
322
  m !== -1 ? i[f] = r[m] : i[f] = a(l);
@@ -325,27 +325,27 @@ function ye$1(e) {
325
325
  return t.pop(), r.pop(), i;
326
326
  }
327
327
  }
328
- pe$1();
329
- function de$1(e) {
330
- return function(r, n) {
328
+ ye$1();
329
+ function he$1(e) {
330
+ return function(r, o) {
331
331
  return r != null ? `${r}` : "";
332
332
  };
333
333
  }
334
- function he(e) {
335
- return function(r, n) {
336
- const s = (n.variables?.name ?? w)({ name: r.name });
337
- return ee$1(
334
+ function be$1(e) {
335
+ return function(r, o) {
336
+ const s = (o.variables?.name ?? O)({ name: r.name });
337
+ return ne$1(
338
338
  s,
339
- r.fallback ? e(r.fallback, n) : void 0
339
+ r.fallback ? e(r.fallback, o) : void 0
340
340
  );
341
341
  };
342
342
  }
343
- function be$1(e) {
343
+ function ge$1(e) {
344
344
  const t = S$1(e);
345
- return function(n, o) {
346
- return n.themes.reduce(
347
- (s, u) => (s.push(e(u, o)), s),
348
- [t(":root", n, o)]
345
+ return function(o, n) {
346
+ return o.themes.reduce(
347
+ (s, u) => (s.push(e(u, n)), s),
348
+ [t(":root", o, n)]
349
349
  // Default theme (root)
350
350
  ).join(`
351
351
 
@@ -354,108 +354,108 @@ function be$1(e) {
354
354
  }
355
355
  function Ae$1(e) {
356
356
  const t = S$1(e);
357
- return function(n, o) {
358
- return t(n.query, n, o);
357
+ return function(o, n) {
358
+ return t(o.query, o, n);
359
359
  };
360
360
  }
361
- function ge(e) {
361
+ function Se(e) {
362
362
  const t = S$1(e);
363
- return function(n, o) {
364
- const u = (o.themes?.selector ?? D)({ name: n.name });
365
- return t(u, n, o);
363
+ return function(o, n) {
364
+ const u = (n.themes?.selector ?? k)({ name: o.name });
365
+ return t(u, o, n);
366
366
  };
367
367
  }
368
- function Se(e) {
368
+ function Ce(e) {
369
369
  const t = S$1(e);
370
- return function(n, o) {
371
- const s = [], a = (o.utilities?.selector ?? x$1)({
372
- name: n.name,
373
- value: n.value,
374
- modifiers: n.modifiers
370
+ return function(o, n) {
371
+ const s = [], a = (n.utilities?.selector ?? M)({
372
+ name: o.name,
373
+ value: o.value,
374
+ modifiers: o.modifiers
375
375
  });
376
- return s.push(t(a, n, o)), s.join(`
376
+ return s.push(t(a, o, n)), s.join(`
377
377
 
378
378
  `);
379
379
  };
380
380
  }
381
381
  function d(e, t) {
382
- const r = be$1(d), n = Ae$1(d), o = Se(d), s = re$1(d), u = ge(d), a = B(d), c = he(d), i = ne$1(d), f = de$1();
382
+ const r = ge$1(d), o = Ae$1(d), n = Ce(d), s = ce(d), u = Se(d), a = F$1(d), c = be$1(d), i = ue$1(d), f = he$1();
383
383
  switch (true) {
384
- case v$1(e):
385
- return n(e, t);
386
- case se(e):
384
+ case C$1(e):
387
385
  return o(e, t);
388
- case ie(e):
386
+ case fe(e):
387
+ return n(e, t);
388
+ case le$1(e):
389
389
  return s(e, t);
390
- case T$1(e):
390
+ case N(e):
391
391
  return r(e, t);
392
- case le$1(e):
392
+ case pe$1(e):
393
393
  return u(e, t);
394
- case ce$1(e):
394
+ case ie$1(e):
395
395
  return a(e, t);
396
- case ue$1(e):
397
- return c(e, t);
398
396
  case ae$1(e):
397
+ return c(e, t);
398
+ case me$1(e):
399
399
  return i(e, t);
400
400
  default:
401
401
  return f(e, t);
402
402
  }
403
403
  }
404
- function Ce(e) {
405
- return function(r, n) {
406
- let o = r._exportName;
407
- o || (o = Z$1(r.name), r.name[0] && J$1(r.name[0]) && (o = me$1(o)));
408
- const s = `${o}Recipe`, u = r._runtime ?? {};
404
+ function je(e) {
405
+ return function(r, o) {
406
+ let n = r._exportName;
407
+ n || (n = T$1(r.name), r.name[0] && x$1(r.name[0]) && (n = L$1(n)));
408
+ const s = `${n}Recipe`, u = r._runtime ?? {};
409
409
  return `const ${s} = ${JSON.stringify(
410
410
  u,
411
411
  null,
412
412
  4
413
413
  )} as const satisfies RecipeRuntime;
414
414
 
415
- export const ${o} = createRecipe("${r.name}", ${s});
415
+ export const ${n} = createRecipe("${r.name}", ${s});
416
416
  `;
417
417
  };
418
418
  }
419
- function je(e) {
419
+ function ve(e) {
420
420
  return e.filter(
421
- (t) => v$1(t) && !!t._exportName
421
+ (t) => C$1(t) && !!t._exportName
422
422
  );
423
423
  }
424
- function ve(e) {
425
- return function(r, n) {
426
- const o = je(r.children), s = r.recipes.length > 0, u = o.length > 0;
424
+ function Re(e) {
425
+ return function(r, o) {
426
+ const n = ve(r.children), s = r.recipes.length > 0, u = n.length > 0;
427
427
  if (!s && !u)
428
428
  return "";
429
429
  const a = [];
430
430
  return s && (a.push(`import { createRecipe } from '@styleframe/runtime';
431
431
  import type { RecipeRuntime } from '@styleframe/runtime';
432
- `), a.push(e(r.recipes, n))), u && a.push(e(o, n)), a.join(`
432
+ `), a.push(e(r.recipes, o))), u && a.push(e(n, o)), a.join(`
433
433
  `);
434
434
  };
435
435
  }
436
- function Re$1(e) {
437
- return function(r, n) {
436
+ function $e(e) {
437
+ return function(r, o) {
438
438
  return r._exportName ? `export const ${r._exportName} = ${JSON.stringify(r.query)};
439
439
  ` : "";
440
440
  };
441
441
  }
442
- function j$1(e, t) {
443
- const r = ve(j$1), n = Ce(), o = Re$1();
442
+ function R$1(e, t) {
443
+ const r = Re(R$1), o = je(), n = $e();
444
444
  switch (true) {
445
445
  case Array.isArray(e):
446
- return e.map((s) => j$1(s, t)).join(`
446
+ return e.map((s) => R$1(s, t)).join(`
447
447
  `);
448
- case T$1(e):
448
+ case N(e):
449
449
  return r(e, t);
450
- case fe$1(e):
451
- return n(e, t);
452
- case v$1(e):
450
+ case D$1(e):
453
451
  return o(e, t);
452
+ case C$1(e):
453
+ return n(e, t);
454
454
  default:
455
455
  return "";
456
456
  }
457
457
  }
458
- const $e = `-----BEGIN PUBLIC KEY-----
458
+ const Ne = `-----BEGIN PUBLIC KEY-----
459
459
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
460
460
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
461
461
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -463,9 +463,9 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
463
463
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
464
464
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
465
465
  GwIDAQAB
466
- -----END PUBLIC KEY-----`, we = "__licenseRequired", Ne = "__licenseValidated";
467
- async function Oe(e) {
468
- const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
466
+ -----END PUBLIC KEY-----`, we = "__licenseRequired", Oe = "__licenseValidated";
467
+ async function _e(e) {
468
+ const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (o) => o.charCodeAt(0));
469
469
  return await crypto.subtle.importKey(
470
470
  "spki",
471
471
  r,
@@ -477,18 +477,18 @@ async function Oe(e) {
477
477
  ["verify"]
478
478
  );
479
479
  }
480
- async function Ee({
480
+ async function xe({
481
481
  payload: e,
482
482
  signature: t
483
483
  }) {
484
- const r = new TextEncoder().encode(e), n = Uint8Array.from(
484
+ const r = new TextEncoder().encode(e), o = Uint8Array.from(
485
485
  atob(t),
486
486
  (s) => s.charCodeAt(0)
487
- ), o = await Oe($e);
487
+ ), n = await _e(Ne);
488
488
  if (!await crypto.subtle.verify(
489
489
  { name: "RSASSA-PKCS1-v1_5" },
490
- o,
491
490
  n,
491
+ o,
492
492
  r
493
493
  ))
494
494
  throw new Error(
@@ -496,13 +496,13 @@ async function Ee({
496
496
  );
497
497
  return JSON.parse(e);
498
498
  }
499
- function Be(e) {
499
+ function Te(e) {
500
500
  return Object.prototype.hasOwnProperty.call(e, we);
501
501
  }
502
- async function Te(e) {
502
+ async function Be(e) {
503
503
  const t = Object.getOwnPropertyDescriptor(
504
504
  e,
505
- Ne
505
+ Oe
506
506
  );
507
507
  if (!t?.value)
508
508
  return {
@@ -520,7 +520,7 @@ async function Te(e) {
520
520
  valid: false
521
521
  };
522
522
  try {
523
- return await Ee(
523
+ return await xe(
524
524
  r
525
525
  );
526
526
  } catch {
@@ -532,7 +532,81 @@ async function Te(e) {
532
532
  };
533
533
  }
534
534
  }
535
- function _e(e) {
535
+ function Ee(e) {
536
+ const t = e?.variants;
537
+ if (!t || Object.keys(t).length === 0)
538
+ return "Record<string, never>";
539
+ const r = [];
540
+ for (const [o, n] of Object.entries(t)) {
541
+ if (!n) continue;
542
+ const s = Object.keys(n);
543
+ if (s.length > 0) {
544
+ const u = s.map((a) => `"${a}"`).join(" | ");
545
+ r.push(`${o}?: ${u}`);
546
+ }
547
+ }
548
+ return r.length === 0 ? "Record<string, never>" : `{ ${r.join("; ")} }`;
549
+ }
550
+ function Fe$1(e) {
551
+ return function(r, o) {
552
+ let n = r._exportName;
553
+ n || (n = T$1(r.name), r.name[0] && x$1(r.name[0]) && (n = L$1(n)));
554
+ const s = Ee(r._runtime);
555
+ return ` export const ${n}: (props?: ${s}) => string;`;
556
+ };
557
+ }
558
+ function De(e) {
559
+ return e.filter(
560
+ (t) => C$1(t) && !!t._exportName
561
+ );
562
+ }
563
+ function Le(e) {
564
+ return function(r, o) {
565
+ const n = De(r.children), s = r.recipes.length > 0, u = n.length > 0, a = [
566
+ "// Auto-generated by @styleframe/plugin - DO NOT EDIT",
567
+ "",
568
+ 'declare module "virtual:styleframe" {',
569
+ ' import type { Styleframe } from "@styleframe/core";',
570
+ "",
571
+ " /** Returns the global styleframe instance from styleframe.config.ts */",
572
+ " export function styleframe(): Styleframe;"
573
+ ];
574
+ if (s) {
575
+ a.push("");
576
+ const c = r.recipes.map((i) => e(i, o)).filter(Boolean);
577
+ a.push(...c);
578
+ }
579
+ if (u) {
580
+ a.push("");
581
+ const c = n.map((i) => e(i, o)).filter(Boolean);
582
+ a.push(...c);
583
+ }
584
+ return a.push("}"), a.push(""), a.push('declare module "virtual:styleframe.css" {'), a.push(" const css: string;"), a.push(" export default css;"), a.push("}"), a.push(""), a.join(`
585
+ `);
586
+ };
587
+ }
588
+ function Ie(e) {
589
+ return function(r, o) {
590
+ return r._exportName ? ` export const ${r._exportName}: string;` : "";
591
+ };
592
+ }
593
+ function $(e, t) {
594
+ const r = Le($), o = Fe$1(), n = Ie();
595
+ switch (true) {
596
+ case Array.isArray(e):
597
+ return e.map((s) => $(s, t)).join(`
598
+ `);
599
+ case N(e):
600
+ return r(e, t);
601
+ case D$1(e):
602
+ return o(e, t);
603
+ case C$1(e):
604
+ return n(e, t);
605
+ default:
606
+ return "";
607
+ }
608
+ }
609
+ function Pe(e) {
536
610
  const t = Math.floor(Math.random() * 100);
537
611
  e.root.children.push({
538
612
  type: "selector",
@@ -556,36 +630,43 @@ function _e(e) {
556
630
  }
557
631
  });
558
632
  }
559
- function $$1(e, t = "") {
633
+ function v$1(e, t = "") {
560
634
  return {
561
635
  name: e,
562
636
  content: t
563
637
  };
564
638
  }
565
- async function Le(e, {
639
+ async function ke$1(e, {
566
640
  type: t = "all",
567
- consumers: r = { css: d, ts: j$1 }
641
+ consumers: r = { css: d, ts: R$1, dts: $ }
568
642
  } = {}) {
569
- const n = { files: [] }, o = e.options;
570
- if (Be(e)) {
571
- const s = await Te(e);
572
- (!s.valid || s.instanceId !== e.id) && _e(e);
643
+ const o = { files: [] }, n = e.options;
644
+ if (Te(e)) {
645
+ const s = await Be(e);
646
+ (!s.valid || s.instanceId !== e.id) && Pe(e);
573
647
  }
574
648
  if (t === "all" || t === "css") {
575
- const s = $$1(
649
+ const s = v$1(
576
650
  "index.css",
577
- r.css(e.root, o)
651
+ r.css(e.root, n)
578
652
  );
579
- n.files.push(s);
653
+ o.files.push(s);
580
654
  }
581
655
  if (t === "all" || t === "ts") {
582
- const s = $$1(
656
+ const s = v$1(
583
657
  "index.ts",
584
- r.ts(e.root, o)
658
+ r.ts(e.root, n)
585
659
  );
586
- n.files.push(s);
660
+ o.files.push(s);
587
661
  }
588
- return n;
662
+ if (t === "dts") {
663
+ const s = v$1(
664
+ "index.d.ts",
665
+ r.dts(e.root, n)
666
+ );
667
+ o.files.push(s);
668
+ }
669
+ return o;
589
670
  }
590
671
  async function directoryExists(path2) {
591
672
  try {
@@ -601,7 +682,7 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
601
682
  environment: process.env.NODE_ENV || "development",
602
683
  isBuild: true
603
684
  });
604
- const output = await Le(instance, transpiler);
685
+ const output = await ke$1(instance, transpiler);
605
686
  const outputDirExists = await directoryExists(outputDir);
606
687
  if (clean && outputDirExists) {
607
688
  await rm(outputDir, { recursive: true });
@@ -616,90 +697,109 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
616
697
  await writeFile(filePath, file.content);
617
698
  }
618
699
  }
619
- function S(e) {
700
+ function C(e) {
620
701
  return typeof e == "object" && e !== null;
621
702
  }
622
- function p(e, r) {
623
- return S(e) && "type" in e && e.type === r;
703
+ function h(e, r) {
704
+ return C(e) && "type" in e && e.type === r;
624
705
  }
625
- function L(e) {
626
- return p(e, "variable");
706
+ function G(e) {
707
+ return h(e, "variable");
627
708
  }
628
- function A(e) {
629
- return p(e, "reference");
709
+ function j(e) {
710
+ return h(e, "reference");
630
711
  }
631
- function be(e) {
632
- return p(e, "selector");
712
+ function Ae(e) {
713
+ return h(e, "selector");
633
714
  }
634
- function q(e) {
635
- return p(e, "modifier");
715
+ function I(e) {
716
+ return h(e, "modifier");
636
717
  }
637
- function E(e) {
638
- return p(e, "css");
718
+ function T(e) {
719
+ return h(e, "css");
639
720
  }
640
- function Ae(e) {
641
- return p(e, "recipe");
721
+ function V(e) {
722
+ return h(e, "root");
642
723
  }
643
- function G(e) {
724
+ function ke(e) {
725
+ return h(e, "recipe");
726
+ }
727
+ function z(e) {
644
728
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
645
729
  }
646
- function $(e) {
647
- return G(e) || A(e) || E(e) || Array.isArray(e) && e.every($);
730
+ function D(e) {
731
+ return z(e) || j(e) || T(e) || Array.isArray(e) && e.every(D);
648
732
  }
649
- function I(e) {
650
- return S(e) && "children" in e && "declarations" in e && "variables" in e;
651
- }
652
- function z(e = (r) => r) {
653
- return (r) => {
654
- let n = r, t;
655
- if (typeof n == "string" && n[0] === "@") {
656
- const i = n.slice(1);
657
- t = e(i), n = {
733
+ function Y(e) {
734
+ return C(e) && "children" in e && "declarations" in e && "variables" in e;
735
+ }
736
+ function Ve(e) {
737
+ return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
738
+ }
739
+ function P(e) {
740
+ const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
741
+ return (c) => {
742
+ let s = c, a;
743
+ if (typeof s == "string" && s[0] === "@") {
744
+ const o = s.slice(1), f = i.find(
745
+ (y) => o === y || o.startsWith(`${y}.`)
746
+ );
747
+ let l, u;
748
+ f ? (l = o, u = o.startsWith(`${f}.`) ? o.slice(f.length + 1) : o) : i.length > 0 ? (l = `${i[0]}.${o}`, u = o) : (l = o, u = o), a = n(u), s = {
658
749
  type: "reference",
659
- name: i
750
+ name: l
660
751
  };
661
- } else A(n) ? t = e(n.name) : t = `[${r}]`;
752
+ } else if (j(s)) {
753
+ let o = s.name;
754
+ for (const f of i)
755
+ if (o.startsWith(`${f}.`)) {
756
+ o = o.slice(f.length + 1);
757
+ break;
758
+ }
759
+ a = n(o);
760
+ } else
761
+ a = `[${c}]`;
662
762
  return {
663
- [t]: n
763
+ [a]: s
664
764
  };
665
765
  };
666
766
  }
667
- function W(e, r) {
767
+ function Z(e, r) {
668
768
  return function(t, ...i) {
669
769
  return {
670
770
  type: "css",
671
- value: t.reduce((o, u, s) => (o.push(u), s < i.length && o.push(i[s]), o), [])
771
+ value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
672
772
  };
673
773
  };
674
774
  }
675
- function C(e, r) {
775
+ function K(e, r) {
676
776
  return function(t, i, c) {
677
- const o = {
777
+ const s = {
678
778
  type: "at-rule",
679
779
  identifier: t,
680
780
  rule: i,
681
781
  declarations: {},
682
782
  variables: [],
683
783
  children: []
684
- }, u = v(o, r);
685
- return typeof c == "function" ? o.declarations = c(u) ?? {} : c && (o.declarations = c), V(o.declarations, u), e.children.push(o), o;
784
+ }, a = v(s, r);
785
+ return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
686
786
  };
687
787
  }
688
- function Y(e, r) {
689
- const n = C(e, r);
788
+ function J(e, r) {
789
+ const n = K(e, r);
690
790
  return function(i, c) {
691
791
  return n("media", i, c);
692
792
  };
693
793
  }
694
- function Z(e, r) {
695
- const n = C(e, r);
794
+ function Q(e, r) {
795
+ const n = K(e, r);
696
796
  return function(i, c) {
697
797
  return n("keyframes", i, c);
698
798
  };
699
799
  }
700
- function J(e, r) {
800
+ function X(e, r) {
701
801
  return function(t, i) {
702
- return L(t) ? {
802
+ return G(t) ? {
703
803
  type: "reference",
704
804
  name: t.name,
705
805
  fallback: i
@@ -710,7 +810,7 @@ function J(e, r) {
710
810
  };
711
811
  };
712
812
  }
713
- function Q(e, r) {
813
+ function ee(e, r) {
714
814
  return function(t, i) {
715
815
  const c = {
716
816
  type: "selector",
@@ -718,56 +818,60 @@ function Q(e, r) {
718
818
  declarations: {},
719
819
  variables: [],
720
820
  children: []
721
- }, o = v(c, r);
722
- 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;
821
+ }, s = v(c, r);
822
+ return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
723
823
  };
724
824
  }
725
- function X(e, r) {
825
+ function te(e, r) {
726
826
  return function(t, i, c = {
727
827
  default: false
728
828
  }) {
729
- const o = typeof t == "string" ? t : t.name, u = e.variables.find(
730
- (f) => f.name === o
829
+ const s = typeof t == "string" ? t : t.name, a = e.variables.find(
830
+ (f) => f.name === s
731
831
  );
732
- if (c.default && u)
733
- return u;
734
- if (u)
735
- return u.value = i, u;
736
- const s = {
832
+ if (c.default && a)
833
+ return a;
834
+ if (a)
835
+ return a.value = i, a;
836
+ const o = {
737
837
  type: "variable",
738
- name: o,
838
+ name: s,
739
839
  value: i
740
840
  };
741
- return e.variables.push(s), s;
841
+ return e.variables.push(o), o;
742
842
  };
743
843
  }
744
844
  function v(e, r) {
745
- const n = X(e), t = Q(e, r), i = C(e, r), c = Z(r, r), o = Y(e, r), u = J(), s = W();
845
+ const n = te(e), t = ee(e, r), i = K(e, r), c = Q(r, r), s = J(e, r), a = X(), o = Z();
746
846
  return {
747
847
  variable: n,
748
848
  selector: t,
749
849
  keyframes: c,
750
850
  atRule: i,
751
- media: o,
752
- ref: u,
753
- css: s
851
+ media: s,
852
+ ref: a,
853
+ css: o
754
854
  };
755
855
  }
756
- function V(e, r) {
856
+ function R(e, r) {
757
857
  for (const n in e)
758
858
  if (n.startsWith("@")) {
759
859
  const t = e[n];
760
- if (typeof t == "object" && t !== null && !$(t)) {
860
+ if (typeof t == "object" && t !== null && !D(t)) {
761
861
  const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
762
862
  r.atRule(i, c, t), delete e[n];
763
863
  }
764
- } else if (/^[.&:]/.test(n)) {
864
+ } else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
765
865
  const t = e[n];
766
866
  typeof t == "object" && (r.selector(n, t), delete e[n]);
767
867
  }
868
+ for (const n in e) {
869
+ const t = e[n];
870
+ typeof t == "string" && t[0] === "@" && (e[n] = r.ref(t.slice(1)));
871
+ }
768
872
  return e;
769
873
  }
770
- function j(e) {
874
+ function A(e) {
771
875
  if (e instanceof Buffer)
772
876
  return Buffer.from(e);
773
877
  const r = e.constructor;
@@ -777,133 +881,133 @@ function j(e) {
777
881
  e.byteLength / e.BYTES_PER_ELEMENT || 1
778
882
  );
779
883
  }
780
- function ee(e) {
884
+ function ne(e) {
781
885
  if (e = e || {}, e.circular)
782
- return te(e);
886
+ return re(e);
783
887
  const r = /* @__PURE__ */ new Map();
784
- if (r.set(Date, (o) => new Date(o)), r.set(
888
+ if (r.set(Date, (s) => new Date(s)), r.set(
785
889
  Map,
786
- (o, u) => new Map(t(Array.from(o), u))
890
+ (s, a) => new Map(t(Array.from(s), a))
787
891
  ), r.set(
788
892
  Set,
789
- (o, u) => new Set(t(Array.from(o), u))
893
+ (s, a) => new Set(t(Array.from(s), a))
790
894
  ), e.constructorHandlers)
791
- for (const o of e.constructorHandlers)
792
- r.set(o[0], o[1]);
895
+ for (const s of e.constructorHandlers)
896
+ r.set(s[0], s[1]);
793
897
  let n;
794
898
  return e.proto ? c : i;
795
- function t(o, u) {
796
- const s = Object.keys(o), f = Array.from({ length: s.length });
797
- for (let l = 0; l < s.length; l++) {
798
- const a = s[l], y = o[a];
799
- 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);
899
+ function t(s, a) {
900
+ const o = Object.keys(s), f = Array.from({ length: o.length });
901
+ for (let l = 0; l < o.length; l++) {
902
+ const u = o[l], y = s[u];
903
+ typeof y != "object" || y === null ? f[u] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[u] = n(y, a) : ArrayBuffer.isView(y) ? f[u] = A(y) : f[u] = a(y);
800
904
  }
801
905
  return f;
802
906
  }
803
- function i(o) {
804
- if (typeof o != "object" || o === null) return o;
805
- if (Array.isArray(o)) return t(o, i);
806
- if (o.constructor !== Object && (n = r.get(o.constructor)))
807
- return n(o, i);
808
- const u = {};
809
- for (const s in o) {
810
- if (Object.hasOwnProperty.call(o, s) === false) continue;
811
- const f = o[s];
812
- 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);
907
+ function i(s) {
908
+ if (typeof s != "object" || s === null) return s;
909
+ if (Array.isArray(s)) return t(s, i);
910
+ if (s.constructor !== Object && (n = r.get(s.constructor)))
911
+ return n(s, i);
912
+ const a = {};
913
+ for (const o in s) {
914
+ if (Object.hasOwnProperty.call(s, o) === false) continue;
915
+ const f = s[o];
916
+ typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, i) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = i(f);
813
917
  }
814
- return u;
918
+ return a;
815
919
  }
816
- function c(o) {
817
- if (typeof o != "object" || o === null) return o;
818
- if (Array.isArray(o)) return t(o, c);
819
- if (o.constructor !== Object && (n = r.get(o.constructor)))
820
- return n(o, c);
821
- const u = {};
822
- for (const s in o) {
823
- const f = o[s];
824
- 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);
920
+ function c(s) {
921
+ if (typeof s != "object" || s === null) return s;
922
+ if (Array.isArray(s)) return t(s, c);
923
+ if (s.constructor !== Object && (n = r.get(s.constructor)))
924
+ return n(s, c);
925
+ const a = {};
926
+ for (const o in s) {
927
+ const f = s[o];
928
+ typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, c) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = c(f);
825
929
  }
826
- return u;
930
+ return a;
827
931
  }
828
932
  }
829
- function te(e) {
933
+ function re(e) {
830
934
  const r = [], n = [], t = /* @__PURE__ */ new Map();
831
- if (t.set(Date, (s) => new Date(s)), t.set(
935
+ if (t.set(Date, (o) => new Date(o)), t.set(
832
936
  Map,
833
- (s, f) => new Map(c(Array.from(s), f))
937
+ (o, f) => new Map(c(Array.from(o), f))
834
938
  ), t.set(
835
939
  Set,
836
- (s, f) => new Set(c(Array.from(s), f))
940
+ (o, f) => new Set(c(Array.from(o), f))
837
941
  ), e.constructorHandlers)
838
- for (const s of e.constructorHandlers)
839
- t.set(s[0], s[1]);
942
+ for (const o of e.constructorHandlers)
943
+ t.set(o[0], o[1]);
840
944
  let i;
841
- return e.proto ? u : o;
842
- function c(s, f) {
843
- const l = Object.keys(s), a = Array.from({ length: l.length });
945
+ return e.proto ? a : s;
946
+ function c(o, f) {
947
+ const l = Object.keys(o), u = Array.from({ length: l.length });
844
948
  for (let y = 0; y < l.length; y++) {
845
- const m = l[y], d2 = s[m];
949
+ const p = l[y], d2 = o[p];
846
950
  if (typeof d2 != "object" || d2 === null)
847
- a[m] = d2;
951
+ u[p] = d2;
848
952
  else if (d2.constructor !== Object && (i = t.get(d2.constructor)))
849
- a[m] = i(d2, f);
953
+ u[p] = i(d2, f);
850
954
  else if (ArrayBuffer.isView(d2))
851
- a[m] = j(d2);
955
+ u[p] = A(d2);
852
956
  else {
853
- const h2 = r.indexOf(d2);
854
- h2 !== -1 ? a[m] = n[h2] : a[m] = f(d2);
957
+ const w2 = r.indexOf(d2);
958
+ w2 !== -1 ? u[p] = n[w2] : u[p] = f(d2);
855
959
  }
856
960
  }
857
- return a;
961
+ return u;
858
962
  }
859
- function o(s) {
860
- if (typeof s != "object" || s === null) return s;
861
- if (Array.isArray(s)) return c(s, o);
862
- if (s.constructor !== Object && (i = t.get(s.constructor)))
863
- return i(s, o);
963
+ function s(o) {
964
+ if (typeof o != "object" || o === null) return o;
965
+ if (Array.isArray(o)) return c(o, s);
966
+ if (o.constructor !== Object && (i = t.get(o.constructor)))
967
+ return i(o, s);
864
968
  const f = {};
865
- r.push(s), n.push(f);
866
- for (const l in s) {
867
- if (Object.hasOwnProperty.call(s, l) === false) continue;
868
- const a = s[l];
869
- if (typeof a != "object" || a === null)
870
- f[l] = a;
871
- else if (a.constructor !== Object && (i = t.get(a.constructor)))
872
- f[l] = i(a, o);
873
- else if (ArrayBuffer.isView(a))
874
- f[l] = j(a);
969
+ r.push(o), n.push(f);
970
+ for (const l in o) {
971
+ if (Object.hasOwnProperty.call(o, l) === false) continue;
972
+ const u = o[l];
973
+ if (typeof u != "object" || u === null)
974
+ f[l] = u;
975
+ else if (u.constructor !== Object && (i = t.get(u.constructor)))
976
+ f[l] = i(u, s);
977
+ else if (ArrayBuffer.isView(u))
978
+ f[l] = A(u);
875
979
  else {
876
- const y = r.indexOf(a);
877
- y !== -1 ? f[l] = n[y] : f[l] = o(a);
980
+ const y = r.indexOf(u);
981
+ y !== -1 ? f[l] = n[y] : f[l] = s(u);
878
982
  }
879
983
  }
880
984
  return r.pop(), n.pop(), f;
881
985
  }
882
- function u(s) {
883
- if (typeof s != "object" || s === null) return s;
884
- if (Array.isArray(s)) return c(s, u);
885
- if (s.constructor !== Object && (i = t.get(s.constructor)))
886
- return i(s, u);
986
+ function a(o) {
987
+ if (typeof o != "object" || o === null) return o;
988
+ if (Array.isArray(o)) return c(o, a);
989
+ if (o.constructor !== Object && (i = t.get(o.constructor)))
990
+ return i(o, a);
887
991
  const f = {};
888
- r.push(s), n.push(f);
889
- for (const l in s) {
890
- const a = s[l];
891
- if (typeof a != "object" || a === null)
892
- f[l] = a;
893
- else if (a.constructor !== Object && (i = t.get(a.constructor)))
894
- f[l] = i(a, u);
895
- else if (ArrayBuffer.isView(a))
896
- f[l] = j(a);
992
+ r.push(o), n.push(f);
993
+ for (const l in o) {
994
+ const u = o[l];
995
+ if (typeof u != "object" || u === null)
996
+ f[l] = u;
997
+ else if (u.constructor !== Object && (i = t.get(u.constructor)))
998
+ f[l] = i(u, a);
999
+ else if (ArrayBuffer.isView(u))
1000
+ f[l] = A(u);
897
1001
  else {
898
- const y = r.indexOf(a);
899
- y !== -1 ? f[l] = n[y] : f[l] = u(a);
1002
+ const y = r.indexOf(u);
1003
+ y !== -1 ? f[l] = n[y] : f[l] = a(u);
900
1004
  }
901
1005
  }
902
1006
  return r.pop(), n.pop(), f;
903
1007
  }
904
1008
  }
905
- const R = ee();
906
- function ne(e, r = 8) {
1009
+ const F = ne();
1010
+ function ie(e, r = 8) {
907
1011
  const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
908
1012
  let t = "";
909
1013
  for (let i = 0; i < r; i++) {
@@ -912,7 +1016,7 @@ function ne(e, r = 8) {
912
1016
  }
913
1017
  return e ? `${e}${t}` : t;
914
1018
  }
915
- function re(e, r) {
1019
+ function se(e, r) {
916
1020
  const n = e.modifiers.find(
917
1021
  (t) => t.key.includes(r)
918
1022
  );
@@ -920,23 +1024,23 @@ function re(e, r) {
920
1024
  throw new Error(`Modifier "${r}" not found`);
921
1025
  return n;
922
1026
  }
923
- function ce(e) {
1027
+ function ae(e) {
924
1028
  const r = [];
925
1029
  function n(t, i) {
926
1030
  i.length > 0 && r.push([...i].sort());
927
1031
  for (let c = t; c < e.length; c++) {
928
- const o = e[c];
929
- if (o)
930
- if (o.length === 1 && o[0])
931
- n(c + 1, [...i, o[0]]);
1032
+ const s = e[c];
1033
+ if (s)
1034
+ if (s.length === 1 && s[0])
1035
+ n(c + 1, [...i, s[0]]);
932
1036
  else
933
- for (const u of o)
934
- n(c + 1, [...i, u]);
1037
+ for (const a of s)
1038
+ n(c + 1, [...i, a]);
935
1039
  }
936
1040
  }
937
1041
  return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
938
1042
  }
939
- function fe(e, r, n) {
1043
+ function ue(e, r, n) {
940
1044
  const t = {
941
1045
  ...e,
942
1046
  modifiers: [...n.keys()]
@@ -944,13 +1048,13 @@ function fe(e, r, n) {
944
1048
  for (const c of n.values())
945
1049
  c.factory({
946
1050
  ...i,
947
- declarations: R(t.declarations),
948
- variables: R(t.variables),
949
- children: R(t.children)
950
- }), V(t.declarations, i);
1051
+ declarations: F(t.declarations),
1052
+ variables: F(t.variables),
1053
+ children: F(t.children)
1054
+ }), R(t.declarations, i);
951
1055
  return t;
952
1056
  }
953
- function ue(e, r) {
1057
+ function le(e, r) {
954
1058
  return function(t, i) {
955
1059
  const c = {
956
1060
  type: "modifier",
@@ -960,7 +1064,7 @@ function ue(e, r) {
960
1064
  return r.modifiers.push(c), c;
961
1065
  };
962
1066
  }
963
- function ae() {
1067
+ function ye() {
964
1068
  return {
965
1069
  type: "root",
966
1070
  declarations: {},
@@ -972,30 +1076,84 @@ function ae() {
972
1076
  themes: []
973
1077
  };
974
1078
  }
975
- function le(e, r) {
1079
+ function de(e, r) {
1080
+ const n = P({ namespace: e });
1081
+ return (t) => {
1082
+ if (typeof t == "string" && t[0] === "@") {
1083
+ const i = t.slice(1), c = e.find(
1084
+ (s) => i === s || i.startsWith(`${s}.`)
1085
+ );
1086
+ if (c) {
1087
+ const s = i.slice(c.length + 1) || i;
1088
+ if (r.variables.some((a) => a.name === i))
1089
+ return {
1090
+ [s]: {
1091
+ type: "reference",
1092
+ name: i
1093
+ }
1094
+ };
1095
+ } else
1096
+ for (const s of e) {
1097
+ const a = `${s}.${i}`;
1098
+ if (r.variables.some((o) => o.name === a))
1099
+ return {
1100
+ [i]: {
1101
+ type: "reference",
1102
+ name: a
1103
+ }
1104
+ };
1105
+ }
1106
+ return n(t);
1107
+ }
1108
+ return n(t);
1109
+ };
1110
+ }
1111
+ function me(e, r) {
976
1112
  return function(t, i, c = {}) {
977
- const o = {
1113
+ const s = {
978
1114
  type: "utility",
979
1115
  name: t,
980
1116
  factory: i,
981
1117
  values: [],
982
- autogenerate: c.autogenerate ?? z(),
983
- create: (u, s = []) => {
984
- let f = u;
985
- if (Array.isArray(u)) {
1118
+ autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? de(c.namespace, r) : P(
1119
+ c.namespace ? { namespace: c.namespace } : void 0
1120
+ )),
1121
+ namespace: c.namespace,
1122
+ create: (a, o = []) => {
1123
+ let f = a;
1124
+ if (Array.isArray(a)) {
986
1125
  f = {};
987
- for (const l of u) {
988
- const a = o.autogenerate(l);
1126
+ for (const l of a) {
1127
+ const u = s.autogenerate(l);
989
1128
  f = {
990
1129
  ...f,
991
- ...a
1130
+ ...u
992
1131
  };
993
1132
  }
994
1133
  }
995
- for (const [l, a] of Object.entries(f)) {
996
- const y = o.values.find(
997
- (h2) => h2.key === l && h2.modifiers.length === 0
998
- ), m = {
1134
+ for (const [l, u] of Object.entries(f)) {
1135
+ let y = u;
1136
+ if (s.namespace && j(u))
1137
+ if (r.variables.some((g) => g.name === u.name))
1138
+ y = u;
1139
+ else {
1140
+ const g = Array.isArray(s.namespace) ? s.namespace : [s.namespace];
1141
+ let $2 = false;
1142
+ for (const O2 of g) {
1143
+ const m = `${O2}.${l}`;
1144
+ if (m !== u.name && r.variables.some((b) => b.name === m)) {
1145
+ y = {
1146
+ type: "reference",
1147
+ name: m
1148
+ }, $2 = true;
1149
+ break;
1150
+ }
1151
+ }
1152
+ $2 || (y = l);
1153
+ }
1154
+ const p = s.values.find(
1155
+ (g) => g.key === l && g.modifiers.length === 0
1156
+ ), d2 = {
999
1157
  type: "utility",
1000
1158
  name: t,
1001
1159
  value: l,
@@ -1003,196 +1161,253 @@ function le(e, r) {
1003
1161
  variables: [],
1004
1162
  children: [],
1005
1163
  modifiers: []
1006
- }, d2 = v(
1007
- m,
1164
+ }, w2 = v(
1165
+ d2,
1008
1166
  r
1009
1167
  );
1010
- if (m.declarations = i({
1011
- ...d2,
1012
- value: a
1013
- }) ?? {}, V(m.declarations, d2), y || (o.values.push({
1168
+ if (d2.declarations = i({
1169
+ ...w2,
1170
+ value: y
1171
+ }) ?? {}, R(d2.declarations, w2), p || (s.values.push({
1014
1172
  key: l,
1015
- value: a,
1173
+ value: y,
1016
1174
  modifiers: []
1017
- }), e.children.push(m)), s && s.length > 0) {
1018
- const h2 = s.map((b) => b.key), H2 = ce(h2).filter((b) => !o.values.find(
1019
- (g2) => g2.key === l && g2.modifiers.length === b.length && g2.modifiers.every((w2) => b.includes(w2))
1020
- )).reduce((b, g2) => {
1021
- const w2 = /* @__PURE__ */ new Map();
1022
- for (const K2 of g2) {
1023
- const k2 = s.find(
1024
- (N2) => N2.key.includes(K2)
1175
+ }), e.children.push(d2)), o && o.length > 0) {
1176
+ const g = o.map((m) => m.key), O2 = ae(g).filter((m) => !s.values.find(
1177
+ (b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k2) => m.includes(k2))
1178
+ )).reduce((m, b) => {
1179
+ const k2 = /* @__PURE__ */ new Map();
1180
+ for (const U2 of b) {
1181
+ const M2 = o.find(
1182
+ (q2) => q2.key.includes(U2)
1025
1183
  );
1026
- k2 && q(k2) && w2.set(K2, k2);
1184
+ M2 && I(M2) && k2.set(U2, M2);
1027
1185
  }
1028
- return o.values.push({
1186
+ return s.values.push({
1029
1187
  key: l,
1030
- value: a,
1031
- modifiers: g2
1032
- }), b.push(fe(m, r, w2)), b;
1188
+ value: y,
1189
+ modifiers: b
1190
+ }), m.push(ue(d2, r, k2)), m;
1033
1191
  }, []);
1034
- e.children.push(...H2);
1192
+ e.children.push(...O2);
1035
1193
  }
1036
1194
  }
1037
1195
  }
1038
1196
  };
1039
- return r.utilities.push(o), o.create;
1197
+ return r.utilities.push(s), s.create;
1040
1198
  };
1041
1199
  }
1042
- function ye(e, r) {
1200
+ function pe(e, r) {
1043
1201
  return function(t, i) {
1044
- const c = r.themes.find((s) => s.name === t), o = c ?? {
1202
+ const c = r.themes.find((o) => o.name === t), s = c ?? {
1045
1203
  type: "theme",
1046
1204
  name: t,
1047
1205
  declarations: {},
1048
1206
  variables: [],
1049
1207
  children: []
1050
1208
  };
1051
- c || r.themes.push(o);
1052
- const u = v(o, r);
1053
- return i && i(u), o;
1209
+ c || r.themes.push(s);
1210
+ const a = v(s, r);
1211
+ return i && i(a), s;
1054
1212
  };
1055
1213
  }
1056
- function de(e, r) {
1214
+ function he(e, r) {
1057
1215
  return function(t) {
1058
1216
  const i = {
1059
1217
  type: "recipe",
1060
1218
  ...t
1061
1219
  };
1062
- return i._runtime = me(i, r), pe(i, r), r.recipes.push(i), i;
1220
+ return i._runtime = ge(i, r), be(i, r), r.recipes.push(i), i;
1063
1221
  };
1064
1222
  }
1065
1223
  function _(e, r) {
1066
1224
  const n = e.autogenerate(r);
1067
1225
  return Object.keys(n)[0] ?? "default";
1068
1226
  }
1069
- function F(e, r) {
1227
+ function x(e, r) {
1070
1228
  const n = {};
1071
1229
  for (const [t, i] of Object.entries(e))
1072
- if (P(i)) {
1230
+ if (L(i)) {
1073
1231
  const c = {};
1074
- for (const [o, u] of Object.entries(i)) {
1075
- const s = T(r, o);
1076
- s && (c[o] = _(
1077
- s,
1078
- u
1079
- ));
1232
+ for (const [s, a] of Object.entries(i)) {
1233
+ const o = S(r, s);
1234
+ o ? c[s] = _(
1235
+ o,
1236
+ a
1237
+ ) : console.warn(
1238
+ `[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`
1239
+ );
1080
1240
  }
1081
1241
  n[t] = c;
1082
1242
  } else if (typeof i == "boolean")
1083
1243
  n[t] = i;
1084
1244
  else {
1085
- const c = T(r, t);
1086
- c && (n[t] = _(c, i));
1245
+ const c = S(r, t);
1246
+ c ? n[t] = _(c, i) : console.warn(
1247
+ `[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
1248
+ );
1087
1249
  }
1088
1250
  return n;
1089
1251
  }
1090
- function me(e, r) {
1252
+ function ge(e, r) {
1091
1253
  const n = {};
1092
- if (e.base && (n.base = F(e.base, r)), e.variants) {
1254
+ if (e.base && (n.base = x(e.base, r)), e.variants) {
1093
1255
  const t = {};
1094
1256
  for (const [i, c] of Object.entries(e.variants)) {
1095
- const o = {};
1096
- for (const [u, s] of Object.entries(
1257
+ const s = {};
1258
+ for (const [a, o] of Object.entries(
1097
1259
  c
1098
1260
  ))
1099
- s == null ? o[u] = null : o[u] = F(
1100
- s,
1261
+ o == null ? s[a] = null : s[a] = x(
1262
+ o,
1101
1263
  r
1102
1264
  );
1103
- t[i] = o;
1265
+ t[i] = s;
1104
1266
  }
1105
1267
  n.variants = t;
1106
1268
  }
1107
1269
  return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
1108
1270
  match: { ...t.match },
1109
- css: F(t.css, r)
1271
+ css: x(t.css, r)
1110
1272
  }))), n;
1111
1273
  }
1112
- function P(e) {
1113
- return !A(e) && typeof e == "object" && e !== null;
1274
+ function L(e) {
1275
+ return !j(e) && typeof e == "object" && e !== null;
1114
1276
  }
1115
- function x(e, r) {
1277
+ function E(e, r) {
1116
1278
  const n = (t, i, c) => {
1117
- let o = r.get(t);
1118
- o || (o = [], r.set(t, o)), o.push({ value: i, modifiers: c });
1279
+ let s = r.get(t);
1280
+ s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
1119
1281
  };
1120
1282
  for (const [t, i] of Object.entries(e))
1121
- if (P(i)) {
1283
+ if (L(i)) {
1122
1284
  const c = t.split(":");
1123
- for (const [o, u] of Object.entries(i))
1124
- n(o, u, c);
1285
+ for (const [s, a] of Object.entries(i))
1286
+ n(s, a, c);
1125
1287
  } else
1126
1288
  n(t, i, []);
1127
1289
  }
1128
- function T(e, r) {
1290
+ function S(e, r) {
1129
1291
  const n = e.utilities.find((i) => i.name === r);
1130
1292
  if (n)
1131
1293
  return n;
1132
1294
  const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
1133
1295
  return e.utilities.find((i) => i.name === t);
1134
1296
  }
1135
- function pe(e, r) {
1297
+ function be(e, r) {
1136
1298
  const n = /* @__PURE__ */ new Map();
1137
- if (e.base && x(e.base, n), e.variants)
1299
+ if (e.base && E(e.base, n), e.variants)
1138
1300
  for (const i of Object.values(e.variants))
1139
1301
  for (const c of Object.values(i))
1140
- x(
1302
+ E(
1141
1303
  c,
1142
1304
  n
1143
1305
  );
1144
1306
  if (e.compoundVariants)
1145
1307
  for (const i of e.compoundVariants)
1146
- i.css && x(i.css, n);
1308
+ i.css && E(i.css, n);
1147
1309
  const t = /* @__PURE__ */ new Map();
1148
1310
  for (const [i, c] of n) {
1149
- const o = T(r, i);
1150
- if (!o) {
1311
+ const s = S(r, i);
1312
+ if (!s) {
1151
1313
  console.warn(
1152
1314
  `[styleframe] Utility "${i}" not found in registry. Skipping.`
1153
1315
  );
1154
1316
  continue;
1155
1317
  }
1156
- for (const u of c) {
1157
- const s = [];
1158
- for (const f of u.modifiers) {
1318
+ for (const a of c) {
1319
+ const o = [];
1320
+ for (const f of a.modifiers) {
1159
1321
  if (!t.has(f))
1160
1322
  try {
1161
- t.set(f, re(r, f));
1323
+ t.set(f, se(r, f));
1162
1324
  } catch {
1163
1325
  console.warn(
1164
1326
  `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
1165
1327
  ), t.set(f, null);
1166
1328
  }
1167
1329
  const l = t.get(f);
1168
- l && s.push(l);
1330
+ l && o.push(l);
1169
1331
  }
1170
- o.create(
1171
- [u.value],
1172
- s.length > 0 ? s : void 0
1332
+ s.create(
1333
+ [a.value],
1334
+ o.length > 0 ? o : void 0
1173
1335
  );
1174
1336
  }
1175
1337
  }
1176
1338
  }
1177
- function Re(e) {
1178
- 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);
1339
+ function Fe(e) {
1340
+ const r = ie("sf-"), n = ye(), t = { ...e }, i = me(n, n), c = le(n, n), s = he(n, n), a = pe(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d2 } = v(n, n);
1179
1341
  return {
1180
1342
  id: r,
1181
1343
  root: n,
1182
- variable: s,
1344
+ variable: o,
1183
1345
  selector: f,
1184
1346
  utility: i,
1185
1347
  modifier: c,
1186
- recipe: o,
1187
- theme: u,
1348
+ recipe: s,
1349
+ theme: a,
1188
1350
  atRule: l,
1189
- keyframes: a,
1351
+ keyframes: u,
1190
1352
  media: y,
1191
- ref: m,
1353
+ ref: p,
1192
1354
  css: d2,
1193
1355
  options: t
1194
1356
  };
1195
1357
  }
1358
+ function createLoader(basePath, alias) {
1359
+ return createJiti(basePath, {
1360
+ fsCache: false,
1361
+ moduleCache: false,
1362
+ alias
1363
+ });
1364
+ }
1365
+ function trackExports(module) {
1366
+ const exports = /* @__PURE__ */ new Map();
1367
+ for (const [name, value] of Object.entries(module)) {
1368
+ if (name === "default") continue;
1369
+ let type = null;
1370
+ if (ke(value)) {
1371
+ type = "recipe";
1372
+ value._exportName = name;
1373
+ } else if (Ae(value)) {
1374
+ type = "selector";
1375
+ value._exportName = name;
1376
+ }
1377
+ if (type) {
1378
+ exports.set(name, { name, type });
1379
+ }
1380
+ }
1381
+ return exports;
1382
+ }
1383
+ async function loadModule(filePath, options = {}) {
1384
+ const { alias, validateInstance = true } = options;
1385
+ const jiti = createLoader(path.dirname(filePath), alias);
1386
+ const module = await jiti.import(filePath);
1387
+ if (!module.default) {
1388
+ throw new Error(
1389
+ `Missing default export in ${filePath}. Expected a Styleframe instance.`
1390
+ );
1391
+ }
1392
+ if (validateInstance && !Ve(module.default)) {
1393
+ throw new Error(
1394
+ `Invalid default export in ${filePath}. Expected a Styleframe instance created with styleframe().`
1395
+ );
1396
+ }
1397
+ const exports = trackExports(module);
1398
+ return {
1399
+ module,
1400
+ instance: module.default,
1401
+ exports
1402
+ };
1403
+ }
1404
+ async function loadExtensionModule(filePath, options = {}) {
1405
+ const { alias } = options;
1406
+ const jiti = createLoader(path.dirname(filePath), alias);
1407
+ const module = await jiti.import(filePath);
1408
+ const exports = trackExports(module);
1409
+ return { module, exports };
1410
+ }
1196
1411
  const SUPPORTED_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
1197
1412
  function hasKnownExtension(filePath) {
1198
1413
  return SUPPORTED_EXTENSIONS.some((ext) => filePath.endsWith(ext));
@@ -1210,33 +1425,16 @@ function resolveConfigFile(cwd, entry) {
1210
1425
  }
1211
1426
  return void 0;
1212
1427
  }
1213
- function trackNamedExports(module) {
1214
- for (const [exportName, exportValue] of Object.entries(module)) {
1215
- if (exportName === "default") continue;
1216
- if (Ae(exportValue)) {
1217
- exportValue._exportName = exportName;
1218
- } else if (be(exportValue)) {
1219
- exportValue._exportName = exportName;
1220
- }
1221
- }
1222
- }
1223
1428
  async function loadConfiguration({
1224
1429
  cwd = process.cwd(),
1225
1430
  entry = "styleframe.config"
1226
1431
  } = {}) {
1227
1432
  const resolvedPath = resolveConfigFile(cwd, entry);
1228
1433
  if (!resolvedPath) {
1229
- return Re();
1230
- }
1231
- const jiti = createJiti(path.dirname(resolvedPath), { cache: false });
1232
- const module = await jiti.import(resolvedPath);
1233
- if (!module.default) {
1234
- throw new Error(
1235
- `Missing default export in ${resolvedPath}. Expected a Styleframe instance.`
1236
- );
1434
+ return Fe();
1237
1435
  }
1238
- trackNamedExports(module);
1239
- return module.default;
1436
+ const { instance } = await loadModule(resolvedPath);
1437
+ return instance;
1240
1438
  }
1241
1439
  async function watchConfiguration({
1242
1440
  cwd = process.cwd(),
@@ -1268,7 +1466,11 @@ async function watchConfiguration({
1268
1466
  }
1269
1467
  export {
1270
1468
  build,
1469
+ createLoader,
1271
1470
  directoryExists,
1272
1471
  loadConfiguration,
1472
+ loadExtensionModule,
1473
+ loadModule,
1474
+ trackExports,
1273
1475
  watchConfiguration
1274
1476
  };