@styleframe/transpiler 2.0.1 → 2.0.3
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.js +132 -132
- package/dist/transpiler.umd.cjs +6 -6
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @styleframe/transpiler
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1ead424`](https://github.com/styleframe-dev/styleframe/commit/1ead424825a6696969294d3127ac79298da03182) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: update license package version
|
|
8
|
+
|
|
9
|
+
- [`a08c996`](https://github.com/styleframe-dev/styleframe/commit/a08c996b3b781ead2000b087b3b16906821ba5e3) Thanks [@alexgrozav](https://github.com/alexgrozav)! - fix: update package dependencies
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`1ead424`](https://github.com/styleframe-dev/styleframe/commit/1ead424825a6696969294d3127ac79298da03182), [`a08c996`](https://github.com/styleframe-dev/styleframe/commit/a08c996b3b781ead2000b087b3b16906821ba5e3)]:
|
|
12
|
+
- @styleframe/core@2.0.2
|
|
13
|
+
|
|
3
14
|
## 2.0.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/transpiler.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const ve = " ", N = ["charset", "import", "namespace"], R = ["layer"], D = ({ name: e }) => `[data-theme="${e}"]`, I = ({
|
|
2
2
|
name: e,
|
|
3
3
|
value: t,
|
|
4
|
-
modifiers:
|
|
5
|
-
}) => `._${[...
|
|
4
|
+
modifiers: n
|
|
5
|
+
}) => `._${[...n, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
|
|
6
6
|
function L(e, t) {
|
|
7
7
|
return `@${e}${t ? " " : ""}${t}`;
|
|
8
8
|
}
|
|
@@ -12,34 +12,34 @@ function $(e = "") {
|
|
|
12
12
|
return e !== e.toLowerCase();
|
|
13
13
|
}
|
|
14
14
|
function U(e, t) {
|
|
15
|
-
const
|
|
15
|
+
const n = M, r = [];
|
|
16
16
|
if (!e || typeof e != "string")
|
|
17
|
-
return
|
|
18
|
-
let
|
|
17
|
+
return r;
|
|
18
|
+
let c = "", a, i;
|
|
19
19
|
for (const s of e) {
|
|
20
|
-
const o =
|
|
20
|
+
const o = n.includes(s);
|
|
21
21
|
if (o === !0) {
|
|
22
|
-
|
|
22
|
+
r.push(c), c = "", a = void 0;
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const u = $(s);
|
|
26
26
|
if (i === !1) {
|
|
27
|
-
if (a === !1 &&
|
|
28
|
-
|
|
27
|
+
if (a === !1 && u === !0) {
|
|
28
|
+
r.push(c), c = s, a = u;
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
if (a === !0 &&
|
|
32
|
-
const f =
|
|
33
|
-
|
|
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;
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
c += s, a = u, i = o;
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return r.push(c), r;
|
|
40
40
|
}
|
|
41
41
|
function _(e, t) {
|
|
42
|
-
return e ? (Array.isArray(e) ? e : U(e)).map((
|
|
42
|
+
return e ? (Array.isArray(e) ? e : U(e)).map((n) => n.toLowerCase()).join("-") : "";
|
|
43
43
|
}
|
|
44
44
|
function k(e) {
|
|
45
45
|
return ` ${e}`;
|
|
@@ -76,28 +76,28 @@ function C(e, t) {
|
|
|
76
76
|
return `${e} ${q(t)}`;
|
|
77
77
|
}
|
|
78
78
|
function Q(e) {
|
|
79
|
-
return function(
|
|
80
|
-
return Object.entries(
|
|
79
|
+
return function(n, r) {
|
|
80
|
+
return Object.entries(n).map(([c, a]) => B(c, e(a, r)));
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function E(e) {
|
|
84
|
-
return function(
|
|
85
|
-
const a = (
|
|
86
|
-
return z(a, e(
|
|
84
|
+
return function(n, r) {
|
|
85
|
+
const a = (r.variables?.name ?? w)({ name: n.name });
|
|
86
|
+
return z(a, e(n.value, r));
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
function S(e) {
|
|
90
|
-
const t = E(e),
|
|
91
|
-
return function(
|
|
92
|
-
const { variables: s, declarations: o, children:
|
|
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(
|
|
93
93
|
(A) => t(A, i)
|
|
94
|
-
), m =
|
|
94
|
+
), m = n(
|
|
95
95
|
o ?? {},
|
|
96
96
|
i
|
|
97
|
-
), y = (
|
|
97
|
+
), y = (u ?? []).map(
|
|
98
98
|
(A) => e(A, i)
|
|
99
99
|
), d = l.length > 0, h = m.length > 0, v = y.length > 0;
|
|
100
|
-
return f ? `${d || h ? C(
|
|
100
|
+
return f ? `${d || h ? C(c, [
|
|
101
101
|
...l,
|
|
102
102
|
...d && h ? [""] : [],
|
|
103
103
|
...m
|
|
@@ -105,7 +105,7 @@ function S(e) {
|
|
|
105
105
|
|
|
106
106
|
` : ""}${y.join(`
|
|
107
107
|
|
|
108
|
-
`)}` : C(
|
|
108
|
+
`)}` : C(c, [
|
|
109
109
|
...l,
|
|
110
110
|
...d && (v || h) ? [""] : [],
|
|
111
111
|
...m,
|
|
@@ -118,11 +118,11 @@ function S(e) {
|
|
|
118
118
|
}
|
|
119
119
|
function Z(e) {
|
|
120
120
|
const t = S(e);
|
|
121
|
-
return function(
|
|
122
|
-
const a = N.includes(
|
|
123
|
-
|
|
124
|
-
), s = Object.keys(
|
|
125
|
-
return a || i && !(s || o ||
|
|
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);
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
function W(e) {
|
|
@@ -167,79 +167,79 @@ function g(e) {
|
|
|
167
167
|
}
|
|
168
168
|
function oe(e) {
|
|
169
169
|
if (e = e || {}, e.circular)
|
|
170
|
-
return
|
|
170
|
+
return ue(e);
|
|
171
171
|
const t = /* @__PURE__ */ new Map();
|
|
172
172
|
if (t.set(Date, (i) => new Date(i)), t.set(
|
|
173
173
|
Map,
|
|
174
|
-
(i, s) => new Map(
|
|
174
|
+
(i, s) => new Map(r(Array.from(i), s))
|
|
175
175
|
), t.set(
|
|
176
176
|
Set,
|
|
177
|
-
(i, s) => new Set(
|
|
177
|
+
(i, s) => new Set(r(Array.from(i), s))
|
|
178
178
|
), e.constructorHandlers)
|
|
179
179
|
for (const i of e.constructorHandlers)
|
|
180
180
|
t.set(i[0], i[1]);
|
|
181
|
-
let
|
|
182
|
-
return e.proto ? a :
|
|
183
|
-
function
|
|
184
|
-
const o = Object.keys(i),
|
|
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
185
|
for (let f = 0; f < o.length; f++) {
|
|
186
186
|
const l = o[f], m = i[l];
|
|
187
|
-
typeof m != "object" || m === null ?
|
|
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);
|
|
188
188
|
}
|
|
189
|
-
return
|
|
189
|
+
return u;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function c(i) {
|
|
192
192
|
if (typeof i != "object" || i === null) return i;
|
|
193
|
-
if (Array.isArray(i)) return
|
|
194
|
-
if (i.constructor !== Object && (
|
|
195
|
-
return
|
|
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
196
|
const s = {};
|
|
197
197
|
for (const o in i) {
|
|
198
198
|
if (Object.hasOwnProperty.call(i, o) === !1) continue;
|
|
199
|
-
const
|
|
200
|
-
typeof
|
|
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);
|
|
201
201
|
}
|
|
202
202
|
return s;
|
|
203
203
|
}
|
|
204
204
|
function a(i) {
|
|
205
205
|
if (typeof i != "object" || i === null) return i;
|
|
206
|
-
if (Array.isArray(i)) return
|
|
207
|
-
if (i.constructor !== Object && (
|
|
208
|
-
return
|
|
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
209
|
const s = {};
|
|
210
210
|
for (const o in i) {
|
|
211
|
-
const
|
|
212
|
-
typeof
|
|
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);
|
|
213
213
|
}
|
|
214
214
|
return s;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const t = [],
|
|
219
|
-
if (
|
|
217
|
+
function ue(e) {
|
|
218
|
+
const t = [], n = [], r = /* @__PURE__ */ new Map();
|
|
219
|
+
if (r.set(Date, (o) => new Date(o)), r.set(
|
|
220
220
|
Map,
|
|
221
|
-
(o,
|
|
222
|
-
),
|
|
221
|
+
(o, u) => new Map(a(Array.from(o), u))
|
|
222
|
+
), r.set(
|
|
223
223
|
Set,
|
|
224
|
-
(o,
|
|
224
|
+
(o, u) => new Set(a(Array.from(o), u))
|
|
225
225
|
), e.constructorHandlers)
|
|
226
226
|
for (const o of e.constructorHandlers)
|
|
227
|
-
|
|
228
|
-
let
|
|
227
|
+
r.set(o[0], o[1]);
|
|
228
|
+
let c;
|
|
229
229
|
return e.proto ? s : i;
|
|
230
|
-
function a(o,
|
|
230
|
+
function a(o, u) {
|
|
231
231
|
const f = Object.keys(o), l = Array.from({ length: f.length });
|
|
232
232
|
for (let m = 0; m < f.length; m++) {
|
|
233
233
|
const y = f[m], d = o[y];
|
|
234
234
|
if (typeof d != "object" || d === null)
|
|
235
235
|
l[y] = d;
|
|
236
|
-
else if (d.constructor !== Object && (
|
|
237
|
-
l[y] =
|
|
236
|
+
else if (d.constructor !== Object && (c = r.get(d.constructor)))
|
|
237
|
+
l[y] = c(d, u);
|
|
238
238
|
else if (ArrayBuffer.isView(d))
|
|
239
239
|
l[y] = g(d);
|
|
240
240
|
else {
|
|
241
241
|
const h = t.indexOf(d);
|
|
242
|
-
h !== -1 ? l[y] =
|
|
242
|
+
h !== -1 ? l[y] = n[h] : l[y] = u(d);
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
return l;
|
|
@@ -247,75 +247,75 @@ function ce(e) {
|
|
|
247
247
|
function i(o) {
|
|
248
248
|
if (typeof o != "object" || o === null) return o;
|
|
249
249
|
if (Array.isArray(o)) return a(o, i);
|
|
250
|
-
if (o.constructor !== Object && (
|
|
251
|
-
return
|
|
252
|
-
const
|
|
253
|
-
t.push(o),
|
|
250
|
+
if (o.constructor !== Object && (c = r.get(o.constructor)))
|
|
251
|
+
return c(o, i);
|
|
252
|
+
const u = {};
|
|
253
|
+
t.push(o), n.push(u);
|
|
254
254
|
for (const f in o) {
|
|
255
255
|
if (Object.hasOwnProperty.call(o, f) === !1) continue;
|
|
256
256
|
const l = o[f];
|
|
257
257
|
if (typeof l != "object" || l === null)
|
|
258
|
-
|
|
259
|
-
else if (l.constructor !== Object && (
|
|
260
|
-
|
|
258
|
+
u[f] = l;
|
|
259
|
+
else if (l.constructor !== Object && (c = r.get(l.constructor)))
|
|
260
|
+
u[f] = c(l, i);
|
|
261
261
|
else if (ArrayBuffer.isView(l))
|
|
262
|
-
|
|
262
|
+
u[f] = g(l);
|
|
263
263
|
else {
|
|
264
264
|
const m = t.indexOf(l);
|
|
265
|
-
m !== -1 ?
|
|
265
|
+
m !== -1 ? u[f] = n[m] : u[f] = i(l);
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
return t.pop(),
|
|
268
|
+
return t.pop(), n.pop(), u;
|
|
269
269
|
}
|
|
270
270
|
function s(o) {
|
|
271
271
|
if (typeof o != "object" || o === null) return o;
|
|
272
272
|
if (Array.isArray(o)) return a(o, s);
|
|
273
|
-
if (o.constructor !== Object && (
|
|
274
|
-
return
|
|
275
|
-
const
|
|
276
|
-
t.push(o),
|
|
273
|
+
if (o.constructor !== Object && (c = r.get(o.constructor)))
|
|
274
|
+
return c(o, s);
|
|
275
|
+
const u = {};
|
|
276
|
+
t.push(o), n.push(u);
|
|
277
277
|
for (const f in o) {
|
|
278
278
|
const l = o[f];
|
|
279
279
|
if (typeof l != "object" || l === null)
|
|
280
|
-
|
|
281
|
-
else if (l.constructor !== Object && (
|
|
282
|
-
|
|
280
|
+
u[f] = l;
|
|
281
|
+
else if (l.constructor !== Object && (c = r.get(l.constructor)))
|
|
282
|
+
u[f] = c(l, s);
|
|
283
283
|
else if (ArrayBuffer.isView(l))
|
|
284
|
-
|
|
284
|
+
u[f] = g(l);
|
|
285
285
|
else {
|
|
286
286
|
const m = t.indexOf(l);
|
|
287
|
-
m !== -1 ?
|
|
287
|
+
m !== -1 ? u[f] = n[m] : u[f] = s(l);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
return t.pop(),
|
|
290
|
+
return t.pop(), n.pop(), u;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
oe();
|
|
294
|
-
function
|
|
295
|
-
return function(
|
|
296
|
-
return
|
|
294
|
+
function ce(e) {
|
|
295
|
+
return function(n, r) {
|
|
296
|
+
return n.value.map((c) => e(c, r)).join("").trim();
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
function ie(e) {
|
|
300
|
-
return function(
|
|
301
|
-
return
|
|
300
|
+
return function(n, r) {
|
|
301
|
+
return n != null ? `${n}` : "";
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
function se(e) {
|
|
305
|
-
return function(
|
|
306
|
-
const a = (
|
|
305
|
+
return function(n, r) {
|
|
306
|
+
const a = (r.variables?.name ?? w)({ name: n.name });
|
|
307
307
|
return H(
|
|
308
308
|
a,
|
|
309
|
-
|
|
309
|
+
n.fallback ? e(n.fallback, r) : void 0
|
|
310
310
|
);
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
function ae(e) {
|
|
314
314
|
const t = S(e);
|
|
315
|
-
return function(
|
|
316
|
-
return
|
|
317
|
-
(a, i) => (a.push(e(i,
|
|
318
|
-
[t(":root",
|
|
315
|
+
return function(r, c) {
|
|
316
|
+
return r.themes.reduce(
|
|
317
|
+
(a, i) => (a.push(e(i, c)), a),
|
|
318
|
+
[t(":root", r, c)]
|
|
319
319
|
// Default theme (root)
|
|
320
320
|
).join(`
|
|
321
321
|
|
|
@@ -324,41 +324,41 @@ function ae(e) {
|
|
|
324
324
|
}
|
|
325
325
|
function le(e) {
|
|
326
326
|
const t = S(e);
|
|
327
|
-
return function(
|
|
328
|
-
return t(
|
|
327
|
+
return function(r, c) {
|
|
328
|
+
return t(r.query, r, c);
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
331
|
function fe(e) {
|
|
332
332
|
const t = S(e);
|
|
333
|
-
return function(
|
|
334
|
-
const i = (
|
|
335
|
-
return t(i,
|
|
333
|
+
return function(r, c) {
|
|
334
|
+
const i = (c.theme?.selector ?? D)({ name: r.name });
|
|
335
|
+
return t(i, r, c);
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
function me(e) {
|
|
339
339
|
const t = S(e);
|
|
340
|
-
return function(
|
|
341
|
-
const a = [], s = (
|
|
342
|
-
name:
|
|
343
|
-
value:
|
|
344
|
-
modifiers:
|
|
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
|
|
345
345
|
});
|
|
346
|
-
return a.push(t(s,
|
|
346
|
+
return a.push(t(s, r, c)), a.join(`
|
|
347
347
|
|
|
348
348
|
`);
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
function p(e, t) {
|
|
352
|
-
const
|
|
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();
|
|
353
353
|
switch (!0) {
|
|
354
354
|
case Y(e):
|
|
355
|
-
return
|
|
355
|
+
return r(e, t);
|
|
356
356
|
case ee(e):
|
|
357
|
-
return
|
|
357
|
+
return c(e, t);
|
|
358
358
|
case X(e):
|
|
359
359
|
return a(e, t);
|
|
360
360
|
case re(e):
|
|
361
|
-
return
|
|
361
|
+
return n(e, t);
|
|
362
362
|
case ne(e):
|
|
363
363
|
return i(e, t);
|
|
364
364
|
case J(e):
|
|
@@ -366,7 +366,7 @@ function p(e, t) {
|
|
|
366
366
|
case G(e):
|
|
367
367
|
return o(e, t);
|
|
368
368
|
case te(e):
|
|
369
|
-
return
|
|
369
|
+
return u(e, t);
|
|
370
370
|
default:
|
|
371
371
|
return f(e, t);
|
|
372
372
|
}
|
|
@@ -374,7 +374,7 @@ function p(e, t) {
|
|
|
374
374
|
function T(e, t) {
|
|
375
375
|
switch (!0) {
|
|
376
376
|
case Array.isArray(e):
|
|
377
|
-
return e.map((
|
|
377
|
+
return e.map((n) => T(n)).join(`
|
|
378
378
|
`);
|
|
379
379
|
// case isRecipe(instance):
|
|
380
380
|
// return consumeRecipe(instance, options);
|
|
@@ -393,10 +393,10 @@ hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
|
393
393
|
GwIDAQAB
|
|
394
394
|
-----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
|
|
395
395
|
async function he(e) {
|
|
396
|
-
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""),
|
|
396
|
+
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), n = Uint8Array.from(atob(t), (r) => r.charCodeAt(0));
|
|
397
397
|
return await crypto.subtle.importKey(
|
|
398
398
|
"spki",
|
|
399
|
-
|
|
399
|
+
n,
|
|
400
400
|
{
|
|
401
401
|
name: "RSASSA-PKCS1-v1_5",
|
|
402
402
|
hash: "SHA-256"
|
|
@@ -409,15 +409,15 @@ async function be({
|
|
|
409
409
|
payload: e,
|
|
410
410
|
signature: t
|
|
411
411
|
}) {
|
|
412
|
-
const
|
|
412
|
+
const n = new TextEncoder().encode(e), r = Uint8Array.from(
|
|
413
413
|
atob(t),
|
|
414
414
|
(a) => a.charCodeAt(0)
|
|
415
|
-
),
|
|
415
|
+
), c = await he(de);
|
|
416
416
|
if (!await crypto.subtle.verify(
|
|
417
417
|
{ name: "RSASSA-PKCS1-v1_5" },
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
418
|
+
c,
|
|
419
|
+
r,
|
|
420
|
+
n
|
|
421
421
|
))
|
|
422
422
|
throw new Error(
|
|
423
423
|
"License validation failed: Invalid signature detected. The license may have been modified or corrupted."
|
|
@@ -439,8 +439,8 @@ async function ge(e) {
|
|
|
439
439
|
environment: "",
|
|
440
440
|
valid: !1
|
|
441
441
|
};
|
|
442
|
-
const
|
|
443
|
-
if (typeof
|
|
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")
|
|
444
444
|
return {
|
|
445
445
|
key: "",
|
|
446
446
|
instanceId: "",
|
|
@@ -449,7 +449,7 @@ async function ge(e) {
|
|
|
449
449
|
};
|
|
450
450
|
try {
|
|
451
451
|
return await be(
|
|
452
|
-
|
|
452
|
+
n
|
|
453
453
|
);
|
|
454
454
|
} catch {
|
|
455
455
|
return {
|
|
@@ -492,23 +492,23 @@ function j(e, t = "") {
|
|
|
492
492
|
}
|
|
493
493
|
async function Ce(e, {
|
|
494
494
|
type: t = "all",
|
|
495
|
-
consumers:
|
|
495
|
+
consumers: n = { css: p, ts: T }
|
|
496
496
|
} = {}) {
|
|
497
|
-
const
|
|
497
|
+
const r = { files: [] }, c = e.options;
|
|
498
498
|
if (Ae(e)) {
|
|
499
499
|
const s = await ge(e);
|
|
500
500
|
(!s.valid || s.instanceId !== e.id) && Se(e);
|
|
501
501
|
}
|
|
502
502
|
const { recipes: a, ...i } = e.root;
|
|
503
503
|
if (t === "all" || t === "css") {
|
|
504
|
-
const s = j("index.css",
|
|
505
|
-
|
|
504
|
+
const s = j("index.css", n.css(i, c));
|
|
505
|
+
r.files.push(s);
|
|
506
506
|
}
|
|
507
507
|
if (t === "all" || t === "ts") {
|
|
508
|
-
const s = j("index.ts",
|
|
509
|
-
|
|
508
|
+
const s = j("index.ts", n.ts([], c));
|
|
509
|
+
r.files.push(s);
|
|
510
510
|
}
|
|
511
|
-
return
|
|
511
|
+
return r;
|
|
512
512
|
}
|
|
513
513
|
export {
|
|
514
514
|
ve as DEFAULT_INDENT,
|
|
@@ -518,7 +518,7 @@ export {
|
|
|
518
518
|
p as consumeCSS,
|
|
519
519
|
T as consumeTS,
|
|
520
520
|
Z as createAtRuleConsumer,
|
|
521
|
-
|
|
521
|
+
ce as createCSSTemplateLiteralConsumer,
|
|
522
522
|
S as createContainerConsumer,
|
|
523
523
|
Q as createDeclarationsConsumer,
|
|
524
524
|
j as createFile,
|
package/dist/transpiler.umd.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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:
|
|
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
2
|
`).map(t=>L(t)).join(`
|
|
3
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
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(r
|
|
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)?`
|
|
6
6
|
|
|
7
7
|
`:""}${b.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(
|
|
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(`
|
|
10
10
|
|
|
11
|
-
`)}}function z(e){const t=S(e);return function(
|
|
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(`
|
|
12
12
|
|
|
13
|
-
`)}}function h(e,t){const
|
|
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
14
|
`);default:return""}}const ye=`-----BEGIN PUBLIC KEY-----
|
|
15
15
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
|
|
16
16
|
qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
|
|
@@ -19,4 +19,4 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
|
19
19
|
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
20
20
|
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
21
21
|
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,""),
|
|
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"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/transpiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/transpiler.d.ts",
|
|
6
6
|
"module": "./dist/transpiler.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@styleframe/license": "^
|
|
22
|
+
"@styleframe/license": "^2.0.0",
|
|
23
23
|
"scule": "^1.3.0",
|
|
24
|
-
"@styleframe/core": "
|
|
24
|
+
"@styleframe/core": "2.0.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@vitest/coverage-v8": "^3.2.4",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"vite": "^7.0.6",
|
|
30
30
|
"vite-plugin-dts": "^4.5.4",
|
|
31
31
|
"vitest": "^3.2.4",
|
|
32
|
-
"@styleframe/config-typescript": "
|
|
33
|
-
"@styleframe/config-vite": "
|
|
32
|
+
"@styleframe/config-typescript": "2.0.3",
|
|
33
|
+
"@styleframe/config-vite": "2.0.3"
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/styleframe-dev/styleframe#readme",
|
|
36
36
|
"bugs": {
|