js-dos 8.xx Help

Command Interface (CI)

The Command Interface is only one object that allows you to communicate with js-dos instance. Once you run some js-dos bundle you will receive Command Interface instance.

Dos(/*element*/, { url: /* bundle url */, onEvent: ("ci-ready", ci: CommandInterface) { // now ci s ready }, );
const ci = await Dos(/*element*/).run(/*bundle url*/);

CI interface:

export interface CommandInterface { config: () => Promise<DosConfig>; height: () => number; width: () => number; soundFrequency: () => number; screenshot: () => Promise<ImageData>; pause: () => void; resume: () => void; mute: () => void; unmute: () => void; exit: () => Promise<void>; simulateKeyPress: (...keyCodes: number[]) => void; sendKeyEvent: (keyCode: number, pressed: boolean) => void; sendMouseMotion: (x: number, y: number) => void; sendMouseRelativeMotion: (x: number, y: number) => void; sendMouseButton: (button: number, pressed: boolean) => void; sendMouseSync: () => void; sendBackendEvent: (event: any) => void; persist(onlyChanges?: boolean): Promise<Uint8Array | null>; events(): CommandInterfaceEvents; networkConnect(networkType: NetworkType, address: string): Promise<void>; networkDisconnect(networkType: NetworkType): Promise<void>; asyncifyStats(): Promise<AsyncifyStats>; fsTree(): Promise<FsNode>; fsReadFile(file: string): Promise<Uint8Array>; fsWriteFile(file: string, contents: ReadableStream<Uint8Array> | Uint8Array): Promise<void>; fsDeleteFile(file: string): Promise<void>; }

Events interface:

export type MessageType = "log" | "warn" | "error" | string; export interface CommandInterfaceEvents { onStdout: (consumer: (message: string) => void) => void; onFrameSize: (consumer: (width: number, height: number) => void) => void; onFrame: (consumer: (rgb: Uint8Array | null, rgba: Uint8Array | null) => void) => void; onSoundPush: (consumer: (samples: Float32Array) => void) => void; onExit: (consumer: () => void) => void; onMessage: (consumer: (msgType: MessageType, ...args: any[]) => void) => void; onNetworkConnected: (consumer: (networkType: NetworkType, address: string) => void) => void; onNetworkDisconnected: (consumer: (networkType: NetworkType) => void) => void; }
Last modified: 26 апреля 2024