@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.
- package/LICENSE +21 -0
- package/dist/core/client-types.d.ts +7 -1
- package/dist/core/client.d.ts +25 -1
- package/dist/core/client.js +38 -34
- package/dist/core/consultation-adapter.d.ts +90 -0
- package/dist/core/consultation-adapter.js +200 -0
- package/dist/core/consultations.d.ts +108 -0
- package/dist/core/consultations.js +95 -0
- package/dist/core/errors.d.ts +52 -0
- package/dist/core/errors.js +73 -0
- package/dist/core/index.d.ts +7 -1
- package/dist/core/index.js +80 -64
- package/dist/core/queries.d.ts +16 -1
- package/dist/core/queries.js +198 -61
- package/dist/core/review/format.d.ts +30 -0
- package/dist/core/review/format.js +78 -0
- package/dist/core/review/index.d.ts +6 -0
- package/dist/core/review/index.js +9 -0
- package/dist/core/review/types.d.ts +176 -0
- package/dist/core/review/types.js +9 -0
- package/dist/core/server-only.d.ts +12 -0
- package/dist/core/server-only.js +11 -0
- package/dist/core/types.d.ts +295 -0
- package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +21 -25
- package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +1 -0
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +105 -94
- package/dist/packages/mdx-schema/dist/metadata/index.js +12 -3
- package/dist/packages/mdx-schema/dist/styles/index.js +9 -1
- package/dist/packages/mdx-schema/dist/tripmap.js +81 -35
- package/dist/packages/tripmap-core/dist/attribution.js +121 -6
- package/dist/packages/tripmap-core/dist/css.js +149 -20
- package/dist/packages/tripmap-core/dist/detail.js +51 -0
- package/dist/packages/tripmap-core/dist/engine.js +367 -174
- package/dist/packages/tripmap-core/dist/export.js +72 -0
- package/dist/packages/tripmap-core/dist/filmstrip.js +30 -17
- package/dist/packages/tripmap-core/dist/framing.js +30 -30
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
- package/dist/packages/tripmap-core/dist/heading.js +8 -0
- package/dist/packages/tripmap-core/dist/href.js +18 -0
- package/dist/packages/tripmap-core/dist/index.js +60 -36
- package/dist/packages/tripmap-core/dist/lightbox.js +96 -0
- package/dist/packages/tripmap-core/dist/line.js +6 -6
- package/dist/packages/tripmap-core/dist/markers.js +60 -51
- package/dist/packages/tripmap-core/dist/nodes.js +56 -43
- package/dist/packages/tripmap-core/dist/playback.js +20 -16
- package/dist/packages/tripmap-core/dist/preload.js +44 -0
- package/dist/packages/tripmap-core/dist/theme.js +21 -21
- package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl.js +2006 -1791
- package/dist/{node_modules → packages/tripmap-core/node_modules}/pmtiles/dist/esm/index.js +1 -1
- package/package.json +8 -3
- package/src/core/client-types.ts +13 -2
- package/src/core/client.ts +40 -5
- package/src/core/consultation-adapter.ts +408 -0
- package/src/core/consultations.ts +224 -0
- package/src/core/errors.ts +145 -0
- package/src/core/index.ts +68 -0
- package/src/core/queries.ts +167 -3
- package/src/core/review/format.ts +138 -0
- package/src/core/review/index.ts +22 -0
- package/src/core/review/types.ts +168 -0
- package/src/core/server-only.ts +20 -0
- package/src/core/types.ts +337 -0
- /package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl-shared.js +0 -0
|
@@ -1,255 +1,448 @@
|
|
|
1
|
-
import { Map as
|
|
2
|
-
import { Protocol as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Map as be, NavigationControl as we, FullscreenControl as ve, GeolocateControl as xe, Popup as Ce, setWorkerUrl as Ee, Marker as Le } from "../node_modules/maplibre-gl/dist/maplibre-gl.js";
|
|
2
|
+
import { Protocol as ke } from "../node_modules/pmtiles/dist/esm/index.js";
|
|
3
|
+
import { ImagePreloader as Me } from "./preload.js";
|
|
4
|
+
import { mapyRouteUrl as Ne, googleMapsRouteUrl as _e, buildGpx as Se, gpxFileName as Ae } from "./export.js";
|
|
5
|
+
import { Lightbox as De } from "./lightbox.js";
|
|
6
|
+
import { DetailPanel as Re } from "./detail.js";
|
|
7
|
+
import { headingRotation as Pe } from "./heading.js";
|
|
8
|
+
import Te from "./generated/maplibre-worker.bundle.js";
|
|
9
|
+
import { TripMapAttributionControl as Fe, buildAttributions as Ue } from "./attribution.js";
|
|
10
|
+
import { injectTripMapCss as Ie } from "./css.js";
|
|
11
|
+
import { Filmstrip as ze } from "./filmstrip.js";
|
|
12
|
+
import { computeFramingBounds as Be } from "./framing.js";
|
|
13
|
+
import { buildLineFeature as Oe, LINE_LAYER_PAINT as He, LINE_LAYER_LAYOUT as Ge } from "./line.js";
|
|
14
|
+
import { createPopupContent as qe, setMarkerActive as W, MarkerPool as $e, createClusterMarkerEl as je, createNodeMarkerEl as We } from "./markers.js";
|
|
15
|
+
import { formatTimeHHMM as Ze, lineNodes as Ve } from "./nodes.js";
|
|
16
|
+
import { startPlayback as Ye } from "./playback.js";
|
|
17
|
+
import { watchSystemTheme as Je, resolveTheme as Z, carryTripMapLayers as Ke } from "./theme.js";
|
|
18
|
+
import { Mn as Qe } from "../node_modules/maplibre-gl/dist/maplibre-gl-shared.js";
|
|
19
|
+
const w = "tripmap-nodes", V = "tripmap-line", Xe = "tripmap-line-layer", et = "tripmap-nodes-anchor", tt = 17;
|
|
20
|
+
let ae = !1;
|
|
21
|
+
function rt() {
|
|
22
|
+
if (ae) return;
|
|
23
|
+
const i = new ke();
|
|
24
|
+
Qe("pmtiles", i.tile), ae = !0;
|
|
20
25
|
}
|
|
21
|
-
let
|
|
22
|
-
function
|
|
23
|
-
if (!
|
|
24
|
-
|
|
26
|
+
let le = !1;
|
|
27
|
+
function nt() {
|
|
28
|
+
if (!le) {
|
|
29
|
+
le = !0;
|
|
25
30
|
try {
|
|
26
|
-
const i = new Blob([
|
|
27
|
-
|
|
31
|
+
const i = new Blob([Te], { type: "text/javascript" });
|
|
32
|
+
Ee(URL.createObjectURL(i));
|
|
28
33
|
} catch {
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
|
-
function
|
|
37
|
+
function ie(i) {
|
|
33
38
|
return {
|
|
34
39
|
type: "FeatureCollection",
|
|
35
|
-
features: i.map((
|
|
40
|
+
features: i.map((r) => ({
|
|
36
41
|
type: "Feature",
|
|
37
|
-
geometry: { type: "Point", coordinates: [
|
|
38
|
-
properties: { id:
|
|
42
|
+
geometry: { type: "Point", coordinates: [r.lng, r.lat] },
|
|
43
|
+
properties: { id: r.id }
|
|
39
44
|
}))
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
container:
|
|
49
|
-
style:
|
|
50
|
-
center:
|
|
51
|
-
zoom:
|
|
52
|
-
attributionControl: !1
|
|
47
|
+
function Ct(i, r) {
|
|
48
|
+
nt(), rt(), Ie(i.ownerDocument), i.classList.add("tripmap");
|
|
49
|
+
const f = i.ownerDocument.createElement("div");
|
|
50
|
+
f.className = "tripmap__map", i.appendChild(f);
|
|
51
|
+
let d = [], _ = /* @__PURE__ */ new Map(), S = null, p = !1, A = !1, Y = !1, x = null, P = null, B = !1;
|
|
52
|
+
const J = (e) => Z(e) === "dark" ? r.darkStyleUrl : r.styleUrl, l = new be({
|
|
53
|
+
container: f,
|
|
54
|
+
style: J(r.theme),
|
|
55
|
+
center: r.initialView?.center ?? [0, 0],
|
|
56
|
+
zoom: r.initialView?.zoom ?? 1,
|
|
57
|
+
attributionControl: !1,
|
|
58
|
+
locale: {
|
|
59
|
+
"FullscreenControl.Enter": r.labels.fullscreen,
|
|
60
|
+
"FullscreenControl.Exit": r.labels.exitFullscreen,
|
|
61
|
+
"GeolocateControl.FindMyLocation": r.labels.findMyLocation,
|
|
62
|
+
"GeolocateControl.LocationNotAvailable": r.labels.locationNotAvailable
|
|
63
|
+
}
|
|
53
64
|
});
|
|
54
|
-
|
|
55
|
-
new
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
if (l.addControl(new Fe(Ue(r.extraAttribution)), "bottom-right"), l.addControl(new we({ showCompass: !1 }), "top-right"), r.showFullscreen && l.addControl(new ve({ container: i }), "top-right"), r.showGeolocate) {
|
|
66
|
+
const e = new xe({
|
|
67
|
+
trackUserLocation: !0,
|
|
68
|
+
showUserLocation: !0,
|
|
69
|
+
showAccuracyCircle: !0,
|
|
70
|
+
positionOptions: { enableHighAccuracy: !0, timeout: 8e3 },
|
|
71
|
+
// Cap the zoom: a 5 m fix would otherwise slam the camera to z20 and
|
|
72
|
+
// lose the route the reader is trying to follow.
|
|
73
|
+
fitBoundsOptions: { maxZoom: 16 }
|
|
74
|
+
});
|
|
75
|
+
l.addControl(e, "top-right");
|
|
76
|
+
let o = null;
|
|
77
|
+
const t = () => {
|
|
78
|
+
const n = f.querySelector(".maplibregl-user-location-dot");
|
|
79
|
+
if (!n) return;
|
|
80
|
+
let a = n.querySelector(".tripmap-heading");
|
|
81
|
+
a || (a = i.ownerDocument.createElement("div"), a.className = "tripmap-heading", a.setAttribute("aria-hidden", "true"), n.appendChild(a));
|
|
82
|
+
const s = Pe(o, l.getBearing());
|
|
83
|
+
if (s == null) {
|
|
84
|
+
n.classList.remove("tripmap-user--heading");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
n.style.setProperty("--tripmap-heading", `${s}deg`), n.classList.add("tripmap-user--heading");
|
|
88
|
+
};
|
|
89
|
+
e.on("geolocate", (n) => {
|
|
90
|
+
const a = n?.coords?.heading;
|
|
91
|
+
o = typeof a == "number" && Number.isFinite(a) ? a : null, t();
|
|
92
|
+
}), e.on("trackuserlocationend", () => {
|
|
93
|
+
o = null;
|
|
94
|
+
}), l.on("rotate", t);
|
|
95
|
+
}
|
|
96
|
+
const T = r.watermark ? (() => {
|
|
97
|
+
const e = i.ownerDocument.createElement("img");
|
|
98
|
+
return e.className = "tripmap__watermark", e.alt = r.watermark.alt ?? "", e.decoding = "async", r.watermark.height && (e.style.height = `${r.watermark.height}px`), f.appendChild(e), e;
|
|
99
|
+
})() : null;
|
|
100
|
+
function O() {
|
|
101
|
+
const e = r.watermark;
|
|
102
|
+
if (!T || !e) return;
|
|
103
|
+
const t = i.dataset.tripmapTheme === "dark" && e.darkSrc || e.src;
|
|
104
|
+
T.getAttribute("src") !== t && T.setAttribute("src", t), T.hidden = i.ownerDocument.fullscreenElement !== i;
|
|
105
|
+
}
|
|
106
|
+
const H = i.ownerDocument, K = () => {
|
|
107
|
+
p || (l.resize(), G(), N(), O());
|
|
108
|
+
};
|
|
109
|
+
H.addEventListener("fullscreenchange", K);
|
|
110
|
+
function G() {
|
|
111
|
+
const e = f.clientHeight || 0, o = e > 0 ? Math.max(96, Math.min(180, Math.round(e * 0.4))) : 180;
|
|
112
|
+
i.style.setProperty("--tripmap-popup-img-max", `${o}px`), e > 0 && i.style.setProperty("--tripmap-map-h", `${e}px`);
|
|
113
|
+
}
|
|
114
|
+
G(), l.on("resize", G);
|
|
115
|
+
const D = new Me(H);
|
|
116
|
+
typeof requestAnimationFrame == "function" && requestAnimationFrame(() => {
|
|
117
|
+
p || l.resize();
|
|
118
|
+
}), l.on("error", (e) => {
|
|
119
|
+
r.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
|
|
63
120
|
});
|
|
64
|
-
const
|
|
65
|
-
mount: (e,
|
|
66
|
-
move: (e,
|
|
67
|
-
e.setLngLat(
|
|
121
|
+
const F = new $e({
|
|
122
|
+
mount: (e, o) => new Le({ element: e }).setLngLat(o).addTo(l),
|
|
123
|
+
move: (e, o) => {
|
|
124
|
+
e.setLngLat(o);
|
|
68
125
|
},
|
|
69
126
|
unmount: (e) => e.remove()
|
|
70
|
-
});
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
formatTime:
|
|
127
|
+
}), U = r.showTime !== !1 ? Ze : () => "";
|
|
128
|
+
let C = null;
|
|
129
|
+
r.showFilmstrip && (C = new ze(i, {
|
|
130
|
+
formatTime: U,
|
|
74
131
|
onSelect: (e) => {
|
|
75
|
-
|
|
132
|
+
M(e.id, { fly: !0 }), z(e);
|
|
76
133
|
}
|
|
77
134
|
}));
|
|
135
|
+
let q = null, I = null;
|
|
136
|
+
const Q = new De(
|
|
137
|
+
i,
|
|
138
|
+
{ close: r.labels.lightboxClose, prev: r.labels.lightboxPrev, next: r.labels.lightboxNext },
|
|
139
|
+
{
|
|
140
|
+
formatTime: U,
|
|
141
|
+
preload: (e) => {
|
|
142
|
+
D.preload(e);
|
|
143
|
+
},
|
|
144
|
+
onChange: (e) => {
|
|
145
|
+
I = e, e.id !== S && M(e.id, { fly: !1 });
|
|
146
|
+
},
|
|
147
|
+
onClose: () => {
|
|
148
|
+
const e = I;
|
|
149
|
+
I = null, e && e.id !== q && !p && z(e), q = null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
function X(e) {
|
|
154
|
+
q = e.id, I = e, Q.open(d, e.id);
|
|
155
|
+
}
|
|
156
|
+
let ee = !1;
|
|
157
|
+
const se = !r.detailHost, E = r.detail === "panel" ? new Re(
|
|
158
|
+
r.detailHost ?? i,
|
|
159
|
+
{
|
|
160
|
+
formatTime: U,
|
|
161
|
+
onImageClick: X,
|
|
162
|
+
takePreloaded: (e) => D.take(e)
|
|
163
|
+
},
|
|
164
|
+
{ zoomImage: r.labels.zoomImage }
|
|
165
|
+
) : null;
|
|
166
|
+
function z(e) {
|
|
167
|
+
E ? E.show(e) : de(e);
|
|
168
|
+
}
|
|
169
|
+
function ce() {
|
|
170
|
+
if (!E || !se || ee) return;
|
|
171
|
+
const e = i.getBoundingClientRect().height;
|
|
172
|
+
if (e <= 0) return;
|
|
173
|
+
ee = !0;
|
|
174
|
+
const o = C ? C.element.getBoundingClientRect().height : 0;
|
|
175
|
+
i.classList.add("tripmap--panel"), i.style.height = "auto", f.style.flex = "0 0 auto", f.style.height = `${Math.max(180, Math.round(e - o - (o > 0 ? 8 : 0)))}px`, l.resize();
|
|
176
|
+
}
|
|
177
|
+
const L = i.ownerDocument.createElement("div");
|
|
178
|
+
L.className = "tripmap__controls";
|
|
179
|
+
const g = i.ownerDocument.createElement("button");
|
|
180
|
+
g.type = "button", g.className = "tripmap__ctrl tripmap__play", g.textContent = r.labels.play, g.addEventListener("click", () => {
|
|
181
|
+
x ? x.stop() : oe();
|
|
182
|
+
}), L.appendChild(g);
|
|
78
183
|
const v = i.ownerDocument.createElement("div");
|
|
79
|
-
v.className = "
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
184
|
+
v.className = "tripmap__export";
|
|
185
|
+
const y = i.ownerDocument.createElement("button");
|
|
186
|
+
y.type = "button", y.className = "tripmap__ctrl tripmap__export-btn", y.textContent = r.labels.export, y.setAttribute("aria-haspopup", "menu"), y.setAttribute("aria-expanded", "false");
|
|
187
|
+
const h = i.ownerDocument.createElement("div");
|
|
188
|
+
h.className = "tripmap__menu", h.setAttribute("role", "menu"), h.hidden = !0, v.appendChild(y), v.appendChild(h), L.appendChild(v);
|
|
189
|
+
const te = (e) => {
|
|
190
|
+
v.contains(e.target) || k();
|
|
191
|
+
}, re = (e) => {
|
|
192
|
+
e.key === "Escape" && k();
|
|
193
|
+
};
|
|
194
|
+
function k() {
|
|
195
|
+
h.hidden || (h.hidden = !0, y.setAttribute("aria-expanded", "false"), i.ownerDocument.removeEventListener("pointerdown", te, !0), i.ownerDocument.removeEventListener("keydown", re));
|
|
196
|
+
}
|
|
197
|
+
function ue() {
|
|
198
|
+
const e = i.ownerDocument;
|
|
199
|
+
h.textContent = "";
|
|
200
|
+
const o = (s, c, u) => {
|
|
201
|
+
const m = e.createElement(s);
|
|
202
|
+
if (m.className = "tripmap__menu-item", m.setAttribute("role", "menuitem"), m.appendChild(e.createTextNode(c)), u) {
|
|
203
|
+
const b = e.createElement("small");
|
|
204
|
+
b.textContent = u, m.appendChild(b);
|
|
205
|
+
}
|
|
206
|
+
return h.appendChild(m), m;
|
|
207
|
+
}, t = o("button", r.labels.exportGpx, r.labels.exportGpxHint);
|
|
208
|
+
t.type = "button", t.addEventListener("click", () => {
|
|
209
|
+
k(), me();
|
|
210
|
+
});
|
|
211
|
+
const n = e.defaultView?.matchMedia?.("(pointer: coarse)").matches ?? !1, a = [
|
|
212
|
+
[r.labels.openInMapy, Ne(d)],
|
|
213
|
+
[r.labels.openInGoogleMaps, _e(d, { maxWaypoints: n ? 3 : 9 })]
|
|
214
|
+
];
|
|
215
|
+
for (const [s, c] of a) {
|
|
216
|
+
if (!c) continue;
|
|
217
|
+
const u = o("a", s);
|
|
218
|
+
u.href = c, u.target = "_blank", u.rel = "noopener", u.addEventListener("click", () => k());
|
|
219
|
+
}
|
|
220
|
+
h.hidden = !1, y.setAttribute("aria-expanded", "true"), e.addEventListener("pointerdown", te, !0), e.addEventListener("keydown", re);
|
|
221
|
+
}
|
|
222
|
+
y.addEventListener("click", () => {
|
|
223
|
+
h.hidden ? ue() : k();
|
|
224
|
+
});
|
|
225
|
+
async function me() {
|
|
226
|
+
const e = Se(d, { name: r.title });
|
|
227
|
+
if (!e) return;
|
|
228
|
+
const o = i.ownerDocument, t = o.defaultView, n = Ae(r.title), a = "application/gpx+xml";
|
|
229
|
+
if (t && typeof t.File == "function" && t.navigator?.canShare) {
|
|
230
|
+
const m = new t.File([e], n, { type: a });
|
|
231
|
+
if (t.navigator.canShare({ files: [m] }))
|
|
232
|
+
try {
|
|
233
|
+
await t.navigator.share({ files: [m], title: r.title });
|
|
234
|
+
return;
|
|
235
|
+
} catch (b) {
|
|
236
|
+
if (b?.name === "AbortError") return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const s = new Blob([e], { type: a }), c = URL.createObjectURL(s), u = o.createElement("a");
|
|
240
|
+
u.href = c, u.download = n, u.rel = "noopener", u.style.display = "none", o.body.appendChild(u), u.click(), u.remove(), setTimeout(() => URL.revokeObjectURL(c), 1e4);
|
|
241
|
+
}
|
|
242
|
+
f.appendChild(L), L.style.display = "none";
|
|
243
|
+
function de(e) {
|
|
244
|
+
P?.remove();
|
|
245
|
+
const o = e.imageUrl || e.thumbnailUrl, t = o ? D.take(o) : null, n = qe(e, U, {
|
|
246
|
+
image: t ?? void 0,
|
|
247
|
+
onImageClick: X,
|
|
248
|
+
zoomLabel: r.labels.zoomImage
|
|
249
|
+
}), a = new Ce({ offset: 26, maxWidth: "280px", className: "tripmap-popup-anchor" }).setLngLat([e.lng, e.lat]).setDOMContent(n).addTo(l);
|
|
250
|
+
P = a;
|
|
251
|
+
const s = () => {
|
|
252
|
+
!p && P === a && pe(a);
|
|
253
|
+
};
|
|
254
|
+
requestAnimationFrame(s);
|
|
255
|
+
const c = n.querySelector("img");
|
|
256
|
+
c && !c.complete && c.addEventListener("load", s, { once: !0 });
|
|
257
|
+
}
|
|
258
|
+
function pe(e) {
|
|
259
|
+
const o = e.getElement();
|
|
260
|
+
if (!o) return;
|
|
261
|
+
const t = o.getBoundingClientRect(), n = f.getBoundingClientRect();
|
|
262
|
+
if (t.width === 0 || n.width === 0) return;
|
|
263
|
+
const a = 8;
|
|
264
|
+
let s = 0, c = 0;
|
|
265
|
+
t.width > n.width - 2 * a ? s = t.left - (n.left + a) : t.right > n.right - a ? s = t.right - (n.right - a) : t.left < n.left + a && (s = t.left - (n.left + a)), t.height > n.height - 2 * a ? c = t.top - (n.top + a) : t.bottom > n.bottom - a ? c = t.bottom - (n.bottom - a) : t.top < n.top + a && (c = t.top - (n.top + a)), !(Math.abs(s) < 1 && Math.abs(c) < 1) && l.panBy([s, c], { duration: 300, essential: !0 });
|
|
266
|
+
}
|
|
267
|
+
function M(e, o = {}) {
|
|
268
|
+
if (!p) {
|
|
269
|
+
if (S && W(F.get(`n:${S}`), !1), S = e, e && W(F.get(`n:${e}`), !0), C?.setActive(e), e && o.fly) {
|
|
270
|
+
const t = _.get(e);
|
|
271
|
+
t && l.flyTo({
|
|
272
|
+
center: [t.lng, t.lat],
|
|
273
|
+
zoom: Math.max(l.getZoom(), 15),
|
|
94
274
|
essential: !0
|
|
95
275
|
});
|
|
96
276
|
}
|
|
97
|
-
|
|
277
|
+
r.events.onActiveNodeChange?.(e);
|
|
98
278
|
}
|
|
99
279
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
280
|
+
function N() {
|
|
281
|
+
B || p || (B = !0, requestAnimationFrame(() => {
|
|
282
|
+
B = !1, fe();
|
|
103
283
|
}));
|
|
104
284
|
}
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
107
|
-
const e =
|
|
108
|
-
for (const
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const s =
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
key:
|
|
285
|
+
function fe() {
|
|
286
|
+
if (p || !A || !l.getSource(w)) return;
|
|
287
|
+
const e = l.querySourceFeatures(w), o = [], t = /* @__PURE__ */ new Set();
|
|
288
|
+
for (const n of e) {
|
|
289
|
+
const a = n.geometry;
|
|
290
|
+
if (a.type !== "Point") continue;
|
|
291
|
+
const s = a.coordinates, c = n.properties;
|
|
292
|
+
if (c.cluster) {
|
|
293
|
+
const u = c.cluster_id, m = `c:${u}`;
|
|
294
|
+
if (t.has(m)) continue;
|
|
295
|
+
t.add(m);
|
|
296
|
+
const b = c.point_count ?? 0;
|
|
297
|
+
o.push({
|
|
298
|
+
key: m,
|
|
119
299
|
lngLat: s,
|
|
120
300
|
createEl: () => {
|
|
121
|
-
const
|
|
122
|
-
return
|
|
301
|
+
const R = je(b, void 0, () => ge(u, s));
|
|
302
|
+
return he(R, u), R;
|
|
123
303
|
}
|
|
124
304
|
});
|
|
125
305
|
} else {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
131
|
-
|
|
132
|
-
key:
|
|
306
|
+
const u = c.id, m = `n:${u}`;
|
|
307
|
+
if (t.has(m)) continue;
|
|
308
|
+
t.add(m);
|
|
309
|
+
const b = _.get(u);
|
|
310
|
+
if (!b) continue;
|
|
311
|
+
o.push({
|
|
312
|
+
key: m,
|
|
133
313
|
lngLat: s,
|
|
134
314
|
createEl: () => {
|
|
135
|
-
const
|
|
136
|
-
|
|
315
|
+
const R = We(b, (j) => {
|
|
316
|
+
M(j.id, { fly: !1 }), z(j), r.events.onNodeClick?.(j);
|
|
137
317
|
});
|
|
138
|
-
return
|
|
318
|
+
return u === S && W(R, !0), R;
|
|
139
319
|
}
|
|
140
320
|
});
|
|
141
321
|
}
|
|
142
322
|
}
|
|
143
|
-
|
|
323
|
+
F.sync(o);
|
|
144
324
|
}
|
|
145
|
-
async function
|
|
325
|
+
async function he(e, o) {
|
|
146
326
|
try {
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
const a = (await
|
|
150
|
-
if (!
|
|
151
|
-
const
|
|
152
|
-
|
|
327
|
+
const t = l.getSource(w);
|
|
328
|
+
if (!t) return;
|
|
329
|
+
const a = (await t.getClusterLeaves(o, 1, 0))?.[0]?.properties?.id, s = a ? _.get(a)?.thumbnailUrl : void 0;
|
|
330
|
+
if (!s || !e.isConnected) return;
|
|
331
|
+
const c = e.ownerDocument.createElement("img");
|
|
332
|
+
c.src = s, c.alt = "", c.loading = "lazy", c.decoding = "async", c.draggable = !1, c.className = "tripmap-marker__img", e.prepend(c);
|
|
153
333
|
} catch {
|
|
154
334
|
}
|
|
155
335
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
336
|
+
function ge(e, o) {
|
|
337
|
+
const t = l.getSource(w);
|
|
338
|
+
t && (t.getClusterExpansionZoom(e).then((n) => {
|
|
339
|
+
p || l.easeTo({ center: o, zoom: Math.min(n + 0.5, 19) });
|
|
160
340
|
}).catch(() => {
|
|
161
|
-
})
|
|
341
|
+
}), t.getClusterLeaves(e, 1, 0).then((n) => {
|
|
342
|
+
const a = n?.[0]?.properties?.id, s = a ? _.get(a) : void 0;
|
|
343
|
+
p || !s || (M(s.id, { fly: !1 }), E && E.show(s));
|
|
344
|
+
}).catch(() => {
|
|
345
|
+
}));
|
|
162
346
|
}
|
|
163
|
-
function
|
|
164
|
-
if (
|
|
165
|
-
const e =
|
|
166
|
-
e ? e.setData(
|
|
347
|
+
function $() {
|
|
348
|
+
if (p || !A) return;
|
|
349
|
+
const e = l.getSource(w);
|
|
350
|
+
e ? e.setData(ie(d)) : (l.addSource(w, {
|
|
167
351
|
type: "geojson",
|
|
168
|
-
data:
|
|
169
|
-
cluster:
|
|
170
|
-
clusterRadius:
|
|
171
|
-
clusterMaxZoom:
|
|
172
|
-
}),
|
|
173
|
-
id:
|
|
352
|
+
data: ie(d),
|
|
353
|
+
cluster: r.cluster,
|
|
354
|
+
clusterRadius: r.clusterRadius,
|
|
355
|
+
clusterMaxZoom: tt
|
|
356
|
+
}), l.addLayer({
|
|
357
|
+
id: et,
|
|
174
358
|
type: "circle",
|
|
175
|
-
source:
|
|
359
|
+
source: w,
|
|
176
360
|
paint: { "circle-radius": 0, "circle-opacity": 0 }
|
|
177
361
|
}));
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
id:
|
|
362
|
+
const o = r.showLine ? Oe(d) : null, t = l.getSource(V), n = o ?? { type: "FeatureCollection", features: [] };
|
|
363
|
+
t ? t.setData(n) : o && (l.addSource(V, { type: "geojson", data: n, lineMetrics: !0 }), l.addLayer({
|
|
364
|
+
id: Xe,
|
|
181
365
|
type: "line",
|
|
182
|
-
source:
|
|
183
|
-
layout:
|
|
184
|
-
paint:
|
|
185
|
-
}))
|
|
186
|
-
|
|
187
|
-
|
|
366
|
+
source: V,
|
|
367
|
+
layout: Ge,
|
|
368
|
+
paint: He
|
|
369
|
+
}));
|
|
370
|
+
const a = Ve(d).length, s = a >= 2;
|
|
371
|
+
if (g.hidden = !(r.showPlayback && s), v.hidden = !(r.showExport && s), L.style.display = g.hidden && v.hidden ? "none" : "", i.dataset.tripmapNodes = String(d.length), i.dataset.tripmapRoute = String(a), i.dataset.tripmapLine = String(!!o), i.dataset.tripmapTheme = Z(r.theme), O(), C?.setNodes(d), d.length > 0 && ce(), !Y && d.length > 0 && !r.initialView?.center) {
|
|
372
|
+
const c = Be(d);
|
|
373
|
+
c && (l.fitBounds(c, { padding: 56, maxZoom: 15, duration: 0 }), Y = !0);
|
|
188
374
|
}
|
|
189
|
-
|
|
375
|
+
N();
|
|
190
376
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}),
|
|
194
|
-
e.sourceId ===
|
|
377
|
+
l.on("load", () => {
|
|
378
|
+
A = !0, $(), r.events.onReady?.();
|
|
379
|
+
}), l.on("moveend", N), l.on("zoomend", N), l.on("idle", N), l.on("sourcedata", (e) => {
|
|
380
|
+
e.sourceId === w && e.isSourceLoaded && N();
|
|
195
381
|
});
|
|
196
|
-
const
|
|
197
|
-
|
|
382
|
+
const ye = r.theme === "auto" ? Je(() => {
|
|
383
|
+
p || ne("auto");
|
|
198
384
|
}) : () => {
|
|
199
385
|
};
|
|
200
|
-
function
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
transformStyle: (
|
|
205
|
-
}),
|
|
206
|
-
|
|
386
|
+
function ne(e) {
|
|
387
|
+
if (p) return;
|
|
388
|
+
const o = J(e);
|
|
389
|
+
i.dataset.tripmapTheme = Z(e), O(), A = !1, l.setStyle(o, {
|
|
390
|
+
transformStyle: (t, n) => Ke(t, n)
|
|
391
|
+
}), l.once("styledata", () => {
|
|
392
|
+
A = !0, $();
|
|
207
393
|
});
|
|
208
394
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
395
|
+
function oe(e = {}) {
|
|
396
|
+
x?.stop(), g.textContent = r.labels.stop;
|
|
397
|
+
const o = Ye(
|
|
398
|
+
d,
|
|
213
399
|
{
|
|
214
|
-
flyTo: (
|
|
215
|
-
|
|
216
|
-
center: [
|
|
217
|
-
zoom: Math.max(
|
|
400
|
+
flyTo: (t) => new Promise((n) => {
|
|
401
|
+
l.once("moveend", () => n()), l.flyTo({
|
|
402
|
+
center: [t.lng, t.lat],
|
|
403
|
+
zoom: Math.max(l.getZoom(), 14),
|
|
218
404
|
speed: 0.9,
|
|
219
|
-
essential: !0
|
|
405
|
+
essential: !0,
|
|
406
|
+
// Land the node in the upper third so its popup (which opens
|
|
407
|
+
// below it) has two thirds of the viewport instead of one half.
|
|
408
|
+
offset: [0, -Math.round((f.clientHeight || 0) * 0.18)]
|
|
220
409
|
});
|
|
221
410
|
}),
|
|
222
|
-
showNode: (
|
|
223
|
-
|
|
411
|
+
showNode: (t) => {
|
|
412
|
+
M(t.id, { fly: !1 }), z(t);
|
|
413
|
+
},
|
|
414
|
+
preload: (t) => {
|
|
415
|
+
const n = t.imageUrl || t.thumbnailUrl;
|
|
416
|
+
return n ? D.preload(n) : void 0;
|
|
224
417
|
},
|
|
225
418
|
onDone: () => {
|
|
226
|
-
|
|
419
|
+
x = null, g.textContent = r.labels.play;
|
|
227
420
|
},
|
|
228
|
-
onUserInterrupt: (
|
|
229
|
-
const
|
|
230
|
-
return
|
|
421
|
+
onUserInterrupt: (t) => {
|
|
422
|
+
const n = l.getCanvasContainer(), a = ["pointerdown", "wheel"];
|
|
423
|
+
return a.forEach((s) => n.addEventListener(s, t, { passive: !0 })), () => a.forEach((s) => n.removeEventListener(s, t));
|
|
231
424
|
}
|
|
232
425
|
},
|
|
233
426
|
e
|
|
234
427
|
);
|
|
235
|
-
return
|
|
428
|
+
return x = o, o;
|
|
236
429
|
}
|
|
237
430
|
return {
|
|
238
|
-
_map:
|
|
431
|
+
_map: l,
|
|
239
432
|
setNodes(e) {
|
|
240
|
-
|
|
433
|
+
d = e, _ = new Map(e.map((o) => [o.id, o])), $();
|
|
241
434
|
},
|
|
242
|
-
setActiveNode:
|
|
243
|
-
playSequence:
|
|
244
|
-
setTheme:
|
|
435
|
+
setActiveNode: M,
|
|
436
|
+
playSequence: oe,
|
|
437
|
+
setTheme: ne,
|
|
245
438
|
resize() {
|
|
246
|
-
|
|
439
|
+
p || l.resize();
|
|
247
440
|
},
|
|
248
441
|
destroy() {
|
|
249
|
-
|
|
442
|
+
p || (p = !0, x?.stop(), ye(), H.removeEventListener("fullscreenchange", K), k(), Q.destroy(), E?.destroy(), D.clear(), P?.remove(), F.clear(), C?.destroy(), l.remove(), f.remove(), i.classList.remove("tripmap"));
|
|
250
443
|
}
|
|
251
444
|
};
|
|
252
445
|
}
|
|
253
446
|
export {
|
|
254
|
-
|
|
447
|
+
Ct as createEngine
|
|
255
448
|
};
|