@realsee/live 0.6.15 → 0.7.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.
Files changed (167) hide show
  1. package/README.md +50 -55
  2. package/dist/index.cjs.js +38 -24
  3. package/dist/index.d.cts +1336 -0
  4. package/dist/index.d.ts +1336 -5
  5. package/dist/index.esm.js +10 -0
  6. package/docs/README.md +435 -0
  7. package/docs/classes/BrowserRTC.md +436 -0
  8. package/docs/classes/BrowserRTC4Chime.md +558 -0
  9. package/docs/classes/CoreRTC.md +448 -0
  10. package/docs/classes/Live.md +797 -0
  11. package/docs/classes/Subscribe.md +211 -0
  12. package/docs/classes/VRWebViewRTC.md +436 -0
  13. package/docs/enumerations/BuiltInRTCType.md +27 -0
  14. package/docs/enumerations/BuiltinActionType.md +81 -0
  15. package/docs/enumerations/BuiltinEventType.md +33 -0
  16. package/docs/enumerations/Command.md +107 -0
  17. package/docs/enumerations/LiveState.md +53 -0
  18. package/docs/enumerations/MemUserStatus.md +67 -0
  19. package/docs/enumerations/MicroStatus.md +33 -0
  20. package/docs/enumerations/RTCJoinedInfoCodeEnum.md +69 -0
  21. package/docs/enumerations/RTCType.md +39 -0
  22. package/docs/enumerations/UserStatus.md +45 -0
  23. package/docs/enumerations/WebSocketCloseError.md +117 -0
  24. package/docs/enumerations/WebSocketErrorType.md +77 -0
  25. package/docs/enumerations/WebSocketState.md +69 -0
  26. package/docs/functions/GetVoiceSignFn.md +27 -0
  27. package/docs/functions/clearLiveInstanceIfNeed.md +17 -0
  28. package/docs/functions/createLive.md +27 -0
  29. package/docs/functions/createLiveReact.md +449 -0
  30. package/docs/functions/parseLiveMsg.md +27 -0
  31. package/docs/functions/parseWSClsErr.md +21 -0
  32. package/docs/globals.md +77 -0
  33. package/docs/interfaces/AttendeeResponse.md +37 -0
  34. package/docs/interfaces/LiveOptions.md +246 -0
  35. package/docs/interfaces/MeetingResponse.md +55 -0
  36. package/docs/interfaces/MeetingSessionConfigurationOptions.md +93 -0
  37. package/docs/interfaces/Permission.md +147 -0
  38. package/docs/interfaces/RTCJoinedInfo.md +67 -0
  39. package/docs/interfaces/RTCProtocol.md +404 -0
  40. package/docs/interfaces/VRWebViewRTCOptions.md +41 -0
  41. package/docs/namespaces/SubscribeMixinType/README.md +17 -0
  42. package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +31 -0
  43. package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +25 -0
  44. package/docs/namespaces/SubscribeMixinType/interfaces/off.md +31 -0
  45. package/docs/namespaces/SubscribeMixinType/interfaces/on.md +37 -0
  46. package/docs/namespaces/SubscribeMixinType/interfaces/once.md +35 -0
  47. package/docs/type-aliases/BuiltinMsg.md +41 -0
  48. package/docs/type-aliases/EventMap.md +17 -0
  49. package/docs/type-aliases/EventType.md +19 -0
  50. package/docs/type-aliases/GetVoiceSign.md +15 -0
  51. package/docs/type-aliases/GetVoiceSignParams.md +35 -0
  52. package/docs/type-aliases/GetVoiceSignReturnType.md +41 -0
  53. package/docs/type-aliases/KeyframeEventType.md +19 -0
  54. package/docs/type-aliases/LiveBuiltInData.md +47 -0
  55. package/docs/type-aliases/LiveConnectOptions.md +47 -0
  56. package/docs/type-aliases/LiveEventType.md +165 -0
  57. package/docs/type-aliases/LiveMsg.md +53 -0
  58. package/docs/type-aliases/LiveProviderPropTypes.md +27 -0
  59. package/docs/type-aliases/RTCActionReactCallback.md +13 -0
  60. package/docs/type-aliases/RTCEventType.md +65 -0
  61. package/docs/type-aliases/ReqLiveMsg.md +45 -0
  62. package/docs/type-aliases/RoomInfo.md +55 -0
  63. package/docs/type-aliases/UserInfo.md +77 -0
  64. package/docs/type-aliases/UserInfoExt.md +33 -0
  65. package/docs/type-aliases/UserVolume.md +25 -0
  66. package/docs/type-aliases/WebSocketError.md +31 -0
  67. package/package.json +39 -32
  68. package/dist/index.cjs.js.map +0 -1
  69. package/dist/index.es.js +0 -2328
  70. package/dist/index.es.js.map +0 -1
  71. package/dist/live/controller.d.ts +0 -118
  72. package/dist/live/createLive.d.ts +0 -8
  73. package/dist/live/createLiveReact.d.ts +0 -52
  74. package/dist/live/live.d.ts +0 -182
  75. package/dist/rtc/BrowserRTC.d.ts +0 -39
  76. package/dist/rtc/BrowserRTC4Chime.d.ts +0 -60
  77. package/dist/rtc/CoreRTC.d.ts +0 -23
  78. package/dist/rtc/VRWebViewRTC.d.ts +0 -97
  79. package/dist/rtc/index.d.ts +0 -5
  80. package/dist/typings/chime/AttendeeResponse.d.ts +0 -5
  81. package/dist/typings/chime/MeetingResponse.d.ts +0 -12
  82. package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +0 -16
  83. package/dist/typings/chime/index.d.ts +0 -3
  84. package/dist/typings/index.d.ts +0 -4
  85. package/dist/typings/live/EventType.d.ts +0 -74
  86. package/dist/typings/live/GetVoiceSign.d.ts +0 -45
  87. package/dist/typings/live/LiveConnectOptions.d.ts +0 -24
  88. package/dist/typings/live/LiveMsg.d.ts +0 -133
  89. package/dist/typings/live/LiveOptions.d.ts +0 -79
  90. package/dist/typings/live/LiveState.d.ts +0 -15
  91. package/dist/typings/live/RoomInfo.d.ts +0 -13
  92. package/dist/typings/live/UserInfo.d.ts +0 -103
  93. package/dist/typings/live/UserVolume.d.ts +0 -7
  94. package/dist/typings/live/WebSocket.d.ts +0 -82
  95. package/dist/typings/live/index.d.ts +0 -10
  96. package/dist/typings/react/RTCActionReactCallback.d.ts +0 -2
  97. package/dist/typings/react/index.d.ts +0 -1
  98. package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +0 -6
  99. package/dist/typings/rtc/eventType.d.ts +0 -44
  100. package/dist/typings/rtc/index.d.ts +0 -5
  101. package/dist/typings/rtc/joinedInfo.d.ts +0 -38
  102. package/dist/typings/rtc/protocol.d.ts +0 -62
  103. package/dist/typings/rtc/type.d.ts +0 -12
  104. package/dist/utils/RobustWebSocket.d.ts +0 -160
  105. package/dist/utils/appendUri.d.ts +0 -1
  106. package/dist/utils/clientDetector.d.ts +0 -4
  107. package/dist/utils/equal.d.ts +0 -10
  108. package/dist/utils/logger.d.ts +0 -16
  109. package/dist/utils/subscribe.d.ts +0 -75
  110. package/dist/utils/uuid.d.ts +0 -4
  111. package/docs/.nojekyll +0 -1
  112. package/docs/assets/highlight.css +0 -120
  113. package/docs/assets/main.js +0 -58
  114. package/docs/assets/search.js +0 -1
  115. package/docs/assets/style.css +0 -1280
  116. package/docs/classes/BrowserRTC.html +0 -561
  117. package/docs/classes/BrowserRTC4Chime.html +0 -602
  118. package/docs/classes/CoreRTC.html +0 -432
  119. package/docs/classes/Live.html +0 -812
  120. package/docs/classes/VRWebViewRTC.html +0 -639
  121. package/docs/enums/BuiltInRTCType.html +0 -69
  122. package/docs/enums/BuiltinActionType.html +0 -112
  123. package/docs/enums/BuiltinEventType.html +0 -76
  124. package/docs/enums/Command.html +0 -134
  125. package/docs/enums/LiveState.html +0 -89
  126. package/docs/enums/MemUserStatus.html +0 -97
  127. package/docs/enums/MicroStatus.html +0 -76
  128. package/docs/enums/RTCJoinedInfoCodeEnum.html +0 -103
  129. package/docs/enums/RTCType.html +0 -79
  130. package/docs/enums/UserStatus.html +0 -85
  131. package/docs/enums/WebSocketCloseError.html +0 -139
  132. package/docs/enums/WebSocketErrorType.html +0 -104
  133. package/docs/enums/WebSocketState.html +0 -103
  134. package/docs/functions/_clearLiveInstanceIfNeed.html +0 -98
  135. package/docs/functions/createLive.html +0 -111
  136. package/docs/functions/createLiveReact.html +0 -579
  137. package/docs/functions/parseLiveMsg.html +0 -109
  138. package/docs/functions/parseWSClsErr.html +0 -103
  139. package/docs/index.html +0 -474
  140. package/docs/interfaces/AttendeeResponse.html +0 -80
  141. package/docs/interfaces/LiveOptions.html +0 -272
  142. package/docs/interfaces/MeetingResponse.html +0 -90
  143. package/docs/interfaces/MeetingSessionConfigurationOptions.html +0 -119
  144. package/docs/interfaces/Permission.html +0 -157
  145. package/docs/interfaces/RTCJoinedInfo.html +0 -104
  146. package/docs/interfaces/RTCProtocol.html +0 -424
  147. package/docs/interfaces/VRWebViewRTCOptions.html +0 -73
  148. package/docs/modules.html +0 -156
  149. package/docs/types/BuiltinMsg.html +0 -112
  150. package/docs/types/EventType.html +0 -101
  151. package/docs/types/GetVoiceSign.html +0 -109
  152. package/docs/types/GetVoiceSignParams.html +0 -111
  153. package/docs/types/GetVoiceSignReturnType.html +0 -115
  154. package/docs/types/KeyframeTypes.html +0 -101
  155. package/docs/types/LiveBuiltInData.html +0 -117
  156. package/docs/types/LiveConnectOptions.html +0 -123
  157. package/docs/types/LiveEventType.html +0 -276
  158. package/docs/types/LiveMsg.html +0 -117
  159. package/docs/types/LiveProviderPropTypes.html +0 -106
  160. package/docs/types/RTCActionReactCallback.html +0 -94
  161. package/docs/types/RTCEventType.html +0 -210
  162. package/docs/types/ReqLiveMsg.html +0 -118
  163. package/docs/types/RoomInfo.html +0 -118
  164. package/docs/types/UserInfo.html +0 -139
  165. package/docs/types/UserInfoExt.html +0 -109
  166. package/docs/types/UserVolume.html +0 -103
  167. package/docs/types/WebSocketError.html +0 -105
package/dist/index.es.js DELETED
@@ -1,2328 +0,0 @@
1
- var Dt = Object.defineProperty;
2
- var $t = (r, o, e) => o in r ? Dt(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
- import xt from "@realsee/jsbridge-x";
5
- import je from "trtc-js-sdk";
6
- import { ConsoleLogger as Ut, LogLevel as Wt, DefaultDeviceController as Ft, MeetingSessionConfiguration as Bt, DefaultMeetingSession as Kt, DefaultModality as rt, MeetingSessionStatusCode as qt } from "amazon-chime-sdk-js";
7
- import M, { createContext as Gt } from "react";
8
- const ue = Symbol("$$REALSEE_LIVE_EVENT$$");
9
- function Ee(r) {
10
- return r[ue] || (r[ue] = {}), r[ue];
11
- }
12
- function Yt(r) {
13
- r[ue] || delete r[ue];
14
- }
15
- class le {
16
- /**
17
- * 判断是否注册了事件
18
- * @param name 事件类型
19
- */
20
- hasListener(o) {
21
- const e = Ee(this);
22
- return e && e[o] && e[o].length > 0;
23
- }
24
- /**
25
- * 注册事件
26
- * @param name 事件类型
27
- * @param callback 事件回调函数
28
- * @param once 是否只执行一次
29
- * @returns 解除事件
30
- * @template K 预设的监听事件名称
31
- * @template C 回调函数函数上下文
32
- */
33
- on(o, e, i) {
34
- const n = Ee(this);
35
- return n[o] || (n[o] = []), n[o].push([e, i || !1]), () => this.off(o, e);
36
- }
37
- /**
38
- * 注册事件(是否只执行一次)
39
- * @param name 事件类型
40
- * @param callback 事件回调函数
41
- * @returns 解除事件
42
- * @template K 预设的监听事件名称
43
- * @template C 回调函数函数上下文
44
- */
45
- once(o, e) {
46
- return this.on(o, e, !0);
47
- }
48
- /**
49
- * 解除事件
50
- *
51
- * 如果 name 不传的话解除对应所有事件
52
- * 如果 name, callback 不传的话解除所有name的所有事件
53
- * @param name 事件类型
54
- * @param callback 事件回调函数
55
- * @template K 预设的监听事件名称
56
- */
57
- off(o, e) {
58
- if (o === void 0) {
59
- Yt(this);
60
- return;
61
- }
62
- const i = Ee(this);
63
- if (i[o] || (i[o] = []), e === void 0) {
64
- i[o].length = 0;
65
- return;
66
- }
67
- let n = 0;
68
- for (; n < i[o].length && i[o][n][0] !== e; n++)
69
- ;
70
- n < i[o].length && i[o].splice(n, 1);
71
- }
72
- /**
73
- * 触发事件
74
- * @param name 事件类型
75
- * @param data 触发事件的数据
76
- * @returns canceled 是否被触发取消
77
- * @template K 预设的监听事件名称
78
- */
79
- emit(o, ...e) {
80
- let i = !1;
81
- const a = Ee(this)[o] || [];
82
- for (let u of a.slice()) {
83
- const [d, g = !1] = u, _ = d(...e);
84
- g && this.off(o, d), _ === !1 && (i = !0);
85
- }
86
- return i;
87
- }
88
- }
89
- class Me extends le {
90
- }
91
- var Q = /* @__PURE__ */ ((r) => (r.RealseeBrowserRTC = "RealseeBrowserRTC", r.RealseeVRWebViewRTC = "RealseeVRWebViewRTC", r.RealseeBrowserChimeRTC = "RealseeBrowserChimeRTC", r))(Q || {}), lt = /* @__PURE__ */ ((r) => (r.RealseeXTRTC = "trtc", r.RealseeXChimeRTC = "chime", r))(lt || {});
92
- const Jt = () => {
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"), a = r.getMinutes().toString().padStart(2, "0"), u = r.getSeconds().toString().padStart(2, "0"), d = r.getMilliseconds();
94
- return `[${o}-${e}-${i} ${n}:${a}:${u}.${d}]`;
95
- }, Se = (r, o = []) => {
96
- switch (o.unshift(`Realsee Live ${Jt()} <${r}> `), r) {
97
- case "INFO":
98
- return console.info(...o);
99
- case "ERROR":
100
- return console.error(...o);
101
- case "WARN":
102
- return console.warn(...o);
103
- default:
104
- return console.log(...o);
105
- }
106
- }, Ht = (...r) => Se("LOG", r), zt = (...r) => Se("INFO", r), Xt = (...r) => Se("ERROR", r), Zt = (...r) => Se("WARN", r), Qt = {
107
- log: Ht,
108
- info: zt,
109
- error: Xt,
110
- warn: Zt
111
- }, O = Qt;
112
- function X() {
113
- return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
114
- }
115
- function ye() {
116
- return (X() + X() + "-" + X() + "-4" + X().substr(0, 3) + "-" + X() + "-" + X() + X() + X()).toLowerCase();
117
- }
118
- class it extends Me {
119
- constructor(e) {
120
- super();
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
- throw new Error("方法 getVoiceSign 未实现");
127
- });
128
- s(this, "_autoPlayConfirm");
129
- s(this, "checkRequirement", () => je.checkSystemRequirements());
130
- s(this, "$dom", document.createElement("div"));
131
- s(this, "_trtc", {
132
- client: null,
133
- stream: null
134
- });
135
- s(this, "join", async (e) => {
136
- var a;
137
- this.emit("joinWillStart");
138
- const i = await this._getVoiceSign({
139
- voiceId: e.voiceId,
140
- roomId: e.roomId,
141
- userId: e.userId
142
- });
143
- this._trtc.client = je.createClient({
144
- mode: "rtc",
145
- ...i,
146
- enableAutoPlayDialog: typeof this._autoPlayConfirm != "function"
147
- }), (a = this._trtc.client) == null || a.enableAudioVolumeEvaluation(), this._registerRtcEvent();
148
- let n = await new Promise((u) => {
149
- var d;
150
- (d = this._trtc.client) == null || d.join({ roomId: Number(e.voiceId) }).then(() => u(!0)).catch(() => u(!1));
151
- });
152
- return this.joined = n, n ? (this._trtc.stream = je.createStream({
153
- userId: i.userId,
154
- audio: !0,
155
- video: !1
156
- }), n = await new Promise((u) => {
157
- var d;
158
- (d = this._trtc.stream) == null || d.initialize().then(() => u(!0)).catch(() => u(!1));
159
- }), n = await new Promise((u) => {
160
- var d;
161
- (d = this._trtc.client) == null || d.publish(this._trtc.stream).then(() => u(!0)).catch(() => u(!1));
162
- }), this.joined = n, this.joined && this.emit("joined"), n) : !1;
163
- });
164
- s(this, "_handleStreamAdded", (e) => {
165
- var n;
166
- const i = e.stream;
167
- console.log("远端流增加: " + i.getId()), (n = this._trtc.client) == null || n.subscribe(i);
168
- });
169
- s(this, "_handleStreamSubscribed", (e) => {
170
- const i = e.stream;
171
- console.log("远端流订阅成功:" + i.getId());
172
- const a = `rs-rtc-remote_stream-${i.getId()}`, u = document.createElement("div");
173
- u.id = a, this.$dom.appendChild(u), typeof this._autoPlayConfirm == "function" ? (i.play(a).catch((d) => {
174
- }), i.on("error", (d) => {
175
- if (d.getCode() === 16451) {
176
- const _ = () => i.resume();
177
- this._autoPlayConfirm({ onConfirm: _ });
178
- }
179
- })) : i.play(a);
180
- });
181
- this._getVoiceSign = e.getVoiceSign, this._autoPlayConfirm = e.autoPlayConfirm, this._initParentDom();
182
- }
183
- _initParentDom() {
184
- this.$dom.id = `rs-rtc-${ye()}`, this.$dom.style.display = "none", document.body.appendChild(this.$dom);
185
- }
186
- quit() {
187
- return new Promise(async (e) => {
188
- var i, n;
189
- this.joined = !1, this._trtc.stream && (await ((i = this._trtc.client) == null ? void 0 : i.unpublish(this._trtc.stream)), this._trtc.stream.stop(), this._trtc.stream.close(), this._trtc.stream = null), (n = this._trtc.client) == null || n.leave().then(() => this._trtc.client = null).then(() => e(!0)).catch(() => e(!1)), e(!0);
190
- });
191
- }
192
- detectMicro() {
193
- return new Promise((e) => {
194
- const i = { audio: !0, video: !1 };
195
- try {
196
- navigator.mediaDevices.getUserMedia(i).then(() => e(!0)).catch((n) => {
197
- O.error(n.message), e(!1);
198
- });
199
- } catch (n) {
200
- console.error(n), e(!1);
201
- }
202
- });
203
- }
204
- toggleMicro(e) {
205
- var i, n, a, u;
206
- return Promise.resolve(
207
- (e ? (n = (i = this._trtc) == null ? void 0 : i.stream) == null ? void 0 : n.unmuteAudio() : (u = (a = this._trtc) == null ? void 0 : a.stream) == null ? void 0 : u.muteAudio()) || !1
208
- );
209
- }
210
- shock() {
211
- throw new Error("Method not implemented.");
212
- }
213
- _registerRtcEvent() {
214
- var e, i, n, a;
215
- (e = this._trtc.client) == null || e.on("stream-added", this._handleStreamAdded), (i = this._trtc.client) == null || i.on("stream-subscribed", this._handleStreamSubscribed), (n = this._trtc.client) == null || n.on(
216
- "audio-volume",
217
- (u) => this.emit(
218
- "userVolumes",
219
- u.result.map(({ userId: d, audioVolume: g }) => ({
220
- userId: d,
221
- audioVolume: g
222
- }))
223
- )
224
- ), (a = this._trtc.client) == null || a.on("error", (u) => this.emit("error", u));
225
- }
226
- }
227
- class nt extends Me {
228
- constructor(e) {
229
- super();
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
- throw new Error("方法 getVoiceSign 未实现");
245
- });
246
- s(this, "_autoPlayConfirm");
247
- s(this, "$dom", document.createElement("div"));
248
- s(this, "$audio", document.createElement("audio"));
249
- /**
250
- * 对audio标签初始化
251
- */
252
- s(this, "_initDom", () => {
253
- this.$audio.id = `rs-rtc-${ye()}`, this.$dom.id = `rs-rtc-${ye()}`, this.$dom.appendChild(this.$audio), document.body.appendChild(this.$dom);
254
- });
255
- /**
256
- * 初始化事件监听器
257
- */
258
- s(this, "initObservers", () => {
259
- this.deviceChangeObserver = {
260
- audioInputsChanged: (e) => {
261
- this.logger.info(`audioInputsChanged ${typeof e}`), e == null || e.forEach((i) => {
262
- this.logger.info(`Device ID: ${i.deviceId} Microphone: ${i.label}`);
263
- });
264
- },
265
- audioOutputsChanged: (e) => {
266
- this.logger.info(`audioOutputsChanged ${typeof e}`), e == null || e.forEach((i) => {
267
- this.logger.info(`Device ID: ${i.deviceId} Speaker: ${i.label}`);
268
- });
269
- },
270
- // videoInputsChanged: (freshVideoInputDeviceList: any) => {
271
- // this.logger.info(`Video inputs updated: ${freshVideoInputDeviceList}`);
272
- // },
273
- audioInputMuteStateChanged: (e, i) => {
274
- this.logger.info(`Device ${e.toString()} ${i ? "is muted in hardware" : "is not muted"}`);
275
- }
276
- }, this.audioVideoObserver = {
277
- audioVideoDidStart: () => {
278
- this.logger.info("Started");
279
- },
280
- audioVideoDidStop: (e) => {
281
- this.logger.info(`Stopped with a session status code: ${e.statusCode()}`);
282
- },
283
- audioVideoDidStartConnecting: (e) => {
284
- e && this.logger.info("Attempting to reconnect");
285
- }
286
- }, this.audioMixObserver = {
287
- meetingAudioStreamBecameActive: (e) => {
288
- if (this.$audio.paused) {
289
- const i = () => this.$audio.play().then(() => {
290
- }).catch((n) => {
291
- if (O.error("播放远端流失败!", n), typeof this._autoPlayConfirm == "function") {
292
- const a = () => i();
293
- this._autoPlayConfirm({ onConfirm: a });
294
- }
295
- });
296
- i();
297
- }
298
- },
299
- meetingAudioStreamBecameInactive: (e) => {
300
- }
301
- };
302
- });
303
- /**
304
- * 注册rtc事件
305
- */
306
- s(this, "_registerRtcEvent", () => {
307
- var i, n, a, u, d, g;
308
- const e = ((a = (n = (i = this.meetingSession) == null ? void 0 : i.configuration) == null ? void 0 : n.credentials) == null ? void 0 : a.attendeeId) || "";
309
- if (e) {
310
- const _ = /* @__PURE__ */ new Map(), E = () => {
311
- const y = [];
312
- return _.forEach((I, m) => {
313
- y.push({
314
- userId: I.userId,
315
- volume: I.muted || I.signalStrength === 0 || !Boolean(I.volume) ? 0 : I.volume
316
- });
317
- }), y;
318
- };
319
- (u = this.meetingSession) == null || u.audioVideo.realtimeSubscribeToAttendeeIdPresence(
320
- (y, I, m) => {
321
- var D;
322
- if (!I) {
323
- _.delete(y), this.emit("userVolumes", E());
324
- return;
325
- }
326
- (D = this.meetingSession) == null || D.audioVideo.realtimeSubscribeToVolumeIndicator(
327
- y,
328
- (w, k, U, P) => {
329
- new rt(w).base() === w && (_.set(w, {
330
- userId: m || w,
331
- volume: k,
332
- muted: U,
333
- signalStrength: P
334
- }), this.emit("userVolumes", E()));
335
- }
336
- );
337
- }
338
- ), (d = this.meetingSession) == null || d.audioVideo.realtimeSubscribeToVolumeIndicator(
339
- e,
340
- (y, I, m, D) => {
341
- new rt(y).base() === y && D !== null && D !== 1 && this.emit("weakNetwork");
342
- }
343
- ), (g = this.meetingSession) == null || g.audioVideo.realtimeSubscribeToFatalError((y) => this.emit("error", y));
344
- }
345
- });
346
- this._getVoiceSign = e.getVoiceSign, this._autoPlayConfirm = e.autoPlayConfirm, this._initDom(), this.logger = new Ut("WebRTCLogger", e.logLevel || Wt.INFO), this.deviceController = new Ft(this.logger), this.initObservers();
347
- }
348
- /**
349
- * 加入语音会议
350
- * @param options
351
- * @returns
352
- */
353
- async join(e) {
354
- return new Promise(async (i, n) => {
355
- var a, u;
356
- this.emit("joinWillStart");
357
- try {
358
- const { sdkAppId: d, userId: g, roomId: _, userSig: E } = await this._getVoiceSign({
359
- ...e,
360
- roomId: e.roomId || 0
361
- });
362
- this.userId = g;
363
- const { attendence: y, vendor_wrapper: I } = JSON.parse(
364
- decodeURIComponent(E)
365
- ), m = new Bt(
366
- {
367
- Meeting: I
368
- },
369
- {
370
- Attendee: {
371
- ExternalUserId: y.external_user_id,
372
- AttendeeId: y.attendee_id,
373
- JoinToken: y.join_token
374
- }
375
- }
376
- );
377
- this.meetingSession = new Kt(m, this.logger, this.deviceController), this._registerRtcEvent(), this.meetingSession.audioVideo.addDeviceChangeObserver(this.deviceChangeObserver), this.meetingSession.audioVideo.addObserver(this.audioVideoObserver), this.meetingSession.audioVideo.bindAudioElement(this.$audio);
378
- const D = {
379
- audioVideoDidStart: () => {
380
- var w;
381
- (w = this.meetingSession) == null || w.audioVideo.realtimeMuteLocalAudio(), this.joined = !0, this.emit("joined"), i(!0);
382
- },
383
- audioVideoDidStop: () => {
384
- this.joined = !1, i(!1);
385
- }
386
- };
387
- this.meetingSession.audioVideo.addObserver(D), this.audioMixObserver && this.meetingSession.audioVideo.addAudioMixObserver(this.audioMixObserver), this.meetingSession.audioVideo.setDeviceLabelTrigger(
388
- async () => await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 })
389
- );
390
- try {
391
- const w = await this.meetingSession.audioVideo.listAudioInputDevices();
392
- O.info("audioInputDevices ===>", w);
393
- const k = ((a = w[0]) == null ? void 0 : a.deviceId) || "default";
394
- await this.meetingSession.audioVideo.startAudioInput(k);
395
- } catch (w) {
396
- O.error(`设置语音输入设备失败:${w.message}`);
397
- }
398
- try {
399
- const w = await this.meetingSession.audioVideo.listAudioOutputDevices();
400
- O.info("audioOutputDevices ===>", w);
401
- const k = ((u = w[0]) == null ? void 0 : u.deviceId) || "default";
402
- await this.meetingSession.audioVideo.chooseAudioOutput(k);
403
- } catch (w) {
404
- O.error(`设置语音输出设备失败:${w.message}`);
405
- }
406
- this.meetingSession.audioVideo.start();
407
- } catch (d) {
408
- this.emit("error", d), this.logger.error(d.message), i(!1);
409
- }
410
- });
411
- }
412
- quit() {
413
- return this.joined ? new Promise((e, i) => {
414
- var a, u;
415
- this.joined = !1;
416
- const n = {
417
- audioVideoDidStop: async (d) => {
418
- var _;
419
- const g = d.statusCode();
420
- (_ = this.meetingSession) == null || _.deviceController.destroy(), g === qt.Left ? (this.logger.info("You left the session"), e(!0)) : (this.logger.info(`Stopped with a session status code: ${g}`), e(!0));
421
- }
422
- };
423
- (a = this.meetingSession) == null || a.audioVideo.addObserver(n), (u = this.meetingSession) == null || u.audioVideo.stop();
424
- }) : Promise.resolve(!0);
425
- }
426
- async detectMicro() {
427
- return new Promise((e) => {
428
- const i = { audio: !0, video: !1 };
429
- try {
430
- navigator.mediaDevices.getUserMedia(i).then(() => e(!0)).catch(() => e(!1));
431
- } catch (n) {
432
- this.logger.error(n.message), e(!1);
433
- }
434
- });
435
- }
436
- async toggleMicro(e) {
437
- var n, a, u;
438
- e ? (n = this.meetingSession) == null || n.audioVideo.realtimeUnmuteLocalAudio() : (a = this.meetingSession) == null || a.audioVideo.realtimeMuteLocalAudio();
439
- const i = (u = this.meetingSession) == null ? void 0 : u.audioVideo.realtimeIsLocalAudioMuted();
440
- return i !== void 0 ? e !== i : !1;
441
- }
442
- shock() {
443
- throw new Error("Method not implemented.");
444
- }
445
- }
446
- var ne = /* @__PURE__ */ ((r) => (r[r.Success = 0] = "Success", r[r.Failure = 1] = "Failure", r[r.ReJoin = 2] = "ReJoin", r[r.NoMicroPermission = 3] = "NoMicroPermission", r[r.Unknown = 500] = "Unknown", r))(ne || {});
447
- class st extends Me {
448
- constructor({ jsBridge: e, getVoiceSign: i }) {
449
- super();
450
- s(this, "type", Q.RealseeVRWebViewRTC);
451
- s(this, "joined", !1);
452
- s(this, "micro", !1);
453
- s(this, "voiceId", "");
454
- /**
455
- * 保留加入房间参数,用于重连
456
- */
457
- s(this, "_joinOptions", null);
458
- s(this, "options");
459
- /**
460
- * 处理用户音量
461
- * @param userVolumes
462
- */
463
- s(this, "handleUserVolumes", (e) => {
464
- this.emit("userVolumes", e);
465
- });
466
- /**
467
- * 处理弱网络情况
468
- * @param weakNetwork
469
- */
470
- s(this, "handleWeakNetwork", (e) => {
471
- e && this.emit("weakNetwork");
472
- });
473
- /**
474
- * 加入语音房间
475
- * @param options
476
- * @returns
477
- */
478
- s(this, "join", async (e) => {
479
- this._joinOptions = e, this.emit("joinWillStart");
480
- const { sdkAppId: i, userId: n, userSig: a } = await this.getVoiceSignOrEmitError(
481
- e
482
- );
483
- return !i || !n || !a ? !1 : (this.type = e.type, this.jsBridge.webViewType === "WxMiniProgramWebView" ? this.handleWxMiniProgramWebViewJoin({
484
- sdkAppId: i,
485
- userId: n,
486
- userSig: a,
487
- voiceId: e.voiceId
488
- }) : this.handleAppWebViewJoin({
489
- sdkAppId: i,
490
- userId: n,
491
- userSig: a,
492
- voiceId: e.voiceId
493
- }));
494
- });
495
- /**
496
- * 重连
497
- * @returns
498
- */
499
- s(this, "reJoin", async () => this._joinOptions ? this.join({
500
- voiceId: this._joinOptions.voiceId,
501
- userId: this._joinOptions.userId,
502
- roomId: this._joinOptions.roomId,
503
- type: this._joinOptions.type
504
- }) : (this.emitErrorAndSetJoinedFalse("重连失败:未找到加入房间参数。"), !1));
505
- /**
506
- * 获取 rtc 签名
507
- * @param params
508
- * @returns
509
- */
510
- s(this, "getVoiceSignOrEmitError", async (e) => {
511
- try {
512
- return await this.options.getVoiceSign(e);
513
- } catch (i) {
514
- return this.emitErrorAndSetJoinedFalse("加入房间失败:rtc 签名请求异常"), {};
515
- }
516
- });
517
- /**
518
- * 处理小程序的加入房间
519
- * @param options
520
- * @returns
521
- */
522
- s(this, "handleWxMiniProgramWebViewJoin", async (e) => {
523
- const [i, n] = await this.joinRoomOrEmitError(e);
524
- return n ? !1 : this.handleJoinResult(i);
525
- });
526
- /**
527
- * 处理App WebView的加入房间
528
- * @param options
529
- * @returns
530
- */
531
- s(this, "handleAppWebViewJoin", (e) => new Promise((i) => {
532
- this.off("inner.rtc.success");
533
- const n = (a) => {
534
- this.off("inner.rtc.fail", n), this.off("inner.rtc.success", n), i(this.handleJoinResult(a));
535
- };
536
- this.once("inner.rtc.fail", n), this.once("inner.rtc.success", n);
537
- try {
538
- const { sdkAppId: a, userId: u, userSig: d, voiceId: g } = e;
539
- this.jsBridge.callAndListen(
540
- `live/join?sdkAppID=${a}&userID=${u}&roomID=${g}&userSig=${d}`,
541
- (_) => {
542
- _ === !0 ? this.emit("inner.rtc.success", _) : typeof _ == "object" ? _.code === ne.Success || _.code === ne.ReJoin ? this.emit("inner.rtc.success", _) : this.emit("inner.rtc.fail", _) : this.emit("inner.rtc.fail", _);
543
- }
544
- );
545
- } catch (a) {
546
- i(
547
- this.handleJoinResult({
548
- message: a.message,
549
- code: ne.Unknown
550
- })
551
- );
552
- }
553
- }));
554
- /**
555
- * 加入语音房间,给小程序使用
556
- * @param param0
557
- * @returns
558
- */
559
- s(this, "joinRoomOrEmitError", async ({
560
- sdkAppId: e,
561
- userId: i,
562
- voiceId: n,
563
- userSig: a
564
- }) => {
565
- try {
566
- return await this.jsBridge.callAndBackfeed(
567
- `live/join?sdkAppID=${e}&userID=${i}&roomID=${Number(
568
- n
569
- )}&userSig=${a}`
570
- );
571
- } catch (u) {
572
- return this.emitErrorAndSetJoinedFalse("加入房间失败:" + u.message), [null, u];
573
- }
574
- });
575
- /**
576
- * 处理加入语音房间结果
577
- * @param res
578
- * @returns
579
- */
580
- s(this, "handleJoinResult", (e) => {
581
- switch (!0) {
582
- case e === !0:
583
- case (typeof e == "object" && e.code === ne.Success):
584
- case (typeof e == "object" && e.code === ne.ReJoin): {
585
- this.emit("joined"), this.joined = !0;
586
- break;
587
- }
588
- default: {
589
- this.joined = !1;
590
- const i = typeof e == "object" ? e.message : "加入房间失败:未知异常。";
591
- this.emit("error", new Error(i, { cause: e }));
592
- }
593
- }
594
- return this.joined;
595
- });
596
- /**
597
- * 将错误信息发送出去,并将 joined 置为 false
598
- * @param message
599
- */
600
- s(this, "emitErrorAndSetJoinedFalse", (e) => {
601
- this.emit("error", new Error(e)), this.joined = !1;
602
- });
603
- /**
604
- * 退出房间
605
- * @returns
606
- */
607
- s(this, "quit", async () => {
608
- const [e, i] = await this.jsBridge.callAndBackfeed(
609
- "live/quit"
610
- );
611
- return e === null && this.emit("error", i || new Error("退出房间失败:未知异常。")), this.joined = !1, !!e;
612
- });
613
- /**
614
- * 监测麦克风权限
615
- * @returns
616
- */
617
- s(this, "detectMicro", async () => {
618
- const [e, i] = await this.jsBridge.detectMicro();
619
- return e === null ? (this.emit("error", i || new Error("麦克风监测异常!")), !1) : e;
620
- });
621
- /**
622
- * 修改麦克风状态
623
- * @param flag
624
- * @returns
625
- */
626
- s(this, "toggleMicro", async (e) => {
627
- const [i, n] = await this.jsBridge.callAndBackfeed(
628
- `live/toggleMicro?flag=${Boolean(e) ? 1 : 0}`
629
- );
630
- return i === null ? (this.emit("error", n || new Error("麦克风监测异常!")), !1) : (this.micro = i, i);
631
- });
632
- /**
633
- * 震动
634
- */
635
- s(this, "shock", () => {
636
- this.jsBridge.shock(1);
637
- });
638
- this.options = { jsBridge: e, getVoiceSign: i }, this.jsBridge.webViewType !== "WxMiniProgramWebView" && this.jsBridge.callAndListen("live/userVolumes", this.handleUserVolumes), this.jsBridge.callAndListen("live/weakNetwork", this.handleWeakNetwork), this.on("inner.rtc.fail", this.handleJoinResult);
639
- }
640
- get jsBridge() {
641
- return this.options.jsBridge;
642
- }
643
- }
644
- 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 || {}), J = /* @__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))(J || {}), Z = /* @__PURE__ */ ((r) => (r.OPEN = "OPEN", r.CLOSE = "CLOSE", r))(Z || {});
645
- function Nr(r) {
646
- try {
647
- const o = JSON.parse(r), e = {
648
- code: o.code,
649
- message: o.message,
650
- command: o.command,
651
- roomCode: o.room_code,
652
- appID: o.app_id,
653
- requestId: o.request_id,
654
- frontRequestId: o.front_request_id,
655
- triggerUserID: o.trigger_user_id,
656
- data: o.data || {}
657
- }, i = Object.keys(e).filter(
658
- (n) => e[n] === void 0
659
- );
660
- return i.length > 0 && console.warn(`推送数据格式异常:${i.join(" ")} 值不存在!`), e;
661
- } catch (o) {
662
- return !1;
663
- }
664
- }
665
- var x = /* @__PURE__ */ ((r) => (r[r.NOTINITIALIZED = -1] = "NOTINITIALIZED", r[r.CONNECTING = 0] = "CONNECTING", r[r.OPEN = 1] = "OPEN", r[r.CLOSED = 3] = "CLOSED", r))(x || {}), er = /* @__PURE__ */ ((r) => (r[r.Normal = 0] = "Normal", r[r.Removed = 1] = "Removed", r[r.Replaced = 2] = "Replaced", r))(er || {}), tr = /* @__PURE__ */ ((r) => (r.WAIT_ENTER = "WAIT_ENTER", r.ONLINE = "ONLINE", r.LEAVE = "LEAVE", r.KICK_OUT = "KICK_OUT", r.BE_REPLACE = "BE_REPLACE", r.EXCEPTION = "EXCEPTION", r))(tr || {}), Ae = /* @__PURE__ */ ((r) => (r[r.NOTINITIALIZED = -1] = "NOTINITIALIZED", r[r.CONNECTING = 0] = "CONNECTING", r[r.OPEN = 1] = "OPEN", r[r.CLOSING = 2] = "CLOSING", r[r.CLOSED = 3] = "CLOSED", r))(Ae || {}), rr = /* @__PURE__ */ ((r) => (r.Error = "Error", r.Close = "Close", r.MicroAuth = "MicroAuth", r.DuplicateConnect = "DuplicateConnect", r.IllegalURL = "IllegalURL", r.Unknown = "Unknown", r.IllegalArgs = "IllegalArgs", r))(rr || {}), ir = /* @__PURE__ */ ((r) => (r.Err_1000 = "CLOSE_NORMAL", r.Err_1001 = "CLOSE_GOING_AWAY", r.Err_1002 = "CLOSE_PROTOCOL_ERROR", r.Err_1003 = "CLOSE_UNSUPPORTED", r.Err_1006 = "CLOSE_ABNORMAL", r.Err_1007 = "Unsupported Data", r.Err_1008 = "Policy Violation", r.Err_1009 = "CLOSE_TOO_LARGE", r.Err_unknown = "unknown", r))(ir || {});
666
- function nr(r) {
667
- switch (r) {
668
- case 1e3:
669
- return "CLOSE_NORMAL";
670
- case 1001:
671
- return "CLOSE_GOING_AWAY";
672
- case 1002:
673
- return "CLOSE_PROTOCOL_ERROR";
674
- case 1003:
675
- return "CLOSE_UNSUPPORTED";
676
- case 1006:
677
- return "CLOSE_ABNORMAL";
678
- case 1007:
679
- return "Unsupported Data";
680
- case 1008:
681
- return "Policy Violation";
682
- case 1009:
683
- return "CLOSE_TOO_LARGE";
684
- }
685
- return "unknown";
686
- }
687
- function sr(r) {
688
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
689
- }
690
- var ft = {};
691
- (function(r) {
692
- Object.defineProperty(r, "__esModule", { value: !0 }), r.LogLevel = void 0;
693
- var o;
694
- (function(e) {
695
- 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";
696
- })(o = r.LogLevel || (r.LogLevel = {})), r.default = o;
697
- })(ft);
698
- const ot = /* @__PURE__ */ sr(ft);
699
- function or(r, o = {}) {
700
- const e = r.indexOf("?") !== -1, i = Object.keys(o).reduce(
701
- (n, a, u) => `${n}${u === 0 && !e ? "?" : "&"}${a}=${o[a]}`,
702
- ""
703
- );
704
- return r + i;
705
- }
706
- const fe = globalThis.navigator.userAgent, ar = /android/gi.test(fe), cr = /iPhone|iPad\s+OS/gi.test(fe), ur = /MicroMessenger/gi.test(fe) && /miniProgram/gi.test(fe), lr = /realsee/gi.test(fe);
707
- function be(r) {
708
- return Object.prototype.toString.call(r) === "[object Object]";
709
- }
710
- function we(r, o) {
711
- return r === o ? !0 : typeof r != typeof o ? !1 : !!(Number.isNaN(r) && Number.isNaN(o));
712
- }
713
- function fr(r, o) {
714
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
715
- if (e.length !== i.length)
716
- return !1;
717
- for (let n = 0, a = e.length; n < a; n++) {
718
- const u = e[n];
719
- if (!we(r[u], o[u]))
720
- return !1;
721
- }
722
- return !0;
723
- }
724
- function dr(r, o) {
725
- if (r.length !== o.length)
726
- return !1;
727
- for (let e = 0, i = r.length; e < i; e++)
728
- if (!we(r[e], o[e]))
729
- return !1;
730
- return !0;
731
- }
732
- function hr(r, o) {
733
- return we(r, o) ? !0 : be(r) && be(o) ? fr(r, o) : Array.isArray(r) && Array.isArray(o) ? dr(r, o) : !1;
734
- }
735
- function De(r, o) {
736
- return we(r, o) ? !0 : be(r) && be(o) ? gr(r, o) : Array.isArray(r) && Array.isArray(o) ? _r(r, o) : !1;
737
- }
738
- function _r(r, o) {
739
- if (r.length !== o.length)
740
- return !1;
741
- for (let e = 0, i = r.length; e < i; e++)
742
- if (!De(r[e], o[e]))
743
- return !1;
744
- return !0;
745
- }
746
- function gr(r, o) {
747
- const e = Object.getOwnPropertyNames(r), i = Object.getOwnPropertyNames(o);
748
- if (e.length !== i.length)
749
- return !1;
750
- for (let n = 0, a = e.length; n < a; n++) {
751
- const u = e[n];
752
- if (!De(r[u], o[u]))
753
- return !1;
754
- }
755
- return !0;
756
- }
757
- function at(r, o, e = { deep: !1 }) {
758
- return e.deep ? De(r, o) : hr(r, o);
759
- }
760
- class mr extends le {
761
- constructor(e) {
762
- super();
763
- s(this, "_realWebSocket");
764
- s(this, "_url");
765
- s(this, "_protocols");
766
- s(this, "_readyState", Ae.NOTINITIALIZED);
767
- s(this, "_options", {
768
- timeout: 1e4,
769
- shouldReconnect: (e, i) => {
770
- if (!(e.code === 1008 || e.code === 1011))
771
- return [0, 1e3, 2e3][i.attempts % 3];
772
- },
773
- should1000Reconnect: !1,
774
- ignoreConnectivityEvents: !1,
775
- automaticOpen: !1
776
- });
777
- s(this, "_connectTimeout");
778
- s(this, "_attempts", 0);
779
- s(this, "_reconnects", -1);
780
- s(this, "_reconnectWhenOnlineAgain", !1);
781
- s(this, "_explicitlyClosed", !1);
782
- s(this, "_pendingReconnect");
783
- s(this, "_connectivityEventsAttached", !1);
784
- s(this, "_heathCheckTimer");
785
- /**
786
- * 做一个健康检查
787
- */
788
- s(this, "_healthCheck", async () => {
789
- this._realWebSocket && this._realWebSocket.readyState !== this._readyState && (this._readyState = this._realWebSocket.readyState, this._readyState === Ae.CLOSING && this.emit("closing")), await new Promise((e) => setTimeout(e, 2e3)), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
790
- });
791
- /**
792
- * 清理超时计时器
793
- */
794
- s(this, "_clearConnectTimeoutIfNeed", () => {
795
- this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
796
- });
797
- /**
798
- * 清理健康检查
799
- */
800
- s(this, "_clearHeathCheckIfNeed", () => {
801
- this._heathCheckTimer && (cancelAnimationFrame(this._heathCheckTimer), this._heathCheckTimer = void 0);
802
- });
803
- /**
804
- * 开启健康检查
805
- */
806
- s(this, "_startHealthCheck", () => {
807
- this._clearHeathCheckIfNeed(), this._heathCheckTimer = requestAnimationFrame(this._healthCheck);
808
- });
809
- /**
810
- * 停止健康检查
811
- */
812
- s(this, "_stopHealthCheck", () => {
813
- this._clearHeathCheckIfNeed();
814
- });
815
- /**
816
- * 清理连接中的请求
817
- */
818
- s(this, "_clearPendingReconnectIfNeeded", () => {
819
- this._pendingReconnect && (clearTimeout(this._pendingReconnect), this._pendingReconnect = void 0);
820
- });
821
- /**
822
- * 当网页连接上网络进行重连
823
- * @param event
824
- */
825
- s(this, "_online", (e) => {
826
- this._reconnectWhenOnlineAgain && (this._clearPendingReconnectIfNeeded(), this._reconnect(e));
827
- });
828
- /**
829
- * 当网页断开网络进行关闭
830
- */
831
- s(this, "_offline", () => {
832
- var e;
833
- this._reconnectWhenOnlineAgain = !0, (e = this._realWebSocket) == null || e.close(1e3, "offline");
834
- });
835
- /**
836
- * 解除网络监听事件
837
- */
838
- s(this, "_detachConnectivityEvents", () => {
839
- this._connectivityEventsAttached && (globalThis == null || globalThis.removeEventListener("online", this._online), globalThis == null || globalThis.removeEventListener("offline", this._offline), this._connectivityEventsAttached = !1);
840
- });
841
- /**
842
- * 注册网络监听事件
843
- */
844
- s(this, "_attachConnectivityEvents", () => {
845
- this._connectivityEventsAttached || (globalThis == null || globalThis.addEventListener("online", this._online), globalThis == null || globalThis.addEventListener("offline", this._offline), this._connectivityEventsAttached = !0);
846
- });
847
- /**
848
- * 发送消息
849
- * @param data
850
- * @returns
851
- */
852
- s(this, "send", (e) => {
853
- var i, n, a;
854
- ((i = this._realWebSocket) == null ? void 0 : i.readyState) === ((n = this._realWebSocket) == null ? void 0 : n.OPEN) && ((a = this._realWebSocket) == null || a.send(e));
855
- });
856
- /**
857
- * 关闭连接
858
- * @param code 代码
859
- * @param reason 原因
860
- * @returns
861
- */
862
- s(this, "close", (e, i) => {
863
- var n;
864
- 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);
865
- });
866
- /**
867
- * 进行ws连接
868
- */
869
- s(this, "open", (e) => {
870
- var i, n;
871
- 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());
872
- });
873
- /**
874
- * 创建ws连接
875
- */
876
- s(this, "_createWebSocket", () => {
877
- var n, a, u;
878
- const e = typeof this._url == "string" ? this._url : (n = this._url) == null ? void 0 : n.call(this, this);
879
- if (!e)
880
- return;
881
- this._clearConnectTimeoutIfNeed(), this._clearPendingReconnectIfNeeded(), this._removeWebSocketEvent(), this._realWebSocket = new WebSocket(e, this._protocols || void 0), this._attempts = this._attempts + 1, this.emit(
882
- "connecting",
883
- new CustomEvent("connecting", {
884
- detail: { attempts: this._attempts, reconnects: this._reconnects }
885
- })
886
- );
887
- const i = () => {
888
- this._connectTimeout = void 0, this._detachConnectivityEvents(), this.emit(
889
- "timeout",
890
- new CustomEvent("timeout", {
891
- detail: {
892
- attempts: this._attempts,
893
- reconnects: this._reconnects
894
- }
895
- })
896
- );
897
- };
898
- this._connectTimeout = setTimeout(i, (a = this._options) == null ? void 0 : a.timeout), this._dispatchWebSocketEvent(), (u = this._options) != null && u.ignoreConnectivityEvents || this._attachConnectivityEvents();
899
- });
900
- /**
901
- * 断开ws事件
902
- */
903
- s(this, "_removeWebSocketEvent", () => {
904
- var e, i, n, a;
905
- (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), (a = this._realWebSocket) == null || a.removeEventListener("message", this._webSocketMessageHandler);
906
- });
907
- /**
908
- * 分发ws事件
909
- */
910
- s(this, "_dispatchWebSocketEvent", () => {
911
- var e, i, n, a;
912
- (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), (a = this._realWebSocket) == null || a.addEventListener("message", this._webSocketMessageHandler);
913
- });
914
- /**
915
- * ws连接事件
916
- * @returns
917
- */
918
- s(this, "_webSocketOpenHandler", (e) => {
919
- this._connectTimeout && (clearTimeout(this._connectTimeout), this._connectTimeout = void 0);
920
- const i = ++this._reconnects, n = this._attempts;
921
- return this._attempts = 0, this._reconnectWhenOnlineAgain = !1, this._startHealthCheck(), this.emit("open", Object.assign(e, { detail: { reconnects: i, attempts: n } }));
922
- });
923
- /**
924
- * ws 关闭事件
925
- * @param event
926
- * @returns
927
- */
928
- s(this, "_webSocketCloseHandler", (e) => (this._reconnect(e), this._stopHealthCheck(), this.emit("close", e)));
929
- /**
930
- * ws 异常
931
- * @param event
932
- * @returns
933
- */
934
- s(this, "_webSocketErrorHandler", (e) => this.emit("error", new CustomEvent("error", { detail: { error: e } })));
935
- /**
936
- * ws消息
937
- * @param event
938
- * @returns
939
- */
940
- s(this, "_webSocketMessageHandler", (e) => this.emit("message", e));
941
- e && this.setOptions(e), this._startHealthCheck();
942
- }
943
- get attempts() {
944
- return this._attempts;
945
- }
946
- setOptions(e) {
947
- if (!e)
948
- return;
949
- this._url = e.url, this._protocols = e.protocols;
950
- const i = Object.assign(this._options, e.robustOptions || {});
951
- if (typeof (i == null ? void 0 : i.timeout) != "number")
952
- throw new Error("timeout must be the number of milliseconds to timeout a connection attempt");
953
- if (typeof (i == null ? void 0 : i.shouldReconnect) != "function")
954
- throw new Error(
955
- "shouldReconnect must be a function that returns the number of milliseconds to wait for a reconnect attempt, or null or undefined to not reconnect."
956
- );
957
- this._options = i, this._options.automaticOpen && this._createWebSocket();
958
- }
959
- /**
960
- * 进行重连
961
- * @param event
962
- * @returns
963
- */
964
- _reconnect(e) {
965
- var n, a, u, d;
966
- if (!((n = this._options) != null && n.should1000Reconnect) && e.code === 1e3 || this._explicitlyClosed) {
967
- this._attempts = 0;
968
- return;
969
- }
970
- if (this._connectivityEventsAttached && ((a = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : a.onLine) === !1) {
971
- this._reconnectWhenOnlineAgain = !0;
972
- return;
973
- }
974
- const i = (d = (u = this._options) == null ? void 0 : u.shouldReconnect) == null ? void 0 : d.call(u, e, this);
975
- typeof i == "number" && (this._pendingReconnect = setTimeout(this._createWebSocket, i));
976
- }
977
- }
978
- class vr extends le {
979
- constructor() {
980
- super();
981
- /**
982
- * ws代理器
983
- */
984
- s(this, "_ws", new mr({
985
- url: "",
986
- robustOptions: { should1000Reconnect: !0, ignoreConnectivityEvents: !0 }
987
- }));
988
- /**
989
- * 带看连接状态
990
- */
991
- s(this, "_state", x.NOTINITIALIZED);
992
- /**
993
- * 添加事件监听
994
- */
995
- s(this, "_addWebSocketEventListeners", () => {
996
- 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);
997
- });
998
- /**
999
- * 移除事件监听
1000
- */
1001
- s(this, "_removeWebSocketEventListeners", () => {
1002
- 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);
1003
- });
1004
- /**
1005
- * 处理房间关闭事件
1006
- * @param event
1007
- */
1008
- s(this, "_handleCloseEvent", (e) => {
1009
- O.info(`live room closed bacause of ${e.code}-${e.reason || nr(e.code)}`), this.state = x.CLOSED;
1010
- });
1011
- /**
1012
- * 处理房间正在关闭事件(这个时候可能是断网了)
1013
- */
1014
- s(this, "_handleClosingEvent", () => {
1015
- var e;
1016
- O.info("live room is closing, onLine:", (e = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : e.onLine), this.state = x.CLOSED;
1017
- });
1018
- /**
1019
- * 连接中
1020
- * @param event
1021
- */
1022
- s(this, "_handleConnectingEvent", (e) => {
1023
- O.info("live room is connecting"), this.state = x.CONNECTING, e.detail.reconnects > 0 && this.emit("reconnecting", e.detail);
1024
- });
1025
- /**
1026
- * 连接发送异常
1027
- * @param event
1028
- */
1029
- s(this, "_handleErrorEvent", (e) => {
1030
- O.error("live room error", e), this.state = x.CLOSED;
1031
- });
1032
- /**
1033
- * 接收到消息
1034
- * @param event
1035
- */
1036
- s(this, "_handleMessageEvent", (e) => {
1037
- let i = (() => {
1038
- try {
1039
- return JSON.parse(e.data);
1040
- } catch (n) {
1041
- return e.data;
1042
- }
1043
- })();
1044
- this.emit("message", i);
1045
- });
1046
- /**
1047
- * 连接建立成功
1048
- * @param event
1049
- */
1050
- s(this, "_handleOpenEvent", (e) => {
1051
- O.info("live room open", e.detail), this.state = x.OPEN, e.detail.reconnects > 0 && this.emit("reconnected", e.detail);
1052
- });
1053
- /**
1054
- * 处理超时
1055
- * @param event
1056
- */
1057
- s(this, "_handleTimeoutEvent", (e) => {
1058
- O.error("live room connect timeout!", e.detail), this.state = x.CLOSED;
1059
- });
1060
- /**
1061
- * 释放资源,释放之后需要重新实例化
1062
- * @returns
1063
- */
1064
- s(this, "dispose", async () => (this._removeWebSocketEventListeners(), await this.close("live room close by controller disposed!")));
1065
- /**
1066
- * 开启房间链接
1067
- * @param url 房间链接
1068
- * @returns
1069
- */
1070
- s(this, "open", (e) => this._ws.open(e));
1071
- /**
1072
- * 关闭房间
1073
- * @param code
1074
- * @param reason
1075
- */
1076
- s(this, "close", (e, i) => new Promise((n) => {
1077
- this._ws.once("close", () => n(!0)), this._ws.close(e, i);
1078
- }));
1079
- this._addWebSocketEventListeners();
1080
- }
1081
- set state(e) {
1082
- const i = JSON.parse(JSON.stringify(this._state));
1083
- this._state = e, this.emit("stateChange", this.state, i);
1084
- }
1085
- get state() {
1086
- return this._state;
1087
- }
1088
- /**
1089
- * 发送数据
1090
- * @param data
1091
- */
1092
- sendMessage(e = "") {
1093
- if (e == null || e === "")
1094
- throw new Error("live message is empty!");
1095
- if (this.state === x.OPEN)
1096
- return this._ws.send(JSON.stringify(e));
1097
- throw new Error("live has not yet been initialized!");
1098
- }
1099
- /**
1100
- * 准备关闭带看
1101
- */
1102
- readyClose() {
1103
- this._ws && (this._ws._explicitlyClosed = !0);
1104
- }
1105
- }
1106
- const pr = (r) => Promise.reject("unimplemented method GetVoiceSign"), Le = (r, o = {}, e = []) => ({
1107
- command: r,
1108
- front_request_id: ye(),
1109
- data: {
1110
- ...o,
1111
- to_user_ids: Array.isArray(e) ? e : [e]
1112
- }
1113
- }), Er = () => {
1114
- var r, o;
1115
- 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);
1116
- };
1117
- class yr extends le {
1118
- constructor(e) {
1119
- var i;
1120
- super();
1121
- /**
1122
- * 带看的配置
1123
- */
1124
- s(this, "_options", {});
1125
- /**
1126
- * 帧数据监听
1127
- */
1128
- s(this, "keyframes", new le());
1129
- /**
1130
- * 内置的一些数据
1131
- */
1132
- s(this, "_buildInData", {
1133
- keyframes: {}
1134
- });
1135
- /**
1136
- * 根据键值取帧数据
1137
- * @param key 帧数据的键值
1138
- * @returns
1139
- */
1140
- s(this, "getFramesByKey", (e) => this.snapshot[e]);
1141
- /**
1142
- * 发送帧数据(需要能够被序列化)
1143
- * @param key 帧数据键值
1144
- * @param frame 帧数据本体
1145
- * @returns
1146
- */
1147
- s(this, "sendKeyframe", (e, i) => {
1148
- if (this.state !== x.OPEN)
1149
- return !1;
1150
- this._buildInData.keyframes = {
1151
- ...this._buildInData.keyframes,
1152
- [e]: i
1153
- };
1154
- const n = Le(K.KeyframeSync, this.snapshot);
1155
- try {
1156
- return this._controller.sendMessage(n), !0;
1157
- } catch (a) {
1158
- return O.error(a), !1;
1159
- }
1160
- });
1161
- /**
1162
- * 带看控制器
1163
- */
1164
- s(this, "_controller", new vr());
1165
- /**
1166
- * 添加带看控制的事件监听
1167
- */
1168
- s(this, "_addLiveControllerEventListeners", () => {
1169
- this._controller.on("stateChange", this._handleStateChange), this._controller.on("message", this._handleMessage);
1170
- });
1171
- /**
1172
- * 移除带看控制的事件监听
1173
- */
1174
- s(this, "_removeLiveControllerEventListeners", () => {
1175
- this._controller.off("stateChange", this._handleStateChange), this._controller.off("message", this._handleMessage);
1176
- });
1177
- /**
1178
- * 带看状态变化
1179
- * @param state
1180
- * @returns
1181
- */
1182
- s(this, "_handleStateChange", (e, i) => this.emit("stateChange", e, i));
1183
- /**
1184
- * 消息接收
1185
- * @param liveMsg
1186
- */
1187
- s(this, "_handleMessage", async (e) => {
1188
- var i, n, a, u, d;
1189
- if (typeof e == "object") {
1190
- const { command: g, data: _ = {}, frontRequestId: E, code: y, message: I } = e;
1191
- if (y === "SUCCESS")
1192
- switch (g) {
1193
- case K.SelfUserInfo: {
1194
- const m = _;
1195
- at(this.selfInfo, m, { deep: !0 }) || (this._buildInData.selfInfo = m, this.emit("selfInfoUpdate", this._buildInData.selfInfo, E));
1196
- break;
1197
- }
1198
- case K.RoomInfo: {
1199
- const m = _;
1200
- this._buildInData.roomInfo = Object.assign({}, m), this.emit("readyKeyframeSync", m.last_frame || {});
1201
- break;
1202
- }
1203
- case K.RTCInfo: {
1204
- const { voice_id: m, type: D } = _;
1205
- if (this._buildInData.rtcInfo = { voiceId: m, type: D }, (i = this.$RTC) != null && i.joined)
1206
- O.warn("已加入语音房间,无需重复加入!");
1207
- else if (await ((u = this.$RTC) == null ? void 0 : u.join({
1208
- voiceId: m,
1209
- userId: ((n = this.selfInfo) == null ? void 0 : n.id) || "",
1210
- roomId: (a = this.roomInfo) == null ? void 0 : a.info.room_code,
1211
- type: D
1212
- }))) {
1213
- const k = (d = this._options.initialMicroStatus) != null ? d : Z.OPEN;
1214
- await this.toggleMicro(k === Z.OPEN);
1215
- } else
1216
- O.error("加入语音房间失败");
1217
- break;
1218
- }
1219
- case K.UserList: {
1220
- const m = _;
1221
- this._buildInData.userList = m, this.emit("userListUpdate", this.userList, E);
1222
- break;
1223
- }
1224
- case K.CustomEvent: {
1225
- const m = _;
1226
- this.emit("broadcast", m, E);
1227
- break;
1228
- }
1229
- case K.KeyframeSync: {
1230
- const m = _, D = Object.keys(m).reduce(
1231
- (w, k) => {
1232
- if (at(m[k], this._buildInData.keyframes[k], {
1233
- deep: !0
1234
- }))
1235
- return w;
1236
- const U = [m[k], this._buildInData.keyframes[k], E], P = k;
1237
- return this.keyframes.emit(
1238
- P,
1239
- ...U
1240
- ), this._buildInData.keyframes[k] = m[k], w[k] = m[k], w;
1241
- },
1242
- {}
1243
- );
1244
- this.emit("keyframes", D, E);
1245
- break;
1246
- }
1247
- case K.BuiltinMsg: {
1248
- const m = _;
1249
- this.emit("builtinEvent", m), m.event_type === q.UserChange && this.emit("userChange", m), m.event_type === q.RoomChange && this.emit("roomChange", m), m.event_type === q.UserChange && m.action === J.UserMicroStatus && await this.toggleMicro(m.data.status === Z.OPEN), m.event_type === q.RoomChange && m.action === J.RoomClose && await this._exit();
1250
- break;
1251
- }
1252
- case K.UserKickOut: {
1253
- this.emit("kickOut");
1254
- break;
1255
- }
1256
- default:
1257
- console.warn("unknown command: ", g);
1258
- }
1259
- else
1260
- this.emit("error", e);
1261
- }
1262
- });
1263
- /**
1264
- * 清理带看缓存的数据
1265
- */
1266
- s(this, "_clearLiveData", () => {
1267
- this._buildInData = { keyframes: {} };
1268
- });
1269
- /**
1270
- * 连接带看
1271
- * @param options
1272
- * @returns
1273
- */
1274
- s(this, "connect", async (e = {}) => {
1275
- var u, d, g, _;
1276
- 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 = (_ = e.rtcMicStatus) != null ? _ : this._options.initialMicroStatus, !/^ws(s):\/\//.test(this._options.url) || typeof this._options.getTicket != "function")
1277
- 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");
1278
- const { force: i = !1 } = e;
1279
- if (this._options.rtc && !await this._options.rtc.detectMicro())
1280
- return new Error("Failed to obtain microphone authorization");
1281
- const n = this.state;
1282
- if (n === x.CONNECTING || n === x.OPEN)
1283
- if (i)
1284
- try {
1285
- await this._controller.close("force close by connect");
1286
- } catch (E) {
1287
- console.warn(E);
1288
- }
1289
- else
1290
- return new Error("已有Live实例正在连接中,请勿重复连接!");
1291
- this._clearLiveData();
1292
- const a = or(this._options.url, {
1293
- ticket: await this._options.getTicket(),
1294
- force: Number(!!i)
1295
- });
1296
- return this._controller.open(a), !0;
1297
- });
1298
- /**
1299
- * 退出带看
1300
- * @returns
1301
- */
1302
- s(this, "_exit", async () => {
1303
- var e;
1304
- this._clearLiveData();
1305
- try {
1306
- await ((e = this.$RTC) == null ? void 0 : e.quit());
1307
- } catch (i) {
1308
- O.warn(i);
1309
- }
1310
- return this.state !== x.OPEN ? !0 : await this._controller.close();
1311
- });
1312
- /**
1313
- * 退出带看
1314
- * @returns
1315
- */
1316
- s(this, "exit", async () => this.close());
1317
- /**
1318
- * 关闭带看房间
1319
- * @param code
1320
- * @param reason
1321
- * @returns
1322
- */
1323
- s(this, "close", async () => {
1324
- var e;
1325
- await this._controller.readyClose();
1326
- try {
1327
- await ((e = this.$RTC) == null ? void 0 : e.quit());
1328
- } catch (i) {
1329
- O.warn(i);
1330
- }
1331
- await this.updateStatus(q.RoomChange, J.RoomClose, {});
1332
- });
1333
- /**
1334
- * 销毁带看
1335
- * @returns
1336
- */
1337
- s(this, "dispose", async () => (this._removeLiveControllerEventListeners(), this._clearLiveData(), await this._controller.dispose()));
1338
- /**
1339
- * 设置自己的用户信息
1340
- * @param userInfo
1341
- * @returns
1342
- */
1343
- s(this, "setSelfInfo", async (e) => await this.updateStatus(q.UserChange, J.UserInfo, e));
1344
- // 仅用于用户自己的麦克风控制
1345
- s(this, "toggleMicro", async (e) => {
1346
- var n, a, u;
1347
- if (!((a = (n = this.selfInfo) == null ? void 0 : n.permission) != null && a.control_own_micro))
1348
- return !1;
1349
- const i = await ((u = this.$RTC) == null ? void 0 : u.toggleMicro(e));
1350
- return i && await this.updateStatus(
1351
- q.UserChange,
1352
- J.UserMicroStatus,
1353
- {
1354
- status: e ? Z.OPEN : Z.CLOSE
1355
- },
1356
- []
1357
- ), i;
1358
- });
1359
- /**
1360
- * 控制别人的麦
1361
- * @param microStatus
1362
- * @param toUserIds
1363
- * @returns
1364
- */
1365
- s(this, "forbidMicro", async (e, i) => {
1366
- var n, a;
1367
- return typeof this._options.canForbidUserMicro == "function" && !this._options.canForbidUserMicro(i) || !((a = (n = this.selfInfo) == null ? void 0 : n.permission) != null && a.control_other_micro) ? !1 : await this.updateStatus(
1368
- q.UserChange,
1369
- J.UserMicroStatus,
1370
- {
1371
- status: e
1372
- },
1373
- i
1374
- );
1375
- });
1376
- /**
1377
- * 控制别人的同步全量帧数据权限
1378
- * @param sync
1379
- * @param toUserIds
1380
- * @returns
1381
- */
1382
- s(this, "forbidSync", async (e, i) => {
1383
- var n, a;
1384
- return typeof this._options.canForbidUserSync == "function" && !this._options.canForbidUserSync(i) || !((a = (n = this.selfInfo) == null ? void 0 : n.permission) != null && a.control_other_sync) ? !1 : await this.updateStatus(
1385
- q.UserChange,
1386
- J.UserPermission,
1387
- { sync_frame: e },
1388
- i
1389
- );
1390
- });
1391
- /**
1392
- * 把用户踢出带看
1393
- * @param toUserIds
1394
- * @returns
1395
- */
1396
- s(this, "kick", async (e) => {
1397
- var i, n;
1398
- 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(
1399
- q.UserChange,
1400
- J.UserStatus,
1401
- {
1402
- status: "KICK_OUT"
1403
- },
1404
- e
1405
- );
1406
- });
1407
- this._addLiveControllerEventListeners(), this._options = Object.assign({ initialMicroStatus: Z.OPEN }, e), this._options.jsBridge = (() => {
1408
- if (e.jsBridge)
1409
- return e.jsBridge;
1410
- if (e.useBuiltInJsBridge)
1411
- return new xt();
1412
- })(), this._options.getVoiceSign = (i = e.getVoiceSign) != null ? i : pr, this._options.autoPlayConfirm = e.autoPlayConfirm, this._options.rtc = (() => {
1413
- if (e.rtc)
1414
- return e.rtc;
1415
- if (e.rtcType)
1416
- switch (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), e.rtcType) {
1417
- case Q.RealseeVRWebViewRTC: {
1418
- if (this._options.jsBridge)
1419
- return new st({
1420
- jsBridge: this._options.jsBridge,
1421
- getVoiceSign: this._options.getVoiceSign
1422
- });
1423
- O.error("JsBridge instance must be passed when using built-in VRWebViewRTC instances");
1424
- return;
1425
- }
1426
- case Q.RealseeBrowserChimeRTC:
1427
- return new nt({
1428
- getVoiceSign: this._options.getVoiceSign,
1429
- logLevel: e.__debug__ ? ot.DEBUG : ot.INFO
1430
- });
1431
- case Q.RealseeBrowserRTC:
1432
- return this._options.autoPlayConfirm || O.error("autoPlayConfirm method must be passed when using built-in RealseeBrowserRTC instances"), new it({
1433
- getVoiceSign: this._options.getVoiceSign,
1434
- autoPlayConfirm: this._options.autoPlayConfirm
1435
- });
1436
- default: {
1437
- O.error("unknown built-in RTC type");
1438
- return;
1439
- }
1440
- }
1441
- if (e.useBuiltInRTC) {
1442
- if (e.getVoiceSign || O.error("GetVoiceSign method must be passed when using built-in RTC instances"), this._options.jsBridge)
1443
- return lr && (ar || cr) || ur ? new st({
1444
- jsBridge: this._options.jsBridge,
1445
- getVoiceSign: this._options.getVoiceSign
1446
- }) : e.builtInRTCType === lt.RealseeXChimeRTC ? new nt({
1447
- getVoiceSign: this._options.getVoiceSign
1448
- }) : new it({
1449
- getVoiceSign: this._options.getVoiceSign,
1450
- autoPlayConfirm: this._options.autoPlayConfirm
1451
- });
1452
- O.error("jsBridge instance must be passed when using built-in RTC instances");
1453
- return;
1454
- }
1455
- })(), 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 });
1456
- }
1457
- get options() {
1458
- return Object.freeze(this._options || {});
1459
- }
1460
- /**
1461
- * 带看状态
1462
- */
1463
- get state() {
1464
- return this._controller.state;
1465
- }
1466
- /**
1467
- * 兼容老逻辑
1468
- * @deprecated 请直接读取 state 属性字段,未来将移除该属性
1469
- */
1470
- get readyState() {
1471
- return this._controller.state;
1472
- }
1473
- /**
1474
- * 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
1475
- * @deprecated 带看不需要关注底层ws的相关信息,未来将移除
1476
- */
1477
- get url() {
1478
- return this.options.url;
1479
- }
1480
- /**
1481
- * 获取当前live使用的RTC实例
1482
- */
1483
- get $RTC() {
1484
- return this._options.rtc;
1485
- }
1486
- /**
1487
- * 获取当前live使用的jsBridge实例
1488
- */
1489
- get jsBridge() {
1490
- return this._options.jsBridge;
1491
- }
1492
- /**
1493
- * 当前帧数据快照
1494
- */
1495
- get snapshot() {
1496
- return this._buildInData.keyframes;
1497
- }
1498
- /**
1499
- * 当前用户信息
1500
- */
1501
- get selfInfo() {
1502
- return this._buildInData.selfInfo;
1503
- }
1504
- /**
1505
- * 当前用户列表
1506
- */
1507
- get userList() {
1508
- return this._buildInData.userList || [];
1509
- }
1510
- /**
1511
- * 当前带看房间信息
1512
- */
1513
- get roomInfo() {
1514
- return this._buildInData.roomInfo;
1515
- }
1516
- /**
1517
- * 修改状态
1518
- * @param evtType
1519
- * @param atnType
1520
- * @param status
1521
- * @param toUserIds
1522
- * @returns
1523
- */
1524
- async updateStatus(e, i, n, a) {
1525
- if (this.state !== x.OPEN)
1526
- return !1;
1527
- const u = Object.assign({ event_type: e, action: i }, { data: n }), d = Le(K.BuiltinMsg, u, a);
1528
- try {
1529
- return this._controller.sendMessage(d), !0;
1530
- } catch (g) {
1531
- return O.error(g), !1;
1532
- }
1533
- }
1534
- /**
1535
- * 自定义广播
1536
- * @param request 广播请求的数据
1537
- * @param toUserIds
1538
- * @param timeout
1539
- * @returns
1540
- */
1541
- broadcast(e, i, n) {
1542
- return this.state !== x.OPEN ? !1 : new Promise((a, u) => {
1543
- const d = Le(K.CustomEvent, e, i), g = d.front_request_id, _ = n ? setTimeout(() => {
1544
- u(new Error("RESPONSE TIMEOUT")), this.off("broadcast", E);
1545
- }, n) : void 0, E = (y, I) => {
1546
- I === g && (_ && clearTimeout(_), this.off("broadcast", E), a(y));
1547
- };
1548
- this.on("broadcast", E);
1549
- try {
1550
- this._controller.sendMessage(d);
1551
- } catch (y) {
1552
- u(y);
1553
- }
1554
- });
1555
- }
1556
- }
1557
- const br = (r) => (Er(), new yr(r));
1558
- var Ve = {}, Sr = {
1559
- get exports() {
1560
- return Ve;
1561
- },
1562
- set exports(r) {
1563
- Ve = r;
1564
- }
1565
- }, ae = {};
1566
- /**
1567
- * @license React
1568
- * react-jsx-runtime.production.min.js
1569
- *
1570
- * Copyright (c) Facebook, Inc. and its affiliates.
1571
- *
1572
- * This source code is licensed under the MIT license found in the
1573
- * LICENSE file in the root directory of this source tree.
1574
- */
1575
- var ct;
1576
- function wr() {
1577
- if (ct)
1578
- return ae;
1579
- ct = 1;
1580
- var r = M, 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, a = { key: !0, ref: !0, __self: !0, __source: !0 };
1581
- function u(d, g, _) {
1582
- var E, y = {}, I = null, m = null;
1583
- _ !== void 0 && (I = "" + _), g.key !== void 0 && (I = "" + g.key), g.ref !== void 0 && (m = g.ref);
1584
- for (E in g)
1585
- i.call(g, E) && !a.hasOwnProperty(E) && (y[E] = g[E]);
1586
- if (d && d.defaultProps)
1587
- for (E in g = d.defaultProps, g)
1588
- y[E] === void 0 && (y[E] = g[E]);
1589
- return { $$typeof: o, type: d, key: I, ref: m, props: y, _owner: n.current };
1590
- }
1591
- return ae.Fragment = e, ae.jsx = u, ae.jsxs = u, ae;
1592
- }
1593
- var ce = {};
1594
- /**
1595
- * @license React
1596
- * react-jsx-runtime.development.js
1597
- *
1598
- * Copyright (c) Facebook, Inc. and its affiliates.
1599
- *
1600
- * This source code is licensed under the MIT license found in the
1601
- * LICENSE file in the root directory of this source tree.
1602
- */
1603
- var ut;
1604
- function Cr() {
1605
- return ut || (ut = 1, process.env.NODE_ENV !== "production" && function() {
1606
- var r = M, o = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), d = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), _ = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), m = Symbol.for("react.offscreen"), D = Symbol.iterator, w = "@@iterator";
1607
- function k(t) {
1608
- if (t === null || typeof t != "object")
1609
- return null;
1610
- var c = D && t[D] || t[w];
1611
- return typeof c == "function" ? c : null;
1612
- }
1613
- var U = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1614
- function P(t) {
1615
- {
1616
- for (var c = arguments.length, l = new Array(c > 1 ? c - 1 : 0), h = 1; h < c; h++)
1617
- l[h - 1] = arguments[h];
1618
- de("error", t, l);
1619
- }
1620
- }
1621
- function de(t, c, l) {
1622
- {
1623
- var h = U.ReactDebugCurrentFrame, b = h.getStackAddendum();
1624
- b !== "" && (c += "%s", l = l.concat([b]));
1625
- var R = l.map(function(p) {
1626
- return String(p);
1627
- });
1628
- R.unshift("Warning: " + c), Function.prototype.apply.call(console[t], console, R);
1629
- }
1630
- }
1631
- var f = !1, C = !1, A = !1, S = !1, N = !1, V;
1632
- V = Symbol.for("react.module.reference");
1633
- function W(t) {
1634
- return !!(typeof t == "string" || typeof t == "function" || t === i || t === a || N || t === n || t === _ || t === E || S || t === m || f || C || A || typeof t == "object" && t !== null && (t.$$typeof === I || t.$$typeof === y || t.$$typeof === u || t.$$typeof === d || t.$$typeof === g || // This needs to include all possible module reference object
1635
- // types supported by any Flight configuration anywhere since
1636
- // we don't know which Flight build this will end up being used
1637
- // with.
1638
- t.$$typeof === V || t.getModuleId !== void 0));
1639
- }
1640
- function H(t, c, l) {
1641
- var h = t.displayName;
1642
- if (h)
1643
- return h;
1644
- var b = c.displayName || c.name || "";
1645
- return b !== "" ? l + "(" + b + ")" : l;
1646
- }
1647
- function se(t) {
1648
- return t.displayName || "Context";
1649
- }
1650
- function G(t) {
1651
- if (t == null)
1652
- return null;
1653
- if (typeof t.tag == "number" && P("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
1654
- return t.displayName || t.name || null;
1655
- if (typeof t == "string")
1656
- return t;
1657
- switch (t) {
1658
- case i:
1659
- return "Fragment";
1660
- case e:
1661
- return "Portal";
1662
- case a:
1663
- return "Profiler";
1664
- case n:
1665
- return "StrictMode";
1666
- case _:
1667
- return "Suspense";
1668
- case E:
1669
- return "SuspenseList";
1670
- }
1671
- if (typeof t == "object")
1672
- switch (t.$$typeof) {
1673
- case d:
1674
- var c = t;
1675
- return se(c) + ".Consumer";
1676
- case u:
1677
- var l = t;
1678
- return se(l._context) + ".Provider";
1679
- case g:
1680
- return H(t, t.render, "ForwardRef");
1681
- case y:
1682
- var h = t.displayName || null;
1683
- return h !== null ? h : G(t.type) || "Memo";
1684
- case I: {
1685
- var b = t, R = b._payload, p = b._init;
1686
- try {
1687
- return G(p(R));
1688
- } catch (v) {
1689
- return null;
1690
- }
1691
- }
1692
- }
1693
- return null;
1694
- }
1695
- var z = Object.assign, ee = 0, T, F, te, he, $e, xe, Ue;
1696
- function We() {
1697
- }
1698
- We.__reactDisabledLog = !0;
1699
- function dt() {
1700
- {
1701
- if (ee === 0) {
1702
- T = console.log, F = console.info, te = console.warn, he = console.error, $e = console.group, xe = console.groupCollapsed, Ue = console.groupEnd;
1703
- var t = {
1704
- configurable: !0,
1705
- enumerable: !0,
1706
- value: We,
1707
- writable: !0
1708
- };
1709
- Object.defineProperties(console, {
1710
- info: t,
1711
- log: t,
1712
- warn: t,
1713
- error: t,
1714
- group: t,
1715
- groupCollapsed: t,
1716
- groupEnd: t
1717
- });
1718
- }
1719
- ee++;
1720
- }
1721
- }
1722
- function ht() {
1723
- {
1724
- if (ee--, ee === 0) {
1725
- var t = {
1726
- configurable: !0,
1727
- enumerable: !0,
1728
- writable: !0
1729
- };
1730
- Object.defineProperties(console, {
1731
- log: z({}, t, {
1732
- value: T
1733
- }),
1734
- info: z({}, t, {
1735
- value: F
1736
- }),
1737
- warn: z({}, t, {
1738
- value: te
1739
- }),
1740
- error: z({}, t, {
1741
- value: he
1742
- }),
1743
- group: z({}, t, {
1744
- value: $e
1745
- }),
1746
- groupCollapsed: z({}, t, {
1747
- value: xe
1748
- }),
1749
- groupEnd: z({}, t, {
1750
- value: Ue
1751
- })
1752
- });
1753
- }
1754
- ee < 0 && P("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
1755
- }
1756
- }
1757
- var Ce = U.ReactCurrentDispatcher, Re;
1758
- function _e(t, c, l) {
1759
- {
1760
- if (Re === void 0)
1761
- try {
1762
- throw Error();
1763
- } catch (b) {
1764
- var h = b.stack.trim().match(/\n( *(at )?)/);
1765
- Re = h && h[1] || "";
1766
- }
1767
- return `
1768
- ` + Re + t;
1769
- }
1770
- }
1771
- var Oe = !1, ge;
1772
- {
1773
- var _t = typeof WeakMap == "function" ? WeakMap : Map;
1774
- ge = new _t();
1775
- }
1776
- function Fe(t, c) {
1777
- if (!t || Oe)
1778
- return "";
1779
- {
1780
- var l = ge.get(t);
1781
- if (l !== void 0)
1782
- return l;
1783
- }
1784
- var h;
1785
- Oe = !0;
1786
- var b = Error.prepareStackTrace;
1787
- Error.prepareStackTrace = void 0;
1788
- var R;
1789
- R = Ce.current, Ce.current = null, dt();
1790
- try {
1791
- if (c) {
1792
- var p = function() {
1793
- throw Error();
1794
- };
1795
- if (Object.defineProperty(p.prototype, "props", {
1796
- set: function() {
1797
- throw Error();
1798
- }
1799
- }), typeof Reflect == "object" && Reflect.construct) {
1800
- try {
1801
- Reflect.construct(p, []);
1802
- } catch (Y) {
1803
- h = Y;
1804
- }
1805
- Reflect.construct(t, [], p);
1806
- } else {
1807
- try {
1808
- p.call();
1809
- } catch (Y) {
1810
- h = Y;
1811
- }
1812
- t.call(p.prototype);
1813
- }
1814
- } else {
1815
- try {
1816
- throw Error();
1817
- } catch (Y) {
1818
- h = Y;
1819
- }
1820
- t();
1821
- }
1822
- } catch (Y) {
1823
- if (Y && h && typeof Y.stack == "string") {
1824
- for (var v = Y.stack.split(`
1825
- `), $ = h.stack.split(`
1826
- `), j = v.length - 1, L = $.length - 1; j >= 1 && L >= 0 && v[j] !== $[L]; )
1827
- L--;
1828
- for (; j >= 1 && L >= 0; j--, L--)
1829
- if (v[j] !== $[L]) {
1830
- if (j !== 1 || L !== 1)
1831
- do
1832
- if (j--, L--, L < 0 || v[j] !== $[L]) {
1833
- var B = `
1834
- ` + v[j].replace(" at new ", " at ");
1835
- return t.displayName && B.includes("<anonymous>") && (B = B.replace("<anonymous>", t.displayName)), typeof t == "function" && ge.set(t, B), B;
1836
- }
1837
- while (j >= 1 && L >= 0);
1838
- break;
1839
- }
1840
- }
1841
- } finally {
1842
- Oe = !1, Ce.current = R, ht(), Error.prepareStackTrace = b;
1843
- }
1844
- var ie = t ? t.displayName || t.name : "", tt = ie ? _e(ie) : "";
1845
- return typeof t == "function" && ge.set(t, tt), tt;
1846
- }
1847
- function gt(t, c, l) {
1848
- return Fe(t, !1);
1849
- }
1850
- function mt(t) {
1851
- var c = t.prototype;
1852
- return !!(c && c.isReactComponent);
1853
- }
1854
- function me(t, c, l) {
1855
- if (t == null)
1856
- return "";
1857
- if (typeof t == "function")
1858
- return Fe(t, mt(t));
1859
- if (typeof t == "string")
1860
- return _e(t);
1861
- switch (t) {
1862
- case _:
1863
- return _e("Suspense");
1864
- case E:
1865
- return _e("SuspenseList");
1866
- }
1867
- if (typeof t == "object")
1868
- switch (t.$$typeof) {
1869
- case g:
1870
- return gt(t.render);
1871
- case y:
1872
- return me(t.type, c, l);
1873
- case I: {
1874
- var h = t, b = h._payload, R = h._init;
1875
- try {
1876
- return me(R(b), c, l);
1877
- } catch (p) {
1878
- }
1879
- }
1880
- }
1881
- return "";
1882
- }
1883
- var ve = Object.prototype.hasOwnProperty, Be = {}, Ke = U.ReactDebugCurrentFrame;
1884
- function pe(t) {
1885
- if (t) {
1886
- var c = t._owner, l = me(t.type, t._source, c ? c.type : null);
1887
- Ke.setExtraStackFrame(l);
1888
- } else
1889
- Ke.setExtraStackFrame(null);
1890
- }
1891
- function vt(t, c, l, h, b) {
1892
- {
1893
- var R = Function.call.bind(ve);
1894
- for (var p in t)
1895
- if (R(t, p)) {
1896
- var v = void 0;
1897
- try {
1898
- if (typeof t[p] != "function") {
1899
- var $ = Error((h || "React class") + ": " + l + " type `" + p + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[p] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
1900
- throw $.name = "Invariant Violation", $;
1901
- }
1902
- v = t[p](c, p, h, l, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1903
- } catch (j) {
1904
- v = j;
1905
- }
1906
- v && !(v instanceof Error) && (pe(b), P("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", h || "React class", l, p, typeof v), pe(null)), v instanceof Error && !(v.message in Be) && (Be[v.message] = !0, pe(b), P("Failed %s type: %s", l, v.message), pe(null));
1907
- }
1908
- }
1909
- }
1910
- var pt = Array.isArray;
1911
- function Ie(t) {
1912
- return pt(t);
1913
- }
1914
- function Et(t) {
1915
- {
1916
- var c = typeof Symbol == "function" && Symbol.toStringTag, l = c && t[Symbol.toStringTag] || t.constructor.name || "Object";
1917
- return l;
1918
- }
1919
- }
1920
- function yt(t) {
1921
- try {
1922
- return qe(t), !1;
1923
- } catch (c) {
1924
- return !0;
1925
- }
1926
- }
1927
- function qe(t) {
1928
- return "" + t;
1929
- }
1930
- function Ge(t) {
1931
- if (yt(t))
1932
- return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Et(t)), qe(t);
1933
- }
1934
- var oe = U.ReactCurrentOwner, bt = {
1935
- key: !0,
1936
- ref: !0,
1937
- __self: !0,
1938
- __source: !0
1939
- }, Ye, Je, Te;
1940
- Te = {};
1941
- function St(t) {
1942
- if (ve.call(t, "ref")) {
1943
- var c = Object.getOwnPropertyDescriptor(t, "ref").get;
1944
- if (c && c.isReactWarning)
1945
- return !1;
1946
- }
1947
- return t.ref !== void 0;
1948
- }
1949
- function wt(t) {
1950
- if (ve.call(t, "key")) {
1951
- var c = Object.getOwnPropertyDescriptor(t, "key").get;
1952
- if (c && c.isReactWarning)
1953
- return !1;
1954
- }
1955
- return t.key !== void 0;
1956
- }
1957
- function Ct(t, c) {
1958
- if (typeof t.ref == "string" && oe.current && c && oe.current.stateNode !== c) {
1959
- var l = G(oe.current.type);
1960
- Te[l] || (P('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', G(oe.current.type), t.ref), Te[l] = !0);
1961
- }
1962
- }
1963
- function Rt(t, c) {
1964
- {
1965
- var l = function() {
1966
- Ye || (Ye = !0, P("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", c));
1967
- };
1968
- l.isReactWarning = !0, Object.defineProperty(t, "key", {
1969
- get: l,
1970
- configurable: !0
1971
- });
1972
- }
1973
- }
1974
- function Ot(t, c) {
1975
- {
1976
- var l = function() {
1977
- Je || (Je = !0, P("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", c));
1978
- };
1979
- l.isReactWarning = !0, Object.defineProperty(t, "ref", {
1980
- get: l,
1981
- configurable: !0
1982
- });
1983
- }
1984
- }
1985
- var It = function(t, c, l, h, b, R, p) {
1986
- var v = {
1987
- // This tag allows us to uniquely identify this as a React Element
1988
- $$typeof: o,
1989
- // Built-in properties that belong on the element
1990
- type: t,
1991
- key: c,
1992
- ref: l,
1993
- props: p,
1994
- // Record the component responsible for creating this element.
1995
- _owner: R
1996
- };
1997
- return v._store = {}, Object.defineProperty(v._store, "validated", {
1998
- configurable: !1,
1999
- enumerable: !1,
2000
- writable: !0,
2001
- value: !1
2002
- }), Object.defineProperty(v, "_self", {
2003
- configurable: !1,
2004
- enumerable: !1,
2005
- writable: !1,
2006
- value: h
2007
- }), Object.defineProperty(v, "_source", {
2008
- configurable: !1,
2009
- enumerable: !1,
2010
- writable: !1,
2011
- value: b
2012
- }), Object.freeze && (Object.freeze(v.props), Object.freeze(v)), v;
2013
- };
2014
- function Tt(t, c, l, h, b) {
2015
- {
2016
- var R, p = {}, v = null, $ = null;
2017
- l !== void 0 && (Ge(l), v = "" + l), wt(c) && (Ge(c.key), v = "" + c.key), St(c) && ($ = c.ref, Ct(c, b));
2018
- for (R in c)
2019
- ve.call(c, R) && !bt.hasOwnProperty(R) && (p[R] = c[R]);
2020
- if (t && t.defaultProps) {
2021
- var j = t.defaultProps;
2022
- for (R in j)
2023
- p[R] === void 0 && (p[R] = j[R]);
2024
- }
2025
- if (v || $) {
2026
- var L = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
2027
- v && Rt(p, L), $ && Ot(p, L);
2028
- }
2029
- return It(t, v, $, b, h, oe.current, p);
2030
- }
2031
- }
2032
- var ke = U.ReactCurrentOwner, He = U.ReactDebugCurrentFrame;
2033
- function re(t) {
2034
- if (t) {
2035
- var c = t._owner, l = me(t.type, t._source, c ? c.type : null);
2036
- He.setExtraStackFrame(l);
2037
- } else
2038
- He.setExtraStackFrame(null);
2039
- }
2040
- var Pe;
2041
- Pe = !1;
2042
- function Ne(t) {
2043
- return typeof t == "object" && t !== null && t.$$typeof === o;
2044
- }
2045
- function ze() {
2046
- {
2047
- if (ke.current) {
2048
- var t = G(ke.current.type);
2049
- if (t)
2050
- return `
2051
-
2052
- Check the render method of \`` + t + "`.";
2053
- }
2054
- return "";
2055
- }
2056
- }
2057
- function kt(t) {
2058
- {
2059
- if (t !== void 0) {
2060
- var c = t.fileName.replace(/^.*[\\\/]/, ""), l = t.lineNumber;
2061
- return `
2062
-
2063
- Check your code at ` + c + ":" + l + ".";
2064
- }
2065
- return "";
2066
- }
2067
- }
2068
- var Xe = {};
2069
- function Pt(t) {
2070
- {
2071
- var c = ze();
2072
- if (!c) {
2073
- var l = typeof t == "string" ? t : t.displayName || t.name;
2074
- l && (c = `
2075
-
2076
- Check the top-level render call using <` + l + ">.");
2077
- }
2078
- return c;
2079
- }
2080
- }
2081
- function Ze(t, c) {
2082
- {
2083
- if (!t._store || t._store.validated || t.key != null)
2084
- return;
2085
- t._store.validated = !0;
2086
- var l = Pt(c);
2087
- if (Xe[l])
2088
- return;
2089
- Xe[l] = !0;
2090
- var h = "";
2091
- t && t._owner && t._owner !== ke.current && (h = " It was passed a child from " + G(t._owner.type) + "."), re(t), P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', l, h), re(null);
2092
- }
2093
- }
2094
- function Qe(t, c) {
2095
- {
2096
- if (typeof t != "object")
2097
- return;
2098
- if (Ie(t))
2099
- for (var l = 0; l < t.length; l++) {
2100
- var h = t[l];
2101
- Ne(h) && Ze(h, c);
2102
- }
2103
- else if (Ne(t))
2104
- t._store && (t._store.validated = !0);
2105
- else if (t) {
2106
- var b = k(t);
2107
- if (typeof b == "function" && b !== t.entries)
2108
- for (var R = b.call(t), p; !(p = R.next()).done; )
2109
- Ne(p.value) && Ze(p.value, c);
2110
- }
2111
- }
2112
- }
2113
- function Nt(t) {
2114
- {
2115
- var c = t.type;
2116
- if (c == null || typeof c == "string")
2117
- return;
2118
- var l;
2119
- if (typeof c == "function")
2120
- l = c.propTypes;
2121
- else if (typeof c == "object" && (c.$$typeof === g || // Note: Memo only checks outer props here.
2122
- // Inner props are checked in the reconciler.
2123
- c.$$typeof === y))
2124
- l = c.propTypes;
2125
- else
2126
- return;
2127
- if (l) {
2128
- var h = G(c);
2129
- vt(l, t.props, "prop", h, t);
2130
- } else if (c.PropTypes !== void 0 && !Pe) {
2131
- Pe = !0;
2132
- var b = G(c);
2133
- P("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", b || "Unknown");
2134
- }
2135
- typeof c.getDefaultProps == "function" && !c.getDefaultProps.isReactClassApproved && P("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
2136
- }
2137
- }
2138
- function jt(t) {
2139
- {
2140
- for (var c = Object.keys(t.props), l = 0; l < c.length; l++) {
2141
- var h = c[l];
2142
- if (h !== "children" && h !== "key") {
2143
- re(t), P("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", h), re(null);
2144
- break;
2145
- }
2146
- }
2147
- t.ref !== null && (re(t), P("Invalid attribute `ref` supplied to `React.Fragment`."), re(null));
2148
- }
2149
- }
2150
- function et(t, c, l, h, b, R) {
2151
- {
2152
- var p = W(t);
2153
- if (!p) {
2154
- var v = "";
2155
- (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (v += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
2156
- var $ = kt(b);
2157
- $ ? v += $ : v += ze();
2158
- var j;
2159
- t === null ? j = "null" : Ie(t) ? j = "array" : t !== void 0 && t.$$typeof === o ? (j = "<" + (G(t.type) || "Unknown") + " />", v = " 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, v);
2160
- }
2161
- var L = Tt(t, c, l, b, R);
2162
- if (L == null)
2163
- return L;
2164
- if (p) {
2165
- var B = c.children;
2166
- if (B !== void 0)
2167
- if (h)
2168
- if (Ie(B)) {
2169
- for (var ie = 0; ie < B.length; ie++)
2170
- Qe(B[ie], t);
2171
- Object.freeze && Object.freeze(B);
2172
- } else
2173
- P("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
2174
- else
2175
- Qe(B, t);
2176
- }
2177
- return t === i ? jt(L) : Nt(L), L;
2178
- }
2179
- }
2180
- function Lt(t, c, l) {
2181
- return et(t, c, l, !0);
2182
- }
2183
- function At(t, c, l) {
2184
- return et(t, c, l, !1);
2185
- }
2186
- var Vt = At, Mt = Lt;
2187
- ce.Fragment = i, ce.jsx = Vt, ce.jsxs = Mt;
2188
- }()), ce;
2189
- }
2190
- (function(r) {
2191
- process.env.NODE_ENV === "production" ? r.exports = wr() : r.exports = Cr();
2192
- })(Sr);
2193
- const Rr = Ve.jsx;
2194
- function jr(r) {
2195
- const o = Gt(null), e = br(r), i = e.jsBridge, n = (f) => /* @__PURE__ */ Rr(o.Provider, { value: e, children: f.children }), a = () => {
2196
- const f = M.useContext(o);
2197
- if (!f)
2198
- throw new Error("LiveProvider never found.");
2199
- return f;
2200
- }, u = () => e, d = () => e.$RTC, g = () => d(), _ = () => async (f) => await e.connect(f);
2201
- function E(f, C, A = []) {
2202
- const S = a(), N = [S, name, ...A], V = () => S.keyframes.off(f, C);
2203
- return M.useEffect(() => (S.keyframes.on(f, C), V), N), V;
2204
- }
2205
- function y() {
2206
- const f = a();
2207
- return {
2208
- connect: async (T) => await f.connect(T),
2209
- broadcast: async (T, F, te = 0) => await f.broadcast(T, F, te),
2210
- exit: async () => await f.exit(),
2211
- kick: async (T) => await f.kick(T),
2212
- toggleMicro: (T) => f.toggleMicro(T),
2213
- forbidMicro: async (T, F = []) => await f.forbidMicro(T, F),
2214
- forbidSync: (T, F = []) => f.forbidSync(T, F),
2215
- sendKeyframe: (T, F) => f.sendKeyframe(T, F),
2216
- getFramesByKey: (T) => f.getFramesByKey(T),
2217
- setSelfInfo: (T) => f.setSelfInfo(T),
2218
- updateStatus: (T, F, te, he) => f.updateStatus(T, F, te, he)
2219
- };
2220
- }
2221
- function I(f) {
2222
- const C = a(), [A, S] = M.useState(C.getFramesByKey(f));
2223
- M.useEffect(() => {
2224
- const V = (se) => S(se), W = f, H = V;
2225
- return C.keyframes.on(W, H), () => C.keyframes.off(W, H);
2226
- }, [C]);
2227
- const N = M.useCallback(
2228
- (V) => C.sendKeyframe(f, V),
2229
- [C]
2230
- );
2231
- return [A, N];
2232
- }
2233
- function m(f, C, A = []) {
2234
- const S = a(), N = () => S.off(f, C), V = [S, f, ...A];
2235
- return M.useEffect(() => (S.on(f, C), N), V), N;
2236
- }
2237
- function D() {
2238
- const f = a(), [C, A] = M.useState(f.state);
2239
- return M.useEffect(() => {
2240
- const S = (N) => A(N);
2241
- return f.on("stateChange", S), () => f.off("stateChange", S);
2242
- }, [f]), C;
2243
- }
2244
- function w() {
2245
- const f = a();
2246
- return {
2247
- join: (W) => f.$RTC.join(W),
2248
- quit: () => f.$RTC.quit(),
2249
- shock: () => {
2250
- var W, H;
2251
- return (H = (W = f.$RTC).shock) == null ? void 0 : H.call(W);
2252
- },
2253
- toggleMicro: (W) => f.$RTC.toggleMicro(W),
2254
- detectMicro: () => f.$RTC.detectMicro()
2255
- };
2256
- }
2257
- function k(f, C, A = []) {
2258
- const S = a(), N = () => S.$RTC.off(f, C), V = [S, f, ...A];
2259
- return M.useEffect(() => (S.$RTC.on(f, C), N), V), N;
2260
- }
2261
- function U() {
2262
- const f = a(), [C, A] = M.useState(
2263
- f.selfInfo || {}
2264
- ), S = (V) => A(V);
2265
- M.useEffect(() => (f.on("selfInfoUpdate", S), () => f.off("selfInfoUpdate", S)), [f]);
2266
- const N = M.useCallback(
2267
- async (V) => await f.setSelfInfo(V),
2268
- [f]
2269
- );
2270
- return [C, N];
2271
- }
2272
- function P() {
2273
- const f = a(), [C, A] = M.useState(
2274
- f.snapshot
2275
- );
2276
- return M.useEffect(() => {
2277
- const S = (N) => A(N);
2278
- return f.on("keyframes", S), () => f.off("keyframes", S);
2279
- }), C;
2280
- }
2281
- function de() {
2282
- const f = a(), [C, A] = M.useState(f.userList), S = (N) => A(N);
2283
- return M.useEffect(() => (f.on("userListUpdate", S), () => f.off("userListUpdate", S)), [f]), C;
2284
- }
2285
- return {
2286
- live: e,
2287
- jsBridge: i,
2288
- LiveProvider: n,
2289
- unsafe__useLiveInstance: u,
2290
- unsafe__useRTCInstance: g,
2291
- useConnect: _,
2292
- useKeyframe: I,
2293
- useKeyframeUpdateCallback: E,
2294
- useLiveAction: y,
2295
- useLiveEventCallback: m,
2296
- useLiveState: D,
2297
- useRTCAction: w,
2298
- useRTCEventCallback: k,
2299
- useSelfInfo: U,
2300
- useKeyframesSnapshot: P,
2301
- useUserList: de
2302
- };
2303
- }
2304
- export {
2305
- it as BrowserRTC,
2306
- nt as BrowserRTC4Chime,
2307
- lt as BuiltInRTCType,
2308
- J as BuiltinActionType,
2309
- q as BuiltinEventType,
2310
- K as Command,
2311
- Me as CoreRTC,
2312
- yr as Live,
2313
- x as LiveState,
2314
- tr as MemUserStatus,
2315
- Z as MicroStatus,
2316
- ne as RTCJoinedInfoCodeEnum,
2317
- Q as RTCType,
2318
- er as UserStatus,
2319
- st as VRWebViewRTC,
2320
- ir as WebSocketCloseError,
2321
- rr as WebSocketErrorType,
2322
- Ae as WebSocketState,
2323
- Er as _clearLiveInstanceIfNeed,
2324
- br as createLive,
2325
- jr as createLiveReact,
2326
- Nr as parseLiveMsg,
2327
- nr as parseWSClsErr
2328
- };