@hyperframes/studio 0.8.114 → 0.8.115
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/{hyperframes-player-aXNJKiIg.js → hyperframes-player-C-9N8nk0.js} +1 -1
- package/dist/assets/{index-Bn2RJNTJ.js → index-BoUM6Xqb.js} +1 -1
- package/dist/assets/{index-Dz7doz9l.js → index-CAvZ0AA-.js} +201 -201
- package/dist/assets/{index-C9N-DGjC.js → index-CVuorIMv.js} +1 -1
- package/dist/assets/{index-BYnsJnJV.css → index-t1LH6H5H.css} +1 -1
- package/dist/{chunk-K47E2ZJA.js → chunk-5EKWJZLM.js} +504 -17
- package/dist/chunk-5EKWJZLM.js.map +1 -0
- package/dist/{chunk-VWT7STY3.js → chunk-J6Q572FA.js} +2 -2
- package/dist/{chunk-BIUXP3PG.js → chunk-TXZMMOMA.js} +43 -276
- package/dist/chunk-TXZMMOMA.js.map +1 -0
- package/dist/{domEditingLayers-V67MS4WP.js → domEditingLayers-D7VYFJJD.js} +3 -5
- package/dist/index.d.ts +43 -19
- package/dist/index.html +2 -2
- package/dist/index.js +2939 -2596
- package/dist/index.js.map +1 -1
- package/dist/player.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +9 -8
- package/src/App.tsx +2 -2
- package/src/components/LinkedSelectionToggle.tsx +3 -2
- package/src/components/dock/Dock.tsx +5 -7
- package/src/components/editor/CanvasContextMenu.tsx +3 -2
- package/src/components/editor/DomEditCropHandles.test.tsx +27 -0
- package/src/components/editor/DomEditCropHandles.tsx +7 -4
- package/src/components/editor/DomEditOverlay.tsx +5 -1
- package/src/components/editor/FileTreeNodes.tsx +13 -10
- package/src/components/editor/MotionPathOverlay.tsx +7 -2
- package/src/components/editor/PropertyPanelEmptyState.tsx +12 -2
- package/src/components/editor/SnapToolbar.test.tsx +100 -1
- package/src/components/editor/SnapToolbar.tsx +43 -5
- package/src/components/editor/anchoredResizeCommitFeedsOffset.test.ts +48 -1
- package/src/components/editor/audioFxTelemetry.ts +2 -3
- package/src/components/editor/commitPreflightHandles.test.tsx +2 -2
- package/src/components/editor/cropResize.ts +4 -3
- package/src/components/editor/domEditingDom.ts +4 -0
- package/src/components/editor/domEditingLayers.ts +1 -5
- package/src/components/editor/manualEdits.ts +1 -0
- package/src/components/editor/manualEditsParsing.ts +7 -0
- package/src/components/editor/marqueeCommit.test.tsx +106 -37
- package/src/components/editor/marqueeCommit.ts +24 -8
- package/src/components/editor/motionPathCommit.test.ts +29 -1
- package/src/components/editor/motionPathCommit.ts +21 -9
- package/src/components/editor/probeSourceElement.test.ts +45 -0
- package/src/components/editor/probeSourceElement.ts +39 -15
- package/src/components/editor/propertyPanelFlatTextSection.tsx +10 -7
- package/src/components/editor/propertyPanelFxAddMenu.tsx +11 -2
- package/src/components/editor/propertyPanelFxCarveModule.tsx +15 -5
- package/src/components/editor/propertyPanelFxNodeOpenBody.tsx +3 -0
- package/src/components/editor/propertyPanelFxNodeParams.tsx +15 -2
- package/src/components/editor/propertyPanelFxNodeRow.tsx +3 -0
- package/src/components/editor/propertyPanelFxPresetRun.tsx +10 -2
- package/src/components/editor/propertyPanelFxSection.test.tsx +56 -0
- package/src/components/editor/propertyPanelFxSection.tsx +30 -28
- package/src/components/editor/propertyPanelTypes.ts +6 -3
- package/src/components/editor/useDomEditNudge.test.tsx +37 -0
- package/src/components/editor/useDomEditNudge.ts +2 -0
- package/src/components/editor/useDomEditOverlayGestures.ts +5 -0
- package/src/components/editor/useDomEditZOrder.ts +12 -2
- package/src/components/nle/useTimelineEditCallbacks.test.tsx +1 -0
- package/src/components/nle/useTimelineEditCallbacks.ts +7 -1
- package/src/components/sidebar/AssetContextMenu.tsx +4 -4
- package/src/components/ui/menuStyle.test.ts +61 -0
- package/src/components/ui/menuStyle.ts +10 -0
- package/src/contexts/DomEditContext.tsx +1 -1
- package/src/contexts/TimelineEditContext.tsx +1 -0
- package/src/domEditExports.test.tsx +9 -1
- package/src/hooks/domEditCommitRunner.ts +1 -1
- package/src/hooks/elementOffsetStager.ts +5 -4
- package/src/hooks/gsapDragCommit.ts +2 -20
- package/src/hooks/gsapDragPositionCommit.ts +18 -3
- package/src/hooks/gsapGestureOutcome.test.ts +161 -0
- package/src/hooks/gsapGestureOutcome.ts +64 -0
- package/src/hooks/gsapKeyframeCommit.ts +3 -12
- package/src/hooks/gsapResizeIntercept.test.ts +33 -0
- package/src/hooks/gsapResizeIntercept.ts +1 -0
- package/src/hooks/gsapScriptCommitTypes.ts +5 -0
- package/src/hooks/gsapShared.writeTarget.test.ts +20 -0
- package/src/hooks/keyframeCacheAstLoad.ts +6 -5
- package/src/hooks/plainRotation.ts +3 -2
- package/src/hooks/previewPromotionSelection.test.tsx +1 -1
- package/src/hooks/refreshTimelineRowText.test.ts +65 -0
- package/src/hooks/refreshTimelineRowText.ts +29 -0
- package/src/hooks/useAnimatedPropertyCommit.test.tsx +46 -5
- package/src/hooks/useAnimatedPropertyCommit.ts +2 -2
- package/src/hooks/useBlockedTimelineEditToast.ts +12 -3
- package/src/hooks/useDomEditPositionPatchCommit.ts +18 -23
- package/src/hooks/useDomEditTextCommits.test.tsx +18 -0
- package/src/hooks/useDomEditTextCommits.ts +5 -1
- package/src/hooks/useDomEditWiring.ts +4 -2
- package/src/hooks/useDomGeometryCommit.test.tsx +25 -6
- package/src/hooks/useDomGeometryCommit.ts +7 -4
- package/src/hooks/useDomGeometryCommits.test.tsx +1 -0
- package/src/hooks/useDomGeometryCommits.ts +3 -2
- package/src/hooks/useDomSelection.test.ts +26 -0
- package/src/hooks/useDomSelection.ts +10 -3
- package/src/hooks/useDomSelectionTypes.ts +6 -1
- package/src/hooks/useEnableKeyframes.test.ts +2 -2
- package/src/hooks/useEnableKeyframes.ts +5 -3
- package/src/hooks/useExternalFileChangeCoordinator.test.tsx +102 -0
- package/src/hooks/useExternalFileChangeCoordinator.ts +31 -6
- package/src/hooks/useGestureCommit.test.tsx +225 -55
- package/src/hooks/useGestureCommit.ts +86 -55
- package/src/hooks/useGsapAwareEditing.test.tsx +11 -6
- package/src/hooks/useGsapAwareEditing.ts +96 -195
- package/src/hooks/useGsapAwareGroupMove.ts +179 -0
- package/src/hooks/useGsapKeyframeOps.sdkUsage.test.tsx +114 -0
- package/src/hooks/useGsapKeyframeOps.ts +36 -10
- package/src/hooks/useGsapScriptCommits.test.tsx +57 -0
- package/src/hooks/useGsapScriptCommits.ts +3 -0
- package/src/hooks/useGsapSelectionHandlers.test.tsx +1 -1
- package/src/hooks/useGsapSelectionHandlers.ts +24 -18
- package/src/hooks/useGsapTweenCache.ts +18 -12
- package/src/hooks/usePopulateKeyframeCacheForFile.test.tsx +76 -2
- package/src/hooks/usePreviewInteraction.test.ts +21 -0
- package/src/hooks/usePreviewInteraction.ts +2 -0
- package/src/hooks/useRenderClipContent.test.ts +18 -0
- package/src/hooks/useRenderClipContent.ts +4 -5
- package/src/hooks/useTimelineDeleteOps.test.tsx +30 -22
- package/src/hooks/useTimelineDeleteOps.ts +21 -27
- package/src/hooks/useTimelineEditing.test.tsx +1 -1
- package/src/player/components/AutomationSelectionMenu.tsx +3 -2
- package/src/player/components/ClipContextMenu.test.tsx +73 -0
- package/src/player/components/ClipContextMenu.tsx +33 -31
- package/src/player/components/KeyframeDiamondContextMenu.tsx +8 -9
- package/src/player/components/OutOfSyncBadge.tsx +5 -5
- package/src/player/components/TextClipContent.test.ts +19 -0
- package/src/player/components/TextClipContent.tsx +27 -0
- package/src/player/components/TrackGapContextMenu.tsx +3 -6
- package/src/player/components/clipMenuToolItems.test.tsx +23 -0
- package/src/player/components/clipMenuToolItems.tsx +13 -9
- package/src/player/components/timelineCallbacks.ts +1 -0
- package/src/player/components/timelineClipDragGestureLifecycle.ts +1 -1
- package/src/player/components/timelineClipGestureHandlers.test.ts +94 -0
- package/src/player/components/timelineClipGestureHandlers.ts +20 -2
- package/src/player/components/timelineEditing.ts +3 -1
- package/src/player/components/timelineLinkSelection.ts +35 -1
- package/src/player/components/useTimelineClipDrag.keyboard.test.tsx +14 -0
- package/src/player/components/useTimelineClipDrag.ts +6 -7
- package/src/player/hooks/timelinePlayerSync.test.ts +6 -0
- package/src/player/hooks/timelinePlayerSync.ts +6 -1
- package/src/player/lib/timelineElementHelpers.test.ts +87 -1
- package/src/player/lib/timelineElementHelpers.ts +6 -15
- package/src/player/lib/timelineText.ts +40 -0
- package/src/player/store/timelineElement.ts +12 -0
- package/src/styles/theme.css +3 -0
- package/src/utils/keyframeUsage.ts +79 -0
- package/src/utils/previewFeatureUsage.test.ts +32 -0
- package/src/utils/previewFeatureUsage.ts +46 -0
- package/src/utils/studioTelemetry.test.ts +107 -0
- package/src/utils/studioTelemetry.ts +49 -4
- package/src/webmcp/StudioAgentTools.tsx +2 -2
- package/dist/chunk-BIUXP3PG.js.map +0 -1
- package/dist/chunk-K47E2ZJA.js.map +0 -1
- /package/dist/{chunk-VWT7STY3.js.map → chunk-J6Q572FA.js.map} +0 -0
- /package/dist/{domEditingLayers-V67MS4WP.js.map → domEditingLayers-D7VYFJJD.js.map} +0 -0
|
@@ -137,6 +137,7 @@ export interface TimelineEditCallbacks {
|
|
|
137
137
|
onRazorSplit?: (element: TimelineElement, splitTime: number) => Promise<void> | void;
|
|
138
138
|
onRazorSplitAll?: (splitTime: number) => Promise<void> | void;
|
|
139
139
|
onFreezeFrame?: (element: TimelineElement, time: number) => Promise<void> | void;
|
|
140
|
+
clipMenuTools?: boolean;
|
|
140
141
|
onNotice?: (message: string, tone?: "error" | "info") => void;
|
|
141
142
|
onDeleteKeyframe?: (elementId: string, keyframe: TimelineKeyframeTarget) => void;
|
|
142
143
|
onDeleteAllKeyframes?: (element: TimelineElement, animationId?: string) => void;
|
|
@@ -195,7 +195,7 @@ export function mountTimelineClipDragGestureLifecycle({
|
|
|
195
195
|
event.clientX - blocked.originClientX,
|
|
196
196
|
event.clientY - blocked.originClientY,
|
|
197
197
|
);
|
|
198
|
-
const threshold = blocked.intent === "move" ? 4 : 2;
|
|
198
|
+
const threshold = blocked.intent === "move" || blocked.intent === "edit-many" ? 4 : 2;
|
|
199
199
|
if (!blocked.started && distance < threshold) return;
|
|
200
200
|
if (!blocked.started) {
|
|
201
201
|
blocked.started = true;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import type { PointerEvent as ReactPointerEvent } from "react";
|
|
5
|
+
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
6
|
+
import { createClipGestureHandlers, type ClipGestureDeps } from "./timelineClipGestureHandlers";
|
|
7
|
+
import { MAX_HAND_EDIT_CLIPS } from "./timelineEditing";
|
|
8
|
+
|
|
9
|
+
afterEach(() => usePlayerStore.getState().reset());
|
|
10
|
+
|
|
11
|
+
const clips: TimelineElement[] = Array.from({ length: 6 }, (_, i) => ({
|
|
12
|
+
id: `clip-${i}`,
|
|
13
|
+
domId: `clip-${i}`,
|
|
14
|
+
tag: "div",
|
|
15
|
+
start: i,
|
|
16
|
+
duration: 1,
|
|
17
|
+
track: i,
|
|
18
|
+
}));
|
|
19
|
+
const capabilities = { canMove: true, canTrimStart: true, canTrimEnd: true, readOnly: false };
|
|
20
|
+
|
|
21
|
+
function grabFirstClip(count: number, gesture: "move" | "resize", locked: number[] = []) {
|
|
22
|
+
const store = usePlayerStore.getState();
|
|
23
|
+
store.setElements(
|
|
24
|
+
clips.map((clip, i) => (locked.includes(i) ? { ...clip, timelineLocked: true } : clip)),
|
|
25
|
+
);
|
|
26
|
+
store.setSelectedElementIds(new Set(clips.slice(0, count).map((c) => c.id)));
|
|
27
|
+
const setDraggedClip = vi.fn();
|
|
28
|
+
const setResizingClip = vi.fn();
|
|
29
|
+
const blockedClipRef = { current: null as { intent: string } | null };
|
|
30
|
+
const deps = {
|
|
31
|
+
pps: 100,
|
|
32
|
+
onMoveElement: vi.fn(),
|
|
33
|
+
onResizeElement: vi.fn(),
|
|
34
|
+
blockedClipRef,
|
|
35
|
+
suppressClickRef: { current: false },
|
|
36
|
+
scrollRef: { current: null },
|
|
37
|
+
setShowPopover: vi.fn(),
|
|
38
|
+
setRangeSelection: vi.fn(),
|
|
39
|
+
setResizingClip,
|
|
40
|
+
setDraggedClip,
|
|
41
|
+
setSelectedElementId: vi.fn(),
|
|
42
|
+
} as unknown as ClipGestureDeps;
|
|
43
|
+
const handlers = createClipGestureHandlers(clips[0], clips[0].id, clips[0], capabilities, deps);
|
|
44
|
+
const event = {
|
|
45
|
+
button: 0,
|
|
46
|
+
clientX: 50,
|
|
47
|
+
clientY: 5,
|
|
48
|
+
pointerId: 1,
|
|
49
|
+
stopPropagation: vi.fn(),
|
|
50
|
+
currentTarget: { getBoundingClientRect: () => ({ left: 0, width: 100 }) },
|
|
51
|
+
} as unknown as ReactPointerEvent;
|
|
52
|
+
if (gesture === "move") handlers.onPointerDown(event);
|
|
53
|
+
else handlers.onResizeStart("end", event);
|
|
54
|
+
return { setDraggedClip, setResizingClip, blockedClipRef };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe("hand-editing a multi-selection", () => {
|
|
58
|
+
it("moves up to the limit by hand", () => {
|
|
59
|
+
const { setDraggedClip, blockedClipRef } = grabFirstClip(MAX_HAND_EDIT_CLIPS, "move");
|
|
60
|
+
expect(setDraggedClip).toHaveBeenCalledOnce();
|
|
61
|
+
expect(blockedClipRef.current).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("refuses to start a drag above the limit and asks for the toast", () => {
|
|
65
|
+
const { setDraggedClip, blockedClipRef } = grabFirstClip(MAX_HAND_EDIT_CLIPS + 1, "move");
|
|
66
|
+
expect(setDraggedClip).not.toHaveBeenCalled();
|
|
67
|
+
expect(blockedClipRef.current?.intent).toBe("edit-many");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("resizes up to the limit by hand", () => {
|
|
71
|
+
const { setResizingClip, blockedClipRef } = grabFirstClip(MAX_HAND_EDIT_CLIPS, "resize");
|
|
72
|
+
expect(setResizingClip).toHaveBeenCalledOnce();
|
|
73
|
+
expect(blockedClipRef.current).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("refuses to start a resize above the limit and asks for the toast", () => {
|
|
77
|
+
const { setResizingClip, blockedClipRef } = grabFirstClip(MAX_HAND_EDIT_CLIPS + 1, "resize");
|
|
78
|
+
expect(setResizingClip).not.toHaveBeenCalled();
|
|
79
|
+
expect(blockedClipRef.current?.intent).toBe("edit-many");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("counts the clips a move would change: locked ones in the selection stay put", () => {
|
|
83
|
+
const allowed = grabFirstClip(MAX_HAND_EDIT_CLIPS + 2, "move", [3, 4]);
|
|
84
|
+
expect(allowed.setDraggedClip).toHaveBeenCalledOnce();
|
|
85
|
+
const refused = grabFirstClip(MAX_HAND_EDIT_CLIPS + 2, "move", [4]);
|
|
86
|
+
expect(refused.setDraggedClip).not.toHaveBeenCalled();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("counts the clips a trim would change: a locked member leaves a trim of the grabbed clip alone", () => {
|
|
90
|
+
const allowed = grabFirstClip(MAX_HAND_EDIT_CLIPS + 1, "resize", [3]);
|
|
91
|
+
expect(allowed.setResizingClip).toHaveBeenCalledOnce();
|
|
92
|
+
expect(allowed.blockedClipRef.current).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
import type { TimelineEditCapabilities } from "./timelineEditCapabilities";
|
|
9
9
|
import type { TimelineEditCallbacks } from "./timelineCallbacks";
|
|
10
10
|
import { CLIP_HANDLE_W } from "./timelineLayout";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
exceedsHandEditLimit,
|
|
13
|
+
selectClipWithLinks,
|
|
14
|
+
toggleClipWithLinks,
|
|
15
|
+
} from "./timelineLinkSelection";
|
|
12
16
|
import { SPLIT_BOUNDARY_EPSILON_S } from "../../utils/timelineElementSplit";
|
|
13
17
|
|
|
14
18
|
export interface ClipGestureDeps {
|
|
@@ -73,6 +77,7 @@ function isIntentBlocked(
|
|
|
73
77
|
*/
|
|
74
78
|
function resolvePointerDownAction(
|
|
75
79
|
e: ReactPointerEvent,
|
|
80
|
+
grabbed: TimelineElement,
|
|
76
81
|
capabilities: TimelineEditCapabilities,
|
|
77
82
|
onResizeElement: ClipGestureDeps["onResizeElement"],
|
|
78
83
|
onMoveElement: ClipGestureDeps["onMoveElement"],
|
|
@@ -93,6 +98,8 @@ function resolvePointerDownAction(
|
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
if (!onMoveElement || !capabilities.canMove) return { kind: "ignore" };
|
|
101
|
+
if (exceedsHandEditLimit(grabbed, e.altKey, null))
|
|
102
|
+
return { kind: "block", intent: "edit-many", rect };
|
|
96
103
|
return { kind: "move", rect };
|
|
97
104
|
}
|
|
98
105
|
|
|
@@ -129,6 +136,17 @@ export function createClipGestureHandlers(
|
|
|
129
136
|
const onResizeStart = (edge: "start" | "end", e: ReactPointerEvent): void => {
|
|
130
137
|
if (!canStartResize(edge, e, capabilities, onResizeElement)) return;
|
|
131
138
|
e.stopPropagation();
|
|
139
|
+
if (exceedsHandEditLimit(el, e.altKey, edge)) {
|
|
140
|
+
blockedClipRef.current = {
|
|
141
|
+
pointerId: e.pointerId,
|
|
142
|
+
element: el,
|
|
143
|
+
intent: "edit-many",
|
|
144
|
+
originClientX: e.clientX,
|
|
145
|
+
originClientY: e.clientY,
|
|
146
|
+
started: false,
|
|
147
|
+
};
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
132
150
|
blockedClipRef.current = null;
|
|
133
151
|
setShowPopover(false);
|
|
134
152
|
setRangeSelection(null);
|
|
@@ -147,7 +165,7 @@ export function createClipGestureHandlers(
|
|
|
147
165
|
};
|
|
148
166
|
|
|
149
167
|
const onPointerDown = (e: ReactPointerEvent): void => {
|
|
150
|
-
const action = resolvePointerDownAction(e, capabilities, onResizeElement, onMoveElement);
|
|
168
|
+
const action = resolvePointerDownAction(e, el, capabilities, onResizeElement, onMoveElement);
|
|
151
169
|
if (action.kind === "ignore") return;
|
|
152
170
|
|
|
153
171
|
if (action.kind === "block") {
|
|
@@ -248,7 +248,9 @@ export interface TimelinePromptElement {
|
|
|
248
248
|
track: number;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
export type BlockedTimelineEditIntent = "move" | "resize-start" | "resize-end";
|
|
251
|
+
export type BlockedTimelineEditIntent = "move" | "edit-many" | "resize-start" | "resize-end";
|
|
252
|
+
|
|
253
|
+
export const MAX_HAND_EDIT_CLIPS = 3;
|
|
252
254
|
|
|
253
255
|
export interface TimelineRangeSelection {
|
|
254
256
|
start: number;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
dropMisalignedTrimPartners,
|
|
4
|
+
expandToLinkedMembers,
|
|
5
|
+
linkedGestureKeys,
|
|
6
|
+
linkedMembersOf,
|
|
7
|
+
} from "./audioClipLink";
|
|
8
|
+
import { buildTimelineGroupResizeMembers } from "./timelineGroupEditing";
|
|
9
|
+
import { resolveGroupMovers } from "./timelineMultiDragPreview";
|
|
10
|
+
import { MAX_HAND_EDIT_CLIPS } from "./timelineEditing";
|
|
3
11
|
import { isLinkedSelectionOn } from "../../utils/linkedClipPreferences";
|
|
4
12
|
|
|
5
13
|
/**
|
|
@@ -39,3 +47,29 @@ export function toggleClipWithLinks(key: string, altKey: boolean): TimelineEleme
|
|
|
39
47
|
const primary = usePlayerStore.getState().selectedElementId;
|
|
40
48
|
return state.elements.find((el) => (el.key ?? el.id) === primary) ?? null;
|
|
41
49
|
}
|
|
50
|
+
|
|
51
|
+
/** Whether a hand drag on `grabbed` (trimming `edge`, or null to move) would change more clips than allowed. */
|
|
52
|
+
export function exceedsHandEditLimit(
|
|
53
|
+
grabbed: TimelineElement,
|
|
54
|
+
altKey: boolean,
|
|
55
|
+
edge: "start" | "end" | null,
|
|
56
|
+
): boolean {
|
|
57
|
+
const { selectedElementIds, elements } = usePlayerStore.getState();
|
|
58
|
+
const grabbedKey = grabbed.key ?? grabbed.id;
|
|
59
|
+
const keys = linkedGestureKeys(
|
|
60
|
+
selectedElementIds,
|
|
61
|
+
grabbed,
|
|
62
|
+
elements,
|
|
63
|
+
altKey,
|
|
64
|
+
isLinkedSelectionOn(),
|
|
65
|
+
);
|
|
66
|
+
const changed = edge
|
|
67
|
+
? buildTimelineGroupResizeMembers(
|
|
68
|
+
elements,
|
|
69
|
+
dropMisalignedTrimPartners(keys, grabbed, elements, edge),
|
|
70
|
+
grabbedKey,
|
|
71
|
+
edge,
|
|
72
|
+
)
|
|
73
|
+
: resolveGroupMovers(elements, keys, grabbedKey);
|
|
74
|
+
return (changed?.length ?? 1) > MAX_HAND_EDIT_CLIPS;
|
|
75
|
+
}
|
|
@@ -49,6 +49,7 @@ function mount(order = [0, 1, 2]) {
|
|
|
49
49
|
const host = document.createElement("div");
|
|
50
50
|
const root = createRoot(host);
|
|
51
51
|
const onMoveElements = vi.fn();
|
|
52
|
+
const onBlockedEditAttempt = vi.fn();
|
|
52
53
|
const trackOrderRef = { current: order };
|
|
53
54
|
const trackInsertLayoutRef = { current: buildTimelineTrackInsertLayout(order, groups) };
|
|
54
55
|
let state: ReturnType<typeof useTimelineClipDrag>;
|
|
@@ -68,6 +69,7 @@ function mount(order = [0, 1, 2]) {
|
|
|
68
69
|
},
|
|
69
70
|
onMoveElement: vi.fn(),
|
|
70
71
|
onMoveElements,
|
|
72
|
+
onBlockedEditAttempt,
|
|
71
73
|
setShowPopover: () => {},
|
|
72
74
|
setRangeSelectionRef: { current: null },
|
|
73
75
|
});
|
|
@@ -83,6 +85,7 @@ function mount(order = [0, 1, 2]) {
|
|
|
83
85
|
key,
|
|
84
86
|
clip,
|
|
85
87
|
onMoveElements,
|
|
88
|
+
onBlockedEditAttempt,
|
|
86
89
|
root,
|
|
87
90
|
elements,
|
|
88
91
|
changeOrder(next: number[]) {
|
|
@@ -161,3 +164,14 @@ it("leaves Space on a nested fade slider to the slider", () => {
|
|
|
161
164
|
expect(event.defaultPrevented).toBe(false);
|
|
162
165
|
act(() => view.root.unmount());
|
|
163
166
|
});
|
|
167
|
+
|
|
168
|
+
it("does not pick up a clip held in a selection above the hand-move limit", () => {
|
|
169
|
+
const view = mount();
|
|
170
|
+
usePlayerStore.getState().setSelection(["top", "hero", "tail", "bottom"], "hero");
|
|
171
|
+
view.key(" ");
|
|
172
|
+
expect(view.drag).toBeNull();
|
|
173
|
+
expect(view.onBlockedEditAttempt).toHaveBeenCalledWith(
|
|
174
|
+
expect.objectContaining({ id: "hero" }),
|
|
175
|
+
"edit-many",
|
|
176
|
+
);
|
|
177
|
+
});
|
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
} from "./timelineClipDragTypes";
|
|
30
30
|
import { getTimelineElementIndexes } from "../lib/timelineElementIndexes";
|
|
31
31
|
import { dropMisalignedTrimPartners, linkedGestureKeys } from "./audioClipLink";
|
|
32
|
+
import { exceedsHandEditLimit } from "./timelineLinkSelection";
|
|
32
33
|
import { isLinkedSelectionOn } from "../../utils/linkedClipPreferences";
|
|
33
34
|
import { useTimelineClipCapabilities } from "./timelineReadOnly";
|
|
34
35
|
import { timelineClipFocusId } from "./timelineNavigationIdentity";
|
|
@@ -158,11 +159,8 @@ export function useTimelineClipDrag({
|
|
|
158
159
|
const elementsRef = useRef(elements);
|
|
159
160
|
elementsRef.current = elements;
|
|
160
161
|
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
// gesture), so build each ONCE and reuse it across every pointermove and every
|
|
164
|
-
// auto-scroll frame. Both caches are cleared at gesture teardown
|
|
165
|
-
// (stopClipDragAutoScroll), so the next gesture rebuilds against fresh state.
|
|
162
|
+
// The snap-target and audio-track sets are fixed for one drag/resize (the store is not
|
|
163
|
+
// re-authored mid gesture): built once, reused per pointermove, cleared at teardown.
|
|
166
164
|
const snapTargetsCacheRef = useRef<Map<string, TimelineSnapTarget[]>>(new Map());
|
|
167
165
|
const dragAudioTracksRef = useRef<ReadonlySet<number> | null>(null);
|
|
168
166
|
|
|
@@ -272,8 +270,7 @@ export function useTimelineClipDrag({
|
|
|
272
270
|
const blockedClipRef = useRef<BlockedClipState | null>(null);
|
|
273
271
|
const suppressClickRef = useRef(false);
|
|
274
272
|
|
|
275
|
-
//
|
|
276
|
-
// It owns a projection only; canonical store timing changes at commit.
|
|
273
|
+
// Group-resize session, created on first movement; a projection only, committed at the end.
|
|
277
274
|
const groupResizeRef = useRef<TimelineGroupResizeSession | null>(null);
|
|
278
275
|
|
|
279
276
|
const onMoveElementRef = useRef(onMoveElement);
|
|
@@ -541,6 +538,8 @@ export function useTimelineClipDrag({
|
|
|
541
538
|
if (!element || !getClipCapabilities(element).canMove) return;
|
|
542
539
|
event.preventDefault();
|
|
543
540
|
event.stopImmediatePropagation();
|
|
541
|
+
if (exceedsHandEditLimit(element, false, null))
|
|
542
|
+
return void onBlockedEditAttemptRef.current?.(element, "edit-many");
|
|
544
543
|
setShowPopover(false);
|
|
545
544
|
setRangeSelectionRef.current?.(null);
|
|
546
545
|
const row = keyboardPickupInsertRow(
|
|
@@ -31,4 +31,10 @@ describe("timelineElementsChanged", () => {
|
|
|
31
31
|
expect(timelineElementsChanged([grouped], [clip])).toBe(true);
|
|
32
32
|
expect(timelineElementsChanged([grouped], [{ ...grouped }])).toBe(false);
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
it("sees a change to a text row's words, but not an identical re-read", () => {
|
|
36
|
+
const row = { id: "t", tag: "h1", start: 0, duration: 2, track: 0, text: { value: "Old" } };
|
|
37
|
+
expect(timelineElementsChanged([row], [{ ...row, text: { value: "Old" } }])).toBe(false);
|
|
38
|
+
expect(timelineElementsChanged([row], [{ ...row, text: { value: "New" } }])).toBe(true);
|
|
39
|
+
});
|
|
34
40
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TimelineElement } from "../store/playerStore";
|
|
2
|
+
import { sameTimelineText } from "../lib/timelineText";
|
|
2
3
|
|
|
3
4
|
const RENDERED_FIELDS: readonly (keyof TimelineElement)[] = [
|
|
4
5
|
"id",
|
|
@@ -28,6 +29,10 @@ export function timelineElementsChanged(
|
|
|
28
29
|
if (next.length !== previous.length) return true;
|
|
29
30
|
return next.some((element, index) => {
|
|
30
31
|
const prior = previous[index];
|
|
31
|
-
return
|
|
32
|
+
return (
|
|
33
|
+
!prior ||
|
|
34
|
+
RENDERED_FIELDS.some((key) => element[key] !== prior[key]) ||
|
|
35
|
+
!sameTimelineText(element.text, prior.text)
|
|
36
|
+
);
|
|
32
37
|
});
|
|
33
38
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
1
2
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
+
import type { TimelineElement } from "../store/playerStore";
|
|
4
|
+
import {
|
|
5
|
+
applyMediaMetadataFromElement,
|
|
6
|
+
getTimelineElementSelector,
|
|
7
|
+
isVideoAudible,
|
|
8
|
+
resolveMediaElement,
|
|
9
|
+
} from "./timelineElementHelpers";
|
|
10
|
+
import { readTimelineText, sameTimelineText } from "./timelineText";
|
|
3
11
|
|
|
4
12
|
describe("isVideoAudible — the compiler's data-has-audio rule", () => {
|
|
5
13
|
it("explicit data-has-audio wins", () => {
|
|
@@ -14,3 +22,81 @@ describe("isVideoAudible — the compiler's data-has-audio rule", () => {
|
|
|
14
22
|
expect(isVideoAudible({ tag: "img", hasAudioAttr: null, muted: false })).toBe(false);
|
|
15
23
|
});
|
|
16
24
|
});
|
|
25
|
+
|
|
26
|
+
describe("preview nodes built in another realm", () => {
|
|
27
|
+
// The Studio preview's body carries the editor window's prototypes, so its
|
|
28
|
+
// nodes fail `instanceof` against their own window's HTMLElement.
|
|
29
|
+
function foreignNode(html: string): Element {
|
|
30
|
+
const holder = document.createElement("div");
|
|
31
|
+
holder.innerHTML = html;
|
|
32
|
+
const node = holder.firstElementChild!;
|
|
33
|
+
document.body.appendChild(node);
|
|
34
|
+
Object.setPrototypeOf(node, Object.create(Element.prototype));
|
|
35
|
+
expect(node instanceof HTMLElement).toBe(false);
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
it("gives a row with an id its id selector", () => {
|
|
40
|
+
const el = foreignNode(`<div id="layer-00" class="clip layer"></div>`);
|
|
41
|
+
expect(getTimelineElementSelector(el)).toBe("#layer-00");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("reads media metadata off a foreign <video>", () => {
|
|
45
|
+
const el = foreignNode(`<video src="a.mp4" data-source-duration="12"></video>`);
|
|
46
|
+
expect(resolveMediaElement(el)).toBe(el);
|
|
47
|
+
const entry = { id: "v", tag: "div", start: 0, duration: 4, track: 0 } as TimelineElement;
|
|
48
|
+
applyMediaMetadataFromElement(entry, el);
|
|
49
|
+
expect(entry.sourceDuration).toBe(12);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("readTimelineText", () => {
|
|
54
|
+
function layer(html: string): Element {
|
|
55
|
+
document.body.innerHTML = html;
|
|
56
|
+
return document.body.firstElementChild!;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
it("reads a text layer's words, collapsed to one line, with its font and colour", () => {
|
|
60
|
+
const text = readTimelineText(
|
|
61
|
+
layer(`<h1 style="font-family: Georgia; font-weight: 700; color: rgb(255, 0, 0)">
|
|
62
|
+
Ship <span>it</span>
|
|
63
|
+
</h1>`),
|
|
64
|
+
);
|
|
65
|
+
expect(text).toMatchObject({ value: "Ship it", fontWeight: "700", color: "rgb(255, 0, 0)" });
|
|
66
|
+
expect(text?.fontFamily).toContain("Georgia");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("leaves a layer that holds anything but text, or no words, to its picture", () => {
|
|
70
|
+
expect(
|
|
71
|
+
readTimelineText(layer(`<div><div>Title</div><div><i></i></div></div>`)),
|
|
72
|
+
).toBeUndefined();
|
|
73
|
+
expect(readTimelineText(layer(`<div class="glyph"></div>`))).toBeUndefined();
|
|
74
|
+
expect(readTimelineText(layer(`<section>Words</section>`))).toBeUndefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("keeps a layer that paints an image as a picture, and carries a flat background colour", () => {
|
|
78
|
+
expect(
|
|
79
|
+
readTimelineText(
|
|
80
|
+
layer(`<div style="background-image: linear-gradient(red, blue)">L01</div>`),
|
|
81
|
+
),
|
|
82
|
+
).toBeUndefined();
|
|
83
|
+
expect(
|
|
84
|
+
readTimelineText(layer(`<div style="background-color: rgb(230, 57, 70)">Go</div>`)),
|
|
85
|
+
).toMatchObject({
|
|
86
|
+
value: "Go",
|
|
87
|
+
background: "rgb(230, 57, 70)",
|
|
88
|
+
});
|
|
89
|
+
expect(readTimelineText(layer(`<div>Go</div>`))?.background).toBeUndefined();
|
|
90
|
+
expect(
|
|
91
|
+
readTimelineText(layer(`<div style="background-color: rgba(255, 255, 255, 0.01)">Go</div>`))
|
|
92
|
+
?.background,
|
|
93
|
+
).toBeUndefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("tells a text change apart from an identical re-read", () => {
|
|
97
|
+
const text = { value: "Old", color: "rgb(0, 0, 0)" };
|
|
98
|
+
expect(sameTimelineText(text, { ...text })).toBe(true);
|
|
99
|
+
expect(sameTimelineText(text, { ...text, value: "New" })).toBe(false);
|
|
100
|
+
expect(sameTimelineText(text, undefined)).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { TimelineElement } from "../store/playerStore";
|
|
11
|
+
import { readTimelineText } from "./timelineText";
|
|
11
12
|
import type { ClipManifestClip } from "./playbackTypes";
|
|
12
13
|
import { isFinitePositive } from "./playbackAdapter";
|
|
13
14
|
import { getSourceScopedSelectorIndex } from "../../utils/sourceScopedSelectorIndex";
|
|
14
15
|
import { HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
|
|
15
16
|
import { readElementFades } from "@hyperframes/core/audio-fade";
|
|
17
|
+
import { isHtmlElement, isImageElement, isMediaElement } from "@hyperframes/core/runtime/dom-realm";
|
|
16
18
|
import { elementVolume } from "./storedVolume";
|
|
17
19
|
import {
|
|
18
20
|
type AttrReader,
|
|
@@ -143,11 +145,6 @@ export function furthestClipEndFromSource(source: string): number {
|
|
|
143
145
|
// DOM element type guards
|
|
144
146
|
// ---------------------------------------------------------------------------
|
|
145
147
|
|
|
146
|
-
function isHtmlElement(el: Element): el is HTMLElement {
|
|
147
|
-
const HtmlElementCtor = el.ownerDocument.defaultView?.HTMLElement ?? globalThis.HTMLElement;
|
|
148
|
-
return typeof HtmlElementCtor !== "undefined" && el instanceof HtmlElementCtor;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
148
|
function isCompositionHost(el: Element): boolean {
|
|
152
149
|
return (
|
|
153
150
|
el.hasAttribute("data-composition-id") ||
|
|
@@ -157,16 +154,11 @@ function isCompositionHost(el: Element): boolean {
|
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
export function resolveMediaElement(el: Element): HTMLMediaElement | HTMLImageElement | null {
|
|
160
|
-
|
|
161
|
-
const MediaElementCtor = win.HTMLMediaElement ?? globalThis.HTMLMediaElement;
|
|
162
|
-
const ImageElementCtor = win.HTMLImageElement ?? globalThis.HTMLImageElement;
|
|
163
|
-
if (el instanceof MediaElementCtor || el instanceof ImageElementCtor) return el;
|
|
157
|
+
if (isMediaElement(el) || isImageElement(el)) return el;
|
|
164
158
|
// A composition's media belongs to its own timeline, not the clip's: its length would cap a trim.
|
|
165
159
|
if (isCompositionHost(el)) return null;
|
|
166
160
|
const candidate = el.querySelector("video, audio, img");
|
|
167
|
-
return candidate
|
|
168
|
-
? candidate
|
|
169
|
-
: null;
|
|
161
|
+
return isMediaElement(candidate) || isImageElement(candidate) ? candidate : null;
|
|
170
162
|
}
|
|
171
163
|
|
|
172
164
|
/** The in-point as playback reads it, and the attribute holding it; empty when neither is authored. */
|
|
@@ -255,6 +247,7 @@ function applyFadeMetadataFromElement(entry: TimelineElement, el: Element): void
|
|
|
255
247
|
}
|
|
256
248
|
|
|
257
249
|
export function applyMediaMetadataFromElement(entry: TimelineElement, el: Element): void {
|
|
250
|
+
setOptional(entry, "text", readTimelineText(el));
|
|
258
251
|
applyPlaybackMetadataFromElement(entry, el);
|
|
259
252
|
applyAudioMetadataFromElement(entry, el);
|
|
260
253
|
applyFadeMetadataFromElement(entry, el);
|
|
@@ -266,9 +259,7 @@ export function applyMediaMetadataFromElement(entry: TimelineElement, el: Elemen
|
|
|
266
259
|
const src = mediaEl.getAttribute("src");
|
|
267
260
|
if (src) entry.src = src;
|
|
268
261
|
|
|
269
|
-
|
|
270
|
-
const MediaElementCtor = win.HTMLMediaElement ?? globalThis.HTMLMediaElement;
|
|
271
|
-
if (typeof MediaElementCtor === "undefined" || !(mediaEl instanceof MediaElementCtor)) return;
|
|
262
|
+
if (!isMediaElement(mediaEl)) return;
|
|
272
263
|
|
|
273
264
|
const sourceDurationAttr =
|
|
274
265
|
el.getAttribute("data-source-duration") ?? mediaEl.getAttribute("data-source-duration");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isHtmlElement } from "@hyperframes/core/runtime/dom-realm";
|
|
2
|
+
import { parseCssColor } from "../../components/editor/colorValue";
|
|
3
|
+
import type { TimelineText } from "../store/timelineElement";
|
|
4
|
+
import {
|
|
5
|
+
getCuratedComputedStyles,
|
|
6
|
+
isEditableTextLeaf,
|
|
7
|
+
isTextBearingTag,
|
|
8
|
+
} from "../../components/editor/domEditingDom";
|
|
9
|
+
|
|
10
|
+
/** A layer that paints only text and a flat colour (a text tag whose children are all text leaves,
|
|
11
|
+
* no background image): its words and look. Anything painted beyond that keeps its picture. */
|
|
12
|
+
export function readTimelineText(el: Element): TimelineText | undefined {
|
|
13
|
+
if (!isHtmlElement(el) || !isTextBearingTag(el.localName)) return undefined;
|
|
14
|
+
const children = Array.from(el.children);
|
|
15
|
+
if (!children.every((child) => isHtmlElement(child) && isEditableTextLeaf(child)))
|
|
16
|
+
return undefined;
|
|
17
|
+
const value = el.textContent?.replace(/\s+/g, " ").trim();
|
|
18
|
+
if (!value) return undefined;
|
|
19
|
+
const style = getCuratedComputedStyles(el);
|
|
20
|
+
if ((style["background-image"] ?? "none") !== "none") return undefined;
|
|
21
|
+
const background = style["background-color"];
|
|
22
|
+
return {
|
|
23
|
+
value,
|
|
24
|
+
fontFamily: style["font-family"],
|
|
25
|
+
fontWeight: style["font-weight"],
|
|
26
|
+
color: style.color,
|
|
27
|
+
background: background && parseCssColor(background)?.alpha === 1 ? background : undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function sameTimelineText(a?: TimelineText, b?: TimelineText): boolean {
|
|
32
|
+
if (!a || !b) return a === b;
|
|
33
|
+
return (
|
|
34
|
+
a.value === b.value &&
|
|
35
|
+
a.fontFamily === b.fontFamily &&
|
|
36
|
+
a.fontWeight === b.fontWeight &&
|
|
37
|
+
a.color === b.color &&
|
|
38
|
+
a.background === b.background
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -95,6 +95,17 @@ export interface TimelineElement {
|
|
|
95
95
|
authoredStartIsMasterTime?: boolean;
|
|
96
96
|
/** Legacy marker for an inline sub-composition child; current rows never set it. */
|
|
97
97
|
expandedHostKey?: string;
|
|
98
|
+
/** A text layer's words and look, which its row draws live instead of a captured picture. */
|
|
99
|
+
text?: TimelineText;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface TimelineText {
|
|
103
|
+
value: string;
|
|
104
|
+
fontFamily?: string;
|
|
105
|
+
fontWeight?: string;
|
|
106
|
+
color?: string;
|
|
107
|
+
/** The layer's own opaque background colour, when it paints one. */
|
|
108
|
+
background?: string;
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
type RowClock = Pick<
|
|
@@ -156,6 +167,7 @@ export type TimelineElementPatch = Partial<
|
|
|
156
167
|
| "audioGroupHidden"
|
|
157
168
|
| "audioGroupFxChain"
|
|
158
169
|
| "audioGroupAutomation"
|
|
170
|
+
| "text"
|
|
159
171
|
>
|
|
160
172
|
>;
|
|
161
173
|
|
package/src/styles/theme.css
CHANGED
|
@@ -146,6 +146,9 @@
|
|
|
146
146
|
transparent 100%
|
|
147
147
|
);
|
|
148
148
|
--timeline-thumbnail-label-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
|
|
149
|
+
/* A text clip's strip behind its live words: dark for light text, light for dark text. */
|
|
150
|
+
--timeline-text-clip-dark-bg: #1c2028;
|
|
151
|
+
--timeline-text-clip-light-bg: #e9e6df;
|
|
149
152
|
--timeline-waveform-bar-rgb: 245, 237, 255;
|
|
150
153
|
--timeline-waveform-muted-rgb: 236, 238, 242;
|
|
151
154
|
--timeline-waveform-baseline-rgb: 226, 216, 238;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { CommitMutationOptions, MutationResult } from "../hooks/gsapScriptCommitTypes";
|
|
2
|
+
import { trackStudioEvent } from "./studioTelemetry";
|
|
3
|
+
|
|
4
|
+
export type KeyframeUsageAction = "add" | "convert" | "remove_all" | "reset";
|
|
5
|
+
|
|
6
|
+
export function keyframeUsageActions(
|
|
7
|
+
mutations: ReadonlyArray<Record<string, unknown>>,
|
|
8
|
+
semanticActions?: ReadonlyArray<KeyframeUsageAction | undefined>,
|
|
9
|
+
): Set<KeyframeUsageAction> {
|
|
10
|
+
const actions = new Set<KeyframeUsageAction>();
|
|
11
|
+
for (const [index, mutation] of mutations.entries()) {
|
|
12
|
+
const semanticAction = semanticActions?.[index];
|
|
13
|
+
if (semanticAction) {
|
|
14
|
+
actions.add(semanticAction);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
switch (mutation.type) {
|
|
18
|
+
case "add-keyframe":
|
|
19
|
+
case "add-with-keyframes":
|
|
20
|
+
actions.add("add");
|
|
21
|
+
break;
|
|
22
|
+
case "convert-to-keyframes":
|
|
23
|
+
actions.add("convert");
|
|
24
|
+
break;
|
|
25
|
+
case "remove-all-keyframes":
|
|
26
|
+
actions.add("remove_all");
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return actions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function trackKeyframeUsage(action: KeyframeUsageAction, property?: string): void {
|
|
34
|
+
trackStudioEvent("keyframe", property === undefined ? { action } : { action, property });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function primaryKeyframeAction(
|
|
38
|
+
actions: ReadonlySet<KeyframeUsageAction>,
|
|
39
|
+
): KeyframeUsageAction | undefined {
|
|
40
|
+
return (["add", "convert", "remove_all", "reset"] as const).find((action) => actions.has(action));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function changedMutationIndices(
|
|
44
|
+
result: MutationResult,
|
|
45
|
+
count: number,
|
|
46
|
+
options?: ReadonlyArray<Pick<CommitMutationOptions, "keyframeTelemetry">>,
|
|
47
|
+
): number[] {
|
|
48
|
+
if (!result.ok || result.changed !== true) return [];
|
|
49
|
+
const changes = count === 1 ? [true] : result.mutationChanges;
|
|
50
|
+
if (
|
|
51
|
+
!Array.isArray(changes) ||
|
|
52
|
+
changes.length !== count ||
|
|
53
|
+
changes.some((value) => typeof value !== "boolean")
|
|
54
|
+
)
|
|
55
|
+
return [];
|
|
56
|
+
return changes.flatMap((changed, index) =>
|
|
57
|
+
changed && options?.[index]?.keyframeTelemetry !== false ? [index] : [],
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function trackKeyframeCommit(
|
|
62
|
+
mutations: ReadonlyArray<Record<string, unknown>>,
|
|
63
|
+
result: MutationResult,
|
|
64
|
+
options: CommitMutationOptions,
|
|
65
|
+
memberOptions?: ReadonlyArray<CommitMutationOptions>,
|
|
66
|
+
): void {
|
|
67
|
+
if (!result.ok || result.changed !== true || options.keyframeTelemetry === false) return;
|
|
68
|
+
const indices = changedMutationIndices(result, mutations.length, memberOptions);
|
|
69
|
+
const actions = keyframeUsageActions(
|
|
70
|
+
indices.map((index) => mutations[index]!),
|
|
71
|
+
indices.map(
|
|
72
|
+
(index) =>
|
|
73
|
+
memberOptions?.[index]?.keyframeAction ??
|
|
74
|
+
(mutations.length === 1 ? options.keyframeAction : undefined),
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
const action = primaryKeyframeAction(actions);
|
|
78
|
+
if (action) trackKeyframeUsage(action, action === "add" ? options.keyframeProperty : undefined);
|
|
79
|
+
}
|