@styleframe/transpiler 2.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @styleframe/transpiler
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#117](https://github.com/styleframe-dev/styleframe/pull/117) [`ffe6764`](https://github.com/styleframe-dev/styleframe/commit/ffe6764a2e6c84d5b3cfdf431bf11f17a3f3f118) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Introduce global Styleframe single-instance architecture. Extension files (`*.styleframe.ts`) now share the same instance created in `styleframe.config.ts` instead of creating independent instances. This is a breaking change that affects how styles are imported and composed across files.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`266f961`](https://github.com/styleframe-dev/styleframe/commit/266f96143e9ffb47e0e6326d0e5e7cc9d974ab83), [`ffe6764`](https://github.com/styleframe-dev/styleframe/commit/ffe6764a2e6c84d5b3cfdf431bf11f17a3f3f118)]:
12
+ - @styleframe/core@3.0.0
13
+
3
14
  ## 2.6.0
4
15
 
5
16
  ### Minor Changes
@@ -54,10 +54,11 @@ export declare function toKebabCase<S extends string>(str: S): KebabCase<S>;
54
54
  export declare function transpile(instance: Styleframe, { type, consumers, }?: TranspileOptions): Promise<Output>;
55
55
 
56
56
  export declare type TranspileOptions = {
57
- type?: "css" | "ts" | "all";
57
+ type?: "css" | "ts" | "dts" | "all";
58
58
  consumers?: {
59
59
  css: ConsumeFunction;
60
60
  ts: ConsumeFunction;
61
+ dts: ConsumeFunction;
61
62
  };
62
63
  };
63
64
 
@@ -1,190 +1,190 @@
1
- const Fe = " ", F = ["charset", "import", "namespace"], L = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, x = ({
1
+ const Ue = " ", P = ["charset", "import", "namespace"], U = ["layer"], k = ({ name: e }) => `[data-theme="${e}"]`, M = ({
2
2
  name: e,
3
3
  value: t,
4
4
  modifiers: r
5
- }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, w = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
6
- function I(e, t) {
5
+ }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, O = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
6
+ function V(e, t) {
7
7
  return `@${e}${t ? " " : ""}${t}`;
8
8
  }
9
- const U = /\d/, P = ["-", "_", "/", "."];
10
- function M(e = "") {
11
- if (!U.test(e))
9
+ const K = /\d/, q = ["-", "_", "/", "."];
10
+ function z(e = "") {
11
+ if (!K.test(e))
12
12
  return e !== e.toLowerCase();
13
13
  }
14
- function N(e, t) {
15
- const r = P, n = [];
14
+ function _(e, t) {
15
+ const r = q, o = [];
16
16
  if (!e || typeof e != "string")
17
- return n;
18
- let o = "", s, u;
17
+ return o;
18
+ let n = "", s, u;
19
19
  for (const a of e) {
20
20
  const c = r.includes(a);
21
21
  if (c === !0) {
22
- n.push(o), o = "", s = void 0;
22
+ o.push(n), n = "", s = void 0;
23
23
  continue;
24
24
  }
25
- const i = M(a);
25
+ const i = z(a);
26
26
  if (u === !1) {
27
27
  if (s === !1 && i === !0) {
28
- n.push(o), o = a, s = i;
28
+ o.push(n), n = a, s = i;
29
29
  continue;
30
30
  }
31
- if (s === !0 && i === !1 && o.length > 1) {
32
- const f = o.at(-1);
33
- n.push(o.slice(0, Math.max(0, o.length - 1))), o = f + a, s = i;
31
+ if (s === !0 && i === !1 && n.length > 1) {
32
+ const f = n.at(-1);
33
+ o.push(n.slice(0, Math.max(0, n.length - 1))), n = f + a, s = i;
34
34
  continue;
35
35
  }
36
36
  }
37
- o += a, s = i, u = c;
37
+ n += a, s = i, u = c;
38
38
  }
39
- return n.push(o), n;
39
+ return o.push(n), o;
40
40
  }
41
- function k(e) {
41
+ function H(e) {
42
42
  return e ? e[0].toUpperCase() + e.slice(1) : "";
43
43
  }
44
- function V(e) {
44
+ function Q(e) {
45
45
  return e ? e[0].toLowerCase() + e.slice(1) : "";
46
46
  }
47
- function q(e, t) {
48
- return e ? (Array.isArray(e) ? e : N(e)).map((r) => k(r)).join("") : "";
47
+ function J(e, t) {
48
+ return e ? (Array.isArray(e) ? e : _(e)).map((r) => H(r)).join("") : "";
49
49
  }
50
- function K(e, t) {
51
- return V(q(e || ""));
50
+ function Z(e, t) {
51
+ return Q(J(e || ""));
52
52
  }
53
- function z(e, t) {
54
- return e ? (Array.isArray(e) ? e : N(e)).map((r) => r.toLowerCase()).join("-") : "";
53
+ function W(e, t) {
54
+ return e ? (Array.isArray(e) ? e : _(e)).map((r) => r.toLowerCase()).join("-") : "";
55
55
  }
56
- function H(e) {
56
+ function G(e) {
57
57
  return ` ${e}`;
58
58
  }
59
- function Q(e) {
59
+ function Y(e) {
60
60
  return e.split(`
61
- `).map((t) => H(t)).join(`
61
+ `).map((t) => G(t)).join(`
62
62
  `);
63
63
  }
64
- function J(e) {
64
+ function x(e) {
65
65
  return e === e.toUpperCase();
66
66
  }
67
- function Z(e) {
68
- return K(e);
69
- }
70
- function W(e) {
71
- return z(e);
67
+ function T(e) {
68
+ return Z(e);
72
69
  }
73
- function G(e) {
70
+ function X(e) {
74
71
  return W(e);
75
72
  }
76
- function O(e, t) {
77
- return `${e.startsWith("--") ? e : G(e)}: ${t};`;
73
+ function ee(e) {
74
+ return X(e);
78
75
  }
79
- function Y(e) {
76
+ function B(e, t) {
77
+ return `${e.startsWith("--") ? e : ee(e)}: ${t};`;
78
+ }
79
+ function te(e) {
80
80
  return `{${e.length > 0 ? `
81
- ` : ""}${e.map((t) => `${Q(`${t}`)}
81
+ ` : ""}${e.map((t) => `${Y(`${t}`)}
82
82
  `).join("")}}`;
83
83
  }
84
84
  function E(e) {
85
85
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
86
86
  }
87
- function X(e, t) {
88
- return O(E(e), t);
87
+ function re(e, t) {
88
+ return B(E(e), t);
89
89
  }
90
- function ee(e, t) {
90
+ function ne(e, t) {
91
91
  return `var(${E(e)}${t ? `, ${t}` : ""})`;
92
92
  }
93
- function R(e, t) {
94
- return `${e} ${Y(t)}`;
93
+ function w(e, t) {
94
+ return `${e} ${te(t)}`;
95
95
  }
96
- function te(e) {
97
- return function(r, n) {
98
- return Object.entries(r).map(([o, s]) => O(o, e(s, n)));
96
+ function oe(e) {
97
+ return function(r, o) {
98
+ return Object.entries(r).map(([n, s]) => B(n, e(s, o)));
99
99
  };
100
100
  }
101
- function B(e) {
102
- return function(r, n) {
103
- const s = (n.variables?.name ?? w)({ name: r.name });
104
- return X(s, e(r.value, n));
101
+ function F(e) {
102
+ return function(r, o) {
103
+ const s = (o.variables?.name ?? O)({ name: r.name });
104
+ return re(s, e(r.value, o));
105
105
  };
106
106
  }
107
107
  function S(e) {
108
- const t = B(e), r = te(e);
109
- return function(o, s, u) {
110
- const { variables: a, declarations: c, children: i } = s, f = o === ":root", l = (a ?? []).map(
111
- (A) => t(A, u)
108
+ const t = F(e), r = oe(e);
109
+ return function(n, s, u) {
110
+ const { variables: a, declarations: c, children: i } = s, f = n === ":root", l = (a ?? []).map(
111
+ (g) => t(g, u)
112
112
  ), m = r(
113
113
  c ?? {},
114
114
  u
115
115
  ), y = (i ?? []).map(
116
- (A) => e(A, u)
117
- ), p = l.length > 0, b = m.length > 0, C = y.length > 0;
118
- return f ? `${p || b ? R(o, [
116
+ (g) => e(g, u)
117
+ ), p = l.length > 0, b = m.length > 0, j = y.length > 0;
118
+ return f ? `${p || b ? w(n, [
119
119
  ...l,
120
120
  ...p && b ? [""] : [],
121
121
  ...m
122
- ]) : ""}${C && (p || b) ? `
122
+ ]) : ""}${j && (p || b) ? `
123
123
 
124
124
  ` : ""}${y.join(`
125
125
 
126
- `)}` : R(o, [
126
+ `)}` : w(n, [
127
127
  ...l,
128
- ...p && (C || b) ? [""] : [],
128
+ ...p && (j || b) ? [""] : [],
129
129
  ...m,
130
- ...b && C ? [""] : [],
130
+ ...b && j ? [""] : [],
131
131
  ...y.flatMap(
132
- (A, _) => _ === y.length - 1 ? [A] : [A, ""]
132
+ (g, I) => I === y.length - 1 ? [g] : [g, ""]
133
133
  )
134
134
  ]);
135
135
  };
136
136
  }
137
- function re(e) {
137
+ function ce(e) {
138
138
  const t = S(e);
139
- return function(n, o) {
140
- const s = F.includes(n.identifier), u = L.includes(
141
- n.identifier
142
- ), a = Object.keys(n.declarations).length > 0, c = n.variables.length > 0, i = n.children.length > 0, f = I(n.identifier, n.rule);
143
- return s || u && !(a || c || i) ? `${f};` : t(f, n, o);
139
+ return function(o, n) {
140
+ const s = P.includes(o.identifier), u = U.includes(
141
+ o.identifier
142
+ ), a = Object.keys(o.declarations).length > 0, c = o.variables.length > 0, i = o.children.length > 0, f = V(o.identifier, o.rule);
143
+ return s || u && !(a || c || i) ? `${f};` : t(f, o, n);
144
144
  };
145
145
  }
146
- function ne(e) {
147
- return function(r, n) {
148
- return r.value.map((o) => e(o, n)).join("").trim();
146
+ function ue(e) {
147
+ return function(r, o) {
148
+ return r.value.map((n) => e(n, o)).join("").trim();
149
149
  };
150
150
  }
151
- function oe(e) {
151
+ function se(e) {
152
152
  return typeof e == "object" && e !== null;
153
153
  }
154
154
  function h(e, t) {
155
- return oe(e) && "type" in e && e.type === t;
155
+ return se(e) && "type" in e && e.type === t;
156
156
  }
157
- function ce(e) {
157
+ function ie(e) {
158
158
  return h(e, "variable");
159
159
  }
160
- function ue(e) {
160
+ function ae(e) {
161
161
  return h(e, "reference");
162
162
  }
163
- function v(e) {
163
+ function C(e) {
164
164
  return h(e, "selector");
165
165
  }
166
- function ie(e) {
166
+ function le(e) {
167
167
  return h(e, "at-rule");
168
168
  }
169
- function se(e) {
169
+ function fe(e) {
170
170
  return h(e, "utility");
171
171
  }
172
- function ae(e) {
172
+ function me(e) {
173
173
  return h(e, "css");
174
174
  }
175
- function le(e) {
175
+ function pe(e) {
176
176
  return h(e, "theme");
177
177
  }
178
- function T(e) {
178
+ function N(e) {
179
179
  return h(e, "root");
180
180
  }
181
- function fe(e) {
181
+ function D(e) {
182
182
  return h(e, "recipe");
183
183
  }
184
- function me(e) {
184
+ function L(e) {
185
185
  return e.charAt(0).toUpperCase() + e.slice(1);
186
186
  }
187
- function g(e) {
187
+ function A(e) {
188
188
  if (e instanceof Buffer)
189
189
  return Buffer.from(e);
190
190
  const t = e.constructor;
@@ -194,67 +194,67 @@ function g(e) {
194
194
  e.byteLength / e.BYTES_PER_ELEMENT || 1
195
195
  );
196
196
  }
197
- function pe(e) {
197
+ function ye(e) {
198
198
  if (e = e || {}, e.circular)
199
- return ye(e);
199
+ return de(e);
200
200
  const t = /* @__PURE__ */ new Map();
201
201
  if (t.set(Date, (u) => new Date(u)), t.set(
202
202
  Map,
203
- (u, a) => new Map(n(Array.from(u), a))
203
+ (u, a) => new Map(o(Array.from(u), a))
204
204
  ), t.set(
205
205
  Set,
206
- (u, a) => new Set(n(Array.from(u), a))
206
+ (u, a) => new Set(o(Array.from(u), a))
207
207
  ), e.constructorHandlers)
208
208
  for (const u of e.constructorHandlers)
209
209
  t.set(u[0], u[1]);
210
210
  let r;
211
- return e.proto ? s : o;
212
- function n(u, a) {
211
+ return e.proto ? s : n;
212
+ function o(u, a) {
213
213
  const c = Object.keys(u), i = Array.from({ length: c.length });
214
214
  for (let f = 0; f < c.length; f++) {
215
215
  const l = c[f], m = u[l];
216
- 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);
216
+ 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(m) : i[l] = a(m);
217
217
  }
218
218
  return i;
219
219
  }
220
- function o(u) {
220
+ function n(u) {
221
221
  if (typeof u != "object" || u === null) return u;
222
- if (Array.isArray(u)) return n(u, o);
222
+ if (Array.isArray(u)) return o(u, n);
223
223
  if (u.constructor !== Object && (r = t.get(u.constructor)))
224
- return r(u, o);
224
+ return r(u, n);
225
225
  const a = {};
226
226
  for (const c in u) {
227
227
  if (Object.hasOwnProperty.call(u, c) === !1) continue;
228
228
  const i = u[c];
229
- 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);
229
+ 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(i) : a[c] = n(i);
230
230
  }
231
231
  return a;
232
232
  }
233
233
  function s(u) {
234
234
  if (typeof u != "object" || u === null) return u;
235
- if (Array.isArray(u)) return n(u, s);
235
+ if (Array.isArray(u)) return o(u, s);
236
236
  if (u.constructor !== Object && (r = t.get(u.constructor)))
237
237
  return r(u, s);
238
238
  const a = {};
239
239
  for (const c in u) {
240
240
  const i = u[c];
241
- 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);
241
+ 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(i) : a[c] = s(i);
242
242
  }
243
243
  return a;
244
244
  }
245
245
  }
246
- function ye(e) {
247
- const t = [], r = [], n = /* @__PURE__ */ new Map();
248
- if (n.set(Date, (c) => new Date(c)), n.set(
246
+ function de(e) {
247
+ const t = [], r = [], o = /* @__PURE__ */ new Map();
248
+ if (o.set(Date, (c) => new Date(c)), o.set(
249
249
  Map,
250
250
  (c, i) => new Map(s(Array.from(c), i))
251
- ), n.set(
251
+ ), o.set(
252
252
  Set,
253
253
  (c, i) => new Set(s(Array.from(c), i))
254
254
  ), e.constructorHandlers)
255
255
  for (const c of e.constructorHandlers)
256
- n.set(c[0], c[1]);
257
- let o;
256
+ o.set(c[0], c[1]);
257
+ let n;
258
258
  return e.proto ? a : u;
259
259
  function s(c, i) {
260
260
  const f = Object.keys(c), l = Array.from({ length: f.length });
@@ -262,10 +262,10 @@ function ye(e) {
262
262
  const y = f[m], p = c[y];
263
263
  if (typeof p != "object" || p === null)
264
264
  l[y] = p;
265
- else if (p.constructor !== Object && (o = n.get(p.constructor)))
266
- l[y] = o(p, i);
265
+ else if (p.constructor !== Object && (n = o.get(p.constructor)))
266
+ l[y] = n(p, i);
267
267
  else if (ArrayBuffer.isView(p))
268
- l[y] = g(p);
268
+ l[y] = A(p);
269
269
  else {
270
270
  const b = t.indexOf(p);
271
271
  b !== -1 ? l[y] = r[b] : l[y] = i(p);
@@ -276,8 +276,8 @@ function ye(e) {
276
276
  function u(c) {
277
277
  if (typeof c != "object" || c === null) return c;
278
278
  if (Array.isArray(c)) return s(c, u);
279
- if (c.constructor !== Object && (o = n.get(c.constructor)))
280
- return o(c, u);
279
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
280
+ return n(c, u);
281
281
  const i = {};
282
282
  t.push(c), r.push(i);
283
283
  for (const f in c) {
@@ -285,10 +285,10 @@ function ye(e) {
285
285
  const l = c[f];
286
286
  if (typeof l != "object" || l === null)
287
287
  i[f] = l;
288
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
289
- i[f] = o(l, u);
288
+ else if (l.constructor !== Object && (n = o.get(l.constructor)))
289
+ i[f] = n(l, u);
290
290
  else if (ArrayBuffer.isView(l))
291
- i[f] = g(l);
291
+ i[f] = A(l);
292
292
  else {
293
293
  const m = t.indexOf(l);
294
294
  m !== -1 ? i[f] = r[m] : i[f] = u(l);
@@ -299,18 +299,18 @@ function ye(e) {
299
299
  function a(c) {
300
300
  if (typeof c != "object" || c === null) return c;
301
301
  if (Array.isArray(c)) return s(c, a);
302
- if (c.constructor !== Object && (o = n.get(c.constructor)))
303
- return o(c, a);
302
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
303
+ return n(c, a);
304
304
  const i = {};
305
305
  t.push(c), r.push(i);
306
306
  for (const f in c) {
307
307
  const l = c[f];
308
308
  if (typeof l != "object" || l === null)
309
309
  i[f] = l;
310
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
311
- i[f] = o(l, a);
310
+ else if (l.constructor !== Object && (n = o.get(l.constructor)))
311
+ i[f] = n(l, a);
312
312
  else if (ArrayBuffer.isView(l))
313
- i[f] = g(l);
313
+ i[f] = A(l);
314
314
  else {
315
315
  const m = t.indexOf(l);
316
316
  m !== -1 ? i[f] = r[m] : i[f] = a(l);
@@ -319,27 +319,27 @@ function ye(e) {
319
319
  return t.pop(), r.pop(), i;
320
320
  }
321
321
  }
322
- pe();
323
- function de(e) {
324
- return function(r, n) {
322
+ ye();
323
+ function he(e) {
324
+ return function(r, o) {
325
325
  return r != null ? `${r}` : "";
326
326
  };
327
327
  }
328
- function he(e) {
329
- return function(r, n) {
330
- const s = (n.variables?.name ?? w)({ name: r.name });
331
- return ee(
328
+ function be(e) {
329
+ return function(r, o) {
330
+ const s = (o.variables?.name ?? O)({ name: r.name });
331
+ return ne(
332
332
  s,
333
- r.fallback ? e(r.fallback, n) : void 0
333
+ r.fallback ? e(r.fallback, o) : void 0
334
334
  );
335
335
  };
336
336
  }
337
- function be(e) {
337
+ function ge(e) {
338
338
  const t = S(e);
339
- return function(n, o) {
340
- return n.themes.reduce(
341
- (s, u) => (s.push(e(u, o)), s),
342
- [t(":root", n, o)]
339
+ return function(o, n) {
340
+ return o.themes.reduce(
341
+ (s, u) => (s.push(e(u, n)), s),
342
+ [t(":root", o, n)]
343
343
  // Default theme (root)
344
344
  ).join(`
345
345
 
@@ -348,108 +348,108 @@ function be(e) {
348
348
  }
349
349
  function Ae(e) {
350
350
  const t = S(e);
351
- return function(n, o) {
352
- return t(n.query, n, o);
351
+ return function(o, n) {
352
+ return t(o.query, o, n);
353
353
  };
354
354
  }
355
- function ge(e) {
355
+ function Se(e) {
356
356
  const t = S(e);
357
- return function(n, o) {
358
- const u = (o.themes?.selector ?? D)({ name: n.name });
359
- return t(u, n, o);
357
+ return function(o, n) {
358
+ const u = (n.themes?.selector ?? k)({ name: o.name });
359
+ return t(u, o, n);
360
360
  };
361
361
  }
362
- function Se(e) {
362
+ function Ce(e) {
363
363
  const t = S(e);
364
- return function(n, o) {
365
- const s = [], a = (o.utilities?.selector ?? x)({
366
- name: n.name,
367
- value: n.value,
368
- modifiers: n.modifiers
364
+ return function(o, n) {
365
+ const s = [], a = (n.utilities?.selector ?? M)({
366
+ name: o.name,
367
+ value: o.value,
368
+ modifiers: o.modifiers
369
369
  });
370
- return s.push(t(a, n, o)), s.join(`
370
+ return s.push(t(a, o, n)), s.join(`
371
371
 
372
372
  `);
373
373
  };
374
374
  }
375
375
  function d(e, t) {
376
- const r = be(d), n = Ae(d), o = Se(d), s = re(d), u = ge(d), a = B(d), c = he(d), i = ne(d), f = de();
376
+ const r = ge(d), o = Ae(d), n = Ce(d), s = ce(d), u = Se(d), a = F(d), c = be(d), i = ue(d), f = he();
377
377
  switch (!0) {
378
- case v(e):
379
- return n(e, t);
380
- case se(e):
378
+ case C(e):
381
379
  return o(e, t);
382
- case ie(e):
380
+ case fe(e):
381
+ return n(e, t);
382
+ case le(e):
383
383
  return s(e, t);
384
- case T(e):
384
+ case N(e):
385
385
  return r(e, t);
386
- case le(e):
386
+ case pe(e):
387
387
  return u(e, t);
388
- case ce(e):
388
+ case ie(e):
389
389
  return a(e, t);
390
- case ue(e):
391
- return c(e, t);
392
390
  case ae(e):
391
+ return c(e, t);
392
+ case me(e):
393
393
  return i(e, t);
394
394
  default:
395
395
  return f(e, t);
396
396
  }
397
397
  }
398
- function Ce(e) {
399
- return function(r, n) {
400
- let o = r._exportName;
401
- o || (o = Z(r.name), r.name[0] && J(r.name[0]) && (o = me(o)));
402
- const s = `${o}Recipe`, u = r._runtime ?? {};
398
+ function je(e) {
399
+ return function(r, o) {
400
+ let n = r._exportName;
401
+ n || (n = T(r.name), r.name[0] && x(r.name[0]) && (n = L(n)));
402
+ const s = `${n}Recipe`, u = r._runtime ?? {};
403
403
  return `const ${s} = ${JSON.stringify(
404
404
  u,
405
405
  null,
406
406
  4
407
407
  )} as const satisfies RecipeRuntime;
408
408
 
409
- export const ${o} = createRecipe("${r.name}", ${s});
409
+ export const ${n} = createRecipe("${r.name}", ${s});
410
410
  `;
411
411
  };
412
412
  }
413
- function je(e) {
413
+ function ve(e) {
414
414
  return e.filter(
415
- (t) => v(t) && !!t._exportName
415
+ (t) => C(t) && !!t._exportName
416
416
  );
417
417
  }
418
- function ve(e) {
419
- return function(r, n) {
420
- const o = je(r.children), s = r.recipes.length > 0, u = o.length > 0;
418
+ function Re(e) {
419
+ return function(r, o) {
420
+ const n = ve(r.children), s = r.recipes.length > 0, u = n.length > 0;
421
421
  if (!s && !u)
422
422
  return "";
423
423
  const a = [];
424
424
  return s && (a.push(`import { createRecipe } from '@styleframe/runtime';
425
425
  import type { RecipeRuntime } from '@styleframe/runtime';
426
- `), a.push(e(r.recipes, n))), u && a.push(e(o, n)), a.join(`
426
+ `), a.push(e(r.recipes, o))), u && a.push(e(n, o)), a.join(`
427
427
  `);
428
428
  };
429
429
  }
430
- function Re(e) {
431
- return function(r, n) {
430
+ function $e(e) {
431
+ return function(r, o) {
432
432
  return r._exportName ? `export const ${r._exportName} = ${JSON.stringify(r.query)};
433
433
  ` : "";
434
434
  };
435
435
  }
436
- function j(e, t) {
437
- const r = ve(j), n = Ce(), o = Re();
436
+ function R(e, t) {
437
+ const r = Re(R), o = je(), n = $e();
438
438
  switch (!0) {
439
439
  case Array.isArray(e):
440
- return e.map((s) => j(s, t)).join(`
440
+ return e.map((s) => R(s, t)).join(`
441
441
  `);
442
- case T(e):
442
+ case N(e):
443
443
  return r(e, t);
444
- case fe(e):
445
- return n(e, t);
446
- case v(e):
444
+ case D(e):
447
445
  return o(e, t);
446
+ case C(e):
447
+ return n(e, t);
448
448
  default:
449
449
  return "";
450
450
  }
451
451
  }
452
- const $e = `-----BEGIN PUBLIC KEY-----
452
+ const Ne = `-----BEGIN PUBLIC KEY-----
453
453
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
454
454
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
455
455
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -457,9 +457,9 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
457
457
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
458
458
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
459
459
  GwIDAQAB
460
- -----END PUBLIC KEY-----`, we = "__licenseRequired", Ne = "__licenseValidated";
461
- async function Oe(e) {
462
- const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
460
+ -----END PUBLIC KEY-----`, we = "__licenseRequired", Oe = "__licenseValidated";
461
+ async function _e(e) {
462
+ const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (o) => o.charCodeAt(0));
463
463
  return await crypto.subtle.importKey(
464
464
  "spki",
465
465
  r,
@@ -471,18 +471,18 @@ async function Oe(e) {
471
471
  ["verify"]
472
472
  );
473
473
  }
474
- async function Ee({
474
+ async function xe({
475
475
  payload: e,
476
476
  signature: t
477
477
  }) {
478
- const r = new TextEncoder().encode(e), n = Uint8Array.from(
478
+ const r = new TextEncoder().encode(e), o = Uint8Array.from(
479
479
  atob(t),
480
480
  (s) => s.charCodeAt(0)
481
- ), o = await Oe($e);
481
+ ), n = await _e(Ne);
482
482
  if (!await crypto.subtle.verify(
483
483
  { name: "RSASSA-PKCS1-v1_5" },
484
- o,
485
484
  n,
485
+ o,
486
486
  r
487
487
  ))
488
488
  throw new Error(
@@ -490,13 +490,13 @@ async function Ee({
490
490
  );
491
491
  return JSON.parse(e);
492
492
  }
493
- function Be(e) {
493
+ function Te(e) {
494
494
  return Object.prototype.hasOwnProperty.call(e, we);
495
495
  }
496
- async function Te(e) {
496
+ async function Be(e) {
497
497
  const t = Object.getOwnPropertyDescriptor(
498
498
  e,
499
- Ne
499
+ Oe
500
500
  );
501
501
  if (!t?.value)
502
502
  return {
@@ -514,7 +514,7 @@ async function Te(e) {
514
514
  valid: !1
515
515
  };
516
516
  try {
517
- return await Ee(
517
+ return await xe(
518
518
  r
519
519
  );
520
520
  } catch {
@@ -526,7 +526,81 @@ async function Te(e) {
526
526
  };
527
527
  }
528
528
  }
529
- function _e(e) {
529
+ function Ee(e) {
530
+ const t = e?.variants;
531
+ if (!t || Object.keys(t).length === 0)
532
+ return "Record<string, never>";
533
+ const r = [];
534
+ for (const [o, n] of Object.entries(t)) {
535
+ if (!n) continue;
536
+ const s = Object.keys(n);
537
+ if (s.length > 0) {
538
+ const u = s.map((a) => `"${a}"`).join(" | ");
539
+ r.push(`${o}?: ${u}`);
540
+ }
541
+ }
542
+ return r.length === 0 ? "Record<string, never>" : `{ ${r.join("; ")} }`;
543
+ }
544
+ function Fe(e) {
545
+ return function(r, o) {
546
+ let n = r._exportName;
547
+ n || (n = T(r.name), r.name[0] && x(r.name[0]) && (n = L(n)));
548
+ const s = Ee(r._runtime);
549
+ return ` export const ${n}: (props?: ${s}) => string;`;
550
+ };
551
+ }
552
+ function De(e) {
553
+ return e.filter(
554
+ (t) => C(t) && !!t._exportName
555
+ );
556
+ }
557
+ function Le(e) {
558
+ return function(r, o) {
559
+ const n = De(r.children), s = r.recipes.length > 0, u = n.length > 0, a = [
560
+ "// Auto-generated by @styleframe/plugin - DO NOT EDIT",
561
+ "",
562
+ 'declare module "virtual:styleframe" {',
563
+ ' import type { Styleframe } from "@styleframe/core";',
564
+ "",
565
+ " /** Returns the global styleframe instance from styleframe.config.ts */",
566
+ " export function styleframe(): Styleframe;"
567
+ ];
568
+ if (s) {
569
+ a.push("");
570
+ const c = r.recipes.map((i) => e(i, o)).filter(Boolean);
571
+ a.push(...c);
572
+ }
573
+ if (u) {
574
+ a.push("");
575
+ const c = n.map((i) => e(i, o)).filter(Boolean);
576
+ a.push(...c);
577
+ }
578
+ 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(`
579
+ `);
580
+ };
581
+ }
582
+ function Ie(e) {
583
+ return function(r, o) {
584
+ return r._exportName ? ` export const ${r._exportName}: string;` : "";
585
+ };
586
+ }
587
+ function $(e, t) {
588
+ const r = Le($), o = Fe(), n = Ie();
589
+ switch (!0) {
590
+ case Array.isArray(e):
591
+ return e.map((s) => $(s, t)).join(`
592
+ `);
593
+ case N(e):
594
+ return r(e, t);
595
+ case D(e):
596
+ return o(e, t);
597
+ case C(e):
598
+ return n(e, t);
599
+ default:
600
+ return "";
601
+ }
602
+ }
603
+ function Pe(e) {
530
604
  const t = Math.floor(Math.random() * 100);
531
605
  e.root.children.push({
532
606
  type: "selector",
@@ -550,51 +624,58 @@ function _e(e) {
550
624
  }
551
625
  });
552
626
  }
553
- function $(e, t = "") {
627
+ function v(e, t = "") {
554
628
  return {
555
629
  name: e,
556
630
  content: t
557
631
  };
558
632
  }
559
- async function Le(e, {
633
+ async function ke(e, {
560
634
  type: t = "all",
561
- consumers: r = { css: d, ts: j }
635
+ consumers: r = { css: d, ts: R, dts: $ }
562
636
  } = {}) {
563
- const n = { files: [] }, o = e.options;
564
- if (Be(e)) {
565
- const s = await Te(e);
566
- (!s.valid || s.instanceId !== e.id) && _e(e);
637
+ const o = { files: [] }, n = e.options;
638
+ if (Te(e)) {
639
+ const s = await Be(e);
640
+ (!s.valid || s.instanceId !== e.id) && Pe(e);
567
641
  }
568
642
  if (t === "all" || t === "css") {
569
- const s = $(
643
+ const s = v(
570
644
  "index.css",
571
- r.css(e.root, o)
645
+ r.css(e.root, n)
572
646
  );
573
- n.files.push(s);
647
+ o.files.push(s);
574
648
  }
575
649
  if (t === "all" || t === "ts") {
576
- const s = $(
650
+ const s = v(
577
651
  "index.ts",
578
- r.ts(e.root, o)
652
+ r.ts(e.root, n)
653
+ );
654
+ o.files.push(s);
655
+ }
656
+ if (t === "dts") {
657
+ const s = v(
658
+ "index.d.ts",
659
+ r.dts(e.root, n)
579
660
  );
580
- n.files.push(s);
661
+ o.files.push(s);
581
662
  }
582
- return n;
663
+ return o;
583
664
  }
584
665
  export {
585
- Fe as DEFAULT_INDENT,
586
- F as STATEMENT_AT_RULES,
587
- L as STATEMENT_OR_BLOCK_AT_RULES,
588
- H as addIndentToLine,
666
+ Ue as DEFAULT_INDENT,
667
+ P as STATEMENT_AT_RULES,
668
+ U as STATEMENT_OR_BLOCK_AT_RULES,
669
+ G as addIndentToLine,
589
670
  d as consumeCSS,
590
- j as consumeTS,
591
- $ as createFile,
592
- D as defaultThemeSelectorFn,
593
- x as defaultUtilitySelectorFn,
594
- w as defaultVariableNameFn,
595
- Q as indentLines,
596
- J as isUppercase,
597
- Z as toCamelCase,
598
- W as toKebabCase,
599
- Le as transpile
671
+ R as consumeTS,
672
+ v as createFile,
673
+ k as defaultThemeSelectorFn,
674
+ M as defaultUtilitySelectorFn,
675
+ O as defaultVariableNameFn,
676
+ Y as indentLines,
677
+ x as isUppercase,
678
+ T as toCamelCase,
679
+ X as toKebabCase,
680
+ ke as transpile
600
681
  };
@@ -1,24 +1,24 @@
1
- (function(p,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(p=typeof globalThis<"u"?globalThis:p||self,j(p.transpiler={}))})(this,(function(p){"use strict";const _=["charset","import","namespace"],$=["layer"],w=({name:e})=>`[data-theme="${e}"]`,O=({name:e,value:t,modifiers:n})=>`._${[...n,e,...t==="default"?[]:[t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g,"\\$&")}`,v=({name:e})=>e.replace(/^\.+|\.+$/g,"").replace(/\.+/g,"--");function q(e,t){return`@${e}${t?" ":""}${t}`}const x=/\d/,z=["-","_","/","."];function H(e=""){if(!x.test(e))return e!==e.toLowerCase()}function F(e,t){const n=z,r=[];if(!e||typeof e!="string")return r;let o="",a,u;for(const s of e){const c=n.includes(s);if(c===!0){r.push(o),o="",a=void 0;continue}const i=H(s);if(u===!1){if(a===!1&&i===!0){r.push(o),o=s,a=i;continue}if(a===!0&&i===!1&&o.length>1){const f=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=f+s,a=i;continue}}o+=s,a=i,u=c}return r.push(o),r}function Q(e){return e?e[0].toUpperCase()+e.slice(1):""}function J(e){return e?e[0].toLowerCase()+e.slice(1):""}function Z(e,t){return e?(Array.isArray(e)?e:F(e)).map(n=>Q(n)).join(""):""}function W(e,t){return J(Z(e||""))}function G(e,t){return e?(Array.isArray(e)?e:F(e)).map(n=>n.toLowerCase()).join("-"):""}function L(e){return` ${e}`}function B(e){return e.split(`
2
- `).map(t=>L(t)).join(`
3
- `)}function U(e){return e===e.toUpperCase()}function D(e){return W(e)}function I(e){return G(e)}function Y(e){return I(e)}function M(e,t){return`${e.startsWith("--")?e:Y(e)}: ${t};`}function X(e){return`{${e.length>0?`
4
- `:""}${e.map(t=>`${B(`${t}`)}
5
- `).join("")}}`}function P(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function ee(e,t){return M(P(e),t)}function te(e,t){return`var(${P(e)}${t?`, ${t}`:""})`}function k(e,t){return`${e} ${X(t)}`}function ne(e){return function(n,r){return Object.entries(n).map(([o,a])=>M(o,e(a,r)))}}function V(e){return function(n,r){const a=(r.variables?.name??v)({name:n.name});return ee(a,e(n.value,r))}}function C(e){const t=V(e),n=ne(e);return function(o,a,u){const{variables:s,declarations:c,children:i}=a,f=o===":root",l=(s??[]).map(g=>t(g,u)),m=n(c??{},u),y=(i??[]).map(g=>e(g,u)),d=l.length>0,A=m.length>0,N=y.length>0;return f?`${d||A?k(o,[...l,...d&&A?[""]:[],...m]):""}${N&&(d||A)?`
1
+ (function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p.transpiler={}))})(this,(function(p){"use strict";const F=["charset","import","namespace"],B=["layer"],D=({name:e})=>`[data-theme="${e}"]`,L=({name:e,value:t,modifiers:r})=>`._${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g,"\\$&")}`,$=({name:e})=>e.replace(/^\.+|\.+$/g,"").replace(/\.+/g,"--");function H(e,t){return`@${e}${t?" ":""}${t}`}const Q=/\d/,J=["-","_","/","."];function Z(e=""){if(!Q.test(e))return e!==e.toLowerCase()}function U(e,t){const r=J,o=[];if(!e||typeof e!="string")return o;let n="",i,u;for(const a of e){const c=r.includes(a);if(c===!0){o.push(n),n="",i=void 0;continue}const s=Z(a);if(u===!1){if(i===!1&&s===!0){o.push(n),n=a,i=s;continue}if(i===!0&&s===!1&&n.length>1){const f=n.at(-1);o.push(n.slice(0,Math.max(0,n.length-1))),n=f+a,i=s;continue}}n+=a,i=s,u=c}return o.push(n),o}function W(e){return e?e[0].toUpperCase()+e.slice(1):""}function G(e){return e?e[0].toLowerCase()+e.slice(1):""}function Y(e,t){return e?(Array.isArray(e)?e:U(e)).map(r=>W(r)).join(""):""}function X(e,t){return G(Y(e||""))}function ee(e,t){return e?(Array.isArray(e)?e:U(e)).map(r=>r.toLowerCase()).join("-"):""}function I(e){return` ${e}`}function P(e){return e.split(`
2
+ `).map(t=>I(t)).join(`
3
+ `)}function N(e){return e===e.toUpperCase()}function _(e){return X(e)}function x(e){return ee(e)}function te(e){return x(e)}function M(e,t){return`${e.startsWith("--")?e:te(e)}: ${t};`}function re(e){return`{${e.length>0?`
4
+ `:""}${e.map(t=>`${P(`${t}`)}
5
+ `).join("")}}`}function k(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function ne(e,t){return M(k(e),t)}function oe(e,t){return`var(${k(e)}${t?`, ${t}`:""})`}function V(e,t){return`${e} ${re(t)}`}function ce(e){return function(r,o){return Object.entries(r).map(([n,i])=>M(n,e(i,o)))}}function K(e){return function(r,o){const i=(o.variables?.name??$)({name:r.name});return ne(i,e(r.value,o))}}function C(e){const t=K(e),r=ce(e);return function(n,i,u){const{variables:a,declarations:c,children:s}=i,f=n===":root",l=(a??[]).map(S=>t(S,u)),m=r(c??{},u),y=(s??[]).map(S=>e(S,u)),d=l.length>0,g=m.length>0,w=y.length>0;return f?`${d||g?V(n,[...l,...d&&g?[""]:[],...m]):""}${w&&(d||g)?`
6
6
 
7
7
  `:""}${y.join(`
8
8
 
9
- `)}`:k(o,[...l,...d&&(N||A)?[""]:[],...m,...A&&N?[""]:[],...y.flatMap((g,Ue)=>Ue===y.length-1?[g]:[g,""])])}}function re(e){const t=C(e);return function(r,o){const a=_.includes(r.identifier),u=$.includes(r.identifier),s=Object.keys(r.declarations).length>0,c=r.variables.length>0,i=r.children.length>0,f=q(r.identifier,r.rule);return a||u&&!(s||c||i)?`${f};`:t(f,r,o)}}function oe(e){return function(n,r){return n.value.map(o=>e(o,r)).join("").trim()}}function ce(e){return typeof e=="object"&&e!==null}function b(e,t){return ce(e)&&"type"in e&&e.type===t}function ue(e){return b(e,"variable")}function ie(e){return b(e,"reference")}function R(e){return b(e,"selector")}function ae(e){return b(e,"at-rule")}function se(e){return b(e,"utility")}function le(e){return b(e,"css")}function fe(e){return b(e,"theme")}function K(e){return b(e,"root")}function me(e){return b(e,"recipe")}function pe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function S(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function de(e){if(e=e||{},e.circular)return ye(e);const t=new Map;if(t.set(Date,u=>new Date(u)),t.set(Map,(u,s)=>new Map(r(Array.from(u),s))),t.set(Set,(u,s)=>new Set(r(Array.from(u),s))),e.constructorHandlers)for(const u of e.constructorHandlers)t.set(u[0],u[1]);let n;return e.proto?a:o;function r(u,s){const c=Object.keys(u),i=Array.from({length:c.length});for(let f=0;f<c.length;f++){const l=c[f],m=u[l];typeof m!="object"||m===null?i[l]=m:m.constructor!==Object&&(n=t.get(m.constructor))?i[l]=n(m,s):ArrayBuffer.isView(m)?i[l]=S(m):i[l]=s(m)}return i}function o(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return r(u,o);if(u.constructor!==Object&&(n=t.get(u.constructor)))return n(u,o);const s={};for(const c in u){if(Object.hasOwnProperty.call(u,c)===!1)continue;const i=u[c];typeof i!="object"||i===null?s[c]=i:i.constructor!==Object&&(n=t.get(i.constructor))?s[c]=n(i,o):ArrayBuffer.isView(i)?s[c]=S(i):s[c]=o(i)}return s}function a(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return r(u,a);if(u.constructor!==Object&&(n=t.get(u.constructor)))return n(u,a);const s={};for(const c in u){const i=u[c];typeof i!="object"||i===null?s[c]=i:i.constructor!==Object&&(n=t.get(i.constructor))?s[c]=n(i,a):ArrayBuffer.isView(i)?s[c]=S(i):s[c]=a(i)}return s}}function ye(e){const t=[],n=[],r=new Map;if(r.set(Date,c=>new Date(c)),r.set(Map,(c,i)=>new Map(a(Array.from(c),i))),r.set(Set,(c,i)=>new Set(a(Array.from(c),i))),e.constructorHandlers)for(const c of e.constructorHandlers)r.set(c[0],c[1]);let o;return e.proto?s:u;function a(c,i){const f=Object.keys(c),l=Array.from({length:f.length});for(let m=0;m<f.length;m++){const y=f[m],d=c[y];if(typeof d!="object"||d===null)l[y]=d;else if(d.constructor!==Object&&(o=r.get(d.constructor)))l[y]=o(d,i);else if(ArrayBuffer.isView(d))l[y]=S(d);else{const A=t.indexOf(d);A!==-1?l[y]=n[A]:l[y]=i(d)}}return l}function u(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return a(c,u);if(c.constructor!==Object&&(o=r.get(c.constructor)))return o(c,u);const i={};t.push(c),n.push(i);for(const f in c){if(Object.hasOwnProperty.call(c,f)===!1)continue;const l=c[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=r.get(l.constructor)))i[f]=o(l,u);else if(ArrayBuffer.isView(l))i[f]=S(l);else{const m=t.indexOf(l);m!==-1?i[f]=n[m]:i[f]=u(l)}}return t.pop(),n.pop(),i}function s(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return a(c,s);if(c.constructor!==Object&&(o=r.get(c.constructor)))return o(c,s);const i={};t.push(c),n.push(i);for(const f in c){const l=c[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=r.get(l.constructor)))i[f]=o(l,s);else if(ArrayBuffer.isView(l))i[f]=S(l);else{const m=t.indexOf(l);m!==-1?i[f]=n[m]:i[f]=s(l)}}return t.pop(),n.pop(),i}}de();function he(e){return function(n,r){return n!=null?`${n}`:""}}function be(e){return function(n,r){const a=(r.variables?.name??v)({name:n.name});return te(a,n.fallback?e(n.fallback,r):void 0)}}function Ae(e){const t=C(e);return function(r,o){return r.themes.reduce((a,u)=>(a.push(e(u,o)),a),[t(":root",r,o)]).join(`
9
+ `)}`:V(n,[...l,...d&&(w||g)?[""]:[],...m,...g&&w?[""]:[],...y.flatMap((S,ke)=>ke===y.length-1?[S]:[S,""])])}}function ue(e){const t=C(e);return function(o,n){const i=F.includes(o.identifier),u=B.includes(o.identifier),a=Object.keys(o.declarations).length>0,c=o.variables.length>0,s=o.children.length>0,f=H(o.identifier,o.rule);return i||u&&!(a||c||s)?`${f};`:t(f,o,n)}}function ie(e){return function(r,o){return r.value.map(n=>e(n,o)).join("").trim()}}function se(e){return typeof e=="object"&&e!==null}function b(e,t){return se(e)&&"type"in e&&e.type===t}function ae(e){return b(e,"variable")}function le(e){return b(e,"reference")}function j(e){return b(e,"selector")}function fe(e){return b(e,"at-rule")}function me(e){return b(e,"utility")}function pe(e){return b(e,"css")}function de(e){return b(e,"theme")}function E(e){return b(e,"root")}function q(e){return b(e,"recipe")}function z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function A(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function ye(e){if(e=e||{},e.circular)return he(e);const t=new Map;if(t.set(Date,u=>new Date(u)),t.set(Map,(u,a)=>new Map(o(Array.from(u),a))),t.set(Set,(u,a)=>new Set(o(Array.from(u),a))),e.constructorHandlers)for(const u of e.constructorHandlers)t.set(u[0],u[1]);let r;return e.proto?i:n;function o(u,a){const c=Object.keys(u),s=Array.from({length:c.length});for(let f=0;f<c.length;f++){const l=c[f],m=u[l];typeof m!="object"||m===null?s[l]=m:m.constructor!==Object&&(r=t.get(m.constructor))?s[l]=r(m,a):ArrayBuffer.isView(m)?s[l]=A(m):s[l]=a(m)}return s}function n(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return o(u,n);if(u.constructor!==Object&&(r=t.get(u.constructor)))return r(u,n);const a={};for(const c in u){if(Object.hasOwnProperty.call(u,c)===!1)continue;const s=u[c];typeof s!="object"||s===null?a[c]=s:s.constructor!==Object&&(r=t.get(s.constructor))?a[c]=r(s,n):ArrayBuffer.isView(s)?a[c]=A(s):a[c]=n(s)}return a}function i(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return o(u,i);if(u.constructor!==Object&&(r=t.get(u.constructor)))return r(u,i);const a={};for(const c in u){const s=u[c];typeof s!="object"||s===null?a[c]=s:s.constructor!==Object&&(r=t.get(s.constructor))?a[c]=r(s,i):ArrayBuffer.isView(s)?a[c]=A(s):a[c]=i(s)}return a}}function he(e){const t=[],r=[],o=new Map;if(o.set(Date,c=>new Date(c)),o.set(Map,(c,s)=>new Map(i(Array.from(c),s))),o.set(Set,(c,s)=>new Set(i(Array.from(c),s))),e.constructorHandlers)for(const c of e.constructorHandlers)o.set(c[0],c[1]);let n;return e.proto?a:u;function i(c,s){const f=Object.keys(c),l=Array.from({length:f.length});for(let m=0;m<f.length;m++){const y=f[m],d=c[y];if(typeof d!="object"||d===null)l[y]=d;else if(d.constructor!==Object&&(n=o.get(d.constructor)))l[y]=n(d,s);else if(ArrayBuffer.isView(d))l[y]=A(d);else{const g=t.indexOf(d);g!==-1?l[y]=r[g]:l[y]=s(d)}}return l}function u(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return i(c,u);if(c.constructor!==Object&&(n=o.get(c.constructor)))return n(c,u);const s={};t.push(c),r.push(s);for(const f in c){if(Object.hasOwnProperty.call(c,f)===!1)continue;const l=c[f];if(typeof l!="object"||l===null)s[f]=l;else if(l.constructor!==Object&&(n=o.get(l.constructor)))s[f]=n(l,u);else if(ArrayBuffer.isView(l))s[f]=A(l);else{const m=t.indexOf(l);m!==-1?s[f]=r[m]:s[f]=u(l)}}return t.pop(),r.pop(),s}function a(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return i(c,a);if(c.constructor!==Object&&(n=o.get(c.constructor)))return n(c,a);const s={};t.push(c),r.push(s);for(const f in c){const l=c[f];if(typeof l!="object"||l===null)s[f]=l;else if(l.constructor!==Object&&(n=o.get(l.constructor)))s[f]=n(l,a);else if(ArrayBuffer.isView(l))s[f]=A(l);else{const m=t.indexOf(l);m!==-1?s[f]=r[m]:s[f]=a(l)}}return t.pop(),r.pop(),s}}ye();function be(e){return function(r,o){return r!=null?`${r}`:""}}function ge(e){return function(r,o){const i=(o.variables?.name??$)({name:r.name});return oe(i,r.fallback?e(r.fallback,o):void 0)}}function Ae(e){const t=C(e);return function(o,n){return o.themes.reduce((i,u)=>(i.push(e(u,n)),i),[t(":root",o,n)]).join(`
10
10
 
11
- `)}}function Se(e){const t=C(e);return function(r,o){return t(r.query,r,o)}}function ge(e){const t=C(e);return function(r,o){const u=(o.themes?.selector??w)({name:r.name});return t(u,r,o)}}function Ce(e){const t=C(e);return function(r,o){const a=[],s=(o.utilities?.selector??O)({name:r.name,value:r.value,modifiers:r.modifiers});return a.push(t(s,r,o)),a.join(`
11
+ `)}}function Se(e){const t=C(e);return function(o,n){return t(o.query,o,n)}}function Ce(e){const t=C(e);return function(o,n){const u=(n.themes?.selector??D)({name:o.name});return t(u,o,n)}}function je(e){const t=C(e);return function(o,n){const i=[],a=(n.utilities?.selector??L)({name:o.name,value:o.value,modifiers:o.modifiers});return i.push(t(a,o,n)),i.join(`
12
12
 
13
- `)}}function h(e,t){const n=Ae(h),r=Se(h),o=Ce(h),a=re(h),u=ge(h),s=V(h),c=be(h),i=oe(h),f=he();switch(!0){case R(e):return r(e,t);case se(e):return o(e,t);case ae(e):return a(e,t);case K(e):return n(e,t);case fe(e):return u(e,t);case ue(e):return s(e,t);case ie(e):return c(e,t);case le(e):return i(e,t);default:return f(e,t)}}function je(e){return function(n,r){let o=n._exportName;o||(o=D(n.name),n.name[0]&&U(n.name[0])&&(o=pe(o)));const a=`${o}Recipe`,u=n._runtime??{};return`const ${a} = ${JSON.stringify(u,null,4)} as const satisfies RecipeRuntime;
13
+ `)}}function h(e,t){const r=Ae(h),o=Se(h),n=je(h),i=ue(h),u=Ce(h),a=K(h),c=ge(h),s=ie(h),f=be();switch(!0){case j(e):return o(e,t);case me(e):return n(e,t);case fe(e):return i(e,t);case E(e):return r(e,t);case de(e):return u(e,t);case ae(e):return a(e,t);case le(e):return c(e,t);case pe(e):return s(e,t);default:return f(e,t)}}function ve(e){return function(r,o){let n=r._exportName;n||(n=_(r.name),r.name[0]&&N(r.name[0])&&(n=z(n)));const i=`${n}Recipe`,u=r._runtime??{};return`const ${i} = ${JSON.stringify(u,null,4)} as const satisfies RecipeRuntime;
14
14
 
15
- export const ${o} = createRecipe("${n.name}", ${a});
16
- `}}function Te(e){return e.filter(t=>R(t)&&!!t._exportName)}function ve(e){return function(n,r){const o=Te(n.children),a=n.recipes.length>0,u=o.length>0;if(!a&&!u)return"";const s=[];return a&&(s.push(`import { createRecipe } from '@styleframe/runtime';
15
+ export const ${n} = createRecipe("${r.name}", ${i});
16
+ `}}function Re(e){return e.filter(t=>j(t)&&!!t._exportName)}function Te(e){return function(r,o){const n=Re(r.children),i=r.recipes.length>0,u=n.length>0;if(!i&&!u)return"";const a=[];return i&&(a.push(`import { createRecipe } from '@styleframe/runtime';
17
17
  import type { RecipeRuntime } from '@styleframe/runtime';
18
- `),s.push(e(n.recipes,r))),u&&s.push(e(o,r)),s.join(`
19
- `)}}function Re(e){return function(n,r){return n._exportName?`export const ${n._exportName} = ${JSON.stringify(n.query)};
20
- `:""}}function T(e,t){const n=ve(T),r=je(),o=Re();switch(!0){case Array.isArray(e):return e.map(a=>T(a,t)).join(`
21
- `);case K(e):return n(e,t);case me(e):return r(e,t);case R(e):return o(e,t);default:return""}}const Ee=`-----BEGIN PUBLIC KEY-----
18
+ `),a.push(e(r.recipes,o))),u&&a.push(e(n,o)),a.join(`
19
+ `)}}function $e(e){return function(r,o){return r._exportName?`export const ${r._exportName} = ${JSON.stringify(r.query)};
20
+ `:""}}function R(e,t){const r=Te(R),o=ve(),n=$e();switch(!0){case Array.isArray(e):return e.map(i=>R(i,t)).join(`
21
+ `);case E(e):return r(e,t);case q(e):return o(e,t);case j(e):return n(e,t);default:return""}}const Ne=`-----BEGIN PUBLIC KEY-----
22
22
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
23
23
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
24
24
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -26,4 +26,6 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
26
26
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
27
27
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
28
28
  GwIDAQAB
29
- -----END PUBLIC KEY-----`,Ne="__licenseRequired",_e="__licenseValidated";async function $e(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),n=Uint8Array.from(atob(t),r=>r.charCodeAt(0));return await crypto.subtle.importKey("spki",n,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function we({payload:e,signature:t}){const n=new TextEncoder().encode(e),r=Uint8Array.from(atob(t),a=>a.charCodeAt(0)),o=await $e(Ee);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,r,n))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function Oe(e){return Object.prototype.hasOwnProperty.call(e,Ne)}async function Fe(e){const t=Object.getOwnPropertyDescriptor(e,_e);if(!t?.value)return{key:"",instanceId:"",environment:"",valid:!1};const n=t.value;if(typeof n!="object"||n===null||!("payload"in n)||!("signature"in n)||typeof n.payload!="string"||typeof n.signature!="string")return{key:"",instanceId:"",environment:"",valid:!1};try{return await we(n)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function Le(e){const t=Math.floor(Math.random()*100);e.root.children.push({type:"selector",query:`html:nth-of-type(${t}n+1)::after`,variables:[],children:[],declarations:{content:'"Styleframe Pro: Development Mode License required for production use"',zIndex:99999,position:"fixed",display:"block !important",opacity:"1 !important",bottom:0,left:0,background:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"12px",lineHeight:"1",padding:"0.5rem",fontFamily:"sans-serif"}})}function E(e,t=""){return{name:e,content:t}}async function Be(e,{type:t="all",consumers:n={css:h,ts:T}}={}){const r={files:[]},o=e.options;if(Oe(e)){const a=await Fe(e);(!a.valid||a.instanceId!==e.id)&&Le(e)}if(t==="all"||t==="css"){const a=E("index.css",n.css(e.root,o));r.files.push(a)}if(t==="all"||t==="ts"){const a=E("index.ts",n.ts(e.root,o));r.files.push(a)}return r}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=_,p.STATEMENT_OR_BLOCK_AT_RULES=$,p.addIndentToLine=L,p.consumeCSS=h,p.consumeTS=T,p.createFile=E,p.defaultThemeSelectorFn=w,p.defaultUtilitySelectorFn=O,p.defaultVariableNameFn=v,p.indentLines=B,p.isUppercase=U,p.toCamelCase=D,p.toKebabCase=I,p.transpile=Be,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
29
+ -----END PUBLIC KEY-----`,_e="__licenseRequired",Ee="__licenseValidated";async function Oe(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=Uint8Array.from(atob(t),o=>o.charCodeAt(0));return await crypto.subtle.importKey("spki",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function we({payload:e,signature:t}){const r=new TextEncoder().encode(e),o=Uint8Array.from(atob(t),i=>i.charCodeAt(0)),n=await Oe(Ne);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,o,r))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function Fe(e){return Object.prototype.hasOwnProperty.call(e,_e)}async function Be(e){const t=Object.getOwnPropertyDescriptor(e,Ee);if(!t?.value)return{key:"",instanceId:"",environment:"",valid:!1};const r=t.value;if(typeof r!="object"||r===null||!("payload"in r)||!("signature"in r)||typeof r.payload!="string"||typeof r.signature!="string")return{key:"",instanceId:"",environment:"",valid:!1};try{return await we(r)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function De(e){const t=e?.variants;if(!t||Object.keys(t).length===0)return"Record<string, never>";const r=[];for(const[o,n]of Object.entries(t)){if(!n)continue;const i=Object.keys(n);if(i.length>0){const u=i.map(a=>`"${a}"`).join(" | ");r.push(`${o}?: ${u}`)}}return r.length===0?"Record<string, never>":`{ ${r.join("; ")} }`}function Le(e){return function(r,o){let n=r._exportName;n||(n=_(r.name),r.name[0]&&N(r.name[0])&&(n=z(n)));const i=De(r._runtime);return` export const ${n}: (props?: ${i}) => string;`}}function Ue(e){return e.filter(t=>j(t)&&!!t._exportName)}function Ie(e){return function(r,o){const n=Ue(r.children),i=r.recipes.length>0,u=n.length>0,a=["// Auto-generated by @styleframe/plugin - DO NOT EDIT","",'declare module "virtual:styleframe" {',' import type { Styleframe } from "@styleframe/core";',""," /** Returns the global styleframe instance from styleframe.config.ts */"," export function styleframe(): Styleframe;"];if(i){a.push("");const c=r.recipes.map(s=>e(s,o)).filter(Boolean);a.push(...c)}if(u){a.push("");const c=n.map(s=>e(s,o)).filter(Boolean);a.push(...c)}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(`
30
+ `)}}function Pe(e){return function(r,o){return r._exportName?` export const ${r._exportName}: string;`:""}}function O(e,t){const r=Ie(O),o=Le(),n=Pe();switch(!0){case Array.isArray(e):return e.map(i=>O(i,t)).join(`
31
+ `);case E(e):return r(e,t);case q(e):return o(e,t);case j(e):return n(e,t);default:return""}}function xe(e){const t=Math.floor(Math.random()*100);e.root.children.push({type:"selector",query:`html:nth-of-type(${t}n+1)::after`,variables:[],children:[],declarations:{content:'"Styleframe Pro: Development Mode – License required for production use"',zIndex:99999,position:"fixed",display:"block !important",opacity:"1 !important",bottom:0,left:0,background:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"12px",lineHeight:"1",padding:"0.5rem",fontFamily:"sans-serif"}})}function T(e,t=""){return{name:e,content:t}}async function Me(e,{type:t="all",consumers:r={css:h,ts:R,dts:O}}={}){const o={files:[]},n=e.options;if(Fe(e)){const i=await Be(e);(!i.valid||i.instanceId!==e.id)&&xe(e)}if(t==="all"||t==="css"){const i=T("index.css",r.css(e.root,n));o.files.push(i)}if(t==="all"||t==="ts"){const i=T("index.ts",r.ts(e.root,n));o.files.push(i)}if(t==="dts"){const i=T("index.d.ts",r.dts(e.root,n));o.files.push(i)}return o}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=F,p.STATEMENT_OR_BLOCK_AT_RULES=B,p.addIndentToLine=I,p.consumeCSS=h,p.consumeTS=R,p.createFile=T,p.defaultThemeSelectorFn=D,p.defaultUtilitySelectorFn=L,p.defaultVariableNameFn=$,p.indentLines=P,p.isUppercase=N,p.toCamelCase=_,p.toKebabCase=x,p.transpile=Me,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@styleframe/transpiler",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "types": "./dist/transpiler.d.ts",
6
6
  "module": "./dist/transpiler.js",
@@ -22,14 +22,14 @@
22
22
  "scule": "^1.3.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@styleframe/core": "^2.6.0",
26
- "@styleframe/license": "^2.0.0"
25
+ "@styleframe/core": "^3.0.0",
26
+ "@styleframe/license": "^2.0.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@styleframe/config-typescript": "^2",
30
- "@styleframe/config-vite": "^2",
31
- "@styleframe/core": "^2.6.0",
32
- "@styleframe/license": "^2.0.0",
29
+ "@styleframe/config-typescript": "^3.0.0",
30
+ "@styleframe/config-vite": "^3.0.0",
31
+ "@styleframe/core": "^3.0.0",
32
+ "@styleframe/license": "^2.0.2",
33
33
  "@vitest/coverage-v8": "^3.2.4",
34
34
  "typescript": "^5.8.3",
35
35
  "vite": "^7.0.6",