@styleframe/loader 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.cjs +996 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +996 -0
- package/package.json +14 -7
- package/.tsbuildinfo +0 -1
- package/playground/build.ts +0 -13
- package/playground/load.ts +0 -9
- package/playground/styleframe.config.ts +0 -50
- package/playground/watch.ts +0 -9
- package/src/build.ts +0 -36
- package/src/config.ts +0 -45
- package/src/index.ts +0 -3
- package/src/utils.ts +0 -10
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -12
- package/vite.config.ts +0 -13
package/dist/index.js
ADDED
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
import { stat, rm, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { validateInstanceLicense, getLicenseKeyFromEnv } from "@styleframe/license";
|
|
4
|
+
import { loadConfig, watchConfig } from "c12";
|
|
5
|
+
const N = ["charset", "import", "namespace"], R$1 = ["layer"], D$1 = ({ name: e }) => `[data-theme="${e}"]`, I = ({
|
|
6
|
+
name: e,
|
|
7
|
+
value: t,
|
|
8
|
+
modifiers: r
|
|
9
|
+
}) => `._${[...r, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
|
|
10
|
+
function L(e, t) {
|
|
11
|
+
return `@${e}${t ? " " : ""}${t}`;
|
|
12
|
+
}
|
|
13
|
+
const P$1 = /\d/, M$1 = ["-", "_", "/", "."];
|
|
14
|
+
function $$1(e = "") {
|
|
15
|
+
if (!P$1.test(e))
|
|
16
|
+
return e !== e.toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
function U$1(e, t) {
|
|
19
|
+
const r = M$1, n = [];
|
|
20
|
+
if (!e || typeof e != "string")
|
|
21
|
+
return n;
|
|
22
|
+
let u = "", a, i;
|
|
23
|
+
for (const s of e) {
|
|
24
|
+
const o = r.includes(s);
|
|
25
|
+
if (o === true) {
|
|
26
|
+
n.push(u), u = "", a = void 0;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const c = $$1(s);
|
|
30
|
+
if (i === false) {
|
|
31
|
+
if (a === false && c === true) {
|
|
32
|
+
n.push(u), u = s, a = c;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (a === true && c === false && u.length > 1) {
|
|
36
|
+
const f = u.at(-1);
|
|
37
|
+
n.push(u.slice(0, Math.max(0, u.length - 1))), u = f + s, a = c;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
u += s, a = c, i = o;
|
|
42
|
+
}
|
|
43
|
+
return n.push(u), n;
|
|
44
|
+
}
|
|
45
|
+
function _$1(e, t) {
|
|
46
|
+
return e ? (Array.isArray(e) ? e : U$1(e)).map((r) => r.toLowerCase()).join("-") : "";
|
|
47
|
+
}
|
|
48
|
+
function k$1(e) {
|
|
49
|
+
return ` ${e}`;
|
|
50
|
+
}
|
|
51
|
+
function V(e) {
|
|
52
|
+
return e.split(`
|
|
53
|
+
`).map((t) => k$1(t)).join(`
|
|
54
|
+
`);
|
|
55
|
+
}
|
|
56
|
+
function x(e) {
|
|
57
|
+
return _$1(e);
|
|
58
|
+
}
|
|
59
|
+
function K$1(e) {
|
|
60
|
+
return x(e);
|
|
61
|
+
}
|
|
62
|
+
function B$1(e, t) {
|
|
63
|
+
return `${e.startsWith("--") ? e : K$1(e)}: ${t};`;
|
|
64
|
+
}
|
|
65
|
+
function q$1(e) {
|
|
66
|
+
return `{${e.length > 0 ? `
|
|
67
|
+
` : ""}${e.map((t) => `${V(`${t}`)}
|
|
68
|
+
`).join("")}}`;
|
|
69
|
+
}
|
|
70
|
+
function O$1(e) {
|
|
71
|
+
return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
|
|
72
|
+
}
|
|
73
|
+
function z$1(e, t) {
|
|
74
|
+
return B$1(O$1(e), t);
|
|
75
|
+
}
|
|
76
|
+
function H$1(e, t) {
|
|
77
|
+
return `var(${O$1(e)}${t ? `, ${t}` : ""})`;
|
|
78
|
+
}
|
|
79
|
+
function C$1(e, t) {
|
|
80
|
+
return `${e} ${q$1(t)}`;
|
|
81
|
+
}
|
|
82
|
+
function Q$1(e) {
|
|
83
|
+
return function(r, n) {
|
|
84
|
+
return Object.entries(r).map(([u, a]) => B$1(u, e(a, n)));
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function E$1(e) {
|
|
88
|
+
return function(r, n) {
|
|
89
|
+
const a = (n.variables?.name ?? w)({ name: r.name });
|
|
90
|
+
return z$1(a, e(r.value, n));
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function S$1(e) {
|
|
94
|
+
const t = E$1(e), r = Q$1(e);
|
|
95
|
+
return function(u, a, i) {
|
|
96
|
+
const { variables: s, declarations: o, children: c } = a, f = u === ":root", l = (s ?? []).map(
|
|
97
|
+
(A2) => t(A2, i)
|
|
98
|
+
), m2 = r(
|
|
99
|
+
o ?? {},
|
|
100
|
+
i
|
|
101
|
+
), y = (c ?? []).map(
|
|
102
|
+
(A2) => e(A2, i)
|
|
103
|
+
), d = l.length > 0, h = m2.length > 0, v = y.length > 0;
|
|
104
|
+
return f ? `${d || h ? C$1(u, [
|
|
105
|
+
...l,
|
|
106
|
+
...d && h ? [""] : [],
|
|
107
|
+
...m2
|
|
108
|
+
]) : ""}${v && (d || h) ? `
|
|
109
|
+
|
|
110
|
+
` : ""}${y.join(`
|
|
111
|
+
|
|
112
|
+
`)}` : C$1(u, [
|
|
113
|
+
...l,
|
|
114
|
+
...d && (v || h) ? [""] : [],
|
|
115
|
+
...m2,
|
|
116
|
+
...h && v ? [""] : [],
|
|
117
|
+
...y.flatMap(
|
|
118
|
+
(A2, F2) => F2 === y.length - 1 ? [A2] : [A2, ""]
|
|
119
|
+
)
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function Z(e) {
|
|
124
|
+
const t = S$1(e);
|
|
125
|
+
return function(n, u) {
|
|
126
|
+
const a = N.includes(n.identifier), i = R$1.includes(
|
|
127
|
+
n.identifier
|
|
128
|
+
), s = Object.keys(n.declarations).length > 0, o = n.variables.length > 0, c = n.children.length > 0, f = L(n.identifier, n.rule);
|
|
129
|
+
return a || i && !(s || o || c) ? `${f};` : t(f, n, u);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function W$1(e) {
|
|
133
|
+
return typeof e == "object" && e !== null;
|
|
134
|
+
}
|
|
135
|
+
function b$1(e, t) {
|
|
136
|
+
return W$1(e) && "type" in e && e.type === t;
|
|
137
|
+
}
|
|
138
|
+
function J$1(e) {
|
|
139
|
+
return b$1(e, "variable");
|
|
140
|
+
}
|
|
141
|
+
function G$1(e) {
|
|
142
|
+
return b$1(e, "reference");
|
|
143
|
+
}
|
|
144
|
+
function Y$1(e) {
|
|
145
|
+
return b$1(e, "selector");
|
|
146
|
+
}
|
|
147
|
+
function X$1(e) {
|
|
148
|
+
return b$1(e, "at-rule");
|
|
149
|
+
}
|
|
150
|
+
function ee(e) {
|
|
151
|
+
return b$1(e, "utility");
|
|
152
|
+
}
|
|
153
|
+
function te(e) {
|
|
154
|
+
return b$1(e, "css");
|
|
155
|
+
}
|
|
156
|
+
function ne(e) {
|
|
157
|
+
return b$1(e, "theme");
|
|
158
|
+
}
|
|
159
|
+
function re(e) {
|
|
160
|
+
return b$1(e, "root");
|
|
161
|
+
}
|
|
162
|
+
function g$1(e) {
|
|
163
|
+
if (e instanceof Buffer)
|
|
164
|
+
return Buffer.from(e);
|
|
165
|
+
const t = e.constructor;
|
|
166
|
+
return new t(
|
|
167
|
+
e.buffer.slice(0),
|
|
168
|
+
e.byteOffset,
|
|
169
|
+
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function oe(e) {
|
|
173
|
+
if (e = e || {}, e.circular)
|
|
174
|
+
return ce(e);
|
|
175
|
+
const t = /* @__PURE__ */ new Map();
|
|
176
|
+
if (t.set(Date, (i) => new Date(i)), t.set(
|
|
177
|
+
Map,
|
|
178
|
+
(i, s) => new Map(n(Array.from(i), s))
|
|
179
|
+
), t.set(
|
|
180
|
+
Set,
|
|
181
|
+
(i, s) => new Set(n(Array.from(i), s))
|
|
182
|
+
), e.constructorHandlers)
|
|
183
|
+
for (const i of e.constructorHandlers)
|
|
184
|
+
t.set(i[0], i[1]);
|
|
185
|
+
let r;
|
|
186
|
+
return e.proto ? a : u;
|
|
187
|
+
function n(i, s) {
|
|
188
|
+
const o = Object.keys(i), c = Array.from({ length: o.length });
|
|
189
|
+
for (let f = 0; f < o.length; f++) {
|
|
190
|
+
const l = o[f], m2 = i[l];
|
|
191
|
+
typeof m2 != "object" || m2 === null ? c[l] = m2 : m2.constructor !== Object && (r = t.get(m2.constructor)) ? c[l] = r(m2, s) : ArrayBuffer.isView(m2) ? c[l] = g$1(m2) : c[l] = s(m2);
|
|
192
|
+
}
|
|
193
|
+
return c;
|
|
194
|
+
}
|
|
195
|
+
function u(i) {
|
|
196
|
+
if (typeof i != "object" || i === null) return i;
|
|
197
|
+
if (Array.isArray(i)) return n(i, u);
|
|
198
|
+
if (i.constructor !== Object && (r = t.get(i.constructor)))
|
|
199
|
+
return r(i, u);
|
|
200
|
+
const s = {};
|
|
201
|
+
for (const o in i) {
|
|
202
|
+
if (Object.hasOwnProperty.call(i, o) === false) continue;
|
|
203
|
+
const c = i[o];
|
|
204
|
+
typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, u) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = u(c);
|
|
205
|
+
}
|
|
206
|
+
return s;
|
|
207
|
+
}
|
|
208
|
+
function a(i) {
|
|
209
|
+
if (typeof i != "object" || i === null) return i;
|
|
210
|
+
if (Array.isArray(i)) return n(i, a);
|
|
211
|
+
if (i.constructor !== Object && (r = t.get(i.constructor)))
|
|
212
|
+
return r(i, a);
|
|
213
|
+
const s = {};
|
|
214
|
+
for (const o in i) {
|
|
215
|
+
const c = i[o];
|
|
216
|
+
typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, a) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = a(c);
|
|
217
|
+
}
|
|
218
|
+
return s;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function ce(e) {
|
|
222
|
+
const t = [], r = [], n = /* @__PURE__ */ new Map();
|
|
223
|
+
if (n.set(Date, (o) => new Date(o)), n.set(
|
|
224
|
+
Map,
|
|
225
|
+
(o, c) => new Map(a(Array.from(o), c))
|
|
226
|
+
), n.set(
|
|
227
|
+
Set,
|
|
228
|
+
(o, c) => new Set(a(Array.from(o), c))
|
|
229
|
+
), e.constructorHandlers)
|
|
230
|
+
for (const o of e.constructorHandlers)
|
|
231
|
+
n.set(o[0], o[1]);
|
|
232
|
+
let u;
|
|
233
|
+
return e.proto ? s : i;
|
|
234
|
+
function a(o, c) {
|
|
235
|
+
const f = Object.keys(o), l = Array.from({ length: f.length });
|
|
236
|
+
for (let m2 = 0; m2 < f.length; m2++) {
|
|
237
|
+
const y = f[m2], d = o[y];
|
|
238
|
+
if (typeof d != "object" || d === null)
|
|
239
|
+
l[y] = d;
|
|
240
|
+
else if (d.constructor !== Object && (u = n.get(d.constructor)))
|
|
241
|
+
l[y] = u(d, c);
|
|
242
|
+
else if (ArrayBuffer.isView(d))
|
|
243
|
+
l[y] = g$1(d);
|
|
244
|
+
else {
|
|
245
|
+
const h = t.indexOf(d);
|
|
246
|
+
h !== -1 ? l[y] = r[h] : l[y] = c(d);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return l;
|
|
250
|
+
}
|
|
251
|
+
function i(o) {
|
|
252
|
+
if (typeof o != "object" || o === null) return o;
|
|
253
|
+
if (Array.isArray(o)) return a(o, i);
|
|
254
|
+
if (o.constructor !== Object && (u = n.get(o.constructor)))
|
|
255
|
+
return u(o, i);
|
|
256
|
+
const c = {};
|
|
257
|
+
t.push(o), r.push(c);
|
|
258
|
+
for (const f in o) {
|
|
259
|
+
if (Object.hasOwnProperty.call(o, f) === false) continue;
|
|
260
|
+
const l = o[f];
|
|
261
|
+
if (typeof l != "object" || l === null)
|
|
262
|
+
c[f] = l;
|
|
263
|
+
else if (l.constructor !== Object && (u = n.get(l.constructor)))
|
|
264
|
+
c[f] = u(l, i);
|
|
265
|
+
else if (ArrayBuffer.isView(l))
|
|
266
|
+
c[f] = g$1(l);
|
|
267
|
+
else {
|
|
268
|
+
const m2 = t.indexOf(l);
|
|
269
|
+
m2 !== -1 ? c[f] = r[m2] : c[f] = i(l);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return t.pop(), r.pop(), c;
|
|
273
|
+
}
|
|
274
|
+
function s(o) {
|
|
275
|
+
if (typeof o != "object" || o === null) return o;
|
|
276
|
+
if (Array.isArray(o)) return a(o, s);
|
|
277
|
+
if (o.constructor !== Object && (u = n.get(o.constructor)))
|
|
278
|
+
return u(o, s);
|
|
279
|
+
const c = {};
|
|
280
|
+
t.push(o), r.push(c);
|
|
281
|
+
for (const f in o) {
|
|
282
|
+
const l = o[f];
|
|
283
|
+
if (typeof l != "object" || l === null)
|
|
284
|
+
c[f] = l;
|
|
285
|
+
else if (l.constructor !== Object && (u = n.get(l.constructor)))
|
|
286
|
+
c[f] = u(l, s);
|
|
287
|
+
else if (ArrayBuffer.isView(l))
|
|
288
|
+
c[f] = g$1(l);
|
|
289
|
+
else {
|
|
290
|
+
const m2 = t.indexOf(l);
|
|
291
|
+
m2 !== -1 ? c[f] = r[m2] : c[f] = s(l);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return t.pop(), r.pop(), c;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
oe();
|
|
298
|
+
function ue$1(e) {
|
|
299
|
+
return function(r, n) {
|
|
300
|
+
return r.value.map((u) => e(u, n)).join("").trim();
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function ie(e) {
|
|
304
|
+
return function(r, n) {
|
|
305
|
+
return r != null ? `${r}` : "";
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function se(e) {
|
|
309
|
+
return function(r, n) {
|
|
310
|
+
const a = (n.variables?.name ?? w)({ name: r.name });
|
|
311
|
+
return H$1(
|
|
312
|
+
a,
|
|
313
|
+
r.fallback ? e(r.fallback, n) : void 0
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function ae(e) {
|
|
318
|
+
const t = S$1(e);
|
|
319
|
+
return function(n, u) {
|
|
320
|
+
return n.themes.reduce(
|
|
321
|
+
(a, i) => (a.push(e(i, u)), a),
|
|
322
|
+
[t(":root", n, u)]
|
|
323
|
+
// Default theme (root)
|
|
324
|
+
).join(`
|
|
325
|
+
|
|
326
|
+
`);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function le(e) {
|
|
330
|
+
const t = S$1(e);
|
|
331
|
+
return function(n, u) {
|
|
332
|
+
return t(n.query, n, u);
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function fe(e) {
|
|
336
|
+
const t = S$1(e);
|
|
337
|
+
return function(n, u) {
|
|
338
|
+
const i = (u.theme?.selector ?? D$1)({ name: n.name });
|
|
339
|
+
return t(i, n, u);
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function me(e) {
|
|
343
|
+
const t = S$1(e);
|
|
344
|
+
return function(n, u) {
|
|
345
|
+
const a = [], s = (u.utilities?.selector ?? I)({
|
|
346
|
+
name: n.name,
|
|
347
|
+
value: n.value,
|
|
348
|
+
modifiers: n.modifiers
|
|
349
|
+
});
|
|
350
|
+
return a.push(t(s, n, u)), a.join(`
|
|
351
|
+
|
|
352
|
+
`);
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function p$1(e, t) {
|
|
356
|
+
const r = ae(p$1), n = le(p$1), u = me(p$1), a = Z(p$1), i = fe(p$1), s = E$1(p$1), o = se(p$1), c = ue$1(p$1), f = ie();
|
|
357
|
+
switch (true) {
|
|
358
|
+
case Y$1(e):
|
|
359
|
+
return n(e, t);
|
|
360
|
+
case ee(e):
|
|
361
|
+
return u(e, t);
|
|
362
|
+
case X$1(e):
|
|
363
|
+
return a(e, t);
|
|
364
|
+
case re(e):
|
|
365
|
+
return r(e, t);
|
|
366
|
+
case ne(e):
|
|
367
|
+
return i(e, t);
|
|
368
|
+
case J$1(e):
|
|
369
|
+
return s(e, t);
|
|
370
|
+
case G$1(e):
|
|
371
|
+
return o(e, t);
|
|
372
|
+
case te(e):
|
|
373
|
+
return c(e, t);
|
|
374
|
+
default:
|
|
375
|
+
return f(e, t);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function T$1(e, t) {
|
|
379
|
+
switch (true) {
|
|
380
|
+
case Array.isArray(e):
|
|
381
|
+
return e.map((r) => T$1(r)).join(`
|
|
382
|
+
`);
|
|
383
|
+
// case isRecipe(instance):
|
|
384
|
+
// return consumeRecipe(instance, options);
|
|
385
|
+
// break;
|
|
386
|
+
default:
|
|
387
|
+
return "";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const de = `-----BEGIN PUBLIC KEY-----
|
|
391
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
|
|
392
|
+
qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
|
|
393
|
+
BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
|
|
394
|
+
dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
|
|
395
|
+
hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
|
|
396
|
+
4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
|
|
397
|
+
GwIDAQAB
|
|
398
|
+
-----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
|
|
399
|
+
async function he(e) {
|
|
400
|
+
const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
|
|
401
|
+
return await crypto.subtle.importKey(
|
|
402
|
+
"spki",
|
|
403
|
+
r,
|
|
404
|
+
{
|
|
405
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
406
|
+
hash: "SHA-256"
|
|
407
|
+
},
|
|
408
|
+
true,
|
|
409
|
+
["verify"]
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
async function be({
|
|
413
|
+
payload: e,
|
|
414
|
+
signature: t
|
|
415
|
+
}) {
|
|
416
|
+
const r = new TextEncoder().encode(e), n = Uint8Array.from(
|
|
417
|
+
atob(t),
|
|
418
|
+
(a) => a.charCodeAt(0)
|
|
419
|
+
), u = await he(de);
|
|
420
|
+
if (!await crypto.subtle.verify(
|
|
421
|
+
{ name: "RSASSA-PKCS1-v1_5" },
|
|
422
|
+
u,
|
|
423
|
+
n,
|
|
424
|
+
r
|
|
425
|
+
))
|
|
426
|
+
throw new Error(
|
|
427
|
+
"License validation failed: Invalid signature detected. The license may have been modified or corrupted."
|
|
428
|
+
);
|
|
429
|
+
return JSON.parse(e);
|
|
430
|
+
}
|
|
431
|
+
function Ae(e) {
|
|
432
|
+
return Object.prototype.hasOwnProperty.call(e, ye);
|
|
433
|
+
}
|
|
434
|
+
async function ge(e) {
|
|
435
|
+
const t = Object.getOwnPropertyDescriptor(
|
|
436
|
+
e,
|
|
437
|
+
pe
|
|
438
|
+
);
|
|
439
|
+
if (!t?.value)
|
|
440
|
+
return {
|
|
441
|
+
key: "",
|
|
442
|
+
instanceId: "",
|
|
443
|
+
environment: "",
|
|
444
|
+
valid: false
|
|
445
|
+
};
|
|
446
|
+
const r = t.value;
|
|
447
|
+
if (typeof r != "object" || r === null || !("payload" in r) || !("signature" in r) || typeof r.payload != "string" || typeof r.signature != "string")
|
|
448
|
+
return {
|
|
449
|
+
key: "",
|
|
450
|
+
instanceId: "",
|
|
451
|
+
environment: "",
|
|
452
|
+
valid: false
|
|
453
|
+
};
|
|
454
|
+
try {
|
|
455
|
+
return await be(
|
|
456
|
+
r
|
|
457
|
+
);
|
|
458
|
+
} catch {
|
|
459
|
+
return {
|
|
460
|
+
key: "",
|
|
461
|
+
instanceId: "",
|
|
462
|
+
environment: "",
|
|
463
|
+
valid: false
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function Se(e) {
|
|
468
|
+
const t = Math.floor(Math.random() * 100);
|
|
469
|
+
e.root.children.push({
|
|
470
|
+
type: "selector",
|
|
471
|
+
query: `html:nth-of-type(${t}n+1)::after`,
|
|
472
|
+
variables: [],
|
|
473
|
+
children: [],
|
|
474
|
+
declarations: {
|
|
475
|
+
content: '"Styleframe Pro: Development Mode – License required for production use"',
|
|
476
|
+
zIndex: 99999,
|
|
477
|
+
position: "fixed",
|
|
478
|
+
display: "block !important",
|
|
479
|
+
opacity: "1 !important",
|
|
480
|
+
bottom: 0,
|
|
481
|
+
left: 0,
|
|
482
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
483
|
+
color: "white",
|
|
484
|
+
fontSize: "12px",
|
|
485
|
+
lineHeight: "1",
|
|
486
|
+
padding: "0.5rem",
|
|
487
|
+
fontFamily: "sans-serif"
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function j(e, t = "") {
|
|
492
|
+
return {
|
|
493
|
+
name: e,
|
|
494
|
+
content: t
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
async function Ce(e, {
|
|
498
|
+
type: t = "all",
|
|
499
|
+
consumers: r = { css: p$1, ts: T$1 }
|
|
500
|
+
} = {}) {
|
|
501
|
+
const n = { files: [] }, u = e.options;
|
|
502
|
+
if (Ae(e)) {
|
|
503
|
+
const s = await ge(e);
|
|
504
|
+
(!s.valid || s.instanceId !== e.id) && Se(e);
|
|
505
|
+
}
|
|
506
|
+
const { recipes: a, ...i } = e.root;
|
|
507
|
+
if (t === "all" || t === "css") {
|
|
508
|
+
const s = j("index.css", r.css(i, u));
|
|
509
|
+
n.files.push(s);
|
|
510
|
+
}
|
|
511
|
+
if (t === "all" || t === "ts") {
|
|
512
|
+
const s = j("index.ts", r.ts([], u));
|
|
513
|
+
n.files.push(s);
|
|
514
|
+
}
|
|
515
|
+
return console.log(n.files), n;
|
|
516
|
+
}
|
|
517
|
+
async function directoryExists(path2) {
|
|
518
|
+
try {
|
|
519
|
+
const stats = await stat(path2);
|
|
520
|
+
return stats.isDirectory();
|
|
521
|
+
} catch {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
async function build(instance, { clean = true, outputDir = "./styleframe", transpiler } = {}) {
|
|
526
|
+
await validateInstanceLicense(instance, {
|
|
527
|
+
licenseKey: getLicenseKeyFromEnv() || "",
|
|
528
|
+
environment: process.env.NODE_ENV || "development",
|
|
529
|
+
isBuild: true
|
|
530
|
+
});
|
|
531
|
+
const output = await Ce(instance, transpiler);
|
|
532
|
+
const outputDirExists = await directoryExists(outputDir);
|
|
533
|
+
if (clean && outputDirExists) {
|
|
534
|
+
await rm(outputDir, { recursive: true });
|
|
535
|
+
}
|
|
536
|
+
for (const file of output.files) {
|
|
537
|
+
const filePath = path.join(outputDir, file.name);
|
|
538
|
+
const fileOutputDirPath = path.dirname(filePath);
|
|
539
|
+
const fileOutputDirExists = await directoryExists(fileOutputDirPath);
|
|
540
|
+
if (!fileOutputDirExists) {
|
|
541
|
+
await mkdir(fileOutputDirPath, { recursive: true });
|
|
542
|
+
}
|
|
543
|
+
await writeFile(filePath, file.content);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function k(e, r) {
|
|
547
|
+
return function(t, ...i) {
|
|
548
|
+
return {
|
|
549
|
+
type: "css",
|
|
550
|
+
value: t.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
function M(e) {
|
|
555
|
+
return typeof e == "object" && e !== null;
|
|
556
|
+
}
|
|
557
|
+
function p(e, r) {
|
|
558
|
+
return M(e) && "type" in e && e.type === r;
|
|
559
|
+
}
|
|
560
|
+
function B(e) {
|
|
561
|
+
return p(e, "variable");
|
|
562
|
+
}
|
|
563
|
+
function F(e) {
|
|
564
|
+
return p(e, "reference");
|
|
565
|
+
}
|
|
566
|
+
function T(e) {
|
|
567
|
+
return p(e, "css");
|
|
568
|
+
}
|
|
569
|
+
function _(e) {
|
|
570
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
571
|
+
}
|
|
572
|
+
function O(e) {
|
|
573
|
+
return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(O);
|
|
574
|
+
}
|
|
575
|
+
function C(e) {
|
|
576
|
+
return M(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
577
|
+
}
|
|
578
|
+
function R(e, r) {
|
|
579
|
+
return function(t, i, s) {
|
|
580
|
+
const o = {
|
|
581
|
+
type: "at-rule",
|
|
582
|
+
identifier: t,
|
|
583
|
+
rule: i,
|
|
584
|
+
declarations: {},
|
|
585
|
+
variables: [],
|
|
586
|
+
children: []
|
|
587
|
+
}, u = b(o, r);
|
|
588
|
+
return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function S(e, r) {
|
|
592
|
+
const n = R(e, r);
|
|
593
|
+
return function(i, s) {
|
|
594
|
+
return n("media", i, s);
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function E(e, r) {
|
|
598
|
+
const n = R(e, r);
|
|
599
|
+
return function(i, s) {
|
|
600
|
+
return n("keyframes", i, s);
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function P(e, r) {
|
|
604
|
+
return function(t, i) {
|
|
605
|
+
return B(t) ? {
|
|
606
|
+
type: "reference",
|
|
607
|
+
name: t.name,
|
|
608
|
+
fallback: i
|
|
609
|
+
} : {
|
|
610
|
+
type: "reference",
|
|
611
|
+
name: t,
|
|
612
|
+
fallback: i
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function D(e, r) {
|
|
617
|
+
return function(t, i) {
|
|
618
|
+
const s = {
|
|
619
|
+
type: "selector",
|
|
620
|
+
query: t,
|
|
621
|
+
declarations: {},
|
|
622
|
+
variables: [],
|
|
623
|
+
children: []
|
|
624
|
+
}, o = b(s, r);
|
|
625
|
+
return typeof i == "function" ? s.declarations = i(o) ?? {} : C(i) ? (s.variables = i.variables, s.declarations = i.declarations, s.children = i.children) : s.declarations = i, g(s.declarations, o), e.children.push(s), s;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function H(e, r) {
|
|
629
|
+
return function(t, i, s = {
|
|
630
|
+
default: false
|
|
631
|
+
}) {
|
|
632
|
+
const o = typeof t == "string" ? t : t.name, u = e.variables.find(
|
|
633
|
+
(f) => f.name === o
|
|
634
|
+
);
|
|
635
|
+
if (s.default && u)
|
|
636
|
+
return u;
|
|
637
|
+
if (u)
|
|
638
|
+
return u.value = i, u;
|
|
639
|
+
const c = {
|
|
640
|
+
type: "variable",
|
|
641
|
+
name: o,
|
|
642
|
+
value: i
|
|
643
|
+
};
|
|
644
|
+
return e.variables.push(c), c;
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
function b(e, r) {
|
|
648
|
+
const n = H(e), t = D(e, r), i = R(e, r), s = E(r, r), o = S(e, r), u = P(), c = k();
|
|
649
|
+
return {
|
|
650
|
+
variable: n,
|
|
651
|
+
selector: t,
|
|
652
|
+
keyframes: s,
|
|
653
|
+
atRule: i,
|
|
654
|
+
media: o,
|
|
655
|
+
ref: u,
|
|
656
|
+
css: c
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function g(e, r) {
|
|
660
|
+
for (const n in e)
|
|
661
|
+
if (n.startsWith("@")) {
|
|
662
|
+
const t = e[n];
|
|
663
|
+
if (typeof t == "object" && t !== null && !O(t)) {
|
|
664
|
+
const i = n.replace(/^@(\w+).*/, "$1"), s = n.replace(`@${i}`, "").trim();
|
|
665
|
+
r.atRule(i, s, t), delete e[n];
|
|
666
|
+
}
|
|
667
|
+
} else if (/^[.&:]/.test(n)) {
|
|
668
|
+
const t = e[n];
|
|
669
|
+
typeof t == "object" && (r.selector(n, t), delete e[n]);
|
|
670
|
+
}
|
|
671
|
+
return e;
|
|
672
|
+
}
|
|
673
|
+
function m(e) {
|
|
674
|
+
if (e instanceof Buffer)
|
|
675
|
+
return Buffer.from(e);
|
|
676
|
+
const r = e.constructor;
|
|
677
|
+
return new r(
|
|
678
|
+
e.buffer.slice(0),
|
|
679
|
+
e.byteOffset,
|
|
680
|
+
e.byteLength / e.BYTES_PER_ELEMENT || 1
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
function K(e) {
|
|
684
|
+
if (e = e || {}, e.circular)
|
|
685
|
+
return U(e);
|
|
686
|
+
const r = /* @__PURE__ */ new Map();
|
|
687
|
+
if (r.set(Date, (o) => new Date(o)), r.set(
|
|
688
|
+
Map,
|
|
689
|
+
(o, u) => new Map(t(Array.from(o), u))
|
|
690
|
+
), r.set(
|
|
691
|
+
Set,
|
|
692
|
+
(o, u) => new Set(t(Array.from(o), u))
|
|
693
|
+
), e.constructorHandlers)
|
|
694
|
+
for (const o of e.constructorHandlers)
|
|
695
|
+
r.set(o[0], o[1]);
|
|
696
|
+
let n;
|
|
697
|
+
return e.proto ? s : i;
|
|
698
|
+
function t(o, u) {
|
|
699
|
+
const c = Object.keys(o), f = Array.from({ length: c.length });
|
|
700
|
+
for (let a = 0; a < c.length; a++) {
|
|
701
|
+
const l = c[a], y = o[l];
|
|
702
|
+
typeof y != "object" || y === null ? f[l] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[l] = n(y, u) : ArrayBuffer.isView(y) ? f[l] = m(y) : f[l] = u(y);
|
|
703
|
+
}
|
|
704
|
+
return f;
|
|
705
|
+
}
|
|
706
|
+
function i(o) {
|
|
707
|
+
if (typeof o != "object" || o === null) return o;
|
|
708
|
+
if (Array.isArray(o)) return t(o, i);
|
|
709
|
+
if (o.constructor !== Object && (n = r.get(o.constructor)))
|
|
710
|
+
return n(o, i);
|
|
711
|
+
const u = {};
|
|
712
|
+
for (const c in o) {
|
|
713
|
+
if (Object.hasOwnProperty.call(o, c) === false) continue;
|
|
714
|
+
const f = o[c];
|
|
715
|
+
typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, i) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = i(f);
|
|
716
|
+
}
|
|
717
|
+
return u;
|
|
718
|
+
}
|
|
719
|
+
function s(o) {
|
|
720
|
+
if (typeof o != "object" || o === null) return o;
|
|
721
|
+
if (Array.isArray(o)) return t(o, s);
|
|
722
|
+
if (o.constructor !== Object && (n = r.get(o.constructor)))
|
|
723
|
+
return n(o, s);
|
|
724
|
+
const u = {};
|
|
725
|
+
for (const c in o) {
|
|
726
|
+
const f = o[c];
|
|
727
|
+
typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? u[c] = n(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
|
|
728
|
+
}
|
|
729
|
+
return u;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function U(e) {
|
|
733
|
+
const r = [], n = [], t = /* @__PURE__ */ new Map();
|
|
734
|
+
if (t.set(Date, (c) => new Date(c)), t.set(
|
|
735
|
+
Map,
|
|
736
|
+
(c, f) => new Map(s(Array.from(c), f))
|
|
737
|
+
), t.set(
|
|
738
|
+
Set,
|
|
739
|
+
(c, f) => new Set(s(Array.from(c), f))
|
|
740
|
+
), e.constructorHandlers)
|
|
741
|
+
for (const c of e.constructorHandlers)
|
|
742
|
+
t.set(c[0], c[1]);
|
|
743
|
+
let i;
|
|
744
|
+
return e.proto ? u : o;
|
|
745
|
+
function s(c, f) {
|
|
746
|
+
const a = Object.keys(c), l = Array.from({ length: a.length });
|
|
747
|
+
for (let y = 0; y < a.length; y++) {
|
|
748
|
+
const h = a[y], d = c[h];
|
|
749
|
+
if (typeof d != "object" || d === null)
|
|
750
|
+
l[h] = d;
|
|
751
|
+
else if (d.constructor !== Object && (i = t.get(d.constructor)))
|
|
752
|
+
l[h] = i(d, f);
|
|
753
|
+
else if (ArrayBuffer.isView(d))
|
|
754
|
+
l[h] = m(d);
|
|
755
|
+
else {
|
|
756
|
+
const v = r.indexOf(d);
|
|
757
|
+
v !== -1 ? l[h] = n[v] : l[h] = f(d);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return l;
|
|
761
|
+
}
|
|
762
|
+
function o(c) {
|
|
763
|
+
if (typeof c != "object" || c === null) return c;
|
|
764
|
+
if (Array.isArray(c)) return s(c, o);
|
|
765
|
+
if (c.constructor !== Object && (i = t.get(c.constructor)))
|
|
766
|
+
return i(c, o);
|
|
767
|
+
const f = {};
|
|
768
|
+
r.push(c), n.push(f);
|
|
769
|
+
for (const a in c) {
|
|
770
|
+
if (Object.hasOwnProperty.call(c, a) === false) continue;
|
|
771
|
+
const l = c[a];
|
|
772
|
+
if (typeof l != "object" || l === null)
|
|
773
|
+
f[a] = l;
|
|
774
|
+
else if (l.constructor !== Object && (i = t.get(l.constructor)))
|
|
775
|
+
f[a] = i(l, o);
|
|
776
|
+
else if (ArrayBuffer.isView(l))
|
|
777
|
+
f[a] = m(l);
|
|
778
|
+
else {
|
|
779
|
+
const y = r.indexOf(l);
|
|
780
|
+
y !== -1 ? f[a] = n[y] : f[a] = o(l);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return r.pop(), n.pop(), f;
|
|
784
|
+
}
|
|
785
|
+
function u(c) {
|
|
786
|
+
if (typeof c != "object" || c === null) return c;
|
|
787
|
+
if (Array.isArray(c)) return s(c, u);
|
|
788
|
+
if (c.constructor !== Object && (i = t.get(c.constructor)))
|
|
789
|
+
return i(c, u);
|
|
790
|
+
const f = {};
|
|
791
|
+
r.push(c), n.push(f);
|
|
792
|
+
for (const a in c) {
|
|
793
|
+
const l = c[a];
|
|
794
|
+
if (typeof l != "object" || l === null)
|
|
795
|
+
f[a] = l;
|
|
796
|
+
else if (l.constructor !== Object && (i = t.get(l.constructor)))
|
|
797
|
+
f[a] = i(l, u);
|
|
798
|
+
else if (ArrayBuffer.isView(l))
|
|
799
|
+
f[a] = m(l);
|
|
800
|
+
else {
|
|
801
|
+
const y = r.indexOf(l);
|
|
802
|
+
y !== -1 ? f[a] = n[y] : f[a] = u(l);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return r.pop(), n.pop(), f;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const A = K();
|
|
809
|
+
function $(e, r = 8) {
|
|
810
|
+
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
811
|
+
let t = "";
|
|
812
|
+
for (let i = 0; i < r; i++) {
|
|
813
|
+
const s = Math.floor(Math.random() * n.length);
|
|
814
|
+
t += n[s];
|
|
815
|
+
}
|
|
816
|
+
return e ? `${e}${t}` : t;
|
|
817
|
+
}
|
|
818
|
+
function q(e) {
|
|
819
|
+
const r = [];
|
|
820
|
+
function n(t, i) {
|
|
821
|
+
i.length > 0 && r.push([...i].sort());
|
|
822
|
+
for (let s = t; s < e.length; s++) {
|
|
823
|
+
const o = e[s];
|
|
824
|
+
if (o)
|
|
825
|
+
if (o.length === 1 && o[0])
|
|
826
|
+
n(s + 1, [...i, o[0]]);
|
|
827
|
+
else
|
|
828
|
+
for (const u of o)
|
|
829
|
+
n(s + 1, [...i, u]);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
|
|
833
|
+
}
|
|
834
|
+
function z(e, r, n) {
|
|
835
|
+
const t = {
|
|
836
|
+
...e,
|
|
837
|
+
modifiers: [...n.keys()]
|
|
838
|
+
}, i = b(t, r);
|
|
839
|
+
for (const s of n.values())
|
|
840
|
+
s.factory({
|
|
841
|
+
...i,
|
|
842
|
+
declarations: A(t.declarations),
|
|
843
|
+
variables: A(t.variables),
|
|
844
|
+
children: A(t.children)
|
|
845
|
+
}), g(t.declarations, i);
|
|
846
|
+
return t;
|
|
847
|
+
}
|
|
848
|
+
function W(e, r) {
|
|
849
|
+
return function(t, i) {
|
|
850
|
+
const s = {
|
|
851
|
+
type: "modifier",
|
|
852
|
+
key: Array.isArray(t) ? t : [t],
|
|
853
|
+
factory: i
|
|
854
|
+
};
|
|
855
|
+
return r.modifiers.push(s), s;
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function Y() {
|
|
859
|
+
return {
|
|
860
|
+
type: "root",
|
|
861
|
+
declarations: {},
|
|
862
|
+
utilities: [],
|
|
863
|
+
modifiers: [],
|
|
864
|
+
recipes: [],
|
|
865
|
+
variables: [],
|
|
866
|
+
children: [],
|
|
867
|
+
themes: []
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
function G(e, r, n) {
|
|
871
|
+
const t = r.map((s) => s.key);
|
|
872
|
+
return q(t).map((s) => {
|
|
873
|
+
const o = /* @__PURE__ */ new Map();
|
|
874
|
+
for (const u of s) {
|
|
875
|
+
const c = r.find(
|
|
876
|
+
(f) => f.key.includes(u)
|
|
877
|
+
);
|
|
878
|
+
c && o.set(u, c);
|
|
879
|
+
}
|
|
880
|
+
return z(e, n, o);
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
function J(e, r) {
|
|
884
|
+
return function(t, i) {
|
|
885
|
+
const s = {
|
|
886
|
+
type: "utility",
|
|
887
|
+
name: t,
|
|
888
|
+
factory: i
|
|
889
|
+
};
|
|
890
|
+
return r.utilities.push(s), (o, u = []) => {
|
|
891
|
+
for (const [c, f] of Object.entries(o)) {
|
|
892
|
+
const a = {
|
|
893
|
+
type: "utility",
|
|
894
|
+
name: t,
|
|
895
|
+
value: c,
|
|
896
|
+
declarations: {},
|
|
897
|
+
variables: [],
|
|
898
|
+
children: [],
|
|
899
|
+
modifiers: []
|
|
900
|
+
}, l = b(
|
|
901
|
+
a,
|
|
902
|
+
r
|
|
903
|
+
);
|
|
904
|
+
a.declarations = i({
|
|
905
|
+
...l,
|
|
906
|
+
value: f
|
|
907
|
+
}) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
|
|
908
|
+
...G(a, u, r)
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function Q(e, r) {
|
|
915
|
+
return function(t, i) {
|
|
916
|
+
const s = r.themes.find((c) => c.name === t), o = s ?? {
|
|
917
|
+
type: "theme",
|
|
918
|
+
name: t,
|
|
919
|
+
declarations: {},
|
|
920
|
+
variables: [],
|
|
921
|
+
children: []
|
|
922
|
+
};
|
|
923
|
+
s || r.themes.push(o);
|
|
924
|
+
const u = b(o, r);
|
|
925
|
+
return i && i(u), o;
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function X(e, r) {
|
|
929
|
+
return function(t, i, s, o) {
|
|
930
|
+
const u = {
|
|
931
|
+
type: "recipe",
|
|
932
|
+
name: t,
|
|
933
|
+
defaults: i,
|
|
934
|
+
variants: s,
|
|
935
|
+
...o
|
|
936
|
+
};
|
|
937
|
+
return r.recipes.push(u), u;
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
function ue(e) {
|
|
941
|
+
const r = $("sf-"), n = Y(), t = { ...e }, i = J(n, n), s = W(n, n), o = X(n, n), u = Q(n, n), { variable: c, selector: f, atRule: a, keyframes: l, media: y, ref: h, css: d } = b(n, n);
|
|
942
|
+
return {
|
|
943
|
+
id: r,
|
|
944
|
+
root: n,
|
|
945
|
+
variable: c,
|
|
946
|
+
selector: f,
|
|
947
|
+
utility: i,
|
|
948
|
+
modifier: s,
|
|
949
|
+
recipe: o,
|
|
950
|
+
theme: u,
|
|
951
|
+
atRule: a,
|
|
952
|
+
keyframes: l,
|
|
953
|
+
media: y,
|
|
954
|
+
ref: h,
|
|
955
|
+
css: d,
|
|
956
|
+
options: t
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
async function loadConfiguration({
|
|
960
|
+
cwd = process.cwd(),
|
|
961
|
+
name = "styleframe"
|
|
962
|
+
} = {}) {
|
|
963
|
+
const { config } = await loadConfig({
|
|
964
|
+
cwd,
|
|
965
|
+
name,
|
|
966
|
+
defaults: ue()
|
|
967
|
+
});
|
|
968
|
+
return config;
|
|
969
|
+
}
|
|
970
|
+
async function loadConfigurationFromPath(entry) {
|
|
971
|
+
const entryPath = path.resolve(entry);
|
|
972
|
+
const cwd = path.dirname(entryPath);
|
|
973
|
+
const name = path.basename(entryPath).replace(/(\.config)?(\.ts)?$/, "");
|
|
974
|
+
return await loadConfiguration({ cwd, name });
|
|
975
|
+
}
|
|
976
|
+
async function watchConfiguration({
|
|
977
|
+
cwd = process.cwd()
|
|
978
|
+
} = {}) {
|
|
979
|
+
return await watchConfig({
|
|
980
|
+
cwd,
|
|
981
|
+
name: "styleframe",
|
|
982
|
+
acceptHMR({ getDiff }) {
|
|
983
|
+
const diff = getDiff();
|
|
984
|
+
if (diff.length === 0) {
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
export {
|
|
991
|
+
build,
|
|
992
|
+
directoryExists,
|
|
993
|
+
loadConfiguration,
|
|
994
|
+
loadConfigurationFromPath,
|
|
995
|
+
watchConfiguration
|
|
996
|
+
};
|