@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,55 +0,0 @@
|
|
|
1
|
-
import type { TimelineRangeSelection } from "./timelineEditing";
|
|
2
|
-
import { GUTTER, RULER_H } from "./timelineLayout";
|
|
3
|
-
import type { TimelineMarqueeOverlayRect } from "./useTimelineMarqueeSelection";
|
|
4
|
-
|
|
5
|
-
interface TimelineSelectionOverlaysProps {
|
|
6
|
-
rangeSelection: TimelineRangeSelection | null;
|
|
7
|
-
marqueeRect: TimelineMarqueeOverlayRect | null;
|
|
8
|
-
pps: number;
|
|
9
|
-
/** Primary/accent color (hex) shared with the rest of the timeline chrome. */
|
|
10
|
-
accentColor: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function TimelineSelectionOverlays({
|
|
14
|
-
rangeSelection,
|
|
15
|
-
marqueeRect,
|
|
16
|
-
pps,
|
|
17
|
-
accentColor,
|
|
18
|
-
}: TimelineSelectionOverlaysProps) {
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
{rangeSelection && (
|
|
22
|
-
<div
|
|
23
|
-
className="absolute pointer-events-none"
|
|
24
|
-
style={{
|
|
25
|
-
left: GUTTER + Math.min(rangeSelection.start, rangeSelection.end) * pps,
|
|
26
|
-
width: Math.abs(rangeSelection.end - rangeSelection.start) * pps,
|
|
27
|
-
top: RULER_H,
|
|
28
|
-
bottom: 0,
|
|
29
|
-
backgroundColor: `${accentColor}1f`,
|
|
30
|
-
borderLeft: `1px solid ${accentColor}`,
|
|
31
|
-
borderRight: `1px solid ${accentColor}`,
|
|
32
|
-
zIndex: 50,
|
|
33
|
-
}}
|
|
34
|
-
/>
|
|
35
|
-
)}
|
|
36
|
-
{marqueeRect && (
|
|
37
|
-
<div
|
|
38
|
-
aria-hidden="true"
|
|
39
|
-
className="absolute pointer-events-none"
|
|
40
|
-
data-timeline-marquee="true"
|
|
41
|
-
style={{
|
|
42
|
-
left: marqueeRect.left,
|
|
43
|
-
top: marqueeRect.top,
|
|
44
|
-
width: marqueeRect.width,
|
|
45
|
-
height: marqueeRect.height,
|
|
46
|
-
backgroundColor: `${accentColor}29`,
|
|
47
|
-
border: `1px solid ${accentColor}`,
|
|
48
|
-
boxShadow: "0 0 0 1px rgba(15, 23, 42, 0.35)",
|
|
49
|
-
zIndex: 60,
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
)}
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { TimelineElement } from "../store/playerStore";
|
|
3
|
-
import { RULER_H, TRACK_H } from "./timelineLayout";
|
|
4
|
-
import { selectTimelineElementsInMarquee } from "./timelineEditing";
|
|
5
|
-
import type { StackingTimelineLayer } from "./timelineTrackOrder";
|
|
6
|
-
|
|
7
|
-
function element(id: string, start: number, duration: number, track: number): TimelineElement {
|
|
8
|
-
return { id, tag: "div", start, duration, track };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function layer(id: string, elements: TimelineElement[]): StackingTimelineLayer {
|
|
12
|
-
return {
|
|
13
|
-
id,
|
|
14
|
-
kind: "visual",
|
|
15
|
-
contextKey: "",
|
|
16
|
-
zIndex: 0,
|
|
17
|
-
placementTrack: elements[0]?.track ?? 0,
|
|
18
|
-
elements,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe("selectTimelineElementsInMarquee", () => {
|
|
23
|
-
it("selects clips intersecting both the marquee time span and lane span", () => {
|
|
24
|
-
const layers = [
|
|
25
|
-
layer("lane-0", [element("first-hit", 1, 1, 0), element("time-miss", 5, 1, 0)]),
|
|
26
|
-
layer("lane-1", [element("second-hit", 2.25, 1, 1)]),
|
|
27
|
-
layer("lane-2", [element("lane-miss", 1.5, 1, 2)]),
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
expect(
|
|
31
|
-
selectTimelineElementsInMarquee({
|
|
32
|
-
rect: {
|
|
33
|
-
startTime: 0.5,
|
|
34
|
-
endTime: 3,
|
|
35
|
-
top: RULER_H,
|
|
36
|
-
bottom: RULER_H + TRACK_H * 2,
|
|
37
|
-
},
|
|
38
|
-
layers,
|
|
39
|
-
layerOrder: layers.map((item) => item.id),
|
|
40
|
-
rulerHeight: RULER_H,
|
|
41
|
-
trackHeight: TRACK_H,
|
|
42
|
-
}),
|
|
43
|
-
).toEqual(["first-hit", "second-hit"]);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("returns no ids when the marquee intersects no clip", () => {
|
|
47
|
-
const layers = [layer("lane-0", [element("outside", 4, 1, 0)])];
|
|
48
|
-
|
|
49
|
-
expect(
|
|
50
|
-
selectTimelineElementsInMarquee({
|
|
51
|
-
rect: {
|
|
52
|
-
startTime: 0,
|
|
53
|
-
endTime: 1,
|
|
54
|
-
top: RULER_H,
|
|
55
|
-
bottom: RULER_H + TRACK_H,
|
|
56
|
-
},
|
|
57
|
-
layers,
|
|
58
|
-
layerOrder: ["lane-0"],
|
|
59
|
-
rulerHeight: RULER_H,
|
|
60
|
-
trackHeight: TRACK_H,
|
|
61
|
-
}),
|
|
62
|
-
).toEqual([]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("accounts for context group headers before row hit testing", () => {
|
|
66
|
-
const layers: StackingTimelineLayer[] = [
|
|
67
|
-
{ ...layer("lane-0", [element("above", 0, 1, 0)]), contextKey: "root" },
|
|
68
|
-
{ ...layer("lane-1", [element("below", 0, 1, 1)]), contextKey: "nested" },
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
selectTimelineElementsInMarquee({
|
|
73
|
-
rect: {
|
|
74
|
-
startTime: 0,
|
|
75
|
-
endTime: 1,
|
|
76
|
-
top: RULER_H + 18 + TRACK_H,
|
|
77
|
-
bottom: RULER_H + 18 + TRACK_H + 18 + TRACK_H,
|
|
78
|
-
},
|
|
79
|
-
layers,
|
|
80
|
-
layerOrder: ["lane-0", "lane-1"],
|
|
81
|
-
rulerHeight: RULER_H,
|
|
82
|
-
trackHeight: TRACK_H,
|
|
83
|
-
groupHeaderHeight: 18,
|
|
84
|
-
}),
|
|
85
|
-
).toEqual(["below"]);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { TimelineElement } from "../store/playerStore";
|
|
3
|
-
import {
|
|
4
|
-
buildTimelineSnapTargets,
|
|
5
|
-
snapEdgesToTargets,
|
|
6
|
-
snapResizeEdgeToTargets,
|
|
7
|
-
} from "./timelineSnapTargets";
|
|
8
|
-
|
|
9
|
-
function timelineElement(input: {
|
|
10
|
-
id: string;
|
|
11
|
-
key?: string;
|
|
12
|
-
start: number;
|
|
13
|
-
duration: number;
|
|
14
|
-
}): TimelineElement {
|
|
15
|
-
return {
|
|
16
|
-
id: input.id,
|
|
17
|
-
key: input.key,
|
|
18
|
-
tag: "div",
|
|
19
|
-
start: input.start,
|
|
20
|
-
duration: input.duration,
|
|
21
|
-
track: 0,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("buildTimelineSnapTargets", () => {
|
|
26
|
-
it("excludes the dragged clip's own edges", () => {
|
|
27
|
-
const dragged = timelineElement({
|
|
28
|
-
id: "dragged-id",
|
|
29
|
-
key: "dragged-key",
|
|
30
|
-
start: 1,
|
|
31
|
-
duration: 2,
|
|
32
|
-
});
|
|
33
|
-
const other = timelineElement({ id: "other", start: 4, duration: 2 });
|
|
34
|
-
|
|
35
|
-
const targets = buildTimelineSnapTargets({
|
|
36
|
-
elements: [dragged, other],
|
|
37
|
-
excludedKeys: new Set(["dragged-key"]),
|
|
38
|
-
playhead: 8,
|
|
39
|
-
compDuration: 10,
|
|
40
|
-
beats: [1.5],
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const times = targets.map((target) => target.time);
|
|
44
|
-
expect(times).not.toContain(1);
|
|
45
|
-
expect(times).not.toContain(3);
|
|
46
|
-
expect(times).toContain(4);
|
|
47
|
-
expect(times).toContain(6);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("excludes every moving group member, not just the grabbed clip", () => {
|
|
51
|
-
const a = timelineElement({ id: "a", start: 1, duration: 1 });
|
|
52
|
-
const b = timelineElement({ id: "b", start: 3, duration: 1 });
|
|
53
|
-
const other = timelineElement({ id: "other", start: 6, duration: 1 });
|
|
54
|
-
|
|
55
|
-
const targets = buildTimelineSnapTargets({
|
|
56
|
-
elements: [a, b, other],
|
|
57
|
-
excludedKeys: new Set(["a", "b"]),
|
|
58
|
-
playhead: 9,
|
|
59
|
-
compDuration: 10,
|
|
60
|
-
beats: [],
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const times = targets.map((target) => target.time);
|
|
64
|
-
// Both group members' edges are excluded; the non-member's edges remain.
|
|
65
|
-
expect(times).not.toContain(1);
|
|
66
|
-
expect(times).not.toContain(2);
|
|
67
|
-
expect(times).not.toContain(3);
|
|
68
|
-
expect(times).not.toContain(4);
|
|
69
|
-
expect(times).toContain(6);
|
|
70
|
-
expect(times).toContain(7);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("dedupes near-equal times from different sources", () => {
|
|
74
|
-
const dragged = timelineElement({ id: "dragged", start: 2, duration: 2 });
|
|
75
|
-
const other = timelineElement({ id: "other", start: 0.0004, duration: 10 });
|
|
76
|
-
|
|
77
|
-
const targets = buildTimelineSnapTargets({
|
|
78
|
-
elements: [dragged, other],
|
|
79
|
-
excludedKeys: new Set(["dragged"]),
|
|
80
|
-
playhead: 5,
|
|
81
|
-
compDuration: 10,
|
|
82
|
-
beats: [0.0002, 10.0002],
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
expect(targets.filter((target) => Math.abs(target.time) < 0.001)).toHaveLength(1);
|
|
86
|
-
expect(targets.filter((target) => Math.abs(target.time - 10) < 0.001)).toHaveLength(1);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe("snapEdgesToTargets", () => {
|
|
91
|
-
it("snaps the start edge to another clip's end", () => {
|
|
92
|
-
const snap = snapEdgesToTargets(3.95, 2, [{ time: 4, kind: "edge" }], 100);
|
|
93
|
-
|
|
94
|
-
expect(snap).toEqual({ start: 4, snapTime: 4, snapKind: "edge" });
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("snaps the end edge to another clip's start", () => {
|
|
98
|
-
const snap = snapEdgesToTargets(2.96, 2, [{ time: 5, kind: "edge" }], 100);
|
|
99
|
-
|
|
100
|
-
expect(snap).toEqual({ start: 3, snapTime: 5, snapKind: "edge" });
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("snaps to the playhead", () => {
|
|
104
|
-
const snap = snapEdgesToTargets(2.94, 1, [{ time: 3, kind: "playhead" }], 100);
|
|
105
|
-
|
|
106
|
-
expect(snap).toEqual({ start: 3, snapTime: 3, snapKind: "playhead" });
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("snaps the start edge to the lower composition bound", () => {
|
|
110
|
-
const snap = snapEdgesToTargets(0.04, 1, [{ time: 0, kind: "bound" }], 100);
|
|
111
|
-
|
|
112
|
-
expect(snap).toEqual({ start: 0, snapTime: 0, snapKind: "bound" });
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("snaps the end edge to the upper composition bound", () => {
|
|
116
|
-
const snap = snapEdgesToTargets(7.96, 2, [{ time: 10, kind: "bound" }], 100);
|
|
117
|
-
|
|
118
|
-
expect(snap).toEqual({ start: 8, snapTime: 10, snapKind: "bound" });
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("does not snap when targets are beyond the pixel threshold", () => {
|
|
122
|
-
const snap = snapEdgesToTargets(3.9, 1, [{ time: 4, kind: "edge" }], 100);
|
|
123
|
-
|
|
124
|
-
expect(snap).toEqual({ start: 3.9, snapTime: null, snapKind: null });
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe("snapResizeEdgeToTargets", () => {
|
|
129
|
-
it("does not apply end-edge snaps past maxEnd or below minDuration", () => {
|
|
130
|
-
expect(
|
|
131
|
-
snapResizeEdgeToTargets("end", 4, 2.95, [{ time: 7.01, kind: "edge" }], 100, {
|
|
132
|
-
minDuration: 0.05,
|
|
133
|
-
maxEnd: 7,
|
|
134
|
-
}),
|
|
135
|
-
).toEqual({ start: 4, duration: 2.95, snapTime: null, snapKind: null });
|
|
136
|
-
|
|
137
|
-
expect(
|
|
138
|
-
snapResizeEdgeToTargets("end", 4, 0.1, [{ time: 4.03, kind: "edge" }], 100, {
|
|
139
|
-
minDuration: 0.05,
|
|
140
|
-
maxEnd: 10,
|
|
141
|
-
}),
|
|
142
|
-
).toEqual({ start: 4, duration: 0.1, snapTime: null, snapKind: null });
|
|
143
|
-
});
|
|
144
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import type { TimelineElement } from "../store/playerStore";
|
|
2
|
-
|
|
3
|
-
export type TimelineSnapKind = "beat" | "edge" | "playhead" | "bound";
|
|
4
|
-
|
|
5
|
-
export interface TimelineSnapTarget {
|
|
6
|
-
time: number;
|
|
7
|
-
kind: TimelineSnapKind;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface NearestSnap {
|
|
11
|
-
target: TimelineSnapTarget;
|
|
12
|
-
distance: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const SNAP_PX = 8;
|
|
16
|
-
const DEDUPE_EPSILON_SECONDS = 0.001;
|
|
17
|
-
const ROUND_FACTOR = 1000;
|
|
18
|
-
const KIND_PRIORITY: Record<TimelineSnapKind, number> = {
|
|
19
|
-
bound: 0,
|
|
20
|
-
playhead: 1,
|
|
21
|
-
edge: 2,
|
|
22
|
-
beat: 3,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function roundToMillis(value: number): number {
|
|
26
|
-
return Math.round(value * ROUND_FACTOR) / ROUND_FACTOR;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function addTarget(targets: TimelineSnapTarget[], candidate: TimelineSnapTarget) {
|
|
30
|
-
if (!Number.isFinite(candidate.time)) return;
|
|
31
|
-
const existingIndex = targets.findIndex(
|
|
32
|
-
(target) => Math.abs(target.time - candidate.time) < DEDUPE_EPSILON_SECONDS,
|
|
33
|
-
);
|
|
34
|
-
if (existingIndex === -1) {
|
|
35
|
-
targets.push(candidate);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const existing = targets[existingIndex];
|
|
40
|
-
if (!existing || KIND_PRIORITY[candidate.kind] >= KIND_PRIORITY[existing.kind]) return;
|
|
41
|
-
targets[existingIndex] = candidate;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function buildTimelineSnapTargets(input: {
|
|
45
|
-
elements: TimelineElement[];
|
|
46
|
-
/** Keys of every clip moving in this gesture (the whole group), excluded as targets. */
|
|
47
|
-
excludedKeys: ReadonlySet<string>;
|
|
48
|
-
playhead: number;
|
|
49
|
-
compDuration: number;
|
|
50
|
-
beats: number[];
|
|
51
|
-
}): TimelineSnapTarget[] {
|
|
52
|
-
const targets: TimelineSnapTarget[] = [];
|
|
53
|
-
|
|
54
|
-
addTarget(targets, { time: 0, kind: "bound" });
|
|
55
|
-
addTarget(targets, { time: Math.max(0, input.compDuration), kind: "bound" });
|
|
56
|
-
addTarget(targets, { time: Math.max(0, input.playhead), kind: "playhead" });
|
|
57
|
-
|
|
58
|
-
for (const element of input.elements) {
|
|
59
|
-
const elementKey = element.key ?? element.id;
|
|
60
|
-
if (input.excludedKeys.has(elementKey) || input.excludedKeys.has(element.id)) continue;
|
|
61
|
-
addTarget(targets, { time: element.start, kind: "edge" });
|
|
62
|
-
addTarget(targets, { time: element.start + element.duration, kind: "edge" });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
for (const beat of input.beats) {
|
|
66
|
-
addTarget(targets, { time: beat, kind: "beat" });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return targets.sort((a, b) => a.time - b.time || KIND_PRIORITY[a.kind] - KIND_PRIORITY[b.kind]);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function nearestSnap(
|
|
73
|
-
time: number,
|
|
74
|
-
targets: TimelineSnapTarget[],
|
|
75
|
-
thresholdSeconds: number,
|
|
76
|
-
): NearestSnap | null {
|
|
77
|
-
let best: NearestSnap | null = null;
|
|
78
|
-
let bestDistance = thresholdSeconds;
|
|
79
|
-
for (const target of targets) {
|
|
80
|
-
if (target.time === time) continue;
|
|
81
|
-
const distance = Math.abs(target.time - time);
|
|
82
|
-
if (distance < bestDistance) {
|
|
83
|
-
bestDistance = distance;
|
|
84
|
-
best = { target, distance };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return best;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function snapEdgesToTargets(
|
|
91
|
-
start: number,
|
|
92
|
-
duration: number,
|
|
93
|
-
targets: TimelineSnapTarget[],
|
|
94
|
-
pixelsPerSecond: number,
|
|
95
|
-
options?: { maxStart?: number },
|
|
96
|
-
): { start: number; snapTime: number | null; snapKind: TimelineSnapKind | null } {
|
|
97
|
-
const thresholdSeconds = SNAP_PX / Math.max(pixelsPerSecond, 1);
|
|
98
|
-
const startSnap = nearestSnap(start, targets, thresholdSeconds);
|
|
99
|
-
const endSnap = nearestSnap(start + duration, targets, thresholdSeconds);
|
|
100
|
-
|
|
101
|
-
let candidate = start;
|
|
102
|
-
let snapTarget: TimelineSnapTarget | null = null;
|
|
103
|
-
if (startSnap && (!endSnap || startSnap.distance <= endSnap.distance)) {
|
|
104
|
-
candidate = startSnap.target.time;
|
|
105
|
-
snapTarget = startSnap.target;
|
|
106
|
-
} else if (endSnap) {
|
|
107
|
-
candidate = endSnap.target.time - duration;
|
|
108
|
-
snapTarget = endSnap.target;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const maxStart = options?.maxStart ?? Number.POSITIVE_INFINITY;
|
|
112
|
-
const upperStart = Number.isFinite(maxStart) ? Math.max(0, maxStart) : Number.POSITIVE_INFINITY;
|
|
113
|
-
const clamped = Math.max(0, Math.min(upperStart, roundToMillis(candidate)));
|
|
114
|
-
if (snapTarget && Math.abs(clamped - candidate) > 1e-6) {
|
|
115
|
-
return { start: clamped, snapTime: null, snapKind: null };
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
start: clamped,
|
|
119
|
-
snapTime: snapTarget?.time ?? null,
|
|
120
|
-
snapKind: snapTarget?.kind ?? null,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function snapResizeEdgeToTargets(
|
|
125
|
-
edge: "start" | "end",
|
|
126
|
-
start: number,
|
|
127
|
-
duration: number,
|
|
128
|
-
targets: TimelineSnapTarget[],
|
|
129
|
-
pixelsPerSecond: number,
|
|
130
|
-
limits: { minDuration: number; maxEnd: number; maxLeftDelta?: number },
|
|
131
|
-
): { start: number; duration: number; snapTime: number | null; snapKind: TimelineSnapKind | null } {
|
|
132
|
-
const thresholdSeconds = SNAP_PX / Math.max(pixelsPerSecond, 1);
|
|
133
|
-
|
|
134
|
-
if (edge === "end") {
|
|
135
|
-
const snap = nearestSnap(start + duration, targets, thresholdSeconds);
|
|
136
|
-
if (!snap) return { start, duration, snapTime: null, snapKind: null };
|
|
137
|
-
const snappedDuration = roundToMillis(snap.target.time - start);
|
|
138
|
-
if (snap.target.time > limits.maxEnd + 1e-6 || snappedDuration < limits.minDuration) {
|
|
139
|
-
return { start, duration, snapTime: null, snapKind: null };
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
start,
|
|
143
|
-
duration: snappedDuration,
|
|
144
|
-
snapTime: snap.target.time,
|
|
145
|
-
snapKind: snap.target.kind,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const snap = nearestSnap(start, targets, thresholdSeconds);
|
|
150
|
-
if (!snap) return { start, duration, snapTime: null, snapKind: null };
|
|
151
|
-
const snappedStart = roundToMillis(snap.target.time);
|
|
152
|
-
const delta = start - snappedStart;
|
|
153
|
-
const snappedDuration = roundToMillis(duration + delta);
|
|
154
|
-
const maxLeftDelta = limits.maxLeftDelta ?? Number.POSITIVE_INFINITY;
|
|
155
|
-
if (snappedStart < 0 || delta > maxLeftDelta + 1e-6 || snappedDuration < limits.minDuration) {
|
|
156
|
-
return { start, duration, snapTime: null, snapKind: null };
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
start: snappedStart,
|
|
160
|
-
duration: snappedDuration,
|
|
161
|
-
snapTime: snap.target.time,
|
|
162
|
-
snapKind: snap.target.kind,
|
|
163
|
-
};
|
|
164
|
-
}
|