Skip to content

@jsvision/core / RuntimeAdapter

Interface: RuntimeAdapter ​

Defined in: host/types.ts:122

The injectable OS boundary the host runs against. The real implementation wraps node:tty / node:process / node:fs; tests inject a fake that records exit codes, captures writes, and drives signals and timers on demand. You only touch this when driving the host headlessly — normal apps let it default.

Properties ​

platform ​

readonly platform: "linux" | "darwin" | "win32"

Defined in: host/types.ts:124

The OS the adapter targets; selects the per-OS signal source map.

Methods ​

clearTimer() ​

clearTimer(handle): void

Defined in: host/types.ts:140

Clear a timer previously armed by setTimer (real: clearTimeout).

Parameters ​

handle ​

unknown

Returns ​

void


exit() ​

exit(code): never

Defined in: host/types.ts:150

Terminate the process (real: process.exit).

Parameters ​

code ​

number

Returns ​

never


on() ​

on(event, handler): () => void

Defined in: host/types.ts:128

Subscribe to a payload-free signal/resize source; returns an unsubscribe function.

Parameters ​

event ​

HostSignal

handler ​

() => void

Returns ​

() => void


onProcessExit() ​

onProcessExit(handler): () => void

Defined in: host/types.ts:142

Register a last-resort restore to run on process exit (real: process.on('exit')); returns an unsubscribe.

Parameters ​

handler ​

() => void

Returns ​

() => void


onUncaughtException() ​

onUncaughtException(handler): () => void

Defined in: host/types.ts:130

Subscribe to an uncaught exception; the handler receives the thrown value.

Parameters ​

handler ​

(err) => void

Returns ​

() => void


onUnhandledRejection() ​

onUnhandledRejection(handler): () => void

Defined in: host/types.ts:132

Subscribe to an unhandled promise rejection; the handler receives the reason.

Parameters ​

handler ​

(reason) => void

Returns ​

() => void


scheduleImmediate() ​

scheduleImmediate(fn): void

Defined in: host/types.ts:136

Schedule a callback to run after the current turn (real: setImmediate), used to coalesce resizes.

Parameters ​

fn ​

() => void

Returns ​

void


setRawMode() ​

setRawMode(stream, on): void

Defined in: host/types.ts:126

Put the input stream in or out of raw mode. Guarded so it is a no-op on a non-TTY.

Parameters ​

stream ​

ReadStream

on ​

boolean

Returns ​

void


setTimer() ​

setTimer(fn, ms): unknown

Defined in: host/types.ts:138

Arm a timer (real: setTimeout), used for the lone-ESC disambiguation window; returns a clearable handle.

Parameters ​

fn ​

() => void

ms ​

number

Returns ​

unknown


suspendSelf() ​

suspendSelf(): void

Defined in: host/types.ts:134

Suspend the current process (real: process.kill(pid, 'SIGSTOP')), used for Ctrl+Z.

Returns ​

void


warn() ​

warn(message): void

Defined in: host/types.ts:154

Best-effort warning channel (e.g. a legacy Windows console without VT processing). Never logs input.

Parameters ​

message ​

string

Returns ​

void


writeError() ​

writeError(message): void

Defined in: host/types.ts:152

Write a diagnostic line to stderr (real: process.stderr.write). Never receives raw input.

Parameters ​

message ​

string

Returns ​

void


writeSync() ​

writeSync(fd, data): void

Defined in: host/types.ts:148

Synchronously write to a file descriptor (real: fs.writeSync). Used only by the on-exit restore backstop, where the event loop is draining and an async write would never flush. Synchronous on every platform.

Parameters ​

fd ​

number

data ​

string

Returns ​

void