Skip to content

🎥 Make videos programmatically with React

Unify retained timeline calculation and remove obsolete paths

JonnyBurger2b4614420393
diff --git a/packages/sdk/src/calculate-timeline.ts b/packages/sdk/src/calculate-timeline.ts
index f9860c5761..f96cab3b0b 100644
--- a/packages/sdk/src/calculate-timeline.ts
+++ b/packages/sdk/src/calculate-timeline.ts
@@ -32,14 +32,22 @@ type TimelineCalculation = {
structure: {trackIndexById: ReadonlyMap<string, number>};
};
+type TimelineCalculationSnapshot = {
+ input: TimelineCalculationInput;
+ result: TimelineCalculation;
+};
+
const EMPTY_COMPOSITIONS: readonly _InternalTypes['AnyComposition'][] = [];
-const calculateTimelineState = ({
- sequences,
- overrideIdsToNodePaths,
- compositions = EMPTY_COMPOSITIONS,
- showConnectedCompositionChildren = false,
-}: TimelineCalculationInput): {
+const calculateTimelineState = (
+ {
+ sequences,
+ overrideIdsToNodePaths,
+ compositions = EMPTY_COMPOSITIONS,
+ showConnectedCompositionChildren = false,
+ }: TimelineCalculationInput,
+ previous: TimelineCalculationSnapshot | null,
+): {
result: TimelineCalculation;
update: (input: TimelineCalculationInput) => TimelineCalculation | null;
} => {
@@ -138,28 +146,25 @@ const calculateTimelineState = ({
}
const parentTiming = parent ? getTiming(parent) : null;
- // Timing and nesting helpers historically treat an empty parent ID as a
- // root, while playback rate and inherited loop lookup still resolve it.
- const timingParent = sequence.parent ? parentTiming! : null;
const parentPlaybackRate = parent
? parent.sequencePlaybackRate * parentTiming!.parentPlaybackRate
: 1;
const sequencePlaybackRate =
parentPlaybackRate * sequence.sequencePlaybackRate;
- const cascadedStart = timingParent
- ? timingParent.cascadedStart +
+ const cascadedStart = parentTiming
+ ? parentTiming.cascadedStart +
(sequence.from - (parent!.trimBefore ?? 0)) / parentPlaybackRate
: sequence.from;
- const visibleStart = timingParent
- ? Math.max(timingParent.visibleStart, Math.max(0, cascadedStart))
+ const visibleStart = parentTiming
+ ? Math.max(parentTiming.visibleStart, Math.max(0, cascadedStart))
: Math.max(0, cascadedStart);
const end = cascadedStart + sequence.duration / parentPlaybackRate;
const visibleDuration = Math.max(
0,
- (timingParent
+ (parentTiming
? Math.min(
end,
- timingParent.visibleStart + timingParent.visibleDuration,
+ parentTiming.visibleStart + parentTiming.visibleDuration,
)
: end) - visibleStart,
);
@@ -188,8 +193,8 @@ const calculateTimelineState = ({
cascadedStart,
visibleStart,
visibleDuration,
- depth: timingParent
- ? timingParent.depth + (parent!.showInTimeline ? 1 : 0)
+ depth: parentTiming
+ ? parentTiming.depth + (parent!.showInTimeline ? 1 : 0)
: 0,
loopOwner,
mediaIterationStart,
@@ -266,7 +271,7 @@ const calculateTimelineState = ({
owner.loopDisplay.startOffset / ownerTiming.parentPlaybackRate;
let start = Math.max(0, origin);
let end = origin + durationInFrames * owner.loopDisplay.numberOfTimes;
- if (owner.parent) {
+ if (owner.parent !== null) {
const loopParentTiming = getTiming(sequencesById.get(owner.parent)!);
start = Math.max(start, loopParentTiming.visibleStart);
end = Math.min(
@@ -354,9 +359,10 @@ const calculateTimelineState = ({
const rank = sequenceRanks.get(track.sequence.id) ?? 0;
const id = String(rank).padStart(6, '0');
- const parent = track.sequence.parent
- ? tracksById.get(track.sequence.parent)
- : null;
+ const parent =
+ track.sequence.parent !== null
+ ? tracksById.get(track.sequence.parent)
+ : null;
const key = parent ? `${getSortKey(parent)}-${id}` : id;
sortKeysById.set(track.sequence.id, key);
return key;
@@ -413,6 +419,69 @@ const calculateTimelineState = ({
};
});
+ if (
+ previous !== null &&
+ previous.input.overrideIdsToNodePaths === overrideIdsToNodePaths &&
+ (previous.input.compositions ?? EMPTY_COMPOSITIONS) === compositions
+ ) {
+ const previousSequencesById = new Map(
+ previous.input.sequences.map((sequence) => [sequence.id, sequence]),
+ );
+ // Rebuilding the hierarchy does not invalidate unchanged track snapshots.
+ // Keep this ownership here so every consumer receives the same identities.
+ currentTracks = currentTracks.map((track) => {
+ const previousIndex = previous.result.structure.trackIndexById.get(
+ track.sequence.id,
+ );
+ if (previousIndex === undefined) {
+ return track;
+ }
+
+ const oldTrack = previous.result.tracks[previousIndex];
+ // Matching source and mapping references also preserve controls, path
+ // details and video config; only the path's index and count can change.
+ const oldNodePath = oldTrack.nodePathInfo;
+ const nodePath = track.nodePathInfo;
+ const oldLoop = oldTrack.sequence.loopDisplay;
+ const loop = track.sequence.loopDisplay;
+ if (
+ sequencesById.get(track.sequence.id) !==
+ previousSequencesById.get(track.sequence.id) ||
+ oldTrack.depth !== track.depth ||
+ oldTrack.cascadedStart !== track.cascadedStart ||
+ oldTrack.localStart !== track.localStart ||
+ oldTrack.parentVisibleStart !== track.parentVisibleStart ||
+ oldTrack.parentVisibleEnd !== track.parentVisibleEnd ||
+ oldTrack.keyframeDisplayOffset !== track.keyframeDisplayOffset ||
+ oldTrack.keyframePlaybackRate !== track.keyframePlaybackRate ||
+ oldTrack.sequenceFrameOffset !== track.sequenceFrameOffset ||
+ oldTrack.sequence.from !== track.sequence.from ||
+ oldTrack.sequence.duration !== track.sequence.duration ||
+ oldTrack.sequence.sequencePlaybackRate !==
+ track.sequence.sequencePlaybackRate ||
+ oldTrack.sequence.premountDisplay !== track.sequence.premountDisplay ||
+ oldTrack.sequence.postmountDisplay !==
+ track.sequence.postmountDisplay ||
+ (oldNodePath === null) !== (nodePath === null) ||
+ oldNodePath?.index !== nodePath?.index ||
+ oldNodePath?.numberOfSequencesWithThisNodePath !==
+ nodePath?.numberOfSequencesWithThisNodePath ||
+ (oldLoop === undefined) !== (loop === undefined) ||
+ (oldLoop !== undefined &&
+ loop !== undefined &&
+ (oldLoop.durationInFrames !== loop.durationInFrames ||
+ oldLoop.numberOfTimes !== loop.numberOfTimes ||
+ oldLoop.startOffset !== loop.startOffset ||
+ oldLoop.phaseOffsetInFrames !== loop.phaseOffsetInFrames ||
+ oldLoop.mediaOffsetInFrames !== loop.mediaOffsetInFrames))
+ ) {
+ return track;
+ }
+
+ return oldTrack;
+ });
+ }
+
const trackIndexById = new Map(
currentTracks.map((track, index) => [track.sequence.id, index]),
);
@@ -430,10 +499,6 @@ const calculateTimelineState = ({
return null;
}
- if (input.sequences === currentSequences) {
- return {tracks: currentTracks, structure};
- }
-
if (
input.sequences.length !== currentSequences.length ||
sequencesById.size !== currentSequences.length
@@ -444,15 +509,15 @@ const calculateTimelineState = ({
const changed: TSequence[] = [];
for (let i = 0; i < input.sequences.length; i++) {
const sequence = input.sequences[i];
- const previous = currentSequences[i];
- if (sequence === previous) {
+ const previousSequence = currentSequences[i];
+ if (sequence === previousSequence) {
continue;
}
// Retain ordering and node-path indexes only for ordinary media leaves.
// Changes to registrations, controls or hierarchy need a full rebuild.
if (
- sequence.id !== previous.id ||
+ sequence.id !== previousSequence.id ||
(sequence.type !== 'audio' && sequence.type !== 'video') ||
sequence.frozenMediaFrame !== null ||
sequence.autoDuration ||
@@ -465,12 +530,12 @@ const calculateTimelineState = ({
}
const keys = Object.keys(sequence);
- if (keys.length !== Object.keys(previous).length) {
+ if (keys.length !== Object.keys(previousSequence).length) {
return null;
}
for (const key of keys) {
- if (!Object.hasOwn(previous, key)) {
+ if (!Object.hasOwn(previousSequence, key)) {
return null;
}
@@ -485,7 +550,8 @@ const calculateTimelineState = ({
}
if (
- sequence[key as keyof TSequence] !== previous[key as keyof TSequence]
+ sequence[key as keyof TSequence] !==
+ previousSequence[key as keyof TSequence]
) {
return null;
}
@@ -545,23 +611,32 @@ const calculateTimelineState = ({
};
};
-export const calculateTimeline = (
- input: TimelineCalculationInput,
-): TimelineTrackData[] => {
- return calculateTimelineState(input).result.tracks;
-};
-
-// One instance belongs to one timeline consumer. Compatible commits reuse the
+// One instance belongs to one timeline. Compatible commits reuse the
// hierarchy, timing cache, sort order and node-path indexes from its last rebuild.
export const createTimelineCalculator = () => {
let state: ReturnType<typeof calculateTimelineState> | null = null;
+ let previous: TimelineCalculationSnapshot | null = null;
return (input: TimelineCalculationInput): TimelineCalculation => {
+ if (
+ previous !== null &&
+ input.sequences === previous.input.sequences &&
+ input.overrideIdsToNodePaths === previous.input.overrideIdsToNodePaths &&
+ (input.compositions ?? EMPTY_COMPOSITIONS) ===
+ (previous.input.compositions ?? EMPTY_COMPOSITIONS) &&
+ (input.showConnectedCompositionChildren ?? false) ===
+ (previous.input.showConnectedCompositionChildren ?? false)
+ ) {
+ return previous.result;
+ }
+
const updated = state?.update(input) ?? null;
if (updated !== null) {
+ previous = {input, result: updated};
return updated;
}
- state = calculateTimelineState(input);
+ state = calculateTimelineState(input, previous);
+ previous = {input, result: state.result};
return state.result;
};
};
diff --git a/packages/sdk/src/canvas-controller.ts b/packages/sdk/src/canvas-controller.ts
index 7b73d2c625..0797d0117d 100644
--- a/packages/sdk/src/canvas-controller.ts
+++ b/packages/sdk/src/canvas-controller.ts
@@ -7,7 +7,7 @@ import type {
TSequence,
} from 'remotion';
import {Internals} from 'remotion';
-import {calculateTimeline} from './calculate-timeline';
+import {createTimelineCalculator} from './calculate-timeline';
import type {
SequenceNodePathInfo,
TimelineTrackData,
@@ -108,6 +108,7 @@ const nodePathsAreEqual = (
};
export const createCanvasController = (): CanvasController => {
+ const calculateTimeline = createTimelineCalculator();
let timelineSnapshot: readonly TimelineTrackData[] = [];
let sequences: TSequence[] = [];
let nodePaths: OverrideIdToNodePaths = {};
@@ -132,7 +133,7 @@ export const createCanvasController = (): CanvasController => {
calculateTimeline({
sequences,
overrideIdsToNodePaths: nodePaths,
- }),
+ }).tracks,
);
};
diff --git a/packages/sdk/src/canvas-internals.ts b/packages/sdk/src/canvas-internals.ts
index b97421b46a..6f027858ca 100644
--- a/packages/sdk/src/canvas-internals.ts
+++ b/packages/sdk/src/canvas-internals.ts
@@ -3,10 +3,7 @@ export {
collectReactCommit,
installReactCommitObserver,
} from './react-commit-adapter';
-export {
- calculateTimeline,
- createTimelineCalculator,
-} from './calculate-timeline';
+export {createTimelineCalculator} from './calculate-timeline';
export {useIsCanvasSequenceHovered} from './hover';
export type {
CanvasOutline,
@@ -57,19 +54,8 @@ export type {
CanvasOutlineLayoutTarget,
} from './outline-targets';
export {getConnectedCompositions} from './get-connected-compositions';
-export {
- getParentSequencePlaybackRate,
- getCascadedStart,
- getCascadedStartWithTrim,
- getTimelineVisibleDuration,
- getTimelineVisibleStart,
-} from './get-sequence-visible-range';
-export {getTimelineNestedLevel} from './get-timeline-nestedness';
-export {getTimelineSequenceSortKey} from './get-timeline-sequence-sort-key';
-export type {
- TimelineLoopDisplay,
- TimelineTrackWithOriginalTimings,
-} from './get-timeline-sequence-sort-key';
+export {getParentSequencePlaybackRate} from './get-sequence-visible-range';
+export type {TimelineLoopDisplay} from './get-timeline-sequence-sort-key';
export {
EMPTY_CANVAS_SELECTION,
getCanvasSelectionAfterInteraction,
diff --git a/packages/sdk/src/get-sequence-visible-range.ts b/packages/sdk/src/get-sequence-visible-range.ts
index 63667cb0c7..e88a5d01c8 100644
--- a/packages/sdk/src/get-sequence-visible-range.ts
+++ b/packages/sdk/src/get-sequence-visible-range.ts
@@ -20,80 +20,3 @@ export const getParentSequencePlaybackRate = (
getParentSequencePlaybackRate(parent, sequences)
);
};
-
-export const getCascadedStart = (
- sequence: TSequence,
- sequences: TSequence[],
-): number => {
- if (!sequence.parent) {
- return sequence.from;
- }
-
- const parent = sequences.find((s) => s.id === sequence.parent);
- if (!parent) {
- throw new TypeError('Parent not found for sequence ' + sequence.id);
- }
-
- return (
- getCascadedStart(parent, sequences) +
- (sequence.from - (parent.trimBefore ?? 0)) /
- getParentSequencePlaybackRate(sequence, sequences)
- );
-};
-
-export const getCascadedStartWithTrim = (
- sequence: TSequence,
- sequences: TSequence[],
-): number => {
- return (
- getCascadedStart(sequence, sequences) -
- (sequence.trimBefore ?? 0) /
- (getParentSequencePlaybackRate(sequence, sequences) *
- sequence.sequencePlaybackRate)
- );
-};
-
-export const getTimelineVisibleStart = (
- sequence: TSequence,
- sequences: TSequence[],
-): number => {
- const cascadedStart = Math.max(0, getCascadedStart(sequence, sequences));
- if (!sequence.parent) {
- return cascadedStart;
- }
-
- const parent = sequences.find((s) => s.id === sequence.parent);
- if (!parent) {
- throw new TypeError('Parent not found for sequence ' + sequence.id);
- }
-
- const timelineVisibleStart = getTimelineVisibleStart(parent, sequences);
- return Math.max(timelineVisibleStart, cascadedStart);
-};
-
-export const getTimelineVisibleDuration = (
- sequence: TSequence,
- sequences: TSequence[],
-): number => {
- const start = getTimelineVisibleStart(sequence, sequences);
- const end =
- getCascadedStart(sequence, sequences) +
- sequence.duration / getParentSequencePlaybackRate(sequence, sequences);
- if (!sequence.parent) {
- return Math.max(0, end - start);
- }
-
- const parent = sequences.find((s) => s.id === sequence.parent);
- if (!parent) {
- throw new TypeError('Parent not found for sequence ' + sequence.id);
- }
-
- return Math.max(
- 0,
- Math.min(
- end,
- getTimelineVisibleStart(parent, sequences) +
- getTimelineVisibleDuration(parent, sequences),
- ) - start,
- );
-};
diff --git a/packages/sdk/src/get-timeline-nestedness.ts b/packages/sdk/src/get-timeline-nestedness.ts
deleted file mode 100644
index f0bebc9ce0..0000000000
--- a/packages/sdk/src/get-timeline-nestedness.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type {TSequence} from 'remotion';
-
-export const getTimelineNestedLevel = (
- sequence: TSequence,
- allSequences: TSequence[],
- depth: number,
-): number => {
- if (!sequence.parent) {
- return depth;
- }
-
- const parentSequence = allSequences.find((s) => s.id === sequence.parent);
- if (!parentSequence) {
- throw new Error('has parentId but no parent');
- }
-
- const parentContributes = parentSequence.showInTimeline;
- return getTimelineNestedLevel(
- parentSequence,
- allSequences,
- parentContributes ? depth + 1 : depth,
- );
-};
diff --git a/packages/sdk/src/get-timeline-sequence-sort-key.ts b/packages/sdk/src/get-timeline-sequence-sort-key.ts
index 6a359d4af4..150bb9bfb2 100644
--- a/packages/sdk/src/get-timeline-sequence-sort-key.ts
+++ b/packages/sdk/src/get-timeline-sequence-sort-key.ts
@@ -35,28 +35,3 @@ export type TimelineLoopDisplay = LoopDisplay & {
// Elapsed time from the currently registered iteration to the media's visible start.
mediaOffsetInFrames: number;
};
-
-export type TimelineTrackWithOriginalTimings = TimelineTrackData & {
- cascadedDuration: number;
-};
-
-export const getTimelineSequenceSortKey = (
- track: TimelineTrackData,
- tracks: TimelineTrackData[],
- sequenceRanks: Map<string, number>,
-): string => {
- const rank = sequenceRanks.get(track.sequence.id) ?? 0;
- const id = String(rank).padStart(6, '0');
- if (!track.sequence.parent) {
- return id;
- }
-
- const parent = tracks.find((t) => t.sequence.id === track.sequence.parent);
- if (!parent) {
- // Due to effects and conditional `showInTimeline`, a parent
- // may not exist in the `allTracks` array.
- return id;
- }
-
- return `${getTimelineSequenceSortKey(parent, tracks, sequenceRanks)}-${id}`;
-};
diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts
index 8b85dc2d98..2897ffe026 100644
--- a/packages/sdk/src/index.ts
+++ b/packages/sdk/src/index.ts
@@ -100,7 +100,6 @@ export type {
CanvasSelectableOutline,
CanvasOutlineLayoutTarget,
TimelineLoopDisplay,
- TimelineTrackWithOriginalTimings,
PointerSessionEndReason,
ParsedTranslate,
ParsedTranslateWithUnits,
diff --git a/packages/sdk/src/test/calculate-timeline.test.ts b/packages/sdk/src/test/calculate-timeline.test.ts
index 3e28a61d7a..3be5f54f35 100644
--- a/packages/sdk/src/test/calculate-timeline.test.ts
+++ b/packages/sdk/src/test/calculate-timeline.test.ts
@@ -1,6 +1,6 @@
import {expect, test} from 'bun:test';
import type {TSequence} from 'remotion';
-import {calculateTimeline} from '../calculate-timeline';
+import {createTimelineCalculator} from '../calculate-timeline';
const makeSequence = ({
id,
@@ -35,13 +35,15 @@ const makeSequence = ({
});
test('returns an empty timeline when there are no sequences', () => {
+ const calculateTimeline = createTimelineCalculator();
expect(
- calculateTimeline({overrideIdsToNodePaths: {}, sequences: []}),
+ calculateTimeline({overrideIdsToNodePaths: {}, sequences: []}).tracks,
).toEqual([]);
});
test('normalizes nesting and visible starts', () => {
- const timeline = calculateTimeline({
+ const calculateTimeline = createTimelineCalculator();
+ const {tracks: timeline} = calculateTimeline({
overrideIdsToNodePaths: {},
sequences: [
makeSequence({id: 'child', parent: 'parent', from: -10}),
@@ -87,6 +89,7 @@ test('normalizes nesting and visible starts', () => {
});
test('committed Fiber order takes precedence over internal order', () => {
+ const calculateTimeline = createTimelineCalculator();
const right = makeSequence({
id: 'right',
parent: null,
@@ -100,7 +103,7 @@ test('committed Fiber order takes precedence over internal order', () => {
right.timelineOrder = 1;
left.timelineOrder = 0;
- const timeline = calculateTimeline({
+ const {tracks: timeline} = calculateTimeline({
overrideIdsToNodePaths: {},
sequences: [right, left],
});
@@ -109,6 +112,7 @@ test('committed Fiber order takes precedence over internal order', () => {
});
test('retimed nested tracks use composition geometry and local media clocks', () => {
+ const calculateTimeline = createTimelineCalculator();
const outer: TSequence = {
...makeSequence({id: 'outer', parent: null, from: 10}),
sequencePlaybackRate: 1.5,
@@ -132,7 +136,7 @@ test('retimed nested tracks use composition geometry and local media clocks', ()
muted: false,
loopDisplay: {durationInFrames: 30, startOffset: 0, numberOfTimes: 6},
};
- const tracks = calculateTimeline({
+ const {tracks} = calculateTimeline({
sequences: [outer, inner, video],
overrideIdsToNodePaths: {},
});
diff --git a/packages/studio/src/components/GlobalKeybindings.tsx b/packages/studio/src/components/GlobalKeybindings.tsx
index 55814fd48e..9c4252a111 100644
--- a/packages/studio/src/components/GlobalKeybindings.tsx
+++ b/packages/studio/src/components/GlobalKeybindings.tsx
@@ -3,7 +3,7 @@ import type React from 'react';
import {useCallback, useContext, useEffect} from 'react';
import {Internals} from 'remotion';
import {getBrowserStudioOperations} from '../helpers/browser-studio-operations';
-import {calculateTimeline} from '../helpers/calculate-timeline';
+import {useTimelineCalculator} from '../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {getPreviewFileType} from '../helpers/get-preview-file-type';
import {pickColor} from '../helpers/pick-color';
@@ -42,6 +42,7 @@ const hasOwnProperty = (obj: object, key: string) =>
Object.prototype.hasOwnProperty.call(obj, key);
export const GlobalKeybindings: React.FC = () => {
+ const calculateTimeline = useTimelineCalculator();
const keybindings = useKeybinding();
const {setSelectedModal} = useContext(SetSelectedModalContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
@@ -140,7 +141,7 @@ export const GlobalKeybindings: React.FC = () => {
const selectedTrackKey = getTimelineSequenceSelectionKey(
selection.nodePathInfo,
);
- const timeline = calculateTimeline({
+ const {tracks: timeline} = calculateTimeline({
sequences: sequencesRef.current,
overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
});
@@ -180,6 +181,7 @@ export const GlobalKeybindings: React.FC = () => {
return true;
},
[
+ calculateTimeline,
currentSelection,
overrideIdToNodePathMappingsRef,
sequencesRef,
diff --git a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
index 300fd4846b..36416f08e4 100644
--- a/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/EasingInspector.tsx
@@ -60,10 +60,6 @@ export const EasingInspector: React.FC<{
const runtimeValues = useRuntimeValues(track?.sequence.controls ?? null);
const videoConfig = useVideoConfig();
const timelinePosition = Internals.Timeline.useTimelinePosition();
- const sequences = Internals.useSequenceManagerSequences();
- const {overrideIdToNodePathMappings} = useContext(
- Internals.OverrideIdsToNodePathsGettersContext,
- );
const {propStatuses} = useContext(Internals.VisualModePropStatusesContext);
const {getDragOverrides, getEffectDragOverrides} = useContext(
Internals.VisualModeDragOverridesContext,
@@ -80,11 +76,10 @@ export const EasingInspector: React.FC<{
() =>
getSelectedEasingUpdate({
selection,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks: track ? [track] : [],
propStatuses,
}),
- [overrideIdToNodePathMappings, propStatuses, selection, sequences],
+ [propStatuses, selection, track],
);
const initialEasing = easingUpdate?.currentEasing ?? null;
const easingDetails = useMemo<EasingInspectorDetails | null>(() => {
diff --git a/packages/studio/src/components/InspectorPanel/MultiSequenceInspector.tsx b/packages/studio/src/components/InspectorPanel/MultiSequenceInspector.tsx
index 4a5749e3d0..32fc18c4dc 100644
--- a/packages/studio/src/components/InspectorPanel/MultiSequenceInspector.tsx
+++ b/packages/studio/src/components/InspectorPanel/MultiSequenceInspector.tsx
@@ -19,6 +19,7 @@ import {InspectorInfoHeader} from '../InspectorInfoHeader';
import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';
import {COMPACT_CONTROL_ROW_HEIGHT} from '../layout';
import {VERTICAL_SCROLLBAR_CLASSNAME} from '../Menu/is-menu-item';
+import {findTrackForNodePathInfo} from '../Timeline/find-track-for-node-path-info';
import {getCurrentFrame} from '../Timeline/imperative-state';
import {splitSelectedTimelineItems} from '../Timeline/split-selected-timeline-item';
import {
@@ -81,14 +82,10 @@ export const MultiSequenceInspector: React.FC<{
const key = stringifySequenceExpandedRowKey(
selection.nodePathInfo.sequenceSubscriptionKey,
);
- const track = tracks.find(
- (candidate) =>
- candidate.nodePathInfo !== null &&
- stringifySequenceExpandedRowKey(
- candidate.nodePathInfo.sequenceSubscriptionKey,
- ) === key &&
- candidate.nodePathInfo.index === selection.nodePathInfo.index,
- );
+ const track = findTrackForNodePathInfo({
+ tracks,
+ nodePathInfo: selection.nodePathInfo,
+ });
if (!track?.sequence.controls || !track.nodePathInfo) {
return null;
}
@@ -113,17 +110,7 @@ export const MultiSequenceInspector: React.FC<{
overrideIdsToNodePaths: overrideIdToNodePathMappings,
});
return selections.map(({nodePathInfo}) => {
- const key = stringifySequenceExpandedRowKey(
- nodePathInfo.sequenceSubscriptionKey,
- );
- const track = tracks.find(
- (candidate) =>
- candidate.nodePathInfo !== null &&
- stringifySequenceExpandedRowKey(
- candidate.nodePathInfo.sequenceSubscriptionKey,
- ) === key &&
- candidate.nodePathInfo.index === nodePathInfo.index,
- );
+ const track = findTrackForNodePathInfo({tracks, nodePathInfo});
return {
nodePathInfo,
displayName: track?.sequence.displayName ?? null,
@@ -187,13 +174,16 @@ export const MultiSequenceInspector: React.FC<{
splitSelectedTimelineItems({
selections,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks: calculateTimeline({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ }).tracks,
propStatuses,
splitFrame: getCurrentFrame(),
})?.catch(() => undefined);
}, [
canSplit,
+ calculateTimeline,
overrideIdToNodePathMappings,
propStatuses,
selections,
diff --git a/packages/studio/src/components/InspectorPanel/SequenceWrapAction.tsx b/packages/studio/src/components/InspectorPanel/SequenceWrapAction.tsx
index f8c1701339..027e1183c6 100644
--- a/packages/studio/src/components/InspectorPanel/SequenceWrapAction.tsx
+++ b/packages/studio/src/components/InspectorPanel/SequenceWrapAction.tsx
@@ -1,7 +1,7 @@
import type {NodeWrapper} from '@remotion/studio-shared';
import React, {useCallback, useContext, useState} from 'react';
import {Internals, isHtmlInCanvasSupported} from 'remotion';
-import {calculateTimeline} from '../../helpers/calculate-timeline';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import type {
SequenceNodePathInfo,
TimelineTrackData,
@@ -40,6 +40,7 @@ export const SequenceWrapAction: React.FC<{
readonly line: number;
};
}> = ({nodePathInfo, track, sourceActionsDisabled, sourceLocation}) => {
+ const calculateTimeline = useTimelineCalculator();
const {setSelectedModal} = useContext(SetSelectedModalContext);
const {canvasContent} = useContext(Internals.CompositionManager);
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
@@ -139,7 +140,7 @@ export const SequenceWrapAction: React.FC<{
tracks: calculateTimeline({
sequences,
overrideIdsToNodePaths: overrideIdToNodePathMappings,
- }),
+ }).tracks,
sequenceSubscriptionKey: nodePath,
});
setBusy(true);
@@ -200,6 +201,7 @@ export const SequenceWrapAction: React.FC<{
},
[
busy,
+ calculateTimeline,
isTransition,
canWrapInHtmlInCanvas,
canvasContent,
diff --git a/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts b/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts
index 4009271bb0..8864622919 100644
--- a/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts
+++ b/packages/studio/src/components/InspectorPanel/use-track-for-selection.ts
@@ -1,7 +1,7 @@
import {useContext, useMemo} from 'react';
import {Internals} from 'remotion';
import {useTimelineCalculator} from '../../helpers/calculate-timeline';
-import {findTrackForNodePathInfoInTimeline} from '../Timeline/find-track-for-node-path-info';
+import {findTrackForNodePathInfo} from '../Timeline/find-track-for-node-path-info';
import type {TimelineSelection} from '../Timeline/TimelineSelection';
export const useTrackForSelection = (selection: TimelineSelection | null) => {
@@ -21,7 +21,7 @@ export const useTrackForSelection = (selection: TimelineSelection | null) => {
overrideIdsToNodePaths: overrideIdToNodePathMappings,
});
return (
- findTrackForNodePathInfoInTimeline({
+ findTrackForNodePathInfo({
tracks,
nodePathInfo: selection.nodePathInfo,
}) ?? null
diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsx
index 838bd2b9a5..8fd30beef8 100644
--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx
+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx
@@ -39,7 +39,6 @@ import {
getSelectedSequenceKeys,
getSelectedTransformOriginInfo,
getSequenceKeysContainingSelection,
- type getSequencesWithSelectableOutlines,
} from './selected-outline-measurement';
import {orderOutlinesForRendering} from './selected-outline-order';
import {
@@ -107,7 +106,6 @@ export {
getSelectedOutlineRotationDeltaDegrees,
getSelectedOutlineRotationPivot,
getSelectedSequenceKeys,
- getSequencesWithSelectableOutlines,
getTransformedSvgViewportPoints,
} from './selected-outline-measurement';
@@ -190,7 +188,7 @@ const getCropDragFields = ({
};
type SelectableOutlines = Readonly<
- ReturnType<typeof getSequencesWithSelectableOutlines>
+ ReturnType<typeof getCanvasSelectableOutlines>
>;
type CalculateOutlineTargetsOptions = {
@@ -698,7 +696,7 @@ type ActiveSelectedOutlineOverlayProps = Omit<
) => SelectedOutlineTarget | undefined;
readonly getSelectableOutlines: (
timelinePosition: number,
- ) => ReturnType<typeof getSequencesWithSelectableOutlines>;
+ ) => ReturnType<typeof getCanvasSelectableOutlines>;
readonly hoveredTimelineNodePathKey: string | null;
readonly measureAllOutlines: boolean;
readonly onDraggingChange: (dragging: boolean) => void;
@@ -876,7 +874,7 @@ const SelectedOutlineOverlayUnmemoized: React.FC<
// Resolve source identities once per sequence snapshot, on first demand.
// Playback only filters the cached candidates by their visible range.
let selectableOutlines: ReturnType<
- typeof getSequencesWithSelectableOutlines
+ typeof getCanvasSelectableOutlines
> | null = null;
return (timelinePosition: number | null) => {
if (
@@ -959,9 +957,7 @@ const SelectedOutlineOverlayUnmemoized: React.FC<
const getSelectableOutlinesRef = useRef(getSelectableOutlines);
const selectableOutlinesCacheRef = useRef<{
readonly getSelectableOutlines: typeof getSelectableOutlines;
- readonly selectableOutlines: ReturnType<
- typeof getSequencesWithSelectableOutlines
- >;
+ readonly selectableOutlines: ReturnType<typeof getCanvasSelectableOutlines>;
readonly timelinePosition: number;
} | null>(null);
useLayoutEffect(() => {
diff --git a/packages/studio/src/components/Timeline/EasingEditorModal.tsx b/packages/studio/src/components/Timeline/EasingEditorModal.tsx
index aee319a9cd..472e99ae0f 100644
--- a/packages/studio/src/components/Timeline/EasingEditorModal.tsx
+++ b/packages/studio/src/components/Timeline/EasingEditorModal.tsx
@@ -13,6 +13,7 @@ import React, {
} from 'react';
import type {InteractivitySchemaField} from 'remotion';
import {Easing, Internals} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
BACKGROUND,
@@ -734,6 +735,7 @@ export const EasingEditor: React.FC<{
modeItems: SegmentedControlItem[],
) => React.ReactNode;
}> = ({state, renderHeader}) => {
+ const calculateTimeline = useTimelineCalculator();
const {previewServerState} = useContext(StudioServerConnectionCtx);
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const propStatusesRef = useContext(
@@ -775,11 +777,14 @@ export const EasingEditor: React.FC<{
const getCurrentEasingUpdates = useCallback(() => {
return getSelectedEasingUpdates({
selections: state.selections,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ }).tracks,
propStatuses: propStatusesRef.current,
});
}, [
+ calculateTimeline,
overrideIdToNodePathMappings,
propStatusesRef,
sequencesRef,
@@ -883,8 +888,10 @@ export const EasingEditor: React.FC<{
const promise = updateSelectedTimelineEasings({
selections: state.selections,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ }).tracks,
propStatuses: propStatusesRef.current,
setPropStatuses,
clientId: previewServerState.clientId,
@@ -903,6 +910,7 @@ export const EasingEditor: React.FC<{
});
},
[
+ calculateTimeline,
clearPendingEasingDragOverrides,
getCurrentEasingUpdates,
overrideIdToNodePathMappings,
diff --git a/packages/studio/src/components/Timeline/Timeline.tsx b/packages/studio/src/components/Timeline/Timeline.tsx
index 77b82b858c..18417e6c09 100644
--- a/packages/studio/src/components/Timeline/Timeline.tsx
+++ b/packages/studio/src/components/Timeline/Timeline.tsx
@@ -14,7 +14,6 @@ import {
removeErrorFromOverlay,
} from '../../error-overlay/runtime-error-store';
import {FastRefreshContext} from '../../fast-refresh-context';
-import {areSequenceNodePathInfosEqual} from '../../helpers/are-sequence-node-path-infos-equal';
import {getBrowserStudioOperations} from '../../helpers/browser-studio-operations';
import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
@@ -318,9 +317,6 @@ const TimelineInner: React.FC = () => {
],
);
const previousDisplayRef = useRef<{
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: typeof overrideIdToNodePathMappings;
- readonly compositions: typeof compositions;
readonly structure: typeof calculation.structure;
readonly tracks: typeof calculation.tracks;
readonly timeline: TimelineTrackWithDisplayGroup[];
@@ -330,71 +326,27 @@ const TimelineInner: React.FC = () => {
const previous = previousDisplayRef.current;
if (previous === null || previous.structure !== calculation.structure) {
const next = addTimelineDisplayGroups(calculation.tracks);
- if (
- previous === null ||
- previous.overrideIdsToNodePaths !== overrideIdToNodePathMappings ||
- previous.compositions !== compositions
- ) {
+ if (previous === null) {
return {timeline: next, structureTimeline: next};
}
- // Unsupported edits still derive the full timeline, but unchanged bars
- // keep the snapshots their memoized thumbnails and waveforms consume.
- const previousSequencesById = new Map(
- previous.sequences.map((sequence) => [sequence.id, sequence]),
- );
- const currentSequencesById = new Map(
- sequences.map((sequence) => [sequence.id, sequence]),
- );
- const previousTracksById = new Map(
- previous.timeline.map((track) => [track.sequence.id, track]),
- );
- const tracks = next.map((track) => {
- const oldTrack = previousTracksById.get(track.sequence.id);
- const currentSource = currentSequencesById.get(track.sequence.id);
- const oldNodePath = oldTrack?.nodePathInfo ?? null;
- const nodePath = track.nodePathInfo;
- const oldLoop = oldTrack?.sequence.loopDisplay;
- const loop = track.sequence.loopDisplay;
+ const tracks = next.map((track, index) => {
+ const previousIndex = previous.structure.trackIndexById.get(
+ track.sequence.id,
+ );
if (
- oldTrack === undefined ||
- currentSource !== previousSequencesById.get(track.sequence.id) ||
- oldTrack.depth !== track.depth ||
- oldTrack.cascadedStart !== track.cascadedStart ||
- oldTrack.localStart !== track.localStart ||
- oldTrack.parentVisibleStart !== track.parentVisibleStart ||
- oldTrack.parentVisibleEnd !== track.parentVisibleEnd ||
- oldTrack.keyframeDisplayOffset !== track.keyframeDisplayOffset ||
- oldTrack.keyframePlaybackRate !== track.keyframePlaybackRate ||
- oldTrack.sequenceFrameOffset !== track.sequenceFrameOffset ||
- oldTrack.sequence.from !== track.sequence.from ||
- oldTrack.sequence.duration !== track.sequence.duration ||
- oldTrack.sequence.sequencePlaybackRate !==
- track.sequence.sequencePlaybackRate ||
- oldTrack.sequence.premountDisplay !==
- track.sequence.premountDisplay ||
- oldTrack.sequence.postmountDisplay !==
- track.sequence.postmountDisplay ||
- oldTrack.displayGroup?.key !== track.displayGroup?.key ||
- oldTrack.displayGroup?.numberOfSequences !==
- track.displayGroup?.numberOfSequences ||
- (oldNodePath === null) !== (nodePath === null) ||
- (oldNodePath !== null &&
- nodePath !== null &&
- !areSequenceNodePathInfosEqual(oldNodePath, nodePath)) ||
- (oldLoop === undefined) !== (loop === undefined) ||
- (oldLoop !== undefined &&
- loop !== undefined &&
- (oldLoop.durationInFrames !== loop.durationInFrames ||
- oldLoop.numberOfTimes !== loop.numberOfTimes ||
- oldLoop.startOffset !== loop.startOffset ||
- oldLoop.phaseOffsetInFrames !== loop.phaseOffsetInFrames ||
- oldLoop.mediaOffsetInFrames !== loop.mediaOffsetInFrames))
+ previousIndex === undefined ||
+ previous.tracks[previousIndex] !== calculation.tracks[index]
) {
return track;
}
- return oldTrack;
+ const oldTrack = previous.timeline[previousIndex];
+ return oldTrack.displayGroup?.key === track.displayGroup?.key &&
+ oldTrack.displayGroup?.numberOfSequences ===
+ track.displayGroup?.numberOfSequences
+ ? oldTrack
+ : track;
});
return {timeline: tracks, structureTimeline: tracks};
}
@@ -412,25 +364,15 @@ const TimelineInner: React.FC = () => {
: {...track, displayGroup: previous.timeline[index].displayGroup},
),
};
- }, [calculation, compositions, overrideIdToNodePathMappings, sequences]);
+ }, [calculation]);
useLayoutEffect(() => {
previousDisplayRef.current = {
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
- compositions,
structure: calculation.structure,
tracks: calculation.tracks,
timeline,
structureTimeline,
};
- }, [
- calculation,
- compositions,
- overrideIdToNodePathMappings,
- sequences,
- structureTimeline,
- timeline,
- ]);
+ }, [calculation, structureTimeline, timeline]);
const durationInFrames = videoConfig?.durationInFrames ?? 0;
const activeFromDragOverrideKeys = Internals.useActiveFromDragOverrideKeys();
diff --git a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
index f4088cbcc2..6abcc383a2 100644
--- a/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
+++ b/packages/studio/src/components/Timeline/TimelineClipboardKeybindings.tsx
@@ -18,20 +18,22 @@ import {memo, useContext, useEffect} from 'react';
import type {VideoConfigValues} from 'remotion';
import {
Internals,
- type OverrideIdToNodePaths,
type PropStatuses,
type InteractivitySchemaField,
type SequencePropsSubscriptionKey,
type InteractivitySchema,
- type TSequence,
} from 'remotion';
import {canUseEffectOperations} from '../../helpers/browser-studio-operations';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {hasClipboardFigmaPayload} from '../../helpers/clipboard-figma';
import {hasClipboardImage} from '../../helpers/clipboard-images';
import {hasClipboardSvgMarkup} from '../../helpers/clipboard-svg';
import {copyText} from '../../helpers/copy-text';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {
areKeyboardShortcutsDisabled,
useKeybinding,
@@ -487,19 +489,16 @@ export const getEffectPropClipboardDataFromSelection = ({
export const getEasingClipboardDataFromSelection = ({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
selection: EasingSelection;
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses;
}): EasingClipboardData | null => {
const easing = getTimelineEasingValueForSelection({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
});
if (easing === null) {
@@ -518,14 +517,12 @@ const getPasteEffectPropTargetForSelection = ({
selection,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
}: {
readonly selection: TimelineSelection;
readonly payload: EffectPropClipboardData;
readonly propStatuses: PropStatuses;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
}):
| {type: 'valid'; target: PasteEffectPropEditTarget}
| Exclude<PasteEffectPropTarget, {type: 'valid'}> => {
@@ -559,8 +556,7 @@ const getPasteEffectPropTargetForSelection = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
const sequence = track?.sequence ?? null;
@@ -620,14 +616,12 @@ export const getPasteEffectPropTarget = ({
selectedItems,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
}: {
readonly selectedItems: readonly TimelineSelection[];
readonly payload: EffectPropClipboardData;
readonly propStatuses: PropStatuses;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
}): PasteEffectPropTarget => {
if (selectedItems.length === 0) {
return {type: 'none'};
@@ -639,8 +633,7 @@ export const getPasteEffectPropTarget = ({
selection,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
});
if (result.type !== 'valid') {
return result;
@@ -663,6 +656,7 @@ export const getPasteEffectPropTarget = ({
};
const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
+ const calculateTimeline = useTimelineCalculator();
const keybindings = useKeybinding();
const {previewServerState} = useContext(StudioServerConnectionCtx);
const canSelect = useTimelineSelectionCanSelect();
@@ -692,13 +686,16 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const sequences = sequencesRef.current;
const overrideIdToNodePathMappings =
overrideIdToNodePathMappingsRef.current;
+ const {tracks} = calculateTimeline({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ });
const selectedItems = currentSelection.current.selectedItems.map(
(selection) => {
if (selection.type === 'guide') return selection;
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
return track?.nodePathInfo
@@ -734,8 +731,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const payload = getKeyframeClipboardDataFromSelections({
selections: selectedItems,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
});
if (payload === null) {
@@ -768,8 +764,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const payload = getEasingClipboardDataFromSelection({
selection: easingSelections[0],
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
});
if (payload === null) {
@@ -808,8 +803,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const payload = getSequencePropClipboardDataFromSelection({
selection: selectedItems[0],
propStatuses,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
});
if (payload === null) {
showNotification(
@@ -929,8 +923,6 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
return;
}
- const overrideIdToNodePathMappings =
- overrideIdToNodePathMappingsRef.current;
const effectClipboardData = getEffectClipboardDataFromSelections({
selectedItems,
propStatuses: propStatusesRef.current,
@@ -965,8 +957,10 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
.then(() => {
const deletePromise = deleteSelectedTimelineItems({
selections: selectedItems,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
setPropStatuses,
clientId,
confirm,
@@ -1028,6 +1022,10 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const sequences = sequencesRef.current;
const overrideIdToNodePathMappings =
overrideIdToNodePathMappingsRef.current;
+ const {tracks} = calculateTimeline({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ });
const timelinePosition = getCurrentFrame();
Promise.resolve()
.then(() => {
@@ -1045,8 +1043,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
selectedItems,
payload: keyframeResult.data,
timelinePosition,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
});
if (keyframeTarget.type !== 'valid') {
@@ -1182,8 +1179,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
const updatePromise = updateSelectedTimelineEasings({
selections: easingSelections,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
setPropStatuses,
clientId,
@@ -1221,8 +1217,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
selectedItems,
payload: sequencePropResult.data,
propStatuses,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
});
if (sequencePropTarget.type !== 'valid') {
switch (sequencePropTarget.type) {
@@ -1312,8 +1307,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
selectedItems,
payload: effectPropResult.data,
propStatuses,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
});
if (effectPropTarget.type !== 'valid') {
@@ -1471,6 +1465,7 @@ const TimelineClipboardKeybindingsUnmemoized: React.FC = () => {
document.removeEventListener('paste', handlePaste);
};
}, [
+ calculateTimeline,
canSelect,
confirm,
currentSelection,
diff --git a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx
index 17d16eabb5..c259b253a3 100644
--- a/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx
+++ b/packages/studio/src/components/Timeline/TimelineDeleteKeybindings.tsx
@@ -1,6 +1,7 @@
import type React from 'react';
import {memo, useContext, useEffect} from 'react';
import {Internals} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {useKeybinding} from '../../helpers/use-keybinding';
import {useConfirmationDialog} from '../ConfirmationDialog';
@@ -17,6 +18,7 @@ import {useDeleteTimelineItems} from './use-delete-timeline-items';
const TimelineDeleteKeybindingsUnmemoized: React.FC = () => {
const keybindings = useKeybinding();
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -76,8 +78,10 @@ const TimelineDeleteKeybindingsUnmemoized: React.FC = () => {
const splitPromise = splitSelectedTimelineItems({
selections: selectedItems,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
propStatuses: propStatusesRef.current,
splitFrame: getCurrentFrame(),
});
@@ -104,6 +108,7 @@ const TimelineDeleteKeybindingsUnmemoized: React.FC = () => {
currentSelection,
deleteTimelineItems,
keybindings,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
propStatusesRef,
previewServerState,
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
index b6346d4cd9..14eb2e26d2 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx
@@ -35,6 +35,7 @@ import {
type DeleteEffectKeyframeChange,
type DeleteSequenceKeyframeChange,
} from './call-delete-keyframe';
+import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {
getKeyframePlaybackRate,
getKeyframeDisplayOffset,
@@ -197,33 +198,6 @@ const findFieldNode = (
return null;
};
-const findTrackForNodePathInfo = ({
- tracks,
- nodePathInfo,
-}: {
- readonly tracks: readonly TimelineTrackData[];
- readonly nodePathInfo: SequenceNodePathInfo;
-}): TimelineTrackData | null => {
- return (
- tracks.find((track) => {
- if (track.nodePathInfo === null) {
- return false;
- }
-
- return (
- timelineNodePathInfoToKey({
- ...track.nodePathInfo,
- auxiliaryKeys: [],
- }) ===
- timelineNodePathInfoToKey({
- ...nodePathInfo,
- auxiliaryKeys: [],
- })
- );
- }) ?? null
- );
-};
-
const resolveKeyframeControlTarget = ({
nodePathInfo,
tracks,
@@ -240,11 +214,7 @@ const resolveKeyframeControlTarget = ({
readonly timelinePosition: number;
}): KeyframeControlTarget | null => {
const track = findTrackForNodePathInfo({tracks, nodePathInfo});
- if (
- track === null ||
- track.nodePathInfo === null ||
- !track.sequence.controls
- ) {
+ if (!track || track.nodePathInfo === null || !track.sequence.controls) {
return null;
}
diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
index 3d3d5ed871..3c27690d03 100644
--- a/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
+++ b/packages/studio/src/components/Timeline/TimelineKeyframeEasingLine.tsx
@@ -1,6 +1,7 @@
import {canvasKeyframeEasingPresets} from '@remotion/sdk';
import React, {useCallback, useContext, useMemo, useRef} from 'react';
import {Internals, useVideoConfig} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {BLUE, LIGHT_TEXT, WHITE_ALPHA_10} from '../../helpers/colors';
import {getXPositionOfItemInTimelineImperatively} from '../../helpers/get-left-of-timeline-slider';
@@ -82,6 +83,7 @@ const TimelineKeyframeEasingLineInteraction: React.FC<
readonly style: React.CSSProperties;
}
> = ({fromFrame, toFrame, nodePathInfo, segmentIndex, style}) => {
+ const calculateTimeline = useTimelineCalculator();
const buttonRef = useRef<HTMLButtonElement>(null);
const {selected, onSelect, selectable, selectionItem} =
useTimelineEasingSelection({
@@ -124,8 +126,10 @@ const TimelineKeyframeEasingLineInteraction: React.FC<
const promise = updateSelectedTimelineEasings({
selections: getTargetSelections(),
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
propStatuses: propStatusesRef.current,
setPropStatuses,
clientId: previewServerState.clientId,
@@ -134,6 +138,7 @@ const TimelineKeyframeEasingLineInteraction: React.FC<
promise?.catch(() => undefined);
},
[
+ calculateTimeline,
getTargetSelections,
overrideIdToNodePathMappingsRef,
previewServerState,
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index cdd6499c30..baf8674ea6 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -15,6 +15,7 @@ import type {
TSequence,
} from 'remotion';
import {Internals} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
BLUE,
@@ -1080,6 +1081,7 @@ const useTimelineSequenceState = (props: TimelineSequenceProps) => {
// if that is the case, it needs to be asynchronously determined
const video = Internals.useVideo();
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const registryEntry = useTimelineSequenceRegistry(s.id);
const isTransitionInteraction =
@@ -1526,12 +1528,15 @@ const useTimelineSequenceState = (props: TimelineSequenceProps) => {
splitSelectedTimelineItems({
selections: selectedItems,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
propStatuses,
splitFrame: getCurrentFrame(),
})?.catch(() => undefined);
}, [
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
previewInteractive,
propStatuses,
@@ -1611,8 +1616,10 @@ const useTimelineSequenceState = (props: TimelineSequenceProps) => {
getContextForAgents: () =>
getSequencesContextForAgents({
nodePathInfos: selectedSequenceNodePathInfos,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
- sequences: sequencesRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
}),
deleteDisabled: !previewInteractive,
duplicateDisabled: !previewInteractive,
@@ -1714,6 +1721,7 @@ const useTimelineSequenceState = (props: TimelineSequenceProps) => {
openInCodingAgent,
openInEditor,
originalLocation,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
previewInteractive,
previewServerState,
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
index 0e0f4621ed..0f3ad1b0a0 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceItem.tsx
@@ -19,6 +19,7 @@ import type {
import {Internals} from 'remotion';
import {areSequenceNodePathInfosEqual} from '../../helpers/are-sequence-node-path-infos-equal';
import {canUseEffectOperations} from '../../helpers/browser-studio-operations';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
BORDER_TIMELINE_DROP_BLUE,
@@ -376,6 +377,7 @@ const TimelineSequenceItemInner: React.FC<{
}) => {
const isPackedTrack = sequence.timelineTrack?.role === 'track';
const nodePath = nodePathInfo?.sequenceSubscriptionKey ?? null;
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -541,12 +543,15 @@ const TimelineSequenceItemInner: React.FC<{
splitSelectedTimelineItems({
selections: selectedItems,
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
propStatuses: propStatusesRef.current,
splitFrame: getCurrentFrame(),
})?.catch(() => undefined);
}, [
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
previewInteractive,
propStatusesRef,
@@ -1388,8 +1393,10 @@ const TimelineSequenceItemInner: React.FC<{
getContextForAgents: () =>
getSequencesContextForAgents({
nodePathInfos: selectedSequenceNodePathInfos,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
- sequences: sequencesRef.current,
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ }).tracks,
}),
deleteDisabled: !previewInteractive,
duplicateDisabled: !previewInteractive,
@@ -1576,6 +1583,7 @@ const TimelineSequenceItemInner: React.FC<{
openInCodingAgent,
openInEditor,
originalLocation,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
previewInteractive,
previewServerState,
diff --git a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
index 17fad45fd2..04a2591e86 100644
--- a/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequenceRightEdgeDragHandle.tsx
@@ -1,8 +1,5 @@
import {CanvasInternals} from '@remotion/sdk';
-import {
- stringifySequenceExpandedRowKey,
- stringifySequenceSubscriptionKey,
-} from '@remotion/studio-shared';
+import {stringifySequenceSubscriptionKey} from '@remotion/studio-shared';
import React, {
useCallback,
useContext,
@@ -22,10 +19,13 @@ import type {
} from 'remotion';
import {Internals} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
-import {calculateTimeline} from '../../helpers/calculate-timeline';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {TRANSPARENT} from '../../helpers/colors';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {
isPointerSessionRelease,
startDeferredCapturedPointerSession,
@@ -43,6 +43,7 @@ import type {
MoveEffectKeyframeChange,
MoveSequenceKeyframeChange,
} from './call-move-keyframe';
+import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {getKeyframeTrimConstraints} from './get-keyframe-trim-constraints';
import {
getKeyframedSequenceDragTargets,
@@ -84,7 +85,7 @@ import {
type TimelineTrimTooltipState,
} from './TimelineTrimTooltip';
-const {getParentSequencePlaybackRate, sortItemsByCommitOrder} = CanvasInternals;
+const {sortItemsByCommitOrder} = CanvasInternals;
const timelineSequenceEdgeDragThresholdPx = 4;
export const timelineSequenceFromDragSnapThresholdPx = 10;
@@ -994,37 +995,13 @@ export const getTimelineSequenceFromDragKeyframeMoves = ({
};
};
-const findSequenceTrack = ({
- tracks,
- nodePathInfo,
-}: {
- readonly tracks: ReturnType<typeof calculateTimeline>;
- readonly nodePathInfo: SequenceNodePathInfo;
-}) => {
- const key = stringifySequenceExpandedRowKey(
- nodePathInfo.sequenceSubscriptionKey,
- );
-
- return tracks.find((candidate) => {
- if (candidate.nodePathInfo === null) {
- return false;
- }
-
- return (
- stringifySequenceExpandedRowKey(
- candidate.nodePathInfo.sequenceSubscriptionKey,
- ) === key && candidate.nodePathInfo.index === nodePathInfo.index
- );
- });
-};
-
export const getTimelineSequenceDurationDragTargets = ({
draggedNodePathInfo,
draggedSequenceMediaDurationDragLimits,
selectedSequenceMediaDurationDragLimits,
selectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
}: {
@@ -1036,7 +1013,7 @@ export const getTimelineSequenceDurationDragTargets = ({
> | null;
readonly selectedItems: readonly TimelineSelection[];
readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
readonly timelineDurationInFrames: number;
}): TimelineSequenceDurationDragTarget[] | null => {
@@ -1063,11 +1040,10 @@ export const getTimelineSequenceDurationDragTargets = ({
draggedItemIsSelected && selectedSequenceItems.length > 1
? selectedSequenceItems.map((item) => item.nodePathInfo)
: [draggedNodePathInfo];
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
const targets = new Map<string, TimelineSequenceDurationDragTarget>();
for (const nodePathInfo of targetNodePathInfos) {
- const track = findSequenceTrack({tracks, nodePathInfo});
+ const track = findTrackForNodePathInfo({tracks, nodePathInfo});
const originalSequence = track
? sequences.find((sequence) => sequence.id === track.sequence.id)
: null;
@@ -1201,10 +1177,7 @@ export const getTimelineSequenceDurationDragTargets = ({
);
targets.set(key, {
- parentPlaybackRate: getParentSequencePlaybackRate(
- originalSequence,
- sequences,
- ),
+ parentPlaybackRate: track.keyframePlaybackRate,
fileName: nodePath.absolutePath,
initialDuration,
maximumDuration,
@@ -1238,7 +1211,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
draggedNodePathInfo,
selectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames = Infinity,
trimBeforeOnly = false,
@@ -1247,7 +1220,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
readonly draggedNodePathInfo: SequenceNodePathInfo;
readonly selectedItems: readonly TimelineSelection[];
readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
readonly timelineDurationInFrames?: number;
readonly trimBeforeOnly?: boolean;
@@ -1272,8 +1245,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
return null;
}
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
- const draggedTrack = findSequenceTrack({
+ const draggedTrack = findTrackForNodePathInfo({
tracks,
nodePathInfo: draggedNodePathInfo,
});
@@ -1288,7 +1260,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
const targets = new Map<string, TimelineSequenceLeftEdgeDragTarget>();
for (const nodePathInfo of targetNodePathInfos) {
- const track = findSequenceTrack({tracks, nodePathInfo});
+ const track = findTrackForNodePathInfo({tracks, nodePathInfo});
const originalSequence = track
? sequences.find((sequence) => sequence.id === track.sequence.id)
: null;
@@ -1350,7 +1322,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [],
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
})?.[0] ?? null;
@@ -1538,10 +1510,7 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
}
targets.set(key, {
- parentPlaybackRate: getParentSequencePlaybackRate(
- originalSequence,
- sequences,
- ),
+ parentPlaybackRate: track.keyframePlaybackRate,
fileName: nodePath.absolutePath,
initialDuration:
(originalSequence.autoDuration
@@ -1592,14 +1561,14 @@ export const getTimelineSequenceLeftEdgeDragTargets = ({
export const getTimelineSequenceRollingEditTargets = ({
draggedNodePathInfo,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
mediaDurationDragLimits,
}: {
readonly draggedNodePathInfo: SequenceNodePathInfo;
readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
readonly timelineDurationInFrames: number;
readonly mediaDurationDragLimits: ReadonlyMap<
@@ -1607,8 +1576,7 @@ export const getTimelineSequenceRollingEditTargets = ({
TimelineSequenceMediaDurationDragLimits | null
> | null;
}): TimelineSequenceLeftEdgeDragTarget[] | null => {
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
- const rightTrack = findSequenceTrack({
+ const rightTrack = findTrackForNodePathInfo({
tracks,
nodePathInfo: draggedNodePathInfo,
});
@@ -1675,7 +1643,7 @@ export const getTimelineSequenceRollingEditTargets = ({
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [],
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
})?.[0],
@@ -1759,7 +1727,7 @@ export const getTimelineSequenceRollingEditTargets = ({
draggedNodePathInfo,
selectedItems: [],
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
trimBeforeOnly: false,
@@ -1774,7 +1742,7 @@ export const getTimelineSequenceRollingEditTargets = ({
selectedSequenceMediaDurationDragLimits: mediaDurationDragLimits,
selectedItems: [],
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelineDurationInFrames,
})?.[0];
@@ -1855,12 +1823,14 @@ export const getTimelineSequenceFromDragTargets = ({
draggedNodePathInfo,
selectedItems,
sequences,
+ tracks,
overrideIdsToNodePaths,
propStatuses,
}: {
readonly draggedNodePathInfo: SequenceNodePathInfo;
readonly selectedItems: readonly TimelineSelection[];
readonly sequences: TSequence[];
+ readonly tracks: readonly TimelineTrackData[];
readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
readonly propStatuses: PropStatuses;
}): TimelineSequenceFromDragTarget[] | null => {
@@ -1887,12 +1857,11 @@ export const getTimelineSequenceFromDragTargets = ({
draggedItemIsSelected && selectedSequenceItems.length > 1
? selectedSequenceItems.map((item) => item.nodePathInfo)
: [draggedNodePathInfo];
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
const sequencesById = new Map(
sequences.map((sequence) => [sequence.id, sequence]),
);
const selectedSequences = targetNodePathInfos.flatMap((nodePathInfo) => {
- const track = findSequenceTrack({tracks, nodePathInfo});
+ const track = findTrackForNodePathInfo({tracks, nodePathInfo});
const originalSequence = track
? sequencesById.get(track.sequence.id)
: undefined;
@@ -1991,13 +1960,10 @@ export const getTimelineSequenceFromDragTargets = ({
const sequenceKeyframes = descendantKeyframes.flatMap(
(descendant) => descendant.sequenceKeyframes,
);
- const parentPlaybackRate = getParentSequencePlaybackRate(
- originalSequence,
- sequences,
- );
const track = tracks.find(
(candidate) => candidate.sequence.id === originalSequence.id,
)!;
+ const parentPlaybackRate = track.keyframePlaybackRate;
const timingLimits = getTimelineSequenceTimingLimits({
propStatuses,
track,
@@ -2161,6 +2127,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
const propStatusesRef = useContext(
Internals.VisualModePropStatusesRefContext,
);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -2350,6 +2317,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
const downEvent = e.nativeEvent;
const sequences = sequencesRef.current;
const overrideIdsToNodePaths = overrideIdToNodePathMappingsRef.current;
+ const {tracks} = calculateTimeline({sequences, overrideIdsToNodePaths});
const propStatuses = propStatusesRef.current;
const handleRect = captureTarget.getBoundingClientRect();
const initialEdgeClientX =
@@ -2366,7 +2334,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
? getTimelineSequenceRollingEditTargets({
draggedNodePathInfo: latestNodePathInfo,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses: statuses,
timelineDurationInFrames,
mediaDurationDragLimits:
@@ -2376,7 +2344,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
draggedNodePathInfo: latestNodePathInfo,
selectedItems: latestSelectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses: statuses,
timelineDurationInFrames,
trimBeforeOnly,
@@ -2790,6 +2758,7 @@ const TimelineSequenceLeftEdgeDragHandleInner: React.FC<{
[
currentSelection,
mediaDurationDragLimitsRegistry,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
cursor,
finishDrag,
@@ -2947,6 +2916,7 @@ export const useTimelineSequenceFromDrag = ({
const propStatusesRef = useContext(
Internals.VisualModePropStatusesRefContext,
);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -3127,7 +3097,12 @@ export const useTimelineSequenceFromDrag = ({
return;
}
+ const {tracks} = calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ });
const targets = getTimelineSequenceFromDragTargets({
+ tracks,
draggedNodePathInfo: latestNodePathInfo,
selectedItems: latestSelectedItems,
sequences: sequencesRef.current,
@@ -3313,6 +3288,7 @@ export const useTimelineSequenceFromDrag = ({
},
[
currentSelection,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
finishDrag,
propStatusesRef,
@@ -3382,6 +3358,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
const propStatusesRef = useContext(
Internals.VisualModePropStatusesRefContext,
);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -3549,6 +3526,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
const downEvent = e.nativeEvent;
const sequences = sequencesRef.current;
const overrideIdsToNodePaths = overrideIdToNodePathMappingsRef.current;
+ const {tracks} = calculateTimeline({sequences, overrideIdsToNodePaths});
const propStatuses = propStatusesRef.current;
const handleRect = captureTarget.getBoundingClientRect();
const initialEdgeClientX =
@@ -3566,7 +3544,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
mediaDurationDragLimitsRegistry?.current ?? null,
selectedItems: latestSelectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses: statuses,
timelineDurationInFrames,
}) ?? [])
@@ -3781,6 +3759,7 @@ const TimelineSequenceRightEdgeDragHandleInner: React.FC<{
},
[
currentSelection,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
cursor,
finishDrag,
diff --git a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts b/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
index c5440a69e3..620ae467da 100644
--- a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
+++ b/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
@@ -1,11 +1,9 @@
-import type {
- CanUpdateSequencePropStatus,
- OverrideIdToNodePaths,
- PropStatuses,
- TSequence,
-} from 'remotion';
+import type {CanUpdateSequencePropStatus, PropStatuses} from 'remotion';
import {Internals} from 'remotion';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {
callDeleteKeyframes,
type DeleteEffectKeyframeChange,
@@ -47,15 +45,13 @@ const getValueWhenLastKeyframeDeleted = ({
const getSelectedKeyframeDeletion = ({
nodePathInfo,
frame,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelinePosition,
}: {
nodePathInfo: SequenceNodePathInfo;
frame: number;
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses;
timelinePosition: number;
}): SelectedKeyframeDeletion | null => {
@@ -65,8 +61,7 @@ const getSelectedKeyframeDeletion = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo,
});
const sequence = track?.sequence ?? null;
@@ -165,8 +160,7 @@ const getSelectedKeyframeDeletion = ({
export const deleteSelectedKeyframes = ({
keyframes,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
setPropStatuses,
clientId,
propStatuses,
@@ -176,8 +170,7 @@ export const deleteSelectedKeyframes = ({
nodePathInfo: SequenceNodePathInfo;
frame: number;
}[];
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
setPropStatuses: SetPropStatuses;
clientId: string;
propStatuses: PropStatuses;
@@ -188,8 +181,7 @@ export const deleteSelectedKeyframes = ({
getSelectedKeyframeDeletion({
nodePathInfo: keyframe.nodePathInfo,
frame: keyframe.frame,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
timelinePosition,
}),
diff --git a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
index 079b4810d0..fe8d94e15d 100644
--- a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
+++ b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
@@ -1,6 +1,9 @@
-import type {OverrideIdToNodePaths, PropStatuses, TSequence} from 'remotion';
+import type {PropStatuses} from 'remotion';
import {canUseEffectOperations} from '../../helpers/browser-studio-operations';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {getSourceMutationRevision} from '../../helpers/source-mutation-queue';
import type {ConfirmationDialogFunction} from '../ConfirmationDialog-types';
import {deleteNodes} from '../delete-nodes-api';
@@ -231,8 +234,7 @@ const containsOnlyKeyframesAndEasings = (
export const deleteSelectedTimelineItems = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
setPropStatuses,
clientId,
confirm,
@@ -240,8 +242,7 @@ export const deleteSelectedTimelineItems = ({
timelinePosition,
}: {
selections: readonly TimelineSelection[];
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
setPropStatuses: SetPropStatuses;
clientId: string;
confirm: ConfirmationDialogFunction;
@@ -264,8 +265,7 @@ export const deleteSelectedTimelineItems = ({
nodePathInfo: selection.nodePathInfo,
frame: selection.frame,
})),
- sequences,
- overrideIdsToNodePaths,
+ tracks,
setPropStatuses,
clientId,
propStatuses,
diff --git a/packages/studio/src/components/Timeline/find-track-for-node-path-info.ts b/packages/studio/src/components/Timeline/find-track-for-node-path-info.ts
index 0793aac443..4c23ba0ee5 100644
--- a/packages/studio/src/components/Timeline/find-track-for-node-path-info.ts
+++ b/packages/studio/src/components/Timeline/find-track-for-node-path-info.ts
@@ -1,38 +1,25 @@
import {stringifySequenceExpandedRowKey} from '@remotion/studio-shared';
-import type {OverrideIdToNodePaths, TSequence} from 'remotion';
-import {calculateTimeline} from '../../helpers/calculate-timeline';
import type {
SequenceNodePathInfo,
TimelineTrackData,
} from '../../helpers/get-timeline-sequence-sort-key';
-export const findTrackForNodePathInfoInTimeline = ({
+export const findTrackForNodePathInfo = ({
tracks,
nodePathInfo,
}: {
- tracks: readonly TimelineTrackData[];
- nodePathInfo: SequenceNodePathInfo;
+ readonly tracks: readonly TimelineTrackData[];
+ readonly nodePathInfo: SequenceNodePathInfo;
}) => {
+ const key = stringifySequenceExpandedRowKey(
+ nodePathInfo.sequenceSubscriptionKey,
+ );
return tracks.find(
(candidate) =>
candidate.nodePathInfo !== null &&
stringifySequenceExpandedRowKey(
candidate.nodePathInfo.sequenceSubscriptionKey,
- ) ===
- stringifySequenceExpandedRowKey(nodePathInfo.sequenceSubscriptionKey) &&
+ ) === key &&
candidate.nodePathInfo.index === nodePathInfo.index,
);
};
-
-export const findTrackForNodePathInfo = ({
- sequences,
- overrideIdsToNodePaths,
- nodePathInfo,
-}: {
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
- nodePathInfo: SequenceNodePathInfo;
-}) => {
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
- return findTrackForNodePathInfoInTimeline({tracks, nodePathInfo});
-};
diff --git a/packages/studio/src/components/Timeline/get-sequences-context-for-agents.ts b/packages/studio/src/components/Timeline/get-sequences-context-for-agents.ts
index 265c437946..6b4df2d95f 100644
--- a/packages/studio/src/components/Timeline/get-sequences-context-for-agents.ts
+++ b/packages/studio/src/components/Timeline/get-sequences-context-for-agents.ts
@@ -1,24 +1,23 @@
-import type {OverrideIdToNodePaths, TSequence} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
import {formatContextForAgents} from '../../helpers/format-file-location';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {getOriginalLocationFromStack} from './TimelineStack/get-stack';
export const getSequencesContextForAgents = async ({
nodePathInfos,
- overrideIdsToNodePaths,
- sequences,
+ tracks,
}: {
readonly nodePathInfos: readonly SequenceNodePathInfo[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
- readonly sequences: TSequence[];
+ readonly tracks: readonly TimelineTrackData[];
}): Promise<string | null> => {
const contexts = await Promise.all(
nodePathInfos.map(async (nodePathInfo) => {
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo,
});
const stack = track?.sequence.getStack() ?? null;
diff --git a/packages/studio/src/components/Timeline/keyframe-clipboard.ts b/packages/studio/src/components/Timeline/keyframe-clipboard.ts
index 7bbe7ec5af..f93c450c7d 100644
--- a/packages/studio/src/components/Timeline/keyframe-clipboard.ts
+++ b/packages/studio/src/components/Timeline/keyframe-clipboard.ts
@@ -10,11 +10,10 @@ import {
Internals,
type CanUpdateSequencePropStatus,
type InteractivitySchema,
- type OverrideIdToNodePaths,
type PropStatuses,
type SequencePropsSubscriptionKey,
- type TSequence,
} from 'remotion';
+import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {
getKeyframePlaybackRate,
@@ -82,13 +81,11 @@ const getKeyframeFieldIdentity = (
const resolveKeyframeField = ({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
readonly selection: TimelineSelection;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
}): ResolvedKeyframeField | null => {
if (
@@ -106,8 +103,7 @@ const resolveKeyframeField = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
if (!track || track.nodePathInfo === null) {
@@ -209,13 +205,11 @@ const areResolvedFieldsEqual = (
export const getKeyframeClipboardDataFromSelections = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
readonly selections: readonly TimelineSelection[];
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
}): KeyframeClipboardData | null => {
const keyframeSelections = selections.filter(
@@ -237,8 +231,7 @@ export const getKeyframeClipboardDataFromSelections = ({
selection,
resolved: resolveKeyframeField({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}),
}));
@@ -310,8 +303,7 @@ export const getKeyframeClipboardDataFromSelections = ({
for (const easingSelection of easingSelections) {
const resolved = resolveKeyframeField({
selection: easingSelection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
});
if (
@@ -407,15 +399,13 @@ export const getPasteKeyframeTarget = ({
selectedItems,
payload,
timelinePosition,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
readonly selectedItems: readonly TimelineSelection[];
readonly payload: KeyframeClipboardData;
readonly timelinePosition: number;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
}): PasteKeyframeTarget => {
if (selectedItems.length === 0) {
@@ -444,8 +434,7 @@ export const getPasteKeyframeTarget = ({
const resolvedFields = resolvedSelectedItems.map((item) =>
resolveKeyframeField({
selection: item,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}),
);
diff --git a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
index b227817998..27a86a6e50 100644
--- a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
+++ b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
@@ -1,14 +1,13 @@
import {getEffectFieldsToShow} from '@remotion/studio-shared';
import type {
CanUpdateSequencePropStatus,
- OverrideIdToNodePaths,
PropStatuses,
InteractivitySchemaField,
SequencePropsSubscriptionKey,
InteractivitySchema,
- TSequence,
} from 'remotion';
import {Internals} from 'remotion';
+import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {getSequencePropResetChanges} from './get-sequence-prop-reset-changes';
import {saveMultipleEffectProps} from './save-effect-prop';
@@ -131,13 +130,11 @@ const getActiveFieldSchema = ({
export const getTimelinePropResetTargets = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
readonly selections: readonly TimelineSelection[];
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
}): TimelinePropResetTarget[] | null => {
const propSelections = selections.filter(isPropResetSelection);
@@ -154,8 +151,7 @@ export const getTimelinePropResetTargets = ({
const resetTargets: TimelinePropResetTarget[] = [];
for (const selection of selections) {
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
const sequence = track?.sequence ?? null;
@@ -259,23 +255,20 @@ export const getTimelinePropResetTargets = ({
export const resetSelectedTimelineProps = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
setPropStatuses,
clientId,
}: {
readonly selections: readonly TimelineSelection[];
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
readonly setPropStatuses: SetPropStatuses;
readonly clientId: string;
}): Promise<void> | null => {
const resetTargets = getTimelinePropResetTargets({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
});
if (resetTargets === null || resetTargets.length === 0) {
diff --git a/packages/studio/src/components/Timeline/sequence-prop-clipboard.ts b/packages/studio/src/components/Timeline/sequence-prop-clipboard.ts
index 80c9c7a8b5..680fe77873 100644
--- a/packages/studio/src/components/Timeline/sequence-prop-clipboard.ts
+++ b/packages/studio/src/components/Timeline/sequence-prop-clipboard.ts
@@ -8,11 +8,10 @@ import {
Internals,
type CanUpdateSequencePropStatus,
type InteractivitySchema,
- type OverrideIdToNodePaths,
type PropStatuses,
type SequencePropsSubscriptionKey,
- type TSequence,
} from 'remotion';
+import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-key';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {isKeyframeValueCompatible} from './keyframe-clipboard';
import type {TimelineSelection} from './TimelineSelection';
@@ -52,21 +51,18 @@ export const propStatusToClipboardParam = (
export const getSequencePropClipboardDataFromSelection = ({
selection,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
}: {
readonly selection: TimelineSelection;
readonly propStatuses: PropStatuses;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
}): SequencePropClipboardData | null => {
if (selection.type !== 'sequence-prop') {
return null;
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
if (!track?.sequence.controls) {
@@ -125,14 +121,12 @@ const getPasteTargetForSelection = ({
selection,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
}: {
readonly selection: TimelineSelection;
readonly payload: SequencePropClipboardData;
readonly propStatuses: PropStatuses;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
}):
| {type: 'valid'; target: PasteSequencePropEditTarget}
| Exclude<PasteSequencePropTarget, {type: 'valid'}> => {
@@ -147,8 +141,7 @@ const getPasteTargetForSelection = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
if (!track?.sequence.controls || !track.nodePathInfo) {
@@ -199,14 +192,12 @@ export const getPasteSequencePropTarget = ({
selectedItems,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
}: {
readonly selectedItems: readonly TimelineSelection[];
readonly payload: SequencePropClipboardData;
readonly propStatuses: PropStatuses;
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
}): PasteSequencePropTarget => {
if (selectedItems.length === 0) {
return {type: 'none'};
@@ -218,8 +209,7 @@ export const getPasteSequencePropTarget = ({
selection,
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
});
if (result.type !== 'valid') {
return result;
diff --git a/packages/studio/src/components/Timeline/should-show-track-in-timeline.ts b/packages/studio/src/components/Timeline/should-show-track-in-timeline.ts
index 44f1d2c704..083a37d9c3 100644
--- a/packages/studio/src/components/Timeline/should-show-track-in-timeline.ts
+++ b/packages/studio/src/components/Timeline/should-show-track-in-timeline.ts
@@ -4,7 +4,7 @@ import type {TimelineTrackData} from '../../helpers/get-timeline-sequence-sort-k
// - The sequence opted-in via `showInTimeline` (the default).
// Children of a sequence with `showInTimeline: false` keep being listed
// on their own; their depth is independently flattened by
-// `getTimelineNestedLevel` so the parent does not contribute an indent.
+// the timeline calculator so the parent does not contribute an indent.
// - The sequence has a positive duration.
// - The sequence starts before the composition ends.
export const shouldShowTrackInTimeline = (
diff --git a/packages/studio/src/components/Timeline/split-selected-timeline-item.ts b/packages/studio/src/components/Timeline/split-selected-timeline-item.ts
index 48286600ee..360bdce58e 100644
--- a/packages/studio/src/components/Timeline/split-selected-timeline-item.ts
+++ b/packages/studio/src/components/Timeline/split-selected-timeline-item.ts
@@ -1,7 +1,6 @@
import {hasSequenceTimingTraits} from '@remotion/studio-shared';
import type {
CanUpdateSequencePropStatus,
- OverrideIdToNodePaths,
PropStatuses,
TSequence,
} from 'remotion';
@@ -226,16 +225,14 @@ export const splitTimelineSequencesFromSource = ({
export const splitSelectedTimelineItems = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
splitFrame,
splitSequences = splitTimelineSequencesFromSource,
notify = showNotification,
}: {
selections: readonly TimelineSelection[];
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses | undefined;
splitFrame: number;
splitSequences?: (options: {
@@ -264,8 +261,7 @@ export const splitSelectedTimelineItems = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
const sequencePropStatuses = propStatuses
diff --git a/packages/studio/src/components/Timeline/timeline-track-groups.ts b/packages/studio/src/components/Timeline/timeline-track-groups.ts
index 2de7929b6f..815f21dfad 100644
--- a/packages/studio/src/components/Timeline/timeline-track-groups.ts
+++ b/packages/studio/src/components/Timeline/timeline-track-groups.ts
@@ -274,10 +274,10 @@ export const projectTimelineDisplayRows = ({
}: {
readonly rows: readonly TimelineDisplayRow[];
readonly tracksById: ReadonlyMap<string, TimelineTrackWithDisplayGroup>;
- readonly previousRows: readonly TimelineDisplayRow[] | null;
+ readonly previousRows: readonly TimelineDisplayRow[];
}): readonly TimelineDisplayRow[] => {
const previousById =
- previousRows === null || previousRows === rows
+ previousRows === rows
? null
: new Map(previousRows.map((row) => [row.track.sequence.id, row]));
const updateTracks = (
diff --git a/packages/studio/src/components/Timeline/update-selected-easing.ts b/packages/studio/src/components/Timeline/update-selected-easing.ts
index bde8a3e233..b32138924c 100644
--- a/packages/studio/src/components/Timeline/update-selected-easing.ts
+++ b/packages/studio/src/components/Timeline/update-selected-easing.ts
@@ -6,14 +6,15 @@ import {
import type {
CanUpdateSequencePropStatusKeyframed,
DragOverrideValue,
- OverrideIdToNodePaths,
PropStatuses,
SequencePropsSubscriptionKey,
InteractivitySchema,
- TSequence,
} from 'remotion';
import {Internals} from 'remotion';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {callBatchUpdateKeyframeSettings} from './call-update-keyframe-settings';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {parseKeyframeFieldFromNodePath} from './parse-keyframe-field-from-node-path';
@@ -59,13 +60,11 @@ const isEasingSelection = (
export const getSelectedEasingUpdate = ({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
selection: EasingSelection;
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses;
}): SelectedEasingUpdate | null => {
const field = parseKeyframeFieldFromNodePath(
@@ -76,8 +75,7 @@ export const getSelectedEasingUpdate = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo: selection.nodePathInfo,
});
const sequence = track?.sequence ?? null;
@@ -166,21 +164,18 @@ export const getSelectedEasingUpdate = ({
export const getSelectedEasingUpdates = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
readonly selections: readonly TimelineSelection[];
- readonly sequences: TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
+ readonly tracks: readonly TimelineTrackData[];
readonly propStatuses: PropStatuses;
}): SelectedEasingUpdate[] => {
return getEasingSelections(selections)
.map((selection) =>
getSelectedEasingUpdate({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}),
)
@@ -216,20 +211,17 @@ export const getEasingSelections = (
export const getTimelineEasingValueForSelection = ({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
}: {
selection: EasingSelection;
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses;
}): TimelineEasingValue | null => {
return (
getSelectedEasingUpdate({
selection,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
})?.currentEasing ?? null
);
@@ -237,16 +229,14 @@ export const getTimelineEasingValueForSelection = ({
export const updateSelectedTimelineEasings = ({
selections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
setPropStatuses,
clientId,
easing,
}: {
selections: readonly TimelineSelection[];
- sequences: TSequence[];
- overrideIdsToNodePaths: OverrideIdToNodePaths;
+ tracks: readonly TimelineTrackData[];
propStatuses: PropStatuses;
setPropStatuses: SetPropStatuses;
clientId: string;
@@ -259,8 +249,7 @@ export const updateSelectedTimelineEasings = ({
const updates = getSelectedEasingUpdates({
selections: easingSelections,
- sequences,
- overrideIdsToNodePaths,
+ tracks,
propStatuses,
});
diff --git a/packages/studio/src/components/Timeline/use-clamp-sequence-timing-value.ts b/packages/studio/src/components/Timeline/use-clamp-sequence-timing-value.ts
index 277a89cc9d..54af302a91 100644
--- a/packages/studio/src/components/Timeline/use-clamp-sequence-timing-value.ts
+++ b/packages/studio/src/components/Timeline/use-clamp-sequence-timing-value.ts
@@ -2,12 +2,13 @@ import {stringifySequenceSubscriptionKey} from '@remotion/studio-shared';
import {useCallback, useContext, useRef} from 'react';
import type {SequencePropsSubscriptionKey} from 'remotion';
import {Internals} from 'remotion';
-import {calculateTimeline} from '../../helpers/calculate-timeline';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {OverrideIdToNodePathMappingsRefContext} from '../SequencePropsSubscriptionProvider';
import {getKeyframeTrimConstraints} from './get-keyframe-trim-constraints';
import {getTimelineSequenceTimingLimits} from './get-timeline-sequence-timing-limits';
export const useClampSequenceTimingValue = () => {
+ const calculateTimeline = useTimelineCalculator();
const propStatusesRef = useContext(
Internals.VisualModePropStatusesRefContext,
);
@@ -35,7 +36,7 @@ export const useClampSequenceTimingValue = () => {
let limits = limitsRef.current.get(key);
if (!limits) {
const sequences = sequencesRef.current;
- const tracks = calculateTimeline({
+ const {tracks} = calculateTimeline({
sequences,
overrideIdsToNodePaths: mappingsRef.current,
});
@@ -124,7 +125,13 @@ export const useClampSequenceTimingValue = () => {
),
);
},
- [mappingsRef, sequencesRef, propStatusesRef, video?.durationInFrames],
+ [
+ calculateTimeline,
+ mappingsRef,
+ sequencesRef,
+ propStatusesRef,
+ video?.durationInFrames,
+ ],
);
return {clampTimingValue, clearTimingLimits};
};
diff --git a/packages/studio/src/components/Timeline/use-delete-timeline-items.ts b/packages/studio/src/components/Timeline/use-delete-timeline-items.ts
index 423416ef47..4ddc17491d 100644
--- a/packages/studio/src/components/Timeline/use-delete-timeline-items.ts
+++ b/packages/studio/src/components/Timeline/use-delete-timeline-items.ts
@@ -1,6 +1,7 @@
import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared';
import {useCallback, useContext} from 'react';
import {Internals} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
import {
EditorShowGuidesContext,
@@ -24,6 +25,7 @@ import {
} from './update-selected-easing';
export const useDeleteTimelineItems = () => {
+ const calculateTimeline = useTimelineCalculator();
const {previewServerState} = useContext(StudioServerConnectionCtx);
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
@@ -50,9 +52,6 @@ export const useDeleteTimelineItems = () => {
selectItems,
} = currentSelection.current;
const selectedItems = selectedItemsOverride ?? currentSelectedItems;
- const sequences = sequencesRef.current;
- const overrideIdToNodePathMappings =
- overrideIdToNodePathMappingsRef.current;
const propStatuses = propStatusesRef.current;
const timelinePosition = getCurrentFrame();
if (selectedItems.length === 0) {
@@ -72,10 +71,13 @@ export const useDeleteTimelineItems = () => {
return;
}
+ const {tracks} = calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
+ });
const deletePromise = deleteSelectedTimelineItems({
selections: selectedItems,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
setPropStatuses,
clientId,
confirm,
@@ -117,8 +119,7 @@ export const useDeleteTimelineItems = () => {
if (easingSelections.length === selectedItems.length) {
const resetEasingPromise = updateSelectedTimelineEasings({
selections: easingSelections,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
setPropStatuses,
clientId,
@@ -133,8 +134,7 @@ export const useDeleteTimelineItems = () => {
const resetPromise = resetSelectedTimelineProps({
selections: selectedItems,
- sequences,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ tracks,
propStatuses,
setPropStatuses,
clientId,
@@ -145,6 +145,7 @@ export const useDeleteTimelineItems = () => {
}
},
[
+ calculateTimeline,
confirm,
currentSelection,
overrideIdToNodePathMappingsRef,
diff --git a/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts b/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts
index 07cac7b756..c232a6f0f5 100644
--- a/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts
+++ b/packages/studio/src/components/Timeline/use-timeline-keyframe-drag.ts
@@ -4,14 +4,16 @@ import {useCallback, useContext} from 'react';
import type {
CanUpdateSequencePropStatusKeyframed,
InteractivitySchema,
- OverrideIdToNodePaths,
PropStatuses,
SequencePropsSubscriptionKey,
- TSequence,
} from 'remotion';
import {Internals, useVideoConfig} from 'remotion';
+import {useTimelineCalculator} from '../../helpers/calculate-timeline';
import {StudioServerConnectionCtx} from '../../helpers/client-id';
-import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
+import type {
+ SequenceNodePathInfo,
+ TimelineTrackData,
+} from '../../helpers/get-timeline-sequence-sort-key';
import {
isPointerSessionRelease,
startCapturedPointerSession,
@@ -218,14 +220,12 @@ const getTimelineKeyframeDragTarget = ({
propStatuses,
displayFrame,
nodePathInfo,
- overrideIdsToNodePaths,
- sequences,
+ tracks,
}: {
readonly propStatuses: PropStatuses;
readonly displayFrame: number;
readonly nodePathInfo: SequenceNodePathInfo;
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
- readonly sequences: TSequence[];
+ readonly tracks: readonly TimelineTrackData[];
}): TimelineKeyframeDragTarget | null => {
const field = parseKeyframeFieldFromNodePath(nodePathInfo.auxiliaryKeys);
if (field === null) {
@@ -233,8 +233,7 @@ const getTimelineKeyframeDragTarget = ({
}
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths,
+ tracks,
nodePathInfo,
});
const sequence = track?.sequence ?? null;
@@ -486,6 +485,7 @@ export const useTimelineKeyframeDrag = ({
const videoConfig = useVideoConfig();
const timelineWidth = useContext(TimelineWidthContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -557,14 +557,17 @@ export const useTimelineKeyframeDrag = ({
return dragTargets;
}
+ const {tracks} = calculateTimeline({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ });
dragTargets = keyframesToDrag
.map((keyframe) =>
getTimelineKeyframeDragTarget({
propStatuses,
displayFrame: keyframe.frame,
nodePathInfo: keyframe.nodePathInfo,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
- sequences,
+ tracks,
}),
)
.filter(
@@ -743,6 +746,7 @@ export const useTimelineKeyframeDrag = ({
frame,
nodePathInfo,
onSelect,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
propStatusesRef,
previewServerState,
@@ -773,6 +777,7 @@ export const useTimelineEasingKeyframeDrag = ({
const videoConfig = useVideoConfig();
const timelineWidth = useContext(TimelineWidthContext);
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const calculateTimeline = useTimelineCalculator();
const sequencesRef = useContext(Internals.SequenceManagerRefContext);
const overrideIdToNodePathMappingsRef = useContext(
OverrideIdToNodePathMappingsRefContext,
@@ -836,14 +841,17 @@ export const useTimelineEasingKeyframeDrag = ({
return dragTargets;
}
+ const {tracks} = calculateTimeline({
+ sequences,
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
+ });
dragTargets = keyframesToDrag
.map((keyframe) =>
getTimelineKeyframeDragTarget({
propStatuses,
displayFrame: keyframe.frame,
nodePathInfo: keyframe.nodePathInfo,
- overrideIdsToNodePaths: overrideIdToNodePathMappings,
- sequences,
+ tracks,
}),
)
.filter(
@@ -1019,6 +1027,7 @@ export const useTimelineEasingKeyframeDrag = ({
clearDraggedKeyframes,
currentSelection,
onSelect,
+ calculateTimeline,
overrideIdToNodePathMappingsRef,
propStatusesRef,
previewServerState,
diff --git a/packages/studio/src/components/Timeline/use-timeline-sequence-registry.ts b/packages/studio/src/components/Timeline/use-timeline-sequence-registry.ts
index 6e450780fc..e10bf1fa15 100644
--- a/packages/studio/src/components/Timeline/use-timeline-sequence-registry.ts
+++ b/packages/studio/src/components/Timeline/use-timeline-sequence-registry.ts
@@ -12,7 +12,6 @@ type SequenceRegistry = NonNullable<
type TimelineSequenceRegistryEntry = {
readonly sequence: TSequence;
- readonly previousSequenceId: string | null;
readonly previousOverrideId: string | null;
readonly nextOverrideId: string | null;
readonly previousTouchingSequence: TSequence | null;
@@ -91,7 +90,6 @@ const updateRegistryEntries = ({
index.entries.set(
sequenceId,
previousEntry?.sequence === sequence &&
- previousEntry.previousSequenceId === previousSequenceId &&
previousEntry.previousOverrideId === previousOverrideId &&
previousEntry.nextOverrideId === nextOverrideId &&
previousEntry.previousTouchingSequence === previousTouchingSequence &&
@@ -99,7 +97,6 @@ const updateRegistryEntries = ({
? previousEntry
: {
sequence,
- previousSequenceId,
previousOverrideId,
nextOverrideId,
previousTouchingSequence,
diff --git a/packages/studio/src/components/WebMcp.tsx b/packages/studio/src/components/WebMcp.tsx
index 4cba7a2cb5..aa4e4a92f6 100644
--- a/packages/studio/src/components/WebMcp.tsx
+++ b/packages/studio/src/components/WebMcp.tsx
@@ -1,3 +1,4 @@
+import {CanvasInternals} from '@remotion/sdk';
import {isValidPackageName} from '@remotion/studio-shared';
import {
useContext,
@@ -15,7 +16,7 @@ import {restartStudio} from '../api/restart-studio';
import {seek} from '../api/seek';
import {shutDownStudio} from '../api/shut-down-studio';
import {getCurrentError} from '../error-overlay/current-error';
-import {calculateTimeline} from '../helpers/calculate-timeline';
+import {useTimelineCalculator} from '../helpers/calculate-timeline';
import {createFolderTree} from '../helpers/create-folder-tree';
import {
formatContextForAgents,
@@ -50,10 +51,7 @@ import {
validatePublicOutputName,
} from './public-output-name';
import {RenderQueueContext} from './RenderQueue/context';
-import {
- getSequencesWithSelectableOutlines,
- measureOutlineTargets,
-} from './selected-outline-measurement';
+import {measureOutlineTargets} from './selected-outline-measurement';
import {getCurrentDuration, getCurrentFrame} from './Timeline/imperative-state';
import {parseKeyframeFieldFromNodePath} from './Timeline/parse-keyframe-field-from-node-path';
import {shouldShowTrackInTimeline} from './Timeline/should-show-track-in-timeline';
@@ -262,6 +260,7 @@ const WebMcpSelectionSync: FC<{
};
export const WebMcp: FC = () => {
+ const calculateTimeline = useTimelineCalculator();
const compactSeries = useCompactSeries();
const compactSeriesRef = useRef(compactSeries);
compactSeriesRef.current = compactSeries;
@@ -365,7 +364,7 @@ export const WebMcp: FC = () => {
overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
compositions: compositionsRef.current,
showConnectedCompositionChildren: compactSeriesRef.current,
- }).filter((timelineTrack) =>
+ }).tracks.filter((timelineTrack) =>
shouldShowTrackInTimeline(timelineTrack, durationInFrames),
);
};
@@ -1068,12 +1067,17 @@ export const WebMcp: FC = () => {
}
const currentFrame = getCurrentFrame();
- const selectableOutlines = getSequencesWithSelectableOutlines({
- sequences: sequencesRef.current,
- overrideIdsToNodePaths: overrideIdToNodePathMappingsRef.current,
- compositions: compositionsRef.current,
- timelinePosition: currentFrame,
- });
+ const selectableOutlines =
+ CanvasInternals.getCanvasSelectableOutlines({
+ tracks: calculateTimeline({
+ sequences: sequencesRef.current,
+ overrideIdsToNodePaths:
+ overrideIdToNodePathMappingsRef.current,
+ compositions: compositionsRef.current,
+ }).tracks,
+ timelinePosition: currentFrame,
+ resolveSequenceNodePathInfo: null,
+ });
const portalNode = Internals.portalNode();
const portalRect = portalNode.getBoundingClientRect();
if (portalRect.width === 0 || portalRect.height === 0) {
@@ -1749,6 +1753,7 @@ export const WebMcp: FC = () => {
}, [
addCaptionJob,
addVideoMattingJob,
+ calculateTimeline,
isPlaying,
selectComposition,
sequencesRef,
diff --git a/packages/studio/src/components/selected-outline-measurement.ts b/packages/studio/src/components/selected-outline-measurement.ts
index de3e3348f6..855a4bf88e 100644
--- a/packages/studio/src/components/selected-outline-measurement.ts
+++ b/packages/studio/src/components/selected-outline-measurement.ts
@@ -1,11 +1,8 @@
import {CanvasInternals} from '@remotion/sdk';
-import type {_InternalTypes, OverrideIdToNodePaths, TSequence} from 'remotion';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {BLACK, WHITE} from '../helpers/colors';
import {studioCssVariables} from '../helpers/studio-css-variables';
import type {OutlinePoint, SelectedOutline} from './selected-outline-geometry';
import {mixPoint} from './selected-outline-geometry';
-import type {SequenceWithSelectedOutline} from './selected-outline-types';
import {
cropFieldKeys,
rotateFieldKey,
@@ -22,8 +19,6 @@ import {
parseTransformOrigin,
} from './Timeline/transform-origin-utils';
-const {getCanvasSelectableOutlines} = CanvasInternals;
-
export const {
getCanvasOutlineSelectionInteraction: getOutlineSelectionInteraction,
getCanvasSelectedSequenceKeys: getSelectedSequenceKeys,
@@ -391,25 +386,3 @@ export const getSelectedRotationInfo = (
: selectedItem.fromFrame,
};
};
-
-export const getSequencesWithSelectableOutlines = ({
- sequences,
- overrideIdsToNodePaths,
- compositions = [],
- timelinePosition,
-}: {
- readonly sequences: readonly TSequence[];
- readonly overrideIdsToNodePaths: OverrideIdToNodePaths;
- readonly compositions?: readonly _InternalTypes['AnyComposition'][];
- readonly timelinePosition: number | null;
-}): SequenceWithSelectedOutline[] => {
- return getCanvasSelectableOutlines({
- tracks: calculateTimeline({
- sequences,
- overrideIdsToNodePaths,
- compositions,
- }),
- timelinePosition,
- resolveSequenceNodePathInfo: null,
- });
-};
diff --git a/packages/studio/src/helpers/calculate-timeline.ts b/packages/studio/src/helpers/calculate-timeline.ts
index 34c52bd6b9..c30e73de1d 100644
--- a/packages/studio/src/helpers/calculate-timeline.ts
+++ b/packages/studio/src/helpers/calculate-timeline.ts
@@ -1,81 +1,73 @@
import {CanvasInternals} from '@remotion/sdk';
-import {useContext, useRef} from 'react';
+import {useContext, useMemo, type ContextType} from 'react';
import {Internals} from 'remotion';
-type TimelineInput = Parameters<typeof CanvasInternals.calculateTimeline>[0];
-type TimelineTracks = ReturnType<typeof CanvasInternals.calculateTimeline>;
+type TimelineCalculator = ReturnType<
+ typeof CanvasInternals.createTimelineCalculator
+>;
+type TimelineInput = Parameters<TimelineCalculator>[0];
type Compositions = NonNullable<TimelineInput['compositions']>;
const emptyCompositions: Compositions = [];
-
-// Registry snapshots are immutable and belong to one preview root. Weak keys
-// let interactions share its calculated tracks without retaining old snapshots.
-const timelinesBySnapshot = new WeakMap<
- TimelineInput['sequences'],
- WeakMap<
- TimelineInput['overrideIdsToNodePaths'],
- WeakMap<Compositions, Map<boolean, TimelineTracks>>
- >
+const calculatorsByRegistry = new WeakMap<
+ NonNullable<ContextType<typeof Internals.SequenceRegistryContext>>,
+ TimelineCalculator
>();
-const findCachedTimeline = (input: TimelineInput) => {
- return timelinesBySnapshot
- .get(input.sequences)
- ?.get(input.overrideIdsToNodePaths)
- ?.get(input.compositions?.length ? input.compositions : emptyCompositions)
- ?.get(input.showConnectedCompositionChildren ?? false);
-};
-
-const cacheTimelineCalculation = (
- input: TimelineInput,
- tracks: TimelineTracks,
-) => {
- const byMapping = timelinesBySnapshot.get(input.sequences) ?? new WeakMap();
- const byCompositions =
- byMapping.get(input.overrideIdsToNodePaths) ?? new WeakMap();
- const compositions = input.compositions?.length
- ? input.compositions
- : emptyCompositions;
- const byVisibility = byCompositions.get(compositions) ?? new Map();
- byVisibility.set(input.showConnectedCompositionChildren ?? false, tracks);
- byCompositions.set(compositions, byVisibility);
- byMapping.set(input.overrideIdsToNodePaths, byCompositions);
- timelinesBySnapshot.set(input.sequences, byMapping);
-};
+export const useTimelineCalculator = (): TimelineCalculator => {
+ const registry = useContext(Internals.SequenceRegistryContext);
+ return useMemo(() => {
+ const existing =
+ registry === null ? null : calculatorsByRegistry.get(registry);
+ if (existing) {
+ return existing;
+ }
-export const calculateTimeline = (input: TimelineInput): TimelineTracks => {
- const cached = findCachedTimeline(input);
- if (cached) {
- return cached;
- }
+ // Consumers in one preview share retained models. Different composition
+ // visibility settings need independent models of the same registrations.
+ const calculatorsByConfiguration = new WeakMap<
+ TimelineInput['overrideIdsToNodePaths'],
+ WeakMap<Compositions, Map<boolean, TimelineCalculator>>
+ >();
+ const calculate: TimelineCalculator = (input) => {
+ const compositions = input.compositions?.length
+ ? input.compositions
+ : emptyCompositions;
+ const showConnectedCompositionChildren =
+ input.showConnectedCompositionChildren ?? false;
+ let byCompositions = calculatorsByConfiguration.get(
+ input.overrideIdsToNodePaths,
+ );
+ if (!byCompositions) {
+ byCompositions = new WeakMap();
+ calculatorsByConfiguration.set(
+ input.overrideIdsToNodePaths,
+ byCompositions,
+ );
+ }
- const tracks = CanvasInternals.calculateTimeline(input);
- // Ad hoc callers may mutate their input between calls. Only retain results
- // for immutable registry snapshots already published by a retained calculator.
- if (timelinesBySnapshot.has(input.sequences)) {
- cacheTimelineCalculation(input, tracks);
- }
+ let byVisibility = byCompositions.get(compositions);
+ if (!byVisibility) {
+ byVisibility = new Map();
+ byCompositions.set(compositions, byVisibility);
+ }
- return tracks;
-};
+ let calculator = byVisibility.get(showConnectedCompositionChildren);
+ if (!calculator) {
+ calculator = CanvasInternals.createTimelineCalculator();
+ byVisibility.set(showConnectedCompositionChildren, calculator);
+ }
-export const createTimelineCalculator = () => {
- const calculate = CanvasInternals.createTimelineCalculator();
- return (input: TimelineInput) => {
- const result = calculate(input);
- cacheTimelineCalculation(input, result.tracks);
- return result;
- };
-};
+ return calculator({
+ ...input,
+ compositions,
+ showConnectedCompositionChildren,
+ });
+ };
-export const useTimelineCalculator = () => {
- const registry = useContext(Internals.SequenceRegistryContext);
- const calculator = useRef<{
- readonly registry: typeof registry;
- readonly calculate: ReturnType<typeof createTimelineCalculator>;
- } | null>(null);
- if (calculator.current === null || calculator.current.registry !== registry) {
- calculator.current = {registry, calculate: createTimelineCalculator()};
- }
+ if (registry !== null) {
+ calculatorsByRegistry.set(registry, calculate);
+ }
- return calculator.current.calculate;
+ return calculate;
+ }, [registry]);
};
diff --git a/packages/studio/src/helpers/get-sequence-visible-range.ts b/packages/studio/src/helpers/get-sequence-visible-range.ts
deleted file mode 100644
index 33df99c396..0000000000
--- a/packages/studio/src/helpers/get-sequence-visible-range.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import {CanvasInternals} from '@remotion/sdk';
-export const {
- getParentSequencePlaybackRate,
- getCascadedStart,
- getCascadedStartWithTrim,
- getTimelineVisibleDuration,
- getTimelineVisibleStart,
-} = CanvasInternals;
diff --git a/packages/studio/src/helpers/get-timeline-nestedness.ts b/packages/studio/src/helpers/get-timeline-nestedness.ts
deleted file mode 100644
index 7c5fefdce4..0000000000
--- a/packages/studio/src/helpers/get-timeline-nestedness.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import {CanvasInternals} from '@remotion/sdk';
-export const {getTimelineNestedLevel} = CanvasInternals;
diff --git a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts b/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
index 62cfa44f04..7c534c46f6 100644
--- a/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
+++ b/packages/studio/src/helpers/get-timeline-sequence-sort-key.ts
@@ -1,7 +1 @@
-import {CanvasInternals} from '@remotion/sdk';
-export const {getTimelineSequenceSortKey} = CanvasInternals;
-export type {
- SequenceNodePathInfo,
- TimelineTrackData,
- TimelineTrackWithOriginalTimings,
-} from '@remotion/sdk';
+export type {SequenceNodePathInfo, TimelineTrackData} from '@remotion/sdk';
diff --git a/packages/studio/src/test/html-in-canvas-wrapper-timing.test.ts b/packages/studio/src/test/html-in-canvas-wrapper-timing.test.ts
index b5d253c207..72d282abb2 100644
--- a/packages/studio/src/test/html-in-canvas-wrapper-timing.test.ts
+++ b/packages/studio/src/test/html-in-canvas-wrapper-timing.test.ts
@@ -1,7 +1,7 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {SequencePropsSubscriptionKey, TSequence} from 'remotion';
import {getHtmlInCanvasWrapperTiming} from '../components/InspectorPanel/get-html-in-canvas-wrapper-timing';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {makeRuntimeValueStore} from './make-runtime-value-store';
const nodePath: SequencePropsSubscriptionKey = {
@@ -63,7 +63,8 @@ const makeSequence = ({
});
test('converts nested playback and trim into the parent clock', () => {
- const nestedTracks = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const nestedTracks = calculate({
sequences: [
makeSequence({
id: 'outer',
@@ -83,7 +84,7 @@ test('converts nested playback and trim into the parent clock', () => {
}),
],
overrideIdsToNodePaths: {selected: nodePath},
- });
+ }).tracks;
expect(
getHtmlInCanvasWrapperTiming({
@@ -94,7 +95,8 @@ test('converts nested playback and trim into the parent clock', () => {
});
test('clips wrapper timing to the parent visible range', () => {
- const parentClippedTracks = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const parentClippedTracks = calculate({
sequences: [
makeSequence({
id: 'parent',
@@ -110,7 +112,7 @@ test('clips wrapper timing to the parent visible range', () => {
}),
],
overrideIdsToNodePaths: {selected: nodePath},
- });
+ }).tracks;
expect(
getHtmlInCanvasWrapperTiming({
diff --git a/packages/studio/src/test/keyframe-trim-constraints.test.ts b/packages/studio/src/test/keyframe-trim-constraints.test.ts
index be6071a6e8..e436aca67c 100644
--- a/packages/studio/src/test/keyframe-trim-constraints.test.ts
+++ b/packages/studio/src/test/keyframe-trim-constraints.test.ts
@@ -1,5 +1,6 @@
import {expect, test} from 'bun:test';
import {CodemodsInternals, getNodeProps, getNodes} from '@remotion/codemods';
+import {CanvasInternals} from '@remotion/sdk';
import type {EventSourceEvent} from '@remotion/studio-shared';
import {waitFor} from '@testing-library/react';
import type {
@@ -16,7 +17,6 @@ import {
getTimelineSequenceLeftEdgeDragChanges,
getTimelineSequenceLeftEdgeDragTargets,
} from '../components/Timeline/TimelineSequenceRightEdgeDragHandle';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {makeBrowserStudioOperations} from './make-browser-studio-operations';
import {makeRuntimeValueStore} from './make-runtime-value-store';
@@ -162,7 +162,8 @@ const getTargets = (
propStatuses: PropStatuses,
id: string,
) => {
- const tracks = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const {tracks} = calculate({
sequences: fixture.sequences,
overrideIdsToNodePaths: fixture.mappings,
});
@@ -176,7 +177,7 @@ const getTargets = (
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [],
sequences: fixture.sequences,
- overrideIdsToNodePaths: fixture.mappings,
+ tracks,
propStatuses,
timelineDurationInFrames: 1000,
})!;
@@ -195,6 +196,7 @@ const makeSourceOnlyFixture = ({
parentPlaybackRate: number;
range: string;
}) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const fixture = makeFixture(range, 'child', 120);
// A declared source out-point bounds these unit tests without fetching media.
const runtime = {
@@ -264,7 +266,7 @@ export const App = () => <Video from={0} trimBefore={${trimBefore}} trimAfter={3
effectKeys: [],
});
prepareSource(fixture);
- const tracks = calculateTimeline({
+ const {tracks} = calculate({
sequences: fixture.sequences,
overrideIdsToNodePaths: fixture.mappings,
});
@@ -276,7 +278,7 @@ export const App = () => <Video from={0} trimBefore={${trimBefore}} trimAfter={3
draggedNodePathInfo: mediaTrack.nodePathInfo!,
selectedItems: [],
sequences: fixture.sequences,
- overrideIdsToNodePaths: fixture.mappings,
+ tracks,
propStatuses: fixture.propStatuses,
timelineDurationInFrames: 1000,
trimBeforeOnly: true,
@@ -332,6 +334,7 @@ test.each([
maximumTrim: 60,
},
])('source-only trims preserve the visible range: %j', (testCase) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const {fixture, targets, mediaTrack} = makeSourceOnlyFixture({
...testCase,
range: '[0, 1]',
@@ -382,7 +385,7 @@ test.each([
expect(actual).toEqual(expected);
if (deltaFrames === 0) expect(changes).toEqual([]);
- const updatedTracks = calculateTimeline({
+ const updatedTracks = calculate({
sequences: fixture.sequences.map((sequence) =>
sequence.id === 'parent'
? {
@@ -393,7 +396,7 @@ test.each([
: sequence,
),
overrideIdsToNodePaths: fixture.mappings,
- });
+ }).tracks;
const updated = updatedTracks.find(
(track) => track.sequence.id === 'parent',
)!;
@@ -436,6 +439,7 @@ test.each([
);
test('source-only edits do not replace an animated trimBefore', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const {fixture} = makeSourceOnlyFixture({
trimBefore: 20,
explicitDuration: true,
@@ -460,16 +464,17 @@ export const App = () => {
Internals.getPropStatusesCtx(fixture.propStatuses, nodePath)?.trimBefore
.status,
).toBe('keyframed');
- const track = calculateTimeline({
+ const {tracks} = calculate({
sequences: fixture.sequences,
overrideIdsToNodePaths: fixture.mappings,
- }).find((item) => item.sequence.id === 'parent')!;
+ });
+ const track = tracks.find((item) => item.sequence.id === 'parent')!;
expect(
getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: track.nodePathInfo!,
selectedItems: [],
sequences: fixture.sequences,
- overrideIdsToNodePaths: fixture.mappings,
+ tracks,
propStatuses: fixture.propStatuses,
timelineDurationInFrames: 1000,
trimBeforeOnly: true,
@@ -541,6 +546,7 @@ test.each([
'dev.remotion.remotion.Series.Sequence',
'dev.remotion.transitions.TransitionSeries.Sequence',
])('left-edge trims respect keyframe bounds for %s', (componentIdentity) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
for (const {
range,
deltaFrames,
@@ -610,7 +616,7 @@ test.each([
fixture.sequences[0].controls!.componentIdentity = componentIdentity;
fixture.sequences[1].controls!.videoConfigValues = config(60 + trimBefore);
prepareSource(fixture);
- const tracks = calculateTimeline({
+ const {tracks} = calculate({
sequences: fixture.sequences,
overrideIdsToNodePaths: fixture.mappings,
});
@@ -620,7 +626,7 @@ test.each([
)!.nodePathInfo!,
selectedItems: [],
sequences: fixture.sequences,
- overrideIdsToNodePaths: fixture.mappings,
+ tracks,
propStatuses: fixture.propStatuses,
timelineDurationInFrames: 1000,
trimBeforeOnly: false,
diff --git a/packages/studio/src/test/media-video-fallback-timeline.test.tsx b/packages/studio/src/test/media-video-fallback-timeline.test.tsx
index 1ab92f6cf2..cb230cb22c 100644
--- a/packages/studio/src/test/media-video-fallback-timeline.test.tsx
+++ b/packages/studio/src/test/media-video-fallback-timeline.test.tsx
@@ -1,15 +1,16 @@
import {afterEach, expect, spyOn, test} from 'bun:test';
import {Video} from '@remotion/media';
import {Player, PlayerInternals} from '@remotion/player';
+import {CanvasInternals} from '@remotion/sdk';
import {cleanup, render, waitFor} from '@testing-library/react';
import React from 'react';
import type {TSequence} from 'remotion';
import {shouldShowTrackInTimeline} from '../components/Timeline/should-show-track-in-timeline';
-import {calculateTimeline} from '../helpers/calculate-timeline';
afterEach(cleanup);
test('a trimmed Video keeps one timeline layer when native playback takes over', async () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const isPlayer = Object.getOwnPropertyDescriptor(window, 'remotion_isPlayer');
// Simulate an unavailable browser canvas without starting a browser or fetching media.
const getContext = Object.getOwnPropertyDescriptor(
@@ -52,8 +53,8 @@ test('a trimmed Video keeps one timeline layer when native playback takes over',
await waitFor(() => {
expect(container.querySelector('video')?.src.split('#')[0]).toBe(src);
});
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths: {}})
- .filter((track) => shouldShowTrackInTimeline(track, 720))
+ const tracks = calculate({sequences, overrideIdsToNodePaths: {}})
+ .tracks.filter((track) => shouldShowTrackInTimeline(track, 720))
.map((track) => track.sequence);
expect(tracks).toMatchObject([
{type: 'video', src, duration: 224, startMediaFrom: 191},
diff --git a/packages/studio/src/test/sequenced-timeline.test.ts b/packages/studio/src/test/sequenced-timeline.test.ts
index d631e90466..1aa307a249 100644
--- a/packages/studio/src/test/sequenced-timeline.test.ts
+++ b/packages/studio/src/test/sequenced-timeline.test.ts
@@ -1,6 +1,6 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {TSequence} from 'remotion';
-import {calculateTimeline} from '../helpers/calculate-timeline';
const getStack = () => null;
@@ -33,10 +33,11 @@ const withoutKeyframeDisplayOffset = <
);
test('Should calculate sequences correctly', () => {
- const timeline = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const timeline = calculate({
sequences,
overrideIdsToNodePaths: {},
- });
+ }).tracks;
expect(withoutKeyframeDisplayOffset(timeline)).toEqual([
{
diff --git a/packages/studio/src/test/split-selected-timeline-item.test.ts b/packages/studio/src/test/split-selected-timeline-item.test.ts
index 39acce6973..371eb8d722 100644
--- a/packages/studio/src/test/split-selected-timeline-item.test.ts
+++ b/packages/studio/src/test/split-selected-timeline-item.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {
CanUpdateSequencePropStatus,
PropStatuses,
@@ -230,12 +231,15 @@ test('splitSelectedTimelineItems splits the selected sequence at the playhead',
const splitCalls: {nodePathInfo: SequenceNodePathInfo; splitFrame: number}[] =
[];
+ const calculate = CanvasInternals.createTimelineCalculator();
const result = await splitSelectedTimelineItems({
selections: [{type: 'sequence', nodePathInfo}],
- sequences: [makeSequence()],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [makeSequence()],
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses,
splitFrame: 30,
splitSequences: ({sequences: splitSequences}) => {
@@ -259,16 +263,19 @@ test('splitSelectedTimelineItems batches multiple selected clips', async () => {
const splitCalls: {nodePathInfo: SequenceNodePathInfo; splitFrame: number}[] =
[];
+ const calculate = CanvasInternals.createTimelineCalculator();
const result = await splitSelectedTimelineItems({
selections: [
{type: 'sequence', nodePathInfo: first},
{type: 'sequence', nodePathInfo: second},
],
- sequences: [firstSequence, secondSequence],
- overrideIdsToNodePaths: {
- override: first.sequenceSubscriptionKey,
- 'second-override': second.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [firstSequence, secondSequence],
+ overrideIdsToNodePaths: {
+ override: first.sequenceSubscriptionKey,
+ 'second-override': second.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: undefined,
splitFrame: 30,
splitSequences: ({sequences}) => {
@@ -295,16 +302,19 @@ test('splitSelectedTimelineItems skips ineligible clips and reports the partial
[];
const notifications: string[] = [];
+ const calculate = CanvasInternals.createTimelineCalculator();
const result = await splitSelectedTimelineItems({
selections: [
{type: 'sequence', nodePathInfo: eligible},
{type: 'sequence', nodePathInfo: ineligible},
],
- sequences: [makeSequence(), ineligibleSequence],
- overrideIdsToNodePaths: {
- override: eligible.sequenceSubscriptionKey,
- 'ineligible-override': ineligible.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [makeSequence(), ineligibleSequence],
+ overrideIdsToNodePaths: {
+ override: eligible.sequenceSubscriptionKey,
+ 'ineligible-override': ineligible.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: undefined,
splitFrame: 30,
splitSequences: ({sequences}) => {
diff --git a/packages/studio/src/test/timeline-keyframes.test.ts b/packages/studio/src/test/timeline-keyframes.test.ts
index 8a2f07b17d..a64d92bdb5 100644
--- a/packages/studio/src/test/timeline-keyframes.test.ts
+++ b/packages/studio/src/test/timeline-keyframes.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {
CanUpdateSequencePropStatusKeyframed,
SequencePropsSubscriptionKey,
@@ -13,7 +14,6 @@ import {
getTimelineKeyframes,
} from '../components/Timeline/get-timeline-keyframes';
import {getTimelineKeyframeDragKey} from '../components/Timeline/TimelineKeyframeDragState';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {
getSchemaFieldGroup,
type TimelineTreeNode,
@@ -185,7 +185,8 @@ const makePropStatuses = (
});
test('keyframe display offsets follow the parent sequence context', () => {
- const timeline = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const timeline = calculate({
sequences: [
makeSequence({
id: 'root-style',
@@ -232,7 +233,7 @@ test('keyframe display offsets follow the parent sequence context', () => {
'own-from': makeNodePath('own-from'),
grandchild: makeNodePath('grandchild'),
},
- });
+ }).tracks;
const getOffset = (id: string): number => {
const track = timeline.find((t) => t.sequence.id === id);
@@ -275,8 +276,9 @@ test('keyframe display offsets follow the parent sequence context', () => {
});
test('keyframes retain their source frames across nested rates and trimmed clocks', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePath = makeNodePath('child');
- const timeline = calculateTimeline({
+ const timeline = calculate({
sequences: [
{
...makeSequence({
@@ -310,7 +312,7 @@ test('keyframes retain their source frames across nested rates and trimmed clock
},
],
overrideIdsToNodePaths: {child: nodePath},
- });
+ }).tracks;
const track = timeline.find(
(candidate) => candidate.sequence.id === 'child',
)!;
@@ -355,6 +357,7 @@ test('keyframes retain their source frames across nested rates and trimmed clock
});
test('track lookup survives effect key changes', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const sequences = [
makeSequence({
id: 'sequence',
@@ -371,10 +374,12 @@ test('track lookup survives effect key changes', () => {
const staleNodePath = makeNodePathWithEffectKeys('sequence', [['blur']]);
const track = findTrackForNodePathInfo({
- sequences,
- overrideIdsToNodePaths: {
- sequence: currentNodePath,
- },
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ sequence: currentNodePath,
+ },
+ }).tracks,
nodePathInfo: {
sequenceSubscriptionKey: staleNodePath,
auxiliaryKeys: [],
@@ -388,7 +393,8 @@ test('track lookup survives effect key changes', () => {
});
test('keyframe display offsets account for parent trimBefore', () => {
- const timeline = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const timeline = calculate({
sequences: [
makeSequence({
id: 'parent',
@@ -408,7 +414,7 @@ test('keyframe display offsets account for parent trimBefore', () => {
overrideIdsToNodePaths: {
child: makeNodePath('child'),
},
- });
+ }).tracks;
const child = timeline.find((t) => t.sequence.id === 'child');
expect(child?.keyframeDisplayOffset).toBe(-20);
@@ -436,7 +442,8 @@ test('keyframe display offsets account for parent trimBefore', () => {
});
test('keyframe display offsets respect the useCurrentFrame coordinate space', () => {
- const timeline = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const timeline = calculate({
sequences: [
makeSequence({
id: 'timing-wrapper',
@@ -456,7 +463,7 @@ test('keyframe display offsets respect the useCurrentFrame coordinate space', ()
overrideIdsToNodePaths: {
'controlled-element': makeNodePath('controlled-element'),
},
- });
+ }).tracks;
const controlledElement = timeline.find(
(track) => track.sequence.id === 'controlled-element',
);
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index ce1d634c3b..0a7ae46d36 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -1,4 +1,5 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {RefObject} from 'react';
import {
Internals,
@@ -56,7 +57,6 @@ import {
getSelectedOutlineTransformOriginDragChanges,
getSelectedOutlineTransformOriginLockedAxis,
getSelectedSequenceKeys,
- getSequencesWithSelectableOutlines,
getTransformedSvgViewportPoints,
orderOutlinesForRendering,
selectedOutlineTransformOriginSnapThresholdPx,
@@ -151,7 +151,6 @@ import {
getKeyframesForTimelineEasingDrag,
getTimelineSelectionsAfterEasingKeyframeDrag,
} from '../components/Timeline/use-timeline-keyframe-drag';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {
getConnectedCompositionFrame,
getSequenceDoubleClickAction,
@@ -932,6 +931,7 @@ test('copying a selected effect prop creates an effect prop payload', () => {
});
test('copying selected keyframes preserves their frame deltas', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const schema = {
@@ -973,8 +973,10 @@ test('copying selected keyframes preserves their frame deltas', () => {
segmentIndex: 0,
},
],
- sequences: [makeTimelineSequence({schema, from: 20})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema, from: 20})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({
@@ -992,6 +994,7 @@ test('copying selected keyframes preserves their frame deltas', () => {
});
test('pasting keyframes onto a sequence targets the copied property', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const schema = {
@@ -1031,8 +1034,10 @@ test('pasting keyframes onto a sequence targets the copied property', () => {
easing: [{type: 'linear'}],
},
timelinePosition: 50,
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toMatchObject({
@@ -1048,6 +1053,7 @@ test('pasting keyframes onto a sequence targets the copied property', () => {
});
test('copies a keyframed sequence prop between components with matching schemas', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const sourceNodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'style.rotate'],
@@ -1110,8 +1116,10 @@ test('copies a keyframed sequence prop between components with matching schemas'
key: 'style.rotate',
},
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
});
expect(payload).toMatchObject({
@@ -1129,8 +1137,10 @@ test('copies a keyframed sequence prop between components with matching schemas'
selectedItems: [{type: 'sequence', nodePathInfo: targetNodePathInfo}],
payload,
propStatuses,
- sequences,
- overrideIdsToNodePaths,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
}),
).toMatchObject({
type: 'valid',
@@ -1139,6 +1149,7 @@ test('copies a keyframed sequence prop between components with matching schemas'
});
test('copying selected keyframes requires one property', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const opacityNodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'opacity'],
@@ -1188,14 +1199,17 @@ test('copying selected keyframes requires one property', () => {
{type: 'keyframe', nodePathInfo: opacityNodePathInfo, frame: 10},
{type: 'keyframe', nodePathInfo: otherNodePathInfo, frame: 30},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toBe(null);
});
test('pasting keyframes targets one selected property at the playhead', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const schema = {
@@ -1235,8 +1249,10 @@ test('pasting keyframes targets one selected property at the playhead', () => {
easing: [{type: 'linear'}],
},
timelinePosition: 50,
- sequences: [makeTimelineSequence({schema, from: 20})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema, from: 20})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({
@@ -1257,6 +1273,7 @@ test('pasting keyframes targets one selected property at the playhead', () => {
});
test('pasting keyframes replaces the destination range and preserves easing', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], ['controls', 'opacity']);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const schema = {
@@ -1309,8 +1326,10 @@ test('pasting keyframes replaces the destination range and preserves easing', ()
easing: [copiedEasing],
},
timelinePosition: 50,
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({
@@ -1331,6 +1350,7 @@ test('pasting keyframes replaces the destination range and preserves easing', ()
});
test('pasting a keyframe rejects an incompatible property', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'background'],
@@ -1373,14 +1393,17 @@ test('pasting a keyframe rejects an incompatible property', () => {
easing: [],
},
timelinePosition: 50,
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({type: 'incompatible'} satisfies PasteKeyframeTarget);
});
test('copying a selected sequence easing creates an easing payload', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const opacityNodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'opacity'],
@@ -1428,8 +1451,10 @@ test('copying a selected sequence easing creates an easing payload', () => {
toFrame: 100,
segmentIndex: 0,
},
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({
@@ -1441,6 +1466,7 @@ test('copying a selected sequence easing creates an easing payload', () => {
});
test('copying a selected effect easing creates an easing payload', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const effectPropNodePathInfo = makeNodePathInfo(
['body', 0],
['effects', '0', 'intensity'],
@@ -1492,13 +1518,15 @@ test('copying a selected effect easing creates an easing payload', () => {
toFrame: 100,
segmentIndex: 0,
},
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
}),
).toEqual({
@@ -1510,6 +1538,7 @@ test('copying a selected effect easing creates an easing payload', () => {
});
test('pasting an effect prop targets a matching selected effect', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const effectNodePathInfo = makeNodePathInfo(
['body', 0],
['effects', '1'],
@@ -1560,13 +1589,15 @@ test('pasting an effect prop targets a matching selected effect', () => {
param: {type: 'static', value: 10},
},
propStatuses,
- sequences: [
- makeTimelineSequence({
- schema: {},
- effects: [{schema: effectSchema}, {schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema: {},
+ effects: [{schema: effectSchema}, {schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
}),
).toEqual({
type: 'valid',
@@ -1584,6 +1615,7 @@ test('pasting an effect prop targets a matching selected effect', () => {
});
test('pasting an effect prop targets multiple matching selected effects', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const firstNodePathInfo = makeNodePathInfo(
['body', 0],
['effects', '0'],
@@ -1656,24 +1688,26 @@ test('pasting an effect prop targets multiple matching selected effects', () =>
param: {type: 'static', value: 10},
},
propStatuses,
- sequences: [
- makeTimelineSequence({
- schema: {},
- effects: [{schema: effectSchema}],
- id: 'first',
- overrideId: 'first',
- }),
- makeTimelineSequence({
- schema: {},
- effects: [{schema: effectSchema}],
- id: 'second',
- overrideId: 'second',
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePath,
- second: secondNodePath,
- },
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema: {},
+ effects: [{schema: effectSchema}],
+ id: 'first',
+ overrideId: 'first',
+ }),
+ makeTimelineSequence({
+ schema: {},
+ effects: [{schema: effectSchema}],
+ id: 'second',
+ overrideId: 'second',
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ first: firstNodePath,
+ second: secondNodePath,
+ },
+ }).tracks,
}),
).toEqual({
type: 'valid',
@@ -1699,6 +1733,7 @@ test('pasting an effect prop targets multiple matching selected effects', () =>
});
test('pasting an effect prop requires the same effect type and prop key', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const effectPropNodePathInfo = makeNodePathInfo(
['body', 0],
['effects', '0', 'opacity'],
@@ -1761,13 +1796,15 @@ test('pasting an effect prop requires the same effect type and prop key', () =>
],
payload: basePayload,
propStatuses,
- sequences: [
- makeTimelineSequence({
- schema: {},
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema: {},
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
}),
).toEqual({type: 'prop-mismatch'} satisfies PasteEffectPropTarget);
@@ -1778,18 +1815,21 @@ test('pasting an effect prop requires the same effect type and prop key', () =>
],
payload: basePayload,
propStatuses,
- sequences: [
- makeTimelineSequence({
- schema: {},
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema: {},
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
}),
).toEqual({type: 'effect-type-mismatch'} satisfies PasteEffectPropTarget);
});
test('Timeline duration drag applies the same delta to selected sequences', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -1818,10 +1858,13 @@ test('Timeline duration drag applies the same delta to selected sequences', () =
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
sequences,
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
firstNodePathInfo.sequenceSubscriptionKey,
secondNodePathInfo.sequenceSubscriptionKey,
@@ -1846,6 +1889,7 @@ test('Timeline duration drag applies the same delta to selected sequences', () =
});
test('Timeline duration drag clamps each selected media item to its asset end', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -1876,10 +1920,13 @@ test('Timeline duration drag clamps each selected media item to its asset end',
{type: 'sequence' as const, nodePathInfo: secondNodePathInfo},
],
sequences,
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
firstNodePathInfo.sequenceSubscriptionKey,
secondNodePathInfo.sequenceSubscriptionKey,
@@ -1918,23 +1965,28 @@ test('Timeline duration drag clamps each selected media item to its asset end',
});
test('Timeline duration drag uses the declared duration for negative from values', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ duration: 36,
+ from: -3,
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- duration: 36,
- from: -3,
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
nodePathInfo.sequenceSubscriptionKey,
]),
@@ -1997,6 +2049,7 @@ test.each([
expectedDurationInFrames: 31,
},
])('Timeline duration drag retains one visible frame: $name', (scenario) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
@@ -2019,13 +2072,17 @@ test.each([
sequencePlaybackRate: scenario.childPlaybackRate,
});
const overrideIdsToNodePaths = {child: nodePath};
+ const sequences = [parent, child];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [parent, child],
- overrideIdsToNodePaths,
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
propStatuses: makeDurationPropStatuses([nodePath]),
timelineDurationInFrames: 600,
});
@@ -2041,7 +2098,7 @@ test.each([
},
]);
- const resizedTracks = calculateTimeline({
+ const resizedTracks = calculate({
sequences: [
parent,
{
@@ -2050,7 +2107,7 @@ test.each([
},
],
overrideIdsToNodePaths,
- });
+ }).tracks;
expect(
resizedTracks.find((track) => track.sequence.id === child.id)?.sequence
.duration,
@@ -2058,23 +2115,28 @@ test.each([
});
test('Timeline duration drag clamps to the composition end', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ duration: 40,
+ from: 30,
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- duration: 40,
- from: 30,
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
nodePathInfo.sequenceSubscriptionKey,
]),
@@ -2091,6 +2153,7 @@ test('Timeline duration drag clamps to the composition end', () => {
});
test('Timeline duration drag supports interactive video clips', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const video = makeTimelineSequence({
schema: Internals.baseSchema,
@@ -2099,6 +2162,7 @@ test('Timeline duration drag supports interactive video clips', () => {
});
expect(isTimelineSequenceDurationDraggable(video)).toBe(true);
+ const sequences = [video];
expect(
getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
@@ -2108,10 +2172,13 @@ test('Timeline duration drag supports interactive video clips', () => {
},
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [video],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
nodePathInfo.sequenceSubscriptionKey,
]),
@@ -2134,6 +2201,7 @@ test('Timeline duration drag supports interactive video clips', () => {
});
test('Timeline edge drags edit durationInFrames in the child clock', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const propStatuses: PropStatuses = {
@@ -2150,24 +2218,28 @@ test('Timeline edge drags edit durationInFrames in the child clock', () => {
effects: [],
},
};
+ const sequences = [
+ makeTimelineSequence({
+ schema: Internals.baseSchema,
+ duration: 10,
+ sequencePlaybackRate: 2,
+ currentRuntimeValueDotNotation: {
+ durationInFrames: 20,
+ playbackRate: 2,
+ trimBefore: 4,
+ },
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema: Internals.baseSchema,
- duration: 10,
- sequencePlaybackRate: 2,
- currentRuntimeValueDotNotation: {
- durationInFrames: 20,
- playbackRate: 2,
- trimBefore: 4,
- },
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
timelineDurationInFrames: 1000,
});
@@ -2186,6 +2258,7 @@ test('Timeline edge drags edit durationInFrames in the child clock', () => {
});
test('Left edge trim preserves a recent right edge trim in the child clock', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const sequence = makeTimelineSequence({
@@ -2199,11 +2272,15 @@ test('Left edge trim preserves a recent right edge trim in the child clock', ()
trimBefore: 4,
},
});
+ const sequences = [sequence];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [sequence],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses([nodePath], true, true, [16]),
});
@@ -2220,6 +2297,7 @@ test('Left edge trim preserves a recent right edge trim in the child clock', ()
});
test('Looping timeline items cannot be resized or split', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const loopedSequence = {
...makeTimelineSequence({
@@ -2248,15 +2326,19 @@ test('Looping timeline items cannot be resized or split', () => {
playbackRate: 1,
frozenMediaFrame: null,
} satisfies TSequence;
+ const sequences = [loopedVideo];
const resizeTargets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [selection],
- sequences: [loopedVideo],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
nodePathInfo.sequenceSubscriptionKey,
]),
@@ -2325,9 +2407,18 @@ test('Implicit media can be shortened once its edge reaches the asset end', () =
});
test('Timeline duration drag clamps explicit audio and video to the asset end', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
for (const type of ['audio', 'video'] as const) {
const nodePathInfo = makeNodePathInfo(['body', type], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [
+ makeTimelineSequence({
+ schema: Internals.baseSchema,
+ type,
+ duration: 200,
+ from: -192,
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: {
@@ -2336,15 +2427,11 @@ test('Timeline duration drag clamps explicit audio and video to the asset end',
},
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema: Internals.baseSchema,
- type,
- duration: 200,
- from: -192,
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses: makeDurationPropStatuses([nodePath]),
timelineDurationInFrames: 1000,
});
@@ -2360,8 +2447,17 @@ test('Timeline duration drag clamps explicit audio and video to the asset end',
});
test('An overlong explicit Video can be shortened without snapping', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [
+ makeTimelineSequence({
+ schema: Internals.baseSchema,
+ type: 'video',
+ duration: 300,
+ from: -192,
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: {
@@ -2370,15 +2466,11 @@ test('An overlong explicit Video can be shortened without snapping', () => {
},
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema: Internals.baseSchema,
- type: 'video',
- duration: 300,
- from: -192,
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses: makeDurationPropStatuses([nodePath]),
timelineDurationInFrames: 1000,
});
@@ -2399,6 +2491,7 @@ test('An overlong explicit Video can be shortened without snapping', () => {
});
test('Timeline duration drag trims audio and video without an explicit duration', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
for (const type of ['audio', 'video'] as const) {
const nodePathInfo = makeNodePathInfo(['body', type], []);
const media = makeTimelineSequence({
@@ -2407,6 +2500,7 @@ test('Timeline duration drag trims audio and video without an explicit duration'
duration: Infinity,
});
const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [media];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: {
@@ -2415,10 +2509,13 @@ test('Timeline duration drag trims audio and video without an explicit duration'
},
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [media],
- overrideIdsToNodePaths: {
- override: nodePath,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePath,
+ },
+ }).tracks,
propStatuses: {
[Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
durationDependentKeyframes: null,
@@ -2464,22 +2561,27 @@ test('Timeline duration drag trims audio and video without an explicit duration'
});
test('Timeline duration drag waits for an effective implicit media duration', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [
+ makeTimelineSequence({
+ schema: Internals.baseSchema,
+ type: 'video',
+ duration: Infinity,
+ }),
+ ];
expect(
getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: nodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
selectedSequenceMediaDurationDragLimits: null,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema: Internals.baseSchema,
- type: 'video',
- duration: Infinity,
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses: {
[Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
durationDependentKeyframes: null,
@@ -2553,6 +2655,7 @@ test('Timeline duration drag clamps each selected sequence to one frame', () =>
});
test('TransitionSeries.Sequence resize clamps to adjacent transition durations', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const nodePathInfo = makeNodePathInfo(['body', 2], []);
@@ -2605,7 +2708,10 @@ test('TransitionSeries.Sequence resize clamps to adjacent transition durations',
selectedSequenceMediaDurationDragLimits: null,
selectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
propStatuses,
timelineDurationInFrames: 1000,
});
@@ -2622,7 +2728,10 @@ test('TransitionSeries.Sequence resize clamps to adjacent transition durations',
draggedNodePathInfo: nodePathInfo,
selectedItems,
sequences,
- overrideIdsToNodePaths,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
propStatuses,
});
@@ -2636,6 +2745,7 @@ test('TransitionSeries.Sequence resize clamps to adjacent transition durations',
});
test('Timeline duration drag is blocked if one selected sequence cannot update duration', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -2654,6 +2764,21 @@ test('Timeline duration drag is blocked if one selected sequence cannot update d
effects: [],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'first',
+ overrideId: 'first',
+ duration: 40,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'second',
+ overrideId: 'second',
+ duration: 15,
+ from: 10,
+ }),
+ ];
expect(
getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: firstNodePathInfo,
@@ -2663,25 +2788,14 @@ test('Timeline duration drag is blocked if one selected sequence cannot update d
{type: 'sequence', nodePathInfo: firstNodePathInfo},
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'first',
- overrideId: 'first',
- duration: 40,
- }),
- makeTimelineSequence({
- schema,
- id: 'second',
- overrideId: 'second',
- duration: 15,
- from: 10,
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses,
timelineDurationInFrames: 1000,
}),
@@ -2689,6 +2803,7 @@ test('Timeline duration drag is blocked if one selected sequence cannot update d
});
test('Timeline duration drag is blocked if one selected sequence duration is keyframed', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -2719,6 +2834,21 @@ test('Timeline duration drag is blocked if one selected sequence duration is key
effects: [],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'first',
+ overrideId: 'first',
+ duration: 40,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'second',
+ overrideId: 'second',
+ duration: 15,
+ from: 10,
+ }),
+ ];
expect(
getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: firstNodePathInfo,
@@ -2728,25 +2858,14 @@ test('Timeline duration drag is blocked if one selected sequence duration is key
{type: 'sequence', nodePathInfo: firstNodePathInfo},
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'first',
- overrideId: 'first',
- duration: 40,
- }),
- makeTimelineSequence({
- schema,
- id: 'second',
- overrideId: 'second',
- duration: 15,
- from: 10,
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses,
timelineDurationInFrames: 1000,
}),
@@ -2754,10 +2873,33 @@ test('Timeline duration drag is blocked if one selected sequence duration is key
});
test('Timeline duration drag ignores selection if dragged sequence is not selected', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
const thirdNodePathInfo = makeNodePathInfo(['body', 2], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'first',
+ overrideId: 'first',
+ duration: 40,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'second',
+ overrideId: 'second',
+ duration: 15,
+ from: 10,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'third',
+ overrideId: 'third',
+ duration: 25,
+ from: 20,
+ }),
+ ];
const targets = getTimelineSequenceDurationDragTargets({
draggedNodePathInfo: firstNodePathInfo,
draggedSequenceMediaDurationDragLimits: null,
@@ -2766,33 +2908,15 @@ test('Timeline duration drag ignores selection if dragged sequence is not select
{type: 'sequence', nodePathInfo: secondNodePathInfo},
{type: 'sequence', nodePathInfo: thirdNodePathInfo},
],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'first',
- overrideId: 'first',
- duration: 40,
- }),
- makeTimelineSequence({
- schema,
- id: 'second',
- overrideId: 'second',
- duration: 15,
- from: 10,
- }),
- makeTimelineSequence({
- schema,
- id: 'third',
- overrideId: 'third',
- duration: 25,
- from: 20,
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- third: thirdNodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ third: thirdNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
firstNodePathInfo.sequenceSubscriptionKey,
secondNodePathInfo.sequenceSubscriptionKey,
@@ -2807,36 +2931,41 @@ test('Timeline duration drag ignores selection if dragged sequence is not select
});
test('Timeline left edge drag adjusts from, duration and trimBefore for selected sequences', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'first',
+ overrideId: 'first',
+ duration: 40,
+ from: 5,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'second',
+ overrideId: 'second',
+ duration: 15,
+ from: 10,
+ type: 'image',
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: firstNodePathInfo,
selectedItems: [
{type: 'sequence', nodePathInfo: firstNodePathInfo},
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'first',
- overrideId: 'first',
- duration: 40,
- from: 5,
- }),
- makeTimelineSequence({
- schema,
- id: 'second',
- overrideId: 'second',
- duration: 15,
- from: 10,
- type: 'image',
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses(
[
firstNodePathInfo.sequenceSubscriptionKey,
@@ -2868,6 +2997,7 @@ test.each([
])(
'left edge trimming uses the visible start of a clipped child: %j',
({durationInFrames, from, parentRate, childRate}) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
const child = makeTimelineSequence({
@@ -2898,7 +3028,10 @@ test.each([
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
sequences,
- overrideIdsToNodePaths,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses(
[nodePathInfo.sequenceSubscriptionKey],
true,
@@ -2924,7 +3057,7 @@ test.each([
durationInFrames: (129 - 6 * parentRate) * childRate,
trimBefore: (369 + 6 * parentRate) * childRate,
});
- const tracks = calculateTimeline({
+ const {tracks} = calculate({
sequences: [
sequences[0],
{
@@ -2944,25 +3077,30 @@ test.each([
);
test('TransitionSeries.Sequence self-trim changes its duration and trimBefore', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const subscriptionKey = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ componentIdentity: 'dev.remotion.transitions.TransitionSeries.Sequence',
+ duration: 40,
+ from: 12,
+ isInsideSeries: true,
+ trimBefore: 3,
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- componentIdentity: 'dev.remotion.transitions.TransitionSeries.Sequence',
- duration: 40,
- from: 12,
- isInsideSeries: true,
- trimBefore: 3,
- }),
- ],
- overrideIdsToNodePaths: {
- override: subscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: subscriptionKey,
+ },
+ }).tracks,
propStatuses: {
[Internals.makeSequencePropsSubscriptionKey(subscriptionKey)]: {
durationDependentKeyframes: null,
@@ -3003,25 +3141,30 @@ test('TransitionSeries.Sequence self-trim changes its duration and trimBefore',
});
test('Series.Sequence self-trim changes its duration and trimBefore', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
const subscriptionKey = nodePathInfo.sequenceSubscriptionKey;
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ componentIdentity: 'dev.remotion.remotion.Series.Sequence',
+ duration: 40,
+ from: 12,
+ isInsideSeries: true,
+ trimBefore: 3,
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- componentIdentity: 'dev.remotion.remotion.Series.Sequence',
- duration: 40,
- from: 12,
- isInsideSeries: true,
- trimBefore: 3,
- }),
- ],
- overrideIdsToNodePaths: {
- override: subscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: subscriptionKey,
+ },
+ }).tracks,
propStatuses: {
[Internals.makeSequencePropsSubscriptionKey(subscriptionKey)]: {
durationDependentKeyframes: null,
@@ -3092,6 +3235,7 @@ test('Timeline left edge drag clamps trimBefore to the visible range', () => {
});
test('Timeline left edge drag scales media trimBefore by the runtime playbackRate', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const cases = [
{componentIdentity: 'dev.remotion.media.Video', type: 'video'},
@@ -3105,20 +3249,24 @@ test('Timeline left edge drag scales media trimBefore by the runtime playbackRat
for (const [index, testCase] of cases.entries()) {
const nodePathInfo = makeNodePathInfo(['body', index], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ componentIdentity: testCase.componentIdentity,
+ currentRuntimeValueDotNotation: {playbackRate: 2},
+ type: testCase.type,
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- componentIdentity: testCase.componentIdentity,
- currentRuntimeValueDotNotation: {playbackRate: 2},
- type: testCase.type,
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses(
[nodePathInfo.sequenceSubscriptionKey],
true,
@@ -3176,23 +3324,28 @@ test('Timeline left edge drag reaches exact zero with fractional playback rates'
});
test('Timeline left edge drag adjusts and clamps media trimBefore', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ duration: 40,
+ from: 12,
+ startMediaFrom: 8,
+ type: 'video',
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- duration: 40,
- from: 12,
- startMediaFrom: 8,
- type: 'video',
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses(
[nodePathInfo.sequenceSubscriptionKey],
true,
@@ -3213,23 +3366,28 @@ test('Timeline left edge drag adjusts and clamps media trimBefore', () => {
});
test('Timeline left edge drag is blocked without timeline range props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ duration: 40,
+ from: 0,
+ startMediaFrom: 8,
+ type: 'video',
+ }),
+ ];
const targets = getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- duration: 40,
- from: 0,
- startMediaFrom: 8,
- type: 'video',
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses(
[nodePathInfo.sequenceSubscriptionKey],
true,
@@ -3241,22 +3399,27 @@ test('Timeline left edge drag is blocked without timeline range props', () => {
});
test('Timeline left edge drag is blocked if trimBefore cannot update', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const nodePathInfo = makeNodePathInfo(['body', 0], []);
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ type: 'audio',
+ }),
+ ];
expect(
getTimelineSequenceLeftEdgeDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- type: 'audio',
- }),
- ],
- overrideIdsToNodePaths: {
- override: nodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths: {
+ override: nodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeLeftEdgePropStatuses([
nodePathInfo.sequenceSubscriptionKey,
]),
@@ -3265,6 +3428,7 @@ test('Timeline left edge drag is blocked if trimBefore cannot update', () => {
});
test('Timeline from drag applies the same delta to selected sequences', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -3285,6 +3449,10 @@ test('Timeline from drag applies the same delta to selected sequences', () => {
type: 'audio',
}),
];
+ const overrideIdsToNodePaths = {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ };
const targets = getTimelineSequenceFromDragTargets({
draggedNodePathInfo: firstNodePathInfo,
selectedItems: [
@@ -3292,10 +3460,11 @@ test('Timeline from drag applies the same delta to selected sequences', () => {
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
sequences,
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses: makeFromPropStatuses([
firstNodePathInfo.sequenceSubscriptionKey,
secondNodePathInfo.sequenceSubscriptionKey,
@@ -3328,6 +3497,7 @@ test('Timeline from drag applies the same delta to selected sequences', () => {
});
test('Timeline from drag only moves selected sequences without selected ancestors', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const parentNodePathInfo = makeNodePathInfo(['body', 0], []);
const childNodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
@@ -3354,6 +3524,11 @@ test('Timeline from drag only moves selected sequences without selected ancestor
type: 'video',
}),
];
+ const overrideIdsToNodePaths = {
+ parent: parentNodePathInfo.sequenceSubscriptionKey,
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ video: videoNodePathInfo.sequenceSubscriptionKey,
+ };
const targets = getTimelineSequenceFromDragTargets({
draggedNodePathInfo: parentNodePathInfo,
selectedItems: [
@@ -3362,11 +3537,11 @@ test('Timeline from drag only moves selected sequences without selected ancestor
{type: 'sequence', nodePathInfo: videoNodePathInfo},
],
sequences,
- overrideIdsToNodePaths: {
- parent: parentNodePathInfo.sequenceSubscriptionKey,
- child: childNodePathInfo.sequenceSubscriptionKey,
- video: videoNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses: makeFromPropStatuses([
parentNodePathInfo.sequenceSubscriptionKey,
childNodePathInfo.sequenceSubscriptionKey,
@@ -3384,6 +3559,7 @@ test('Timeline from drag only moves selected sequences without selected ancestor
});
test('Timeline from drag moves all owned sequence keyframes by the same delta', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
'style.translate': {type: 'translate', default: '0px 0px'},
opacity: {type: 'number', default: 1, hiddenFromList: false},
@@ -3429,17 +3605,23 @@ test('Timeline from drag moves all owned sequence keyframes by the same delta',
},
effects: [],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ duration: 40,
+ from: 0,
+ }),
+ ];
+ const overrideIdsToNodePaths = {override: nodePath};
const targets = getTimelineSequenceFromDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- duration: 40,
- from: 0,
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses,
});
@@ -3461,6 +3643,7 @@ test('Timeline from drag moves all owned sequence keyframes by the same delta',
});
test('Timeline from drag moves only descendant keyframes tied to an outer frame clock', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const parentNodePathInfo = makeNodePathInfo(['body', 0], []);
const parentNodePath = parentNodePathInfo.sequenceSubscriptionKey;
const outerFrameDescendantNodePath = makeNodePathInfo(
@@ -3511,33 +3694,39 @@ test('Timeline from drag moves only descendant keyframes tied to an outer frame
effects: [],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema: {},
+ id: 'parent',
+ overrideId: 'parent-override',
+ }),
+ makeTimelineSequence({
+ schema: {color: {type: 'color', default: '#000000'}},
+ id: 'outer-frame-descendant',
+ overrideId: 'outer-frame-descendant-override',
+ parentId: 'parent',
+ }),
+ makeTimelineSequence({
+ schema: {color: {type: 'color', default: '#000000'}},
+ id: 'local-frame-descendant',
+ overrideId: 'local-frame-descendant-override',
+ parentId: 'parent',
+ }),
+ ];
+ const overrideIdsToNodePaths = {
+ 'parent-override': parentNodePath,
+ 'outer-frame-descendant-override': outerFrameDescendantNodePath,
+ 'local-frame-descendant-override': localFrameDescendantNodePath,
+ };
const targets = getTimelineSequenceFromDragTargets({
draggedNodePathInfo: parentNodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo: parentNodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema: {},
- id: 'parent',
- overrideId: 'parent-override',
- }),
- makeTimelineSequence({
- schema: {color: {type: 'color', default: '#000000'}},
- id: 'outer-frame-descendant',
- overrideId: 'outer-frame-descendant-override',
- parentId: 'parent',
- }),
- makeTimelineSequence({
- schema: {color: {type: 'color', default: '#000000'}},
- id: 'local-frame-descendant',
- overrideId: 'local-frame-descendant-override',
- parentId: 'parent',
- }),
- ],
- overrideIdsToNodePaths: {
- 'parent-override': parentNodePath,
- 'outer-frame-descendant-override': outerFrameDescendantNodePath,
- 'local-frame-descendant-override': localFrameDescendantNodePath,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses,
});
@@ -3569,6 +3758,7 @@ test('Timeline from drag moves only descendant keyframes tied to an outer frame
});
test('Timeline from drag moves owned effect keyframes by the same delta', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
intensity: {type: 'number', default: 0, hiddenFromList: false},
@@ -3612,16 +3802,22 @@ test('Timeline from drag moves owned effect keyframes by the same delta', () =>
},
],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ];
+ const overrideIdsToNodePaths = {override: nodePath};
const targets = getTimelineSequenceFromDragTargets({
draggedNodePathInfo: nodePathInfo,
selectedItems: [{type: 'sequence', nodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses,
});
@@ -3723,31 +3919,38 @@ test('Timeline from drag does not snap nested sequences to the timeline start',
});
test('Timeline from drag saves relative from for nested sequences', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const childNodePathInfo = makeNodePathInfo(['body', 1], []);
- const targets = getTimelineSequenceFromDragTargets({
- draggedNodePathInfo: childNodePathInfo,
- selectedItems: [{type: 'sequence', nodePathInfo: childNodePathInfo}],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'parent',
- overrideId: 'parent',
- duration: 100,
- from: 50,
- }),
- makeTimelineSequence({
- schema,
- id: 'child',
- overrideId: 'child',
- duration: 20,
- from: 10,
- parentId: 'parent',
- }),
- ],
- overrideIdsToNodePaths: {
- child: childNodePathInfo.sequenceSubscriptionKey,
- },
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'parent',
+ overrideId: 'parent',
+ duration: 100,
+ from: 50,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'child',
+ overrideId: 'child',
+ duration: 20,
+ from: 10,
+ parentId: 'parent',
+ }),
+ ];
+ const overrideIdsToNodePaths = {
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ };
+ const targets = getTimelineSequenceFromDragTargets({
+ draggedNodePathInfo: childNodePathInfo,
+ selectedItems: [{type: 'sequence', nodePathInfo: childNodePathInfo}],
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses: makeFromPropStatuses([
childNodePathInfo.sequenceSubscriptionKey,
]),
@@ -3763,6 +3966,7 @@ test('Timeline from drag saves relative from for nested sequences', () => {
});
test('Timeline from drag is blocked if one selected sequence cannot update from', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const firstNodePathInfo = makeNodePathInfo(['body', 0], []);
const secondNodePathInfo = makeNodePathInfo(['body', 1], []);
@@ -3781,6 +3985,25 @@ test('Timeline from drag is blocked if one selected sequence cannot update from'
effects: [],
};
+ const sequences = [
+ makeTimelineSequence({
+ schema,
+ id: 'first',
+ overrideId: 'first',
+ duration: 40,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'second',
+ overrideId: 'second',
+ duration: 15,
+ from: 10,
+ }),
+ ];
+ const overrideIdsToNodePaths = {
+ first: firstNodePathInfo.sequenceSubscriptionKey,
+ second: secondNodePathInfo.sequenceSubscriptionKey,
+ };
expect(
getTimelineSequenceFromDragTargets({
draggedNodePathInfo: firstNodePathInfo,
@@ -3788,25 +4011,12 @@ test('Timeline from drag is blocked if one selected sequence cannot update from'
{type: 'sequence', nodePathInfo: firstNodePathInfo},
{type: 'sequence', nodePathInfo: secondNodePathInfo},
],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'first',
- overrideId: 'first',
- duration: 40,
- }),
- makeTimelineSequence({
- schema,
- id: 'second',
- overrideId: 'second',
- duration: 15,
- from: 10,
- }),
- ],
- overrideIdsToNodePaths: {
- first: firstNodePathInfo.sequenceSubscriptionKey,
- second: secondNodePathInfo.sequenceSubscriptionKey,
- },
+ sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
+ overrideIdsToNodePaths,
propStatuses,
}),
).toBe(null);
@@ -4035,31 +4245,35 @@ test('Connected composition double-click respects frozen frames', () => {
});
test('Canvas outline hit targets render nested sequences above parents', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const refForOutline = {current: null};
const parentNodePathInfo = makeNodePathInfo(['body', 0], []);
const childNodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
- const outlines = getSequencesWithSelectableOutlines({
+ const outlines = CanvasInternals.getCanvasSelectableOutlines({
timelinePosition: 0,
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'parent',
- overrideId: 'parent',
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'child',
- overrideId: 'child',
- parentId: 'parent',
- refForOutline,
- }),
- ],
- overrideIdsToNodePaths: {
- parent: parentNodePathInfo.sequenceSubscriptionKey,
- child: childNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ id: 'parent',
+ overrideId: 'parent',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'child',
+ overrideId: 'child',
+ parentId: 'parent',
+ refForOutline,
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ parent: parentNodePathInfo.sequenceSubscriptionKey,
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
+ resolveSequenceNodePathInfo: null,
});
expect(outlines.map((outline) => outline.key)).toEqual([
@@ -4069,6 +4283,7 @@ test('Canvas outline hit targets render nested sequences above parents', () => {
});
test('Canvas outlines exclude descendants of connected compositions', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const ConnectedChild = () => null;
const schema = {} satisfies InteractivitySchema;
const refForOutline = {current: null};
@@ -4082,44 +4297,47 @@ test('Canvas outlines exclude descendants of connected compositions', () => {
const connectedComposition = {
componentFromProps: ConnectedChild,
} as unknown as _InternalTypes['AnyComposition'];
- const outlines = getSequencesWithSelectableOutlines({
+ const outlines = CanvasInternals.getCanvasSelectableOutlines({
timelinePosition: 0,
- compositions: [connectedComposition],
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'connected',
- overrideId: 'connected',
- refForOutline,
- singleChildComponent: ConnectedChild,
- }),
- makeTimelineSequence({
- schema,
- id: 'child',
- overrideId: 'child',
- parentId: 'connected',
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'grandchild',
- overrideId: 'grandchild',
- parentId: 'child',
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'sibling',
- overrideId: 'sibling',
- refForOutline,
- }),
- ],
- overrideIdsToNodePaths: {
- connected: connectedNodePathInfo.sequenceSubscriptionKey,
- child: childNodePathInfo.sequenceSubscriptionKey,
- grandchild: grandchildNodePathInfo.sequenceSubscriptionKey,
- sibling: siblingNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ compositions: [connectedComposition],
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ id: 'connected',
+ overrideId: 'connected',
+ refForOutline,
+ singleChildComponent: ConnectedChild,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'child',
+ overrideId: 'child',
+ parentId: 'connected',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'grandchild',
+ overrideId: 'grandchild',
+ parentId: 'child',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'sibling',
+ overrideId: 'sibling',
+ refForOutline,
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ connected: connectedNodePathInfo.sequenceSubscriptionKey,
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ grandchild: grandchildNodePathInfo.sequenceSubscriptionKey,
+ sibling: siblingNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
+ resolveSequenceNodePathInfo: null,
});
expect(outlines.map((outline) => outline.key)).toEqual([
@@ -4710,40 +4928,44 @@ test('Canvas outline rendering follows hidden intermediate ancestors', () => {
});
test('Canvas outline hit targets exclude sequences hidden from the timeline', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const refForOutline = {current: null};
const hiddenNodePathInfo = makeNodePathInfo(['body', 0], []);
const visibleNodePathInfo = makeNodePathInfo(['body', 1], []);
const childNodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
- const outlines = getSequencesWithSelectableOutlines({
+ const outlines = CanvasInternals.getCanvasSelectableOutlines({
timelinePosition: 0,
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'hidden',
- overrideId: 'hidden',
- refForOutline,
- showInTimeline: false,
- }),
- makeTimelineSequence({
- schema,
- id: 'visible',
- overrideId: 'visible',
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'child',
- overrideId: 'child',
- parentId: 'hidden',
- refForOutline,
- }),
- ],
- overrideIdsToNodePaths: {
- hidden: hiddenNodePathInfo.sequenceSubscriptionKey,
- visible: visibleNodePathInfo.sequenceSubscriptionKey,
- child: childNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ id: 'hidden',
+ overrideId: 'hidden',
+ refForOutline,
+ showInTimeline: false,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'visible',
+ overrideId: 'visible',
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'child',
+ overrideId: 'child',
+ parentId: 'hidden',
+ refForOutline,
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ hidden: hiddenNodePathInfo.sequenceSubscriptionKey,
+ visible: visibleNodePathInfo.sequenceSubscriptionKey,
+ child: childNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
+ resolveSequenceNodePathInfo: null,
});
expect(outlines.map((outline) => outline.key).sort()).toEqual(
@@ -4755,46 +4977,50 @@ test('Canvas outline hit targets exclude sequences hidden from the timeline', ()
});
test('Canvas outline hit targets exclude premounted and postmounted sequences', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const refForOutline = {current: null};
const premountedNodePathInfo = makeNodePathInfo(['body', 0], []);
const activeNodePathInfo = makeNodePathInfo(['body', 1], []);
const postmountedNodePathInfo = makeNodePathInfo(['body', 2], []);
- const outlines = getSequencesWithSelectableOutlines({
+ const outlines = CanvasInternals.getCanvasSelectableOutlines({
timelinePosition: 10,
- sequences: [
- makeTimelineSequence({
- schema,
- id: 'premounted',
- overrideId: 'premounted',
- from: 20,
- duration: 10,
- premountDisplay: 10,
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'active',
- overrideId: 'active',
- from: 10,
- duration: 10,
- refForOutline,
- }),
- makeTimelineSequence({
- schema,
- id: 'postmounted',
- overrideId: 'postmounted',
- from: 0,
- duration: 10,
- postmountDisplay: 10,
- refForOutline,
- }),
- ],
- overrideIdsToNodePaths: {
- premounted: premountedNodePathInfo.sequenceSubscriptionKey,
- active: activeNodePathInfo.sequenceSubscriptionKey,
- postmounted: postmountedNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ id: 'premounted',
+ overrideId: 'premounted',
+ from: 20,
+ duration: 10,
+ premountDisplay: 10,
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'active',
+ overrideId: 'active',
+ from: 10,
+ duration: 10,
+ refForOutline,
+ }),
+ makeTimelineSequence({
+ schema,
+ id: 'postmounted',
+ overrideId: 'postmounted',
+ from: 0,
+ duration: 10,
+ postmountDisplay: 10,
+ refForOutline,
+ }),
+ ],
+ overrideIdsToNodePaths: {
+ premounted: premountedNodePathInfo.sequenceSubscriptionKey,
+ active: activeNodePathInfo.sequenceSubscriptionKey,
+ postmounted: postmountedNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
+ resolveSequenceNodePathInfo: null,
});
expect(outlines.map((outline) => outline.key)).toEqual([
@@ -6772,6 +6998,7 @@ test('Cmd+D duplicates selected timeline sequence and effect rows', () => {
});
test('Backspace reset targets multiple selected sequence props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
'style.rotate': {type: 'rotation-css', default: '0deg'},
@@ -6818,8 +7045,10 @@ test('Backspace reset targets multiple selected sequence props', () => {
key: 'style.rotate',
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -6831,6 +7060,7 @@ test('Backspace reset targets multiple selected sequence props', () => {
});
test('Backspace reset targets stroke with the SVG default', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
stroke: {type: 'color', default: 'none'},
} satisfies InteractivitySchema;
@@ -6862,8 +7092,10 @@ test('Backspace reset targets stroke with the SVG default', () => {
key: 'stroke',
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -6881,6 +7113,7 @@ test('Backspace reset targets stroke with the SVG default', () => {
});
test('Backspace reset targets border radius with the CSS default', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const radiusNodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'style.borderRadius'],
@@ -6909,10 +7142,12 @@ test('Backspace reset targets border radius with the CSS default', () => {
key: 'style.borderRadius',
},
],
- sequences: [
- makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -6930,6 +7165,7 @@ test('Backspace reset targets border radius with the CSS default', () => {
});
test('Backspace reset targets selected keyframed sequence props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -6969,8 +7205,10 @@ test('Backspace reset targets selected keyframed sequence props', () => {
key: 'opacity',
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -6988,6 +7226,7 @@ test('Backspace reset targets selected keyframed sequence props', () => {
});
test('Backspace reset skips selected computed sequence props with defaults', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
'style.scale': {type: 'scale', default: 1, max: 100},
} satisfies InteractivitySchema;
@@ -7017,8 +7256,10 @@ test('Backspace reset skips selected computed sequence props with defaults', ()
key: 'style.scale',
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -7026,6 +7267,7 @@ test('Backspace reset skips selected computed sequence props with defaults', ()
});
test('Backspace reset targets flattened built-in keyframed sequence style props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const opacityNodePathInfo = makeNodePathInfo(
['body', 0],
['controls', 'style.opacity'],
@@ -7062,10 +7304,12 @@ test('Backspace reset targets flattened built-in keyframed sequence style props'
key: 'style.opacity',
},
],
- sequences: [
- makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -7083,6 +7327,7 @@ test('Backspace reset targets flattened built-in keyframed sequence style props'
});
test('Backspace reset skips keyframed sequence props without defaults', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: undefined, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -7122,8 +7367,10 @@ test('Backspace reset skips keyframed sequence props without defaults', () => {
key: 'opacity',
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -7931,6 +8178,7 @@ test('Selected outline scale edge cursors follow rotated outlines', () => {
});
test('Backspace reset targets selected effect props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
intensity: {type: 'number', default: 0, hiddenFromList: false},
@@ -7972,13 +8220,15 @@ test('Backspace reset targets selected effect props', () => {
key: 'intensity',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -7997,6 +8247,7 @@ test('Backspace reset targets selected effect props', () => {
});
test('Backspace reset targets active enum variant effect props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
colorMode: {
@@ -8055,13 +8306,15 @@ test('Backspace reset targets active enum variant effect props', () => {
key: 'dotColor',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -8080,6 +8333,7 @@ test('Backspace reset targets active enum variant effect props', () => {
});
test('Backspace reset targets selected static blur radius with default', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
radius: {type: 'number', default: 40, hiddenFromList: false},
@@ -8121,13 +8375,15 @@ test('Backspace reset targets selected static blur radius with default', () => {
key: 'radius',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -8146,6 +8402,7 @@ test('Backspace reset targets selected static blur radius with default', () => {
});
test('Backspace reset targets selected keyframed effect props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
intensity: {type: 'number', default: 0, hiddenFromList: false},
@@ -8195,13 +8452,15 @@ test('Backspace reset targets selected keyframed effect props', () => {
key: 'intensity',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -8220,6 +8479,7 @@ test('Backspace reset targets selected keyframed effect props', () => {
});
test('Backspace reset skips keyframed effect props without defaults', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {} satisfies InteractivitySchema;
const effectSchema = {
intensity: {type: 'number', default: undefined, hiddenFromList: false},
@@ -8269,13 +8529,15 @@ test('Backspace reset skips keyframed effect props without defaults', () => {
key: 'intensity',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -8283,6 +8545,7 @@ test('Backspace reset skips keyframed effect props without defaults', () => {
});
test('Backspace reset targets mixed selected sequence and effect props', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -8341,13 +8604,15 @@ test('Backspace reset targets mixed selected sequence and effect props', () => {
key: 'intensity',
},
],
- sequences: [
- makeTimelineSequence({
- schema,
- effects: [{schema: effectSchema}],
- }),
- ],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [
+ makeTimelineSequence({
+ schema,
+ effects: [{schema: effectSchema}],
+ }),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
propStatuses,
});
@@ -8363,6 +8628,7 @@ test('Backspace reset targets mixed selected sequence and effect props', () => {
});
test('Backspace reset ignores incompatible mixed prop selections', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -8385,10 +8651,12 @@ test('Backspace reset ignores incompatible mixed prop selections', () => {
frame: 12,
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {
- override: opacityNodePathInfo.sequenceSubscriptionKey,
- },
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {
+ override: opacityNodePathInfo.sequenceSubscriptionKey,
+ },
+ }).tracks,
propStatuses: makeDurationPropStatuses([
opacityNodePathInfo.sequenceSubscriptionKey,
]),
@@ -8411,8 +8679,7 @@ test('Deleting unsupported mixed timeline selection types returns null', () => {
i: 0,
},
],
- sequences: [],
- overrideIdsToNodePaths: {},
+ tracks: [],
setPropStatuses: () => undefined,
clientId: 'client',
confirm,
@@ -8544,6 +8811,7 @@ test('Deleting keyframes across properties selects each affected property once',
});
test('Deleting selected keyframes ignores selected easings', async () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -8584,8 +8852,10 @@ test('Deleting selected keyframes ignores selected easings', async () => {
segmentIndex: 0,
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
setPropStatuses: () => undefined,
clientId: 'client',
confirm: () => Promise.resolve(true),
@@ -8619,6 +8889,7 @@ test('Deleting selected keyframes ignores selected easings', async () => {
});
test('Deleting all selected keyframes preserves the value at the playhead', async () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},
} satisfies InteractivitySchema;
@@ -8679,8 +8950,10 @@ test('Deleting all selected keyframes preserves the value at the playhead', asyn
frame: 10,
},
],
- sequences: [makeTimelineSequence({schema})],
- overrideIdsToNodePaths: {override: nodePath},
+ tracks: calculate({
+ sequences: [makeTimelineSequence({schema})],
+ overrideIdsToNodePaths: {override: nodePath},
+ }).tracks,
setPropStatuses: () => undefined,
clientId: 'client',
confirm: () => Promise.resolve(true),
@@ -9387,6 +9660,7 @@ test.each([
expectedFrom: 50,
},
])('Timeline moves preserve existing ancestor clipping: $name', (scenario) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0, 'children', 0], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const parent = makeTimelineSequence({
@@ -9408,7 +9682,7 @@ test.each([
const sequences = [parent, child];
const overrideIdsToNodePaths = {child: nodePath};
const propStatuses = makeFromPropStatuses([nodePath]);
- const tracks = calculateTimeline({sequences, overrideIdsToNodePaths});
+ const {tracks} = calculate({sequences, overrideIdsToNodePaths});
const limits = getTimelineSequenceTimingLimits({
track: tracks.find((t) => t.sequence.id === child.id)!,
tracks,
@@ -9427,6 +9701,10 @@ test.each([
draggedNodePathInfo: nodePathInfo,
selectedItems: [],
sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
overrideIdsToNodePaths,
propStatuses,
});
@@ -9443,10 +9721,10 @@ test.each([
deltaFrames,
});
expect(changes.map((c) => c.value)).toEqual([scenario.expectedFrom]);
- const movedTracks = calculateTimeline({
+ const movedTracks = calculate({
sequences: [parent, {...child, from: Number(changes[0].value)}],
overrideIdsToNodePaths,
- });
+ }).tracks;
expect(
movedTracks.find((t) => t.sequence.id === child.id)!.sequence.duration,
).toBeGreaterThanOrEqual(1);
@@ -9459,6 +9737,7 @@ test.each([
])(
'Timeline moves stop at Track neighbours after timing edits: %j',
({parentPlaybackRate, media}) => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const nodePathInfo = makeNodePathInfo(['body', 0, 'children', 1], []);
const nodePath = nodePathInfo.sequenceSubscriptionKey;
const parent = makeTimelineSequence({
@@ -9529,6 +9808,10 @@ test.each([
draggedNodePathInfo: nodePathInfo,
selectedItems: [],
sequences,
+ tracks: calculate({
+ sequences,
+ overrideIdsToNodePaths,
+ }).tracks,
overrideIdsToNodePaths,
propStatuses,
});
@@ -9549,7 +9832,7 @@ test.each([
deltaFrames,
});
expect(changes.map((c) => c.value)).toEqual([expectedFrom]);
- const movedTracks = calculateTimeline({
+ const movedTracks = calculate({
sequences: [
parent,
previous,
@@ -9557,7 +9840,7 @@ test.each([
next,
],
overrideIdsToNodePaths,
- });
+ }).tracks;
const moved = movedTracks.find(
(t) => t.sequence.id === child.id,
)!.sequence;
diff --git a/packages/studio/src/test/timeline-video-info.test.ts b/packages/studio/src/test/timeline-video-info.test.ts
index 95a9fd0c70..b595edf003 100644
--- a/packages/studio/src/test/timeline-video-info.test.ts
+++ b/packages/studio/src/test/timeline-video-info.test.ts
@@ -1,4 +1,5 @@
import {afterEach, expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import {
getLoopDisplaySegments,
sliceVisibleWaveformPeaks,
@@ -19,7 +20,6 @@ import {
} from '../components/Timeline/timeline-asset-link';
import {getTimelineVideoFilmstripTimes} from '../components/Timeline/timeline-video-filmstrip-times';
import {toFileToken} from '../components/Timeline/TimelineAssetField';
-import {calculateTimeline} from '../helpers/calculate-timeline';
import {isVideoWithLastFrameHold} from '../helpers/is-video-with-last-frame-hold';
import {makeRuntimeValueStore} from './make-runtime-value-store';
@@ -356,6 +356,7 @@ test('remote asset URLs split before the filename for middle ellipsis', () => {
});
test('filmstrips and waveform peaks follow nested sequence rates and trims', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const outer: TSequence = {
controls: null,
displayName: 'outer',
@@ -404,10 +405,10 @@ test('filmstrips and waveform peaks follow nested sequence rates and trims', ()
frozenMediaFrame: null,
muted: false,
};
- const track = calculateTimeline({
+ const track = calculate({
sequences: [outer, inner, media],
overrideIdsToNodePaths: {},
- }).find((candidate) => candidate.sequence.id === 'media')!;
+ }).tracks.find((candidate) => candidate.sequence.id === 'media')!;
if (track.sequence.type !== 'video') throw new Error('Expected video');
const startFrame = getTimelineMediaStartFrame({
startMediaFrom: track.sequence.startMediaFrom,
@@ -499,7 +500,7 @@ test('filmstrips and waveform peaks follow nested sequence rates and trims', ()
duration: cycle + 12,
loopDisplay: undefined,
};
- const loopTrack = calculateTimeline({
+ const loopTrack = calculate({
sequences:
iteration === null
? [{...trimmedParent, duration: parentDuration}, loopingVideo]
@@ -510,7 +511,7 @@ test('filmstrips and waveform peaks follow nested sequence rates and trims', ()
loopingVideo,
],
overrideIdsToNodePaths: {},
- }).find((candidate) => candidate.sequence.id === 'media')!;
+ }).tracks.find((candidate) => candidate.sequence.id === 'media')!;
if (loopTrack.sequence.type !== 'video') throw new Error('Expected video');
const {sequence: loopedMedia} = loopTrack;
const {loopDisplay} = loopedMedia;
diff --git a/packages/studio/src/test/timeline.test.ts b/packages/studio/src/test/timeline.test.ts
index 93a1e7e3a3..0291c319a7 100644
--- a/packages/studio/src/test/timeline.test.ts
+++ b/packages/studio/src/test/timeline.test.ts
@@ -1,7 +1,7 @@
import {expect, test} from 'bun:test';
+import {CanvasInternals} from '@remotion/sdk';
import type {_InternalTypes, TSequence} from 'remotion';
import {getTimelineMediaStartFrame} from '../components/Timeline/get-timeline-media-start-frame';
-import {calculateTimeline} from '../helpers/calculate-timeline';
const getStack = () => null;
@@ -34,15 +34,17 @@ const withoutKeyframeDisplayOffset = <
);
test('Should calculate timeline with no sequences', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [],
- });
+ }).tracks;
expect(calculated).toEqual([]);
});
test('Should calculate a basic timeline', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -69,7 +71,7 @@ test('Should calculate a basic timeline', () => {
frozenFrame: null,
},
],
- });
+ }).tracks;
expect(withoutKeyframeDisplayOffset(calculated)).toEqual([
{
nodePathInfo: null,
@@ -104,7 +106,8 @@ test('Should calculate a basic timeline', () => {
});
test('Should follow order of nesting', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -154,7 +157,7 @@ test('Should follow order of nesting', () => {
frozenFrame: null,
},
],
- });
+ }).tracks;
expect(withoutKeyframeDisplayOffset(calculated)).toEqual([
{
nodePathInfo: null,
@@ -218,7 +221,8 @@ test('Should follow order of nesting', () => {
});
test('Should inherit loop display from parent for media tracks', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -278,7 +282,7 @@ test('Should inherit loop display from parent for media tracks', () => {
frozenFrame: null,
},
],
- });
+ }).tracks;
expect(calculated[1].sequence.loopDisplay).toEqual({
durationInFrames: 100,
@@ -290,7 +294,8 @@ test('Should inherit loop display from parent for media tracks', () => {
});
test('Should calculate sequence frame offset for negative from values', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -317,7 +322,7 @@ test('Should calculate sequence frame offset for negative from values', () => {
frozenFrame: null,
},
],
- });
+ }).tracks;
expect(calculated[0].sequence.from).toBe(0);
expect(calculated[0].sequenceFrameOffset).toBe(37);
@@ -325,7 +330,8 @@ test('Should calculate sequence frame offset for negative from values', () => {
});
test('Should calculate sequence frame offset for trimBefore values', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -352,14 +358,15 @@ test('Should calculate sequence frame offset for trimBefore values', () => {
frozenFrame: null,
},
],
- });
+ }).tracks;
expect(calculated[0].sequence.from).toBe(0);
expect(calculated[0].sequenceFrameOffset).toBe(20);
});
test('Should account for a parent Sequence trimBefore in video thumbnails', () => {
- const calculated = calculateTimeline({
+ const calculate = CanvasInternals.createTimelineCalculator();
+ const calculated = calculate({
overrideIdsToNodePaths: {},
sequences: [
{
@@ -415,7 +422,7 @@ test('Should account for a parent Sequence trimBefore in video thumbnails', () =
playbackRate: 1,
},
],
- });
+ }).tracks;
const video = calculated.find((track) => track.sequence.type === 'video');
if (!video || video.sequence.type !== 'video') {
@@ -433,6 +440,7 @@ test('Should account for a parent Sequence trimBefore in video thumbnails', () =
});
test('Should hide descendants of sequences with connected compositions', () => {
+ const calculate = CanvasInternals.createTimelineCalculator();
const LinkedChild = () => null;
const makeSequence = ({
id,
@@ -472,7 +480,7 @@ test('Should hide descendants of sequences with connected compositions', () => {
componentFromProps: LinkedChild,
} as unknown as _InternalTypes['AnyComposition'];
- const calculated = calculateTimeline({
+ const calculated = calculate({
compositions: [connectedComposition],
showConnectedCompositionChildren: true,
overrideIdsToNodePaths: {},
@@ -487,7 +495,7 @@ test('Should hide descendants of sequences with connected compositions', () => {
makeSequence({id: 'grandchild', parent: 'child', timelineOrder: 2}),
makeSequence({id: 'sibling', parent: null, timelineOrder: 3}),
],
- });
+ }).tracks;
expect(calculated.map((track) => track.sequence.id)).toEqual([
'linked',