@realsee/live 0.6.9 → 0.6.11-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var Vt = Object.defineProperty;
2
- var $t = (r, s, e) => s in r ? Vt(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
3
- var o = (r, s, e) => ($t(r, typeof s != "symbol" ? s + "" : s, e), e);
2
+ var $t = (r, o, e) => o in r ? Vt(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e;
3
+ var s = (r, o, e) => ($t(r, typeof o != "symbol" ? o + "" : o, e), e);
4
4
  import xt from "@realsee/jsbridge-x";
5
5
  import Ne from "trtc-js-sdk";
6
6
  import { ConsoleLogger as Ut, LogLevel as Ft, DefaultDeviceController as Bt, MeetingSessionConfiguration as Wt, DefaultMeetingSession as Kt, DefaultModality as tt, MeetingSessionStatusCode as qt } from "amazon-chime-sdk-js";
@@ -17,9 +17,9 @@ class ue {
17
17
  * 判断是否注册了事件
18
18
  * @param name 事件类型
19
19
  */
20
- hasListener(s) {
20
+ hasListener(o) {
21
21
  const e = pe(this);
22
- return e && e[s] && e[s].length > 0;
22
+ return e && e[o] && e[o].length > 0;
23
23
  }
24
24
  /**
25
25
  * 注册事件
@@ -30,9 +30,9 @@ class ue {
30
30
  * @template K 预设的监听事件名称
31
31
  * @template C 回调函数函数上下文
32
32
  */
33
- on(s, e, i) {
33
+ on(o, e, i) {
34
34
  const n = pe(this);
35
- return n[s] || (n[s] = []), n[s].push([e, i || !1]), () => this.off(s, e);
35
+ return n[o] || (n[o] = []), n[o].push([e, i || !1]), () => this.off(o, e);
36
36
  }
37
37
  /**
38
38
  * 注册事件(是否只执行一次)
@@ -42,8 +42,8 @@ class ue {
42
42
  * @template K 预设的监听事件名称
43
43
  * @template C 回调函数函数上下文
44
44
  */
45
- once(s, e) {
46
- return this.on(s, e, !0);
45
+ once(o, e) {
46
+ return this.on(o, e, !0);
47
47
  }
48
48
  /**
49
49
  * 解除事件
@@ -54,20 +54,20 @@ class ue {
54
54
  * @param callback 事件回调函数
55
55
  * @template K 预设的监听事件名称
56
56
  */
57
- off(s, e) {
58
- if (s === void 0) {
57
+ off(o, e) {
58
+ if (o === void 0) {
59
59
  Yt(this);
60
60
  return;
61
61
  }
62
62
  const i = pe(this);
63
- if (i[s] || (i[s] = []), e === void 0) {
64
- i[s].length = 0;
63
+ if (i[o] || (i[o] = []), e === void 0) {
64
+ i[o].length = 0;
65
65
  return;
66
66
  }
67
67
  let n = 0;
68
- for (; n < i[s].length && i[s][n][0] !== e; n++)
68
+ for (; n < i[o].length && i[o][n][0] !== e; n++)
69
69
  ;
70
- n < i[s].length && i[s].splice(n, 1);
70
+ n < i[o].length && i[o].splice(n, 1);
71
71
  }
72
72
  /**
73
73
  * 触发事件
@@ -76,12 +76,12 @@ class ue {
76
76
  * @returns canceled 是否被触发取消
77
77
  * @template K 预设的监听事件名称
78
78
  */
79
- emit(s, ...e) {
79
+ emit(o, ...e) {
80
80
  let i = !1;
81
- const c = pe(this)[s] || [];
81
+ const c = pe(this)[o] || [];
82
82
  for (let u of c.slice()) {
83
83
  const [d, g = !1] = u, v = d(...e);
84
- g && this.off(s, d), v === !1 && (i = !0);
84
+ g && this.off(o, d), v === !1 && (i = !0);
85
85
  }
86
86
  return i;
87
87
  }
@@ -90,18 +90,18 @@ class Me extends ue {
90
90
  }
91
91
  var Q = /* @__PURE__ */ ((r) => (r.RealseeBrowserRTC = "RealseeBrowserRTC", r.RealseeVRWebViewRTC = "RealseeVRWebViewRTC", r.RealseeBrowserChimeRTC = "RealseeBrowserChimeRTC", r))(Q || {}), ut = /* @__PURE__ */ ((r) => (r.RealseeXTRTC = "trtc", r.RealseeXChimeRTC = "chime", r))(ut || {});
92
92
  const Ht = () => {
93
- const r = new Date(), s = r.getFullYear(), e = (r.getMonth() + 1).toString().padStart(2, "0"), i = r.getDate().toString().padStart(2, "0"), n = r.getHours().toString().padStart(2, "0"), c = r.getMinutes().toString().padStart(2, "0"), u = r.getSeconds().toString().padStart(2, "0"), d = r.getMilliseconds();
94
- return `[${s}-${e}-${i} ${n}:${c}:${u}.${d}]`;
95
- }, be = (r, s = []) => {
96
- switch (s.unshift(`Realsee Live ${Ht()} <${r}> `), r) {
93
+ const r = new Date(), o = r.getFullYear(), e = (r.getMonth() + 1).toString().padStart(2, "0"), i = r.getDate().toString().padStart(2, "0"), n = r.getHours().toString().padStart(2, "0"), c = r.getMinutes().toString().padStart(2, "0"), u = r.getSeconds().toString().padStart(2, "0"), d = r.getMilliseconds();
94
+ return `[${o}-${e}-${i} ${n}:${c}:${u}.${d}]`;
95
+ }, be = (r, o = []) => {
96
+ switch (o.unshift(`Realsee Live ${Ht()} <${r}> `), r) {
97
97
  case "INFO":
98
- return console.info(...s);
98
+ return console.info(...o);
99
99
  case "ERROR":
100
- return console.error(...s);
100
+ return console.error(...o);
101
101
  case "WARN":
102
- return console.warn(...s);
102
+ return console.warn(...o);
103
103
  default:
104
- return console.log(...s);
104
+ return console.log(...o);
105
105
  }
106
106
  }, Jt = (...r) => be("LOG", r), zt = (...r) => be("INFO", r), Xt = (...r) => be("ERROR", r), Zt = (...r) => be("WARN", r), Qt = {
107
107
  log: Jt,
@@ -118,21 +118,21 @@ function Ee() {
118
118
  class rt extends Me {
119
119
  constructor(e) {
120
120
  super();
121
- o(this, "type", Q.RealseeBrowserRTC);
122
- o(this, "joined", !1);
123
- o(this, "micro", !1);
124
- o(this, "voiceId", "");
125
- o(this, "_getVoiceSign", () => {
121
+ s(this, "type", Q.RealseeBrowserRTC);
122
+ s(this, "joined", !1);
123
+ s(this, "micro", !1);
124
+ s(this, "voiceId", "");
125
+ s(this, "_getVoiceSign", () => {
126
126
  throw new Error("方法 getVoiceSign 未实现");
127
127
  });
128
- o(this, "_autoPlayConfirm");
129
- o(this, "checkRequirement", () => Ne.checkSystemRequirements());
130
- o(this, "$dom", document.createElement("div"));
131
- o(this, "_trtc", {
128
+ s(this, "_autoPlayConfirm");
129
+ s(this, "checkRequirement", () => Ne.checkSystemRequirements());
130
+ s(this, "$dom", document.createElement("div"));
131
+ s(this, "_trtc", {
132
132
  client: null,
133
133
  stream: null
134
134
  });
135
- o(this, "join", async (e) => {
135
+ s(this, "join", async (e) => {
136
136
  var c;
137
137
  this.emit("joinWillStart");
138
138
  const i = await this._getVoiceSign({
@@ -161,12 +161,12 @@ class rt extends Me {
161
161
  (d = this._trtc.client) == null || d.publish(this._trtc.stream).then(() => u(!0)).catch(() => u(!1));
162
162
  }), this.joined = n, this.joined && this.emit("joined"), n) : !1;
163
163
  });
164
- o(this, "_handleStreamAdded", (e) => {
164
+ s(this, "_handleStreamAdded", (e) => {
165
165
  var n;
166
166
  const i = e.stream;
167
167
  console.log("远端流增加: " + i.getId()), (n = this._trtc.client) == null || n.subscribe(i);
168
168
  });
169
- o(this, "_handleStreamSubscribed", (e) => {
169
+ s(this, "_handleStreamSubscribed", (e) => {
170
170
  const i = e.stream;
171
171
  console.log("远端流订阅成功:" + i.getId());
172
172
  const c = `rs-rtc-remote_stream-${i.getId()}`, u = document.createElement("div");
@@ -227,35 +227,35 @@ class rt extends Me {
227
227
  class it extends Me {
228
228
  constructor(e) {
229
229
  super();
230
- o(this, "type", Q.RealseeBrowserChimeRTC);
231
- o(this, "joined", !1);
232
- o(this, "micro", !1);
233
- o(this, "voiceId", "");
234
- o(this, "userId", "");
235
- o(this, "logger");
236
- o(this, "deviceController");
237
- o(this, "meetingSession");
238
- o(this, "audioInput");
239
- o(this, "audioOutput");
240
- o(this, "deviceChangeObserver", {});
241
- o(this, "audioVideoObserver", {});
242
- o(this, "audioMixObserver");
243
- o(this, "_getVoiceSign", () => {
230
+ s(this, "type", Q.RealseeBrowserChimeRTC);
231
+ s(this, "joined", !1);
232
+ s(this, "micro", !1);
233
+ s(this, "voiceId", "");
234
+ s(this, "userId", "");
235
+ s(this, "logger");
236
+ s(this, "deviceController");
237
+ s(this, "meetingSession");
238
+ s(this, "audioInput");
239
+ s(this, "audioOutput");
240
+ s(this, "deviceChangeObserver", {});
241
+ s(this, "audioVideoObserver", {});
242
+ s(this, "audioMixObserver");
243
+ s(this, "_getVoiceSign", () => {
244
244
  throw new Error("方法 getVoiceSign 未实现");
245
245
  });
246
- o(this, "_autoPlayConfirm");
247
- o(this, "$dom", document.createElement("div"));
248
- o(this, "$audio", document.createElement("audio"));
246
+ s(this, "_autoPlayConfirm");
247
+ s(this, "$dom", document.createElement("div"));
248
+ s(this, "$audio", document.createElement("audio"));
249
249
  /**
250
250
  * 对audio标签初始化
251
251
  */
252
- o(this, "_initDom", () => {
252
+ s(this, "_initDom", () => {
253
253
  this.$audio.id = `rs-rtc-${Ee()}`, this.$dom.id = `rs-rtc-${Ee()}`, this.$dom.appendChild(this.$audio), document.body.appendChild(this.$dom);
254
254
  });
255
255
  /**
256
256
  * 初始化事件监听器
257
257
  */
258
- o(this, "initObservers", () => {
258
+ s(this, "initObservers", () => {
259
259
  this.deviceChangeObserver = {
260
260
  audioInputsChanged: (e) => {
261
261
  this.logger.info(`audioInputsChanged ${typeof e}`), e == null || e.forEach((i) => {
@@ -303,7 +303,7 @@ class it extends Me {
303
303
  /**
304
304
  * 注册rtc事件
305
305
  */
306
- o(this, "_registerRtcEvent", () => {
306
+ s(this, "_registerRtcEvent", () => {
307
307
  var i, n, c, u, d, g;
308
308
  const e = ((c = (n = (i = this.meetingSession) == null ? void 0 : i.configuration) == null ? void 0 : n.credentials) == null ? void 0 : c.attendeeId) || "";
309
309
  if (e) {
@@ -447,17 +447,14 @@ var lt = /* @__PURE__ */ ((r) => (r[r.Success = 0] = "Success", r[r.Failure = 1]
447
447
  class nt extends Me {
448
448
  constructor({ jsBridge: e, getVoiceSign: i }) {
449
449
  super();
450
- o(this, "type", Q.RealseeVRWebViewRTC);
451
- o(this, "joined", !1);
452
- o(this, "micro", !1);
453
- o(this, "voiceId", "");
454
- o(this, "options");
455
- this.options = { jsBridge: e, getVoiceSign: i }, this.jsBridge.webViewType !== "WxMiniProgramWebView" && this.jsBridge.callAndListen(
456
- "live/userVolumes",
457
- (n) => {
458
- this.emit("userVolumes", n);
459
- }
460
- ), this.jsBridge.callAndListen("live/weakNetwork", (n) => {
450
+ s(this, "type", Q.RealseeVRWebViewRTC);
451
+ s(this, "joined", !1);
452
+ s(this, "micro", !1);
453
+ s(this, "voiceId", "");
454
+ s(this, "options");
455
+ this.options = { jsBridge: e, getVoiceSign: i }, this.jsBridge.webViewType !== "WxMiniProgramWebView" && this.jsBridge.callAndListen("live/userVolumes", (n) => {
456
+ this.emit("userVolumes", n);
457
+ }), this.jsBridge.callAndListen("live/weakNetwork", (n) => {
461
458
  n && this.emit("weakNetwork");
462
459
  });
463
460
  }
@@ -467,29 +464,20 @@ class nt extends Me {
467
464
  async join(e) {
468
465
  try {
469
466
  this.emit("joinWillStart");
470
- const { sdkAppId: i, userId: n, userSig: c } = await this.options.getVoiceSign(
471
- e
472
- );
467
+ const { sdkAppId: i, userId: n, userSig: c } = await this.options.getVoiceSign(e);
473
468
  if (!(Boolean(i) && Boolean(n) && Boolean(c)))
474
469
  return this.emit("error", new Error("加入房间失败:rtc 签名请求异常")), this.joined = !1, this.joined;
475
470
  this.type = e.type;
476
471
  const [u, d] = await this.jsBridge.callAndBackfeed(
477
- `live/join?sdkAppID=${i}&userID=${n}&roomID=${Number(
478
- e.voiceId
479
- )}&userSig=${c}`
472
+ `live/join?sdkAppID=${i}&userID=${n}&roomID=${Number(e.voiceId)}&userSig=${c}`
480
473
  );
481
- return u ? u.code === lt.Success ? (this.emit("joined"), this.joined = !0) : (this.emit("error", u), this.joined = !1) : (this.emit(
482
- "error",
483
- d || new Error("加入房间失败:未知异常。")
484
- ), this.joined = !1), this.joined;
474
+ return O.info(`加入语音房间回调结果: ${JSON.stringify(u)}`), d && O.error("加入语音房间回调报错:", d), u === !0 ? (this.emit("joined"), this.joined = !0) : u ? u.code === lt.Success ? (this.emit("joined"), this.joined = !0) : (this.emit("error", u), this.joined = !1) : (this.emit("error", d || new Error("加入房间失败:未知异常。")), this.joined = !1), this.joined;
485
475
  } catch (i) {
486
476
  return this.emit("error", new Error("加入房间失败:" + i.message)), this.joined = !1, this.joined;
487
477
  }
488
478
  }
489
479
  async quit() {
490
- const [e, i] = await this.jsBridge.callAndBackfeed(
491
- "live/quit"
492
- );
480
+ const [e, i] = await this.jsBridge.callAndBackfeed("live/quit");
493
481
  return e === null && this.emit("error", i || new Error("退出房间失败:未知异常。")), this.joined = !1, !!e;
494
482
  }
495
483
  async detectMicro() {
@@ -497,9 +485,7 @@ class nt extends Me {
497
485
  return e === null ? (this.emit("error", i || new Error("麦克风监测异常!")), !1) : e;
498
486
  }
499
487
  async toggleMicro(e) {
500
- const [i, n] = await this.jsBridge.callAndBackfeed(
501
- `live/toggleMicro?flag=${e ? 1 : 0}`
502
- );
488
+ const [i, n] = await this.jsBridge.callAndBackfeed(`live/toggleMicro?flag=${e ? 1 : 0}`);
503
489
  return i === null ? (this.emit("error", n || new Error("麦克风监测异常!")), !1) : (this.micro = i, i);
504
490
  }
505
491
  shock() {
@@ -509,21 +495,21 @@ class nt extends Me {
509
495
  var K = /* @__PURE__ */ ((r) => (r.SelfUserInfo = "SELF_USER_INFO", r.RoomInfo = "ROOM_INFO", r.RTCInfo = "RTC_INFO", r.UserList = "USER_LIST", r.BuiltinMsg = "BUILTIN_MSG", r.CustomEvent = "CUSTOM_EVENT", r.KeyframeSync = "KEYFRAME_SYNC", r.UserKickOut = "USER_KICK_OUT", r))(K || {}), q = /* @__PURE__ */ ((r) => (r.UserChange = "user_change", r.RoomChange = "room_change", r))(q || {}), H = /* @__PURE__ */ ((r) => (r.UserMicroStatus = "change_micro_status", r.UserMicroStatusSync = "sync_micro_status", r.UserPermission = "change_permission", r.UserStatus = "change_status", r.UserInfo = "change_info", r.RoomClose = "close", r))(H || {}), Z = /* @__PURE__ */ ((r) => (r.OPEN = "OPEN", r.CLOSE = "CLOSE", r))(Z || {});
510
496
  function Nr(r) {
511
497
  try {
512
- const s = JSON.parse(r), e = {
513
- code: s.code,
514
- message: s.message,
515
- command: s.command,
516
- roomCode: s.room_code,
517
- appID: s.app_id,
518
- requestId: s.request_id,
519
- frontRequestId: s.front_request_id,
520
- triggerUserID: s.trigger_user_id,
521
- data: s.data || {}
498
+ const o = JSON.parse(r), e = {
499
+ code: o.code,
500
+ message: o.message,
501
+ command: o.command,
502
+ roomCode: o.room_code,
503
+ appID: o.app_id,
504
+ requestId: o.request_id,
505
+ frontRequestId: o.front_request_id,
506
+ triggerUserID: o.trigger_user_id,
507
+ data: o.data || {}
522
508
  }, i = Object.keys(e).filter(
523
509
  (n) => e[n] === void 0
524
510
  );
525
511
  return i.length > 0 && console.warn(`推送数据格式异常:${i.join(" ")} 值不存在!`), e;
526
- } catch (s) {
512
+ } catch (o) {
527
513
  return !1;
528
514
  }
529
515
  }
@@ -555,15 +541,15 @@ function sr(r) {
555
541
  var ft = {};
556
542
  (function(r) {
557
543
  Object.defineProperty(r, "__esModule", { value: !0 }), r.LogLevel = void 0;
558
- var s;
544
+ var o;
559
545
  (function(e) {
560
546
  e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.OFF = 4] = "OFF";
561
- })(s = r.LogLevel || (r.LogLevel = {})), r.default = s;
547
+ })(o = r.LogLevel || (r.LogLevel = {})), r.default = o;
562
548
  })(ft);
563
549
  const st = /* @__PURE__ */ sr(ft);
564
- function or(r, s = {}) {
565
- const e = r.indexOf("?") !== -1, i = Object.keys(s).reduce(
566
- (n, c, u) => `${n}${u === 0 && !e ? "?" : "&"}${c}=${s[c]}`,
550
+ function or(r, o = {}) {
551
+ const e = r.indexOf("?") !== -1, i = Object.keys(o).reduce(
552
+ (n, c, u) => `${n}${u === 0 && !e ? "?" : "&"}${c}=${o[c]}`,
567
553
  ""
568
554
  );
569
555
  return r + i;
@@ -572,141 +558,141 @@ const le = globalThis.navigator.userAgent, ar = /android/gi.test(le), cr = /iPho
572
558
  function ye(r) {
573
559
  return Object.prototype.toString.call(r) === "[object Object]";
574
560
  }
575
- function Se(r, s) {
576
- return r === s ? !0 : typeof r != typeof s ? !1 : !!(Number.isNaN(r) && Number.isNaN(s));
561
+ function Se(r, o) {
562
+ return r === o ? !0 : typeof r != typeof o ? !1 : !!(Number.isNaN(r) && Number.isNaN(o));
577
563
  }
578
- function fr(r, s) {
579
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(s);
564
+ function fr(r, o) {
565
+ const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
580
566
  if (e.length !== i.length)
581
567
  return !1;
582
568
  for (let n = 0, c = e.length; n < c; n++) {
583
569
  const u = e[n];
584
- if (!Se(r[u], s[u]))
570
+ if (!Se(r[u], o[u]))
585
571
  return !1;
586
572
  }
587
573
  return !0;
588
574
  }
589
- function dr(r, s) {
590
- if (r.length !== s.length)
575
+ function dr(r, o) {
576
+ if (r.length !== o.length)
591
577
  return !1;
592
578
  for (let e = 0, i = r.length; e < i; e++)
593
- if (!Se(r[e], s[e]))
579
+ if (!Se(r[e], o[e]))
594
580
  return !1;
595
581
  return !0;
596
582
  }
597
- function hr(r, s) {
598
- return Se(r, s) ? !0 : ye(r) && ye(s) ? fr(r, s) : Array.isArray(r) && Array.isArray(s) ? dr(r, s) : !1;
583
+ function hr(r, o) {
584
+ return Se(r, o) ? !0 : ye(r) && ye(o) ? fr(r, o) : Array.isArray(r) && Array.isArray(o) ? dr(r, o) : !1;
599
585
  }
600
- function De(r, s) {
601
- return Se(r, s) ? !0 : ye(r) && ye(s) ? gr(r, s) : Array.isArray(r) && Array.isArray(s) ? _r(r, s) : !1;
586
+ function De(r, o) {
587
+ return Se(r, o) ? !0 : ye(r) && ye(o) ? gr(r, o) : Array.isArray(r) && Array.isArray(o) ? _r(r, o) : !1;
602
588
  }
603
- function _r(r, s) {
604
- if (r.length !== s.length)
589
+ function _r(r, o) {
590
+ if (r.length !== o.length)
605
591
  return !1;
606
592
  for (let e = 0, i = r.length; e < i; e++)
607
- if (!De(r[e], s[e]))
593
+ if (!De(r[e], o[e]))
608
594
  return !1;
609
595
  return !0;
610
596
  }
611
- function gr(r, s) {
612
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(s);
597
+ function gr(r, o) {
598
+ const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
613
599
  if (e.length !== i.length)
614
600
  return !1;
615
601
  for (let n = 0, c = e.length; n < c; n++) {
616
602
  const u = e[n];
617
- if (!De(r[u], s[u]))
603
+ if (!De(r[u], o[u]))
618
604
  return !1;
619
605
  }
620
606
  return !0;
621
607
  }
622
- function ot(r, s, e = { deep: !1 }) {
623
- return e.deep ? De(r, s) : hr(r, s);
608
+ function ot(r, o, e = { deep: !1 }) {
609
+ return e.deep ? De(r, o) : hr(r, o);
624
610
  }
625
611
  class mr extends ue {
626
612
  constructor(e) {
627
613
  super();
628
- o(this, "_realWebSocket");
629
- o(this, "_url");
630
- o(this, "_protocols");
631
- o(this, "_readyState", Le.NOTINITIALIZED);
632
- o(this, "_options", {
614
+ s(this, "_realWebSocket");
615
+ s(this, "_url");
616
+ s(this, "_protocols");
617
+ s(this, "_readyState", Le.NOTINITIALIZED);
618
+ s(this, "_options", {
633
619
  timeout: 1e4,
634
620
  shouldReconnect: (e, i) => {
635
621
  if (!(e.code === 1008 || e.code === 1011))
636
- return [1e3, 3e3, 6e3][i.attempts % 3];
622
+ return [0, 1e3, 2e3][i.attempts % 3];
637
623
  },
638
624
  should1000Reconnect: !1,
639
625
  ignoreConnectivityEvents: !1,
640
626
  automaticOpen: !1
641
627
  });
642
- o(this, "_connectTimeout");
643
- o(this, "_attempts", 0);
644
- o(this, "_reconnects", -1);
645
- o(this, "_reconnectWhenOnlineAgain", !1);
646
- o(this, "_explicitlyClosed", !1);
647
- o(this, "_pendingReconnect");
648
- o(this, "_connectivityEventsAttached", !1);
649
- o(this, "_heathCheckTimer");
628
+ s(this, "_connectTimeout");
629
+ s(this, "_attempts", 0);
630
+ s(this, "_reconnects", -1);
631
+ s(this, "_reconnectWhenOnlineAgain", !1);
632
+ s(this, "_explicitlyClosed", !1);
633
+ s(this, "_pendingReconnect");
634
+ s(this, "_connectivityEventsAttached", !1);
635
+ s(this, "_heathCheckTimer");
650
636
  /**
651
637
  * 做一个健康检查
652
638
  */
653
- o(this, "_healthCheck", async () => {
639
+ s(this, "_healthCheck", async () => {
654
640
  this._realWebSocket && this._realWebSocket.readyState !== this._readyState && (this._readyState = this._realWebSocket.readyState, this._readyState === Le.CLOSING && this.emit("closing")), await new Promise((e) => setTimeout(e, 2e3)), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
655
641
  });
656
642
  /**
657
643
  * 清理超时计时器
658
644
  */
659
- o(this, "_clearConnectTimeoutIfNeed", () => {
645
+ s(this, "_clearConnectTimeoutIfNeed", () => {
660
646
  this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
661
647
  });
662
648
  /**
663
649
  * 清理健康检查
664
650
  */
665
- o(this, "_clearHeathCheckIfNeed", () => {
651
+ s(this, "_clearHeathCheckIfNeed", () => {
666
652
  this._heathCheckTimer && (cancelAnimationFrame(this._heathCheckTimer), this._heathCheckTimer = void 0);
667
653
  });
668
654
  /**
669
655
  * 开启健康检查
670
656
  */
671
- o(this, "_startHealthCheck", () => {
657
+ s(this, "_startHealthCheck", () => {
672
658
  this._clearHeathCheckIfNeed(), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
673
659
  });
674
660
  /**
675
661
  * 停止健康检查
676
662
  */
677
- o(this, "_stopHealthCheck", () => {
663
+ s(this, "_stopHealthCheck", () => {
678
664
  this._clearHeathCheckIfNeed();
679
665
  });
680
666
  /**
681
667
  * 清理连接中的请求
682
668
  */
683
- o(this, "_clearPendingReconnectIfNeeded", () => {
669
+ s(this, "_clearPendingReconnectIfNeeded", () => {
684
670
  this._pendingReconnect && (clearTimeout(this._pendingReconnect), this._pendingReconnect = void 0);
685
671
  });
686
672
  /**
687
673
  * 当网页连接上网络进行重连
688
674
  * @param event
689
675
  */
690
- o(this, "_online", (e) => {
676
+ s(this, "_online", (e) => {
691
677
  this._reconnectWhenOnlineAgain && (this._clearPendingReconnectIfNeeded(), this._reconnect(e));
692
678
  });
693
679
  /**
694
680
  * 当网页断开网络进行关闭
695
681
  */
696
- o(this, "_offline", () => {
682
+ s(this, "_offline", () => {
697
683
  var e;
698
684
  this._reconnectWhenOnlineAgain = !0, (e = this._realWebSocket) == null || e.close(1e3, "offline");
699
685
  });
700
686
  /**
701
687
  * 解除网络监听事件
702
688
  */
703
- o(this, "_detachConnectivityEvents", () => {
689
+ s(this, "_detachConnectivityEvents", () => {
704
690
  this._connectivityEventsAttached && (globalThis == null || globalThis.removeEventListener("online", this._online), globalThis == null || globalThis.removeEventListener("offline", this._offline), this._connectivityEventsAttached = !1);
705
691
  });
706
692
  /**
707
693
  * 注册网络监听事件
708
694
  */
709
- o(this, "_attachConnectivityEvents", () => {
695
+ s(this, "_attachConnectivityEvents", () => {
710
696
  this._connectivityEventsAttached || (globalThis == null || globalThis.addEventListener("online", this._online), globalThis == null || globalThis.addEventListener("offline", this._offline), this._connectivityEventsAttached = !0);
711
697
  });
712
698
  /**
@@ -714,7 +700,7 @@ class mr extends ue {
714
700
  * @param data
715
701
  * @returns
716
702
  */
717
- o(this, "send", (e) => {
703
+ s(this, "send", (e) => {
718
704
  var i, n, c;
719
705
  ((i = this._realWebSocket) == null ? void 0 : i.readyState) === ((n = this._realWebSocket) == null ? void 0 : n.OPEN) && ((c = this._realWebSocket) == null || c.send(e));
720
706
  });
@@ -724,21 +710,21 @@ class mr extends ue {
724
710
  * @param reason 原因
725
711
  * @returns
726
712
  */
727
- o(this, "close", (e, i) => {
713
+ s(this, "close", (e, i) => {
728
714
  var n;
729
715
  return typeof e != "number" && (i = e, e = 1e3), this._clearPendingReconnectIfNeeded(), this._reconnectWhenOnlineAgain = !1, this._explicitlyClosed = !0, this._detachConnectivityEvents(), (n = this._realWebSocket) == null ? void 0 : n.close(e, i);
730
716
  });
731
717
  /**
732
718
  * 进行ws连接
733
719
  */
734
- o(this, "open", (e) => {
720
+ s(this, "open", (e) => {
735
721
  var i, n;
736
722
  e && (this._url = e), ((i = this._realWebSocket) == null ? void 0 : i.readyState) !== WebSocket.OPEN && ((n = this._realWebSocket) == null ? void 0 : n.readyState) !== WebSocket.CONNECTING && (this._clearPendingReconnectIfNeeded(), this._reconnectWhenOnlineAgain = !1, this._explicitlyClosed = !1, this._createWebSocket());
737
723
  });
738
724
  /**
739
725
  * 创建ws连接
740
726
  */
741
- o(this, "_createWebSocket", () => {
727
+ s(this, "_createWebSocket", () => {
742
728
  var n, c, u;
743
729
  const e = typeof this._url == "string" ? this._url : (n = this._url) == null ? void 0 : n.call(this, this);
744
730
  if (!e)
@@ -765,14 +751,14 @@ class mr extends ue {
765
751
  /**
766
752
  * 断开ws事件
767
753
  */
768
- o(this, "_removeWebSocketEvent", () => {
754
+ s(this, "_removeWebSocketEvent", () => {
769
755
  var e, i, n, c;
770
756
  (e = this._realWebSocket) == null || e.removeEventListener("open", this._webSocketOpenHandler), (i = this._realWebSocket) == null || i.removeEventListener("close", this._webSocketCloseHandler), (n = this._realWebSocket) == null || n.removeEventListener("error", this._webSocketErrorHandler), (c = this._realWebSocket) == null || c.removeEventListener("message", this._webSocketMessageHandler);
771
757
  });
772
758
  /**
773
759
  * 分发ws事件
774
760
  */
775
- o(this, "_dispatchWebSocketEvent", () => {
761
+ s(this, "_dispatchWebSocketEvent", () => {
776
762
  var e, i, n, c;
777
763
  (e = this._realWebSocket) == null || e.addEventListener("open", this._webSocketOpenHandler), (i = this._realWebSocket) == null || i.addEventListener("close", this._webSocketCloseHandler), (n = this._realWebSocket) == null || n.addEventListener("error", this._webSocketErrorHandler), (c = this._realWebSocket) == null || c.addEventListener("message", this._webSocketMessageHandler);
778
764
  });
@@ -780,7 +766,7 @@ class mr extends ue {
780
766
  * ws连接事件
781
767
  * @returns
782
768
  */
783
- o(this, "_webSocketOpenHandler", (e) => {
769
+ s(this, "_webSocketOpenHandler", (e) => {
784
770
  this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
785
771
  const i = ++this._reconnects, n = this._attempts;
786
772
  return this._attempts = 0, this._reconnectWhenOnlineAgain = !1, this._startHealthCheck(), this.emit("open", Object.assign(e, { detail: { reconnects: i, attempts: n } }));
@@ -790,19 +776,19 @@ class mr extends ue {
790
776
  * @param event
791
777
  * @returns
792
778
  */
793
- o(this, "_webSocketCloseHandler", (e) => (this._reconnect(e), this._stopHealthCheck(), this.emit("close", e)));
779
+ s(this, "_webSocketCloseHandler", (e) => (this._reconnect(e), this._stopHealthCheck(), this.emit("close", e)));
794
780
  /**
795
781
  * ws 异常
796
782
  * @param event
797
783
  * @returns
798
784
  */
799
- o(this, "_webSocketErrorHandler", (e) => this.emit("error", new CustomEvent("error", { detail: { error: e } })));
785
+ s(this, "_webSocketErrorHandler", (e) => this.emit("error", new CustomEvent("error", { detail: { error: e } })));
800
786
  /**
801
787
  * ws消息
802
788
  * @param event
803
789
  * @returns
804
790
  */
805
- o(this, "_webSocketMessageHandler", (e) => this.emit("message", e));
791
+ s(this, "_webSocketMessageHandler", (e) => this.emit("message", e));
806
792
  e && this.setOptions(e), this._startHealthCheck();
807
793
  }
808
794
  get attempts() {
@@ -846,31 +832,31 @@ class vr extends ue {
846
832
  /**
847
833
  * ws代理器
848
834
  */
849
- o(this, "_ws", new mr({
835
+ s(this, "_ws", new mr({
850
836
  url: "",
851
837
  robustOptions: { should1000Reconnect: !0, ignoreConnectivityEvents: !0 }
852
838
  }));
853
839
  /**
854
840
  * 带看连接状态
855
841
  */
856
- o(this, "_state", x.NOTINITIALIZED);
842
+ s(this, "_state", x.NOTINITIALIZED);
857
843
  /**
858
844
  * 添加事件监听
859
845
  */
860
- o(this, "_addWebSocketEventListeners", () => {
846
+ s(this, "_addWebSocketEventListeners", () => {
861
847
  this._ws.on("close", this._handleCloseEvent), this._ws.on("closing", this._handleClosingEvent), this._ws.on("connecting", this._handleConnectingEvent), this._ws.on("error", this._handleErrorEvent), this._ws.on("message", this._handleMessageEvent), this._ws.on("open", this._handleOpenEvent), this._ws.on("timeout", this._handleTimeoutEvent);
862
848
  });
863
849
  /**
864
850
  * 移除事件监听
865
851
  */
866
- o(this, "_removeWebSocketEventListeners", () => {
852
+ s(this, "_removeWebSocketEventListeners", () => {
867
853
  this._ws.off("close", this._handleCloseEvent), this._ws.off("closing", this._handleClosingEvent), this._ws.off("connecting", this._handleConnectingEvent), this._ws.off("error", this._handleErrorEvent), this._ws.off("message", this._handleMessageEvent), this._ws.off("open", this._handleOpenEvent), this._ws.off("timeout", this._handleTimeoutEvent);
868
854
  });
869
855
  /**
870
856
  * 处理房间关闭事件
871
857
  * @param event
872
858
  */
873
- o(this, "_handleCloseEvent", (e) => {
859
+ s(this, "_handleCloseEvent", (e) => {
874
860
  O.info(
875
861
  `live room closed bacause of ${e.code}-${e.reason || nr(e.code)}`
876
862
  ), this.state = x.CLOSED;
@@ -878,7 +864,7 @@ class vr extends ue {
878
864
  /**
879
865
  * 处理房间正在关闭事件(这个时候可能是断网了)
880
866
  */
881
- o(this, "_handleClosingEvent", () => {
867
+ s(this, "_handleClosingEvent", () => {
882
868
  var e;
883
869
  O.info("live room is closing, onLine:", (e = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : e.onLine), this.state = x.CLOSED;
884
870
  });
@@ -886,21 +872,21 @@ class vr extends ue {
886
872
  * 连接中
887
873
  * @param event
888
874
  */
889
- o(this, "_handleConnectingEvent", () => {
875
+ s(this, "_handleConnectingEvent", () => {
890
876
  O.info("live room is connecting"), this.state = x.CONNECTING;
891
877
  });
892
878
  /**
893
879
  * 连接发送异常
894
880
  * @param event
895
881
  */
896
- o(this, "_handleErrorEvent", (e) => {
882
+ s(this, "_handleErrorEvent", (e) => {
897
883
  O.error("live room error", e), this.state = x.CLOSED;
898
884
  });
899
885
  /**
900
886
  * 接收到消息
901
887
  * @param event
902
888
  */
903
- o(this, "_handleMessageEvent", (e) => {
889
+ s(this, "_handleMessageEvent", (e) => {
904
890
  let i = (() => {
905
891
  try {
906
892
  return JSON.parse(e.data);
@@ -914,33 +900,33 @@ class vr extends ue {
914
900
  * 连接建立成功
915
901
  * @param event
916
902
  */
917
- o(this, "_handleOpenEvent", (e) => {
903
+ s(this, "_handleOpenEvent", (e) => {
918
904
  O.info("live room open", e.detail), this.state = x.OPEN, e.detail.reconnects > 0 && this.emit("reconnected", e.detail);
919
905
  });
920
906
  /**
921
907
  * 处理超时
922
908
  * @param event
923
909
  */
924
- o(this, "_handleTimeoutEvent", (e) => {
910
+ s(this, "_handleTimeoutEvent", (e) => {
925
911
  O.error("live room connect timeout!", e.detail), this.state = x.CLOSED;
926
912
  });
927
913
  /**
928
914
  * 释放资源,释放之后需要重新实例化
929
915
  * @returns
930
916
  */
931
- o(this, "dispose", async () => (this._removeWebSocketEventListeners(), await this.close("live room close by controller disposed!")));
917
+ s(this, "dispose", async () => (this._removeWebSocketEventListeners(), await this.close("live room close by controller disposed!")));
932
918
  /**
933
919
  * 开启房间链接
934
920
  * @param url 房间链接
935
921
  * @returns
936
922
  */
937
- o(this, "open", (e) => this._ws.open(e));
923
+ s(this, "open", (e) => this._ws.open(e));
938
924
  /**
939
925
  * 关闭房间
940
926
  * @param code
941
927
  * @param reason
942
928
  */
943
- o(this, "close", (e, i) => new Promise((n) => {
929
+ s(this, "close", (e, i) => new Promise((n) => {
944
930
  this._ws.once("close", () => n(!0)), this._ws.close(e, i);
945
931
  }));
946
932
  this._addWebSocketEventListeners();
@@ -963,17 +949,23 @@ class vr extends ue {
963
949
  return this._ws.send(JSON.stringify(e));
964
950
  throw new Error("live has not yet been initialized!");
965
951
  }
952
+ /**
953
+ * 准备关闭带看
954
+ */
955
+ readyClose() {
956
+ this._ws && (this._ws._explicitlyClosed = !0);
957
+ }
966
958
  }
967
- const pr = (r) => Promise.reject("unimplemented method GetVoiceSign"), je = (r, s = {}, e = []) => ({
959
+ const pr = (r) => Promise.reject("unimplemented method GetVoiceSign"), je = (r, o = {}, e = []) => ({
968
960
  command: r,
969
961
  front_request_id: Ee(),
970
962
  data: {
971
- ...s,
963
+ ...o,
972
964
  to_user_ids: Array.isArray(e) ? e : [e]
973
965
  }
974
966
  }), Er = () => {
975
- var r, s;
976
- window != null && window.__Realsee_Live__ && ((s = (r = window == null ? void 0 : window.__Realsee_Live__) == null ? void 0 : r.dispose) == null || s.call(r), window.__Realsee_Live__ = null);
967
+ var r, o;
968
+ window != null && window.__Realsee_Live__ && ((o = (r = window == null ? void 0 : window.__Realsee_Live__) == null ? void 0 : r.dispose) == null || o.call(r), window.__Realsee_Live__ = null);
977
969
  };
978
970
  class yr extends ue {
979
971
  constructor(e) {
@@ -982,15 +974,15 @@ class yr extends ue {
982
974
  /**
983
975
  * 带看的配置
984
976
  */
985
- o(this, "_options", {});
977
+ s(this, "_options", {});
986
978
  /**
987
979
  * 帧数据监听
988
980
  */
989
- o(this, "keyframes", new ue());
981
+ s(this, "keyframes", new ue());
990
982
  /**
991
983
  * 内置的一些数据
992
984
  */
993
- o(this, "_buildInData", {
985
+ s(this, "_buildInData", {
994
986
  keyframes: {}
995
987
  });
996
988
  /**
@@ -998,14 +990,14 @@ class yr extends ue {
998
990
  * @param key 帧数据的键值
999
991
  * @returns
1000
992
  */
1001
- o(this, "getFramesByKey", (e) => this.snapshot[e]);
993
+ s(this, "getFramesByKey", (e) => this.snapshot[e]);
1002
994
  /**
1003
995
  * 发送帧数据(需要能够被序列化)
1004
996
  * @param key 帧数据键值
1005
997
  * @param frame 帧数据本体
1006
998
  * @returns
1007
999
  */
1008
- o(this, "sendKeyframe", (e, i) => {
1000
+ s(this, "sendKeyframe", (e, i) => {
1009
1001
  if (this.state !== x.OPEN)
1010
1002
  return !1;
1011
1003
  this._buildInData.keyframes = {
@@ -1022,17 +1014,17 @@ class yr extends ue {
1022
1014
  /**
1023
1015
  * 带看控制器
1024
1016
  */
1025
- o(this, "_controller", new vr());
1017
+ s(this, "_controller", new vr());
1026
1018
  /**
1027
1019
  * 添加带看控制的事件监听
1028
1020
  */
1029
- o(this, "_addLiveControllerEventListeners", () => {
1021
+ s(this, "_addLiveControllerEventListeners", () => {
1030
1022
  this._controller.on("stateChange", this._handleStateChange), this._controller.on("message", this._handleMessage);
1031
1023
  });
1032
1024
  /**
1033
1025
  * 移除带看控制的事件监听
1034
1026
  */
1035
- o(this, "_removeLiveControllerEventListeners", () => {
1027
+ s(this, "_removeLiveControllerEventListeners", () => {
1036
1028
  this._controller.off("stateChange", this._handleStateChange), this._controller.off("message", this._handleMessage);
1037
1029
  });
1038
1030
  /**
@@ -1040,12 +1032,12 @@ class yr extends ue {
1040
1032
  * @param state
1041
1033
  * @returns
1042
1034
  */
1043
- o(this, "_handleStateChange", (e, i) => this.emit("stateChange", e, i));
1035
+ s(this, "_handleStateChange", (e, i) => this.emit("stateChange", e, i));
1044
1036
  /**
1045
1037
  * 消息接收
1046
1038
  * @param liveMsg
1047
1039
  */
1048
- o(this, "_handleMessage", async (e) => {
1040
+ s(this, "_handleMessage", async (e) => {
1049
1041
  var i, n, c, u, d;
1050
1042
  if (typeof e == "object") {
1051
1043
  const { command: g, data: v = {}, frontRequestId: E, code: y, message: I } = e;
@@ -1053,19 +1045,12 @@ class yr extends ue {
1053
1045
  switch (g) {
1054
1046
  case K.SelfUserInfo: {
1055
1047
  const _ = v;
1056
- ot(this.selfInfo, _, { deep: !0 }) || (this._buildInData.selfInfo = _, this.emit(
1057
- "selfInfoUpdate",
1058
- this._buildInData.selfInfo,
1059
- E
1060
- ));
1048
+ ot(this.selfInfo, _, { deep: !0 }) || (this._buildInData.selfInfo = _, this.emit("selfInfoUpdate", this._buildInData.selfInfo, E));
1061
1049
  break;
1062
1050
  }
1063
1051
  case K.RoomInfo: {
1064
1052
  const _ = v;
1065
- this._buildInData.roomInfo = Object.assign({}, _), this.emit(
1066
- "readyKeyframeSync",
1067
- _.last_frame || {}
1068
- );
1053
+ this._buildInData.roomInfo = Object.assign({}, _), this.emit("readyKeyframeSync", _.last_frame || {});
1069
1054
  break;
1070
1055
  }
1071
1056
  case K.RTCInfo: {
@@ -1095,23 +1080,13 @@ class yr extends ue {
1095
1080
  break;
1096
1081
  }
1097
1082
  case K.KeyframeSync: {
1098
- const _ = v, V = Object.keys(
1099
- _
1100
- ).reduce(
1083
+ const _ = v, V = Object.keys(_).reduce(
1101
1084
  (C, k) => {
1102
- if (ot(
1103
- _[k],
1104
- this._buildInData.keyframes[k],
1105
- {
1106
- deep: !0
1107
- }
1108
- ))
1085
+ if (ot(_[k], this._buildInData.keyframes[k], {
1086
+ deep: !0
1087
+ }))
1109
1088
  return C;
1110
- const U = [
1111
- _[k],
1112
- this._buildInData.keyframes[k],
1113
- E
1114
- ], P = k;
1089
+ const U = [_[k], this._buildInData.keyframes[k], E], P = k;
1115
1090
  return this.keyframes.emit(
1116
1091
  P,
1117
1092
  ...U
@@ -1124,9 +1099,7 @@ class yr extends ue {
1124
1099
  }
1125
1100
  case K.BuiltinMsg: {
1126
1101
  const _ = v;
1127
- this.emit("builtinEvent", _), _.event_type === q.UserChange && this.emit("userChange", _), _.event_type === q.RoomChange && this.emit("roomChange", _), _.event_type === q.UserChange && _.action === H.UserMicroStatus && await this.toggleMicro(
1128
- _.data.status === Z.OPEN
1129
- ), _.event_type === q.RoomChange && _.action === H.RoomClose && await this.exit();
1102
+ this.emit("builtinEvent", _), _.event_type === q.UserChange && this.emit("userChange", _), _.event_type === q.RoomChange && this.emit("roomChange", _), _.event_type === q.UserChange && _.action === H.UserMicroStatus && await this.toggleMicro(_.data.status === Z.OPEN), _.event_type === q.RoomChange && _.action === H.RoomClose && await this._exit();
1130
1103
  break;
1131
1104
  }
1132
1105
  case K.UserKickOut: {
@@ -1143,7 +1116,7 @@ class yr extends ue {
1143
1116
  /**
1144
1117
  * 清理带看缓存的数据
1145
1118
  */
1146
- o(this, "_clearLiveData", () => {
1119
+ s(this, "_clearLiveData", () => {
1147
1120
  this._buildInData = { keyframes: {} };
1148
1121
  });
1149
1122
  /**
@@ -1151,7 +1124,7 @@ class yr extends ue {
1151
1124
  * @param options
1152
1125
  * @returns
1153
1126
  */
1154
- o(this, "connect", async (e = {}) => {
1127
+ s(this, "connect", async (e = {}) => {
1155
1128
  var u, d, g, v;
1156
1129
  if (this._options.url = (d = (u = e.url) != null ? u : this._options.url) != null ? d : "", this._options.getTicket = (g = e.getTicket) != null ? g : this._options.getTicket, this._options.initialMicroStatus = (v = e.rtcMicStatus) != null ? v : this._options.initialMicroStatus, !/^ws(s):\/\//.test(this._options.url) || typeof this._options.getTicket != "function")
1157
1130
  return /^ws(s):\/\//.test(this._options.url) ? typeof this._options.getTicket != "function" ? new Error("getTicket muse be function") : !1 : new Error("Illegal realsee live room link");
@@ -1179,45 +1152,50 @@ class yr extends ue {
1179
1152
  * 退出带看
1180
1153
  * @returns
1181
1154
  */
1182
- o(this, "exit", async () => {
1155
+ s(this, "_exit", async () => {
1183
1156
  var e;
1184
- if (this._clearLiveData(), this.state !== x.OPEN)
1185
- return !0;
1157
+ this._clearLiveData();
1186
1158
  try {
1187
1159
  await ((e = this.$RTC) == null ? void 0 : e.quit());
1188
1160
  } catch (i) {
1189
1161
  O.warn(i);
1190
1162
  }
1191
- return await this._controller.close();
1163
+ return this.state !== x.OPEN ? !0 : await this._controller.close();
1192
1164
  });
1165
+ /**
1166
+ * 退出带看
1167
+ * @returns
1168
+ */
1169
+ s(this, "exit", async () => this.close());
1193
1170
  /**
1194
1171
  * 关闭带看房间
1195
1172
  * @param code
1196
1173
  * @param reason
1197
1174
  * @returns
1198
1175
  */
1199
- o(this, "close", async () => await this.updateStatus(
1200
- q.RoomChange,
1201
- H.RoomClose,
1202
- {}
1203
- ));
1176
+ s(this, "close", async () => {
1177
+ var e;
1178
+ await this._controller.readyClose();
1179
+ try {
1180
+ await ((e = this.$RTC) == null ? void 0 : e.quit());
1181
+ } catch (i) {
1182
+ O.warn(i);
1183
+ }
1184
+ await this.updateStatus(q.RoomChange, H.RoomClose, {});
1185
+ });
1204
1186
  /**
1205
1187
  * 销毁带看
1206
1188
  * @returns
1207
1189
  */
1208
- o(this, "dispose", async () => (this._removeLiveControllerEventListeners(), this._clearLiveData(), await this._controller.dispose()));
1190
+ s(this, "dispose", async () => (this._removeLiveControllerEventListeners(), this._clearLiveData(), await this._controller.dispose()));
1209
1191
  /**
1210
1192
  * 设置自己的用户信息
1211
1193
  * @param userInfo
1212
1194
  * @returns
1213
1195
  */
1214
- o(this, "setSelfInfo", async (e) => await this.updateStatus(
1215
- q.UserChange,
1216
- H.UserInfo,
1217
- e
1218
- ));
1196
+ s(this, "setSelfInfo", async (e) => await this.updateStatus(q.UserChange, H.UserInfo, e));
1219
1197
  // 仅用于用户自己的麦克风控制
1220
- o(this, "toggleMicro", async (e) => {
1198
+ s(this, "toggleMicro", async (e) => {
1221
1199
  var n, c, u;
1222
1200
  if (!((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_own_micro))
1223
1201
  return !1;
@@ -1237,7 +1215,7 @@ class yr extends ue {
1237
1215
  * @param toUserIds
1238
1216
  * @returns
1239
1217
  */
1240
- o(this, "forbidMicro", async (e, i) => {
1218
+ s(this, "forbidMicro", async (e, i) => {
1241
1219
  var n, c;
1242
1220
  return typeof this._options.canForbidUserMicro == "function" && !this._options.canForbidUserMicro(i) || !((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_other_micro) ? !1 : await this.updateStatus(
1243
1221
  q.UserChange,
@@ -1254,7 +1232,7 @@ class yr extends ue {
1254
1232
  * @param toUserIds
1255
1233
  * @returns
1256
1234
  */
1257
- o(this, "forbidSync", async (e, i) => {
1235
+ s(this, "forbidSync", async (e, i) => {
1258
1236
  var n, c;
1259
1237
  return typeof this._options.canForbidUserSync == "function" && !this._options.canForbidUserSync(i) || !((c = (n = this.selfInfo) == null ? void 0 : n.permission) != null && c.control_other_sync) ? !1 : await this.updateStatus(
1260
1238
  q.UserChange,
@@ -1268,7 +1246,7 @@ class yr extends ue {
1268
1246
  * @param toUserIds
1269
1247
  * @returns
1270
1248
  */
1271
- o(this, "kick", async (e) => {
1249
+ s(this, "kick", async (e) => {
1272
1250
  var i, n;
1273
1251
  return typeof this._options.canForbidUserKick == "function" && !this._options.canForbidUserKick(e) || !((n = (i = this.selfInfo) == null ? void 0 : i.permission) != null && n.change_other_status) ? !1 : await this.updateStatus(
1274
1252
  q.UserChange,
@@ -1279,10 +1257,7 @@ class yr extends ue {
1279
1257
  e
1280
1258
  );
1281
1259
  });
1282
- this._addLiveControllerEventListeners(), this._options = Object.assign(
1283
- { initialMicroStatus: Z.OPEN },
1284
- e
1285
- ), this._options.jsBridge = (() => {
1260
+ this._addLiveControllerEventListeners(), this._options = Object.assign({ initialMicroStatus: Z.OPEN }, e), this._options.jsBridge = (() => {
1286
1261
  if (e.jsBridge)
1287
1262
  return e.jsBridge;
1288
1263
  if (e.useBuiltInJsBridge)
@@ -1291,18 +1266,14 @@ class yr extends ue {
1291
1266
  if (e.rtc)
1292
1267
  return e.rtc;
1293
1268
  if (e.rtcType)
1294
- switch (e.getVoiceSign || O.error(
1295
- "GetVoiceSign method must be passed when using built-in RTC instances"
1296
- ), e.rtcType) {
1269
+ switch (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), e.rtcType) {
1297
1270
  case Q.RealseeVRWebViewRTC: {
1298
1271
  if (this._options.jsBridge)
1299
1272
  return new nt({
1300
1273
  jsBridge: this._options.jsBridge,
1301
1274
  getVoiceSign: this._options.getVoiceSign
1302
1275
  });
1303
- O.error(
1304
- "JsBridge instance must be passed when using built-in VRWebViewRTC instances"
1305
- );
1276
+ O.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");
1306
1277
  return;
1307
1278
  }
1308
1279
  case Q.RealseeBrowserChimeRTC:
@@ -1311,9 +1282,7 @@ class yr extends ue {
1311
1282
  logLevel: e.__debug__ ? st.DEBUG : st.INFO
1312
1283
  });
1313
1284
  case Q.RealseeBrowserRTC:
1314
- return this._options.autoPlayConfirm || O.error(
1315
- "autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"
1316
- ), new rt({
1285
+ return this._options.autoPlayConfirm || O.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"), new rt({
1317
1286
  getVoiceSign: this._options.getVoiceSign,
1318
1287
  autoPlayConfirm: this._options.autoPlayConfirm
1319
1288
  });
@@ -1323,9 +1292,7 @@ class yr extends ue {
1323
1292
  }
1324
1293
  }
1325
1294
  if (e.useBuiltInRTC) {
1326
- if (e.getVoiceSign || O.error(
1327
- "GetVoiceSign method must be passed when using built-in RTC instances"
1328
- ), this._options.jsBridge)
1295
+ if (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), this._options.jsBridge)
1329
1296
  return lr && (ar || cr) || ur ? new nt({
1330
1297
  jsBridge: this._options.jsBridge,
1331
1298
  getVoiceSign: this._options.getVoiceSign
@@ -1335,9 +1302,7 @@ class yr extends ue {
1335
1302
  getVoiceSign: this._options.getVoiceSign,
1336
1303
  autoPlayConfirm: this._options.autoPlayConfirm
1337
1304
  });
1338
- O.error(
1339
- "jsBridge instance must be passed when using built-in RTC instances"
1340
- );
1305
+ O.error("jsBridge instance must be passed when using built-in RTC instances");
1341
1306
  return;
1342
1307
  }
1343
1308
  })(), this._options.rtc || O.warn("unused rtc"), this._options.url && this._options.getTicket && this.connect(), this._options.__debug__ && Object.assign(window, { $liveController: this._controller, $live: this });
@@ -1412,10 +1377,7 @@ class yr extends ue {
1412
1377
  async updateStatus(e, i, n, c) {
1413
1378
  if (this.state !== x.OPEN)
1414
1379
  return !1;
1415
- const u = Object.assign(
1416
- { event_type: e, action: i },
1417
- { data: n }
1418
- ), d = je(K.BuiltinMsg, u, c);
1380
+ const u = Object.assign({ event_type: e, action: i }, { data: n }), d = je(K.BuiltinMsg, u, c);
1419
1381
  try {
1420
1382
  return this._controller.sendMessage(d), !0;
1421
1383
  } catch (g) {
@@ -1431,11 +1393,7 @@ class yr extends ue {
1431
1393
  */
1432
1394
  broadcast(e, i, n) {
1433
1395
  return this.state !== x.OPEN ? !1 : new Promise((c, u) => {
1434
- const d = je(
1435
- K.CustomEvent,
1436
- e,
1437
- i
1438
- ), g = d.front_request_id, v = n ? setTimeout(() => {
1396
+ const d = je(K.CustomEvent, e, i), g = d.front_request_id, v = n ? setTimeout(() => {
1439
1397
  u(new Error("RESPONSE TIMEOUT")), this.off("broadcast", E);
1440
1398
  }, n) : void 0, E = (y, I) => {
1441
1399
  I === g && (v && clearTimeout(v), this.off("broadcast", E), c(y));
@@ -1472,7 +1430,7 @@ function Cr() {
1472
1430
  if (at)
1473
1431
  return oe;
1474
1432
  at = 1;
1475
- var r = D, s = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, n = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
1433
+ var r = D, o = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, n = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
1476
1434
  function u(d, g, v) {
1477
1435
  var E, y = {}, I = null, _ = null;
1478
1436
  v !== void 0 && (I = "" + v), g.key !== void 0 && (I = "" + g.key), g.ref !== void 0 && (_ = g.ref);
@@ -1481,7 +1439,7 @@ function Cr() {
1481
1439
  if (d && d.defaultProps)
1482
1440
  for (E in g = d.defaultProps, g)
1483
1441
  y[E] === void 0 && (y[E] = g[E]);
1484
- return { $$typeof: s, type: d, key: I, ref: _, props: y, _owner: n.current };
1442
+ return { $$typeof: o, type: d, key: I, ref: _, props: y, _owner: n.current };
1485
1443
  }
1486
1444
  return oe.Fragment = e, oe.jsx = u, oe.jsxs = u, oe;
1487
1445
  }
@@ -1498,7 +1456,7 @@ var ae = {};
1498
1456
  var ct;
1499
1457
  function wr() {
1500
1458
  return ct || (ct = 1, process.env.NODE_ENV !== "production" && function() {
1501
- var r = D, s = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), d = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), V = Symbol.iterator, C = "@@iterator";
1459
+ var r = D, o = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), d = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), V = Symbol.iterator, C = "@@iterator";
1502
1460
  function k(t) {
1503
1461
  if (t === null || typeof t != "object")
1504
1462
  return null;
@@ -1880,7 +1838,7 @@ function wr() {
1880
1838
  var It = function(t, a, l, h, b, R, p) {
1881
1839
  var m = {
1882
1840
  // This tag allows us to uniquely identify this as a React Element
1883
- $$typeof: s,
1841
+ $$typeof: o,
1884
1842
  // Built-in properties that belong on the element
1885
1843
  type: t,
1886
1844
  key: a,
@@ -1935,7 +1893,7 @@ function wr() {
1935
1893
  var ke;
1936
1894
  ke = !1;
1937
1895
  function Pe(t) {
1938
- return typeof t == "object" && t !== null && t.$$typeof === s;
1896
+ return typeof t == "object" && t !== null && t.$$typeof === o;
1939
1897
  }
1940
1898
  function Je() {
1941
1899
  {
@@ -2051,7 +2009,7 @@ Check the top-level render call using <` + l + ">.");
2051
2009
  var $ = kt(b);
2052
2010
  $ ? m += $ : m += Je();
2053
2011
  var j;
2054
- t === null ? j = "null" : Oe(t) ? j = "array" : t !== void 0 && t.$$typeof === s ? (j = "<" + (G(t.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : j = typeof t, P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, m);
2012
+ t === null ? j = "null" : Oe(t) ? j = "array" : t !== void 0 && t.$$typeof === o ? (j = "<" + (G(t.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : j = typeof t, P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, m);
2055
2013
  }
2056
2014
  var L = Tt(t, a, l, b, R);
2057
2015
  if (L == null)
@@ -2087,8 +2045,8 @@ Check the top-level render call using <` + l + ">.");
2087
2045
  })(Sr);
2088
2046
  const Rr = Ae.jsx;
2089
2047
  function jr(r) {
2090
- const s = Gt(null), e = br(r), i = e.jsBridge, n = (f) => /* @__PURE__ */ Rr(s.Provider, { value: e, children: f.children }), c = () => {
2091
- const f = D.useContext(s);
2048
+ const o = Gt(null), e = br(r), i = e.jsBridge, n = (f) => /* @__PURE__ */ Rr(o.Provider, { value: e, children: f.children }), c = () => {
2049
+ const f = D.useContext(o);
2092
2050
  if (!f)
2093
2051
  throw new Error("LiveProvider never found.");
2094
2052
  return f;