strata-react 1.3.22 → 1.3.24

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 CHANGED
@@ -218,7 +218,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
218
218
  | Expansion | `Disclosure`, `useExpanded`, `DataTable`'s `expansion` (`RowExpansion<T>`) | Show more of one row in place. The toggle is a button with `aria-expanded`; the body is mounted only while open, so a request inside it runs on first open (unlike `<details>`, which mounts every closed body); `useExpanded({ param })` shares the open keys across a list or table and keeps them in the URL; a table's detail row spans the data columns and is measured when virtualised |
219
219
  | Data loading | `StrataQueryProvider`, `createQueryClient`, `useLoad`, `usePoll`, `useInfiniteLoad`, `useJob`, `useWorkflowRun`, `isWorkflowRunning`, `toLoad`, `staleOf`, `fetchJson`, `createApi`, `appBase`, `withBase`, `HttpError`, `readErrorBody`, `fieldErrorsOf` | TanStack Query in, `Load<T>` out; a refetch that fails after a good read stays `ready` with `stale` set, never an error panel; `useLoad({ poll })` with `usePoll({ every })` reads again on an interval until the person pauses it (`PauseButton`), and once at once on resume; `useInfiniteLoad` works out the cursor itself (after the last item held), merges pages by key and can `dismiss` an item at once; `useJob` polls a job's status only while it runs and invalidates the queries it changes once, when it ends; `fetchJson(url, { json })` sends a JSON body (content type and `POST` set for you); `createTypedApi<paths>()` is the same typed by `strata-api-types`' `paths` (path, `{params}`, `query`, `json` and the answer are checked); `createApi({ base })` is `get`/`post`/`put`/`patch`/`delete` over it with the app's base put before root-relative paths (`appBase()` reads the page's `<base href>`, so the app works behind a reverse proxy; use `withBase` for an `<img src>` or a download link); `fetchJson` reads an error response's body onto the `HttpError` (`body`, `reason`, `fieldErrors`, read by `readErrorBody` or the API's own `readError`); the strata apps' shared server shapes (`strata_python.contracts`): `apiPage<T>()` gives `useInfiniteLoad` the `Page<T>` items and its own `next` cursor (nothing held or dismissed changes it), `isTaskRunning(task, FINISHED)` is `useJob`'s `isRunning` for a `Task`, and an error body's `payload` (what is already running, on a 409) is on `HttpError.payload`, read typed with `errorPayload<T>(error)`; `useWorkflowRun({ finished })` is `useJob` for a `WorkflowRun`, polling while the run's job (`WorkflowRun.job`) is in a state not in `finished` |
220
220
  | Page and navigation | `AppShell`, `SideNav`, `Breadcrumb`, `Tabs`, `PageHeader`, `LinkCard`, `LinkCardList` | React Router; tab and sort state in the URL; a `LinkCard` is one link named by its title, described by its text and `Status` marks, with the whole card as the target (`to` a route, `href` elsewhere, marked with an arrow only when it is on another origin or `external`) |
221
- | Keyboard | `useHotkeys`, `KeysLegend`, `Shortcut`, `useActiveItem`, `ActiveList`, `isTypingTarget`, `useRebindableShortcuts`, `ShortcutEditor`, `keyName` | For queues worked from the keyboard; one shortcut list drives the handler and the legend; keys never fire while typing; answering moves focus to the next item. To let a person rebind the keys, give the same `Shortcut[]` to `useRebindableShortcuts` (remembered under `storageKey`, or handed to `onChange`) and pass its `shortcuts` to `useHotkeys` and `KeysLegend` and its result to `ShortcutEditor`: each action with its keys and a Change that records the next key, a chord refused with the reason (Ctrl, Cmd and Alt belong to the browser), a conflict named with a swap, Reset and Reset all, all said in a polite status |
221
+ | Keyboard | `useHotkeys`, `KeysLegend`, `Shortcut`, `useActiveItem`, `ActiveList`, `isTypingTarget`, `useRebindableShortcuts`, `ShortcutEditor`, `keyName` | For queues worked from the keyboard; one shortcut list drives the handler and the legend; keys never fire while typing; answering moves focus to the next item. To let a person rebind the keys, give the same `Shortcut[]` to `useRebindableShortcuts` (remembered under `storageKey`, or handed to `onChange`) and pass its `shortcuts` to `useHotkeys` and `KeysLegend` and its result to `ShortcutEditor`: each action with its keys and a Change that records the next key, a chord refused with the reason (Ctrl, Cmd and Alt belong to the browser), a conflict named with a swap, Reset and Reset all, all said in a polite status `useHotkeys` takes `within` (keys count only with focus inside a region; a shortcut marked `anywhere` stays page-wide) and returns `live`, the keys that answer right now, for `KeysLegend`. |
222
222
  | Theme | `ThemeProvider` (`defaultPalette`), `PaletteChoice`, `usePalette`, `paletteScript`, `palettes`, `useColorScheme`, `useSystemColorScheme`, `ColorSchemeChoice`, `colorSchemeScript` | System, light or dark; sets `.dark`, persists in localStorage when it can; `ColorSchemeChoice` is a radio list for a settings page, or `compact` icon segments named "Appearance" for an app with no settings page |
223
223
  | Density | `Density`, `DensityName`, `ThemeProvider`'s `density`, `ControlSize` (`size="sm"` on `Input`, `NativeSelect`, `NumberField`, `IconButton`) | Control height is two variables, `--control-h` and `--control-h-sm`. `<ThemeProvider density="compact">` or `<Density page value="compact">` sets them app-wide, including dialogs and menus, which portal out of the app's root; `<Density value="compact">` is one region (a toolbar, a dense panel) and does not reach its overlays. A coarse pointer (touch) always gets 44px targets, whatever the density A second look for a region is roles alone: set `--control-h`, `--control-h-sm`, `--control-px`, `--control-px-sm`, `--control-icon` and each type step's `--type-<step>-size`, `-leading` and `-weight` (`caption`, `label`, `body-sm`, `body`, `heading`, `title`, `figure`) on a class; the defaults are today's values. |
224
224
  | Workspace | `Workspace`, `WorkspaceBar`, `Split`, `Pane`, `useWorkspaceState`, `WorkspaceState` | One screen of panes for a tool: splits of panes with a growing stage, a header on every pane (name, actions, fold button), separators that resize by pointer and by keyboard (arrows, Shift, Home, End, Enter to restore) within each pane's `min` and `max`, panes that fold to a rail or header bar with a visible way back (and `state.toggle(id)` from a menu), sizes and folds remembered with `useWorkspaceState("name")`, and stacking below 720px. `WorkspaceBar` is the one bar across the top (the tool's name as the `h1`, a polite status, the filled action, an end slot for the scheme and palette choice, wrapping on a phone), where `PageHeader` is an app screen's heading and `Toolbar` a row of controls inside a pane. A pane's body is inset by default so an `Inspector` lines up with the pane's name; `flush` draws a tree, table or stage edge to edge. `onFiles` and `acceptLabel` on `Workspace` take files dropped anywhere on the window (`FileDropOverlay`). Each pane is a labelled region |
@@ -233,8 +233,8 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
233
233
  | Overlays | `Dialog`, `DialogProps`, `AlertDialog`, `Popover`, `Tooltip` | React Aria underneath. A dialog always has a title and, via `actions`'s close render prop, a way out; `closable={false}` while work cannot stop; `placement="end"` is a sheet. `AlertDialog` is the only confirm: required verb on the confirm button, Cancel focused first, no outside dismiss, stays open with the reason when an async confirm fails. `Popover` needs a `label`. `Tooltip` opens on hover and focus and `IconButton` uses it. All portal onto the `layer-*` stacking utilities |
234
234
  | Value controls | `NumberField`, `Slider`, `ColorField`, `SecretField` | Set a number or colour precisely, inside `Field`. `NumberField` and `Slider` are React Aria's; the number field runs with `commitBehavior="validate"`, so a typed value outside `min`/`max` is kept on screen, explained in the `Field` ("Enter a value from 0% to 500%.") and never passed to `onChange`. A value that is not known is `null` and shows an en dash, never 0 or NaN. Digits and decimal mark follow `locale`. The unit sits inside the control, and in the slider's spoken value when `Intl` has it (%, °, ms, s, kB, MB, GB, kbps, Mbps). Arrows step, Home/End jump to the limits; `Slider editable` adds a number field. `ColorField`: platform picker, typed hex that is normalised, app suggestions, and a contrast note against `against`. No motion on value changes. `NumberField` options for a value set a little at a time or that costs work to change: `nudge={[0.1, 1, 10]}` (a toolbar of named step buttons that repeat when held and stop at the limits), `suggestion={{ value, label, reason }}` (a row with the reason in words and Use this value, never applied by itself) and `preview` (changes wait behind Apply and Revert; `onChange` is Apply's). `SecretField` is a credential the server keeps and never shows again: not set, set (no characters, no length, no input in the DOM), a masked entry with a Show toggle named for what it reveals, `onSave` through `AsyncButton`, Replace, a confirmed Remove that says what stops working, and a Test whose result is text beside it; a set, untouched field reports nothing |
235
235
  | Notices and progress | `Alert`, `toast`, `StrataToastRegion`, `useClientWork`, `JobStatus` | Three weights. A `toast` confirms finished work and goes by itself (5 s plus 40 ms a character, 8 s minimum with an action, paused under the pointer or focus, always dismissable); it has no danger tone, because an error a person must act on is an inline `Alert` with its recovery as `action` (`announce` makes it `role="alert"` only when it answers something the person just did). `StrataToastRegion` goes once at the app root. `useClientWork` runs browser work with progress, cancel (aborts its `signal`, ends `cancelled`, never `failed`) and a double-start guard; `JobStatus` shows it exactly as it shows a server job, with `onCancel`, `cancelled` and `onDismiss` |
236
- | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions`, `PlayerNotice`, `SpanStrip`, `MediaContents` | Play a file or a sequence of chapters without the event glue: `marks` puts one file's own chapters on the seek bar, and `MediaContents` lists them beside the player (the playing one marked, pressing one plays from its start, never scrolling the page); the element, its state, Strata's controls (or the browser's own on a touch device, `controls="auto"`), a load error with Try again, `navigator.mediaSession` metadata, the seek bar spanning the whole sequence. `useMediaElement(ref)` alone follows an element drawn with the browser's controls `spans` and `spanKinds` mark stretches (an intro, a recap, a sponsor read) on the seek bar as named ranges in a status role's tone and act on them as playback reaches them: `auto` skips (or mutes, for `action: "mute"`) with "Skipped intro" and Undo, `ask` offers a Skip button over the picture and on the `s` key, `off` only draws; each is acted on once, `onSpan` reports `skipped`, `muted`, `undone` or `played`, and `SeekBar` takes `spans` too. `mediaRef` hands out the player's state and requests (an object ref holds the latest, no render of its own), `overlay` draws the app's own thing over the picture only, `heading` (title, subtitle, avatar, each a link, with the app's router `state`) is drawn across the top of a video while paused or the pointer moves, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. A video has a Full screen button and the `f` key by default (`fullscreen={false}` removes them); on the picture a click plays or pauses, a double click toggles full screen and the wheel sets the volume while the player has focus. A kind's `colour` names a custom property of the app's theme (`"--seg-sponsor"`) instead of a tone, each range carries `data-kind`, and under the browser's own controls a `SpanStrip` under the picture draws the ranges. `start` begins a first load at a time (an attacher's `startAt`, or a seek once the metadata is in) and says "Picked up at 2:05" with Start over (`resumeWords`); `onProgress` reports the position and the seconds actually played through, each once, a skipped span counted (`useMediaElement` takes it too, with `markWatched`). The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
237
- | Media playback | `Transport`, `SeekBar`, `TimeReadout`, `VolumeControl`, `RateChoice`, `MediaStage`, `StageGuides`, `transportShortcuts`, `format.timecode` | The controls around anything that plays, wired to a player the app owns (HTML media, Web Audio, a canvas, a data replay). Every control is a named icon button in one toolbar; the play button's name is "Play" or "Pause". `SeekBar` has the formatted time as its accessible value, arrows step 5 s and Page keys 30 s by default, and optional marks. `VolumeControl` shows its percent, and muting remembers the level. `transportShortcuts` is the one list for `useHotkeys` and `KeysLegend` (Space and K, J and L, the arrows by a frame, Home and End). `format.timecode` prints m:ss, m:ss.mmm or m:ss:ff. `MediaStage` fits a picture of any aspect ratio into the pane with a letterbox on the sunken surface role, and takes overlays such as `StageGuides` |
236
+ | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions`, `PlayerNotice`, `SpanStrip`, `MediaContents` | Play a file or a sequence of chapters without the event glue: `marks` puts one file's own chapters (and `kind: "scene"` scenes, shorter) on the seek bar, each named in a tooltip and pressed to jump; the skip buttons beside Play step by scene (small) and chapter (large), or by 10 s and 1 min where a file has none (`skip`, `skipAction`); `fps` adds frame steps (`,` and `.`); `float` keeps a playing video in a corner box once the player has scrolled off the screen; and `MediaContents` lists them beside the player (the playing one marked, pressing one plays from its start, never scrolling the page); the element, its state, Strata's controls (or the browser's own on a touch device, `controls="auto"`), a load error with Try again, `navigator.mediaSession` metadata, the seek bar spanning the whole sequence. `useMediaElement(ref)` alone follows an element drawn with the browser's controls `spans` and `spanKinds` mark stretches (an intro, a recap, a sponsor read) on the seek bar as named ranges in a status role's tone and act on them as playback reaches them: `auto` skips (or mutes, for `action: "mute"`) with "Skipped intro" and Undo, `ask` offers a Skip button over the picture and on the `s` key, `off` only draws; each is acted on once, `onSpan` reports `skipped`, `muted`, `undone` or `played`, and `SeekBar` takes `spans` too. `mediaRef` hands out the player's state and requests (an object ref holds the latest, no render of its own), `overlay` draws the app's own thing over the picture only, `heading` (title, subtitle, avatar, each a link, with the app's router `state`) is drawn across the top of a video while paused or the pointer moves, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. A video has a Full screen button and the `f` key by default (`fullscreen={false}` removes them); on the picture a click plays or pauses, a double click toggles full screen and the wheel sets the volume while the player has focus. A kind's `colour` names a custom property of the app's theme (`"--seg-sponsor"`) instead of a tone, each range carries `data-kind`, and under the browser's own controls a `SpanStrip` under the picture draws the ranges. `start` begins a first load at a time (an attacher's `startAt`, or a seek once the metadata is in) and says "Picked up at 2:05" with Start over (`resumeWords`); `onProgress` reports the position and the seconds actually played through, each once, a skipped span counted (`useMediaElement` takes it too, with `markWatched`). The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
237
+ | Media playback | `useTimeline`, `TimelinePlayer`, `Transport`, `SeekBar`, `TimeReadout`, `VolumeControl`, `RateChoice`, `MediaStage`, `StageGuides`, `transportShortcuts`, `format.timecode` | The controls around anything that plays, wired to a player the app owns (HTML media, Web Audio, a canvas, a data replay). Every control is a named icon button in one toolbar; the play button's name is "Play" or "Pause". `SeekBar` has the formatted time as its accessible value, arrows step 5 s and Page keys 30 s by default, and optional marks. `VolumeControl` shows its percent, and muting remembers the level. `transportShortcuts` is the one list for `useHotkeys` and `KeysLegend` (Space and K, J and L, the arrows by a frame, Home and End). `format.timecode` prints m:ss, m:ss.mmm or m:ss:ff. `MediaStage` fits a picture of any aspect ratio into the pane with a letterbox on the sunken surface role, and takes overlays such as `StageGuides` `useTimeline` is the same state for a clock the app owns (a recorded run, a replay, an animation): rAF at `rate`, loops or stops, play at the end restarts, a seek pauses, `step` by `frame`, `startAt`, joins a `MediaGroup` and the key-owner rule, so `Transport`, `SeekBar` and `transportShortcuts` plug in; `TimelinePlayer` puts a stage (a `SceneViewport` given `time`) over the same control bar, with the stage keeping the arrow keys. |
238
238
  | Listening and reading | `Waveform`, `TranscriptView`, `PlayWindowButton`, `MediaGroup`, `FilmStrip`; `resamplePeaks`, `peaksFromAudio`, `peakGain`, `phraseAt`, `wordAt`, `pickEvenly`, `frameAt` | Timed media: a waveform from peaks or a decoded file (one slider, marks by line style, named spans, zoom, a keyboard-made range, a spectrogram underlay, `normalise` to draw quiet sound to fill the height and say by how much); `FilmStrip` is a row of frames from a stretch of video that fits its width (picked evenly), each with its time, pressing one seeks (`onSeek`, one tab stop with arrow keys), and the frame at `time` inside `span` is ringed; timed text that marks the heard word and plays from any word (modes, speakers, follow and Jump to now, virtualised), with doubtful words (dotted, named, counted, "Only doubtful"), a mark per phrase set from a row menu (`states`, `onPhraseState`), correction in place (Enter or F2, `onEdit`) and a hover and focus card (`renderCard`); `MediaPlayer window` plays one stretch of a file, `MediaGroup` lets one player play at a time, `PlayWindowButton` is a row's play control on a shared element; a review transcript needs no player (`time` and `onSeek` are optional), takes `marking` (words become `MarkableText` marks with ids `wordId(phraseId, index)`, selected across rows that are not mounted) and shows a corrected word (`word.correction`) dotted with the original on hover and `onCorrectionPress` to open it |
239
239
  | Streams | `MediaPlayer attach`/`growing`, `useAttachedSource`, `attachHls` (`strata-react/hls`) | A source the element cannot play is attached by an engine; a source still being made says so, shows what exists as ready, and waits at its end without ending |
240
240
  | 360 | `PanoramaViewer` (`strata-react/panorama`), `project`, `unproject`, `describeView` | A 360 picture or video as a controlled window (yaw, pitch, field of view), drag, wheel, pinch and keys, an overlay in the picture's coordinates, said in words, a flat fallback with no WebGL2 |
package/UPGRADING.md CHANGED
@@ -11,6 +11,16 @@ time. While the version is 0.x, any release may break.
11
11
 
12
12
  Every PR that changes what an app sees adds a line here (see `CLAUDE.md`, "Changelog").
13
13
 
14
+ ## 2026-11-26 (clock, key scope and theming hooks, #383–#386)
15
+ - `useHotkeys` now returns `{ live }` (it returned nothing) and takes `within` (a ref: keys count only while focus is inside it; a `Shortcut` with `anywhere` stays page-wide). Nothing changes for a call that passes neither.
16
+ - `SceneFrame` has a new member, `time` (0 unless `SceneViewport time` is given): a `SceneFrame` you build by hand in a test needs it. `MediaPlayer`'s several-players warning now reads "several players are on this page" (the store is shared with `useTimeline`).
17
+ - Structural parts carry `data-part` (`pane`, `pane-header`, `pane-title`, `workspace-bar`, `inspector`, `inspector-header`, `inspector-section`, `link-card`); `type-heading` reads `--type-heading-font`, `type-figure` reads `--figure-ink`, and the body and those panels read `--surface-image`. All inert unless a theme sets them.
18
+
19
+ ## 2026-11-26 (player skips and frame steps, #387)
20
+ - **`MediaPlayer` draws skip buttons either side of Play** (`Back 10 s`, `Forward 10 s`, `Back 1 min`, `Forward 1 min`, or `Previous scene`, `Next chapter`… when `marks` has them), and a sequence's `Previous chapter` now comes before Play. A test that listed the `Playback` toolbar's buttons, or found the only "Play" by position, needs the new names; `skip={false}` removes them. Visual baselines with a player move.
21
+ - `SeekBar` marks are buttons with a `Tooltip`, not a `title`: a test that read a mark's `title` reads its accessible name (unchanged, "Dinner, 10:00") or hovers for the tooltip.
22
+ - `MediaPlayer` no longer renders `Transport`; the toolbar is still named "Playback".
23
+
14
24
  ## 2026-11-25 (seek bar marks past the end)
15
25
  - **`SeekBar` (and `MediaPlayer` through it) no longer draws a mark outside 0 to the duration.** A test that found a mark button past the loaded file's end will not find it; pass marks within the file.
16
26
 
@@ -10,18 +10,29 @@ export type Shortcut = {
10
10
  run: () => void;
11
11
  /** Fire again while the key is held. On for moving through a list, off (the default) for answers. */
12
12
  repeat?: boolean;
13
+ /** With `useHotkeys`' `within`: keep this key page-wide (Space to play, say) while the others only count with focus inside the region. */
14
+ anywhere?: boolean;
13
15
  /** Ignore the key for now, and show it muted in the legend (nothing is active, say). */
14
16
  disabled?: boolean;
15
17
  };
16
18
  /** True when a key pressed on this element is the person typing, so single-key shortcuts must leave it alone. */
17
19
  export declare function isTypingTarget(target: EventTarget | null): boolean;
20
+ export type HotkeysOptions = {
21
+ enabled?: boolean;
22
+ /**
23
+ * Only count keys while focus is inside this region (strata-react issue #385): a player's own region, so a stage beside it keeps
24
+ * its arrow keys. A shortcut with `anywhere` stays page-wide. A key whose target is outside the region goes to whoever else wants it.
25
+ */
26
+ within?: React.RefObject<Element | null>;
27
+ };
18
28
  /**
19
29
  * 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
20
- * or Alt, IME composition and (unless `repeat`) held keys. Pass the same list to `KeysLegend`.
30
+ * 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
31
+ * right now (nothing while `enabled` is off; with `within`, only the `anywhere` keys until focus is inside the region).
21
32
  */
22
- export declare function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled }?: {
23
- enabled?: boolean;
24
- }): void;
33
+ export declare function useHotkeys(shortcuts: Shortcut[] | Record<string, () => void>, { enabled, within }?: HotkeysOptions): {
34
+ live: Shortcut[];
35
+ };
25
36
  /** How a `KeyboardEvent.key` is drawn in a legend and an editor: arrows as arrows, the rest by name. */
26
37
  export declare const keyName: (key: string) => string;
27
38
  /** A quiet legend of the screen's shortcuts, from the same list `useHotkeys` binds. Hidden on touch screens. */
@@ -0,0 +1,11 @@
1
+ export type KeyOwner = {
2
+ /** Whether this player's keys are live: it is the only one on the page, or the one last used. */
3
+ owns: boolean;
4
+ /** Take the keys (the player was focused or pressed). */
5
+ claim: () => void;
6
+ };
7
+ /**
8
+ * Joins the page's key owners while `enabled`, and takes the keys whenever `playing` turns true. Spread nothing: call
9
+ * `claim` from the region's focus and pointer-down handlers, and bind the player's `useHotkeys` with `enabled: owner.owns`.
10
+ */
11
+ export declare function useKeyOwner(enabled: boolean, playing?: boolean): KeyOwner;
@@ -1,7 +1,14 @@
1
1
  import { MediaElementState, MediaWindow } from './media-player';
2
2
  import * as React from "react";
3
- /** Adds an element to a named group until the returned function is called; whenever one plays, the others pause. */
4
- export declare function joinMediaGroup(name: string, el: HTMLMediaElement): () => void;
3
+ /** What a group needs of a member: whether it is paused, a way to pause it, and a way to hear it start. An `HTMLMediaElement` is one; so is a `useTimeline` clock (strata-react issue #384). */
4
+ export type GroupMember = {
5
+ readonly paused: boolean;
6
+ pause(): void;
7
+ addEventListener(type: "play", listener: () => void): void;
8
+ removeEventListener(type: "play", listener: () => void): void;
9
+ };
10
+ /** Adds an element, or a `useTimeline` clock, to a named group until the returned function is called; whenever one plays, the others pause. */
11
+ export declare function joinMediaGroup(name: string, el: GroupMember): () => void;
5
12
  /** The group a `MediaGroup` above this point names, or null. */
6
13
  export declare function useMediaGroupName(): string | null;
7
14
  /** Players and elements under it play one at a time: starting one pauses the others. */
@@ -1,4 +1,5 @@
1
1
  import { PlayerWarningEvent } from './player-warning';
2
+ import { MediaMark, SkipSteps } from './media-skip';
2
3
  import { MediaSpanData, SpanKind, SpanOutcome, SpanWords } from './media-spans';
3
4
  import { MediaProgress } from './media-progress';
4
5
  import * as React from "react";
@@ -202,11 +203,14 @@ export type MediaPlayerProps = {
202
203
  spans?: readonly MediaSpanData[];
203
204
  /** 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`). */
204
205
  spanKinds?: Readonly<Record<string, SpanKind>>;
205
- /** Named points of one file drawn on the seek bar (its chapters: "Christmas dinner" at 40:12); pressing one seeks there (strata-react issue #371). 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. */
206
- marks?: readonly {
207
- time: number;
208
- label: string;
209
- }[];
206
+ /** 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. */
207
+ marks?: readonly MediaMark[];
208
+ /** 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. */
209
+ skip?: SkipSteps | false;
210
+ /** 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. */
211
+ fps?: number;
212
+ /** 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. */
213
+ float?: boolean;
210
214
  /** Told what was done with a span: `skipped`, `muted`, `undone` or `played`. */
211
215
  onSpan?: (span: MediaSpanData, what: SpanOutcome) => void;
212
216
  /** The Skip button's and the notice's words, in the product's language. */
@@ -244,4 +248,4 @@ export declare const SPEECH_RATES: readonly number[];
244
248
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
245
249
  * parts and `useMediaElement` directly.
246
250
  */
247
- export 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, className, }: MediaPlayerProps): React.JSX.Element;
251
+ export 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;
@@ -0,0 +1,31 @@
1
+ /** A named point on a player's timeline: a chapter (the default) or a scene within one. */
2
+ export type MediaMark = {
3
+ time: number;
4
+ label: string;
5
+ kind?: "chapter" | "scene";
6
+ };
7
+ /** The two skip levels. */
8
+ export type SkipLevel = "small" | "large";
9
+ /** The time steps for a file without parts at that level, in seconds. */
10
+ export type SkipSteps = {
11
+ small?: number;
12
+ large?: number;
13
+ };
14
+ /** What a skip does: its button's name, and where it goes (null when there is nowhere, at either end). */
15
+ export type SkipAction = {
16
+ label: string;
17
+ to: number | null;
18
+ by: "mark" | "time";
19
+ };
20
+ /** The marks a level skips by: scenes for small, chapters (and marks with no kind) for large, in time order. */
21
+ export declare function marksFor(marks: readonly MediaMark[], level: SkipLevel): number[];
22
+ /**
23
+ * Where a skip at `level` in `direction` from `time` goes: by the level's marks when the file has any
24
+ * (the file's start counts as one), else by its time step. `restart` is how far into a part
25
+ * "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.
26
+ */
27
+ export declare function skipAction(marks: readonly MediaMark[], level: SkipLevel, direction: -1 | 1, time: number, { steps, duration, restart }?: {
28
+ steps?: SkipSteps;
29
+ duration?: number | null;
30
+ restart?: number;
31
+ }): SkipAction;
@@ -1,6 +1,7 @@
1
1
  import { SpanTone } from './line-chart';
2
2
  import { Shortcut } from './hotkeys';
3
3
  import { CursorMapping } from './cursor';
4
+ import { MediaMark } from './media-skip';
4
5
  import * as React from "react";
5
6
  export type Precision = "seconds" | "ms" | "frames";
6
7
  type TimeProps = {
@@ -44,18 +45,12 @@ export type SeekBarProps = TimeProps & {
44
45
  duration: number | null;
45
46
  /** The viewer asked for this time (drag, click or key). */
46
47
  onSeek: (time: number) => void;
47
- /** Named points on the bar (chapters, markers). Pressing one seeks to it. */
48
- marks?: readonly {
49
- time: number;
50
- label: string;
51
- }[];
48
+ /** 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. */
49
+ marks?: readonly MediaMark[];
52
50
  /** 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. */
53
51
  spans?: readonly SeekBarSpan[];
54
52
  /** 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. */
55
- onMarkPress?: (mark: {
56
- time: number;
57
- label: string;
58
- }) => void;
53
+ onMarkPress?: (mark: MediaMark) => void;
59
54
  /** How far has loaded or been recorded, drawn behind the played part. */
60
55
  buffered?: number;
61
56
  /** Arrow key step in seconds. Default 5. */
@@ -109,9 +104,9 @@ export declare function RateChoice({ rate, onRateChange, rates, className }: {
109
104
  /**
110
105
  * The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
111
106
  * or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
112
- * to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
107
+ * 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`).
113
108
  */
114
- export declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute }: {
109
+ export declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute, stageKeys }: {
115
110
  toggle: () => void;
116
111
  seek: (time: number) => void;
117
112
  time: number;
@@ -119,6 +114,7 @@ export declare function transportShortcuts({ toggle, seek, time, duration, frame
119
114
  frame?: number;
120
115
  jump?: number;
121
116
  toggleMute?: () => void;
117
+ stageKeys?: boolean;
122
118
  }): Shortcut[];
123
119
  /** 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. */
124
120
  export declare function MediaStage({ aspect, children, label, className }: {
@@ -0,0 +1,18 @@
1
+ import { TimelineClock } from './use-timeline';
2
+ import * as React from "react";
3
+ export type TimelinePlayerProps = {
4
+ /** From `useTimeline`. */
5
+ clock: TimelineClock;
6
+ /** Names the player and its controls: "Movement replay". */
7
+ label: string;
8
+ /** The picture, drawn from `clock.time` (give `SceneViewport` `time={clock.time}`). */
9
+ stage: React.ReactNode;
10
+ /** The speeds offered, with `onRateChange` to change `useTimeline`'s `rate`. Without `onRateChange` the choice is not drawn. */
11
+ rates?: readonly number[];
12
+ onRateChange?: (rate: number) => void;
13
+ /** Show the legend of keys that are live now. Default false (an app usually has its own place for it). */
14
+ legend?: boolean;
15
+ className?: string;
16
+ };
17
+ /** A stage over a control bar for a timeline the app owns: transport, seek bar, time and speed, with the keys following the clock last used and the stage keeping its arrows. */
18
+ export declare function TimelinePlayer({ clock, label, stage, rates, onRateChange, legend, className }: TimelinePlayerProps): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ export type TimelineClockOptions = {
2
+ /** Seconds. */
3
+ duration: number;
4
+ /** Playback speed; a multiple of real time. Default 1. The app owns it (`RateChoice` sets it). */
5
+ rate?: number;
6
+ /** What one step moves, in seconds. Default 1/30. */
7
+ frame?: number;
8
+ /** Start again at the end instead of stopping. */
9
+ loop?: boolean;
10
+ /** Where the playhead rests before anyone has used it: `"end"` shows a recorded run whole before play is pressed. Default `"start"`. */
11
+ startAt?: "start" | "end";
12
+ /** Join a group, as `useMediaElement`'s: starting this clock pauses the others in it. Defaults to the nearest `MediaGroup`. */
13
+ group?: string;
14
+ /** Join the page's key ownership (default true): pass `ownsKeys` to `useHotkeys`' `enabled`. Off for a clock whose keys the screen binds itself. */
15
+ keys?: boolean;
16
+ };
17
+ /** What `useTimeline` returns: the media element's names for a clock the app owns. */
18
+ export type TimelineClock = {
19
+ /** Seconds. */
20
+ time: number;
21
+ duration: number;
22
+ playing: boolean;
23
+ /** Stopped at the end of a clock that does not loop. */
24
+ ended: boolean;
25
+ rate: number;
26
+ /** One step, in seconds, as given. */
27
+ frame: number;
28
+ play: () => void;
29
+ pause: () => void;
30
+ toggle: () => void;
31
+ /** Moves the playhead (clamped to the run) and pauses. */
32
+ seek: (time: number) => void;
33
+ /** Moves `count` frames (negative goes back) and pauses. */
34
+ step: (count: number) => void;
35
+ /** Whether this clock's keys are live: it is the only player on the page, or the one last used. Pass it to `useHotkeys`' `enabled`. */
36
+ ownsKeys: boolean;
37
+ /** Spread on the region that holds the transport (and the stage, if the keys are to follow it): focus or a press there takes the keys. */
38
+ regionProps: {
39
+ onFocusCapture: () => void;
40
+ onPointerDownCapture: () => void;
41
+ };
42
+ };
43
+ /** A playhead the app owns, in the shape `Transport`, `SeekBar` and `transportShortcuts` take. */
44
+ export declare function useTimeline({ duration, rate, frame, loop, startAt, group, keys }: TimelineClockOptions): TimelineClock;
package/dist/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export { ScheduleTable, type ScheduleTableProps, type ScheduleRow } from './comp
45
45
  export { Thumbnail, ThumbnailSkeleton, type ThumbnailProps, type AspectRatio } from './components/thumbnail';
46
46
  export { FilmStrip, pickEvenly, frameAt, type FilmStripProps, type FilmFrame } from './components/film-strip';
47
47
  export { MediaContents, currentItem, type MediaContentsProps, type MediaContentsItem } from './components/media-contents';
48
+ export { skipAction, marksFor, type MediaMark, type SkipLevel, type SkipSteps, type SkipAction } from './components/media-skip';
48
49
  export { DataTable, TableSkeleton, parseSort, serialiseSort, type CellValue, type Column, type Sort, type DataTableProps, type RowSelection, type RowExpansion, } from './components/data-table';
49
50
  export { MediaPlayer, useMediaElement, useAttachedSource, SPEECH_RATES, type MediaPlayerProps, type MediaElementState, type MediaElementOptions, type MediaWindow, type StreamContext, type StreamAttachment, type SourceAttacher, type MediaProblem, type MediaSource, type MediaSession, type MediaHeading, type MediaProgress, type ResumeWords } from './components/media-player';
50
51
  export { useMediaSpans, SpanActions, PlayerNotice, type SpanActionsNotice, type MediaSpanData, type SpanKind, type SpanBehaviour, type SpanOutcome, type SpanWords, type MediaSpansState } from './components/media-spans';
@@ -52,7 +53,9 @@ export { TranscriptView, type TranscriptViewProps, type TranscriptSeek } from '.
52
53
  export { phraseAt, wordAt, wordId, phraseOfWordId, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
53
54
  export { Waveform, type WaveformProps, type WaveformMark, type WaveformMarkKind, type WaveformSpan, type WaveformTone } from './components/waveform';
54
55
  export { resamplePeaks, toPeakPair, peaksFromAudio, peakGain, type WaveformPeaks, type PeakPair, type DecodedAudio } from './lib/waveform';
55
- export { MediaGroup, PlayWindowButton, joinMediaGroup, type PlayWindowButtonProps } from './components/media-group';
56
+ export { MediaGroup, PlayWindowButton, joinMediaGroup, type GroupMember, type PlayWindowButtonProps } from './components/media-group';
57
+ export { useTimeline, type TimelineClock, type TimelineClockOptions } from './components/use-timeline';
58
+ export { TimelinePlayer, type TimelinePlayerProps } from './components/timeline-player';
56
59
  export { Transport, TimeReadout, SeekBar, SpanStrip, VolumeControl, RateChoice, MediaStage, StageGuides, transportShortcuts, type TransportProps, type SeekBarProps, type SeekBarSpan, type VolumeControlProps, type Precision } from './components/media';
57
60
  export { Timeline, TimelineZoomControls, useTimelineZoom, noOverlap, type TimelineProps, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelineChange, type TimelineDrop } from './components/timeline';
58
61
  export { tickStep, ticksBetween, tickLabel } from './lib/timeline';
@@ -85,7 +88,7 @@ export { AppShell, SideNav, Breadcrumb, type NavItem } from './components/app-sh
85
88
  export { Tabs, type TabItem } from './components/tabs';
86
89
  export { Density, type DensityName, type DensityProps } from './components/density';
87
90
  export type { ControlSize } from './lib/control';
88
- export { useHotkeys, KeysLegend, isTypingTarget, keyName, type Shortcut } from './components/hotkeys';
91
+ export { useHotkeys, KeysLegend, isTypingTarget, keyName, type Shortcut, type HotkeysOptions } from './components/hotkeys';
89
92
  export { useActiveItem, ActiveList, type ActiveItem } from './components/active-list';
90
93
  export { ThemeProvider, useColorScheme, useSystemColorScheme, ColorSchemeChoice, colorSchemeScript, COLOR_SCHEME_STORAGE_KEY, usePalette, PaletteChoice, paletteScript, palettes, DEFAULT_PALETTE, PALETTE_STORAGE_KEY, type PaletteOption, type PaletteState, type ColorScheme, type ColorSchemePreference, type ColorSchemeLabels, type ColorSchemeState, } from './components/theme';
91
94
  export { StrataQueryProvider, createQueryClient, toLoad, staleOf, useLoad, usePoll, type Poll, useInfiniteLoad, useJob, isTaskRunning, useWorkflowRun, isWorkflowRunning, type WorkflowRunLike, type WorkflowRunOptions, apiPage, fetchJson, HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody, type FetchJsonOptions, type FetchJsonInit, createApi, createTypedApi, type TypedApi, type Api, type ApiOptions, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type Job, type JobOptions, type More, } from './query';