strata-react 1.3.24 → 1.3.26
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 -1
- package/UPGRADING.md +7 -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-CXQsL86O.js +16 -0
- 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 +5300 -140
- package/dist/index.js +363 -224
- 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 +54 -109
- 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 +74 -77
- 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-3Qa-o35k.js +108 -0
- package/dist/viewer-input-3Qa-o35k.js.map +1 -0
- 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/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/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/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 -74
- 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
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** A brief, non-blocking playback warning. Important playback failures use the player's error state. */
|
|
3
|
+
type PlayerWarning = {
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
/** Milliseconds on screen. Defaults to the shared toast reading time. */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
action?: {
|
|
9
|
+
label: string;
|
|
10
|
+
onPress: () => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** The current warning event, including its identity so repeated warnings start a fresh timer. */
|
|
14
|
+
type PlayerWarningEvent = PlayerWarning & {
|
|
15
|
+
key: number;
|
|
16
|
+
};
|
|
17
|
+
/** Creates a warning channel for one player. Pass `warning` to MediaPlayer and call `warn` when a warning occurs. */
|
|
18
|
+
declare function usePlayerWarnings(): {
|
|
19
|
+
warning: PlayerWarningEvent | undefined;
|
|
20
|
+
warn: (message: PlayerWarning) => void;
|
|
21
|
+
};
|
|
22
|
+
/** A named point on a player's timeline: a chapter (the default) or a scene within one. */
|
|
23
|
+
type MediaMark = {
|
|
24
|
+
time: number;
|
|
25
|
+
label: string;
|
|
26
|
+
kind?: "chapter" | "scene";
|
|
27
|
+
};
|
|
28
|
+
/** The two skip levels. */
|
|
29
|
+
type SkipLevel = "small" | "large";
|
|
30
|
+
/** The time steps for a file without parts at that level, in seconds. */
|
|
31
|
+
type SkipSteps = {
|
|
32
|
+
small?: number;
|
|
33
|
+
large?: number;
|
|
34
|
+
};
|
|
35
|
+
/** What a skip does: its button's name, and where it goes (null when there is nowhere, at either end). */
|
|
36
|
+
type SkipAction = {
|
|
37
|
+
label: string;
|
|
38
|
+
to: number | null;
|
|
39
|
+
by: "mark" | "time";
|
|
40
|
+
};
|
|
41
|
+
/** The marks a level skips by: scenes for small, chapters (and marks with no kind) for large, in time order. */
|
|
42
|
+
declare function marksFor(marks: readonly MediaMark[], level: SkipLevel): number[];
|
|
43
|
+
/**
|
|
44
|
+
* Where a skip at `level` in `direction` from `time` goes: by the level's marks when the file has any
|
|
45
|
+
* (the file's start counts as one), else by its time step. `restart` is how far into a part
|
|
46
|
+
* "previous" still means its start. The target is kept within 0 to `duration` when that is known, and marks past it are not skipped to.
|
|
47
|
+
*/
|
|
48
|
+
declare function skipAction(marks: readonly MediaMark[], level: SkipLevel, direction: -1 | 1, time: number, { steps, duration, restart }?: {
|
|
49
|
+
steps?: SkipSteps;
|
|
50
|
+
duration?: number | null;
|
|
51
|
+
restart?: number;
|
|
52
|
+
}): SkipAction;
|
|
53
|
+
/** Who set the cursor: a pointer or key over a member, or playback (a player's clock). */
|
|
54
|
+
type CursorOwner = "pointer" | "playback";
|
|
55
|
+
/** How a member's own x relates to the scope's unit. Both default to the identity. */
|
|
56
|
+
type CursorMapping = {
|
|
57
|
+
/** 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). */
|
|
58
|
+
toCursor?: (x: number) => number;
|
|
59
|
+
/** From the scope's unit to this member's x. */
|
|
60
|
+
fromCursor?: (at: number) => number;
|
|
61
|
+
};
|
|
62
|
+
type Snapshot = {
|
|
63
|
+
/** The position now: the pointer's while there is one, else playback's; null when neither is set. */
|
|
64
|
+
at: number | null;
|
|
65
|
+
/** Who wrote `at`; a member ignores a position it wrote. */
|
|
66
|
+
source: string | null;
|
|
67
|
+
owner: CursorOwner | null;
|
|
68
|
+
};
|
|
69
|
+
type CursorScopeProps = {
|
|
70
|
+
children: React.ReactNode;
|
|
71
|
+
/** Words for the position in the scope's unit ("12.4 km along", "1:23"), for the polite announcement. Without it nothing is announced. */
|
|
72
|
+
format?: (at: number) => string;
|
|
73
|
+
/** Milliseconds between announcements. Default 1000. */
|
|
74
|
+
announceEvery?: number;
|
|
75
|
+
};
|
|
76
|
+
/** 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. */
|
|
77
|
+
declare function CursorScope({ children, format, announceEvery }: CursorScopeProps): React.JSX.Element;
|
|
78
|
+
/** What a member reads and writes. */
|
|
79
|
+
type SharedCursor = Snapshot & {
|
|
80
|
+
/** This member's own id: positions it writes are not drawn back at it. */
|
|
81
|
+
source: string;
|
|
82
|
+
/** The position another member (or playback) put there, in the scope's unit; null when none or when this member wrote it. */
|
|
83
|
+
other: number | null;
|
|
84
|
+
/** The pointer or keyboard is at `at` over this member (the scope's unit). `null`: it left. */
|
|
85
|
+
setPointer: (at: number | null) => void;
|
|
86
|
+
/** Playback is at `at` (the scope's unit). Call it from the player's clock; `null` when it stops. */
|
|
87
|
+
setPlayback: (at: number | null) => void;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Join the nearest `CursorScope` as one member. Returns null outside a scope, so a component can take a
|
|
91
|
+
* `cursor` prop and do nothing when the app has not set one up. `source` is this member's id; the
|
|
92
|
+
* default is a unique one.
|
|
93
|
+
*/
|
|
94
|
+
declare function useSharedCursor(source?: string): SharedCursor | null;
|
|
95
|
+
type Point = {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
};
|
|
99
|
+
/** Shading tones for `spans`: the role's subtle fill. */
|
|
100
|
+
type SpanTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
101
|
+
/** A stretch of x shaded behind the line (stops, usable footage, a chosen stretch). */
|
|
102
|
+
type ChartSpan = {
|
|
103
|
+
from: number;
|
|
104
|
+
to: number;
|
|
105
|
+
label: string;
|
|
106
|
+
tone?: SpanTone;
|
|
107
|
+
};
|
|
108
|
+
/** A labelled point on the line, as a control. */
|
|
109
|
+
type ChartMark = {
|
|
110
|
+
x: number;
|
|
111
|
+
/** Its name: "Clip 4". Said with its x, listed for screen readers and shown on hover and focus. */
|
|
112
|
+
label: string;
|
|
113
|
+
/** Any CSS colour, normally a role. Default the foreground. */
|
|
114
|
+
colour?: string;
|
|
115
|
+
selected?: boolean;
|
|
116
|
+
};
|
|
117
|
+
type LineChartProps = {
|
|
118
|
+
/** What the chart shows, as a sentence. Used as the accessible name and the table caption. */
|
|
119
|
+
label: string;
|
|
120
|
+
series: Point[];
|
|
121
|
+
seriesLabel: string;
|
|
122
|
+
planned?: Point[];
|
|
123
|
+
plannedLabel?: string;
|
|
124
|
+
band?: {
|
|
125
|
+
below: number;
|
|
126
|
+
label: string;
|
|
127
|
+
};
|
|
128
|
+
/** The lowest and highest value each reading stands for, by index into `series` (a downsampled track keeps its extremes). Drawn as a pale area behind the line, included in the y-axis, said in the readout and the table. `label` names it in the key: "Lowest to highest in each stretch". */
|
|
129
|
+
range?: {
|
|
130
|
+
low: readonly number[];
|
|
131
|
+
high: readonly number[];
|
|
132
|
+
label: string;
|
|
133
|
+
};
|
|
134
|
+
formatX: (x: number) => string;
|
|
135
|
+
/** What x is, as the screen-reader table's first column heading: "Distance", "Day". Default "Time". */
|
|
136
|
+
xLabel?: string;
|
|
137
|
+
formatY: (y: number) => string;
|
|
138
|
+
/** Where to put x labels, in x units, or a function of the visible range (so labels can switch between clock time and distance). The chart drops every other one (and so on) when they would overlap at its width. */
|
|
139
|
+
xTicks: number[] | ((range: {
|
|
140
|
+
min: number;
|
|
141
|
+
max: number;
|
|
142
|
+
}) => number[]);
|
|
143
|
+
/** A fixed x range, for charts that share one axis (`LineChartGroup` sets it). Default: the series' own. */
|
|
144
|
+
xDomain?: readonly [number, number];
|
|
145
|
+
/** `"none"` draws no x labels: the upper charts of a stack. Default `"labels"`. */
|
|
146
|
+
xAxis?: "labels" | "none";
|
|
147
|
+
/** `"log"` for a quantity that spans decades (pace, a magnitude). Ticks are 1, 2, 5 steps chosen here; a reading at or below zero is not drawn and is counted under the chart. Default `"linear"`. */
|
|
148
|
+
yScale?: "linear" | "log";
|
|
149
|
+
/** The smaller value at the top (pace: faster is up). */
|
|
150
|
+
yInvert?: boolean;
|
|
151
|
+
/** Stretches shaded behind the line, named in the key and the text for screen readers. */
|
|
152
|
+
spans?: readonly ChartSpan[];
|
|
153
|
+
/** Labelled points on the line. One tab stop; arrows move between them. */
|
|
154
|
+
marks?: readonly ChartMark[];
|
|
155
|
+
/** A mark was pressed (a click, Enter or Space). */
|
|
156
|
+
onMarkSelect?: (mark: ChartMark) => void;
|
|
157
|
+
/** What shows beside a mark on hover and focus: words, as in `Tooltip`. Default the mark's label and x. */
|
|
158
|
+
renderMarkCard?: (mark: ChartMark) => React.ReactNode;
|
|
159
|
+
/** Join the nearest `CursorScope`: hovering or arrowing here puts a rule and this chart's reading in every member, and theirs shows here. `true` when x is the scope's unit; a mapping when it is not (time here, distance there). */
|
|
160
|
+
cursor?: boolean | CursorMapping;
|
|
161
|
+
/** Pin the bottom of the y-axis (default: 0, or lower if a reading is negative). A reading below it still shows. */
|
|
162
|
+
yMin?: number;
|
|
163
|
+
/** Pin the top of the y-axis, for a bounded quantity such as a percentage (`yMax={100}`), so a low reading looks low. Choose a range that divides into four steps. A reading above it still shows. */
|
|
164
|
+
yMax?: number;
|
|
165
|
+
/** CSS colour for the measured series. Defaults to the first chart token. */
|
|
166
|
+
colour?: string;
|
|
167
|
+
/** Colour the measured series by value: each stop applies from `at` upwards, blending to the
|
|
168
|
+
* next. Only where the colour means something in the subject; record the reason in DESIGN.md. */
|
|
169
|
+
colourScale?: {
|
|
170
|
+
at: number;
|
|
171
|
+
colour: string;
|
|
172
|
+
}[];
|
|
173
|
+
/** Says what the colours mean, shown beside the legend swatch when `colourScale` is set. */
|
|
174
|
+
colourScaleLabel?: string;
|
|
175
|
+
/** What the end of the line is. `"now"` marks the last reading with a rule, a dot and "<value> now": right for a live reading, where the last point is the present. `"none"` leaves it unmarked: right for a series whose x is not time running up to now (an elevation profile, where the last point is the finish). Default `"now"`, or `"none"` when `current` is set, since `current` already says where now is. The peak label stays either way. */
|
|
176
|
+
end?: "now" | "none";
|
|
177
|
+
/** The current x, supplied by the app and drawn as a rule with its value ("now" in a replay, a playhead). Cheap to update often. */
|
|
178
|
+
current?: number;
|
|
179
|
+
/** The value at the rule, as a sentence part. Default: `formatX` and the value read off the line. */
|
|
180
|
+
formatCurrent?: (at: {
|
|
181
|
+
x: number;
|
|
182
|
+
y: number;
|
|
183
|
+
}) => string;
|
|
184
|
+
/** Read values at the pointer, and by keyboard on the plot (arrows, Home, End). `readout` words the reading; default `formatX: formatY`. */
|
|
185
|
+
readout?: boolean | ((p: Point) => string);
|
|
186
|
+
/** The viewer chose a reading (a click, or Enter on the plot): its x, so the app can seek or select. */
|
|
187
|
+
onPick?: (x: number) => void;
|
|
188
|
+
/** One flat, pale tint under the line. Only where the area carries the meaning (a profile, a running total). */
|
|
189
|
+
area?: boolean;
|
|
190
|
+
height?: number;
|
|
191
|
+
className?: string;
|
|
192
|
+
};
|
|
193
|
+
/** What a y scale gives the chart: its ends, ticks and where a value falls between them (0 at `min`, 1 at `max`). */
|
|
194
|
+
type YScale = {
|
|
195
|
+
min: number;
|
|
196
|
+
max: number;
|
|
197
|
+
ticks: number[];
|
|
198
|
+
at: (v: number) => number;
|
|
199
|
+
log: boolean;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* A logarithmic y axis over the positive values: the ends are the nearest 1, 2, 5 steps outside the
|
|
203
|
+
* data, the ticks are those steps, thinned to whole decades and then every k-th decade when there are
|
|
204
|
+
* more than seven. Values at or below zero are ignored (the chart reports them). A pinned end is used as
|
|
205
|
+
* given when it is positive and does not cut a reading off.
|
|
206
|
+
*/
|
|
207
|
+
declare function logScale(values: number[], pin?: {
|
|
208
|
+
min?: number;
|
|
209
|
+
max?: number;
|
|
210
|
+
}): YScale;
|
|
211
|
+
/** The value of a series at x, read between the two readings either side (flat beyond the ends). Series need not be sorted. */
|
|
212
|
+
declare function valueAt(series: readonly Point[], x: number): number;
|
|
213
|
+
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
214
|
+
declare function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel, formatY, xTicks, xDomain, xAxis, yScale: yMode, yInvert, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour, colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, range, height, className }: LineChartProps): React.JSX.Element;
|
|
215
|
+
/** One chart of a `LineChartGroup`: the props that differ per chart. The group owns the x axis, the cursor, `current` and `onPick`. */
|
|
216
|
+
type GroupedChart = Omit<LineChartProps, "formatX" | "xLabel" | "xTicks" | "xDomain" | "xAxis" | "current" | "onPick" | "cursor" | "readout" | "label"> & {
|
|
217
|
+
/** Names this chart in the group's reading and its own accessible name. Default `seriesLabel`. */
|
|
218
|
+
label?: string;
|
|
219
|
+
};
|
|
220
|
+
type LineChartGroupProps = {
|
|
221
|
+
/** What the stack shows, as a sentence. */
|
|
222
|
+
label: string;
|
|
223
|
+
charts: readonly GroupedChart[];
|
|
224
|
+
formatX: (x: number) => string;
|
|
225
|
+
xLabel?: string;
|
|
226
|
+
xTicks: LineChartProps["xTicks"];
|
|
227
|
+
/** Drawn on every chart (a chart's own `spans` and `marks` replace them). */
|
|
228
|
+
spans?: readonly ChartSpan[];
|
|
229
|
+
marks?: readonly ChartMark[];
|
|
230
|
+
onMarkSelect?: (mark: ChartMark) => void;
|
|
231
|
+
renderMarkCard?: (mark: ChartMark) => React.ReactNode;
|
|
232
|
+
/** The current x, drawn on every chart. */
|
|
233
|
+
current?: number;
|
|
234
|
+
onPick?: (x: number) => void;
|
|
235
|
+
className?: string;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Charts stacked on one x axis: one shared range, labels on the last chart only, and one cursor, so
|
|
239
|
+
* hovering or arrowing in any chart puts a rule and that chart's own reading in all of them (read
|
|
240
|
+
* together, and announced as one sentence, politely, at most once a second). Inside a `CursorScope`
|
|
241
|
+
* already, it joins that scope (a map beside the charts moves with them); otherwise it makes its own.
|
|
242
|
+
*/
|
|
243
|
+
declare function LineChartGroup({ label, charts, formatX, xLabel, xTicks, spans, marks, onMarkSelect, renderMarkCard, current, onPick, className }: LineChartGroupProps): React.JSX.Element;
|
|
244
|
+
/** One shortcut: the keys that run it (as `KeyboardEvent.key`), what it does in the product's words, and the action. */
|
|
245
|
+
type Shortcut = {
|
|
246
|
+
/** `KeyboardEvent.key` values, e.g. `["j", "ArrowDown"]`. The first is the one the legend leads with. */
|
|
247
|
+
keys: string[];
|
|
248
|
+
/** What it does, in the product's words: "Accept booking", not "Action 1". */
|
|
249
|
+
label: string;
|
|
250
|
+
/** What names it when keys are rebound (`ShortcutEditor`): stable across releases, so a person's saved keys still mean the same action. Default: the label. */
|
|
251
|
+
id?: string;
|
|
252
|
+
run: () => void;
|
|
253
|
+
/** Fire again while the key is held. On for moving through a list, off (the default) for answers. */
|
|
254
|
+
repeat?: boolean;
|
|
255
|
+
/** With `useHotkeys`' `within`: keep this key page-wide (Space to play, say) while the others only count with focus inside the region. */
|
|
256
|
+
anywhere?: boolean;
|
|
257
|
+
/** Ignore the key for now, and show it muted in the legend (nothing is active, say). */
|
|
258
|
+
disabled?: boolean;
|
|
259
|
+
};
|
|
260
|
+
/** True when a key pressed on this element is the person typing, so single-key shortcuts must leave it alone. */
|
|
261
|
+
declare function isTypingTarget(target: EventTarget | null): boolean;
|
|
262
|
+
type HotkeysOptions = {
|
|
263
|
+
enabled?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Only count keys while focus is inside this region (strata-react issue #385): a player's own region, so a stage beside it keeps
|
|
266
|
+
* its arrow keys. A shortcut with `anywhere` stays page-wide. A key whose target is outside the region goes to whoever else wants it.
|
|
267
|
+
*/
|
|
268
|
+
within?: React.RefObject<Element | null>;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Binds single-key shortcuts on the window (also for a key pressed on a control inside a grid row, whose React Aria hooks stop propagation), ignoring keys typed into fields, chords with Ctrl, Meta
|
|
272
|
+
* or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`: better, pass it `live`, which is what answers a key
|
|
273
|
+
* right now (nothing while `enabled` is off; with `within`, only the `anywhere` keys until focus is inside the region).
|
|
274
|
+
*/
|
|
275
|
+
declare function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled, within }?: HotkeysOptions): {
|
|
276
|
+
live: Shortcut[];
|
|
277
|
+
};
|
|
278
|
+
/** How a `KeyboardEvent.key` is drawn in a legend and an editor: arrows as arrows, the rest by name. */
|
|
279
|
+
declare const keyName: (key: string) => string;
|
|
280
|
+
/** A quiet legend of the screen's shortcuts, from the same list `useHotkeys` binds. Hidden on touch screens. */
|
|
281
|
+
declare function KeysLegend({ shortcuts, label, className }: {
|
|
282
|
+
shortcuts: Pick<Shortcut, "keys" | "label" | "disabled">[];
|
|
283
|
+
/** Names the legend for screen readers. */
|
|
284
|
+
label?: string;
|
|
285
|
+
className?: string;
|
|
286
|
+
}): React.JSX.Element;
|
|
287
|
+
type Precision = "seconds" | "ms" | "frames";
|
|
288
|
+
type TimeProps = {
|
|
289
|
+
precision?: Precision;
|
|
290
|
+
fps?: number;
|
|
291
|
+
};
|
|
292
|
+
/** The current and total time, in `tabular-nums`, as `<time>` elements. */
|
|
293
|
+
declare function TimeReadout({ time, duration, precision, fps, className }: {
|
|
294
|
+
time: number;
|
|
295
|
+
duration: number | null;
|
|
296
|
+
} & TimeProps & {
|
|
297
|
+
className?: string;
|
|
298
|
+
}): React.JSX.Element;
|
|
299
|
+
/** A stretch of the bar, drawn as a range: an intro, a recap, an advert break. */
|
|
300
|
+
type SeekBarSpan = {
|
|
301
|
+
/** Seconds. */
|
|
302
|
+
start: number;
|
|
303
|
+
end: number;
|
|
304
|
+
/** Its name for a screen reader and the tooltip: "Intro". The bar adds its times: "Intro, 0:00 to 0:12". */
|
|
305
|
+
label: string;
|
|
306
|
+
/** Default "info". */
|
|
307
|
+
tone?: SpanTone;
|
|
308
|
+
/** What kind of stretch it is ("sponsor"). Drawn as `data-kind` on the range, so an app can colour kinds from its own theme (`[data-kind="sponsor"]`). */
|
|
309
|
+
kind?: string;
|
|
310
|
+
/** A colour of the app's theme, named by its custom property (`"--seg-sponsor"`), for a kind whose colour the app's people know, instead of one of the five tones. Only a name starting with `--` is used; the library never picks a colour. */
|
|
311
|
+
colour?: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* The marked stretches as a thin strip, for under a picture played with the browser's own controls, whose seek bar cannot draw them
|
|
315
|
+
* (strata-react issue #270): the same ranges, names and colours as `SeekBar spans`, not a control. Draws nothing until `duration` is known.
|
|
316
|
+
*/
|
|
317
|
+
declare function SpanStrip({ spans, duration, label, precision, fps, className }: {
|
|
318
|
+
spans: readonly SeekBarSpan[];
|
|
319
|
+
duration: number | null;
|
|
320
|
+
label?: string;
|
|
321
|
+
className?: string;
|
|
322
|
+
} & TimeProps): React.JSX.Element | null;
|
|
323
|
+
type SeekBarProps = TimeProps & {
|
|
324
|
+
time: number;
|
|
325
|
+
/** Seconds; null, NaN or 0 while it is not known (a stream before its metadata): the bar is drawn disabled, with no thumb. */
|
|
326
|
+
duration: number | null;
|
|
327
|
+
/** The viewer asked for this time (drag, click or key). */
|
|
328
|
+
onSeek: (time: number) => void;
|
|
329
|
+
/** Named points on the bar (chapters, scenes, markers), each with its name and time in a tooltip on hover. Pressing one seeks to it. A `kind: "scene"` mark is drawn shorter and fainter than a chapter, so the parts read inside the whole. */
|
|
330
|
+
marks?: readonly MediaMark[];
|
|
331
|
+
/** Stretches drawn along the bar as ranges (strata-react issue #207): each named for a screen reader and in a tooltip, in a status role's colour, and never thinner than a few pixels so a one-second span still shows. They only draw; `MediaPlayer`'s `spans` is what acts on them. */
|
|
332
|
+
spans?: readonly SeekBarSpan[];
|
|
333
|
+
/** What pressing a mark does. Default seeks to it; a screen that wants to land on it and pause (a moment to look at) passes its own. */
|
|
334
|
+
onMarkPress?: (mark: MediaMark) => void;
|
|
335
|
+
/** How far has loaded or been recorded, drawn behind the played part. */
|
|
336
|
+
buffered?: number;
|
|
337
|
+
/** Arrow key step in seconds. Default 5. */
|
|
338
|
+
step?: number;
|
|
339
|
+
/** Page Up and Page Down step in seconds. Default 30. */
|
|
340
|
+
bigStep?: number;
|
|
341
|
+
label?: string;
|
|
342
|
+
disabled?: boolean;
|
|
343
|
+
/** Join the nearest `CursorScope` (strata-react issue #184): a pointer over the bar puts its time in every member, another member's position shows as a faint tick, and the bar's own time is the scope's playback position (`playback: false` to leave that to the app). A mapping when the scope's unit is not seconds (a route's metres). */
|
|
344
|
+
cursor?: boolean | (CursorMapping & {
|
|
345
|
+
playback?: boolean;
|
|
346
|
+
});
|
|
347
|
+
className?: string;
|
|
348
|
+
};
|
|
349
|
+
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
350
|
+
declare function SeekBar({ time, duration: known, onSeek, marks, spans, onMarkPress, buffered, step, bigStep, label, precision, fps, disabled: off, cursor: cursorProp, className }: SeekBarProps): React.JSX.Element;
|
|
351
|
+
type TransportProps = {
|
|
352
|
+
playing: boolean;
|
|
353
|
+
onPlayPause: () => void;
|
|
354
|
+
onStop?: () => void;
|
|
355
|
+
onToStart?: () => void;
|
|
356
|
+
onToEnd?: () => void;
|
|
357
|
+
onStepBack?: () => void;
|
|
358
|
+
onStepForward?: () => void;
|
|
359
|
+
/** What a step is called in the buttons' names: "frame" (default) or "second". */
|
|
360
|
+
stepUnit?: string;
|
|
361
|
+
/** Anything else on the row: the time readout, a seek bar, volume. */
|
|
362
|
+
children?: React.ReactNode;
|
|
363
|
+
className?: string;
|
|
364
|
+
};
|
|
365
|
+
/** The transport buttons for a player the app owns. Every control is a named icon button; the play button's name is "Play" or "Pause" from `playing`. Only the buttons whose handler is passed are drawn. */
|
|
366
|
+
declare function Transport({ playing, onPlayPause, onStop, onToStart, onToEnd, onStepBack, onStepForward, stepUnit, children, className }: TransportProps): React.JSX.Element;
|
|
367
|
+
type VolumeControlProps = {
|
|
368
|
+
/** 0 to 100. */
|
|
369
|
+
volume: number;
|
|
370
|
+
onVolumeChange: (volume: number) => void;
|
|
371
|
+
/** Allow over 100 (a boost), up to this. Default 100. */
|
|
372
|
+
max?: number;
|
|
373
|
+
disabled?: boolean;
|
|
374
|
+
className?: string;
|
|
375
|
+
};
|
|
376
|
+
/** A mute button and a volume slider with its value in percent. Muting sets the volume to 0 and remembers the level; unmuting puts it back. Moving the slider from 0 unmutes. */
|
|
377
|
+
declare function VolumeControl({ volume, onVolumeChange, max, disabled, className }: VolumeControlProps): React.JSX.Element;
|
|
378
|
+
/** A choice of playback speed ("0.5×", "1×", "1.5×"), named "Playback speed": React Aria's Select. */
|
|
379
|
+
declare function RateChoice({ rate, onRateChange, rates, className }: {
|
|
380
|
+
rate: number;
|
|
381
|
+
onRateChange: (rate: number) => void;
|
|
382
|
+
rates?: readonly number[];
|
|
383
|
+
className?: string;
|
|
384
|
+
}): React.JSX.Element;
|
|
385
|
+
/**
|
|
386
|
+
* The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
|
|
387
|
+
* or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
|
|
388
|
+
* to the ends, M mutes. Pass the player's actions; the labels are the legend's words. `stageKeys` is for a transport beside a stage that uses the arrows (see `TimelinePlayer`).
|
|
389
|
+
*/
|
|
390
|
+
declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute, stageKeys }: {
|
|
391
|
+
toggle: () => void;
|
|
392
|
+
seek: (time: number) => void;
|
|
393
|
+
time: number;
|
|
394
|
+
duration: number;
|
|
395
|
+
frame?: number;
|
|
396
|
+
jump?: number;
|
|
397
|
+
toggleMute?: () => void;
|
|
398
|
+
stageKeys?: boolean;
|
|
399
|
+
}): Shortcut[];
|
|
400
|
+
/** A frame that fits content of an aspect ratio into the pane, letterboxed on the sunken surface role (light and dark both), with room for the app's overlays. */
|
|
401
|
+
declare function MediaStage({ aspect, children, label, className }: {
|
|
402
|
+
aspect: number | `${number}/${number}`;
|
|
403
|
+
children: React.ReactNode;
|
|
404
|
+
label: string;
|
|
405
|
+
className?: string;
|
|
406
|
+
}): React.JSX.Element;
|
|
407
|
+
/** Guides over a stage: action-safe and title-safe frames (90% and 80%), a centre cross and a rule-of-thirds grid. Drawn as two strokes (light over dark) so they read on any picture. */
|
|
408
|
+
declare function StageGuides({ safe, thirds, centre, className }: {
|
|
409
|
+
safe?: boolean;
|
|
410
|
+
thirds?: boolean;
|
|
411
|
+
centre?: boolean;
|
|
412
|
+
className?: string;
|
|
413
|
+
}): React.JSX.Element;
|
|
414
|
+
/** What happens when playback reaches a kind of stretch. `"off"` only draws it. */
|
|
415
|
+
type SpanBehaviour = "auto" | "ask" | "off";
|
|
416
|
+
/** How one kind of stretch is drawn and treated. */
|
|
417
|
+
type SpanKind = {
|
|
418
|
+
/** "Intro": its name on the bar and in the buttons ("Skip intro"). */
|
|
419
|
+
label: string;
|
|
420
|
+
/** Default "off". */
|
|
421
|
+
behaviour?: SpanBehaviour;
|
|
422
|
+
/** Default "info". */
|
|
423
|
+
tone?: SpanTone;
|
|
424
|
+
/** A colour of the app's theme for this kind, by its custom property (`"--seg-sponsor"`): for kinds whose colours the app's people already know, and more than five of them. Wins over `tone`. The name stays the carrier of meaning; the library never picks a colour. */
|
|
425
|
+
colour?: string;
|
|
426
|
+
};
|
|
427
|
+
/** A stretch of the recording, in seconds on the player's timeline, of one of the `spanKinds`. */
|
|
428
|
+
type MediaSpanData = {
|
|
429
|
+
start: number;
|
|
430
|
+
end: number;
|
|
431
|
+
kind: string;
|
|
432
|
+
/** What acting on it does: skip to its end (default), or mute until it ends. */
|
|
433
|
+
action?: "skip" | "mute";
|
|
434
|
+
};
|
|
435
|
+
/** What the player did with a stretch, for an app that records it: `skipped`, `muted`, `undone` (the person took it back), `played` (it was offered and let play, or played after Undo). */
|
|
436
|
+
type SpanOutcome = "skipped" | "muted" | "undone" | "played";
|
|
437
|
+
/** The words of the Skip button and the notice, in the product's voice. Each takes the kind's label. */
|
|
438
|
+
type SpanWords = {
|
|
439
|
+
/** Default `Skip intro` (the label in lower case). */
|
|
440
|
+
skip?: (label: string) => string;
|
|
441
|
+
/** Default `Skipped intro`. */
|
|
442
|
+
skipped?: (label: string) => string;
|
|
443
|
+
/** Default `Mute sponsor`. */
|
|
444
|
+
mute?: (label: string) => string;
|
|
445
|
+
/** Default `Muted sponsor`. */
|
|
446
|
+
muted?: (label: string) => string;
|
|
447
|
+
/** Default "Undo". */
|
|
448
|
+
undo?: string;
|
|
449
|
+
};
|
|
450
|
+
type Options = {
|
|
451
|
+
spans?: readonly MediaSpanData[];
|
|
452
|
+
kinds?: Readonly<Record<string, SpanKind>>;
|
|
453
|
+
words?: SpanWords;
|
|
454
|
+
onSpan?: (span: MediaSpanData, what: SpanOutcome) => void;
|
|
455
|
+
/** Seconds, on the same timeline as the spans. */
|
|
456
|
+
time: number;
|
|
457
|
+
playing: boolean;
|
|
458
|
+
/** The length, once known: spans are cut to it. */
|
|
459
|
+
duration: number | null;
|
|
460
|
+
/** Seconds that exist so far, for a source still being made; a span ending beyond it is not skipped yet. */
|
|
461
|
+
limit?: number;
|
|
462
|
+
seek: (time: number) => void;
|
|
463
|
+
/** 0 to 100; 0 is muted. */
|
|
464
|
+
volume: number;
|
|
465
|
+
setVolume: (volume: number) => void;
|
|
466
|
+
};
|
|
467
|
+
/** What `useMediaSpans` gives the player. */
|
|
468
|
+
type MediaSpansState = {
|
|
469
|
+
/** For `SeekBar spans`. */
|
|
470
|
+
bars: SeekBarSpan[];
|
|
471
|
+
/** The stretch being played that the person can skip (or mute), with its button's words; null when none is offered. */
|
|
472
|
+
offer: {
|
|
473
|
+
label: string;
|
|
474
|
+
run: () => void;
|
|
475
|
+
} | null;
|
|
476
|
+
/** What was just done, with the way back; gone after a few seconds. */
|
|
477
|
+
notice: {
|
|
478
|
+
text: string;
|
|
479
|
+
undoLabel: string;
|
|
480
|
+
undo: () => void;
|
|
481
|
+
} | null;
|
|
482
|
+
};
|
|
483
|
+
/** Draws the spans' ranges and acts on them as playback reaches them. See the file comment for the rules. */
|
|
484
|
+
declare function useMediaSpans({ spans, kinds, words, onSpan, time, playing, duration, limit, seek, volume, setVolume }: Options): MediaSpansState;
|
|
485
|
+
/** A short notice drawn over a picture (or under an audio player) with one way back: "Skipped intro, Undo", "Picked up at 2:05, Start over". The player's own notices use it, so an overlay of an app's own matches them without copying classes. */
|
|
486
|
+
declare function PlayerNotice({ children, action, onAction }: {
|
|
487
|
+
children: React.ReactNode;
|
|
488
|
+
action: string;
|
|
489
|
+
onAction: () => void;
|
|
490
|
+
}): React.JSX.Element;
|
|
491
|
+
/** What `SpanActions` can also show in its notice place: a notice that is not about a span (the player's "Picked up at 2:05, Start over"). A span's own notice wins while it shows. */
|
|
492
|
+
type SpanActionsNotice = {
|
|
493
|
+
text: string;
|
|
494
|
+
actionLabel: string;
|
|
495
|
+
run: () => void;
|
|
496
|
+
};
|
|
497
|
+
/** The Skip button and the "Skipped intro, Undo" notice, for the player to draw over a picture or under the bar. The notice's live region is always present, so a screen reader hears what is put in it. */
|
|
498
|
+
declare function SpanActions({ state, other, className }: {
|
|
499
|
+
state: MediaSpansState;
|
|
500
|
+
other?: SpanActionsNotice | null;
|
|
501
|
+
className?: string;
|
|
502
|
+
}): React.JSX.Element;
|
|
503
|
+
/** What `onProgress` is called with. */
|
|
504
|
+
type MediaProgress = {
|
|
505
|
+
/** Where the playhead is, seconds into the file. */
|
|
506
|
+
position: number;
|
|
507
|
+
/** Seconds played through, each counted once; a span the player skipped counts as watched. */
|
|
508
|
+
watched: number;
|
|
509
|
+
/** The file's length in seconds, or null while it is not known. */
|
|
510
|
+
duration: number | null;
|
|
511
|
+
};
|
|
512
|
+
/** The words of the "Picked up at" notice. */
|
|
513
|
+
type ResumeWords = {
|
|
514
|
+
/** Default `Picked up at 2:05`. Takes the time already formatted. */
|
|
515
|
+
pickedUp?: (time: string) => string;
|
|
516
|
+
/** Default "Start over". */
|
|
517
|
+
startOver?: string;
|
|
518
|
+
};
|
|
519
|
+
/** Why a player is not playing, for the app to word. */
|
|
520
|
+
type MediaProblem = {
|
|
521
|
+
kind: "load";
|
|
522
|
+
message: string;
|
|
523
|
+
} | {
|
|
524
|
+
kind: "blocked";
|
|
525
|
+
message: string;
|
|
526
|
+
};
|
|
527
|
+
/** What `useMediaElement` returns: the element's state as values, and the requests a player makes of it. */
|
|
528
|
+
type MediaElementState = {
|
|
529
|
+
/** Seconds that can be sought to: for a source still being made, the end of what exists; otherwise the duration (or 0 while it is not known). */
|
|
530
|
+
ready: number;
|
|
531
|
+
/** A source that is still being made has been played up to the end of what exists, and is waiting for more. */
|
|
532
|
+
waitingForMore: boolean;
|
|
533
|
+
/** Shows a stream's own failure (one the element cannot report, such as a stream engine's fatal error) as the load error, with Try again. */
|
|
534
|
+
reportProblem: (message: string | null) => void;
|
|
535
|
+
/** The stretch of the file being played, if any: the `window` option, or the last `playWindow`. */
|
|
536
|
+
window: MediaWindow | null;
|
|
537
|
+
/** Plays a stretch: seeks to its start, plays, and stops (or loops) at its end. */
|
|
538
|
+
playWindow: (window: MediaWindow) => Promise<void>;
|
|
539
|
+
playing: boolean;
|
|
540
|
+
/** Seconds. */
|
|
541
|
+
time: number;
|
|
542
|
+
/** Seconds, or null until the element knows it (a stream reports NaN or Infinity). */
|
|
543
|
+
duration: number | null;
|
|
544
|
+
/** Seconds buffered from the start of the range holding `time`. */
|
|
545
|
+
buffered: number;
|
|
546
|
+
/** 0 to 100; 0 while muted. */
|
|
547
|
+
volume: number;
|
|
548
|
+
muted: boolean;
|
|
549
|
+
rate: number;
|
|
550
|
+
ended: boolean;
|
|
551
|
+
/** Waiting for data (the first load, or a seek into what is not buffered yet). */
|
|
552
|
+
loading: boolean;
|
|
553
|
+
error: MediaProblem | null;
|
|
554
|
+
play: () => Promise<void>;
|
|
555
|
+
pause: () => void;
|
|
556
|
+
toggle: () => void;
|
|
557
|
+
/** Seeks; before the metadata has loaded, remembers the time and applies it when it has. */
|
|
558
|
+
seek: (time: number) => void;
|
|
559
|
+
/** 0 to 100. 0 mutes; more unmutes at that level. */
|
|
560
|
+
setVolume: (volume: number) => void;
|
|
561
|
+
setRate: (rate: number) => void;
|
|
562
|
+
/** Loads again, and plays if it was playing. For the error state's "Try again". */
|
|
563
|
+
retry: () => void;
|
|
564
|
+
/** Counts a stretch (seconds in the file) as watched without it being played, for one the app skipped on purpose. See `onProgress`. */
|
|
565
|
+
markWatched: (start: number, end: number) => void;
|
|
566
|
+
};
|
|
567
|
+
/** A stretch of a file, in seconds. */
|
|
568
|
+
type MediaWindow = {
|
|
569
|
+
start: number;
|
|
570
|
+
end: number;
|
|
571
|
+
};
|
|
572
|
+
/** What `useMediaElement` can be asked to do besides follow the element. */
|
|
573
|
+
type MediaElementOptions = {
|
|
574
|
+
/** Bound playback to a stretch: it starts at `start` (a play from outside it seeks there) and stops at `end`. */
|
|
575
|
+
window?: MediaWindow | null;
|
|
576
|
+
/** At the end of the window, go back to its start and carry on, instead of stopping. */
|
|
577
|
+
loop?: boolean;
|
|
578
|
+
/** Join a group: when this element plays, the others in the group pause. Defaults to the nearest `MediaGroup`. */
|
|
579
|
+
group?: string;
|
|
580
|
+
/** Called every animation frame while playing, with the element's time, for highlighting what is being heard. */
|
|
581
|
+
onTimeUpdate?: (time: number) => void;
|
|
582
|
+
/** The window's end was reached (once per play; not called when it loops). */
|
|
583
|
+
onWindowEnd?: () => void;
|
|
584
|
+
/** The source is still being made (a growing stream): its duration is the end of what exists and keeps growing, it never counts as ended, and playback that reached the end carries on when more arrives. */
|
|
585
|
+
growing?: boolean;
|
|
586
|
+
/** Loads again from `time`, for a source the element cannot reload itself (a stream engine). Replaces the element's `load()` in `retry`. */
|
|
587
|
+
onRetry?: (time: number) => void;
|
|
588
|
+
/**
|
|
589
|
+
* How much has been seen (strata-react issue #272): called every `progressEvery` seconds of playing, and on pause, on the end, when the page is hidden, when it is left and when the player unmounts or changes file.
|
|
590
|
+
* `watched` counts each second once, when the playhead passes it by playing; a seek or skip counts nothing and going back over a part adds nothing. A report is not repeated while nothing has changed.
|
|
591
|
+
*/
|
|
592
|
+
onProgress?: (report: MediaProgress) => void;
|
|
593
|
+
/** Seconds of playing between reports. Default 15. */
|
|
594
|
+
progressEvery?: number;
|
|
595
|
+
/** Names what is being played, so the count starts again when it changes. Default the element's `src` attribute; give it for a stream attached by an engine. */
|
|
596
|
+
progressKey?: string;
|
|
597
|
+
};
|
|
598
|
+
/** Follows an `<audio>` or `<video>` and returns its state and the requests a player makes. Works with the browser's own controls too. */
|
|
599
|
+
declare function useMediaElement(ref: React.RefObject<HTMLMediaElement | null>, options?: MediaElementOptions): MediaElementState;
|
|
600
|
+
/** What a stream engine is given when it takes over an element. */
|
|
601
|
+
type StreamContext = {
|
|
602
|
+
/** Where to start, seconds (a reload starts where playback was). */
|
|
603
|
+
startAt: number;
|
|
604
|
+
/** Tell the player the stream failed, in words for the person: it shows the load error with Try again. */
|
|
605
|
+
onProblem: (message: string) => void;
|
|
606
|
+
/** The source is still being made (`MediaPlayer growing`): its start exists and the edge moves, so a first load starts at the beginning, not at the newest part. */
|
|
607
|
+
growing?: boolean;
|
|
608
|
+
};
|
|
609
|
+
/** A stream engine's hold on an element, so the player can end it and restart it. */
|
|
610
|
+
type StreamAttachment = {
|
|
611
|
+
/** Lets go of the element: stops loading, frees what the engine made. */
|
|
612
|
+
detach: () => void;
|
|
613
|
+
/** Starts again from `at` seconds (the player's Try again). */
|
|
614
|
+
reload: (at: number) => void;
|
|
615
|
+
};
|
|
616
|
+
/**
|
|
617
|
+
* Plays a source the element cannot play by itself (HLS outside Safari, say) by taking over the
|
|
618
|
+
* element: sets what it needs on it, and returns a hold the player ends when the source changes or the
|
|
619
|
+
* player unmounts. `strata-react/hls` has one; any engine that fits is used the same way.
|
|
620
|
+
*/
|
|
621
|
+
type SourceAttacher = (el: HTMLMediaElement, src: string, context: StreamContext) => StreamAttachment;
|
|
622
|
+
/**
|
|
623
|
+
* Hands `src` to a stream engine (`attach`) for the element in `ref`, and ends the hold when `src` changes, `attach` does, or the component unmounts.
|
|
624
|
+
* Use it for a plain `<video>` the app owns, with `useMediaElement`; `MediaPlayer` does it for `attach`.
|
|
625
|
+
* Returns `reload`, for the player's Try again (`useMediaElement`'s `onRetry`), and gives the engine's failures to `onProblem` (`reportProblem`).
|
|
626
|
+
*/
|
|
627
|
+
declare function useAttachedSource(ref: React.RefObject<HTMLMediaElement | null>, src: string | undefined, attach: SourceAttacher | undefined, onProblem?: (message: string) => void, growing?: boolean, start?: number): {
|
|
628
|
+
reload: (at: number) => void;
|
|
629
|
+
};
|
|
630
|
+
/** One file in a sequence. */
|
|
631
|
+
type MediaSource = {
|
|
632
|
+
src: string;
|
|
633
|
+
/** Names the source on the seek bar's marks and in "Chapter 2 of 5". */
|
|
634
|
+
title: string;
|
|
635
|
+
/** Seconds. When every source gives it, the seek bar spans the whole sequence. */
|
|
636
|
+
duration?: number;
|
|
637
|
+
};
|
|
638
|
+
/** Lock-screen and headset metadata (`navigator.mediaSession`). */
|
|
639
|
+
type MediaSession = {
|
|
640
|
+
title: string;
|
|
641
|
+
artist?: string;
|
|
642
|
+
album?: string;
|
|
643
|
+
artwork?: string;
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* What is playing, drawn across the top of a video while it is paused or the pointer is on it: a
|
|
647
|
+
* title, who made it, and their picture. Plain data; the player draws it.
|
|
648
|
+
*/
|
|
649
|
+
type MediaHeading = {
|
|
650
|
+
/** What is playing ("Glazing a celadon bowl"). */
|
|
651
|
+
title: string;
|
|
652
|
+
/** An app route the title leads to. */
|
|
653
|
+
to?: string;
|
|
654
|
+
/** Under the title: who made it, or where it is from ("Kiln room"). */
|
|
655
|
+
subtitle?: string;
|
|
656
|
+
/** An app route the subtitle leads to, and the picture with it when there is a subtitle to name that link. */
|
|
657
|
+
subtitleTo?: string;
|
|
658
|
+
/** React Router's location state the heading's links carry (where the person came from, for the next page to read). */
|
|
659
|
+
state?: unknown;
|
|
660
|
+
/** A small round picture before the words (the maker's avatar). `null` draws the subtitle's first letter instead. */
|
|
661
|
+
avatar?: string | null;
|
|
662
|
+
};
|
|
663
|
+
type MediaPlayerProps = {
|
|
664
|
+
/** Names the player and its element. */
|
|
665
|
+
label: string;
|
|
666
|
+
kind?: "audio" | "video";
|
|
667
|
+
/** One file. */
|
|
668
|
+
src?: string;
|
|
669
|
+
/** Or a sequence; ending moves to the next and keeps playing. */
|
|
670
|
+
sources?: readonly MediaSource[];
|
|
671
|
+
/** The current source, when the app holds it (a chapter list beside the player). */
|
|
672
|
+
index?: number;
|
|
673
|
+
onIndexChange?: (index: number) => void;
|
|
674
|
+
/** Move to the next source when one ends. Default true. */
|
|
675
|
+
autoAdvance?: boolean;
|
|
676
|
+
/** `"auto"`: the browser's controls on a touch device, Strata's on a desktop. Default. */
|
|
677
|
+
controls?: "auto" | "native" | "strata";
|
|
678
|
+
autoPlay?: boolean;
|
|
679
|
+
poster?: string;
|
|
680
|
+
session?: MediaSession;
|
|
681
|
+
/** The playback speeds offered. Default 0.5 to 2; for speech use {@link SPEECH_RATES}. */
|
|
682
|
+
rates?: readonly number[];
|
|
683
|
+
/** Keys on the page (Space or K, J and L for 10 s, M). Default true; turn off when the screen binds its own. With several players on a page the keys go to the one last played, focused or pressed. */
|
|
684
|
+
shortcuts?: boolean;
|
|
685
|
+
/** Play only a stretch of the file (seconds): it starts at `start`, stops at `end` (or loops), the seek bar and time show the stretch, and "Playing 0:12 to 0:15" is announced. One file only, not with `sources`. */
|
|
686
|
+
window?: MediaWindow;
|
|
687
|
+
/** Go back to the start of `window` at its end and carry on. */
|
|
688
|
+
loop?: boolean;
|
|
689
|
+
/** Show the whole file's timeline with the window marked, instead of the window as the whole bar. */
|
|
690
|
+
showFull?: boolean;
|
|
691
|
+
/** Join a group: starting this player pauses the others in it. Defaults to the nearest `MediaGroup`. */
|
|
692
|
+
group?: string;
|
|
693
|
+
/** Called every animation frame while playing, with the time in the file (not in the window), for highlighting. */
|
|
694
|
+
onTimeUpdate?: (time: number) => void;
|
|
695
|
+
/** The window reached its end (not called when it loops). */
|
|
696
|
+
onWindowEnd?: () => void;
|
|
697
|
+
/** Plays the sources through a stream engine instead of the element's own `src` (`attachHls` from `strata-react/hls` for HLS). The element is the same one throughout, so playback carries on across sources as ever. */
|
|
698
|
+
attach?: SourceAttacher;
|
|
699
|
+
/** The source is still being made (a stream that grows while it plays): the seek bar shows the part that exists, a "Still being made" word and `status` (what the app says about progress) appear, and playback that catches up with the end waits, says so, and resumes when more arrives, without an `onEnded`. Give the source's `duration` when the whole length is known. */
|
|
700
|
+
growing?: {
|
|
701
|
+
status?: string;
|
|
702
|
+
};
|
|
703
|
+
/** The last source has ended. */
|
|
704
|
+
onEnded?: () => void;
|
|
705
|
+
/** Called as the element plays, with the time in the whole sequence. */
|
|
706
|
+
onTimeChange?: (time: number) => void;
|
|
707
|
+
/** Marked stretches (an intro, a recap, a sponsor read), in seconds on the player's timeline: drawn on the seek bar, and acted on as playback reaches them as `spanKinds` says (strata-react issue #207). */
|
|
708
|
+
spans?: readonly MediaSpanData[];
|
|
709
|
+
/** For each kind of span: its `label`, its `tone` (a status role) and what happens on reaching one: `"auto"` skips it (or mutes it, for a span whose `action` is `"mute"`) with "Skipped intro" and Undo, `"ask"` offers a Skip button over the picture (and the `s` key), `"off"` (default) only draws it. Keep the object stable (state or `useMemo`). */
|
|
710
|
+
spanKinds?: Readonly<Record<string, SpanKind>>;
|
|
711
|
+
/** Named points of one file drawn on the seek bar (its chapters: "Christmas dinner" at 40:12, and `kind: "scene"` for the scenes within them), each named in a tooltip; pressing one seeks there (strata-react issues #371, #387). They are also what the skip buttons step through. For a single `src` without a `window`: a sequence's own marks (each source's start) and a window's take their place. Keep the array stable. */
|
|
712
|
+
marks?: readonly MediaMark[];
|
|
713
|
+
/** The skip buttons either side of Play. A file with marks skips by them (scenes small, chapters large: "Next scene", "Previous chapter"); a level without marks skips by time, `small` (default 10 s) and `large` (default 60 s). A sequence's large skip is its previous and next source. `false` draws none. */
|
|
714
|
+
skip?: SkipSteps | false;
|
|
715
|
+
/** The video's frame rate: draws Back one frame and Forward one frame beside Play (and the `,` and `.` keys), which pause and step one frame. Not drawn without it, since a browser does not say a file's rate. */
|
|
716
|
+
fps?: number;
|
|
717
|
+
/** Keep a playing video in sight while the page scrolls: once the player has scrolled off the top of the screen, the picture floats in a small box in the corner with its own seek bar, Play, Back to the player and Close, and goes back in place when the player is scrolled to. The same element moves, so playback carries on. Video only. */
|
|
718
|
+
float?: boolean;
|
|
719
|
+
/** Told what was done with a span: `skipped`, `muted`, `undone` or `played`. */
|
|
720
|
+
onSpan?: (span: MediaSpanData, what: SpanOutcome) => void;
|
|
721
|
+
/** The Skip button's and the notice's words, in the product's language. */
|
|
722
|
+
spanWords?: SpanWords;
|
|
723
|
+
/** Where a first load begins, seconds (strata-react issue #271: "Continue watching"). For an `attach`ed stream it is the attacher's `startAt`; for a plain `src`, a seek once the metadata is in. A reload (Try again) keeps the time reached. While it is more than 0 the player says "Picked up at 2:05" over the picture, with Start over, until the person starts over, plays for a few seconds, or it is dismissed by seeking. */
|
|
724
|
+
start?: number;
|
|
725
|
+
/** The words of that notice, in the product's language. */
|
|
726
|
+
resumeWords?: ResumeWords;
|
|
727
|
+
/** How much has been seen: every `progressEvery` seconds of playing, and on pause, on the end, when the page is hidden or left and when the player unmounts, with the position and the seconds played through (a span the player skipped counts as watched). `index` is the source in a `sources` sequence, and the times are those of that file (strata-react issue #272). */
|
|
728
|
+
onProgress?: (report: MediaProgress & {
|
|
729
|
+
index: number;
|
|
730
|
+
}) => void;
|
|
731
|
+
/** Seconds of playing between progress reports. Default 15. */
|
|
732
|
+
progressEvery?: number;
|
|
733
|
+
/** The player's state and requests (`seek`, `setVolume`, `time`, `duration`…), for an app that acts on playback from beside it: a chapter list, comments at a time (strata-react issue #211). An object ref holds the latest state without rendering again; a function ref is called with it on every render. */
|
|
734
|
+
mediaRef?: React.Ref<MediaElementState>;
|
|
735
|
+
/** What is playing, across the top of a video: shown while it is paused, and for a few seconds after the pointer moves on it, a key is pressed or playing starts; hidden with the controls (strata-react issue #329). Video only. */
|
|
736
|
+
heading?: MediaHeading;
|
|
737
|
+
/** Drawn over the picture only (never the controls) in a box that fills it; the app's classes choose the corner (`absolute bottom-3 right-3`). Anything interactive in it is clickable and focusable. A video's box keeps its shape before the metadata loads, so the overlay has a stable place. */
|
|
738
|
+
overlay?: (media: MediaElementState) => React.ReactNode;
|
|
739
|
+
/** Content below the controls for playback-related messages and actions. Hides with the controls during idle fullscreen playback. */
|
|
740
|
+
status?: React.ReactNode;
|
|
741
|
+
/** A transient warning from `usePlayerWarnings`, shown independently of the controls. */
|
|
742
|
+
warning?: PlayerWarningEvent;
|
|
743
|
+
/** The picture's shape before its metadata loads (and after, when given): a width over a height, or "16/9". Default "16/9" until the video says its own. */
|
|
744
|
+
aspect?: number | `${number}/${number}`;
|
|
745
|
+
/** A video has a Full screen button (and the `f` key) beside the speed and volume. Default true; `false` for a picture that must stay in its place. Only where the browser has the Fullscreen API (the window-filling fallback would mount the video again and lose its place). Not drawn with the browser's own controls (`controls="native"`, or `"auto"` on a touch device), which have their own. */
|
|
746
|
+
fullscreen?: boolean;
|
|
747
|
+
className?: string;
|
|
748
|
+
};
|
|
749
|
+
/** Playback speeds an audiobook or lecture listener expects. */
|
|
750
|
+
declare const SPEECH_RATES: readonly number[];
|
|
751
|
+
/**
|
|
752
|
+
* Plays a file or a sequence: the element, its state, and Strata's controls (or the browser's own on
|
|
753
|
+
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
754
|
+
* parts and `useMediaElement` directly.
|
|
755
|
+
*/
|
|
756
|
+
declare function MediaPlayer({ label, kind, src, sources, index: controlledIndex, onIndexChange, autoAdvance, controls, autoPlay, poster, session, rates, shortcuts, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen, skip, fps, float, className }: MediaPlayerProps): React.JSX.Element;
|
|
757
|
+
export { LineChartGroupProps as $, RateChoice as A, VolumeControlProps as B, SpanBehaviour as C, useMediaSpans as D, SpanWords as E, StageGuides as F, isTypingTarget as G, HotkeysOptions as H, TimeReadout as I, ChartMark as J, keyName as K, Transport as L, SeekBarProps as M, SeekBarSpan as N, MediaStage as O, SpanStrip as P, LineChartGroup as Q, TransportProps as R, SpanActionsNotice as S, SpanOutcome as T, KeysLegend as U, transportShortcuts as V, Shortcut as W, GroupedChart as X, ChartSpan as Y, LineChart as Z, MediaProgress as _, skipAction as _t, MediaPlayerProps as a, valueAt as at, PlayerNotice as b, usePlayerWarnings as bt, MediaSource as c, CursorScope as ct, SPEECH_RATES as d, useSharedCursor as dt, LineChartProps as et, SourceAttacher as f, MediaMark as ft, useMediaElement as g, marksFor as gt, useAttachedSource as h, SkipSteps as ht, MediaPlayer as i, logScale as it, SeekBar as j, Precision as k, MediaWindow as l, CursorScopeProps as lt, StreamContext as m, SkipLevel as mt, MediaElementState as n, SpanTone as nt, MediaProblem as o, CursorMapping as ot, StreamAttachment as p, SkipAction as pt, useHotkeys as q, MediaHeading as r, YScale as rt, MediaSession as s, CursorOwner as st, MediaElementOptions as t, Point as tt, ResumeWords as u, SharedCursor as ut, MediaSpanData as v, PlayerWarning as vt, SpanKind as w, SpanActions as x, MediaSpansState as y, PlayerWarningEvent as yt, VolumeControl as z };
|
|
758
|
+
//# sourceMappingURL=media-player-BETa3P7K.d.ts.map
|