@styleframe/loader 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.cjs +696 -494
- package/dist/index.d.ts +75 -0
- package/dist/index.js +695 -493
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -2,195 +2,195 @@ import { stat, rm, mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { validateInstanceLicense, getLicenseKeyFromEnv } from "@styleframe/license";
|
|
4
4
|
import { watch } from "chokidar";
|
|
5
|
-
import { createJiti } from "jiti";
|
|
6
5
|
import { existsSync } from "node:fs";
|
|
7
|
-
|
|
6
|
+
import { createJiti } from "jiti";
|
|
7
|
+
const P$1 = ["charset", "import", "namespace"], U = ["layer"], k = ({ name: e }) => `[data-theme="${e}"]`, M = ({
|
|
8
8
|
name: e,
|
|
9
9
|
value: t,
|
|
10
10
|
modifiers: r
|
|
11
|
-
}) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`,
|
|
12
|
-
function
|
|
11
|
+
}) => `._${[...r, e, ...t === "default" ? [] : [t]].filter(Boolean).join("\\:").replace(/[[\].#()%,]/g, "\\$&")}`, O = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
|
|
12
|
+
function V$1(e, t) {
|
|
13
13
|
return `@${e}${t ? " " : ""}${t}`;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
if (!
|
|
15
|
+
const K$1 = /\d/, q = ["-", "_", "/", "."];
|
|
16
|
+
function z$1(e = "") {
|
|
17
|
+
if (!K$1.test(e))
|
|
18
18
|
return e !== e.toLowerCase();
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const r =
|
|
20
|
+
function _$1(e, t) {
|
|
21
|
+
const r = q, o = [];
|
|
22
22
|
if (!e || typeof e != "string")
|
|
23
|
-
return
|
|
24
|
-
let
|
|
23
|
+
return o;
|
|
24
|
+
let n = "", s, u;
|
|
25
25
|
for (const a of e) {
|
|
26
26
|
const c = r.includes(a);
|
|
27
27
|
if (c === true) {
|
|
28
|
-
|
|
28
|
+
o.push(n), n = "", s = void 0;
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
const i =
|
|
31
|
+
const i = z$1(a);
|
|
32
32
|
if (u === false) {
|
|
33
33
|
if (s === false && i === true) {
|
|
34
|
-
|
|
34
|
+
o.push(n), n = a, s = i;
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
if (s === true && i === false &&
|
|
38
|
-
const f =
|
|
39
|
-
|
|
37
|
+
if (s === true && i === false && n.length > 1) {
|
|
38
|
+
const f = n.at(-1);
|
|
39
|
+
o.push(n.slice(0, Math.max(0, n.length - 1))), n = f + a, s = i;
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
n += a, s = i, u = c;
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return o.push(n), o;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function H(e) {
|
|
48
48
|
return e ? e[0].toUpperCase() + e.slice(1) : "";
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Q$1(e) {
|
|
51
51
|
return e ? e[0].toLowerCase() + e.slice(1) : "";
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return e ? (Array.isArray(e) ? e :
|
|
53
|
+
function J$1(e, t) {
|
|
54
|
+
return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => H(r)).join("") : "";
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function Z$1(e, t) {
|
|
57
|
+
return Q$1(J$1(e || ""));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return e ? (Array.isArray(e) ? e :
|
|
59
|
+
function W(e, t) {
|
|
60
|
+
return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => r.toLowerCase()).join("-") : "";
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function G$1(e) {
|
|
63
63
|
return ` ${e}`;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function Y$1(e) {
|
|
66
66
|
return e.split(`
|
|
67
|
-
`).map((t) =>
|
|
67
|
+
`).map((t) => G$1(t)).join(`
|
|
68
68
|
`);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function x$1(e) {
|
|
71
71
|
return e === e.toUpperCase();
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
73
|
+
function T$1(e) {
|
|
74
|
+
return Z$1(e);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
76
|
+
function X$1(e) {
|
|
77
|
+
return W(e);
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function ee$1(e) {
|
|
80
|
+
return X$1(e);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return `${e.startsWith("--") ? e :
|
|
82
|
+
function B(e, t) {
|
|
83
|
+
return `${e.startsWith("--") ? e : ee$1(e)}: ${t};`;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function te$1(e) {
|
|
86
86
|
return `{${e.length > 0 ? `
|
|
87
|
-
` : ""}${e.map((t) => `${
|
|
87
|
+
` : ""}${e.map((t) => `${Y$1(`${t}`)}
|
|
88
88
|
`).join("")}}`;
|
|
89
89
|
}
|
|
90
90
|
function E$1(e) {
|
|
91
91
|
return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
93
|
+
function re$1(e, t) {
|
|
94
|
+
return B(E$1(e), t);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function ne$1(e, t) {
|
|
97
97
|
return `var(${E$1(e)}${t ? `, ${t}` : ""})`;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return `${e} ${
|
|
99
|
+
function w(e, t) {
|
|
100
|
+
return `${e} ${te$1(t)}`;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return function(r,
|
|
104
|
-
return Object.entries(r).map(([
|
|
102
|
+
function oe(e) {
|
|
103
|
+
return function(r, o) {
|
|
104
|
+
return Object.entries(r).map(([n, s]) => B(n, e(s, o)));
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return function(r,
|
|
109
|
-
const s = (
|
|
110
|
-
return
|
|
107
|
+
function F$1(e) {
|
|
108
|
+
return function(r, o) {
|
|
109
|
+
const s = (o.variables?.name ?? O)({ name: r.name });
|
|
110
|
+
return re$1(s, e(r.value, o));
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
function S$1(e) {
|
|
114
|
-
const t =
|
|
115
|
-
return function(
|
|
116
|
-
const { variables: a, declarations: c, children: i } = s, f =
|
|
117
|
-
(
|
|
114
|
+
const t = F$1(e), r = oe(e);
|
|
115
|
+
return function(n, s, u) {
|
|
116
|
+
const { variables: a, declarations: c, children: i } = s, f = n === ":root", l = (a ?? []).map(
|
|
117
|
+
(g) => t(g, u)
|
|
118
118
|
), m = r(
|
|
119
119
|
c ?? {},
|
|
120
120
|
u
|
|
121
121
|
), y = (i ?? []).map(
|
|
122
|
-
(
|
|
123
|
-
),
|
|
124
|
-
return f ? `${
|
|
122
|
+
(g) => e(g, u)
|
|
123
|
+
), p = l.length > 0, b = m.length > 0, j2 = y.length > 0;
|
|
124
|
+
return f ? `${p || b ? w(n, [
|
|
125
125
|
...l,
|
|
126
|
-
...
|
|
126
|
+
...p && b ? [""] : [],
|
|
127
127
|
...m
|
|
128
|
-
]) : ""}${
|
|
128
|
+
]) : ""}${j2 && (p || b) ? `
|
|
129
129
|
|
|
130
130
|
` : ""}${y.join(`
|
|
131
131
|
|
|
132
|
-
`)}` :
|
|
132
|
+
`)}` : w(n, [
|
|
133
133
|
...l,
|
|
134
|
-
...
|
|
134
|
+
...p && (j2 || b) ? [""] : [],
|
|
135
135
|
...m,
|
|
136
|
-
...b &&
|
|
136
|
+
...b && j2 ? [""] : [],
|
|
137
137
|
...y.flatMap(
|
|
138
|
-
(
|
|
138
|
+
(g, I2) => I2 === y.length - 1 ? [g] : [g, ""]
|
|
139
139
|
)
|
|
140
140
|
]);
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function ce(e) {
|
|
144
144
|
const t = S$1(e);
|
|
145
|
-
return function(
|
|
146
|
-
const s =
|
|
147
|
-
|
|
148
|
-
), a = Object.keys(
|
|
149
|
-
return s || u && !(a || c || i) ? `${f};` : t(f,
|
|
145
|
+
return function(o, n) {
|
|
146
|
+
const s = P$1.includes(o.identifier), u = U.includes(
|
|
147
|
+
o.identifier
|
|
148
|
+
), a = Object.keys(o.declarations).length > 0, c = o.variables.length > 0, i = o.children.length > 0, f = V$1(o.identifier, o.rule);
|
|
149
|
+
return s || u && !(a || c || i) ? `${f};` : t(f, o, n);
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return function(r,
|
|
154
|
-
return r.value.map((
|
|
152
|
+
function ue$1(e) {
|
|
153
|
+
return function(r, o) {
|
|
154
|
+
return r.value.map((n) => e(n, o)).join("").trim();
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function se$1(e) {
|
|
158
158
|
return typeof e == "object" && e !== null;
|
|
159
159
|
}
|
|
160
|
-
function h(e, t) {
|
|
161
|
-
return
|
|
160
|
+
function h$1(e, t) {
|
|
161
|
+
return se$1(e) && "type" in e && e.type === t;
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
return h(e, "variable");
|
|
163
|
+
function ie$1(e) {
|
|
164
|
+
return h$1(e, "variable");
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
return h(e, "reference");
|
|
166
|
+
function ae$1(e) {
|
|
167
|
+
return h$1(e, "reference");
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
return h(e, "selector");
|
|
169
|
+
function C$1(e) {
|
|
170
|
+
return h$1(e, "selector");
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return h(e, "at-rule");
|
|
172
|
+
function le$1(e) {
|
|
173
|
+
return h$1(e, "at-rule");
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
return h(e, "utility");
|
|
175
|
+
function fe(e) {
|
|
176
|
+
return h$1(e, "utility");
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return h(e, "css");
|
|
178
|
+
function me$1(e) {
|
|
179
|
+
return h$1(e, "css");
|
|
180
180
|
}
|
|
181
|
-
function
|
|
182
|
-
return h(e, "theme");
|
|
181
|
+
function pe$1(e) {
|
|
182
|
+
return h$1(e, "theme");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
return h(e, "root");
|
|
184
|
+
function N(e) {
|
|
185
|
+
return h$1(e, "root");
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
return h(e, "recipe");
|
|
187
|
+
function D$1(e) {
|
|
188
|
+
return h$1(e, "recipe");
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function L$1(e) {
|
|
191
191
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function A$1(e) {
|
|
194
194
|
if (e instanceof Buffer)
|
|
195
195
|
return Buffer.from(e);
|
|
196
196
|
const t = e.constructor;
|
|
@@ -200,81 +200,81 @@ function g(e) {
|
|
|
200
200
|
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function ye$1(e) {
|
|
204
204
|
if (e = e || {}, e.circular)
|
|
205
|
-
return
|
|
205
|
+
return de$1(e);
|
|
206
206
|
const t = /* @__PURE__ */ new Map();
|
|
207
207
|
if (t.set(Date, (u) => new Date(u)), t.set(
|
|
208
208
|
Map,
|
|
209
|
-
(u, a) => new Map(
|
|
209
|
+
(u, a) => new Map(o(Array.from(u), a))
|
|
210
210
|
), t.set(
|
|
211
211
|
Set,
|
|
212
|
-
(u, a) => new Set(
|
|
212
|
+
(u, a) => new Set(o(Array.from(u), a))
|
|
213
213
|
), e.constructorHandlers)
|
|
214
214
|
for (const u of e.constructorHandlers)
|
|
215
215
|
t.set(u[0], u[1]);
|
|
216
216
|
let r;
|
|
217
|
-
return e.proto ? s :
|
|
218
|
-
function
|
|
217
|
+
return e.proto ? s : n;
|
|
218
|
+
function o(u, a) {
|
|
219
219
|
const c = Object.keys(u), i = Array.from({ length: c.length });
|
|
220
220
|
for (let f = 0; f < c.length; f++) {
|
|
221
221
|
const l = c[f], m = u[l];
|
|
222
|
-
typeof m != "object" || m === null ? i[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? i[l] = r(m, a) : ArrayBuffer.isView(m) ? i[l] =
|
|
222
|
+
typeof m != "object" || m === null ? i[l] = m : m.constructor !== Object && (r = t.get(m.constructor)) ? i[l] = r(m, a) : ArrayBuffer.isView(m) ? i[l] = A$1(m) : i[l] = a(m);
|
|
223
223
|
}
|
|
224
224
|
return i;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function n(u) {
|
|
227
227
|
if (typeof u != "object" || u === null) return u;
|
|
228
|
-
if (Array.isArray(u)) return
|
|
228
|
+
if (Array.isArray(u)) return o(u, n);
|
|
229
229
|
if (u.constructor !== Object && (r = t.get(u.constructor)))
|
|
230
|
-
return r(u,
|
|
230
|
+
return r(u, n);
|
|
231
231
|
const a = {};
|
|
232
232
|
for (const c in u) {
|
|
233
233
|
if (Object.hasOwnProperty.call(u, c) === false) continue;
|
|
234
234
|
const i = u[c];
|
|
235
|
-
typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i,
|
|
235
|
+
typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, n) : ArrayBuffer.isView(i) ? a[c] = A$1(i) : a[c] = n(i);
|
|
236
236
|
}
|
|
237
237
|
return a;
|
|
238
238
|
}
|
|
239
239
|
function s(u) {
|
|
240
240
|
if (typeof u != "object" || u === null) return u;
|
|
241
|
-
if (Array.isArray(u)) return
|
|
241
|
+
if (Array.isArray(u)) return o(u, s);
|
|
242
242
|
if (u.constructor !== Object && (r = t.get(u.constructor)))
|
|
243
243
|
return r(u, s);
|
|
244
244
|
const a = {};
|
|
245
245
|
for (const c in u) {
|
|
246
246
|
const i = u[c];
|
|
247
|
-
typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, s) : ArrayBuffer.isView(i) ? a[c] =
|
|
247
|
+
typeof i != "object" || i === null ? a[c] = i : i.constructor !== Object && (r = t.get(i.constructor)) ? a[c] = r(i, s) : ArrayBuffer.isView(i) ? a[c] = A$1(i) : a[c] = s(i);
|
|
248
248
|
}
|
|
249
249
|
return a;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
const t = [], r = [],
|
|
254
|
-
if (
|
|
252
|
+
function de$1(e) {
|
|
253
|
+
const t = [], r = [], o = /* @__PURE__ */ new Map();
|
|
254
|
+
if (o.set(Date, (c) => new Date(c)), o.set(
|
|
255
255
|
Map,
|
|
256
256
|
(c, i) => new Map(s(Array.from(c), i))
|
|
257
|
-
),
|
|
257
|
+
), o.set(
|
|
258
258
|
Set,
|
|
259
259
|
(c, i) => new Set(s(Array.from(c), i))
|
|
260
260
|
), e.constructorHandlers)
|
|
261
261
|
for (const c of e.constructorHandlers)
|
|
262
|
-
|
|
263
|
-
let
|
|
262
|
+
o.set(c[0], c[1]);
|
|
263
|
+
let n;
|
|
264
264
|
return e.proto ? a : u;
|
|
265
265
|
function s(c, i) {
|
|
266
266
|
const f = Object.keys(c), l = Array.from({ length: f.length });
|
|
267
267
|
for (let m = 0; m < f.length; m++) {
|
|
268
|
-
const y = f[m],
|
|
269
|
-
if (typeof
|
|
270
|
-
l[y] =
|
|
271
|
-
else if (
|
|
272
|
-
l[y] =
|
|
273
|
-
else if (ArrayBuffer.isView(
|
|
274
|
-
l[y] =
|
|
268
|
+
const y = f[m], p = c[y];
|
|
269
|
+
if (typeof p != "object" || p === null)
|
|
270
|
+
l[y] = p;
|
|
271
|
+
else if (p.constructor !== Object && (n = o.get(p.constructor)))
|
|
272
|
+
l[y] = n(p, i);
|
|
273
|
+
else if (ArrayBuffer.isView(p))
|
|
274
|
+
l[y] = A$1(p);
|
|
275
275
|
else {
|
|
276
|
-
const b = t.indexOf(
|
|
277
|
-
b !== -1 ? l[y] = r[b] : l[y] = i(
|
|
276
|
+
const b = t.indexOf(p);
|
|
277
|
+
b !== -1 ? l[y] = r[b] : l[y] = i(p);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
return l;
|
|
@@ -282,8 +282,8 @@ function ye$1(e) {
|
|
|
282
282
|
function u(c) {
|
|
283
283
|
if (typeof c != "object" || c === null) return c;
|
|
284
284
|
if (Array.isArray(c)) return s(c, u);
|
|
285
|
-
if (c.constructor !== Object && (
|
|
286
|
-
return
|
|
285
|
+
if (c.constructor !== Object && (n = o.get(c.constructor)))
|
|
286
|
+
return n(c, u);
|
|
287
287
|
const i = {};
|
|
288
288
|
t.push(c), r.push(i);
|
|
289
289
|
for (const f in c) {
|
|
@@ -291,10 +291,10 @@ function ye$1(e) {
|
|
|
291
291
|
const l = c[f];
|
|
292
292
|
if (typeof l != "object" || l === null)
|
|
293
293
|
i[f] = l;
|
|
294
|
-
else if (l.constructor !== Object && (
|
|
295
|
-
i[f] =
|
|
294
|
+
else if (l.constructor !== Object && (n = o.get(l.constructor)))
|
|
295
|
+
i[f] = n(l, u);
|
|
296
296
|
else if (ArrayBuffer.isView(l))
|
|
297
|
-
i[f] =
|
|
297
|
+
i[f] = A$1(l);
|
|
298
298
|
else {
|
|
299
299
|
const m = t.indexOf(l);
|
|
300
300
|
m !== -1 ? i[f] = r[m] : i[f] = u(l);
|
|
@@ -305,18 +305,18 @@ function ye$1(e) {
|
|
|
305
305
|
function a(c) {
|
|
306
306
|
if (typeof c != "object" || c === null) return c;
|
|
307
307
|
if (Array.isArray(c)) return s(c, a);
|
|
308
|
-
if (c.constructor !== Object && (
|
|
309
|
-
return
|
|
308
|
+
if (c.constructor !== Object && (n = o.get(c.constructor)))
|
|
309
|
+
return n(c, a);
|
|
310
310
|
const i = {};
|
|
311
311
|
t.push(c), r.push(i);
|
|
312
312
|
for (const f in c) {
|
|
313
313
|
const l = c[f];
|
|
314
314
|
if (typeof l != "object" || l === null)
|
|
315
315
|
i[f] = l;
|
|
316
|
-
else if (l.constructor !== Object && (
|
|
317
|
-
i[f] =
|
|
316
|
+
else if (l.constructor !== Object && (n = o.get(l.constructor)))
|
|
317
|
+
i[f] = n(l, a);
|
|
318
318
|
else if (ArrayBuffer.isView(l))
|
|
319
|
-
i[f] =
|
|
319
|
+
i[f] = A$1(l);
|
|
320
320
|
else {
|
|
321
321
|
const m = t.indexOf(l);
|
|
322
322
|
m !== -1 ? i[f] = r[m] : i[f] = a(l);
|
|
@@ -325,27 +325,27 @@ function ye$1(e) {
|
|
|
325
325
|
return t.pop(), r.pop(), i;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
|
|
329
|
-
function
|
|
330
|
-
return function(r,
|
|
328
|
+
ye$1();
|
|
329
|
+
function he$1(e) {
|
|
330
|
+
return function(r, o) {
|
|
331
331
|
return r != null ? `${r}` : "";
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
return function(r,
|
|
336
|
-
const s = (
|
|
337
|
-
return
|
|
334
|
+
function be$1(e) {
|
|
335
|
+
return function(r, o) {
|
|
336
|
+
const s = (o.variables?.name ?? O)({ name: r.name });
|
|
337
|
+
return ne$1(
|
|
338
338
|
s,
|
|
339
|
-
r.fallback ? e(r.fallback,
|
|
339
|
+
r.fallback ? e(r.fallback, o) : void 0
|
|
340
340
|
);
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function ge$1(e) {
|
|
344
344
|
const t = S$1(e);
|
|
345
|
-
return function(
|
|
346
|
-
return
|
|
347
|
-
(s, u) => (s.push(e(u,
|
|
348
|
-
[t(":root",
|
|
345
|
+
return function(o, n) {
|
|
346
|
+
return o.themes.reduce(
|
|
347
|
+
(s, u) => (s.push(e(u, n)), s),
|
|
348
|
+
[t(":root", o, n)]
|
|
349
349
|
// Default theme (root)
|
|
350
350
|
).join(`
|
|
351
351
|
|
|
@@ -354,108 +354,108 @@ function be$1(e) {
|
|
|
354
354
|
}
|
|
355
355
|
function Ae$1(e) {
|
|
356
356
|
const t = S$1(e);
|
|
357
|
-
return function(
|
|
358
|
-
return t(
|
|
357
|
+
return function(o, n) {
|
|
358
|
+
return t(o.query, o, n);
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function Se(e) {
|
|
362
362
|
const t = S$1(e);
|
|
363
|
-
return function(
|
|
364
|
-
const u = (
|
|
365
|
-
return t(u,
|
|
363
|
+
return function(o, n) {
|
|
364
|
+
const u = (n.themes?.selector ?? k)({ name: o.name });
|
|
365
|
+
return t(u, o, n);
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
|
-
function
|
|
368
|
+
function Ce(e) {
|
|
369
369
|
const t = S$1(e);
|
|
370
|
-
return function(
|
|
371
|
-
const s = [], a = (
|
|
372
|
-
name:
|
|
373
|
-
value:
|
|
374
|
-
modifiers:
|
|
370
|
+
return function(o, n) {
|
|
371
|
+
const s = [], a = (n.utilities?.selector ?? M)({
|
|
372
|
+
name: o.name,
|
|
373
|
+
value: o.value,
|
|
374
|
+
modifiers: o.modifiers
|
|
375
375
|
});
|
|
376
|
-
return s.push(t(a,
|
|
376
|
+
return s.push(t(a, o, n)), s.join(`
|
|
377
377
|
|
|
378
378
|
`);
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
381
|
function d(e, t) {
|
|
382
|
-
const r =
|
|
382
|
+
const r = ge$1(d), o = Ae$1(d), n = Ce(d), s = ce(d), u = Se(d), a = F$1(d), c = be$1(d), i = ue$1(d), f = he$1();
|
|
383
383
|
switch (true) {
|
|
384
|
-
case
|
|
385
|
-
return n(e, t);
|
|
386
|
-
case se(e):
|
|
384
|
+
case C$1(e):
|
|
387
385
|
return o(e, t);
|
|
388
|
-
case
|
|
386
|
+
case fe(e):
|
|
387
|
+
return n(e, t);
|
|
388
|
+
case le$1(e):
|
|
389
389
|
return s(e, t);
|
|
390
|
-
case
|
|
390
|
+
case N(e):
|
|
391
391
|
return r(e, t);
|
|
392
|
-
case
|
|
392
|
+
case pe$1(e):
|
|
393
393
|
return u(e, t);
|
|
394
|
-
case
|
|
394
|
+
case ie$1(e):
|
|
395
395
|
return a(e, t);
|
|
396
|
-
case ue$1(e):
|
|
397
|
-
return c(e, t);
|
|
398
396
|
case ae$1(e):
|
|
397
|
+
return c(e, t);
|
|
398
|
+
case me$1(e):
|
|
399
399
|
return i(e, t);
|
|
400
400
|
default:
|
|
401
401
|
return f(e, t);
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
return function(r,
|
|
406
|
-
let
|
|
407
|
-
|
|
408
|
-
const s = `${
|
|
404
|
+
function je(e) {
|
|
405
|
+
return function(r, o) {
|
|
406
|
+
let n = r._exportName;
|
|
407
|
+
n || (n = T$1(r.name), r.name[0] && x$1(r.name[0]) && (n = L$1(n)));
|
|
408
|
+
const s = `${n}Recipe`, u = r._runtime ?? {};
|
|
409
409
|
return `const ${s} = ${JSON.stringify(
|
|
410
410
|
u,
|
|
411
411
|
null,
|
|
412
412
|
4
|
|
413
413
|
)} as const satisfies RecipeRuntime;
|
|
414
414
|
|
|
415
|
-
export const ${
|
|
415
|
+
export const ${n} = createRecipe("${r.name}", ${s});
|
|
416
416
|
`;
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function ve(e) {
|
|
420
420
|
return e.filter(
|
|
421
|
-
(t) =>
|
|
421
|
+
(t) => C$1(t) && !!t._exportName
|
|
422
422
|
);
|
|
423
423
|
}
|
|
424
|
-
function
|
|
425
|
-
return function(r,
|
|
426
|
-
const
|
|
424
|
+
function Re(e) {
|
|
425
|
+
return function(r, o) {
|
|
426
|
+
const n = ve(r.children), s = r.recipes.length > 0, u = n.length > 0;
|
|
427
427
|
if (!s && !u)
|
|
428
428
|
return "";
|
|
429
429
|
const a = [];
|
|
430
430
|
return s && (a.push(`import { createRecipe } from '@styleframe/runtime';
|
|
431
431
|
import type { RecipeRuntime } from '@styleframe/runtime';
|
|
432
|
-
`), a.push(e(r.recipes,
|
|
432
|
+
`), a.push(e(r.recipes, o))), u && a.push(e(n, o)), a.join(`
|
|
433
433
|
`);
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
|
-
function
|
|
437
|
-
return function(r,
|
|
436
|
+
function $e(e) {
|
|
437
|
+
return function(r, o) {
|
|
438
438
|
return r._exportName ? `export const ${r._exportName} = ${JSON.stringify(r.query)};
|
|
439
439
|
` : "";
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function
|
|
443
|
-
const r =
|
|
442
|
+
function R$1(e, t) {
|
|
443
|
+
const r = Re(R$1), o = je(), n = $e();
|
|
444
444
|
switch (true) {
|
|
445
445
|
case Array.isArray(e):
|
|
446
|
-
return e.map((s) =>
|
|
446
|
+
return e.map((s) => R$1(s, t)).join(`
|
|
447
447
|
`);
|
|
448
|
-
case
|
|
448
|
+
case N(e):
|
|
449
449
|
return r(e, t);
|
|
450
|
-
case
|
|
451
|
-
return n(e, t);
|
|
452
|
-
case v$1(e):
|
|
450
|
+
case D$1(e):
|
|
453
451
|
return o(e, t);
|
|
452
|
+
case C$1(e):
|
|
453
|
+
return n(e, t);
|
|
454
454
|
default:
|
|
455
455
|
return "";
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
const
|
|
458
|
+
const Ne = `-----BEGIN PUBLIC KEY-----
|
|
459
459
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
|
|
460
460
|
qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
|
|
461
461
|
BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
|
|
@@ -463,9 +463,9 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
|
463
463
|
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
464
464
|
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
465
465
|
GwIDAQAB
|
|
466
|
-
-----END PUBLIC KEY-----`, we = "__licenseRequired",
|
|
467
|
-
async function
|
|
468
|
-
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (
|
|
466
|
+
-----END PUBLIC KEY-----`, we = "__licenseRequired", Oe = "__licenseValidated";
|
|
467
|
+
async function _e(e) {
|
|
468
|
+
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (o) => o.charCodeAt(0));
|
|
469
469
|
return await crypto.subtle.importKey(
|
|
470
470
|
"spki",
|
|
471
471
|
r,
|
|
@@ -477,18 +477,18 @@ async function Oe(e) {
|
|
|
477
477
|
["verify"]
|
|
478
478
|
);
|
|
479
479
|
}
|
|
480
|
-
async function
|
|
480
|
+
async function xe({
|
|
481
481
|
payload: e,
|
|
482
482
|
signature: t
|
|
483
483
|
}) {
|
|
484
|
-
const r = new TextEncoder().encode(e),
|
|
484
|
+
const r = new TextEncoder().encode(e), o = Uint8Array.from(
|
|
485
485
|
atob(t),
|
|
486
486
|
(s) => s.charCodeAt(0)
|
|
487
|
-
),
|
|
487
|
+
), n = await _e(Ne);
|
|
488
488
|
if (!await crypto.subtle.verify(
|
|
489
489
|
{ name: "RSASSA-PKCS1-v1_5" },
|
|
490
|
-
o,
|
|
491
490
|
n,
|
|
491
|
+
o,
|
|
492
492
|
r
|
|
493
493
|
))
|
|
494
494
|
throw new Error(
|
|
@@ -496,13 +496,13 @@ async function Ee({
|
|
|
496
496
|
);
|
|
497
497
|
return JSON.parse(e);
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function Te(e) {
|
|
500
500
|
return Object.prototype.hasOwnProperty.call(e, we);
|
|
501
501
|
}
|
|
502
|
-
async function
|
|
502
|
+
async function Be(e) {
|
|
503
503
|
const t = Object.getOwnPropertyDescriptor(
|
|
504
504
|
e,
|
|
505
|
-
|
|
505
|
+
Oe
|
|
506
506
|
);
|
|
507
507
|
if (!t?.value)
|
|
508
508
|
return {
|
|
@@ -520,7 +520,7 @@ async function Te(e) {
|
|
|
520
520
|
valid: false
|
|
521
521
|
};
|
|
522
522
|
try {
|
|
523
|
-
return await
|
|
523
|
+
return await xe(
|
|
524
524
|
r
|
|
525
525
|
);
|
|
526
526
|
} catch {
|
|
@@ -532,7 +532,81 @@ async function Te(e) {
|
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Ee(e) {
|
|
536
|
+
const t = e?.variants;
|
|
537
|
+
if (!t || Object.keys(t).length === 0)
|
|
538
|
+
return "Record<string, never>";
|
|
539
|
+
const r = [];
|
|
540
|
+
for (const [o, n] of Object.entries(t)) {
|
|
541
|
+
if (!n) continue;
|
|
542
|
+
const s = Object.keys(n);
|
|
543
|
+
if (s.length > 0) {
|
|
544
|
+
const u = s.map((a) => `"${a}"`).join(" | ");
|
|
545
|
+
r.push(`${o}?: ${u}`);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return r.length === 0 ? "Record<string, never>" : `{ ${r.join("; ")} }`;
|
|
549
|
+
}
|
|
550
|
+
function Fe$1(e) {
|
|
551
|
+
return function(r, o) {
|
|
552
|
+
let n = r._exportName;
|
|
553
|
+
n || (n = T$1(r.name), r.name[0] && x$1(r.name[0]) && (n = L$1(n)));
|
|
554
|
+
const s = Ee(r._runtime);
|
|
555
|
+
return ` export const ${n}: (props?: ${s}) => string;`;
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
function De(e) {
|
|
559
|
+
return e.filter(
|
|
560
|
+
(t) => C$1(t) && !!t._exportName
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
function Le(e) {
|
|
564
|
+
return function(r, o) {
|
|
565
|
+
const n = De(r.children), s = r.recipes.length > 0, u = n.length > 0, a = [
|
|
566
|
+
"// Auto-generated by @styleframe/plugin - DO NOT EDIT",
|
|
567
|
+
"",
|
|
568
|
+
'declare module "virtual:styleframe" {',
|
|
569
|
+
' import type { Styleframe } from "@styleframe/core";',
|
|
570
|
+
"",
|
|
571
|
+
" /** Returns the global styleframe instance from styleframe.config.ts */",
|
|
572
|
+
" export function styleframe(): Styleframe;"
|
|
573
|
+
];
|
|
574
|
+
if (s) {
|
|
575
|
+
a.push("");
|
|
576
|
+
const c = r.recipes.map((i) => e(i, o)).filter(Boolean);
|
|
577
|
+
a.push(...c);
|
|
578
|
+
}
|
|
579
|
+
if (u) {
|
|
580
|
+
a.push("");
|
|
581
|
+
const c = n.map((i) => e(i, o)).filter(Boolean);
|
|
582
|
+
a.push(...c);
|
|
583
|
+
}
|
|
584
|
+
return a.push("}"), a.push(""), a.push('declare module "virtual:styleframe.css" {'), a.push(" const css: string;"), a.push(" export default css;"), a.push("}"), a.push(""), a.join(`
|
|
585
|
+
`);
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function Ie(e) {
|
|
589
|
+
return function(r, o) {
|
|
590
|
+
return r._exportName ? ` export const ${r._exportName}: string;` : "";
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function $(e, t) {
|
|
594
|
+
const r = Le($), o = Fe$1(), n = Ie();
|
|
595
|
+
switch (true) {
|
|
596
|
+
case Array.isArray(e):
|
|
597
|
+
return e.map((s) => $(s, t)).join(`
|
|
598
|
+
`);
|
|
599
|
+
case N(e):
|
|
600
|
+
return r(e, t);
|
|
601
|
+
case D$1(e):
|
|
602
|
+
return o(e, t);
|
|
603
|
+
case C$1(e):
|
|
604
|
+
return n(e, t);
|
|
605
|
+
default:
|
|
606
|
+
return "";
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function Pe(e) {
|
|
536
610
|
const t = Math.floor(Math.random() * 100);
|
|
537
611
|
e.root.children.push({
|
|
538
612
|
type: "selector",
|
|
@@ -556,36 +630,43 @@ function _e(e) {
|
|
|
556
630
|
}
|
|
557
631
|
});
|
|
558
632
|
}
|
|
559
|
-
function
|
|
633
|
+
function v$1(e, t = "") {
|
|
560
634
|
return {
|
|
561
635
|
name: e,
|
|
562
636
|
content: t
|
|
563
637
|
};
|
|
564
638
|
}
|
|
565
|
-
async function
|
|
639
|
+
async function ke$1(e, {
|
|
566
640
|
type: t = "all",
|
|
567
|
-
consumers: r = { css: d, ts:
|
|
641
|
+
consumers: r = { css: d, ts: R$1, dts: $ }
|
|
568
642
|
} = {}) {
|
|
569
|
-
const
|
|
570
|
-
if (
|
|
571
|
-
const s = await
|
|
572
|
-
(!s.valid || s.instanceId !== e.id) &&
|
|
643
|
+
const o = { files: [] }, n = e.options;
|
|
644
|
+
if (Te(e)) {
|
|
645
|
+
const s = await Be(e);
|
|
646
|
+
(!s.valid || s.instanceId !== e.id) && Pe(e);
|
|
573
647
|
}
|
|
574
648
|
if (t === "all" || t === "css") {
|
|
575
|
-
const s =
|
|
649
|
+
const s = v$1(
|
|
576
650
|
"index.css",
|
|
577
|
-
r.css(e.root,
|
|
651
|
+
r.css(e.root, n)
|
|
578
652
|
);
|
|
579
|
-
|
|
653
|
+
o.files.push(s);
|
|
580
654
|
}
|
|
581
655
|
if (t === "all" || t === "ts") {
|
|
582
|
-
const s =
|
|
656
|
+
const s = v$1(
|
|
583
657
|
"index.ts",
|
|
584
|
-
r.ts(e.root,
|
|
658
|
+
r.ts(e.root, n)
|
|
585
659
|
);
|
|
586
|
-
|
|
660
|
+
o.files.push(s);
|
|
587
661
|
}
|
|
588
|
-
|
|
662
|
+
if (t === "dts") {
|
|
663
|
+
const s = v$1(
|
|
664
|
+
"index.d.ts",
|
|
665
|
+
r.dts(e.root, n)
|
|
666
|
+
);
|
|
667
|
+
o.files.push(s);
|
|
668
|
+
}
|
|
669
|
+
return o;
|
|
589
670
|
}
|
|
590
671
|
async function directoryExists(path2) {
|
|
591
672
|
try {
|
|
@@ -601,7 +682,7 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
|
|
|
601
682
|
environment: process.env.NODE_ENV || "development",
|
|
602
683
|
isBuild: true
|
|
603
684
|
});
|
|
604
|
-
const output = await
|
|
685
|
+
const output = await ke$1(instance, transpiler);
|
|
605
686
|
const outputDirExists = await directoryExists(outputDir);
|
|
606
687
|
if (clean && outputDirExists) {
|
|
607
688
|
await rm(outputDir, { recursive: true });
|
|
@@ -616,90 +697,109 @@ async function build(instance, { clean = true, outputDir = "./styleframe", trans
|
|
|
616
697
|
await writeFile(filePath, file.content);
|
|
617
698
|
}
|
|
618
699
|
}
|
|
619
|
-
function
|
|
700
|
+
function C(e) {
|
|
620
701
|
return typeof e == "object" && e !== null;
|
|
621
702
|
}
|
|
622
|
-
function
|
|
623
|
-
return
|
|
703
|
+
function h(e, r) {
|
|
704
|
+
return C(e) && "type" in e && e.type === r;
|
|
624
705
|
}
|
|
625
|
-
function
|
|
626
|
-
return
|
|
706
|
+
function G(e) {
|
|
707
|
+
return h(e, "variable");
|
|
627
708
|
}
|
|
628
|
-
function
|
|
629
|
-
return
|
|
709
|
+
function j(e) {
|
|
710
|
+
return h(e, "reference");
|
|
630
711
|
}
|
|
631
|
-
function
|
|
632
|
-
return
|
|
712
|
+
function Ae(e) {
|
|
713
|
+
return h(e, "selector");
|
|
633
714
|
}
|
|
634
|
-
function
|
|
635
|
-
return
|
|
715
|
+
function I(e) {
|
|
716
|
+
return h(e, "modifier");
|
|
636
717
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
718
|
+
function T(e) {
|
|
719
|
+
return h(e, "css");
|
|
639
720
|
}
|
|
640
|
-
function
|
|
641
|
-
return
|
|
721
|
+
function V(e) {
|
|
722
|
+
return h(e, "root");
|
|
642
723
|
}
|
|
643
|
-
function
|
|
724
|
+
function ke(e) {
|
|
725
|
+
return h(e, "recipe");
|
|
726
|
+
}
|
|
727
|
+
function z(e) {
|
|
644
728
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
645
729
|
}
|
|
646
|
-
function
|
|
647
|
-
return
|
|
730
|
+
function D(e) {
|
|
731
|
+
return z(e) || j(e) || T(e) || Array.isArray(e) && e.every(D);
|
|
648
732
|
}
|
|
649
|
-
function
|
|
650
|
-
return
|
|
651
|
-
}
|
|
652
|
-
function
|
|
653
|
-
return (
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
733
|
+
function Y(e) {
|
|
734
|
+
return C(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
735
|
+
}
|
|
736
|
+
function Ve(e) {
|
|
737
|
+
return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
|
|
738
|
+
}
|
|
739
|
+
function P(e) {
|
|
740
|
+
const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
|
|
741
|
+
return (c) => {
|
|
742
|
+
let s = c, a;
|
|
743
|
+
if (typeof s == "string" && s[0] === "@") {
|
|
744
|
+
const o = s.slice(1), f = i.find(
|
|
745
|
+
(y) => o === y || o.startsWith(`${y}.`)
|
|
746
|
+
);
|
|
747
|
+
let l, u;
|
|
748
|
+
f ? (l = o, u = o.startsWith(`${f}.`) ? o.slice(f.length + 1) : o) : i.length > 0 ? (l = `${i[0]}.${o}`, u = o) : (l = o, u = o), a = n(u), s = {
|
|
658
749
|
type: "reference",
|
|
659
|
-
name:
|
|
750
|
+
name: l
|
|
660
751
|
};
|
|
661
|
-
} else
|
|
752
|
+
} else if (j(s)) {
|
|
753
|
+
let o = s.name;
|
|
754
|
+
for (const f of i)
|
|
755
|
+
if (o.startsWith(`${f}.`)) {
|
|
756
|
+
o = o.slice(f.length + 1);
|
|
757
|
+
break;
|
|
758
|
+
}
|
|
759
|
+
a = n(o);
|
|
760
|
+
} else
|
|
761
|
+
a = `[${c}]`;
|
|
662
762
|
return {
|
|
663
|
-
[
|
|
763
|
+
[a]: s
|
|
664
764
|
};
|
|
665
765
|
};
|
|
666
766
|
}
|
|
667
|
-
function
|
|
767
|
+
function Z(e, r) {
|
|
668
768
|
return function(t, ...i) {
|
|
669
769
|
return {
|
|
670
770
|
type: "css",
|
|
671
|
-
value: t.reduce((
|
|
771
|
+
value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
|
|
672
772
|
};
|
|
673
773
|
};
|
|
674
774
|
}
|
|
675
|
-
function
|
|
775
|
+
function K(e, r) {
|
|
676
776
|
return function(t, i, c) {
|
|
677
|
-
const
|
|
777
|
+
const s = {
|
|
678
778
|
type: "at-rule",
|
|
679
779
|
identifier: t,
|
|
680
780
|
rule: i,
|
|
681
781
|
declarations: {},
|
|
682
782
|
variables: [],
|
|
683
783
|
children: []
|
|
684
|
-
},
|
|
685
|
-
return typeof c == "function" ?
|
|
784
|
+
}, a = v(s, r);
|
|
785
|
+
return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
|
|
686
786
|
};
|
|
687
787
|
}
|
|
688
|
-
function
|
|
689
|
-
const n =
|
|
788
|
+
function J(e, r) {
|
|
789
|
+
const n = K(e, r);
|
|
690
790
|
return function(i, c) {
|
|
691
791
|
return n("media", i, c);
|
|
692
792
|
};
|
|
693
793
|
}
|
|
694
|
-
function
|
|
695
|
-
const n =
|
|
794
|
+
function Q(e, r) {
|
|
795
|
+
const n = K(e, r);
|
|
696
796
|
return function(i, c) {
|
|
697
797
|
return n("keyframes", i, c);
|
|
698
798
|
};
|
|
699
799
|
}
|
|
700
|
-
function
|
|
800
|
+
function X(e, r) {
|
|
701
801
|
return function(t, i) {
|
|
702
|
-
return
|
|
802
|
+
return G(t) ? {
|
|
703
803
|
type: "reference",
|
|
704
804
|
name: t.name,
|
|
705
805
|
fallback: i
|
|
@@ -710,7 +810,7 @@ function J(e, r) {
|
|
|
710
810
|
};
|
|
711
811
|
};
|
|
712
812
|
}
|
|
713
|
-
function
|
|
813
|
+
function ee(e, r) {
|
|
714
814
|
return function(t, i) {
|
|
715
815
|
const c = {
|
|
716
816
|
type: "selector",
|
|
@@ -718,56 +818,60 @@ function Q(e, r) {
|
|
|
718
818
|
declarations: {},
|
|
719
819
|
variables: [],
|
|
720
820
|
children: []
|
|
721
|
-
},
|
|
722
|
-
return typeof i == "function" ? c.declarations = i(
|
|
821
|
+
}, s = v(c, r);
|
|
822
|
+
return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
|
|
723
823
|
};
|
|
724
824
|
}
|
|
725
|
-
function
|
|
825
|
+
function te(e, r) {
|
|
726
826
|
return function(t, i, c = {
|
|
727
827
|
default: false
|
|
728
828
|
}) {
|
|
729
|
-
const
|
|
730
|
-
(f) => f.name ===
|
|
829
|
+
const s = typeof t == "string" ? t : t.name, a = e.variables.find(
|
|
830
|
+
(f) => f.name === s
|
|
731
831
|
);
|
|
732
|
-
if (c.default &&
|
|
733
|
-
return
|
|
734
|
-
if (
|
|
735
|
-
return
|
|
736
|
-
const
|
|
832
|
+
if (c.default && a)
|
|
833
|
+
return a;
|
|
834
|
+
if (a)
|
|
835
|
+
return a.value = i, a;
|
|
836
|
+
const o = {
|
|
737
837
|
type: "variable",
|
|
738
|
-
name:
|
|
838
|
+
name: s,
|
|
739
839
|
value: i
|
|
740
840
|
};
|
|
741
|
-
return e.variables.push(
|
|
841
|
+
return e.variables.push(o), o;
|
|
742
842
|
};
|
|
743
843
|
}
|
|
744
844
|
function v(e, r) {
|
|
745
|
-
const n =
|
|
845
|
+
const n = te(e), t = ee(e, r), i = K(e, r), c = Q(r, r), s = J(e, r), a = X(), o = Z();
|
|
746
846
|
return {
|
|
747
847
|
variable: n,
|
|
748
848
|
selector: t,
|
|
749
849
|
keyframes: c,
|
|
750
850
|
atRule: i,
|
|
751
|
-
media:
|
|
752
|
-
ref:
|
|
753
|
-
css:
|
|
851
|
+
media: s,
|
|
852
|
+
ref: a,
|
|
853
|
+
css: o
|
|
754
854
|
};
|
|
755
855
|
}
|
|
756
|
-
function
|
|
856
|
+
function R(e, r) {
|
|
757
857
|
for (const n in e)
|
|
758
858
|
if (n.startsWith("@")) {
|
|
759
859
|
const t = e[n];
|
|
760
|
-
if (typeof t == "object" && t !== null &&
|
|
860
|
+
if (typeof t == "object" && t !== null && !D(t)) {
|
|
761
861
|
const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
|
|
762
862
|
r.atRule(i, c, t), delete e[n];
|
|
763
863
|
}
|
|
764
|
-
} else if (/^[.&:]/.test(n)) {
|
|
864
|
+
} else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
|
|
765
865
|
const t = e[n];
|
|
766
866
|
typeof t == "object" && (r.selector(n, t), delete e[n]);
|
|
767
867
|
}
|
|
868
|
+
for (const n in e) {
|
|
869
|
+
const t = e[n];
|
|
870
|
+
typeof t == "string" && t[0] === "@" && (e[n] = r.ref(t.slice(1)));
|
|
871
|
+
}
|
|
768
872
|
return e;
|
|
769
873
|
}
|
|
770
|
-
function
|
|
874
|
+
function A(e) {
|
|
771
875
|
if (e instanceof Buffer)
|
|
772
876
|
return Buffer.from(e);
|
|
773
877
|
const r = e.constructor;
|
|
@@ -777,133 +881,133 @@ function j(e) {
|
|
|
777
881
|
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
778
882
|
);
|
|
779
883
|
}
|
|
780
|
-
function
|
|
884
|
+
function ne(e) {
|
|
781
885
|
if (e = e || {}, e.circular)
|
|
782
|
-
return
|
|
886
|
+
return re(e);
|
|
783
887
|
const r = /* @__PURE__ */ new Map();
|
|
784
|
-
if (r.set(Date, (
|
|
888
|
+
if (r.set(Date, (s) => new Date(s)), r.set(
|
|
785
889
|
Map,
|
|
786
|
-
(
|
|
890
|
+
(s, a) => new Map(t(Array.from(s), a))
|
|
787
891
|
), r.set(
|
|
788
892
|
Set,
|
|
789
|
-
(
|
|
893
|
+
(s, a) => new Set(t(Array.from(s), a))
|
|
790
894
|
), e.constructorHandlers)
|
|
791
|
-
for (const
|
|
792
|
-
r.set(
|
|
895
|
+
for (const s of e.constructorHandlers)
|
|
896
|
+
r.set(s[0], s[1]);
|
|
793
897
|
let n;
|
|
794
898
|
return e.proto ? c : i;
|
|
795
|
-
function t(
|
|
796
|
-
const
|
|
797
|
-
for (let l = 0; l <
|
|
798
|
-
const
|
|
799
|
-
typeof y != "object" || y === null ? f[
|
|
899
|
+
function t(s, a) {
|
|
900
|
+
const o = Object.keys(s), f = Array.from({ length: o.length });
|
|
901
|
+
for (let l = 0; l < o.length; l++) {
|
|
902
|
+
const u = o[l], y = s[u];
|
|
903
|
+
typeof y != "object" || y === null ? f[u] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[u] = n(y, a) : ArrayBuffer.isView(y) ? f[u] = A(y) : f[u] = a(y);
|
|
800
904
|
}
|
|
801
905
|
return f;
|
|
802
906
|
}
|
|
803
|
-
function i(
|
|
804
|
-
if (typeof
|
|
805
|
-
if (Array.isArray(
|
|
806
|
-
if (
|
|
807
|
-
return n(
|
|
808
|
-
const
|
|
809
|
-
for (const
|
|
810
|
-
if (Object.hasOwnProperty.call(
|
|
811
|
-
const f = o
|
|
812
|
-
typeof f != "object" || f === null ?
|
|
907
|
+
function i(s) {
|
|
908
|
+
if (typeof s != "object" || s === null) return s;
|
|
909
|
+
if (Array.isArray(s)) return t(s, i);
|
|
910
|
+
if (s.constructor !== Object && (n = r.get(s.constructor)))
|
|
911
|
+
return n(s, i);
|
|
912
|
+
const a = {};
|
|
913
|
+
for (const o in s) {
|
|
914
|
+
if (Object.hasOwnProperty.call(s, o) === false) continue;
|
|
915
|
+
const f = s[o];
|
|
916
|
+
typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, i) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = i(f);
|
|
813
917
|
}
|
|
814
|
-
return
|
|
918
|
+
return a;
|
|
815
919
|
}
|
|
816
|
-
function c(
|
|
817
|
-
if (typeof
|
|
818
|
-
if (Array.isArray(
|
|
819
|
-
if (
|
|
820
|
-
return n(
|
|
821
|
-
const
|
|
822
|
-
for (const
|
|
823
|
-
const f = o
|
|
824
|
-
typeof f != "object" || f === null ?
|
|
920
|
+
function c(s) {
|
|
921
|
+
if (typeof s != "object" || s === null) return s;
|
|
922
|
+
if (Array.isArray(s)) return t(s, c);
|
|
923
|
+
if (s.constructor !== Object && (n = r.get(s.constructor)))
|
|
924
|
+
return n(s, c);
|
|
925
|
+
const a = {};
|
|
926
|
+
for (const o in s) {
|
|
927
|
+
const f = s[o];
|
|
928
|
+
typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, c) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = c(f);
|
|
825
929
|
}
|
|
826
|
-
return
|
|
930
|
+
return a;
|
|
827
931
|
}
|
|
828
932
|
}
|
|
829
|
-
function
|
|
933
|
+
function re(e) {
|
|
830
934
|
const r = [], n = [], t = /* @__PURE__ */ new Map();
|
|
831
|
-
if (t.set(Date, (
|
|
935
|
+
if (t.set(Date, (o) => new Date(o)), t.set(
|
|
832
936
|
Map,
|
|
833
|
-
(
|
|
937
|
+
(o, f) => new Map(c(Array.from(o), f))
|
|
834
938
|
), t.set(
|
|
835
939
|
Set,
|
|
836
|
-
(
|
|
940
|
+
(o, f) => new Set(c(Array.from(o), f))
|
|
837
941
|
), e.constructorHandlers)
|
|
838
|
-
for (const
|
|
839
|
-
t.set(
|
|
942
|
+
for (const o of e.constructorHandlers)
|
|
943
|
+
t.set(o[0], o[1]);
|
|
840
944
|
let i;
|
|
841
|
-
return e.proto ?
|
|
842
|
-
function c(
|
|
843
|
-
const l = Object.keys(
|
|
945
|
+
return e.proto ? a : s;
|
|
946
|
+
function c(o, f) {
|
|
947
|
+
const l = Object.keys(o), u = Array.from({ length: l.length });
|
|
844
948
|
for (let y = 0; y < l.length; y++) {
|
|
845
|
-
const
|
|
949
|
+
const p = l[y], d2 = o[p];
|
|
846
950
|
if (typeof d2 != "object" || d2 === null)
|
|
847
|
-
|
|
951
|
+
u[p] = d2;
|
|
848
952
|
else if (d2.constructor !== Object && (i = t.get(d2.constructor)))
|
|
849
|
-
|
|
953
|
+
u[p] = i(d2, f);
|
|
850
954
|
else if (ArrayBuffer.isView(d2))
|
|
851
|
-
|
|
955
|
+
u[p] = A(d2);
|
|
852
956
|
else {
|
|
853
|
-
const
|
|
854
|
-
|
|
957
|
+
const w2 = r.indexOf(d2);
|
|
958
|
+
w2 !== -1 ? u[p] = n[w2] : u[p] = f(d2);
|
|
855
959
|
}
|
|
856
960
|
}
|
|
857
|
-
return
|
|
961
|
+
return u;
|
|
858
962
|
}
|
|
859
|
-
function o
|
|
860
|
-
if (typeof
|
|
861
|
-
if (Array.isArray(
|
|
862
|
-
if (
|
|
863
|
-
return i(
|
|
963
|
+
function s(o) {
|
|
964
|
+
if (typeof o != "object" || o === null) return o;
|
|
965
|
+
if (Array.isArray(o)) return c(o, s);
|
|
966
|
+
if (o.constructor !== Object && (i = t.get(o.constructor)))
|
|
967
|
+
return i(o, s);
|
|
864
968
|
const f = {};
|
|
865
|
-
r.push(
|
|
866
|
-
for (const l in
|
|
867
|
-
if (Object.hasOwnProperty.call(
|
|
868
|
-
const
|
|
869
|
-
if (typeof
|
|
870
|
-
f[l] =
|
|
871
|
-
else if (
|
|
872
|
-
f[l] = i(
|
|
873
|
-
else if (ArrayBuffer.isView(
|
|
874
|
-
f[l] =
|
|
969
|
+
r.push(o), n.push(f);
|
|
970
|
+
for (const l in o) {
|
|
971
|
+
if (Object.hasOwnProperty.call(o, l) === false) continue;
|
|
972
|
+
const u = o[l];
|
|
973
|
+
if (typeof u != "object" || u === null)
|
|
974
|
+
f[l] = u;
|
|
975
|
+
else if (u.constructor !== Object && (i = t.get(u.constructor)))
|
|
976
|
+
f[l] = i(u, s);
|
|
977
|
+
else if (ArrayBuffer.isView(u))
|
|
978
|
+
f[l] = A(u);
|
|
875
979
|
else {
|
|
876
|
-
const y = r.indexOf(
|
|
877
|
-
y !== -1 ? f[l] = n[y] : f[l] =
|
|
980
|
+
const y = r.indexOf(u);
|
|
981
|
+
y !== -1 ? f[l] = n[y] : f[l] = s(u);
|
|
878
982
|
}
|
|
879
983
|
}
|
|
880
984
|
return r.pop(), n.pop(), f;
|
|
881
985
|
}
|
|
882
|
-
function
|
|
883
|
-
if (typeof
|
|
884
|
-
if (Array.isArray(
|
|
885
|
-
if (
|
|
886
|
-
return i(
|
|
986
|
+
function a(o) {
|
|
987
|
+
if (typeof o != "object" || o === null) return o;
|
|
988
|
+
if (Array.isArray(o)) return c(o, a);
|
|
989
|
+
if (o.constructor !== Object && (i = t.get(o.constructor)))
|
|
990
|
+
return i(o, a);
|
|
887
991
|
const f = {};
|
|
888
|
-
r.push(
|
|
889
|
-
for (const l in
|
|
890
|
-
const
|
|
891
|
-
if (typeof
|
|
892
|
-
f[l] =
|
|
893
|
-
else if (
|
|
894
|
-
f[l] = i(
|
|
895
|
-
else if (ArrayBuffer.isView(
|
|
896
|
-
f[l] =
|
|
992
|
+
r.push(o), n.push(f);
|
|
993
|
+
for (const l in o) {
|
|
994
|
+
const u = o[l];
|
|
995
|
+
if (typeof u != "object" || u === null)
|
|
996
|
+
f[l] = u;
|
|
997
|
+
else if (u.constructor !== Object && (i = t.get(u.constructor)))
|
|
998
|
+
f[l] = i(u, a);
|
|
999
|
+
else if (ArrayBuffer.isView(u))
|
|
1000
|
+
f[l] = A(u);
|
|
897
1001
|
else {
|
|
898
|
-
const y = r.indexOf(
|
|
899
|
-
y !== -1 ? f[l] = n[y] : f[l] = u
|
|
1002
|
+
const y = r.indexOf(u);
|
|
1003
|
+
y !== -1 ? f[l] = n[y] : f[l] = a(u);
|
|
900
1004
|
}
|
|
901
1005
|
}
|
|
902
1006
|
return r.pop(), n.pop(), f;
|
|
903
1007
|
}
|
|
904
1008
|
}
|
|
905
|
-
const
|
|
906
|
-
function
|
|
1009
|
+
const F = ne();
|
|
1010
|
+
function ie(e, r = 8) {
|
|
907
1011
|
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
908
1012
|
let t = "";
|
|
909
1013
|
for (let i = 0; i < r; i++) {
|
|
@@ -912,7 +1016,7 @@ function ne(e, r = 8) {
|
|
|
912
1016
|
}
|
|
913
1017
|
return e ? `${e}${t}` : t;
|
|
914
1018
|
}
|
|
915
|
-
function
|
|
1019
|
+
function se(e, r) {
|
|
916
1020
|
const n = e.modifiers.find(
|
|
917
1021
|
(t) => t.key.includes(r)
|
|
918
1022
|
);
|
|
@@ -920,23 +1024,23 @@ function re(e, r) {
|
|
|
920
1024
|
throw new Error(`Modifier "${r}" not found`);
|
|
921
1025
|
return n;
|
|
922
1026
|
}
|
|
923
|
-
function
|
|
1027
|
+
function ae(e) {
|
|
924
1028
|
const r = [];
|
|
925
1029
|
function n(t, i) {
|
|
926
1030
|
i.length > 0 && r.push([...i].sort());
|
|
927
1031
|
for (let c = t; c < e.length; c++) {
|
|
928
|
-
const
|
|
929
|
-
if (
|
|
930
|
-
if (
|
|
931
|
-
n(c + 1, [...i,
|
|
1032
|
+
const s = e[c];
|
|
1033
|
+
if (s)
|
|
1034
|
+
if (s.length === 1 && s[0])
|
|
1035
|
+
n(c + 1, [...i, s[0]]);
|
|
932
1036
|
else
|
|
933
|
-
for (const
|
|
934
|
-
n(c + 1, [...i,
|
|
1037
|
+
for (const a of s)
|
|
1038
|
+
n(c + 1, [...i, a]);
|
|
935
1039
|
}
|
|
936
1040
|
}
|
|
937
1041
|
return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
|
|
938
1042
|
}
|
|
939
|
-
function
|
|
1043
|
+
function ue(e, r, n) {
|
|
940
1044
|
const t = {
|
|
941
1045
|
...e,
|
|
942
1046
|
modifiers: [...n.keys()]
|
|
@@ -944,13 +1048,13 @@ function fe(e, r, n) {
|
|
|
944
1048
|
for (const c of n.values())
|
|
945
1049
|
c.factory({
|
|
946
1050
|
...i,
|
|
947
|
-
declarations:
|
|
948
|
-
variables:
|
|
949
|
-
children:
|
|
950
|
-
}),
|
|
1051
|
+
declarations: F(t.declarations),
|
|
1052
|
+
variables: F(t.variables),
|
|
1053
|
+
children: F(t.children)
|
|
1054
|
+
}), R(t.declarations, i);
|
|
951
1055
|
return t;
|
|
952
1056
|
}
|
|
953
|
-
function
|
|
1057
|
+
function le(e, r) {
|
|
954
1058
|
return function(t, i) {
|
|
955
1059
|
const c = {
|
|
956
1060
|
type: "modifier",
|
|
@@ -960,7 +1064,7 @@ function ue(e, r) {
|
|
|
960
1064
|
return r.modifiers.push(c), c;
|
|
961
1065
|
};
|
|
962
1066
|
}
|
|
963
|
-
function
|
|
1067
|
+
function ye() {
|
|
964
1068
|
return {
|
|
965
1069
|
type: "root",
|
|
966
1070
|
declarations: {},
|
|
@@ -972,30 +1076,84 @@ function ae() {
|
|
|
972
1076
|
themes: []
|
|
973
1077
|
};
|
|
974
1078
|
}
|
|
975
|
-
function
|
|
1079
|
+
function de(e, r) {
|
|
1080
|
+
const n = P({ namespace: e });
|
|
1081
|
+
return (t) => {
|
|
1082
|
+
if (typeof t == "string" && t[0] === "@") {
|
|
1083
|
+
const i = t.slice(1), c = e.find(
|
|
1084
|
+
(s) => i === s || i.startsWith(`${s}.`)
|
|
1085
|
+
);
|
|
1086
|
+
if (c) {
|
|
1087
|
+
const s = i.slice(c.length + 1) || i;
|
|
1088
|
+
if (r.variables.some((a) => a.name === i))
|
|
1089
|
+
return {
|
|
1090
|
+
[s]: {
|
|
1091
|
+
type: "reference",
|
|
1092
|
+
name: i
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
} else
|
|
1096
|
+
for (const s of e) {
|
|
1097
|
+
const a = `${s}.${i}`;
|
|
1098
|
+
if (r.variables.some((o) => o.name === a))
|
|
1099
|
+
return {
|
|
1100
|
+
[i]: {
|
|
1101
|
+
type: "reference",
|
|
1102
|
+
name: a
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
return n(t);
|
|
1107
|
+
}
|
|
1108
|
+
return n(t);
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
function me(e, r) {
|
|
976
1112
|
return function(t, i, c = {}) {
|
|
977
|
-
const
|
|
1113
|
+
const s = {
|
|
978
1114
|
type: "utility",
|
|
979
1115
|
name: t,
|
|
980
1116
|
factory: i,
|
|
981
1117
|
values: [],
|
|
982
|
-
autogenerate: c.autogenerate ??
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1118
|
+
autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? de(c.namespace, r) : P(
|
|
1119
|
+
c.namespace ? { namespace: c.namespace } : void 0
|
|
1120
|
+
)),
|
|
1121
|
+
namespace: c.namespace,
|
|
1122
|
+
create: (a, o = []) => {
|
|
1123
|
+
let f = a;
|
|
1124
|
+
if (Array.isArray(a)) {
|
|
986
1125
|
f = {};
|
|
987
|
-
for (const l of
|
|
988
|
-
const
|
|
1126
|
+
for (const l of a) {
|
|
1127
|
+
const u = s.autogenerate(l);
|
|
989
1128
|
f = {
|
|
990
1129
|
...f,
|
|
991
|
-
...
|
|
1130
|
+
...u
|
|
992
1131
|
};
|
|
993
1132
|
}
|
|
994
1133
|
}
|
|
995
|
-
for (const [l,
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1134
|
+
for (const [l, u] of Object.entries(f)) {
|
|
1135
|
+
let y = u;
|
|
1136
|
+
if (s.namespace && j(u))
|
|
1137
|
+
if (r.variables.some((g) => g.name === u.name))
|
|
1138
|
+
y = u;
|
|
1139
|
+
else {
|
|
1140
|
+
const g = Array.isArray(s.namespace) ? s.namespace : [s.namespace];
|
|
1141
|
+
let $2 = false;
|
|
1142
|
+
for (const O2 of g) {
|
|
1143
|
+
const m = `${O2}.${l}`;
|
|
1144
|
+
if (m !== u.name && r.variables.some((b) => b.name === m)) {
|
|
1145
|
+
y = {
|
|
1146
|
+
type: "reference",
|
|
1147
|
+
name: m
|
|
1148
|
+
}, $2 = true;
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
$2 || (y = l);
|
|
1153
|
+
}
|
|
1154
|
+
const p = s.values.find(
|
|
1155
|
+
(g) => g.key === l && g.modifiers.length === 0
|
|
1156
|
+
), d2 = {
|
|
999
1157
|
type: "utility",
|
|
1000
1158
|
name: t,
|
|
1001
1159
|
value: l,
|
|
@@ -1003,196 +1161,253 @@ function le(e, r) {
|
|
|
1003
1161
|
variables: [],
|
|
1004
1162
|
children: [],
|
|
1005
1163
|
modifiers: []
|
|
1006
|
-
},
|
|
1007
|
-
|
|
1164
|
+
}, w2 = v(
|
|
1165
|
+
d2,
|
|
1008
1166
|
r
|
|
1009
1167
|
);
|
|
1010
|
-
if (
|
|
1011
|
-
...
|
|
1012
|
-
value:
|
|
1013
|
-
}) ?? {},
|
|
1168
|
+
if (d2.declarations = i({
|
|
1169
|
+
...w2,
|
|
1170
|
+
value: y
|
|
1171
|
+
}) ?? {}, R(d2.declarations, w2), p || (s.values.push({
|
|
1014
1172
|
key: l,
|
|
1015
|
-
value:
|
|
1173
|
+
value: y,
|
|
1016
1174
|
modifiers: []
|
|
1017
|
-
}), e.children.push(
|
|
1018
|
-
const
|
|
1019
|
-
(
|
|
1020
|
-
)).reduce((
|
|
1021
|
-
const
|
|
1022
|
-
for (const
|
|
1023
|
-
const
|
|
1024
|
-
(
|
|
1175
|
+
}), e.children.push(d2)), o && o.length > 0) {
|
|
1176
|
+
const g = o.map((m) => m.key), O2 = ae(g).filter((m) => !s.values.find(
|
|
1177
|
+
(b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k2) => m.includes(k2))
|
|
1178
|
+
)).reduce((m, b) => {
|
|
1179
|
+
const k2 = /* @__PURE__ */ new Map();
|
|
1180
|
+
for (const U2 of b) {
|
|
1181
|
+
const M2 = o.find(
|
|
1182
|
+
(q2) => q2.key.includes(U2)
|
|
1025
1183
|
);
|
|
1026
|
-
|
|
1184
|
+
M2 && I(M2) && k2.set(U2, M2);
|
|
1027
1185
|
}
|
|
1028
|
-
return
|
|
1186
|
+
return s.values.push({
|
|
1029
1187
|
key: l,
|
|
1030
|
-
value:
|
|
1031
|
-
modifiers:
|
|
1032
|
-
}),
|
|
1188
|
+
value: y,
|
|
1189
|
+
modifiers: b
|
|
1190
|
+
}), m.push(ue(d2, r, k2)), m;
|
|
1033
1191
|
}, []);
|
|
1034
|
-
e.children.push(...
|
|
1192
|
+
e.children.push(...O2);
|
|
1035
1193
|
}
|
|
1036
1194
|
}
|
|
1037
1195
|
}
|
|
1038
1196
|
};
|
|
1039
|
-
return r.utilities.push(
|
|
1197
|
+
return r.utilities.push(s), s.create;
|
|
1040
1198
|
};
|
|
1041
1199
|
}
|
|
1042
|
-
function
|
|
1200
|
+
function pe(e, r) {
|
|
1043
1201
|
return function(t, i) {
|
|
1044
|
-
const c = r.themes.find((
|
|
1202
|
+
const c = r.themes.find((o) => o.name === t), s = c ?? {
|
|
1045
1203
|
type: "theme",
|
|
1046
1204
|
name: t,
|
|
1047
1205
|
declarations: {},
|
|
1048
1206
|
variables: [],
|
|
1049
1207
|
children: []
|
|
1050
1208
|
};
|
|
1051
|
-
c || r.themes.push(
|
|
1052
|
-
const
|
|
1053
|
-
return i && i(
|
|
1209
|
+
c || r.themes.push(s);
|
|
1210
|
+
const a = v(s, r);
|
|
1211
|
+
return i && i(a), s;
|
|
1054
1212
|
};
|
|
1055
1213
|
}
|
|
1056
|
-
function
|
|
1214
|
+
function he(e, r) {
|
|
1057
1215
|
return function(t) {
|
|
1058
1216
|
const i = {
|
|
1059
1217
|
type: "recipe",
|
|
1060
1218
|
...t
|
|
1061
1219
|
};
|
|
1062
|
-
return i._runtime =
|
|
1220
|
+
return i._runtime = ge(i, r), be(i, r), r.recipes.push(i), i;
|
|
1063
1221
|
};
|
|
1064
1222
|
}
|
|
1065
1223
|
function _(e, r) {
|
|
1066
1224
|
const n = e.autogenerate(r);
|
|
1067
1225
|
return Object.keys(n)[0] ?? "default";
|
|
1068
1226
|
}
|
|
1069
|
-
function
|
|
1227
|
+
function x(e, r) {
|
|
1070
1228
|
const n = {};
|
|
1071
1229
|
for (const [t, i] of Object.entries(e))
|
|
1072
|
-
if (
|
|
1230
|
+
if (L(i)) {
|
|
1073
1231
|
const c = {};
|
|
1074
|
-
for (const [
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
)
|
|
1232
|
+
for (const [s, a] of Object.entries(i)) {
|
|
1233
|
+
const o = S(r, s);
|
|
1234
|
+
o ? c[s] = _(
|
|
1235
|
+
o,
|
|
1236
|
+
a
|
|
1237
|
+
) : console.warn(
|
|
1238
|
+
`[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`
|
|
1239
|
+
);
|
|
1080
1240
|
}
|
|
1081
1241
|
n[t] = c;
|
|
1082
1242
|
} else if (typeof i == "boolean")
|
|
1083
1243
|
n[t] = i;
|
|
1084
1244
|
else {
|
|
1085
|
-
const c =
|
|
1086
|
-
c
|
|
1245
|
+
const c = S(r, t);
|
|
1246
|
+
c ? n[t] = _(c, i) : console.warn(
|
|
1247
|
+
`[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
|
|
1248
|
+
);
|
|
1087
1249
|
}
|
|
1088
1250
|
return n;
|
|
1089
1251
|
}
|
|
1090
|
-
function
|
|
1252
|
+
function ge(e, r) {
|
|
1091
1253
|
const n = {};
|
|
1092
|
-
if (e.base && (n.base =
|
|
1254
|
+
if (e.base && (n.base = x(e.base, r)), e.variants) {
|
|
1093
1255
|
const t = {};
|
|
1094
1256
|
for (const [i, c] of Object.entries(e.variants)) {
|
|
1095
|
-
const
|
|
1096
|
-
for (const [
|
|
1257
|
+
const s = {};
|
|
1258
|
+
for (const [a, o] of Object.entries(
|
|
1097
1259
|
c
|
|
1098
1260
|
))
|
|
1099
|
-
|
|
1100
|
-
|
|
1261
|
+
o == null ? s[a] = null : s[a] = x(
|
|
1262
|
+
o,
|
|
1101
1263
|
r
|
|
1102
1264
|
);
|
|
1103
|
-
t[i] =
|
|
1265
|
+
t[i] = s;
|
|
1104
1266
|
}
|
|
1105
1267
|
n.variants = t;
|
|
1106
1268
|
}
|
|
1107
1269
|
return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
|
|
1108
1270
|
match: { ...t.match },
|
|
1109
|
-
css:
|
|
1271
|
+
css: x(t.css, r)
|
|
1110
1272
|
}))), n;
|
|
1111
1273
|
}
|
|
1112
|
-
function
|
|
1113
|
-
return !
|
|
1274
|
+
function L(e) {
|
|
1275
|
+
return !j(e) && typeof e == "object" && e !== null;
|
|
1114
1276
|
}
|
|
1115
|
-
function
|
|
1277
|
+
function E(e, r) {
|
|
1116
1278
|
const n = (t, i, c) => {
|
|
1117
|
-
let
|
|
1118
|
-
|
|
1279
|
+
let s = r.get(t);
|
|
1280
|
+
s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
|
|
1119
1281
|
};
|
|
1120
1282
|
for (const [t, i] of Object.entries(e))
|
|
1121
|
-
if (
|
|
1283
|
+
if (L(i)) {
|
|
1122
1284
|
const c = t.split(":");
|
|
1123
|
-
for (const [
|
|
1124
|
-
n(
|
|
1285
|
+
for (const [s, a] of Object.entries(i))
|
|
1286
|
+
n(s, a, c);
|
|
1125
1287
|
} else
|
|
1126
1288
|
n(t, i, []);
|
|
1127
1289
|
}
|
|
1128
|
-
function
|
|
1290
|
+
function S(e, r) {
|
|
1129
1291
|
const n = e.utilities.find((i) => i.name === r);
|
|
1130
1292
|
if (n)
|
|
1131
1293
|
return n;
|
|
1132
1294
|
const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
|
|
1133
1295
|
return e.utilities.find((i) => i.name === t);
|
|
1134
1296
|
}
|
|
1135
|
-
function
|
|
1297
|
+
function be(e, r) {
|
|
1136
1298
|
const n = /* @__PURE__ */ new Map();
|
|
1137
|
-
if (e.base &&
|
|
1299
|
+
if (e.base && E(e.base, n), e.variants)
|
|
1138
1300
|
for (const i of Object.values(e.variants))
|
|
1139
1301
|
for (const c of Object.values(i))
|
|
1140
|
-
|
|
1302
|
+
E(
|
|
1141
1303
|
c,
|
|
1142
1304
|
n
|
|
1143
1305
|
);
|
|
1144
1306
|
if (e.compoundVariants)
|
|
1145
1307
|
for (const i of e.compoundVariants)
|
|
1146
|
-
i.css &&
|
|
1308
|
+
i.css && E(i.css, n);
|
|
1147
1309
|
const t = /* @__PURE__ */ new Map();
|
|
1148
1310
|
for (const [i, c] of n) {
|
|
1149
|
-
const
|
|
1150
|
-
if (!
|
|
1311
|
+
const s = S(r, i);
|
|
1312
|
+
if (!s) {
|
|
1151
1313
|
console.warn(
|
|
1152
1314
|
`[styleframe] Utility "${i}" not found in registry. Skipping.`
|
|
1153
1315
|
);
|
|
1154
1316
|
continue;
|
|
1155
1317
|
}
|
|
1156
|
-
for (const
|
|
1157
|
-
const
|
|
1158
|
-
for (const f of
|
|
1318
|
+
for (const a of c) {
|
|
1319
|
+
const o = [];
|
|
1320
|
+
for (const f of a.modifiers) {
|
|
1159
1321
|
if (!t.has(f))
|
|
1160
1322
|
try {
|
|
1161
|
-
t.set(f,
|
|
1323
|
+
t.set(f, se(r, f));
|
|
1162
1324
|
} catch {
|
|
1163
1325
|
console.warn(
|
|
1164
1326
|
`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
|
|
1165
1327
|
), t.set(f, null);
|
|
1166
1328
|
}
|
|
1167
1329
|
const l = t.get(f);
|
|
1168
|
-
l &&
|
|
1330
|
+
l && o.push(l);
|
|
1169
1331
|
}
|
|
1170
|
-
|
|
1171
|
-
[
|
|
1172
|
-
|
|
1332
|
+
s.create(
|
|
1333
|
+
[a.value],
|
|
1334
|
+
o.length > 0 ? o : void 0
|
|
1173
1335
|
);
|
|
1174
1336
|
}
|
|
1175
1337
|
}
|
|
1176
1338
|
}
|
|
1177
|
-
function
|
|
1178
|
-
const r =
|
|
1339
|
+
function Fe(e) {
|
|
1340
|
+
const r = ie("sf-"), n = ye(), t = { ...e }, i = me(n, n), c = le(n, n), s = he(n, n), a = pe(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d2 } = v(n, n);
|
|
1179
1341
|
return {
|
|
1180
1342
|
id: r,
|
|
1181
1343
|
root: n,
|
|
1182
|
-
variable:
|
|
1344
|
+
variable: o,
|
|
1183
1345
|
selector: f,
|
|
1184
1346
|
utility: i,
|
|
1185
1347
|
modifier: c,
|
|
1186
|
-
recipe:
|
|
1187
|
-
theme:
|
|
1348
|
+
recipe: s,
|
|
1349
|
+
theme: a,
|
|
1188
1350
|
atRule: l,
|
|
1189
|
-
keyframes:
|
|
1351
|
+
keyframes: u,
|
|
1190
1352
|
media: y,
|
|
1191
|
-
ref:
|
|
1353
|
+
ref: p,
|
|
1192
1354
|
css: d2,
|
|
1193
1355
|
options: t
|
|
1194
1356
|
};
|
|
1195
1357
|
}
|
|
1358
|
+
function createLoader(basePath, alias) {
|
|
1359
|
+
return createJiti(basePath, {
|
|
1360
|
+
fsCache: false,
|
|
1361
|
+
moduleCache: false,
|
|
1362
|
+
alias
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
function trackExports(module) {
|
|
1366
|
+
const exports = /* @__PURE__ */ new Map();
|
|
1367
|
+
for (const [name, value] of Object.entries(module)) {
|
|
1368
|
+
if (name === "default") continue;
|
|
1369
|
+
let type = null;
|
|
1370
|
+
if (ke(value)) {
|
|
1371
|
+
type = "recipe";
|
|
1372
|
+
value._exportName = name;
|
|
1373
|
+
} else if (Ae(value)) {
|
|
1374
|
+
type = "selector";
|
|
1375
|
+
value._exportName = name;
|
|
1376
|
+
}
|
|
1377
|
+
if (type) {
|
|
1378
|
+
exports.set(name, { name, type });
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return exports;
|
|
1382
|
+
}
|
|
1383
|
+
async function loadModule(filePath, options = {}) {
|
|
1384
|
+
const { alias, validateInstance = true } = options;
|
|
1385
|
+
const jiti = createLoader(path.dirname(filePath), alias);
|
|
1386
|
+
const module = await jiti.import(filePath);
|
|
1387
|
+
if (!module.default) {
|
|
1388
|
+
throw new Error(
|
|
1389
|
+
`Missing default export in ${filePath}. Expected a Styleframe instance.`
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
if (validateInstance && !Ve(module.default)) {
|
|
1393
|
+
throw new Error(
|
|
1394
|
+
`Invalid default export in ${filePath}. Expected a Styleframe instance created with styleframe().`
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
const exports = trackExports(module);
|
|
1398
|
+
return {
|
|
1399
|
+
module,
|
|
1400
|
+
instance: module.default,
|
|
1401
|
+
exports
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
async function loadExtensionModule(filePath, options = {}) {
|
|
1405
|
+
const { alias } = options;
|
|
1406
|
+
const jiti = createLoader(path.dirname(filePath), alias);
|
|
1407
|
+
const module = await jiti.import(filePath);
|
|
1408
|
+
const exports = trackExports(module);
|
|
1409
|
+
return { module, exports };
|
|
1410
|
+
}
|
|
1196
1411
|
const SUPPORTED_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
|
|
1197
1412
|
function hasKnownExtension(filePath) {
|
|
1198
1413
|
return SUPPORTED_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
@@ -1210,33 +1425,16 @@ function resolveConfigFile(cwd, entry) {
|
|
|
1210
1425
|
}
|
|
1211
1426
|
return void 0;
|
|
1212
1427
|
}
|
|
1213
|
-
function trackNamedExports(module) {
|
|
1214
|
-
for (const [exportName, exportValue] of Object.entries(module)) {
|
|
1215
|
-
if (exportName === "default") continue;
|
|
1216
|
-
if (Ae(exportValue)) {
|
|
1217
|
-
exportValue._exportName = exportName;
|
|
1218
|
-
} else if (be(exportValue)) {
|
|
1219
|
-
exportValue._exportName = exportName;
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
1428
|
async function loadConfiguration({
|
|
1224
1429
|
cwd = process.cwd(),
|
|
1225
1430
|
entry = "styleframe.config"
|
|
1226
1431
|
} = {}) {
|
|
1227
1432
|
const resolvedPath = resolveConfigFile(cwd, entry);
|
|
1228
1433
|
if (!resolvedPath) {
|
|
1229
|
-
return
|
|
1230
|
-
}
|
|
1231
|
-
const jiti = createJiti(path.dirname(resolvedPath), { cache: false });
|
|
1232
|
-
const module = await jiti.import(resolvedPath);
|
|
1233
|
-
if (!module.default) {
|
|
1234
|
-
throw new Error(
|
|
1235
|
-
`Missing default export in ${resolvedPath}. Expected a Styleframe instance.`
|
|
1236
|
-
);
|
|
1434
|
+
return Fe();
|
|
1237
1435
|
}
|
|
1238
|
-
|
|
1239
|
-
return
|
|
1436
|
+
const { instance } = await loadModule(resolvedPath);
|
|
1437
|
+
return instance;
|
|
1240
1438
|
}
|
|
1241
1439
|
async function watchConfiguration({
|
|
1242
1440
|
cwd = process.cwd(),
|
|
@@ -1268,7 +1466,11 @@ async function watchConfiguration({
|
|
|
1268
1466
|
}
|
|
1269
1467
|
export {
|
|
1270
1468
|
build,
|
|
1469
|
+
createLoader,
|
|
1271
1470
|
directoryExists,
|
|
1272
1471
|
loadConfiguration,
|
|
1472
|
+
loadExtensionModule,
|
|
1473
|
+
loadModule,
|
|
1474
|
+
trackExports,
|
|
1273
1475
|
watchConfiguration
|
|
1274
1476
|
};
|