UNPKG

@casual-simulation/aux-vm-browser

Version:

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

48 lines 2.24 kB
/* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences. * * Copyright (c) 2019-2025 Casual Simulation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ import '@casual-simulation/aux-vm/globalThis-polyfill'; import { createAuxPartition } from '@casual-simulation/aux-common'; import { RemoteAuxChannel } from '@casual-simulation/aux-vm-client/vm/RemoteAuxChannel'; import { createProxyClientPartition } from '../partitions/ProxyClientPartition'; import { proxy } from 'comlink'; import { createLocalStoragePartition } from '../partitions/LocalStoragePartition'; export class BrowserAuxChannel extends RemoteAuxChannel { constructor(defaultHost, config) { super(config, {}); BrowserAuxChannel.defaultHost = defaultHost; } async _createPartition(config, services) { let partition = await super._createPartition(config, services); if (!partition) { partition = await createAuxPartition(config, services, createProxyClientPartition, createLocalStoragePartition); } return partition; } _createSubChannel(runtime, config) { const channel = new BrowserAuxChannel(BrowserAuxChannel.defaultHost, config); channel._runtime = runtime; return channel; } _handleSubChannelAdded(subChannel) { return super._handleSubChannelAdded(proxy({ getInfo: subChannel.getInfo, getChannel: async () => proxy(await subChannel.getChannel()), })); } } //# sourceMappingURL=BrowserAuxChannel.js.map