@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.8.228",
3
+ "version": "0.8.230",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,12 +60,12 @@
60
60
  "dockview-react": "8.3.1",
61
61
  "gsap": "^3.13.0",
62
62
  "mediabunny": "^1.45.3",
63
- "@hyperframes/player": "0.8.228",
64
- "@hyperframes/parsers": "0.8.228",
65
- "@hyperframes/sdk": "0.8.228",
66
- "@hyperframes/shader-transitions": "0.8.228",
67
- "@hyperframes/studio-server": "0.8.228",
68
- "@hyperframes/core": "0.8.228"
63
+ "@hyperframes/parsers": "0.8.230",
64
+ "@hyperframes/sdk": "0.8.230",
65
+ "@hyperframes/player": "0.8.230",
66
+ "@hyperframes/shader-transitions": "0.8.230",
67
+ "@hyperframes/core": "0.8.230",
68
+ "@hyperframes/studio-server": "0.8.230"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@tailwindcss/vite": "^4.3.3",
@@ -82,7 +82,7 @@
82
82
  "vite": "^6.4.2",
83
83
  "vitest": "^4.1.11",
84
84
  "zustand": "^5.0.0",
85
- "@hyperframes/producer": "0.8.228"
85
+ "@hyperframes/producer": "0.8.230"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": "19",
@@ -5,6 +5,7 @@ import { Scissors } from "../icons/SystemIcons";
5
5
  import { Menu, MenuItem } from "./ui";
6
6
  import { cn } from "./ui/cn";
7
7
  import { flatIdle } from "./timelineToolbarStyles";
8
+ import { keyHint, useStudioKeys } from "../player/components/studioShortcuts";
8
9
 
9
10
  function SelectIcon() {
10
11
  return (
@@ -25,18 +26,19 @@ interface ToolRow {
25
26
  /** One button for the active timeline tool; its menu switches tools or selects clips around the playhead. */
26
27
  export function TimelineToolPicker({ showSelectAroundPlayhead = true }) {
27
28
  const activeTool = usePlayerStore((s) => s.activeTool);
29
+ const keys = useStudioKeys();
28
30
  const store = () => usePlayerStore.getState();
29
31
  const rows: ToolRow[] = [
30
32
  {
31
33
  label: "Select",
32
- shortcut: "V",
34
+ shortcut: keyHint("selectTool", keys),
33
35
  icon: <SelectIcon />,
34
36
  active: activeTool === "select",
35
37
  run: () => store().setActiveTool("select"),
36
38
  },
37
39
  {
38
40
  label: "Split",
39
- shortcut: "B",
41
+ shortcut: keyHint("razorTool", keys),
40
42
  icon: <Scissors size={16} />,
41
43
  active: activeTool === "razor",
42
44
  run: () => store().setActiveTool("razor"),
@@ -46,14 +48,14 @@ export function TimelineToolPicker({ showSelectAroundPlayhead = true }) {
46
48
  rows.push(
47
49
  {
48
50
  label: "Select leftward",
49
- shortcut: "[",
51
+ shortcut: keyHint("selectLeftward", keys),
50
52
  icon: <ArrowLineLeft size={16} aria-hidden="true" />,
51
53
  active: false,
52
54
  run: () => store().selectLeftward(),
53
55
  },
54
56
  {
55
57
  label: "Select rightward",
56
- shortcut: "]",
58
+ shortcut: keyHint("selectRightward", keys),
57
59
  icon: <ArrowLineRight size={16} aria-hidden="true" />,
58
60
  active: false,
59
61
  run: () => store().selectRightward(),
@@ -40,10 +40,7 @@ import { LinkedSelectionToggle } from "./LinkedSelectionToggle";
40
40
  import { useProjectHasAudio } from "../utils/audioMeterMath";
41
41
  import { canAddBeatAt, addBeatAtCompositionTime } from "../utils/beatEditActions";
42
42
  import { isTypingTarget } from "../utils/typingTarget";
43
- import {
44
- SPLIT_SHORTCUT_HINT,
45
- ZOOM_SELECTION_SHORTCUT_HINT,
46
- } from "../player/components/studioShortcuts";
43
+ import { getStudioKey, keyHint, useStudioKeys } from "../player/components/studioShortcuts";
47
44
  import type { TimelineProps } from "../player/components/TimelineTypes";
48
45
 
49
46
  interface DomEditSessionSlice extends EnableKeyframesSession {
@@ -155,7 +152,7 @@ function useKeyframeToggle(session?: DomEditSessionSlice) {
155
152
  export const TimelineToolbar = memo(function TimelineToolbar({
156
153
  domEditSession,
157
154
  onSplitElement,
158
- splitShortcut = SPLIT_SHORTCUT_HINT,
155
+ splitShortcut,
159
156
  history,
160
157
  showHistory = true,
161
158
  showSelectAroundPlayhead = true,
@@ -163,6 +160,8 @@ export const TimelineToolbar = memo(function TimelineToolbar({
163
160
  showKeyframes = true,
164
161
  rightActions,
165
162
  }: TimelineToolbarProps) {
163
+ const keys = useStudioKeys();
164
+ const kf = keyHint("addKeyframe", keys);
166
165
  const timelineSnapEnabled = usePlayerStore((s) => s.timelineSnapEnabled);
167
166
  const setTimelineSnapEnabled = usePlayerStore((s) => s.setTimelineSnapEnabled);
168
167
  const rippleEditEnabled = usePlayerStore((s) => s.rippleEditEnabled);
@@ -199,7 +198,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
199
198
  onToggle: onToggleKeyframe,
200
199
  } = useKeyframeToggle(domEditSession);
201
200
 
202
- // Wire the "Add keyframe (K)" shortcut the toolbar advertises. Active only when
201
+ // Wire the Add keyframe shortcut the toolbar advertises. Active only when
203
202
  // there's a keyframeable selection; otherwise K stays JKL-pause in playback.
204
203
  useKeyframeKeyboard({
205
204
  enabled: showKeyframes && Boolean(onToggleKeyframe),
@@ -214,7 +213,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
214
213
  // Skip when typing in an input/contenteditable.
215
214
  useEffect(() => {
216
215
  const onKeyDown = (e: KeyboardEvent) => {
217
- if (e.key !== "n" && e.key !== "N") return;
216
+ if (e.key.toLowerCase() !== getStudioKey("timelineSnap")) return;
218
217
  if (e.metaKey || e.ctrlKey || e.altKey) return;
219
218
  if (isTypingTarget(e.target)) return;
220
219
  const store = usePlayerStore.getState();
@@ -233,7 +232,13 @@ export const TimelineToolbar = memo(function TimelineToolbar({
233
232
  {/* Divider: tool-mode | editing-actions */}
234
233
  <div aria-hidden="true" className="mx-1 h-4 w-px bg-neutral-800" />
235
234
  <LinkedSelectionToggle />
236
- <Tooltip label={timelineSnapEnabled ? "Snapping on (N)" : "Snapping off (N)"}>
235
+ <Tooltip
236
+ label={
237
+ timelineSnapEnabled
238
+ ? `Snapping on (${keyHint("timelineSnap", keys)})`
239
+ : `Snapping off (${keyHint("timelineSnap", keys)})`
240
+ }
241
+ >
237
242
  <button
238
243
  type="button"
239
244
  onClick={() => setTimelineSnapEnabled(!timelineSnapEnabled)}
@@ -286,17 +291,17 @@ export const TimelineToolbar = memo(function TimelineToolbar({
286
291
  ? "Select an animated element to add keyframes"
287
292
  : keyframeIsMotionPath
288
293
  ? keyframeWillExtend
289
- ? "Extend motion path to playhead (K)"
294
+ ? `Extend motion path to playhead (${kf})`
290
295
  : keyframeState === "active"
291
- ? "Remove waypoint from motion path (K)"
292
- : "Add waypoint to motion path (K)"
296
+ ? `Remove waypoint from motion path (${kf})`
297
+ : `Add waypoint to motion path (${kf})`
293
298
  : keyframeState === "active"
294
- ? "Remove keyframe at playhead (K)"
299
+ ? `Remove keyframe at playhead (${kf})`
295
300
  : keyframeState === "inactive"
296
301
  ? keyframeWillExtend
297
- ? "Add keyframe at playhead, extends animation (K)"
298
- : "Add keyframe at playhead (K)"
299
- : "Add keyframe (K)"
302
+ ? `Add keyframe at playhead, extends animation (${kf})`
303
+ : `Add keyframe at playhead (${kf})`
304
+ : `Add keyframe (${kf})`
300
305
  }
301
306
  >
302
307
  <button
@@ -393,7 +398,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
393
398
  <Tooltip
394
399
  label={
395
400
  canSplit
396
- ? `Split at playhead (${splitShortcut})`
401
+ ? `Split at playhead (${splitShortcut ?? keyHint("split", keys)})`
397
402
  : splittable
398
403
  ? "Move the playhead inside the clip to split"
399
404
  : "Select a clip to split"
@@ -502,7 +507,7 @@ export const TimelineToolbar = memo(function TimelineToolbar({
502
507
  <Tooltip
503
508
  label={
504
509
  canZoomSelection
505
- ? `Zoom to selected clips (${ZOOM_SELECTION_SHORTCUT_HINT})`
510
+ ? `Zoom to selected clips (${keyHint("zoomSelection", keys)})`
506
511
  : "Select a clip to zoom the timeline"
507
512
  }
508
513
  >
@@ -1,4 +1,5 @@
1
1
  import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";
2
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
2
3
 
3
4
  export type GestureRecordingState = "idle" | "recording" | "preview";
4
5
 
@@ -29,6 +30,7 @@ export function GestureRecordPanelButton({
29
30
  recordingDuration,
30
31
  onToggleRecording,
31
32
  }: GestureRecordPanelButtonProps) {
33
+ const recordKey = keyHint("record", useStudioKeys());
32
34
  const recording = recordingState === "recording";
33
35
  const track = useTrackDesignInput();
34
36
 
@@ -49,8 +51,8 @@ export function GestureRecordPanelButton({
49
51
  >
50
52
  <GestureRecordIcon recording={recording} />
51
53
  {recording
52
- ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s -- press R`
53
- : "Record gesture (R) -- move pointer to capture motion"}
54
+ ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s -- press ${recordKey}`
55
+ : `Record gesture (${recordKey}) -- move pointer to capture motion`}
54
56
  </button>
55
57
  </div>
56
58
  );
@@ -67,8 +69,11 @@ export function GestureRecordBadge({
67
69
  recordingState,
68
70
  onToggleRecording,
69
71
  }: GestureRecordBadgeProps) {
72
+ const recordKey = keyHint("record", useStudioKeys());
70
73
  const recording = recordingState === "recording";
71
- const label = recording ? "Stop gesture recording (R)" : "Record gesture (R)";
74
+ const label = recording
75
+ ? `Stop gesture recording (${recordKey})`
76
+ : `Record gesture (${recordKey})`;
72
77
 
73
78
  return (
74
79
  <button
@@ -1,4 +1,5 @@
1
1
  import { useTrackDesignInput } from "../../contexts/DesignPanelInputContext";
2
+ import { keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
2
3
 
3
4
  export function PropertyPanelFlatFooter({
4
5
  onAskAgent,
@@ -13,9 +14,10 @@ export function PropertyPanelFlatFooter({
13
14
  }) {
14
15
  const track = useTrackDesignInput();
15
16
  const recording = recordingState === "recording";
17
+ const recordKey = keyHint("record", useStudioKeys());
16
18
  const recordTitle = recording
17
19
  ? `Stop recording ${(recordingDuration ?? 0).toFixed(1)}s`
18
- : "Record gesture (R)";
20
+ : `Record gesture (${recordKey})`;
19
21
 
20
22
  return (
21
23
  // No border-t here: every possible element immediately above this footer
@@ -4,9 +4,11 @@ import { MagnetStraight, GridFour, Path, Ruler, FrameCorners } from "@phosphor-i
4
4
  import { usePlayerStore } from "../../player/store/playerStore";
5
5
  import { usePreviewOverlayContext } from "./PreviewOverlayProvider";
6
6
  import { ownsPlainKeys } from "../../utils/typingTarget";
7
+ import { getStudioKey, keyHint, useStudioKeys } from "../../player/components/studioShortcuts";
7
8
 
8
9
  // fallow-ignore-next-line complexity
9
10
  export const SnapToolbar = memo(function SnapToolbar() {
11
+ const keys = useStudioKeys();
10
12
  const [gridPopoverOpen, setGridPopoverOpen] = useState(false);
11
13
  const { state, actions } = usePreviewOverlayContext();
12
14
  const { snapPrefs: prefs, rulerVisible, safeMarginsVisible } = state;
@@ -51,12 +53,12 @@ export const SnapToolbar = memo(function SnapToolbar() {
51
53
  if (e.defaultPrevented) return;
52
54
  if (ownsPlainKeys(e.target)) return;
53
55
  if (e.target instanceof HTMLIFrameElement) return;
54
- if (e.key === "s" && !e.metaKey && !e.ctrlKey && !e.altKey) {
56
+ if (e.key === getStudioKey("snap") && !e.metaKey && !e.ctrlKey && !e.altKey) {
55
57
  e.preventDefault();
56
58
  updatePrefs({ snapEnabled: !prefs.snapEnabled });
57
59
  if (!e.repeat) trackPreviewFeatureUsed("snapping", "keyboard");
58
60
  }
59
- if (e.key === "g" && !e.metaKey && !e.ctrlKey && !e.altKey) {
61
+ if (e.key === getStudioKey("grid") && !e.metaKey && !e.ctrlKey && !e.altKey) {
60
62
  e.preventDefault();
61
63
  updatePrefs({ gridVisible: !prefs.gridVisible });
62
64
  if (!e.repeat) trackPreviewFeatureUsed("grid", "keyboard");
@@ -137,7 +139,11 @@ export const SnapToolbar = memo(function SnapToolbar() {
137
139
  : "bg-black/40 text-white/60 hover:bg-black/60 hover:text-white/80"
138
140
  }`}
139
141
  onClick={toggleSnap}
140
- title={prefs.snapEnabled ? "Snap enabled (S)" : "Snap disabled (S)"}
142
+ title={
143
+ prefs.snapEnabled
144
+ ? `Snap enabled (${keyHint("snap", keys)})`
145
+ : `Snap disabled (${keyHint("snap", keys)})`
146
+ }
141
147
  aria-label="Toggle snap"
142
148
  >
143
149
  <MagnetStraight size={16} weight={prefs.snapEnabled ? "fill" : "regular"} />
@@ -160,8 +166,8 @@ export const SnapToolbar = memo(function SnapToolbar() {
160
166
  }}
161
167
  title={
162
168
  prefs.gridVisible
163
- ? "Grid visible (G). Right-click for spacing options"
164
- : "Grid hidden (G). Right-click for spacing options"
169
+ ? `Grid visible (${keyHint("grid", keys)}). Right-click for spacing options`
170
+ : `Grid hidden (${keyHint("grid", keys)}). Right-click for spacing options`
165
171
  }
166
172
  aria-label="Toggle grid"
167
173
  >
@@ -8,7 +8,8 @@ import { isEditableTarget } from "../utils/timelineDiscovery";
8
8
  import { shouldIgnoreHistoryShortcut } from "../utils/studioHelpers";
9
9
  import { canSplitElement } from "../utils/timelineElementSplit";
10
10
  import { trackStudioEvent } from "../utils/studioTelemetry";
11
- import { STUDIO_PLAIN_KEYS } from "../player/components/studioShortcuts";
11
+ import { razorClaimsKey } from "../player/lib/playbackShortcuts";
12
+ import { getStudioKeys, keyHint } from "../player/components/studioShortcuts";
12
13
  import { zoomTimelineToSelectedClips } from "../player/components/timelineZoomInput";
13
14
  import { openAudioGainDialog } from "../player/components/audioGainDialogStore";
14
15
  import type { LinkShortcutCallbacks } from "./linkShortcuts";
@@ -157,13 +158,14 @@ export function dispatchModifierKey(
157
158
  * be asserted without standing up the whole hook. */
158
159
  export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCallbacks): void {
159
160
  if (ownsPlainKeys(event.target)) return;
160
- if (key === STUDIO_PLAIN_KEYS.zoomSelection && !event.shiftKey && !event.altKey) {
161
+ const keys = getStudioKeys();
162
+ if (key === keys.zoomSelection && !event.shiftKey && !event.altKey) {
161
163
  if (!zoomTimelineToSelectedClips()) return;
162
164
  event.preventDefault();
163
165
  return;
164
166
  }
165
167
 
166
- if (key === STUDIO_PLAIN_KEYS.fullscreen && !event.shiftKey && !event.altKey) {
168
+ if (key === keys.fullscreen && !event.shiftKey && !event.altKey) {
167
169
  event.preventDefault();
168
170
  if (document.fullscreenElement) void document.exitFullscreen();
169
171
  else
@@ -171,7 +173,7 @@ export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCa
171
173
  return;
172
174
  }
173
175
 
174
- if (event.key === STUDIO_PLAIN_KEYS.split && !event.altKey) {
176
+ if (event.key === keys.split && !event.altKey) {
175
177
  // Reserve bare `s` for Split even when the current selection cannot split,
176
178
  // so secondary listeners do not reinterpret the same key as Snap toggle.
177
179
  event.preventDefault();
@@ -192,51 +194,53 @@ export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCa
192
194
  // that isn't in the raw `elements` list, so the s-key can't resolve them.
193
195
  // Nudge toward the razor tool instead of failing silently.
194
196
  if (!el && selectedElementId.includes("#")) {
195
- cb.showToast("Use the razor tool (B) to split clips inside a sub-composition", "info");
197
+ cb.showToast(
198
+ `Use the razor tool (${keyHint("razorTool", keys)}) to split clips inside a sub-composition`,
199
+ "info",
200
+ );
196
201
  return;
197
202
  }
198
203
  }
199
204
  }
200
205
 
201
206
  // Only with a sound clip selected, so bare G still reaches the canvas grid toggle otherwise.
202
- if (key === STUDIO_PLAIN_KEYS.audioGain && !event.shiftKey && !event.altKey) {
207
+ if (key === keys.audioGain && !event.shiftKey && !event.altKey) {
203
208
  if (!cb.readOnlyPreview && openAudioGainDialog()) {
204
209
  event.preventDefault();
205
210
  return;
206
211
  }
207
212
  }
208
213
 
209
- if (key === "b" && !event.shiftKey && !event.altKey) {
214
+ if (key === keys.razorTool && !event.shiftKey && !event.altKey) {
210
215
  event.preventDefault();
211
216
  const { activeTool, setActiveTool } = usePlayerStore.getState();
212
217
  setActiveTool(activeTool === "razor" ? "select" : "razor");
213
218
  return;
214
219
  }
215
220
 
216
- if (key === "v" && !event.shiftKey && !event.altKey) {
221
+ if (key === keys.selectTool && !event.shiftKey && !event.altKey) {
217
222
  event.preventDefault();
218
223
  usePlayerStore.getState().setActiveTool("select");
219
224
  return;
220
225
  }
221
226
 
222
- if ((key === "[" || key === "]") && !event.shiftKey && !event.altKey) {
227
+ if (
228
+ (key === keys.selectLeftward || key === keys.selectRightward) &&
229
+ !event.shiftKey &&
230
+ !event.altKey
231
+ ) {
223
232
  event.preventDefault();
224
233
  const store = usePlayerStore.getState();
225
- if (key === "[") store.selectLeftward();
234
+ if (key === keys.selectLeftward) store.selectLeftward();
226
235
  else store.selectRightward();
227
236
  return;
228
237
  }
229
238
 
230
- // CapCut returns to the select tool with "A". Scoped to the razor being
231
- // armed; usePlaybackKeyboard.ts's own "A" (seek to in-point) checks the
232
- // same activeTool to stay out of the way.
233
- if (key === "a" && !event.shiftKey && !event.altKey) {
234
- const { activeTool, setActiveTool } = usePlayerStore.getState();
235
- if (activeTool === "razor") {
236
- event.preventDefault();
237
- setActiveTool("select");
238
- return;
239
- }
239
+ // CapCut returns to the select tool with "A"; playback's seek-to-in asks the same razorClaimsKey.
240
+ if (razorClaimsKey(event, key)) {
241
+ event.preventDefault();
242
+ usePlayerStore.getState().setActiveTool("select");
243
+ return;
240
244
  }
241
245
 
242
246
  if (event.key === "Escape") {
@@ -295,12 +299,7 @@ export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCa
295
299
  return;
296
300
  }
297
301
 
298
- if (
299
- event.key === STUDIO_PLAIN_KEYS.record &&
300
- !event.shiftKey &&
301
- !event.altKey &&
302
- cb.onToggleRecording
303
- ) {
302
+ if (event.key === keys.record && !event.shiftKey && !event.altKey && cb.onToggleRecording) {
304
303
  event.preventDefault();
305
304
  cb.onToggleRecording();
306
305
  }
@@ -6,6 +6,7 @@ import type { DomEditSelection } from "../components/editor/domEditing";
6
6
  import { clearAutomationClipboard, copyRange } from "../player/components/automationClipboard";
7
7
  import { VOLUME_RANGE } from "@hyperframes/core/audio-automation";
8
8
  import type { TimelineElement } from "../player/store/timelineElement";
9
+ import { setStudioKeys } from "../player/components/studioShortcuts";
9
10
  import { useAudioGainDialogStore } from "../player/components/audioGainDialogStore";
10
11
  import {
11
12
  cancelTimelineZoom,
@@ -55,6 +56,8 @@ const chord = (key: string) =>
55
56
  new KeyboardEvent("keydown", { key, metaKey: true, bubbles: true, cancelable: true });
56
57
 
57
58
  afterEach(() => {
59
+ setStudioKeys(null);
60
+ usePlayerStore.getState().setActiveTool("select");
58
61
  clearAutomationClipboard();
59
62
  usePlayerStore.getState().clearAutomationSelection();
60
63
  usePlayerStore.setState({
@@ -583,3 +586,58 @@ describe("dispatchPlainKey — G opens Audio Gain", () => {
583
586
  expect(event.defaultPrevented).toBe(false);
584
587
  });
585
588
  });
589
+
590
+ describe("editor keys the host can remap", () => {
591
+ const dispatch = (key: string) => {
592
+ const event = press(key);
593
+ dispatchPlainKey(event, key.toLowerCase(), callbacks());
594
+ return event;
595
+ };
596
+ const tool = () => usePlayerStore.getState().activeTool;
597
+
598
+ it("answers every default key", () => {
599
+ dispatch("b");
600
+ expect(tool()).toBe("razor");
601
+ dispatch("a");
602
+ expect(tool()).toBe("select");
603
+ dispatch("b");
604
+ dispatch("v");
605
+ expect(tool()).toBe("select");
606
+ const original = usePlayerStore.getState().selectLeftward;
607
+ const left = vi.fn();
608
+ usePlayerStore.setState({ selectLeftward: left });
609
+ dispatch("[");
610
+ usePlayerStore.setState({ selectLeftward: original });
611
+ expect(left).toHaveBeenCalledTimes(1);
612
+ });
613
+
614
+ it("a remapped key answers and the old one does not", () => {
615
+ setStudioKeys({ razorTool: "y", selectTool: "u", exitRazor: "q" });
616
+ dispatch("b");
617
+ expect(tool()).toBe("select");
618
+ expect(dispatch("y").defaultPrevented).toBe(true);
619
+ expect(tool()).toBe("razor");
620
+ dispatch("a");
621
+ expect(tool()).toBe("razor");
622
+ dispatch("q");
623
+ expect(tool()).toBe("select");
624
+ dispatch("y");
625
+ dispatch("v");
626
+ expect(tool()).toBe("razor");
627
+ dispatch("u");
628
+ expect(tool()).toBe("select");
629
+ });
630
+
631
+ it("split, fullscreen and record follow the map", () => {
632
+ setStudioKeys({ split: "t", record: "w" });
633
+ const cb = callbacks({ onToggleRecording: vi.fn() });
634
+ dispatchPlainKey(press("r"), "r", cb);
635
+ expect(cb.onToggleRecording).not.toHaveBeenCalled();
636
+ dispatchPlainKey(press("w"), "w", cb);
637
+ expect(cb.onToggleRecording).toHaveBeenCalledTimes(1);
638
+ expect(press("s").defaultPrevented).toBe(false);
639
+ const split = press("t");
640
+ dispatchPlainKey(split, "t", cb);
641
+ expect(split.defaultPrevented).toBe(true);
642
+ });
643
+ });
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useCallback } from "react";
2
- import { STUDIO_PLAIN_KEYS } from "../player/components/studioShortcuts";
2
+ import { getStudioKey } from "../player/components/studioShortcuts";
3
3
  import { isTypingTarget } from "../utils/typingTarget";
4
4
 
5
5
  interface KeyframeKeyboardOptions {
@@ -13,7 +13,7 @@ export function useKeyframeKeyboard({ enabled, onAddKeyframe }: KeyframeKeyboard
13
13
  if (!enabled || !onAddKeyframe) return;
14
14
  if (isTypingTarget(document.activeElement)) return;
15
15
  if (e.metaKey || e.ctrlKey) return; // never shadow browser/system combos
16
- if (e.key.toLowerCase() !== STUDIO_PLAIN_KEYS.addKeyframe) return;
16
+ if (e.key.toLowerCase() !== getStudioKey("addKeyframe")) return;
17
17
  // K is also playback's stop key: claiming it here keeps playback from also pausing.
18
18
  e.preventDefault();
19
19
  e.stopImmediatePropagation();
package/src/index.ts CHANGED
@@ -5,7 +5,15 @@ export * from "./ui";
5
5
  export { EditorShell } from "./components/EditorShell";
6
6
  export type { EditorShellProps } from "./components/EditorShell";
7
7
  export { NLEPreview } from "./components/nle/NLEPreview";
8
- export { DEFAULT_SHORTCUT_SECTIONS } from "./player/components/studioShortcuts";
8
+ export {
9
+ DEFAULT_SHORTCUT_SECTIONS,
10
+ DEFAULT_STUDIO_KEYS,
11
+ buildShortcutSections,
12
+ getStudioKeys,
13
+ setStudioKeys,
14
+ useStudioKeys,
15
+ } from "./player/components/studioShortcuts";
16
+ export type { StudioKeyAction, StudioKeys } from "./player/components/studioShortcuts";
9
17
  export { ShortcutsButton } from "./player/components/ShortcutsPanel";
10
18
  export { dispatchLinkShortcut } from "./hooks/linkShortcuts";
11
19
  export type { LinkShortcutCallbacks } from "./hooks/linkShortcuts";
@@ -10,7 +10,7 @@ import { ClipMenuAudioItems } from "./clipMenuAudioItems";
10
10
  import { ClipMenuLinkItems } from "./clipMenuLinkItems";
11
11
  import { menuClasses } from "../../components/ui/menuStyle";
12
12
  import { useTimelineEditContextOptional } from "../../contexts/TimelineEditContext";
13
- import { SPLIT_SHORTCUT_HINT } from "./studioShortcuts";
13
+ import { keyHint, useStudioKeys } from "./studioShortcuts";
14
14
 
15
15
  const MENU_MARGIN = 8;
16
16
 
@@ -97,8 +97,9 @@ export const ClipContextMenu = memo(function ClipContextMenu({
97
97
  onDuplicate,
98
98
  canPaste,
99
99
  hostItems = [],
100
- splitShortcut = SPLIT_SHORTCUT_HINT,
100
+ splitShortcut,
101
101
  }: ClipContextMenuProps) {
102
+ const keys = useStudioKeys();
102
103
  const menuRef = useContextMenuDismiss(onClose);
103
104
  useMenuKeyboardNav(menuRef);
104
105
  const tools = useTimelineEditContextOptional().clipMenuTools !== false;
@@ -160,7 +161,9 @@ export const ClipContextMenu = memo(function ClipContextMenu({
160
161
  }}
161
162
  >
162
163
  <span>{splitLabel}</span>
163
- <span className="text-neutral-500 text-[10px] ml-3">{splitShortcut}</span>
164
+ <span className="text-neutral-500 text-[10px] ml-3">
165
+ {splitShortcut ?? keyHint("split", keys)}
166
+ </span>
164
167
  </button>
165
168
  )}
166
169
  {tools && splitLabel && (
@@ -8,7 +8,7 @@ import { Tooltip } from "../../components/ui";
8
8
  import { useMountEffect } from "../../hooks/useMountEffect";
9
9
  import { useLinkedClipPreferences } from "../../utils/linkedClipPreferences";
10
10
  import { ShortcutsButton } from "./ShortcutsPanel";
11
- import type { ShortcutSection } from "./studioShortcuts";
11
+ import { keyHint, useStudioKeys, type ShortcutSection } from "./studioShortcuts";
12
12
  import { SpeedMenu } from "./SpeedMenu";
13
13
  import { VolumeControl } from "./VolumeControl";
14
14
  import { PreviewSeekBar } from "./PreviewSeekBar";
@@ -111,8 +111,9 @@ const FullscreenButton = memo(function FullscreenButton({
111
111
  isFullscreen: boolean;
112
112
  onToggleFullscreen: () => void;
113
113
  }) {
114
+ const fsKey = keyHint("fullscreen", useStudioKeys());
114
115
  return (
115
- <Tooltip label={isFullscreen ? "Exit fullscreen (F)" : "Enter fullscreen (F)"}>
116
+ <Tooltip label={isFullscreen ? `Exit fullscreen (${fsKey})` : `Enter fullscreen (${fsKey})`}>
116
117
  <button
117
118
  type="button"
118
119
  onClick={() => {
@@ -4,7 +4,7 @@ import { Popover, Tooltip } from "../../components/ui";
4
4
  import { flatActive, flatIdle } from "../../components/timelineToolbarStyles";
5
5
  import { usePlayerStore } from "../store/playerStore";
6
6
  import { useCompositionFps } from "../../utils/linkedClipPreferences";
7
- import { DEFAULT_SHORTCUT_SECTIONS, type ShortcutSection } from "./studioShortcuts";
7
+ import { useShortcutSections, type ShortcutSection } from "./studioShortcuts";
8
8
 
9
9
  interface ShortcutsPanelProps {
10
10
  disabled: boolean;
@@ -28,8 +28,9 @@ export const ShortcutsPanel = memo(function ShortcutsPanel({
28
28
  setInPoint,
29
29
  setOutPoint,
30
30
  onSeek,
31
- sections = DEFAULT_SHORTCUT_SECTIONS,
31
+ sections: hostSections,
32
32
  }: ShortcutsPanelProps) {
33
+ const sections = useShortcutSections(hostSections);
33
34
  const [showShortcuts, setShowShortcuts] = useState(false);
34
35
  const [jumpFrame, setJumpFrame] = useState("");
35
36
  const compositionFps = useCompositionFps();
@@ -452,3 +452,62 @@ describe("VideoThumbnail during a zoom", () => {
452
452
  );
453
453
  });
454
454
  });
455
+
456
+ describe("VideoThumbnail during a trim", () => {
457
+ beforeEach(() => {
458
+ vi.useFakeTimers({
459
+ toFake: ["setTimeout", "clearTimeout", "requestAnimationFrame", "cancelAnimationFrame"],
460
+ });
461
+ vi.mocked(decodeVideoThumbnail).mockResolvedValue({
462
+ value: { kind: "filmstrip", urls: ["blob:a", "blob:b"], aspect: 16 / 9 },
463
+ weight: 256,
464
+ });
465
+ });
466
+ afterEach(() => {
467
+ vi.useRealTimers();
468
+ });
469
+
470
+ const trimmed = (duration: number, sourceStart: number) => (
471
+ <VideoThumbnail
472
+ videoSrc="/api/projects/p/preview/assets/clip.mp4"
473
+ label=""
474
+ labelColor="#fff"
475
+ projectId="p"
476
+ sessionEpoch={1}
477
+ duration={duration}
478
+ sourceStart={sourceStart}
479
+ sourceRangeDuration={duration}
480
+ />
481
+ );
482
+
483
+ it("keeps its strip through every move of a trim and decodes the new range once at rest", async () => {
484
+ Object.defineProperty(host, "clientWidth", { configurable: true, value: 440 });
485
+ Object.defineProperty(host, "clientHeight", { configurable: true, value: 40 });
486
+ const root = harness.mount(host);
487
+ await act(async () => {
488
+ root.render(trimmed(10, 0));
489
+ await Promise.resolve();
490
+ });
491
+ vi.mocked(decodeVideoThumbnail).mockClear();
492
+ for (const [duration, start] of [
493
+ [9.5, 0.5],
494
+ [9, 1],
495
+ [8.5, 1.5],
496
+ ] as const) {
497
+ await act(async () => {
498
+ markTimelineMotion();
499
+ root.render(trimmed(duration, start));
500
+ await Promise.resolve();
501
+ });
502
+ }
503
+ expect(decodeVideoThumbnail).not.toHaveBeenCalled();
504
+ await act(async () => {
505
+ vi.runOnlyPendingTimers();
506
+ await Promise.resolve();
507
+ });
508
+ const ranges = vi
509
+ .mocked(decodeVideoThumbnail)
510
+ .mock.calls.map(([r]) => [r.sourceStart, r.sourceRangeDuration]);
511
+ expect(new Set(ranges.map((r) => r.join()))).toEqual(new Set(["1.5,8.5"]));
512
+ });
513
+ });