@realsee/live 0.4.0-beta.5 → 0.4.0-beta.8

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.
@@ -13,7 +13,97 @@ var JSBridge__default = /*#__PURE__*/_interopDefaultLegacy(JSBridge);
13
13
  var TRTC__default = /*#__PURE__*/_interopDefaultLegacy(TRTC);
14
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
15
 
16
- const EVENT_SYMBOL = Symbol('$$REALSEE_LIVE_EVENT$$');
16
+ /******************************************************************************
17
+ Copyright (c) Microsoft Corporation.
18
+
19
+ Permission to use, copy, modify, and/or distribute this software for any
20
+ purpose with or without fee is hereby granted.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
23
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
25
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
27
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28
+ PERFORMANCE OF THIS SOFTWARE.
29
+ ***************************************************************************** */
30
+ /* global Reflect, Promise */
31
+
32
+ var extendStatics = function(d, b) {
33
+ extendStatics = Object.setPrototypeOf ||
34
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
36
+ return extendStatics(d, b);
37
+ };
38
+
39
+ function __extends(d, b) {
40
+ if (typeof b !== "function" && b !== null)
41
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
42
+ extendStatics(d, b);
43
+ function __() { this.constructor = d; }
44
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45
+ }
46
+
47
+ var __assign = function() {
48
+ __assign = Object.assign || function __assign(t) {
49
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
50
+ s = arguments[i];
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
52
+ }
53
+ return t;
54
+ };
55
+ return __assign.apply(this, arguments);
56
+ };
57
+
58
+ function __awaiter(thisArg, _arguments, P, generator) {
59
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
60
+ return new (P || (P = Promise))(function (resolve, reject) {
61
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
62
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
63
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
64
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
65
+ });
66
+ }
67
+
68
+ function __generator(thisArg, body) {
69
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
70
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
71
+ function verb(n) { return function (v) { return step([n, v]); }; }
72
+ function step(op) {
73
+ if (f) throw new TypeError("Generator is already executing.");
74
+ while (_) try {
75
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
76
+ if (y = 0, t) op = [op[0] & 2, t.value];
77
+ switch (op[0]) {
78
+ case 0: case 1: t = op; break;
79
+ case 4: _.label++; return { value: op[1], done: false };
80
+ case 5: _.label++; y = op[1]; op = [0]; continue;
81
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
82
+ default:
83
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
84
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
85
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
86
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
87
+ if (t[2]) _.ops.pop();
88
+ _.trys.pop(); continue;
89
+ }
90
+ op = body.call(thisArg, _);
91
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
92
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
93
+ }
94
+ }
95
+
96
+ function __spreadArray(to, from, pack) {
97
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
98
+ if (ar || !(i in from)) {
99
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
100
+ ar[i] = from[i];
101
+ }
102
+ }
103
+ return to.concat(ar || Array.prototype.slice.call(from));
104
+ }
105
+
106
+ var EVENT_SYMBOL = Symbol('$$REALSEE_LIVE_EVENT$$');
17
107
  function __generateEventIfNotExisted(instance) {
18
108
  if (!instance[EVENT_SYMBOL]) {
19
109
  instance[EVENT_SYMBOL] = {};
@@ -36,15 +126,17 @@ function __removeEventIfNotExisted(instance) {
36
126
  * }>()
37
127
  * ```
38
128
  */
39
- class Subscribe {
129
+ var Subscribe = /** @class */ (function () {
130
+ function Subscribe() {
131
+ }
40
132
  /**
41
133
  * 判断是否注册了事件
42
134
  * @param name 事件类型
43
135
  */
44
- hasListener(name) {
45
- const events = __generateEventIfNotExisted(this);
136
+ Subscribe.prototype.hasListener = function (name) {
137
+ var events = __generateEventIfNotExisted(this);
46
138
  return events && events[name] && events[name].length > 0;
47
- }
139
+ };
48
140
  /**
49
141
  * 注册事件
50
142
  * @param name 事件类型
@@ -54,13 +146,14 @@ class Subscribe {
54
146
  * @template K 预设的监听事件名称
55
147
  * @template C 回调函数函数上下文
56
148
  */
57
- on(name, callback, once) {
58
- const events = __generateEventIfNotExisted(this);
149
+ Subscribe.prototype.on = function (name, callback, once) {
150
+ var _this = this;
151
+ var events = __generateEventIfNotExisted(this);
59
152
  if (!events[name])
60
153
  events[name] = [];
61
154
  events[name].push([callback, once || false]);
62
- return () => this.off(name, callback);
63
- }
155
+ return function () { return _this.off(name, callback); };
156
+ };
64
157
  /**
65
158
  * 注册事件(是否只执行一次)
66
159
  * @param name 事件类型
@@ -69,9 +162,9 @@ class Subscribe {
69
162
  * @template K 预设的监听事件名称
70
163
  * @template C 回调函数函数上下文
71
164
  */
72
- once(name, callback) {
165
+ Subscribe.prototype.once = function (name, callback) {
73
166
  return this.on(name, callback, true);
74
- }
167
+ };
75
168
  /**
76
169
  * 解除事件
77
170
  *
@@ -81,19 +174,19 @@ class Subscribe {
81
174
  * @param callback 事件回调函数
82
175
  * @template K 预设的监听事件名称
83
176
  */
84
- off(name, callback) {
177
+ Subscribe.prototype.off = function (name, callback) {
85
178
  if (name === undefined) {
86
179
  __removeEventIfNotExisted(this);
87
180
  return;
88
181
  }
89
- const events = __generateEventIfNotExisted(this);
182
+ var events = __generateEventIfNotExisted(this);
90
183
  if (!events[name])
91
184
  events[name] = [];
92
185
  if (callback === undefined) {
93
186
  events[name].length = 0;
94
187
  return;
95
188
  }
96
- let index = 0;
189
+ var index = 0;
97
190
  for (; index < events[name].length; index++) {
98
191
  if (events[name][index][0] === callback)
99
192
  break;
@@ -101,7 +194,7 @@ class Subscribe {
101
194
  if (index < events[name].length) {
102
195
  events[name].splice(index, 1);
103
196
  }
104
- }
197
+ };
105
198
  /**
106
199
  * 触发事件
107
200
  * @param name 事件类型
@@ -109,27 +202,38 @@ class Subscribe {
109
202
  * @returns canceled 是否被触发取消
110
203
  * @template K 预设的监听事件名称
111
204
  */
112
- emit(name, ...data) {
113
- let canceled = false;
114
- const events = __generateEventIfNotExisted(this);
115
- const event = events[name] || [];
116
- for (let one of event.slice()) {
117
- const [callback, once = false] = one;
118
- const result = callback(...data);
205
+ Subscribe.prototype.emit = function (name) {
206
+ var data = [];
207
+ for (var _i = 1; _i < arguments.length; _i++) {
208
+ data[_i - 1] = arguments[_i];
209
+ }
210
+ var canceled = false;
211
+ var events = __generateEventIfNotExisted(this);
212
+ var event = events[name] || [];
213
+ for (var _a = 0, _b = event.slice(); _a < _b.length; _a++) {
214
+ var one = _b[_a];
215
+ var callback = one[0], _c = one[1], once = _c === void 0 ? false : _c;
216
+ var result = callback.apply(void 0, data);
119
217
  if (once)
120
218
  this.off(name, callback);
121
219
  if (result === false)
122
220
  canceled = true;
123
221
  }
124
222
  return canceled;
125
- }
126
- }
223
+ };
224
+ return Subscribe;
225
+ }());
127
226
 
128
227
  /**
129
228
  * rtc 基础抽象类
130
229
  */
131
- class CoreRTC extends Subscribe {
132
- }
230
+ var CoreRTC = /** @class */ (function (_super) {
231
+ __extends(CoreRTC, _super);
232
+ function CoreRTC() {
233
+ return _super !== null && _super.apply(this, arguments) || this;
234
+ }
235
+ return CoreRTC;
236
+ }(Subscribe));
133
237
 
134
238
  /**
135
239
  * rtc 类型
@@ -169,202 +273,231 @@ function uuid() {
169
273
  S4()).toLowerCase();
170
274
  }
171
275
 
172
- class BrowserRTC extends CoreRTC {
173
- constructor(options) {
174
- super();
175
- this.type = exports.RTCType.RealseeBrowserRTC;
176
- this.joined = false;
177
- this.micro = false;
178
- this.voiceId = '';
179
- this._getVoiceSign = () => {
276
+ var BrowserRTC = /** @class */ (function (_super) {
277
+ __extends(BrowserRTC, _super);
278
+ function BrowserRTC(options) {
279
+ var _this = _super.call(this) || this;
280
+ _this.type = exports.RTCType.RealseeBrowserRTC;
281
+ _this.joined = false;
282
+ _this.micro = false;
283
+ _this.voiceId = '';
284
+ _this._getVoiceSign = function () {
180
285
  throw new Error('方法 getVoiceSign 未实现');
181
286
  };
182
- this.$dom = document.createElement('div');
183
- this._trtc = {
287
+ _this.$dom = document.createElement('div');
288
+ _this._trtc = {
184
289
  client: null,
185
290
  stream: null,
186
291
  };
187
- this.join = async (options) => {
292
+ _this.join = function (options) { return __awaiter(_this, void 0, void 0, function () {
293
+ var createClientOptions, result;
294
+ var _this = this;
188
295
  var _a;
189
- this.emit('joinWillStart');
190
- const createClientOptions = await this._getVoiceSign({
191
- voiceId: options.voiceId,
192
- roomId: options.roomId,
193
- userId: options.userId,
194
- });
195
- // 1. 创建client
196
- this._trtc.client = TRTC__default["default"].createClient({
197
- mode: 'rtc',
198
- ...createClientOptions,
199
- });
200
- (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.enableAudioVolumeEvaluation();
201
- // 2. 订阅事件
202
- this._registerRtcEvent();
203
- // 3. 加入语音房间
204
- let result = await new Promise((resolve) => {
205
- var _a;
206
- (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.join({ roomId: Number(options.voiceId) }).then(() => resolve(true)).catch(() => resolve(false));
207
- });
208
- this.joined = result;
209
- if (!result)
210
- return false; // 进房失败
211
- // 4. 创建本地流
212
- this._trtc.stream = TRTC__default["default"].createStream({
213
- userId: createClientOptions.userId,
214
- audio: true,
215
- video: false,
216
- });
217
- // 5. 初始化本地流
218
- result = await new Promise((resolve) => {
219
- var _a;
220
- (_a = this._trtc.stream) === null || _a === void 0 ? void 0 : _a.initialize().then(() => resolve(true)).catch(() => resolve(false));
221
- });
222
- // 6. 发布本地流
223
- result = await new Promise((resolve) => {
224
- var _a;
225
- (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.publish(this._trtc.stream).then(() => resolve(true)).catch(() => resolve(false));
296
+ return __generator(this, function (_b) {
297
+ switch (_b.label) {
298
+ case 0:
299
+ this.emit('joinWillStart');
300
+ return [4 /*yield*/, this._getVoiceSign({
301
+ voiceId: options.voiceId,
302
+ roomId: options.roomId,
303
+ userId: options.userId,
304
+ })];
305
+ case 1:
306
+ createClientOptions = _b.sent();
307
+ // 1. 创建client
308
+ this._trtc.client = TRTC__default["default"].createClient(__assign({ mode: 'rtc' }, createClientOptions));
309
+ (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.enableAudioVolumeEvaluation();
310
+ // 2. 订阅事件
311
+ this._registerRtcEvent();
312
+ return [4 /*yield*/, new Promise(function (resolve) {
313
+ var _a;
314
+ (_a = _this._trtc.client) === null || _a === void 0 ? void 0 : _a.join({ roomId: Number(options.voiceId) }).then(function () { return resolve(true); }).catch(function () { return resolve(false); });
315
+ })];
316
+ case 2:
317
+ result = _b.sent();
318
+ this.joined = result;
319
+ if (!result)
320
+ return [2 /*return*/, false]; // 进房失败
321
+ // 4. 创建本地流
322
+ this._trtc.stream = TRTC__default["default"].createStream({
323
+ userId: createClientOptions.userId,
324
+ audio: true,
325
+ video: false,
326
+ });
327
+ return [4 /*yield*/, new Promise(function (resolve) {
328
+ var _a;
329
+ (_a = _this._trtc.stream) === null || _a === void 0 ? void 0 : _a.initialize().then(function () { return resolve(true); }).catch(function () { return resolve(false); });
330
+ })];
331
+ case 3:
332
+ // 5. 初始化本地流
333
+ result = _b.sent();
334
+ return [4 /*yield*/, new Promise(function (resolve) {
335
+ var _a;
336
+ (_a = _this._trtc.client) === null || _a === void 0 ? void 0 : _a.publish(_this._trtc.stream).then(function () { return resolve(true); }).catch(function () { return resolve(false); });
337
+ })];
338
+ case 4:
339
+ // 6. 发布本地流
340
+ result = _b.sent();
341
+ this.joined = result;
342
+ if (this.joined)
343
+ this.emit('joined');
344
+ return [2 /*return*/, result];
345
+ }
226
346
  });
227
- this.joined = result;
228
- if (this.joined)
229
- this.emit('joined');
230
- return result;
231
- };
232
- this._handleStreamAdded = (event) => {
347
+ }); };
348
+ _this._handleStreamAdded = function (event) {
233
349
  var _a;
234
- const remoteStream = event.stream;
350
+ var remoteStream = event.stream;
235
351
  console.log('远端流增加: ' + remoteStream.getId());
236
352
  //订阅远端流
237
- (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.subscribe(remoteStream);
353
+ (_a = _this._trtc.client) === null || _a === void 0 ? void 0 : _a.subscribe(remoteStream);
238
354
  };
239
- this._handleStreamSubscribed = (event) => {
240
- const remoteStream = event.stream;
355
+ _this._handleStreamSubscribed = function (event) {
356
+ var remoteStream = event.stream;
241
357
  console.log('远端流订阅成功:' + remoteStream.getId());
242
- const playId = remoteStream.getId();
243
- const domId = `rs-rtc-remote_stream-${playId}`;
244
- const dom = document.createElement('div');
358
+ var playId = remoteStream.getId();
359
+ var domId = "rs-rtc-remote_stream-".concat(playId);
360
+ var dom = document.createElement('div');
245
361
  dom.id = domId;
246
- this.$dom.appendChild(dom);
362
+ _this.$dom.appendChild(dom);
247
363
  // 播放远端流
248
364
  remoteStream.play(domId);
249
365
  };
250
- this._getVoiceSign = options.getVoiceSign;
251
- this._initParentDom();
366
+ _this._getVoiceSign = options.getVoiceSign;
367
+ _this._initParentDom();
368
+ return _this;
252
369
  }
253
- _initParentDom() {
254
- this.$dom.id = `rs-rtc-${uuid()}`;
370
+ BrowserRTC.prototype._initParentDom = function () {
371
+ this.$dom.id = "rs-rtc-".concat(uuid());
255
372
  this.$dom.style.display = 'none';
256
373
  document.body.appendChild(this.$dom);
257
- }
258
- quit() {
259
- return new Promise(async (resolve) => {
374
+ };
375
+ BrowserRTC.prototype.quit = function () {
376
+ var _this = this;
377
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
378
+ var _this = this;
260
379
  var _a, _b;
261
- this.joined = false;
262
- if (this._trtc.stream) {
263
- await ((_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.unpublish(this._trtc.stream));
264
- this._trtc.stream.stop();
265
- this._trtc.stream.close();
266
- this._trtc.stream = null;
267
- }
268
- (_b = this._trtc.client) === null || _b === void 0 ? void 0 : _b.leave().then(() => (this._trtc.client = null)).then(() => resolve(true)).catch(() => resolve(false));
269
- });
270
- }
271
- detectMicro() {
272
- return new Promise((resolve) => {
273
- const rule = { audio: true, video: false };
380
+ return __generator(this, function (_c) {
381
+ switch (_c.label) {
382
+ case 0:
383
+ this.joined = false;
384
+ if (!this._trtc.stream) return [3 /*break*/, 2];
385
+ return [4 /*yield*/, ((_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.unpublish(this._trtc.stream))];
386
+ case 1:
387
+ _c.sent();
388
+ this._trtc.stream.stop();
389
+ this._trtc.stream.close();
390
+ this._trtc.stream = null;
391
+ _c.label = 2;
392
+ case 2:
393
+ (_b = this._trtc.client) === null || _b === void 0 ? void 0 : _b.leave().then(function () { return (_this._trtc.client = null); }).then(function () { return resolve(true); }).catch(function () { return resolve(false); });
394
+ return [2 /*return*/];
395
+ }
396
+ });
397
+ }); });
398
+ };
399
+ BrowserRTC.prototype.detectMicro = function () {
400
+ return new Promise(function (resolve) {
401
+ var rule = { audio: true, video: false };
274
402
  try {
275
403
  navigator.mediaDevices
276
404
  .getUserMedia(rule)
277
- .then(() => resolve(true))
278
- .catch(() => resolve(false));
405
+ .then(function () { return resolve(true); })
406
+ .catch(function () { return resolve(false); });
279
407
  }
280
408
  catch (e) {
281
409
  console.error(e);
282
410
  resolve(false);
283
411
  }
284
412
  });
285
- }
286
- toggleMicro(flag) {
413
+ };
414
+ BrowserRTC.prototype.toggleMicro = function (flag) {
287
415
  var _a, _b, _c, _d;
288
416
  return Promise.resolve((flag
289
417
  ? (_b = (_a = this._trtc) === null || _a === void 0 ? void 0 : _a.stream) === null || _b === void 0 ? void 0 : _b.unmuteAudio()
290
418
  : (_d = (_c = this._trtc) === null || _c === void 0 ? void 0 : _c.stream) === null || _d === void 0 ? void 0 : _d.muteAudio()) || false);
291
- }
292
- shock() {
419
+ };
420
+ BrowserRTC.prototype.shock = function () {
293
421
  throw new Error('Method not implemented.');
294
- }
295
- _registerRtcEvent() {
422
+ };
423
+ BrowserRTC.prototype._registerRtcEvent = function () {
424
+ var _this = this;
296
425
  var _a, _b, _c, _d;
297
426
  (_a = this._trtc.client) === null || _a === void 0 ? void 0 : _a.on('stream-added', this._handleStreamAdded);
298
427
  (_b = this._trtc.client) === null || _b === void 0 ? void 0 : _b.on('stream-subscribed', this._handleStreamSubscribed);
299
- (_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', (event) => this.emit('userVolumes', [
300
- { userId: event.userId, audioVolume: event.audioVolume },
301
- ]));
302
- (_d = this._trtc.client) === null || _d === void 0 ? void 0 : _d.on('error', (event) => this.emit('error', event));
303
- }
304
- }
428
+ (_c = this._trtc.client) === null || _c === void 0 ? void 0 : _c.on('audio-volume', function (event) {
429
+ return _this.emit('userVolumes', [
430
+ { userId: event.userId, audioVolume: event.audioVolume },
431
+ ]);
432
+ });
433
+ (_d = this._trtc.client) === null || _d === void 0 ? void 0 : _d.on('error', function (event) { return _this.emit('error', event); });
434
+ };
435
+ return BrowserRTC;
436
+ }(CoreRTC));
305
437
 
306
438
  /**
307
439
  * amazon-chime-sdk-js 适配的rtc实现
308
440
  */
309
- class BrowserRTC4Chime extends CoreRTC {
310
- constructor(options) {
311
- super();
312
- this.type = exports.RTCType.RealseeBrowserChimeRTC;
313
- this.joined = false;
314
- this.micro = false;
315
- this.voiceId = '';
316
- this.userId = '';
317
- this.deviceChangeObserver = {};
318
- this.audioVideoObserver = {};
319
- this._getVoiceSign = () => {
441
+ var BrowserRTC4Chime = /** @class */ (function (_super) {
442
+ __extends(BrowserRTC4Chime, _super);
443
+ function BrowserRTC4Chime(options) {
444
+ var _this = _super.call(this) || this;
445
+ _this.type = exports.RTCType.RealseeBrowserChimeRTC;
446
+ _this.joined = false;
447
+ _this.micro = false;
448
+ _this.voiceId = '';
449
+ _this.userId = '';
450
+ _this.deviceChangeObserver = {};
451
+ _this.audioVideoObserver = {};
452
+ _this._getVoiceSign = function () {
320
453
  throw new Error('方法 getVoiceSign 未实现');
321
454
  };
322
- this.$dom = document.createElement('div');
323
- this.$audio = document.createElement('audio');
455
+ _this.$dom = document.createElement('div');
456
+ _this.$audio = document.createElement('audio');
324
457
  /**
325
458
  * 对audio标签初始化
326
459
  */
327
- this._initDom = () => {
328
- this.$audio.id = `rs-rtc-${uuid()}`;
329
- this.$dom.id = `rs-rtc-${uuid()}`;
330
- this.$dom.appendChild(this.$audio);
331
- document.body.appendChild(this.$dom);
460
+ _this._initDom = function () {
461
+ _this.$audio.id = "rs-rtc-".concat(uuid());
462
+ _this.$dom.id = "rs-rtc-".concat(uuid());
463
+ _this.$dom.appendChild(_this.$audio);
464
+ document.body.appendChild(_this.$dom);
332
465
  };
333
466
  /**
334
467
  * 初始化事件监听器
335
468
  */
336
- this.initObservers = () => {
469
+ _this.initObservers = function () {
337
470
  // 输入输出设备变化的监听器
338
- this.deviceChangeObserver = {
339
- audioInputsChanged: (freshAudioInputDeviceList) => {
471
+ _this.deviceChangeObserver = {
472
+ audioInputsChanged: function (freshAudioInputDeviceList) {
340
473
  // An array of MediaDeviceInfo objects
341
- freshAudioInputDeviceList === null || freshAudioInputDeviceList === void 0 ? void 0 : freshAudioInputDeviceList.forEach((mediaDeviceInfo) => {
342
- this.logger.info(`Device ID: ${mediaDeviceInfo.deviceId} Microphone: ${mediaDeviceInfo.label}`);
474
+ freshAudioInputDeviceList === null || freshAudioInputDeviceList === void 0 ? void 0 : freshAudioInputDeviceList.forEach(function (mediaDeviceInfo) {
475
+ _this.logger.info("Device ID: ".concat(mediaDeviceInfo.deviceId, " Microphone: ").concat(mediaDeviceInfo.label));
343
476
  });
344
477
  },
345
- audioOutputsChanged: (freshAudioOutputDeviceList) => {
346
- this.logger.info(`Audio outputs updated: ${freshAudioOutputDeviceList}`);
478
+ audioOutputsChanged: function (freshAudioOutputDeviceList) {
479
+ _this.logger.info("Audio outputs updated: ".concat(freshAudioOutputDeviceList));
347
480
  },
348
- videoInputsChanged: (freshVideoInputDeviceList) => {
349
- this.logger.info(`Video inputs updated: ${freshVideoInputDeviceList}`);
481
+ videoInputsChanged: function (freshVideoInputDeviceList) {
482
+ _this.logger.info("Video inputs updated: ".concat(freshVideoInputDeviceList));
350
483
  },
351
- audioInputMuteStateChanged: (device, muted) => {
352
- this.logger.info(`Device ${device.toString()} ${muted ? 'is muted in hardware' : 'is not muted'}`);
484
+ audioInputMuteStateChanged: function (device, muted) {
485
+ _this.logger.info("Device ".concat(device.toString(), " ").concat(muted ? 'is muted in hardware' : 'is not muted'));
353
486
  },
354
487
  };
355
488
  // 流变化监听器
356
- this.audioVideoObserver = {
357
- audioVideoDidStart: () => {
358
- this.logger.info('Started');
489
+ _this.audioVideoObserver = {
490
+ audioVideoDidStart: function () {
491
+ _this.logger.info('Started');
359
492
  },
360
- audioVideoDidStop: (sessionStatus) => {
493
+ audioVideoDidStop: function (sessionStatus) {
361
494
  // See the "Stopping a session" section for details.
362
- this.logger.info(`Stopped with a session status code: ${sessionStatus.statusCode()}`);
495
+ _this.logger.info("Stopped with a session status code: ".concat(sessionStatus.statusCode()));
363
496
  },
364
- audioVideoDidStartConnecting: (reconnecting) => {
497
+ audioVideoDidStartConnecting: function (reconnecting) {
365
498
  if (reconnecting) {
366
499
  // e.g. the WiFi connection is dropped.
367
- this.logger.info('Attempting to reconnect');
500
+ _this.logger.info('Attempting to reconnect');
368
501
  }
369
502
  },
370
503
  };
@@ -372,15 +505,15 @@ class BrowserRTC4Chime extends CoreRTC {
372
505
  /**
373
506
  * 注册rtc事件
374
507
  */
375
- this._registerRtcEvent = () => {
508
+ _this._registerRtcEvent = function () {
376
509
  var _a, _b, _c, _d, _e, _f;
377
- const presentAttendeeId = ((_c = (_b = (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.configuration) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.attendeeId) || '';
510
+ var presentAttendeeId = ((_c = (_b = (_a = _this.meetingSession) === null || _a === void 0 ? void 0 : _a.configuration) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.attendeeId) || '';
378
511
  if (presentAttendeeId) {
379
512
  // 处理音量变化
380
- const roster = new Map();
381
- const getUserVolumes = () => {
382
- const result = [];
383
- roster.forEach((v, k) => {
513
+ var roster_1 = new Map();
514
+ var getUserVolumes_1 = function () {
515
+ var result = [];
516
+ roster_1.forEach(function (v, k) {
384
517
  result.push({
385
518
  userId: v.userId,
386
519
  volume: v.muted || v.signalStrength === 0 || !Boolean(v.volume)
@@ -390,175 +523,208 @@ class BrowserRTC4Chime extends CoreRTC {
390
523
  });
391
524
  return result;
392
525
  };
393
- (_d = this.meetingSession) === null || _d === void 0 ? void 0 : _d.audioVideo.realtimeSubscribeToAttendeeIdPresence((presentAttendeeId, present, externalUserId) => {
526
+ (_d = _this.meetingSession) === null || _d === void 0 ? void 0 : _d.audioVideo.realtimeSubscribeToAttendeeIdPresence(function (presentAttendeeId, present, externalUserId) {
394
527
  var _a;
395
528
  if (!present) {
396
- roster.delete(presentAttendeeId);
397
- this.emit('userVolumes', getUserVolumes());
529
+ roster_1.delete(presentAttendeeId);
530
+ _this.emit('userVolumes', getUserVolumes_1());
398
531
  return;
399
532
  }
400
- (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeSubscribeToVolumeIndicator(presentAttendeeId, (attendeeId, volume, muted, signalStrength) => {
401
- const baseAttendeeId = new amazonChimeSdkJs.DefaultModality(attendeeId).base();
533
+ (_a = _this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeSubscribeToVolumeIndicator(presentAttendeeId, function (attendeeId, volume, muted, signalStrength) {
534
+ var baseAttendeeId = new amazonChimeSdkJs.DefaultModality(attendeeId).base();
402
535
  if (baseAttendeeId !== attendeeId) {
403
536
  // Optional: Do not include the content attendee (attendee-id#content) in the roster.
404
537
  // See the "Screen and content share" section for details.
405
538
  return;
406
539
  }
407
- roster.set(attendeeId, {
540
+ roster_1.set(attendeeId, {
408
541
  userId: externalUserId || attendeeId,
409
- volume,
410
- muted,
411
- signalStrength,
542
+ volume: volume,
543
+ muted: muted,
544
+ signalStrength: signalStrength,
412
545
  });
413
- this.emit('userVolumes', getUserVolumes());
546
+ _this.emit('userVolumes', getUserVolumes_1());
414
547
  });
415
548
  });
416
549
  // 弱网
417
- (_e = this.meetingSession) === null || _e === void 0 ? void 0 : _e.audioVideo.realtimeSubscribeToVolumeIndicator(presentAttendeeId, (attendeeId, volume, muted, signalStrength) => {
418
- const baseAttendeeId = new amazonChimeSdkJs.DefaultModality(attendeeId).base();
550
+ (_e = _this.meetingSession) === null || _e === void 0 ? void 0 : _e.audioVideo.realtimeSubscribeToVolumeIndicator(presentAttendeeId, function (attendeeId, volume, muted, signalStrength) {
551
+ var baseAttendeeId = new amazonChimeSdkJs.DefaultModality(attendeeId).base();
419
552
  if (baseAttendeeId === attendeeId) {
420
553
  if (signalStrength !== null && signalStrength !== 1) {
421
- this.emit('weakNetwork');
554
+ _this.emit('weakNetwork');
422
555
  }
423
556
  }
424
557
  });
425
558
  // 报错
426
- (_f = this.meetingSession) === null || _f === void 0 ? void 0 : _f.audioVideo.realtimeSubscribeToFatalError((error) => this.emit('error', error));
559
+ (_f = _this.meetingSession) === null || _f === void 0 ? void 0 : _f.audioVideo.realtimeSubscribeToFatalError(function (error) { return _this.emit('error', error); });
427
560
  }
428
561
  };
429
562
  // 挂载签名钩子
430
- this._getVoiceSign = options.getVoiceSign;
431
- this._initDom();
432
- this.logger = new amazonChimeSdkJs.ConsoleLogger('WebRTCLogger', options.logLevel || amazonChimeSdkJs.LogLevel.OFF);
433
- this.deviceController = new amazonChimeSdkJs.DefaultDeviceController(this.logger);
434
- this.initObservers();
563
+ _this._getVoiceSign = options.getVoiceSign;
564
+ _this._initDom();
565
+ _this.logger = new amazonChimeSdkJs.ConsoleLogger('WebRTCLogger', options.logLevel || amazonChimeSdkJs.LogLevel.OFF);
566
+ _this.deviceController = new amazonChimeSdkJs.DefaultDeviceController(_this.logger);
567
+ _this.initObservers();
568
+ return _this;
435
569
  }
436
570
  /**
437
571
  * 加入语音会议
438
572
  * @param options
439
573
  * @returns
440
574
  */
441
- async join(options) {
442
- return new Promise(async (success, fail) => {
443
- var _a;
444
- this.emit('joinWillStart');
445
- try {
446
- // 取签名
447
- const { sdkAppId, userId, roomId, userSig } = await this._getVoiceSign({
448
- ...options,
449
- roomId: options.roomId || 0,
450
- });
451
- this.userId = userId;
452
- const { attendence, vendor_wrapper, } = JSON.parse(decodeURIComponent(userSig));
453
- // 初始化配置
454
- const configuration = new amazonChimeSdkJs.MeetingSessionConfiguration({
455
- Meeting: vendor_wrapper,
456
- }, {
457
- Attendee: {
458
- ExternalUserId: attendence.external_user_id,
459
- AttendeeId: attendence.attendee_id,
460
- JoinToken: attendence.join_token,
461
- },
462
- });
463
- // 初始化会议会话
464
- this.meetingSession = new amazonChimeSdkJs.DefaultMeetingSession(configuration, this.logger, this.deviceController);
465
- // 注册事件
466
- this._registerRtcEvent();
467
- // 绑定监听器
468
- this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver);
469
- this.meetingSession.audioVideo.addObserver(this.audioVideoObserver);
470
- // 绑定播放器
471
- this.meetingSession.audioVideo.bindAudioElement(this.$audio);
472
- const observer = {
473
- audioVideoDidStart: () => {
474
- var _a;
475
- (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeMuteLocalAudio();
476
- this.joined = true;
477
- this.emit('joined');
478
- success(true);
479
- },
480
- audioVideoDidStop: () => {
481
- this.joined = false;
482
- success(false);
483
- },
484
- };
485
- this.meetingSession.audioVideo.addObserver(observer);
486
- // 选择语音输入设备
487
- const audioInputDevices = await this.deviceController.listAudioInputDevices(true);
488
- const defaultAudioInput = audioInputDevices.find((device) => device.deviceId === 'default');
489
- const otherAudioInput = audioInputDevices.find((device) => device.deviceId !== '');
490
- this.audioInput = defaultAudioInput || otherAudioInput;
491
- await this.meetingSession.audioVideo.chooseVideoInputDevice(null);
492
- await this.meetingSession.audioVideo.chooseAudioInputDevice(((_a = this.audioInput) === null || _a === void 0 ? void 0 : _a.deviceId) || 'default');
493
- this.meetingSession.audioVideo.start();
494
- }
495
- catch (e) {
496
- this.emit('error', e);
497
- this.logger.error(e.message);
498
- success(false);
499
- }
575
+ BrowserRTC4Chime.prototype.join = function (options) {
576
+ return __awaiter(this, void 0, void 0, function () {
577
+ var _this = this;
578
+ return __generator(this, function (_a) {
579
+ return [2 /*return*/, new Promise(function (success, fail) { return __awaiter(_this, void 0, void 0, function () {
580
+ var _a, userId, userSig, _b, attendence, vendor_wrapper, configuration, observer, audioInputDevices, defaultAudioInput, otherAudioInput, e_1;
581
+ var _this = this;
582
+ var _c;
583
+ return __generator(this, function (_d) {
584
+ switch (_d.label) {
585
+ case 0:
586
+ this.emit('joinWillStart');
587
+ _d.label = 1;
588
+ case 1:
589
+ _d.trys.push([1, 6, , 7]);
590
+ return [4 /*yield*/, this._getVoiceSign(__assign(__assign({}, options), { roomId: options.roomId || 0 }))];
591
+ case 2:
592
+ _a = _d.sent(), userId = _a.userId, userSig = _a.userSig;
593
+ this.userId = userId;
594
+ _b = JSON.parse(decodeURIComponent(userSig)), attendence = _b.attendence, vendor_wrapper = _b.vendor_wrapper;
595
+ configuration = new amazonChimeSdkJs.MeetingSessionConfiguration({
596
+ Meeting: vendor_wrapper,
597
+ }, {
598
+ Attendee: {
599
+ ExternalUserId: attendence.external_user_id,
600
+ AttendeeId: attendence.attendee_id,
601
+ JoinToken: attendence.join_token,
602
+ },
603
+ });
604
+ // 初始化会议会话
605
+ this.meetingSession = new amazonChimeSdkJs.DefaultMeetingSession(configuration, this.logger, this.deviceController);
606
+ // 注册事件
607
+ this._registerRtcEvent();
608
+ // 绑定监听器
609
+ this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver);
610
+ this.meetingSession.audioVideo.addObserver(this.audioVideoObserver);
611
+ // 绑定播放器
612
+ this.meetingSession.audioVideo.bindAudioElement(this.$audio);
613
+ observer = {
614
+ audioVideoDidStart: function () {
615
+ var _a;
616
+ (_a = _this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeMuteLocalAudio();
617
+ _this.joined = true;
618
+ _this.emit('joined');
619
+ success(true);
620
+ },
621
+ audioVideoDidStop: function () {
622
+ _this.joined = false;
623
+ success(false);
624
+ },
625
+ };
626
+ this.meetingSession.audioVideo.addObserver(observer);
627
+ return [4 /*yield*/, this.deviceController.listAudioInputDevices(true)];
628
+ case 3:
629
+ audioInputDevices = _d.sent();
630
+ defaultAudioInput = audioInputDevices.find(function (device) { return device.deviceId === 'default'; });
631
+ otherAudioInput = audioInputDevices.find(function (device) { return device.deviceId !== ''; });
632
+ this.audioInput = defaultAudioInput || otherAudioInput;
633
+ return [4 /*yield*/, this.meetingSession.audioVideo.chooseVideoInputDevice(null)];
634
+ case 4:
635
+ _d.sent();
636
+ return [4 /*yield*/, this.meetingSession.audioVideo.chooseAudioInputDevice(((_c = this.audioInput) === null || _c === void 0 ? void 0 : _c.deviceId) || 'default')];
637
+ case 5:
638
+ _d.sent();
639
+ this.meetingSession.audioVideo.start();
640
+ return [3 /*break*/, 7];
641
+ case 6:
642
+ e_1 = _d.sent();
643
+ this.emit('error', e_1);
644
+ this.logger.error(e_1.message);
645
+ success(false);
646
+ return [3 /*break*/, 7];
647
+ case 7: return [2 /*return*/];
648
+ }
649
+ });
650
+ }); })];
651
+ });
500
652
  });
501
- }
502
- quit() {
503
- return new Promise((success, fail) => {
653
+ };
654
+ BrowserRTC4Chime.prototype.quit = function () {
655
+ var _this = this;
656
+ if (!this.joined)
657
+ return Promise.resolve(true);
658
+ return new Promise(function (success, fail) {
504
659
  var _a, _b;
505
- this.joined = false;
506
- const observer = {
507
- audioVideoDidStop: (sessionStatus) => {
508
- const sessionStatusCode = sessionStatus.statusCode();
660
+ _this.joined = false;
661
+ var observer = {
662
+ audioVideoDidStop: function (sessionStatus) {
663
+ var sessionStatusCode = sessionStatus.statusCode();
509
664
  if (sessionStatusCode === amazonChimeSdkJs.MeetingSessionStatusCode.Left) {
510
665
  /*
511
666
  - You called meetingSession.audioVideo.stop().
512
667
  - When closing a browser window or page, Chime SDK attempts to leave the session.
513
668
  */
514
- this.logger.info('You left the session');
669
+ _this.logger.info('You left the session');
515
670
  success(true);
516
671
  }
517
672
  else {
518
- this.logger.info(`Stopped with a session status code: ${sessionStatusCode}`);
673
+ _this.logger.info("Stopped with a session status code: ".concat(sessionStatusCode));
519
674
  success(true);
520
675
  }
521
676
  },
522
677
  };
523
- (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.addObserver(observer);
524
- (_b = this.meetingSession) === null || _b === void 0 ? void 0 : _b.audioVideo.stop();
678
+ (_a = _this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.addObserver(observer);
679
+ (_b = _this.meetingSession) === null || _b === void 0 ? void 0 : _b.audioVideo.stop();
525
680
  });
526
- }
527
- async detectMicro() {
528
- return new Promise((resolve) => {
529
- const rule = { audio: true, video: false };
530
- try {
531
- navigator.mediaDevices
532
- .getUserMedia(rule)
533
- .then(() => resolve(true))
534
- .catch(() => resolve(false));
535
- }
536
- catch (e) {
537
- this.logger.error(e.message);
538
- resolve(false);
539
- }
681
+ };
682
+ BrowserRTC4Chime.prototype.detectMicro = function () {
683
+ return __awaiter(this, void 0, void 0, function () {
684
+ var _this = this;
685
+ return __generator(this, function (_a) {
686
+ return [2 /*return*/, new Promise(function (resolve) {
687
+ var rule = { audio: true, video: false };
688
+ try {
689
+ navigator.mediaDevices
690
+ .getUserMedia(rule)
691
+ .then(function () { return resolve(true); })
692
+ .catch(function () { return resolve(false); });
693
+ }
694
+ catch (e) {
695
+ _this.logger.error(e.message);
696
+ resolve(false);
697
+ }
698
+ })];
699
+ });
540
700
  });
541
- }
542
- async toggleMicro(flag) {
701
+ };
702
+ BrowserRTC4Chime.prototype.toggleMicro = function (flag) {
543
703
  var _a, _b, _c;
544
- if (flag) {
545
- (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeUnmuteLocalAudio();
546
- }
547
- else {
548
- (_b = this.meetingSession) === null || _b === void 0 ? void 0 : _b.audioVideo.realtimeMuteLocalAudio();
549
- }
550
- const muted = (_c = this.meetingSession) === null || _c === void 0 ? void 0 : _c.audioVideo.realtimeIsLocalAudioMuted();
551
- if (muted !== undefined) {
552
- return flag !== muted;
553
- }
554
- else {
555
- return false;
556
- }
557
- }
558
- shock() {
704
+ return __awaiter(this, void 0, void 0, function () {
705
+ var muted;
706
+ return __generator(this, function (_d) {
707
+ if (flag) {
708
+ (_a = this.meetingSession) === null || _a === void 0 ? void 0 : _a.audioVideo.realtimeUnmuteLocalAudio();
709
+ }
710
+ else {
711
+ (_b = this.meetingSession) === null || _b === void 0 ? void 0 : _b.audioVideo.realtimeMuteLocalAudio();
712
+ }
713
+ muted = (_c = this.meetingSession) === null || _c === void 0 ? void 0 : _c.audioVideo.realtimeIsLocalAudioMuted();
714
+ if (muted !== undefined) {
715
+ return [2 /*return*/, flag !== muted];
716
+ }
717
+ else {
718
+ return [2 /*return*/, false];
719
+ }
720
+ });
721
+ });
722
+ };
723
+ BrowserRTC4Chime.prototype.shock = function () {
559
724
  throw new Error('Method not implemented.');
560
- }
561
- }
725
+ };
726
+ return BrowserRTC4Chime;
727
+ }(CoreRTC));
562
728
 
563
729
  /**
564
730
  * rtc加入返回值code枚举
@@ -583,75 +749,122 @@ exports.RTCJoinedInfoCodeEnum = void 0;
583
749
  RTCJoinedInfoCodeEnum[RTCJoinedInfoCodeEnum["NoMicroPermission"] = 3] = "NoMicroPermission";
584
750
  })(exports.RTCJoinedInfoCodeEnum || (exports.RTCJoinedInfoCodeEnum = {}));
585
751
 
586
- class VRWebViewRTC extends CoreRTC {
587
- constructor({ jsBridge, getVoiceSign }) {
588
- super();
589
- this.type = exports.RTCType.RealseeVRWebViewRTC;
590
- this.joined = false;
591
- this.micro = false;
592
- this.voiceId = '';
593
- this.options = { jsBridge, getVoiceSign };
594
- this.jsBridge.callAndListen('live/userVolumes', (userVolumes) => {
595
- this.emit('userVolumes', userVolumes);
752
+ var VRWebViewRTC = /** @class */ (function (_super) {
753
+ __extends(VRWebViewRTC, _super);
754
+ function VRWebViewRTC(_a) {
755
+ var jsBridge = _a.jsBridge, getVoiceSign = _a.getVoiceSign;
756
+ var _this = _super.call(this) || this;
757
+ _this.type = exports.RTCType.RealseeVRWebViewRTC;
758
+ _this.joined = false;
759
+ _this.micro = false;
760
+ _this.voiceId = '';
761
+ _this.options = { jsBridge: jsBridge, getVoiceSign: getVoiceSign };
762
+ _this.jsBridge.callAndListen('live/userVolumes', function (userVolumes) {
763
+ _this.emit('userVolumes', userVolumes);
596
764
  });
597
- this.jsBridge.callAndListen('live/weakNetwork', (weakNetwork) => {
765
+ _this.jsBridge.callAndListen('live/weakNetwork', function (weakNetwork) {
598
766
  if (weakNetwork)
599
- this.emit('weakNetwork');
767
+ _this.emit('weakNetwork');
600
768
  });
769
+ return _this;
601
770
  }
602
- get jsBridge() {
603
- return this.options.jsBridge;
604
- }
605
- async join(options) {
606
- this.emit('joinWillStart');
607
- const { sdkAppId, userId, userSig } = await this.options.getVoiceSign(options);
608
- this.type = options.type;
609
- const [res, error] = await this.jsBridge.callAndBackfeed(`live/join?sdkAppID=${sdkAppId}&userID=${userId}&roomID=${Number(options.voiceId)}&userSig=${userSig}`);
610
- if (!res) {
611
- this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
612
- this.joined = false;
613
- }
614
- else {
615
- if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
616
- this.emit('joined');
617
- this.joined = true;
618
- }
619
- else {
620
- this.emit('error', res);
621
- this.joined = false;
622
- }
623
- }
624
- return this.joined;
625
- }
626
- async quit() {
627
- const [res, error] = await this.jsBridge.callAndBackfeed('live/quit');
628
- if (res === null) {
629
- this.emit('error', error ? error : new Error('退出房间失败:未知异常。'));
630
- }
631
- this.joined = false;
632
- return !!res;
633
- }
634
- async detectMicro() {
635
- const [res, error] = await this.jsBridge.detectMicro();
636
- if (res === null) {
637
- this.emit('error', error ? error : new Error('麦克风监测异常!'));
638
- return false;
639
- }
640
- return res;
641
- }
642
- async toggleMicro(flag) {
643
- const [res, error] = await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${!!flag ? 1 : 0}`);
644
- if (res === null) {
645
- this.emit('error', error ? error : new Error('麦克风监测异常!'));
646
- return false;
647
- }
648
- this.micro = res;
649
- return res;
650
- }
651
- shock() {
771
+ Object.defineProperty(VRWebViewRTC.prototype, "jsBridge", {
772
+ get: function () {
773
+ return this.options.jsBridge;
774
+ },
775
+ enumerable: false,
776
+ configurable: true
777
+ });
778
+ VRWebViewRTC.prototype.join = function (options) {
779
+ return __awaiter(this, void 0, void 0, function () {
780
+ var _a, sdkAppId, userId, userSig, _b, res, error;
781
+ return __generator(this, function (_c) {
782
+ switch (_c.label) {
783
+ case 0:
784
+ this.emit('joinWillStart');
785
+ return [4 /*yield*/, this.options.getVoiceSign(options)];
786
+ case 1:
787
+ _a = _c.sent(), sdkAppId = _a.sdkAppId, userId = _a.userId, userSig = _a.userSig;
788
+ this.type = options.type;
789
+ return [4 /*yield*/, this.jsBridge.callAndBackfeed("live/join?sdkAppID=".concat(sdkAppId, "&userID=").concat(userId, "&roomID=").concat(Number(options.voiceId), "&userSig=").concat(userSig))];
790
+ case 2:
791
+ _b = _c.sent(), res = _b[0], error = _b[1];
792
+ if (!res) {
793
+ this.emit('error', error ? error : new Error('加入房间失败:未知异常。'));
794
+ this.joined = false;
795
+ }
796
+ else {
797
+ if (res.code === exports.RTCJoinedInfoCodeEnum.Success) {
798
+ this.emit('joined');
799
+ this.joined = true;
800
+ }
801
+ else {
802
+ this.emit('error', res);
803
+ this.joined = false;
804
+ }
805
+ }
806
+ return [2 /*return*/, this.joined];
807
+ }
808
+ });
809
+ });
810
+ };
811
+ VRWebViewRTC.prototype.quit = function () {
812
+ return __awaiter(this, void 0, void 0, function () {
813
+ var _a, res, error;
814
+ return __generator(this, function (_b) {
815
+ switch (_b.label) {
816
+ case 0: return [4 /*yield*/, this.jsBridge.callAndBackfeed('live/quit')];
817
+ case 1:
818
+ _a = _b.sent(), res = _a[0], error = _a[1];
819
+ if (res === null) {
820
+ this.emit('error', error ? error : new Error('退出房间失败:未知异常。'));
821
+ }
822
+ this.joined = false;
823
+ return [2 /*return*/, !!res];
824
+ }
825
+ });
826
+ });
827
+ };
828
+ VRWebViewRTC.prototype.detectMicro = function () {
829
+ return __awaiter(this, void 0, void 0, function () {
830
+ var _a, res, error;
831
+ return __generator(this, function (_b) {
832
+ switch (_b.label) {
833
+ case 0: return [4 /*yield*/, this.jsBridge.detectMicro()];
834
+ case 1:
835
+ _a = _b.sent(), res = _a[0], error = _a[1];
836
+ if (res === null) {
837
+ this.emit('error', error ? error : new Error('麦克风监测异常!'));
838
+ return [2 /*return*/, false];
839
+ }
840
+ return [2 /*return*/, res];
841
+ }
842
+ });
843
+ });
844
+ };
845
+ VRWebViewRTC.prototype.toggleMicro = function (flag) {
846
+ return __awaiter(this, void 0, void 0, function () {
847
+ var _a, res, error;
848
+ return __generator(this, function (_b) {
849
+ switch (_b.label) {
850
+ case 0: return [4 /*yield*/, this.jsBridge.callAndBackfeed("live/toggleMicro?flag=".concat(!!flag ? 1 : 0))];
851
+ case 1:
852
+ _a = _b.sent(), res = _a[0], error = _a[1];
853
+ if (res === null) {
854
+ this.emit('error', error ? error : new Error('麦克风监测异常!'));
855
+ return [2 /*return*/, false];
856
+ }
857
+ this.micro = res;
858
+ return [2 /*return*/, res];
859
+ }
860
+ });
861
+ });
862
+ };
863
+ VRWebViewRTC.prototype.shock = function () {
652
864
  this.jsBridge.shock(1);
653
- }
654
- }
865
+ };
866
+ return VRWebViewRTC;
867
+ }(CoreRTC));
655
868
 
656
869
  /**
657
870
  * WebSocket 通信指令
@@ -736,8 +949,8 @@ exports.MicroStatus = void 0;
736
949
  */
737
950
  function parseLiveMsg(jsonTxt) {
738
951
  try {
739
- const msg = JSON.parse(jsonTxt);
740
- const resMsg = {
952
+ var msg = JSON.parse(jsonTxt);
953
+ var resMsg_1 = {
741
954
  code: msg.code,
742
955
  message: msg.message,
743
956
  command: msg.command,
@@ -748,11 +961,11 @@ function parseLiveMsg(jsonTxt) {
748
961
  triggerUserID: msg.trigger_user_id,
749
962
  data: msg.data || {},
750
963
  };
751
- const undefinedKeys = Object.keys(resMsg).filter((key) => resMsg[key] === undefined);
964
+ var undefinedKeys = Object.keys(resMsg_1).filter(function (key) { return resMsg_1[key] === undefined; });
752
965
  if (undefinedKeys.length > 0) {
753
- console.warn(`推送数据格式异常:${undefinedKeys.join(" ")} 值不存在!`);
966
+ console.warn("\u63A8\u9001\u6570\u636E\u683C\u5F0F\u5F02\u5E38\uFF1A".concat(undefinedKeys.join(" "), " \u503C\u4E0D\u5B58\u5728\uFF01"));
754
967
  }
755
- return resMsg;
968
+ return resMsg_1;
756
969
  }
757
970
  catch (error) {
758
971
  // notcare? 过滤掉所有不符合规范的数据
@@ -890,16 +1103,19 @@ function parseWSClsErr(code) {
890
1103
  }
891
1104
 
892
1105
  function appendUri(uri, query) {
893
- const hasQuery = uri.indexOf('?') !== -1;
894
- const newQuery = Object.keys(query).reduce((accu, curr, idx) => `${accu}${(idx === 0 && !hasQuery) ? '?' : '&'}${curr}=${query[curr]}`, '');
1106
+ if (query === void 0) { query = {}; }
1107
+ var hasQuery = uri.indexOf('?') !== -1;
1108
+ var newQuery = Object.keys(query).reduce(function (accu, curr, idx) {
1109
+ return "".concat(accu).concat((idx === 0 && !hasQuery) ? '?' : '&').concat(curr, "=").concat(query[curr]);
1110
+ }, '');
895
1111
  return uri + newQuery;
896
1112
  }
897
1113
 
898
- const userAgent = globalThis.navigator.userAgent;
899
- const isAndroid = /android/gi.test(userAgent);
900
- const isIOS = /iPhone|iPad\s+OS/gi.test(userAgent);
901
- const isWxMiniProgram = /MicroMessenger/gi.test(userAgent) && /miniProgram/gi.test(userAgent);
902
- const isRealseeVRWebview = /realsee/gi.test(userAgent);
1114
+ var userAgent = globalThis.navigator.userAgent;
1115
+ var isAndroid = /android/gi.test(userAgent);
1116
+ var isIOS = /iPhone|iPad\s+OS/gi.test(userAgent);
1117
+ var isWxMiniProgram = /MicroMessenger/gi.test(userAgent) && /miniProgram/gi.test(userAgent);
1118
+ var isRealseeVRWebview = /realsee/gi.test(userAgent);
903
1119
 
904
1120
  /**
905
1121
  * 判断是否是真实的对象类型
@@ -931,12 +1147,12 @@ function baseIsEqual(value, other) {
931
1147
  * @returns
932
1148
  */
933
1149
  function objEqualShallow(value, other) {
934
- const valueProps = Object.getOwnPropertyNames(value);
935
- const otherProps = Object.getOwnPropertyNames(other);
1150
+ var valueProps = Object.getOwnPropertyNames(value);
1151
+ var otherProps = Object.getOwnPropertyNames(other);
936
1152
  if (valueProps.length !== otherProps.length)
937
1153
  return false;
938
- for (let i = 0, len = valueProps.length; i < len; i++) {
939
- const propName = valueProps[i];
1154
+ for (var i = 0, len = valueProps.length; i < len; i++) {
1155
+ var propName = valueProps[i];
940
1156
  if (!baseIsEqual(value[propName], other[propName]))
941
1157
  return false;
942
1158
  }
@@ -951,7 +1167,7 @@ function objEqualShallow(value, other) {
951
1167
  function arrayEqualShallow(value, other) {
952
1168
  if (value.length !== other.length)
953
1169
  return false;
954
- for (let i = 0, len = value.length; i < len; i++) {
1170
+ for (var i = 0, len = value.length; i < len; i++) {
955
1171
  if (!baseIsEqual(value[i], other[i]))
956
1172
  return false;
957
1173
  }
@@ -996,7 +1212,7 @@ function isDeepEqual(value, other) {
996
1212
  function arrayEqualDeep(value, other) {
997
1213
  if (value.length !== other.length)
998
1214
  return false;
999
- for (let i = 0, len = value.length; i < len; i++) {
1215
+ for (var i = 0, len = value.length; i < len; i++) {
1000
1216
  if (!isDeepEqual(value[i], other[i]))
1001
1217
  return false;
1002
1218
  }
@@ -1009,12 +1225,12 @@ function arrayEqualDeep(value, other) {
1009
1225
  * @returns
1010
1226
  */
1011
1227
  function objEqualDeep(value, other) {
1012
- const valueProps = Object.getOwnPropertyNames(value);
1013
- const otherProps = Object.getOwnPropertyNames(other);
1228
+ var valueProps = Object.getOwnPropertyNames(value);
1229
+ var otherProps = Object.getOwnPropertyNames(other);
1014
1230
  if (valueProps.length !== otherProps.length)
1015
1231
  return false;
1016
- for (let i = 0, len = valueProps.length; i < len; i++) {
1017
- const propName = valueProps[i];
1232
+ for (var i = 0, len = valueProps.length; i < len; i++) {
1233
+ var propName = valueProps[i];
1018
1234
  if (!isDeepEqual(value[propName], other[propName]))
1019
1235
  return false;
1020
1236
  }
@@ -1028,13 +1244,15 @@ function objEqualDeep(value, other) {
1028
1244
  * @returns {boolean} 是否相等。
1029
1245
  */
1030
1246
  function equal(value, other, opt) {
1247
+ if (opt === void 0) { opt = { deep: false }; }
1031
1248
  if (!opt.deep)
1032
1249
  return isShallowEqual(value, other);
1033
1250
  return isDeepEqual(value, other);
1034
1251
  }
1035
1252
 
1036
- class LiveController {
1037
- constructor(options) {
1253
+ var LiveController = /** @class */ (function () {
1254
+ function LiveController(options) {
1255
+ var _this = this;
1038
1256
  this.readyState = exports.WebSocketState.NOTINITIALIZED;
1039
1257
  this.canSync = true;
1040
1258
  this.connecting = false;
@@ -1042,56 +1260,56 @@ class LiveController {
1042
1260
  /**
1043
1261
  * 检测 WebSocket.readyState 状态
1044
1262
  */
1045
- this.checkReadyState = (live) => {
1263
+ this.checkReadyState = function (live) {
1046
1264
  do {
1047
- if (!this.webSocket) {
1048
- if (this.readyState !== exports.WebSocketState.NOTINITIALIZED) {
1049
- this.readyState = exports.WebSocketState.NOTINITIALIZED;
1050
- live.emit('ws.readyStateUpdate', this.readyState);
1265
+ if (!_this.webSocket) {
1266
+ if (_this.readyState !== exports.WebSocketState.NOTINITIALIZED) {
1267
+ _this.readyState = exports.WebSocketState.NOTINITIALIZED;
1268
+ live.emit('ws.readyStateUpdate', _this.readyState);
1051
1269
  }
1052
1270
  break;
1053
1271
  }
1054
- const readyState = this.webSocket.readyState;
1055
- if (readyState !== this.readyState) {
1056
- this.readyState = readyState;
1057
- live.emit('ws.readyStateUpdate', this.readyState);
1272
+ var readyState = _this.webSocket.readyState;
1273
+ if (readyState !== _this.readyState) {
1274
+ _this.readyState = readyState;
1275
+ live.emit('ws.readyStateUpdate', _this.readyState);
1058
1276
  }
1059
1277
  } while (false);
1060
- return this.readyState;
1278
+ return _this.readyState;
1061
1279
  };
1062
- this.dispose = () => {
1063
- this.disposeWebSocket();
1064
- this.connecting = false;
1065
- if (this.healthCheckId) {
1066
- clearInterval(this.healthCheckId);
1067
- this.healthCheckId = undefined;
1280
+ this.dispose = function () {
1281
+ _this.disposeWebSocket();
1282
+ _this.connecting = false;
1283
+ if (_this.healthCheckId) {
1284
+ clearInterval(_this.healthCheckId);
1285
+ _this.healthCheckId = undefined;
1068
1286
  }
1069
1287
  return true;
1070
1288
  };
1071
1289
  /**
1072
1290
  * 销毁WebSocket相关依赖。
1073
1291
  */
1074
- this.disposeWebSocket = () => {
1075
- if (!this.webSocket)
1292
+ this.disposeWebSocket = function () {
1293
+ if (!_this.webSocket)
1076
1294
  return;
1077
- if (this.onEvtOpnListener) {
1078
- this.webSocket.removeEventListener('open', this.onEvtOpnListener);
1079
- this.onEvtOpnListener = undefined;
1295
+ if (_this.onEvtOpnListener) {
1296
+ _this.webSocket.removeEventListener('open', _this.onEvtOpnListener);
1297
+ _this.onEvtOpnListener = undefined;
1080
1298
  }
1081
- if (this.onEvtMsgListener) {
1082
- this.webSocket.removeEventListener('message', this.onEvtMsgListener);
1083
- this.onEvtMsgListener = undefined;
1299
+ if (_this.onEvtMsgListener) {
1300
+ _this.webSocket.removeEventListener('message', _this.onEvtMsgListener);
1301
+ _this.onEvtMsgListener = undefined;
1084
1302
  }
1085
- if (this.onEvtErrListener) {
1086
- this.webSocket.removeEventListener('error', this.onEvtErrListener);
1087
- this.onEvtErrListener = undefined;
1303
+ if (_this.onEvtErrListener) {
1304
+ _this.webSocket.removeEventListener('error', _this.onEvtErrListener);
1305
+ _this.onEvtErrListener = undefined;
1088
1306
  }
1089
- if (this.onEvtCLEListener) {
1090
- this.webSocket.removeEventListener('close', this.onEvtCLEListener);
1091
- this.onEvtCLEListener = undefined;
1307
+ if (_this.onEvtCLEListener) {
1308
+ _this.webSocket.removeEventListener('close', _this.onEvtCLEListener);
1309
+ _this.onEvtCLEListener = undefined;
1092
1310
  }
1093
- this.webSocket.close();
1094
- this.webSocket = undefined;
1311
+ _this.webSocket.close();
1312
+ _this.webSocket = undefined;
1095
1313
  return true;
1096
1314
  };
1097
1315
  this.options = Object.assign({ autoConnect: true, healthCheck: 3000 }, options);
@@ -1101,16 +1319,17 @@ class LiveController {
1101
1319
  * @param liveMsg
1102
1320
  * @param live
1103
1321
  */
1104
- handleMessage(liveMsg, live) {
1322
+ LiveController.prototype.handleMessage = function (liveMsg, live) {
1323
+ var _this = this;
1105
1324
  var _a, _b, _c;
1106
- const { command, data, frontRequestId, code, message } = liveMsg;
1325
+ var command = liveMsg.command, data = liveMsg.data, frontRequestId = liveMsg.frontRequestId, code = liveMsg.code;
1107
1326
  if (code === 'SUCCESS') {
1108
1327
  switch (command) {
1109
1328
  /**
1110
1329
  * 自己的状态变化
1111
1330
  */
1112
1331
  case exports.Command.SelfUserInfo: {
1113
- const selfInfo = data;
1332
+ var selfInfo = data;
1114
1333
  if (equal(this.selfUserInfo, selfInfo, { deep: true }))
1115
1334
  return;
1116
1335
  this.selfUserInfo = selfInfo;
@@ -1121,7 +1340,7 @@ class LiveController {
1121
1340
  * 房间信息变化
1122
1341
  */
1123
1342
  case exports.Command.RoomInfo: {
1124
- const roomInfo = data;
1343
+ var roomInfo = data;
1125
1344
  this.roomInfo = Object.assign({}, roomInfo);
1126
1345
  live.emit('readyKeyframeSync', (roomInfo.last_frame || {}));
1127
1346
  break;
@@ -1130,16 +1349,16 @@ class LiveController {
1130
1349
  * 语音信息变化
1131
1350
  */
1132
1351
  case exports.Command.RTCInfo: {
1133
- const { voice_id: voiceId, type } = data;
1352
+ var _d = data, voiceId = _d.voice_id, type = _d.type;
1134
1353
  /* 如果已经进入语音房间,则不重复进入 --> "RTCInfo" 指令可能会下发多次 */
1135
1354
  if (live.$RTC.joined) {
1136
1355
  break;
1137
1356
  }
1138
1357
  live.$RTC.join({
1139
- voiceId,
1358
+ voiceId: voiceId,
1140
1359
  userId: ((_a = this.selfUserInfo) === null || _a === void 0 ? void 0 : _a.id) || '',
1141
1360
  roomId: (_b = this.roomInfo) === null || _b === void 0 ? void 0 : _b.info.room_code,
1142
- type,
1361
+ type: type,
1143
1362
  });
1144
1363
  // 加入房间后 麦克风默认就开启了:需要发个指令。
1145
1364
  live.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
@@ -1151,7 +1370,7 @@ class LiveController {
1151
1370
  * 房间用户列表变化
1152
1371
  */
1153
1372
  case exports.Command.UserList: {
1154
- const userList = data;
1373
+ var userList = data;
1155
1374
  this.userList = userList;
1156
1375
  live.emit('userListUpdate', this.userList, frontRequestId);
1157
1376
  break;
@@ -1160,7 +1379,7 @@ class LiveController {
1160
1379
  * 自定义事件广播
1161
1380
  */
1162
1381
  case exports.Command.CustomEvent: {
1163
- const evtMsg = data;
1382
+ var evtMsg = data;
1164
1383
  live.emit('broadcast', evtMsg, frontRequestId);
1165
1384
  break;
1166
1385
  }
@@ -1168,21 +1387,22 @@ class LiveController {
1168
1387
  * 帧数据同步
1169
1388
  */
1170
1389
  case exports.Command.KeyframeSync: {
1171
- const remoteKeyframes = data;
1390
+ var remoteKeyframes_1 = data;
1172
1391
  // 此处做一层 diff,仅跟本地数据不一致的情况下才广播数据。
1173
- const keyframes = Object.keys(remoteKeyframes).reduce((accu, curr) => {
1174
- if (equal(remoteKeyframes[curr], this.keyframes[curr], { deep: true })) {
1392
+ var keyframes = Object.keys(remoteKeyframes_1).reduce(function (accu, curr) {
1393
+ var _a;
1394
+ if (equal(remoteKeyframes_1[curr], _this.keyframes[curr], { deep: true })) {
1175
1395
  return accu;
1176
1396
  }
1177
- const params = [
1178
- remoteKeyframes[curr],
1179
- this.keyframes[curr],
1397
+ var params = [
1398
+ remoteKeyframes_1[curr],
1399
+ _this.keyframes[curr],
1180
1400
  frontRequestId,
1181
1401
  ];
1182
- const evtName = curr;
1183
- live.keyframes.emit(evtName, ...params);
1184
- this.keyframes[curr] = remoteKeyframes[curr];
1185
- accu[curr] = remoteKeyframes[curr];
1402
+ var evtName = curr;
1403
+ (_a = live.keyframes).emit.apply(_a, __spreadArray([evtName], params, false));
1404
+ _this.keyframes[curr] = remoteKeyframes_1[curr];
1405
+ accu[curr] = remoteKeyframes_1[curr];
1186
1406
  return accu;
1187
1407
  }, {});
1188
1408
  live.emit('keyframes', keyframes, frontRequestId);
@@ -1192,7 +1412,7 @@ class LiveController {
1192
1412
  * 内置消息
1193
1413
  */
1194
1414
  case exports.Command.BuiltinMsg: {
1195
- const builtinMsg = data;
1415
+ var builtinMsg = data;
1196
1416
  live.emit('builtinEvent', builtinMsg);
1197
1417
  if (builtinMsg.event_type === exports.BuiltinEventType.UserChange) {
1198
1418
  live.emit('userChange', builtinMsg);
@@ -1235,27 +1455,31 @@ class LiveController {
1235
1455
  else {
1236
1456
  live.emit('error', liveMsg);
1237
1457
  }
1238
- }
1458
+ };
1239
1459
  /**
1240
1460
  * 发送数据
1241
1461
  * @param data
1242
1462
  */
1243
- sendMessage(data) {
1463
+ LiveController.prototype.sendMessage = function (data) {
1244
1464
  if (!this.webSocket)
1245
1465
  return console.warn('WebSocket has not yet been initialized!');
1246
1466
  if (!data)
1247
1467
  return console.warn('WebSocket messages is empty!');
1248
1468
  this.webSocket.send(JSON.stringify(data));
1249
- }
1250
- }
1469
+ };
1470
+ return LiveController;
1471
+ }());
1251
1472
 
1252
- const unimplementedGetVoiceSign = (params) => Promise.reject('unimplemented method GetVoiceSign');
1473
+ var unimplementedGetVoiceSign = function (params) {
1474
+ return Promise.reject('unimplemented method GetVoiceSign');
1475
+ };
1253
1476
  /**
1254
1477
  * 创建 `live` 实例。
1255
1478
  */
1256
1479
  function createLive(options) {
1257
- const liveController = new LiveController(options);
1258
- const createLiveMsg = (command, data = {}, toUserIds) => {
1480
+ var liveController = new LiveController(options);
1481
+ var createLiveMsg = function (command, data, toUserIds) {
1482
+ if (data === void 0) { data = {}; }
1259
1483
  toUserIds = toUserIds
1260
1484
  ? Array.isArray(toUserIds)
1261
1485
  ? toUserIds
@@ -1263,14 +1487,16 @@ function createLive(options) {
1263
1487
  : [];
1264
1488
  if (toUserIds)
1265
1489
  data['to_user_ids'] = toUserIds;
1266
- return { command, front_request_id: uuid(), data };
1490
+ return { command: command, front_request_id: uuid(), data: data };
1267
1491
  };
1268
- class LiveTpl extends Subscribe {
1269
- constructor() {
1492
+ var LiveTpl = /** @class */ (function (_super) {
1493
+ __extends(LiveTpl, _super);
1494
+ function LiveTpl() {
1495
+ var _this = this;
1270
1496
  var _a, _b;
1271
- super();
1272
- this.keyframes = new Subscribe();
1273
- const jsBridge = (() => {
1497
+ _this = _super.call(this) || this;
1498
+ _this.keyframes = new Subscribe();
1499
+ var jsBridge = (function () {
1274
1500
  if (options.jsBridge)
1275
1501
  return options.jsBridge;
1276
1502
  if (options.useBuiltInJsBridge)
@@ -1285,7 +1511,7 @@ function createLive(options) {
1285
1511
  if (!options.getVoiceSign) {
1286
1512
  throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
1287
1513
  }
1288
- const getVoiceSign = (_a = options.getVoiceSign) !== null && _a !== void 0 ? _a : unimplementedGetVoiceSign;
1514
+ var getVoiceSign = (_a = options.getVoiceSign) !== null && _a !== void 0 ? _a : unimplementedGetVoiceSign;
1289
1515
  switch (options.rtcType) {
1290
1516
  case exports.RTCType.RealseeVRWebViewRTC: {
1291
1517
  // 内置的 VRWebViewRTC
@@ -1293,15 +1519,15 @@ function createLive(options) {
1293
1519
  throw new Error('JsBridge instance must be passed when using built-in VRWebViewRTC instances');
1294
1520
  }
1295
1521
  liveController.options.rtc = new VRWebViewRTC({
1296
- jsBridge,
1297
- getVoiceSign,
1522
+ jsBridge: jsBridge,
1523
+ getVoiceSign: getVoiceSign,
1298
1524
  });
1299
1525
  break;
1300
1526
  }
1301
1527
  case exports.RTCType.RealseeBrowserChimeRTC: {
1302
1528
  // 内置的 RealseeBrowserChimeRTC
1303
1529
  liveController.options.rtc = new BrowserRTC4Chime({
1304
- getVoiceSign,
1530
+ getVoiceSign: getVoiceSign,
1305
1531
  logLevel: options.__debug__ ? amazonChimeSdkJs.LogLevel.DEBUG : amazonChimeSdkJs.LogLevel.ERROR,
1306
1532
  });
1307
1533
  break;
@@ -1309,7 +1535,7 @@ function createLive(options) {
1309
1535
  case exports.RTCType.RealseeBrowserRTC: {
1310
1536
  // 内置的 RealseeBrowserRTC
1311
1537
  liveController.options.rtc = new BrowserRTC({
1312
- getVoiceSign,
1538
+ getVoiceSign: getVoiceSign,
1313
1539
  });
1314
1540
  break;
1315
1541
  }
@@ -1323,23 +1549,23 @@ function createLive(options) {
1323
1549
  if (!options.getVoiceSign) {
1324
1550
  throw new Error('GetVoiceSign method must be passed when using built-in RTC instances');
1325
1551
  }
1326
- const getVoiceSign = (_b = options.getVoiceSign) !== null && _b !== void 0 ? _b : unimplementedGetVoiceSign;
1552
+ var getVoiceSign = (_b = options.getVoiceSign) !== null && _b !== void 0 ? _b : unimplementedGetVoiceSign;
1327
1553
  if (!jsBridge) {
1328
1554
  throw new Error('jsBridge instance must be passed when using built-in RTC instances');
1329
1555
  }
1330
1556
  // vrwebview 默认
1331
1557
  if ((isRealseeVRWebview && (isAndroid || isIOS)) || isWxMiniProgram) {
1332
1558
  liveController.options.rtc = new VRWebViewRTC({
1333
- jsBridge,
1334
- getVoiceSign,
1559
+ jsBridge: jsBridge,
1560
+ getVoiceSign: getVoiceSign,
1335
1561
  });
1336
1562
  }
1337
1563
  else {
1338
1564
  // 其它终端使用
1339
1565
  liveController.options.rtc =
1340
1566
  options.builtInRTCType === exports.BuiltInRTCType.RealseeXChimeRTC
1341
- ? new BrowserRTC4Chime({ getVoiceSign })
1342
- : new BrowserRTC({ getVoiceSign });
1567
+ ? new BrowserRTC4Chime({ getVoiceSign: getVoiceSign })
1568
+ : new BrowserRTC({ getVoiceSign: getVoiceSign });
1343
1569
  }
1344
1570
  }
1345
1571
  }
@@ -1348,283 +1574,407 @@ function createLive(options) {
1348
1574
  }
1349
1575
  // 默认自动连接
1350
1576
  if (liveController.options.url && liveController.options.getTicket) {
1351
- this.connect();
1577
+ _this.connect();
1352
1578
  }
1353
1579
  // 健康检查:WHY --> 在某些WebView特殊场景下 WebSocket.readyState 发生变化时不会出发error\close等事件;
1354
1580
  // 因此,开启一个定时任务监测 WebSocket.readyState 状态的更新
1355
- const healthCheck = ((healthCheck) => {
1581
+ var healthCheck = (function (healthCheck) {
1356
1582
  if (!healthCheck)
1357
1583
  return 0;
1358
1584
  if (healthCheck === true)
1359
1585
  return 3000;
1360
- const duration = Number(healthCheck);
1586
+ var duration = Number(healthCheck);
1361
1587
  if (duration > 0)
1362
1588
  return duration;
1363
1589
  return 3000;
1364
1590
  })(liveController.options.healthCheck);
1365
1591
  if (healthCheck) {
1366
- liveController.healthCheckId = setInterval(() => liveController.checkReadyState(this), healthCheck);
1367
- }
1368
- }
1369
- get options() {
1370
- return Object.freeze(Object.assign({}, liveController.options));
1371
- }
1372
- get readyState() {
1373
- liveController.checkReadyState(this);
1374
- return liveController.readyState;
1375
- }
1376
- get url() {
1377
- var _a;
1378
- return ((_a = liveController.webSocket) === null || _a === void 0 ? void 0 : _a.url) || '';
1379
- }
1380
- get selfInfo() {
1381
- return liveController.selfUserInfo;
1382
- }
1383
- get userList() {
1384
- return liveController.userList || [];
1385
- }
1386
- get snapshot() {
1387
- return liveController.keyframes || {};
1388
- }
1389
- get $RTC() {
1390
- return liveController.options.rtc;
1391
- }
1392
- get jsBridge() {
1393
- return liveController.options.jsBridge;
1394
- }
1395
- async setSelfInfo(userInfo) {
1396
- if (this.readyState !== exports.WebSocketState.OPEN) {
1397
- return new Error('The connection is not open and ready to communicate.');
1398
- }
1399
- try {
1400
- return await this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserInfo, userInfo);
1401
- }
1402
- catch (error) {
1403
- return error;
1592
+ liveController.healthCheckId = setInterval(function () { return liveController.checkReadyState(_this); }, healthCheck);
1404
1593
  }
1594
+ return _this;
1405
1595
  }
1406
- getFramesByKey(key) {
1596
+ Object.defineProperty(LiveTpl.prototype, "options", {
1597
+ get: function () {
1598
+ return Object.freeze(Object.assign({}, liveController.options));
1599
+ },
1600
+ enumerable: false,
1601
+ configurable: true
1602
+ });
1603
+ Object.defineProperty(LiveTpl.prototype, "readyState", {
1604
+ get: function () {
1605
+ liveController.checkReadyState(this);
1606
+ return liveController.readyState;
1607
+ },
1608
+ enumerable: false,
1609
+ configurable: true
1610
+ });
1611
+ Object.defineProperty(LiveTpl.prototype, "url", {
1612
+ get: function () {
1613
+ var _a;
1614
+ return ((_a = liveController.webSocket) === null || _a === void 0 ? void 0 : _a.url) || '';
1615
+ },
1616
+ enumerable: false,
1617
+ configurable: true
1618
+ });
1619
+ Object.defineProperty(LiveTpl.prototype, "selfInfo", {
1620
+ get: function () {
1621
+ return liveController.selfUserInfo;
1622
+ },
1623
+ enumerable: false,
1624
+ configurable: true
1625
+ });
1626
+ Object.defineProperty(LiveTpl.prototype, "userList", {
1627
+ get: function () {
1628
+ return liveController.userList || [];
1629
+ },
1630
+ enumerable: false,
1631
+ configurable: true
1632
+ });
1633
+ Object.defineProperty(LiveTpl.prototype, "snapshot", {
1634
+ get: function () {
1635
+ return liveController.keyframes || {};
1636
+ },
1637
+ enumerable: false,
1638
+ configurable: true
1639
+ });
1640
+ Object.defineProperty(LiveTpl.prototype, "$RTC", {
1641
+ get: function () {
1642
+ return liveController.options.rtc;
1643
+ },
1644
+ enumerable: false,
1645
+ configurable: true
1646
+ });
1647
+ Object.defineProperty(LiveTpl.prototype, "jsBridge", {
1648
+ get: function () {
1649
+ return liveController.options.jsBridge;
1650
+ },
1651
+ enumerable: false,
1652
+ configurable: true
1653
+ });
1654
+ LiveTpl.prototype.setSelfInfo = function (userInfo) {
1655
+ return __awaiter(this, void 0, void 0, function () {
1656
+ var error_1;
1657
+ return __generator(this, function (_a) {
1658
+ switch (_a.label) {
1659
+ case 0:
1660
+ if (this.readyState !== exports.WebSocketState.OPEN) {
1661
+ return [2 /*return*/, new Error('The connection is not open and ready to communicate.')];
1662
+ }
1663
+ _a.label = 1;
1664
+ case 1:
1665
+ _a.trys.push([1, 3, , 4]);
1666
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserInfo, userInfo)];
1667
+ case 2: return [2 /*return*/, _a.sent()];
1668
+ case 3:
1669
+ error_1 = _a.sent();
1670
+ return [2 /*return*/, error_1];
1671
+ case 4: return [2 /*return*/];
1672
+ }
1673
+ });
1674
+ });
1675
+ };
1676
+ LiveTpl.prototype.getFramesByKey = function (key) {
1407
1677
  return liveController.keyframes[key];
1408
- }
1409
- sendKeyframe(key, frame) {
1678
+ };
1679
+ LiveTpl.prototype.sendKeyframe = function (key, frame) {
1410
1680
  if (this.readyState !== exports.WebSocketState.OPEN) {
1411
1681
  return new Error('The connection is not open and ready to communicate.');
1412
1682
  }
1413
1683
  liveController.keyframes[key] = frame;
1414
- const liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
1684
+ var liveMsg = createLiveMsg(exports.Command.KeyframeSync, this.snapshot);
1415
1685
  liveController.sendMessage(liveMsg);
1416
1686
  return true;
1417
- }
1418
- broadcast(data, toUserIds, timeout) {
1687
+ };
1688
+ LiveTpl.prototype.broadcast = function (data, toUserIds, timeout) {
1689
+ var _this = this;
1419
1690
  if (this.readyState !== exports.WebSocketState.OPEN) {
1420
1691
  return new Error('The connection is not open and ready to communicate.');
1421
1692
  }
1422
- return new Promise((resolve, reject) => {
1423
- const customEvent = createLiveMsg(exports.Command.CustomEvent, data, toUserIds);
1424
- const front_request_id = customEvent.front_request_id;
1693
+ return new Promise(function (resolve, reject) {
1694
+ var customEvent = createLiveMsg(exports.Command.CustomEvent, data, toUserIds);
1695
+ var front_request_id = customEvent.front_request_id;
1425
1696
  liveController.sendMessage(customEvent);
1426
- const timeoutId = timeout
1427
- ? setTimeout(() => {
1697
+ var timeoutId = timeout
1698
+ ? setTimeout(function () {
1428
1699
  reject(new Error('RESPONSE TIMEOUT'));
1429
- this.off('broadcast', broadcast);
1700
+ _this.off('broadcast', broadcast);
1430
1701
  }, timeout)
1431
1702
  : undefined;
1432
- const broadcast = (data, frontRequestId) => {
1703
+ var broadcast = function (data, frontRequestId) {
1433
1704
  if (frontRequestId !== front_request_id)
1434
1705
  return;
1435
- this.off('broadcast', broadcast);
1706
+ _this.off('broadcast', broadcast);
1436
1707
  resolve(data);
1437
1708
  if (timeoutId)
1438
1709
  clearInterval(timeoutId);
1439
1710
  };
1440
- this.on('broadcast', broadcast);
1711
+ _this.on('broadcast', broadcast);
1441
1712
  });
1442
- }
1443
- async updateStatus(evtType, atnType, status, toUserIds) {
1444
- // TODO 统一规则,不能联合类型
1445
- if (this.readyState !== exports.WebSocketState.OPEN) {
1446
- return false;
1447
- }
1448
- const data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
1449
- const liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
1450
- liveController.sendMessage(liveMsg);
1451
- return true;
1452
- }
1713
+ };
1714
+ LiveTpl.prototype.updateStatus = function (evtType, atnType, status, toUserIds) {
1715
+ return __awaiter(this, void 0, void 0, function () {
1716
+ var data, liveMsg;
1717
+ return __generator(this, function (_a) {
1718
+ // TODO 统一规则,不能联合类型
1719
+ if (this.readyState !== exports.WebSocketState.OPEN) {
1720
+ return [2 /*return*/, false];
1721
+ }
1722
+ data = Object.assign({ event_type: evtType, action: atnType }, { data: status });
1723
+ liveMsg = createLiveMsg(exports.Command.BuiltinMsg, data, toUserIds);
1724
+ liveController.sendMessage(liveMsg);
1725
+ return [2 /*return*/, true];
1726
+ });
1727
+ });
1728
+ };
1453
1729
  // 仅用于用户自己的麦克风控制
1454
- async toggleMicro(microStatus) {
1730
+ LiveTpl.prototype.toggleMicro = function (microStatus) {
1455
1731
  var _a, _b;
1456
- if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_own_micro))
1457
- return false;
1458
- await this.$RTC.toggleMicro(microStatus);
1459
- return await this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
1460
- status: microStatus ? exports.MicroStatus.OPEN : exports.MicroStatus.CLOSE,
1461
- }, []);
1462
- }
1463
- async forbidMicro(microStatus, toUserIds) {
1732
+ return __awaiter(this, void 0, void 0, function () {
1733
+ return __generator(this, function (_c) {
1734
+ switch (_c.label) {
1735
+ case 0:
1736
+ if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_own_micro))
1737
+ return [2 /*return*/, false];
1738
+ return [4 /*yield*/, this.$RTC.toggleMicro(microStatus)];
1739
+ case 1:
1740
+ _c.sent();
1741
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
1742
+ status: microStatus ? exports.MicroStatus.OPEN : exports.MicroStatus.CLOSE,
1743
+ }, [])];
1744
+ case 2: return [2 /*return*/, _c.sent()];
1745
+ }
1746
+ });
1747
+ });
1748
+ };
1749
+ LiveTpl.prototype.forbidMicro = function (microStatus, toUserIds) {
1464
1750
  var _a, _b;
1465
- if (liveController.options.canForbidUserMicro &&
1466
- !liveController.options.canForbidUserMicro(toUserIds)) {
1467
- return false;
1468
- }
1469
- if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_other_micro)) {
1470
- return false;
1471
- }
1472
- return await this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
1473
- status: microStatus,
1474
- }, toUserIds);
1475
- }
1751
+ return __awaiter(this, void 0, void 0, function () {
1752
+ return __generator(this, function (_c) {
1753
+ switch (_c.label) {
1754
+ case 0:
1755
+ if (liveController.options.canForbidUserMicro &&
1756
+ !liveController.options.canForbidUserMicro(toUserIds)) {
1757
+ return [2 /*return*/, false];
1758
+ }
1759
+ if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_other_micro)) {
1760
+ return [2 /*return*/, false];
1761
+ }
1762
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserMicroStatus, {
1763
+ status: microStatus,
1764
+ }, toUserIds)];
1765
+ case 1: return [2 /*return*/, _c.sent()];
1766
+ }
1767
+ });
1768
+ });
1769
+ };
1476
1770
  /**
1477
1771
  * @deprecated 暂不可用
1478
1772
  */
1479
- async forbidSync(sync, toUserIds) {
1773
+ LiveTpl.prototype.forbidSync = function (sync, toUserIds) {
1480
1774
  var _a, _b;
1481
- if (liveController.options.canForbidUserSync &&
1482
- !liveController.options.canForbidUserSync(toUserIds)) {
1483
- return false;
1484
- }
1485
- if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_other_sync)) {
1486
- return false;
1487
- }
1488
- return await this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserPermission, { sync_frame: sync }, toUserIds);
1489
- }
1490
- async kick(toUserIds) {
1775
+ return __awaiter(this, void 0, void 0, function () {
1776
+ return __generator(this, function (_c) {
1777
+ switch (_c.label) {
1778
+ case 0:
1779
+ if (liveController.options.canForbidUserSync &&
1780
+ !liveController.options.canForbidUserSync(toUserIds)) {
1781
+ return [2 /*return*/, false];
1782
+ }
1783
+ if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.control_other_sync)) {
1784
+ return [2 /*return*/, false];
1785
+ }
1786
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserPermission, { sync_frame: sync }, toUserIds)];
1787
+ case 1: return [2 /*return*/, _c.sent()];
1788
+ }
1789
+ });
1790
+ });
1791
+ };
1792
+ LiveTpl.prototype.kick = function (toUserIds) {
1491
1793
  var _a, _b;
1492
- if (liveController.options.canForbidUserKick &&
1493
- !liveController.options.canForbidUserKick(toUserIds)) {
1494
- return false;
1495
- }
1496
- if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.change_other_status)) {
1497
- return false;
1498
- }
1499
- return await this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserStatus, {
1500
- status: 'KICK_OUT',
1501
- }, toUserIds);
1502
- }
1503
- async exit() {
1504
- /** 退出强制关闭语音(?) */
1505
- await this.$RTC.quit();
1506
- await this.updateStatus(exports.BuiltinEventType.RoomChange, exports.BuiltinActionType.RoomClose, {});
1507
- return liveController.dispose();
1508
- }
1509
- async connect(options = {}) {
1510
- // 连接 WebSocket 前验证麦克风权限
1511
- const microAuth = await this.$RTC.detectMicro();
1512
- if (!microAuth) {
1513
- const error = new Error('系统监测麦克风未授权~');
1514
- this.emit('ws.error', { type: exports.WebSocketErrorType.MicroAuth, error });
1515
- return error;
1516
- }
1517
- // WebSocket 正在连接中,规避重复连接
1518
- if (liveController.connecting) {
1519
- const error = new Error('WebSocket 正在连接中,请勿重复连接 ...');
1520
- this.emit('ws.error', {
1521
- type: exports.WebSocketErrorType.DuplicateConnect,
1522
- error,
1794
+ return __awaiter(this, void 0, void 0, function () {
1795
+ return __generator(this, function (_c) {
1796
+ switch (_c.label) {
1797
+ case 0:
1798
+ if (liveController.options.canForbidUserKick &&
1799
+ !liveController.options.canForbidUserKick(toUserIds)) {
1800
+ return [2 /*return*/, false];
1801
+ }
1802
+ if (!((_b = (_a = this.selfInfo) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.change_other_status)) {
1803
+ return [2 /*return*/, false];
1804
+ }
1805
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.UserChange, exports.BuiltinActionType.UserStatus, {
1806
+ status: 'KICK_OUT',
1807
+ }, toUserIds)];
1808
+ case 1: return [2 /*return*/, _c.sent()];
1809
+ }
1523
1810
  });
1524
- return error;
1525
- }
1526
- // 非强制连接场景下,如果已经完成 WebSocket 连接则不执行后续逻辑
1527
- const { force } = options;
1528
- if (!force) {
1529
- if (this.readyState === exports.WebSocketState.CONNECTING ||
1530
- this.readyState === exports.WebSocketState.OPEN) {
1531
- return true;
1532
- }
1533
- }
1534
- // WebSocket URL 逻辑
1535
- if (options.url) {
1536
- liveController.options.url = options.url;
1537
- }
1538
- if (options.getTicket) {
1539
- liveController.options.getTicket = options.getTicket;
1540
- }
1541
- if (!liveController.options.url ||
1542
- !liveController.options.url.startsWith('ws')) {
1543
- const error = new Error(`WebSocket URL 未配置或格式不合法:"${liveController.options.url}"`);
1544
- this.emit('ws.error', { type: exports.WebSocketErrorType.IllegalURL, error });
1545
- return error;
1546
- }
1547
- if (!liveController.options.getTicket) {
1548
- const error = new Error(`getTicket() 未配置!`);
1549
- this.emit('ws.error', { type: exports.WebSocketErrorType.IllegalArgs, error });
1550
- return error;
1551
- }
1552
- // 连接锁
1553
- liveController.connecting = true;
1554
- // 连接前销毁之前绑定的事件
1555
- liveController.disposeWebSocket();
1556
- this.emit('ws.beforeConnect');
1557
- const url = force || options.url || !this.url
1558
- ? appendUri(liveController.options.url, {
1559
- ticket: await liveController.options.getTicket(),
1560
- force: Number(!!force),
1561
- })
1562
- : this.url;
1563
- liveController.webSocket = new WebSocket(url);
1564
- liveController.onEvtOpnListener = () => {
1565
- liveController.checkReadyState(this);
1566
- this.emit('ws.afterConnect');
1567
- };
1568
- liveController.onEvtMsgListener = (evt) => {
1569
- liveController.checkReadyState(this);
1570
- try {
1571
- const liveMsg = parseLiveMsg(evt.data);
1572
- if (liveMsg === false)
1573
- return;
1574
- liveController.handleMessage(liveMsg, this);
1575
- }
1576
- catch (error) {
1577
- // 未知错误
1578
- this.emit('ws.error', {
1579
- type: exports.WebSocketErrorType.Unknown,
1580
- error,
1581
- target: evt,
1582
- });
1583
- }
1584
- };
1585
- liveController.onEvtErrListener = (evt) => {
1586
- live.emit('ws.error', { type: exports.WebSocketErrorType.Error, target: evt });
1587
- liveController.checkReadyState(this);
1588
- };
1589
- liveController.onEvtCLEListener = (evt) => {
1590
- liveController.checkReadyState(this);
1591
- const code = Number(evt.code);
1592
- if (code === 1000)
1593
- return;
1594
- // 异常退出不一定会触发'error'事件,根据 evt.code 一些类型的退出也算是 error 行为
1595
- const errMsg = parseWSClsErr(code);
1596
- live.emit('ws.error', {
1597
- target: evt,
1598
- type: exports.WebSocketErrorType.Close,
1599
- closeError: errMsg,
1811
+ });
1812
+ };
1813
+ LiveTpl.prototype.exit = function () {
1814
+ return __awaiter(this, void 0, void 0, function () {
1815
+ var e_1;
1816
+ return __generator(this, function (_a) {
1817
+ switch (_a.label) {
1818
+ case 0:
1819
+ _a.trys.push([0, 2, , 3]);
1820
+ this.$RTC.quit();
1821
+ return [4 /*yield*/, this.updateStatus(exports.BuiltinEventType.RoomChange, exports.BuiltinActionType.RoomClose, {})];
1822
+ case 1:
1823
+ _a.sent();
1824
+ return [3 /*break*/, 3];
1825
+ case 2:
1826
+ e_1 = _a.sent();
1827
+ console.log(e_1);
1828
+ return [3 /*break*/, 3];
1829
+ case 3: return [2 /*return*/, liveController.dispose()];
1830
+ }
1600
1831
  });
1601
- };
1602
- liveController.webSocket.addEventListener('open', liveController.onEvtOpnListener);
1603
- liveController.webSocket.addEventListener('message', liveController.onEvtMsgListener);
1604
- liveController.webSocket.addEventListener('error', liveController.onEvtErrListener);
1605
- liveController.webSocket.addEventListener('close', liveController.onEvtCLEListener);
1606
- return await new Promise((resolve, reject) => {
1607
- const success = () => {
1608
- resolve(true);
1609
- liveController.connecting = false;
1610
- this.off('ws.error', fail);
1611
- };
1612
- const fail = (error) => {
1613
- reject(error.error
1614
- ? error.error
1615
- : new Error('WebSocket connection failed!'));
1616
- liveController.connecting = false;
1617
- this.off('ws.afterConnect', success);
1618
- };
1619
- this.once('ws.afterConnect', success);
1620
- this.once('ws.error', fail);
1621
1832
  });
1622
- }
1623
- async revoke() {
1624
- return true;
1625
- }
1626
- }
1627
- const live = new LiveTpl();
1833
+ };
1834
+ LiveTpl.prototype.connect = function (options) {
1835
+ if (options === void 0) { options = {}; }
1836
+ return __awaiter(this, void 0, void 0, function () {
1837
+ var microAuth, error, error, force, error, error, url, _a, _b, _c;
1838
+ var _d;
1839
+ var _this = this;
1840
+ return __generator(this, function (_e) {
1841
+ switch (_e.label) {
1842
+ case 0: return [4 /*yield*/, this.$RTC.detectMicro()];
1843
+ case 1:
1844
+ microAuth = _e.sent();
1845
+ if (!microAuth) {
1846
+ error = new Error('系统监测麦克风未授权~');
1847
+ this.emit('ws.error', { type: exports.WebSocketErrorType.MicroAuth, error: error });
1848
+ return [2 /*return*/, error];
1849
+ }
1850
+ // WebSocket 正在连接中,规避重复连接
1851
+ if (liveController.connecting) {
1852
+ error = new Error('WebSocket 正在连接中,请勿重复连接 ...');
1853
+ this.emit('ws.error', {
1854
+ type: exports.WebSocketErrorType.DuplicateConnect,
1855
+ error: error,
1856
+ });
1857
+ return [2 /*return*/, error];
1858
+ }
1859
+ force = options.force;
1860
+ if (!force) {
1861
+ if (this.readyState === exports.WebSocketState.CONNECTING ||
1862
+ this.readyState === exports.WebSocketState.OPEN) {
1863
+ return [2 /*return*/, true];
1864
+ }
1865
+ }
1866
+ // WebSocket URL 逻辑
1867
+ if (options.url) {
1868
+ liveController.options.url = options.url;
1869
+ }
1870
+ if (options.getTicket) {
1871
+ liveController.options.getTicket = options.getTicket;
1872
+ }
1873
+ if (!liveController.options.url ||
1874
+ !liveController.options.url.startsWith('ws')) {
1875
+ error = new Error("WebSocket URL \u672A\u914D\u7F6E\u6216\u683C\u5F0F\u4E0D\u5408\u6CD5\uFF1A\"".concat(liveController.options.url, "\""));
1876
+ this.emit('ws.error', { type: exports.WebSocketErrorType.IllegalURL, error: error });
1877
+ return [2 /*return*/, error];
1878
+ }
1879
+ if (!liveController.options.getTicket) {
1880
+ error = new Error("getTicket() \u672A\u914D\u7F6E!");
1881
+ this.emit('ws.error', { type: exports.WebSocketErrorType.IllegalArgs, error: error });
1882
+ return [2 /*return*/, error];
1883
+ }
1884
+ // 连接锁
1885
+ liveController.connecting = true;
1886
+ // 连接前销毁之前绑定的事件
1887
+ liveController.disposeWebSocket();
1888
+ this.emit('ws.beforeConnect');
1889
+ if (!(force || options.url || !this.url)) return [3 /*break*/, 3];
1890
+ _b = appendUri;
1891
+ _c = [liveController.options.url];
1892
+ _d = {};
1893
+ return [4 /*yield*/, liveController.options.getTicket()];
1894
+ case 2:
1895
+ _a = _b.apply(void 0, _c.concat([(_d.ticket = _e.sent(),
1896
+ _d.force = Number(!!force),
1897
+ _d)]));
1898
+ return [3 /*break*/, 4];
1899
+ case 3:
1900
+ _a = this.url;
1901
+ _e.label = 4;
1902
+ case 4:
1903
+ url = _a;
1904
+ liveController.webSocket = new WebSocket(url);
1905
+ liveController.onEvtOpnListener = function () {
1906
+ liveController.checkReadyState(_this);
1907
+ _this.emit('ws.afterConnect');
1908
+ };
1909
+ liveController.onEvtMsgListener = function (evt) {
1910
+ liveController.checkReadyState(_this);
1911
+ try {
1912
+ var liveMsg = parseLiveMsg(evt.data);
1913
+ if (liveMsg === false)
1914
+ return;
1915
+ liveController.handleMessage(liveMsg, _this);
1916
+ }
1917
+ catch (error) {
1918
+ // 未知错误
1919
+ _this.emit('ws.error', {
1920
+ type: exports.WebSocketErrorType.Unknown,
1921
+ error: error,
1922
+ target: evt,
1923
+ });
1924
+ }
1925
+ };
1926
+ liveController.onEvtErrListener = function (evt) {
1927
+ live.emit('ws.error', { type: exports.WebSocketErrorType.Error, target: evt });
1928
+ liveController.checkReadyState(_this);
1929
+ };
1930
+ liveController.onEvtCLEListener = function (evt) {
1931
+ liveController.checkReadyState(_this);
1932
+ var code = Number(evt.code);
1933
+ if (code === 1000)
1934
+ return;
1935
+ // 异常退出不一定会触发'error'事件,根据 evt.code 一些类型的退出也算是 error 行为
1936
+ var errMsg = parseWSClsErr(code);
1937
+ live.emit('ws.error', {
1938
+ target: evt,
1939
+ type: exports.WebSocketErrorType.Close,
1940
+ closeError: errMsg,
1941
+ });
1942
+ };
1943
+ liveController.webSocket.addEventListener('open', liveController.onEvtOpnListener);
1944
+ liveController.webSocket.addEventListener('message', liveController.onEvtMsgListener);
1945
+ liveController.webSocket.addEventListener('error', liveController.onEvtErrListener);
1946
+ liveController.webSocket.addEventListener('close', liveController.onEvtCLEListener);
1947
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
1948
+ var success = function () {
1949
+ resolve(true);
1950
+ liveController.connecting = false;
1951
+ _this.off('ws.error', fail);
1952
+ };
1953
+ var fail = function (error) {
1954
+ reject(error.error
1955
+ ? error.error
1956
+ : new Error('WebSocket connection failed!'));
1957
+ liveController.connecting = false;
1958
+ _this.off('ws.afterConnect', success);
1959
+ };
1960
+ _this.once('ws.afterConnect', success);
1961
+ _this.once('ws.error', fail);
1962
+ })];
1963
+ case 5: return [2 /*return*/, _e.sent()];
1964
+ }
1965
+ });
1966
+ });
1967
+ };
1968
+ LiveTpl.prototype.revoke = function () {
1969
+ return __awaiter(this, void 0, void 0, function () {
1970
+ return __generator(this, function (_a) {
1971
+ return [2 /*return*/, true];
1972
+ });
1973
+ });
1974
+ };
1975
+ return LiveTpl;
1976
+ }(Subscribe));
1977
+ var live = new LiveTpl();
1628
1978
  // 如果是调试环境则将内部状态暴露出来
1629
1979
  if (options.__debug__) {
1630
1980
  Object.assign(live, { __controller__: liveController });
@@ -1637,14 +1987,14 @@ function createLive(options) {
1637
1987
  * 创建 {@link LiveReact} 实例,并提供 `React` 技术栈相关工具链。
1638
1988
  */
1639
1989
  function createLiveReact(options) {
1640
- const LiveContext = React__default["default"].createContext(null);
1641
- const live = createLive(options);
1642
- const jsBridge = live.jsBridge;
1990
+ var LiveContext = React__default["default"].createContext(null);
1991
+ var live = createLive(options);
1992
+ var jsBridge = live.jsBridge;
1643
1993
  function LiveProvider(props) {
1644
1994
  return (React__default["default"].createElement(LiveContext.Provider, { value: props.live || live }, props.children));
1645
1995
  }
1646
1996
  function useLiveInstance() {
1647
- const context = React__default["default"].useContext(LiveContext);
1997
+ var context = React__default["default"].useContext(LiveContext);
1648
1998
  if (!context)
1649
1999
  throw new Error('LiveProvider never found.');
1650
2000
  return context;
@@ -1657,7 +2007,7 @@ function createLiveReact(options) {
1657
2007
  return useLiveInstance();
1658
2008
  }
1659
2009
  function useRTCInstance() {
1660
- const live = useLiveInstance();
2010
+ var live = useLiveInstance();
1661
2011
  return live.$RTC;
1662
2012
  }
1663
2013
  /**
@@ -1668,76 +2018,93 @@ function createLiveReact(options) {
1668
2018
  return useRTCInstance();
1669
2019
  }
1670
2020
  function useConnect() {
1671
- const live = useLiveInstance();
1672
- return async (options) => await live.connect(options);
2021
+ var _this = this;
2022
+ var live = useLiveInstance();
2023
+ return function (options) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
2024
+ switch (_a.label) {
2025
+ case 0: return [4 /*yield*/, live.connect(options)];
2026
+ case 1: return [2 /*return*/, _a.sent()];
2027
+ }
2028
+ }); }); };
1673
2029
  }
1674
2030
  function useCurrentWebSocketUrl() {
1675
- const live = useLiveInstance();
1676
- const [state, setState] = React__default["default"].useState(undefined);
1677
- React__default["default"].useEffect(() => {
1678
- const onWSBeforeConnect = () => setState(live.url);
2031
+ var live = useLiveInstance();
2032
+ var _a = React__default["default"].useState(undefined), state = _a[0], setState = _a[1];
2033
+ React__default["default"].useEffect(function () {
2034
+ var onWSBeforeConnect = function () { return setState(live.url); };
1679
2035
  live.on('ws.beforeConnect', onWSBeforeConnect);
1680
- return () => live.off('ws.beforeConnect', onWSBeforeConnect);
2036
+ return function () { return live.off('ws.beforeConnect', onWSBeforeConnect); };
1681
2037
  }, [live]);
1682
2038
  return state;
1683
2039
  }
1684
- function useKeyframeUpdateCallback(name, callback, deps = []) {
1685
- const live = useLiveInstance();
1686
- const dependencyList = [live, name, ...deps];
1687
- const dispose = () => live.keyframes.off(name, callback);
1688
- React__default["default"].useEffect(() => {
2040
+ function useKeyframeUpdateCallback(name, callback, deps) {
2041
+ if (deps === void 0) { deps = []; }
2042
+ var live = useLiveInstance();
2043
+ var dependencyList = __spreadArray([live, name], deps, true);
2044
+ var dispose = function () { return live.keyframes.off(name, callback); };
2045
+ React__default["default"].useEffect(function () {
1689
2046
  live.keyframes.on(name, callback);
1690
2047
  return dispose;
1691
2048
  }, dependencyList);
1692
2049
  return dispose;
1693
2050
  }
1694
2051
  function useLiveAction() {
1695
- const live = useLiveInstance();
1696
- const toggleMicro = React__default["default"].useCallback((microStatus) => live.toggleMicro(microStatus), [live]);
1697
- const broadcast = React__default["default"].useCallback((data, toUserIds, timeout = 0) => live.broadcast(data, toUserIds, timeout), [live]);
1698
- const exit = React__default["default"].useCallback(() => live.exit(), [live]);
1699
- const kick = React__default["default"].useCallback((toUserIds) => live.kick(toUserIds), [live]);
1700
- const forbidMicro = React__default["default"].useCallback((micro, toUserIds) => live.forbidMicro(micro, toUserIds), [live]);
2052
+ var live = useLiveInstance();
2053
+ var toggleMicro = React__default["default"].useCallback(function (microStatus) { return live.toggleMicro(microStatus); }, [live]);
2054
+ var broadcast = React__default["default"].useCallback(function (data, toUserIds, timeout) {
2055
+ if (timeout === void 0) { timeout = 0; }
2056
+ return live.broadcast(data, toUserIds, timeout);
2057
+ }, [live]);
2058
+ var exit = React__default["default"].useCallback(function () { return live.exit(); }, [live]);
2059
+ var kick = React__default["default"].useCallback(function (toUserIds) { return live.kick(toUserIds); }, [live]);
2060
+ var forbidMicro = React__default["default"].useCallback(function (micro, toUserIds) {
2061
+ return live.forbidMicro(micro, toUserIds);
2062
+ }, [live]);
1701
2063
  // const forbidSync = React.useCallback(
1702
2064
  // (sync: boolean, toUserIds?: string | string[] | undefined) =>
1703
2065
  // live.forbidSync(sync, toUserIds),
1704
2066
  // [live],
1705
2067
  // );
1706
- const getFramesByKey = React__default["default"].useCallback((key) => live.getFramesByKey(key), [live]);
1707
- const sendKeyframe = React__default["default"].useCallback((key, frame) => live.sendKeyframe(key, frame), [live]);
1708
- const setSelfInfo = React__default["default"].useCallback((userInfo) => live.setSelfInfo(userInfo), [live]);
1709
- const updateStatus = React__default["default"].useCallback((evtType, atnType, status, toUserIds) => live.updateStatus(evtType, atnType, status, toUserIds), [live]);
2068
+ var getFramesByKey = React__default["default"].useCallback(function (key) { return live.getFramesByKey(key); }, [live]);
2069
+ var sendKeyframe = React__default["default"].useCallback(function (key, frame) {
2070
+ return live.sendKeyframe(key, frame);
2071
+ }, [live]);
2072
+ var setSelfInfo = React__default["default"].useCallback(function (userInfo) { return live.setSelfInfo(userInfo); }, [live]);
2073
+ var updateStatus = React__default["default"].useCallback(function (evtType, atnType, status, toUserIds) { return live.updateStatus(evtType, atnType, status, toUserIds); }, [live]);
1710
2074
  return {
1711
- broadcast,
1712
- exit,
1713
- kick,
1714
- toggleMicro,
1715
- forbidMicro,
2075
+ broadcast: broadcast,
2076
+ exit: exit,
2077
+ kick: kick,
2078
+ toggleMicro: toggleMicro,
2079
+ forbidMicro: forbidMicro,
1716
2080
  // forbidSync,
1717
- sendKeyframe,
1718
- getFramesByKey,
1719
- setSelfInfo,
1720
- updateStatus,
2081
+ sendKeyframe: sendKeyframe,
2082
+ getFramesByKey: getFramesByKey,
2083
+ setSelfInfo: setSelfInfo,
2084
+ updateStatus: updateStatus,
1721
2085
  };
1722
2086
  }
1723
2087
  function useKeyframe(key) {
1724
- const live = useLiveInstance();
1725
- const [state, updateState] = React__default["default"].useState(live.getFramesByKey(key));
1726
- React__default["default"].useEffect(() => {
1727
- const onUpdate = (nextKeyframes) => updateState(nextKeyframes);
1728
- const evtName = key;
1729
- const callback = onUpdate;
2088
+ var live = useLiveInstance();
2089
+ var _a = React__default["default"].useState(live.getFramesByKey(key)), state = _a[0], updateState = _a[1];
2090
+ React__default["default"].useEffect(function () {
2091
+ var onUpdate = function (nextKeyframes) {
2092
+ return updateState(nextKeyframes);
2093
+ };
2094
+ var evtName = key;
2095
+ var callback = onUpdate;
1730
2096
  live.keyframes.on(evtName, callback);
1731
- return () => live.keyframes.off(evtName, callback);
2097
+ return function () { return live.keyframes.off(evtName, callback); };
1732
2098
  }, [live]);
1733
- const setState = React__default["default"].useCallback((frame) => live.sendKeyframe(key, frame), [live]);
2099
+ var setState = React__default["default"].useCallback(function (frame) { return live.sendKeyframe(key, frame); }, [live]);
1734
2100
  return [state, setState];
1735
2101
  }
1736
- function useLiveEventCallback(name, callback, deps = []) {
1737
- const live = useLiveInstance();
1738
- const dispose = () => live.off(name, callback);
1739
- const dependencyList = [live, name, ...deps];
1740
- React__default["default"].useEffect(() => {
2102
+ function useLiveEventCallback(name, callback, deps) {
2103
+ if (deps === void 0) { deps = []; }
2104
+ var live = useLiveInstance();
2105
+ var dispose = function () { return live.off(name, callback); };
2106
+ var dependencyList = __spreadArray([live, name], deps, true);
2107
+ React__default["default"].useEffect(function () {
1741
2108
  live.on(name, callback);
1742
2109
  return dispose;
1743
2110
  }, dependencyList);
@@ -1748,70 +2115,81 @@ function createLiveReact(options) {
1748
2115
  * @returns
1749
2116
  */
1750
2117
  function useReadyState() {
1751
- const live = useLiveInstance();
1752
- const [state, updateState] = React__default["default"].useState(live.readyState);
1753
- React__default["default"].useEffect(() => {
1754
- const readyStateUpdate = (readyState) => updateState(readyState);
2118
+ var live = useLiveInstance();
2119
+ var _a = React__default["default"].useState(live.readyState), state = _a[0], updateState = _a[1];
2120
+ React__default["default"].useEffect(function () {
2121
+ var readyStateUpdate = function (readyState) {
2122
+ return updateState(readyState);
2123
+ };
1755
2124
  live.on('ws.readyStateUpdate', readyStateUpdate);
1756
- return () => live.off('ws.readyStateUpdate', readyStateUpdate);
2125
+ return function () { return live.off('ws.readyStateUpdate', readyStateUpdate); };
1757
2126
  }, [live]);
1758
2127
  return state;
1759
2128
  }
1760
2129
  function useRTCAction() {
1761
- const live = useLiveInstance();
1762
- const join = React__default["default"].useCallback((options) => live.$RTC.join(options), [live]);
1763
- const quit = React__default["default"].useCallback(() => live.$RTC.quit(), [live]);
1764
- const shock = React__default["default"].useCallback(() => { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); }, [live]);
1765
- const toggleMicro = React__default["default"].useCallback((flag) => live.$RTC.toggleMicro(flag), [live]);
1766
- const detectMicro = React__default["default"].useCallback(() => live.$RTC.detectMicro(), [live]);
2130
+ var live = useLiveInstance();
2131
+ var join = React__default["default"].useCallback(function (options) { return live.$RTC.join(options); }, [live]);
2132
+ var quit = React__default["default"].useCallback(function () { return live.$RTC.quit(); }, [live]);
2133
+ var shock = React__default["default"].useCallback(function () { var _a, _b; return (_b = (_a = live.$RTC).shock) === null || _b === void 0 ? void 0 : _b.call(_a); }, [live]);
2134
+ var toggleMicro = React__default["default"].useCallback(function (flag) { return live.$RTC.toggleMicro(flag); }, [live]);
2135
+ var detectMicro = React__default["default"].useCallback(function () { return live.$RTC.detectMicro(); }, [live]);
1767
2136
  return {
1768
- join,
1769
- quit,
1770
- shock,
1771
- toggleMicro,
1772
- detectMicro,
2137
+ join: join,
2138
+ quit: quit,
2139
+ shock: shock,
2140
+ toggleMicro: toggleMicro,
2141
+ detectMicro: detectMicro,
1773
2142
  };
1774
2143
  }
1775
- function useRTCEventCallback(name, callback, deps = []) {
1776
- const live = useLiveInstance();
1777
- const dispose = () => live.$RTC.off(name, callback);
1778
- const dependencyList = [live, name, ...deps];
1779
- React__default["default"].useEffect(() => {
2144
+ function useRTCEventCallback(name, callback, deps) {
2145
+ if (deps === void 0) { deps = []; }
2146
+ var live = useLiveInstance();
2147
+ var dispose = function () { return live.$RTC.off(name, callback); };
2148
+ var dependencyList = __spreadArray([live, name], deps, true);
2149
+ React__default["default"].useEffect(function () {
1780
2150
  live.$RTC.on(name, callback);
1781
2151
  return dispose;
1782
2152
  }, dependencyList);
1783
2153
  return dispose;
1784
2154
  }
1785
2155
  function useSelfInfo() {
1786
- const live = useLiveInstance();
1787
- const [state, updateState] = React__default["default"].useState(live.selfInfo || {});
1788
- const selfInfoUpdate = (userInfo) => updateState(userInfo);
1789
- React__default["default"].useEffect(() => {
2156
+ var _this = this;
2157
+ var live = useLiveInstance();
2158
+ var _a = React__default["default"].useState(live.selfInfo || {}), state = _a[0], updateState = _a[1];
2159
+ var selfInfoUpdate = function (userInfo) {
2160
+ return updateState(userInfo);
2161
+ };
2162
+ React__default["default"].useEffect(function () {
1790
2163
  live.on('selfInfoUpdate', selfInfoUpdate);
1791
- return () => live.off('selfInfoUpdate', selfInfoUpdate);
1792
- }, [live]);
1793
- const setState = React__default["default"].useCallback(async (userInfo) => {
1794
- return await live.setSelfInfo(userInfo);
2164
+ return function () { return live.off('selfInfoUpdate', selfInfoUpdate); };
1795
2165
  }, [live]);
2166
+ var setState = React__default["default"].useCallback(function (userInfo) { return __awaiter(_this, void 0, void 0, function () {
2167
+ return __generator(this, function (_a) {
2168
+ switch (_a.label) {
2169
+ case 0: return [4 /*yield*/, live.setSelfInfo(userInfo)];
2170
+ case 1: return [2 /*return*/, _a.sent()];
2171
+ }
2172
+ });
2173
+ }); }, [live]);
1796
2174
  return [state, setState];
1797
2175
  }
1798
2176
  function useSnapshot() {
1799
- const live = useLiveInstance();
1800
- const [state, setState] = React__default["default"].useState(live.snapshot);
1801
- React__default["default"].useEffect(() => {
1802
- const onKeyframes = (keyframes) => setState(keyframes);
2177
+ var live = useLiveInstance();
2178
+ var _a = React__default["default"].useState(live.snapshot), state = _a[0], setState = _a[1];
2179
+ React__default["default"].useEffect(function () {
2180
+ var onKeyframes = function (keyframes) { return setState(keyframes); };
1803
2181
  live.on('keyframes', onKeyframes);
1804
- return () => live.off('keyframes', onKeyframes);
2182
+ return function () { return live.off('keyframes', onKeyframes); };
1805
2183
  });
1806
2184
  return state;
1807
2185
  }
1808
2186
  function useUserList() {
1809
- const live = useLiveInstance();
1810
- const [state, updateState] = React__default["default"].useState(live.userList);
1811
- const userListUpdate = (userList) => updateState(userList);
1812
- React__default["default"].useEffect(() => {
2187
+ var live = useLiveInstance();
2188
+ var _a = React__default["default"].useState(live.userList), state = _a[0], updateState = _a[1];
2189
+ var userListUpdate = function (userList) { return updateState(userList); };
2190
+ React__default["default"].useEffect(function () {
1813
2191
  live.on('userListUpdate', userListUpdate);
1814
- return () => live.off('userListUpdate', userListUpdate);
2192
+ return function () { return live.off('userListUpdate', userListUpdate); };
1815
2193
  }, [live]);
1816
2194
  return state;
1817
2195
  }
@@ -1823,35 +2201,36 @@ function createLiveReact(options) {
1823
2201
  * @returns
1824
2202
  * @deprecated
1825
2203
  */
1826
- function useWebSocketEventCallback(name, callback, deps = []) {
1827
- const live = useLiveInstance();
1828
- const dispose = () => live.off(name, callback);
1829
- const dependencyList = [live, name, ...deps];
1830
- React__default["default"].useEffect(() => {
2204
+ function useWebSocketEventCallback(name, callback, deps) {
2205
+ if (deps === void 0) { deps = []; }
2206
+ var live = useLiveInstance();
2207
+ var dispose = function () { return live.off(name, callback); };
2208
+ var dependencyList = __spreadArray([live, name], deps, true);
2209
+ React__default["default"].useEffect(function () {
1831
2210
  live.on(name, callback);
1832
2211
  return dispose;
1833
2212
  }, dependencyList);
1834
2213
  return dispose;
1835
2214
  }
1836
2215
  return {
1837
- live,
1838
- jsBridge,
1839
- LiveProvider,
1840
- unsafe__useLiveInstance,
1841
- unsafe__useRTCInstance,
1842
- useCurrentWebSocketUrl,
1843
- useConnect,
1844
- useKeyframe,
1845
- useKeyframeUpdateCallback,
1846
- useLiveAction,
1847
- useLiveEventCallback,
1848
- useReadyState,
1849
- useRTCAction,
1850
- useRTCEventCallback,
1851
- useSelfInfo,
1852
- useSnapshot,
1853
- useUserList,
1854
- useWebSocketEventCallback,
2216
+ live: live,
2217
+ jsBridge: jsBridge,
2218
+ LiveProvider: LiveProvider,
2219
+ unsafe__useLiveInstance: unsafe__useLiveInstance,
2220
+ unsafe__useRTCInstance: unsafe__useRTCInstance,
2221
+ useCurrentWebSocketUrl: useCurrentWebSocketUrl,
2222
+ useConnect: useConnect,
2223
+ useKeyframe: useKeyframe,
2224
+ useKeyframeUpdateCallback: useKeyframeUpdateCallback,
2225
+ useLiveAction: useLiveAction,
2226
+ useLiveEventCallback: useLiveEventCallback,
2227
+ useReadyState: useReadyState,
2228
+ useRTCAction: useRTCAction,
2229
+ useRTCEventCallback: useRTCEventCallback,
2230
+ useSelfInfo: useSelfInfo,
2231
+ useSnapshot: useSnapshot,
2232
+ useUserList: useUserList,
2233
+ useWebSocketEventCallback: useWebSocketEventCallback,
1855
2234
  };
1856
2235
  }
1857
2236