@diffusionstudio/core-v4
Version:
2D motion graphics and video rendering engine
215 lines (214 loc) • 6.78 kB
TypeScript
import { Timestamp } from '../../models';
import { Serializer } from '../../services';
import { Renderer } from '../../renderer';
import { ClipEvents, ClipType, ClipAnimationOptions } from './types';
import { MediaInput, Size, Time } from '../../types';
import { Layer, TransitionConfig } from '../../layer';
import { BaseSource } from '../../sources';
import { ClipProps } from './interfaces';
declare const Clip_base: {
new (...args: any[]): {
_handlers: {
'*'?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<any, any>) => void;
} | undefined;
error?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<Error, any>) => void;
} | undefined;
offset?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<Timestamp, any>) => void;
} | undefined;
frame?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<number | undefined, any>) => void;
} | undefined;
attach?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<undefined, any>) => void;
} | undefined;
detach?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<undefined, any>) => void;
} | undefined;
update?: {
[x: string]: (event: import('../../mixins/event/types').EmittedEvent<any, any>) => void;
} | undefined;
};
on<T extends "*" | "error" | keyof ClipEvents>(eventType: T, callback: (event: import('../../mixins/event/types').EmittedEvent<import('../../mixins/event/types').BaseEvents<ClipEvents>[T], /*elided*/ any>) => void): string;
off(id?: string | "*", ...ids: string[]): void;
emit<T extends "*" | "error" | keyof ClipEvents>(eventType: T, detail: import('../../mixins/event/types').BaseEvents<ClipEvents>[T]): void;
bubble(target: /*elided*/ any): string;
resolve(eventType: "*" | "error" | keyof ClipEvents): (resolve: (value: unknown) => void,
/**
* Access the parent layer
*/
reject: (reason?: any) => void) => void;
};
} & typeof Serializer;
export declare class Clip extends Clip_base {
/**
* Unique identifier of the clip
*/
id: string;
_name: undefined | string;
_delay: Timestamp;
_duration: Timestamp;
/**
* Data associated with the clip
*/
data: Record<string, unknown>;
/**
* Flag to check if the clip has been initialized
*/
initialized: boolean;
/**
* Defines the type of the clip
*/
readonly type: ClipType;
/**
* Defines the source of the clip which can be
* shared with other clips for more efficient
* memory usage
*/
source?: BaseSource;
/**
* Timestamp when the clip has been created
*/
readonly createdAt: Date;
/**
* Controls the visability of the clip
*/
disabled: boolean;
/**
* Animation properties for the clip
*/
animations: ClipAnimationOptions;
/**
* Access the parent layer
*/
layer?: Layer;
/**
* The input that was used to create the clip
*/
input?: MediaInput;
/**
* Stores the current transition configuration; how this clip transitions to the next clip.
*/
transition?: TransitionConfig;
/**
* Human readable identifier of the clip
*/
get name(): string | undefined;
set name(name: string);
/**
* Get the first visible frame
*/
get start(): Timestamp;
/**
* Get the last visible frame
*/
get stop(): Timestamp;
/**
* Get the delay of the clip
*/
get delay(): Timestamp;
/**
* Get the duration of the clip
*/
get duration(): Timestamp;
constructor(props?: ClipProps);
/**
* Set the animation time of the clip
* and interpolate the values
* @param time the current absolute time to render
*/
animate(time: Timestamp): this;
/**
* Method for connecting the layer with the clip
*/
connect(layer: Layer<Clip>): Promise<void>;
/**
* Change clip's offset to zero in seconds. Can be negative
*/
set delay(time: Time);
/**
* Set the duration of the clip, needs to be positive
*/
set duration(time: Time);
/**
* Offsets the clip by a given frame number
*/
offset(time: Time): this;
/**
* Triggered when the clip is
* added to the composition
*/
init(renderer: Renderer): Promise<void>;
/**
* Triggered when the clip enters the scene
*/
enter(renderer: Renderer): Promise<void>;
/**
* Triggered for each redraw of the scene.
*/
update(renderer: Renderer): Promise<void>;
/**
* Triggered after the clip was updated
*/
render(renderer: Renderer): void;
/**
* Triggered when the clip exits the scene
*/
exit(renderer: Renderer): Promise<void>;
/**
* Seek the clip to a specific absolute time
*/
seek(renderer: Renderer): Promise<void>;
/**
* Play the clip
*/
play(renderer: Renderer): Promise<void>;
/**
* Pause the clip
*/
pause(renderer: Renderer): Promise<void>;
/**
* Handle layout changes of the parent layer
*/
layout(nextLayout: Size): void;
/**
* Remove the clip from the layer
*/
detach(): this;
/**
* Cleanup the clip after it has been removed from the layer
*/
cleanup(): void;
/**
* Trim the clip to the specified start and stop
*/
trim(start?: Time, stop?: Time): this;
/**
* Split the clip into two clips at the specified time
* @param time split, will use the current frame of the composition
* a fallback
* @returns The clip that was created by performing this action
*/
split(time?: Time): Promise<this>;
/**
* Create a copy of the clip. Will have receive a new id
* but share the same source
*/
copy(): this;
/**
* Create a checkpoint of the clip. May include Blob or FileSystemFileHandle.
* @param middleware A function to modify the checkpoint data
* @returns A serialized representation of the clip
*/
createCheckpoint(): Promise<unknown>;
/**
* Restore a checkpoint of the clip.
* @param checkpoint The checkpoint to restore
* @param sources The sources to use for the restoration
* @returns The restored clip
*/
restoreCheckpoint(checkpoint: unknown, sources?: BaseSource[]): Promise<this>;
}
export {};