@blogmcp/sdk 0.2.2 → 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/composables/useMdxParsing.js +330 -80
- 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/dist/react/KbMdxContent.d.ts +3 -3
- package/dist/react/KbMdxContent.js +60 -68
- package/dist/sdk.css +1 -1
- package/dist/vue/components/KbMdxContent.vue.js +2 -2
- package/dist/vue/components/KbMdxContent.vue2.js +50 -53
- package/package.json +3 -3
- package/src/core/queries.ts +6 -0
- package/src/core/types.ts +9 -0
- package/src/react/KbMdxContent.tsx +25 -39
- package/src/vue/components/KbMdxContent.vue +43 -40
|
@@ -400,16 +400,118 @@ Read this carefully.
|
|
|
400
400
|
</Tooltip>`,
|
|
401
401
|
addedIn: "0.1.0",
|
|
402
402
|
deprecated: []
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "TripMap",
|
|
406
|
+
description: "Interactive trip map built from photo GPS + capture time: thumbnail markers, chronological route line, synced photo filmstrip, fly-through playback. Without props it maps every geotagged media attached to or embedded in the article (auto mode); only media with exposed location (geoExposed) appear. In article previews it renders as a static photo strip + stop list — the live map loads on the published page.",
|
|
407
|
+
icon: "🗺",
|
|
408
|
+
category: "media",
|
|
409
|
+
aliases: ["tripmap", "map", "trip", "route", "travelmap", "hike"],
|
|
410
|
+
props: [
|
|
411
|
+
{
|
|
412
|
+
name: "slugs",
|
|
413
|
+
type: "string",
|
|
414
|
+
required: !1,
|
|
415
|
+
description: 'Comma-separated media slugs to map (e.g. "img-a,img-b"). Omit for AUTO mode: all geotagged media of the article, sorted by capture time.'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
name: "exclude",
|
|
419
|
+
type: "string",
|
|
420
|
+
required: !1,
|
|
421
|
+
description: "AUTO mode only: comma-separated media slugs to leave off the map."
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "nodes",
|
|
425
|
+
type: "array",
|
|
426
|
+
required: !1,
|
|
427
|
+
description: 'Hand-made nodes merged chronologically with the photos. STRICT JSON with quoted keys: [{"lat": 49.35, "lng": 16.31, "title": "Níhov, nádraží", "capturedAt": "2025-04-20T08:52:00"}]. Entries without capturedAt render as markers but stay off the route line. Unquoted keys silently break the prop.'
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: "height",
|
|
431
|
+
type: "string",
|
|
432
|
+
required: !1,
|
|
433
|
+
default: '"420px"',
|
|
434
|
+
description: "CSS height of the map box."
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "line",
|
|
438
|
+
type: "boolean",
|
|
439
|
+
required: !1,
|
|
440
|
+
default: "true",
|
|
441
|
+
description: "Draw the chronological route line between time-neighbouring nodes."
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "filmstrip",
|
|
445
|
+
type: "boolean",
|
|
446
|
+
required: !1,
|
|
447
|
+
default: "true",
|
|
448
|
+
description: "Show the synced photo strip below the map."
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "playback",
|
|
452
|
+
type: "boolean",
|
|
453
|
+
required: !1,
|
|
454
|
+
default: "true",
|
|
455
|
+
description: "Show the play button that flies the camera along the route."
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "cluster",
|
|
459
|
+
type: "boolean",
|
|
460
|
+
required: !1,
|
|
461
|
+
default: "true",
|
|
462
|
+
description: "Cluster nearby markers at low zoom."
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: "theme",
|
|
466
|
+
type: "string",
|
|
467
|
+
required: !1,
|
|
468
|
+
default: '"auto"',
|
|
469
|
+
description: 'Map color scheme; "auto" follows the reader’s system preference.',
|
|
470
|
+
enum: ["light", "dark", "auto"]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
name: "styleUrl",
|
|
474
|
+
type: "string",
|
|
475
|
+
required: !1,
|
|
476
|
+
description: "MapLibre style JSON URL override for this block (wins over tenant config)."
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "center",
|
|
480
|
+
type: "string",
|
|
481
|
+
required: !1,
|
|
482
|
+
description: 'Initial center as "lat,lng" — overrides smart framing; pair with zoom.'
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
name: "zoom",
|
|
486
|
+
type: "number",
|
|
487
|
+
required: !1,
|
|
488
|
+
description: "Initial zoom level — overrides smart framing; pair with center.",
|
|
489
|
+
numericRange: [1, 19]
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: "title",
|
|
493
|
+
type: "string",
|
|
494
|
+
required: !1,
|
|
495
|
+
description: "Accessible label for the map region."
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
hasChildren: !1,
|
|
499
|
+
selfClosing: !0,
|
|
500
|
+
defaultProps: 'title="Trasa výletu"',
|
|
501
|
+
defaultChildren: "",
|
|
502
|
+
example: '<TripMap title="Trasa údolím Libochovky" nodes={[{"lat": 49.3641, "lng": 16.3143, "title": "Níhov, nádraží", "capturedAt": "2025-04-20T08:52:00"}]} />',
|
|
503
|
+
addedIn: "0.3.0",
|
|
504
|
+
deprecated: []
|
|
403
505
|
}
|
|
404
|
-
],
|
|
405
|
-
function
|
|
406
|
-
return
|
|
506
|
+
], a = new Map(t.map((e) => [e.name, e]));
|
|
507
|
+
function i(e) {
|
|
508
|
+
return a.get(e);
|
|
407
509
|
}
|
|
408
|
-
function
|
|
510
|
+
function r() {
|
|
409
511
|
return t.map((e) => e.name);
|
|
410
512
|
}
|
|
411
513
|
export {
|
|
412
514
|
t as componentMetadata,
|
|
413
|
-
|
|
414
|
-
|
|
515
|
+
i as getComponentMetadata,
|
|
516
|
+
r as getComponentNames
|
|
415
517
|
};
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
const t = {
|
|
2
|
+
container: "my-6 flex flex-col gap-3 rounded-xl border border-gray-200 bg-white p-3",
|
|
3
|
+
head: "text-sm font-medium text-gray-700 m-0",
|
|
4
|
+
/**
|
|
5
|
+
* Sized wrapper that hosts BOTH the engine div and the facade overlay.
|
|
6
|
+
* The engine host must be a plain absolutely-positioned child that the
|
|
7
|
+
* framework never re-patches (a reactive class binding on the engine's
|
|
8
|
+
* own container would clobber the classes the engine adds to it).
|
|
9
|
+
*/
|
|
10
|
+
mapWrap: "relative w-full overflow-hidden rounded-lg",
|
|
11
|
+
mapOverlay: "absolute inset-0",
|
|
12
|
+
mapBox: "flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-gray-100",
|
|
13
|
+
mapHint: "text-sm text-gray-500",
|
|
14
|
+
strip: "flex gap-2 overflow-x-auto pb-1 m-0 p-0 list-none",
|
|
15
|
+
stripItem: "h-20 w-20 flex-none overflow-hidden rounded-lg bg-gray-100",
|
|
16
|
+
stripImg: "block h-full w-full object-cover",
|
|
17
|
+
stopList: "flex flex-col gap-0.5 text-sm text-gray-700 m-0 p-0 list-none",
|
|
18
|
+
stopTime: "mr-2 tabular-nums text-gray-500",
|
|
19
|
+
note: "text-xs text-gray-400 m-0"
|
|
20
|
+
}, a = {
|
|
2
21
|
base: "inline-flex items-center justify-center font-medium border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
3
22
|
size: {
|
|
4
23
|
sm: "px-2.5 py-1 text-sm rounded",
|
|
@@ -42,7 +61,7 @@ const t = {
|
|
|
42
61
|
error: "text-red-700 hover:underline border-transparent bg-transparent"
|
|
43
62
|
}
|
|
44
63
|
}
|
|
45
|
-
},
|
|
64
|
+
}, o = {
|
|
46
65
|
base: "inline-flex items-center px-2 py-0.5 text-xs font-medium border rounded-full",
|
|
47
66
|
variantColor: {
|
|
48
67
|
solid: {
|
|
@@ -67,7 +86,7 @@ const t = {
|
|
|
67
86
|
error: "border-red-500 text-red-700"
|
|
68
87
|
}
|
|
69
88
|
}
|
|
70
|
-
},
|
|
89
|
+
}, n = {
|
|
71
90
|
base: "mdx-alert flex gap-3 rounded-md border px-4 py-3 text-sm",
|
|
72
91
|
severity: {
|
|
73
92
|
info: { wrap: "bg-blue-50 border-blue-200 text-blue-900", icon: "lucide:info", iconClass: "text-blue-600" },
|
|
@@ -75,7 +94,7 @@ const t = {
|
|
|
75
94
|
warning: { wrap: "bg-amber-50 border-amber-200 text-amber-900", icon: "lucide:alert-triangle", iconClass: "text-amber-600" },
|
|
76
95
|
error: { wrap: "bg-red-50 border-red-200 text-red-900", icon: "lucide:alert-octagon", iconClass: "text-red-600" }
|
|
77
96
|
}
|
|
78
|
-
},
|
|
97
|
+
}, b = {
|
|
79
98
|
default: {
|
|
80
99
|
base: "callout my-6 p-4 rounded-lg border-l-4",
|
|
81
100
|
type: {
|
|
@@ -102,7 +121,7 @@ const t = {
|
|
|
102
121
|
danger: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
103
122
|
}
|
|
104
123
|
};
|
|
105
|
-
function
|
|
124
|
+
function l(e) {
|
|
106
125
|
const r = e.aspectRatio || "1";
|
|
107
126
|
return r === "auto" ? { tileStyle: {}, mediaStyle: {}, mediaSizeClass: "w-full h-auto" } : {
|
|
108
127
|
tileStyle: { aspectRatio: r },
|
|
@@ -111,9 +130,10 @@ function o(e) {
|
|
|
111
130
|
};
|
|
112
131
|
}
|
|
113
132
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
n as alertStyles,
|
|
134
|
+
o as badgeStyles,
|
|
135
|
+
a as buttonStyles,
|
|
136
|
+
b as calloutStyles,
|
|
137
|
+
l as galleryTileLayout,
|
|
138
|
+
t as tripMapStyles
|
|
119
139
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const s = "420px";
|
|
2
|
+
function r(t) {
|
|
3
|
+
return (t ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
4
|
+
}
|
|
5
|
+
function p(t) {
|
|
6
|
+
let e = t;
|
|
7
|
+
if (typeof e == "string")
|
|
8
|
+
try {
|
|
9
|
+
e = JSON.parse(e);
|
|
10
|
+
} catch {
|
|
11
|
+
return typeof console < "u" && console.warn('[TripMap] `nodes` prop is not valid JSON — use quoted keys: [{"lat":49.3,"lng":16.3}]'), [];
|
|
12
|
+
}
|
|
13
|
+
return Array.isArray(e) ? e.filter((a) => !!a && typeof a == "object" && typeof a.lat == "number" && typeof a.lng == "number") : [];
|
|
14
|
+
}
|
|
15
|
+
function u(t) {
|
|
16
|
+
const e = /T(\d{2}):(\d{2})/.exec(t);
|
|
17
|
+
return e ? `${e[1]}:${e[2]}` : "";
|
|
18
|
+
}
|
|
19
|
+
function l(t, e) {
|
|
20
|
+
const a = new URLSearchParams();
|
|
21
|
+
e?.language && a.set("lang", e.language);
|
|
22
|
+
const n = r(t.slugs);
|
|
23
|
+
if (n.length > 0)
|
|
24
|
+
return a.set("slugs", n.join(",")), `/api/media/geo?${a.toString()}`;
|
|
25
|
+
if (e?.filename) {
|
|
26
|
+
a.set("article", e.filename);
|
|
27
|
+
const o = r(t.exclude);
|
|
28
|
+
return o.length > 0 && a.set("exclude", o.join(",")), `/api/media/geo?${a.toString()}`;
|
|
29
|
+
}
|
|
30
|
+
const i = a.toString();
|
|
31
|
+
return i ? `/api/media/geo?${i}` : "/api/media/geo";
|
|
32
|
+
}
|
|
33
|
+
function c(t) {
|
|
34
|
+
return (t ?? "").toLowerCase().startsWith("cs") ? {
|
|
35
|
+
hint: "Interaktivní mapa výletu",
|
|
36
|
+
empty: "Žádná z fotek nemá zveřejněnou polohu.",
|
|
37
|
+
unavailable: "Mapa se zobrazí na publikovaném webu."
|
|
38
|
+
} : {
|
|
39
|
+
hint: "Interactive trip map",
|
|
40
|
+
empty: "No photos with public location data.",
|
|
41
|
+
unavailable: "The map is shown on the published page."
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function f(t) {
|
|
45
|
+
return (t ?? "").toLowerCase().startsWith("cs") ? { play: "Přehrát trasu", stop: "Zastavit" } : void 0;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
s as TRIPMAP_DEFAULT_HEIGHT,
|
|
49
|
+
l as buildTripMapGeoUrl,
|
|
50
|
+
p as parseTripMapHandNodes,
|
|
51
|
+
r as splitTripMapList,
|
|
52
|
+
u as tripMapFormatTime,
|
|
53
|
+
f as tripMapPlaybackLabels,
|
|
54
|
+
c as tripMapUiTexts
|
|
55
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const n = '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors';
|
|
2
|
+
function o(e) {
|
|
3
|
+
const t = [n], r = e?.trim();
|
|
4
|
+
return r && t.push(r), t;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
n as OSM_ATTRIBUTION,
|
|
8
|
+
o as buildAttributions
|
|
9
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import t from "./node_modules/maplibre-gl/dist/maplibre-gl.css.js";
|
|
2
|
+
const r = "tripmap-core-css", e = `
|
|
3
|
+
.tripmap { position: relative; display: flex; flex-direction: column; gap: 8px; height: 100%; }
|
|
4
|
+
.tripmap__map { position: relative; flex: 1 1 auto; width: 100%; min-height: 180px; border-radius: 12px; overflow: hidden; }
|
|
5
|
+
.tripmap__map .maplibregl-canvas { outline: none; }
|
|
6
|
+
|
|
7
|
+
.tripmap-marker {
|
|
8
|
+
display: block; padding: 0; border: 2px solid #ffffff; border-radius: 9999px;
|
|
9
|
+
background: #e5e7eb; cursor: pointer; width: 44px; height: 44px; overflow: hidden;
|
|
10
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.35);
|
|
11
|
+
transition: transform 120ms ease, border-color 120ms ease;
|
|
12
|
+
}
|
|
13
|
+
.tripmap-marker:hover { transform: scale(1.12); z-index: 3; }
|
|
14
|
+
.tripmap-marker--active { border-color: #2563eb; transform: scale(1.15); z-index: 4; }
|
|
15
|
+
.tripmap-marker__img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
16
|
+
.tripmap-marker--dot { width: 18px; height: 18px; background: #2563eb; border-width: 3px; }
|
|
17
|
+
.tripmap-marker__dot { display: block; width: 100%; height: 100%; }
|
|
18
|
+
.tripmap-marker--cluster { position: relative; overflow: visible; }
|
|
19
|
+
.tripmap-marker--cluster .tripmap-marker__img { border-radius: 9999px; }
|
|
20
|
+
.tripmap-marker__count {
|
|
21
|
+
position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px;
|
|
22
|
+
padding: 0 5px; border-radius: 9999px; background: #1d4ed8; color: #fff;
|
|
23
|
+
font: 600 11px/20px system-ui, sans-serif; text-align: center; pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tripmap-popup .maplibregl-popup-content, .tripmap-popup { font: 13px/1.4 system-ui, sans-serif; }
|
|
27
|
+
.tripmap-popup { max-width: 260px; }
|
|
28
|
+
.tripmap-popup__img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; }
|
|
29
|
+
.tripmap-popup__meta { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
|
|
30
|
+
.tripmap-popup__title { font-weight: 600; }
|
|
31
|
+
.tripmap-popup__time { color: #6b7280; font-size: 12px; }
|
|
32
|
+
.tripmap-popup__desc { margin: 0; }
|
|
33
|
+
|
|
34
|
+
.tripmap-filmstrip {
|
|
35
|
+
display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px;
|
|
36
|
+
scrollbar-width: thin; -webkit-overflow-scrolling: touch;
|
|
37
|
+
}
|
|
38
|
+
.tripmap-filmstrip__item {
|
|
39
|
+
position: relative; flex: 0 0 auto; width: 64px; height: 64px; padding: 0;
|
|
40
|
+
border: 2px solid transparent; border-radius: 10px; overflow: hidden;
|
|
41
|
+
background: #f3f4f6; cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
.tripmap-filmstrip__item--active { border-color: #2563eb; }
|
|
44
|
+
.tripmap-filmstrip__img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
45
|
+
.tripmap-filmstrip__item--waypoint { display: flex; align-items: center; justify-content: center; }
|
|
46
|
+
.tripmap-filmstrip__label {
|
|
47
|
+
font: 600 10px/1.2 system-ui, sans-serif; color: #374151; padding: 2px 3px 14px; text-align: center;
|
|
48
|
+
max-width: 100%; overflow-wrap: anywhere; hyphens: auto;
|
|
49
|
+
display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
|
|
50
|
+
}
|
|
51
|
+
.tripmap-filmstrip__time {
|
|
52
|
+
position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 0;
|
|
53
|
+
background: rgba(17,24,39,0.55); color: #fff; font: 10px/1.3 system-ui, sans-serif;
|
|
54
|
+
text-align: center; pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.tripmap__controls { position: absolute; top: 10px; left: 10px; z-index: 5; display: flex; gap: 6px; }
|
|
58
|
+
.tripmap__play {
|
|
59
|
+
border: 0; border-radius: 8px; padding: 6px 10px; background: rgba(255,255,255,0.95);
|
|
60
|
+
color: #1f2937; font: 600 12px/1 system-ui, sans-serif; cursor: pointer;
|
|
61
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
62
|
+
}
|
|
63
|
+
.tripmap__play:hover { background: #fff; }
|
|
64
|
+
`;
|
|
65
|
+
function a(p = document) {
|
|
66
|
+
if (p.getElementById(r)) return;
|
|
67
|
+
const i = p.createElement("style");
|
|
68
|
+
i.id = r, i.textContent = `${t}
|
|
69
|
+
${e}`, p.head.appendChild(i);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
r as TRIPMAP_STYLE_ID,
|
|
73
|
+
a as injectTripMapCss
|
|
74
|
+
};
|
|
@@ -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
|
+
};
|