@brightsideoy/kama 0.1.0-alpha.63 → 0.1.0-alpha.64
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/dist/assets/{index-BLtwZM_Q.js → index-BwhzZuhD.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +489 -370
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -140,66 +140,66 @@ function T(e) {
|
|
|
140
140
|
}
|
|
141
141
|
return !1;
|
|
142
142
|
}
|
|
143
|
-
var E = (e) => (S(e) || w(e)) && !!e.anchor, D = Symbol("break visit"),
|
|
144
|
-
function
|
|
145
|
-
let n =
|
|
146
|
-
y(e) ?
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function
|
|
150
|
-
let i =
|
|
151
|
-
if (T(i) || x(i)) return
|
|
143
|
+
var E = (e) => (S(e) || w(e)) && !!e.anchor, D = Symbol("break visit"), ee = Symbol("skip children"), O = Symbol("remove node");
|
|
144
|
+
function k(e, t) {
|
|
145
|
+
let n = re(t);
|
|
146
|
+
y(e) ? A(null, e.contents, n, Object.freeze([e])) === O && (e.contents = null) : A(null, e, n, Object.freeze([]));
|
|
147
|
+
}
|
|
148
|
+
k.BREAK = D, k.SKIP = ee, k.REMOVE = O;
|
|
149
|
+
function A(e, t, n, r) {
|
|
150
|
+
let i = ie(e, t, n, r);
|
|
151
|
+
if (T(i) || x(i)) return ae(e, r, i), A(e, i, n, r);
|
|
152
152
|
if (typeof i != "symbol") {
|
|
153
153
|
if (w(t)) {
|
|
154
154
|
r = Object.freeze(r.concat(t));
|
|
155
155
|
for (let e = 0; e < t.items.length; ++e) {
|
|
156
|
-
let i =
|
|
156
|
+
let i = A(e, t.items[e], n, r);
|
|
157
157
|
if (typeof i == "number") e = i - 1;
|
|
158
158
|
else if (i === D) return D;
|
|
159
|
-
else i ===
|
|
159
|
+
else i === O && (t.items.splice(e, 1), --e);
|
|
160
160
|
}
|
|
161
161
|
} else if (x(t)) {
|
|
162
162
|
r = Object.freeze(r.concat(t));
|
|
163
|
-
let e =
|
|
163
|
+
let e = A("key", t.key, n, r);
|
|
164
164
|
if (e === D) return D;
|
|
165
|
-
e ===
|
|
166
|
-
let i =
|
|
165
|
+
e === O && (t.key = null);
|
|
166
|
+
let i = A("value", t.value, n, r);
|
|
167
167
|
if (i === D) return D;
|
|
168
|
-
i ===
|
|
168
|
+
i === O && (t.value = null);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
return i;
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
let n =
|
|
175
|
-
y(e) ? await
|
|
173
|
+
async function te(e, t) {
|
|
174
|
+
let n = re(t);
|
|
175
|
+
y(e) ? await ne(null, e.contents, n, Object.freeze([e])) === O && (e.contents = null) : await ne(null, e, n, Object.freeze([]));
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
async function
|
|
179
|
-
let i = await
|
|
180
|
-
if (T(i) || x(i)) return
|
|
177
|
+
te.BREAK = D, te.SKIP = ee, te.REMOVE = O;
|
|
178
|
+
async function ne(e, t, n, r) {
|
|
179
|
+
let i = await ie(e, t, n, r);
|
|
180
|
+
if (T(i) || x(i)) return ae(e, r, i), ne(e, i, n, r);
|
|
181
181
|
if (typeof i != "symbol") {
|
|
182
182
|
if (w(t)) {
|
|
183
183
|
r = Object.freeze(r.concat(t));
|
|
184
184
|
for (let e = 0; e < t.items.length; ++e) {
|
|
185
|
-
let i = await
|
|
185
|
+
let i = await ne(e, t.items[e], n, r);
|
|
186
186
|
if (typeof i == "number") e = i - 1;
|
|
187
187
|
else if (i === D) return D;
|
|
188
|
-
else i ===
|
|
188
|
+
else i === O && (t.items.splice(e, 1), --e);
|
|
189
189
|
}
|
|
190
190
|
} else if (x(t)) {
|
|
191
191
|
r = Object.freeze(r.concat(t));
|
|
192
|
-
let e = await
|
|
192
|
+
let e = await ne("key", t.key, n, r);
|
|
193
193
|
if (e === D) return D;
|
|
194
|
-
e ===
|
|
195
|
-
let i = await
|
|
194
|
+
e === O && (t.key = null);
|
|
195
|
+
let i = await ne("value", t.value, n, r);
|
|
196
196
|
if (i === D) return D;
|
|
197
|
-
i ===
|
|
197
|
+
i === O && (t.value = null);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
return i;
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function re(e) {
|
|
203
203
|
return typeof e == "object" && (e.Collection || e.Node || e.Value) ? Object.assign({
|
|
204
204
|
Alias: e.Node,
|
|
205
205
|
Map: e.Node,
|
|
@@ -214,7 +214,7 @@ function ne(e) {
|
|
|
214
214
|
Seq: e.Collection
|
|
215
215
|
}, e) : e;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function ie(e, t, n, r) {
|
|
218
218
|
if (typeof n == "function") return n(e, t, r);
|
|
219
219
|
if (b(t)) return n.Map?.(e, t, r);
|
|
220
220
|
if (C(t)) return n.Seq?.(e, t, r);
|
|
@@ -222,7 +222,7 @@ function re(e, t, n, r) {
|
|
|
222
222
|
if (S(t)) return n.Scalar?.(e, t, r);
|
|
223
223
|
if (v(t)) return n.Alias?.(e, t, r);
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function ae(e, t, n) {
|
|
226
226
|
let r = t[t.length - 1];
|
|
227
227
|
if (w(r)) r.items[e] = n;
|
|
228
228
|
else if (x(r)) e === "key" ? r.key = n : r.value = n;
|
|
@@ -234,14 +234,14 @@ function M(e, t, n) {
|
|
|
234
234
|
}
|
|
235
235
|
//#endregion
|
|
236
236
|
//#region node_modules/yaml/browser/dist/doc/directives.js
|
|
237
|
-
var
|
|
237
|
+
var j = {
|
|
238
238
|
"!": "%21",
|
|
239
239
|
",": "%2C",
|
|
240
240
|
"[": "%5B",
|
|
241
241
|
"]": "%5D",
|
|
242
242
|
"{": "%7B",
|
|
243
243
|
"}": "%7D"
|
|
244
|
-
},
|
|
244
|
+
}, oe = (e) => e.replace(/[!,[\]{}]/g, (e) => j[e]), se = class e {
|
|
245
245
|
constructor(t, n) {
|
|
246
246
|
this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, e.defaultYaml, t), this.tags = Object.assign({}, e.defaultTags, n);
|
|
247
247
|
}
|
|
@@ -304,14 +304,14 @@ var ie = {
|
|
|
304
304
|
return n === "!" ? e : (t(`Could not resolve tag: ${e}`), null);
|
|
305
305
|
}
|
|
306
306
|
tagString(e) {
|
|
307
|
-
for (let [t, n] of Object.entries(this.tags)) if (e.startsWith(n)) return t +
|
|
307
|
+
for (let [t, n] of Object.entries(this.tags)) if (e.startsWith(n)) return t + oe(e.substring(n.length));
|
|
308
308
|
return e[0] === "!" ? e : `!<${e}>`;
|
|
309
309
|
}
|
|
310
310
|
toString(e) {
|
|
311
311
|
let t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], n = Object.entries(this.tags), r;
|
|
312
312
|
if (e && n.length > 0 && T(e.contents)) {
|
|
313
313
|
let t = {};
|
|
314
|
-
|
|
314
|
+
k(e.contents, (e, n) => {
|
|
315
315
|
T(n) && n.tag && (t[n.tag] = !0);
|
|
316
316
|
}), r = Object.keys(t);
|
|
317
317
|
} else r = [];
|
|
@@ -319,37 +319,37 @@ var ie = {
|
|
|
319
319
|
return t.join("\n");
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
|
-
|
|
322
|
+
se.defaultYaml = {
|
|
323
323
|
explicit: !1,
|
|
324
324
|
version: "1.2"
|
|
325
|
-
},
|
|
325
|
+
}, se.defaultTags = { "!!": "tag:yaml.org,2002:" };
|
|
326
326
|
//#endregion
|
|
327
327
|
//#region node_modules/yaml/browser/dist/doc/anchors.js
|
|
328
|
-
function
|
|
328
|
+
function ce(e) {
|
|
329
329
|
if (/[\x00-\x19\s,[\]{}]/.test(e)) {
|
|
330
330
|
let t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;
|
|
331
331
|
throw Error(t);
|
|
332
332
|
}
|
|
333
333
|
return !0;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function le(e) {
|
|
336
336
|
let t = /* @__PURE__ */ new Set();
|
|
337
|
-
return
|
|
337
|
+
return k(e, { Value(e, n) {
|
|
338
338
|
n.anchor && t.add(n.anchor);
|
|
339
339
|
} }), t;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function ue(e, t) {
|
|
342
342
|
for (let n = 1;; ++n) {
|
|
343
343
|
let r = `${e}${n}`;
|
|
344
344
|
if (!t.has(r)) return r;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function M(e, t) {
|
|
348
348
|
let n = [], r = /* @__PURE__ */ new Map(), i = null;
|
|
349
349
|
return {
|
|
350
350
|
onAnchor: (r) => {
|
|
351
|
-
n.push(r), i ??=
|
|
352
|
-
let a =
|
|
351
|
+
n.push(r), i ??= le(e);
|
|
352
|
+
let a = ue(t, i);
|
|
353
353
|
return i.add(a), a;
|
|
354
354
|
},
|
|
355
355
|
setAnchors: () => {
|
|
@@ -367,22 +367,22 @@ function le(e, t) {
|
|
|
367
367
|
}
|
|
368
368
|
//#endregion
|
|
369
369
|
//#region node_modules/yaml/browser/dist/doc/applyReviver.js
|
|
370
|
-
function
|
|
370
|
+
function N(e, t, n, r) {
|
|
371
371
|
if (r && typeof r == "object") {
|
|
372
372
|
if (Array.isArray(r)) for (let t = 0, n = r.length; t < n; ++t) {
|
|
373
|
-
let n = r[t], i =
|
|
373
|
+
let n = r[t], i = N(e, r, String(t), n);
|
|
374
374
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
375
375
|
}
|
|
376
376
|
else if (r instanceof Map) for (let t of Array.from(r.keys())) {
|
|
377
|
-
let n = r.get(t), i =
|
|
377
|
+
let n = r.get(t), i = N(e, r, t, n);
|
|
378
378
|
i === void 0 ? r.delete(t) : i !== n && r.set(t, i);
|
|
379
379
|
}
|
|
380
380
|
else if (r instanceof Set) for (let t of Array.from(r)) {
|
|
381
|
-
let n =
|
|
381
|
+
let n = N(e, r, t, t);
|
|
382
382
|
n === void 0 ? r.delete(t) : n !== t && (r.delete(t), r.add(n));
|
|
383
383
|
}
|
|
384
384
|
else for (let [t, n] of Object.entries(r)) {
|
|
385
|
-
let i =
|
|
385
|
+
let i = N(e, r, t, n);
|
|
386
386
|
i === void 0 ? delete r[t] : i !== n && (r[t] = i);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -390,8 +390,8 @@ function P(e, t, n, r) {
|
|
|
390
390
|
}
|
|
391
391
|
//#endregion
|
|
392
392
|
//#region node_modules/yaml/browser/dist/nodes/toJS.js
|
|
393
|
-
function
|
|
394
|
-
if (Array.isArray(e)) return e.map((e, t) =>
|
|
393
|
+
function P(e, t, n) {
|
|
394
|
+
if (Array.isArray(e)) return e.map((e, t) => P(e, String(t), n));
|
|
395
395
|
if (e && typeof e.toJSON == "function") {
|
|
396
396
|
if (!n || !E(e)) return e.toJSON(t, n);
|
|
397
397
|
let r = {
|
|
@@ -409,7 +409,7 @@ function F(e, t, n) {
|
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
411
|
//#region node_modules/yaml/browser/dist/nodes/Node.js
|
|
412
|
-
var
|
|
412
|
+
var F = class {
|
|
413
413
|
constructor(e) {
|
|
414
414
|
Object.defineProperty(this, _, { value: e });
|
|
415
415
|
}
|
|
@@ -426,11 +426,11 @@ var ue = class {
|
|
|
426
426
|
mapAsMap: t === !0,
|
|
427
427
|
mapKeyWarned: !1,
|
|
428
428
|
maxAliasCount: typeof n == "number" ? n : 100
|
|
429
|
-
}, o =
|
|
429
|
+
}, o = P(this, "", a);
|
|
430
430
|
if (typeof r == "function") for (let { count: e, res: t } of a.anchors.values()) r(t, e);
|
|
431
|
-
return typeof i == "function" ?
|
|
431
|
+
return typeof i == "function" ? N(i, { "": o }, "", o) : o;
|
|
432
432
|
}
|
|
433
|
-
}, de = class extends
|
|
433
|
+
}, de = class extends F {
|
|
434
434
|
constructor(e) {
|
|
435
435
|
super(d), this.source = e, Object.defineProperty(this, "tag", { set() {
|
|
436
436
|
throw Error("Alias nodes cannot have tags");
|
|
@@ -439,7 +439,7 @@ var ue = class {
|
|
|
439
439
|
resolve(e, t) {
|
|
440
440
|
if (t?.maxAliasCount === 0) throw ReferenceError("Alias resolution is disabled");
|
|
441
441
|
let n;
|
|
442
|
-
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [],
|
|
442
|
+
t?.aliasResolveCache ? n = t.aliasResolveCache : (n = [], k(e, { Node: (e, t) => {
|
|
443
443
|
(v(t) || E(t)) && n.push(t);
|
|
444
444
|
} }), t && (t.aliasResolveCache = n));
|
|
445
445
|
let r;
|
|
@@ -458,14 +458,14 @@ var ue = class {
|
|
|
458
458
|
}
|
|
459
459
|
let o = n.get(a);
|
|
460
460
|
/* istanbul ignore if */
|
|
461
|
-
if (o ||= (
|
|
461
|
+
if (o ||= (P(a, null, t), n.get(a)), o?.res === void 0) throw ReferenceError("This should not happen: Alias anchor was not resolved?");
|
|
462
462
|
if (i >= 0 && (o.count += 1, o.aliasCount === 0 && (o.aliasCount = fe(r, a, n)), o.count * o.aliasCount > i)) throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");
|
|
463
463
|
return o.res;
|
|
464
464
|
}
|
|
465
465
|
toString(e, t, n) {
|
|
466
466
|
let r = `*${this.source}`;
|
|
467
467
|
if (e) {
|
|
468
|
-
if (
|
|
468
|
+
if (ce(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
469
469
|
let e = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
470
470
|
throw Error(e);
|
|
471
471
|
}
|
|
@@ -495,12 +495,12 @@ function fe(e, t, n) {
|
|
|
495
495
|
}
|
|
496
496
|
//#endregion
|
|
497
497
|
//#region node_modules/yaml/browser/dist/nodes/Scalar.js
|
|
498
|
-
var pe = (e) => !e || typeof e != "function" && typeof e != "object", I = class extends
|
|
498
|
+
var pe = (e) => !e || typeof e != "function" && typeof e != "object", I = class extends F {
|
|
499
499
|
constructor(e) {
|
|
500
500
|
super(h), this.value = e;
|
|
501
501
|
}
|
|
502
502
|
toJSON(e, t) {
|
|
503
|
-
return t?.keep ? this.value :
|
|
503
|
+
return t?.keep ? this.value : P(this.value, e, t);
|
|
504
504
|
}
|
|
505
505
|
toString() {
|
|
506
506
|
return String(this.value);
|
|
@@ -567,7 +567,7 @@ function _e(e, t, n) {
|
|
|
567
567
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
|
-
var ve = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next().done, ye = class extends
|
|
570
|
+
var ve = (e) => e == null || typeof e == "object" && !!e[Symbol.iterator]().next().done, ye = class extends F {
|
|
571
571
|
constructor(e, t) {
|
|
572
572
|
super(e), Object.defineProperty(this, "schema", {
|
|
573
573
|
value: t,
|
|
@@ -911,7 +911,7 @@ function Re(e, t) {
|
|
|
911
911
|
function ze(e, t, { anchors: n, doc: r }) {
|
|
912
912
|
if (!r.directives) return "";
|
|
913
913
|
let i = [], a = (S(e) || w(e)) && e.anchor;
|
|
914
|
-
a &&
|
|
914
|
+
a && ce(a) && (n.add(a), i.push(`&${a}`));
|
|
915
915
|
let o = e.tag ?? (t.default ? null : t.tag);
|
|
916
916
|
return o && i.push(r.directives.tagString(o)), i.join(" ");
|
|
917
917
|
}
|
|
@@ -1016,11 +1016,11 @@ function Je(e, t, { key: n, value: r }) {
|
|
|
1016
1016
|
if (T(n) && n.addToJSMap) n.addToJSMap(e, t, r);
|
|
1017
1017
|
else if (We(e, n)) Ge(e, t, r);
|
|
1018
1018
|
else {
|
|
1019
|
-
let i =
|
|
1020
|
-
if (t instanceof Map) t.set(i,
|
|
1019
|
+
let i = P(n, "", e);
|
|
1020
|
+
if (t instanceof Map) t.set(i, P(r, i, e));
|
|
1021
1021
|
else if (t instanceof Set) t.add(i);
|
|
1022
1022
|
else {
|
|
1023
|
-
let a = Ye(n, i, e), o =
|
|
1023
|
+
let a = Ye(n, i, e), o = P(r, a, e);
|
|
1024
1024
|
a in t ? Object.defineProperty(t, a, {
|
|
1025
1025
|
value: o,
|
|
1026
1026
|
writable: !0,
|
|
@@ -1252,7 +1252,7 @@ var B = class extends ye {
|
|
|
1252
1252
|
let n = [];
|
|
1253
1253
|
t?.onCreate && t.onCreate(n);
|
|
1254
1254
|
let r = 0;
|
|
1255
|
-
for (let e of this.items) n.push(
|
|
1255
|
+
for (let e of this.items) n.push(P(e, String(r++), t));
|
|
1256
1256
|
return n;
|
|
1257
1257
|
}
|
|
1258
1258
|
toString(e, t, n) {
|
|
@@ -1550,7 +1550,7 @@ var Tt = {
|
|
|
1550
1550
|
t?.onCreate && t.onCreate(n);
|
|
1551
1551
|
for (let e of this.items) {
|
|
1552
1552
|
let r, i;
|
|
1553
|
-
if (x(e) ? (r =
|
|
1553
|
+
if (x(e) ? (r = P(e.key, "", t), i = P(e.value, r, t)) : r = P(e, "", t), n.has(r)) throw Error("Ordered maps must not include duplicate keys");
|
|
1554
1554
|
n.set(r, i);
|
|
1555
1555
|
}
|
|
1556
1556
|
return n;
|
|
@@ -1926,7 +1926,7 @@ var nn = class e {
|
|
|
1926
1926
|
}, n);
|
|
1927
1927
|
this.options = i;
|
|
1928
1928
|
let { version: a } = i;
|
|
1929
|
-
n?._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (a = this.directives.yaml.version)) : this.directives = new
|
|
1929
|
+
n?._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (a = this.directives.yaml.version)) : this.directives = new se({ version: a }), this.setSchema(a, n), this.contents = e === void 0 ? null : this.createNode(e, r, n);
|
|
1930
1930
|
}
|
|
1931
1931
|
clone() {
|
|
1932
1932
|
let t = Object.create(e.prototype, { [_]: { value: f } });
|
|
@@ -1940,8 +1940,8 @@ var nn = class e {
|
|
|
1940
1940
|
}
|
|
1941
1941
|
createAlias(e, t) {
|
|
1942
1942
|
if (!e.anchor) {
|
|
1943
|
-
let n =
|
|
1944
|
-
e.anchor = !t || n.has(t) ?
|
|
1943
|
+
let n = le(this);
|
|
1944
|
+
e.anchor = !t || n.has(t) ? ue(t || "a", n) : t;
|
|
1945
1945
|
}
|
|
1946
1946
|
return new de(e.anchor);
|
|
1947
1947
|
}
|
|
@@ -1952,7 +1952,7 @@ var nn = class e {
|
|
|
1952
1952
|
let e = t.filter((e) => typeof e == "number" || e instanceof String || e instanceof Number).map(String);
|
|
1953
1953
|
e.length > 0 && (t = t.concat(e)), r = t;
|
|
1954
1954
|
} else n === void 0 && t && (n = t, t = void 0);
|
|
1955
|
-
let { aliasDuplicateObjects: i, anchorPrefix: a, flow: o, keepUndefined: s, onTagObj: c, tag: l } = n ?? {}, { onAnchor: u, setAnchors: d, sourceObjects: f } =
|
|
1955
|
+
let { aliasDuplicateObjects: i, anchorPrefix: a, flow: o, keepUndefined: s, onTagObj: c, tag: l } = n ?? {}, { onAnchor: u, setAnchors: d, sourceObjects: f } = M(this, a || "a"), p = {
|
|
1956
1956
|
aliasDuplicateObjects: i ?? !0,
|
|
1957
1957
|
keepUndefined: s ?? !1,
|
|
1958
1958
|
onAnchor: u,
|
|
@@ -1995,14 +1995,14 @@ var nn = class e {
|
|
|
1995
1995
|
let n;
|
|
1996
1996
|
switch (e) {
|
|
1997
1997
|
case "1.1":
|
|
1998
|
-
this.directives ? this.directives.yaml.version = "1.1" : this.directives = new
|
|
1998
|
+
this.directives ? this.directives.yaml.version = "1.1" : this.directives = new se({ version: "1.1" }), n = {
|
|
1999
1999
|
resolveKnownTags: !1,
|
|
2000
2000
|
schema: "yaml-1.1"
|
|
2001
2001
|
};
|
|
2002
2002
|
break;
|
|
2003
2003
|
case "1.2":
|
|
2004
2004
|
case "next":
|
|
2005
|
-
this.directives ? this.directives.yaml.version = e : this.directives = new
|
|
2005
|
+
this.directives ? this.directives.yaml.version = e : this.directives = new se({ version: e }), n = {
|
|
2006
2006
|
resolveKnownTags: !0,
|
|
2007
2007
|
schema: "core"
|
|
2008
2008
|
};
|
|
@@ -2027,9 +2027,9 @@ var nn = class e {
|
|
|
2027
2027
|
mapAsMap: n === !0,
|
|
2028
2028
|
mapKeyWarned: !1,
|
|
2029
2029
|
maxAliasCount: typeof r == "number" ? r : 100
|
|
2030
|
-
}, s =
|
|
2030
|
+
}, s = P(this.contents, t ?? "", o);
|
|
2031
2031
|
if (typeof i == "function") for (let { count: e, res: t } of o.anchors.values()) i(t, e);
|
|
2032
|
-
return typeof a == "function" ?
|
|
2032
|
+
return typeof a == "function" ? N(a, { "": s }, "", s) : s;
|
|
2033
2033
|
}
|
|
2034
2034
|
toJSON(e, t) {
|
|
2035
2035
|
return this.toJS({
|
|
@@ -2853,7 +2853,7 @@ var Wn = class {
|
|
|
2853
2853
|
this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (e, t, n, r) => {
|
|
2854
2854
|
let i = Hn(e);
|
|
2855
2855
|
r ? this.warnings.push(new sn(i, t, n)) : this.errors.push(new on(i, t, n));
|
|
2856
|
-
}, this.directives = new
|
|
2856
|
+
}, this.directives = new se({ version: e.version || "1.2" }), this.options = e;
|
|
2857
2857
|
}
|
|
2858
2858
|
decorate(e, t) {
|
|
2859
2859
|
let { comment: n, afterEmptyLine: r } = Un(this.prelude);
|
|
@@ -4394,8 +4394,8 @@ var kr = /* @__PURE__ */ a({
|
|
|
4394
4394
|
parseAllDocuments: () => Tr,
|
|
4395
4395
|
parseDocument: () => Er,
|
|
4396
4396
|
stringify: () => Or,
|
|
4397
|
-
visit: () =>
|
|
4398
|
-
visitAsync: () =>
|
|
4397
|
+
visit: () => k,
|
|
4398
|
+
visitAsync: () => te
|
|
4399
4399
|
}), Ar = {
|
|
4400
4400
|
rawNodes: {
|
|
4401
4401
|
address: {
|
|
@@ -7394,7 +7394,7 @@ function ui(e) {
|
|
|
7394
7394
|
D[e] = J(D[e] || {}, t);
|
|
7395
7395
|
});
|
|
7396
7396
|
});
|
|
7397
|
-
let
|
|
7397
|
+
let ee = p ? {
|
|
7398
7398
|
...p,
|
|
7399
7399
|
fields: D
|
|
7400
7400
|
} : null;
|
|
@@ -7408,7 +7408,7 @@ function ui(e) {
|
|
|
7408
7408
|
nodeTemplate: u || null,
|
|
7409
7409
|
treeTemplate: d || null,
|
|
7410
7410
|
channelTemplate: E,
|
|
7411
|
-
userTemplate:
|
|
7411
|
+
userTemplate: ee
|
|
7412
7412
|
};
|
|
7413
7413
|
}
|
|
7414
7414
|
//#endregion
|
|
@@ -7743,7 +7743,7 @@ X.get("/", async (e) => {
|
|
|
7743
7743
|
`).all(...T), a = Array.isArray(i) ? i : a?.results || [];
|
|
7744
7744
|
for (let e of a) D[e.nodeId] || (D[e.nodeId] = []), D[e.nodeId].includes(e.label) || D[e.nodeId].push(e.label);
|
|
7745
7745
|
}
|
|
7746
|
-
let
|
|
7746
|
+
let ee = await Promise.all(w.map(async (e) => {
|
|
7747
7747
|
let n = (e.status === "draft" || !e.status) && !!e.publishedAt, r = {
|
|
7748
7748
|
id: e.id,
|
|
7749
7749
|
title: e.title,
|
|
@@ -7771,9 +7771,9 @@ X.get("/", async (e) => {
|
|
|
7771
7771
|
return r;
|
|
7772
7772
|
}));
|
|
7773
7773
|
return e.json({
|
|
7774
|
-
items:
|
|
7774
|
+
items: ee,
|
|
7775
7775
|
total: v,
|
|
7776
|
-
hasMore: p +
|
|
7776
|
+
hasMore: p + ee.length < v,
|
|
7777
7777
|
offset: p,
|
|
7778
7778
|
limit: f
|
|
7779
7779
|
});
|
|
@@ -8886,7 +8886,18 @@ Z.get("/", async (e) => {
|
|
|
8886
8886
|
//#endregion
|
|
8887
8887
|
//#region server/routes/public/node.ts
|
|
8888
8888
|
var Ii = new e();
|
|
8889
|
-
function Li(
|
|
8889
|
+
function Li() {
|
|
8890
|
+
return {
|
|
8891
|
+
fullPath: /* @__PURE__ */ new Map(),
|
|
8892
|
+
treeEdges: /* @__PURE__ */ new Map(),
|
|
8893
|
+
nodeSlugs: /* @__PURE__ */ new Map(),
|
|
8894
|
+
assetUrls: /* @__PURE__ */ new Map()
|
|
8895
|
+
};
|
|
8896
|
+
}
|
|
8897
|
+
function Ri(...e) {
|
|
8898
|
+
return e.map((e) => String(e ?? "")).join(":");
|
|
8899
|
+
}
|
|
8900
|
+
function zi(e, t) {
|
|
8890
8901
|
let n = /* @__PURE__ */ new Date();
|
|
8891
8902
|
if (e && String(e).trim() !== "") {
|
|
8892
8903
|
let t = new Date(e);
|
|
@@ -8898,38 +8909,19 @@ function Li(e, t) {
|
|
|
8898
8909
|
}
|
|
8899
8910
|
return !0;
|
|
8900
8911
|
}
|
|
8901
|
-
async function
|
|
8902
|
-
if (!t || typeof t != "object") return t;
|
|
8903
|
-
let n = { ...t };
|
|
8904
|
-
for (let [t, r] of Object.entries(n)) if (typeof r == "string" && r.startsWith("ast_")) try {
|
|
8905
|
-
let i = await e.prepare("SELECT * FROM assets WHERE id = ? AND deletedAt IS NULL").get(r);
|
|
8906
|
-
if (i) {
|
|
8907
|
-
let e = null;
|
|
8908
|
-
if (i.cropCoordinatesJson) try {
|
|
8909
|
-
e = typeof i.cropCoordinatesJson == "string" ? JSON.parse(i.cropCoordinatesJson) : i.cropCoordinatesJson;
|
|
8910
|
-
} catch {}
|
|
8911
|
-
n[t] = {
|
|
8912
|
-
id: i.id,
|
|
8913
|
-
url: i.cdnUrl || `/media/uploads/${i.filename}`,
|
|
8914
|
-
originalUrl: i.cdnUrl || `/media/uploads/${i.filename}`,
|
|
8915
|
-
parentAssetId: i.parentAssetId || null,
|
|
8916
|
-
cropCoordinates: e,
|
|
8917
|
-
filename: i.filename,
|
|
8918
|
-
mimeType: i.mimeType
|
|
8919
|
-
};
|
|
8920
|
-
}
|
|
8921
|
-
} catch {}
|
|
8922
|
-
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Ri(e, r));
|
|
8923
|
-
return n;
|
|
8924
|
-
}
|
|
8925
|
-
async function zi(e, t, n) {
|
|
8912
|
+
async function Bi(e, t, n) {
|
|
8926
8913
|
let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
|
|
8927
|
-
|
|
8914
|
+
await Promise.all(r.map(async (t) => {
|
|
8928
8915
|
let r = t.data || {}, i = r.nodeType || "article", a = Number(r.limit) || 12, o = r.sortBy || "updatedAt", s = "FROM content_nodes WHERE contentType = ? AND isHidden = 0 AND (status = 'published' OR status IS NULL)", c = [i];
|
|
8929
8916
|
n && n !== "all" && (s += " AND id IN (SELECT nodeId FROM node_channels WHERE channelId = ?)", c.push(Number(n) || n));
|
|
8930
8917
|
let l = "ORDER BY updatedAt DESC";
|
|
8931
8918
|
o === "published_desc" || o === "createdAt" ? l = "ORDER BY createdAt DESC" : o === "title_asc" && (l = "ORDER BY LOWER(title) ASC");
|
|
8932
|
-
let u = `
|
|
8919
|
+
let u = `
|
|
8920
|
+
SELECT id, title, slug, language, dataJson, createdAt, updatedAt
|
|
8921
|
+
${s}
|
|
8922
|
+
${l}
|
|
8923
|
+
LIMIT ?
|
|
8924
|
+
`;
|
|
8933
8925
|
c.push(a);
|
|
8934
8926
|
try {
|
|
8935
8927
|
let n = await e.prepare(u).all(...c), r = Array.isArray(n) ? n : n?.results || [];
|
|
@@ -8938,7 +8930,7 @@ async function zi(e, t, n) {
|
|
|
8938
8930
|
if (e.dataJson) try {
|
|
8939
8931
|
t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
8940
8932
|
} catch {}
|
|
8941
|
-
return
|
|
8933
|
+
return zi(t.startShowingAt, t.stopShowingAt) ? {
|
|
8942
8934
|
id: e.id,
|
|
8943
8935
|
title: e.title,
|
|
8944
8936
|
slug: e.slug,
|
|
@@ -8953,61 +8945,88 @@ async function zi(e, t, n) {
|
|
|
8953
8945
|
} catch (e) {
|
|
8954
8946
|
console.error("[CMS Hydration] Failed to hydrate content feed block", e), t.data.initialItems = [];
|
|
8955
8947
|
}
|
|
8956
|
-
}
|
|
8948
|
+
}));
|
|
8957
8949
|
}
|
|
8958
|
-
async function
|
|
8950
|
+
async function Vi(e, t, n, r, i = !1, a) {
|
|
8959
8951
|
if (!t) return { blocks: [] };
|
|
8960
|
-
let
|
|
8961
|
-
if (!
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8952
|
+
let o = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n\n UNION ALL\n\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT *\n FROM ancestor_path\n ORDER BY level ASC\n ").all(t, t), s = Array.isArray(o) ? o : o?.results || [];
|
|
8953
|
+
if (!s || s.length === 0) return { blocks: [] };
|
|
8954
|
+
let c = s.map((e) => e.contentId).filter((e) => e != null);
|
|
8955
|
+
if (c.length === 0) return { blocks: [] };
|
|
8956
|
+
let l = c.map(() => "?").join(","), u = +!!i, d = await e.prepare(`
|
|
8957
|
+
SELECT *
|
|
8958
|
+
FROM content_blocks
|
|
8959
|
+
WHERE contentId IN (${l})
|
|
8960
|
+
AND isDraft = ?
|
|
8961
|
+
ORDER BY contentId ASC, sortOrder ASC
|
|
8962
|
+
`).all(...c, u), f = Array.isArray(d) ? d : d?.results || [], p = [];
|
|
8963
|
+
if (!i) {
|
|
8964
|
+
let t = await e.prepare(`
|
|
8965
|
+
SELECT *
|
|
8966
|
+
FROM content_blocks
|
|
8967
|
+
WHERE contentId IN (${l})
|
|
8968
|
+
ORDER BY contentId ASC, sortOrder ASC
|
|
8969
|
+
`).all(...c);
|
|
8970
|
+
p = Array.isArray(t) ? t : t?.results || [];
|
|
8971
|
+
}
|
|
8972
|
+
let m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
8973
|
+
for (let e of f) {
|
|
8974
|
+
let t = String(e.contentId);
|
|
8975
|
+
m.has(t) || m.set(t, []), m.get(t).push(e);
|
|
8976
|
+
}
|
|
8977
|
+
for (let e of p) {
|
|
8978
|
+
let t = String(e.contentId);
|
|
8979
|
+
h.has(t) || h.set(t, []), h.get(t).push(e);
|
|
8980
|
+
}
|
|
8981
|
+
for (let t of s) {
|
|
8982
|
+
let a = m.get(String(t.contentId)) || [];
|
|
8983
|
+
if (a.length === 0 && !i && (a = h.get(String(t.contentId)) || []), a.filter((e) => e.region === n).length === 0) continue;
|
|
8984
|
+
let o = /* @__PURE__ */ new Set([n]), s = !0;
|
|
8985
|
+
for (; s;) {
|
|
8986
|
+
s = !1;
|
|
8987
|
+
for (let e of a) {
|
|
8988
|
+
if (!o.has(e.region)) continue;
|
|
8989
|
+
let t = {};
|
|
8985
8990
|
try {
|
|
8986
|
-
|
|
8991
|
+
t = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
8987
8992
|
} catch {}
|
|
8988
|
-
let
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
instanceId: t.id,
|
|
8995
|
-
blockId: f,
|
|
8996
|
-
componentId: u,
|
|
8997
|
-
data: p
|
|
8998
|
-
});
|
|
8993
|
+
let n = String(e.id), r = String(t.blockId || t._instanceId || t.id || e.blockId);
|
|
8994
|
+
for (let e of a) {
|
|
8995
|
+
if (!e.region) continue;
|
|
8996
|
+
let t = e.region;
|
|
8997
|
+
o.has(t) || (t.startsWith(`${n}-`) || t.startsWith(`${n}_`) || r && r !== "undefined" && r !== "null" && (t.startsWith(`${r}-`) || t.startsWith(`${r}_`) || t.startsWith(r))) && (o.add(t), s = !0);
|
|
8998
|
+
}
|
|
8999
8999
|
}
|
|
9000
|
-
if (c[n] && c[n].length > 0) return {
|
|
9001
|
-
blocks: c[n],
|
|
9002
|
-
subRegions: c,
|
|
9003
|
-
inheritedFromId: String(t.contentId),
|
|
9004
|
-
inheritedFromTitle: t.title || t.slug
|
|
9005
|
-
};
|
|
9006
9000
|
}
|
|
9001
|
+
let c = await Promise.all(a.filter((e) => o.has(e.region)).map(async (t) => {
|
|
9002
|
+
let a = {};
|
|
9003
|
+
try {
|
|
9004
|
+
a = (typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson) || {};
|
|
9005
|
+
} catch {}
|
|
9006
|
+
let o = a.hidden === !0 || a.hidden === 1 || a.hidden === "1" || a.hidden === "true", s = zi(a.startShowingAt, a.stopShowingAt);
|
|
9007
|
+
if (!i && (o || !s)) return null;
|
|
9008
|
+
let c = t.elementType || t.componentId || "text-block", l = r.blocks?.[c]?.fields || r.elements?.[c]?.fields || r.components?.[c]?.fields || {}, u = String(a.blockId || a._instanceId || a.id || t.blockId || t.id), d = Hi(a, l);
|
|
9009
|
+
return d = await si(e, d), d = Ui(d), d.blockId = u, {
|
|
9010
|
+
region: t.region || n,
|
|
9011
|
+
block: {
|
|
9012
|
+
instanceId: t.id,
|
|
9013
|
+
blockId: u,
|
|
9014
|
+
componentId: c,
|
|
9015
|
+
data: d
|
|
9016
|
+
}
|
|
9017
|
+
};
|
|
9018
|
+
})), l = {};
|
|
9019
|
+
for (let e of c) e && (l[e.region] || (l[e.region] = []), l[e.region].push(e.block));
|
|
9020
|
+
if (l[n] && l[n].length > 0) return {
|
|
9021
|
+
blocks: l[n],
|
|
9022
|
+
subRegions: l,
|
|
9023
|
+
inheritedFromId: String(t.contentId),
|
|
9024
|
+
inheritedFromTitle: t.title || t.slug
|
|
9025
|
+
};
|
|
9007
9026
|
}
|
|
9008
9027
|
return { blocks: [] };
|
|
9009
9028
|
}
|
|
9010
|
-
function
|
|
9029
|
+
function Hi(e, t = {}) {
|
|
9011
9030
|
let n = {};
|
|
9012
9031
|
for (let [r, i] of Object.entries(e)) {
|
|
9013
9032
|
if (r.endsWith("_meta") || r === "disabledRegions" || r === "hidden" || r === "is_hidden" || r === "isHidden" || r === "status" || r === "startShowingAt" || r === "stopShowingAt" || r === "slug" || r === "title" || r === "id" || r.startsWith("_")) continue;
|
|
@@ -9016,14 +9035,14 @@ function Vi(e, t = {}) {
|
|
|
9016
9035
|
}
|
|
9017
9036
|
return n;
|
|
9018
9037
|
}
|
|
9019
|
-
function
|
|
9020
|
-
if (Array.isArray(e)) return e.map(
|
|
9038
|
+
function Ui(e) {
|
|
9039
|
+
if (Array.isArray(e)) return e.map(Ui);
|
|
9021
9040
|
if (!e || typeof e != "object") return e;
|
|
9022
9041
|
if (typeof e.id == "string" && e.id.startsWith("ast_") && typeof e.url == "string") {
|
|
9023
9042
|
let t = e.metadataOverrides || {}, n = e.variants && typeof e.variants == "object" ? e.variants : {}, r = Object.entries(n).find(([, t]) => t?.id === e.id)?.[0], i = r ? {
|
|
9024
9043
|
...t,
|
|
9025
9044
|
...t.crops?.[r] || {}
|
|
9026
|
-
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t,
|
|
9045
|
+
} : t, a = Object.fromEntries(Object.entries(n).filter(([, t]) => t?.id !== e.id).map(([t, n]) => [t, Ui({
|
|
9027
9046
|
...n,
|
|
9028
9047
|
title: n?.title ?? e.title ?? "",
|
|
9029
9048
|
alt: n?.alt ?? e.alt ?? "",
|
|
@@ -9037,70 +9056,101 @@ function Hi(e) {
|
|
|
9037
9056
|
...Object.keys(a).length > 0 ? { variants: a } : {}
|
|
9038
9057
|
};
|
|
9039
9058
|
}
|
|
9040
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e,
|
|
9059
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Ui(t)]));
|
|
9041
9060
|
}
|
|
9042
|
-
async function
|
|
9061
|
+
async function Wi(e, t, n) {
|
|
9043
9062
|
if (typeof t == "string") {
|
|
9044
9063
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
9045
|
-
let n = /* @__PURE__ */ new Set();
|
|
9046
|
-
for (let e of t.matchAll(/(?:#node:|data-node-id=["'])([^"'\s>]+)/gi)) n.add(e[1]);
|
|
9047
9064
|
let r = /* @__PURE__ */ new Set();
|
|
9048
|
-
for (let e of t.matchAll(/(?:#
|
|
9049
|
-
|
|
9050
|
-
let
|
|
9051
|
-
|
|
9052
|
-
let
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9065
|
+
for (let e of t.matchAll(/(?:#node:|data-node-id=["'])([^"'\s>]+)/gi)) r.add(e[1]);
|
|
9066
|
+
let i = /* @__PURE__ */ new Set();
|
|
9067
|
+
for (let e of t.matchAll(/(?:#asset:|data-asset-id=["'])([^"'\s>]+)/gi)) i.add(e[1]);
|
|
9068
|
+
if (r.size === 0 && i.size === 0) return t;
|
|
9069
|
+
let a = Array.from(r).map(() => "?").join(","), o = r.size > 0 ? await e.prepare(`
|
|
9070
|
+
SELECT id, slug
|
|
9071
|
+
FROM content_nodes
|
|
9072
|
+
WHERE id IN (${a})
|
|
9073
|
+
`).all(...r) : [], s = /* @__PURE__ */ new Map();
|
|
9074
|
+
for (let e of o || []) s.set(String(e.id), String(e.slug || "").replace(/^\/+|\/+$/g, ""));
|
|
9075
|
+
let c = Array.from(i).map(() => "?").join(","), l = i.size > 0 ? await e.prepare(`
|
|
9076
|
+
SELECT id, cdnUrl, storageKeyPrivate
|
|
9077
|
+
FROM assets
|
|
9078
|
+
WHERE id IN (${c})
|
|
9079
|
+
`).all(...i) : [], u = /* @__PURE__ */ new Map();
|
|
9080
|
+
for (let e of l || []) u.set(String(e.id), e.cdnUrl || (e.storageKeyPrivate ? `/media/${e.storageKeyPrivate}` : ""));
|
|
9081
|
+
let d = /* @__PURE__ */ new Map(), f = /<a\b([^>]*?)>/gi;
|
|
9082
|
+
return await Promise.all(Array.from(t.matchAll(f)).map(async (t) => {
|
|
9083
|
+
let r = t[1], i = r.match(/data-node-id=["']([^"']+)["']/i), a = r.match(/data-tree-id=["']([^"']+)["']/i);
|
|
9084
|
+
if (!i || !a) return;
|
|
9085
|
+
let o = i[1], s = a[1], c = await Ki(e, o, s, n);
|
|
9086
|
+
if (c?.treeNodeId) {
|
|
9087
|
+
let t = await Xi(e, String(c.treeNodeId), s, n);
|
|
9088
|
+
d.set(`${o}:${s}`, t);
|
|
9089
|
+
}
|
|
9090
|
+
})), t.replace(f, (e, t) => {
|
|
9062
9091
|
let n = t.match(/data-node-id=["']([^"']+)["']/i), r = t.match(/data-asset-id=["']([^"']+)["']/i), i = t.match(/href=["']([^"']+)["']/i);
|
|
9063
9092
|
if (i?.[1].startsWith("mailto:")) return `<a${t.replace(/\s+target=["'][^"']*["']/i, "")}>`;
|
|
9064
|
-
let a = i?.[1].match(/^#node:(.+)$/i),
|
|
9065
|
-
if (!
|
|
9066
|
-
if (c && !
|
|
9067
|
-
let n =
|
|
9093
|
+
let a = i?.[1].match(/^#node:(.+)$/i), o = i?.[1].match(/^#asset:(.+)$/i), c = r?.[1] || o?.[1], l = n?.[1] || a?.[1];
|
|
9094
|
+
if (!l && !c) return e;
|
|
9095
|
+
if (c && !l) {
|
|
9096
|
+
let n = u.get(c);
|
|
9068
9097
|
return n && i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${n}"`).replace(/data-asset-id=["'][^"']*["']/i, `data-asset-id="${c}"`)}>` : e;
|
|
9069
9098
|
}
|
|
9070
|
-
let f = t.match(/data-tree-id=["']([^"']+)["']/i), p =
|
|
9099
|
+
let f = t.match(/data-tree-id=["']([^"']+)["']/i), p = l, m = f ? d.get(`${p}:${f[1]}`) : void 0, h = s.get(p), g = m || (h === void 0 ? "#" : `/${h}`);
|
|
9071
9100
|
return i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${g || "/"}"`)}>` : e;
|
|
9072
9101
|
});
|
|
9073
9102
|
}
|
|
9074
|
-
if (Array.isArray(t)) return Promise.all(t.map((t) =>
|
|
9103
|
+
if (Array.isArray(t)) return Promise.all(t.map((t) => Wi(e, t, n)));
|
|
9075
9104
|
if (t && typeof t == "object") {
|
|
9076
9105
|
if (typeof t.href == "string" && (t.href.startsWith("#node:") || t.href.startsWith("#asset:"))) return {
|
|
9077
9106
|
...t,
|
|
9078
|
-
href: await
|
|
9107
|
+
href: await Gi(e, t, n)
|
|
9079
9108
|
};
|
|
9080
|
-
let
|
|
9081
|
-
return Object.fromEntries(
|
|
9109
|
+
let r = await Promise.all(Object.entries(t).map(async ([t, r]) => [t, await Wi(e, r, n)]));
|
|
9110
|
+
return Object.fromEntries(r);
|
|
9082
9111
|
}
|
|
9083
9112
|
return t;
|
|
9084
9113
|
}
|
|
9085
|
-
async function
|
|
9086
|
-
let
|
|
9087
|
-
if (
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
}
|
|
9091
|
-
if (!n) return t.href;
|
|
9092
|
-
let i = n[1];
|
|
9114
|
+
async function Gi(e, t, n) {
|
|
9115
|
+
let r = t.href.match(/^#node:(.+)$/), i = t.href.match(/^#asset:(.+)$/);
|
|
9116
|
+
if (i) return Ji(e, i[1], n);
|
|
9117
|
+
if (!r) return t.href;
|
|
9118
|
+
let a = r[1];
|
|
9093
9119
|
if (t.treeId) {
|
|
9094
|
-
let
|
|
9095
|
-
if (
|
|
9096
|
-
let
|
|
9097
|
-
if (
|
|
9098
|
-
}
|
|
9099
|
-
}
|
|
9100
|
-
let
|
|
9101
|
-
return
|
|
9102
|
-
}
|
|
9103
|
-
function
|
|
9120
|
+
let r = await Ki(e, a, String(t.treeId), n);
|
|
9121
|
+
if (r?.treeNodeId) {
|
|
9122
|
+
let i = await Xi(e, String(r.treeNodeId), String(t.treeId), n);
|
|
9123
|
+
if (i) return i;
|
|
9124
|
+
}
|
|
9125
|
+
}
|
|
9126
|
+
let o = await qi(e, a, n);
|
|
9127
|
+
return o === void 0 ? "#" : `/${o}`;
|
|
9128
|
+
}
|
|
9129
|
+
async function Ki(e, t, n, r) {
|
|
9130
|
+
let i = Ri(t, n), a = r.treeEdges.get(i);
|
|
9131
|
+
if (a) return a;
|
|
9132
|
+
let o = e.prepare("\n SELECT id as treeNodeId\n FROM tree_nodes\n WHERE contentId = ?\n AND treeId = ?\n LIMIT 1\n ").get(t, n);
|
|
9133
|
+
return r.treeEdges.set(i, Promise.resolve(o)), o;
|
|
9134
|
+
}
|
|
9135
|
+
async function qi(e, t, n) {
|
|
9136
|
+
let r = String(t), i = n.nodeSlugs.get(r);
|
|
9137
|
+
if (i) return i;
|
|
9138
|
+
let a = (async () => {
|
|
9139
|
+
let n = await e.prepare("SELECT slug FROM content_nodes WHERE id = ?").get(t);
|
|
9140
|
+
return n?.slug ? String(n.slug).replace(/^\/+|\/+$/g, "") : void 0;
|
|
9141
|
+
})();
|
|
9142
|
+
return n.nodeSlugs.set(r, a), a;
|
|
9143
|
+
}
|
|
9144
|
+
async function Ji(e, t, n) {
|
|
9145
|
+
let r = String(t), i = n.assetUrls.get(r);
|
|
9146
|
+
if (i) return i;
|
|
9147
|
+
let a = (async () => {
|
|
9148
|
+
let n = await e.prepare("SELECT cdnUrl, storageKeyPrivate FROM assets WHERE id = ?").get(t);
|
|
9149
|
+
return n?.cdnUrl || (n?.storageKeyPrivate ? `/media/${n.storageKeyPrivate}` : "#");
|
|
9150
|
+
})();
|
|
9151
|
+
return n.assetUrls.set(r, a), a;
|
|
9152
|
+
}
|
|
9153
|
+
function Yi(e) {
|
|
9104
9154
|
let t = e.socialImage;
|
|
9105
9155
|
if (!t || typeof t != "object") return null;
|
|
9106
9156
|
let n = (e, t) => {
|
|
@@ -9131,19 +9181,27 @@ function Gi(e) {
|
|
|
9131
9181
|
])
|
|
9132
9182
|
};
|
|
9133
9183
|
}
|
|
9134
|
-
async function
|
|
9184
|
+
async function Xi(e, t, n, r) {
|
|
9135
9185
|
if (!t) return "";
|
|
9136
|
-
let
|
|
9137
|
-
|
|
9138
|
-
let
|
|
9139
|
-
|
|
9186
|
+
let i = Ri(t, n);
|
|
9187
|
+
if (r) {
|
|
9188
|
+
let e = r.fullPath.get(i);
|
|
9189
|
+
if (e) return e;
|
|
9140
9190
|
}
|
|
9141
|
-
|
|
9191
|
+
let a = (async () => {
|
|
9192
|
+
let r = await e.prepare("\n WITH RECURSIVE ancestor_path(id, parentId, slug, level) AS (\n SELECT t.id, t.parentId, c.slug, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? AND t.treeId = ?\n\n UNION ALL\n\n SELECT t.id, t.parentId, c.slug, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n WHERE t.treeId = ?\n )\n SELECT slug\n FROM ancestor_path\n ORDER BY level DESC\n ").all(t, n, n), i = Array.isArray(r) ? r : r?.results || [], a = [];
|
|
9193
|
+
for (let e of i) {
|
|
9194
|
+
let t = (e.slug || "").replace(/^\/+|\/+$/g, "");
|
|
9195
|
+
t === "home" || t === "homee" ? i.length === 1 && (a.length = 0) : t && a.push(t);
|
|
9196
|
+
}
|
|
9197
|
+
return "/" + a.join("/");
|
|
9198
|
+
})();
|
|
9199
|
+
return r && r.fullPath.set(i, a), a;
|
|
9142
9200
|
}
|
|
9143
|
-
async function
|
|
9201
|
+
async function Zi(e, t, n, r, i) {
|
|
9144
9202
|
let a = {}, o = null;
|
|
9145
9203
|
if (t) {
|
|
9146
|
-
let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n UNION ALL\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT c.dataJson, c.draftDataJson
|
|
9204
|
+
let n = await e.prepare("\n WITH RECURSIVE ancestor_path(id, contentId, title, slug, parentId, level) AS (\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, 0\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.id = ? OR c.id = ?\n\n UNION ALL\n\n SELECT t.id, t.contentId, c.title, c.slug, t.parentId, ap.level + 1\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n INNER JOIN ancestor_path ap ON t.id = ap.parentId\n )\n SELECT c.dataJson, c.draftDataJson\n FROM ancestor_path ap\n INNER JOIN content_nodes c ON ap.contentId = c.id\n ORDER BY ap.level ASC\n ").all(t, t), i = Array.isArray(n) ? n : n?.results || [], s = /* @__PURE__ */ new Set([
|
|
9147
9205
|
"subpageLayoutId",
|
|
9148
9206
|
"layoutId",
|
|
9149
9207
|
"slug",
|
|
@@ -9168,7 +9226,7 @@ async function qi(e, t, n, r, i) {
|
|
|
9168
9226
|
}
|
|
9169
9227
|
if (!o) {
|
|
9170
9228
|
let t = await e.prepare("SELECT dataJson FROM trees WHERE id = ?").get(n);
|
|
9171
|
-
if (t
|
|
9229
|
+
if (t?.dataJson) try {
|
|
9172
9230
|
let e = typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson;
|
|
9173
9231
|
e.subpageLayoutId && e.subpageLayoutId !== "inherit" && (o = e.subpageLayoutId);
|
|
9174
9232
|
} catch {}
|
|
@@ -9178,114 +9236,142 @@ async function qi(e, t, n, r, i) {
|
|
|
9178
9236
|
inheritedFields: a
|
|
9179
9237
|
};
|
|
9180
9238
|
}
|
|
9239
|
+
function Qi(e) {
|
|
9240
|
+
let t = Number(e?.env?.CMS_NODE_CACHE_TTL);
|
|
9241
|
+
return Number.isFinite(t) && t >= 60 ? Math.floor(t) : 300;
|
|
9242
|
+
}
|
|
9243
|
+
async function $i(e, t, n, r) {
|
|
9244
|
+
try {
|
|
9245
|
+
await e.set(t, n, r);
|
|
9246
|
+
} catch (e) {
|
|
9247
|
+
console.warn("[CMS Cache] Failed to write node response to cache:", e);
|
|
9248
|
+
}
|
|
9249
|
+
}
|
|
9181
9250
|
Ii.get("/*", async (e) => {
|
|
9182
9251
|
try {
|
|
9183
|
-
let t = e.get("db"), n = new URL(e.req.url).pathname.match(/\/node\/(.+)$/),
|
|
9184
|
-
if (!
|
|
9185
|
-
let
|
|
9186
|
-
if (!
|
|
9187
|
-
let
|
|
9188
|
-
if (!
|
|
9189
|
-
let t = await
|
|
9252
|
+
let t = e.get("db"), n = Li(), r = new URL(e.req.url).pathname.match(/\/node\/(.+)$/), i = (r ? r[1] : "home").replace(/^\/+|\/+$/g, ""), a = e.req.query("channelId") || e.req.query("channel") || "1", o = e.req.query("lang") || "en", s = e.req.query("preview") === "true", c = isNaN(Number(a)) ? await t.prepare("SELECT * FROM channels WHERE key = ?").get(a) : await t.prepare("SELECT * FROM channels WHERE id = ?").get(Number(a));
|
|
9253
|
+
if (!c) return e.json({ error: `Channel '${a}' not found` }, 404);
|
|
9254
|
+
let l = c.status === "disabled" || c.status === "inactive" || c.isEnabled === 0 || c.isEnabled === !1;
|
|
9255
|
+
if (!s && l) return e.json({ error: `Channel '${c.key || a}' is currently inactive` }, 404);
|
|
9256
|
+
let u = c.id, d = c.key || a, f = q(e), p = `node:${u || d}:${o}:${i}`;
|
|
9257
|
+
if (!s) {
|
|
9258
|
+
let t = await f.get(p);
|
|
9190
9259
|
if (t) return e.header("X-Cache", "HIT"), e.json(t);
|
|
9191
9260
|
}
|
|
9192
|
-
let
|
|
9193
|
-
if (
|
|
9261
|
+
let m = ui(e.env?.BUNDLED_DEFINITIONS), h = !isNaN(Number(i)) && i.length > 0, g = null, _ = null, v = e.req.query("treeId");
|
|
9262
|
+
if (h) g = u === null ? await t.prepare("SELECT * FROM content_nodes WHERE id = ?").get(Number(i)) : await t.prepare("\n SELECT cn.*\n FROM content_nodes cn\n INNER JOIN node_channels nc\n ON cn.id = nc.nodeId\n WHERE cn.id = ?\n AND nc.channelId = ?\n ").get(Number(i), u);
|
|
9194
9263
|
else {
|
|
9195
|
-
let e =
|
|
9196
|
-
SELECT
|
|
9264
|
+
let e = i.split("/"), r = e[e.length - 1], a = "/" + i.replace(/^\/+|\/+$/g, ""), o = `
|
|
9265
|
+
SELECT
|
|
9266
|
+
cn.*,
|
|
9267
|
+
tn.id as treeNodeId,
|
|
9268
|
+
tn.parentId,
|
|
9269
|
+
tn.treeId
|
|
9197
9270
|
FROM content_nodes cn
|
|
9198
|
-
INNER JOIN tree_nodes tn
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9271
|
+
INNER JOIN tree_nodes tn
|
|
9272
|
+
ON cn.id = tn.contentId
|
|
9273
|
+
${u === null ? "" : "INNER JOIN node_channels nc ON cn.id = nc.nodeId"}
|
|
9274
|
+
WHERE cn.slug = ?
|
|
9275
|
+
${u === null ? "" : "AND nc.channelId = ?"}
|
|
9276
|
+
`, s = u === null ? [r] : [r, u], c = await t.prepare(o).all(...s), l = Array.isArray(c) ? c : c?.results || [];
|
|
9277
|
+
if (l.length > 0) {
|
|
9278
|
+
let e = await Promise.all(l.map(async (e) => ({
|
|
9279
|
+
candidate: e,
|
|
9280
|
+
calculatedPath: await Xi(t, String(e.treeNodeId), String(e.treeId), n)
|
|
9281
|
+
}))), r = a.replace(/^\/+|\/+$/g, "");
|
|
9282
|
+
for (let { candidate: t, calculatedPath: n } of e) {
|
|
9283
|
+
let e = n.replace(/^\/+|\/+$/g, "");
|
|
9284
|
+
if (e === r || r === "home" && (e === "" || e === "home")) {
|
|
9285
|
+
g = t, _ = t;
|
|
9286
|
+
break;
|
|
9287
|
+
}
|
|
9207
9288
|
}
|
|
9208
9289
|
}
|
|
9209
|
-
!
|
|
9210
|
-
}
|
|
9211
|
-
if (!
|
|
9212
|
-
if (!
|
|
9213
|
-
let e =
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9290
|
+
!g && e.length === 1 && (g = u === null ? await t.prepare("SELECT * FROM content_nodes WHERE slug = ?").get(r) : await t.prepare("\n SELECT cn.*\n FROM content_nodes cn\n INNER JOIN node_channels nc\n ON cn.id = nc.nodeId\n WHERE cn.slug = ?\n AND nc.channelId = ?\n ").get(r, u));
|
|
9291
|
+
}
|
|
9292
|
+
if (!g) return e.json({ error: `Node '${i}' not found for Channel '${a}'` }, 404);
|
|
9293
|
+
if (!_) {
|
|
9294
|
+
let e = v ? [g.id, v] : [g.id];
|
|
9295
|
+
_ = await t.prepare(`
|
|
9296
|
+
SELECT
|
|
9297
|
+
id as treeNodeId,
|
|
9298
|
+
treeId,
|
|
9299
|
+
parentId
|
|
9300
|
+
FROM tree_nodes
|
|
9301
|
+
WHERE contentId = ?
|
|
9302
|
+
${v ? "AND treeId = ?" : ""}
|
|
9303
|
+
LIMIT 1
|
|
9304
|
+
`).get(...e);
|
|
9305
|
+
}
|
|
9306
|
+
let y = _?.treeId || v || "main-nav", b = _?.parentId || null, x = _?.treeNodeId ? await Xi(t, String(_.treeNodeId), String(y), n) : `/${(g.slug || "").replace(/^\/+|\/+$/g, "")}`, S = {
|
|
9307
|
+
id: g.id,
|
|
9308
|
+
title: g.title,
|
|
9309
|
+
slug: g.slug,
|
|
9310
|
+
language: g.language || o || "en",
|
|
9311
|
+
path: x === "" ? "/" : x,
|
|
9312
|
+
nodeType: g.contentType,
|
|
9313
|
+
createdAt: g.createdAt,
|
|
9314
|
+
updatedAt: g.updatedAt
|
|
9315
|
+
}, C = g.contentType || "node", w = m.nodes?.[C] || Object.values(m.nodes || {})[0] || {}, T = { ...w.fields || {} };
|
|
9316
|
+
w.tabs && Object.values(w.tabs).forEach((e) => {
|
|
9317
|
+
Object.assign(T, e.fields || {});
|
|
9233
9318
|
});
|
|
9234
|
-
let
|
|
9319
|
+
let E = {}, D = null, ee = null, O = !1, k = {}, A = s && g.draftDataJson ? g.draftDataJson : g.dataJson || g.draftDataJson;
|
|
9235
9320
|
if (A) try {
|
|
9236
9321
|
k = typeof A == "string" ? JSON.parse(A) : A;
|
|
9237
9322
|
} catch {}
|
|
9238
|
-
k.disabledRegions && (
|
|
9239
|
-
let
|
|
9240
|
-
for (let [e, t] of Object.entries(
|
|
9241
|
-
let
|
|
9242
|
-
|
|
9243
|
-
let
|
|
9244
|
-
delete
|
|
9245
|
-
let
|
|
9246
|
-
if (!
|
|
9247
|
-
let
|
|
9248
|
-
if (
|
|
9249
|
-
let e = await t.prepare("\n
|
|
9250
|
-
|
|
9251
|
-
let t = {}, n =
|
|
9323
|
+
k.disabledRegions && (E = k.disabledRegions), O = k.hidden === !0 || k.hidden === 1 || k.hidden === "1" || k.hidden === "true", D = k.startShowingAt || null, ee = k.stopShowingAt || null;
|
|
9324
|
+
let te = k.layoutId, ne = te && te !== "inherit", { resolvedLayoutId: re, inheritedFields: ie } = await Zi(t, b, y, s, T), ae = ne ? te : re || w.defaultLayout || null;
|
|
9325
|
+
for (let [e, t] of Object.entries(ie)) (k[e] === void 0 || k[e] === null || k[e] === "" || k[e] === "inherit") && t !== void 0 && (k[e] = t);
|
|
9326
|
+
let j = await si(t, Hi(k, T));
|
|
9327
|
+
j = Ui(j), j = await Wi(t, j, n);
|
|
9328
|
+
let oe = Yi(j);
|
|
9329
|
+
delete j.socialImage, delete j.fbImage, delete j.xImage, delete j.whatsappImage, oe && (j.socialImages = oe), S.slug = g.slug, S.title = g.title, Object.assign(S, j), S.layoutId = ae;
|
|
9330
|
+
let se = !!g.isHidden || O, ce = !zi(D, ee);
|
|
9331
|
+
if (!s && (se || ce)) return e.json({ error: "Node is hidden or outside its scheduled publishing window" }, 404);
|
|
9332
|
+
let le = [];
|
|
9333
|
+
if (_?.treeNodeId) {
|
|
9334
|
+
let e = await t.prepare("\n SELECT\n t.id as treeNodeId,\n t.contentId as id,\n c.title,\n c.slug,\n c.language,\n c.contentType as nodeType,\n c.isHidden,\n c.dataJson,\n c.draftDataJson\n FROM tree_nodes t\n INNER JOIN content_nodes c\n ON t.contentId = c.id\n WHERE t.parentId = ?\n AND t.treeId = ?\n ORDER BY t.sortOrder ASC\n ").all(_.treeNodeId, y), n = Array.isArray(e) ? e : e?.results || [], r = S.path === "/" ? "" : S.path;
|
|
9335
|
+
le = n.map((e) => {
|
|
9336
|
+
let t = {}, n = s && e.draftDataJson ? e.draftDataJson : e.dataJson;
|
|
9252
9337
|
try {
|
|
9253
9338
|
t = (typeof n == "string" ? JSON.parse(n) : n) || {};
|
|
9254
9339
|
} catch {}
|
|
9255
|
-
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a =
|
|
9256
|
-
return !
|
|
9340
|
+
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a = zi(t.startShowingAt, t.stopShowingAt), o = (e.slug || "").replace(/^\/+|\/+$/g, "");
|
|
9341
|
+
return !s && (i || !a) ? null : {
|
|
9257
9342
|
treeNodeId: e.treeNodeId,
|
|
9258
9343
|
id: e.id,
|
|
9259
9344
|
title: e.title,
|
|
9260
|
-
slug:
|
|
9345
|
+
slug: o,
|
|
9261
9346
|
language: e.language || "en",
|
|
9262
|
-
path: `${r}/${
|
|
9347
|
+
path: `${r}/${o}`.replace(/\/+/g, "/"),
|
|
9263
9348
|
nodeType: e.nodeType
|
|
9264
9349
|
};
|
|
9265
9350
|
}).filter(Boolean);
|
|
9266
9351
|
}
|
|
9267
|
-
|
|
9268
|
-
let
|
|
9269
|
-
|
|
9270
|
-
let P = {}, F = {}
|
|
9271
|
-
|
|
9272
|
-
let n = e.region || "main";
|
|
9273
|
-
P[n] || (P[n] = [], F[n] = { isInherited: !1 });
|
|
9274
|
-
let r = {};
|
|
9352
|
+
S.children = le;
|
|
9353
|
+
let ue = +!!s, M = await t.prepare("\n SELECT *\n FROM content_blocks\n WHERE contentId = ?\n AND isDraft = ?\n ORDER BY sortOrder ASC\n ").all(g.id, ue), N = Array.isArray(M) ? M : M?.results || [];
|
|
9354
|
+
N.length === 0 && !s && (M = await t.prepare("\n SELECT *\n FROM content_blocks\n WHERE contentId = ?\n ORDER BY sortOrder ASC\n ").all(g.id), N = Array.isArray(M) ? M : M?.results || []);
|
|
9355
|
+
let P = {}, F = {}, de = await Promise.all(N.map(async (e) => {
|
|
9356
|
+
let r = e.region || "main", i = {};
|
|
9275
9357
|
try {
|
|
9276
|
-
|
|
9358
|
+
i = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
9277
9359
|
} catch {}
|
|
9278
|
-
let
|
|
9279
|
-
if (!
|
|
9280
|
-
let
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9360
|
+
let a = i.hidden === !0 || i.hidden === 1 || i.hidden === "1" || i.hidden === "true", o = zi(i.startShowingAt, i.stopShowingAt);
|
|
9361
|
+
if (!s && (a || !o)) return null;
|
|
9362
|
+
let c = e.elementType || e.componentId || "text-block", l = m.blocks?.[c]?.fields || m.elements?.[c]?.fields || m.components?.[c]?.fields || {}, u = String(i.blockId || i._instanceId || i.id || e.blockId || e.id), d = Hi(i, l);
|
|
9363
|
+
return d = await si(t, d), d = Ui(d), d = await Wi(t, d, n), d.blockId = u, {
|
|
9364
|
+
region: r,
|
|
9365
|
+
block: {
|
|
9366
|
+
instanceId: e.id,
|
|
9367
|
+
blockId: u,
|
|
9368
|
+
componentId: c,
|
|
9369
|
+
data: d
|
|
9370
|
+
}
|
|
9371
|
+
};
|
|
9372
|
+
}));
|
|
9373
|
+
for (let e of de) e && (P[e.region] || (P[e.region] = [], F[e.region] = { isInherited: !1 }), P[e.region].push(e.block));
|
|
9374
|
+
let fe = {
|
|
9289
9375
|
header: {
|
|
9290
9376
|
label: "Header",
|
|
9291
9377
|
inherit: "parent"
|
|
@@ -9294,33 +9380,33 @@ Ii.get("/*", async (e) => {
|
|
|
9294
9380
|
label: "Footer",
|
|
9295
9381
|
inherit: "parent"
|
|
9296
9382
|
},
|
|
9297
|
-
...(
|
|
9383
|
+
...(ae ? m.nodeLayouts?.[ae] || m.layouts?.[ae] : null)?.regions || { main: { label: "Content" } }
|
|
9298
9384
|
};
|
|
9299
|
-
for (let [e,
|
|
9300
|
-
let
|
|
9301
|
-
if (P[e] || (P[e] = [], F[e] = { isInherited: !1 }), (
|
|
9302
|
-
let
|
|
9303
|
-
if (
|
|
9385
|
+
for (let [e, r] of Object.entries(fe)) {
|
|
9386
|
+
let i = P[e] && P[e].length > 0, a = !!E[e];
|
|
9387
|
+
if (P[e] || (P[e] = [], F[e] = { isInherited: !1 }), (r?.inherit === "parent" || r?.inherit === !0 || r?.inherit === "true" || e === "header" || e === "footer") && !i && !a && b) {
|
|
9388
|
+
let r = await Vi(t, b, e, m, s, n);
|
|
9389
|
+
if (r.blocks.length > 0 && (P[e] = r.blocks, F[e] = {
|
|
9304
9390
|
isInherited: !0,
|
|
9305
|
-
inheritedFromId:
|
|
9306
|
-
inheritedFromTitle:
|
|
9307
|
-
},
|
|
9391
|
+
inheritedFromId: r.inheritedFromId,
|
|
9392
|
+
inheritedFromTitle: r.inheritedFromTitle
|
|
9393
|
+
}, r.subRegions)) for (let [t, n] of Object.entries(r.subRegions)) t !== e && (P[t] = n, F[t] = {
|
|
9308
9394
|
isInherited: !0,
|
|
9309
|
-
inheritedFromId:
|
|
9310
|
-
inheritedFromTitle:
|
|
9395
|
+
inheritedFromId: r.inheritedFromId,
|
|
9396
|
+
inheritedFromTitle: r.inheritedFromTitle
|
|
9311
9397
|
});
|
|
9312
9398
|
}
|
|
9313
9399
|
}
|
|
9314
|
-
|
|
9315
|
-
let
|
|
9316
|
-
channelId:
|
|
9317
|
-
treeId:
|
|
9318
|
-
language:
|
|
9319
|
-
node:
|
|
9400
|
+
await Promise.all(Object.keys(P).map((e) => Bi(t, P[e], u)));
|
|
9401
|
+
let pe = {
|
|
9402
|
+
channelId: u || d,
|
|
9403
|
+
treeId: y,
|
|
9404
|
+
language: S.language,
|
|
9405
|
+
node: S,
|
|
9320
9406
|
content: P,
|
|
9321
9407
|
regionMeta: F
|
|
9322
9408
|
};
|
|
9323
|
-
return
|
|
9409
|
+
return s || (e.header("X-Cache", "MISS"), await $i(f, p, pe, Qi(e))), e.json(pe);
|
|
9324
9410
|
} catch (t) {
|
|
9325
9411
|
return console.error("[CMS Public API] Error fetching node by path:", t), e.json({
|
|
9326
9412
|
error: "Failed to fetch JSON payload",
|
|
@@ -9330,8 +9416,8 @@ Ii.get("/*", async (e) => {
|
|
|
9330
9416
|
});
|
|
9331
9417
|
//#endregion
|
|
9332
9418
|
//#region server/routes/public/tree.ts
|
|
9333
|
-
var
|
|
9334
|
-
function
|
|
9419
|
+
var ea = new e();
|
|
9420
|
+
function ta(e, t) {
|
|
9335
9421
|
let n = /* @__PURE__ */ new Date();
|
|
9336
9422
|
if (e && String(e).trim() !== "") {
|
|
9337
9423
|
let t = new Date(e);
|
|
@@ -9343,7 +9429,14 @@ function Yi(e, t) {
|
|
|
9343
9429
|
}
|
|
9344
9430
|
return !0;
|
|
9345
9431
|
}
|
|
9346
|
-
|
|
9432
|
+
async function na(e, t, n, r) {
|
|
9433
|
+
try {
|
|
9434
|
+
await e.set(t, n, r);
|
|
9435
|
+
} catch (e) {
|
|
9436
|
+
console.warn("[CMS Cache] Failed to write tree response to cache:", e);
|
|
9437
|
+
}
|
|
9438
|
+
}
|
|
9439
|
+
ea.get("/:treeParam", async (e) => {
|
|
9347
9440
|
try {
|
|
9348
9441
|
let t = e.get("db"), n = e.req.param("treeParam"), r = e.req.query("channelId") || e.req.query("channel") || "default", i = e.req.query("preview") === "true";
|
|
9349
9442
|
if (r && r !== "default" && r !== "all") {
|
|
@@ -9369,20 +9462,35 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9369
9462
|
}
|
|
9370
9463
|
let d = [];
|
|
9371
9464
|
if (l !== null) {
|
|
9372
|
-
let e = await t.prepare("\n
|
|
9465
|
+
let e = await t.prepare("\n SELECT \n t.id as treeNodeId,\n t.treeId,\n t.contentId as id,\n t.parentId,\n t.sortOrder,\n c.title,\n c.slug,\n c.language,\n c.contentType as nodeType,\n c.isHidden,\n c.status,\n c.dataJson,\n c.draftDataJson\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE t.treeId = ? AND (c.deletedAt IS NULL OR c.deletedAt = '')\n ORDER BY t.sortOrder ASC\n ").all(l);
|
|
9373
9466
|
d = Array.isArray(e) ? e : e?.results || [];
|
|
9374
9467
|
}
|
|
9375
9468
|
if ((!d || d.length === 0) && !c) return e.json({ error: `Tree '${n}' not found` }, 404);
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9469
|
+
let f = /* @__PURE__ */ new Map();
|
|
9470
|
+
for (let e of d) {
|
|
9471
|
+
let t = !e.parentId || e.parentId === "null" || e.parentId === "" ? null : e.parentId, n = t === null ? "__ROOT__" : String(t), r = f.get(n);
|
|
9472
|
+
r ? r.push(e) : f.set(n, [e]);
|
|
9473
|
+
}
|
|
9474
|
+
let p = /* @__PURE__ */ new Map();
|
|
9475
|
+
for (let e of d) {
|
|
9476
|
+
let t = String(e.treeNodeId), n = i && e.draftDataJson ? e.draftDataJson : e.dataJson;
|
|
9477
|
+
if (!n) {
|
|
9478
|
+
p.set(t, {});
|
|
9479
|
+
continue;
|
|
9480
|
+
}
|
|
9481
|
+
try {
|
|
9482
|
+
let e = typeof n == "string" ? JSON.parse(n) : n;
|
|
9483
|
+
p.set(t, e && typeof e == "object" ? e : {});
|
|
9484
|
+
} catch {
|
|
9485
|
+
p.set(t, {});
|
|
9486
|
+
}
|
|
9487
|
+
}
|
|
9488
|
+
function m(e = null, t = "") {
|
|
9489
|
+
let n = e == null || e === "" || e === "null" ? "__ROOT__" : String(e);
|
|
9490
|
+
return (f.get(n) || []).map((e) => {
|
|
9491
|
+
let n = p.get(String(e.treeNodeId)) || {}, r = {};
|
|
9492
|
+
for (let [e, t] of Object.entries(n)) e !== "_isTreeDraft" && e !== "_draftParentId" && e !== "isNew" && e !== "hidden" && e !== "is_hidden" && e !== "isHidden" && e !== "status" && (r[e] = t);
|
|
9493
|
+
let a = !i && (e.status === "draft" || e.status === "new"), o = !!e.isHidden || a || n.hidden === !0 || n.hidden === 1 || n.hidden === "1" || n.hidden === "true", s = ta(n.startShowingAt, n.stopShowingAt), c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/"), u = {
|
|
9386
9494
|
id: e.id,
|
|
9387
9495
|
treeNodeId: e.treeNodeId,
|
|
9388
9496
|
parentId: e.parentId || null,
|
|
@@ -9392,22 +9500,22 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9392
9500
|
path: l,
|
|
9393
9501
|
nodeType: e.nodeType,
|
|
9394
9502
|
hidden: o || !s ? 1 : 0,
|
|
9395
|
-
summary:
|
|
9503
|
+
summary: r.summary || ""
|
|
9396
9504
|
};
|
|
9397
|
-
e.nodeType === "external-link" && (
|
|
9505
|
+
e.nodeType === "external-link" && (r.url && (u.url = r.url), r.target && (u.target = r.target));
|
|
9398
9506
|
let d = l === "/" ? "" : l;
|
|
9399
|
-
return u.children =
|
|
9507
|
+
return u.children = m(e.treeNodeId, d), u;
|
|
9400
9508
|
}).filter((e) => i || !e.hidden);
|
|
9401
9509
|
}
|
|
9402
|
-
let
|
|
9510
|
+
let h = {
|
|
9403
9511
|
treeId: c?.id || l,
|
|
9404
9512
|
key: c?.key || n,
|
|
9405
9513
|
channelId: r,
|
|
9406
9514
|
label: c?.label || n,
|
|
9407
9515
|
...u,
|
|
9408
|
-
items:
|
|
9516
|
+
items: m(null)
|
|
9409
9517
|
};
|
|
9410
|
-
return i || (
|
|
9518
|
+
return i || (e.header("X-Cache", "MISS"), await na(a, o, h, 300)), e.json(h);
|
|
9411
9519
|
} catch (t) {
|
|
9412
9520
|
return console.error("[CMS Public Tree API] Error:", t), e.json({
|
|
9413
9521
|
error: "Failed to fetch public tree",
|
|
@@ -9417,8 +9525,8 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9417
9525
|
});
|
|
9418
9526
|
//#endregion
|
|
9419
9527
|
//#region server/routes/public/assets.ts
|
|
9420
|
-
var
|
|
9421
|
-
function
|
|
9528
|
+
var ra = new e();
|
|
9529
|
+
function ia(e, t) {
|
|
9422
9530
|
if (t === "webp") return "image/webp";
|
|
9423
9531
|
if (t === "avif") return "image/avif";
|
|
9424
9532
|
if (t === "jpeg" || t === "jpg") return "image/jpeg";
|
|
@@ -9426,7 +9534,7 @@ function Zi(e, t) {
|
|
|
9426
9534
|
let n = e.toLowerCase();
|
|
9427
9535
|
return n.endsWith(".jpg") || n.endsWith(".jpeg") ? "image/jpeg" : n.endsWith(".png") ? "image/png" : n.endsWith(".webp") ? "image/webp" : n.endsWith(".gif") ? "image/gif" : n.endsWith(".svg") ? "image/svg+xml" : n.endsWith(".pdf") ? "application/pdf" : n.endsWith(".mp4") ? "video/mp4" : n.endsWith(".webm") ? "video/webm" : "application/octet-stream";
|
|
9428
9536
|
}
|
|
9429
|
-
|
|
9537
|
+
ra.get("/*", async (e) => {
|
|
9430
9538
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
9431
9539
|
if (!t) return e.text("Asset key missing", 400);
|
|
9432
9540
|
let n = e.env?.MEDIA_BUCKET, { w: r, h: i, q: a, f: o } = e.req.query(), s = !!(r || i || a || o), c = e.req.header("Via")?.includes("image-resizing") || e.req.header("User-Agent")?.includes("Cloudflare-ImgRen");
|
|
@@ -9472,7 +9580,7 @@ Xi.get("/*", async (e) => {
|
|
|
9472
9580
|
if (!s) {
|
|
9473
9581
|
let n = u(g);
|
|
9474
9582
|
return e.body(n, 200, {
|
|
9475
|
-
"Content-Type":
|
|
9583
|
+
"Content-Type": ia(t),
|
|
9476
9584
|
"Cache-Control": "public, max-age=86400"
|
|
9477
9585
|
});
|
|
9478
9586
|
}
|
|
@@ -9480,7 +9588,7 @@ Xi.get("/*", async (e) => {
|
|
|
9480
9588
|
if (l(b)) {
|
|
9481
9589
|
let n = u(b);
|
|
9482
9590
|
return e.body(n, 200, {
|
|
9483
|
-
"Content-Type":
|
|
9591
|
+
"Content-Type": ia(t, v),
|
|
9484
9592
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9485
9593
|
"X-Local-Cache": "HIT"
|
|
9486
9594
|
});
|
|
@@ -9493,14 +9601,14 @@ Xi.get("/*", async (e) => {
|
|
|
9493
9601
|
typeof n == "number" && (a.width = n), typeof c == "number" && (a.height = c), (a.width || a.height) && (a.fit = "cover", i = i.resize(a)), v === "webp" ? i = i.webp({ quality: typeof _ == "number" ? _ : 80 }) : v === "avif" ? i = i.avif({ quality: typeof _ == "number" ? _ : 70 }) : v === "jpeg" || v === "jpg" ? i = i.jpeg({ quality: typeof _ == "number" ? _ : 80 }) : v === "png" && (i = i.png({ quality: typeof _ == "number" ? _ : 80 }));
|
|
9494
9602
|
let o = await i.toBuffer();
|
|
9495
9603
|
return d(m(b), { recursive: !0 }), f(b, o), e.body(o, 200, {
|
|
9496
|
-
"Content-Type":
|
|
9604
|
+
"Content-Type": ia(t, v),
|
|
9497
9605
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9498
9606
|
"X-Local-Cache": "MISS"
|
|
9499
9607
|
});
|
|
9500
9608
|
} catch {
|
|
9501
9609
|
let n = u(g);
|
|
9502
9610
|
return e.body(n, 200, {
|
|
9503
|
-
"Content-Type":
|
|
9611
|
+
"Content-Type": ia(t),
|
|
9504
9612
|
"Cache-Control": "public, max-age=86400"
|
|
9505
9613
|
});
|
|
9506
9614
|
}
|
|
@@ -9511,8 +9619,8 @@ Xi.get("/*", async (e) => {
|
|
|
9511
9619
|
});
|
|
9512
9620
|
//#endregion
|
|
9513
9621
|
//#region server/routes/public/paths.ts
|
|
9514
|
-
var
|
|
9515
|
-
function
|
|
9622
|
+
var aa = new e();
|
|
9623
|
+
function oa(e, t) {
|
|
9516
9624
|
let n = /* @__PURE__ */ new Date();
|
|
9517
9625
|
if (e && String(e).trim() !== "") {
|
|
9518
9626
|
let t = new Date(e);
|
|
@@ -9524,37 +9632,48 @@ function $i(e, t) {
|
|
|
9524
9632
|
}
|
|
9525
9633
|
return !0;
|
|
9526
9634
|
}
|
|
9527
|
-
|
|
9635
|
+
aa.get("/", async (e) => {
|
|
9528
9636
|
try {
|
|
9529
|
-
let t = await e.get("db").prepare("\n
|
|
9530
|
-
|
|
9531
|
-
let
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
let
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9637
|
+
let t = await e.get("db").prepare("\n SELECT\n t.id as treeNodeId,\n t.parentId,\n c.slug,\n c.contentType as nodeType,\n c.status,\n c.dataJson\n FROM tree_nodes t\n INNER JOIN content_nodes c ON t.contentId = c.id\n WHERE (c.deletedAt IS NULL OR c.deletedAt = '')\n ORDER BY t.sortOrder ASC\n ").all(), n = Array.isArray(t) ? t : t?.results || [], r = [], i = /* @__PURE__ */ new Map();
|
|
9638
|
+
for (let e of n) {
|
|
9639
|
+
let t = !e.parentId || e.parentId === "null" || e.parentId === "" ? null : e.parentId, n = t === null ? "__ROOT__" : String(t), r = i.get(n);
|
|
9640
|
+
r ? r.push(e) : i.set(n, [e]);
|
|
9641
|
+
}
|
|
9642
|
+
let a = /* @__PURE__ */ new Map();
|
|
9643
|
+
for (let e of n) {
|
|
9644
|
+
let t = String(e.treeNodeId);
|
|
9645
|
+
if (!e.dataJson) {
|
|
9646
|
+
a.set(t, {});
|
|
9647
|
+
continue;
|
|
9648
|
+
}
|
|
9649
|
+
try {
|
|
9650
|
+
let n = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
9651
|
+
a.set(t, n && typeof n == "object" ? n : {});
|
|
9652
|
+
} catch {
|
|
9653
|
+
a.set(t, {});
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9656
|
+
function o(e = null, t = "") {
|
|
9657
|
+
let n = e == null || e === "" || e === "null" ? "__ROOT__" : String(e), s = i.get(n) || [];
|
|
9658
|
+
for (let e of s) {
|
|
9659
|
+
let n = a.get(String(e.treeNodeId)) || {}, i = e.status === "published" || e.status === "active", s = oa(n.startShowingAt, n.stopShowingAt);
|
|
9660
|
+
if (!i || !s) continue;
|
|
9661
|
+
let c = (e.slug || "").replace(/^\/+|\/+$/g, ""), l = c === "home" || c === "homee" ? "/" : `${t}/${c}`.replace(/\/+/g, "/");
|
|
9662
|
+
e.nodeType !== "external-link" && r.push(l);
|
|
9663
|
+
let u = l === "/" ? "" : l;
|
|
9664
|
+
o(e.treeNodeId, u);
|
|
9546
9665
|
}
|
|
9547
9666
|
}
|
|
9548
|
-
|
|
9549
|
-
let
|
|
9550
|
-
return e.json(
|
|
9667
|
+
o(null);
|
|
9668
|
+
let s = [...new Set(r)];
|
|
9669
|
+
return e.json(s);
|
|
9551
9670
|
} catch (t) {
|
|
9552
9671
|
return console.error("[CMS Paths API] Error:", t), e.json({ error: "Failed to fetch paths" }, 500);
|
|
9553
9672
|
}
|
|
9554
9673
|
});
|
|
9555
9674
|
//#endregion
|
|
9556
9675
|
//#region server/index.ts
|
|
9557
|
-
var $ = new e(),
|
|
9676
|
+
var $ = new e(), sa = !1;
|
|
9558
9677
|
$.use("*", o()), $.use("/media/*", o({
|
|
9559
9678
|
origin: "*",
|
|
9560
9679
|
allowMethods: [
|
|
@@ -9575,13 +9694,13 @@ $.use("*", o()), $.use("/media/*", o({
|
|
|
9575
9694
|
let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
|
|
9576
9695
|
e.set("currentDomain", r);
|
|
9577
9696
|
let i = u(e);
|
|
9578
|
-
if (e.set("db", i), !
|
|
9579
|
-
await Pr(i),
|
|
9697
|
+
if (e.set("db", i), !sa) try {
|
|
9698
|
+
await Pr(i), sa = !0;
|
|
9580
9699
|
} catch (e) {
|
|
9581
9700
|
console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
|
|
9582
9701
|
}
|
|
9583
9702
|
await t();
|
|
9584
|
-
}), $.route("/media",
|
|
9703
|
+
}), $.route("/media", ra), $.use("/media/*", Lr()), $.route("/api/cms/nodes", X), $.route("/api/cms/nodes.json", X), $.route("/api/cms/formcsv", X), $.route("/api/cms/formcsv.json", X), $.route("/api/cms/stats", Mi), $.route("/api/cms/stats.json", Mi), $.route("/api/cms", xi), $.route("/api/cms/channels", Ti), $.route("/api/cms/channels.json", Ti), $.route("/api/cms/schemas", Ei), $.route("/api/cms/schemas.json", Ei), $.route("/api/cms", ki), $.route("/api/admin/assets", Z), $.route("/api/v1/node", Ii), $.route("/api/v1/page", Ii), $.route("/api/v1/tree", ea), $.route("/api/v1/all-paths", aa), $.get("*", async (e) => {
|
|
9585
9704
|
if (e.env?.ASSETS) {
|
|
9586
9705
|
let t = await e.env.ASSETS.fetch(e.req.raw);
|
|
9587
9706
|
if (t.status === 404) {
|