@styleframe/core 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/styleframe.d.ts +7 -7
- package/dist/styleframe.js +300 -290
- package/dist/styleframe.umd.cjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @styleframe/core
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#164](https://github.com/styleframe-dev/styleframe/pull/164) [`efd99f7`](https://github.com/styleframe-dev/styleframe/commit/efd99f70a30f9a42c6e1793ed777b1565fb47a82) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add className support for compound variants in recipes
|
|
8
|
+
- Add optional `className` field to compound variants, appended to output when conditions match
|
|
9
|
+
- Make `css` optional on compound variants, allowing className-only compound variants
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#175](https://github.com/styleframe-dev/styleframe/pull/175) [`b506ea5`](https://github.com/styleframe-dev/styleframe/commit/b506ea5c3c36fa24fea19a69ee3fef7035397dda) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add Skeleton recipe with pulse animation and supporting utilities
|
|
14
|
+
- Add `useSkeletonRecipe` with size (`xs`, `sm`, `md`, `lg`, `xl`) and rounded (`true`, `false`) variants, pulse animation, and dark mode support
|
|
15
|
+
- Add granular animation utilities: `useAnimationNameUtility`, `useAnimationDurationUtility`, `useAnimationTimingFunctionUtility`, `useAnimationIterationCountUtility`
|
|
16
|
+
- Switch `useWidthUtility` and `useHeightUtility` to `createUseSpacingUtility` for `@N` multiplier support
|
|
17
|
+
- Add compound keyframe selector support in core engine (e.g. `"0%, 100%"`)
|
|
18
|
+
- Add Skeleton storybook component, grid previews, and stories
|
|
19
|
+
- Add Skeleton documentation page
|
|
20
|
+
|
|
21
|
+
## 3.2.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [#155](https://github.com/styleframe-dev/styleframe/pull/155) [`cc4f170`](https://github.com/styleframe-dev/styleframe/commit/cc4f170c56ad2e246b94ab4d64b7f6c3097c7223) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Refactor recipes, improve modifier at-rule support, and forward variables through modifier factories
|
|
26
|
+
- Refactor recipes and utilities with improved color theming composables
|
|
27
|
+
- Add at-rule support for modifiers (e.g. media preference modifiers)
|
|
28
|
+
- Forward variables and children through all modifier factory functions
|
|
29
|
+
- Restructure docs for components, utilities, and modifiers into composable subdirectories
|
|
30
|
+
- Add Button composable recipe documentation
|
|
31
|
+
- Update plugin scanner for improved recipe handling
|
|
32
|
+
|
|
3
33
|
## 3.1.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/dist/styleframe.d.ts
CHANGED
|
@@ -36,8 +36,6 @@ export declare function classNameToCssSelector(className: string): string;
|
|
|
36
36
|
*/
|
|
37
37
|
declare type CloneFunction<T = any> = (obj: T) => T;
|
|
38
38
|
|
|
39
|
-
export declare function combineKeys(groups: string[][]): string[][];
|
|
40
|
-
|
|
41
39
|
declare type ConstructorHandler<T = any> = (obj: T, fn: CloneFunction) => T;
|
|
42
40
|
|
|
43
41
|
declare type ConstructorHandlerTuple<T = any> = [
|
|
@@ -57,7 +55,7 @@ export declare type ContainerChild = Variable | Selector | AtRule | Utility;
|
|
|
57
55
|
|
|
58
56
|
export declare type ContainerInput = Pick<Container, "declarations" | "variables" | "children">;
|
|
59
57
|
|
|
60
|
-
export declare function createAtRuleFunction(parent: Container, root: Root): (identifier: string, rule: string, declarationsOrCallback?: DeclarationsBlock | DeclarationsCallback) => AtRule;
|
|
58
|
+
export declare function createAtRuleFunction(parent: Container, root: Root): (identifier: string, rule: string, declarationsOrCallback?: DeclarationsBlock | ContainerInput | DeclarationsCallback) => AtRule;
|
|
61
59
|
|
|
62
60
|
export declare function createCssFunction(_parent: Container, _root: Root): (strings: TemplateStringsArray, ...interpolations: (TokenValue | Variable | AtRule)[]) => CSS_2;
|
|
63
61
|
|
|
@@ -65,7 +63,7 @@ export declare function createDeclarationsCallbackContext(parent: Container, roo
|
|
|
65
63
|
|
|
66
64
|
export declare function createKeyframesFunction(parent: Container, root: Root): (name: string, declarations: Record<string, DeclarationsBlock>) => AtRule;
|
|
67
65
|
|
|
68
|
-
export declare function createMediaFunction(parent: Container, root: Root): (query: string, declarationsOrCallback?: DeclarationsBlock | DeclarationsCallback) => AtRule;
|
|
66
|
+
export declare function createMediaFunction(parent: Container, root: Root): (query: string, declarationsOrCallback?: DeclarationsBlock | ContainerInput | DeclarationsCallback) => AtRule;
|
|
69
67
|
|
|
70
68
|
export declare function createModifierFunction(_parent: Container, root: Root): <Key extends string>(key: Key | Key[], factory: ModifierFactory["factory"]) => ModifierFactory;
|
|
71
69
|
|
|
@@ -260,7 +258,7 @@ declare type CSSValueWithReference<T> = T extends string | number | undefined ?
|
|
|
260
258
|
export declare type DeclarationsBlock = {
|
|
261
259
|
[K in keyof Properties]: CSSValueWithReference<Properties[K]>;
|
|
262
260
|
} & {
|
|
263
|
-
[key: string]: CSSValueWithReference<Properties[keyof Properties]> | DeclarationsBlock;
|
|
261
|
+
[key: string]: CSSValueWithReference<Properties[keyof Properties]> | DeclarationsBlock | ContainerInput;
|
|
264
262
|
};
|
|
265
263
|
|
|
266
264
|
export declare type DeclarationsCallback<Context extends DeclarationsCallbackContext = DeclarationsCallbackContext> = (context: Context) => DeclarationsBlock | void;
|
|
@@ -435,7 +433,8 @@ export declare type Recipe<Name extends string = string, Variants extends Varian
|
|
|
435
433
|
match: {
|
|
436
434
|
[K in keyof Variants]?: keyof Variants[K] & string;
|
|
437
435
|
};
|
|
438
|
-
css
|
|
436
|
+
css?: VariantDeclarationsBlock;
|
|
437
|
+
className?: string;
|
|
439
438
|
}>;
|
|
440
439
|
_runtime?: RecipeRuntime<Variants>;
|
|
441
440
|
_exportName?: string;
|
|
@@ -456,6 +455,7 @@ export declare type RecipeRuntime<Variants extends VariantsBase = VariantsBase>
|
|
|
456
455
|
[K in keyof Variants]?: keyof Variants[K] & string;
|
|
457
456
|
};
|
|
458
457
|
css?: RuntimeVariantDeclarationsBlock;
|
|
458
|
+
className?: string;
|
|
459
459
|
}>;
|
|
460
460
|
};
|
|
461
461
|
|
|
@@ -583,7 +583,7 @@ export declare type UtilityCallbackFn = DeclarationsCallback<DeclarationsCallbac
|
|
|
583
583
|
value: TokenValue;
|
|
584
584
|
}>;
|
|
585
585
|
|
|
586
|
-
export declare type UtilityCreatorFn = (values: Record<string, TokenValue> | TokenValue[], modifiers?: ModifierFactory[]) => void;
|
|
586
|
+
export declare type UtilityCreatorFn = (values: Record<string, TokenValue> | TokenValue[], modifiers?: (ModifierFactory | ModifierFactory[])[]) => void;
|
|
587
587
|
|
|
588
588
|
export declare type UtilityFactory<Name extends string = string> = {
|
|
589
589
|
type: "utility";
|
package/dist/styleframe.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
function
|
|
1
|
+
function x(e) {
|
|
2
2
|
return typeof e == "object" && e !== null;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function g(e, t) {
|
|
5
|
+
return x(e) && "type" in e && e.type === t;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function H(e) {
|
|
8
|
+
return g(e, "variable");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function A(e) {
|
|
11
|
+
return g(e, "reference");
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function _e(e) {
|
|
14
|
+
return g(e, "selector");
|
|
15
15
|
}
|
|
16
16
|
function te(e) {
|
|
17
|
-
return
|
|
17
|
+
return g(e, "at-rule");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function Ne(e) {
|
|
20
|
+
return g(e, "utility");
|
|
21
21
|
}
|
|
22
22
|
function ne(e) {
|
|
23
|
-
return
|
|
23
|
+
return g(e, "modifier");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
25
|
+
function T(e) {
|
|
26
|
+
return g(e, "css");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function Oe(e) {
|
|
29
|
+
return g(e, "theme");
|
|
30
30
|
}
|
|
31
31
|
function $(e) {
|
|
32
|
-
return
|
|
32
|
+
return g(e, "root");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function Se(e) {
|
|
35
|
+
return g(e, "recipe");
|
|
36
36
|
}
|
|
37
37
|
function re(e) {
|
|
38
38
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
39
39
|
}
|
|
40
40
|
function B(e) {
|
|
41
|
-
return re(e) ||
|
|
41
|
+
return re(e) || A(e) || T(e) || Array.isArray(e) && e.every(B);
|
|
42
|
+
}
|
|
43
|
+
function Te(e) {
|
|
44
|
+
return x(e) && "id" in e && "children" in e && "declarations" in e && "variables" in e;
|
|
42
45
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
46
|
+
function L(e) {
|
|
47
|
+
return x(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
45
48
|
}
|
|
46
49
|
function ie(e) {
|
|
47
|
-
return M(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
48
|
-
}
|
|
49
|
-
function se(e) {
|
|
50
50
|
return typeof e == "string" && e.startsWith("@");
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
52
|
+
function Be(e) {
|
|
53
|
+
return x(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && $(e.root);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function se(e) {
|
|
56
56
|
let t = 5381;
|
|
57
57
|
for (let r = 0; r < e.length; r++)
|
|
58
58
|
t = (t << 5) + t + e.charCodeAt(r) & 4294967295;
|
|
59
59
|
return (t >>> 0).toString(16).padStart(7, "0").slice(0, 7);
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function G(e) {
|
|
62
62
|
const t = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: r = (o) => o, namespace: n } = t, s = Array.isArray(n) ? n : n ? [n] : [];
|
|
63
63
|
return (o) => {
|
|
64
64
|
let i = o, f;
|
|
65
65
|
if (typeof i == "string" && i[0] === "@") {
|
|
66
66
|
const c = i.slice(1), a = s.find(
|
|
67
|
-
(
|
|
67
|
+
(y) => c === y || c.startsWith(`${y}.`)
|
|
68
68
|
);
|
|
69
69
|
let l, u;
|
|
70
70
|
a ? (l = c, u = c.startsWith(`${a}.`) ? c.slice(a.length + 1) : c) : s.length > 0 ? (l = `${s[0]}.${c}`, u = c) : (l = c, u = c), f = r(u), i = {
|
|
71
71
|
type: "reference",
|
|
72
72
|
name: l
|
|
73
73
|
};
|
|
74
|
-
} else if (
|
|
74
|
+
} else if (A(i)) {
|
|
75
75
|
let c = i.name;
|
|
76
76
|
for (const a of s)
|
|
77
77
|
if (c.startsWith(`${a}.`)) {
|
|
@@ -81,14 +81,14 @@ function q(e) {
|
|
|
81
81
|
f = r(c);
|
|
82
82
|
} else {
|
|
83
83
|
const c = String(o).trim();
|
|
84
|
-
/\s/.test(c) ? f =
|
|
84
|
+
/\s/.test(c) ? f = se(c) : f = `[${c}]`;
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
87
|
[f]: i
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const Pe = ({
|
|
92
92
|
name: e,
|
|
93
93
|
value: t,
|
|
94
94
|
modifiers: r
|
|
@@ -104,7 +104,7 @@ function z(e) {
|
|
|
104
104
|
t.push(e.slice(r, n.index)), t.push({ type: "reference", name: n[1] }), r = _.lastIndex;
|
|
105
105
|
return t.push(e.slice(r)), t;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function oe(e, t, r) {
|
|
108
108
|
let n = t;
|
|
109
109
|
for (; n; ) {
|
|
110
110
|
if (n.variables.some((s) => s.name === e))
|
|
@@ -116,28 +116,28 @@ function ce(e, t, r) {
|
|
|
116
116
|
}
|
|
117
117
|
return !1;
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
if (!
|
|
119
|
+
function ce(e, t, r) {
|
|
120
|
+
if (!oe(e, t, r))
|
|
121
121
|
throw new Error(
|
|
122
122
|
`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function C(e, t) {
|
|
126
126
|
return function(n) {
|
|
127
127
|
if (typeof n != "string" || !n.includes("@"))
|
|
128
128
|
return n;
|
|
129
|
-
if (
|
|
129
|
+
if (ie(n) && /^@[\w.-]+$/.test(n)) {
|
|
130
130
|
const i = n.slice(1);
|
|
131
|
-
return
|
|
131
|
+
return ce(i, e, t), { type: "reference", name: i };
|
|
132
132
|
}
|
|
133
133
|
const s = z(n);
|
|
134
|
-
return s.some((i) =>
|
|
134
|
+
return s.some((i) => A(i)) ? { type: "css", value: s } : n;
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function q(e, t) {
|
|
138
138
|
return function(n, s) {
|
|
139
|
-
const o =
|
|
140
|
-
if (
|
|
139
|
+
const o = C(e, t), i = s != null ? o(s) : s;
|
|
140
|
+
if (H(n))
|
|
141
141
|
return {
|
|
142
142
|
type: "reference",
|
|
143
143
|
name: n.name,
|
|
@@ -154,28 +154,28 @@ function X(e, t) {
|
|
|
154
154
|
};
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
const r =
|
|
157
|
+
function fe(e, t) {
|
|
158
|
+
const r = q(e, t);
|
|
159
159
|
return function(s, ...o) {
|
|
160
160
|
return {
|
|
161
161
|
type: "css",
|
|
162
162
|
value: s.reduce((f, c, a) => {
|
|
163
163
|
if (f.push(...z(c)), a < o.length) {
|
|
164
164
|
const l = o[a];
|
|
165
|
-
|
|
165
|
+
H(l) ? f.push(r(l)) : te(l) ? f.push(l.rule) : f.push(l);
|
|
166
166
|
}
|
|
167
167
|
return f;
|
|
168
168
|
}, [])
|
|
169
169
|
};
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function Ue(e) {
|
|
173
173
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function De(e) {
|
|
176
176
|
return `.${e.replace(/[[\].#()%,:/]/g, "\\$&")}`;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function j(e) {
|
|
179
179
|
if (e instanceof Buffer)
|
|
180
180
|
return Buffer.from(e);
|
|
181
181
|
const t = e.constructor;
|
|
@@ -185,9 +185,9 @@ function v(e) {
|
|
|
185
185
|
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function ae(e) {
|
|
189
189
|
if (e = e || {}, e.circular)
|
|
190
|
-
return
|
|
190
|
+
return ue(e);
|
|
191
191
|
const t = /* @__PURE__ */ new Map();
|
|
192
192
|
if (t.set(Date, (i) => new Date(i)), t.set(
|
|
193
193
|
Map,
|
|
@@ -203,8 +203,8 @@ function ue(e) {
|
|
|
203
203
|
function n(i, f) {
|
|
204
204
|
const c = Object.keys(i), a = Array.from({ length: c.length });
|
|
205
205
|
for (let l = 0; l < c.length; l++) {
|
|
206
|
-
const u = c[l],
|
|
207
|
-
typeof
|
|
206
|
+
const u = c[l], y = i[u];
|
|
207
|
+
typeof y != "object" || y === null ? a[u] = y : y.constructor !== Object && (r = t.get(y.constructor)) ? a[u] = r(y, f) : ArrayBuffer.isView(y) ? a[u] = j(y) : a[u] = f(y);
|
|
208
208
|
}
|
|
209
209
|
return a;
|
|
210
210
|
}
|
|
@@ -217,7 +217,7 @@ function ue(e) {
|
|
|
217
217
|
for (const c in i) {
|
|
218
218
|
if (Object.hasOwnProperty.call(i, c) === !1) continue;
|
|
219
219
|
const a = i[c];
|
|
220
|
-
typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, s) : ArrayBuffer.isView(a) ? f[c] =
|
|
220
|
+
typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, s) : ArrayBuffer.isView(a) ? f[c] = j(a) : f[c] = s(a);
|
|
221
221
|
}
|
|
222
222
|
return f;
|
|
223
223
|
}
|
|
@@ -229,12 +229,12 @@ function ue(e) {
|
|
|
229
229
|
const f = {};
|
|
230
230
|
for (const c in i) {
|
|
231
231
|
const a = i[c];
|
|
232
|
-
typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, o) : ArrayBuffer.isView(a) ? f[c] =
|
|
232
|
+
typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, o) : ArrayBuffer.isView(a) ? f[c] = j(a) : f[c] = o(a);
|
|
233
233
|
}
|
|
234
234
|
return f;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function ue(e) {
|
|
238
238
|
const t = [], r = [], n = /* @__PURE__ */ new Map();
|
|
239
239
|
if (n.set(Date, (c) => new Date(c)), n.set(
|
|
240
240
|
Map,
|
|
@@ -249,17 +249,17 @@ function le(e) {
|
|
|
249
249
|
return e.proto ? f : i;
|
|
250
250
|
function o(c, a) {
|
|
251
251
|
const l = Object.keys(c), u = Array.from({ length: l.length });
|
|
252
|
-
for (let
|
|
253
|
-
const
|
|
252
|
+
for (let y = 0; y < l.length; y++) {
|
|
253
|
+
const d = l[y], m = c[d];
|
|
254
254
|
if (typeof m != "object" || m === null)
|
|
255
|
-
u[
|
|
255
|
+
u[d] = m;
|
|
256
256
|
else if (m.constructor !== Object && (s = n.get(m.constructor)))
|
|
257
|
-
u[
|
|
257
|
+
u[d] = s(m, a);
|
|
258
258
|
else if (ArrayBuffer.isView(m))
|
|
259
|
-
u[
|
|
259
|
+
u[d] = j(m);
|
|
260
260
|
else {
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const h = t.indexOf(m);
|
|
262
|
+
h !== -1 ? u[d] = r[h] : u[d] = a(m);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
return u;
|
|
@@ -279,10 +279,10 @@ function le(e) {
|
|
|
279
279
|
else if (u.constructor !== Object && (s = n.get(u.constructor)))
|
|
280
280
|
a[l] = s(u, i);
|
|
281
281
|
else if (ArrayBuffer.isView(u))
|
|
282
|
-
a[l] =
|
|
282
|
+
a[l] = j(u);
|
|
283
283
|
else {
|
|
284
|
-
const
|
|
285
|
-
|
|
284
|
+
const y = t.indexOf(u);
|
|
285
|
+
y !== -1 ? a[l] = r[y] : a[l] = i(u);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
return t.pop(), r.pop(), a;
|
|
@@ -301,17 +301,17 @@ function le(e) {
|
|
|
301
301
|
else if (u.constructor !== Object && (s = n.get(u.constructor)))
|
|
302
302
|
a[l] = s(u, f);
|
|
303
303
|
else if (ArrayBuffer.isView(u))
|
|
304
|
-
a[l] =
|
|
304
|
+
a[l] = j(u);
|
|
305
305
|
else {
|
|
306
|
-
const
|
|
307
|
-
|
|
306
|
+
const y = t.indexOf(u);
|
|
307
|
+
y !== -1 ? a[l] = r[y] : a[l] = f(u);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
return t.pop(), r.pop(), a;
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
function
|
|
313
|
+
const M = ae();
|
|
314
|
+
function b(e, t = 8) {
|
|
315
315
|
const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
316
316
|
let n = "";
|
|
317
317
|
for (let s = 0; s < t; s++) {
|
|
@@ -320,7 +320,7 @@ function w(e, t = 8) {
|
|
|
320
320
|
}
|
|
321
321
|
return e ? `${e}${n}` : n;
|
|
322
322
|
}
|
|
323
|
-
function
|
|
323
|
+
function Ce(e, t) {
|
|
324
324
|
const r = e.variables.find((n) => n.name === t);
|
|
325
325
|
if (!r)
|
|
326
326
|
throw new Error(`Variable "${t}" not found`);
|
|
@@ -332,7 +332,7 @@ function Ie(e, t) {
|
|
|
332
332
|
throw new Error(`Utility "${t}" not found`);
|
|
333
333
|
return r;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function le(e, t) {
|
|
336
336
|
const r = e.modifiers.find(
|
|
337
337
|
(n) => n.key.includes(t)
|
|
338
338
|
);
|
|
@@ -340,25 +340,25 @@ function de(e, t) {
|
|
|
340
340
|
throw new Error(`Modifier "${t}" not found`);
|
|
341
341
|
return r;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function N(e, t) {
|
|
344
344
|
if (e === t) return !0;
|
|
345
345
|
if (typeof e != typeof t) return !1;
|
|
346
346
|
if (e === null || t === null) return e === t;
|
|
347
347
|
if (typeof e != "object" || typeof t != "object") return !1;
|
|
348
348
|
if (Array.isArray(e) && Array.isArray(t))
|
|
349
|
-
return e.length !== t.length ? !1 : e.every((r, n) =>
|
|
349
|
+
return e.length !== t.length ? !1 : e.every((r, n) => N(r, t[n]));
|
|
350
350
|
if ("type" in e && "type" in t) {
|
|
351
351
|
if (e.type !== t.type) return !1;
|
|
352
|
-
if (
|
|
353
|
-
return e.name === t.name &&
|
|
354
|
-
if (
|
|
355
|
-
return
|
|
352
|
+
if (A(e) && A(t))
|
|
353
|
+
return e.name === t.name && N(e.fallback, t.fallback);
|
|
354
|
+
if (T(e) && T(t))
|
|
355
|
+
return N(e.value, t.value);
|
|
356
356
|
}
|
|
357
357
|
return !1;
|
|
358
358
|
}
|
|
359
|
-
const
|
|
359
|
+
const X = "__licenseRequired";
|
|
360
360
|
function ye(e) {
|
|
361
|
-
P(e) || Object.defineProperty(e,
|
|
361
|
+
P(e) || Object.defineProperty(e, X, {
|
|
362
362
|
value: !0,
|
|
363
363
|
writable: !1,
|
|
364
364
|
configurable: !1,
|
|
@@ -366,9 +366,9 @@ function ye(e) {
|
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
368
|
function P(e) {
|
|
369
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
369
|
+
return Object.prototype.hasOwnProperty.call(e, X);
|
|
370
370
|
}
|
|
371
|
-
function
|
|
371
|
+
function de(e, t) {
|
|
372
372
|
const r = [...e];
|
|
373
373
|
for (const n of t) {
|
|
374
374
|
const s = r.find(
|
|
@@ -378,7 +378,7 @@ function me(e, t) {
|
|
|
378
378
|
}
|
|
379
379
|
return r;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function me(e, t) {
|
|
382
382
|
const r = [...e];
|
|
383
383
|
for (const n of t) {
|
|
384
384
|
const s = r.find(
|
|
@@ -386,14 +386,14 @@ function pe(e, t) {
|
|
|
386
386
|
);
|
|
387
387
|
s ? Object.assign(
|
|
388
388
|
s,
|
|
389
|
-
|
|
389
|
+
Y(s, n)
|
|
390
390
|
) : r.push(n);
|
|
391
391
|
}
|
|
392
392
|
return r;
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function Y(e, t) {
|
|
395
395
|
return Object.keys(e).reduce(
|
|
396
|
-
(r, n) => (n === "variables" ? r.variables =
|
|
396
|
+
(r, n) => (n === "variables" ? r.variables = de(e.variables, t.variables) : n === "declarations" ? r.declarations = { ...e.declarations, ...t.declarations } : n === "themes" && $(r) && $(e) && $(t) ? r.themes = me(e.themes, t.themes) : Array.isArray(e[n]) && (r[n] = e[n].concat(
|
|
397
397
|
t[n]
|
|
398
398
|
)), r),
|
|
399
399
|
{
|
|
@@ -402,29 +402,29 @@ function Z(e, t) {
|
|
|
402
402
|
}
|
|
403
403
|
);
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function U(e, t) {
|
|
406
406
|
for (const r of e)
|
|
407
|
-
"id" in r && typeof r.id == "string" && (t._registry.set(r.id, r), "children" in r &&
|
|
407
|
+
"id" in r && typeof r.id == "string" && (t._registry.set(r.id, r), "children" in r && U(r.children, t));
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
e._registry = /* @__PURE__ */ new Map(), e._registry.set(e.id, e),
|
|
409
|
+
function pe(e) {
|
|
410
|
+
e._registry = /* @__PURE__ */ new Map(), e._registry.set(e.id, e), U(e.children, e);
|
|
411
411
|
for (const t of e.themes)
|
|
412
|
-
e._registry.set(t.id, t),
|
|
412
|
+
e._registry.set(t.id, t), U(t.children, e);
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Ke(e, ...t) {
|
|
415
415
|
return t.reduce((r, n) => {
|
|
416
416
|
const s = {
|
|
417
417
|
...r,
|
|
418
|
-
root:
|
|
418
|
+
root: Y(r.root, n.root)
|
|
419
419
|
};
|
|
420
|
-
return
|
|
420
|
+
return pe(s.root), (P(r) || P(n)) && ye(s), s;
|
|
421
421
|
}, e);
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function I(e, t) {
|
|
424
424
|
return function(n, s, o) {
|
|
425
425
|
const i = {
|
|
426
426
|
type: "at-rule",
|
|
427
|
-
id:
|
|
427
|
+
id: b("ar-"),
|
|
428
428
|
parentId: e.id,
|
|
429
429
|
identifier: n,
|
|
430
430
|
rule: s,
|
|
@@ -433,8 +433,8 @@ function D(e, t) {
|
|
|
433
433
|
children: []
|
|
434
434
|
};
|
|
435
435
|
t._registry.set(i.id, i);
|
|
436
|
-
const f =
|
|
437
|
-
return typeof o == "function" ? i.declarations = o(f) ?? {} : o && (i.declarations = o),
|
|
436
|
+
const f = v(i, t);
|
|
437
|
+
return typeof o == "function" ? i.declarations = o(f) ?? {} : L(o) ? (i.variables = o.variables, i.declarations = o.declarations, i.children = o.children) : o && (i.declarations = o), E(
|
|
438
438
|
i.declarations,
|
|
439
439
|
f,
|
|
440
440
|
i,
|
|
@@ -442,23 +442,23 @@ function D(e, t) {
|
|
|
442
442
|
), e.children.push(i), i;
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
function
|
|
446
|
-
const r =
|
|
445
|
+
function he(e, t) {
|
|
446
|
+
const r = I(e, t);
|
|
447
447
|
return function(s, o) {
|
|
448
448
|
return r("media", s, o);
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
function
|
|
452
|
-
const r =
|
|
451
|
+
function ge(e, t) {
|
|
452
|
+
const r = I(e, t);
|
|
453
453
|
return function(s, o) {
|
|
454
454
|
return r("keyframes", s, o);
|
|
455
455
|
};
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function be(e, t) {
|
|
458
458
|
return function(n, s) {
|
|
459
459
|
const o = {
|
|
460
460
|
type: "selector",
|
|
461
|
-
id:
|
|
461
|
+
id: b("sel-"),
|
|
462
462
|
parentId: e.id,
|
|
463
463
|
query: n,
|
|
464
464
|
declarations: {},
|
|
@@ -466,8 +466,8 @@ function Ae(e, t) {
|
|
|
466
466
|
children: []
|
|
467
467
|
};
|
|
468
468
|
t._registry.set(o.id, o);
|
|
469
|
-
const i =
|
|
470
|
-
return typeof s == "function" ? o.declarations = s(i) ?? {} :
|
|
469
|
+
const i = v(o, t);
|
|
470
|
+
return typeof s == "function" ? o.declarations = s(i) ?? {} : L(s) ? (o.variables = s.variables, o.declarations = s.declarations, o.children = s.children) : o.declarations = s, E(
|
|
471
471
|
o.declarations,
|
|
472
472
|
i,
|
|
473
473
|
o,
|
|
@@ -475,11 +475,11 @@ function Ae(e, t) {
|
|
|
475
475
|
), e.children.push(o), o;
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function Ae(e, t) {
|
|
479
479
|
return function(n, s, o = {
|
|
480
480
|
default: !1
|
|
481
481
|
}) {
|
|
482
|
-
const i = typeof n == "string" ? n : n.name, c =
|
|
482
|
+
const i = typeof n == "string" ? n : n.name, c = C(e, t)(s), a = e.variables.find(
|
|
483
483
|
(u) => u.name === i
|
|
484
484
|
);
|
|
485
485
|
if (o.default && a)
|
|
@@ -488,7 +488,7 @@ function we(e, t) {
|
|
|
488
488
|
return a.value = c, a;
|
|
489
489
|
const l = {
|
|
490
490
|
type: "variable",
|
|
491
|
-
id:
|
|
491
|
+
id: b("var-"),
|
|
492
492
|
parentId: e.id,
|
|
493
493
|
name: i,
|
|
494
494
|
value: c
|
|
@@ -496,8 +496,8 @@ function we(e, t) {
|
|
|
496
496
|
return e.variables.push(l), l;
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
function
|
|
500
|
-
const r =
|
|
499
|
+
function v(e, t) {
|
|
500
|
+
const r = Ae(e, t), n = be(e, t), s = I(e, t), o = ge(t, t), i = he(e, t), f = q(t, t), c = fe(t, t);
|
|
501
501
|
return {
|
|
502
502
|
variable: r,
|
|
503
503
|
selector: n,
|
|
@@ -508,7 +508,7 @@ function V(e, t) {
|
|
|
508
508
|
css: c
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function E(e, t, r, n) {
|
|
512
512
|
for (const o in e)
|
|
513
513
|
if (o.startsWith("@")) {
|
|
514
514
|
const i = e[o];
|
|
@@ -516,11 +516,11 @@ function x(e, t, r, n) {
|
|
|
516
516
|
const f = o.replace(/^@(\w+).*/, "$1"), c = o.replace(`@${f}`, "").trim();
|
|
517
517
|
t.atRule(f, c, i), delete e[o];
|
|
518
518
|
}
|
|
519
|
-
} else if (/^[.&:]/.test(o) ||
|
|
519
|
+
} else if (/^[.&:]/.test(o) || /^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(o)) {
|
|
520
520
|
const i = e[o];
|
|
521
521
|
typeof i == "object" && (t.selector(o, i), delete e[o]);
|
|
522
522
|
}
|
|
523
|
-
const s =
|
|
523
|
+
const s = C(r, n);
|
|
524
524
|
for (const o in e) {
|
|
525
525
|
const i = e[o];
|
|
526
526
|
if (B(i)) {
|
|
@@ -530,55 +530,41 @@ function x(e, t, r, n) {
|
|
|
530
530
|
}
|
|
531
531
|
return e;
|
|
532
532
|
}
|
|
533
|
-
function je(e) {
|
|
534
|
-
const t = [];
|
|
535
|
-
function r(n, s) {
|
|
536
|
-
s.length > 0 && t.push([...s].sort());
|
|
537
|
-
for (let o = n; o < e.length; o++) {
|
|
538
|
-
const i = e[o];
|
|
539
|
-
if (i)
|
|
540
|
-
if (i.length === 1 && i[0])
|
|
541
|
-
r(o + 1, [...s, i[0]]);
|
|
542
|
-
else
|
|
543
|
-
for (const f of i)
|
|
544
|
-
r(o + 1, [...s, f]);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return r(0, []), t.sort((n, s) => n.length !== s.length ? n.length - s.length : n.join(",").localeCompare(s.join(",")));
|
|
548
|
-
}
|
|
549
533
|
function ve(e, t, r) {
|
|
550
534
|
const n = {
|
|
551
535
|
...e,
|
|
552
|
-
id:
|
|
536
|
+
id: b("ut-"),
|
|
553
537
|
parentId: e.parentId,
|
|
554
538
|
declarations: { ...e.declarations },
|
|
555
539
|
variables: [...e.variables],
|
|
556
540
|
children: [...e.children],
|
|
557
541
|
modifiers: [...r.keys()]
|
|
558
542
|
};
|
|
559
|
-
t._registry.set(n.id, n)
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
let
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
children: R(n.children)
|
|
543
|
+
if (t._registry.set(n.id, n), r.size > 0) {
|
|
544
|
+
const s = [...r.values()];
|
|
545
|
+
let o = M(e.declarations);
|
|
546
|
+
n.declarations = {}, n.variables = [], n.children = [];
|
|
547
|
+
for (let f = s.length - 1; f >= 0; f--) {
|
|
548
|
+
const c = v(n, t), a = s[f]?.factory({
|
|
549
|
+
...c,
|
|
550
|
+
declarations: M(o),
|
|
551
|
+
variables: M(e.variables),
|
|
552
|
+
children: M(e.children)
|
|
570
553
|
});
|
|
571
|
-
|
|
572
|
-
n.declarations,
|
|
573
|
-
s,
|
|
574
|
-
n,
|
|
575
|
-
t
|
|
576
|
-
));
|
|
554
|
+
a && (o = a);
|
|
577
555
|
}
|
|
556
|
+
n.declarations = o;
|
|
557
|
+
const i = v(n, t);
|
|
558
|
+
E(
|
|
559
|
+
n.declarations,
|
|
560
|
+
i,
|
|
561
|
+
n,
|
|
562
|
+
t
|
|
563
|
+
);
|
|
578
564
|
}
|
|
579
565
|
return n;
|
|
580
566
|
}
|
|
581
|
-
function
|
|
567
|
+
function we(e, t) {
|
|
582
568
|
return function(n, s) {
|
|
583
569
|
const o = {
|
|
584
570
|
type: "modifier",
|
|
@@ -588,10 +574,10 @@ function Ve(e, t) {
|
|
|
588
574
|
return t.modifiers.push(o), o;
|
|
589
575
|
};
|
|
590
576
|
}
|
|
591
|
-
function
|
|
577
|
+
function je() {
|
|
592
578
|
const e = {
|
|
593
579
|
type: "root",
|
|
594
|
-
id:
|
|
580
|
+
id: b("rt-"),
|
|
595
581
|
declarations: {},
|
|
596
582
|
utilities: [],
|
|
597
583
|
modifiers: [],
|
|
@@ -603,8 +589,8 @@ function ke() {
|
|
|
603
589
|
};
|
|
604
590
|
return e._registry.set(e.id, e), e;
|
|
605
591
|
}
|
|
606
|
-
function
|
|
607
|
-
const r =
|
|
592
|
+
function Ve(e, t) {
|
|
593
|
+
const r = G({ namespace: e });
|
|
608
594
|
return (n) => {
|
|
609
595
|
if (typeof n == "string" && n[0] === "@") {
|
|
610
596
|
const s = n.slice(1), o = e.find(
|
|
@@ -619,7 +605,7 @@ function Re(e, t) {
|
|
|
619
605
|
name: s
|
|
620
606
|
}
|
|
621
607
|
};
|
|
622
|
-
} else
|
|
608
|
+
} else {
|
|
623
609
|
for (const i of e) {
|
|
624
610
|
const f = `${i}.${s}`;
|
|
625
611
|
if (t.variables.some((c) => c.name === f))
|
|
@@ -630,12 +616,34 @@ function Re(e, t) {
|
|
|
630
616
|
}
|
|
631
617
|
};
|
|
632
618
|
}
|
|
619
|
+
if (t.variables.some((i) => i.name === s))
|
|
620
|
+
return {
|
|
621
|
+
[s]: {
|
|
622
|
+
type: "reference",
|
|
623
|
+
name: s
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
633
627
|
return r(n);
|
|
634
628
|
}
|
|
635
629
|
return r(n);
|
|
636
630
|
};
|
|
637
631
|
}
|
|
638
|
-
function
|
|
632
|
+
function Re(e) {
|
|
633
|
+
let t = [/* @__PURE__ */ new Map()];
|
|
634
|
+
for (const r of e) {
|
|
635
|
+
if (!ne(r)) continue;
|
|
636
|
+
const n = [];
|
|
637
|
+
for (const s of r.key)
|
|
638
|
+
for (const o of t) {
|
|
639
|
+
const i = new Map(o);
|
|
640
|
+
i.set(s, r), n.push(i);
|
|
641
|
+
}
|
|
642
|
+
t = n;
|
|
643
|
+
}
|
|
644
|
+
return t.filter((r) => r.size > 0);
|
|
645
|
+
}
|
|
646
|
+
function ke(e, t) {
|
|
639
647
|
return function(n, s, o = {}) {
|
|
640
648
|
const i = t.utilities.find((c) => c.name === n);
|
|
641
649
|
if (i)
|
|
@@ -645,7 +653,7 @@ function $e(e, t) {
|
|
|
645
653
|
name: n,
|
|
646
654
|
factory: s,
|
|
647
655
|
values: [],
|
|
648
|
-
autogenerate: o.autogenerate ?? (Array.isArray(o.namespace) ?
|
|
656
|
+
autogenerate: o.autogenerate ?? (Array.isArray(o.namespace) ? Ve(o.namespace, t) : G(
|
|
649
657
|
o.namespace ? { namespace: o.namespace } : void 0
|
|
650
658
|
)),
|
|
651
659
|
namespace: o.namespace,
|
|
@@ -654,42 +662,45 @@ function $e(e, t) {
|
|
|
654
662
|
if (Array.isArray(c)) {
|
|
655
663
|
l = {};
|
|
656
664
|
for (const u of c) {
|
|
657
|
-
const
|
|
665
|
+
const y = f.autogenerate(u);
|
|
658
666
|
l = {
|
|
659
667
|
...l,
|
|
660
|
-
...
|
|
668
|
+
...y
|
|
661
669
|
};
|
|
662
670
|
}
|
|
663
671
|
}
|
|
664
|
-
for (const [u,
|
|
665
|
-
let
|
|
666
|
-
if (typeof
|
|
667
|
-
const
|
|
668
|
-
!Array.isArray(l) &&
|
|
672
|
+
for (const [u, y] of Object.entries(l)) {
|
|
673
|
+
let d = y;
|
|
674
|
+
if (typeof y == "string" && y[0] === "@") {
|
|
675
|
+
const p = y.slice(1);
|
|
676
|
+
!Array.isArray(l) && p in l && (d = l[p]);
|
|
669
677
|
}
|
|
670
|
-
if (f.namespace &&
|
|
671
|
-
if (t.variables.some((
|
|
672
|
-
|
|
678
|
+
if (f.namespace && A(y))
|
|
679
|
+
if (t.variables.some((p) => p.name === y.name))
|
|
680
|
+
d = y;
|
|
673
681
|
else {
|
|
674
|
-
const
|
|
675
|
-
let
|
|
676
|
-
for (const
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
679
|
-
|
|
682
|
+
const p = Array.isArray(f.namespace) ? f.namespace : [f.namespace];
|
|
683
|
+
let k = !1;
|
|
684
|
+
for (const V of p) {
|
|
685
|
+
const w = `${V}.${u}`;
|
|
686
|
+
if (w !== y.name && t.variables.some((R) => R.name === w)) {
|
|
687
|
+
d = {
|
|
680
688
|
type: "reference",
|
|
681
|
-
name:
|
|
682
|
-
},
|
|
689
|
+
name: w
|
|
690
|
+
}, k = !0;
|
|
683
691
|
break;
|
|
684
692
|
}
|
|
685
693
|
}
|
|
686
|
-
|
|
694
|
+
k || (t.variables.some((V) => V.name === u) ? d = {
|
|
695
|
+
type: "reference",
|
|
696
|
+
name: u
|
|
697
|
+
} : d = u);
|
|
687
698
|
}
|
|
688
699
|
const m = f.values.find(
|
|
689
|
-
(
|
|
690
|
-
),
|
|
700
|
+
(p) => p.key === u && p.modifiers.length === 0
|
|
701
|
+
), h = {
|
|
691
702
|
type: "utility",
|
|
692
|
-
id:
|
|
703
|
+
id: b("ut-"),
|
|
693
704
|
parentId: e.id,
|
|
694
705
|
name: n,
|
|
695
706
|
value: u,
|
|
@@ -698,42 +709,41 @@ function $e(e, t) {
|
|
|
698
709
|
children: [],
|
|
699
710
|
modifiers: []
|
|
700
711
|
};
|
|
701
|
-
t._registry.set(
|
|
702
|
-
const
|
|
703
|
-
|
|
712
|
+
t._registry.set(h.id, h);
|
|
713
|
+
const K = v(
|
|
714
|
+
h,
|
|
704
715
|
t
|
|
705
716
|
);
|
|
706
|
-
if (
|
|
707
|
-
...
|
|
708
|
-
value:
|
|
709
|
-
}) ?? {},
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
717
|
+
if (h.declarations = s({
|
|
718
|
+
...K,
|
|
719
|
+
value: d
|
|
720
|
+
}) ?? {}, E(
|
|
721
|
+
h.declarations,
|
|
722
|
+
K,
|
|
723
|
+
h,
|
|
713
724
|
t
|
|
714
725
|
), m || (f.values.push({
|
|
715
726
|
key: u,
|
|
716
|
-
value:
|
|
727
|
+
value: d,
|
|
717
728
|
modifiers: []
|
|
718
|
-
}), e.children.push(
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
729
|
+
}), e.children.push(h)), a && a.length > 0)
|
|
730
|
+
for (const p of a) {
|
|
731
|
+
const k = Array.isArray(p) ? p : [p], V = Re(k);
|
|
732
|
+
for (const w of V) {
|
|
733
|
+
const R = [...w.keys()];
|
|
734
|
+
f.values.find(
|
|
735
|
+
(F) => F.key === u && F.modifiers.length === R.length && F.modifiers.every(
|
|
736
|
+
(Q, ee) => Q === R[ee]
|
|
737
|
+
)
|
|
738
|
+
) || (f.values.push({
|
|
739
|
+
key: u,
|
|
740
|
+
value: d,
|
|
741
|
+
modifiers: R
|
|
742
|
+
}), e.children.push(
|
|
743
|
+
ve(h, t, w)
|
|
744
|
+
));
|
|
728
745
|
}
|
|
729
|
-
|
|
730
|
-
key: u,
|
|
731
|
-
value: y,
|
|
732
|
-
modifiers: A
|
|
733
|
-
}), g.push(ve(p, t, k)), g;
|
|
734
|
-
}, []);
|
|
735
|
-
e.children.push(...O);
|
|
736
|
-
}
|
|
746
|
+
}
|
|
737
747
|
}
|
|
738
748
|
}
|
|
739
749
|
};
|
|
@@ -744,7 +754,7 @@ function Me(e, t) {
|
|
|
744
754
|
return function(n, s) {
|
|
745
755
|
const o = t.themes.find((c) => c.name === n), i = o ?? {
|
|
746
756
|
type: "theme",
|
|
747
|
-
id:
|
|
757
|
+
id: b("th-"),
|
|
748
758
|
parentId: t.id,
|
|
749
759
|
name: n,
|
|
750
760
|
declarations: {},
|
|
@@ -752,62 +762,62 @@ function Me(e, t) {
|
|
|
752
762
|
children: []
|
|
753
763
|
};
|
|
754
764
|
o || (t._registry.set(i.id, i), t.themes.push(i));
|
|
755
|
-
const f =
|
|
765
|
+
const f = v(i, t);
|
|
756
766
|
return s && s(f), i;
|
|
757
767
|
};
|
|
758
768
|
}
|
|
759
|
-
function
|
|
769
|
+
function $e(e, t) {
|
|
760
770
|
return function(n) {
|
|
761
771
|
const s = {
|
|
762
772
|
type: "recipe",
|
|
763
773
|
...n
|
|
764
774
|
};
|
|
765
|
-
return s._runtime =
|
|
775
|
+
return s._runtime = xe(s, t), Ee(s, t), t.recipes.push(s), s;
|
|
766
776
|
};
|
|
767
777
|
}
|
|
768
|
-
function
|
|
778
|
+
function W(e, t) {
|
|
769
779
|
const r = e.autogenerate(t);
|
|
770
780
|
return Object.keys(r)[0] ?? "default";
|
|
771
781
|
}
|
|
772
|
-
function
|
|
782
|
+
function O(e, t) {
|
|
773
783
|
const r = {};
|
|
774
784
|
for (const [n, s] of Object.entries(e))
|
|
775
|
-
if (
|
|
785
|
+
if (Z(s)) {
|
|
776
786
|
const o = {};
|
|
777
787
|
for (const [i, f] of Object.entries(s)) {
|
|
778
|
-
const c =
|
|
788
|
+
const c = D(t, i);
|
|
779
789
|
if (!c)
|
|
780
790
|
throw new Error(
|
|
781
791
|
`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`
|
|
782
792
|
);
|
|
783
|
-
o[i] =
|
|
793
|
+
o[i] = W(
|
|
784
794
|
c,
|
|
785
795
|
f
|
|
786
796
|
);
|
|
787
797
|
}
|
|
788
|
-
r[
|
|
798
|
+
r[J(n)] = o;
|
|
789
799
|
} else if (typeof s == "boolean")
|
|
790
800
|
r[n] = s;
|
|
791
801
|
else {
|
|
792
|
-
const o =
|
|
802
|
+
const o = D(t, n);
|
|
793
803
|
if (!o)
|
|
794
804
|
throw new Error(
|
|
795
805
|
`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`
|
|
796
806
|
);
|
|
797
|
-
r[n] =
|
|
807
|
+
r[n] = W(o, s);
|
|
798
808
|
}
|
|
799
809
|
return r;
|
|
800
810
|
}
|
|
801
|
-
function
|
|
811
|
+
function xe(e, t) {
|
|
802
812
|
const r = {};
|
|
803
|
-
if (e.base && (r.base =
|
|
813
|
+
if (e.base && (r.base = O(e.base, t)), e.variants) {
|
|
804
814
|
const n = {};
|
|
805
815
|
for (const [s, o] of Object.entries(e.variants)) {
|
|
806
816
|
const i = {};
|
|
807
817
|
for (const [f, c] of Object.entries(
|
|
808
818
|
o
|
|
809
819
|
))
|
|
810
|
-
c == null ? i[f] = null : i[f] =
|
|
820
|
+
c == null ? i[f] = null : i[f] = O(
|
|
811
821
|
c,
|
|
812
822
|
t
|
|
813
823
|
);
|
|
@@ -817,50 +827,51 @@ function Ee(e, t) {
|
|
|
817
827
|
}
|
|
818
828
|
return e.defaultVariants && (r.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (r.compoundVariants = e.compoundVariants.map((n) => ({
|
|
819
829
|
match: { ...n.match },
|
|
820
|
-
css:
|
|
830
|
+
...n.css ? { css: O(n.css, t) } : {},
|
|
831
|
+
...n.className ? { className: n.className } : {}
|
|
821
832
|
}))), r;
|
|
822
833
|
}
|
|
823
|
-
function
|
|
824
|
-
return !
|
|
834
|
+
function Z(e) {
|
|
835
|
+
return !A(e) && typeof e == "object" && e !== null;
|
|
825
836
|
}
|
|
826
|
-
function
|
|
837
|
+
function J(e) {
|
|
827
838
|
return e.startsWith("&::") ? e.slice(3) : e.startsWith("&:") ? e.slice(2) : e;
|
|
828
839
|
}
|
|
829
|
-
function
|
|
840
|
+
function S(e, t) {
|
|
830
841
|
const r = (n, s, o) => {
|
|
831
842
|
let i = t.get(n);
|
|
832
843
|
i || (i = [], t.set(n, i)), i.push({ value: s, modifiers: o });
|
|
833
844
|
};
|
|
834
845
|
for (const [n, s] of Object.entries(e))
|
|
835
|
-
if (
|
|
836
|
-
const o =
|
|
846
|
+
if (Z(s)) {
|
|
847
|
+
const o = J(n).split(":");
|
|
837
848
|
for (const [i, f] of Object.entries(s))
|
|
838
849
|
r(i, f, o);
|
|
839
850
|
} else
|
|
840
851
|
r(n, s, []);
|
|
841
852
|
}
|
|
842
|
-
function
|
|
853
|
+
function D(e, t) {
|
|
843
854
|
const r = e.utilities.find((s) => s.name === t);
|
|
844
855
|
if (r)
|
|
845
856
|
return r;
|
|
846
857
|
const n = t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
|
847
858
|
return e.utilities.find((s) => s.name === n);
|
|
848
859
|
}
|
|
849
|
-
function
|
|
860
|
+
function Ee(e, t) {
|
|
850
861
|
const r = /* @__PURE__ */ new Map();
|
|
851
|
-
if (e.base &&
|
|
862
|
+
if (e.base && S(e.base, r), e.variants)
|
|
852
863
|
for (const s of Object.values(e.variants))
|
|
853
864
|
for (const o of Object.values(s))
|
|
854
|
-
|
|
865
|
+
S(
|
|
855
866
|
o,
|
|
856
867
|
r
|
|
857
868
|
);
|
|
858
869
|
if (e.compoundVariants)
|
|
859
870
|
for (const s of e.compoundVariants)
|
|
860
|
-
s.css &&
|
|
871
|
+
s.css && S(s.css, r);
|
|
861
872
|
const n = /* @__PURE__ */ new Map();
|
|
862
873
|
for (const [s, o] of r) {
|
|
863
|
-
const i =
|
|
874
|
+
const i = D(t, s);
|
|
864
875
|
if (!i)
|
|
865
876
|
throw new Error(
|
|
866
877
|
`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`
|
|
@@ -870,7 +881,7 @@ function Oe(e, t) {
|
|
|
870
881
|
for (const a of f.modifiers) {
|
|
871
882
|
if (!n.has(a))
|
|
872
883
|
try {
|
|
873
|
-
n.set(a,
|
|
884
|
+
n.set(a, le(t, a));
|
|
874
885
|
} catch {
|
|
875
886
|
throw new Error(
|
|
876
887
|
`[styleframe] Modifier "${a}" not found in registry. Make sure the modifier is registered before using it in a recipe.`
|
|
@@ -881,13 +892,13 @@ function Oe(e, t) {
|
|
|
881
892
|
}
|
|
882
893
|
i.create(
|
|
883
894
|
[f.value],
|
|
884
|
-
c.length > 0 ? c : void 0
|
|
895
|
+
c.length > 0 ? c.length > 1 ? [c] : c : void 0
|
|
885
896
|
);
|
|
886
897
|
}
|
|
887
898
|
}
|
|
888
899
|
}
|
|
889
900
|
function We(e) {
|
|
890
|
-
const t =
|
|
901
|
+
const t = b("sf-"), r = je(), n = { ...e }, s = ke(r, r), o = we(r, r), i = $e(r, r), f = Me(r, r), { variable: c, selector: a, atRule: l, keyframes: u, media: y, ref: d, css: m } = v(r, r);
|
|
891
902
|
return {
|
|
892
903
|
id: t,
|
|
893
904
|
root: r,
|
|
@@ -899,69 +910,68 @@ function We(e) {
|
|
|
899
910
|
theme: f,
|
|
900
911
|
atRule: l,
|
|
901
912
|
keyframes: u,
|
|
902
|
-
media:
|
|
903
|
-
ref:
|
|
913
|
+
media: y,
|
|
914
|
+
ref: d,
|
|
904
915
|
css: m,
|
|
905
916
|
options: n
|
|
906
917
|
};
|
|
907
918
|
}
|
|
908
919
|
export {
|
|
909
920
|
ve as applyModifiers,
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
Ae as createSelectorFunction,
|
|
921
|
+
Ue as capitalizeFirst,
|
|
922
|
+
De as classNameToCssSelector,
|
|
923
|
+
I as createAtRuleFunction,
|
|
924
|
+
fe as createCssFunction,
|
|
925
|
+
v as createDeclarationsCallbackContext,
|
|
926
|
+
ge as createKeyframesFunction,
|
|
927
|
+
he as createMediaFunction,
|
|
928
|
+
we as createModifierFunction,
|
|
929
|
+
C as createPropertyValueResolver,
|
|
930
|
+
$e as createRecipeFunction,
|
|
931
|
+
q as createRefFunction,
|
|
932
|
+
je as createRoot,
|
|
933
|
+
be as createSelectorFunction,
|
|
924
934
|
Me as createThemeFunction,
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
935
|
+
ke as createUtilityFunction,
|
|
936
|
+
Ae as createVariableFunction,
|
|
937
|
+
M as deepClone,
|
|
938
|
+
Pe as defaultUtilitySelectorFn,
|
|
939
|
+
oe as findVariableInScope,
|
|
940
|
+
b as generateRandomId,
|
|
941
|
+
xe as generateRecipeRuntime,
|
|
942
|
+
le as getModifier,
|
|
933
943
|
Ie as getUtility,
|
|
934
|
-
|
|
935
|
-
|
|
944
|
+
Ce as getVariable,
|
|
945
|
+
se as hashValue,
|
|
936
946
|
te as isAtRule,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
947
|
+
T as isCSS,
|
|
948
|
+
Te as isContainer,
|
|
949
|
+
L as isContainerInput,
|
|
950
|
+
ie as isKeyReferenceValue,
|
|
941
951
|
ne as isModifier,
|
|
942
|
-
|
|
952
|
+
x as isObject,
|
|
943
953
|
re as isPrimitiveTokenValue,
|
|
944
|
-
|
|
945
|
-
|
|
954
|
+
Se as isRecipe,
|
|
955
|
+
A as isRef,
|
|
946
956
|
$ as isRoot,
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
957
|
+
_e as isSelector,
|
|
958
|
+
Be as isStyleframe,
|
|
959
|
+
Oe as isTheme,
|
|
960
|
+
g as isToken,
|
|
961
|
+
N as isTokenEqual,
|
|
952
962
|
B as isTokenValue,
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
963
|
+
Ne as isUtility,
|
|
964
|
+
H as isVariable,
|
|
965
|
+
Ke as merge,
|
|
966
|
+
Y as mergeContainers,
|
|
967
|
+
me as mergeThemesArray,
|
|
968
|
+
de as mergeVariablesArray,
|
|
959
969
|
z as parseAtReferences,
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
970
|
+
E as parseDeclarationsBlock,
|
|
971
|
+
Ee as processRecipeUtilities,
|
|
972
|
+
pe as rebuildRegistry,
|
|
973
|
+
ae as rfdc,
|
|
964
974
|
We as styleframe,
|
|
965
|
-
|
|
966
|
-
|
|
975
|
+
G as transformUtilityKey,
|
|
976
|
+
ce as validateReference
|
|
967
977
|
};
|
package/dist/styleframe.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(u=typeof globalThis<"u"?globalThis:u||self,V(u.styleframe={}))})(this,(function(u){"use strict";function V(e){return typeof e=="object"&&e!==null}function g(e,t){return V(e)&&"type"in e&&e.type===t}function U(e){return g(e,"variable")}function v(e){return g(e,"reference")}function $e(e){return g(e,"selector")}function Y(e){return g(e,"at-rule")}function Te(e){return g(e,"utility")}function Z(e){return g(e,"modifier")}function T(e){return g(e,"css")}function Se(e){return g(e,"theme")}function F(e){return g(e,"root")}function Ce(e){return g(e,"recipe")}function J(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function S(e){return J(e)||v(e)||T(e)||Array.isArray(e)&&e.every(S)}function Ee(e){return V(e)&&"id"in e&&"children"in e&&"declarations"in e&&"variables"in e}function Q(e){return V(e)&&"children"in e&&"declarations"in e&&"variables"in e}function x(e){return typeof e=="string"&&e.startsWith("@")}function Oe(e){return V(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&F(e.root)}function ee(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)&4294967295;return(t>>>0).toString(16).padStart(7,"0").slice(0,7)}function K(e){const t=typeof e=="function"?{replacer:e}:e??{},{replacer:r=c=>c,namespace:n}=t,s=Array.isArray(n)?n:n?[n]:[];return c=>{let i=c,a;if(typeof i=="string"&&i[0]==="@"){const o=i.slice(1),f=s.find(y=>o===y||o.startsWith(`${y}.`));let d,l;f?(d=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):s.length>0?(d=`${s[0]}.${o}`,l=o):(d=o,l=o),a=r(l),i={type:"reference",name:d}}else if(v(i)){let o=i.name;for(const f of s)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=r(o)}else{const o=String(c).trim();/\s/.test(o)?a=ee(o):a=`[${o}]`}return{[a]:i}}}const _e=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`,N=/@([\w.-]+)/g;function P(e){const t=[];let r=0,n;for(N.lastIndex=0;(n=N.exec(e))!==null;)t.push(e.slice(r,n.index)),t.push({type:"reference",name:n[1]}),r=N.lastIndex;return t.push(e.slice(r)),t}function te(e,t,r){let n=t;for(;n;){if(n.variables.some(s=>s.name===e))return!0;if(n.parentId)n=r._registry.get(n.parentId);else break}return!1}function ne(e,t,r){if(!te(e,t,r))throw new Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function C(e,t){return function(n){if(typeof n!="string"||!n.includes("@"))return n;if(x(n)&&/^@[\w.-]+$/.test(n)){const i=n.slice(1);return ne(i,e,t),{type:"reference",name:i}}const s=P(n);return s.some(i=>v(i))?{type:"css",value:s}:n}}function B(e,t){return function(n,s){const c=C(e,t),i=s!=null?c(s):s;if(U(n))return{type:"reference",name:n.name,fallback:i};if(n==null)throw new Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return{type:"reference",name:n,fallback:i}}}function re(e,t){const r=B(e,t);return function(s,...c){return{type:"css",value:s.reduce((a,o,f)=>{if(a.push(...P(o)),f<c.length){const d=c[f];U(d)?a.push(r(d)):Y(d)?a.push(d.rule):a.push(d)}return a},[])}}}function Ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ke(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function k(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 ie(e){if(e=e||{},e.circular)return Ne(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,a)=>new Map(n(Array.from(i),a))),t.set(Set,(i,a)=>new Set(n(Array.from(i),a))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let r;return e.proto?c:s;function n(i,a){const o=Object.keys(i),f=Array.from({length:o.length});for(let d=0;d<o.length;d++){const l=o[d],y=i[l];typeof y!="object"||y===null?f[l]=y:y.constructor!==Object&&(r=t.get(y.constructor))?f[l]=r(y,a):ArrayBuffer.isView(y)?f[l]=k(y):f[l]=a(y)}return f}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,s);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,s);const a={};for(const o in i){if(Object.hasOwnProperty.call(i,o)===!1)continue;const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,s):ArrayBuffer.isView(f)?a[o]=k(f):a[o]=s(f)}return a}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,c);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,c);const a={};for(const o in i){const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,c):ArrayBuffer.isView(f)?a[o]=k(f):a[o]=c(f)}return a}}function Ne(e){const t=[],r=[],n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,f)=>new Map(c(Array.from(o),f))),n.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)n.set(o[0],o[1]);let s;return e.proto?a:i;function c(o,f){const d=Object.keys(o),l=Array.from({length:d.length});for(let y=0;y<d.length;y++){const m=d[y],h=o[m];if(typeof h!="object"||h===null)l[m]=h;else if(h.constructor!==Object&&(s=n.get(h.constructor)))l[m]=s(h,f);else if(ArrayBuffer.isView(h))l[m]=k(h);else{const p=t.indexOf(h);p!==-1?l[m]=r[p]:l[m]=f(h)}}return l}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,i);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,i);const f={};t.push(o),r.push(f);for(const d in o){if(Object.hasOwnProperty.call(o,d)===!1)continue;const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,i);else if(ArrayBuffer.isView(l))f[d]=k(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=i(l)}}return t.pop(),r.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&&(s=n.get(o.constructor)))return s(o,a);const f={};t.push(o),r.push(f);for(const d in o){const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,a);else if(ArrayBuffer.isView(l))f[d]=k(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=a(l)}}return t.pop(),r.pop(),f}}const M=ie();function j(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let s=0;s<t;s++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}function Pe(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function Be(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function se(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}function E(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>E(r,t[n]));if("type"in e&&"type"in t){if(e.type!==t.type)return!1;if(v(e)&&v(t))return e.name===t.name&&E(e.fallback,t.fallback);if(T(e)&&T(t))return E(e.value,t.value)}return!1}const ce="__licenseRequired";function Ie(e){I(e)||Object.defineProperty(e,ce,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function I(e){return Object.prototype.hasOwnProperty.call(e,ce)}function oe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?s.value=n.value:r.push(n)}return r}function ae(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?Object.assign(s,D(s,n)):r.push(n)}return r}function D(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=oe(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&F(r)&&F(e)&&F(t)?r.themes=ae(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function W(e,t){for(const r of e)"id"in r&&typeof r.id=="string"&&(t._registry.set(r.id,r),"children"in r&&W(r.children,t))}function fe(e){e._registry=new Map,e._registry.set(e.id,e),W(e.children,e);for(const t of e.themes)e._registry.set(t.id,t),W(t.children,e)}function De(e,...t){return t.reduce((r,n)=>{const s={...r,root:D(r.root,n.root)};return fe(s.root),(I(r)||I(n))&&Ie(s),s},e)}function O(e,t){return function(n,s,c){const i={type:"at-rule",id:j("ar-"),parentId:e.id,identifier:n,rule:s,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);const a=R(i,t);return typeof c=="function"?i.declarations=c(a)??{}:c&&(i.declarations=c),$(i.declarations,a,i,t),e.children.push(i),i}}function ue(e,t){const r=O(e,t);return function(s,c){return r("media",s,c)}}function le(e,t){const r=O(e,t);return function(s,c){return r("keyframes",s,c)}}function de(e,t){return function(n,s){const c={type:"selector",id:j("sel-"),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(c.id,c);const i=R(c,t);return typeof s=="function"?c.declarations=s(i)??{}:Q(s)?(c.variables=s.variables,c.declarations=s.declarations,c.children=s.children):c.declarations=s,$(c.declarations,i,c,t),e.children.push(c),c}}function ye(e,t){return function(n,s,c={default:!1}){const i=typeof n=="string"?n:n.name,o=C(e,t)(s),f=e.variables.find(l=>l.name===i);if(c.default&&f)return f;if(f)return f.value=o,f;const d={type:"variable",id:j("var-"),parentId:e.id,name:i,value:o};return e.variables.push(d),d}}function R(e,t){const r=ye(e,t),n=de(e,t),s=O(e,t),c=le(t,t),i=ue(e,t),a=B(t,t),o=re(t,t);return{variable:r,selector:n,keyframes:c,atRule:s,media:i,ref:a,css:o}}function $(e,t,r,n){for(const c in e)if(c.startsWith("@")){const i=e[c];if(typeof i=="object"&&i!==null&&!S(i)){const a=c.replace(/^@(\w+).*/,"$1"),o=c.replace(`@${a}`,"").trim();t.atRule(a,o,i),delete e[c]}}else if(/^[.&:]/.test(c)||/^\d+%$/.test(c)||c==="from"||c==="to"){const i=e[c];typeof i=="object"&&(t.selector(c,i),delete e[c])}const s=C(r,n);for(const c in e){const i=e[c];if(S(i)){const a=s(i);a!==i&&(e[c]=a)}}return e}function me(e){const t=[];function r(n,s){s.length>0&&t.push([...s].sort());for(let c=n;c<e.length;c++){const i=e[c];if(i)if(i.length===1&&i[0])r(c+1,[...s,i[0]]);else for(const a of i)r(c+1,[...s,a])}}return r(0,[]),t.sort((n,s)=>n.length!==s.length?n.length-s.length:n.join(",").localeCompare(s.join(",")))}function he(e,t,r){const n={...e,id:j("ut-"),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...r.keys()]};t._registry.set(n.id,n);const s=R(n,t);if(r.size>0){const c=M(e.declarations);let i=!1;for(const a of r.values()){const o=a.factory({...s,declarations:M(c),variables:M(n.variables),children:M(n.children)});o&&(i||(n.declarations={},i=!0),Object.assign(n.declarations,o),$(n.declarations,s,n,t))}}return n}function ge(e,t){return function(n,s){const c={type:"modifier",key:Array.isArray(n)?n:[n],factory:s};return t.modifiers.push(c),c}}function pe(){const e={type:"root",id:j("rt-"),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map};return e._registry.set(e.id,e),e}function We(e,t){const r=K({namespace:e});return n=>{if(typeof n=="string"&&n[0]==="@"){const s=n.slice(1),c=e.find(i=>s===i||s.startsWith(`${i}.`));if(c){const i=s.slice(c.length+1)||s;if(t.variables.some(a=>a.name===s))return{[i]:{type:"reference",name:s}}}else for(const i of e){const a=`${i}.${s}`;if(t.variables.some(o=>o.name===a))return{[s]:{type:"reference",name:a}}}return r(n)}return r(n)}}function be(e,t){return function(n,s,c={}){const i=t.utilities.find(o=>o.name===n);if(i)return i.create;const a={type:"utility",name:n,factory:s,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?We(c.namespace,t):K(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(o,f=[])=>{let d=o;if(Array.isArray(o)){d={};for(const l of o){const y=a.autogenerate(l);d={...d,...y}}}for(const[l,y]of Object.entries(d)){let m=y;if(typeof y=="string"&&y[0]==="@"){const b=y.slice(1);!Array.isArray(d)&&b in d&&(m=d[b])}if(a.namespace&&v(y))if(t.variables.some(b=>b.name===y.name))m=y;else{const b=Array.isArray(a.namespace)?a.namespace:[a.namespace];let z=!1;for(const G of b){const A=`${G}.${l}`;if(A!==y.name&&t.variables.some(w=>w.name===A)){m={type:"reference",name:A},z=!0;break}}z||(m=l)}const h=a.values.find(b=>b.key===l&&b.modifiers.length===0),p={type:"utility",id:j("ut-"),parentId:e.id,name:n,value:l,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(p.id,p);const Fe=R(p,t);if(p.declarations=s({...Fe,value:m})??{},$(p.declarations,Fe,p,t),h||(a.values.push({key:l,value:m,modifiers:[]}),e.children.push(p)),f&&f.length>0){const b=f.map(A=>A.key),G=me(b).filter(A=>!a.values.find(w=>w.key===l&&w.modifiers.length===A.length&&w.modifiers.every(_=>A.includes(_)))).reduce((A,w)=>{const _=new Map;for(const Me of w){const X=f.find(Le=>Le.key.includes(Me));X&&Z(X)&&_.set(Me,X)}return a.values.push({key:l,value:m,modifiers:w}),A.push(he(p,t,_)),A},[]);e.children.push(...G)}}}};return t.utilities.push(a),a.create}}function Ae(e,t){return function(n,s){const c=t.themes.find(o=>o.name===n),i=c??{type:"theme",id:j("th-"),parentId:t.id,name:n,declarations:{},variables:[],children:[]};c||(t._registry.set(i.id,i),t.themes.push(i));const a=R(i,t);return s&&s(a),i}}function Ve(e,t){return function(n){const s={type:"recipe",...n};return s._runtime=ve(s,t),ke(s,t),t.recipes.push(s),s}}function je(e,t){const r=e.autogenerate(t);return Object.keys(r)[0]??"default"}function H(e,t){const r={};for(const[n,s]of Object.entries(e))if(we(s)){const c={};for(const[i,a]of Object.entries(s)){const o=q(t,i);if(!o)throw new Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);c[i]=je(o,a)}r[Re(n)]=c}else if(typeof s=="boolean")r[n]=s;else{const c=q(t,n);if(!c)throw new Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);r[n]=je(c,s)}return r}function ve(e,t){const r={};if(e.base&&(r.base=H(e.base,t)),e.variants){const n={};for(const[s,c]of Object.entries(e.variants)){const i={};for(const[a,o]of Object.entries(c))o==null?i[a]=null:i[a]=H(o,t);n[s]=i}r.variants=n}return e.defaultVariants&&(r.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(r.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},css:H(n.css,t)}))),r}function we(e){return!v(e)&&typeof e=="object"&&e!==null}function Re(e){return e.startsWith("&::")?e.slice(3):e.startsWith("&:")?e.slice(2):e}function L(e,t){const r=(n,s,c)=>{let i=t.get(n);i||(i=[],t.set(n,i)),i.push({value:s,modifiers:c})};for(const[n,s]of Object.entries(e))if(we(s)){const c=Re(n).split(":");for(const[i,a]of Object.entries(s))r(i,a,c)}else r(n,s,[])}function q(e,t){const r=e.utilities.find(s=>s.name===t);if(r)return r;const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return e.utilities.find(s=>s.name===n)}function ke(e,t){const r=new Map;if(e.base&&L(e.base,r),e.variants)for(const s of Object.values(e.variants))for(const c of Object.values(s))L(c,r);if(e.compoundVariants)for(const s of e.compoundVariants)s.css&&L(s.css,r);const n=new Map;for(const[s,c]of r){const i=q(t,s);if(!i)throw new Error(`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(const a of c){const o=[];for(const f of a.modifiers){if(!n.has(f))try{n.set(f,se(t,f))}catch{throw new Error(`[styleframe] Modifier "${f}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}const d=n.get(f);d&&o.push(d)}i.create([a.value],o.length>0?o:void 0)}}}function He(e){const t=j("sf-"),r=pe(),n={...e},s=be(r,r),c=ge(r,r),i=Ve(r,r),a=Ae(r,r),{variable:o,selector:f,atRule:d,keyframes:l,media:y,ref:m,css:h}=R(r,r);return{id:t,root:r,variable:o,selector:f,utility:s,modifier:c,recipe:i,theme:a,atRule:d,keyframes:l,media:y,ref:m,css:h,options:n}}u.applyModifiers=he,u.capitalizeFirst=Ue,u.classNameToCssSelector=Ke,u.combineKeys=me,u.createAtRuleFunction=O,u.createCssFunction=re,u.createDeclarationsCallbackContext=R,u.createKeyframesFunction=le,u.createMediaFunction=ue,u.createModifierFunction=ge,u.createPropertyValueResolver=C,u.createRecipeFunction=Ve,u.createRefFunction=B,u.createRoot=pe,u.createSelectorFunction=de,u.createThemeFunction=Ae,u.createUtilityFunction=be,u.createVariableFunction=ye,u.deepClone=M,u.defaultUtilitySelectorFn=_e,u.findVariableInScope=te,u.generateRandomId=j,u.generateRecipeRuntime=ve,u.getModifier=se,u.getUtility=Be,u.getVariable=Pe,u.hashValue=ee,u.isAtRule=Y,u.isCSS=T,u.isContainer=Ee,u.isContainerInput=Q,u.isKeyReferenceValue=x,u.isModifier=Z,u.isObject=V,u.isPrimitiveTokenValue=J,u.isRecipe=Ce,u.isRef=v,u.isRoot=F,u.isSelector=$e,u.isStyleframe=Oe,u.isTheme=Se,u.isToken=g,u.isTokenEqual=E,u.isTokenValue=S,u.isUtility=Te,u.isVariable=U,u.merge=De,u.mergeContainers=D,u.mergeThemesArray=ae,u.mergeVariablesArray=oe,u.parseAtReferences=P,u.parseDeclarationsBlock=$,u.processRecipeUtilities=ke,u.rebuildRegistry=fe,u.rfdc=ie,u.styleframe=He,u.transformUtilityKey=K,u.validateReference=ne,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(u,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(u=typeof globalThis<"u"?globalThis:u||self,A(u.styleframe={}))})(this,(function(u){"use strict";function A(e){return typeof e=="object"&&e!==null}function g(e,t){return A(e)&&"type"in e&&e.type===t}function U(e){return g(e,"variable")}function w(e){return g(e,"reference")}function ke(e){return g(e,"selector")}function Y(e){return g(e,"at-rule")}function Me(e){return g(e,"utility")}function Z(e){return g(e,"modifier")}function S(e){return g(e,"css")}function Fe(e){return g(e,"theme")}function k(e){return g(e,"root")}function $e(e){return g(e,"recipe")}function J(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function E(e){return J(e)||w(e)||S(e)||Array.isArray(e)&&e.every(E)}function Te(e){return A(e)&&"id"in e&&"children"in e&&"declarations"in e&&"variables"in e}function P(e){return A(e)&&"children"in e&&"declarations"in e&&"variables"in e}function Q(e){return typeof e=="string"&&e.startsWith("@")}function Se(e){return A(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&k(e.root)}function x(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)&4294967295;return(t>>>0).toString(16).padStart(7,"0").slice(0,7)}function B(e){const t=typeof e=="function"?{replacer:e}:e??{},{replacer:r=c=>c,namespace:n}=t,s=Array.isArray(n)?n:n?[n]:[];return c=>{let i=c,a;if(typeof i=="string"&&i[0]==="@"){const o=i.slice(1),f=s.find(y=>o===y||o.startsWith(`${y}.`));let d,l;f?(d=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):s.length>0?(d=`${s[0]}.${o}`,l=o):(d=o,l=o),a=r(l),i={type:"reference",name:d}}else if(w(i)){let o=i.name;for(const f of s)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=r(o)}else{const o=String(c).trim();/\s/.test(o)?a=x(o):a=`[${o}]`}return{[a]:i}}}const Ee=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`,D=/@([\w.-]+)/g;function I(e){const t=[];let r=0,n;for(D.lastIndex=0;(n=D.exec(e))!==null;)t.push(e.slice(r,n.index)),t.push({type:"reference",name:n[1]}),r=D.lastIndex;return t.push(e.slice(r)),t}function ee(e,t,r){let n=t;for(;n;){if(n.variables.some(s=>s.name===e))return!0;if(n.parentId)n=r._registry.get(n.parentId);else break}return!1}function te(e,t,r){if(!ee(e,t,r))throw new Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function N(e,t){return function(n){if(typeof n!="string"||!n.includes("@"))return n;if(Q(n)&&/^@[\w.-]+$/.test(n)){const i=n.slice(1);return te(i,e,t),{type:"reference",name:i}}const s=I(n);return s.some(i=>w(i))?{type:"css",value:s}:n}}function K(e,t){return function(n,s){const c=N(e,t),i=s!=null?c(s):s;if(U(n))return{type:"reference",name:n.name,fallback:i};if(n==null)throw new Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return{type:"reference",name:n,fallback:i}}}function ne(e,t){const r=K(e,t);return function(s,...c){return{type:"css",value:s.reduce((a,o,f)=>{if(a.push(...I(o)),f<c.length){const d=c[f];U(d)?a.push(r(d)):Y(d)?a.push(d.rule):a.push(d)}return a},[])}}}function Ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _e(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function R(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 re(e){if(e=e||{},e.circular)return Oe(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,a)=>new Map(n(Array.from(i),a))),t.set(Set,(i,a)=>new Set(n(Array.from(i),a))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let r;return e.proto?c:s;function n(i,a){const o=Object.keys(i),f=Array.from({length:o.length});for(let d=0;d<o.length;d++){const l=o[d],y=i[l];typeof y!="object"||y===null?f[l]=y:y.constructor!==Object&&(r=t.get(y.constructor))?f[l]=r(y,a):ArrayBuffer.isView(y)?f[l]=R(y):f[l]=a(y)}return f}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,s);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,s);const a={};for(const o in i){if(Object.hasOwnProperty.call(i,o)===!1)continue;const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,s):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=s(f)}return a}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,c);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,c);const a={};for(const o in i){const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,c):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=c(f)}return a}}function Oe(e){const t=[],r=[],n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,f)=>new Map(c(Array.from(o),f))),n.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)n.set(o[0],o[1]);let s;return e.proto?a:i;function c(o,f){const d=Object.keys(o),l=Array.from({length:d.length});for(let y=0;y<d.length;y++){const m=d[y],h=o[m];if(typeof h!="object"||h===null)l[m]=h;else if(h.constructor!==Object&&(s=n.get(h.constructor)))l[m]=s(h,f);else if(ArrayBuffer.isView(h))l[m]=R(h);else{const b=t.indexOf(h);b!==-1?l[m]=r[b]:l[m]=f(h)}}return l}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,i);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,i);const f={};t.push(o),r.push(f);for(const d in o){if(Object.hasOwnProperty.call(o,d)===!1)continue;const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,i);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=i(l)}}return t.pop(),r.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&&(s=n.get(o.constructor)))return s(o,a);const f={};t.push(o),r.push(f);for(const d in o){const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,a);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=a(l)}}return t.pop(),r.pop(),f}}const M=re();function v(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let s=0;s<t;s++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}function Ce(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function Ue(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function ie(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}function _(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>_(r,t[n]));if("type"in e&&"type"in t){if(e.type!==t.type)return!1;if(w(e)&&w(t))return e.name===t.name&&_(e.fallback,t.fallback);if(S(e)&&S(t))return _(e.value,t.value)}return!1}const se="__licenseRequired";function Pe(e){W(e)||Object.defineProperty(e,se,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function W(e){return Object.prototype.hasOwnProperty.call(e,se)}function ce(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?s.value=n.value:r.push(n)}return r}function oe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?Object.assign(s,H(s,n)):r.push(n)}return r}function H(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=ce(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&k(r)&&k(e)&&k(t)?r.themes=oe(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function L(e,t){for(const r of e)"id"in r&&typeof r.id=="string"&&(t._registry.set(r.id,r),"children"in r&&L(r.children,t))}function ae(e){e._registry=new Map,e._registry.set(e.id,e),L(e.children,e);for(const t of e.themes)e._registry.set(t.id,t),L(t.children,e)}function Be(e,...t){return t.reduce((r,n)=>{const s={...r,root:H(r.root,n.root)};return ae(s.root),(W(r)||W(n))&&Pe(s),s},e)}function O(e,t){return function(n,s,c){const i={type:"at-rule",id:v("ar-"),parentId:e.id,identifier:n,rule:s,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);const a=V(i,t);return typeof c=="function"?i.declarations=c(a)??{}:P(c)?(i.variables=c.variables,i.declarations=c.declarations,i.children=c.children):c&&(i.declarations=c),F(i.declarations,a,i,t),e.children.push(i),i}}function fe(e,t){const r=O(e,t);return function(s,c){return r("media",s,c)}}function ue(e,t){const r=O(e,t);return function(s,c){return r("keyframes",s,c)}}function le(e,t){return function(n,s){const c={type:"selector",id:v("sel-"),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(c.id,c);const i=V(c,t);return typeof s=="function"?c.declarations=s(i)??{}:P(s)?(c.variables=s.variables,c.declarations=s.declarations,c.children=s.children):c.declarations=s,F(c.declarations,i,c,t),e.children.push(c),c}}function de(e,t){return function(n,s,c={default:!1}){const i=typeof n=="string"?n:n.name,o=N(e,t)(s),f=e.variables.find(l=>l.name===i);if(c.default&&f)return f;if(f)return f.value=o,f;const d={type:"variable",id:v("var-"),parentId:e.id,name:i,value:o};return e.variables.push(d),d}}function V(e,t){const r=de(e,t),n=le(e,t),s=O(e,t),c=ue(t,t),i=fe(e,t),a=K(t,t),o=ne(t,t);return{variable:r,selector:n,keyframes:c,atRule:s,media:i,ref:a,css:o}}function F(e,t,r,n){for(const c in e)if(c.startsWith("@")){const i=e[c];if(typeof i=="object"&&i!==null&&!E(i)){const a=c.replace(/^@(\w+).*/,"$1"),o=c.replace(`@${a}`,"").trim();t.atRule(a,o,i),delete e[c]}}else if(/^[.&:]/.test(c)||/^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(c)){const i=e[c];typeof i=="object"&&(t.selector(c,i),delete e[c])}const s=N(r,n);for(const c in e){const i=e[c];if(E(i)){const a=s(i);a!==i&&(e[c]=a)}}return e}function ye(e,t,r){const n={...e,id:v("ut-"),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...r.keys()]};if(t._registry.set(n.id,n),r.size>0){const s=[...r.values()];let c=M(e.declarations);n.declarations={},n.variables=[],n.children=[];for(let a=s.length-1;a>=0;a--){const o=V(n,t),f=s[a]?.factory({...o,declarations:M(c),variables:M(e.variables),children:M(e.children)});f&&(c=f)}n.declarations=c;const i=V(n,t);F(n.declarations,i,n,t)}return n}function me(e,t){return function(n,s){const c={type:"modifier",key:Array.isArray(n)?n:[n],factory:s};return t.modifiers.push(c),c}}function he(){const e={type:"root",id:v("rt-"),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map};return e._registry.set(e.id,e),e}function De(e,t){const r=B({namespace:e});return n=>{if(typeof n=="string"&&n[0]==="@"){const s=n.slice(1),c=e.find(i=>s===i||s.startsWith(`${i}.`));if(c){const i=s.slice(c.length+1)||s;if(t.variables.some(a=>a.name===s))return{[i]:{type:"reference",name:s}}}else{for(const i of e){const a=`${i}.${s}`;if(t.variables.some(o=>o.name===a))return{[s]:{type:"reference",name:a}}}if(t.variables.some(i=>i.name===s))return{[s]:{type:"reference",name:s}}}return r(n)}return r(n)}}function Ie(e){let t=[new Map];for(const r of e){if(!Z(r))continue;const n=[];for(const s of r.key)for(const c of t){const i=new Map(c);i.set(s,r),n.push(i)}t=n}return t.filter(r=>r.size>0)}function pe(e,t){return function(n,s,c={}){const i=t.utilities.find(o=>o.name===n);if(i)return i.create;const a={type:"utility",name:n,factory:s,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?De(c.namespace,t):B(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(o,f=[])=>{let d=o;if(Array.isArray(o)){d={};for(const l of o){const y=a.autogenerate(l);d={...d,...y}}}for(const[l,y]of Object.entries(d)){let m=y;if(typeof y=="string"&&y[0]==="@"){const p=y.slice(1);!Array.isArray(d)&&p in d&&(m=d[p])}if(a.namespace&&w(y))if(t.variables.some(p=>p.name===y.name))m=y;else{const p=Array.isArray(a.namespace)?a.namespace:[a.namespace];let C=!1;for(const $ of p){const j=`${$}.${l}`;if(j!==y.name&&t.variables.some(T=>T.name===j)){m={type:"reference",name:j},C=!0;break}}C||(t.variables.some($=>$.name===l)?m={type:"reference",name:l}:m=l)}const h=a.values.find(p=>p.key===l&&p.modifiers.length===0),b={type:"utility",id:v("ut-"),parentId:e.id,name:n,value:l,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(b.id,b);const je=V(b,t);if(b.declarations=s({...je,value:m})??{},F(b.declarations,je,b,t),h||(a.values.push({key:l,value:m,modifiers:[]}),e.children.push(b)),f&&f.length>0)for(const p of f){const C=Array.isArray(p)?p:[p],$=Ie(C);for(const j of $){const T=[...j.keys()];a.values.find(X=>X.key===l&&X.modifiers.length===T.length&&X.modifiers.every((We,He)=>We===T[He]))||(a.values.push({key:l,value:m,modifiers:T}),e.children.push(ye(b,t,j)))}}}}};return t.utilities.push(a),a.create}}function ge(e,t){return function(n,s){const c=t.themes.find(o=>o.name===n),i=c??{type:"theme",id:v("th-"),parentId:t.id,name:n,declarations:{},variables:[],children:[]};c||(t._registry.set(i.id,i),t.themes.push(i));const a=V(i,t);return s&&s(a),i}}function be(e,t){return function(n){const s={type:"recipe",...n};return s._runtime=ve(s,t),Re(s,t),t.recipes.push(s),s}}function Ae(e,t){const r=e.autogenerate(t);return Object.keys(r)[0]??"default"}function z(e,t){const r={};for(const[n,s]of Object.entries(e))if(we(s)){const c={};for(const[i,a]of Object.entries(s)){const o=q(t,i);if(!o)throw new Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);c[i]=Ae(o,a)}r[Ve(n)]=c}else if(typeof s=="boolean")r[n]=s;else{const c=q(t,n);if(!c)throw new Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);r[n]=Ae(c,s)}return r}function ve(e,t){const r={};if(e.base&&(r.base=z(e.base,t)),e.variants){const n={};for(const[s,c]of Object.entries(e.variants)){const i={};for(const[a,o]of Object.entries(c))o==null?i[a]=null:i[a]=z(o,t);n[s]=i}r.variants=n}return e.defaultVariants&&(r.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(r.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},...n.css?{css:z(n.css,t)}:{},...n.className?{className:n.className}:{}}))),r}function we(e){return!w(e)&&typeof e=="object"&&e!==null}function Ve(e){return e.startsWith("&::")?e.slice(3):e.startsWith("&:")?e.slice(2):e}function G(e,t){const r=(n,s,c)=>{let i=t.get(n);i||(i=[],t.set(n,i)),i.push({value:s,modifiers:c})};for(const[n,s]of Object.entries(e))if(we(s)){const c=Ve(n).split(":");for(const[i,a]of Object.entries(s))r(i,a,c)}else r(n,s,[])}function q(e,t){const r=e.utilities.find(s=>s.name===t);if(r)return r;const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return e.utilities.find(s=>s.name===n)}function Re(e,t){const r=new Map;if(e.base&&G(e.base,r),e.variants)for(const s of Object.values(e.variants))for(const c of Object.values(s))G(c,r);if(e.compoundVariants)for(const s of e.compoundVariants)s.css&&G(s.css,r);const n=new Map;for(const[s,c]of r){const i=q(t,s);if(!i)throw new Error(`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(const a of c){const o=[];for(const f of a.modifiers){if(!n.has(f))try{n.set(f,ie(t,f))}catch{throw new Error(`[styleframe] Modifier "${f}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}const d=n.get(f);d&&o.push(d)}i.create([a.value],o.length>0?o.length>1?[o]:o:void 0)}}}function Ke(e){const t=v("sf-"),r=he(),n={...e},s=pe(r,r),c=me(r,r),i=be(r,r),a=ge(r,r),{variable:o,selector:f,atRule:d,keyframes:l,media:y,ref:m,css:h}=V(r,r);return{id:t,root:r,variable:o,selector:f,utility:s,modifier:c,recipe:i,theme:a,atRule:d,keyframes:l,media:y,ref:m,css:h,options:n}}u.applyModifiers=ye,u.capitalizeFirst=Ne,u.classNameToCssSelector=_e,u.createAtRuleFunction=O,u.createCssFunction=ne,u.createDeclarationsCallbackContext=V,u.createKeyframesFunction=ue,u.createMediaFunction=fe,u.createModifierFunction=me,u.createPropertyValueResolver=N,u.createRecipeFunction=be,u.createRefFunction=K,u.createRoot=he,u.createSelectorFunction=le,u.createThemeFunction=ge,u.createUtilityFunction=pe,u.createVariableFunction=de,u.deepClone=M,u.defaultUtilitySelectorFn=Ee,u.findVariableInScope=ee,u.generateRandomId=v,u.generateRecipeRuntime=ve,u.getModifier=ie,u.getUtility=Ue,u.getVariable=Ce,u.hashValue=x,u.isAtRule=Y,u.isCSS=S,u.isContainer=Te,u.isContainerInput=P,u.isKeyReferenceValue=Q,u.isModifier=Z,u.isObject=A,u.isPrimitiveTokenValue=J,u.isRecipe=$e,u.isRef=w,u.isRoot=k,u.isSelector=ke,u.isStyleframe=Se,u.isTheme=Fe,u.isToken=g,u.isTokenEqual=_,u.isTokenValue=E,u.isUtility=Me,u.isVariable=U,u.merge=Be,u.mergeContainers=H,u.mergeThemesArray=oe,u.mergeVariablesArray=ce,u.parseAtReferences=I,u.parseDeclarationsBlock=F,u.processRecipeUtilities=Re,u.rebuildRegistry=ae,u.rfdc=re,u.styleframe=Ke,u.transformUtilityKey=B,u.validateReference=te,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|