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