@zegocloud/zego-uikit-prebuilt 1.8.13 → 1.8.14

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/index.d.ts CHANGED
@@ -148,98 +148,106 @@ declare interface ZegoCloudRoomConfig {
148
148
  onInRoomMessageReceived?: (messageInfo: InRoomMessageInfo) => void; // Callback for room chat message
149
149
  onInRoomCommandReceived?: (fromUser: ZegoUser, command: string) => void; // Callback for room command message
150
150
  onInRoomTextMessageReceived?: (messages: ZegoSignalingInRoomTextMessage[]) => void; // Callback for room signaling text message
151
+ onInRoomCustomCommandReceived?: (command: ZegoSignalingInRoomCommandMessage[]) => void; // Callback for room custom command message
151
152
  }
152
153
 
153
154
  export enum RightPanelExpandedType {
154
- None = "None",
155
- RoomDetails = "RoomDetails",
156
- RoomMembers = "RoomMembers",
157
- RoomMessages = "RoomMessages",
155
+ None = "None",
156
+ RoomDetails = "RoomDetails",
157
+ RoomMembers = "RoomMembers",
158
+ RoomMessages = "RoomMessages",
158
159
  }
159
160
  declare interface ZegoSignalingInRoomTextMessage {
160
- messageID: string;
161
- timestamp: number;
162
- orderKey: number;
163
- senderUserID: string;
164
- text: string;
161
+ messageID: string;
162
+ timestamp: number;
163
+ orderKey: number;
164
+ senderUserID: string;
165
+ text: string;
166
+ }
167
+ declare interface ZegoSignalingInRoomCommandMessage {
168
+ messageID: string;
169
+ timestamp: number;
170
+ orderKey: number;
171
+ senderUserID: string;
172
+ command: object;
165
173
  }
174
+
166
175
  declare enum ZegoInvitationType {
167
- VoiceCall = 0,
168
- VideoCall,
176
+ VoiceCall = 0,
177
+ VideoCall,
169
178
  }
170
179
  declare interface ZegoCallInvitationConfig {
171
- enableCustomCallInvitationWaitingPage?: boolean; // Whether to customize the call invitation waiting page, default false
172
- enableCustomCallInvitationDialog?: boolean; // Whether to customize the call invitation pop-up window, the default is false
173
- enableNotifyWhenAppRunningInBackgroundOrQuit?: boolean; // Notify users when the app is running in the background or the app is killed, default false
174
- ringtoneConfig?: {
175
- incomingCallUrl?: string; // ringtone when receiving
176
- outgoingCallUrl?: string; // Outgoing ringtone
177
- };
178
- // Callback when entering the call waiting page, return the cancel method, if called, you can cancel the invitation
179
- onWaitingPageWhenSending?: (
180
- callType: ZegoInvitationType,
181
- callees: ZegoUser[],
182
- cancel: CancelCallInvitationFunc
183
- ) => void;
180
+ enableCustomCallInvitationWaitingPage?: boolean; // Whether to customize the call invitation waiting page, default false
181
+ enableCustomCallInvitationDialog?: boolean; // Whether to customize the call invitation pop-up window, the default is false
182
+ enableNotifyWhenAppRunningInBackgroundOrQuit?: boolean; // Notify users when the app is running in the background or the app is killed, default false
183
+ ringtoneConfig?: {
184
+ incomingCallUrl?: string; // ringtone when receiving
185
+ outgoingCallUrl?: string; // Outgoing ringtone
186
+ };
187
+ // Callback when entering the call waiting page, return the cancel method, if called, you can cancel the invitation
188
+ onWaitingPageWhenSending?: (
189
+ callType: ZegoInvitationType,
190
+ callees: ZegoUser[],
191
+ cancel: CancelCallInvitationFunc
192
+ ) => void;
184
193
 
185
- // When the callee receives the invitation, the invitation pop-up window displays the callback, and returns the accept and refuse methods to bind the UI to the user
186
- onConfirmDialogWhenReceiving?: (
187
- callType: ZegoInvitationType,
188
- caller: ZegoUser,
189
- refuse: RefuseCallInvitationFunc,
190
- accept: AcceptCallInvitationFunc,
191
- data: string
192
- ) => void;
194
+ // When the callee receives the invitation, the invitation pop-up window displays the callback, and returns the accept and refuse methods to bind the UI to the user
195
+ onConfirmDialogWhenReceiving?: (
196
+ callType: ZegoInvitationType,
197
+ caller: ZegoUser,
198
+ refuse: RefuseCallInvitationFunc,
199
+ accept: AcceptCallInvitationFunc,
200
+ data: string
201
+ ) => void;
193
202
 
194
- // Callback before entering the room after accepting the invitation, used to set the room configuration, automatically join the room internally, and the room configuration is based on the default ZegoInvitationType
195
- onSetRoomConfigBeforeJoining?: (
196
- callType: ZegoInvitationType
197
- ) => ZegoCloudRoomConfig;
203
+ // Callback before entering the room after accepting the invitation, used to set the room configuration, automatically join the room internally, and the room configuration is based on the default ZegoInvitationType
204
+ onSetRoomConfigBeforeJoining?: (callType: ZegoInvitationType) => ZegoCloudRoomConfig;
198
205
 
199
- // Call invitation end callback (call rejected, timeout, busy, user exits the room where the call was invited, etc.)
200
- onCallInvitationEnded?: (
201
- reason: CallInvitationEndReason,
202
- data: string
203
- ) => void;
206
+ // Call invitation end callback (call rejected, timeout, busy, user exits the room where the call was invited, etc.)
207
+ onCallInvitationEnded?: (reason: CallInvitationEndReason, data: string) => void;
204
208
 
205
- // After Prebuilt receives the call invitation, it converts the internal data into corresponding data and throws
206
- onIncomingCallReceived?: (
207
- callID: string,
208
- caller: ZegoUser,
209
- callType: ZegoInvitationType,
210
- callees: ZegoUser[]
211
- ) => void;
212
- // When the caller cancels the call, convert the internal data to the corresponding data and throw it.
213
- onIncomingCallCanceled?: (callID: string, caller: ZegoUser) => void;
214
- // After the callee accepts the invitation, the caller will receive the callback, convert the internal data into corresponding data and throw it.
215
- onOutgoingCallAccepted?: (callID: string, callee: ZegoUser) => void;
216
- // When the callee is in a call and rejects the invitation, the caller will receive this callback, convert the internal data into corresponding data and throw it.
217
- onOutgoingCallRejected?: (callID: string, callee: ZegoUser) => void;
218
- // When the callee voluntarily refuses the call, the caller will receive this callback, convert the internal data into corresponding data and throw it.
219
- onOutgoingCallDeclined?: (callID: string, callee: ZegoUser) => void;
220
- //When the callee fails to respond to the invitation after a timeout, the callee will receive the callback, convert the internal data into corresponding data and throw it.
221
- onIncomingCallTimeout?: (callID: string, caller: ZegoUser) => void;
222
- //When the call exceeds the fixed time, if there are still callees who do not respond, the caller will receive the callback, convert the internal data into corresponding data and throw it.
223
- onOutgoingCallTimeout?: (callID: string, callees: ZegoUser[]) => void;
209
+ // After Prebuilt receives the call invitation, it converts the internal data into corresponding data and throws
210
+ onIncomingCallReceived?: (
211
+ callID: string,
212
+ caller: ZegoUser,
213
+ callType: ZegoInvitationType,
214
+ callees: ZegoUser[]
215
+ ) => void;
216
+ // When the caller cancels the call, convert the internal data to the corresponding data and throw it.
217
+ onIncomingCallCanceled?: (callID: string, caller: ZegoUser) => void;
218
+ // After the callee accepts the invitation, the caller will receive the callback, convert the internal data into corresponding data and throw it.
219
+ onOutgoingCallAccepted?: (callID: string, callee: ZegoUser) => void;
220
+ // When the callee is in a call and rejects the invitation, the caller will receive this callback, convert the internal data into corresponding data and throw it.
221
+ onOutgoingCallRejected?: (callID: string, callee: ZegoUser) => void;
222
+ // When the callee voluntarily refuses the call, the caller will receive this callback, convert the internal data into corresponding data and throw it.
223
+ onOutgoingCallDeclined?: (callID: string, callee: ZegoUser) => void;
224
+ //When the callee fails to respond to the invitation after a timeout, the callee will receive the callback, convert the internal data into corresponding data and throw it.
225
+ onIncomingCallTimeout?: (callID: string, caller: ZegoUser) => void;
226
+ //When the call exceeds the fixed time, if there are still callees who do not respond, the caller will receive the callback, convert the internal data into corresponding data and throw it.
227
+ onOutgoingCallTimeout?: (callID: string, callees: ZegoUser[]) => void;
224
228
  }
225
229
 
226
230
  declare interface ZegoSignalingPluginNotificationConfig {
227
- resourcesID?: string;
228
- title?: string;
229
- message?: string;
231
+ resourcesID?: string;
232
+ title?: string;
233
+ message?: string;
230
234
  }
231
235
 
232
236
  declare enum CallInvitationEndReason {
233
- Declined = "Declined",
234
- Timeout = "Timeout",
235
- Canceled = "Canceled",
236
- Busy = "Busy",
237
- LeaveRoom = "LeaveRoom",
237
+ Declined = "Declined",
238
+ Timeout = "Timeout",
239
+ Canceled = "Canceled",
240
+ Busy = "Busy",
241
+ LeaveRoom = "LeaveRoom",
238
242
  }
239
243
  declare type CancelCallInvitationFunc = (data?: string) => void; // cancel invitation
240
244
  declare type AcceptCallInvitationFunc = (data?: string) => void; // accept invitation
241
245
  declare type RefuseCallInvitationFunc = (data?: string) => void; // reject invitation
242
-
246
+ declare enum MessagePriority {
247
+ Low = 1,
248
+ Medium = 2,
249
+ High = 3,
250
+ }
243
251
  export declare class ZegoUIKitPrebuilt {
244
252
  static core: ZegoCloudRTCCore | undefined;
245
253
  static _instance: ZegoUIKitPrebuilt;
@@ -295,5 +303,6 @@ export declare class ZegoUIKitPrebuilt {
295
303
  errorInvitees: ZegoUser[];
296
304
  }>;
297
305
  sendInRoomCommand(command: string, toUserIDs: string[]): Promise<boolean>;
306
+ sendInRoomCustomCommand(command: object, priority?: MessagePriority): Promise<ZegoSignalingInRoomCommandMessage>;
298
307
  hangUp(): void;
299
308
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zegocloud/zego-uikit-prebuilt",
3
- "version": "1.8.13",
3
+ "version": "1.8.14",
4
4
  "description": "zegocloud prebuilt meeting webrtc sdk",
5
5
  "keywords": [
6
6
  "sdk",
@@ -2233,7 +2233,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2233
2233
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2234
2234
 
2235
2235
  "use strict";
2236
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoUIKitPrebuilt\": function() { return /* binding */ ZegoUIKitPrebuilt; }\n/* harmony export */ });\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js\");\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom/client */ \"./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/client.js\");\n/* harmony import */ var _model_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./model/index */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _modules_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/index */ \"./src/sdk/modules/index.ts\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _view_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./view/index */ \"./src/sdk/view/index.tsx\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\nclass ZegoUIKitPrebuilt {\n constructor() {\n this.hasJoinedRoom = false;\n this.express = _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore._zg;\n }\n get localStream() {\n var _a;\n return (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.localStream;\n }\n static generateKitTokenForTest(appID, serverSecret, roomID, userID, userName, ExpirationSeconds) {\n return (0,_util__WEBPACK_IMPORTED_MODULE_4__.generatePrebuiltToken)(appID, serverSecret, roomID, userID, userName, ExpirationSeconds);\n }\n static generateKitTokenForProduction(appID, token, roomID, userID, userName) {\n return (token +\n \"#\" +\n window.btoa(JSON.stringify({\n userID,\n roomID,\n userName: encodeURIComponent(userName || \"\"),\n appID,\n })));\n }\n static create(kitToken) {\n if (!ZegoUIKitPrebuilt.core && kitToken) {\n ZegoUIKitPrebuilt.core = _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore.getInstance(kitToken);\n ZegoUIKitPrebuilt._instance = new ZegoUIKitPrebuilt();\n }\n return ZegoUIKitPrebuilt._instance;\n }\n addPlugins(plugins) {\n var _a, _b, _c;\n // @ts-ignore\n (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.addPlugins(plugins);\n if ((_b = ZegoUIKitPrebuilt.core) === null || _b === void 0 ? void 0 : _b._zimManager) {\n (_c = ZegoUIKitPrebuilt.core) === null || _c === void 0 ? void 0 : _c._zimManager.notifyJoinRoom((type, config, mode) => {\n var _a, _b, _c;\n console.warn(\"notifyJoinRoom\", type, config);\n if (config.autoLeaveRoomWhenOnlySelfInRoom === undefined) {\n config.autoLeaveRoomWhenOnlySelfInRoom = mode === _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n }\n config.turnOnMicrophoneWhenJoining = (_a = config.turnOnCameraWhenJoining) !== null && _a !== void 0 ? _a : true;\n if (type === _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall) {\n config.turnOnCameraWhenJoining = (_b = config.turnOnCameraWhenJoining) !== null && _b !== void 0 ? _b : false;\n }\n if (type === _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall) {\n config.turnOnCameraWhenJoining = (_c = config.turnOnCameraWhenJoining) !== null && _c !== void 0 ? _c : true;\n }\n // ZegoCloudRoomConfig部分参数不允许自定义\n let roomConfig = Object.assign(config, {\n showPreJoinView: false,\n showLeavingView: false,\n sharedLinks: [],\n scenario: {\n mode: mode,\n },\n });\n ZegoUIKitPrebuilt.core.status = {\n loginRsp: false,\n videoRefuse: undefined,\n audioRefuse: undefined,\n };\n this.joinRoom(roomConfig);\n });\n }\n }\n joinRoom(roomConfig) {\n if (!ZegoUIKitPrebuilt.core) {\n console.error(\"【ZEGOCLOUD】 please call init first !!\");\n return;\n }\n if (this.hasJoinedRoom) {\n console.error(\"【ZEGOCLOUD】joinRoom repeat !!\");\n return;\n }\n let div;\n if (!roomConfig || !roomConfig.container) {\n console.warn(\"【ZEGOCLOUD】joinRoom/roomConfig/container required !!\");\n div = document.createElement(\"div\");\n div.style.position = \"fixed\";\n div.style.width = \"100%\";\n div.style.height = (0,_util__WEBPACK_IMPORTED_MODULE_4__.isPc)() ? \"100vh\" : \"100%\";\n div.style.minWidth = \"345px\";\n div.style.top = \"0px\";\n div.style.left = \"0px\";\n div.style.zIndex = \"100\";\n div.style.backgroundColor = \"#FFFFFF\";\n div.style.overflow = \"auto\";\n document.body.appendChild(div);\n roomConfig = Object.assign(Object.assign({}, roomConfig), {\n container: div,\n });\n }\n const result = ZegoUIKitPrebuilt.core.setConfig(roomConfig);\n if (result) {\n this.root = react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot(roomConfig.container);\n this.root.render((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_view_index__WEBPACK_IMPORTED_MODULE_5__.ZegoCloudRTCKitComponent, { core: ZegoUIKitPrebuilt.core, unmount: () => {\n var _a;\n // 单纯的销毁渲染的节点,不会销毁实例\n (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();\n this.root = undefined;\n this.hasJoinedRoom = false;\n div && div.remove();\n } }));\n this.hasJoinedRoom = true;\n }\n else {\n console.error(\"【ZEGOCLOUD】joinRoom parameter error !!\");\n }\n }\n destroy() {\n var _a, _b, _c, _d;\n (_b = (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.leaveRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n ZegoUIKitPrebuilt.core = undefined;\n // @ts-ignore\n _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore._instance = undefined;\n (_d = (_c = this.root) === null || _c === void 0 ? void 0 : _c.unmount) === null || _d === void 0 ? void 0 : _d.call(_c);\n this.root = undefined;\n this.hasJoinedRoom = false;\n }\n setCallInvitationConfig(config) {\n var _a, _b;\n if (!((_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a._zimManager)) {\n console.error(\"【ZEGOCLOUD】Please add ZIM plugin first\");\n return;\n }\n if (!config)\n return;\n (_b = ZegoUIKitPrebuilt.core) === null || _b === void 0 ? void 0 : _b._zimManager.setCallInvitationConfig(config);\n }\n // 发起邀请\n sendCallInvitation(params) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (!((_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a._zimManager)) {\n console.error(\"【ZEGOCLOUD】Please add ZIM plugin first\");\n return Promise.reject(\"ZEGOCLOUD】Please add ZIM plugin first\");\n }\n const { callees, callType, timeout = 60, data = \"\", notificationConfig } = params;\n if (!Array.isArray(callees) || callees.length < 1) {\n return Promise.reject(\"【ZEGOCLOUD】sendCallInvitation params error: callees !!\");\n }\n else if (callees.length > 9) {\n return Promise.reject(\"【ZEGOCLOUD】Maximum number of users exceeded\");\n }\n if (callType !== _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall && callType !== _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall) {\n return Promise.reject(\"【ZEGOCLOUD】sendCallInvitation params error: callType !!\");\n }\n return ZegoUIKitPrebuilt.core._zimManager.sendInvitation(callees, callType, timeout, data, notificationConfig);\n });\n }\n sendInRoomCommand(command, toUserIDs) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield ZegoUIKitPrebuilt.core.sendInRoomCommand(command, toUserIDs);\n });\n }\n // 主动退出房间\n hangUp() {\n var _a;\n (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.eventEmitter.emit(\"hangUp\");\n }\n}\nZegoUIKitPrebuilt.Host = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\nZegoUIKitPrebuilt.Cohost = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\nZegoUIKitPrebuilt.Audience = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\nZegoUIKitPrebuilt.OneONoneCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\nZegoUIKitPrebuilt.GroupCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall;\nZegoUIKitPrebuilt.LiveStreaming = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming;\nZegoUIKitPrebuilt.VideoConference = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.VideoConference;\nZegoUIKitPrebuilt.VideoResolution_180P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._180P;\nZegoUIKitPrebuilt.VideoResolution_360P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P;\nZegoUIKitPrebuilt.VideoResolution_480P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._480P;\nZegoUIKitPrebuilt.VideoResolution_720P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._720P;\nZegoUIKitPrebuilt.LiveStreamingMode = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode;\nZegoUIKitPrebuilt.InvitationTypeVoiceCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall;\nZegoUIKitPrebuilt.InvitationTypeVideoCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall;\nZegoUIKitPrebuilt.ConsoleDebug = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Debug;\nZegoUIKitPrebuilt.ConsoleInfo = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Info;\nZegoUIKitPrebuilt.ConsoleWarning = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Warning;\nZegoUIKitPrebuilt.ConsoleError = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Error;\nZegoUIKitPrebuilt.ConsoleNone = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.None;\nZegoUIKitPrebuilt.VideoMixinOutputResolution = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoMixinOutputResolution;\nZegoUIKitPrebuilt.RightPanelExpandedType = _model_index__WEBPACK_IMPORTED_MODULE_2__.RightPanelExpandedType;\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/index.tsx?");
2236
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoUIKitPrebuilt\": function() { return /* binding */ ZegoUIKitPrebuilt; }\n/* harmony export */ });\n/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ \"./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js\");\n/* harmony import */ var react_dom_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom/client */ \"./node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/client.js\");\n/* harmony import */ var _model_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./model/index */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _modules_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/index */ \"./src/sdk/modules/index.ts\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _view_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./view/index */ \"./src/sdk/view/index.tsx\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\nclass ZegoUIKitPrebuilt {\n constructor() {\n this.hasJoinedRoom = false;\n this.express = _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore._zg;\n }\n get localStream() {\n var _a;\n return (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.localStream;\n }\n static generateKitTokenForTest(appID, serverSecret, roomID, userID, userName, ExpirationSeconds) {\n return (0,_util__WEBPACK_IMPORTED_MODULE_4__.generatePrebuiltToken)(appID, serverSecret, roomID, userID, userName, ExpirationSeconds);\n }\n static generateKitTokenForProduction(appID, token, roomID, userID, userName) {\n return (token +\n \"#\" +\n window.btoa(JSON.stringify({\n userID,\n roomID,\n userName: encodeURIComponent(userName || \"\"),\n appID,\n })));\n }\n static create(kitToken) {\n if (!ZegoUIKitPrebuilt.core && kitToken) {\n ZegoUIKitPrebuilt.core = _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore.getInstance(kitToken);\n ZegoUIKitPrebuilt._instance = new ZegoUIKitPrebuilt();\n }\n return ZegoUIKitPrebuilt._instance;\n }\n addPlugins(plugins) {\n var _a, _b, _c;\n // @ts-ignore\n (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.addPlugins(plugins);\n if ((_b = ZegoUIKitPrebuilt.core) === null || _b === void 0 ? void 0 : _b._zimManager) {\n (_c = ZegoUIKitPrebuilt.core) === null || _c === void 0 ? void 0 : _c._zimManager.notifyJoinRoom((type, config, mode) => {\n var _a, _b, _c;\n console.warn(\"notifyJoinRoom\", type, config);\n if (config.autoLeaveRoomWhenOnlySelfInRoom === undefined) {\n config.autoLeaveRoomWhenOnlySelfInRoom = mode === _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n }\n config.turnOnMicrophoneWhenJoining = (_a = config.turnOnCameraWhenJoining) !== null && _a !== void 0 ? _a : true;\n if (type === _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall) {\n config.turnOnCameraWhenJoining = (_b = config.turnOnCameraWhenJoining) !== null && _b !== void 0 ? _b : false;\n }\n if (type === _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall) {\n config.turnOnCameraWhenJoining = (_c = config.turnOnCameraWhenJoining) !== null && _c !== void 0 ? _c : true;\n }\n // ZegoCloudRoomConfig部分参数不允许自定义\n let roomConfig = Object.assign(config, {\n showPreJoinView: false,\n showLeavingView: false,\n sharedLinks: [],\n scenario: {\n mode: mode,\n },\n });\n ZegoUIKitPrebuilt.core.status = {\n loginRsp: false,\n videoRefuse: undefined,\n audioRefuse: undefined,\n };\n this.joinRoom(roomConfig);\n });\n }\n }\n joinRoom(roomConfig) {\n if (!ZegoUIKitPrebuilt.core) {\n console.error(\"【ZEGOCLOUD】 please call init first !!\");\n return;\n }\n if (this.hasJoinedRoom) {\n console.error(\"【ZEGOCLOUD】joinRoom repeat !!\");\n return;\n }\n let div;\n if (!roomConfig || !roomConfig.container) {\n console.warn(\"【ZEGOCLOUD】joinRoom/roomConfig/container required !!\");\n div = document.createElement(\"div\");\n div.style.position = \"fixed\";\n div.style.width = \"100%\";\n div.style.height = (0,_util__WEBPACK_IMPORTED_MODULE_4__.isPc)() ? \"100vh\" : \"100%\";\n div.style.minWidth = \"345px\";\n div.style.top = \"0px\";\n div.style.left = \"0px\";\n div.style.zIndex = \"100\";\n div.style.backgroundColor = \"#FFFFFF\";\n div.style.overflow = \"auto\";\n document.body.appendChild(div);\n roomConfig = Object.assign(Object.assign({}, roomConfig), {\n container: div,\n });\n }\n const result = ZegoUIKitPrebuilt.core.setConfig(roomConfig);\n if (result) {\n this.root = react_dom_client__WEBPACK_IMPORTED_MODULE_1__.createRoot(roomConfig.container);\n this.root.render((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_view_index__WEBPACK_IMPORTED_MODULE_5__.ZegoCloudRTCKitComponent, { core: ZegoUIKitPrebuilt.core, unmount: () => {\n var _a;\n // 单纯的销毁渲染的节点,不会销毁实例\n (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();\n this.root = undefined;\n this.hasJoinedRoom = false;\n div && div.remove();\n } }));\n this.hasJoinedRoom = true;\n }\n else {\n console.error(\"【ZEGOCLOUD】joinRoom parameter error !!\");\n }\n }\n destroy() {\n var _a, _b, _c, _d;\n (_b = (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.leaveRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n ZegoUIKitPrebuilt.core = undefined;\n // @ts-ignore\n _modules_index__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudRTCCore._instance = undefined;\n (_d = (_c = this.root) === null || _c === void 0 ? void 0 : _c.unmount) === null || _d === void 0 ? void 0 : _d.call(_c);\n this.root = undefined;\n this.hasJoinedRoom = false;\n }\n setCallInvitationConfig(config) {\n var _a, _b;\n if (!((_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a._zimManager)) {\n console.error(\"【ZEGOCLOUD】Please add ZIM plugin first\");\n return;\n }\n if (!config)\n return;\n (_b = ZegoUIKitPrebuilt.core) === null || _b === void 0 ? void 0 : _b._zimManager.setCallInvitationConfig(config);\n }\n // 发起邀请\n sendCallInvitation(params) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (!((_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a._zimManager)) {\n console.error(\"【ZEGOCLOUD】Please add ZIM plugin first\");\n return Promise.reject(\"ZEGOCLOUD】Please add ZIM plugin first\");\n }\n const { callees, callType, timeout = 60, data = \"\", notificationConfig } = params;\n if (!Array.isArray(callees) || callees.length < 1) {\n return Promise.reject(\"【ZEGOCLOUD】sendCallInvitation params error: callees !!\");\n }\n else if (callees.length > 9) {\n return Promise.reject(\"【ZEGOCLOUD】Maximum number of users exceeded\");\n }\n if (callType !== _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall && callType !== _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall) {\n return Promise.reject(\"【ZEGOCLOUD】sendCallInvitation params error: callType !!\");\n }\n return ZegoUIKitPrebuilt.core._zimManager.sendInvitation(callees, callType, timeout, data, notificationConfig);\n });\n }\n sendInRoomCommand(command, toUserIDs) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield ZegoUIKitPrebuilt.core.sendInRoomCommand(command, toUserIDs);\n });\n }\n sendInRoomCustomCommand(command, priority = 1) {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n if (!((_b = (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a._zimManager) === null || _b === void 0 ? void 0 : _b._zim)) {\n console.error(\"【ZEGOCLOUD】Please add ZIM plugin first\");\n return Promise.reject(\"ZEGOCLOUD】Please add ZIM plugin first\");\n }\n if (typeof command !== \"object\" || command === null) {\n return Promise.reject(\"【ZEGOCLOUD】sendInRoomCustomCommand params error: command !!\");\n }\n return yield ZegoUIKitPrebuilt.core._zimManager.sendMessage(command, priority);\n });\n }\n // 主动退出房间\n hangUp() {\n var _a;\n (_a = ZegoUIKitPrebuilt.core) === null || _a === void 0 ? void 0 : _a.eventEmitter.emit(\"hangUp\");\n }\n}\nZegoUIKitPrebuilt.Host = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\nZegoUIKitPrebuilt.Cohost = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\nZegoUIKitPrebuilt.Audience = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\nZegoUIKitPrebuilt.OneONoneCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\nZegoUIKitPrebuilt.GroupCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall;\nZegoUIKitPrebuilt.LiveStreaming = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming;\nZegoUIKitPrebuilt.VideoConference = _model_index__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.VideoConference;\nZegoUIKitPrebuilt.VideoResolution_180P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._180P;\nZegoUIKitPrebuilt.VideoResolution_360P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P;\nZegoUIKitPrebuilt.VideoResolution_480P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._480P;\nZegoUIKitPrebuilt.VideoResolution_720P = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._720P;\nZegoUIKitPrebuilt.LiveStreamingMode = _model_index__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode;\nZegoUIKitPrebuilt.InvitationTypeVoiceCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VoiceCall;\nZegoUIKitPrebuilt.InvitationTypeVideoCall = _model_index__WEBPACK_IMPORTED_MODULE_2__.ZegoInvitationType.VideoCall;\nZegoUIKitPrebuilt.ConsoleDebug = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Debug;\nZegoUIKitPrebuilt.ConsoleInfo = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Info;\nZegoUIKitPrebuilt.ConsoleWarning = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Warning;\nZegoUIKitPrebuilt.ConsoleError = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.Error;\nZegoUIKitPrebuilt.ConsoleNone = _model_index__WEBPACK_IMPORTED_MODULE_2__.ConsoleLevel.None;\nZegoUIKitPrebuilt.VideoMixinOutputResolution = _model_index__WEBPACK_IMPORTED_MODULE_2__.VideoMixinOutputResolution;\nZegoUIKitPrebuilt.RightPanelExpandedType = _model_index__WEBPACK_IMPORTED_MODULE_2__.RightPanelExpandedType;\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/index.tsx?");
2237
2237
 
2238
2238
  /***/ }),
2239
2239
 
@@ -2244,7 +2244,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2244
2244
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2245
2245
 
2246
2246
  "use strict";
2247
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CallInvitationEndReason\": function() { return /* binding */ CallInvitationEndReason; },\n/* harmony export */ \"ConsoleLevel\": function() { return /* binding */ ConsoleLevel; },\n/* harmony export */ \"CoreError\": function() { return /* binding */ CoreError; },\n/* harmony export */ \"LiveRole\": function() { return /* binding */ LiveRole; },\n/* harmony export */ \"LiveStreamingMode\": function() { return /* binding */ LiveStreamingMode; },\n/* harmony export */ \"ReasonForRefusedInviteToCoHost\": function() { return /* binding */ ReasonForRefusedInviteToCoHost; },\n/* harmony export */ \"RightPanelExpandedType\": function() { return /* binding */ RightPanelExpandedType; },\n/* harmony export */ \"ScenarioModel\": function() { return /* binding */ ScenarioModel; },\n/* harmony export */ \"UserListMenuItemType\": function() { return /* binding */ UserListMenuItemType; },\n/* harmony export */ \"VideoMixinLayoutType\": function() { return /* binding */ VideoMixinLayoutType; },\n/* harmony export */ \"VideoMixinOutputResolution\": function() { return /* binding */ VideoMixinOutputResolution; },\n/* harmony export */ \"VideoResolution\": function() { return /* binding */ VideoResolution; },\n/* harmony export */ \"ZegoInvitationType\": function() { return /* binding */ ZegoInvitationType; },\n/* harmony export */ \"ZegoStreamType\": function() { return /* binding */ ZegoStreamType; }\n/* harmony export */ });\nvar LiveRole;\n(function (LiveRole) {\n LiveRole[\"Host\"] = \"Host\";\n LiveRole[\"Cohost\"] = \"Cohost\";\n LiveRole[\"Audience\"] = \"Audience\";\n})(LiveRole || (LiveRole = {}));\nvar ScenarioModel;\n(function (ScenarioModel) {\n ScenarioModel[\"OneONoneCall\"] = \"OneONoneCall\";\n ScenarioModel[\"GroupCall\"] = \"GroupCall\";\n ScenarioModel[\"VideoConference\"] = \"VideoConference\";\n ScenarioModel[\"LiveStreaming\"] = \"LiveStreaming\";\n})(ScenarioModel || (ScenarioModel = {}));\nvar VideoResolution;\n(function (VideoResolution) {\n VideoResolution[\"_180P\"] = \"180p\";\n VideoResolution[\"_360P\"] = \"360p\";\n VideoResolution[\"_480P\"] = \"480p\";\n VideoResolution[\"_720P\"] = \"720p\";\n})(VideoResolution || (VideoResolution = {}));\nvar LiveStreamingMode;\n(function (LiveStreamingMode) {\n /**\n * @Deprecated StanderLive will be removed, please use LiveStreaming instead\n */\n LiveStreamingMode[\"StanderLive\"] = \"LiveStreaming\";\n /**\n * @Deprecated PremiumLive will be removed, please use InteractiveLiveStreaming instead\n */\n LiveStreamingMode[\"PremiumLive\"] = \"InteractiveLiveStreaming\";\n LiveStreamingMode[\"LiveStreaming\"] = \"LiveStreaming\";\n LiveStreamingMode[\"InteractiveLiveStreaming\"] = \"InteractiveLiveStreaming\";\n LiveStreamingMode[\"RealTimeLive\"] = \"RealTimeLive\";\n})(LiveStreamingMode || (LiveStreamingMode = {}));\nvar VideoMixinLayoutType;\n(function (VideoMixinLayoutType) {\n VideoMixinLayoutType[VideoMixinLayoutType[\"AutoLayout\"] = 0] = \"AutoLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"GridLayout\"] = 1] = \"GridLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"HorizontalLayout\"] = 2] = \"HorizontalLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"VerticalLayout\"] = 3] = \"VerticalLayout\";\n})(VideoMixinLayoutType || (VideoMixinLayoutType = {}));\nvar VideoMixinOutputResolution;\n(function (VideoMixinOutputResolution) {\n VideoMixinOutputResolution[\"_180P\"] = \"180p\";\n VideoMixinOutputResolution[\"_360P\"] = \"360p\";\n VideoMixinOutputResolution[\"_540P\"] = \"540p\";\n VideoMixinOutputResolution[\"_720P\"] = \"720p\";\n VideoMixinOutputResolution[\"_1080P\"] = \"1080p\";\n})(VideoMixinOutputResolution || (VideoMixinOutputResolution = {}));\nvar ConsoleLevel;\n(function (ConsoleLevel) {\n ConsoleLevel[\"Debug\"] = \"Debug\";\n ConsoleLevel[\"Info\"] = \"Info\";\n ConsoleLevel[\"Warning\"] = \"Warning\";\n ConsoleLevel[\"Error\"] = \"Error\";\n ConsoleLevel[\"None\"] = \"None\";\n})(ConsoleLevel || (ConsoleLevel = {}));\nvar RightPanelExpandedType;\n(function (RightPanelExpandedType) {\n RightPanelExpandedType[\"None\"] = \"None\";\n RightPanelExpandedType[\"RoomDetails\"] = \"RoomDetails\";\n RightPanelExpandedType[\"RoomMembers\"] = \"RoomMembers\";\n RightPanelExpandedType[\"RoomMessages\"] = \"RoomMessages\";\n})(RightPanelExpandedType || (RightPanelExpandedType = {}));\nvar ZegoStreamType;\n(function (ZegoStreamType) {\n ZegoStreamType[ZegoStreamType[\"main\"] = 0] = \"main\";\n ZegoStreamType[ZegoStreamType[\"media\"] = 1] = \"media\";\n ZegoStreamType[ZegoStreamType[\"screensharing\"] = 2] = \"screensharing\";\n})(ZegoStreamType || (ZegoStreamType = {}));\nvar CoreError;\n(function (CoreError) {\n CoreError[CoreError[\"notSupportCDNLive\"] = 10001] = \"notSupportCDNLive\";\n CoreError[CoreError[\"notSupportStandardLive\"] = 10002] = \"notSupportStandardLive\";\n})(CoreError || (CoreError = {}));\nvar ZegoInvitationType;\n(function (ZegoInvitationType) {\n ZegoInvitationType[ZegoInvitationType[\"VoiceCall\"] = 0] = \"VoiceCall\";\n ZegoInvitationType[ZegoInvitationType[\"VideoCall\"] = 1] = \"VideoCall\";\n ZegoInvitationType[ZegoInvitationType[\"RequestCoHost\"] = 2] = \"RequestCoHost\";\n ZegoInvitationType[ZegoInvitationType[\"InviteToCoHost\"] = 3] = \"InviteToCoHost\";\n ZegoInvitationType[ZegoInvitationType[\"RemoveCoHost\"] = 4] = \"RemoveCoHost\";\n})(ZegoInvitationType || (ZegoInvitationType = {}));\nvar CallInvitationEndReason;\n(function (CallInvitationEndReason) {\n CallInvitationEndReason[\"Declined\"] = \"Declined\";\n CallInvitationEndReason[\"Timeout\"] = \"Timeout\";\n CallInvitationEndReason[\"Canceled\"] = \"Canceled\";\n CallInvitationEndReason[\"Busy\"] = \"Busy\";\n CallInvitationEndReason[\"LeaveRoom\"] = \"LeaveRoom\";\n})(CallInvitationEndReason || (CallInvitationEndReason = {}));\nvar UserListMenuItemType;\n(function (UserListMenuItemType) {\n UserListMenuItemType[\"ChangePin\"] = \"ChangePin\";\n UserListMenuItemType[\"MuteMic\"] = \"MuteMic\";\n UserListMenuItemType[\"MuteCamera\"] = \"MuteCamera\";\n UserListMenuItemType[\"RemoveUser\"] = \"RemoveUser\";\n UserListMenuItemType[\"RemoveCohost\"] = \"RemoveCohost\";\n UserListMenuItemType[\"InviteCohost\"] = \"InviteCohost\";\n UserListMenuItemType[\"DisagreeRequestCohost\"] = \"disagreeRequestCohost\";\n UserListMenuItemType[\"AgreeRequestCohost\"] = \"agreeRequestCohost\";\n})(UserListMenuItemType || (UserListMenuItemType = {}));\nvar ReasonForRefusedInviteToCoHost;\n(function (ReasonForRefusedInviteToCoHost) {\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Disagree\"] = 0] = \"Disagree\";\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Busy\"] = 1] = \"Busy\";\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Timeout\"] = 2] = \"Timeout\";\n})(ReasonForRefusedInviteToCoHost || (ReasonForRefusedInviteToCoHost = {}));\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/model/index.ts?");
2247
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"CallInvitationEndReason\": function() { return /* binding */ CallInvitationEndReason; },\n/* harmony export */ \"ConsoleLevel\": function() { return /* binding */ ConsoleLevel; },\n/* harmony export */ \"CoreError\": function() { return /* binding */ CoreError; },\n/* harmony export */ \"LiveRole\": function() { return /* binding */ LiveRole; },\n/* harmony export */ \"LiveStreamingMode\": function() { return /* binding */ LiveStreamingMode; },\n/* harmony export */ \"ReasonForRefusedInviteToCoHost\": function() { return /* binding */ ReasonForRefusedInviteToCoHost; },\n/* harmony export */ \"RightPanelExpandedType\": function() { return /* binding */ RightPanelExpandedType; },\n/* harmony export */ \"ScenarioModel\": function() { return /* binding */ ScenarioModel; },\n/* harmony export */ \"UserListMenuItemType\": function() { return /* binding */ UserListMenuItemType; },\n/* harmony export */ \"VideoMixinLayoutType\": function() { return /* binding */ VideoMixinLayoutType; },\n/* harmony export */ \"VideoMixinOutputResolution\": function() { return /* binding */ VideoMixinOutputResolution; },\n/* harmony export */ \"VideoResolution\": function() { return /* binding */ VideoResolution; },\n/* harmony export */ \"ZegoInvitationType\": function() { return /* binding */ ZegoInvitationType; },\n/* harmony export */ \"ZegoStreamType\": function() { return /* binding */ ZegoStreamType; }\n/* harmony export */ });\nvar LiveRole;\n(function (LiveRole) {\n LiveRole[\"Host\"] = \"Host\";\n LiveRole[\"Cohost\"] = \"Cohost\";\n LiveRole[\"Audience\"] = \"Audience\";\n})(LiveRole || (LiveRole = {}));\nvar ScenarioModel;\n(function (ScenarioModel) {\n ScenarioModel[\"OneONoneCall\"] = \"OneONoneCall\";\n ScenarioModel[\"GroupCall\"] = \"GroupCall\";\n ScenarioModel[\"VideoConference\"] = \"VideoConference\";\n ScenarioModel[\"LiveStreaming\"] = \"LiveStreaming\";\n})(ScenarioModel || (ScenarioModel = {}));\nvar VideoResolution;\n(function (VideoResolution) {\n VideoResolution[\"_180P\"] = \"180p\";\n VideoResolution[\"_360P\"] = \"360p\";\n VideoResolution[\"_480P\"] = \"480p\";\n VideoResolution[\"_720P\"] = \"720p\";\n})(VideoResolution || (VideoResolution = {}));\nvar LiveStreamingMode;\n(function (LiveStreamingMode) {\n /**\n * @Deprecated StanderLive will be removed, please use LiveStreaming instead\n */\n LiveStreamingMode[\"StanderLive\"] = \"LiveStreaming\";\n /**\n * @Deprecated PremiumLive will be removed, please use InteractiveLiveStreaming instead\n */\n LiveStreamingMode[\"PremiumLive\"] = \"InteractiveLiveStreaming\";\n LiveStreamingMode[\"LiveStreaming\"] = \"LiveStreaming\";\n LiveStreamingMode[\"InteractiveLiveStreaming\"] = \"InteractiveLiveStreaming\";\n LiveStreamingMode[\"RealTimeLive\"] = \"RealTimeLive\";\n})(LiveStreamingMode || (LiveStreamingMode = {}));\nvar VideoMixinLayoutType;\n(function (VideoMixinLayoutType) {\n VideoMixinLayoutType[VideoMixinLayoutType[\"AutoLayout\"] = 0] = \"AutoLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"GridLayout\"] = 1] = \"GridLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"HorizontalLayout\"] = 2] = \"HorizontalLayout\";\n VideoMixinLayoutType[VideoMixinLayoutType[\"VerticalLayout\"] = 3] = \"VerticalLayout\";\n})(VideoMixinLayoutType || (VideoMixinLayoutType = {}));\nvar VideoMixinOutputResolution;\n(function (VideoMixinOutputResolution) {\n VideoMixinOutputResolution[\"_180P\"] = \"180p\";\n VideoMixinOutputResolution[\"_360P\"] = \"360p\";\n VideoMixinOutputResolution[\"_540P\"] = \"540p\";\n VideoMixinOutputResolution[\"_720P\"] = \"720p\";\n VideoMixinOutputResolution[\"_1080P\"] = \"1080p\";\n})(VideoMixinOutputResolution || (VideoMixinOutputResolution = {}));\nvar ConsoleLevel;\n(function (ConsoleLevel) {\n ConsoleLevel[\"Debug\"] = \"Debug\";\n ConsoleLevel[\"Info\"] = \"Info\";\n ConsoleLevel[\"Warning\"] = \"Warning\";\n ConsoleLevel[\"Error\"] = \"Error\";\n ConsoleLevel[\"None\"] = \"None\";\n})(ConsoleLevel || (ConsoleLevel = {}));\nvar RightPanelExpandedType;\n(function (RightPanelExpandedType) {\n RightPanelExpandedType[\"None\"] = \"None\";\n RightPanelExpandedType[\"RoomDetails\"] = \"RoomDetails\";\n RightPanelExpandedType[\"RoomMembers\"] = \"RoomMembers\";\n RightPanelExpandedType[\"RoomMessages\"] = \"RoomMessages\";\n})(RightPanelExpandedType || (RightPanelExpandedType = {}));\n;\nvar ZegoStreamType;\n(function (ZegoStreamType) {\n ZegoStreamType[ZegoStreamType[\"main\"] = 0] = \"main\";\n ZegoStreamType[ZegoStreamType[\"media\"] = 1] = \"media\";\n ZegoStreamType[ZegoStreamType[\"screensharing\"] = 2] = \"screensharing\";\n})(ZegoStreamType || (ZegoStreamType = {}));\nvar CoreError;\n(function (CoreError) {\n CoreError[CoreError[\"notSupportCDNLive\"] = 10001] = \"notSupportCDNLive\";\n CoreError[CoreError[\"notSupportStandardLive\"] = 10002] = \"notSupportStandardLive\";\n})(CoreError || (CoreError = {}));\nvar ZegoInvitationType;\n(function (ZegoInvitationType) {\n ZegoInvitationType[ZegoInvitationType[\"VoiceCall\"] = 0] = \"VoiceCall\";\n ZegoInvitationType[ZegoInvitationType[\"VideoCall\"] = 1] = \"VideoCall\";\n ZegoInvitationType[ZegoInvitationType[\"RequestCoHost\"] = 2] = \"RequestCoHost\";\n ZegoInvitationType[ZegoInvitationType[\"InviteToCoHost\"] = 3] = \"InviteToCoHost\";\n ZegoInvitationType[ZegoInvitationType[\"RemoveCoHost\"] = 4] = \"RemoveCoHost\";\n})(ZegoInvitationType || (ZegoInvitationType = {}));\nvar CallInvitationEndReason;\n(function (CallInvitationEndReason) {\n CallInvitationEndReason[\"Declined\"] = \"Declined\";\n CallInvitationEndReason[\"Timeout\"] = \"Timeout\";\n CallInvitationEndReason[\"Canceled\"] = \"Canceled\";\n CallInvitationEndReason[\"Busy\"] = \"Busy\";\n CallInvitationEndReason[\"LeaveRoom\"] = \"LeaveRoom\";\n})(CallInvitationEndReason || (CallInvitationEndReason = {}));\nvar UserListMenuItemType;\n(function (UserListMenuItemType) {\n UserListMenuItemType[\"ChangePin\"] = \"ChangePin\";\n UserListMenuItemType[\"MuteMic\"] = \"MuteMic\";\n UserListMenuItemType[\"MuteCamera\"] = \"MuteCamera\";\n UserListMenuItemType[\"RemoveUser\"] = \"RemoveUser\";\n UserListMenuItemType[\"RemoveCohost\"] = \"RemoveCohost\";\n UserListMenuItemType[\"InviteCohost\"] = \"InviteCohost\";\n UserListMenuItemType[\"DisagreeRequestCohost\"] = \"disagreeRequestCohost\";\n UserListMenuItemType[\"AgreeRequestCohost\"] = \"agreeRequestCohost\";\n})(UserListMenuItemType || (UserListMenuItemType = {}));\nvar ReasonForRefusedInviteToCoHost;\n(function (ReasonForRefusedInviteToCoHost) {\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Disagree\"] = 0] = \"Disagree\";\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Busy\"] = 1] = \"Busy\";\n ReasonForRefusedInviteToCoHost[ReasonForRefusedInviteToCoHost[\"Timeout\"] = 2] = \"Timeout\";\n})(ReasonForRefusedInviteToCoHost || (ReasonForRefusedInviteToCoHost = {}));\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/model/index.ts?");
2248
2248
 
2249
2249
  /***/ }),
2250
2250
 
@@ -2255,7 +2255,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2255
2255
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2256
2256
 
2257
2257
  "use strict";
2258
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCCore\": function() { return /* binding */ ZegoCloudRTCCore; }\n/* harmony export */ });\n/* harmony import */ var _tools_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/util */ \"./src/sdk/modules/tools/util.ts\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zego-express-engine-webrtc */ \"./node_modules/.pnpm/zego-express-engine-webrtc@2.26.0/node_modules/zego-express-engine-webrtc/ZegoExpressWebRTC.js\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/UserListManager */ \"./src/sdk/modules/tools/UserListManager.ts\");\n/* harmony import */ var _tools_ZimManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tools/ZimManager */ \"./src/sdk/modules/tools/ZimManager.ts\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _tools_EventEmitter__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tools/EventEmitter */ \"./src/sdk/modules/tools/EventEmitter.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\nclass ZegoCloudRTCCore {\n constructor() {\n this._zimManager = null;\n this.zegoSuperBoardView = undefined;\n this.eventEmitter = new _tools_EventEmitter__WEBPACK_IMPORTED_MODULE_6__.EventEmitter();\n this.status = {\n loginRsp: false,\n videoRefuse: undefined,\n audioRefuse: undefined,\n };\n this.remoteStreamMap = {};\n this.waitingHandlerStreams = { add: [], delete: [] };\n this._config = {\n // @ts-ignore\n container: undefined,\n preJoinViewConfig: {\n title: \"Join Room\", // 标题设置,默认join Room\n // invitationLink: window.location.href, // 邀请链接,空则不显示,默认空\n },\n showPreJoinView: true,\n turnOnMicrophoneWhenJoining: true,\n turnOnCameraWhenJoining: true,\n showMyCameraToggleButton: true,\n showMyMicrophoneToggleButton: true,\n showAudioVideoSettingsButton: true,\n showTextChat: true,\n showUserList: true,\n lowerLeftNotification: {\n showUserJoinAndLeave: true,\n showTextChat: true, // 是否显示未读消息,默认显示\n },\n branding: {\n logoURL: \"\",\n },\n showLeavingView: true,\n maxUsers: 0,\n layout: \"Auto\",\n showNonVideoUser: true,\n showOnlyAudioUser: false,\n useFrontFacingCamera: true,\n onJoinRoom: () => { },\n onLeaveRoom: () => { },\n onUserJoin: (user) => { },\n onUserLeave: (user) => { },\n onUserAvatarSetter: (user) => { },\n sharedLinks: [],\n showScreenSharingButton: true,\n scenario: {\n mode: _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall,\n config: {\n role: _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host,\n liveStreamingMode: undefined,\n enableVideoMixing: false,\n videoMixingLayout: _model__WEBPACK_IMPORTED_MODULE_2__.VideoMixinLayoutType.AutoLayout,\n videoMixingOutputResolution: _model__WEBPACK_IMPORTED_MODULE_2__.VideoMixinOutputResolution._540P,\n }, // 对应场景专有配置\n },\n facingMode: \"user\",\n joinRoomCallback: () => { },\n leaveRoomCallback: () => { },\n userUpdateCallback: () => { },\n showLayoutButton: true,\n showPinButton: true,\n whiteboardConfig: {\n showAddImageButton: false,\n showCreateAndCloseButton: true,\n },\n videoResolutionList: [],\n plugins: {},\n autoLeaveRoomWhenOnlySelfInRoom: false,\n showRoomTimer: false,\n videoCodec: \"H264\",\n showRoomDetailsButton: true,\n showInviteToCohostButton: false,\n showRemoveCohostButton: false,\n showRequestToCohostButton: false,\n rightPanelExpandedType: _model__WEBPACK_IMPORTED_MODULE_2__.RightPanelExpandedType.None,\n autoHideFooter: true,\n enableStereo: false,\n };\n this._currentPage = \"BrowserCheckPage\";\n this.extraInfoKey = \"extra_info\";\n this._roomExtraInfo = {\n live_status: \"0\",\n };\n this.NetworkStatusTimer = null;\n this.hostSetterTimer = null;\n this.localStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.localScreensharingStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.hasPublishedStream = false; // 是否有已经推上去的流\n this.mixStreamDomain = \"\"; // 混流域名\n this.mixUser = {}; // 混流用户数据\n this._originConfig = {};\n this.onRemoteMediaUpdateCallBack = (updateType, streamList) => __awaiter(this, void 0, void 0, function* () {\n yield this.zum.mainStreamUpdate(updateType, streamList);\n yield this.zum.screenStreamUpdate(updateType, streamList);\n this.throttleStartAndUpdateMixinTask();\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack && this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n });\n this.throttleStartAndUpdateMixinTask = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.throttle)(this.startAndUpdateMixinTask, 1200);\n }\n // static _soundMeter: SoundMeter;\n static getInstance(kitToken) {\n const config = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)(kitToken);\n if (!ZegoCloudRTCCore._instance && config) {\n ZegoCloudRTCCore._instance = new ZegoCloudRTCCore();\n ZegoCloudRTCCore._instance._expressConfig = config;\n // ZegoCloudRTCCore._soundMeter = new SoundMeter();\n ZegoCloudRTCCore._zg = new zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__.ZegoExpressEngine(ZegoCloudRTCCore._instance._expressConfig.appID, \"wss://webliveroom\" + ZegoCloudRTCCore._instance._expressConfig.appID + \"-api.zegocloud.com/ws\");\n ZegoCloudRTCCore._instance.zum = new _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudUserListManager(ZegoCloudRTCCore._zg);\n }\n return ZegoCloudRTCCore._instance;\n }\n get isCDNLive() {\n var _a, _b;\n return (((_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_b = this._config.scenario.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience &&\n this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming);\n }\n isHost(userID) {\n var _a;\n userID !== null && userID !== void 0 ? userID : (userID = this._expressConfig.userID);\n return userID === ((_a = this.roomExtraInfo) === null || _a === void 0 ? void 0 : _a.host);\n }\n addPlugins(plugins) {\n this._config.plugins = plugins;\n if (plugins.ZIM && this._expressConfig.token) {\n this.initZIM(plugins.ZIM);\n }\n }\n set originConfig(config) {\n var _a;\n if (config.container) {\n this._originConfig[\"cw\"] = config.container.clientWidth / document.body.clientWidth;\n this._originConfig[\"ch\"] = config.container.clientHeight / document.body.clientHeight;\n }\n if (config.showPreJoinView !== undefined) {\n this._originConfig[\"spj\"] = config.showPreJoinView ? 1 : 0;\n }\n if (config.turnOnMicrophoneWhenJoining !== undefined) {\n this._originConfig[\"tmwj\"] = config.turnOnMicrophoneWhenJoining ? 1 : 0;\n }\n if (config.turnOnCameraWhenJoining !== undefined) {\n this._originConfig[\"tcwj\"] = config.turnOnCameraWhenJoining ? 1 : 0;\n }\n if (config.showMyMicrophoneToggleButton !== undefined) {\n this._originConfig[\"smtb\"] = config.showMyMicrophoneToggleButton ? 1 : 0;\n }\n if (config.showMyCameraToggleButton !== undefined) {\n this._originConfig[\"sctb\"] = config.showMyCameraToggleButton ? 1 : 0;\n }\n if (config.showAudioVideoSettingsButton !== undefined) {\n this._originConfig[\"savsb\"] = config.showAudioVideoSettingsButton ? 1 : 0;\n }\n if (config.showTextChat !== undefined) {\n this._originConfig[\"stc\"] = config.showTextChat ? 1 : 0;\n }\n if (config.showUserList !== undefined) {\n this._originConfig[\"sul\"] = config.showUserList ? 1 : 0;\n }\n if (config.showLeavingView !== undefined) {\n this._originConfig[\"slv\"] = config.showLeavingView ? 1 : 0;\n }\n if (config.maxUsers !== undefined) {\n this._originConfig[\"mu\"] = config.maxUsers ? 1 : 0;\n }\n if (config.layout !== undefined) {\n this._originConfig[\"lo\"] = config.layout;\n }\n if (config.showScreenSharingButton !== undefined) {\n this._originConfig[\"sssb\"] = config.showScreenSharingButton ? 1 : 0;\n }\n if (this._config.plugins.ZegoSuperBoardManager !== undefined) {\n this._originConfig[\"swbb\"] = 1;\n }\n if (this._config.plugins.ZIM !== undefined) {\n this._originConfig[\"uc\"] = 1;\n }\n if (((_a = config.scenario) === null || _a === void 0 ? void 0 : _a.mode) !== undefined) {\n this._originConfig[\"sm\"] = config.scenario.mode;\n }\n if (config.lowerLeftNotification !== undefined) {\n this._originConfig[\"lln\"] = config.lowerLeftNotification ? 1 : 0;\n }\n if (config.showNonVideoUser !== undefined) {\n this._originConfig[\"snvu\"] = config.showNonVideoUser ? 1 : 0;\n }\n if (config.showOnlyAudioUser !== undefined) {\n this._originConfig[\"snau\"] = config.showOnlyAudioUser ? 1 : 0;\n }\n if (config.onJoinRoom !== undefined) {\n this._originConfig[\"ojr\"] = 1;\n }\n if (config.onLeaveRoom !== undefined) {\n this._originConfig[\"olr\"] = 1;\n }\n if (config.onLiveStart !== undefined) {\n this._originConfig[\"ols\"] = 1;\n }\n if (config.onLiveEnd !== undefined) {\n this._originConfig[\"ole\"] = 1;\n }\n this._originConfig[\"url\"] = window.location.origin + window.location.pathname;\n }\n get originConfig() {\n return this._originConfig;\n }\n setConfig(config) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;\n this.originConfig = Object.assign({}, config);\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming) {\n if (config.showNonVideoUser === true) {\n console.error(\"【ZEGOCLOUD】 showNonVideoUser have be false scenario.mode is LiveStreaming!!\");\n return false;\n }\n config.videoCodec = \"H264\";\n config.showNonVideoUser = false;\n config.showOnlyAudioUser = true;\n config.autoLeaveRoomWhenOnlySelfInRoom = false;\n if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host) {\n if (config.turnOnMicrophoneWhenJoining === false &&\n config.turnOnCameraWhenJoining === false &&\n config.showMyCameraToggleButton === false &&\n config.showAudioVideoSettingsButton === false) {\n console.error(\"【ZEGOCLOUD】 Host could turn on at least one of the camera and the microphone!!\");\n return false;\n }\n }\n else if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n if (config.turnOnMicrophoneWhenJoining === true ||\n config.turnOnCameraWhenJoining === true ||\n config.showMyCameraToggleButton === true ||\n config.showMyMicrophoneToggleButton === true ||\n config.showAudioVideoSettingsButton === true ||\n config.showScreenSharingButton === true ||\n config.useFrontFacingCamera === true ||\n (!!config.layout && config.layout !== \"Grid\")) {\n console.error(\"【ZEGOCLOUD】 Audience cannot configure camera and microphone related params\");\n return false;\n }\n }\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n config.showUserList = config.showUserList === undefined ? false : config.showUserList;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n }\n }\n else {\n config.showInviteToCohostButton = false;\n config.showRemoveCohostButton = false;\n config.showRequestToCohostButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall) {\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n config.showLayoutButton = false;\n config.showPinButton = false;\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n config.showRemoveUserButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall) {\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n }\n if (config.scenario && ((_b = (_a = config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.showPinButton = false;\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n config.showRemoveUserButton = false;\n }\n if (((_d = (_c = config === null || config === void 0 ? void 0 : config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost) {\n config.showRemoveUserButton = false;\n }\n config.facingMode && (config.useFrontFacingCamera = config.facingMode === \"user\");\n config.joinRoomCallback && (config.onJoinRoom = config.joinRoomCallback);\n config.leaveRoomCallback && (config.onLeaveRoom = config.leaveRoomCallback);\n if (config.userUpdateCallback) {\n config.onUserJoin = (users) => {\n config.userUpdateCallback && config.userUpdateCallback(\"ADD\", users);\n };\n config.onUserLeave = (users) => {\n config.userUpdateCallback && config.userUpdateCallback(\"DELETE\", users);\n };\n }\n if (config.preJoinViewConfig && config.preJoinViewConfig.invitationLink) {\n config.sharedLinks = [\n {\n name: \"Share the link\",\n url: config.preJoinViewConfig.invitationLink,\n },\n ];\n }\n if (config.videoResolutionDefault) {\n if (!config.videoResolutionList) {\n config.videoResolutionList = [];\n }\n (_e = config.videoResolutionList) === null || _e === void 0 ? void 0 : _e.unshift(config.videoResolutionDefault);\n }\n if (config.videoResolutionList && config.videoResolutionList.length > 0) {\n const list = Array.from(new Set(config.videoResolutionList)).filter((s) => {\n return (s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._180P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._480P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._720P);\n });\n config.videoResolutionList = list.length > 0 ? list : [_model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P];\n }\n else {\n config.videoResolutionList = [_model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P];\n }\n config.preJoinViewConfig &&\n (config.preJoinViewConfig = Object.assign(Object.assign({}, this._config.preJoinViewConfig), config.preJoinViewConfig));\n config.scenario &&\n // @ts-ignore\n (config.scenario.config = Object.assign(Object.assign(Object.assign({}, (_f = this._config.scenario) === null || _f === void 0 ? void 0 : _f.config), (config.scenario.config || {})), { enableVideoMixing: config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming\n ? (_g = config.scenario.config) === null || _g === void 0 ? void 0 : _g.enableVideoMixing\n : false }));\n config.whiteboardConfig &&\n (config.whiteboardConfig = Object.assign(Object.assign({}, this._config.whiteboardConfig), config.whiteboardConfig));\n this._config = Object.assign(Object.assign({}, this._config), config);\n this.zum.scenario = ((_h = this._config.scenario) === null || _h === void 0 ? void 0 : _h.mode) || _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n this.zum.role = ((_k = (_j = this._config.scenario) === null || _j === void 0 ? void 0 : _j.config) === null || _k === void 0 ? void 0 : _k.role) || _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\n this.zum.enableVideoMixing = ((_m = (_l = this._config.scenario) === null || _l === void 0 ? void 0 : _l.config) === null || _m === void 0 ? void 0 : _m.enableVideoMixing) || false;\n this.zum.liveStreamingMode = this.getLiveStreamingMode((_p = (_o = this._config.scenario) === null || _o === void 0 ? void 0 : _o.config) === null || _p === void 0 ? void 0 : _p.liveStreamingMode);\n this.zum.showOnlyAudioUser = !!this._config.showOnlyAudioUser;\n this.zum.setShowNonVideo(!!this._config.showNonVideoUser);\n if (!this._config.turnOnCameraWhenJoining && !this._config.showMyCameraToggleButton) {\n this.status.videoRefuse = true;\n }\n if (config.console) {\n let logLevel = \"debug\";\n if (config.console === \"Info\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"Warning\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"Error\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"None\") {\n logLevel = \"disable\";\n }\n ZegoCloudRTCCore._zg.setLogConfig({\n logLevel,\n });\n }\n return true;\n }\n // Audience变成Cohost\n changeAudienceToCohostInLiveStream() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const config = this._config;\n config.scenario.config.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\n this.zum.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\n config.turnOnMicrophoneWhenJoining = true;\n config.turnOnCameraWhenJoining = true;\n config.showMyCameraToggleButton = true;\n config.showMyMicrophoneToggleButton = true;\n config.showAudioVideoSettingsButton = true;\n config.showScreenSharingButton = true;\n config.useFrontFacingCamera = true;\n config.showUserList = true;\n config.showPinButton = true;\n config.showLayoutButton = true;\n config.layout = \"Auto\";\n config.lowerLeftNotification = {\n showTextChat: true,\n showUserJoinAndLeave: true,\n };\n config.showTurnOffRemoteCameraButton = true;\n config.showTurnOffRemoteMicrophoneButton = true;\n this.status.videoRefuse = undefined;\n this.clearMixUser();\n // 拉流需要变成RTC的\n let _streamList = [];\n for (let streamInfo of Object.values(this.remoteStreamMap)) {\n // 需要停止原来的L3拉流\n if (streamInfo.media &&\n ((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive) {\n ZegoCloudRTCCore._zg.stopPlayingStream(streamInfo.streamID);\n }\n try {\n const stream = yield this.zum.startPullStream(streamInfo.fromUser.userID, streamInfo.streamID);\n this.remoteStreamMap[streamInfo.streamID].media = stream;\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】change to Cohost:\", error);\n }\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", _streamList);\n });\n }\n // Cohost 变成 Audience\n changeCohostToAudienceInLiveStream() {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n const config = this._config;\n config.scenario.config.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\n this.zum.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n // config.showUserList = true;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n this.setMixUser();\n // 如果是设置的RTC拉流则不变,否则需要重新拉流\n try {\n if (((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive &&\n !((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.enableVideoMixing)) {\n let _streamList = [];\n for (let key in this.remoteStreamMap) {\n // 先停止拉流\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n // 重新拉流\n if (this.isCDNLive) {\n if (!this.mixStreamDomain) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportCDNLive, \"urlsFLV is empty\");\n }\n // CDN拉流\n this.remoteStreamMap[key].media = undefined;\n this.remoteStreamMap[key].urlsHttpsFLV = `${this.mixStreamDomain}${key}.flv`;\n this.remoteStreamMap[key].urlsHttpsHLS = `${this.mixStreamDomain}${key}.m3u8`;\n }\n else {\n const stream = yield this.zum.startPullStream(this.remoteStreamMap[key].fromUser.userID, key);\n this.remoteStreamMap[key].media = stream;\n this.remoteStreamMap[key].urlsHttpsFLV = \"\";\n this.remoteStreamMap[key].urlsHttpsHLS = \"\";\n }\n _streamList.push(this.remoteStreamMap[key]);\n }\n _streamList.length > 0 && ((_e = this.onRemoteMediaUpdateCallBack) === null || _e === void 0 ? void 0 : _e.call(this, \"UPDATE\", _streamList));\n }\n }\n catch (error) {\n console.error(error);\n }\n });\n }\n // 兼容处理LiveStreamingMode\n getLiveStreamingMode(mode) {\n if (mode === \"StandardLive\" || mode === \"LiveStreaming\")\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming;\n if (mode === \"PremiumLive\" || mode === \"InteractiveLiveStreaming\")\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.InteractiveLiveStreaming;\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive;\n }\n checkWebRTC() {\n return __awaiter(this, void 0, void 0, function* () {\n if (!this.isCDNLive) {\n const webRTC = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"webRTC\");\n if (this._config.videoCodec === \"H264\") {\n const H264 = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"H264\");\n return !!webRTC.result && !!H264.result;\n }\n if (this._config.videoCodec === \"VP8\") {\n const VP8 = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"VP8\");\n return !!webRTC.result && !!VP8.result;\n }\n return !!webRTC.result;\n }\n return true;\n });\n }\n setPin(userID, pined, stopUpdateUser) {\n this.zum.setPin(userID, pined);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n }\n setMaxScreenNum(num, stopUpdateUser) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setMaxScreenNum(num);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n });\n }\n setSidebarLayOut(enable, stopUpdateUser) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setSidebarLayOut(enable);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n });\n }\n setShowNonVideo(enable) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setShowNonVideo(enable);\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n });\n }\n setCurrentPage(page) {\n this._currentPage = page;\n }\n getCameras() {\n return ZegoCloudRTCCore._zg.getCameras();\n }\n useVideoDevice(localStream, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(localStream, deviceID);\n }\n getMicrophones() {\n return ZegoCloudRTCCore._zg.getMicrophones();\n }\n getSpeakers() {\n return ZegoCloudRTCCore._zg.getSpeakers();\n }\n setVolume(media, volume) {\n media.volume = volume;\n }\n createStream(source) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.createStream(source);\n });\n }\n createAndPublishWhiteboard(parentDom, name) {\n return __awaiter(this, void 0, void 0, function* () {\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n yield this.zegoSuperBoard.createWhiteboardView({\n name,\n perPageWidth: 1480.3,\n perPageHeight: 758.5,\n pageCount: 5, // 白板页数\n });\n // this.zegoSuperBoard.setBrushColor(\"#F64326\"); not working to set default color\n return this.zegoSuperBoard.getSuperBoardView();\n });\n }\n setWhiteboardToolType(type, fontSize, color) {\n return __awaiter(this, void 0, void 0, function* () {\n if (type === 512) {\n const zegoSuperBoardSubView = this.zegoSuperBoard.getSuperBoardView().getCurrentSuperBoardSubView();\n zegoSuperBoardSubView && zegoSuperBoardSubView.clearCurrentPage();\n }\n else {\n this.zegoSuperBoard.setToolType(type);\n if ([1, 4, 8, 16].includes(type)) {\n fontSize && this.zegoSuperBoard.setBrushSize(fontSize);\n color && this.zegoSuperBoard.setBrushColor(color);\n }\n }\n });\n }\n setWhiteboardFont(font, fontSize, color) {\n if (font === \"BOLD\") {\n this.zegoSuperBoard.setFontBold(true);\n }\n else if (font === \"NO_BOLD\") {\n this.zegoSuperBoard.setFontBold(false);\n }\n else if (font === \"ITALIC\") {\n this.zegoSuperBoard.setFontItalic(true);\n }\n else if (font === \"NO_ITALIC\") {\n this.zegoSuperBoard.setFontItalic(false);\n }\n fontSize && this.zegoSuperBoard.setFontSize(fontSize);\n color && this.zegoSuperBoard.setBrushColor(color);\n }\n setVideoConfig(media, constraints) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.setVideoConfig(media, constraints);\n });\n }\n stopPublishingStream(streamID) {\n if (streamID.indexOf(\"_main\") > -1) {\n this.localStreamInfo = {};\n }\n if (streamID.indexOf(\"_screensharing\") > -1) {\n // 停止屏幕共享,更新混流\n this.localScreensharingStreamInfo = {};\n this.startAndUpdateMixinTask();\n }\n return ZegoCloudRTCCore._zg.stopPublishingStream(streamID);\n }\n destroyStream(stream) {\n ZegoCloudRTCCore._zg.destroyStream(stream);\n }\n destroyAndStopPublishWhiteboard() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const uniqueID = (_b = (_a = this.zegoSuperBoard.getSuperBoardView()) === null || _a === void 0 ? void 0 : _a.getCurrentSuperBoardSubView()) === null || _b === void 0 ? void 0 : _b.getModel().uniqueID;\n if (uniqueID) {\n this.zegoSuperBoard.destroySuperBoardSubView(uniqueID);\n }\n const result = yield this.zegoSuperBoard.querySuperBoardSubViewList();\n for (let i = 0; i < result.length; i++) {\n yield this.zegoSuperBoard.destroySuperBoardSubView(result[i].uniqueID);\n }\n });\n }\n useCameraDevice(media, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(media, deviceID);\n }\n useMicrophoneDevice(media, deviceID) {\n return ZegoCloudRTCCore._zg.useAudioDevice(media, deviceID);\n }\n useSpeakerDevice(media, deviceID) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!media.srcObject) {\n return Promise.resolve({ errorCode: -1 });\n }\n try {\n const res = yield ZegoCloudRTCCore._zg.useAudioOutputDevice(media, deviceID);\n return { errorCode: res ? 0 : -1 };\n }\n catch (error) {\n return { errorCode: -1 };\n }\n });\n }\n enableVideoCaptureDevice(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.cameraStatus = !enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.enableVideoCaptureDevice(localStream, enable);\n });\n }\n mutePublishStreamVideo(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.cameraStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.mutePublishStreamVideo(localStream, enable);\n });\n }\n mutePublishStreamAudio(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.micStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.mutePublishStreamAudio(localStream, enable);\n });\n }\n muteMicrophone(enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.micStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.muteMicrophone(enable);\n });\n }\n set roomExtraInfo(value) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n if (this._currentPage === \"Room\") {\n if (this._roomExtraInfo.live_status === \"0\" && value.live_status === \"1\") {\n // 开始直播\n this.setMixUser();\n this._config.onLiveStart &&\n this._config.onLiveStart({\n userID: this._expressConfig.userID,\n userName: this._expressConfig.userID,\n });\n }\n else if (this._roomExtraInfo.live_status === \"1\" && value.live_status === \"0\") {\n // 停止直播\n this.clearMixUser();\n (_b = (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a._inRoomInviteMg) === null || _b === void 0 ? void 0 : _b.audienceCancelRequest();\n (_d = (_c = this._zimManager) === null || _c === void 0 ? void 0 : _c._inRoomInviteMg) === null || _d === void 0 ? void 0 : _d.hostCancelAllInvitation();\n this._config.onLiveEnd &&\n this._config.onLiveEnd({\n userID: this._expressConfig.userID,\n userName: this._expressConfig.userID,\n });\n }\n this._roomExtraInfo = value;\n this.zum.setLiveStates(this._roomExtraInfo.live_status);\n (_e = this.onRoomLiveStateUpdateCallBack) === null || _e === void 0 ? void 0 : _e.call(this, this._roomExtraInfo.live_status);\n (_f = this.onRoomMixingStateUpdateCallBack) === null || _f === void 0 ? void 0 : _f.call(this, this._roomExtraInfo.isMixing);\n // 直播时设置房间属性host\n if (this.hostSetterTimer) {\n clearTimeout(this.hostSetterTimer);\n this.hostSetterTimer = null;\n }\n if (((_g = this._config.scenario) === null || _g === void 0 ? void 0 : _g.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_h = this._config.scenario.config) === null || _h === void 0 ? void 0 : _h.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host &&\n !this._roomExtraInfo.host) {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n host: this._expressConfig.userID,\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n if (value.live_status === \"1\" && this.roomExtraInfo.isMixing === \"1\") {\n // TODO:开播时 主播离开房间,自己变成主播,刷新混流\n this.startAndUpdateMixinTask();\n }\n }\n }\n else if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.roomExtraInfo = value;\n }, 1000);\n }\n (_j = this._zimManager) === null || _j === void 0 ? void 0 : _j._inRoomInviteMg.updateRoomExtraInfo(this._roomExtraInfo);\n }\n get roomExtraInfo() {\n return this._roomExtraInfo;\n }\n setLive(status) {\n var _a, _b, _c, _d;\n return __awaiter(this, void 0, void 0, function* () {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n live_status: status === \"live\" ? \"1\" : \"0\",\n });\n const res = yield ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n if (res.errorCode === 0) {\n this.roomExtraInfo = setRoomExtraInfo;\n if (status === \"live\") {\n this.startAndUpdateMixinTask(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host);\n }\n else {\n this.stopMixerTask(((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host);\n }\n }\n return res.errorCode === 0;\n });\n }\n enterRoom() {\n var _a, _b, _c;\n return __awaiter(this, void 0, void 0, function* () {\n // 已经登陆过不再登录\n if (this.status.loginRsp)\n return Promise.resolve(0);\n if ((_a = this._config.plugins) === null || _a === void 0 ? void 0 : _a.ZegoSuperBoardManager) {\n this.zegoSuperBoard = this._config.plugins.ZegoSuperBoardManager.getInstance();\n this.zegoSuperBoard.init(ZegoCloudRTCCore._zg, {\n isTestEnv: false,\n parentDomID: \"ZegoCloudWhiteboardContainer\",\n appID: this._expressConfig.appID,\n userID: this._expressConfig.userID,\n token: this._expressConfig.token, // 登录房间需要用于验证身份的 Token\n });\n if (this._config.console) {\n let logLevel = \"debug\";\n if (this._config.console === \"Info\") {\n logLevel = \"warn\";\n }\n else if (this._config.console === \"Warning\") {\n logLevel = \"warn\";\n }\n else if (this._config.console === \"Error\") {\n logLevel = \"error\";\n }\n else if (this._config.console === \"None\") {\n logLevel = \"disable\";\n }\n this.zegoSuperBoard.setLogConfig({\n logLevel,\n remoteLogLevel: logLevel,\n });\n }\n this.zegoSuperBoard.setWhiteboardBackgroundColor(\"#ffffff\");\n }\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvCustomCommand\");\n if (this.zegoSuperBoard) {\n // 监听远端新增白板\n this.zegoSuperBoard.off(\"remoteSuperBoardSubViewAdded\");\n // 监听远端销毁白板\n this.zegoSuperBoard.off(\"remoteSuperBoardSubViewRemoved\");\n }\n ZegoCloudRTCCore._zg.on(\"roomStreamUpdate\", (roomID, updateType, streamList, extendedData) => __awaiter(this, void 0, void 0, function* () {\n var _d, _e;\n if (updateType === \"ADD\") {\n this.mixStreamDomain = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(((_e = (_d = streamList[0]) === null || _d === void 0 ? void 0 : _d.urlsFLV) === null || _e === void 0 ? void 0 : _e.replace(/[^/]+$/, \"\")) || \"\");\n this.waitingHandlerStreams.add = [...this.waitingHandlerStreams.add, ...streamList];\n this.waitingHandlerStreams.delete = this.waitingHandlerStreams.delete.filter((stream) => {\n if (streamList.some((add_stream) => add_stream.streamID === stream.streamID)) {\n return false;\n }\n else {\n return true;\n }\n });\n }\n else {\n // 找出删除流中,和之前的新增流重叠的,存储这个下面对象中\n let willDelete = [];\n // 新增流中,删除下线的流\n this.waitingHandlerStreams.add = this.waitingHandlerStreams.add.filter((stream) => {\n if (streamList.some((delete_stream) => {\n if (delete_stream.streamID === stream.streamID) {\n willDelete.push(delete_stream.streamID);\n return true;\n }\n else {\n return false;\n }\n })) {\n return false;\n }\n else {\n return true;\n }\n });\n // 删除流中,去除上次要新增的\n streamList = streamList.filter((s) => {\n if (willDelete.some((wd) => wd === s.streamID)) {\n return false;\n }\n else {\n return true;\n }\n });\n this.waitingHandlerStreams.delete = [...this.waitingHandlerStreams.delete, ...streamList];\n }\n // console.error(\"roomStreamUpdate\", this.waitingHandlerStreams);\n }));\n ZegoCloudRTCCore._zg.on(\"roomExtraInfoUpdate\", (roomID, roomExtraInfoList) => {\n roomExtraInfoList.forEach((info) => {\n if (info.key === this.extraInfoKey) {\n this.roomExtraInfo = JSON.parse(info.value);\n console.warn(\"roomExtraInfo\", this.roomExtraInfo);\n }\n });\n });\n ZegoCloudRTCCore._zg.on(\"remoteCameraStatusUpdate\", (streamID, status) => {\n console.warn(\"remoteCameraStatusUpdate\", streamID, status);\n if (this.remoteStreamMap[streamID]) {\n this.remoteStreamMap[streamID].cameraStatus = status;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamID]]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"remoteMicStatusUpdate\", (streamID, status) => {\n console.warn(\"remoteMicStatusUpdate\", streamID, status);\n if (this.remoteStreamMap[streamID]) {\n this.remoteStreamMap[streamID].micStatus = status;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamID]]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"playerStateUpdate\", (streamInfo) => {\n console.warn(\"【ZEGOCLOUD】playerStateUpdate\", streamInfo);\n if (this.remoteStreamMap[streamInfo.streamID]) {\n this.remoteStreamMap[streamInfo.streamID].state = streamInfo.state;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamInfo.streamID]]);\n }\n if (streamInfo.errorCode === 1104038) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportStandardLive, streamInfo.extendedData);\n }\n if (streamInfo.errorCode === 1104039 && streamInfo.streamID.includes(\"__mix\")) {\n // 混流拉流重试\n setTimeout(() => {\n this.clearMixUser();\n this.setMixUser();\n }, 2000);\n }\n });\n ZegoCloudRTCCore._zg.on(\"roomUserUpdate\", (roomID, updateType, userList) => {\n var _a;\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", updateType, userList);\n if (updateType === \"DELETE\") {\n (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a._inRoomInviteMg.clearInviteWhenUserLeave(userList);\n }\n if (this.onRemoteUserUpdateCallBack) {\n this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n }\n else {\n setTimeout(() => {\n this.onRemoteUserUpdateCallBack &&\n this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n }, 1000);\n }\n });\n ZegoCloudRTCCore._zg.on(\"IMRecvBroadcastMessage\", (roomID, chatData) => {\n this.onRoomMessageUpdateCallBack && this.onRoomMessageUpdateCallBack(roomID, chatData);\n chatData.forEach((data) => {\n this._config.onInRoomMessageReceived && this._config.onInRoomMessageReceived(data);\n });\n });\n // 房间内自定义消息\n ZegoCloudRTCCore._zg.on(\"IMRecvCustomCommand\", (roomID, fromUser, command) => {\n try {\n const commandData = JSON.parse(command);\n console.warn(\"IMRecvCustomCommand\", commandData);\n if (Object.keys(commandData).includes(\"zego_remove_user\") &&\n commandData[\"zego_remove_user\"].includes(this._expressConfig.userID)) {\n // 被移除房间的通知\n // 通知UI层leaveRoom\n this.onKickedOutRoomCallback && this.onKickedOutRoomCallback();\n return;\n }\n if (Object.keys(commandData).includes(\"zego_turn_camera_off\") &&\n commandData[\"zego_turn_camera_off\"] === this._expressConfig.userID) {\n // 通知UI层关闭摄像头\n this.onChangeYourDeviceStatusCallback &&\n this.onChangeYourDeviceStatusCallback(\"Camera\", \"CLOSE\", fromUser);\n return;\n }\n if (Object.keys(commandData).includes(\"zego_turn_microphone_off\") &&\n commandData[\"zego_turn_microphone_off\"] === this._expressConfig.userID) {\n // 通知UI层关闭麦克风\n this.onChangeYourDeviceStatusCallback &&\n this.onChangeYourDeviceStatusCallback(\"Microphone\", \"CLOSE\", fromUser);\n return;\n }\n }\n catch (error) { }\n this._config.onInRoomCommandReceived && this._config.onInRoomCommandReceived(fromUser, command);\n });\n ZegoCloudRTCCore._zg.on(\"publisherStateUpdate\", (streamInfo) => {\n let state = \"DISCONNECTED\";\n if (streamInfo.state === \"PUBLISHING\") {\n state = \"CONNECTED\";\n // 推流成功后开始混流\n if (this.roomExtraInfo.live_status === \"1\") {\n // 直播后再开始混流\n this.startAndUpdateMixinTask();\n }\n else {\n // 直播未开始,先标记已经有推流了\n this.hasPublishedStream = true;\n }\n }\n else if (streamInfo.state === \"NO_PUBLISH\") {\n state = \"DISCONNECTED\";\n }\n else if (streamInfo.state === \"PUBLISH_REQUESTING\") {\n state = \"CONNECTING\";\n }\n this.onNetworkStatusCallBack &&\n this.onNetworkStatusCallBack(ZegoCloudRTCCore._instance._expressConfig.roomID, \"STREAM\", state);\n });\n ZegoCloudRTCCore._zg.on(\"playQualityUpdate\", (streamID, stats) => {\n this.onNetworkStatusQualityCallBack &&\n this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"publishQualityUpdate\", (streamID, stats) => {\n this.onNetworkStatusQualityCallBack &&\n this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"soundLevelUpdate\", (soundLevelList) => {\n this.onSoundLevelUpdateCallBack && this.onSoundLevelUpdateCallBack(soundLevelList);\n });\n ZegoCloudRTCCore._zg.on(\"screenSharingEnded\", (stream) => {\n this.onScreenSharingEndedCallBack && this.onScreenSharingEndedCallBack(stream);\n });\n if (this.zegoSuperBoard) {\n // 监听远端新增白板\n this.zegoSuperBoard.on(\"remoteSuperBoardSubViewAdded\", (uniqueID) => __awaiter(this, void 0, void 0, function* () {\n yield this.zegoSuperBoard.querySuperBoardSubViewList();\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n this.zegoSuperBoardView = this.zegoSuperBoard.getSuperBoardView();\n }));\n // 监听远端销毁白板\n this.zegoSuperBoard.on(\"remoteSuperBoardSubViewRemoved\", (uniqueID) => {\n this.zegoSuperBoardView = null;\n });\n }\n // if (this.isCDNLive) {\n ZegoCloudRTCCore._zg.on(\"streamExtraInfoUpdate\", (roomID, streamList) => {\n if (roomID === this._expressConfig.roomID) {\n console.warn(\"streamExtraInfoUpdate\", streamList);\n this.streamExtraInfoUpdateCallBack(streamList);\n }\n });\n // }\n // 监听房间内ZIM text消息\n this._config.onInRoomTextMessageReceived &&\n ((_b = this._zimManager) === null || _b === void 0 ? void 0 : _b.onRoomTextMessage(this._config.onInRoomTextMessageReceived));\n const resp = yield new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {\n var _f, _g;\n ZegoCloudRTCCore._zg.on(\"roomStateUpdate\", (roomID, state, errorCode, extendedData) => {\n this.onNetworkStatusCallBack && this.onNetworkStatusCallBack(roomID, \"ROOM\", state);\n if (state === \"CONNECTED\" || state === \"DISCONNECTED\") {\n this.status.loginRsp = errorCode === 0;\n res(errorCode);\n }\n });\n yield ZegoCloudRTCCore._zg.loginRoom(ZegoCloudRTCCore._instance._expressConfig.roomID, ZegoCloudRTCCore._instance._expressConfig.token, {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n }, {\n userUpdate: true,\n maxMemberCount: ZegoCloudRTCCore._instance._config.maxUsers,\n });\n if (((_f = this._config.scenario) === null || _f === void 0 ? void 0 : _f.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_g = this._config.scenario.config) === null || _g === void 0 ? void 0 : _g.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host &&\n this.roomExtraInfo.host === undefined) {\n // 进房后如果没有host,就将自己设置为host\n this.hostSetterTimer = setTimeout(() => {\n if (!this.roomExtraInfo.host) {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n host: this._expressConfig.userID,\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n }, 2000);\n }\n if (this.zegoSuperBoard) {\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n const result = yield this.zegoSuperBoard.querySuperBoardSubViewList();\n result.length > 0 && (this.zegoSuperBoardView = this.zegoSuperBoard.getSuperBoardView());\n }\n const user = {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n setUserAvatar: (avatar) => {\n if (avatar && typeof avatar === \"string\") {\n this._expressConfig.avatar = avatar;\n }\n },\n };\n this._config.onUserAvatarSetter && this._config.onUserAvatarSetter([user]);\n // @ts-ignore 日志上报\n ZegoCloudRTCCore._zg.logger.error(\"zu.jr \" + JSON.stringify(this.originConfig));\n }));\n (_c = this._zimManager) === null || _c === void 0 ? void 0 : _c.enterRoom();\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(true, 300);\n this.streamUpdateTimer(this.waitingHandlerStreams);\n return resp;\n });\n }\n streamUpdateTimer(_waitingHandlerStreams) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!this.status.loginRsp) {\n console.warn(\"【ZEGOCLOUD】logoutRoom,stop streamUpdateTimer\");\n return;\n }\n if (this._currentPage === \"Room\") {\n let _streamList = [];\n if (_waitingHandlerStreams.add.length > 0) {\n for (let i = 0; i < _waitingHandlerStreams.add.length; i++) {\n const streamInfo = _waitingHandlerStreams.add[i];\n let extraInfo = {\n isMicrophoneOn: undefined,\n isCameraOn: undefined,\n hasAudio: undefined,\n hasVideo: undefined,\n };\n try {\n // 防止流附加消息为空解析报错\n extraInfo = JSON.parse(streamInfo.extraInfo);\n }\n catch (err) { }\n try {\n if (this.isCDNLive) {\n if (!streamInfo.urlsFLV) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportCDNLive, \"urlsFLV is empty\");\n }\n // CDN拉流\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: undefined,\n micStatus: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMicrophoneOn) ? \"OPEN\" : \"MUTE\",\n cameraStatus: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isCameraOn) ? \"OPEN\" : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n urlsHttpsFLV: (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(streamInfo.urlsHttpsFLV || streamInfo.urlsFLV),\n urlsHttpsHLS: (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(streamInfo.urlsHttpsHLS || streamInfo.urlsHLS),\n hasAudio: extraInfo.hasAudio,\n hasVideo: extraInfo.hasVideo,\n };\n }\n else {\n const stream = yield this.zum.startPullStream(streamInfo.user.userID, streamInfo.streamID);\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: stream,\n micStatus: stream\n ? stream.getAudioTracks().length > 0\n ? \"OPEN\"\n : \"MUTE\"\n : (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMicrophoneOn)\n ? \"OPEN\"\n : \"MUTE\",\n cameraStatus: stream\n ? stream.getVideoTracks().length > 0\n ? \"OPEN\"\n : \"MUTE\"\n : (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isCameraOn)\n ? \"OPEN\"\n : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n };\n }\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n }\n catch (error) {\n console.warn(\"【ZEGOCLOUD】startPlayingStream error:\", error);\n // 未开通L3服务\n if ((error === null || error === void 0 ? void 0 : error.errorCode) === 110438) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportStandardLive, error === null || error === void 0 ? void 0 : error.extendedData);\n }\n }\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"ADD\", _streamList);\n }\n if (_waitingHandlerStreams.delete.length > 0) {\n _streamList = [];\n for (let i = 0; i < _waitingHandlerStreams.delete.length; i++) {\n const streamInfo = _waitingHandlerStreams.delete[i];\n this.remoteStreamMap[streamInfo.streamID] &&\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n yield this.zum.stopPullStream(streamInfo.user.userID, streamInfo.streamID);\n delete this.remoteStreamMap[streamInfo.streamID];\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"DELETE\", _streamList);\n }\n if (this.zegoSuperBoardView !== undefined) {\n this.subscribeWhiteBoardCallBack(this.zegoSuperBoardView);\n this.zegoSuperBoardView = undefined;\n }\n // const nextWaitingHandlerStreams = {\n // add: [...this.waitingHandlerStreams.add],\n // delete: [...this.waitingHandlerStreams.delete],\n // };\n const nextWaitingHandlerStreams = {\n add: this.waitingHandlerStreams.add.filter((realTime_item) => {\n if (_waitingHandlerStreams.add.some((handing_item) => handing_item.streamID === realTime_item.streamID)) {\n return false;\n }\n else {\n return true;\n }\n }),\n delete: this.waitingHandlerStreams.delete.filter((realTime_item) => {\n if (_waitingHandlerStreams.delete.some((handing_item) => handing_item.streamID === realTime_item.streamID)) {\n return false;\n }\n else {\n return true;\n }\n }),\n };\n this.setMixUser();\n this.waitingHandlerStreams = nextWaitingHandlerStreams;\n setTimeout(() => {\n this.streamUpdateTimer(this.waitingHandlerStreams);\n }, 700);\n }\n else if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.streamUpdateTimer(_waitingHandlerStreams);\n }, 1000);\n }\n });\n }\n publishLocalStream(media, streamType, extraInfo) {\n if (!media)\n return false;\n const streamID = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.generateStreamID)(this._expressConfig.userID, this._expressConfig.roomID, streamType);\n if (streamType === \"main\") {\n this.localStreamInfo.streamID = streamID;\n }\n if (streamType === \"screensharing\") {\n this.localScreensharingStreamInfo.streamID = streamID;\n }\n let publishOption;\n if (extraInfo) {\n publishOption = {\n extraInfo,\n };\n }\n const res = ZegoCloudRTCCore._zg.startPublishingStream(streamID, media, Object.assign(Object.assign({}, publishOption), { videoCodec: this._config.videoCodec }));\n return res && streamID;\n }\n replaceTrack(media, mediaStreamTrack) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.replaceTrack(media, mediaStreamTrack);\n });\n }\n subscribeUserList(callback) {\n this.subscribeUserListCallBack = callback;\n }\n subscribeScreenStream(callback) {\n this.subscribeScreenStreamCallBack = callback;\n }\n subscribeWhiteBoard(callback) {\n this.subscribeWhiteBoardCallBack = callback;\n }\n onNetworkStatusQuality(func) {\n this.onNetworkStatusQualityCallBack = func;\n }\n onRemoteUserUpdate(func) {\n this.onRemoteUserUpdateCallBack = (roomID, updateType, users) => __awaiter(this, void 0, void 0, function* () {\n if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.onRemoteUserUpdateCallBack(roomID, updateType, users);\n }, 1000);\n }\n else if (this._currentPage === \"Room\") {\n // 本地数据管理\n yield this.zum.userUpdate(roomID, updateType, users);\n // 人员进出通知\n func(roomID, updateType, users, this.zum.remoteUserList);\n // 用户监听回调\n const newUserList = users.map((user) => {\n user.setUserAvatar = (avatar) => {\n if (avatar && typeof avatar === \"string\") {\n this.zum.updateUserInfo(user.userID, \"avatar\", avatar);\n }\n };\n return user;\n });\n if (updateType === \"ADD\") {\n this._config.onUserAvatarSetter && this._config.onUserAvatarSetter(newUserList);\n this._config.onUserJoin && this._config.onUserJoin(users);\n }\n else {\n this._config.onUserLeave && this._config.onUserLeave(users);\n }\n // 页面渲染\n setTimeout(() => {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", [...this.zum.remoteUserList], [...this.zum.remoteUserList].length);\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }, 0);\n }\n });\n }\n onSoundLevelUpdate(func) {\n this.onSoundLevelUpdateCallBack = func;\n }\n onRoomLiveStateUpdate(func) {\n this.onRoomLiveStateUpdateCallBack = func;\n }\n onRoomMixingStateUpdate(func) {\n this.onRoomMixingStateUpdateCallBack = func;\n }\n sendRoomMessage(message) {\n return ZegoCloudRTCCore._zg.sendBroadcastMessage(ZegoCloudRTCCore._instance._expressConfig.roomID, message);\n }\n onRoomMessageUpdate(func) {\n this.onRoomMessageUpdateCallBack = func;\n }\n onScreenSharingEnded(func) {\n this.onScreenSharingEndedCallBack = func;\n }\n onNetworkStatus(func) {\n this.onNetworkStatusCallBack = (roomID, type, status) => {\n if (status === \"CONNECTING\") {\n !this.NetworkStatusTimer &&\n (this.NetworkStatusTimer = setTimeout(() => {\n func(roomID, type, \"DISCONNECTED\");\n }, 60000));\n }\n else {\n if (this.NetworkStatusTimer) {\n clearTimeout(this.NetworkStatusTimer);\n this.NetworkStatusTimer = null;\n }\n }\n func(roomID, type, status);\n };\n }\n streamExtraInfoUpdateCallBack(streamList) {\n // 流附加消息解析\n streamList.forEach((stream) => {\n const extraInfo = JSON.parse(stream.extraInfo);\n console.warn(\"extraInfo\", extraInfo);\n if (extraInfo.isCameraOn !== undefined) {\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"cameraStatus\", extraInfo.isCameraOn ? \"OPEN\" : \"MUTE\");\n }\n if (extraInfo.isMicrophoneOn !== undefined) {\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"micStatus\", extraInfo.isMicrophoneOn ? \"OPEN\" : \"MUTE\");\n }\n extraInfo.hasVideo !== undefined &&\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"hasVideo\", !!extraInfo.hasVideo);\n extraInfo.hasAudio !== undefined &&\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"hasAudio\", !!extraInfo.hasAudio);\n });\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack && this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n }\n onCoreError(func) {\n this.coreErrorCallback = func;\n }\n leaveRoom() {\n var _a;\n if (!this.status.loginRsp)\n return;\n ZegoCloudRTCCore._zg.off(\"streamExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"screenSharingEnded\");\n ZegoCloudRTCCore._zg.off(\"IMRecvCustomCommand\");\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(false);\n this.onNetworkStatusCallBack = () => { };\n this.onRemoteMediaUpdateCallBack = (updateType, streamList) => __awaiter(this, void 0, void 0, function* () {\n yield this.zum.mainStreamUpdate(updateType, streamList);\n yield this.zum.screenStreamUpdate(updateType, streamList);\n this.throttleStartAndUpdateMixinTask();\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n });\n this.onRemoteUserUpdateCallBack = () => { };\n this.onRoomMessageUpdateCallBack = () => { };\n this.onRoomLiveStateUpdateCallBack = () => { };\n this.subscribeUserListCallBack = () => { };\n this.zum.reset();\n this.localStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.localScreensharingStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n // TODO\n // this.startAndUpdateMixinTask();\n for (let key in this.remoteStreamMap) {\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n }\n this.remoteStreamMap = {};\n this.clearMixUser();\n this.waitingHandlerStreams = { add: [], delete: [] };\n if (this.isHost()) {\n // host离开房间,清除房间属性host\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n host: \"\",\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n this.hasPublishedStream = false;\n (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a.leaveRoom();\n ZegoCloudRTCCore._zg.logoutRoom();\n this.status.loginRsp = false;\n }\n setStreamExtraInfo(streamID, extraInfo) {\n return ZegoCloudRTCCore._zg.setStreamExtraInfo(streamID, extraInfo);\n }\n initZIM(ZIM) {\n if (this._zimManager)\n return;\n this._zimManager = new _tools_ZimManager__WEBPACK_IMPORTED_MODULE_4__.ZimManager(ZIM, this._expressConfig);\n // 更新roomID\n this._zimManager.onUpdateRoomID((roomID) => {\n this._expressConfig.roomID = roomID;\n });\n }\n // 发送房间自定义消息\n sendInRoomCommand(message, userIDs) {\n return __awaiter(this, void 0, void 0, function* () {\n const res = yield ZegoCloudRTCCore._zg.sendCustomCommand(this._expressConfig.roomID, message, this.zum.remoteUserList.length > 500 ? [] : userIDs);\n if (res.errorCode === 0) {\n return true;\n }\n else {\n console.error(\"【ZEGOCLOUD】sendInRoomCommand error:\", res.errorCode);\n return false;\n }\n });\n }\n // 踢人\n removeMember(userID) {\n this.sendInRoomCommand(JSON.stringify({ zego_remove_user: userID }), [userID]);\n }\n //关闭摄像头麦克风\n turnRemoteCameraOff(userID) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield this.sendInRoomCommand(JSON.stringify({ zego_turn_camera_off: userID }), [userID]);\n });\n }\n turnRemoteMicrophoneOff(userID) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield this.sendInRoomCommand(JSON.stringify({ zego_turn_microphone_off: userID }), [userID]);\n });\n }\n onKickedOutRoom(func) {\n func && (this.onKickedOutRoomCallback = func);\n }\n onChangeYourDeviceStatus(func) {\n func && (this.onChangeYourDeviceStatusCallback = func);\n }\n startMixerTask() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const { width, height, bitrate, frameRate } = (0,_util__WEBPACK_IMPORTED_MODULE_5__.getVideoResolution)(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.videoMixingOutputResolution) || \"540p\");\n const inputList = this.getMixStreamInput(width, height);\n if (!inputList.length)\n return { errorCode: 1 };\n const config = {\n taskID: `${this._expressConfig.roomID}__task`,\n inputList: this.getMixStreamInput(width, height),\n outputList: [\n `${this._expressConfig.roomID}__mix`,\n // `rtmp://publish-ws.coolxcloud.com/uikit/${this._expressConfig.roomID}_11__mix`,\n ],\n outputConfig: {\n outputBitrate: bitrate,\n outputFPS: frameRate,\n outputWidth: width,\n outputHeight: height,\n },\n };\n console.warn(\"getMixStreamInput\", config);\n try {\n return yield ZegoCloudRTCCore._zg.startMixerTask(config);\n }\n catch (error) {\n console.error(error);\n return { errorCode: 1 };\n }\n });\n }\n stopMixerTask(isHost = false) {\n return __awaiter(this, void 0, void 0, function* () {\n const taskID = `${this._expressConfig.roomID}__task`;\n if ((this.isHost() || isHost) && this.roomExtraInfo.isMixing === \"1\") {\n // 停止混流,设置房间附加属性isMixing:0|1\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n isMixing: \"0\",\n });\n yield ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n const res = yield ZegoCloudRTCCore._zg.stopMixerTask(taskID);\n console.warn(\"stopMixerTask\", res);\n return res;\n }\n });\n }\n setMixerTaskConfig(config) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield ZegoCloudRTCCore._zg.setMixerTaskConfig(config);\n });\n }\n getMixStreamInput(outWidth, outHeight) {\n const hasScreensharing = this.zum.remoteScreenStreamList.length > 0 || this.localScreensharingStreamInfo.streamID;\n const inputList = [];\n let videoWidth = 0, videoHeight = 0, screensharingWidth, screensharingHeight;\n // if((this._config.scenario?.config as ScenarioConfig[ScenarioModel.LiveStreaming])?.videoMixingLayout === VideoMixinLayoutType.AutoLayout) {\n // 自适应布局\n const streams = this.zum.remoteUserList\n .filter((user) => {\n var _a, _b, _c;\n return ((_a = user.streamList[0]) === null || _a === void 0 ? void 0 : _a.streamID) &&\n (((_b = user.streamList[0]) === null || _b === void 0 ? void 0 : _b.cameraStatus) === \"OPEN\" || ((_c = user.streamList[0]) === null || _c === void 0 ? void 0 : _c.micStatus) === \"OPEN\");\n })\n .map((u) => ({\n streamID: u.streamList[0].streamID,\n cameraStatus: u.streamList[0].cameraStatus,\n micStatus: u.streamList[0].micStatus,\n userName: u.userName,\n }));\n if (this.localStreamInfo.streamID &&\n (this.localStreamInfo.cameraStatus === \"OPEN\" || this.localStreamInfo.micStatus === \"OPEN\")) {\n streams.unshift(Object.assign(Object.assign({}, this.localStreamInfo), { userName: this._expressConfig.userName }));\n }\n let config;\n if (hasScreensharing) {\n let maxVideo = 5;\n videoHeight = Math.floor((outHeight - 16 * 2 - 4 * 10) / 5);\n videoWidth = Math.floor((videoHeight * 16) / 9);\n screensharingWidth = outWidth - 16 * 2 - 10 - videoWidth;\n screensharingHeight = outHeight - 16 * 2;\n if (streams.length > 0) {\n // screen sharing\n inputList.push({\n streamID: this.localScreensharingStreamInfo.streamID ||\n this.zum.remoteScreenStreamList[0].streamList[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: screensharingHeight + 16,\n right: screensharingWidth + 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n });\n // user streams\n streams.forEach((user) => {\n if (maxVideo > 0) {\n config = {\n streamID: user.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16 + (5 - maxVideo) * (videoHeight + 10),\n left: screensharingWidth + 26,\n bottom: 16 + (5 - maxVideo) * (videoHeight + 10) + videoHeight,\n right: outWidth - 16,\n },\n label: {\n text: user.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoWidth - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n inputList.push(config);\n maxVideo--;\n }\n else {\n inputList.push({\n streamID: user.streamID,\n contentType: \"AUDIO\",\n layout: {\n top: 0,\n left: 0,\n bottom: 1,\n right: 1,\n },\n renderMode: 1,\n });\n }\n });\n }\n else {\n // 只有屏幕共享的情况\n inputList.push({\n streamID: this.localScreensharingStreamInfo.streamID ||\n this.zum.remoteScreenStreamList[0].streamList[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: outHeight - 16,\n right: outWidth - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n });\n }\n }\n else {\n // 没有屏幕共享的情况\n let len = streams.length;\n if (len === 1) {\n config = {\n streamID: streams[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: outHeight - 16,\n right: outWidth - 16,\n },\n label: {\n text: streams[0].userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: outHeight - 16 * 2 - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (streams[0].cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n }\n else if (len === 2) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10) / 2);\n streams.forEach((u, i) => {\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16 + (videoWidth + 10) * i,\n bottom: outHeight - 16,\n right: 16 + (videoWidth + 10) * i + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: outHeight - 16 * 2 - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else if (len === 3 || len === 4) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10) / 2);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10) / 2);\n streams.forEach((u, i) => {\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: i <= 1 ? 16 : 16 + 10 + videoHeight,\n left: len === 3\n ? i < 2\n ? 16 + (videoWidth + 10) * i\n : Math.floor((outWidth - videoWidth) / 2)\n : i % 2 === 0\n ? 16\n : 16 + videoWidth + 10,\n bottom: i <= 1 ? 16 + videoHeight : outHeight - 16,\n right: len === 3 && i === 2\n ? outWidth - Math.floor((outWidth - videoWidth) / 2)\n : i % 2 === 0\n ? 16 + videoWidth\n : outWidth - 16,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else if (len === 5 || len === 6) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10 * 2) / 3);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10) / 2);\n let lastRowPaddingLeft = len === 5 ? Math.floor((videoWidth + 10) / 2) : 0;\n streams.forEach((u, i) => {\n const left = i <= 2 ? 16 + (videoWidth + 10) * i : 16 + lastRowPaddingLeft + (videoWidth + 10) * (i % 3);\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: i <= 2 ? 16 : 16 + 10 + videoHeight,\n left: left,\n bottom: i <= 2 ? 16 + videoHeight : outHeight - 16,\n right: left + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10 * 2) / 3);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10 * 2) / 3);\n let lastRowPaddingLeft = 0;\n if (len === 7) {\n lastRowPaddingLeft = videoWidth + 10;\n }\n if (len === 8) {\n lastRowPaddingLeft = Math.floor((videoWidth + 10) / 2);\n }\n streams.forEach((u, i) => {\n if (i < 9) {\n const left = i < 6\n ? 16 + (videoWidth + 10) * (i % 3)\n : 16 + lastRowPaddingLeft + (videoWidth + 10) * (i % 3);\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16 + (videoHeight + 10) * Math.floor(i / 3),\n left: left,\n bottom: 16 + (videoHeight + 10) * Math.floor(i / 3) + videoHeight,\n right: left + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n }\n else {\n inputList.push({\n streamID: u.streamID,\n contentType: \"AUDIO\",\n layout: {\n top: 0,\n left: 0,\n bottom: 1,\n right: 1,\n },\n renderMode: 1,\n });\n }\n });\n }\n }\n // }\n return inputList;\n }\n startAndUpdateMixinTask(isHost = false) {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n // 多主播情况下,非房间属性主播开启直播,也需要开始混流\n if (!this.isHost() && !isHost)\n return;\n if (!(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.enableVideoMixing) && this.roomExtraInfo.live_status === \"1\"))\n return;\n const res = yield this.startMixerTask();\n console.warn(\"startMixerTask\", res);\n if ((res === null || res === void 0 ? void 0 : res.errorCode) !== 0)\n return;\n if (this.roomExtraInfo.isMixing !== \"1\") {\n //第一次混流,需要设置房间附加属性isMixing:0|1\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n isMixing: \"1\",\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n });\n }\n // 设置混流用户数据用于渲染\n setMixUser() {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (((_b = (_a = this.mixUser) === null || _a === void 0 ? void 0 : _a.streamList) === null || _b === void 0 ? void 0 : _b.length) > 0)\n return;\n if (((_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming &&\n !this.mixStreamDomain)\n return;\n if (this.roomExtraInfo.live_status !== \"1\")\n return;\n if (!((_e = (_d = this._config.scenario) === null || _d === void 0 ? void 0 : _d.config) === null || _e === void 0 ? void 0 : _e.enableVideoMixing))\n return;\n if (this._config.scenario.config.role !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience)\n return;\n let stream = {\n media: undefined,\n fromUser: {\n userID: this.roomExtraInfo.host,\n },\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n // hasVideo: false, //为了一开始能播放纯音频\n state: \"PLAYING\",\n streamID: `${this._expressConfig.roomID}__mix`,\n };\n if (this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming) {\n // CDN\n stream.urlsHttpsFLV = `${this.mixStreamDomain}${stream.streamID}.flv`;\n stream.urlsHttpsHLS = `${this.mixStreamDomain}${stream.streamID}.m3u8`;\n }\n else {\n // RTC, L3\n try {\n const media = yield this.zum.startPullStream(this.roomExtraInfo.host, stream.streamID);\n if (media) {\n stream.media = media;\n }\n else {\n stream = null;\n }\n }\n catch (error) {\n console.error(\"startPullStream\", error);\n }\n }\n this.mixUser = {\n pin: false,\n userID: this.roomExtraInfo.host,\n userName: \"\",\n streamList: [],\n };\n stream && this.mixUser.streamList.push(stream);\n });\n }\n // 停止拉混流,Cohost变成 Audience,或离开房间时\n clearMixUser() {\n var _a, _b, _c, _d;\n if (!((_b = (_a = this.mixUser) === null || _a === void 0 ? void 0 : _a.streamList) === null || _b === void 0 ? void 0 : _b.length))\n return;\n if (((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming) {\n ZegoCloudRTCCore._zg.stopPlayingStream(this.mixUser.streamList[0].streamID);\n }\n this.mixUser.streamList = [];\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/index.ts?");
2258
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCCore\": function() { return /* binding */ ZegoCloudRTCCore; }\n/* harmony export */ });\n/* harmony import */ var _tools_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/util */ \"./src/sdk/modules/tools/util.ts\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zego-express-engine-webrtc */ \"./node_modules/.pnpm/zego-express-engine-webrtc@2.26.0/node_modules/zego-express-engine-webrtc/ZegoExpressWebRTC.js\");\n/* harmony import */ var zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/UserListManager */ \"./src/sdk/modules/tools/UserListManager.ts\");\n/* harmony import */ var _tools_ZimManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tools/ZimManager */ \"./src/sdk/modules/tools/ZimManager.ts\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _tools_EventEmitter__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tools/EventEmitter */ \"./src/sdk/modules/tools/EventEmitter.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\nclass ZegoCloudRTCCore {\n constructor() {\n this._zimManager = null;\n this.zegoSuperBoardView = undefined;\n this.eventEmitter = new _tools_EventEmitter__WEBPACK_IMPORTED_MODULE_6__.EventEmitter();\n this.status = {\n loginRsp: false,\n videoRefuse: undefined,\n audioRefuse: undefined,\n };\n this.remoteStreamMap = {};\n this.waitingHandlerStreams = { add: [], delete: [] };\n this._config = {\n // @ts-ignore\n container: undefined,\n preJoinViewConfig: {\n title: \"Join Room\", // 标题设置,默认join Room\n // invitationLink: window.location.href, // 邀请链接,空则不显示,默认空\n },\n showPreJoinView: true,\n turnOnMicrophoneWhenJoining: true,\n turnOnCameraWhenJoining: true,\n showMyCameraToggleButton: true,\n showMyMicrophoneToggleButton: true,\n showAudioVideoSettingsButton: true,\n showTextChat: true,\n showUserList: true,\n lowerLeftNotification: {\n showUserJoinAndLeave: true,\n showTextChat: true, // 是否显示未读消息,默认显示\n },\n branding: {\n logoURL: \"\",\n },\n showLeavingView: true,\n maxUsers: 0,\n layout: \"Auto\",\n showNonVideoUser: true,\n showOnlyAudioUser: false,\n useFrontFacingCamera: true,\n onJoinRoom: () => { },\n onLeaveRoom: () => { },\n onUserJoin: (user) => { },\n onUserLeave: (user) => { },\n onUserAvatarSetter: (user) => { },\n sharedLinks: [],\n showScreenSharingButton: true,\n scenario: {\n mode: _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall,\n config: {\n role: _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host,\n liveStreamingMode: undefined,\n enableVideoMixing: false,\n videoMixingLayout: _model__WEBPACK_IMPORTED_MODULE_2__.VideoMixinLayoutType.AutoLayout,\n videoMixingOutputResolution: _model__WEBPACK_IMPORTED_MODULE_2__.VideoMixinOutputResolution._540P,\n }, // 对应场景专有配置\n },\n facingMode: \"user\",\n joinRoomCallback: () => { },\n leaveRoomCallback: () => { },\n userUpdateCallback: () => { },\n showLayoutButton: true,\n showPinButton: true,\n whiteboardConfig: {\n showAddImageButton: false,\n showCreateAndCloseButton: true,\n },\n videoResolutionList: [],\n plugins: {},\n autoLeaveRoomWhenOnlySelfInRoom: false,\n showRoomTimer: false,\n videoCodec: \"H264\",\n showRoomDetailsButton: true,\n showInviteToCohostButton: false,\n showRemoveCohostButton: false,\n showRequestToCohostButton: false,\n rightPanelExpandedType: _model__WEBPACK_IMPORTED_MODULE_2__.RightPanelExpandedType.None,\n autoHideFooter: true,\n enableStereo: false,\n };\n this._currentPage = \"BrowserCheckPage\";\n this.extraInfoKey = \"extra_info\";\n this._roomExtraInfo = {\n live_status: \"0\",\n };\n this.NetworkStatusTimer = null;\n this.hostSetterTimer = null;\n this.localStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.localScreensharingStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.hasPublishedStream = false; // 是否有已经推上去的流\n this.mixStreamDomain = \"\"; // 混流域名\n this.mixUser = {}; // 混流用户数据\n this._originConfig = {};\n this.onRemoteMediaUpdateCallBack = (updateType, streamList) => __awaiter(this, void 0, void 0, function* () {\n yield this.zum.mainStreamUpdate(updateType, streamList);\n yield this.zum.screenStreamUpdate(updateType, streamList);\n this.throttleStartAndUpdateMixinTask();\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack && this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n });\n this.throttleStartAndUpdateMixinTask = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.throttle)(this.startAndUpdateMixinTask, 1200);\n }\n // static _soundMeter: SoundMeter;\n static getInstance(kitToken) {\n const config = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)(kitToken);\n if (!ZegoCloudRTCCore._instance && config) {\n ZegoCloudRTCCore._instance = new ZegoCloudRTCCore();\n ZegoCloudRTCCore._instance._expressConfig = config;\n // ZegoCloudRTCCore._soundMeter = new SoundMeter();\n ZegoCloudRTCCore._zg = new zego_express_engine_webrtc__WEBPACK_IMPORTED_MODULE_1__.ZegoExpressEngine(ZegoCloudRTCCore._instance._expressConfig.appID, \"wss://webliveroom\" + ZegoCloudRTCCore._instance._expressConfig.appID + \"-api.zegocloud.com/ws\");\n ZegoCloudRTCCore._instance.zum = new _tools_UserListManager__WEBPACK_IMPORTED_MODULE_3__.ZegoCloudUserListManager(ZegoCloudRTCCore._zg);\n }\n return ZegoCloudRTCCore._instance;\n }\n get isCDNLive() {\n var _a, _b;\n return (((_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_b = this._config.scenario.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience &&\n this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming);\n }\n isHost(userID) {\n var _a;\n userID !== null && userID !== void 0 ? userID : (userID = this._expressConfig.userID);\n return userID === ((_a = this.roomExtraInfo) === null || _a === void 0 ? void 0 : _a.host);\n }\n addPlugins(plugins) {\n this._config.plugins = plugins;\n if (plugins.ZIM && this._expressConfig.token) {\n this.initZIM(plugins.ZIM);\n }\n }\n set originConfig(config) {\n var _a;\n if (config.container) {\n this._originConfig[\"cw\"] = config.container.clientWidth / document.body.clientWidth;\n this._originConfig[\"ch\"] = config.container.clientHeight / document.body.clientHeight;\n }\n if (config.showPreJoinView !== undefined) {\n this._originConfig[\"spj\"] = config.showPreJoinView ? 1 : 0;\n }\n if (config.turnOnMicrophoneWhenJoining !== undefined) {\n this._originConfig[\"tmwj\"] = config.turnOnMicrophoneWhenJoining ? 1 : 0;\n }\n if (config.turnOnCameraWhenJoining !== undefined) {\n this._originConfig[\"tcwj\"] = config.turnOnCameraWhenJoining ? 1 : 0;\n }\n if (config.showMyMicrophoneToggleButton !== undefined) {\n this._originConfig[\"smtb\"] = config.showMyMicrophoneToggleButton ? 1 : 0;\n }\n if (config.showMyCameraToggleButton !== undefined) {\n this._originConfig[\"sctb\"] = config.showMyCameraToggleButton ? 1 : 0;\n }\n if (config.showAudioVideoSettingsButton !== undefined) {\n this._originConfig[\"savsb\"] = config.showAudioVideoSettingsButton ? 1 : 0;\n }\n if (config.showTextChat !== undefined) {\n this._originConfig[\"stc\"] = config.showTextChat ? 1 : 0;\n }\n if (config.showUserList !== undefined) {\n this._originConfig[\"sul\"] = config.showUserList ? 1 : 0;\n }\n if (config.showLeavingView !== undefined) {\n this._originConfig[\"slv\"] = config.showLeavingView ? 1 : 0;\n }\n if (config.maxUsers !== undefined) {\n this._originConfig[\"mu\"] = config.maxUsers ? 1 : 0;\n }\n if (config.layout !== undefined) {\n this._originConfig[\"lo\"] = config.layout;\n }\n if (config.showScreenSharingButton !== undefined) {\n this._originConfig[\"sssb\"] = config.showScreenSharingButton ? 1 : 0;\n }\n if (this._config.plugins.ZegoSuperBoardManager !== undefined) {\n this._originConfig[\"swbb\"] = 1;\n }\n if (this._config.plugins.ZIM !== undefined) {\n this._originConfig[\"uc\"] = 1;\n }\n if (((_a = config.scenario) === null || _a === void 0 ? void 0 : _a.mode) !== undefined) {\n this._originConfig[\"sm\"] = config.scenario.mode;\n }\n if (config.lowerLeftNotification !== undefined) {\n this._originConfig[\"lln\"] = config.lowerLeftNotification ? 1 : 0;\n }\n if (config.showNonVideoUser !== undefined) {\n this._originConfig[\"snvu\"] = config.showNonVideoUser ? 1 : 0;\n }\n if (config.showOnlyAudioUser !== undefined) {\n this._originConfig[\"snau\"] = config.showOnlyAudioUser ? 1 : 0;\n }\n if (config.onJoinRoom !== undefined) {\n this._originConfig[\"ojr\"] = 1;\n }\n if (config.onLeaveRoom !== undefined) {\n this._originConfig[\"olr\"] = 1;\n }\n if (config.onLiveStart !== undefined) {\n this._originConfig[\"ols\"] = 1;\n }\n if (config.onLiveEnd !== undefined) {\n this._originConfig[\"ole\"] = 1;\n }\n this._originConfig[\"url\"] = window.location.origin + window.location.pathname;\n }\n get originConfig() {\n return this._originConfig;\n }\n setConfig(config) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;\n this.originConfig = Object.assign({}, config);\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming) {\n if (config.showNonVideoUser === true) {\n console.error(\"【ZEGOCLOUD】 showNonVideoUser have be false scenario.mode is LiveStreaming!!\");\n return false;\n }\n config.videoCodec = \"H264\";\n config.showNonVideoUser = false;\n config.showOnlyAudioUser = true;\n config.autoLeaveRoomWhenOnlySelfInRoom = false;\n if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host) {\n if (config.turnOnMicrophoneWhenJoining === false &&\n config.turnOnCameraWhenJoining === false &&\n config.showMyCameraToggleButton === false &&\n config.showAudioVideoSettingsButton === false) {\n console.error(\"【ZEGOCLOUD】 Host could turn on at least one of the camera and the microphone!!\");\n return false;\n }\n }\n else if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n if (config.turnOnMicrophoneWhenJoining === true ||\n config.turnOnCameraWhenJoining === true ||\n config.showMyCameraToggleButton === true ||\n config.showMyMicrophoneToggleButton === true ||\n config.showAudioVideoSettingsButton === true ||\n config.showScreenSharingButton === true ||\n config.useFrontFacingCamera === true ||\n (!!config.layout && config.layout !== \"Grid\")) {\n console.error(\"【ZEGOCLOUD】 Audience cannot configure camera and microphone related params\");\n return false;\n }\n }\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n if (config.scenario.config && config.scenario.config.role === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n config.showUserList = config.showUserList === undefined ? false : config.showUserList;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n }\n }\n else {\n config.showInviteToCohostButton = false;\n config.showRemoveCohostButton = false;\n config.showRequestToCohostButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall) {\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n config.showLayoutButton = false;\n config.showPinButton = false;\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n config.showRemoveUserButton = false;\n }\n if (config.scenario && config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.GroupCall) {\n if (!config.maxUsers) {\n config.maxUsers = 0;\n }\n }\n if (config.scenario && ((_b = (_a = config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience) {\n config.showPinButton = false;\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n config.showRemoveUserButton = false;\n }\n if (((_d = (_c = config === null || config === void 0 ? void 0 : config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost) {\n config.showRemoveUserButton = false;\n }\n config.facingMode && (config.useFrontFacingCamera = config.facingMode === \"user\");\n config.joinRoomCallback && (config.onJoinRoom = config.joinRoomCallback);\n config.leaveRoomCallback && (config.onLeaveRoom = config.leaveRoomCallback);\n if (config.userUpdateCallback) {\n config.onUserJoin = (users) => {\n config.userUpdateCallback && config.userUpdateCallback(\"ADD\", users);\n };\n config.onUserLeave = (users) => {\n config.userUpdateCallback && config.userUpdateCallback(\"DELETE\", users);\n };\n }\n if (config.preJoinViewConfig && config.preJoinViewConfig.invitationLink) {\n config.sharedLinks = [\n {\n name: \"Share the link\",\n url: config.preJoinViewConfig.invitationLink,\n },\n ];\n }\n if (config.videoResolutionDefault) {\n if (!config.videoResolutionList) {\n config.videoResolutionList = [];\n }\n (_e = config.videoResolutionList) === null || _e === void 0 ? void 0 : _e.unshift(config.videoResolutionDefault);\n }\n if (config.videoResolutionList && config.videoResolutionList.length > 0) {\n const list = Array.from(new Set(config.videoResolutionList)).filter((s) => {\n return (s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._180P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._480P ||\n s === _model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._720P);\n });\n config.videoResolutionList = list.length > 0 ? list : [_model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P];\n }\n else {\n config.videoResolutionList = [_model__WEBPACK_IMPORTED_MODULE_2__.VideoResolution._360P];\n }\n config.preJoinViewConfig &&\n (config.preJoinViewConfig = Object.assign(Object.assign({}, this._config.preJoinViewConfig), config.preJoinViewConfig));\n config.scenario &&\n // @ts-ignore\n (config.scenario.config = Object.assign(Object.assign(Object.assign({}, (_f = this._config.scenario) === null || _f === void 0 ? void 0 : _f.config), (config.scenario.config || {})), { enableVideoMixing: config.scenario.mode === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming\n ? (_g = config.scenario.config) === null || _g === void 0 ? void 0 : _g.enableVideoMixing\n : false }));\n config.whiteboardConfig &&\n (config.whiteboardConfig = Object.assign(Object.assign({}, this._config.whiteboardConfig), config.whiteboardConfig));\n this._config = Object.assign(Object.assign({}, this._config), config);\n this.zum.scenario = ((_h = this._config.scenario) === null || _h === void 0 ? void 0 : _h.mode) || _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.OneONoneCall;\n this.zum.role = ((_k = (_j = this._config.scenario) === null || _j === void 0 ? void 0 : _j.config) === null || _k === void 0 ? void 0 : _k.role) || _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host;\n this.zum.enableVideoMixing = ((_m = (_l = this._config.scenario) === null || _l === void 0 ? void 0 : _l.config) === null || _m === void 0 ? void 0 : _m.enableVideoMixing) || false;\n this.zum.liveStreamingMode = this.getLiveStreamingMode((_p = (_o = this._config.scenario) === null || _o === void 0 ? void 0 : _o.config) === null || _p === void 0 ? void 0 : _p.liveStreamingMode);\n this.zum.showOnlyAudioUser = !!this._config.showOnlyAudioUser;\n this.zum.setShowNonVideo(!!this._config.showNonVideoUser);\n if (!this._config.turnOnCameraWhenJoining && !this._config.showMyCameraToggleButton) {\n this.status.videoRefuse = true;\n }\n if (config.console) {\n let logLevel = \"debug\";\n if (config.console === \"Info\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"Warning\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"Error\") {\n logLevel = \"warn\";\n }\n else if (config.console === \"None\") {\n logLevel = \"disable\";\n }\n ZegoCloudRTCCore._zg.setLogConfig({\n logLevel,\n });\n }\n return true;\n }\n // Audience变成Cohost\n changeAudienceToCohostInLiveStream() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const config = this._config;\n config.scenario.config.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\n this.zum.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Cohost;\n config.turnOnMicrophoneWhenJoining = true;\n config.turnOnCameraWhenJoining = true;\n config.showMyCameraToggleButton = true;\n config.showMyMicrophoneToggleButton = true;\n config.showAudioVideoSettingsButton = true;\n config.showScreenSharingButton = true;\n config.useFrontFacingCamera = true;\n config.showUserList = true;\n config.showPinButton = true;\n config.showLayoutButton = true;\n config.layout = \"Auto\";\n config.lowerLeftNotification = {\n showTextChat: true,\n showUserJoinAndLeave: true,\n };\n config.showTurnOffRemoteCameraButton = true;\n config.showTurnOffRemoteMicrophoneButton = true;\n this.status.videoRefuse = undefined;\n this.clearMixUser();\n // 拉流需要变成RTC的\n let _streamList = [];\n for (let streamInfo of Object.values(this.remoteStreamMap)) {\n // 需要停止原来的L3拉流\n if (streamInfo.media &&\n ((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive) {\n ZegoCloudRTCCore._zg.stopPlayingStream(streamInfo.streamID);\n }\n try {\n const stream = yield this.zum.startPullStream(streamInfo.fromUser.userID, streamInfo.streamID);\n this.remoteStreamMap[streamInfo.streamID].media = stream;\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】change to Cohost:\", error);\n }\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", _streamList);\n });\n }\n // Cohost 变成 Audience\n changeCohostToAudienceInLiveStream() {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n const config = this._config;\n config.scenario.config.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\n this.zum.role = _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience;\n config.turnOnMicrophoneWhenJoining = false;\n config.turnOnCameraWhenJoining = false;\n config.showMyCameraToggleButton = false;\n config.showMyMicrophoneToggleButton = false;\n config.showAudioVideoSettingsButton = false;\n config.showScreenSharingButton = false;\n config.useFrontFacingCamera = false;\n // config.showUserList = true;\n config.showPinButton = false;\n config.showLayoutButton = false;\n config.layout = \"Grid\";\n config.lowerLeftNotification = {\n showTextChat: false,\n showUserJoinAndLeave: false,\n };\n config.showTurnOffRemoteCameraButton = false;\n config.showTurnOffRemoteMicrophoneButton = false;\n this.setMixUser();\n // 如果是设置的RTC拉流则不变,否则需要重新拉流\n try {\n if (((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive &&\n !((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.enableVideoMixing)) {\n let _streamList = [];\n for (let key in this.remoteStreamMap) {\n // 先停止拉流\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n // 重新拉流\n if (this.isCDNLive) {\n if (!this.mixStreamDomain) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportCDNLive, \"urlsFLV is empty\");\n }\n // CDN拉流\n this.remoteStreamMap[key].media = undefined;\n this.remoteStreamMap[key].urlsHttpsFLV = `${this.mixStreamDomain}${key}.flv`;\n this.remoteStreamMap[key].urlsHttpsHLS = `${this.mixStreamDomain}${key}.m3u8`;\n }\n else {\n const stream = yield this.zum.startPullStream(this.remoteStreamMap[key].fromUser.userID, key);\n this.remoteStreamMap[key].media = stream;\n this.remoteStreamMap[key].urlsHttpsFLV = \"\";\n this.remoteStreamMap[key].urlsHttpsHLS = \"\";\n }\n _streamList.push(this.remoteStreamMap[key]);\n }\n _streamList.length > 0 && ((_e = this.onRemoteMediaUpdateCallBack) === null || _e === void 0 ? void 0 : _e.call(this, \"UPDATE\", _streamList));\n }\n }\n catch (error) {\n console.error(error);\n }\n });\n }\n // 兼容处理LiveStreamingMode\n getLiveStreamingMode(mode) {\n if (mode === \"StandardLive\" || mode === \"LiveStreaming\")\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming;\n if (mode === \"PremiumLive\" || mode === \"InteractiveLiveStreaming\")\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.InteractiveLiveStreaming;\n return _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.RealTimeLive;\n }\n checkWebRTC() {\n return __awaiter(this, void 0, void 0, function* () {\n if (!this.isCDNLive) {\n const webRTC = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"webRTC\");\n if (this._config.videoCodec === \"H264\") {\n const H264 = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"H264\");\n return !!webRTC.result && !!H264.result;\n }\n if (this._config.videoCodec === \"VP8\") {\n const VP8 = yield ZegoCloudRTCCore._zg.checkSystemRequirements(\"VP8\");\n return !!webRTC.result && !!VP8.result;\n }\n return !!webRTC.result;\n }\n return true;\n });\n }\n setPin(userID, pined, stopUpdateUser) {\n this.zum.setPin(userID, pined);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n }\n setMaxScreenNum(num, stopUpdateUser) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setMaxScreenNum(num);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n });\n }\n setSidebarLayOut(enable, stopUpdateUser) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setSidebarLayOut(enable);\n if (!stopUpdateUser) {\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }\n });\n }\n setShowNonVideo(enable) {\n return __awaiter(this, void 0, void 0, function* () {\n yield this.zum.setShowNonVideo(enable);\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n });\n }\n setCurrentPage(page) {\n this._currentPage = page;\n }\n getCameras() {\n return ZegoCloudRTCCore._zg.getCameras();\n }\n useVideoDevice(localStream, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(localStream, deviceID);\n }\n getMicrophones() {\n return ZegoCloudRTCCore._zg.getMicrophones();\n }\n getSpeakers() {\n return ZegoCloudRTCCore._zg.getSpeakers();\n }\n setVolume(media, volume) {\n media.volume = volume;\n }\n createStream(source) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.createStream(source);\n });\n }\n createAndPublishWhiteboard(parentDom, name) {\n return __awaiter(this, void 0, void 0, function* () {\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n yield this.zegoSuperBoard.createWhiteboardView({\n name,\n perPageWidth: 1480.3,\n perPageHeight: 758.5,\n pageCount: 5, // 白板页数\n });\n // this.zegoSuperBoard.setBrushColor(\"#F64326\"); not working to set default color\n return this.zegoSuperBoard.getSuperBoardView();\n });\n }\n setWhiteboardToolType(type, fontSize, color) {\n return __awaiter(this, void 0, void 0, function* () {\n if (type === 512) {\n const zegoSuperBoardSubView = this.zegoSuperBoard.getSuperBoardView().getCurrentSuperBoardSubView();\n zegoSuperBoardSubView && zegoSuperBoardSubView.clearCurrentPage();\n }\n else {\n this.zegoSuperBoard.setToolType(type);\n if ([1, 4, 8, 16].includes(type)) {\n fontSize && this.zegoSuperBoard.setBrushSize(fontSize);\n color && this.zegoSuperBoard.setBrushColor(color);\n }\n }\n });\n }\n setWhiteboardFont(font, fontSize, color) {\n if (font === \"BOLD\") {\n this.zegoSuperBoard.setFontBold(true);\n }\n else if (font === \"NO_BOLD\") {\n this.zegoSuperBoard.setFontBold(false);\n }\n else if (font === \"ITALIC\") {\n this.zegoSuperBoard.setFontItalic(true);\n }\n else if (font === \"NO_ITALIC\") {\n this.zegoSuperBoard.setFontItalic(false);\n }\n fontSize && this.zegoSuperBoard.setFontSize(fontSize);\n color && this.zegoSuperBoard.setBrushColor(color);\n }\n setVideoConfig(media, constraints) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.setVideoConfig(media, constraints);\n });\n }\n stopPublishingStream(streamID) {\n if (streamID.indexOf(\"_main\") > -1) {\n this.localStreamInfo = {};\n }\n if (streamID.indexOf(\"_screensharing\") > -1) {\n // 停止屏幕共享,更新混流\n this.localScreensharingStreamInfo = {};\n this.startAndUpdateMixinTask();\n }\n return ZegoCloudRTCCore._zg.stopPublishingStream(streamID);\n }\n destroyStream(stream) {\n ZegoCloudRTCCore._zg.destroyStream(stream);\n }\n destroyAndStopPublishWhiteboard() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const uniqueID = (_b = (_a = this.zegoSuperBoard.getSuperBoardView()) === null || _a === void 0 ? void 0 : _a.getCurrentSuperBoardSubView()) === null || _b === void 0 ? void 0 : _b.getModel().uniqueID;\n if (uniqueID) {\n this.zegoSuperBoard.destroySuperBoardSubView(uniqueID);\n }\n const result = yield this.zegoSuperBoard.querySuperBoardSubViewList();\n for (let i = 0; i < result.length; i++) {\n yield this.zegoSuperBoard.destroySuperBoardSubView(result[i].uniqueID);\n }\n });\n }\n useCameraDevice(media, deviceID) {\n return ZegoCloudRTCCore._zg.useVideoDevice(media, deviceID);\n }\n useMicrophoneDevice(media, deviceID) {\n return ZegoCloudRTCCore._zg.useAudioDevice(media, deviceID);\n }\n useSpeakerDevice(media, deviceID) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!media.srcObject) {\n return Promise.resolve({ errorCode: -1 });\n }\n try {\n const res = yield ZegoCloudRTCCore._zg.useAudioOutputDevice(media, deviceID);\n return { errorCode: res ? 0 : -1 };\n }\n catch (error) {\n return { errorCode: -1 };\n }\n });\n }\n enableVideoCaptureDevice(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.cameraStatus = !enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.enableVideoCaptureDevice(localStream, enable);\n });\n }\n mutePublishStreamVideo(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.cameraStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.mutePublishStreamVideo(localStream, enable);\n });\n }\n mutePublishStreamAudio(localStream, enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.micStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.mutePublishStreamAudio(localStream, enable);\n });\n }\n muteMicrophone(enable) {\n return __awaiter(this, void 0, void 0, function* () {\n this.localStreamInfo.micStatus = enable ? \"MUTE\" : \"OPEN\";\n this.startAndUpdateMixinTask();\n return ZegoCloudRTCCore._zg.muteMicrophone(enable);\n });\n }\n set roomExtraInfo(value) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n if (this._currentPage === \"Room\") {\n if (this._roomExtraInfo.live_status === \"0\" && value.live_status === \"1\") {\n // 开始直播\n this.setMixUser();\n this._config.onLiveStart &&\n this._config.onLiveStart({\n userID: this._expressConfig.userID,\n userName: this._expressConfig.userID,\n });\n }\n else if (this._roomExtraInfo.live_status === \"1\" && value.live_status === \"0\") {\n // 停止直播\n this.clearMixUser();\n (_b = (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a._inRoomInviteMg) === null || _b === void 0 ? void 0 : _b.audienceCancelRequest();\n (_d = (_c = this._zimManager) === null || _c === void 0 ? void 0 : _c._inRoomInviteMg) === null || _d === void 0 ? void 0 : _d.hostCancelAllInvitation();\n this._config.onLiveEnd &&\n this._config.onLiveEnd({\n userID: this._expressConfig.userID,\n userName: this._expressConfig.userID,\n });\n }\n this._roomExtraInfo = value;\n this.zum.setLiveStates(this._roomExtraInfo.live_status);\n (_e = this.onRoomLiveStateUpdateCallBack) === null || _e === void 0 ? void 0 : _e.call(this, this._roomExtraInfo.live_status);\n (_f = this.onRoomMixingStateUpdateCallBack) === null || _f === void 0 ? void 0 : _f.call(this, this._roomExtraInfo.isMixing);\n // 直播时设置房间属性host\n if (this.hostSetterTimer) {\n clearTimeout(this.hostSetterTimer);\n this.hostSetterTimer = null;\n }\n if (((_g = this._config.scenario) === null || _g === void 0 ? void 0 : _g.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_h = this._config.scenario.config) === null || _h === void 0 ? void 0 : _h.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host &&\n !this._roomExtraInfo.host) {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n host: this._expressConfig.userID,\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n if (value.live_status === \"1\" && this.roomExtraInfo.isMixing === \"1\") {\n // TODO:开播时 主播离开房间,自己变成主播,刷新混流\n this.startAndUpdateMixinTask();\n }\n }\n }\n else if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.roomExtraInfo = value;\n }, 1000);\n }\n (_j = this._zimManager) === null || _j === void 0 ? void 0 : _j._inRoomInviteMg.updateRoomExtraInfo(this._roomExtraInfo);\n }\n get roomExtraInfo() {\n return this._roomExtraInfo;\n }\n setLive(status) {\n var _a, _b, _c, _d;\n return __awaiter(this, void 0, void 0, function* () {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n live_status: status === \"live\" ? \"1\" : \"0\",\n });\n const res = yield ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n if (res.errorCode === 0) {\n this.roomExtraInfo = setRoomExtraInfo;\n if (status === \"live\") {\n this.startAndUpdateMixinTask(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host);\n }\n else {\n this.stopMixerTask(((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host);\n }\n }\n return res.errorCode === 0;\n });\n }\n enterRoom() {\n var _a, _b, _c, _d;\n return __awaiter(this, void 0, void 0, function* () {\n // 已经登陆过不再登录\n if (this.status.loginRsp)\n return Promise.resolve(0);\n if ((_a = this._config.plugins) === null || _a === void 0 ? void 0 : _a.ZegoSuperBoardManager) {\n this.zegoSuperBoard = this._config.plugins.ZegoSuperBoardManager.getInstance();\n this.zegoSuperBoard.init(ZegoCloudRTCCore._zg, {\n isTestEnv: false,\n parentDomID: \"ZegoCloudWhiteboardContainer\",\n appID: this._expressConfig.appID,\n userID: this._expressConfig.userID,\n token: this._expressConfig.token, // 登录房间需要用于验证身份的 Token\n });\n if (this._config.console) {\n let logLevel = \"debug\";\n if (this._config.console === \"Info\") {\n logLevel = \"warn\";\n }\n else if (this._config.console === \"Warning\") {\n logLevel = \"warn\";\n }\n else if (this._config.console === \"Error\") {\n logLevel = \"error\";\n }\n else if (this._config.console === \"None\") {\n logLevel = \"disable\";\n }\n this.zegoSuperBoard.setLogConfig({\n logLevel,\n remoteLogLevel: logLevel,\n });\n }\n this.zegoSuperBoard.setWhiteboardBackgroundColor(\"#ffffff\");\n }\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvCustomCommand\");\n if (this.zegoSuperBoard) {\n // 监听远端新增白板\n this.zegoSuperBoard.off(\"remoteSuperBoardSubViewAdded\");\n // 监听远端销毁白板\n this.zegoSuperBoard.off(\"remoteSuperBoardSubViewRemoved\");\n }\n ZegoCloudRTCCore._zg.on(\"roomStreamUpdate\", (roomID, updateType, streamList, extendedData) => __awaiter(this, void 0, void 0, function* () {\n var _e, _f;\n if (updateType === \"ADD\") {\n this.mixStreamDomain = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(((_f = (_e = streamList[0]) === null || _e === void 0 ? void 0 : _e.urlsFLV) === null || _f === void 0 ? void 0 : _f.replace(/[^/]+$/, \"\")) || \"\");\n this.waitingHandlerStreams.add = [...this.waitingHandlerStreams.add, ...streamList];\n this.waitingHandlerStreams.delete = this.waitingHandlerStreams.delete.filter((stream) => {\n if (streamList.some((add_stream) => add_stream.streamID === stream.streamID)) {\n return false;\n }\n else {\n return true;\n }\n });\n }\n else {\n // 找出删除流中,和之前的新增流重叠的,存储这个下面对象中\n let willDelete = [];\n // 新增流中,删除下线的流\n this.waitingHandlerStreams.add = this.waitingHandlerStreams.add.filter((stream) => {\n if (streamList.some((delete_stream) => {\n if (delete_stream.streamID === stream.streamID) {\n willDelete.push(delete_stream.streamID);\n return true;\n }\n else {\n return false;\n }\n })) {\n return false;\n }\n else {\n return true;\n }\n });\n // 删除流中,去除上次要新增的\n streamList = streamList.filter((s) => {\n if (willDelete.some((wd) => wd === s.streamID)) {\n return false;\n }\n else {\n return true;\n }\n });\n this.waitingHandlerStreams.delete = [...this.waitingHandlerStreams.delete, ...streamList];\n }\n // console.error(\"roomStreamUpdate\", this.waitingHandlerStreams);\n }));\n ZegoCloudRTCCore._zg.on(\"roomExtraInfoUpdate\", (roomID, roomExtraInfoList) => {\n roomExtraInfoList.forEach((info) => {\n if (info.key === this.extraInfoKey) {\n this.roomExtraInfo = JSON.parse(info.value);\n console.warn(\"roomExtraInfo\", this.roomExtraInfo);\n }\n });\n });\n ZegoCloudRTCCore._zg.on(\"remoteCameraStatusUpdate\", (streamID, status) => {\n console.warn(\"remoteCameraStatusUpdate\", streamID, status);\n if (this.remoteStreamMap[streamID]) {\n this.remoteStreamMap[streamID].cameraStatus = status;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamID]]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"remoteMicStatusUpdate\", (streamID, status) => {\n console.warn(\"remoteMicStatusUpdate\", streamID, status);\n if (this.remoteStreamMap[streamID]) {\n this.remoteStreamMap[streamID].micStatus = status;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamID]]);\n }\n });\n ZegoCloudRTCCore._zg.on(\"playerStateUpdate\", (streamInfo) => {\n console.warn(\"【ZEGOCLOUD】playerStateUpdate\", streamInfo);\n if (this.remoteStreamMap[streamInfo.streamID]) {\n this.remoteStreamMap[streamInfo.streamID].state = streamInfo.state;\n this.onRemoteMediaUpdateCallBack &&\n this.onRemoteMediaUpdateCallBack(\"UPDATE\", [this.remoteStreamMap[streamInfo.streamID]]);\n }\n if (streamInfo.errorCode === 1104038) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportStandardLive, streamInfo.extendedData);\n }\n if (streamInfo.errorCode === 1104039 && streamInfo.streamID.includes(\"__mix\")) {\n // 混流拉流重试\n setTimeout(() => {\n this.clearMixUser();\n this.setMixUser();\n }, 2000);\n }\n });\n ZegoCloudRTCCore._zg.on(\"roomUserUpdate\", (roomID, updateType, userList) => {\n var _a;\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", updateType, userList);\n if (updateType === \"DELETE\") {\n (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a._inRoomInviteMg.clearInviteWhenUserLeave(userList);\n }\n if (this.onRemoteUserUpdateCallBack) {\n this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n }\n else {\n setTimeout(() => {\n this.onRemoteUserUpdateCallBack &&\n this.onRemoteUserUpdateCallBack(roomID, updateType, userList);\n }, 1000);\n }\n });\n ZegoCloudRTCCore._zg.on(\"IMRecvBroadcastMessage\", (roomID, chatData) => {\n this.onRoomMessageUpdateCallBack && this.onRoomMessageUpdateCallBack(roomID, chatData);\n chatData.forEach((data) => {\n this._config.onInRoomMessageReceived && this._config.onInRoomMessageReceived(data);\n });\n });\n // 房间内自定义消息\n ZegoCloudRTCCore._zg.on(\"IMRecvCustomCommand\", (roomID, fromUser, command) => {\n try {\n const commandData = JSON.parse(command);\n console.warn(\"IMRecvCustomCommand\", commandData);\n if (Object.keys(commandData).includes(\"zego_remove_user\") &&\n commandData[\"zego_remove_user\"].includes(this._expressConfig.userID)) {\n // 被移除房间的通知\n // 通知UI层leaveRoom\n this.onKickedOutRoomCallback && this.onKickedOutRoomCallback();\n return;\n }\n if (Object.keys(commandData).includes(\"zego_turn_camera_off\") &&\n commandData[\"zego_turn_camera_off\"] === this._expressConfig.userID) {\n // 通知UI层关闭摄像头\n this.onChangeYourDeviceStatusCallback &&\n this.onChangeYourDeviceStatusCallback(\"Camera\", \"CLOSE\", fromUser);\n return;\n }\n if (Object.keys(commandData).includes(\"zego_turn_microphone_off\") &&\n commandData[\"zego_turn_microphone_off\"] === this._expressConfig.userID) {\n // 通知UI层关闭麦克风\n this.onChangeYourDeviceStatusCallback &&\n this.onChangeYourDeviceStatusCallback(\"Microphone\", \"CLOSE\", fromUser);\n return;\n }\n }\n catch (error) { }\n this._config.onInRoomCommandReceived && this._config.onInRoomCommandReceived(fromUser, command);\n });\n ZegoCloudRTCCore._zg.on(\"publisherStateUpdate\", (streamInfo) => {\n let state = \"DISCONNECTED\";\n if (streamInfo.state === \"PUBLISHING\") {\n state = \"CONNECTED\";\n // 推流成功后开始混流\n if (this.roomExtraInfo.live_status === \"1\") {\n // 直播后再开始混流\n this.startAndUpdateMixinTask();\n }\n else {\n // 直播未开始,先标记已经有推流了\n this.hasPublishedStream = true;\n }\n }\n else if (streamInfo.state === \"NO_PUBLISH\") {\n state = \"DISCONNECTED\";\n }\n else if (streamInfo.state === \"PUBLISH_REQUESTING\") {\n state = \"CONNECTING\";\n }\n this.onNetworkStatusCallBack &&\n this.onNetworkStatusCallBack(ZegoCloudRTCCore._instance._expressConfig.roomID, \"STREAM\", state);\n });\n ZegoCloudRTCCore._zg.on(\"playQualityUpdate\", (streamID, stats) => {\n this.onNetworkStatusQualityCallBack &&\n this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"publishQualityUpdate\", (streamID, stats) => {\n this.onNetworkStatusQualityCallBack &&\n this.onNetworkStatusQualityCallBack(streamID, Math.max(stats.video.videoQuality, stats.audio.audioQuality));\n });\n ZegoCloudRTCCore._zg.on(\"soundLevelUpdate\", (soundLevelList) => {\n this.onSoundLevelUpdateCallBack && this.onSoundLevelUpdateCallBack(soundLevelList);\n });\n ZegoCloudRTCCore._zg.on(\"screenSharingEnded\", (stream) => {\n this.onScreenSharingEndedCallBack && this.onScreenSharingEndedCallBack(stream);\n });\n if (this.zegoSuperBoard) {\n // 监听远端新增白板\n this.zegoSuperBoard.on(\"remoteSuperBoardSubViewAdded\", (uniqueID) => __awaiter(this, void 0, void 0, function* () {\n yield this.zegoSuperBoard.querySuperBoardSubViewList();\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n this.zegoSuperBoardView = this.zegoSuperBoard.getSuperBoardView();\n }));\n // 监听远端销毁白板\n this.zegoSuperBoard.on(\"remoteSuperBoardSubViewRemoved\", (uniqueID) => {\n this.zegoSuperBoardView = null;\n });\n }\n // if (this.isCDNLive) {\n ZegoCloudRTCCore._zg.on(\"streamExtraInfoUpdate\", (roomID, streamList) => {\n if (roomID === this._expressConfig.roomID) {\n console.warn(\"streamExtraInfoUpdate\", streamList);\n this.streamExtraInfoUpdateCallBack(streamList);\n }\n });\n // }\n // 监听房间内ZIM text消息\n this._config.onInRoomTextMessageReceived &&\n ((_b = this._zimManager) === null || _b === void 0 ? void 0 : _b.onRoomTextMessage(this._config.onInRoomTextMessageReceived));\n this._config.onInRoomCustomCommandReceived &&\n ((_c = this._zimManager) === null || _c === void 0 ? void 0 : _c.onRoomCommandMessage(this._config.onInRoomCustomCommandReceived));\n const resp = yield new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {\n var _g, _h;\n ZegoCloudRTCCore._zg.on(\"roomStateUpdate\", (roomID, state, errorCode, extendedData) => {\n this.onNetworkStatusCallBack && this.onNetworkStatusCallBack(roomID, \"ROOM\", state);\n if (state === \"CONNECTED\" || state === \"DISCONNECTED\") {\n this.status.loginRsp = errorCode === 0;\n res(errorCode);\n }\n });\n yield ZegoCloudRTCCore._zg.loginRoom(ZegoCloudRTCCore._instance._expressConfig.roomID, ZegoCloudRTCCore._instance._expressConfig.token, {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n }, {\n userUpdate: true,\n maxMemberCount: ZegoCloudRTCCore._instance._config.maxUsers,\n });\n if (((_g = this._config.scenario) === null || _g === void 0 ? void 0 : _g.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n ((_h = this._config.scenario.config) === null || _h === void 0 ? void 0 : _h.role) === _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Host &&\n this.roomExtraInfo.host === undefined) {\n // 进房后如果没有host,就将自己设置为host\n this.hostSetterTimer = setTimeout(() => {\n if (!this.roomExtraInfo.host) {\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n host: this._expressConfig.userID,\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n }, 2000);\n }\n if (this.zegoSuperBoard) {\n this.zegoSuperBoard.setToolType(1);\n this.zegoSuperBoard.setBrushColor(\"#333333\");\n this.zegoSuperBoard.setBrushSize(6);\n this.zegoSuperBoard.setFontItalic(false);\n this.zegoSuperBoard.setFontBold(false);\n this.zegoSuperBoard.setFontSize(24);\n const result = yield this.zegoSuperBoard.querySuperBoardSubViewList();\n result.length > 0 && (this.zegoSuperBoardView = this.zegoSuperBoard.getSuperBoardView());\n }\n const user = {\n userID: ZegoCloudRTCCore._instance._expressConfig.userID,\n userName: ZegoCloudRTCCore._instance._expressConfig.userName,\n setUserAvatar: (avatar) => {\n if (avatar && typeof avatar === \"string\") {\n this._expressConfig.avatar = avatar;\n }\n },\n };\n this._config.onUserAvatarSetter && this._config.onUserAvatarSetter([user]);\n // @ts-ignore 日志上报\n ZegoCloudRTCCore._zg.logger.error(\"zu.jr \" + JSON.stringify(this.originConfig));\n }));\n (_d = this._zimManager) === null || _d === void 0 ? void 0 : _d.enterRoom();\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(true, 300);\n this.streamUpdateTimer(this.waitingHandlerStreams);\n return resp;\n });\n }\n streamUpdateTimer(_waitingHandlerStreams) {\n return __awaiter(this, void 0, void 0, function* () {\n if (!this.status.loginRsp) {\n console.warn(\"【ZEGOCLOUD】logoutRoom,stop streamUpdateTimer\");\n return;\n }\n if (this._currentPage === \"Room\") {\n let _streamList = [];\n if (_waitingHandlerStreams.add.length > 0) {\n for (let i = 0; i < _waitingHandlerStreams.add.length; i++) {\n const streamInfo = _waitingHandlerStreams.add[i];\n let extraInfo = {\n isMicrophoneOn: undefined,\n isCameraOn: undefined,\n hasAudio: undefined,\n hasVideo: undefined,\n };\n try {\n // 防止流附加消息为空解析报错\n extraInfo = JSON.parse(streamInfo.extraInfo);\n }\n catch (err) { }\n try {\n if (this.isCDNLive) {\n if (!streamInfo.urlsFLV) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportCDNLive, \"urlsFLV is empty\");\n }\n // CDN拉流\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: undefined,\n micStatus: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMicrophoneOn) ? \"OPEN\" : \"MUTE\",\n cameraStatus: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isCameraOn) ? \"OPEN\" : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n urlsHttpsFLV: (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(streamInfo.urlsHttpsFLV || streamInfo.urlsFLV),\n urlsHttpsHLS: (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.changeCDNUrlOrigin)(streamInfo.urlsHttpsHLS || streamInfo.urlsHLS),\n hasAudio: extraInfo.hasAudio,\n hasVideo: extraInfo.hasVideo,\n };\n }\n else {\n const stream = yield this.zum.startPullStream(streamInfo.user.userID, streamInfo.streamID);\n this.remoteStreamMap[streamInfo.streamID] = {\n fromUser: streamInfo.user,\n media: stream,\n micStatus: stream\n ? stream.getAudioTracks().length > 0\n ? \"OPEN\"\n : \"MUTE\"\n : (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMicrophoneOn)\n ? \"OPEN\"\n : \"MUTE\",\n cameraStatus: stream\n ? stream.getVideoTracks().length > 0\n ? \"OPEN\"\n : \"MUTE\"\n : (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isCameraOn)\n ? \"OPEN\"\n : \"MUTE\",\n state: \"PLAYING\",\n streamID: streamInfo.streamID,\n };\n }\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n }\n catch (error) {\n console.warn(\"【ZEGOCLOUD】startPlayingStream error:\", error);\n // 未开通L3服务\n if ((error === null || error === void 0 ? void 0 : error.errorCode) === 110438) {\n this.coreErrorCallback(_model__WEBPACK_IMPORTED_MODULE_2__.CoreError.notSupportStandardLive, error === null || error === void 0 ? void 0 : error.extendedData);\n }\n }\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"ADD\", _streamList);\n }\n if (_waitingHandlerStreams.delete.length > 0) {\n _streamList = [];\n for (let i = 0; i < _waitingHandlerStreams.delete.length; i++) {\n const streamInfo = _waitingHandlerStreams.delete[i];\n this.remoteStreamMap[streamInfo.streamID] &&\n _streamList.push(this.remoteStreamMap[streamInfo.streamID]);\n yield this.zum.stopPullStream(streamInfo.user.userID, streamInfo.streamID);\n delete this.remoteStreamMap[streamInfo.streamID];\n }\n this.onRemoteMediaUpdateCallBack &&\n _streamList.length > 0 &&\n this.onRemoteMediaUpdateCallBack(\"DELETE\", _streamList);\n }\n if (this.zegoSuperBoardView !== undefined) {\n this.subscribeWhiteBoardCallBack(this.zegoSuperBoardView);\n this.zegoSuperBoardView = undefined;\n }\n // const nextWaitingHandlerStreams = {\n // add: [...this.waitingHandlerStreams.add],\n // delete: [...this.waitingHandlerStreams.delete],\n // };\n const nextWaitingHandlerStreams = {\n add: this.waitingHandlerStreams.add.filter((realTime_item) => {\n if (_waitingHandlerStreams.add.some((handing_item) => handing_item.streamID === realTime_item.streamID)) {\n return false;\n }\n else {\n return true;\n }\n }),\n delete: this.waitingHandlerStreams.delete.filter((realTime_item) => {\n if (_waitingHandlerStreams.delete.some((handing_item) => handing_item.streamID === realTime_item.streamID)) {\n return false;\n }\n else {\n return true;\n }\n }),\n };\n this.setMixUser();\n this.waitingHandlerStreams = nextWaitingHandlerStreams;\n setTimeout(() => {\n this.streamUpdateTimer(this.waitingHandlerStreams);\n }, 700);\n }\n else if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.streamUpdateTimer(_waitingHandlerStreams);\n }, 1000);\n }\n });\n }\n publishLocalStream(media, streamType, extraInfo) {\n if (!media)\n return false;\n const streamID = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.generateStreamID)(this._expressConfig.userID, this._expressConfig.roomID, streamType);\n if (streamType === \"main\") {\n this.localStreamInfo.streamID = streamID;\n }\n if (streamType === \"screensharing\") {\n this.localScreensharingStreamInfo.streamID = streamID;\n }\n let publishOption;\n if (extraInfo) {\n publishOption = {\n extraInfo,\n };\n }\n const res = ZegoCloudRTCCore._zg.startPublishingStream(streamID, media, Object.assign(Object.assign({}, publishOption), { videoCodec: this._config.videoCodec }));\n return res && streamID;\n }\n replaceTrack(media, mediaStreamTrack) {\n return __awaiter(this, void 0, void 0, function* () {\n return ZegoCloudRTCCore._zg.replaceTrack(media, mediaStreamTrack);\n });\n }\n subscribeUserList(callback) {\n this.subscribeUserListCallBack = callback;\n }\n subscribeScreenStream(callback) {\n this.subscribeScreenStreamCallBack = callback;\n }\n subscribeWhiteBoard(callback) {\n this.subscribeWhiteBoardCallBack = callback;\n }\n onNetworkStatusQuality(func) {\n this.onNetworkStatusQualityCallBack = func;\n }\n onRemoteUserUpdate(func) {\n this.onRemoteUserUpdateCallBack = (roomID, updateType, users) => __awaiter(this, void 0, void 0, function* () {\n if (this._currentPage === \"BrowserCheckPage\" || this._currentPage === \"RejoinRoom\") {\n setTimeout(() => {\n this.onRemoteUserUpdateCallBack(roomID, updateType, users);\n }, 1000);\n }\n else if (this._currentPage === \"Room\") {\n // 本地数据管理\n yield this.zum.userUpdate(roomID, updateType, users);\n // 人员进出通知\n func(roomID, updateType, users, this.zum.remoteUserList);\n // 用户监听回调\n const newUserList = users.map((user) => {\n user.setUserAvatar = (avatar) => {\n if (avatar && typeof avatar === \"string\") {\n this.zum.updateUserInfo(user.userID, \"avatar\", avatar);\n }\n };\n return user;\n });\n if (updateType === \"ADD\") {\n this._config.onUserAvatarSetter && this._config.onUserAvatarSetter(newUserList);\n this._config.onUserJoin && this._config.onUserJoin(users);\n }\n else {\n this._config.onUserLeave && this._config.onUserLeave(users);\n }\n // 页面渲染\n setTimeout(() => {\n console.warn(\"【ZEGOCLOUD】roomUserUpdate\", [...this.zum.remoteUserList], [...this.zum.remoteUserList].length);\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n }, 0);\n }\n });\n }\n onSoundLevelUpdate(func) {\n this.onSoundLevelUpdateCallBack = func;\n }\n onRoomLiveStateUpdate(func) {\n this.onRoomLiveStateUpdateCallBack = func;\n }\n onRoomMixingStateUpdate(func) {\n this.onRoomMixingStateUpdateCallBack = func;\n }\n sendRoomMessage(message) {\n return ZegoCloudRTCCore._zg.sendBroadcastMessage(ZegoCloudRTCCore._instance._expressConfig.roomID, message);\n }\n onRoomMessageUpdate(func) {\n this.onRoomMessageUpdateCallBack = func;\n }\n onScreenSharingEnded(func) {\n this.onScreenSharingEndedCallBack = func;\n }\n onNetworkStatus(func) {\n this.onNetworkStatusCallBack = (roomID, type, status) => {\n if (status === \"CONNECTING\") {\n !this.NetworkStatusTimer &&\n (this.NetworkStatusTimer = setTimeout(() => {\n func(roomID, type, \"DISCONNECTED\");\n }, 60000));\n }\n else {\n if (this.NetworkStatusTimer) {\n clearTimeout(this.NetworkStatusTimer);\n this.NetworkStatusTimer = null;\n }\n }\n func(roomID, type, status);\n };\n }\n streamExtraInfoUpdateCallBack(streamList) {\n // 流附加消息解析\n streamList.forEach((stream) => {\n const extraInfo = JSON.parse(stream.extraInfo);\n console.warn(\"extraInfo\", extraInfo);\n if (extraInfo.isCameraOn !== undefined) {\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"cameraStatus\", extraInfo.isCameraOn ? \"OPEN\" : \"MUTE\");\n }\n if (extraInfo.isMicrophoneOn !== undefined) {\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"micStatus\", extraInfo.isMicrophoneOn ? \"OPEN\" : \"MUTE\");\n }\n extraInfo.hasVideo !== undefined &&\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"hasVideo\", !!extraInfo.hasVideo);\n extraInfo.hasAudio !== undefined &&\n this.zum.updateStreamInfo(stream.user.userID, stream.streamID, \"hasAudio\", !!extraInfo.hasAudio);\n });\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack && this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n }\n onCoreError(func) {\n this.coreErrorCallback = func;\n }\n leaveRoom() {\n var _a;\n if (!this.status.loginRsp)\n return;\n ZegoCloudRTCCore._zg.off(\"streamExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomExtraInfoUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomStreamUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteCameraStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"remoteMicStatusUpdate\");\n ZegoCloudRTCCore._zg.off(\"playerStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"roomUserUpdate\");\n ZegoCloudRTCCore._zg.off(\"IMRecvBroadcastMessage\");\n ZegoCloudRTCCore._zg.off(\"roomStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publisherStateUpdate\");\n ZegoCloudRTCCore._zg.off(\"publishQualityUpdate\");\n ZegoCloudRTCCore._zg.off(\"soundLevelUpdate\");\n ZegoCloudRTCCore._zg.off(\"screenSharingEnded\");\n ZegoCloudRTCCore._zg.off(\"IMRecvCustomCommand\");\n ZegoCloudRTCCore._zg.setSoundLevelDelegate(false);\n this.onNetworkStatusCallBack = () => { };\n this.onRemoteMediaUpdateCallBack = (updateType, streamList) => __awaiter(this, void 0, void 0, function* () {\n yield this.zum.mainStreamUpdate(updateType, streamList);\n yield this.zum.screenStreamUpdate(updateType, streamList);\n this.throttleStartAndUpdateMixinTask();\n this.subscribeUserListCallBack && this.subscribeUserListCallBack([...this.zum.remoteUserList]);\n this.subscribeScreenStreamCallBack &&\n this.subscribeScreenStreamCallBack([...this.zum.remoteScreenStreamList]);\n });\n this.onRemoteUserUpdateCallBack = () => { };\n this.onRoomMessageUpdateCallBack = () => { };\n this.onRoomLiveStateUpdateCallBack = () => { };\n this.subscribeUserListCallBack = () => { };\n this.zum.reset();\n this.localStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n this.localScreensharingStreamInfo = {\n streamID: \"\",\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n };\n // TODO\n // this.startAndUpdateMixinTask();\n for (let key in this.remoteStreamMap) {\n ZegoCloudRTCCore._zg.stopPlayingStream(key);\n }\n this.remoteStreamMap = {};\n this.clearMixUser();\n this.waitingHandlerStreams = { add: [], delete: [] };\n if (this.isHost()) {\n // host离开房间,清除房间属性host\n const setRoomExtraInfo = Object.assign(Object.assign({}, this._roomExtraInfo), {\n host: \"\",\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n this.hasPublishedStream = false;\n (_a = this._zimManager) === null || _a === void 0 ? void 0 : _a.leaveRoom();\n ZegoCloudRTCCore._zg.logoutRoom();\n this.status.loginRsp = false;\n }\n setStreamExtraInfo(streamID, extraInfo) {\n return ZegoCloudRTCCore._zg.setStreamExtraInfo(streamID, extraInfo);\n }\n initZIM(ZIM) {\n if (this._zimManager)\n return;\n this._zimManager = new _tools_ZimManager__WEBPACK_IMPORTED_MODULE_4__.ZimManager(ZIM, this._expressConfig);\n // 更新roomID\n this._zimManager.onUpdateRoomID((roomID) => {\n this._expressConfig.roomID = roomID;\n });\n }\n // 发送房间自定义消息\n sendInRoomCommand(message, userIDs) {\n return __awaiter(this, void 0, void 0, function* () {\n const res = yield ZegoCloudRTCCore._zg.sendCustomCommand(this._expressConfig.roomID, message, this.zum.remoteUserList.length > 500 ? [] : userIDs);\n if (res.errorCode === 0) {\n return true;\n }\n else {\n console.error(\"【ZEGOCLOUD】sendInRoomCommand error:\", res.errorCode);\n return false;\n }\n });\n }\n // 踢人\n removeMember(userID) {\n this.sendInRoomCommand(JSON.stringify({ zego_remove_user: userID }), [userID]);\n }\n //关闭摄像头麦克风\n turnRemoteCameraOff(userID) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield this.sendInRoomCommand(JSON.stringify({ zego_turn_camera_off: userID }), [userID]);\n });\n }\n turnRemoteMicrophoneOff(userID) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield this.sendInRoomCommand(JSON.stringify({ zego_turn_microphone_off: userID }), [userID]);\n });\n }\n onKickedOutRoom(func) {\n func && (this.onKickedOutRoomCallback = func);\n }\n onChangeYourDeviceStatus(func) {\n func && (this.onChangeYourDeviceStatusCallback = func);\n }\n startMixerTask() {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n const { width, height, bitrate, frameRate } = (0,_util__WEBPACK_IMPORTED_MODULE_5__.getVideoResolution)(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.videoMixingOutputResolution) || \"540p\");\n const inputList = this.getMixStreamInput(width, height);\n if (!inputList.length)\n return { errorCode: 1 };\n const config = {\n taskID: `${this._expressConfig.roomID}__task`,\n inputList: this.getMixStreamInput(width, height),\n outputList: [\n `${this._expressConfig.roomID}__mix`,\n // `rtmp://publish-ws.coolxcloud.com/uikit/${this._expressConfig.roomID}_11__mix`,\n ],\n outputConfig: {\n outputBitrate: bitrate,\n outputFPS: frameRate,\n outputWidth: width,\n outputHeight: height,\n },\n };\n console.warn(\"getMixStreamInput\", config);\n try {\n return yield ZegoCloudRTCCore._zg.startMixerTask(config);\n }\n catch (error) {\n console.error(error);\n return { errorCode: 1 };\n }\n });\n }\n stopMixerTask(isHost = false) {\n return __awaiter(this, void 0, void 0, function* () {\n const taskID = `${this._expressConfig.roomID}__task`;\n if ((this.isHost() || isHost) && this.roomExtraInfo.isMixing === \"1\") {\n // 停止混流,设置房间附加属性isMixing:0|1\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n isMixing: \"0\",\n });\n yield ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n const res = yield ZegoCloudRTCCore._zg.stopMixerTask(taskID);\n console.warn(\"stopMixerTask\", res);\n return res;\n }\n });\n }\n setMixerTaskConfig(config) {\n return __awaiter(this, void 0, void 0, function* () {\n return yield ZegoCloudRTCCore._zg.setMixerTaskConfig(config);\n });\n }\n getMixStreamInput(outWidth, outHeight) {\n const hasScreensharing = this.zum.remoteScreenStreamList.length > 0 || this.localScreensharingStreamInfo.streamID;\n const inputList = [];\n let videoWidth = 0, videoHeight = 0, screensharingWidth, screensharingHeight;\n // if((this._config.scenario?.config as ScenarioConfig[ScenarioModel.LiveStreaming])?.videoMixingLayout === VideoMixinLayoutType.AutoLayout) {\n // 自适应布局\n const streams = this.zum.remoteUserList\n .filter((user) => {\n var _a, _b, _c;\n return ((_a = user.streamList[0]) === null || _a === void 0 ? void 0 : _a.streamID) &&\n (((_b = user.streamList[0]) === null || _b === void 0 ? void 0 : _b.cameraStatus) === \"OPEN\" || ((_c = user.streamList[0]) === null || _c === void 0 ? void 0 : _c.micStatus) === \"OPEN\");\n })\n .map((u) => ({\n streamID: u.streamList[0].streamID,\n cameraStatus: u.streamList[0].cameraStatus,\n micStatus: u.streamList[0].micStatus,\n userName: u.userName,\n }));\n if (this.localStreamInfo.streamID &&\n (this.localStreamInfo.cameraStatus === \"OPEN\" || this.localStreamInfo.micStatus === \"OPEN\")) {\n streams.unshift(Object.assign(Object.assign({}, this.localStreamInfo), { userName: this._expressConfig.userName }));\n }\n let config;\n if (hasScreensharing) {\n let maxVideo = 5;\n videoHeight = Math.floor((outHeight - 16 * 2 - 4 * 10) / 5);\n videoWidth = Math.floor((videoHeight * 16) / 9);\n screensharingWidth = outWidth - 16 * 2 - 10 - videoWidth;\n screensharingHeight = outHeight - 16 * 2;\n if (streams.length > 0) {\n // screen sharing\n inputList.push({\n streamID: this.localScreensharingStreamInfo.streamID ||\n this.zum.remoteScreenStreamList[0].streamList[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: screensharingHeight + 16,\n right: screensharingWidth + 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n });\n // user streams\n streams.forEach((user) => {\n if (maxVideo > 0) {\n config = {\n streamID: user.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16 + (5 - maxVideo) * (videoHeight + 10),\n left: screensharingWidth + 26,\n bottom: 16 + (5 - maxVideo) * (videoHeight + 10) + videoHeight,\n right: outWidth - 16,\n },\n label: {\n text: user.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoWidth - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n inputList.push(config);\n maxVideo--;\n }\n else {\n inputList.push({\n streamID: user.streamID,\n contentType: \"AUDIO\",\n layout: {\n top: 0,\n left: 0,\n bottom: 1,\n right: 1,\n },\n renderMode: 1,\n });\n }\n });\n }\n else {\n // 只有屏幕共享的情况\n inputList.push({\n streamID: this.localScreensharingStreamInfo.streamID ||\n this.zum.remoteScreenStreamList[0].streamList[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: outHeight - 16,\n right: outWidth - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n });\n }\n }\n else {\n // 没有屏幕共享的情况\n let len = streams.length;\n if (len === 1) {\n config = {\n streamID: streams[0].streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16,\n bottom: outHeight - 16,\n right: outWidth - 16,\n },\n label: {\n text: streams[0].userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: outHeight - 16 * 2 - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (streams[0].cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n }\n else if (len === 2) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10) / 2);\n streams.forEach((u, i) => {\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16,\n left: 16 + (videoWidth + 10) * i,\n bottom: outHeight - 16,\n right: 16 + (videoWidth + 10) * i + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: outHeight - 16 * 2 - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else if (len === 3 || len === 4) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10) / 2);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10) / 2);\n streams.forEach((u, i) => {\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: i <= 1 ? 16 : 16 + 10 + videoHeight,\n left: len === 3\n ? i < 2\n ? 16 + (videoWidth + 10) * i\n : Math.floor((outWidth - videoWidth) / 2)\n : i % 2 === 0\n ? 16\n : 16 + videoWidth + 10,\n bottom: i <= 1 ? 16 + videoHeight : outHeight - 16,\n right: len === 3 && i === 2\n ? outWidth - Math.floor((outWidth - videoWidth) / 2)\n : i % 2 === 0\n ? 16 + videoWidth\n : outWidth - 16,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 24,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else if (len === 5 || len === 6) {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10 * 2) / 3);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10) / 2);\n let lastRowPaddingLeft = len === 5 ? Math.floor((videoWidth + 10) / 2) : 0;\n streams.forEach((u, i) => {\n const left = i <= 2 ? 16 + (videoWidth + 10) * i : 16 + lastRowPaddingLeft + (videoWidth + 10) * (i % 3);\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: i <= 2 ? 16 : 16 + 10 + videoHeight,\n left: left,\n bottom: i <= 2 ? 16 + videoHeight : outHeight - 16,\n right: left + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n });\n }\n else {\n videoWidth = Math.floor((outWidth - 16 * 2 - 10 * 2) / 3);\n videoHeight = Math.floor((outHeight - 16 * 2 - 10 * 2) / 3);\n let lastRowPaddingLeft = 0;\n if (len === 7) {\n lastRowPaddingLeft = videoWidth + 10;\n }\n if (len === 8) {\n lastRowPaddingLeft = Math.floor((videoWidth + 10) / 2);\n }\n streams.forEach((u, i) => {\n if (i < 9) {\n const left = i < 6\n ? 16 + (videoWidth + 10) * (i % 3)\n : 16 + lastRowPaddingLeft + (videoWidth + 10) * (i % 3);\n config = {\n streamID: u.streamID,\n contentType: \"VIDEO\",\n layout: {\n top: 16 + (videoHeight + 10) * Math.floor(i / 3),\n left: left,\n bottom: 16 + (videoHeight + 10) * Math.floor(i / 3) + videoHeight,\n right: left + videoWidth,\n },\n label: {\n text: u.userName,\n font: {\n size: 14,\n transparency: 0,\n color: 16777215,\n border: true,\n borderColor: 8421505,\n },\n left: 20,\n top: videoHeight - 16,\n },\n cornerRadius: 10,\n renderMode: 1,\n };\n if (u.cameraStatus === \"MUTE\") {\n config.imageInfo = {\n url: \"https://resource.zegocloud.com/office/sdk_static/mixing_video_bg.jpg\",\n };\n }\n inputList.push(config);\n }\n else {\n inputList.push({\n streamID: u.streamID,\n contentType: \"AUDIO\",\n layout: {\n top: 0,\n left: 0,\n bottom: 1,\n right: 1,\n },\n renderMode: 1,\n });\n }\n });\n }\n }\n // }\n return inputList;\n }\n startAndUpdateMixinTask(isHost = false) {\n var _a, _b;\n return __awaiter(this, void 0, void 0, function* () {\n // 多主播情况下,非房间属性主播开启直播,也需要开始混流\n if (!this.isHost() && !isHost)\n return;\n if (!(((_b = (_a = this._config.scenario) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.enableVideoMixing) && this.roomExtraInfo.live_status === \"1\"))\n return;\n const res = yield this.startMixerTask();\n console.warn(\"startMixerTask\", res);\n if ((res === null || res === void 0 ? void 0 : res.errorCode) !== 0)\n return;\n if (this.roomExtraInfo.isMixing !== \"1\") {\n //第一次混流,需要设置房间附加属性isMixing:0|1\n const setRoomExtraInfo = Object.assign(Object.assign({}, this.roomExtraInfo), {\n isMixing: \"1\",\n });\n ZegoCloudRTCCore._zg.setRoomExtraInfo(ZegoCloudRTCCore._instance._expressConfig.roomID, \"extra_info\", JSON.stringify(setRoomExtraInfo));\n this._roomExtraInfo = setRoomExtraInfo;\n }\n });\n }\n // 设置混流用户数据用于渲染\n setMixUser() {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (((_b = (_a = this.mixUser) === null || _a === void 0 ? void 0 : _a.streamList) === null || _b === void 0 ? void 0 : _b.length) > 0)\n return;\n if (((_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.mode) === _model__WEBPACK_IMPORTED_MODULE_2__.ScenarioModel.LiveStreaming &&\n this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming &&\n !this.mixStreamDomain)\n return;\n if (this.roomExtraInfo.live_status !== \"1\")\n return;\n if (!((_e = (_d = this._config.scenario) === null || _d === void 0 ? void 0 : _d.config) === null || _e === void 0 ? void 0 : _e.enableVideoMixing))\n return;\n if (this._config.scenario.config.role !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveRole.Audience)\n return;\n let stream = {\n media: undefined,\n fromUser: {\n userID: this.roomExtraInfo.host,\n },\n micStatus: \"OPEN\",\n cameraStatus: \"OPEN\",\n // hasVideo: false, //为了一开始能播放纯音频\n state: \"PLAYING\",\n streamID: `${this._expressConfig.roomID}__mix`,\n };\n if (this._config.scenario.config.liveStreamingMode === _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming) {\n // CDN\n stream.urlsHttpsFLV = `${this.mixStreamDomain}${stream.streamID}.flv`;\n stream.urlsHttpsHLS = `${this.mixStreamDomain}${stream.streamID}.m3u8`;\n }\n else {\n // RTC, L3\n try {\n const media = yield this.zum.startPullStream(this.roomExtraInfo.host, stream.streamID);\n if (media) {\n stream.media = media;\n }\n else {\n stream = null;\n }\n }\n catch (error) {\n console.error(\"startPullStream\", error);\n }\n }\n this.mixUser = {\n pin: false,\n userID: this.roomExtraInfo.host,\n userName: \"\",\n streamList: [],\n };\n stream && this.mixUser.streamList.push(stream);\n });\n }\n // 停止拉混流,Cohost变成 Audience,或离开房间时\n clearMixUser() {\n var _a, _b, _c, _d;\n if (!((_b = (_a = this.mixUser) === null || _a === void 0 ? void 0 : _a.streamList) === null || _b === void 0 ? void 0 : _b.length))\n return;\n if (((_d = (_c = this._config.scenario) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.liveStreamingMode) !== _model__WEBPACK_IMPORTED_MODULE_2__.LiveStreamingMode.LiveStreaming) {\n ZegoCloudRTCCore._zg.stopPlayingStream(this.mixUser.streamList[0].streamID);\n }\n this.mixUser.streamList = [];\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/index.ts?");
2259
2259
 
2260
2260
  /***/ }),
2261
2261
 
@@ -2310,7 +2310,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2310
2310
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2311
2311
 
2312
2312
  "use strict";
2313
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZimManager\": function() { return /* binding */ ZimManager; }\n/* harmony export */ });\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../view/pages/ZegoCallInvitation/callInvitationControl */ \"./src/sdk/view/pages/ZegoCallInvitation/callInvitationControl.tsx\");\n/* harmony import */ var _InRoomInviteManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./InRoomInviteManager */ \"./src/sdk/modules/tools/InRoomInviteManager.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nclass ZimManager {\n constructor(ZIM, expressConfig) {\n this._inRoomInviteMg = {};\n this.isLogin = false;\n this.isServiceActivated = true; //IM 服务是否开通\n this.callInfo = {};\n this.inSendOperation = false; //防止重复点击\n this.inRefuseOperation = false; //防止重复点击\n this.inAcceptOperation = false; //防止重复点击\n this.inCancelOperation = false; //防止重复点击\n this.config = {\n enableCustomCallInvitationWaitingPage: false,\n enableCustomCallInvitationDialog: false,\n enableNotifyWhenAppRunningInBackgroundOrQuit: false,\n };\n this.notificationConfig = undefined;\n this.hostID = \"\";\n this.incomingTimer = null;\n this.outgoingTimer = null;\n this.notifyJoinRoomCallback = () => { };\n this.notifyLeaveRoomCallback = (reason) => { };\n this.onUpdateRoomIDCallback = () => { };\n this.onRoomTextMessageCallback = (msgs) => { };\n // @ts-ignore\n this._zim = ZIM.create({ appID: expressConfig.appID }) || ZIM.getInstance();\n this._inRoomInviteMg = new _InRoomInviteManager__WEBPACK_IMPORTED_MODULE_2__[\"default\"](this._zim, expressConfig);\n this.expressConfig = expressConfig;\n this.initListener();\n this.login();\n }\n login(retryTime = 1) {\n return __awaiter(this, void 0, void 0, function* () {\n console.warn(\"retryTime\", retryTime);\n if (retryTime > 4) {\n console.error(\"【ZEGOCLOUD】zim login failed, retryTime \", retryTime);\n return;\n }\n this._zim.login({\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n }, this.expressConfig.token)\n .then(() => {\n // 登录成功\n console.warn(\"zim login success!!\");\n this.isLogin = true;\n })\n .catch((err) => {\n // 登录失败\n this.isLogin = false;\n console.error(\"【ZEGOCLOUD】zim login failed !!\", err);\n if (err.code === 6000014) {\n this.isServiceActivated = false;\n return;\n }\n if (err.code === 6000111) {\n return;\n }\n setTimeout(() => {\n this.login(++retryTime);\n }, 2000 * retryTime);\n });\n });\n }\n initListener() {\n var _a, _b;\n // 被邀请者收到邀请后的回调通知(被邀请者)\n this._zim.on(\"callInvitationReceived\", (zim, { callID, inviter, timeout, extendedData }) => {\n var _a, _b, _c, _d;\n console.warn(\"callInvitationReceived\", {\n callID,\n inviter,\n timeout,\n extendedData,\n });\n const { type } = JSON.parse(extendedData);\n if (type > _model__WEBPACK_IMPORTED_MODULE_0__.ZegoInvitationType.VideoCall) {\n this._inRoomInviteMg.onCallInvitationReceived(callID, inviter, timeout, extendedData);\n }\n else {\n if (this.callInfo.callID) {\n // 如果已被邀请,就拒绝其他的\n callID !== this.callInfo.callID &&\n this.refuseInvitation(\"busy\", callID);\n }\n else {\n const { inviter_name, type, data } = JSON.parse(extendedData);\n const { call_id, invitees, custom_data } = JSON.parse(data);\n this.callInfo = {\n callID,\n invitees: invitees.map((i) => ({\n userID: i.user_id,\n userName: i.user_name,\n })),\n inviter: {\n userID: inviter,\n userName: inviter_name,\n },\n acceptedInvitees: [],\n roomID: call_id,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 设置来电计时器,当断网等收不到消息时以超时为由结束call\n if (this.incomingTimer) {\n this.clearIncomingTimer();\n }\n else {\n this.incomingTimer = setTimeout(() => {\n if (this.callInfo.callID) {\n this.config.onIncomingCallTimeout &&\n this.config.onIncomingCallTimeout(this.callInfo.roomID, this.callInfo.inviter);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n this.clearIncomingTimer();\n }, (timeout + 1) * 1000);\n }\n if (!this.config.enableCustomCallInvitationDialog) {\n // 展示默认UI\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogShow({ userID: inviter, userName: inviter_name }, () => {\n this.clearIncomingTimer();\n this.refuseInvitation(\"decline\");\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }, () => {\n this.clearIncomingTimer();\n this.acceptInvitation();\n this.notifyJoinRoomCallback();\n }, (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.ringtoneConfig) === null || _b === void 0 ? void 0 : _b.incomingCallUrl);\n }\n // 透传接收到邀请回调\n if (this.config.onIncomingCallReceived) {\n this.config.onIncomingCallReceived(this.callInfo.roomID, this.callInfo.inviter, this.callInfo.type, this.callInfo.invitees);\n }\n // 对外再包一层,不暴露内部逻辑\n const refuse = (data) => {\n this.clearIncomingTimer();\n this.refuseInvitation(\"decline\", \"\", data);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n };\n const accept = (data) => {\n this.clearIncomingTimer();\n this.acceptInvitation(data);\n this.notifyJoinRoomCallback();\n };\n (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.onConfirmDialogWhenReceiving) === null || _d === void 0 ? void 0 : _d.call(_c, type, { userID: inviter, userName: inviter_name }, (data) => {\n refuse(data);\n }, (data) => {\n accept(data);\n }, custom_data);\n }\n }\n });\n // 被邀请者收到邀请被取消后的回调通知(被邀请者)\n this._zim.on(\"callInvitationCancelled\", (zim, { callID, inviter, extendedData }) => {\n console.warn(\"callInvitationCancelled\", {\n callID,\n inviter,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationCanceled(callID, inviter, extendedData);\n if (!this.callInfo.callID)\n return;\n // 透传取消呼叫事件\n if (this.config.onIncomingCallCanceled) {\n this.config.onIncomingCallCanceled(this.callInfo.roomID, this.callInfo.inviter);\n }\n this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled);\n });\n // 邀请者的邀请被接受后的回调通知(邀请者)\n this._zim.on(\"callInvitationAccepted\", (zim, { callID, invitee, extendedData }) => {\n console.warn(\"callInvitationAccepted\", {\n callID,\n invitee,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationAccepted(callID, invitee, extendedData);\n if (!this.callInfo.callID)\n return;\n this.clearOutgoingTimer();\n this.callInfo.acceptedInvitees.push({\n userID: invitee,\n userName: \"\",\n });\n if (!this.callInfo.isGroupCall) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.notifyJoinRoomCallback();\n }\n // 透传接受邀请事件\n if (this.config.onOutgoingCallAccepted) {\n const callee = this.callInfo.invitees.find((i) => i.userID === invitee) || { userID: invitee };\n this.config.onOutgoingCallAccepted(this.callInfo.roomID, callee);\n }\n });\n // 邀请者的邀请被拒绝后的回调通知(邀请者)\n this._zim.on(\"callInvitationRejected\", (zim, { callID, invitee, extendedData }) => {\n console.warn(\"callInvitationRejected\", {\n callID,\n invitee,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationRefused(callID, invitee, extendedData);\n if (!this.callInfo.callID)\n return;\n let reason;\n if (extendedData.length) {\n const data = JSON.parse(extendedData);\n reason = data.reason;\n }\n // 透传拒绝事件\n const callee = this.callInfo.invitees.find((i) => i.userID === invitee) || { userID: invitee };\n if (reason === \"busy\") {\n this.config.onOutgoingCallRejected &&\n this.config.onOutgoingCallRejected(this.callInfo.roomID, callee);\n }\n else {\n this.config.onOutgoingCallDeclined &&\n this.config.onOutgoingCallDeclined(this.callInfo.roomID, callee);\n }\n if (!this.callInfo.isGroupCall) {\n // 单人邀请,隐藏waitingPage,清除callInfo\n this.clearOutgoingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(reason === \"busy\"\n ? _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Busy\n : _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n else {\n // 多人邀请,\n // 移除拒绝者\n this.callInfo.invitees = this.callInfo.invitees.filter((i) => i.userID !== invitee);\n if (this.callInfo.invitees.length === 0) {\n // 全部拒绝后需要退出房间\n this.clearOutgoingTimer();\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n }\n });\n //被邀请者响应超时后,“邀请者”收到的回调通知, 超时时间单位:秒(邀请者)\n this._zim.on(\"callInviteesAnsweredTimeout\", (zim, { callID, invitees }) => {\n console.warn(\"callInviteesAnsweredTimeout\", { callID, invitees });\n this._inRoomInviteMg.onCallInviteesAnsweredTimeout(callID, invitees);\n if (!this.callInfo.callID)\n return;\n this.clearOutgoingTimer();\n // 透传超时事件\n if (this.config.onOutgoingCallTimeout) {\n const callees = invitees.map((i) => {\n return (this.callInfo.invitees.find((u) => u.userID === i) || {\n userID: i,\n });\n });\n this.config.onOutgoingCallTimeout(this.callInfo.roomID, callees);\n }\n this.answeredTimeoutCallback(invitees);\n });\n //被邀请者响应超时后,“被邀请者”收到的回调通知, 超时时间单位:秒 (被邀请者)\n this._zim.on(\"callInvitationTimeout\", (zim, { callID }) => {\n console.warn(\"callInvitationTimeout\", { callID });\n this._inRoomInviteMg.onCallInvitationTimeout(callID);\n if (!this.callInfo.callID)\n return;\n // 透传超时事件\n if (this.config.onIncomingCallTimeout) {\n this.config.onIncomingCallTimeout(this.callInfo.roomID, this.callInfo.inviter);\n }\n this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n });\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.on(\"connectionStateChanged\", (zim, data) => {\n console.warn(\"【zim】connectionStateChanged\", data);\n });\n (_b = this._zim) === null || _b === void 0 ? void 0 : _b.on(\"receiveRoomMessage\", (zim, data) => {\n console.warn(\"receiveRoomMessage\", data);\n const textMsgs = data.messageList\n .filter((msg) => msg.type === 1)\n .map((msg) => ({\n messageID: msg.messageID,\n timestamp: msg.timestamp,\n orderKey: msg.orderKey,\n senderUserID: msg.senderUserID,\n text: msg.message,\n }));\n this.onRoomTextMessageCallback &&\n this.onRoomTextMessageCallback(textMsgs);\n });\n }\n answeredTimeoutCallback(invitees) {\n if (!this.callInfo.callID)\n return;\n if (this.callInfo.isGroupCall) {\n // 多人邀请\n this.callInfo.invitees = this.callInfo.invitees.filter((i) => !invitees.find((u) => u === i.userID));\n if (this.callInfo.invitees.length === 0) {\n // 全部超时就退出房间,结束邀请\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n else {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n sendInvitation(invitees, type, timeout, data, notificationConfig) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.callInfo.callID)\n return Promise.reject(\"You already have a call invitation!\");\n if (!this.isServiceActivated)\n return Promise.reject(\"The call invitation service has not been activated.\");\n if (this.inSendOperation)\n return Promise.reject(\"send invitation repeat !!\");\n this.inSendOperation = true;\n const inviteesID = invitees.map((i) => i.userID);\n const roomID = `call_${this.expressConfig.userID}_${new Date().getTime()}`;\n if (notificationConfig) {\n this.notificationConfig = notificationConfig;\n }\n const _data = {\n call_id: roomID,\n invitees: invitees.map((u) => ({\n user_id: u.userID,\n user_name: u.userName,\n })),\n inviter: {\n id: this.expressConfig.userID,\n name: this.expressConfig.userName,\n },\n type,\n custom_data: data,\n };\n const extendedData = {\n inviter_name: this.expressConfig.userName,\n type,\n data: JSON.stringify(_data),\n };\n const config = {\n timeout,\n extendedData: JSON.stringify(extendedData),\n };\n // 发送离线消息\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n const pushConfig = {\n title: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.title) || this.expressConfig.userName,\n content: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.message) ||\n `Incoming ${invitees.length > 1 ? \"group \" : \"\"}${type === 0 ? \"voice\" : \"video\"} call...`,\n payload: JSON.stringify(Object.assign({}, _data, extendedData)),\n resourcesID: (_a = notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.resourcesID) !== null && _a !== void 0 ? _a : \"zegouikit_call\",\n };\n config.pushConfig = pushConfig;\n }\n try {\n this.callInfo.callID = new Date().getTime().toString(); //临时生成个id,防止同时呼叫情况\n const res = yield this._zim.callInvite(inviteesID, config);\n const errorInvitees = res.errorInvitees.map((i) => {\n return invitees.find((u) => u.userID === i.userID);\n });\n if (res.errorInvitees.length >= invitees.length) {\n // 全部邀请失败,中断流程\n this.inSendOperation = false;\n this.clearCallInfo();\n return Promise.resolve({ errorInvitees });\n }\n // 过滤掉不在线的用户\n const onlineInvitee = invitees.filter((i) => !res.errorInvitees.find((e) => e.userID === i.userID));\n // 保存邀请信息,进入busy状态\n this.callInfo = {\n callID: res.callID,\n invitees: onlineInvitee,\n inviter: {\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n },\n acceptedInvitees: [],\n roomID,\n type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 添加定时器,断网等情况导致收不到消息时,当超时处理\n this.outgoingTimer = setTimeout(() => {\n if (this.callInfo.callID) {\n // 透传超时事件\n this.config.onOutgoingCallTimeout &&\n this.config.onOutgoingCallTimeout(this.callInfo.roomID, this.callInfo.invitees);\n // 当超时后,没有一个人接受邀请,则主动退出房间\n !this.callInfo.acceptedInvitees.length &&\n this.answeredTimeoutCallback(onlineInvitee.map((u) => u.userID));\n }\n this.clearOutgoingTimer();\n }, (timeout + 1) * 1000);\n if (invitees.length > 1) {\n // 多人邀请,直接进房\n this.notifyJoinRoomCallback();\n }\n else {\n // 单人邀请,进入等待页\n if (!this.config.enableCustomCallInvitationWaitingPage) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageShow(invitees[0], type, () => {\n var _a, _b;\n this.cancelInvitation();\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n }, (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.outgoingCallUrl);\n }\n const cancel = () => {\n var _a, _b;\n this.cancelInvitation();\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n };\n (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.onWaitingPageWhenSending) === null || _e === void 0 ? void 0 : _e.call(_d, this.callInfo.type, invitees, () => {\n cancel();\n });\n }\n this.inSendOperation = false;\n return Promise.resolve({ errorInvitees });\n }\n catch (error) {\n this.clearCallInfo();\n this.inSendOperation = false;\n return Promise.reject(JSON.stringify(error));\n }\n });\n }\n cancelInvitation(data) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inCancelOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inCancelOperation = true;\n this.clearOutgoingTimer();\n const invitees = this.callInfo.invitees.map((i) => i.userID);\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n const config = {\n extendedData: JSON.stringify(extendedData),\n };\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n config.pushConfig = {\n title: ((_a = this.notificationConfig) === null || _a === void 0 ? void 0 : _a.title) || this.expressConfig.userName,\n content: ((_b = this.notificationConfig) === null || _b === void 0 ? void 0 : _b.message) || \"Cancelled invitation\",\n resourcesID: (_d = (_c = this.notificationConfig) === null || _c === void 0 ? void 0 : _c.resourcesID) !== null && _d !== void 0 ? _d : \"zegouikit_call\",\n payload: JSON.stringify({\n call_id: this.callInfo.roomID,\n operation_type: \"cancel_invitation\",\n }),\n };\n console.log(\"cancelInvitation\", config);\n }\n try {\n yield ((_e = this._zim) === null || _e === void 0 ? void 0 : _e.callCancel(invitees, this.callInfo.callID, config));\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.clearCallInfo();\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】cancelInvitation\", error);\n }\n this.inCancelOperation = false;\n });\n }\n refuseInvitation(reason, callID, data) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inRefuseOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inRefuseOperation = true;\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n if (reason) {\n extendedData.reason = reason;\n }\n try {\n yield ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callReject(callID || this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }));\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】refuseInvitation\", error);\n }\n this.inRefuseOperation = false;\n });\n }\n acceptInvitation(data) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inAcceptOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inAcceptOperation = true;\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n try {\n yield ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callAccept(this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }));\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】acceptInvitation\", error);\n }\n this.inAcceptOperation = false;\n });\n }\n clearCallInfo() {\n this.callInfo = {};\n }\n destroy() {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.destroy();\n this._zim = null;\n }\n /** 通知UI层调用joinRoom */\n notifyJoinRoom(func) {\n func &&\n (this.notifyJoinRoomCallback = () => {\n var _a, _b;\n // 接收客户传递进来的roomConfig\n const roomConfig = ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onSetRoomConfigBeforeJoining) === null || _b === void 0 ? void 0 : _b.call(_a, this.callInfo.type)) || {};\n func(this.callInfo.type, roomConfig, this.callInfo.isGroupCall\n ? _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.GroupCall\n : _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.OneONoneCall);\n });\n }\n /** 通知UI层调用leaveRoom */\n notifyLeaveRoom(func) {\n this.notifyLeaveRoomCallback = (reason) => {\n func && func();\n this.endCall(reason);\n };\n }\n /**收到邀请后需要更新roomID*/\n onUpdateRoomID(func) {\n func &&\n (this.onUpdateRoomIDCallback = () => {\n func(this.callInfo.roomID);\n this.expressConfig.roomID = this.callInfo.roomID;\n });\n }\n /**结束 call,清除 callInfo */\n endCall(reason) {\n var _a, _b;\n if (reason === _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.LeaveRoom &&\n !this.callInfo.acceptedInvitees.length &&\n this.callInfo.inviter.userID === this.expressConfig.userID) {\n // 主叫人如果在所有人接收邀请前离开房间,则取消所有人的邀请\n this.cancelInvitation();\n }\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, reason, \"\");\n this.clearCallInfo();\n }\n setCallInvitationConfig(config) {\n this.config = Object.assign(this.config, config);\n }\n clearOutgoingTimer() {\n if (this.outgoingTimer) {\n clearTimeout(this.outgoingTimer);\n this.outgoingTimer = null;\n }\n }\n clearIncomingTimer() {\n if (this.incomingTimer) {\n clearTimeout(this.incomingTimer);\n this.incomingTimer = null;\n }\n }\n onRoomTextMessage(func) {\n this.onRoomTextMessageCallback = func;\n }\n enterRoom() {\n var _a;\n if (this.isLogin) {\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.enterRoom({\n roomID: this.callInfo.callID || this.expressConfig.roomID,\n roomName: this.callInfo.callID || this.expressConfig.roomID,\n }).then((res) => {\n console.warn(\"【zim enterRoom】success\");\n }).catch((error) => {\n console.error(\"【zim enterRoom】failed\", error);\n });\n }\n }\n leaveRoom() {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.leaveRoom(this.callInfo.callID || this.expressConfig.roomID).then((res) => {\n console.warn(\"【zim leaveRoom】success\");\n }).catch((error) => {\n console.error(\"【zim leaveRoom】failed\", error);\n });\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/ZimManager.ts?");
2313
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZimManager\": function() { return /* binding */ ZimManager; }\n/* harmony export */ });\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../view/pages/ZegoCallInvitation/callInvitationControl */ \"./src/sdk/view/pages/ZegoCallInvitation/callInvitationControl.tsx\");\n/* harmony import */ var _InRoomInviteManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./InRoomInviteManager */ \"./src/sdk/modules/tools/InRoomInviteManager.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nclass ZimManager {\n constructor(ZIM, expressConfig) {\n var _a;\n this._inRoomInviteMg = {};\n this.isLogin = false;\n this.isServiceActivated = true; //IM 服务是否开通\n this.callInfo = {};\n this.inSendOperation = false; //防止重复点击\n this.inRefuseOperation = false; //防止重复点击\n this.inAcceptOperation = false; //防止重复点击\n this.inCancelOperation = false; //防止重复点击\n this.config = {\n enableCustomCallInvitationWaitingPage: false,\n enableCustomCallInvitationDialog: false,\n enableNotifyWhenAppRunningInBackgroundOrQuit: false,\n };\n this.notificationConfig = undefined;\n this.hostID = \"\";\n this.incomingTimer = null;\n this.outgoingTimer = null;\n this.notifyJoinRoomCallback = () => { };\n this.notifyLeaveRoomCallback = (reason) => { };\n this.onUpdateRoomIDCallback = () => { };\n this.onRoomTextMessageCallback = (msgs) => { };\n this.onRoomCommandMessageCallback = (msgs) => { };\n // @ts-ignore\n this._zim = ZIM.create({ appID: expressConfig.appID }) || ZIM.getInstance();\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.setLogConfig({\n logLevel: \"error\",\n });\n this._inRoomInviteMg = new _InRoomInviteManager__WEBPACK_IMPORTED_MODULE_2__[\"default\"](this._zim, expressConfig);\n this.expressConfig = expressConfig;\n this.initListener();\n this.login();\n }\n login(retryTime = 1) {\n return __awaiter(this, void 0, void 0, function* () {\n console.warn(\"retryTime\", retryTime);\n if (retryTime > 4) {\n console.error(\"【ZEGOCLOUD】zim login failed, retryTime \", retryTime);\n return;\n }\n this._zim.login({\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n }, this.expressConfig.token)\n .then(() => {\n // 登录成功\n console.warn(\"zim login success!!\");\n this.isLogin = true;\n })\n .catch((err) => {\n // 登录失败\n this.isLogin = false;\n console.error(\"【ZEGOCLOUD】zim login failed !!\", err);\n if (err.code === 6000014) {\n this.isServiceActivated = false;\n return;\n }\n if (err.code === 6000111) {\n return;\n }\n setTimeout(() => {\n this.login(++retryTime);\n }, 2000 * retryTime);\n });\n });\n }\n initListener() {\n var _a, _b;\n // 被邀请者收到邀请后的回调通知(被邀请者)\n this._zim.on(\"callInvitationReceived\", (zim, { callID, inviter, timeout, extendedData }) => {\n var _a, _b, _c, _d;\n console.warn(\"callInvitationReceived\", {\n callID,\n inviter,\n timeout,\n extendedData,\n });\n const { type } = JSON.parse(extendedData);\n if (type > _model__WEBPACK_IMPORTED_MODULE_0__.ZegoInvitationType.VideoCall) {\n this._inRoomInviteMg.onCallInvitationReceived(callID, inviter, timeout, extendedData);\n }\n else {\n if (this.callInfo.callID) {\n // 如果已被邀请,就拒绝其他的\n callID !== this.callInfo.callID && this.refuseInvitation(\"busy\", callID);\n }\n else {\n const { inviter_name, type, data } = JSON.parse(extendedData);\n const { call_id, invitees, custom_data } = JSON.parse(data);\n this.callInfo = {\n callID,\n invitees: invitees.map((i) => ({\n userID: i.user_id,\n userName: i.user_name,\n })),\n inviter: {\n userID: inviter,\n userName: inviter_name,\n },\n acceptedInvitees: [],\n roomID: call_id,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 设置来电计时器,当断网等收不到消息时以超时为由结束call\n if (this.incomingTimer) {\n this.clearIncomingTimer();\n }\n else {\n this.incomingTimer = setTimeout(() => {\n if (this.callInfo.callID) {\n this.config.onIncomingCallTimeout &&\n this.config.onIncomingCallTimeout(this.callInfo.roomID, this.callInfo.inviter);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n this.clearIncomingTimer();\n }, (timeout + 1) * 1000);\n }\n if (!this.config.enableCustomCallInvitationDialog) {\n // 展示默认UI\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogShow({ userID: inviter, userName: inviter_name }, () => {\n this.clearIncomingTimer();\n this.refuseInvitation(\"decline\");\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }, () => {\n this.clearIncomingTimer();\n this.acceptInvitation();\n this.notifyJoinRoomCallback();\n }, (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.ringtoneConfig) === null || _b === void 0 ? void 0 : _b.incomingCallUrl);\n }\n // 透传接收到邀请回调\n if (this.config.onIncomingCallReceived) {\n this.config.onIncomingCallReceived(this.callInfo.roomID, this.callInfo.inviter, this.callInfo.type, this.callInfo.invitees);\n }\n // 对外再包一层,不暴露内部逻辑\n const refuse = (data) => {\n this.clearIncomingTimer();\n this.refuseInvitation(\"decline\", \"\", data);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n };\n const accept = (data) => {\n this.clearIncomingTimer();\n this.acceptInvitation(data);\n this.notifyJoinRoomCallback();\n };\n (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.onConfirmDialogWhenReceiving) === null || _d === void 0 ? void 0 : _d.call(_c, type, { userID: inviter, userName: inviter_name }, (data) => {\n refuse(data);\n }, (data) => {\n accept(data);\n }, custom_data);\n }\n }\n });\n // 被邀请者收到邀请被取消后的回调通知(被邀请者)\n this._zim.on(\"callInvitationCancelled\", (zim, { callID, inviter, extendedData }) => {\n console.warn(\"callInvitationCancelled\", {\n callID,\n inviter,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationCanceled(callID, inviter, extendedData);\n if (!this.callInfo.callID)\n return;\n // 透传取消呼叫事件\n if (this.config.onIncomingCallCanceled) {\n this.config.onIncomingCallCanceled(this.callInfo.roomID, this.callInfo.inviter);\n }\n this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled);\n });\n // 邀请者的邀请被接受后的回调通知(邀请者)\n this._zim.on(\"callInvitationAccepted\", (zim, { callID, invitee, extendedData }) => {\n console.warn(\"callInvitationAccepted\", {\n callID,\n invitee,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationAccepted(callID, invitee, extendedData);\n if (!this.callInfo.callID)\n return;\n this.clearOutgoingTimer();\n this.callInfo.acceptedInvitees.push({\n userID: invitee,\n userName: \"\",\n });\n if (!this.callInfo.isGroupCall) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.notifyJoinRoomCallback();\n }\n // 透传接受邀请事件\n if (this.config.onOutgoingCallAccepted) {\n const callee = this.callInfo.invitees.find((i) => i.userID === invitee) || { userID: invitee };\n this.config.onOutgoingCallAccepted(this.callInfo.roomID, callee);\n }\n });\n // 邀请者的邀请被拒绝后的回调通知(邀请者)\n this._zim.on(\"callInvitationRejected\", (zim, { callID, invitee, extendedData }) => {\n console.warn(\"callInvitationRejected\", {\n callID,\n invitee,\n extendedData,\n });\n this._inRoomInviteMg.onCallInvitationRefused(callID, invitee, extendedData);\n if (!this.callInfo.callID)\n return;\n let reason;\n if (extendedData.length) {\n const data = JSON.parse(extendedData);\n reason = data.reason;\n }\n // 透传拒绝事件\n const callee = this.callInfo.invitees.find((i) => i.userID === invitee) || { userID: invitee };\n if (reason === \"busy\") {\n this.config.onOutgoingCallRejected && this.config.onOutgoingCallRejected(this.callInfo.roomID, callee);\n }\n else {\n this.config.onOutgoingCallDeclined && this.config.onOutgoingCallDeclined(this.callInfo.roomID, callee);\n }\n if (!this.callInfo.isGroupCall) {\n // 单人邀请,隐藏waitingPage,清除callInfo\n this.clearOutgoingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(reason === \"busy\" ? _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Busy : _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n else {\n // 多人邀请,\n // 移除拒绝者\n this.callInfo.invitees = this.callInfo.invitees.filter((i) => i.userID !== invitee);\n if (this.callInfo.invitees.length === 0) {\n // 全部拒绝后需要退出房间\n this.clearOutgoingTimer();\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n }\n });\n //被邀请者响应超时后,“邀请者”收到的回调通知, 超时时间单位:秒(邀请者)\n this._zim.on(\"callInviteesAnsweredTimeout\", (zim, { callID, invitees }) => {\n console.warn(\"callInviteesAnsweredTimeout\", { callID, invitees });\n this._inRoomInviteMg.onCallInviteesAnsweredTimeout(callID, invitees);\n if (!this.callInfo.callID)\n return;\n this.clearOutgoingTimer();\n // 透传超时事件\n if (this.config.onOutgoingCallTimeout) {\n const callees = invitees.map((i) => {\n return (this.callInfo.invitees.find((u) => u.userID === i) || {\n userID: i,\n });\n });\n this.config.onOutgoingCallTimeout(this.callInfo.roomID, callees);\n }\n this.answeredTimeoutCallback(invitees);\n });\n //被邀请者响应超时后,“被邀请者”收到的回调通知, 超时时间单位:秒 (被邀请者)\n this._zim.on(\"callInvitationTimeout\", (zim, { callID }) => {\n console.warn(\"callInvitationTimeout\", { callID });\n this._inRoomInviteMg.onCallInvitationTimeout(callID);\n if (!this.callInfo.callID)\n return;\n // 透传超时事件\n if (this.config.onIncomingCallTimeout) {\n this.config.onIncomingCallTimeout(this.callInfo.roomID, this.callInfo.inviter);\n }\n this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n });\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.on(\"connectionStateChanged\", (zim, data) => {\n console.warn(\"【zim】connectionStateChanged\", data);\n });\n (_b = this._zim) === null || _b === void 0 ? void 0 : _b.on(\"receiveRoomMessage\", (zim, data) => {\n console.warn(\"receiveRoomMessage\", data);\n const textMsgs = data.messageList\n .filter((msg) => msg.type === 1)\n .map((msg) => ({\n messageID: msg.messageID,\n timestamp: msg.timestamp,\n orderKey: msg.orderKey,\n senderUserID: msg.senderUserID,\n text: msg.message,\n }));\n const commandMsgs = data.messageList\n .filter((msg) => msg.type === 2)\n .map((msg) => ({\n messageID: msg.messageID,\n timestamp: msg.timestamp,\n orderKey: msg.orderKey,\n senderUserID: msg.senderUserID,\n command: JSON.parse(decodeURIComponent(escape(String.fromCharCode(...Array.from(msg.message))))),\n }));\n commandMsgs.length && this.onRoomCommandMessageCallback && this.onRoomCommandMessageCallback(commandMsgs);\n textMsgs.length && this.onRoomTextMessageCallback && this.onRoomTextMessageCallback(textMsgs);\n });\n }\n answeredTimeoutCallback(invitees) {\n if (!this.callInfo.callID)\n return;\n if (this.callInfo.isGroupCall) {\n // 多人邀请\n this.callInfo.invitees = this.callInfo.invitees.filter((i) => !invitees.find((u) => u === i.userID));\n if (this.callInfo.invitees.length === 0) {\n // 全部超时就退出房间,结束邀请\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n else {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n sendInvitation(invitees, type, timeout, data, notificationConfig) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.callInfo.callID)\n return Promise.reject(\"You already have a call invitation!\");\n if (!this.isServiceActivated)\n return Promise.reject(\"The call invitation service has not been activated.\");\n if (this.inSendOperation)\n return Promise.reject(\"send invitation repeat !!\");\n this.inSendOperation = true;\n const inviteesID = invitees.map((i) => i.userID);\n const roomID = `call_${this.expressConfig.userID}_${new Date().getTime()}`;\n if (notificationConfig) {\n this.notificationConfig = notificationConfig;\n }\n const _data = {\n call_id: roomID,\n invitees: invitees.map((u) => ({\n user_id: u.userID,\n user_name: u.userName,\n })),\n inviter: {\n id: this.expressConfig.userID,\n name: this.expressConfig.userName,\n },\n type,\n custom_data: data,\n };\n const extendedData = {\n inviter_name: this.expressConfig.userName,\n type,\n data: JSON.stringify(_data),\n };\n const config = {\n timeout,\n extendedData: JSON.stringify(extendedData),\n };\n // 发送离线消息\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n const pushConfig = {\n title: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.title) || this.expressConfig.userName,\n content: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.message) ||\n `Incoming ${invitees.length > 1 ? \"group \" : \"\"}${type === 0 ? \"voice\" : \"video\"} call...`,\n payload: JSON.stringify(Object.assign({}, _data, extendedData)),\n resourcesID: (_a = notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.resourcesID) !== null && _a !== void 0 ? _a : \"zegouikit_call\",\n };\n config.pushConfig = pushConfig;\n }\n try {\n this.callInfo.callID = new Date().getTime().toString(); //临时生成个id,防止同时呼叫情况\n const res = yield this._zim.callInvite(inviteesID, config);\n const errorInvitees = res.errorInvitees.map((i) => {\n return invitees.find((u) => u.userID === i.userID);\n });\n if (res.errorInvitees.length >= invitees.length) {\n // 全部邀请失败,中断流程\n this.inSendOperation = false;\n this.clearCallInfo();\n return Promise.resolve({ errorInvitees });\n }\n // 过滤掉不在线的用户\n const onlineInvitee = invitees.filter((i) => !res.errorInvitees.find((e) => e.userID === i.userID));\n // 保存邀请信息,进入busy状态\n this.callInfo = {\n callID: res.callID,\n invitees: onlineInvitee,\n inviter: {\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n },\n acceptedInvitees: [],\n roomID,\n type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 添加定时器,断网等情况导致收不到消息时,当超时处理\n this.outgoingTimer = setTimeout(() => {\n if (this.callInfo.callID) {\n // 透传超时事件\n this.config.onOutgoingCallTimeout &&\n this.config.onOutgoingCallTimeout(this.callInfo.roomID, this.callInfo.invitees);\n // 当超时后,没有一个人接受邀请,则主动退出房间\n !this.callInfo.acceptedInvitees.length &&\n this.answeredTimeoutCallback(onlineInvitee.map((u) => u.userID));\n }\n this.clearOutgoingTimer();\n }, (timeout + 1) * 1000);\n if (invitees.length > 1) {\n // 多人邀请,直接进房\n this.notifyJoinRoomCallback();\n }\n else {\n // 单人邀请,进入等待页\n if (!this.config.enableCustomCallInvitationWaitingPage) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageShow(invitees[0], type, () => {\n var _a, _b;\n this.cancelInvitation();\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n }, (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.outgoingCallUrl);\n }\n const cancel = () => {\n var _a, _b;\n this.cancelInvitation();\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n };\n (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.onWaitingPageWhenSending) === null || _e === void 0 ? void 0 : _e.call(_d, this.callInfo.type, invitees, () => {\n cancel();\n });\n }\n this.inSendOperation = false;\n return Promise.resolve({ errorInvitees });\n }\n catch (error) {\n this.clearCallInfo();\n this.inSendOperation = false;\n return Promise.reject(JSON.stringify(error));\n }\n });\n }\n cancelInvitation(data) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inCancelOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inCancelOperation = true;\n this.clearOutgoingTimer();\n const invitees = this.callInfo.invitees.map((i) => i.userID);\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n const config = {\n extendedData: JSON.stringify(extendedData),\n };\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n config.pushConfig = {\n title: ((_a = this.notificationConfig) === null || _a === void 0 ? void 0 : _a.title) || this.expressConfig.userName,\n content: ((_b = this.notificationConfig) === null || _b === void 0 ? void 0 : _b.message) || \"Cancelled invitation\",\n resourcesID: (_d = (_c = this.notificationConfig) === null || _c === void 0 ? void 0 : _c.resourcesID) !== null && _d !== void 0 ? _d : \"zegouikit_call\",\n payload: JSON.stringify({\n call_id: this.callInfo.roomID,\n operation_type: \"cancel_invitation\",\n }),\n };\n console.log(\"cancelInvitation\", config);\n }\n try {\n yield ((_e = this._zim) === null || _e === void 0 ? void 0 : _e.callCancel(invitees, this.callInfo.callID, config));\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.clearCallInfo();\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】cancelInvitation\", error);\n }\n this.inCancelOperation = false;\n });\n }\n refuseInvitation(reason, callID, data) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inRefuseOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inRefuseOperation = true;\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n if (reason) {\n extendedData.reason = reason;\n }\n try {\n yield ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callReject(callID || this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }));\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】refuseInvitation\", error);\n }\n this.inRefuseOperation = false;\n });\n }\n acceptInvitation(data) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n if (this.inAcceptOperation)\n return;\n if (!this.callInfo.callID)\n return;\n this.inAcceptOperation = true;\n const extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n try {\n yield ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callAccept(this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }));\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n }\n catch (error) {\n console.error(\"【ZEGOCLOUD】acceptInvitation\", error);\n }\n this.inAcceptOperation = false;\n });\n }\n clearCallInfo() {\n this.callInfo = {};\n }\n destroy() {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.destroy();\n this._zim = null;\n }\n /** 通知UI层调用joinRoom */\n notifyJoinRoom(func) {\n func &&\n (this.notifyJoinRoomCallback = () => {\n var _a, _b;\n // 接收客户传递进来的roomConfig\n const roomConfig = ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onSetRoomConfigBeforeJoining) === null || _b === void 0 ? void 0 : _b.call(_a, this.callInfo.type)) || {};\n func(this.callInfo.type, roomConfig, this.callInfo.isGroupCall ? _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.GroupCall : _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.OneONoneCall);\n });\n }\n /** 通知UI层调用leaveRoom */\n notifyLeaveRoom(func) {\n this.notifyLeaveRoomCallback = (reason) => {\n func && func();\n this.endCall(reason);\n };\n }\n /**收到邀请后需要更新roomID*/\n onUpdateRoomID(func) {\n func &&\n (this.onUpdateRoomIDCallback = () => {\n func(this.callInfo.roomID);\n this.expressConfig.roomID = this.callInfo.roomID;\n });\n }\n /**结束 call,清除 callInfo */\n endCall(reason) {\n var _a, _b;\n if (reason === _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.LeaveRoom &&\n !this.callInfo.acceptedInvitees.length &&\n this.callInfo.inviter.userID === this.expressConfig.userID) {\n // 主叫人如果在所有人接收邀请前离开房间,则取消所有人的邀请\n this.cancelInvitation();\n }\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, reason, \"\");\n this.clearCallInfo();\n }\n setCallInvitationConfig(config) {\n this.config = Object.assign(this.config, config);\n }\n clearOutgoingTimer() {\n if (this.outgoingTimer) {\n clearTimeout(this.outgoingTimer);\n this.outgoingTimer = null;\n }\n }\n clearIncomingTimer() {\n if (this.incomingTimer) {\n clearTimeout(this.incomingTimer);\n this.incomingTimer = null;\n }\n }\n onRoomTextMessage(func) {\n this.onRoomTextMessageCallback = func;\n }\n onRoomCommandMessage(func) {\n this.onRoomCommandMessageCallback = func;\n }\n enterRoom() {\n var _a;\n if (this.isLogin) {\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.enterRoom({\n roomID: this.callInfo.callID || this.expressConfig.roomID,\n roomName: this.callInfo.callID || this.expressConfig.roomID,\n }).then((res) => {\n console.warn(\"【zim enterRoom】success\");\n }).catch((error) => {\n console.error(\"【zim enterRoom】failed\", error);\n });\n }\n }\n leaveRoom() {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.leaveRoom(this.callInfo.callID || this.expressConfig.roomID).then((res) => {\n console.warn(\"【zim leaveRoom】success\");\n }).catch((error) => {\n console.error(\"【zim leaveRoom】failed\", error);\n });\n }\n sendMessage(command, priority = 1) {\n var _a;\n return __awaiter(this, void 0, void 0, function* () {\n const res = yield ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.sendMessage({\n type: 2,\n message: new Uint8Array(Array.from(unescape(encodeURIComponent(JSON.stringify(command)))).map((val) => val.charCodeAt(0))),\n }, this.expressConfig.roomID, 1, {\n priority: priority,\n }));\n const { messageID, orderKey, timestamp, senderUserID, message } = res.message;\n return {\n messageID,\n timestamp,\n orderKey,\n senderUserID,\n command: JSON.parse(decodeURIComponent(escape(String.fromCharCode(...Array.from(message))))),\n };\n });\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/ZimManager.ts?");
2314
2314
 
2315
2315
  /***/ }),
2316
2316