@zegocloud/zego-uikit-prebuilt 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/index.d.ts +255 -42
  2. package/package.json +1 -1
  3. package/zego-uikit-prebuilt.js +1 -1
  4. package/fingerGestureUtil.d.ts +0 -50
  5. package/model/index.d.ts +0 -283
  6. package/modules/index.d.ts +0 -128
  7. package/modules/soundmeter.d.ts +0 -18
  8. package/modules/tools/UserListManager.d.ts +0 -46
  9. package/modules/tools/ZimManager.d.ts +0 -54
  10. package/modules/tools/util.d.ts +0 -12
  11. package/view/components/mobile/zegoConfirm/index.d.ts +0 -17
  12. package/view/components/mobile/zegoToast/index.d.ts +0 -13
  13. package/view/components/zegoLoading/index.d.ts +0 -10
  14. package/view/components/zegoMedia/audio.d.ts +0 -18
  15. package/view/components/zegoMedia/video.d.ts +0 -34
  16. package/view/components/zegoModel/index.d.ts +0 -13
  17. package/view/components/zegoSelect/index.d.ts +0 -32
  18. package/view/components/zegoSetting/index.d.ts +0 -60
  19. package/view/components/zegoSetting/speakerFile.d.ts +0 -1
  20. package/view/components/zegoToast/index.d.ts +0 -13
  21. package/view/index.d.ts +0 -15
  22. package/view/pages/ZegoBrowserCheck/index.d.ts +0 -51
  23. package/view/pages/ZegoBrowserCheckMobile/components/ZegoLoading.d.ts +0 -6
  24. package/view/pages/ZegoBrowserCheckMobile/index.d.ts +0 -38
  25. package/view/pages/ZegoCallInvitation/callInvitationControl.d.ts +0 -16
  26. package/view/pages/ZegoCallInvitation/callInvitationDialog.d.ts +0 -13
  27. package/view/pages/ZegoCallInvitation/callInvitationWaiting.d.ts +0 -14
  28. package/view/pages/ZegoRejoinRoom/index.d.ts +0 -11
  29. package/view/pages/ZegoRoom/components/ZegoScreenSharingLayout.d.ts +0 -13
  30. package/view/pages/ZegoRoom/components/ZegoWhiteboardSharingLayout.d.ts +0 -16
  31. package/view/pages/ZegoRoom/components/zegoGridLayout.d.ts +0 -6
  32. package/view/pages/ZegoRoom/components/zegoMessage.d.ts +0 -21
  33. package/view/pages/ZegoRoom/components/zegoOne2One.d.ts +0 -15
  34. package/view/pages/ZegoRoom/components/zegoOthersVideo.d.ts +0 -8
  35. package/view/pages/ZegoRoom/components/zegoRoomInvite.d.ts +0 -8
  36. package/view/pages/ZegoRoom/components/zegoSidebarLayout.d.ts +0 -6
  37. package/view/pages/ZegoRoom/components/zegoTimer.d.ts +0 -9
  38. package/view/pages/ZegoRoom/components/zegoUserList.d.ts +0 -22
  39. package/view/pages/ZegoRoom/components/zegoVideoPlayer.d.ts +0 -23
  40. package/view/pages/ZegoRoom/components/zegoWhiteboard/ZegoWhiteboardTools.d.ts +0 -21
  41. package/view/pages/ZegoRoom/components/zegoWhiteboard/ZegoWhiteboardToolsGraphicsTooTips.d.ts +0 -19
  42. package/view/pages/ZegoRoom/components/zegoWhiteboard/ZegoWhiteboardToolsPenToolTips.d.ts +0 -18
  43. package/view/pages/ZegoRoom/components/zegoWhiteboard/ZegoWhiteboardToolsTextToolTips.d.ts +0 -20
  44. package/view/pages/ZegoRoom/index.d.ts +0 -109
  45. package/view/pages/ZegoRoomMobile/components/ZegoReconnect.d.ts +0 -6
  46. package/view/pages/ZegoRoomMobile/components/zegoGrid.d.ts +0 -5
  47. package/view/pages/ZegoRoomMobile/components/zegoLayout.d.ts +0 -13
  48. package/view/pages/ZegoRoomMobile/components/zegoManage.d.ts +0 -10
  49. package/view/pages/ZegoRoomMobile/components/zegoMessage.d.ts +0 -38
  50. package/view/pages/ZegoRoomMobile/components/zegoMore.d.ts +0 -10
  51. package/view/pages/ZegoRoomMobile/components/zegoOne2One.d.ts +0 -14
  52. package/view/pages/ZegoRoomMobile/components/zegoRoomInvite.d.ts +0 -8
  53. package/view/pages/ZegoRoomMobile/components/zegoScreen.d.ts +0 -9
  54. package/view/pages/ZegoRoomMobile/components/zegoSidebar.d.ts +0 -8
  55. package/view/pages/ZegoRoomMobile/components/zegoTimer.d.ts +0 -9
  56. package/view/pages/ZegoRoomMobile/components/zegoUserList.d.ts +0 -18
  57. package/view/pages/ZegoRoomMobile/components/zegoUserVideo.d.ts +0 -29
  58. package/view/pages/ZegoRoomMobile/components/zegoWhiteboard/ZegoWhiteboardTools.d.ts +0 -20
  59. package/view/pages/ZegoRoomMobile/components/zegoWhiteboard/ZegoWhiteboardToolsGraphicsTooTips.d.ts +0 -18
  60. package/view/pages/ZegoRoomMobile/components/zegoWhiteboard/ZegoWhiteboardToolsPenToolTips.d.ts +0 -17
  61. package/view/pages/ZegoRoomMobile/components/zegoWhiteboard/ZegoWhiteboardToolsTextToolTips.d.ts +0 -20
  62. package/view/pages/ZegoRoomMobile/components/zegoWhiteboard.d.ts +0 -15
  63. package/view/pages/ZegoRoomMobile/index.d.ts +0 -89
  64. package/view/pages/context/showManage.d.ts +0 -21
package/index.d.ts CHANGED
@@ -1,44 +1,257 @@
1
- import { Root } from "react-dom/client";
2
- import { ZegoSuperBoardManager } from "zego-superboard-web";
3
- import ZIM from "zego-zim-web";
4
- import { LiveRole, LiveStreamingMode, ScenarioModel, VideoResolution, ZegoCallInvitationConfig, ZegoCloudRoomConfig, ZegoInvitationType, ZegoSignalingPluginNotificationConfig, ZegoUser } from "./model/index";
5
- import { ZegoCloudRTCCore } from "./modules/index";
1
+ declare type ZegoCloudRTCCore = {};
2
+ declare interface ZegoUser {
3
+ userID: string;
4
+ userName?: string;
5
+ setUserAvatar?: (avatar: string) => void;
6
+ }
7
+ declare enum LiveRole {
8
+ Host = "Host",
9
+ Cohost = "Cohost",
10
+ Audience = "Audience",
11
+ }
12
+ declare enum ScenarioModel {
13
+ OneONoneCall = "OneONoneCall",
14
+ GroupCall = "GroupCall",
15
+ VideoConference = "VideoConference",
16
+ LiveStreaming = "LiveStreaming",
17
+ }
18
+ declare enum VideoResolution {
19
+ _180P = "180p",
20
+ _360P = "360p",
21
+ _480P = "480p",
22
+ _720P = "720p",
23
+ }
24
+
25
+ declare interface ScenarioConfig {
26
+ [ScenarioModel.LiveStreaming]: {
27
+ role: LiveRole;
28
+ liveStreamingMode: LiveStreamingMode;
29
+ };
30
+ [ScenarioModel.OneONoneCall]: {
31
+ role: LiveRole;
32
+ };
33
+ [ScenarioModel.GroupCall]: {
34
+ role: LiveRole;
35
+ };
36
+ [ScenarioModel.VideoConference]: {
37
+ role: LiveRole;
38
+ };
39
+ }
40
+ declare enum LiveStreamingMode {
41
+ /**
42
+ * @Deprecated StanderLive will be removed, please use LiveStreaming instead
43
+ */
44
+ StanderLive = "LiveStreaming",
45
+ /**
46
+ * @Deprecated PremiumLive will be removed, please use InteractiveLiveStreaming instead
47
+ */
48
+ PremiumLive = "InteractiveLiveStreaming",
49
+ LiveStreaming = "LiveStreaming", // CDN
50
+ InteractiveLiveStreaming = "InteractiveLiveStreaming", // L3
51
+ RealTimeLive = "RealTimeLive", //RTC
52
+ }
53
+ declare interface ZegoCloudRoomConfig {
54
+ container?: HTMLElement | undefined | null; // mount container
55
+ preJoinViewConfig?: {
56
+ title?: string; // Title setting, default enter Room
57
+ invitationLink?: string;
58
+ };
59
+ showPreJoinView?: boolean; // Whether to display the preview detection page, the default display
60
+ turnOnMicrophoneWhenJoining?: boolean; // Whether to turn on your own microphone, by default
61
+ turnOnCameraWhenJoining?: boolean; // Whether to turn on your own camera or not, it is turned on by default
62
+ showMyCameraToggleButton?: boolean; // Whether to display the button to control your own microphone, the default display
63
+ showMyMicrophoneToggleButton?: boolean; // Whether to display the button to control your own camera, the default display
64
+ showAudioVideoSettingsButton?: boolean; // Whether to display the audio and video settings button, the default display
65
+
66
+ showTextChat?: boolean; // Whether to enable chat, default enabled
67
+ showUserList?: boolean; //Whether to display the member list or not by default
68
+ lowerLeftNotification?: {
69
+ showUserJoinAndLeave?: boolean; //Whether to display members entering and leaving, default is not displayed
70
+ showTextChat?: boolean; // Whether to display unread messages or not by default
71
+ };
72
+ branding?: {
73
+ logoURL?: string; // call page logo
74
+ };
75
+ showLeavingView?: boolean; // The page after leaving the room, by default
76
+
77
+ maxUsers?: number; // The number of people in the room is 2 to 20, the default is 2
78
+ layout?: "Sidebar" | "Grid" | "Auto"; // Default Default
79
+
80
+ showNonVideoUser?: boolean; // whether to display users without video, default display
81
+ showOnlyAudioUser?: boolean; // Whether to display audio-only users, the default display
82
+
83
+ useFrontFacingCamera?: boolean;
84
+ onJoinRoom?: () => void; // User enters call page callback
85
+ onLeaveRoom?: () => void; // User exit call page callback
86
+ onUserJoin?: (user: ZegoUser[]) => void; // other users enter the callback
87
+ onUserLeave?: (user: ZegoUser[]) => void; // Other users leave the callback
88
+ sharedLinks?: { name?: string; url?: string }[]; // product link description
89
+ showScreenSharingButton?: boolean; // Whether to display the screen sharing button
90
+ scenario?: {
91
+ mode?: ScenarioModel; // Scenario selection
92
+ config?: ScenarioConfig[ScenarioModel]; // Corresponding scenario-specific configuration
93
+ };
94
+
95
+ showLayoutButton?: boolean; // Whether to display the layout switch button
96
+ showPinButton?: boolean; // Whether to display the pin button
97
+ onUserAvatarSetter?: (user: ZegoUser[]) => void; //Is it possible to set the user avatar callback
98
+ videoResolutionList?: VideoResolution[]; // video resolution list (the first one is used by default)
99
+ videoResolutionDefault?: VideoResolution; // Default video resolution
100
+ onLiveStart?: (user: ZegoUser) => void; //Live start callback
101
+ onLiveEnd?: (user: ZegoUser) => void; //Callback for live broadcast end
102
+ /**
103
+ * @deprecated facingMode will be removed
104
+ * */
105
+ facingMode?: "user" | "environment"; // front camera mode
106
+ /**
107
+ * @deprecated joinRoomCallback will be removed
108
+ * */
109
+ joinRoomCallback?: () => void; // join room success callback
110
+ /**
111
+ * @deprecated leaveRoomCallback will be removed
112
+ * */
113
+ leaveRoomCallback?: () => void; // exit room callback
114
+ /**
115
+ * @deprecated userUpdateCallback will be removed
116
+ * */
117
+ userUpdateCallback?: (
118
+ updateType: "DELETE" | "ADD",
119
+ userList: ZegoUser[]
120
+ ) => void; // user add/exit callback
121
+ /**
122
+ * @deprecated roomTimerDisplayed will be removed
123
+ * */
124
+ roomTimerDisplayed?: boolean; // Whether to display the countdown
125
+
126
+ whiteboardConfig?: {
127
+ showAddImageButton?: boolean; // The default is false, the file sharing function is enabled and the plug-in is introduced before it will take effect; otherwise, an error message will appear: "Failed to add image, this feature is not supported."
128
+ showCreateAndCloseButton?: boolean;
129
+ };
130
+ autoLeaveRoomWhenOnlySelfInRoom?: boolean; // When there is only one person left in the room, automatically exit the room
131
+ }
132
+
133
+ declare enum ZegoInvitationType {
134
+ VoiceCall = 0,
135
+ VideoCall,
136
+ }
137
+ declare interface ZegoCallInvitationConfig {
138
+ enableCustomCallInvitationWaitingPage?: boolean; // Whether to customize the call invitation waiting page, default false
139
+ enableCustomCallInvitationDialog?: boolean; // Whether to customize the call invitation pop-up window, the default is false
140
+ enableNotifyWhenAppRunningInBackgroundOrQuit?: boolean; // Notify users when the app is running in the background or the app is killed, default false
141
+ ringtoneConfig?: {
142
+ incomingCallUrl?: string; // ringtone when receiving
143
+ outgoingCallUrl?: string; // Outgoing ringtone
144
+ };
145
+ // Callback when entering the call waiting page, return the cancel method, if called, you can cancel the invitation
146
+ onWaitingPageWhenSending?: (
147
+ callType: ZegoInvitationType,
148
+ callees: ZegoUser[],
149
+ cancel: CancelCallInvitationFunc
150
+ ) => void;
151
+
152
+ // When the callee receives the invitation, the invitation pop-up window displays the callback, and returns the accept and refuse methods to bind the UI to the user
153
+ onConfirmDialogWhenReceiving?: (
154
+ callType: ZegoInvitationType,
155
+ caller: ZegoUser,
156
+ refuse: RefuseCallInvitationFunc,
157
+ accept: AcceptCallInvitationFunc,
158
+ data: string
159
+ ) => void;
160
+
161
+ // Callback before entering the room after accepting the invitation, used to set the room configuration, automatically join the room internally, and the room configuration is based on the default ZegoInvitationType
162
+ onSetRoomConfigBeforeJoining?: (
163
+ callType: ZegoInvitationType
164
+ ) => ZegoCloudRoomConfig;
165
+
166
+ // Call invitation end callback (call rejected, timeout, busy, user exits the room where the call was invited, etc.)
167
+ onCallInvitationEnded?: (
168
+ reason: CallInvitationEndReason,
169
+ data: string
170
+ ) => void;
171
+
172
+ // After Prebuilt receives the call invitation, it converts the internal data into corresponding data and throws
173
+ onIncomingCallReceived?: (
174
+ callID: string,
175
+ caller: ZegoUser,
176
+ callType: ZegoInvitationType,
177
+ callees: ZegoUser[]
178
+ ) => void;
179
+ // When the caller cancels the call, convert the internal data to the corresponding data and throw it.
180
+ onIncomingCallCanceled?: (callID: string, caller: ZegoUser) => void;
181
+ // After the callee accepts the invitation, the caller will receive the callback, convert the internal data into corresponding data and throw it.
182
+ onOutgoingCallAccepted?: (callID: string, callee: ZegoUser) => void;
183
+ // When the callee is in a call and rejects the invitation, the caller will receive this callback, convert the internal data into corresponding data and throw it.
184
+ onOutgoingCallRejected?: (callID: string, callee: ZegoUser) => void;
185
+ // When the callee voluntarily refuses the call, the caller will receive this callback, convert the internal data into corresponding data and throw it.
186
+ onOutgoingCallDeclined?: (callID: string, callee: ZegoUser) => void;
187
+ //When the callee fails to respond to the invitation after a timeout, the callee will receive the callback, convert the internal data into corresponding data and throw it.
188
+ onIncomingCallTimeout?: (callID: string, caller: ZegoUser) => void;
189
+ //When the call exceeds the fixed time, if there are still callees who do not respond, the caller will receive the callback, convert the internal data into corresponding data and throw it.
190
+ onOutgoingCallTimeout?: (callID: string, callees: ZegoUser[]) => void;
191
+ }
192
+
193
+ declare interface ZegoSignalingPluginNotificationConfig {
194
+ resourcesID?: string;
195
+ title?: string;
196
+ message?: string;
197
+ }
198
+
199
+ declare enum CallInvitationEndReason {
200
+ Declined = "Declined",
201
+ Timeout = "Timeout",
202
+ Canceled = "Canceled",
203
+ Busy = "Busy",
204
+ LeaveRoom = "LeaveRoom",
205
+ }
206
+ declare type CancelCallInvitationFunc = (data?: string) => void; // cancel invitation
207
+ declare type AcceptCallInvitationFunc = (data?: string) => void; // accept invitation
208
+ declare type RefuseCallInvitationFunc = (data?: string) => void; // reject invitation
209
+
6
210
  export declare class ZegoUIKitPrebuilt {
7
- static core: ZegoCloudRTCCore | undefined;
8
- static _instance: ZegoUIKitPrebuilt;
9
- static Host: LiveRole;
10
- static Cohost: LiveRole;
11
- static Audience: LiveRole;
12
- static OneONoneCall: ScenarioModel;
13
- static GroupCall: ScenarioModel;
14
- static LiveStreaming: ScenarioModel;
15
- static VideoConference: ScenarioModel;
16
- static VideoResolution_180P: VideoResolution;
17
- static VideoResolution_360P: VideoResolution;
18
- static VideoResolution_480P: VideoResolution;
19
- static VideoResolution_720P: VideoResolution;
20
- static LiveStreamingMode: typeof LiveStreamingMode;
21
- static InvitationTypeVoiceCall: ZegoInvitationType;
22
- static InvitationTypeVideoCall: ZegoInvitationType;
23
- private hasJoinedRoom;
24
- root: Root | undefined;
25
- static generateKitTokenForTest(appID: number, serverSecret: string, roomID: string, userID: string, userName?: string, ExpirationSeconds?: number): string;
26
- static generateKitTokenForProduction(appID: number, token: string, roomID: string, userID: string, userName?: string): string;
27
- static create(kitToken: string): ZegoUIKitPrebuilt;
28
- addPlugins(plugins?: {
29
- ZegoSuperBoardManager?: typeof ZegoSuperBoardManager;
30
- ZIM?: typeof ZIM;
31
- }): void;
32
- joinRoom(roomConfig?: ZegoCloudRoomConfig): void;
33
- destroy(): void;
34
- setCallInvitationConfig(config?: ZegoCallInvitationConfig): void;
35
- sendCallInvitation(params: {
36
- callees: ZegoUser[];
37
- callType: ZegoInvitationType;
38
- timeout?: number;
39
- data?: string;
40
- notificationConfig?: ZegoSignalingPluginNotificationConfig;
41
- }): Promise<{
42
- errorInvitees: ZegoUser[];
43
- }>;
211
+ static core: ZegoCloudRTCCore | undefined;
212
+ static _instance: ZegoUIKitPrebuilt;
213
+ static Host: LiveRole;
214
+ static Cohost: LiveRole;
215
+ static Audience: LiveRole;
216
+ static OneONoneCall: ScenarioModel;
217
+ static GroupCall: ScenarioModel;
218
+ static LiveStreaming: ScenarioModel;
219
+ static VideoConference: ScenarioModel;
220
+ static VideoResolution_180P: VideoResolution;
221
+ static VideoResolution_360P: VideoResolution;
222
+ static VideoResolution_480P: VideoResolution;
223
+ static VideoResolution_720P: VideoResolution;
224
+ static LiveStreamingMode: typeof LiveStreamingMode;
225
+ static InvitationTypeVoiceCall: ZegoInvitationType;
226
+ static InvitationTypeVideoCall: ZegoInvitationType;
227
+ private hasJoinedRoom;
228
+ static generateKitTokenForTest(
229
+ appID: number,
230
+ serverSecret: string,
231
+ roomID: string,
232
+ userID: string,
233
+ userName?: string,
234
+ ExpirationSeconds?: number
235
+ ): string;
236
+ static generateKitTokenForProduction(
237
+ appID: number,
238
+ token: string,
239
+ roomID: string,
240
+ userID: string,
241
+ userName?: string
242
+ ): string;
243
+ static create(kitToken: string): ZegoUIKitPrebuilt;
244
+ addPlugins(plugins?: { ZegoSuperBoardManager?: any; ZIM?: any }): void;
245
+ joinRoom(roomConfig?: ZegoCloudRoomConfig): void;
246
+ destroy(): void;
247
+ setCallInvitationConfig(config?: ZegoCallInvitationConfig): void;
248
+ sendCallInvitation(params: {
249
+ callees: ZegoUser[];
250
+ callType: ZegoInvitationType;
251
+ timeout?: number;
252
+ data?: string;
253
+ notificationConfig?: ZegoSignalingPluginNotificationConfig;
254
+ }): Promise<{
255
+ errorInvitees: ZegoUser[];
256
+ }>;
44
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zegocloud/zego-uikit-prebuilt",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "zegocloud prebuilt meeting webrtc sdk",
5
5
  "keywords": [
6
6
  "sdk",
@@ -2102,7 +2102,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
2102
2102
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2103
2103
 
2104
2104
  "use strict";
2105
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZimManager\": function() { return /* binding */ ZimManager; }\n/* harmony export */ });\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../view/pages/ZegoCallInvitation/callInvitationControl */ \"./src/sdk/view/pages/ZegoCallInvitation/callInvitationControl.tsx\");\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};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\n\nvar ZimManager = /** @class */ (function () {\n function ZimManager(ZIM, expressConfig) {\n var _this = this;\n this.isLogin = false;\n this.isServiceActivated = true; //IM 服务是否开通\n this.callInfo = {};\n this.inSendOperation = false; //防止重复点击\n this.inRefuseOperation = false; //防止重复点击\n this.inAcceptOperation = false; //防止重复点击\n this.inCancelOperation = false; //防止重复点击\n this.config = {\n enableCustomCallInvitationWaitingPage: false,\n enableCustomCallInvitationDialog: false,\n enableNotifyWhenAppRunningInBackgroundOrQuit: false,\n };\n this.incomingTimer = null;\n this.outgoingTimer = null;\n this.notifyJoinRoomCallback = function () { };\n this.notifyLeaveRoomCallback = function (reason) { };\n this.onUpdateRoomIDCallback = function () { };\n // @ts-ignore\n this._zim = ZIM.create({ appID: expressConfig.appID }) || ZIM.getInstance();\n this.expressConfig = expressConfig;\n this.initListener();\n this._zim.login({ userID: expressConfig.userID, userName: expressConfig.userName }, expressConfig.token)\n .then(function () {\n // 登录成功\n console.warn(\"zim login success!!\");\n _this.isLogin = true;\n })\n .catch(function (err) {\n // 登录失败\n _this.isLogin = false;\n if (err.code === 6000014) {\n _this.isServiceActivated = false;\n }\n console.error(\"【ZEGOCLOUD】zim login failed !!\", err);\n });\n }\n ZimManager.prototype.initListener = function () {\n var _this = this;\n var _a;\n // 被邀请者收到邀请后的回调通知(被邀请者)\n this._zim.on(\"callInvitationReceived\", function (zim, _a) {\n var _b, _c, _d, _e;\n var callID = _a.callID, inviter = _a.inviter, timeout = _a.timeout, extendedData = _a.extendedData;\n console.warn(\"callInvitationReceived\", {\n callID: callID,\n inviter: inviter,\n timeout: timeout,\n extendedData: extendedData,\n });\n if (_this.callInfo.callID) {\n // 如果已被邀请,就拒绝其他的\n callID !== _this.callInfo.callID &&\n _this.refuseInvitation(\"busy\", callID);\n }\n else {\n var _f = JSON.parse(extendedData), inviter_name = _f.inviter_name, type = _f.type, data = _f.data;\n var _g = JSON.parse(data), call_id = _g.call_id, invitees = _g.invitees, custom_data = _g.custom_data;\n _this.callInfo = {\n callID: callID,\n invitees: invitees.map(function (i) { return ({\n userID: i.user_id,\n userName: i.user_name,\n }); }),\n inviter: {\n userID: inviter,\n userName: inviter_name,\n },\n acceptedInvitees: [],\n roomID: call_id,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n _this.onUpdateRoomIDCallback();\n // 设置来电计时器,当断网等收不到消息时以超时为由结束call\n if (_this.incomingTimer) {\n _this.clearIncomingTimer();\n }\n else {\n _this.incomingTimer = setTimeout(function () {\n if (_this.callInfo.callID) {\n _this.config.onIncomingCallTimeout &&\n _this.config.onIncomingCallTimeout(_this.callInfo.roomID, _this.callInfo.inviter);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n _this.clearIncomingTimer();\n }, (timeout + 1) * 1000);\n }\n if (!_this.config.enableCustomCallInvitationDialog) {\n // 展示默认UI\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogShow({ userID: inviter, userName: inviter_name }, function () {\n _this.clearIncomingTimer();\n _this.refuseInvitation(\"decline\");\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }, function () {\n _this.clearIncomingTimer();\n _this.acceptInvitation();\n _this.notifyJoinRoomCallback();\n }, (_c = (_b = _this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.incomingCallUrl);\n }\n // 透传接收到邀请回调\n if (_this.config.onIncomingCallReceived) {\n _this.config.onIncomingCallReceived(_this.callInfo.roomID, _this.callInfo.inviter, _this.callInfo.type, _this.callInfo.invitees);\n }\n // 对外再包一层,不暴露内部逻辑\n var refuse_1 = function (data) {\n _this.clearIncomingTimer();\n _this.refuseInvitation(\"decline\", \"\", data);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n };\n var accept_1 = function (data) {\n _this.clearIncomingTimer();\n _this.acceptInvitation(data);\n };\n (_e = (_d = _this.config) === null || _d === void 0 ? void 0 : _d.onConfirmDialogWhenReceiving) === null || _e === void 0 ? void 0 : _e.call(_d, type, { userID: inviter, userName: inviter_name }, function (data) {\n refuse_1(data);\n }, function (data) {\n accept_1(data);\n }, custom_data);\n }\n });\n // 被邀请者收到邀请被取消后的回调通知(被邀请者)\n this._zim.on(\"callInvitationCancelled\", function (zim, _a) {\n var callID = _a.callID, inviter = _a.inviter, extendedData = _a.extendedData;\n console.warn(\"callInvitationCancelled\", {\n callID: callID,\n inviter: inviter,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n // 透传取消呼叫事件\n if (_this.config.onIncomingCallCanceled) {\n _this.config.onIncomingCallCanceled(_this.callInfo.roomID, _this.callInfo.inviter);\n }\n _this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled);\n });\n // 邀请者的邀请被接受后的回调通知(邀请者)\n this._zim.on(\"callInvitationAccepted\", function (zim, _a) {\n var callID = _a.callID, invitee = _a.invitee, extendedData = _a.extendedData;\n console.warn(\"callInvitationAccepted\", {\n callID: callID,\n invitee: invitee,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n _this.clearOutgoingTimer();\n _this.callInfo.acceptedInvitees.push({\n userID: invitee,\n userName: \"\",\n });\n if (!_this.callInfo.isGroupCall) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n _this.notifyJoinRoomCallback();\n }\n // 透传接受邀请事件\n if (_this.config.onOutgoingCallAccepted) {\n var callee = _this.callInfo.invitees.find(function (i) { return i.userID === invitee; }) || { userID: invitee };\n _this.config.onOutgoingCallAccepted(_this.callInfo.roomID, callee);\n }\n });\n // 邀请者的邀请被拒绝后的回调通知(邀请者)\n this._zim.on(\"callInvitationRejected\", function (zim, _a) {\n var callID = _a.callID, invitee = _a.invitee, extendedData = _a.extendedData;\n console.warn(\"callInvitationRejected\", {\n callID: callID,\n invitee: invitee,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n var reason;\n if (extendedData.length) {\n var data = JSON.parse(extendedData);\n reason = data.reason;\n }\n // 透传拒绝事件\n var callee = _this.callInfo.invitees.find(function (i) { return i.userID === invitee; }) || { userID: invitee };\n if (reason === \"busy\") {\n _this.config.onOutgoingCallRejected &&\n _this.config.onOutgoingCallRejected(_this.callInfo.roomID, callee);\n }\n else {\n _this.config.onOutgoingCallDeclined &&\n _this.config.onOutgoingCallDeclined(_this.callInfo.roomID, callee);\n }\n if (!_this.callInfo.isGroupCall) {\n // 单人邀请,隐藏waitingPage,清除callInfo\n _this.clearOutgoingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n _this.endCall(reason === \"busy\"\n ? _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Busy\n : _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n else {\n // 多人邀请,\n // 移除拒绝者\n _this.callInfo.invitees = _this.callInfo.invitees.filter(function (i) { return i.userID !== invitee; });\n if (_this.callInfo.invitees.length === 0) {\n // 全部拒绝后需要退出房间\n _this.clearOutgoingTimer();\n _this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n }\n });\n //被邀请者响应超时后,“邀请者”收到的回调通知, 超时时间单位:秒(邀请者)\n this._zim.on(\"callInviteesAnsweredTimeout\", function (zim, _a) {\n var callID = _a.callID, invitees = _a.invitees;\n console.warn(\"callInviteesAnsweredTimeout\", { callID: callID, invitees: invitees });\n if (!_this.callInfo.callID)\n return;\n _this.clearOutgoingTimer();\n // 透传超时事件\n if (_this.config.onOutgoingCallTimeout) {\n var callees = invitees.map(function (i) {\n return (_this.callInfo.invitees.find(function (u) { return u.userID === i; }) || {\n userID: i,\n });\n });\n _this.config.onOutgoingCallTimeout(_this.callInfo.roomID, callees);\n }\n _this.answeredTimeoutCallback(invitees);\n });\n //被邀请者响应超时后,“被邀请者”收到的回调通知, 超时时间单位:秒 (被邀请者)\n this._zim.on(\"callInvitationTimeout\", function (zim, _a) {\n var callID = _a.callID;\n console.warn(\"callInvitationTimeout\", { callID: callID });\n if (!_this.callInfo.callID)\n return;\n // 透传超时事件\n if (_this.config.onIncomingCallTimeout) {\n _this.config.onIncomingCallTimeout(_this.callInfo.roomID, _this.callInfo.inviter);\n }\n _this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n });\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.on(\"connectionStateChanged\", function (zim, data) {\n console.warn(\"【zim】connectionStateChanged\", data);\n });\n };\n ZimManager.prototype.answeredTimeoutCallback = function (invitees) {\n if (!this.callInfo.callID)\n return;\n if (this.callInfo.isGroupCall) {\n // 多人邀请\n this.callInfo.invitees = this.callInfo.invitees.filter(function (i) { return !invitees.find(function (u) { return u === i.userID; }); });\n if (this.callInfo.invitees.length === 0) {\n // 全部超时就退出房间,结束邀请\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n else {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n };\n ZimManager.prototype.sendInvitation = function (invitees, type, timeout, data, notificationConfig) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function () {\n var inviteesID, roomID, _data, extendedData, config, pushConfig, res_1, errorInvitees, onlineInvitee_1, cancel_1, error_1;\n var _this = this;\n return __generator(this, function (_f) {\n switch (_f.label) {\n case 0:\n if (this.callInfo.callID)\n return [2 /*return*/, Promise.reject(\"You already have a call invitation!\")];\n if (!this.isServiceActivated)\n return [2 /*return*/, Promise.reject(\"The call invitation service has not been activated.\")];\n if (this.inSendOperation)\n return [2 /*return*/, Promise.reject(\"send invitation repeat !!\")];\n this.inSendOperation = true;\n inviteesID = invitees.map(function (i) { return i.userID; });\n roomID = \"call_\".concat(this.expressConfig.userID, \"_\").concat(new Date().getTime());\n _data = JSON.stringify({\n call_id: roomID,\n invitees: invitees.map(function (u) { return ({\n user_id: u.userID,\n user_name: u.userName,\n }); }),\n custom_data: data,\n });\n extendedData = JSON.stringify({\n inviter_name: this.expressConfig.userName,\n type: type,\n data: _data,\n });\n config = {\n timeout: timeout,\n extendedData: extendedData,\n };\n // 发送离线消息\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n pushConfig = {\n title: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.title) || this.expressConfig.userName,\n content: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.message) ||\n \"Incoming \".concat(invitees.length > 1 ? \"group \" : \"\").concat(type === 0 ? \"voice\" : \"video\", \" call...\"),\n payload: extendedData,\n resourcesID: (_a = notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.resourcesID) !== null && _a !== void 0 ? _a : \"zegouikit_call\",\n };\n config.pushConfig = pushConfig;\n }\n _f.label = 1;\n case 1:\n _f.trys.push([1, 3, , 4]);\n this.callInfo.callID = new Date().getTime().toString(); //临时生成个id,防止同时呼叫情况\n return [4 /*yield*/, this._zim.callInvite(inviteesID, config)];\n case 2:\n res_1 = _f.sent();\n errorInvitees = res_1.errorInvitees.map(function (i) {\n return invitees.find(function (u) { return u.userID === i.userID; });\n });\n if (res_1.errorInvitees.length >= invitees.length) {\n // 全部邀请失败,中断流程\n this.inSendOperation = false;\n this.clearCallInfo();\n return [2 /*return*/, Promise.resolve({ errorInvitees: errorInvitees })];\n }\n onlineInvitee_1 = invitees.filter(function (i) { return !res_1.errorInvitees.find(function (e) { return e.userID === i.userID; }); });\n // 保存邀请信息,进入busy状态\n this.callInfo = {\n callID: res_1.callID,\n invitees: onlineInvitee_1,\n inviter: {\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n },\n acceptedInvitees: [],\n roomID: roomID,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 添加定时器,断网等情况导致收不到消息时,当超时处理\n this.outgoingTimer = setTimeout(function () {\n if (_this.callInfo.callID) {\n // 透传超时事件\n _this.config.onOutgoingCallTimeout &&\n _this.config.onOutgoingCallTimeout(_this.callInfo.roomID, _this.callInfo.invitees);\n // 当超时后,没有一个人接受邀请,则主动退出房间\n !_this.callInfo.acceptedInvitees.length &&\n _this.answeredTimeoutCallback(onlineInvitee_1.map(function (u) { return u.userID; }));\n }\n _this.clearOutgoingTimer();\n }, (timeout + 1) * 1000);\n if (invitees.length > 1) {\n // 多人邀请,直接进房\n this.notifyJoinRoomCallback();\n }\n else {\n // 单人邀请,进入等待页\n if (!this.config.enableCustomCallInvitationWaitingPage) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageShow(invitees[0], type, function () {\n _this.cancelInvitation();\n }, (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.outgoingCallUrl);\n }\n cancel_1 = function () {\n _this.cancelInvitation();\n };\n (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.onWaitingPageWhenSending) === null || _e === void 0 ? void 0 : _e.call(_d, this.callInfo.type, invitees, function () {\n cancel_1();\n });\n }\n this.inSendOperation = false;\n return [2 /*return*/, Promise.resolve({ errorInvitees: errorInvitees })];\n case 3:\n error_1 = _f.sent();\n this.clearCallInfo();\n this.inSendOperation = false;\n return [2 /*return*/, Promise.reject(JSON.stringify(error_1))];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.cancelInvitation = function (data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var invitees, extendedData, error_2;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inCancelOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inCancelOperation = true;\n this.clearOutgoingTimer();\n invitees = this.callInfo.invitees.map(function (i) { return i.userID; });\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callCancel(invitees, this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.clearCallInfo();\n return [3 /*break*/, 4];\n case 3:\n error_2 = _b.sent();\n console.error(\"【ZEGOCLOUD】cancelInvitation\", error_2);\n return [3 /*break*/, 4];\n case 4:\n this.inCancelOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.refuseInvitation = function (reason, callID, data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var extendedData, error_3;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inRefuseOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inRefuseOperation = true;\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n if (reason) {\n extendedData.reason = reason;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callReject(callID || this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n return [3 /*break*/, 4];\n case 3:\n error_3 = _b.sent();\n console.error(\"【ZEGOCLOUD】refuseInvitation\", error_3);\n return [3 /*break*/, 4];\n case 4:\n this.inRefuseOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.acceptInvitation = function (data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var extendedData, error_4;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inAcceptOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inAcceptOperation = true;\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callAccept(this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n return [3 /*break*/, 4];\n case 3:\n error_4 = _b.sent();\n console.error(\"【ZEGOCLOUD】acceptInvitation\", error_4);\n return [3 /*break*/, 4];\n case 4:\n this.inAcceptOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.clearCallInfo = function () {\n this.callInfo = {};\n };\n ZimManager.prototype.destroy = function () {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.destroy();\n this._zim = null;\n };\n /** 通知UI层调用joinRoom */\n ZimManager.prototype.notifyJoinRoom = function (func) {\n var _this = this;\n func &&\n (this.notifyJoinRoomCallback = function () {\n var _a, _b;\n // 接收客户传递进来的roomConfig\n var roomConfig = ((_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.onSetRoomConfigBeforeJoining) === null || _b === void 0 ? void 0 : _b.call(_a, _this.callInfo.type)) || {};\n func(_this.callInfo.type, roomConfig, _this.callInfo.isGroupCall\n ? _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.GroupCall\n : _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.OneONoneCall);\n });\n };\n /** 通知UI层调用leaveRoom */\n ZimManager.prototype.notifyLeaveRoom = function (func) {\n var _this = this;\n this.notifyLeaveRoomCallback = function (reason) {\n func && func();\n _this.endCall(reason);\n };\n };\n /**收到邀请后需要更新roomID*/\n ZimManager.prototype.onUpdateRoomID = function (func) {\n var _this = this;\n func &&\n (this.onUpdateRoomIDCallback = function () {\n func(_this.callInfo.roomID);\n _this.expressConfig.roomID = _this.callInfo.roomID;\n });\n };\n /**结束 call,清除 callInfo */\n ZimManager.prototype.endCall = function (reason) {\n var _a, _b;\n if (reason === _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.LeaveRoom &&\n !this.callInfo.acceptedInvitees.length &&\n this.callInfo.inviter.userID === this.expressConfig.userID) {\n // 主叫人如果在所有人接收邀请前离开房间,则取消所有人的邀请\n this.cancelInvitation();\n }\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, reason, \"\");\n this.clearCallInfo();\n };\n ZimManager.prototype.setCallInvitationConfig = function (config) {\n this.config = Object.assign(this.config, config);\n };\n ZimManager.prototype.clearOutgoingTimer = function () {\n if (this.outgoingTimer) {\n clearTimeout(this.outgoingTimer);\n this.outgoingTimer = null;\n }\n };\n ZimManager.prototype.clearIncomingTimer = function () {\n if (this.incomingTimer) {\n clearTimeout(this.incomingTimer);\n this.incomingTimer = null;\n }\n };\n return ZimManager;\n}());\n\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/ZimManager.ts?");
2105
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ZimManager\": function() { return /* binding */ ZimManager; }\n/* harmony export */ });\n/* harmony import */ var _model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../model */ \"./src/sdk/model/index.ts\");\n/* harmony import */ var _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../view/pages/ZegoCallInvitation/callInvitationControl */ \"./src/sdk/view/pages/ZegoCallInvitation/callInvitationControl.tsx\");\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};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\n\nvar ZimManager = /** @class */ (function () {\n function ZimManager(ZIM, expressConfig) {\n var _this = this;\n this.isLogin = false;\n this.isServiceActivated = true; //IM 服务是否开通\n this.callInfo = {};\n this.inSendOperation = false; //防止重复点击\n this.inRefuseOperation = false; //防止重复点击\n this.inAcceptOperation = false; //防止重复点击\n this.inCancelOperation = false; //防止重复点击\n this.config = {\n enableCustomCallInvitationWaitingPage: false,\n enableCustomCallInvitationDialog: false,\n enableNotifyWhenAppRunningInBackgroundOrQuit: false,\n };\n this.incomingTimer = null;\n this.outgoingTimer = null;\n this.notifyJoinRoomCallback = function () { };\n this.notifyLeaveRoomCallback = function (reason) { };\n this.onUpdateRoomIDCallback = function () { };\n // @ts-ignore\n this._zim = ZIM.create({ appID: expressConfig.appID }) || ZIM.getInstance();\n this.expressConfig = expressConfig;\n this.initListener();\n this._zim.login({ userID: expressConfig.userID, userName: expressConfig.userName }, expressConfig.token)\n .then(function () {\n // 登录成功\n console.warn(\"zim login success!!\");\n _this.isLogin = true;\n })\n .catch(function (err) {\n // 登录失败\n _this.isLogin = false;\n if (err.code === 6000014) {\n _this.isServiceActivated = false;\n }\n console.error(\"【ZEGOCLOUD】zim login failed !!\", err);\n });\n }\n ZimManager.prototype.initListener = function () {\n var _this = this;\n var _a;\n // 被邀请者收到邀请后的回调通知(被邀请者)\n this._zim.on(\"callInvitationReceived\", function (zim, _a) {\n var _b, _c, _d, _e;\n var callID = _a.callID, inviter = _a.inviter, timeout = _a.timeout, extendedData = _a.extendedData;\n console.warn(\"callInvitationReceived\", {\n callID: callID,\n inviter: inviter,\n timeout: timeout,\n extendedData: extendedData,\n });\n if (_this.callInfo.callID) {\n // 如果已被邀请,就拒绝其他的\n callID !== _this.callInfo.callID &&\n _this.refuseInvitation(\"busy\", callID);\n }\n else {\n var _f = JSON.parse(extendedData), inviter_name = _f.inviter_name, type = _f.type, data = _f.data;\n var _g = JSON.parse(data), call_id = _g.call_id, invitees = _g.invitees, custom_data = _g.custom_data;\n _this.callInfo = {\n callID: callID,\n invitees: invitees.map(function (i) { return ({\n userID: i.user_id,\n userName: i.user_name,\n }); }),\n inviter: {\n userID: inviter,\n userName: inviter_name,\n },\n acceptedInvitees: [],\n roomID: call_id,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n _this.onUpdateRoomIDCallback();\n // 设置来电计时器,当断网等收不到消息时以超时为由结束call\n if (_this.incomingTimer) {\n _this.clearIncomingTimer();\n }\n else {\n _this.incomingTimer = setTimeout(function () {\n if (_this.callInfo.callID) {\n _this.config.onIncomingCallTimeout &&\n _this.config.onIncomingCallTimeout(_this.callInfo.roomID, _this.callInfo.inviter);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n _this.clearIncomingTimer();\n }, (timeout + 1) * 1000);\n }\n if (!_this.config.enableCustomCallInvitationDialog) {\n // 展示默认UI\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogShow({ userID: inviter, userName: inviter_name }, function () {\n _this.clearIncomingTimer();\n _this.refuseInvitation(\"decline\");\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }, function () {\n _this.clearIncomingTimer();\n _this.acceptInvitation();\n _this.notifyJoinRoomCallback();\n }, (_c = (_b = _this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.incomingCallUrl);\n }\n // 透传接收到邀请回调\n if (_this.config.onIncomingCallReceived) {\n _this.config.onIncomingCallReceived(_this.callInfo.roomID, _this.callInfo.inviter, _this.callInfo.type, _this.callInfo.invitees);\n }\n // 对外再包一层,不暴露内部逻辑\n var refuse_1 = function (data) {\n _this.clearIncomingTimer();\n _this.refuseInvitation(\"decline\", \"\", data);\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n };\n var accept_1 = function (data) {\n _this.clearIncomingTimer();\n _this.acceptInvitation(data);\n _this.notifyJoinRoomCallback();\n };\n (_e = (_d = _this.config) === null || _d === void 0 ? void 0 : _d.onConfirmDialogWhenReceiving) === null || _e === void 0 ? void 0 : _e.call(_d, type, { userID: inviter, userName: inviter_name }, function (data) {\n refuse_1(data);\n }, function (data) {\n accept_1(data);\n }, custom_data);\n }\n });\n // 被邀请者收到邀请被取消后的回调通知(被邀请者)\n this._zim.on(\"callInvitationCancelled\", function (zim, _a) {\n var callID = _a.callID, inviter = _a.inviter, extendedData = _a.extendedData;\n console.warn(\"callInvitationCancelled\", {\n callID: callID,\n inviter: inviter,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n // 透传取消呼叫事件\n if (_this.config.onIncomingCallCanceled) {\n _this.config.onIncomingCallCanceled(_this.callInfo.roomID, _this.callInfo.inviter);\n }\n _this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled);\n });\n // 邀请者的邀请被接受后的回调通知(邀请者)\n this._zim.on(\"callInvitationAccepted\", function (zim, _a) {\n var callID = _a.callID, invitee = _a.invitee, extendedData = _a.extendedData;\n console.warn(\"callInvitationAccepted\", {\n callID: callID,\n invitee: invitee,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n _this.clearOutgoingTimer();\n _this.callInfo.acceptedInvitees.push({\n userID: invitee,\n userName: \"\",\n });\n if (!_this.callInfo.isGroupCall) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n _this.notifyJoinRoomCallback();\n }\n // 透传接受邀请事件\n if (_this.config.onOutgoingCallAccepted) {\n var callee = _this.callInfo.invitees.find(function (i) { return i.userID === invitee; }) || { userID: invitee };\n _this.config.onOutgoingCallAccepted(_this.callInfo.roomID, callee);\n }\n });\n // 邀请者的邀请被拒绝后的回调通知(邀请者)\n this._zim.on(\"callInvitationRejected\", function (zim, _a) {\n var callID = _a.callID, invitee = _a.invitee, extendedData = _a.extendedData;\n console.warn(\"callInvitationRejected\", {\n callID: callID,\n invitee: invitee,\n extendedData: extendedData,\n });\n if (!_this.callInfo.callID)\n return;\n var reason;\n if (extendedData.length) {\n var data = JSON.parse(extendedData);\n reason = data.reason;\n }\n // 透传拒绝事件\n var callee = _this.callInfo.invitees.find(function (i) { return i.userID === invitee; }) || { userID: invitee };\n if (reason === \"busy\") {\n _this.config.onOutgoingCallRejected &&\n _this.config.onOutgoingCallRejected(_this.callInfo.roomID, callee);\n }\n else {\n _this.config.onOutgoingCallDeclined &&\n _this.config.onOutgoingCallDeclined(_this.callInfo.roomID, callee);\n }\n if (!_this.callInfo.isGroupCall) {\n // 单人邀请,隐藏waitingPage,清除callInfo\n _this.clearOutgoingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n _this.endCall(reason === \"busy\"\n ? _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Busy\n : _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n else {\n // 多人邀请,\n // 移除拒绝者\n _this.callInfo.invitees = _this.callInfo.invitees.filter(function (i) { return i.userID !== invitee; });\n if (_this.callInfo.invitees.length === 0) {\n // 全部拒绝后需要退出房间\n _this.clearOutgoingTimer();\n _this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Declined);\n }\n }\n });\n //被邀请者响应超时后,“邀请者”收到的回调通知, 超时时间单位:秒(邀请者)\n this._zim.on(\"callInviteesAnsweredTimeout\", function (zim, _a) {\n var callID = _a.callID, invitees = _a.invitees;\n console.warn(\"callInviteesAnsweredTimeout\", { callID: callID, invitees: invitees });\n if (!_this.callInfo.callID)\n return;\n _this.clearOutgoingTimer();\n // 透传超时事件\n if (_this.config.onOutgoingCallTimeout) {\n var callees = invitees.map(function (i) {\n return (_this.callInfo.invitees.find(function (u) { return u.userID === i; }) || {\n userID: i,\n });\n });\n _this.config.onOutgoingCallTimeout(_this.callInfo.roomID, callees);\n }\n _this.answeredTimeoutCallback(invitees);\n });\n //被邀请者响应超时后,“被邀请者”收到的回调通知, 超时时间单位:秒 (被邀请者)\n this._zim.on(\"callInvitationTimeout\", function (zim, _a) {\n var callID = _a.callID;\n console.warn(\"callInvitationTimeout\", { callID: callID });\n if (!_this.callInfo.callID)\n return;\n // 透传超时事件\n if (_this.config.onIncomingCallTimeout) {\n _this.config.onIncomingCallTimeout(_this.callInfo.roomID, _this.callInfo.inviter);\n }\n _this.clearIncomingTimer();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n _this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n });\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.on(\"connectionStateChanged\", function (zim, data) {\n console.warn(\"【zim】connectionStateChanged\", data);\n });\n };\n ZimManager.prototype.answeredTimeoutCallback = function (invitees) {\n if (!this.callInfo.callID)\n return;\n if (this.callInfo.isGroupCall) {\n // 多人邀请\n this.callInfo.invitees = this.callInfo.invitees.filter(function (i) { return !invitees.find(function (u) { return u === i.userID; }); });\n if (this.callInfo.invitees.length === 0) {\n // 全部超时就退出房间,结束邀请\n this.notifyLeaveRoomCallback(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n }\n else {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.endCall(_model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Timeout);\n }\n };\n ZimManager.prototype.sendInvitation = function (invitees, type, timeout, data, notificationConfig) {\n var _a, _b, _c, _d, _e;\n return __awaiter(this, void 0, void 0, function () {\n var inviteesID, roomID, _data, extendedData, config, pushConfig, res_1, errorInvitees, onlineInvitee_1, cancel_1, error_1;\n var _this = this;\n return __generator(this, function (_f) {\n switch (_f.label) {\n case 0:\n if (this.callInfo.callID)\n return [2 /*return*/, Promise.reject(\"You already have a call invitation!\")];\n if (!this.isServiceActivated)\n return [2 /*return*/, Promise.reject(\"The call invitation service has not been activated.\")];\n if (this.inSendOperation)\n return [2 /*return*/, Promise.reject(\"send invitation repeat !!\")];\n this.inSendOperation = true;\n inviteesID = invitees.map(function (i) { return i.userID; });\n roomID = \"call_\".concat(this.expressConfig.userID, \"_\").concat(new Date().getTime());\n _data = JSON.stringify({\n call_id: roomID,\n invitees: invitees.map(function (u) { return ({\n user_id: u.userID,\n user_name: u.userName,\n }); }),\n custom_data: data,\n });\n extendedData = JSON.stringify({\n inviter_name: this.expressConfig.userName,\n type: type,\n data: _data,\n });\n config = {\n timeout: timeout,\n extendedData: extendedData,\n };\n // 发送离线消息\n if (this.config.enableNotifyWhenAppRunningInBackgroundOrQuit) {\n pushConfig = {\n title: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.title) || this.expressConfig.userName,\n content: (notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.message) ||\n \"Incoming \".concat(invitees.length > 1 ? \"group \" : \"\").concat(type === 0 ? \"voice\" : \"video\", \" call...\"),\n payload: extendedData,\n resourcesID: (_a = notificationConfig === null || notificationConfig === void 0 ? void 0 : notificationConfig.resourcesID) !== null && _a !== void 0 ? _a : \"zegouikit_call\",\n };\n config.pushConfig = pushConfig;\n }\n _f.label = 1;\n case 1:\n _f.trys.push([1, 3, , 4]);\n this.callInfo.callID = new Date().getTime().toString(); //临时生成个id,防止同时呼叫情况\n return [4 /*yield*/, this._zim.callInvite(inviteesID, config)];\n case 2:\n res_1 = _f.sent();\n errorInvitees = res_1.errorInvitees.map(function (i) {\n return invitees.find(function (u) { return u.userID === i.userID; });\n });\n if (res_1.errorInvitees.length >= invitees.length) {\n // 全部邀请失败,中断流程\n this.inSendOperation = false;\n this.clearCallInfo();\n return [2 /*return*/, Promise.resolve({ errorInvitees: errorInvitees })];\n }\n onlineInvitee_1 = invitees.filter(function (i) { return !res_1.errorInvitees.find(function (e) { return e.userID === i.userID; }); });\n // 保存邀请信息,进入busy状态\n this.callInfo = {\n callID: res_1.callID,\n invitees: onlineInvitee_1,\n inviter: {\n userID: this.expressConfig.userID,\n userName: this.expressConfig.userName,\n },\n acceptedInvitees: [],\n roomID: roomID,\n type: type,\n isGroupCall: invitees.length > 1,\n };\n this.onUpdateRoomIDCallback();\n // 添加定时器,断网等情况导致收不到消息时,当超时处理\n this.outgoingTimer = setTimeout(function () {\n if (_this.callInfo.callID) {\n // 透传超时事件\n _this.config.onOutgoingCallTimeout &&\n _this.config.onOutgoingCallTimeout(_this.callInfo.roomID, _this.callInfo.invitees);\n // 当超时后,没有一个人接受邀请,则主动退出房间\n !_this.callInfo.acceptedInvitees.length &&\n _this.answeredTimeoutCallback(onlineInvitee_1.map(function (u) { return u.userID; }));\n }\n _this.clearOutgoingTimer();\n }, (timeout + 1) * 1000);\n if (invitees.length > 1) {\n // 多人邀请,直接进房\n this.notifyJoinRoomCallback();\n }\n else {\n // 单人邀请,进入等待页\n if (!this.config.enableCustomCallInvitationWaitingPage) {\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageShow(invitees[0], type, function () {\n var _a, _b;\n _this.cancelInvitation();\n (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n }, (_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.ringtoneConfig) === null || _c === void 0 ? void 0 : _c.outgoingCallUrl);\n }\n cancel_1 = function () {\n var _a, _b;\n _this.cancelInvitation();\n (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.Canceled, \"\");\n };\n (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.onWaitingPageWhenSending) === null || _e === void 0 ? void 0 : _e.call(_d, this.callInfo.type, invitees, function () {\n cancel_1();\n });\n }\n this.inSendOperation = false;\n return [2 /*return*/, Promise.resolve({ errorInvitees: errorInvitees })];\n case 3:\n error_1 = _f.sent();\n this.clearCallInfo();\n this.inSendOperation = false;\n return [2 /*return*/, Promise.reject(JSON.stringify(error_1))];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.cancelInvitation = function (data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var invitees, extendedData, error_2;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inCancelOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inCancelOperation = true;\n this.clearOutgoingTimer();\n invitees = this.callInfo.invitees.map(function (i) { return i.userID; });\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callCancel(invitees, this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationWaitingPageHide();\n this.clearCallInfo();\n return [3 /*break*/, 4];\n case 3:\n error_2 = _b.sent();\n console.error(\"【ZEGOCLOUD】cancelInvitation\", error_2);\n return [3 /*break*/, 4];\n case 4:\n this.inCancelOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.refuseInvitation = function (reason, callID, data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var extendedData, error_3;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inRefuseOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inRefuseOperation = true;\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n if (reason) {\n extendedData.reason = reason;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callReject(callID || this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n return [3 /*break*/, 4];\n case 3:\n error_3 = _b.sent();\n console.error(\"【ZEGOCLOUD】refuseInvitation\", error_3);\n return [3 /*break*/, 4];\n case 4:\n this.inRefuseOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.acceptInvitation = function (data) {\n var _a;\n return __awaiter(this, void 0, void 0, function () {\n var extendedData, error_4;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n if (this.inAcceptOperation)\n return [2 /*return*/];\n if (!this.callInfo.callID)\n return [2 /*return*/];\n this.inAcceptOperation = true;\n extendedData = {};\n if (data) {\n extendedData.custom_data = data;\n }\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, ((_a = this._zim) === null || _a === void 0 ? void 0 : _a.callAccept(this.callInfo.callID, {\n extendedData: JSON.stringify(extendedData),\n }))];\n case 2:\n _b.sent();\n _view_pages_ZegoCallInvitation_callInvitationControl__WEBPACK_IMPORTED_MODULE_1__.callInvitationControl.callInvitationDialogHide();\n return [3 /*break*/, 4];\n case 3:\n error_4 = _b.sent();\n console.error(\"【ZEGOCLOUD】acceptInvitation\", error_4);\n return [3 /*break*/, 4];\n case 4:\n this.inAcceptOperation = false;\n return [2 /*return*/];\n }\n });\n });\n };\n ZimManager.prototype.clearCallInfo = function () {\n this.callInfo = {};\n };\n ZimManager.prototype.destroy = function () {\n var _a;\n (_a = this._zim) === null || _a === void 0 ? void 0 : _a.destroy();\n this._zim = null;\n };\n /** 通知UI层调用joinRoom */\n ZimManager.prototype.notifyJoinRoom = function (func) {\n var _this = this;\n func &&\n (this.notifyJoinRoomCallback = function () {\n var _a, _b;\n // 接收客户传递进来的roomConfig\n var roomConfig = ((_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.onSetRoomConfigBeforeJoining) === null || _b === void 0 ? void 0 : _b.call(_a, _this.callInfo.type)) || {};\n func(_this.callInfo.type, roomConfig, _this.callInfo.isGroupCall\n ? _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.GroupCall\n : _model__WEBPACK_IMPORTED_MODULE_0__.ScenarioModel.OneONoneCall);\n });\n };\n /** 通知UI层调用leaveRoom */\n ZimManager.prototype.notifyLeaveRoom = function (func) {\n var _this = this;\n this.notifyLeaveRoomCallback = function (reason) {\n func && func();\n _this.endCall(reason);\n };\n };\n /**收到邀请后需要更新roomID*/\n ZimManager.prototype.onUpdateRoomID = function (func) {\n var _this = this;\n func &&\n (this.onUpdateRoomIDCallback = function () {\n func(_this.callInfo.roomID);\n _this.expressConfig.roomID = _this.callInfo.roomID;\n });\n };\n /**结束 call,清除 callInfo */\n ZimManager.prototype.endCall = function (reason) {\n var _a, _b;\n if (reason === _model__WEBPACK_IMPORTED_MODULE_0__.CallInvitationEndReason.LeaveRoom &&\n !this.callInfo.acceptedInvitees.length &&\n this.callInfo.inviter.userID === this.expressConfig.userID) {\n // 主叫人如果在所有人接收邀请前离开房间,则取消所有人的邀请\n this.cancelInvitation();\n }\n (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.onCallInvitationEnded) === null || _b === void 0 ? void 0 : _b.call(_a, reason, \"\");\n this.clearCallInfo();\n };\n ZimManager.prototype.setCallInvitationConfig = function (config) {\n this.config = Object.assign(this.config, config);\n };\n ZimManager.prototype.clearOutgoingTimer = function () {\n if (this.outgoingTimer) {\n clearTimeout(this.outgoingTimer);\n this.outgoingTimer = null;\n }\n };\n ZimManager.prototype.clearIncomingTimer = function () {\n if (this.incomingTimer) {\n clearTimeout(this.incomingTimer);\n this.incomingTimer = null;\n }\n };\n return ZimManager;\n}());\n\n\n\n//# sourceURL=webpack://zegocloud_client_sdk_web/./src/sdk/modules/tools/ZimManager.ts?");
2106
2106
 
2107
2107
  /***/ }),
2108
2108
 
@@ -1,50 +0,0 @@
1
- export declare class FingerGestureUtils {
2
- isPointerdown: boolean;
3
- pointers: PointerEvent[];
4
- point1: {
5
- x: number;
6
- y: number;
7
- };
8
- point2: {
9
- x: number;
10
- y: number;
11
- };
12
- diff: {
13
- x: number;
14
- y: number;
15
- };
16
- lastPointermove: {
17
- x: number;
18
- y: number;
19
- };
20
- lastPoint1: {
21
- x: number;
22
- y: number;
23
- };
24
- lastPoint2: {
25
- x: number;
26
- y: number;
27
- };
28
- lastCenter: {
29
- x: number;
30
- y: number;
31
- };
32
- dom: HTMLElement;
33
- x: number;
34
- y: number;
35
- scale: number;
36
- maxScale: number;
37
- minScale: number;
38
- private callBack;
39
- addDomListener(dom: HTMLElement, callBack: (x: number, y: number, scale: number) => void): void;
40
- private pointerDown;
41
- private pointerMove;
42
- private pointerUp;
43
- private pointerCancel;
44
- /**
45
- * 更新或删除指针
46
- * @param {PointerEvent} e
47
- * @param {string} type
48
- */
49
- handlePointers(e: PointerEvent, type: "update" | "delete"): void;
50
- }