@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,72 @@
1
+ import { lineNodes as g, captureTimeMs as m } from "./nodes.js";
2
+ function c(o) {
3
+ return g(o);
4
+ }
5
+ function u(o, n) {
6
+ const t = o.slice(1, -1);
7
+ if (n <= 0 || t.length === 0) return [];
8
+ if (t.length <= n) return t;
9
+ const r = [];
10
+ for (let i = 0; i < n; i++) {
11
+ const a = Math.round((i + 1) * (t.length - 1) / (n + 1)), e = t[Math.min(a, t.length - 1)];
12
+ r[r.length - 1] !== e && r.push(e);
13
+ }
14
+ return r;
15
+ }
16
+ const l = (o) => o.toFixed(5).replace(/\.?0+$/, "");
17
+ function h(o, n = {}) {
18
+ const t = c(o);
19
+ if (t.length < 2) return null;
20
+ const r = (e) => `${l(e.lng)},${l(e.lat)}`, i = [
21
+ `mapset=${n.mapset ?? "outdoor"}`,
22
+ `start=${r(t[0])}`,
23
+ `end=${r(t[t.length - 1])}`,
24
+ `routeType=${n.routeType ?? "foot_hiking"}`
25
+ ], a = u(t, Math.min(n.maxWaypoints ?? 15, 15));
26
+ return a.length > 0 && i.push(`waypoints=${a.map(r).join(";")}`), n.navigate && i.push("navigate=true"), `https://mapy.com/fnc/v1/route?${i.join("&")}`;
27
+ }
28
+ function f(o, n = {}) {
29
+ const t = c(o);
30
+ if (t.length < 2) return null;
31
+ const r = (e) => `${l(e.lat)},${l(e.lng)}`, i = [
32
+ "api=1",
33
+ `origin=${r(t[0])}`,
34
+ `destination=${r(t[t.length - 1])}`,
35
+ `travelmode=${n.travelmode ?? "walking"}`
36
+ ], a = u(t, Math.min(n.maxWaypoints ?? 9, 9));
37
+ return a.length > 0 && i.push(`waypoints=${a.map(r).join("%7C")}`), `https://www.google.com/maps/dir/?${i.join("&")}`;
38
+ }
39
+ const s = (o) => o.replace(/[<>&'"]/g, (n) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", "'": "&apos;", '"': "&quot;" })[n]);
40
+ function p(o) {
41
+ const n = m(o);
42
+ return n === null ? "" : `<time>${new Date(n).toISOString()}</time>`;
43
+ }
44
+ function d(o, n = {}) {
45
+ const t = c(o);
46
+ if (t.length < 2) return null;
47
+ const r = s(n.name || "Trip"), a = [
48
+ '<?xml version="1.0" encoding="UTF-8"?>',
49
+ `<gpx version="1.1" creator="${s(n.creator || "blogmcp TripMap")}" xmlns="http://www.topografix.com/GPX/1/1">`,
50
+ ` <metadata><name>${r}</name>${p(t[0].capturedAt)}</metadata>`
51
+ ];
52
+ for (const e of o)
53
+ e.title && a.push(
54
+ ` <wpt lat="${l(e.lat)}" lon="${l(e.lng)}">` + p(e.capturedAt) + `<name>${s(e.title)}</name>` + (e.description ? `<desc>${s(e.description)}</desc>` : "") + "</wpt>"
55
+ );
56
+ a.push(` <trk><name>${r}</name><trkseg>`);
57
+ for (const e of t)
58
+ a.push(` <trkpt lat="${l(e.lat)}" lon="${l(e.lng)}">${p(e.capturedAt)}</trkpt>`);
59
+ return a.push(" </trkseg></trk>", "</gpx>", ""), a.join(`
60
+ `);
61
+ }
62
+ function w(o, n = "trasa") {
63
+ return `${(o ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || n}.gpx`;
64
+ }
65
+ export {
66
+ d as buildGpx,
67
+ f as googleMapsRouteUrl,
68
+ w as gpxFileName,
69
+ h as mapyRouteUrl,
70
+ c as routePoints,
71
+ u as sampleWaypoints
72
+ };
@@ -1,35 +1,48 @@
1
- const a = "tripmap-filmstrip__item--active";
2
- class l {
3
- constructor(s, i) {
4
- this.callbacks = i, this.root = document.createElement("div"), this.root.className = "tripmap-filmstrip", this.root.setAttribute("role", "listbox"), s.appendChild(this.root);
1
+ const l = "tripmap-filmstrip__item--active";
2
+ class r {
3
+ constructor(s, e) {
4
+ this.callbacks = e, this.root = document.createElement("div"), this.root.className = "tripmap-filmstrip", this.root.setAttribute("role", "listbox"), s.appendChild(this.root);
5
5
  }
6
6
  root;
7
7
  items = /* @__PURE__ */ new Map();
8
+ /**
9
+ * The active node id, remembered ACROSS rebuilds. `setNodes` runs again when
10
+ * the map style finishes loading (engine `applyData`), and a host that
11
+ * activates a node before that — the storefront's Split map dialog opens ON
12
+ * the clicked photo — would otherwise get a fresh strip with nothing selected
13
+ * and the scroll back at the start.
14
+ */
15
+ activeId = null;
8
16
  setNodes(s) {
9
17
  this.root.textContent = "", this.items.clear();
10
- for (const i of s) {
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) {
18
+ for (const e of s) {
19
+ const i = document.createElement("button");
20
+ if (i.type = "button", i.className = "tripmap-filmstrip__item", i.dataset.tripmapNode = e.id, i.setAttribute("role", "option"), i.setAttribute("aria-selected", "false"), i.setAttribute("aria-label", e.title || e.altText || e.id), e.thumbnailUrl) {
13
21
  const t = document.createElement("img");
14
- t.src = i.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-filmstrip__img", e.appendChild(t);
22
+ t.src = e.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-filmstrip__img", i.appendChild(t);
15
23
  } else {
16
- e.classList.add("tripmap-filmstrip__item--waypoint");
24
+ i.classList.add("tripmap-filmstrip__item--waypoint");
17
25
  const t = document.createElement("span");
18
- t.className = "tripmap-filmstrip__label", t.textContent = i.title || "·", e.appendChild(t);
26
+ t.className = "tripmap-filmstrip__label", t.textContent = e.title || "·", i.appendChild(t);
19
27
  }
20
- if (i.capturedAt) {
28
+ const a = e.capturedAt ? this.callbacks.formatTime(e.capturedAt) : "";
29
+ if (a) {
21
30
  const t = document.createElement("span");
22
- t.className = "tripmap-filmstrip__time", t.textContent = this.callbacks.formatTime(i.capturedAt), e.appendChild(t);
31
+ t.className = "tripmap-filmstrip__time", t.textContent = a, i.appendChild(t);
23
32
  }
24
- e.addEventListener("click", () => this.callbacks.onSelect(i)), this.items.set(i.id, e), this.root.appendChild(e);
33
+ i.addEventListener("click", () => this.callbacks.onSelect(e)), this.items.set(e.id, i), this.root.appendChild(i);
25
34
  }
35
+ this.activeId && this.items.has(this.activeId) && this.apply(this.activeId, "instant");
26
36
  }
27
37
  setActive(s) {
28
- for (const [i, e] of this.items) {
38
+ this.activeId = s, this.apply(s, "smooth");
39
+ }
40
+ apply(s, e) {
41
+ for (const [i, a] of this.items) {
29
42
  const t = i === s;
30
- if (e.classList.toggle(a, t), e.setAttribute("aria-selected", t ? "true" : "false"), t && typeof e.scrollIntoView == "function")
43
+ if (a.classList.toggle(l, t), a.setAttribute("aria-selected", t ? "true" : "false"), t && typeof a.scrollIntoView == "function")
31
44
  try {
32
- e.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
45
+ a.scrollIntoView({ block: "nearest", inline: "nearest", behavior: e });
33
46
  } catch {
34
47
  }
35
48
  }
@@ -42,5 +55,5 @@ class l {
42
55
  }
43
56
  }
44
57
  export {
45
- l as Filmstrip
58
+ r as Filmstrip
46
59
  };
@@ -1,44 +1,44 @@
1
- function i(l) {
2
- const t = [...l].sort((a, o) => a - o), n = Math.floor(t.length / 2);
3
- return t.length % 2 ? t[n] : (t[n - 1] + t[n]) / 2;
1
+ function s(n) {
2
+ const t = [...n].sort((i, r) => i - r), e = Math.floor(t.length / 2);
3
+ return t.length % 2 ? t[e] : (t[e - 1] + t[e]) / 2;
4
4
  }
5
- function h(l, t) {
6
- const n = (l.lat - t.lat) * 111.32, a = (l.lng - t.lng) * 111.32 * Math.cos((l.lat + t.lat) / 2 * (Math.PI / 180));
7
- return Math.sqrt(n * n + a * a);
5
+ function m(n, t) {
6
+ const i = (n.lat - t.lat) * 111.32, r = (n.lng - t.lng) * 111.32 * Math.cos((n.lat + t.lat) / 2 * (Math.PI / 180));
7
+ return Math.sqrt(i * i + r * r);
8
8
  }
9
- function c(l) {
10
- let t = 1 / 0, n = 1 / 0, a = -1 / 0, o = -1 / 0;
11
- for (const e of l)
12
- e.lng < t && (t = e.lng), e.lng > a && (a = e.lng), e.lat < n && (n = e.lat), e.lat > o && (o = e.lat);
9
+ function f(n) {
10
+ let t = 1 / 0, e = 1 / 0, i = -1 / 0, r = -1 / 0;
11
+ for (const o of n)
12
+ o.lng < t && (t = o.lng), o.lng > i && (i = o.lng), o.lat < e && (e = o.lat), o.lat > r && (r = o.lat);
13
13
  return [
14
- [t, n],
15
- [a, o]
14
+ [t, e],
15
+ [i, r]
16
16
  ];
17
17
  }
18
- function f(l) {
19
- return h({ lat: l[0][1], lng: l[0][0] }, { lat: l[1][1], lng: l[1][0] });
18
+ function u(n) {
19
+ return m({ lat: n[0][1], lng: n[0][0] }, { lat: n[1][1], lng: n[1][0] });
20
20
  }
21
- function M(l) {
22
- const t = l.filter((r) => Number.isFinite(r.lat) && Number.isFinite(r.lng));
21
+ function p(n) {
22
+ const t = n.filter((l) => Number.isFinite(l.lat) && Number.isFinite(l.lng));
23
23
  if (t.length === 0) return null;
24
24
  if (t.length === 1) {
25
- const r = t[0];
25
+ const l = t[0];
26
26
  return [
27
- [r.lng, r.lat],
28
- [r.lng, r.lat]
27
+ [l.lng, l.lat],
28
+ [l.lng, l.lat]
29
29
  ];
30
30
  }
31
- const n = c(t);
32
- if (t.length < 5) return n;
33
- const a = {
34
- lat: i(t.map((r) => r.lat)),
35
- lng: i(t.map((r) => r.lng))
36
- }, o = t.map((r) => h(r, a)), e = Math.max(5, 3 * i(o)), g = t.filter((r, p) => o[p] <= e);
37
- if (g.length === t.length || g.length < 2) return n;
38
- const u = c(g), s = f(n), m = f(u);
39
- return s > 0 && m / s < 0.5 ? u : n;
31
+ const e = f(t);
32
+ if (t.length < 5) return e;
33
+ const i = {
34
+ lat: s(t.map((l) => l.lat)),
35
+ lng: s(t.map((l) => l.lng))
36
+ }, r = t.map((l) => m(l, i)), o = Math.max(5, 3 * s(r)), a = t.filter((l, d) => r[d] <= o);
37
+ if (a.length === t.length || a.length < 2) return e;
38
+ const c = f(a), g = u(e), h = u(c);
39
+ return g > 0 && h / g < 0.5 ? c : e;
40
40
  }
41
41
  export {
42
- h as approxDistanceKm,
43
- M as computeFramingBounds
42
+ m as approxDistanceKm,
43
+ p as computeFramingBounds
44
44
  };