@styleframe/core 2.6.0 → 3.0.1
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 +19 -0
- package/dist/styleframe.d.ts +21 -1
- package/dist/styleframe.js +409 -321
- package/dist/styleframe.umd.cjs +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @styleframe/core
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#120](https://github.com/styleframe-dev/styleframe/pull/120) [`fa48802`](https://github.com/styleframe-dev/styleframe/commit/fa488027d32956e20fa26dc92ee1a3b3583671ad) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add hash-based utility class names for arbitrary CSS values containing whitespace. Values like `transition: 'all 0.3s ease'` now produce valid CSS class names using a deterministic hash (e.g., `_transition:2f7a3b1`) instead of invalid bracket notation with spaces.
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#117](https://github.com/styleframe-dev/styleframe/pull/117) [`ffe6764`](https://github.com/styleframe-dev/styleframe/commit/ffe6764a2e6c84d5b3cfdf431bf11f17a3f3f118) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Introduce global Styleframe single-instance architecture. Extension files (`*.styleframe.ts`) now share the same instance created in `styleframe.config.ts` instead of creating independent instances. This is a breaking change that affects how styles are imported and composed across files.
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#81](https://github.com/styleframe-dev/styleframe/pull/81) [`266f961`](https://github.com/styleframe-dev/styleframe/commit/266f96143e9ffb47e0e6326d0e5e7cc9d974ab83) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add @-prefixed string reference shorthand and fix keyframes object API
|
|
18
|
+
- Add `@`-prefixed string reference shorthand for inline token references in declarations (e.g., `"@color.primary"`)
|
|
19
|
+
- Fix keyframes object API outputting `[object Object]` by parsing percentage, `from`, and `to` keys as nested selectors
|
|
20
|
+
- Prevent namespace double-prepending for `@`-prefixed values in utilities and defaults
|
|
21
|
+
|
|
3
22
|
## 2.6.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/styleframe.d.ts
CHANGED
|
@@ -222,6 +222,7 @@ export declare function createThemeFunction(_parent: Container, root: Root): (na
|
|
|
222
222
|
|
|
223
223
|
export declare function createUtilityFunction(parent: Container, root: Root): <Name extends string>(name: Name, factory: UtilityCallbackFn, options?: {
|
|
224
224
|
autogenerate?: UtilityAutogenerateFn;
|
|
225
|
+
namespace?: string | string[];
|
|
225
226
|
}) => UtilityCreatorFn;
|
|
226
227
|
|
|
227
228
|
export declare function createVariableFunction(parent: Container, _root: Root): <Name extends string>(nameOrInstance: Name | Variable<Name>, value: TokenValue, options?: {
|
|
@@ -281,6 +282,15 @@ export declare function getUtility(root: Root, name: string): UtilityFactory;
|
|
|
281
282
|
|
|
282
283
|
export declare function getVariable(root: Container, name: string): Variable;
|
|
283
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Generates a deterministic, CSS-safe hash string from an arbitrary value.
|
|
287
|
+
* Uses DJB2 algorithm for fast, low-collision hashing.
|
|
288
|
+
*
|
|
289
|
+
* @param value - The string value to hash
|
|
290
|
+
* @returns A lowercase hex string of 7 characters (e.g., "a1b2c3d")
|
|
291
|
+
*/
|
|
292
|
+
export declare function hashValue(value: string): string;
|
|
293
|
+
|
|
284
294
|
export declare function isAtRule(value: unknown): value is AtRule;
|
|
285
295
|
|
|
286
296
|
export declare function isContainer(value: unknown): value is Container;
|
|
@@ -301,6 +311,8 @@ export declare function isRoot(value: unknown): value is Root;
|
|
|
301
311
|
|
|
302
312
|
export declare function isSelector(value: unknown): value is Selector;
|
|
303
313
|
|
|
314
|
+
export declare function isStyleframe(value: unknown): value is Styleframe;
|
|
315
|
+
|
|
304
316
|
export declare function isTheme(value: unknown): value is Theme;
|
|
305
317
|
|
|
306
318
|
/**
|
|
@@ -499,7 +511,14 @@ export declare type TokenType = Variable["type"] | Reference["type"] | Selector[
|
|
|
499
511
|
|
|
500
512
|
export declare type TokenValue = PrimitiveTokenValue | Reference | CSS_2 | Array<PrimitiveTokenValue | Reference | CSS_2>;
|
|
501
513
|
|
|
502
|
-
export declare function transformUtilityKey(
|
|
514
|
+
export declare function transformUtilityKey(replacerOrOptions?: ((key: string) => string) | TransformUtilityKeyOptions): (value: TokenValue) => Record<string, TokenValue>;
|
|
515
|
+
|
|
516
|
+
export declare interface TransformUtilityKeyOptions {
|
|
517
|
+
/** Transforms the key used in the utility class name */
|
|
518
|
+
replacer?: (key: string) => string;
|
|
519
|
+
/** Namespace prepended to the reference name (e.g., "spacing" makes "@sm" resolve to ref("spacing.sm")) */
|
|
520
|
+
namespace?: string | string[];
|
|
521
|
+
}
|
|
503
522
|
|
|
504
523
|
export declare type Utility<Name extends string = string> = {
|
|
505
524
|
type: "utility";
|
|
@@ -529,6 +548,7 @@ export declare type UtilityFactory<Name extends string = string> = {
|
|
|
529
548
|
modifiers: string[];
|
|
530
549
|
}>;
|
|
531
550
|
autogenerate: UtilityAutogenerateFn;
|
|
551
|
+
namespace?: string | string[];
|
|
532
552
|
create: UtilityCreatorFn;
|
|
533
553
|
};
|
|
534
554
|
|
package/dist/styleframe.js
CHANGED
|
@@ -1,99 +1,123 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(e) {
|
|
2
2
|
return typeof e == "object" && e !== null;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function h(e, r) {
|
|
5
|
+
return C(e) && "type" in e && e.type === r;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function G(e) {
|
|
8
|
+
return h(e, "variable");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function j(e) {
|
|
11
|
+
return h(e, "reference");
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function je(e) {
|
|
14
|
+
return h(e, "selector");
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function ve(e) {
|
|
17
|
+
return h(e, "at-rule");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function we(e) {
|
|
20
|
+
return h(e, "utility");
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
22
|
+
function I(e) {
|
|
23
|
+
return h(e, "modifier");
|
|
24
24
|
}
|
|
25
25
|
function E(e) {
|
|
26
|
-
return
|
|
26
|
+
return h(e, "css");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function ke(e) {
|
|
29
|
+
return h(e, "theme");
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function V(e) {
|
|
32
|
+
return h(e, "root");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function Ve(e) {
|
|
35
|
+
return h(e, "recipe");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function z(e) {
|
|
38
38
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
40
|
+
function D(e) {
|
|
41
|
+
return z(e) || j(e) || E(e) || Array.isArray(e) && e.every(D);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
function
|
|
47
|
-
return (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
function Y(e) {
|
|
44
|
+
return C(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
45
|
+
}
|
|
46
|
+
function Re(e) {
|
|
47
|
+
return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
|
|
48
|
+
}
|
|
49
|
+
function Z(e) {
|
|
50
|
+
let r = 5381;
|
|
51
|
+
for (let n = 0; n < e.length; n++)
|
|
52
|
+
r = (r << 5) + r + e.charCodeAt(n) & 4294967295;
|
|
53
|
+
return (r >>> 0).toString(16).padStart(7, "0").slice(0, 7);
|
|
54
|
+
}
|
|
55
|
+
function P(e) {
|
|
56
|
+
const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
|
|
57
|
+
return (c) => {
|
|
58
|
+
let s = c, a;
|
|
59
|
+
if (typeof s == "string" && s[0] === "@") {
|
|
60
|
+
const o = s.slice(1), f = i.find(
|
|
61
|
+
(y) => o === y || o.startsWith(`${y}.`)
|
|
62
|
+
);
|
|
63
|
+
let l, u;
|
|
64
|
+
f ? (l = o, u = o.startsWith(`${f}.`) ? o.slice(f.length + 1) : o) : i.length > 0 ? (l = `${i[0]}.${o}`, u = o) : (l = o, u = o), a = n(u), s = {
|
|
52
65
|
type: "reference",
|
|
53
|
-
name:
|
|
66
|
+
name: l
|
|
54
67
|
};
|
|
55
|
-
} else
|
|
68
|
+
} else if (j(s)) {
|
|
69
|
+
let o = s.name;
|
|
70
|
+
for (const f of i)
|
|
71
|
+
if (o.startsWith(`${f}.`)) {
|
|
72
|
+
o = o.slice(f.length + 1);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
a = n(o);
|
|
76
|
+
} else {
|
|
77
|
+
const o = String(c).trim();
|
|
78
|
+
/\s/.test(o) ? a = Z(o) : a = `[${o}]`;
|
|
79
|
+
}
|
|
56
80
|
return {
|
|
57
|
-
[
|
|
81
|
+
[a]: s
|
|
58
82
|
};
|
|
59
83
|
};
|
|
60
84
|
}
|
|
61
|
-
function
|
|
85
|
+
function J(e, r) {
|
|
62
86
|
return function(t, ...i) {
|
|
63
87
|
return {
|
|
64
88
|
type: "css",
|
|
65
|
-
value: t.reduce((
|
|
89
|
+
value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
|
|
66
90
|
};
|
|
67
91
|
};
|
|
68
92
|
}
|
|
69
|
-
function
|
|
93
|
+
function K(e, r) {
|
|
70
94
|
return function(t, i, c) {
|
|
71
|
-
const
|
|
95
|
+
const s = {
|
|
72
96
|
type: "at-rule",
|
|
73
97
|
identifier: t,
|
|
74
98
|
rule: i,
|
|
75
99
|
declarations: {},
|
|
76
100
|
variables: [],
|
|
77
101
|
children: []
|
|
78
|
-
},
|
|
79
|
-
return typeof c == "function" ?
|
|
102
|
+
}, a = v(s, r);
|
|
103
|
+
return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
|
|
80
104
|
};
|
|
81
105
|
}
|
|
82
|
-
function
|
|
83
|
-
const n =
|
|
106
|
+
function Q(e, r) {
|
|
107
|
+
const n = K(e, r);
|
|
84
108
|
return function(i, c) {
|
|
85
109
|
return n("media", i, c);
|
|
86
110
|
};
|
|
87
111
|
}
|
|
88
|
-
function
|
|
89
|
-
const n =
|
|
112
|
+
function X(e, r) {
|
|
113
|
+
const n = K(e, r);
|
|
90
114
|
return function(i, c) {
|
|
91
115
|
return n("keyframes", i, c);
|
|
92
116
|
};
|
|
93
117
|
}
|
|
94
|
-
function
|
|
118
|
+
function ee(e, r) {
|
|
95
119
|
return function(t, i) {
|
|
96
|
-
return
|
|
120
|
+
return G(t) ? {
|
|
97
121
|
type: "reference",
|
|
98
122
|
name: t.name,
|
|
99
123
|
fallback: i
|
|
@@ -104,7 +128,7 @@ function J(e, r) {
|
|
|
104
128
|
};
|
|
105
129
|
};
|
|
106
130
|
}
|
|
107
|
-
function
|
|
131
|
+
function te(e, r) {
|
|
108
132
|
return function(t, i) {
|
|
109
133
|
const c = {
|
|
110
134
|
type: "selector",
|
|
@@ -112,59 +136,63 @@ function Q(e, r) {
|
|
|
112
136
|
declarations: {},
|
|
113
137
|
variables: [],
|
|
114
138
|
children: []
|
|
115
|
-
},
|
|
116
|
-
return typeof i == "function" ? c.declarations = i(
|
|
139
|
+
}, s = v(c, r);
|
|
140
|
+
return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
|
|
117
141
|
};
|
|
118
142
|
}
|
|
119
|
-
function
|
|
143
|
+
function ne(e, r) {
|
|
120
144
|
return function(t, i, c = {
|
|
121
145
|
default: !1
|
|
122
146
|
}) {
|
|
123
|
-
const
|
|
124
|
-
(f) => f.name ===
|
|
147
|
+
const s = typeof t == "string" ? t : t.name, a = e.variables.find(
|
|
148
|
+
(f) => f.name === s
|
|
125
149
|
);
|
|
126
|
-
if (c.default &&
|
|
127
|
-
return
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
130
|
-
const
|
|
150
|
+
if (c.default && a)
|
|
151
|
+
return a;
|
|
152
|
+
if (a)
|
|
153
|
+
return a.value = i, a;
|
|
154
|
+
const o = {
|
|
131
155
|
type: "variable",
|
|
132
|
-
name:
|
|
156
|
+
name: s,
|
|
133
157
|
value: i
|
|
134
158
|
};
|
|
135
|
-
return e.variables.push(
|
|
159
|
+
return e.variables.push(o), o;
|
|
136
160
|
};
|
|
137
161
|
}
|
|
138
162
|
function v(e, r) {
|
|
139
|
-
const n =
|
|
163
|
+
const n = ne(e), t = te(e, r), i = K(e, r), c = X(r, r), s = Q(e, r), a = ee(), o = J();
|
|
140
164
|
return {
|
|
141
165
|
variable: n,
|
|
142
166
|
selector: t,
|
|
143
167
|
keyframes: c,
|
|
144
168
|
atRule: i,
|
|
145
|
-
media:
|
|
146
|
-
ref:
|
|
147
|
-
css:
|
|
169
|
+
media: s,
|
|
170
|
+
ref: a,
|
|
171
|
+
css: o
|
|
148
172
|
};
|
|
149
173
|
}
|
|
150
|
-
function
|
|
174
|
+
function R(e, r) {
|
|
151
175
|
for (const n in e)
|
|
152
176
|
if (n.startsWith("@")) {
|
|
153
177
|
const t = e[n];
|
|
154
|
-
if (typeof t == "object" && t !== null &&
|
|
178
|
+
if (typeof t == "object" && t !== null && !D(t)) {
|
|
155
179
|
const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
|
|
156
180
|
r.atRule(i, c, t), delete e[n];
|
|
157
181
|
}
|
|
158
|
-
} else if (/^[.&:]/.test(n)) {
|
|
182
|
+
} else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
|
|
159
183
|
const t = e[n];
|
|
160
184
|
typeof t == "object" && (r.selector(n, t), delete e[n]);
|
|
161
185
|
}
|
|
186
|
+
for (const n in e) {
|
|
187
|
+
const t = e[n];
|
|
188
|
+
typeof t == "string" && t[0] === "@" && (e[n] = r.ref(t.slice(1)));
|
|
189
|
+
}
|
|
162
190
|
return e;
|
|
163
191
|
}
|
|
164
|
-
function
|
|
192
|
+
function $e(e) {
|
|
165
193
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
166
194
|
}
|
|
167
|
-
function
|
|
195
|
+
function A(e) {
|
|
168
196
|
if (e instanceof Buffer)
|
|
169
197
|
return Buffer.from(e);
|
|
170
198
|
const r = e.constructor;
|
|
@@ -174,133 +202,133 @@ function j(e) {
|
|
|
174
202
|
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
175
203
|
);
|
|
176
204
|
}
|
|
177
|
-
function
|
|
205
|
+
function re(e) {
|
|
178
206
|
if (e = e || {}, e.circular)
|
|
179
|
-
return
|
|
207
|
+
return ie(e);
|
|
180
208
|
const r = /* @__PURE__ */ new Map();
|
|
181
|
-
if (r.set(Date, (
|
|
209
|
+
if (r.set(Date, (s) => new Date(s)), r.set(
|
|
182
210
|
Map,
|
|
183
|
-
(
|
|
211
|
+
(s, a) => new Map(t(Array.from(s), a))
|
|
184
212
|
), r.set(
|
|
185
213
|
Set,
|
|
186
|
-
(
|
|
214
|
+
(s, a) => new Set(t(Array.from(s), a))
|
|
187
215
|
), e.constructorHandlers)
|
|
188
|
-
for (const
|
|
189
|
-
r.set(
|
|
216
|
+
for (const s of e.constructorHandlers)
|
|
217
|
+
r.set(s[0], s[1]);
|
|
190
218
|
let n;
|
|
191
219
|
return e.proto ? c : i;
|
|
192
|
-
function t(
|
|
193
|
-
const
|
|
194
|
-
for (let l = 0; l <
|
|
195
|
-
const
|
|
196
|
-
typeof y != "object" || y === null ? f[
|
|
220
|
+
function t(s, a) {
|
|
221
|
+
const o = Object.keys(s), f = Array.from({ length: o.length });
|
|
222
|
+
for (let l = 0; l < o.length; l++) {
|
|
223
|
+
const u = o[l], y = s[u];
|
|
224
|
+
typeof y != "object" || y === null ? f[u] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[u] = n(y, a) : ArrayBuffer.isView(y) ? f[u] = A(y) : f[u] = a(y);
|
|
197
225
|
}
|
|
198
226
|
return f;
|
|
199
227
|
}
|
|
200
|
-
function i(
|
|
201
|
-
if (typeof
|
|
202
|
-
if (Array.isArray(
|
|
203
|
-
if (
|
|
204
|
-
return n(
|
|
205
|
-
const
|
|
206
|
-
for (const
|
|
207
|
-
if (Object.hasOwnProperty.call(
|
|
208
|
-
const f = o
|
|
209
|
-
typeof f != "object" || f === null ?
|
|
228
|
+
function i(s) {
|
|
229
|
+
if (typeof s != "object" || s === null) return s;
|
|
230
|
+
if (Array.isArray(s)) return t(s, i);
|
|
231
|
+
if (s.constructor !== Object && (n = r.get(s.constructor)))
|
|
232
|
+
return n(s, i);
|
|
233
|
+
const a = {};
|
|
234
|
+
for (const o in s) {
|
|
235
|
+
if (Object.hasOwnProperty.call(s, o) === !1) continue;
|
|
236
|
+
const f = s[o];
|
|
237
|
+
typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, i) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = i(f);
|
|
210
238
|
}
|
|
211
|
-
return
|
|
239
|
+
return a;
|
|
212
240
|
}
|
|
213
|
-
function c(
|
|
214
|
-
if (typeof
|
|
215
|
-
if (Array.isArray(
|
|
216
|
-
if (
|
|
217
|
-
return n(
|
|
218
|
-
const
|
|
219
|
-
for (const
|
|
220
|
-
const f = o
|
|
221
|
-
typeof f != "object" || f === null ?
|
|
241
|
+
function c(s) {
|
|
242
|
+
if (typeof s != "object" || s === null) return s;
|
|
243
|
+
if (Array.isArray(s)) return t(s, c);
|
|
244
|
+
if (s.constructor !== Object && (n = r.get(s.constructor)))
|
|
245
|
+
return n(s, c);
|
|
246
|
+
const a = {};
|
|
247
|
+
for (const o in s) {
|
|
248
|
+
const f = s[o];
|
|
249
|
+
typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, c) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = c(f);
|
|
222
250
|
}
|
|
223
|
-
return
|
|
251
|
+
return a;
|
|
224
252
|
}
|
|
225
253
|
}
|
|
226
|
-
function
|
|
254
|
+
function ie(e) {
|
|
227
255
|
const r = [], n = [], t = /* @__PURE__ */ new Map();
|
|
228
|
-
if (t.set(Date, (
|
|
256
|
+
if (t.set(Date, (o) => new Date(o)), t.set(
|
|
229
257
|
Map,
|
|
230
|
-
(
|
|
258
|
+
(o, f) => new Map(c(Array.from(o), f))
|
|
231
259
|
), t.set(
|
|
232
260
|
Set,
|
|
233
|
-
(
|
|
261
|
+
(o, f) => new Set(c(Array.from(o), f))
|
|
234
262
|
), e.constructorHandlers)
|
|
235
|
-
for (const
|
|
236
|
-
t.set(
|
|
263
|
+
for (const o of e.constructorHandlers)
|
|
264
|
+
t.set(o[0], o[1]);
|
|
237
265
|
let i;
|
|
238
|
-
return e.proto ?
|
|
239
|
-
function c(
|
|
240
|
-
const l = Object.keys(
|
|
266
|
+
return e.proto ? a : s;
|
|
267
|
+
function c(o, f) {
|
|
268
|
+
const l = Object.keys(o), u = Array.from({ length: l.length });
|
|
241
269
|
for (let y = 0; y < l.length; y++) {
|
|
242
|
-
const
|
|
270
|
+
const p = l[y], d = o[p];
|
|
243
271
|
if (typeof d != "object" || d === null)
|
|
244
|
-
|
|
272
|
+
u[p] = d;
|
|
245
273
|
else if (d.constructor !== Object && (i = t.get(d.constructor)))
|
|
246
|
-
|
|
274
|
+
u[p] = i(d, f);
|
|
247
275
|
else if (ArrayBuffer.isView(d))
|
|
248
|
-
|
|
276
|
+
u[p] = A(d);
|
|
249
277
|
else {
|
|
250
|
-
const
|
|
251
|
-
|
|
278
|
+
const w = r.indexOf(d);
|
|
279
|
+
w !== -1 ? u[p] = n[w] : u[p] = f(d);
|
|
252
280
|
}
|
|
253
281
|
}
|
|
254
|
-
return
|
|
282
|
+
return u;
|
|
255
283
|
}
|
|
256
|
-
function o
|
|
257
|
-
if (typeof
|
|
258
|
-
if (Array.isArray(
|
|
259
|
-
if (
|
|
260
|
-
return i(
|
|
284
|
+
function s(o) {
|
|
285
|
+
if (typeof o != "object" || o === null) return o;
|
|
286
|
+
if (Array.isArray(o)) return c(o, s);
|
|
287
|
+
if (o.constructor !== Object && (i = t.get(o.constructor)))
|
|
288
|
+
return i(o, s);
|
|
261
289
|
const f = {};
|
|
262
|
-
r.push(
|
|
263
|
-
for (const l in
|
|
264
|
-
if (Object.hasOwnProperty.call(
|
|
265
|
-
const
|
|
266
|
-
if (typeof
|
|
267
|
-
f[l] =
|
|
268
|
-
else if (
|
|
269
|
-
f[l] = i(
|
|
270
|
-
else if (ArrayBuffer.isView(
|
|
271
|
-
f[l] =
|
|
290
|
+
r.push(o), n.push(f);
|
|
291
|
+
for (const l in o) {
|
|
292
|
+
if (Object.hasOwnProperty.call(o, l) === !1) continue;
|
|
293
|
+
const u = o[l];
|
|
294
|
+
if (typeof u != "object" || u === null)
|
|
295
|
+
f[l] = u;
|
|
296
|
+
else if (u.constructor !== Object && (i = t.get(u.constructor)))
|
|
297
|
+
f[l] = i(u, s);
|
|
298
|
+
else if (ArrayBuffer.isView(u))
|
|
299
|
+
f[l] = A(u);
|
|
272
300
|
else {
|
|
273
|
-
const y = r.indexOf(
|
|
274
|
-
y !== -1 ? f[l] = n[y] : f[l] =
|
|
301
|
+
const y = r.indexOf(u);
|
|
302
|
+
y !== -1 ? f[l] = n[y] : f[l] = s(u);
|
|
275
303
|
}
|
|
276
304
|
}
|
|
277
305
|
return r.pop(), n.pop(), f;
|
|
278
306
|
}
|
|
279
|
-
function
|
|
280
|
-
if (typeof
|
|
281
|
-
if (Array.isArray(
|
|
282
|
-
if (
|
|
283
|
-
return i(
|
|
307
|
+
function a(o) {
|
|
308
|
+
if (typeof o != "object" || o === null) return o;
|
|
309
|
+
if (Array.isArray(o)) return c(o, a);
|
|
310
|
+
if (o.constructor !== Object && (i = t.get(o.constructor)))
|
|
311
|
+
return i(o, a);
|
|
284
312
|
const f = {};
|
|
285
|
-
r.push(
|
|
286
|
-
for (const l in
|
|
287
|
-
const
|
|
288
|
-
if (typeof
|
|
289
|
-
f[l] =
|
|
290
|
-
else if (
|
|
291
|
-
f[l] = i(
|
|
292
|
-
else if (ArrayBuffer.isView(
|
|
293
|
-
f[l] =
|
|
313
|
+
r.push(o), n.push(f);
|
|
314
|
+
for (const l in o) {
|
|
315
|
+
const u = o[l];
|
|
316
|
+
if (typeof u != "object" || u === null)
|
|
317
|
+
f[l] = u;
|
|
318
|
+
else if (u.constructor !== Object && (i = t.get(u.constructor)))
|
|
319
|
+
f[l] = i(u, a);
|
|
320
|
+
else if (ArrayBuffer.isView(u))
|
|
321
|
+
f[l] = A(u);
|
|
294
322
|
else {
|
|
295
|
-
const y = r.indexOf(
|
|
296
|
-
y !== -1 ? f[l] = n[y] : f[l] = u
|
|
323
|
+
const y = r.indexOf(u);
|
|
324
|
+
y !== -1 ? f[l] = n[y] : f[l] = a(u);
|
|
297
325
|
}
|
|
298
326
|
}
|
|
299
327
|
return r.pop(), n.pop(), f;
|
|
300
328
|
}
|
|
301
329
|
}
|
|
302
|
-
const
|
|
303
|
-
function
|
|
330
|
+
const F = re();
|
|
331
|
+
function se(e, r = 8) {
|
|
304
332
|
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
305
333
|
let t = "";
|
|
306
334
|
for (let i = 0; i < r; i++) {
|
|
@@ -309,19 +337,19 @@ function ne(e, r = 8) {
|
|
|
309
337
|
}
|
|
310
338
|
return e ? `${e}${t}` : t;
|
|
311
339
|
}
|
|
312
|
-
function
|
|
340
|
+
function Oe(e, r) {
|
|
313
341
|
const n = e.variables.find((t) => t.name === r);
|
|
314
342
|
if (!n)
|
|
315
343
|
throw new Error(`Variable "${r}" not found`);
|
|
316
344
|
return n;
|
|
317
345
|
}
|
|
318
|
-
function
|
|
346
|
+
function Me(e, r) {
|
|
319
347
|
const n = e.utilities.find((t) => t.name === r);
|
|
320
348
|
if (!n)
|
|
321
349
|
throw new Error(`Utility "${r}" not found`);
|
|
322
350
|
return n;
|
|
323
351
|
}
|
|
324
|
-
function
|
|
352
|
+
function oe(e, r) {
|
|
325
353
|
const n = e.modifiers.find(
|
|
326
354
|
(t) => t.key.includes(r)
|
|
327
355
|
);
|
|
@@ -329,35 +357,35 @@ function re(e, r) {
|
|
|
329
357
|
throw new Error(`Modifier "${r}" not found`);
|
|
330
358
|
return n;
|
|
331
359
|
}
|
|
332
|
-
function
|
|
360
|
+
function S(e, r) {
|
|
333
361
|
if (e === r) return !0;
|
|
334
362
|
if (typeof e != typeof r) return !1;
|
|
335
363
|
if (e === null || r === null) return e === r;
|
|
336
364
|
if (typeof e != "object" || typeof r != "object") return !1;
|
|
337
365
|
if (Array.isArray(e) && Array.isArray(r))
|
|
338
|
-
return e.length !== r.length ? !1 : e.every((n, t) =>
|
|
366
|
+
return e.length !== r.length ? !1 : e.every((n, t) => S(n, r[t]));
|
|
339
367
|
if ("type" in e && "type" in r) {
|
|
340
368
|
if (e.type !== r.type) return !1;
|
|
341
|
-
if (
|
|
342
|
-
return e.name === r.name &&
|
|
369
|
+
if (j(e) && j(r))
|
|
370
|
+
return e.name === r.name && S(e.fallback, r.fallback);
|
|
343
371
|
if (E(e) && E(r))
|
|
344
|
-
return
|
|
372
|
+
return S(e.value, r.value);
|
|
345
373
|
}
|
|
346
374
|
return !1;
|
|
347
375
|
}
|
|
348
|
-
const
|
|
349
|
-
function
|
|
350
|
-
|
|
376
|
+
const H = "__licenseRequired";
|
|
377
|
+
function ce(e) {
|
|
378
|
+
T(e) || Object.defineProperty(e, H, {
|
|
351
379
|
value: !0,
|
|
352
380
|
writable: !1,
|
|
353
381
|
configurable: !1,
|
|
354
382
|
enumerable: !0
|
|
355
383
|
});
|
|
356
384
|
}
|
|
357
|
-
function
|
|
358
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
385
|
+
function T(e) {
|
|
386
|
+
return Object.prototype.hasOwnProperty.call(e, H);
|
|
359
387
|
}
|
|
360
|
-
function
|
|
388
|
+
function fe(e, r) {
|
|
361
389
|
const n = [...e];
|
|
362
390
|
for (const t of r) {
|
|
363
391
|
const i = n.find(
|
|
@@ -367,7 +395,7 @@ function oe(e, r) {
|
|
|
367
395
|
}
|
|
368
396
|
return n;
|
|
369
397
|
}
|
|
370
|
-
function
|
|
398
|
+
function ae(e, r) {
|
|
371
399
|
const n = [...e];
|
|
372
400
|
for (const t of r) {
|
|
373
401
|
const i = n.find(
|
|
@@ -375,14 +403,14 @@ function se(e, r) {
|
|
|
375
403
|
);
|
|
376
404
|
i ? Object.assign(
|
|
377
405
|
i,
|
|
378
|
-
|
|
406
|
+
W(i, t)
|
|
379
407
|
) : n.push(t);
|
|
380
408
|
}
|
|
381
409
|
return n;
|
|
382
410
|
}
|
|
383
|
-
function
|
|
411
|
+
function W(e, r) {
|
|
384
412
|
return Object.keys(e).reduce(
|
|
385
|
-
(n, t) => (t === "variables" ? n.variables =
|
|
413
|
+
(n, t) => (t === "variables" ? n.variables = fe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && V(n) && V(e) && V(r) ? n.themes = ae(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
|
|
386
414
|
r[t]
|
|
387
415
|
)), n),
|
|
388
416
|
{
|
|
@@ -391,32 +419,32 @@ function U(e, r) {
|
|
|
391
419
|
}
|
|
392
420
|
);
|
|
393
421
|
}
|
|
394
|
-
function
|
|
422
|
+
function Fe(e, ...r) {
|
|
395
423
|
return r.reduce((n, t) => {
|
|
396
424
|
const i = {
|
|
397
425
|
...n,
|
|
398
|
-
root:
|
|
426
|
+
root: W(n.root, t.root)
|
|
399
427
|
};
|
|
400
|
-
return (
|
|
428
|
+
return (T(n) || T(t)) && ce(i), i;
|
|
401
429
|
}, e);
|
|
402
430
|
}
|
|
403
|
-
function
|
|
431
|
+
function ue(e) {
|
|
404
432
|
const r = [];
|
|
405
433
|
function n(t, i) {
|
|
406
434
|
i.length > 0 && r.push([...i].sort());
|
|
407
435
|
for (let c = t; c < e.length; c++) {
|
|
408
|
-
const
|
|
409
|
-
if (
|
|
410
|
-
if (
|
|
411
|
-
n(c + 1, [...i,
|
|
436
|
+
const s = e[c];
|
|
437
|
+
if (s)
|
|
438
|
+
if (s.length === 1 && s[0])
|
|
439
|
+
n(c + 1, [...i, s[0]]);
|
|
412
440
|
else
|
|
413
|
-
for (const
|
|
414
|
-
n(c + 1, [...i,
|
|
441
|
+
for (const a of s)
|
|
442
|
+
n(c + 1, [...i, a]);
|
|
415
443
|
}
|
|
416
444
|
}
|
|
417
445
|
return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
|
|
418
446
|
}
|
|
419
|
-
function
|
|
447
|
+
function le(e, r, n) {
|
|
420
448
|
const t = {
|
|
421
449
|
...e,
|
|
422
450
|
modifiers: [...n.keys()]
|
|
@@ -424,13 +452,13 @@ function fe(e, r, n) {
|
|
|
424
452
|
for (const c of n.values())
|
|
425
453
|
c.factory({
|
|
426
454
|
...i,
|
|
427
|
-
declarations:
|
|
428
|
-
variables:
|
|
429
|
-
children:
|
|
430
|
-
}),
|
|
455
|
+
declarations: F(t.declarations),
|
|
456
|
+
variables: F(t.variables),
|
|
457
|
+
children: F(t.children)
|
|
458
|
+
}), R(t.declarations, i);
|
|
431
459
|
return t;
|
|
432
460
|
}
|
|
433
|
-
function
|
|
461
|
+
function ye(e, r) {
|
|
434
462
|
return function(t, i) {
|
|
435
463
|
const c = {
|
|
436
464
|
type: "modifier",
|
|
@@ -440,7 +468,7 @@ function ue(e, r) {
|
|
|
440
468
|
return r.modifiers.push(c), c;
|
|
441
469
|
};
|
|
442
470
|
}
|
|
443
|
-
function
|
|
471
|
+
function de() {
|
|
444
472
|
return {
|
|
445
473
|
type: "root",
|
|
446
474
|
declarations: {},
|
|
@@ -452,30 +480,84 @@ function ae() {
|
|
|
452
480
|
themes: []
|
|
453
481
|
};
|
|
454
482
|
}
|
|
455
|
-
function
|
|
483
|
+
function me(e, r) {
|
|
484
|
+
const n = P({ namespace: e });
|
|
485
|
+
return (t) => {
|
|
486
|
+
if (typeof t == "string" && t[0] === "@") {
|
|
487
|
+
const i = t.slice(1), c = e.find(
|
|
488
|
+
(s) => i === s || i.startsWith(`${s}.`)
|
|
489
|
+
);
|
|
490
|
+
if (c) {
|
|
491
|
+
const s = i.slice(c.length + 1) || i;
|
|
492
|
+
if (r.variables.some((a) => a.name === i))
|
|
493
|
+
return {
|
|
494
|
+
[s]: {
|
|
495
|
+
type: "reference",
|
|
496
|
+
name: i
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
} else
|
|
500
|
+
for (const s of e) {
|
|
501
|
+
const a = `${s}.${i}`;
|
|
502
|
+
if (r.variables.some((o) => o.name === a))
|
|
503
|
+
return {
|
|
504
|
+
[i]: {
|
|
505
|
+
type: "reference",
|
|
506
|
+
name: a
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
return n(t);
|
|
511
|
+
}
|
|
512
|
+
return n(t);
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function pe(e, r) {
|
|
456
516
|
return function(t, i, c = {}) {
|
|
457
|
-
const
|
|
517
|
+
const s = {
|
|
458
518
|
type: "utility",
|
|
459
519
|
name: t,
|
|
460
520
|
factory: i,
|
|
461
521
|
values: [],
|
|
462
|
-
autogenerate: c.autogenerate ??
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
522
|
+
autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? me(c.namespace, r) : P(
|
|
523
|
+
c.namespace ? { namespace: c.namespace } : void 0
|
|
524
|
+
)),
|
|
525
|
+
namespace: c.namespace,
|
|
526
|
+
create: (a, o = []) => {
|
|
527
|
+
let f = a;
|
|
528
|
+
if (Array.isArray(a)) {
|
|
466
529
|
f = {};
|
|
467
|
-
for (const l of
|
|
468
|
-
const
|
|
530
|
+
for (const l of a) {
|
|
531
|
+
const u = s.autogenerate(l);
|
|
469
532
|
f = {
|
|
470
533
|
...f,
|
|
471
|
-
...
|
|
534
|
+
...u
|
|
472
535
|
};
|
|
473
536
|
}
|
|
474
537
|
}
|
|
475
|
-
for (const [l,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
538
|
+
for (const [l, u] of Object.entries(f)) {
|
|
539
|
+
let y = u;
|
|
540
|
+
if (s.namespace && j(u))
|
|
541
|
+
if (r.variables.some((g) => g.name === u.name))
|
|
542
|
+
y = u;
|
|
543
|
+
else {
|
|
544
|
+
const g = Array.isArray(s.namespace) ? s.namespace : [s.namespace];
|
|
545
|
+
let $ = !1;
|
|
546
|
+
for (const O of g) {
|
|
547
|
+
const m = `${O}.${l}`;
|
|
548
|
+
if (m !== u.name && r.variables.some((b) => b.name === m)) {
|
|
549
|
+
y = {
|
|
550
|
+
type: "reference",
|
|
551
|
+
name: m
|
|
552
|
+
}, $ = !0;
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
$ || (y = l);
|
|
557
|
+
}
|
|
558
|
+
const p = s.values.find(
|
|
559
|
+
(g) => g.key === l && g.modifiers.length === 0
|
|
560
|
+
), d = {
|
|
479
561
|
type: "utility",
|
|
480
562
|
name: t,
|
|
481
563
|
value: l,
|
|
@@ -483,136 +565,140 @@ function le(e, r) {
|
|
|
483
565
|
variables: [],
|
|
484
566
|
children: [],
|
|
485
567
|
modifiers: []
|
|
486
|
-
},
|
|
487
|
-
|
|
568
|
+
}, w = v(
|
|
569
|
+
d,
|
|
488
570
|
r
|
|
489
571
|
);
|
|
490
|
-
if (
|
|
491
|
-
...
|
|
492
|
-
value:
|
|
493
|
-
}) ?? {},
|
|
572
|
+
if (d.declarations = i({
|
|
573
|
+
...w,
|
|
574
|
+
value: y
|
|
575
|
+
}) ?? {}, R(d.declarations, w), p || (s.values.push({
|
|
494
576
|
key: l,
|
|
495
|
-
value:
|
|
577
|
+
value: y,
|
|
496
578
|
modifiers: []
|
|
497
|
-
}), e.children.push(
|
|
498
|
-
const
|
|
499
|
-
(
|
|
500
|
-
)).reduce((
|
|
501
|
-
const
|
|
502
|
-
for (const
|
|
503
|
-
const
|
|
504
|
-
(
|
|
579
|
+
}), e.children.push(d)), o && o.length > 0) {
|
|
580
|
+
const g = o.map((m) => m.key), O = ue(g).filter((m) => !s.values.find(
|
|
581
|
+
(b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k) => m.includes(k))
|
|
582
|
+
)).reduce((m, b) => {
|
|
583
|
+
const k = /* @__PURE__ */ new Map();
|
|
584
|
+
for (const U of b) {
|
|
585
|
+
const M = o.find(
|
|
586
|
+
(q) => q.key.includes(U)
|
|
505
587
|
);
|
|
506
|
-
|
|
588
|
+
M && I(M) && k.set(U, M);
|
|
507
589
|
}
|
|
508
|
-
return
|
|
590
|
+
return s.values.push({
|
|
509
591
|
key: l,
|
|
510
|
-
value:
|
|
511
|
-
modifiers:
|
|
512
|
-
}),
|
|
592
|
+
value: y,
|
|
593
|
+
modifiers: b
|
|
594
|
+
}), m.push(le(d, r, k)), m;
|
|
513
595
|
}, []);
|
|
514
|
-
e.children.push(...
|
|
596
|
+
e.children.push(...O);
|
|
515
597
|
}
|
|
516
598
|
}
|
|
517
599
|
}
|
|
518
600
|
};
|
|
519
|
-
return r.utilities.push(
|
|
601
|
+
return r.utilities.push(s), s.create;
|
|
520
602
|
};
|
|
521
603
|
}
|
|
522
|
-
function
|
|
604
|
+
function he(e, r) {
|
|
523
605
|
return function(t, i) {
|
|
524
|
-
const c = r.themes.find((
|
|
606
|
+
const c = r.themes.find((o) => o.name === t), s = c ?? {
|
|
525
607
|
type: "theme",
|
|
526
608
|
name: t,
|
|
527
609
|
declarations: {},
|
|
528
610
|
variables: [],
|
|
529
611
|
children: []
|
|
530
612
|
};
|
|
531
|
-
c || r.themes.push(
|
|
532
|
-
const
|
|
533
|
-
return i && i(
|
|
613
|
+
c || r.themes.push(s);
|
|
614
|
+
const a = v(s, r);
|
|
615
|
+
return i && i(a), s;
|
|
534
616
|
};
|
|
535
617
|
}
|
|
536
|
-
function
|
|
618
|
+
function ge(e, r) {
|
|
537
619
|
return function(t) {
|
|
538
620
|
const i = {
|
|
539
621
|
type: "recipe",
|
|
540
622
|
...t
|
|
541
623
|
};
|
|
542
|
-
return i._runtime =
|
|
624
|
+
return i._runtime = be(i, r), Ae(i, r), r.recipes.push(i), i;
|
|
543
625
|
};
|
|
544
626
|
}
|
|
545
627
|
function _(e, r) {
|
|
546
628
|
const n = e.autogenerate(r);
|
|
547
629
|
return Object.keys(n)[0] ?? "default";
|
|
548
630
|
}
|
|
549
|
-
function
|
|
631
|
+
function N(e, r) {
|
|
550
632
|
const n = {};
|
|
551
633
|
for (const [t, i] of Object.entries(e))
|
|
552
|
-
if (
|
|
634
|
+
if (L(i)) {
|
|
553
635
|
const c = {};
|
|
554
|
-
for (const [
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
)
|
|
636
|
+
for (const [s, a] of Object.entries(i)) {
|
|
637
|
+
const o = B(r, s);
|
|
638
|
+
o ? c[s] = _(
|
|
639
|
+
o,
|
|
640
|
+
a
|
|
641
|
+
) : console.warn(
|
|
642
|
+
`[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`
|
|
643
|
+
);
|
|
560
644
|
}
|
|
561
645
|
n[t] = c;
|
|
562
646
|
} else if (typeof i == "boolean")
|
|
563
647
|
n[t] = i;
|
|
564
648
|
else {
|
|
565
|
-
const c =
|
|
566
|
-
c
|
|
649
|
+
const c = B(r, t);
|
|
650
|
+
c ? n[t] = _(c, i) : console.warn(
|
|
651
|
+
`[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
|
|
652
|
+
);
|
|
567
653
|
}
|
|
568
654
|
return n;
|
|
569
655
|
}
|
|
570
|
-
function
|
|
656
|
+
function be(e, r) {
|
|
571
657
|
const n = {};
|
|
572
|
-
if (e.base && (n.base =
|
|
658
|
+
if (e.base && (n.base = N(e.base, r)), e.variants) {
|
|
573
659
|
const t = {};
|
|
574
660
|
for (const [i, c] of Object.entries(e.variants)) {
|
|
575
|
-
const
|
|
576
|
-
for (const [
|
|
661
|
+
const s = {};
|
|
662
|
+
for (const [a, o] of Object.entries(
|
|
577
663
|
c
|
|
578
664
|
))
|
|
579
|
-
|
|
580
|
-
|
|
665
|
+
o == null ? s[a] = null : s[a] = N(
|
|
666
|
+
o,
|
|
581
667
|
r
|
|
582
668
|
);
|
|
583
|
-
t[i] =
|
|
669
|
+
t[i] = s;
|
|
584
670
|
}
|
|
585
671
|
n.variants = t;
|
|
586
672
|
}
|
|
587
673
|
return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
|
|
588
674
|
match: { ...t.match },
|
|
589
|
-
css:
|
|
675
|
+
css: N(t.css, r)
|
|
590
676
|
}))), n;
|
|
591
677
|
}
|
|
592
|
-
function
|
|
593
|
-
return !
|
|
678
|
+
function L(e) {
|
|
679
|
+
return !j(e) && typeof e == "object" && e !== null;
|
|
594
680
|
}
|
|
595
681
|
function x(e, r) {
|
|
596
682
|
const n = (t, i, c) => {
|
|
597
|
-
let
|
|
598
|
-
|
|
683
|
+
let s = r.get(t);
|
|
684
|
+
s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
|
|
599
685
|
};
|
|
600
686
|
for (const [t, i] of Object.entries(e))
|
|
601
|
-
if (
|
|
687
|
+
if (L(i)) {
|
|
602
688
|
const c = t.split(":");
|
|
603
|
-
for (const [
|
|
604
|
-
n(
|
|
689
|
+
for (const [s, a] of Object.entries(i))
|
|
690
|
+
n(s, a, c);
|
|
605
691
|
} else
|
|
606
692
|
n(t, i, []);
|
|
607
693
|
}
|
|
608
|
-
function
|
|
694
|
+
function B(e, r) {
|
|
609
695
|
const n = e.utilities.find((i) => i.name === r);
|
|
610
696
|
if (n)
|
|
611
697
|
return n;
|
|
612
698
|
const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
|
|
613
699
|
return e.utilities.find((i) => i.name === t);
|
|
614
700
|
}
|
|
615
|
-
function
|
|
701
|
+
function Ae(e, r) {
|
|
616
702
|
const n = /* @__PURE__ */ new Map();
|
|
617
703
|
if (e.base && x(e.base, n), e.variants)
|
|
618
704
|
for (const i of Object.values(e.variants))
|
|
@@ -626,99 +712,101 @@ function pe(e, r) {
|
|
|
626
712
|
i.css && x(i.css, n);
|
|
627
713
|
const t = /* @__PURE__ */ new Map();
|
|
628
714
|
for (const [i, c] of n) {
|
|
629
|
-
const
|
|
630
|
-
if (!
|
|
715
|
+
const s = B(r, i);
|
|
716
|
+
if (!s) {
|
|
631
717
|
console.warn(
|
|
632
718
|
`[styleframe] Utility "${i}" not found in registry. Skipping.`
|
|
633
719
|
);
|
|
634
720
|
continue;
|
|
635
721
|
}
|
|
636
|
-
for (const
|
|
637
|
-
const
|
|
638
|
-
for (const f of
|
|
722
|
+
for (const a of c) {
|
|
723
|
+
const o = [];
|
|
724
|
+
for (const f of a.modifiers) {
|
|
639
725
|
if (!t.has(f))
|
|
640
726
|
try {
|
|
641
|
-
t.set(f,
|
|
727
|
+
t.set(f, oe(r, f));
|
|
642
728
|
} catch {
|
|
643
729
|
console.warn(
|
|
644
730
|
`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
|
|
645
731
|
), t.set(f, null);
|
|
646
732
|
}
|
|
647
733
|
const l = t.get(f);
|
|
648
|
-
l &&
|
|
734
|
+
l && o.push(l);
|
|
649
735
|
}
|
|
650
|
-
|
|
651
|
-
[
|
|
652
|
-
|
|
736
|
+
s.create(
|
|
737
|
+
[a.value],
|
|
738
|
+
o.length > 0 ? o : void 0
|
|
653
739
|
);
|
|
654
740
|
}
|
|
655
741
|
}
|
|
656
742
|
}
|
|
657
|
-
function
|
|
658
|
-
const r =
|
|
743
|
+
function Se(e) {
|
|
744
|
+
const r = se("sf-"), n = de(), t = { ...e }, i = pe(n, n), c = ye(n, n), s = ge(n, n), a = he(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d } = v(n, n);
|
|
659
745
|
return {
|
|
660
746
|
id: r,
|
|
661
747
|
root: n,
|
|
662
|
-
variable:
|
|
748
|
+
variable: o,
|
|
663
749
|
selector: f,
|
|
664
750
|
utility: i,
|
|
665
751
|
modifier: c,
|
|
666
|
-
recipe:
|
|
667
|
-
theme:
|
|
752
|
+
recipe: s,
|
|
753
|
+
theme: a,
|
|
668
754
|
atRule: l,
|
|
669
|
-
keyframes:
|
|
755
|
+
keyframes: u,
|
|
670
756
|
media: y,
|
|
671
|
-
ref:
|
|
757
|
+
ref: p,
|
|
672
758
|
css: d,
|
|
673
759
|
options: t
|
|
674
760
|
};
|
|
675
761
|
}
|
|
676
762
|
export {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
763
|
+
le as applyModifiers,
|
|
764
|
+
$e as capitalizeFirst,
|
|
765
|
+
ue as combineKeys,
|
|
766
|
+
K as createAtRuleFunction,
|
|
767
|
+
J as createCssFunction,
|
|
682
768
|
v as createDeclarationsCallbackContext,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
769
|
+
X as createKeyframesFunction,
|
|
770
|
+
Q as createMediaFunction,
|
|
771
|
+
ye as createModifierFunction,
|
|
772
|
+
ge as createRecipeFunction,
|
|
773
|
+
ee as createRefFunction,
|
|
774
|
+
de as createRoot,
|
|
775
|
+
te as createSelectorFunction,
|
|
776
|
+
he as createThemeFunction,
|
|
777
|
+
pe as createUtilityFunction,
|
|
778
|
+
ne as createVariableFunction,
|
|
779
|
+
F as deepClone,
|
|
780
|
+
se as generateRandomId,
|
|
781
|
+
be as generateRecipeRuntime,
|
|
782
|
+
oe as getModifier,
|
|
783
|
+
Me as getUtility,
|
|
784
|
+
Oe as getVariable,
|
|
785
|
+
Z as hashValue,
|
|
786
|
+
ve as isAtRule,
|
|
700
787
|
E as isCSS,
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
788
|
+
Y as isContainer,
|
|
789
|
+
I as isModifier,
|
|
790
|
+
C as isObject,
|
|
791
|
+
z as isPrimitiveTokenValue,
|
|
792
|
+
Ve as isRecipe,
|
|
793
|
+
j as isRef,
|
|
794
|
+
V as isRoot,
|
|
795
|
+
je as isSelector,
|
|
796
|
+
Re as isStyleframe,
|
|
797
|
+
ke as isTheme,
|
|
798
|
+
h as isToken,
|
|
799
|
+
S as isTokenEqual,
|
|
800
|
+
D as isTokenValue,
|
|
801
|
+
we as isUtility,
|
|
802
|
+
G as isVariable,
|
|
803
|
+
Fe as merge,
|
|
804
|
+
W as mergeContainers,
|
|
805
|
+
ae as mergeThemesArray,
|
|
806
|
+
fe as mergeVariablesArray,
|
|
807
|
+
R as parseDeclarationsBlock,
|
|
808
|
+
Ae as processRecipeUtilities,
|
|
809
|
+
re as rfdc,
|
|
810
|
+
Se as styleframe,
|
|
811
|
+
P as transformUtilityKey
|
|
724
812
|
};
|
package/dist/styleframe.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(a=typeof globalThis<"u"?globalThis:a||self,b(a.styleframe={}))})(this,(function(a){"use strict";function b(e){return typeof e=="object"&&e!==null}function p(e,r){return b(e)&&"type"in e&&e.type===r}function $(e){return p(e,"variable")}function A(e){return p(e,"reference")}function de(e){return p(e,"selector")}function me(e){return p(e,"at-rule")}function he(e){return p(e,"utility")}function P(e){return p(e,"modifier")}function k(e){return p(e,"css")}function pe(e){return p(e,"theme")}function F(e){return p(e,"root")}function be(e){return p(e,"recipe")}function H(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function S(e){return H(e)||A(e)||k(e)||Array.isArray(e)&&e.every(S)}function N(e){return b(e)&&"children"in e&&"declarations"in e&&"variables"in e}function q(e=r=>r){return r=>{let n=r,t;if(typeof n=="string"&&n[0]==="@"){const i=n.slice(1);t=e(i),n={type:"reference",name:i}}else A(n)?t=e(n.name):t=`[${r}]`;return{[t]:n}}}function I(e,r){return function(t,...i){return{type:"css",value:t.reduce((o,u,s)=>(o.push(u),s<i.length&&o.push(i[s]),o),[])}}}function O(e,r){return function(t,i,c){const o={type:"at-rule",identifier:t,rule:i,declarations:{},variables:[],children:[]},u=g(o,r);return typeof c=="function"?o.declarations=c(u)??{}:c&&(o.declarations=c),w(o.declarations,u),e.children.push(o),o}}function L(e,r){const n=O(e,r);return function(i,c){return n("media",i,c)}}function z(e,r){const n=O(e,r);return function(i,c){return n("keyframes",i,c)}}function G(e,r){return function(t,i){return $(t)?{type:"reference",name:t.name,fallback:i}:{type:"reference",name:t,fallback:i}}}function W(e,r){return function(t,i){const c={type:"selector",query:t,declarations:{},variables:[],children:[]},o=g(c,r);return typeof i=="function"?c.declarations=i(o)??{}:N(i)?(c.variables=i.variables,c.declarations=i.declarations,c.children=i.children):c.declarations=i,w(c.declarations,o),e.children.push(c),c}}function Y(e,r){return function(t,i,c={default:!1}){const o=typeof t=="string"?t:t.name,u=e.variables.find(f=>f.name===o);if(c.default&&u)return u;if(u)return u.value=i,u;const s={type:"variable",name:o,value:i};return e.variables.push(s),s}}function g(e,r){const n=Y(e),t=W(e,r),i=O(e,r),c=z(r,r),o=L(e,r),u=G(),s=I();return{variable:n,selector:t,keyframes:c,atRule:i,media:o,ref:u,css:s}}function w(e,r){for(const n in e)if(n.startsWith("@")){const t=e[n];if(typeof t=="object"&&t!==null&&!S(t)){const i=n.replace(/^@(\w+).*/,"$1"),c=n.replace(`@${i}`,"").trim();r.atRule(i,c,t),delete e[n]}}else if(/^[.&:]/.test(n)){const t=e[n];typeof t=="object"&&(r.selector(n,t),delete e[n])}return e}function ge(e){return e.charAt(0).toUpperCase()+e.slice(1)}function R(e){if(e instanceof Buffer)return Buffer.from(e);const r=e.constructor;return new r(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function Z(e){if(e=e||{},e.circular)return je(e);const r=new Map;if(r.set(Date,o=>new Date(o)),r.set(Map,(o,u)=>new Map(t(Array.from(o),u))),r.set(Set,(o,u)=>new Set(t(Array.from(o),u))),e.constructorHandlers)for(const o of e.constructorHandlers)r.set(o[0],o[1]);let n;return e.proto?c:i;function t(o,u){const s=Object.keys(o),f=Array.from({length:s.length});for(let y=0;y<s.length;y++){const l=s[y],d=o[l];typeof d!="object"||d===null?f[l]=d:d.constructor!==Object&&(n=r.get(d.constructor))?f[l]=n(d,u):ArrayBuffer.isView(d)?f[l]=R(d):f[l]=u(d)}return f}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return t(o,i);if(o.constructor!==Object&&(n=r.get(o.constructor)))return n(o,i);const u={};for(const s in o){if(Object.hasOwnProperty.call(o,s)===!1)continue;const f=o[s];typeof f!="object"||f===null?u[s]=f:f.constructor!==Object&&(n=r.get(f.constructor))?u[s]=n(f,i):ArrayBuffer.isView(f)?u[s]=R(f):u[s]=i(f)}return u}function c(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return t(o,c);if(o.constructor!==Object&&(n=r.get(o.constructor)))return n(o,c);const u={};for(const s in o){const f=o[s];typeof f!="object"||f===null?u[s]=f:f.constructor!==Object&&(n=r.get(f.constructor))?u[s]=n(f,c):ArrayBuffer.isView(f)?u[s]=R(f):u[s]=c(f)}return u}}function je(e){const r=[],n=[],t=new Map;if(t.set(Date,s=>new Date(s)),t.set(Map,(s,f)=>new Map(c(Array.from(s),f))),t.set(Set,(s,f)=>new Set(c(Array.from(s),f))),e.constructorHandlers)for(const s of e.constructorHandlers)t.set(s[0],s[1]);let i;return e.proto?u:o;function c(s,f){const y=Object.keys(s),l=Array.from({length:y.length});for(let d=0;d<y.length;d++){const h=y[d],m=s[h];if(typeof m!="object"||m===null)l[h]=m;else if(m.constructor!==Object&&(i=t.get(m.constructor)))l[h]=i(m,f);else if(ArrayBuffer.isView(m))l[h]=R(m);else{const j=r.indexOf(m);j!==-1?l[h]=n[j]:l[h]=f(m)}}return l}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,o);if(s.constructor!==Object&&(i=t.get(s.constructor)))return i(s,o);const f={};r.push(s),n.push(f);for(const y in s){if(Object.hasOwnProperty.call(s,y)===!1)continue;const l=s[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,o);else if(ArrayBuffer.isView(l))f[y]=R(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=o(l)}}return r.pop(),n.pop(),f}function u(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,u);if(s.constructor!==Object&&(i=t.get(s.constructor)))return i(s,u);const f={};r.push(s),n.push(f);for(const y in s){const l=s[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,u);else if(ArrayBuffer.isView(l))f[y]=R(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=u(l)}}return r.pop(),n.pop(),f}}const M=Z();function J(e,r=8){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let i=0;i<r;i++){const c=Math.floor(Math.random()*n.length);t+=n[c]}return e?`${e}${t}`:t}function ve(e,r){const n=e.variables.find(t=>t.name===r);if(!n)throw new Error(`Variable "${r}" not found`);return n}function Ae(e,r){const n=e.utilities.find(t=>t.name===r);if(!n)throw new Error(`Utility "${r}" not found`);return n}function Q(e,r){const n=e.modifiers.find(t=>t.key.includes(r));if(!n)throw new Error(`Modifier "${r}" not found`);return n}function T(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(e===null||r===null)return e===r;if(typeof e!="object"||typeof r!="object")return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((n,t)=>T(n,r[t]));if("type"in e&&"type"in r){if(e.type!==r.type)return!1;if(A(e)&&A(r))return e.name===r.name&&T(e.fallback,r.fallback);if(k(e)&&k(r))return T(e.value,r.value)}return!1}const X="__licenseRequired";function Re(e){E(e)||Object.defineProperty(e,X,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function E(e){return Object.prototype.hasOwnProperty.call(e,X)}function x(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?i.value=t.value:n.push(t)}return n}function ee(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?Object.assign(i,B(i,t)):n.push(t)}return n}function B(e,r){return Object.keys(e).reduce((n,t)=>(t==="variables"?n.variables=x(e.variables,r.variables):t==="declarations"?n.declarations={...e.declarations,...r.declarations}:t==="themes"&&F(n)&&F(e)&&F(r)?n.themes=ee(e.themes,r.themes):Array.isArray(e[t])&&(n[t]=e[t].concat(r[t])),n),{...e,...r})}function Ve(e,...r){return r.reduce((n,t)=>{const i={...n,root:B(n.root,t.root)};return(E(n)||E(t))&&Re(i),i},e)}function te(e){const r=[];function n(t,i){i.length>0&&r.push([...i].sort());for(let c=t;c<e.length;c++){const o=e[c];if(o)if(o.length===1&&o[0])n(c+1,[...i,o[0]]);else for(const u of o)n(c+1,[...i,u])}}return n(0,[]),r.sort((t,i)=>t.length!==i.length?t.length-i.length:t.join(",").localeCompare(i.join(",")))}function ne(e,r,n){const t={...e,modifiers:[...n.keys()]},i=g(t,r);for(const c of n.values())c.factory({...i,declarations:M(t.declarations),variables:M(t.variables),children:M(t.children)}),w(t.declarations,i);return t}function re(e,r){return function(t,i){const c={type:"modifier",key:Array.isArray(t)?t:[t],factory:i};return r.modifiers.push(c),c}}function ie(){return{type:"root",declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[]}}function oe(e,r){return function(t,i,c={}){const o={type:"utility",name:t,factory:i,values:[],autogenerate:c.autogenerate??q(),create:(u,s=[])=>{let f=u;if(Array.isArray(u)){f={};for(const y of u){const l=o.autogenerate(y);f={...f,...l}}}for(const[y,l]of Object.entries(f)){const d=o.values.find(j=>j.key===y&&j.modifiers.length===0),h={type:"utility",name:t,value:y,declarations:{},variables:[],children:[],modifiers:[]},m=g(h,r);if(h.declarations=i({...m,value:l})??{},w(h.declarations,m),d||(o.values.push({key:y,value:l,modifiers:[]}),e.children.push(h)),s&&s.length>0){const j=s.map(v=>v.key),ke=te(j).filter(v=>!o.values.find(V=>V.key===y&&V.modifiers.length===v.length&&V.modifiers.every(C=>v.includes(C)))).reduce((v,V)=>{const C=new Map;for(const ye of V){const _=s.find(Fe=>Fe.key.includes(ye));_&&P(_)&&C.set(ye,_)}return o.values.push({key:y,value:l,modifiers:V}),v.push(ne(h,r,C)),v},[]);e.children.push(...ke)}}}};return r.utilities.push(o),o.create}}function se(e,r){return function(t,i){const c=r.themes.find(s=>s.name===t),o=c??{type:"theme",name:t,declarations:{},variables:[],children:[]};c||r.themes.push(o);const u=g(o,r);return i&&i(u),o}}function ce(e,r){return function(t){const i={type:"recipe",...t};return i._runtime=ue(i,r),le(i,r),r.recipes.push(i),i}}function fe(e,r){const n=e.autogenerate(r);return Object.keys(n)[0]??"default"}function K(e,r){const n={};for(const[t,i]of Object.entries(e))if(ae(i)){const c={};for(const[o,u]of Object.entries(i)){const s=D(r,o);s&&(c[o]=fe(s,u))}n[t]=c}else if(typeof i=="boolean")n[t]=i;else{const c=D(r,t);c&&(n[t]=fe(c,i))}return n}function ue(e,r){const n={};if(e.base&&(n.base=K(e.base,r)),e.variants){const t={};for(const[i,c]of Object.entries(e.variants)){const o={};for(const[u,s]of Object.entries(c))s==null?o[u]=null:o[u]=K(s,r);t[i]=o}n.variants=t}return e.defaultVariants&&(n.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(n.compoundVariants=e.compoundVariants.map(t=>({match:{...t.match},css:K(t.css,r)}))),n}function ae(e){return!A(e)&&typeof e=="object"&&e!==null}function U(e,r){const n=(t,i,c)=>{let o=r.get(t);o||(o=[],r.set(t,o)),o.push({value:i,modifiers:c})};for(const[t,i]of Object.entries(e))if(ae(i)){const c=t.split(":");for(const[o,u]of Object.entries(i))n(o,u,c)}else n(t,i,[])}function D(e,r){const n=e.utilities.find(i=>i.name===r);if(n)return n;const t=r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`);return e.utilities.find(i=>i.name===t)}function le(e,r){const n=new Map;if(e.base&&U(e.base,n),e.variants)for(const i of Object.values(e.variants))for(const c of Object.values(i))U(c,n);if(e.compoundVariants)for(const i of e.compoundVariants)i.css&&U(i.css,n);const t=new Map;for(const[i,c]of n){const o=D(r,i);if(!o){console.warn(`[styleframe] Utility "${i}" not found in registry. Skipping.`);continue}for(const u of c){const s=[];for(const f of u.modifiers){if(!t.has(f))try{t.set(f,Q(r,f))}catch{console.warn(`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`),t.set(f,null)}const y=t.get(f);y&&s.push(y)}o.create([u.value],s.length>0?s:void 0)}}}function we(e){const r=J("sf-"),n=ie(),t={...e},i=oe(n,n),c=re(n,n),o=ce(n,n),u=se(n,n),{variable:s,selector:f,atRule:y,keyframes:l,media:d,ref:h,css:m}=g(n,n);return{id:r,root:n,variable:s,selector:f,utility:i,modifier:c,recipe:o,theme:u,atRule:y,keyframes:l,media:d,ref:h,css:m,options:t}}a.applyModifiers=ne,a.capitalizeFirst=ge,a.combineKeys=te,a.createAtRuleFunction=O,a.createCssFunction=I,a.createDeclarationsCallbackContext=g,a.createKeyframesFunction=z,a.createMediaFunction=L,a.createModifierFunction=re,a.createRecipeFunction=ce,a.createRefFunction=G,a.createRoot=ie,a.createSelectorFunction=W,a.createThemeFunction=se,a.createUtilityFunction=oe,a.createVariableFunction=Y,a.deepClone=M,a.generateRandomId=J,a.generateRecipeRuntime=ue,a.getModifier=Q,a.getUtility=Ae,a.getVariable=ve,a.isAtRule=me,a.isCSS=k,a.isContainer=N,a.isModifier=P,a.isObject=b,a.isPrimitiveTokenValue=H,a.isRecipe=be,a.isRef=A,a.isRoot=F,a.isSelector=de,a.isTheme=pe,a.isToken=p,a.isTokenEqual=T,a.isTokenValue=S,a.isUtility=he,a.isVariable=$,a.merge=Ve,a.mergeContainers=B,a.mergeThemesArray=ee,a.mergeVariablesArray=x,a.parseDeclarationsBlock=w,a.processRecipeUtilities=le,a.rfdc=Z,a.styleframe=we,a.transformUtilityKey=q,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(u,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(u=typeof globalThis<"u"?globalThis:u||self,b(u.styleframe={}))})(this,(function(u){"use strict";function b(e){return typeof e=="object"&&e!==null}function h(e,r){return b(e)&&"type"in e&&e.type===r}function W(e){return h(e,"variable")}function v(e){return h(e,"reference")}function ge(e){return h(e,"selector")}function be(e){return h(e,"at-rule")}function Ae(e){return h(e,"utility")}function q(e){return h(e,"modifier")}function M(e){return h(e,"css")}function je(e){return h(e,"theme")}function w(e){return h(e,"root")}function ve(e){return h(e,"recipe")}function I(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function C(e){return I(e)||v(e)||M(e)||Array.isArray(e)&&e.every(C)}function L(e){return b(e)&&"children"in e&&"declarations"in e&&"variables"in e}function ke(e){return b(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&w(e.root)}function z(e){let r=5381;for(let n=0;n<e.length;n++)r=(r<<5)+r+e.charCodeAt(n)&4294967295;return(r>>>0).toString(16).padStart(7,"0").slice(0,7)}function U(e){const r=typeof e=="function"?{replacer:e}:e??{},{replacer:n=c=>c,namespace:t}=r,i=Array.isArray(t)?t:t?[t]:[];return c=>{let s=c,a;if(typeof s=="string"&&s[0]==="@"){const o=s.slice(1),f=i.find(d=>o===d||o.startsWith(`${d}.`));let y,l;f?(y=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):i.length>0?(y=`${i[0]}.${o}`,l=o):(y=o,l=o),a=n(l),s={type:"reference",name:y}}else if(v(s)){let o=s.name;for(const f of i)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=n(o)}else{const o=String(c).trim();/\s/.test(o)?a=z(o):a=`[${o}]`}return{[a]:s}}}function G(e,r){return function(t,...i){return{type:"css",value:t.reduce((s,a,o)=>(s.push(a),o<i.length&&s.push(i[o]),s),[])}}}function T(e,r){return function(t,i,c){const s={type:"at-rule",identifier:t,rule:i,declarations:{},variables:[],children:[]},a=k(s,r);return typeof c=="function"?s.declarations=c(a)??{}:c&&(s.declarations=c),R(s.declarations,a),e.children.push(s),s}}function Y(e,r){const n=T(e,r);return function(i,c){return n("media",i,c)}}function Z(e,r){const n=T(e,r);return function(i,c){return n("keyframes",i,c)}}function J(e,r){return function(t,i){return W(t)?{type:"reference",name:t.name,fallback:i}:{type:"reference",name:t,fallback:i}}}function Q(e,r){return function(t,i){const c={type:"selector",query:t,declarations:{},variables:[],children:[]},s=k(c,r);return typeof i=="function"?c.declarations=i(s)??{}:L(i)?(c.variables=i.variables,c.declarations=i.declarations,c.children=i.children):c.declarations=i,R(c.declarations,s),e.children.push(c),c}}function X(e,r){return function(t,i,c={default:!1}){const s=typeof t=="string"?t:t.name,a=e.variables.find(f=>f.name===s);if(c.default&&a)return a;if(a)return a.value=i,a;const o={type:"variable",name:s,value:i};return e.variables.push(o),o}}function k(e,r){const n=X(e),t=Q(e,r),i=T(e,r),c=Z(r,r),s=Y(e,r),a=J(),o=G();return{variable:n,selector:t,keyframes:c,atRule:i,media:s,ref:a,css:o}}function R(e,r){for(const n in e)if(n.startsWith("@")){const t=e[n];if(typeof t=="object"&&t!==null&&!C(t)){const i=n.replace(/^@(\w+).*/,"$1"),c=n.replace(`@${i}`,"").trim();r.atRule(i,c,t),delete e[n]}}else if(/^[.&:]/.test(n)||/^\d+%$/.test(n)||n==="from"||n==="to"){const t=e[n];typeof t=="object"&&(r.selector(n,t),delete e[n])}for(const n in e){const t=e[n];typeof t=="string"&&t[0]==="@"&&(e[n]=r.ref(t.slice(1)))}return e}function Ve(e){return e.charAt(0).toUpperCase()+e.slice(1)}function V(e){if(e instanceof Buffer)return Buffer.from(e);const r=e.constructor;return new r(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function x(e){if(e=e||{},e.circular)return we(e);const r=new Map;if(r.set(Date,s=>new Date(s)),r.set(Map,(s,a)=>new Map(t(Array.from(s),a))),r.set(Set,(s,a)=>new Set(t(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)r.set(s[0],s[1]);let n;return e.proto?c:i;function t(s,a){const o=Object.keys(s),f=Array.from({length:o.length});for(let y=0;y<o.length;y++){const l=o[y],d=s[l];typeof d!="object"||d===null?f[l]=d:d.constructor!==Object&&(n=r.get(d.constructor))?f[l]=n(d,a):ArrayBuffer.isView(d)?f[l]=V(d):f[l]=a(d)}return f}function i(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,i);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,i);const a={};for(const o in s){if(Object.hasOwnProperty.call(s,o)===!1)continue;const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,i):ArrayBuffer.isView(f)?a[o]=V(f):a[o]=i(f)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return t(s,c);if(s.constructor!==Object&&(n=r.get(s.constructor)))return n(s,c);const a={};for(const o in s){const f=s[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(n=r.get(f.constructor))?a[o]=n(f,c):ArrayBuffer.isView(f)?a[o]=V(f):a[o]=c(f)}return a}}function we(e){const r=[],n=[],t=new Map;if(t.set(Date,o=>new Date(o)),t.set(Map,(o,f)=>new Map(c(Array.from(o),f))),t.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)t.set(o[0],o[1]);let i;return e.proto?a:s;function c(o,f){const y=Object.keys(o),l=Array.from({length:y.length});for(let d=0;d<y.length;d++){const g=y[d],m=o[g];if(typeof m!="object"||m===null)l[g]=m;else if(m.constructor!==Object&&(i=t.get(m.constructor)))l[g]=i(m,f);else if(ArrayBuffer.isView(m))l[g]=V(m);else{const F=r.indexOf(m);F!==-1?l[g]=n[F]:l[g]=f(m)}}return l}function s(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,s);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,s);const f={};r.push(o),n.push(f);for(const y in o){if(Object.hasOwnProperty.call(o,y)===!1)continue;const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,s);else if(ArrayBuffer.isView(l))f[y]=V(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=s(l)}}return r.pop(),n.pop(),f}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,a);if(o.constructor!==Object&&(i=t.get(o.constructor)))return i(o,a);const f={};r.push(o),n.push(f);for(const y in o){const l=o[y];if(typeof l!="object"||l===null)f[y]=l;else if(l.constructor!==Object&&(i=t.get(l.constructor)))f[y]=i(l,a);else if(ArrayBuffer.isView(l))f[y]=V(l);else{const d=r.indexOf(l);d!==-1?f[y]=n[d]:f[y]=a(l)}}return r.pop(),n.pop(),f}}const O=x();function ee(e,r=8){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let i=0;i<r;i++){const c=Math.floor(Math.random()*n.length);t+=n[c]}return e?`${e}${t}`:t}function Re(e,r){const n=e.variables.find(t=>t.name===r);if(!n)throw new Error(`Variable "${r}" not found`);return n}function Fe(e,r){const n=e.utilities.find(t=>t.name===r);if(!n)throw new Error(`Utility "${r}" not found`);return n}function te(e,r){const n=e.modifiers.find(t=>t.key.includes(r));if(!n)throw new Error(`Modifier "${r}" not found`);return n}function S(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(e===null||r===null)return e===r;if(typeof e!="object"||typeof r!="object")return!1;if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((n,t)=>S(n,r[t]));if("type"in e&&"type"in r){if(e.type!==r.type)return!1;if(v(e)&&v(r))return e.name===r.name&&S(e.fallback,r.fallback);if(M(e)&&M(r))return S(e.value,r.value)}return!1}const ne="__licenseRequired";function Me(e){E(e)||Object.defineProperty(e,ne,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function E(e){return Object.prototype.hasOwnProperty.call(e,ne)}function re(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?i.value=t.value:n.push(t)}return n}function ie(e,r){const n=[...e];for(const t of r){const i=n.find(c=>c.name===t.name);i?Object.assign(i,N(i,t)):n.push(t)}return n}function N(e,r){return Object.keys(e).reduce((n,t)=>(t==="variables"?n.variables=re(e.variables,r.variables):t==="declarations"?n.declarations={...e.declarations,...r.declarations}:t==="themes"&&w(n)&&w(e)&&w(r)?n.themes=ie(e.themes,r.themes):Array.isArray(e[t])&&(n[t]=e[t].concat(r[t])),n),{...e,...r})}function Te(e,...r){return r.reduce((n,t)=>{const i={...n,root:N(n.root,t.root)};return(E(n)||E(t))&&Me(i),i},e)}function se(e){const r=[];function n(t,i){i.length>0&&r.push([...i].sort());for(let c=t;c<e.length;c++){const s=e[c];if(s)if(s.length===1&&s[0])n(c+1,[...i,s[0]]);else for(const a of s)n(c+1,[...i,a])}}return n(0,[]),r.sort((t,i)=>t.length!==i.length?t.length-i.length:t.join(",").localeCompare(i.join(",")))}function oe(e,r,n){const t={...e,modifiers:[...n.keys()]},i=k(t,r);for(const c of n.values())c.factory({...i,declarations:O(t.declarations),variables:O(t.variables),children:O(t.children)}),R(t.declarations,i);return t}function ce(e,r){return function(t,i){const c={type:"modifier",key:Array.isArray(t)?t:[t],factory:i};return r.modifiers.push(c),c}}function fe(){return{type:"root",declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[]}}function Oe(e,r){const n=U({namespace:e});return t=>{if(typeof t=="string"&&t[0]==="@"){const i=t.slice(1),c=e.find(s=>i===s||i.startsWith(`${s}.`));if(c){const s=i.slice(c.length+1)||i;if(r.variables.some(a=>a.name===i))return{[s]:{type:"reference",name:i}}}else for(const s of e){const a=`${s}.${i}`;if(r.variables.some(o=>o.name===a))return{[i]:{type:"reference",name:a}}}return n(t)}return n(t)}}function ae(e,r){return function(t,i,c={}){const s={type:"utility",name:t,factory:i,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?Oe(c.namespace,r):U(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(a,o=[])=>{let f=a;if(Array.isArray(a)){f={};for(const y of a){const l=s.autogenerate(y);f={...f,...l}}}for(const[y,l]of Object.entries(f)){let d=l;if(s.namespace&&v(l))if(r.variables.some(A=>A.name===l.name))d=l;else{const A=Array.isArray(s.namespace)?s.namespace:[s.namespace];let _=!1;for(const P of A){const p=`${P}.${y}`;if(p!==l.name&&r.variables.some(j=>j.name===p)){d={type:"reference",name:p},_=!0;break}}_||(d=y)}const g=s.values.find(A=>A.key===y&&A.modifiers.length===0),m={type:"utility",name:t,value:y,declarations:{},variables:[],children:[],modifiers:[]},F=k(m,r);if(m.declarations=i({...F,value:d})??{},R(m.declarations,F),g||(s.values.push({key:y,value:d,modifiers:[]}),e.children.push(m)),o&&o.length>0){const A=o.map(p=>p.key),P=se(A).filter(p=>!s.values.find(j=>j.key===y&&j.modifiers.length===p.length&&j.modifiers.every($=>p.includes($)))).reduce((p,j)=>{const $=new Map;for(const pe of j){const H=o.find($e=>$e.key.includes(pe));H&&q(H)&&$.set(pe,H)}return s.values.push({key:y,value:d,modifiers:j}),p.push(oe(m,r,$)),p},[]);e.children.push(...P)}}}};return r.utilities.push(s),s.create}}function ue(e,r){return function(t,i){const c=r.themes.find(o=>o.name===t),s=c??{type:"theme",name:t,declarations:{},variables:[],children:[]};c||r.themes.push(s);const a=k(s,r);return i&&i(a),s}}function le(e,r){return function(t){const i={type:"recipe",...t};return i._runtime=de(i,r),he(i,r),r.recipes.push(i),i}}function ye(e,r){const n=e.autogenerate(r);return Object.keys(n)[0]??"default"}function B(e,r){const n={};for(const[t,i]of Object.entries(e))if(me(i)){const c={};for(const[s,a]of Object.entries(i)){const o=D(r,s);o?c[s]=ye(o,a):console.warn(`[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`)}n[t]=c}else if(typeof i=="boolean")n[t]=i;else{const c=D(r,t);c?n[t]=ye(c,i):console.warn(`[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`)}return n}function de(e,r){const n={};if(e.base&&(n.base=B(e.base,r)),e.variants){const t={};for(const[i,c]of Object.entries(e.variants)){const s={};for(const[a,o]of Object.entries(c))o==null?s[a]=null:s[a]=B(o,r);t[i]=s}n.variants=t}return e.defaultVariants&&(n.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(n.compoundVariants=e.compoundVariants.map(t=>({match:{...t.match},css:B(t.css,r)}))),n}function me(e){return!v(e)&&typeof e=="object"&&e!==null}function K(e,r){const n=(t,i,c)=>{let s=r.get(t);s||(s=[],r.set(t,s)),s.push({value:i,modifiers:c})};for(const[t,i]of Object.entries(e))if(me(i)){const c=t.split(":");for(const[s,a]of Object.entries(i))n(s,a,c)}else n(t,i,[])}function D(e,r){const n=e.utilities.find(i=>i.name===r);if(n)return n;const t=r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`);return e.utilities.find(i=>i.name===t)}function he(e,r){const n=new Map;if(e.base&&K(e.base,n),e.variants)for(const i of Object.values(e.variants))for(const c of Object.values(i))K(c,n);if(e.compoundVariants)for(const i of e.compoundVariants)i.css&&K(i.css,n);const t=new Map;for(const[i,c]of n){const s=D(r,i);if(!s){console.warn(`[styleframe] Utility "${i}" not found in registry. Skipping.`);continue}for(const a of c){const o=[];for(const f of a.modifiers){if(!t.has(f))try{t.set(f,te(r,f))}catch{console.warn(`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`),t.set(f,null)}const y=t.get(f);y&&o.push(y)}s.create([a.value],o.length>0?o:void 0)}}}function Se(e){const r=ee("sf-"),n=fe(),t={...e},i=ae(n,n),c=ce(n,n),s=le(n,n),a=ue(n,n),{variable:o,selector:f,atRule:y,keyframes:l,media:d,ref:g,css:m}=k(n,n);return{id:r,root:n,variable:o,selector:f,utility:i,modifier:c,recipe:s,theme:a,atRule:y,keyframes:l,media:d,ref:g,css:m,options:t}}u.applyModifiers=oe,u.capitalizeFirst=Ve,u.combineKeys=se,u.createAtRuleFunction=T,u.createCssFunction=G,u.createDeclarationsCallbackContext=k,u.createKeyframesFunction=Z,u.createMediaFunction=Y,u.createModifierFunction=ce,u.createRecipeFunction=le,u.createRefFunction=J,u.createRoot=fe,u.createSelectorFunction=Q,u.createThemeFunction=ue,u.createUtilityFunction=ae,u.createVariableFunction=X,u.deepClone=O,u.generateRandomId=ee,u.generateRecipeRuntime=de,u.getModifier=te,u.getUtility=Fe,u.getVariable=Re,u.hashValue=z,u.isAtRule=be,u.isCSS=M,u.isContainer=L,u.isModifier=q,u.isObject=b,u.isPrimitiveTokenValue=I,u.isRecipe=ve,u.isRef=v,u.isRoot=w,u.isSelector=ge,u.isStyleframe=ke,u.isTheme=je,u.isToken=h,u.isTokenEqual=S,u.isTokenValue=C,u.isUtility=Ae,u.isVariable=W,u.merge=Te,u.mergeContainers=N,u.mergeThemesArray=ie,u.mergeVariablesArray=re,u.parseDeclarationsBlock=R,u.processRecipeUtilities=he,u.rfdc=x,u.styleframe=Se,u.transformUtilityKey=U,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/styleframe.d.ts",
|
|
6
6
|
"module": "./dist/styleframe.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"csstype": "^3.1.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@styleframe/license": "^2.0.
|
|
25
|
+
"@styleframe/license": "^2.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@styleframe/config-typescript": "^
|
|
29
|
-
"@styleframe/config-vite": "^
|
|
30
|
-
"@styleframe/license": "^2.0.
|
|
28
|
+
"@styleframe/config-typescript": "^3.0.0",
|
|
29
|
+
"@styleframe/config-vite": "^3.0.0",
|
|
30
|
+
"@styleframe/license": "^2.0.2",
|
|
31
31
|
"@vitest/coverage-v8": "^3.2.4",
|
|
32
32
|
"typescript": "^5.8.3",
|
|
33
33
|
"vite": "^7.0.6",
|