@styleframe/core 1.0.2 → 1.0.3
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 +7 -0
- package/dist/styleframe.js +221 -206
- package/dist/styleframe.umd.cjs +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @styleframe/core
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`6700e6f`](https://github.com/styleframe-dev/styleframe/commit/6700e6fa835183ac50808c05d44154c25e85e9e1)]:
|
|
8
|
+
- @styleframe/license@1.0.0
|
|
9
|
+
|
|
3
10
|
## 1.0.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/styleframe.js
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
function
|
|
2
|
-
return function(n, ...
|
|
1
|
+
function k(e, t) {
|
|
2
|
+
return function(n, ...i) {
|
|
3
3
|
return {
|
|
4
4
|
type: "css",
|
|
5
|
-
value: n.reduce((
|
|
5
|
+
value: n.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function R(e) {
|
|
10
10
|
return typeof e == "object" && e !== null;
|
|
11
11
|
}
|
|
12
12
|
function p(e, t) {
|
|
13
|
-
return
|
|
13
|
+
return R(e) && "type" in e && e.type === t;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function B(e) {
|
|
16
16
|
return p(e, "variable");
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function F(e) {
|
|
19
19
|
return p(e, "reference");
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function X(e) {
|
|
22
22
|
return p(e, "selector");
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function Z(e) {
|
|
25
25
|
return p(e, "at-rule");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ee(e) {
|
|
28
28
|
return p(e, "utility");
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function te(e) {
|
|
31
31
|
return p(e, "modifier");
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function T(e) {
|
|
34
34
|
return p(e, "css");
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function ne(e) {
|
|
37
37
|
return p(e, "theme");
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function j(e) {
|
|
40
40
|
return p(e, "root");
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function _(e) {
|
|
43
43
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function V(e) {
|
|
46
|
+
return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(V);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function C(e) {
|
|
49
|
+
return R(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return function(n,
|
|
53
|
-
const
|
|
51
|
+
function v(e, t) {
|
|
52
|
+
return function(n, i, s) {
|
|
53
|
+
const o = {
|
|
54
54
|
type: "at-rule",
|
|
55
55
|
identifier: n,
|
|
56
|
-
rule:
|
|
56
|
+
rule: i,
|
|
57
57
|
declarations: {},
|
|
58
58
|
variables: [],
|
|
59
59
|
children: []
|
|
60
|
-
}, u = b(
|
|
61
|
-
return typeof s == "function" ?
|
|
60
|
+
}, u = b(o, t);
|
|
61
|
+
return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
const r =
|
|
66
|
-
return function(
|
|
67
|
-
return r("media",
|
|
64
|
+
function S(e, t) {
|
|
65
|
+
const r = v(e, t);
|
|
66
|
+
return function(i, s) {
|
|
67
|
+
return r("media", i, s);
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const r =
|
|
72
|
-
return function(
|
|
73
|
-
return r("keyframes",
|
|
70
|
+
function E(e, t) {
|
|
71
|
+
const r = v(e, t);
|
|
72
|
+
return function(i, s) {
|
|
73
|
+
return r("keyframes", i, s);
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return function(n,
|
|
78
|
-
return
|
|
76
|
+
function P(e, t) {
|
|
77
|
+
return function(n, i) {
|
|
78
|
+
return B(n) ? {
|
|
79
79
|
type: "reference",
|
|
80
80
|
name: n.name,
|
|
81
|
-
fallback:
|
|
81
|
+
fallback: i
|
|
82
82
|
} : {
|
|
83
83
|
type: "reference",
|
|
84
84
|
name: n,
|
|
85
|
-
fallback:
|
|
85
|
+
fallback: i
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
return function(n,
|
|
89
|
+
function D(e, t) {
|
|
90
|
+
return function(n, i) {
|
|
91
91
|
const s = {
|
|
92
92
|
type: "selector",
|
|
93
93
|
query: n,
|
|
94
94
|
declarations: {},
|
|
95
95
|
variables: [],
|
|
96
96
|
children: []
|
|
97
|
-
},
|
|
98
|
-
return typeof
|
|
97
|
+
}, o = b(s, t);
|
|
98
|
+
return typeof i == "function" ? s.declarations = i(o) ?? {} : C(i) ? (s.variables = i.variables, s.declarations = i.declarations, s.children = i.children) : s.declarations = i, g(s.declarations, o), e.children.push(s), s;
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
return function(n,
|
|
101
|
+
function H(e, t) {
|
|
102
|
+
return function(n, i, s = {
|
|
103
103
|
default: !1
|
|
104
104
|
}) {
|
|
105
|
-
const
|
|
106
|
-
(f) => f.name ===
|
|
105
|
+
const o = typeof n == "string" ? n : n.name, u = e.variables.find(
|
|
106
|
+
(f) => f.name === o
|
|
107
107
|
);
|
|
108
108
|
if (s.default && u)
|
|
109
109
|
return u;
|
|
110
110
|
if (u)
|
|
111
|
-
return u.value =
|
|
111
|
+
return u.value = i, u;
|
|
112
112
|
const c = {
|
|
113
113
|
type: "variable",
|
|
114
|
-
name:
|
|
115
|
-
value:
|
|
114
|
+
name: o,
|
|
115
|
+
value: i
|
|
116
116
|
};
|
|
117
117
|
return e.variables.push(c), c;
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
function b(e, t) {
|
|
121
|
-
const r =
|
|
121
|
+
const r = H(e), n = D(e, t), i = v(e, t), s = E(t, t), o = S(e, t), u = P(), c = k();
|
|
122
122
|
return {
|
|
123
123
|
variable: r,
|
|
124
124
|
selector: n,
|
|
125
125
|
keyframes: s,
|
|
126
|
-
atRule:
|
|
127
|
-
media:
|
|
126
|
+
atRule: i,
|
|
127
|
+
media: o,
|
|
128
128
|
ref: u,
|
|
129
129
|
css: c
|
|
130
130
|
};
|
|
@@ -133,9 +133,9 @@ function g(e, t) {
|
|
|
133
133
|
for (const r in e)
|
|
134
134
|
if (r.startsWith("@")) {
|
|
135
135
|
const n = e[r];
|
|
136
|
-
if (typeof n == "object" && n !== null && !
|
|
137
|
-
const
|
|
138
|
-
t.atRule(
|
|
136
|
+
if (typeof n == "object" && n !== null && !V(n)) {
|
|
137
|
+
const i = r.replace(/^@(\w+).*/, "$1"), s = r.replace(`@${i}`, "").trim();
|
|
138
|
+
t.atRule(i, s, n), delete e[r];
|
|
139
139
|
}
|
|
140
140
|
} else if (/^[.&:]/.test(r)) {
|
|
141
141
|
const n = e[r];
|
|
@@ -143,7 +143,7 @@ function g(e, t) {
|
|
|
143
143
|
}
|
|
144
144
|
return e;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function re(e) {
|
|
147
147
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
148
148
|
}
|
|
149
149
|
function m(e) {
|
|
@@ -156,56 +156,56 @@ function m(e) {
|
|
|
156
156
|
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function K(e) {
|
|
160
160
|
if (e = e || {}, e.circular)
|
|
161
|
-
return
|
|
161
|
+
return U(e);
|
|
162
162
|
const t = /* @__PURE__ */ new Map();
|
|
163
|
-
if (t.set(Date, (
|
|
163
|
+
if (t.set(Date, (o) => new Date(o)), t.set(
|
|
164
164
|
Map,
|
|
165
|
-
(
|
|
165
|
+
(o, u) => new Map(n(Array.from(o), u))
|
|
166
166
|
), t.set(
|
|
167
167
|
Set,
|
|
168
|
-
(
|
|
168
|
+
(o, u) => new Set(n(Array.from(o), u))
|
|
169
169
|
), e.constructorHandlers)
|
|
170
|
-
for (const
|
|
171
|
-
t.set(
|
|
170
|
+
for (const o of e.constructorHandlers)
|
|
171
|
+
t.set(o[0], o[1]);
|
|
172
172
|
let r;
|
|
173
|
-
return e.proto ? s :
|
|
174
|
-
function n(
|
|
175
|
-
const c = Object.keys(
|
|
173
|
+
return e.proto ? s : i;
|
|
174
|
+
function n(o, u) {
|
|
175
|
+
const c = Object.keys(o), f = Array.from({ length: c.length });
|
|
176
176
|
for (let a = 0; a < c.length; a++) {
|
|
177
|
-
const l = c[a], y =
|
|
177
|
+
const l = c[a], y = o[l];
|
|
178
178
|
typeof y != "object" || y === null ? f[l] = y : y.constructor !== Object && (r = t.get(y.constructor)) ? f[l] = r(y, u) : ArrayBuffer.isView(y) ? f[l] = m(y) : f[l] = u(y);
|
|
179
179
|
}
|
|
180
180
|
return f;
|
|
181
181
|
}
|
|
182
|
-
function o
|
|
183
|
-
if (typeof
|
|
184
|
-
if (Array.isArray(
|
|
185
|
-
if (
|
|
186
|
-
return r(
|
|
182
|
+
function i(o) {
|
|
183
|
+
if (typeof o != "object" || o === null) return o;
|
|
184
|
+
if (Array.isArray(o)) return n(o, i);
|
|
185
|
+
if (o.constructor !== Object && (r = t.get(o.constructor)))
|
|
186
|
+
return r(o, i);
|
|
187
187
|
const u = {};
|
|
188
|
-
for (const c in
|
|
189
|
-
if (Object.hasOwnProperty.call(
|
|
190
|
-
const f =
|
|
191
|
-
typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f,
|
|
188
|
+
for (const c in o) {
|
|
189
|
+
if (Object.hasOwnProperty.call(o, c) === !1) continue;
|
|
190
|
+
const f = o[c];
|
|
191
|
+
typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, i) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = i(f);
|
|
192
192
|
}
|
|
193
193
|
return u;
|
|
194
194
|
}
|
|
195
|
-
function s(
|
|
196
|
-
if (typeof
|
|
197
|
-
if (Array.isArray(
|
|
198
|
-
if (
|
|
199
|
-
return r(
|
|
195
|
+
function s(o) {
|
|
196
|
+
if (typeof o != "object" || o === null) return o;
|
|
197
|
+
if (Array.isArray(o)) return n(o, s);
|
|
198
|
+
if (o.constructor !== Object && (r = t.get(o.constructor)))
|
|
199
|
+
return r(o, s);
|
|
200
200
|
const u = {};
|
|
201
|
-
for (const c in
|
|
202
|
-
const f =
|
|
201
|
+
for (const c in o) {
|
|
202
|
+
const f = o[c];
|
|
203
203
|
typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
|
|
204
204
|
}
|
|
205
205
|
return u;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function U(e) {
|
|
209
209
|
const t = [], r = [], n = /* @__PURE__ */ new Map();
|
|
210
210
|
if (n.set(Date, (c) => new Date(c)), n.set(
|
|
211
211
|
Map,
|
|
@@ -216,30 +216,30 @@ function K(e) {
|
|
|
216
216
|
), e.constructorHandlers)
|
|
217
217
|
for (const c of e.constructorHandlers)
|
|
218
218
|
n.set(c[0], c[1]);
|
|
219
|
-
let
|
|
220
|
-
return e.proto ? u :
|
|
219
|
+
let i;
|
|
220
|
+
return e.proto ? u : o;
|
|
221
221
|
function s(c, f) {
|
|
222
222
|
const a = Object.keys(c), l = Array.from({ length: a.length });
|
|
223
223
|
for (let y = 0; y < a.length; y++) {
|
|
224
224
|
const h = a[y], d = c[h];
|
|
225
225
|
if (typeof d != "object" || d === null)
|
|
226
226
|
l[h] = d;
|
|
227
|
-
else if (d.constructor !== Object && (
|
|
228
|
-
l[h] =
|
|
227
|
+
else if (d.constructor !== Object && (i = n.get(d.constructor)))
|
|
228
|
+
l[h] = i(d, f);
|
|
229
229
|
else if (ArrayBuffer.isView(d))
|
|
230
230
|
l[h] = m(d);
|
|
231
231
|
else {
|
|
232
|
-
const
|
|
233
|
-
|
|
232
|
+
const O = t.indexOf(d);
|
|
233
|
+
O !== -1 ? l[h] = r[O] : l[h] = f(d);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
return l;
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function o(c) {
|
|
239
239
|
if (typeof c != "object" || c === null) return c;
|
|
240
|
-
if (Array.isArray(c)) return s(c,
|
|
241
|
-
if (c.constructor !== Object && (
|
|
242
|
-
return
|
|
240
|
+
if (Array.isArray(c)) return s(c, o);
|
|
241
|
+
if (c.constructor !== Object && (i = n.get(c.constructor)))
|
|
242
|
+
return i(c, o);
|
|
243
243
|
const f = {};
|
|
244
244
|
t.push(c), r.push(f);
|
|
245
245
|
for (const a in c) {
|
|
@@ -247,13 +247,13 @@ function K(e) {
|
|
|
247
247
|
const l = c[a];
|
|
248
248
|
if (typeof l != "object" || l === null)
|
|
249
249
|
f[a] = l;
|
|
250
|
-
else if (l.constructor !== Object && (
|
|
251
|
-
f[a] =
|
|
250
|
+
else if (l.constructor !== Object && (i = n.get(l.constructor)))
|
|
251
|
+
f[a] = i(l, o);
|
|
252
252
|
else if (ArrayBuffer.isView(l))
|
|
253
253
|
f[a] = m(l);
|
|
254
254
|
else {
|
|
255
255
|
const y = t.indexOf(l);
|
|
256
|
-
y !== -1 ? f[a] = r[y] : f[a] =
|
|
256
|
+
y !== -1 ? f[a] = r[y] : f[a] = o(l);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
return t.pop(), r.pop(), f;
|
|
@@ -261,16 +261,16 @@ function K(e) {
|
|
|
261
261
|
function u(c) {
|
|
262
262
|
if (typeof c != "object" || c === null) return c;
|
|
263
263
|
if (Array.isArray(c)) return s(c, u);
|
|
264
|
-
if (c.constructor !== Object && (
|
|
265
|
-
return
|
|
264
|
+
if (c.constructor !== Object && (i = n.get(c.constructor)))
|
|
265
|
+
return i(c, u);
|
|
266
266
|
const f = {};
|
|
267
267
|
t.push(c), r.push(f);
|
|
268
268
|
for (const a in c) {
|
|
269
269
|
const l = c[a];
|
|
270
270
|
if (typeof l != "object" || l === null)
|
|
271
271
|
f[a] = l;
|
|
272
|
-
else if (l.constructor !== Object && (
|
|
273
|
-
f[a] =
|
|
272
|
+
else if (l.constructor !== Object && (i = n.get(l.constructor)))
|
|
273
|
+
f[a] = i(l, u);
|
|
274
274
|
else if (ArrayBuffer.isView(l))
|
|
275
275
|
f[a] = m(l);
|
|
276
276
|
else {
|
|
@@ -281,20 +281,20 @@ function K(e) {
|
|
|
281
281
|
return t.pop(), r.pop(), f;
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
const
|
|
285
|
-
function
|
|
284
|
+
const A = K();
|
|
285
|
+
function ie(e, t) {
|
|
286
286
|
const r = e.variables.find((n) => n.name === t);
|
|
287
287
|
if (!r)
|
|
288
288
|
throw new Error(`Variable "${t}" not found`);
|
|
289
289
|
return r;
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function oe(e, t) {
|
|
292
292
|
const r = e.utilities.find((n) => n.name === t);
|
|
293
293
|
if (!r)
|
|
294
294
|
throw new Error(`Utility "${t}" not found`);
|
|
295
295
|
return r;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function ce(e, t) {
|
|
298
298
|
const r = e.modifiers.find(
|
|
299
299
|
(n) => n.key.includes(t)
|
|
300
300
|
);
|
|
@@ -302,32 +302,44 @@ function re(e, t) {
|
|
|
302
302
|
throw new Error(`Modifier "${t}" not found`);
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
const x = Symbol.for("__licenseRequired");
|
|
306
|
+
function $(e) {
|
|
307
|
+
w(e) || Object.defineProperty(e, x, {
|
|
308
|
+
value: !0,
|
|
309
|
+
writable: !1,
|
|
310
|
+
configurable: !1,
|
|
311
|
+
enumerable: !0
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function w(e) {
|
|
315
|
+
return Object.prototype.hasOwnProperty.call(e, x);
|
|
316
|
+
}
|
|
317
|
+
function L(e, t) {
|
|
306
318
|
const r = [...e];
|
|
307
319
|
for (const n of t) {
|
|
308
|
-
const
|
|
320
|
+
const i = r.find(
|
|
309
321
|
(s) => s.name === n.name
|
|
310
322
|
);
|
|
311
|
-
|
|
323
|
+
i ? i.value = n.value : r.push(n);
|
|
312
324
|
}
|
|
313
325
|
return r;
|
|
314
326
|
}
|
|
315
|
-
function
|
|
327
|
+
function N(e, t) {
|
|
316
328
|
const r = [...e];
|
|
317
329
|
for (const n of t) {
|
|
318
|
-
const
|
|
330
|
+
const i = r.find(
|
|
319
331
|
(s) => s.name === n.name
|
|
320
332
|
);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
333
|
+
i ? Object.assign(
|
|
334
|
+
i,
|
|
335
|
+
M(i, n)
|
|
324
336
|
) : r.push(n);
|
|
325
337
|
}
|
|
326
338
|
return r;
|
|
327
339
|
}
|
|
328
|
-
function
|
|
340
|
+
function M(e, t) {
|
|
329
341
|
return Object.keys(e).reduce(
|
|
330
|
-
(r, n) => (n === "variables" ? r.variables =
|
|
342
|
+
(r, n) => (n === "variables" ? r.variables = L(e.variables, t.variables) : n === "declarations" ? r.declarations = { ...e.declarations, ...t.declarations } : n === "themes" && j(r) && j(e) && j(t) ? r.themes = N(e.themes, t.themes) : Array.isArray(e[n]) && (r[n] = e[n].concat(
|
|
331
343
|
t[n]
|
|
332
344
|
)), r),
|
|
333
345
|
{
|
|
@@ -336,53 +348,56 @@ function x(e, t) {
|
|
|
336
348
|
}
|
|
337
349
|
);
|
|
338
350
|
}
|
|
339
|
-
function
|
|
340
|
-
return t.reduce((r, n) =>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
351
|
+
function se(e, ...t) {
|
|
352
|
+
return t.reduce((r, n) => {
|
|
353
|
+
const i = {
|
|
354
|
+
...r,
|
|
355
|
+
root: M(r.root, n.root)
|
|
356
|
+
};
|
|
357
|
+
return (w(r) || w(n)) && $(i), i;
|
|
358
|
+
}, e);
|
|
344
359
|
}
|
|
345
|
-
function
|
|
360
|
+
function q(e) {
|
|
346
361
|
const t = [];
|
|
347
|
-
function r(n,
|
|
348
|
-
|
|
362
|
+
function r(n, i) {
|
|
363
|
+
i.length > 0 && t.push([...i].sort());
|
|
349
364
|
for (let s = n; s < e.length; s++) {
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
if (
|
|
353
|
-
r(s + 1, [...
|
|
365
|
+
const o = e[s];
|
|
366
|
+
if (o)
|
|
367
|
+
if (o.length === 1 && o[0])
|
|
368
|
+
r(s + 1, [...i, o[0]]);
|
|
354
369
|
else
|
|
355
|
-
for (const u of
|
|
356
|
-
r(s + 1, [...
|
|
370
|
+
for (const u of o)
|
|
371
|
+
r(s + 1, [...i, u]);
|
|
357
372
|
}
|
|
358
373
|
}
|
|
359
|
-
return r(0, []), t.sort((n,
|
|
374
|
+
return r(0, []), t.sort((n, i) => n.length !== i.length ? n.length - i.length : n.join(",").localeCompare(i.join(",")));
|
|
360
375
|
}
|
|
361
|
-
function
|
|
376
|
+
function z(e, t, r) {
|
|
362
377
|
const n = {
|
|
363
378
|
...e,
|
|
364
379
|
modifiers: [...r.keys()]
|
|
365
|
-
},
|
|
380
|
+
}, i = b(n, t);
|
|
366
381
|
for (const s of r.values())
|
|
367
382
|
s.factory({
|
|
368
|
-
...
|
|
369
|
-
declarations:
|
|
370
|
-
variables:
|
|
371
|
-
children:
|
|
372
|
-
}), g(n.declarations,
|
|
383
|
+
...i,
|
|
384
|
+
declarations: A(n.declarations),
|
|
385
|
+
variables: A(n.variables),
|
|
386
|
+
children: A(n.children)
|
|
387
|
+
}), g(n.declarations, i);
|
|
373
388
|
return n;
|
|
374
389
|
}
|
|
375
|
-
function
|
|
376
|
-
return function(n,
|
|
390
|
+
function I(e, t) {
|
|
391
|
+
return function(n, i) {
|
|
377
392
|
const s = {
|
|
378
393
|
type: "modifier",
|
|
379
394
|
key: Array.isArray(n) ? n : [n],
|
|
380
|
-
factory:
|
|
395
|
+
factory: i
|
|
381
396
|
};
|
|
382
397
|
return t.modifiers.push(s), s;
|
|
383
398
|
};
|
|
384
399
|
}
|
|
385
|
-
function
|
|
400
|
+
function W() {
|
|
386
401
|
return {
|
|
387
402
|
type: "root",
|
|
388
403
|
declarations: {},
|
|
@@ -394,28 +409,28 @@ function z() {
|
|
|
394
409
|
themes: []
|
|
395
410
|
};
|
|
396
411
|
}
|
|
397
|
-
function
|
|
412
|
+
function Y(e, t, r) {
|
|
398
413
|
const n = t.map((s) => s.key);
|
|
399
|
-
return
|
|
400
|
-
const
|
|
414
|
+
return q(n).map((s) => {
|
|
415
|
+
const o = /* @__PURE__ */ new Map();
|
|
401
416
|
for (const u of s) {
|
|
402
417
|
const c = t.find(
|
|
403
418
|
(f) => f.key.includes(u)
|
|
404
419
|
);
|
|
405
|
-
c &&
|
|
420
|
+
c && o.set(u, c);
|
|
406
421
|
}
|
|
407
|
-
return
|
|
422
|
+
return z(e, r, o);
|
|
408
423
|
});
|
|
409
424
|
}
|
|
410
|
-
function
|
|
411
|
-
return function(n,
|
|
425
|
+
function G(e, t) {
|
|
426
|
+
return function(n, i) {
|
|
412
427
|
const s = {
|
|
413
428
|
type: "utility",
|
|
414
429
|
name: n,
|
|
415
|
-
factory:
|
|
430
|
+
factory: i
|
|
416
431
|
};
|
|
417
|
-
return t.utilities.push(s), (
|
|
418
|
-
for (const [c, f] of Object.entries(
|
|
432
|
+
return t.utilities.push(s), (o, u = []) => {
|
|
433
|
+
for (const [c, f] of Object.entries(o)) {
|
|
419
434
|
const a = {
|
|
420
435
|
type: "utility",
|
|
421
436
|
name: n,
|
|
@@ -428,52 +443,52 @@ function W(e, t) {
|
|
|
428
443
|
a,
|
|
429
444
|
t
|
|
430
445
|
);
|
|
431
|
-
a.declarations =
|
|
446
|
+
a.declarations = i({
|
|
432
447
|
...l,
|
|
433
448
|
value: f
|
|
434
449
|
}) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
|
|
435
|
-
...
|
|
450
|
+
...Y(a, u, t)
|
|
436
451
|
);
|
|
437
452
|
}
|
|
438
453
|
};
|
|
439
454
|
};
|
|
440
455
|
}
|
|
441
|
-
function
|
|
442
|
-
return function(n,
|
|
443
|
-
const s = t.themes.find((c) => c.name === n),
|
|
456
|
+
function J(e, t) {
|
|
457
|
+
return function(n, i) {
|
|
458
|
+
const s = t.themes.find((c) => c.name === n), o = s ?? {
|
|
444
459
|
type: "theme",
|
|
445
460
|
name: n,
|
|
446
461
|
declarations: {},
|
|
447
462
|
variables: [],
|
|
448
463
|
children: []
|
|
449
464
|
};
|
|
450
|
-
s || t.themes.push(
|
|
451
|
-
const u = b(
|
|
452
|
-
return
|
|
465
|
+
s || t.themes.push(o);
|
|
466
|
+
const u = b(o, t);
|
|
467
|
+
return i && i(u), o;
|
|
453
468
|
};
|
|
454
469
|
}
|
|
455
|
-
function
|
|
456
|
-
return function(n,
|
|
470
|
+
function Q(e, t) {
|
|
471
|
+
return function(n, i, s, o) {
|
|
457
472
|
const u = {
|
|
458
473
|
type: "recipe",
|
|
459
474
|
name: n,
|
|
460
|
-
defaults:
|
|
475
|
+
defaults: i,
|
|
461
476
|
variants: s,
|
|
462
|
-
...
|
|
477
|
+
...o
|
|
463
478
|
};
|
|
464
479
|
return t.recipes.push(u), u;
|
|
465
480
|
};
|
|
466
481
|
}
|
|
467
|
-
function
|
|
468
|
-
const t =
|
|
482
|
+
function fe(e) {
|
|
483
|
+
const t = W(), r = { ...e }, n = G(t, t), i = I(t, t), s = Q(t, t), o = J(t, t), { variable: u, selector: c, atRule: f, keyframes: a, media: l, ref: y, css: h } = b(t, t);
|
|
469
484
|
return {
|
|
470
485
|
root: t,
|
|
471
486
|
variable: u,
|
|
472
487
|
selector: c,
|
|
473
488
|
utility: n,
|
|
474
|
-
modifier:
|
|
489
|
+
modifier: i,
|
|
475
490
|
recipe: s,
|
|
476
|
-
theme:
|
|
491
|
+
theme: o,
|
|
477
492
|
atRule: f,
|
|
478
493
|
keyframes: a,
|
|
479
494
|
media: l,
|
|
@@ -483,46 +498,46 @@ function oe(e) {
|
|
|
483
498
|
};
|
|
484
499
|
}
|
|
485
500
|
export {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
501
|
+
z as applyModifiers,
|
|
502
|
+
re as capitalizeFirst,
|
|
503
|
+
q as combineKeys,
|
|
504
|
+
v as createAtRuleFunction,
|
|
505
|
+
k as createCssFunction,
|
|
491
506
|
b as createDeclarationsCallbackContext,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
507
|
+
E as createKeyframesFunction,
|
|
508
|
+
S as createMediaFunction,
|
|
509
|
+
Y as createModifiedUtilityInstances,
|
|
510
|
+
I as createModifierFunction,
|
|
511
|
+
Q as createRecipeFunction,
|
|
512
|
+
P as createRefFunction,
|
|
513
|
+
W as createRoot,
|
|
514
|
+
D as createSelectorFunction,
|
|
515
|
+
J as createThemeFunction,
|
|
516
|
+
G as createUtilityFunction,
|
|
517
|
+
H as createVariableFunction,
|
|
518
|
+
A as deepClone,
|
|
519
|
+
ce as getModifier,
|
|
520
|
+
oe as getUtility,
|
|
521
|
+
ie as getVariable,
|
|
522
|
+
Z as isAtRule,
|
|
523
|
+
T as isCSS,
|
|
524
|
+
C as isContainer,
|
|
525
|
+
te as isModifier,
|
|
526
|
+
R as isObject,
|
|
527
|
+
_ as isPrimitiveTokenValue,
|
|
528
|
+
F as isRef,
|
|
529
|
+
j as isRoot,
|
|
530
|
+
X as isSelector,
|
|
531
|
+
ne as isTheme,
|
|
517
532
|
p as isToken,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
533
|
+
V as isTokenValue,
|
|
534
|
+
ee as isUtility,
|
|
535
|
+
B as isVariable,
|
|
536
|
+
se as merge,
|
|
537
|
+
M as mergeContainers,
|
|
538
|
+
N as mergeThemesArray,
|
|
539
|
+
L as mergeVariablesArray,
|
|
525
540
|
g as parseDeclarationsBlock,
|
|
526
|
-
|
|
527
|
-
|
|
541
|
+
K as rfdc,
|
|
542
|
+
fe as styleframe
|
|
528
543
|
};
|
package/dist/styleframe.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(a=typeof globalThis<"u"?globalThis:a||self,g(a.styleframe={}))})(this,(function(a){"use strict";function g(e,t){return function(n,...
|
|
1
|
+
(function(a,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(a=typeof globalThis<"u"?globalThis:a||self,g(a.styleframe={}))})(this,(function(a){"use strict";function g(e,t){return function(n,...i){return{type:"css",value:n.reduce((c,u,o)=>(c.push(u),o<i.length&&c.push(i[o]),c),[])}}}function V(e){return typeof e=="object"&&e!==null}function m(e,t){return V(e)&&"type"in e&&e.type===t}function v(e){return m(e,"variable")}function O(e){return m(e,"reference")}function X(e){return m(e,"selector")}function Z(e){return m(e,"at-rule")}function x(e){return m(e,"utility")}function ee(e){return m(e,"modifier")}function C(e){return m(e,"css")}function te(e){return m(e,"theme")}function w(e){return m(e,"root")}function S(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function M(e){return S(e)||O(e)||C(e)||Array.isArray(e)&&e.every(M)}function B(e){return V(e)&&"children"in e&&"declarations"in e&&"variables"in e}function F(e,t){return function(n,i,s){const c={type:"at-rule",identifier:n,rule:i,declarations:{},variables:[],children:[]},u=p(c,t);return typeof s=="function"?c.declarations=s(u)??{}:s&&(c.declarations=s),j(c.declarations,u),e.children.push(c),c}}function _(e,t){const r=F(e,t);return function(i,s){return r("media",i,s)}}function P(e,t){const r=F(e,t);return function(i,s){return r("keyframes",i,s)}}function U(e,t){return function(n,i){return v(n)?{type:"reference",name:n.name,fallback:i}:{type:"reference",name:n,fallback:i}}}function D(e,t){return function(n,i){const s={type:"selector",query:n,declarations:{},variables:[],children:[]},c=p(s,t);return typeof i=="function"?s.declarations=i(c)??{}:B(i)?(s.variables=i.variables,s.declarations=i.declarations,s.children=i.children):s.declarations=i,j(s.declarations,c),e.children.push(s),s}}function E(e,t){return function(n,i,s={default:!1}){const c=typeof n=="string"?n:n.name,u=e.variables.find(f=>f.name===c);if(s.default&&u)return u;if(u)return u.value=i,u;const o={type:"variable",name:c,value:i};return e.variables.push(o),o}}function p(e,t){const r=E(e),n=D(e,t),i=F(e,t),s=P(t,t),c=_(e,t),u=U(),o=g();return{variable:r,selector:n,keyframes:s,atRule:i,media:c,ref:u,css:o}}function j(e,t){for(const r in e)if(r.startsWith("@")){const n=e[r];if(typeof n=="object"&&n!==null&&!M(n)){const i=r.replace(/^@(\w+).*/,"$1"),s=r.replace(`@${i}`,"").trim();t.atRule(i,s,n),delete e[r]}}else if(/^[.&:]/.test(r)){const n=e[r];typeof n=="object"&&(t.selector(r,n),delete e[r])}return e}function ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function A(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function K(e){if(e=e||{},e.circular)return re(e);const t=new Map;if(t.set(Date,c=>new Date(c)),t.set(Map,(c,u)=>new Map(n(Array.from(c),u))),t.set(Set,(c,u)=>new Set(n(Array.from(c),u))),e.constructorHandlers)for(const c of e.constructorHandlers)t.set(c[0],c[1]);let r;return e.proto?s:i;function n(c,u){const o=Object.keys(c),f=Array.from({length:o.length});for(let y=0;y<o.length;y++){const l=o[y],d=c[l];typeof d!="object"||d===null?f[l]=d:d.constructor!==Object&&(r=t.get(d.constructor))?f[l]=r(d,u):ArrayBuffer.isView(d)?f[l]=A(d):f[l]=u(d)}return f}function i(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return n(c,i);if(c.constructor!==Object&&(r=t.get(c.constructor)))return r(c,i);const u={};for(const o in c){if(Object.hasOwnProperty.call(c,o)===!1)continue;const f=c[o];typeof f!="object"||f===null?u[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?u[o]=r(f,i):ArrayBuffer.isView(f)?u[o]=A(f):u[o]=i(f)}return u}function s(c){if(typeof c!="object"||c===null)return c;if(Array.isArray(c))return n(c,s);if(c.constructor!==Object&&(r=t.get(c.constructor)))return r(c,s);const u={};for(const o in c){const f=c[o];typeof f!="object"||f===null?u[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?u[o]=r(f,s):ArrayBuffer.isView(f)?u[o]=A(f):u[o]=s(f)}return u}}function re(e){const t=[],r=[],n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,f)=>new Map(s(Array.from(o),f))),n.set(Set,(o,f)=>new Set(s(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)n.set(o[0],o[1]);let i;return e.proto?u:c;function s(o,f){const y=Object.keys(o),l=Array.from({length:y.length});for(let d=0;d<y.length;d++){const b=y[d],h=o[b];if(typeof h!="object"||h===null)l[b]=h;else if(h.constructor!==Object&&(i=n.get(h.constructor)))l[b]=i(h,f);else if(ArrayBuffer.isView(h))l[b]=A(h);else{const Q=t.indexOf(h);Q!==-1?l[b]=r[Q]:l[b]=f(h)}}return l}function c(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,c);if(o.constructor!==Object&&(i=n.get(o.constructor)))return i(o,c);const f={};t.push(o),r.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=n.get(l.constructor)))f[y]=i(l,c);else if(ArrayBuffer.isView(l))f[y]=A(l);else{const d=t.indexOf(l);d!==-1?f[y]=r[d]:f[y]=c(l)}}return t.pop(),r.pop(),f}function u(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return s(o,u);if(o.constructor!==Object&&(i=n.get(o.constructor)))return i(o,u);const f={};t.push(o),r.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=n.get(l.constructor)))f[y]=i(l,u);else if(ArrayBuffer.isView(l))f[y]=A(l);else{const d=t.indexOf(l);d!==-1?f[y]=r[d]:f[y]=u(l)}}return t.pop(),r.pop(),f}}const R=K();function ie(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function ce(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function oe(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}const H=Symbol.for("__licenseRequired");function se(e){T(e)||Object.defineProperty(e,H,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function T(e){return Object.prototype.hasOwnProperty.call(e,H)}function $(e,t){const r=[...e];for(const n of t){const i=r.find(s=>s.name===n.name);i?i.value=n.value:r.push(n)}return r}function z(e,t){const r=[...e];for(const n of t){const i=r.find(s=>s.name===n.name);i?Object.assign(i,k(i,n)):r.push(n)}return r}function k(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=$(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&w(r)&&w(e)&&w(t)?r.themes=z(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function fe(e,...t){return t.reduce((r,n)=>{const i={...r,root:k(r.root,n.root)};return(T(r)||T(n))&&se(i),i},e)}function I(e){const t=[];function r(n,i){i.length>0&&t.push([...i].sort());for(let s=n;s<e.length;s++){const c=e[s];if(c)if(c.length===1&&c[0])r(s+1,[...i,c[0]]);else for(const u of c)r(s+1,[...i,u])}}return r(0,[]),t.sort((n,i)=>n.length!==i.length?n.length-i.length:n.join(",").localeCompare(i.join(",")))}function L(e,t,r){const n={...e,modifiers:[...r.keys()]},i=p(n,t);for(const s of r.values())s.factory({...i,declarations:R(n.declarations),variables:R(n.variables),children:R(n.children)}),j(n.declarations,i);return n}function N(e,t){return function(n,i){const s={type:"modifier",key:Array.isArray(n)?n:[n],factory:i};return t.modifiers.push(s),s}}function q(){return{type:"root",declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[]}}function W(e,t,r){const n=t.map(s=>s.key);return I(n).map(s=>{const c=new Map;for(const u of s){const o=t.find(f=>f.key.includes(u));o&&c.set(u,o)}return L(e,r,c)})}function Y(e,t){return function(n,i){const s={type:"utility",name:n,factory:i};return t.utilities.push(s),(c,u=[])=>{for(const[o,f]of Object.entries(c)){const y={type:"utility",name:n,value:o,declarations:{},variables:[],children:[],modifiers:[]},l=p(y,t);y.declarations=i({...l,value:f})??{},j(y.declarations,l),e.children.push(y),u.length>0&&e.children.push(...W(y,u,t))}}}}function G(e,t){return function(n,i){const s=t.themes.find(o=>o.name===n),c=s??{type:"theme",name:n,declarations:{},variables:[],children:[]};s||t.themes.push(c);const u=p(c,t);return i&&i(u),c}}function J(e,t){return function(n,i,s,c){const u={type:"recipe",name:n,defaults:i,variants:s,...c};return t.recipes.push(u),u}}function ue(e){const t=q(),r={...e},n=Y(t,t),i=N(t,t),s=J(t,t),c=G(t,t),{variable:u,selector:o,atRule:f,keyframes:y,media:l,ref:d,css:b}=p(t,t);return{root:t,variable:u,selector:o,utility:n,modifier:i,recipe:s,theme:c,atRule:f,keyframes:y,media:l,ref:d,css:b,options:r}}a.applyModifiers=L,a.capitalizeFirst=ne,a.combineKeys=I,a.createAtRuleFunction=F,a.createCssFunction=g,a.createDeclarationsCallbackContext=p,a.createKeyframesFunction=P,a.createMediaFunction=_,a.createModifiedUtilityInstances=W,a.createModifierFunction=N,a.createRecipeFunction=J,a.createRefFunction=U,a.createRoot=q,a.createSelectorFunction=D,a.createThemeFunction=G,a.createUtilityFunction=Y,a.createVariableFunction=E,a.deepClone=R,a.getModifier=oe,a.getUtility=ce,a.getVariable=ie,a.isAtRule=Z,a.isCSS=C,a.isContainer=B,a.isModifier=ee,a.isObject=V,a.isPrimitiveTokenValue=S,a.isRef=O,a.isRoot=w,a.isSelector=X,a.isTheme=te,a.isToken=m,a.isTokenValue=M,a.isUtility=x,a.isVariable=v,a.merge=fe,a.mergeContainers=k,a.mergeThemesArray=z,a.mergeVariablesArray=$,a.parseDeclarationsBlock=j,a.rfdc=K,a.styleframe=ue,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/styleframe.d.ts",
|
|
6
6
|
"module": "./dist/styleframe.js",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"csstype": "^3.1.3"
|
|
22
|
+
"csstype": "^3.1.3",
|
|
23
|
+
"@styleframe/license": "^1.0.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@vitest/coverage-v8": "^3.2.4",
|