@brightsideoy/kama 0.1.0-alpha.64 → 0.1.0-alpha.65

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-BwhzZuhD.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-CZFirq-c.css">
7
+ <script type="module" crossorigin src="/assets/index-CfSQLCq2.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 = /* @__PURE__ */ new Date();
8901
+ let n = Date.now();
8902
8902
  if (e && String(e).trim() !== "") {
8903
- let t = new Date(e);
8904
- if (!isNaN(t.getTime()) && n < t) return !1;
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 = new Date(t);
8908
- if (!isNaN(e.getTime()) && n > e) return !1;
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 = /* @__PURE__ */ new Set();
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(`
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 (${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(`
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 (${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);
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(f, (e, t) => {
9091
- let n = t.match(/data-node-id=["']([^"']+)["']/i), r = t.match(/data-asset-id=["']([^"']+)["']/i), i = t.match(/href=["']([^"']+)["']/i);
9092
- if (i?.[1].startsWith("mailto:")) return `<a${t.replace(/\s+target=["'][^"']*["']/i, "")}>`;
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);
9097
- return n && i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${n}"`).replace(/data-asset-id=["'][^"']*["']/i, `data-asset-id="${c}"`)}>` : e;
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 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}`);
9100
- return i ? `<a${t.replace(/href=["'][^"']*["']/i, `href="${g || "/"}"`)}>` : e;
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
- return console.error("[CMS Public API] Error fetching node by path:", t), e.json({
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightsideoy/kama",
3
- "version": "0.1.0-alpha.64",
3
+ "version": "0.1.0-alpha.65",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",