@styleframe/core 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/styleframe.js +220 -216
- package/dist/styleframe.umd.cjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @styleframe/core
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#72](https://github.com/styleframe-dev/styleframe/pull/72) [`d98b650`](https://github.com/styleframe-dev/styleframe/commit/d98b65030170582ceacfabde3ba9ff7d92105389) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: add support for .styleframe file imports
|
|
8
|
+
|
|
3
9
|
## 2.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/styleframe.js
CHANGED
|
@@ -4,73 +4,73 @@ function S(e) {
|
|
|
4
4
|
function p(e, r) {
|
|
5
5
|
return S(e) && "type" in e && e.type === r;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function L(e) {
|
|
8
8
|
return p(e, "variable");
|
|
9
9
|
}
|
|
10
10
|
function A(e) {
|
|
11
11
|
return p(e, "reference");
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function be(e) {
|
|
14
14
|
return p(e, "selector");
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function ge(e) {
|
|
17
17
|
return p(e, "at-rule");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function je(e) {
|
|
20
20
|
return p(e, "utility");
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function q(e) {
|
|
23
23
|
return p(e, "modifier");
|
|
24
24
|
}
|
|
25
25
|
function E(e) {
|
|
26
26
|
return p(e, "css");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function ve(e) {
|
|
29
29
|
return p(e, "theme");
|
|
30
30
|
}
|
|
31
31
|
function O(e) {
|
|
32
32
|
return p(e, "root");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Ae(e) {
|
|
35
35
|
return p(e, "recipe");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function G(e) {
|
|
38
38
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
40
|
+
function $(e) {
|
|
41
|
+
return G(e) || A(e) || E(e) || Array.isArray(e) && e.every($);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function I(e) {
|
|
44
44
|
return S(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
45
45
|
}
|
|
46
46
|
function z(e = (r) => r) {
|
|
47
47
|
return (r) => {
|
|
48
|
-
let
|
|
49
|
-
if (typeof
|
|
50
|
-
const i =
|
|
51
|
-
|
|
48
|
+
let n = r, t;
|
|
49
|
+
if (typeof n == "string" && n[0] === "@") {
|
|
50
|
+
const i = n.slice(1);
|
|
51
|
+
t = e(i), n = {
|
|
52
52
|
type: "reference",
|
|
53
53
|
name: i
|
|
54
54
|
};
|
|
55
|
-
} else A(
|
|
55
|
+
} else A(n) ? t = e(n.name) : t = `[${r}]`;
|
|
56
56
|
return {
|
|
57
|
-
[
|
|
57
|
+
[t]: n
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
function W(e, r) {
|
|
62
|
-
return function(
|
|
62
|
+
return function(t, ...i) {
|
|
63
63
|
return {
|
|
64
64
|
type: "css",
|
|
65
|
-
value:
|
|
65
|
+
value: t.reduce((o, u, s) => (o.push(u), s < i.length && o.push(i[s]), o), [])
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return function(
|
|
69
|
+
function C(e, r) {
|
|
70
|
+
return function(t, i, c) {
|
|
71
71
|
const o = {
|
|
72
72
|
type: "at-rule",
|
|
73
|
-
identifier:
|
|
73
|
+
identifier: t,
|
|
74
74
|
rule: i,
|
|
75
75
|
declarations: {},
|
|
76
76
|
variables: [],
|
|
@@ -80,47 +80,47 @@ function K(e, r) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function Y(e, r) {
|
|
83
|
-
const
|
|
83
|
+
const n = C(e, r);
|
|
84
84
|
return function(i, c) {
|
|
85
|
-
return
|
|
85
|
+
return n("media", i, c);
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const
|
|
88
|
+
function Z(e, r) {
|
|
89
|
+
const n = C(e, r);
|
|
90
90
|
return function(i, c) {
|
|
91
|
-
return
|
|
91
|
+
return n("keyframes", i, c);
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
return function(
|
|
96
|
-
return
|
|
94
|
+
function J(e, r) {
|
|
95
|
+
return function(t, i) {
|
|
96
|
+
return L(t) ? {
|
|
97
97
|
type: "reference",
|
|
98
|
-
name:
|
|
98
|
+
name: t.name,
|
|
99
99
|
fallback: i
|
|
100
100
|
} : {
|
|
101
101
|
type: "reference",
|
|
102
|
-
name:
|
|
102
|
+
name: t,
|
|
103
103
|
fallback: i
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return function(
|
|
107
|
+
function Q(e, r) {
|
|
108
|
+
return function(t, i) {
|
|
109
109
|
const c = {
|
|
110
110
|
type: "selector",
|
|
111
|
-
query:
|
|
111
|
+
query: t,
|
|
112
112
|
declarations: {},
|
|
113
113
|
variables: [],
|
|
114
114
|
children: []
|
|
115
115
|
}, o = v(c, r);
|
|
116
|
-
return typeof i == "function" ? c.declarations = i(o) ?? {} :
|
|
116
|
+
return typeof i == "function" ? c.declarations = i(o) ?? {} : I(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, V(c.declarations, o), e.children.push(c), c;
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
|
-
function
|
|
120
|
-
return function(
|
|
119
|
+
function X(e, r) {
|
|
120
|
+
return function(t, i, c = {
|
|
121
121
|
default: !1
|
|
122
122
|
}) {
|
|
123
|
-
const o = typeof
|
|
123
|
+
const o = typeof t == "string" ? t : t.name, u = e.variables.find(
|
|
124
124
|
(f) => f.name === o
|
|
125
125
|
);
|
|
126
126
|
if (c.default && u)
|
|
@@ -136,10 +136,10 @@ function Z(e, r) {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
function v(e, r) {
|
|
139
|
-
const
|
|
139
|
+
const n = X(e), t = Q(e, r), i = C(e, r), c = Z(r, r), o = Y(e, r), u = J(), s = W();
|
|
140
140
|
return {
|
|
141
|
-
variable:
|
|
142
|
-
selector:
|
|
141
|
+
variable: n,
|
|
142
|
+
selector: t,
|
|
143
143
|
keyframes: c,
|
|
144
144
|
atRule: i,
|
|
145
145
|
media: o,
|
|
@@ -148,20 +148,20 @@ function v(e, r) {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
function V(e, r) {
|
|
151
|
-
for (const
|
|
152
|
-
if (
|
|
153
|
-
const
|
|
154
|
-
if (typeof
|
|
155
|
-
const i =
|
|
156
|
-
r.atRule(i, c,
|
|
151
|
+
for (const n in e)
|
|
152
|
+
if (n.startsWith("@")) {
|
|
153
|
+
const t = e[n];
|
|
154
|
+
if (typeof t == "object" && t !== null && !$(t)) {
|
|
155
|
+
const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
|
|
156
|
+
r.atRule(i, c, t), delete e[n];
|
|
157
157
|
}
|
|
158
|
-
} else if (/^[.&:]/.test(
|
|
159
|
-
const
|
|
160
|
-
typeof
|
|
158
|
+
} else if (/^[.&:]/.test(n)) {
|
|
159
|
+
const t = e[n];
|
|
160
|
+
typeof t == "object" && (r.selector(n, t), delete e[n]);
|
|
161
161
|
}
|
|
162
162
|
return e;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function we(e) {
|
|
165
165
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
166
166
|
}
|
|
167
167
|
function j(e) {
|
|
@@ -180,60 +180,60 @@ function ee(e) {
|
|
|
180
180
|
const r = /* @__PURE__ */ new Map();
|
|
181
181
|
if (r.set(Date, (o) => new Date(o)), r.set(
|
|
182
182
|
Map,
|
|
183
|
-
(o, u) => new Map(
|
|
183
|
+
(o, u) => new Map(t(Array.from(o), u))
|
|
184
184
|
), r.set(
|
|
185
185
|
Set,
|
|
186
|
-
(o, u) => new Set(
|
|
186
|
+
(o, u) => new Set(t(Array.from(o), u))
|
|
187
187
|
), e.constructorHandlers)
|
|
188
188
|
for (const o of e.constructorHandlers)
|
|
189
189
|
r.set(o[0], o[1]);
|
|
190
|
-
let
|
|
190
|
+
let n;
|
|
191
191
|
return e.proto ? c : i;
|
|
192
|
-
function
|
|
192
|
+
function t(o, u) {
|
|
193
193
|
const s = Object.keys(o), f = Array.from({ length: s.length });
|
|
194
194
|
for (let l = 0; l < s.length; l++) {
|
|
195
195
|
const a = s[l], y = o[a];
|
|
196
|
-
typeof y != "object" || y === null ? f[a] = y : y.constructor !== Object && (
|
|
196
|
+
typeof y != "object" || y === null ? f[a] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[a] = n(y, u) : ArrayBuffer.isView(y) ? f[a] = j(y) : f[a] = u(y);
|
|
197
197
|
}
|
|
198
198
|
return f;
|
|
199
199
|
}
|
|
200
200
|
function i(o) {
|
|
201
201
|
if (typeof o != "object" || o === null) return o;
|
|
202
|
-
if (Array.isArray(o)) return
|
|
203
|
-
if (o.constructor !== Object && (
|
|
204
|
-
return
|
|
202
|
+
if (Array.isArray(o)) return t(o, i);
|
|
203
|
+
if (o.constructor !== Object && (n = r.get(o.constructor)))
|
|
204
|
+
return n(o, i);
|
|
205
205
|
const u = {};
|
|
206
206
|
for (const s in o) {
|
|
207
207
|
if (Object.hasOwnProperty.call(o, s) === !1) continue;
|
|
208
208
|
const f = o[s];
|
|
209
|
-
typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (
|
|
209
|
+
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] = j(f) : u[s] = i(f);
|
|
210
210
|
}
|
|
211
211
|
return u;
|
|
212
212
|
}
|
|
213
213
|
function c(o) {
|
|
214
214
|
if (typeof o != "object" || o === null) return o;
|
|
215
|
-
if (Array.isArray(o)) return
|
|
216
|
-
if (o.constructor !== Object && (
|
|
217
|
-
return
|
|
215
|
+
if (Array.isArray(o)) return t(o, c);
|
|
216
|
+
if (o.constructor !== Object && (n = r.get(o.constructor)))
|
|
217
|
+
return n(o, c);
|
|
218
218
|
const u = {};
|
|
219
219
|
for (const s in o) {
|
|
220
220
|
const f = o[s];
|
|
221
|
-
typeof f != "object" || f === null ? u[s] = f : f.constructor !== Object && (
|
|
221
|
+
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] = j(f) : u[s] = c(f);
|
|
222
222
|
}
|
|
223
223
|
return u;
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
function te(e) {
|
|
227
|
-
const r = [],
|
|
228
|
-
if (
|
|
227
|
+
const r = [], n = [], t = /* @__PURE__ */ new Map();
|
|
228
|
+
if (t.set(Date, (s) => new Date(s)), t.set(
|
|
229
229
|
Map,
|
|
230
230
|
(s, f) => new Map(c(Array.from(s), f))
|
|
231
|
-
),
|
|
231
|
+
), t.set(
|
|
232
232
|
Set,
|
|
233
233
|
(s, f) => new Set(c(Array.from(s), f))
|
|
234
234
|
), e.constructorHandlers)
|
|
235
235
|
for (const s of e.constructorHandlers)
|
|
236
|
-
|
|
236
|
+
t.set(s[0], s[1]);
|
|
237
237
|
let i;
|
|
238
238
|
return e.proto ? u : o;
|
|
239
239
|
function c(s, f) {
|
|
@@ -242,13 +242,13 @@ function te(e) {
|
|
|
242
242
|
const m = l[y], d = s[m];
|
|
243
243
|
if (typeof d != "object" || d === null)
|
|
244
244
|
a[m] = d;
|
|
245
|
-
else if (d.constructor !== Object && (i =
|
|
245
|
+
else if (d.constructor !== Object && (i = t.get(d.constructor)))
|
|
246
246
|
a[m] = i(d, f);
|
|
247
247
|
else if (ArrayBuffer.isView(d))
|
|
248
248
|
a[m] = j(d);
|
|
249
249
|
else {
|
|
250
250
|
const h = r.indexOf(d);
|
|
251
|
-
h !== -1 ? a[m] =
|
|
251
|
+
h !== -1 ? a[m] = n[h] : a[m] = f(d);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
return a;
|
|
@@ -256,78 +256,78 @@ function te(e) {
|
|
|
256
256
|
function o(s) {
|
|
257
257
|
if (typeof s != "object" || s === null) return s;
|
|
258
258
|
if (Array.isArray(s)) return c(s, o);
|
|
259
|
-
if (s.constructor !== Object && (i =
|
|
259
|
+
if (s.constructor !== Object && (i = t.get(s.constructor)))
|
|
260
260
|
return i(s, o);
|
|
261
261
|
const f = {};
|
|
262
|
-
r.push(s),
|
|
262
|
+
r.push(s), n.push(f);
|
|
263
263
|
for (const l in s) {
|
|
264
264
|
if (Object.hasOwnProperty.call(s, l) === !1) continue;
|
|
265
265
|
const a = s[l];
|
|
266
266
|
if (typeof a != "object" || a === null)
|
|
267
267
|
f[l] = a;
|
|
268
|
-
else if (a.constructor !== Object && (i =
|
|
268
|
+
else if (a.constructor !== Object && (i = t.get(a.constructor)))
|
|
269
269
|
f[l] = i(a, o);
|
|
270
270
|
else if (ArrayBuffer.isView(a))
|
|
271
271
|
f[l] = j(a);
|
|
272
272
|
else {
|
|
273
273
|
const y = r.indexOf(a);
|
|
274
|
-
y !== -1 ? f[l] =
|
|
274
|
+
y !== -1 ? f[l] = n[y] : f[l] = o(a);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
return r.pop(),
|
|
277
|
+
return r.pop(), n.pop(), f;
|
|
278
278
|
}
|
|
279
279
|
function u(s) {
|
|
280
280
|
if (typeof s != "object" || s === null) return s;
|
|
281
281
|
if (Array.isArray(s)) return c(s, u);
|
|
282
|
-
if (s.constructor !== Object && (i =
|
|
282
|
+
if (s.constructor !== Object && (i = t.get(s.constructor)))
|
|
283
283
|
return i(s, u);
|
|
284
284
|
const f = {};
|
|
285
|
-
r.push(s),
|
|
285
|
+
r.push(s), n.push(f);
|
|
286
286
|
for (const l in s) {
|
|
287
287
|
const a = s[l];
|
|
288
288
|
if (typeof a != "object" || a === null)
|
|
289
289
|
f[l] = a;
|
|
290
|
-
else if (a.constructor !== Object && (i =
|
|
290
|
+
else if (a.constructor !== Object && (i = t.get(a.constructor)))
|
|
291
291
|
f[l] = i(a, u);
|
|
292
292
|
else if (ArrayBuffer.isView(a))
|
|
293
293
|
f[l] = j(a);
|
|
294
294
|
else {
|
|
295
295
|
const y = r.indexOf(a);
|
|
296
|
-
y !== -1 ? f[l] =
|
|
296
|
+
y !== -1 ? f[l] = n[y] : f[l] = u(a);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
return r.pop(),
|
|
299
|
+
return r.pop(), n.pop(), f;
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
const R = ee();
|
|
303
303
|
function ne(e, r = 8) {
|
|
304
|
-
const
|
|
305
|
-
let
|
|
304
|
+
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
305
|
+
let t = "";
|
|
306
306
|
for (let i = 0; i < r; i++) {
|
|
307
|
-
const c = Math.floor(Math.random() *
|
|
308
|
-
|
|
307
|
+
const c = Math.floor(Math.random() * n.length);
|
|
308
|
+
t += n[c];
|
|
309
309
|
}
|
|
310
|
-
return e ? `${e}${
|
|
310
|
+
return e ? `${e}${t}` : t;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
const
|
|
314
|
-
if (!
|
|
312
|
+
function Ve(e, r) {
|
|
313
|
+
const n = e.variables.find((t) => t.name === r);
|
|
314
|
+
if (!n)
|
|
315
315
|
throw new Error(`Variable "${r}" not found`);
|
|
316
|
-
return
|
|
316
|
+
return n;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
if (!
|
|
318
|
+
function ke(e, r) {
|
|
319
|
+
const n = e.utilities.find((t) => t.name === r);
|
|
320
|
+
if (!n)
|
|
321
321
|
throw new Error(`Utility "${r}" not found`);
|
|
322
|
-
return
|
|
322
|
+
return n;
|
|
323
323
|
}
|
|
324
324
|
function re(e, r) {
|
|
325
|
-
const
|
|
326
|
-
(
|
|
325
|
+
const n = e.modifiers.find(
|
|
326
|
+
(t) => t.key.includes(r)
|
|
327
327
|
);
|
|
328
|
-
if (!
|
|
328
|
+
if (!n)
|
|
329
329
|
throw new Error(`Modifier "${r}" not found`);
|
|
330
|
-
return
|
|
330
|
+
return n;
|
|
331
331
|
}
|
|
332
332
|
function M(e, r) {
|
|
333
333
|
if (e === r) return !0;
|
|
@@ -335,7 +335,7 @@ function M(e, r) {
|
|
|
335
335
|
if (e === null || r === null) return e === r;
|
|
336
336
|
if (typeof e != "object" || typeof r != "object") return !1;
|
|
337
337
|
if (Array.isArray(e) && Array.isArray(r))
|
|
338
|
-
return e.length !== r.length ? !1 : e.every((
|
|
338
|
+
return e.length !== r.length ? !1 : e.every((n, t) => M(n, r[t]));
|
|
339
339
|
if ("type" in e && "type" in r) {
|
|
340
340
|
if (e.type !== r.type) return !1;
|
|
341
341
|
if (A(e) && A(r))
|
|
@@ -345,9 +345,9 @@ function M(e, r) {
|
|
|
345
345
|
}
|
|
346
346
|
return !1;
|
|
347
347
|
}
|
|
348
|
-
const
|
|
348
|
+
const D = "__licenseRequired";
|
|
349
349
|
function ie(e) {
|
|
350
|
-
B(e) || Object.defineProperty(e,
|
|
350
|
+
B(e) || Object.defineProperty(e, D, {
|
|
351
351
|
value: !0,
|
|
352
352
|
writable: !1,
|
|
353
353
|
configurable: !1,
|
|
@@ -355,86 +355,86 @@ function ie(e) {
|
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
357
|
function B(e) {
|
|
358
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
358
|
+
return Object.prototype.hasOwnProperty.call(e, D);
|
|
359
359
|
}
|
|
360
360
|
function oe(e, r) {
|
|
361
|
-
const
|
|
362
|
-
for (const
|
|
363
|
-
const i =
|
|
364
|
-
(c) => c.name ===
|
|
361
|
+
const n = [...e];
|
|
362
|
+
for (const t of r) {
|
|
363
|
+
const i = n.find(
|
|
364
|
+
(c) => c.name === t.name
|
|
365
365
|
);
|
|
366
|
-
i ? i.value =
|
|
366
|
+
i ? i.value = t.value : n.push(t);
|
|
367
367
|
}
|
|
368
|
-
return
|
|
368
|
+
return n;
|
|
369
369
|
}
|
|
370
370
|
function se(e, r) {
|
|
371
|
-
const
|
|
372
|
-
for (const
|
|
373
|
-
const i =
|
|
374
|
-
(c) => c.name ===
|
|
371
|
+
const n = [...e];
|
|
372
|
+
for (const t of r) {
|
|
373
|
+
const i = n.find(
|
|
374
|
+
(c) => c.name === t.name
|
|
375
375
|
);
|
|
376
376
|
i ? Object.assign(
|
|
377
377
|
i,
|
|
378
|
-
|
|
379
|
-
) :
|
|
378
|
+
U(i, t)
|
|
379
|
+
) : n.push(t);
|
|
380
380
|
}
|
|
381
|
-
return
|
|
381
|
+
return n;
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function U(e, r) {
|
|
384
384
|
return Object.keys(e).reduce(
|
|
385
|
-
(
|
|
386
|
-
r[
|
|
387
|
-
)),
|
|
385
|
+
(n, t) => (t === "variables" ? n.variables = oe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && O(n) && O(e) && O(r) ? n.themes = se(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
|
|
386
|
+
r[t]
|
|
387
|
+
)), n),
|
|
388
388
|
{
|
|
389
389
|
...e,
|
|
390
390
|
...r
|
|
391
391
|
}
|
|
392
392
|
);
|
|
393
393
|
}
|
|
394
|
-
function
|
|
395
|
-
return r.reduce((
|
|
394
|
+
function Oe(e, ...r) {
|
|
395
|
+
return r.reduce((n, t) => {
|
|
396
396
|
const i = {
|
|
397
|
-
...
|
|
398
|
-
root:
|
|
397
|
+
...n,
|
|
398
|
+
root: U(n.root, t.root)
|
|
399
399
|
};
|
|
400
|
-
return (B(
|
|
400
|
+
return (B(n) || B(t)) && ie(i), i;
|
|
401
401
|
}, e);
|
|
402
402
|
}
|
|
403
403
|
function ce(e) {
|
|
404
404
|
const r = [];
|
|
405
|
-
function t
|
|
405
|
+
function n(t, i) {
|
|
406
406
|
i.length > 0 && r.push([...i].sort());
|
|
407
|
-
for (let c =
|
|
407
|
+
for (let c = t; c < e.length; c++) {
|
|
408
408
|
const o = e[c];
|
|
409
409
|
if (o)
|
|
410
410
|
if (o.length === 1 && o[0])
|
|
411
|
-
|
|
411
|
+
n(c + 1, [...i, o[0]]);
|
|
412
412
|
else
|
|
413
413
|
for (const u of o)
|
|
414
|
-
|
|
414
|
+
n(c + 1, [...i, u]);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
return
|
|
417
|
+
return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
|
|
418
418
|
}
|
|
419
|
-
function fe(e, r,
|
|
420
|
-
const
|
|
419
|
+
function fe(e, r, n) {
|
|
420
|
+
const t = {
|
|
421
421
|
...e,
|
|
422
|
-
modifiers: [...
|
|
423
|
-
}, i = v(
|
|
424
|
-
for (const c of
|
|
422
|
+
modifiers: [...n.keys()]
|
|
423
|
+
}, i = v(t, r);
|
|
424
|
+
for (const c of n.values())
|
|
425
425
|
c.factory({
|
|
426
426
|
...i,
|
|
427
|
-
declarations: R(
|
|
428
|
-
variables: R(
|
|
429
|
-
children: R(
|
|
430
|
-
}), V(
|
|
431
|
-
return
|
|
427
|
+
declarations: R(t.declarations),
|
|
428
|
+
variables: R(t.variables),
|
|
429
|
+
children: R(t.children)
|
|
430
|
+
}), V(t.declarations, i);
|
|
431
|
+
return t;
|
|
432
432
|
}
|
|
433
433
|
function ue(e, r) {
|
|
434
|
-
return function(
|
|
434
|
+
return function(t, i) {
|
|
435
435
|
const c = {
|
|
436
436
|
type: "modifier",
|
|
437
|
-
key: Array.isArray(
|
|
437
|
+
key: Array.isArray(t) ? t : [t],
|
|
438
438
|
factory: i
|
|
439
439
|
};
|
|
440
440
|
return r.modifiers.push(c), c;
|
|
@@ -453,10 +453,10 @@ function ae() {
|
|
|
453
453
|
};
|
|
454
454
|
}
|
|
455
455
|
function le(e, r) {
|
|
456
|
-
return function(
|
|
456
|
+
return function(t, i, c = {}) {
|
|
457
457
|
const o = {
|
|
458
458
|
type: "utility",
|
|
459
|
-
name:
|
|
459
|
+
name: t,
|
|
460
460
|
factory: i,
|
|
461
461
|
values: [],
|
|
462
462
|
autogenerate: c.autogenerate ?? z(),
|
|
@@ -477,7 +477,7 @@ function le(e, r) {
|
|
|
477
477
|
(h) => h.key === l && h.modifiers.length === 0
|
|
478
478
|
), m = {
|
|
479
479
|
type: "utility",
|
|
480
|
-
name:
|
|
480
|
+
name: t,
|
|
481
481
|
value: l,
|
|
482
482
|
declarations: {},
|
|
483
483
|
variables: [],
|
|
@@ -499,11 +499,11 @@ function le(e, r) {
|
|
|
499
499
|
(g) => g.key === l && g.modifiers.length === b.length && g.modifiers.every((w) => b.includes(w))
|
|
500
500
|
)).reduce((b, g) => {
|
|
501
501
|
const w = /* @__PURE__ */ new Map();
|
|
502
|
-
for (const
|
|
502
|
+
for (const K of g) {
|
|
503
503
|
const k = s.find(
|
|
504
|
-
(N) => N.key.includes(
|
|
504
|
+
(N) => N.key.includes(K)
|
|
505
505
|
);
|
|
506
|
-
k &&
|
|
506
|
+
k && q(k) && w.set(K, k);
|
|
507
507
|
}
|
|
508
508
|
return o.values.push({
|
|
509
509
|
key: l,
|
|
@@ -520,10 +520,10 @@ function le(e, r) {
|
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
522
|
function ye(e, r) {
|
|
523
|
-
return function(
|
|
524
|
-
const c = r.themes.find((s) => s.name ===
|
|
523
|
+
return function(t, i) {
|
|
524
|
+
const c = r.themes.find((s) => s.name === t), o = c ?? {
|
|
525
525
|
type: "theme",
|
|
526
|
-
name:
|
|
526
|
+
name: t,
|
|
527
527
|
declarations: {},
|
|
528
528
|
variables: [],
|
|
529
529
|
children: []
|
|
@@ -534,43 +534,43 @@ function ye(e, r) {
|
|
|
534
534
|
};
|
|
535
535
|
}
|
|
536
536
|
function de(e, r) {
|
|
537
|
-
return function(
|
|
537
|
+
return function(t) {
|
|
538
538
|
const i = {
|
|
539
539
|
type: "recipe",
|
|
540
|
-
...
|
|
540
|
+
...t
|
|
541
541
|
};
|
|
542
|
-
return i._runtime = me(i, r), r.recipes.push(i), i;
|
|
542
|
+
return i._runtime = me(i, r), pe(i, r), r.recipes.push(i), i;
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
const
|
|
547
|
-
return Object.keys(
|
|
545
|
+
function _(e, r) {
|
|
546
|
+
const n = e.autogenerate(r);
|
|
547
|
+
return Object.keys(n)[0] ?? "default";
|
|
548
548
|
}
|
|
549
549
|
function F(e, r) {
|
|
550
|
-
const
|
|
551
|
-
for (const [
|
|
550
|
+
const n = {};
|
|
551
|
+
for (const [t, i] of Object.entries(e))
|
|
552
552
|
if (P(i)) {
|
|
553
553
|
const c = {};
|
|
554
554
|
for (const [o, u] of Object.entries(i)) {
|
|
555
555
|
const s = T(r, o);
|
|
556
|
-
s && (c[o] =
|
|
556
|
+
s && (c[o] = _(
|
|
557
557
|
s,
|
|
558
558
|
u
|
|
559
559
|
));
|
|
560
560
|
}
|
|
561
|
-
t
|
|
561
|
+
n[t] = c;
|
|
562
562
|
} else if (typeof i == "boolean")
|
|
563
|
-
t
|
|
563
|
+
n[t] = i;
|
|
564
564
|
else {
|
|
565
|
-
const c = T(r,
|
|
566
|
-
c && (t
|
|
565
|
+
const c = T(r, t);
|
|
566
|
+
c && (n[t] = _(c, i));
|
|
567
567
|
}
|
|
568
|
-
return
|
|
568
|
+
return n;
|
|
569
569
|
}
|
|
570
570
|
function me(e, r) {
|
|
571
|
-
const
|
|
572
|
-
if (e.base && (
|
|
573
|
-
const
|
|
571
|
+
const n = {};
|
|
572
|
+
if (e.base && (n.base = F(e.base, r)), e.variants) {
|
|
573
|
+
const t = {};
|
|
574
574
|
for (const [i, c] of Object.entries(e.variants)) {
|
|
575
575
|
const o = {};
|
|
576
576
|
for (const [u, s] of Object.entries(
|
|
@@ -580,48 +580,52 @@ function me(e, r) {
|
|
|
580
580
|
s,
|
|
581
581
|
r
|
|
582
582
|
);
|
|
583
|
-
|
|
583
|
+
t[i] = o;
|
|
584
584
|
}
|
|
585
|
-
|
|
585
|
+
n.variants = t;
|
|
586
586
|
}
|
|
587
|
-
return e.defaultVariants && (
|
|
588
|
-
match: { ...
|
|
589
|
-
css: F(
|
|
590
|
-
}))),
|
|
587
|
+
return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
|
|
588
|
+
match: { ...t.match },
|
|
589
|
+
css: F(t.css, r)
|
|
590
|
+
}))), n;
|
|
591
591
|
}
|
|
592
592
|
function P(e) {
|
|
593
593
|
return !A(e) && typeof e == "object" && e !== null;
|
|
594
594
|
}
|
|
595
595
|
function x(e, r) {
|
|
596
|
-
const
|
|
597
|
-
let o = r.get(
|
|
598
|
-
o || (o = [], r.set(
|
|
596
|
+
const n = (t, i, c) => {
|
|
597
|
+
let o = r.get(t);
|
|
598
|
+
o || (o = [], r.set(t, o)), o.push({ value: i, modifiers: c });
|
|
599
599
|
};
|
|
600
|
-
for (const [
|
|
600
|
+
for (const [t, i] of Object.entries(e))
|
|
601
601
|
if (P(i)) {
|
|
602
|
-
const c =
|
|
602
|
+
const c = t.split(":");
|
|
603
603
|
for (const [o, u] of Object.entries(i))
|
|
604
|
-
|
|
604
|
+
n(o, u, c);
|
|
605
605
|
} else
|
|
606
|
-
t
|
|
606
|
+
n(t, i, []);
|
|
607
607
|
}
|
|
608
608
|
function T(e, r) {
|
|
609
|
-
|
|
609
|
+
const n = e.utilities.find((i) => i.name === r);
|
|
610
|
+
if (n)
|
|
611
|
+
return n;
|
|
612
|
+
const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
|
|
613
|
+
return e.utilities.find((i) => i.name === t);
|
|
610
614
|
}
|
|
611
|
-
function
|
|
612
|
-
const
|
|
613
|
-
if (e.base && x(e.base,
|
|
615
|
+
function pe(e, r) {
|
|
616
|
+
const n = /* @__PURE__ */ new Map();
|
|
617
|
+
if (e.base && x(e.base, n), e.variants)
|
|
614
618
|
for (const i of Object.values(e.variants))
|
|
615
619
|
for (const c of Object.values(i))
|
|
616
620
|
x(
|
|
617
621
|
c,
|
|
618
|
-
|
|
622
|
+
n
|
|
619
623
|
);
|
|
620
624
|
if (e.compoundVariants)
|
|
621
625
|
for (const i of e.compoundVariants)
|
|
622
|
-
i.css && x(i.css,
|
|
623
|
-
const
|
|
624
|
-
for (const [i, c] of
|
|
626
|
+
i.css && x(i.css, n);
|
|
627
|
+
const t = /* @__PURE__ */ new Map();
|
|
628
|
+
for (const [i, c] of n) {
|
|
625
629
|
const o = T(r, i);
|
|
626
630
|
if (!o) {
|
|
627
631
|
console.warn(
|
|
@@ -632,15 +636,15 @@ function Oe(e, r) {
|
|
|
632
636
|
for (const u of c) {
|
|
633
637
|
const s = [];
|
|
634
638
|
for (const f of u.modifiers) {
|
|
635
|
-
if (!
|
|
639
|
+
if (!t.has(f))
|
|
636
640
|
try {
|
|
637
|
-
|
|
641
|
+
t.set(f, re(r, f));
|
|
638
642
|
} catch {
|
|
639
643
|
console.warn(
|
|
640
644
|
`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
|
|
641
|
-
),
|
|
645
|
+
), t.set(f, null);
|
|
642
646
|
}
|
|
643
|
-
const l =
|
|
647
|
+
const l = t.get(f);
|
|
644
648
|
l && s.push(l);
|
|
645
649
|
}
|
|
646
650
|
o.create(
|
|
@@ -651,10 +655,10 @@ function Oe(e, r) {
|
|
|
651
655
|
}
|
|
652
656
|
}
|
|
653
657
|
function Re(e) {
|
|
654
|
-
const r = ne("sf-"),
|
|
658
|
+
const r = ne("sf-"), n = ae(), t = { ...e }, i = le(n, n), c = ue(n, n), o = de(n, n), u = ye(n, n), { variable: s, selector: f, atRule: l, keyframes: a, media: y, ref: m, css: d } = v(n, n);
|
|
655
659
|
return {
|
|
656
660
|
id: r,
|
|
657
|
-
root:
|
|
661
|
+
root: n,
|
|
658
662
|
variable: s,
|
|
659
663
|
selector: f,
|
|
660
664
|
utility: i,
|
|
@@ -666,54 +670,54 @@ function Re(e) {
|
|
|
666
670
|
media: y,
|
|
667
671
|
ref: m,
|
|
668
672
|
css: d,
|
|
669
|
-
options:
|
|
673
|
+
options: t
|
|
670
674
|
};
|
|
671
675
|
}
|
|
672
676
|
export {
|
|
673
677
|
fe as applyModifiers,
|
|
674
|
-
|
|
678
|
+
we as capitalizeFirst,
|
|
675
679
|
ce as combineKeys,
|
|
676
|
-
|
|
680
|
+
C as createAtRuleFunction,
|
|
677
681
|
W as createCssFunction,
|
|
678
682
|
v as createDeclarationsCallbackContext,
|
|
679
|
-
|
|
683
|
+
Z as createKeyframesFunction,
|
|
680
684
|
Y as createMediaFunction,
|
|
681
685
|
ue as createModifierFunction,
|
|
682
686
|
de as createRecipeFunction,
|
|
683
|
-
|
|
687
|
+
J as createRefFunction,
|
|
684
688
|
ae as createRoot,
|
|
685
|
-
|
|
689
|
+
Q as createSelectorFunction,
|
|
686
690
|
ye as createThemeFunction,
|
|
687
691
|
le as createUtilityFunction,
|
|
688
|
-
|
|
692
|
+
X as createVariableFunction,
|
|
689
693
|
R as deepClone,
|
|
690
694
|
ne as generateRandomId,
|
|
691
695
|
me as generateRecipeRuntime,
|
|
692
696
|
re as getModifier,
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
697
|
+
ke as getUtility,
|
|
698
|
+
Ve as getVariable,
|
|
699
|
+
ge as isAtRule,
|
|
696
700
|
E as isCSS,
|
|
697
|
-
|
|
698
|
-
|
|
701
|
+
I as isContainer,
|
|
702
|
+
q as isModifier,
|
|
699
703
|
S as isObject,
|
|
700
|
-
|
|
701
|
-
|
|
704
|
+
G as isPrimitiveTokenValue,
|
|
705
|
+
Ae as isRecipe,
|
|
702
706
|
A as isRef,
|
|
703
707
|
O as isRoot,
|
|
704
|
-
|
|
705
|
-
|
|
708
|
+
be as isSelector,
|
|
709
|
+
ve as isTheme,
|
|
706
710
|
p as isToken,
|
|
707
711
|
M as isTokenEqual,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
712
|
+
$ as isTokenValue,
|
|
713
|
+
je as isUtility,
|
|
714
|
+
L as isVariable,
|
|
715
|
+
Oe as merge,
|
|
716
|
+
U as mergeContainers,
|
|
713
717
|
se as mergeThemesArray,
|
|
714
718
|
oe as mergeVariablesArray,
|
|
715
719
|
V as parseDeclarationsBlock,
|
|
716
|
-
|
|
720
|
+
pe as processRecipeUtilities,
|
|
717
721
|
ee as rfdc,
|
|
718
722
|
Re as styleframe,
|
|
719
723
|
z as transformUtilityKey
|
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 P(e){return p(e,"variable")}function A(e){return p(e,"reference")}function ye(e){return p(e,"selector")}function de(e){return p(e,"at-rule")}function me(e){return p(e,"utility")}function $(e){return p(e,"modifier")}function k(e){return p(e,"css")}function he(e){return p(e,"theme")}function F(e){return p(e,"root")}function pe(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 t=r,n;if(typeof t=="string"&&t[0]==="@"){const i=t.slice(1);n=e(i),t={type:"reference",name:i}}else A(t)?n=e(t.name):n=`[${r}]`;return{[n]:t}}}function I(e,r){return function(n,...i){return{type:"css",value:n.reduce((o,u,s)=>(o.push(u),s<i.length&&o.push(i[s]),o),[])}}}function O(e,r){return function(n,i,c){const o={type:"at-rule",identifier:n,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 z(e,r){const t=O(e,r);return function(i,c){return t("media",i,c)}}function G(e,r){const t=O(e,r);return function(i,c){return t("keyframes",i,c)}}function L(e,r){return function(n,i){return P(n)?{type:"reference",name:n.name,fallback:i}:{type:"reference",name:n,fallback:i}}}function W(e,r){return function(n,i){const c={type:"selector",query:n,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(n,i,c={default:!1}){const o=typeof n=="string"?n:n.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 t=Y(e),n=W(e,r),i=O(e,r),c=G(r,r),o=z(e,r),u=L(),s=I();return{variable:t,selector:n,keyframes:c,atRule:i,media:o,ref:u,css:s}}function w(e,r){for(const t in e)if(t.startsWith("@")){const n=e[t];if(typeof n=="object"&&n!==null&&!S(n)){const i=t.replace(/^@(\w+).*/,"$1"),c=t.replace(`@${i}`,"").trim();r.atRule(i,c,n),delete e[t]}}else if(/^[.&:]/.test(t)){const n=e[t];typeof n=="object"&&(r.selector(t,n),delete e[t])}return e}function be(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 J(e){if(e=e||{},e.circular)return ge(e);const r=new Map;if(r.set(Date,o=>new Date(o)),r.set(Map,(o,u)=>new Map(n(Array.from(o),u))),r.set(Set,(o,u)=>new Set(n(Array.from(o),u))),e.constructorHandlers)for(const o of e.constructorHandlers)r.set(o[0],o[1]);let t;return e.proto?c:i;function n(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&&(t=r.get(d.constructor))?f[l]=t(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 n(o,i);if(o.constructor!==Object&&(t=r.get(o.constructor)))return t(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&&(t=r.get(f.constructor))?u[s]=t(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 n(o,c);if(o.constructor!==Object&&(t=r.get(o.constructor)))return t(o,c);const u={};for(const s in o){const f=o[s];typeof f!="object"||f===null?u[s]=f:f.constructor!==Object&&(t=r.get(f.constructor))?u[s]=t(f,c):ArrayBuffer.isView(f)?u[s]=R(f):u[s]=c(f)}return u}}function ge(e){const r=[],t=[],n=new Map;if(n.set(Date,s=>new Date(s)),n.set(Map,(s,f)=>new Map(c(Array.from(s),f))),n.set(Set,(s,f)=>new Set(c(Array.from(s),f))),e.constructorHandlers)for(const s of e.constructorHandlers)n.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=n.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]=t[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=n.get(s.constructor)))return i(s,o);const f={};r.push(s),t.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=n.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]=t[d]:f[y]=o(l)}}return r.pop(),t.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=n.get(s.constructor)))return i(s,u);const f={};r.push(s),t.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=n.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]=t[d]:f[y]=u(l)}}return r.pop(),t.pop(),f}}const M=J();function Q(e,r=8){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let i=0;i<r;i++){const c=Math.floor(Math.random()*t.length);n+=t[c]}return e?`${e}${n}`:n}function je(e,r){const t=e.variables.find(n=>n.name===r);if(!t)throw new Error(`Variable "${r}" not found`);return t}function ve(e,r){const t=e.utilities.find(n=>n.name===r);if(!t)throw new Error(`Utility "${r}" not found`);return t}function X(e,r){const t=e.modifiers.find(n=>n.key.includes(r));if(!t)throw new Error(`Modifier "${r}" not found`);return t}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((t,n)=>T(t,r[n]));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 Z="__licenseRequired";function Ae(e){E(e)||Object.defineProperty(e,Z,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function E(e){return Object.prototype.hasOwnProperty.call(e,Z)}function x(e,r){const t=[...e];for(const n of r){const i=t.find(c=>c.name===n.name);i?i.value=n.value:t.push(n)}return t}function ee(e,r){const t=[...e];for(const n of r){const i=t.find(c=>c.name===n.name);i?Object.assign(i,B(i,n)):t.push(n)}return t}function B(e,r){return Object.keys(e).reduce((t,n)=>(n==="variables"?t.variables=x(e.variables,r.variables):n==="declarations"?t.declarations={...e.declarations,...r.declarations}:n==="themes"&&F(t)&&F(e)&&F(r)?t.themes=ee(e.themes,r.themes):Array.isArray(e[n])&&(t[n]=e[n].concat(r[n])),t),{...e,...r})}function Re(e,...r){return r.reduce((t,n)=>{const i={...t,root:B(t.root,n.root)};return(E(t)||E(n))&&Ae(i),i},e)}function te(e){const r=[];function t(n,i){i.length>0&&r.push([...i].sort());for(let c=n;c<e.length;c++){const o=e[c];if(o)if(o.length===1&&o[0])t(c+1,[...i,o[0]]);else for(const u of o)t(c+1,[...i,u])}}return t(0,[]),r.sort((n,i)=>n.length!==i.length?n.length-i.length:n.join(",").localeCompare(i.join(",")))}function ne(e,r,t){const n={...e,modifiers:[...t.keys()]},i=g(n,r);for(const c of t.values())c.factory({...i,declarations:M(n.declarations),variables:M(n.variables),children:M(n.children)}),w(n.declarations,i);return n}function re(e,r){return function(n,i){const c={type:"modifier",key:Array.isArray(n)?n:[n],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(n,i,c={}){const o={type:"utility",name:n,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:n,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 le of V){const _=s.find(Fe=>Fe.key.includes(le));_&&$(_)&&C.set(le,_)}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(n,i){const c=r.themes.find(s=>s.name===n),o=c??{type:"theme",name:n,declarations:{},variables:[],children:[]};c||r.themes.push(o);const u=g(o,r);return i&&i(u),o}}function ce(e,r){return function(n){const i={type:"recipe",...n};return i._runtime=ue(i,r),r.recipes.push(i),i}}function fe(e,r){const t=e.autogenerate(r);return Object.keys(t)[0]??"default"}function K(e,r){const t={};for(const[n,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))}t[n]=c}else if(typeof i=="boolean")t[n]=i;else{const c=D(r,n);c&&(t[n]=fe(c,i))}return t}function ue(e,r){const t={};if(e.base&&(t.base=K(e.base,r)),e.variants){const n={};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);n[i]=o}t.variants=n}return e.defaultVariants&&(t.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(t.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},css:K(n.css,r)}))),t}function ae(e){return!A(e)&&typeof e=="object"&&e!==null}function U(e,r){const t=(n,i,c)=>{let o=r.get(n);o||(o=[],r.set(n,o)),o.push({value:i,modifiers:c})};for(const[n,i]of Object.entries(e))if(ae(i)){const c=n.split(":");for(const[o,u]of Object.entries(i))t(o,u,c)}else t(n,i,[])}function D(e,r){return e.utilities.find(t=>t.name===r)}function Ve(e,r){const t=new Map;if(e.base&&U(e.base,t),e.variants)for(const i of Object.values(e.variants))for(const c of Object.values(i))U(c,t);if(e.compoundVariants)for(const i of e.compoundVariants)i.css&&U(i.css,t);const n=new Map;for(const[i,c]of t){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(!n.has(f))try{n.set(f,X(r,f))}catch{console.warn(`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`),n.set(f,null)}const y=n.get(f);y&&s.push(y)}o.create([u.value],s.length>0?s:void 0)}}}function we(e){const r=Q("sf-"),t=ie(),n={...e},i=oe(t,t),c=re(t,t),o=ce(t,t),u=se(t,t),{variable:s,selector:f,atRule:y,keyframes:l,media:d,ref:h,css:m}=g(t,t);return{id:r,root:t,variable:s,selector:f,utility:i,modifier:c,recipe:o,theme:u,atRule:y,keyframes:l,media:d,ref:h,css:m,options:n}}a.applyModifiers=ne,a.capitalizeFirst=be,a.combineKeys=te,a.createAtRuleFunction=O,a.createCssFunction=I,a.createDeclarationsCallbackContext=g,a.createKeyframesFunction=G,a.createMediaFunction=z,a.createModifierFunction=re,a.createRecipeFunction=ce,a.createRefFunction=L,a.createRoot=ie,a.createSelectorFunction=W,a.createThemeFunction=se,a.createUtilityFunction=oe,a.createVariableFunction=Y,a.deepClone=M,a.generateRandomId=Q,a.generateRecipeRuntime=ue,a.getModifier=X,a.getUtility=ve,a.getVariable=je,a.isAtRule=de,a.isCSS=k,a.isContainer=N,a.isModifier=$,a.isObject=b,a.isPrimitiveTokenValue=H,a.isRecipe=pe,a.isRef=A,a.isRoot=F,a.isSelector=ye,a.isTheme=he,a.isToken=p,a.isTokenEqual=T,a.isTokenValue=S,a.isUtility=me,a.isVariable=P,a.merge=Re,a.mergeContainers=B,a.mergeThemesArray=ee,a.mergeVariablesArray=x,a.parseDeclarationsBlock=w,a.processRecipeUtilities=Ve,a.rfdc=J,a.styleframe=we,a.transformUtilityKey=q,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
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"})}));
|