@trtc/calls-uikit-react 4.1.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/README-zh_CN.md +97 -0
- package/README.md +104 -0
- package/debug/GenerateTestUserSig-es.js +26 -0
- package/debug/lib-generate-test-usersig-es.min.js +2 -0
- package/package.json +42 -0
- package/src/Components/TUICallKit/TUICallKit.module.scss +21 -0
- package/src/Components/TUICallKit/TUICallKit.tsx +267 -0
- package/src/Components/TUICallKit/index.ts +3 -0
- package/src/Components/assets/base/close.svg +1 -0
- package/src/Components/assets/base/error.svg +1 -0
- package/src/Components/assets/base/info.svg +1 -0
- package/src/Components/assets/base/loading-circle.svg +1 -0
- package/src/Components/assets/base/success.svg +1 -0
- package/src/Components/assets/base/waring.svg +1 -0
- package/src/Components/assets/button/accept.svg +10 -0
- package/src/Components/assets/button/backgroundBlurClose.svg +3 -0
- package/src/Components/assets/button/backgroundBlurOpen.svg +3 -0
- package/src/Components/assets/button/camera-close.svg +8 -0
- package/src/Components/assets/button/camera-open.svg +3 -0
- package/src/Components/assets/button/desktop/arrow.png +0 -0
- package/src/Components/assets/button/desktop/fullScreen.svg +4 -0
- package/src/Components/assets/button/desktop/minimize.svg +6 -0
- package/src/Components/assets/button/hangup.svg +3 -0
- package/src/Components/assets/button/microphone-close.svg +4 -0
- package/src/Components/assets/button/microphone-open.svg +4 -0
- package/src/Components/assets/button/mobile/down.svg +4 -0
- package/src/Components/assets/button/mobile/minimize.svg +4 -0
- package/src/Components/assets/button/mobile/switch-camera.svg +3 -0
- package/src/Components/assets/button/mobile/up.svg +4 -0
- package/src/Components/assets/button/speaker-close.svg +4 -0
- package/src/Components/assets/button/speaker-open.svg +3 -0
- package/src/Components/assets/button/switch-audio.svg +3 -0
- package/src/Components/assets/callMessage/audioCall.svg +3 -0
- package/src/Components/assets/callMessage/videoCall.svg +3 -0
- package/src/Components/assets/common/defaultAvatar.svg +11 -0
- package/src/Components/assets/common/microphone-volumn-close.svg +9 -0
- package/src/Components/assets/floatingWindow/desktop/floatCallEnd.svg +3 -0
- package/src/Components/assets/floatingWindow/desktop/floatFullScreen.svg +3 -0
- package/src/Components/assets/floatingWindow/desktop/floatMicrophone.svg +4 -0
- package/src/Components/assets/floatingWindow/desktop/floatMicrophoneClosed.svg +3 -0
- package/src/Components/assets/floatingWindow/mobile/camera-close.svg +14 -0
- package/src/Components/assets/floatingWindow/mobile/camera-open.svg +14 -0
- package/src/Components/assets/floatingWindow/mobile/earphone.svg +3 -0
- package/src/Components/assets/floatingWindow/mobile/microphone-close.svg +4 -0
- package/src/Components/assets/floatingWindow/mobile/microphone-open.svg +4 -0
- package/src/Components/assets/permission/desktop/index.ts +11 -0
- package/src/Components/assets/permission/desktop/mac/permit-en.jpg +0 -0
- package/src/Components/assets/permission/desktop/mac/permit-zh.jpg +0 -0
- package/src/Components/assets/permission/desktop/win/permit-en.png +0 -0
- package/src/Components/assets/permission/desktop/win/permit-zh.png +0 -0
- package/src/Components/assets/streamInfo/mobile/microphone-close-group.svg +19 -0
- package/src/Components/assets/streamInfo/mobile/microphone-close-single.svg +6 -0
- package/src/Components/assets/streamInfo/mobile/volumn.svg +20 -0
- package/src/Components/assets/streamInfo/networkStatus.svg +22 -0
- package/src/Components/components/GroupCall/GroupCall.module.scss +13 -0
- package/src/Components/components/GroupCall/GroupCall.tsx +82 -0
- package/src/Components/components/GroupCall/MediaContainer/AudioStream/AudioStream.tsx +41 -0
- package/src/Components/components/GroupCall/MediaContainer/MediaContainer.module.scss +74 -0
- package/src/Components/components/GroupCall/MediaContainer/MediaContainer.tsx +138 -0
- package/src/Components/components/GroupCall/MediaContainer/StreamLoading/StreamLoading.tsx +48 -0
- package/src/Components/components/GroupCall/MediaContainer/index.ts +3 -0
- package/src/Components/components/GroupCall/Waiting/Waiting.module.scss +44 -0
- package/src/Components/components/GroupCall/Waiting/Waiting.tsx +89 -0
- package/src/Components/components/SingleCall/MediaContainer/AudioStream/AudioStream.tsx +86 -0
- package/src/Components/components/SingleCall/MediaContainer/MediaContainer.module.scss +33 -0
- package/src/Components/components/SingleCall/MediaContainer/MediaContainer.tsx +121 -0
- package/src/Components/components/SingleCall/MediaContainer/hooks/useGetLargeViewName.ts +29 -0
- package/src/Components/components/SingleCall/MediaContainer/index.ts +3 -0
- package/src/Components/components/SingleCall/SingleCall.module.scss +28 -0
- package/src/Components/components/SingleCall/SingleCall.tsx +54 -0
- package/src/Components/components/SingleCall/Waiting/Waiting.module.scss +3 -0
- package/src/Components/components/SingleCall/Waiting/Waiting.tsx +45 -0
- package/src/Components/components/base/Avatar/Avatar.scss +28 -0
- package/src/Components/components/base/Avatar/Avatar.tsx +52 -0
- package/src/Components/components/base/Avatar/index.ts +3 -0
- package/src/Components/components/base/Button/Button.scss +122 -0
- package/src/Components/components/base/Button/Button.tsx +107 -0
- package/src/Components/components/base/Button/index.ts +3 -0
- package/src/Components/components/base/Drag/Drag.tsx +155 -0
- package/src/Components/components/base/Drag/index.tsx +3 -0
- package/src/Components/components/base/Grid/Col/Col.scss +31 -0
- package/src/Components/components/base/Grid/Col/Col.tsx +52 -0
- package/src/Components/components/base/Grid/Col/index.ts +3 -0
- package/src/Components/components/base/Grid/Row/Row.scss +27 -0
- package/src/Components/components/base/Grid/Row/Row.tsx +51 -0
- package/src/Components/components/base/Grid/Row/index.ts +5 -0
- package/src/Components/components/base/Grid/style/mixin.scss +61 -0
- package/src/Components/components/base/GridLayout/GridLayout.tsx +189 -0
- package/src/Components/components/base/GridLayout/GridPlusItem/GridPlusItem.scss +11 -0
- package/src/Components/components/base/GridLayout/GridPlusItem/GridPlusItem.tsx +37 -0
- package/src/Components/components/base/GridLayout/index.ts +7 -0
- package/src/Components/components/base/Icon/Icon.tsx +25 -0
- package/src/Components/components/base/Loading/Circle/Cilrcle.tsx +20 -0
- package/src/Components/components/base/Loading/Circle/Circle.scss +29 -0
- package/src/Components/components/base/Loading/Dot/Dot.scss +69 -0
- package/src/Components/components/base/Loading/Dot/Dot.tsx +21 -0
- package/src/Components/components/base/Loading/Loading.scss +22 -0
- package/src/Components/components/base/Loading/Loading.tsx +47 -0
- package/src/Components/components/base/Loading/index.ts +3 -0
- package/src/Components/components/base/Message/Message.scss +61 -0
- package/src/Components/components/base/Message/Message.tsx +94 -0
- package/src/Components/components/base/Message/MessageIcon/Error.tsx +7 -0
- package/src/Components/components/base/Message/MessageIcon/Info.tsx +7 -0
- package/src/Components/components/base/Message/MessageIcon/Success.tsx +8 -0
- package/src/Components/components/base/Message/MessageIcon/Warning.tsx +7 -0
- package/src/Components/components/base/Message/MessagePlugin.tsx +148 -0
- package/src/Components/components/base/Overlayer/Overlayer.scss +17 -0
- package/src/Components/components/base/Overlayer/Overlayer.tsx +49 -0
- package/src/Components/components/base/Popup/Popup.scss +34 -0
- package/src/Components/components/base/Popup/Popup.tsx +91 -0
- package/src/Components/components/base/Popup/hooks/useTrigger.tsx +67 -0
- package/src/Components/components/base/Portal/Portal.tsx +74 -0
- package/src/Components/components/base/Text/Text.scss +15 -0
- package/src/Components/components/base/Text/Text.tsx +30 -0
- package/src/Components/components/base/Time/Time.scss +14 -0
- package/src/Components/components/base/Time/Time.tsx +13 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindow.scss +9 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindow.tsx +83 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.scss +51 -0
- package/src/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.tsx +50 -0
- package/src/Components/components/base/ToggleWindow/index.ts +7 -0
- package/src/Components/components/base/common.ts +13 -0
- package/src/Components/components/base/hooks/useControlled.ts +31 -0
- package/src/Components/components/base/hooks/useDrag.ts +96 -0
- package/src/Components/components/base/hooks/useListenerEvent.ts +37 -0
- package/src/Components/components/base/hooks/useMutationObserver.ts +38 -0
- package/src/Components/components/base/hooks/useOnClickOutSide.ts +24 -0
- package/src/Components/components/base/util/index.ts +26 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanel.tsx +127 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanelH5/ButtonPanelH5.module.scss +67 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanelH5/ButtonPanelH5.tsx +153 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanelPC/ButtonPanelPC.module.scss +9 -0
- package/src/Components/components/common/ButtonPanel/ButtonPanelPC/ButtonPanelPC.tsx +32 -0
- package/src/Components/components/common/ButtonPanel/button/Accept/Accept.module.scss +7 -0
- package/src/Components/components/common/ButtonPanel/button/Accept/Accept.tsx +39 -0
- package/src/Components/components/common/ButtonPanel/button/Accept/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/BackgroundBlur/BackgroundBlur.module.scss +15 -0
- package/src/Components/components/common/ButtonPanel/button/BackgroundBlur/BackgroundBlur.tsx +46 -0
- package/src/Components/components/common/ButtonPanel/button/BackgroundBlur/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/Camera.tsx +81 -0
- package/src/Components/components/common/ButtonPanel/button/FullScreen/FullScreen.module.scss +13 -0
- package/src/Components/components/common/ButtonPanel/button/FullScreen/FullScreen.tsx +26 -0
- package/src/Components/components/common/ButtonPanel/button/FullScreen/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/Hangup/Hangup.module.scss +7 -0
- package/src/Components/components/common/ButtonPanel/button/Hangup/Hangup.tsx +42 -0
- package/src/Components/components/common/ButtonPanel/button/Hangup/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/Microphone.tsx +78 -0
- package/src/Components/components/common/ButtonPanel/button/Minimize/Minimize.module.scss +23 -0
- package/src/Components/components/common/ButtonPanel/button/Minimize/Minimize.tsx +35 -0
- package/src/Components/components/common/ButtonPanel/button/Minimize/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/Reject/Reject.module.scss +7 -0
- package/src/Components/components/common/ButtonPanel/button/Reject/Reject.tsx +39 -0
- package/src/Components/components/common/ButtonPanel/button/Reject/index.ts +3 -0
- package/src/Components/components/common/ButtonPanel/button/Speaker.tsx +75 -0
- package/src/Components/components/common/ButtonPanel/button/SwitchAudioCall.tsx +32 -0
- package/src/Components/components/common/ButtonPanel/button/SwitchCamera.tsx +19 -0
- package/src/Components/components/common/ButtonPanel/button/common.module.scss +51 -0
- package/src/Components/components/common/ButtonPanel/config.ts +505 -0
- package/src/Components/components/common/ButtonPanel/index.ts +3 -0
- package/src/Components/components/common/CallMessage/CallMessage.tsx +18 -0
- package/src/Components/components/common/CallMessage/CallMessageC2C/CallMessageC2C.module.scss +19 -0
- package/src/Components/components/common/CallMessage/CallMessageC2C/CallMessageC2C.tsx +84 -0
- package/src/Components/components/common/CallMessage/CallMessageGroup/CallMessageGroup.module.scss +5 -0
- package/src/Components/components/common/CallMessage/CallMessageGroup/CallMessageGroup.tsx +37 -0
- package/src/Components/components/common/CallMessage/index.ts +3 -0
- package/src/Components/components/common/DeviceSelector/DeviceSelector.module.scss +62 -0
- package/src/Components/components/common/DeviceSelector/DeviceSelector.tsx +105 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindow.tsx +37 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowGroupCall/FloatingWindowGroupCall.tsx +97 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowGroupCall/style/FloatingWindowGroupCall.module.scss +2 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowGroupCall/style/mobile.module.scss +126 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowGroupCall/style/pc.module.scss +126 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowSingleCall/FloatingWindowSingleCall.tsx +75 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowSingleCall/style/FloatingWindowSingleCall.module.scss +2 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowSingleCall/style/mobile.module.scss +117 -0
- package/src/Components/components/common/FloatingWindow/FloatingWindowSingleCall/style/pc.module.scss +123 -0
- package/src/Components/components/common/FloatingWindow/index.ts +3 -0
- package/src/Components/components/common/MicrophoneVolumn/MicrophoneVolumn.module.scss +9 -0
- package/src/Components/components/common/MicrophoneVolumn/MicrophoneVolumn.tsx +50 -0
- package/src/Components/components/common/OverlayStream/OverlayStream.module.scss +165 -0
- package/src/Components/components/common/OverlayStream/OverlayStream.tsx +119 -0
- package/src/Components/components/common/Player/Player.module.scss +11 -0
- package/src/Components/components/common/Player/Player.tsx +75 -0
- package/src/Components/components/common/Pusher/Pusher.module.scss +10 -0
- package/src/Components/components/common/Pusher/Pusher.tsx +96 -0
- package/src/Components/components/common/StreamInfo/StreamInfo.tsx +10 -0
- package/src/Components/components/common/StreamInfo/StreamInfoH5/StreamInfoH5.module.scss +21 -0
- package/src/Components/components/common/StreamInfo/StreamInfoH5/StreamInfoH5.tsx +95 -0
- package/src/Components/components/common/StreamInfo/StreamInfoPC/StreamInfoPC.module.scss +38 -0
- package/src/Components/components/common/StreamInfo/StreamInfoPC/StreamInfoPC.tsx +35 -0
- package/src/Components/components/common/StreamInfo/index.ts +3 -0
- package/src/Components/components/common/Tip/Tip.tsx +68 -0
- package/src/Components/components/common/TopBar/TopBar.tsx +17 -0
- package/src/Components/components/common/TopBar/h5/TopBarH5.module.scss +12 -0
- package/src/Components/components/common/TopBar/h5/TopBarH5.tsx +40 -0
- package/src/Components/components/common/TopBar/pc/TopBarPC.module.scss +8 -0
- package/src/Components/components/common/TopBar/pc/TopBarPC.tsx +36 -0
- package/src/Components/const/common.ts +15 -0
- package/src/Components/context/CallUserInfoContext.ts +21 -0
- package/src/Components/context/CallerUserInfoContext.ts +11 -0
- package/src/Components/context/CustomUIConfigContext.ts +6 -0
- package/src/Components/context/FocusItemContext.ts +13 -0
- package/src/Components/context/IsClickableContext.ts +5 -0
- package/src/Components/context/TranslateContext.ts +6 -0
- package/src/Components/context/UserInfoContext.ts +9 -0
- package/src/Components/context/index.ts +17 -0
- package/src/Components/hooks/index.ts +9 -0
- package/src/Components/hooks/useCallDuration.ts +34 -0
- package/src/Components/hooks/useCustomButtonUIConfig.ts +27 -0
- package/src/Components/hooks/useDeviceList.ts +53 -0
- package/src/Components/hooks/useGetSpeakers.ts +69 -0
- package/src/Components/hooks/useGetVolumeMap.ts +67 -0
- package/src/Components/hooks/useNetWorkStatus.ts +34 -0
- package/src/Components/hooks/useTranslate.ts +7 -0
- package/src/Components/hooks/useViewBackgroundConfig.ts +8 -0
- package/src/Components/style/common/mixin.scss +22 -0
- package/src/Components/style/common/var.scss +21 -0
- package/src/Components/style/index.scss +5 -0
- package/src/Components/style/theme/_dark.scss +56 -0
- package/src/Components/style/theme/_light.scss +56 -0
- package/src/Components/style/theme/_util.scss +79 -0
- package/src/Components/style/theme/color.scss +23 -0
- package/src/Components/util/classnames.ts +35 -0
- package/src/Components/util/index.ts +138 -0
- package/src/Components/util/uiDesign.ts +45 -0
- package/src/TUICallService/CallService/UIDesign.ts +174 -0
- package/src/TUICallService/CallService/bellContext.ts +88 -0
- package/src/TUICallService/CallService/chatCombine.ts +313 -0
- package/src/TUICallService/CallService/engineEventHandler.ts +404 -0
- package/src/TUICallService/CallService/index.ts +797 -0
- package/src/TUICallService/CallService/miniProgram.ts +65 -0
- package/src/TUICallService/CallService/utils.ts +281 -0
- package/src/TUICallService/TUIGlobal/tuiGlobal.ts +43 -0
- package/src/TUICallService/TUIStore/callStore.ts +93 -0
- package/src/TUICallService/TUIStore/tuiStore.ts +167 -0
- package/src/TUICallService/assets/phone_dialing.mp3 +0 -0
- package/src/TUICallService/assets/phone_ringing.mp3 +0 -0
- package/src/TUICallService/const/call.ts +157 -0
- package/src/TUICallService/const/error.ts +20 -0
- package/src/TUICallService/const/index.ts +103 -0
- package/src/TUICallService/const/log.ts +9 -0
- package/src/TUICallService/index.ts +37 -0
- package/src/TUICallService/interface/ICallService.ts +70 -0
- package/src/TUICallService/interface/ICallStore.ts +55 -0
- package/src/TUICallService/interface/ITUIGlobal.ts +36 -0
- package/src/TUICallService/interface/ITUIStore.ts +87 -0
- package/src/TUICallService/interface/index.ts +4 -0
- package/src/TUICallService/locales/en.ts +135 -0
- package/src/TUICallService/locales/index.ts +61 -0
- package/src/TUICallService/locales/ja_JP.ts +134 -0
- package/src/TUICallService/locales/zh-cn.ts +130 -0
- package/src/TUICallService/serve/callManager.ts +109 -0
- package/src/TUICallService/utils/common-utils.ts +269 -0
- package/src/TUICallService/utils/decorators/promise-retry.ts +51 -0
- package/src/TUICallService/utils/env.ts +51 -0
- package/src/TUICallService/utils/index.ts +32 -0
- package/src/TUICallService/utils/is-empty.ts +31 -0
- package/src/TUICallService/utils/retry.ts +88 -0
- package/src/TUICallService/utils/timer.ts +162 -0
- package/src/TUICallService/utils/validate/avoidRepeatedCall.ts +39 -0
- package/src/TUICallService/utils/validate/index.ts +7 -0
- package/src/TUICallService/utils/validate/validateConfig.ts +188 -0
- package/src/TUICallService/utils/validate/validateParams.ts +88 -0
- package/src/TUICallService/utils/validate/validateStatus.ts +26 -0
- package/src/image.d.ts +8 -0
- package/src/index.ts +63 -0
- package/src/style.d.ts +1 -0
- package/tuicall-uikit-react.es.js +13177 -0
- package/tuicall-uikit-react.umd.js +133 -0
- package/types/Components/TUICallKit/TUICallKit.d.ts +15 -0
- package/types/Components/TUICallKit/index.d.ts +2 -0
- package/types/Components/assets/permission/desktop/index.d.ts +5 -0
- package/types/Components/components/GroupCall/GroupCall.d.ts +1 -0
- package/types/Components/components/GroupCall/MediaContainer/AudioStream/AudioStream.d.ts +10 -0
- package/types/Components/components/GroupCall/MediaContainer/MediaContainer.d.ts +1 -0
- package/types/Components/components/GroupCall/MediaContainer/StreamLoading/StreamLoading.d.ts +7 -0
- package/types/Components/components/GroupCall/MediaContainer/index.d.ts +2 -0
- package/types/Components/components/GroupCall/Waiting/Waiting.d.ts +8 -0
- package/types/Components/components/SingleCall/MediaContainer/AudioStream/AudioStream.d.ts +11 -0
- package/types/Components/components/SingleCall/MediaContainer/MediaContainer.d.ts +1 -0
- package/types/Components/components/SingleCall/MediaContainer/hooks/useGetLargeViewName.d.ts +3 -0
- package/types/Components/components/SingleCall/MediaContainer/index.d.ts +2 -0
- package/types/Components/components/SingleCall/SingleCall.d.ts +3 -0
- package/types/Components/components/SingleCall/Waiting/Waiting.d.ts +9 -0
- package/types/Components/components/base/Avatar/Avatar.d.ts +12 -0
- package/types/Components/components/base/Avatar/index.d.ts +2 -0
- package/types/Components/components/base/Button/Button.d.ts +25 -0
- package/types/Components/components/base/Button/index.d.ts +2 -0
- package/types/Components/components/base/Drag/Drag.d.ts +14 -0
- package/types/Components/components/base/Drag/index.d.ts +2 -0
- package/types/Components/components/base/Grid/Col/Col.d.ts +14 -0
- package/types/Components/components/base/Grid/Col/index.d.ts +2 -0
- package/types/Components/components/base/Grid/Row/Row.d.ts +14 -0
- package/types/Components/components/base/Grid/Row/index.d.ts +3 -0
- package/types/Components/components/base/GridLayout/GridLayout.d.ts +11 -0
- package/types/Components/components/base/GridLayout/GridPlusItem/GridPlusItem.d.ts +14 -0
- package/types/Components/components/base/GridLayout/index.d.ts +3 -0
- package/types/Components/components/base/Icon/Icon.d.ts +9 -0
- package/types/Components/components/base/Loading/Circle/Cilrcle.d.ts +6 -0
- package/types/Components/components/base/Loading/Dot/Dot.d.ts +6 -0
- package/types/Components/components/base/Loading/Loading.d.ts +14 -0
- package/types/Components/components/base/Loading/index.d.ts +2 -0
- package/types/Components/components/base/Message/Message.d.ts +16 -0
- package/types/Components/components/base/Message/MessageIcon/Error.d.ts +1 -0
- package/types/Components/components/base/Message/MessageIcon/Info.d.ts +1 -0
- package/types/Components/components/base/Message/MessageIcon/Success.d.ts +1 -0
- package/types/Components/components/base/Message/MessageIcon/Warning.d.ts +1 -0
- package/types/Components/components/base/Message/MessagePlugin.d.ts +14 -0
- package/types/Components/components/base/Overlayer/Overlayer.d.ts +14 -0
- package/types/Components/components/base/Popup/Popup.d.ts +13 -0
- package/types/Components/components/base/Popup/hooks/useTrigger.d.ts +10 -0
- package/types/Components/components/base/Portal/Portal.d.ts +19 -0
- package/types/Components/components/base/Text/Text.d.ts +10 -0
- package/types/Components/components/base/Time/Time.d.ts +7 -0
- package/types/Components/components/base/ToggleWindow/ToggleWindow.d.ts +15 -0
- package/types/Components/components/base/ToggleWindow/ToggleWindowItem/ToggleWindowItem.d.ts +14 -0
- package/types/Components/components/base/ToggleWindow/index.d.ts +3 -0
- package/types/Components/components/base/common.d.ts +7 -0
- package/types/Components/components/base/hooks/useControlled.d.ts +8 -0
- package/types/Components/components/base/hooks/useDrag.d.ts +6 -0
- package/types/Components/components/base/hooks/useListenerEvent.d.ts +13 -0
- package/types/Components/components/base/hooks/useMutationObserver.d.ts +4 -0
- package/types/Components/components/base/hooks/useOnClickOutSide.d.ts +1 -0
- package/types/Components/components/base/util/index.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/ButtonPanel.d.ts +1 -0
- package/types/Components/components/common/ButtonPanel/ButtonPanelH5/ButtonPanelH5.d.ts +8 -0
- package/types/Components/components/common/ButtonPanel/ButtonPanelPC/ButtonPanelPC.d.ts +6 -0
- package/types/Components/components/common/ButtonPanel/button/Accept/Accept.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/Accept/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/BackgroundBlur/BackgroundBlur.d.ts +1 -0
- package/types/Components/components/common/ButtonPanel/button/BackgroundBlur/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/Camera.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/FullScreen/FullScreen.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/FullScreen/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/Hangup/Hangup.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/Hangup/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/Microphone.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/Minimize/Minimize.d.ts +1 -0
- package/types/Components/components/common/ButtonPanel/button/Minimize/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/Reject/Reject.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/Reject/index.d.ts +2 -0
- package/types/Components/components/common/ButtonPanel/button/Speaker.d.ts +5 -0
- package/types/Components/components/common/ButtonPanel/button/SwitchAudioCall.d.ts +1 -0
- package/types/Components/components/common/ButtonPanel/button/SwitchCamera.d.ts +1 -0
- package/types/Components/components/common/ButtonPanel/config.d.ts +254 -0
- package/types/Components/components/common/ButtonPanel/index.d.ts +2 -0
- package/types/Components/components/common/CallMessage/CallMessage.d.ts +10 -0
- package/types/Components/components/common/CallMessage/CallMessageC2C/CallMessageC2C.d.ts +2 -0
- package/types/Components/components/common/CallMessage/CallMessageGroup/CallMessageGroup.d.ts +2 -0
- package/types/Components/components/common/CallMessage/index.d.ts +2 -0
- package/types/Components/components/common/DeviceSelector/DeviceSelector.d.ts +7 -0
- package/types/Components/components/common/FloatingWindow/FloatingWindow.d.ts +10 -0
- package/types/Components/components/common/FloatingWindow/FloatingWindowGroupCall/FloatingWindowGroupCall.d.ts +9 -0
- package/types/Components/components/common/FloatingWindow/FloatingWindowSingleCall/FloatingWindowSingleCall.d.ts +10 -0
- package/types/Components/components/common/FloatingWindow/index.d.ts +2 -0
- package/types/Components/components/common/MicrophoneVolumn/MicrophoneVolumn.d.ts +8 -0
- package/types/Components/components/common/OverlayStream/OverlayStream.d.ts +28 -0
- package/types/Components/components/common/Player/Player.d.ts +15 -0
- package/types/Components/components/common/Pusher/Pusher.d.ts +13 -0
- package/types/Components/components/common/StreamInfo/StreamInfo.d.ts +1 -0
- package/types/Components/components/common/StreamInfo/StreamInfoH5/StreamInfoH5.d.ts +10 -0
- package/types/Components/components/common/StreamInfo/StreamInfoPC/StreamInfoPC.d.ts +9 -0
- package/types/Components/components/common/StreamInfo/index.d.ts +2 -0
- package/types/Components/components/common/Tip/Tip.d.ts +7 -0
- package/types/Components/components/common/TopBar/TopBar.d.ts +1 -0
- package/types/Components/components/common/TopBar/h5/TopBarH5.d.ts +5 -0
- package/types/Components/components/common/TopBar/pc/TopBarPC.d.ts +5 -0
- package/types/Components/const/common.d.ts +11 -0
- package/types/Components/context/CallUserInfoContext.d.ts +17 -0
- package/types/Components/context/CallerUserInfoContext.d.ts +7 -0
- package/types/Components/context/CustomUIConfigContext.d.ts +3 -0
- package/types/Components/context/FocusItemContext.d.ts +8 -0
- package/types/Components/context/IsClickableContext.d.ts +2 -0
- package/types/Components/context/TranslateContext.d.ts +4 -0
- package/types/Components/context/UserInfoContext.d.ts +6 -0
- package/types/Components/context/index.d.ts +8 -0
- package/types/Components/hooks/index.d.ts +4 -0
- package/types/Components/hooks/useCallDuration.d.ts +1 -0
- package/types/Components/hooks/useCustomButtonUIConfig.d.ts +1 -0
- package/types/Components/hooks/useDeviceList.d.ts +8 -0
- package/types/Components/hooks/useGetSpeakers.d.ts +1 -0
- package/types/Components/hooks/useGetVolumeMap.d.ts +3 -0
- package/types/Components/hooks/useNetWorkStatus.d.ts +1 -0
- package/types/Components/hooks/useTranslate.d.ts +3 -0
- package/types/Components/hooks/useViewBackgroundConfig.d.ts +1 -0
- package/types/Components/util/classnames.d.ts +1 -0
- package/types/Components/util/index.d.ts +15 -0
- package/types/Components/util/uiDesign.d.ts +2 -0
- package/types/TUICallService/CallService/UIDesign.d.ts +28 -0
- package/types/TUICallService/CallService/bellContext.d.ts +19 -0
- package/types/TUICallService/CallService/chatCombine.d.ts +50 -0
- package/types/TUICallService/CallService/engineEventHandler.d.ts +35 -0
- package/types/TUICallService/CallService/index.d.ts +98 -0
- package/types/TUICallService/CallService/miniProgram.d.ts +7 -0
- package/types/TUICallService/CallService/utils.d.ts +42 -0
- package/types/TUICallService/TUIGlobal/tuiGlobal.d.ts +21 -0
- package/types/TUICallService/TUIStore/callStore.d.ts +10 -0
- package/types/TUICallService/TUIStore/tuiStore.d.ts +57 -0
- package/types/TUICallService/const/call.d.ts +141 -0
- package/types/TUICallService/const/error.d.ts +2 -0
- package/types/TUICallService/const/index.d.ts +27 -0
- package/types/TUICallService/const/log.d.ts +7 -0
- package/types/TUICallService/index.d.ts +5 -0
- package/types/TUICallService/interface/ICallService.d.ts +69 -0
- package/types/TUICallService/interface/ICallStore.d.ts +47 -0
- package/types/TUICallService/interface/ITUIGlobal.d.ts +36 -0
- package/types/TUICallService/interface/ITUIStore.d.ts +83 -0
- package/types/TUICallService/interface/index.d.ts +4 -0
- package/types/TUICallService/locales/en.d.ts +128 -0
- package/types/TUICallService/locales/index.d.ts +10 -0
- package/types/TUICallService/locales/ja_JP.d.ts +127 -0
- package/types/TUICallService/locales/zh-cn.d.ts +123 -0
- package/types/TUICallService/serve/callManager.d.ts +11 -0
- package/types/TUICallService/utils/common-utils.d.ts +62 -0
- package/types/TUICallService/utils/decorators/promise-retry.d.ts +32 -0
- package/types/TUICallService/utils/env.d.ts +10 -0
- package/types/TUICallService/utils/index.d.ts +2 -0
- package/types/TUICallService/utils/is-empty.d.ts +2 -0
- package/types/TUICallService/utils/retry.d.ts +36 -0
- package/types/TUICallService/utils/timer.d.ts +63 -0
- package/types/TUICallService/utils/validate/avoidRepeatedCall.d.ts +10 -0
- package/types/TUICallService/utils/validate/index.d.ts +2 -0
- package/types/TUICallService/utils/validate/validateConfig.d.ts +173 -0
- package/types/TUICallService/utils/validate/validateParams.d.ts +1 -0
- package/types/TUICallService/utils/validate/validateStatus.d.ts +5 -0
- package/types/index.d.ts +11 -0
|
@@ -0,0 +1,797 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IUserInfo, ICallbackParam, ISelfInfoParams, IBellParams, IInviteUserParams, IInitParams, ICallsParams,
|
|
3
|
+
} from '../interface/ICallService';
|
|
4
|
+
import {
|
|
5
|
+
StoreName, CallStatus, CallMediaType, NAME, CALL_DATA_KEY, LanguageType, CallRole, LOG_LEVEL, VideoDisplayMode,
|
|
6
|
+
VideoResolution, StatusChange, AudioPlayBackDevice, CameraPosition, COMPONENT, FeatureButton, ButtonState,
|
|
7
|
+
LayoutMode, DEFAULT_BLUR_LEVEL,
|
|
8
|
+
} from '../const/index';
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import { TUICallEngine } from '@trtc/call-engine-lite-js';
|
|
11
|
+
import { checkLocalMP3FileExists } from '../utils/index';
|
|
12
|
+
import { CallTips, t } from '../locales/index';
|
|
13
|
+
import { BellContext } from './bellContext';
|
|
14
|
+
import { avoidRepeatedCall } from '../utils/validate/index';
|
|
15
|
+
import { handleRepeatedCallError, formatTime, performanceNow, initBrowserCloseDetection } from '../utils/common-utils';
|
|
16
|
+
import { getRemoteUserProfile, generateStatusChangeText, noDevicePermissionToast, setLocalUserInfoAudioVideoAvailable,
|
|
17
|
+
getGroupMemberList, getGroupProfile, updateRoomIdAndRoomIdType, updateDeviceList } from './utils';
|
|
18
|
+
import timer from '../utils/timer';
|
|
19
|
+
import { ITUIGlobal, ITUIStore } from '../interface/index';
|
|
20
|
+
import TuiGlobal from '../TUIGlobal/tuiGlobal';
|
|
21
|
+
import TuiStore from '../TUIStore/tuiStore';
|
|
22
|
+
import { UIDesign } from './UIDesign';
|
|
23
|
+
import ChatCombine from './chatCombine';
|
|
24
|
+
import EngineEventHandler from './engineEventHandler';
|
|
25
|
+
const TUIGlobal: ITUIGlobal = TuiGlobal.getInstance();
|
|
26
|
+
const TUIStore: ITUIStore = TuiStore.getInstance();
|
|
27
|
+
const uiDesign = UIDesign.getInstance();
|
|
28
|
+
uiDesign.setTUIStore(TUIStore);
|
|
29
|
+
const version = '4.1.0';
|
|
30
|
+
const frameWork = 'react';
|
|
31
|
+
export { TUIGlobal, TUIStore, uiDesign };
|
|
32
|
+
|
|
33
|
+
export default class TUICallService {
|
|
34
|
+
static instance: TUICallService;
|
|
35
|
+
public _tuiCallEngine: any;
|
|
36
|
+
private _tim: any = null;
|
|
37
|
+
private _TUICore: any = null;
|
|
38
|
+
private _timerId: number = -1;
|
|
39
|
+
private _startTimeStamp: number = performanceNow();
|
|
40
|
+
private _bellContext: any = null;
|
|
41
|
+
private _isFromChat: boolean = false;
|
|
42
|
+
private _currentGroupId: string = ''; // The currentGroupId of the group chat that the user is currently in
|
|
43
|
+
private _offlinePushInfo = null;
|
|
44
|
+
private _permissionCheckTimer: any = null;
|
|
45
|
+
private _chatCombine: any = null;
|
|
46
|
+
private _engineEventHandler: any = null;
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
console.log(`${NAME.PREFIX}version: ${version}`);
|
|
50
|
+
this._watchTUIStore();
|
|
51
|
+
this._engineEventHandler = EngineEventHandler.getInstance({ callService: this });
|
|
52
|
+
|
|
53
|
+
this._chatCombine = ChatCombine.getInstance({ callService: this });
|
|
54
|
+
initBrowserCloseDetection(this.handleExceptionExit.bind(this));
|
|
55
|
+
}
|
|
56
|
+
static getInstance() {
|
|
57
|
+
if (!TUICallService.instance) {
|
|
58
|
+
TUICallService.instance = new TUICallService();
|
|
59
|
+
}
|
|
60
|
+
return TUICallService.instance;
|
|
61
|
+
}
|
|
62
|
+
@avoidRepeatedCall()
|
|
63
|
+
public async init(params: IInitParams) {
|
|
64
|
+
try {
|
|
65
|
+
if (this._tuiCallEngine) return;
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
let { userID, tim, userSig, sdkAppID, SDKAppID, isFromChat, component = COMPONENT.TUI_CALL_KIT } = params;
|
|
68
|
+
if (this._TUICore) {
|
|
69
|
+
sdkAppID = this._TUICore.SDKAppID;
|
|
70
|
+
tim = this._TUICore.tim;
|
|
71
|
+
}
|
|
72
|
+
this._tim = tim;
|
|
73
|
+
console.log(`${NAME.PREFIX}init sdkAppId: ${sdkAppID || SDKAppID}, userId: ${userID}`);
|
|
74
|
+
|
|
75
|
+
let scene = `web`;
|
|
76
|
+
scene = `${scene}-${frameWork}`;
|
|
77
|
+
// To distinguish whether the UniApp mini-program chooses Vue 2 or Vue 3
|
|
78
|
+
|
|
79
|
+
this._tuiCallEngine = TUICallEngine.createInstance({
|
|
80
|
+
tim,
|
|
81
|
+
SDKAppID: sdkAppID || SDKAppID, // 兼容传入 SDKAppID 的问题
|
|
82
|
+
frameWork,
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
language: 7,
|
|
85
|
+
callkitVersion: version,
|
|
86
|
+
isFromChat: isFromChat || false,
|
|
87
|
+
component,
|
|
88
|
+
scene,
|
|
89
|
+
});
|
|
90
|
+
uiDesign.setEngineInstance(this._tuiCallEngine);
|
|
91
|
+
this._addListenTuiCallEngineEvent();
|
|
92
|
+
this._bellContext = new BellContext();
|
|
93
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, { userId: userID });
|
|
94
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { userId: userID });
|
|
95
|
+
uiDesign.updateViewBackgroundUserId('local');
|
|
96
|
+
await this._tuiCallEngine.login({ userID, userSig, assetsPath: '' }); // web && mini
|
|
97
|
+
const uiConfig = TUIStore.getData(StoreName.CALL, NAME.CUSTOM_UI_CONFIG);
|
|
98
|
+
this._tuiCallEngine?.reportLog?.({
|
|
99
|
+
name: 'TUICallkit.init',
|
|
100
|
+
data: {
|
|
101
|
+
uiConfig,
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error(`${NAME.PREFIX}init failed, error: ${error}.`);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// component destroy
|
|
110
|
+
public async destroyed() {
|
|
111
|
+
try {
|
|
112
|
+
const currentCallStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
|
|
113
|
+
if (currentCallStatus !== CallStatus.IDLE) {
|
|
114
|
+
throw new Error(`please destroyed when status is idle, current status: ${currentCallStatus}`);
|
|
115
|
+
}
|
|
116
|
+
if (this._tuiCallEngine) {
|
|
117
|
+
this._removeListenTuiCallEngineEvent();
|
|
118
|
+
await this._tuiCallEngine.destroyInstance();
|
|
119
|
+
this._tuiCallEngine = null;
|
|
120
|
+
}
|
|
121
|
+
this._bellContext?.destroy();
|
|
122
|
+
this._bellContext = null;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(`${NAME.PREFIX}destroyed failed, error: ${error}.`);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ===============================【通话操作】===============================
|
|
129
|
+
@avoidRepeatedCall()
|
|
130
|
+
public async inviteUser(params: IInviteUserParams) {
|
|
131
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.IDLE) return; // avoid double click when application stuck
|
|
132
|
+
try {
|
|
133
|
+
const { userIDList } = params;
|
|
134
|
+
let inviteUserInfoList = await getRemoteUserProfile(userIDList, this.getTim());
|
|
135
|
+
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST);
|
|
136
|
+
const userIDListNotInRemoteUserInfoList = userIDList.filter(userId => {
|
|
137
|
+
return !remoteUserInfoList.some(remoteUserInfo => remoteUserInfo.userId === userId);
|
|
138
|
+
});
|
|
139
|
+
if (userIDListNotInRemoteUserInfoList.length === 0) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, [...remoteUserInfoList, ...inviteUserInfoList]);
|
|
143
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, [...remoteUserInfoList, ...inviteUserInfoList]);
|
|
144
|
+
this._tuiCallEngine && await this._tuiCallEngine.inviteUser(params);
|
|
145
|
+
} catch (error: any) {
|
|
146
|
+
console.error(`${NAME.PREFIX}inviteUser failed, error: ${error}.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
@avoidRepeatedCall()
|
|
150
|
+
public async calls(callsParams: ICallsParams) {
|
|
151
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return; // avoid double click when application stuck
|
|
152
|
+
try {
|
|
153
|
+
const { userIDList, type, chatGroupID, offlinePushInfo } = callsParams;
|
|
154
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return;
|
|
155
|
+
const remoteUserInfoList = userIDList.map(userId => ({ userId }));
|
|
156
|
+
await this._updateCallStoreBeforeCall(type, remoteUserInfoList, chatGroupID);
|
|
157
|
+
this.executeExternalBeforeCalling();
|
|
158
|
+
callsParams.offlinePushInfo = { ...this.getDefaultOfflinePushInfo(), ...offlinePushInfo };
|
|
159
|
+
const response = await this._tuiCallEngine.calls(callsParams);
|
|
160
|
+
await this._updateCallStoreAfterCall(userIDList, response);
|
|
161
|
+
} catch (error: any) {
|
|
162
|
+
this._handleCallError(error, 'calls');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
@avoidRepeatedCall()
|
|
166
|
+
public async join(params) {
|
|
167
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.CONNECTED) return; // avoid double click when application stuck
|
|
168
|
+
try {
|
|
169
|
+
const response = await this._tuiCallEngine.join(params);
|
|
170
|
+
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true);
|
|
171
|
+
this.startTimer();
|
|
172
|
+
|
|
173
|
+
const updateStoreParams = {
|
|
174
|
+
[NAME.CALL_ROLE]: CallRole.CALLEE,
|
|
175
|
+
[NAME.IS_GROUP]: true,
|
|
176
|
+
[NAME.CALL_STATUS]: CallStatus.CONNECTED,
|
|
177
|
+
[NAME.CALL_MEDIA_TYPE]: TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE) || CallMediaType.AUDIO, // default audio callMediaType
|
|
178
|
+
};
|
|
179
|
+
TUIStore.updateStore(updateStoreParams, StoreName.CALL);
|
|
180
|
+
|
|
181
|
+
updateDeviceList(this._tuiCallEngine);;
|
|
182
|
+
await this._tuiCallEngine.setVideoQuality(TUIStore.getData(StoreName.CALL, NAME.VIDEO_RESOLUTION));
|
|
183
|
+
const localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO);
|
|
184
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, { ...localUserInfo, isEnter: true });
|
|
185
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true });
|
|
186
|
+
|
|
187
|
+
await this.openMicrophone();
|
|
188
|
+
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO);
|
|
189
|
+
|
|
190
|
+
// // Current policy: By default, the camera remains off when joining GroupCall
|
|
191
|
+
// if (TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE) === CallMediaType.VIDEO) {
|
|
192
|
+
// await this.openCamera(NAME.LOCAL_VIDEO);
|
|
193
|
+
// setLocalUserInfoAudioVideoAvailable(true, NAME.VIDEO);
|
|
194
|
+
// }
|
|
195
|
+
} catch (error) {
|
|
196
|
+
this._handleCallError(error, 'join');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// ===============================【其它对外接口】===============================
|
|
200
|
+
public getTUICallEngineInstance(): any {
|
|
201
|
+
return this?._tuiCallEngine || null;
|
|
202
|
+
}
|
|
203
|
+
public setLogLevel(level: LOG_LEVEL) {
|
|
204
|
+
this?._tuiCallEngine?.setLogLevel(level);
|
|
205
|
+
}
|
|
206
|
+
public setLanguage(language: string) {
|
|
207
|
+
if (language && Object.values(LanguageType).includes(language as LanguageType)) {
|
|
208
|
+
TUIStore.update(StoreName.CALL, NAME.LANGUAGE, language);
|
|
209
|
+
TUIStore.update(StoreName.CALL, NAME.TRANSLATE, t.bind(null));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
public enableFloatWindow(enable: boolean) {
|
|
213
|
+
TUIStore.update(StoreName.CALL, NAME.ENABLE_FLOAT_WINDOW, enable);
|
|
214
|
+
}
|
|
215
|
+
public async setSelfInfo(params: ISelfInfoParams) {
|
|
216
|
+
const { nickName, avatar } = params;
|
|
217
|
+
try {
|
|
218
|
+
await this._tuiCallEngine.setSelfInfo({ nickName, avatar });
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error(`${NAME.PREFIX}setSelfInfo failed, error: ${error}.`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
public async enableVirtualBackground(enable: boolean) {
|
|
224
|
+
TUIStore.update(StoreName.CALL, NAME.IS_SHOW_ENABLE_VIRTUAL_BACKGROUND, enable);
|
|
225
|
+
}
|
|
226
|
+
public async enableAIVoice(enable: boolean) {
|
|
227
|
+
try {
|
|
228
|
+
await this._tuiCallEngine.enableAIVoice(enable);
|
|
229
|
+
console.log(`${NAME.PREFIX}enableAIVoice: ${enable}.`);
|
|
230
|
+
} catch (error: any) {
|
|
231
|
+
console.error(`${NAME.PREFIX}enableAIVoice failed, error: ${error}.`);
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// 修改默认铃声:只支持本地铃声文件,不支持在线铃声文件;修改铃声修改的是被叫的铃声
|
|
236
|
+
public async setCallingBell(filePath?: string) {
|
|
237
|
+
let isCheckFileExist: boolean = true;
|
|
238
|
+
isCheckFileExist = await checkLocalMP3FileExists(filePath);
|
|
239
|
+
if (!isCheckFileExist) {
|
|
240
|
+
console.warn(`${NAME.PREFIX}setCallingBell failed, filePath: ${filePath}.`);
|
|
241
|
+
return ;
|
|
242
|
+
}
|
|
243
|
+
const bellParams: IBellParams = { calleeBellFilePath: filePath };
|
|
244
|
+
this._bellContext.setBellProperties(bellParams);
|
|
245
|
+
}
|
|
246
|
+
public async enableMuteMode(enable: boolean) {
|
|
247
|
+
try {
|
|
248
|
+
const bellParams: IBellParams = { isMuteBell: enable };
|
|
249
|
+
this._bellContext.setBellProperties(bellParams);
|
|
250
|
+
await this._bellContext.setBellMute(enable);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console.warn(`${NAME.PREFIX}enableMuteMode failed, error: ${error}.`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
public hideFeatureButton(buttonName: FeatureButton) {
|
|
256
|
+
uiDesign.hideFeatureButton(buttonName);
|
|
257
|
+
}
|
|
258
|
+
public setLocalViewBackgroundImage(url: string) {
|
|
259
|
+
uiDesign.setLocalViewBackgroundImage(url);
|
|
260
|
+
}
|
|
261
|
+
public setRemoteViewBackgroundImage(userId: string, url: string) {
|
|
262
|
+
uiDesign.setRemoteViewBackgroundImage(userId, url);
|
|
263
|
+
}
|
|
264
|
+
public setLayoutMode(layoutMode: LayoutMode) {
|
|
265
|
+
uiDesign.setLayoutMode(layoutMode);
|
|
266
|
+
}
|
|
267
|
+
public setCameraDefaultState(isOpen: boolean) {
|
|
268
|
+
uiDesign.setCameraDefaultState(isOpen);
|
|
269
|
+
}
|
|
270
|
+
// =============================【实验性接口】=============================
|
|
271
|
+
public callExperimentalAPI(jsonStr: string) {
|
|
272
|
+
const jsonObj = JSON.parse(jsonStr);
|
|
273
|
+
if (jsonObj === jsonStr) return;
|
|
274
|
+
|
|
275
|
+
const { api, params } = jsonObj;
|
|
276
|
+
if (!api || !params) return;
|
|
277
|
+
|
|
278
|
+
try {
|
|
279
|
+
switch(api) {
|
|
280
|
+
case 'forceUseV2API':
|
|
281
|
+
const { enable } = params;
|
|
282
|
+
TUIStore.update(StoreName.CALL, NAME.IS_FORCE_USE_V2_API, !!enable);
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
} catch (error) {
|
|
288
|
+
this._tuiCallEngine?.reportLog?.({ name: 'TUICallKit.callExperimentalAPI.fail', data: { error } });
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// =============================【内部按钮操作方法】=============================
|
|
292
|
+
@avoidRepeatedCall()
|
|
293
|
+
public async accept() {
|
|
294
|
+
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
|
|
295
|
+
this._tuiCallEngine?.reportLog?.({
|
|
296
|
+
name: 'TUICallKit.accept.start',
|
|
297
|
+
data: { callStatus },
|
|
298
|
+
});
|
|
299
|
+
if (callStatus === CallStatus.CONNECTED) return; // avoid double click when application stuck, especially for miniProgram
|
|
300
|
+
try {
|
|
301
|
+
TUIStore.update(StoreName.CALL, NAME.CALL_STATUS, CallStatus.CONNECTED);
|
|
302
|
+
updateDeviceList(this._tuiCallEngine);;
|
|
303
|
+
const response = await this._tuiCallEngine.accept();
|
|
304
|
+
if (response) {
|
|
305
|
+
this._chatCombine?.callTUIService({ message: response?.data?.message });
|
|
306
|
+
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true);
|
|
307
|
+
this.startTimer();
|
|
308
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
309
|
+
const isCameraDefaultStateClose = this._getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close;
|
|
310
|
+
(callMediaType === CallMediaType.VIDEO) && !isCameraDefaultStateClose && await this.openCamera(NAME.LOCAL_VIDEO);
|
|
311
|
+
await this._tuiCallEngine.setVideoQuality(TUIStore.getData(StoreName.CALL, NAME.VIDEO_RESOLUTION));
|
|
312
|
+
const localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO);
|
|
313
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, { ...localUserInfo, isEnter: true });
|
|
314
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true });
|
|
315
|
+
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini default open audio
|
|
316
|
+
}
|
|
317
|
+
} catch (error) {
|
|
318
|
+
this._tuiCallEngine?.reportLog?.({
|
|
319
|
+
name: 'TUICallKit.accept.fail',
|
|
320
|
+
level: 'error',
|
|
321
|
+
error,
|
|
322
|
+
});
|
|
323
|
+
if (handleRepeatedCallError(error)) return;
|
|
324
|
+
noDevicePermissionToast(error, CallMediaType.AUDIO, this._tuiCallEngine);
|
|
325
|
+
this._resetCallStore();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
@avoidRepeatedCall()
|
|
329
|
+
public async hangup() {
|
|
330
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.IDLE) return; // avoid double click when application stuck
|
|
331
|
+
try {
|
|
332
|
+
const response = await this._tuiCallEngine.hangup();
|
|
333
|
+
response?.forEach((item) => {
|
|
334
|
+
if (item?.code === 0) {
|
|
335
|
+
this._chatCombine?.callTUIService({ message: item?.data?.message });
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.debug(error);
|
|
340
|
+
}
|
|
341
|
+
this._resetCallStore();
|
|
342
|
+
}
|
|
343
|
+
@avoidRepeatedCall()
|
|
344
|
+
public async reject() {
|
|
345
|
+
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.IDLE) return; // avoid double click when application stuck
|
|
346
|
+
try {
|
|
347
|
+
const response = await this._tuiCallEngine.reject();
|
|
348
|
+
if (response?.code === 0) {
|
|
349
|
+
this._chatCombine?.callTUIService({ message: response?.data?.message });
|
|
350
|
+
}
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.debug(error);
|
|
353
|
+
}
|
|
354
|
+
this._resetCallStore();
|
|
355
|
+
}
|
|
356
|
+
@avoidRepeatedCall()
|
|
357
|
+
public async openCamera(videoViewDomID: string) {
|
|
358
|
+
try {
|
|
359
|
+
if (TUIGlobal.isH5 || TUIGlobal.isWeChat) {
|
|
360
|
+
const currentPosition = TUIStore.getData(StoreName.CALL, NAME.CAMERA_POSITION);
|
|
361
|
+
const isFrontCamera = currentPosition === CameraPosition.FRONT ? true : false;
|
|
362
|
+
this._tuiCallEngine.openCamera(videoViewDomID, isFrontCamera);
|
|
363
|
+
} else {
|
|
364
|
+
await this._tuiCallEngine.openCamera(videoViewDomID);
|
|
365
|
+
}
|
|
366
|
+
setLocalUserInfoAudioVideoAvailable(true, NAME.VIDEO);
|
|
367
|
+
} catch (error: any) {
|
|
368
|
+
noDevicePermissionToast(error, CallMediaType.VIDEO, this._tuiCallEngine);
|
|
369
|
+
console.error(`${NAME.PREFIX}openCamera error: ${error}.`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
@avoidRepeatedCall()
|
|
373
|
+
public async closeCamera() {
|
|
374
|
+
try {
|
|
375
|
+
await this._tuiCallEngine.closeCamera();
|
|
376
|
+
setLocalUserInfoAudioVideoAvailable(false, NAME.VIDEO);
|
|
377
|
+
} catch (error: any) {
|
|
378
|
+
console.error(`${NAME.PREFIX}closeCamera error: ${error}.`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
@avoidRepeatedCall()
|
|
382
|
+
public async openMicrophone() {
|
|
383
|
+
try {
|
|
384
|
+
await this._tuiCallEngine.openMicrophone();
|
|
385
|
+
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO);
|
|
386
|
+
} catch (error: any) {
|
|
387
|
+
console.error(`${NAME.PREFIX}openMicrophone failed, error: ${error}.`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
@avoidRepeatedCall()
|
|
391
|
+
public async closeMicrophone() {
|
|
392
|
+
try {
|
|
393
|
+
await this._tuiCallEngine.closeMicrophone();
|
|
394
|
+
setLocalUserInfoAudioVideoAvailable(false, NAME.AUDIO);
|
|
395
|
+
} catch (error: any) {
|
|
396
|
+
console.error(`${NAME.PREFIX}closeMicrophone failed, error: ${error}.`);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
@avoidRepeatedCall()
|
|
400
|
+
public unMuteSpeaker() {
|
|
401
|
+
try {
|
|
402
|
+
const trtcCloudInstance = this._tuiCallEngine?.getTRTCCloudInstance?.();
|
|
403
|
+
if (trtcCloudInstance) {
|
|
404
|
+
trtcCloudInstance.muteAllRemoteAudio(false);
|
|
405
|
+
TUIStore.update(StoreName.CALL, NAME.IS_MUTE_SPEAKER, false);
|
|
406
|
+
}
|
|
407
|
+
} catch (error: any) {
|
|
408
|
+
console.error(`${NAME.PREFIX}unMuteSpeaker failed, error: ${error}.`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
@avoidRepeatedCall()
|
|
412
|
+
public muteSpeaker() {
|
|
413
|
+
try {
|
|
414
|
+
const trtcCloudInstance = this._tuiCallEngine?.getTRTCCloudInstance?.();
|
|
415
|
+
if (trtcCloudInstance) {
|
|
416
|
+
trtcCloudInstance.muteAllRemoteAudio(true);
|
|
417
|
+
TUIStore.update(StoreName.CALL, NAME.IS_MUTE_SPEAKER, true);
|
|
418
|
+
}
|
|
419
|
+
} catch (error: any) {
|
|
420
|
+
console.error(`${NAME.PREFIX}muteSpeaker failed, error: ${error}.`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
@avoidRepeatedCall()
|
|
424
|
+
public switchScreen(userId: string) {
|
|
425
|
+
if(!userId) return;
|
|
426
|
+
TUIStore.update(StoreName.CALL, NAME.BIG_SCREEN_USER_ID, userId);
|
|
427
|
+
}
|
|
428
|
+
// support video to audio; not support audio to video
|
|
429
|
+
@avoidRepeatedCall()
|
|
430
|
+
public async switchCallMediaType() {
|
|
431
|
+
try {
|
|
432
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
433
|
+
if (callMediaType === CallMediaType.AUDIO) {
|
|
434
|
+
console.warn(`${NAME.PREFIX}switchCallMediaType failed, ${callMediaType} not support.`);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const response = await this._tuiCallEngine.switchCallMediaType(CallMediaType.AUDIO);
|
|
438
|
+
if (response?.code === 0) {
|
|
439
|
+
this._chatCombine?.callTUIService({ message: response?.data?.message });
|
|
440
|
+
}
|
|
441
|
+
TUIStore.update(StoreName.CALL, NAME.CALL_MEDIA_TYPE, CallMediaType.AUDIO);
|
|
442
|
+
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP);
|
|
443
|
+
const oldStatus = isGroup ? StatusChange.CALLING_GROUP_VIDEO : StatusChange.CALLING_C2C_VIDEO;
|
|
444
|
+
const newStatus = generateStatusChangeText();
|
|
445
|
+
this.statusChanged && this.statusChanged({ oldStatus, newStatus });
|
|
446
|
+
} catch (error: any) {
|
|
447
|
+
console.error(`${NAME.PREFIX}switchCallMediaType failed, error: ${error}.`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
@avoidRepeatedCall()
|
|
451
|
+
public async switchCamera() {
|
|
452
|
+
const currentPosition = TUIStore.getData(StoreName.CALL, NAME.CAMERA_POSITION);
|
|
453
|
+
const targetPosition = currentPosition === CameraPosition.BACK ? CameraPosition.FRONT : CameraPosition.BACK;
|
|
454
|
+
try {
|
|
455
|
+
await this._tuiCallEngine.switchCamera(targetPosition);
|
|
456
|
+
TUIStore.update(StoreName.CALL, NAME.CAMERA_POSITION, targetPosition);
|
|
457
|
+
} catch (error) {
|
|
458
|
+
console.error(`${NAME.PREFIX}_switchCamera failed, error: ${error}.`);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
@avoidRepeatedCall()
|
|
462
|
+
public async setBlurBackground(enable: boolean) {
|
|
463
|
+
try {
|
|
464
|
+
await this._tuiCallEngine.setBlurBackground(enable ? DEFAULT_BLUR_LEVEL : 0); // 0 indicate close blurBackground
|
|
465
|
+
TUIStore.update(StoreName.CALL, NAME.ENABLE_VIRTUAL_BACKGROUND, enable);
|
|
466
|
+
} catch (error) {
|
|
467
|
+
console.error(`${NAME.PREFIX}_setBlurBackground failed, error: ${error}.`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
@avoidRepeatedCall()
|
|
471
|
+
public async switchDevice(params) {
|
|
472
|
+
try {
|
|
473
|
+
await this._tuiCallEngine.switchDevice(params);
|
|
474
|
+
} catch (error) {
|
|
475
|
+
console.error(`${NAME.PREFIX}_switchDevice failed, error: ${error}.`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
public async getDeviceList(deviceType: string) {
|
|
479
|
+
try {
|
|
480
|
+
const response = await this._tuiCallEngine.getDeviceList(deviceType);
|
|
481
|
+
return response;
|
|
482
|
+
} catch (error: any) {
|
|
483
|
+
this._handleCallError(error, 'call');
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
// ==========================【TUICallEngine 事件处理】==========================
|
|
487
|
+
private _addListenTuiCallEngineEvent() {
|
|
488
|
+
this._engineEventHandler.addListenTuiCallEngineEvent();
|
|
489
|
+
}
|
|
490
|
+
private _removeListenTuiCallEngineEvent() {
|
|
491
|
+
this._engineEventHandler.removeListenTuiCallEngineEvent();
|
|
492
|
+
}
|
|
493
|
+
// ========================【原 Web CallKit 提供的方法】========================
|
|
494
|
+
public beforeCalling: ((...args: any[]) => void) | undefined; // 原来
|
|
495
|
+
public afterCalling: ((...args: any[]) => void) | undefined;
|
|
496
|
+
public onMinimized: ((...args: any[]) => void) | undefined;
|
|
497
|
+
public onMessageSentByMe: ((...args: any[]) => void) | undefined;
|
|
498
|
+
public kickedOut: ((...args: any[]) => void) | undefined;
|
|
499
|
+
public statusChanged: ((...args: any[]) => void) | undefined;
|
|
500
|
+
public setCallback(params: ICallbackParam) {
|
|
501
|
+
const { beforeCalling, afterCalling, onMinimized, onMessageSentByMe, kickedOut, statusChanged } = params;
|
|
502
|
+
beforeCalling && (this.beforeCalling = beforeCalling);
|
|
503
|
+
afterCalling && (this.afterCalling = afterCalling);
|
|
504
|
+
onMinimized && (this.onMinimized = onMinimized);
|
|
505
|
+
onMessageSentByMe && (this.onMessageSentByMe = onMessageSentByMe);
|
|
506
|
+
kickedOut && (this.kickedOut = kickedOut);
|
|
507
|
+
statusChanged && (this.statusChanged = statusChanged);
|
|
508
|
+
}
|
|
509
|
+
public toggleMinimize() {
|
|
510
|
+
const isMinimized = TUIStore.getData(StoreName.CALL, NAME.IS_MINIMIZED);
|
|
511
|
+
TUIStore.update(StoreName.CALL, NAME.IS_MINIMIZED, !isMinimized);
|
|
512
|
+
console.log(`${NAME.PREFIX}toggleMinimize: ${isMinimized} -> ${!isMinimized}.`);
|
|
513
|
+
this.onMinimized && this.onMinimized(isMinimized, !isMinimized);
|
|
514
|
+
}
|
|
515
|
+
public executeExternalBeforeCalling(): void {
|
|
516
|
+
this.beforeCalling && this.beforeCalling();
|
|
517
|
+
}
|
|
518
|
+
public executeExternalAfterCalling(): void {
|
|
519
|
+
this.afterCalling && this.afterCalling();
|
|
520
|
+
}
|
|
521
|
+
// 处理用户异常退出的情况, 小程序 ”右滑“、"左上角退出"; web 页面关闭浏览器或关闭 tab 页面
|
|
522
|
+
public async handleExceptionExit(event?: any) {
|
|
523
|
+
try {
|
|
524
|
+
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
|
|
525
|
+
const callRole = TUIStore.getData(StoreName.CALL, NAME.CALL_ROLE);
|
|
526
|
+
this._tuiCallEngine?.reportLog?.({ name: 'TUICallkit.handleExceptionExit', data: { callStatus, callRole } });
|
|
527
|
+
|
|
528
|
+
if (callStatus === CallStatus.IDLE) return;
|
|
529
|
+
// 在呼叫状态下,被叫调用 reject,主叫调用 hangup
|
|
530
|
+
if (callStatus === CallStatus.CALLING) {
|
|
531
|
+
if (callRole === CallRole.CALLER) {
|
|
532
|
+
await this?.hangup();
|
|
533
|
+
} else {
|
|
534
|
+
await this?.reject();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (callStatus === CallStatus.CONNECTED) {
|
|
538
|
+
await this?.hangup();
|
|
539
|
+
}
|
|
540
|
+
this?._resetCallStore();
|
|
541
|
+
} catch (error) {
|
|
542
|
+
console.error(`${NAME.PREFIX} handleExceptionExit failed, error: ${error}.`);
|
|
543
|
+
}
|
|
544
|
+
if (event) {
|
|
545
|
+
event.returnValue = '';
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
// ========================【TUICallKit 组件属性设置方法】========================
|
|
549
|
+
public setVideoDisplayMode(displayMode: VideoDisplayMode) {
|
|
550
|
+
TUIStore.update(StoreName.CALL, NAME.DISPLAY_MODE, displayMode);
|
|
551
|
+
}
|
|
552
|
+
public async setVideoResolution(resolution: VideoResolution) {
|
|
553
|
+
try {
|
|
554
|
+
if (!resolution) return;
|
|
555
|
+
TUIStore.update(StoreName.CALL, NAME.VIDEO_RESOLUTION, resolution);
|
|
556
|
+
await this._tuiCallEngine?.setVideoQuality(resolution);
|
|
557
|
+
} catch (error) {
|
|
558
|
+
console.warn(`${NAME.PREFIX}setVideoResolution failed, error: ${error}.`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
// 通话时长更新
|
|
562
|
+
public startTimer(): void {
|
|
563
|
+
if (this._timerId === -1) {
|
|
564
|
+
this._startTimeStamp = performanceNow();
|
|
565
|
+
this._timerId = timer.run(NAME.TIMEOUT, this._updateCallDuration.bind(this), { delay: 1000 });
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
// =========================【private methods for service use】=========================
|
|
569
|
+
// 处理 “呼叫” 抛出的异常
|
|
570
|
+
private _handleCallError(error: any, methodName?: string) {
|
|
571
|
+
this._permissionCheckTimer && clearInterval(this._permissionCheckTimer);
|
|
572
|
+
|
|
573
|
+
if (handleRepeatedCallError(error)) return;
|
|
574
|
+
noDevicePermissionToast(error, CallMediaType.AUDIO, this._tuiCallEngine);
|
|
575
|
+
console.error(`${NAME.PREFIX}${methodName} failed, error: ${error}.`);
|
|
576
|
+
this._resetCallStore();
|
|
577
|
+
throw error;
|
|
578
|
+
}
|
|
579
|
+
private async _updateCallStoreBeforeCall(type: number, remoteUserInfoList: IUserInfo[], groupID?: string): Promise<void> {
|
|
580
|
+
let callTips = CallTips.CALLER_CALLING_MSG;
|
|
581
|
+
if (groupID || TUIStore.getData(StoreName.CALL, NAME.IS_MINIMIZED) || remoteUserInfoList.length > 1) {
|
|
582
|
+
callTips = CallTips.CALLER_GROUP_CALLING_MSG;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
console.warn(`呼叫前更新 call status: ${(!!groupID || remoteUserInfoList.length > 1)}, ${groupID}, ${JSON.stringify(remoteUserInfoList)}`)
|
|
586
|
+
|
|
587
|
+
let updateStoreParams: any = {
|
|
588
|
+
[NAME.CALL_MEDIA_TYPE]: type,
|
|
589
|
+
[NAME.CALL_ROLE]: CallRole.CALLER,
|
|
590
|
+
[NAME.REMOTE_USER_INFO_LIST]: remoteUserInfoList,
|
|
591
|
+
[NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST]: remoteUserInfoList,
|
|
592
|
+
[NAME.IS_GROUP]: (!!groupID || remoteUserInfoList.length > 1),
|
|
593
|
+
[NAME.CALL_TIPS]: callTips,
|
|
594
|
+
[NAME.GROUP_ID]: groupID
|
|
595
|
+
};
|
|
596
|
+
TUIStore.updateStore({ ...updateStoreParams, [NAME.CALL_STATUS]: CallStatus.CALLING }, StoreName.CALL);
|
|
597
|
+
this.statusChanged && this.statusChanged({
|
|
598
|
+
oldStatus: StatusChange.IDLE,
|
|
599
|
+
newStatus: (groupID || remoteUserInfoList.length > 1) ? StatusChange.DIALING_GROUP : StatusChange.DIALING_C2C,
|
|
600
|
+
});
|
|
601
|
+
updateDeviceList(this._tuiCallEngine);;
|
|
602
|
+
const remoteUserInfoLists = await getRemoteUserProfile(remoteUserInfoList.map(obj => obj.userId), this.getTim());
|
|
603
|
+
|
|
604
|
+
if (remoteUserInfoLists.length > 0) {
|
|
605
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoLists);
|
|
606
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoLists);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
private async _updateCallStoreAfterCall(userIdList: string[], response: any) {
|
|
611
|
+
if (response) {
|
|
612
|
+
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true);
|
|
613
|
+
updateRoomIdAndRoomIdType(response?.roomID, response?.strRoomID);
|
|
614
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
615
|
+
if (response.code === 0) {
|
|
616
|
+
this._chatCombine?.callTUIService({ message: response?.data?.message });
|
|
617
|
+
try {
|
|
618
|
+
await this._tuiCallEngine.setVideoQuality(TUIStore.getData(StoreName.CALL, NAME.VIDEO_RESOLUTION));
|
|
619
|
+
} catch (error) {
|
|
620
|
+
console.warn(`${NAME.PREFIX}setVideoQuality failed, error: ${error}.`);
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
this._resetCallStore();
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const isCameraDefaultStateClose = this._getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close;
|
|
627
|
+
(callMediaType === CallMediaType.VIDEO) && !isCameraDefaultStateClose && await this.openCamera(NAME.LOCAL_VIDEO);
|
|
628
|
+
const localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO);
|
|
629
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, { ...localUserInfo, isEnter: true });
|
|
630
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true });
|
|
631
|
+
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini, default open audio
|
|
632
|
+
} else {
|
|
633
|
+
this._permissionCheckTimer && clearInterval(this._permissionCheckTimer);
|
|
634
|
+
this._permissionCheckTimer = null;
|
|
635
|
+
this._resetCallStore();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
private _getFeatureButtonDefaultState(buttonName: FeatureButton) {
|
|
639
|
+
const { button: buttonConfig } = TUIStore.getData(StoreName.CALL, NAME.CUSTOM_UI_CONFIG);
|
|
640
|
+
return buttonConfig?.[buttonName]?.state;
|
|
641
|
+
}
|
|
642
|
+
private _updateCallDuration(): void {
|
|
643
|
+
const callDurationNum = Math.round((performanceNow() - this._startTimeStamp) / 1000); // miniProgram stop timer when background
|
|
644
|
+
const callDurationStr = formatTime(callDurationNum);
|
|
645
|
+
TUIStore.update(StoreName.CALL, NAME.CALL_DURATION, callDurationStr);
|
|
646
|
+
}
|
|
647
|
+
private _stopTimer(): void {
|
|
648
|
+
if (this._timerId !== -1) {
|
|
649
|
+
timer.clearTask(this._timerId);
|
|
650
|
+
this._timerId = -1;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
private _resetCallStore() {
|
|
654
|
+
const oldStatusStr = generateStatusChangeText();
|
|
655
|
+
this._stopTimer();
|
|
656
|
+
// localUserInfo, language 在通话结束后不需要清除
|
|
657
|
+
// callStatus 清除需要通知; isMinimized 也需要通知(basic-vue3 中切小窗关闭后, 再呼叫还是小窗, 因此需要通知到组件侧)
|
|
658
|
+
// isGroup 也不清除(engine 先抛 cancel 事件, 再抛 reject 事件)
|
|
659
|
+
// displayMode、videoResolution 也不能清除, 组件不卸载, 这些属性也需保留, 否则采用默认值.
|
|
660
|
+
// enableFloatWindow 不清除:开启/关闭悬浮窗功能。
|
|
661
|
+
let notResetOrNotifyKeys = Object.keys(CALL_DATA_KEY).filter((key) => {
|
|
662
|
+
switch (CALL_DATA_KEY[key]) {
|
|
663
|
+
case NAME.CALL_STATUS:
|
|
664
|
+
case NAME.LANGUAGE:
|
|
665
|
+
case NAME.IS_GROUP:
|
|
666
|
+
case NAME.DISPLAY_MODE:
|
|
667
|
+
case NAME.VIDEO_RESOLUTION:
|
|
668
|
+
case NAME.ENABLE_FLOAT_WINDOW:
|
|
669
|
+
case NAME.LOCAL_USER_INFO:
|
|
670
|
+
case NAME.IS_SHOW_ENABLE_VIRTUAL_BACKGROUND:
|
|
671
|
+
case NAME.IS_FORCE_USE_V2_API:
|
|
672
|
+
case NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN: {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
default: {
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
notResetOrNotifyKeys = notResetOrNotifyKeys.map(key => CALL_DATA_KEY[key]);
|
|
681
|
+
TUIStore.reset(StoreName.CALL, notResetOrNotifyKeys);
|
|
682
|
+
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
|
|
683
|
+
callStatus !== CallStatus.IDLE && TUIStore.reset(StoreName.CALL, [NAME.CALL_STATUS], true); // callStatus reset need notify
|
|
684
|
+
TUIStore.reset(StoreName.CALL, [NAME.IS_MINIMIZED], true); // isMinimized reset need notify
|
|
685
|
+
TUIStore.reset(StoreName.CALL, [NAME.IS_EAR_PHONE], true); // isEarPhone reset need notify
|
|
686
|
+
TUIStore.reset(StoreName.CALL, [NAME.ENABLE_VIRTUAL_BACKGROUND], true); // ENABLE_VIRTUAL_BACKGROUND reset need notify
|
|
687
|
+
TUIStore.reset(StoreName.CALL, [NAME.IS_MUTE_SPEAKER], true); // IS_MUTE_SPEAKER reset need notify
|
|
688
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, {
|
|
689
|
+
...TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO),
|
|
690
|
+
isVideoAvailable: false,
|
|
691
|
+
isAudioAvailable: false,
|
|
692
|
+
});
|
|
693
|
+
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, {
|
|
694
|
+
...TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN),
|
|
695
|
+
isVideoAvailable: false,
|
|
696
|
+
isAudioAvailable: false,
|
|
697
|
+
});
|
|
698
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, []);
|
|
699
|
+
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, []);
|
|
700
|
+
TUIStore.update(StoreName.CALL, NAME.CAMERA_POSITION, CameraPosition.FRONT);
|
|
701
|
+
|
|
702
|
+
const newStatusStr = generateStatusChangeText();
|
|
703
|
+
if (oldStatusStr !== newStatusStr) {
|
|
704
|
+
this.statusChanged && this.statusChanged({ oldStatus: oldStatusStr, newStatus: newStatusStr });
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
// =========================【Calling the Chat SDK APi】=========================
|
|
708
|
+
// 获取群成员
|
|
709
|
+
public async getGroupMemberList(count: number, offset: number) {
|
|
710
|
+
const groupID = TUIStore.getData(StoreName.CALL, NAME.GROUP_ID);
|
|
711
|
+
let groupMemberList = await getGroupMemberList(groupID, this.getTim(), count, offset);
|
|
712
|
+
return groupMemberList;
|
|
713
|
+
}
|
|
714
|
+
// 获取群信息
|
|
715
|
+
public async getGroupProfile() {
|
|
716
|
+
const groupID: string = TUIStore.getData(StoreName.CALL, NAME.GROUP_ID);
|
|
717
|
+
return await getGroupProfile(groupID, this.getTim());
|
|
718
|
+
}
|
|
719
|
+
// =========================【监听 TUIStore 中的状态及处理】=========================
|
|
720
|
+
private _handleCallStatusChange = async (value: CallStatus) => {
|
|
721
|
+
try {
|
|
722
|
+
const bellParams: IBellParams = {
|
|
723
|
+
callRole: TUIStore.getData(StoreName.CALL, NAME.CALL_ROLE),
|
|
724
|
+
callStatus: TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS),
|
|
725
|
+
};
|
|
726
|
+
this._bellContext.setBellProperties(bellParams);
|
|
727
|
+
if (value === CallStatus.CALLING) {
|
|
728
|
+
await this?._bellContext?.play();
|
|
729
|
+
} else {
|
|
730
|
+
// 状态变更通知
|
|
731
|
+
if (value === CallStatus.CONNECTED) {
|
|
732
|
+
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP);
|
|
733
|
+
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE);
|
|
734
|
+
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST);
|
|
735
|
+
const oldStatus = isGroup ? StatusChange.DIALING_GROUP : StatusChange.DIALING_C2C;
|
|
736
|
+
TUIStore.update(StoreName.CALL, NAME.CALL_TIPS, '');
|
|
737
|
+
this.statusChanged && this.statusChanged({ oldStatus, newStatus: generateStatusChangeText() });
|
|
738
|
+
if (!isGroup && callMediaType === CallMediaType.VIDEO) {
|
|
739
|
+
this.switchScreen(remoteUserInfoList[0].domId);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
await this?._bellContext?.stop();
|
|
743
|
+
}
|
|
744
|
+
} catch (error) {
|
|
745
|
+
console.warn(`${NAME.PREFIX}handleCallStatusChange, ${error}.`);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
private _watchTUIStore() {
|
|
749
|
+
TUIStore?.watch(StoreName.CALL, {
|
|
750
|
+
[NAME.CALL_STATUS]: this._handleCallStatusChange,
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
private _unwatchTUIStore() {
|
|
754
|
+
TUIStore?.unwatch(StoreName.CALL, {
|
|
755
|
+
[NAME.CALL_STATUS]: this._handleCallStatusChange,
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
// =========================【融合 chat 】=========================
|
|
759
|
+
public bindTUICore(TUICore: any) {
|
|
760
|
+
this._TUICore = TUICore;
|
|
761
|
+
}
|
|
762
|
+
// =========================【set、get methods】=========================
|
|
763
|
+
public getTim() {
|
|
764
|
+
if (this._tim) return this._tim;
|
|
765
|
+
if (!this._tuiCallEngine) {
|
|
766
|
+
console.warn(`${NAME.PREFIX}getTim warning: _tuiCallEngine Instance is not available.`);
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
return this._tuiCallEngine?.tim || this._tuiCallEngine?.getTim(); // mini support getTim interface
|
|
770
|
+
}
|
|
771
|
+
public setIsFromChat(isFromChat: boolean) {
|
|
772
|
+
this._isFromChat = isFromChat;
|
|
773
|
+
}
|
|
774
|
+
public setCurrentGroupId(groupId: string) {
|
|
775
|
+
this._currentGroupId = groupId;
|
|
776
|
+
}
|
|
777
|
+
public getCurrentGroupId() {
|
|
778
|
+
return this._currentGroupId;
|
|
779
|
+
}
|
|
780
|
+
public setDefaultOfflinePushInfo(offlinePushInfo) {
|
|
781
|
+
this._offlinePushInfo = offlinePushInfo;
|
|
782
|
+
}
|
|
783
|
+
public getDefaultOfflinePushInfo() {
|
|
784
|
+
const localUserInfo: IUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO);
|
|
785
|
+
if (this._offlinePushInfo) {
|
|
786
|
+
return this._offlinePushInfo;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
return {
|
|
790
|
+
title: localUserInfo?.displayUserInfo || '',
|
|
791
|
+
description: t('you have a new call'),
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
public async getCallMessage(message) {
|
|
795
|
+
return await this._chatCombine.getCallKitMessage(message, this.getTim());
|
|
796
|
+
}
|
|
797
|
+
}
|