@blogmcp/sdk 0.3.1 → 0.3.2

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.
@@ -0,0 +1,70 @@
1
+ import { lineNodes as m } from "./nodes.js";
2
+ function u(a) {
3
+ return m(a);
4
+ }
5
+ function c(a, e) {
6
+ const t = a.slice(1, -1);
7
+ if (e <= 0 || t.length === 0) return [];
8
+ if (t.length <= e) return t;
9
+ const r = [];
10
+ for (let o = 0; o < e; o++) {
11
+ const n = Math.round((o + 1) * (t.length - 1) / (e + 1)), i = t[Math.min(n, t.length - 1)];
12
+ r[r.length - 1] !== i && r.push(i);
13
+ }
14
+ return r;
15
+ }
16
+ const p = (a) => a.toFixed(5).replace(/\.?0+$/, "");
17
+ function $(a, e = {}) {
18
+ const t = u(a);
19
+ if (t.length < 2) return null;
20
+ const r = (i) => `${p(i.lng)},${p(i.lat)}`, o = [
21
+ `mapset=${e.mapset ?? "outdoor"}`,
22
+ `start=${r(t[0])}`,
23
+ `end=${r(t[t.length - 1])}`,
24
+ `routeType=${e.routeType ?? "foot_hiking"}`
25
+ ], n = c(t, Math.min(e.maxWaypoints ?? 15, 15));
26
+ return n.length > 0 && o.push(`waypoints=${n.map(r).join(";")}`), e.navigate && o.push("navigate=true"), `https://mapy.com/fnc/v1/route?${o.join("&")}`;
27
+ }
28
+ function h(a, e = {}) {
29
+ const t = u(a);
30
+ if (t.length < 2) return null;
31
+ const r = (i) => `${p(i.lat)},${p(i.lng)}`, o = [
32
+ "api=1",
33
+ `origin=${r(t[0])}`,
34
+ `destination=${r(t[t.length - 1])}`,
35
+ `travelmode=${e.travelmode ?? "walking"}`
36
+ ], n = c(t, Math.min(e.maxWaypoints ?? 9, 9));
37
+ return n.length > 0 && o.push(`waypoints=${n.map(r).join("%7C")}`), `https://www.google.com/maps/dir/?${o.join("&")}`;
38
+ }
39
+ const s = (a) => a.replace(/[<>&'"]/g, (e) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", "'": "&apos;", '"': "&quot;" })[e]), l = (a) => s(a);
40
+ function d(a, e = {}) {
41
+ const t = u(a);
42
+ if (t.length < 2) return null;
43
+ const r = s(e.name || "Trip"), o = [
44
+ '<?xml version="1.0" encoding="UTF-8"?>',
45
+ `<gpx version="1.1" creator="${s(e.creator || "blogmcp TripMap")}" xmlns="http://www.topografix.com/GPX/1/1">`,
46
+ ` <metadata><name>${r}</name>${t[0].capturedAt ? `<time>${l(t[0].capturedAt)}</time>` : ""}</metadata>`
47
+ ];
48
+ for (const n of a)
49
+ n.title && o.push(
50
+ ` <wpt lat="${p(n.lat)}" lon="${p(n.lng)}">` + (n.capturedAt ? `<time>${l(n.capturedAt)}</time>` : "") + `<name>${s(n.title)}</name>` + (n.description ? `<desc>${s(n.description)}</desc>` : "") + "</wpt>"
51
+ );
52
+ o.push(` <trk><name>${r}</name><trkseg>`);
53
+ for (const n of t)
54
+ o.push(
55
+ ` <trkpt lat="${p(n.lat)}" lon="${p(n.lng)}">` + (n.capturedAt ? `<time>${l(n.capturedAt)}</time>` : "") + "</trkpt>"
56
+ );
57
+ return o.push(" </trkseg></trk>", "</gpx>", ""), o.join(`
58
+ `);
59
+ }
60
+ function f(a, e = "trasa") {
61
+ return `${(a ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || e}.gpx`;
62
+ }
63
+ export {
64
+ d as buildGpx,
65
+ h as googleMapsRouteUrl,
66
+ f as gpxFileName,
67
+ $ as mapyRouteUrl,
68
+ u as routePoints,
69
+ c as sampleWaypoints
70
+ };
@@ -9,7 +9,7 @@ class l {
9
9
  this.root.textContent = "", this.items.clear();
10
10
  for (const i of s) {
11
11
  const e = document.createElement("button");
12
- if (e.type = "button", e.className = "tripmap-filmstrip__item", e.dataset.tripmapNode = i.id, e.setAttribute("role", "option"), e.setAttribute("aria-label", i.title || i.altText || i.id), i.thumbnailUrl) {
12
+ if (e.type = "button", e.className = "tripmap-filmstrip__item", e.dataset.tripmapNode = i.id, e.setAttribute("role", "option"), e.setAttribute("aria-selected", "false"), e.setAttribute("aria-label", i.title || i.altText || i.id), i.thumbnailUrl) {
13
13
  const t = document.createElement("img");
14
14
  t.src = i.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-filmstrip__img", e.appendChild(t);
15
15
  } else {
@@ -1,32 +1,48 @@
1
- import { buildTripNodes as p, formatTimeHHMM as g, lineNodes as u, normalizeHandNode as c, tripSummary as m } from "./nodes.js";
2
- import { approxDistanceKm as v, computeFramingBounds as N } from "./framing.js";
3
- import { OSM_ATTRIBUTION as A, buildAttributions as b } from "./attribution.js";
4
- const o = "0.1.0", s = {
1
+ import { buildTripNodes as d, formatTimeHHMM as g, lineNodes as u, normalizeHandNode as c, tripSummary as m } from "./nodes.js";
2
+ import { approxDistanceKm as b, computeFramingBounds as y } from "./framing.js";
3
+ import { OSM_ATTRIBUTION as N, buildAttributions as w } from "./attribution.js";
4
+ const r = "0.1.0", n = {
5
5
  light: "https://tiles.openfreemap.org/styles/liberty",
6
6
  dark: "https://tiles.openfreemap.org/styles/dark"
7
- }, r = () => import("./engine.js");
8
- function l(e) {
7
+ }, l = () => import("./engine.js");
8
+ function o(e) {
9
9
  return {
10
- styleUrl: e.styleUrl || s.light,
11
- darkStyleUrl: e.darkStyleUrl || e.styleUrl || s.dark,
10
+ styleUrl: e.styleUrl || n.light,
11
+ darkStyleUrl: e.darkStyleUrl || e.styleUrl || n.dark,
12
12
  theme: e.theme ?? "auto",
13
13
  cluster: e.cluster ?? !0,
14
14
  clusterRadius: e.clusterRadius ?? 40,
15
15
  showLine: e.showLine ?? !0,
16
16
  showFilmstrip: e.showFilmstrip ?? !0,
17
17
  showPlayback: e.showPlayback ?? !0,
18
+ showFullscreen: e.showFullscreen ?? !0,
19
+ showExport: e.showExport ?? !0,
20
+ title: e.title,
21
+ detail: e.detail ?? "popup",
22
+ detailHost: e.detailHost,
18
23
  initialView: e.initialView,
19
24
  extraAttribution: e.extraAttribution,
20
25
  labels: {
21
26
  play: e.labels?.play ?? "Play route",
22
- stop: e.labels?.stop ?? "Stop"
27
+ stop: e.labels?.stop ?? "Stop",
28
+ fullscreen: e.labels?.fullscreen ?? "Fullscreen",
29
+ exitFullscreen: e.labels?.exitFullscreen ?? "Exit fullscreen",
30
+ export: e.labels?.export ?? "Export route",
31
+ exportGpx: e.labels?.exportGpx ?? "Download GPX",
32
+ exportGpxHint: e.labels?.exportGpxHint ?? "watches, Garmin, Strava, Komoot",
33
+ openInMapy: e.labels?.openInMapy ?? "Open in Mapy.com",
34
+ openInGoogleMaps: e.labels?.openInGoogleMaps ?? "Open in Google Maps",
35
+ lightboxClose: e.labels?.lightboxClose ?? "Close",
36
+ lightboxPrev: e.labels?.lightboxPrev ?? "Previous photo",
37
+ lightboxNext: e.labels?.lightboxNext ?? "Next photo",
38
+ zoomImage: e.labels?.zoomImage ?? "View full screen"
23
39
  },
24
40
  events: e.events ?? {}
25
41
  };
26
42
  }
27
- class h {
28
- constructor(i, t) {
29
- this.container = i, this.resolved = l(t), this.loader = t.engineLoader ?? r;
43
+ class a {
44
+ constructor(t, i) {
45
+ this.container = t, this.resolved = o(i), this.loader = i.engineLoader ?? l;
30
46
  }
31
47
  resolved;
32
48
  engine = null;
@@ -44,28 +60,28 @@ class h {
44
60
  */
45
61
  init() {
46
62
  return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
47
- let i;
63
+ let t;
48
64
  try {
49
- i = await this.loader();
50
- } catch (t) {
51
- const n = t instanceof Error ? t : new Error("tripmap: engine load failed");
52
- throw this.resolved.events.onError?.(n), n;
65
+ t = await this.loader();
66
+ } catch (i) {
67
+ const s = i instanceof Error ? i : new Error("tripmap: engine load failed");
68
+ throw this.resolved.events.onError?.(s), s;
53
69
  }
54
- this.destroyed || (this.engine = i.createEngine(this.container, this.resolved), this.pendingNodes && this.engine.setNodes(this.pendingNodes), this.pendingTheme && this.engine.setTheme(this.pendingTheme), this.pendingActive && this.engine.setActiveNode(this.pendingActive.id, this.pendingActive), this.pendingNodes = null, this.pendingTheme = null, this.pendingActive = null);
70
+ this.destroyed || (this.engine = t.createEngine(this.container, this.resolved), this.pendingNodes && this.engine.setNodes(this.pendingNodes), this.pendingTheme && this.engine.setTheme(this.pendingTheme), this.pendingActive && this.engine.setActiveNode(this.pendingActive.id, this.pendingActive), this.pendingNodes = null, this.pendingTheme = null, this.pendingActive = null);
55
71
  })(), this.initPromise);
56
72
  }
57
- setNodes(i) {
58
- this.engine ? this.engine.setNodes(i) : this.pendingNodes = i;
73
+ setNodes(t) {
74
+ this.engine ? this.engine.setNodes(t) : this.pendingNodes = t;
59
75
  }
60
- setActiveNode(i, t) {
61
- this.engine ? this.engine.setActiveNode(i, t) : this.pendingActive = { id: i, ...t };
76
+ setActiveNode(t, i) {
77
+ this.engine ? this.engine.setActiveNode(t, i) : this.pendingActive = { id: t, ...i };
62
78
  }
63
- playSequence(i) {
64
- return this.engine ? this.engine.playSequence(i) : { stop() {
79
+ playSequence(t) {
80
+ return this.engine ? this.engine.playSequence(t) : { stop() {
65
81
  } };
66
82
  }
67
- setTheme(i) {
68
- this.engine ? this.engine.setTheme(i) : this.pendingTheme = i;
83
+ setTheme(t) {
84
+ this.engine ? this.engine.setTheme(t) : this.pendingTheme = t;
69
85
  }
70
86
  resize() {
71
87
  this.engine?.resize();
@@ -75,14 +91,14 @@ class h {
75
91
  }
76
92
  }
77
93
  export {
78
- s as DEFAULT_STYLE_URLS,
79
- A as OSM_ATTRIBUTION,
80
- h as TripMap,
81
- o as VERSION,
82
- v as approxDistanceKm,
83
- b as buildAttributions,
84
- p as buildTripNodes,
85
- N as computeFramingBounds,
94
+ n as DEFAULT_STYLE_URLS,
95
+ N as OSM_ATTRIBUTION,
96
+ a as TripMap,
97
+ r as VERSION,
98
+ b as approxDistanceKm,
99
+ w as buildAttributions,
100
+ d as buildTripNodes,
101
+ y as computeFramingBounds,
86
102
  g as formatTimeHHMM,
87
103
  u as lineNodes,
88
104
  c as normalizeHandNode,
@@ -0,0 +1,94 @@
1
+ function c(h) {
2
+ return h.largeImageUrl || h.imageUrl || h.thumbnailUrl;
3
+ }
4
+ class p {
5
+ constructor(t, e, n) {
6
+ this.host = t, this.labels = e, this.callbacks = n;
7
+ }
8
+ root = null;
9
+ img = null;
10
+ caption = null;
11
+ prevBtn = null;
12
+ nextBtn = null;
13
+ nodes = [];
14
+ index = 0;
15
+ restoreFocus = null;
16
+ bodyOverflow = "";
17
+ get isOpen() {
18
+ return this.root !== null;
19
+ }
20
+ get current() {
21
+ return this.root ? this.nodes[this.index] ?? null : null;
22
+ }
23
+ /** Open on `id`; `nodes` is filtered to the ones with an image. */
24
+ open(t, e) {
25
+ this.nodes = t.filter((s) => !!c(s));
26
+ const n = this.nodes.findIndex((s) => s.id === e);
27
+ n < 0 || (this.index = n, this.root || this.mount(), this.render());
28
+ }
29
+ next() {
30
+ !this.root || this.nodes.length < 2 || (this.index = (this.index + 1) % this.nodes.length, this.render());
31
+ }
32
+ prev() {
33
+ !this.root || this.nodes.length < 2 || (this.index = (this.index - 1 + this.nodes.length) % this.nodes.length, this.render());
34
+ }
35
+ close() {
36
+ if (!this.root) return;
37
+ const t = this.host.ownerDocument;
38
+ t.removeEventListener("keydown", this.onKeyDown), this.root.remove(), this.root = null, this.img = null, this.caption = null, t.body.style.overflow = this.bodyOverflow;
39
+ const e = this.restoreFocus;
40
+ this.restoreFocus = null, e && typeof e.focus == "function" && e.focus(), this.callbacks.onClose?.();
41
+ }
42
+ destroy() {
43
+ this.close();
44
+ }
45
+ onKeyDown = (t) => {
46
+ t.key === "Escape" ? (t.preventDefault(), this.close()) : t.key === "ArrowRight" ? (t.preventDefault(), this.next()) : t.key === "ArrowLeft" && (t.preventDefault(), this.prev());
47
+ };
48
+ mount() {
49
+ const t = this.host.ownerDocument, e = t.createElement("div");
50
+ e.className = "tripmap-lightbox", e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e.addEventListener("click", (d) => {
51
+ d.target === e && this.close();
52
+ });
53
+ const n = t.createElement("button");
54
+ n.type = "button", n.className = "tripmap-lightbox__close", n.setAttribute("aria-label", this.labels.close), n.textContent = "×", n.addEventListener("click", () => this.close());
55
+ const s = t.createElement("button");
56
+ s.type = "button", s.className = "tripmap-lightbox__nav tripmap-lightbox__nav--prev", s.setAttribute("aria-label", this.labels.prev), s.textContent = "‹", s.addEventListener("click", () => this.prev());
57
+ const o = t.createElement("button");
58
+ o.type = "button", o.className = "tripmap-lightbox__nav tripmap-lightbox__nav--next", o.setAttribute("aria-label", this.labels.next), o.textContent = "›", o.addEventListener("click", () => this.next());
59
+ const l = t.createElement("figure");
60
+ l.className = "tripmap-lightbox__figure";
61
+ const i = t.createElement("img");
62
+ i.className = "tripmap-lightbox__img", i.decoding = "async", i.draggable = !1;
63
+ const r = t.createElement("figcaption");
64
+ r.className = "tripmap-lightbox__caption", l.appendChild(i), l.appendChild(r), e.appendChild(n), e.appendChild(s), e.appendChild(l), e.appendChild(o);
65
+ const a = t.fullscreenElement;
66
+ (a && (a === this.host || a.contains(this.host)) ? a : t.body).appendChild(e), this.restoreFocus = t.activeElement instanceof HTMLElement ? t.activeElement : null, this.bodyOverflow = t.body.style.overflow, t.body.style.overflow = "hidden", t.addEventListener("keydown", this.onKeyDown), this.root = e, this.img = i, this.caption = r, this.prevBtn = s, this.nextBtn = o, n.focus();
67
+ }
68
+ render() {
69
+ const t = this.nodes[this.index];
70
+ if (!t || !this.img || !this.caption || !this.root) return;
71
+ const e = c(t);
72
+ this.img.src = e, this.img.alt = t.altText || t.title || "", this.caption.textContent = "";
73
+ const n = [];
74
+ t.title && n.push(t.title), t.capturedAt && n.push(this.callbacks.formatTime(t.capturedAt));
75
+ const s = this.host.ownerDocument.createElement("span");
76
+ s.className = "tripmap-lightbox__caption-head", s.textContent = n.join(" · "), n.length && this.caption.appendChild(s);
77
+ const o = t.description || t.altText;
78
+ if (o) {
79
+ const i = this.host.ownerDocument.createElement("span");
80
+ i.className = "tripmap-lightbox__caption-text", i.textContent = o, this.caption.appendChild(i);
81
+ }
82
+ const l = this.nodes.length > 1;
83
+ if (this.prevBtn && (this.prevBtn.hidden = !l), this.nextBtn && (this.nextBtn.hidden = !l), this.root.dataset.tripmapNode = t.id, l && this.callbacks.preload)
84
+ for (const i of [1, -1]) {
85
+ const r = this.nodes[(this.index + i + this.nodes.length) % this.nodes.length], a = c(r);
86
+ a && this.callbacks.preload(a);
87
+ }
88
+ this.callbacks.onChange?.(t);
89
+ }
90
+ }
91
+ export {
92
+ p as Lightbox,
93
+ c as lightboxImageUrl
94
+ };
@@ -1,90 +1,95 @@
1
- class c {
2
- constructor(r) {
3
- this.adapter = r;
1
+ class p {
2
+ constructor(i) {
3
+ this.adapter = i;
4
4
  }
5
5
  entries = /* @__PURE__ */ new Map();
6
6
  /** Diff the desired set against the mounted set by key. */
7
- sync(r) {
8
- const a = /* @__PURE__ */ new Set();
9
- for (const t of r) {
10
- a.add(t.key);
11
- const e = this.entries.get(t.key);
12
- if (e) {
13
- (e.lngLat[0] !== t.lngLat[0] || e.lngLat[1] !== t.lngLat[1]) && (this.adapter.move(e.handle, t.lngLat), e.lngLat = t.lngLat);
7
+ sync(i) {
8
+ const n = /* @__PURE__ */ new Set();
9
+ for (const t of i) {
10
+ n.add(t.key);
11
+ const r = this.entries.get(t.key);
12
+ if (r) {
13
+ (r.lngLat[0] !== t.lngLat[0] || r.lngLat[1] !== t.lngLat[1]) && (this.adapter.move(r.handle, t.lngLat), r.lngLat = t.lngLat);
14
14
  continue;
15
15
  }
16
- const s = t.createEl(), i = this.adapter.mount(s, t.lngLat);
17
- this.entries.set(t.key, { el: s, handle: i, lngLat: t.lngLat });
16
+ const a = t.createEl(), s = this.adapter.mount(a, t.lngLat);
17
+ this.entries.set(t.key, { el: a, handle: s, lngLat: t.lngLat });
18
18
  }
19
- for (const [t, e] of this.entries)
20
- a.has(t) || (this.adapter.unmount(e.handle), this.entries.delete(t));
19
+ for (const [t, r] of this.entries)
20
+ n.has(t) || (this.adapter.unmount(r.handle), this.entries.delete(t));
21
21
  }
22
- get(r) {
23
- return this.entries.get(r)?.el;
22
+ get(i) {
23
+ return this.entries.get(i)?.el;
24
24
  }
25
25
  keys() {
26
26
  return [...this.entries.keys()];
27
27
  }
28
28
  clear() {
29
- for (const r of this.entries.values()) this.adapter.unmount(r.handle);
29
+ for (const i of this.entries.values()) this.adapter.unmount(i.handle);
30
30
  this.entries.clear();
31
31
  }
32
32
  }
33
- const l = "tripmap-marker--active";
34
- function p(n, r) {
35
- const a = document.createElement("button");
36
- if (a.type = "button", a.className = "tripmap-marker", a.dataset.tripmapNode = n.id, a.setAttribute("aria-label", n.title || n.altText || n.id), n.thumbnailUrl) {
33
+ const o = "tripmap-marker--active";
34
+ function c(e, i) {
35
+ const n = document.createElement("button");
36
+ if (n.type = "button", n.className = "tripmap-marker", n.dataset.tripmapNode = e.id, n.setAttribute("aria-label", e.title || e.altText || e.id), e.thumbnailUrl) {
37
37
  const t = document.createElement("img");
38
- t.src = n.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-marker__img", a.appendChild(t);
38
+ t.src = e.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-marker__img", n.appendChild(t);
39
39
  } else {
40
- a.classList.add("tripmap-marker--dot");
40
+ n.classList.add("tripmap-marker--dot");
41
41
  const t = document.createElement("span");
42
- t.className = "tripmap-marker__dot", a.appendChild(t);
42
+ t.className = "tripmap-marker__dot", n.appendChild(t);
43
43
  }
44
- return a.addEventListener("click", (t) => {
45
- t.stopPropagation(), r(n);
46
- }), a;
44
+ return n.addEventListener("click", (t) => {
45
+ t.stopPropagation(), i(e);
46
+ }), n;
47
47
  }
48
- function o(n, r, a) {
48
+ function m(e, i, n) {
49
49
  const t = document.createElement("button");
50
- t.type = "button", t.className = "tripmap-marker tripmap-marker--cluster", t.setAttribute("aria-label", `${n}`);
51
- const e = document.createElement("span");
52
- return e.className = "tripmap-marker__count", e.textContent = String(n), t.appendChild(e), t.addEventListener("click", (s) => {
53
- s.stopPropagation(), a();
50
+ t.type = "button", t.className = "tripmap-marker tripmap-marker--cluster", t.setAttribute("aria-label", `${e}`);
51
+ const r = document.createElement("span");
52
+ return r.className = "tripmap-marker__count", r.textContent = String(e), t.appendChild(r), t.addEventListener("click", (a) => {
53
+ a.stopPropagation(), n();
54
54
  }), t;
55
55
  }
56
- function m(n, r) {
57
- n?.classList.toggle(l, r);
56
+ function d(e, i) {
57
+ e?.classList.toggle(o, i);
58
58
  }
59
- function d(n, r) {
60
- const a = document.createElement("div");
61
- if (a.className = "tripmap-popup", n.imageUrl || n.thumbnailUrl) {
62
- const e = document.createElement("img");
63
- if (e.src = n.imageUrl || n.thumbnailUrl, e.alt = n.altText || "", e.className = "tripmap-popup__img", e.loading = "lazy", e.decoding = "async", n.href) {
59
+ function u(e, i, n = {}) {
60
+ const t = document.createElement("div");
61
+ if (t.className = "tripmap-popup", e.imageUrl || e.thumbnailUrl) {
62
+ const a = n.image ?? document.createElement("img");
63
+ if (n.image || (a.src = e.imageUrl || e.thumbnailUrl, a.loading = "eager", a.decoding = "async"), a.alt = e.altText || "", a.className = "tripmap-popup__img", e.href) {
64
64
  const s = document.createElement("a");
65
- s.href = n.href, s.appendChild(e), a.appendChild(s);
65
+ s.href = e.href, s.appendChild(a), t.appendChild(s);
66
+ } else if (n.onImageClick) {
67
+ const s = document.createElement("button");
68
+ s.type = "button", s.className = "tripmap-popup__zoom", n.zoomLabel && s.setAttribute("aria-label", n.zoomLabel), s.appendChild(a), s.addEventListener("click", (l) => {
69
+ l.stopPropagation(), n.onImageClick?.(e);
70
+ }), t.appendChild(s);
66
71
  } else
67
- a.appendChild(e);
72
+ t.appendChild(a);
68
73
  }
69
- const t = document.createElement("div");
70
- if (t.className = "tripmap-popup__meta", n.title) {
71
- const e = document.createElement("strong");
72
- e.className = "tripmap-popup__title", e.textContent = n.title, t.appendChild(e);
74
+ const r = document.createElement("div");
75
+ if (r.className = "tripmap-popup__meta", e.title) {
76
+ const a = document.createElement("strong");
77
+ a.className = "tripmap-popup__title", a.textContent = e.title, r.appendChild(a);
73
78
  }
74
- if (n.capturedAt) {
75
- const e = document.createElement("span");
76
- e.className = "tripmap-popup__time", e.textContent = r(n.capturedAt), t.appendChild(e);
79
+ if (e.capturedAt) {
80
+ const a = document.createElement("span");
81
+ a.className = "tripmap-popup__time", a.textContent = i(e.capturedAt), r.appendChild(a);
77
82
  }
78
- if (n.description || n.altText) {
79
- const e = document.createElement("p");
80
- e.className = "tripmap-popup__desc", e.textContent = n.description || n.altText || "", t.appendChild(e);
83
+ if (e.description || e.altText) {
84
+ const a = document.createElement("p");
85
+ a.className = "tripmap-popup__desc", a.textContent = e.description || e.altText || "", r.appendChild(a);
81
86
  }
82
- return t.childNodes.length > 0 && a.appendChild(t), a;
87
+ return r.childNodes.length > 0 && t.appendChild(r), t;
83
88
  }
84
89
  export {
85
- c as MarkerPool,
86
- o as createClusterMarkerEl,
87
- p as createNodeMarkerEl,
88
- d as createPopupContent,
89
- m as setMarkerActive
90
+ p as MarkerPool,
91
+ m as createClusterMarkerEl,
92
+ c as createNodeMarkerEl,
93
+ u as createPopupContent,
94
+ d as setMarkerActive
90
95
  };
@@ -1,25 +1,29 @@
1
- import { lineNodes as p } from "./nodes.js";
1
+ import { lineNodes as d } from "./nodes.js";
2
2
  const m = 2e3;
3
- function d(a, o, c = {}) {
4
- const n = p(a), i = c.dwellMs ?? m;
5
- let t = !1, s;
6
- const e = {
3
+ function h(c, o, i = {}) {
4
+ const e = d(c), p = i.dwellMs ?? m;
5
+ let t = !1, r;
6
+ const n = {
7
7
  stop() {
8
- t || (t = !0, s && clearTimeout(s), f(), o.onDone?.());
8
+ t || (t = !0, r && clearTimeout(r), f(), o.onDone?.());
9
9
  }
10
- }, f = o.onUserInterrupt?.(() => e.stop()) ?? (() => {
10
+ }, f = o.onUserInterrupt?.(() => n.stop()) ?? (() => {
11
11
  });
12
- async function l() {
13
- for (const r of n) {
14
- if (t || (await o.flyTo(r), t)) return;
15
- o.showNode(r), await new Promise((u) => {
16
- s = setTimeout(u, i);
12
+ async function u() {
13
+ o.preload?.(e[0]);
14
+ for (let s = 0; s < e.length; s++) {
15
+ const a = e[s];
16
+ if (t || (await o.flyTo(a), t)) return;
17
+ o.showNode(a);
18
+ const l = e[s + 1];
19
+ l && o.preload?.(l), await new Promise((w) => {
20
+ r = setTimeout(w, p);
17
21
  });
18
22
  }
19
- e.stop();
23
+ n.stop();
20
24
  }
21
- return n.length === 0 ? e.stop() : l(), e;
25
+ return e.length === 0 ? n.stop() : u(), n;
22
26
  }
23
27
  export {
24
- d as startPlayback
28
+ h as startPlayback
25
29
  };
@@ -0,0 +1,44 @@
1
+ class c {
2
+ constructor(e, t = 4) {
3
+ this.doc = e, this.limit = t;
4
+ }
5
+ entries = /* @__PURE__ */ new Map();
6
+ /** Start (or reuse) a load; resolves once decoded, or on error (never rejects). */
7
+ preload(e) {
8
+ const t = this.entries.get(e);
9
+ if (t)
10
+ return this.entries.delete(e), this.entries.set(e, t), t.ready;
11
+ const s = this.doc.createElement("img");
12
+ s.decoding = "async";
13
+ const r = new Promise((i) => {
14
+ s.addEventListener(
15
+ "load",
16
+ () => {
17
+ const n = typeof s.decode == "function" ? s.decode() : void 0;
18
+ n ? n.then(i, i) : i();
19
+ },
20
+ { once: !0 }
21
+ ), s.addEventListener("error", () => i(), { once: !0 });
22
+ });
23
+ for (s.src = e, this.entries.set(e, { img: s, ready: r }); this.entries.size > this.limit; ) {
24
+ const i = this.entries.keys().next().value;
25
+ if (i === void 0) break;
26
+ this.entries.delete(i);
27
+ }
28
+ return r;
29
+ }
30
+ /** Hand out the preloaded element (it leaves the cache — it is about to be mounted). */
31
+ take(e) {
32
+ const t = this.entries.get(e);
33
+ return t ? (this.entries.delete(e), t.img) : null;
34
+ }
35
+ has(e) {
36
+ return this.entries.has(e);
37
+ }
38
+ clear() {
39
+ this.entries.clear();
40
+ }
41
+ }
42
+ export {
43
+ c as ImagePreloader
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogmcp/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -61,7 +61,7 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
- "@blogmcp/mdx-schema": "^0.4.0",
64
+ "@blogmcp/mdx-schema": "^0.5.0",
65
65
  "@blogmcp/sanitize": "^0.3.0",
66
66
  "marked": "^15.0.7"
67
67
  },