@styleframe/transpiler 3.0.1 → 3.2.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 +30 -0
- package/dist/transpiler.js +56 -56
- package/dist/transpiler.umd.cjs +13 -13
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @styleframe/transpiler
|
|
2
2
|
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#167](https://github.com/styleframe-dev/styleframe/pull/167) [`179c90d`](https://github.com/styleframe-dev/styleframe/commit/179c90d9f73dadbbeb9159ab9fbd7287ceba1f20) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add boolean support for recipe variant props
|
|
8
|
+
- When a variant defines both `true` and `false` keys, the runtime now accepts boolean `true`/`false` values in addition to string `"true"`/`"false"`
|
|
9
|
+
- Generated `.d.ts` type declarations include `| boolean` in the type union for boolean variants
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`b506ea5`](https://github.com/styleframe-dev/styleframe/commit/b506ea5c3c36fa24fea19a69ee3fef7035397dda), [`efd99f7`](https://github.com/styleframe-dev/styleframe/commit/efd99f70a30f9a42c6e1793ed777b1565fb47a82)]:
|
|
14
|
+
- @styleframe/core@3.3.0
|
|
15
|
+
|
|
16
|
+
## 3.1.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [#155](https://github.com/styleframe-dev/styleframe/pull/155) [`cc4f170`](https://github.com/styleframe-dev/styleframe/commit/cc4f170c56ad2e246b94ab4d64b7f6c3097c7223) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Refactor recipes, improve modifier at-rule support, and forward variables through modifier factories
|
|
21
|
+
- Refactor recipes and utilities with improved color theming composables
|
|
22
|
+
- Add at-rule support for modifiers (e.g. media preference modifiers)
|
|
23
|
+
- Forward variables and children through all modifier factory functions
|
|
24
|
+
- Restructure docs for components, utilities, and modifiers into composable subdirectories
|
|
25
|
+
- Add Button composable recipe documentation
|
|
26
|
+
- Update plugin scanner for improved recipe handling
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`cc4f170`](https://github.com/styleframe-dev/styleframe/commit/cc4f170c56ad2e246b94ab4d64b7f6c3097c7223)]:
|
|
31
|
+
- @styleframe/core@3.2.0
|
|
32
|
+
|
|
3
33
|
## 3.0.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/transpiler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const ke = " ",
|
|
1
|
+
const ke = " ", P = ["charset", "import", "namespace"], I = ["layer"];
|
|
2
2
|
function M(e) {
|
|
3
3
|
return typeof e == "object" && e !== null;
|
|
4
4
|
}
|
|
@@ -41,7 +41,7 @@ const Q = ({
|
|
|
41
41
|
e,
|
|
42
42
|
...t === "default" ? [] : [t]
|
|
43
43
|
].filter(Boolean).join(":")}`;
|
|
44
|
-
function
|
|
44
|
+
function x(e) {
|
|
45
45
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
46
46
|
}
|
|
47
47
|
function J(e) {
|
|
@@ -192,7 +192,7 @@ function G(e, t = 8) {
|
|
|
192
192
|
}
|
|
193
193
|
return e ? `${e}${n}` : n;
|
|
194
194
|
}
|
|
195
|
-
const Y = ({ name: e }) =>
|
|
195
|
+
const Y = ({ name: e }) => `.${e}-theme, [data-theme="${e}"]`, w = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
|
|
196
196
|
function X(e, t) {
|
|
197
197
|
return `@${e}${t ? " " : ""}${t}`;
|
|
198
198
|
}
|
|
@@ -201,7 +201,7 @@ function re(e = "") {
|
|
|
201
201
|
if (!ee.test(e))
|
|
202
202
|
return e !== e.toLowerCase();
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function B(e, t) {
|
|
205
205
|
const r = te, n = [];
|
|
206
206
|
if (!e || typeof e != "string")
|
|
207
207
|
return n;
|
|
@@ -235,13 +235,13 @@ function oe(e) {
|
|
|
235
235
|
return e ? e[0].toLowerCase() + e.slice(1) : "";
|
|
236
236
|
}
|
|
237
237
|
function ue(e, t) {
|
|
238
|
-
return e ? (Array.isArray(e) ? e :
|
|
238
|
+
return e ? (Array.isArray(e) ? e : B(e)).map((r) => ne(r)).join("") : "";
|
|
239
239
|
}
|
|
240
240
|
function ce(e, t) {
|
|
241
241
|
return oe(ue(e || ""));
|
|
242
242
|
}
|
|
243
243
|
function se(e, t) {
|
|
244
|
-
return e ? (Array.isArray(e) ? e :
|
|
244
|
+
return e ? (Array.isArray(e) ? e : B(e)).map((r) => r.toLowerCase()).join("-") : "";
|
|
245
245
|
}
|
|
246
246
|
function ie(e) {
|
|
247
247
|
return ` ${e}`;
|
|
@@ -251,7 +251,7 @@ function ae(e) {
|
|
|
251
251
|
`).map((t) => ie(t)).join(`
|
|
252
252
|
`);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function T(e) {
|
|
255
255
|
return e === e.toUpperCase();
|
|
256
256
|
}
|
|
257
257
|
function E(e) {
|
|
@@ -263,7 +263,7 @@ function le(e) {
|
|
|
263
263
|
function fe(e) {
|
|
264
264
|
return le(e);
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function D(e, t) {
|
|
267
267
|
return `${e.startsWith("--") ? e : fe(e)}: ${t};`;
|
|
268
268
|
}
|
|
269
269
|
function me(e) {
|
|
@@ -271,31 +271,31 @@ function me(e) {
|
|
|
271
271
|
` : ""}${e.map((t) => `${ae(`${t}`)}
|
|
272
272
|
`).join("")}}`;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function F(e) {
|
|
275
275
|
return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
|
|
276
276
|
}
|
|
277
277
|
function pe(e, t) {
|
|
278
|
-
return F(
|
|
278
|
+
return D(F(e), t);
|
|
279
279
|
}
|
|
280
280
|
function de(e, t) {
|
|
281
|
-
return `var(${
|
|
281
|
+
return `var(${F(e)}${t ? `, ${t}` : ""})`;
|
|
282
282
|
}
|
|
283
283
|
function O(e, t) {
|
|
284
284
|
return `${e} ${me(t)}`;
|
|
285
285
|
}
|
|
286
286
|
function ye(e) {
|
|
287
287
|
return function(r, n) {
|
|
288
|
-
return Object.entries(r).map(([o, c]) =>
|
|
288
|
+
return Object.entries(r).map(([o, c]) => D(o, e(c, n)));
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function U(e) {
|
|
292
292
|
return function(r, n) {
|
|
293
|
-
const c = (n.variables?.name ??
|
|
293
|
+
const c = (n.variables?.name ?? w)({ name: r.name });
|
|
294
294
|
return pe(c, e(r.value, n));
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
function C(e) {
|
|
298
|
-
const t =
|
|
298
|
+
const t = U(e), r = ye(e);
|
|
299
299
|
return function(o, c, s) {
|
|
300
300
|
const { variables: a, declarations: u, children: i } = c, f = o === ":root", l = (a ?? []).map(
|
|
301
301
|
(g) => t(g, s)
|
|
@@ -319,7 +319,7 @@ function C(e) {
|
|
|
319
319
|
...m,
|
|
320
320
|
...b && v ? [""] : [],
|
|
321
321
|
...d.flatMap(
|
|
322
|
-
(g,
|
|
322
|
+
(g, L) => L === d.length - 1 ? [g] : [g, ""]
|
|
323
323
|
)
|
|
324
324
|
]);
|
|
325
325
|
};
|
|
@@ -327,7 +327,7 @@ function C(e) {
|
|
|
327
327
|
function he(e) {
|
|
328
328
|
const t = C(e);
|
|
329
329
|
return function(n, o) {
|
|
330
|
-
const c =
|
|
330
|
+
const c = P.includes(n.identifier), s = I.includes(
|
|
331
331
|
n.identifier
|
|
332
332
|
), a = Object.keys(n.declarations).length > 0, u = n.variables.length > 0, i = n.children.length > 0, f = X(n.identifier, n.rule);
|
|
333
333
|
return c || s && !(a || u || i) ? `${f};` : t(f, n, o);
|
|
@@ -345,7 +345,7 @@ function ge(e) {
|
|
|
345
345
|
}
|
|
346
346
|
function Ae(e) {
|
|
347
347
|
return function(r, n) {
|
|
348
|
-
const c = (n.variables?.name ??
|
|
348
|
+
const c = (n.variables?.name ?? w)({ name: r.name });
|
|
349
349
|
return de(
|
|
350
350
|
c,
|
|
351
351
|
r.fallback ? e(r.fallback, n) : void 0
|
|
@@ -377,7 +377,7 @@ function ve(e) {
|
|
|
377
377
|
return t(s, n, o);
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function $e(e) {
|
|
381
381
|
const t = C(e);
|
|
382
382
|
return function(n, o) {
|
|
383
383
|
const c = [], a = (o.utilities?.selector ?? Q)({
|
|
@@ -391,7 +391,7 @@ function je(e) {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
function y(e, t) {
|
|
394
|
-
const r = Se(y), n = Ce(y), o =
|
|
394
|
+
const r = Se(y), n = Ce(y), o = $e(y), c = he(y), s = ve(y), a = U(y), u = Ae(y), i = be(y), f = ge();
|
|
395
395
|
switch (!0) {
|
|
396
396
|
case S(e):
|
|
397
397
|
return n(e, t);
|
|
@@ -413,10 +413,10 @@ function y(e, t) {
|
|
|
413
413
|
return f(e, t);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function je(e) {
|
|
417
417
|
return function(r, n) {
|
|
418
418
|
let o = r._exportName;
|
|
419
|
-
o || (o = E(r.name), r.name[0] &&
|
|
419
|
+
o || (o = E(r.name), r.name[0] && T(r.name[0]) && (o = x(o)));
|
|
420
420
|
const c = `${o}Recipe`, s = r._runtime ?? {};
|
|
421
421
|
return `const ${c} = ${JSON.stringify(
|
|
422
422
|
s,
|
|
@@ -451,11 +451,11 @@ function Oe(e) {
|
|
|
451
451
|
` : "";
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
const r = Ne(
|
|
454
|
+
function j(e, t) {
|
|
455
|
+
const r = Ne(j), n = je(), o = Oe();
|
|
456
456
|
switch (!0) {
|
|
457
457
|
case Array.isArray(e):
|
|
458
|
-
return e.map((c) =>
|
|
458
|
+
return e.map((c) => j(c, t)).join(`
|
|
459
459
|
`);
|
|
460
460
|
case N(e):
|
|
461
461
|
return r(e, t);
|
|
@@ -475,8 +475,8 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
|
475
475
|
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
476
476
|
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
477
477
|
GwIDAQAB
|
|
478
|
-
-----END PUBLIC KEY-----`,
|
|
479
|
-
async function
|
|
478
|
+
-----END PUBLIC KEY-----`, xe = "__licenseRequired", we = "__licenseValidated";
|
|
479
|
+
async function Be(e) {
|
|
480
480
|
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
|
|
481
481
|
return await crypto.subtle.importKey(
|
|
482
482
|
"spki",
|
|
@@ -489,14 +489,14 @@ async function Te(e) {
|
|
|
489
489
|
["verify"]
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
|
-
async function
|
|
492
|
+
async function Te({
|
|
493
493
|
payload: e,
|
|
494
494
|
signature: t
|
|
495
495
|
}) {
|
|
496
496
|
const r = new TextEncoder().encode(e), n = Uint8Array.from(
|
|
497
497
|
atob(t),
|
|
498
498
|
(c) => c.charCodeAt(0)
|
|
499
|
-
), o = await
|
|
499
|
+
), o = await Be(_e);
|
|
500
500
|
if (!await crypto.subtle.verify(
|
|
501
501
|
{ name: "RSASSA-PKCS1-v1_5" },
|
|
502
502
|
o,
|
|
@@ -509,12 +509,12 @@ async function Be({
|
|
|
509
509
|
return JSON.parse(e);
|
|
510
510
|
}
|
|
511
511
|
function Ee(e) {
|
|
512
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
512
|
+
return Object.prototype.hasOwnProperty.call(e, xe);
|
|
513
513
|
}
|
|
514
|
-
async function
|
|
514
|
+
async function De(e) {
|
|
515
515
|
const t = Object.getOwnPropertyDescriptor(
|
|
516
516
|
e,
|
|
517
|
-
|
|
517
|
+
we
|
|
518
518
|
);
|
|
519
519
|
if (!t?.value)
|
|
520
520
|
return {
|
|
@@ -532,7 +532,7 @@ async function Fe(e) {
|
|
|
532
532
|
valid: !1
|
|
533
533
|
};
|
|
534
534
|
try {
|
|
535
|
-
return await
|
|
535
|
+
return await Te(
|
|
536
536
|
r
|
|
537
537
|
);
|
|
538
538
|
} catch {
|
|
@@ -544,7 +544,7 @@ async function Fe(e) {
|
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function Fe(e) {
|
|
548
548
|
const t = e?.variants;
|
|
549
549
|
if (!t || Object.keys(t).length === 0)
|
|
550
550
|
return "Record<string, never>";
|
|
@@ -553,28 +553,28 @@ function De(e) {
|
|
|
553
553
|
if (!o) continue;
|
|
554
554
|
const c = Object.keys(o);
|
|
555
555
|
if (c.length > 0) {
|
|
556
|
-
const s = c.map((
|
|
557
|
-
r.push(`${n}?: ${
|
|
556
|
+
const s = c.map((i) => `"${i}"`).join(" | "), u = c.includes("true") && c.includes("false") ? `${s} | boolean` : s;
|
|
557
|
+
r.push(`${n}?: ${u}`);
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
return r.length === 0 ? "Record<string, never>" : `{ ${r.join("; ")} }`;
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function Ue(e) {
|
|
563
563
|
return function(r, n) {
|
|
564
564
|
let o = r._exportName;
|
|
565
|
-
o || (o = E(r.name), r.name[0] &&
|
|
566
|
-
const c =
|
|
565
|
+
o || (o = E(r.name), r.name[0] && T(r.name[0]) && (o = x(o)));
|
|
566
|
+
const c = Fe(r._runtime);
|
|
567
567
|
return ` export const ${o}: (props?: ${c}) => string;`;
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function Le(e) {
|
|
571
571
|
return e.filter(
|
|
572
572
|
(t) => S(t) && !!t._exportName
|
|
573
573
|
);
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function Pe(e) {
|
|
576
576
|
return function(r, n) {
|
|
577
|
-
const o =
|
|
577
|
+
const o = Le(r.children), c = r.recipes.length > 0, s = o.length > 0, a = [
|
|
578
578
|
"// Auto-generated by @styleframe/plugin - DO NOT EDIT",
|
|
579
579
|
"",
|
|
580
580
|
'declare module "virtual:styleframe" {',
|
|
@@ -597,13 +597,13 @@ function Ie(e) {
|
|
|
597
597
|
`);
|
|
598
598
|
};
|
|
599
599
|
}
|
|
600
|
-
function
|
|
600
|
+
function Ie(e) {
|
|
601
601
|
return function(r, n) {
|
|
602
602
|
return r._exportName ? ` export const ${r._exportName}: string;` : "";
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
function R(e, t) {
|
|
606
|
-
const r =
|
|
606
|
+
const r = Pe(R), n = Ue(), o = Ie();
|
|
607
607
|
switch (!0) {
|
|
608
608
|
case Array.isArray(e):
|
|
609
609
|
return e.map((c) => R(c, t)).join(`
|
|
@@ -643,7 +643,7 @@ function Me(e) {
|
|
|
643
643
|
}
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function $(e, t = "") {
|
|
647
647
|
return {
|
|
648
648
|
name: e,
|
|
649
649
|
content: t
|
|
@@ -651,29 +651,29 @@ function j(e, t = "") {
|
|
|
651
651
|
}
|
|
652
652
|
async function Ve(e, {
|
|
653
653
|
type: t = "all",
|
|
654
|
-
consumers: r = { css: y, ts:
|
|
654
|
+
consumers: r = { css: y, ts: j, dts: R }
|
|
655
655
|
} = {}) {
|
|
656
656
|
const n = { files: [] }, o = e.options;
|
|
657
657
|
if (Ee(e)) {
|
|
658
|
-
const c = await
|
|
658
|
+
const c = await De(e);
|
|
659
659
|
(!c.valid || c.instanceId !== e.id) && Me(e);
|
|
660
660
|
}
|
|
661
661
|
if (t === "all" || t === "css") {
|
|
662
|
-
const c =
|
|
662
|
+
const c = $(
|
|
663
663
|
"index.css",
|
|
664
664
|
r.css(e.root, o)
|
|
665
665
|
);
|
|
666
666
|
n.files.push(c);
|
|
667
667
|
}
|
|
668
668
|
if (t === "all" || t === "ts") {
|
|
669
|
-
const c =
|
|
669
|
+
const c = $(
|
|
670
670
|
"index.ts",
|
|
671
671
|
r.ts(e.root, o)
|
|
672
672
|
);
|
|
673
673
|
n.files.push(c);
|
|
674
674
|
}
|
|
675
675
|
if (t === "dts") {
|
|
676
|
-
const c =
|
|
676
|
+
const c = $(
|
|
677
677
|
"index.d.ts",
|
|
678
678
|
r.dts(e.root, o)
|
|
679
679
|
);
|
|
@@ -683,17 +683,17 @@ async function Ve(e, {
|
|
|
683
683
|
}
|
|
684
684
|
export {
|
|
685
685
|
ke as DEFAULT_INDENT,
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
P as STATEMENT_AT_RULES,
|
|
687
|
+
I as STATEMENT_OR_BLOCK_AT_RULES,
|
|
688
688
|
ie as addIndentToLine,
|
|
689
689
|
y as consumeCSS,
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
j as consumeTS,
|
|
691
|
+
$ as createFile,
|
|
692
692
|
Y as defaultThemeSelectorFn,
|
|
693
693
|
Q as defaultUtilitySelectorFn,
|
|
694
|
-
|
|
694
|
+
w as defaultVariableNameFn,
|
|
695
695
|
ae as indentLines,
|
|
696
|
-
|
|
696
|
+
T as isUppercase,
|
|
697
697
|
E as toCamelCase,
|
|
698
698
|
le as toKebabCase,
|
|
699
699
|
Ve as transpile
|
package/dist/transpiler.umd.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
(function(p,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(p=typeof globalThis<"u"?globalThis:p||self,j(p.transpiler={}))})(this,(function(p){"use strict";const
|
|
2
|
-
`).map(t=>
|
|
3
|
-
`)}function _(e){return e===e.toUpperCase()}function
|
|
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 B=["charset","import","namespace"],F=["layer"];function H(e){return typeof e=="object"&&e!==null}function b(e,t){return H(e)&&"type"in e&&e.type===t}function Q(e){return b(e,"variable")}function J(e){return b(e,"reference")}function C(e){return b(e,"selector")}function Z(e){return b(e,"at-rule")}function W(e){return b(e,"utility")}function G(e){return b(e,"css")}function Y(e){return b(e,"theme")}function T(e){return b(e,"root")}function D(e){return b(e,"recipe")}const L=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`;function U(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}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 ee(e){if(e=e||{},e.circular)return te(e);const t=new Map;if(t.set(Date,s=>new Date(s)),t.set(Map,(s,a)=>new Map(n(Array.from(s),a))),t.set(Set,(s,a)=>new Set(n(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)t.set(s[0],s[1]);let r;return e.proto?c:o;function n(s,a){const u=Object.keys(s),i=Array.from({length:u.length});for(let f=0;f<u.length;f++){const l=u[f],m=s[l];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)}return i}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,o);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,o);const a={};for(const u in s){if(Object.hasOwnProperty.call(s,u)===!1)continue;const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,o):ArrayBuffer.isView(i)?a[u]=A(i):a[u]=o(i)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,c);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,c);const a={};for(const u in s){const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,c):ArrayBuffer.isView(i)?a[u]=A(i):a[u]=c(i)}return a}}function te(e){const t=[],r=[],n=new Map;if(n.set(Date,u=>new Date(u)),n.set(Map,(u,i)=>new Map(c(Array.from(u),i))),n.set(Set,(u,i)=>new Set(c(Array.from(u),i))),e.constructorHandlers)for(const u of e.constructorHandlers)n.set(u[0],u[1]);let o;return e.proto?a:s;function c(u,i){const f=Object.keys(u),l=Array.from({length:f.length});for(let m=0;m<f.length;m++){const y=f[m],d=u[y];if(typeof d!="object"||d===null)l[y]=d;else if(d.constructor!==Object&&(o=n.get(d.constructor)))l[y]=o(d,i);else if(ArrayBuffer.isView(d))l[y]=A(d);else{const g=t.indexOf(d);g!==-1?l[y]=r[g]:l[y]=i(d)}}return l}function s(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,s);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,s);const i={};t.push(u),r.push(i);for(const f in u){if(Object.hasOwnProperty.call(u,f)===!1)continue;const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,s);else if(ArrayBuffer.isView(l))i[f]=A(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=s(l)}}return t.pop(),r.pop(),i}function a(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,a);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,a);const i={};t.push(u),r.push(i);for(const f in u){const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,a);else if(ArrayBuffer.isView(l))i[f]=A(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=a(l)}}return t.pop(),r.pop(),i}}ee();function re(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let o=0;o<t;o++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}const I=({name:e})=>`.${e}-theme, [data-theme="${e}"]`,N=({name:e})=>e.replace(/^\.+|\.+$/g,"").replace(/\.+/g,"--");function ne(e,t){return`@${e}${t?" ":""}${t}`}const oe=/\d/,ue=["-","_","/","."];function ce(e=""){if(!oe.test(e))return e!==e.toLowerCase()}function P(e,t){const r=ue,n=[];if(!e||typeof e!="string")return n;let o="",c,s;for(const a of e){const u=r.includes(a);if(u===!0){n.push(o),o="",c=void 0;continue}const i=ce(a);if(s===!1){if(c===!1&&i===!0){n.push(o),o=a,c=i;continue}if(c===!0&&i===!1&&o.length>1){const f=o.at(-1);n.push(o.slice(0,Math.max(0,o.length-1))),o=f+a,c=i;continue}}o+=a,c=i,s=u}return n.push(o),n}function se(e){return e?e[0].toUpperCase()+e.slice(1):""}function ie(e){return e?e[0].toLowerCase()+e.slice(1):""}function ae(e,t){return e?(Array.isArray(e)?e:P(e)).map(r=>se(r)).join(""):""}function le(e,t){return ie(ae(e||""))}function fe(e,t){return e?(Array.isArray(e)?e:P(e)).map(r=>r.toLowerCase()).join("-"):""}function M(e){return` ${e}`}function x(e){return e.split(`
|
|
2
|
+
`).map(t=>M(t)).join(`
|
|
3
|
+
`)}function _(e){return e===e.toUpperCase()}function O(e){return le(e)}function k(e){return fe(e)}function me(e){return k(e)}function V(e,t){return`${e.startsWith("--")?e:me(e)}: ${t};`}function pe(e){return`{${e.length>0?`
|
|
4
4
|
`:""}${e.map(t=>`${x(`${t}`)}
|
|
5
|
-
`).join("")}}`}function K(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function de(e,t){return V(K(e),t)}function ye(e,t){return`var(${K(e)}${t?`, ${t}`:""})`}function q(e,t){return`${e} ${pe(t)}`}function he(e){return function(r,n){return Object.entries(r).map(([o,c])=>V(o,e(c,n)))}}function z(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return de(c,e(r.value,n))}}function v(e){const t=z(e),r=he(e);return function(o,c,s){const{variables:a,declarations:u,children:i}=c,f=o===":root",l=(a??[]).map(
|
|
5
|
+
`).join("")}}`}function K(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function de(e,t){return V(K(e),t)}function ye(e,t){return`var(${K(e)}${t?`, ${t}`:""})`}function q(e,t){return`${e} ${pe(t)}`}function he(e){return function(r,n){return Object.entries(r).map(([o,c])=>V(o,e(c,n)))}}function z(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return de(c,e(r.value,n))}}function v(e){const t=z(e),r=he(e);return function(o,c,s){const{variables:a,declarations:u,children:i}=c,f=o===":root",l=(a??[]).map(S=>t(S,s)),m=r(u??{},s),y=(i??[]).map(S=>e(S,s)),d=l.length>0,g=m.length>0,w=y.length>0;return f?`${d||g?q(o,[...l,...d&&g?[""]:[],...m]):""}${w&&(d||g)?`
|
|
6
6
|
|
|
7
7
|
`:""}${y.join(`
|
|
8
8
|
|
|
9
|
-
`)}`:q(o,[...l,...d&&(w||g)?[""]:[],...m,...g&&w?[""]:[],...y.flatMap((
|
|
9
|
+
`)}`:q(o,[...l,...d&&(w||g)?[""]:[],...m,...g&&w?[""]:[],...y.flatMap((S,Ke)=>Ke===y.length-1?[S]:[S,""])])}}function be(e){const t=v(e);return function(n,o){const c=B.includes(n.identifier),s=F.includes(n.identifier),a=Object.keys(n.declarations).length>0,u=n.variables.length>0,i=n.children.length>0,f=ne(n.identifier,n.rule);return c||s&&!(a||u||i)?`${f};`:t(f,n,o)}}function ge(e){return function(r,n){return r.value.map(o=>e(o,n)).join("").trim()}}function Ae(e){return function(r,n){return r!=null?`${r}`:""}}function Se(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return ye(c,r.fallback?e(r.fallback,n):void 0)}}function Ce(e){const t=v(e);return function(n,o){return n.themes.reduce((c,s)=>(c.push(e(s,o)),c),[t(":root",n,o)]).join(`
|
|
10
10
|
|
|
11
|
-
`)}}function ve(e){const t=v(e);return function(n,o){return t(n.query,n,o)}}function je(e){const t=v(e);return function(n,o){const s=(o.themes?.selector??I)({name:n.name});return t(s,n,o)}}function
|
|
11
|
+
`)}}function ve(e){const t=v(e);return function(n,o){return t(n.query,n,o)}}function je(e){const t=v(e);return function(n,o){const s=(o.themes?.selector??I)({name:n.name});return t(s,n,o)}}function $e(e){const t=v(e);return function(n,o){const c=[],a=(o.utilities?.selector??L)({name:n.name,value:n.value,modifiers:n.modifiers}),u=X(a);return c.push(t(u,n,o)),c.join(`
|
|
12
12
|
|
|
13
|
-
`)}}function h(e,t){const r=Ce(h),n=ve(h),o
|
|
13
|
+
`)}}function h(e,t){const r=Ce(h),n=ve(h),o=$e(h),c=be(h),s=je(h),a=z(h),u=Se(h),i=ge(h),f=Ae();switch(!0){case C(e):return n(e,t);case W(e):return o(e,t);case Z(e):return c(e,t);case T(e):return r(e,t);case Y(e):return s(e,t);case Q(e):return a(e,t);case J(e):return u(e,t);case G(e):return i(e,t);default:return f(e,t)}}function Re(e){return function(r,n){let o=r._exportName;o||(o=O(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=`${o}Recipe`,s=r._runtime??{};return`const ${c} = ${JSON.stringify(s,null,4)} as const satisfies RecipeRuntime;
|
|
14
14
|
|
|
15
15
|
export const ${o} = createRecipe("${r.name}", ${c});
|
|
16
|
-
`}}function
|
|
16
|
+
`}}function Te(e){return e.filter(t=>C(t)&&!!t._exportName)}function Ne(e){return function(r,n){const o=Te(r.children),c=r.recipes.length>0,s=o.length>0;if(!c&&!s)return"";const a=[];return c&&(a.push(`import { createRecipe } from '@styleframe/runtime';
|
|
17
17
|
import type { RecipeRuntime } from '@styleframe/runtime';
|
|
18
18
|
`),a.push(e(r.recipes,n))),s&&a.push(e(o,n)),a.join(`
|
|
19
19
|
`)}}function _e(e){return function(r,n){return r._exportName?`export const ${r._exportName} = ${JSON.stringify(r.query)};
|
|
20
|
-
`:""}}function
|
|
21
|
-
`);case
|
|
20
|
+
`:""}}function $(e,t){const r=Ne($),n=Re(),o=_e();switch(!0){case Array.isArray(e):return e.map(c=>$(c,t)).join(`
|
|
21
|
+
`);case T(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}const Oe=`-----BEGIN PUBLIC KEY-----
|
|
22
22
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
|
|
23
23
|
qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
|
|
24
24
|
BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
|
|
@@ -26,6 +26,6 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
|
26
26
|
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
27
27
|
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
28
28
|
GwIDAQAB
|
|
29
|
-
-----END PUBLIC KEY-----`,
|
|
30
|
-
`)}}function xe(e){return function(r,n){return r._exportName?` export const ${r._exportName}: string;`:""}}function
|
|
31
|
-
`);case
|
|
29
|
+
-----END PUBLIC KEY-----`,Ee="__licenseRequired",we="__licenseValidated";async function Be(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=Uint8Array.from(atob(t),n=>n.charCodeAt(0));return await crypto.subtle.importKey("spki",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function Fe({payload:e,signature:t}){const r=new TextEncoder().encode(e),n=Uint8Array.from(atob(t),c=>c.charCodeAt(0)),o=await Be(Oe);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,n,r))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function De(e){return Object.prototype.hasOwnProperty.call(e,Ee)}async function Le(e){const t=Object.getOwnPropertyDescriptor(e,we);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 Fe(r)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function Ue(e){const t=e?.variants;if(!t||Object.keys(t).length===0)return"Record<string, never>";const r=[];for(const[n,o]of Object.entries(t)){if(!o)continue;const c=Object.keys(o);if(c.length>0){const s=c.map(i=>`"${i}"`).join(" | "),u=c.includes("true")&&c.includes("false")?`${s} | boolean`:s;r.push(`${n}?: ${u}`)}}return r.length===0?"Record<string, never>":`{ ${r.join("; ")} }`}function Ie(e){return function(r,n){let o=r._exportName;o||(o=O(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=Ue(r._runtime);return` export const ${o}: (props?: ${c}) => string;`}}function Pe(e){return e.filter(t=>C(t)&&!!t._exportName)}function Me(e){return function(r,n){const o=Pe(r.children),c=r.recipes.length>0,s=o.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(c){a.push("");const u=r.recipes.map(i=>e(i,n)).filter(Boolean);a.push(...u)}if(s){a.push("");const u=o.map(i=>e(i,n)).filter(Boolean);a.push(...u)}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 xe(e){return function(r,n){return r._exportName?` export const ${r._exportName}: string;`:""}}function E(e,t){const r=Me(E),n=Ie(),o=xe();switch(!0){case Array.isArray(e):return e.map(c=>E(c,t)).join(`
|
|
31
|
+
`);case T(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}function ke(e){const t=Math.floor(Math.random()*100);e.root.children.push({type:"selector",id:re("sel-"),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 Ve(e,{type:t="all",consumers:r={css:h,ts:$,dts:E}}={}){const n={files:[]},o=e.options;if(De(e)){const c=await Le(e);(!c.valid||c.instanceId!==e.id)&&ke(e)}if(t==="all"||t==="css"){const c=R("index.css",r.css(e.root,o));n.files.push(c)}if(t==="all"||t==="ts"){const c=R("index.ts",r.ts(e.root,o));n.files.push(c)}if(t==="dts"){const c=R("index.d.ts",r.dts(e.root,o));n.files.push(c)}return n}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=B,p.STATEMENT_OR_BLOCK_AT_RULES=F,p.addIndentToLine=M,p.consumeCSS=h,p.consumeTS=$,p.createFile=R,p.defaultThemeSelectorFn=I,p.defaultUtilitySelectorFn=L,p.defaultVariableNameFn=N,p.indentLines=x,p.isUppercase=_,p.toCamelCase=O,p.toKebabCase=k,p.transpile=Ve,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.0
|
|
3
|
+
"version": "3.2.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": "^3.
|
|
25
|
+
"@styleframe/core": "^3.3.0",
|
|
26
26
|
"@styleframe/license": "^2.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@styleframe/config-typescript": "^3.0.0",
|
|
30
30
|
"@styleframe/config-vite": "^3.0.0",
|
|
31
|
-
"@styleframe/core": "^3.
|
|
31
|
+
"@styleframe/core": "^3.3.0",
|
|
32
32
|
"@styleframe/license": "^2.0.2",
|
|
33
33
|
"@vitest/coverage-v8": "^3.2.4",
|
|
34
34
|
"typescript": "^5.8.3",
|