@brightsideoy/kama 0.1.0-alpha.62 → 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/defaults/definitions/blocks/button.yaml +15 -0
- package/definitions/editor/button.ts +11 -0
- package/definitions/editor/default.ts +4 -0
- package/definitions/editor/minimal.ts +2 -0
- package/dist/assets/index-BwhzZuhD.js +1388 -0
- package/dist/assets/{index-Bdgd-8l4.css → index-CZFirq-c.css} +1 -1
- package/dist/index.html +2 -2
- package/dist/index.js +521 -370
- package/package.json +1 -1
- package/dist/assets/index-ay1nW_ZN.js +0 -1374
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: {
|
|
@@ -4865,6 +4865,22 @@ var kr = /* @__PURE__ */ a({
|
|
|
4865
4865
|
}
|
|
4866
4866
|
},
|
|
4867
4867
|
rawBlocks: {
|
|
4868
|
+
button: {
|
|
4869
|
+
id: "button",
|
|
4870
|
+
label: "Button",
|
|
4871
|
+
group: "Content",
|
|
4872
|
+
description: "Button text",
|
|
4873
|
+
fields: [
|
|
4874
|
+
{ text: {
|
|
4875
|
+
label: "Text",
|
|
4876
|
+
type: "richtext",
|
|
4877
|
+
editor: "button",
|
|
4878
|
+
public: !0
|
|
4879
|
+
} },
|
|
4880
|
+
{ fieldSet: "access" },
|
|
4881
|
+
{ hidden: { default: !1 } }
|
|
4882
|
+
]
|
|
4883
|
+
},
|
|
4868
4884
|
header: {
|
|
4869
4885
|
id: "header",
|
|
4870
4886
|
label: "Header",
|
|
@@ -5043,6 +5059,22 @@ var kr = /* @__PURE__ */ a({
|
|
|
5043
5059
|
}
|
|
5044
5060
|
},
|
|
5045
5061
|
rawElements: {
|
|
5062
|
+
button: {
|
|
5063
|
+
id: "button",
|
|
5064
|
+
label: "Button",
|
|
5065
|
+
group: "Content",
|
|
5066
|
+
description: "Button text",
|
|
5067
|
+
fields: [
|
|
5068
|
+
{ text: {
|
|
5069
|
+
label: "Text",
|
|
5070
|
+
type: "richtext",
|
|
5071
|
+
editor: "button",
|
|
5072
|
+
public: !0
|
|
5073
|
+
} },
|
|
5074
|
+
{ fieldSet: "access" },
|
|
5075
|
+
{ hidden: { default: !1 } }
|
|
5076
|
+
]
|
|
5077
|
+
},
|
|
5046
5078
|
header: {
|
|
5047
5079
|
id: "header",
|
|
5048
5080
|
label: "Header",
|
|
@@ -7362,7 +7394,7 @@ function ui(e) {
|
|
|
7362
7394
|
D[e] = J(D[e] || {}, t);
|
|
7363
7395
|
});
|
|
7364
7396
|
});
|
|
7365
|
-
let
|
|
7397
|
+
let ee = p ? {
|
|
7366
7398
|
...p,
|
|
7367
7399
|
fields: D
|
|
7368
7400
|
} : null;
|
|
@@ -7376,7 +7408,7 @@ function ui(e) {
|
|
|
7376
7408
|
nodeTemplate: u || null,
|
|
7377
7409
|
treeTemplate: d || null,
|
|
7378
7410
|
channelTemplate: E,
|
|
7379
|
-
userTemplate:
|
|
7411
|
+
userTemplate: ee
|
|
7380
7412
|
};
|
|
7381
7413
|
}
|
|
7382
7414
|
//#endregion
|
|
@@ -7711,7 +7743,7 @@ X.get("/", async (e) => {
|
|
|
7711
7743
|
`).all(...T), a = Array.isArray(i) ? i : a?.results || [];
|
|
7712
7744
|
for (let e of a) D[e.nodeId] || (D[e.nodeId] = []), D[e.nodeId].includes(e.label) || D[e.nodeId].push(e.label);
|
|
7713
7745
|
}
|
|
7714
|
-
let
|
|
7746
|
+
let ee = await Promise.all(w.map(async (e) => {
|
|
7715
7747
|
let n = (e.status === "draft" || !e.status) && !!e.publishedAt, r = {
|
|
7716
7748
|
id: e.id,
|
|
7717
7749
|
title: e.title,
|
|
@@ -7739,9 +7771,9 @@ X.get("/", async (e) => {
|
|
|
7739
7771
|
return r;
|
|
7740
7772
|
}));
|
|
7741
7773
|
return e.json({
|
|
7742
|
-
items:
|
|
7774
|
+
items: ee,
|
|
7743
7775
|
total: v,
|
|
7744
|
-
hasMore: p +
|
|
7776
|
+
hasMore: p + ee.length < v,
|
|
7745
7777
|
offset: p,
|
|
7746
7778
|
limit: f
|
|
7747
7779
|
});
|
|
@@ -8854,7 +8886,18 @@ Z.get("/", async (e) => {
|
|
|
8854
8886
|
//#endregion
|
|
8855
8887
|
//#region server/routes/public/node.ts
|
|
8856
8888
|
var Ii = new e();
|
|
8857
|
-
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) {
|
|
8858
8901
|
let n = /* @__PURE__ */ new Date();
|
|
8859
8902
|
if (e && String(e).trim() !== "") {
|
|
8860
8903
|
let t = new Date(e);
|
|
@@ -8866,38 +8909,19 @@ function Li(e, t) {
|
|
|
8866
8909
|
}
|
|
8867
8910
|
return !0;
|
|
8868
8911
|
}
|
|
8869
|
-
async function
|
|
8870
|
-
if (!t || typeof t != "object") return t;
|
|
8871
|
-
let n = { ...t };
|
|
8872
|
-
for (let [t, r] of Object.entries(n)) if (typeof r == "string" && r.startsWith("ast_")) try {
|
|
8873
|
-
let i = await e.prepare("SELECT * FROM assets WHERE id = ? AND deletedAt IS NULL").get(r);
|
|
8874
|
-
if (i) {
|
|
8875
|
-
let e = null;
|
|
8876
|
-
if (i.cropCoordinatesJson) try {
|
|
8877
|
-
e = typeof i.cropCoordinatesJson == "string" ? JSON.parse(i.cropCoordinatesJson) : i.cropCoordinatesJson;
|
|
8878
|
-
} catch {}
|
|
8879
|
-
n[t] = {
|
|
8880
|
-
id: i.id,
|
|
8881
|
-
url: i.cdnUrl || `/media/uploads/${i.filename}`,
|
|
8882
|
-
originalUrl: i.cdnUrl || `/media/uploads/${i.filename}`,
|
|
8883
|
-
parentAssetId: i.parentAssetId || null,
|
|
8884
|
-
cropCoordinates: e,
|
|
8885
|
-
filename: i.filename,
|
|
8886
|
-
mimeType: i.mimeType
|
|
8887
|
-
};
|
|
8888
|
-
}
|
|
8889
|
-
} catch {}
|
|
8890
|
-
else typeof r == "object" && r && !Array.isArray(r) && !r.url && (n[t] = await Ri(e, r));
|
|
8891
|
-
return n;
|
|
8892
|
-
}
|
|
8893
|
-
async function zi(e, t, n) {
|
|
8912
|
+
async function Bi(e, t, n) {
|
|
8894
8913
|
let r = t.filter((e) => e.componentId === "content-feed" || e.componentId === "article-list");
|
|
8895
|
-
|
|
8914
|
+
await Promise.all(r.map(async (t) => {
|
|
8896
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];
|
|
8897
8916
|
n && n !== "all" && (s += " AND id IN (SELECT nodeId FROM node_channels WHERE channelId = ?)", c.push(Number(n) || n));
|
|
8898
8917
|
let l = "ORDER BY updatedAt DESC";
|
|
8899
8918
|
o === "published_desc" || o === "createdAt" ? l = "ORDER BY createdAt DESC" : o === "title_asc" && (l = "ORDER BY LOWER(title) ASC");
|
|
8900
|
-
let u = `
|
|
8919
|
+
let u = `
|
|
8920
|
+
SELECT id, title, slug, language, dataJson, createdAt, updatedAt
|
|
8921
|
+
${s}
|
|
8922
|
+
${l}
|
|
8923
|
+
LIMIT ?
|
|
8924
|
+
`;
|
|
8901
8925
|
c.push(a);
|
|
8902
8926
|
try {
|
|
8903
8927
|
let n = await e.prepare(u).all(...c), r = Array.isArray(n) ? n : n?.results || [];
|
|
@@ -8906,7 +8930,7 @@ async function zi(e, t, n) {
|
|
|
8906
8930
|
if (e.dataJson) try {
|
|
8907
8931
|
t = typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson;
|
|
8908
8932
|
} catch {}
|
|
8909
|
-
return
|
|
8933
|
+
return zi(t.startShowingAt, t.stopShowingAt) ? {
|
|
8910
8934
|
id: e.id,
|
|
8911
8935
|
title: e.title,
|
|
8912
8936
|
slug: e.slug,
|
|
@@ -8921,61 +8945,88 @@ async function zi(e, t, n) {
|
|
|
8921
8945
|
} catch (e) {
|
|
8922
8946
|
console.error("[CMS Hydration] Failed to hydrate content feed block", e), t.data.initialItems = [];
|
|
8923
8947
|
}
|
|
8924
|
-
}
|
|
8948
|
+
}));
|
|
8925
8949
|
}
|
|
8926
|
-
async function
|
|
8950
|
+
async function Vi(e, t, n, r, i = !1, a) {
|
|
8927
8951
|
if (!t) return { blocks: [] };
|
|
8928
|
-
let
|
|
8929
|
-
if (!
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
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 = {};
|
|
8953
8990
|
try {
|
|
8954
|
-
|
|
8991
|
+
t = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
8955
8992
|
} catch {}
|
|
8956
|
-
let
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
instanceId: t.id,
|
|
8963
|
-
blockId: f,
|
|
8964
|
-
componentId: u,
|
|
8965
|
-
data: p
|
|
8966
|
-
});
|
|
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
|
+
}
|
|
8967
8999
|
}
|
|
8968
|
-
if (c[n] && c[n].length > 0) return {
|
|
8969
|
-
blocks: c[n],
|
|
8970
|
-
subRegions: c,
|
|
8971
|
-
inheritedFromId: String(t.contentId),
|
|
8972
|
-
inheritedFromTitle: t.title || t.slug
|
|
8973
|
-
};
|
|
8974
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
|
+
};
|
|
8975
9026
|
}
|
|
8976
9027
|
return { blocks: [] };
|
|
8977
9028
|
}
|
|
8978
|
-
function
|
|
9029
|
+
function Hi(e, t = {}) {
|
|
8979
9030
|
let n = {};
|
|
8980
9031
|
for (let [r, i] of Object.entries(e)) {
|
|
8981
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;
|
|
@@ -8984,14 +9035,14 @@ function Vi(e, t = {}) {
|
|
|
8984
9035
|
}
|
|
8985
9036
|
return n;
|
|
8986
9037
|
}
|
|
8987
|
-
function
|
|
8988
|
-
if (Array.isArray(e)) return e.map(
|
|
9038
|
+
function Ui(e) {
|
|
9039
|
+
if (Array.isArray(e)) return e.map(Ui);
|
|
8989
9040
|
if (!e || typeof e != "object") return e;
|
|
8990
9041
|
if (typeof e.id == "string" && e.id.startsWith("ast_") && typeof e.url == "string") {
|
|
8991
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 ? {
|
|
8992
9043
|
...t,
|
|
8993
9044
|
...t.crops?.[r] || {}
|
|
8994
|
-
} : 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({
|
|
8995
9046
|
...n,
|
|
8996
9047
|
title: n?.title ?? e.title ?? "",
|
|
8997
9048
|
alt: n?.alt ?? e.alt ?? "",
|
|
@@ -9005,70 +9056,101 @@ function Hi(e) {
|
|
|
9005
9056
|
...Object.keys(a).length > 0 ? { variants: a } : {}
|
|
9006
9057
|
};
|
|
9007
9058
|
}
|
|
9008
|
-
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e,
|
|
9059
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Ui(t)]));
|
|
9009
9060
|
}
|
|
9010
|
-
async function
|
|
9061
|
+
async function Wi(e, t, n) {
|
|
9011
9062
|
if (typeof t == "string") {
|
|
9012
9063
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
9013
|
-
let n = /* @__PURE__ */ new Set();
|
|
9014
|
-
for (let e of t.matchAll(/(?:#node:|data-node-id=["'])([^"'\s>]+)/gi)) n.add(e[1]);
|
|
9015
9064
|
let r = /* @__PURE__ */ new Set();
|
|
9016
|
-
for (let e of t.matchAll(/(?:#
|
|
9017
|
-
|
|
9018
|
-
let
|
|
9019
|
-
|
|
9020
|
-
let
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
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) => {
|
|
9030
9091
|
let n = t.match(/data-node-id=["']([^"']+)["']/i), r = t.match(/data-asset-id=["']([^"']+)["']/i), i = t.match(/href=["']([^"']+)["']/i);
|
|
9031
9092
|
if (i?.[1].startsWith("mailto:")) return `<a${t.replace(/\s+target=["'][^"']*["']/i, "")}>`;
|
|
9032
|
-
let a = i?.[1].match(/^#node:(.+)$/i),
|
|
9033
|
-
if (!
|
|
9034
|
-
if (c && !
|
|
9035
|
-
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);
|
|
9036
9097
|
return n && i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${n}"`).replace(/data-asset-id=["'][^"']*["']/i, `data-asset-id="${c}"`)}>` : e;
|
|
9037
9098
|
}
|
|
9038
|
-
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}`);
|
|
9039
9100
|
return i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${g || "/"}"`)}>` : e;
|
|
9040
9101
|
});
|
|
9041
9102
|
}
|
|
9042
|
-
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)));
|
|
9043
9104
|
if (t && typeof t == "object") {
|
|
9044
9105
|
if (typeof t.href == "string" && (t.href.startsWith("#node:") || t.href.startsWith("#asset:"))) return {
|
|
9045
9106
|
...t,
|
|
9046
|
-
href: await
|
|
9107
|
+
href: await Gi(e, t, n)
|
|
9047
9108
|
};
|
|
9048
|
-
let
|
|
9049
|
-
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);
|
|
9050
9111
|
}
|
|
9051
9112
|
return t;
|
|
9052
9113
|
}
|
|
9053
|
-
async function
|
|
9054
|
-
let
|
|
9055
|
-
if (
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
}
|
|
9059
|
-
if (!n) return t.href;
|
|
9060
|
-
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];
|
|
9061
9119
|
if (t.treeId) {
|
|
9062
|
-
let
|
|
9063
|
-
if (
|
|
9064
|
-
let
|
|
9065
|
-
if (
|
|
9066
|
-
}
|
|
9067
|
-
}
|
|
9068
|
-
let
|
|
9069
|
-
return
|
|
9070
|
-
}
|
|
9071
|
-
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) {
|
|
9072
9154
|
let t = e.socialImage;
|
|
9073
9155
|
if (!t || typeof t != "object") return null;
|
|
9074
9156
|
let n = (e, t) => {
|
|
@@ -9099,19 +9181,27 @@ function Gi(e) {
|
|
|
9099
9181
|
])
|
|
9100
9182
|
};
|
|
9101
9183
|
}
|
|
9102
|
-
async function
|
|
9184
|
+
async function Xi(e, t, n, r) {
|
|
9103
9185
|
if (!t) return "";
|
|
9104
|
-
let
|
|
9105
|
-
|
|
9106
|
-
let
|
|
9107
|
-
|
|
9186
|
+
let i = Ri(t, n);
|
|
9187
|
+
if (r) {
|
|
9188
|
+
let e = r.fullPath.get(i);
|
|
9189
|
+
if (e) return e;
|
|
9108
9190
|
}
|
|
9109
|
-
|
|
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;
|
|
9110
9200
|
}
|
|
9111
|
-
async function
|
|
9201
|
+
async function Zi(e, t, n, r, i) {
|
|
9112
9202
|
let a = {}, o = null;
|
|
9113
9203
|
if (t) {
|
|
9114
|
-
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([
|
|
9115
9205
|
"subpageLayoutId",
|
|
9116
9206
|
"layoutId",
|
|
9117
9207
|
"slug",
|
|
@@ -9136,7 +9226,7 @@ async function qi(e, t, n, r, i) {
|
|
|
9136
9226
|
}
|
|
9137
9227
|
if (!o) {
|
|
9138
9228
|
let t = await e.prepare("SELECT dataJson FROM trees WHERE id = ?").get(n);
|
|
9139
|
-
if (t
|
|
9229
|
+
if (t?.dataJson) try {
|
|
9140
9230
|
let e = typeof t.dataJson == "string" ? JSON.parse(t.dataJson) : t.dataJson;
|
|
9141
9231
|
e.subpageLayoutId && e.subpageLayoutId !== "inherit" && (o = e.subpageLayoutId);
|
|
9142
9232
|
} catch {}
|
|
@@ -9146,114 +9236,142 @@ async function qi(e, t, n, r, i) {
|
|
|
9146
9236
|
inheritedFields: a
|
|
9147
9237
|
};
|
|
9148
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
|
+
}
|
|
9149
9250
|
Ii.get("/*", async (e) => {
|
|
9150
9251
|
try {
|
|
9151
|
-
let t = e.get("db"), n = new URL(e.req.url).pathname.match(/\/node\/(.+)$/),
|
|
9152
|
-
if (!
|
|
9153
|
-
let
|
|
9154
|
-
if (!
|
|
9155
|
-
let
|
|
9156
|
-
if (!
|
|
9157
|
-
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);
|
|
9158
9259
|
if (t) return e.header("X-Cache", "HIT"), e.json(t);
|
|
9159
9260
|
}
|
|
9160
|
-
let
|
|
9161
|
-
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);
|
|
9162
9263
|
else {
|
|
9163
|
-
let e =
|
|
9164
|
-
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
|
|
9165
9270
|
FROM content_nodes cn
|
|
9166
|
-
INNER JOIN tree_nodes tn
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
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
|
+
}
|
|
9175
9288
|
}
|
|
9176
9289
|
}
|
|
9177
|
-
!
|
|
9178
|
-
}
|
|
9179
|
-
if (!
|
|
9180
|
-
if (!
|
|
9181
|
-
let e =
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
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 || {});
|
|
9201
9318
|
});
|
|
9202
|
-
let
|
|
9319
|
+
let E = {}, D = null, ee = null, O = !1, k = {}, A = s && g.draftDataJson ? g.draftDataJson : g.dataJson || g.draftDataJson;
|
|
9203
9320
|
if (A) try {
|
|
9204
9321
|
k = typeof A == "string" ? JSON.parse(A) : A;
|
|
9205
9322
|
} catch {}
|
|
9206
|
-
k.disabledRegions && (
|
|
9207
|
-
let
|
|
9208
|
-
for (let [e, t] of Object.entries(
|
|
9209
|
-
let
|
|
9210
|
-
|
|
9211
|
-
let
|
|
9212
|
-
delete
|
|
9213
|
-
let
|
|
9214
|
-
if (!
|
|
9215
|
-
let
|
|
9216
|
-
if (
|
|
9217
|
-
let e = await t.prepare("\n
|
|
9218
|
-
|
|
9219
|
-
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;
|
|
9220
9337
|
try {
|
|
9221
9338
|
t = (typeof n == "string" ? JSON.parse(n) : n) || {};
|
|
9222
9339
|
} catch {}
|
|
9223
|
-
let i = !!e.isHidden || t.hidden === !0 || t.hidden === 1 || t.hidden === "1", a =
|
|
9224
|
-
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 : {
|
|
9225
9342
|
treeNodeId: e.treeNodeId,
|
|
9226
9343
|
id: e.id,
|
|
9227
9344
|
title: e.title,
|
|
9228
|
-
slug:
|
|
9345
|
+
slug: o,
|
|
9229
9346
|
language: e.language || "en",
|
|
9230
|
-
path: `${r}/${
|
|
9347
|
+
path: `${r}/${o}`.replace(/\/+/g, "/"),
|
|
9231
9348
|
nodeType: e.nodeType
|
|
9232
9349
|
};
|
|
9233
9350
|
}).filter(Boolean);
|
|
9234
9351
|
}
|
|
9235
|
-
|
|
9236
|
-
let
|
|
9237
|
-
|
|
9238
|
-
let P = {}, F = {}
|
|
9239
|
-
|
|
9240
|
-
let n = e.region || "main";
|
|
9241
|
-
P[n] || (P[n] = [], F[n] = { isInherited: !1 });
|
|
9242
|
-
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 = {};
|
|
9243
9357
|
try {
|
|
9244
|
-
|
|
9358
|
+
i = (typeof e.dataJson == "string" ? JSON.parse(e.dataJson) : e.dataJson) || {};
|
|
9245
9359
|
} catch {}
|
|
9246
|
-
let
|
|
9247
|
-
if (!
|
|
9248
|
-
let
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
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 = {
|
|
9257
9375
|
header: {
|
|
9258
9376
|
label: "Header",
|
|
9259
9377
|
inherit: "parent"
|
|
@@ -9262,33 +9380,33 @@ Ii.get("/*", async (e) => {
|
|
|
9262
9380
|
label: "Footer",
|
|
9263
9381
|
inherit: "parent"
|
|
9264
9382
|
},
|
|
9265
|
-
...(
|
|
9383
|
+
...(ae ? m.nodeLayouts?.[ae] || m.layouts?.[ae] : null)?.regions || { main: { label: "Content" } }
|
|
9266
9384
|
};
|
|
9267
|
-
for (let [e,
|
|
9268
|
-
let
|
|
9269
|
-
if (P[e] || (P[e] = [], F[e] = { isInherited: !1 }), (
|
|
9270
|
-
let
|
|
9271
|
-
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] = {
|
|
9272
9390
|
isInherited: !0,
|
|
9273
|
-
inheritedFromId:
|
|
9274
|
-
inheritedFromTitle:
|
|
9275
|
-
},
|
|
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] = {
|
|
9276
9394
|
isInherited: !0,
|
|
9277
|
-
inheritedFromId:
|
|
9278
|
-
inheritedFromTitle:
|
|
9395
|
+
inheritedFromId: r.inheritedFromId,
|
|
9396
|
+
inheritedFromTitle: r.inheritedFromTitle
|
|
9279
9397
|
});
|
|
9280
9398
|
}
|
|
9281
9399
|
}
|
|
9282
|
-
|
|
9283
|
-
let
|
|
9284
|
-
channelId:
|
|
9285
|
-
treeId:
|
|
9286
|
-
language:
|
|
9287
|
-
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,
|
|
9288
9406
|
content: P,
|
|
9289
9407
|
regionMeta: F
|
|
9290
9408
|
};
|
|
9291
|
-
return
|
|
9409
|
+
return s || (e.header("X-Cache", "MISS"), await $i(f, p, pe, Qi(e))), e.json(pe);
|
|
9292
9410
|
} catch (t) {
|
|
9293
9411
|
return console.error("[CMS Public API] Error fetching node by path:", t), e.json({
|
|
9294
9412
|
error: "Failed to fetch JSON payload",
|
|
@@ -9298,8 +9416,8 @@ Ii.get("/*", async (e) => {
|
|
|
9298
9416
|
});
|
|
9299
9417
|
//#endregion
|
|
9300
9418
|
//#region server/routes/public/tree.ts
|
|
9301
|
-
var
|
|
9302
|
-
function
|
|
9419
|
+
var ea = new e();
|
|
9420
|
+
function ta(e, t) {
|
|
9303
9421
|
let n = /* @__PURE__ */ new Date();
|
|
9304
9422
|
if (e && String(e).trim() !== "") {
|
|
9305
9423
|
let t = new Date(e);
|
|
@@ -9311,7 +9429,14 @@ function Yi(e, t) {
|
|
|
9311
9429
|
}
|
|
9312
9430
|
return !0;
|
|
9313
9431
|
}
|
|
9314
|
-
|
|
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) => {
|
|
9315
9440
|
try {
|
|
9316
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";
|
|
9317
9442
|
if (r && r !== "default" && r !== "all") {
|
|
@@ -9337,20 +9462,35 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9337
9462
|
}
|
|
9338
9463
|
let d = [];
|
|
9339
9464
|
if (l !== null) {
|
|
9340
|
-
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);
|
|
9341
9466
|
d = Array.isArray(e) ? e : e?.results || [];
|
|
9342
9467
|
}
|
|
9343
9468
|
if ((!d || d.length === 0) && !c) return e.json({ error: `Tree '${n}' not found` }, 404);
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
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 = {
|
|
9354
9494
|
id: e.id,
|
|
9355
9495
|
treeNodeId: e.treeNodeId,
|
|
9356
9496
|
parentId: e.parentId || null,
|
|
@@ -9360,22 +9500,22 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9360
9500
|
path: l,
|
|
9361
9501
|
nodeType: e.nodeType,
|
|
9362
9502
|
hidden: o || !s ? 1 : 0,
|
|
9363
|
-
summary:
|
|
9503
|
+
summary: r.summary || ""
|
|
9364
9504
|
};
|
|
9365
|
-
e.nodeType === "external-link" && (
|
|
9505
|
+
e.nodeType === "external-link" && (r.url && (u.url = r.url), r.target && (u.target = r.target));
|
|
9366
9506
|
let d = l === "/" ? "" : l;
|
|
9367
|
-
return u.children =
|
|
9507
|
+
return u.children = m(e.treeNodeId, d), u;
|
|
9368
9508
|
}).filter((e) => i || !e.hidden);
|
|
9369
9509
|
}
|
|
9370
|
-
let
|
|
9510
|
+
let h = {
|
|
9371
9511
|
treeId: c?.id || l,
|
|
9372
9512
|
key: c?.key || n,
|
|
9373
9513
|
channelId: r,
|
|
9374
9514
|
label: c?.label || n,
|
|
9375
9515
|
...u,
|
|
9376
|
-
items:
|
|
9516
|
+
items: m(null)
|
|
9377
9517
|
};
|
|
9378
|
-
return i || (
|
|
9518
|
+
return i || (e.header("X-Cache", "MISS"), await na(a, o, h, 300)), e.json(h);
|
|
9379
9519
|
} catch (t) {
|
|
9380
9520
|
return console.error("[CMS Public Tree API] Error:", t), e.json({
|
|
9381
9521
|
error: "Failed to fetch public tree",
|
|
@@ -9385,8 +9525,8 @@ Ji.get("/:treeParam", async (e) => {
|
|
|
9385
9525
|
});
|
|
9386
9526
|
//#endregion
|
|
9387
9527
|
//#region server/routes/public/assets.ts
|
|
9388
|
-
var
|
|
9389
|
-
function
|
|
9528
|
+
var ra = new e();
|
|
9529
|
+
function ia(e, t) {
|
|
9390
9530
|
if (t === "webp") return "image/webp";
|
|
9391
9531
|
if (t === "avif") return "image/avif";
|
|
9392
9532
|
if (t === "jpeg" || t === "jpg") return "image/jpeg";
|
|
@@ -9394,7 +9534,7 @@ function Zi(e, t) {
|
|
|
9394
9534
|
let n = e.toLowerCase();
|
|
9395
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";
|
|
9396
9536
|
}
|
|
9397
|
-
|
|
9537
|
+
ra.get("/*", async (e) => {
|
|
9398
9538
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
9399
9539
|
if (!t) return e.text("Asset key missing", 400);
|
|
9400
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");
|
|
@@ -9440,7 +9580,7 @@ Xi.get("/*", async (e) => {
|
|
|
9440
9580
|
if (!s) {
|
|
9441
9581
|
let n = u(g);
|
|
9442
9582
|
return e.body(n, 200, {
|
|
9443
|
-
"Content-Type":
|
|
9583
|
+
"Content-Type": ia(t),
|
|
9444
9584
|
"Cache-Control": "public, max-age=86400"
|
|
9445
9585
|
});
|
|
9446
9586
|
}
|
|
@@ -9448,7 +9588,7 @@ Xi.get("/*", async (e) => {
|
|
|
9448
9588
|
if (l(b)) {
|
|
9449
9589
|
let n = u(b);
|
|
9450
9590
|
return e.body(n, 200, {
|
|
9451
|
-
"Content-Type":
|
|
9591
|
+
"Content-Type": ia(t, v),
|
|
9452
9592
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9453
9593
|
"X-Local-Cache": "HIT"
|
|
9454
9594
|
});
|
|
@@ -9461,14 +9601,14 @@ Xi.get("/*", async (e) => {
|
|
|
9461
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 }));
|
|
9462
9602
|
let o = await i.toBuffer();
|
|
9463
9603
|
return d(m(b), { recursive: !0 }), f(b, o), e.body(o, 200, {
|
|
9464
|
-
"Content-Type":
|
|
9604
|
+
"Content-Type": ia(t, v),
|
|
9465
9605
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9466
9606
|
"X-Local-Cache": "MISS"
|
|
9467
9607
|
});
|
|
9468
9608
|
} catch {
|
|
9469
9609
|
let n = u(g);
|
|
9470
9610
|
return e.body(n, 200, {
|
|
9471
|
-
"Content-Type":
|
|
9611
|
+
"Content-Type": ia(t),
|
|
9472
9612
|
"Cache-Control": "public, max-age=86400"
|
|
9473
9613
|
});
|
|
9474
9614
|
}
|
|
@@ -9479,8 +9619,8 @@ Xi.get("/*", async (e) => {
|
|
|
9479
9619
|
});
|
|
9480
9620
|
//#endregion
|
|
9481
9621
|
//#region server/routes/public/paths.ts
|
|
9482
|
-
var
|
|
9483
|
-
function
|
|
9622
|
+
var aa = new e();
|
|
9623
|
+
function oa(e, t) {
|
|
9484
9624
|
let n = /* @__PURE__ */ new Date();
|
|
9485
9625
|
if (e && String(e).trim() !== "") {
|
|
9486
9626
|
let t = new Date(e);
|
|
@@ -9492,37 +9632,48 @@ function $i(e, t) {
|
|
|
9492
9632
|
}
|
|
9493
9633
|
return !0;
|
|
9494
9634
|
}
|
|
9495
|
-
|
|
9635
|
+
aa.get("/", async (e) => {
|
|
9496
9636
|
try {
|
|
9497
|
-
let t = await e.get("db").prepare("\n
|
|
9498
|
-
|
|
9499
|
-
let
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
let
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
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);
|
|
9514
9665
|
}
|
|
9515
9666
|
}
|
|
9516
|
-
|
|
9517
|
-
let
|
|
9518
|
-
return e.json(
|
|
9667
|
+
o(null);
|
|
9668
|
+
let s = [...new Set(r)];
|
|
9669
|
+
return e.json(s);
|
|
9519
9670
|
} catch (t) {
|
|
9520
9671
|
return console.error("[CMS Paths API] Error:", t), e.json({ error: "Failed to fetch paths" }, 500);
|
|
9521
9672
|
}
|
|
9522
9673
|
});
|
|
9523
9674
|
//#endregion
|
|
9524
9675
|
//#region server/index.ts
|
|
9525
|
-
var $ = new e(),
|
|
9676
|
+
var $ = new e(), sa = !1;
|
|
9526
9677
|
$.use("*", o()), $.use("/media/*", o({
|
|
9527
9678
|
origin: "*",
|
|
9528
9679
|
allowMethods: [
|
|
@@ -9543,13 +9694,13 @@ $.use("*", o()), $.use("/media/*", o({
|
|
|
9543
9694
|
let n = new URL(e.req.url), r = (e.req.header("host") || n.hostname).split(":")[0];
|
|
9544
9695
|
e.set("currentDomain", r);
|
|
9545
9696
|
let i = u(e);
|
|
9546
|
-
if (e.set("db", i), !
|
|
9547
|
-
await Pr(i),
|
|
9697
|
+
if (e.set("db", i), !sa) try {
|
|
9698
|
+
await Pr(i), sa = !0;
|
|
9548
9699
|
} catch (e) {
|
|
9549
9700
|
console.error("❌ [CMS Server] Failed to initialize system tables on cold start:", e);
|
|
9550
9701
|
}
|
|
9551
9702
|
await t();
|
|
9552
|
-
}), $.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) => {
|
|
9553
9704
|
if (e.env?.ASSETS) {
|
|
9554
9705
|
let t = await e.env.ASSETS.fetch(e.req.raw);
|
|
9555
9706
|
if (t.status === 404) {
|