import { type ReplayController } from "./replay.control.ts"; import { type ReplayGroup } from "./replay.ts"; import type { ReplayChange, ReplayLook, ReplaySettings, ReplayTimeline } from "./replay.types.ts"; import type { Language, ScoreOptions, SurfaceOptions } from "./types.ts"; /** The controls' stylesheet: written once beside the controls, scoped to them, in the page's own colours. */ export declare const REPLAY_STYLE: string; /** A replay attached to a container: the controller, the stage the drawing goes in, and how to draw it again. */ export interface ReplayView { controller: ReplayController; /** The element the drawing is written into. */ stage: HTMLElement; /** Draw the surface and the frame the clock is at, with new options (a theme that changed, a score that moved). */ draw(options: SurfaceOptions | ScoreOptions): void; /** Stop the clock and the listeners, and empty the container. */ destroy(): void; } /** What a painter is given: where the drawing is, what it was drawn from, and how to draw it whole again. */ export interface PainterSource { doc: Document; timeline: ReplayTimeline; look: ReplayLook; /** The drawing the replay's groups are in (`svg.kyogijo`), or `null` before it is written. */ svg(): SVGSVGElement | null; /** The options it was drawn with, its `id` among them. */ options(): SurfaceOptions | ScoreOptions; language(): Language; /** Which groups of the replay are in this drawing: all when missing (a 3D view stands the players up and leaves the rest on the floor). */ keep?: (group: ReplayGroup) => boolean; /** Write the drawing whole again at a time; the painter binds itself to it afterwards. */ redraw(t: number): void; } /** The painter of a replay's drawing: `paint` moves the marks to a time; `bind` matches the elements of a drawing just written at `t`. */ export interface ReplayPainter { paint(t: number): void; bind(t: number): void; } /** * The painter of a replay: it moves the marks that move and nothing else. A mark that comes or goes (an object that enters, an event that begins) draws the replay's own group * again, never the surface; a group whose marks cannot be matched to elements one for one is drawn again each time. */ export declare function replayPainter(source: PainterSource): ReplayPainter; /** What a driver is given: how to paint a time, where its keys are heard, and what it labels. */ export interface DriverSource { /** Move the drawing to a time. Called on every change of the clock, with the change (what moved it, and the state after). */ paint(t: number, change?: ReplayChange): void; language: Language; /** The element whose keys play, step and seek (its descendants too): the stage and the bar in a flat replay, the bar alone over a 3D view. */ keysOn: HTMLElement; /** The element that says what the replay is doing (`data-state`, `data-motion`). */ holder: HTMLElement; /** The element that names the replay and points at its key help (the flat drawing's stage), if any. */ labelled?: HTMLElement; /** The element whose being in sight lets the clock run: no frame is asked for while it is scrolled out of sight. */ seen?: Element; /** The key help: `keys` and `keysStep` by default, `keysTurn` and `keysTurnStep` over a 3D view. */ help?: "flat" | "turn"; /** Where frames are asked for: the page's `requestAnimationFrame` by default; a 3D view lends its own, so that a turning view and its replay share one frame. */ frames?: { request(callback: FrameRequestCallback): number; cancel(id: number): void; }; } /** The page's side of a replay without its drawing: the clock on animation frames, the controls, the keys, the live region, a hidden page and reduced motion. */ export interface ReplayDriver { controller: ReplayController; /** The style, the key help, the bar and the live region, in that order, for the caller to put in the page. */ parts: { style: HTMLStyleElement; hint: HTMLElement; bar: HTMLElement; live: HTMLElement; }; /** The words changed: the controls are made again. */ setLanguage(language: Language): void; /** The play, pause or step the keys of a 3D view's stage ask for, by the names of the keys: the same moves as the bar's keys. */ key(event: KeyboardEvent, scope: "stage" | "bar"): boolean; destroy(): void; } /** Make the clock, the controls and the keys of a replay. Nothing runs until the reader (or `autoplay`) plays it, and nothing runs while it is paused, hidden or out of sight. */ export declare function replayDriver(doc: Document, timeline: ReplayTimeline, settings: ReplaySettings, source: DriverSource): ReplayDriver; /** * Attach a replay to a container: the stage with the drawing, the controls under it, the keyboard and the live region. The drawing is written once * and then only the marks that move are moved, on `requestAnimationFrame`; a mark that comes or goes (an object that enters, an event that * begins) redraws the replay's own layers, never the surface. With `prefers-reduced-motion` nothing plays by itself and play steps instead. */ export declare function createReplayView(host: HTMLElement, timeline: ReplayTimeline, settings: ReplaySettings, initial: SurfaceOptions | ScoreOptions): ReplayView;