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