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