@hyperframes/studio 0.8.228 → 0.8.230

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.
Files changed (31) hide show
  1. package/dist/assets/{hyperframes-player-Cf70g7g5.js → hyperframes-player-Dv5Ew1Dr.js} +1 -1
  2. package/dist/assets/{index-KTleZEQO.js → index-BvqtI0ko.js} +160 -160
  3. package/dist/assets/{index-Ds4bLp7M.js → index-hiL49K7x.js} +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.html +1 -1
  6. package/dist/index.js +2171 -2003
  7. package/package.json +8 -8
  8. package/src/components/TimelineToolPicker.tsx +6 -4
  9. package/src/components/TimelineToolbar.tsx +22 -17
  10. package/src/components/editor/GestureRecordControl.tsx +8 -3
  11. package/src/components/editor/PropertyPanelFlatFooter.tsx +3 -1
  12. package/src/components/editor/SnapToolbar.tsx +11 -5
  13. package/src/hooks/appHotkeysDispatch.ts +25 -26
  14. package/src/hooks/useAppHotkeys.test.ts +58 -0
  15. package/src/hooks/useKeyframeKeyboard.ts +2 -2
  16. package/src/index.ts +9 -1
  17. package/src/player/components/ClipContextMenu.tsx +6 -3
  18. package/src/player/components/PlayerControls.tsx +3 -2
  19. package/src/player/components/ShortcutsPanel.tsx +3 -2
  20. package/src/player/components/VideoThumbnail.test.tsx +59 -0
  21. package/src/player/components/VideoThumbnail.tsx +36 -12
  22. package/src/player/components/studioShortcuts.test.tsx +109 -0
  23. package/src/player/components/studioShortcuts.ts +187 -94
  24. package/src/player/components/useTimelineClipDrag.resize.test.tsx +16 -0
  25. package/src/player/components/useTimelineClipDrag.ts +2 -0
  26. package/src/player/hooks/usePlaybackKeyboard.test.ts +78 -1
  27. package/src/player/hooks/usePlaybackKeyboard.ts +36 -40
  28. package/src/player/hooks/useShadowPreviewReload.ts +11 -4
  29. package/src/player/hooks/useShadowReloadRetry.ts +68 -0
  30. package/src/player/hooks/useTimelinePlayer.shadowRetry.test.ts +85 -0
  31. package/src/player/lib/playbackShortcuts.ts +12 -0
@@ -104,6 +104,33 @@ function useVideoThumbnailSnapshot(
104
104
  return selectThumbnailSnapshot(posterSnapshot, richSnapshot, shownSnapshot);
105
105
  }
106
106
 
107
+ function useRangeHeldDuringTrim(
108
+ props: Required<
109
+ Pick<VideoThumbnailProps, "videoSrc" | "duration" | "projectId" | "sessionEpoch" | "priority">
110
+ > &
111
+ Pick<VideoThumbnailProps, "sourceStart" | "sourceRangeDuration">,
112
+ ) {
113
+ const {
114
+ videoSrc,
115
+ sourceStart,
116
+ sourceRangeDuration,
117
+ duration,
118
+ projectId,
119
+ sessionEpoch,
120
+ priority,
121
+ } = props;
122
+ const range = useValueAtRest(
123
+ useMemo(
124
+ () => ({ sourceStart, sourceRangeDuration, duration }),
125
+ [duration, sourceRangeDuration, sourceStart],
126
+ ),
127
+ );
128
+ return useMemo(
129
+ () => ({ videoSrc, ...range, projectId, sessionEpoch, priority }),
130
+ [priority, projectId, range, sessionEpoch, videoSrc],
131
+ );
132
+ }
133
+
107
134
  /** Sparse, bounded video frames supplied by the shared thumbnail scheduler. */
108
135
  export const VideoThumbnail = memo(function VideoThumbnail({
109
136
  videoSrc,
@@ -122,18 +149,15 @@ export const VideoThumbnail = memo(function VideoThumbnail({
122
149
  computeThumbnailStrip(container.width, 16 / 9, container.height).frameCount,
123
150
  ),
124
151
  );
125
- const requestProps = useMemo(
126
- () => ({
127
- videoSrc,
128
- sourceStart,
129
- sourceRangeDuration,
130
- duration,
131
- projectId,
132
- sessionEpoch,
133
- priority,
134
- }),
135
- [duration, priority, projectId, sessionEpoch, sourceRangeDuration, sourceStart, videoSrc],
136
- );
152
+ const requestProps = useRangeHeldDuringTrim({
153
+ videoSrc,
154
+ sourceStart,
155
+ sourceRangeDuration,
156
+ duration,
157
+ projectId,
158
+ sessionEpoch,
159
+ priority,
160
+ });
137
161
  const posterRequest = useMemo(
138
162
  () => createVideoThumbnailRequest(requestProps, 1, false),
139
163
  [requestProps],
@@ -0,0 +1,109 @@
1
+ // @vitest-environment happy-dom
2
+ import React, { act } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { afterEach, describe, expect, it, vi } from "vitest";
5
+ import {
6
+ DEFAULT_SHORTCUT_SECTIONS,
7
+ DEFAULT_STUDIO_KEYS,
8
+ getShortcutSections,
9
+ getStudioKey,
10
+ setStudioKeys,
11
+ useStudioKeys,
12
+ } from "./studioShortcuts";
13
+
14
+ (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
15
+
16
+ afterEach(() => {
17
+ setStudioKeys(null);
18
+ document.body.innerHTML = "";
19
+ vi.restoreAllMocks();
20
+ });
21
+
22
+ const hintFor = (label: string) =>
23
+ getShortcutSections()
24
+ .flatMap((s) => s.hints)
25
+ .find((h) => h.label === label)?.key;
26
+
27
+ describe("studio key resolver", () => {
28
+ it("answers today's keys when no host overrides anything", () => {
29
+ expect(DEFAULT_STUDIO_KEYS).toMatchObject({
30
+ mute: "m",
31
+ pause: "k",
32
+ shuttleBack: "j",
33
+ shuttleForward: "l",
34
+ inPoint: "i",
35
+ outPoint: "o",
36
+ seekToIn: "a",
37
+ seekToOut: "e",
38
+ fullscreen: "f",
39
+ split: "s",
40
+ record: "r",
41
+ addKeyframe: "k",
42
+ audioGain: "g",
43
+ zoomSelection: "z",
44
+ selectTool: "v",
45
+ razorTool: "b",
46
+ selectLeftward: "[",
47
+ selectRightward: "]",
48
+ exitRazor: "a",
49
+ snap: "s",
50
+ grid: "g",
51
+ timelineSnap: "n",
52
+ });
53
+ expect(getShortcutSections()).toEqual(DEFAULT_SHORTCUT_SECTIONS);
54
+ });
55
+
56
+ it("normalises an override to lower case and leaves the other actions alone", () => {
57
+ setStudioKeys({ mute: "X" });
58
+ expect(getStudioKey("mute")).toBe("x");
59
+ expect(getStudioKey("fullscreen")).toBe("f");
60
+ });
61
+
62
+ it("lists the remapped key in the shortcut list", () => {
63
+ setStudioKeys({ mute: "x", seekToIn: "u" });
64
+ expect(hintFor("Toggle mute")).toBe("X");
65
+ expect(hintFor("Jump to in-point")).toBe("U");
66
+ expect(hintFor("Toggle loop")).toBe("⇧L");
67
+ setStudioKeys({ shuttleForward: "y" });
68
+ expect(hintFor("Play forward")).toBe("Y");
69
+ expect(hintFor("Toggle loop")).toBe("⇧Y");
70
+ });
71
+
72
+ it("refuses a map that binds two actions to one key and keeps every default", () => {
73
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
74
+ setStudioKeys({ mute: "x", razorTool: "x" });
75
+ expect(getStudioKey("mute")).toBe("m");
76
+ expect(getStudioKey("razorTool")).toBe("b");
77
+ setStudioKeys({ mute: "x", razorTool: "x" });
78
+ expect(warn).toHaveBeenCalledTimes(2);
79
+ });
80
+
81
+ it("refuses a key that is not one character", () => {
82
+ vi.spyOn(console, "warn").mockImplementation(() => {});
83
+ setStudioKeys({ razorTool: "y", mute: "ctrl" });
84
+ expect(getStudioKey("mute")).toBe("m");
85
+ expect(getStudioKey("razorTool")).toBe("b");
86
+ setStudioKeys({ razorTool: "y", toString: "z" } as never);
87
+ expect(getStudioKey("razorTool")).toBe("b");
88
+ });
89
+
90
+ it("still lets the keys Studio already shares (K stop/keyframe, S split/snap) share", () => {
91
+ setStudioKeys({ mute: "x" });
92
+ expect(getStudioKey("pause")).toBe(getStudioKey("addKeyframe"));
93
+ expect(getStudioKey("mute")).toBe("x");
94
+ });
95
+
96
+ it("re-renders a component using the hook when the host swaps the map", () => {
97
+ function Probe() {
98
+ return <span data-probe>{useStudioKeys().razorTool}</span>;
99
+ }
100
+ const host = document.createElement("div");
101
+ document.body.append(host);
102
+ const root = createRoot(host);
103
+ act(() => root.render(<Probe />));
104
+ expect(host.textContent).toBe("b");
105
+ act(() => setStudioKeys({ razorTool: "y" }));
106
+ expect(host.textContent).toBe("y");
107
+ act(() => root.unmount());
108
+ });
109
+ });
@@ -1,12 +1,98 @@
1
- /** Bare keys Studio's hotkeys bind; the shortcuts list names them from here. */
2
- export const STUDIO_PLAIN_KEYS = {
1
+ import { useSyncExternalStore } from "react";
2
+
3
+ /** Every single-character bare key Studio answers, by action. */
4
+ export const DEFAULT_STUDIO_KEYS = {
3
5
  fullscreen: "f",
4
6
  split: "s",
5
7
  record: "r",
6
8
  addKeyframe: "k",
7
9
  audioGain: "g",
8
10
  zoomSelection: "z",
9
- } as const;
11
+ mute: "m",
12
+ pause: "k",
13
+ shuttleBack: "j",
14
+ shuttleForward: "l",
15
+ inPoint: "i",
16
+ outPoint: "o",
17
+ seekToIn: "a",
18
+ seekToOut: "e",
19
+ selectTool: "v",
20
+ razorTool: "b",
21
+ selectLeftward: "[",
22
+ selectRightward: "]",
23
+ exitRazor: "a",
24
+ snap: "s",
25
+ grid: "g",
26
+ timelineSnap: "n",
27
+ };
28
+
29
+ export type StudioKeyAction = keyof typeof DEFAULT_STUDIO_KEYS;
30
+ export type StudioKeys = Readonly<Record<StudioKeyAction, string>>;
31
+
32
+ const SHARED_BY_DESIGN: ReadonlyArray<readonly [StudioKeyAction, StudioKeyAction]> = [
33
+ ["pause", "addKeyframe"],
34
+ ["seekToIn", "exitRazor"],
35
+ ["split", "snap"],
36
+ ["audioGain", "grid"],
37
+ ];
38
+
39
+ let current: StudioKeys = DEFAULT_STUDIO_KEYS;
40
+ const listeners = new Set<() => void>();
41
+
42
+ const sharedByDesign = (a: StudioKeyAction, b: StudioKeyAction) =>
43
+ SHARED_BY_DESIGN.some(([x, y]) => (x === a && y === b) || (x === b && y === a));
44
+
45
+ function findClash(keys: StudioKeys): string | null {
46
+ const actions = Object.keys(keys) as StudioKeyAction[];
47
+ for (const [i, a] of actions.entries()) {
48
+ for (const b of actions.slice(i + 1)) {
49
+ if (keys[a] === keys[b] && !sharedByDesign(a, b)) return `${a} and ${b} both on "${keys[a]}"`;
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+
55
+ function resolve(overrides: Partial<Record<StudioKeyAction, string>>): StudioKeys {
56
+ const next: Record<string, string> = { ...DEFAULT_STUDIO_KEYS };
57
+ for (const [action, key] of Object.entries(overrides)) {
58
+ if (
59
+ !Object.hasOwn(DEFAULT_STUDIO_KEYS, action) ||
60
+ typeof key !== "string" ||
61
+ [...key].length !== 1
62
+ ) {
63
+ console.warn(
64
+ `Studio keys: using defaults, "${action}" is not a known action with one character`,
65
+ );
66
+ return DEFAULT_STUDIO_KEYS;
67
+ }
68
+ next[action] = key.toLowerCase();
69
+ }
70
+ const clash = findClash(next as StudioKeys);
71
+ if (!clash) return next as StudioKeys;
72
+ console.warn(`Studio keys: using defaults, ${clash}`);
73
+ return DEFAULT_STUDIO_KEYS;
74
+ }
75
+
76
+ /** Replaces the host key map; a bad map is refused whole. null restores the defaults. */
77
+ export function setStudioKeys(overrides: Partial<Record<StudioKeyAction, string>> | null) {
78
+ current = overrides ? resolve(overrides) : DEFAULT_STUDIO_KEYS;
79
+ for (const listener of listeners) listener();
80
+ }
81
+
82
+ export const getStudioKeys = (): StudioKeys => current;
83
+ export const getStudioKey = (action: StudioKeyAction): string => current[action];
84
+
85
+ function subscribe(listener: () => void) {
86
+ listeners.add(listener);
87
+ return () => listeners.delete(listener);
88
+ }
89
+
90
+ export const useStudioKeys = (): StudioKeys => useSyncExternalStore(subscribe, getStudioKeys);
91
+
92
+ export function useShortcutSections(host?: readonly ShortcutSection[]): readonly ShortcutSection[] {
93
+ const keys = useStudioKeys();
94
+ return host ?? buildShortcutSections(keys);
95
+ }
10
96
 
11
97
  export interface ShortcutHint {
12
98
  key: string;
@@ -20,94 +106,101 @@ export interface ShortcutSection {
20
106
 
21
107
  const hintKey = (key: string) => key.toUpperCase();
22
108
 
23
- export const SPLIT_SHORTCUT_HINT = hintKey(STUDIO_PLAIN_KEYS.split);
24
- export const ZOOM_SELECTION_SHORTCUT_HINT = hintKey(STUDIO_PLAIN_KEYS.zoomSelection);
25
-
26
- /** What PlayerControls' shortcuts panel lists unless an embedder passes its own sections. */
27
- export const DEFAULT_SHORTCUT_SECTIONS: readonly ShortcutSection[] = [
28
- {
29
- title: "Playback",
30
- hints: [
31
- { key: "Space", label: "Play / Pause" },
32
- { key: "J", label: "Play backward" },
33
- { key: "K", label: "Stop" },
34
- { key: "L", label: "Play forward" },
35
- { key: "M", label: "Toggle mute" },
36
- { key: "⇧L", label: "Toggle loop" },
37
- { key: "←/→", label: "Step 1 frame" },
38
- { key: "⇧←/⇧→", label: "Step 10 frames" },
39
- { key: hintKey(STUDIO_PLAIN_KEYS.fullscreen), label: "Toggle fullscreen" },
40
- ],
41
- },
42
- {
43
- title: "Keyframes (when an element is selected)",
44
- hints: [
45
- { key: hintKey(STUDIO_PLAIN_KEYS.addKeyframe), label: "Add / remove keyframe at playhead" },
46
- { key: "Del", label: "Delete selected keyframe" },
47
- { key: hintKey(STUDIO_PLAIN_KEYS.record), label: "Record gesture" },
48
- ],
49
- },
50
- {
51
- title: "Editing",
52
- hints: [
53
- { key: "⌘Z", label: "Undo" },
54
- { key: "⌘⇧Z", label: "Redo" },
55
- { key: "⌘C", label: "Copy element" },
56
- { key: "⌘V", label: "Paste element" },
57
- { key: "⌘X", label: "Cut element" },
58
- { key: SPLIT_SHORTCUT_HINT, label: "Split clip at playhead" },
59
- { key: ZOOM_SELECTION_SHORTCUT_HINT, label: "Zoom timeline to selected clips" },
60
- { key: hintKey(STUDIO_PLAIN_KEYS.audioGain), label: "Audio Gain for clips with sound" },
61
- { key: "⇧Click", label: "Razor tool: split all tracks" },
62
- { key: "[", label: "Select clips starting before the playhead" },
63
- { key: "]", label: "Select clips running at or after the playhead" },
64
- { key: "⌘G", label: "Group elements" },
65
- { key: "⌘⇧G", label: "Ungroup" },
66
- { key: "Del", label: "Delete selected element (no keyframe selected)" },
67
- ],
68
- },
69
- {
70
- title: "Gesture recording modifiers",
71
- hints: [
72
- { key: "Drag", label: "Record x / y position" },
73
- { key: "Scroll", label: "Record z depth" },
74
- { key: "⇧ Drag", label: "Record rotationX / rotationY" },
75
- { key: "⌥ Drag", label: "Record rotation" },
76
- { key: "⌘ Drag↕", label: "Record opacity" },
77
- { key: "⌘ Scroll", label: "Record scale" },
78
- ],
79
- },
80
- {
81
- title: "Canvas",
82
- hints: [
83
- { key: "Drag", label: "Move element / add keyframe" },
84
- { key: "⌥ Drag", label: "Move entire animation path" },
85
- { key: "⇧ Drag", label: "Uniform resize" },
86
- ],
87
- },
88
- {
89
- title: "Crop",
90
- hints: [
91
- { key: "Drag edge", label: "Crop a side" },
92
- { key: "Drag center", label: "Reposition the crop" },
93
- ],
94
- },
95
- {
96
- title: "Panels",
97
- hints: [
98
- { key: "⌘1", label: "Compositions tab" },
99
- { key: "⌘2", label: "Assets tab" },
100
- ],
101
- },
102
- {
103
- title: "Work area",
104
- hints: [
105
- { key: "I", label: "Set in-point" },
106
- { key: "⇧I", label: "Clear in-point" },
107
- { key: "O", label: "Set out-point" },
108
- { key: "⇧O", label: "Clear out-point" },
109
- { key: "A", label: "Jump to in-point" },
110
- { key: "E", label: "Jump to out-point" },
111
- ],
112
- },
113
- ];
109
+ export const keyHint = (action: StudioKeyAction, keys: StudioKeys = current) =>
110
+ hintKey(keys[action]);
111
+
112
+ export function buildShortcutSections(keys: StudioKeys): readonly ShortcutSection[] {
113
+ const k = (action: StudioKeyAction) => keyHint(action, keys);
114
+ return [
115
+ {
116
+ title: "Playback",
117
+ hints: [
118
+ { key: "Space", label: "Play / Pause" },
119
+ { key: k("shuttleBack"), label: "Play backward" },
120
+ { key: k("pause"), label: "Stop" },
121
+ { key: k("shuttleForward"), label: "Play forward" },
122
+ { key: k("mute"), label: "Toggle mute" },
123
+ { key: `⇧${k("shuttleForward")}`, label: "Toggle loop" },
124
+ { key: "←/→", label: "Step 1 frame" },
125
+ { key: "⇧←/⇧→", label: "Step 10 frames" },
126
+ { key: k("fullscreen"), label: "Toggle fullscreen" },
127
+ ],
128
+ },
129
+ {
130
+ title: "Keyframes (when an element is selected)",
131
+ hints: [
132
+ { key: k("addKeyframe"), label: "Add / remove keyframe at playhead" },
133
+ { key: "Del", label: "Delete selected keyframe" },
134
+ { key: k("record"), label: "Record gesture" },
135
+ ],
136
+ },
137
+ {
138
+ title: "Editing",
139
+ hints: [
140
+ { key: "⌘Z", label: "Undo" },
141
+ { key: "⌘⇧Z", label: "Redo" },
142
+ { key: "⌘C", label: "Copy element" },
143
+ { key: "⌘V", label: "Paste element" },
144
+ { key: "⌘X", label: "Cut element" },
145
+ { key: k("split"), label: "Split clip at playhead" },
146
+ { key: k("zoomSelection"), label: "Zoom timeline to selected clips" },
147
+ { key: k("audioGain"), label: "Audio Gain for clips with sound" },
148
+ { key: "⇧Click", label: "Razor tool: split all tracks" },
149
+ { key: k("selectLeftward"), label: "Select clips starting before the playhead" },
150
+ { key: k("selectRightward"), label: "Select clips running at or after the playhead" },
151
+ { key: "⌘G", label: "Group elements" },
152
+ { key: "⌘⇧G", label: "Ungroup" },
153
+ { key: "Del", label: "Delete selected element (no keyframe selected)" },
154
+ ],
155
+ },
156
+ {
157
+ title: "Gesture recording modifiers",
158
+ hints: [
159
+ { key: "Drag", label: "Record x / y position" },
160
+ { key: "Scroll", label: "Record z depth" },
161
+ { key: "⇧ Drag", label: "Record rotationX / rotationY" },
162
+ { key: "⌥ Drag", label: "Record rotation" },
163
+ { key: "⌘ Drag↕", label: "Record opacity" },
164
+ { key: "⌘ Scroll", label: "Record scale" },
165
+ ],
166
+ },
167
+ {
168
+ title: "Canvas",
169
+ hints: [
170
+ { key: "Drag", label: "Move element / add keyframe" },
171
+ { key: "⌥ Drag", label: "Move entire animation path" },
172
+ { key: "⇧ Drag", label: "Uniform resize" },
173
+ ],
174
+ },
175
+ {
176
+ title: "Crop",
177
+ hints: [
178
+ { key: "Drag edge", label: "Crop a side" },
179
+ { key: "Drag center", label: "Reposition the crop" },
180
+ ],
181
+ },
182
+ {
183
+ title: "Panels",
184
+ hints: [
185
+ { key: "⌘1", label: "Compositions tab" },
186
+ { key: "⌘2", label: "Assets tab" },
187
+ ],
188
+ },
189
+ {
190
+ title: "Work area",
191
+ hints: [
192
+ { key: k("inPoint"), label: "Set in-point" },
193
+ { key: `⇧${k("inPoint")}`, label: "Clear in-point" },
194
+ { key: k("outPoint"), label: "Set out-point" },
195
+ { key: `⇧${k("outPoint")}`, label: "Clear out-point" },
196
+ { key: k("seekToIn"), label: "Jump to in-point" },
197
+ { key: k("seekToOut"), label: "Jump to out-point" },
198
+ ],
199
+ },
200
+ ];
201
+ }
202
+
203
+ export const getShortcutSections = () => buildShortcutSections(current);
204
+
205
+ export const DEFAULT_SHORTCUT_SECTIONS: readonly ShortcutSection[] =
206
+ buildShortcutSections(DEFAULT_STUDIO_KEYS);
@@ -8,6 +8,7 @@ import { usePreviewFrameStore } from "../store/previewFrameStore";
8
8
  import type { BlockedClipState, DraggedClipState, ResizingClipState } from "./useTimelineClipDrag";
9
9
  import { useTimelineClipDrag } from "./useTimelineClipDrag";
10
10
  import { mountReactHarness } from "../../hooks/domSelectionTestHarness";
11
+ import { isTimelineMoving, TIMELINE_REST_MS } from "./timelineMotion";
11
12
 
12
13
  (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
13
14
 
@@ -25,6 +26,7 @@ function el(id: string, over: Partial<TimelineElement> = {}): TimelineElement {
25
26
  }
26
27
 
27
28
  afterEach(() => {
29
+ vi.useRealTimers();
28
30
  document.body.innerHTML = "";
29
31
  usePlayerStore.getState().reset();
30
32
  usePreviewFrameStore.setState({ time: null });
@@ -222,6 +224,20 @@ describe("useTimelineClipDrag — single-clip resize (unchanged path)", () => {
222
224
  h.unmount();
223
225
  });
224
226
 
227
+ it("marks the timeline as moving on every trim move, so thumbnails hold their range", () => {
228
+ vi.useFakeTimers();
229
+ const a = el("a", { start: 0, duration: 2 });
230
+ const h = renderResizeHarness([a], []);
231
+ h.startResize(a, "end");
232
+ act(() => vi.advanceTimersByTime(TIMELINE_REST_MS));
233
+ expect(isTimelineMoving()).toBe(false);
234
+
235
+ h.movePointer(50);
236
+
237
+ expect(isTimelineMoving()).toBe(true);
238
+ h.unmount();
239
+ });
240
+
225
241
  it("does not let an older rejected resize roll back a newer optimistic gesture", async () => {
226
242
  const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
227
243
  const a = el("a", { start: 0, duration: 2 });
@@ -1,5 +1,6 @@
1
1
  import { useRef, useState, useCallback, useMemo, useEffect } from "react";
2
2
  import { useMountEffect } from "../../hooks/useMountEffect";
3
+ import { markTimelineMotion } from "./timelineMotion";
3
4
  import {
4
5
  applyTimelineAutoScrollStep,
5
6
  resolveTimelineAutoScrollLoopAction,
@@ -201,6 +202,7 @@ export function useTimelineClipDrag({
201
202
  const [resizingClip, setResizingClipState] = useState<ResizingClipState | null>(null);
202
203
  const resizingClipRef = useRef<ResizingClipState | null>(null);
203
204
  const publishResizingClip = useCallback((next: ResizingClipState | null) => {
205
+ if (next) markTimelineMotion();
204
206
  resizingClipRef.current = next;
205
207
  setResizingClipState(next);
206
208
  }, []);
@@ -3,14 +3,16 @@
3
3
 
4
4
  import React, { act, useEffect } from "react";
5
5
  import { createRoot } from "react-dom/client";
6
- import { afterEach, describe, expect, it, vi } from "vitest";
6
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
7
7
  import { usePlaybackKeyboard } from "./usePlaybackKeyboard";
8
8
  import { usePlayerStore } from "../store/playerStore";
9
+ import { setStudioKeys } from "../components/studioShortcuts";
9
10
  import { useLinkedClipPreferences } from "../../utils/linkedClipPreferences";
10
11
 
11
12
  globalThis.IS_REACT_ACT_ENVIRONMENT = true;
12
13
 
13
14
  afterEach(() => {
15
+ setStudioKeys(null);
14
16
  document.body.innerHTML = "";
15
17
  usePlayerStore.getState().reset();
16
18
  useLinkedClipPreferences.getState().setCompositionFps(30);
@@ -323,3 +325,78 @@ describe("usePlaybackKeyboard — frame step", () => {
323
325
  expect(spies.seek).toHaveBeenCalledWith((frame + 1) / fps);
324
326
  });
325
327
  });
328
+
329
+ describe("usePlaybackKeyboard — keys the host can remap", () => {
330
+ beforeEach(() => usePlayerStore.setState({ audioMuted: false, loopEnabled: false }));
331
+
332
+ const press = (dispatch: HookHandle["dispatch"], key: string, shiftKey = false) =>
333
+ act(() => {
334
+ dispatch(keydown({ code: `Key${key.toUpperCase()}`, key, shiftKey }));
335
+ });
336
+
337
+ it("answers every default key", () => {
338
+ const { dispatch, release, spies } = setupHook();
339
+ press(dispatch, "m");
340
+ expect(usePlayerStore.getState().audioMuted).toBe(true);
341
+ press(dispatch, "l", true);
342
+ expect(usePlayerStore.getState().loopEnabled).toBe(true);
343
+ press(dispatch, "k");
344
+ expect(spies.pause).toHaveBeenCalledTimes(1);
345
+ act(() => release(keyup({ code: "KeyK", key: "k" })));
346
+ press(dispatch, "j");
347
+ expect(spies.playBackward).toHaveBeenCalledTimes(1);
348
+ press(dispatch, "i");
349
+ expect(usePlayerStore.getState().inPoint).not.toBeNull();
350
+ press(dispatch, "o");
351
+ expect(usePlayerStore.getState().outPoint).not.toBeNull();
352
+ press(dispatch, "a");
353
+ press(dispatch, "e");
354
+ expect(spies.seek).toHaveBeenCalledTimes(2);
355
+ });
356
+
357
+ it("a remapped key answers and the old one does not", () => {
358
+ setStudioKeys({ mute: "x", seekToIn: "u", shuttleForward: "y" });
359
+ const { dispatch, spies } = setupHook();
360
+ press(dispatch, "m");
361
+ expect(usePlayerStore.getState().audioMuted).toBe(false);
362
+ press(dispatch, "x");
363
+ expect(usePlayerStore.getState().audioMuted).toBe(true);
364
+ press(dispatch, "a");
365
+ expect(spies.seek).not.toHaveBeenCalled();
366
+ press(dispatch, "u");
367
+ expect(spies.seek).toHaveBeenCalledTimes(1);
368
+ press(dispatch, "l");
369
+ expect(spies.play).not.toHaveBeenCalled();
370
+ press(dispatch, "y");
371
+ expect(spies.play).toHaveBeenCalledTimes(1);
372
+ press(dispatch, "y", true);
373
+ expect(usePlayerStore.getState().loopEnabled).toBe(true);
374
+ });
375
+
376
+ it("holding the remapped stop key still frame-steps with the remapped shuttle keys", () => {
377
+ setStudioKeys({ pause: "p", shuttleForward: "y" });
378
+ const { dispatch, spies } = setupHook();
379
+ press(dispatch, "p");
380
+ press(dispatch, "y");
381
+ press(dispatch, "j");
382
+ expect(spies.seek).toHaveBeenCalledTimes(2);
383
+ expect(spies.play).not.toHaveBeenCalled();
384
+ expect(spies.playBackward).not.toHaveBeenCalled();
385
+ });
386
+
387
+ it("with the razor armed, jump-to-in still answers when razor-back-to-select moved", () => {
388
+ setStudioKeys({ exitRazor: "x" });
389
+ usePlayerStore.setState({ activeTool: "razor", inPoint: 2 });
390
+ const { dispatch, spies } = setupHook();
391
+ press(dispatch, "a");
392
+ expect(spies.seek).toHaveBeenCalledWith(2, { keepPlaying: true });
393
+ });
394
+
395
+ it("with the razor armed, a remapped jump-to-in key still answers", () => {
396
+ setStudioKeys({ seekToIn: "q" });
397
+ usePlayerStore.setState({ activeTool: "razor", inPoint: 3 });
398
+ const { dispatch, spies } = setupHook();
399
+ press(dispatch, "q");
400
+ expect(spies.seek).toHaveBeenCalledWith(3, { keepPlaying: true });
401
+ });
402
+ });