strata-react 1.3.23 → 1.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { i as typeSteps, n as KeyText, r as cn, t as Tooltip } from "./tooltip-DhqrDtyu.js";
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
+ import { t as followAim } from "./follow-BTPs49FP.js";
5
+ import { n as useViewPointers, r as useWheelZoom, t as useSettledStatus } from "./viewer-input-CHU0Hx4A.js";
4
6
  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-Dq2-QpvA.js";
7
+ 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
8
  import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
7
9
  import { a as fieldErrorsOf, i as errorPayload, n as describeActionError, o as readErrorBody, r as describeHttpError, t as HttpError } from "./errors-BUvY1Z4d.js";
8
10
  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";
@@ -1645,6 +1647,7 @@ function LinkCard({ title, description, marks, as: Heading = "h3", className, ex
1645
1647
  const describedBy = [description && descriptionId, marks && marksId].filter(Boolean).join(" ") || void 0;
1646
1648
  const linkClass = "rounded-control outline-none after:absolute after:inset-0 after:rounded-surface";
1647
1649
  return /* @__PURE__ */ jsxs("div", {
1650
+ "data-part": "link-card",
1648
1651
  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
1652
  children: [
1650
1653
  /* @__PURE__ */ jsx(Heading, {
@@ -3651,7 +3654,7 @@ function FullscreenFrame({ label, active, onActiveChange, modal: allowModal = tr
3651
3654
  });
3652
3655
  }
3653
3656
  // src/components/media.tsx
3654
- var clamp$3 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
3657
+ var clamp$4 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
3655
3658
  var timecode = (t, { precision, fps }) => format.timecode(t, {
3656
3659
  precision,
3657
3660
  fps
@@ -3742,8 +3745,8 @@ function SpanStrip({ spans, duration, label = "Marked parts", precision = "secon
3742
3745
  function drawableSpans(spans, duration) {
3743
3746
  return spans.map((s) => ({
3744
3747
  ...s,
3745
- start: clamp$3(s.start, 0, duration),
3746
- end: clamp$3(s.end, 0, duration)
3748
+ start: clamp$4(s.start, 0, duration),
3749
+ end: clamp$4(s.end, 0, duration)
3747
3750
  })).filter((s) => Number.isFinite(s.start) && Number.isFinite(s.end) && s.end > s.start).sort((a, b) => a.start - b.start);
3748
3751
  }
3749
3752
  /** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
@@ -3752,8 +3755,8 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
3752
3755
  const disabled = off || duration === 0;
3753
3756
  const track = React.useRef(null);
3754
3757
  const input = React.useRef(null);
3755
- const frac = duration > 0 ? clamp$3(time / duration, 0, 1) : 0;
3756
- const seekTo = (t) => onSeek(clamp$3(t, 0, duration));
3758
+ const frac = duration > 0 ? clamp$4(time / duration, 0, 1) : 0;
3759
+ const seekTo = (t) => onSeek(clamp$4(t, 0, duration));
3757
3760
  const shared = useSharedCursor();
3758
3761
  const joined = Boolean(cursorProp) && shared !== null;
3759
3762
  const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
@@ -3790,7 +3793,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
3790
3793
  minValue: 0,
3791
3794
  maxValue: Math.max(duration, fine),
3792
3795
  step: fine,
3793
- value: [clamp$3(time, 0, duration)],
3796
+ value: [clamp$4(time, 0, duration)],
3794
3797
  onChange: ([t]) => seekTo(t),
3795
3798
  numberFormatter: timeText,
3796
3799
  isDisabled: disabled
@@ -3832,7 +3835,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
3832
3835
  onPointerMove: (e) => {
3833
3836
  if (!joined || duration === 0) return;
3834
3837
  const box = e.currentTarget.getBoundingClientRect();
3835
- shared.setPointer(toCursor(clamp$3((e.clientX - box.left) / (box.width || 1) * duration, 0, duration)));
3838
+ shared.setPointer(toCursor(clamp$4((e.clientX - box.left) / (box.width || 1) * duration, 0, duration)));
3836
3839
  },
3837
3840
  onPointerLeave: () => shared?.setPointer(null)
3838
3841
  }),
@@ -3846,7 +3849,7 @@ function SeekBar({ time, duration: known, onSeek, marks = [], spans = [], onMark
3846
3849
  buffered !== void 0 && duration > 0 && /* @__PURE__ */ jsx("span", {
3847
3850
  "aria-hidden": true,
3848
3851
  className: "absolute left-0 h-1.5 rounded-pill bg-neutral-4",
3849
- style: { width: `${clamp$3(buffered / duration, 0, 1) * 100}%` }
3852
+ style: { width: `${clamp$4(buffered / duration, 0, 1) * 100}%` }
3850
3853
  }),
3851
3854
  /* @__PURE__ */ jsx("span", {
3852
3855
  "aria-hidden": true,
@@ -4020,27 +4023,31 @@ function RateChoice({ rate, onRateChange, rates = [
4020
4023
  /**
4021
4024
  * The shortcuts a player takes, as one list for `useHotkeys` and `KeysLegend`: Space and K play
4022
4025
  * or pause, J and L go back or forward `jump` seconds, the arrows by `frame` seconds, Home and End
4023
- * to the ends, M mutes. Pass the player's actions; the labels are the legend's words.
4026
+ * 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`).
4024
4027
  */
4025
- function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute }) {
4026
- const to = (t) => () => seek(clamp$3(t, 0, duration));
4028
+ function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump = 1, toggleMute, stageKeys }) {
4029
+ const to = (t) => () => seek(clamp$4(t, 0, duration));
4030
+ const anywhere = stageKeys || void 0;
4027
4031
  return [
4028
4032
  {
4029
4033
  keys: [" ", "k"],
4030
4034
  label: "Play or pause",
4031
- run: toggle
4035
+ run: toggle,
4036
+ anywhere
4032
4037
  },
4033
4038
  {
4034
4039
  keys: ["j"],
4035
4040
  label: `Back ${jump} s`,
4036
4041
  run: to(time - jump),
4037
- repeat: true
4042
+ repeat: true,
4043
+ anywhere
4038
4044
  },
4039
4045
  {
4040
4046
  keys: ["l"],
4041
4047
  label: `Forward ${jump} s`,
4042
4048
  run: to(time + jump),
4043
- repeat: true
4049
+ repeat: true,
4050
+ anywhere
4044
4051
  },
4045
4052
  {
4046
4053
  keys: ["ArrowLeft"],
@@ -4057,17 +4064,20 @@ function transportShortcuts({ toggle, seek, time, duration, frame = 1 / 30, jump
4057
4064
  {
4058
4065
  keys: ["Home"],
4059
4066
  label: "Go to start",
4060
- run: to(0)
4067
+ run: to(0),
4068
+ anywhere
4061
4069
  },
4062
4070
  {
4063
4071
  keys: ["End"],
4064
4072
  label: "Go to end",
4065
- run: to(duration)
4073
+ run: to(duration),
4074
+ anywhere
4066
4075
  },
4067
4076
  ...toggleMute ? [{
4068
4077
  keys: ["m"],
4069
4078
  label: "Mute",
4070
- run: toggleMute
4079
+ run: toggleMute,
4080
+ anywhere
4071
4081
  }] : []
4072
4082
  ];
4073
4083
  }
@@ -4179,9 +4189,68 @@ function StageGuides({ safe, thirds, centre, className }) {
4179
4189
  children: [draw("stroke-foreground", 3), draw("stroke-background", 1)]
4180
4190
  });
4181
4191
  }
4192
+ // src/components/key-owner.ts
4193
+ var members = /* @__PURE__ */ new Set();
4194
+ var active = null;
4195
+ var warned = false;
4196
+ var snapshot = {
4197
+ count: 0,
4198
+ active: null
4199
+ };
4200
+ var listeners = /* @__PURE__ */ new Set();
4201
+ var emit = () => {
4202
+ snapshot = {
4203
+ count: members.size,
4204
+ active
4205
+ };
4206
+ listeners.forEach((l) => l());
4207
+ };
4208
+ var subscribe = (l) => {
4209
+ listeners.add(l);
4210
+ return () => void listeners.delete(l);
4211
+ };
4212
+ var get = () => snapshot;
4213
+ /**
4214
+ * Joins the page's key owners while `enabled`, and takes the keys whenever `playing` turns true. Spread nothing: call
4215
+ * `claim` from the region's focus and pointer-down handlers, and bind the player's `useHotkeys` with `enabled: owner.owns`.
4216
+ */
4217
+ function useKeyOwner(enabled, playing = false) {
4218
+ const id = React.useId();
4219
+ React.useEffect(() => {
4220
+ if (!enabled) return;
4221
+ members.add(id);
4222
+ if (members.size === 2 && !warned && isDev()) {
4223
+ warned = true;
4224
+ 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.");
4225
+ }
4226
+ emit();
4227
+ return () => {
4228
+ members.delete(id);
4229
+ if (active === id) active = null;
4230
+ emit();
4231
+ };
4232
+ }, [id, enabled]);
4233
+ const page = React.useSyncExternalStore(subscribe, get, get);
4234
+ const claim = React.useCallback(() => {
4235
+ if (active === id || !members.has(id)) return;
4236
+ active = id;
4237
+ emit();
4238
+ }, [id]);
4239
+ React.useEffect(() => {
4240
+ if (playing && enabled) claim();
4241
+ }, [
4242
+ playing,
4243
+ enabled,
4244
+ claim
4245
+ ]);
4246
+ return {
4247
+ owns: enabled && (page.count <= 1 || page.active === id),
4248
+ claim
4249
+ };
4250
+ }
4182
4251
  // src/components/media-group.tsx
4183
4252
  var groups = /* @__PURE__ */ new Map();
4184
- /** Adds an element to a named group until the returned function is called; whenever one plays, the others pause. */
4253
+ /** Adds an element, or a `useTimeline` clock, to a named group until the returned function is called; whenever one plays, the others pause. */
4185
4254
  function joinMediaGroup(name, el) {
4186
4255
  let members = groups.get(name);
4187
4256
  if (!members) groups.set(name, members = /* @__PURE__ */ new Set());
@@ -4946,48 +5015,6 @@ function useAttachedSource(ref, src, attach, onProblem, growing, start) {
4946
5015
  }, []);
4947
5016
  return React.useMemo(() => ({ reload: (at) => hold.current?.attachment.reload(at) }), []);
4948
5017
  }
4949
- var keyPlayers = (() => {
4950
- const ids = /* @__PURE__ */ new Set();
4951
- let active = null;
4952
- let warned = false;
4953
- const listeners = /* @__PURE__ */ new Set();
4954
- let snapshot = {
4955
- count: 0,
4956
- active: null
4957
- };
4958
- const emit = () => {
4959
- snapshot = {
4960
- count: ids.size,
4961
- active
4962
- };
4963
- listeners.forEach((l) => l());
4964
- };
4965
- return {
4966
- subscribe: (l) => {
4967
- listeners.add(l);
4968
- return () => void listeners.delete(l);
4969
- },
4970
- get: () => snapshot,
4971
- add(id) {
4972
- ids.add(id);
4973
- if (ids.size === 2 && !warned && isDev()) {
4974
- warned = true;
4975
- 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.");
4976
- }
4977
- emit();
4978
- },
4979
- remove(id) {
4980
- ids.delete(id);
4981
- if (active === id) active = null;
4982
- emit();
4983
- },
4984
- use(id) {
4985
- if (active === id || !ids.has(id)) return;
4986
- active = id;
4987
- emit();
4988
- }
4989
- };
4990
- })();
4991
5018
  /** Playback speeds an audiobook or lecture listener expects. */
4992
5019
  var SPEECH_RATES = [
4993
5020
  .75,
@@ -5361,25 +5388,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
5361
5388
  frames,
5362
5389
  fps
5363
5390
  ]);
5364
- const id = React.useId();
5365
- React.useEffect(() => {
5366
- if (!shortcuts || native) return;
5367
- keyPlayers.add(id);
5368
- return () => keyPlayers.remove(id);
5369
- }, [
5370
- id,
5371
- shortcuts,
5372
- native
5373
- ]);
5374
- const page = React.useSyncExternalStore(keyPlayers.subscribe, keyPlayers.get, keyPlayers.get);
5375
- React.useEffect(() => {
5376
- if (media.playing && shortcuts && !native) keyPlayers.use(id);
5377
- }, [
5378
- media.playing,
5379
- id,
5380
- shortcuts,
5381
- native
5382
- ]);
5391
+ const owner = useKeyOwner(shortcuts && !native, media.playing);
5383
5392
  const activeKeys = autoHide ? keys.map((shortcut) => ({
5384
5393
  ...shortcut,
5385
5394
  run: () => {
@@ -5387,7 +5396,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
5387
5396
  shortcut.run();
5388
5397
  }
5389
5398
  })) : keys;
5390
- useHotkeys(activeKeys, { enabled: shortcuts && !native && (page.count <= 1 || page.active === id) });
5399
+ useHotkeys(activeKeys, { enabled: shortcuts && !native && owner.owns });
5391
5400
  React.useEffect(() => {
5392
5401
  if (!session || typeof navigator === "undefined" || !("mediaSession" in navigator) || typeof MediaMetadata === "undefined") return;
5393
5402
  const s = navigator.mediaSession;
@@ -5504,12 +5513,12 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
5504
5513
  role: "group",
5505
5514
  "aria-label": label,
5506
5515
  "data-floating": floating || void 0,
5507
- onFocusCapture: () => keyPlayers.use(id),
5516
+ onFocusCapture: owner.claim,
5508
5517
  onMouseMoveCapture: autoHide ? wakeControls : void 0,
5509
5518
  onKeyDownCapture: autoHide ? wakeControls : void 0,
5510
5519
  onMouseLeave: autoHide && !full ? sleepControls : void 0,
5511
5520
  onPointerDownCapture: () => {
5512
- keyPlayers.use(id);
5521
+ owner.claim();
5513
5522
  if (autoHide) wakeControls();
5514
5523
  },
5515
5524
  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")),
@@ -6863,7 +6872,7 @@ async function defaultDecode(data) {
6863
6872
  ctx.close?.();
6864
6873
  }
6865
6874
  }
6866
- var clamp$2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
6875
+ var clamp$3 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
6867
6876
  var clock = (t) => format.runningTime(t);
6868
6877
  /** An audio waveform with marks, spans and a playhead: one slider you click, drag or key to seek, zoom, and a range to select. */
6869
6878
  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 }) {
@@ -6912,7 +6921,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
6912
6921
  const span = Math.max(v1 - v0, 1e-6);
6913
6922
  const zoomBy = (factor, about) => {
6914
6923
  const centre = about ?? (time >= v0 && time <= v1 ? time : (v0 + v1) / 2);
6915
- const next = clamp$2(span * factor, Math.min(duration, .5), duration);
6924
+ const next = clamp$3(span * factor, Math.min(duration, .5), duration);
6916
6925
  const from = centre - (centre - v0) / span * next;
6917
6926
  setView(next >= duration - 1e-6 ? null : clampView(from, next, duration));
6918
6927
  };
@@ -6987,8 +6996,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
6987
6996
  minValue: v0,
6988
6997
  maxValue: Math.max(v1, v0 + .01),
6989
6998
  step: .01,
6990
- value: [clamp$2(time, v0, Math.max(v1, v0 + .01))],
6991
- onChange: ([t]) => onSeek(clamp$2(t, 0, duration)),
6999
+ value: [clamp$3(time, v0, Math.max(v1, v0 + .01))],
7000
+ onChange: ([t]) => onSeek(clamp$3(t, 0, duration)),
6992
7001
  numberFormatter: timeText,
6993
7002
  isDisabled: off
6994
7003
  });
@@ -7004,7 +7013,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7004
7013
  isDisabled: off
7005
7014
  }, state);
7006
7015
  const { focusProps, isFocusVisible } = useFocusRing();
7007
- const seekTo = (t) => onSeek(clamp$2(t, 0, duration));
7016
+ const seekTo = (t) => onSeek(clamp$3(t, 0, duration));
7008
7017
  const onKeyDownCapture = (e) => {
7009
7018
  if (off) return;
7010
7019
  const big = e.shiftKey ? bigStep : step;
@@ -7077,8 +7086,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7077
7086
  for (let x = 0; x < width; x += column) {
7078
7087
  const [lo, hi] = peaksBetween(pair, (v0 + x / width * (v1 - v0)) / duration, (v0 + (x + column) / width * (v1 - v0)) / duration);
7079
7088
  if (!Number.isFinite(lo)) continue;
7080
- const top = 50 - clamp$2(hi * gain, -1, 1) * 48;
7081
- const bottom = 50 - clamp$2(lo * gain, -1, 1) * 48;
7089
+ const top = 50 - clamp$3(hi * gain, -1, 1) * 48;
7090
+ const bottom = 50 - clamp$3(lo * gain, -1, 1) * 48;
7082
7091
  d += `M${x + .5} ${top.toFixed(1)}V${Math.max(bottom, top + 1).toFixed(1)}`;
7083
7092
  }
7084
7093
  return d;
@@ -7152,8 +7161,8 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7152
7161
  })
7153
7162
  }) }),
7154
7163
  spans.map((s) => {
7155
- const a = clamp$2(px(s.from), 0, width);
7156
- const b = clamp$2(px(s.to), 0, width);
7164
+ const a = clamp$3(px(s.from), 0, width);
7165
+ const b = clamp$3(px(s.to), 0, width);
7157
7166
  const tone = TONE$1[s.tone ?? "neutral"];
7158
7167
  return b > a ? /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
7159
7168
  x: a,
@@ -7171,9 +7180,9 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7171
7180
  })] }, `${s.from}-${s.to}-${s.label}`) : null;
7172
7181
  }),
7173
7182
  shown && /* @__PURE__ */ jsx("rect", {
7174
- x: clamp$2(px(shown[0]), 0, width),
7183
+ x: clamp$3(px(shown[0]), 0, width),
7175
7184
  y: 0,
7176
- width: Math.max(clamp$2(px(shown[1]), 0, width) - clamp$2(px(shown[0]), 0, width), 1),
7185
+ width: Math.max(clamp$3(px(shown[1]), 0, width) - clamp$3(px(shown[0]), 0, width), 1),
7177
7186
  height: 100,
7178
7187
  fill: "var(--primary-5)",
7179
7188
  opacity: .45
@@ -7247,7 +7256,7 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7247
7256
  children: /* @__PURE__ */ jsx("div", {
7248
7257
  ...thumbProps,
7249
7258
  className: "absolute inset-y-0 w-0",
7250
- style: { left: `${clamp$2((time - v0) / span, 0, 1) * 100}%` },
7259
+ style: { left: `${clamp$3((time - v0) / span, 0, 1) * 100}%` },
7251
7260
  children: /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", {
7252
7261
  ref: input,
7253
7262
  ...mergeProps(inputProps, focusProps, { "aria-describedby": summaryId }),
@@ -7310,6 +7319,174 @@ function Waveform({ label, peaks, source, duration: given, time, onSeek, marks =
7310
7319
  ]
7311
7320
  });
7312
7321
  }
7322
+ // src/components/use-timeline.ts
7323
+ var clamp$2 = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
7324
+ /** A playhead the app owns, in the shape `Transport`, `SeekBar` and `transportShortcuts` take. */
7325
+ function useTimeline({ duration, rate = 1, frame = 1 / 30, loop = false, startAt = "start", group, keys = true }) {
7326
+ const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
7327
+ const [at, setAt] = React.useState(null);
7328
+ const [playing, setPlaying] = React.useState(false);
7329
+ const time = clamp$2(at ?? (startAt === "end" ? length : 0), 0, length);
7330
+ const live = React.useRef({
7331
+ time,
7332
+ length,
7333
+ rate,
7334
+ loop
7335
+ });
7336
+ live.current = {
7337
+ time,
7338
+ length,
7339
+ rate,
7340
+ loop
7341
+ };
7342
+ const member = React.useRef(null);
7343
+ if (!member.current) {
7344
+ const listeners = /* @__PURE__ */ new Set();
7345
+ member.current = {
7346
+ paused: true,
7347
+ pause: () => {},
7348
+ addEventListener: (_, l) => void listeners.add(l),
7349
+ removeEventListener: (_, l) => void listeners.delete(l),
7350
+ start: () => listeners.forEach((l) => l())
7351
+ };
7352
+ }
7353
+ const contextGroup = useMediaGroupName();
7354
+ const name = group ?? contextGroup;
7355
+ React.useEffect(() => name && member.current ? joinMediaGroup(name, member.current) : void 0, [name]);
7356
+ const pause = React.useCallback(() => setPlaying(false), []);
7357
+ if (member.current) {
7358
+ member.current.paused = !playing;
7359
+ member.current.pause = pause;
7360
+ }
7361
+ const play = React.useCallback(() => {
7362
+ const { time: t, length: n, loop: again } = live.current;
7363
+ if (n === 0) return;
7364
+ if (t >= n && !again) setAt(0);
7365
+ else setAt(t);
7366
+ setPlaying(true);
7367
+ member.current?.start();
7368
+ }, []);
7369
+ const seek = React.useCallback((to) => {
7370
+ setAt(clamp$2(to, 0, live.current.length));
7371
+ setPlaying(false);
7372
+ }, []);
7373
+ const toggle = React.useCallback(() => playing ? pause() : play(), [
7374
+ playing,
7375
+ pause,
7376
+ play
7377
+ ]);
7378
+ React.useEffect(() => {
7379
+ if (!playing) return;
7380
+ let last = performance.now();
7381
+ let id = requestAnimationFrame(function tick() {
7382
+ const now = performance.now();
7383
+ const { time: t, length: n, rate: r, loop: again } = live.current;
7384
+ let next = t + (now - last) / 1e3 * r;
7385
+ last = now;
7386
+ if (next >= n) {
7387
+ if (again) next = n > 0 ? next % n : 0;
7388
+ else {
7389
+ setAt(n);
7390
+ setPlaying(false);
7391
+ return;
7392
+ }
7393
+ }
7394
+ live.current = {
7395
+ ...live.current,
7396
+ time: next
7397
+ };
7398
+ setAt(next);
7399
+ id = requestAnimationFrame(tick);
7400
+ });
7401
+ return () => cancelAnimationFrame(id);
7402
+ }, [playing]);
7403
+ const owner = useKeyOwner(keys, playing);
7404
+ const regionProps = React.useMemo(() => ({
7405
+ onFocusCapture: owner.claim,
7406
+ onPointerDownCapture: owner.claim
7407
+ }), [owner.claim]);
7408
+ return {
7409
+ time,
7410
+ duration: length,
7411
+ playing,
7412
+ ended: !playing && length > 0 && time >= length && !loop,
7413
+ rate,
7414
+ frame,
7415
+ play,
7416
+ pause,
7417
+ toggle,
7418
+ seek,
7419
+ step: (count) => seek(live.current.time + count * frame),
7420
+ ownsKeys: owner.owns,
7421
+ regionProps
7422
+ };
7423
+ }
7424
+ // src/components/timeline-player.tsx
7425
+ /** 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. */
7426
+ function TimelinePlayer({ clock, label, stage, rates, onRateChange, legend = false, className }) {
7427
+ const bar = React.useRef(null);
7428
+ const fps = Math.max(1, Math.round(1 / clock.frame));
7429
+ const shortcuts = transportShortcuts({
7430
+ toggle: clock.toggle,
7431
+ seek: clock.seek,
7432
+ time: clock.time,
7433
+ duration: clock.duration,
7434
+ frame: clock.frame,
7435
+ stageKeys: true
7436
+ });
7437
+ const { live } = useHotkeys(shortcuts, {
7438
+ enabled: clock.ownsKeys,
7439
+ within: bar
7440
+ });
7441
+ return /* @__PURE__ */ jsxs("div", {
7442
+ role: "group",
7443
+ "aria-label": label,
7444
+ ...clock.regionProps,
7445
+ className: cn("grid min-w-0 gap-2", className),
7446
+ children: [
7447
+ /* @__PURE__ */ jsx("div", {
7448
+ className: "min-w-0",
7449
+ children: stage
7450
+ }),
7451
+ /* @__PURE__ */ jsxs("div", {
7452
+ ref: bar,
7453
+ className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",
7454
+ children: [
7455
+ /* @__PURE__ */ jsx(Transport, {
7456
+ playing: clock.playing,
7457
+ onPlayPause: clock.toggle,
7458
+ onToStart: () => clock.seek(0),
7459
+ onToEnd: () => clock.seek(clock.duration),
7460
+ onStepBack: () => clock.step(-1),
7461
+ onStepForward: () => clock.step(1),
7462
+ className: "shrink-0"
7463
+ }),
7464
+ /* @__PURE__ */ jsx(SeekBar, {
7465
+ time: clock.time,
7466
+ duration: clock.duration,
7467
+ onSeek: clock.seek,
7468
+ label: `Seek ${label}`,
7469
+ precision: "frames",
7470
+ fps,
7471
+ step: Math.max(clock.frame, clock.duration / 50)
7472
+ }),
7473
+ /* @__PURE__ */ jsx(TimeReadout, {
7474
+ time: clock.time,
7475
+ duration: clock.duration,
7476
+ precision: "frames",
7477
+ fps
7478
+ }),
7479
+ rates && onRateChange && /* @__PURE__ */ jsx(RateChoice, {
7480
+ rate: clock.rate,
7481
+ onRateChange,
7482
+ rates
7483
+ })
7484
+ ]
7485
+ }),
7486
+ legend && /* @__PURE__ */ jsx(KeysLegend, { shortcuts: live })
7487
+ ]
7488
+ });
7489
+ }
7313
7490
  // src/lib/timeline.ts
7314
7491
  /** 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. */
7315
7492
  var STEPS = [
@@ -9468,6 +9645,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
9468
9645
  value: state,
9469
9646
  children: /* @__PURE__ */ jsx("aside", {
9470
9647
  ref: root,
9648
+ "data-part": "inspector",
9471
9649
  tabIndex: -1,
9472
9650
  "aria-labelledby": title === null ? void 0 : headingId,
9473
9651
  "aria-label": title === null ? "Properties" : void 0,
@@ -9476,6 +9654,7 @@ function Inspector({ title, kind, empty, selectionKey, storageKey, actions, summ
9476
9654
  className: "grid grid-cols-1 gap-4",
9477
9655
  children: [
9478
9656
  /* @__PURE__ */ jsxs("header", {
9657
+ "data-part": "inspector-header",
9479
9658
  className: "flex items-start gap-3",
9480
9659
  children: [/* @__PURE__ */ jsxs("div", {
9481
9660
  className: "min-w-0 flex-1",
@@ -9513,6 +9692,7 @@ function InspectorSection({ id, title, defaultOpen = true, actions, children, cl
9513
9692
  const expanded = inspector ? inspector.isOpen(id, defaultOpen) : own;
9514
9693
  const onChange = (open) => inspector ? inspector.setOpen(id, open) : setOwn(open);
9515
9694
  return /* @__PURE__ */ jsx(Disclosure$1, {
9695
+ "data-part": "inspector-section",
9516
9696
  isExpanded: expanded,
9517
9697
  onExpandedChange: onChange,
9518
9698
  className: cn("min-w-0 border-t border-border first:border-t-0", className),
@@ -16724,6 +16904,7 @@ function Workspace({ label, state, narrowBelow = 720, onFiles, acceptLabel, clas
16724
16904
  /** 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. */
16725
16905
  function WorkspaceBar({ title, status, actions, end, className }) {
16726
16906
  return /* @__PURE__ */ jsxs("header", {
16907
+ "data-part": "workspace-bar",
16727
16908
  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),
16728
16909
  children: [
16729
16910
  /* @__PURE__ */ jsx("h1", {
@@ -16781,6 +16962,7 @@ function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollap
16781
16962
  id: `pane-${id}`,
16782
16963
  "aria-labelledby": headingId,
16783
16964
  "data-pane": id,
16965
+ "data-part": "pane",
16784
16966
  "data-collapsed": folded || void 0,
16785
16967
  "data-grow": grow || void 0,
16786
16968
  "data-min": grow ? least : void 0,
@@ -16788,10 +16970,12 @@ function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollap
16788
16970
  style,
16789
16971
  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),
16790
16972
  children: [/* @__PURE__ */ jsxs("header", {
16973
+ "data-part": "pane-header",
16791
16974
  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"),
16792
16975
  children: [
16793
16976
  /* @__PURE__ */ jsx("h2", {
16794
16977
  id: headingId,
16978
+ "data-part": "pane-title",
16795
16979
  className: cn("type-label min-w-0 flex-1 truncate", rail && "sr-only"),
16796
16980
  children: name
16797
16981
  }),
@@ -19974,6 +20158,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
19974
20158
  ]
19975
20159
  });
19976
20160
  }
19977
- 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, 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, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
20161
+ 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, followAim, 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, useSettledStatus, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
19978
20162
 
19979
20163
  //# sourceMappingURL=index.js.map