UNPKG

@bitblit/asyncglk

Version:
108 lines (107 loc) 4.23 kB
import { Blorb } from '../../blorb/blorb.js'; import * as protocol from '../../common/protocol.js'; import type { Dialog } from '../../dialog/common/interface.js'; import type { GlkApi } from '../../glkapi/interface.js'; export interface GlkOte { classname: string; error(msg: any): void; extevent(val: any): void; getdomcontext(): HTMLElement | undefined; getdomid(name: string): string; getinterface(): GlkOteOptions; getlibrary(name: string): Blorb | Dialog | null | undefined; init(options: GlkOteOptions): void; inited(): boolean; log(msg: string): void; save_allstate(): any; setdomcontext(val: HTMLElement): void; update(data: protocol.Update): void; version: string; warning(msg: any): void; } export interface GlkOteOptions { accept(event: protocol.Event): void; Blorb?: Blorb; debug_commands?: boolean; detect_external_links?: string | boolean; Dialog?: Dialog; dialog_dom_prefix?: string; dom_prefix?: string; errorcontent?: string; errorpane?: string; gameport?: string; Glk?: GlkApi; loadingpane?: string; max_buffer_length?: number; /** Cookie name to opt out of transcript recording. Default: `transcript_recording_opt_out` */ recording_cookie?: string; /** Transcript recording service protocol format. Only `simple` is supported by AsyncGlk */ recording_format?: string; /** Custom transcript recording handler function */ recording_handler?: (state: TranscriptRecordingData) => void; /** Transcript recording label for this story */ recording_label?: string; /** URL for the transcript recording service */ recording_url?: string; regex_external_links?: RegExp; /** Whether or not to set the <body> background colour to the page_margin_bg */ set_body_to_page_bg?: boolean | number; windowport?: string; } /** Format of the transcript recorder data */ export interface TranscriptRecordingData { /** The transcript record format is always 'simple */ format: 'simple'; /** Player input for char and line events */ input: string; /** The label given to this story at the beginning */ label: string; /** Combined output from buffer windows */ output: string; /** Timestamp from when output returned to GlkOte (milliseconds) */ outtimestamp: number; /** Session ID */ sessionId: string; /** Timestamp from when GlkOte event was sent to VM (milliseconds) */ timestamp: number; } export declare abstract class GlkOteBase implements GlkOte { classname: string; version: string; protected accept_func: (event: protocol.Event) => void; protected autorestoring: boolean; protected Blorb?: Blorb; current_metrics: protocol.NormalisedMetrics; protected Dialog?: Dialog; disabled: boolean; protected generation: number; protected is_inited: boolean; protected options: GlkOteOptions; protected timer: ReturnType<typeof setTimeout> | null; protected waiting_for_update: boolean; init(options: GlkOteOptions): Promise<void>; error(error: Error | string): void; extevent(value: any): void; getdomcontext(): HTMLElement | undefined; getdomid(name: string): string; getinterface(): GlkOteOptions; getlibrary(name: string): Blorb | Dialog | null | undefined; inited(): boolean; log(msg: string): void; setdomcontext(val: HTMLElement): void; update(data: protocol.Update): void; warning(msg: any): void; protected autorestore(data: any): void; protected capabilities(): string[]; protected exit(): void; protected handle_specialinput(data: protocol.SpecialInput): void; protected ontimer(): void; save_allstate(): any; send_event(ev: Partial<protocol.Event>): void; protected set_page_bg(colour: string): void; protected abstract cancel_inputs(windows: protocol.InputUpdate[]): void; protected abstract disable(disable: boolean): void; protected abstract update_content(content: protocol.ContentUpdate[]): void; protected abstract update_inputs(windows: protocol.InputUpdate[]): void; protected abstract update_windows(windows: protocol.WindowUpdate[]): void; }