declare const BRAND_MODES: readonly ["dark", "light"]; declare const BRAND_CASES: readonly ["sentence", "upper", "title"]; declare const BRAND_MOTIONS: readonly ["snappy", "punchy", "bouncy", "smooth", "calm"]; declare const BRAND_SURFACES: readonly ["soft", "flat", "glass", "bold", "sketch", "paper", "clay", "pixel"]; declare const BRAND_TEXTURES: readonly ["none", "grid", "glow", "grain", "paper", "board", "parchment", "pixel", "studio"]; type BrandMode = (typeof BRAND_MODES)[number]; type BrandCase = (typeof BRAND_CASES)[number]; type BrandMotion = (typeof BRAND_MOTIONS)[number]; type BrandSurface = (typeof BRAND_SURFACES)[number]; type BrandTexture = (typeof BRAND_TEXTURES)[number]; /** Colour roles. ink is always the dark one and paper the light one; `mode` says which is the ground. */ interface BrandColors { /** The one thing that matters on screen. */ accent: string; /** Markers, highlights, a second series. */ accent2: string; ink: string; paper: string; /** Cards and panels on the ground. */ surface?: string; positive?: string; negative?: string; } /** Font specs ("Inter:900", "Playfair Display:400i") — always bundled faces. */ interface BrandFonts { display: string; text: string; mono: string; /** An occasional accent face (a serif italic word). */ accent?: string; } interface BrandStyle { name: string; title: string; description: string; mode: BrandMode; colors: BrandColors; fonts: BrandFonts; /** The faces the source named, when they had to be mapped to bundled ones ("Geist" → Inter). */ fontsNamed?: string[]; case: BrandCase; motion: BrandMotion; surface: BrandSurface; texture: BrandTexture; /** Corner radius of cards on a 1080-wide canvas, px. */ radius: number; rules: string[]; /** The DESIGN.md prose (without its front matter). */ body: string; source: "builtin" | "user"; path?: string; updatedAt?: number; } /** The tokens a placed program carries — the runtime's defaults follow them. */ interface ProgramStyle { name?: string; mode: BrandMode; colors: BrandColors; fonts: BrandFonts; case: BrandCase; motion: BrandMotion; surface: BrandSurface; texture: BrandTexture; radius: number; } /** Plain aliases for the editor's id and time types. */ type ID = string; type Seconds = number; /** * Motion graphics as programs. A graphic on the timeline can be code instead of a * template: `function frame(t, $)` returning the SVG of one frame, a pure function of the * clip's time — the way the video engines MONARC learned from draw a film (`seek(t)` * builds any frame from scratch). The designer model writes the program for one shot * (what is said over it, the words' times, the region it owns, the media it may show); * the desktop runs it in a sandboxed worker and draws each frame through the same * renderer in the player, the export and on the phone. * * Programs live on title clips (`title.program`), so the layer stack, transitions, * keyframes, trims and the title bake work for them unchanged. */ interface GraphicWord { w: string; /** Start, clip seconds. */ s: Seconds; /** End, clip seconds. */ e: Seconds; } /** A box in the program's canvas, px. */ interface GraphicBox { x: number; y: number; w: number; h: number; } /** A hole the renderer keeps clear in every frame so footage below shows through (a face bubble). */ interface GraphicWindow extends GraphicBox { kind: "circle" | "rect"; /** Corner radius for a rect window, px. */ r?: number; /** A ring drawn round the hole. */ ring?: { color: string; width: number; }; } interface TitleProgram { version: 1; /** Plain JavaScript defining `function frame(t, $)` (and optionally `function setup($)`). */ code: string; /** The canvas the code draws on, px — the project's frame size when it was written. */ width: number; height: number; /** Faces the code uses, "Family:weight" with an "i" for italic ("Inter:800", "Playfair Display:400i"). */ fonts: string[]; /** The words spoken over the clip, in clip seconds — what `$.at(word)` reads. */ words?: GraphicWord[]; /** Named moments, clip seconds — `$.beat(name)`. */ beats?: Record; /** Free data the code reads as `$.data` (numbers, labels). */ data?: Record; /** Colours, the accent first — `$.palette` / `$.c`. */ palette?: string[]; /** Asset ids of pictures the code shows with `$.image(id, …)`. */ media?: ID[]; /** The part of the canvas the graphic owns (a split's top panel); drawing outside it is clipped. */ region?: GraphicBox; /** A hole kept clear for the footage below. */ window?: GraphicWindow; /** The picture no longer changes after this many seconds (the export holds the last frame). */ holdAfter?: Seconds; /** What it shows, one or two lines — the inspector and the agent read it. */ brief?: string; /** Which model (or person) wrote the code. */ author?: string; /** The layout or placement it was designed for (face, split, broll, card, cutaway, overlay, panel, full, bubble) — a repair keeps its rules. */ layout?: string; /** The brand style's tokens: the runtime's colours, faces, radius, surfaces and spring feel follow them. */ style?: ProgramStyle; } /** What a creator (or an agent) may set on one part. */ interface MotionSpec { /** Entrance move. */ in?: string; /** Exit move (the move played backwards), or "none" to stay to the end. */ out?: string; /** Seconds the entrance takes. */ dur?: number; /** Seconds the exit takes. */ outDur?: number; ease?: string; outEase?: string; /** The side a move comes from. */ from?: string; /** The side an exit leaves to. */ outFrom?: string; /** How far a move travels, px at 1080. */ distance?: number; /** Motion blur on the way in and out. */ blur?: boolean; /** A loop while the part holds. */ idle?: string; /** Hits: "pulse@1.2, shake@now" or [{fx, at}] — at is seconds, a beat name or a spoken word. */ emphasis?: string | Array<{ fx: string; at: number | string; }>; /** Keyframes: [{t, x, y, s, sx, sy, r, skx, op, blur, ease}] in clip seconds (negative from the end), px at 1080. */ keys?: Array>; /** Seconds added to the part's start. */ delay?: number; /** Clip seconds the part starts (replaces the item's). */ at?: number; /** Clip seconds the exit starts (negative from the end). */ outAt?: number; /** 0–2: how far, how big, how much rotation. */ intensity?: number; /** The pivot for scale, rotation and skew. */ origin?: string; /** Text: animate it whole, or by lines, words or letters. */ split?: string; order?: string; /** Seconds between units. */ stagger?: number; outStagger?: number; } /** Overrides as they arrive from a command line, an agent or JSON: values not yet read (normalizeMotion reads them). */ type MotionInput = Record>; /** * Interactive states for : a graphic's timeline cut into named stretches — idle, hover, * press, loading, success — that page events and code switch between. Each state plays its stretch once * (then stays on its last frame, or moves on to `next`), loops it, or holds one frame. Times are seconds or * the item's beat names, so an item that names its beats ("hover", "press") declares its states in * item.json and works with no setup: * * "states": { "idle": { "from": "idle", "to": "hover", "play": "loop" }, * "hover": { "from": "hover", "to": "press", "play": "once" }, * "press": { "from": "press", "to": "loading", "play": "once", "next": "loading" } }, * "on": "pointerenter(idle): hover; pointerleave(hover): idle; click: press" * * Pure functions: parsed and resolved here, played by the element. */ declare const STATE_PLAYS: readonly ["once", "loop", "hold"]; type StatePlay = (typeof STATE_PLAYS)[number]; interface StateDef { /** Where the stretch starts: seconds, a beat name, "start" or "end". Default: the start. */ from?: number | string; /** Where it ends: seconds, a beat name, "start" or "end". Default: the end. */ to?: number | string; /** once: play it and stay on its last frame (or go to `next`); loop: repeat it; hold: show `from` and stay. */ play?: StatePlay; /** The state to go to when a `once` stretch finishes. */ next?: string; } /** * Packs and items: the library format. A pack is a folder of items that share a look and a * helper file; an item is one motion graphic — `item.json` (what it is, the props it takes, * how long it runs, the aspects it fits) and `frame.js` (a `function frame(t, $)` program that * reads its props as `$.data`). Nothing here touches the filesystem or the DOM, so the CLI, * the MCP server and the browser player all build programs the same way. */ declare const CATEGORIES: readonly ["lower-third", "title", "cta", "stat", "list", "quote", "end-card", "callout", "social", "chart", "logo", "transition", "banner", "timer", "text", "captions", "scene"]; type Category = (typeof CATEGORIES)[number]; /** overlay: transparent, sits over footage · full: draws its own ground (a card, a scene). */ type Placement = "overlay" | "full"; declare const ASPECTS: { readonly "16:9": readonly [1920, 1080]; readonly "9:16": readonly [1080, 1920]; readonly "1:1": readonly [1080, 1080]; readonly "4:5": readonly [1080, 1350]; }; type Aspect = keyof typeof ASPECTS; type PropType = "text" | "longtext" | "number" | "boolean" | "choice" | "color" | "list" | "image" | "icon"; /** One field of a list prop's rows ({ label: "text", value: "number" }). */ type ListField = "text" | "number"; interface PropSpec { type: PropType; label?: string; description?: string; default?: unknown; /** choice: the values allowed. */ options?: string[]; /** number: bounds and step. */ min?: number; max?: number; step?: number; /** text / longtext: the most characters that still fit the design. */ maxLength?: number; /** list: rows are text (the default) or objects with these fields. */ of?: ListField | Record; minItems?: number; maxItems?: number; /** Shown only when another prop has a value ({ prop: "side", is: ["left"] }). */ when?: { prop: string; is: unknown[]; }; } interface ItemManifest { /** Unique in its pack: lowercase words joined by hyphens ("lower-third"). */ id: string; name: string; description: string; category: Category; tags?: string[]; placement: Placement; /** Seconds. */ duration: { default: number; min?: number; max?: number; }; /** The aspects the design is laid out for; all four when omitted. */ aspects?: Aspect[]; props: Record; /** Named moments the code reads with $.beat(name): seconds from the start, or from the end when negative. */ beats?: Record; /** Faces the code names besides the brand style's (Family:weight, "i" for italic). */ fonts?: string[]; /** The style it is shown in when none is asked for. */ style?: string; /** The picture stops changing after this many seconds before the end (renders hold the last frame). */ holdFromEnd?: number; /** * An editor can use it as the look of a caption track: it draws the words it is given one cue at a time (the * `cues` build option), fits any cue, and draws a frame within the caption speed budget (CAPTION_FRAME_MS). */ captionLook?: boolean; /** The parts a creator can animate on their own (name → what it is): the names motion overrides use. */ parts?: Record; /** Libraries the code uses besides the motion kit: "3d" (scene3d), "world" (country shapes). */ libs?: LibraryName[]; /** Faces whose glyphs 3D text is built from: brand roles ("display") or specs ("Anton:400"). Default: display. */ faces3d?: string[]; /** * Interactive states for : named stretches of the timeline (beat names or seconds), each * played once, looped or held — { "idle": { "from": "idle", "to": "hover", "play": "loop" }, … }. */ states?: Record; /** The page events that switch states by default: "pointerenter(idle): hover; click: press". */ on?: string; } /** An item ready to build: its manifest, the pack it belongs to and its own code. */ interface MotionItem extends ItemManifest { pack: string; /** "essentials/lower-third". */ ref: string; /** The pack's helpers and the item's frame.js. The kit and libraries are added when it is built. */ code: string; libs: LibraryName[]; } declare const LIBRARY_NAMES: readonly ["3d", "world", "three"]; type LibraryName = (typeof LIBRARY_NAMES)[number]; /** What a caller may pass as a style: a built-in name, DESIGN.md text, a BrandStyle or program tokens. */ type StyleInput = string | BrandStyle | ProgramStyle | null | undefined; interface StyleOverrides { accent?: string; accent2?: string; ink?: string; paper?: string; surface?: string; mode?: "dark" | "light"; display?: string; text?: string; mono?: string; } interface BuildOptions { props?: Record; style?: StyleInput; colors?: StyleOverrides; /** An aspect name, or a canvas size in px. */ aspect?: Aspect | { width: number; height: number; }; /** Seconds; the item's default when omitted. */ duration?: number; /** Words spoken over the graphic (clip seconds) — items land their text on them. */ words?: GraphicWord[]; /** * An editor's caption cues over those words (clip seconds, in order): a caption look shows one cue at a time, * on screen exactly while the cue is, and never puts words of two cues together. Words said in no cue are not * captioned. Items that are not caption looks ignore them. */ cues?: CaptionCue[]; /** Named moments, overriding the item's. */ beats?: Record; /** Image props as data: URLs, by prop name (the caller loads the files). */ media?: Record; /** How each part moves: { "*": {…every part}, name: { in: "pop", ease: "bouncy", … } } (see MOVES). */ motion?: MotionInput; /** A choreography mood (energetic, elegant, playful, cinematic, glitchy, minimal, retro, kinetic). */ mood?: string; /** A seed for a new choreography: every seed moves differently, the same seed the same way. */ seed?: number; /** Plays every move faster (2) or slower (0.5). */ speed?: number; /** * How three.js scenes (renderThree) are drawn: "svg" (the default — in the sandbox, as SVG, no GPU), * "webgl" (three.js's WebGLRenderer in headless Chrome, in software: identical everywhere) or "gpu" * (the same on the machine's graphics card). The host draws the WebGL ones; see src/node/three-gl.ts. */ three?: "svg" | "webgl" | "gpu"; } /** One caption cue: when it comes on and goes, clip seconds. */ interface CaptionCue { s: number; e: number; } /** * Volito in the browser: play any item (or your own program) live on a canvas — the same * sandboxed worker and SVG → image → canvas path MONARC PRO's player uses, so a web page * shows exactly what a render will be. * * import { loadRegistry, findItem, createPlayer } from "volito/browser"; * const reg = await loadRegistry(); * const player = await createPlayer(canvas, findItem(reg, "essentials/lower-third"), { props: { name: "Priya" }, style: "ember" }); * player.play(); * * Fonts and the registry load from `base` (the package's folder on jsDelivr by default); serve the * package's fonts/ and dist/registry.json yourself and pass their folder to keep it offline. */ declare const VERSION: string; /** Where fonts/ and dist/registry.json are fetched from unless told otherwise. */ declare const CDN_BASE: string; interface PlayerOptions extends BuildOptions { /** Where fonts/ (and dist/registry.json) live — the package on jsDelivr by default. */ base?: string; fps?: number; /** Play again from the start at the end (true). */ loop?: boolean; /** A colour drawn under the graphic; transparent by default. */ background?: string; /** Called with the program's warnings (text off the frame, props that do not fit) whenever they change. */ onWarnings?: (warnings: string[]) => void; /** Called with a failure (the program threw, a frame did not parse). */ onError?: (err: Error) => void; /** Called on every drawn frame with its time. */ onFrame?: (t: number) => void; } declare class MotionPlayer { readonly canvas: HTMLCanvasElement; private item; private opts; private built; private worker; private env; /** Every face the package has (fonts/faces.json), and the files the worker has loaded. */ private all; private loaded; private readonly css; private widening; private gone; private lastT; private raf; private started; private offset; private playing; private drawing; private lastSvg; private warned; private constructor(); static create(canvas: HTMLCanvasElement, item: MotionItem, opts?: PlayerOptions): Promise; /** Seconds the graphic runs. */ get duration(): number; /** The time shown now, seconds. */ get time(): number; get program(): TitleProgram; private get base(); private load; private startWorker; /** The faces a frame draws with. */ private facesOf; /** The @font-face rules for a set of faces, as data: URLs; one string per set, made once. */ private cssOf; /** A frame drew with a face the worker lacks (so measured without it): restart it with that face, then redraw. */ private widen; private report; /** Change props, style, aspect or duration; the frame redraws. */ update(opts: Partial): Promise; /** Play another item (or program) with the current options. */ setItem(item: MotionItem | string): Promise; /** Draw the frame at `t` seconds. */ draw(t: number): Promise; play(): void; pause(): void; seek(t: number): Promise; destroy(): void; } /** * : a Volito graphic playing live in any web page, with optional controls and aspect * tabs. It wraps volito/browser's MotionPlayer (the same sandboxed engine a render uses) and keeps * its own clock, so it can play at any rate, inside a range, and stop with an `ended` event. * * * * * It starts when it comes near the screen (loading="eager" to start at once), pauses off screen * and in a hidden tab, and does not autoplay for readers who prefer reduced motion. */ /** Events a fires. None bubbles, like a media element's. */ interface VolitoPlayerEventMap { /** The graphic loaded and drew its first frame. */ ready: CustomEvent<{ duration: number; width: number; height: number; aspect: string; }>; /** About ten times a second while playing, and on every seek. */ timeupdate: CustomEvent<{ currentTime: number; }>; play: CustomEvent; pause: CustomEvent; /** Playback reached the end of the range without `loop`. */ ended: CustomEvent; durationchange: CustomEvent<{ duration: number; }>; /** The shown aspect changed (a tab, or the aspect attribute). */ aspectchange: CustomEvent<{ aspect: string; }>; /** The program's warnings changed: text off the frame, props that do not fit. */ warnings: CustomEvent<{ warnings: string[]; }>; /** The item could not load or a frame failed; `message` says why. */ error: CustomEvent<{ message: string; error: unknown; }>; /** The interactive state changed (a page event, `state = …` or a `next`). */ statechange: CustomEvent<{ from: string | null; to: string; }>; } declare const Base: typeof HTMLElement; declare class VolitoPlayer extends Base { static get observedAttributes(): string[]; private readonly shadow; private readonly el; private mp; private itemName; private starting; /** Bumped whenever a load is abandoned (a new item, disconnecting), so a late one throws itself away. */ private gen; private jsProps; private jsBrand; private jsProgram; private extra; private warn; private t; private dur; private playing; private atEnd; private anchorT; private anchorWall; private raf; private lastEmit; private inflight; private busy; /** Someone wants it playing (autoplay or play()); off screen it waits, a pause() clears it. */ private intent; private scrubResume; private onScreen; private shownAspect; private firstAspect; private queued; private itemObj; private stateNow; private reflecting; private triggers; private readonly bound; private io; private ro; private resizeTimer; private readonly onVisibility; constructor(); /** The item: "pack/id" or an id. */ get item(): string; set item(v: string); /** Your own program instead of an item: `function frame(t, $) { … }` (see `volito api`). */ get program(): string | null; set program(code: string | null); /** Props as an object; setting it overrides the props attribute. */ get props(): Record | undefined; set props(v: Record | undefined); /** A built-in style name, DESIGN.md text, or style tokens; a name also sets the brand attribute. */ get brand(): StyleInput; set brand(v: StyleInput); /** Anything else a build takes (words, beats, media, motion…), under the attributes. */ get options(): Partial; set options(v: Partial); /** The aspect shown: 16:9, 9:16, 1:1, 4:5 or WIDTHxHEIGHT. */ get aspect(): string; set aspect(v: string); get currentTime(): number; set currentTime(v: number); get duration(): number; get paused(): boolean; get ended(): boolean; get ready(): boolean; get loop(): boolean; set loop(v: boolean); get playbackRate(): number; set playbackRate(v: number); /** The program's current warnings. */ get warnings(): string[]; /** The underlying volito/browser player, once ready. */ get player(): MotionPlayer | null; connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(name: string, old: string | null, value: string | null): void; /** Load the graphic now (it otherwise waits until it is near the screen). */ load(): Promise; /** Play from the current time (or from the start after the end); off screen it starts when shown. */ play(): Promise; pause(): void; /** Show the frame at `t` seconds. */ seek(t: number): Promise; private start; private resume; /** Stop the clock; `announce` fires pause (a pause by someone, not the page going off screen). */ private stopClock; /** Draw a frame unless one is still drawing (while playing) — `wait` draws after it instead. */ private paint; private queue; private flush; /** Rebuild the program with the current options, keeping the time shown; `resize` for a new aspect. */ private reload; private showAspect; /** Match the canvas to the frame's size on screen; a big change redraws at the new size. */ private fitCanvas; private initialAspect; private aspects; private rangeStart; private rangeEnd; /** The current interactive state, or "" when the graphic has none. Setting it switches state. */ get state(): string; set state(v: string); /** The states this graphic has: the states attribute, else the item's own. */ stateDefs(): Record | undefined; /** Switch to a state: play its stretch once, loop it, or hold its first frame. */ setState(name: string): Promise; private enterInitialState; /** Beat times for state stretches: the item's beats, moved by the beats attribute. */ private beatTimes; /** Listen for the page events in the on attribute (else the item's "on") and switch state on them. */ private bindTriggers; private unbindTriggers; private base; private resolveItem; private buildOptions; private playerOptions; private sizeFor; private setSize; /** The live canvas on top; the poster (a still with the graphic baked in) out of the way. */ private showCanvas; /** The still for this aspect, if there is one, in place of the canvas until a frame is drawn. */ private showPoster; private posterFor; private renderUI; private chooseTab; private onTabKey; private onKey; private updatePlay; private updateTime; private status; private fail; private safe; private emit; } /** Register the element (done on import as ); call with another tag to use your own. */ declare function defineVolitoPlayer(tag?: string): void; /** * volito/player: the element. Importing this module registers it. * * import "volito/player"; * // * * Or straight from a CDN, with no build step: * */ declare global { interface HTMLElementTagNameMap { "volito-player": VolitoPlayer; } } export { CDN_BASE, MotionPlayer, VERSION, VolitoPlayer, defineVolitoPlayer }; export type { PlayerOptions, VolitoPlayerEventMap };