@zegocloud/zego-uikit-prebuilt 1.9.0 → 1.10.0

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
@@ -77,6 +77,16 @@ declare interface InRoomMessageInfo {
77
77
  sendTime: number;
78
78
  messageID: number;
79
79
  }
80
+ declare enum ScreenSharingResolution {
81
+ _360P = "360p",
82
+ _480P = "480p",
83
+ _720P = "720p",
84
+ _1080P = "1080p",
85
+ _2K = "2k",
86
+ _4K = "4k",
87
+ Auto = "auto",
88
+ Custom = "custom",
89
+ }
80
90
  declare interface ZegoCloudRoomConfig {
81
91
  // 1 UI controls
82
92
  // 1.1 Global
@@ -87,6 +97,14 @@ declare interface ZegoCloudRoomConfig {
87
97
  config?: ScenarioConfig[ScenarioModel]; // Specific configurations in the corresponding scenario.
88
98
  };
89
99
  console?: ConsoleLevel; // Used to problem localization, not a regular setup. While setting this can decide what severity of logs you want to print.
100
+ screenSharingConfig?: {
101
+ resolution?: ScreenSharingResolution;
102
+ width?: number;
103
+ height?: number;
104
+ frameRate?: number;
105
+ maxBitRate?: number;
106
+ }; // Screen sharing settings, resolution settings
107
+
90
108
  // 1.2 Prejoin view
91
109
  showPreJoinView?: boolean; // Whether to display the prejoin view. Displayed by default.
92
110
  preJoinViewConfig?: {
@@ -135,6 +153,7 @@ declare interface ZegoCloudRoomConfig {
135
153
  enableUserSearch?: boolean; // Whether to enable the user search feature, false by default.
136
154
  // 1.4 Leaving view
137
155
  showLeavingView?: boolean; // Whether to display the leaving view. Displayed by default.
156
+ showLeaveRoomConfirmDialog?: boolean; // When leaving the room, whether to display a confirmation pop-up window, the default is true
138
157
 
139
158
  // 2 Related event callbacks
140
159
  onJoinRoom?: () => void; // Callback for participants join the room.
@@ -149,6 +168,7 @@ declare interface ZegoCloudRoomConfig {
149
168
  onInRoomCommandReceived?: (fromUser: ZegoUser, command: string) => void; // Callback for room command message
150
169
  onInRoomTextMessageReceived?: (messages: ZegoSignalingInRoomTextMessage[]) => void; // Callback for room signaling text message
151
170
  onInRoomCustomCommandReceived?: (command: ZegoSignalingInRoomCommandMessage[]) => void; // Callback for room custom command message
171
+ onReturnToHomeScreenClicked?: () => void; // Callback for click return to home screen button.
152
172
  }
153
173
 
154
174
  export enum RightPanelExpandedType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zegocloud/zego-uikit-prebuilt",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "zegocloud prebuilt meeting webrtc sdk",
5
5
  "keywords": [
6
6
  "sdk",
@@ -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 showLeaveRoomConfirmDialog: true,\n screenSharingConfig: {\n resolution: _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution.Auto,\n },\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 if (config.screenSharingConfig && config.screenSharingConfig.resolution) {\n if (config.screenSharingConfig.resolution === _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution.Custom) {\n const { width, height, frameRate, maxBitRate } = config.screenSharingConfig;\n if (!width || !height || !frameRate || !maxBitRate) {\n console.error(\"【ZEGOCLOUD】【screenSharingConfig】 Please configure 'width', 'height', 'frameRate' and 'maxBitRate' for custom screen sharing resolution\");\n return false;\n }\n if (height < 360 && width < 640) {\n config.screenSharingConfig.resolution = _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution._360P;\n // width height too small, it will cause screen sharing failed\n console.warn(\"【ZEGOCLOUD】 The minimum value of 'width' and 'height' are 640 and 360\");\n }\n if (width > 3840 && height > 2160) {\n config.screenSharingConfig.resolution = _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution._4K;\n // width height too large, it will cause screen sharing failed\n console.warn(\"【ZEGOCLOUD】 The maximum value of 'width' and 'height' are 3840 and 2160\");\n }\n if (maxBitRate > 10000) {\n config.screenSharingConfig.maxBitRate = 10000;\n console.warn(\"【ZEGOCLOUD】【screenSharingConfig】 The maximum value of 'maxBitRate' is 10000\");\n }\n }\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?");
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 showLeaveRoomConfirmDialog: true,\n screenSharingConfig: {\n resolution: _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution.Auto,\n },\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 if (config.screenSharingConfig && config.screenSharingConfig.resolution) {\n if (config.screenSharingConfig.resolution === _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution.Custom) {\n const { width, height, frameRate, maxBitRate } = config.screenSharingConfig;\n if (!width || !height || !frameRate || !maxBitRate) {\n console.error(\"【ZEGOCLOUD】【screenSharingConfig】 Please configure 'width', 'height', 'frameRate' and 'maxBitRate' for custom screen sharing resolution\");\n return false;\n }\n if (height < 360 && width < 640) {\n config.screenSharingConfig.resolution = _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution._360P;\n // width height too small, it will cause screen sharing failed\n console.warn(\"【ZEGOCLOUD】 The minimum value of 'width' and 'height' are 640 and 360\");\n }\n if (width > 3840 && height > 2160) {\n config.screenSharingConfig.resolution = _model__WEBPACK_IMPORTED_MODULE_2__.ScreenSharingResolution._4K;\n // width height too large, it will cause screen sharing failed\n console.warn(\"【ZEGOCLOUD】 The maximum value of 'width' and 'height' are 3840 and 2160\");\n }\n if (maxBitRate > 10000) {\n config.screenSharingConfig.maxBitRate = 10000;\n console.warn(\"【ZEGOCLOUD】【screenSharingConfig】 The maximum value of 'maxBitRate' is 10000\");\n }\n }\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 const newChatData = (0,_tools_util__WEBPACK_IMPORTED_MODULE_0__.transformMsg)(chatData);\n this.onRoomMessageUpdateCallBack && this.onRoomMessageUpdateCallBack(roomID, newChatData);\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
 
@@ -2321,7 +2321,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2321
2321
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2322
2322
 
2323
2323
  "use strict";
2324
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"changeCDNUrlOrigin\": function() { return /* binding */ changeCDNUrlOrigin; },\n/* harmony export */ \"copy\": function() { return /* binding */ copy; },\n/* harmony export */ \"formatTime\": function() { return /* binding */ formatTime; },\n/* harmony export */ \"generateStreamID\": function() { return /* binding */ generateStreamID; },\n/* harmony export */ \"generateVideoView\": function() { return /* binding */ generateVideoView; },\n/* harmony export */ \"getConfig\": function() { return /* binding */ getConfig; },\n/* harmony export */ \"throttle\": function() { return /* binding */ throttle; }\n/* harmony export */ });\nfunction generateVideoView(isVideo, userID) {\n const mediaDom = document.createElement(isVideo ? \"video\" : \"audio\");\n mediaDom.id = \"zego-video-\" + userID;\n mediaDom.autoplay = true;\n return mediaDom;\n}\nfunction getConfig(token) {\n if (token.split(\"#\").length > 1) {\n const tokenInfo = JSON.parse(window.atob(token.split(\"#\")[1]));\n return {\n appID: tokenInfo.appID * 1,\n userID: tokenInfo.userID,\n userName: decodeURIComponent(tokenInfo.userName),\n roomID: tokenInfo.roomID,\n token: token.split(\"#\")[0],\n };\n }\n else {\n console.error(\"【ZEGOCLOUD】kitToken error\");\n }\n}\nfunction fallbackCopyTextToClipboard(text) {\n const textArea = document.createElement(\"textarea\");\n textArea.value = text;\n // Avoid scrolling to bottom\n textArea.style.top = \"0\";\n textArea.style.left = \"0\";\n textArea.style.position = \"fixed\";\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n try {\n var successful = document.execCommand(\"copy\");\n var msg = successful ? \"successful\" : \"unsuccessful\";\n console.log(\"【ZEGOCLOUD】 Fallback: Copying text command was \" + msg);\n }\n catch (err) {\n console.error(\"【ZEGOCLOUD】Fallback: Oops, unable to copy\", err);\n }\n document.body.removeChild(textArea);\n}\nfunction copy(text) {\n if (!navigator.clipboard) {\n fallbackCopyTextToClipboard(text);\n return;\n }\n navigator.clipboard.writeText(text).then(function () {\n console.log(\"【ZEGOCLOUD】Async: Copying to clipboard was successful!\");\n }, function (err) {\n console.error(\"【ZEGOCLOUD】 Async: Could not copy text: \", err);\n });\n}\nfunction formatTime(s) {\n return [s / 3600, s / 60, s % 60]\n .map((item) => (item < 10 ? \"0\" : \"\") + Math.floor(item))\n .join(\":\");\n}\nfunction generateStreamID(userID, roomID, type) {\n type = type || \"main\";\n return `${roomID}_${userID}_${type}`;\n}\nfunction changeCDNUrlOrigin(url) {\n if (/^http:\\/\\//.test(url)) {\n return url.replace(/http:/, \"https:\");\n }\n return url;\n}\nconst throttle = (func, delay) => {\n let timeoutId;\n let lastExecTime = 0;\n return function (...args) {\n const now = Date.now();\n if (now - lastExecTime < delay) {\n if (timeoutId)\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n lastExecTime = now;\n func.apply(this, args);\n }, delay - (now - lastExecTime));\n }\n else {\n lastExecTime = now;\n func.apply(this, args);\n }\n };\n};\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/util.ts?");
2324
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"changeCDNUrlOrigin\": function() { return /* binding */ changeCDNUrlOrigin; },\n/* harmony export */ \"copy\": function() { return /* binding */ copy; },\n/* harmony export */ \"formatTime\": function() { return /* binding */ formatTime; },\n/* harmony export */ \"generateStreamID\": function() { return /* binding */ generateStreamID; },\n/* harmony export */ \"generateVideoView\": function() { return /* binding */ generateVideoView; },\n/* harmony export */ \"getConfig\": function() { return /* binding */ getConfig; },\n/* harmony export */ \"throttle\": function() { return /* binding */ throttle; },\n/* harmony export */ \"transformMsg\": function() { return /* binding */ transformMsg; }\n/* harmony export */ });\nfunction generateVideoView(isVideo, userID) {\n const mediaDom = document.createElement(isVideo ? \"video\" : \"audio\");\n mediaDom.id = \"zego-video-\" + userID;\n mediaDom.autoplay = true;\n return mediaDom;\n}\nfunction getConfig(token) {\n if (token.split(\"#\").length > 1) {\n const tokenInfo = JSON.parse(window.atob(token.split(\"#\")[1]));\n return {\n appID: tokenInfo.appID * 1,\n userID: tokenInfo.userID,\n userName: decodeURIComponent(tokenInfo.userName),\n roomID: tokenInfo.roomID,\n token: token.split(\"#\")[0],\n };\n }\n else {\n console.error(\"【ZEGOCLOUD】kitToken error\");\n }\n}\nfunction fallbackCopyTextToClipboard(text) {\n const textArea = document.createElement(\"textarea\");\n textArea.value = text;\n // Avoid scrolling to bottom\n textArea.style.top = \"0\";\n textArea.style.left = \"0\";\n textArea.style.position = \"fixed\";\n document.body.appendChild(textArea);\n textArea.focus();\n textArea.select();\n try {\n var successful = document.execCommand(\"copy\");\n var msg = successful ? \"successful\" : \"unsuccessful\";\n console.log(\"【ZEGOCLOUD】 Fallback: Copying text command was \" + msg);\n }\n catch (err) {\n console.error(\"【ZEGOCLOUD】Fallback: Oops, unable to copy\", err);\n }\n document.body.removeChild(textArea);\n}\nfunction copy(text) {\n if (!navigator.clipboard) {\n fallbackCopyTextToClipboard(text);\n return;\n }\n navigator.clipboard.writeText(text).then(function () {\n console.log(\"【ZEGOCLOUD】Async: Copying to clipboard was successful!\");\n }, function (err) {\n console.error(\"【ZEGOCLOUD】 Async: Could not copy text: \", err);\n });\n}\nfunction formatTime(s) {\n return [s / 3600, s / 60, s % 60].map((item) => (item < 10 ? \"0\" : \"\") + Math.floor(item)).join(\":\");\n}\nfunction generateStreamID(userID, roomID, type) {\n type = type || \"main\";\n return `${roomID}_${userID}_${type}`;\n}\nfunction changeCDNUrlOrigin(url) {\n if (/^http:\\/\\//.test(url)) {\n return url.replace(/http:/, \"https:\");\n }\n return url;\n}\nconst throttle = (func, delay) => {\n let timeoutId;\n let lastExecTime = 0;\n return function (...args) {\n const now = Date.now();\n if (now - lastExecTime < delay) {\n if (timeoutId)\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n lastExecTime = now;\n func.apply(this, args);\n }, delay - (now - lastExecTime));\n }\n else {\n lastExecTime = now;\n func.apply(this, args);\n }\n };\n};\n// message maybe a string or a json string, need to be transformed\nfunction transformMsg(msgs) {\n return msgs.map((msg) => {\n try {\n const message = JSON.parse(msg.message);\n return Object.assign(Object.assign({}, msg), { message: message.msg !== undefined ? message.msg : msg.message });\n }\n catch (error) {\n return msg;\n }\n });\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/util.ts?");
2325
2325
 
2326
2326
  /***/ }),
2327
2327
 
@@ -2453,7 +2453,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2453
2453
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2454
2454
 
2455
2455
  "use strict";
2456
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCKitComponent\": function() { return /* binding */ ZegoCloudRTCKitComponent; }\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__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/.pnpm/react@18.2.0/node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _pages_ZegoBrowserCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pages/ZegoBrowserCheck */ \"./src/sdk/view/pages/ZegoBrowserCheck/index.tsx\");\n/* harmony import */ var _pages_ZegoBrowserCheckMobile__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pages/ZegoBrowserCheckMobile */ \"./src/sdk/view/pages/ZegoBrowserCheckMobile/index.tsx\");\n/* harmony import */ var _pages_ZegoRoom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pages/ZegoRoom */ \"./src/sdk/view/pages/ZegoRoom/index.tsx\");\n/* harmony import */ var _pages_ZegoRoomMobile__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pages/ZegoRoomMobile */ \"./src/sdk/view/pages/ZegoRoomMobile/index.tsx\");\n/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react-intl */ \"./node_modules/.pnpm/react-intl@6.0.4_react@18.2.0_typescript@4.8.4/node_modules/react-intl/lib/src/components/provider.js\");\n/* harmony import */ var _index_module_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./index.module.scss */ \"./src/sdk/view/index.module.scss\");\n/* harmony import */ var _pages_ZegoRejoinRoom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pages/ZegoRejoinRoom */ \"./src/sdk/view/pages/ZegoRejoinRoom/index.tsx\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _components_zegoModel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./components/zegoModel */ \"./src/sdk/view/components/zegoModel/index.tsx\");\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.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\n\n\n\n\n\nclass ZegoCloudRTCKitComponent extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {\n constructor() {\n super(...arguments);\n this.state = {\n step: this.props.core._config.showPreJoinView ? 0 : 1,\n isSupportWebRTC: true,\n };\n }\n componentDidMount() {\n return __awaiter(this, void 0, void 0, function* () {\n // const notSupportPhone =\n // !isPc() && isIOS() && IsSafari();\n const res = yield this.props.core.checkWebRTC();\n // await this.deviceCheck();\n this.setState({\n isSupportWebRTC: res,\n });\n });\n }\n deviceCheck() {\n return __awaiter(this, void 0, void 0, function* () {\n // 没有预览页面才检查,预览页本身就会检查\n if (!this.props.core._config.showPreJoinView) {\n // 检查摄像头\n if (this.props.core._config.turnOnCameraWhenJoining) {\n try {\n const cameras = yield this.props.core.getCameras();\n cameras.length < 1 && (this.props.core.status.videoRefuse = true);\n }\n catch (error) {\n this.props.core.status.videoRefuse = true;\n }\n }\n else {\n // this.props.core.status.videoRefuse = true;\n }\n // 检查麦克风\n if (this.props.core._config.turnOnMicrophoneWhenJoining) {\n try {\n const mics = yield this.props.core.getMicrophones();\n mics.length < 1 && (this.props.core.status.audioRefuse = true);\n }\n catch (error) {\n this.props.core.status.audioRefuse = true;\n }\n }\n else {\n // this.props.core.status.audioRefuse = true;\n }\n }\n });\n }\n nextPage() {\n this.setState((state) => {\n return {\n step: ++state.step,\n };\n });\n }\n destroyNodeWhenNoView() {\n //退出房间后,如果没有预览页面,就销毁渲染节点\n if (!this.props.core._config.showLeavingView &&\n !this.props.core._config.showPreJoinView) {\n this.props.unmount();\n }\n }\n render() {\n let page;\n if (this.state.isSupportWebRTC) {\n if (this.state.step === 0 && this.props.core) {\n if (false) {}\n page = (0,_util__WEBPACK_IMPORTED_MODULE_8__.isPc)() ? ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoBrowserCheck__WEBPACK_IMPORTED_MODULE_2__.ZegoBrowserCheck, { core: this.props.core, joinRoom: () => {\n this.nextPage();\n } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoBrowserCheckMobile__WEBPACK_IMPORTED_MODULE_3__.ZegoBrowserCheckMobile, { core: this.props.core, joinRoom: () => {\n this.nextPage();\n } }));\n this.props.core.setCurrentPage(\"BrowserCheckPage\");\n }\n else if (this.state.step === 1 && this.props.core) {\n if (false) {}\n setTimeout(() => {\n var _a;\n this.props.core._config.joinRoomCallback &&\n ((_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.joinRoomCallback());\n this.props.core._config.onJoinRoom &&\n this.props.core._config.onJoinRoom();\n }, 0);\n page = (0,_util__WEBPACK_IMPORTED_MODULE_8__.isPc)() ? ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRoom__WEBPACK_IMPORTED_MODULE_4__.ZegoRoom, { core: this.props.core, leaveRoom: (isKickedOut = false) => {\n if (isKickedOut) {\n // 被踢出房间回到预览页\n if (this.props.core._config.showPreJoinView) {\n this.setState({ step: 0 });\n }\n }\n else {\n this.props.core._config.showLeavingView && this.nextPage();\n }\n setTimeout(() => {\n var _a, _b, _c, _d;\n if (!isKickedOut) {\n this.props.core._config.leaveRoomCallback &&\n this.props.core._config.leaveRoomCallback();\n this.props.core._config.onLeaveRoom &&\n this.props.core._config.onLeaveRoom();\n }\n else {\n (_b = (_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.onYouRemovedFromRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n this.destroyNodeWhenNoView();\n ((_d = (_c = this.props.core._zimManager) === null || _c === void 0 ? void 0 : _c.callInfo) === null || _d === void 0 ? void 0 : _d.callID) &&\n this.props.core._zimManager.endCall(_model__WEBPACK_IMPORTED_MODULE_10__.CallInvitationEndReason.LeaveRoom);\n }, 0);\n } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRoomMobile__WEBPACK_IMPORTED_MODULE_5__.ZegoRoomMobile, { core: this.props.core, leaveRoom: (isKickedOut = false) => {\n if (isKickedOut) {\n // 被踢出房间回到预览页\n if (this.props.core._config.showPreJoinView) {\n this.setState({ step: 0 });\n }\n }\n else {\n this.props.core._config.showLeavingView && this.nextPage();\n }\n setTimeout(() => {\n var _a, _b, _c, _d;\n if (!isKickedOut) {\n this.props.core._config.leaveRoomCallback &&\n this.props.core._config.leaveRoomCallback();\n this.props.core._config.onLeaveRoom &&\n this.props.core._config.onLeaveRoom();\n }\n else {\n (_b = (_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.onYouRemovedFromRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n this.destroyNodeWhenNoView();\n // 主动退出房间,呼叫邀请结束\n ((_d = (_c = this.props.core._zimManager) === null || _c === void 0 ? void 0 : _c.callInfo) === null || _d === void 0 ? void 0 : _d.callID) &&\n this.props.core._zimManager.endCall(_model__WEBPACK_IMPORTED_MODULE_10__.CallInvitationEndReason.LeaveRoom);\n }, 0);\n } }));\n this.props.core.setCurrentPage(\"Room\");\n }\n else if (this.state.step === 2 && this.props.core) {\n page = ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRejoinRoom__WEBPACK_IMPORTED_MODULE_7__.ZegoRejoinRoom, { core: this.props.core, joinRoom: () => {\n this.setState({\n step: 1,\n });\n }, returnHome: () => {\n this.setState({\n step: 0,\n });\n } }));\n this.props.core.setCurrentPage(\"RejoinRoom\");\n }\n }\n else {\n page = ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_zegoModel__WEBPACK_IMPORTED_MODULE_9__.ZegoModel, { header: \"Browser not supported\", contentText: /Firefox/.test(window.navigator.userAgent)\n ? \"Your browser version does not support the features or something wrong with your network. Please check them and try again.\"\n : \"The current browser is not available for you to join the room.\" }));\n this.props.core.setCurrentPage(\"BrowserCheckPage\");\n }\n return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(react_intl__WEBPACK_IMPORTED_MODULE_11__[\"default\"], Object.assign({ locale: \"en\" }, { children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(\"div\", Object.assign({ className: _index_module_scss__WEBPACK_IMPORTED_MODULE_6__[\"default\"].index }, { children: page })) })));\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/view/index.tsx?");
2456
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZegoCloudRTCKitComponent\": function() { return /* binding */ ZegoCloudRTCKitComponent; }\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__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"./node_modules/.pnpm/react@18.2.0/node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _pages_ZegoBrowserCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pages/ZegoBrowserCheck */ \"./src/sdk/view/pages/ZegoBrowserCheck/index.tsx\");\n/* harmony import */ var _pages_ZegoBrowserCheckMobile__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pages/ZegoBrowserCheckMobile */ \"./src/sdk/view/pages/ZegoBrowserCheckMobile/index.tsx\");\n/* harmony import */ var _pages_ZegoRoom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pages/ZegoRoom */ \"./src/sdk/view/pages/ZegoRoom/index.tsx\");\n/* harmony import */ var _pages_ZegoRoomMobile__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pages/ZegoRoomMobile */ \"./src/sdk/view/pages/ZegoRoomMobile/index.tsx\");\n/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react-intl */ \"./node_modules/.pnpm/react-intl@6.0.4_react@18.2.0_typescript@4.8.4/node_modules/react-intl/lib/src/components/provider.js\");\n/* harmony import */ var _index_module_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./index.module.scss */ \"./src/sdk/view/index.module.scss\");\n/* harmony import */ var _pages_ZegoRejoinRoom__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./pages/ZegoRejoinRoom */ \"./src/sdk/view/pages/ZegoRejoinRoom/index.tsx\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util */ \"./src/sdk/util.ts\");\n/* harmony import */ var _components_zegoModel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./components/zegoModel */ \"./src/sdk/view/components/zegoModel/index.tsx\");\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../model */ \"./src/sdk/model/index.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\n\n\n\n\n\nclass ZegoCloudRTCKitComponent extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {\n constructor() {\n super(...arguments);\n this.state = {\n step: this.props.core._config.showPreJoinView ? 0 : 1,\n isSupportWebRTC: true,\n };\n }\n componentDidMount() {\n return __awaiter(this, void 0, void 0, function* () {\n // const notSupportPhone =\n // !isPc() && isIOS() && IsSafari();\n const res = yield this.props.core.checkWebRTC();\n // await this.deviceCheck();\n this.setState({\n isSupportWebRTC: res,\n });\n });\n }\n deviceCheck() {\n return __awaiter(this, void 0, void 0, function* () {\n // 没有预览页面才检查,预览页本身就会检查\n if (!this.props.core._config.showPreJoinView) {\n // 检查摄像头\n if (this.props.core._config.turnOnCameraWhenJoining) {\n try {\n const cameras = yield this.props.core.getCameras();\n cameras.length < 1 && (this.props.core.status.videoRefuse = true);\n }\n catch (error) {\n this.props.core.status.videoRefuse = true;\n }\n }\n else {\n // this.props.core.status.videoRefuse = true;\n }\n // 检查麦克风\n if (this.props.core._config.turnOnMicrophoneWhenJoining) {\n try {\n const mics = yield this.props.core.getMicrophones();\n mics.length < 1 && (this.props.core.status.audioRefuse = true);\n }\n catch (error) {\n this.props.core.status.audioRefuse = true;\n }\n }\n else {\n // this.props.core.status.audioRefuse = true;\n }\n }\n });\n }\n nextPage() {\n this.setState((state) => {\n return {\n step: ++state.step,\n };\n });\n }\n destroyNodeWhenNoView() {\n //退出房间后,如果没有预览页面,就销毁渲染节点\n if (!this.props.core._config.showLeavingView &&\n !this.props.core._config.showPreJoinView) {\n this.props.unmount();\n }\n }\n render() {\n let page;\n if (this.state.isSupportWebRTC) {\n if (this.state.step === 0 && this.props.core) {\n if (false) {}\n page = (0,_util__WEBPACK_IMPORTED_MODULE_8__.isPc)() ? ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoBrowserCheck__WEBPACK_IMPORTED_MODULE_2__.ZegoBrowserCheck, { core: this.props.core, joinRoom: () => {\n this.nextPage();\n } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoBrowserCheckMobile__WEBPACK_IMPORTED_MODULE_3__.ZegoBrowserCheckMobile, { core: this.props.core, joinRoom: () => {\n this.nextPage();\n } }));\n this.props.core.setCurrentPage(\"BrowserCheckPage\");\n }\n else if (this.state.step === 1 && this.props.core) {\n if (false) {}\n setTimeout(() => {\n var _a;\n this.props.core._config.joinRoomCallback &&\n ((_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.joinRoomCallback());\n this.props.core._config.onJoinRoom &&\n this.props.core._config.onJoinRoom();\n }, 0);\n page = (0,_util__WEBPACK_IMPORTED_MODULE_8__.isPc)() ? ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRoom__WEBPACK_IMPORTED_MODULE_4__.ZegoRoom, { core: this.props.core, leaveRoom: (isKickedOut = false) => {\n if (isKickedOut) {\n // 被踢出房间回到预览页\n if (this.props.core._config.showPreJoinView) {\n this.setState({ step: 0 });\n }\n }\n else {\n this.props.core._config.showLeavingView && this.nextPage();\n }\n setTimeout(() => {\n var _a, _b, _c, _d;\n if (!isKickedOut) {\n this.props.core._config.leaveRoomCallback &&\n this.props.core._config.leaveRoomCallback();\n this.props.core._config.onLeaveRoom &&\n this.props.core._config.onLeaveRoom();\n }\n else {\n (_b = (_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.onYouRemovedFromRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n this.destroyNodeWhenNoView();\n ((_d = (_c = this.props.core._zimManager) === null || _c === void 0 ? void 0 : _c.callInfo) === null || _d === void 0 ? void 0 : _d.callID) &&\n this.props.core._zimManager.endCall(_model__WEBPACK_IMPORTED_MODULE_10__.CallInvitationEndReason.LeaveRoom);\n }, 0);\n } })) : ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRoomMobile__WEBPACK_IMPORTED_MODULE_5__.ZegoRoomMobile, { core: this.props.core, leaveRoom: (isKickedOut = false) => {\n if (isKickedOut) {\n // 被踢出房间回到预览页\n if (this.props.core._config.showPreJoinView) {\n this.setState({ step: 0 });\n }\n }\n else {\n this.props.core._config.showLeavingView && this.nextPage();\n }\n setTimeout(() => {\n var _a, _b, _c, _d;\n if (!isKickedOut) {\n this.props.core._config.leaveRoomCallback &&\n this.props.core._config.leaveRoomCallback();\n this.props.core._config.onLeaveRoom &&\n this.props.core._config.onLeaveRoom();\n }\n else {\n (_b = (_a = this.props.core._config) === null || _a === void 0 ? void 0 : _a.onYouRemovedFromRoom) === null || _b === void 0 ? void 0 : _b.call(_a);\n }\n this.destroyNodeWhenNoView();\n // 主动退出房间,呼叫邀请结束\n ((_d = (_c = this.props.core._zimManager) === null || _c === void 0 ? void 0 : _c.callInfo) === null || _d === void 0 ? void 0 : _d.callID) &&\n this.props.core._zimManager.endCall(_model__WEBPACK_IMPORTED_MODULE_10__.CallInvitationEndReason.LeaveRoom);\n }, 0);\n } }));\n this.props.core.setCurrentPage(\"Room\");\n }\n else if (this.state.step === 2 && this.props.core) {\n page = ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_pages_ZegoRejoinRoom__WEBPACK_IMPORTED_MODULE_7__.ZegoRejoinRoom, { core: this.props.core, joinRoom: () => {\n this.setState({\n step: 1,\n });\n }, returnHome: () => {\n if (this.props.core._config.onReturnToHomeScreenClicked) {\n this.props.core._config.onReturnToHomeScreenClicked();\n }\n else {\n this.setState({\n step: 0,\n });\n }\n } }));\n this.props.core.setCurrentPage(\"RejoinRoom\");\n }\n }\n else {\n page = ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_zegoModel__WEBPACK_IMPORTED_MODULE_9__.ZegoModel, { header: \"Browser not supported\", contentText: /Firefox/.test(window.navigator.userAgent)\n ? \"Your browser version does not support the features or something wrong with your network. Please check them and try again.\"\n : \"The current browser is not available for you to join the room.\" }));\n this.props.core.setCurrentPage(\"BrowserCheckPage\");\n }\n return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(react_intl__WEBPACK_IMPORTED_MODULE_11__[\"default\"], Object.assign({ locale: \"en\" }, { children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(\"div\", Object.assign({ className: _index_module_scss__WEBPACK_IMPORTED_MODULE_6__[\"default\"].index }, { children: page })) })));\n }\n}\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/view/index.tsx?");
2457
2457
 
2458
2458
  /***/ }),
2459
2459