strata-react 1.3.25 → 1.3.27
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 +1 -0
- package/UPGRADING.md +4 -0
- package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
- package/dist/api-types-cli.js +4 -3
- package/dist/api-types-cli.js.map +1 -1
- package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
- package/dist/api-types.js +3 -1
- package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
- package/dist/button-CYXjU-fs.js.map +1 -0
- package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
- package/dist/cursor-Cwyvgwsw.js.map +1 -0
- package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
- package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
- package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
- package/dist/field-DBCsFIng.js.map +1 -0
- package/dist/{follow-BTPs49FP.js → follow-CXQsL86O.js} +2 -2
- package/dist/follow-CXQsL86O.js.map +1 -0
- package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
- package/dist/generate-BkWhh4k4.js.map +1 -0
- package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
- package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
- package/dist/hls.js +5 -4
- package/dist/hls.js.map +1 -1
- package/dist/index.d.ts +5401 -142
- package/dist/index.js +1072 -227
- package/dist/index.js.map +1 -1
- package/dist/map.d.ts +184 -0
- package/dist/map.js +21 -17
- package/dist/map.js.map +1 -1
- package/dist/media-player-BETa3P7K.d.ts +758 -0
- package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
- package/dist/microphone-76skMt6i.js.map +1 -0
- package/dist/microphone-DDOnQHxf.d.ts +237 -0
- package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
- package/dist/migrate-cli.js +8 -6
- package/dist/migrate-cli.js.map +1 -1
- package/dist/panorama.d.ts +102 -0
- package/dist/panorama.js +18 -15
- package/dist/panorama.js.map +1 -1
- package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
- package/dist/run-D_Ic1jE7.js.map +1 -0
- package/dist/scene.d.ts +147 -0
- package/dist/scene.js +15 -13
- package/dist/scene.js.map +1 -1
- package/dist/testing.d.ts +468 -0
- package/dist/testing.js +11 -3
- package/dist/testing.js.map +1 -1
- package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
- package/dist/theme-1oOSMj_D.js.map +1 -0
- package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
- package/dist/tooltip-BosfsWYh.js.map +1 -0
- package/dist/types-B3TsF0Ey.d.ts +241 -0
- package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
- package/dist/value-controls-5u7sD_wG.js.map +1 -0
- package/dist/{viewer-input-CHU0Hx4A.js → viewer-input-3Qa-o35k.js} +3 -2
- package/dist/{viewer-input-CHU0Hx4A.js.map → viewer-input-3Qa-o35k.js.map} +1 -1
- package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
- package/dist/visual-cli.js +5 -4
- package/dist/visual-cli.js.map +1 -1
- package/dist/visual.d.ts +105 -0
- package/dist/visual.js +4 -3
- package/dist/visual.js.map +1 -1
- package/package.json +24 -19
- package/dist/api-types/index.d.ts +0 -1
- package/dist/button-KGJI6jQr.js.map +0 -1
- package/dist/components/active-list.d.ts +0 -46
- package/dist/components/alert.d.ts +0 -17
- package/dist/components/app-shell.d.ts +0 -32
- package/dist/components/async-button.d.ts +0 -48
- package/dist/components/auto-recorder.d.ts +0 -67
- package/dist/components/book-viewer.d.ts +0 -50
- package/dist/components/box-overlay.d.ts +0 -44
- package/dist/components/boxed-picture.d.ts +0 -34
- package/dist/components/button.d.ts +0 -45
- package/dist/components/byte-view.d.ts +0 -32
- package/dist/components/checkbox.d.ts +0 -39
- package/dist/components/choice-grid.d.ts +0 -42
- package/dist/components/commands.d.ts +0 -104
- package/dist/components/compare-audio.d.ts +0 -30
- package/dist/components/compare-grid.d.ts +0 -24
- package/dist/components/compare-parts.d.ts +0 -90
- package/dist/components/compare-regions.d.ts +0 -37
- package/dist/components/compare-text.d.ts +0 -32
- package/dist/components/compare-video-grid.d.ts +0 -52
- package/dist/components/compare-video.d.ts +0 -61
- package/dist/components/compare.d.ts +0 -90
- package/dist/components/composition.d.ts +0 -44
- package/dist/components/console.d.ts +0 -34
- package/dist/components/conversation.d.ts +0 -83
- package/dist/components/cursor.d.ts +0 -44
- package/dist/components/data-table.d.ts +0 -89
- package/dist/components/data-view.d.ts +0 -66
- package/dist/components/density.d.ts +0 -16
- package/dist/components/dialog.d.ts +0 -45
- package/dist/components/difference.d.ts +0 -19
- package/dist/components/disclosure.d.ts +0 -49
- package/dist/components/done.d.ts +0 -14
- package/dist/components/drag-source.d.ts +0 -29
- package/dist/components/field.d.ts +0 -79
- package/dist/components/file-intake.d.ts +0 -60
- package/dist/components/film-strip.d.ts +0 -35
- package/dist/components/folder-picker.d.ts +0 -59
- package/dist/components/fullscreen-frame.d.ts +0 -18
- package/dist/components/history.d.ts +0 -61
- package/dist/components/hotkeys.d.ts +0 -44
- package/dist/components/infinite-list.d.ts +0 -77
- package/dist/components/inspector.d.ts +0 -66
- package/dist/components/job-action.d.ts +0 -30
- package/dist/components/job-status.d.ts +0 -55
- package/dist/components/jobs-table.d.ts +0 -35
- package/dist/components/key-glyphs.d.ts +0 -5
- package/dist/components/key-owner.d.ts +0 -11
- package/dist/components/lightbox.d.ts +0 -61
- package/dist/components/line-chart.d.ts +0 -169
- package/dist/components/link-card.d.ts +0 -32
- package/dist/components/link.d.ts +0 -54
- package/dist/components/markable-text.d.ts +0 -60
- package/dist/components/media-contents.d.ts +0 -28
- package/dist/components/media-group.d.ts +0 -32
- package/dist/components/media-player.d.ts +0 -251
- package/dist/components/media-progress.d.ts +0 -17
- package/dist/components/media-skip.d.ts +0 -31
- package/dist/components/media-spans.d.ts +0 -93
- package/dist/components/media.d.ts +0 -133
- package/dist/components/meter.d.ts +0 -32
- package/dist/components/metric.d.ts +0 -17
- package/dist/components/outbox-status.d.ts +0 -10
- package/dist/components/page-header.d.ts +0 -14
- package/dist/components/pair-vote.d.ts +0 -70
- package/dist/components/pause-button.d.ts +0 -7
- package/dist/components/pixel-image.d.ts +0 -29
- package/dist/components/place-board.d.ts +0 -39
- package/dist/components/player-warning.d.ts +0 -24
- package/dist/components/popover.d.ts +0 -20
- package/dist/components/recorder.d.ts +0 -73
- package/dist/components/region-editor.d.ts +0 -67
- package/dist/components/save.d.ts +0 -46
- package/dist/components/say-again.d.ts +0 -13
- package/dist/components/schedule-table.d.ts +0 -24
- package/dist/components/secret-field.d.ts +0 -34
- package/dist/components/selectable-grid.d.ts +0 -57
- package/dist/components/selection.d.ts +0 -104
- package/dist/components/sequence-timeline.d.ts +0 -50
- package/dist/components/shortcut-editor.d.ts +0 -44
- package/dist/components/sortable-list.d.ts +0 -39
- package/dist/components/status.d.ts +0 -9
- package/dist/components/switch.d.ts +0 -15
- package/dist/components/system-panel.d.ts +0 -58
- package/dist/components/tabs.d.ts +0 -16
- package/dist/components/theme.d.ts +0 -106
- package/dist/components/thumbnail.d.ts +0 -50
- package/dist/components/tile-grid.d.ts +0 -67
- package/dist/components/timeline-player.d.ts +0 -18
- package/dist/components/timeline.d.ts +0 -115
- package/dist/components/toast.d.ts +0 -36
- package/dist/components/toggle.d.ts +0 -51
- package/dist/components/toolbar.d.ts +0 -15
- package/dist/components/tooltip.d.ts +0 -19
- package/dist/components/transcript-view.d.ts +0 -63
- package/dist/components/tree.d.ts +0 -74
- package/dist/components/undo.d.ts +0 -63
- package/dist/components/use-timeline.d.ts +0 -44
- package/dist/components/value-controls.d.ts +0 -91
- package/dist/components/video-clock.d.ts +0 -68
- package/dist/components/view-options.d.ts +0 -105
- package/dist/components/viewport.d.ts +0 -85
- package/dist/components/virtual-list.d.ts +0 -19
- package/dist/components/waveform.d.ts +0 -71
- package/dist/components/workflow-steps.d.ts +0 -71
- package/dist/components/workspace.d.ts +0 -83
- package/dist/cursor-DDGBPiTJ.js.map +0 -1
- package/dist/field-BjeE_FeB.js.map +0 -1
- package/dist/follow-BTPs49FP.js.map +0 -1
- package/dist/generate-CjTHKJ39.js.map +0 -1
- package/dist/lib/base.d.ts +0 -10
- package/dist/lib/book.d.ts +0 -25
- package/dist/lib/boxes.d.ts +0 -55
- package/dist/lib/breakpoint.d.ts +0 -4
- package/dist/lib/choice.d.ts +0 -29
- package/dist/lib/chords.d.ts +0 -20
- package/dist/lib/client-work.d.ts +0 -24
- package/dist/lib/control.d.ts +0 -4
- package/dist/lib/dev.d.ts +0 -2
- package/dist/lib/errors.d.ts +0 -43
- package/dist/lib/file-intake.d.ts +0 -60
- package/dist/lib/follow.d.ts +0 -18
- package/dist/lib/format.d.ts +0 -243
- package/dist/lib/grouped-grid-layout.d.ts +0 -44
- package/dist/lib/icon.d.ts +0 -6
- package/dist/lib/image-diff.d.ts +0 -30
- package/dist/lib/in-view.d.ts +0 -21
- package/dist/lib/loudness.d.ts +0 -18
- package/dist/lib/marks.d.ts +0 -6
- package/dist/lib/microphone.d.ts +0 -24
- package/dist/lib/number-input.d.ts +0 -4
- package/dist/lib/object-url.d.ts +0 -2
- package/dist/lib/overlay.d.ts +0 -1
- package/dist/lib/recording.d.ts +0 -16
- package/dist/lib/region.d.ts +0 -64
- package/dist/lib/rich-text.d.ts +0 -44
- package/dist/lib/search-param.d.ts +0 -16
- package/dist/lib/segmenter.d.ts +0 -40
- package/dist/lib/sequence.d.ts +0 -34
- package/dist/lib/speech.d.ts +0 -53
- package/dist/lib/text-diff.d.ts +0 -16
- package/dist/lib/timeline.d.ts +0 -14
- package/dist/lib/transcript.d.ts +0 -53
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/viewer-input.d.ts +0 -29
- package/dist/lib/viewport.d.ts +0 -55
- package/dist/lib/waveform.d.ts +0 -46
- package/dist/map/fan.d.ts +0 -15
- package/dist/map/index.d.ts +0 -3
- package/dist/map/map-styles.d.ts +0 -2
- package/dist/map/markers.d.ts +0 -60
- package/dist/map/route-map.d.ts +0 -146
- package/dist/microphone-Bo3WaXgD.js.map +0 -1
- package/dist/migrate/stock-classes.d.ts +0 -11
- package/dist/panorama/gl.d.ts +0 -16
- package/dist/panorama/index.d.ts +0 -2
- package/dist/panorama/panorama-viewer.d.ts +0 -56
- package/dist/panorama/projection.d.ts +0 -45
- package/dist/query/api.d.ts +0 -23
- package/dist/query/clips.d.ts +0 -48
- package/dist/query/index.d.ts +0 -55
- package/dist/query/infinite.d.ts +0 -60
- package/dist/query/job.d.ts +0 -26
- package/dist/query/outbox.d.ts +0 -85
- package/dist/query/poll.d.ts +0 -24
- package/dist/query/reserve.d.ts +0 -33
- package/dist/query/typed-api.d.ts +0 -84
- package/dist/query/workflow.d.ts +0 -17
- package/dist/run-BT2WKzMz.js.map +0 -1
- package/dist/scene/camera.d.ts +0 -99
- package/dist/scene/index.d.ts +0 -2
- package/dist/scene/scene-viewport.d.ts +0 -48
- package/dist/testing/buttons.d.ts +0 -7
- package/dist/testing/index.d.ts +0 -161
- package/dist/testing/intersection-observer.d.ts +0 -34
- package/dist/testing/layout.d.ts +0 -13
- package/dist/testing/microphone.d.ts +0 -35
- package/dist/testing/setup.d.ts +0 -14
- package/dist/testing/speech.d.ts +0 -38
- package/dist/testing/storage.d.ts +0 -7
- package/dist/theme-CxYZkUNk.js.map +0 -1
- package/dist/tooltip-DhqrDtyu.js.map +0 -1
- package/dist/value-controls-Dm_EYfZW.js.map +0 -1
- package/dist/visual/capture.d.ts +0 -37
- package/dist/visual/compare.d.ts +0 -46
- package/dist/visual/drop.d.ts +0 -19
- package/dist/visual/fonts.d.ts +0 -18
- package/dist/visual/index.d.ts +0 -19
- package/dist/visual/run.d.ts +0 -22
- package/dist/visual/serve.d.ts +0 -13
- package/dist/visual/targets.d.ts +0 -17
- package/dist/visual/types.d.ts +0 -188
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { ShareBox, Viewport } from '../lib/viewport';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
/** The caller's zoom and pan, and how to change them. */
|
|
4
|
-
export type ViewportState = {
|
|
5
|
-
viewport: Viewport;
|
|
6
|
-
setViewport: (next: Viewport) => void;
|
|
7
|
-
};
|
|
8
|
-
/** Zoom and pan held in React state, to give to every `ViewportFrame` that should move together. */
|
|
9
|
-
export declare function useViewport(initial?: Viewport): ViewportState;
|
|
10
|
-
/** Where a click on a frame would choose: a stretch of the frame's width as shares (0 to 1), what it chooses and what to say about it. */
|
|
11
|
-
export type PickZone = {
|
|
12
|
-
value: string;
|
|
13
|
-
from: number;
|
|
14
|
-
to: number;
|
|
15
|
-
hint: string;
|
|
16
|
-
};
|
|
17
|
-
/** How a frame takes a click as a choice. */
|
|
18
|
-
export type FramePick = {
|
|
19
|
-
/** The zone under a pointer at `x` (0 to 1 across the frame), or null where a click chooses nothing. */
|
|
20
|
-
zoneAt: (x: number) => PickZone | null;
|
|
21
|
-
/** A click happened in `zone`. */
|
|
22
|
-
onPick: (zone: PickZone) => void;
|
|
23
|
-
/** What the frame is described as for assistive technology: "Click to choose A". */
|
|
24
|
-
describe: string;
|
|
25
|
-
/** Names what is being judged. A choice still waiting out the double-click window is dropped if this changes or the pick goes away (the next pair came up, or an answer is pending). */
|
|
26
|
-
token?: string;
|
|
27
|
-
};
|
|
28
|
-
/** Props for `ViewportFrame`. */
|
|
29
|
-
export type ViewportFrameProps = ViewportState & {
|
|
30
|
-
/** Names the frame for screen readers: "Picture A". Required. */
|
|
31
|
-
label: string;
|
|
32
|
-
/** Width over height of the frame before anything inside it has loaded. */
|
|
33
|
-
aspect: number;
|
|
34
|
-
children: React.ReactNode;
|
|
35
|
-
/** A second picture layer above `children`, zoomed and panned with them but cut at `shown` percent of the *frame's* width from the left, so a swipe divider in `overlay` stays where the cut is at any zoom. */
|
|
36
|
-
cover?: {
|
|
37
|
-
content: React.ReactNode;
|
|
38
|
-
shown: number;
|
|
39
|
-
};
|
|
40
|
-
/** Drawn over the frame, not zoomed with it: a divider to drag, a corner label. Its pointer, key and double-click events do not reach the frame, so using it never pans the picture. */
|
|
41
|
-
overlay?: React.ReactNode;
|
|
42
|
-
/** The tallest the frame may be, as a CSS length (`"60svh"`). The width follows, narrower than the space it has and centred, so the picture keeps its shape. Default: no limit, the frame is as tall as its width and aspect make it. */
|
|
43
|
-
maxHeight?: string;
|
|
44
|
-
/** Shift-drag draws a rectangle on the frame and calls this with it when let go (pixels from the frame's top left). Without it Shift-drag does nothing special. */
|
|
45
|
-
onBox?: (rect: {
|
|
46
|
-
x0: number;
|
|
47
|
-
y0: number;
|
|
48
|
-
x1: number;
|
|
49
|
-
y1: number;
|
|
50
|
-
}) => void;
|
|
51
|
-
/** A box to outline on the whole picture (a region being pointed at), as shares of it. Drawn only while the picture is fitted. */
|
|
52
|
-
outline?: ShareBox | null;
|
|
53
|
-
/** Take a click (not a drag, not a double click) as a choice: see the note at the top of the file. Without it a click does nothing, as before. */
|
|
54
|
-
pick?: FramePick;
|
|
55
|
-
className?: string;
|
|
56
|
-
};
|
|
57
|
-
/** A clipped frame whose children zoom and pan together; the viewport is the caller's, so frames can share one. */
|
|
58
|
-
export declare const ViewportFrame: React.ForwardRefExoticComponent<ViewportState & {
|
|
59
|
-
/** Names the frame for screen readers: "Picture A". Required. */
|
|
60
|
-
label: string;
|
|
61
|
-
/** Width over height of the frame before anything inside it has loaded. */
|
|
62
|
-
aspect: number;
|
|
63
|
-
children: React.ReactNode;
|
|
64
|
-
/** A second picture layer above `children`, zoomed and panned with them but cut at `shown` percent of the *frame's* width from the left, so a swipe divider in `overlay` stays where the cut is at any zoom. */
|
|
65
|
-
cover?: {
|
|
66
|
-
content: React.ReactNode;
|
|
67
|
-
shown: number;
|
|
68
|
-
};
|
|
69
|
-
/** Drawn over the frame, not zoomed with it: a divider to drag, a corner label. Its pointer, key and double-click events do not reach the frame, so using it never pans the picture. */
|
|
70
|
-
overlay?: React.ReactNode;
|
|
71
|
-
/** The tallest the frame may be, as a CSS length (`"60svh"`). The width follows, narrower than the space it has and centred, so the picture keeps its shape. Default: no limit, the frame is as tall as its width and aspect make it. */
|
|
72
|
-
maxHeight?: string;
|
|
73
|
-
/** Shift-drag draws a rectangle on the frame and calls this with it when let go (pixels from the frame's top left). Without it Shift-drag does nothing special. */
|
|
74
|
-
onBox?: (rect: {
|
|
75
|
-
x0: number;
|
|
76
|
-
y0: number;
|
|
77
|
-
x1: number;
|
|
78
|
-
y1: number;
|
|
79
|
-
}) => void;
|
|
80
|
-
/** A box to outline on the whole picture (a region being pointed at), as shares of it. Drawn only while the picture is fitted. */
|
|
81
|
-
outline?: ShareBox | null;
|
|
82
|
-
/** Take a click (not a drag, not a double click) as a choice: see the note at the top of the file. Without it a click does nothing, as before. */
|
|
83
|
-
pick?: FramePick;
|
|
84
|
-
className?: string;
|
|
85
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/** A list that renders only its visible rows (React Aria's GridList and Virtualizer) from `virtualizeFrom` items, with arrow-key navigation between rows. */
|
|
3
|
-
export declare function VirtualList<T>({ label, items, itemKey, children, estimateSize, rowHeight, height, virtualizeFrom, bounded, footer, className, }: {
|
|
4
|
-
label: string;
|
|
5
|
-
items: T[];
|
|
6
|
-
itemKey: (item: T) => string;
|
|
7
|
-
children: (item: T, index: number) => React.ReactNode;
|
|
8
|
-
/** First-paint height of a row, in px; rows are measured after they render. */
|
|
9
|
-
estimateSize?: number;
|
|
10
|
-
/** Every row is exactly this tall (px): nothing is measured. */
|
|
11
|
-
rowHeight?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
virtualizeFrom?: number;
|
|
14
|
-
/** Scroll inside a box capped at `height` even below `virtualizeFrom`, so growing past it changes nothing on screen. */
|
|
15
|
-
bounded?: boolean;
|
|
16
|
-
/** After the last row, inside the scroll box (a next-page row, an end note). */
|
|
17
|
-
footer?: React.ReactNode;
|
|
18
|
-
className?: string;
|
|
19
|
-
}): React.JSX.Element;
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
/** Scale the drawing so the loud parts fill the height (a quiet recording, such as a camcorder tape), and say by how much. `true` uses the defaults of `peakGain`; an object sets them. Only the drawing changes. */
|
|
46
|
-
normalise?: boolean | {
|
|
47
|
-
percentile?: number;
|
|
48
|
-
maxGain?: number;
|
|
49
|
-
};
|
|
50
|
-
/** Turns a decoded file into samples. Default: the browser's `AudioContext.decodeAudioData`. */
|
|
51
|
-
decode?: (data: ArrayBuffer) => Promise<DecodedAudio>;
|
|
52
|
-
/** The words of the reading state; defaults say "Reading the waveform". */
|
|
53
|
-
words?: {
|
|
54
|
-
running: string;
|
|
55
|
-
finished: string;
|
|
56
|
-
failed: string;
|
|
57
|
-
};
|
|
58
|
-
disabled?: boolean;
|
|
59
|
-
className?: string;
|
|
60
|
-
};
|
|
61
|
-
/** `peaks` or a `source` to decode: one of them, so a waveform with nothing to draw cannot be written. */
|
|
62
|
-
export type WaveformProps = Common & ({
|
|
63
|
-
peaks: WaveformPeaks;
|
|
64
|
-
source?: never;
|
|
65
|
-
} | {
|
|
66
|
-
source: string | Blob;
|
|
67
|
-
peaks?: never;
|
|
68
|
-
});
|
|
69
|
-
/** An audio waveform with marks, spans and a playhead: one slider you click, drag or key to seek, zoom, and a range to select. */
|
|
70
|
-
export declare function Waveform({ label, peaks, source, duration: given, time, onSeek, marks, spans, underlay, range: controlledRange, onRangeChange, step, bigStep, defaultView, buckets, normalise, decode, words, disabled, className }: WaveformProps): React.JSX.Element;
|
|
71
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/** A stage's state on the server: `strata_python.contracts.StageState`. */
|
|
2
|
-
export type StageState = "done" | "ready" | "stale" | "failed" | "waiting" | "blocked";
|
|
3
|
-
/** The fields of a stage `WorkflowSteps` draws: the shape of `Schema<"StageRun">`, which satisfies it. */
|
|
4
|
-
export type WorkflowStage = {
|
|
5
|
-
name: string;
|
|
6
|
-
title: string;
|
|
7
|
-
gate: boolean;
|
|
8
|
-
state: string;
|
|
9
|
-
last?: {
|
|
10
|
-
status: string;
|
|
11
|
-
at: string;
|
|
12
|
-
elapsed_s?: number;
|
|
13
|
-
error?: string | null;
|
|
14
|
-
by?: string | null;
|
|
15
|
-
} | null;
|
|
16
|
-
};
|
|
17
|
-
/** Each state's word, in the product's terms. Any left out keeps its default. */
|
|
18
|
-
export type StageWords = Partial<Record<StageState | "approved", string>>;
|
|
19
|
-
/** The workflow steps' props. */
|
|
20
|
-
export type WorkflowStepsProps<S extends WorkflowStage> = {
|
|
21
|
-
/** What the subject's pipeline is ("Ingest of Wolf Hall"): names the list. */
|
|
22
|
-
label: string;
|
|
23
|
-
/** The stages in order: `WorkflowRun.stages`. */
|
|
24
|
-
stages: S[];
|
|
25
|
-
/** Approves a gate (the POST to `.../stages/<name>/approve`). Without it, a waiting gate has no button. */
|
|
26
|
-
onApprove?: (stage: S) => Promise<unknown>;
|
|
27
|
-
/** Runs the subject again (the POST to `.../run`). Without it, a failed stage has no button. */
|
|
28
|
-
onRetry?: (stage: S) => Promise<unknown>;
|
|
29
|
-
/** Renames the states. */
|
|
30
|
-
words?: StageWords;
|
|
31
|
-
/** "Now", for `format.ago` (tests and screenshots). */
|
|
32
|
-
now?: Date;
|
|
33
|
-
className?: string;
|
|
34
|
-
};
|
|
35
|
-
/** A subject's stages through a strata-python pipeline, each with its state as a word, when it last ran, its error, and Approve on a waiting gate or Try again on a failed stage. */
|
|
36
|
-
export declare function WorkflowSteps<S extends WorkflowStage>({ label, stages, onApprove, onRetry, words, now, className }: WorkflowStepsProps<S>): import('react').JSX.Element;
|
|
37
|
-
/** A whole run's state, for a list of subjects: a stage state that matters, or one of the run's own. */
|
|
38
|
-
export type WorkflowSummaryState = "running" | "failed" | "waiting" | "stale" | "done" | "partial" | "ready";
|
|
39
|
-
/** A run in a few words' worth of data: its state, the stage it is about, and how many stages are done of how many. */
|
|
40
|
-
export type WorkflowSummaryData<S extends WorkflowStage = WorkflowStage> = {
|
|
41
|
-
state: WorkflowSummaryState;
|
|
42
|
-
/** The stage the state is about: the one running or next, the failed one, the waiting gate, the stale one. */
|
|
43
|
-
stage?: S;
|
|
44
|
-
/** That stage's place, from 1. */
|
|
45
|
-
step?: number;
|
|
46
|
-
done: number;
|
|
47
|
-
total: number;
|
|
48
|
-
};
|
|
49
|
-
/** Reduces a run's stages to one state and the stage it is about. `running`: its job is queued or running. */
|
|
50
|
-
export declare function summariseWorkflow<S extends WorkflowStage>(stages: readonly S[], { running }?: {
|
|
51
|
-
running?: boolean;
|
|
52
|
-
}): WorkflowSummaryData<S>;
|
|
53
|
-
/** The summary's words: the stage words `WorkflowSteps` uses, and the run's own two. */
|
|
54
|
-
export type WorkflowSummaryWords = StageWords & {
|
|
55
|
-
running?: string;
|
|
56
|
-
partial?: string;
|
|
57
|
-
};
|
|
58
|
-
/** The sentence beside the word: which stage, and how far through. */
|
|
59
|
-
export declare function describeWorkflowSummary(s: WorkflowSummaryData): string | null;
|
|
60
|
-
/** The workflow summary's props. */
|
|
61
|
-
export type WorkflowSummaryProps = {
|
|
62
|
-
/** The run's stages: `WorkflowRun.stages`. */
|
|
63
|
-
stages: readonly WorkflowStage[];
|
|
64
|
-
/** Its job is queued or running (`WorkflowRun.job` in a state that has not ended). */
|
|
65
|
-
running?: boolean;
|
|
66
|
-
/** Renames the words. */
|
|
67
|
-
words?: WorkflowSummaryWords;
|
|
68
|
-
className?: string;
|
|
69
|
-
};
|
|
70
|
-
/** A subject's run through a strata-python pipeline in a few words, for a list of subjects: running (on which step), failed (which), waiting for review (which gate), out of date, part done, or done. */
|
|
71
|
-
export declare function WorkflowSummary({ stages, running, words, className }: WorkflowSummaryProps): import('react').JSX.Element;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/** What `useWorkspaceState` returns: pass it to `Workspace`, and use it from outside (a menu, a shortcut) to fold or reset panes. */
|
|
3
|
-
export type WorkspaceState = {
|
|
4
|
-
/** Whether a pane is folded now. `fallback` is the pane's `defaultCollapsed`. */
|
|
5
|
-
isCollapsed: (id: string, fallback?: boolean) => boolean;
|
|
6
|
-
setCollapsed: (id: string, collapsed: boolean) => void;
|
|
7
|
-
/** Folds an open pane, opens a folded one. */
|
|
8
|
-
toggle: (id: string) => void;
|
|
9
|
-
/** Forgets every size and fold, back to the defaults. */
|
|
10
|
-
reset: () => void;
|
|
11
|
-
/** @internal */
|
|
12
|
-
sizeOf: (id: string) => number | undefined;
|
|
13
|
-
/** @internal */
|
|
14
|
-
setSize: (id: string, size: number | null) => void;
|
|
15
|
-
/** @internal */
|
|
16
|
-
register: (id: string, defaultCollapsed: boolean) => void;
|
|
17
|
-
/** @internal */
|
|
18
|
-
narrow: boolean;
|
|
19
|
-
/** @internal */
|
|
20
|
-
setNarrow: (narrow: boolean) => void;
|
|
21
|
-
};
|
|
22
|
-
/** The sizes and folded panes of a `Workspace`; with `persist`, remembered in localStorage under that name. */
|
|
23
|
-
export declare function useWorkspaceState(persist?: string): WorkspaceState;
|
|
24
|
-
/** The workspace: a labelled region that holds the splits and panes, and stacks them when narrow. */
|
|
25
|
-
export declare function Workspace({ label, state, narrowBelow, onFiles, acceptLabel, className, children, }: {
|
|
26
|
-
label: string;
|
|
27
|
-
state: WorkspaceState;
|
|
28
|
-
/** Stack side-by-side splits when the workspace is narrower than this many pixels. Default 720. */
|
|
29
|
-
narrowBelow?: number;
|
|
30
|
-
/** Takes files dropped anywhere on the window (issue #368): while a drag of files is over it, an overlay says "Drop to add {acceptLabel}". Needs `acceptLabel`. Keep a `FileButton` in the bar for the keyboard and phones. The app's own drags (`DragSource`) never trigger it. */
|
|
31
|
-
onFiles?: (files: File[]) => void;
|
|
32
|
-
/** What the drop takes, in words ("PAK files"). */
|
|
33
|
-
acceptLabel?: string;
|
|
34
|
-
className?: string;
|
|
35
|
-
children: React.ReactNode;
|
|
36
|
-
}): React.JSX.Element;
|
|
37
|
-
/** What `WorkspaceBar` shows. */
|
|
38
|
-
export type WorkspaceBarProps = {
|
|
39
|
-
/** The tool's name: the screen's heading ("Quake 2 explorer"). */
|
|
40
|
-
title: string;
|
|
41
|
-
/** What is loaded or happening, in words ("pak.pak, mod.pak, 3 MB"). A polite live region; it is not announced on first render. */
|
|
42
|
-
status?: React.ReactNode;
|
|
43
|
-
/** The bar's few actions, with at most one filled button (the view's one primary action). */
|
|
44
|
-
actions?: React.ReactNode;
|
|
45
|
-
/** The far end: `ColorSchemeChoice compact`, `PaletteChoice compact`. */
|
|
46
|
-
end?: React.ReactNode;
|
|
47
|
-
className?: string;
|
|
48
|
-
};
|
|
49
|
-
/** The bar across the top of a `Workspace`: the tool's name as the heading, a polite status line, the few actions, then an end slot for the scheme and palette choice. Wraps on a phone. */
|
|
50
|
-
export declare function WorkspaceBar({ title, status, actions, end, className }: WorkspaceBarProps): React.JSX.Element;
|
|
51
|
-
/** What a `Pane` is, for the split that lays it out. */
|
|
52
|
-
export type PaneProps = {
|
|
53
|
-
/** Identifies the pane in the remembered state: unique in the workspace. */
|
|
54
|
-
id: string;
|
|
55
|
-
/** The pane's name, in its header and as its landmark: "Library", "Inspector". */
|
|
56
|
-
name: string;
|
|
57
|
-
/** Takes the space the fixed panes leave. One per split (a nested `Split` always does). */
|
|
58
|
-
grow?: boolean;
|
|
59
|
-
/** Starting size in pixels (width beside the stage, height above or below it). Default 280. */
|
|
60
|
-
size?: number;
|
|
61
|
-
/** Smallest size in pixels. Default 160; for a growing pane, the least it keeps (default 240 wide, 120 high). */
|
|
62
|
-
min?: number;
|
|
63
|
-
/** Largest size in pixels. Default none. */
|
|
64
|
-
max?: number;
|
|
65
|
-
/** Shows a collapse button in the header and lets the pane fold to a rail or its header. */
|
|
66
|
-
collapsible?: boolean;
|
|
67
|
-
/** Starts folded until the person opens it. */
|
|
68
|
-
defaultCollapsed?: boolean;
|
|
69
|
-
/** The pane's few actions, drawn in its header before the collapse button. */
|
|
70
|
-
actions?: React.ReactNode;
|
|
71
|
-
/** Draws the body edge to edge. By default the body has the standard inset (the header's own 0.75rem), so a heading, an `Inspector` or text lines up with the pane's name; a tree, table, list or stage that brings its own edges is `flush`. */
|
|
72
|
-
flush?: boolean;
|
|
73
|
-
className?: string;
|
|
74
|
-
children?: React.ReactNode;
|
|
75
|
-
};
|
|
76
|
-
/** A region of a workspace with a consistent header (name, actions, fold button) and a body that scrolls. */
|
|
77
|
-
export declare function Pane({ id, name, grow, size, min, max, collapsible, defaultCollapsed, actions, flush, className, children }: PaneProps): React.JSX.Element;
|
|
78
|
-
/** Lays its children out in a row or a column, with a separator between a fixed pane and its neighbour. A nested split takes the space the fixed panes leave. */
|
|
79
|
-
export declare function Split({ direction, className, children }: {
|
|
80
|
-
direction: "row" | "column";
|
|
81
|
-
className?: string;
|
|
82
|
-
children: React.ReactNode;
|
|
83
|
-
}): React.JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
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,KA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AAM,OAAO;GACtC,IAAI,EAAE,UAAU,aAAa,EAAE,OAAO,MAAM,QAAQ,EAAE,EAAE,EAAE,CAAC;EAC7D;EACA,MAAM,OAAO,KAAK,UAAU,QAAQ,KAAK,IAAI;EAC7C,IAAI,QAAQ,GAAG,MAAM;OAChB,MAAM,YAAY,OAAO,WAAW,OAAO,IAAI;CACtD,GAAG,CAAC,MAAM,KAAK,CAAC;CAChB,MAAM,sBAAsB,OAAO,aAAa,MAAM,OAAO,GAAG,CAAC,CAAC;CAClE,OACE,oBAAC,KAAD;EAAG,MAAK;EAAS,aAAU;EAAS,WAAU;EAC3C,UAAA;CACA,CAAA;AAEP;;;;;;AAmBA,SAAgB,gBAAgB,QAAsC;CACpE,MAAM,QAAQ,MAAM,WAAW,KAAK;CACpC,MAAM,MAAM,MAAM,MAAM;CACxB,MAAM,KAAK,UAAU;CACrB,MAAM,YAAY,MAAM,aAAa,OAAoB,QAAQ,MAAM,UAAU,EAAE,UAAU,CAAC,GAAI,CAAC,KAAK,CAAC;CACzG,MAAM,OAAO,MAAM,qBAAqB,iBAAiB,OAAO,YAAY,aAAa,KAAK;CAC9F,MAAM,aAAa,MAAM,aAAa,OAAsB,OAAO,WAAW,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CAClG,MAAM,cAAc,MAAM,aAAa,OAAsB,OAAO,YAAY,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;CACpG,OAAO,MAAM,cACJ,QAAQ;EAAE,GAAG;EAAM,QAAQ;EAAI,OAAO,KAAK,OAAO,QAAQ,KAAK,WAAW,KAAK,KAAK,KAAK;EAAM;EAAY;CAAY,IAAI,MAClI;EAAC;EAAO;EAAM;EAAI;EAAY;CAAW,CAC3C;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-BjeE_FeB.js","names":["Input"],"sources":["../src/lib/format.ts","../src/lib/search-param.ts","../src/lib/control.ts","../src/components/field.tsx"],"sourcesContent":["// Every number and date on screen goes through Intl, once, here. Units are joined with a\n// non-breaking space so \"212 °C\" never wraps between figure and unit. A product that is not\n// en-GB calls createFormat with its locale once and exports the result from its own lib.\n//\n// The number formatters are callable (`format.integer(n)`) because that is the form people reach\n// for (strata-react issue #12), and they keep Intl's methods (`format.integer.format(n)`,\n// `formatToParts`, `resolvedOptions`) so existing calls and Intl knowledge still work.\n//\n// Dates follow the same shape. Every date formatter is callable with a Date, an ISO string or\n// epoch milliseconds (`format.dateTime(row.at)`), because rows arrive from an API as ISO strings\n// and an app that has to wrap each one in `new Date(...)` soon builds its own Intl.DateTimeFormat\n// beside it instead (strata-react issue #31, from the Bright Horizons History screen). An invalid\n// date throws a RangeError naming the input rather than printing \"Invalid Date\" into a row.\n// `date` and `dateTime` use Intl's medium/short styles, so the locale decides the order\n// (\"8 Nov 2026, 06:05\" in en-GB, \"Nov 8, 2026, 6:05 AM\" in en-US) and nobody hand-writes a\n// pattern. `timeZone` is optional: left out, times are the viewer's; a product that shows a place's\n// times (a kiln in one room, a shop's opening hours) passes that place's zone once.\n//\n// Tests: the non-breaking space is a real character in the DOM. Testing Library's text matchers\n// (`getByText`, `toHaveTextContent`) collapse whitespace and match \"6 pieces\", but accessible-name\n// matching (`getByRole(\"heading\", { name: \"6 pieces\" })`) compares the name exactly and does not.\n// Build the expected string with the same formatter (`{ name: format.count(6, \"piece\") }`), or\n// use a regex with `\\s` (`/6\\spieces/`), which matches U+00A0.\n//\n// A value that is not known (`null` or `undefined`: a count the source does not give, a date for\n// something never synced) prints as the placeholder, an en dash unless `createFormat`'s `missing`\n// says otherwise, from every number and date formatter (strata-react issue #47). Each screen used\n// to pick its own (\"–\", \"Never\", blank), so tables and cards disagreed. An invalid date still\n// throws: that is a bug, not a missing value.\n//\n// Three formatters came from the Tubes viewer, which wrote its own (strata-react issue #52): `ago`\n// (\"3 weeks ago\", from Intl.RelativeTimeFormat, with `now` passed in by tests), `compact` (\"1.2k\"\n// in en-GB, and `count`'s `{ compact: true }` for \"1.2k views\") and `runningTime` (\"4:05\", \"1:02:09\"), the\n// m:ss of a media player, which Intl.DurationFormat's long form is not. `share` is `percent` for a\n// part of a whole (strata-react issue #43): a part that is there never prints as \"0%\", nor a part\n// short of the whole as \"100%\".\n//\n// Four more came from a status page (strata-react issue #341, jburnhams/homepage), each written by\n// hand there because `format` had no equivalent: `bytes` in binary units (`{ binary: true }`:\n// memory is read in KiB, MiB, GiB, and `free -h` shows them, so a decimal GB reads 7% high);\n// `duration` (\"16 min\", \"3.5 h\", \"2 days\" to say how long, or `style: \"parts\"` for an uptime,\n// \"1d 1h 0m\"), which `runningTime`'s clock cannot say; `measure` (a reading and its unit, \"12.3 GB\",\n// \"41%\"); and `agoTick` (\"now\", \"−30 s\", \"−2 min\") for the axis of a history chart.\n\nexport const NBSP = \" \";\n\n/** The placeholder printed for a value that is not known: an en dash. */\nexport const MISSING = \"–\";\n\n/** The decimal byte units `format.bytes` writes. */\nexport type ByteUnit = \"B\" | \"kB\" | \"MB\" | \"GB\" | \"TB\" | \"PB\";\nconst BYTE_UNITS: readonly ByteUnit[] = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\"];\nconst BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1000 ** i])) as Record<ByteUnit, number>;\n\n/** The binary byte units `format.bytes` writes with `{ binary: true }`. */\nexport type BinaryByteUnit = \"B\" | \"KiB\" | \"MiB\" | \"GiB\" | \"TiB\" | \"PiB\";\nconst BINARY_UNITS: readonly BinaryByteUnit[] = [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\"];\nconst BINARY_SIZE = Object.fromEntries(BINARY_UNITS.map((u, i) => [u, 1024 ** i])) as Record<BinaryByteUnit, number>;\nconst SIZE: Record<ByteUnit | BinaryByteUnit, number> = { ...BYTE_SIZE, ...BINARY_SIZE };\n\n/** What `format.bytes` and `format.byteUnit` take beyond the value: `{ binary: true }` for KiB, MiB, GiB (powers of 1024), or a unit to fix. A binary unit implies binary. */\nexport type BytesOptions = { binary?: boolean; unit?: ByteUnit | BinaryByteUnit };\n\nfunction chooseByteUnit(value: number, binary: boolean): ByteUnit | BinaryByteUnit {\n const units: readonly (ByteUnit | BinaryByteUnit)[] = binary ? BINARY_UNITS : BYTE_UNITS;\n return [...units].reverse().find((u) => Math.abs(value) >= SIZE[u]) ?? \"B\";\n}\n\n/** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. `null` or `undefined` prints the placeholder. */\nexport type NumberFormatter = ((value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string) & {\n format: (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string;\n} & Pick<Intl.NumberFormat, \"formatToParts\" | \"resolvedOptions\">;\n\n/** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */\nexport type DateInput = Date | string | number;\n\n/** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */\nexport type DateFormatter = ((value: DateInput | null | undefined) => string) & {\n format: (value: DateInput | null | undefined) => string;\n formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];\n formatRange: (start: DateInput, end: DateInput) => string;\n} & Pick<Intl.DateTimeFormat, \"resolvedOptions\">;\n\n/** Options shared by every date formatter one `createFormat` call makes. */\nexport interface FormatOptions {\n /** An IANA zone (\"Europe/London\", \"UTC\") to show times in. Left out, times are the viewer's own. */\n timeZone?: string;\n /** What a missing value (`null`, `undefined`) prints as. Default an en dash (`MISSING`). */\n missing?: string;\n}\n\n/** Options for `format.count`. */\nexport interface CountOptions {\n /** Write the figure compactly: \"1.2k views\". The noun still agrees with the exact count. */\n compact?: boolean;\n}\n\n/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */\nexport function toDate(value: DateInput): Date {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);\n return date;\n}\n\nfunction callableDate(df: Intl.DateTimeFormat, missing: string): DateFormatter {\n const format = (value: DateInput | null | undefined) => (value == null ? missing : df.format(toDate(value)));\n return Object.assign(format, {\n format,\n formatToParts: (value: DateInput) => df.formatToParts(toDate(value)),\n formatRange: (start: DateInput, end: DateInput) => df.formatRange(toDate(start), toDate(end)),\n resolvedOptions: () => df.resolvedOptions(),\n });\n}\n\nfunction callable(nf: Intl.NumberFormat, missing: string): NumberFormatter {\n const format = (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => (value == null ? missing : nf.format(value));\n return Object.assign(format, {\n format,\n formatToParts: (value: number | bigint) => nf.formatToParts(value),\n resolvedOptions: () => nf.resolvedOptions(),\n });\n}\n\n// Largest first: `ago` says a span in the largest unit it fills at least once, rounded down, so\n// 13 days is \"last week\" and 20 days \"2 weeks ago\", never \"3 weeks\" too early.\nconst DAY = 86_400_000;\nconst AGO_STEPS: readonly [Intl.RelativeTimeFormatUnit, number][] = [\n [\"year\", 365 * DAY],\n [\"month\", 30 * DAY],\n [\"week\", 7 * DAY],\n [\"day\", DAY],\n [\"hour\", 3_600_000],\n [\"minute\", 60_000],\n];\n\n/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */\nexport function createFormat(locale: string, options: FormatOptions = {}) {\n const { timeZone, missing = MISSING } = options;\n const dates = (opts: Intl.DateTimeFormatOptions) => callableDate(new Intl.DateTimeFormat(locale, { ...opts, timeZone }), missing);\n const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }), missing);\n const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }), missing);\n const percent = callable(new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }), missing);\n const compact = callable(new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }), missing);\n const relative = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n const plurals = new Intl.PluralRules(locale);\n const clock = dates({ hour: \"2-digit\", minute: \"2-digit\" });\n const day = dates({ weekday: \"long\", day: \"numeric\", month: \"long\" });\n const shortDay = dates({ weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\n const date = dates({ dateStyle: \"medium\" });\n const dateTime = dates({ dateStyle: \"medium\", timeStyle: \"short\" });\n const withUnit = (value: number, unit: string, fmt: Pick<Intl.NumberFormat, \"format\"> = integer) =>\n `${fmt.format(value)}${NBSP}${unit}`;\n return {\n locale,\n /** The zone times are shown in, or `undefined` for the viewer's own. */\n timeZone,\n /** Whole numbers with grouping: `format.integer(1222)` is \"1,222\". */\n integer,\n /** One decimal place at most: `format.decimal(3.14)` is \"3.1\". */\n decimal,\n /** A ratio as a whole percent: `format.percent(0.42)` is \"42%\". */\n percent,\n /**\n * A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that\n * rounds to 0 is \"<1%\", and one short of the whole that rounds to 100 is \">99%\".\n * `format.share(2.4 / 512)` is \"<1%\".\n */\n share: (value: number | null | undefined) => {\n if (value == null || Number.isNaN(value)) return missing;\n if (value > 0 && value < 0.005) return `<${percent.format(0.01)}`;\n if (value >= 0.995 && value < 1) return `>${percent.format(0.99)}`;\n return percent.format(value);\n },\n /** A figure in short form for counts that run to thousands: `format.compact(1234)` is \"1.2k\" in en-GB, \"1.2K\" in en-US. */\n compact,\n /**\n * How long ago (or how far ahead) a time is, in the largest unit it reaches:\n * \"3 weeks ago\", \"yesterday\", \"in 2 hours\", \"now\" under a minute. Pass `now` in tests.\n */\n ago: (value: DateInput | null | undefined, now: DateInput = new Date()) => {\n if (value == null) return missing;\n const diff = toDate(value).getTime() - toDate(now).getTime();\n const span = Math.abs(diff);\n for (const [unit, size] of AGO_STEPS) {\n if (span >= size) return relative.format(Math.sign(diff) * Math.floor(span / size), unit);\n }\n return relative.format(0, \"second\");\n },\n /**\n * A media running time from seconds, as a player shows it: \"4:05\", \"1:02:09\". Unknown\n * (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n runningTime: (seconds: number | null | undefined) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const s = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(s / 3600), Math.floor((s % 3600) / 60)];\n return h > 0 ? `${h}:${two(m)}:${two(s % 60)}` : `${m}:${two(s % 60)}`;\n },\n /**\n * A position in media as an editor shows it, to a chosen precision: \"4:05\" (seconds), \"4:05.250\"\n * (`\"ms\"`), or \"0:04:05:07\" (`\"frames\"` at `fps`, the last part the frame). Hours appear only\n * from one hour, except in frames. Frames are always four parts, hours included, as SMPTE\n * timecode is (non-drop frame, with colons): a three-part \"1:05:00\" reads as one hour five, so\n * a frame count must never be three. Editors write the same four parts (strata-react issue\n * #122). Floors, never rounds up, so a time never reads ahead of the picture. Unknown (null,\n * negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n timecode: (seconds: number | null | undefined, { precision = \"seconds\", fps = 30 }: { precision?: \"seconds\" | \"ms\" | \"frames\"; fps?: number } = {}) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const whole = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(whole / 3600), Math.floor((whole % 3600) / 60)];\n const base = h > 0 ? `${h}:${two(m)}:${two(whole % 60)}` : `${m}:${two(whole % 60)}`;\n if (precision === \"ms\") return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1000 + 1e-6), 999)).padStart(3, \"0\")}`;\n if (precision === \"frames\") return `${h}:${two(m)}:${two(whole % 60)}:${two(Math.min(Math.floor((seconds - whole) * fps + 1e-6), Math.ceil(fps) - 1))}`;\n return base;\n },\n /** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */\n missing,\n /** A time of day: `format.clock(at)` is \"06:05\". */\n clock,\n /** A day without its year, for this week's things: `format.day(at)` is \"Sunday 8 November\". */\n day,\n /** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is \"Sun 06:05\". */\n shortDay,\n /** A date with its year, for a record or a deadline: `format.date(at)` is \"8 Nov 2026\". */\n date,\n /** A date and time, for a log or history row: `format.dateTime(at)` is \"8 Nov 2026, 06:05\". */\n dateTime,\n /** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */\n withUnit,\n /** A temperature in °C, joined by a non-breaking space. */\n celsius: (value: number) => withUnit(value, \"°C\"),\n /**\n * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and\n * networks are sold): one decimal below 10 (\"5.2 GB\"), whole above (\"431 GB\"). Pass `unit`\n * to fix the unit, so figures compared side by side (\"431 of 466 GB\") share one. Memory is\n * read in binary units: `{ binary: true }` writes KiB, MiB, GiB (\"7.6 GiB\"), and a binary\n * unit (\"GiB\") picks that too. The second argument is a unit or `{ binary, unit }`.\n */\n bytes: (value: number, unitOrOptions?: ByteUnit | BinaryByteUnit | BytesOptions) => {\n const { binary = false, unit } = typeof unitOrOptions === \"string\" ? { unit: unitOrOptions } : (unitOrOptions ?? {});\n const chosen = unit ?? chooseByteUnit(value, binary);\n const scaled = value / SIZE[chosen];\n return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== \"B\" ? decimal : integer);\n },\n /**\n * A length of time in words, the unit chosen by size: \"45 s\", \"16 min\", \"3.5 h\", \"2 days\". Unknown\n * (null, negative, not finite) prints the placeholder. `style: \"parts\"` is an uptime, the two\n * largest units written out: \"1d 1h 0m\", \"2h 5m\", \"5m 3s\". Not `runningTime`, which is a media clock.\n */\n duration: (seconds: number | null | undefined, { style = \"approx\" }: { style?: \"approx\" | \"parts\" } = {}) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n if (style === \"parts\") {\n const s = Math.floor(seconds);\n const [d, h, m] = [Math.floor(s / 86400), Math.floor((s % 86400) / 3600), Math.floor((s % 3600) / 60)];\n if (d > 0) return `${d}d${NBSP}${h}h${NBSP}${m}m`;\n if (h > 0) return `${h}h${NBSP}${m}m`;\n if (m > 0) return `${m}m${NBSP}${s % 60}s`;\n return `${s}s`;\n }\n if (seconds < 60) return withUnit(Math.floor(seconds), \"s\");\n if (seconds < 3600) return withUnit(Math.floor(seconds / 60), \"min\");\n if (seconds < 86400) return withUnit(seconds / 3600, \"h\", decimal);\n const days = seconds / 86400;\n return withUnit(days, plurals.select(Math.round(days * 10) / 10) === \"one\" ? \"day\" : \"days\", decimal);\n },\n /**\n * A reading and its unit: `format.measure(12.34, \"GB\")` is \"12.3 GB\" (one decimal at most, a\n * non-breaking space). `\"%\"` takes the figure as percent points and goes through `percent`, so\n * the locale decides the spacing: `format.measure(41, \"%\")` is \"41%\". Unknown prints the placeholder.\n */\n measure: (value: number | null | undefined, unit: string) =>\n value == null ? missing : unit === \"%\" ? percent.format(value / 100) : withUnit(value, unit, decimal),\n /**\n * A tick for the axis of a chart of the past, from seconds before now: \"now\", \"−30 s\", \"−2 min\",\n * \"−6 h\", \"−3 d\" (a true minus sign). Pass it as `LineChart`'s `formatX` after turning x into seconds ago.\n */\n agoTick: (secondsAgo: number | null | undefined) => {\n if (secondsAgo == null || !Number.isFinite(secondsAgo)) return missing;\n const s = Math.abs(secondsAgo);\n if (s < 1) return \"now\";\n const [n, unit] = s < 60 ? [s, \"s\"] : s < 3600 ? [s / 60, \"min\"] : s < 86400 ? [s / 3600, \"h\"] : [s / 86400, \"d\"];\n return `−${integer.format(n)}${NBSP}${unit}`;\n },\n /**\n * A distance in metres as a person says it: metres under a kilometre (\"850 m\"), then\n * kilometres, one decimal below 100 (\"12.4 km\"), whole above; `\"imperial\"` is feet under a\n * tenth of a mile (\"320 ft\"), then miles (\"7.7 mi\").\n */\n distance: (metres: number, system: \"metric\" | \"imperial\" = \"metric\") => {\n if (system === \"imperial\") {\n const miles = metres / 1609.344;\n return miles < 0.1 ? withUnit(metres * 3.28084, \"ft\") : withUnit(miles, \"mi\", miles < 100 ? decimal : integer);\n }\n return Math.abs(metres) < 1000 ? withUnit(metres, \"m\") : withUnit(metres / 1000, \"km\", Math.abs(metres) < 100_000 ? decimal : integer);\n },\n /** The unit `bytes` would choose for a value, to share it across a set of figures. */\n byteUnit: (value: number, { binary = false }: { binary?: boolean } = {}) => chooseByteUnit(value, binary),\n /**\n * \"1 piece\", \"6 pieces\": the count and its noun, so copy never reads \"1 pieces\". They are\n * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same\n * call or a `\\s` regex, not a typed \"6 pieces\" string in a role's `name`.\n */\n count: (value: number | null | undefined, one: string, many = `${one}s`, { compact: short = false }: CountOptions = {}) =>\n value == null\n ? missing\n : `${(short ? compact : integer).format(value)}${NBSP}${plurals.select(value) === \"one\" ? one : many}`,\n };\n}\n\nexport type Format = ReturnType<typeof createFormat>;\n\n/** The en-GB formatters. */\nexport const format = createFormat(\"en-GB\");\n","import * as React from \"react\";\nimport { useSearchParams } from \"react-router\";\n\n// \"Anything a person would link or reload into (tab, sort, filter, page, open item) is in the URL.\"\n// Tabs (`param=`), DataTable (`sortParam`) and `useExpanded({ param })` already do; a plain filter or\n// choice did not, so each app wrote the same `setParams(p => { new URLSearchParams(p) … })` (#297).\n// Rules fixed here once: the default is never written (the plain URL stays plain, as `Tabs` does),\n// a value that does not parse reads as the default (a stale or hand-edited link must not break the\n// screen), other params are kept, and a filter replaces the history entry (Back leaves the screen,\n// it does not walk through every filter change; `replace: false` for a choice worth a Back step).\n\n/** Options of `useSearchParam`. */\nexport type SearchParamOptions<T extends string> = {\n /** Read when the param is missing or invalid; setting it removes the param. */\n default: T;\n /** Says whether a raw value is allowed: a type guard (`isMode`), or a function that returns the typed value or `undefined`. */\n parse?: (raw: string) => T | boolean | undefined;\n /** Replace the history entry instead of adding one. Default `true`, since most params are filters. */\n replace?: boolean;\n};\n\n/** What `useSearchParam` returns: the value, and a setter that takes the next value or `null` for the default. */\nexport type SearchParam<T extends string> = readonly [T, (next: T | null) => void];\n\n/**\n * One value held in a URL search parameter (React Router): `const [mode, setMode] = useSearchParam(\"mode\", { default: \"all\", parse: isMode })`.\n * Reads and validates it, drops the param when set to the default or `null`, keeps the others, and replaces the history entry by default.\n */\nexport function useSearchParam<T extends string = string>(key: string, { default: fallback, parse, replace = true }: SearchParamOptions<T>): SearchParam<T> {\n const [params, setParams] = useSearchParams();\n const raw = params.get(key);\n let value = fallback;\n if (raw !== null) {\n const parsed = parse ? parse(raw) : (raw as T);\n if (parsed === true) value = raw as T;\n else if (typeof parsed === \"string\") value = parsed;\n }\n const set = React.useCallback(\n (next: T | null) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n if (next === null || next === fallback) out.delete(key);\n else out.set(key, next);\n return out;\n },\n { replace },\n ),\n [key, fallback, replace, setParams],\n );\n return [value, set];\n}\n","// Control sizes, one set for everything that sits in a toolbar or a property row: `default` is\n// --control-h and `sm` is --control-h-sm, so two controls of the same size name are the same height\n// in every density (issue #117). Button, IconButton, Toggle, ToggleGroup, Input, NativeSelect and\n// NumberField all take it as `size`.\n\n/** The size names a control takes: `default` (--control-h) or `sm` (--control-h-sm). */\nexport type ControlSize = \"default\" | \"sm\";\n\n/** The height class of each control size. */\nexport const controlHeight: Record<ControlSize, string> = {\n default: \"h-(--control-h)\",\n sm: \"h-(--control-h-sm)\",\n};\n","import * as React from \"react\";\nimport { CircleAlert } from \"lucide-react\";\nimport { Label, Radio, RadioGroup } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { useSearchParam } from \"../lib/search-param\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Field owns the wiring a generated form usually forgets: the label's htmlFor, aria-describedby\n// pointing at the hint and the error, and aria-invalid. Controls read it from context, so a control\n// inside a Field cannot end up unlabelled or silently invalid.\n//\n// A one-field form (\"paste a link, Add\", a search box, \"invite by email\") puts its button on the\n// control's row, not beside the whole field (strata-react issue #46, from the Tubes Library\n// screen): in a plain flex row the button lines up with label, hint and error together and drifts\n// off the input whenever one shows. `action` is drawn on the control's row, both at --control-h,\n// with the hint and the error under both across the full width. It wraps under the control only\n// when the row cannot keep the control 10rem wide beside it (a 250px inspector body keeps a Reset beside its slider, issue #116): on a phone a short \"Add\" stays on the\n// row, as a search box's button does, and a long label or a narrow column wraps. The error and hint stay the input's description; the\n// button is not described by them. Field messages for a form come from `useAsyncAction`'s\n// `fieldErrors` (its `validate`, or the server's 422), so no `problem` state is kept by hand.\n\ntype FieldState = { id: string; label: string; describedBy?: string; invalid: boolean; report: (message: string | undefined) => void };\nconst FieldContext = React.createContext<FieldState | null>(null);\n\n// A control that checks what was typed (a number field, a colour field) reports its own message to\n// the Field it sits in, which draws it as the field's error, so a value outside the limits is\n// explained in the same place and way as a server's 422, with nothing for the screen to wire.\n// `error` from the screen wins over the control's own. Outside a Field `report` does nothing and\n// the control marks itself invalid without a message.\n/** @internal The surrounding Field, and where a control reports its own message. */\nexport function useFieldControl() {\n const field = React.useContext(FieldContext);\n return { field, report: field?.report ?? noReport };\n}\n\nfunction useField(id?: string) {\n const field = React.useContext(FieldContext);\n return {\n // Inside a Field the Field's id wins, so the label always points at the control. To choose the\n // id yourself, pass it to Field.\n id: field?.id ?? id,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid || undefined,\n };\n}\n\nconst noReport = () => {};\n\nexport type FieldProps = {\n label: string;\n /** The control's id, when the page needs a known one (an anchor, a test). Generated otherwise. */\n id?: string;\n /** What the person needs to know before typing, such as limits or units. */\n hint?: React.ReactNode;\n /** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */\n error?: string;\n /** A button on the control's row, for a one-field form (an `AsyncButton` \"Add\"). The hint and error run under both; on a narrow screen it wraps under the control. */\n action?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n};\n\n/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */\nexport function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps) {\n const generated = React.useId();\n const id = idProp ?? generated;\n const hintId = hint ? `${id}-hint` : undefined;\n const [reported, report] = React.useState<string>();\n const shown = error ?? reported;\n const errorId = shown ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, label, describedBy, invalid: Boolean(shown), report }}>\n <div className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n <label htmlFor={id} className=\"type-label text-foreground\">\n {label}\n </label>\n {action ? (\n <div className=\"flex flex-wrap items-start gap-2\">\n <div className=\"min-w-40 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {shown && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {shown}\n </p>\n )}\n {hint && (\n <p id={hintId} className=\"type-body-sm text-muted-foreground\">\n {hint}\n </p>\n )}\n </div>\n </FieldContext.Provider>\n );\n}\n\nconst control =\n \"w-full min-w-0 rounded-control border border-input bg-background px-3 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger\";\n\n/** A text input that picks up its id and descriptions from the surrounding `Field`. `size=\"sm\"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */\nexport function Input({ className, id, size = \"default\", ...props }: Omit<React.ComponentProps<\"input\">, \"size\"> & { size?: ControlSize }) {\n return <input {...useField(id)} className={cn(control, controlHeight[size], className)} {...props} />;\n}\n\n/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Textarea({ className, id, ...props }: React.ComponentProps<\"textarea\">) {\n return <textarea {...useField(id)} className={cn(control, \"min-h-24 py-2\", className)} {...props} />;\n}\n\n// A native select, styled. For short option lists on a touch screen it beats a custom listbox:\n// the platform picker, typeahead and form autofill all work with no code.\n/** The platform select, styled. The default for short lists, especially on touch screens. `size=\"sm\"` is --control-h-sm. */\nexport function NativeSelect(props: NativeSelectProps) {\n // `param` is a different component so a select outside a router (no `param`) never calls router hooks.\n return props.param === undefined ? <PlainSelect {...(props as PlainSelectProps)} /> : <ParamSelect {...props} />;\n}\n\ntype PlainSelectProps = Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize };\n\n/** Props of `NativeSelect`: a native select's own, or (with `param`) a choice held in the URL. */\nexport type NativeSelectProps =\n | PlainSelectProps & { param?: undefined; paramDefault?: undefined }\n | (Omit<PlainSelectProps, \"value\" | \"defaultValue\" | \"onChange\"> & {\n /** The search parameter that holds the choice (`?mode=…`), so it can be linked and survives a reload. */\n param: string;\n /** The option that is chosen when the URL says nothing; choosing it removes the param. */\n paramDefault: string;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n });\n\nfunction PlainSelect({ className, id, size = \"default\", ...props }: PlainSelectProps) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"pr-8\", className)} {...props} />;\n}\n\n/** The values of every `<option>`, looking inside `<optgroup>`s and fragments. */\nfunction optionValues(children: React.ReactNode): string[] {\n return React.Children.toArray(children).flatMap((c) => {\n if (!React.isValidElement<{ value?: string; children?: React.ReactNode }>(c)) return [];\n if (c.type === \"option\") return [c.props.value ?? String(c.props.children)];\n return optionValues(c.props.children);\n });\n}\n\nfunction ParamSelect({ param, paramDefault, onChange, children, ...props }: Extract<NativeSelectProps, { param: string }>) {\n // An unknown value in the URL reads as the default: the select shows an option that exists.\n const options = optionValues(children);\n const [value, setValue] = useSearchParam(param, { default: paramDefault, parse: (raw) => options.length === 0 || options.includes(raw) });\n return (\n <PlainSelect\n {...props}\n value={value}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value);\n }}\n >\n {children}\n </PlainSelect>\n );\n}\n\n// Radio choices: React Aria's RadioGroup (a group named by its label, arrow-key movement, one tab\n// stop), and each row wraps its control so the whole row is one hit target. The dot is drawn from\n// tokens, not the platform's accent-color radio.\n/** One option of a `ChoiceGroup`: its value, its words, and optionally a decorative `leading` mark (a swatch) before the words, which a screen reader skips, so the label must say it all. */\nexport type Choice = { value: string; label: string; detail?: string; leading?: React.ReactNode };\n\n/** Radio choices in a fieldset with a legend; each whole row is the hit target. For 2 to 5 options that each need a sentence. */\nexport function ChoiceGroup(props: ChoiceGroupProps) {\n return props.param === undefined ? <ChoiceGroupView {...props} /> : <ParamChoiceGroup {...props} />;\n}\n\n/** Props of `ChoiceGroup`: the value and `onChange` are the caller's, or (with `param`) the URL's, the first choice being the default. */\nexport type ChoiceGroupProps = {\n legend: string;\n name: string;\n choices: Choice[];\n error?: string;\n} & (\n | { value: string; onChange: (value: string) => void; param?: undefined }\n | {\n /** The search parameter that holds the choice, so it can be linked and survives a reload. The first choice is the default and is not written. */\n param: string;\n value?: undefined;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n }\n);\n\nfunction ParamChoiceGroup({ param, choices, onChange, ...props }: Extract<ChoiceGroupProps, { param: string }>) {\n const [value, setValue] = useSearchParam(param, { default: choices[0]?.value ?? \"\", parse: (raw) => choices.some((c) => c.value === raw) });\n return <ChoiceGroupView {...props} choices={choices} value={value} onChange={(next) => { setValue(next); onChange?.(next); }} />;\n}\n\nfunction ChoiceGroupView({\n legend,\n name,\n choices,\n value,\n onChange,\n error,\n}: {\n legend: string;\n name: string;\n choices: Choice[];\n value: string;\n onChange: (value: string) => void;\n error?: string;\n}) {\n const errorId = React.useId();\n return (\n <RadioGroup name={name} value={value} onChange={onChange} aria-describedby={error ? errorId : undefined} className=\"grid gap-2\">\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio key={c.value} value={c.value} className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\">\n <span\n aria-hidden\n className=\"mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100\" />\n </span>\n {c.leading && <span className=\"mt-0.5 shrink-0\">{c.leading}</span>}\n <span className=\"grid\">\n <span className=\"type-body\">{c.label}</span>\n {c.detail && <span className=\"type-body-sm text-muted-foreground\">{c.detail}</span>}\n </span>\n </Radio>\n ))}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n </RadioGroup>\n );\n}\n"],"mappings":";;;;;;;AA4CA,IAAa,OAAO;;AAGpB,IAAa,UAAU;AAIvB,IAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,IAAM,YAAY,OAAO,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC,GAAG,OAAQ,CAAC,CAAC,CAAC;AAI7E,IAAM,eAA0C;CAAC;CAAK;CAAO;CAAO;CAAO;CAAO;AAAK;AACvF,IAAM,cAAc,OAAO,YAAY,aAAa,KAAK,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AACjF,IAAM,OAAkD;CAAE,GAAG;CAAW,GAAG;AAAY;AAKvF,SAAS,eAAe,OAAe,QAA4C;CAEjF,OAAO,CAAC,GAD8C,SAAS,eAAe,UAC9D,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,KAAK,EAAE,KAAK;AACzE;;AAgCA,SAAgB,OAAO,OAAwB;CAC7C,MAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;CAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG,MAAM,IAAI,WAAW,eAAe,KAAK,UAAU,OAAO,KAAK,CAAC,GAAG;CACrG,OAAO;AACT;AAEA,SAAS,aAAa,IAAyB,SAAgC;CAC7E,MAAM,UAAU,UAAyC,SAAS,OAAO,UAAU,GAAG,OAAO,OAAO,KAAK,CAAC;CAC1G,OAAO,OAAO,OAAO,QAAQ;EAC3B;EACA,gBAAgB,UAAqB,GAAG,cAAc,OAAO,KAAK,CAAC;EACnE,cAAc,OAAkB,QAAmB,GAA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AO,WAAW,SAAS;GAAE,SAAS,IAAI;GAAG,WAAW,IAAI;EAAG;CAAI,CAAA;AACjI;AAEA,SAAS,gBAAgB,EACvB,QACA,MACA,SACA,OACA,UACA,SAQC;CACD,MAAM,UAAU,MAAM,MAAM;CAC5B,OACE,qBAAC,YAAD;EAAkB;EAAa;EAAiB;EAAU,oBAAkB,QAAQ,UAAU,KAAA;EAAW,WAAU;EAAnH,UAAA;GACE,oBAAC,OAAD;IAAO,WAAU;IAAqC,UAAA;GAAc,CAAA;GACnE,QAAQ,KAAK,MACZ,qBAAC,OAAD;IAAqB,OAAO,EAAE;IAAO,WAAU;IAA/C,UAAA;KACE,oBAAC,QAAD;MACE,eAAA;MACA,WAAU;MAEV,UAAA,oBAAC,QAAD,EAAM,WAAU,sEAAuE,CAAA;KACnF,CAAA;KACL,EAAE,WAAW,oBAAC,QAAD;MAAM,WAAU;MAAmB,UAAA,EAAE;KAAc,CAAA;KACjE,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAM,WAAU;OAAa,UAAA,EAAE;MAAY,CAAA,GAC1C,EAAE,UAAU,oBAAC,QAAD;OAAM,WAAU;OAAsC,UAAA,EAAE;MAAa,CAAA,CAC9E;;IACD;GAZK,GAAA,EAAE,KAYP,CACR;GACA,SACC,qBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;IAA1B,UAAA,CACE,oBAAC,aAAD;KAAa,eAAA;KAAY,WAAU;IAA0B,CAAA,GAC5D,KACA;;EAEK;;AAEhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"follow-BTPs49FP.js","names":[],"sources":["../src/lib/follow.ts"],"sourcesContent":["// Pure, so the camera maths (no GL, no React) can use it. See `followAim`.\n\n/**\n * Where a viewer looks when it follows something that moves (a player in a replay, a camera operator): the heading the app\n * supplies, with the person's own look added on top, so panning during playback still works and \"through the player's eyes\" is just\n * `follow` mode. Degrees, positive yaw to the right and positive pitch up, the same in `PanoramaViewer` and `SceneViewport`.\n * Yaw wraps to -180 to 180 and pitch is held to `maxPitch` (default 89), where \"up\" stops meaning anything.\n */\nexport function followAim({ heading, pitch = 0, look, maxPitch = 89 }: { heading: number; pitch?: number; look?: { yaw?: number; pitch?: number }; maxPitch?: number }): { yaw: number; pitch: number } {\n const yaw = ((((heading + (look?.yaw ?? 0) + 180) % 360) + 360) % 360) - 180;\n return { yaw, pitch: Math.min(Math.max(pitch + (look?.pitch ?? 0), -maxPitch), maxPitch) };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,UAAU,EAAE,SAAS,QAAQ,GAAG,MAAM,WAAW,MAAuI;CAEtM,OAAO;EAAE,OADO,WAAW,MAAM,OAAO,KAAK,OAAO,MAAO,OAAO,MAAO;EAC3D,OAAO,KAAK,IAAI,KAAK,IAAI,SAAS,MAAM,SAAS,IAAI,CAAC,QAAQ,GAAG,QAAQ;CAAE;AAC3F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-CjTHKJ39.js","names":[],"sources":["../src/api-types/generate.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport { pathToFileURL } from \"node:url\";\n\n// The types behind `strata-api-types` (strata-react issue #263). A strata app's FastAPI server\n// publishes its routes, the shared contracts (`strata_python.contracts`: Health, Task, Page, ErrorBody…)\n// and its typed settings at `/api/openapi.json`; the TypeScript types follow that schema instead of\n// being written again by hand and drifting. The work of reading OpenAPI is `openapi-typescript`\n// (Jonathan, 2026-11-14: types only, nothing in the app's bundle); this file adds where the schema\n// comes from (a running server, or a file the server's own CLI wrote, so CI needs no server) and what\n// the committed file looks like. It lives behind its own entry (`strata-react/api-types`), like\n// `strata-react/visual`, and `openapi-typescript` is an optional peer, so an app that never runs the\n// command installs nothing and the main entry's peer contract is unchanged.\n//\n// The output is deterministic, so `--check` can compare it with the committed file and fail CI when\n// the Python side moved and the file did not. Nothing about the machine (the URL it was read from, a\n// date) goes into it, for the same reason.\n\n/** The OpenAPI document as the generator takes it: a parsed JSON object. */\nexport type OpenApiDocument = Record<string, unknown>;\n\n/** Reads an OpenAPI document from an `http(s)` URL (a running server) or a JSON file path. */\nexport async function loadSchema(source: string, fetcher: typeof fetch = fetch): Promise<OpenApiDocument> {\n let text: string;\n if (/^https?:\\/\\//i.test(source)) {\n const response = await fetcher(source, { headers: { accept: \"application/json\" } });\n if (!response.ok) throw new Error(`${source} answered ${response.status} ${response.statusText}`);\n text = await response.text();\n } else {\n text = await readFile(source, \"utf8\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new Error(`${source} is not JSON. Give the OpenAPI document (/api/openapi.json), not the docs page.`);\n }\n if (!parsed || typeof parsed !== \"object\" || !(\"openapi\" in parsed)) throw new Error(`${source} is JSON but not an OpenAPI document (no \"openapi\" field).`);\n return parsed as OpenApiDocument;\n}\n\nconst header = `/* eslint-disable */\n// Generated by strata-api-types from the app's OpenAPI schema. Do not edit by hand:\n// regenerate with \\`strata-api-types <schema> -o <this file>\\`; CI runs it with --check.\n`;\n\n// Short names for the schemas, so a screen writes \\`Schema<\"Task\">\\` and not the whole path.\nconst footer = `\n/** A named schema of the API: \\`Schema<\"Task\">\\`. */\nexport type Schema<K extends keyof components[\"schemas\"]> = components[\"schemas\"][K];\n`;\n\n/** The URL relative references resolve against: the document's own URL, or its file's location. */\nfunction baseOf(source: string): URL {\n return /^https?:\\/\\//i.test(source) ? new URL(source) : pathToFileURL(resolve(source));\n}\n\n/** The message for a failed `import(\"openapi-typescript\")`: absent, or present but unable to load (issue #293: a TypeScript 7 app was told to install what it had). */\nexport function explainImportFailure(cause: unknown, typescriptMajor: number | undefined = installedTypescriptMajor()): string {\n const text = cause instanceof Error ? cause.message : String(cause);\n const code = (cause as { code?: string } | null)?.code;\n const notFound = (code === \"ERR_MODULE_NOT_FOUND\" || code === \"MODULE_NOT_FOUND\") && /Cannot find (package|module) 'openapi-typescript'/.test(text);\n if (notFound) {\n return \"strata-api-types needs openapi-typescript: npm install --save-dev openapi-typescript (see \\\"API types from the server\\\" in the README for the TypeScript it wants).\";\n }\n const hint =\n typescriptMajor !== undefined && typescriptMajor >= 7\n ? ` The \\`typescript\\` package installed here is version ${typescriptMajor}, which ships no JavaScript API, and openapi-typescript needs one. Install TypeScript 6's under the name \\`typescript\\` (\"typescript\": \"npm:@typescript/typescript6@~6.0.2\", with TypeScript 7 as another name such as \"typescript7\" for \\`tsc\\`) and keep the \\`overrides\\` entry; see \"API types from the server\" in the README.`\n : \" It is installed but did not load; the cause is above. It needs a `typescript` package with a JavaScript API (TypeScript 5 or 6).\";\n return `strata-api-types could not load openapi-typescript: ${text}.${hint}`;\n}\n\n/** The major version of the `typescript` package an app resolves, or `undefined` when none can be read. */\nfunction installedTypescriptMajor(): number | undefined {\n try {\n const { version } = createRequire(resolve(\"package.json\"))(\"typescript/package.json\") as { version?: string };\n const major = Number.parseInt(version ?? \"\", 10);\n return Number.isNaN(major) ? undefined : major;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The TypeScript types for an OpenAPI document, as the text of the generated file. `source` is where the\n * document was read from (a URL or file path): relative `$ref`s to other files resolve against it.\n */\nexport async function generateApiTypes(schema: OpenApiDocument, source?: string): Promise<string> {\n const mod = await import(\"openapi-typescript\").catch((cause: unknown) => {\n throw new Error(explainImportFailure(cause), { cause });\n });\n const { default: openapiTS, astToString } = mod;\n const ast = await openapiTS(schema as never, source ? { cwd: baseOf(source) } : undefined);\n return `${header}\\n${astToString(ast).trimEnd()}\\n${footer}`;\n}\n"],"mappings":";;;;;;AAuBA,eAAsB,WAAW,QAAgB,UAAwB,OAAiC;CACxG,IAAI;CACJ,IAAI,gBAAgB,KAAK,MAAM,GAAG;EAChC,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE,SAAS,EAAE,QAAQ,mBAAmB,EAAE,CAAC;EAClF,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,GAAG,OAAO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C;CACxD,CAAC;CAGD,OAAO,GAAG,OAAO,IAAI,YAAY,MADf,UAAU,QAAiB,SAAS,EAAE,KAAK,OAAO,MAAM,EAAE,IAAI,KAAA,CAAS,CACrD,CAAC,CAAC,QAAQ,EAAE,IAAI;AACtD"}
|
package/dist/lib/base.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where the app is mounted: the path of the page's `<base href>` without its trailing slash, `""` at the root or where there is no base (SSR, a plain page).
|
|
3
|
-
* Give it to React Router as `createBrowserRouter(routes, { basename: appBase() || "/" })`.
|
|
4
|
-
*/
|
|
5
|
-
export declare function appBase(doc?: Document | undefined): string;
|
|
6
|
-
/**
|
|
7
|
-
* Puts the app's base in front of a root-relative path (`/api/learners` becomes `/proxy/api/learners` behind a proxy).
|
|
8
|
-
* Anything else (a relative path, a full URL, a protocol-relative `//host`) is returned as it is. Use it for every `fetch`, `<img src>` and download link the app builds; in-app links are router paths and need none.
|
|
9
|
-
*/
|
|
10
|
-
export declare function withBase(path: string, base?: string): string;
|
package/dist/lib/book.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** A page as the lookup sees it: its position in the scan (1-based, as a person counts) and its printed label, if it has one. */
|
|
2
|
-
export type PageNames = {
|
|
3
|
-
scan: string;
|
|
4
|
-
printed?: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* The pages shown together, as indexes into the set. In a spread the first page stands alone on
|
|
8
|
-
* the right (a book opens on its first recto, so the left side is empty), then pages pair 2 and 3,
|
|
9
|
-
* 4 and 5, and an odd one out at the end stands alone on the left. In a single layout every page
|
|
10
|
-
* is its own view.
|
|
11
|
-
*/
|
|
12
|
-
export declare function viewsOf(count: number, spread: boolean): number[][];
|
|
13
|
-
/** The index of the view that holds page `index`. */
|
|
14
|
-
export declare function viewOf(index: number, spread: boolean): number;
|
|
15
|
-
/**
|
|
16
|
-
* Finds the page a person typed. A printed label wins ("iv", "12") because that is what is printed
|
|
17
|
-
* on the page they are looking at; otherwise it is the scan's own position ("22" is the 22nd
|
|
18
|
-
* image). Roman numerals and any other label match as text, case aside. Returns the index, or
|
|
19
|
-
* `null` when no page has that name.
|
|
20
|
-
*/
|
|
21
|
-
export declare function findPage(pages: readonly PageNames[], query: string): number | null;
|
|
22
|
-
/** A page said in words: "Page 22 (12)" or "Page 22" with no printed label. */
|
|
23
|
-
export declare const pageName: (p: PageNames, word?: string) => string;
|
|
24
|
-
/** Where the viewer is, in words: "Page 22 (12) of 44", or "Pages 22 and 23 of 44" for a spread. */
|
|
25
|
-
export declare function sayPosition(shown: readonly PageNames[], total: number, word?: string, plural?: string): string;
|
package/dist/lib/boxes.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Viewport } from './viewport';
|
|
2
|
-
import { Rect } from './region';
|
|
3
|
-
/** A box on a picture, in the picture's own pixels. `label` names it for assistive technology and the list beside it. */
|
|
4
|
-
export type PictureBox = Rect & {
|
|
5
|
-
id: string;
|
|
6
|
-
label: string;
|
|
7
|
-
tone?: BoxTone;
|
|
8
|
-
};
|
|
9
|
-
/** The status role a box is drawn in. `neutral` is the foreground. Outline only, so the type underneath stays readable. */
|
|
10
|
-
export type BoxTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
11
|
-
/**
|
|
12
|
-
* The boxes in reading order: top to bottom in rows, left to right within a row. A box joins the
|
|
13
|
-
* row above when its centre falls inside that row's first box vertically, so lines of text that
|
|
14
|
-
* wobble a few pixels still read in order and two columns read row by row, not column by column.
|
|
15
|
-
* Returns ids, so a caller keeps its own objects.
|
|
16
|
-
*/
|
|
17
|
-
export declare function readingOrder(boxes: readonly Rect[] & readonly {
|
|
18
|
-
id: string;
|
|
19
|
-
}[]): string[];
|
|
20
|
-
/**
|
|
21
|
-
* The viewport that fills a frame with one box of the picture. The picture sits in the frame the way
|
|
22
|
-
* `object-fit: contain` puts it (a frame of another shape leaves bars), which is also how
|
|
23
|
-
* `BoxOverlay` draws it, so the same numbers agree. `margin` is the share of the box added on every
|
|
24
|
-
* side so the box is not touching the frame (default 0.25).
|
|
25
|
-
*/
|
|
26
|
-
export declare function zoomToBox(box: Rect, of: {
|
|
27
|
-
w: number;
|
|
28
|
-
h: number;
|
|
29
|
-
}, frame: {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
}, margin?: number): Viewport;
|
|
33
|
-
/** One box of a picture to show on its own, as `Thumbnail`'s `region` takes it: the picture's size, the box in its pixels, and `pad`, how many times the box's size the crop is (default 1.6, a face with its hair and chin). */
|
|
34
|
-
export type PictureRegion = {
|
|
35
|
-
of: {
|
|
36
|
-
w: number;
|
|
37
|
-
h: number;
|
|
38
|
-
};
|
|
39
|
-
box: Rect;
|
|
40
|
-
pad?: number;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Where the whole picture goes so that one box of it fills a frame of `aspect` (width over height), as
|
|
44
|
-
* percentages of the frame: the crop is the box grown `pad` times about its centre, then widened or
|
|
45
|
-
* heightened to the frame's shape, so the box is never squashed and stays in the middle. A crop that
|
|
46
|
-
* runs past the picture's edge shows the frame's own ground there, as a face at the edge of a photo
|
|
47
|
-
* is shown by a server crop that pads. No canvas and no second request: the browser draws the one
|
|
48
|
-
* picture, which a list of faces from the same photo shares from its cache.
|
|
49
|
-
*/
|
|
50
|
-
export declare function regionStyle({ of, box, pad }: PictureRegion, aspect: number): {
|
|
51
|
-
left: string;
|
|
52
|
-
top: string;
|
|
53
|
-
width: string;
|
|
54
|
-
height: string;
|
|
55
|
-
};
|