@archduck/gst-core 0.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/LICENSE +21 -0
- package/README.md +344 -0
- package/dist/chunks/core-Wpl1tnO4.js +35 -0
- package/dist/chunks/core-Wpl1tnO4.js.map +1 -0
- package/dist/chunks/core-ovxYfJ25.js +2362 -0
- package/dist/chunks/core-ovxYfJ25.js.map +1 -0
- package/dist/chunks/loaders-B7J79C97.js +606 -0
- package/dist/chunks/loaders-B7J79C97.js.map +1 -0
- package/dist/chunks/loaders-BEwXPBCN.js +2 -0
- package/dist/chunks/loaders-BEwXPBCN.js.map +1 -0
- package/dist/chunks/mergeConfigs-CRhPUSCj.js +191 -0
- package/dist/chunks/mergeConfigs-CRhPUSCj.js.map +1 -0
- package/dist/chunks/mergeConfigs-Dgwcseh2.js +2 -0
- package/dist/chunks/mergeConfigs-Dgwcseh2.js.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +41 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders.cjs +2 -0
- package/dist/loaders.cjs.map +1 -0
- package/dist/loaders.js +19 -0
- package/dist/loaders.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { l as x, b as q, t as K } from "./mergeConfigs-CRhPUSCj.js";
|
|
2
|
+
function m(e) {
|
|
3
|
+
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
4
|
+
}
|
|
5
|
+
function v(e, t) {
|
|
6
|
+
if (!e || typeof e != "string") return;
|
|
7
|
+
const n = e.split(".");
|
|
8
|
+
let s = t;
|
|
9
|
+
for (const i of n) {
|
|
10
|
+
if (s == null) return;
|
|
11
|
+
s = s[i];
|
|
12
|
+
}
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
function S(e, t, n = {}) {
|
|
16
|
+
return t == null || typeof t != "object" ? t : Array.isArray(t) ? rt(e, t, n) : at(e, t, n);
|
|
17
|
+
}
|
|
18
|
+
function rt(e, t, n) {
|
|
19
|
+
const s = t.indexOf("...") !== -1, i = t.some((d) => typeof d == "string" && d.startsWith("%")), r = Array.isArray(e) && e.some((d) => m(d) && d.name), a = t.some((d) => m(d) && d.name);
|
|
20
|
+
if (i || r && a)
|
|
21
|
+
return it(e, t, n);
|
|
22
|
+
if (!s)
|
|
23
|
+
return t.map((d) => m(d) ? S({}, d, n) : d);
|
|
24
|
+
const o = t.indexOf("..."), c = Array.isArray(e) ? e : [], f = t.slice(0, o), y = t.slice(o + 1), p = f.map(
|
|
25
|
+
(d) => m(d) ? S({}, d, n) : d
|
|
26
|
+
), O = y.map(
|
|
27
|
+
(d) => m(d) ? S({}, d, n) : d
|
|
28
|
+
);
|
|
29
|
+
return [...p, ...c, ...O];
|
|
30
|
+
}
|
|
31
|
+
function it(e, t, n) {
|
|
32
|
+
const s = Array.isArray(e) ? e : [], i = {};
|
|
33
|
+
for (const a of s)
|
|
34
|
+
m(a) && a.name && (i[a.name] = a);
|
|
35
|
+
const r = [];
|
|
36
|
+
for (const a of t)
|
|
37
|
+
if (a === "...")
|
|
38
|
+
for (const o of s)
|
|
39
|
+
r.push(o);
|
|
40
|
+
else if (typeof a == "string" && a.startsWith("%")) {
|
|
41
|
+
const o = a.slice(1), c = i[o];
|
|
42
|
+
c ? r.push(c) : console.warn(`[gst-compose] %${o}: no group named "${o}" in target layout`);
|
|
43
|
+
} else if (m(a)) {
|
|
44
|
+
const o = a.name && i[a.name] ? i[a.name] : {}, c = S(o, a, n);
|
|
45
|
+
r.push(c);
|
|
46
|
+
} else
|
|
47
|
+
r.push(a);
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
function at(e, t, n) {
|
|
51
|
+
let s = n, i = {};
|
|
52
|
+
if ("__source" in t) {
|
|
53
|
+
const o = t.__source;
|
|
54
|
+
if (o === null || m(o) && Object.keys(o).length === 0)
|
|
55
|
+
s = {};
|
|
56
|
+
else {
|
|
57
|
+
const c = Array.isArray(o) ? o : [o];
|
|
58
|
+
for (const f of c)
|
|
59
|
+
if (typeof f == "string") {
|
|
60
|
+
const y = v(f, n);
|
|
61
|
+
y && m(y) && (s = { ...s, ...y });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if ("..." in t) {
|
|
66
|
+
const o = t["..."], c = Array.isArray(o) ? o : [o];
|
|
67
|
+
let f = !1;
|
|
68
|
+
for (const y of c)
|
|
69
|
+
if (y === "^")
|
|
70
|
+
m(e) && (i = { ...i, ...e });
|
|
71
|
+
else if (typeof y == "string") {
|
|
72
|
+
const p = v(y, s);
|
|
73
|
+
m(p) ? i = { ...i, ...p } : f = !0;
|
|
74
|
+
}
|
|
75
|
+
f && Object.keys(s).length > 0 && (i["..."] = o);
|
|
76
|
+
}
|
|
77
|
+
const r = { ...i }, a = "__source" in t || Object.entries(t).some(
|
|
78
|
+
([o, c]) => o !== "..." && o !== "__source" && (c === "^" || typeof c == "string" && c.startsWith("{{") || m(c) && "..." in c)
|
|
79
|
+
);
|
|
80
|
+
for (const [o, c] of Object.entries(t))
|
|
81
|
+
if (!(o === "__source" || o === "...")) {
|
|
82
|
+
if (c === "^" || c === o) {
|
|
83
|
+
const f = v(o, s);
|
|
84
|
+
if (f !== void 0) {
|
|
85
|
+
r[o] = m(f) ? { ...f } : f;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (typeof c == "string" && a && s[c] !== void 0) {
|
|
90
|
+
const f = v(c, s);
|
|
91
|
+
if (f !== void 0 && m(f)) {
|
|
92
|
+
r[o] = { ...f };
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (m(c)) {
|
|
97
|
+
const f = m(r[o]) ? r[o] : {};
|
|
98
|
+
r[o] = S(f, c, s);
|
|
99
|
+
} else if (Array.isArray(c)) {
|
|
100
|
+
const f = Array.isArray(r[o]) ? r[o] : [];
|
|
101
|
+
r[o] = S(f, c, s);
|
|
102
|
+
} else
|
|
103
|
+
r[o] = c;
|
|
104
|
+
}
|
|
105
|
+
return r;
|
|
106
|
+
}
|
|
107
|
+
function V(e, t = {}, n = {}) {
|
|
108
|
+
let s = t;
|
|
109
|
+
for (const i of e)
|
|
110
|
+
s = S(s, i, n);
|
|
111
|
+
return s;
|
|
112
|
+
}
|
|
113
|
+
const Q = ["https:", "http:", "file:"], ct = [
|
|
114
|
+
"localhost",
|
|
115
|
+
"127.0.0.1",
|
|
116
|
+
"0.0.0.0",
|
|
117
|
+
"169.254.169.254",
|
|
118
|
+
// AWS metadata endpoint
|
|
119
|
+
"::1",
|
|
120
|
+
// IPv6 localhost
|
|
121
|
+
"metadata.google.internal"
|
|
122
|
+
// GCP metadata
|
|
123
|
+
];
|
|
124
|
+
function ft(e) {
|
|
125
|
+
try {
|
|
126
|
+
const t = new URL(e, window.location.href);
|
|
127
|
+
if (!Q.includes(t.protocol))
|
|
128
|
+
throw new Error(`Security: Blocked protocol "${t.protocol}" - only ${Q.join(", ")} allowed`);
|
|
129
|
+
const n = t.hostname.toLowerCase();
|
|
130
|
+
if (ct.some((s) => n === s || n.endsWith(`.${s}`)))
|
|
131
|
+
throw new Error(`Security: Blocked host "${t.hostname}" - potential SSRF attempt`);
|
|
132
|
+
if (n.startsWith("10.") || n.startsWith("192.168.") || /^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(n))
|
|
133
|
+
throw new Error(`Security: Blocked private IP address "${n}"`);
|
|
134
|
+
} catch (t) {
|
|
135
|
+
if (t.message.startsWith("Security:"))
|
|
136
|
+
throw t;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function et(e) {
|
|
141
|
+
ft(e);
|
|
142
|
+
const t = await fetch(e);
|
|
143
|
+
if (!t.ok) throw new Error(`Failed to load ${e}: ${t.statusText}`);
|
|
144
|
+
const n = await t.text();
|
|
145
|
+
return JSON.parse(n);
|
|
146
|
+
}
|
|
147
|
+
function nt(e) {
|
|
148
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
149
|
+
const t = e.bulkApply;
|
|
150
|
+
if (!Array.isArray(t) || t.length === 0) return e;
|
|
151
|
+
const { bulkApply: n, ...s } = e;
|
|
152
|
+
for (const i of t) {
|
|
153
|
+
if (!i || typeof i != "object" || Array.isArray(i)) {
|
|
154
|
+
x.warn("bulk-apply: entry must be an object, skipping");
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const { targets: r, ...a } = i;
|
|
158
|
+
if (!Array.isArray(r) || r.length === 0) {
|
|
159
|
+
x.warn("bulk-apply: entry missing targets array, skipping");
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (Object.keys(a).length === 0) {
|
|
163
|
+
x.warn("bulk-apply: entry has no properties to apply, skipping");
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
for (const o of r) {
|
|
167
|
+
if (typeof o != "string") {
|
|
168
|
+
x.warn(`bulk-apply: target must be a string, got ${typeof o}`);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const c = s[o];
|
|
172
|
+
if (c && typeof c == "object" && !Array.isArray(c))
|
|
173
|
+
s[o] = { ...c, ...a };
|
|
174
|
+
else if (c === void 0)
|
|
175
|
+
s[o] = { ...a };
|
|
176
|
+
else if (typeof c == "string") {
|
|
177
|
+
const f = c === "^" ? o : c;
|
|
178
|
+
s[o] = { "...": f, ...a };
|
|
179
|
+
} else
|
|
180
|
+
x.warn(`bulk-apply: target "${o}" is not an object definition, skipping`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
for (const [i, r] of Object.entries(s))
|
|
184
|
+
if (r && typeof r == "object" && !Array.isArray(r) && r.fields && typeof r.fields == "object") {
|
|
185
|
+
const a = nt(r.fields);
|
|
186
|
+
a !== r.fields && (s[i] = { ...r, fields: a });
|
|
187
|
+
}
|
|
188
|
+
return s;
|
|
189
|
+
}
|
|
190
|
+
function lt(e, t) {
|
|
191
|
+
if (!e || typeof e != "object" || !t || typeof t != "string") return;
|
|
192
|
+
let n = e;
|
|
193
|
+
for (const s of t.split(".")) {
|
|
194
|
+
if (n == null || typeof n != "object") return;
|
|
195
|
+
n = n[s];
|
|
196
|
+
}
|
|
197
|
+
return n;
|
|
198
|
+
}
|
|
199
|
+
function ut(e, t = {}) {
|
|
200
|
+
let n = e || {};
|
|
201
|
+
return n.default && (n = n.default), { ...n, ...t };
|
|
202
|
+
}
|
|
203
|
+
function dt(e, t = {}) {
|
|
204
|
+
const n = {};
|
|
205
|
+
for (const [s, i] of Object.entries(t)) {
|
|
206
|
+
const r = lt(e, s), a = n[i];
|
|
207
|
+
r && typeof r == "object" && !Array.isArray(r) ? n[i] = { ...a, ...r } : r !== void 0 ? n[i] = r : a || (n[i] = {});
|
|
208
|
+
}
|
|
209
|
+
return n;
|
|
210
|
+
}
|
|
211
|
+
function ht(e, t) {
|
|
212
|
+
const n = e.actions || {}, s = e.meta || {};
|
|
213
|
+
return {
|
|
214
|
+
buttonSet: n.buttonSet ?? s.buttonSet,
|
|
215
|
+
buttons: t.buttons || {},
|
|
216
|
+
hooks: t.hooks || {}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function st(e, t = {}) {
|
|
220
|
+
const { mapping: n = {}, functions: s = {} } = t, i = ut(e.functions, s), r = {};
|
|
221
|
+
for (const [y, p] of Object.entries(e))
|
|
222
|
+
r[y] = nt(p);
|
|
223
|
+
r.functions = i;
|
|
224
|
+
const a = dt(r, n), o = ht(r, a), c = r.meta || {}, f = r.record && Object.keys(r.record).length > 0 ? r.record : null;
|
|
225
|
+
return f && !c.initialRecord && (c.initialRecord = f), {
|
|
226
|
+
meta: c,
|
|
227
|
+
layout: r.layout || [],
|
|
228
|
+
registries: a,
|
|
229
|
+
actions: o,
|
|
230
|
+
styles: e.styles || null,
|
|
231
|
+
record: f,
|
|
232
|
+
state: r.state || {}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function pt(e, t) {
|
|
236
|
+
return !e || !t || typeof t != "object" ? e : B(e, t);
|
|
237
|
+
}
|
|
238
|
+
function B(e, t) {
|
|
239
|
+
if (typeof e == "string")
|
|
240
|
+
return Object.hasOwn(t, e) ? t[e] : e;
|
|
241
|
+
if (Array.isArray(e))
|
|
242
|
+
return e.map((n) => B(n, t));
|
|
243
|
+
if (e !== null && typeof e == "object") {
|
|
244
|
+
const n = {};
|
|
245
|
+
for (const s of Object.keys(e))
|
|
246
|
+
n[s] = B(e[s], t);
|
|
247
|
+
return n;
|
|
248
|
+
}
|
|
249
|
+
return e;
|
|
250
|
+
}
|
|
251
|
+
function N(...e) {
|
|
252
|
+
return Object.assign({}, ...e.filter(Boolean));
|
|
253
|
+
}
|
|
254
|
+
function _(e) {
|
|
255
|
+
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
256
|
+
}
|
|
257
|
+
function yt(e) {
|
|
258
|
+
if (!e.show) return e;
|
|
259
|
+
const { show: t, ...n } = e, s = {};
|
|
260
|
+
for (const [i, r] of Object.entries(n))
|
|
261
|
+
_(r) && !r.show ? s[i] = { ...r, show: t } : s[i] = r;
|
|
262
|
+
return s;
|
|
263
|
+
}
|
|
264
|
+
async function M(e, t) {
|
|
265
|
+
if (e == null || typeof e != "object")
|
|
266
|
+
return e;
|
|
267
|
+
if (Array.isArray(e)) {
|
|
268
|
+
const s = [];
|
|
269
|
+
for (const i of e)
|
|
270
|
+
s.push(await M(i, t));
|
|
271
|
+
return s;
|
|
272
|
+
}
|
|
273
|
+
if (e.__include) {
|
|
274
|
+
const s = e.__include, { __include: i, ...r } = e;
|
|
275
|
+
if (s.endsWith(".html") || s.endsWith(".htm")) {
|
|
276
|
+
try {
|
|
277
|
+
const o = await fetch(`${t}/${s}`);
|
|
278
|
+
if (o.ok)
|
|
279
|
+
return { component: "html", content: await o.text(), ...r };
|
|
280
|
+
} catch {
|
|
281
|
+
}
|
|
282
|
+
return Object.keys(r).length > 0 ? r : {};
|
|
283
|
+
}
|
|
284
|
+
const a = await g(t, s);
|
|
285
|
+
if (a) {
|
|
286
|
+
const o = await M(a, t), c = Object.keys(r).length > 0;
|
|
287
|
+
return _(o) && c ? { ...o, ...r } : o;
|
|
288
|
+
}
|
|
289
|
+
return Object.keys(r).length > 0 ? r : {};
|
|
290
|
+
}
|
|
291
|
+
const n = {};
|
|
292
|
+
for (const [s, i] of Object.entries(e))
|
|
293
|
+
n[s] = await M(i, t);
|
|
294
|
+
return n;
|
|
295
|
+
}
|
|
296
|
+
async function g(e, t) {
|
|
297
|
+
try {
|
|
298
|
+
return await et(`${e}/${t}`);
|
|
299
|
+
} catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async function mt(e) {
|
|
304
|
+
try {
|
|
305
|
+
return await et(`${e}/form.json`) || {};
|
|
306
|
+
} catch {
|
|
307
|
+
return {};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
function gt(e) {
|
|
311
|
+
const t = e.split("/").pop();
|
|
312
|
+
return !t || t === "." || t === "src" ? null : t.toLowerCase();
|
|
313
|
+
}
|
|
314
|
+
function bt(e) {
|
|
315
|
+
return `${e.split("/").slice(0, -2).join("/") || "."}/base`;
|
|
316
|
+
}
|
|
317
|
+
function X(e) {
|
|
318
|
+
const t = new Set(e), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
319
|
+
for (const i of e) {
|
|
320
|
+
if (i.includes("~")) {
|
|
321
|
+
const a = i.match(/~([a-z][a-z0-9]*)\.json$/);
|
|
322
|
+
a && s.add(a[1]);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const r = i.match(/^[a-z]+-([a-z][a-z0-9-]*)\.json$/);
|
|
326
|
+
r && n.add(r[1]);
|
|
327
|
+
}
|
|
328
|
+
return { files: t, patches: [...n].sort(), maps: [...s].sort() };
|
|
329
|
+
}
|
|
330
|
+
async function jt(e, t, n, s, i, r, a, o) {
|
|
331
|
+
var d;
|
|
332
|
+
const c = [], y = t && (!a || a.has(`${n}.json`)) ? await g(e, `${n}.json`) : null;
|
|
333
|
+
if (i[n] !== void 0 && c.push(await M(i[n], e)), y !== null && c.push(await M(y, e)), c.length === 0)
|
|
334
|
+
return q() && K("config", `load-property "${n}"`, "no files found (using default)", {
|
|
335
|
+
property: n,
|
|
336
|
+
basePath: e,
|
|
337
|
+
namespace: t,
|
|
338
|
+
hasSource: o !== void 0
|
|
339
|
+
}), o ?? r(n);
|
|
340
|
+
q() && K("config", `load-property "${n}"`, `${c.length} layer(s) found`, {
|
|
341
|
+
property: n,
|
|
342
|
+
layerCount: c.length,
|
|
343
|
+
hasConsolidated: i[n] !== void 0,
|
|
344
|
+
hasSource: o !== void 0,
|
|
345
|
+
namespace: t
|
|
346
|
+
});
|
|
347
|
+
let p = o ?? r(n), O = s;
|
|
348
|
+
_((d = s.base) == null ? void 0 : d[n]) && (O = { ...O, ...s.base[n] });
|
|
349
|
+
for (let R = 0; R < c.length; R++)
|
|
350
|
+
p = S(p, c[R], O), O = { ...O, [n]: p };
|
|
351
|
+
return p;
|
|
352
|
+
}
|
|
353
|
+
async function wt(e, t = {}) {
|
|
354
|
+
var E, z, J, U, H;
|
|
355
|
+
const { schema: n } = t;
|
|
356
|
+
if (!n)
|
|
357
|
+
throw new Error(
|
|
358
|
+
"loadJsonConfig requires options.schema. Pass a TLP schema from createTLPSchema(), or use the loadJsonConfig wrapper from @archduck/gst-forms."
|
|
359
|
+
);
|
|
360
|
+
const s = t.rootPath || bt(e), i = e, r = t.namespace || gt(e), [a, o] = await Promise.all([
|
|
361
|
+
mt(e),
|
|
362
|
+
t.manifest ? Promise.resolve(X(t.manifest)) : g(i, "manifest.json").then(
|
|
363
|
+
(u) => Array.isArray(u) ? X(u) : null
|
|
364
|
+
)
|
|
365
|
+
]), c = { ...t.scope }, f = {};
|
|
366
|
+
let y = (E = a.meta) == null ? void 0 : E.source;
|
|
367
|
+
if (!y && r) {
|
|
368
|
+
const u = !o || o != null && o.files.has("meta.json") ? await g(i, "meta.json") : null;
|
|
369
|
+
u != null && u.source && (y = u.source);
|
|
370
|
+
}
|
|
371
|
+
let p = null;
|
|
372
|
+
if (y) {
|
|
373
|
+
const u = t.scope || {};
|
|
374
|
+
if (typeof y == "string")
|
|
375
|
+
p = u[y] || null;
|
|
376
|
+
else if (_(y)) {
|
|
377
|
+
p = {};
|
|
378
|
+
for (const [l, A] of Object.entries(y)) {
|
|
379
|
+
const P = u[l];
|
|
380
|
+
if (P)
|
|
381
|
+
for (const b of Array.isArray(A) ? A : [])
|
|
382
|
+
P[b] !== void 0 && (p[b] = P[b]);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const O = await Promise.all(
|
|
387
|
+
n.resolutionOrder.map(
|
|
388
|
+
(u) => jt(i, r, u, c, a, n.getDefault, o == null ? void 0 : o.files, p == null ? void 0 : p[u])
|
|
389
|
+
)
|
|
390
|
+
);
|
|
391
|
+
for (let u = 0; u < n.resolutionOrder.length; u++)
|
|
392
|
+
f[n.resolutionOrder[u]] = O[u];
|
|
393
|
+
const d = _(a.patches) ? a.patches : await g(i, "patches.json") || {}, R = Array.isArray((z = f.meta) == null ? void 0 : z.patches) ? f.meta.patches : o ? o.patches : [], ot = Array.isArray(t.patches) ? t.patches : [], F = [...R, ...ot];
|
|
394
|
+
if (F.length > 0) {
|
|
395
|
+
let u = { ...t.scope };
|
|
396
|
+
for (const l of n.resolutionOrder)
|
|
397
|
+
p != null && p[l] && _(p[l]) && ((J = n.declarations[l]) != null && J.registry) && (u = { ...u, ...p[l] }), f[l] && (u[l] = f[l], _(f[l]) && ((U = n.declarations[l]) != null && U.registry) && (u = { ...u, ...f[l] }));
|
|
398
|
+
for (const l of F) {
|
|
399
|
+
const [A, ...P] = await Promise.all([
|
|
400
|
+
!o || o.files.has(`form-${l}.json`) ? g(i, `form-${l}.json`) : Promise.resolve(null),
|
|
401
|
+
...n.resolutionOrder.map(
|
|
402
|
+
(j) => !o || o.files.has(`${j}-${l}.json`) ? g(i, `${j}-${l}.json`) : Promise.resolve(null)
|
|
403
|
+
)
|
|
404
|
+
]), b = d[l] || null;
|
|
405
|
+
let T = !1;
|
|
406
|
+
for (let j = 0; j < n.resolutionOrder.length; j++) {
|
|
407
|
+
const w = n.resolutionOrder[j];
|
|
408
|
+
let $ = P[j];
|
|
409
|
+
if (!$ && (A == null ? void 0 : A[w]) !== void 0 && ($ = A[w]), !$ && (b == null ? void 0 : b[w]) !== void 0 && ($ = b[w]), !$) continue;
|
|
410
|
+
T = !0;
|
|
411
|
+
const L = await M($, i), W = _(L) ? yt(L) : L;
|
|
412
|
+
f[w] = S(f[w], W, u), u = { ...u, [w]: f[w] };
|
|
413
|
+
}
|
|
414
|
+
!T && Array.isArray((H = f.meta) == null ? void 0 : H.patches) && f.meta.patches.includes(l) && console.warn(
|
|
415
|
+
`[gst] meta.patches declares "${l}" but no patch files were found (expected files like fields-${l}.json, layout-${l}.json, etc.)`
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (t.map) {
|
|
420
|
+
const u = _(a.maps) ? a.maps : await g(i, "maps.json") || {}, l = [], A = u[t.map] || null;
|
|
421
|
+
A && l.push(A);
|
|
422
|
+
const P = [
|
|
423
|
+
g(s, `form~${t.map}.json`),
|
|
424
|
+
...r ? [
|
|
425
|
+
!o || o.files.has(`form~${t.map}.json`) ? g(i, `form~${t.map}.json`) : Promise.resolve(null)
|
|
426
|
+
] : [],
|
|
427
|
+
...r ? F.map(
|
|
428
|
+
(h) => !o || o.files.has(`form-${h}~${t.map}.json`) ? g(i, `form-${h}~${t.map}.json`) : Promise.resolve(null)
|
|
429
|
+
) : []
|
|
430
|
+
], b = n.resolutionOrder.filter(
|
|
431
|
+
(h) => f[h] && typeof f[h] == "object"
|
|
432
|
+
), T = b.flatMap((h) => [
|
|
433
|
+
g(s, `${h}~${t.map}.json`),
|
|
434
|
+
...r ? [
|
|
435
|
+
!o || o.files.has(`${h}~${t.map}.json`) ? g(i, `${h}~${t.map}.json`) : Promise.resolve(null)
|
|
436
|
+
] : []
|
|
437
|
+
]), [j, w] = await Promise.all([
|
|
438
|
+
Promise.all(P),
|
|
439
|
+
Promise.all(T)
|
|
440
|
+
]), $ = j[0];
|
|
441
|
+
if ($ && l.push($), r) {
|
|
442
|
+
const h = j[1];
|
|
443
|
+
h && l.push(h);
|
|
444
|
+
for (let C = 0; C < F.length; C++) {
|
|
445
|
+
const k = j[2 + C];
|
|
446
|
+
k && l.push(k);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const L = {}, W = r ? 2 : 1;
|
|
450
|
+
for (let h = 0; h < b.length; h++) {
|
|
451
|
+
const C = b[h], k = [], I = w[h * W];
|
|
452
|
+
if (I && k.push(I), r) {
|
|
453
|
+
const G = w[h * W + 1];
|
|
454
|
+
G && k.push(G);
|
|
455
|
+
}
|
|
456
|
+
k.length > 0 && (L[C] = k.length === 1 ? k[0] : N(...k));
|
|
457
|
+
}
|
|
458
|
+
const D = l.length === 0 ? {} : l.length === 1 ? l[0] : N(...l);
|
|
459
|
+
for (const h of n.resolutionOrder) {
|
|
460
|
+
if (!f[h] || typeof f[h] != "object") continue;
|
|
461
|
+
const C = L[h] ? N(D, L[h]) : Object.keys(D).length > 0 ? D : null;
|
|
462
|
+
C && (f[h] = pt(f[h], C));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return st(f, {
|
|
466
|
+
mapping: n.registryMapping,
|
|
467
|
+
functions: t.functions
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
const At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
471
|
+
__proto__: null,
|
|
472
|
+
loadJsonConfig: wt
|
|
473
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
474
|
+
function Y(e, t, n, s = {}) {
|
|
475
|
+
const i = { ...s }, r = n.resolutionOrder.indexOf(e);
|
|
476
|
+
for (let a = 0; a < r; a++) {
|
|
477
|
+
const o = n.resolutionOrder[a];
|
|
478
|
+
t[o] !== void 0 && (i[o] = t[o]);
|
|
479
|
+
}
|
|
480
|
+
return i;
|
|
481
|
+
}
|
|
482
|
+
function Z(e, t) {
|
|
483
|
+
return t.resolutionOrder.filter(
|
|
484
|
+
(n) => {
|
|
485
|
+
var s;
|
|
486
|
+
return (s = t.dependencies[n]) == null ? void 0 : s.includes(e);
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
function tt(e) {
|
|
491
|
+
var t, n, s, i;
|
|
492
|
+
return {
|
|
493
|
+
functions: ((t = e.registries) == null ? void 0 : t.functions) || {},
|
|
494
|
+
optionSets: ((n = e.registries) == null ? void 0 : n.optionSets) || {},
|
|
495
|
+
actions: e.actions || {},
|
|
496
|
+
fields: ((s = e.registries) == null ? void 0 : s.fields) || {},
|
|
497
|
+
components: ((i = e.registries) == null ? void 0 : i.components) || {},
|
|
498
|
+
meta: e.meta || {},
|
|
499
|
+
layout: e.layout || [],
|
|
500
|
+
record: e.record || {},
|
|
501
|
+
styles: e.styles || null
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
class Ot {
|
|
505
|
+
/**
|
|
506
|
+
* @param {Object} options
|
|
507
|
+
* @param {Object} options.schema - TLP schema (from createTLPSchema). Required.
|
|
508
|
+
*/
|
|
509
|
+
constructor(t = {}) {
|
|
510
|
+
if (!t.schema)
|
|
511
|
+
throw new Error(
|
|
512
|
+
"LiveConfig requires options.schema. Pass a TLP schema from createTLPSchema(), or use the LiveConfig wrapper from @archduck/gst-forms."
|
|
513
|
+
);
|
|
514
|
+
this.schema = t.schema, this.loaded = {}, this.stdlib = null, this.options = {}, this._cachedConfig = null;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Load initial configuration from a path
|
|
518
|
+
* Delegates to namespaceLoader's loadJsonConfig
|
|
519
|
+
*/
|
|
520
|
+
async load(t, n = {}) {
|
|
521
|
+
var r;
|
|
522
|
+
const { loadJsonConfig: s } = await Promise.resolve().then(() => At);
|
|
523
|
+
this.stdlib = ((r = n.scope) == null ? void 0 : r.stdlib) || {}, this.options = n;
|
|
524
|
+
const i = await s(t, { ...n, schema: this.schema });
|
|
525
|
+
return this.loaded = tt(i), this._cachedConfig = i, this;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Initialize from a pre-built config object
|
|
529
|
+
* Use this when you've already assembled a config (e.g., from JSON imports)
|
|
530
|
+
*/
|
|
531
|
+
from(t, n = {}) {
|
|
532
|
+
return this.stdlib = n.stdlib || {}, this.options = n, this.loaded = tt(t), this._cachedConfig = t, this;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Apply a patch to a single property
|
|
536
|
+
* Re-resolves the property and any dependents
|
|
537
|
+
*/
|
|
538
|
+
patch(t, n) {
|
|
539
|
+
if (!this.schema.resolutionOrder.includes(t))
|
|
540
|
+
throw new Error(`Unknown property: ${t}. Must be one of: ${this.schema.resolutionOrder.join(", ")}`);
|
|
541
|
+
const s = Y(t, this.loaded, this.schema, { stdlib: this.stdlib }), i = this.loaded[t] || this.schema.getDefault(t), r = V([i, n], this.schema.getDefault(t), s);
|
|
542
|
+
this.loaded[t] = r;
|
|
543
|
+
for (const a of Z(t, this.schema))
|
|
544
|
+
this._reResolve(a);
|
|
545
|
+
return this._cachedConfig = null, this;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Re-resolve a property against current scope
|
|
549
|
+
* Used after a dependency changes
|
|
550
|
+
*/
|
|
551
|
+
_reResolve(t) {
|
|
552
|
+
const n = Y(t, this.loaded, this.schema, { stdlib: this.stdlib }), s = this.loaded[t];
|
|
553
|
+
s !== void 0 && (this.loaded[t] = V([s], this.schema.getDefault(t), n));
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Get the current resolved configuration
|
|
557
|
+
*/
|
|
558
|
+
get() {
|
|
559
|
+
return this._cachedConfig ? this._cachedConfig : (this._cachedConfig = st(this.loaded, {
|
|
560
|
+
mapping: this.schema.registryMapping,
|
|
561
|
+
functions: this.options.functions
|
|
562
|
+
}), this._cachedConfig);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Get a specific property's current value
|
|
566
|
+
*/
|
|
567
|
+
getProperty(t) {
|
|
568
|
+
return this.loaded[t];
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Replace a property entirely (no merge)
|
|
572
|
+
*/
|
|
573
|
+
set(t, n) {
|
|
574
|
+
if (!this.schema.resolutionOrder.includes(t))
|
|
575
|
+
throw new Error(`Unknown property: ${t}`);
|
|
576
|
+
this.loaded[t] = n;
|
|
577
|
+
for (const s of Z(t, this.schema))
|
|
578
|
+
this._reResolve(s);
|
|
579
|
+
return this._cachedConfig = null, this;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function $t(e = {}) {
|
|
583
|
+
return new Ot(e);
|
|
584
|
+
}
|
|
585
|
+
async function _t(e, t = {}) {
|
|
586
|
+
const n = $t({ schema: t.schema });
|
|
587
|
+
return await n.load(e, t), n;
|
|
588
|
+
}
|
|
589
|
+
export {
|
|
590
|
+
Ot as L,
|
|
591
|
+
pt as a,
|
|
592
|
+
st as b,
|
|
593
|
+
Y as c,
|
|
594
|
+
$t as d,
|
|
595
|
+
ht as e,
|
|
596
|
+
tt as f,
|
|
597
|
+
Z as g,
|
|
598
|
+
lt as h,
|
|
599
|
+
wt as i,
|
|
600
|
+
_t as j,
|
|
601
|
+
N as k,
|
|
602
|
+
et as l,
|
|
603
|
+
dt as m,
|
|
604
|
+
nt as p
|
|
605
|
+
};
|
|
606
|
+
//# sourceMappingURL=loaders-B7J79C97.js.map
|