Skip to content

Class: IndiClient

A reconnecting client that mirrors bridge state into a typed cache.

Constructors

Constructor

new IndiClient(options?): IndiClient

Parameters

options?

IndiClientOptions

Returns

IndiClient

Accessors

connected

Get Signature

get connected(): boolean

Whether the browser<->bridge WebSocket is open.

Returns

boolean


connectionState

Get Signature

get connectionState(): ConnectionState

The current combined connection state.

Returns

ConnectionState


store

Get Signature

get store(): PropertyStore

The underlying property cache.

Returns

PropertyStore


upstreamConnected

Get Signature

get upstreamConnected(): boolean

Whether the bridge reports a live upstream indiserver connection.

Returns

boolean

Methods

close()

close(): void

Close the connection and stop reconnecting.

Returns

void


connect()

connect(): void

Open the connection to the bridge and begin mirroring state.

Returns

void


device()

device(name): Readonly\<Record\<string, Vector>>

A stable read-only snapshot of one device's properties.

Parameters

name

string

Returns

Readonly\<Record\<string, Vector>>


devices()

devices(): readonly string[]

A stable, sorted list of all known device names.

Returns

readonly string[]


enableBlob()

enableBlob(device, name?, policy?): void

Set the BLOB delivery policy for a device (or one property).

The request is remembered and replayed on every reconnect, matching the Python client.

Parameters

device

string

name?

string

policy?

BLOBPolicy

Returns

void


get()

get(device, name): Vector | undefined

Return a cached vector, or undefined if it is not present.

Parameters

device

string

name

string

Returns

Vector | undefined


getProperties()

getProperties(device?, name?): void

Ask the server to (re-)send property definitions.

Parameters

device?

string

name?

string

Returns

void


messages()

messages(): readonly Message[]

The retained inbound message notifications, oldest first.

The returned array is a stable snapshot (a new reference only when a message arrives), so it is safe to feed to useSyncExternalStore.

Returns

readonly Message[]


onConnection()

onConnection(callback): () => void

Register a callback for connection-state transitions.

Parameters

callback

ConnectionCallback

Returns

() => void


onMessage()

onMessage(callback): () => void

Register a callback for inbound message notifications.

Parameters

callback

MessageCallback

Returns

() => void


onWrite()

onWrite(callback): () => void

Register a callback for each new vector this client sends.

A property's state changing is telemetry - a driver emits set frames continuously and nothing may treat them as events worth reporting. The exception is a vector this browser has just written to, whose next state is the answer to that write rather than more of the stream, and only the sender can tell the two apart. It fires on the send, not on the acknowledgement: the socket buffers while offline, and the operator pressed the button either way.

Parameters

callback

WriteCallback

Called with the device and property name of each write.

Returns

An unsubscribe function.

() => void


send()

send(message): void

Queue an arbitrary message to send upstream.

Parameters

message

IndiMessage

Returns

void


setBlob()

setBlob(device, name, values): void

Send new BLOB payloads (base64 strings) for a property.

Parameters

device

string

name

string

values

Record\<string, string>

Returns

void


setNumber()

setNumber(device, name, values): void

Send new number values for a property.

Parameters

device

string

name

string

values

Record\<string, number>

Returns

void


setSwitch()

setSwitch(device, name, values): void

Send new switch states for a property.

Parameters

device

string

name

string

values

Record\<string, SwitchInput>

Returns

void


setText()

setText(device, name, values): void

Send new text values for a property.

Parameters

device

string

name

string

values

Record\<string, string>

Returns

void


subscribe()

subscribe(callback, filter?): () => void

Register a property-event callback; returns an unsubscribe function.

Parameters

callback

Subscriber

filter?

SubscriptionFilter

Returns

() => void


waitFor()

waitFor(device, name, predicate?, options?): Promise\<Vector>

Resolve once a property exists (and satisfies predicate).

Resolves immediately if the cached property already matches; rejects with a TimeoutError-like Error if timeout (ms) elapses first.

Parameters

device

string

name

string

predicate?

Predicate

options?
timeout?

number

Returns

Promise\<Vector>