@hyperframes/studio 0.7.54 → 0.7.56
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/assets/{index-uBY329wb.js → index-BWnOxAiH.js} +1 -1
- package/dist/assets/{index-CMHYjEZ5.js → index-C4csZims.js} +1 -1
- package/dist/assets/index-CmVCjZjp.js +423 -0
- package/dist/assets/index-D-GyYi2d.css +1 -0
- package/dist/{chunk-SOTCF4DF.js → chunk-5QSIMBEJ.js} +2 -1
- package/dist/chunk-5QSIMBEJ.js.map +1 -0
- package/dist/{domEditingLayers-2ECJK24D.js → domEditingLayers-6LQGKPOI.js} +2 -2
- package/dist/index.d.ts +146 -144
- package/dist/index.html +2 -2
- package/dist/index.js +40582 -37803
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/App.tsx +106 -96
- package/src/components/EditorShell.tsx +253 -0
- package/src/components/StudioGlobalDragOverlay.tsx +1 -3
- package/src/components/StudioLeftSidebar.tsx +13 -3
- package/src/components/StudioRightPanel.tsx +8 -3
- package/src/components/TimelineToolbar.test.tsx +2 -2
- package/src/components/TimelineToolbar.tsx +179 -121
- package/src/components/editor/CanvasContextMenu.test.tsx +115 -0
- package/src/components/editor/CanvasContextMenu.tsx +198 -0
- package/src/components/editor/DomEditCropHandles.test.tsx +74 -3
- package/src/components/editor/DomEditCropHandles.tsx +64 -29
- package/src/components/editor/DomEditOverlay.test.ts +245 -279
- package/src/components/editor/DomEditOverlay.tsx +158 -126
- package/src/components/editor/DomEditOverlayHover.test.tsx +90 -0
- package/src/components/editor/DomEditRotateHandle.tsx +38 -18
- package/src/components/editor/DomEditSelectionChrome.test.tsx +80 -0
- package/src/components/editor/DomEditSelectionChrome.tsx +257 -0
- package/src/components/editor/LayersPanel.test.ts +66 -2
- package/src/components/editor/LayersPanel.tsx +43 -1
- package/src/components/editor/OffCanvasIndicators.test.tsx +34 -0
- package/src/components/editor/OffCanvasIndicators.tsx +49 -10
- package/src/components/editor/SnapGuideOverlay.tsx +28 -23
- package/src/components/editor/SnapToolbar.test.tsx +0 -1
- package/src/components/editor/anchoredResizeCommitFeedsOffset.test.ts +214 -0
- package/src/components/editor/anchoredResizeReleaseShift.test.ts +208 -0
- package/src/components/editor/canvasContextMenuZOrder.test.ts +435 -0
- package/src/components/editor/canvasContextMenuZOrder.ts +352 -0
- package/src/components/editor/domEditNudge.test.ts +80 -0
- package/src/components/editor/domEditNudge.ts +44 -0
- package/src/components/editor/domEditOverlayGeometry.test.ts +167 -1
- package/src/components/editor/domEditOverlayGeometry.ts +280 -20
- package/src/components/editor/domEditOverlayGestures.ts +44 -41
- package/src/components/editor/domEditOverlayStartGesture.ts +62 -2
- package/src/components/editor/domEditResizeLocal.test.ts +131 -0
- package/src/components/editor/domEditResizeLocal.ts +125 -0
- package/src/components/editor/domEditingDom.ts +1 -1
- package/src/components/editor/manualEditsDomPatches.test.ts +47 -0
- package/src/components/editor/manualOffsetDrag.ts +55 -12
- package/src/components/editor/offCanvasIndicatorGeometry.ts +31 -10
- package/src/components/editor/offCanvasIndicatorRefresh.test.tsx +25 -1
- package/src/components/editor/resizeDraft.ts +108 -0
- package/src/components/editor/snapEngine.test.ts +12 -78
- package/src/components/editor/snapEngine.ts +13 -53
- package/src/components/editor/useDomEditNudge.test.tsx +228 -0
- package/src/components/editor/useDomEditNudge.ts +254 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +115 -116
- package/src/components/editor/useDomEditOverlayRects.ts +9 -2
- package/src/components/nle/AssetPreviewOverlay.tsx +147 -0
- package/src/components/nle/NLEContext.test.ts +144 -0
- package/src/components/nle/NLEContext.tsx +328 -0
- package/src/components/nle/NLEPreview.tsx +1 -1
- package/src/components/nle/PreviewOverlays.tsx +240 -0
- package/src/components/nle/PreviewPane.tsx +163 -0
- package/src/components/nle/TimelinePane.test.ts +60 -0
- package/src/components/nle/TimelinePane.tsx +293 -0
- package/src/components/nle/TimelineResizeDivider.tsx +8 -2
- package/src/components/nle/useCompositionStack.test.tsx +44 -0
- package/src/components/nle/useCompositionStack.ts +17 -9
- package/src/components/nle/useTimelineEditCallbacks.ts +217 -0
- package/src/components/sidebar/AssetCard.tsx +326 -0
- package/src/components/sidebar/AssetContextMenu.tsx +15 -30
- package/src/components/sidebar/AssetsTab.test.ts +96 -0
- package/src/components/sidebar/AssetsTab.tsx +71 -206
- package/src/components/sidebar/AudioRow.tsx +39 -2
- package/src/components/sidebar/BlocksTab.tsx +8 -1
- package/src/components/sidebar/LeftSidebar.tsx +4 -1
- package/src/components/sidebar/assetHelpers.ts +29 -0
- package/src/contexts/DomEditContext.tsx +9 -0
- package/src/contexts/StudioContext.tsx +9 -8
- package/src/contexts/TimelineEditContext.tsx +3 -7
- package/src/hooks/deleteSelectedKeyframes.ts +35 -0
- package/src/hooks/domEditCommitTypes.ts +12 -1
- package/src/hooks/domSelectionTestHarness.ts +14 -0
- package/src/hooks/gestureTransaction.test.ts +311 -0
- package/src/hooks/gestureTransaction.ts +199 -0
- package/src/hooks/gsapDragCommit.test.ts +141 -41
- package/src/hooks/gsapDragCommit.ts +64 -74
- package/src/hooks/gsapDragStaticSetHelpers.ts +9 -21
- package/src/hooks/gsapResizeIntercept.test.ts +69 -0
- package/src/hooks/gsapResizeIntercept.ts +38 -10
- package/src/hooks/gsapRuntimeBridge.test.ts +49 -13
- package/src/hooks/gsapRuntimeBridge.ts +4 -4
- package/src/hooks/gsapScriptCommitTypes.ts +16 -5
- package/src/hooks/gsapShared.test.ts +19 -1
- package/src/hooks/gsapShared.ts +14 -0
- package/src/hooks/patchDocumentRootDuration.test.ts +71 -0
- package/src/hooks/timelineEditingGsap.ts +14 -0
- package/src/hooks/timelineEditingHelpers.test.ts +34 -1
- package/src/hooks/timelineEditingHelpers.ts +22 -48
- package/src/hooks/timelineMoveAdapter.test.ts +77 -0
- package/src/hooks/timelineMoveAdapter.ts +37 -0
- package/src/hooks/useAnimatedPropertyCommit.test.tsx +36 -8
- package/src/hooks/useAnimatedPropertyCommit.ts +31 -26
- package/src/hooks/useAppHotkeys.ts +16 -25
- package/src/hooks/useBlockHandlers.ts +55 -27
- package/src/hooks/useContextMenuDismiss.ts +31 -7
- package/src/hooks/useDomEditCommits.test.tsx +154 -1
- package/src/hooks/useDomEditCommits.ts +100 -3
- package/src/hooks/useDomEditPositionPatchCommit.ts +2 -0
- package/src/hooks/useDomEditSession.ts +2 -2
- package/src/hooks/useDomEditTextCommits.test.tsx +135 -0
- package/src/hooks/useDomEditTextCommits.ts +8 -3
- package/src/hooks/useDomEditWiring.ts +7 -9
- package/src/hooks/useDomGeometryCommits.ts +17 -2
- package/src/hooks/useDomSelection.test.ts +2 -36
- package/src/hooks/useDomSelection.ts +81 -51
- package/src/hooks/useDomSelectionSelectionGuards.test.ts +276 -0
- package/src/hooks/useElementLifecycleOps.test.tsx +258 -0
- package/src/hooks/useElementLifecycleOps.ts +40 -71
- package/src/hooks/useEnableKeyframes.test.ts +142 -1
- package/src/hooks/useEnableKeyframes.ts +73 -29
- package/src/hooks/useGestureCommit.test.tsx +130 -0
- package/src/hooks/useGestureCommit.ts +32 -8
- package/src/hooks/useGroupCommits.ts +7 -28
- package/src/hooks/useGsapAwareEditing.test.tsx +239 -0
- package/src/hooks/useGsapAwareEditing.ts +115 -20
- package/src/hooks/useGsapKeyframeOps.test.tsx +59 -0
- package/src/hooks/useGsapKeyframeOps.ts +38 -10
- package/src/hooks/useGsapScriptCommits.test.tsx +40 -1
- package/src/hooks/useGsapScriptCommits.ts +134 -50
- package/src/hooks/useGsapSelectionHandlers.ts +49 -16
- package/src/hooks/useMusicBeatAnalysis.ts +72 -36
- package/src/hooks/usePersistentEditHistory.test.ts +33 -0
- package/src/hooks/usePersistentEditHistory.ts +92 -58
- package/src/hooks/usePreviewPersistence.ts +25 -7
- package/src/hooks/useRazorSplit.history.test.tsx +303 -0
- package/src/hooks/useRazorSplit.test.ts +269 -0
- package/src/hooks/useRazorSplit.testHelpers.ts +64 -0
- package/src/hooks/useRazorSplit.ts +107 -36
- package/src/hooks/useRenderClipContent.ts +24 -6
- package/src/hooks/useStudioContextValue.ts +15 -5
- package/src/hooks/useStudioUrlState.ts +2 -4
- package/src/hooks/useTimelineEditing.test.tsx +20 -29
- package/src/hooks/useTimelineEditingTypes.ts +6 -0
- package/src/hooks/useTimelineGroupEditing.ts +18 -4
- package/src/index.ts +1 -1
- package/src/player/components/ImageThumbnail.test.tsx +173 -0
- package/src/player/components/ImageThumbnail.tsx +160 -0
- package/src/player/components/PlayheadIndicator.tsx +50 -5
- package/src/player/components/Timeline.test.ts +102 -19
- package/src/player/components/Timeline.tsx +194 -194
- package/src/player/components/TimelineCanvas.tsx +207 -521
- package/src/player/components/TimelineClip.tsx +4 -1
- package/src/player/components/TimelineClipDiamonds.tsx +9 -40
- package/src/player/components/TimelineEmptyState.tsx +3 -1
- package/src/player/components/TimelineLanes.tsx +487 -0
- package/src/player/components/TimelineOverlays.tsx +122 -0
- package/src/player/components/VideoThumbnail.test.tsx +152 -0
- package/src/player/components/VideoThumbnail.tsx +28 -7
- package/src/player/components/thumbnailUtils.test.ts +127 -0
- package/src/player/components/thumbnailUtils.ts +54 -0
- package/src/player/components/timelineCallbacks.ts +18 -18
- package/src/player/components/timelineClipChildren.tsx +39 -0
- package/src/player/components/timelineClipDragCommit.test.ts +943 -0
- package/src/player/components/timelineClipDragCommit.ts +401 -0
- package/src/player/components/timelineClipDragPreview.test.ts +144 -0
- package/src/player/components/timelineClipDragPreview.ts +323 -38
- package/src/player/components/timelineClipDragTypes.ts +65 -0
- package/src/player/components/timelineCollision.test.ts +477 -0
- package/src/player/components/timelineCollision.ts +263 -0
- package/src/player/components/timelineDragDrop.ts +69 -60
- package/src/player/components/timelineEditCapabilities.ts +52 -0
- package/src/player/components/timelineEditing.test.ts +1 -1
- package/src/player/components/timelineEditing.ts +76 -59
- package/src/player/components/timelineGroupEditing.test.ts +126 -0
- package/src/player/components/timelineGroupEditing.ts +133 -0
- package/src/player/components/timelineGroupResizeCommit.ts +54 -0
- package/src/player/components/timelineLayout.test.ts +95 -23
- package/src/player/components/timelineLayout.ts +120 -61
- package/src/player/components/timelineMarquee.test.ts +197 -0
- package/src/player/components/timelineMarquee.ts +112 -0
- package/src/player/components/timelineMultiDragPreview.test.ts +127 -0
- package/src/player/components/timelineMultiDragPreview.ts +106 -0
- package/src/player/components/timelineOptimisticRevision.ts +42 -0
- package/src/player/components/timelineSnapping.test.ts +134 -0
- package/src/player/components/timelineSnapping.ts +110 -0
- package/src/player/components/timelineStackingSync.test.ts +244 -0
- package/src/player/components/timelineStackingSync.ts +331 -0
- package/src/player/components/timelineTheme.ts +6 -1
- package/src/player/components/timelineZones.test.ts +425 -0
- package/src/player/components/timelineZones.ts +198 -0
- package/src/player/components/timelineZoom.test.ts +67 -0
- package/src/player/components/timelineZoom.ts +51 -0
- package/src/player/components/useResolvedTimelineEditCallbacks.ts +25 -3
- package/src/player/components/useTimelineClipDrag.resize.test.tsx +241 -0
- package/src/player/components/useTimelineClipDrag.ts +380 -386
- package/src/player/components/useTimelineEditPinning.ts +121 -0
- package/src/player/components/useTimelineGeometry.ts +129 -0
- package/src/player/components/useTimelinePlayhead.ts +4 -16
- package/src/player/components/useTimelineRangeSelection.ts +341 -50
- package/src/player/components/useTimelineStackingSync.test.tsx +67 -0
- package/src/player/components/useTimelineStackingSync.ts +83 -0
- package/src/player/hooks/useExpandedTimelineElements.ts +0 -3
- package/src/player/hooks/usePlaybackKeyboard.ts +5 -0
- package/src/player/hooks/useTimelinePlayer.ts +48 -53
- package/src/player/hooks/useTimelinePlayerLoop.ts +85 -0
- package/src/player/hooks/useTimelineSyncCallbacks.test.ts +219 -0
- package/src/player/hooks/useTimelineSyncCallbacks.ts +104 -4
- package/src/player/index.ts +3 -2
- package/src/player/lib/time.test.ts +19 -19
- package/src/player/lib/time.ts +6 -2
- package/src/player/lib/timelineDOM.test.ts +25 -98
- package/src/player/lib/timelineDOM.ts +12 -81
- package/src/player/lib/timelineElementHelpers.ts +54 -5
- package/src/player/lib/timelineIframeHelpers.ts +2 -0
- package/src/player/store/playerStore.ts +62 -3
- package/src/styles/studio.css +27 -0
- package/src/utils/assetClickBehavior.test.ts +104 -0
- package/src/utils/assetClickBehavior.ts +75 -0
- package/src/utils/assetPreviewStore.ts +33 -0
- package/src/utils/blockInstaller.ts +10 -2
- package/src/utils/canvasNudgeGate.test.ts +31 -0
- package/src/utils/canvasNudgeGate.ts +32 -0
- package/src/utils/editHistory.test.ts +35 -0
- package/src/utils/gsapSoftReload.test.ts +119 -1
- package/src/utils/gsapSoftReload.ts +153 -0
- package/src/utils/mediaTypes.ts +3 -2
- package/src/utils/resizeDebug.ts +55 -0
- package/src/utils/rootDuration.test.ts +90 -1
- package/src/utils/rootDuration.ts +76 -13
- package/src/utils/sdkCutover.ts +4 -0
- package/src/utils/studioFileHistory.ts +37 -7
- package/src/utils/studioHelpers.ts +62 -0
- package/src/utils/studioPreviewHelpers.test.ts +65 -8
- package/src/utils/studioPreviewHelpers.ts +10 -0
- package/src/utils/studioTelemetry.ts +4 -1
- package/src/utils/studioUiPreferences.test.ts +38 -0
- package/src/utils/studioUiPreferences.ts +27 -0
- package/src/utils/studioUrlState.test.ts +0 -1
- package/src/utils/timelineAssetDrop.ts +62 -0
- package/src/utils/timelineDiscovery.ts +0 -17
- package/src/utils/timelineInspector.test.ts +121 -0
- package/src/utils/timelineInspector.ts +32 -1
- package/dist/assets/index-Dq7FEg0K.css +0 -1
- package/dist/assets/index-pRhCpGPz.js +0 -423
- package/dist/chunk-SOTCF4DF.js.map +0 -1
- package/src/components/StudioPreviewArea.tsx +0 -500
- package/src/components/nle/NLELayout.test.ts +0 -12
- package/src/components/nle/NLELayout.tsx +0 -591
- package/src/player/components/TimelineLayerGutter.tsx +0 -61
- package/src/player/components/TimelineSelectionOverlays.tsx +0 -55
- package/src/player/components/timelineMarqueeSelection.test.ts +0 -87
- package/src/player/components/timelineSnapTargets.test.ts +0 -144
- package/src/player/components/timelineSnapTargets.ts +0 -164
- package/src/player/components/useTimelineClipDrag.test.tsx +0 -506
- package/src/player/components/useTimelineClipGroupDrag.ts +0 -417
- package/src/player/components/useTimelineMarqueeSelection.test.tsx +0 -231
- package/src/player/components/useTimelineMarqueeSelection.ts +0 -276
- package/src/utils/timelineDiscovery.test.ts +0 -90
- /package/dist/{domEditingLayers-2ECJK24D.js.map → domEditingLayers-6LQGKPOI.js.map} +0 -0
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCallback,
|
|
3
|
-
useEffect,
|
|
4
|
-
useRef,
|
|
5
|
-
useState,
|
|
6
|
-
type PointerEvent as ReactPointerEvent,
|
|
7
|
-
type RefObject,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { usePlayerStore } from "../store/playerStore";
|
|
10
|
-
import {
|
|
11
|
-
resolveTimelineAutoScroll,
|
|
12
|
-
selectTimelineElementsInMarquee,
|
|
13
|
-
type TimelineMarqueeSelectionRect,
|
|
14
|
-
} from "./timelineEditing";
|
|
15
|
-
import { GUTTER, RULER_H, TRACK_H } from "./timelineLayout";
|
|
16
|
-
import { TIMELINE_LAYER_GROUP_HEADER_H } from "./TimelineLayerGroupHeader";
|
|
17
|
-
import type { StackingTimelineLayer, TimelineLayerId } from "./timelineTrackOrder";
|
|
18
|
-
|
|
19
|
-
const MARQUEE_THRESHOLD_PX = 4;
|
|
20
|
-
|
|
21
|
-
export interface TimelineMarqueeOverlayRect {
|
|
22
|
-
left: number;
|
|
23
|
-
top: number;
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface ActiveMarqueeGesture {
|
|
29
|
-
pointerId: number;
|
|
30
|
-
anchorClientX: number;
|
|
31
|
-
anchorClientY: number;
|
|
32
|
-
anchorX: number;
|
|
33
|
-
anchorY: number;
|
|
34
|
-
lastClientX: number;
|
|
35
|
-
lastClientY: number;
|
|
36
|
-
started: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface UseTimelineMarqueeSelectionInput {
|
|
40
|
-
scrollRef: RefObject<HTMLDivElement | null>;
|
|
41
|
-
ppsRef: RefObject<number>;
|
|
42
|
-
trackOrderRef: RefObject<TimelineLayerId[]>;
|
|
43
|
-
timelineLayersRef: RefObject<StackingTimelineLayer[]>;
|
|
44
|
-
disabled?: boolean;
|
|
45
|
-
setShowPopover: (show: boolean) => void;
|
|
46
|
-
setRangeSelectionRef: RefObject<((sel: null) => void) | null>;
|
|
47
|
-
/** Canonical playhead seek, used to keep empty-lane clicks scrubbing the playhead. */
|
|
48
|
-
seekFromX: (clientX: number) => void;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getCanvasPoint(scroll: HTMLDivElement, clientX: number, clientY: number) {
|
|
52
|
-
const rect = scroll.getBoundingClientRect();
|
|
53
|
-
return {
|
|
54
|
-
x: clientX - rect.left + scroll.scrollLeft,
|
|
55
|
-
y: clientY - rect.top + scroll.scrollTop,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getMarqueeStartPoint(
|
|
60
|
-
event: ReactPointerEvent<HTMLDivElement>,
|
|
61
|
-
scroll: HTMLDivElement | null,
|
|
62
|
-
disabled: boolean,
|
|
63
|
-
) {
|
|
64
|
-
if (disabled || event.button !== 0 || event.shiftKey || !scroll) return null;
|
|
65
|
-
const target = event.target as HTMLElement;
|
|
66
|
-
if (target.closest("[data-clip]")) return null;
|
|
67
|
-
const point = getCanvasPoint(scroll, event.clientX, event.clientY);
|
|
68
|
-
if (point.x < GUTTER || point.y < RULER_H) return null;
|
|
69
|
-
return point;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function capturePointerIfAvailable(event: ReactPointerEvent<HTMLDivElement>) {
|
|
73
|
-
const currentTarget = event.currentTarget as HTMLElement;
|
|
74
|
-
if (typeof currentTarget.setPointerCapture === "function") {
|
|
75
|
-
currentTarget.setPointerCapture(event.pointerId);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function buildSelectionRect(
|
|
80
|
-
active: ActiveMarqueeGesture,
|
|
81
|
-
scroll: HTMLDivElement,
|
|
82
|
-
pps: number,
|
|
83
|
-
): { overlay: TimelineMarqueeOverlayRect; selection: TimelineMarqueeSelectionRect } {
|
|
84
|
-
const current = getCanvasPoint(scroll, active.lastClientX, active.lastClientY);
|
|
85
|
-
const left = Math.min(active.anchorX, current.x);
|
|
86
|
-
const right = Math.max(active.anchorX, current.x);
|
|
87
|
-
const top = Math.min(active.anchorY, current.y);
|
|
88
|
-
const bottom = Math.max(active.anchorY, current.y);
|
|
89
|
-
const overlayLeft = Math.max(GUTTER, left);
|
|
90
|
-
const overlayTop = Math.max(RULER_H, top);
|
|
91
|
-
const overlayRight = Math.max(overlayLeft, right);
|
|
92
|
-
const overlayBottom = Math.max(overlayTop, bottom);
|
|
93
|
-
|
|
94
|
-
// Hit-test must use the SAME pixels-per-second the overlay is drawn at, or the
|
|
95
|
-
// selected time span diverges from the visible box at low zoom (pps < 1). Guard
|
|
96
|
-
// only against a non-finite/zero pps (would yield NaN/Infinity), never floor it.
|
|
97
|
-
const safePps = Number.isFinite(pps) && pps > 0 ? pps : 0;
|
|
98
|
-
const timeFromX = (x: number) => (safePps > 0 ? Math.max(0, (x - GUTTER) / safePps) : 0);
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
overlay: {
|
|
102
|
-
left: overlayLeft,
|
|
103
|
-
top: overlayTop,
|
|
104
|
-
width: overlayRight - overlayLeft,
|
|
105
|
-
height: overlayBottom - overlayTop,
|
|
106
|
-
},
|
|
107
|
-
selection: {
|
|
108
|
-
startTime: timeFromX(left),
|
|
109
|
-
endTime: timeFromX(right),
|
|
110
|
-
top,
|
|
111
|
-
bottom,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function useTimelineMarqueeSelection({
|
|
117
|
-
scrollRef,
|
|
118
|
-
ppsRef,
|
|
119
|
-
trackOrderRef,
|
|
120
|
-
timelineLayersRef,
|
|
121
|
-
disabled = false,
|
|
122
|
-
setShowPopover,
|
|
123
|
-
setRangeSelectionRef,
|
|
124
|
-
seekFromX,
|
|
125
|
-
}: UseTimelineMarqueeSelectionInput) {
|
|
126
|
-
const activeRef = useRef<ActiveMarqueeGesture | null>(null);
|
|
127
|
-
const pointerRef = useRef<{ clientX: number; clientY: number } | null>(null);
|
|
128
|
-
const scrollRafRef = useRef(0);
|
|
129
|
-
const [marqueeRect, setMarqueeRect] = useState<TimelineMarqueeOverlayRect | null>(null);
|
|
130
|
-
|
|
131
|
-
const stopAutoScroll = useCallback(() => {
|
|
132
|
-
pointerRef.current = null;
|
|
133
|
-
if (scrollRafRef.current) {
|
|
134
|
-
cancelAnimationFrame(scrollRafRef.current);
|
|
135
|
-
scrollRafRef.current = 0;
|
|
136
|
-
}
|
|
137
|
-
}, []);
|
|
138
|
-
|
|
139
|
-
const updateMarqueeRect = useCallback(() => {
|
|
140
|
-
const active = activeRef.current;
|
|
141
|
-
const scroll = scrollRef.current;
|
|
142
|
-
if (!active || !scroll) return null;
|
|
143
|
-
const rects = buildSelectionRect(active, scroll, ppsRef.current);
|
|
144
|
-
setMarqueeRect(rects.overlay);
|
|
145
|
-
return rects;
|
|
146
|
-
}, [ppsRef, scrollRef]);
|
|
147
|
-
|
|
148
|
-
const stepAutoScroll = useCallback(() => {
|
|
149
|
-
scrollRafRef.current = 0;
|
|
150
|
-
const pointer = pointerRef.current;
|
|
151
|
-
const scroll = scrollRef.current;
|
|
152
|
-
if (!pointer || !scroll || !activeRef.current) return;
|
|
153
|
-
|
|
154
|
-
const delta = resolveTimelineAutoScroll(
|
|
155
|
-
scroll.getBoundingClientRect(),
|
|
156
|
-
pointer.clientX,
|
|
157
|
-
pointer.clientY,
|
|
158
|
-
);
|
|
159
|
-
if (delta.x === 0 && delta.y === 0) return;
|
|
160
|
-
|
|
161
|
-
const maxScrollLeft = Math.max(0, scroll.scrollWidth - scroll.clientWidth);
|
|
162
|
-
const maxScrollTop = Math.max(0, scroll.scrollHeight - scroll.clientHeight);
|
|
163
|
-
const nextScrollLeft = Math.max(0, Math.min(maxScrollLeft, scroll.scrollLeft + delta.x));
|
|
164
|
-
const nextScrollTop = Math.max(0, Math.min(maxScrollTop, scroll.scrollTop + delta.y));
|
|
165
|
-
if (nextScrollLeft === scroll.scrollLeft && nextScrollTop === scroll.scrollTop) return;
|
|
166
|
-
|
|
167
|
-
scroll.scrollLeft = nextScrollLeft;
|
|
168
|
-
scroll.scrollTop = nextScrollTop;
|
|
169
|
-
updateMarqueeRect();
|
|
170
|
-
scrollRafRef.current = requestAnimationFrame(stepAutoScroll);
|
|
171
|
-
}, [scrollRef, updateMarqueeRect]);
|
|
172
|
-
|
|
173
|
-
const syncAutoScroll = useCallback(
|
|
174
|
-
(clientX: number, clientY: number) => {
|
|
175
|
-
pointerRef.current = { clientX, clientY };
|
|
176
|
-
const scroll = scrollRef.current;
|
|
177
|
-
if (!scroll) return;
|
|
178
|
-
const delta = resolveTimelineAutoScroll(scroll.getBoundingClientRect(), clientX, clientY);
|
|
179
|
-
if (delta.x === 0 && delta.y === 0) {
|
|
180
|
-
if (scrollRafRef.current) {
|
|
181
|
-
cancelAnimationFrame(scrollRafRef.current);
|
|
182
|
-
scrollRafRef.current = 0;
|
|
183
|
-
}
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (!scrollRafRef.current) {
|
|
187
|
-
scrollRafRef.current = requestAnimationFrame(stepAutoScroll);
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
[scrollRef, stepAutoScroll],
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
const handlePointerDown = useCallback(
|
|
194
|
-
(event: ReactPointerEvent<HTMLDivElement>) => {
|
|
195
|
-
const point = getMarqueeStartPoint(event, scrollRef.current, disabled);
|
|
196
|
-
if (!point) return false;
|
|
197
|
-
capturePointerIfAvailable(event);
|
|
198
|
-
activeRef.current = {
|
|
199
|
-
pointerId: event.pointerId,
|
|
200
|
-
anchorClientX: event.clientX,
|
|
201
|
-
anchorClientY: event.clientY,
|
|
202
|
-
anchorX: point.x,
|
|
203
|
-
anchorY: point.y,
|
|
204
|
-
lastClientX: event.clientX,
|
|
205
|
-
lastClientY: event.clientY,
|
|
206
|
-
started: false,
|
|
207
|
-
};
|
|
208
|
-
setShowPopover(false);
|
|
209
|
-
setRangeSelectionRef.current?.(null);
|
|
210
|
-
return true;
|
|
211
|
-
},
|
|
212
|
-
[disabled, scrollRef, setRangeSelectionRef, setShowPopover],
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const handlePointerMove = useCallback(
|
|
216
|
-
(event: ReactPointerEvent<HTMLDivElement>) => {
|
|
217
|
-
const active = activeRef.current;
|
|
218
|
-
if (!active || active.pointerId !== event.pointerId) return false;
|
|
219
|
-
active.lastClientX = event.clientX;
|
|
220
|
-
active.lastClientY = event.clientY;
|
|
221
|
-
const distance = Math.hypot(
|
|
222
|
-
event.clientX - active.anchorClientX,
|
|
223
|
-
event.clientY - active.anchorClientY,
|
|
224
|
-
);
|
|
225
|
-
if (!active.started && distance < MARQUEE_THRESHOLD_PX) return true;
|
|
226
|
-
active.started = true;
|
|
227
|
-
updateMarqueeRect();
|
|
228
|
-
syncAutoScroll(event.clientX, event.clientY);
|
|
229
|
-
return true;
|
|
230
|
-
},
|
|
231
|
-
[syncAutoScroll, updateMarqueeRect],
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const handlePointerUp = useCallback(
|
|
235
|
-
(event?: ReactPointerEvent<HTMLDivElement>) => {
|
|
236
|
-
const active = activeRef.current;
|
|
237
|
-
if (!active || (event && active.pointerId !== event.pointerId)) return false;
|
|
238
|
-
activeRef.current = null;
|
|
239
|
-
stopAutoScroll();
|
|
240
|
-
setMarqueeRect(null);
|
|
241
|
-
|
|
242
|
-
if (!active.started) {
|
|
243
|
-
// A press that never crossed the marquee threshold is a plain empty-lane
|
|
244
|
-
// click: clear the selection AND scrub the playhead, matching the seek that
|
|
245
|
-
// the range/playhead handler would have run had the marquee not claimed it.
|
|
246
|
-
usePlayerStore.getState().clearSelection();
|
|
247
|
-
seekFromX(active.anchorClientX);
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const scroll = scrollRef.current;
|
|
252
|
-
if (!scroll) return true;
|
|
253
|
-
const rects = buildSelectionRect(active, scroll, ppsRef.current);
|
|
254
|
-
const selectedIds = selectTimelineElementsInMarquee({
|
|
255
|
-
rect: rects.selection,
|
|
256
|
-
layers: timelineLayersRef.current,
|
|
257
|
-
layerOrder: trackOrderRef.current,
|
|
258
|
-
rulerHeight: RULER_H,
|
|
259
|
-
trackHeight: TRACK_H,
|
|
260
|
-
groupHeaderHeight: TIMELINE_LAYER_GROUP_HEADER_H,
|
|
261
|
-
});
|
|
262
|
-
usePlayerStore.getState().setSelection(selectedIds);
|
|
263
|
-
return true;
|
|
264
|
-
},
|
|
265
|
-
[ppsRef, scrollRef, seekFromX, stopAutoScroll, timelineLayersRef, trackOrderRef],
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
useEffect(() => stopAutoScroll, [stopAutoScroll]);
|
|
269
|
-
|
|
270
|
-
return {
|
|
271
|
-
marqueeRect,
|
|
272
|
-
handlePointerDown,
|
|
273
|
-
handlePointerMove,
|
|
274
|
-
handlePointerUp,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
TIMELINE_TOGGLE_SHORTCUT_LABEL,
|
|
4
|
-
getTimelineToggleTitle,
|
|
5
|
-
shouldHandleTimelineToggleHotkey,
|
|
6
|
-
} from "./timelineDiscovery";
|
|
7
|
-
|
|
8
|
-
describe("shouldHandleTimelineToggleHotkey", () => {
|
|
9
|
-
it("accepts Shift+T when focus is not inside an editor", () => {
|
|
10
|
-
expect(
|
|
11
|
-
shouldHandleTimelineToggleHotkey({
|
|
12
|
-
key: "T",
|
|
13
|
-
shiftKey: true,
|
|
14
|
-
metaKey: false,
|
|
15
|
-
ctrlKey: false,
|
|
16
|
-
altKey: false,
|
|
17
|
-
target: {
|
|
18
|
-
tagName: "DIV",
|
|
19
|
-
isContentEditable: false,
|
|
20
|
-
closest: () => null,
|
|
21
|
-
},
|
|
22
|
-
} as KeyboardEvent),
|
|
23
|
-
).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("ignores the shortcut inside text inputs", () => {
|
|
27
|
-
expect(
|
|
28
|
-
shouldHandleTimelineToggleHotkey({
|
|
29
|
-
key: "t",
|
|
30
|
-
shiftKey: true,
|
|
31
|
-
metaKey: false,
|
|
32
|
-
ctrlKey: false,
|
|
33
|
-
altKey: false,
|
|
34
|
-
target: {
|
|
35
|
-
tagName: "TEXTAREA",
|
|
36
|
-
isContentEditable: false,
|
|
37
|
-
closest: () => null,
|
|
38
|
-
},
|
|
39
|
-
} as KeyboardEvent),
|
|
40
|
-
).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("ignores the shortcut inside contenteditable editors", () => {
|
|
44
|
-
expect(
|
|
45
|
-
shouldHandleTimelineToggleHotkey({
|
|
46
|
-
key: "t",
|
|
47
|
-
shiftKey: true,
|
|
48
|
-
metaKey: false,
|
|
49
|
-
ctrlKey: false,
|
|
50
|
-
altKey: false,
|
|
51
|
-
target: {
|
|
52
|
-
tagName: "DIV",
|
|
53
|
-
isContentEditable: true,
|
|
54
|
-
closest: () => null,
|
|
55
|
-
},
|
|
56
|
-
} as KeyboardEvent),
|
|
57
|
-
).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("requires Shift without other modifiers", () => {
|
|
61
|
-
expect(
|
|
62
|
-
shouldHandleTimelineToggleHotkey({
|
|
63
|
-
key: "t",
|
|
64
|
-
shiftKey: false,
|
|
65
|
-
metaKey: false,
|
|
66
|
-
ctrlKey: false,
|
|
67
|
-
altKey: false,
|
|
68
|
-
target: null,
|
|
69
|
-
} as KeyboardEvent),
|
|
70
|
-
).toBe(false);
|
|
71
|
-
|
|
72
|
-
expect(
|
|
73
|
-
shouldHandleTimelineToggleHotkey({
|
|
74
|
-
key: "t",
|
|
75
|
-
shiftKey: true,
|
|
76
|
-
metaKey: true,
|
|
77
|
-
ctrlKey: false,
|
|
78
|
-
altKey: false,
|
|
79
|
-
target: null,
|
|
80
|
-
} as KeyboardEvent),
|
|
81
|
-
).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("getTimelineToggleTitle", () => {
|
|
86
|
-
it("includes the shortcut in both show and hide titles", () => {
|
|
87
|
-
expect(getTimelineToggleTitle(true)).toContain(TIMELINE_TOGGLE_SHORTCUT_LABEL);
|
|
88
|
-
expect(getTimelineToggleTitle(false)).toContain(TIMELINE_TOGGLE_SHORTCUT_LABEL);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
File without changes
|