export type ClipKind = 'pose' | 'move'; /** What the player must do, in order (spec/player.md, "Commands"). */ export type Command = { type: 'showClip'; edge: string; kind: ClipKind; rate: number; } | { type: 'showStill'; pose: string; } | { type: 'preload'; edge: string; } | { type: 'playSound'; edge: string; } | { type: 'stopSounds'; onlyLooping: boolean; } | { type: 'poseEntered'; pose: string; } | { type: 'interrupted'; edge: string; } | { type: 'spent'; name: string; used: boolean; } | { type: 'error'; code: string; detail?: string; }; /** The engine's view of the screen, for tests and tools. */ export interface EngineState { clock: number; pose: string | null; /** The edge on screen, or `still:`. */ clip: string | null; moving: boolean; shownAt: number; expectedMs: number; next: { clip: string; at: number | 'end'; } | null; } export type Value = boolean | number; /** Where the WebAssembly comes from: a URL, its bytes, or a compiled module. */ export type WasmSource = string | URL | Response | BufferSource | WebAssembly.Module; /** A delivery the engine refuses (rules.md 1.2, 1.3). */ export declare class LoadError extends Error { readonly code: string; readonly detail: string; constructor(code: string, detail: string); } /** * Where to load the engine's WebAssembly from. By default the ES module build * loads `masko_player_wasm_bg.wasm` next to itself and the script build has it * inlined. Call before the first mascot mounts. */ export declare function setWasmSource(source: WasmSource): void; /** Loads the engine once; every mascot on the page shares it. */ export declare function loadWasm(): Promise; /** The inlined engine's bytes. */ export declare function fromBase64(base64: string): Uint8Array; /** Loads the engine from bytes at once, for Node and tests. */ export declare function loadWasmSync(bytes: BufferSource | WebAssembly.Module): void; /** One loaded release. Times are play time in whole milliseconds. */ export declare class Engine { private readonly inner; private constructor(); /** Reads a delivery (a JSON string), or throws a `LoadError`. */ static load(delivery: string): Engine; start(now: number): Command[]; reset(now: number): Command[]; /** `instant`: what it starts starts now; an Any State start cuts straight in (rules.md 5.8). */ set(name: string, value: Value, instant: boolean, now: number): Command[]; fire(name: string, instant: boolean, now: number): Command[]; advance(now: number): Command[]; /** The clip's first frame is on screen: its safety net counts from now (rules.md 9.3). */ clipShown(edge: string, now: number): Command[]; clipEnded(edge: string, now: number): Command[]; clipFailed(edge: string, now: number): Command[]; markUnplayable(edge: string): void; markPlayable(edge: string): void; previewShowPose(pose: string, now: number): Command[]; previewPlayMove(edge: string, now: number): Command[]; /** The next play time at which the engine has work, if any. */ nextWake(): number | undefined; state(): EngineState; value(name: string): Value; pendingFires(): string[]; seed(seed: number): void; /** Fixed extra-clip rolls, for scenarios. */ useRolls(rolls: number[]): void; free(): void; }