strata-react 1.3.23 → 1.3.25
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 +3 -3
- package/UPGRADING.md +8 -0
- package/dist/components/hotkeys.d.ts +15 -4
- package/dist/components/key-owner.d.ts +11 -0
- package/dist/components/media-group.d.ts +9 -2
- package/dist/components/media.d.ts +3 -2
- package/dist/components/timeline-player.d.ts +18 -0
- package/dist/components/use-timeline.d.ts +44 -0
- package/dist/follow-BTPs49FP.js +16 -0
- package/dist/follow-BTPs49FP.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +280 -96
- package/dist/index.js.map +1 -1
- package/dist/lib/follow.d.ts +18 -0
- package/dist/lib/viewer-input.d.ts +29 -0
- package/dist/panorama.js +38 -96
- package/dist/panorama.js.map +1 -1
- package/dist/scene/camera.d.ts +29 -1
- package/dist/scene/index.d.ts +1 -1
- package/dist/scene/scene-viewport.d.ts +3 -1
- package/dist/scene.js +74 -74
- package/dist/scene.js.map +1 -1
- package/dist/strata.bare.css +9 -1
- package/dist/strata.css +9 -1
- package/dist/strata.migrate.css +9 -1
- package/dist/{value-controls-Dq2-QpvA.js → value-controls-Dm_EYfZW.js} +26 -6
- package/dist/value-controls-Dm_EYfZW.js.map +1 -0
- package/dist/viewer-input-CHU0Hx4A.js +107 -0
- package/dist/viewer-input-CHU0Hx4A.js.map +1 -0
- package/package.json +1 -1
- package/dist/value-controls-Dq2-QpvA.js.map +0 -1
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 |
|
|
@@ -234,7 +234,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
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
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 | `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` |
|
|
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 |
|
|
@@ -256,7 +256,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
|
|
|
256
256
|
| Bytes | `ByteView`, `ByteHighlight`, `ByteRange` | A hex dump for the file no other viewer understands: offsets, sixteen bytes a row and the printable characters, windowed so a 50 MB file scrolls, one tab stop with Left/Right by byte, Up/Down by row, PageUp/PageDown by screen, Home/End, Shift to extend; the range reported as `{ start, end }` (end exclusive) for a decoder beside it; `highlight` tints ranges by tone and names them in the status |
|
|
257
257
|
| Pictures from bytes | `PixelImage`, `pixelZoom`, `rgbaToBlob`, `useObjectUrl` | A decoded RGBA buffer (or `ImageData`) on a canvas at a whole-number zoom with square pixels and a checkerboard behind clear ones, named with its size; `useObjectUrl(bytes \| Blob, type)` is a URL for `MediaPlayer`, `Thumbnail` or a download, revoked when the value changes or the component unmounts |
|
|
258
258
|
| Console | `Console`, `ConsoleLine`, `ConsoleLevel` | A command line over a polite `log` that is virtualised from 100 lines and pinned to the end unless scrolled up: levels as words (`Warning`, `Error`), an echo of the command, history with Up and Down kept under `historyKey`, Tab completion from the app's `complete` |
|
|
259
|
-
| 3D scene | `strata-react/scene`: `SceneViewport`, `useOrbitCamera`, `frameFor`, `describeCamera`, camera maths | A frame for a scene the app draws in WebGL2: `render(gl, frame)` runs on change (frame has the view, projection and eye), orbit by drag, pan by right drag or Shift, zoom by Ctrl/Cmd+wheel or pinch (a plain wheel scrolls the page), arrows, `+` `-` `0`, a Reset button (animated unless motion is reduced), `mode="fly"` for a walkthrough, a lost context restored (`frame.context` counts them), the camera in words; its own entry, no dependency |
|
|
259
|
+
| 3D scene | `strata-react/scene`: `SceneViewport`, `useOrbitCamera`, `frameFor`, `describeCamera`, camera maths | A frame for a scene the app draws in WebGL2: `render(gl, frame)` runs on change (frame has the view, projection and eye), orbit by drag, pan by right drag or Shift, zoom by Ctrl/Cmd+wheel or pinch (a plain wheel scrolls the page), arrows, `+` `-` `0`, a Reset button (animated unless motion is reduced), `mode="fly"` for a walkthrough, a lost context restored (`frame.context` counts them), the camera in words; its own entry, no dependency `time` redraws it from a `useTimeline` clock (`frame.time`), `TimelinePlayer` puts it over the player's bar. One view model with `PanoramaViewer`: both read pointers, wheel and the settled status through `useViewPointers`, `useWheelZoom` and `useSettledStatus`; `cameraFromView` and `viewFromCamera` turn a panorama view into the fly camera that looks the same way; `followCamera` (and `followAim`) follow a heading the app supplies with the person's own look on top, for "through the player's eyes". |
|
|
260
260
|
| Testing | `strata-react/testing`: `renderWithStrata`, `renderRoutes`, `createTestQueryClient`, `installLayoutShims`, `setupStrataTests`, `installFakeIntersectionObserver`, `filledButtons`, `expectOneFilledButton`, `asyncButtonPhase` | Router + query client around Testing Library's `render`; `renderRoutes(routes, { route, basename })` renders the app's own `RouteObject[]` in a memory data router, so layout routes, redirects, loaders and error elements run, and returns the `router` (where a redirect landed is `router.state.location`) and an act-wrapped `navigate`; a fixed box and ResizeObserver so measuring components render in jsdom (a no-op without a DOM, so a setup file shared with node-environment tests is safe); `setupStrataTests({ afterEach })` is the one setup call (the layout shims, and after each test unmounting, the toast queue and loaded thumbnails: Testing Library only cleans up by itself when Vitest's `globals` are on); an IntersectionObserver the test fires with `scrollToEnd()` or `intersect(el)`; `filledButtons()` and `expectOneFilledButton()` check "one filled button per view" from `data-variant`, and `asyncButtonPhase(el)` reads an `AsyncButton`'s phase. Role names keep the non-breaking space from `format.count`, so match them with the same call or a `\s` regex |
|
|
261
261
|
| API types | `strata-react/api-types` and the `strata-api-types` command | See "API types from the server" below |
|
|
262
262
|
| Visual regression | `strata-react/visual` and the `strata-visual` command | Screenshots an app's Storybook and its routes in each MSW state, light and dark, against baselines in the app's repo |
|
package/UPGRADING.md
CHANGED
|
@@ -11,6 +11,14 @@ 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 (shared 3D input, #386)
|
|
15
|
+
- No action needed. `PanoramaViewer` and `SceneViewport` read pointers, the wheel and the status through shared hooks with the same behaviour; a pointer cancelled mid-press no longer calls `onPick`.
|
|
16
|
+
|
|
17
|
+
## 2026-11-26 (clock, key scope and theming hooks, #383–#386)
|
|
18
|
+
- `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.
|
|
19
|
+
- `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`).
|
|
20
|
+
- 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.
|
|
21
|
+
|
|
14
22
|
## 2026-11-26 (player skips and frame steps, #387)
|
|
15
23
|
- **`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.
|
|
16
24
|
- `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.
|
|
@@ -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
|
-
|
|
24
|
-
}
|
|
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
|
-
/**
|
|
4
|
-
export
|
|
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. */
|
|
@@ -104,9 +104,9 @@ export declare function RateChoice({ rate, onRateChange, rates, className }: {
|
|
|
104
104
|
/**
|
|
105
105
|
* The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
|
|
106
106
|
* or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
|
|
107
|
-
* 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`).
|
|
108
108
|
*/
|
|
109
|
-
export declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute }: {
|
|
109
|
+
export declare function transportShortcuts({ toggle, seek, time, duration, frame, jump, toggleMute, stageKeys }: {
|
|
110
110
|
toggle: () => void;
|
|
111
111
|
seek: (time: number) => void;
|
|
112
112
|
time: number;
|
|
@@ -114,6 +114,7 @@ export declare function transportShortcuts({ toggle, seek, time, duration, frame
|
|
|
114
114
|
frame?: number;
|
|
115
115
|
jump?: number;
|
|
116
116
|
toggleMute?: () => void;
|
|
117
|
+
stageKeys?: boolean;
|
|
117
118
|
}): Shortcut[];
|
|
118
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. */
|
|
119
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/lib/follow.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where a viewer looks when it follows something that moves (a player in a replay, a camera operator): the heading the app
|
|
4
|
+
* supplies, with the person's own look added on top, so panning during playback still works and "through the player's eyes" is just
|
|
5
|
+
* `follow` mode. Degrees, positive yaw to the right and positive pitch up, the same in `PanoramaViewer` and `SceneViewport`.
|
|
6
|
+
* Yaw wraps to -180 to 180 and pitch is held to `maxPitch` (default 89), where "up" stops meaning anything.
|
|
7
|
+
*/
|
|
8
|
+
function followAim({ heading, pitch = 0, look, maxPitch = 89 }) {
|
|
9
|
+
return {
|
|
10
|
+
yaw: ((heading + (look?.yaw ?? 0) + 180) % 360 + 360) % 360 - 180,
|
|
11
|
+
pitch: Math.min(Math.max(pitch + (look?.pitch ?? 0), -maxPitch), maxPitch)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export { followAim as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=follow-BTPs49FP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow-BTPs49FP.js","names":[],"sources":["../src/lib/follow.ts"],"sourcesContent":["// Pure, so the camera maths (no GL, no React) can use it. See `followAim`.\n\n/**\n * Where a viewer looks when it follows something that moves (a player in a replay, a camera operator): the heading the app\n * supplies, with the person's own look added on top, so panning during playback still works and \"through the player's eyes\" is just\n * `follow` mode. Degrees, positive yaw to the right and positive pitch up, the same in `PanoramaViewer` and `SceneViewport`.\n * Yaw wraps to -180 to 180 and pitch is held to `maxPitch` (default 89), where \"up\" stops meaning anything.\n */\nexport function followAim({ heading, pitch = 0, look, maxPitch = 89 }: { heading: number; pitch?: number; look?: { yaw?: number; pitch?: number }; maxPitch?: number }): { yaw: number; pitch: number } {\n const yaw = ((((heading + (look?.yaw ?? 0) + 180) % 360) + 360) % 360) - 180;\n return { yaw, pitch: Math.min(Math.max(pitch + (look?.pitch ?? 0), -maxPitch), maxPitch) };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,UAAU,EAAE,SAAS,QAAQ,GAAG,MAAM,WAAW,MAAuI;CAEtM,OAAO;EAAE,OADO,WAAW,MAAM,OAAO,KAAK,OAAO,MAAO,OAAO,MAAO;EAC3D,OAAO,KAAK,IAAI,KAAK,IAAI,SAAS,MAAM,SAAS,IAAI,CAAC,QAAQ,GAAG,QAAQ;CAAE;AAC3F"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
export { cn, typeSteps } from './lib/utils';
|
|
9
9
|
export { createFormat, format, NBSP, MISSING, toDate, type BinaryByteUnit, type ByteUnit, type BytesOptions, type CountOptions, type DateFormatter, type DateInput, type Format, type FormatOptions, type NumberFormatter, } from './lib/format';
|
|
10
10
|
export { useInView, type InViewOptions } from './lib/in-view';
|
|
11
|
+
export { followAim } from './lib/follow';
|
|
12
|
+
export { useSettledStatus, useViewPointers, useWheelZoom, type ViewPointerOptions } from './lib/viewer-input';
|
|
11
13
|
export type { IconComponent } from './lib/icon';
|
|
12
14
|
export { Button, IconButton, RowAction, buttonVariants, type ButtonProps, type IconButtonProps, type RowActionProps, } from './components/button';
|
|
13
15
|
export { Menu, ContextMenu, CommandMenu, CommandLegend, useCommands, commandShortcut, labelOf, type Command, type MenuEntry, type MenuProps, type ContextMenuProps, type CommandMenuProps, type CommandsOptions, } from './components/commands';
|
|
@@ -53,7 +55,9 @@ export { TranscriptView, type TranscriptViewProps, type TranscriptSeek } from '.
|
|
|
53
55
|
export { phraseAt, wordAt, wordId, phraseOfWordId, isDoubtful, phraseDoubtful, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptWord } from './lib/transcript';
|
|
54
56
|
export { Waveform, type WaveformProps, type WaveformMark, type WaveformMarkKind, type WaveformSpan, type WaveformTone } from './components/waveform';
|
|
55
57
|
export { resamplePeaks, toPeakPair, peaksFromAudio, peakGain, type WaveformPeaks, type PeakPair, type DecodedAudio } from './lib/waveform';
|
|
56
|
-
export { MediaGroup, PlayWindowButton, joinMediaGroup, type PlayWindowButtonProps } from './components/media-group';
|
|
58
|
+
export { MediaGroup, PlayWindowButton, joinMediaGroup, type GroupMember, type PlayWindowButtonProps } from './components/media-group';
|
|
59
|
+
export { useTimeline, type TimelineClock, type TimelineClockOptions } from './components/use-timeline';
|
|
60
|
+
export { TimelinePlayer, type TimelinePlayerProps } from './components/timeline-player';
|
|
57
61
|
export { Transport, TimeReadout, SeekBar, SpanStrip, VolumeControl, RateChoice, MediaStage, StageGuides, transportShortcuts, type TransportProps, type SeekBarProps, type SeekBarSpan, type VolumeControlProps, type Precision } from './components/media';
|
|
58
62
|
export { Timeline, TimelineZoomControls, useTimelineZoom, noOverlap, type TimelineProps, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelineChange, type TimelineDrop } from './components/timeline';
|
|
59
63
|
export { tickStep, ticksBetween, tickLabel } from './lib/timeline';
|
|
@@ -86,7 +90,7 @@ export { AppShell, SideNav, Breadcrumb, type NavItem } from './components/app-sh
|
|
|
86
90
|
export { Tabs, type TabItem } from './components/tabs';
|
|
87
91
|
export { Density, type DensityName, type DensityProps } from './components/density';
|
|
88
92
|
export type { ControlSize } from './lib/control';
|
|
89
|
-
export { useHotkeys, KeysLegend, isTypingTarget, keyName, type Shortcut } from './components/hotkeys';
|
|
93
|
+
export { useHotkeys, KeysLegend, isTypingTarget, keyName, type Shortcut, type HotkeysOptions } from './components/hotkeys';
|
|
90
94
|
export { useActiveItem, ActiveList, type ActiveItem } from './components/active-list';
|
|
91
95
|
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';
|
|
92
96
|
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';
|