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