@blogmcp/sdk 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/queries.d.ts +2 -2
- package/dist/core/queries.js +10 -4
- package/dist/core/types.d.ts +9 -0
- package/dist/node_modules/fflate/esm/browser.js +284 -0
- package/dist/node_modules/maplibre-gl/dist/maplibre-gl-shared.js +11606 -0
- package/dist/node_modules/maplibre-gl/dist/maplibre-gl.js +12289 -0
- package/dist/node_modules/pmtiles/dist/esm/index.js +441 -0
- package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +31 -0
- package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +43 -0
- package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue2.js +4 -0
- package/dist/packages/mdx-render-vue/dist/registry.js +29 -22
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +169 -0
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue2.js +4 -0
- package/dist/packages/mdx-schema/dist/metadata/index.js +108 -6
- package/dist/packages/mdx-schema/dist/styles/index.js +29 -9
- package/dist/packages/mdx-schema/dist/tripmap.js +55 -0
- package/dist/packages/tripmap-core/dist/attribution.js +9 -0
- package/dist/packages/tripmap-core/dist/css.js +74 -0
- package/dist/packages/tripmap-core/dist/engine.js +255 -0
- package/dist/packages/tripmap-core/dist/filmstrip.js +46 -0
- package/dist/packages/tripmap-core/dist/framing.js +44 -0
- package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +4 -0
- package/dist/packages/tripmap-core/dist/index.js +90 -0
- package/dist/packages/tripmap-core/dist/line.js +34 -0
- package/dist/packages/tripmap-core/dist/markers.js +90 -0
- package/dist/packages/tripmap-core/dist/node_modules/maplibre-gl/dist/maplibre-gl.css.js +4 -0
- package/dist/packages/tripmap-core/dist/nodes.js +55 -0
- package/dist/packages/tripmap-core/dist/playback.js +25 -0
- package/dist/packages/tripmap-core/dist/theme.js +42 -0
- package/package.json +2 -2
- package/src/core/queries.ts +6 -0
- package/src/core/types.ts +9 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Map as W, AttributionControl as Q, NavigationControl as G, Popup as J, setWorkerUrl as K, Marker as X } from "../../../node_modules/maplibre-gl/dist/maplibre-gl.js";
|
|
2
|
+
import { Protocol as $ } from "../../../node_modules/pmtiles/dist/esm/index.js";
|
|
3
|
+
import ee from "./generated/maplibre-worker.bundle.js";
|
|
4
|
+
import { buildAttributions as te } from "./attribution.js";
|
|
5
|
+
import { injectTripMapCss as ne } from "./css.js";
|
|
6
|
+
import { Filmstrip as oe } from "./filmstrip.js";
|
|
7
|
+
import { computeFramingBounds as re } from "./framing.js";
|
|
8
|
+
import { buildLineFeature as ae, LINE_LAYER_PAINT as se, LINE_LAYER_LAYOUT as ie } from "./line.js";
|
|
9
|
+
import { createPopupContent as ce, setMarkerActive as P, MarkerPool as le, createClusterMarkerEl as me, createNodeMarkerEl as ue } from "./markers.js";
|
|
10
|
+
import { formatTimeHHMM as B, lineNodes as pe } from "./nodes.js";
|
|
11
|
+
import { startPlayback as de } from "./playback.js";
|
|
12
|
+
import { watchSystemTheme as fe, resolveTheme as ye, carryTripMapLayers as ge } from "./theme.js";
|
|
13
|
+
import { Mn as he } from "../../../node_modules/maplibre-gl/dist/maplibre-gl-shared.js";
|
|
14
|
+
const u = "tripmap-nodes", z = "tripmap-line", ve = "tripmap-line-layer", we = "tripmap-nodes-anchor", Le = 17;
|
|
15
|
+
let I = !1;
|
|
16
|
+
function Ce() {
|
|
17
|
+
if (I) return;
|
|
18
|
+
const i = new $();
|
|
19
|
+
he("pmtiles", i.tile), I = !0;
|
|
20
|
+
}
|
|
21
|
+
let Z = !1;
|
|
22
|
+
function Ee() {
|
|
23
|
+
if (!Z) {
|
|
24
|
+
Z = !0;
|
|
25
|
+
try {
|
|
26
|
+
const i = new Blob([ee], { type: "text/javascript" });
|
|
27
|
+
K(URL.createObjectURL(i));
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function R(i) {
|
|
33
|
+
return {
|
|
34
|
+
type: "FeatureCollection",
|
|
35
|
+
features: i.map((o) => ({
|
|
36
|
+
type: "Feature",
|
|
37
|
+
geometry: { type: "Point", coordinates: [o.lng, o.lat] },
|
|
38
|
+
properties: { id: o.id }
|
|
39
|
+
}))
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Ue(i, o) {
|
|
43
|
+
Ee(), Ce(), ne(i.ownerDocument), i.classList.add("tripmap");
|
|
44
|
+
const g = i.ownerDocument.createElement("div");
|
|
45
|
+
g.className = "tripmap__map", i.appendChild(g);
|
|
46
|
+
let m = [], C = /* @__PURE__ */ new Map(), E = null, c = !1, h = !1, D = !1, y = null, A = null, T = !1;
|
|
47
|
+
const U = (e) => ye(e) === "dark" ? o.darkStyleUrl : o.styleUrl, t = new W({
|
|
48
|
+
container: g,
|
|
49
|
+
style: U(o.theme),
|
|
50
|
+
center: o.initialView?.center ?? [0, 0],
|
|
51
|
+
zoom: o.initialView?.zoom ?? 1,
|
|
52
|
+
attributionControl: !1
|
|
53
|
+
});
|
|
54
|
+
t.addControl(
|
|
55
|
+
new Q({
|
|
56
|
+
compact: !1,
|
|
57
|
+
customAttribution: te(o.extraAttribution)
|
|
58
|
+
})
|
|
59
|
+
), t.addControl(new G({ showCompass: !1 }), "top-right"), typeof requestAnimationFrame == "function" && requestAnimationFrame(() => {
|
|
60
|
+
c || t.resize();
|
|
61
|
+
}), t.on("error", (e) => {
|
|
62
|
+
o.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
|
|
63
|
+
});
|
|
64
|
+
const b = new le({
|
|
65
|
+
mount: (e, r) => new X({ element: e }).setLngLat(r).addTo(t),
|
|
66
|
+
move: (e, r) => {
|
|
67
|
+
e.setLngLat(r);
|
|
68
|
+
},
|
|
69
|
+
unmount: (e) => e.remove()
|
|
70
|
+
});
|
|
71
|
+
let M = null;
|
|
72
|
+
o.showFilmstrip && (M = new oe(i, {
|
|
73
|
+
formatTime: B,
|
|
74
|
+
onSelect: (e) => {
|
|
75
|
+
N(e.id, { fly: !0 }), _(e);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
const v = i.ownerDocument.createElement("div");
|
|
79
|
+
v.className = "tripmap__controls";
|
|
80
|
+
const p = i.ownerDocument.createElement("button");
|
|
81
|
+
p.type = "button", p.className = "tripmap__play", p.textContent = o.labels.play, p.addEventListener("click", () => {
|
|
82
|
+
y ? y.stop() : q();
|
|
83
|
+
}), v.appendChild(p), g.appendChild(v), v.style.display = "none";
|
|
84
|
+
function _(e) {
|
|
85
|
+
A?.remove(), A = new J({ offset: 26, maxWidth: "280px", className: "tripmap-popup-anchor" }).setLngLat([e.lng, e.lat]).setDOMContent(ce(e, B)).addTo(t);
|
|
86
|
+
}
|
|
87
|
+
function N(e, r = {}) {
|
|
88
|
+
if (!c) {
|
|
89
|
+
if (E && P(b.get(`n:${E}`), !1), E = e, e && P(b.get(`n:${e}`), !0), M?.setActive(e), e && r.fly) {
|
|
90
|
+
const n = C.get(e);
|
|
91
|
+
n && t.flyTo({
|
|
92
|
+
center: [n.lng, n.lat],
|
|
93
|
+
zoom: Math.max(t.getZoom(), 15),
|
|
94
|
+
essential: !0
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
o.events.onActiveNodeChange?.(e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function w() {
|
|
101
|
+
T || c || (T = !0, requestAnimationFrame(() => {
|
|
102
|
+
T = !1, O();
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
function O() {
|
|
106
|
+
if (c || !h || !t.getSource(u)) return;
|
|
107
|
+
const e = t.querySourceFeatures(u), r = [], n = /* @__PURE__ */ new Set();
|
|
108
|
+
for (const a of e) {
|
|
109
|
+
const l = a.geometry;
|
|
110
|
+
if (l.type !== "Point") continue;
|
|
111
|
+
const s = l.coordinates, S = a.properties;
|
|
112
|
+
if (S.cluster) {
|
|
113
|
+
const d = S.cluster_id, f = `c:${d}`;
|
|
114
|
+
if (n.has(f)) continue;
|
|
115
|
+
n.add(f);
|
|
116
|
+
const k = S.point_count ?? 0;
|
|
117
|
+
r.push({
|
|
118
|
+
key: f,
|
|
119
|
+
lngLat: s,
|
|
120
|
+
createEl: () => {
|
|
121
|
+
const L = me(k, void 0, () => H(d, s));
|
|
122
|
+
return Y(L, d), L;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
const d = S.id, f = `n:${d}`;
|
|
127
|
+
if (n.has(f)) continue;
|
|
128
|
+
n.add(f);
|
|
129
|
+
const k = C.get(d);
|
|
130
|
+
if (!k) continue;
|
|
131
|
+
r.push({
|
|
132
|
+
key: f,
|
|
133
|
+
lngLat: s,
|
|
134
|
+
createEl: () => {
|
|
135
|
+
const L = ue(k, (F) => {
|
|
136
|
+
N(F.id, { fly: !1 }), _(F), o.events.onNodeClick?.(F);
|
|
137
|
+
});
|
|
138
|
+
return d === E && P(L, !0), L;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
b.sync(r);
|
|
144
|
+
}
|
|
145
|
+
async function Y(e, r) {
|
|
146
|
+
try {
|
|
147
|
+
const n = t.getSource(u);
|
|
148
|
+
if (!n) return;
|
|
149
|
+
const a = (await n.getClusterLeaves(r, 1, 0))?.[0]?.properties?.id, l = a ? C.get(a)?.thumbnailUrl : void 0;
|
|
150
|
+
if (!l || !e.isConnected) return;
|
|
151
|
+
const s = e.ownerDocument.createElement("img");
|
|
152
|
+
s.src = l, s.alt = "", s.loading = "lazy", s.decoding = "async", s.draggable = !1, s.className = "tripmap-marker__img", e.prepend(s);
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function H(e, r) {
|
|
157
|
+
const n = t.getSource(u);
|
|
158
|
+
n && n.getClusterExpansionZoom(e).then((a) => {
|
|
159
|
+
c || t.easeTo({ center: r, zoom: Math.min(a + 0.5, 19) });
|
|
160
|
+
}).catch(() => {
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function x() {
|
|
164
|
+
if (c || !h) return;
|
|
165
|
+
const e = t.getSource(u);
|
|
166
|
+
e ? e.setData(R(m)) : (t.addSource(u, {
|
|
167
|
+
type: "geojson",
|
|
168
|
+
data: R(m),
|
|
169
|
+
cluster: o.cluster,
|
|
170
|
+
clusterRadius: o.clusterRadius,
|
|
171
|
+
clusterMaxZoom: Le
|
|
172
|
+
}), t.addLayer({
|
|
173
|
+
id: we,
|
|
174
|
+
type: "circle",
|
|
175
|
+
source: u,
|
|
176
|
+
paint: { "circle-radius": 0, "circle-opacity": 0 }
|
|
177
|
+
}));
|
|
178
|
+
const r = o.showLine ? ae(m) : null, n = t.getSource(z), a = r ?? { type: "FeatureCollection", features: [] };
|
|
179
|
+
if (n ? n.setData(a) : r && (t.addSource(z, { type: "geojson", data: a, lineMetrics: !0 }), t.addLayer({
|
|
180
|
+
id: ve,
|
|
181
|
+
type: "line",
|
|
182
|
+
source: z,
|
|
183
|
+
layout: ie,
|
|
184
|
+
paint: se
|
|
185
|
+
})), v.style.display = o.showPlayback && pe(m).length >= 2 ? "" : "none", M?.setNodes(m), !D && m.length > 0 && !o.initialView?.center) {
|
|
186
|
+
const l = re(m);
|
|
187
|
+
l && (t.fitBounds(l, { padding: 56, maxZoom: 15, duration: 0 }), D = !0);
|
|
188
|
+
}
|
|
189
|
+
w();
|
|
190
|
+
}
|
|
191
|
+
t.on("load", () => {
|
|
192
|
+
h = !0, x(), o.events.onReady?.();
|
|
193
|
+
}), t.on("moveend", w), t.on("zoomend", w), t.on("idle", w), t.on("sourcedata", (e) => {
|
|
194
|
+
e.sourceId === u && e.isSourceLoaded && w();
|
|
195
|
+
});
|
|
196
|
+
const V = o.theme === "auto" ? fe(() => {
|
|
197
|
+
c || j("auto");
|
|
198
|
+
}) : () => {
|
|
199
|
+
};
|
|
200
|
+
function j(e) {
|
|
201
|
+
if (c) return;
|
|
202
|
+
const r = U(e);
|
|
203
|
+
h = !1, t.setStyle(r, {
|
|
204
|
+
transformStyle: (n, a) => ge(n, a)
|
|
205
|
+
}), t.once("styledata", () => {
|
|
206
|
+
h = !0, x();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function q(e = {}) {
|
|
210
|
+
y?.stop(), p.textContent = o.labels.stop;
|
|
211
|
+
const r = de(
|
|
212
|
+
m,
|
|
213
|
+
{
|
|
214
|
+
flyTo: (n) => new Promise((a) => {
|
|
215
|
+
t.once("moveend", () => a()), t.flyTo({
|
|
216
|
+
center: [n.lng, n.lat],
|
|
217
|
+
zoom: Math.max(t.getZoom(), 14),
|
|
218
|
+
speed: 0.9,
|
|
219
|
+
essential: !0
|
|
220
|
+
});
|
|
221
|
+
}),
|
|
222
|
+
showNode: (n) => {
|
|
223
|
+
N(n.id, { fly: !1 }), _(n);
|
|
224
|
+
},
|
|
225
|
+
onDone: () => {
|
|
226
|
+
y = null, p.textContent = o.labels.play;
|
|
227
|
+
},
|
|
228
|
+
onUserInterrupt: (n) => {
|
|
229
|
+
const a = t.getCanvasContainer(), l = ["pointerdown", "wheel"];
|
|
230
|
+
return l.forEach((s) => a.addEventListener(s, n, { passive: !0 })), () => l.forEach((s) => a.removeEventListener(s, n));
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
e
|
|
234
|
+
);
|
|
235
|
+
return y = r, r;
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
_map: t,
|
|
239
|
+
setNodes(e) {
|
|
240
|
+
m = e, C = new Map(e.map((r) => [r.id, r])), x();
|
|
241
|
+
},
|
|
242
|
+
setActiveNode: N,
|
|
243
|
+
playSequence: q,
|
|
244
|
+
setTheme: j,
|
|
245
|
+
resize() {
|
|
246
|
+
c || t.resize();
|
|
247
|
+
},
|
|
248
|
+
destroy() {
|
|
249
|
+
c || (c = !0, y?.stop(), V(), A?.remove(), b.clear(), M?.destroy(), t.remove(), g.remove(), i.classList.remove("tripmap"));
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
Ue as createEngine
|
|
255
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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);
|
|
5
|
+
}
|
|
6
|
+
root;
|
|
7
|
+
items = /* @__PURE__ */ new Map();
|
|
8
|
+
setNodes(s) {
|
|
9
|
+
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) {
|
|
13
|
+
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);
|
|
15
|
+
} else {
|
|
16
|
+
e.classList.add("tripmap-filmstrip__item--waypoint");
|
|
17
|
+
const t = document.createElement("span");
|
|
18
|
+
t.className = "tripmap-filmstrip__label", t.textContent = i.title || "·", e.appendChild(t);
|
|
19
|
+
}
|
|
20
|
+
if (i.capturedAt) {
|
|
21
|
+
const t = document.createElement("span");
|
|
22
|
+
t.className = "tripmap-filmstrip__time", t.textContent = this.callbacks.formatTime(i.capturedAt), e.appendChild(t);
|
|
23
|
+
}
|
|
24
|
+
e.addEventListener("click", () => this.callbacks.onSelect(i)), this.items.set(i.id, e), this.root.appendChild(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
setActive(s) {
|
|
28
|
+
for (const [i, e] of this.items) {
|
|
29
|
+
const t = i === s;
|
|
30
|
+
if (e.classList.toggle(a, t), e.setAttribute("aria-selected", t ? "true" : "false"), t && typeof e.scrollIntoView == "function")
|
|
31
|
+
try {
|
|
32
|
+
e.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
get element() {
|
|
38
|
+
return this.root;
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
this.root.remove(), this.items.clear();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
l as Filmstrip
|
|
46
|
+
};
|
|
@@ -0,0 +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;
|
|
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);
|
|
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);
|
|
13
|
+
return [
|
|
14
|
+
[t, n],
|
|
15
|
+
[a, o]
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
function f(l) {
|
|
19
|
+
return h({ lat: l[0][1], lng: l[0][0] }, { lat: l[1][1], lng: l[1][0] });
|
|
20
|
+
}
|
|
21
|
+
function M(l) {
|
|
22
|
+
const t = l.filter((r) => Number.isFinite(r.lat) && Number.isFinite(r.lng));
|
|
23
|
+
if (t.length === 0) return null;
|
|
24
|
+
if (t.length === 1) {
|
|
25
|
+
const r = t[0];
|
|
26
|
+
return [
|
|
27
|
+
[r.lng, r.lat],
|
|
28
|
+
[r.lng, r.lat]
|
|
29
|
+
];
|
|
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;
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
h as approxDistanceKm,
|
|
43
|
+
M as computeFramingBounds
|
|
44
|
+
};
|