UNPKG

@diffusionstudio/core-v2

Version:
1,701 lines (1,555 loc) 104 kB
import { Muxer } from 'mp4-muxer'; import { StreamTarget } from 'mp4-muxer'; declare type Abs<T extends Object> = { [K in keyof T]: T[K] extends number | Percent ? number : T[K]; }; export declare function abs(value: number | Percent, max: number): number; /** * Move an element inside the provided array */ export declare function arraymove(arr: any[], fromIndex: number, toIndex: number): void; /** * clip assert replacement for the browser * @example assert(true == false) */ export declare function assert(condition: any): void; /** * Converts the specified AudioBuffer to a Blob. * * Note that changing the MIME type does not change the actual file format. * The output is a WAVE in any case */ export declare function audioBufferToWav(buffer: AudioBuffer, type?: string): Blob; export declare class AudioClip extends MediaClip { readonly type = "audio"; track?: Track<AudioClip>; source: AudioSource; /** * Access to the HTML5 audio element */ element: HTMLAudioElement; constructor(source?: File | AudioSource, props?: AudioClipProps); init(): Promise<void>; update(_renderer: Renderer, _time: Timestamp, mode?: RenderMode): void | Promise<void>; copy(): AudioClip; } export declare interface AudioClipProps extends MediaClipProps { } export declare type AudioMimeType = keyof (typeof SUPPORTED_MIME_TYPES)['AUDIO']; declare type AudioSettings = { sampleRate: number; numberOfChannels: number; bitrate: number; }; export declare type AudioSlice = { start: Timestamp; stop: Timestamp; }; export declare class AudioSource extends AudioSource_base { private decoding; private _silences?; readonly duration: Timestamp; readonly type: ClipType; element: HTMLAudioElement; transcript?: Transcript; audioBuffer?: AudioBuffer; protected loadElement(): Promise<void>; decode(numberOfChannels?: number, sampleRate?: number, cache?: boolean): Promise<AudioBuffer>; /** * Sampler that uses a window size to calculate the max value of the samples in the window. * @param options - Sampling options. * @returns An array of the max values of the samples in the window. */ sample({ length, start, stop, logarithmic, }?: SamplerOptions): Promise<Float32Array>; thumbnail(options?: SamplerOptions): Promise<HTMLElement>; /** * Find silences in the audio clip. Results are cached. * * uses default sample rate of 3000 * @param options - Silences options. * @returns An array of the silences (in ms) in the clip. */ silences(options?: SilenceDetectionOptions): Promise<AudioSlice[]>; } declare const AudioSource_base: { new (...args: any[]): { readonly height: int; readonly width: int; readonly aspectRatio: number; id: `${string}-${string}-${string}-${string}-${string}`; toJSON(): any; }; } & typeof Source; export declare class AudioTrack extends MediaTrack<AudioClip> { readonly type = "audio"; } export declare type Background = { /** * @default #000000 */ fill?: hex; /** * @default 100 */ opacity?: number; /** * @default 20 */ borderRadius?: number; /** * @default { x: 30, y: 20 } */ padding?: { x: int; y: int; }; }; export declare class BaseError extends Error { readonly message: string; readonly code: string; constructor({ message, code }: { message?: string | undefined; code?: string | undefined; }, ...args: any[]); } declare type BaseEvents<E = {}> = { '*': any; error: Error; } & E; /** * Defines the blend mode to use */ export declare type BlendMode = 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity'; /** * Merges the channels of the audio blob into a mono AudioBuffer */ export declare function blobToMonoBuffer(blob: Blob, sampleRate?: number, scalingFactor?: number): Promise<AudioBuffer>; /** * Convert an audio buffer into a planar float 32 array */ export declare function bufferToF32Planar(input: AudioBuffer): Float32Array; /** * Conver an audio buffer inter a interleaved int 16 array */ export declare function bufferToI16Interleaved(audioBuffer: AudioBuffer): Int16Array; export declare function capitalize(str: string): string; export declare class CaptionPresetDeserializer { static fromJSON<K extends { type?: CaptionPresetType; }>(data: K extends string ? never : K): CaptionPresetStrategy; } export declare interface CaptionPresetStrategy { /** * Defines the type of strategy */ type: CaptionPresetType; /** * This function returns the position of the captions */ position: RelativePoint; /** * This function applies the settings to the track */ applyTo(track: CaptionTrack): Promise<void>; } export declare type CaptionPresetType = 'CLASSIC' | 'SPOTLIGHT' | 'CASCADE' | 'GUINEA' | 'SOLAR' | 'WHISPER' | 'VERDANT' | string; /** * Defines the captions transport format */ export declare type Captions = { /** * Defines the word or token * currently spoken */ token: string; /** * Defines the time when the token * will be spoken in **milliseconds** */ start: number; /** * Defines the time when the token * has been spoken in **milliseconds** */ stop: number; }[][]; export declare class CaptionTrack extends Track<TextClip> { /** * Defines the media clip that will be * used for creating the captions */ clip?: MediaClip; readonly type = "caption"; /** * The currently active captioning strategy */ preset: CaptionPresetStrategy; /** * Defines the media resource from which the * captions will be created. It must contain * a `Transcript` */ from(value: MediaClip | undefined): this; /** * If a transcript has been added to the resource * you can generate captions with this function * @param strategy The caption strategy to use * @default ClassicCaptionPreset */ createCaptions(strategy?: CaptionPresetStrategy | (new () => CaptionPresetStrategy)): Promise<this>; } export declare class CascadeCaptionPreset extends Serializer implements CaptionPresetStrategy { generatorOptions: GeneratorOptions; readonly type = "CASCADE"; position: RelativePoint; constructor(config?: Partial<DefaultCaptionPresetConfig>); applyTo(track: CaptionTrack): Promise<void>; } /** * Defines the properties of a circle */ export declare interface Circle { /** * The x coordinate of the circle */ cx: number | Percent; /** * The y coordinate of the circle */ cy: number | Percent; /** * The radius of the circle */ radius: number; } export declare class CircleClip extends ShapeClip { track?: Track<CircleClip>; radius: number; animations: CircleClipAnimationOptions; constructor(props?: CircleClipProps); /** * Access to the html document that * will be rendered to the canvas */ render(renderer: Renderer): void; copy(): CircleClip; } export declare type CircleClipAnimationOptions = (KeyframeOptions<'x' | 'y' | 'translateX' | 'translateY', number | Percent> | KeyframeOptions<'opacity' | 'rotation' | 'scale' | 'scaleX' | 'scaleY' | 'radius', number> | KeyframeOptions<'fill', string>)[]; export declare interface CircleClipProps extends ShapeClipProps { radius: number; animations?: CircleClipAnimationOptions; } export declare class CircleMask extends Mask { constructor(options: Abs<Circle>); } export declare class ClassicCaptionPreset extends Serializer implements CaptionPresetStrategy { generatorOptions: GeneratorOptions; readonly type: CaptionPresetType; position: RelativePoint; constructor(config?: Partial<DefaultCaptionPresetConfig>); applyTo(track: CaptionTrack): Promise<void>; } export declare class Clip extends Clip_base { _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 with a * one-to-many (1:n) relationship */ source?: Source; /** * Flag to check if the clip has been rendered */ rendered?: boolean; /** * 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 track */ track?: Track<Clip>; /** * Human readable identifier ot 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 track with the clip */ connect(track: Track<Clip>): Promise<void>; /** * Change clip's offset to zero in seconds. Can be negative */ set delay(time: frame | Timestamp); /** * Set the duration of the clip, needs to be positive */ set duration(time: frame | Timestamp); /** * Offsets the clip by a given frame number */ offset(time: frame | Timestamp): this; /** * Triggered when the clip is * added to the composition */ init(): Promise<void>; /** * Triggered when the clip enters the scene */ enter(): void; /** * Triggered for each redraw of the scene. * Can return a promise which will be awaited * during export. * @param time the current time to render */ update(renderer: Renderer, time: Timestamp, mode?: RenderMode, fps?: number): void | Promise<void>; render(renderer: Renderer, time: Timestamp): void; /** * Triggered when the clip exits the scene */ exit(): void; /** * Remove the clip from the track */ detach(): this; /** * Trim the clip to the specified start and stop */ trim(start?: Timestamp | frame, stop?: Timestamp | frame): 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?: frame | Timestamp): Promise<this>; /** * Create a copy of the clip */ copy(): Clip; } declare const Clip_base: { new (...args: any[]): { _handlers: { '*'?: { [x: string]: (event: EmittedEvent<any, any>) => void; } | undefined; error?: { [x: string]: (event: EmittedEvent<Error, any>) => void; } | undefined; offset?: { [x: string]: (event: EmittedEvent<Timestamp, any>) => void; } | undefined; update?: { [x: string]: (event: EmittedEvent<any, any>) => void; } | undefined; frame?: { [x: string]: (event: EmittedEvent<number | undefined, any>) => void; } | undefined; attach?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; detach?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; }; on<T extends "*" | "error" | keyof ClipEvents>(eventType: T, callback: (event: EmittedEvent<BaseEvents<ClipEvents>[T], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T extends "*" | "error" | keyof ClipEvents>(eventType: T, detail: BaseEvents<ClipEvents>[T]): void; bubble(target: any): string; resolve(eventType: "*" | "error" | keyof ClipEvents): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }; } & typeof Serializer; export declare type ClipAnimationOptions = KeyframeOptions<any, number | string | hex | Percent>[]; export declare class ClipDeserializer { static fromType(data: { type: ClipType; }): Clip; static fromSource(data: Source): VideoClip | AudioClip | HtmlClip | ImageClip | undefined; } export declare type ClipEvents = { offset: Timestamp; update: any; frame: number | undefined; attach: undefined; detach: undefined; }; export declare interface ClipProps { disabled?: boolean; name?: string; duration?: frame | Timestamp; delay?: frame | Timestamp; animations?: ClipAnimationOptions; } export declare type ClipType = 'image' | 'audio' | 'text' | 'video' | 'base' | 'html' | 'shape'; export declare class Composition extends Composition_base { /** * Access to the gpu renderer */ renderer: Renderer; /** * Tracks attached to the composition */ tracks: Track<Clip>[]; /** * The ticker used for rendering the composition */ ticker: Ticker; constructor({ height, width, background, }?: Partial<CompositionSettings>); /** * Settings of the composition */ get settings(): CompositionSettings; /** * Get the current width of the canvas */ get width(): number; /** * Get the current height of the canvas */ get height(): number; /** * This is where the playback stops playing */ get duration(): Timestamp; /** * Limit the total duration of the composition */ set duration(time: frame | Timestamp | undefined); /** * Resize the renderer */ resize(width: number, height: number): void; /** * Add the renderer to the dom. * This will start the ticker */ mount(element: HTMLElement): void; /** * Remove the renderer from the dom. * This will stop the ticker */ unmount(): void; /** * Insert a new track at the specified index (defaults to 0) * @param Track The track to insert * @param index The index to insert at (0 = top layer, default: 0) */ insertTrack<L extends Track<Clip>>(Track: (new () => L) | L, index?: number): L; /** * Create a track with the given type * @param type the desired type of the track * @returns A new track */ createTrack<T extends TrackType>(type: T): TrackMap[T]; /** * Convenience function for appending a track * aswell as the clip to the composition */ add<L extends Clip>(clip: L): Promise<L>; /** * Remove a given clip from the composition * @returns `Clip` when it has been successfully removed `undefined` otherwise */ remove<L extends Clip>(clip: L): L | undefined; /** * Remove all tracks that are of the specified type * @param track type to be removed */ removeTracks(Track: new (composition: Composition) => Track<Clip>): Track<Clip>[]; /** * Find tracks that match the profided parameters */ findTracks<T extends Track<Clip>>(predicate: ((value: Track<Clip>) => boolean) | (new () => T)): T[]; /** * Find clips that match the profided parameters */ findClips<T extends Clip>(predicate: ((value: Clip) => boolean) | (new () => T)): T[]; /** * Compute the currently active frame */ render(frame: frame): void; /** * Update the composition at a specific frame */ update(frame: frame): void; /** * Take a screenshot of the still frame */ screenshot(format?: ScreenshotImageFormat, quality?: number): string; /** * Set the playback position to a specific time * @param value new playback time */ seek(value: frame | Timestamp): Promise<void>; /** * Play the composition */ play(): Promise<void>; /** * Pause the composition */ pause(): Promise<void>; audio(numberOfChannels?: number, sampleRate?: number): Promise<AudioBuffer>; /** * Remove all tracks and clips from the composition */ clear(): void; /** * Get the current playback time and composition * duration formatted as `00:00 / 00:00` by default. * if **hours** is set the format is `HH:mm:ss` whereas * **milliseconds** will return `mm:ss.SSS` */ time(precision?: { hours?: boolean; milliseconds?: boolean; }): string; /** * Remove a given track from the composition * @returns `Track` when it has been successfully removed `undefined` otherwise */ removeTrack<T extends Track<Clip>>(track: T): T | undefined; } declare const Composition_base: { new (...args: any[]): { _handlers: { '*'?: { [x: string]: (event: EmittedEvent<any, any>) => void; } | undefined; error?: { [x: string]: (event: EmittedEvent<Error, any>) => void; } | undefined; play?: { [x: string]: (event: EmittedEvent<frame, any>) => void; } | undefined; pause?: { [x: string]: (event: EmittedEvent<frame, any>) => void; } | undefined; init?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; currentframe?: { [x: string]: (event: EmittedEvent<frame, any>) => void; } | undefined; update?: { [x: string]: (event: EmittedEvent<any, any>) => void; } | undefined; frame?: { [x: string]: (event: EmittedEvent<number | undefined, any>) => void; } | undefined; attach?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; detach?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; load?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; resize?: { [x: string]: (event: EmittedEvent<undefined, any>) => void; } | undefined; }; on<T extends "*" | "error" | keyof CompositionEvents>(eventType: T, callback: (event: EmittedEvent<BaseEvents<CompositionEvents>[T], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T extends "*" | "error" | keyof CompositionEvents>(eventType: T, detail: BaseEvents<CompositionEvents>[T]): void; bubble(target: any): string; resolve(eventType: "*" | "error" | keyof CompositionEvents): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }; } & typeof Serializer; /** * Defines the type of events emitted by the * composition */ export declare type CompositionEvents = { play: frame; pause: frame; init: undefined; currentframe: frame; update: any; frame: number | undefined; attach: undefined; detach: undefined; load: undefined; resize: undefined; }; export declare type CompositionSettings = { /** * Height of the composition * * @default 1080 */ height: int; /** * Width of the composition * * @default 1920 */ width: int; /** * Background color of the composition * * @default #000000 */ background: hex | 'transparent'; }; /** * Defines the constructor required by mixins */ export declare type Constructor<T = {}> = new (...args: any[]) => T; /** * Limit the number of times a function can be called * per interval, timeout is in milliseconds */ export declare function debounce(func: Function, timeout?: number): (...args: any[]) => void; export declare type DefaultCaptionPresetConfig = { generatorOptions: GeneratorOptions; position: RelativePoint; }; export declare type Deserializer<T> = (data: any) => Promise<T> | T; /** * This utility creates an anchor tag and clicks on it * @param source Blob url or base64 encoded svg * @param name File name suggestion */ export declare function downloadObject(source: string | Blob, name?: string): Promise<void>; /** * An optional easing function to apply to the interpolation. * Easing functions can modify the interpolation to be non-linear. * @default "linear" */ declare type Easing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'ease-out-in'; declare type EmittedEvent<K, T extends {}> = OverrideValues<CustomEvent<K>, { target: T; }>; export declare type EncodedOpusChunk = { data: Uint8Array; timestamp: number; type: 'key' | 'delta'; duration: number; }; export declare type EncodedOpusChunkOutputCallback = (output: EncodedOpusChunk, metadata: EncodedAudioChunkMetadata) => void; export declare class Encoder extends WebcodecsVideoEncoder { private audioEncoder?; /** * Create a new audio and video encoder and multiplex the result * using a mp4 container * @param composition The composition to render * @param options Configure the output * @example * ``` * new Encoder(composition, { resolution: 2 }).render() // will render at 4K * ``` */ constructor(composition: Composition, init?: VideoEncoderInit_2); /** * Export the specified composition * @throws DOMException if the export has been aborted */ render(target?: StreamCallback | FileSystemFileHandle | string, signal?: AbortSignal): Promise<undefined | Blob>; /** * Check which configurations are supported and select the best * @returns A supported audio and video configuration */ private getConfigs; } export declare class EncoderError extends BaseError { } declare type EncoderEvents = { render: { /** * Defines how many frames were rendered yet */ progress: number; /** * Defines the total number of frames * to be rendered */ total: number; /** * Defines the estimated remaining * render time */ remaining: Date; }; }; declare interface EncoderInit { /** * A floating point number indicating the audio context's sample rate, in samples per second. * * @default 48000 */ sampleRate?: number; /** * Defines the number of channels * of the composed audio * * @default 2 */ numberOfChannels?: number; /** * Defines the bitrate at which the video * should be rendered at * @default 10e6 */ videoBitrate?: number; /** * Defines the maximum size of the video * encoding queue, increasing this number * will put a higher pressure on the gpu. * It's restricted to a value between 1 and 100 * @default 5 */ gpuBatchSize?: number; /** * Defines the fps at which the composition * will be rendered * @default 30 */ fps?: number; /** * Defines if the audio should be encoded */ audio?: boolean; } /** * Error message structure */ export declare type ErrorEventDetail = { msg: string; code: string; params?: any; }; export declare function EventEmitter<Events = {}>(): { new (...args: any[]): { _handlers: { [T in keyof BaseEvents<Events>]?: { [x: string]: (event: EmittedEvent<BaseEvents<Events>[T], any>) => void; } | undefined; }; on<T_1 extends "*" | "error" | keyof Events>(eventType: T_1, callback: (event: EmittedEvent<BaseEvents<Events>[T_1], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T_1 extends "*" | "error" | keyof Events>(eventType: T_1, detail: BaseEvents<Events>[T_1]): void; bubble(target: { _handlers: { [T in keyof BaseEvents<Events>]?: { [x: string]: (event: EmittedEvent<BaseEvents<Events>[T], any>) => void; } | undefined; }; on<T_1 extends "*" | "error" | keyof Events>(eventType: T_1, callback: (event: EmittedEvent<BaseEvents<Events>[T_1], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T_1 extends "*" | "error" | keyof Events>(eventType: T_1, detail: BaseEvents<Events>[T_1]): void; bubble(target: any): string; resolve(eventType: "*" | "error" | keyof Events): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }): string; resolve(eventType: "*" | "error" | keyof Events): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }; }; export declare function EventEmitterMixin<Events = {}, T extends Constructor = Constructor>(Base: T): { new (...args: any[]): { _handlers: { [T_1 in keyof BaseEvents<Events>]?: { [x: string]: (event: EmittedEvent<BaseEvents<Events>[T_1], any>) => void; }; }; on<T_1 extends keyof BaseEvents<Events>>(eventType: T_1, callback: (event: EmittedEvent<BaseEvents<Events>[T_1], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T_1 extends keyof BaseEvents<Events>>(eventType: T_1, detail: BaseEvents<Events>[T_1]): void; bubble(target: any): string; resolve(eventType: keyof BaseEvents<Events>): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }; } & T; declare type EventListener_2 = (event: MessageEvent<any>['data']) => void; declare type Events = { load: undefined; update: undefined; }; declare type Events_2 = { update: any; frame: number | undefined; attach: undefined; detach: undefined; }; declare type Events_3 = { update: any; }; /** * Defines the extrapolation behavior outside the input range. * - "clamp": Clamps the value to the nearest endpoint within the range. * - "extend": Allows values to extend beyond the range. * @default "clamp" */ declare type Extrapolate = 'clamp' | 'extend'; /** * Defines the fill properties that * can be applied to a shape */ export declare interface FillOptions { /** * The color of the fill */ color: hex | Gradient | Pattern; /** * The opacity of the fill */ opacity?: number; } /** * Defines the fill rule of the mask */ export declare type FillRule = 'nonzero' | 'evenodd'; /** * Defines a floating point number */ export declare type float = (number & { _float: void; }) | number; /** * Converts a Float32Array to 16-bit PCM. */ export declare function floatTo16BitPCM(dataview: DataView, buffer: Float32Array, offset: number): DataView; /** * Defines the properties of a font */ export declare interface Font { /** * The size of the font */ size: number; /** * The family of the font */ family: string; /** * The weight of the font */ weight?: FontWeight; /** * The style of the font */ style?: FontStyle; } export declare const FONT_WEIGHTS: { readonly '100': "Thin"; readonly '200': "Extra Light"; readonly '300': "Light"; readonly '400': "Normal"; readonly '500': "Medium"; readonly '600': "Semi Bold"; readonly '700': "Bold"; readonly '800': "Extra Bold"; readonly '900': "Black"; }; /** * Defines all available font families */ export declare type FontFamily = keyof typeof WebFonts | string; export declare class FontManager extends Serializer { /** * The fonts that have been loaded */ loadedFonts: types_2.FontSource[]; /** * Load the font that has been initiated via the constructor */ load<T extends keyof typeof WebFonts>(options: types_2.FontSource | types_2.WebfontProperties<T>): Promise<Font>; /** * Reload all fonts */ reload(): Promise<void>; /** * Get all available local fonts, requires the * **Local Font Access API** */ static localFonts(): Promise<types_2.FontSources[]>; /** * Get common web fonts */ static webFonts(): types_2.FontSources[]; static load<T extends keyof typeof WebFonts>(options: types_2.FontSource | types_2.WebfontProperties<T>): Promise<Font>; copy(): FontManager; } /** * Defines the properties that are required * to load a new font */ export declare type FontSource = { /** * Name of the Family * @example 'Arial' */ family: string; /** * Source of the Variant * @example url(arial.ttf) */ source: string; /** * Defines the font style * @example 'italic' */ style?: FontStyle; /** * The weight of the font * @example '400' */ weight?: FontWeight; /** * The size of the font * @example 16 */ size?: number; }; /** * Defines a single font that has one or * more variants */ export declare type FontSources = { family: string; variants: FontSource[]; }; /** * Defines the style of the font */ export declare type FontStyle = 'normal' | 'italic' | 'oblique'; /** * Defines all available font subsets which * limit the number of characters */ export declare type FontSubset = 'latin' | 'latin-ext' | 'vietnamese' | 'cyrillic' | 'cyrillic-ext'; /** * Defines the source where the font is coming from */ export declare type FontType = 'local' | 'web'; /** * Defines the thickness/weight of the font */ export declare type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'; export declare const FPS_DEFAULT = 30; /** * Defines an interger that correspondes * to a point in time */ export declare type frame = (number & { _frame: void; }) | number; /** * Convert frames to milliseconds */ export declare function framesToMillis(frames: frame, fps?: number): number; /** * Convert frames into seconds */ export declare function framesToSeconds(frames: frame, fps?: number): number; export declare type GeneratorOptions = { /** * Iterates by word count */ count?: [number, number?]; /** * Iterates by group duration */ duration?: [number, number?]; /** * Iterates by number of characters within the group */ length?: [number, number?]; }; /** * Function for retrieving supported audio encoder configurations */ export declare function getAudioEncoderConfigs(settings: AudioSettings): Promise<AudioEncoderConfig[]>; /** * Function for retrieving the best supported audio * and video profiles */ export declare function getSupportedEncoderConfigs(settings: { audio: AudioSettings; video: VideoSettings; }): Promise<[VideoEncoderConfig, AudioEncoderConfig | undefined]>; /** * Function for retrieving supported video encoder * configurations */ export declare function getVideoEncoderConfigs(settings: VideoSettings): Promise<VideoEncoderConfig[]>; /** * Defines the properties of a glow */ export declare interface Glow { /** * The color of the glow */ color: hex; /** * The radius of the glow */ radius?: number; /** * The intensity of the glow */ intensity?: number; /** * The opacity of the glow */ opacity?: number; } /** * Defines the properties of a gradient */ export declare interface Gradient { /** * The type of gradient to use */ type: GradientType; /** * The stops of the gradient */ stops: GradientStop[]; } /** * Defines the properties of a gradient stop */ export declare interface GradientStop { /** * The offset of the gradient stop */ offset: number; /** * The color of the gradient stop */ color: string; } /** * Defines the type of gradient to use */ export declare type GradientType = 'linear' | 'radial'; /** * Group an array of objects by the specified key */ export declare function groupBy<T extends {}, K extends keyof T>(arr: T[], key: K): Record<T[K], T[]>; export declare class GuineaCaptionPreset extends Serializer implements CaptionPresetStrategy { readonly type: CaptionPresetType; colors: hex[]; position: RelativePoint; constructor(config?: Partial<MultiColorCaptionPresetConfig>); applyTo(track: CaptionTrack): Promise<void>; protected splitSequence(sequence: WordGroup): { segments: string[]; words: Word[][]; }; } /** * Defines a color hex value */ export declare type hex = `#${string}`; export declare function hexWithOpacity(color?: hex, opacity?: number): hex; export declare class HtmlClip extends HtmlClip_base { readonly type = "html"; track?: Track<HtmlClip>; source: HtmlSource; animations: HtmlClipAnimationOptions; /** * Access to the html document that * will be rendered to the canvas */ readonly element: HTMLImageElement; constructor(source?: File | HtmlSource, props?: HtmlClipProps); init(): Promise<void>; render(renderer: Renderer): void; copy(): HtmlClip; refresh(): this; } declare const HtmlClip_base: { new (...args: any[]): { source: VisualSource; _height?: number | Percent; _width?: number | Percent; mask?: Mask; anchorX: number; anchorY: number; scaleX: number; scaleY: number; translateX: number; translateY: number; freeTransform: boolean; x: number | Percent; y: number | Percent; rotation: number; opacity: number; filter?: string; blendMode?: BlendMode; get translate(): Point; set translate(value: Point | number); get anchor(): Point; set anchor(value: Point | number); get scale(): Point; set scale(value: Point | number); get height(): number | Percent; set height(value: Percent | number | undefined); get width(): number | Percent; set width(value: Percent | number | undefined); get position(): RelativePoint; set position(value: RelativePoint | "center"); readonly size: Size; track?: { composition?: { height?: number; width?: number; }; }; id: `${string}-${string}-${string}-${string}-${string}`; toJSON(): any; }; } & typeof Clip; export declare type HtmlClipAnimationOptions = VisualMixinAnimationOptions; export declare interface HtmlClipProps extends ClipProps, VisualMixinProps { animations?: HtmlClipAnimationOptions; } export declare class HtmlSource extends HtmlSource_base { readonly type: ClipType; /** * Access to the iframe that is required * for extracting the html's dimensions */ element: HTMLIFrameElement; constructor(); get height(): number; get width(): number; /** * Access to the html document as loaded * within the iframe. Can be manipulated with * javascript */ get document(): Document | undefined; get imageUrl(): string; thumbnail(): Promise<HTMLImageElement>; } declare const HtmlSource_base: { new (...args: any[]): { readonly height: int; readonly width: int; readonly aspectRatio: number; id: `${string}-${string}-${string}-${string}-${string}`; toJSON(): any; }; } & typeof Source; export declare class HtmlTrack extends Track<HtmlClip> { readonly type = "html"; } export declare class ImageClip extends ImageClip_base { readonly type = "image"; track?: Track<ImageClip>; element: HTMLImageElement; source: ImageSource; animations: ImageClipAnimationOptions; constructor(source?: File | ImageSource, props?: ImageClipProps); init(): Promise<void>; render(renderer: Renderer): void; copy(): ImageClip; } declare const ImageClip_base: { new (...args: any[]): { source: VisualSource; _height?: number | Percent; _width?: number | Percent; mask?: Mask; anchorX: number; anchorY: number; scaleX: number; scaleY: number; translateX: number; translateY: number; freeTransform: boolean; x: number | Percent; y: number | Percent; rotation: number; opacity: number; filter?: string; blendMode?: BlendMode; get translate(): Point; set translate(value: Point | number); get anchor(): Point; set anchor(value: Point | number); get scale(): Point; set scale(value: Point | number); get height(): number | Percent; set height(value: Percent | number | undefined); get width(): number | Percent; set width(value: Percent | number | undefined); get position(): RelativePoint; set position(value: RelativePoint | "center"); readonly size: Size; track?: { composition?: { height?: number; width?: number; }; }; id: `${string}-${string}-${string}-${string}-${string}`; toJSON(): any; }; } & typeof Clip; export declare type ImageClipAnimationOptions = VisualMixinAnimationOptions; export declare interface ImageClipProps extends ClipProps, VisualMixinProps { animations?: ImageClipAnimationOptions; } export declare type ImageMimeType = keyof (typeof SUPPORTED_MIME_TYPES)['IMAGE']; /** * Defines the properties of an image */ export declare interface ImageOptions { /** * The x coordinate of the image */ x?: number | Percent; /** * The y coordinate of the image */ y?: number | Percent; /** * The width of the image */ width?: number | Percent; /** * The height of the image */ height?: number | Percent; } export declare class ImageSource extends ImageSource_base { readonly type: ClipType; element: HTMLImageElement; get height(): number; get width(): number; thumbnail(): Promise<HTMLImageElement>; } declare const ImageSource_base: { new (...args: any[]): { readonly height: int; readonly width: int; readonly aspectRatio: number; id: `${string}-${string}-${string}-${string}-${string}`; toJSON(): any; }; } & typeof Source; declare class ImageTrack_2 extends Track<ImageClip> { readonly type = "image"; } export { ImageTrack_2 as ImageTrack } export declare type InsertMode = (typeof insertModes)[number]; declare const insertModes: readonly ["DEFAULT", "STACK"]; declare interface InsertStrategy<T extends InsertMode> { readonly mode: T; add(clip: Clip, track: Track<Clip>, index?: number): void; update(clip: Clip, track: Track<Clip>): void; offset(time: Timestamp, track: Track<Clip>): void; } /** * Defines a number without decimal places */ export declare type int = (number & { _int: void; }) | number; /** * Converts an AudioBuffer to a Float32Array. * For 2 channels it will result in something like: * [L[0], R[0], L[1], R[1], ... , L[n], R[n]] */ export declare function interleave(input: AudioBuffer): Float32Array; export declare class IOError extends BaseError { } /** * Check whether a given value is a class */ export declare function isClass(value: any): boolean; declare interface KeyFrame<T> { value: T; frame: number; easing?: Easing; } declare interface KeyframeOptions<K, T> { key: K; extrapolate?: Extrapolate; frames: KeyFrame<T>[]; easing?: Easing; } export declare enum Language { en = "en", de = "de" } export declare class Library extends Library_base { sources: Source[]; add(...sources: (Source | Promise<Source>)[]): Promise<this>; remove(source: Source | string): this; get<T extends Source>(key: string): T; at<T extends Source>(index: number): T; } declare const Library_base: { new (...args: any[]): { _handlers: { '*'?: { [x: string]: (event: EmittedEvent<any, any>) => void; } | undefined; error?: { [x: string]: (event: EmittedEvent<Error, any>) => void; } | undefined; add?: { [x: string]: (event: EmittedEvent<string, any>) => void; } | undefined; remove?: { [x: string]: (event: EmittedEvent<string, any>) => void; } | undefined; }; on<T extends "*" | "error" | keyof LibraryEvents>(eventType: T, callback: (event: EmittedEvent<BaseEvents<LibraryEvents>[T], any>) => void): string; off(id?: string | "*", ...ids: string[]): void; emit<T extends "*" | "error" | keyof LibraryEvents>(eventType: T, detail: BaseEvents<LibraryEvents>[T]): void; bubble(target: any): string; resolve(eventType: "*" | "error" | keyof LibraryEvents): (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void; }; } & Constructor; declare type LibraryEvents = { add: string; remove: string; }; /** * Defines the cap style of the stroke */ export declare type LineCap = 'butt' | 'round' | 'square'; /** * Defines the join style of the stroke */ export declare type LineJoin = 'bevel' | 'round' | 'miter'; export declare class Mask { path: Path2D; fillRule?: FillRule; } export declare class MediaClip extends Clip { source: AudioSource; element?: HTMLAudioElement | HTMLVideoElement; /** * Is the media currently playing */ playing: boolean; /** * Trimmed start and stop values */ range: [Timestamp, Timestamp]; constructor(props?: MediaClipProps); /** * Defines the transcript of the video/audio. * Will be trimmed to the clip range. * If the duration is not set, the transcript will be returned. */ get transcript(): Transcript | undefined; set transcript(transcript: Transcript | undefined); get start(): Timestamp; get stop(): Timestamp; get duration(): Timestamp; set duration(time: frame | Timestamp); /** * Defines if the clip is currently muted * @default false */ get muted(): boolean; set muted(state: boolean); trim(start?: frame | Timestamp, stop?: frame | Timestamp): this; /** * Set the media playback to a given time */ seek(time: Timestamp): Promise<void>; exit(): void; /** * Returns a slice of a media clip with trimmed start and stop */ subclip(start?: frame | Timestamp, stop?: frame | Timestamp): this; /** * Number between 0 and 1 defining the volume of the media * @default 1; */ get volume(): float; set volume(volume: float); copy(): MediaClip; split(time?: frame | Timestamp): Promise<this>; /** * Generates a new caption track for the current clip using the specified captioning strategy. * @param strategy An optional CaptionPresetStrategy to define how captions should be generated. */ createCaptions(strategy?: CaptionPresetStrategy | (new () => CaptionPresetStrategy)): Promise<CaptionTrack>; /** * Remove silences from the clip * * @param options - Options for silence detection */ removeSilences(options?: SilenceRemoveOptions): Promise<MediaClip[]>; } export declare interface MediaClipProps extends ClipProps { playing?: boolean; transcript?: Transcript; volume?: number; muted?: boolean; } export declare class MediaTrack<Clip extends MediaClip> extends Track<MediaClip> { clips: Clip[]; seek(time: Timestamp): Promise<void>; /** * Remove silences from all clips in the track * * @param options - Options for silence detection */ removeSilences(options?: SilenceRemoveOptions): Promise<void>; } declare type MimeType_2 = ImageMimeType | VideoMimeType | AudioMimeType; export { MimeType_2 as MimeType } export declare type MixinType<T extends (...args: any[]) => { new (...args: any[]): any; }> = InstanceType<ReturnType<T>>; export declare type MultiColorCaptionPresetConfig = { colors: hex[] | undefined; } & DefaultCaptionPresetConfig; export declare class OpusEncoder { output: EncodedOpusChunkOutputCallback; error: WebCodecsErrorCallback; config?: OpusEncoderConfig; private encoder?; private opus?; private meta?; /** * Create a new OpusEncoder for encoding pcm to opus * @param init encoder callbacks */ constructor(init: OpusEncoderInit); /** * Configure the encoder. **Note** these values must match the samples to encode * @param config The sample rate and channel count to use */ configure(config: OpusEncoderConfig): Promise<void>; /** * Encode the samples synchronously (this is a blocking event) * @param samples The data to encode */ encode({ data, numberOfFrames, timestamp }: OpusEncoderSamples): void; } export declare type OpusEncoderConfig = Omit<AudioEncoderConfig, 'codec' | 'bitrate'>; export declare type OpusEncoderInit = { output: EncodedOpusChunkOutputCallback; error: WebCodecsErrorCallback; }; export declare type OpusEncoderSamples = { /** * 16-bit signed integer array of interleaved audio samples */ data: Int16Array; /** * The number of frames (usually total samples / number of channels) */ numberOfFrames: number; /** * Defines the timestamp of the first frame */ timestamp?: number; }; declare type OverrideValues<T, U> = Omit<T, keyof U> & Pick<U, Extract<keyof U, keyof T>>; /** * Make sure a mimetype is valid * @param mimeType The mimetype to check * @returns A valid mimetype */ export declare function parseMimeType(mimeType?: string | null): MimeType_2; /** * Defines the properties of a pattern */ export declare interface Pattern { /** * The image to use for the pattern */ image: HTMLImageElement | HTMLCanvasElement; /** * The repetition of the pattern */ repetition: PatternRepetition; } /** * Defines the repetition of the pattern */ export declare type PatternRepetition = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; /** * Defines a string that starts with a number * and ends with a `%` character * @example '50%' */ export declare type Percent = `${number}%`; /** * Defines the properties of a point */ export declare interface Point { /** * The x coordinate of the point */ x: number; /** * The y coordinate of the point */ y: number; } /** * Generate a random value between two numbers */ export declare function randInt(min: number, max: number | undefined): number; /** * Defines the properties of a rectangle */ export declare interface Rect extends Partial<Point> { /** * The width of the rectangle */ width: number | Percent; /** * The height of the rectangle */ height: number | Percent; } export declare class RectangleClip extends ShapeClip { track?: Track<RectangleClip>; animations: RectangleClipAnimationOptions; rad