motiontext-renderer
Version:
Web-based animated caption/subtitle renderer with plugin system
153 lines (152 loc) • 4.39 kB
TypeScript
import { Layout, TextStyle, BoxStyle, EffectScope, LayoutConstraints } from './layout';
import { PluginSpec } from './plugin-v3';
export declare const SCENARIO_VERSION: "2.0";
export type TimeRange = [number, number];
export type DefineReference<T> = T | string;
export interface DefineAsset {
type: 'font' | 'image' | 'video' | 'audio';
family?: string;
src: string;
url?: string;
preload?: boolean;
integrity?: string;
fallback?: string[];
alt?: string;
mimeType?: string;
loop?: boolean;
volume?: number;
display?: 'swap' | 'fallback' | 'optional' | 'block';
}
export interface AssetContext {
baseUrl?: string;
fonts: Map<string, FontFace>;
images: Map<string, string>;
videos: Map<string, string>;
audios: Map<string, string>;
}
export interface DefineSection {
[key: string]: any;
}
export interface Timebase {
unit: 'seconds';
fps?: number;
}
export interface Stage {
baseAspect: '16:9' | '9:16' | 'auto';
safeArea?: {
top?: number;
bottom?: number;
left?: number;
right?: number;
};
}
export interface Behavior {
preloadMs?: number;
resizeThrottleMs?: number;
snapToFrame?: boolean;
}
export type TrackType = 'subtitle' | 'free';
export type OverlapPolicy = 'push' | 'stack' | 'ignore';
export interface Track {
id: string;
type: TrackType;
layer: number;
overlapPolicy?: DefineReference<OverlapPolicy>;
defaultStyle?: DefineReference<TextStyle>;
defaultBoxStyle?: DefineReference<BoxStyle>;
defaultConstraints?: DefineReference<LayoutConstraints>;
}
export interface Cue {
id: string;
track: string;
domLifetime?: DefineReference<TimeRange>;
root: Node;
}
export interface BaseNode {
id: string;
eType: 'group' | 'text' | 'image' | 'video';
displayTime?: DefineReference<TimeRange>;
baseTime?: DefineReference<TimeRange>;
layout?: DefineReference<Layout>;
style?: DefineReference<TextStyle>;
pluginChain?: DefineReference<PluginSpec[]>;
effectScope?: DefineReference<EffectScope>;
}
export interface GroupNode extends BaseNode {
eType: 'group';
children?: Node[];
boxStyle?: DefineReference<BoxStyle>;
}
export interface TextNode extends BaseNode {
eType: 'text';
text: DefineReference<string>;
}
export interface ImageNode extends BaseNode {
eType: 'image';
src: DefineReference<string>;
alt?: DefineReference<string>;
}
export interface VideoNode extends BaseNode {
eType: 'video';
src: DefineReference<string>;
autoplay?: DefineReference<boolean>;
muted?: DefineReference<boolean>;
loop?: DefineReference<boolean>;
}
export type Node = GroupNode | TextNode | ImageNode | VideoNode;
export interface Scenario {
version: '2.0';
pluginApiVersion?: '3.0';
timebase: Timebase;
stage: Stage;
behavior?: Behavior;
define?: DefineSection;
tracks: Track[];
cues: Cue[];
}
export interface ResolvedNode extends Omit<BaseNode, 'displayTime' | 'baseTime' | 'layout' | 'style' | 'pluginChain' | 'effectScope'> {
displayTime: TimeRange;
baseTime?: TimeRange;
layout?: Layout;
style?: TextStyle;
pluginChain?: PluginSpec[];
effectScope?: EffectScope;
}
export interface ResolvedTextNode extends ResolvedNode {
eType: 'text';
text: string;
}
export interface ResolvedImageNode extends ResolvedNode {
eType: 'image';
src: string;
alt?: string;
}
export interface ResolvedVideoNode extends ResolvedNode {
eType: 'video';
src: string;
autoplay?: boolean;
muted?: boolean;
loop?: boolean;
}
export interface ResolvedGroupNode extends ResolvedNode {
eType: 'group';
children?: ResolvedNodeUnion[];
boxStyle?: BoxStyle;
}
export type ResolvedNodeUnion = ResolvedTextNode | ResolvedImageNode | ResolvedVideoNode | ResolvedGroupNode;
export interface AssetManager {
baseUrl?: string;
fonts: Map<string, FontFace>;
images: Map<string, string>;
videos: Map<string, string>;
audios: Map<string, string>;
}
export type ScenarioV2 = Scenario;
export type NodeV2 = Node;
export type CueV2 = Cue;
export type TrackV2 = Track;
export type TimebaseV2 = Timebase;
export type StageSpecV2 = Stage;
export type BehaviorSpecV2 = Behavior;
export type PluginSpecV2 = PluginSpec;
//# sourceMappingURL=scenario-v2.d.ts.map