UNPKG

@casual-simulation/aux-vm-client

Version:

A set of utilities required to securely run an AUX as a client.

91 lines 3.6 kB
import type { StateUpdatedEvent, BotAction, StoredAux, PartitionAuthMessage } from '@casual-simulation/aux-common'; import type { AuxChannel, AuxChannelErrorType, AuxSubVM, AuxVM, ChannelActionResult } from '@casual-simulation/aux-vm/vm'; import type { DeviceAction, StatusUpdate } from '@casual-simulation/aux-common'; import type { Observable } from 'rxjs'; import type { Remote } from 'comlink'; import type { AuxDevice, RuntimeActions, RuntimeStateVersion } from '@casual-simulation/aux-runtime'; import type { SimulationOrigin } from '@casual-simulation/aux-vm/managers'; /** * Defines a VM that is able to wrap a remote aux channel. */ export declare class RemoteAuxVM implements AuxVM { private _localEvents; private _deviceEvents; private _connectionStateChanged; private _stateUpdated; private _versionUpdated; private _onError; private _subVMAdded; private _subVMRemoved; private _subVMMap; private _onAuthMessage; private _proxy; private _id; private _configBotId; private _origin; closed: boolean; /** * The ID of the simulation. */ get id(): string; get configBotId(): string; get origin(): SimulationOrigin; /** * Creates a new Simulation VM. */ constructor(id: string, origin: SimulationOrigin, configBotId: string, channel: Remote<AuxChannel>); get subVMAdded(): Observable<AuxSubVM>; get subVMRemoved(): Observable<AuxSubVM>; get connectionStateChanged(): Observable<StatusUpdate>; get onError(): Observable<AuxChannelErrorType>; get onAuthMessage(): Observable<PartitionAuthMessage>; /** * Initaializes the VM. */ init(): Promise<void>; private _init; /** * The observable list of events that should be produced locally. */ get localEvents(): Observable<RuntimeActions[]>; get deviceEvents(): Observable<DeviceAction[]>; /** * The observable list of bot state updates from this simulation. */ get stateUpdated(): Observable<StateUpdatedEvent>; get versionUpdated(): Observable<RuntimeStateVersion>; /** * Sends the given list of events to the simulation. * @param events The events to send to the simulation. */ sendEvents(events: BotAction[]): Promise<void>; /** * Executes a shout with the given event name on the given bot IDs with the given argument. * Also dispatches any actions and errors that occur. * Returns the results from the event. * @param eventName The name of the event. * @param botIds The IDs of the bots that the shout is being sent to. * @param arg The argument to include in the shout. */ shout(eventName: string, botIds?: string[], arg?: any): Promise<ChannelActionResult>; formulaBatch(formulas: string[]): Promise<void>; forkAux(newId: string): Promise<void>; exportBots(botIds: string[]): Promise<StoredAux>; /** * Exports the causal tree for the simulation. */ export(): Promise<StoredAux>; getTags(): Promise<string[]>; updateDevice(device: AuxDevice): Promise<void>; /** * Gets a new endpoint for the aux channel. * Can then be used with a ConnectableAuxVM. */ createEndpoint(): Promise<MessagePort>; sendAuthMessage(message: PartitionAuthMessage): Promise<void>; unsubscribe(): void; protected _createSubVM(id: string, origin: SimulationOrigin, configBotId: string, channel: Remote<AuxChannel>): AuxVM; private _handleAddedSubChannel; private _handleRemovedSubChannel; } //# sourceMappingURL=RemoteAuxVM.d.ts.map