Class

TimelineEngine

The central orchestrator and coordinator for the high-performance timeline editor. Maintains state (tracks, clips, markers, playhead position, zoom scale, scrolls, snaps), builds dynamic snap indexes for magnetic snap guidance, handles split and edit actions, and publishes state events to trigger low-latency canvas renderings and lightweight React layouts.

Signature

Type Definition
Class TimelineEngine

Properties

NameSignatureDescription
canPasteSelectioncanPasteSelection: booleanWhether copied clips are available to paste.
canRedocanRedo: booleanWhether a redo snapshot is available.
canUndocanUndo: booleanWhether an undo snapshot is available.
clipboardCountclipboardCount: numberNumber of clips currently stored in the engine clipboard.
clipGroupsclipGroups: typeOperatorCurrent clip groups owned by the engine.
contentRevisioncontentRevision: numberMonotonic revision for changes that can affect active layer lookup.
frameRateframeRate: TimecodeFrameRate | undefinedConfigured timeline frame rate for frame-accurate editing controls.
geometrygeometry: TimelineGeometry
isSnappingEnabledisSnappingEnabled: booleanWhether magnetic snapping is enabled.
keyframeskeyframes: TimelineKeyframes
markersmarkers: typeOperatorCurrent marker list.
maxContentTimemaxContentTime: RationalTimeMaximum timeline time used for playback and scroll clamping.
maxScrollLeftmaxScrollLeft: numberMaximum horizontal scroll offset for the current viewport and content duration.
maxScrollTopmaxScrollTop: numberMaximum vertical scroll offset for the current viewport and track stack.
maxZoomScalemaxZoomScale: numberCurrent maximum zoom scale in pixels per second. When a frame-rate cap is lower than the content-fit floor, the content-fit floor wins so zoom never violates viewport bounds.
mediamedia: TimelineMediaQueries
minZoomScaleminZoomScale: numberCurrent minimum zoom scale in pixels per second. This preserves the content-fit floor so users cannot zoom out past the current duration/content bounds.
playheadTimeplayheadTime: RationalTimeCurrent playhead position.
scrollLeftscrollLeft: numberCurrent horizontal scroll offset in pixels.
scrollTopscrollTop: numberCurrent vertical scroll offset in pixels.
snapThresholdPixelssnapThresholdPixels: numberMagnetic snap radius in screen pixels.
trackstracks: typeOperatorCurrent readonly track snapshots.
zoomScalezoomScale: numberCurrent horizontal zoom scale in pixels per second.

Constructors

NameSignatureDescription
constructorconstructor(initialState: object): TimelineEngineCreates an instance of the TimelineEngine.

Methods

NameSignatureDescription
addMarkeraddMarker(time: RationalTime, label?: string, color?: string, description?: string): MarkerAdds a marker at a timeline time.
addTrackaddTrack(track: Track): TimelineCommandResultAppends a track to the timeline.
cancelEditcancelEdit(): voidClears the active command-layer edit preview and snap guides.
clearClipDropFeedbackclearClipDropFeedback(): voidClears transient drop feedback for the active clip body drag interaction.
clearInOutPointsclearInOutPoints(): voidClears both in-point and out-point boundaries.
commitEditcommitEdit(command: TimelineEditCommand): TimelineEditCommitResultResolves, validates, and commits an edit command as one history entry.
commitEditscommitEdits(commands: typeOperator): TimelineEditCommitResult[]Validates and applies an ordered batch atomically as one undo step.
copySelectioncopySelection(): voidCopies selected clips into the engine clipboard.
createClipGroupcreateClipGroup(options: TimelineCreateClipGroupOptions): TimelineClipGroup | nullCreates a clip group from existing clips.
cutSelectioncutSelection(): TimelineEditCommitResultCopies selected clips into the clipboard, then removes them from their tracks.
emitemit(event: Key, args: undefined): voidEmits a typed event to all active subscribers. Supports type-safety by enforcing key-value mapping and allows omitting the payload argument entirely if the map type is void.
getClipDropFeedbackgetClipDropFeedback(): TimelineClipDropFeedbackCurrent transient drop feedback for the active clip body drag interaction.
getClipGroupgetClipGroup(id: string): TimelineClipGroup | undefined
getClipGroupClipsgetClipGroupClips(groupId: string): TimelineClipEntry<string>[]Returns clips contained by a group in group order.
getClipGroupForClipgetClipGroupForClip(id: string): TimelineClipGroup | undefined
getEditImpactsgetEditImpacts(): TimelineEditImpacts | nullCurrent transient impacts for the active live edit interaction. Returns null when no live edit is currently affecting other clips.
getEditPreviewgetEditPreview(): TimelineEditPreview | nullCurrent transient preview for the active command-layer edit. Returns null when no command preview is active.
getKeyframePropertyDefinitiongetKeyframePropertyDefinition(property: string): Readonly<TimelineKeyframePropertyDefinition<string>> | nullReturns one registered scalar keyframe property definition.
getPlaybackRategetPlaybackRate(): numberReturns the current playback speed multiplier.
getPlaybackStartTimegetPlaybackStartTime(options: PlaybackOptions = {}): RationalTimeResolves exhausted Out-point and loop-duration starts to the active range start.
getRenderStategetRenderState(): objectReturns readonly drawing content, including a non-mutating edit preview.
getSelectedClipIdsgetSelectedClipIds(): string[]Returns currently selected clip IDs in timeline track order.
getStategetState(): objectReturns a stable, deeply readonly snapshot with owned document values.
getTimegetTime(): RationalTimeReturns the current playhead time.
hasKeyframePropertyhasKeyframeProperty(property: string): booleanReturns whether a scalar keyframe property is registered.
insertClipGroupinsertClipGroup(options: TimelineInsertClipGroupOptions): TimelineClipGroup | nullInserts multiple clips on chosen tracks and groups them in one history entry. This convenience API uses the same grouped insert command pipeline as `commitEdit({ type: 'insert-clip-group', ... })`, including validation, edit policy checks, snapping, ripple behavior, lifecycle events, and undo history.
invalidateContentinvalidateContent(): voidInvalidates content-dependent queries and renderer snapshots.
listKeyframePropertieslistKeyframeProperties(): Readonly<TimelineKeyframePropertyDefinition<string>>[]Returns all registered scalar keyframe property definitions.
moveTrackmoveTrack(trackId: string, toIndex: number): TimelineCommandResultMoves a track to a final zero-based row index as one undoable change.
onon(event: K, callback: (payload: indexedAccess) => void): () => voidSubscribes to a typed event.
pasteSelectionpasteSelection(time: RationalTime, targetTrackId?: string): TimelineEditCommitResult[] | undefinedPastes clipboard clips at a timeline time. Relative offsets between copied clips are preserved. When no target track is supplied, the first targeted track is used, then the first track as fallback.
pausepause(): voidStops playhead playback and clears the active animation frame.
pixelToTimepixelToTime(pixel: number, rate: number = 24000): RationalTimeConverts a horizontal pixel coordinate to timeline time.
playplay(options: PlaybackOptions = {}): booleanPlays the timeline.
prepareSnappingprepareSnapping(ignoreClipIdOrOptions?: string | SnapPreparationOptions): voidRebuilds snap targets for an upcoming drag, trim, or range-boundary gesture.
previewEditpreviewEdit(command: TimelineEditCommand): TimelineEditPreviewResolves and publishes a non-mutating preview for an edit command.
redoredo(): voidRestores the next redo-history snapshot when available.
registerKeyframePropertiesregisterKeyframeProperties(definitions: TimelineKeyframePropertyDefinition<string>[]): voidRegisters scalar keyframe property definitions.
registerKeyframePropertyregisterKeyframeProperty(definition: TimelineKeyframePropertyDefinition): voidRegisters one scalar keyframe property definition.
registerSnapProviderregisterSnapProvider(provider: TimelineSnapProvider): () => voidRegisters a runtime snap target provider.
removeMarkerremoveMarker(id: string): booleanRemoves a marker by id.
removeTrackremoveTrack(trackId: string): TimelineCommandResult<void>Removes a track by id.
renameTrackrenameTrack(trackId: string, name: string | undefined): TimelineCommandResultRenames a track, or clears its app-defined name.
resolveSnapresolveSnap(time: RationalTime, publishFeedback: boolean = true): TimelineSnapResult | nullResolves a candidate timeline time against the prepared snap index.
selectClipselectClip(clipId: string | null): TimelineCommandResultSelects one clip and clears selection from all others.
selectClipsselectClips(clipIds: typeOperator): TimelineCommandResultSelects a set of clips and clears selection from all others.
selectTrackselectTrack(trackId: string | null): TimelineCommandResultSelects one track and clears selection from all others.
setClipDropFeedbacksetClipDropFeedback(feedback: TimelineClipDropFeedback): voidPublishes transient drop feedback for renderer and headless UI consumers.
setDurationsetDuration(duration: RationalTime | undefined): voidSets or clears an explicit timeline duration. When a duration is set, zoom, scroll, and playhead are clamped to that duration instead of the dynamic maximum clip end.
setEditPolicysetEditPolicy(policy: TimelineEditPolicy | undefined): voidReplaces the app-defined edit policy used by command validation.
setInOutRangesetInOutRange(startTime: RationalTime, endTime: RationalTime): TimelineCommandResultAtomically replaces both In/Out boundaries without intermediate range clearing.
setInPointsetInPoint(time: RationalTime | undefined, snap?: boolean): voidSets or clears the in-point boundary. Clears both points when it reaches or crosses the out-point.
setOutPointsetOutPoint(time: RationalTime | undefined, snap?: boolean): voidSets or clears the out-point boundary. Clears both points when it reaches or crosses the in-point.
setPlaybackRatesetPlaybackRate(rate: number): voidUpdates the playback speed multiplier.
setScrollLeftsetScrollLeft(scroll: number): voidSets horizontal scroll offset, clamped to the valid scroll range.
setScrollTopsetScrollTop(scroll: number): voidSets vertical scroll offset, clamped to the valid track stack scroll range.
setSnappingEnabledsetSnappingEnabled(enabled: boolean): voidEnables or disables magnetic snapping.
setSnapThresholdPixelssetSnapThresholdPixels(thresholdPixels: number): voidSets the magnetic snap radius in screen pixels.
setTimesetTime(time: RationalTime): voidMoves the playhead to an absolute timeline time. Alias for `updatePlayhead` that reads naturally in external media sync code.
settlesettle(): voidFinalizes an interaction, clears snap guides, snapshots history, and emits settled state.
setTrackCollapsedsetTrackCollapsed(trackId: string, collapsed: boolean): TimelineCommandResultSets row collapse without changing its expanded height or media visibility.
setTrackGroupsetTrackGroup(trackId: string, groupId: string | undefined): TimelineCommandResult<void>Assigns a track to a group or removes it from grouping.
setTrackHeightsetTrackHeight(trackId: string, height: number): TimelineCommandResult<void>Updates a track's expanded display height.
setTrackHeightssetTrackHeights(updates: typeOperator, options: TimelineTrackHeightBatchOptions = {}): voidSets multiple expanded track heights and publishes a single settled/render cycle.
setViewportHeightsetViewportHeight(height: number): voidStores the visible timeline viewport height.
setViewportWidthsetViewportWidth(width: number): voidStores the visible timeline viewport width.
setZoomConstraintssetZoomConstraints(constraints: TimelineZoomConstraints = {}): voidUpdates engine-owned zoom constraints and re-clamps the current viewport.
setZoomScalesetZoomScale(scale: number): voidSets the zoom scale while keeping the viewport within content bounds.
snapshotsnapshot(): voidStores the current track and marker state in undo history.
timeToPixeltimeToPixel(time: RationalTime): numberConverts a timeline time to a horizontal pixel coordinate.
toggleClipSelectiontoggleClipSelection(clipId: string, selected?: boolean): TimelineCommandResult<void>Toggles one clip in the current multi-selection.
toggleLockTracktoggleLockTrack(trackId: string, locked?: boolean): TimelineCommandResult<void>Enables, disables, or toggles a track's locked state.
toggleMuteTracktoggleMuteTrack(trackId: string, muted?: boolean): TimelineCommandResult<void>Enables, disables, or toggles a track's muted state.
toggleTrackTargettoggleTrackTarget(trackId: string, targeted?: boolean): TimelineCommandResult<void>Enables, disables, or toggles track targeting.
toggleTrackVisibilitytoggleTrackVisibility(trackId: string, visible?: boolean): TimelineCommandResult<void>Enables, disables, or toggles a track's output visibility.
undoundo(): voidRestores the previous undo-history snapshot when available.
ungroupClipGroupungroupClipGroup(groupId: string): booleanRemoves one clip group.
ungroupClipsungroupClips(clipIds: typeOperator): booleanRemoves groups containing any of the supplied clips.
updateClipPropertiesupdateClipProperties(clipId: string, properties: Partial<Pick<Clip, "label" | "opacity" | "color">>): TimelineCommandResult<void>Updates user-facing clip display properties.
updateExternalPlaybackTimeupdateExternalPlaybackTime(time: RationalTime): ExternalPlaybackUpdateAdvances externally clocked playback through the shared range policy.
updateMarkerupdateMarker(id: string, updates: Partial<Omit<Marker, "id">>): Marker | nullUpdates an existing marker.
updatePlayheadupdatePlayhead(time: RationalTime): voidMoves the playhead, clamped to the timeline content range.
validateEditvalidateEdit(command: TimelineEditCommand): TimelineEditValidationResult