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 +3 -3
- package/UPGRADING.md +10 -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-player.d.ts +10 -6
- package/dist/components/media-skip.d.ts +31 -0
- package/dist/components/media.d.ts +7 -11
- package/dist/components/timeline-player.d.ts +18 -0
- package/dist/components/use-timeline.d.ts +44 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +669 -264
- package/dist/index.js.map +1 -1
- package/dist/panorama.js +1 -1
- package/dist/scene/camera.d.ts +4 -1
- package/dist/scene/scene-viewport.d.ts +3 -1
- package/dist/scene.js +12 -7
- 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/package.json +1 -1
- package/dist/value-controls-Dq2-QpvA.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import { i as typeSteps, n as KeyText, r as cn, t as Tooltip } from "./tooltip-D
|
|
|
2
2
|
import { a as Textarea, c as useSearchParam, d as createFormat, f as format, i as NativeSelect, l as MISSING, n as Field, o as useFieldControl, p as toDate, r as Input, s as controlHeight, t as ChoiceGroup, u as NBSP } from "./field-BjeE_FeB.js";
|
|
3
3
|
import { a as isDev, i as buttonVariants, n as IconButton, o as useInView, r as RowAction, t as Button } from "./button-KGJI6jQr.js";
|
|
4
4
|
import { A as StrataQueryProvider, C as toast, D as LoadError, E as EmptyState, F as useLoad, I as usePoll, L as overlaySurface, M as fetchJson, N as staleOf, O as Skeleton, P as toLoad, S as StrataToastRegion, T as DataView$1, _ as clampViewport, a as useMicrophone, b as viewportTransform, d as zoomToBox, f as FIT, g as boxViewport, h as actualPixelsScale, i as explainMicrophoneError, j as createQueryClient, k as StaleNotice, l as readingOrder, m as MIN_SCALE, n as MicrophoneError, o as Thumbnail, p as MAX_SCALE, r as browserMicrophone, s as ThumbnailSkeleton, t as MicrophoneContext, u as regionStyle, v as frameBoxToShares, w as toastTimeout, x as zoomAt, y as regionShares } from "./microphone-Bo3WaXgD.js";
|
|
5
|
-
import { a as useAsyncAction, c as KeysLegend, d as useHotkeys, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as keyName } from "./value-controls-
|
|
5
|
+
import { a as useAsyncAction, c as KeysLegend, d as useHotkeys, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as keyName } from "./value-controls-Dm_EYfZW.js";
|
|
6
6
|
import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
|
|
7
7
|
import { a as fieldErrorsOf, i as errorPayload, n as describeActionError, o as readErrorBody, r as describeHttpError, t as HttpError } from "./errors-BUvY1Z4d.js";
|
|
8
8
|
import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-CxYZkUNk.js";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
11
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
11
|
+
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
|
|
14
14
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -1645,6 +1645,7 @@ function LinkCard({ title, description, marks, as: Heading = "h3", className, ex
|
|
|
1645
1645
|
const describedBy = [description && descriptionId, marks && marksId].filter(Boolean).join(" ") || void 0;
|
|
1646
1646
|
const linkClass = "rounded-control outline-none after:absolute after:inset-0 after:rounded-surface";
|
|
1647
1647
|
return /* @__PURE__ */ jsxs("div", {
|
|
1648
|
+
"data-part": "link-card",
|
|
1648
1649
|
className: cn("relative grid content-start gap-1.5 rounded-surface border border-border bg-background p-4 transition-state", "hover:border-muted-foreground has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring", className),
|
|
1649
1650
|
children: [
|
|
1650
1651
|
/* @__PURE__ */ jsx(Heading, {
|
|
@@ -3535,6 +3536,54 @@ var ContentsRow = React.memo(function ContentsRow({ item, current, onSeek, onSel
|
|
|
3535
3536
|
})
|
|
3536
3537
|
});
|
|
3537
3538
|
});
|
|
3539
|
+
// src/components/media-skip.ts
|
|
3540
|
+
var LEVEL_KIND = {
|
|
3541
|
+
small: "scene",
|
|
3542
|
+
large: "chapter"
|
|
3543
|
+
};
|
|
3544
|
+
/** The marks a level skips by: scenes for small, chapters (and marks with no kind) for large, in time order. */
|
|
3545
|
+
function marksFor(marks, level) {
|
|
3546
|
+
const kind = LEVEL_KIND[level];
|
|
3547
|
+
return marks.filter((m) => (m.kind ?? "chapter") === kind).map((m) => m.time).sort((a, b) => a - b);
|
|
3548
|
+
}
|
|
3549
|
+
/** "1 min", "10 s", "90 s". */
|
|
3550
|
+
function stepWords(seconds) {
|
|
3551
|
+
return seconds >= 60 && seconds % 60 === 0 ? `${seconds / 60} min` : `${seconds} s`;
|
|
3552
|
+
}
|
|
3553
|
+
/**
|
|
3554
|
+
* Where a skip at `level` in `direction` from `time` goes: by the level's marks when the file has any
|
|
3555
|
+
* (the file's start counts as one), else by its time step. `restart` is how far into a part
|
|
3556
|
+
* "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.
|
|
3557
|
+
*/
|
|
3558
|
+
function skipAction(marks, level, direction, time, { steps = {}, duration = null, restart = 2 } = {}) {
|
|
3559
|
+
const points = marksFor(marks, level).filter((p) => p >= 0 && (duration == null || p <= duration));
|
|
3560
|
+
const noun = LEVEL_KIND[level];
|
|
3561
|
+
if (points.length) {
|
|
3562
|
+
const all = points[0] > 0 ? [0, ...points] : points;
|
|
3563
|
+
if (direction > 0) {
|
|
3564
|
+
const next = all.find((p) => p > time + .01);
|
|
3565
|
+
return {
|
|
3566
|
+
label: `Next ${noun}`,
|
|
3567
|
+
to: next ?? null,
|
|
3568
|
+
by: "mark"
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
const behind = all.filter((p) => p <= time - restart);
|
|
3572
|
+
return {
|
|
3573
|
+
label: `Previous ${noun}`,
|
|
3574
|
+
to: behind.length ? behind[behind.length - 1] : time > 0 ? 0 : null,
|
|
3575
|
+
by: "mark"
|
|
3576
|
+
};
|
|
3577
|
+
}
|
|
3578
|
+
const step = level === "small" ? steps.small ?? 10 : steps.large ?? 60;
|
|
3579
|
+
const raw = time + direction * step;
|
|
3580
|
+
const to = direction < 0 ? Math.max(0, raw) : duration ? Math.min(duration, raw) : raw;
|
|
3581
|
+
return {
|
|
3582
|
+
label: `${direction < 0 ? "Back" : "Forward"} ${stepWords(step)}`,
|
|
3583
|
+
to: direction < 0 && time <= 0 || direction > 0 && duration != null && time >= duration ? null : to,
|
|
3584
|
+
by: "time"
|
|
3585
|
+
};
|
|
3586
|
+
}
|
|
3538
3587
|
// src/components/fullscreen-frame.tsx
|
|
3539
3588
|
/** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
|
|
3540
3589
|
function canFullscreen() {
|
|
@@ -3603,7 +3652,7 @@ function FullscreenFrame({ label, active, onActiveChange, modal: allowModal = tr
|
|
|
3603
3652
|
});
|
|
3604
3653
|
}
|
|
3605
3654
|
// src/components/media.tsx
|
|
3606
|
-
var clamp$
|
|
3655
|
+
var clamp$4 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
3607
3656
|
var timecode = (t, { precision, fps }) => format.timecode(t, {
|
|
3608
3657
|
precision,
|
|
3609
3658
|
fps
|
|
@@ -3694,8 +3743,8 @@ function SpanStrip({ spans, duration, label = "Marked parts", precision = "secon
|
|
|
3694
3743
|
function drawableSpans(spans, duration) {
|
|
3695
3744
|
return spans.map((s) => ({
|
|
3696
3745
|
...s,
|
|
3697
|
-
start: clamp$
|
|
3698
|
-
end: clamp$
|
|
3746
|
+
start: clamp$4(s.start, 0, duration),
|
|
3747
|
+
end: clamp$4(s.end, 0, duration)
|
|
3699
3748
|
})).filter((s) => Number.isFinite(s.start) && Number.isFinite(s.end) && s.end > s.start).sort((a, b) => a.start - b.start);
|
|
3700
3749
|
}
|
|
3701
3750
|
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
@@ -3704,8 +3753,8 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
|
|
|
3704
3753
|
const disabled = off || duration === 0;
|
|
3705
3754
|
const track = React.useRef(null);
|
|
3706
3755
|
const input = React.useRef(null);
|
|
3707
|
-
const frac = duration > 0 ? clamp$
|
|
3708
|
-
const seekTo = (t) => onSeek(clamp$
|
|
3756
|
+
const frac = duration > 0 ? clamp$4(time / duration, 0, 1) : 0;
|
|
3757
|
+
const seekTo = (t) => onSeek(clamp$4(t, 0, duration));
|
|
3709
3758
|
const shared = useSharedCursor();
|
|
3710
3759
|
const joined = Boolean(cursorProp) && shared !== null;
|
|
3711
3760
|
const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
|
|
@@ -3742,7 +3791,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
|
|
|
3742
3791
|
minValue: 0,
|
|
3743
3792
|
maxValue: Math.max(duration, fine),
|
|
3744
3793
|
step: fine,
|
|
3745
|
-
value: [clamp$
|
|
3794
|
+
value: [clamp$4(time, 0, duration)],
|
|
3746
3795
|
onChange: ([t]) => seekTo(t),
|
|
3747
3796
|
numberFormatter: timeText,
|
|
3748
3797
|
isDisabled: disabled
|
|
@@ -3784,7 +3833,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
|
|
|
3784
3833
|
onPointerMove: (e) => {
|
|
3785
3834
|
if (!joined || duration === 0) return;
|
|
3786
3835
|
const box = e.currentTarget.getBoundingClientRect();
|
|
3787
|
-
shared.setPointer(toCursor(clamp$
|
|
3836
|
+
shared.setPointer(toCursor(clamp$4((e.clientX - box.left) / (box.width || 1) * duration, 0, duration)));
|
|
3788
3837
|
},
|
|
3789
3838
|
onPointerLeave: () => shared?.setPointer(null)
|
|
3790
3839
|
}),
|
|
@@ -3798,7 +3847,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
|
|
|
3798
3847
|
buffered !== void 0 && duration > 0 && /* @__PURE__ */ jsx("span", {
|
|
3799
3848
|
"aria-hidden": true,
|
|
3800
3849
|
className: "absolute left-0 h-1.5 rounded-pill bg-neutral-4",
|
|
3801
|
-
style: { width: `${clamp$
|
|
3850
|
+
style: { width: `${clamp$4(buffered / duration, 0, 1) * 100}%` }
|
|
3802
3851
|
}),
|
|
3803
3852
|
/* @__PURE__ */ jsx("span", {
|
|
3804
3853
|
"aria-hidden": true,
|
|
@@ -3817,27 +3866,37 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
|
|
|
3817
3866
|
className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-foreground/60",
|
|
3818
3867
|
style: { left: `${otherTime / duration * 100}%` }
|
|
3819
3868
|
}),
|
|
3820
|
-
duration > 0 && marks.filter((m) => m.time >= 0 && m.time <= duration).map((m) =>
|
|
3821
|
-
|
|
3822
|
-
tabIndex: -1,
|
|
3823
|
-
disabled,
|
|
3824
|
-
title: `${m.label}, ${timecode(m.time, {
|
|
3825
|
-
precision,
|
|
3826
|
-
fps
|
|
3827
|
-
})}`,
|
|
3828
|
-
"aria-label": `${m.label}, ${timecode(m.time, {
|
|
3869
|
+
duration > 0 && marks.filter((m) => m.time >= 0 && m.time <= duration).map((m) => {
|
|
3870
|
+
const at = timecode(m.time, {
|
|
3829
3871
|
precision,
|
|
3830
3872
|
fps
|
|
3831
|
-
})
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3873
|
+
});
|
|
3874
|
+
const scene = m.kind === "scene";
|
|
3875
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
3876
|
+
label: m.label,
|
|
3877
|
+
hint: /* @__PURE__ */ jsx("span", {
|
|
3878
|
+
className: "tabular-nums",
|
|
3879
|
+
children: at
|
|
3880
|
+
}),
|
|
3881
|
+
delay: 150,
|
|
3882
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
3883
|
+
excludeFromTabOrder: true,
|
|
3884
|
+
isDisabled: disabled,
|
|
3885
|
+
"aria-label": `${m.label}, ${at}`,
|
|
3886
|
+
"data-kind": m.kind ?? "chapter",
|
|
3887
|
+
onPress: () => onMarkPress ? onMarkPress(m) : seekTo(m.time),
|
|
3888
|
+
className: cn("group/mark absolute inset-y-0 flex -translate-x-1/2 cursor-pointer items-center justify-center", scene ? "w-2" : "z-10 w-3"),
|
|
3889
|
+
style: { left: `${m.time / duration * 100}%` },
|
|
3890
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
3891
|
+
"aria-hidden": true,
|
|
3892
|
+
className: cn("rounded-pill transition-state group-hover/mark:bg-primary", scene ? "h-2 w-0.5 bg-foreground/50" : "h-3.5 w-1 bg-foreground")
|
|
3893
|
+
})
|
|
3894
|
+
})
|
|
3895
|
+
}, `${m.time}-${m.kind ?? "chapter"}-${m.label}`);
|
|
3896
|
+
}),
|
|
3838
3897
|
/* @__PURE__ */ jsx("div", {
|
|
3839
3898
|
...thumbProps,
|
|
3840
|
-
className: cn("absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-pill border-2 border-primary bg-background", isFocusVisible && "outline-2 outline-offset-2 outline-ring"),
|
|
3899
|
+
className: cn("absolute top-1/2 z-20 size-4 -translate-x-1/2 -translate-y-1/2 rounded-pill border-2 border-primary bg-background", isFocusVisible && "outline-2 outline-offset-2 outline-ring"),
|
|
3841
3900
|
style: { left: `${frac * 100}%` },
|
|
3842
3901
|
children: /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", {
|
|
3843
3902
|
ref: input,
|
|
@@ -3962,27 +4021,31 @@ function RateChoice({ rate, onRateChange, rates = [
|
|
|
3962
4021
|
/**
|
|
3963
4022
|
* The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
|
|
3964
4023
|
* or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
|
|
3965
|
-
* to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
|
|
4024
|
+
* 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`).
|
|
3966
4025
|
*/
|
|
3967
|
-
function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute }) {
|
|
3968
|
-
const to = (t) => () => seek(clamp$
|
|
4026
|
+
function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute, stageKeys }) {
|
|
4027
|
+
const to = (t) => () => seek(clamp$4(t, 0, duration));
|
|
4028
|
+
const anywhere = stageKeys || void 0;
|
|
3969
4029
|
return [
|
|
3970
4030
|
{
|
|
3971
4031
|
keys: [" ", "k"],
|
|
3972
4032
|
label: "Play or pause",
|
|
3973
|
-
run: toggle
|
|
4033
|
+
run: toggle,
|
|
4034
|
+
anywhere
|
|
3974
4035
|
},
|
|
3975
4036
|
{
|
|
3976
4037
|
keys: ["j"],
|
|
3977
4038
|
label: `Back ${jump} s`,
|
|
3978
4039
|
run: to(time - jump),
|
|
3979
|
-
repeat: true
|
|
4040
|
+
repeat: true,
|
|
4041
|
+
anywhere
|
|
3980
4042
|
},
|
|
3981
4043
|
{
|
|
3982
4044
|
keys: ["l"],
|
|
3983
4045
|
label: `Forward ${jump} s`,
|
|
3984
4046
|
run: to(time + jump),
|
|
3985
|
-
repeat: true
|
|
4047
|
+
repeat: true,
|
|
4048
|
+
anywhere
|
|
3986
4049
|
},
|
|
3987
4050
|
{
|
|
3988
4051
|
keys: ["ArrowLeft"],
|
|
@@ -3999,17 +4062,20 @@ function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump
|
|
|
3999
4062
|
{
|
|
4000
4063
|
keys: ["Home"],
|
|
4001
4064
|
label: "Go to start",
|
|
4002
|
-
run: to(0)
|
|
4065
|
+
run: to(0),
|
|
4066
|
+
anywhere
|
|
4003
4067
|
},
|
|
4004
4068
|
{
|
|
4005
4069
|
keys: ["End"],
|
|
4006
4070
|
label: "Go to end",
|
|
4007
|
-
run: to(duration)
|
|
4071
|
+
run: to(duration),
|
|
4072
|
+
anywhere
|
|
4008
4073
|
},
|
|
4009
4074
|
...toggleMute ? [{
|
|
4010
4075
|
keys: ["m"],
|
|
4011
4076
|
label: "Mute",
|
|
4012
|
-
run: toggleMute
|
|
4077
|
+
run: toggleMute,
|
|
4078
|
+
anywhere
|
|
4013
4079
|
}] : []
|
|
4014
4080
|
];
|
|
4015
4081
|
}
|
|
@@ -4121,9 +4187,68 @@ function StageGuides({ safe, thirds, centre, className }) {
|
|
|
4121
4187
|
children: [draw("stroke-foreground", 3), draw("stroke-background", 1)]
|
|
4122
4188
|
});
|
|
4123
4189
|
}
|
|
4190
|
+
// src/components/key-owner.ts
|
|
4191
|
+
var members = /* @__PURE__ */ new Set();
|
|
4192
|
+
var active = null;
|
|
4193
|
+
var warned = false;
|
|
4194
|
+
var snapshot = {
|
|
4195
|
+
count: 0,
|
|
4196
|
+
active: null
|
|
4197
|
+
};
|
|
4198
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
4199
|
+
var emit = () => {
|
|
4200
|
+
snapshot = {
|
|
4201
|
+
count: members.size,
|
|
4202
|
+
active
|
|
4203
|
+
};
|
|
4204
|
+
listeners.forEach((l) => l());
|
|
4205
|
+
};
|
|
4206
|
+
var subscribe = (l) => {
|
|
4207
|
+
listeners.add(l);
|
|
4208
|
+
return () => void listeners.delete(l);
|
|
4209
|
+
};
|
|
4210
|
+
var get = () => snapshot;
|
|
4211
|
+
/**
|
|
4212
|
+
* Joins the page's key owners while `enabled`, and takes the keys whenever `playing` turns true. Spread nothing: call
|
|
4213
|
+
* `claim` from the region's focus and pointer-down handlers, and bind the player's `useHotkeys` with `enabled: owner.owns`.
|
|
4214
|
+
*/
|
|
4215
|
+
function useKeyOwner(enabled, playing = false) {
|
|
4216
|
+
const id = React.useId();
|
|
4217
|
+
React.useEffect(() => {
|
|
4218
|
+
if (!enabled) return;
|
|
4219
|
+
members.add(id);
|
|
4220
|
+
if (members.size === 2 && !warned && isDev()) {
|
|
4221
|
+
warned = true;
|
|
4222
|
+
console.warn("strata-react: several players are on this page, so Space, K, J, L and M go to the one last played or focused. Pass shortcuts={false} to one you bind your own keys for.");
|
|
4223
|
+
}
|
|
4224
|
+
emit();
|
|
4225
|
+
return () => {
|
|
4226
|
+
members.delete(id);
|
|
4227
|
+
if (active === id) active = null;
|
|
4228
|
+
emit();
|
|
4229
|
+
};
|
|
4230
|
+
}, [id, enabled]);
|
|
4231
|
+
const page = React.useSyncExternalStore(subscribe, get, get);
|
|
4232
|
+
const claim = React.useCallback(() => {
|
|
4233
|
+
if (active === id || !members.has(id)) return;
|
|
4234
|
+
active = id;
|
|
4235
|
+
emit();
|
|
4236
|
+
}, [id]);
|
|
4237
|
+
React.useEffect(() => {
|
|
4238
|
+
if (playing && enabled) claim();
|
|
4239
|
+
}, [
|
|
4240
|
+
playing,
|
|
4241
|
+
enabled,
|
|
4242
|
+
claim
|
|
4243
|
+
]);
|
|
4244
|
+
return {
|
|
4245
|
+
owns: enabled && (page.count <= 1 || page.active === id),
|
|
4246
|
+
claim
|
|
4247
|
+
};
|
|
4248
|
+
}
|
|
4124
4249
|
// src/components/media-group.tsx
|
|
4125
4250
|
var groups = /* @__PURE__ */ new Map();
|
|
4126
|
-
/** Adds an element to a named group until the returned function is called; whenever one plays, the others pause. */
|
|
4251
|
+
/** Adds an element, or a `useTimeline` clock, to a named group until the returned function is called; whenever one plays, the others pause. */
|
|
4127
4252
|
function joinMediaGroup(name, el) {
|
|
4128
4253
|
let members = groups.get(name);
|
|
4129
4254
|
if (!members) groups.set(name, members = /* @__PURE__ */ new Set());
|
|
@@ -4888,48 +5013,6 @@ function useAttachedSource(ref, src, attach, onProblem, growing, start) {
|
|
|
4888
5013
|
}, []);
|
|
4889
5014
|
return React.useMemo(() => ({ reload: (at) => hold.current?.attachment.reload(at) }), []);
|
|
4890
5015
|
}
|
|
4891
|
-
var keyPlayers = (() => {
|
|
4892
|
-
const ids = /* @__PURE__ */ new Set();
|
|
4893
|
-
let active = null;
|
|
4894
|
-
let warned = false;
|
|
4895
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
4896
|
-
let snapshot = {
|
|
4897
|
-
count: 0,
|
|
4898
|
-
active: null
|
|
4899
|
-
};
|
|
4900
|
-
const emit = () => {
|
|
4901
|
-
snapshot = {
|
|
4902
|
-
count: ids.size,
|
|
4903
|
-
active
|
|
4904
|
-
};
|
|
4905
|
-
listeners.forEach((l) => l());
|
|
4906
|
-
};
|
|
4907
|
-
return {
|
|
4908
|
-
subscribe: (l) => {
|
|
4909
|
-
listeners.add(l);
|
|
4910
|
-
return () => void listeners.delete(l);
|
|
4911
|
-
},
|
|
4912
|
-
get: () => snapshot,
|
|
4913
|
-
add(id) {
|
|
4914
|
-
ids.add(id);
|
|
4915
|
-
if (ids.size === 2 && !warned && isDev()) {
|
|
4916
|
-
warned = true;
|
|
4917
|
-
console.warn("strata-react: several MediaPlayers are on this page, so Space, K, J, L and M go to the one last played or focused. Pass shortcuts={false} to one you bind your own keys for.");
|
|
4918
|
-
}
|
|
4919
|
-
emit();
|
|
4920
|
-
},
|
|
4921
|
-
remove(id) {
|
|
4922
|
-
ids.delete(id);
|
|
4923
|
-
if (active === id) active = null;
|
|
4924
|
-
emit();
|
|
4925
|
-
},
|
|
4926
|
-
use(id) {
|
|
4927
|
-
if (active === id || !ids.has(id)) return;
|
|
4928
|
-
active = id;
|
|
4929
|
-
emit();
|
|
4930
|
-
}
|
|
4931
|
-
};
|
|
4932
|
-
})();
|
|
4933
5016
|
/** Playback speeds an audiobook or lecture listener expects. */
|
|
4934
5017
|
var SPEECH_RATES = [
|
|
4935
5018
|
.75,
|
|
@@ -4961,7 +5044,7 @@ function useCoarsePointer() {
|
|
|
4961
5044
|
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
4962
5045
|
* parts and `useMediaElement` directly.
|
|
4963
5046
|
*/
|
|
4964
|
-
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, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
|
|
5047
|
+
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, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, skip = {}, fps, float = false, className }) {
|
|
4965
5048
|
const list = React.useMemo(() => sources ?? (src ? [{
|
|
4966
5049
|
src,
|
|
4967
5050
|
title: label
|
|
@@ -5077,6 +5160,21 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5077
5160
|
resume.current = media.playing;
|
|
5078
5161
|
go(to);
|
|
5079
5162
|
};
|
|
5163
|
+
const ownMarks = !cut && !offsets && list.length <= 1 && !bound ? marks ?? [] : [];
|
|
5164
|
+
const skipping = skip !== false;
|
|
5165
|
+
const skipTo = (level, direction) => skipAction(ownMarks, level, direction, time, {
|
|
5166
|
+
steps: skip || {},
|
|
5167
|
+
duration
|
|
5168
|
+
});
|
|
5169
|
+
const stepFrame = (direction) => {
|
|
5170
|
+
if (!fps) return;
|
|
5171
|
+
media.pause();
|
|
5172
|
+
const el = ref.current;
|
|
5173
|
+
const now = el && Number.isFinite(el.currentTime) ? cut ? el.currentTime - cut.start : (offsets ? offsets[index] : 0) + el.currentTime : time;
|
|
5174
|
+
const at = Math.floor(now * fps + .001);
|
|
5175
|
+
seek(Math.max(0, (at + direction + .5) / fps));
|
|
5176
|
+
};
|
|
5177
|
+
const frames = Boolean(fps) && kind === "video";
|
|
5080
5178
|
const carried = React.useRef(null);
|
|
5081
5179
|
React.useEffect(() => {
|
|
5082
5180
|
const c = carried.current;
|
|
@@ -5189,6 +5287,35 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5189
5287
|
}, [wakeControls]);
|
|
5190
5288
|
const idle = autoHide && controlsIdle;
|
|
5191
5289
|
const hideControls = full && canFull && autoHide && controlsIdle;
|
|
5290
|
+
const floatable = float && kind === "video";
|
|
5291
|
+
const box = React.useRef(null);
|
|
5292
|
+
const below = React.useRef(null);
|
|
5293
|
+
const [offTop, setOffTop] = React.useState(false);
|
|
5294
|
+
const [played, setPlayed] = React.useState(false);
|
|
5295
|
+
const [closed, setClosed] = React.useState(false);
|
|
5296
|
+
React.useEffect(() => {
|
|
5297
|
+
if (media.playing) setPlayed(true);
|
|
5298
|
+
}, [media.playing]);
|
|
5299
|
+
React.useEffect(() => {
|
|
5300
|
+
const el = below.current;
|
|
5301
|
+
if (!floatable || !el || typeof IntersectionObserver === "undefined") return;
|
|
5302
|
+
const observer = new IntersectionObserver((entries) => {
|
|
5303
|
+
const e = entries[entries.length - 1];
|
|
5304
|
+
const gone = !e.isIntersecting && e.boundingClientRect.top < (e.rootBounds?.top ?? 0);
|
|
5305
|
+
setOffTop(gone);
|
|
5306
|
+
if (!gone) setClosed(false);
|
|
5307
|
+
});
|
|
5308
|
+
observer.observe(el);
|
|
5309
|
+
return () => observer.disconnect();
|
|
5310
|
+
}, [floatable]);
|
|
5311
|
+
const wantFloat = floatable && offTop && played && !closed && !full;
|
|
5312
|
+
const [held, setHeld] = React.useState(null);
|
|
5313
|
+
React.useLayoutEffect(() => setHeld(wantFloat ? box.current?.getBoundingClientRect().height ?? 0 : null), [wantFloat]);
|
|
5314
|
+
const floating = wantFloat && held !== null;
|
|
5315
|
+
const backToPlayer = () => {
|
|
5316
|
+
below.current?.previousElementSibling?.scrollIntoView({ block: "nearest" });
|
|
5317
|
+
setOffTop(false);
|
|
5318
|
+
};
|
|
5192
5319
|
const stage = React.useRef(null);
|
|
5193
5320
|
const latest = React.useRef(media);
|
|
5194
5321
|
latest.current = media;
|
|
@@ -5227,6 +5354,17 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5227
5354
|
label: "Mute",
|
|
5228
5355
|
run: () => media.setVolume(media.muted ? 100 : 0)
|
|
5229
5356
|
},
|
|
5357
|
+
...frames ? [{
|
|
5358
|
+
keys: [","],
|
|
5359
|
+
label: "Back one frame",
|
|
5360
|
+
run: () => stepFrame(-1),
|
|
5361
|
+
repeat: true
|
|
5362
|
+
}, {
|
|
5363
|
+
keys: ["."],
|
|
5364
|
+
label: "Forward one frame",
|
|
5365
|
+
run: () => stepFrame(1),
|
|
5366
|
+
repeat: true
|
|
5367
|
+
}] : [],
|
|
5230
5368
|
...canFull ? [{
|
|
5231
5369
|
keys: ["f"],
|
|
5232
5370
|
label: full ? "Leave full screen" : "Full screen",
|
|
@@ -5244,27 +5382,11 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5244
5382
|
index,
|
|
5245
5383
|
offer,
|
|
5246
5384
|
canFull,
|
|
5247
|
-
full
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
React.useEffect(() => {
|
|
5251
|
-
if (!shortcuts || native) return;
|
|
5252
|
-
keyPlayers.add(id);
|
|
5253
|
-
return () => keyPlayers.remove(id);
|
|
5254
|
-
}, [
|
|
5255
|
-
id,
|
|
5256
|
-
shortcuts,
|
|
5257
|
-
native
|
|
5258
|
-
]);
|
|
5259
|
-
const page = React.useSyncExternalStore(keyPlayers.subscribe, keyPlayers.get, keyPlayers.get);
|
|
5260
|
-
React.useEffect(() => {
|
|
5261
|
-
if (media.playing && shortcuts && !native) keyPlayers.use(id);
|
|
5262
|
-
}, [
|
|
5263
|
-
media.playing,
|
|
5264
|
-
id,
|
|
5265
|
-
shortcuts,
|
|
5266
|
-
native
|
|
5385
|
+
full,
|
|
5386
|
+
frames,
|
|
5387
|
+
fps
|
|
5267
5388
|
]);
|
|
5389
|
+
const owner = useKeyOwner(shortcuts && !native, media.playing);
|
|
5268
5390
|
const activeKeys = autoHide ? keys.map((shortcut) => ({
|
|
5269
5391
|
...shortcut,
|
|
5270
5392
|
run: () => {
|
|
@@ -5272,7 +5394,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5272
5394
|
shortcut.run();
|
|
5273
5395
|
}
|
|
5274
5396
|
})) : keys;
|
|
5275
|
-
useHotkeys(activeKeys, { enabled: shortcuts && !native &&
|
|
5397
|
+
useHotkeys(activeKeys, { enabled: shortcuts && !native && owner.owns });
|
|
5276
5398
|
React.useEffect(() => {
|
|
5277
5399
|
if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
|
|
5278
5400
|
const s = navigator.mediaSession;
|
|
@@ -5331,6 +5453,16 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5331
5453
|
};
|
|
5332
5454
|
const hasSpans = (spans?.length ?? 0) > 0;
|
|
5333
5455
|
const showActions = hasSpans || picked;
|
|
5456
|
+
const barMarks = bound && showFull ? [{
|
|
5457
|
+
time: bound.start,
|
|
5458
|
+
label: "Window starts"
|
|
5459
|
+
}, {
|
|
5460
|
+
time: bound.end,
|
|
5461
|
+
label: "Window ends"
|
|
5462
|
+
}] : offsets ? list.map((s, i) => ({
|
|
5463
|
+
time: offsets[i],
|
|
5464
|
+
label: s.title
|
|
5465
|
+
})).slice(1) : !bound && marks || [];
|
|
5334
5466
|
const element = kind === "video" ? /* @__PURE__ */ jsxs("div", {
|
|
5335
5467
|
ref: stage,
|
|
5336
5468
|
tabIndex: -1,
|
|
@@ -5345,7 +5477,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5345
5477
|
onDoubleClick: canFull ? () => setFull((f) => !f) : void 0,
|
|
5346
5478
|
className: "absolute inset-0 size-full object-contain"
|
|
5347
5479
|
}),
|
|
5348
|
-
heading && /* @__PURE__ */ jsx(PictureHeading, {
|
|
5480
|
+
heading && !floating && /* @__PURE__ */ jsx(PictureHeading, {
|
|
5349
5481
|
heading,
|
|
5350
5482
|
shown: !idle
|
|
5351
5483
|
}),
|
|
@@ -5367,172 +5499,270 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5367
5499
|
children: /* @__PURE__ */ jsx(PlayerWarningToast, { warning }, warning.key)
|
|
5368
5500
|
});
|
|
5369
5501
|
const what = kind === "video" ? "this video" : "this recording";
|
|
5370
|
-
return /* @__PURE__ */
|
|
5502
|
+
return /* @__PURE__ */ jsxs(FullscreenFrame, {
|
|
5371
5503
|
label,
|
|
5372
5504
|
active: full,
|
|
5373
5505
|
onActiveChange: setFull,
|
|
5374
5506
|
modal: false,
|
|
5375
5507
|
className,
|
|
5376
|
-
children:
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
action: /* @__PURE__ */ jsx(Button, {
|
|
5407
|
-
size: "sm",
|
|
5408
|
-
variant: "outline",
|
|
5409
|
-
onClick: media.retry,
|
|
5410
|
-
children: "Try again"
|
|
5411
|
-
}),
|
|
5412
|
-
children: media.error.message
|
|
5413
|
-
}),
|
|
5414
|
-
media.error?.kind === "blocked" && /* @__PURE__ */ jsx("p", {
|
|
5415
|
-
role: "status",
|
|
5416
|
-
className: "type-body-sm text-muted-foreground",
|
|
5417
|
-
children: media.error.message
|
|
5418
|
-
}),
|
|
5419
|
-
(growing || bound || !native || status) && /* @__PURE__ */ jsxs("div", {
|
|
5420
|
-
className: cn("grid gap-2", hideControls && "pointer-events-none absolute inset-x-0 bottom-0 opacity-0 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:static has-[:focus-visible]:opacity-100"),
|
|
5421
|
-
children: [
|
|
5422
|
-
growing && /* @__PURE__ */ jsxs("div", {
|
|
5423
|
-
className: "flex flex-wrap items-center gap-x-3 gap-y-1",
|
|
5508
|
+
children: [
|
|
5509
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5510
|
+
ref: box,
|
|
5511
|
+
role: "group",
|
|
5512
|
+
"aria-label": label,
|
|
5513
|
+
"data-floating": floating || void 0,
|
|
5514
|
+
onFocusCapture: owner.claim,
|
|
5515
|
+
onMouseMoveCapture: autoHide ? wakeControls : void 0,
|
|
5516
|
+
onKeyDownCapture: autoHide ? wakeControls : void 0,
|
|
5517
|
+
onMouseLeave: autoHide && !full ? sleepControls : void 0,
|
|
5518
|
+
onPointerDownCapture: () => {
|
|
5519
|
+
owner.claim();
|
|
5520
|
+
if (autoHide) wakeControls();
|
|
5521
|
+
},
|
|
5522
|
+
className: cn("relative grid w-full gap-2", full && "flex h-full min-h-0 flex-col", floating && cn("fixed right-4 bottom-4 layer-bar w-80 max-w-full gap-1.5 p-2", "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay")),
|
|
5523
|
+
children: [
|
|
5524
|
+
element,
|
|
5525
|
+
floating && /* @__PURE__ */ jsxs("div", {
|
|
5526
|
+
className: "grid gap-1",
|
|
5527
|
+
children: [!native && /* @__PURE__ */ jsx(SeekBar, {
|
|
5528
|
+
time,
|
|
5529
|
+
duration,
|
|
5530
|
+
onSeek: seek,
|
|
5531
|
+
spans: spanState.bars,
|
|
5532
|
+
marks: barMarks,
|
|
5533
|
+
step: JUMP,
|
|
5534
|
+
bigStep: 60,
|
|
5535
|
+
label: `Seek in ${label}`
|
|
5536
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
5537
|
+
className: "flex items-center gap-1",
|
|
5424
5538
|
children: [
|
|
5425
|
-
/* @__PURE__ */ jsx(
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5539
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
5540
|
+
icon: media.playing ? Pause : Play,
|
|
5541
|
+
label: media.playing ? "Pause" : "Play",
|
|
5542
|
+
hint: "Space",
|
|
5543
|
+
size: "sm",
|
|
5544
|
+
onClick: media.toggle
|
|
5429
5545
|
}),
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5546
|
+
/* @__PURE__ */ jsx(TimeReadout, {
|
|
5547
|
+
time,
|
|
5548
|
+
duration,
|
|
5549
|
+
className: "type-caption"
|
|
5433
5550
|
}),
|
|
5434
|
-
/* @__PURE__ */
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5551
|
+
/* @__PURE__ */ jsxs("span", {
|
|
5552
|
+
className: "ml-auto flex items-center gap-1",
|
|
5553
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
5554
|
+
icon: ArrowUp,
|
|
5555
|
+
label: "Back to the player",
|
|
5556
|
+
size: "sm",
|
|
5557
|
+
onPress: backToPlayer
|
|
5558
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
5559
|
+
icon: X,
|
|
5560
|
+
label: "Close",
|
|
5561
|
+
size: "sm",
|
|
5562
|
+
onPress: () => setClosed(true)
|
|
5563
|
+
})]
|
|
5438
5564
|
})
|
|
5439
5565
|
]
|
|
5566
|
+
})]
|
|
5567
|
+
}),
|
|
5568
|
+
!floating && native && hasSpans && /* @__PURE__ */ jsx(SpanStrip, {
|
|
5569
|
+
spans: spanState.bars,
|
|
5570
|
+
duration,
|
|
5571
|
+
label: `Marked parts of ${label}`
|
|
5572
|
+
}),
|
|
5573
|
+
warningToast,
|
|
5574
|
+
!floating && kind === "audio" && showActions && /* @__PURE__ */ jsx(SpanActions, {
|
|
5575
|
+
state: spanState,
|
|
5576
|
+
other: resumeNotice,
|
|
5577
|
+
className: "flex flex-wrap items-center gap-2"
|
|
5578
|
+
}),
|
|
5579
|
+
kind === "audio" && overlay?.(media),
|
|
5580
|
+
media.error?.kind === "load" && /* @__PURE__ */ jsx(Alert, {
|
|
5581
|
+
tone: "danger",
|
|
5582
|
+
announce: true,
|
|
5583
|
+
title: `Could not load ${what}`,
|
|
5584
|
+
action: /* @__PURE__ */ jsx(Button, {
|
|
5585
|
+
size: "sm",
|
|
5586
|
+
variant: "outline",
|
|
5587
|
+
onClick: media.retry,
|
|
5588
|
+
children: "Try again"
|
|
5440
5589
|
}),
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
!native && /* @__PURE__ */ jsxs("div", {
|
|
5454
|
-
className: "grid gap-2",
|
|
5455
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
5456
|
-
className: "flex min-w-0 items-center gap-3",
|
|
5457
|
-
children: [/* @__PURE__ */ jsx(SeekBar, {
|
|
5458
|
-
time,
|
|
5459
|
-
duration,
|
|
5460
|
-
onSeek: seek,
|
|
5461
|
-
buffered: growing ? media.ready : offsets ? void 0 : media.buffered,
|
|
5462
|
-
spans: spanState.bars,
|
|
5463
|
-
marks: bound && showFull ? [{
|
|
5464
|
-
time: bound.start,
|
|
5465
|
-
label: "Window starts"
|
|
5466
|
-
}, {
|
|
5467
|
-
time: bound.end,
|
|
5468
|
-
label: "Window ends"
|
|
5469
|
-
}] : offsets ? list.map((s, i) => ({
|
|
5470
|
-
time: offsets[i],
|
|
5471
|
-
label: s.title
|
|
5472
|
-
})).slice(1) : !bound && marks || [],
|
|
5473
|
-
step: JUMP,
|
|
5474
|
-
bigStep: 60,
|
|
5475
|
-
label: `Seek in ${label}`
|
|
5476
|
-
}), /* @__PURE__ */ jsx(TimeReadout, {
|
|
5477
|
-
time,
|
|
5478
|
-
duration
|
|
5479
|
-
})]
|
|
5480
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
5481
|
-
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
5590
|
+
children: media.error.message
|
|
5591
|
+
}),
|
|
5592
|
+
media.error?.kind === "blocked" && /* @__PURE__ */ jsx("p", {
|
|
5593
|
+
role: "status",
|
|
5594
|
+
className: "type-body-sm text-muted-foreground",
|
|
5595
|
+
children: media.error.message
|
|
5596
|
+
}),
|
|
5597
|
+
!floating && (growing || bound || !native || status) && /* @__PURE__ */ jsxs("div", {
|
|
5598
|
+
className: cn("grid gap-2", hideControls && "pointer-events-none absolute inset-x-0 bottom-0 opacity-0 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:static has-[:focus-visible]:opacity-100"),
|
|
5599
|
+
children: [
|
|
5600
|
+
growing && /* @__PURE__ */ jsxs("div", {
|
|
5601
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-1",
|
|
5482
5602
|
children: [
|
|
5483
|
-
/* @__PURE__ */
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
children:
|
|
5487
|
-
icon: SkipBack,
|
|
5488
|
-
label: "Previous chapter",
|
|
5489
|
-
disabled: index === 0,
|
|
5490
|
-
onClick: () => step(-1)
|
|
5491
|
-
}), list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
|
|
5492
|
-
icon: SkipForward,
|
|
5493
|
-
label: "Next chapter",
|
|
5494
|
-
disabled: index === list.length - 1,
|
|
5495
|
-
onClick: () => step(1)
|
|
5496
|
-
})]
|
|
5603
|
+
/* @__PURE__ */ jsx(Status, {
|
|
5604
|
+
tone: "info",
|
|
5605
|
+
icon: LoaderCircle,
|
|
5606
|
+
children: "Still being made"
|
|
5497
5607
|
}),
|
|
5498
|
-
|
|
5608
|
+
growing.status && /* @__PURE__ */ jsx("span", {
|
|
5499
5609
|
className: "type-body-sm text-muted-foreground",
|
|
5500
|
-
children:
|
|
5501
|
-
current?.title,
|
|
5502
|
-
" (",
|
|
5503
|
-
index + 1,
|
|
5504
|
-
" of ",
|
|
5505
|
-
list.length,
|
|
5506
|
-
")"
|
|
5507
|
-
]
|
|
5610
|
+
children: growing.status
|
|
5508
5611
|
}),
|
|
5509
|
-
/* @__PURE__ */
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
rate: media.rate,
|
|
5514
|
-
onRateChange: media.setRate,
|
|
5515
|
-
rates
|
|
5516
|
-
}),
|
|
5517
|
-
/* @__PURE__ */ jsx(VolumeControl, {
|
|
5518
|
-
volume: media.volume,
|
|
5519
|
-
onVolumeChange: media.setVolume
|
|
5520
|
-
}),
|
|
5521
|
-
canFull && /* @__PURE__ */ jsx(IconButton, {
|
|
5522
|
-
icon: full ? Minimize : Maximize,
|
|
5523
|
-
label: full ? "Leave full screen" : "Full screen",
|
|
5524
|
-
onPress: () => setFull(!full)
|
|
5525
|
-
})
|
|
5526
|
-
]
|
|
5612
|
+
/* @__PURE__ */ jsx("span", {
|
|
5613
|
+
role: "status",
|
|
5614
|
+
className: "type-body-sm text-muted-foreground",
|
|
5615
|
+
children: media.waitingForMore ? "Waiting for more to be made. It will carry on by itself." : ""
|
|
5527
5616
|
})
|
|
5528
5617
|
]
|
|
5529
|
-
})
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5618
|
+
}),
|
|
5619
|
+
bound && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
|
|
5620
|
+
className: "type-caption text-muted-foreground tabular-nums",
|
|
5621
|
+
children: [
|
|
5622
|
+
format.runningTime(bound.start),
|
|
5623
|
+
" to ",
|
|
5624
|
+
format.runningTime(bound.end),
|
|
5625
|
+
loop ? ", looping" : ""
|
|
5626
|
+
]
|
|
5627
|
+
}), /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("span", {
|
|
5628
|
+
role: "status",
|
|
5629
|
+
children: media.playing ? `Playing ${format.runningTime(bound.start)} to ${format.runningTime(bound.end)}` : ""
|
|
5630
|
+
}) })] }),
|
|
5631
|
+
!native && /* @__PURE__ */ jsxs("div", {
|
|
5632
|
+
className: "grid gap-2",
|
|
5633
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
5634
|
+
className: "flex min-w-0 items-center gap-3",
|
|
5635
|
+
children: [/* @__PURE__ */ jsx(SeekBar, {
|
|
5636
|
+
time,
|
|
5637
|
+
duration,
|
|
5638
|
+
onSeek: seek,
|
|
5639
|
+
buffered: growing ? media.ready : offsets ? void 0 : media.buffered,
|
|
5640
|
+
spans: spanState.bars,
|
|
5641
|
+
marks: barMarks,
|
|
5642
|
+
step: JUMP,
|
|
5643
|
+
bigStep: 60,
|
|
5644
|
+
label: `Seek in ${label}`
|
|
5645
|
+
}), /* @__PURE__ */ jsx(TimeReadout, {
|
|
5646
|
+
time,
|
|
5647
|
+
duration
|
|
5648
|
+
})]
|
|
5649
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
5650
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
5651
|
+
children: [
|
|
5652
|
+
/* @__PURE__ */ jsxs(Toolbar, {
|
|
5653
|
+
label: "Playback",
|
|
5654
|
+
className: "gap-2",
|
|
5655
|
+
children: [
|
|
5656
|
+
list.length > 1 ? /* @__PURE__ */ jsx(IconButton, {
|
|
5657
|
+
icon: SkipBack,
|
|
5658
|
+
label: "Previous chapter",
|
|
5659
|
+
disabled: index === 0,
|
|
5660
|
+
onClick: () => step(-1)
|
|
5661
|
+
}) : skipping && /* @__PURE__ */ jsx(SkipButton, {
|
|
5662
|
+
action: skipTo("large", -1),
|
|
5663
|
+
icon: SkipBack,
|
|
5664
|
+
seek
|
|
5665
|
+
}),
|
|
5666
|
+
skipping && /* @__PURE__ */ jsx(SkipButton, {
|
|
5667
|
+
action: skipTo("small", -1),
|
|
5668
|
+
icon: Rewind,
|
|
5669
|
+
seek
|
|
5670
|
+
}),
|
|
5671
|
+
frames && /* @__PURE__ */ jsx(IconButton, {
|
|
5672
|
+
icon: StepBack,
|
|
5673
|
+
label: "Back one frame",
|
|
5674
|
+
hint: ",",
|
|
5675
|
+
onClick: () => stepFrame(-1)
|
|
5676
|
+
}),
|
|
5677
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
5678
|
+
icon: media.playing ? Pause : Play,
|
|
5679
|
+
label: media.playing ? "Pause" : "Play",
|
|
5680
|
+
hint: "Space",
|
|
5681
|
+
variant: "outline",
|
|
5682
|
+
onClick: media.toggle
|
|
5683
|
+
}),
|
|
5684
|
+
frames && /* @__PURE__ */ jsx(IconButton, {
|
|
5685
|
+
icon: StepForward,
|
|
5686
|
+
label: "Forward one frame",
|
|
5687
|
+
hint: ".",
|
|
5688
|
+
onClick: () => stepFrame(1)
|
|
5689
|
+
}),
|
|
5690
|
+
skipping && /* @__PURE__ */ jsx(SkipButton, {
|
|
5691
|
+
action: skipTo("small", 1),
|
|
5692
|
+
icon: FastForward,
|
|
5693
|
+
seek
|
|
5694
|
+
}),
|
|
5695
|
+
list.length > 1 ? /* @__PURE__ */ jsx(IconButton, {
|
|
5696
|
+
icon: SkipForward,
|
|
5697
|
+
label: "Next chapter",
|
|
5698
|
+
disabled: index === list.length - 1,
|
|
5699
|
+
onClick: () => step(1)
|
|
5700
|
+
}) : skipping && /* @__PURE__ */ jsx(SkipButton, {
|
|
5701
|
+
action: skipTo("large", 1),
|
|
5702
|
+
icon: SkipForward,
|
|
5703
|
+
seek
|
|
5704
|
+
})
|
|
5705
|
+
]
|
|
5706
|
+
}),
|
|
5707
|
+
list.length > 1 && /* @__PURE__ */ jsxs("span", {
|
|
5708
|
+
className: "type-body-sm text-muted-foreground",
|
|
5709
|
+
children: [
|
|
5710
|
+
current?.title,
|
|
5711
|
+
" (",
|
|
5712
|
+
index + 1,
|
|
5713
|
+
" of ",
|
|
5714
|
+
list.length,
|
|
5715
|
+
")"
|
|
5716
|
+
]
|
|
5717
|
+
}),
|
|
5718
|
+
/* @__PURE__ */ jsxs("span", {
|
|
5719
|
+
className: "ml-auto flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-2",
|
|
5720
|
+
children: [
|
|
5721
|
+
/* @__PURE__ */ jsx(RateChoice, {
|
|
5722
|
+
rate: media.rate,
|
|
5723
|
+
onRateChange: media.setRate,
|
|
5724
|
+
rates
|
|
5725
|
+
}),
|
|
5726
|
+
/* @__PURE__ */ jsx(VolumeControl, {
|
|
5727
|
+
volume: media.volume,
|
|
5728
|
+
onVolumeChange: media.setVolume
|
|
5729
|
+
}),
|
|
5730
|
+
canFull && /* @__PURE__ */ jsx(IconButton, {
|
|
5731
|
+
icon: full ? Minimize : Maximize,
|
|
5732
|
+
label: full ? "Leave full screen" : "Full screen",
|
|
5733
|
+
onPress: () => setFull(!full)
|
|
5734
|
+
})
|
|
5735
|
+
]
|
|
5736
|
+
})
|
|
5737
|
+
]
|
|
5738
|
+
})]
|
|
5739
|
+
}),
|
|
5740
|
+
status
|
|
5741
|
+
]
|
|
5742
|
+
})
|
|
5743
|
+
]
|
|
5744
|
+
}),
|
|
5745
|
+
floating && /* @__PURE__ */ jsx("div", {
|
|
5746
|
+
"aria-hidden": true,
|
|
5747
|
+
"data-player-place": "",
|
|
5748
|
+
style: { height: held ?? 0 }
|
|
5749
|
+
}),
|
|
5750
|
+
floatable && /* @__PURE__ */ jsx("span", {
|
|
5751
|
+
ref: below,
|
|
5752
|
+
"aria-hidden": true,
|
|
5753
|
+
"data-player-end": "",
|
|
5754
|
+
className: "block"
|
|
5755
|
+
})
|
|
5756
|
+
]
|
|
5757
|
+
});
|
|
5758
|
+
}
|
|
5759
|
+
/** One skip button: named for where it goes ("Next scene", "Back 10 s"), and not pressable when there is nowhere to go. */
|
|
5760
|
+
function SkipButton({ action, icon, seek }) {
|
|
5761
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
5762
|
+
icon,
|
|
5763
|
+
label: action.label,
|
|
5764
|
+
disabled: action.to === null,
|
|
5765
|
+
onClick: () => action.to !== null && seek(action.to)
|
|
5536
5766
|
});
|
|
5537
5767
|
}
|
|
5538
5768
|
function PictureHeading({ heading, shown }) {
|
|
@@ -6640,7 +6870,7 @@ async function defaultDecode(data) {
|
|
|
6640
6870
|
ctx.close?.();
|
|
6641
6871
|
}
|
|
6642
6872
|
}
|
|
6643
|
-
var clamp$
|
|
6873
|
+
var clamp$3 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
6644
6874
|
var clock = (t) => format.runningTime(t);
|
|
6645
6875
|
/** An audio waveform with marks, spans and a playhead: one slider you click, drag or key to seek, zoom, and a range to select. */
|
|
6646
6876
|
function Waveform({ label, peaks, source, duration: given, time, onSeek, marks = [], spans = [], underlay, range: controlledRange, onRangeChange, step = 5, bigStep = 30, defaultView, buckets = 2e3, normalise = false, decode = defaultDecode, words = WORDS, disabled, className }) {
|
|
@@ -6689,7 +6919,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6689
6919
|
const span = Math.max(v1 - v0, 1e-6);
|
|
6690
6920
|
const zoomBy = (factor, about) => {
|
|
6691
6921
|
const centre = about ?? (time >= v0 && time <= v1 ? time : (v0 + v1) / 2);
|
|
6692
|
-
const next = clamp$
|
|
6922
|
+
const next = clamp$3(span * factor, Math.min(duration, .5), duration);
|
|
6693
6923
|
const from = centre - (centre - v0) / span * next;
|
|
6694
6924
|
setView(next >= duration - 1e-6 ? null : clampView(from, next, duration));
|
|
6695
6925
|
};
|
|
@@ -6764,8 +6994,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6764
6994
|
minValue: v0,
|
|
6765
6995
|
maxValue: Math.max(v1, v0 + .01),
|
|
6766
6996
|
step: .01,
|
|
6767
|
-
value: [clamp$
|
|
6768
|
-
onChange: ([t]) => onSeek(clamp$
|
|
6997
|
+
value: [clamp$3(time, v0, Math.max(v1, v0 + .01))],
|
|
6998
|
+
onChange: ([t]) => onSeek(clamp$3(t, 0, duration)),
|
|
6769
6999
|
numberFormatter: timeText,
|
|
6770
7000
|
isDisabled: off
|
|
6771
7001
|
});
|
|
@@ -6781,7 +7011,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6781
7011
|
isDisabled: off
|
|
6782
7012
|
}, state);
|
|
6783
7013
|
const { focusProps, isFocusVisible } = useFocusRing();
|
|
6784
|
-
const seekTo = (t) => onSeek(clamp$
|
|
7014
|
+
const seekTo = (t) => onSeek(clamp$3(t, 0, duration));
|
|
6785
7015
|
const onKeyDownCapture = (e) => {
|
|
6786
7016
|
if (off) return;
|
|
6787
7017
|
const big = e.shiftKey ? bigStep : step;
|
|
@@ -6854,8 +7084,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6854
7084
|
for (let x = 0; x < width; x += column) {
|
|
6855
7085
|
const [lo, hi] = peaksBetween(pair, (v0 + x / width * (v1 - v0)) / duration, (v0 + (x + column) / width * (v1 - v0)) / duration);
|
|
6856
7086
|
if (!Number.isFinite(lo)) continue;
|
|
6857
|
-
const top = 50 - clamp$
|
|
6858
|
-
const bottom = 50 - clamp$
|
|
7087
|
+
const top = 50 - clamp$3(hi * gain, -1, 1) * 48;
|
|
7088
|
+
const bottom = 50 - clamp$3(lo * gain, -1, 1) * 48;
|
|
6859
7089
|
d += `M${x + .5} ${top.toFixed(1)}V${Math.max(bottom, top + 1).toFixed(1)}`;
|
|
6860
7090
|
}
|
|
6861
7091
|
return d;
|
|
@@ -6929,8 +7159,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6929
7159
|
})
|
|
6930
7160
|
}) }),
|
|
6931
7161
|
spans.map((s) => {
|
|
6932
|
-
const a = clamp$
|
|
6933
|
-
const b = clamp$
|
|
7162
|
+
const a = clamp$3(px(s.from), 0, width);
|
|
7163
|
+
const b = clamp$3(px(s.to), 0, width);
|
|
6934
7164
|
const tone = TONE$1[s.tone ?? "neutral"];
|
|
6935
7165
|
return b > a ? /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
|
|
6936
7166
|
x: a,
|
|
@@ -6948,9 +7178,9 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
6948
7178
|
})] }, `${s.from}-${s.to}-${s.label}`) : null;
|
|
6949
7179
|
}),
|
|
6950
7180
|
shown && /* @__PURE__ */ jsx("rect", {
|
|
6951
|
-
x: clamp$
|
|
7181
|
+
x: clamp$3(px(shown[0]), 0, width),
|
|
6952
7182
|
y: 0,
|
|
6953
|
-
width: Math.max(clamp$
|
|
7183
|
+
width: Math.max(clamp$3(px(shown[1]), 0, width) - clamp$3(px(shown[0]), 0, width), 1),
|
|
6954
7184
|
height: 100,
|
|
6955
7185
|
fill: "var(--primary-5)",
|
|
6956
7186
|
opacity: .45
|
|
@@ -7024,7 +7254,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
7024
7254
|
children: /* @__PURE__ */ jsx("div", {
|
|
7025
7255
|
...thumbProps,
|
|
7026
7256
|
className: "absolute inset-y-0 w-0",
|
|
7027
|
-
style: { left: `${clamp$
|
|
7257
|
+
style: { left: `${clamp$3((time - v0) / span, 0, 1) * 100}%` },
|
|
7028
7258
|
children: /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", {
|
|
7029
7259
|
ref: input,
|
|
7030
7260
|
...mergeProps(inputProps, focusProps, { "aria-describedby": summaryId }),
|
|
@@ -7087,6 +7317,174 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
|
|
|
7087
7317
|
]
|
|
7088
7318
|
});
|
|
7089
7319
|
}
|
|
7320
|
+
// src/components/use-timeline.ts
|
|
7321
|
+
var clamp$2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
7322
|
+
/** A playhead the app owns, in the shape `Transport`, `SeekBar` and `transportShortcuts` take. */
|
|
7323
|
+
function useTimeline({ duration, rate = 1, frame = 1 / 30, loop = false, startAt = "start", group, keys = true }) {
|
|
7324
|
+
const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
|
|
7325
|
+
const [at, setAt] = React.useState(null);
|
|
7326
|
+
const [playing, setPlaying] = React.useState(false);
|
|
7327
|
+
const time = clamp$2(at ?? (startAt === "end" ? length : 0), 0, length);
|
|
7328
|
+
const live = React.useRef({
|
|
7329
|
+
time,
|
|
7330
|
+
length,
|
|
7331
|
+
rate,
|
|
7332
|
+
loop
|
|
7333
|
+
});
|
|
7334
|
+
live.current = {
|
|
7335
|
+
time,
|
|
7336
|
+
length,
|
|
7337
|
+
rate,
|
|
7338
|
+
loop
|
|
7339
|
+
};
|
|
7340
|
+
const member = React.useRef(null);
|
|
7341
|
+
if (!member.current) {
|
|
7342
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7343
|
+
member.current = {
|
|
7344
|
+
paused: true,
|
|
7345
|
+
pause: () => {},
|
|
7346
|
+
addEventListener: (_, l) => void listeners.add(l),
|
|
7347
|
+
removeEventListener: (_, l) => void listeners.delete(l),
|
|
7348
|
+
start: () => listeners.forEach((l) => l())
|
|
7349
|
+
};
|
|
7350
|
+
}
|
|
7351
|
+
const contextGroup = useMediaGroupName();
|
|
7352
|
+
const name = group ?? contextGroup;
|
|
7353
|
+
React.useEffect(() => name && member.current ? joinMediaGroup(name, member.current) : void 0, [name]);
|
|
7354
|
+
const pause = React.useCallback(() => setPlaying(false), []);
|
|
7355
|
+
if (member.current) {
|
|
7356
|
+
member.current.paused = !playing;
|
|
7357
|
+
member.current.pause = pause;
|
|
7358
|
+
}
|
|
7359
|
+
const play = React.useCallback(() => {
|
|
7360
|
+
const { time: t, length: n, loop: again } = live.current;
|
|
7361
|
+
if (n === 0) return;
|
|
7362
|
+
if (t >= n && !again) setAt(0);
|
|
7363
|
+
else setAt(t);
|
|
7364
|
+
setPlaying(true);
|
|
7365
|
+
member.current?.start();
|
|
7366
|
+
}, []);
|
|
7367
|
+
const seek = React.useCallback((to) => {
|
|
7368
|
+
setAt(clamp$2(to, 0, live.current.length));
|
|
7369
|
+
setPlaying(false);
|
|
7370
|
+
}, []);
|
|
7371
|
+
const toggle = React.useCallback(() => playing ? pause() : play(), [
|
|
7372
|
+
playing,
|
|
7373
|
+
pause,
|
|
7374
|
+
play
|
|
7375
|
+
]);
|
|
7376
|
+
React.useEffect(() => {
|
|
7377
|
+
if (!playing) return;
|
|
7378
|
+
let last = performance.now();
|
|
7379
|
+
let id = requestAnimationFrame(function tick() {
|
|
7380
|
+
const now = performance.now();
|
|
7381
|
+
const { time: t, length: n, rate: r, loop: again } = live.current;
|
|
7382
|
+
let next = t + (now - last) / 1e3 * r;
|
|
7383
|
+
last = now;
|
|
7384
|
+
if (next >= n) {
|
|
7385
|
+
if (again) next = n > 0 ? next % n : 0;
|
|
7386
|
+
else {
|
|
7387
|
+
setAt(n);
|
|
7388
|
+
setPlaying(false);
|
|
7389
|
+
return;
|
|
7390
|
+
}
|
|
7391
|
+
}
|
|
7392
|
+
live.current = {
|
|
7393
|
+
...live.current,
|
|
7394
|
+
time: next
|
|
7395
|
+
};
|
|
7396
|
+
setAt(next);
|
|
7397
|
+
id = requestAnimationFrame(tick);
|
|
7398
|
+
});
|
|
7399
|
+
return () => cancelAnimationFrame(id);
|
|
7400
|
+
}, [playing]);
|
|
7401
|
+
const owner = useKeyOwner(keys, playing);
|
|
7402
|
+
const regionProps = React.useMemo(() => ({
|
|
7403
|
+
onFocusCapture: owner.claim,
|
|
7404
|
+
onPointerDownCapture: owner.claim
|
|
7405
|
+
}), [owner.claim]);
|
|
7406
|
+
return {
|
|
7407
|
+
time,
|
|
7408
|
+
duration: length,
|
|
7409
|
+
playing,
|
|
7410
|
+
ended: !playing && length > 0 && time >= length && !loop,
|
|
7411
|
+
rate,
|
|
7412
|
+
frame,
|
|
7413
|
+
play,
|
|
7414
|
+
pause,
|
|
7415
|
+
toggle,
|
|
7416
|
+
seek,
|
|
7417
|
+
step: (count) => seek(live.current.time + count * frame),
|
|
7418
|
+
ownsKeys: owner.owns,
|
|
7419
|
+
regionProps
|
|
7420
|
+
};
|
|
7421
|
+
}
|
|
7422
|
+
// src/components/timeline-player.tsx
|
|
7423
|
+
/** 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. */
|
|
7424
|
+
function TimelinePlayer({ clock, label, stage, rates, onRateChange, legend = false, className }) {
|
|
7425
|
+
const bar = React.useRef(null);
|
|
7426
|
+
const fps = Math.max(1, Math.round(1 / clock.frame));
|
|
7427
|
+
const shortcuts = transportShortcuts({
|
|
7428
|
+
toggle: clock.toggle,
|
|
7429
|
+
seek: clock.seek,
|
|
7430
|
+
time: clock.time,
|
|
7431
|
+
duration: clock.duration,
|
|
7432
|
+
frame: clock.frame,
|
|
7433
|
+
stageKeys: true
|
|
7434
|
+
});
|
|
7435
|
+
const { live } = useHotkeys(shortcuts, {
|
|
7436
|
+
enabled: clock.ownsKeys,
|
|
7437
|
+
within: bar
|
|
7438
|
+
});
|
|
7439
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
7440
|
+
role: "group",
|
|
7441
|
+
"aria-label": label,
|
|
7442
|
+
...clock.regionProps,
|
|
7443
|
+
className: cn("grid min-w-0 gap-2", className),
|
|
7444
|
+
children: [
|
|
7445
|
+
/* @__PURE__ */ jsx("div", {
|
|
7446
|
+
className: "min-w-0",
|
|
7447
|
+
children: stage
|
|
7448
|
+
}),
|
|
7449
|
+
/* @__PURE__ */ jsxs("div", {
|
|
7450
|
+
ref: bar,
|
|
7451
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",
|
|
7452
|
+
children: [
|
|
7453
|
+
/* @__PURE__ */ jsx(Transport, {
|
|
7454
|
+
playing: clock.playing,
|
|
7455
|
+
onPlayPause: clock.toggle,
|
|
7456
|
+
onToStart: () => clock.seek(0),
|
|
7457
|
+
onToEnd: () => clock.seek(clock.duration),
|
|
7458
|
+
onStepBack: () => clock.step(-1),
|
|
7459
|
+
onStepForward: () => clock.step(1),
|
|
7460
|
+
className: "shrink-0"
|
|
7461
|
+
}),
|
|
7462
|
+
/* @__PURE__ */ jsx(SeekBar, {
|
|
7463
|
+
time: clock.time,
|
|
7464
|
+
duration: clock.duration,
|
|
7465
|
+
onSeek: clock.seek,
|
|
7466
|
+
label: `Seek ${label}`,
|
|
7467
|
+
precision: "frames",
|
|
7468
|
+
fps,
|
|
7469
|
+
step: Math.max(clock.frame, clock.duration / 50)
|
|
7470
|
+
}),
|
|
7471
|
+
/* @__PURE__ */ jsx(TimeReadout, {
|
|
7472
|
+
time: clock.time,
|
|
7473
|
+
duration: clock.duration,
|
|
7474
|
+
precision: "frames",
|
|
7475
|
+
fps
|
|
7476
|
+
}),
|
|
7477
|
+
rates && onRateChange && /* @__PURE__ */ jsx(RateChoice, {
|
|
7478
|
+
rate: clock.rate,
|
|
7479
|
+
onRateChange,
|
|
7480
|
+
rates
|
|
7481
|
+
})
|
|
7482
|
+
]
|
|
7483
|
+
}),
|
|
7484
|
+
legend && /* @__PURE__ */ jsx(KeysLegend, { shortcuts: live })
|
|
7485
|
+
]
|
|
7486
|
+
});
|
|
7487
|
+
}
|
|
7090
7488
|
// src/lib/timeline.ts
|
|
7091
7489
|
/** Steps a person would write on a scale, in seconds: 1, 2, 5 and 10 × 10ⁿ below a minute, then 15 s, 30 s, minutes, quarter hours, hours, days. ux-research components.md §3.8: ticks land on values people would write. */
|
|
7092
7490
|
var STEPS = [
|
|
@@ -9245,6 +9643,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
|
|
|
9245
9643
|
value: state,
|
|
9246
9644
|
children: /* @__PURE__ */ jsx("aside", {
|
|
9247
9645
|
ref: root,
|
|
9646
|
+
"data-part": "inspector",
|
|
9248
9647
|
tabIndex: -1,
|
|
9249
9648
|
"aria-labelledby": title === null ? void 0 : headingId,
|
|
9250
9649
|
"aria-label": title === null ? "Properties" : void 0,
|
|
@@ -9253,6 +9652,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
|
|
|
9253
9652
|
className: "grid grid-cols-1 gap-4",
|
|
9254
9653
|
children: [
|
|
9255
9654
|
/* @__PURE__ */ jsxs("header", {
|
|
9655
|
+
"data-part": "inspector-header",
|
|
9256
9656
|
className: "flex items-start gap-3",
|
|
9257
9657
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
9258
9658
|
className: "min-w-0 flex-1",
|
|
@@ -9290,6 +9690,7 @@ function InspectorSection({ id, title, defaultOpen = true, actions, children, cl
|
|
|
9290
9690
|
const expanded = inspector ? inspector.isOpen(id, defaultOpen) : own;
|
|
9291
9691
|
const onChange = (open) => inspector ? inspector.setOpen(id, open) : setOwn(open);
|
|
9292
9692
|
return /* @__PURE__ */ jsx(Disclosure$1, {
|
|
9693
|
+
"data-part": "inspector-section",
|
|
9293
9694
|
isExpanded: expanded,
|
|
9294
9695
|
onExpandedChange: onChange,
|
|
9295
9696
|
className: cn("min-w-0 border-t border-border first:border-t-0", className),
|
|
@@ -16501,6 +16902,7 @@ function Workspace({ label, state, narrowBelow = 720, onFiles, acceptLabel, clas
|
|
|
16501
16902
|
/** The bar across the top of a `Workspace`: the tool's name as the heading, a polite status line, the few actions, then an end slot for the scheme and palette choice. Wraps on a phone. */
|
|
16502
16903
|
function WorkspaceBar({ title, status, actions, end, className }) {
|
|
16503
16904
|
return /* @__PURE__ */ jsxs("header", {
|
|
16905
|
+
"data-part": "workspace-bar",
|
|
16504
16906
|
className: cn("flex min-h-(--control-h) shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-3 py-1", className),
|
|
16505
16907
|
children: [
|
|
16506
16908
|
/* @__PURE__ */ jsx("h1", {
|
|
@@ -16558,6 +16960,7 @@ function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollap
|
|
|
16558
16960
|
id: `pane-${id}`,
|
|
16559
16961
|
"aria-labelledby": headingId,
|
|
16560
16962
|
"data-pane": id,
|
|
16963
|
+
"data-part": "pane",
|
|
16561
16964
|
"data-collapsed": folded || void 0,
|
|
16562
16965
|
"data-grow": grow || void 0,
|
|
16563
16966
|
"data-min": grow ? least : void 0,
|
|
@@ -16565,10 +16968,12 @@ function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollap
|
|
|
16565
16968
|
style,
|
|
16566
16969
|
className: cn("flex min-h-0 min-w-0 flex-col overflow-hidden bg-background", rail && cn("w-(--control-h) items-center", edge === "end" ? "border-l border-border" : "border-r border-border"), className),
|
|
16567
16970
|
children: [/* @__PURE__ */ jsxs("header", {
|
|
16971
|
+
"data-part": "pane-header",
|
|
16568
16972
|
className: cn("flex shrink-0 items-center gap-1 pl-3 pr-1", rail ? "h-auto flex-col py-1 pl-1" : "h-(--control-h) border-b border-border"),
|
|
16569
16973
|
children: [
|
|
16570
16974
|
/* @__PURE__ */ jsx("h2", {
|
|
16571
16975
|
id: headingId,
|
|
16976
|
+
"data-part": "pane-title",
|
|
16572
16977
|
className: cn("type-label min-w-0 flex-1 truncate", rail && "sr-only"),
|
|
16573
16978
|
children: name
|
|
16574
16979
|
}),
|
|
@@ -19751,6 +20156,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
19751
20156
|
]
|
|
19752
20157
|
});
|
|
19753
20158
|
}
|
|
19754
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
20159
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, skipAction, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
19755
20160
|
|
|
19756
20161
|
//# sourceMappingURL=index.js.map
|