strata-react 1.0.18 → 1.0.20
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 +5 -0
- package/UPGRADING.md +4 -0
- package/dist/components/key-glyphs.d.ts +5 -0
- package/dist/components/media-player.d.ts +90 -0
- package/dist/components/media.d.ts +3 -2
- package/dist/geo-C0jcFp4q.js +318 -0
- package/dist/geo-C0jcFp4q.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +497 -203
- package/dist/index.js.map +1 -1
- package/dist/lib/format.d.ts +12 -0
- package/dist/lib/geo.d.ts +44 -0
- package/dist/map/index.d.ts +1 -0
- package/dist/map/map-styles.d.ts +2 -0
- package/dist/map/route-map.d.ts +72 -0
- package/dist/map.js +400 -0
- package/dist/map.js.map +1 -0
- package/dist/query-CP78goXj.js +165 -0
- package/dist/query-CP78goXj.js.map +1 -0
- package/dist/{run-Yrgm5xIq.js → run-CKlcLpdN.js} +13 -2
- package/dist/run-CKlcLpdN.js.map +1 -0
- package/dist/strata.css +9 -0
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/{query-CIh1Dpgn.js → theme-BgTOESmN.js} +55 -164
- package/dist/theme-BgTOESmN.js.map +1 -0
- package/dist/visual/drop.d.ts +19 -0
- package/dist/visual/index.d.ts +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +68 -1
- package/dist/visual.js.map +1 -0
- package/package.json +13 -1
- package/dist/query-CIh1Dpgn.js.map +0 -1
- package/dist/run-Yrgm5xIq.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,201 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as cn, a as useColorScheme, c as ChoiceGroup, d as NativeSelect, f as Textarea, g as KeyText, h as Tooltip, i as colorSchemeScript, l as Field, m as controlHeight, n as ColorSchemeChoice, o as useSystemColorScheme, p as useFieldControl, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY, u as Input, v as typeSteps } from "./theme-BgTOESmN.js";
|
|
2
|
+
import { a as format, i as createFormat, n as MISSING, o as toDate, r as NBSP, t as geo } from "./geo-C0jcFp4q.js";
|
|
3
|
+
import { a as toLoad, c as describeActionError, d as readErrorBody, i as staleOf, l as describeHttpError, n as createQueryClient, o as useLoad, r as fetchJson, s as HttpError, t as StrataQueryProvider, u as fieldErrorsOf } from "./query-CP78goXj.js";
|
|
2
4
|
import * as React from "react";
|
|
3
5
|
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, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
4
6
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronRight, CircleAlert, CircleCheck, FileQuestion, GripVertical, History, ImageOff, Info, Loader, LoaderCircle, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Play, Redo2, RotateCcw, Scan, Search, SkipBack, SkipForward, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
import { Link, NavLink, useSearchParams } from "react-router";
|
|
8
10
|
import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
|
|
9
11
|
import { VisuallyHidden, mergeProps, useDrop, useFocusRing, useMove, useSlider, useSliderThumb } from "react-aria";
|
|
10
12
|
import { Size, useSliderState } from "react-stately";
|
|
11
13
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
12
14
|
import pixelmatch from "pixelmatch";
|
|
13
|
-
// src/lib/format.ts
|
|
14
|
-
var NBSP = "\xA0";
|
|
15
|
-
/** The placeholder printed for a value that is not known: an en dash. */
|
|
16
|
-
var MISSING = "–";
|
|
17
|
-
var BYTE_UNITS = [
|
|
18
|
-
"B",
|
|
19
|
-
"kB",
|
|
20
|
-
"MB",
|
|
21
|
-
"GB",
|
|
22
|
-
"TB",
|
|
23
|
-
"PB"
|
|
24
|
-
];
|
|
25
|
-
var BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1e3 ** i]));
|
|
26
|
-
/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */
|
|
27
|
-
function toDate(value) {
|
|
28
|
-
const date = value instanceof Date ? value : new Date(value);
|
|
29
|
-
if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);
|
|
30
|
-
return date;
|
|
31
|
-
}
|
|
32
|
-
function callableDate(df, missing) {
|
|
33
|
-
const format = (value) => value == null ? missing : df.format(toDate(value));
|
|
34
|
-
return Object.assign(format, {
|
|
35
|
-
format,
|
|
36
|
-
formatToParts: (value) => df.formatToParts(toDate(value)),
|
|
37
|
-
formatRange: (start, end) => df.formatRange(toDate(start), toDate(end)),
|
|
38
|
-
resolvedOptions: () => df.resolvedOptions()
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function callable(nf, missing) {
|
|
42
|
-
const format = (value) => value == null ? missing : nf.format(value);
|
|
43
|
-
return Object.assign(format, {
|
|
44
|
-
format,
|
|
45
|
-
formatToParts: (value) => nf.formatToParts(value),
|
|
46
|
-
resolvedOptions: () => nf.resolvedOptions()
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
var DAY = 864e5;
|
|
50
|
-
var AGO_STEPS = [
|
|
51
|
-
["year", 365 * DAY],
|
|
52
|
-
["month", 30 * DAY],
|
|
53
|
-
["week", 7 * DAY],
|
|
54
|
-
["day", DAY],
|
|
55
|
-
["hour", 36e5],
|
|
56
|
-
["minute", 6e4]
|
|
57
|
-
];
|
|
58
|
-
/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */
|
|
59
|
-
function createFormat(locale, options = {}) {
|
|
60
|
-
const { timeZone, missing = "–" } = options;
|
|
61
|
-
const dates = (opts) => callableDate(new Intl.DateTimeFormat(locale, {
|
|
62
|
-
...opts,
|
|
63
|
-
timeZone
|
|
64
|
-
}), missing);
|
|
65
|
-
const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }), missing);
|
|
66
|
-
const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }), missing);
|
|
67
|
-
const percent = callable(new Intl.NumberFormat(locale, {
|
|
68
|
-
style: "percent",
|
|
69
|
-
maximumFractionDigits: 0
|
|
70
|
-
}), missing);
|
|
71
|
-
const compact = callable(new Intl.NumberFormat(locale, {
|
|
72
|
-
notation: "compact",
|
|
73
|
-
maximumFractionDigits: 1
|
|
74
|
-
}), missing);
|
|
75
|
-
const relative = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
76
|
-
const plurals = new Intl.PluralRules(locale);
|
|
77
|
-
const clock = dates({
|
|
78
|
-
hour: "2-digit",
|
|
79
|
-
minute: "2-digit"
|
|
80
|
-
});
|
|
81
|
-
const day = dates({
|
|
82
|
-
weekday: "long",
|
|
83
|
-
day: "numeric",
|
|
84
|
-
month: "long"
|
|
85
|
-
});
|
|
86
|
-
const shortDay = dates({
|
|
87
|
-
weekday: "short",
|
|
88
|
-
hour: "2-digit",
|
|
89
|
-
minute: "2-digit"
|
|
90
|
-
});
|
|
91
|
-
const date = dates({ dateStyle: "medium" });
|
|
92
|
-
const dateTime = dates({
|
|
93
|
-
dateStyle: "medium",
|
|
94
|
-
timeStyle: "short"
|
|
95
|
-
});
|
|
96
|
-
const withUnit = (value, unit, fmt = integer) => `${fmt.format(value)} ${unit}`;
|
|
97
|
-
return {
|
|
98
|
-
locale,
|
|
99
|
-
/** The zone times are shown in, or `undefined` for the viewer's own. */
|
|
100
|
-
timeZone,
|
|
101
|
-
/** Whole numbers with grouping: `format.integer(1222)` is "1,222". */
|
|
102
|
-
integer,
|
|
103
|
-
/** One decimal place at most: `format.decimal(3.14)` is "3.1". */
|
|
104
|
-
decimal,
|
|
105
|
-
/** A ratio as a whole percent: `format.percent(0.42)` is "42%". */
|
|
106
|
-
percent,
|
|
107
|
-
/**
|
|
108
|
-
* A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that
|
|
109
|
-
* rounds to 0 is "<1%", and one short of the whole that rounds to 100 is ">99%".
|
|
110
|
-
* `format.share(2.4 / 512)` is "<1%".
|
|
111
|
-
*/
|
|
112
|
-
share: (value) => {
|
|
113
|
-
if (value == null || Number.isNaN(value)) return missing;
|
|
114
|
-
if (value > 0 && value < .005) return `<${percent.format(.01)}`;
|
|
115
|
-
if (value >= .995 && value < 1) return `>${percent.format(.99)}`;
|
|
116
|
-
return percent.format(value);
|
|
117
|
-
},
|
|
118
|
-
/** A figure in short form for counts that run to thousands: `format.compact(1234)` is "1.2k" in en-GB, "1.2K" in en-US. */
|
|
119
|
-
compact,
|
|
120
|
-
/**
|
|
121
|
-
* How long ago (or how far ahead) a time is, in the largest unit it reaches:
|
|
122
|
-
* "3 weeks ago", "yesterday", "in 2 hours", "now" under a minute. Pass `now` in tests.
|
|
123
|
-
*/
|
|
124
|
-
ago: (value, now = /* @__PURE__ */ new Date()) => {
|
|
125
|
-
if (value == null) return missing;
|
|
126
|
-
const diff = toDate(value).getTime() - toDate(now).getTime();
|
|
127
|
-
const span = Math.abs(diff);
|
|
128
|
-
for (const [unit, size] of AGO_STEPS) if (span >= size) return relative.format(Math.sign(diff) * Math.floor(span / size), unit);
|
|
129
|
-
return relative.format(0, "second");
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* A media running time from seconds, as a player shows it: "4:05", "1:02:09". Unknown
|
|
133
|
-
* (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.
|
|
134
|
-
*/
|
|
135
|
-
runningTime: (seconds) => {
|
|
136
|
-
if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;
|
|
137
|
-
const s = Math.floor(seconds);
|
|
138
|
-
const two = (n) => String(n).padStart(2, "0");
|
|
139
|
-
const [h, m] = [Math.floor(s / 3600), Math.floor(s % 3600 / 60)];
|
|
140
|
-
return h > 0 ? `${h}:${two(m)}:${two(s % 60)}` : `${m}:${two(s % 60)}`;
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* A position in media as an editor shows it, to a chosen precision: "4:05" (seconds), "4:05.250"
|
|
144
|
-
* (`"ms"`), or "0:04:05:07" (`"frames"` at `fps`, the last part the frame). Hours appear only
|
|
145
|
-
* from one hour, except in frames. Frames are always four parts, hours included, as SMPTE
|
|
146
|
-
* timecode is (non-drop frame, with colons): a three-part "1:05:00" reads as one hour five, so
|
|
147
|
-
* a frame count must never be three. Editors write the same four parts (strata-react issue
|
|
148
|
-
* #122). Floors, never rounds up, so a time never reads ahead of the picture. Unknown (null,
|
|
149
|
-
* negative, not finite) prints the placeholder. Set it in `tabular-nums`.
|
|
150
|
-
*/
|
|
151
|
-
timecode: (seconds, { precision = "seconds", fps = 30 } = {}) => {
|
|
152
|
-
if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;
|
|
153
|
-
const whole = Math.floor(seconds);
|
|
154
|
-
const two = (n) => String(n).padStart(2, "0");
|
|
155
|
-
const [h, m] = [Math.floor(whole / 3600), Math.floor(whole % 3600 / 60)];
|
|
156
|
-
const base = h > 0 ? `${h}:${two(m)}:${two(whole % 60)}` : `${m}:${two(whole % 60)}`;
|
|
157
|
-
if (precision === "ms") return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1e3 + 1e-6), 999)).padStart(3, "0")}`;
|
|
158
|
-
if (precision === "frames") return `${h}:${two(m)}:${two(whole % 60)}:${two(Math.min(Math.floor((seconds - whole) * fps + 1e-6), Math.ceil(fps) - 1))}`;
|
|
159
|
-
return base;
|
|
160
|
-
},
|
|
161
|
-
/** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */
|
|
162
|
-
missing,
|
|
163
|
-
/** A time of day: `format.clock(at)` is "06:05". */
|
|
164
|
-
clock,
|
|
165
|
-
/** A day without its year, for this week's things: `format.day(at)` is "Sunday 8 November". */
|
|
166
|
-
day,
|
|
167
|
-
/** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is "Sun 06:05". */
|
|
168
|
-
shortDay,
|
|
169
|
-
/** A date with its year, for a record or a deadline: `format.date(at)` is "8 Nov 2026". */
|
|
170
|
-
date,
|
|
171
|
-
/** A date and time, for a log or history row: `format.dateTime(at)` is "8 Nov 2026, 06:05". */
|
|
172
|
-
dateTime,
|
|
173
|
-
/** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */
|
|
174
|
-
withUnit,
|
|
175
|
-
/** A temperature in °C, joined by a non-breaking space. */
|
|
176
|
-
celsius: (value) => withUnit(value, "°C"),
|
|
177
|
-
/**
|
|
178
|
-
* A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and
|
|
179
|
-
* networks are sold): one decimal below 10 ("5.2 GB"), whole above ("431 GB"). Pass `unit`
|
|
180
|
-
* to fix the unit, so figures compared side by side ("431 of 466 GB") share one.
|
|
181
|
-
*/
|
|
182
|
-
bytes: (value, unit) => {
|
|
183
|
-
const chosen = unit ?? [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? "B";
|
|
184
|
-
const scaled = value / BYTE_SIZE[chosen];
|
|
185
|
-
return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== "B" ? decimal : integer);
|
|
186
|
-
},
|
|
187
|
-
/** The unit `bytes` would choose for a value, to share it across a set of figures. */
|
|
188
|
-
byteUnit: (value) => [...BYTE_UNITS].reverse().find((u) => Math.abs(value) >= BYTE_SIZE[u]) ?? "B",
|
|
189
|
-
/**
|
|
190
|
-
* "1 piece", "6 pieces": the count and its noun, so copy never reads "1 pieces". They are
|
|
191
|
-
* joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same
|
|
192
|
-
* call or a `\s` regex, not a typed "6 pieces" string in a role's `name`.
|
|
193
|
-
*/
|
|
194
|
-
count: (value, one, many = `${one}s`, { compact: short = false } = {}) => value == null ? missing : `${(short ? compact : integer).format(value)} ${plurals.select(value) === "one" ? one : many}`
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
/** The en-GB formatters. */
|
|
198
|
-
var format = createFormat("en-GB");
|
|
199
15
|
// src/lib/in-view.ts
|
|
200
16
|
/**
|
|
201
17
|
* Whether an element is within `rootMargin` of its scroll region (the nearest
|
|
@@ -507,7 +323,7 @@ function KeysLegend({ shortcuts, label = "Keyboard shortcuts", className }) {
|
|
|
507
323
|
children: " or "
|
|
508
324
|
}), /* @__PURE__ */ jsx("kbd", {
|
|
509
325
|
className: "min-w-5 rounded-control border border-border bg-surface-sunken px-1 text-center font-mono text-foreground",
|
|
510
|
-
children: KEY_NAMES[k] ?? k
|
|
326
|
+
children: /* @__PURE__ */ jsx(KeyText, { children: KEY_NAMES[k] ?? k })
|
|
511
327
|
})] }, k))
|
|
512
328
|
}), /* @__PURE__ */ jsx("dd", { children: s.label })]
|
|
513
329
|
}, s.keys.join(" ")))
|
|
@@ -563,7 +379,7 @@ function CommandLegend({ commands, platform, label = "Keyboard shortcuts", class
|
|
|
563
379
|
className: cn("flex items-center gap-1.5", isDisabled(c) && "opacity-50"),
|
|
564
380
|
children: [/* @__PURE__ */ jsx("dt", { children: /* @__PURE__ */ jsx("kbd", {
|
|
565
381
|
className: "min-w-5 rounded-control border border-border bg-surface-sunken px-1 text-center font-mono text-foreground",
|
|
566
|
-
children: commandShortcut(c, where)
|
|
382
|
+
children: /* @__PURE__ */ jsx(KeyText, { children: commandShortcut(c, where) ?? "" })
|
|
567
383
|
}) }), /* @__PURE__ */ jsx("dd", { children: labelOf(c) })]
|
|
568
384
|
}, c.id))
|
|
569
385
|
});
|
|
@@ -595,7 +411,7 @@ function Item({ command, platform }) {
|
|
|
595
411
|
}),
|
|
596
412
|
shortcut && /* @__PURE__ */ jsx(Keyboard, {
|
|
597
413
|
className: "ml-6 shrink-0 font-mono type-caption text-muted-foreground",
|
|
598
|
-
children: shortcut
|
|
414
|
+
children: /* @__PURE__ */ jsx(KeyText, { children: shortcut })
|
|
599
415
|
}),
|
|
600
416
|
reason && /* @__PURE__ */ jsx(Text, {
|
|
601
417
|
slot: "description",
|
|
@@ -766,7 +582,7 @@ function CommandMenu({ commands, open, onOpenChange, shortcut = "Mod+K", label =
|
|
|
766
582
|
isOpen,
|
|
767
583
|
onOpenChange: set,
|
|
768
584
|
isDismissable: true,
|
|
769
|
-
className: "layer-overlay fixed inset-0 grid justify-items-center overflow-hidden
|
|
585
|
+
className: "layer-overlay fixed inset-0 grid justify-items-center overflow-hidden scrim p-4 pt-24",
|
|
770
586
|
children: /* @__PURE__ */ jsxs(Modal, {
|
|
771
587
|
className: cn("flex max-h-full w-full max-w-lg flex-col self-start outline-none", overlaySurface),
|
|
772
588
|
children: [/* @__PURE__ */ jsx(Dialog$1, {
|
|
@@ -965,7 +781,7 @@ function Driven({ open, onOpenChange, children }) {
|
|
|
965
781
|
onOpenChange
|
|
966
782
|
});
|
|
967
783
|
}
|
|
968
|
-
var overlayClass = "layer-overlay fixed inset-0 grid overflow-hidden
|
|
784
|
+
var overlayClass = "layer-overlay fixed inset-0 grid overflow-hidden scrim";
|
|
969
785
|
/** A modal dialog with a required title; focus goes in and returns, Escape and a close control dismiss it. `placement="end"` makes it a sheet. */
|
|
970
786
|
function Dialog({ title, description, trigger, open, onOpenChange, className, children, actions, hideTitle, closable = true, placement = "center", size = "md" }) {
|
|
971
787
|
const descriptionId = React.useId();
|
|
@@ -1253,7 +1069,7 @@ function AsyncButton({ phase, labels, error, disabled, ...props }) {
|
|
|
1253
1069
|
}
|
|
1254
1070
|
/** Runs an async action and reports its phase, its error and any field messages. `done` returns to `idle` after `settleMs`; `run` never changes identity. */
|
|
1255
1071
|
function useAsyncAction(action, { settleMs = 2e3, onError, describeError = describeActionError, validate, onInvalid } = {}) {
|
|
1256
|
-
const [state, setState] = React.useState(idle);
|
|
1072
|
+
const [state, setState] = React.useState(idle$1);
|
|
1257
1073
|
const timer = React.useRef(void 0);
|
|
1258
1074
|
const unreported = React.useRef(void 0);
|
|
1259
1075
|
const latest = React.useRef({
|
|
@@ -1281,22 +1097,22 @@ function useAsyncAction(action, { settleMs = 2e3, onError, describeError = descr
|
|
|
1281
1097
|
if (invalid) {
|
|
1282
1098
|
unreported.current = { invalid };
|
|
1283
1099
|
setState({
|
|
1284
|
-
...idle,
|
|
1100
|
+
...idle$1,
|
|
1285
1101
|
fieldErrors: invalid
|
|
1286
1102
|
});
|
|
1287
1103
|
return;
|
|
1288
1104
|
}
|
|
1289
1105
|
setState({
|
|
1290
|
-
...idle,
|
|
1106
|
+
...idle$1,
|
|
1291
1107
|
phase: "pending"
|
|
1292
1108
|
});
|
|
1293
1109
|
try {
|
|
1294
1110
|
await latest.current.action(...args);
|
|
1295
1111
|
setState({
|
|
1296
|
-
...idle,
|
|
1112
|
+
...idle$1,
|
|
1297
1113
|
phase: "done"
|
|
1298
1114
|
});
|
|
1299
|
-
timer.current = window.setTimeout(() => setState(idle), latest.current.settleMs);
|
|
1115
|
+
timer.current = window.setTimeout(() => setState(idle$1), latest.current.settleMs);
|
|
1300
1116
|
} catch (thrown) {
|
|
1301
1117
|
unreported.current = { thrown };
|
|
1302
1118
|
setState({
|
|
@@ -1336,7 +1152,7 @@ function useAsyncAction(action, { settleMs = 2e3, onError, describeError = descr
|
|
|
1336
1152
|
clearFieldError
|
|
1337
1153
|
};
|
|
1338
1154
|
}
|
|
1339
|
-
var idle = {
|
|
1155
|
+
var idle$1 = {
|
|
1340
1156
|
phase: "idle",
|
|
1341
1157
|
error: void 0,
|
|
1342
1158
|
thrown: void 0,
|
|
@@ -3003,7 +2819,9 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
|
|
|
3003
2819
|
});
|
|
3004
2820
|
}
|
|
3005
2821
|
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
3006
|
-
function SeekBar({ time, duration, onSeek, marks = [], buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled, className }) {
|
|
2822
|
+
function SeekBar({ time, duration: known, onSeek, marks = [], buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, className }) {
|
|
2823
|
+
const duration = known && Number.isFinite(known) && known > 0 ? known : 0;
|
|
2824
|
+
const disabled = off || duration === 0;
|
|
3007
2825
|
const track = React.useRef(null);
|
|
3008
2826
|
const input = React.useRef(null);
|
|
3009
2827
|
const frac = duration > 0 ? clamp$2(time / duration, 0, 1) : 0;
|
|
@@ -3365,6 +3183,480 @@ function StageGuides({ safe, thirds, centre, className }) {
|
|
|
3365
3183
|
children: [draw("stroke-foreground", 3), draw("stroke-background", 1)]
|
|
3366
3184
|
});
|
|
3367
3185
|
}
|
|
3186
|
+
// src/components/media-player.tsx
|
|
3187
|
+
var idle = {
|
|
3188
|
+
playing: false,
|
|
3189
|
+
time: 0,
|
|
3190
|
+
duration: null,
|
|
3191
|
+
buffered: 0,
|
|
3192
|
+
volume: 100,
|
|
3193
|
+
muted: false,
|
|
3194
|
+
rate: 1,
|
|
3195
|
+
ended: false,
|
|
3196
|
+
loading: false,
|
|
3197
|
+
error: null
|
|
3198
|
+
};
|
|
3199
|
+
var LOAD_MESSAGES = {
|
|
3200
|
+
2: "The connection dropped while it was loading.",
|
|
3201
|
+
3: "The file could not be decoded.",
|
|
3202
|
+
4: "This format is not supported or the file is not there."
|
|
3203
|
+
};
|
|
3204
|
+
function bufferedAhead(el) {
|
|
3205
|
+
const ranges = el.buffered;
|
|
3206
|
+
for (let i = 0; i < ranges.length; i++) if (el.currentTime >= ranges.start(i) && el.currentTime <= ranges.end(i)) return ranges.end(i);
|
|
3207
|
+
return 0;
|
|
3208
|
+
}
|
|
3209
|
+
function useElementListeners(ref, bind) {
|
|
3210
|
+
const bound = React.useRef(null);
|
|
3211
|
+
const latest = React.useRef(bind);
|
|
3212
|
+
latest.current = bind;
|
|
3213
|
+
React.useEffect(() => {
|
|
3214
|
+
const el = ref.current;
|
|
3215
|
+
if (bound.current?.el === el) return;
|
|
3216
|
+
bound.current?.unbind();
|
|
3217
|
+
bound.current = el ? {
|
|
3218
|
+
el,
|
|
3219
|
+
unbind: latest.current(el)
|
|
3220
|
+
} : null;
|
|
3221
|
+
});
|
|
3222
|
+
React.useEffect(() => () => {
|
|
3223
|
+
bound.current?.unbind();
|
|
3224
|
+
bound.current = null;
|
|
3225
|
+
}, []);
|
|
3226
|
+
}
|
|
3227
|
+
var EVENTS = [
|
|
3228
|
+
"loadstart",
|
|
3229
|
+
"loadedmetadata",
|
|
3230
|
+
"durationchange",
|
|
3231
|
+
"timeupdate",
|
|
3232
|
+
"progress",
|
|
3233
|
+
"play",
|
|
3234
|
+
"playing",
|
|
3235
|
+
"pause",
|
|
3236
|
+
"ended",
|
|
3237
|
+
"volumechange",
|
|
3238
|
+
"ratechange",
|
|
3239
|
+
"seeking",
|
|
3240
|
+
"seeked",
|
|
3241
|
+
"waiting",
|
|
3242
|
+
"canplay",
|
|
3243
|
+
"emptied",
|
|
3244
|
+
"error"
|
|
3245
|
+
];
|
|
3246
|
+
/** Follows an `<audio>` or `<video>` and returns its state and the requests a player makes. Works with the browser's own controls too. */
|
|
3247
|
+
function useMediaElement(ref) {
|
|
3248
|
+
const [snapshot, setSnapshot] = React.useState(idle);
|
|
3249
|
+
const blocked = React.useRef(null);
|
|
3250
|
+
const pendingSeek = React.useRef(null);
|
|
3251
|
+
const read = React.useCallback(() => {
|
|
3252
|
+
const el = ref.current;
|
|
3253
|
+
if (!el) return;
|
|
3254
|
+
const finite = Number.isFinite(el.duration) && el.duration > 0;
|
|
3255
|
+
let error = blocked.current;
|
|
3256
|
+
if (el.error && el.error.code !== 1) error = {
|
|
3257
|
+
kind: "load",
|
|
3258
|
+
message: LOAD_MESSAGES[el.error.code] ?? "It could not be played."
|
|
3259
|
+
};
|
|
3260
|
+
const next = {
|
|
3261
|
+
playing: !el.paused && !el.ended,
|
|
3262
|
+
time: Number.isFinite(el.currentTime) ? el.currentTime : 0,
|
|
3263
|
+
duration: finite ? el.duration : null,
|
|
3264
|
+
buffered: bufferedAhead(el),
|
|
3265
|
+
volume: el.muted ? 0 : Math.round(el.volume * 100),
|
|
3266
|
+
muted: el.muted,
|
|
3267
|
+
rate: el.playbackRate,
|
|
3268
|
+
ended: el.ended,
|
|
3269
|
+
loading: !error && el.networkState === 2 && el.readyState < 3 && !el.paused,
|
|
3270
|
+
error
|
|
3271
|
+
};
|
|
3272
|
+
setSnapshot((previous) => Object.keys(next).every((k) => Object.is(previous[k], next[k]) || k === "error" && previous.error?.message === next.error?.message && previous.error?.kind === next.error?.kind) ? previous : next);
|
|
3273
|
+
}, [ref]);
|
|
3274
|
+
useElementListeners(ref, (el) => {
|
|
3275
|
+
const on = (e) => {
|
|
3276
|
+
if (e.type === "play" || e.type === "playing") blocked.current = null;
|
|
3277
|
+
if (e.type === "loadedmetadata" && pendingSeek.current !== null) {
|
|
3278
|
+
el.currentTime = pendingSeek.current;
|
|
3279
|
+
pendingSeek.current = null;
|
|
3280
|
+
}
|
|
3281
|
+
if (e.type === "emptied" || e.type === "loadstart") blocked.current = null;
|
|
3282
|
+
read();
|
|
3283
|
+
};
|
|
3284
|
+
for (const type of EVENTS) el.addEventListener(type, on);
|
|
3285
|
+
read();
|
|
3286
|
+
return () => {
|
|
3287
|
+
for (const type of EVENTS) el.removeEventListener(type, on);
|
|
3288
|
+
};
|
|
3289
|
+
});
|
|
3290
|
+
return React.useMemo(() => {
|
|
3291
|
+
const play = async () => {
|
|
3292
|
+
const el = ref.current;
|
|
3293
|
+
if (!el) return;
|
|
3294
|
+
try {
|
|
3295
|
+
await el.play();
|
|
3296
|
+
} catch (e) {
|
|
3297
|
+
if (e instanceof DOMException && e.name === "NotAllowedError") {
|
|
3298
|
+
blocked.current = {
|
|
3299
|
+
kind: "blocked",
|
|
3300
|
+
message: "The browser blocked playback until you press Play."
|
|
3301
|
+
};
|
|
3302
|
+
read();
|
|
3303
|
+
} else if (!(e instanceof DOMException && e.name === "AbortError")) read();
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
return {
|
|
3307
|
+
...snapshot,
|
|
3308
|
+
play,
|
|
3309
|
+
pause: () => ref.current?.pause(),
|
|
3310
|
+
toggle: () => {
|
|
3311
|
+
const el = ref.current;
|
|
3312
|
+
if (!el) return;
|
|
3313
|
+
if (el.paused || el.ended) play();
|
|
3314
|
+
else el.pause();
|
|
3315
|
+
},
|
|
3316
|
+
seek: (time) => {
|
|
3317
|
+
const el = ref.current;
|
|
3318
|
+
if (!el) return;
|
|
3319
|
+
if (el.readyState < 1) pendingSeek.current = Math.max(0, time);
|
|
3320
|
+
else el.currentTime = Math.max(0, Number.isFinite(el.duration) ? Math.min(time, el.duration) : time);
|
|
3321
|
+
read();
|
|
3322
|
+
},
|
|
3323
|
+
setVolume: (volume) => {
|
|
3324
|
+
const el = ref.current;
|
|
3325
|
+
if (!el) return;
|
|
3326
|
+
const v = Math.min(Math.max(volume, 0), 100);
|
|
3327
|
+
el.muted = v === 0;
|
|
3328
|
+
if (v > 0) el.volume = v / 100;
|
|
3329
|
+
},
|
|
3330
|
+
setRate: (rate) => {
|
|
3331
|
+
const el = ref.current;
|
|
3332
|
+
if (!el) return;
|
|
3333
|
+
el.defaultPlaybackRate = rate;
|
|
3334
|
+
el.playbackRate = rate;
|
|
3335
|
+
},
|
|
3336
|
+
retry: () => {
|
|
3337
|
+
const el = ref.current;
|
|
3338
|
+
if (!el) return;
|
|
3339
|
+
const resume = !el.paused;
|
|
3340
|
+
const at = el.currentTime;
|
|
3341
|
+
blocked.current = null;
|
|
3342
|
+
el.load();
|
|
3343
|
+
if (at > 0) pendingSeek.current = at;
|
|
3344
|
+
read();
|
|
3345
|
+
if (resume) play();
|
|
3346
|
+
}
|
|
3347
|
+
};
|
|
3348
|
+
}, [
|
|
3349
|
+
snapshot,
|
|
3350
|
+
ref,
|
|
3351
|
+
read
|
|
3352
|
+
]);
|
|
3353
|
+
}
|
|
3354
|
+
/** Playback speeds an audiobook or lecture listener expects. */
|
|
3355
|
+
var SPEECH_RATES = [
|
|
3356
|
+
.75,
|
|
3357
|
+
1,
|
|
3358
|
+
1.25,
|
|
3359
|
+
1.5,
|
|
3360
|
+
1.75,
|
|
3361
|
+
2,
|
|
3362
|
+
2.5,
|
|
3363
|
+
3
|
|
3364
|
+
];
|
|
3365
|
+
var JUMP = 10;
|
|
3366
|
+
function useCoarsePointer() {
|
|
3367
|
+
const [coarse, setCoarse] = React.useState(false);
|
|
3368
|
+
React.useEffect(() => {
|
|
3369
|
+
if (typeof matchMedia !== "function") return;
|
|
3370
|
+
const query = matchMedia("(pointer: coarse)");
|
|
3371
|
+
const read = () => setCoarse(query.matches);
|
|
3372
|
+
read();
|
|
3373
|
+
query.addEventListener?.("change", read);
|
|
3374
|
+
return () => query.removeEventListener?.("change", read);
|
|
3375
|
+
}, []);
|
|
3376
|
+
return coarse;
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Plays a file or a sequence: the element, its state, and Strata's controls (or the browser's own on
|
|
3380
|
+
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
3381
|
+
* parts and `useMediaElement` directly.
|
|
3382
|
+
*/
|
|
3383
|
+
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, onEnded, onTimeChange, className }) {
|
|
3384
|
+
const list = React.useMemo(() => sources ?? (src ? [{
|
|
3385
|
+
src,
|
|
3386
|
+
title: label
|
|
3387
|
+
}] : []), [
|
|
3388
|
+
sources,
|
|
3389
|
+
src,
|
|
3390
|
+
label
|
|
3391
|
+
]);
|
|
3392
|
+
const [ownIndex, setOwnIndex] = React.useState(0);
|
|
3393
|
+
const index = Math.min(controlledIndex ?? ownIndex, Math.max(list.length - 1, 0));
|
|
3394
|
+
const current = list[index];
|
|
3395
|
+
const ref = React.useRef(null);
|
|
3396
|
+
const media = useMediaElement(ref);
|
|
3397
|
+
const coarse = useCoarsePointer();
|
|
3398
|
+
const native = controls === "native" || controls === "auto" && coarse;
|
|
3399
|
+
const go = React.useCallback((to) => {
|
|
3400
|
+
if (controlledIndex === void 0) setOwnIndex(to);
|
|
3401
|
+
onIndexChange?.(to);
|
|
3402
|
+
}, [controlledIndex, onIndexChange]);
|
|
3403
|
+
const resume = React.useRef(false);
|
|
3404
|
+
const startAt = React.useRef(null);
|
|
3405
|
+
const keep = React.useRef({
|
|
3406
|
+
index,
|
|
3407
|
+
playing: media.playing,
|
|
3408
|
+
go,
|
|
3409
|
+
onEnded,
|
|
3410
|
+
autoAdvance,
|
|
3411
|
+
last: list.length - 1
|
|
3412
|
+
});
|
|
3413
|
+
keep.current = {
|
|
3414
|
+
index,
|
|
3415
|
+
playing: media.playing,
|
|
3416
|
+
go,
|
|
3417
|
+
onEnded,
|
|
3418
|
+
autoAdvance,
|
|
3419
|
+
last: list.length - 1
|
|
3420
|
+
};
|
|
3421
|
+
const wasSrc = React.useRef(current?.src);
|
|
3422
|
+
React.useEffect(() => {
|
|
3423
|
+
if (wasSrc.current === current?.src) return;
|
|
3424
|
+
wasSrc.current = current?.src;
|
|
3425
|
+
if (!ref.current) return;
|
|
3426
|
+
if (startAt.current !== null) {
|
|
3427
|
+
media.seek(startAt.current);
|
|
3428
|
+
startAt.current = null;
|
|
3429
|
+
}
|
|
3430
|
+
if (resume.current) {
|
|
3431
|
+
resume.current = false;
|
|
3432
|
+
media.play();
|
|
3433
|
+
}
|
|
3434
|
+
}, [current?.src]);
|
|
3435
|
+
const onEnd = React.useCallback(() => {
|
|
3436
|
+
const k = keep.current;
|
|
3437
|
+
if (k.autoAdvance && k.index < k.last) {
|
|
3438
|
+
resume.current = true;
|
|
3439
|
+
k.go(k.index + 1);
|
|
3440
|
+
} else k.onEnded?.();
|
|
3441
|
+
}, []);
|
|
3442
|
+
useElementListeners(ref, (el) => {
|
|
3443
|
+
el.addEventListener("ended", onEnd);
|
|
3444
|
+
return () => el.removeEventListener("ended", onEnd);
|
|
3445
|
+
});
|
|
3446
|
+
const offsets = React.useMemo(() => {
|
|
3447
|
+
if (list.length < 2 || !list.every((s) => s.duration && s.duration > 0)) return null;
|
|
3448
|
+
let at = 0;
|
|
3449
|
+
return list.map((s) => {
|
|
3450
|
+
const start = at;
|
|
3451
|
+
at += s.duration;
|
|
3452
|
+
return start;
|
|
3453
|
+
});
|
|
3454
|
+
}, [list]);
|
|
3455
|
+
const total = offsets ? offsets[offsets.length - 1] + list[list.length - 1].duration : null;
|
|
3456
|
+
const time = (offsets ? offsets[index] : 0) + media.time;
|
|
3457
|
+
const duration = total ?? media.duration;
|
|
3458
|
+
const seek = (t) => {
|
|
3459
|
+
if (!offsets) return media.seek(t);
|
|
3460
|
+
let to = offsets.length - 1;
|
|
3461
|
+
while (to > 0 && offsets[to] > t) to--;
|
|
3462
|
+
if (to === index) return media.seek(t - offsets[to]);
|
|
3463
|
+
resume.current = media.playing;
|
|
3464
|
+
startAt.current = t - offsets[to];
|
|
3465
|
+
go(to);
|
|
3466
|
+
};
|
|
3467
|
+
const step = (by) => {
|
|
3468
|
+
const to = index + by;
|
|
3469
|
+
if (to < 0 || to > list.length - 1) return;
|
|
3470
|
+
resume.current = media.playing;
|
|
3471
|
+
go(to);
|
|
3472
|
+
};
|
|
3473
|
+
React.useEffect(() => {
|
|
3474
|
+
if (onTimeChange) onTimeChange(time);
|
|
3475
|
+
}, [time]);
|
|
3476
|
+
useHotkeys(React.useMemo(() => [
|
|
3477
|
+
{
|
|
3478
|
+
keys: [" ", "k"],
|
|
3479
|
+
label: "Play or pause",
|
|
3480
|
+
run: media.toggle
|
|
3481
|
+
},
|
|
3482
|
+
{
|
|
3483
|
+
keys: ["j"],
|
|
3484
|
+
label: `Back ${JUMP} s`,
|
|
3485
|
+
run: () => seek(time - JUMP),
|
|
3486
|
+
repeat: true
|
|
3487
|
+
},
|
|
3488
|
+
{
|
|
3489
|
+
keys: ["l"],
|
|
3490
|
+
label: `Forward ${JUMP} s`,
|
|
3491
|
+
run: () => seek(time + JUMP),
|
|
3492
|
+
repeat: true
|
|
3493
|
+
},
|
|
3494
|
+
{
|
|
3495
|
+
keys: ["m"],
|
|
3496
|
+
label: "Mute",
|
|
3497
|
+
run: () => media.setVolume(media.muted ? 100 : 0)
|
|
3498
|
+
}
|
|
3499
|
+
], [
|
|
3500
|
+
media,
|
|
3501
|
+
time,
|
|
3502
|
+
offsets,
|
|
3503
|
+
index
|
|
3504
|
+
]), { enabled: shortcuts && !native });
|
|
3505
|
+
React.useEffect(() => {
|
|
3506
|
+
if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
|
|
3507
|
+
const s = navigator.mediaSession;
|
|
3508
|
+
s.metadata = new MediaMetadata({
|
|
3509
|
+
title: current?.title ?? session.title,
|
|
3510
|
+
artist: session.artist,
|
|
3511
|
+
album: session.album ?? (list.length > 1 ? session.title : void 0),
|
|
3512
|
+
artwork: session.artwork ? [{ src: session.artwork }] : []
|
|
3513
|
+
});
|
|
3514
|
+
return () => {
|
|
3515
|
+
s.metadata = null;
|
|
3516
|
+
};
|
|
3517
|
+
}, [
|
|
3518
|
+
session,
|
|
3519
|
+
current?.title,
|
|
3520
|
+
list.length
|
|
3521
|
+
]);
|
|
3522
|
+
React.useEffect(() => {
|
|
3523
|
+
if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator)) return;
|
|
3524
|
+
const s = navigator.mediaSession;
|
|
3525
|
+
const set = (action, handler) => {
|
|
3526
|
+
try {
|
|
3527
|
+
s.setActionHandler(action, handler);
|
|
3528
|
+
} catch {}
|
|
3529
|
+
};
|
|
3530
|
+
set("play", () => void media.play());
|
|
3531
|
+
set("pause", media.pause);
|
|
3532
|
+
set("seekbackward", () => seek(time - JUMP));
|
|
3533
|
+
set("seekforward", () => seek(time + JUMP));
|
|
3534
|
+
set("previoustrack", index > 0 ? () => step(-1) : null);
|
|
3535
|
+
set("nexttrack", index < list.length - 1 ? () => step(1) : null);
|
|
3536
|
+
return () => {
|
|
3537
|
+
for (const a of [
|
|
3538
|
+
"play",
|
|
3539
|
+
"pause",
|
|
3540
|
+
"seekbackward",
|
|
3541
|
+
"seekforward",
|
|
3542
|
+
"previoustrack",
|
|
3543
|
+
"nexttrack"
|
|
3544
|
+
]) set(a, null);
|
|
3545
|
+
};
|
|
3546
|
+
}, [
|
|
3547
|
+
session,
|
|
3548
|
+
media,
|
|
3549
|
+
time,
|
|
3550
|
+
index,
|
|
3551
|
+
list.length
|
|
3552
|
+
]);
|
|
3553
|
+
const common = {
|
|
3554
|
+
ref,
|
|
3555
|
+
src: current?.src,
|
|
3556
|
+
controls: native,
|
|
3557
|
+
autoPlay,
|
|
3558
|
+
preload: "metadata",
|
|
3559
|
+
"aria-label": label
|
|
3560
|
+
};
|
|
3561
|
+
const element = kind === "video" ? /* @__PURE__ */ jsx("video", {
|
|
3562
|
+
...common,
|
|
3563
|
+
poster,
|
|
3564
|
+
playsInline: true,
|
|
3565
|
+
className: "w-full rounded-surface bg-surface-sunken"
|
|
3566
|
+
}) : /* @__PURE__ */ jsx("audio", {
|
|
3567
|
+
...common,
|
|
3568
|
+
className: native ? "w-full" : "hidden"
|
|
3569
|
+
});
|
|
3570
|
+
const what = kind === "video" ? "this video" : "this recording";
|
|
3571
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3572
|
+
role: "group",
|
|
3573
|
+
"aria-label": label,
|
|
3574
|
+
className: cn("grid w-full gap-2", className),
|
|
3575
|
+
children: [
|
|
3576
|
+
element,
|
|
3577
|
+
media.error?.kind === "load" && /* @__PURE__ */ jsx(Alert, {
|
|
3578
|
+
tone: "danger",
|
|
3579
|
+
announce: true,
|
|
3580
|
+
title: `Could not load ${what}`,
|
|
3581
|
+
action: /* @__PURE__ */ jsx(Button, {
|
|
3582
|
+
size: "sm",
|
|
3583
|
+
variant: "outline",
|
|
3584
|
+
onClick: media.retry,
|
|
3585
|
+
children: "Try again"
|
|
3586
|
+
}),
|
|
3587
|
+
children: media.error.message
|
|
3588
|
+
}),
|
|
3589
|
+
media.error?.kind === "blocked" && /* @__PURE__ */ jsx("p", {
|
|
3590
|
+
role: "status",
|
|
3591
|
+
className: "type-body-sm text-muted-foreground",
|
|
3592
|
+
children: media.error.message
|
|
3593
|
+
}),
|
|
3594
|
+
!native && /* @__PURE__ */ jsxs("div", {
|
|
3595
|
+
className: "grid gap-2",
|
|
3596
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3597
|
+
className: "flex min-w-0 items-center gap-3",
|
|
3598
|
+
children: [/* @__PURE__ */ jsx(SeekBar, {
|
|
3599
|
+
time,
|
|
3600
|
+
duration,
|
|
3601
|
+
onSeek: seek,
|
|
3602
|
+
buffered: offsets ? void 0 : media.buffered,
|
|
3603
|
+
marks: offsets ? list.map((s, i) => ({
|
|
3604
|
+
time: offsets[i],
|
|
3605
|
+
label: s.title
|
|
3606
|
+
})).slice(1) : [],
|
|
3607
|
+
step: JUMP,
|
|
3608
|
+
bigStep: 60,
|
|
3609
|
+
label: `Seek in ${label}`
|
|
3610
|
+
}), /* @__PURE__ */ jsx(TimeReadout, {
|
|
3611
|
+
time,
|
|
3612
|
+
duration
|
|
3613
|
+
})]
|
|
3614
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3615
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
3616
|
+
children: [
|
|
3617
|
+
/* @__PURE__ */ jsxs(Transport, {
|
|
3618
|
+
playing: media.playing,
|
|
3619
|
+
onPlayPause: media.toggle,
|
|
3620
|
+
children: [list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
|
|
3621
|
+
icon: SkipBack,
|
|
3622
|
+
label: "Previous chapter",
|
|
3623
|
+
disabled: index === 0,
|
|
3624
|
+
onClick: () => step(-1)
|
|
3625
|
+
}), list.length > 1 && /* @__PURE__ */ jsx(IconButton, {
|
|
3626
|
+
icon: SkipForward,
|
|
3627
|
+
label: "Next chapter",
|
|
3628
|
+
disabled: index === list.length - 1,
|
|
3629
|
+
onClick: () => step(1)
|
|
3630
|
+
})]
|
|
3631
|
+
}),
|
|
3632
|
+
list.length > 1 && /* @__PURE__ */ jsxs("span", {
|
|
3633
|
+
className: "type-body-sm text-muted-foreground",
|
|
3634
|
+
children: [
|
|
3635
|
+
current?.title,
|
|
3636
|
+
" (",
|
|
3637
|
+
index + 1,
|
|
3638
|
+
" of ",
|
|
3639
|
+
list.length,
|
|
3640
|
+
")"
|
|
3641
|
+
]
|
|
3642
|
+
}),
|
|
3643
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3644
|
+
className: "ml-auto flex items-center gap-3",
|
|
3645
|
+
children: [/* @__PURE__ */ jsx(RateChoice, {
|
|
3646
|
+
rate: media.rate,
|
|
3647
|
+
onRateChange: media.setRate,
|
|
3648
|
+
rates
|
|
3649
|
+
}), /* @__PURE__ */ jsx(VolumeControl, {
|
|
3650
|
+
volume: media.volume,
|
|
3651
|
+
onVolumeChange: media.setVolume
|
|
3652
|
+
})]
|
|
3653
|
+
})
|
|
3654
|
+
]
|
|
3655
|
+
})]
|
|
3656
|
+
})
|
|
3657
|
+
]
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3368
3660
|
// src/lib/timeline.ts
|
|
3369
3661
|
/** 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. */
|
|
3370
3662
|
var STEPS = [
|
|
@@ -6272,7 +6564,7 @@ function FullscreenFrame({ label, active, onActiveChange, children, className })
|
|
|
6272
6564
|
isOpen: true,
|
|
6273
6565
|
onOpenChange: (o) => !o && onActiveChange(false),
|
|
6274
6566
|
isDismissable: true,
|
|
6275
|
-
className: "layer-overlay fixed inset-0
|
|
6567
|
+
className: "layer-overlay fixed inset-0 scrim",
|
|
6276
6568
|
children: /* @__PURE__ */ jsx(Modal, {
|
|
6277
6569
|
className: cn("h-full w-full outline-none", overlaySurface, "rounded-none"),
|
|
6278
6570
|
children: /* @__PURE__ */ jsx(Dialog$1, {
|
|
@@ -6583,7 +6875,9 @@ function DifferenceMarks({ difference }) {
|
|
|
6583
6875
|
if (!canvas || !ctx) return;
|
|
6584
6876
|
canvas.width = difference.width;
|
|
6585
6877
|
canvas.height = difference.height;
|
|
6586
|
-
ctx.
|
|
6878
|
+
const image = ctx.createImageData(difference.width, difference.height);
|
|
6879
|
+
image.data.set(difference.marks);
|
|
6880
|
+
ctx.putImageData(image, 0, 0);
|
|
6587
6881
|
}, [difference]);
|
|
6588
6882
|
return /* @__PURE__ */ jsx("canvas", {
|
|
6589
6883
|
ref,
|
|
@@ -7803,6 +8097,6 @@ function SaveStatus({ state, onRetry, className }) {
|
|
|
7803
8097
|
]
|
|
7804
8098
|
});
|
|
7805
8099
|
}
|
|
7806
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
|
|
8100
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, differences, fetchJson, fieldErrorsOf, format, formatChord, geo, isReservedChord, isTypingTarget, labelOf, matchesAccept, matchesChord, noOverlap, parseChord, parseSort, readErrorBody, readPixels, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
|
|
7807
8101
|
|
|
7808
8102
|
//# sourceMappingURL=index.js.map
|