import { z } from "zod"; import { AudioClip, Clip } from "../clip"; import { Layer } from "../layer"; /** * Rounding modes used when aligning times to timeline frames. */ export declare enum AlignRoundEnum { NEAREST = "nearest", UP = "up", DOWN = "down" } /** * Additional options that control a timeline render tick. */ export interface TimelineRenderOptions { skipRequestAnimationFrame: boolean; } /** * Zod schema for serialized timeline state. */ export declare const TimelineSchema: z.ZodObject<{ startTime: z.ZodNumber; fps: z.ZodNumber; layers: z.ZodArray; visible: z.ZodOptional; muted: z.ZodOptional; volume: z.ZodOptional; clips: z.ZodArray; transitions: z.ZodArray, "many">; }, "strip", z.ZodTypeAny, { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }, { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }>, "many">; customData: z.ZodOptional, "many">>; }, "strip", z.ZodTypeAny, { id: string; transitions: { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }[]; clips: any[]; name?: string | undefined; visible?: boolean | undefined; muted?: boolean | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }, { id: string; transitions: { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }[]; clips: any[]; name?: string | undefined; visible?: boolean | undefined; muted?: boolean | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }>, "many">; fitDuration: z.ZodDefault>; volume: z.ZodDefault>; customData: z.ZodOptional, "many">>; }, "strip", z.ZodTypeAny, { startTime: number; volume: number; fps: number; layers: { id: string; transitions: { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }[]; clips: any[]; name?: string | undefined; visible?: boolean | undefined; muted?: boolean | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }[]; fitDuration: number; customData?: [string, unknown][] | undefined; }, { startTime: number; fps: number; layers: { id: string; transitions: { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }[]; clips: any[]; name?: string | undefined; visible?: boolean | undefined; muted?: boolean | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }[]; fitDuration?: number | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }>; /** * Owns the ordered set of layers and drives playback, seeking, and frame updates across the project. */ export declare class Timeline { private startTime; layers: Record; layersOrder: string[]; fps: number; volume: number; protected customData?: Map; currentTime: number; isPlaying: boolean; private justStartedPlaying; private isDestroyed; private animationFrameHandler; /** * Creates an empty timeline with default playback settings. */ constructor(); /** * Initializes all layers and starts the render loop. * * @returns A promise that resolves after timeline initialization completes. */ init(): Promise; /** * Clears the current timeline state, destroys existing layers, and restarts the render loop with default playback settings. * * @returns Nothing. */ reset(): void; /** * Stops the render loop, destroys every layer, and removes all timeline content. * * @returns Nothing. */ destroy(): void; /** * Imports a media file into the project library. * * @param file Source file to add. * @returns A promise that resolves to the created media ID, or `null` if the import fails before an ID can be returned. */ addMedia(file: File): Promise; private updateLayerOrder; /** * Adds an existing layer instance to the timeline. * * @param layer Layer instance to add. * @param index Optional insertion index in the layer order. * @returns A promise that resolves after the layer has been initialized. */ addLayer(layer: Layer, index?: number): Promise; /** * Creates, inserts, and initializes a new layer. * * @param options Optional insertion options. * @returns The created layer. */ createLayer(options?: { index?: number; }): Layer; /** * Returns a layer by its ID. * * @param layerId Layer ID to look up. * @returns The matching layer, or `undefined` if not found. */ getLayerById(layerId: string): Layer | undefined; /** * Returns the layer that currently owns the specified clip. * * @param clipId Clip ID to look up. * @returns The layer containing the clip, or `undefined` if the clip cannot be found. */ getLayerByClipId(clipId: string): Layer | undefined; /** * Returns the current order index of a layer in the timeline stack. * * @param layerId Layer ID to look up. * @returns The zero-based layer index, or `-1` if the layer is not present. */ getLayerIdx(layerId: string): number; /** * Returns a clip by its ID. * * @param clipId Clip ID to look up. * @returns The matching clip, or `undefined` if not found. */ getClipById(clipId: string): Clip | undefined; /** * Returns all clips that reference the specified media item. * * @param mediaId Media ID to match. * @returns The matching clips. */ getClipsByMediaId(mediaId: string): Clip[]; /** * Returns all clips that reference the specified subtitles asset. * * @param subtitlesId Subtitles asset ID to match. * @returns The matching clips. */ getClipsBySubtitlesId(subtitlesId: string): Clip[]; /** * Sets the master timeline volume used by audio and video clips during playback. * * @param volume Timeline volume multiplier. * @returns Nothing. */ setVolume(volume: number): void; /** * Returns the current master timeline volume. * * @returns The timeline volume multiplier. */ getVolume(): number; /** * Starts timeline playback. * * @returns A promise that resolves after all layers have handled playback start. */ play(): Promise; /** * Pauses playback without changing the current playhead position. * * @returns Nothing. */ pause(): void; /** * Stops playback and resets the playhead to the start of the timeline. * * @returns Nothing. */ stop(): void; /** * Moves the playhead to a specific timeline time. * * @param value Target time, in seconds. * @returns Nothing. */ seek(value: number): void; /** * Returns all clips across every layer. * * @returns The flattened clip list. */ getClips(): Clip[]; /** * Cancels in-progress processing work for every clip on the timeline. * * @returns Nothing. */ discardProcessing(): void; /** * Indicates whether any clip on the timeline is still processing media or effects. * * @returns `true` if at least one clip is still processing; otherwise `false`. */ getIsProcessing(): boolean; /** * Assigns a subtitles asset to clips on the timeline. * * @param subtitlesId Subtitles asset ID to apply. * @param offset Global subtitles offset in seconds. * @param clipIds Optional clip ID subset to update. When omitted, all clips are updated. * @returns Nothing. */ setSubtitles(subtitlesId: string, offset: number, clipIds?: string[]): void; removeClip(clipId: string): boolean; /** * Removes a layer and all of its clips. * * @param layerId Layer ID to remove. * @returns `true` if the layer existed and was removed; otherwise `false`. */ removeLayer(layerId: string): boolean; /** * Moves a clip from its current layer to another layer. * * @param clipId Clip ID to move. * @param newLayerId Destination layer ID. * @returns A promise that resolves after the move has completed. */ moveClipToLayer(clipId: string, newLayerId: string): Promise; /** * Creates an audio clip from the audio track of a video clip. * * @param clip Video clip instance or video clip ID. * @returns The created audio clip, or `undefined` if extraction is not possible. */ extractAudio(clip: string | Clip): AudioClip | undefined; /** * Aligns a time value to the nearest valid frame boundary. * * @param time Source time in seconds. * @param roundDirection Rounding strategy used during alignment. * @returns The aligned time in seconds. */ alignTime(time: number, roundDirection?: AlignRoundEnum): number; /** * Converts a time value into a frame number using the current timeline FPS. * * @param time Source time in seconds. * @param roundDirection Rounding strategy used during alignment. * @returns The aligned frame number. */ getFrameNumberFromTime(time: number, roundDirection?: AlignRoundEnum): number; /** * Converts multiple time values into frame numbers using the current timeline FPS. * * @param timeValues Source times in seconds. * @returns The matching frame numbers in the same order. */ getFrameNumberFromTimeValues(timeValues: number[]): number[]; /** * Reflows clips on every layer to resolve overlaps or spacing issues according to each layer's layout rules. * * @returns `true` if any layer changed its clip layout; otherwise `false`. */ adjustClipsLayout(): boolean; /** * Returns the duration of a single timeline frame. * * @returns The frame duration in seconds. */ getFrameDuration(): number; /** * Returns the timeline frame rate. * * @returns Frames per second used for playback and time alignment. */ getFps(): number; /** * Sets the timeline frame rate used for playback and frame alignment. * * @param fps Frames per second to use. * @returns Nothing. */ setFps(fps: number): void; /** * Returns the end time of the right-most visible content on the timeline. * * @returns The fit duration in seconds. */ getFitDuration(): number; /** * Stores an arbitrary metadata entry on the timeline instance. * * @param key Metadata key. * @param value Metadata value. * @param overwrite Whether an existing value for the same key may be replaced. * @returns `true` if the value was stored; otherwise `false` when `overwrite` is disabled and the key already exists. */ setCustomData(key: string, value: unknown, overwrite?: boolean): boolean; /** * Returns a previously stored timeline metadata value. * * @param key Metadata key to look up. * @returns The stored value, or `undefined` if the key is not present. */ getCustomData(key: string): unknown; /** * Indicates whether the timeline has a stored metadata value for the provided key. * * @param key Metadata key to test. * @returns `true` if the key exists; otherwise `false`. */ hasCustomData(key: string): boolean; /** * Removes all custom metadata stored on the timeline. * * @returns Nothing. */ clearAllCustomData(): void; /** * Replaces all custom timeline metadata with a copy of the provided map. * * @param data Metadata entries to store. * @returns Nothing. */ setAllCustomData(data: Map): void; /** * Returns a copy of all custom metadata stored on the timeline. * * @returns A copied metadata map, or `undefined` if no custom data has been stored. */ getAllCustomData(): Map | undefined; /** * Advances the timeline and renders one frame. * * @param options Optional render-loop behavior overrides. * @returns A promise that resolves after the frame has been processed. */ render(options?: TimelineRenderOptions): Promise; /** * Runs post-render hooks for every layer after a frame has been presented. * * @returns Nothing. */ postRender(): void; /** * Stops the animation-frame driven render loop without destroying timeline state. * * @returns Nothing. */ stopRenderingLoop(): void; /** * Replaces the current timeline state with serialized data and reinitializes rendering. * * @param data Serialized timeline payload. * @returns A promise that resolves after the timeline has been reloaded. */ loadSerializedData(data: object): Promise; /** * Serializes the timeline and all of its layers. * * @returns The serialized timeline payload. */ serialize(): { startTime: number; volume: number; fps: number; layers: { id: string; transitions: { properties: [string, any][]; id: string; provider: string; startClipId: string; endClipId: string; inDuration: number; outDuration: number; transitionId: string; }[]; clips: any[]; name?: string | undefined; visible?: boolean | undefined; muted?: boolean | undefined; volume?: number | undefined; customData?: [string, unknown][] | undefined; }[]; fitDuration: number; customData?: [string, unknown][] | undefined; }; /** * Creates a timeline instance from serialized data. * * @param data Serialized timeline payload. * @returns The deserialized timeline. */ static deserialize(data: object): Timeline; }