@casual-simulation/aux-vm-browser 3.4.6-alpha.14668890889 → 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.
Files changed (38) hide show
  1. package/html/IFrameHelpers.js +28 -39
  2. package/html/IFrameHelpers.js.map +1 -1
  3. package/managers/AuthCoordinator.d.ts +9 -0
  4. package/managers/AuthCoordinator.js +369 -383
  5. package/managers/AuthCoordinator.js.map +1 -1
  6. package/managers/AuthEndpointHelper.d.ts +3 -2
  7. package/managers/AuthEndpointHelper.js +399 -462
  8. package/managers/AuthEndpointHelper.js.map +1 -1
  9. package/managers/AuthHelper.js +2 -2
  10. package/managers/AuthHelper.js.map +1 -1
  11. package/managers/BotManager.js +54 -58
  12. package/managers/BotManager.js.map +1 -1
  13. package/managers/BotPanelManager.js +2 -11
  14. package/managers/BotPanelManager.js.map +1 -1
  15. package/managers/BrowserSimulationCalculations.js +1 -1
  16. package/managers/BrowserSimulationCalculations.js.map +1 -1
  17. package/managers/IdePortalManager.js +2 -11
  18. package/managers/IdePortalManager.js.map +1 -1
  19. package/managers/LivekitManager.js +320 -324
  20. package/managers/LivekitManager.js.map +1 -1
  21. package/managers/SystemPortalCoordinator.js +74 -66
  22. package/managers/SystemPortalCoordinator.js.map +1 -1
  23. package/package.json +15 -12
  24. package/partitions/LocalStoragePartition.d.ts +6 -0
  25. package/partitions/LocalStoragePartition.js +44 -46
  26. package/partitions/LocalStoragePartition.js.map +1 -1
  27. package/partitions/ProxyClientPartition.js +28 -40
  28. package/partitions/ProxyClientPartition.js.map +1 -1
  29. package/vm/AuxVMImpl.js +120 -153
  30. package/vm/AuxVMImpl.js.map +1 -1
  31. package/vm/BrowserAuxChannel.js +9 -22
  32. package/vm/BrowserAuxChannel.js.map +1 -1
  33. package/vm/ConnectableAuxVM.js +54 -85
  34. package/vm/ConnectableAuxVM.js.map +1 -1
  35. package/vm/StaticAuxVMImpl.d.ts +91 -3
  36. package/vm/StaticAuxVMImpl.js +198 -108
  37. package/vm/StaticAuxVMImpl.js.map +1 -1
  38. package/vm/WorkerEntryHelpers.js.map +1 -1
@@ -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 { asyncResult, hasValue, ON_ROOM_JOINED, ON_ROOM_LEAVE, ON_ROOM_OPTIONS_CHANGED, ON_ROOM_REMOTE_JOINED, ON_ROOM_REMOTE_LEAVE, ON_ROOM_SPEAKERS_CHANGED, ON_ROOM_STREAMING, ON_ROOM_STREAM_LOST, ON_ROOM_TRACK_SUBSCRIBED, ON_ROOM_TRACK_UNSUBSCRIBED, } from '@casual-simulation/aux-common';
11
2
  import { Subject } from 'rxjs';
12
3
  /**
@@ -52,187 +43,183 @@ export class LivekitManager {
52
43
  this._addressToTrack = null;
53
44
  this._trackToAddress = null;
54
45
  }
55
- _requestMediaPermissions() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- // Request audio and video permission (required)
46
+ async _requestMediaPermissions() {
47
+ // Request audio and video permission (required)
48
+ try {
49
+ await navigator.mediaDevices.getUserMedia({
50
+ video: true,
51
+ audio: true,
52
+ });
53
+ console.log('[LivekitManager] Media permissions granted.');
54
+ }
55
+ catch (error) {
56
+ console.error('[LivekitManager] Media permissions denied:', error);
57
+ throw new Error('Media permissions are required to join the room.');
58
+ }
59
+ }
60
+ async joinRoom(join) {
61
+ try {
62
+ await this._requestMediaPermissions();
63
+ this._livekit = await import('livekit-client');
64
+ const room = new this._livekit.Room({
65
+ adaptiveStream: false,
66
+ dynacast: true,
67
+ ...join.options,
68
+ });
69
+ room.on(this._livekit.RoomEvent.TrackSubscribed, this._onTrackSubscribed(room))
70
+ .on(this._livekit.RoomEvent.TrackUnsubscribed, this._onTrackUnsubscribed(room))
71
+ .on(this._livekit.RoomEvent.Disconnected, this._onDisconnected(room))
72
+ .on(this._livekit.RoomEvent.Reconnected, this._onReconnected(room))
73
+ .on(this._livekit.RoomEvent.LocalTrackPublished, this._onLocalTrackPublished(room))
74
+ .on(this._livekit.RoomEvent.LocalTrackUnpublished, this._onLocalTrackUnpublished(room))
75
+ .on(this._livekit.RoomEvent.TrackMuted, this._onTrackMuted(room))
76
+ .on(this._livekit.RoomEvent.TrackUnmuted, this._onTrackUnmuted(room))
77
+ .on(this._livekit.RoomEvent.ActiveSpeakersChanged, this._onActiveSpeakersChanged(room))
78
+ .on(this._livekit.RoomEvent.ParticipantConnected, this._onParticipantConnected(room))
79
+ .on(this._livekit.RoomEvent.ParticipantDisconnected, this._onParticipantDisconnected(room));
80
+ await room.connect(join.url, join.token, {});
58
81
  try {
59
- yield navigator.mediaDevices.getUserMedia({
82
+ await this._setRoomOptions(room, {
60
83
  video: true,
61
84
  audio: true,
85
+ ...join.options,
62
86
  });
63
- console.log('[LivekitManager] Media permissions granted.');
64
- }
65
- catch (error) {
66
- console.error('[LivekitManager] Media permissions denied:', error);
67
- throw new Error('Media permissions are required to join the room.');
68
- }
69
- });
70
- }
71
- joinRoom(join) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- try {
74
- yield this._requestMediaPermissions();
75
- this._livekit = yield import('livekit-client');
76
- const room = new this._livekit.Room(Object.assign({ adaptiveStream: false, dynacast: true }, join.options));
77
- room.on(this._livekit.RoomEvent.TrackSubscribed, this._onTrackSubscribed(room))
78
- .on(this._livekit.RoomEvent.TrackUnsubscribed, this._onTrackUnsubscribed(room))
79
- .on(this._livekit.RoomEvent.Disconnected, this._onDisconnected(room))
80
- .on(this._livekit.RoomEvent.Reconnected, this._onReconnected(room))
81
- .on(this._livekit.RoomEvent.LocalTrackPublished, this._onLocalTrackPublished(room))
82
- .on(this._livekit.RoomEvent.LocalTrackUnpublished, this._onLocalTrackUnpublished(room))
83
- .on(this._livekit.RoomEvent.TrackMuted, this._onTrackMuted(room))
84
- .on(this._livekit.RoomEvent.TrackUnmuted, this._onTrackUnmuted(room))
85
- .on(this._livekit.RoomEvent.ActiveSpeakersChanged, this._onActiveSpeakersChanged(room))
86
- .on(this._livekit.RoomEvent.ParticipantConnected, this._onParticipantConnected(room))
87
- .on(this._livekit.RoomEvent.ParticipantDisconnected, this._onParticipantDisconnected(room));
88
- yield room.connect(join.url, join.token, {});
89
- try {
90
- yield this._setRoomOptions(room, Object.assign({ video: true, audio: true }, join.options));
91
- }
92
- catch (err) {
93
- console.warn('[LivekitManager] Unable to set room options:', err);
94
- }
95
- this._rooms.push(room);
96
- const options = this._getRoomOptions(room);
97
- join.resolve(options);
98
- let actions = [
99
- {
100
- eventName: ON_ROOM_JOINED,
101
- bots: null,
102
- arg: { roomName: room.name, options },
103
- },
104
- {
105
- eventName: ON_ROOM_STREAMING,
106
- bots: null,
107
- arg: { roomName: room.name, options },
108
- },
109
- ];
110
- // Send initial ON_ROOM_REMOTE_JOINED events
111
- for (let participant of room.remoteParticipants.values()) {
112
- actions.push({
113
- eventName: ON_ROOM_REMOTE_JOINED,
114
- bots: null,
115
- arg: {
116
- roomName: room.name,
117
- remoteId: participant.identity,
118
- },
119
- });
120
- }
121
- this._helper.transaction(...this._helper.actions(actions));
122
87
  }
123
88
  catch (err) {
124
- join.reject('server_error', err.toString());
89
+ console.warn('[LivekitManager] Unable to set room options:', err);
90
+ }
91
+ this._rooms.push(room);
92
+ const options = this._getRoomOptions(room);
93
+ join.resolve(options);
94
+ let actions = [
95
+ {
96
+ eventName: ON_ROOM_JOINED,
97
+ bots: null,
98
+ arg: { roomName: room.name, options },
99
+ },
100
+ {
101
+ eventName: ON_ROOM_STREAMING,
102
+ bots: null,
103
+ arg: { roomName: room.name, options },
104
+ },
105
+ ];
106
+ // Send initial ON_ROOM_REMOTE_JOINED events
107
+ for (let participant of room.remoteParticipants.values()) {
108
+ actions.push({
109
+ eventName: ON_ROOM_REMOTE_JOINED,
110
+ bots: null,
111
+ arg: {
112
+ roomName: room.name,
113
+ remoteId: participant.identity,
114
+ },
115
+ });
125
116
  }
126
- });
117
+ this._helper.transaction(...this._helper.actions(actions));
118
+ }
119
+ catch (err) {
120
+ join.reject('server_error', err.toString());
121
+ }
127
122
  }
128
- leaveRoom(leave) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- try {
131
- const index = this._rooms.findIndex((r) => r.name === leave.roomName);
132
- let room;
133
- let actions = [];
134
- if (index >= 0) {
135
- room = this._rooms[index];
136
- this._rooms.splice(index, 1);
137
- if (room) {
138
- // Send ON_ROOM_REMOTE_LEAVE events
139
- for (let participant of room.remoteParticipants.values()) {
140
- actions.push({
141
- eventName: ON_ROOM_REMOTE_LEAVE,
142
- bots: null,
143
- arg: {
144
- roomName: room.name,
145
- remoteId: participant.identity,
146
- },
147
- });
148
- }
149
- room.disconnect(true);
150
- }
151
- }
152
- leave.resolve();
123
+ async leaveRoom(leave) {
124
+ try {
125
+ const index = this._rooms.findIndex((r) => r.name === leave.roomName);
126
+ let room;
127
+ let actions = [];
128
+ if (index >= 0) {
129
+ room = this._rooms[index];
130
+ this._rooms.splice(index, 1);
153
131
  if (room) {
154
- actions.push({
155
- eventName: ON_ROOM_STREAM_LOST,
156
- bots: null,
157
- arg: { roomName: leave.roomName },
158
- }, {
159
- eventName: ON_ROOM_LEAVE,
160
- bots: null,
161
- arg: { roomName: leave.roomName },
162
- });
163
- this._helper.transaction(...this._helper.actions(actions));
164
- }
165
- }
166
- catch (err) {
167
- leave.reject('error', err.toString());
168
- }
169
- });
170
- }
171
- setRoomOptions(setRoomOptions) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- try {
174
- const room = this._rooms.find((r) => r.name === setRoomOptions.roomName);
175
- if (!room || !this._livekit) {
176
- setRoomOptions.reject('room_not_found', 'The specified room was not found.');
177
- return;
178
- }
179
- const changed = yield this._setRoomOptions(room, setRoomOptions.options);
180
- const options = this._getRoomOptions(room);
181
- let rejected = false;
182
- for (let key in setRoomOptions.options) {
183
- const targetValue = setRoomOptions.options[key];
184
- const currentValue = options[key];
185
- if (targetValue !== currentValue) {
186
- setRoomOptions.reject('error', `Unable to set "${key}" to ${targetValue}`);
187
- rejected = true;
132
+ // Send ON_ROOM_REMOTE_LEAVE events
133
+ for (let participant of room.remoteParticipants.values()) {
134
+ actions.push({
135
+ eventName: ON_ROOM_REMOTE_LEAVE,
136
+ bots: null,
137
+ arg: {
138
+ roomName: room.name,
139
+ remoteId: participant.identity,
140
+ },
141
+ });
188
142
  }
189
- }
190
- if (!rejected) {
191
- setRoomOptions.resolve(options);
192
- }
193
- if (changed) {
194
- this._helper.action(ON_ROOM_OPTIONS_CHANGED, null, {
195
- roomName: room.name,
196
- options,
197
- });
143
+ room.disconnect(true);
198
144
  }
199
145
  }
200
- catch (err) {
201
- setRoomOptions.reject('error', err.toString());
146
+ leave.resolve();
147
+ if (room) {
148
+ actions.push({
149
+ eventName: ON_ROOM_STREAM_LOST,
150
+ bots: null,
151
+ arg: { roomName: leave.roomName },
152
+ }, {
153
+ eventName: ON_ROOM_LEAVE,
154
+ bots: null,
155
+ arg: { roomName: leave.roomName },
156
+ });
157
+ this._helper.transaction(...this._helper.actions(actions));
202
158
  }
203
- });
159
+ }
160
+ catch (err) {
161
+ leave.reject('error', err.toString());
162
+ }
204
163
  }
205
- _setRoomOptions(room, options) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- let promises = [];
208
- if ('video' in options) {
209
- promises.push(room.localParticipant.setCameraEnabled(!!options.video));
164
+ async setRoomOptions(setRoomOptions) {
165
+ try {
166
+ const room = this._rooms.find((r) => r.name === setRoomOptions.roomName);
167
+ if (!room || !this._livekit) {
168
+ setRoomOptions.reject('room_not_found', 'The specified room was not found.');
169
+ return;
170
+ }
171
+ const changed = await this._setRoomOptions(room, setRoomOptions.options);
172
+ const options = this._getRoomOptions(room);
173
+ let rejected = false;
174
+ for (let key in setRoomOptions.options) {
175
+ const targetValue = setRoomOptions.options[key];
176
+ const currentValue = options[key];
177
+ if (targetValue !== currentValue) {
178
+ setRoomOptions.reject('error', `Unable to set "${key}" to ${targetValue}`);
179
+ rejected = true;
180
+ }
210
181
  }
211
- if ('audio' in options) {
212
- promises.push(room.localParticipant.setMicrophoneEnabled(!!options.audio));
182
+ if (!rejected) {
183
+ setRoomOptions.resolve(options);
213
184
  }
214
- if ('screen' in options) {
215
- promises.push(room.localParticipant.setScreenShareEnabled(!!options.screen));
185
+ if (changed) {
186
+ this._helper.action(ON_ROOM_OPTIONS_CHANGED, null, {
187
+ roomName: room.name,
188
+ options,
189
+ });
216
190
  }
217
- const results = yield Promise.allSettled(promises);
218
- return results.some((r) => r.status === 'fulfilled');
219
- });
191
+ }
192
+ catch (err) {
193
+ setRoomOptions.reject('error', err.toString());
194
+ }
220
195
  }
221
- getRoomOptions(getRoomOptions) {
222
- return __awaiter(this, void 0, void 0, function* () {
223
- try {
224
- const room = this._rooms.find((r) => r.name === getRoomOptions.roomName);
225
- if (!room) {
226
- getRoomOptions.reject('room_not_found', 'The specified room was not found.');
227
- return;
228
- }
229
- const options = this._getRoomOptions(room);
230
- getRoomOptions.resolve(options);
231
- }
232
- catch (err) {
233
- getRoomOptions.reject('error', err.toString());
234
- }
235
- });
196
+ async _setRoomOptions(room, options) {
197
+ let promises = [];
198
+ if ('video' in options) {
199
+ promises.push(room.localParticipant.setCameraEnabled(!!options.video));
200
+ }
201
+ if ('audio' in options) {
202
+ promises.push(room.localParticipant.setMicrophoneEnabled(!!options.audio));
203
+ }
204
+ if ('screen' in options) {
205
+ promises.push(room.localParticipant.setScreenShareEnabled(!!options.screen));
206
+ }
207
+ const results = await Promise.allSettled(promises);
208
+ return results.some((r) => r.status === 'fulfilled');
209
+ }
210
+ async getRoomOptions(getRoomOptions) {
211
+ try {
212
+ const room = this._rooms.find((r) => r.name === getRoomOptions.roomName);
213
+ if (!room) {
214
+ getRoomOptions.reject('room_not_found', 'The specified room was not found.');
215
+ return;
216
+ }
217
+ const options = this._getRoomOptions(room);
218
+ getRoomOptions.resolve(options);
219
+ }
220
+ catch (err) {
221
+ getRoomOptions.reject('error', err.toString());
222
+ }
236
223
  }
237
224
  _getRoomOptions(room) {
238
225
  return this._getParticipantOptions(room.localParticipant);
@@ -275,130 +262,126 @@ export class LivekitManager {
275
262
  }
276
263
  }
277
264
  }
278
- _getRoomTrackOptions(event) {
279
- return __awaiter(this, void 0, void 0, function* () {
280
- try {
281
- const room = this._rooms.find((r) => r.name === event.roomName);
282
- if (!room || !this._livekit) {
283
- this._helper.transaction(asyncResult(event.taskId, {
284
- success: false,
285
- errorCode: 'room_not_found',
286
- errorMessage: 'The specified room was not found.',
287
- roomName: event.roomName,
288
- }));
289
- return;
290
- }
291
- const pub = this._addressToPublication.get(event.address);
292
- const participant = this._addressToParticipant.get(event.address);
293
- if (!pub || !participant) {
294
- this._helper.transaction(asyncResult(event.taskId, {
295
- success: false,
296
- errorCode: 'track_not_found',
297
- errorMessage: 'The specified track was not found.',
298
- roomName: event.roomName,
299
- address: event.address,
300
- }));
301
- return;
302
- }
303
- const options = this._getTrackOptions(pub, participant);
265
+ async _getRoomTrackOptions(event) {
266
+ try {
267
+ const room = this._rooms.find((r) => r.name === event.roomName);
268
+ if (!room || !this._livekit) {
304
269
  this._helper.transaction(asyncResult(event.taskId, {
305
- success: true,
306
- roomName: room.name,
270
+ success: false,
271
+ errorCode: 'room_not_found',
272
+ errorMessage: 'The specified room was not found.',
273
+ roomName: event.roomName,
274
+ }));
275
+ return;
276
+ }
277
+ const pub = this._addressToPublication.get(event.address);
278
+ const participant = this._addressToParticipant.get(event.address);
279
+ if (!pub || !participant) {
280
+ this._helper.transaction(asyncResult(event.taskId, {
281
+ success: false,
282
+ errorCode: 'track_not_found',
283
+ errorMessage: 'The specified track was not found.',
284
+ roomName: event.roomName,
307
285
  address: event.address,
308
- options,
309
286
  }));
287
+ return;
310
288
  }
311
- catch (err) {
312
- if (hasValue(event.taskId)) {
313
- this._helper.transaction(asyncResult(event.taskId, {
314
- success: false,
315
- errorCode: 'error',
316
- errorMessage: err.toString(),
317
- roomName: event.roomName,
318
- address: event.address,
319
- }));
320
- }
289
+ const options = this._getTrackOptions(pub, participant);
290
+ this._helper.transaction(asyncResult(event.taskId, {
291
+ success: true,
292
+ roomName: room.name,
293
+ address: event.address,
294
+ options,
295
+ }));
296
+ }
297
+ catch (err) {
298
+ if (hasValue(event.taskId)) {
299
+ this._helper.transaction(asyncResult(event.taskId, {
300
+ success: false,
301
+ errorCode: 'error',
302
+ errorMessage: err.toString(),
303
+ roomName: event.roomName,
304
+ address: event.address,
305
+ }));
321
306
  }
322
- });
307
+ }
323
308
  }
324
- _setRoomTrackOptions(event) {
325
- return __awaiter(this, void 0, void 0, function* () {
326
- try {
327
- const room = this._rooms.find((r) => r.name === event.roomName);
328
- if (!room || !this._livekit) {
329
- this._helper.transaction(asyncResult(event.taskId, {
330
- success: false,
331
- errorCode: 'room_not_found',
332
- errorMessage: 'The specified room was not found.',
333
- roomName: event.roomName,
334
- }));
335
- return;
309
+ async _setRoomTrackOptions(event) {
310
+ try {
311
+ const room = this._rooms.find((r) => r.name === event.roomName);
312
+ if (!room || !this._livekit) {
313
+ this._helper.transaction(asyncResult(event.taskId, {
314
+ success: false,
315
+ errorCode: 'room_not_found',
316
+ errorMessage: 'The specified room was not found.',
317
+ roomName: event.roomName,
318
+ }));
319
+ return;
320
+ }
321
+ const pub = this._addressToPublication.get(event.address);
322
+ const participant = this._addressToParticipant.get(event.address);
323
+ if (!pub || !participant) {
324
+ this._helper.transaction(asyncResult(event.taskId, {
325
+ success: false,
326
+ errorCode: 'track_not_found',
327
+ errorMessage: 'The specified track was not found.',
328
+ roomName: event.roomName,
329
+ address: event.address,
330
+ }));
331
+ return;
332
+ }
333
+ let promises = [];
334
+ if ('muted' in event.options) {
335
+ if (pub instanceof this._livekit.LocalTrackPublication) {
336
+ if (event.options.muted) {
337
+ promises.push(pub.mute().then(() => { }));
338
+ }
339
+ else {
340
+ promises.push(pub.unmute().then(() => { }));
341
+ }
336
342
  }
337
- const pub = this._addressToPublication.get(event.address);
338
- const participant = this._addressToParticipant.get(event.address);
339
- if (!pub || !participant) {
340
- this._helper.transaction(asyncResult(event.taskId, {
341
- success: false,
342
- errorCode: 'track_not_found',
343
- errorMessage: 'The specified track was not found.',
344
- roomName: event.roomName,
345
- address: event.address,
346
- }));
347
- return;
343
+ else if (pub instanceof this._livekit.RemoteTrackPublication) {
344
+ pub.setEnabled(!event.options.muted);
348
345
  }
349
- let promises = [];
350
- if ('muted' in event.options) {
351
- if (pub instanceof this._livekit.LocalTrackPublication) {
352
- if (event.options.muted) {
353
- promises.push(pub.mute().then(() => { }));
354
- }
355
- else {
356
- promises.push(pub.unmute().then(() => { }));
357
- }
346
+ }
347
+ if ('videoQuality' in event.options) {
348
+ if (pub instanceof this._livekit.RemoteTrackPublication) {
349
+ let quality = this._livekit.VideoQuality.HIGH;
350
+ if (event.options.videoQuality === 'medium') {
351
+ quality = this._livekit.VideoQuality.MEDIUM;
358
352
  }
359
- else if (pub instanceof this._livekit.RemoteTrackPublication) {
360
- pub.setEnabled(!event.options.muted);
353
+ else if (event.options.videoQuality === 'low') {
354
+ quality = this._livekit.VideoQuality.LOW;
361
355
  }
362
- }
363
- if ('videoQuality' in event.options) {
364
- if (pub instanceof this._livekit.RemoteTrackPublication) {
365
- let quality = this._livekit.VideoQuality.HIGH;
366
- if (event.options.videoQuality === 'medium') {
367
- quality = this._livekit.VideoQuality.MEDIUM;
368
- }
369
- else if (event.options.videoQuality === 'low') {
370
- quality = this._livekit.VideoQuality.LOW;
371
- }
372
- else if (event.options.videoQuality === 'high') {
373
- quality = this._livekit.VideoQuality.HIGH;
374
- }
375
- else if (event.options.videoQuality === 'off') {
376
- pub.setEnabled(false);
377
- }
378
- pub.setVideoQuality(quality);
356
+ else if (event.options.videoQuality === 'high') {
357
+ quality = this._livekit.VideoQuality.HIGH;
379
358
  }
359
+ else if (event.options.videoQuality === 'off') {
360
+ pub.setEnabled(false);
361
+ }
362
+ pub.setVideoQuality(quality);
380
363
  }
381
- yield Promise.allSettled(promises);
382
- const options = this._getTrackOptions(pub, participant);
364
+ }
365
+ await Promise.allSettled(promises);
366
+ const options = this._getTrackOptions(pub, participant);
367
+ this._helper.transaction(asyncResult(event.taskId, {
368
+ success: true,
369
+ roomName: room.name,
370
+ address: event.address,
371
+ options,
372
+ }));
373
+ }
374
+ catch (err) {
375
+ if (hasValue(event.taskId)) {
383
376
  this._helper.transaction(asyncResult(event.taskId, {
384
- success: true,
385
- roomName: room.name,
377
+ success: false,
378
+ errorCode: 'error',
379
+ errorMessage: err.toString(),
380
+ roomName: event.roomName,
386
381
  address: event.address,
387
- options,
388
382
  }));
389
383
  }
390
- catch (err) {
391
- if (hasValue(event.taskId)) {
392
- this._helper.transaction(asyncResult(event.taskId, {
393
- success: false,
394
- errorCode: 'error',
395
- errorMessage: err.toString(),
396
- roomName: event.roomName,
397
- address: event.address,
398
- }));
399
- }
400
- }
401
- });
384
+ }
402
385
  }
403
386
  _findRemoteParticipant(room, identity) {
404
387
  for (let p of room.remoteParticipants.values()) {
@@ -408,51 +391,53 @@ export class LivekitManager {
408
391
  }
409
392
  return null;
410
393
  }
411
- _getRoomRemoteOptions(event) {
412
- return __awaiter(this, void 0, void 0, function* () {
413
- try {
414
- const room = this._rooms.find((r) => r.name === event.roomName);
415
- if (!room || !this._livekit) {
416
- this._helper.transaction(asyncResult(event.taskId, {
417
- success: false,
418
- errorCode: 'room_not_found',
419
- errorMessage: 'The specified room was not found.',
420
- roomName: event.roomName,
421
- }));
422
- return;
423
- }
424
- const participant = this._findRemoteParticipant(room, event.remoteId);
425
- if (!participant) {
426
- this._helper.transaction(asyncResult(event.taskId, {
427
- success: false,
428
- errorCode: 'remote_not_found',
429
- errorMessage: 'The specified remote was not found.',
430
- roomName: event.roomName,
431
- remoteId: event.remoteId,
432
- }));
433
- return;
434
- }
435
- const basicOptions = this._getParticipantOptions(participant);
436
- const options = Object.assign(Object.assign({}, basicOptions), { audioLevel: participant.audioLevel, connectionQuality: participant.connectionQuality });
394
+ async _getRoomRemoteOptions(event) {
395
+ try {
396
+ const room = this._rooms.find((r) => r.name === event.roomName);
397
+ if (!room || !this._livekit) {
437
398
  this._helper.transaction(asyncResult(event.taskId, {
438
- success: true,
439
- roomName: room.name,
440
- remoteId: event.remoteId,
441
- options,
399
+ success: false,
400
+ errorCode: 'room_not_found',
401
+ errorMessage: 'The specified room was not found.',
402
+ roomName: event.roomName,
442
403
  }));
404
+ return;
443
405
  }
444
- catch (err) {
445
- if (hasValue(event.taskId)) {
446
- this._helper.transaction(asyncResult(event.taskId, {
447
- success: false,
448
- errorCode: 'error',
449
- errorMessage: err.toString(),
450
- roomName: event.roomName,
451
- remoteId: event.remoteId,
452
- }));
453
- }
406
+ const participant = this._findRemoteParticipant(room, event.remoteId);
407
+ if (!participant) {
408
+ this._helper.transaction(asyncResult(event.taskId, {
409
+ success: false,
410
+ errorCode: 'remote_not_found',
411
+ errorMessage: 'The specified remote was not found.',
412
+ roomName: event.roomName,
413
+ remoteId: event.remoteId,
414
+ }));
415
+ return;
416
+ }
417
+ const basicOptions = this._getParticipantOptions(participant);
418
+ const options = {
419
+ ...basicOptions,
420
+ audioLevel: participant.audioLevel,
421
+ connectionQuality: participant.connectionQuality,
422
+ };
423
+ this._helper.transaction(asyncResult(event.taskId, {
424
+ success: true,
425
+ roomName: room.name,
426
+ remoteId: event.remoteId,
427
+ options,
428
+ }));
429
+ }
430
+ catch (err) {
431
+ if (hasValue(event.taskId)) {
432
+ this._helper.transaction(asyncResult(event.taskId, {
433
+ success: false,
434
+ errorCode: 'error',
435
+ errorMessage: err.toString(),
436
+ roomName: event.roomName,
437
+ remoteId: event.remoteId,
438
+ }));
454
439
  }
455
- });
440
+ }
456
441
  }
457
442
  /**
458
443
  * Gets the media stream that is referenced by the given address.
@@ -527,7 +512,11 @@ export class LivekitManager {
527
512
  };
528
513
  }
529
514
  _trackArg(roomName, pub, participant, address, track) {
530
- return Object.assign({ roomName: roomName, address: address }, this._getTrackOptions(pub, participant, track));
515
+ return {
516
+ roomName: roomName,
517
+ address: address,
518
+ ...this._getTrackOptions(pub, participant, track),
519
+ };
531
520
  }
532
521
  _getTrackOptions(pub, participant, t) {
533
522
  const track = t !== null && t !== void 0 ? t : pub.track;
@@ -540,10 +529,17 @@ export class LivekitManager {
540
529
  source: track.source,
541
530
  };
542
531
  if (pub.kind === this._livekit.Track.Kind.Video) {
543
- return Object.assign(Object.assign({}, common), { dimensions: pub.dimensions, aspectRatio: pub.dimensions.width / pub.dimensions.height, videoQuality: this._getTrackQuality(pub) });
532
+ return {
533
+ ...common,
534
+ dimensions: pub.dimensions,
535
+ aspectRatio: pub.dimensions.width / pub.dimensions.height,
536
+ videoQuality: this._getTrackQuality(pub),
537
+ };
544
538
  }
545
539
  else {
546
- return Object.assign({}, common);
540
+ return {
541
+ ...common,
542
+ };
547
543
  }
548
544
  }
549
545
  _onDisconnected(room) {