@styleframe/loader 3.0.0 → 3.0.1
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 +13 -0
- package/dist/index.cjs +1 -1474
- package/dist/index.d.ts +41 -0
- package/dist/index.js +124 -1447
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -1,1476 +1,153 @@
|
|
|
1
|
-
import { stat, rm, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
modifiers: r
|
|
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
|
-
return `@${e}${t ? " " : ""}${t}`;
|
|
14
|
-
}
|
|
15
|
-
const K$1 = /\d/, q = ["-", "_", "/", "."];
|
|
16
|
-
function z$1(e = "") {
|
|
17
|
-
if (!K$1.test(e))
|
|
18
|
-
return e !== e.toLowerCase();
|
|
19
|
-
}
|
|
20
|
-
function _$1(e, t) {
|
|
21
|
-
const r = q, o = [];
|
|
22
|
-
if (!e || typeof e != "string")
|
|
23
|
-
return o;
|
|
24
|
-
let n = "", s, u;
|
|
25
|
-
for (const a of e) {
|
|
26
|
-
const c = r.includes(a);
|
|
27
|
-
if (c === true) {
|
|
28
|
-
o.push(n), n = "", s = void 0;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const i = z$1(a);
|
|
32
|
-
if (u === false) {
|
|
33
|
-
if (s === false && i === true) {
|
|
34
|
-
o.push(n), n = a, s = i;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
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
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
n += a, s = i, u = c;
|
|
44
|
-
}
|
|
45
|
-
return o.push(n), o;
|
|
46
|
-
}
|
|
47
|
-
function H(e) {
|
|
48
|
-
return e ? e[0].toUpperCase() + e.slice(1) : "";
|
|
49
|
-
}
|
|
50
|
-
function Q$1(e) {
|
|
51
|
-
return e ? e[0].toLowerCase() + e.slice(1) : "";
|
|
52
|
-
}
|
|
53
|
-
function J$1(e, t) {
|
|
54
|
-
return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => H(r)).join("") : "";
|
|
55
|
-
}
|
|
56
|
-
function Z$1(e, t) {
|
|
57
|
-
return Q$1(J$1(e || ""));
|
|
58
|
-
}
|
|
59
|
-
function W(e, t) {
|
|
60
|
-
return e ? (Array.isArray(e) ? e : _$1(e)).map((r) => r.toLowerCase()).join("-") : "";
|
|
61
|
-
}
|
|
62
|
-
function G$1(e) {
|
|
63
|
-
return ` ${e}`;
|
|
64
|
-
}
|
|
65
|
-
function Y$1(e) {
|
|
66
|
-
return e.split(`
|
|
67
|
-
`).map((t) => G$1(t)).join(`
|
|
68
|
-
`);
|
|
69
|
-
}
|
|
70
|
-
function x$1(e) {
|
|
71
|
-
return e === e.toUpperCase();
|
|
72
|
-
}
|
|
73
|
-
function T$1(e) {
|
|
74
|
-
return Z$1(e);
|
|
75
|
-
}
|
|
76
|
-
function X$1(e) {
|
|
77
|
-
return W(e);
|
|
78
|
-
}
|
|
79
|
-
function ee$1(e) {
|
|
80
|
-
return X$1(e);
|
|
81
|
-
}
|
|
82
|
-
function B(e, t) {
|
|
83
|
-
return `${e.startsWith("--") ? e : ee$1(e)}: ${t};`;
|
|
84
|
-
}
|
|
85
|
-
function te$1(e) {
|
|
86
|
-
return `{${e.length > 0 ? `
|
|
87
|
-
` : ""}${e.map((t) => `${Y$1(`${t}`)}
|
|
88
|
-
`).join("")}}`;
|
|
89
|
-
}
|
|
90
|
-
function E$1(e) {
|
|
91
|
-
return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
|
|
92
|
-
}
|
|
93
|
-
function re$1(e, t) {
|
|
94
|
-
return B(E$1(e), t);
|
|
95
|
-
}
|
|
96
|
-
function ne$1(e, t) {
|
|
97
|
-
return `var(${E$1(e)}${t ? `, ${t}` : ""})`;
|
|
98
|
-
}
|
|
99
|
-
function w(e, t) {
|
|
100
|
-
return `${e} ${te$1(t)}`;
|
|
101
|
-
}
|
|
102
|
-
function oe(e) {
|
|
103
|
-
return function(r, o) {
|
|
104
|
-
return Object.entries(r).map(([n, s]) => B(n, e(s, o)));
|
|
105
|
-
};
|
|
106
|
-
}
|
|
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
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function S$1(e) {
|
|
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
|
-
), m = r(
|
|
119
|
-
c ?? {},
|
|
120
|
-
u
|
|
121
|
-
), y = (i ?? []).map(
|
|
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
|
-
...l,
|
|
126
|
-
...p && b ? [""] : [],
|
|
127
|
-
...m
|
|
128
|
-
]) : ""}${j2 && (p || b) ? `
|
|
129
|
-
|
|
130
|
-
` : ""}${y.join(`
|
|
131
|
-
|
|
132
|
-
`)}` : w(n, [
|
|
133
|
-
...l,
|
|
134
|
-
...p && (j2 || b) ? [""] : [],
|
|
135
|
-
...m,
|
|
136
|
-
...b && j2 ? [""] : [],
|
|
137
|
-
...y.flatMap(
|
|
138
|
-
(g, I2) => I2 === y.length - 1 ? [g] : [g, ""]
|
|
139
|
-
)
|
|
140
|
-
]);
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function ce(e) {
|
|
144
|
-
const t = S$1(e);
|
|
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
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function ue$1(e) {
|
|
153
|
-
return function(r, o) {
|
|
154
|
-
return r.value.map((n) => e(n, o)).join("").trim();
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function se$1(e) {
|
|
158
|
-
return typeof e == "object" && e !== null;
|
|
159
|
-
}
|
|
160
|
-
function h$1(e, t) {
|
|
161
|
-
return se$1(e) && "type" in e && e.type === t;
|
|
162
|
-
}
|
|
163
|
-
function ie$1(e) {
|
|
164
|
-
return h$1(e, "variable");
|
|
165
|
-
}
|
|
166
|
-
function ae$1(e) {
|
|
167
|
-
return h$1(e, "reference");
|
|
168
|
-
}
|
|
169
|
-
function C$1(e) {
|
|
170
|
-
return h$1(e, "selector");
|
|
171
|
-
}
|
|
172
|
-
function le$1(e) {
|
|
173
|
-
return h$1(e, "at-rule");
|
|
174
|
-
}
|
|
175
|
-
function fe(e) {
|
|
176
|
-
return h$1(e, "utility");
|
|
177
|
-
}
|
|
178
|
-
function me$1(e) {
|
|
179
|
-
return h$1(e, "css");
|
|
180
|
-
}
|
|
181
|
-
function pe$1(e) {
|
|
182
|
-
return h$1(e, "theme");
|
|
183
|
-
}
|
|
184
|
-
function N(e) {
|
|
185
|
-
return h$1(e, "root");
|
|
186
|
-
}
|
|
187
|
-
function D$1(e) {
|
|
188
|
-
return h$1(e, "recipe");
|
|
189
|
-
}
|
|
190
|
-
function L$1(e) {
|
|
191
|
-
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
192
|
-
}
|
|
193
|
-
function A$1(e) {
|
|
194
|
-
if (e instanceof Buffer)
|
|
195
|
-
return Buffer.from(e);
|
|
196
|
-
const t = e.constructor;
|
|
197
|
-
return new t(
|
|
198
|
-
e.buffer.slice(0),
|
|
199
|
-
e.byteOffset,
|
|
200
|
-
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
function ye$1(e) {
|
|
204
|
-
if (e = e || {}, e.circular)
|
|
205
|
-
return de$1(e);
|
|
206
|
-
const t = /* @__PURE__ */ new Map();
|
|
207
|
-
if (t.set(Date, (u) => new Date(u)), t.set(
|
|
208
|
-
Map,
|
|
209
|
-
(u, a) => new Map(o(Array.from(u), a))
|
|
210
|
-
), t.set(
|
|
211
|
-
Set,
|
|
212
|
-
(u, a) => new Set(o(Array.from(u), a))
|
|
213
|
-
), e.constructorHandlers)
|
|
214
|
-
for (const u of e.constructorHandlers)
|
|
215
|
-
t.set(u[0], u[1]);
|
|
216
|
-
let r;
|
|
217
|
-
return e.proto ? s : n;
|
|
218
|
-
function o(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] = A$1(m) : i[l] = a(m);
|
|
223
|
-
}
|
|
224
|
-
return i;
|
|
225
|
-
}
|
|
226
|
-
function n(u) {
|
|
227
|
-
if (typeof u != "object" || u === null) return u;
|
|
228
|
-
if (Array.isArray(u)) return o(u, n);
|
|
229
|
-
if (u.constructor !== Object && (r = t.get(u.constructor)))
|
|
230
|
-
return r(u, n);
|
|
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, n) : ArrayBuffer.isView(i) ? a[c] = A$1(i) : a[c] = n(i);
|
|
236
|
-
}
|
|
237
|
-
return a;
|
|
238
|
-
}
|
|
239
|
-
function s(u) {
|
|
240
|
-
if (typeof u != "object" || u === null) return u;
|
|
241
|
-
if (Array.isArray(u)) return o(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] = A$1(i) : a[c] = s(i);
|
|
248
|
-
}
|
|
249
|
-
return a;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
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
|
-
Map,
|
|
256
|
-
(c, i) => new Map(s(Array.from(c), i))
|
|
257
|
-
), o.set(
|
|
258
|
-
Set,
|
|
259
|
-
(c, i) => new Set(s(Array.from(c), i))
|
|
260
|
-
), e.constructorHandlers)
|
|
261
|
-
for (const c of e.constructorHandlers)
|
|
262
|
-
o.set(c[0], c[1]);
|
|
263
|
-
let n;
|
|
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], 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
|
-
else {
|
|
276
|
-
const b = t.indexOf(p);
|
|
277
|
-
b !== -1 ? l[y] = r[b] : l[y] = i(p);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return l;
|
|
281
|
-
}
|
|
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 && (n = o.get(c.constructor)))
|
|
286
|
-
return n(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];
|
|
292
|
-
if (typeof l != "object" || l === null)
|
|
293
|
-
i[f] = l;
|
|
294
|
-
else if (l.constructor !== Object && (n = o.get(l.constructor)))
|
|
295
|
-
i[f] = n(l, u);
|
|
296
|
-
else if (ArrayBuffer.isView(l))
|
|
297
|
-
i[f] = A$1(l);
|
|
298
|
-
else {
|
|
299
|
-
const m = t.indexOf(l);
|
|
300
|
-
m !== -1 ? i[f] = r[m] : i[f] = u(l);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return t.pop(), r.pop(), i;
|
|
304
|
-
}
|
|
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 && (n = o.get(c.constructor)))
|
|
309
|
-
return n(c, a);
|
|
310
|
-
const i = {};
|
|
311
|
-
t.push(c), r.push(i);
|
|
312
|
-
for (const f in c) {
|
|
313
|
-
const l = c[f];
|
|
314
|
-
if (typeof l != "object" || l === null)
|
|
315
|
-
i[f] = l;
|
|
316
|
-
else if (l.constructor !== Object && (n = o.get(l.constructor)))
|
|
317
|
-
i[f] = n(l, a);
|
|
318
|
-
else if (ArrayBuffer.isView(l))
|
|
319
|
-
i[f] = A$1(l);
|
|
320
|
-
else {
|
|
321
|
-
const m = t.indexOf(l);
|
|
322
|
-
m !== -1 ? i[f] = r[m] : i[f] = a(l);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return t.pop(), r.pop(), i;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
ye$1();
|
|
329
|
-
function he$1(e) {
|
|
330
|
-
return function(r, o) {
|
|
331
|
-
return r != null ? `${r}` : "";
|
|
332
|
-
};
|
|
333
|
-
}
|
|
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
|
-
s,
|
|
339
|
-
r.fallback ? e(r.fallback, o) : void 0
|
|
340
|
-
);
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function ge$1(e) {
|
|
344
|
-
const t = S$1(e);
|
|
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
|
-
// Default theme (root)
|
|
350
|
-
).join(`
|
|
351
|
-
|
|
352
|
-
`);
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function Ae$1(e) {
|
|
356
|
-
const t = S$1(e);
|
|
357
|
-
return function(o, n) {
|
|
358
|
-
return t(o.query, o, n);
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
function Se(e) {
|
|
362
|
-
const t = S$1(e);
|
|
363
|
-
return function(o, n) {
|
|
364
|
-
const u = (n.themes?.selector ?? k)({ name: o.name });
|
|
365
|
-
return t(u, o, n);
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
function Ce(e) {
|
|
369
|
-
const t = S$1(e);
|
|
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
|
-
});
|
|
376
|
-
return s.push(t(a, o, n)), s.join(`
|
|
377
|
-
|
|
378
|
-
`);
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function d(e, t) {
|
|
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
|
-
switch (true) {
|
|
384
|
-
case C$1(e):
|
|
385
|
-
return o(e, t);
|
|
386
|
-
case fe(e):
|
|
387
|
-
return n(e, t);
|
|
388
|
-
case le$1(e):
|
|
389
|
-
return s(e, t);
|
|
390
|
-
case N(e):
|
|
391
|
-
return r(e, t);
|
|
392
|
-
case pe$1(e):
|
|
393
|
-
return u(e, t);
|
|
394
|
-
case ie$1(e):
|
|
395
|
-
return a(e, t);
|
|
396
|
-
case ae$1(e):
|
|
397
|
-
return c(e, t);
|
|
398
|
-
case me$1(e):
|
|
399
|
-
return i(e, t);
|
|
400
|
-
default:
|
|
401
|
-
return f(e, t);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
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
|
-
return `const ${s} = ${JSON.stringify(
|
|
410
|
-
u,
|
|
411
|
-
null,
|
|
412
|
-
4
|
|
413
|
-
)} as const satisfies RecipeRuntime;
|
|
414
|
-
|
|
415
|
-
export const ${n} = createRecipe("${r.name}", ${s});
|
|
416
|
-
`;
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function ve(e) {
|
|
420
|
-
return e.filter(
|
|
421
|
-
(t) => C$1(t) && !!t._exportName
|
|
422
|
-
);
|
|
423
|
-
}
|
|
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
|
-
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, o))), u && a.push(e(n, o)), a.join(`
|
|
433
|
-
`);
|
|
434
|
-
};
|
|
435
|
-
}
|
|
436
|
-
function $e(e) {
|
|
437
|
-
return function(r, o) {
|
|
438
|
-
return r._exportName ? `export const ${r._exportName} = ${JSON.stringify(r.query)};
|
|
439
|
-
` : "";
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function R$1(e, t) {
|
|
443
|
-
const r = Re(R$1), o = je(), n = $e();
|
|
444
|
-
switch (true) {
|
|
445
|
-
case Array.isArray(e):
|
|
446
|
-
return e.map((s) => R$1(s, t)).join(`
|
|
447
|
-
`);
|
|
448
|
-
case N(e):
|
|
449
|
-
return r(e, t);
|
|
450
|
-
case D$1(e):
|
|
451
|
-
return o(e, t);
|
|
452
|
-
case C$1(e):
|
|
453
|
-
return n(e, t);
|
|
454
|
-
default:
|
|
455
|
-
return "";
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
const Ne = `-----BEGIN PUBLIC KEY-----
|
|
459
|
-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
|
|
460
|
-
qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
|
|
461
|
-
BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
|
|
462
|
-
dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
463
|
-
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
464
|
-
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
465
|
-
GwIDAQAB
|
|
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
|
-
return await crypto.subtle.importKey(
|
|
470
|
-
"spki",
|
|
471
|
-
r,
|
|
472
|
-
{
|
|
473
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
474
|
-
hash: "SHA-256"
|
|
475
|
-
},
|
|
476
|
-
true,
|
|
477
|
-
["verify"]
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
async function xe({
|
|
481
|
-
payload: e,
|
|
482
|
-
signature: t
|
|
483
|
-
}) {
|
|
484
|
-
const r = new TextEncoder().encode(e), o = Uint8Array.from(
|
|
485
|
-
atob(t),
|
|
486
|
-
(s) => s.charCodeAt(0)
|
|
487
|
-
), n = await _e(Ne);
|
|
488
|
-
if (!await crypto.subtle.verify(
|
|
489
|
-
{ name: "RSASSA-PKCS1-v1_5" },
|
|
490
|
-
n,
|
|
491
|
-
o,
|
|
492
|
-
r
|
|
493
|
-
))
|
|
494
|
-
throw new Error(
|
|
495
|
-
"License validation failed: Invalid signature detected. The license may have been modified or corrupted."
|
|
496
|
-
);
|
|
497
|
-
return JSON.parse(e);
|
|
498
|
-
}
|
|
499
|
-
function Te(e) {
|
|
500
|
-
return Object.prototype.hasOwnProperty.call(e, we);
|
|
501
|
-
}
|
|
502
|
-
async function Be(e) {
|
|
503
|
-
const t = Object.getOwnPropertyDescriptor(
|
|
504
|
-
e,
|
|
505
|
-
Oe
|
|
506
|
-
);
|
|
507
|
-
if (!t?.value)
|
|
508
|
-
return {
|
|
509
|
-
key: "",
|
|
510
|
-
instanceId: "",
|
|
511
|
-
environment: "",
|
|
512
|
-
valid: false
|
|
513
|
-
};
|
|
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")
|
|
516
|
-
return {
|
|
517
|
-
key: "",
|
|
518
|
-
instanceId: "",
|
|
519
|
-
environment: "",
|
|
520
|
-
valid: false
|
|
521
|
-
};
|
|
1
|
+
import { stat as E, rm as x, mkdir as j, writeFile as v } from "node:fs/promises";
|
|
2
|
+
import s from "node:path";
|
|
3
|
+
import { transpile as g } from "@styleframe/transpiler";
|
|
4
|
+
import { validateInstanceLicense as C, getLicenseKeyFromEnv as S } from "@styleframe/license";
|
|
5
|
+
import { isRecipe as b, isSelector as O, isStyleframe as $, styleframe as D } from "@styleframe/core";
|
|
6
|
+
import { watch as J } from "chokidar";
|
|
7
|
+
import { existsSync as l } from "node:fs";
|
|
8
|
+
import { createJiti as m } from "jiti";
|
|
9
|
+
async function u(i) {
|
|
522
10
|
try {
|
|
523
|
-
return await
|
|
524
|
-
r
|
|
525
|
-
);
|
|
11
|
+
return (await E(i)).isDirectory();
|
|
526
12
|
} catch {
|
|
527
|
-
return
|
|
528
|
-
key: "",
|
|
529
|
-
instanceId: "",
|
|
530
|
-
environment: "",
|
|
531
|
-
valid: false
|
|
532
|
-
};
|
|
13
|
+
return !1;
|
|
533
14
|
}
|
|
534
15
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
|
|
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) {
|
|
610
|
-
const t = Math.floor(Math.random() * 100);
|
|
611
|
-
e.root.children.push({
|
|
612
|
-
type: "selector",
|
|
613
|
-
query: `html:nth-of-type(${t}n+1)::after`,
|
|
614
|
-
variables: [],
|
|
615
|
-
children: [],
|
|
616
|
-
declarations: {
|
|
617
|
-
content: '"Styleframe Pro: Development Mode – License required for production use"',
|
|
618
|
-
zIndex: 99999,
|
|
619
|
-
position: "fixed",
|
|
620
|
-
display: "block !important",
|
|
621
|
-
opacity: "1 !important",
|
|
622
|
-
bottom: 0,
|
|
623
|
-
left: 0,
|
|
624
|
-
background: "rgba(0, 0, 0, 0.5)",
|
|
625
|
-
color: "white",
|
|
626
|
-
fontSize: "12px",
|
|
627
|
-
lineHeight: "1",
|
|
628
|
-
padding: "0.5rem",
|
|
629
|
-
fontFamily: "sans-serif"
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
function v$1(e, t = "") {
|
|
634
|
-
return {
|
|
635
|
-
name: e,
|
|
636
|
-
content: t
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
async function ke$1(e, {
|
|
640
|
-
type: t = "all",
|
|
641
|
-
consumers: r = { css: d, ts: R$1, dts: $ }
|
|
642
|
-
} = {}) {
|
|
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);
|
|
647
|
-
}
|
|
648
|
-
if (t === "all" || t === "css") {
|
|
649
|
-
const s = v$1(
|
|
650
|
-
"index.css",
|
|
651
|
-
r.css(e.root, n)
|
|
652
|
-
);
|
|
653
|
-
o.files.push(s);
|
|
654
|
-
}
|
|
655
|
-
if (t === "all" || t === "ts") {
|
|
656
|
-
const s = v$1(
|
|
657
|
-
"index.ts",
|
|
658
|
-
r.ts(e.root, n)
|
|
659
|
-
);
|
|
660
|
-
o.files.push(s);
|
|
661
|
-
}
|
|
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;
|
|
670
|
-
}
|
|
671
|
-
async function directoryExists(path2) {
|
|
672
|
-
try {
|
|
673
|
-
const stats = await stat(path2);
|
|
674
|
-
return stats.isDirectory();
|
|
675
|
-
} catch {
|
|
676
|
-
return false;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
async function build(instance, { clean = true, outputDir = "./styleframe", transpiler } = {}) {
|
|
680
|
-
await validateInstanceLicense(instance, {
|
|
681
|
-
licenseKey: getLicenseKeyFromEnv() || "",
|
|
16
|
+
async function T(i, { clean: t = !0, outputDir: e = "./styleframe", transpiler: o } = {}) {
|
|
17
|
+
await C(i, {
|
|
18
|
+
licenseKey: S() || "",
|
|
682
19
|
environment: process.env.NODE_ENV || "development",
|
|
683
|
-
isBuild:
|
|
20
|
+
isBuild: !0
|
|
684
21
|
});
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
await writeFile(filePath, file.content);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
function C(e) {
|
|
701
|
-
return typeof e == "object" && e !== null;
|
|
702
|
-
}
|
|
703
|
-
function h(e, r) {
|
|
704
|
-
return C(e) && "type" in e && e.type === r;
|
|
705
|
-
}
|
|
706
|
-
function G(e) {
|
|
707
|
-
return h(e, "variable");
|
|
708
|
-
}
|
|
709
|
-
function j(e) {
|
|
710
|
-
return h(e, "reference");
|
|
711
|
-
}
|
|
712
|
-
function Ae(e) {
|
|
713
|
-
return h(e, "selector");
|
|
714
|
-
}
|
|
715
|
-
function I(e) {
|
|
716
|
-
return h(e, "modifier");
|
|
717
|
-
}
|
|
718
|
-
function T(e) {
|
|
719
|
-
return h(e, "css");
|
|
720
|
-
}
|
|
721
|
-
function V(e) {
|
|
722
|
-
return h(e, "root");
|
|
723
|
-
}
|
|
724
|
-
function ke(e) {
|
|
725
|
-
return h(e, "recipe");
|
|
726
|
-
}
|
|
727
|
-
function z(e) {
|
|
728
|
-
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
729
|
-
}
|
|
730
|
-
function D(e) {
|
|
731
|
-
return z(e) || j(e) || T(e) || Array.isArray(e) && e.every(D);
|
|
732
|
-
}
|
|
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 = {
|
|
749
|
-
type: "reference",
|
|
750
|
-
name: l
|
|
751
|
-
};
|
|
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}]`;
|
|
762
|
-
return {
|
|
763
|
-
[a]: s
|
|
764
|
-
};
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
function Z(e, r) {
|
|
768
|
-
return function(t, ...i) {
|
|
769
|
-
return {
|
|
770
|
-
type: "css",
|
|
771
|
-
value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
|
|
772
|
-
};
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
function K(e, r) {
|
|
776
|
-
return function(t, i, c) {
|
|
777
|
-
const s = {
|
|
778
|
-
type: "at-rule",
|
|
779
|
-
identifier: t,
|
|
780
|
-
rule: i,
|
|
781
|
-
declarations: {},
|
|
782
|
-
variables: [],
|
|
783
|
-
children: []
|
|
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;
|
|
786
|
-
};
|
|
787
|
-
}
|
|
788
|
-
function J(e, r) {
|
|
789
|
-
const n = K(e, r);
|
|
790
|
-
return function(i, c) {
|
|
791
|
-
return n("media", i, c);
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
function Q(e, r) {
|
|
795
|
-
const n = K(e, r);
|
|
796
|
-
return function(i, c) {
|
|
797
|
-
return n("keyframes", i, c);
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
function X(e, r) {
|
|
801
|
-
return function(t, i) {
|
|
802
|
-
return G(t) ? {
|
|
803
|
-
type: "reference",
|
|
804
|
-
name: t.name,
|
|
805
|
-
fallback: i
|
|
806
|
-
} : {
|
|
807
|
-
type: "reference",
|
|
808
|
-
name: t,
|
|
809
|
-
fallback: i
|
|
810
|
-
};
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
function ee(e, r) {
|
|
814
|
-
return function(t, i) {
|
|
815
|
-
const c = {
|
|
816
|
-
type: "selector",
|
|
817
|
-
query: t,
|
|
818
|
-
declarations: {},
|
|
819
|
-
variables: [],
|
|
820
|
-
children: []
|
|
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;
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
function te(e, r) {
|
|
826
|
-
return function(t, i, c = {
|
|
827
|
-
default: false
|
|
828
|
-
}) {
|
|
829
|
-
const s = typeof t == "string" ? t : t.name, a = e.variables.find(
|
|
830
|
-
(f) => f.name === s
|
|
831
|
-
);
|
|
832
|
-
if (c.default && a)
|
|
833
|
-
return a;
|
|
834
|
-
if (a)
|
|
835
|
-
return a.value = i, a;
|
|
836
|
-
const o = {
|
|
837
|
-
type: "variable",
|
|
838
|
-
name: s,
|
|
839
|
-
value: i
|
|
840
|
-
};
|
|
841
|
-
return e.variables.push(o), o;
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
function v(e, r) {
|
|
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();
|
|
846
|
-
return {
|
|
847
|
-
variable: n,
|
|
848
|
-
selector: t,
|
|
849
|
-
keyframes: c,
|
|
850
|
-
atRule: i,
|
|
851
|
-
media: s,
|
|
852
|
-
ref: a,
|
|
853
|
-
css: o
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
function R(e, r) {
|
|
857
|
-
for (const n in e)
|
|
858
|
-
if (n.startsWith("@")) {
|
|
859
|
-
const t = e[n];
|
|
860
|
-
if (typeof t == "object" && t !== null && !D(t)) {
|
|
861
|
-
const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
|
|
862
|
-
r.atRule(i, c, t), delete e[n];
|
|
863
|
-
}
|
|
864
|
-
} else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
|
|
865
|
-
const t = e[n];
|
|
866
|
-
typeof t == "object" && (r.selector(n, t), delete e[n]);
|
|
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
|
-
}
|
|
872
|
-
return e;
|
|
873
|
-
}
|
|
874
|
-
function A(e) {
|
|
875
|
-
if (e instanceof Buffer)
|
|
876
|
-
return Buffer.from(e);
|
|
877
|
-
const r = e.constructor;
|
|
878
|
-
return new r(
|
|
879
|
-
e.buffer.slice(0),
|
|
880
|
-
e.byteOffset,
|
|
881
|
-
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
function ne(e) {
|
|
885
|
-
if (e = e || {}, e.circular)
|
|
886
|
-
return re(e);
|
|
887
|
-
const r = /* @__PURE__ */ new Map();
|
|
888
|
-
if (r.set(Date, (s) => new Date(s)), r.set(
|
|
889
|
-
Map,
|
|
890
|
-
(s, a) => new Map(t(Array.from(s), a))
|
|
891
|
-
), r.set(
|
|
892
|
-
Set,
|
|
893
|
-
(s, a) => new Set(t(Array.from(s), a))
|
|
894
|
-
), e.constructorHandlers)
|
|
895
|
-
for (const s of e.constructorHandlers)
|
|
896
|
-
r.set(s[0], s[1]);
|
|
897
|
-
let n;
|
|
898
|
-
return e.proto ? c : i;
|
|
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);
|
|
904
|
-
}
|
|
905
|
-
return f;
|
|
906
|
-
}
|
|
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);
|
|
917
|
-
}
|
|
918
|
-
return a;
|
|
919
|
-
}
|
|
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);
|
|
929
|
-
}
|
|
930
|
-
return a;
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
function re(e) {
|
|
934
|
-
const r = [], n = [], t = /* @__PURE__ */ new Map();
|
|
935
|
-
if (t.set(Date, (o) => new Date(o)), t.set(
|
|
936
|
-
Map,
|
|
937
|
-
(o, f) => new Map(c(Array.from(o), f))
|
|
938
|
-
), t.set(
|
|
939
|
-
Set,
|
|
940
|
-
(o, f) => new Set(c(Array.from(o), f))
|
|
941
|
-
), e.constructorHandlers)
|
|
942
|
-
for (const o of e.constructorHandlers)
|
|
943
|
-
t.set(o[0], o[1]);
|
|
944
|
-
let i;
|
|
945
|
-
return e.proto ? a : s;
|
|
946
|
-
function c(o, f) {
|
|
947
|
-
const l = Object.keys(o), u = Array.from({ length: l.length });
|
|
948
|
-
for (let y = 0; y < l.length; y++) {
|
|
949
|
-
const p = l[y], d2 = o[p];
|
|
950
|
-
if (typeof d2 != "object" || d2 === null)
|
|
951
|
-
u[p] = d2;
|
|
952
|
-
else if (d2.constructor !== Object && (i = t.get(d2.constructor)))
|
|
953
|
-
u[p] = i(d2, f);
|
|
954
|
-
else if (ArrayBuffer.isView(d2))
|
|
955
|
-
u[p] = A(d2);
|
|
956
|
-
else {
|
|
957
|
-
const w2 = r.indexOf(d2);
|
|
958
|
-
w2 !== -1 ? u[p] = n[w2] : u[p] = f(d2);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
return u;
|
|
962
|
-
}
|
|
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);
|
|
968
|
-
const f = {};
|
|
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);
|
|
979
|
-
else {
|
|
980
|
-
const y = r.indexOf(u);
|
|
981
|
-
y !== -1 ? f[l] = n[y] : f[l] = s(u);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
return r.pop(), n.pop(), f;
|
|
985
|
-
}
|
|
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);
|
|
991
|
-
const f = {};
|
|
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);
|
|
1001
|
-
else {
|
|
1002
|
-
const y = r.indexOf(u);
|
|
1003
|
-
y !== -1 ? f[l] = n[y] : f[l] = a(u);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
return r.pop(), n.pop(), f;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
const F = ne();
|
|
1010
|
-
function ie(e, r = 8) {
|
|
1011
|
-
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1012
|
-
let t = "";
|
|
1013
|
-
for (let i = 0; i < r; i++) {
|
|
1014
|
-
const c = Math.floor(Math.random() * n.length);
|
|
1015
|
-
t += n[c];
|
|
1016
|
-
}
|
|
1017
|
-
return e ? `${e}${t}` : t;
|
|
1018
|
-
}
|
|
1019
|
-
function se(e, r) {
|
|
1020
|
-
const n = e.modifiers.find(
|
|
1021
|
-
(t) => t.key.includes(r)
|
|
1022
|
-
);
|
|
1023
|
-
if (!n)
|
|
1024
|
-
throw new Error(`Modifier "${r}" not found`);
|
|
1025
|
-
return n;
|
|
1026
|
-
}
|
|
1027
|
-
function ae(e) {
|
|
1028
|
-
const r = [];
|
|
1029
|
-
function n(t, i) {
|
|
1030
|
-
i.length > 0 && r.push([...i].sort());
|
|
1031
|
-
for (let c = t; c < e.length; c++) {
|
|
1032
|
-
const s = e[c];
|
|
1033
|
-
if (s)
|
|
1034
|
-
if (s.length === 1 && s[0])
|
|
1035
|
-
n(c + 1, [...i, s[0]]);
|
|
1036
|
-
else
|
|
1037
|
-
for (const a of s)
|
|
1038
|
-
n(c + 1, [...i, a]);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
|
|
1042
|
-
}
|
|
1043
|
-
function ue(e, r, n) {
|
|
1044
|
-
const t = {
|
|
1045
|
-
...e,
|
|
1046
|
-
modifiers: [...n.keys()]
|
|
1047
|
-
}, i = v(t, r);
|
|
1048
|
-
for (const c of n.values())
|
|
1049
|
-
c.factory({
|
|
1050
|
-
...i,
|
|
1051
|
-
declarations: F(t.declarations),
|
|
1052
|
-
variables: F(t.variables),
|
|
1053
|
-
children: F(t.children)
|
|
1054
|
-
}), R(t.declarations, i);
|
|
1055
|
-
return t;
|
|
1056
|
-
}
|
|
1057
|
-
function le(e, r) {
|
|
1058
|
-
return function(t, i) {
|
|
1059
|
-
const c = {
|
|
1060
|
-
type: "modifier",
|
|
1061
|
-
key: Array.isArray(t) ? t : [t],
|
|
1062
|
-
factory: i
|
|
1063
|
-
};
|
|
1064
|
-
return r.modifiers.push(c), c;
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
function ye() {
|
|
1068
|
-
return {
|
|
1069
|
-
type: "root",
|
|
1070
|
-
declarations: {},
|
|
1071
|
-
utilities: [],
|
|
1072
|
-
modifiers: [],
|
|
1073
|
-
recipes: [],
|
|
1074
|
-
variables: [],
|
|
1075
|
-
children: [],
|
|
1076
|
-
themes: []
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
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) {
|
|
1112
|
-
return function(t, i, c = {}) {
|
|
1113
|
-
const s = {
|
|
1114
|
-
type: "utility",
|
|
1115
|
-
name: t,
|
|
1116
|
-
factory: i,
|
|
1117
|
-
values: [],
|
|
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)) {
|
|
1125
|
-
f = {};
|
|
1126
|
-
for (const l of a) {
|
|
1127
|
-
const u = s.autogenerate(l);
|
|
1128
|
-
f = {
|
|
1129
|
-
...f,
|
|
1130
|
-
...u
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
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 = {
|
|
1157
|
-
type: "utility",
|
|
1158
|
-
name: t,
|
|
1159
|
-
value: l,
|
|
1160
|
-
declarations: {},
|
|
1161
|
-
variables: [],
|
|
1162
|
-
children: [],
|
|
1163
|
-
modifiers: []
|
|
1164
|
-
}, w2 = v(
|
|
1165
|
-
d2,
|
|
1166
|
-
r
|
|
1167
|
-
);
|
|
1168
|
-
if (d2.declarations = i({
|
|
1169
|
-
...w2,
|
|
1170
|
-
value: y
|
|
1171
|
-
}) ?? {}, R(d2.declarations, w2), p || (s.values.push({
|
|
1172
|
-
key: l,
|
|
1173
|
-
value: y,
|
|
1174
|
-
modifiers: []
|
|
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)
|
|
1183
|
-
);
|
|
1184
|
-
M2 && I(M2) && k2.set(U2, M2);
|
|
1185
|
-
}
|
|
1186
|
-
return s.values.push({
|
|
1187
|
-
key: l,
|
|
1188
|
-
value: y,
|
|
1189
|
-
modifiers: b
|
|
1190
|
-
}), m.push(ue(d2, r, k2)), m;
|
|
1191
|
-
}, []);
|
|
1192
|
-
e.children.push(...O2);
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
};
|
|
1197
|
-
return r.utilities.push(s), s.create;
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
function pe(e, r) {
|
|
1201
|
-
return function(t, i) {
|
|
1202
|
-
const c = r.themes.find((o) => o.name === t), s = c ?? {
|
|
1203
|
-
type: "theme",
|
|
1204
|
-
name: t,
|
|
1205
|
-
declarations: {},
|
|
1206
|
-
variables: [],
|
|
1207
|
-
children: []
|
|
1208
|
-
};
|
|
1209
|
-
c || r.themes.push(s);
|
|
1210
|
-
const a = v(s, r);
|
|
1211
|
-
return i && i(a), s;
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
function he(e, r) {
|
|
1215
|
-
return function(t) {
|
|
1216
|
-
const i = {
|
|
1217
|
-
type: "recipe",
|
|
1218
|
-
...t
|
|
1219
|
-
};
|
|
1220
|
-
return i._runtime = ge(i, r), be(i, r), r.recipes.push(i), i;
|
|
1221
|
-
};
|
|
1222
|
-
}
|
|
1223
|
-
function _(e, r) {
|
|
1224
|
-
const n = e.autogenerate(r);
|
|
1225
|
-
return Object.keys(n)[0] ?? "default";
|
|
1226
|
-
}
|
|
1227
|
-
function x(e, r) {
|
|
1228
|
-
const n = {};
|
|
1229
|
-
for (const [t, i] of Object.entries(e))
|
|
1230
|
-
if (L(i)) {
|
|
1231
|
-
const c = {};
|
|
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
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
n[t] = c;
|
|
1242
|
-
} else if (typeof i == "boolean")
|
|
1243
|
-
n[t] = i;
|
|
1244
|
-
else {
|
|
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
|
-
);
|
|
1249
|
-
}
|
|
1250
|
-
return n;
|
|
1251
|
-
}
|
|
1252
|
-
function ge(e, r) {
|
|
1253
|
-
const n = {};
|
|
1254
|
-
if (e.base && (n.base = x(e.base, r)), e.variants) {
|
|
1255
|
-
const t = {};
|
|
1256
|
-
for (const [i, c] of Object.entries(e.variants)) {
|
|
1257
|
-
const s = {};
|
|
1258
|
-
for (const [a, o] of Object.entries(
|
|
1259
|
-
c
|
|
1260
|
-
))
|
|
1261
|
-
o == null ? s[a] = null : s[a] = x(
|
|
1262
|
-
o,
|
|
1263
|
-
r
|
|
1264
|
-
);
|
|
1265
|
-
t[i] = s;
|
|
1266
|
-
}
|
|
1267
|
-
n.variants = t;
|
|
1268
|
-
}
|
|
1269
|
-
return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
|
|
1270
|
-
match: { ...t.match },
|
|
1271
|
-
css: x(t.css, r)
|
|
1272
|
-
}))), n;
|
|
1273
|
-
}
|
|
1274
|
-
function L(e) {
|
|
1275
|
-
return !j(e) && typeof e == "object" && e !== null;
|
|
1276
|
-
}
|
|
1277
|
-
function E(e, r) {
|
|
1278
|
-
const n = (t, i, c) => {
|
|
1279
|
-
let s = r.get(t);
|
|
1280
|
-
s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
|
|
1281
|
-
};
|
|
1282
|
-
for (const [t, i] of Object.entries(e))
|
|
1283
|
-
if (L(i)) {
|
|
1284
|
-
const c = t.split(":");
|
|
1285
|
-
for (const [s, a] of Object.entries(i))
|
|
1286
|
-
n(s, a, c);
|
|
1287
|
-
} else
|
|
1288
|
-
n(t, i, []);
|
|
1289
|
-
}
|
|
1290
|
-
function S(e, r) {
|
|
1291
|
-
const n = e.utilities.find((i) => i.name === r);
|
|
1292
|
-
if (n)
|
|
1293
|
-
return n;
|
|
1294
|
-
const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
|
|
1295
|
-
return e.utilities.find((i) => i.name === t);
|
|
1296
|
-
}
|
|
1297
|
-
function be(e, r) {
|
|
1298
|
-
const n = /* @__PURE__ */ new Map();
|
|
1299
|
-
if (e.base && E(e.base, n), e.variants)
|
|
1300
|
-
for (const i of Object.values(e.variants))
|
|
1301
|
-
for (const c of Object.values(i))
|
|
1302
|
-
E(
|
|
1303
|
-
c,
|
|
1304
|
-
n
|
|
1305
|
-
);
|
|
1306
|
-
if (e.compoundVariants)
|
|
1307
|
-
for (const i of e.compoundVariants)
|
|
1308
|
-
i.css && E(i.css, n);
|
|
1309
|
-
const t = /* @__PURE__ */ new Map();
|
|
1310
|
-
for (const [i, c] of n) {
|
|
1311
|
-
const s = S(r, i);
|
|
1312
|
-
if (!s) {
|
|
1313
|
-
console.warn(
|
|
1314
|
-
`[styleframe] Utility "${i}" not found in registry. Skipping.`
|
|
1315
|
-
);
|
|
1316
|
-
continue;
|
|
1317
|
-
}
|
|
1318
|
-
for (const a of c) {
|
|
1319
|
-
const o = [];
|
|
1320
|
-
for (const f of a.modifiers) {
|
|
1321
|
-
if (!t.has(f))
|
|
1322
|
-
try {
|
|
1323
|
-
t.set(f, se(r, f));
|
|
1324
|
-
} catch {
|
|
1325
|
-
console.warn(
|
|
1326
|
-
`[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
|
|
1327
|
-
), t.set(f, null);
|
|
1328
|
-
}
|
|
1329
|
-
const l = t.get(f);
|
|
1330
|
-
l && o.push(l);
|
|
1331
|
-
}
|
|
1332
|
-
s.create(
|
|
1333
|
-
[a.value],
|
|
1334
|
-
o.length > 0 ? o : void 0
|
|
1335
|
-
);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
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);
|
|
1341
|
-
return {
|
|
1342
|
-
id: r,
|
|
1343
|
-
root: n,
|
|
1344
|
-
variable: o,
|
|
1345
|
-
selector: f,
|
|
1346
|
-
utility: i,
|
|
1347
|
-
modifier: c,
|
|
1348
|
-
recipe: s,
|
|
1349
|
-
theme: a,
|
|
1350
|
-
atRule: l,
|
|
1351
|
-
keyframes: u,
|
|
1352
|
-
media: y,
|
|
1353
|
-
ref: p,
|
|
1354
|
-
css: d2,
|
|
1355
|
-
options: t
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
function createLoader(basePath, alias) {
|
|
1359
|
-
return createJiti(basePath, {
|
|
1360
|
-
fsCache: false,
|
|
1361
|
-
moduleCache: false,
|
|
1362
|
-
alias
|
|
22
|
+
const n = await g(i, o), a = await u(e);
|
|
23
|
+
t && a && await x(e, { recursive: !0 });
|
|
24
|
+
for (const r of n.files) {
|
|
25
|
+
const c = s.join(e, r.name), f = s.dirname(c);
|
|
26
|
+
await u(f) || await j(f, { recursive: !0 }), await v(c, r.content);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function p(i, t) {
|
|
30
|
+
return m(i, {
|
|
31
|
+
fsCache: !1,
|
|
32
|
+
moduleCache: !1,
|
|
33
|
+
alias: t
|
|
1363
34
|
});
|
|
1364
35
|
}
|
|
1365
|
-
function
|
|
1366
|
-
const
|
|
1367
|
-
for (const [
|
|
1368
|
-
if (
|
|
1369
|
-
let
|
|
1370
|
-
|
|
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
|
-
}
|
|
36
|
+
function w(i) {
|
|
37
|
+
const t = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const [e, o] of Object.entries(i)) {
|
|
39
|
+
if (e === "default") continue;
|
|
40
|
+
let n = null;
|
|
41
|
+
b(o) ? (n = "recipe", o._exportName = e) : O(o) && (n = "selector", o._exportName = e), n && t.set(e, { name: e, type: n });
|
|
1380
42
|
}
|
|
1381
|
-
return
|
|
43
|
+
return t;
|
|
1382
44
|
}
|
|
1383
|
-
async function
|
|
1384
|
-
const { alias, validateInstance =
|
|
1385
|
-
|
|
1386
|
-
const module = await jiti.import(filePath);
|
|
1387
|
-
if (!module.default) {
|
|
45
|
+
async function M(i, t = {}) {
|
|
46
|
+
const { alias: e, validateInstance: o = !0, jiti: n } = t, r = await (n ?? p(s.dirname(i), e)).import(i);
|
|
47
|
+
if (!r.default)
|
|
1388
48
|
throw new Error(
|
|
1389
|
-
`Missing default export in ${
|
|
49
|
+
`Missing default export in ${i}. Expected a Styleframe instance.`
|
|
1390
50
|
);
|
|
1391
|
-
|
|
1392
|
-
if (validateInstance && !Ve(module.default)) {
|
|
51
|
+
if (o && !$(r.default))
|
|
1393
52
|
throw new Error(
|
|
1394
|
-
`Invalid default export in ${
|
|
53
|
+
`Invalid default export in ${i}. Expected a Styleframe instance created with styleframe().`
|
|
1395
54
|
);
|
|
1396
|
-
|
|
1397
|
-
const exports = trackExports(module);
|
|
55
|
+
const c = w(r);
|
|
1398
56
|
return {
|
|
1399
|
-
module,
|
|
1400
|
-
instance:
|
|
1401
|
-
exports
|
|
57
|
+
module: r,
|
|
58
|
+
instance: r.default,
|
|
59
|
+
exports: c
|
|
1402
60
|
};
|
|
1403
61
|
}
|
|
1404
|
-
async function
|
|
1405
|
-
const { alias } =
|
|
1406
|
-
|
|
1407
|
-
const module = await jiti.import(filePath);
|
|
1408
|
-
const exports = trackExports(module);
|
|
1409
|
-
return { module, exports };
|
|
62
|
+
async function z(i, t = {}) {
|
|
63
|
+
const { alias: e, jiti: o } = t, a = await (o ?? p(s.dirname(i), e)).import(i), r = w(a);
|
|
64
|
+
return { module: a, exports: r };
|
|
1410
65
|
}
|
|
1411
|
-
const
|
|
1412
|
-
function
|
|
1413
|
-
return
|
|
66
|
+
const h = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
|
|
67
|
+
function N(i) {
|
|
68
|
+
return h.some((t) => i.endsWith(t));
|
|
1414
69
|
}
|
|
1415
|
-
function
|
|
1416
|
-
const
|
|
1417
|
-
if (
|
|
1418
|
-
return
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
return filePath;
|
|
1424
|
-
}
|
|
70
|
+
function y(i, t) {
|
|
71
|
+
const e = s.isAbsolute(t) ? t : s.join(i, t);
|
|
72
|
+
if (N(e))
|
|
73
|
+
return l(e) ? e : void 0;
|
|
74
|
+
for (const o of h) {
|
|
75
|
+
const n = `${e}${o}`;
|
|
76
|
+
if (l(n))
|
|
77
|
+
return n;
|
|
1425
78
|
}
|
|
1426
|
-
return void 0;
|
|
1427
79
|
}
|
|
1428
|
-
async function
|
|
1429
|
-
cwd = process.cwd(),
|
|
1430
|
-
entry = "styleframe.config"
|
|
80
|
+
async function d({
|
|
81
|
+
cwd: i = process.cwd(),
|
|
82
|
+
entry: t = "styleframe.config"
|
|
1431
83
|
} = {}) {
|
|
1432
|
-
const
|
|
1433
|
-
if (!
|
|
1434
|
-
return
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
return instance;
|
|
84
|
+
const e = y(i, t);
|
|
85
|
+
if (!e)
|
|
86
|
+
return D();
|
|
87
|
+
const { instance: o } = await M(e);
|
|
88
|
+
return o;
|
|
1438
89
|
}
|
|
1439
|
-
async function
|
|
1440
|
-
cwd = process.cwd(),
|
|
1441
|
-
entry = "styleframe.config",
|
|
1442
|
-
onUpdate,
|
|
1443
|
-
onError
|
|
90
|
+
async function B({
|
|
91
|
+
cwd: i = process.cwd(),
|
|
92
|
+
entry: t = "styleframe.config",
|
|
93
|
+
onUpdate: e,
|
|
94
|
+
onError: o
|
|
1444
95
|
} = {}) {
|
|
1445
|
-
const
|
|
1446
|
-
if (!
|
|
1447
|
-
throw new Error(`Config file not found: ${
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
watcher.on("change", async () => {
|
|
96
|
+
const n = y(i, t);
|
|
97
|
+
if (!n)
|
|
98
|
+
throw new Error(`Config file not found: ${t}`);
|
|
99
|
+
const a = J(n, { ignoreInitial: !0 });
|
|
100
|
+
return a.on("change", async () => {
|
|
1451
101
|
try {
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1454
|
-
} catch (
|
|
1455
|
-
|
|
1456
|
-
}
|
|
102
|
+
const r = await d({ entry: n });
|
|
103
|
+
e?.(r);
|
|
104
|
+
} catch (r) {
|
|
105
|
+
o?.(r instanceof Error ? r : new Error(String(r)));
|
|
106
|
+
}
|
|
107
|
+
}), a.on("unlink", () => {
|
|
108
|
+
o?.(new Error(`Config file was deleted: ${n}`));
|
|
109
|
+
}), {
|
|
110
|
+
config: await d({ entry: n }),
|
|
111
|
+
configFile: n,
|
|
112
|
+
unwatch: () => a.close()
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function U(i = {}) {
|
|
116
|
+
return m(process.cwd(), {
|
|
117
|
+
interopDefault: !0,
|
|
118
|
+
moduleCache: !0,
|
|
119
|
+
// Enable module caching for shared dependencies
|
|
120
|
+
...i
|
|
1457
121
|
});
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
122
|
+
}
|
|
123
|
+
function V(i, ...t) {
|
|
124
|
+
const e = i.cache;
|
|
125
|
+
if (e)
|
|
126
|
+
for (const o of t) {
|
|
127
|
+
const n = s.resolve(o);
|
|
128
|
+
typeof e == "object" && e !== null && (e instanceof Map ? (e.delete(n), e.delete(`file://${n}`)) : typeof e == "object" && (delete e[n], delete e[`file://${n}`]));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function W(i) {
|
|
132
|
+
const t = i.cache;
|
|
133
|
+
if (t) {
|
|
134
|
+
if (t instanceof Map)
|
|
135
|
+
t.clear();
|
|
136
|
+
else if (typeof t == "object")
|
|
137
|
+
for (const e of Object.keys(t))
|
|
138
|
+
delete t[e];
|
|
139
|
+
}
|
|
1466
140
|
}
|
|
1467
141
|
export {
|
|
1468
|
-
build,
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
142
|
+
T as build,
|
|
143
|
+
W as clearAllJitiCache,
|
|
144
|
+
V as clearJitiCache,
|
|
145
|
+
p as createLoader,
|
|
146
|
+
U as createSharedJiti,
|
|
147
|
+
u as directoryExists,
|
|
148
|
+
d as loadConfiguration,
|
|
149
|
+
z as loadExtensionModule,
|
|
150
|
+
M as loadModule,
|
|
151
|
+
w as trackExports,
|
|
152
|
+
B as watchConfiguration
|
|
1476
153
|
};
|