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