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