UNPKG

@casual-simulation/aux-vm-browser

Version:

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

70 lines 3.42 kB
import { type DeviceAction, type StateUpdatedEvent, type StatusUpdate, type PartitionAuthMessage, type BotAction, type StoredAux } from '@casual-simulation/aux-common'; import type { RuntimeActions, RuntimeStateVersion, AuxDevice } from '@casual-simulation/aux-runtime'; import type { SimulationOrigin } from '@casual-simulation/aux-vm/managers'; import type { AuxChannel, AuxChannelErrorType, AuxConfig, AuxSubChannel, AuxSubVM, AuxVM, ChannelActionResult } from '@casual-simulation/aux-vm/vm'; import type { Observable } from 'rxjs'; import { Subject } from 'rxjs'; /** * Defines a class that represents an AUX VM that provides no isolation or sandboxing. */ export default class AuxNoVM implements AuxVM { protected _localEvents: Subject<RuntimeActions[]>; protected _deviceEvents: Subject<DeviceAction[]>; protected _connectionStateChanged: Subject<StatusUpdate>; protected _stateUpdated: Subject<StateUpdatedEvent>; protected _versionUpdated: Subject<RuntimeStateVersion>; protected _onError: Subject<AuxChannelErrorType>; protected _subVMAdded: Subject<AuxSubVM>; protected _subVMRemoved: Subject<AuxSubVM>; protected _subVMMap: Map<string, AuxSubVM>; private _channel; protected _onAuthMessage: Subject<PartitionAuthMessage>; protected _configBotId: string; protected _id: string; protected _origin: SimulationOrigin; closed: boolean; /** * The ID of the simulation. */ get id(): string; get configBotId(): string; /** * Creates a new AUX VM that provides no isolation or sandboxing. * @param id The ID of the inst. * @param origin The origin of the inst. * @param config The config that should be used. */ constructor(id: string, origin: SimulationOrigin, configBotId: string, channel: AuxChannel); init(): Promise<void>; unsubscribe(): void; get origin(): SimulationOrigin; get subVMAdded(): Observable<AuxSubVM>; get subVMRemoved(): Observable<AuxSubVM>; get connectionStateChanged(): Observable<StatusUpdate>; get onError(): Observable<AuxChannelErrorType>; get onAuthMessage(): Observable<PartitionAuthMessage>; /** * 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>; sendEvents(events: BotAction[]): Promise<void>; shout(eventName: string, botIds?: string[], arg?: any): Promise<ChannelActionResult>; formulaBatch(formulas: string[]): Promise<void>; forkAux(newId: string): Promise<void>; exportBots(botIds: string[]): Promise<StoredAux>; export(): Promise<StoredAux>; getTags(): Promise<string[]>; updateDevice(device: AuxDevice): Promise<void>; sendAuthMessage(message: PartitionAuthMessage): Promise<void>; protected _createSubVM(id: string, origin: SimulationOrigin, configBotId: string, channel: AuxChannel): AuxVM; protected _handleAddedSubChannel(subChannel: AuxSubChannel): Promise<void>; protected _handleRemovedSubChannel(channelId: string): Promise<void>; } export declare function processPartitions(config: AuxConfig): AuxConfig; //# sourceMappingURL=AuxNoVM.d.ts.map