@brightsideoy/kama 0.1.0-alpha.64 → 0.1.0-alpha.66
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/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>KAMA</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BJPfXUUJ.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BvcEh0__.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="app"></div>
|
package/dist/index.js
CHANGED
|
@@ -8898,14 +8898,14 @@ function Ri(...e) {
|
|
|
8898
8898
|
return e.map((e) => String(e ?? "")).join(":");
|
|
8899
8899
|
}
|
|
8900
8900
|
function zi(e, t) {
|
|
8901
|
-
let n =
|
|
8901
|
+
let n = Date.now();
|
|
8902
8902
|
if (e && String(e).trim() !== "") {
|
|
8903
|
-
let t =
|
|
8904
|
-
if (!isNaN(t
|
|
8903
|
+
let t = Date.parse(e);
|
|
8904
|
+
if (!isNaN(t) && n < t) return !1;
|
|
8905
8905
|
}
|
|
8906
8906
|
if (t && String(t).trim() !== "") {
|
|
8907
|
-
let e =
|
|
8908
|
-
if (!isNaN(e
|
|
8907
|
+
let e = Date.parse(t);
|
|
8908
|
+
if (!isNaN(e) && n > e) return !1;
|
|
8909
8909
|
}
|
|
8910
8910
|
return !0;
|
|
8911
8911
|
}
|
|
@@ -9061,43 +9061,49 @@ function Ui(e) {
|
|
|
9061
9061
|
async function Wi(e, t, n) {
|
|
9062
9062
|
if (typeof t == "string") {
|
|
9063
9063
|
if (!t.includes("#node:") && !t.includes("data-node-id") && !t.includes("#asset:") && !t.includes("data-asset-id")) return t;
|
|
9064
|
-
let r =
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
let
|
|
9064
|
+
let r = (e, t) => {
|
|
9065
|
+
let n = e.match(RegExp(`\\b${t}\\s*=\\s*(["'])(.*?)\\1`, "i"));
|
|
9066
|
+
return n ? n[2] : void 0;
|
|
9067
|
+
}, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
|
|
9068
|
+
for (let e of t.matchAll(/(?:#node:|data-node-id\s*=\s*["'])([^"'\s>]+)/gi)) i.add(e[1]);
|
|
9069
|
+
for (let e of t.matchAll(/(?:#asset:|data-asset-id\s*=\s*["'])([^"'\s>]+)/gi)) a.add(e[1]);
|
|
9070
|
+
if (i.size === 0 && a.size === 0) return t;
|
|
9071
|
+
let o = Array.from(i).map(() => "?").join(","), s = i.size > 0 ? await e.prepare(`
|
|
9070
9072
|
SELECT id, slug
|
|
9071
9073
|
FROM content_nodes
|
|
9072
|
-
WHERE id IN (${
|
|
9073
|
-
`).all(...
|
|
9074
|
-
for (let e of
|
|
9075
|
-
let
|
|
9074
|
+
WHERE id IN (${o})
|
|
9075
|
+
`).all(...i) : [], c = Array.isArray(s) ? s : s?.results || [], l = /* @__PURE__ */ new Map();
|
|
9076
|
+
for (let e of c) l.set(String(e.id), String(e.slug || "").replace(/^\/+|\/+$/g, ""));
|
|
9077
|
+
let u = Array.from(a).map(() => "?").join(","), d = a.size > 0 ? await e.prepare(`
|
|
9076
9078
|
SELECT id, cdnUrl, storageKeyPrivate
|
|
9077
9079
|
FROM assets
|
|
9078
|
-
WHERE id IN (${
|
|
9079
|
-
`).all(...
|
|
9080
|
-
for (let e of
|
|
9081
|
-
let
|
|
9082
|
-
return await Promise.all(Array.from(t.matchAll(
|
|
9083
|
-
let
|
|
9084
|
-
if (!
|
|
9085
|
-
let
|
|
9086
|
-
if (
|
|
9087
|
-
let t = await Xi(e, String(
|
|
9088
|
-
|
|
9080
|
+
WHERE id IN (${u})
|
|
9081
|
+
`).all(...a) : [], f = Array.isArray(d) ? d : d?.results || [], p = /* @__PURE__ */ new Map();
|
|
9082
|
+
for (let e of f) p.set(String(e.id), e.cdnUrl || (e.storageKeyPrivate ? `/media/${e.storageKeyPrivate}` : ""));
|
|
9083
|
+
let m = /* @__PURE__ */ new Map(), h = /<a\s+([^>]+)>/gi;
|
|
9084
|
+
return await Promise.all(Array.from(t.matchAll(h)).map(async (t) => {
|
|
9085
|
+
let i = t[1], a = r(i, "data-node-id"), o = r(i, "data-tree-id");
|
|
9086
|
+
if (!a || !o) return;
|
|
9087
|
+
let s = await Ki(e, a, o, n);
|
|
9088
|
+
if (s?.treeNodeId) {
|
|
9089
|
+
let t = await Xi(e, String(s.treeNodeId), o, n);
|
|
9090
|
+
m.set(`${a}:${o}`, t);
|
|
9089
9091
|
}
|
|
9090
|
-
})), t.replace(
|
|
9091
|
-
let n = t
|
|
9092
|
-
if (
|
|
9093
|
-
let
|
|
9094
|
-
if (!
|
|
9095
|
-
if (c && !
|
|
9096
|
-
let n =
|
|
9097
|
-
|
|
9092
|
+
})), t.replace(h, (e, t) => {
|
|
9093
|
+
let n = r(t, "data-node-id"), i = r(t, "data-asset-id"), a = r(t, "href") || "";
|
|
9094
|
+
if (a.startsWith("mailto:")) return `<a ${t.replace(/\s+target\s*=\s*["'][^"']*["']/i, "")}>`;
|
|
9095
|
+
let o = a.match(/^#node:(.+)$/i), s = a.match(/^#asset:(.+)$/i), c = i || s?.[1], u = n || o?.[1];
|
|
9096
|
+
if (!u && !c) return e;
|
|
9097
|
+
if (c && !u) {
|
|
9098
|
+
let n = p.get(c);
|
|
9099
|
+
if (n) {
|
|
9100
|
+
let e = t;
|
|
9101
|
+
return /href\s*=\s*["'][^"']*["']/i.test(e) ? e = e.replace(/href\s*=\s*["'][^"']*["']/i, `href="${n}"`) : e += ` href="${n}"`, i || (e += ` data-asset-id="${c}"`), `<a ${e}>`;
|
|
9102
|
+
}
|
|
9103
|
+
return e;
|
|
9098
9104
|
}
|
|
9099
|
-
let
|
|
9100
|
-
return i ?
|
|
9105
|
+
let d = r(t, "data-tree-id"), f = d ? m.get(`${u}:${d}`) : void 0, h = l.get(u), g = f || (h === void 0 ? "#" : `/${h}`), _ = t;
|
|
9106
|
+
return /href\s*=\s*["'][^"']*["']/i.test(_) ? _ = _.replace(/href\s*=\s*["'][^"']*["']/i, `href="${g || "/"}"`) : _ += ` href="${g || "/"}"`, `<a ${_}>`;
|
|
9101
9107
|
});
|
|
9102
9108
|
}
|
|
9103
9109
|
if (Array.isArray(t)) return Promise.all(t.map((t) => Wi(e, t, n)));
|
|
@@ -9408,9 +9414,11 @@ Ii.get("/*", async (e) => {
|
|
|
9408
9414
|
};
|
|
9409
9415
|
return s || (e.header("X-Cache", "MISS"), await $i(f, p, pe, Qi(e))), e.json(pe);
|
|
9410
9416
|
} catch (t) {
|
|
9411
|
-
|
|
9417
|
+
console.error("[CMS Public API] Error fetching node by path:", t);
|
|
9418
|
+
let n = e.env?.ENVIRONMENT === "development";
|
|
9419
|
+
return e.json({
|
|
9412
9420
|
error: "Failed to fetch JSON payload",
|
|
9413
|
-
details: t.message
|
|
9421
|
+
...n ? { details: t.message } : {}
|
|
9414
9422
|
}, 500);
|
|
9415
9423
|
}
|
|
9416
9424
|
});
|
|
@@ -9537,12 +9545,12 @@ function ia(e, t) {
|
|
|
9537
9545
|
ra.get("/*", async (e) => {
|
|
9538
9546
|
let t = e.req.path.replace(/^\/media\//, "").replace(/^\//, "");
|
|
9539
9547
|
if (!t) return e.text("Asset key missing", 400);
|
|
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");
|
|
9548
|
+
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"), l = new URL(e.req.url), u = e.env?.CDN_DOMAIN || l.hostname;
|
|
9541
9549
|
if (n) {
|
|
9542
|
-
if (s &&
|
|
9543
|
-
let n = r ? parseInt(r, 10) : void 0, s = i ? parseInt(i, 10) : void 0, c = a ? parseInt(a, 10) : 85, l = o || "auto",
|
|
9550
|
+
if (s && u && !c) {
|
|
9551
|
+
let n = r ? parseInt(r, 10) : void 0, s = i ? parseInt(i, 10) : void 0, c = a ? parseInt(a, 10) : 85, l = o || "auto", d = `https://${u}/media/${t}`;
|
|
9544
9552
|
try {
|
|
9545
|
-
let t = await fetch(
|
|
9553
|
+
let t = await fetch(d, {
|
|
9546
9554
|
headers: { Accept: e.req.header("Accept") || "image/webp,image/avif,image/*,*/*;q=0.8" },
|
|
9547
9555
|
cf: { image: {
|
|
9548
9556
|
width: n,
|
|
@@ -9555,8 +9563,8 @@ ra.get("/*", async (e) => {
|
|
|
9555
9563
|
});
|
|
9556
9564
|
if (t.ok) return t;
|
|
9557
9565
|
console.warn(`[Cloudflare Image] Resizing returned status ${t.status}. Falling back to raw R2 stream.`);
|
|
9558
|
-
} catch {
|
|
9559
|
-
console.warn("[Cloudflare Image] Resize fetch failed. Falling back to raw R2 stream.");
|
|
9566
|
+
} catch (e) {
|
|
9567
|
+
console.warn("[Cloudflare Image] Resize fetch failed. Falling back to raw R2 stream.", e);
|
|
9560
9568
|
}
|
|
9561
9569
|
}
|
|
9562
9570
|
let l = await n.get(t);
|
|
@@ -9569,26 +9577,26 @@ ra.get("/*", async (e) => {
|
|
|
9569
9577
|
return l.writeHttpMetadata(t), t.set("etag", l.httpEtag), t.set("Cache-Control", "public, max-age=31536000, immutable"), e.body(l.body, 200, Object.fromEntries(t.entries()));
|
|
9570
9578
|
}
|
|
9571
9579
|
}
|
|
9572
|
-
let [{ existsSync:
|
|
9580
|
+
let [{ existsSync: d, readFileSync: f, mkdirSync: p, writeFileSync: m }, { join: h, dirname: g }] = await Promise.all([import(
|
|
9573
9581
|
/* @vite-ignore */
|
|
9574
9582
|
"node:fs"
|
|
9575
9583
|
), import(
|
|
9576
9584
|
/* @vite-ignore */
|
|
9577
9585
|
"node:path"
|
|
9578
|
-
)]),
|
|
9579
|
-
if (
|
|
9586
|
+
)]), _ = e.env?.LOCAL_MEDIA_PATH || "./public/media", v = h(process.cwd(), _, t);
|
|
9587
|
+
if (d(v)) try {
|
|
9580
9588
|
if (!s) {
|
|
9581
|
-
let n =
|
|
9589
|
+
let n = f(v);
|
|
9582
9590
|
return e.body(n, 200, {
|
|
9583
9591
|
"Content-Type": ia(t),
|
|
9584
9592
|
"Cache-Control": "public, max-age=86400"
|
|
9585
9593
|
});
|
|
9586
9594
|
}
|
|
9587
|
-
let n = r ? parseInt(r, 10) : "auto", c = i ? parseInt(i, 10) : "auto",
|
|
9588
|
-
if (
|
|
9589
|
-
let n =
|
|
9595
|
+
let n = r ? parseInt(r, 10) : "auto", c = i ? parseInt(i, 10) : "auto", l = a ? parseInt(a, 10) : 80, u = o || "webp", y = `w${n}_h${c}_q${l}_f${u}_${t.replace(/[/\\?%*:|"<>]/g, "_")}`, b = h(process.cwd(), _, ".cache", y);
|
|
9596
|
+
if (d(b)) {
|
|
9597
|
+
let n = f(b);
|
|
9590
9598
|
return e.body(n, 200, {
|
|
9591
|
-
"Content-Type": ia(t,
|
|
9599
|
+
"Content-Type": ia(t, u),
|
|
9592
9600
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9593
9601
|
"X-Local-Cache": "HIT"
|
|
9594
9602
|
});
|
|
@@ -9597,16 +9605,16 @@ ra.get("/*", async (e) => {
|
|
|
9597
9605
|
let r = (await import(
|
|
9598
9606
|
/* @vite-ignore */
|
|
9599
9607
|
"sharp"
|
|
9600
|
-
)).default, i = r(
|
|
9601
|
-
typeof n == "number" && (a.width = n), typeof c == "number" && (a.height = c), (a.width || a.height) && (a.fit = "cover", i = i.resize(a)),
|
|
9608
|
+
)).default, i = r(v), a = {};
|
|
9609
|
+
typeof n == "number" && (a.width = n), typeof c == "number" && (a.height = c), (a.width || a.height) && (a.fit = "cover", i = i.resize(a)), u === "webp" ? i = i.webp({ quality: typeof l == "number" ? l : 80 }) : u === "avif" ? i = i.avif({ quality: typeof l == "number" ? l : 70 }) : u === "jpeg" || u === "jpg" ? i = i.jpeg({ quality: typeof l == "number" ? l : 80 }) : u === "png" && (i = i.png({ quality: typeof l == "number" ? l : 80 }));
|
|
9602
9610
|
let o = await i.toBuffer();
|
|
9603
|
-
return
|
|
9604
|
-
"Content-Type": ia(t,
|
|
9611
|
+
return p(g(b), { recursive: !0 }), m(b, o), e.body(o, 200, {
|
|
9612
|
+
"Content-Type": ia(t, u),
|
|
9605
9613
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
9606
9614
|
"X-Local-Cache": "MISS"
|
|
9607
9615
|
});
|
|
9608
9616
|
} catch {
|
|
9609
|
-
let n =
|
|
9617
|
+
let n = f(v);
|
|
9610
9618
|
return e.body(n, 200, {
|
|
9611
9619
|
"Content-Type": ia(t),
|
|
9612
9620
|
"Cache-Control": "public, max-age=86400"
|