strata-react 1.0.31 → 1.0.32
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/README.md +2 -2
- package/dist/components/compare-parts.d.ts +2 -0
- package/dist/components/compare-video-grid.d.ts +48 -0
- package/dist/components/compare-video.d.ts +2 -5
- package/dist/components/video-clock.d.ts +60 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +552 -249
- package/dist/index.js.map +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/route-map.d.ts +22 -3
- package/dist/map.js +110 -36
- package/dist/map.js.map +1 -1
- package/dist/{run-CKlcLpdN.js → run-BqZGKhW9.js} +10 -1
- package/dist/run-BqZGKhW9.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/run-CKlcLpdN.js.map +0 -1
package/dist/map/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RouteMap, type MapRoute, type RouteMapProps, type TileSource } from './route-map';
|
|
1
|
+
export { RouteMap, type MapPosition, type MapRoute, type RouteMapProps, type TileSource } from './route-map';
|
package/dist/map/route-map.d.ts
CHANGED
|
@@ -27,6 +27,19 @@ export type MapRoute = {
|
|
|
27
27
|
/** Start and finish marks. Default on for a single route. */
|
|
28
28
|
ends?: boolean;
|
|
29
29
|
};
|
|
30
|
+
/** One moving position, for a map with more than one (two runners on the same loop). */
|
|
31
|
+
export type MapPosition = {
|
|
32
|
+
/** Stable between renders: the marker is kept by it and moved, never recreated. */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Where it is now; null hides it. */
|
|
35
|
+
at: LatLng | null;
|
|
36
|
+
/** What it is called in the text alternative ("Runner A"). */
|
|
37
|
+
label: string;
|
|
38
|
+
/** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */
|
|
39
|
+
routeId?: string;
|
|
40
|
+
/** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */
|
|
41
|
+
colour?: string;
|
|
42
|
+
};
|
|
30
43
|
export type RouteMapProps = {
|
|
31
44
|
/** Names the map ("Route of Wednesday's run"). */
|
|
32
45
|
label: string;
|
|
@@ -40,8 +53,14 @@ export type RouteMapProps = {
|
|
|
40
53
|
position?: LatLng | null;
|
|
41
54
|
/** What the position is called in the text alternative. Default "Current position". */
|
|
42
55
|
positionLabel?: string;
|
|
43
|
-
/**
|
|
44
|
-
|
|
56
|
+
/** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */
|
|
57
|
+
positions?: readonly MapPosition[];
|
|
58
|
+
/** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */
|
|
59
|
+
followId?: string;
|
|
60
|
+
/** `true` pans only when the position leaves the inner 80% of the view; `"centre"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */
|
|
61
|
+
follow?: boolean | "centre";
|
|
62
|
+
/** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */
|
|
63
|
+
zoom?: number;
|
|
45
64
|
/** The route drawn heavier, with the others lighter. */
|
|
46
65
|
selectedId?: string | null;
|
|
47
66
|
/** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */
|
|
@@ -69,4 +88,4 @@ export type RouteMapProps = {
|
|
|
69
88
|
className?: string;
|
|
70
89
|
};
|
|
71
90
|
/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
|
|
72
|
-
export declare function RouteMap({ label, routes, tiles, position, positionLabel, follow, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
|
|
91
|
+
export declare function RouteMap({ label, routes, tiles, position, positionLabel, positions, followId, follow, zoom, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
|
package/dist/map.js
CHANGED
|
@@ -55,6 +55,7 @@ function useSlow(value, ms = 1e3) {
|
|
|
55
55
|
}, [ms]);
|
|
56
56
|
return slow;
|
|
57
57
|
}
|
|
58
|
+
var SINGLE = "\0position";
|
|
58
59
|
var PALETTE = [
|
|
59
60
|
1,
|
|
60
61
|
2,
|
|
@@ -62,6 +63,24 @@ var PALETTE = [
|
|
|
62
63
|
4,
|
|
63
64
|
5
|
|
64
65
|
].map((n) => `var(--chart-${n})`);
|
|
66
|
+
/**
|
|
67
|
+
* Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the
|
|
68
|
+
* loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The
|
|
69
|
+
* position is then set by panning to a whole-pixel top-left worked out from the target and the zoom
|
|
70
|
+
* alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan
|
|
71
|
+
* truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every
|
|
72
|
+
* call, which flickers when the position changes every frame.
|
|
73
|
+
*/
|
|
74
|
+
function centre(map, target, z) {
|
|
75
|
+
if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });
|
|
76
|
+
const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();
|
|
77
|
+
const have = map.getPixelBounds().min.round();
|
|
78
|
+
const move = want.subtract(have);
|
|
79
|
+
if (move.x || move.y) map.panBy(move, {
|
|
80
|
+
animate: false,
|
|
81
|
+
noMoveStart: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
65
84
|
/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */
|
|
66
85
|
function resolveColour(el, value) {
|
|
67
86
|
const probe = document.createElement("span");
|
|
@@ -88,7 +107,7 @@ function stepRuns(points, values, stepOf) {
|
|
|
88
107
|
}
|
|
89
108
|
var arrowHtml = (bearing, colour, halo) => `<svg width="26" height="26" viewBox="0 0 26 26" aria-hidden="true" style="transform: rotate(${bearing.toFixed(0)}deg)"><path d="M6 17 L13 9 L20 17" fill="none" stroke="${halo}" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 17 L13 9 L20 17" fill="none" stroke="${colour}" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
90
109
|
/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
|
|
91
|
-
function RouteMap({ label, routes, tiles, position = null, positionLabel = "Current position", follow = false, selectedId = null, onSelect, colourScale, colourScaleLabel, formatValue = plain, summary, units = "metric", scrollZoom = false, topEnd, bottomStart, className }) {
|
|
110
|
+
function RouteMap({ label, routes, tiles, position = null, positionLabel = "Current position", positions, followId, follow = false, zoom, selectedId = null, onSelect, colourScale, colourScaleLabel, formatValue = plain, summary, units = "metric", scrollZoom = false, topEnd, bottomStart, className }) {
|
|
92
111
|
const { scheme } = useColorScheme();
|
|
93
112
|
const host = React.useRef(null);
|
|
94
113
|
const root = React.useRef(null);
|
|
@@ -97,8 +116,7 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
97
116
|
const latest = React.useRef({ onSelect });
|
|
98
117
|
latest.current = { onSelect };
|
|
99
118
|
const selectable = Boolean(onSelect);
|
|
100
|
-
const
|
|
101
|
-
const markerScheme = React.useRef(null);
|
|
119
|
+
const markers = React.useRef(/* @__PURE__ */ new Map());
|
|
102
120
|
const source = (scheme === "dark" ? tiles.dark : void 0) ?? tiles.light;
|
|
103
121
|
const treated = scheme === "dark" && !tiles.dark;
|
|
104
122
|
const stops = React.useMemo(() => colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [], [colourScale]);
|
|
@@ -122,8 +140,7 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
122
140
|
setMap(m);
|
|
123
141
|
return () => {
|
|
124
142
|
ro.disconnect();
|
|
125
|
-
|
|
126
|
-
markerScheme.current = null;
|
|
143
|
+
markers.current.clear();
|
|
127
144
|
m.remove();
|
|
128
145
|
setMap(null);
|
|
129
146
|
};
|
|
@@ -133,7 +150,20 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
133
150
|
if (scrollZoom) map.scrollWheelZoom.enable();
|
|
134
151
|
else map.scrollWheelZoom.disable();
|
|
135
152
|
}, [map, scrollZoom]);
|
|
136
|
-
const
|
|
153
|
+
const zoomed = zoom !== void 0;
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
if (map) map.options.zoomSnap = zoomed ? 0 : .5;
|
|
156
|
+
}, [map, zoomed]);
|
|
157
|
+
const all = React.useMemo(() => [...position ? [{
|
|
158
|
+
id: SINGLE,
|
|
159
|
+
at: position,
|
|
160
|
+
label: positionLabel
|
|
161
|
+
}] : [], ...positions ?? []], [
|
|
162
|
+
position,
|
|
163
|
+
positionLabel,
|
|
164
|
+
positions
|
|
165
|
+
]);
|
|
166
|
+
const spoken = useSlow(all);
|
|
137
167
|
const text = React.useMemo(() => {
|
|
138
168
|
if (summary) return summary;
|
|
139
169
|
if (!routes.length) return "No routes to show.";
|
|
@@ -142,9 +172,9 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
142
172
|
const total = along[along.length - 1] ?? 0;
|
|
143
173
|
const shape = geo.ends(r.points)?.loop ? ", a loop" : "";
|
|
144
174
|
let here = "";
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
here
|
|
175
|
+
for (const p of spoken) {
|
|
176
|
+
if (!p.at || !r.points.length || p.routeId !== void 0 && p.routeId !== r.id && routes.some((o) => o.id === p.routeId)) continue;
|
|
177
|
+
here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 0, units)} along.`;
|
|
148
178
|
}
|
|
149
179
|
let range = "";
|
|
150
180
|
if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? "Value"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;
|
|
@@ -155,7 +185,6 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
155
185
|
summary,
|
|
156
186
|
routes,
|
|
157
187
|
spoken,
|
|
158
|
-
positionLabel,
|
|
159
188
|
units,
|
|
160
189
|
stops.length,
|
|
161
190
|
colourScaleLabel,
|
|
@@ -275,6 +304,7 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
275
304
|
}
|
|
276
305
|
}
|
|
277
306
|
});
|
|
307
|
+
for (const { marker } of markers.current.values()) marker.bringToFront();
|
|
278
308
|
return () => void group.remove();
|
|
279
309
|
}, [
|
|
280
310
|
map,
|
|
@@ -284,6 +314,25 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
284
314
|
stops,
|
|
285
315
|
selectable
|
|
286
316
|
]);
|
|
317
|
+
const target = React.useMemo(() => {
|
|
318
|
+
if (!follow) return null;
|
|
319
|
+
const shown = all.filter((p) => p.at);
|
|
320
|
+
return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;
|
|
321
|
+
}, [
|
|
322
|
+
all,
|
|
323
|
+
follow,
|
|
324
|
+
followId
|
|
325
|
+
]);
|
|
326
|
+
const latestView = React.useRef({
|
|
327
|
+
target,
|
|
328
|
+
zoom,
|
|
329
|
+
centred: follow === "centre"
|
|
330
|
+
});
|
|
331
|
+
latestView.current = {
|
|
332
|
+
target,
|
|
333
|
+
zoom,
|
|
334
|
+
centred: follow === "centre"
|
|
335
|
+
};
|
|
287
336
|
const routeKey = routes.map((r) => r.id).join("\n");
|
|
288
337
|
const fitted = React.useRef(null);
|
|
289
338
|
React.useEffect(() => {
|
|
@@ -294,7 +343,11 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
294
343
|
const box = geo.bounds(routes.flatMap((r) => r.points));
|
|
295
344
|
if (!box) return;
|
|
296
345
|
fitted.current = routeKey;
|
|
297
|
-
|
|
346
|
+
const view = latestView.current;
|
|
347
|
+
if (view.zoom !== void 0) {
|
|
348
|
+
const centre = view.centred && view.target || [(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2];
|
|
349
|
+
map.setView(tuple(centre), view.zoom, { animate: false });
|
|
350
|
+
} else map.fitBounds([tuple(box[0]), tuple(box[1])], {
|
|
298
351
|
padding: [24, 24],
|
|
299
352
|
animate: false,
|
|
300
353
|
maxZoom: 17
|
|
@@ -304,38 +357,59 @@ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Curr
|
|
|
304
357
|
map.on("resize", fit);
|
|
305
358
|
return () => void map.off("resize", fit);
|
|
306
359
|
}, [map, routeKey]);
|
|
307
|
-
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
if (map && zoom !== void 0 && fitted.current !== null && map.getZoom() !== zoom) map.setZoom(zoom, { animate: false });
|
|
362
|
+
}, [map, zoom]);
|
|
308
363
|
React.useEffect(() => {
|
|
309
364
|
if (!map) return;
|
|
310
|
-
if (lat === null || lng === null) {
|
|
311
|
-
marker.current?.remove();
|
|
312
|
-
marker.current = null;
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
365
|
const el = map.getContainer();
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
366
|
+
const live = markers.current;
|
|
367
|
+
const seen = /* @__PURE__ */ new Set();
|
|
368
|
+
for (const p of all) {
|
|
369
|
+
if (!p.at) continue;
|
|
370
|
+
seen.add(p.id);
|
|
371
|
+
let entry = live.get(p.id);
|
|
372
|
+
if (!entry) {
|
|
373
|
+
entry = {
|
|
374
|
+
marker: L.circleMarker(tuple(p.at), {
|
|
375
|
+
radius: 8,
|
|
376
|
+
weight: 3,
|
|
377
|
+
fillOpacity: 1,
|
|
378
|
+
interactive: false
|
|
379
|
+
}).addTo(map),
|
|
380
|
+
style: ""
|
|
381
|
+
};
|
|
382
|
+
live.set(p.id, entry);
|
|
383
|
+
} else entry.marker.setLatLng(tuple(p.at));
|
|
384
|
+
const index = routes.findIndex((r) => r.id === p.routeId);
|
|
385
|
+
const spec = p.colour ?? (index >= 0 ? routes[index].colour ?? PALETTE[index % PALETTE.length] : "var(--primary)");
|
|
386
|
+
const style = `${scheme}|${spec}`;
|
|
387
|
+
if (entry.style !== style) {
|
|
388
|
+
entry.style = style;
|
|
389
|
+
entry.marker.setStyle({
|
|
390
|
+
color: resolveColour(el, "var(--background)"),
|
|
391
|
+
fillColor: resolveColour(el, spec)
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
for (const [id, entry] of live) {
|
|
396
|
+
if (seen.has(id)) continue;
|
|
397
|
+
entry.marker.remove();
|
|
398
|
+
live.delete(id);
|
|
331
399
|
}
|
|
332
|
-
if (
|
|
400
|
+
if (!target) return;
|
|
401
|
+
if (follow === "centre") {
|
|
402
|
+
const z = zoom ?? (fitted.current === null ? void 0 : map.getZoom());
|
|
403
|
+
if (z !== void 0) centre(map, target, z);
|
|
404
|
+
} else if (!map.getBounds().pad(-.2).contains(tuple(target))) map.panTo(tuple(target), { animate: false });
|
|
333
405
|
}, [
|
|
334
406
|
map,
|
|
335
|
-
|
|
336
|
-
|
|
407
|
+
all,
|
|
408
|
+
routes,
|
|
409
|
+
scheme,
|
|
337
410
|
follow,
|
|
338
|
-
|
|
411
|
+
target,
|
|
412
|
+
zoom
|
|
339
413
|
]);
|
|
340
414
|
return /* @__PURE__ */ jsxs("div", {
|
|
341
415
|
ref: root,
|
package/dist/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","names":[],"sources":["../src/map/map-styles.ts","../src/map/route-map.tsx"],"sourcesContent":["import leafletCss from \"leaflet/dist/leaflet.css?inline\";\n\n// Leaflet draws with its own stylesheet (panes, tiles, controls positioned by class), which an app\n// would otherwise have to import beside strata-react's. That is an install step a component must\n// not need (CLAUDE.md, \"Imports decide the peers\"), so the map puts it in the page itself, once,\n// followed by the few rules that make Leaflet's own parts (zoom buttons, attribution, tooltips)\n// read as the app: its roles, its control height, its radius. The dark treatment is here too, in\n// one place: a map without dark tiles is turned to the dark scheme with a filter, which is a\n// fallback, not a design (an app with a dark tile set passes it as `tiles.dark`).\nconst strata = `\n.strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }\n.strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }\n.strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }\n.strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }\n.strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }\n.strata-map .leaflet-bar a:last-child { border-bottom: 0; }\n.strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }\n.strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }\n.strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }\n.strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }\n.strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }\n.strata-map .leaflet-tooltip::before { display: none; }\n.strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }\n.strata-map .strata-map-arrow { background: none; border: 0; }\n`;\n\nlet installed = false;\n\n/** Puts Leaflet's stylesheet and the token overrides in the document head, once. */\nexport function installMapStyles() {\n if (installed || typeof document === \"undefined\") return;\n installed = true;\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-strata-map\", \"\");\n el.textContent = leafletCss + strata;\n document.head.appendChild(el);\n}\n","import * as React from \"react\";\nimport L from \"leaflet\";\nimport { useColorScheme } from \"../components/theme\";\nimport { cn } from \"../lib/utils\";\nimport { format } from \"../lib/format\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { installMapStyles } from \"./map-styles\";\n\n// A themed map of routes with a position that moves along them (strata-react issue #80, from\n// strata-vid's MapPanel and jonathanburnhams.com's activity maps). It is behind its own entry,\n// `strata-react/map`, because Leaflet is heavy and an app that draws no maps should not install it:\n// Leaflet is an optional peer and nothing in the main entry imports it.\n//\n// Leaflet, without react-leaflet (Jonathan's choice, 2026-11-12). react-leaflet binds every layer to\n// a React element, so a position that moves sixty times a second re-renders the route elements\n// beside it; here the map is made once, the routes are one effect that runs only when the routes\n// change, and the position is another that calls `setLatLng` on one marker. A position update\n// touches nothing else: no route is redrawn, none is recreated.\n//\n// What the app supplies, and what the component decides:\n// - Tiles are the app's (`tiles.light`, `tiles.dark`, each with the attribution its provider\n// requires, shown on the map). A dark scheme uses `tiles.dark` when there is one, else the light\n// tiles under a filter (see map-styles.ts); the choice follows the colour scheme.\n// - Colours are roles. A route's colour is any CSS colour (`var(--chart-2)`, `var(--info)`), resolved\n// against the map's own element so SVG strokes, which Leaflet writes as attributes, get a real\n// colour that follows the scheme. Routes default to the chart palette in order.\n// - Colour by value (`values` on a route plus `colourScale`) follows LineChart's rules (§3.8): the\n// colour is a fact of the subject, steps are the app's, and a key names them (`colourScaleLabel`\n// and the step thresholds through `formatValue`) so colour is never the only cue. Runs of one\n// step are drawn as one line, so a long route is a few polylines, not thousands.\n// - One route is the common case: it gets direction chevrons and start and finish marks (a loop is\n// one mark) by default; with several routes those are off unless a route asks.\n// - Fit-to-content happens on first show and when the set of routes changes, not when a route's\n// points are replaced by the same ids, so a person who has zoomed is not thrown back.\n// - Overlay slots, `topEnd` and `bottomStart`, sit where Leaflet puts nothing (it uses the top\n// start for zoom and the bottom end for attribution), so an app's own control or figure never\n// covers a required notice.\n//\n// Keyboard and screen readers. Leaflet's container is a focus stop: arrows pan, + and − zoom. It is\n// named by `label` and described by a text alternative that says what is drawn (each route, its\n// length, whether it is a loop, and how far along the position is), written from the data or given\n// as `summary`. Hovering a route or a mark is a bonus; its facts are in that text. Choosing a route\n// is `onSelect`, and a screen that lets a person choose one lists its routes beside the map (a\n// pointer click on a line has no keyboard equivalent inside Leaflet's SVG, so the list is the path).\n//\n// No animation: zoom, fade and inertia are off, because a map is panned all the time and a tile\n// fade makes a screenshot depend on timing (character by frequency, and strata-visual).\n//\n// Checked: React Aria has no map or geographic part. Leaflet's own keyboard handler and focus are\n// kept as they are.\n\n/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */\nexport type TileSource = {\n /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */\n url: string;\n /** What the provider requires shown (HTML allowed: \"© OpenStreetMap contributors\"). */\n attribution: string;\n subdomains?: string;\n minZoom?: number;\n maxZoom?: number;\n};\n\n/** One route on the map. */\nexport type MapRoute = {\n id: string;\n /** Its name, in the text alternative and on hover (\"Wednesday run\"). */\n label: string;\n points: readonly LatLng[];\n /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */\n colour?: string;\n /** Line width in pixels. Default 4. */\n weight?: number;\n /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */\n values?: readonly number[];\n /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */\n arrows?: boolean | number;\n /** Start and finish marks. Default on for a single route. */\n ends?: boolean;\n};\n\nexport type RouteMapProps = {\n /** Names the map (\"Route of Wednesday's run\"). */\n label: string;\n /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */\n routes: readonly MapRoute[];\n tiles: { light: TileSource; dark?: TileSource };\n /** Where the moving thing is now. Moved without redrawing any route; null for none. */\n position?: LatLng | null;\n /** What the position is called in the text alternative. Default \"Current position\". */\n positionLabel?: string;\n /** Keep the position in view as it moves. */\n follow?: boolean;\n /** The route drawn heavier, with the others lighter. */\n selectedId?: string | null;\n /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */\n onSelect?: (id: string) => void;\n /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */\n colourScale?: readonly { at: number; colour: string }[];\n /** What the colours mean, written in the key (\"Speed\"). */\n colourScaleLabel?: string;\n /** Writes a value in the key and the text alternative (\"12 km/h\"). Default the plain number. */\n formatValue?: (value: number) => string;\n /** Replaces the generated text alternative. */\n summary?: string;\n /** Units for lengths in the generated text. Default metric. */\n units?: \"metric\" | \"imperial\";\n /** Wheel zoom. Off by default so the page still scrolls past the map. */\n scrollZoom?: boolean;\n /** An app control or figure in the top end corner (Leaflet leaves it free). */\n topEnd?: React.ReactNode;\n /** An app legend or figure in the bottom start corner, below the colour key when there is one. */\n bottomStart?: React.ReactNode;\n /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */\n className?: string;\n};\n\n/** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */\nfunction extent(values: readonly number[]): [number, number] {\n let lo = Infinity;\n let hi = -Infinity;\n for (const v of values) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n return [lo, hi];\n}\n\nconst tuple = (p: LatLng): L.LatLngTuple => [p[0], p[1]];\nconst plain = (v: number) => String(v);\n\n/** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */\nfunction useSlow<T>(value: T, ms = 1000): T {\n const [slow, setSlow] = React.useState(value);\n const latest = React.useRef(value);\n latest.current = value;\n React.useEffect(() => {\n const id = window.setInterval(() => setSlow(latest.current), ms);\n return () => window.clearInterval(id);\n }, [ms]);\n return slow;\n}\n\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */\nfunction resolveColour(el: HTMLElement, value: string): string {\n const probe = document.createElement(\"span\");\n probe.style.color = value;\n el.appendChild(probe);\n const resolved = getComputedStyle(probe).color;\n probe.remove();\n return resolved || value;\n}\n\n/** Indices where a run of one step ends, so a coloured route is a few polylines. */\nfunction stepRuns(points: readonly LatLng[], values: readonly number[], stepOf: (v: number) => number) {\n const runs: { from: number; to: number; step: number }[] = [];\n for (let i = 1; i < points.length; i++) {\n const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);\n const last = runs[runs.length - 1];\n if (last && last.step === step) last.to = i;\n else runs.push({ from: i - 1, to: i, step });\n }\n return runs;\n}\n\nconst arrowHtml = (bearing: number, colour: string, halo: string) =>\n `<svg width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" aria-hidden=\"true\" style=\"transform: rotate(${bearing.toFixed(0)}deg)\">` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${halo}\" stroke-width=\"7\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${colour}\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */\nexport function RouteMap({\n label,\n routes,\n tiles,\n position = null,\n positionLabel = \"Current position\",\n follow = false,\n selectedId = null,\n onSelect,\n colourScale,\n colourScaleLabel,\n formatValue = plain,\n summary,\n units = \"metric\",\n scrollZoom = false,\n topEnd,\n bottomStart,\n className,\n}: RouteMapProps) {\n const { scheme } = useColorScheme();\n const host = React.useRef<HTMLDivElement>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [map, setMap] = React.useState<L.Map | null>(null);\n const summaryId = React.useId();\n const latest = React.useRef({ onSelect });\n latest.current = { onSelect };\n const selectable = Boolean(onSelect);\n const marker = React.useRef<L.CircleMarker | null>(null);\n const markerScheme = React.useRef<string | null>(null);\n\n const darkTiles = scheme === \"dark\" ? tiles.dark : undefined;\n const source = darkTiles ?? tiles.light;\n const treated = scheme === \"dark\" && !tiles.dark;\n const stops = React.useMemo(() => (colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : []), [colourScale]);\n\n // The map, made once. Its container is Leaflet's; React owns only the wrapper around it.\n React.useEffect(() => {\n installMapStyles();\n const el = host.current;\n if (!el) return;\n const m = L.map(el, { scrollWheelZoom: scrollZoom, fadeAnimation: false, zoomAnimation: false, markerZoomAnimation: false, inertia: false, attributionControl: false, zoomSnap: 0.5 });\n L.control.attribution({ prefix: '<a href=\"https://leafletjs.com\">Leaflet</a>' }).addTo(m);\n el.setAttribute(\"aria-roledescription\", \"map\");\n // Leaflet follows the window, not its container; a pane that resizes (a Workspace split) needs the same.\n const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));\n ro.observe(el);\n setMap(m);\n return () => {\n ro.disconnect();\n marker.current = null;\n markerScheme.current = null;\n m.remove();\n setMap(null);\n };\n // The wheel setting is applied below, so the map is not rebuilt for it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n if (!map) return;\n if (scrollZoom) map.scrollWheelZoom.enable();\n else map.scrollWheelZoom.disable();\n }, [map, scrollZoom]);\n\n // The text alternative: written from the data unless the app gives one. The position is in it, but\n // it is not a live region: a position that moves many times a second must not be announced.\n const spoken = useSlow(position);\n const text = React.useMemo(() => {\n if (summary) return summary;\n if (!routes.length) return \"No routes to show.\";\n const parts = routes.map((r) => {\n const along = geo.cumulative(r.points);\n const total = along[along.length - 1] ?? 0;\n const ends = geo.ends(r.points);\n const shape = ends?.loop ? \", a loop\" : \"\";\n let here = \"\";\n if (spoken && r.points.length) {\n const i = geo.nearest(r.points, spoken);\n here = ` ${positionLabel}: ${format.distance(along[i] ?? 0, units)} along.`;\n }\n let range = \"\";\n if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? \"Value\"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;\n return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;\n });\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}`;\n }, [summary, routes, spoken, positionLabel, units, stops.length, colourScaleLabel, formatValue]);\n\n React.useEffect(() => {\n if (!map) return;\n const c = map.getContainer();\n c.setAttribute(\"aria-label\", label);\n c.setAttribute(\"aria-describedby\", summaryId);\n }, [map, label, summaryId]);\n\n // Tiles: the light set, or the dark one in the dark scheme.\n React.useEffect(() => {\n if (!map) return;\n const layer = L.tileLayer(source.url, { attribution: source.attribution, subdomains: source.subdomains ?? \"abc\", minZoom: source.minZoom, maxZoom: source.maxZoom ?? 19, keepBuffer: 1 });\n layer.addTo(map);\n return () => void layer.remove();\n }, [map, source.url, source.attribution, source.subdomains, source.minZoom, source.maxZoom]);\n\n // The routes: redrawn when the routes, the scheme (colours resolve differently), the selection or\n // the scale change, and never for a position update.\n React.useEffect(() => {\n if (!map) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n const halo = resolveColour(el, \"var(--background)\");\n const single = routes.length === 1;\n const stepOf = (v: number) => {\n let at = 0;\n stops.forEach((s, i) => {\n if (s.at <= v) at = i;\n });\n return at;\n };\n routes.forEach((route, index) => {\n if (route.points.length < 2) return;\n const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);\n const selected = route.id === selectedId;\n const dim = selectedId !== null && !selected;\n const weight = (route.weight ?? 4) + (selected ? 2 : 0);\n const style = { weight, opacity: dim ? 0.55 : 1, lineCap: \"round\" as const, lineJoin: \"round\" as const, interactive: selectable, bubblingMouseEvents: false };\n const lines: L.Polyline[] = [];\n if (stops.length && route.values?.length) {\n for (const run of stepRuns(route.points, route.values, stepOf)) {\n lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), { ...style, color: resolveColour(el, stops[run.step].colour) }));\n }\n } else {\n lines.push(L.polyline(route.points.map(tuple), { ...style, color: base }));\n }\n for (const line of lines) {\n line.bindTooltip(route.label, { sticky: true });\n line.on(\"click\", () => latest.current.onSelect?.(route.id));\n line.addTo(group);\n }\n const chevrons = route.arrows === undefined ? (single ? 5 : 0) : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;\n if (chevrons > 0) {\n for (const a of geo.arrows(route.points, chevrons)) {\n L.marker(tuple(a.position), {\n interactive: false,\n keyboard: false,\n icon: L.divIcon({ className: \"strata-map-arrow\", iconSize: [26, 26], iconAnchor: [13, 13], html: arrowHtml(a.bearing, base, halo) }),\n }).addTo(group);\n }\n }\n if (route.ends ?? single) {\n const ends = geo.ends(route.points);\n if (ends) {\n const success = resolveColour(el, \"var(--success)\");\n const danger = resolveColour(el, \"var(--danger)\");\n const mark = (at: LatLng, text: string, options: L.CircleMarkerOptions) => L.circleMarker(tuple(at), { radius: 7, interactive: true, bubblingMouseEvents: false, ...options }).bindTooltip(text).addTo(group);\n // Shapes carry the meaning as well as colour: a filled start, a ringed finish, one of each for a loop.\n if (ends.loop) mark(ends.start, `${route.label}: start and finish`, { color: danger, weight: 3, fillColor: success, fillOpacity: 1 });\n else {\n mark(ends.finish, `${route.label}: finish`, { color: danger, weight: 3, fillColor: halo, fillOpacity: 1 });\n mark(ends.start, `${route.label}: start`, { color: halo, weight: 2, fillColor: success, fillOpacity: 1 });\n }\n }\n }\n });\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable]);\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes.\n const routeKey = routes.map((r) => r.id).join(\"\\n\");\n const fitted = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const fit = () => {\n const size = map.getSize();\n if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return;\n fitted.current = routeKey;\n map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n };\n fit();\n map.on(\"resize\", fit);\n return () => void map.off(\"resize\", fit);\n // `routes` is read when the key says the set changed; a new array of the same ids does not refit.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, routeKey]);\n\n // The position: one marker, moved with `setLatLng`. Nothing else is touched.\n const [lat, lng] = position ?? [null, null];\n React.useEffect(() => {\n if (!map) return;\n if (lat === null || lng === null) {\n marker.current?.remove();\n marker.current = null;\n return;\n }\n const el = map.getContainer();\n if (!marker.current) {\n marker.current = L.circleMarker([lat, lng], { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map);\n markerScheme.current = null;\n } else marker.current.setLatLng([lat, lng]);\n if (markerScheme.current !== scheme) {\n markerScheme.current = scheme;\n marker.current.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, \"var(--primary)\") });\n }\n if (follow && !map.getBounds().pad(-0.2).contains([lat, lng])) map.panTo([lat, lng], { animate: false });\n }, [map, lat, lng, follow, scheme]);\n\n return (\n <div ref={root} data-dark-treatment={treated ? \"\" : undefined} className={cn(\"strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border\", className)}>\n <div ref={host} className=\"size-full\" />\n <p id={summaryId} className=\"sr-only\">\n {text}\n </p>\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {(stops.length > 0 || bottomStart) && (\n <div className=\"absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2\">\n {stops.length > 0 && <ColourKey stops={stops} label={colourScaleLabel} formatValue={formatValue} />}\n {bottomStart}\n </div>\n )}\n </div>\n );\n}\n\n/** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */\nfunction ColourKey({ stops, label, formatValue }: { stops: readonly { at: number; colour: string }[]; label?: string; formatValue: (v: number) => string }) {\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n {label && <p className=\"font-medium\">{label}</p>}\n <ul className=\"grid gap-0.5\">\n {stops.map((s) => (\n <li key={s.at} className=\"flex items-center gap-2 tabular-nums\">\n <svg width=\"20\" height=\"4\" aria-hidden>\n <line x1=\"0\" x2=\"20\" y1=\"2\" y2=\"2\" stroke={s.colour} strokeWidth={4} strokeLinecap=\"round\" />\n </svg>\n <span>{`From ${formatValue(s.at)}`}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;AASA,IAAM,SAAS;;;;;;;;;;;;;;;;AAiBf,IAAI,YAAY;;AAGhB,SAAgB,mBAAmB;CACjC,IAAI,aAAa,OAAO,aAAa,aAAa;CAClD,YAAY;CACZ,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,aAAa,mBAAmB,EAAE;CACrC,GAAG,cAAc,aAAa;CAC9B,SAAS,KAAK,YAAY,EAAE;AAC9B;;;ACiFA,SAAS,OAAO,QAA6C;CAC3D,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,IAAI,IAAI,KAAK;EACjB,IAAI,IAAI,IAAI,KAAK;CACnB;CACA,OAAO,CAAC,IAAI,EAAE;AAChB;AAEA,IAAM,SAAS,MAA6B,CAAC,EAAE,IAAI,EAAE,EAAE;AACvD,IAAM,SAAS,MAAc,OAAO,CAAC;;AAGrC,SAAS,QAAW,OAAU,KAAK,KAAS;CAC1C,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,KAAK;CACjC,OAAO,UAAU;CACjB,MAAM,gBAAgB;EACpB,MAAM,KAAK,OAAO,kBAAkB,QAAQ,OAAO,OAAO,GAAG,EAAE;EAC/D,aAAa,OAAO,cAAc,EAAE;CACtC,GAAG,CAAC,EAAE,CAAC;CACP,OAAO;AACT;AAEA,IAAM,UAAU;CAAC;CAAG;CAAG;CAAG;CAAG;AAAC,CAAC,CAAC,KAAK,MAAM,eAAe,EAAE,EAAE;;AAG9D,SAAS,cAAc,IAAiB,OAAuB;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ACL,oBAAC,QAAD,EAAA,UAAO,QAAQ,YAAY,EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"map.js","names":[],"sources":["../src/map/map-styles.ts","../src/map/route-map.tsx"],"sourcesContent":["import leafletCss from \"leaflet/dist/leaflet.css?inline\";\n\n// Leaflet draws with its own stylesheet (panes, tiles, controls positioned by class), which an app\n// would otherwise have to import beside strata-react's. That is an install step a component must\n// not need (CLAUDE.md, \"Imports decide the peers\"), so the map puts it in the page itself, once,\n// followed by the few rules that make Leaflet's own parts (zoom buttons, attribution, tooltips)\n// read as the app: its roles, its control height, its radius. The dark treatment is here too, in\n// one place: a map without dark tiles is turned to the dark scheme with a filter, which is a\n// fallback, not a design (an app with a dark tile set passes it as `tiles.dark`).\nconst strata = `\n.strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }\n.strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }\n.strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }\n.strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }\n.strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }\n.strata-map .leaflet-bar a:last-child { border-bottom: 0; }\n.strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }\n.strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }\n.strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }\n.strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }\n.strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }\n.strata-map .leaflet-tooltip::before { display: none; }\n.strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }\n.strata-map .strata-map-arrow { background: none; border: 0; }\n`;\n\nlet installed = false;\n\n/** Puts Leaflet's stylesheet and the token overrides in the document head, once. */\nexport function installMapStyles() {\n if (installed || typeof document === \"undefined\") return;\n installed = true;\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-strata-map\", \"\");\n el.textContent = leafletCss + strata;\n document.head.appendChild(el);\n}\n","import * as React from \"react\";\nimport L from \"leaflet\";\nimport { useColorScheme } from \"../components/theme\";\nimport { cn } from \"../lib/utils\";\nimport { format } from \"../lib/format\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { installMapStyles } from \"./map-styles\";\n\n// A themed map of routes with a position that moves along them (strata-react issue #80, from\n// strata-vid's MapPanel and jonathanburnhams.com's activity maps). It is behind its own entry,\n// `strata-react/map`, because Leaflet is heavy and an app that draws no maps should not install it:\n// Leaflet is an optional peer and nothing in the main entry imports it.\n//\n// Leaflet, without react-leaflet (Jonathan's choice, 2026-11-12). react-leaflet binds every layer to\n// a React element, so a position that moves sixty times a second re-renders the route elements\n// beside it; here the map is made once, the routes are one effect that runs only when the routes\n// change, and the position is another that calls `setLatLng` on one marker. A position update\n// touches nothing else: no route is redrawn, none is recreated.\n//\n// What the app supplies, and what the component decides:\n// - Tiles are the app's (`tiles.light`, `tiles.dark`, each with the attribution its provider\n// requires, shown on the map). A dark scheme uses `tiles.dark` when there is one, else the light\n// tiles under a filter (see map-styles.ts); the choice follows the colour scheme.\n// - Colours are roles. A route's colour is any CSS colour (`var(--chart-2)`, `var(--info)`), resolved\n// against the map's own element so SVG strokes, which Leaflet writes as attributes, get a real\n// colour that follows the scheme. Routes default to the chart palette in order.\n// - Colour by value (`values` on a route plus `colourScale`) follows LineChart's rules (§3.8): the\n// colour is a fact of the subject, steps are the app's, and a key names them (`colourScaleLabel`\n// and the step thresholds through `formatValue`) so colour is never the only cue. Runs of one\n// step are drawn as one line, so a long route is a few polylines, not thousands.\n// - One route is the common case: it gets direction chevrons and start and finish marks (a loop is\n// one mark) by default; with several routes those are off unless a route asks.\n// - Fit-to-content happens on first show and when the set of routes changes, not when a route's\n// points are replaced by the same ids, so a person who has zoomed is not thrown back.\n// - Overlay slots, `topEnd` and `bottomStart`, sit where Leaflet puts nothing (it uses the top\n// start for zoom and the bottom end for attribution), so an app's own control or figure never\n// covers a required notice.\n//\n// Keyboard and screen readers. Leaflet's container is a focus stop: arrows pan, + and − zoom. It is\n// named by `label` and described by a text alternative that says what is drawn (each route, its\n// length, whether it is a loop, and how far along the position is), written from the data or given\n// as `summary`. Hovering a route or a mark is a bonus; its facts are in that text. Choosing a route\n// is `onSelect`, and a screen that lets a person choose one lists its routes beside the map (a\n// pointer click on a line has no keyboard equivalent inside Leaflet's SVG, so the list is the path).\n//\n// Map as picture content (issue #161, from strata-vid, where a route inset is composed over footage and\n// must look the same on every frame as in an export drawn on a canvas). Three additions, none of which\n// changes a page map: `zoom` sets the zoom from outside (any number, so an animation is a prop that\n// changes every frame; unset keeps fit-to-routes), `follow=\"centre\"` holds the view on a position at that\n// zoom, and `positions` draws several moving positions, each tied to a route and drawn in its colour.\n// Centred follow pans to a whole-pixel view worked out from the position and zoom alone (`centre`), with\n// no animation: Leaflet's own centred pan truncates each step, so where the view ended up would depend\n// on the path it took; this depends only on the position and zoom, which is what makes frame N the same\n// picture however it was reached. A `reset` would give the same view but empties the tile layer on every\n// call, which flickers at one update per frame.\n// Fractional zoom needs `zoomSnap: 0`, which is set only while `zoom` is controlled, so a page map still\n// snaps to half steps. Each marker is one `L.CircleMarker` kept by id and moved with `setLatLng`.\n//\n// No animation: zoom, fade and inertia are off, because a map is panned all the time and a tile\n// fade makes a screenshot depend on timing (character by frequency, and strata-visual).\n//\n// Checked: React Aria has no map or geographic part. Leaflet's own keyboard handler and focus are\n// kept as they are.\n\n/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */\nexport type TileSource = {\n /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */\n url: string;\n /** What the provider requires shown (HTML allowed: \"© OpenStreetMap contributors\"). */\n attribution: string;\n subdomains?: string;\n minZoom?: number;\n maxZoom?: number;\n};\n\n/** One route on the map. */\nexport type MapRoute = {\n id: string;\n /** Its name, in the text alternative and on hover (\"Wednesday run\"). */\n label: string;\n points: readonly LatLng[];\n /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */\n colour?: string;\n /** Line width in pixels. Default 4. */\n weight?: number;\n /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */\n values?: readonly number[];\n /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */\n arrows?: boolean | number;\n /** Start and finish marks. Default on for a single route. */\n ends?: boolean;\n};\n\n/** One moving position, for a map with more than one (two runners on the same loop). */\nexport type MapPosition = {\n /** Stable between renders: the marker is kept by it and moved, never recreated. */\n id: string;\n /** Where it is now; null hides it. */\n at: LatLng | null;\n /** What it is called in the text alternative (\"Runner A\"). */\n label: string;\n /** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */\n routeId?: string;\n /** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */\n colour?: string;\n};\n\nexport type RouteMapProps = {\n /** Names the map (\"Route of Wednesday's run\"). */\n label: string;\n /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */\n routes: readonly MapRoute[];\n tiles: { light: TileSource; dark?: TileSource };\n /** Where the moving thing is now. Moved without redrawing any route; null for none. */\n position?: LatLng | null;\n /** What the position is called in the text alternative. Default \"Current position\". */\n positionLabel?: string;\n /** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */\n positions?: readonly MapPosition[];\n /** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */\n followId?: string;\n /** `true` pans only when the position leaves the inner 80% of the view; `\"centre\"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */\n follow?: boolean | \"centre\";\n /** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */\n zoom?: number;\n /** The route drawn heavier, with the others lighter. */\n selectedId?: string | null;\n /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */\n onSelect?: (id: string) => void;\n /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */\n colourScale?: readonly { at: number; colour: string }[];\n /** What the colours mean, written in the key (\"Speed\"). */\n colourScaleLabel?: string;\n /** Writes a value in the key and the text alternative (\"12 km/h\"). Default the plain number. */\n formatValue?: (value: number) => string;\n /** Replaces the generated text alternative. */\n summary?: string;\n /** Units for lengths in the generated text. Default metric. */\n units?: \"metric\" | \"imperial\";\n /** Wheel zoom. Off by default so the page still scrolls past the map. */\n scrollZoom?: boolean;\n /** An app control or figure in the top end corner (Leaflet leaves it free). */\n topEnd?: React.ReactNode;\n /** An app legend or figure in the bottom start corner, below the colour key when there is one. */\n bottomStart?: React.ReactNode;\n /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */\n className?: string;\n};\n\n/** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */\nfunction extent(values: readonly number[]): [number, number] {\n let lo = Infinity;\n let hi = -Infinity;\n for (const v of values) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n return [lo, hi];\n}\n\nconst tuple = (p: LatLng): L.LatLngTuple => [p[0], p[1]];\nconst plain = (v: number) => String(v);\n\n/** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */\nfunction useSlow<T>(value: T, ms = 1000): T {\n const [slow, setSlow] = React.useState(value);\n const latest = React.useRef(value);\n latest.current = value;\n React.useEffect(() => {\n const id = window.setInterval(() => setSlow(latest.current), ms);\n return () => window.clearInterval(id);\n }, [ms]);\n return slow;\n}\n\nconst SINGLE = \"\\u0000position\";\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/**\n * Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the\n * loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The\n * position is then set by panning to a whole-pixel top-left worked out from the target and the zoom\n * alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan\n * truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every\n * call, which flickers when the position changes every frame.\n */\nfunction centre(map: L.Map, target: LatLng, z: number) {\n if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });\n const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();\n const have = map.getPixelBounds().min!.round();\n const move = want.subtract(have);\n if (move.x || move.y) map.panBy(move, { animate: false, noMoveStart: true });\n}\n\n/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */\nfunction resolveColour(el: HTMLElement, value: string): string {\n const probe = document.createElement(\"span\");\n probe.style.color = value;\n el.appendChild(probe);\n const resolved = getComputedStyle(probe).color;\n probe.remove();\n return resolved || value;\n}\n\n/** Indices where a run of one step ends, so a coloured route is a few polylines. */\nfunction stepRuns(points: readonly LatLng[], values: readonly number[], stepOf: (v: number) => number) {\n const runs: { from: number; to: number; step: number }[] = [];\n for (let i = 1; i < points.length; i++) {\n const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);\n const last = runs[runs.length - 1];\n if (last && last.step === step) last.to = i;\n else runs.push({ from: i - 1, to: i, step });\n }\n return runs;\n}\n\nconst arrowHtml = (bearing: number, colour: string, halo: string) =>\n `<svg width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" aria-hidden=\"true\" style=\"transform: rotate(${bearing.toFixed(0)}deg)\">` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${halo}\" stroke-width=\"7\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${colour}\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */\nexport function RouteMap({\n label,\n routes,\n tiles,\n position = null,\n positionLabel = \"Current position\",\n positions,\n followId,\n follow = false,\n zoom,\n selectedId = null,\n onSelect,\n colourScale,\n colourScaleLabel,\n formatValue = plain,\n summary,\n units = \"metric\",\n scrollZoom = false,\n topEnd,\n bottomStart,\n className,\n}: RouteMapProps) {\n const { scheme } = useColorScheme();\n const host = React.useRef<HTMLDivElement>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [map, setMap] = React.useState<L.Map | null>(null);\n const summaryId = React.useId();\n const latest = React.useRef({ onSelect });\n latest.current = { onSelect };\n const selectable = Boolean(onSelect);\n // One marker per position, by id, with the style last applied so a moving marker is not restyled every frame.\n const markers = React.useRef(new Map<string, { marker: L.CircleMarker; style: string }>());\n\n const darkTiles = scheme === \"dark\" ? tiles.dark : undefined;\n const source = darkTiles ?? tiles.light;\n const treated = scheme === \"dark\" && !tiles.dark;\n const stops = React.useMemo(() => (colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : []), [colourScale]);\n\n // The map, made once. Its container is Leaflet's; React owns only the wrapper around it.\n React.useEffect(() => {\n installMapStyles();\n const el = host.current;\n if (!el) return;\n const m = L.map(el, { scrollWheelZoom: scrollZoom, fadeAnimation: false, zoomAnimation: false, markerZoomAnimation: false, inertia: false, attributionControl: false, zoomSnap: 0.5 });\n L.control.attribution({ prefix: '<a href=\"https://leafletjs.com\">Leaflet</a>' }).addTo(m);\n el.setAttribute(\"aria-roledescription\", \"map\");\n // Leaflet follows the window, not its container; a pane that resizes (a Workspace split) needs the same.\n const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));\n ro.observe(el);\n setMap(m);\n return () => {\n ro.disconnect();\n markers.current.clear();\n m.remove();\n setMap(null);\n };\n // The wheel setting is applied below, so the map is not rebuilt for it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n if (!map) return;\n if (scrollZoom) map.scrollWheelZoom.enable();\n else map.scrollWheelZoom.disable();\n }, [map, scrollZoom]);\n\n // A zoom set from outside is any number; Leaflet snaps to `zoomSnap`, so it is 0 while zoom is controlled.\n const zoomed = zoom !== undefined;\n React.useEffect(() => {\n if (map) map.options.zoomSnap = zoomed ? 0 : 0.5;\n }, [map, zoomed]);\n\n // Every position on the map, the single `position` first: what is spoken, drawn and followed.\n const all = React.useMemo<MapPosition[]>(() => [...(position ? [{ id: SINGLE, at: position, label: positionLabel }] : []), ...(positions ?? [])], [position, positionLabel, positions]);\n\n // The text alternative: written from the data unless the app gives one. The position is in it, but\n // it is not a live region: a position that moves many times a second must not be announced.\n const spoken = useSlow(all);\n const text = React.useMemo(() => {\n if (summary) return summary;\n if (!routes.length) return \"No routes to show.\";\n const parts = routes.map((r) => {\n const along = geo.cumulative(r.points);\n const total = along[along.length - 1] ?? 0;\n const ends = geo.ends(r.points);\n const shape = ends?.loop ? \", a loop\" : \"\";\n let here = \"\";\n // A position tied to another route is not on this one; one tied to no route is described along each.\n for (const p of spoken) {\n if (!p.at || !r.points.length || (p.routeId !== undefined && p.routeId !== r.id && routes.some((o) => o.id === p.routeId))) continue;\n here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 0, units)} along.`;\n }\n let range = \"\";\n if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? \"Value\"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;\n return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;\n });\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}`;\n }, [summary, routes, spoken, units, stops.length, colourScaleLabel, formatValue]);\n\n React.useEffect(() => {\n if (!map) return;\n const c = map.getContainer();\n c.setAttribute(\"aria-label\", label);\n c.setAttribute(\"aria-describedby\", summaryId);\n }, [map, label, summaryId]);\n\n // Tiles: the light set, or the dark one in the dark scheme.\n React.useEffect(() => {\n if (!map) return;\n const layer = L.tileLayer(source.url, { attribution: source.attribution, subdomains: source.subdomains ?? \"abc\", minZoom: source.minZoom, maxZoom: source.maxZoom ?? 19, keepBuffer: 1 });\n layer.addTo(map);\n return () => void layer.remove();\n }, [map, source.url, source.attribution, source.subdomains, source.minZoom, source.maxZoom]);\n\n // The routes: redrawn when the routes, the scheme (colours resolve differently), the selection or\n // the scale change, and never for a position update.\n React.useEffect(() => {\n if (!map) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n const halo = resolveColour(el, \"var(--background)\");\n const single = routes.length === 1;\n const stepOf = (v: number) => {\n let at = 0;\n stops.forEach((s, i) => {\n if (s.at <= v) at = i;\n });\n return at;\n };\n routes.forEach((route, index) => {\n if (route.points.length < 2) return;\n const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);\n const selected = route.id === selectedId;\n const dim = selectedId !== null && !selected;\n const weight = (route.weight ?? 4) + (selected ? 2 : 0);\n const style = { weight, opacity: dim ? 0.55 : 1, lineCap: \"round\" as const, lineJoin: \"round\" as const, interactive: selectable, bubblingMouseEvents: false };\n const lines: L.Polyline[] = [];\n if (stops.length && route.values?.length) {\n for (const run of stepRuns(route.points, route.values, stepOf)) {\n lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), { ...style, color: resolveColour(el, stops[run.step].colour) }));\n }\n } else {\n lines.push(L.polyline(route.points.map(tuple), { ...style, color: base }));\n }\n for (const line of lines) {\n line.bindTooltip(route.label, { sticky: true });\n line.on(\"click\", () => latest.current.onSelect?.(route.id));\n line.addTo(group);\n }\n const chevrons = route.arrows === undefined ? (single ? 5 : 0) : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;\n if (chevrons > 0) {\n for (const a of geo.arrows(route.points, chevrons)) {\n L.marker(tuple(a.position), {\n interactive: false,\n keyboard: false,\n icon: L.divIcon({ className: \"strata-map-arrow\", iconSize: [26, 26], iconAnchor: [13, 13], html: arrowHtml(a.bearing, base, halo) }),\n }).addTo(group);\n }\n }\n if (route.ends ?? single) {\n const ends = geo.ends(route.points);\n if (ends) {\n const success = resolveColour(el, \"var(--success)\");\n const danger = resolveColour(el, \"var(--danger)\");\n const mark = (at: LatLng, text: string, options: L.CircleMarkerOptions) => L.circleMarker(tuple(at), { radius: 7, interactive: true, bubblingMouseEvents: false, ...options }).bindTooltip(text).addTo(group);\n // Shapes carry the meaning as well as colour: a filled start, a ringed finish, one of each for a loop.\n if (ends.loop) mark(ends.start, `${route.label}: start and finish`, { color: danger, weight: 3, fillColor: success, fillOpacity: 1 });\n else {\n mark(ends.finish, `${route.label}: finish`, { color: danger, weight: 3, fillColor: halo, fillOpacity: 1 });\n mark(ends.start, `${route.label}: start`, { color: halo, weight: 2, fillColor: success, fillOpacity: 1 });\n }\n }\n }\n });\n // Redrawn routes are new layers: keep the positions above them.\n for (const { marker } of markers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable]);\n\n // The position a followed view is held on: read by the fit (a map shown for the first time starts\n // centred on it) and by the position effect.\n const target = React.useMemo(() => {\n if (!follow) return null;\n const shown = all.filter((p) => p.at);\n return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;\n }, [all, follow, followId]);\n const latestView = React.useRef({ target, zoom, centred: follow === \"centre\" });\n latestView.current = { target, zoom, centred: follow === \"centre\" };\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes. With a\n // zoom set there is nothing to fit: the view is placed at that zoom, on the followed position when\n // the map is centred on one, else on the middle of the routes.\n const routeKey = routes.map((r) => r.id).join(\"\\n\");\n const fitted = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const fit = () => {\n const size = map.getSize();\n if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return;\n fitted.current = routeKey;\n const view = latestView.current;\n if (view.zoom !== undefined) {\n const centre: LatLng = (view.centred && view.target) || [(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2];\n map.setView(tuple(centre), view.zoom, { animate: false });\n } else map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n };\n fit();\n map.on(\"resize\", fit);\n return () => void map.off(\"resize\", fit);\n // `routes` is read when the key says the set changed; a new array of the same ids does not refit.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, routeKey]);\n\n // A zoom that changes after the first view (an animation) moves the zoom about the view's centre.\n React.useEffect(() => {\n if (map && zoom !== undefined && fitted.current !== null && map.getZoom() !== zoom) map.setZoom(zoom, { animate: false });\n }, [map, zoom]);\n\n // The positions: one marker each, kept by id and moved with `setLatLng`. No route is touched.\n React.useEffect(() => {\n if (!map) return;\n const el = map.getContainer();\n const live = markers.current;\n const seen = new Set<string>();\n for (const p of all) {\n if (!p.at) continue;\n seen.add(p.id);\n let entry = live.get(p.id);\n if (!entry) {\n entry = { marker: L.circleMarker(tuple(p.at), { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map), style: \"\" };\n live.set(p.id, entry);\n } else entry.marker.setLatLng(tuple(p.at));\n const index = routes.findIndex((r) => r.id === p.routeId);\n const spec = p.colour ?? (index >= 0 ? (routes[index].colour ?? PALETTE[index % PALETTE.length]) : \"var(--primary)\");\n const style = `${scheme}|${spec}`;\n if (entry.style !== style) {\n entry.style = style;\n entry.marker.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, spec) });\n }\n }\n for (const [id, entry] of live) {\n if (seen.has(id)) continue;\n entry.marker.remove();\n live.delete(id);\n }\n if (!target) return;\n if (follow === \"centre\") {\n // Before the first fit with no zoom set there is no zoom to hold; the fit places the view.\n const z = zoom ?? (fitted.current === null ? undefined : map.getZoom());\n if (z !== undefined) centre(map, target, z);\n } else if (!map.getBounds().pad(-0.2).contains(tuple(target))) map.panTo(tuple(target), { animate: false });\n }, [map, all, routes, scheme, follow, target, zoom]);\n\n return (\n <div ref={root} data-dark-treatment={treated ? \"\" : undefined} className={cn(\"strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border\", className)}>\n <div ref={host} className=\"size-full\" />\n <p id={summaryId} className=\"sr-only\">\n {text}\n </p>\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {(stops.length > 0 || bottomStart) && (\n <div className=\"absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2\">\n {stops.length > 0 && <ColourKey stops={stops} label={colourScaleLabel} formatValue={formatValue} />}\n {bottomStart}\n </div>\n )}\n </div>\n );\n}\n\n/** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */\nfunction ColourKey({ stops, label, formatValue }: { stops: readonly { at: number; colour: string }[]; label?: string; formatValue: (v: number) => string }) {\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n {label && <p className=\"font-medium\">{label}</p>}\n <ul className=\"grid gap-0.5\">\n {stops.map((s) => (\n <li key={s.at} className=\"flex items-center gap-2 tabular-nums\">\n <svg width=\"20\" height=\"4\" aria-hidden>\n <line x1=\"0\" x2=\"20\" y1=\"2\" y2=\"2\" stroke={s.colour} strokeWidth={4} strokeLinecap=\"round\" />\n </svg>\n <span>{`From ${formatValue(s.at)}`}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;AASA,IAAM,SAAS;;;;;;;;;;;;;;;;AAiBf,IAAI,YAAY;;AAGhB,SAAgB,mBAAmB;CACjC,IAAI,aAAa,OAAO,aAAa,aAAa;CAClD,YAAY;CACZ,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,aAAa,mBAAmB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AAU;GAAa,CAAA;GACvC,oBAAC,KAAD;IAAG,IAAI;IAAW,WAAU;IACzB,UAAA;GACA,CAAA;GACF,UAAU,oBAAC,OAAD;IAAK,WAAU;IAAiC,UAAA;GAAY,CAAA;IACrE,MAAM,SAAS,KAAK,gBACpB,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,MAAM,SAAS,KAAK,oBAAC,WAAD;KAAkB;KAAO,OAAO;KAA+B;IAAc,CAAA,GACjG,WACE;;EAEJ;;AAET;;AAGA,SAAS,UAAU,EAAE,OAAO,OAAO,eAAyH;CAC1J,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SAAS,oBAAC,KAAD;GAAG,WAAU;GAAe,UAAA;EAAS,CAAA,GAC/C,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,MAAM,KAAK,MACV,qBAAC,MAAD;IAAe,WAAU;IAAzB,UAAA,CACE,oBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAI,eAAA;KACzB,UAAA,oBAAC,QAAD;MAAM,IAAG;MAAI,IAAG;MAAK,IAAG;MAAI,IAAG;MAAI,QAAQ,EAAE;MAAQ,aAAa;MAAG,eAAc;KAAS,CAAA;IACzF,CAAA,GACL,oBAAC,QAAD,EAAA,UAAO,QAAQ,YAAY,EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
|
|
@@ -134,6 +134,15 @@ async function capture(browser, shot, options) {
|
|
|
134
134
|
async function settle(page) {
|
|
135
135
|
await page.waitForLoadState("networkidle", { timeout: 3e3 }).catch(() => void 0);
|
|
136
136
|
await page.evaluate(() => document.fonts.ready.then(() => void 0));
|
|
137
|
+
await page.waitForFunction(() => [...document.querySelectorAll("video")].every((v) => v.readyState >= 2 || v.error !== null), void 0, { timeout: 5e3 }).catch(() => void 0);
|
|
138
|
+
await page.evaluate(() => Promise.all([...document.querySelectorAll("video")].filter((v) => v.readyState >= 2 && !v.error && "requestVideoFrameCallback" in v).map((v) => new Promise((done) => {
|
|
139
|
+
const stop = window.setTimeout(done, 2e3);
|
|
140
|
+
v.requestVideoFrameCallback(() => {
|
|
141
|
+
window.clearTimeout(stop);
|
|
142
|
+
done();
|
|
143
|
+
});
|
|
144
|
+
v.currentTime = v.currentTime;
|
|
145
|
+
})))).catch(() => void 0);
|
|
137
146
|
await page.waitForTimeout(250);
|
|
138
147
|
}
|
|
139
148
|
async function platformFonts(page) {
|
|
@@ -749,4 +758,4 @@ function formatReport(report) {
|
|
|
749
758
|
}
|
|
750
759
|
export { capture as _, defaultThemes as a, viewports as c, MAX_DIFF_PIXELS as d, THRESHOLD as f, encode as g, decode as h, runVisual as i, serveStatic as l, compare as m, formatReport as n, routeShots as o, boxBlur as p, pinWarnings as r, storybookShots as s, defineVisualConfig as t, BLUR as u, resolveShotUrl as v, toFetchRequest as y };
|
|
751
760
|
|
|
752
|
-
//# sourceMappingURL=run-
|
|
761
|
+
//# sourceMappingURL=run-BqZGKhW9.js.map
|