@styleframe/transpiler 2.5.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,35 @@
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
+
14
+ ## 2.6.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#96](https://github.com/styleframe-dev/styleframe/pull/96) [`8460f16`](https://github.com/styleframe-dev/styleframe/commit/8460f169cec1199810e9203b357dac9f2f128c56) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Rename `?recipe` imports to `?ts` and add named selector export support
19
+ - **Breaking:** Renamed import query parameter from `?recipe` to `?ts` for styleframe files
20
+ - Add support for exporting named selectors alongside recipes via `?ts` imports
21
+ - Add `_exportName` property to `Selector` and `Recipe` types for tracking named exports
22
+ - Replace `c12` with `chokidar` + `jiti` for simpler, more reliable config loading
23
+ - Add `onError` callback to `watchConfiguration` for error reporting during file watch
24
+ - Add file deletion detection with `unlink` handler in watch mode
25
+ - Simplify `loadConfiguration` API by merging `loadConfigurationFromPath`
26
+ - Add comprehensive unit tests for TypeScript selector consumer
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`8460f16`](https://github.com/styleframe-dev/styleframe/commit/8460f169cec1199810e9203b357dac9f2f128c56)]:
31
+ - @styleframe/core@2.6.0
32
+
3
33
  ## 2.5.0
4
34
 
5
35
  ### 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 = " ", N = ["charset", "import", "namespace"], L = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, I = ({
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 U(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 _ = /\d/, P = ["-", "_", "/", "."];
10
- function M(e = "") {
11
- if (!_.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 $(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, i;
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 u = M(a);
26
- if (i === !1) {
27
- if (s === !1 && u === !0) {
28
- n.push(o), o = a, s = u;
25
+ const i = z(a);
26
+ if (u === !1) {
27
+ if (s === !1 && i === !0) {
28
+ o.push(n), n = a, s = i;
29
29
  continue;
30
30
  }
31
- if (s === !0 && u === !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 = u;
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 = u, i = 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 x(e) {
44
+ function Q(e) {
45
45
  return e ? e[0].toLowerCase() + e.slice(1) : "";
46
46
  }
47
- function V(e, t) {
48
- return e ? (Array.isArray(e) ? e : $(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 x(V(e || ""));
50
+ function Z(e, t) {
51
+ return Q(J(e || ""));
52
52
  }
53
- function q(e, t) {
54
- return e ? (Array.isArray(e) ? e : $(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 z(e) {
56
+ function G(e) {
57
57
  return ` ${e}`;
58
58
  }
59
- function H(e) {
59
+ function Y(e) {
60
60
  return e.split(`
61
- `).map((t) => z(t)).join(`
61
+ `).map((t) => G(t)).join(`
62
62
  `);
63
63
  }
64
- function Q(e) {
64
+ function x(e) {
65
65
  return e === e.toUpperCase();
66
66
  }
67
- function Z(e) {
68
- return K(e);
67
+ function T(e) {
68
+ return Z(e);
69
69
  }
70
- function J(e) {
71
- return q(e);
70
+ function X(e) {
71
+ return W(e);
72
72
  }
73
- function W(e) {
74
- return J(e);
73
+ function ee(e) {
74
+ return X(e);
75
75
  }
76
- function O(e, t) {
77
- return `${e.startsWith("--") ? e : W(e)}: ${t};`;
76
+ function B(e, t) {
77
+ return `${e.startsWith("--") ? e : ee(e)}: ${t};`;
78
78
  }
79
- function G(e) {
79
+ function te(e) {
80
80
  return `{${e.length > 0 ? `
81
- ` : ""}${e.map((t) => `${H(`${t}`)}
81
+ ` : ""}${e.map((t) => `${Y(`${t}`)}
82
82
  `).join("")}}`;
83
83
  }
84
- function B(e) {
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 Y(e, t) {
88
- return O(B(e), t);
87
+ function re(e, t) {
88
+ return B(E(e), t);
89
89
  }
90
- function X(e, t) {
91
- return `var(${B(e)}${t ? `, ${t}` : ""})`;
90
+ function ne(e, t) {
91
+ return `var(${E(e)}${t ? `, ${t}` : ""})`;
92
92
  }
93
- function v(e, t) {
94
- return `${e} ${G(t)}`;
93
+ function w(e, t) {
94
+ return `${e} ${te(t)}`;
95
95
  }
96
- function ee(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 E(e) {
102
- return function(r, n) {
103
- const s = (n.variables?.name ?? w)({ name: r.name });
104
- return Y(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
- function C(e) {
108
- const t = E(e), r = ee(e);
109
- return function(o, s, i) {
110
- const { variables: a, declarations: c, children: u } = s, f = o === ":root", l = (a ?? []).map(
111
- (A) => t(A, i)
107
+ function S(e) {
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
- i
115
- ), y = (u ?? []).map(
116
- (A) => e(A, i)
117
- ), p = l.length > 0, b = m.length > 0, S = y.length > 0;
118
- return f ? `${p || b ? v(o, [
114
+ u
115
+ ), y = (i ?? []).map(
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
- ]) : ""}${S && (p || b) ? `
122
+ ]) : ""}${j && (p || b) ? `
123
123
 
124
124
  ` : ""}${y.join(`
125
125
 
126
- `)}` : v(o, [
126
+ `)}` : w(n, [
127
127
  ...l,
128
- ...p && (S || b) ? [""] : [],
128
+ ...p && (j || b) ? [""] : [],
129
129
  ...m,
130
- ...b && S ? [""] : [],
130
+ ...b && j ? [""] : [],
131
131
  ...y.flatMap(
132
- (A, F) => F === y.length - 1 ? [A] : [A, ""]
132
+ (g, I) => I === y.length - 1 ? [g] : [g, ""]
133
133
  )
134
134
  ]);
135
135
  };
136
136
  }
137
- function te(e) {
138
- const t = C(e);
139
- return function(n, o) {
140
- const s = N.includes(n.identifier), i = L.includes(
141
- n.identifier
142
- ), a = Object.keys(n.declarations).length > 0, c = n.variables.length > 0, u = n.children.length > 0, f = U(n.identifier, n.rule);
143
- return s || i && !(a || c || u) ? `${f};` : t(f, n, o);
137
+ function ce(e) {
138
+ const t = S(e);
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 re(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 ne(e) {
151
+ function se(e) {
152
152
  return typeof e == "object" && e !== null;
153
153
  }
154
154
  function h(e, t) {
155
- return ne(e) && "type" in e && e.type === t;
155
+ return se(e) && "type" in e && e.type === t;
156
156
  }
157
- function oe(e) {
157
+ function ie(e) {
158
158
  return h(e, "variable");
159
159
  }
160
- function ce(e) {
160
+ function ae(e) {
161
161
  return h(e, "reference");
162
162
  }
163
- function ue(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,152 +194,152 @@ 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
- if (t.set(Date, (i) => new Date(i)), t.set(
201
+ if (t.set(Date, (u) => new Date(u)), t.set(
202
202
  Map,
203
- (i, a) => new Map(n(Array.from(i), a))
203
+ (u, a) => new Map(o(Array.from(u), a))
204
204
  ), t.set(
205
205
  Set,
206
- (i, a) => new Set(n(Array.from(i), a))
206
+ (u, a) => new Set(o(Array.from(u), a))
207
207
  ), e.constructorHandlers)
208
- for (const i of e.constructorHandlers)
209
- t.set(i[0], i[1]);
208
+ for (const u of e.constructorHandlers)
209
+ t.set(u[0], u[1]);
210
210
  let r;
211
- return e.proto ? s : o;
212
- function n(i, a) {
213
- const c = Object.keys(i), u = Array.from({ length: c.length });
211
+ return e.proto ? s : n;
212
+ function o(u, a) {
213
+ const c = Object.keys(u), i = Array.from({ length: c.length });
214
214
  for (let f = 0; f < c.length; f++) {
215
- const l = c[f], m = i[l];
216
- typeof m != "object" || m === null ? u[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? u[l] = r(m, a) : ArrayBuffer.isView(m) ? u[l] = g(m) : u[l] = a(m);
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] = A(m) : i[l] = a(m);
217
217
  }
218
- return u;
218
+ return i;
219
219
  }
220
- function o(i) {
221
- if (typeof i != "object" || i === null) return i;
222
- if (Array.isArray(i)) return n(i, o);
223
- if (i.constructor !== Object && (r = t.get(i.constructor)))
224
- return r(i, o);
220
+ function n(u) {
221
+ if (typeof u != "object" || u === null) return u;
222
+ if (Array.isArray(u)) return o(u, n);
223
+ if (u.constructor !== Object && (r = t.get(u.constructor)))
224
+ return r(u, n);
225
225
  const a = {};
226
- for (const c in i) {
227
- if (Object.hasOwnProperty.call(i, c) === !1) continue;
228
- const u = i[c];
229
- typeof u != "object" || u === null ? a[c] = u : u.constructor !== Object && (r = t.get(u.constructor)) ? a[c] = r(u, o) : ArrayBuffer.isView(u) ? a[c] = g(u) : a[c] = o(u);
226
+ for (const c in u) {
227
+ if (Object.hasOwnProperty.call(u, c) === !1) continue;
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, n) : ArrayBuffer.isView(i) ? a[c] = A(i) : a[c] = n(i);
230
230
  }
231
231
  return a;
232
232
  }
233
- function s(i) {
234
- if (typeof i != "object" || i === null) return i;
235
- if (Array.isArray(i)) return n(i, s);
236
- if (i.constructor !== Object && (r = t.get(i.constructor)))
237
- return r(i, s);
233
+ function s(u) {
234
+ if (typeof u != "object" || u === null) return u;
235
+ if (Array.isArray(u)) return o(u, s);
236
+ if (u.constructor !== Object && (r = t.get(u.constructor)))
237
+ return r(u, s);
238
238
  const a = {};
239
- for (const c in i) {
240
- const u = i[c];
241
- typeof u != "object" || u === null ? a[c] = u : u.constructor !== Object && (r = t.get(u.constructor)) ? a[c] = r(u, s) : ArrayBuffer.isView(u) ? a[c] = g(u) : a[c] = s(u);
239
+ for (const c in u) {
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] = 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
- (c, u) => new Map(s(Array.from(c), u))
251
- ), n.set(
250
+ (c, i) => new Map(s(Array.from(c), i))
251
+ ), o.set(
252
252
  Set,
253
- (c, u) => new Set(s(Array.from(c), u))
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;
258
- return e.proto ? a : i;
259
- function s(c, u) {
256
+ o.set(c[0], c[1]);
257
+ let n;
258
+ return e.proto ? a : u;
259
+ function s(c, i) {
260
260
  const f = Object.keys(c), l = Array.from({ length: f.length });
261
261
  for (let m = 0; m < f.length; m++) {
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, u);
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
- b !== -1 ? l[y] = r[b] : l[y] = u(p);
271
+ b !== -1 ? l[y] = r[b] : l[y] = i(p);
272
272
  }
273
273
  }
274
274
  return l;
275
275
  }
276
- function i(c) {
276
+ function u(c) {
277
277
  if (typeof c != "object" || c === null) return c;
278
- if (Array.isArray(c)) return s(c, i);
279
- if (c.constructor !== Object && (o = n.get(c.constructor)))
280
- return o(c, i);
281
- const u = {};
282
- t.push(c), r.push(u);
278
+ if (Array.isArray(c)) return s(c, u);
279
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
280
+ return n(c, u);
281
+ const i = {};
282
+ t.push(c), r.push(i);
283
283
  for (const f in c) {
284
284
  if (Object.hasOwnProperty.call(c, f) === !1) continue;
285
285
  const l = c[f];
286
286
  if (typeof l != "object" || l === null)
287
- u[f] = l;
288
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
289
- u[f] = o(l, i);
287
+ i[f] = l;
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
- u[f] = g(l);
291
+ i[f] = A(l);
292
292
  else {
293
293
  const m = t.indexOf(l);
294
- m !== -1 ? u[f] = r[m] : u[f] = i(l);
294
+ m !== -1 ? i[f] = r[m] : i[f] = u(l);
295
295
  }
296
296
  }
297
- return t.pop(), r.pop(), u;
297
+ return t.pop(), r.pop(), i;
298
298
  }
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);
304
- const u = {};
305
- t.push(c), r.push(u);
302
+ if (c.constructor !== Object && (n = o.get(c.constructor)))
303
+ return n(c, a);
304
+ const i = {};
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
- u[f] = l;
310
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
311
- u[f] = o(l, a);
309
+ i[f] = l;
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
- u[f] = g(l);
313
+ i[f] = A(l);
314
314
  else {
315
315
  const m = t.indexOf(l);
316
- m !== -1 ? u[f] = r[m] : u[f] = a(l);
316
+ m !== -1 ? i[f] = r[m] : i[f] = a(l);
317
317
  }
318
318
  }
319
- return t.pop(), r.pop(), u;
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 X(
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) {
338
- const t = C(e);
339
- return function(n, o) {
340
- return n.themes.reduce(
341
- (s, i) => (s.push(e(i, o)), s),
342
- [t(":root", n, o)]
337
+ function ge(e) {
338
+ const t = S(e);
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
 
@@ -347,92 +347,109 @@ function be(e) {
347
347
  };
348
348
  }
349
349
  function Ae(e) {
350
- const t = C(e);
351
- return function(n, o) {
352
- return t(n.query, n, o);
350
+ const t = S(e);
351
+ return function(o, n) {
352
+ return t(o.query, o, n);
353
353
  };
354
354
  }
355
- function ge(e) {
356
- const t = C(e);
357
- return function(n, o) {
358
- const i = (o.themes?.selector ?? D)({ name: n.name });
359
- return t(i, n, o);
355
+ function Se(e) {
356
+ const t = S(e);
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
362
  function Ce(e) {
363
- const t = C(e);
364
- return function(n, o) {
365
- const s = [], a = (o.utilities?.selector ?? I)({
366
- name: n.name,
367
- value: n.value,
368
- modifiers: n.modifiers
363
+ const t = S(e);
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 = Ce(d), s = te(d), i = ge(d), a = E(d), c = he(d), u = re(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 ue(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):
387
- return i(e, t);
388
- case oe(e):
386
+ case pe(e):
387
+ return u(e, t);
388
+ case ie(e):
389
389
  return a(e, t);
390
- case ce(e):
391
- return c(e, t);
392
390
  case ae(e):
393
- return u(e, t);
391
+ return c(e, t);
392
+ case me(e):
393
+ return i(e, t);
394
394
  default:
395
395
  return f(e, t);
396
396
  }
397
397
  }
398
- function Se(e) {
399
- return function(r, n) {
400
- let o = Z(r.name);
401
- r.name[0] && Q(r.name[0]) && (o = me(o));
402
- const s = `${o}Recipe`, i = 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
- i,
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) {
414
- return function(r, n) {
415
- return r.recipes.length > 0 ? `import { createRecipe } from '@styleframe/runtime';
413
+ function ve(e) {
414
+ return e.filter(
415
+ (t) => C(t) && !!t._exportName
416
+ );
417
+ }
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
+ if (!s && !u)
422
+ return "";
423
+ const a = [];
424
+ return s && (a.push(`import { createRecipe } from '@styleframe/runtime';
416
425
  import type { RecipeRuntime } from '@styleframe/runtime';
417
-
418
- ${e(r.recipes, n)}` : "";
426
+ `), a.push(e(r.recipes, o))), u && a.push(e(n, o)), a.join(`
427
+ `);
428
+ };
429
+ }
430
+ function $e(e) {
431
+ return function(r, o) {
432
+ return r._exportName ? `export const ${r._exportName} = ${JSON.stringify(r.query)};
433
+ ` : "";
419
434
  };
420
435
  }
421
- function j(e, t) {
422
- const r = je(j), n = Se();
436
+ function R(e, t) {
437
+ const r = Re(R), o = je(), n = $e();
423
438
  switch (!0) {
424
439
  case Array.isArray(e):
425
- return e.map((o) => j(o, t)).join(`
440
+ return e.map((s) => R(s, t)).join(`
426
441
  `);
427
- case T(e):
442
+ case N(e):
428
443
  return r(e, t);
429
- case fe(e):
444
+ case D(e):
445
+ return o(e, t);
446
+ case C(e):
430
447
  return n(e, t);
431
448
  default:
432
449
  return "";
433
450
  }
434
451
  }
435
- const ve = `-----BEGIN PUBLIC KEY-----
452
+ const Ne = `-----BEGIN PUBLIC KEY-----
436
453
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
437
454
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
438
455
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -440,9 +457,9 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
440
457
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
441
458
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
442
459
  GwIDAQAB
443
- -----END PUBLIC KEY-----`, Re = "__licenseRequired", we = "__licenseValidated";
444
- async function $e(e) {
445
- 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));
446
463
  return await crypto.subtle.importKey(
447
464
  "spki",
448
465
  r,
@@ -454,18 +471,18 @@ async function $e(e) {
454
471
  ["verify"]
455
472
  );
456
473
  }
457
- async function Oe({
474
+ async function xe({
458
475
  payload: e,
459
476
  signature: t
460
477
  }) {
461
- const r = new TextEncoder().encode(e), n = Uint8Array.from(
478
+ const r = new TextEncoder().encode(e), o = Uint8Array.from(
462
479
  atob(t),
463
480
  (s) => s.charCodeAt(0)
464
- ), o = await $e(ve);
481
+ ), n = await _e(Ne);
465
482
  if (!await crypto.subtle.verify(
466
483
  { name: "RSASSA-PKCS1-v1_5" },
467
- o,
468
484
  n,
485
+ o,
469
486
  r
470
487
  ))
471
488
  throw new Error(
@@ -473,13 +490,13 @@ async function Oe({
473
490
  );
474
491
  return JSON.parse(e);
475
492
  }
476
- function Be(e) {
477
- return Object.prototype.hasOwnProperty.call(e, Re);
493
+ function Te(e) {
494
+ return Object.prototype.hasOwnProperty.call(e, we);
478
495
  }
479
- async function Ee(e) {
496
+ async function Be(e) {
480
497
  const t = Object.getOwnPropertyDescriptor(
481
498
  e,
482
- we
499
+ Oe
483
500
  );
484
501
  if (!t?.value)
485
502
  return {
@@ -497,7 +514,7 @@ async function Ee(e) {
497
514
  valid: !1
498
515
  };
499
516
  try {
500
- return await Oe(
517
+ return await xe(
501
518
  r
502
519
  );
503
520
  } catch {
@@ -509,7 +526,81 @@ async function Ee(e) {
509
526
  };
510
527
  }
511
528
  }
512
- function Te(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) {
513
604
  const t = Math.floor(Math.random() * 100);
514
605
  e.root.children.push({
515
606
  type: "selector",
@@ -533,51 +624,58 @@ function Te(e) {
533
624
  }
534
625
  });
535
626
  }
536
- function R(e, t = "") {
627
+ function v(e, t = "") {
537
628
  return {
538
629
  name: e,
539
630
  content: t
540
631
  };
541
632
  }
542
- async function Ne(e, {
633
+ async function ke(e, {
543
634
  type: t = "all",
544
- consumers: r = { css: d, ts: j }
635
+ consumers: r = { css: d, ts: R, dts: $ }
545
636
  } = {}) {
546
- const n = { files: [] }, o = e.options;
547
- if (Be(e)) {
548
- const s = await Ee(e);
549
- (!s.valid || s.instanceId !== e.id) && Te(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);
550
641
  }
551
642
  if (t === "all" || t === "css") {
552
- const s = R(
643
+ const s = v(
553
644
  "index.css",
554
- r.css(e.root, o)
645
+ r.css(e.root, n)
555
646
  );
556
- n.files.push(s);
647
+ o.files.push(s);
557
648
  }
558
649
  if (t === "all" || t === "ts") {
559
- const s = R(
650
+ const s = v(
560
651
  "index.ts",
561
- 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)
562
660
  );
563
- n.files.push(s);
661
+ o.files.push(s);
564
662
  }
565
- return n;
663
+ return o;
566
664
  }
567
665
  export {
568
- Fe as DEFAULT_INDENT,
569
- N as STATEMENT_AT_RULES,
570
- L as STATEMENT_OR_BLOCK_AT_RULES,
571
- z 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,
572
670
  d as consumeCSS,
573
- j as consumeTS,
574
- R as createFile,
575
- D as defaultThemeSelectorFn,
576
- I as defaultUtilitySelectorFn,
577
- w as defaultVariableNameFn,
578
- H as indentLines,
579
- Q as isUppercase,
580
- Z as toCamelCase,
581
- J as toKebabCase,
582
- Ne 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
583
681
  };
@@ -1,23 +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 w=["charset","import","namespace"],N=["layer"],O=({name:e})=>`[data-theme="${e}"]`,$=({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 K(e,t){return`@${e}${t?" ":""}${t}`}const q=/\d/,z=["-","_","/","."];function H(e=""){if(!q.test(e))return e!==e.toLowerCase()}function F(e,t){const n=z,r=[];if(!e||typeof e!="string")return r;let o="",a,i;for(const s of e){const c=n.includes(s);if(c===!0){r.push(o),o="",a=void 0;continue}const u=H(s);if(i===!1){if(a===!1&&u===!0){r.push(o),o=s,a=u;continue}if(a===!0&&u===!1&&o.length>1){const f=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=f+s,a=u;continue}}o+=s,a=u,i=c}return r.push(o),r}function Q(e){return e?e[0].toUpperCase()+e.slice(1):""}function Z(e){return e?e[0].toLowerCase()+e.slice(1):""}function x(e,t){return e?(Array.isArray(e)?e:F(e)).map(n=>Q(n)).join(""):""}function J(e,t){return Z(x(e||""))}function W(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 _(e){return e===e.toUpperCase()}function U(e){return J(e)}function D(e){return W(e)}function G(e){return D(e)}function I(e,t){return`${e.startsWith("--")?e:G(e)}: ${t};`}function Y(e){return`{${e.length>0?`
4
- `:""}${e.map(t=>`${B(`${t}`)}
5
- `).join("")}}`}function M(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function X(e,t){return I(M(e),t)}function ee(e,t){return`var(${M(e)}${t?`, ${t}`:""})`}function P(e,t){return`${e} ${Y(t)}`}function te(e){return function(n,r){return Object.entries(n).map(([o,a])=>I(o,e(a,r)))}}function k(e){return function(n,r){const a=(r.variables?.name??v)({name:n.name});return X(a,e(n.value,r))}}function C(e){const t=k(e),n=te(e);return function(o,a,i){const{variables:s,declarations:c,children:u}=a,f=o===":root",l=(s??[]).map(S=>t(S,i)),m=n(c??{},i),y=(u??[]).map(S=>e(S,i)),d=l.length>0,A=m.length>0,E=y.length>0;return f?`${d||A?P(o,[...l,...d&&A?[""]:[],...m]):""}${E&&(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
- `)}`:P(o,[...l,...d&&(E||A)?[""]:[],...m,...A&&E?[""]:[],...y.flatMap((S,Be)=>Be===y.length-1?[S]:[S,""])])}}function ne(e){const t=C(e);return function(r,o){const a=w.includes(r.identifier),i=N.includes(r.identifier),s=Object.keys(r.declarations).length>0,c=r.variables.length>0,u=r.children.length>0,f=K(r.identifier,r.rule);return a||i&&!(s||c||u)?`${f};`:t(f,r,o)}}function re(e){return function(n,r){return n.value.map(o=>e(o,r)).join("").trim()}}function oe(e){return typeof e=="object"&&e!==null}function h(e,t){return oe(e)&&"type"in e&&e.type===t}function ce(e){return h(e,"variable")}function ue(e){return h(e,"reference")}function ie(e){return h(e,"selector")}function ae(e){return h(e,"at-rule")}function se(e){return h(e,"utility")}function le(e){return h(e,"css")}function fe(e){return h(e,"theme")}function V(e){return h(e,"root")}function me(e){return h(e,"recipe")}function pe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function g(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,i=>new Date(i)),t.set(Map,(i,s)=>new Map(r(Array.from(i),s))),t.set(Set,(i,s)=>new Set(r(Array.from(i),s))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let n;return e.proto?a:o;function r(i,s){const c=Object.keys(i),u=Array.from({length:c.length});for(let f=0;f<c.length;f++){const l=c[f],m=i[l];typeof m!="object"||m===null?u[l]=m:m.constructor!==Object&&(n=t.get(m.constructor))?u[l]=n(m,s):ArrayBuffer.isView(m)?u[l]=g(m):u[l]=s(m)}return u}function o(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return r(i,o);if(i.constructor!==Object&&(n=t.get(i.constructor)))return n(i,o);const s={};for(const c in i){if(Object.hasOwnProperty.call(i,c)===!1)continue;const u=i[c];typeof u!="object"||u===null?s[c]=u:u.constructor!==Object&&(n=t.get(u.constructor))?s[c]=n(u,o):ArrayBuffer.isView(u)?s[c]=g(u):s[c]=o(u)}return s}function a(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return r(i,a);if(i.constructor!==Object&&(n=t.get(i.constructor)))return n(i,a);const s={};for(const c in i){const u=i[c];typeof u!="object"||u===null?s[c]=u:u.constructor!==Object&&(n=t.get(u.constructor))?s[c]=n(u,a):ArrayBuffer.isView(u)?s[c]=g(u):s[c]=a(u)}return s}}function ye(e){const t=[],n=[],r=new Map;if(r.set(Date,c=>new Date(c)),r.set(Map,(c,u)=>new Map(a(Array.from(c),u))),r.set(Set,(c,u)=>new Set(a(Array.from(c),u))),e.constructorHandlers)for(const c of e.constructorHandlers)r.set(c[0],c[1]);let o;return e.proto?s:i;function a(c,u){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,u);else if(ArrayBuffer.isView(d))l[y]=g(d);else{const A=t.indexOf(d);A!==-1?l[y]=n[A]:l[y]=u(d)}}return l}function i(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return a(c,i);if(c.constructor!==Object&&(o=r.get(c.constructor)))return o(c,i);const u={};t.push(c),n.push(u);for(const f in c){if(Object.hasOwnProperty.call(c,f)===!1)continue;const l=c[f];if(typeof l!="object"||l===null)u[f]=l;else if(l.constructor!==Object&&(o=r.get(l.constructor)))u[f]=o(l,i);else if(ArrayBuffer.isView(l))u[f]=g(l);else{const m=t.indexOf(l);m!==-1?u[f]=n[m]:u[f]=i(l)}}return t.pop(),n.pop(),u}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 u={};t.push(c),n.push(u);for(const f in c){const l=c[f];if(typeof l!="object"||l===null)u[f]=l;else if(l.constructor!==Object&&(o=r.get(l.constructor)))u[f]=o(l,s);else if(ArrayBuffer.isView(l))u[f]=g(l);else{const m=t.indexOf(l);m!==-1?u[f]=n[m]:u[f]=s(l)}}return t.pop(),n.pop(),u}}de();function be(e){return function(n,r){return n!=null?`${n}`:""}}function he(e){return function(n,r){const a=(r.variables?.name??v)({name:n.name});return ee(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,i)=>(a.push(e(i,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 ge(e){const t=C(e);return function(r,o){return t(r.query,r,o)}}function Se(e){const t=C(e);return function(r,o){const i=(o.themes?.selector??O)({name:r.name});return t(i,r,o)}}function Ce(e){const t=C(e);return function(r,o){const a=[],s=(o.utilities?.selector??$)({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 b(e,t){const n=Ae(b),r=ge(b),o=Ce(b),a=ne(b),i=Se(b),s=k(b),c=he(b),u=re(b),f=be();switch(!0){case ie(e):return r(e,t);case se(e):return o(e,t);case ae(e):return a(e,t);case V(e):return n(e,t);case fe(e):return i(e,t);case ce(e):return s(e,t);case ue(e):return c(e,t);case le(e):return u(e,t);default:return f(e,t)}}function je(e){return function(n,r){let o=U(n.name);n.name[0]&&_(n.name[0])&&(o=pe(o));const a=`${o}Recipe`,i=n._runtime??{};return`const ${a} = ${JSON.stringify(i,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 function(n,r){return n.recipes.length>0?`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
-
19
- ${e(n.recipes,r)}`:""}}function T(e,t){const n=Te(T),r=je();switch(!0){case Array.isArray(e):return e.map(o=>T(o,t)).join(`
20
- `);case V(e):return n(e,t);case me(e):return r(e,t);default:return""}}const ve=`-----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-----
21
22
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
22
23
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
23
24
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -25,4 +26,6 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
25
26
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
26
27
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
27
28
  GwIDAQAB
28
- -----END PUBLIC KEY-----`,Re="__licenseRequired",Ee="__licenseValidated";async function we(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 Ne({payload:e,signature:t}){const n=new TextEncoder().encode(e),r=Uint8Array.from(atob(t),a=>a.charCodeAt(0)),o=await we(ve);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,Re)}async function $e(e){const t=Object.getOwnPropertyDescriptor(e,Ee);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 Ne(n)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function Fe(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 R(e,t=""){return{name:e,content:t}}async function Le(e,{type:t="all",consumers:n={css:b,ts:T}}={}){const r={files:[]},o=e.options;if(Oe(e)){const a=await $e(e);(!a.valid||a.instanceId!==e.id)&&Fe(e)}if(t==="all"||t==="css"){const a=R("index.css",n.css(e.root,o));r.files.push(a)}if(t==="all"||t==="ts"){const a=R("index.ts",n.ts(e.root,o));r.files.push(a)}return r}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=w,p.STATEMENT_OR_BLOCK_AT_RULES=N,p.addIndentToLine=L,p.consumeCSS=b,p.consumeTS=T,p.createFile=R,p.defaultThemeSelectorFn=O,p.defaultUtilitySelectorFn=$,p.defaultVariableNameFn=v,p.indentLines=B,p.isUppercase=_,p.toCamelCase=U,p.toKebabCase=D,p.transpile=Le,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.5.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.5.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.5.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",