strata-react 1.1.1 → 1.1.3

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
@@ -168,7 +168,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
168
168
  | 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 |
169
169
  | 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 |
170
170
  | 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` |
171
- | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions` | Play a file or a sequence of chapters without the event glue: 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, and a video keeps a 16:9 (or `aspect`) box before its metadata loads. The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
171
+ | Media player | `MediaPlayer`, `useMediaElement`, `SPEECH_RATES`, `useMediaSpans`, `SpanActions` | Play a file or a sequence of chapters without the event glue: 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, 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. The HLS attacher starts a `growing` source at its beginning, honours `config.startPosition` and takes `words` for its failures. |
172
172
  | 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` |
173
173
  | Listening and reading | `Waveform`, `TranscriptView`, `PlayWindowButton`, `MediaGroup`; `resamplePeaks`, `peaksFromAudio`, `phraseAt`, `wordAt` | 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); 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 |
174
174
  | 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 |
package/UPGRADING.md CHANGED
@@ -11,6 +11,15 @@ 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-18
15
+ - `MediaPlayer` hides the custom controls after three idle seconds during full-screen playback. Moving the mouse or using the keyboard reveals them.
16
+
17
+ ## 2026-11-15
18
+
19
+ - `MediaPlayer` (video, Strata's controls) now has a Full screen button after the volume and an `f` key (where the browser has the Fullscreen API); pass `fullscreen={false}` to remove them. The player is wrapped in `FullscreenFrame`, so a test that counts buttons or a baseline of a video player changes.
20
+ - `MediaPlayer` video: click plays or pauses, double click toggles full screen, and the wheel sets the volume while the player has focus. A test that clicks the video now changes playback.
21
+ - `useAsyncAction` no longer sets state or starts its settle timer after unmount; nothing to change.
22
+
14
23
  ## After v1.0.47 (2026-11-14)
15
24
 
16
25
  - New, optional: the `strata-api-types` command (`strata-react/api-types`) generates API types from a server's OpenAPI schema. It needs `openapi-typescript` installed in the app (an optional peer) and, on a TypeScript other than 5, an `overrides` entry for its `typescript@^5` peer; see the README. Apps that do not run it change nothing.
@@ -7,10 +7,12 @@ export type FullscreenFrameProps = {
7
7
  active: boolean;
8
8
  /** Called with `false` when the person leaves with Escape or the browser's own control. */
9
9
  onActiveChange: (active: boolean) => void;
10
+ /** Open a window-filling modal where the browser has no Fullscreen API or refuses. Default true. `false` for content that must not be mounted again (a playing video): where the browser cannot or will not, `onActiveChange(false)` is called instead. */
11
+ modal?: boolean;
10
12
  children: React.ReactNode;
11
13
  className?: string;
12
14
  };
13
15
  /** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
14
16
  export declare function canFullscreen(): boolean;
15
17
  /** Shows its children full screen while `active`: the browser's Fullscreen API where there is one, a window-filling modal where there is not. */
16
- export declare function FullscreenFrame({ label, active, onActiveChange, children, className }: FullscreenFrameProps): React.JSX.Element;
18
+ export declare function FullscreenFrame({ label, active, onActiveChange, modal: allowModal, children, className }: FullscreenFrameProps): React.JSX.Element;
@@ -173,6 +173,8 @@ export type MediaPlayerProps = {
173
173
  overlay?: (media: MediaElementState) => React.ReactNode;
174
174
  /** 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. */
175
175
  aspect?: number | `${number}/${number}`;
176
+ /** 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. */
177
+ fullscreen?: boolean;
176
178
  className?: string;
177
179
  };
178
180
  /** Playback speeds an audiobook or lecture listener expects. */
@@ -182,4 +184,4 @@ export declare const SPEECH_RATES: readonly number[];
182
184
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
183
185
  * parts and `useMediaElement` directly.
184
186
  */
185
- 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, onSpan, spanWords, mediaRef, overlay, aspect, className, }: MediaPlayerProps): React.JSX.Element;
187
+ 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, onSpan, spanWords, mediaRef, overlay, aspect, fullscreen, className, }: MediaPlayerProps): React.JSX.Element;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as Textarea, c as Tooltip, d as typeSteps, i as NativeSelect, l as KeyText, n as Field, o as useFieldControl, r as Input, s as controlHeight, t as ChoiceGroup, u as cn } from "./field-DeKNvGox.js";
2
2
  import { a as toDate, i as format, n as NBSP, r as createFormat, t as MISSING } from "./format-B32-PVi2.js";
3
- import { a as useAsyncAction, c as KeysLegend, d as useInView, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-DT3sb2MU.js";
3
+ import { a as useAsyncAction, c as KeysLegend, d as useInView, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-miuzPdJZ.js";
4
4
  import { a as fieldErrorsOf, c as IconButton, d as isDev, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-Dt--eHgK.js";
5
5
  import { a as toLoad, c as toast, i as staleOf, l as toastTimeout, n as createQueryClient, o as useLoad, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as overlaySurface } from "./query-CgE9YsRk.js";
6
6
  import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
@@ -2481,6 +2481,68 @@ function TableSkeleton({ rows = 4, columns = 5 }) {
2481
2481
  }, r))]
2482
2482
  });
2483
2483
  }
2484
+ // src/components/fullscreen-frame.tsx
2485
+ /** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
2486
+ function canFullscreen() {
2487
+ return typeof document !== "undefined" && document.fullscreenEnabled === true && typeof Element.prototype.requestFullscreen === "function";
2488
+ }
2489
+ /** Shows its children full screen while `active`: the browser's Fullscreen API where there is one, a window-filling modal where there is not. */
2490
+ function FullscreenFrame({ label, active, onActiveChange, modal: allowModal = true, children, className }) {
2491
+ const ref = React.useRef(null);
2492
+ const [native, setNative] = React.useState(false);
2493
+ const [refused, setRefused] = React.useState(false);
2494
+ const change = React.useRef(onActiveChange);
2495
+ change.current = onActiveChange;
2496
+ React.useEffect(() => {
2497
+ const el = ref.current;
2498
+ if (!active) {
2499
+ setNative(false);
2500
+ setRefused(false);
2501
+ if (document.fullscreenElement && document.fullscreenElement === el) document.exitFullscreen();
2502
+ return;
2503
+ }
2504
+ if (!el) return;
2505
+ if (!canFullscreen()) {
2506
+ if (!allowModal) change.current(false);
2507
+ return;
2508
+ }
2509
+ let cancelled = false;
2510
+ el.requestFullscreen().then(() => !cancelled && setNative(true), () => {
2511
+ if (cancelled) return;
2512
+ if (allowModal) setRefused(true);
2513
+ else change.current(false);
2514
+ });
2515
+ const onChange = () => {
2516
+ if (document.fullscreenElement !== el && !cancelled) change.current(false);
2517
+ };
2518
+ document.addEventListener("fullscreenchange", onChange);
2519
+ return () => {
2520
+ cancelled = true;
2521
+ document.removeEventListener("fullscreenchange", onChange);
2522
+ };
2523
+ }, [active, allowModal]);
2524
+ const modal = allowModal && active && !native && (!canFullscreen() || refused);
2525
+ const inner = /* @__PURE__ */ jsx("div", {
2526
+ ref,
2527
+ className: cn(active && "flex h-full min-h-0 flex-col bg-background p-4", className),
2528
+ children
2529
+ });
2530
+ if (!modal) return inner;
2531
+ return /* @__PURE__ */ jsx(ModalOverlay, {
2532
+ isOpen: true,
2533
+ onOpenChange: (o) => !o && onActiveChange(false),
2534
+ isDismissable: true,
2535
+ className: "layer-overlay fixed inset-0 scrim",
2536
+ children: /* @__PURE__ */ jsx(Modal, {
2537
+ className: cn("h-full w-full outline-none", overlaySurface, "rounded-none"),
2538
+ children: /* @__PURE__ */ jsx(Dialog$1, {
2539
+ "aria-label": label,
2540
+ className: "h-full outline-none",
2541
+ children: inner
2542
+ })
2543
+ })
2544
+ });
2545
+ }
2484
2546
  // src/components/media.tsx
2485
2547
  var clamp$3 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
2486
2548
  var timecode = (t, { precision, fps }) => format.timecode(t, {
@@ -3193,6 +3255,8 @@ function SpanActions({ state, className }) {
3193
3255
  });
3194
3256
  }
3195
3257
  // src/components/media-player.tsx
3258
+ /** How far one notch of the wheel over a focused video moves the volume, in percent. */
3259
+ var WHEEL_VOLUME_STEP = 5;
3196
3260
  var idle = {
3197
3261
  ready: 0,
3198
3262
  waitingForMore: false,
@@ -3596,7 +3660,7 @@ function useCoarsePointer() {
3596
3660
  * a touch device), with the failure to load shown and retried. For an editor or a replay, use the
3597
3661
  * parts and `useMediaElement` directly.
3598
3662
  */
3599
- function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, mediaRef, overlay, aspect, className }) {
3663
+ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, mediaRef, overlay, aspect, fullscreen = true, className }) {
3600
3664
  const list = React.useMemo(() => sources ?? (src ? [{
3601
3665
  src,
3602
3666
  title: label
@@ -3744,6 +3808,38 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3744
3808
  React.useEffect(() => {
3745
3809
  if (onTimeChange) onTimeChange(time);
3746
3810
  }, [time]);
3811
+ const [full, setFull] = React.useState(false);
3812
+ const [fullApi, setFullApi] = React.useState(false);
3813
+ React.useEffect(() => setFullApi(canFullscreen()), []);
3814
+ const canFull = fullscreen && fullApi && kind === "video" && !native;
3815
+ const autoHideControls = full && canFull && media.playing;
3816
+ const [controlsIdle, setControlsIdle] = React.useState(false);
3817
+ const idleTimer = React.useRef(void 0);
3818
+ const wakeControls = React.useCallback(() => {
3819
+ clearTimeout(idleTimer.current);
3820
+ setControlsIdle(false);
3821
+ if (autoHideControls) idleTimer.current = setTimeout(() => setControlsIdle(true), 3e3);
3822
+ }, [autoHideControls]);
3823
+ React.useEffect(() => {
3824
+ wakeControls();
3825
+ return () => clearTimeout(idleTimer.current);
3826
+ }, [wakeControls]);
3827
+ const hideControls = autoHideControls && controlsIdle;
3828
+ const stage = React.useRef(null);
3829
+ const latest = React.useRef(media);
3830
+ latest.current = media;
3831
+ React.useEffect(() => {
3832
+ const el = stage.current;
3833
+ if (!el || kind !== "video") return;
3834
+ const onWheel = (e) => {
3835
+ if (!el.contains(document.activeElement) || e.ctrlKey || !e.deltaY) return;
3836
+ e.preventDefault();
3837
+ const m = latest.current;
3838
+ m.setVolume(Math.min(100, Math.max(0, m.volume + (e.deltaY < 0 ? WHEEL_VOLUME_STEP : -5))));
3839
+ };
3840
+ el.addEventListener("wheel", onWheel, { passive: false });
3841
+ return () => el.removeEventListener("wheel", onWheel);
3842
+ }, [kind]);
3747
3843
  const keys = React.useMemo(() => [
3748
3844
  {
3749
3845
  keys: [" ", "k"],
@@ -3767,6 +3863,11 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3767
3863
  label: "Mute",
3768
3864
  run: () => media.setVolume(media.muted ? 100 : 0)
3769
3865
  },
3866
+ ...canFull ? [{
3867
+ keys: ["f"],
3868
+ label: full ? "Leave full screen" : "Full screen",
3869
+ run: () => setFull((f) => !f)
3870
+ }] : [],
3770
3871
  ...offer ? [{
3771
3872
  keys: ["s"],
3772
3873
  label: offer.label,
@@ -3777,7 +3878,9 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3777
3878
  time,
3778
3879
  offsets,
3779
3880
  index,
3780
- offer
3881
+ offer,
3882
+ canFull,
3883
+ full
3781
3884
  ]);
3782
3885
  const id = React.useId();
3783
3886
  React.useEffect(() => {
@@ -3798,7 +3901,14 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3798
3901
  shortcuts,
3799
3902
  native
3800
3903
  ]);
3801
- useHotkeys(keys, { enabled: shortcuts && !native && (page.count <= 1 || page.active === id) });
3904
+ const activeKeys = autoHideControls ? keys.map((shortcut) => ({
3905
+ ...shortcut,
3906
+ run: () => {
3907
+ wakeControls();
3908
+ shortcut.run();
3909
+ }
3910
+ })) : keys;
3911
+ useHotkeys(activeKeys, { enabled: shortcuts && !native && (page.count <= 1 || page.active === id) });
3802
3912
  React.useEffect(() => {
3803
3913
  if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
3804
3914
  const s = navigator.mediaSession;
@@ -3857,12 +3967,16 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3857
3967
  };
3858
3968
  const hasSpans = (spans?.length ?? 0) > 0;
3859
3969
  const element = kind === "video" ? /* @__PURE__ */ jsxs("div", {
3860
- className: "relative w-full overflow-hidden rounded-surface bg-surface-sunken",
3861
- style: { aspectRatio: aspect ?? natural ?? 16 / 9 },
3970
+ ref: stage,
3971
+ tabIndex: -1,
3972
+ className: cn("relative w-full overflow-hidden rounded-surface bg-surface-sunken outline-none", full && "min-h-0 flex-1"),
3973
+ style: full ? void 0 : { aspectRatio: aspect ?? natural ?? 16 / 9 },
3862
3974
  children: [/* @__PURE__ */ jsx("video", {
3863
3975
  ...common,
3864
3976
  poster,
3865
3977
  playsInline: true,
3978
+ onClick: native ? void 0 : () => media.toggle(),
3979
+ onDoubleClick: canFull ? () => setFull((f) => !f) : void 0,
3866
3980
  className: "absolute inset-0 size-full object-contain"
3867
3981
  }), (overlay || hasSpans) && /* @__PURE__ */ jsxs("div", {
3868
3982
  className: "pointer-events-none absolute inset-0 [&>*]:pointer-events-auto",
@@ -3876,138 +3990,155 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
3876
3990
  className: native ? "w-full" : "hidden"
3877
3991
  });
3878
3992
  const what = kind === "video" ? "this video" : "this recording";
3879
- return /* @__PURE__ */ jsxs("div", {
3880
- role: "group",
3881
- "aria-label": label,
3882
- onFocusCapture: () => keyPlayers.use(id),
3883
- onPointerDownCapture: () => keyPlayers.use(id),
3884
- className: cn("grid w-full gap-2", className),
3885
- children: [
3886
- element,
3887
- kind === "audio" && hasSpans && /* @__PURE__ */ jsx(SpanActions, {
3888
- state: spanState,
3889
- className: "flex flex-wrap items-center gap-2"
3890
- }),
3891
- kind === "audio" && overlay?.(media),
3892
- media.error?.kind === "load" && /* @__PURE__ */ jsx(Alert, {
3893
- tone: "danger",
3894
- announce: true,
3895
- title: `Could not load ${what}`,
3896
- action: /* @__PURE__ */ jsx(Button, {
3897
- size: "sm",
3898
- variant: "outline",
3899
- onClick: media.retry,
3900
- children: "Try again"
3993
+ return /* @__PURE__ */ jsx(FullscreenFrame, {
3994
+ label,
3995
+ active: full,
3996
+ onActiveChange: setFull,
3997
+ modal: false,
3998
+ className,
3999
+ children: /* @__PURE__ */ jsxs("div", {
4000
+ role: "group",
4001
+ "aria-label": label,
4002
+ onFocusCapture: () => keyPlayers.use(id),
4003
+ onMouseMoveCapture: autoHideControls ? wakeControls : void 0,
4004
+ onKeyDownCapture: autoHideControls ? wakeControls : void 0,
4005
+ onPointerDownCapture: () => keyPlayers.use(id),
4006
+ className: cn("grid w-full gap-2", full && "flex h-full min-h-0 flex-col"),
4007
+ children: [
4008
+ element,
4009
+ kind === "audio" && hasSpans && /* @__PURE__ */ jsx(SpanActions, {
4010
+ state: spanState,
4011
+ className: "flex flex-wrap items-center gap-2"
3901
4012
  }),
3902
- children: media.error.message
3903
- }),
3904
- media.error?.kind === "blocked" && /* @__PURE__ */ jsx("p", {
3905
- role: "status",
3906
- className: "type-body-sm text-muted-foreground",
3907
- children: media.error.message
3908
- }),
3909
- growing && /* @__PURE__ */ jsxs("div", {
3910
- className: "flex flex-wrap items-center gap-x-3 gap-y-1",
3911
- children: [
3912
- /* @__PURE__ */ jsx(Status, {
3913
- tone: "info",
3914
- icon: LoaderCircle,
3915
- children: "Still being made"
3916
- }),
3917
- growing.status && /* @__PURE__ */ jsx("span", {
3918
- className: "type-body-sm text-muted-foreground",
3919
- children: growing.status
4013
+ kind === "audio" && overlay?.(media),
4014
+ media.error?.kind === "load" && /* @__PURE__ */ jsx(Alert, {
4015
+ tone: "danger",
4016
+ announce: true,
4017
+ title: `Could not load ${what}`,
4018
+ action: /* @__PURE__ */ jsx(Button, {
4019
+ size: "sm",
4020
+ variant: "outline",
4021
+ onClick: media.retry,
4022
+ children: "Try again"
3920
4023
  }),
3921
- /* @__PURE__ */ jsx("span", {
3922
- role: "status",
3923
- className: "type-body-sm text-muted-foreground",
3924
- children: media.waitingForMore ? "Waiting for more to be made. It will carry on by itself." : ""
3925
- })
3926
- ]
3927
- }),
3928
- bound && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
3929
- className: "type-caption text-muted-foreground tabular-nums",
3930
- children: [
3931
- format.runningTime(bound.start),
3932
- " to ",
3933
- format.runningTime(bound.end),
3934
- loop ? ", looping" : ""
3935
- ]
3936
- }), /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", {
3937
- role: "status",
3938
- children: media.playing ? `Playing ${format.runningTime(bound.start)} to ${format.runningTime(bound.end)}` : ""
3939
- }) })] }),
3940
- !native && /* @__PURE__ */ jsxs("div", {
3941
- className: "grid gap-2",
3942
- children: [/* @__PURE__ */ jsxs("div", {
3943
- className: "flex min-w-0 items-center gap-3",
3944
- children: [/* @__PURE__ */ jsx(SeekBar, {
3945
- time,
3946
- duration,
3947
- onSeek: seek,
3948
- buffered: growing ? media.ready : offsets ? void 0 : media.buffered,
3949
- spans: spanState.bars,
3950
- marks: bound && showFull ? [{
3951
- time: bound.start,
3952
- label: "Window starts"
3953
- }, {
3954
- time: bound.end,
3955
- label: "Window ends"
3956
- }] : offsets ? list.map((s, i) => ({
3957
- time: offsets[i],
3958
- label: s.title
3959
- })).slice(1) : [],
3960
- step: JUMP,
3961
- bigStep: 60,
3962
- label: `Seek in ${label}`
3963
- }), /* @__PURE__ */ jsx(TimeReadout, {
3964
- time,
3965
- duration
3966
- })]
3967
- }), /* @__PURE__ */ jsxs("div", {
3968
- className: "flex flex-wrap items-center gap-x-4 gap-y-2",
4024
+ children: media.error.message
4025
+ }),
4026
+ media.error?.kind === "blocked" && /* @__PURE__ */ jsx("p", {
4027
+ role: "status",
4028
+ className: "type-body-sm text-muted-foreground",
4029
+ children: media.error.message
4030
+ }),
4031
+ growing && /* @__PURE__ */ jsxs("div", {
4032
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1",
3969
4033
  children: [
3970
- /* @__PURE__ */ jsxs(Transport, {
3971
- playing: media.playing,
3972
- onPlayPause: media.toggle,
3973
- children: [list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
3974
- icon: SkipBack,
3975
- label: "Previous chapter",
3976
- disabled: index === 0,
3977
- onClick: () => step(-1)
3978
- }), list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
3979
- icon: SkipForward,
3980
- label: "Next chapter",
3981
- disabled: index === list.length - 1,
3982
- onClick: () => step(1)
3983
- })]
4034
+ /* @__PURE__ */ jsx(Status, {
4035
+ tone: "info",
4036
+ icon: LoaderCircle,
4037
+ children: "Still being made"
3984
4038
  }),
3985
- list.length > 1 && /* @__PURE__ */ jsxs("span", {
4039
+ growing.status && /* @__PURE__ */ jsx("span", {
3986
4040
  className: "type-body-sm text-muted-foreground",
3987
- children: [
3988
- current?.title,
3989
- " (",
3990
- index + 1,
3991
- " of ",
3992
- list.length,
3993
- ")"
3994
- ]
4041
+ children: growing.status
3995
4042
  }),
3996
- /* @__PURE__ */ jsxs("span", {
3997
- className: "ml-auto flex items-center gap-3",
3998
- children: [/* @__PURE__ */ jsx(RateChoice, {
3999
- rate: media.rate,
4000
- onRateChange: media.setRate,
4001
- rates
4002
- }), /* @__PURE__ */ jsx(VolumeControl, {
4003
- volume: media.volume,
4004
- onVolumeChange: media.setVolume
4005
- })]
4043
+ /* @__PURE__ */ jsx("span", {
4044
+ role: "status",
4045
+ className: "type-body-sm text-muted-foreground",
4046
+ children: media.waitingForMore ? "Waiting for more to be made. It will carry on by itself." : ""
4006
4047
  })
4007
4048
  ]
4008
- })]
4009
- })
4010
- ]
4049
+ }),
4050
+ bound && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
4051
+ className: "type-caption text-muted-foreground tabular-nums",
4052
+ children: [
4053
+ format.runningTime(bound.start),
4054
+ " to ",
4055
+ format.runningTime(bound.end),
4056
+ loop ? ", looping" : ""
4057
+ ]
4058
+ }), /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", {
4059
+ role: "status",
4060
+ children: media.playing ? `Playing ${format.runningTime(bound.start)} to ${format.runningTime(bound.end)}` : ""
4061
+ }) })] }),
4062
+ !native && /* @__PURE__ */ jsxs("div", {
4063
+ className: cn("grid gap-2", hideControls && "pointer-events-none opacity-0 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100"),
4064
+ children: [/* @__PURE__ */ jsxs("div", {
4065
+ className: "flex min-w-0 items-center gap-3",
4066
+ children: [/* @__PURE__ */ jsx(SeekBar, {
4067
+ time,
4068
+ duration,
4069
+ onSeek: seek,
4070
+ buffered: growing ? media.ready : offsets ? void 0 : media.buffered,
4071
+ spans: spanState.bars,
4072
+ marks: bound && showFull ? [{
4073
+ time: bound.start,
4074
+ label: "Window starts"
4075
+ }, {
4076
+ time: bound.end,
4077
+ label: "Window ends"
4078
+ }] : offsets ? list.map((s, i) => ({
4079
+ time: offsets[i],
4080
+ label: s.title
4081
+ })).slice(1) : [],
4082
+ step: JUMP,
4083
+ bigStep: 60,
4084
+ label: `Seek in ${label}`
4085
+ }), /* @__PURE__ */ jsx(TimeReadout, {
4086
+ time,
4087
+ duration
4088
+ })]
4089
+ }), /* @__PURE__ */ jsxs("div", {
4090
+ className: "flex flex-wrap items-center gap-x-4 gap-y-2",
4091
+ children: [
4092
+ /* @__PURE__ */ jsxs(Transport, {
4093
+ playing: media.playing,
4094
+ onPlayPause: media.toggle,
4095
+ children: [list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
4096
+ icon: SkipBack,
4097
+ label: "Previous chapter",
4098
+ disabled: index === 0,
4099
+ onClick: () => step(-1)
4100
+ }), list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
4101
+ icon: SkipForward,
4102
+ label: "Next chapter",
4103
+ disabled: index === list.length - 1,
4104
+ onClick: () => step(1)
4105
+ })]
4106
+ }),
4107
+ list.length > 1 && /* @__PURE__ */ jsxs("span", {
4108
+ className: "type-body-sm text-muted-foreground",
4109
+ children: [
4110
+ current?.title,
4111
+ " (",
4112
+ index + 1,
4113
+ " of ",
4114
+ list.length,
4115
+ ")"
4116
+ ]
4117
+ }),
4118
+ /* @__PURE__ */ jsxs("span", {
4119
+ className: "ml-auto flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-2",
4120
+ children: [
4121
+ /* @__PURE__ */ jsx(RateChoice, {
4122
+ rate: media.rate,
4123
+ onRateChange: media.setRate,
4124
+ rates
4125
+ }),
4126
+ /* @__PURE__ */ jsx(VolumeControl, {
4127
+ volume: media.volume,
4128
+ onVolumeChange: media.setVolume
4129
+ }),
4130
+ canFull && /* @__PURE__ */ jsx(IconButton, {
4131
+ icon: full ? Minimize : Maximize,
4132
+ label: full ? "Leave full screen" : "Full screen",
4133
+ onPress: () => setFull(!full)
4134
+ })
4135
+ ]
4136
+ })
4137
+ ]
4138
+ })]
4139
+ })
4140
+ ]
4141
+ })
4011
4142
  });
4012
4143
  }
4013
4144
  // src/lib/transcript.ts
@@ -10511,60 +10642,6 @@ function useJob({ isRunning, every = 2e3, invalidates = [], describeError, ...op
10511
10642
  function isTaskRunning(task, finished) {
10512
10643
  return !(Array.isArray(finished) ? finished.includes(task.state) : finished.has(task.state));
10513
10644
  }
10514
- // src/components/fullscreen-frame.tsx
10515
- /** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
10516
- function canFullscreen() {
10517
- return typeof document !== "undefined" && document.fullscreenEnabled === true && typeof Element.prototype.requestFullscreen === "function";
10518
- }
10519
- /** Shows its children full screen while `active`: the browser's Fullscreen API where there is one, a window-filling modal where there is not. */
10520
- function FullscreenFrame({ label, active, onActiveChange, children, className }) {
10521
- const ref = React.useRef(null);
10522
- const [native, setNative] = React.useState(false);
10523
- const [refused, setRefused] = React.useState(false);
10524
- const change = React.useRef(onActiveChange);
10525
- change.current = onActiveChange;
10526
- React.useEffect(() => {
10527
- const el = ref.current;
10528
- if (!active) {
10529
- setNative(false);
10530
- setRefused(false);
10531
- if (document.fullscreenElement && document.fullscreenElement === el) document.exitFullscreen();
10532
- return;
10533
- }
10534
- if (!el || !canFullscreen()) return;
10535
- let cancelled = false;
10536
- el.requestFullscreen().then(() => !cancelled && setNative(true), () => !cancelled && setRefused(true));
10537
- const onChange = () => {
10538
- if (document.fullscreenElement !== el && !cancelled) change.current(false);
10539
- };
10540
- document.addEventListener("fullscreenchange", onChange);
10541
- return () => {
10542
- cancelled = true;
10543
- document.removeEventListener("fullscreenchange", onChange);
10544
- };
10545
- }, [active]);
10546
- const modal = active && !native && (!canFullscreen() || refused);
10547
- const inner = /* @__PURE__ */ jsx("div", {
10548
- ref,
10549
- className: cn(active && "flex h-full min-h-0 flex-col bg-background p-4", className),
10550
- children
10551
- });
10552
- if (!modal) return inner;
10553
- return /* @__PURE__ */ jsx(ModalOverlay, {
10554
- isOpen: true,
10555
- onOpenChange: (o) => !o && onActiveChange(false),
10556
- isDismissable: true,
10557
- className: "layer-overlay fixed inset-0 scrim",
10558
- children: /* @__PURE__ */ jsx(Modal, {
10559
- className: cn("h-full w-full outline-none", overlaySurface, "rounded-none"),
10560
- children: /* @__PURE__ */ jsx(Dialog$1, {
10561
- "aria-label": label,
10562
- className: "h-full outline-none",
10563
- children: inner
10564
- })
10565
- })
10566
- });
10567
- }
10568
10645
  // src/lib/image-diff.ts
10569
10646
  /** The longest side, in pixels, a picture is compared at. */
10570
10647
  var MAX_SIDE = 2048;