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