@blogmcp/sdk 0.3.1 → 0.6.0

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/dist/core/client-types.d.ts +7 -1
  3. package/dist/core/client.d.ts +25 -1
  4. package/dist/core/client.js +38 -34
  5. package/dist/core/consultation-adapter.d.ts +90 -0
  6. package/dist/core/consultation-adapter.js +200 -0
  7. package/dist/core/consultations.d.ts +108 -0
  8. package/dist/core/consultations.js +95 -0
  9. package/dist/core/errors.d.ts +52 -0
  10. package/dist/core/errors.js +73 -0
  11. package/dist/core/index.d.ts +7 -1
  12. package/dist/core/index.js +80 -64
  13. package/dist/core/queries.d.ts +16 -1
  14. package/dist/core/queries.js +198 -61
  15. package/dist/core/review/format.d.ts +30 -0
  16. package/dist/core/review/format.js +78 -0
  17. package/dist/core/review/index.d.ts +6 -0
  18. package/dist/core/review/index.js +9 -0
  19. package/dist/core/review/types.d.ts +176 -0
  20. package/dist/core/review/types.js +9 -0
  21. package/dist/core/server-only.d.ts +12 -0
  22. package/dist/core/server-only.js +11 -0
  23. package/dist/core/types.d.ts +295 -0
  24. package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +21 -25
  25. package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +1 -0
  26. package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +105 -94
  27. package/dist/packages/mdx-schema/dist/metadata/index.js +12 -3
  28. package/dist/packages/mdx-schema/dist/styles/index.js +9 -1
  29. package/dist/packages/mdx-schema/dist/tripmap.js +81 -35
  30. package/dist/packages/tripmap-core/dist/attribution.js +121 -6
  31. package/dist/packages/tripmap-core/dist/css.js +149 -20
  32. package/dist/packages/tripmap-core/dist/detail.js +51 -0
  33. package/dist/packages/tripmap-core/dist/engine.js +367 -174
  34. package/dist/packages/tripmap-core/dist/export.js +72 -0
  35. package/dist/packages/tripmap-core/dist/filmstrip.js +30 -17
  36. package/dist/packages/tripmap-core/dist/framing.js +30 -30
  37. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
  38. package/dist/packages/tripmap-core/dist/heading.js +8 -0
  39. package/dist/packages/tripmap-core/dist/href.js +18 -0
  40. package/dist/packages/tripmap-core/dist/index.js +60 -36
  41. package/dist/packages/tripmap-core/dist/lightbox.js +96 -0
  42. package/dist/packages/tripmap-core/dist/line.js +6 -6
  43. package/dist/packages/tripmap-core/dist/markers.js +60 -51
  44. package/dist/packages/tripmap-core/dist/nodes.js +56 -43
  45. package/dist/packages/tripmap-core/dist/playback.js +20 -16
  46. package/dist/packages/tripmap-core/dist/preload.js +44 -0
  47. package/dist/packages/tripmap-core/dist/theme.js +21 -21
  48. package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl.js +2006 -1791
  49. package/dist/{node_modules → packages/tripmap-core/node_modules}/pmtiles/dist/esm/index.js +1 -1
  50. package/package.json +8 -3
  51. package/src/core/client-types.ts +13 -2
  52. package/src/core/client.ts +40 -5
  53. package/src/core/consultation-adapter.ts +408 -0
  54. package/src/core/consultations.ts +224 -0
  55. package/src/core/errors.ts +145 -0
  56. package/src/core/index.ts +68 -0
  57. package/src/core/queries.ts +167 -3
  58. package/src/core/review/format.ts +138 -0
  59. package/src/core/review/index.ts +22 -0
  60. package/src/core/review/types.ts +168 -0
  61. package/src/core/server-only.ts +20 -0
  62. package/src/core/types.ts +337 -0
  63. /package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl-shared.js +0 -0
@@ -0,0 +1,8 @@
1
+ function i(t, n) {
2
+ if (typeof t != "number" || !Number.isFinite(t)) return null;
3
+ const e = Number.isFinite(n) ? n : 0;
4
+ return ((t - e) % 360 + 360) % 360;
5
+ }
6
+ export {
7
+ i as headingRotation
8
+ };
@@ -0,0 +1,18 @@
1
+ const o = "https://tripmap.invalid/", l = new URL(o).origin, u = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, c = /[\t\n\r]/g, i = /^(?:\/|\.\.?\/|[#?])/, s = /^[a-z][a-z0-9+.-]*:/i;
2
+ function E(r) {
3
+ if (typeof r != "string") return null;
4
+ const t = r.replace(u, "").replace(c, "");
5
+ if (!t) return null;
6
+ const e = i.test(t);
7
+ if (!e && !s.test(t)) return null;
8
+ let n;
9
+ try {
10
+ n = new URL(t, o);
11
+ } catch {
12
+ return null;
13
+ }
14
+ return e ? n.origin === l ? t : null : n.protocol === "https:" || n.protocol === "http:" ? t : null;
15
+ }
16
+ export {
17
+ E as safeNodeHref
18
+ };
@@ -1,32 +1,54 @@
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 u, captureTimeMs as c, formatTimeHHMM as g, lineNodes as m, normalizeHandNode as p, tripSummary as b } from "./nodes.js";
2
+ import { safeNodeHref as f } from "./href.js";
3
+ import { approxDistanceKm as v, computeFramingBounds as w } from "./framing.js";
4
+ import { OSM_ATTRIBUTION as T, buildAttributions as A } from "./attribution.js";
5
+ const a = "0.1.9", r = {
5
6
  light: "https://tiles.openfreemap.org/styles/liberty",
6
7
  dark: "https://tiles.openfreemap.org/styles/dark"
7
- }, r = () => import("./engine.js");
8
- function l(e) {
8
+ }, n = () => import("./engine.js");
9
+ function s(e) {
9
10
  return {
10
- styleUrl: e.styleUrl || s.light,
11
- darkStyleUrl: e.darkStyleUrl || e.styleUrl || s.dark,
11
+ styleUrl: e.styleUrl || r.light,
12
+ darkStyleUrl: e.darkStyleUrl || e.styleUrl || r.dark,
12
13
  theme: e.theme ?? "auto",
13
14
  cluster: e.cluster ?? !0,
14
15
  clusterRadius: e.clusterRadius ?? 40,
15
16
  showLine: e.showLine ?? !0,
16
17
  showFilmstrip: e.showFilmstrip ?? !0,
17
18
  showPlayback: e.showPlayback ?? !0,
19
+ showFullscreen: e.showFullscreen ?? !0,
20
+ showExport: e.showExport ?? !0,
21
+ showGeolocate: e.showGeolocate ?? !0,
22
+ showTime: e.showTime ?? !0,
23
+ watermark: e.watermark,
24
+ title: e.title,
25
+ detail: e.detail ?? "popup",
26
+ detailHost: e.detailHost,
18
27
  initialView: e.initialView,
19
28
  extraAttribution: e.extraAttribution,
20
29
  labels: {
21
30
  play: e.labels?.play ?? "Play route",
22
- stop: e.labels?.stop ?? "Stop"
31
+ stop: e.labels?.stop ?? "Stop",
32
+ fullscreen: e.labels?.fullscreen ?? "Fullscreen",
33
+ exitFullscreen: e.labels?.exitFullscreen ?? "Exit fullscreen",
34
+ export: e.labels?.export ?? "Export route",
35
+ exportGpx: e.labels?.exportGpx ?? "Download GPX",
36
+ exportGpxHint: e.labels?.exportGpxHint ?? "watches, Garmin, Strava, Komoot",
37
+ openInMapy: e.labels?.openInMapy ?? "Open in Mapy.com",
38
+ openInGoogleMaps: e.labels?.openInGoogleMaps ?? "Open in Google Maps",
39
+ lightboxClose: e.labels?.lightboxClose ?? "Close",
40
+ lightboxPrev: e.labels?.lightboxPrev ?? "Previous photo",
41
+ lightboxNext: e.labels?.lightboxNext ?? "Next photo",
42
+ zoomImage: e.labels?.zoomImage ?? "View full screen",
43
+ findMyLocation: e.labels?.findMyLocation ?? "Show my location",
44
+ locationNotAvailable: e.labels?.locationNotAvailable ?? "Location not available"
23
45
  },
24
46
  events: e.events ?? {}
25
47
  };
26
48
  }
27
- class h {
28
- constructor(i, t) {
29
- this.container = i, this.resolved = l(t), this.loader = t.engineLoader ?? r;
49
+ class o {
50
+ constructor(t, i) {
51
+ this.container = t, this.resolved = s(i), this.loader = i.engineLoader ?? n;
30
52
  }
31
53
  resolved;
32
54
  engine = null;
@@ -44,28 +66,28 @@ class h {
44
66
  */
45
67
  init() {
46
68
  return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
47
- let i;
69
+ let t;
48
70
  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;
71
+ t = await this.loader();
72
+ } catch (i) {
73
+ const l = i instanceof Error ? i : new Error("tripmap: engine load failed");
74
+ throw this.resolved.events.onError?.(l), l;
53
75
  }
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);
76
+ 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
77
  })(), this.initPromise);
56
78
  }
57
- setNodes(i) {
58
- this.engine ? this.engine.setNodes(i) : this.pendingNodes = i;
79
+ setNodes(t) {
80
+ this.engine ? this.engine.setNodes(t) : this.pendingNodes = t;
59
81
  }
60
- setActiveNode(i, t) {
61
- this.engine ? this.engine.setActiveNode(i, t) : this.pendingActive = { id: i, ...t };
82
+ setActiveNode(t, i) {
83
+ this.engine ? this.engine.setActiveNode(t, i) : this.pendingActive = { id: t, ...i };
62
84
  }
63
- playSequence(i) {
64
- return this.engine ? this.engine.playSequence(i) : { stop() {
85
+ playSequence(t) {
86
+ return this.engine ? this.engine.playSequence(t) : { stop() {
65
87
  } };
66
88
  }
67
- setTheme(i) {
68
- this.engine ? this.engine.setTheme(i) : this.pendingTheme = i;
89
+ setTheme(t) {
90
+ this.engine ? this.engine.setTheme(t) : this.pendingTheme = t;
69
91
  }
70
92
  resize() {
71
93
  this.engine?.resize();
@@ -75,16 +97,18 @@ class h {
75
97
  }
76
98
  }
77
99
  export {
78
- s as DEFAULT_STYLE_URLS,
79
- A as OSM_ATTRIBUTION,
80
- h as TripMap,
81
- o as VERSION,
100
+ r as DEFAULT_STYLE_URLS,
101
+ T as OSM_ATTRIBUTION,
102
+ o as TripMap,
103
+ a as VERSION,
82
104
  v as approxDistanceKm,
83
- b as buildAttributions,
84
- p as buildTripNodes,
85
- N as computeFramingBounds,
105
+ A as buildAttributions,
106
+ u as buildTripNodes,
107
+ c as captureTimeMs,
108
+ w as computeFramingBounds,
86
109
  g as formatTimeHHMM,
87
- u as lineNodes,
88
- c as normalizeHandNode,
89
- m as tripSummary
110
+ m as lineNodes,
111
+ p as normalizeHandNode,
112
+ f as safeNodeHref,
113
+ b as tripSummary
90
114
  };
@@ -0,0 +1,96 @@
1
+ function d(h) {
2
+ return h.largeImageUrl || h.imageUrl || h.thumbnailUrl;
3
+ }
4
+ class u {
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((i) => !!d(i));
26
+ const n = this.nodes.findIndex((i) => i.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", (p) => {
51
+ p.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 i = t.createElement("button");
56
+ i.type = "button", i.className = "tripmap-lightbox__nav tripmap-lightbox__nav--prev", i.setAttribute("aria-label", this.labels.prev), i.textContent = "‹", i.addEventListener("click", () => this.prev());
57
+ const s = t.createElement("button");
58
+ s.type = "button", s.className = "tripmap-lightbox__nav tripmap-lightbox__nav--next", s.setAttribute("aria-label", this.labels.next), s.textContent = "›", s.addEventListener("click", () => this.next());
59
+ const r = t.createElement("figure");
60
+ r.className = "tripmap-lightbox__figure";
61
+ const o = t.createElement("img");
62
+ o.className = "tripmap-lightbox__img", o.decoding = "async", o.draggable = !1;
63
+ const l = t.createElement("figcaption");
64
+ l.className = "tripmap-lightbox__caption", r.appendChild(o), r.appendChild(l), e.appendChild(n), e.appendChild(i), e.appendChild(r), e.appendChild(s);
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 = o, this.caption = l, this.prevBtn = i, this.nextBtn = s, 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 = d(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);
75
+ const i = t.capturedAt ? this.callbacks.formatTime(t.capturedAt) : "";
76
+ i && n.push(i);
77
+ const s = this.host.ownerDocument.createElement("span");
78
+ s.className = "tripmap-lightbox__caption-head", s.textContent = n.join(" · "), n.length && this.caption.appendChild(s);
79
+ const r = t.description || t.altText;
80
+ if (r) {
81
+ const l = this.host.ownerDocument.createElement("span");
82
+ l.className = "tripmap-lightbox__caption-text", l.textContent = r, this.caption.appendChild(l);
83
+ }
84
+ const o = this.nodes.length > 1;
85
+ if (this.prevBtn && (this.prevBtn.hidden = !o), this.nextBtn && (this.nextBtn.hidden = !o), this.root.dataset.tripmapNode = t.id, o && this.callbacks.preload)
86
+ for (const l of [1, -1]) {
87
+ const a = this.nodes[(this.index + l + this.nodes.length) % this.nodes.length], c = d(a);
88
+ c && this.callbacks.preload(c);
89
+ }
90
+ this.callbacks.onChange?.(t);
91
+ }
92
+ }
93
+ export {
94
+ u as Lightbox,
95
+ d as lightboxImageUrl
96
+ };
@@ -1,6 +1,6 @@
1
- import { lineNodes as t } from "./nodes.js";
2
- function o(i) {
3
- const e = t(i);
1
+ import { lineNodes as i } from "./nodes.js";
2
+ function l(t) {
3
+ const e = i(t);
4
4
  return e.length < 2 ? null : {
5
5
  type: "Feature",
6
6
  geometry: {
@@ -18,7 +18,7 @@ const r = [
18
18
  "#60a5fa",
19
19
  1,
20
20
  "#1d4ed8"
21
- ], l = {
21
+ ], a = {
22
22
  "line-width": 3,
23
23
  "line-opacity": 0.85,
24
24
  "line-gradient": r
@@ -29,6 +29,6 @@ const r = [
29
29
  export {
30
30
  r as LINE_GRADIENT_EXPRESSION,
31
31
  p as LINE_LAYER_LAYOUT,
32
- l as LINE_LAYER_PAINT,
33
- o as buildLineFeature
32
+ a as LINE_LAYER_PAINT,
33
+ l as buildLineFeature
34
34
  };
@@ -1,23 +1,24 @@
1
- class c {
1
+ import { safeNodeHref as m } from "./href.js";
2
+ class u {
2
3
  constructor(r) {
3
4
  this.adapter = r;
4
5
  }
5
6
  entries = /* @__PURE__ */ new Map();
6
7
  /** Diff the desired set against the mounted set by key. */
7
8
  sync(r) {
8
- const a = /* @__PURE__ */ new Set();
9
+ const n = /* @__PURE__ */ new Set();
9
10
  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);
11
+ n.add(t.key);
12
+ const i = this.entries.get(t.key);
13
+ if (i) {
14
+ (i.lngLat[0] !== t.lngLat[0] || i.lngLat[1] !== t.lngLat[1]) && (this.adapter.move(i.handle, t.lngLat), i.lngLat = t.lngLat);
14
15
  continue;
15
16
  }
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 });
17
+ const s = t.createEl(), a = this.adapter.mount(s, t.lngLat);
18
+ this.entries.set(t.key, { el: s, handle: a, lngLat: t.lngLat });
18
19
  }
19
- for (const [t, e] of this.entries)
20
- a.has(t) || (this.adapter.unmount(e.handle), this.entries.delete(t));
20
+ for (const [t, i] of this.entries)
21
+ n.has(t) || (this.adapter.unmount(i.handle), this.entries.delete(t));
21
22
  }
22
23
  get(r) {
23
24
  return this.entries.get(r)?.el;
@@ -30,61 +31,69 @@ class c {
30
31
  this.entries.clear();
31
32
  }
32
33
  }
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) {
34
+ const o = "tripmap-marker--active";
35
+ function g(e, r) {
36
+ const n = document.createElement("button");
37
+ 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
38
  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);
39
+ t.src = e.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-marker__img", n.appendChild(t);
39
40
  } else {
40
- a.classList.add("tripmap-marker--dot");
41
+ n.classList.add("tripmap-marker--dot");
41
42
  const t = document.createElement("span");
42
- t.className = "tripmap-marker__dot", a.appendChild(t);
43
+ t.className = "tripmap-marker__dot", n.appendChild(t);
43
44
  }
44
- return a.addEventListener("click", (t) => {
45
- t.stopPropagation(), r(n);
46
- }), a;
45
+ return n.addEventListener("click", (t) => {
46
+ t.stopPropagation(), r(e);
47
+ }), n;
47
48
  }
48
- function o(n, r, a) {
49
+ function h(e, r, n) {
49
50
  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();
51
+ t.type = "button", t.className = "tripmap-marker tripmap-marker--cluster", t.setAttribute("aria-label", `${e}`);
52
+ const i = document.createElement("span");
53
+ return i.className = "tripmap-marker__count", i.textContent = String(e), t.appendChild(i), t.addEventListener("click", (s) => {
54
+ s.stopPropagation(), n();
54
55
  }), t;
55
56
  }
56
- function m(n, r) {
57
- n?.classList.toggle(l, r);
57
+ function f(e, r) {
58
+ e?.classList.toggle(o, r);
58
59
  }
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) {
64
- const s = document.createElement("a");
65
- s.href = n.href, s.appendChild(e), a.appendChild(s);
60
+ function k(e, r, n = {}) {
61
+ const t = document.createElement("div");
62
+ if (t.className = "tripmap-popup", e.imageUrl || e.thumbnailUrl) {
63
+ const a = n.image ?? document.createElement("img");
64
+ n.image || (a.src = e.imageUrl || e.thumbnailUrl, a.loading = "eager", a.decoding = "async"), a.alt = e.altText || "", a.className = "tripmap-popup__img";
65
+ const c = m(e.href);
66
+ if (c) {
67
+ const l = document.createElement("a");
68
+ l.href = c, l.appendChild(a), t.appendChild(l);
69
+ } else if (n.onImageClick) {
70
+ const l = document.createElement("button");
71
+ l.type = "button", l.className = "tripmap-popup__zoom", n.zoomLabel && l.setAttribute("aria-label", n.zoomLabel), l.appendChild(a), l.addEventListener("click", (p) => {
72
+ p.stopPropagation(), n.onImageClick?.(e);
73
+ }), t.appendChild(l);
66
74
  } else
67
- a.appendChild(e);
75
+ t.appendChild(a);
68
76
  }
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);
77
+ const i = document.createElement("div");
78
+ if (i.className = "tripmap-popup__meta", e.title) {
79
+ const a = document.createElement("strong");
80
+ a.className = "tripmap-popup__title", a.textContent = e.title, i.appendChild(a);
73
81
  }
74
- if (n.capturedAt) {
75
- const e = document.createElement("span");
76
- e.className = "tripmap-popup__time", e.textContent = r(n.capturedAt), t.appendChild(e);
82
+ const s = e.capturedAt ? r(e.capturedAt) : "";
83
+ if (s) {
84
+ const a = document.createElement("span");
85
+ a.className = "tripmap-popup__time", a.textContent = s, i.appendChild(a);
77
86
  }
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);
87
+ if (e.description || e.altText) {
88
+ const a = document.createElement("p");
89
+ a.className = "tripmap-popup__desc", a.textContent = e.description || e.altText || "", i.appendChild(a);
81
90
  }
82
- return t.childNodes.length > 0 && a.appendChild(t), a;
91
+ return i.childNodes.length > 0 && t.appendChild(i), t;
83
92
  }
84
93
  export {
85
- c as MarkerPool,
86
- o as createClusterMarkerEl,
87
- p as createNodeMarkerEl,
88
- d as createPopupContent,
89
- m as setMarkerActive
94
+ u as MarkerPool,
95
+ h as createClusterMarkerEl,
96
+ g as createNodeMarkerEl,
97
+ k as createPopupContent,
98
+ f as setMarkerActive
90
99
  };
@@ -1,55 +1,68 @@
1
- function d(n, t) {
2
- return typeof n == "number" && typeof t == "number" && Number.isFinite(n) && Number.isFinite(t) && Math.abs(n) <= 90 && Math.abs(t) <= 180;
3
- }
4
- function r(n) {
5
- if (!n) return null;
6
- const t = Date.parse(n);
7
- return Number.isNaN(t) ? null : t;
8
- }
9
- function c(n, t) {
10
- return !n || !d(n.lat, n.lng) ? null : {
11
- id: n.id || `waypoint-${t}`,
12
- lat: n.lat,
13
- lng: n.lng,
14
- capturedAt: r(n.capturedAt) !== null ? n.capturedAt : void 0,
15
- thumbnailUrl: n.thumbnailUrl,
16
- title: n.title,
17
- description: n.description,
18
- href: n.href,
1
+ import { safeNodeHref as f } from "./href.js";
2
+ const p = 90, a = 180;
3
+ function s(t, n) {
4
+ return typeof t == "number" && typeof n == "number" && Number.isFinite(t) && Number.isFinite(n) && Math.abs(t) <= p && Math.abs(n) <= a;
5
+ }
6
+ const m = /^(\d{4}-\d{2}-\d{2})[Tt ](\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)$/;
7
+ function o(t) {
8
+ if (typeof t != "string" || !t) return null;
9
+ const n = m.exec(t.trim()), i = Date.parse(n ? `${n[1]}T${n[2]}Z` : t);
10
+ return Number.isNaN(i) ? null : i;
11
+ }
12
+ function h(t, n) {
13
+ return !t || !s(t.lat, t.lng) ? null : {
14
+ id: t.id || `waypoint-${n}`,
15
+ lat: t.lat,
16
+ lng: t.lng,
17
+ capturedAt: o(t.capturedAt) !== null ? t.capturedAt : void 0,
18
+ thumbnailUrl: t.thumbnailUrl,
19
+ title: t.title,
20
+ description: t.description,
21
+ // Where author JSON becomes a node: an unsafe link is dropped here, so no
22
+ // consumer of the node (popup, SSR fallback) ever holds it.
23
+ href: f(t.href) ?? void 0,
19
24
  kind: "waypoint"
20
25
  };
21
26
  }
22
- function f(n, t = []) {
23
- const i = [], u = /* @__PURE__ */ new Set();
24
- for (const e of n)
25
- !e || !e.id || !d(e.lat, e.lng) || u.has(e.id) || (u.add(e.id), i.push({ kind: "photo", ...e }));
26
- t.forEach((e, a) => {
27
- const l = c(e, a);
28
- !l || u.has(l.id) || (u.add(l.id), i.push(l));
27
+ function M(t, n = []) {
28
+ const i = [], r = /* @__PURE__ */ new Set();
29
+ for (const e of t)
30
+ !e || !e.id || !s(e.lat, e.lng) || r.has(e.id) || (r.add(e.id), i.push({ kind: "photo", ...e }));
31
+ n.forEach((e, d) => {
32
+ const u = h(e, d);
33
+ !u || r.has(u.id) || (r.add(u.id), i.push(u));
29
34
  });
30
- const o = i.filter((e) => r(e.capturedAt) !== null), s = i.filter((e) => r(e.capturedAt) === null);
31
- return o.sort((e, a) => r(e.capturedAt) - r(a.capturedAt)), [...o, ...s];
35
+ const c = i.filter((e) => o(e.capturedAt) !== null), l = i.filter((e) => o(e.capturedAt) === null);
36
+ return c.sort((e, d) => o(e.capturedAt) - o(d.capturedAt)), [...c, ...l];
32
37
  }
33
- function p(n) {
34
- return n.filter((t) => r(t.capturedAt) !== null);
38
+ function A(t) {
39
+ return t.filter((n) => o(n.capturedAt) !== null);
35
40
  }
36
- function h(n) {
37
- const t = /T(\d{2}):(\d{2})/.exec(n);
38
- return t ? `${t[1]}:${t[2]}` : "";
41
+ function g(t) {
42
+ const n = /T(\d{2}):(\d{2})/.exec(t);
43
+ return n ? `${n[1]}:${n[2]}` : "";
39
44
  }
40
- function m(n) {
41
- const t = p(n);
45
+ const T = /^(\d{4}-\d{2}-\d{2})(?:[Tt ]|$)/;
46
+ function E(t) {
47
+ const n = A(t), i = n[0] ?? null;
42
48
  return {
43
- count: n.length,
44
- first: t[0] ?? null,
45
- last: t[t.length - 1] ?? null,
46
- dateIso: t[0]?.capturedAt?.slice(0, 10) ?? null
49
+ count: t.length,
50
+ first: i,
51
+ last: n[n.length - 1] ?? null,
52
+ // Timed means captureTimeMs read it, so capturedAt is a string here.
53
+ dateIso: i ? N(i.capturedAt) : null
47
54
  };
48
55
  }
56
+ function N(t) {
57
+ const n = T.exec(t.trim());
58
+ return n ? n[1] : new Date(o(t)).toISOString().slice(0, 10);
59
+ }
49
60
  export {
50
- f as buildTripNodes,
51
- h as formatTimeHHMM,
52
- p as lineNodes,
53
- c as normalizeHandNode,
54
- m as tripSummary
61
+ M as buildTripNodes,
62
+ o as captureTimeMs,
63
+ g as formatTimeHHMM,
64
+ A as lineNodes,
65
+ h as normalizeHandNode,
66
+ f as safeNodeHref,
67
+ E as tripSummary
55
68
  };
@@ -1,25 +1,29 @@
1
- import { lineNodes as p } from "./nodes.js";
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 = {
1
+ import { lineNodes as m } from "./nodes.js";
2
+ const w = 2e3;
3
+ function T(r, t, u = {}) {
4
+ const e = m(r), a = u.dwellMs ?? w;
5
+ let o = !1, l;
6
+ const n = {
7
7
  stop() {
8
- t || (t = !0, s && clearTimeout(s), f(), o.onDone?.());
8
+ o || (o = !0, l && clearTimeout(l), f(), t.onDone?.());
9
9
  }
10
- }, f = o.onUserInterrupt?.(() => e.stop()) ?? (() => {
10
+ }, f = t.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 p() {
13
+ t.preload?.(e[0]);
14
+ for (let s = 0; s < e.length; s++) {
15
+ const i = e[s];
16
+ if (o || (await t.flyTo(i), o)) return;
17
+ t.showNode(i);
18
+ const c = e[s + 1];
19
+ c && t.preload?.(c), await new Promise((d) => {
20
+ l = setTimeout(d, a);
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() : p(), n;
22
26
  }
23
27
  export {
24
- d as startPlayback
28
+ T as startPlayback
25
29
  };
@@ -0,0 +1,44 @@
1
+ class o {
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 i = this.doc.createElement("img");
12
+ i.decoding = "async";
13
+ const n = new Promise((s) => {
14
+ i.addEventListener(
15
+ "load",
16
+ () => {
17
+ const r = typeof i.decode == "function" ? i.decode() : void 0;
18
+ r ? r.then(s, s) : s();
19
+ },
20
+ { once: !0 }
21
+ ), i.addEventListener("error", () => s(), { once: !0 });
22
+ });
23
+ for (i.src = e, this.entries.set(e, { img: i, ready: n }); this.entries.size > this.limit; ) {
24
+ const s = this.entries.keys().next().value;
25
+ if (s === void 0) break;
26
+ this.entries.delete(s);
27
+ }
28
+ return n;
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
+ o as ImagePreloader
44
+ };