strata-react 1.0.32 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +11 -1
  2. package/UPGRADING.md +2 -0
  3. package/dist/components/conversation.d.ts +67 -0
  4. package/dist/components/cursor.d.ts +44 -0
  5. package/dist/components/dialog.d.ts +1 -1
  6. package/dist/components/folder-picker.d.ts +42 -0
  7. package/dist/components/lightbox.d.ts +34 -0
  8. package/dist/components/line-chart.d.ts +92 -3
  9. package/dist/components/markable-text.d.ts +56 -0
  10. package/dist/components/media-group.d.ts +25 -0
  11. package/dist/components/media-player.d.ts +80 -2
  12. package/dist/components/media.d.ts +6 -1
  13. package/dist/components/region-editor.d.ts +55 -0
  14. package/dist/components/sequence-timeline.d.ts +50 -0
  15. package/dist/components/transcript-view.d.ts +36 -0
  16. package/dist/components/tree.d.ts +41 -0
  17. package/dist/components/waveform.d.ts +66 -0
  18. package/dist/cursor-DDGBPiTJ.js +290 -0
  19. package/dist/cursor-DDGBPiTJ.js.map +1 -0
  20. package/dist/field-7Z4N5r5g.js +178 -0
  21. package/dist/field-7Z4N5r5g.js.map +1 -0
  22. package/dist/{geo-C0jcFp4q.js → format-B32-PVi2.js} +2 -119
  23. package/dist/format-B32-PVi2.js.map +1 -0
  24. package/dist/hls/index.d.ts +19 -0
  25. package/dist/hls.js +84 -0
  26. package/dist/hls.js.map +1 -0
  27. package/dist/index.d.ts +19 -2
  28. package/dist/index.js +9511 -6296
  29. package/dist/index.js.map +1 -1
  30. package/dist/lib/geo.d.ts +17 -1
  31. package/dist/lib/marks.d.ts +6 -0
  32. package/dist/lib/region.d.ts +46 -0
  33. package/dist/lib/rich-text.d.ts +44 -0
  34. package/dist/lib/sequence.d.ts +34 -0
  35. package/dist/lib/transcript.d.ts +28 -0
  36. package/dist/lib/waveform.d.ts +36 -0
  37. package/dist/map/fan.d.ts +15 -0
  38. package/dist/map/index.d.ts +3 -1
  39. package/dist/map/markers.d.ts +60 -0
  40. package/dist/map/route-map.d.ts +53 -1
  41. package/dist/map.js +626 -40
  42. package/dist/map.js.map +1 -1
  43. package/dist/panorama/gl.d.ts +16 -0
  44. package/dist/panorama/index.d.ts +2 -0
  45. package/dist/panorama/panorama-viewer.d.ts +56 -0
  46. package/dist/panorama/projection.d.ts +45 -0
  47. package/dist/panorama.js +657 -0
  48. package/dist/panorama.js.map +1 -0
  49. package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
  50. package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
  51. package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
  52. package/dist/run-DzyLrZlA.js.map +1 -0
  53. package/dist/testing.js +2 -2
  54. package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
  55. package/dist/theme-CFNi6WUO.js.map +1 -0
  56. package/dist/value-controls-D6O9TsM6.js +356 -0
  57. package/dist/value-controls-D6O9TsM6.js.map +1 -0
  58. package/dist/visual-cli.js +1 -1
  59. package/dist/visual.js +1 -1
  60. package/package.json +19 -4
  61. package/dist/geo-C0jcFp4q.js.map +0 -1
  62. package/dist/run-BqZGKhW9.js.map +0 -1
  63. package/dist/theme-BgTOESmN.js.map +0 -1
@@ -0,0 +1,55 @@
1
+ import { Easing, Rect } from '../lib/region';
2
+ import * as React from "react";
3
+ /** The tone a window is drawn in: a role colour, never a hue of its own. */
4
+ export type RegionTone = "neutral" | "info" | "success" | "warning" | "danger";
5
+ /** One window on the picture, in the picture's coordinates. */
6
+ export type EditableRegion = Rect & {
7
+ id: string;
8
+ label: string;
9
+ tone?: RegionTone;
10
+ };
11
+ export type RegionEditorProps = {
12
+ /** Names the editor: "Crop for the cover photo". Required. */
13
+ label: string;
14
+ /** The picture, drawn to fill the frame (an `<img className="size-full object-cover">`). */
15
+ children: React.ReactNode;
16
+ /** The picture's width and height, which are the units of every window. */
17
+ size: readonly [number, number];
18
+ regions: readonly EditableRegion[];
19
+ /** A window was changed and kept. Receives the whole list, edited. */
20
+ onChange: (regions: readonly EditableRegion[]) => void;
21
+ /** Which window is chosen (controlled); leave out to let the editor keep it. */
22
+ selectedId?: string | null;
23
+ onSelectedChange?: (id: string | null) => void;
24
+ /** Width over height every window keeps. */
25
+ aspect?: number;
26
+ /** The smallest a window may be. Default a twentieth of the picture. */
27
+ min?: {
28
+ w: number;
29
+ h: number;
30
+ };
31
+ /** Where windows may be. Default the whole picture. */
32
+ bounds?: Rect;
33
+ /** An arrow key's step, in the picture's units. Default a hundredth of its longer side. */
34
+ step?: number;
35
+ /** A drag on the empty picture draws a new window and calls this with it; the app adds it. Without it nothing can be drawn. */
36
+ onDraw?: (rect: Rect) => void;
37
+ /** "move": the first window is the start and the second the end; draws a line between them and a Watch button. */
38
+ mode?: "single" | "move";
39
+ /** Called as Watch plays, with the rectangle at `t` (0 to 1) and `t`. Also drawn by the editor. */
40
+ onPreview?: (rect: Rect, t: number) => void;
41
+ /** How long Watch takes, in milliseconds. Default 1500. */
42
+ duration?: number;
43
+ easing?: Easing;
44
+ /** Show a number field for each side of the chosen window under the picture. Default true. */
45
+ fields?: boolean;
46
+ /** The unit of the numbers: "px". */
47
+ unit?: string;
48
+ /** The windows as they began; with it a Reset appears while they differ. */
49
+ defaults?: readonly EditableRegion[];
50
+ className?: string;
51
+ };
52
+ /** A window said in words. */
53
+ export declare const describeRegion: (r: EditableRegion) => string;
54
+ /** Draw and move one or two named windows on a picture, with pointer, keyboard and numbers kept in step; aspect and bounds hold through all three; two windows make a from/to move with a Watch preview. */
55
+ export declare function RegionEditor({ label, children, size, regions, onChange, selectedId, onSelectedChange, aspect, min, bounds, step, onDraw, mode, onPreview, duration, easing, fields, unit, defaults, className, }: RegionEditorProps): React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { Grid } from '../lib/sequence';
2
+ import * as React from "react";
3
+ /** One window of the sequence. Windows tile the axis: each starts where the one before ends. */
4
+ export type SequenceItem = {
5
+ id: string;
6
+ label: string;
7
+ start: number;
8
+ end: number;
9
+ };
10
+ /** The room a cut has: the earliest and latest time it may take, with the reason for each end. */
11
+ export type CutRoom = {
12
+ min: number;
13
+ max: number;
14
+ minReason?: string;
15
+ maxReason?: string;
16
+ };
17
+ /** A cut's change: the two windows with their new edges. */
18
+ export type CutChange = {
19
+ before: SequenceItem;
20
+ after: SequenceItem;
21
+ };
22
+ export type SequenceTimelineProps = {
23
+ /** Names the sequence: "Film, windows in order". Required. */
24
+ label: string;
25
+ /** The windows in time order, each starting where the last ends. */
26
+ items: readonly SequenceItem[];
27
+ /** Pixels per second; leave out to fit the width. */
28
+ zoom?: number;
29
+ /** A cut was moved (dragged and let go, or stepped by key). The app applies it. */
30
+ onCutChange: (boundaryIndex: number, time: number, change: CutChange) => void;
31
+ /** The room for the cut between `items[i]` and `items[i + 1]`. Default: each window keeps `minLength`. */
32
+ room?: (boundaryIndex: number) => CutRoom;
33
+ /** The shortest a window may be when `room` is not given. Default 0.1 s. */
34
+ minLength?: number;
35
+ /** A beat grid: a step in seconds, or the beats' times. Cuts snap to it and arrows step along it. */
36
+ grid?: Grid;
37
+ /** The arrow-key step when there is no grid. Default 0.1 s. */
38
+ step?: number;
39
+ /** The windows chosen, as ids. */
40
+ selected?: readonly string[];
41
+ /** A window or a run (Shift+click) was chosen: ids in order. */
42
+ onSelectRange?: (ids: readonly string[]) => void;
43
+ /** The inside of a window, such as a thumbnail; it gets the window and whether it is chosen. */
44
+ renderItem?: (item: SequenceItem, selected: boolean) => React.ReactNode;
45
+ /** The height of the strip. Default 5rem. */
46
+ height?: string;
47
+ className?: string;
48
+ };
49
+ /** A gapless strip of windows whose cuts are dragged or stepped, snapping to a beat grid inside the room the app gives; each cut is a slider that announces both windows' new lengths; Shift+click chooses a run. */
50
+ export declare function SequenceTimeline({ label, items, zoom, onCutChange, room, minLength, grid, step, selected, onSelectRange, renderItem, height, className, }: SequenceTimelineProps): React.JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { TranscriptGroup, TranscriptPhrase } from '../lib/transcript';
2
+ import * as React from "react";
3
+ /** What a seek from the transcript says about where it came from. */
4
+ export type TranscriptSeek = {
5
+ phraseId: string; /** The word pressed, when a word was. */
6
+ wordIndex?: number;
7
+ };
8
+ export type TranscriptViewProps = {
9
+ /** Names the transcript. */
10
+ label: string;
11
+ /** Phrases by clip, in time order. */
12
+ groups: readonly TranscriptGroup[];
13
+ /** The player's time, seconds. */
14
+ time: number;
15
+ /** A word or phrase was pressed: seconds to play from, and which. */
16
+ onSeek: (time: number, from: TranscriptSeek) => void;
17
+ /** The mode shown: "original" (the words) or a key of the phrases' `alt`. Leave out to let the component hold it. */
18
+ mode?: string;
19
+ onModeChange?: (mode: string) => void;
20
+ /** Names for the modes: `{ translated: "English" }`. Default: the key, capitalised. */
21
+ modeLabels?: Readonly<Record<string, string>>;
22
+ /** Show one speaker's phrases: "all" or a speaker. Leave out to let the component hold it. */
23
+ speaker?: string;
24
+ onSpeakerChange?: (speaker: string) => void;
25
+ /** Scroll the heard phrase into view while the person has not scrolled away. Default true. */
26
+ follow?: boolean;
27
+ /** Say each phrase politely as it starts. Default false. */
28
+ announce?: boolean;
29
+ /** A control at the start of each phrase (a `PlayWindowButton`). */
30
+ renderPlay?: (phrase: TranscriptPhrase) => React.ReactNode;
31
+ /** Height of the scroll box once it is long enough to virtualise. Default 480. */
32
+ height?: number;
33
+ className?: string;
34
+ };
35
+ /** Timed text that follows playback: the heard word marked, any word or phrase pressed to play from, modes, speakers, follow and Jump to now. */
36
+ export declare function TranscriptView({ label, groups, time, onSeek, mode: controlledMode, onModeChange, modeLabels, speaker: controlledSpeaker, onSpeakerChange, follow, announce, renderPlay, height, className }: TranscriptViewProps): React.JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { Load } from './data-view';
2
+ import { Expanded } from './disclosure';
3
+ import * as React from "react";
4
+ /** A node's place in the tree, passed to `renderNode`. */
5
+ export type TreeNodeState = {
6
+ expanded: boolean;
7
+ selected: boolean;
8
+ level: number;
9
+ branch: boolean;
10
+ };
11
+ export type TreeProps<N> = {
12
+ /** Names the tree for assistive technology: "Folders". Required. */
13
+ label: string;
14
+ /** The top level, as one read: the skeleton, the failure and Try again come from `DataView`'s `Load`. */
15
+ roots: Load<readonly N[]>;
16
+ /** The children of an open node, as a hook (`useLoad` inside). Called only while the node is open. */
17
+ useChildren: (node: N) => Load<readonly N[]>;
18
+ /** A node's key, unique in the whole tree: a path, an id. */
19
+ nodeKey: (node: N) => string;
20
+ /** A node's name: shown, and what type-ahead matches. */
21
+ nodeLabel: (node: N) => string;
22
+ /** Whether a node can open. Default: every node can. */
23
+ isBranch?: (node: N) => boolean;
24
+ /** What a row shows after the icon. Default: the name, cut with an ellipsis. */
25
+ renderNode?: (node: N, state: TreeNodeState) => React.ReactNode;
26
+ /** The chosen node's key, or `null`. */
27
+ selected: string | null;
28
+ /** A node was chosen. */
29
+ onSelect: (key: string, node: N) => void;
30
+ /** Which nodes are open; from `useExpanded`, optionally in the URL. */
31
+ expanded: Expanded;
32
+ /** The skeleton row while a node's children load. Default: a muted bar. */
33
+ loadingRow?: React.ReactNode;
34
+ /** What an open node with nothing in it says: "No folders". Required, so an empty branch is never blank. */
35
+ emptyRow: string;
36
+ /** The tallest the tree may be before it scrolls, as a CSS length. Default 24rem. */
37
+ height?: string;
38
+ className?: string;
39
+ };
40
+ /** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
41
+ export declare function Tree<N>({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, expanded, loadingRow, emptyRow, height, className }: TreeProps<N>): React.JSX.Element;
@@ -0,0 +1,66 @@
1
+ import { DecodedAudio, WaveformPeaks } from '../lib/waveform';
2
+ import * as React from "react";
3
+ /** What a mark is, which sets how its line is drawn. */
4
+ export type WaveformMarkKind = "beat" | "bar" | "downbeat" | "chapter";
5
+ /** A moment on the waveform: a beat, a bar line, the first downbeat, a chapter. */
6
+ export type WaveformMark = {
7
+ time: number;
8
+ label?: string;
9
+ kind?: WaveformMarkKind; /** In the list for screen readers. Default: yes, except beats. */
10
+ listed?: boolean;
11
+ };
12
+ /** Shading tones for spans. */
13
+ export type WaveformTone = "neutral" | "info" | "success" | "warning" | "danger";
14
+ /** A stretch of the file: voice, silence, a chosen part. */
15
+ export type WaveformSpan = {
16
+ from: number;
17
+ to: number;
18
+ label: string;
19
+ tone?: WaveformTone;
20
+ };
21
+ type Common = {
22
+ /** Names the waveform: "Waveform of the interview". */
23
+ label: string;
24
+ /** Seconds. Needed with `peaks`; with `source` it defaults to the decoded file's. */
25
+ duration?: number;
26
+ /** The playhead, seconds. */
27
+ time: number;
28
+ /** A click, a drag or a key moved the playhead. */
29
+ onSeek: (time: number) => void;
30
+ marks?: readonly WaveformMark[];
31
+ spans?: readonly WaveformSpan[];
32
+ /** A picture under the plot on the same x axis (a spectrogram `<img>`): it is stretched to the file's length and follows the zoom. */
33
+ underlay?: React.ReactNode;
34
+ /** The chosen range, seconds, or null. Leave out to let the component hold it. */
35
+ range?: readonly [number, number] | null;
36
+ onRangeChange?: (range: [number, number] | null) => void;
37
+ /** Seconds an arrow key moves. Default 5. */
38
+ step?: number;
39
+ /** Seconds Shift or a Page key moves. Default 30. */
40
+ bigStep?: number;
41
+ /** The part of the file shown at first, seconds (zoomed in). The component keeps the view after that. */
42
+ defaultView?: readonly [number, number];
43
+ /** How many peaks a decoded file is reduced to. Default 2000. */
44
+ buckets?: number;
45
+ /** Turns a decoded file into samples. Default: the browser's `AudioContext.decodeAudioData`. */
46
+ decode?: (data: ArrayBuffer) => Promise<DecodedAudio>;
47
+ /** The words of the reading state; defaults say "Reading the waveform". */
48
+ words?: {
49
+ running: string;
50
+ finished: string;
51
+ failed: string;
52
+ };
53
+ disabled?: boolean;
54
+ className?: string;
55
+ };
56
+ /** `peaks` or a `source` to decode: one of them, so a waveform with nothing to draw cannot be written. */
57
+ export type WaveformProps = Common & ({
58
+ peaks: WaveformPeaks;
59
+ source?: never;
60
+ } | {
61
+ source: string | Blob;
62
+ peaks?: never;
63
+ });
64
+ /** An audio waveform with marks, spans and a playhead: one slider you click, drag or key to seek, zoom, and a range to select. */
65
+ export declare function Waveform({ label, peaks, source, duration: given, time, onSeek, marks, spans, underlay, range: controlledRange, onRangeChange, step, bigStep, defaultView, buckets, decode, words, disabled, className }: WaveformProps): React.JSX.Element;
66
+ export {};
@@ -0,0 +1,290 @@
1
+ import * as React from "react";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ // src/lib/geo.ts
4
+ var RAD = Math.PI / 180;
5
+ var EARTH_RADIUS_M = 6371e3;
6
+ /** Great-circle distance between two positions, in metres. */
7
+ function distance([lat1, lng1], [lat2, lng2]) {
8
+ const a = Math.sin((lat2 - lat1) * RAD / 2) ** 2 + Math.cos(lat1 * RAD) * Math.cos(lat2 * RAD) * Math.sin((lng2 - lng1) * RAD / 2) ** 2;
9
+ return 2 * EARTH_RADIUS_M * Math.asin(Math.sqrt(a));
10
+ }
11
+ /** The direction from `a` to `b` in degrees clockwise from north (0 to 360), for neighbouring points. */
12
+ function bearing([lat1, lng1], [lat2, lng2]) {
13
+ const dx = (lng2 - lng1) * Math.cos((lat1 + lat2) / 2 * Math.PI / 180);
14
+ const dy = lat2 - lat1;
15
+ return (Math.atan2(dx, dy) * 180 / Math.PI + 360) % 360;
16
+ }
17
+ /** The running distance along a route at each point, in metres, starting at 0. */
18
+ function cumulative(points) {
19
+ const out = points.length ? [0] : [];
20
+ for (let i = 1; i < points.length; i++) out.push(out[i - 1] + distance(points[i - 1], points[i]));
21
+ return out;
22
+ }
23
+ /** The length of a route in metres. */
24
+ function length(points) {
25
+ let total = 0;
26
+ for (let i = 1; i < points.length; i++) total += distance(points[i - 1], points[i]);
27
+ return total;
28
+ }
29
+ /** The south-west and north-east corners that hold every point, or null for none. */
30
+ function bounds(points) {
31
+ if (!points.length) return null;
32
+ let south = Infinity;
33
+ let north = -Infinity;
34
+ let west = Infinity;
35
+ let east = -Infinity;
36
+ for (const [lat, lng] of points) {
37
+ if (lat < south) south = lat;
38
+ if (lat > north) north = lat;
39
+ if (lng < west) west = lng;
40
+ if (lng > east) east = lng;
41
+ }
42
+ return [[south, west], [north, east]];
43
+ }
44
+ /** The position `metres` along a route (clamped to its ends), by linear interpolation, or null for no points. */
45
+ function pointAlong(points, metres, along = cumulative(points)) {
46
+ if (!points.length) return null;
47
+ const total = along[along.length - 1];
48
+ const d = Math.min(Math.max(metres, 0), total);
49
+ if (points.length === 1 || total === 0) return points[0];
50
+ let lo = 1;
51
+ let hi = points.length - 1;
52
+ while (lo < hi) {
53
+ const mid = lo + hi >> 1;
54
+ if (along[mid] < d) lo = mid + 1;
55
+ else hi = mid;
56
+ }
57
+ const [p, q] = [points[lo - 1], points[lo]];
58
+ const t = (d - along[lo - 1]) / (along[lo] - along[lo - 1] || 1);
59
+ return [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t];
60
+ }
61
+ /**
62
+ * `count` positions evenly spaced by distance along a route (the ends skipped), each with the
63
+ * direction of travel there. The direction is smoothed: the bearing from a point a fraction
64
+ * (`window`) of the spacing before to one the same distance after, so GPS jitter and a tight bend
65
+ * do not turn a chevron sideways.
66
+ */
67
+ function arrows(points, count = 5, window = .4) {
68
+ if (points.length < 2 || count < 1) return [];
69
+ const along = cumulative(points);
70
+ const total = along[along.length - 1];
71
+ if (total === 0) return [];
72
+ const spacing = total / (count + 1);
73
+ const half = spacing * window;
74
+ return Array.from({ length: count }, (_, i) => {
75
+ const target = spacing * (i + 1);
76
+ const before = pointAlong(points, target - half, along);
77
+ const after = pointAlong(points, target + half, along);
78
+ return {
79
+ position: pointAlong(points, target, along),
80
+ bearing: bearing(before, after)
81
+ };
82
+ });
83
+ }
84
+ /** The first and last positions, and whether they are within `loopWithin` metres of each other (a loop), or null for no route. */
85
+ function ends(points, loopWithin = 50) {
86
+ if (!points.length) return null;
87
+ const start = points[0];
88
+ const finish = points[points.length - 1];
89
+ return {
90
+ start,
91
+ finish,
92
+ loop: distance(start, finish) <= loopWithin
93
+ };
94
+ }
95
+ /** The index of the point nearest `position`, for "where on the route is this?". */
96
+ function nearest(points, position) {
97
+ let best = -1;
98
+ let bestD = Infinity;
99
+ points.forEach((p, i) => {
100
+ const d = distance(p, position);
101
+ if (d < bestD) {
102
+ bestD = d;
103
+ best = i;
104
+ }
105
+ });
106
+ return best;
107
+ }
108
+ /** The part of a route between two distances along it (metres, clamped, either order): the cut ends and every point between. Empty for no route. */
109
+ function slice(points, from, to, along = cumulative(points)) {
110
+ if (!points.length) return [];
111
+ const [a, b] = from <= to ? [from, to] : [to, from];
112
+ const start = pointAlong(points, a, along);
113
+ const end = pointAlong(points, b, along);
114
+ const lo = Math.max(a, 0);
115
+ const hi = Math.min(b, along[along.length - 1]);
116
+ return [
117
+ start,
118
+ ...points.filter((_, i) => along[i] > lo && along[i] < hi),
119
+ end
120
+ ];
121
+ }
122
+ /**
123
+ * The nearest point on a route to `position`, not only its vertices: where it lies, how far along the
124
+ * route that is, and how far `position` is from the route. The inverse of `pointAlong` (a cursor on a
125
+ * map is a distance on a chart). Each leg is flattened around its own latitude, which is exact enough
126
+ * for any leg a recording has; `index` is the leg's first point. Null for fewer than one point.
127
+ */
128
+ function snap(points, position, along = cumulative(points)) {
129
+ if (!points.length) return null;
130
+ if (points.length === 1) return {
131
+ position: points[0],
132
+ metres: 0,
133
+ offset: distance(points[0], position),
134
+ index: 0
135
+ };
136
+ let best = null;
137
+ for (let i = 1; i < points.length; i++) {
138
+ const [p, q] = [points[i - 1], points[i]];
139
+ const k = Math.cos((p[0] + q[0]) / 2 * Math.PI / 180);
140
+ const [dx, dy] = [(q[1] - p[1]) * k, q[0] - p[0]];
141
+ const len2 = dx * dx + dy * dy;
142
+ const t = len2 === 0 ? 0 : Math.min(1, Math.max(0, ((position[1] - p[1]) * k * dx + (position[0] - p[0]) * dy) / len2));
143
+ const at = [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t];
144
+ const offset = distance(at, position);
145
+ if (!best || offset < best.offset) best = {
146
+ position: at,
147
+ metres: along[i - 1] + (along[i] - along[i - 1]) * t,
148
+ offset,
149
+ index: i - 1
150
+ };
151
+ }
152
+ return best;
153
+ }
154
+ /** Route geometry helpers: `geo.distance`, `bearing`, `length`, `cumulative`, `bounds`, `pointAlong`, `snap` (its inverse), `slice`, `arrows`, `ends`, `nearest`. */
155
+ var geo = {
156
+ distance,
157
+ bearing,
158
+ cumulative,
159
+ length,
160
+ bounds,
161
+ pointAlong,
162
+ snap,
163
+ slice,
164
+ arrows,
165
+ ends,
166
+ nearest
167
+ };
168
+ // src/components/cursor.tsx
169
+ var EMPTY = {
170
+ at: null,
171
+ source: null,
172
+ owner: null
173
+ };
174
+ var CursorStore = class {
175
+ pointer = null;
176
+ playback = null;
177
+ listeners = /* @__PURE__ */ new Set();
178
+ snapshot = EMPTY;
179
+ subscribe = (fn) => {
180
+ this.listeners.add(fn);
181
+ return () => void this.listeners.delete(fn);
182
+ };
183
+ publish() {
184
+ const e = this.pointer ?? this.playback;
185
+ const owner = this.pointer ? "pointer" : this.playback ? "playback" : null;
186
+ if (e?.at === this.snapshot.at && e?.source === this.snapshot.source && owner === this.snapshot.owner) return;
187
+ this.snapshot = e ? {
188
+ at: e.at,
189
+ source: e.source,
190
+ owner
191
+ } : EMPTY;
192
+ for (const l of this.listeners) l();
193
+ }
194
+ /** A pointer or key over a member. `null` means it left: it clears only if the pointer was this member's, so a stale leave cannot remove another member's position. */
195
+ setPointer(at, source) {
196
+ if (at === null) {
197
+ if (this.pointer?.source !== source) return;
198
+ this.pointer = null;
199
+ } else this.pointer = {
200
+ at,
201
+ source
202
+ };
203
+ this.publish();
204
+ }
205
+ setPlayback(at, source) {
206
+ this.playback = at === null ? null : {
207
+ at,
208
+ source
209
+ };
210
+ this.publish();
211
+ }
212
+ };
213
+ var Scope = React.createContext(null);
214
+ /** Holds one cursor position for the charts, map and seek bar inside it, with a throttled polite announcement of where a pointer or key has put it. */
215
+ function CursorScope({ children, format, announceEvery = 1e3 }) {
216
+ const store = React.useRef(null);
217
+ store.current ??= new CursorStore();
218
+ return /* @__PURE__ */ jsxs(Scope.Provider, {
219
+ value: store.current,
220
+ children: [children, format && /* @__PURE__ */ jsx(CursorAnnouncer, {
221
+ store: store.current,
222
+ format,
223
+ every: announceEvery
224
+ })]
225
+ });
226
+ }
227
+ /** The live region: the latest pointer position, at most once per `every` ms (a throttle, so a pointer that never rests is still announced). */
228
+ function CursorAnnouncer({ store, format, every }) {
229
+ const snap = React.useSyncExternalStore(store.subscribe, () => store.snapshot, () => EMPTY);
230
+ const [text, setText] = React.useState("");
231
+ const latest = React.useRef({
232
+ snap,
233
+ format
234
+ });
235
+ latest.current = {
236
+ snap,
237
+ format
238
+ };
239
+ const last = React.useRef(0);
240
+ const timer = React.useRef(void 0);
241
+ React.useEffect(() => {
242
+ if (snap.owner !== "pointer" || snap.at === null) return;
243
+ const speak = () => {
244
+ timer.current = void 0;
245
+ last.current = Date.now();
246
+ const { snap: s, format: f } = latest.current;
247
+ if (s.owner === "pointer" && s.at !== null) setText(f(s.at));
248
+ };
249
+ const wait = last.current + every - Date.now();
250
+ if (wait <= 0) speak();
251
+ else timer.current ??= window.setTimeout(speak, wait);
252
+ }, [snap, every]);
253
+ React.useEffect(() => () => window.clearTimeout(timer.current), []);
254
+ return /* @__PURE__ */ jsx("p", {
255
+ role: "status",
256
+ "aria-live": "polite",
257
+ className: "sr-only",
258
+ children: text
259
+ });
260
+ }
261
+ /**
262
+ * Join the nearest `CursorScope` as one member. Returns null outside a scope, so a component can take a
263
+ * `cursor` prop and do nothing when the app has not set one up. `source` is this member's id; the
264
+ * default is a unique one.
265
+ */
266
+ function useSharedCursor(source) {
267
+ const store = React.useContext(Scope);
268
+ const own = React.useId();
269
+ const id = source ?? own;
270
+ const subscribe = React.useCallback((fn) => store ? store.subscribe(fn) : () => {}, [store]);
271
+ const snap = React.useSyncExternalStore(subscribe, () => store?.snapshot ?? EMPTY, () => EMPTY);
272
+ const setPointer = React.useCallback((at) => store?.setPointer(at, id), [store, id]);
273
+ const setPlayback = React.useCallback((at) => store?.setPlayback(at, id), [store, id]);
274
+ return React.useMemo(() => store ? {
275
+ ...snap,
276
+ source: id,
277
+ other: snap.at !== null && snap.source !== id ? snap.at : null,
278
+ setPointer,
279
+ setPlayback
280
+ } : null, [
281
+ store,
282
+ snap,
283
+ id,
284
+ setPointer,
285
+ setPlayback
286
+ ]);
287
+ }
288
+ export { useSharedCursor as n, geo as r, CursorScope as t };
289
+
290
+ //# sourceMappingURL=cursor-DDGBPiTJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-DDGBPiTJ.js","names":[],"sources":["../src/lib/geo.ts","../src/components/cursor.tsx"],"sourcesContent":["// Geometry for routes on a map (strata-react issue #80; the helpers jonathanburnhams.com wrote by\n// hand for its activity maps). Pure functions on `[latitude, longitude]` pairs in degrees, no map\n// library, so they live in the main entry and an app can use them for a text alternative or a\n// profile without installing the map's peer.\n//\n// Distances are great-circle (haversine) on a 6,371 km sphere, which is within half a percent of\n// the true figure at any route length a person runs, rides or drives. Bearings use a flat\n// approximation between neighbouring points (the longitude scaled by the cosine of the mean\n// latitude), fine for the short hops a chevron or a heading needs and wrong for a leg of hundreds\n// of kilometres: `bearing` is for neighbouring points, not for a flight.\n\n/** A position: `[latitude, longitude]` in degrees. */\nexport type LatLng = readonly [lat: number, lng: number];\n\nconst RAD = Math.PI / 180;\nconst EARTH_RADIUS_M = 6_371_000;\n\n/** Great-circle distance between two positions, in metres. */\nexport function distance([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number {\n const a = Math.sin(((lat2 - lat1) * RAD) / 2) ** 2 + Math.cos(lat1 * RAD) * Math.cos(lat2 * RAD) * Math.sin(((lng2 - lng1) * RAD) / 2) ** 2;\n return 2 * EARTH_RADIUS_M * Math.asin(Math.sqrt(a));\n}\n\n/** The direction from `a` to `b` in degrees clockwise from north (0 to 360), for neighbouring points. */\nexport function bearing([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number {\n const dx = (lng2 - lng1) * Math.cos((((lat1 + lat2) / 2) * Math.PI) / 180);\n const dy = lat2 - lat1;\n return ((Math.atan2(dx, dy) * 180) / Math.PI + 360) % 360;\n}\n\n/** The running distance along a route at each point, in metres, starting at 0. */\nexport function cumulative(points: readonly LatLng[]): number[] {\n const out = points.length ? [0] : [];\n for (let i = 1; i < points.length; i++) out.push(out[i - 1] + distance(points[i - 1], points[i]));\n return out;\n}\n\n/** The length of a route in metres. */\nexport function length(points: readonly LatLng[]): number {\n let total = 0;\n for (let i = 1; i < points.length; i++) total += distance(points[i - 1], points[i]);\n return total;\n}\n\n/** The south-west and north-east corners that hold every point, or null for none. */\nexport function bounds(points: readonly LatLng[]): [LatLng, LatLng] | null {\n if (!points.length) return null;\n let south = Infinity;\n let north = -Infinity;\n let west = Infinity;\n let east = -Infinity;\n for (const [lat, lng] of points) {\n if (lat < south) south = lat;\n if (lat > north) north = lat;\n if (lng < west) west = lng;\n if (lng > east) east = lng;\n }\n return [\n [south, west],\n [north, east],\n ];\n}\n\n/** The position `metres` along a route (clamped to its ends), by linear interpolation, or null for no points. */\nexport function pointAlong(points: readonly LatLng[], metres: number, along: readonly number[] = cumulative(points)): LatLng | null {\n if (!points.length) return null;\n const total = along[along.length - 1];\n const d = Math.min(Math.max(metres, 0), total);\n if (points.length === 1 || total === 0) return points[0];\n let lo = 1;\n let hi = points.length - 1;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (along[mid] < d) lo = mid + 1;\n else hi = mid;\n }\n const [p, q] = [points[lo - 1], points[lo]];\n const t = (d - along[lo - 1]) / (along[lo] - along[lo - 1] || 1);\n return [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t];\n}\n\n/**\n * `count` positions evenly spaced by distance along a route (the ends skipped), each with the\n * direction of travel there. The direction is smoothed: the bearing from a point a fraction\n * (`window`) of the spacing before to one the same distance after, so GPS jitter and a tight bend\n * do not turn a chevron sideways.\n */\nexport function arrows(points: readonly LatLng[], count = 5, window = 0.4): { position: LatLng; bearing: number }[] {\n if (points.length < 2 || count < 1) return [];\n const along = cumulative(points);\n const total = along[along.length - 1];\n if (total === 0) return [];\n const spacing = total / (count + 1);\n const half = spacing * window;\n return Array.from({ length: count }, (_, i) => {\n const target = spacing * (i + 1);\n const before = pointAlong(points, target - half, along)!;\n const after = pointAlong(points, target + half, along)!;\n return { position: pointAlong(points, target, along)!, bearing: bearing(before, after) };\n });\n}\n\n/** The first and last positions, and whether they are within `loopWithin` metres of each other (a loop), or null for no route. */\nexport function ends(points: readonly LatLng[], loopWithin = 50): { start: LatLng; finish: LatLng; loop: boolean } | null {\n if (!points.length) return null;\n const start = points[0];\n const finish = points[points.length - 1];\n return { start, finish, loop: distance(start, finish) <= loopWithin };\n}\n\n/** The index of the point nearest `position`, for \"where on the route is this?\". */\nexport function nearest(points: readonly LatLng[], position: LatLng): number {\n let best = -1;\n let bestD = Infinity;\n points.forEach((p, i) => {\n const d = distance(p, position);\n if (d < bestD) {\n bestD = d;\n best = i;\n }\n });\n return best;\n}\n\n/** The part of a route between two distances along it (metres, clamped, either order): the cut ends and every point between. Empty for no route. */\nexport function slice(points: readonly LatLng[], from: number, to: number, along: readonly number[] = cumulative(points)): LatLng[] {\n if (!points.length) return [];\n const [a, b] = from <= to ? [from, to] : [to, from];\n const start = pointAlong(points, a, along)!;\n const end = pointAlong(points, b, along)!;\n const lo = Math.max(a, 0);\n const hi = Math.min(b, along[along.length - 1]);\n const inside = points.filter((_, i) => along[i] > lo && along[i] < hi);\n return [start, ...inside, end];\n}\n\n/**\n * The nearest point on a route to `position`, not only its vertices: where it lies, how far along the\n * route that is, and how far `position` is from the route. The inverse of `pointAlong` (a cursor on a\n * map is a distance on a chart). Each leg is flattened around its own latitude, which is exact enough\n * for any leg a recording has; `index` is the leg's first point. Null for fewer than one point.\n */\nexport function snap(points: readonly LatLng[], position: LatLng, along: readonly number[] = cumulative(points)): { position: LatLng; metres: number; offset: number; index: number } | null {\n if (!points.length) return null;\n if (points.length === 1) return { position: points[0], metres: 0, offset: distance(points[0], position), index: 0 };\n let best: { position: LatLng; metres: number; offset: number; index: number } | null = null;\n for (let i = 1; i < points.length; i++) {\n const [p, q] = [points[i - 1], points[i]];\n const k = Math.cos((((p[0] + q[0]) / 2) * Math.PI) / 180);\n const [dx, dy] = [(q[1] - p[1]) * k, q[0] - p[0]];\n const len2 = dx * dx + dy * dy;\n const t = len2 === 0 ? 0 : Math.min(1, Math.max(0, (((position[1] - p[1]) * k) * dx + (position[0] - p[0]) * dy) / len2));\n const at: LatLng = [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t];\n const offset = distance(at, position);\n if (!best || offset < best.offset) best = { position: at, metres: along[i - 1] + (along[i] - along[i - 1]) * t, offset, index: i - 1 };\n }\n return best;\n}\n\n/** Route geometry helpers: `geo.distance`, `bearing`, `length`, `cumulative`, `bounds`, `pointAlong`, `snap` (its inverse), `slice`, `arrows`, `ends`, `nearest`. */\nexport const geo = { distance, bearing, cumulative, length, bounds, pointAlong, snap, slice, arrows, ends, nearest };\n","import * as React from \"react\";\n\n// A shared cursor: one position that a map, several charts and a seek bar all show at once (strata-react\n// issue #184, from strata-360, where the cursor on the elevation and pace charts is the marker on the\n// route). Each of those components already draws one position well; what an app lacked was the wiring.\n//\n// One position in a canonical unit the app chooses (metres along a route, or seconds), and every member\n// says how its own x maps to it (`CursorMapping`; the identity when they already agree). The rules:\n//\n// - **A writer never reacts to its own writes.** Every member has a `source` id, and a position whose\n// source is its own is not drawn back at it (a chart's own pointer already draws its own rule).\n// - **Two owners, and the pointer wins.** Playback sets the cursor (sixty times a second); a pointer or\n// key over any member sets it too, and holds it until it leaves, and then playback's position is\n// still there. Stored as two entries, not one value, so \"pointer left\" has something to fall back to.\n// - **It is not announced as it moves.** The scope has one polite live region, written at most once a\n// second and only for a pointer or key (never playback): sixty announcements a second are worse than\n// silence (§3.22).\n// - **A store, not state in the scope.** Members subscribe to it; the scope's children do not render\n// when the cursor moves, only the members that read it.\n//\n// Checked: React Aria has no shared-pointer part; `useSyncExternalStore` is React's own.\n\n/** Who set the cursor: a pointer or key over a member, or playback (a player's clock). */\nexport type CursorOwner = \"pointer\" | \"playback\";\n\n/** How a member's own x relates to the scope's unit. Both default to the identity. */\nexport type CursorMapping = {\n /** From this member's x to the scope's unit (a chart in seconds in a scope in metres: look it up in the series). */\n toCursor?: (x: number) => number;\n /** From the scope's unit to this member's x. */\n fromCursor?: (at: number) => number;\n};\n\ntype Entry = { at: number; source: string };\ntype Snapshot = {\n /** The position now: the pointer's while there is one, else playback's; null when neither is set. */\n at: number | null;\n /** Who wrote `at`; a member ignores a position it wrote. */\n source: string | null;\n owner: CursorOwner | null;\n};\n\nconst EMPTY: Snapshot = { at: null, source: null, owner: null };\n\nclass CursorStore {\n private pointer: Entry | null = null;\n private playback: Entry | null = null;\n private listeners = new Set<() => void>();\n snapshot: Snapshot = EMPTY;\n subscribe = (fn: () => void) => {\n this.listeners.add(fn);\n return () => void this.listeners.delete(fn);\n };\n private publish() {\n const e = this.pointer ?? this.playback;\n const owner: CursorOwner | null = this.pointer ? \"pointer\" : this.playback ? \"playback\" : null;\n if (e?.at === this.snapshot.at && e?.source === this.snapshot.source && owner === this.snapshot.owner) return;\n this.snapshot = e ? { at: e.at, source: e.source, owner } : EMPTY;\n for (const l of this.listeners) l();\n }\n /** A pointer or key over a member. `null` means it left: it clears only if the pointer was this member's, so a stale leave cannot remove another member's position. */\n setPointer(at: number | null, source: string) {\n if (at === null) {\n if (this.pointer?.source !== source) return;\n this.pointer = null;\n } else this.pointer = { at, source };\n this.publish();\n }\n setPlayback(at: number | null, source: string) {\n this.playback = at === null ? null : { at, source };\n this.publish();\n }\n}\n\nconst Scope = React.createContext<CursorStore | null>(null);\n\nexport type CursorScopeProps = {\n children: React.ReactNode;\n /** Words for the position in the scope's unit (\"12.4 km along\", \"1:23\"), for the polite announcement. Without it nothing is announced. */\n format?: (at: number) => string;\n /** Milliseconds between announcements. Default 1000. */\n announceEvery?: number;\n};\n\n/** Holds one cursor position for the charts, map and seek bar inside it, with a throttled polite announcement of where a pointer or key has put it. */\nexport function CursorScope({ children, format, announceEvery = 1000 }: CursorScopeProps) {\n const store = React.useRef<CursorStore | null>(null);\n store.current ??= new CursorStore();\n return (\n <Scope.Provider value={store.current}>\n {children}\n {format && <CursorAnnouncer store={store.current} format={format} every={announceEvery} />}\n </Scope.Provider>\n );\n}\n\n/** The live region: the latest pointer position, at most once per `every` ms (a throttle, so a pointer that never rests is still announced). */\nfunction CursorAnnouncer({ store, format, every }: { store: CursorStore; format: (at: number) => string; every: number }) {\n const snap = React.useSyncExternalStore(store.subscribe, () => store.snapshot, () => EMPTY);\n const [text, setText] = React.useState(\"\");\n const latest = React.useRef({ snap, format });\n latest.current = { snap, format };\n const last = React.useRef(0);\n const timer = React.useRef<number | undefined>(undefined);\n React.useEffect(() => {\n // Playback moves the cursor every frame and is never spoken; a pointer leaving says nothing.\n if (snap.owner !== \"pointer\" || snap.at === null) return;\n const speak = () => {\n timer.current = undefined;\n last.current = Date.now();\n const { snap: s, format: f } = latest.current;\n if (s.owner === \"pointer\" && s.at !== null) setText(f(s.at));\n };\n const wait = last.current + every - Date.now();\n if (wait <= 0) speak();\n else timer.current ??= window.setTimeout(speak, wait);\n }, [snap, every]);\n React.useEffect(() => () => window.clearTimeout(timer.current), []);\n return (\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {text}\n </p>\n );\n}\n\n/** What a member reads and writes. */\nexport type SharedCursor = Snapshot & {\n /** This member's own id: positions it writes are not drawn back at it. */\n source: string;\n /** The position another member (or playback) put there, in the scope's unit; null when none or when this member wrote it. */\n other: number | null;\n /** The pointer or keyboard is at `at` over this member (the scope's unit). `null`: it left. */\n setPointer: (at: number | null) => void;\n /** Playback is at `at` (the scope's unit). Call it from the player's clock; `null` when it stops. */\n setPlayback: (at: number | null) => void;\n};\n\n/**\n * Join the nearest `CursorScope` as one member. Returns null outside a scope, so a component can take a\n * `cursor` prop and do nothing when the app has not set one up. `source` is this member's id; the\n * default is a unique one.\n */\nexport function useSharedCursor(source?: string): SharedCursor | null {\n const store = React.useContext(Scope);\n const own = React.useId();\n const id = source ?? own;\n const subscribe = React.useCallback((fn: () => void) => (store ? store.subscribe(fn) : () => {}), [store]);\n const snap = React.useSyncExternalStore(subscribe, () => store?.snapshot ?? EMPTY, () => EMPTY);\n const setPointer = React.useCallback((at: number | null) => store?.setPointer(at, id), [store, id]);\n const setPlayback = React.useCallback((at: number | null) => store?.setPlayback(at, id), [store, id]);\n return React.useMemo(\n () => (store ? { ...snap, source: id, other: snap.at !== null && snap.source !== id ? snap.at : null, setPointer, setPlayback } : null),\n [store, snap, id, setPointer, setPlayback],\n );\n}\n"],"mappings":";;;AAcA,IAAM,MAAM,KAAK,KAAK;AACtB,IAAM,iBAAiB;;AAGvB,SAAgB,SAAS,CAAC,MAAM,OAAe,CAAC,MAAM,OAAuB;CAC3E,MAAM,IAAI,KAAK,KAAM,OAAO,QAAQ,MAAO,CAAC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,IAAI,KAAK,IAAI,OAAO,GAAG,IAAI,KAAK,KAAM,OAAO,QAAQ,MAAO,CAAC,KAAK;CAC1I,OAAO,IAAI,iBAAiB,KAAK,KAAK,KAAK,KAAK,CAAC,CAAC;AACpD;;AAGA,SAAgB,QAAQ,CAAC,MAAM,OAAe,CAAC,MAAM,OAAuB;CAC1E,MAAM,MAAM,OAAO,QAAQ,KAAK,KAAO,OAAO,QAAQ,IAAK,KAAK,KAAM,GAAG;CACzE,MAAM,KAAK,OAAO;CAClB,QAAS,KAAK,MAAM,IAAI,EAAE,IAAI,MAAO,KAAK,KAAK,OAAO;AACxD;;AAGA,SAAgB,WAAW,QAAqC;CAC9D,MAAM,MAAM,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC;CACnC,KA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