UNPKG

@casual-simulation/aux-vm-browser

Version:

A set of utilities required to securely run an AUX in a web browser.

80 lines 3.43 kB
import type { BotAction, PartitionAuthMessage, StateUpdatedEvent, StoredAux } from '@casual-simulation/aux-common'; import type { AuxDevice, RuntimeActions, RuntimeStateVersion } from '@casual-simulation/aux-runtime'; import type { AuxVM, AuxChannel, AuxChannelErrorType, ChannelActionResult } from '@casual-simulation/aux-vm/vm'; import type { AuxSubVM } from '@casual-simulation/aux-vm/vm'; import type { DeviceAction, StatusUpdate } from '@casual-simulation/aux-common'; import type { Remote } from 'comlink'; import type { Observable } from 'rxjs'; import type { SimulationOrigin } from '@casual-simulation/aux-vm/managers'; /** * Gets an AUX VM that is able to communicate with a proxied aux channel. */ export declare class ConnectableAuxVM implements AuxVM { private _localEvents; private _deviceEvents; private _connectionStateChanged; private _stateUpdated; private _versionUpdated; private _onError; private _subVMAdded; private _subVMRemoved; private _subVMMap; private _onAuthMessage; private _id; private _configBotId; private _proxy; private _port; private _sub; private _origin; get id(): string; get origin(): SimulationOrigin; get configBotId(): string; constructor(id: string, origin: SimulationOrigin, configBotId: string, port: MessagePort); get subVMAdded(): Observable<AuxSubVM>; get subVMRemoved(): Observable<AuxSubVM>; createEndpoint?(): Promise<MessagePort>; get connectionStateChanged(): Observable<StatusUpdate>; get onError(): Observable<AuxChannelErrorType>; get onAuthMessage(): Observable<PartitionAuthMessage>; init(): Promise<void>; unsubscribe(): void; get closed(): boolean; /** * 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>; protected _createSubVM(id: string, origin: SimulationOrigin, configBotId: string, channel: Remote<AuxChannel>): AuxVM; sendAuthMessage(message: PartitionAuthMessage): Promise<void>; private _handleAddedSubChannel; private _handleRemovedSubChannel; } //# sourceMappingURL=ConnectableAuxVM.d.ts.map