@styleframe/transpiler 2.2.0 → 2.4.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,29 @@
1
1
  # @styleframe/transpiler
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#63](https://github.com/styleframe-dev/styleframe/pull/63) [`ec430e1`](https://github.com/styleframe-dev/styleframe/commit/ec430e11502b3dba69c20ee10b24f0302008883c) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: add styleframe runtime for recipes
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`ec430e1`](https://github.com/styleframe-dev/styleframe/commit/ec430e11502b3dba69c20ee10b24f0302008883c)]:
12
+ - @styleframe/core@2.4.0
13
+
14
+ ## 2.3.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#68](https://github.com/styleframe-dev/styleframe/pull/68) [`653d1fc`](https://github.com/styleframe-dev/styleframe/commit/653d1fc4e8fb80f8c3371e728ffc962cf1fb1cec) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: add support for dot notation in variable names
19
+
20
+ ### Patch Changes
21
+
22
+ - [#65](https://github.com/styleframe-dev/styleframe/pull/65) [`7d32059`](https://github.com/styleframe-dev/styleframe/commit/7d320590a311ace8882a5a29db3a911c24b53710) Thanks [@alexgrozav](https://github.com/alexgrozav)! - fix: do not generate default keyword for utilities
23
+
24
+ - Updated dependencies [[`653d1fc`](https://github.com/styleframe-dev/styleframe/commit/653d1fc4e8fb80f8c3371e728ffc962cf1fb1cec)]:
25
+ - @styleframe/core@2.3.0
26
+
3
27
  ## 2.2.0
4
28
 
5
29
  ### Minor Changes
@@ -1,18 +1,9 @@
1
- import { AtRule } from '@styleframe/core';
2
- import { ContainerChild } from '@styleframe/core';
3
- import { CSS as CSS_2 } from '@styleframe/core';
4
- import { DeclarationsBlock } from '@styleframe/core';
1
+ import { CamelCase } from 'scule';
5
2
  import { KebabCase } from 'scule';
6
- import { Reference } from '@styleframe/core';
7
- import { Root } from '@styleframe/core';
8
- import { Selector } from '@styleframe/core';
9
3
  import { Styleframe } from '@styleframe/core';
10
4
  import { StyleframeOptions } from '@styleframe/core';
11
- import { Theme } from '@styleframe/core';
12
5
  import { ThemeSelectorFn } from '@styleframe/core';
13
- import { Utility } from '@styleframe/core';
14
6
  import { UtilitySelectorFn } from '@styleframe/core';
15
- import { Variable } from '@styleframe/core';
16
7
  import { VariableNameFn } from '@styleframe/core';
17
8
 
18
9
  export declare function addIndentToLine(line: string): string;
@@ -29,59 +20,8 @@ export declare type ConsumeFunction = (instance: unknown, options: StyleframeOpt
29
20
  */
30
21
  export declare function consumeTS(instance: unknown, options: StyleframeOptions): string;
31
22
 
32
- /**
33
- * Consumes a generic at-rule instance, equivalent to setting a CSS at-rule
34
- * such as @media, @supports, @keyframes, etc.
35
- */
36
- export declare function createAtRuleConsumer(consume: ConsumeFunction): (instance: AtRule, options: StyleframeOptions) => string;
37
-
38
- /**
39
- * Base function for consuming container-like structures (Selector, AtRule)
40
- */
41
- export declare function createContainerConsumer(consume: ConsumeFunction): (query: string, instance: {
42
- variables?: Variable[];
43
- declarations?: DeclarationsBlock;
44
- children?: ContainerChild[];
45
- }, options: StyleframeOptions) => string;
46
-
47
- /**
48
- * Consumes a CSS value, equivalent to the string body of a selector
49
- */
50
- export declare function createCSSTemplateLiteralConsumer(consume: ConsumeFunction): (instance: CSS_2, options: StyleframeOptions) => string;
51
-
52
- /**
53
- * Consumes a declarations block, equivalent to setting CSS properties
54
- */
55
- export declare function createDeclarationsConsumer(consume: ConsumeFunction): (instance: DeclarationsBlock, options: StyleframeOptions) => string[];
56
-
57
23
  export declare function createFile(name: string, content?: string): OutputFile;
58
24
 
59
- /**
60
- * Consumes a primitive instance, equivalent to setting a CSS value
61
- */
62
- export declare function createPrimitiveConsumer(_consume: ConsumeFunction): (instance: unknown, _options: StyleframeOptions) => string;
63
-
64
- /**
65
- * Consumes a ref instance, equivalent to referencing a CSS variable with optional fallback
66
- */
67
- export declare function createRefConsumer(consume: ConsumeFunction): (instance: Reference, options: StyleframeOptions) => string;
68
-
69
- export declare function createRootConsumer(consume: ConsumeFunction): (instance: Root, options: StyleframeOptions) => string;
70
-
71
- /**
72
- * Consumes a selector instance, equivalent to setting a CSS selector
73
- */
74
- export declare function createSelectorConsumer(consume: ConsumeFunction): (instance: Selector, options: StyleframeOptions) => string;
75
-
76
- export declare function createThemeConsumer(consume: ConsumeFunction): (instance: Theme, options: StyleframeOptions) => string;
77
-
78
- /**
79
- * Consumes a utility instance, equivalent to setting a utility CSS selector
80
- */
81
- export declare function createUtilityConsumer(consume: ConsumeFunction): (instance: Utility, options: StyleframeOptions) => string;
82
-
83
- export declare function createVariableConsumer(consume: ConsumeFunction): (instance: Variable, options: StyleframeOptions) => string;
84
-
85
25
  export declare const DEFAULT_INDENT = "\t";
86
26
 
87
27
  export declare const defaultThemeSelectorFn: ThemeSelectorFn;
@@ -92,6 +32,8 @@ export declare const defaultVariableNameFn: VariableNameFn;
92
32
 
93
33
  export declare function indentLines(lines: string): string;
94
34
 
35
+ export declare function isUppercase(char: string): boolean;
36
+
95
37
  export declare type Output = {
96
38
  files: OutputFile[];
97
39
  };
@@ -105,6 +47,8 @@ export declare const STATEMENT_AT_RULES: string[];
105
47
 
106
48
  export declare const STATEMENT_OR_BLOCK_AT_RULES: string[];
107
49
 
50
+ export declare function toCamelCase<S extends string>(str: S): CamelCase<S>;
51
+
108
52
  export declare function toKebabCase<S extends string>(str: S): KebabCase<S>;
109
53
 
110
54
  export declare function transpile(instance: Styleframe, { type, consumers, }?: TranspileOptions): Promise<Output>;
@@ -1,159 +1,188 @@
1
- const ve = " ", N = ["charset", "import", "namespace"], R = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, I = ({
1
+ const Fe = " ", N = ["charset", "import", "namespace"], D = ["layer"], L = ({ name: e }) => `[data-theme="${e}"]`, I = ({
2
2
  name: e,
3
3
  value: t,
4
- modifiers: n
5
- }) => `._${[...n, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
6
- function L(e, t) {
4
+ modifiers: r
5
+ }) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
6
+ function U(e, t) {
7
7
  return `@${e}${t ? " " : ""}${t}`;
8
8
  }
9
- const P = /\d/, M = ["-", "_", "/", "."];
10
- function $(e = "") {
11
- if (!P.test(e))
9
+ const _ = /\d/, P = ["-", "_", "/", "."];
10
+ function M(e = "") {
11
+ if (!_.test(e))
12
12
  return e !== e.toLowerCase();
13
13
  }
14
- function U(e, t) {
15
- const n = M, r = [];
14
+ function $(e, t) {
15
+ const r = P, n = [];
16
16
  if (!e || typeof e != "string")
17
- return r;
18
- let c = "", a, i;
19
- for (const s of e) {
20
- const o = n.includes(s);
21
- if (o === !0) {
22
- r.push(c), c = "", a = void 0;
17
+ return n;
18
+ let o = "", s, i;
19
+ for (const a of e) {
20
+ const c = r.includes(a);
21
+ if (c === !0) {
22
+ n.push(o), o = "", s = void 0;
23
23
  continue;
24
24
  }
25
- const u = $(s);
25
+ const u = M(a);
26
26
  if (i === !1) {
27
- if (a === !1 && u === !0) {
28
- r.push(c), c = s, a = u;
27
+ if (s === !1 && u === !0) {
28
+ n.push(o), o = a, s = u;
29
29
  continue;
30
30
  }
31
- if (a === !0 && u === !1 && c.length > 1) {
32
- const f = c.at(-1);
33
- r.push(c.slice(0, Math.max(0, c.length - 1))), c = f + s, a = u;
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;
34
34
  continue;
35
35
  }
36
36
  }
37
- c += s, a = u, i = o;
37
+ o += a, s = u, i = c;
38
38
  }
39
- return r.push(c), r;
40
- }
41
- function _(e, t) {
42
- return e ? (Array.isArray(e) ? e : U(e)).map((n) => n.toLowerCase()).join("-") : "";
39
+ return n.push(o), n;
43
40
  }
44
41
  function k(e) {
42
+ return e ? e[0].toUpperCase() + e.slice(1) : "";
43
+ }
44
+ function x(e) {
45
+ return e ? e[0].toLowerCase() + e.slice(1) : "";
46
+ }
47
+ function V(e, t) {
48
+ return e ? (Array.isArray(e) ? e : $(e)).map((r) => k(r)).join("") : "";
49
+ }
50
+ function q(e, t) {
51
+ return x(V(e || ""));
52
+ }
53
+ function K(e, t) {
54
+ return e ? (Array.isArray(e) ? e : $(e)).map((r) => r.toLowerCase()).join("-") : "";
55
+ }
56
+ function z(e) {
45
57
  return ` ${e}`;
46
58
  }
47
- function V(e) {
59
+ function H(e) {
48
60
  return e.split(`
49
- `).map((t) => k(t)).join(`
61
+ `).map((t) => z(t)).join(`
50
62
  `);
51
63
  }
52
- function x(e) {
53
- return _(e);
64
+ function Q(e) {
65
+ return e === e.toUpperCase();
54
66
  }
55
- function K(e) {
56
- return x(e);
67
+ function Z(e) {
68
+ return q(e);
69
+ }
70
+ function J(e) {
71
+ return K(e);
72
+ }
73
+ function W(e) {
74
+ return J(e);
57
75
  }
58
- function B(e, t) {
59
- return `${e.startsWith("--") ? e : K(e)}: ${t};`;
76
+ function O(e, t) {
77
+ return `${e.startsWith("--") ? e : W(e)}: ${t};`;
60
78
  }
61
- function q(e) {
79
+ function G(e) {
62
80
  return `{${e.length > 0 ? `
63
- ` : ""}${e.map((t) => `${V(`${t}`)}
81
+ ` : ""}${e.map((t) => `${H(`${t}`)}
64
82
  `).join("")}}`;
65
83
  }
66
- function O(e) {
84
+ function B(e) {
67
85
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
68
86
  }
69
- function z(e, t) {
70
- return B(O(e), t);
87
+ function Y(e, t) {
88
+ return O(B(e), t);
71
89
  }
72
- function H(e, t) {
73
- return `var(${O(e)}${t ? `, ${t}` : ""})`;
90
+ function X(e, t) {
91
+ return `var(${B(e)}${t ? `, ${t}` : ""})`;
74
92
  }
75
- function C(e, t) {
76
- return `${e} ${q(t)}`;
93
+ function v(e, t) {
94
+ return `${e} ${G(t)}`;
77
95
  }
78
- function Q(e) {
79
- return function(n, r) {
80
- return Object.entries(n).map(([c, a]) => B(c, e(a, r)));
96
+ function ee(e) {
97
+ return function(r, n) {
98
+ return Object.entries(r).map(([o, s]) => O(o, e(s, n)));
81
99
  };
82
100
  }
83
101
  function E(e) {
84
- return function(n, r) {
85
- const a = (r.variables?.name ?? w)({ name: n.name });
86
- return z(a, e(n.value, r));
102
+ return function(r, n) {
103
+ const s = (n.variables?.name ?? w)({ name: r.name });
104
+ return Y(s, e(r.value, n));
87
105
  };
88
106
  }
89
- function S(e) {
90
- const t = E(e), n = Q(e);
91
- return function(c, a, i) {
92
- const { variables: s, declarations: o, children: u } = a, f = c === ":root", l = (s ?? []).map(
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(
93
111
  (A) => t(A, i)
94
- ), m = n(
95
- o ?? {},
112
+ ), m = r(
113
+ c ?? {},
96
114
  i
97
115
  ), y = (u ?? []).map(
98
116
  (A) => e(A, i)
99
- ), d = l.length > 0, h = m.length > 0, v = y.length > 0;
100
- return f ? `${d || h ? C(c, [
117
+ ), p = l.length > 0, b = m.length > 0, S = y.length > 0;
118
+ return f ? `${p || b ? v(o, [
101
119
  ...l,
102
- ...d && h ? [""] : [],
120
+ ...p && b ? [""] : [],
103
121
  ...m
104
- ]) : ""}${v && (d || h) ? `
122
+ ]) : ""}${S && (p || b) ? `
105
123
 
106
124
  ` : ""}${y.join(`
107
125
 
108
- `)}` : C(c, [
126
+ `)}` : v(o, [
109
127
  ...l,
110
- ...d && (v || h) ? [""] : [],
128
+ ...p && (S || b) ? [""] : [],
111
129
  ...m,
112
- ...h && v ? [""] : [],
130
+ ...b && S ? [""] : [],
113
131
  ...y.flatMap(
114
132
  (A, F) => F === y.length - 1 ? [A] : [A, ""]
115
133
  )
116
134
  ]);
117
135
  };
118
136
  }
119
- function Z(e) {
120
- const t = S(e);
121
- return function(r, c) {
122
- const a = N.includes(r.identifier), i = R.includes(
123
- r.identifier
124
- ), s = Object.keys(r.declarations).length > 0, o = r.variables.length > 0, u = r.children.length > 0, f = L(r.identifier, r.rule);
125
- return a || i && !(s || o || u) ? `${f};` : t(f, r, c);
137
+ function te(e) {
138
+ const t = C(e);
139
+ return function(n, o) {
140
+ const s = N.includes(n.identifier), i = D.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);
126
144
  };
127
145
  }
128
- function W(e) {
146
+ function re(e) {
147
+ return function(r, n) {
148
+ return r.value.map((o) => e(o, n)).join("").trim();
149
+ };
150
+ }
151
+ function ne(e) {
129
152
  return typeof e == "object" && e !== null;
130
153
  }
131
- function b(e, t) {
132
- return W(e) && "type" in e && e.type === t;
154
+ function h(e, t) {
155
+ return ne(e) && "type" in e && e.type === t;
133
156
  }
134
- function J(e) {
135
- return b(e, "variable");
157
+ function oe(e) {
158
+ return h(e, "variable");
136
159
  }
137
- function G(e) {
138
- return b(e, "reference");
160
+ function ce(e) {
161
+ return h(e, "reference");
162
+ }
163
+ function ue(e) {
164
+ return h(e, "selector");
139
165
  }
140
- function Y(e) {
141
- return b(e, "selector");
166
+ function ie(e) {
167
+ return h(e, "at-rule");
142
168
  }
143
- function X(e) {
144
- return b(e, "at-rule");
169
+ function se(e) {
170
+ return h(e, "utility");
145
171
  }
146
- function ee(e) {
147
- return b(e, "utility");
172
+ function ae(e) {
173
+ return h(e, "css");
148
174
  }
149
- function te(e) {
150
- return b(e, "css");
175
+ function le(e) {
176
+ return h(e, "theme");
151
177
  }
152
- function ne(e) {
153
- return b(e, "theme");
178
+ function T(e) {
179
+ return h(e, "root");
154
180
  }
155
- function re(e) {
156
- return b(e, "root");
181
+ function fe(e) {
182
+ return h(e, "recipe");
183
+ }
184
+ function me(e) {
185
+ return e.charAt(0).toUpperCase() + e.slice(1);
157
186
  }
158
187
  function g(e) {
159
188
  if (e instanceof Buffer)
@@ -165,225 +194,245 @@ function g(e) {
165
194
  e.byteLength / e.BYTES_PER_ELEMENT || 1
166
195
  );
167
196
  }
168
- function oe(e) {
197
+ function pe(e) {
169
198
  if (e = e || {}, e.circular)
170
- return ue(e);
199
+ return ye(e);
171
200
  const t = /* @__PURE__ */ new Map();
172
201
  if (t.set(Date, (i) => new Date(i)), t.set(
173
202
  Map,
174
- (i, s) => new Map(r(Array.from(i), s))
203
+ (i, a) => new Map(n(Array.from(i), a))
175
204
  ), t.set(
176
205
  Set,
177
- (i, s) => new Set(r(Array.from(i), s))
206
+ (i, a) => new Set(n(Array.from(i), a))
178
207
  ), e.constructorHandlers)
179
208
  for (const i of e.constructorHandlers)
180
209
  t.set(i[0], i[1]);
181
- let n;
182
- return e.proto ? a : c;
183
- function r(i, s) {
184
- const o = Object.keys(i), u = Array.from({ length: o.length });
185
- for (let f = 0; f < o.length; f++) {
186
- const l = o[f], m = i[l];
187
- 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);
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 });
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);
188
217
  }
189
218
  return u;
190
219
  }
191
- function c(i) {
220
+ function o(i) {
192
221
  if (typeof i != "object" || i === null) return i;
193
- if (Array.isArray(i)) return r(i, c);
194
- if (i.constructor !== Object && (n = t.get(i.constructor)))
195
- return n(i, c);
196
- const s = {};
197
- for (const o in i) {
198
- if (Object.hasOwnProperty.call(i, o) === !1) continue;
199
- const u = i[o];
200
- typeof u != "object" || u === null ? s[o] = u : u.constructor !== Object && (n = t.get(u.constructor)) ? s[o] = n(u, c) : ArrayBuffer.isView(u) ? s[o] = g(u) : s[o] = c(u);
222
+ if (Array.isArray(i)) return n(i, o);
223
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
224
+ return r(i, o);
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);
201
230
  }
202
- return s;
231
+ return a;
203
232
  }
204
- function a(i) {
233
+ function s(i) {
205
234
  if (typeof i != "object" || i === null) return i;
206
- if (Array.isArray(i)) return r(i, a);
207
- if (i.constructor !== Object && (n = t.get(i.constructor)))
208
- return n(i, a);
209
- const s = {};
210
- for (const o in i) {
211
- const u = i[o];
212
- typeof u != "object" || u === null ? s[o] = u : u.constructor !== Object && (n = t.get(u.constructor)) ? s[o] = n(u, a) : ArrayBuffer.isView(u) ? s[o] = g(u) : s[o] = a(u);
235
+ if (Array.isArray(i)) return n(i, s);
236
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
237
+ return r(i, s);
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);
213
242
  }
214
- return s;
243
+ return a;
215
244
  }
216
245
  }
217
- function ue(e) {
218
- const t = [], n = [], r = /* @__PURE__ */ new Map();
219
- if (r.set(Date, (o) => new Date(o)), r.set(
246
+ function ye(e) {
247
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
248
+ if (n.set(Date, (c) => new Date(c)), n.set(
220
249
  Map,
221
- (o, u) => new Map(a(Array.from(o), u))
222
- ), r.set(
250
+ (c, u) => new Map(s(Array.from(c), u))
251
+ ), n.set(
223
252
  Set,
224
- (o, u) => new Set(a(Array.from(o), u))
253
+ (c, u) => new Set(s(Array.from(c), u))
225
254
  ), e.constructorHandlers)
226
- for (const o of e.constructorHandlers)
227
- r.set(o[0], o[1]);
228
- let c;
229
- return e.proto ? s : i;
230
- function a(o, u) {
231
- const f = Object.keys(o), l = Array.from({ length: f.length });
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) {
260
+ const f = Object.keys(c), l = Array.from({ length: f.length });
232
261
  for (let m = 0; m < f.length; m++) {
233
- const y = f[m], d = o[y];
234
- if (typeof d != "object" || d === null)
235
- l[y] = d;
236
- else if (d.constructor !== Object && (c = r.get(d.constructor)))
237
- l[y] = c(d, u);
238
- else if (ArrayBuffer.isView(d))
239
- l[y] = g(d);
262
+ const y = f[m], p = c[y];
263
+ if (typeof p != "object" || p === null)
264
+ l[y] = p;
265
+ else if (p.constructor !== Object && (o = n.get(p.constructor)))
266
+ l[y] = o(p, u);
267
+ else if (ArrayBuffer.isView(p))
268
+ l[y] = g(p);
240
269
  else {
241
- const h = t.indexOf(d);
242
- h !== -1 ? l[y] = n[h] : l[y] = u(d);
270
+ const b = t.indexOf(p);
271
+ b !== -1 ? l[y] = r[b] : l[y] = u(p);
243
272
  }
244
273
  }
245
274
  return l;
246
275
  }
247
- function i(o) {
248
- if (typeof o != "object" || o === null) return o;
249
- if (Array.isArray(o)) return a(o, i);
250
- if (o.constructor !== Object && (c = r.get(o.constructor)))
251
- return c(o, i);
276
+ function i(c) {
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);
252
281
  const u = {};
253
- t.push(o), n.push(u);
254
- for (const f in o) {
255
- if (Object.hasOwnProperty.call(o, f) === !1) continue;
256
- const l = o[f];
282
+ t.push(c), r.push(u);
283
+ for (const f in c) {
284
+ if (Object.hasOwnProperty.call(c, f) === !1) continue;
285
+ const l = c[f];
257
286
  if (typeof l != "object" || l === null)
258
287
  u[f] = l;
259
- else if (l.constructor !== Object && (c = r.get(l.constructor)))
260
- u[f] = c(l, i);
288
+ else if (l.constructor !== Object && (o = n.get(l.constructor)))
289
+ u[f] = o(l, i);
261
290
  else if (ArrayBuffer.isView(l))
262
291
  u[f] = g(l);
263
292
  else {
264
293
  const m = t.indexOf(l);
265
- m !== -1 ? u[f] = n[m] : u[f] = i(l);
294
+ m !== -1 ? u[f] = r[m] : u[f] = i(l);
266
295
  }
267
296
  }
268
- return t.pop(), n.pop(), u;
297
+ return t.pop(), r.pop(), u;
269
298
  }
270
- function s(o) {
271
- if (typeof o != "object" || o === null) return o;
272
- if (Array.isArray(o)) return a(o, s);
273
- if (o.constructor !== Object && (c = r.get(o.constructor)))
274
- return c(o, s);
299
+ function a(c) {
300
+ if (typeof c != "object" || c === null) return c;
301
+ if (Array.isArray(c)) return s(c, a);
302
+ if (c.constructor !== Object && (o = n.get(c.constructor)))
303
+ return o(c, a);
275
304
  const u = {};
276
- t.push(o), n.push(u);
277
- for (const f in o) {
278
- const l = o[f];
305
+ t.push(c), r.push(u);
306
+ for (const f in c) {
307
+ const l = c[f];
279
308
  if (typeof l != "object" || l === null)
280
309
  u[f] = l;
281
- else if (l.constructor !== Object && (c = r.get(l.constructor)))
282
- u[f] = c(l, s);
310
+ else if (l.constructor !== Object && (o = n.get(l.constructor)))
311
+ u[f] = o(l, a);
283
312
  else if (ArrayBuffer.isView(l))
284
313
  u[f] = g(l);
285
314
  else {
286
315
  const m = t.indexOf(l);
287
- m !== -1 ? u[f] = n[m] : u[f] = s(l);
316
+ m !== -1 ? u[f] = r[m] : u[f] = a(l);
288
317
  }
289
318
  }
290
- return t.pop(), n.pop(), u;
319
+ return t.pop(), r.pop(), u;
291
320
  }
292
321
  }
293
- oe();
294
- function ce(e) {
295
- return function(n, r) {
296
- return n.value.map((c) => e(c, r)).join("").trim();
322
+ pe();
323
+ function de(e) {
324
+ return function(r, n) {
325
+ return r != null ? `${r}` : "";
297
326
  };
298
327
  }
299
- function ie(e) {
300
- return function(n, r) {
301
- return n != null ? `${n}` : "";
302
- };
303
- }
304
- function se(e) {
305
- return function(n, r) {
306
- const a = (r.variables?.name ?? w)({ name: n.name });
307
- return H(
308
- a,
309
- n.fallback ? e(n.fallback, r) : void 0
328
+ function he(e) {
329
+ return function(r, n) {
330
+ const s = (n.variables?.name ?? w)({ name: r.name });
331
+ return X(
332
+ s,
333
+ r.fallback ? e(r.fallback, n) : void 0
310
334
  );
311
335
  };
312
336
  }
313
- function ae(e) {
314
- const t = S(e);
315
- return function(r, c) {
316
- return r.themes.reduce(
317
- (a, i) => (a.push(e(i, c)), a),
318
- [t(":root", r, c)]
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)]
319
343
  // Default theme (root)
320
344
  ).join(`
321
345
 
322
346
  `);
323
347
  };
324
348
  }
325
- function le(e) {
326
- const t = S(e);
327
- return function(r, c) {
328
- return t(r.query, r, c);
349
+ function Ae(e) {
350
+ const t = C(e);
351
+ return function(n, o) {
352
+ return t(n.query, n, o);
329
353
  };
330
354
  }
331
- function fe(e) {
332
- const t = S(e);
333
- return function(r, c) {
334
- const i = (c.theme?.selector ?? D)({ name: r.name });
335
- return t(i, r, c);
355
+ function ge(e) {
356
+ const t = C(e);
357
+ return function(n, o) {
358
+ const i = (o.themes?.selector ?? L)({ name: n.name });
359
+ return t(i, n, o);
336
360
  };
337
361
  }
338
- function me(e) {
339
- const t = S(e);
340
- return function(r, c) {
341
- const a = [], s = (c.utilities?.selector ?? I)({
342
- name: r.name,
343
- value: r.value,
344
- modifiers: r.modifiers
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
345
369
  });
346
- return a.push(t(s, r, c)), a.join(`
370
+ return s.push(t(a, n, o)), s.join(`
347
371
 
348
372
  `);
349
373
  };
350
374
  }
351
- function p(e, t) {
352
- const n = ae(p), r = le(p), c = me(p), a = Z(p), i = fe(p), s = E(p), o = se(p), u = ce(p), f = ie();
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();
353
377
  switch (!0) {
354
- case Y(e):
355
- return r(e, t);
356
- case ee(e):
357
- return c(e, t);
358
- case X(e):
359
- return a(e, t);
360
- case re(e):
378
+ case ue(e):
361
379
  return n(e, t);
362
- case ne(e):
363
- return i(e, t);
364
- case J(e):
365
- return s(e, t);
366
- case G(e):
380
+ case se(e):
367
381
  return o(e, t);
368
- case te(e):
382
+ case ie(e):
383
+ return s(e, t);
384
+ case T(e):
385
+ return r(e, t);
386
+ case le(e):
387
+ return i(e, t);
388
+ case oe(e):
389
+ return a(e, t);
390
+ case ce(e):
391
+ return c(e, t);
392
+ case ae(e):
369
393
  return u(e, t);
370
394
  default:
371
395
  return f(e, t);
372
396
  }
373
397
  }
374
- function T(e, t) {
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 ?? {};
403
+ return `const ${s} = ${JSON.stringify(
404
+ i,
405
+ null,
406
+ 4
407
+ )} as const satisfies RecipeRuntime;
408
+
409
+ export const ${o} = createRecipe("${r.name}", ${s});
410
+ `;
411
+ };
412
+ }
413
+ function je(e) {
414
+ return function(r, n) {
415
+ return r.recipes.length > 0 ? `import { createRecipe } from '@styleframe/runtime';
416
+ import type { RecipeRuntime } from '@styleframe/runtime';
417
+
418
+ ${e(r.recipes, n)}` : "";
419
+ };
420
+ }
421
+ function j(e, t) {
422
+ const r = je(j), n = Se();
375
423
  switch (!0) {
376
424
  case Array.isArray(e):
377
- return e.map((n) => T(n)).join(`
425
+ return e.map((o) => j(o, t)).join(`
378
426
  `);
379
- // case isRecipe(instance):
380
- // return consumeRecipe(instance, options);
381
- // break;
427
+ case T(e):
428
+ return r(e, t);
429
+ case fe(e):
430
+ return n(e, t);
382
431
  default:
383
432
  return "";
384
433
  }
385
434
  }
386
- const de = `-----BEGIN PUBLIC KEY-----
435
+ const ve = `-----BEGIN PUBLIC KEY-----
387
436
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
388
437
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
389
438
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -391,12 +440,12 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
391
440
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
392
441
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
393
442
  GwIDAQAB
394
- -----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
395
- async function he(e) {
396
- const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), n = Uint8Array.from(atob(t), (r) => r.charCodeAt(0));
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));
397
446
  return await crypto.subtle.importKey(
398
447
  "spki",
399
- n,
448
+ r,
400
449
  {
401
450
  name: "RSASSA-PKCS1-v1_5",
402
451
  hash: "SHA-256"
@@ -405,32 +454,32 @@ async function he(e) {
405
454
  ["verify"]
406
455
  );
407
456
  }
408
- async function be({
457
+ async function Oe({
409
458
  payload: e,
410
459
  signature: t
411
460
  }) {
412
- const n = new TextEncoder().encode(e), r = Uint8Array.from(
461
+ const r = new TextEncoder().encode(e), n = Uint8Array.from(
413
462
  atob(t),
414
- (a) => a.charCodeAt(0)
415
- ), c = await he(de);
463
+ (s) => s.charCodeAt(0)
464
+ ), o = await $e(ve);
416
465
  if (!await crypto.subtle.verify(
417
466
  { name: "RSASSA-PKCS1-v1_5" },
418
- c,
419
- r,
420
- n
467
+ o,
468
+ n,
469
+ r
421
470
  ))
422
471
  throw new Error(
423
472
  "License validation failed: Invalid signature detected. The license may have been modified or corrupted."
424
473
  );
425
474
  return JSON.parse(e);
426
475
  }
427
- function Ae(e) {
428
- return Object.prototype.hasOwnProperty.call(e, ye);
476
+ function Be(e) {
477
+ return Object.prototype.hasOwnProperty.call(e, Re);
429
478
  }
430
- async function ge(e) {
479
+ async function Ee(e) {
431
480
  const t = Object.getOwnPropertyDescriptor(
432
481
  e,
433
- pe
482
+ we
434
483
  );
435
484
  if (!t?.value)
436
485
  return {
@@ -439,8 +488,8 @@ async function ge(e) {
439
488
  environment: "",
440
489
  valid: !1
441
490
  };
442
- const n = t.value;
443
- if (typeof n != "object" || n === null || !("payload" in n) || !("signature" in n) || typeof n.payload != "string" || typeof n.signature != "string")
491
+ const r = t.value;
492
+ if (typeof r != "object" || r === null || !("payload" in r) || !("signature" in r) || typeof r.payload != "string" || typeof r.signature != "string")
444
493
  return {
445
494
  key: "",
446
495
  instanceId: "",
@@ -448,8 +497,8 @@ async function ge(e) {
448
497
  valid: !1
449
498
  };
450
499
  try {
451
- return await be(
452
- n
500
+ return await Oe(
501
+ r
453
502
  );
454
503
  } catch {
455
504
  return {
@@ -460,7 +509,7 @@ async function ge(e) {
460
509
  };
461
510
  }
462
511
  }
463
- function Se(e) {
512
+ function Te(e) {
464
513
  const t = Math.floor(Math.random() * 100);
465
514
  e.root.children.push({
466
515
  type: "selector",
@@ -484,55 +533,51 @@ function Se(e) {
484
533
  }
485
534
  });
486
535
  }
487
- function j(e, t = "") {
536
+ function R(e, t = "") {
488
537
  return {
489
538
  name: e,
490
539
  content: t
491
540
  };
492
541
  }
493
- async function Ce(e, {
542
+ async function Ne(e, {
494
543
  type: t = "all",
495
- consumers: n = { css: p, ts: T }
544
+ consumers: r = { css: d, ts: j }
496
545
  } = {}) {
497
- const r = { files: [] }, c = e.options;
498
- if (Ae(e)) {
499
- const s = await ge(e);
500
- (!s.valid || s.instanceId !== e.id) && Se(e);
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);
501
550
  }
502
- const { recipes: a, ...i } = e.root;
503
551
  if (t === "all" || t === "css") {
504
- const s = j("index.css", n.css(i, c));
505
- r.files.push(s);
552
+ const s = R(
553
+ "index.css",
554
+ r.css(e.root, o)
555
+ );
556
+ n.files.push(s);
506
557
  }
507
558
  if (t === "all" || t === "ts") {
508
- const s = j("index.ts", n.ts([], c));
509
- r.files.push(s);
559
+ const s = R(
560
+ "index.ts",
561
+ r.ts(e.root, o)
562
+ );
563
+ n.files.push(s);
510
564
  }
511
- return r;
565
+ return n;
512
566
  }
513
567
  export {
514
- ve as DEFAULT_INDENT,
568
+ Fe as DEFAULT_INDENT,
515
569
  N as STATEMENT_AT_RULES,
516
- R as STATEMENT_OR_BLOCK_AT_RULES,
517
- k as addIndentToLine,
518
- p as consumeCSS,
519
- T as consumeTS,
520
- Z as createAtRuleConsumer,
521
- ce as createCSSTemplateLiteralConsumer,
522
- S as createContainerConsumer,
523
- Q as createDeclarationsConsumer,
524
- j as createFile,
525
- ie as createPrimitiveConsumer,
526
- se as createRefConsumer,
527
- ae as createRootConsumer,
528
- le as createSelectorConsumer,
529
- fe as createThemeConsumer,
530
- me as createUtilityConsumer,
531
- E as createVariableConsumer,
532
- D as defaultThemeSelectorFn,
570
+ D as STATEMENT_OR_BLOCK_AT_RULES,
571
+ z as addIndentToLine,
572
+ d as consumeCSS,
573
+ j as consumeTS,
574
+ R as createFile,
575
+ L as defaultThemeSelectorFn,
533
576
  I as defaultUtilitySelectorFn,
534
577
  w as defaultVariableNameFn,
535
- V as indentLines,
536
- x as toKebabCase,
537
- Ce as transpile
578
+ H as indentLines,
579
+ Q as isUppercase,
580
+ Z as toCamelCase,
581
+ J as toKebabCase,
582
+ Ne as transpile
538
583
  };
@@ -1,17 +1,23 @@
1
- (function(m,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(m=typeof globalThis<"u"?globalThis:m||self,T(m.transpiler={}))})(this,(function(m){"use strict";const F=["charset","import","namespace"],O=["layer"],B=({name:e})=>`[data-theme="${e}"]`,R=({name:e,value:t,modifiers:n})=>`._${[...n,e,t].filter(Boolean).join("\\:")}`,v=({name:e})=>e;function Z(e,t){return`@${e}${t?" ":""}${t}`}const W=/\d/,J=["-","_","/","."];function G(e=""){if(!W.test(e))return e!==e.toLowerCase()}function Y(e,t){const n=J,r=[];if(!e||typeof e!="string")return r;let c="",s,i;for(const a of e){const o=n.includes(a);if(o===!0){r.push(c),c="",s=void 0;continue}const u=G(a);if(i===!1){if(s===!1&&u===!0){r.push(c),c=a,s=u;continue}if(s===!0&&u===!1&&c.length>1){const f=c.at(-1);r.push(c.slice(0,Math.max(0,c.length-1))),c=f+a,s=u;continue}}c+=a,s=u,i=o}return r.push(c),r}function X(e,t){return e?(Array.isArray(e)?e:Y(e)).map(n=>n.toLowerCase()).join("-"):""}function L(e){return` ${e}`}function D(e){return e.split(`
2
- `).map(t=>L(t)).join(`
3
- `)}function _(e){return X(e)}function x(e){return _(e)}function I(e,t){return`${e.startsWith("--")?e:x(e)}: ${t};`}function ee(e){return`{${e.length>0?`
4
- `:""}${e.map(t=>`${D(`${t}`)}
5
- `).join("")}}`}function U(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function te(e,t){return I(U(e),t)}function ne(e,t){return`var(${U(e)}${t?`, ${t}`:""})`}function M(e,t){return`${e} ${ee(t)}`}function P(e){return function(n,r){return Object.entries(n).map(([c,s])=>I(c,e(s,r)))}}function j(e){return function(n,r){const s=(r.variables?.name??v)({name:n.name});return te(s,e(n.value,r))}}function S(e){const t=j(e),n=P(e);return function(c,s,i){const{variables:a,declarations:o,children:u}=s,f=c===":root",l=(a??[]).map(g=>t(g,i)),d=n(o??{},i),b=(u??[]).map(g=>e(g,i)),y=l.length>0,A=d.length>0,w=b.length>0;return f?`${y||A?M(c,[...l,...y&&A?[""]:[],...d]):""}${w&&(y||A)?`
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}"]`,F=({name:e,value:t,modifiers:n})=>`._${[...n,e,...t==="default"?[]:[t]].filter(Boolean).join("\\:")}`,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 $(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:$(e)).map(n=>Q(n)).join(""):""}function J(e,t){return Z(x(e||""))}function W(e,t){return e?(Array.isArray(e)?e:$(e)).map(n=>n.toLowerCase()).join("-"):""}function B(e){return` ${e}`}function L(e){return e.split(`
2
+ `).map(t=>B(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=>`${L(`${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)?`
6
6
 
7
- `:""}${b.join(`
7
+ `:""}${y.join(`
8
8
 
9
- `)}`:M(c,[...l,...y&&(w||A)?[""]:[],...d,...A&&w?[""]:[],...b.flatMap((g,ve)=>ve===b.length-1?[g]:[g,""])])}}function $(e){const t=S(e);return function(r,c){const s=F.includes(r.identifier),i=O.includes(r.identifier),a=Object.keys(r.declarations).length>0,o=r.variables.length>0,u=r.children.length>0,f=Z(r.identifier,r.rule);return s||i&&!(a||o||u)?`${f};`:t(f,r,c)}}function re(e){return typeof e=="object"&&e!==null}function p(e,t){return re(e)&&"type"in e&&e.type===t}function oe(e){return p(e,"variable")}function ue(e){return p(e,"reference")}function ce(e){return p(e,"selector")}function ie(e){return p(e,"at-rule")}function ae(e){return p(e,"utility")}function se(e){return p(e,"css")}function le(e){return p(e,"theme")}function fe(e){return p(e,"root")}function C(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 me(e){if(e=e||{},e.circular)return de(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,a)=>new Map(r(Array.from(i),a))),t.set(Set,(i,a)=>new Set(r(Array.from(i),a))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let n;return e.proto?s:c;function r(i,a){const o=Object.keys(i),u=Array.from({length:o.length});for(let f=0;f<o.length;f++){const l=o[f],d=i[l];typeof d!="object"||d===null?u[l]=d:d.constructor!==Object&&(n=t.get(d.constructor))?u[l]=n(d,a):ArrayBuffer.isView(d)?u[l]=C(d):u[l]=a(d)}return u}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return r(i,c);if(i.constructor!==Object&&(n=t.get(i.constructor)))return n(i,c);const a={};for(const o in i){if(Object.hasOwnProperty.call(i,o)===!1)continue;const u=i[o];typeof u!="object"||u===null?a[o]=u:u.constructor!==Object&&(n=t.get(u.constructor))?a[o]=n(u,c):ArrayBuffer.isView(u)?a[o]=C(u):a[o]=c(u)}return a}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return r(i,s);if(i.constructor!==Object&&(n=t.get(i.constructor)))return n(i,s);const a={};for(const o in i){const u=i[o];typeof u!="object"||u===null?a[o]=u:u.constructor!==Object&&(n=t.get(u.constructor))?a[o]=n(u,s):ArrayBuffer.isView(u)?a[o]=C(u):a[o]=s(u)}return a}}function de(e){const t=[],n=[],r=new Map;if(r.set(Date,o=>new Date(o)),r.set(Map,(o,u)=>new Map(s(Array.from(o),u))),r.set(Set,(o,u)=>new Set(s(Array.from(o),u))),e.constructorHandlers)for(const o of e.constructorHandlers)r.set(o[0],o[1]);let c;return e.proto?a:i;function s(o,u){const f=Object.keys(o),l=Array.from({length:f.length});for(let d=0;d<f.length;d++){const b=f[d],y=o[b];if(typeof y!="object"||y===null)l[b]=y;else if(y.constructor!==Object&&(c=r.get(y.constructor)))l[b]=c(y,u);else if(ArrayBuffer.isView(y))l[b]=C(y);else{const A=t.indexOf(y);A!==-1?l[b]=n[A]:l[b]=u(y)}}return l}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,i);if(o.constructor!==Object&&(c=r.get(o.constructor)))return c(o,i);const u={};t.push(o),n.push(u);for(const f in o){if(Object.hasOwnProperty.call(o,f)===!1)continue;const l=o[f];if(typeof l!="object"||l===null)u[f]=l;else if(l.constructor!==Object&&(c=r.get(l.constructor)))u[f]=c(l,i);else if(ArrayBuffer.isView(l))u[f]=C(l);else{const d=t.indexOf(l);d!==-1?u[f]=n[d]:u[f]=i(l)}}return t.pop(),n.pop(),u}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,a);if(o.constructor!==Object&&(c=r.get(o.constructor)))return c(o,a);const u={};t.push(o),n.push(u);for(const f in o){const l=o[f];if(typeof l!="object"||l===null)u[f]=l;else if(l.constructor!==Object&&(c=r.get(l.constructor)))u[f]=c(l,a);else if(ArrayBuffer.isView(l))u[f]=C(l);else{const d=t.indexOf(l);d!==-1?u[f]=n[d]:u[f]=a(l)}}return t.pop(),n.pop(),u}}me();function k(e){return function(n,r){return n.value.map(c=>e(c,r)).join("").trim()}}function V(e){return function(n,r){return n!=null?`${n}`:""}}function K(e){return function(n,r){const s=(r.variables?.name??v)({name:n.name});return ne(s,n.fallback?e(n.fallback,r):void 0)}}function q(e){const t=S(e);return function(r,c){return r.themes.reduce((s,i)=>(s.push(e(i,c)),s),[t(":root",r,c)]).join(`
9
+ `)}`:P(o,[...l,...d&&(E||A)?[""]:[],...m,...A&&E?[""]:[],...y.flatMap((S,Le)=>Le===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(`
10
10
 
11
- `)}}function z(e){const t=S(e);return function(r,c){return t(r.query,r,c)}}function H(e){const t=S(e);return function(r,c){const i=(c.theme?.selector??B)({name:r.name});return t(i,r,c)}}function Q(e){const t=S(e);return function(r,c){const s=[],a=(c.utilities?.selector??R)({name:r.name,value:r.value,modifiers:r.modifiers});return s.push(t(a,r,c)),s.join(`
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??F)({name:r.name,value:r.value,modifiers:r.modifiers});return a.push(t(s,r,o)),a.join(`
12
12
 
13
- `)}}function h(e,t){const n=q(h),r=z(h),c=Q(h),s=$(h),i=H(h),a=j(h),o=K(h),u=k(h),f=V();switch(!0){case ce(e):return r(e,t);case ae(e):return c(e,t);case ie(e):return s(e,t);case fe(e):return n(e,t);case le(e):return i(e,t);case oe(e):return a(e,t);case ue(e):return o(e,t);case se(e):return u(e,t);default:return f(e,t)}}function E(e,t){switch(!0){case Array.isArray(e):return e.map(n=>E(n)).join(`
14
- `);default:return""}}const ye=`-----BEGIN PUBLIC KEY-----
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;
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';
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-----
15
21
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
16
22
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
17
23
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -19,4 +25,4 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
19
25
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
20
26
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
21
27
  GwIDAQAB
22
- -----END PUBLIC KEY-----`,be="__licenseRequired",he="__licenseValidated";async function pe(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 Ae({payload:e,signature:t}){const n=new TextEncoder().encode(e),r=Uint8Array.from(atob(t),s=>s.charCodeAt(0)),c=await pe(ye);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},c,r,n))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function Se(e){return Object.prototype.hasOwnProperty.call(e,be)}async function Ce(e){const t=Object.getOwnPropertyDescriptor(e,he);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 Ae(n)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function ge(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 N(e,t=""){return{name:e,content:t}}async function Te(e,{type:t="all",consumers:n={css:h,ts:E}}={}){const r={files:[]},c=e.options;if(Se(e)){const a=await Ce(e);(!a.valid||a.instanceId!==e.id)&&ge(e)}const{recipes:s,...i}=e.root;if(t==="all"||t==="css"){const a=N("index.css",n.css(i,c));r.files.push(a)}if(t==="all"||t==="ts"){const a=N("index.ts",n.ts([],c));r.files.push(a)}return r}m.DEFAULT_INDENT=" ",m.STATEMENT_AT_RULES=F,m.STATEMENT_OR_BLOCK_AT_RULES=O,m.addIndentToLine=L,m.consumeCSS=h,m.consumeTS=E,m.createAtRuleConsumer=$,m.createCSSTemplateLiteralConsumer=k,m.createContainerConsumer=S,m.createDeclarationsConsumer=P,m.createFile=N,m.createPrimitiveConsumer=V,m.createRefConsumer=K,m.createRootConsumer=q,m.createSelectorConsumer=z,m.createThemeConsumer=H,m.createUtilityConsumer=Q,m.createVariableConsumer=j,m.defaultThemeSelectorFn=B,m.defaultUtilitySelectorFn=R,m.defaultVariableNameFn=v,m.indentLines=D,m.toKebabCase=_,m.transpile=Te,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
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 Fe(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 $e(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 Be(e,{type:t="all",consumers:n={css:b,ts:T}}={}){const r={files:[]},o=e.options;if(Oe(e)){const a=await Fe(e);(!a.valid||a.instanceId!==e.id)&&$e(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=B,p.consumeCSS=b,p.consumeTS=T,p.createFile=R,p.defaultThemeSelectorFn=O,p.defaultUtilitySelectorFn=F,p.defaultVariableNameFn=v,p.indentLines=L,p.isUppercase=_,p.toCamelCase=U,p.toKebabCase=D,p.transpile=Be,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.2.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "types": "./dist/transpiler.d.ts",
6
6
  "module": "./dist/transpiler.js",
@@ -22,13 +22,13 @@
22
22
  "scule": "^1.3.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@styleframe/core": "^2.2.0",
25
+ "@styleframe/core": "^2.4.0",
26
26
  "@styleframe/license": "^2.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@styleframe/config-typescript": "^2",
30
30
  "@styleframe/config-vite": "^2",
31
- "@styleframe/core": "^2.2.0",
31
+ "@styleframe/core": "^2.4.0",
32
32
  "@styleframe/license": "^2.0.0",
33
33
  "@vitest/coverage-v8": "^3.2.4",
34
34
  "typescript": "^5.8.3",