@casual-simulation/aux-vm-browser 3.4.6-alpha.14601027727 → 3.5.0-alpha.15117651144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/html/IFrameHelpers.js +28 -39
- package/html/IFrameHelpers.js.map +1 -1
- package/managers/AuthCoordinator.d.ts +9 -0
- package/managers/AuthCoordinator.js +369 -383
- package/managers/AuthCoordinator.js.map +1 -1
- package/managers/AuthEndpointHelper.d.ts +3 -2
- package/managers/AuthEndpointHelper.js +399 -462
- package/managers/AuthEndpointHelper.js.map +1 -1
- package/managers/AuthHelper.js +2 -2
- package/managers/AuthHelper.js.map +1 -1
- package/managers/BotManager.js +54 -58
- package/managers/BotManager.js.map +1 -1
- package/managers/BotPanelManager.js +2 -11
- package/managers/BotPanelManager.js.map +1 -1
- package/managers/BrowserSimulationCalculations.js +1 -1
- package/managers/BrowserSimulationCalculations.js.map +1 -1
- package/managers/IdePortalManager.js +2 -11
- package/managers/IdePortalManager.js.map +1 -1
- package/managers/LivekitManager.js +320 -324
- package/managers/LivekitManager.js.map +1 -1
- package/managers/SystemPortalCoordinator.js +74 -66
- package/managers/SystemPortalCoordinator.js.map +1 -1
- package/package.json +15 -12
- package/partitions/LocalStoragePartition.d.ts +6 -0
- package/partitions/LocalStoragePartition.js +45 -47
- package/partitions/LocalStoragePartition.js.map +1 -1
- package/partitions/ProxyClientPartition.js +28 -40
- package/partitions/ProxyClientPartition.js.map +1 -1
- package/vm/AuxVMImpl.js +120 -153
- package/vm/AuxVMImpl.js.map +1 -1
- package/vm/BrowserAuxChannel.js +9 -22
- package/vm/BrowserAuxChannel.js.map +1 -1
- package/vm/ConnectableAuxVM.js +54 -85
- package/vm/ConnectableAuxVM.js.map +1 -1
- package/vm/StaticAuxVMImpl.d.ts +91 -3
- package/vm/StaticAuxVMImpl.js +198 -108
- package/vm/StaticAuxVMImpl.js.map +1 -1
- package/vm/WorkerEntryHelpers.js.map +1 -1
package/vm/AuxVMImpl.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { ProxyBridgePartitionImpl, } from '@casual-simulation/aux-common';
|
|
1
|
+
import { ProxyBridgePartitionImpl } from '@casual-simulation/aux-common';
|
|
11
2
|
import { Subject } from 'rxjs';
|
|
12
3
|
import { wrap, proxy, expose, transfer, createEndpoint } from 'comlink';
|
|
13
4
|
import { setupChannel, waitForLoad } from '../html/IFrameHelpers';
|
|
14
|
-
import { remapProgressPercent
|
|
5
|
+
import { remapProgressPercent } from '@casual-simulation/aux-common';
|
|
15
6
|
import { RemoteAuxVM } from '@casual-simulation/aux-vm-client/vm/RemoteAuxVM';
|
|
16
7
|
import { getBaseOrigin, getVMOrigin } from './AuxVMUtils';
|
|
17
8
|
export const DEFAULT_IFRAME_ALLOW_ATTRIBUTE = 'accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking';
|
|
@@ -74,70 +65,66 @@ export default class AuxVMImpl {
|
|
|
74
65
|
/**
|
|
75
66
|
* Initaializes the VM.
|
|
76
67
|
*/
|
|
77
|
-
init() {
|
|
78
|
-
return
|
|
79
|
-
return yield this._init();
|
|
80
|
-
});
|
|
68
|
+
async init() {
|
|
69
|
+
return await this._init();
|
|
81
70
|
}
|
|
82
|
-
_init() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
progress: 0.05,
|
|
105
|
-
});
|
|
106
|
-
this._connectionStateChanged.next({
|
|
107
|
-
type: 'progress',
|
|
108
|
-
message: 'Initializing web worker...',
|
|
109
|
-
progress: 0.1,
|
|
110
|
-
});
|
|
111
|
-
this._iframe = document.createElement('iframe');
|
|
112
|
-
this._iframe.src = iframeUrl;
|
|
113
|
-
if (!enableDom) {
|
|
114
|
-
this._iframe.style.display = 'none';
|
|
115
|
-
}
|
|
116
|
-
this._iframe.style.position = 'absolute';
|
|
117
|
-
this._iframe.style.height = '100%';
|
|
118
|
-
this._iframe.style.width = '100%';
|
|
119
|
-
this._iframe.setAttribute('allow', DEFAULT_IFRAME_ALLOW_ATTRIBUTE);
|
|
120
|
-
this._iframe.setAttribute('sandbox', DEFAULT_IFRAME_SANDBOX_ATTRIBUTE);
|
|
121
|
-
let promise = waitForLoad(this._iframe);
|
|
122
|
-
const iframeContainer = document.querySelector('.vm-iframe-container');
|
|
123
|
-
if (iframeContainer) {
|
|
124
|
-
iframeContainer.appendChild(this._iframe);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
document.body.insertBefore(this._iframe, document.body.firstChild);
|
|
128
|
-
}
|
|
129
|
-
yield promise;
|
|
130
|
-
this._channel = setupChannel(this._iframe.contentWindow);
|
|
131
|
-
this._connectionStateChanged.next({
|
|
132
|
-
type: 'progress',
|
|
133
|
-
message: 'Creating VM...',
|
|
134
|
-
progress: 0.2,
|
|
135
|
-
});
|
|
136
|
-
const wrapper = wrap(this._channel.port1);
|
|
137
|
-
this._proxy = yield new wrapper(location.origin, processPartitions(this._config));
|
|
138
|
-
let statusMapper = remapProgressPercent(0.2, 1);
|
|
139
|
-
return yield this._proxy.init(proxy((events) => this._localEvents.next(events)), proxy((events) => this._deviceEvents.next(events)), proxy((state) => this._stateUpdated.next(state)), proxy((version) => this._versionUpdated.next(version)), proxy((state) => this._connectionStateChanged.next(statusMapper(state))), proxy((err) => this._onError.next(err)), proxy((channel) => this._handleAddedSubChannel(channel)), proxy((id) => this._handleRemovedSubChannel(id)), proxy((message) => this._onAuthMessage.next(message)));
|
|
71
|
+
async _init() {
|
|
72
|
+
let origin = getVMOrigin(this._config.config.vmOrigin, location.origin, this._id);
|
|
73
|
+
let enableDom = this._config.config.enableDom;
|
|
74
|
+
if (enableDom &&
|
|
75
|
+
getBaseOrigin(location.origin) === getBaseOrigin(origin) &&
|
|
76
|
+
!this._config.config.debug) {
|
|
77
|
+
console.error(`[AuxVMImpl] Cannot use DOM when base origin is the same as the VM origin. ${origin} should not share the same base domain as ${location.origin}.`);
|
|
78
|
+
console.error('[AuxVMImpl] Using WebWorker isolated VM.');
|
|
79
|
+
console.error('[AuxVMImpl] To use DOM, enable debug mode or use a separate VM origin.');
|
|
80
|
+
enableDom = false;
|
|
81
|
+
}
|
|
82
|
+
if (this._relaxOrigin) {
|
|
83
|
+
const baseOrigin = getBaseOrigin(origin);
|
|
84
|
+
console.log('[AuxVMImpl] Relaxing origin to:', baseOrigin);
|
|
85
|
+
origin = baseOrigin;
|
|
86
|
+
}
|
|
87
|
+
console.log('origin', origin);
|
|
88
|
+
const iframeUrl = new URL(enableDom ? '/aux-vm-iframe-dom.html' : '/aux-vm-iframe.html', origin).href;
|
|
89
|
+
this._connectionStateChanged.next({
|
|
90
|
+
type: 'progress',
|
|
91
|
+
message: 'Getting web manifest...',
|
|
92
|
+
progress: 0.05,
|
|
140
93
|
});
|
|
94
|
+
this._connectionStateChanged.next({
|
|
95
|
+
type: 'progress',
|
|
96
|
+
message: 'Initializing web worker...',
|
|
97
|
+
progress: 0.1,
|
|
98
|
+
});
|
|
99
|
+
this._iframe = document.createElement('iframe');
|
|
100
|
+
this._iframe.src = iframeUrl;
|
|
101
|
+
if (!enableDom) {
|
|
102
|
+
this._iframe.style.display = 'none';
|
|
103
|
+
}
|
|
104
|
+
this._iframe.style.position = 'absolute';
|
|
105
|
+
this._iframe.style.height = '100%';
|
|
106
|
+
this._iframe.style.width = '100%';
|
|
107
|
+
this._iframe.setAttribute('allow', DEFAULT_IFRAME_ALLOW_ATTRIBUTE);
|
|
108
|
+
this._iframe.setAttribute('sandbox', DEFAULT_IFRAME_SANDBOX_ATTRIBUTE);
|
|
109
|
+
let promise = waitForLoad(this._iframe);
|
|
110
|
+
const iframeContainer = document.querySelector('.vm-iframe-container');
|
|
111
|
+
if (iframeContainer) {
|
|
112
|
+
iframeContainer.appendChild(this._iframe);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
document.body.insertBefore(this._iframe, document.body.firstChild);
|
|
116
|
+
}
|
|
117
|
+
await promise;
|
|
118
|
+
this._channel = setupChannel(this._iframe.contentWindow);
|
|
119
|
+
this._connectionStateChanged.next({
|
|
120
|
+
type: 'progress',
|
|
121
|
+
message: 'Creating VM...',
|
|
122
|
+
progress: 0.2,
|
|
123
|
+
});
|
|
124
|
+
const wrapper = wrap(this._channel.port1);
|
|
125
|
+
this._proxy = await new wrapper(location.origin, processPartitions(this._config));
|
|
126
|
+
let statusMapper = remapProgressPercent(0.2, 1);
|
|
127
|
+
return await this._proxy.init(proxy((events) => this._localEvents.next(events)), proxy((events) => this._deviceEvents.next(events)), proxy((state) => this._stateUpdated.next(state)), proxy((version) => this._versionUpdated.next(version)), proxy((state) => this._connectionStateChanged.next(statusMapper(state))), proxy((err) => this._onError.next(err)), proxy((channel) => this._handleAddedSubChannel(channel)), proxy((id) => this._handleRemovedSubChannel(id)), proxy((message) => this._onAuthMessage.next(message)));
|
|
141
128
|
}
|
|
142
129
|
/**
|
|
143
130
|
* The observable list of events that should be produced locally.
|
|
@@ -161,27 +148,25 @@ export default class AuxVMImpl {
|
|
|
161
148
|
* Sends the given list of events to the simulation.
|
|
162
149
|
* @param events The events to send to the simulation.
|
|
163
150
|
*/
|
|
164
|
-
sendEvents(events) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (event.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
transferables.push(event.result);
|
|
175
|
-
}
|
|
151
|
+
async sendEvents(events) {
|
|
152
|
+
if (!this._proxy)
|
|
153
|
+
return null;
|
|
154
|
+
if (events && events.length) {
|
|
155
|
+
const transferables = [];
|
|
156
|
+
for (let event of events) {
|
|
157
|
+
if (event.type === 'async_result') {
|
|
158
|
+
if (event.result instanceof OffscreenCanvas) {
|
|
159
|
+
console.log(`[AuxVMImpl] marked OffscreenCanvas as transferable in AsyncResultAction`, event);
|
|
160
|
+
transferables.push(event.result);
|
|
176
161
|
}
|
|
177
162
|
}
|
|
178
|
-
if (transferables.length > 0) {
|
|
179
|
-
console.log(`[AuxVMImpl] sendEvents marking transferables from events`, events, transferables);
|
|
180
|
-
events = transfer(events, transferables);
|
|
181
|
-
}
|
|
182
163
|
}
|
|
183
|
-
|
|
184
|
-
|
|
164
|
+
if (transferables.length > 0) {
|
|
165
|
+
console.log(`[AuxVMImpl] sendEvents marking transferables from events`, events, transferables);
|
|
166
|
+
events = transfer(events, transferables);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return await this._proxy.sendEvents(events);
|
|
185
170
|
}
|
|
186
171
|
/**
|
|
187
172
|
* Executes a shout with the given event name on the given bot IDs with the given argument.
|
|
@@ -191,57 +176,43 @@ export default class AuxVMImpl {
|
|
|
191
176
|
* @param botIds The IDs of the bots that the shout is being sent to.
|
|
192
177
|
* @param arg The argument to include in the shout.
|
|
193
178
|
*/
|
|
194
|
-
shout(eventName, botIds, arg) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return yield this._proxy.shout(eventName, botIds, arg);
|
|
199
|
-
});
|
|
179
|
+
async shout(eventName, botIds, arg) {
|
|
180
|
+
if (!this._proxy)
|
|
181
|
+
return null;
|
|
182
|
+
return await this._proxy.shout(eventName, botIds, arg);
|
|
200
183
|
}
|
|
201
|
-
formulaBatch(formulas) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return yield this._proxy.formulaBatch(formulas);
|
|
206
|
-
});
|
|
184
|
+
async formulaBatch(formulas) {
|
|
185
|
+
if (!this._proxy)
|
|
186
|
+
return null;
|
|
187
|
+
return await this._proxy.formulaBatch(formulas);
|
|
207
188
|
}
|
|
208
|
-
forkAux(newId) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return yield this._proxy.forkAux(newId);
|
|
213
|
-
});
|
|
189
|
+
async forkAux(newId) {
|
|
190
|
+
if (!this._proxy)
|
|
191
|
+
return null;
|
|
192
|
+
return await this._proxy.forkAux(newId);
|
|
214
193
|
}
|
|
215
|
-
exportBots(botIds) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return yield this._proxy.exportBots(botIds);
|
|
220
|
-
});
|
|
194
|
+
async exportBots(botIds) {
|
|
195
|
+
if (!this._proxy)
|
|
196
|
+
return null;
|
|
197
|
+
return await this._proxy.exportBots(botIds);
|
|
221
198
|
}
|
|
222
199
|
/**
|
|
223
200
|
* Exports the causal tree for the simulation.
|
|
224
201
|
*/
|
|
225
|
-
export() {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return yield this._proxy.export();
|
|
230
|
-
});
|
|
202
|
+
async export() {
|
|
203
|
+
if (!this._proxy)
|
|
204
|
+
return null;
|
|
205
|
+
return await this._proxy.export();
|
|
231
206
|
}
|
|
232
|
-
getTags() {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return yield this._proxy.getTags();
|
|
237
|
-
});
|
|
207
|
+
async getTags() {
|
|
208
|
+
if (!this._proxy)
|
|
209
|
+
return null;
|
|
210
|
+
return await this._proxy.getTags();
|
|
238
211
|
}
|
|
239
|
-
updateDevice(device) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return yield this._proxy.updateDevice(device);
|
|
244
|
-
});
|
|
212
|
+
async updateDevice(device) {
|
|
213
|
+
if (!this._proxy)
|
|
214
|
+
return null;
|
|
215
|
+
return await this._proxy.updateDevice(device);
|
|
245
216
|
}
|
|
246
217
|
/**
|
|
247
218
|
* Gets a new endpoint for the aux channel.
|
|
@@ -274,27 +245,23 @@ export default class AuxVMImpl {
|
|
|
274
245
|
_createSubVM(id, origin, configBotId, channel) {
|
|
275
246
|
return new RemoteAuxVM(id, origin, configBotId, channel);
|
|
276
247
|
}
|
|
277
|
-
_handleAddedSubChannel(subChannel) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
this._subVMAdded.next(subVM);
|
|
288
|
-
});
|
|
248
|
+
async _handleAddedSubChannel(subChannel) {
|
|
249
|
+
const { id, configBotId } = await subChannel.getInfo();
|
|
250
|
+
const channel = (await subChannel.getChannel());
|
|
251
|
+
const subVM = {
|
|
252
|
+
id: id,
|
|
253
|
+
vm: this._createSubVM(id, this.origin, configBotId, channel),
|
|
254
|
+
channel,
|
|
255
|
+
};
|
|
256
|
+
this._subVMMap.set(id, subVM);
|
|
257
|
+
this._subVMAdded.next(subVM);
|
|
289
258
|
}
|
|
290
|
-
_handleRemovedSubChannel(channelId) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
});
|
|
259
|
+
async _handleRemovedSubChannel(channelId) {
|
|
260
|
+
const vm = this._subVMMap.get(channelId);
|
|
261
|
+
if (vm) {
|
|
262
|
+
this._subVMMap.delete(channelId);
|
|
263
|
+
this._subVMRemoved.next(vm);
|
|
264
|
+
}
|
|
298
265
|
}
|
|
299
266
|
}
|
|
300
267
|
export function processPartitions(config) {
|
package/vm/AuxVMImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuxVMImpl.js","sourceRoot":"","sources":["AuxVMImpl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuxVMImpl.js","sourceRoot":"","sources":["AuxVMImpl.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAUxE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAM9E,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,CAAC,MAAM,8BAA8B,GACvC,oJAAoJ,CAAC;AACzJ,MAAM,CAAC,MAAM,gCAAgC,GACzC,0GAA0G,CAAC;AAE/G;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IA2B1B;;OAEG;IACH,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACH,YACI,EAAU,EACV,MAAwB,EACxB,MAAiB,EACjB,cAAuB,KAAK;QAE5B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,C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AAO;gBACpC,IAAI,EAAE,OAAO,CAAC,KAAK;aACtB,CAAC;QACN,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC"}
|
package/vm/BrowserAuxChannel.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
/* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences.
|
|
11
2
|
*
|
|
12
3
|
* Copyright (c) 2019-2025 Casual Simulation, Inc.
|
|
@@ -25,26 +16,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
16
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
26
17
|
*/
|
|
27
18
|
import '@casual-simulation/aux-vm/globalThis-polyfill';
|
|
28
|
-
import { createAuxPartition
|
|
19
|
+
import { createAuxPartition } from '@casual-simulation/aux-common';
|
|
29
20
|
import { RemoteAuxChannel } from '@casual-simulation/aux-vm-client/vm/RemoteAuxChannel';
|
|
30
21
|
import { createProxyClientPartition } from '../partitions/ProxyClientPartition';
|
|
31
22
|
import { proxy } from 'comlink';
|
|
23
|
+
import { createLocalStoragePartition } from '../partitions/LocalStoragePartition';
|
|
32
24
|
export class BrowserAuxChannel extends RemoteAuxChannel {
|
|
33
25
|
constructor(defaultHost, config) {
|
|
34
26
|
super(config, {});
|
|
35
27
|
BrowserAuxChannel.defaultHost = defaultHost;
|
|
36
28
|
}
|
|
37
|
-
_createPartition(config, services) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!partition) {
|
|
44
|
-
partition = yield createAuxPartition(config, services, createProxyClientPartition);
|
|
45
|
-
}
|
|
46
|
-
return partition;
|
|
47
|
-
});
|
|
29
|
+
async _createPartition(config, services) {
|
|
30
|
+
let partition = await super._createPartition(config, services);
|
|
31
|
+
if (!partition) {
|
|
32
|
+
partition = await createAuxPartition(config, services, createProxyClientPartition, createLocalStoragePartition);
|
|
33
|
+
}
|
|
34
|
+
return partition;
|
|
48
35
|
}
|
|
49
36
|
_createSubChannel(runtime, config) {
|
|
50
37
|
const channel = new BrowserAuxChannel(BrowserAuxChannel.defaultHost, config);
|
|
@@ -54,7 +41,7 @@ export class BrowserAuxChannel extends RemoteAuxChannel {
|
|
|
54
41
|
_handleSubChannelAdded(subChannel) {
|
|
55
42
|
return super._handleSubChannelAdded(proxy({
|
|
56
43
|
getInfo: subChannel.getInfo,
|
|
57
|
-
getChannel: () =>
|
|
44
|
+
getChannel: async () => proxy(await subChannel.getChannel()),
|
|
58
45
|
}));
|
|
59
46
|
}
|
|
60
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserAuxChannel.js","sourceRoot":"","sources":["BrowserAuxChannel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BrowserAuxChannel.js","sourceRoot":"","sources":["BrowserAuxChannel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,+CAA+C,CAAC;AAMvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,MAAM,OAAO,iBAAkB,SAAQ,gBAAgB;IAGnD,YAAY,WAAmB,EAAE,MAAiB;QAC9C,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAClB,iBAAiB,CAAC,WAAW,GAAG,WAAW,CAAC;IAChD,CAAC;IAES,KAAK,CAAC,gBAAgB,CAC5B,MAAuB,EACvB,QAA8B;QAE9B,IAAI,SAAS,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,SAAS,GAAG,MAAM,kBAAkB,CAChC,MAAM,EACN,QAAQ,EACR,0BAA0B,EAC1B,2BAA2B,CAC9B,CAAC;QACN,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,iBAAiB,CACvB,OAAmB,EACnB,MAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,iBAAiB,CACjC,iBAAiB,CAAC,WAAW,EAC7B,MAAM,CACT,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC3B,OAAO,OAAO,CAAC;IACnB,CAAC;IAES,sBAAsB,CAAC,UAAyB;QACtD,OAAO,KAAK,CAAC,sBAAsB,CAC/B,KAAK,CAAC;YACF,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;SAC/D,CAAC,CACL,CAAC;IACN,CAAC;CACJ"}
|
package/vm/ConnectableAuxVM.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { RemoteAuxVM } from '@casual-simulation/aux-vm-client/vm';
|
|
11
2
|
import { proxy, releaseProxy, wrap } from 'comlink';
|
|
12
3
|
import { Subject, Subscription } from 'rxjs';
|
|
@@ -60,10 +51,8 @@ export class ConnectableAuxVM {
|
|
|
60
51
|
get onAuthMessage() {
|
|
61
52
|
return this._onAuthMessage;
|
|
62
53
|
}
|
|
63
|
-
init() {
|
|
64
|
-
|
|
65
|
-
yield this._proxy.registerListeners(proxy((events) => this._localEvents.next(events)), proxy((events) => this._deviceEvents.next(events)), proxy((state) => this._stateUpdated.next(state)), proxy((version) => this._versionUpdated.next(version)), proxy((state) => this._connectionStateChanged.next(state)), proxy((err) => this._onError.next(err)), proxy((channel) => this._handleAddedSubChannel(channel)), proxy((id) => this._handleRemovedSubChannel(id)), proxy((message) => this._onAuthMessage.next(message)));
|
|
66
|
-
});
|
|
54
|
+
async init() {
|
|
55
|
+
await this._proxy.registerListeners(proxy((events) => this._localEvents.next(events)), proxy((events) => this._deviceEvents.next(events)), proxy((state) => this._stateUpdated.next(state)), proxy((version) => this._versionUpdated.next(version)), proxy((state) => this._connectionStateChanged.next(state)), proxy((err) => this._onError.next(err)), proxy((channel) => this._handleAddedSubChannel(channel)), proxy((id) => this._handleRemovedSubChannel(id)), proxy((message) => this._onAuthMessage.next(message)));
|
|
67
56
|
}
|
|
68
57
|
unsubscribe() {
|
|
69
58
|
this._sub.unsubscribe();
|
|
@@ -93,12 +82,10 @@ export class ConnectableAuxVM {
|
|
|
93
82
|
* Sends the given list of events to the simulation.
|
|
94
83
|
* @param events The events to send to the simulation.
|
|
95
84
|
*/
|
|
96
|
-
sendEvents(events) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return yield this._proxy.sendEvents(events);
|
|
101
|
-
});
|
|
85
|
+
async sendEvents(events) {
|
|
86
|
+
if (!this._proxy)
|
|
87
|
+
return null;
|
|
88
|
+
return await this._proxy.sendEvents(events);
|
|
102
89
|
}
|
|
103
90
|
/**
|
|
104
91
|
* Executes a shout with the given event name on the given bot IDs with the given argument.
|
|
@@ -108,57 +95,43 @@ export class ConnectableAuxVM {
|
|
|
108
95
|
* @param botIds The IDs of the bots that the shout is being sent to.
|
|
109
96
|
* @param arg The argument to include in the shout.
|
|
110
97
|
*/
|
|
111
|
-
shout(eventName, botIds, arg) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
exportBots(botIds) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
if (!this._proxy)
|
|
135
|
-
return null;
|
|
136
|
-
return yield this._proxy.exportBots(botIds);
|
|
137
|
-
});
|
|
98
|
+
async shout(eventName, botIds, arg) {
|
|
99
|
+
if (!this._proxy)
|
|
100
|
+
return null;
|
|
101
|
+
return await this._proxy.shout(eventName, botIds, arg);
|
|
102
|
+
}
|
|
103
|
+
async formulaBatch(formulas) {
|
|
104
|
+
if (!this._proxy)
|
|
105
|
+
return null;
|
|
106
|
+
return await this._proxy.formulaBatch(formulas);
|
|
107
|
+
}
|
|
108
|
+
async forkAux(newId) {
|
|
109
|
+
if (!this._proxy)
|
|
110
|
+
return null;
|
|
111
|
+
return await this._proxy.forkAux(newId);
|
|
112
|
+
}
|
|
113
|
+
async exportBots(botIds) {
|
|
114
|
+
if (!this._proxy)
|
|
115
|
+
return null;
|
|
116
|
+
return await this._proxy.exportBots(botIds);
|
|
138
117
|
}
|
|
139
118
|
/**
|
|
140
119
|
* Exports the causal tree for the simulation.
|
|
141
120
|
*/
|
|
142
|
-
export() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return yield this._proxy.export();
|
|
147
|
-
});
|
|
121
|
+
async export() {
|
|
122
|
+
if (!this._proxy)
|
|
123
|
+
return null;
|
|
124
|
+
return await this._proxy.export();
|
|
148
125
|
}
|
|
149
|
-
getTags() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return yield this._proxy.getTags();
|
|
154
|
-
});
|
|
126
|
+
async getTags() {
|
|
127
|
+
if (!this._proxy)
|
|
128
|
+
return null;
|
|
129
|
+
return await this._proxy.getTags();
|
|
155
130
|
}
|
|
156
|
-
updateDevice(device) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return yield this._proxy.updateDevice(device);
|
|
161
|
-
});
|
|
131
|
+
async updateDevice(device) {
|
|
132
|
+
if (!this._proxy)
|
|
133
|
+
return null;
|
|
134
|
+
return await this._proxy.updateDevice(device);
|
|
162
135
|
}
|
|
163
136
|
_createSubVM(id, origin, configBotId, channel) {
|
|
164
137
|
return new RemoteAuxVM(id, origin, configBotId, channel);
|
|
@@ -166,27 +139,23 @@ export class ConnectableAuxVM {
|
|
|
166
139
|
sendAuthMessage(message) {
|
|
167
140
|
return this._proxy.sendAuthMessage(message);
|
|
168
141
|
}
|
|
169
|
-
_handleAddedSubChannel(subChannel) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this._subVMMap.delete(channelId);
|
|
187
|
-
this._subVMRemoved.next(vm);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
142
|
+
async _handleAddedSubChannel(subChannel) {
|
|
143
|
+
const { id, configBotId } = await subChannel.getInfo();
|
|
144
|
+
const channel = (await subChannel.getChannel());
|
|
145
|
+
const subVM = {
|
|
146
|
+
id,
|
|
147
|
+
vm: this._createSubVM(id, this.origin, configBotId, channel),
|
|
148
|
+
channel,
|
|
149
|
+
};
|
|
150
|
+
this._subVMMap.set(id, subVM);
|
|
151
|
+
this._subVMAdded.next(subVM);
|
|
152
|
+
}
|
|
153
|
+
async _handleRemovedSubChannel(channelId) {
|
|
154
|
+
const vm = this._subVMMap.get(channelId);
|
|
155
|
+
if (vm) {
|
|
156
|
+
this._subVMMap.delete(channelId);
|
|
157
|
+
this._subVMRemoved.next(vm);
|
|
158
|
+
}
|
|
190
159
|
}
|
|
191
160
|
}
|
|
192
161
|
//# sourceMappingURL=ConnectableAuxVM.js.map
|