@signalwire/js 3.29.2 → 4.0.0-beta.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/dist/base-A5AZTrAd.d.cts +23 -0
- package/dist/base-A5AZTrAd.d.cts.map +1 -0
- package/dist/base-aVtoG8Wk.d.mts +23 -0
- package/dist/base-aVtoG8Wk.d.mts.map +1 -0
- package/dist/browser.mjs +16625 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/browser.umd.js +16646 -0
- package/dist/browser.umd.js.map +1 -0
- package/dist/index.cjs +6210 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2690 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +2690 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6194 -0
- package/dist/index.mjs.map +1 -0
- package/dist/operators/index.cjs +6 -0
- package/dist/operators/index.d.cts +109 -0
- package/dist/operators/index.d.cts.map +1 -0
- package/dist/operators/index.d.mts +109 -0
- package/dist/operators/index.d.mts.map +1 -0
- package/dist/operators/index.mjs +3 -0
- package/dist/operators-BHQMSEzq.mjs +371 -0
- package/dist/operators-BHQMSEzq.mjs.map +1 -0
- package/dist/operators-DT4UB24-.cjs +596 -0
- package/dist/operators-DT4UB24-.cjs.map +1 -0
- package/package.json +73 -37
- package/README.md +0 -40
- package/dist/core/src/BaseClient.d.ts +0 -19
- package/dist/core/src/BaseClient.d.ts.map +0 -1
- package/dist/core/src/BaseComponent.d.ts +0 -101
- package/dist/core/src/BaseComponent.d.ts.map +0 -1
- package/dist/core/src/BaseComponent.test.d.ts +0 -2
- package/dist/core/src/BaseComponent.test.d.ts.map +0 -1
- package/dist/core/src/BaseConsumer.d.ts +0 -18
- package/dist/core/src/BaseConsumer.d.ts.map +0 -1
- package/dist/core/src/BaseConsumer.test.d.ts +0 -2
- package/dist/core/src/BaseConsumer.test.d.ts.map +0 -1
- package/dist/core/src/BaseJWTSession.d.ts +0 -47
- package/dist/core/src/BaseJWTSession.d.ts.map +0 -1
- package/dist/core/src/BaseJWTSession.test.d.ts +0 -2
- package/dist/core/src/BaseJWTSession.test.d.ts.map +0 -1
- package/dist/core/src/BaseSession.d.ts +0 -117
- package/dist/core/src/BaseSession.d.ts.map +0 -1
- package/dist/core/src/BaseSession.test.d.ts +0 -2
- package/dist/core/src/BaseSession.test.d.ts.map +0 -1
- package/dist/core/src/CustomErrors.d.ts +0 -17
- package/dist/core/src/CustomErrors.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCConnect.d.ts +0 -42
- package/dist/core/src/RPCMessages/RPCConnect.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCDisconnect.d.ts +0 -8
- package/dist/core/src/RPCMessages/RPCDisconnect.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCEventAck.d.ts +0 -8
- package/dist/core/src/RPCMessages/RPCEventAck.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCExecute.d.ts +0 -16
- package/dist/core/src/RPCMessages/RPCExecute.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCPing.d.ts +0 -16
- package/dist/core/src/RPCMessages/RPCPing.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/RPCReauthenticate.d.ts +0 -13
- package/dist/core/src/RPCMessages/RPCReauthenticate.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/VertoMessages.d.ts +0 -84
- package/dist/core/src/RPCMessages/VertoMessages.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/helpers.d.ts +0 -31
- package/dist/core/src/RPCMessages/helpers.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/index.d.ts +0 -9
- package/dist/core/src/RPCMessages/index.d.ts.map +0 -1
- package/dist/core/src/RPCMessages/index.test.d.ts +0 -2
- package/dist/core/src/RPCMessages/index.test.d.ts.map +0 -1
- package/dist/core/src/chat/BaseChat.d.ts +0 -23
- package/dist/core/src/chat/BaseChat.d.ts.map +0 -1
- package/dist/core/src/chat/ChatMember.d.ts +0 -15
- package/dist/core/src/chat/ChatMember.d.ts.map +0 -1
- package/dist/core/src/chat/ChatMessage.d.ts +0 -10
- package/dist/core/src/chat/ChatMessage.d.ts.map +0 -1
- package/dist/core/src/chat/applyCommonMethods.d.ts +0 -22
- package/dist/core/src/chat/applyCommonMethods.d.ts.map +0 -1
- package/dist/core/src/chat/index.d.ts +0 -6
- package/dist/core/src/chat/index.d.ts.map +0 -1
- package/dist/core/src/chat/methods.d.ts +0 -31
- package/dist/core/src/chat/methods.d.ts.map +0 -1
- package/dist/core/src/chat/utils/index.d.ts +0 -3
- package/dist/core/src/chat/utils/index.d.ts.map +0 -1
- package/dist/core/src/chat/utils/toInternalChatChannels.d.ts +0 -3
- package/dist/core/src/chat/utils/toInternalChatChannels.d.ts.map +0 -1
- package/dist/core/src/chat/utils/toInternalChatChannels.test.d.ts +0 -2
- package/dist/core/src/chat/utils/toInternalChatChannels.test.d.ts.map +0 -1
- package/dist/core/src/chat/workers/chatWorker.d.ts +0 -4
- package/dist/core/src/chat/workers/chatWorker.d.ts.map +0 -1
- package/dist/core/src/chat/workers/index.d.ts +0 -2
- package/dist/core/src/chat/workers/index.d.ts.map +0 -1
- package/dist/core/src/index.d.ts +0 -45
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/index.test.d.ts +0 -1
- package/dist/core/src/index.test.d.ts.map +0 -1
- package/dist/core/src/memberPosition/index.d.ts +0 -2
- package/dist/core/src/memberPosition/index.d.ts.map +0 -1
- package/dist/core/src/memberPosition/workers.d.ts +0 -13
- package/dist/core/src/memberPosition/workers.d.ts.map +0 -1
- package/dist/core/src/memberPosition/workers.test.d.ts +0 -2
- package/dist/core/src/memberPosition/workers.test.d.ts.map +0 -1
- package/dist/core/src/pubSub/BasePubSub.d.ts +0 -43
- package/dist/core/src/pubSub/BasePubSub.d.ts.map +0 -1
- package/dist/core/src/pubSub/PubSubMessage.d.ts +0 -19
- package/dist/core/src/pubSub/PubSubMessage.d.ts.map +0 -1
- package/dist/core/src/pubSub/index.d.ts +0 -3
- package/dist/core/src/pubSub/index.d.ts.map +0 -1
- package/dist/core/src/pubSub/workers/index.d.ts +0 -2
- package/dist/core/src/pubSub/workers/index.d.ts.map +0 -1
- package/dist/core/src/pubSub/workers/pubSubWorker.d.ts +0 -4
- package/dist/core/src/pubSub/workers/pubSubWorker.d.ts.map +0 -1
- package/dist/core/src/redux/actions.d.ts +0 -25
- package/dist/core/src/redux/actions.d.ts.map +0 -1
- package/dist/core/src/redux/connect.d.ts +0 -23
- package/dist/core/src/redux/connect.d.ts.map +0 -1
- package/dist/core/src/redux/connect.test.d.ts +0 -2
- package/dist/core/src/redux/connect.test.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSaga.d.ts +0 -4
- package/dist/core/src/redux/features/component/componentSaga.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSaga.test.d.ts +0 -2
- package/dist/core/src/redux/features/component/componentSaga.test.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSelectors.d.ts +0 -7
- package/dist/core/src/redux/features/component/componentSelectors.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSelectors.test.d.ts +0 -2
- package/dist/core/src/redux/features/component/componentSelectors.test.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSlice.d.ts +0 -2319
- package/dist/core/src/redux/features/component/componentSlice.d.ts.map +0 -1
- package/dist/core/src/redux/features/component/componentSlice.test.d.ts +0 -2
- package/dist/core/src/redux/features/component/componentSlice.test.d.ts.map +0 -1
- package/dist/core/src/redux/features/index.d.ts +0 -3
- package/dist/core/src/redux/features/index.d.ts.map +0 -1
- package/dist/core/src/redux/features/session/sessionSaga.d.ts +0 -11
- package/dist/core/src/redux/features/session/sessionSaga.d.ts.map +0 -1
- package/dist/core/src/redux/features/session/sessionSelectors.d.ts +0 -9
- package/dist/core/src/redux/features/session/sessionSelectors.d.ts.map +0 -1
- package/dist/core/src/redux/features/session/sessionSlice.d.ts +0 -521
- package/dist/core/src/redux/features/session/sessionSlice.d.ts.map +0 -1
- package/dist/core/src/redux/features/session/sessionSlice.test.d.ts +0 -2
- package/dist/core/src/redux/features/session/sessionSlice.test.d.ts.map +0 -1
- package/dist/core/src/redux/index.d.ts +0 -31
- package/dist/core/src/redux/index.d.ts.map +0 -1
- package/dist/core/src/redux/interfaces.d.ts +0 -87
- package/dist/core/src/redux/interfaces.d.ts.map +0 -1
- package/dist/core/src/redux/rootReducer.d.ts +0 -457
- package/dist/core/src/redux/rootReducer.d.ts.map +0 -1
- package/dist/core/src/redux/rootSaga.d.ts +0 -40
- package/dist/core/src/redux/rootSaga.d.ts.map +0 -1
- package/dist/core/src/redux/rootSaga.test.d.ts +0 -2
- package/dist/core/src/redux/rootSaga.test.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/configureStore.d.ts +0 -77
- package/dist/core/src/redux/toolkit/configureStore.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/createAction.d.ts +0 -180
- package/dist/core/src/redux/toolkit/createAction.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/createReducer.d.ts +0 -42
- package/dist/core/src/redux/toolkit/createReducer.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/createSlice.d.ts +0 -142
- package/dist/core/src/redux/toolkit/createSlice.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/devtoolsExtension.d.ts +0 -185
- package/dist/core/src/redux/toolkit/devtoolsExtension.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/getDefaultMiddleware.d.ts +0 -12
- package/dist/core/src/redux/toolkit/getDefaultMiddleware.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/index.d.ts +0 -13
- package/dist/core/src/redux/toolkit/index.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/isPlainObject.d.ts +0 -12
- package/dist/core/src/redux/toolkit/isPlainObject.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/mapBuilders.d.ts +0 -38
- package/dist/core/src/redux/toolkit/mapBuilders.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/tsHelpers.d.ts +0 -51
- package/dist/core/src/redux/toolkit/tsHelpers.d.ts.map +0 -1
- package/dist/core/src/redux/toolkit/utils.d.ts +0 -11
- package/dist/core/src/redux/toolkit/utils.d.ts.map +0 -1
- package/dist/core/src/redux/utils/createDestroyableSlice.d.ts +0 -9
- package/dist/core/src/redux/utils/createDestroyableSlice.d.ts.map +0 -1
- package/dist/core/src/redux/utils/createDestroyableSlice.test.d.ts +0 -2
- package/dist/core/src/redux/utils/createDestroyableSlice.test.d.ts.map +0 -1
- package/dist/core/src/redux/utils/sagaHelpers.d.ts +0 -5
- package/dist/core/src/redux/utils/sagaHelpers.d.ts.map +0 -1
- package/dist/core/src/redux/utils/useInstanceMap.d.ts +0 -3
- package/dist/core/src/redux/utils/useInstanceMap.d.ts.map +0 -1
- package/dist/core/src/redux/utils/useSession.d.ts +0 -16
- package/dist/core/src/redux/utils/useSession.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionPlayback.d.ts +0 -40
- package/dist/core/src/rooms/RoomSessionPlayback.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionPlayback.test.d.ts +0 -2
- package/dist/core/src/rooms/RoomSessionPlayback.test.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionRecording.d.ts +0 -30
- package/dist/core/src/rooms/RoomSessionRecording.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionRecording.test.d.ts +0 -2
- package/dist/core/src/rooms/RoomSessionRecording.test.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionStream.d.ts +0 -29
- package/dist/core/src/rooms/RoomSessionStream.d.ts.map +0 -1
- package/dist/core/src/rooms/RoomSessionStream.test.d.ts +0 -2
- package/dist/core/src/rooms/RoomSessionStream.test.d.ts.map +0 -1
- package/dist/core/src/rooms/index.d.ts +0 -11
- package/dist/core/src/rooms/index.d.ts.map +0 -1
- package/dist/core/src/rooms/methods.d.ts +0 -179
- package/dist/core/src/rooms/methods.d.ts.map +0 -1
- package/dist/core/src/rooms/methods.test.d.ts +0 -2
- package/dist/core/src/rooms/methods.test.d.ts.map +0 -1
- package/dist/core/src/setupTests.d.ts +0 -1
- package/dist/core/src/setupTests.d.ts.map +0 -1
- package/dist/core/src/testUtils.d.ts +0 -54
- package/dist/core/src/testUtils.d.ts.map +0 -1
- package/dist/core/src/types/cantina.d.ts +0 -82
- package/dist/core/src/types/cantina.d.ts.map +0 -1
- package/dist/core/src/types/chat.d.ts +0 -270
- package/dist/core/src/types/chat.d.ts.map +0 -1
- package/dist/core/src/types/common.d.ts +0 -34
- package/dist/core/src/types/common.d.ts.map +0 -1
- package/dist/core/src/types/conversation.d.ts +0 -33
- package/dist/core/src/types/conversation.d.ts.map +0 -1
- package/dist/core/src/types/fabric.d.ts +0 -15
- package/dist/core/src/types/fabric.d.ts.map +0 -1
- package/dist/core/src/types/fabricLayout.d.ts +0 -25
- package/dist/core/src/types/fabricLayout.d.ts.map +0 -1
- package/dist/core/src/types/fabricMember.d.ts +0 -148
- package/dist/core/src/types/fabricMember.d.ts.map +0 -1
- package/dist/core/src/types/fabricRoomSession.d.ts +0 -631
- package/dist/core/src/types/fabricRoomSession.d.ts.map +0 -1
- package/dist/core/src/types/index.d.ts +0 -276
- package/dist/core/src/types/index.d.ts.map +0 -1
- package/dist/core/src/types/messaging.d.ts +0 -90
- package/dist/core/src/types/messaging.d.ts.map +0 -1
- package/dist/core/src/types/pubSub.d.ts +0 -123
- package/dist/core/src/types/pubSub.d.ts.map +0 -1
- package/dist/core/src/types/task.d.ts +0 -36
- package/dist/core/src/types/task.d.ts.map +0 -1
- package/dist/core/src/types/utils.d.ts +0 -71
- package/dist/core/src/types/utils.d.ts.map +0 -1
- package/dist/core/src/types/video.d.ts +0 -62
- package/dist/core/src/types/video.d.ts.map +0 -1
- package/dist/core/src/types/videoLayout.d.ts +0 -75
- package/dist/core/src/types/videoLayout.d.ts.map +0 -1
- package/dist/core/src/types/videoMember.d.ts +0 -384
- package/dist/core/src/types/videoMember.d.ts.map +0 -1
- package/dist/core/src/types/videoPlayback.d.ts +0 -123
- package/dist/core/src/types/videoPlayback.d.ts.map +0 -1
- package/dist/core/src/types/videoRecording.d.ts +0 -114
- package/dist/core/src/types/videoRecording.d.ts.map +0 -1
- package/dist/core/src/types/videoRoomDevice.d.ts +0 -23
- package/dist/core/src/types/videoRoomDevice.d.ts.map +0 -1
- package/dist/core/src/types/videoRoomSession.d.ts +0 -921
- package/dist/core/src/types/videoRoomSession.d.ts.map +0 -1
- package/dist/core/src/types/videoStream.d.ts +0 -104
- package/dist/core/src/types/videoStream.d.ts.map +0 -1
- package/dist/core/src/types/voice.d.ts +0 -15
- package/dist/core/src/types/voice.d.ts.map +0 -1
- package/dist/core/src/types/voiceCall.d.ts +0 -253
- package/dist/core/src/types/voiceCall.d.ts.map +0 -1
- package/dist/core/src/types/voiceCollect.d.ts +0 -166
- package/dist/core/src/types/voiceCollect.d.ts.map +0 -1
- package/dist/core/src/types/voiceConnect.d.ts +0 -77
- package/dist/core/src/types/voiceConnect.d.ts.map +0 -1
- package/dist/core/src/types/voiceDetect.d.ts +0 -127
- package/dist/core/src/types/voiceDetect.d.ts.map +0 -1
- package/dist/core/src/types/voicePlayback.d.ts +0 -141
- package/dist/core/src/types/voicePlayback.d.ts.map +0 -1
- package/dist/core/src/types/voicePrompt.d.ts +0 -105
- package/dist/core/src/types/voicePrompt.d.ts.map +0 -1
- package/dist/core/src/types/voiceRecording.d.ts +0 -107
- package/dist/core/src/types/voiceRecording.d.ts.map +0 -1
- package/dist/core/src/types/voiceSendDigits.d.ts +0 -21
- package/dist/core/src/types/voiceSendDigits.d.ts.map +0 -1
- package/dist/core/src/types/voiceTap.d.ts +0 -116
- package/dist/core/src/types/voiceTap.d.ts.map +0 -1
- package/dist/core/src/utils/EventEmitter.d.ts +0 -9
- package/dist/core/src/utils/EventEmitter.d.ts.map +0 -1
- package/dist/core/src/utils/EventEmitter.test.d.ts +0 -2
- package/dist/core/src/utils/EventEmitter.test.d.ts.map +0 -1
- package/dist/core/src/utils/SWCloseEvent.d.ts +0 -18
- package/dist/core/src/utils/SWCloseEvent.d.ts.map +0 -1
- package/dist/core/src/utils/asyncRetry.d.ts +0 -18
- package/dist/core/src/utils/asyncRetry.d.ts.map +0 -1
- package/dist/core/src/utils/asyncRetry.test.d.ts +0 -2
- package/dist/core/src/utils/asyncRetry.test.d.ts.map +0 -1
- package/dist/core/src/utils/common.d.ts +0 -9
- package/dist/core/src/utils/common.d.ts.map +0 -1
- package/dist/core/src/utils/constants.d.ts +0 -44
- package/dist/core/src/utils/constants.d.ts.map +0 -1
- package/dist/core/src/utils/debounce.d.ts +0 -8
- package/dist/core/src/utils/debounce.d.ts.map +0 -1
- package/dist/core/src/utils/eventUtils.d.ts +0 -2
- package/dist/core/src/utils/eventUtils.d.ts.map +0 -1
- package/dist/core/src/utils/extendComponent.d.ts +0 -4
- package/dist/core/src/utils/extendComponent.d.ts.map +0 -1
- package/dist/core/src/utils/extendComponent.test.d.ts +0 -2
- package/dist/core/src/utils/extendComponent.test.d.ts.map +0 -1
- package/dist/core/src/utils/index.d.ts +0 -47
- package/dist/core/src/utils/index.d.ts.map +0 -1
- package/dist/core/src/utils/index.test.d.ts +0 -2
- package/dist/core/src/utils/index.test.d.ts.map +0 -1
- package/dist/core/src/utils/interfaces.d.ts +0 -296
- package/dist/core/src/utils/interfaces.d.ts.map +0 -1
- package/dist/core/src/utils/logger.d.ts +0 -6
- package/dist/core/src/utils/logger.d.ts.map +0 -1
- package/dist/core/src/utils/logger.test.d.ts +0 -2
- package/dist/core/src/utils/logger.test.d.ts.map +0 -1
- package/dist/core/src/utils/parseRPCResponse.d.ts +0 -10
- package/dist/core/src/utils/parseRPCResponse.d.ts.map +0 -1
- package/dist/core/src/utils/parseRPCResponse.test.d.ts +0 -2
- package/dist/core/src/utils/parseRPCResponse.test.d.ts.map +0 -1
- package/dist/core/src/utils/storage/index.d.ts +0 -11
- package/dist/core/src/utils/storage/index.d.ts.map +0 -1
- package/dist/core/src/utils/storage/index.native.d.ts +0 -11
- package/dist/core/src/utils/storage/index.native.d.ts.map +0 -1
- package/dist/core/src/utils/toExternalJSON.d.ts +0 -34
- package/dist/core/src/utils/toExternalJSON.d.ts.map +0 -1
- package/dist/core/src/utils/toExternalJSON.test.d.ts +0 -2
- package/dist/core/src/utils/toExternalJSON.test.d.ts.map +0 -1
- package/dist/core/src/utils/toInternalAction.d.ts +0 -7
- package/dist/core/src/utils/toInternalAction.d.ts.map +0 -1
- package/dist/core/src/utils/toInternalAction.test.d.ts +0 -2
- package/dist/core/src/utils/toInternalAction.test.d.ts.map +0 -1
- package/dist/core/src/utils/toInternalEventName.d.ts +0 -8
- package/dist/core/src/utils/toInternalEventName.d.ts.map +0 -1
- package/dist/core/src/utils/toInternalEventName.test.d.ts +0 -2
- package/dist/core/src/utils/toInternalEventName.test.d.ts.map +0 -1
- package/dist/core/src/utils/toSnakeCaseKeys.d.ts +0 -7
- package/dist/core/src/utils/toSnakeCaseKeys.d.ts.map +0 -1
- package/dist/core/src/utils/toSnakeCaseKeys.test.d.ts +0 -2
- package/dist/core/src/utils/toSnakeCaseKeys.test.d.ts.map +0 -1
- package/dist/core/src/workers/executeActionWorker.d.ts +0 -7
- package/dist/core/src/workers/executeActionWorker.d.ts.map +0 -1
- package/dist/core/src/workers/index.d.ts +0 -2
- package/dist/core/src/workers/index.d.ts.map +0 -1
- package/dist/index.esm.js +0 -4673
- package/dist/index.esm.js.map +0 -7
- package/dist/index.js +0 -4655
- package/dist/index.js.map +0 -7
- package/dist/index.umd.js +0 -31
- package/dist/index.umd.js.map +0 -1
- package/dist/js/src/BaseRoomSession.d.ts +0 -52
- package/dist/js/src/BaseRoomSession.d.ts.map +0 -1
- package/dist/js/src/Client.d.ts +0 -38
- package/dist/js/src/Client.d.ts.map +0 -1
- package/dist/js/src/JWTSession.d.ts +0 -31
- package/dist/js/src/JWTSession.d.ts.map +0 -1
- package/dist/js/src/RoomSessionDevice.d.ts +0 -30
- package/dist/js/src/RoomSessionDevice.d.ts.map +0 -1
- package/dist/js/src/RoomSessionScreenShare.d.ts +0 -26
- package/dist/js/src/RoomSessionScreenShare.d.ts.map +0 -1
- package/dist/js/src/VideoOverlays.d.ts +0 -42
- package/dist/js/src/VideoOverlays.d.ts.map +0 -1
- package/dist/js/src/buildVideoElement.d.ts +0 -18
- package/dist/js/src/buildVideoElement.d.ts.map +0 -1
- package/dist/js/src/cantina/VideoManager.d.ts +0 -16
- package/dist/js/src/cantina/VideoManager.d.ts.map +0 -1
- package/dist/js/src/cantina/index.d.ts +0 -2
- package/dist/js/src/cantina/index.d.ts.map +0 -1
- package/dist/js/src/cantina/workers/index.d.ts +0 -2
- package/dist/js/src/cantina/workers/index.d.ts.map +0 -1
- package/dist/js/src/cantina/workers/videoManagerRoomWorker.d.ts +0 -4
- package/dist/js/src/cantina/workers/videoManagerRoomWorker.d.ts.map +0 -1
- package/dist/js/src/cantina/workers/videoManagerRoomsWorker.d.ts +0 -4
- package/dist/js/src/cantina/workers/videoManagerRoomsWorker.d.ts.map +0 -1
- package/dist/js/src/cantina/workers/videoManagerWorker.d.ts +0 -7
- package/dist/js/src/cantina/workers/videoManagerWorker.d.ts.map +0 -1
- package/dist/js/src/chat/Client.d.ts +0 -46
- package/dist/js/src/chat/Client.d.ts.map +0 -1
- package/dist/js/src/chat/index.d.ts +0 -5
- package/dist/js/src/chat/index.d.ts.map +0 -1
- package/dist/js/src/createClient.d.ts +0 -26
- package/dist/js/src/createClient.d.ts.map +0 -1
- package/dist/js/src/createRoomObject.d.ts +0 -38
- package/dist/js/src/createRoomObject.d.ts.map +0 -1
- package/dist/js/src/fabric/FabricRoomSession.d.ts +0 -80
- package/dist/js/src/fabric/FabricRoomSession.d.ts.map +0 -1
- package/dist/js/src/fabric/FabricRoomSessionMember.d.ts +0 -46
- package/dist/js/src/fabric/FabricRoomSessionMember.d.ts.map +0 -1
- package/dist/js/src/fabric/HTTPClient.d.ts +0 -16
- package/dist/js/src/fabric/HTTPClient.d.ts.map +0 -1
- package/dist/js/src/fabric/IncomingCallManager.d.ts +0 -19
- package/dist/js/src/fabric/IncomingCallManager.d.ts.map +0 -1
- package/dist/js/src/fabric/SATSession.d.ts +0 -25
- package/dist/js/src/fabric/SATSession.d.ts.map +0 -1
- package/dist/js/src/fabric/SignalWire.d.ts +0 -3
- package/dist/js/src/fabric/SignalWire.d.ts.map +0 -1
- package/dist/js/src/fabric/WSClient.d.ts +0 -33
- package/dist/js/src/fabric/WSClient.d.ts.map +0 -1
- package/dist/js/src/fabric/createHttpClient.d.ts +0 -22
- package/dist/js/src/fabric/createHttpClient.d.ts.map +0 -1
- package/dist/js/src/fabric/createWSClient.d.ts +0 -38
- package/dist/js/src/fabric/createWSClient.d.ts.map +0 -1
- package/dist/js/src/fabric/index.d.ts +0 -15
- package/dist/js/src/fabric/index.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/address.d.ts +0 -37
- package/dist/js/src/fabric/interfaces/address.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/capabilities.d.ts +0 -29
- package/dist/js/src/fabric/interfaces/capabilities.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/conversation.d.ts +0 -105
- package/dist/js/src/fabric/interfaces/conversation.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/device.d.ts +0 -18
- package/dist/js/src/fabric/interfaces/device.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/httpClient.d.ts +0 -41
- package/dist/js/src/fabric/interfaces/httpClient.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/incomingCallManager.d.ts +0 -30
- package/dist/js/src/fabric/interfaces/incomingCallManager.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/index.d.ts +0 -71
- package/dist/js/src/fabric/interfaces/index.d.ts.map +0 -1
- package/dist/js/src/fabric/interfaces/wsClient.d.ts +0 -132
- package/dist/js/src/fabric/interfaces/wsClient.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/capabilitiesHelpers.d.ts +0 -28
- package/dist/js/src/fabric/utils/capabilitiesHelpers.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/constants.d.ts +0 -5
- package/dist/js/src/fabric/utils/constants.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/eventMappers.d.ts +0 -151
- package/dist/js/src/fabric/utils/eventMappers.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/typeGuard.d.ts +0 -6
- package/dist/js/src/fabric/utils/typeGuard.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/validationProxy.d.ts +0 -13
- package/dist/js/src/fabric/utils/validationProxy.d.ts.map +0 -1
- package/dist/js/src/fabric/utils/validators.d.ts +0 -20
- package/dist/js/src/fabric/utils/validators.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts +0 -4
- package/dist/js/src/fabric/workers/callJoinWorker.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts +0 -4
- package/dist/js/src/fabric/workers/callLeftWorker.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/callSegmentWorker.d.ts +0 -4
- package/dist/js/src/fabric/workers/callSegmentWorker.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/fabricMemberWorker.d.ts +0 -4
- package/dist/js/src/fabric/workers/fabricMemberWorker.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/fabricWorker.d.ts +0 -7
- package/dist/js/src/fabric/workers/fabricWorker.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/index.d.ts +0 -3
- package/dist/js/src/fabric/workers/index.d.ts.map +0 -1
- package/dist/js/src/fabric/workers/wsClientWorker.d.ts +0 -4
- package/dist/js/src/fabric/workers/wsClientWorker.d.ts.map +0 -1
- package/dist/js/src/features/actions.d.ts +0 -2
- package/dist/js/src/features/actions.d.ts.map +0 -1
- package/dist/js/src/features/mediaElements/mediaElementsSagas.d.ts +0 -7
- package/dist/js/src/features/mediaElements/mediaElementsSagas.d.ts.map +0 -1
- package/dist/js/src/index.d.ts +0 -87
- package/dist/js/src/index.d.ts.map +0 -1
- package/dist/js/src/joinRoom.d.ts +0 -24
- package/dist/js/src/joinRoom.d.ts.map +0 -1
- package/dist/js/src/pubSub/Client.d.ts +0 -46
- package/dist/js/src/pubSub/Client.d.ts.map +0 -1
- package/dist/js/src/pubSub/index.d.ts +0 -6
- package/dist/js/src/pubSub/index.d.ts.map +0 -1
- package/dist/js/src/setupTests.d.ts +0 -2
- package/dist/js/src/setupTests.d.ts.map +0 -1
- package/dist/js/src/testUtils.d.ts +0 -77
- package/dist/js/src/testUtils.d.ts.map +0 -1
- package/dist/js/src/utils/CloseEvent.d.ts +0 -7
- package/dist/js/src/utils/CloseEvent.d.ts.map +0 -1
- package/dist/js/src/utils/audioElement.d.ts +0 -6
- package/dist/js/src/utils/audioElement.d.ts.map +0 -1
- package/dist/js/src/utils/constants.d.ts +0 -2
- package/dist/js/src/utils/constants.d.ts.map +0 -1
- package/dist/js/src/utils/interfaces/base.d.ts +0 -55
- package/dist/js/src/utils/interfaces/base.d.ts.map +0 -1
- package/dist/js/src/utils/interfaces/fabric.d.ts +0 -71
- package/dist/js/src/utils/interfaces/fabric.d.ts.map +0 -1
- package/dist/js/src/utils/interfaces/index.d.ts +0 -4
- package/dist/js/src/utils/interfaces/index.d.ts.map +0 -1
- package/dist/js/src/utils/interfaces/video.d.ts +0 -307
- package/dist/js/src/utils/interfaces/video.d.ts.map +0 -1
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts +0 -9
- package/dist/js/src/utils/makeQueryParamsUrl.d.ts.map +0 -1
- package/dist/js/src/utils/paginatedResult.d.ts +0 -12
- package/dist/js/src/utils/paginatedResult.d.ts.map +0 -1
- package/dist/js/src/utils/roomSession.d.ts +0 -26
- package/dist/js/src/utils/roomSession.d.ts.map +0 -1
- package/dist/js/src/utils/storage.d.ts +0 -10
- package/dist/js/src/utils/storage.d.ts.map +0 -1
- package/dist/js/src/utils/videoElement.d.ts +0 -35
- package/dist/js/src/utils/videoElement.d.ts.map +0 -1
- package/dist/js/src/video/RoomSession.d.ts +0 -38
- package/dist/js/src/video/RoomSession.d.ts.map +0 -1
- package/dist/js/src/video/VideoRoomSession.d.ts +0 -57
- package/dist/js/src/video/VideoRoomSession.d.ts.map +0 -1
- package/dist/js/src/video/index.d.ts +0 -16
- package/dist/js/src/video/index.d.ts.map +0 -1
- package/dist/js/src/video/workers/childMemberJoinedWorker.d.ts +0 -10
- package/dist/js/src/video/workers/childMemberJoinedWorker.d.ts.map +0 -1
- package/dist/js/src/video/workers/index.d.ts +0 -7
- package/dist/js/src/video/workers/index.d.ts.map +0 -1
- package/dist/js/src/video/workers/memberListUpdatedWorker.d.ts +0 -14
- package/dist/js/src/video/workers/memberListUpdatedWorker.d.ts.map +0 -1
- package/dist/js/src/video/workers/videoPlaybackWorker.d.ts +0 -4
- package/dist/js/src/video/workers/videoPlaybackWorker.d.ts.map +0 -1
- package/dist/js/src/video/workers/videoRecordWorker.d.ts +0 -4
- package/dist/js/src/video/workers/videoRecordWorker.d.ts.map +0 -1
- package/dist/js/src/video/workers/videoStreamWorker.d.ts +0 -4
- package/dist/js/src/video/workers/videoStreamWorker.d.ts.map +0 -1
- package/dist/js/src/video/workers/videoWorker.d.ts +0 -7
- package/dist/js/src/video/workers/videoWorker.d.ts.map +0 -1
- package/dist/js/src/webrtc.d.ts +0 -3
- package/dist/js/src/webrtc.d.ts.map +0 -1
- package/dist/js/tsconfig.build.tsbuildinfo +0 -1
- package/dist/webrtc/src/BaseConnection.d.ts +0 -232
- package/dist/webrtc/src/BaseConnection.d.ts.map +0 -1
- package/dist/webrtc/src/RTCPeer.d.ts +0 -134
- package/dist/webrtc/src/RTCPeer.d.ts.map +0 -1
- package/dist/webrtc/src/RTCPeer.test.d.ts +0 -2
- package/dist/webrtc/src/RTCPeer.test.d.ts.map +0 -1
- package/dist/webrtc/src/RTCPeerConnectionManager.d.ts +0 -63
- package/dist/webrtc/src/RTCPeerConnectionManager.d.ts.map +0 -1
- package/dist/webrtc/src/RTCPeerConnectionManager.test.d.ts +0 -2
- package/dist/webrtc/src/RTCPeerConnectionManager.test.d.ts.map +0 -1
- package/dist/webrtc/src/connectionPoolManager.d.ts +0 -14
- package/dist/webrtc/src/connectionPoolManager.d.ts.map +0 -1
- package/dist/webrtc/src/index.d.ts +0 -7
- package/dist/webrtc/src/index.d.ts.map +0 -1
- package/dist/webrtc/src/index.test.d.ts +0 -1
- package/dist/webrtc/src/index.test.d.ts.map +0 -1
- package/dist/webrtc/src/setupTests.d.ts +0 -2
- package/dist/webrtc/src/setupTests.d.ts.map +0 -1
- package/dist/webrtc/src/utils/constants.d.ts +0 -7
- package/dist/webrtc/src/utils/constants.d.ts.map +0 -1
- package/dist/webrtc/src/utils/deviceHelpers.d.ts +0 -319
- package/dist/webrtc/src/utils/deviceHelpers.d.ts.map +0 -1
- package/dist/webrtc/src/utils/deviceHelpers.test.d.ts +0 -2
- package/dist/webrtc/src/utils/deviceHelpers.test.d.ts.map +0 -1
- package/dist/webrtc/src/utils/enumerateDevices.d.ts +0 -25
- package/dist/webrtc/src/utils/enumerateDevices.d.ts.map +0 -1
- package/dist/webrtc/src/utils/getDisplayMedia.d.ts +0 -17
- package/dist/webrtc/src/utils/getDisplayMedia.d.ts.map +0 -1
- package/dist/webrtc/src/utils/getUserMedia.d.ts +0 -35
- package/dist/webrtc/src/utils/getUserMedia.d.ts.map +0 -1
- package/dist/webrtc/src/utils/helpers.d.ts +0 -18
- package/dist/webrtc/src/utils/helpers.d.ts.map +0 -1
- package/dist/webrtc/src/utils/helpers.test.d.ts +0 -2
- package/dist/webrtc/src/utils/helpers.test.d.ts.map +0 -1
- package/dist/webrtc/src/utils/index.d.ts +0 -8
- package/dist/webrtc/src/utils/index.d.ts.map +0 -1
- package/dist/webrtc/src/utils/interfaces.d.ts +0 -139
- package/dist/webrtc/src/utils/interfaces.d.ts.map +0 -1
- package/dist/webrtc/src/utils/mockTracks.d.ts +0 -26
- package/dist/webrtc/src/utils/mockTracks.d.ts.map +0 -1
- package/dist/webrtc/src/utils/permissions.d.ts +0 -48
- package/dist/webrtc/src/utils/permissions.d.ts.map +0 -1
- package/dist/webrtc/src/utils/primitives.d.ts +0 -54
- package/dist/webrtc/src/utils/primitives.d.ts.map +0 -1
- package/dist/webrtc/src/utils/primitives.native.d.ts +0 -36
- package/dist/webrtc/src/utils/primitives.native.d.ts.map +0 -1
- package/dist/webrtc/src/utils/requestPermissions.d.ts +0 -27
- package/dist/webrtc/src/utils/requestPermissions.d.ts.map +0 -1
- package/dist/webrtc/src/utils/sdpHelpers.d.ts +0 -61
- package/dist/webrtc/src/utils/sdpHelpers.d.ts.map +0 -1
- package/dist/webrtc/src/utils/sdpHelpers.test.d.ts +0 -2
- package/dist/webrtc/src/utils/sdpHelpers.test.d.ts.map +0 -1
- package/dist/webrtc/src/utils/watchRTCPeerMediaPackets.d.ts +0 -7
- package/dist/webrtc/src/utils/watchRTCPeerMediaPackets.d.ts.map +0 -1
- package/dist/webrtc/src/utils/webrtcHelpers.test.d.ts +0 -2
- package/dist/webrtc/src/utils/webrtcHelpers.test.d.ts.map +0 -1
- package/dist/webrtc/src/webrtcMocks.d.ts +0 -110
- package/dist/webrtc/src/webrtcMocks.d.ts.map +0 -1
- package/dist/webrtc/src/workers/connectionPoolWorker.d.ts +0 -7
- package/dist/webrtc/src/workers/connectionPoolWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/index.d.ts +0 -7
- package/dist/webrtc/src/workers/index.d.ts.map +0 -1
- package/dist/webrtc/src/workers/promoteDemoteWorker.d.ts +0 -10
- package/dist/webrtc/src/workers/promoteDemoteWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/roomSubscribedWorker.d.ts +0 -10
- package/dist/webrtc/src/workers/roomSubscribedWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/sessionAuthWorker.d.ts +0 -10
- package/dist/webrtc/src/workers/sessionAuthWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/sessionConnectionPoolWorker.d.ts +0 -7
- package/dist/webrtc/src/workers/sessionConnectionPoolWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/vertoEventWorker.d.ts +0 -10
- package/dist/webrtc/src/workers/vertoEventWorker.d.ts.map +0 -1
- package/dist/webrtc/src/workers/vertoEventWorker.test.d.ts +0 -2
- package/dist/webrtc/src/workers/vertoEventWorker.test.d.ts.map +0 -1
- package/src/BaseRoomSession.ts +0 -302
- package/src/Client.ts +0 -193
- package/src/JWTSession.test.ts +0 -60
- package/src/JWTSession.ts +0 -146
- package/src/RoomSessionDevice.test.ts +0 -25
- package/src/RoomSessionDevice.ts +0 -62
- package/src/RoomSessionScreenShare.test.ts +0 -25
- package/src/RoomSessionScreenShare.ts +0 -58
- package/src/VideoOverlays.ts +0 -171
- package/src/buildVideoElement.test.ts +0 -933
- package/src/buildVideoElement.ts +0 -290
- package/src/cantina/VideoManager.test.ts +0 -95
- package/src/cantina/VideoManager.ts +0 -72
- package/src/cantina/index.ts +0 -1
- package/src/cantina/workers/index.ts +0 -1
- package/src/cantina/workers/videoManagerRoomWorker.ts +0 -28
- package/src/cantina/workers/videoManagerRoomsWorker.ts +0 -34
- package/src/cantina/workers/videoManagerWorker.ts +0 -64
- package/src/chat/Client.test.ts +0 -688
- package/src/chat/Client.ts +0 -94
- package/src/chat/index.ts +0 -31
- package/src/createClient.test.ts +0 -124
- package/src/createClient.ts +0 -48
- package/src/createRoomObject.ts +0 -149
- package/src/fabric/FabricRoomSession.test.ts +0 -695
- package/src/fabric/FabricRoomSession.ts +0 -446
- package/src/fabric/FabricRoomSessionMember.ts +0 -188
- package/src/fabric/HTTPClient.test.ts +0 -28
- package/src/fabric/HTTPClient.ts +0 -154
- package/src/fabric/IncomingCallManager.test.ts +0 -295
- package/src/fabric/IncomingCallManager.ts +0 -92
- package/src/fabric/SATSession.test.ts +0 -65
- package/src/fabric/SATSession.ts +0 -102
- package/src/fabric/SignalWire.test.ts +0 -115
- package/src/fabric/SignalWire.ts +0 -101
- package/src/fabric/WSClient.ts +0 -430
- package/src/fabric/createHttpClient.ts +0 -188
- package/src/fabric/createWSClient.ts +0 -12
- package/src/fabric/index.ts +0 -30
- package/src/fabric/interfaces/address.ts +0 -46
- package/src/fabric/interfaces/capabilities.ts +0 -30
- package/src/fabric/interfaces/conversation.ts +0 -145
- package/src/fabric/interfaces/device.ts +0 -21
- package/src/fabric/interfaces/httpClient.ts +0 -50
- package/src/fabric/interfaces/incomingCallManager.ts +0 -36
- package/src/fabric/interfaces/index.ts +0 -118
- package/src/fabric/interfaces/wsClient.ts +0 -154
- package/src/fabric/utils/capabilitiesHelpers.test.ts +0 -201
- package/src/fabric/utils/capabilitiesHelpers.ts +0 -208
- package/src/fabric/utils/constants.ts +0 -4
- package/src/fabric/utils/eventMappers.ts +0 -184
- package/src/fabric/utils/typeGuard.ts +0 -31
- package/src/fabric/utils/validationProxy.ts +0 -83
- package/src/fabric/utils/validators.ts +0 -242
- package/src/fabric/workers/callJoinWorker.ts +0 -88
- package/src/fabric/workers/callLeftWorker.ts +0 -32
- package/src/fabric/workers/callSegmentWorker.ts +0 -154
- package/src/fabric/workers/fabricMemberWorker.ts +0 -62
- package/src/fabric/workers/fabricWorker.ts +0 -100
- package/src/fabric/workers/index.ts +0 -2
- package/src/fabric/workers/wsClientWorker.ts +0 -60
- package/src/features/actions.ts +0 -5
- package/src/features/mediaElements/mediaElementsSagas.ts +0 -129
- package/src/index.test.ts +0 -5
- package/src/index.ts +0 -153
- package/src/joinRoom.ts +0 -29
- package/src/pubSub/Client.test.ts +0 -245
- package/src/pubSub/Client.ts +0 -90
- package/src/pubSub/index.ts +0 -10
- package/src/setupTests.ts +0 -122
- package/src/testUtils.ts +0 -259
- package/src/utils/CloseEvent.ts +0 -6
- package/src/utils/audioElement.ts +0 -21
- package/src/utils/constants.ts +0 -7
- package/src/utils/interfaces/base.ts +0 -55
- package/src/utils/interfaces/fabric.ts +0 -156
- package/src/utils/interfaces/index.ts +0 -3
- package/src/utils/interfaces/video.ts +0 -440
- package/src/utils/makeQueryParamsUrl.ts +0 -14
- package/src/utils/paginatedResult.ts +0 -35
- package/src/utils/roomSession.test.ts +0 -140
- package/src/utils/roomSession.ts +0 -85
- package/src/utils/storage.test.ts +0 -24
- package/src/utils/storage.ts +0 -37
- package/src/utils/videoElement.ts +0 -342
- package/src/video/RoomSession.test.ts +0 -31
- package/src/video/RoomSession.ts +0 -290
- package/src/video/VideoRoomSession.test.ts +0 -672
- package/src/video/VideoRoomSession.ts +0 -304
- package/src/video/index.ts +0 -43
- package/src/video/workers/childMemberJoinedWorker.test.ts +0 -99
- package/src/video/workers/childMemberJoinedWorker.ts +0 -75
- package/src/video/workers/index.ts +0 -6
- package/src/video/workers/memberListUpdatedWorker.ts +0 -217
- package/src/video/workers/videoPlaybackWorker.ts +0 -54
- package/src/video/workers/videoRecordWorker.ts +0 -54
- package/src/video/workers/videoStreamWorker.ts +0 -48
- package/src/video/workers/videoWorker.ts +0 -113
- package/src/webrtc.ts +0 -33
package/dist/index.js
DELETED
|
@@ -1,4655 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __reflectGet = Reflect.get;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
var __objRest = (source, exclude) => {
|
|
27
|
-
var target = {};
|
|
28
|
-
for (var prop in source)
|
|
29
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
if (source != null && __getOwnPropSymbols)
|
|
32
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
-
target[prop] = source[prop];
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
};
|
|
38
|
-
var __export = (target, all) => {
|
|
39
|
-
for (var name in all)
|
|
40
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
41
|
-
};
|
|
42
|
-
var __copyProps = (to, from, except, desc) => {
|
|
43
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
44
|
-
for (let key of __getOwnPropNames(from))
|
|
45
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
46
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
47
|
-
}
|
|
48
|
-
return to;
|
|
49
|
-
};
|
|
50
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
51
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
52
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
53
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
54
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
55
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
56
|
-
mod
|
|
57
|
-
));
|
|
58
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
59
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
60
|
-
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
61
|
-
var __async = (__this, __arguments, generator) => {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
var fulfilled = (value) => {
|
|
64
|
-
try {
|
|
65
|
-
step(generator.next(value));
|
|
66
|
-
} catch (e) {
|
|
67
|
-
reject(e);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var rejected = (value) => {
|
|
71
|
-
try {
|
|
72
|
-
step(generator.throw(value));
|
|
73
|
-
} catch (e) {
|
|
74
|
-
reject(e);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
78
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/index.ts
|
|
83
|
-
var index_exports = {};
|
|
84
|
-
__export(index_exports, {
|
|
85
|
-
Chat: () => chat_exports,
|
|
86
|
-
Fabric: () => fabric_exports,
|
|
87
|
-
LocalVideoOverlay: () => LocalVideoOverlay,
|
|
88
|
-
PubSub: () => pubSub_exports,
|
|
89
|
-
SignalWire: () => SignalWire,
|
|
90
|
-
UserOverlay: () => UserOverlay,
|
|
91
|
-
Video: () => video_exports,
|
|
92
|
-
WebRTC: () => webrtc_exports,
|
|
93
|
-
buildVideoElement: () => buildVideoElement,
|
|
94
|
-
isFabricRoomSession: () => isFabricRoomSession
|
|
95
|
-
});
|
|
96
|
-
module.exports = __toCommonJS(index_exports);
|
|
97
|
-
|
|
98
|
-
// src/chat/index.ts
|
|
99
|
-
var chat_exports = {};
|
|
100
|
-
__export(chat_exports, {
|
|
101
|
-
ChatMember: () => import_core35.ChatMember,
|
|
102
|
-
ChatMessage: () => import_core35.ChatMessage,
|
|
103
|
-
Client: () => Client2
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// src/createClient.ts
|
|
107
|
-
var import_core34 = require("@signalwire/core");
|
|
108
|
-
|
|
109
|
-
// src/Client.ts
|
|
110
|
-
var import_core31 = require("@signalwire/core");
|
|
111
|
-
|
|
112
|
-
// src/features/mediaElements/mediaElementsSagas.ts
|
|
113
|
-
var import_core2 = require("@signalwire/core");
|
|
114
|
-
var import_webrtc = require("@signalwire/webrtc");
|
|
115
|
-
|
|
116
|
-
// src/utils/audioElement.ts
|
|
117
|
-
var setAudioMediaTrack = ({
|
|
118
|
-
track,
|
|
119
|
-
element
|
|
120
|
-
}) => {
|
|
121
|
-
element.autoplay = true;
|
|
122
|
-
element.playsinline = true;
|
|
123
|
-
element.srcObject = new MediaStream([track]);
|
|
124
|
-
track.addEventListener("ended", () => {
|
|
125
|
-
element.srcObject = null;
|
|
126
|
-
element.remove();
|
|
127
|
-
});
|
|
128
|
-
return element;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// src/features/actions.ts
|
|
132
|
-
var import_core = require("@signalwire/core");
|
|
133
|
-
var audioSetSpeakerAction = import_core.actions.createAction(
|
|
134
|
-
"swJs/audioSetSpeakerAction"
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
// src/features/mediaElements/mediaElementsSagas.ts
|
|
138
|
-
var makeAudioElementSaga = ({ speakerId }) => {
|
|
139
|
-
return function* audioElementSaga({
|
|
140
|
-
instance: room,
|
|
141
|
-
runSaga
|
|
142
|
-
}) {
|
|
143
|
-
if (typeof Audio === "undefined") {
|
|
144
|
-
(0, import_core2.getLogger)().warn("`Audio` is not supported on this environment.");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
const audioEl = room.getAudioEl();
|
|
149
|
-
let audioTask;
|
|
150
|
-
const trackHandler = function(event) {
|
|
151
|
-
switch (event.track.kind) {
|
|
152
|
-
case "audio": {
|
|
153
|
-
audioTask = runSaga(audioElementSetupWorker, {
|
|
154
|
-
track: event.track,
|
|
155
|
-
element: audioEl,
|
|
156
|
-
speakerId,
|
|
157
|
-
room
|
|
158
|
-
});
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
room.on("track", trackHandler);
|
|
164
|
-
room.once("destroy", () => {
|
|
165
|
-
audioTask == null ? void 0 : audioTask.cancel();
|
|
166
|
-
});
|
|
167
|
-
} catch (error) {
|
|
168
|
-
(0, import_core2.getLogger)().error("audioElementSaga", error);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
function* audioElementActionsWatcher({
|
|
173
|
-
element,
|
|
174
|
-
room
|
|
175
|
-
}) {
|
|
176
|
-
const setSpeakerActionType = import_core2.actions.getCustomSagaActionType(
|
|
177
|
-
room.__uuid,
|
|
178
|
-
audioSetSpeakerAction
|
|
179
|
-
);
|
|
180
|
-
while (true) {
|
|
181
|
-
const action = yield import_core2.sagaEffects.take([setSpeakerActionType]);
|
|
182
|
-
try {
|
|
183
|
-
switch (action.type) {
|
|
184
|
-
case setSpeakerActionType:
|
|
185
|
-
const response = yield import_core2.sagaEffects.call(
|
|
186
|
-
import_webrtc.setMediaElementSinkId,
|
|
187
|
-
element,
|
|
188
|
-
action.payload
|
|
189
|
-
);
|
|
190
|
-
room.emit(
|
|
191
|
-
// @ts-expect-error
|
|
192
|
-
`${import_core2.LOCAL_EVENT_PREFIX}.speaker.updated`,
|
|
193
|
-
action.payload
|
|
194
|
-
);
|
|
195
|
-
room.settleCustomSagaTrigger({
|
|
196
|
-
dispatchId: action.dispatchId,
|
|
197
|
-
payload: response,
|
|
198
|
-
kind: "resolve"
|
|
199
|
-
});
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
} catch (error) {
|
|
203
|
-
room.settleCustomSagaTrigger({
|
|
204
|
-
dispatchId: action.dispatchId,
|
|
205
|
-
payload: error,
|
|
206
|
-
kind: "reject"
|
|
207
|
-
});
|
|
208
|
-
(0, import_core2.getLogger)().error(error);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function* audioElementSetupWorker({
|
|
213
|
-
track,
|
|
214
|
-
element,
|
|
215
|
-
speakerId,
|
|
216
|
-
room
|
|
217
|
-
}) {
|
|
218
|
-
setAudioMediaTrack({ track, element });
|
|
219
|
-
if (speakerId) {
|
|
220
|
-
(0, import_webrtc.setMediaElementSinkId)(element, speakerId).catch(() => {
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
yield import_core2.sagaEffects.fork(audioElementActionsWatcher, {
|
|
224
|
-
element,
|
|
225
|
-
room
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// src/cantina/VideoManager.ts
|
|
230
|
-
var import_core6 = require("@signalwire/core");
|
|
231
|
-
|
|
232
|
-
// src/cantina/workers/videoManagerWorker.ts
|
|
233
|
-
var import_core5 = require("@signalwire/core");
|
|
234
|
-
|
|
235
|
-
// src/cantina/workers/videoManagerRoomsWorker.ts
|
|
236
|
-
var import_core3 = require("@signalwire/core");
|
|
237
|
-
var videoManagerRoomsWorker = function* (options) {
|
|
238
|
-
(0, import_core3.getLogger)().trace("videoManagerRoomsWorker started");
|
|
239
|
-
const {
|
|
240
|
-
instance: client,
|
|
241
|
-
action: { type, payload }
|
|
242
|
-
} = options;
|
|
243
|
-
const modPayload = {
|
|
244
|
-
rooms: payload.rooms.map((row) => (0, import_core3.toExternalJSON)(row))
|
|
245
|
-
};
|
|
246
|
-
client.emit(
|
|
247
|
-
(0, import_core3.stripNamespacePrefix)(type),
|
|
248
|
-
// @ts-expect-error
|
|
249
|
-
modPayload
|
|
250
|
-
);
|
|
251
|
-
(0, import_core3.getLogger)().trace("videoManagerRoomsWorker ended");
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// src/cantina/workers/videoManagerRoomWorker.ts
|
|
255
|
-
var import_core4 = require("@signalwire/core");
|
|
256
|
-
var videoManagerRoomWorker = function* (options) {
|
|
257
|
-
(0, import_core4.getLogger)().trace("videoManagerRoomWorker started");
|
|
258
|
-
const {
|
|
259
|
-
instance: client,
|
|
260
|
-
action: { type, payload }
|
|
261
|
-
} = options;
|
|
262
|
-
client.emit(
|
|
263
|
-
(0, import_core4.stripNamespacePrefix)(type),
|
|
264
|
-
(0, import_core4.toExternalJSON)(payload)
|
|
265
|
-
);
|
|
266
|
-
(0, import_core4.getLogger)().trace("videoManagerRoomWorker ended");
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// src/cantina/workers/videoManagerWorker.ts
|
|
270
|
-
var videoManagerWorker = function* (options) {
|
|
271
|
-
(0, import_core5.getLogger)().trace("videoManagerWorker started");
|
|
272
|
-
const {
|
|
273
|
-
channels: { swEventChannel }
|
|
274
|
-
} = options;
|
|
275
|
-
function* worker(action) {
|
|
276
|
-
const { type } = action;
|
|
277
|
-
switch (type) {
|
|
278
|
-
case "video-manager.rooms.subscribed":
|
|
279
|
-
yield import_core5.sagaEffects.fork(videoManagerRoomsWorker, __spreadValues({
|
|
280
|
-
action
|
|
281
|
-
}, options));
|
|
282
|
-
break;
|
|
283
|
-
case "video-manager.room.added":
|
|
284
|
-
case "video-manager.room.deleted":
|
|
285
|
-
case "video-manager.room.ended":
|
|
286
|
-
case "video-manager.room.started":
|
|
287
|
-
case "video-manager.room.updated":
|
|
288
|
-
yield import_core5.sagaEffects.fork(videoManagerRoomWorker, __spreadValues({
|
|
289
|
-
action
|
|
290
|
-
}, options));
|
|
291
|
-
break;
|
|
292
|
-
default:
|
|
293
|
-
(0, import_core5.getLogger)().warn(`Unknown video-manager event: "${type}"`);
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
while (true) {
|
|
298
|
-
const action = yield import_core5.sagaEffects.take(
|
|
299
|
-
swEventChannel,
|
|
300
|
-
(action2) => {
|
|
301
|
-
return action2.type.startsWith("video-manager.");
|
|
302
|
-
}
|
|
303
|
-
);
|
|
304
|
-
yield import_core5.sagaEffects.fork(worker, action);
|
|
305
|
-
}
|
|
306
|
-
(0, import_core5.getLogger)().trace("videoManagerWorker ended");
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
// src/cantina/VideoManager.ts
|
|
310
|
-
var VideoManagerAPI = class extends import_core6.BaseConsumer {
|
|
311
|
-
constructor(options) {
|
|
312
|
-
super(options);
|
|
313
|
-
this.runWorker("videoManagerWorker", {
|
|
314
|
-
worker: videoManagerWorker
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
/** @internal */
|
|
318
|
-
getSubscriptions() {
|
|
319
|
-
const eventNamesWithPrefix = this.eventNames().map(
|
|
320
|
-
(event) => `video-manager.${event}`
|
|
321
|
-
);
|
|
322
|
-
return (0, import_core6.validateEventsToSubscribe)(eventNamesWithPrefix);
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
var createVideoManagerObject = (params) => {
|
|
326
|
-
const manager = (0, import_core6.connect)({
|
|
327
|
-
store: params.store,
|
|
328
|
-
Component: VideoManagerAPI
|
|
329
|
-
})(params);
|
|
330
|
-
const proxy = new Proxy(manager, {
|
|
331
|
-
get(target, property, receiver) {
|
|
332
|
-
if (property === "_eventsNamespace") {
|
|
333
|
-
return "";
|
|
334
|
-
} else if (property === "eventChannel") {
|
|
335
|
-
return "video-manager.rooms";
|
|
336
|
-
}
|
|
337
|
-
return Reflect.get(target, property, receiver);
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
return proxy;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// src/buildVideoElement.ts
|
|
344
|
-
var import_core30 = require("@signalwire/core");
|
|
345
|
-
|
|
346
|
-
// src/utils/videoElement.ts
|
|
347
|
-
var import_core29 = require("@signalwire/core");
|
|
348
|
-
|
|
349
|
-
// src/VideoOverlays.ts
|
|
350
|
-
var import_core28 = require("@signalwire/core");
|
|
351
|
-
|
|
352
|
-
// src/video/VideoRoomSession.ts
|
|
353
|
-
var import_core17 = require("@signalwire/core");
|
|
354
|
-
|
|
355
|
-
// src/BaseRoomSession.ts
|
|
356
|
-
var import_core15 = require("@signalwire/core");
|
|
357
|
-
var import_webrtc3 = require("@signalwire/webrtc");
|
|
358
|
-
|
|
359
|
-
// src/utils/constants.ts
|
|
360
|
-
var SCREENSHARE_AUDIO_CONSTRAINTS = {
|
|
361
|
-
echoCancellation: true,
|
|
362
|
-
noiseSuppression: false,
|
|
363
|
-
autoGainControl: false,
|
|
364
|
-
// @ts-expect-error
|
|
365
|
-
googAutoGainControl: false
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// src/utils/roomSession.ts
|
|
369
|
-
var import_core7 = require("@signalwire/core");
|
|
370
|
-
var getJoinMediaParams = (options) => {
|
|
371
|
-
const {
|
|
372
|
-
authorization,
|
|
373
|
-
audio = true,
|
|
374
|
-
video = true,
|
|
375
|
-
sendAudio,
|
|
376
|
-
sendVideo,
|
|
377
|
-
receiveAudio,
|
|
378
|
-
receiveVideo
|
|
379
|
-
} = options;
|
|
380
|
-
(0, import_core7.getLogger)().debug("getJoinMediaParams options", __spreadValues({}, options));
|
|
381
|
-
const { audio_allowed, video_allowed, join_as } = authorization;
|
|
382
|
-
const joinAs = join_as != null ? join_as : "member";
|
|
383
|
-
const canSend = joinAs === "member";
|
|
384
|
-
const canSendAudio = canSend && audio_allowed === "both";
|
|
385
|
-
const canSendVideo = canSend && video_allowed === "both";
|
|
386
|
-
const canReceiveAudio = audio_allowed !== "none";
|
|
387
|
-
const canReceiveVideo = video_allowed !== "none";
|
|
388
|
-
const reqToSendAudio = Boolean(sendAudio != null ? sendAudio : audio);
|
|
389
|
-
const reqToSendVideo = Boolean(sendVideo != null ? sendVideo : video);
|
|
390
|
-
const reqToReceiveAudio = Boolean(receiveAudio != null ? receiveAudio : audio);
|
|
391
|
-
const reqToReceiveVideo = Boolean(receiveVideo != null ? receiveVideo : video);
|
|
392
|
-
if (!canSendAudio && reqToSendAudio) {
|
|
393
|
-
(0, import_core7.getLogger)().info(
|
|
394
|
-
"Not allowed to send audio on this room. Default values will be used."
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
if (!canSendVideo && reqToSendVideo) {
|
|
398
|
-
(0, import_core7.getLogger)().info(
|
|
399
|
-
"Not allowed to send video on this room. Default values will be used."
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
if (!canReceiveAudio && reqToReceiveAudio) {
|
|
403
|
-
(0, import_core7.getLogger)().info(
|
|
404
|
-
"Not allowed to receive video from the room. Default values will be used."
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
if (!canReceiveVideo && reqToReceiveVideo) {
|
|
408
|
-
(0, import_core7.getLogger)().info(
|
|
409
|
-
"Not allowed to receive video from the room. Default values will be used."
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
return {
|
|
413
|
-
mustSendAudio: canSendAudio && reqToSendAudio,
|
|
414
|
-
mustSendVideo: canSendVideo && reqToSendVideo,
|
|
415
|
-
mustRecvAudio: canReceiveAudio && reqToReceiveAudio,
|
|
416
|
-
mustRecvVideo: canReceiveVideo && reqToReceiveVideo
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
var checkMediaParams = (options) => {
|
|
420
|
-
return Object.values(options).some(Boolean);
|
|
421
|
-
};
|
|
422
|
-
var SDK_PREFIX = "sw-sdk-";
|
|
423
|
-
var addSDKPrefix = (id) => {
|
|
424
|
-
return `${SDK_PREFIX}${id}`;
|
|
425
|
-
};
|
|
426
|
-
var OVERLAY_PREFIX = "sw-overlay-";
|
|
427
|
-
var addOverlayPrefix = (id) => {
|
|
428
|
-
return `${OVERLAY_PREFIX}${id}`;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
// src/RoomSessionScreenShare.ts
|
|
432
|
-
var import_core8 = require("@signalwire/core");
|
|
433
|
-
var import_webrtc2 = require("@signalwire/webrtc");
|
|
434
|
-
var RoomSessionScreenShareConnection = class extends import_webrtc2.BaseConnection {
|
|
435
|
-
join() {
|
|
436
|
-
return super.invite();
|
|
437
|
-
}
|
|
438
|
-
leave() {
|
|
439
|
-
return super.hangup();
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
var RoomSessionScreenShareAPI = (0, import_core8.extendComponent)(RoomSessionScreenShareConnection, {
|
|
443
|
-
audioMute: import_core8.Rooms.audioMuteMember,
|
|
444
|
-
audioUnmute: import_core8.Rooms.audioUnmuteMember,
|
|
445
|
-
videoMute: import_core8.Rooms.videoMuteMember,
|
|
446
|
-
videoUnmute: import_core8.Rooms.videoUnmuteMember,
|
|
447
|
-
setMicrophoneVolume: import_core8.Rooms.setInputVolumeMember,
|
|
448
|
-
setInputVolume: import_core8.Rooms.setInputVolumeMember,
|
|
449
|
-
setInputSensitivity: import_core8.Rooms.setInputSensitivityMember
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
// src/video/workers/memberListUpdatedWorker.ts
|
|
453
|
-
var import_core9 = require("@signalwire/core");
|
|
454
|
-
var noop = () => {
|
|
455
|
-
};
|
|
456
|
-
var EXTERNAL_MEMBER_LIST_UPDATED_EVENT = "memberList.updated";
|
|
457
|
-
var INTERNAL_MEMBER_LIST_UPDATED_EVENT = (0, import_core9.toInternalEventName)({
|
|
458
|
-
event: EXTERNAL_MEMBER_LIST_UPDATED_EVENT
|
|
459
|
-
});
|
|
460
|
-
var SYNTHETIC_MEMBER_LIST_UPDATED_EVENT = (0, import_core9.toSyntheticEvent)(
|
|
461
|
-
INTERNAL_MEMBER_LIST_UPDATED_EVENT
|
|
462
|
-
);
|
|
463
|
-
var MEMBER_LIST_EVENTS = [
|
|
464
|
-
/** Alias to `video.room.subscribed` */
|
|
465
|
-
"video.room.joined",
|
|
466
|
-
"video.member.joined",
|
|
467
|
-
"video.member.left",
|
|
468
|
-
"video.member.updated"
|
|
469
|
-
];
|
|
470
|
-
var isMemberListEvent = (event) => {
|
|
471
|
-
return MEMBER_LIST_EVENTS.includes(event);
|
|
472
|
-
};
|
|
473
|
-
var getMemberListEventsToSubscribe = (subscriptions) => {
|
|
474
|
-
return (0, import_core9.validateEventsToSubscribe)(MEMBER_LIST_EVENTS).filter((event) => {
|
|
475
|
-
return !subscriptions.includes(event);
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
var shouldHandleMemberList = (subscriptions) => {
|
|
479
|
-
return subscriptions.some(
|
|
480
|
-
(event) => event.includes(EXTERNAL_MEMBER_LIST_UPDATED_EVENT)
|
|
481
|
-
);
|
|
482
|
-
};
|
|
483
|
-
var getMembersFromAction = (action) => {
|
|
484
|
-
if (action.type === "video.room.joined") {
|
|
485
|
-
return action.payload.room_session.members;
|
|
486
|
-
}
|
|
487
|
-
return [action.payload.member];
|
|
488
|
-
};
|
|
489
|
-
var getUpdatedMembers = ({
|
|
490
|
-
action,
|
|
491
|
-
memberList
|
|
492
|
-
}) => {
|
|
493
|
-
const actionMembers = getMembersFromAction(action);
|
|
494
|
-
switch (action.type) {
|
|
495
|
-
case "video.member.left":
|
|
496
|
-
actionMembers.forEach((member) => {
|
|
497
|
-
memberList.delete(member.id);
|
|
498
|
-
});
|
|
499
|
-
break;
|
|
500
|
-
default:
|
|
501
|
-
actionMembers.forEach((member) => {
|
|
502
|
-
memberList.set(member.id, member);
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
return Array.from(memberList.values());
|
|
506
|
-
};
|
|
507
|
-
var initMemberListSubscriptions = (room, subscriptions) => {
|
|
508
|
-
const events = getMemberListEventsToSubscribe(subscriptions);
|
|
509
|
-
events.forEach((event) => {
|
|
510
|
-
room.once(event, noop);
|
|
511
|
-
});
|
|
512
|
-
const eventBridgeHandler = ({ members }) => {
|
|
513
|
-
room.emit(EXTERNAL_MEMBER_LIST_UPDATED_EVENT, { members });
|
|
514
|
-
};
|
|
515
|
-
room.on(SYNTHETIC_MEMBER_LIST_UPDATED_EVENT, eventBridgeHandler);
|
|
516
|
-
const cleanup = () => {
|
|
517
|
-
room.off(SYNTHETIC_MEMBER_LIST_UPDATED_EVENT, eventBridgeHandler);
|
|
518
|
-
};
|
|
519
|
-
return {
|
|
520
|
-
cleanup
|
|
521
|
-
};
|
|
522
|
-
};
|
|
523
|
-
function* membersListUpdatedWatcher({
|
|
524
|
-
swEventChannel,
|
|
525
|
-
instance
|
|
526
|
-
}) {
|
|
527
|
-
const memberList = /* @__PURE__ */ new Map();
|
|
528
|
-
function* worker(pubSubAction) {
|
|
529
|
-
const roomSessionId = pubSubAction.type === "video.room.joined" ? pubSubAction.payload.room_session.id : pubSubAction.payload.room_session_id;
|
|
530
|
-
const members = getUpdatedMembers({ action: pubSubAction, memberList });
|
|
531
|
-
const memberListPayload = {
|
|
532
|
-
/**
|
|
533
|
-
* At this point it's needed to send the
|
|
534
|
-
* `room_session_id` so the pubSubSaga can properly
|
|
535
|
-
* infer the namespace for emitting the events to the
|
|
536
|
-
* appropiate room.
|
|
537
|
-
*/
|
|
538
|
-
room_session_id: roomSessionId,
|
|
539
|
-
members
|
|
540
|
-
};
|
|
541
|
-
instance.emit(SYNTHETIC_MEMBER_LIST_UPDATED_EVENT, memberListPayload);
|
|
542
|
-
}
|
|
543
|
-
while (true) {
|
|
544
|
-
const pubSubAction = yield import_core9.sagaEffects.take(
|
|
545
|
-
swEventChannel,
|
|
546
|
-
({ type }) => {
|
|
547
|
-
return isMemberListEvent(type);
|
|
548
|
-
}
|
|
549
|
-
);
|
|
550
|
-
yield import_core9.sagaEffects.fork(worker, pubSubAction);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
var memberListUpdatedWorker = function* membersChangedWorker({
|
|
554
|
-
channels: { swEventChannel },
|
|
555
|
-
instance
|
|
556
|
-
}) {
|
|
557
|
-
const subscriptions = instance.getSubscriptions();
|
|
558
|
-
if (!shouldHandleMemberList(subscriptions)) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
const { cleanup } = initMemberListSubscriptions(instance, subscriptions);
|
|
562
|
-
yield import_core9.sagaEffects.fork(membersListUpdatedWatcher, {
|
|
563
|
-
swEventChannel,
|
|
564
|
-
instance
|
|
565
|
-
});
|
|
566
|
-
instance.once("destroy", () => {
|
|
567
|
-
cleanup();
|
|
568
|
-
});
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
// src/video/workers/childMemberJoinedWorker.ts
|
|
572
|
-
var import_core10 = require("@signalwire/core");
|
|
573
|
-
var childMemberJoinedWorker = function* (options) {
|
|
574
|
-
(0, import_core10.getLogger)().trace("childMemberJoinedWorker started");
|
|
575
|
-
const { channels, instance, initialState, onDone, onFail } = options;
|
|
576
|
-
const { swEventChannel } = channels;
|
|
577
|
-
const { parentId } = initialState;
|
|
578
|
-
if (!parentId) {
|
|
579
|
-
throw new Error("Missing parentId for childMemberJoinedWorker");
|
|
580
|
-
}
|
|
581
|
-
const action = yield import_core10.sagaEffects.take(swEventChannel, (action2) => {
|
|
582
|
-
if (action2.type === "video.member.joined") {
|
|
583
|
-
return action2.payload.member.parent_id === parentId;
|
|
584
|
-
}
|
|
585
|
-
return false;
|
|
586
|
-
});
|
|
587
|
-
const { member } = action.payload;
|
|
588
|
-
if (member == null ? void 0 : member.parent_id) {
|
|
589
|
-
const byId = yield import_core10.sagaEffects.select(
|
|
590
|
-
import_core10.componentSelectors.getComponentsById
|
|
591
|
-
);
|
|
592
|
-
const parent = Object.values(byId).find((row) => {
|
|
593
|
-
return "memberId" in row && row.memberId === member.parent_id;
|
|
594
|
-
});
|
|
595
|
-
if (parent) {
|
|
596
|
-
yield import_core10.sagaEffects.put(
|
|
597
|
-
import_core10.componentActions.upsert({
|
|
598
|
-
id: instance.callId,
|
|
599
|
-
roomId: action.payload.room_id,
|
|
600
|
-
roomSessionId: action.payload.room_session_id,
|
|
601
|
-
memberId: member.id
|
|
602
|
-
})
|
|
603
|
-
);
|
|
604
|
-
onDone == null ? void 0 : onDone();
|
|
605
|
-
} else {
|
|
606
|
-
onFail == null ? void 0 : onFail({ error: new Error("Unknown parent_id") });
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
(0, import_core10.getLogger)().trace("childMemberJoinedWorker ended");
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
// src/video/workers/videoWorker.ts
|
|
613
|
-
var import_core14 = require("@signalwire/core");
|
|
614
|
-
|
|
615
|
-
// src/video/workers/videoStreamWorker.ts
|
|
616
|
-
var import_core11 = require("@signalwire/core");
|
|
617
|
-
var videoStreamWorker = function* (options) {
|
|
618
|
-
(0, import_core11.getLogger)().trace("videoStreamWorker started");
|
|
619
|
-
const {
|
|
620
|
-
instance: roomSession,
|
|
621
|
-
action: { type, payload },
|
|
622
|
-
instanceMap: { get, set, remove }
|
|
623
|
-
} = options;
|
|
624
|
-
let streamInstance = get(payload.stream.id);
|
|
625
|
-
if (!streamInstance) {
|
|
626
|
-
streamInstance = import_core11.Rooms.createRoomSessionStreamObject({
|
|
627
|
-
store: roomSession.store,
|
|
628
|
-
payload
|
|
629
|
-
});
|
|
630
|
-
} else {
|
|
631
|
-
streamInstance.setPayload(payload);
|
|
632
|
-
}
|
|
633
|
-
set(payload.stream.id, streamInstance);
|
|
634
|
-
switch (type) {
|
|
635
|
-
case "video.stream.started":
|
|
636
|
-
roomSession.emit("stream.started", streamInstance);
|
|
637
|
-
break;
|
|
638
|
-
case "video.stream.ended":
|
|
639
|
-
roomSession.emit("stream.ended", streamInstance);
|
|
640
|
-
remove(payload.stream.id);
|
|
641
|
-
break;
|
|
642
|
-
default:
|
|
643
|
-
(0, import_core11.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
(0, import_core11.getLogger)().trace("videoStreamWorker ended");
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// src/video/workers/videoRecordWorker.ts
|
|
650
|
-
var import_core12 = require("@signalwire/core");
|
|
651
|
-
var videoRecordWorker = function* (options) {
|
|
652
|
-
(0, import_core12.getLogger)().trace("videoRecordWorker started");
|
|
653
|
-
const {
|
|
654
|
-
instance: roomSession,
|
|
655
|
-
action: { type, payload },
|
|
656
|
-
instanceMap: { get, set, remove }
|
|
657
|
-
} = options;
|
|
658
|
-
let recordingInstance = get(payload.recording.id);
|
|
659
|
-
if (!recordingInstance) {
|
|
660
|
-
recordingInstance = import_core12.Rooms.createRoomSessionRecordingObject({
|
|
661
|
-
store: roomSession.store,
|
|
662
|
-
payload
|
|
663
|
-
});
|
|
664
|
-
} else {
|
|
665
|
-
recordingInstance.setPayload(payload);
|
|
666
|
-
}
|
|
667
|
-
set(payload.recording.id, recordingInstance);
|
|
668
|
-
const event = (0, import_core12.stripNamespacePrefix)(type);
|
|
669
|
-
switch (type) {
|
|
670
|
-
case "video.recording.started":
|
|
671
|
-
case "video.recording.updated": {
|
|
672
|
-
roomSession.emit(event, recordingInstance);
|
|
673
|
-
break;
|
|
674
|
-
}
|
|
675
|
-
case "video.recording.ended":
|
|
676
|
-
roomSession.emit(event, recordingInstance);
|
|
677
|
-
remove(payload.recording.id);
|
|
678
|
-
break;
|
|
679
|
-
default:
|
|
680
|
-
(0, import_core12.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
(0, import_core12.getLogger)().trace("videoRecordWorker ended");
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
// src/video/workers/videoPlaybackWorker.ts
|
|
687
|
-
var import_core13 = require("@signalwire/core");
|
|
688
|
-
var videoPlaybackWorker = function* (options) {
|
|
689
|
-
(0, import_core13.getLogger)().trace("videoPlaybackWorker started");
|
|
690
|
-
const {
|
|
691
|
-
instance: roomSession,
|
|
692
|
-
action: { type, payload },
|
|
693
|
-
instanceMap: { get, set, remove }
|
|
694
|
-
} = options;
|
|
695
|
-
let playbackInstance = get(payload.playback.id);
|
|
696
|
-
if (!playbackInstance) {
|
|
697
|
-
playbackInstance = import_core13.Rooms.createRoomSessionPlaybackObject({
|
|
698
|
-
store: roomSession.store,
|
|
699
|
-
payload
|
|
700
|
-
});
|
|
701
|
-
} else {
|
|
702
|
-
playbackInstance.setPayload(payload);
|
|
703
|
-
}
|
|
704
|
-
set(payload.playback.id, playbackInstance);
|
|
705
|
-
const event = (0, import_core13.stripNamespacePrefix)(type);
|
|
706
|
-
switch (type) {
|
|
707
|
-
case "video.playback.started":
|
|
708
|
-
case "video.playback.updated": {
|
|
709
|
-
roomSession.emit(event, playbackInstance);
|
|
710
|
-
break;
|
|
711
|
-
}
|
|
712
|
-
case "video.playback.ended":
|
|
713
|
-
roomSession.emit(event, playbackInstance);
|
|
714
|
-
remove(payload.playback.id);
|
|
715
|
-
break;
|
|
716
|
-
default:
|
|
717
|
-
(0, import_core13.getLogger)().warn(`Unknown video.stream event: "${type}"`);
|
|
718
|
-
break;
|
|
719
|
-
}
|
|
720
|
-
(0, import_core13.getLogger)().trace("videoPlaybackWorker ended");
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
// src/video/workers/videoWorker.ts
|
|
724
|
-
var videoWorker = function* (options) {
|
|
725
|
-
(0, import_core14.getLogger)().trace("videoWorker started");
|
|
726
|
-
const { channels, instance: roomSession } = options;
|
|
727
|
-
const { swEventChannel } = channels;
|
|
728
|
-
function* worker(action) {
|
|
729
|
-
const { type, payload } = action;
|
|
730
|
-
switch (type) {
|
|
731
|
-
case "video.room.subscribed":
|
|
732
|
-
yield import_core14.sagaEffects.fork(import_core14.MemberPosition.memberPositionWorker, __spreadProps(__spreadValues({}, options), {
|
|
733
|
-
instance: roomSession,
|
|
734
|
-
initialState: payload
|
|
735
|
-
}));
|
|
736
|
-
return;
|
|
737
|
-
case "video.playback.started":
|
|
738
|
-
case "video.playback.updated":
|
|
739
|
-
case "video.playback.ended":
|
|
740
|
-
yield import_core14.sagaEffects.fork(videoPlaybackWorker, __spreadValues({
|
|
741
|
-
action
|
|
742
|
-
}, options));
|
|
743
|
-
return;
|
|
744
|
-
// Return since we don't need to handle the raw event for this
|
|
745
|
-
case "video.recording.started":
|
|
746
|
-
case "video.recording.updated":
|
|
747
|
-
case "video.recording.ended":
|
|
748
|
-
yield import_core14.sagaEffects.fork(videoRecordWorker, __spreadValues({
|
|
749
|
-
action
|
|
750
|
-
}, options));
|
|
751
|
-
return;
|
|
752
|
-
case "video.stream.ended":
|
|
753
|
-
case "video.stream.started":
|
|
754
|
-
yield import_core14.sagaEffects.fork(videoStreamWorker, __spreadValues({
|
|
755
|
-
action
|
|
756
|
-
}, options));
|
|
757
|
-
return;
|
|
758
|
-
case "video.room.audience_count": {
|
|
759
|
-
roomSession.emit("room.audienceCount", payload);
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
case "video.member.talking": {
|
|
763
|
-
const { member } = payload;
|
|
764
|
-
if ("talking" in member) {
|
|
765
|
-
const suffix = member.talking ? "started" : "ended";
|
|
766
|
-
roomSession.emit(`member.talking.${suffix}`, payload);
|
|
767
|
-
const deprecatedSuffix = member.talking ? "start" : "stop";
|
|
768
|
-
roomSession.emit(`member.talking.${deprecatedSuffix}`, payload);
|
|
769
|
-
}
|
|
770
|
-
break;
|
|
771
|
-
}
|
|
772
|
-
case "video.layout.changed": {
|
|
773
|
-
roomSession.currentLayoutEvent = action.payload;
|
|
774
|
-
break;
|
|
775
|
-
}
|
|
776
|
-
default:
|
|
777
|
-
break;
|
|
778
|
-
}
|
|
779
|
-
const event = (0, import_core14.stripNamespacePrefix)(type, "video");
|
|
780
|
-
roomSession.emit(event, payload);
|
|
781
|
-
}
|
|
782
|
-
const isVideoEvent = (action) => {
|
|
783
|
-
return action.type.startsWith("video.");
|
|
784
|
-
};
|
|
785
|
-
while (true) {
|
|
786
|
-
const action = yield import_core14.sagaEffects.take(
|
|
787
|
-
swEventChannel,
|
|
788
|
-
isVideoEvent
|
|
789
|
-
);
|
|
790
|
-
yield import_core14.sagaEffects.fork(worker, action);
|
|
791
|
-
}
|
|
792
|
-
(0, import_core14.getLogger)().trace("videoWorker ended");
|
|
793
|
-
};
|
|
794
|
-
|
|
795
|
-
// src/BaseRoomSession.ts
|
|
796
|
-
var BaseRoomSessionConnection = class _BaseRoomSessionConnection extends import_webrtc3.BaseConnection {
|
|
797
|
-
constructor() {
|
|
798
|
-
super(...arguments);
|
|
799
|
-
__publicField(this, "_screenShareList", /* @__PURE__ */ new Set());
|
|
800
|
-
__publicField(this, "_audioEl");
|
|
801
|
-
__publicField(this, "_overlayMap");
|
|
802
|
-
__publicField(this, "_localVideoOverlay");
|
|
803
|
-
}
|
|
804
|
-
get audioEl() {
|
|
805
|
-
return this._audioEl;
|
|
806
|
-
}
|
|
807
|
-
set overlayMap(map) {
|
|
808
|
-
this._overlayMap = map;
|
|
809
|
-
}
|
|
810
|
-
get overlayMap() {
|
|
811
|
-
return this._overlayMap;
|
|
812
|
-
}
|
|
813
|
-
set localVideoOverlay(overlay) {
|
|
814
|
-
this._localVideoOverlay = overlay;
|
|
815
|
-
}
|
|
816
|
-
get localVideoOverlay() {
|
|
817
|
-
return this._localVideoOverlay;
|
|
818
|
-
}
|
|
819
|
-
get screenShareList() {
|
|
820
|
-
return Array.from(this._screenShareList);
|
|
821
|
-
}
|
|
822
|
-
_attachSpeakerTrackListener() {
|
|
823
|
-
if (!(0, import_webrtc3.supportsMediaOutput)()) return;
|
|
824
|
-
(0, import_webrtc3.createSpeakerDeviceWatcher)().then((deviceWatcher) => {
|
|
825
|
-
deviceWatcher.on("removed", (data) => __async(this, null, function* () {
|
|
826
|
-
var _a, _b;
|
|
827
|
-
const sinkId = this._audioEl.sinkId;
|
|
828
|
-
const disconnectedSpeaker = data.changes.find((device) => {
|
|
829
|
-
const payloadDeviceId = device.payload.deviceId;
|
|
830
|
-
return payloadDeviceId === sinkId || payloadDeviceId === "" && sinkId === "default" || payloadDeviceId === "default" && sinkId === "";
|
|
831
|
-
});
|
|
832
|
-
if (disconnectedSpeaker) {
|
|
833
|
-
this.emit("speaker.disconnected", {
|
|
834
|
-
deviceId: disconnectedSpeaker.payload.deviceId,
|
|
835
|
-
label: disconnectedSpeaker.payload.label
|
|
836
|
-
});
|
|
837
|
-
yield (_b = (_a = this._audioEl).setSinkId) == null ? void 0 : _b.call(_a, "");
|
|
838
|
-
const defaultSpeakers = yield (0, import_webrtc3.getSpeakerById)("default");
|
|
839
|
-
if (!(defaultSpeakers == null ? void 0 : defaultSpeakers.deviceId)) return;
|
|
840
|
-
this.emit("speaker.updated", {
|
|
841
|
-
previous: {
|
|
842
|
-
deviceId: disconnectedSpeaker.payload.deviceId,
|
|
843
|
-
label: disconnectedSpeaker.payload.label
|
|
844
|
-
},
|
|
845
|
-
current: {
|
|
846
|
-
deviceId: defaultSpeakers.deviceId,
|
|
847
|
-
label: defaultSpeakers.label
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
}));
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
/** @internal */
|
|
855
|
-
_finalize() {
|
|
856
|
-
this._screenShareList.clear();
|
|
857
|
-
super._finalize();
|
|
858
|
-
}
|
|
859
|
-
/** @internal */
|
|
860
|
-
hangup(id) {
|
|
861
|
-
return __async(this, null, function* () {
|
|
862
|
-
this._screenShareList.forEach((screenShare) => {
|
|
863
|
-
screenShare.leave();
|
|
864
|
-
});
|
|
865
|
-
return __superGet(_BaseRoomSessionConnection.prototype, this, "hangup").call(this, id);
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
leave() {
|
|
869
|
-
return this.hangup();
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* This method will be called by `join()` right before the
|
|
873
|
-
* `connect()` happens and it's a way for us to control
|
|
874
|
-
* exactly when the workers are attached.
|
|
875
|
-
* @internal
|
|
876
|
-
*/
|
|
877
|
-
attachPreConnectWorkers() {
|
|
878
|
-
this.runWorker("memberListUpdated", {
|
|
879
|
-
worker: memberListUpdatedWorker
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
/** @internal */
|
|
883
|
-
getAudioEl() {
|
|
884
|
-
if (this._audioEl) return this._audioEl;
|
|
885
|
-
this._audioEl = new Audio();
|
|
886
|
-
this._attachSpeakerTrackListener();
|
|
887
|
-
return this._audioEl;
|
|
888
|
-
}
|
|
889
|
-
getMemberOverlay(memberId) {
|
|
890
|
-
return this.overlayMap.get(addOverlayPrefix(memberId));
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Allow sharing the screen within the room.
|
|
894
|
-
*/
|
|
895
|
-
startScreenShare() {
|
|
896
|
-
return __async(this, arguments, function* (opts = {}) {
|
|
897
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
898
|
-
var _a;
|
|
899
|
-
const {
|
|
900
|
-
autoJoin = true,
|
|
901
|
-
audio = false,
|
|
902
|
-
video = true,
|
|
903
|
-
layout,
|
|
904
|
-
positions
|
|
905
|
-
} = opts;
|
|
906
|
-
try {
|
|
907
|
-
const displayStream = yield (0, import_webrtc3.getDisplayMedia)({
|
|
908
|
-
audio: audio === true ? SCREENSHARE_AUDIO_CONSTRAINTS : audio,
|
|
909
|
-
video
|
|
910
|
-
});
|
|
911
|
-
const options = __spreadProps(__spreadValues({}, this.options), {
|
|
912
|
-
screenShare: true,
|
|
913
|
-
recoverCall: false,
|
|
914
|
-
localStream: displayStream,
|
|
915
|
-
remoteStream: void 0,
|
|
916
|
-
userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
|
|
917
|
-
memberCallId: this.callId,
|
|
918
|
-
memberId: this.memberId
|
|
919
|
-
}),
|
|
920
|
-
layout,
|
|
921
|
-
positions
|
|
922
|
-
});
|
|
923
|
-
const screenShare = (0, import_core15.connect)({
|
|
924
|
-
store: this.store,
|
|
925
|
-
Component: RoomSessionScreenShareAPI
|
|
926
|
-
})(options);
|
|
927
|
-
displayStream.getVideoTracks().forEach((t) => {
|
|
928
|
-
t.addEventListener("ended", () => {
|
|
929
|
-
if (screenShare && screenShare.active) {
|
|
930
|
-
screenShare.leave();
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
});
|
|
934
|
-
screenShare.once("destroy", () => {
|
|
935
|
-
screenShare.emit("room.left");
|
|
936
|
-
this._screenShareList.delete(screenShare);
|
|
937
|
-
});
|
|
938
|
-
screenShare.runWorker("childMemberJoinedWorker", {
|
|
939
|
-
worker: childMemberJoinedWorker,
|
|
940
|
-
onDone: () => resolve(screenShare),
|
|
941
|
-
onFail: reject,
|
|
942
|
-
initialState: {
|
|
943
|
-
parentId: this.memberId
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
this._screenShareList.add(screenShare);
|
|
947
|
-
if (autoJoin) {
|
|
948
|
-
return yield screenShare.join();
|
|
949
|
-
}
|
|
950
|
-
return resolve(screenShare);
|
|
951
|
-
} catch (error) {
|
|
952
|
-
this.logger.error("ScreenShare Error", error);
|
|
953
|
-
reject(error);
|
|
954
|
-
}
|
|
955
|
-
}));
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
updateSpeaker({ deviceId }) {
|
|
959
|
-
const prevId = this.audioEl.sinkId;
|
|
960
|
-
this.once(
|
|
961
|
-
// @ts-expect-error
|
|
962
|
-
`${import_core15.LOCAL_EVENT_PREFIX}.speaker.updated`,
|
|
963
|
-
(newId) => __async(this, null, function* () {
|
|
964
|
-
const prevSpeaker = yield (0, import_webrtc3.getSpeakerById)(prevId);
|
|
965
|
-
const newSpeaker = yield (0, import_webrtc3.getSpeakerById)(newId);
|
|
966
|
-
const isSame = (newSpeaker == null ? void 0 : newSpeaker.deviceId) === (prevSpeaker == null ? void 0 : prevSpeaker.deviceId);
|
|
967
|
-
if (!(newSpeaker == null ? void 0 : newSpeaker.deviceId) || isSame) return;
|
|
968
|
-
this.emit("speaker.updated", {
|
|
969
|
-
previous: {
|
|
970
|
-
deviceId: prevSpeaker == null ? void 0 : prevSpeaker.deviceId,
|
|
971
|
-
label: prevSpeaker == null ? void 0 : prevSpeaker.label
|
|
972
|
-
},
|
|
973
|
-
current: {
|
|
974
|
-
deviceId: newSpeaker.deviceId,
|
|
975
|
-
label: newSpeaker.label
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
})
|
|
979
|
-
);
|
|
980
|
-
return this.triggerCustomSaga(audioSetSpeakerAction(deviceId));
|
|
981
|
-
}
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// src/RoomSessionDevice.ts
|
|
985
|
-
var import_core16 = require("@signalwire/core");
|
|
986
|
-
var import_webrtc4 = require("@signalwire/webrtc");
|
|
987
|
-
var RoomSessionDeviceConnection = class extends import_webrtc4.BaseConnection {
|
|
988
|
-
join() {
|
|
989
|
-
return super.invite();
|
|
990
|
-
}
|
|
991
|
-
leave() {
|
|
992
|
-
return super.hangup();
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
var RoomSessionDeviceAPI = (0, import_core16.extendComponent)(RoomSessionDeviceConnection, {
|
|
996
|
-
audioMute: import_core16.Rooms.audioMuteMember,
|
|
997
|
-
audioUnmute: import_core16.Rooms.audioUnmuteMember,
|
|
998
|
-
videoMute: import_core16.Rooms.videoMuteMember,
|
|
999
|
-
videoUnmute: import_core16.Rooms.videoUnmuteMember,
|
|
1000
|
-
setInputVolume: import_core16.Rooms.setInputVolumeMember,
|
|
1001
|
-
setMicrophoneVolume: import_core16.Rooms.setInputVolumeMember,
|
|
1002
|
-
setInputSensitivity: import_core16.Rooms.setInputSensitivityMember
|
|
1003
|
-
});
|
|
1004
|
-
|
|
1005
|
-
// src/video/VideoRoomSession.ts
|
|
1006
|
-
var VideoRoomSessionConnection = class _VideoRoomSessionConnection extends BaseRoomSessionConnection {
|
|
1007
|
-
constructor(options) {
|
|
1008
|
-
super(options);
|
|
1009
|
-
__publicField(this, "_deviceList", /* @__PURE__ */ new Set());
|
|
1010
|
-
__publicField(this, "_currentLayoutEvent");
|
|
1011
|
-
this.initWorker();
|
|
1012
|
-
}
|
|
1013
|
-
set currentLayoutEvent(event) {
|
|
1014
|
-
this._currentLayoutEvent = event;
|
|
1015
|
-
}
|
|
1016
|
-
get currentLayoutEvent() {
|
|
1017
|
-
return this._currentLayoutEvent;
|
|
1018
|
-
}
|
|
1019
|
-
get currentLayout() {
|
|
1020
|
-
var _a;
|
|
1021
|
-
return (_a = this._currentLayoutEvent) == null ? void 0 : _a.layout;
|
|
1022
|
-
}
|
|
1023
|
-
get currentPosition() {
|
|
1024
|
-
var _a, _b;
|
|
1025
|
-
return (_b = (_a = this._currentLayoutEvent) == null ? void 0 : _a.layout.layers.find(
|
|
1026
|
-
(layer) => layer.member_id === this.memberId
|
|
1027
|
-
)) == null ? void 0 : _b.position;
|
|
1028
|
-
}
|
|
1029
|
-
get deviceList() {
|
|
1030
|
-
return Array.from(this._deviceList);
|
|
1031
|
-
}
|
|
1032
|
-
get interactivityMode() {
|
|
1033
|
-
return this.select(({ session }) => {
|
|
1034
|
-
var _a;
|
|
1035
|
-
const { authorization } = session;
|
|
1036
|
-
return (_a = authorization == null ? void 0 : authorization.join_as) != null ? _a : "";
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
get permissions() {
|
|
1040
|
-
return this.select(({ session }) => {
|
|
1041
|
-
var _a, _b;
|
|
1042
|
-
const { authorization } = session;
|
|
1043
|
-
return (_b = (_a = authorization == null ? void 0 : authorization.room) == null ? void 0 : _a.scopes) != null ? _b : [];
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
initWorker() {
|
|
1047
|
-
this.runWorker("videoWorker", {
|
|
1048
|
-
worker: videoWorker
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
/** @internal */
|
|
1052
|
-
getSubscriptions() {
|
|
1053
|
-
const eventNamesWithPrefix = this.eventNames().map((event) => {
|
|
1054
|
-
return `video.${String(event)}`;
|
|
1055
|
-
});
|
|
1056
|
-
return (0, import_core17.validateEventsToSubscribe)(
|
|
1057
|
-
eventNamesWithPrefix
|
|
1058
|
-
);
|
|
1059
|
-
}
|
|
1060
|
-
/** @internal */
|
|
1061
|
-
_finalize() {
|
|
1062
|
-
this._deviceList.clear();
|
|
1063
|
-
super._finalize();
|
|
1064
|
-
}
|
|
1065
|
-
/** @internal */
|
|
1066
|
-
hangup(id) {
|
|
1067
|
-
return __async(this, null, function* () {
|
|
1068
|
-
this._deviceList.forEach((device) => {
|
|
1069
|
-
device.leave();
|
|
1070
|
-
});
|
|
1071
|
-
return __superGet(_VideoRoomSessionConnection.prototype, this, "hangup").call(this, id);
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
join() {
|
|
1075
|
-
return super.invite();
|
|
1076
|
-
}
|
|
1077
|
-
/**
|
|
1078
|
-
* @deprecated Use {@link getLayouts} instead. `getLayoutList` will
|
|
1079
|
-
* be removed in v3.0.0
|
|
1080
|
-
*/
|
|
1081
|
-
getLayoutList() {
|
|
1082
|
-
return this.getLayouts();
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* @deprecated Use {@link getMembers} instead. `getMemberList` will
|
|
1086
|
-
* be removed in v3.0.0
|
|
1087
|
-
*/
|
|
1088
|
-
getMemberList() {
|
|
1089
|
-
return this.getMembers();
|
|
1090
|
-
}
|
|
1091
|
-
/** @deprecated Use {@link startScreenShare} instead. */
|
|
1092
|
-
createScreenShareObject() {
|
|
1093
|
-
return __async(this, arguments, function* (opts = {}) {
|
|
1094
|
-
return this.startScreenShare(opts);
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* Allow to add a camera to the room.
|
|
1099
|
-
*/
|
|
1100
|
-
addCamera(opts = {}) {
|
|
1101
|
-
const _a = opts, { autoJoin = true } = _a, video = __objRest(_a, ["autoJoin"]);
|
|
1102
|
-
return this.addDevice({
|
|
1103
|
-
autoJoin,
|
|
1104
|
-
video
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Allow to add a microphone to the room.
|
|
1109
|
-
*/
|
|
1110
|
-
addMicrophone(opts = {}) {
|
|
1111
|
-
const _a = opts, { autoJoin = true } = _a, audio = __objRest(_a, ["autoJoin"]);
|
|
1112
|
-
return this.addDevice({
|
|
1113
|
-
autoJoin,
|
|
1114
|
-
audio
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
* Allow to add additional devices to the room like cameras or microphones.
|
|
1119
|
-
*/
|
|
1120
|
-
addDevice() {
|
|
1121
|
-
return __async(this, arguments, function* (opts = {}) {
|
|
1122
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
1123
|
-
var _a;
|
|
1124
|
-
const { autoJoin = true, audio = false, video = false } = opts;
|
|
1125
|
-
if (!audio && !video) {
|
|
1126
|
-
throw new TypeError(
|
|
1127
|
-
"At least one of `audio` or `video` must be requested."
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
const options = __spreadProps(__spreadValues({}, this.options), {
|
|
1131
|
-
localStream: void 0,
|
|
1132
|
-
remoteStream: void 0,
|
|
1133
|
-
audio,
|
|
1134
|
-
video,
|
|
1135
|
-
additionalDevice: true,
|
|
1136
|
-
recoverCall: false,
|
|
1137
|
-
userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
|
|
1138
|
-
memberCallId: this.callId,
|
|
1139
|
-
memberId: this.memberId
|
|
1140
|
-
})
|
|
1141
|
-
});
|
|
1142
|
-
const roomDevice = (0, import_core17.connect)({
|
|
1143
|
-
store: this.store,
|
|
1144
|
-
Component: RoomSessionDeviceAPI
|
|
1145
|
-
})(options);
|
|
1146
|
-
roomDevice.once("destroy", () => {
|
|
1147
|
-
roomDevice.emit("room.left");
|
|
1148
|
-
this._deviceList.delete(roomDevice);
|
|
1149
|
-
});
|
|
1150
|
-
try {
|
|
1151
|
-
roomDevice.runWorker("childMemberJoinedWorker", {
|
|
1152
|
-
worker: childMemberJoinedWorker,
|
|
1153
|
-
onDone: () => resolve(roomDevice),
|
|
1154
|
-
onFail: reject,
|
|
1155
|
-
initialState: {
|
|
1156
|
-
parentId: this.memberId
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
this._deviceList.add(roomDevice);
|
|
1160
|
-
if (autoJoin) {
|
|
1161
|
-
return yield roomDevice.join();
|
|
1162
|
-
}
|
|
1163
|
-
return resolve(roomDevice);
|
|
1164
|
-
} catch (error) {
|
|
1165
|
-
this.logger.error("RoomDevice Error", error);
|
|
1166
|
-
reject(error);
|
|
1167
|
-
}
|
|
1168
|
-
}));
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
var VideoRoomSessionAPI = (0, import_core17.extendComponent)(VideoRoomSessionConnection, {
|
|
1173
|
-
audioMute: import_core17.Rooms.audioMuteMember,
|
|
1174
|
-
audioUnmute: import_core17.Rooms.audioUnmuteMember,
|
|
1175
|
-
videoMute: import_core17.Rooms.videoMuteMember,
|
|
1176
|
-
videoUnmute: import_core17.Rooms.videoUnmuteMember,
|
|
1177
|
-
deaf: import_core17.Rooms.deafMember,
|
|
1178
|
-
undeaf: import_core17.Rooms.undeafMember,
|
|
1179
|
-
setInputVolume: import_core17.Rooms.setInputVolumeMember,
|
|
1180
|
-
setOutputVolume: import_core17.Rooms.setOutputVolumeMember,
|
|
1181
|
-
setMicrophoneVolume: import_core17.Rooms.setInputVolumeMember,
|
|
1182
|
-
setSpeakerVolume: import_core17.Rooms.setOutputVolumeMember,
|
|
1183
|
-
setInputSensitivity: import_core17.Rooms.setInputSensitivityMember,
|
|
1184
|
-
removeMember: import_core17.Rooms.removeMember,
|
|
1185
|
-
removeAllMembers: import_core17.Rooms.removeAllMembers,
|
|
1186
|
-
getMembers: import_core17.Rooms.getMembers,
|
|
1187
|
-
getLayouts: import_core17.Rooms.getLayouts,
|
|
1188
|
-
setLayout: import_core17.Rooms.setLayout,
|
|
1189
|
-
setPositions: import_core17.Rooms.setPositions,
|
|
1190
|
-
setMemberPosition: import_core17.Rooms.setMemberPosition,
|
|
1191
|
-
hideVideoMuted: import_core17.Rooms.hideVideoMuted,
|
|
1192
|
-
showVideoMuted: import_core17.Rooms.showVideoMuted,
|
|
1193
|
-
getRecordings: import_core17.Rooms.getRecordings,
|
|
1194
|
-
startRecording: import_core17.Rooms.startRecording,
|
|
1195
|
-
getPlaybacks: import_core17.Rooms.getPlaybacks,
|
|
1196
|
-
play: import_core17.Rooms.play,
|
|
1197
|
-
setHideVideoMuted: import_core17.Rooms.setHideVideoMuted,
|
|
1198
|
-
getMeta: import_core17.Rooms.getMeta,
|
|
1199
|
-
setMeta: import_core17.Rooms.setMeta,
|
|
1200
|
-
updateMeta: import_core17.Rooms.updateMeta,
|
|
1201
|
-
deleteMeta: import_core17.Rooms.deleteMeta,
|
|
1202
|
-
getMemberMeta: import_core17.Rooms.getMemberMeta,
|
|
1203
|
-
setMemberMeta: import_core17.Rooms.setMemberMeta,
|
|
1204
|
-
updateMemberMeta: import_core17.Rooms.updateMemberMeta,
|
|
1205
|
-
deleteMemberMeta: import_core17.Rooms.deleteMemberMeta,
|
|
1206
|
-
promote: import_core17.Rooms.promote,
|
|
1207
|
-
demote: import_core17.Rooms.demote,
|
|
1208
|
-
getStreams: import_core17.Rooms.getStreams,
|
|
1209
|
-
startStream: import_core17.Rooms.startStream,
|
|
1210
|
-
lock: import_core17.Rooms.lock,
|
|
1211
|
-
unlock: import_core17.Rooms.unlock,
|
|
1212
|
-
setRaisedHand: import_core17.Rooms.setRaisedHand,
|
|
1213
|
-
setPrioritizeHandraise: import_core17.Rooms.setPrioritizeHandraise
|
|
1214
|
-
});
|
|
1215
|
-
var isVideoRoomSession = (room) => {
|
|
1216
|
-
return room instanceof VideoRoomSessionConnection;
|
|
1217
|
-
};
|
|
1218
|
-
var createVideoRoomSessionObject = (params) => {
|
|
1219
|
-
const room = (0, import_core17.connect)({
|
|
1220
|
-
store: params.store,
|
|
1221
|
-
customSagas: params.customSagas,
|
|
1222
|
-
Component: VideoRoomSessionAPI
|
|
1223
|
-
})(params);
|
|
1224
|
-
return room;
|
|
1225
|
-
};
|
|
1226
|
-
|
|
1227
|
-
// src/fabric/FabricRoomSession.ts
|
|
1228
|
-
var import_core27 = require("@signalwire/core");
|
|
1229
|
-
|
|
1230
|
-
// src/utils/storage.ts
|
|
1231
|
-
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
1232
|
-
var import_core18 = require("@signalwire/core");
|
|
1233
|
-
var getStorage = () => {
|
|
1234
|
-
if (window && window.sessionStorage) {
|
|
1235
|
-
return window.sessionStorage;
|
|
1236
|
-
}
|
|
1237
|
-
return void 0;
|
|
1238
|
-
};
|
|
1239
|
-
var sessionStorageManager = (token) => {
|
|
1240
|
-
var _a;
|
|
1241
|
-
let roomName = "";
|
|
1242
|
-
try {
|
|
1243
|
-
const jwtPayload = (0, import_jwt_decode.default)(token);
|
|
1244
|
-
roomName = (_a = jwtPayload == null ? void 0 : jwtPayload.r) != null ? _a : "";
|
|
1245
|
-
} catch (e) {
|
|
1246
|
-
try {
|
|
1247
|
-
const jwtPayload = (0, import_jwt_decode.default)(token, { header: true });
|
|
1248
|
-
roomName = jwtPayload.typ || "";
|
|
1249
|
-
} catch (e2) {
|
|
1250
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1251
|
-
(0, import_core18.getLogger)().error("[sessionStorageManager] error decoding JWT", token);
|
|
1252
|
-
}
|
|
1253
|
-
roomName = "";
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
const valid = Boolean(roomName);
|
|
1257
|
-
return {
|
|
1258
|
-
authStateKey: valid && `as-${roomName}`,
|
|
1259
|
-
protocolKey: valid && `pt-${roomName}`,
|
|
1260
|
-
callIdKey: valid && `ci-${roomName}`
|
|
1261
|
-
};
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
// src/fabric/utils/constants.ts
|
|
1265
|
-
var PREVIOUS_CALLID_STORAGE_KEY = "ci-SAT";
|
|
1266
|
-
var DEFAULT_API_REQUEST_RETRIES = 10;
|
|
1267
|
-
var DEFAULT_API_REQUEST_RETRIES_DELAY = 300;
|
|
1268
|
-
var DEFAULT_API_REQUEST_RETRIES_DELAY_INCREMENT = 100;
|
|
1269
|
-
|
|
1270
|
-
// src/fabric/workers/wsClientWorker.ts
|
|
1271
|
-
var import_core19 = require("@signalwire/core");
|
|
1272
|
-
var wsClientWorker = function* (options) {
|
|
1273
|
-
(0, import_core19.getLogger)().debug("wsClientWorker started");
|
|
1274
|
-
const { channels, initialState, instance: client } = options;
|
|
1275
|
-
const { swEventChannel } = channels;
|
|
1276
|
-
const { handleIncomingInvite } = initialState;
|
|
1277
|
-
function* fireHoseWorker(action) {
|
|
1278
|
-
client.emit(action.type, action.payload);
|
|
1279
|
-
}
|
|
1280
|
-
function* vertoInviteWorker(action) {
|
|
1281
|
-
handleIncomingInvite(action.payload.params);
|
|
1282
|
-
}
|
|
1283
|
-
const isVertoInvite2 = (action) => {
|
|
1284
|
-
if (action.type === "webrtc.message") {
|
|
1285
|
-
return action.payload.method === "verto.invite";
|
|
1286
|
-
}
|
|
1287
|
-
return false;
|
|
1288
|
-
};
|
|
1289
|
-
try {
|
|
1290
|
-
while (true) {
|
|
1291
|
-
const action = yield import_core19.sagaEffects.take(
|
|
1292
|
-
swEventChannel,
|
|
1293
|
-
() => true
|
|
1294
|
-
);
|
|
1295
|
-
yield import_core19.sagaEffects.fork(fireHoseWorker, action);
|
|
1296
|
-
if (isVertoInvite2(action)) {
|
|
1297
|
-
(0, import_core19.getLogger)().debug("Receiving a call over WebSocket", action);
|
|
1298
|
-
yield import_core19.sagaEffects.fork(
|
|
1299
|
-
vertoInviteWorker,
|
|
1300
|
-
action
|
|
1301
|
-
);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
} finally {
|
|
1305
|
-
(0, import_core19.getLogger)().trace("wsClientWorker ended");
|
|
1306
|
-
}
|
|
1307
|
-
};
|
|
1308
|
-
|
|
1309
|
-
// src/fabric/workers/fabricWorker.ts
|
|
1310
|
-
var import_core25 = require("@signalwire/core");
|
|
1311
|
-
|
|
1312
|
-
// src/fabric/FabricRoomSessionMember.ts
|
|
1313
|
-
var import_core20 = require("@signalwire/core");
|
|
1314
|
-
var FabricRoomSessionMemberAPI = class extends import_core20.BaseComponent {
|
|
1315
|
-
constructor(options) {
|
|
1316
|
-
super(options);
|
|
1317
|
-
__publicField(this, "_payload");
|
|
1318
|
-
this._payload = options.payload;
|
|
1319
|
-
}
|
|
1320
|
-
get id() {
|
|
1321
|
-
return this._payload.member.member_id;
|
|
1322
|
-
}
|
|
1323
|
-
get callId() {
|
|
1324
|
-
return this._payload.member.call_id;
|
|
1325
|
-
}
|
|
1326
|
-
get nodeId() {
|
|
1327
|
-
return this._payload.member.node_id;
|
|
1328
|
-
}
|
|
1329
|
-
get memberId() {
|
|
1330
|
-
return this.id;
|
|
1331
|
-
}
|
|
1332
|
-
get roomSessionId() {
|
|
1333
|
-
return this._payload.room_session_id;
|
|
1334
|
-
}
|
|
1335
|
-
get roomId() {
|
|
1336
|
-
return this._payload.room_id;
|
|
1337
|
-
}
|
|
1338
|
-
get parentId() {
|
|
1339
|
-
return this._payload.member.parent_id;
|
|
1340
|
-
}
|
|
1341
|
-
get subscriberId() {
|
|
1342
|
-
return this._payload.member.subscriber_id;
|
|
1343
|
-
}
|
|
1344
|
-
get addressId() {
|
|
1345
|
-
return this._payload.member.address_id;
|
|
1346
|
-
}
|
|
1347
|
-
get name() {
|
|
1348
|
-
return this._payload.member.name;
|
|
1349
|
-
}
|
|
1350
|
-
get type() {
|
|
1351
|
-
return this._payload.member.type;
|
|
1352
|
-
}
|
|
1353
|
-
get requestedPosition() {
|
|
1354
|
-
return this._payload.member.requested_position;
|
|
1355
|
-
}
|
|
1356
|
-
get currentPosition() {
|
|
1357
|
-
return this._payload.member.current_position;
|
|
1358
|
-
}
|
|
1359
|
-
get meta() {
|
|
1360
|
-
return this._payload.member.meta;
|
|
1361
|
-
}
|
|
1362
|
-
get handraised() {
|
|
1363
|
-
return this._payload.member.handraised;
|
|
1364
|
-
}
|
|
1365
|
-
get talking() {
|
|
1366
|
-
return this._payload.member.talking;
|
|
1367
|
-
}
|
|
1368
|
-
get audioMuted() {
|
|
1369
|
-
return this._payload.member.audio_muted;
|
|
1370
|
-
}
|
|
1371
|
-
get videoMuted() {
|
|
1372
|
-
return this._payload.member.video_muted;
|
|
1373
|
-
}
|
|
1374
|
-
get deaf() {
|
|
1375
|
-
return this._payload.member.deaf;
|
|
1376
|
-
}
|
|
1377
|
-
get visible() {
|
|
1378
|
-
return this._payload.member.visible;
|
|
1379
|
-
}
|
|
1380
|
-
get inputVolume() {
|
|
1381
|
-
return this._payload.member.input_volume;
|
|
1382
|
-
}
|
|
1383
|
-
get outputVolume() {
|
|
1384
|
-
return this._payload.member.output_volume;
|
|
1385
|
-
}
|
|
1386
|
-
get inputSensitivity() {
|
|
1387
|
-
return this._payload.member.input_sensitivity;
|
|
1388
|
-
}
|
|
1389
|
-
get echoCancellation() {
|
|
1390
|
-
return this._payload.member.echo_cancellation;
|
|
1391
|
-
}
|
|
1392
|
-
get autoGain() {
|
|
1393
|
-
return this._payload.member.auto_gain;
|
|
1394
|
-
}
|
|
1395
|
-
get noiseSuppression() {
|
|
1396
|
-
return this._payload.member.noise_suppression;
|
|
1397
|
-
}
|
|
1398
|
-
/** @internal */
|
|
1399
|
-
setPayload(payload) {
|
|
1400
|
-
const newPayload = __spreadProps(__spreadValues(__spreadValues({}, this._payload), payload), {
|
|
1401
|
-
member: __spreadValues(__spreadValues({}, this._payload.member), payload.member)
|
|
1402
|
-
});
|
|
1403
|
-
this._payload = newPayload;
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
var createFabricRoomSessionMemberObject = (params) => {
|
|
1407
|
-
const member = (0, import_core20.connect)({
|
|
1408
|
-
store: params.store,
|
|
1409
|
-
Component: FabricRoomSessionMemberAPI
|
|
1410
|
-
})(params);
|
|
1411
|
-
return member;
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
// src/fabric/workers/callSegmentWorker.ts
|
|
1415
|
-
var import_core24 = require("@signalwire/core");
|
|
1416
|
-
|
|
1417
|
-
// src/fabric/workers/callLeftWorker.ts
|
|
1418
|
-
var import_core21 = require("@signalwire/core");
|
|
1419
|
-
var callLeftWorker = function* (options) {
|
|
1420
|
-
(0, import_core21.getLogger)().trace("callLeftWorker started");
|
|
1421
|
-
const {
|
|
1422
|
-
action: { payload },
|
|
1423
|
-
instance: cfRoomSession,
|
|
1424
|
-
instanceMap
|
|
1425
|
-
} = options;
|
|
1426
|
-
const { room_session_id } = payload;
|
|
1427
|
-
instanceMap.getAll().forEach(([key, obj]) => {
|
|
1428
|
-
if (obj instanceof FabricRoomSessionMemberAPI && obj.roomSessionId === room_session_id) {
|
|
1429
|
-
instanceMap.remove(key);
|
|
1430
|
-
}
|
|
1431
|
-
});
|
|
1432
|
-
cfRoomSession.emit("call.left", payload);
|
|
1433
|
-
cfRoomSession.emit("room.left", payload);
|
|
1434
|
-
(0, import_core21.getLogger)().trace("callLeftWorker ended");
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
// src/fabric/workers/callJoinWorker.ts
|
|
1438
|
-
var import_core23 = require("@signalwire/core");
|
|
1439
|
-
|
|
1440
|
-
// src/fabric/workers/fabricMemberWorker.ts
|
|
1441
|
-
var import_core22 = require("@signalwire/core");
|
|
1442
|
-
var fabricMemberWorker = function* (options) {
|
|
1443
|
-
(0, import_core22.getLogger)().trace("fabricMemberWorker started");
|
|
1444
|
-
const {
|
|
1445
|
-
instance: roomSession,
|
|
1446
|
-
action: { type, payload },
|
|
1447
|
-
instanceMap: { get, set, remove }
|
|
1448
|
-
} = options;
|
|
1449
|
-
const memberId = payload.member.member_id;
|
|
1450
|
-
let memberInstance = get(memberId);
|
|
1451
|
-
if (!memberInstance && type !== "member.talking") {
|
|
1452
|
-
memberInstance = createFabricRoomSessionMemberObject({
|
|
1453
|
-
store: roomSession.store,
|
|
1454
|
-
payload
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
if (memberInstance) {
|
|
1458
|
-
memberInstance.setPayload(payload);
|
|
1459
|
-
}
|
|
1460
|
-
set(memberId, memberInstance);
|
|
1461
|
-
if (type.startsWith("member.updated.")) {
|
|
1462
|
-
const clientType = (0, import_core22.fromSnakeToCamelCase)(type);
|
|
1463
|
-
roomSession.emit(clientType, payload);
|
|
1464
|
-
}
|
|
1465
|
-
switch (type) {
|
|
1466
|
-
case "member.joined":
|
|
1467
|
-
roomSession.emit(type, payload);
|
|
1468
|
-
break;
|
|
1469
|
-
case "member.updated":
|
|
1470
|
-
roomSession.emit(type, payload);
|
|
1471
|
-
break;
|
|
1472
|
-
case "member.left":
|
|
1473
|
-
roomSession.emit(type, payload);
|
|
1474
|
-
remove(memberId);
|
|
1475
|
-
break;
|
|
1476
|
-
case "member.talking":
|
|
1477
|
-
roomSession.emit(type, payload);
|
|
1478
|
-
break;
|
|
1479
|
-
default:
|
|
1480
|
-
break;
|
|
1481
|
-
}
|
|
1482
|
-
(0, import_core22.getLogger)().trace("fabricMemberWorker ended");
|
|
1483
|
-
};
|
|
1484
|
-
|
|
1485
|
-
// src/fabric/utils/capabilitiesHelpers.ts
|
|
1486
|
-
var CapabilityOnOffState = class {
|
|
1487
|
-
constructor(_flags) {
|
|
1488
|
-
this._flags = _flags;
|
|
1489
|
-
}
|
|
1490
|
-
get on() {
|
|
1491
|
-
return this._flags.some((flag) => !flag.endsWith(".off"));
|
|
1492
|
-
}
|
|
1493
|
-
get off() {
|
|
1494
|
-
return this._flags.some((flag) => !flag.endsWith(".on"));
|
|
1495
|
-
}
|
|
1496
|
-
};
|
|
1497
|
-
var MemberCapability = class {
|
|
1498
|
-
constructor(_flags, _memberType) {
|
|
1499
|
-
this._flags = _flags;
|
|
1500
|
-
this._memberType = _memberType;
|
|
1501
|
-
__publicField(this, "_muteAudio");
|
|
1502
|
-
__publicField(this, "_muteVideo");
|
|
1503
|
-
__publicField(this, "_deaf");
|
|
1504
|
-
__publicField(this, "_raisehand");
|
|
1505
|
-
}
|
|
1506
|
-
get muteAudio() {
|
|
1507
|
-
var _a;
|
|
1508
|
-
this._muteAudio = (_a = this._muteAudio) != null ? _a : new CapabilityOnOffState(
|
|
1509
|
-
this._flags.filter(
|
|
1510
|
-
(flag) => flag === this._memberType || flag === `${this._memberType}.mute` || flag.startsWith(`${this._memberType}.mute.audio`)
|
|
1511
|
-
)
|
|
1512
|
-
);
|
|
1513
|
-
return this._muteAudio;
|
|
1514
|
-
}
|
|
1515
|
-
get muteVideo() {
|
|
1516
|
-
var _a;
|
|
1517
|
-
this._muteVideo = (_a = this._muteVideo) != null ? _a : new CapabilityOnOffState(
|
|
1518
|
-
this._flags.filter(
|
|
1519
|
-
(flag) => flag === this._memberType || flag === `${this._memberType}.mute` || flag.startsWith(`${this._memberType}.mute.video`)
|
|
1520
|
-
)
|
|
1521
|
-
);
|
|
1522
|
-
return this._muteVideo;
|
|
1523
|
-
}
|
|
1524
|
-
get microphoneVolume() {
|
|
1525
|
-
return this._flags.some(
|
|
1526
|
-
(flag) => flag === this._memberType || flag === `${this._memberType}.microphone` || flag.startsWith(`${this._memberType}.microphone.volume`)
|
|
1527
|
-
);
|
|
1528
|
-
}
|
|
1529
|
-
get microphoneSensitivity() {
|
|
1530
|
-
return this._flags.some(
|
|
1531
|
-
(flag) => flag === this._memberType || flag === `${this._memberType}.microphone` || flag.startsWith(`${this._memberType}.microphone.sensitivity`)
|
|
1532
|
-
);
|
|
1533
|
-
}
|
|
1534
|
-
get speakerVolume() {
|
|
1535
|
-
return this._flags.some(
|
|
1536
|
-
(flag) => flag === this._memberType || flag === `${this._memberType}.speaker` || flag.startsWith(`${this._memberType}.speaker.volume`)
|
|
1537
|
-
);
|
|
1538
|
-
}
|
|
1539
|
-
get deaf() {
|
|
1540
|
-
var _a;
|
|
1541
|
-
this._deaf = (_a = this._deaf) != null ? _a : new CapabilityOnOffState(
|
|
1542
|
-
this._flags.filter(
|
|
1543
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.deaf`)
|
|
1544
|
-
)
|
|
1545
|
-
);
|
|
1546
|
-
return this._deaf;
|
|
1547
|
-
}
|
|
1548
|
-
get raisehand() {
|
|
1549
|
-
var _a;
|
|
1550
|
-
this._raisehand = (_a = this._raisehand) != null ? _a : new CapabilityOnOffState(
|
|
1551
|
-
this._flags.filter(
|
|
1552
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.raisehand`)
|
|
1553
|
-
)
|
|
1554
|
-
);
|
|
1555
|
-
return this._raisehand;
|
|
1556
|
-
}
|
|
1557
|
-
get position() {
|
|
1558
|
-
return this._flags.some(
|
|
1559
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.position`)
|
|
1560
|
-
);
|
|
1561
|
-
}
|
|
1562
|
-
get meta() {
|
|
1563
|
-
return this._flags.some(
|
|
1564
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.meta`)
|
|
1565
|
-
);
|
|
1566
|
-
}
|
|
1567
|
-
get remove() {
|
|
1568
|
-
return this._flags.some(
|
|
1569
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.remove`)
|
|
1570
|
-
);
|
|
1571
|
-
}
|
|
1572
|
-
get audioFlags() {
|
|
1573
|
-
return this._flags.some(
|
|
1574
|
-
(flag) => flag === this._memberType || flag.startsWith(`${this._memberType}.audioflags.set`)
|
|
1575
|
-
);
|
|
1576
|
-
}
|
|
1577
|
-
};
|
|
1578
|
-
var CallCapabilities = class {
|
|
1579
|
-
constructor(_flags) {
|
|
1580
|
-
this._flags = _flags;
|
|
1581
|
-
__publicField(this, "_self");
|
|
1582
|
-
__publicField(this, "_member");
|
|
1583
|
-
__publicField(this, "_vmutedHide");
|
|
1584
|
-
__publicField(this, "_lock");
|
|
1585
|
-
}
|
|
1586
|
-
_buildMemberCapability(memberType) {
|
|
1587
|
-
return new MemberCapability(
|
|
1588
|
-
this._flags.filter((flag) => flag.startsWith(memberType)),
|
|
1589
|
-
memberType
|
|
1590
|
-
);
|
|
1591
|
-
}
|
|
1592
|
-
get self() {
|
|
1593
|
-
var _a;
|
|
1594
|
-
this._self = (_a = this._self) != null ? _a : this._buildMemberCapability("self");
|
|
1595
|
-
return this._self;
|
|
1596
|
-
}
|
|
1597
|
-
get member() {
|
|
1598
|
-
var _a;
|
|
1599
|
-
this._member = (_a = this._member) != null ? _a : this._buildMemberCapability("member");
|
|
1600
|
-
return this._member;
|
|
1601
|
-
}
|
|
1602
|
-
get end() {
|
|
1603
|
-
return this._flags.some((capability) => capability === "end");
|
|
1604
|
-
}
|
|
1605
|
-
get setLayout() {
|
|
1606
|
-
return this._flags.some((capability) => capability.startsWith("layout"));
|
|
1607
|
-
}
|
|
1608
|
-
get sendDigit() {
|
|
1609
|
-
return this._flags.some((capability) => capability.startsWith("digit"));
|
|
1610
|
-
}
|
|
1611
|
-
get vmutedHide() {
|
|
1612
|
-
var _a;
|
|
1613
|
-
this._vmutedHide = (_a = this._vmutedHide) != null ? _a : new CapabilityOnOffState(
|
|
1614
|
-
this._flags.filter((flag) => flag.startsWith("vmuted"))
|
|
1615
|
-
);
|
|
1616
|
-
return this._vmutedHide;
|
|
1617
|
-
}
|
|
1618
|
-
get lock() {
|
|
1619
|
-
var _a;
|
|
1620
|
-
this._lock = (_a = this._lock) != null ? _a : new CapabilityOnOffState(
|
|
1621
|
-
this._flags.filter((flag) => flag.startsWith("lock"))
|
|
1622
|
-
);
|
|
1623
|
-
return this._lock;
|
|
1624
|
-
}
|
|
1625
|
-
get device() {
|
|
1626
|
-
return this._flags.some((capability) => capability === "device");
|
|
1627
|
-
}
|
|
1628
|
-
get screenshare() {
|
|
1629
|
-
return this._flags.some((capability) => capability === "screenshare");
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
var mapCapabilityPayload = (capabilities) => new CallCapabilities(capabilities);
|
|
1633
|
-
|
|
1634
|
-
// src/fabric/utils/eventMappers.ts
|
|
1635
|
-
var mapInternalFabricMemberToInternalVideoMemberEntity = (params) => {
|
|
1636
|
-
return __spreadProps(__spreadValues({}, params), {
|
|
1637
|
-
id: params.member_id
|
|
1638
|
-
});
|
|
1639
|
-
};
|
|
1640
|
-
var mapInternalFabricMemberToInternalVideoMemberUpdatedEntity = (params) => {
|
|
1641
|
-
return __spreadProps(__spreadValues({}, mapInternalFabricMemberToInternalVideoMemberEntity(params)), {
|
|
1642
|
-
updated: params.updated.map(
|
|
1643
|
-
(key) => key === "member_id" ? "id" : key
|
|
1644
|
-
)
|
|
1645
|
-
});
|
|
1646
|
-
};
|
|
1647
|
-
var mapCallJoinedToRoomSubscribedEventParams = (params) => {
|
|
1648
|
-
return __spreadProps(__spreadValues({}, params), {
|
|
1649
|
-
room: __spreadProps(__spreadValues({}, params.room_session), {
|
|
1650
|
-
members: params.room_session.members.map(
|
|
1651
|
-
mapInternalFabricMemberToInternalVideoMemberEntity
|
|
1652
|
-
)
|
|
1653
|
-
}),
|
|
1654
|
-
room_session: __spreadProps(__spreadValues({}, params.room_session), {
|
|
1655
|
-
members: params.room_session.members.map(
|
|
1656
|
-
mapInternalFabricMemberToInternalVideoMemberEntity
|
|
1657
|
-
)
|
|
1658
|
-
})
|
|
1659
|
-
});
|
|
1660
|
-
};
|
|
1661
|
-
var mapFabricMemberToVideoMemberJoinAndLeftEventParams = (params) => {
|
|
1662
|
-
return {
|
|
1663
|
-
room_session_id: params.room_session_id,
|
|
1664
|
-
room_id: params.room_id,
|
|
1665
|
-
member: mapInternalFabricMemberToInternalVideoMemberEntity(params.member)
|
|
1666
|
-
};
|
|
1667
|
-
};
|
|
1668
|
-
var mapFabricMemberActionToVideoMemberJoinAndLeftAction = (action) => {
|
|
1669
|
-
return {
|
|
1670
|
-
type: `video.${action.type}`,
|
|
1671
|
-
payload: mapFabricMemberToVideoMemberJoinAndLeftEventParams(action.payload)
|
|
1672
|
-
};
|
|
1673
|
-
};
|
|
1674
|
-
var mapFabricMemberEventToVideoMemberUpdatedEventParams = (params) => {
|
|
1675
|
-
return {
|
|
1676
|
-
room_session_id: params.room_session_id,
|
|
1677
|
-
room_id: params.room_id,
|
|
1678
|
-
member: mapInternalFabricMemberToInternalVideoMemberUpdatedEntity(
|
|
1679
|
-
params.member
|
|
1680
|
-
)
|
|
1681
|
-
};
|
|
1682
|
-
};
|
|
1683
|
-
var mapFabricMemberActionToVideoMemberUpdatedAction = (action) => {
|
|
1684
|
-
return {
|
|
1685
|
-
type: `video.${action.type}`,
|
|
1686
|
-
payload: mapFabricMemberEventToVideoMemberUpdatedEventParams(
|
|
1687
|
-
action.payload
|
|
1688
|
-
)
|
|
1689
|
-
};
|
|
1690
|
-
};
|
|
1691
|
-
var mapFabricLayoutActionToVideoLayoutAction = (action) => {
|
|
1692
|
-
return {
|
|
1693
|
-
type: `video.${action.type}`,
|
|
1694
|
-
payload: action.payload
|
|
1695
|
-
};
|
|
1696
|
-
};
|
|
1697
|
-
|
|
1698
|
-
// src/fabric/workers/callJoinWorker.ts
|
|
1699
|
-
var callJoinWorker = function* (options) {
|
|
1700
|
-
var _a;
|
|
1701
|
-
(0, import_core23.getLogger)().trace("callJoinWorker started");
|
|
1702
|
-
const { action, instanceMap, instance: cfRoomSession } = options;
|
|
1703
|
-
const { payload } = action;
|
|
1704
|
-
const { get, set } = instanceMap;
|
|
1705
|
-
yield import_core23.sagaEffects.fork(import_core23.MemberPosition.memberPositionWorker, __spreadProps(__spreadValues({}, options), {
|
|
1706
|
-
/**
|
|
1707
|
-
* The {@link memberPositionWorker} worker understands only the Video SDK events.
|
|
1708
|
-
* So, we need to map CF SDK event to Video SDK event.
|
|
1709
|
-
* Similar to what we do in the {@link callSegmentWorker}, for member events.
|
|
1710
|
-
*/
|
|
1711
|
-
initialState: mapCallJoinedToRoomSubscribedEventParams(payload),
|
|
1712
|
-
dispatcher: function* (subType, subPayload) {
|
|
1713
|
-
const fabricType = (0, import_core23.stripNamespacePrefix)(subType, "video");
|
|
1714
|
-
const fabricPaylod = __spreadProps(__spreadValues({}, subPayload), {
|
|
1715
|
-
member: __spreadProps(__spreadValues({}, subPayload.member), {
|
|
1716
|
-
member_id: subPayload.member.id
|
|
1717
|
-
})
|
|
1718
|
-
});
|
|
1719
|
-
yield import_core23.sagaEffects.fork(fabricMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1720
|
-
action: { type: fabricType, payload: fabricPaylod }
|
|
1721
|
-
}));
|
|
1722
|
-
}
|
|
1723
|
-
}));
|
|
1724
|
-
(_a = payload.room_session.members) == null ? void 0 : _a.forEach((member) => {
|
|
1725
|
-
let memberInstance = get(member.member_id);
|
|
1726
|
-
if (!memberInstance) {
|
|
1727
|
-
memberInstance = createFabricRoomSessionMemberObject({
|
|
1728
|
-
store: cfRoomSession.store,
|
|
1729
|
-
payload: {
|
|
1730
|
-
member,
|
|
1731
|
-
room_id: payload.room_id,
|
|
1732
|
-
room_session_id: payload.room_session_id
|
|
1733
|
-
}
|
|
1734
|
-
});
|
|
1735
|
-
} else {
|
|
1736
|
-
memberInstance.setPayload({
|
|
1737
|
-
member,
|
|
1738
|
-
room_id: payload.room_id,
|
|
1739
|
-
room_session_id: payload.room_session_id
|
|
1740
|
-
});
|
|
1741
|
-
}
|
|
1742
|
-
set(member.member_id, memberInstance);
|
|
1743
|
-
});
|
|
1744
|
-
cfRoomSession.member = get(payload.member_id);
|
|
1745
|
-
cfRoomSession.capabilities = mapCapabilityPayload(payload.capabilities);
|
|
1746
|
-
const fabricEvent = __spreadProps(__spreadValues({}, payload), {
|
|
1747
|
-
capabilities: cfRoomSession.capabilities
|
|
1748
|
-
});
|
|
1749
|
-
cfRoomSession.emit("call.joined", fabricEvent);
|
|
1750
|
-
(0, import_core23.getLogger)().trace("callJoinWorker ended");
|
|
1751
|
-
};
|
|
1752
|
-
|
|
1753
|
-
// src/fabric/workers/callSegmentWorker.ts
|
|
1754
|
-
var callSegmentWorker = function* (options) {
|
|
1755
|
-
const {
|
|
1756
|
-
action,
|
|
1757
|
-
channels: { swEventChannel },
|
|
1758
|
-
instance: cfRoomSession
|
|
1759
|
-
} = options;
|
|
1760
|
-
const segmentCallId = action.payload.call_id;
|
|
1761
|
-
const segmentRooSessionId = action.payload.room_session_id;
|
|
1762
|
-
(0, import_core24.getLogger)().debug(
|
|
1763
|
-
`callSegmentWorker started for: callId ${segmentCallId}, roomSessionId ${segmentRooSessionId}`
|
|
1764
|
-
);
|
|
1765
|
-
yield import_core24.sagaEffects.fork(callJoinWorker, __spreadProps(__spreadValues({}, options), {
|
|
1766
|
-
action
|
|
1767
|
-
}));
|
|
1768
|
-
function* worker(action2) {
|
|
1769
|
-
const { type, payload } = action2;
|
|
1770
|
-
switch (type) {
|
|
1771
|
-
case "call.joined":
|
|
1772
|
-
break;
|
|
1773
|
-
case "call.left":
|
|
1774
|
-
yield import_core24.sagaEffects.call(callLeftWorker, __spreadProps(__spreadValues({}, options), {
|
|
1775
|
-
action: action2
|
|
1776
|
-
}));
|
|
1777
|
-
return true;
|
|
1778
|
-
case "call.updated":
|
|
1779
|
-
cfRoomSession.emit(type, payload);
|
|
1780
|
-
cfRoomSession.emit("room.updated", payload);
|
|
1781
|
-
break;
|
|
1782
|
-
case "call.play":
|
|
1783
|
-
cfRoomSession.emit(type, payload);
|
|
1784
|
-
break;
|
|
1785
|
-
case "call.connect":
|
|
1786
|
-
cfRoomSession.emit(type, payload);
|
|
1787
|
-
break;
|
|
1788
|
-
case "call.room":
|
|
1789
|
-
cfRoomSession.emit(type, payload);
|
|
1790
|
-
break;
|
|
1791
|
-
/**
|
|
1792
|
-
* The Core module includes a generic worker, {@link memberPositionWorker},
|
|
1793
|
-
* which listens for member & layout events to add a "current_position" parameter
|
|
1794
|
-
* and handle member "updated" parameter.
|
|
1795
|
-
* This worker in CF SDK is initialized by the {@link callJoinWorker} worker.
|
|
1796
|
-
*
|
|
1797
|
-
* To ensure compatibility, we map these events to Video SDK events and
|
|
1798
|
-
* re-publish them on the channel so that they can be processed by the
|
|
1799
|
-
* generic worker. Note that the generic worker only dispatches "member.updated"
|
|
1800
|
-
* and "member.updated.*" events.
|
|
1801
|
-
*
|
|
1802
|
-
* Additionally, the "member.joined" event is monitored by another worker,
|
|
1803
|
-
* {@link childMemberJoinedWorker}, specifically for the screen share API.
|
|
1804
|
-
*/
|
|
1805
|
-
case "member.joined":
|
|
1806
|
-
case "member.left": {
|
|
1807
|
-
yield import_core24.sagaEffects.fork(fabricMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1808
|
-
action: action2
|
|
1809
|
-
}));
|
|
1810
|
-
const videoAction = mapFabricMemberActionToVideoMemberJoinAndLeftAction(action2);
|
|
1811
|
-
yield import_core24.sagaEffects.put(swEventChannel, videoAction);
|
|
1812
|
-
break;
|
|
1813
|
-
}
|
|
1814
|
-
case "member.updated": {
|
|
1815
|
-
const videoAction = mapFabricMemberActionToVideoMemberUpdatedAction(action2);
|
|
1816
|
-
yield import_core24.sagaEffects.put(swEventChannel, videoAction);
|
|
1817
|
-
break;
|
|
1818
|
-
}
|
|
1819
|
-
case "layout.changed": {
|
|
1820
|
-
cfRoomSession.currentLayoutEvent = action2.payload;
|
|
1821
|
-
cfRoomSession.emit(type, payload);
|
|
1822
|
-
const videoAction = mapFabricLayoutActionToVideoLayoutAction(action2);
|
|
1823
|
-
yield import_core24.sagaEffects.put(swEventChannel, videoAction);
|
|
1824
|
-
break;
|
|
1825
|
-
}
|
|
1826
|
-
case "member.talking": {
|
|
1827
|
-
yield import_core24.sagaEffects.fork(fabricMemberWorker, __spreadProps(__spreadValues({}, options), {
|
|
1828
|
-
action: action2
|
|
1829
|
-
}));
|
|
1830
|
-
break;
|
|
1831
|
-
}
|
|
1832
|
-
default: {
|
|
1833
|
-
(0, import_core24.getLogger)().warn("Got an unknown fabric event", action2);
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
|
-
return false;
|
|
1837
|
-
}
|
|
1838
|
-
const isSegmentEvent = (action2) => {
|
|
1839
|
-
const { type, payload } = action2;
|
|
1840
|
-
const shouldWatch = type.startsWith("call.") || type.startsWith("member.") || type.startsWith("layout.");
|
|
1841
|
-
const hasSegmentCallId = "call_id" in payload && segmentCallId === payload.call_id;
|
|
1842
|
-
const hasSegmentRoomSessionId = segmentRooSessionId === payload.room_session_id;
|
|
1843
|
-
if (shouldWatch && (hasSegmentCallId || hasSegmentRoomSessionId)) {
|
|
1844
|
-
return true;
|
|
1845
|
-
}
|
|
1846
|
-
return false;
|
|
1847
|
-
};
|
|
1848
|
-
while (true) {
|
|
1849
|
-
const action2 = yield import_core24.sagaEffects.take(
|
|
1850
|
-
swEventChannel,
|
|
1851
|
-
isSegmentEvent
|
|
1852
|
-
);
|
|
1853
|
-
const task = yield import_core24.sagaEffects.fork(worker, action2);
|
|
1854
|
-
const shouldStop = yield import_core24.sagaEffects.join(task);
|
|
1855
|
-
if (shouldStop) return;
|
|
1856
|
-
}
|
|
1857
|
-
};
|
|
1858
|
-
|
|
1859
|
-
// src/fabric/workers/fabricWorker.ts
|
|
1860
|
-
var fabricWorker = function* (options) {
|
|
1861
|
-
(0, import_core25.getLogger)().trace("fabricWorker started");
|
|
1862
|
-
const {
|
|
1863
|
-
channels: { swEventChannel },
|
|
1864
|
-
instance: cfRoomSession
|
|
1865
|
-
} = options;
|
|
1866
|
-
function* worker(action) {
|
|
1867
|
-
const { type, payload } = action;
|
|
1868
|
-
switch (type) {
|
|
1869
|
-
case "call.joined": {
|
|
1870
|
-
if (!cfRoomSession.selfMember) {
|
|
1871
|
-
const memberInstance = createFabricRoomSessionMemberObject({
|
|
1872
|
-
store: cfRoomSession.store,
|
|
1873
|
-
payload: {
|
|
1874
|
-
member: action.payload.room_session.members.find(
|
|
1875
|
-
(m) => m.member_id === action.payload.member_id
|
|
1876
|
-
),
|
|
1877
|
-
room_id: action.payload.room_id,
|
|
1878
|
-
room_session_id: action.payload.room_session_id
|
|
1879
|
-
}
|
|
1880
|
-
});
|
|
1881
|
-
cfRoomSession.selfMember = memberInstance;
|
|
1882
|
-
}
|
|
1883
|
-
yield import_core25.sagaEffects.fork(callSegmentWorker, __spreadProps(__spreadValues({}, options), {
|
|
1884
|
-
instance: cfRoomSession,
|
|
1885
|
-
action
|
|
1886
|
-
}));
|
|
1887
|
-
break;
|
|
1888
|
-
}
|
|
1889
|
-
case "call.state":
|
|
1890
|
-
cfRoomSession.emit(type, payload);
|
|
1891
|
-
break;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
let firstCallJoinedReceived = false;
|
|
1895
|
-
const isFirstCallJoinedorCallStateEvent = (action) => {
|
|
1896
|
-
if (action.type === "call.state") {
|
|
1897
|
-
return true;
|
|
1898
|
-
}
|
|
1899
|
-
if (action.type !== "call.joined") {
|
|
1900
|
-
return false;
|
|
1901
|
-
}
|
|
1902
|
-
if (!firstCallJoinedReceived) {
|
|
1903
|
-
const callId = action.payload.call_id;
|
|
1904
|
-
const originCallId = action.payload.origin_call_id;
|
|
1905
|
-
if (callId === originCallId) {
|
|
1906
|
-
firstCallJoinedReceived = true;
|
|
1907
|
-
return true;
|
|
1908
|
-
}
|
|
1909
|
-
return false;
|
|
1910
|
-
}
|
|
1911
|
-
return true;
|
|
1912
|
-
};
|
|
1913
|
-
while (true) {
|
|
1914
|
-
const action = yield import_core25.sagaEffects.take(
|
|
1915
|
-
swEventChannel,
|
|
1916
|
-
isFirstCallJoinedorCallStateEvent
|
|
1917
|
-
);
|
|
1918
|
-
yield import_core25.sagaEffects.fork(worker, action);
|
|
1919
|
-
}
|
|
1920
|
-
(0, import_core25.getLogger)().trace("fabricWorker ended");
|
|
1921
|
-
};
|
|
1922
|
-
|
|
1923
|
-
// src/fabric/utils/validators.ts
|
|
1924
|
-
var import_core26 = require("@signalwire/core");
|
|
1925
|
-
var isSelfMember = (params, ctx) => {
|
|
1926
|
-
return !(params == null ? void 0 : params.memberId) || params.memberId === ctx.member.id;
|
|
1927
|
-
};
|
|
1928
|
-
function validateAudioMute(params) {
|
|
1929
|
-
var _a, _b;
|
|
1930
|
-
const isSelf = isSelfMember(params, this);
|
|
1931
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.muteAudio.off : (_b = this.capabilities) == null ? void 0 : _b.member.muteAudio.off;
|
|
1932
|
-
if (!capability) {
|
|
1933
|
-
throw new import_core26.CapabilityError("Missing audio mute capability");
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
function validateAudioUnmute(params) {
|
|
1937
|
-
var _a, _b;
|
|
1938
|
-
const isSelf = isSelfMember(params, this);
|
|
1939
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.muteAudio.on : (_b = this.capabilities) == null ? void 0 : _b.member.muteAudio.on;
|
|
1940
|
-
if (!capability) {
|
|
1941
|
-
throw new import_core26.CapabilityError("Missing audio unmute capability");
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
function validateVideoMute(params) {
|
|
1945
|
-
var _a, _b;
|
|
1946
|
-
const isSelf = isSelfMember(params, this);
|
|
1947
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.muteVideo.off : (_b = this.capabilities) == null ? void 0 : _b.member.muteVideo.off;
|
|
1948
|
-
if (!capability) {
|
|
1949
|
-
throw new import_core26.CapabilityError("Missing video mute capability");
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
function validateVideoUnmute(params) {
|
|
1953
|
-
var _a, _b;
|
|
1954
|
-
const isSelf = isSelfMember(params, this);
|
|
1955
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.muteVideo.on : (_b = this.capabilities) == null ? void 0 : _b.member.muteVideo.on;
|
|
1956
|
-
if (!capability) {
|
|
1957
|
-
throw new import_core26.CapabilityError("Missing video unmute capability");
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
function validateDeaf(params) {
|
|
1961
|
-
var _a, _b;
|
|
1962
|
-
const isSelf = isSelfMember(params, this);
|
|
1963
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.deaf.on : (_b = this.capabilities) == null ? void 0 : _b.member.deaf.on;
|
|
1964
|
-
if (!capability) {
|
|
1965
|
-
throw new import_core26.CapabilityError("Missing deaf capability");
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
function validateUndeaf(params) {
|
|
1969
|
-
var _a, _b;
|
|
1970
|
-
const isSelf = isSelfMember(params, this);
|
|
1971
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.deaf.off : (_b = this.capabilities) == null ? void 0 : _b.member.deaf.off;
|
|
1972
|
-
if (!capability) {
|
|
1973
|
-
throw new import_core26.CapabilityError("Missing undeaf capability");
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
function validateRemoveMember(params) {
|
|
1977
|
-
var _a;
|
|
1978
|
-
if (!(params == null ? void 0 : params.memberId)) {
|
|
1979
|
-
throw new TypeError('Invalid or missing "memberId" argument');
|
|
1980
|
-
}
|
|
1981
|
-
const capability = (_a = this.capabilities) == null ? void 0 : _a.member.remove;
|
|
1982
|
-
if (!capability) {
|
|
1983
|
-
throw new import_core26.CapabilityError("Missing remove member capability");
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
function validateSetRaiseHand(params) {
|
|
1987
|
-
var _a, _b, _c, _d;
|
|
1988
|
-
const { raised = true } = params || {};
|
|
1989
|
-
const self = isSelfMember(params, this);
|
|
1990
|
-
const raiseCap = self ? (_a = this.capabilities) == null ? void 0 : _a.self.raisehand.on : (_b = this.capabilities) == null ? void 0 : _b.member.raisehand.on;
|
|
1991
|
-
const lowerCap = self ? (_c = this.capabilities) == null ? void 0 : _c.self.raisehand.off : (_d = this.capabilities) == null ? void 0 : _d.member.raisehand.off;
|
|
1992
|
-
if (raised && !raiseCap) {
|
|
1993
|
-
throw new import_core26.CapabilityError("Missing raisehand capability");
|
|
1994
|
-
}
|
|
1995
|
-
if (!raised && !lowerCap) {
|
|
1996
|
-
throw new import_core26.CapabilityError("Missing lowerhand capability");
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
function validateSetLayout() {
|
|
2000
|
-
var _a;
|
|
2001
|
-
if (!((_a = this.capabilities) == null ? void 0 : _a.setLayout)) {
|
|
2002
|
-
throw new import_core26.CapabilityError("Missing setLayout capability");
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
function validateSetInputVolume(params) {
|
|
2006
|
-
var _a, _b, _c, _d;
|
|
2007
|
-
const isSelf = isSelfMember(params, this);
|
|
2008
|
-
const capability = isSelf ? (_b = (_a = this.capabilities) == null ? void 0 : _a.self) == null ? void 0 : _b.microphoneVolume : (_d = (_c = this.capabilities) == null ? void 0 : _c.member) == null ? void 0 : _d.microphoneVolume;
|
|
2009
|
-
if (!capability) {
|
|
2010
|
-
throw new import_core26.CapabilityError("Missing setInputVolume capability");
|
|
2011
|
-
}
|
|
2012
|
-
if (params.volume < -50 || params.volume > 50) {
|
|
2013
|
-
throw new RangeError("The volume ranges from -50 to 50");
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
function validateSetOutputVolume(params) {
|
|
2017
|
-
var _a, _b, _c, _d;
|
|
2018
|
-
const isSelf = isSelfMember(params, this);
|
|
2019
|
-
const capability = isSelf ? (_b = (_a = this.capabilities) == null ? void 0 : _a.self) == null ? void 0 : _b.speakerVolume : (_d = (_c = this.capabilities) == null ? void 0 : _c.member) == null ? void 0 : _d.speakerVolume;
|
|
2020
|
-
if (!capability) {
|
|
2021
|
-
throw new import_core26.CapabilityError("Missing setOutputVolume capability");
|
|
2022
|
-
}
|
|
2023
|
-
if (params.volume < -50 || params.volume > 50) {
|
|
2024
|
-
throw new RangeError("The volume ranges from -50 to 50");
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
function validateSetInputSensitivity(params) {
|
|
2028
|
-
var _a, _b;
|
|
2029
|
-
const isSelf = isSelfMember(params, this);
|
|
2030
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.microphoneSensitivity : (_b = this.capabilities) == null ? void 0 : _b.member.microphoneSensitivity;
|
|
2031
|
-
if (!capability) {
|
|
2032
|
-
throw new import_core26.CapabilityError("Missing setInputSensitivity capability");
|
|
2033
|
-
}
|
|
2034
|
-
if (params.value < 0 || params.value > 100) {
|
|
2035
|
-
throw new RangeError("The sensitivity value ranges from 0 to 100");
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
function validateSetPositions(params) {
|
|
2039
|
-
var _a, _b;
|
|
2040
|
-
if (params.positions && !Object.keys(params.positions).length) {
|
|
2041
|
-
throw new TypeError("Invalid positions specified");
|
|
2042
|
-
}
|
|
2043
|
-
const hasSelfPositions = Object.keys(params.positions).some(
|
|
2044
|
-
(p) => ["self", `${this.memberId}`].includes(p)
|
|
2045
|
-
);
|
|
2046
|
-
const capability = hasSelfPositions ? (_a = this.capabilities) == null ? void 0 : _a.self.position : (_b = this.capabilities) == null ? void 0 : _b.member.position;
|
|
2047
|
-
if (!capability) {
|
|
2048
|
-
throw new import_core26.CapabilityError("Missing setPositions capability");
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
function validateLock() {
|
|
2052
|
-
var _a;
|
|
2053
|
-
if (!((_a = this.capabilities) == null ? void 0 : _a.lock.on)) {
|
|
2054
|
-
throw new import_core26.CapabilityError("Missing lock capability");
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
function validateUnlock() {
|
|
2058
|
-
var _a;
|
|
2059
|
-
if (!((_a = this.capabilities) == null ? void 0 : _a.lock.off)) {
|
|
2060
|
-
throw new import_core26.CapabilityError("Missing unlock capability");
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
function validateSetAudioFlags(params) {
|
|
2064
|
-
var _a, _b;
|
|
2065
|
-
const isSelf = isSelfMember(params, this);
|
|
2066
|
-
const capability = isSelf ? (_a = this.capabilities) == null ? void 0 : _a.self.audioFlags : (_b = this.capabilities) == null ? void 0 : _b.member.audioFlags;
|
|
2067
|
-
if (!capability) {
|
|
2068
|
-
throw new import_core26.CapabilityError("Missing audio flags capability");
|
|
2069
|
-
}
|
|
2070
|
-
const { echoCancellation, autoGain, noiseSuppression } = params || {};
|
|
2071
|
-
if (echoCancellation === void 0 && autoGain === void 0 && noiseSuppression === void 0) {
|
|
2072
|
-
throw new TypeError(
|
|
2073
|
-
"Invalid parameters: you must specify at least one of `echoCancellation`, `autoGain`, or `noiseSuppression`"
|
|
2074
|
-
);
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
function validateEnd() {
|
|
2078
|
-
var _a;
|
|
2079
|
-
const capability = (_a = this.capabilities) == null ? void 0 : _a.end;
|
|
2080
|
-
if (!capability) {
|
|
2081
|
-
throw new import_core26.CapabilityError("Missing 'end' capability");
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
|
|
2085
|
-
// src/fabric/utils/validationProxy.ts
|
|
2086
|
-
var validationsMap = {
|
|
2087
|
-
audioMute: validateAudioMute,
|
|
2088
|
-
audioUnmute: validateAudioUnmute,
|
|
2089
|
-
videoMute: validateVideoMute,
|
|
2090
|
-
videoUnmute: validateVideoUnmute,
|
|
2091
|
-
deaf: validateDeaf,
|
|
2092
|
-
undeaf: validateUndeaf,
|
|
2093
|
-
removeMember: validateRemoveMember,
|
|
2094
|
-
setRaisedHand: validateSetRaiseHand,
|
|
2095
|
-
setLayout: validateSetLayout,
|
|
2096
|
-
setInputVolume: validateSetInputVolume,
|
|
2097
|
-
setOutputVolume: validateSetOutputVolume,
|
|
2098
|
-
setInputSensitivity: validateSetInputSensitivity,
|
|
2099
|
-
setPositions: validateSetPositions,
|
|
2100
|
-
lock: validateLock,
|
|
2101
|
-
unlock: validateUnlock,
|
|
2102
|
-
setAudioFlags: validateSetAudioFlags,
|
|
2103
|
-
end: validateEnd
|
|
2104
|
-
};
|
|
2105
|
-
function createFabricRoomSessionValidateProxy(instance) {
|
|
2106
|
-
return new Proxy(instance, {
|
|
2107
|
-
get(target, prop, receiver) {
|
|
2108
|
-
if (typeof prop === "string" && prop in validationsMap) {
|
|
2109
|
-
const targetConn = target;
|
|
2110
|
-
const origMethod = targetConn[prop];
|
|
2111
|
-
if (typeof origMethod === "function") {
|
|
2112
|
-
return function(...args) {
|
|
2113
|
-
return __async(this, null, function* () {
|
|
2114
|
-
const validator = validationsMap[prop];
|
|
2115
|
-
if (validator) {
|
|
2116
|
-
validator.apply(targetConn, args);
|
|
2117
|
-
}
|
|
2118
|
-
return origMethod.apply(targetConn, args);
|
|
2119
|
-
});
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
return Reflect.get(target, prop, receiver);
|
|
2124
|
-
}
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
// src/fabric/FabricRoomSession.ts
|
|
2129
|
-
var FabricRoomSessionConnection = class _FabricRoomSessionConnection extends BaseRoomSessionConnection {
|
|
2130
|
-
constructor(options) {
|
|
2131
|
-
super(options);
|
|
2132
|
-
// this is "self" parameter required by the RPC, and is always "the member" on the 1st call segment
|
|
2133
|
-
__publicField(this, "_self");
|
|
2134
|
-
// this is "the member" on the last/active call segment
|
|
2135
|
-
__publicField(this, "_member");
|
|
2136
|
-
__publicField(this, "_currentLayoutEvent");
|
|
2137
|
-
//describes what are methods are allow for the user in a call segment
|
|
2138
|
-
__publicField(this, "_capabilities");
|
|
2139
|
-
this.initWorker();
|
|
2140
|
-
}
|
|
2141
|
-
get memberId() {
|
|
2142
|
-
var _a;
|
|
2143
|
-
return (_a = this._member) == null ? void 0 : _a.memberId;
|
|
2144
|
-
}
|
|
2145
|
-
dialogParams(rtcPeerId) {
|
|
2146
|
-
const params = super.dialogParams(rtcPeerId);
|
|
2147
|
-
params.dialogParams.attach = this.options.attach || this.resuming;
|
|
2148
|
-
params.dialogParams.reattaching = this.options.attach || this.resuming;
|
|
2149
|
-
return params;
|
|
2150
|
-
}
|
|
2151
|
-
set currentLayoutEvent(event) {
|
|
2152
|
-
this._currentLayoutEvent = event;
|
|
2153
|
-
}
|
|
2154
|
-
get currentLayoutEvent() {
|
|
2155
|
-
return this._currentLayoutEvent;
|
|
2156
|
-
}
|
|
2157
|
-
get currentLayout() {
|
|
2158
|
-
var _a;
|
|
2159
|
-
return (_a = this._currentLayoutEvent) == null ? void 0 : _a.layout;
|
|
2160
|
-
}
|
|
2161
|
-
get currentPosition() {
|
|
2162
|
-
var _a, _b;
|
|
2163
|
-
return (_b = (_a = this._currentLayoutEvent) == null ? void 0 : _a.layout.layers.find(
|
|
2164
|
-
(layer) => layer.member_id === this.memberId
|
|
2165
|
-
)) == null ? void 0 : _b.position;
|
|
2166
|
-
}
|
|
2167
|
-
get capabilities() {
|
|
2168
|
-
return this._capabilities;
|
|
2169
|
-
}
|
|
2170
|
-
set capabilities(capabilities) {
|
|
2171
|
-
this._capabilities = capabilities;
|
|
2172
|
-
}
|
|
2173
|
-
get selfMember() {
|
|
2174
|
-
return this._self;
|
|
2175
|
-
}
|
|
2176
|
-
set selfMember(member) {
|
|
2177
|
-
this._self = member;
|
|
2178
|
-
}
|
|
2179
|
-
set member(member) {
|
|
2180
|
-
this._member = member;
|
|
2181
|
-
}
|
|
2182
|
-
get member() {
|
|
2183
|
-
return this._member;
|
|
2184
|
-
}
|
|
2185
|
-
initWorker() {
|
|
2186
|
-
this.runWorker("fabricWorker", {
|
|
2187
|
-
worker: fabricWorker
|
|
2188
|
-
});
|
|
2189
|
-
this.runWorker("makeAudioElement", {
|
|
2190
|
-
worker: makeAudioElementSaga({
|
|
2191
|
-
speakerId: this.options.speakerId
|
|
2192
|
-
})
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
join() {
|
|
2196
|
-
return __async(this, null, function* () {
|
|
2197
|
-
var _a, _b;
|
|
2198
|
-
if (this.options.attach) {
|
|
2199
|
-
this.options.prevCallId = (_b = (_a = getStorage()) == null ? void 0 : _a.getItem(PREVIOUS_CALLID_STORAGE_KEY)) != null ? _b : void 0;
|
|
2200
|
-
this.logger.debug(
|
|
2201
|
-
`Tying to reattach to previuos call? ${!!this.options.prevCallId} - prevCallId: ${this.options.prevCallId}`
|
|
2202
|
-
);
|
|
2203
|
-
}
|
|
2204
|
-
return __superGet(_FabricRoomSessionConnection.prototype, this, "invite").call(this);
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
executeAction(params, options = {}) {
|
|
2208
|
-
var _a, _b, _c;
|
|
2209
|
-
const { method, channel, memberId, extraParams = {} } = params;
|
|
2210
|
-
const targetMember = !memberId || memberId === "all" ? this.member : this.instanceMap.get(memberId);
|
|
2211
|
-
if (!targetMember) {
|
|
2212
|
-
throw new Error(
|
|
2213
|
-
memberId && memberId !== "all" ? `Member ${memberId} not found` : "No target member available"
|
|
2214
|
-
);
|
|
2215
|
-
}
|
|
2216
|
-
return this.execute(
|
|
2217
|
-
{
|
|
2218
|
-
method,
|
|
2219
|
-
params: __spreadValues(__spreadProps(__spreadValues({}, channel && { channels: [channel] }), {
|
|
2220
|
-
self: {
|
|
2221
|
-
member_id: (_a = this.selfMember) == null ? void 0 : _a.id,
|
|
2222
|
-
call_id: (_b = this.selfMember) == null ? void 0 : _b.callId,
|
|
2223
|
-
node_id: (_c = this.selfMember) == null ? void 0 : _c.nodeId
|
|
2224
|
-
},
|
|
2225
|
-
target: {
|
|
2226
|
-
member_id: memberId === "all" ? memberId : targetMember.id,
|
|
2227
|
-
call_id: targetMember.callId,
|
|
2228
|
-
node_id: targetMember.nodeId
|
|
2229
|
-
}
|
|
2230
|
-
}), extraParams)
|
|
2231
|
-
},
|
|
2232
|
-
options
|
|
2233
|
-
);
|
|
2234
|
-
}
|
|
2235
|
-
/** @internal */
|
|
2236
|
-
resume() {
|
|
2237
|
-
return __async(this, null, function* () {
|
|
2238
|
-
var _a;
|
|
2239
|
-
this.logger.warn(`[resume] Call ${this.id}`);
|
|
2240
|
-
if ((_a = this.peer) == null ? void 0 : _a.instance) {
|
|
2241
|
-
const { connectionState } = this.peer.instance;
|
|
2242
|
-
this.logger.debug(
|
|
2243
|
-
`[resume] connectionState for ${this.id} is '${connectionState}'`
|
|
2244
|
-
);
|
|
2245
|
-
if (["closed", "failed", "disconnected"].includes(connectionState)) {
|
|
2246
|
-
this.resuming = !this.selfMember;
|
|
2247
|
-
this.peer.restartIce();
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
-
start() {
|
|
2253
|
-
return __async(this, null, function* () {
|
|
2254
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
2255
|
-
try {
|
|
2256
|
-
this.once("room.subscribed", (params) => {
|
|
2257
|
-
var _a;
|
|
2258
|
-
(_a = getStorage()) == null ? void 0 : _a.setItem(PREVIOUS_CALLID_STORAGE_KEY, params.call_id);
|
|
2259
|
-
resolve();
|
|
2260
|
-
});
|
|
2261
|
-
this.once("destroy", () => {
|
|
2262
|
-
var _a;
|
|
2263
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(PREVIOUS_CALLID_STORAGE_KEY);
|
|
2264
|
-
});
|
|
2265
|
-
yield this.join();
|
|
2266
|
-
} catch (error) {
|
|
2267
|
-
this.logger.error("WSClient call start", error);
|
|
2268
|
-
reject(error);
|
|
2269
|
-
}
|
|
2270
|
-
}));
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
audioMute(params) {
|
|
2274
|
-
return __async(this, null, function* () {
|
|
2275
|
-
return this.executeAction({
|
|
2276
|
-
method: "call.mute",
|
|
2277
|
-
channel: "audio",
|
|
2278
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2279
|
-
});
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
|
-
audioUnmute(params) {
|
|
2283
|
-
return __async(this, null, function* () {
|
|
2284
|
-
return this.executeAction({
|
|
2285
|
-
method: "call.unmute",
|
|
2286
|
-
channel: "audio",
|
|
2287
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2288
|
-
});
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
videoMute(params) {
|
|
2292
|
-
return __async(this, null, function* () {
|
|
2293
|
-
return this.executeAction({
|
|
2294
|
-
method: "call.mute",
|
|
2295
|
-
channel: "video",
|
|
2296
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2297
|
-
});
|
|
2298
|
-
});
|
|
2299
|
-
}
|
|
2300
|
-
videoUnmute(params) {
|
|
2301
|
-
return __async(this, null, function* () {
|
|
2302
|
-
return this.executeAction({
|
|
2303
|
-
method: "call.unmute",
|
|
2304
|
-
channel: "video",
|
|
2305
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2306
|
-
});
|
|
2307
|
-
});
|
|
2308
|
-
}
|
|
2309
|
-
deaf(params) {
|
|
2310
|
-
return __async(this, null, function* () {
|
|
2311
|
-
return this.executeAction({
|
|
2312
|
-
method: "call.deaf",
|
|
2313
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2314
|
-
});
|
|
2315
|
-
});
|
|
2316
|
-
}
|
|
2317
|
-
undeaf(params) {
|
|
2318
|
-
return __async(this, null, function* () {
|
|
2319
|
-
return this.executeAction({
|
|
2320
|
-
method: "call.undeaf",
|
|
2321
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2322
|
-
});
|
|
2323
|
-
});
|
|
2324
|
-
}
|
|
2325
|
-
getLayouts() {
|
|
2326
|
-
return __async(this, null, function* () {
|
|
2327
|
-
return this.executeAction(
|
|
2328
|
-
{
|
|
2329
|
-
method: "call.layout.list"
|
|
2330
|
-
},
|
|
2331
|
-
{
|
|
2332
|
-
transformResolve: (payload) => ({
|
|
2333
|
-
layouts: payload.layouts
|
|
2334
|
-
})
|
|
2335
|
-
}
|
|
2336
|
-
);
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
|
-
getMembers() {
|
|
2340
|
-
return __async(this, null, function* () {
|
|
2341
|
-
return this.executeAction(
|
|
2342
|
-
{
|
|
2343
|
-
method: "call.member.list"
|
|
2344
|
-
},
|
|
2345
|
-
{
|
|
2346
|
-
transformResolve: (payload) => ({
|
|
2347
|
-
members: payload.members
|
|
2348
|
-
})
|
|
2349
|
-
}
|
|
2350
|
-
);
|
|
2351
|
-
});
|
|
2352
|
-
}
|
|
2353
|
-
removeMember(params) {
|
|
2354
|
-
return __async(this, null, function* () {
|
|
2355
|
-
return this.executeAction({
|
|
2356
|
-
method: "call.member.remove",
|
|
2357
|
-
memberId: params.memberId
|
|
2358
|
-
});
|
|
2359
|
-
});
|
|
2360
|
-
}
|
|
2361
|
-
setRaisedHand(params) {
|
|
2362
|
-
return __async(this, null, function* () {
|
|
2363
|
-
const { raised = true, memberId } = params || {};
|
|
2364
|
-
return this.executeAction({
|
|
2365
|
-
method: raised ? "call.raisehand" : "call.lowerhand",
|
|
2366
|
-
memberId
|
|
2367
|
-
});
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
setLayout(params) {
|
|
2371
|
-
return __async(this, null, function* () {
|
|
2372
|
-
const extraParams = {
|
|
2373
|
-
layout: params.name,
|
|
2374
|
-
positions: params.positions
|
|
2375
|
-
};
|
|
2376
|
-
return this.executeAction({
|
|
2377
|
-
method: "call.layout.set",
|
|
2378
|
-
extraParams
|
|
2379
|
-
});
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
setInputVolume(params) {
|
|
2383
|
-
return __async(this, null, function* () {
|
|
2384
|
-
return this.executeAction({
|
|
2385
|
-
method: "call.microphone.volume.set",
|
|
2386
|
-
memberId: params.memberId,
|
|
2387
|
-
extraParams: {
|
|
2388
|
-
volume: params.volume
|
|
2389
|
-
}
|
|
2390
|
-
});
|
|
2391
|
-
});
|
|
2392
|
-
}
|
|
2393
|
-
setOutputVolume(params) {
|
|
2394
|
-
return __async(this, null, function* () {
|
|
2395
|
-
return this.executeAction({
|
|
2396
|
-
method: "call.speaker.volume.set",
|
|
2397
|
-
memberId: params.memberId,
|
|
2398
|
-
extraParams: {
|
|
2399
|
-
volume: params.volume
|
|
2400
|
-
}
|
|
2401
|
-
});
|
|
2402
|
-
});
|
|
2403
|
-
}
|
|
2404
|
-
setInputSensitivity(params) {
|
|
2405
|
-
return __async(this, null, function* () {
|
|
2406
|
-
return this.executeAction({
|
|
2407
|
-
method: "call.microphone.sensitivity.set",
|
|
2408
|
-
memberId: params.memberId,
|
|
2409
|
-
extraParams: {
|
|
2410
|
-
sensitivity: params.value
|
|
2411
|
-
}
|
|
2412
|
-
});
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
setPositions(params) {
|
|
2416
|
-
return __async(this, null, function* () {
|
|
2417
|
-
var _a, _b, _c;
|
|
2418
|
-
const targets = [];
|
|
2419
|
-
Object.entries(params.positions).forEach(([key, value]) => {
|
|
2420
|
-
const targetMember = key === "self" ? this.member : this.instanceMap.get(key);
|
|
2421
|
-
if (targetMember) {
|
|
2422
|
-
targets.push({
|
|
2423
|
-
target: {
|
|
2424
|
-
member_id: targetMember.id,
|
|
2425
|
-
call_id: targetMember.callId,
|
|
2426
|
-
node_id: targetMember.nodeId
|
|
2427
|
-
},
|
|
2428
|
-
position: value
|
|
2429
|
-
});
|
|
2430
|
-
}
|
|
2431
|
-
});
|
|
2432
|
-
if (!targets.length) {
|
|
2433
|
-
throw new Error("Invalid targets");
|
|
2434
|
-
}
|
|
2435
|
-
return this.execute({
|
|
2436
|
-
method: "call.member.position.set",
|
|
2437
|
-
params: {
|
|
2438
|
-
self: {
|
|
2439
|
-
member_id: (_a = this.selfMember) == null ? void 0 : _a.id,
|
|
2440
|
-
call_id: (_b = this.selfMember) == null ? void 0 : _b.callId,
|
|
2441
|
-
node_id: (_c = this.selfMember) == null ? void 0 : _c.nodeId
|
|
2442
|
-
},
|
|
2443
|
-
targets
|
|
2444
|
-
}
|
|
2445
|
-
});
|
|
2446
|
-
});
|
|
2447
|
-
}
|
|
2448
|
-
lock() {
|
|
2449
|
-
return __async(this, null, function* () {
|
|
2450
|
-
return this.executeAction({
|
|
2451
|
-
method: "call.lock"
|
|
2452
|
-
});
|
|
2453
|
-
});
|
|
2454
|
-
}
|
|
2455
|
-
unlock() {
|
|
2456
|
-
return __async(this, null, function* () {
|
|
2457
|
-
return this.executeAction({
|
|
2458
|
-
method: "call.unlock"
|
|
2459
|
-
});
|
|
2460
|
-
});
|
|
2461
|
-
}
|
|
2462
|
-
setAudioFlags(params) {
|
|
2463
|
-
return __async(this, null, function* () {
|
|
2464
|
-
const _a = params, { memberId } = _a, rest = __objRest(_a, ["memberId"]);
|
|
2465
|
-
return this.executeAction({
|
|
2466
|
-
method: "call.audioflags.set",
|
|
2467
|
-
memberId,
|
|
2468
|
-
extraParams: (0, import_core27.toSnakeCaseKeys)(rest)
|
|
2469
|
-
});
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
end(params) {
|
|
2473
|
-
return __async(this, null, function* () {
|
|
2474
|
-
return this.executeAction({
|
|
2475
|
-
method: "call.end",
|
|
2476
|
-
memberId: params == null ? void 0 : params.memberId
|
|
2477
|
-
});
|
|
2478
|
-
});
|
|
2479
|
-
}
|
|
2480
|
-
};
|
|
2481
|
-
var isFabricRoomSession = (room) => {
|
|
2482
|
-
return room instanceof FabricRoomSessionConnection;
|
|
2483
|
-
};
|
|
2484
|
-
var createFabricRoomSessionObject = (params) => {
|
|
2485
|
-
const room = (0, import_core27.connect)({
|
|
2486
|
-
store: params.store,
|
|
2487
|
-
Component: FabricRoomSessionConnection
|
|
2488
|
-
})(params);
|
|
2489
|
-
return createFabricRoomSessionValidateProxy(room);
|
|
2490
|
-
};
|
|
2491
|
-
|
|
2492
|
-
// src/VideoOverlays.ts
|
|
2493
|
-
var UserOverlay = class {
|
|
2494
|
-
constructor(options) {
|
|
2495
|
-
__publicField(this, "id");
|
|
2496
|
-
__publicField(this, "_domElement");
|
|
2497
|
-
__publicField(this, "_status");
|
|
2498
|
-
this.id = options.id;
|
|
2499
|
-
this._status = "hidden";
|
|
2500
|
-
}
|
|
2501
|
-
get userId() {
|
|
2502
|
-
return this.id.split(OVERLAY_PREFIX)[1];
|
|
2503
|
-
}
|
|
2504
|
-
get domElement() {
|
|
2505
|
-
return this._domElement;
|
|
2506
|
-
}
|
|
2507
|
-
set domElement(element) {
|
|
2508
|
-
(0, import_core28.getLogger)().debug("Setting domElement for ", this.id);
|
|
2509
|
-
this._domElement = element;
|
|
2510
|
-
}
|
|
2511
|
-
get status() {
|
|
2512
|
-
return this._status;
|
|
2513
|
-
}
|
|
2514
|
-
set status(status) {
|
|
2515
|
-
this._status = status;
|
|
2516
|
-
}
|
|
2517
|
-
hide() {
|
|
2518
|
-
if (!this.domElement) {
|
|
2519
|
-
return (0, import_core28.getLogger)().warn("Missing overlay to hide");
|
|
2520
|
-
}
|
|
2521
|
-
this.domElement.style.opacity = "0";
|
|
2522
|
-
this.status = "hidden";
|
|
2523
|
-
}
|
|
2524
|
-
show() {
|
|
2525
|
-
if (!this.domElement) {
|
|
2526
|
-
return (0, import_core28.getLogger)().warn("Missing overlay to show");
|
|
2527
|
-
}
|
|
2528
|
-
this.domElement.style.opacity = "1";
|
|
2529
|
-
this.status = "visible";
|
|
2530
|
-
}
|
|
2531
|
-
};
|
|
2532
|
-
var LocalVideoOverlay = class extends UserOverlay {
|
|
2533
|
-
constructor(options) {
|
|
2534
|
-
super(options);
|
|
2535
|
-
__publicField(this, "_mirrored");
|
|
2536
|
-
__publicField(this, "_room");
|
|
2537
|
-
this._mirrored = options.mirrorLocalVideoOverlay;
|
|
2538
|
-
this._room = options.room;
|
|
2539
|
-
this.fabricMemberVideoMutedHandler = this.fabricMemberVideoMutedHandler.bind(this);
|
|
2540
|
-
this.videoMemberVideoMutedHandler = this.videoMemberVideoMutedHandler.bind(this);
|
|
2541
|
-
this.attachListeners();
|
|
2542
|
-
}
|
|
2543
|
-
get userId() {
|
|
2544
|
-
return this.id.split(SDK_PREFIX)[1];
|
|
2545
|
-
}
|
|
2546
|
-
get mirrored() {
|
|
2547
|
-
return this._mirrored;
|
|
2548
|
-
}
|
|
2549
|
-
attachListeners() {
|
|
2550
|
-
if (isFabricRoomSession(this._room)) {
|
|
2551
|
-
this._room.on(
|
|
2552
|
-
"member.updated.videoMuted",
|
|
2553
|
-
this.fabricMemberVideoMutedHandler
|
|
2554
|
-
);
|
|
2555
|
-
} else if (isVideoRoomSession(this._room)) {
|
|
2556
|
-
this._room.on(
|
|
2557
|
-
"member.updated.videoMuted",
|
|
2558
|
-
this.videoMemberVideoMutedHandler
|
|
2559
|
-
);
|
|
2560
|
-
}
|
|
2561
|
-
}
|
|
2562
|
-
/** @internal */
|
|
2563
|
-
detachListeners() {
|
|
2564
|
-
if (isFabricRoomSession(this._room)) {
|
|
2565
|
-
this._room.off(
|
|
2566
|
-
"member.updated.videoMuted",
|
|
2567
|
-
this.fabricMemberVideoMutedHandler
|
|
2568
|
-
);
|
|
2569
|
-
} else if (isVideoRoomSession(this._room)) {
|
|
2570
|
-
this._room.off(
|
|
2571
|
-
"member.updated.videoMuted",
|
|
2572
|
-
this.videoMemberVideoMutedHandler
|
|
2573
|
-
);
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
memberVideoMutedHandler(memberId, videoMuted) {
|
|
2577
|
-
try {
|
|
2578
|
-
if (memberId === this._room.memberId) {
|
|
2579
|
-
videoMuted ? this.hide() : this.show();
|
|
2580
|
-
}
|
|
2581
|
-
} catch (error) {
|
|
2582
|
-
(0, import_core28.getLogger)().error("Error handling videoMuted in LocalVideoOverlay", error);
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
fabricMemberVideoMutedHandler(params) {
|
|
2586
|
-
this.memberVideoMutedHandler(
|
|
2587
|
-
params.member.member_id,
|
|
2588
|
-
params.member.video_muted
|
|
2589
|
-
);
|
|
2590
|
-
}
|
|
2591
|
-
videoMemberVideoMutedHandler(params) {
|
|
2592
|
-
this.memberVideoMutedHandler(params.member.id, params.member.video_muted);
|
|
2593
|
-
}
|
|
2594
|
-
setMediaStream(stream) {
|
|
2595
|
-
if (!this.domElement) {
|
|
2596
|
-
return (0, import_core28.getLogger)().warn("Missing local overlay to set the stream");
|
|
2597
|
-
}
|
|
2598
|
-
const localVideo = this.domElement.querySelector("video");
|
|
2599
|
-
if (localVideo) {
|
|
2600
|
-
localVideo.srcObject = stream;
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
setMirror(mirror = this._mirrored) {
|
|
2604
|
-
if (!this.domElement || !this.domElement.firstChild) {
|
|
2605
|
-
return (0, import_core28.getLogger)().warn("Missing local overlay to set the mirror");
|
|
2606
|
-
}
|
|
2607
|
-
const videoEl = this.domElement.firstChild;
|
|
2608
|
-
videoEl.style.transform = mirror ? "scale(-1, 1)" : "scale(1, 1)";
|
|
2609
|
-
videoEl.style.webkitTransform = mirror ? "scale(-1, 1)" : "scale(1, 1)";
|
|
2610
|
-
this._mirrored = mirror;
|
|
2611
|
-
}
|
|
2612
|
-
};
|
|
2613
|
-
|
|
2614
|
-
// src/utils/videoElement.ts
|
|
2615
|
-
var buildVideo = () => {
|
|
2616
|
-
const video = document.createElement("video");
|
|
2617
|
-
video.muted = true;
|
|
2618
|
-
video.autoplay = true;
|
|
2619
|
-
video.playsInline = true;
|
|
2620
|
-
video.addEventListener("pause", () => {
|
|
2621
|
-
video.play().catch((error) => {
|
|
2622
|
-
(0, import_core29.getLogger)().error("Video Element Paused", video, error);
|
|
2623
|
-
});
|
|
2624
|
-
});
|
|
2625
|
-
return video;
|
|
2626
|
-
};
|
|
2627
|
-
var waitForVideoReady = ({ element }) => {
|
|
2628
|
-
return new Promise((resolve) => {
|
|
2629
|
-
element.addEventListener("canplay", function listener() {
|
|
2630
|
-
element.removeEventListener("canplay", listener);
|
|
2631
|
-
resolve();
|
|
2632
|
-
});
|
|
2633
|
-
element.addEventListener("resize", function listener() {
|
|
2634
|
-
element.removeEventListener("resize", listener);
|
|
2635
|
-
resolve();
|
|
2636
|
-
});
|
|
2637
|
-
});
|
|
2638
|
-
};
|
|
2639
|
-
var _getLocationStyles = ({
|
|
2640
|
-
x,
|
|
2641
|
-
y,
|
|
2642
|
-
width,
|
|
2643
|
-
height
|
|
2644
|
-
}) => {
|
|
2645
|
-
return {
|
|
2646
|
-
top: `${y}%`,
|
|
2647
|
-
left: `${x}%`,
|
|
2648
|
-
width: `${width}%`,
|
|
2649
|
-
height: `${height}%`
|
|
2650
|
-
};
|
|
2651
|
-
};
|
|
2652
|
-
var _buildLayer = ({ location }) => {
|
|
2653
|
-
const { top, left, width, height } = _getLocationStyles(location);
|
|
2654
|
-
const layer = document.createElement("div");
|
|
2655
|
-
layer.style.position = "absolute";
|
|
2656
|
-
layer.style.overflow = "hidden";
|
|
2657
|
-
layer.style.top = top;
|
|
2658
|
-
layer.style.left = left;
|
|
2659
|
-
layer.style.width = width;
|
|
2660
|
-
layer.style.height = height;
|
|
2661
|
-
return layer;
|
|
2662
|
-
};
|
|
2663
|
-
var _updateLayer = ({
|
|
2664
|
-
location,
|
|
2665
|
-
element
|
|
2666
|
-
}) => {
|
|
2667
|
-
const { top, left, width, height } = _getLocationStyles(location);
|
|
2668
|
-
element.style.top = top;
|
|
2669
|
-
element.style.left = left;
|
|
2670
|
-
element.style.width = width;
|
|
2671
|
-
element.style.height = height;
|
|
2672
|
-
return element;
|
|
2673
|
-
};
|
|
2674
|
-
var makeLayoutChangedHandler = (params) => {
|
|
2675
|
-
const {
|
|
2676
|
-
applyLocalVideoOverlay,
|
|
2677
|
-
applyMemberOverlay,
|
|
2678
|
-
overlayMap,
|
|
2679
|
-
localVideoOverlay,
|
|
2680
|
-
mirrorLocalVideoOverlay,
|
|
2681
|
-
rootElement
|
|
2682
|
-
} = params;
|
|
2683
|
-
return (params2) => __async(void 0, null, function* () {
|
|
2684
|
-
(0, import_core29.getLogger)().debug("Process layout.changed");
|
|
2685
|
-
try {
|
|
2686
|
-
const { layout, memberId, localStream } = params2;
|
|
2687
|
-
const { layers = [] } = layout;
|
|
2688
|
-
const mcuLayers = rootElement.querySelector(".mcuLayers");
|
|
2689
|
-
const fragment = document.createDocumentFragment();
|
|
2690
|
-
const currentOverlayIds = /* @__PURE__ */ new Set();
|
|
2691
|
-
if (applyLocalVideoOverlay) {
|
|
2692
|
-
const location = layers.find(({ member_id }) => member_id === memberId);
|
|
2693
|
-
const overlayId = localVideoOverlay.id;
|
|
2694
|
-
let myLayerEl = localVideoOverlay.domElement;
|
|
2695
|
-
currentOverlayIds.add(overlayId);
|
|
2696
|
-
if (!location) {
|
|
2697
|
-
(0, import_core29.getLogger)().warn("Local video overlay location not found", memberId);
|
|
2698
|
-
localVideoOverlay.status = "hidden";
|
|
2699
|
-
if (myLayerEl) {
|
|
2700
|
-
localVideoOverlay.hide();
|
|
2701
|
-
}
|
|
2702
|
-
} else {
|
|
2703
|
-
if (myLayerEl) {
|
|
2704
|
-
(0, import_core29.getLogger)().debug("Update local video overlay");
|
|
2705
|
-
_updateLayer({ location, element: myLayerEl });
|
|
2706
|
-
} else {
|
|
2707
|
-
(0, import_core29.getLogger)().debug("Build local video overlay");
|
|
2708
|
-
myLayerEl = _buildLayer({ location });
|
|
2709
|
-
myLayerEl.id = overlayId;
|
|
2710
|
-
const localVideo = buildVideo();
|
|
2711
|
-
localVideo.srcObject = localStream;
|
|
2712
|
-
localVideo.disablePictureInPicture = true;
|
|
2713
|
-
localVideo.style.width = "100%";
|
|
2714
|
-
localVideo.style.height = "100%";
|
|
2715
|
-
localVideo.style.pointerEvents = "none";
|
|
2716
|
-
localVideo.style.objectFit = "cover";
|
|
2717
|
-
myLayerEl.appendChild(localVideo);
|
|
2718
|
-
localVideoOverlay.domElement = myLayerEl;
|
|
2719
|
-
if (mirrorLocalVideoOverlay) {
|
|
2720
|
-
localVideoOverlay.setMirror();
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
const hasVideo = localStream.getVideoTracks().filter((t) => t.enabled && t.readyState === "live").length > 0;
|
|
2724
|
-
if (hasVideo && location.visible) {
|
|
2725
|
-
localVideoOverlay.setMediaStream(localStream);
|
|
2726
|
-
localVideoOverlay.show();
|
|
2727
|
-
} else {
|
|
2728
|
-
localVideoOverlay.hide();
|
|
2729
|
-
}
|
|
2730
|
-
fragment.appendChild(myLayerEl);
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
if (applyMemberOverlay) {
|
|
2734
|
-
layers.forEach((location) => {
|
|
2735
|
-
const memberIdInLocation = location.member_id;
|
|
2736
|
-
if (!memberIdInLocation) return;
|
|
2737
|
-
const overlayId = addOverlayPrefix(memberIdInLocation);
|
|
2738
|
-
currentOverlayIds.add(overlayId);
|
|
2739
|
-
let overlay = overlayMap.get(overlayId);
|
|
2740
|
-
if (overlay && overlay.domElement) {
|
|
2741
|
-
(0, import_core29.getLogger)().debug("Update an overlay for", memberIdInLocation);
|
|
2742
|
-
_updateLayer({ location, element: overlay.domElement });
|
|
2743
|
-
} else {
|
|
2744
|
-
(0, import_core29.getLogger)().debug("Build an overlay for", memberIdInLocation);
|
|
2745
|
-
overlay = new UserOverlay({ id: overlayId });
|
|
2746
|
-
overlayMap.set(overlayId, overlay);
|
|
2747
|
-
const newLayer = _buildLayer({ location });
|
|
2748
|
-
newLayer.id = `${overlayId}-${(0, import_core29.uuid)()}`;
|
|
2749
|
-
overlay.domElement = newLayer;
|
|
2750
|
-
}
|
|
2751
|
-
if (!location.visible) {
|
|
2752
|
-
overlay.hide();
|
|
2753
|
-
} else {
|
|
2754
|
-
overlay.show();
|
|
2755
|
-
}
|
|
2756
|
-
fragment.appendChild(overlay.domElement);
|
|
2757
|
-
});
|
|
2758
|
-
}
|
|
2759
|
-
overlayMap.forEach((overlay, overlayId) => {
|
|
2760
|
-
if (!currentOverlayIds.has(overlayId)) {
|
|
2761
|
-
if (overlay.domElement && overlay.domElement.parentNode) {
|
|
2762
|
-
overlay.domElement.parentNode.removeChild(overlay.domElement);
|
|
2763
|
-
}
|
|
2764
|
-
overlayMap.delete(overlayId);
|
|
2765
|
-
}
|
|
2766
|
-
});
|
|
2767
|
-
if (mcuLayers) {
|
|
2768
|
-
mcuLayers.innerHTML = "";
|
|
2769
|
-
mcuLayers.appendChild(fragment);
|
|
2770
|
-
}
|
|
2771
|
-
} catch (error) {
|
|
2772
|
-
(0, import_core29.getLogger)().error("Layout Changed Error", error);
|
|
2773
|
-
}
|
|
2774
|
-
});
|
|
2775
|
-
};
|
|
2776
|
-
var cleanupElement = (rootElement) => {
|
|
2777
|
-
while (rootElement.firstChild) {
|
|
2778
|
-
rootElement.removeChild(rootElement.firstChild);
|
|
2779
|
-
}
|
|
2780
|
-
};
|
|
2781
|
-
var setVideoMediaTrack = ({
|
|
2782
|
-
track,
|
|
2783
|
-
element
|
|
2784
|
-
}) => {
|
|
2785
|
-
element.srcObject = new MediaStream([track]);
|
|
2786
|
-
track.addEventListener("ended", () => {
|
|
2787
|
-
element.srcObject = null;
|
|
2788
|
-
element.remove();
|
|
2789
|
-
});
|
|
2790
|
-
};
|
|
2791
|
-
var createRootElementResizeObserver = ({
|
|
2792
|
-
video,
|
|
2793
|
-
rootElement,
|
|
2794
|
-
paddingWrapper
|
|
2795
|
-
}) => {
|
|
2796
|
-
const computePaddingWrapperWidth = (width, height) => {
|
|
2797
|
-
const nativeVideoRatio = video.videoWidth / video.videoHeight;
|
|
2798
|
-
const rootElementRatio = width / height;
|
|
2799
|
-
if (nativeVideoRatio > rootElementRatio) {
|
|
2800
|
-
return "100%";
|
|
2801
|
-
} else {
|
|
2802
|
-
return `${height * nativeVideoRatio}px`;
|
|
2803
|
-
}
|
|
2804
|
-
};
|
|
2805
|
-
const update = (0, import_core29.debounce)(
|
|
2806
|
-
({ width, height }) => {
|
|
2807
|
-
const maxPaddingBottom = video.videoHeight / video.videoWidth * 100;
|
|
2808
|
-
if (paddingWrapper) {
|
|
2809
|
-
const pb = height / width * 100;
|
|
2810
|
-
paddingWrapper.style.paddingBottom = `${pb > maxPaddingBottom ? maxPaddingBottom : pb}%`;
|
|
2811
|
-
paddingWrapper.style.width = computePaddingWrapperWidth(width, height);
|
|
2812
|
-
}
|
|
2813
|
-
},
|
|
2814
|
-
100
|
|
2815
|
-
);
|
|
2816
|
-
const observer = new ResizeObserver((entries) => {
|
|
2817
|
-
entries.forEach((entry) => {
|
|
2818
|
-
if (entry.contentBoxSize) {
|
|
2819
|
-
const { inlineSize, blockSize } = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
2820
|
-
update({ width: inlineSize, height: blockSize });
|
|
2821
|
-
} else if (entry.contentRect) {
|
|
2822
|
-
update({
|
|
2823
|
-
width: entry.contentRect.width,
|
|
2824
|
-
height: entry.contentRect.height
|
|
2825
|
-
});
|
|
2826
|
-
}
|
|
2827
|
-
});
|
|
2828
|
-
});
|
|
2829
|
-
const onVideoResize = () => {
|
|
2830
|
-
const width = rootElement.clientWidth;
|
|
2831
|
-
const height = rootElement.clientHeight;
|
|
2832
|
-
update({ width, height });
|
|
2833
|
-
};
|
|
2834
|
-
return {
|
|
2835
|
-
start: () => {
|
|
2836
|
-
observer.observe(rootElement);
|
|
2837
|
-
video.addEventListener("resize", onVideoResize);
|
|
2838
|
-
},
|
|
2839
|
-
stop: () => {
|
|
2840
|
-
observer.disconnect();
|
|
2841
|
-
video.removeEventListener("resize", onVideoResize);
|
|
2842
|
-
}
|
|
2843
|
-
};
|
|
2844
|
-
};
|
|
2845
|
-
|
|
2846
|
-
// src/buildVideoElement.ts
|
|
2847
|
-
var buildVideoElement = (params) => __async(void 0, null, function* () {
|
|
2848
|
-
var _a;
|
|
2849
|
-
try {
|
|
2850
|
-
const {
|
|
2851
|
-
room,
|
|
2852
|
-
rootElement: element,
|
|
2853
|
-
applyLocalVideoOverlay = true,
|
|
2854
|
-
applyMemberOverlay = true,
|
|
2855
|
-
mirrorLocalVideoOverlay = true
|
|
2856
|
-
} = params;
|
|
2857
|
-
let hasVideoTrack = false;
|
|
2858
|
-
const overlayMap = /* @__PURE__ */ new Map();
|
|
2859
|
-
const id = (0, import_core30.uuid)();
|
|
2860
|
-
let rootElement;
|
|
2861
|
-
if (element) {
|
|
2862
|
-
rootElement = element;
|
|
2863
|
-
} else {
|
|
2864
|
-
rootElement = document.createElement("div");
|
|
2865
|
-
rootElement.id = `rootElement-${id}`;
|
|
2866
|
-
}
|
|
2867
|
-
const overlayId = addSDKPrefix(id);
|
|
2868
|
-
const localVideoOverlay = new LocalVideoOverlay({
|
|
2869
|
-
id: overlayId,
|
|
2870
|
-
mirrorLocalVideoOverlay,
|
|
2871
|
-
room
|
|
2872
|
-
});
|
|
2873
|
-
if (applyLocalVideoOverlay) {
|
|
2874
|
-
overlayMap.set(overlayId, localVideoOverlay);
|
|
2875
|
-
}
|
|
2876
|
-
const makeLayout = makeLayoutChangedHandler({
|
|
2877
|
-
applyLocalVideoOverlay,
|
|
2878
|
-
applyMemberOverlay,
|
|
2879
|
-
overlayMap,
|
|
2880
|
-
localVideoOverlay,
|
|
2881
|
-
mirrorLocalVideoOverlay,
|
|
2882
|
-
rootElement
|
|
2883
|
-
});
|
|
2884
|
-
const processLayoutChanged = (params2) => {
|
|
2885
|
-
var _a2;
|
|
2886
|
-
const hasVideoSender = (_a2 = room.peer) == null ? void 0 : _a2.hasVideoSender;
|
|
2887
|
-
if (hasVideoSender && room.localStream) {
|
|
2888
|
-
makeLayout({
|
|
2889
|
-
layout: params2.layout,
|
|
2890
|
-
localStream: room.localStream,
|
|
2891
|
-
memberId: room.memberId
|
|
2892
|
-
});
|
|
2893
|
-
} else {
|
|
2894
|
-
(0, import_core30.getLogger)().debug(
|
|
2895
|
-
"No local video sender or local stream, hiding local video overlay",
|
|
2896
|
-
hasVideoSender,
|
|
2897
|
-
room.localStream
|
|
2898
|
-
);
|
|
2899
|
-
localVideoOverlay.hide();
|
|
2900
|
-
}
|
|
2901
|
-
};
|
|
2902
|
-
const layoutChangedHandler = (params2) => {
|
|
2903
|
-
(0, import_core30.getLogger)().debug("Received layout.changed - videoTrack", hasVideoTrack);
|
|
2904
|
-
if (hasVideoTrack) {
|
|
2905
|
-
processLayoutChanged(params2);
|
|
2906
|
-
return;
|
|
2907
|
-
}
|
|
2908
|
-
};
|
|
2909
|
-
const processVideoTrack = (track) => __async(void 0, null, function* () {
|
|
2910
|
-
hasVideoTrack = true;
|
|
2911
|
-
yield videoElementSetup({
|
|
2912
|
-
applyLocalVideoOverlay,
|
|
2913
|
-
applyMemberOverlay,
|
|
2914
|
-
rootElement,
|
|
2915
|
-
track
|
|
2916
|
-
});
|
|
2917
|
-
const roomCurrentLayoutEvent = room.currentLayoutEvent;
|
|
2918
|
-
if (roomCurrentLayoutEvent) {
|
|
2919
|
-
processLayoutChanged(roomCurrentLayoutEvent);
|
|
2920
|
-
}
|
|
2921
|
-
});
|
|
2922
|
-
const videoTrack = (_a = room.peer) == null ? void 0 : _a.remoteVideoTrack;
|
|
2923
|
-
if (videoTrack) {
|
|
2924
|
-
yield processVideoTrack(videoTrack);
|
|
2925
|
-
}
|
|
2926
|
-
const trackHandler = function(event) {
|
|
2927
|
-
return __async(this, null, function* () {
|
|
2928
|
-
if (event.track.kind === "video") {
|
|
2929
|
-
yield processVideoTrack(event.track);
|
|
2930
|
-
}
|
|
2931
|
-
});
|
|
2932
|
-
};
|
|
2933
|
-
const unsubscribe = () => {
|
|
2934
|
-
cleanupElement(rootElement);
|
|
2935
|
-
overlayMap.clear();
|
|
2936
|
-
room.overlayMap = overlayMap;
|
|
2937
|
-
if (isFabricRoomSession(room)) {
|
|
2938
|
-
room.off("track", trackHandler);
|
|
2939
|
-
room.off("layout.changed", layoutChangedHandler);
|
|
2940
|
-
room.off("destroy", unsubscribe);
|
|
2941
|
-
} else if (isVideoRoomSession(room)) {
|
|
2942
|
-
room.off("track", trackHandler);
|
|
2943
|
-
room.off("layout.changed", layoutChangedHandler);
|
|
2944
|
-
room.off("destroy", unsubscribe);
|
|
2945
|
-
}
|
|
2946
|
-
localVideoOverlay.detachListeners();
|
|
2947
|
-
};
|
|
2948
|
-
if (isFabricRoomSession(room)) {
|
|
2949
|
-
room.on("track", trackHandler);
|
|
2950
|
-
room.on("layout.changed", layoutChangedHandler);
|
|
2951
|
-
room.once("destroy", unsubscribe);
|
|
2952
|
-
} else if (isVideoRoomSession(room)) {
|
|
2953
|
-
room.on("track", trackHandler);
|
|
2954
|
-
room.on("layout.changed", layoutChangedHandler);
|
|
2955
|
-
room.once("destroy", unsubscribe);
|
|
2956
|
-
}
|
|
2957
|
-
room.overlayMap = overlayMap;
|
|
2958
|
-
room.localVideoOverlay = localVideoOverlay;
|
|
2959
|
-
return { element: rootElement, overlayMap, localVideoOverlay, unsubscribe };
|
|
2960
|
-
} catch (error) {
|
|
2961
|
-
(0, import_core30.getLogger)().error("Unable to build the video element");
|
|
2962
|
-
throw error;
|
|
2963
|
-
}
|
|
2964
|
-
});
|
|
2965
|
-
var videoElementSetup = (options) => __async(void 0, null, function* () {
|
|
2966
|
-
try {
|
|
2967
|
-
const { applyLocalVideoOverlay, applyMemberOverlay, track, rootElement } = options;
|
|
2968
|
-
const videoElement = buildVideo();
|
|
2969
|
-
setVideoMediaTrack({ element: videoElement, track });
|
|
2970
|
-
videoElement.style.width = "100%";
|
|
2971
|
-
videoElement.style.maxHeight = "100%";
|
|
2972
|
-
if (rootElement.querySelector(".mcuContent")) {
|
|
2973
|
-
(0, import_core30.getLogger)().debug("MCU Content already there");
|
|
2974
|
-
return;
|
|
2975
|
-
}
|
|
2976
|
-
const mcuWrapper = document.createElement("div");
|
|
2977
|
-
mcuWrapper.style.position = "absolute";
|
|
2978
|
-
mcuWrapper.style.top = "0";
|
|
2979
|
-
mcuWrapper.style.left = "0";
|
|
2980
|
-
mcuWrapper.style.right = "0";
|
|
2981
|
-
mcuWrapper.style.bottom = "0";
|
|
2982
|
-
mcuWrapper.appendChild(videoElement);
|
|
2983
|
-
const paddingWrapper = document.createElement("div");
|
|
2984
|
-
paddingWrapper.classList.add("paddingWrapper");
|
|
2985
|
-
paddingWrapper.style.paddingBottom = "56.25%";
|
|
2986
|
-
paddingWrapper.style.position = "relative";
|
|
2987
|
-
paddingWrapper.style.width = "100%";
|
|
2988
|
-
paddingWrapper.appendChild(mcuWrapper);
|
|
2989
|
-
let layersWrapper = null;
|
|
2990
|
-
if (applyLocalVideoOverlay || applyMemberOverlay) {
|
|
2991
|
-
layersWrapper = document.createElement("div");
|
|
2992
|
-
layersWrapper.classList.add("mcuLayers");
|
|
2993
|
-
layersWrapper.style.display = "none";
|
|
2994
|
-
paddingWrapper.appendChild(layersWrapper);
|
|
2995
|
-
}
|
|
2996
|
-
const relativeWrapper = document.createElement("div");
|
|
2997
|
-
relativeWrapper.classList.add("mcuContent");
|
|
2998
|
-
relativeWrapper.style.position = "relative";
|
|
2999
|
-
relativeWrapper.style.width = "100%";
|
|
3000
|
-
relativeWrapper.style.height = "100%";
|
|
3001
|
-
relativeWrapper.style.margin = "0 auto";
|
|
3002
|
-
relativeWrapper.style.display = "flex";
|
|
3003
|
-
relativeWrapper.style.alignItems = "center";
|
|
3004
|
-
relativeWrapper.style.justifyContent = "center";
|
|
3005
|
-
relativeWrapper.appendChild(paddingWrapper);
|
|
3006
|
-
rootElement.style.width = "100%";
|
|
3007
|
-
rootElement.style.height = "100%";
|
|
3008
|
-
rootElement.appendChild(relativeWrapper);
|
|
3009
|
-
(0, import_core30.getLogger)().debug("MCU readyState 1 >>", videoElement.readyState);
|
|
3010
|
-
if (videoElement.readyState === HTMLMediaElement.HAVE_NOTHING) {
|
|
3011
|
-
(0, import_core30.getLogger)().debug("Wait for the MCU to be ready");
|
|
3012
|
-
yield waitForVideoReady({ element: videoElement });
|
|
3013
|
-
}
|
|
3014
|
-
(0, import_core30.getLogger)().debug("MCU is ready..");
|
|
3015
|
-
const rootElementResizeObserver = createRootElementResizeObserver({
|
|
3016
|
-
rootElement,
|
|
3017
|
-
video: videoElement,
|
|
3018
|
-
paddingWrapper
|
|
3019
|
-
});
|
|
3020
|
-
rootElementResizeObserver.start();
|
|
3021
|
-
track.addEventListener("ended", () => {
|
|
3022
|
-
if (rootElementResizeObserver) {
|
|
3023
|
-
rootElementResizeObserver.stop();
|
|
3024
|
-
}
|
|
3025
|
-
});
|
|
3026
|
-
if (layersWrapper) {
|
|
3027
|
-
layersWrapper.style.display = "block";
|
|
3028
|
-
}
|
|
3029
|
-
} catch (error) {
|
|
3030
|
-
(0, import_core30.getLogger)().error("Handle video track error", error);
|
|
3031
|
-
}
|
|
3032
|
-
});
|
|
3033
|
-
|
|
3034
|
-
// src/Client.ts
|
|
3035
|
-
var ClientAPI = class extends import_core31.BaseClient {
|
|
3036
|
-
constructor() {
|
|
3037
|
-
super(...arguments);
|
|
3038
|
-
__publicField(this, "_videoManager");
|
|
3039
|
-
__publicField(this, "_chat");
|
|
3040
|
-
__publicField(this, "_pubSub");
|
|
3041
|
-
}
|
|
3042
|
-
get rooms() {
|
|
3043
|
-
return {
|
|
3044
|
-
makeRoomObject: (makeRoomOptions) => {
|
|
3045
|
-
const _a = makeRoomOptions, {
|
|
3046
|
-
rootElement,
|
|
3047
|
-
applyLocalVideoOverlay = true,
|
|
3048
|
-
applyMemberOverlay = true,
|
|
3049
|
-
mirrorLocalVideoOverlay = true,
|
|
3050
|
-
stopCameraWhileMuted = true,
|
|
3051
|
-
stopMicrophoneWhileMuted = true
|
|
3052
|
-
} = _a, options = __objRest(_a, [
|
|
3053
|
-
"rootElement",
|
|
3054
|
-
"applyLocalVideoOverlay",
|
|
3055
|
-
"applyMemberOverlay",
|
|
3056
|
-
"mirrorLocalVideoOverlay",
|
|
3057
|
-
"stopCameraWhileMuted",
|
|
3058
|
-
"stopMicrophoneWhileMuted"
|
|
3059
|
-
]);
|
|
3060
|
-
const customSagas = [];
|
|
3061
|
-
customSagas.push(
|
|
3062
|
-
makeAudioElementSaga({
|
|
3063
|
-
speakerId: options.speakerId
|
|
3064
|
-
})
|
|
3065
|
-
);
|
|
3066
|
-
const room = createVideoRoomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
3067
|
-
store: this.store,
|
|
3068
|
-
customSagas
|
|
3069
|
-
}));
|
|
3070
|
-
if (rootElement) {
|
|
3071
|
-
try {
|
|
3072
|
-
buildVideoElement({
|
|
3073
|
-
applyLocalVideoOverlay,
|
|
3074
|
-
applyMemberOverlay,
|
|
3075
|
-
mirrorLocalVideoOverlay,
|
|
3076
|
-
room,
|
|
3077
|
-
rootElement
|
|
3078
|
-
});
|
|
3079
|
-
} catch (error) {
|
|
3080
|
-
this.logger.error("Unable to build the video element automatically");
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
room.on("room.subscribed", (params) => {
|
|
3084
|
-
var _a2;
|
|
3085
|
-
const member = (_a2 = params.room_session.members) == null ? void 0 : _a2.find(
|
|
3086
|
-
(m) => m.id === room.memberId
|
|
3087
|
-
);
|
|
3088
|
-
if (member == null ? void 0 : member.audio_muted) {
|
|
3089
|
-
try {
|
|
3090
|
-
room.stopOutboundAudio();
|
|
3091
|
-
} catch (error) {
|
|
3092
|
-
this.logger.error("Error handling audio_muted", error);
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
if (member == null ? void 0 : member.video_muted) {
|
|
3096
|
-
try {
|
|
3097
|
-
room.stopOutboundVideo();
|
|
3098
|
-
} catch (error) {
|
|
3099
|
-
this.logger.error("Error handling video_muted", error);
|
|
3100
|
-
}
|
|
3101
|
-
}
|
|
3102
|
-
});
|
|
3103
|
-
if (stopMicrophoneWhileMuted) {
|
|
3104
|
-
room.on("member.updated.audio_muted", ({ member }) => {
|
|
3105
|
-
try {
|
|
3106
|
-
if (member.id === room.memberId && "audio_muted" in member) {
|
|
3107
|
-
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
3108
|
-
}
|
|
3109
|
-
} catch (error) {
|
|
3110
|
-
this.logger.error("Error handling audio_muted", error);
|
|
3111
|
-
}
|
|
3112
|
-
});
|
|
3113
|
-
}
|
|
3114
|
-
if (stopCameraWhileMuted) {
|
|
3115
|
-
room.on("member.updated.video_muted", ({ member }) => {
|
|
3116
|
-
try {
|
|
3117
|
-
if (member.id === room.memberId && "video_muted" in member) {
|
|
3118
|
-
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
3119
|
-
}
|
|
3120
|
-
} catch (error) {
|
|
3121
|
-
this.logger.error("Error handling video_muted", error);
|
|
3122
|
-
}
|
|
3123
|
-
});
|
|
3124
|
-
}
|
|
3125
|
-
return room;
|
|
3126
|
-
}
|
|
3127
|
-
};
|
|
3128
|
-
}
|
|
3129
|
-
get chat() {
|
|
3130
|
-
if (!this._chat) {
|
|
3131
|
-
this._chat = import_core31.Chat.createBaseChatObject({
|
|
3132
|
-
store: this.store
|
|
3133
|
-
});
|
|
3134
|
-
}
|
|
3135
|
-
return this._chat;
|
|
3136
|
-
}
|
|
3137
|
-
get pubSub() {
|
|
3138
|
-
if (!this._pubSub) {
|
|
3139
|
-
this._pubSub = import_core31.PubSub.createBasePubSubObject({
|
|
3140
|
-
store: this.store
|
|
3141
|
-
});
|
|
3142
|
-
}
|
|
3143
|
-
return this._pubSub;
|
|
3144
|
-
}
|
|
3145
|
-
/** @internal */
|
|
3146
|
-
get videoManager() {
|
|
3147
|
-
if (!this._videoManager) {
|
|
3148
|
-
this._videoManager = createVideoManagerObject(this.options);
|
|
3149
|
-
}
|
|
3150
|
-
return this._videoManager;
|
|
3151
|
-
}
|
|
3152
|
-
/**
|
|
3153
|
-
* Reauthenticate with the SignalWire network using a new token
|
|
3154
|
-
* For now it returns void since with an invalid token the server
|
|
3155
|
-
* will close the connection right away so we can hook on the session
|
|
3156
|
-
* events in case. Need to improve it.
|
|
3157
|
-
*
|
|
3158
|
-
* @internal
|
|
3159
|
-
*/
|
|
3160
|
-
reauthenticate(token) {
|
|
3161
|
-
this.store.dispatch(import_core31.actions.reauthAction({ token }));
|
|
3162
|
-
}
|
|
3163
|
-
};
|
|
3164
|
-
|
|
3165
|
-
// src/JWTSession.ts
|
|
3166
|
-
var import_jwt_decode2 = __toESM(require("jwt-decode"));
|
|
3167
|
-
var import_core33 = require("@signalwire/core");
|
|
3168
|
-
|
|
3169
|
-
// src/utils/CloseEvent.ts
|
|
3170
|
-
var import_core32 = require("@signalwire/core");
|
|
3171
|
-
var SwCloseEvent = typeof CloseEvent === "function" ? CloseEvent : import_core32.SWCloseEvent;
|
|
3172
|
-
|
|
3173
|
-
// src/JWTSession.ts
|
|
3174
|
-
var JWTSession = class extends import_core33.BaseJWTSession {
|
|
3175
|
-
constructor(options) {
|
|
3176
|
-
var _a;
|
|
3177
|
-
let decodedJwt = {};
|
|
3178
|
-
try {
|
|
3179
|
-
decodedJwt = (0, import_jwt_decode2.default)(options.token, {
|
|
3180
|
-
header: true
|
|
3181
|
-
});
|
|
3182
|
-
} catch (e) {
|
|
3183
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3184
|
-
(0, import_core33.getLogger)().debug("[JWTSession] error decoding the JWT");
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
super(__spreadProps(__spreadValues({}, options), {
|
|
3188
|
-
host: (decodedJwt == null ? void 0 : decodedJwt.ch) || options.host
|
|
3189
|
-
}));
|
|
3190
|
-
this.options = options;
|
|
3191
|
-
__publicField(this, "WebSocketConstructor", WebSocket);
|
|
3192
|
-
__publicField(this, "CloseEventConstructor", SwCloseEvent);
|
|
3193
|
-
__publicField(this, "agent", "@signalwire/js/browser/3.29.2");
|
|
3194
|
-
__publicField(this, "tokenTyp");
|
|
3195
|
-
this.tokenTyp = (_a = decodedJwt.typ) != null ? _a : "VRT";
|
|
3196
|
-
}
|
|
3197
|
-
get allowReattach() {
|
|
3198
|
-
var _a;
|
|
3199
|
-
return ((_a = this.options) == null ? void 0 : _a.reattach) !== false && (this.isVRT() || this.isSAT());
|
|
3200
|
-
}
|
|
3201
|
-
retrieveRelayProtocol() {
|
|
3202
|
-
return __async(this, null, function* () {
|
|
3203
|
-
var _a, _b;
|
|
3204
|
-
if (!this.allowReattach) {
|
|
3205
|
-
return "";
|
|
3206
|
-
}
|
|
3207
|
-
const { protocolKey } = sessionStorageManager(this.options.token);
|
|
3208
|
-
if (protocolKey) {
|
|
3209
|
-
this.logger.trace("Search protocol for", protocolKey);
|
|
3210
|
-
return (_b = (_a = getStorage()) == null ? void 0 : _a.getItem(protocolKey)) != null ? _b : "";
|
|
3211
|
-
}
|
|
3212
|
-
return "";
|
|
3213
|
-
});
|
|
3214
|
-
}
|
|
3215
|
-
persistRelayProtocol() {
|
|
3216
|
-
return __async(this, null, function* () {
|
|
3217
|
-
var _a;
|
|
3218
|
-
if (!this.allowReattach) {
|
|
3219
|
-
return;
|
|
3220
|
-
}
|
|
3221
|
-
const { protocolKey } = sessionStorageManager(this.options.token);
|
|
3222
|
-
if (protocolKey) {
|
|
3223
|
-
this.logger.trace("Persist protocol", protocolKey, this.relayProtocol);
|
|
3224
|
-
(_a = getStorage()) == null ? void 0 : _a.setItem(protocolKey, this.relayProtocol);
|
|
3225
|
-
}
|
|
3226
|
-
});
|
|
3227
|
-
}
|
|
3228
|
-
removeRelayProtocol() {
|
|
3229
|
-
var _a;
|
|
3230
|
-
const { protocolKey } = sessionStorageManager(this.options.token);
|
|
3231
|
-
if (protocolKey) {
|
|
3232
|
-
this.logger.debug("Remove protocol", protocolKey, this.relayProtocol);
|
|
3233
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(protocolKey);
|
|
3234
|
-
}
|
|
3235
|
-
}
|
|
3236
|
-
removePrevCallId() {
|
|
3237
|
-
var _a;
|
|
3238
|
-
const { callIdKey } = sessionStorageManager(this.options.token);
|
|
3239
|
-
if (callIdKey) {
|
|
3240
|
-
this.logger.debug("Remove Call", callIdKey);
|
|
3241
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(callIdKey);
|
|
3242
|
-
}
|
|
3243
|
-
}
|
|
3244
|
-
retrieveSwAuthorizationState() {
|
|
3245
|
-
return __async(this, null, function* () {
|
|
3246
|
-
var _a, _b;
|
|
3247
|
-
const { authStateKey } = sessionStorageManager(this.options.token);
|
|
3248
|
-
if (authStateKey) {
|
|
3249
|
-
return (_b = (_a = getStorage()) == null ? void 0 : _a.getItem(authStateKey)) != null ? _b : "";
|
|
3250
|
-
}
|
|
3251
|
-
return "";
|
|
3252
|
-
});
|
|
3253
|
-
}
|
|
3254
|
-
persistSwAuthorizationState(state) {
|
|
3255
|
-
return __async(this, null, function* () {
|
|
3256
|
-
var _a;
|
|
3257
|
-
if (!this.allowReattach) {
|
|
3258
|
-
return;
|
|
3259
|
-
}
|
|
3260
|
-
const { authStateKey } = sessionStorageManager(this.options.token);
|
|
3261
|
-
if (authStateKey) {
|
|
3262
|
-
this.logger.trace("Persist auth state", authStateKey, state);
|
|
3263
|
-
(_a = getStorage()) == null ? void 0 : _a.setItem(authStateKey, state);
|
|
3264
|
-
}
|
|
3265
|
-
});
|
|
3266
|
-
}
|
|
3267
|
-
removeSwAuthorizationState() {
|
|
3268
|
-
var _a;
|
|
3269
|
-
const { authStateKey } = sessionStorageManager(this.options.token);
|
|
3270
|
-
if (authStateKey) {
|
|
3271
|
-
this.logger.trace("Remove auth state", authStateKey);
|
|
3272
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(authStateKey);
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
_onSocketClose(event) {
|
|
3276
|
-
var _a, _b, _c;
|
|
3277
|
-
if (this.status === "disconnected") {
|
|
3278
|
-
const { protocolKey, authStateKey, callIdKey } = sessionStorageManager(
|
|
3279
|
-
this.options.token
|
|
3280
|
-
);
|
|
3281
|
-
this.logger.debug("Cleaning up storage");
|
|
3282
|
-
if (protocolKey) {
|
|
3283
|
-
this.logger.debug("Remove protocolKey", protocolKey);
|
|
3284
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(protocolKey);
|
|
3285
|
-
}
|
|
3286
|
-
if (authStateKey) {
|
|
3287
|
-
this.logger.debug("Remove authStateKey", authStateKey);
|
|
3288
|
-
(_b = getStorage()) == null ? void 0 : _b.removeItem(authStateKey);
|
|
3289
|
-
}
|
|
3290
|
-
if (callIdKey) {
|
|
3291
|
-
this.logger.debug("Remove callIdKey", callIdKey);
|
|
3292
|
-
(_c = getStorage()) == null ? void 0 : _c.removeItem(callIdKey);
|
|
3293
|
-
}
|
|
3294
|
-
}
|
|
3295
|
-
super._onSocketClose(event);
|
|
3296
|
-
}
|
|
3297
|
-
isVRT() {
|
|
3298
|
-
return this.tokenTyp === "VRT";
|
|
3299
|
-
}
|
|
3300
|
-
isSAT() {
|
|
3301
|
-
return this.tokenTyp === "SAT";
|
|
3302
|
-
}
|
|
3303
|
-
};
|
|
3304
|
-
|
|
3305
|
-
// src/createClient.ts
|
|
3306
|
-
var createClient = (userOptions) => {
|
|
3307
|
-
const baseUserOptions = __spreadProps(__spreadValues({}, userOptions), {
|
|
3308
|
-
emitter: (0, import_core34.getEventEmitter)()
|
|
3309
|
-
});
|
|
3310
|
-
const store = (0, import_core34.configureStore)({
|
|
3311
|
-
userOptions: baseUserOptions,
|
|
3312
|
-
SessionConstructor: JWTSession
|
|
3313
|
-
});
|
|
3314
|
-
const client = (0, import_core34.connect)({
|
|
3315
|
-
store,
|
|
3316
|
-
Component: ClientAPI
|
|
3317
|
-
})(baseUserOptions);
|
|
3318
|
-
return client;
|
|
3319
|
-
};
|
|
3320
|
-
|
|
3321
|
-
// src/chat/Client.ts
|
|
3322
|
-
var INTERCEPTED_METHODS = [
|
|
3323
|
-
"subscribe",
|
|
3324
|
-
"publish",
|
|
3325
|
-
"getMessages",
|
|
3326
|
-
"getMembers",
|
|
3327
|
-
"getMemberState",
|
|
3328
|
-
"getAllowedChannels",
|
|
3329
|
-
"setMemberState"
|
|
3330
|
-
];
|
|
3331
|
-
var Client2 = function(chatOptions) {
|
|
3332
|
-
const client = createClient(chatOptions);
|
|
3333
|
-
const createInterceptor = (prop) => {
|
|
3334
|
-
return (...params) => __async(this, null, function* () {
|
|
3335
|
-
yield client.connect();
|
|
3336
|
-
return client.chat[prop](...params);
|
|
3337
|
-
});
|
|
3338
|
-
};
|
|
3339
|
-
const interceptors = {
|
|
3340
|
-
_session: client,
|
|
3341
|
-
disconnect: () => client.disconnect()
|
|
3342
|
-
};
|
|
3343
|
-
return new Proxy(client.chat, {
|
|
3344
|
-
get(target, prop, receiver) {
|
|
3345
|
-
if (prop in interceptors) {
|
|
3346
|
-
return interceptors[prop];
|
|
3347
|
-
}
|
|
3348
|
-
if (INTERCEPTED_METHODS.includes(prop)) {
|
|
3349
|
-
return createInterceptor(prop);
|
|
3350
|
-
}
|
|
3351
|
-
return Reflect.get(target, prop, receiver);
|
|
3352
|
-
}
|
|
3353
|
-
});
|
|
3354
|
-
};
|
|
3355
|
-
|
|
3356
|
-
// src/chat/index.ts
|
|
3357
|
-
var import_core35 = require("@signalwire/core");
|
|
3358
|
-
|
|
3359
|
-
// src/pubSub/index.ts
|
|
3360
|
-
var pubSub_exports = {};
|
|
3361
|
-
__export(pubSub_exports, {
|
|
3362
|
-
Client: () => Client3,
|
|
3363
|
-
PubSubMessage: () => PubSubMessage
|
|
3364
|
-
});
|
|
3365
|
-
var import_core37 = require("@signalwire/core");
|
|
3366
|
-
|
|
3367
|
-
// src/utils/interfaces/video.ts
|
|
3368
|
-
var import_core36 = require("@signalwire/core");
|
|
3369
|
-
var INTERNAL_MEMBER_UPDATED_EVENTS = Object.keys(
|
|
3370
|
-
import_core36.INTERNAL_MEMBER_UPDATABLE_PROPS
|
|
3371
|
-
).map((key) => {
|
|
3372
|
-
return `member.updated.${key}`;
|
|
3373
|
-
});
|
|
3374
|
-
|
|
3375
|
-
// src/pubSub/Client.ts
|
|
3376
|
-
var INTERCEPTED_METHODS2 = [
|
|
3377
|
-
"getAllowedChannels",
|
|
3378
|
-
"subscribe",
|
|
3379
|
-
"publish"
|
|
3380
|
-
];
|
|
3381
|
-
var Client3 = function(pubSubOptions) {
|
|
3382
|
-
const client = createClient(pubSubOptions);
|
|
3383
|
-
const createInterceptor = (prop) => {
|
|
3384
|
-
return (...params) => __async(this, null, function* () {
|
|
3385
|
-
yield client.connect();
|
|
3386
|
-
return client.pubSub[prop](...params);
|
|
3387
|
-
});
|
|
3388
|
-
};
|
|
3389
|
-
const interceptors = {
|
|
3390
|
-
_session: client,
|
|
3391
|
-
disconnect: () => client.disconnect()
|
|
3392
|
-
};
|
|
3393
|
-
return new Proxy(client.pubSub, {
|
|
3394
|
-
get(target, prop, receiver) {
|
|
3395
|
-
if (prop in interceptors) {
|
|
3396
|
-
return interceptors[prop];
|
|
3397
|
-
}
|
|
3398
|
-
if (INTERCEPTED_METHODS2.includes(prop)) {
|
|
3399
|
-
return createInterceptor(prop);
|
|
3400
|
-
}
|
|
3401
|
-
return Reflect.get(target, prop, receiver);
|
|
3402
|
-
}
|
|
3403
|
-
});
|
|
3404
|
-
};
|
|
3405
|
-
|
|
3406
|
-
// src/pubSub/index.ts
|
|
3407
|
-
var PubSubMessage = import_core37.PubSub.PubSubMessage;
|
|
3408
|
-
|
|
3409
|
-
// src/fabric/index.ts
|
|
3410
|
-
var fabric_exports = {};
|
|
3411
|
-
__export(fabric_exports, {
|
|
3412
|
-
SignalWire: () => SignalWire,
|
|
3413
|
-
isFabricRoomSession: () => isFabricRoomSession
|
|
3414
|
-
});
|
|
3415
|
-
|
|
3416
|
-
// src/fabric/HTTPClient.ts
|
|
3417
|
-
var import_jwt_decode3 = __toESM(require("jwt-decode"));
|
|
3418
|
-
var import_core39 = require("@signalwire/core");
|
|
3419
|
-
|
|
3420
|
-
// src/fabric/createHttpClient.ts
|
|
3421
|
-
var import_core38 = require("@signalwire/core");
|
|
3422
|
-
var DEFAULT_MAX_RETRIES = 0;
|
|
3423
|
-
var DEFAULT_INITIAL_DELAY = 0;
|
|
3424
|
-
var DEFAULT_DELAY_VARIATION = 0;
|
|
3425
|
-
var DEFAULT_TIMEOUT = 3e4;
|
|
3426
|
-
function http(input, init, maxRetries, retriesDelay, retriesDelayIncrement) {
|
|
3427
|
-
return __async(this, null, function* () {
|
|
3428
|
-
const response = yield (0, import_core38.asyncRetry)({
|
|
3429
|
-
asyncCallable: () => fetch(input, init),
|
|
3430
|
-
maxRetries,
|
|
3431
|
-
validator: (response2) => {
|
|
3432
|
-
if (!response2.ok && response2.status >= 500) {
|
|
3433
|
-
throw new import_core38.HttpError(response2.status, response2.statusText);
|
|
3434
|
-
}
|
|
3435
|
-
},
|
|
3436
|
-
delayFn: (0, import_core38.increasingDelay)({
|
|
3437
|
-
initialDelay: retriesDelay,
|
|
3438
|
-
variation: retriesDelayIncrement
|
|
3439
|
-
})
|
|
3440
|
-
});
|
|
3441
|
-
if (!response.ok) {
|
|
3442
|
-
if (response.status === 401) {
|
|
3443
|
-
throw new import_core38.AuthError(response.status, "Unauthorized");
|
|
3444
|
-
}
|
|
3445
|
-
let errorResponse;
|
|
3446
|
-
try {
|
|
3447
|
-
errorResponse = yield response.json();
|
|
3448
|
-
} catch (e) {
|
|
3449
|
-
}
|
|
3450
|
-
const errorMessage = (errorResponse == null ? void 0 : errorResponse.errors) ? JSON.stringify(errorResponse.errors) : "Not Found";
|
|
3451
|
-
throw new import_core38.HttpError(response.status, errorMessage, errorResponse);
|
|
3452
|
-
}
|
|
3453
|
-
try {
|
|
3454
|
-
response.parsedBody = yield response.json();
|
|
3455
|
-
} catch (e) {
|
|
3456
|
-
}
|
|
3457
|
-
return response;
|
|
3458
|
-
});
|
|
3459
|
-
}
|
|
3460
|
-
var createHttpClient = (_a, fetcher = http) => {
|
|
3461
|
-
var _b = _a, {
|
|
3462
|
-
baseUrl,
|
|
3463
|
-
maxApiRequestRetries: retries = DEFAULT_MAX_RETRIES,
|
|
3464
|
-
apiRequestRetriesDelay: retriesDelay = DEFAULT_INITIAL_DELAY,
|
|
3465
|
-
apiRequestRetriesDelayIncrement: retriesDelayIncrement = DEFAULT_DELAY_VARIATION,
|
|
3466
|
-
timeout = DEFAULT_TIMEOUT
|
|
3467
|
-
} = _b, globalOptions = __objRest(_b, [
|
|
3468
|
-
"baseUrl",
|
|
3469
|
-
"maxApiRequestRetries",
|
|
3470
|
-
"apiRequestRetriesDelay",
|
|
3471
|
-
"apiRequestRetriesDelayIncrement",
|
|
3472
|
-
"timeout"
|
|
3473
|
-
]);
|
|
3474
|
-
const apiClient = (path, options) => __async(void 0, null, function* () {
|
|
3475
|
-
const headers = __spreadValues(__spreadValues(__spreadValues({}, (options == null ? void 0 : options.body) ? { "Content-Type": "application/json" } : {}), globalOptions.headers), options == null ? void 0 : options.headers);
|
|
3476
|
-
const reqInit = getRequestInit(__spreadProps(__spreadValues(__spreadValues({}, globalOptions), options), {
|
|
3477
|
-
headers
|
|
3478
|
-
}));
|
|
3479
|
-
let timerId;
|
|
3480
|
-
if (timeout) {
|
|
3481
|
-
const controller = new AbortController();
|
|
3482
|
-
const signal = controller.signal;
|
|
3483
|
-
reqInit.signal = signal;
|
|
3484
|
-
timerId = setTimeout(() => {
|
|
3485
|
-
controller.abort();
|
|
3486
|
-
}, timeout);
|
|
3487
|
-
}
|
|
3488
|
-
try {
|
|
3489
|
-
const response = yield fetcher(
|
|
3490
|
-
getUrl({
|
|
3491
|
-
path,
|
|
3492
|
-
baseUrl,
|
|
3493
|
-
searchParams: options == null ? void 0 : options.searchParams
|
|
3494
|
-
}),
|
|
3495
|
-
reqInit,
|
|
3496
|
-
retries,
|
|
3497
|
-
retriesDelay,
|
|
3498
|
-
retriesDelayIncrement
|
|
3499
|
-
);
|
|
3500
|
-
return { body: response.parsedBody };
|
|
3501
|
-
} catch (e) {
|
|
3502
|
-
throw e;
|
|
3503
|
-
} finally {
|
|
3504
|
-
timerId && clearTimeout(timerId);
|
|
3505
|
-
}
|
|
3506
|
-
});
|
|
3507
|
-
return apiClient;
|
|
3508
|
-
};
|
|
3509
|
-
var getBody = (body) => {
|
|
3510
|
-
return typeof body === "string" ? body : JSON.stringify(body);
|
|
3511
|
-
};
|
|
3512
|
-
var getRequestInit = (options) => {
|
|
3513
|
-
return Object.entries(options).reduce((reducer, [key, value]) => {
|
|
3514
|
-
if (key === "body") {
|
|
3515
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
3516
|
-
body: getBody(value)
|
|
3517
|
-
});
|
|
3518
|
-
} else if (value != void 0) {
|
|
3519
|
-
return __spreadProps(__spreadValues({}, reducer), {
|
|
3520
|
-
[key]: value
|
|
3521
|
-
});
|
|
3522
|
-
}
|
|
3523
|
-
return reducer;
|
|
3524
|
-
}, {});
|
|
3525
|
-
};
|
|
3526
|
-
var getUrl = ({
|
|
3527
|
-
path,
|
|
3528
|
-
baseUrl,
|
|
3529
|
-
searchParams
|
|
3530
|
-
}) => {
|
|
3531
|
-
const url = new URL(path, baseUrl);
|
|
3532
|
-
if (searchParams) {
|
|
3533
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
3534
|
-
if (value != void 0) {
|
|
3535
|
-
url.searchParams.append(key, value);
|
|
3536
|
-
}
|
|
3537
|
-
});
|
|
3538
|
-
}
|
|
3539
|
-
return url.toString();
|
|
3540
|
-
};
|
|
3541
|
-
|
|
3542
|
-
// src/utils/paginatedResult.ts
|
|
3543
|
-
function buildPaginatedResult(body, client) {
|
|
3544
|
-
const anotherPage = (url) => __async(this, null, function* () {
|
|
3545
|
-
if (!url) return Promise.resolve(void 0);
|
|
3546
|
-
const { body: body2 } = yield client(url);
|
|
3547
|
-
return buildPaginatedResult(body2, client);
|
|
3548
|
-
});
|
|
3549
|
-
return {
|
|
3550
|
-
data: body.data,
|
|
3551
|
-
self: () => __async(this, null, function* () {
|
|
3552
|
-
const { self } = body.links;
|
|
3553
|
-
return anotherPage(self);
|
|
3554
|
-
}),
|
|
3555
|
-
nextPage: () => __async(this, null, function* () {
|
|
3556
|
-
const { next } = body.links;
|
|
3557
|
-
return anotherPage(next);
|
|
3558
|
-
}),
|
|
3559
|
-
prevPage: () => __async(this, null, function* () {
|
|
3560
|
-
const { prev } = body.links;
|
|
3561
|
-
return anotherPage(prev);
|
|
3562
|
-
}),
|
|
3563
|
-
firstPage: () => __async(this, null, function* () {
|
|
3564
|
-
const { first } = body.links;
|
|
3565
|
-
return anotherPage(first);
|
|
3566
|
-
}),
|
|
3567
|
-
hasNext: Boolean(body.links.next),
|
|
3568
|
-
hasPrev: Boolean(body.links.prev)
|
|
3569
|
-
};
|
|
3570
|
-
}
|
|
3571
|
-
|
|
3572
|
-
// src/utils/makeQueryParamsUrl.ts
|
|
3573
|
-
function makeQueryParamsUrls(path, queryParams) {
|
|
3574
|
-
const queryString = queryParams.toString();
|
|
3575
|
-
return queryString ? `${path}?${queryString}` : path;
|
|
3576
|
-
}
|
|
3577
|
-
|
|
3578
|
-
// src/fabric/utils/typeGuard.ts
|
|
3579
|
-
var isGetAddressByNameParams = (obj) => {
|
|
3580
|
-
return obj && "name" in obj;
|
|
3581
|
-
};
|
|
3582
|
-
var isGetAddressByIdParams = (obj) => {
|
|
3583
|
-
return obj && "id" in obj;
|
|
3584
|
-
};
|
|
3585
|
-
var isGetAddressesResponse = (obj) => {
|
|
3586
|
-
return obj && "data" in obj;
|
|
3587
|
-
};
|
|
3588
|
-
|
|
3589
|
-
// src/fabric/HTTPClient.ts
|
|
3590
|
-
var HTTPClient = class {
|
|
3591
|
-
constructor(options) {
|
|
3592
|
-
this.options = options;
|
|
3593
|
-
__publicField(this, "httpClient");
|
|
3594
|
-
this.httpClient = createHttpClient({
|
|
3595
|
-
baseUrl: `https://${this.httpHost}`,
|
|
3596
|
-
headers: {
|
|
3597
|
-
Authorization: `Bearer ${this.options.token}`
|
|
3598
|
-
},
|
|
3599
|
-
maxApiRequestRetries: this.options.maxApiRequestRetries,
|
|
3600
|
-
apiRequestRetriesDelay: this.options.apiRequestRetriesDelay,
|
|
3601
|
-
apiRequestRetriesDelayIncrement: this.options.apiRequestRetriesDelayIncrement
|
|
3602
|
-
});
|
|
3603
|
-
}
|
|
3604
|
-
get fetch() {
|
|
3605
|
-
return this.httpClient;
|
|
3606
|
-
}
|
|
3607
|
-
get httpHost() {
|
|
3608
|
-
let decodedJwt = {};
|
|
3609
|
-
try {
|
|
3610
|
-
decodedJwt = (0, import_jwt_decode3.default)(this.options.token, {
|
|
3611
|
-
header: true
|
|
3612
|
-
});
|
|
3613
|
-
} catch (e) {
|
|
3614
|
-
if (process.env.NODE_ENV !== "production") {
|
|
3615
|
-
(0, import_core39.getLogger)().debug("[JWTSession] error decoding the JWT");
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
const host = this.options.host || (decodedJwt == null ? void 0 : decodedJwt.ch);
|
|
3619
|
-
if (!host) {
|
|
3620
|
-
return "fabric.signalwire.com";
|
|
3621
|
-
}
|
|
3622
|
-
return `fabric.${host.split(".").splice(1).join(".")}`;
|
|
3623
|
-
}
|
|
3624
|
-
getAddress(params) {
|
|
3625
|
-
return __async(this, null, function* () {
|
|
3626
|
-
let path = "/api/fabric/addresses";
|
|
3627
|
-
if (isGetAddressByNameParams(params)) {
|
|
3628
|
-
path = `${path}?name=${params.name}`;
|
|
3629
|
-
} else if (isGetAddressByIdParams(params)) {
|
|
3630
|
-
path = `${path}/${params.id}`;
|
|
3631
|
-
}
|
|
3632
|
-
const { body } = yield this.httpClient(path);
|
|
3633
|
-
if (isGetAddressesResponse(body)) {
|
|
3634
|
-
if (!body.data[0]) throw new import_core39.HttpError(404, "Not Found");
|
|
3635
|
-
return body.data[0];
|
|
3636
|
-
}
|
|
3637
|
-
return body;
|
|
3638
|
-
});
|
|
3639
|
-
}
|
|
3640
|
-
getAddresses(params) {
|
|
3641
|
-
return __async(this, null, function* () {
|
|
3642
|
-
const { type, displayName, pageSize, sortBy, sortOrder } = params || {};
|
|
3643
|
-
let path = "/api/fabric/addresses";
|
|
3644
|
-
const queryParams = new URLSearchParams();
|
|
3645
|
-
if (type) {
|
|
3646
|
-
queryParams.append("type", type);
|
|
3647
|
-
}
|
|
3648
|
-
if (displayName) {
|
|
3649
|
-
queryParams.append("display_name", displayName);
|
|
3650
|
-
}
|
|
3651
|
-
if (pageSize) {
|
|
3652
|
-
queryParams.append("page_size", pageSize.toString());
|
|
3653
|
-
}
|
|
3654
|
-
if (sortBy) {
|
|
3655
|
-
queryParams.append("sort_by", sortBy);
|
|
3656
|
-
}
|
|
3657
|
-
if (sortOrder) {
|
|
3658
|
-
queryParams.append("sort_order", sortOrder);
|
|
3659
|
-
}
|
|
3660
|
-
const queryUrl = makeQueryParamsUrls(path, queryParams);
|
|
3661
|
-
(0, import_core39.getLogger)().debug(`[getAddresses] query URL ${queryUrl}`);
|
|
3662
|
-
const { body } = yield this.httpClient(queryUrl);
|
|
3663
|
-
return buildPaginatedResult(body, this.httpClient);
|
|
3664
|
-
});
|
|
3665
|
-
}
|
|
3666
|
-
registerDevice(params) {
|
|
3667
|
-
return __async(this, null, function* () {
|
|
3668
|
-
const { deviceType, deviceToken } = params;
|
|
3669
|
-
const path = "/subscriber/devices";
|
|
3670
|
-
const { body } = yield this.httpClient(path, {
|
|
3671
|
-
method: "POST",
|
|
3672
|
-
body: {
|
|
3673
|
-
device_type: deviceType,
|
|
3674
|
-
device_token: deviceToken
|
|
3675
|
-
}
|
|
3676
|
-
});
|
|
3677
|
-
return body;
|
|
3678
|
-
});
|
|
3679
|
-
}
|
|
3680
|
-
unregisterDevice(params) {
|
|
3681
|
-
return __async(this, null, function* () {
|
|
3682
|
-
const { id } = params;
|
|
3683
|
-
const path = `/subscriber/devices/${id}`;
|
|
3684
|
-
yield this.httpClient(path, {
|
|
3685
|
-
method: "DELETE"
|
|
3686
|
-
});
|
|
3687
|
-
});
|
|
3688
|
-
}
|
|
3689
|
-
getSubscriberInfo() {
|
|
3690
|
-
return __async(this, null, function* () {
|
|
3691
|
-
let path = "/api/fabric/subscriber/info";
|
|
3692
|
-
const { body } = yield this.httpClient(path);
|
|
3693
|
-
return body;
|
|
3694
|
-
});
|
|
3695
|
-
}
|
|
3696
|
-
};
|
|
3697
|
-
|
|
3698
|
-
// src/fabric/WSClient.ts
|
|
3699
|
-
var import_core42 = require("@signalwire/core");
|
|
3700
|
-
var import_webrtc5 = require("@signalwire/webrtc");
|
|
3701
|
-
|
|
3702
|
-
// src/fabric/IncomingCallManager.ts
|
|
3703
|
-
var IncomingCallManager = class {
|
|
3704
|
-
constructor(options) {
|
|
3705
|
-
this.options = options;
|
|
3706
|
-
__publicField(this, "_client");
|
|
3707
|
-
__publicField(this, "_pendingInvites", {});
|
|
3708
|
-
__publicField(this, "_handlers", {});
|
|
3709
|
-
this._client = options.client;
|
|
3710
|
-
}
|
|
3711
|
-
_buildNotification(invite) {
|
|
3712
|
-
const accept = (params) => __async(this, null, function* () {
|
|
3713
|
-
return new Promise((resolve, reject2) => {
|
|
3714
|
-
delete this._pendingInvites[invite.callID];
|
|
3715
|
-
try {
|
|
3716
|
-
const call = this.options.buildInboundCall(invite, params);
|
|
3717
|
-
call.answer();
|
|
3718
|
-
resolve(call);
|
|
3719
|
-
} catch (e) {
|
|
3720
|
-
reject2(e);
|
|
3721
|
-
}
|
|
3722
|
-
});
|
|
3723
|
-
});
|
|
3724
|
-
const reject = () => {
|
|
3725
|
-
delete this._pendingInvites[invite.callID];
|
|
3726
|
-
return this.options.executeVertoBye(invite.callID, invite.nodeId);
|
|
3727
|
-
};
|
|
3728
|
-
return {
|
|
3729
|
-
invite: {
|
|
3730
|
-
details: invite,
|
|
3731
|
-
accept: (params) => accept(params),
|
|
3732
|
-
reject: () => reject()
|
|
3733
|
-
}
|
|
3734
|
-
};
|
|
3735
|
-
}
|
|
3736
|
-
setNotificationHandlers(handlers) {
|
|
3737
|
-
this._handlers.all = handlers.all;
|
|
3738
|
-
if (handlers.pushNotification && this._handlers.all != handlers.pushNotification || !handlers.pushNotification) {
|
|
3739
|
-
this._handlers.pushNotification = handlers.pushNotification;
|
|
3740
|
-
}
|
|
3741
|
-
if (handlers.websocket && this._handlers.all != handlers.websocket || !handlers.websocket) {
|
|
3742
|
-
this._handlers.websocket = handlers.websocket;
|
|
3743
|
-
}
|
|
3744
|
-
}
|
|
3745
|
-
handleIncomingInvite(incomingInvite) {
|
|
3746
|
-
var _a, _b;
|
|
3747
|
-
if (incomingInvite.callID in this._pendingInvites) {
|
|
3748
|
-
this._client.logger.debug(
|
|
3749
|
-
`skiping nottification for pending invite to callID: ${incomingInvite.callID}`
|
|
3750
|
-
);
|
|
3751
|
-
return;
|
|
3752
|
-
}
|
|
3753
|
-
this._pendingInvites[incomingInvite.callID] = incomingInvite;
|
|
3754
|
-
if (!(this._handlers.all || this._handlers[incomingInvite.source])) {
|
|
3755
|
-
this._client.logger.warn("Skiping nottification due to no listeners");
|
|
3756
|
-
return;
|
|
3757
|
-
}
|
|
3758
|
-
const notification = this._buildNotification(incomingInvite);
|
|
3759
|
-
(_b = (_a = this._handlers).all) == null ? void 0 : _b.call(_a, notification);
|
|
3760
|
-
const handler = this._handlers[incomingInvite.source];
|
|
3761
|
-
handler == null ? void 0 : handler(notification);
|
|
3762
|
-
}
|
|
3763
|
-
};
|
|
3764
|
-
|
|
3765
|
-
// src/fabric/createWSClient.ts
|
|
3766
|
-
var import_core41 = require("@signalwire/core");
|
|
3767
|
-
|
|
3768
|
-
// src/fabric/SATSession.ts
|
|
3769
|
-
var import_core40 = require("@signalwire/core");
|
|
3770
|
-
var SATSession = class _SATSession extends JWTSession {
|
|
3771
|
-
constructor(options) {
|
|
3772
|
-
super(options);
|
|
3773
|
-
this.options = options;
|
|
3774
|
-
__publicField(this, "connectVersion", import_core40.UNIFIED_CONNECT_VERSION);
|
|
3775
|
-
}
|
|
3776
|
-
get signature() {
|
|
3777
|
-
if (this._rpcConnectResult) {
|
|
3778
|
-
const { authorization } = this._rpcConnectResult;
|
|
3779
|
-
return authorization.jti;
|
|
3780
|
-
}
|
|
3781
|
-
return void 0;
|
|
3782
|
-
}
|
|
3783
|
-
_checkTokenExpiration() {
|
|
3784
|
-
return __async(this, null, function* () {
|
|
3785
|
-
});
|
|
3786
|
-
}
|
|
3787
|
-
/**
|
|
3788
|
-
* Reauthenticate with the SignalWire Network using a newer SAT.
|
|
3789
|
-
* If the session has expired, this will reconnect it.
|
|
3790
|
-
* @return Promise<void>
|
|
3791
|
-
*/
|
|
3792
|
-
reauthenticate() {
|
|
3793
|
-
return __async(this, null, function* () {
|
|
3794
|
-
this.logger.debug("Session Reauthenticate", {
|
|
3795
|
-
ready: this.ready,
|
|
3796
|
-
expired: this.expired
|
|
3797
|
-
});
|
|
3798
|
-
if (!this.ready || this.expired) {
|
|
3799
|
-
return this.connect();
|
|
3800
|
-
}
|
|
3801
|
-
const params = {
|
|
3802
|
-
project: this._rpcConnectResult.authorization.project_id,
|
|
3803
|
-
jwt_token: this.options.token
|
|
3804
|
-
};
|
|
3805
|
-
try {
|
|
3806
|
-
const reauthResponse = yield this.execute((0, import_core40.RPCReauthenticate)(params));
|
|
3807
|
-
this._rpcConnectResult = __spreadValues(__spreadValues({}, this._rpcConnectResult), reauthResponse);
|
|
3808
|
-
} catch (error) {
|
|
3809
|
-
throw error;
|
|
3810
|
-
}
|
|
3811
|
-
});
|
|
3812
|
-
}
|
|
3813
|
-
execute(msg) {
|
|
3814
|
-
return __async(this, null, function* () {
|
|
3815
|
-
return (0, import_core40.asyncRetry)({
|
|
3816
|
-
asyncCallable: () => __async(this, null, function* () {
|
|
3817
|
-
yield this._waitConnected();
|
|
3818
|
-
return __superGet(_SATSession.prototype, this, "execute").call(this, msg);
|
|
3819
|
-
}),
|
|
3820
|
-
maxRetries: this.options.maxApiRequestRetries,
|
|
3821
|
-
delayFn: (0, import_core40.increasingDelay)({
|
|
3822
|
-
initialDelay: this.options.apiRequestRetriesDelay,
|
|
3823
|
-
variation: this.options.apiRequestRetriesDelayIncrement
|
|
3824
|
-
}),
|
|
3825
|
-
expectedErrorHandler: (error) => {
|
|
3826
|
-
(0, import_core40.getLogger)().warn(error);
|
|
3827
|
-
if ((0, import_core40.isConnectRequest)(msg)) {
|
|
3828
|
-
return true;
|
|
3829
|
-
}
|
|
3830
|
-
if ((0, import_core40.isVertoInvite)(msg) && ![import_core40.SYMBOL_EXECUTE_CONNECTION_CLOSED, import_core40.SYMBOL_EXECUTE_TIMEOUT].includes(error)) {
|
|
3831
|
-
(0, import_core40.getLogger)().debug("skip verto.invite retry on error:", error);
|
|
3832
|
-
return true;
|
|
3833
|
-
}
|
|
3834
|
-
return false;
|
|
3835
|
-
}
|
|
3836
|
-
});
|
|
3837
|
-
});
|
|
3838
|
-
}
|
|
3839
|
-
};
|
|
3840
|
-
|
|
3841
|
-
// src/fabric/createWSClient.ts
|
|
3842
|
-
var createWSClient = (options) => {
|
|
3843
|
-
const store = (0, import_core41.configureStore)({
|
|
3844
|
-
userOptions: options,
|
|
3845
|
-
SessionConstructor: SATSession
|
|
3846
|
-
});
|
|
3847
|
-
return __spreadProps(__spreadValues({}, options), { store });
|
|
3848
|
-
};
|
|
3849
|
-
|
|
3850
|
-
// src/fabric/WSClient.ts
|
|
3851
|
-
var WSClient = class extends import_core42.BaseClient {
|
|
3852
|
-
constructor(wsClientOptions) {
|
|
3853
|
-
const client = createWSClient(wsClientOptions);
|
|
3854
|
-
super(client);
|
|
3855
|
-
this.wsClientOptions = wsClientOptions;
|
|
3856
|
-
__publicField(this, "_incomingCallManager");
|
|
3857
|
-
__publicField(this, "_disconnected", false);
|
|
3858
|
-
this._incomingCallManager = new IncomingCallManager({
|
|
3859
|
-
client: this,
|
|
3860
|
-
buildInboundCall: this.buildInboundCall.bind(this),
|
|
3861
|
-
executeVertoBye: this.executeVertoBye.bind(this)
|
|
3862
|
-
});
|
|
3863
|
-
this.runWorker("wsClientWorker", {
|
|
3864
|
-
worker: wsClientWorker,
|
|
3865
|
-
initialState: {
|
|
3866
|
-
handleIncomingInvite: (invite) => {
|
|
3867
|
-
this._incomingCallManager.handleIncomingInvite(__spreadValues({
|
|
3868
|
-
source: "websocket"
|
|
3869
|
-
}, invite));
|
|
3870
|
-
}
|
|
3871
|
-
}
|
|
3872
|
-
});
|
|
3873
|
-
this.initializeSessionConnectionPool();
|
|
3874
|
-
}
|
|
3875
|
-
makeFabricObject(makeRoomOptions) {
|
|
3876
|
-
const _a = makeRoomOptions, {
|
|
3877
|
-
rootElement,
|
|
3878
|
-
applyLocalVideoOverlay = true,
|
|
3879
|
-
applyMemberOverlay = true,
|
|
3880
|
-
stopCameraWhileMuted = true,
|
|
3881
|
-
stopMicrophoneWhileMuted = true,
|
|
3882
|
-
mirrorLocalVideoOverlay = true
|
|
3883
|
-
} = _a, options = __objRest(_a, [
|
|
3884
|
-
"rootElement",
|
|
3885
|
-
"applyLocalVideoOverlay",
|
|
3886
|
-
"applyMemberOverlay",
|
|
3887
|
-
"stopCameraWhileMuted",
|
|
3888
|
-
"stopMicrophoneWhileMuted",
|
|
3889
|
-
"mirrorLocalVideoOverlay"
|
|
3890
|
-
]);
|
|
3891
|
-
const room = createFabricRoomSessionObject(__spreadProps(__spreadValues({}, options), {
|
|
3892
|
-
store: this.store
|
|
3893
|
-
}));
|
|
3894
|
-
if (rootElement) {
|
|
3895
|
-
try {
|
|
3896
|
-
buildVideoElement({
|
|
3897
|
-
applyLocalVideoOverlay,
|
|
3898
|
-
applyMemberOverlay,
|
|
3899
|
-
mirrorLocalVideoOverlay,
|
|
3900
|
-
room,
|
|
3901
|
-
rootElement
|
|
3902
|
-
});
|
|
3903
|
-
} catch (error) {
|
|
3904
|
-
this.logger.error("Unable to build the video element automatically");
|
|
3905
|
-
}
|
|
3906
|
-
}
|
|
3907
|
-
const joinMutedHandler = (params) => {
|
|
3908
|
-
var _a2;
|
|
3909
|
-
const member = (_a2 = params.room_session.members) == null ? void 0 : _a2.find(
|
|
3910
|
-
(m) => m.member_id === room.memberId
|
|
3911
|
-
);
|
|
3912
|
-
if (member == null ? void 0 : member.audio_muted) {
|
|
3913
|
-
try {
|
|
3914
|
-
room.stopOutboundAudio();
|
|
3915
|
-
} catch (error) {
|
|
3916
|
-
this.logger.error("Error handling audio_muted", error);
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3919
|
-
if (member == null ? void 0 : member.video_muted) {
|
|
3920
|
-
try {
|
|
3921
|
-
room.stopOutboundVideo();
|
|
3922
|
-
} catch (error) {
|
|
3923
|
-
this.logger.error("Error handling video_muted", error);
|
|
3924
|
-
}
|
|
3925
|
-
}
|
|
3926
|
-
};
|
|
3927
|
-
room.on("room.subscribed", joinMutedHandler);
|
|
3928
|
-
if (stopMicrophoneWhileMuted) {
|
|
3929
|
-
room.on("member.updated.audioMuted", ({ member }) => {
|
|
3930
|
-
try {
|
|
3931
|
-
if (member.member_id === room.memberId && "audio_muted" in member) {
|
|
3932
|
-
member.audio_muted ? room.stopOutboundAudio() : room.restoreOutboundAudio();
|
|
3933
|
-
}
|
|
3934
|
-
} catch (error) {
|
|
3935
|
-
this.logger.error("Error handling audio_muted", error);
|
|
3936
|
-
}
|
|
3937
|
-
});
|
|
3938
|
-
}
|
|
3939
|
-
if (stopCameraWhileMuted) {
|
|
3940
|
-
room.on("member.updated.videoMuted", ({ member }) => {
|
|
3941
|
-
try {
|
|
3942
|
-
if (member.member_id === room.memberId && "video_muted" in member) {
|
|
3943
|
-
member.video_muted ? room.stopOutboundVideo() : room.restoreOutboundVideo();
|
|
3944
|
-
}
|
|
3945
|
-
} catch (error) {
|
|
3946
|
-
this.logger.error("Error handling video_muted", error);
|
|
3947
|
-
}
|
|
3948
|
-
});
|
|
3949
|
-
}
|
|
3950
|
-
return room;
|
|
3951
|
-
}
|
|
3952
|
-
buildOutboundCall(params) {
|
|
3953
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3954
|
-
let video = false;
|
|
3955
|
-
let negotiateVideo = false;
|
|
3956
|
-
if (params.to) {
|
|
3957
|
-
const [pathname, query] = params.to.split("?");
|
|
3958
|
-
if (!pathname) {
|
|
3959
|
-
throw new Error("Invalid destination address");
|
|
3960
|
-
}
|
|
3961
|
-
const queryParams = new URLSearchParams(query);
|
|
3962
|
-
const channel = queryParams.get("channel");
|
|
3963
|
-
if (channel === "video") {
|
|
3964
|
-
video = true;
|
|
3965
|
-
negotiateVideo = true;
|
|
3966
|
-
}
|
|
3967
|
-
}
|
|
3968
|
-
const call = this.makeFabricObject({
|
|
3969
|
-
audio: (_a = params.audio) != null ? _a : true,
|
|
3970
|
-
video: (_b = params.video) != null ? _b : video,
|
|
3971
|
-
negotiateAudio: (_c = params.negotiateAudio) != null ? _c : true,
|
|
3972
|
-
negotiateVideo: (_d = params.negotiateVideo) != null ? _d : negotiateVideo,
|
|
3973
|
-
rootElement: params.rootElement || this.wsClientOptions.rootElement,
|
|
3974
|
-
applyLocalVideoOverlay: params.applyLocalVideoOverlay,
|
|
3975
|
-
applyMemberOverlay: params.applyMemberOverlay,
|
|
3976
|
-
stopCameraWhileMuted: params.stopCameraWhileMuted,
|
|
3977
|
-
stopMicrophoneWhileMuted: params.stopMicrophoneWhileMuted,
|
|
3978
|
-
mirrorLocalVideoOverlay: params.mirrorLocalVideoOverlay,
|
|
3979
|
-
watchMediaPackets: false,
|
|
3980
|
-
destinationNumber: (_e = params.to) != null ? _e : "",
|
|
3981
|
-
nodeId: params.nodeId,
|
|
3982
|
-
attach: (_f = params.attach) != null ? _f : false,
|
|
3983
|
-
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
3984
|
-
userVariables: params.userVariables || this.wsClientOptions.userVariables,
|
|
3985
|
-
fromFabricAddressId: params.fromFabricAddressId
|
|
3986
|
-
});
|
|
3987
|
-
call.once("destroy", () => {
|
|
3988
|
-
this.logger.debug("RTC Connection Destroyed");
|
|
3989
|
-
call.destroy();
|
|
3990
|
-
});
|
|
3991
|
-
this.session.once("session.disconnected", () => {
|
|
3992
|
-
this.logger.debug("Session Disconnected");
|
|
3993
|
-
call.destroy();
|
|
3994
|
-
this.destroy();
|
|
3995
|
-
});
|
|
3996
|
-
call.attachPreConnectWorkers();
|
|
3997
|
-
return call;
|
|
3998
|
-
}
|
|
3999
|
-
buildInboundCall(payload, params) {
|
|
4000
|
-
var _a, _b, _c, _d;
|
|
4001
|
-
const call = this.makeFabricObject({
|
|
4002
|
-
audio: (_a = params.audio) != null ? _a : true,
|
|
4003
|
-
video: (_b = params.video) != null ? _b : true,
|
|
4004
|
-
negotiateAudio: (_c = params.negotiateAudio) != null ? _c : true,
|
|
4005
|
-
negotiateVideo: (_d = params.negotiateVideo) != null ? _d : true,
|
|
4006
|
-
rootElement: params.rootElement || this.wsClientOptions.rootElement,
|
|
4007
|
-
applyLocalVideoOverlay: true,
|
|
4008
|
-
applyMemberOverlay: true,
|
|
4009
|
-
stopCameraWhileMuted: true,
|
|
4010
|
-
stopMicrophoneWhileMuted: true,
|
|
4011
|
-
watchMediaPackets: false,
|
|
4012
|
-
nodeId: payload.nodeId,
|
|
4013
|
-
remoteSdp: payload.sdp,
|
|
4014
|
-
prevCallId: payload.callID,
|
|
4015
|
-
disableUdpIceServers: params.disableUdpIceServers || false,
|
|
4016
|
-
userVariables: params.userVariables || this.wsClientOptions.userVariables
|
|
4017
|
-
});
|
|
4018
|
-
call.once("destroy", () => {
|
|
4019
|
-
this.logger.debug("RTC Connection Destroyed");
|
|
4020
|
-
call.destroy();
|
|
4021
|
-
});
|
|
4022
|
-
this.session.once("session.disconnected", () => {
|
|
4023
|
-
this.logger.debug("Session Disconnected");
|
|
4024
|
-
call.destroy();
|
|
4025
|
-
this.destroy();
|
|
4026
|
-
});
|
|
4027
|
-
call.attachPreConnectWorkers();
|
|
4028
|
-
return call;
|
|
4029
|
-
}
|
|
4030
|
-
executeVertoBye(callId, nodeId) {
|
|
4031
|
-
return __async(this, null, function* () {
|
|
4032
|
-
try {
|
|
4033
|
-
return yield this.execute({
|
|
4034
|
-
method: "webrtc.verto",
|
|
4035
|
-
params: {
|
|
4036
|
-
callID: callId,
|
|
4037
|
-
node_id: nodeId,
|
|
4038
|
-
message: (0, import_core42.VertoBye)({
|
|
4039
|
-
cause: "USER_BUSY",
|
|
4040
|
-
causeCode: "17",
|
|
4041
|
-
dialogParams: { callID: callId }
|
|
4042
|
-
})
|
|
4043
|
-
}
|
|
4044
|
-
});
|
|
4045
|
-
} catch (error) {
|
|
4046
|
-
this.logger.warn("The call is not available anymore", callId);
|
|
4047
|
-
throw error;
|
|
4048
|
-
}
|
|
4049
|
-
});
|
|
4050
|
-
}
|
|
4051
|
-
executeVertoSubscribe(callId, nodeId) {
|
|
4052
|
-
return __async(this, null, function* () {
|
|
4053
|
-
try {
|
|
4054
|
-
return yield this.execute({
|
|
4055
|
-
method: "webrtc.verto",
|
|
4056
|
-
params: {
|
|
4057
|
-
callID: callId,
|
|
4058
|
-
node_id: nodeId,
|
|
4059
|
-
subscribe: [],
|
|
4060
|
-
message: (0, import_core42.VertoSubscribe)({
|
|
4061
|
-
sessid: callId,
|
|
4062
|
-
eventChannel: []
|
|
4063
|
-
})
|
|
4064
|
-
}
|
|
4065
|
-
});
|
|
4066
|
-
} catch (error) {
|
|
4067
|
-
this.logger.warn("The call is not available anymore", callId);
|
|
4068
|
-
throw error;
|
|
4069
|
-
}
|
|
4070
|
-
});
|
|
4071
|
-
}
|
|
4072
|
-
disconnect() {
|
|
4073
|
-
return new Promise((resolve, _reject) => {
|
|
4074
|
-
if (this._disconnected) {
|
|
4075
|
-
resolve();
|
|
4076
|
-
}
|
|
4077
|
-
this.session.once("session.disconnected", () => {
|
|
4078
|
-
this.destroy();
|
|
4079
|
-
resolve();
|
|
4080
|
-
this._disconnected = true;
|
|
4081
|
-
});
|
|
4082
|
-
super.disconnect();
|
|
4083
|
-
});
|
|
4084
|
-
}
|
|
4085
|
-
dial(params) {
|
|
4086
|
-
return __async(this, null, function* () {
|
|
4087
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
4088
|
-
var _a;
|
|
4089
|
-
try {
|
|
4090
|
-
(_a = getStorage()) == null ? void 0 : _a.removeItem(PREVIOUS_CALLID_STORAGE_KEY);
|
|
4091
|
-
const call = this.buildOutboundCall(params);
|
|
4092
|
-
resolve(call);
|
|
4093
|
-
} catch (error) {
|
|
4094
|
-
this.logger.error("Unable to connect and dial a call", error);
|
|
4095
|
-
reject(error);
|
|
4096
|
-
}
|
|
4097
|
-
}));
|
|
4098
|
-
});
|
|
4099
|
-
}
|
|
4100
|
-
reattach(params) {
|
|
4101
|
-
return __async(this, null, function* () {
|
|
4102
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
4103
|
-
try {
|
|
4104
|
-
const call = this.buildOutboundCall(__spreadProps(__spreadValues({}, params), { attach: true }));
|
|
4105
|
-
resolve(call);
|
|
4106
|
-
} catch (error) {
|
|
4107
|
-
this.logger.error("Unable to connect and reattach a call", error);
|
|
4108
|
-
reject(error);
|
|
4109
|
-
}
|
|
4110
|
-
}));
|
|
4111
|
-
});
|
|
4112
|
-
}
|
|
4113
|
-
handlePushNotification(params) {
|
|
4114
|
-
const { incomingCallHandler } = params;
|
|
4115
|
-
this._incomingCallManager.setNotificationHandlers({
|
|
4116
|
-
pushNotification: incomingCallHandler
|
|
4117
|
-
});
|
|
4118
|
-
return new Promise(
|
|
4119
|
-
(resolve, reject) => __async(this, null, function* () {
|
|
4120
|
-
const { decrypted, type } = params;
|
|
4121
|
-
if (type !== "call_invite") {
|
|
4122
|
-
this.logger.warn("Unknown notification type", params);
|
|
4123
|
-
reject("Unknown notification type");
|
|
4124
|
-
}
|
|
4125
|
-
this.logger.debug("handlePushNotification", params);
|
|
4126
|
-
const {
|
|
4127
|
-
params: { params: payload },
|
|
4128
|
-
node_id: nodeId
|
|
4129
|
-
} = decrypted;
|
|
4130
|
-
try {
|
|
4131
|
-
try {
|
|
4132
|
-
yield this.executeVertoSubscribe(payload.callID, nodeId);
|
|
4133
|
-
} catch (error) {
|
|
4134
|
-
this.logger.warn("Verto Subscribe", error);
|
|
4135
|
-
}
|
|
4136
|
-
this._incomingCallManager.handleIncomingInvite(__spreadValues({
|
|
4137
|
-
source: "pushNotification",
|
|
4138
|
-
nodeId
|
|
4139
|
-
}, payload));
|
|
4140
|
-
resolve({ resultType: "inboundCall" });
|
|
4141
|
-
} catch (error) {
|
|
4142
|
-
reject(error);
|
|
4143
|
-
}
|
|
4144
|
-
})
|
|
4145
|
-
);
|
|
4146
|
-
}
|
|
4147
|
-
updateToken(token) {
|
|
4148
|
-
return new Promise((resolve, reject) => {
|
|
4149
|
-
this.session.once("session.auth_error", (error) => {
|
|
4150
|
-
reject(error);
|
|
4151
|
-
});
|
|
4152
|
-
this.session.once("session.connected", () => {
|
|
4153
|
-
resolve();
|
|
4154
|
-
});
|
|
4155
|
-
this.store.dispatch(import_core42.actions.reauthAction({ token }));
|
|
4156
|
-
});
|
|
4157
|
-
}
|
|
4158
|
-
/**
|
|
4159
|
-
* Mark the client as 'online' to receive calls over WebSocket
|
|
4160
|
-
*/
|
|
4161
|
-
online(_0) {
|
|
4162
|
-
return __async(this, arguments, function* ({ incomingCallHandlers }) {
|
|
4163
|
-
if (incomingCallHandlers.all || incomingCallHandlers.pushNotification) {
|
|
4164
|
-
this.logger.warn(
|
|
4165
|
-
`Make sure the device is not registered to receive Push Notifications while it is online`
|
|
4166
|
-
);
|
|
4167
|
-
}
|
|
4168
|
-
this._incomingCallManager.setNotificationHandlers(incomingCallHandlers);
|
|
4169
|
-
return this.execute({
|
|
4170
|
-
method: "subscriber.online",
|
|
4171
|
-
params: {}
|
|
4172
|
-
});
|
|
4173
|
-
});
|
|
4174
|
-
}
|
|
4175
|
-
/**
|
|
4176
|
-
* Mark the client as 'offline' to receive calls over WebSocket
|
|
4177
|
-
*/
|
|
4178
|
-
offline() {
|
|
4179
|
-
this._incomingCallManager.setNotificationHandlers({});
|
|
4180
|
-
return this.execute({
|
|
4181
|
-
method: "subscriber.offline",
|
|
4182
|
-
params: {}
|
|
4183
|
-
});
|
|
4184
|
-
}
|
|
4185
|
-
/**
|
|
4186
|
-
* Initialize the session-level connection pool
|
|
4187
|
-
*/
|
|
4188
|
-
initializeSessionConnectionPool() {
|
|
4189
|
-
this.runWorker("sessionConnectionPoolWorker", {
|
|
4190
|
-
worker: import_webrtc5.sessionConnectionPoolWorker,
|
|
4191
|
-
initialState: {
|
|
4192
|
-
poolSize: 1,
|
|
4193
|
-
// Only one connection per session is required
|
|
4194
|
-
iceCandidatePoolSize: 10
|
|
4195
|
-
}
|
|
4196
|
-
});
|
|
4197
|
-
}
|
|
4198
|
-
};
|
|
4199
|
-
|
|
4200
|
-
// src/fabric/SignalWire.ts
|
|
4201
|
-
var SignalWire = /* @__PURE__ */ (() => {
|
|
4202
|
-
let instance = null;
|
|
4203
|
-
return (params) => {
|
|
4204
|
-
if (!instance) {
|
|
4205
|
-
instance = new Promise((resolve, reject) => __async(void 0, null, function* () {
|
|
4206
|
-
try {
|
|
4207
|
-
const options = __spreadValues({
|
|
4208
|
-
maxApiRequestRetries: DEFAULT_API_REQUEST_RETRIES,
|
|
4209
|
-
apiRequestRetriesDelay: DEFAULT_API_REQUEST_RETRIES_DELAY,
|
|
4210
|
-
apiRequestRetriesDelayIncrement: DEFAULT_API_REQUEST_RETRIES_DELAY_INCREMENT
|
|
4211
|
-
}, params);
|
|
4212
|
-
const wsClient = new WSClient(options);
|
|
4213
|
-
const httpClient = new HTTPClient(options);
|
|
4214
|
-
const conversationError = (method) => {
|
|
4215
|
-
return () => {
|
|
4216
|
-
throw new Error(
|
|
4217
|
-
`This version Conversation.${method} is unsupported by the backend. Use @signalwire/client instead.`
|
|
4218
|
-
);
|
|
4219
|
-
};
|
|
4220
|
-
};
|
|
4221
|
-
yield wsClient.connect();
|
|
4222
|
-
resolve({
|
|
4223
|
-
registerDevice: httpClient.registerDevice.bind(httpClient),
|
|
4224
|
-
unregisterDevice: httpClient.unregisterDevice.bind(httpClient),
|
|
4225
|
-
getSubscriberInfo: httpClient.getSubscriberInfo.bind(httpClient),
|
|
4226
|
-
disconnect: () => __async(void 0, null, function* () {
|
|
4227
|
-
yield wsClient.disconnect();
|
|
4228
|
-
instance = null;
|
|
4229
|
-
}),
|
|
4230
|
-
online: wsClient.online.bind(wsClient),
|
|
4231
|
-
offline: wsClient.offline.bind(wsClient),
|
|
4232
|
-
dial: wsClient.dial.bind(wsClient),
|
|
4233
|
-
reattach: wsClient.reattach.bind(wsClient),
|
|
4234
|
-
handlePushNotification: wsClient.handlePushNotification.bind(wsClient),
|
|
4235
|
-
updateToken: wsClient.updateToken.bind(wsClient),
|
|
4236
|
-
address: {
|
|
4237
|
-
getAddresses: httpClient.getAddresses.bind(httpClient),
|
|
4238
|
-
getAddress: httpClient.getAddress.bind(httpClient)
|
|
4239
|
-
},
|
|
4240
|
-
conversation: {
|
|
4241
|
-
getConversations: conversationError(
|
|
4242
|
-
"getConversations"
|
|
4243
|
-
),
|
|
4244
|
-
getMessages: conversationError(
|
|
4245
|
-
"getMessages"
|
|
4246
|
-
),
|
|
4247
|
-
getConversationMessages: conversationError(
|
|
4248
|
-
"getConversationMessages"
|
|
4249
|
-
),
|
|
4250
|
-
subscribe: conversationError(
|
|
4251
|
-
"subscribe"
|
|
4252
|
-
),
|
|
4253
|
-
sendMessage: conversationError(
|
|
4254
|
-
"sendMessage"
|
|
4255
|
-
),
|
|
4256
|
-
join: conversationError(
|
|
4257
|
-
"join"
|
|
4258
|
-
)
|
|
4259
|
-
},
|
|
4260
|
-
chat: {
|
|
4261
|
-
getMessages: conversationError(
|
|
4262
|
-
"getMessages"
|
|
4263
|
-
),
|
|
4264
|
-
subscribe: conversationError(
|
|
4265
|
-
"subscribe"
|
|
4266
|
-
),
|
|
4267
|
-
sendMessage: conversationError(
|
|
4268
|
-
"sendMessage"
|
|
4269
|
-
),
|
|
4270
|
-
join: conversationError(
|
|
4271
|
-
"join"
|
|
4272
|
-
)
|
|
4273
|
-
},
|
|
4274
|
-
// @ts-expect-error For debugging purposes
|
|
4275
|
-
on: wsClient.on.bind(wsClient),
|
|
4276
|
-
off: wsClient.off.bind(wsClient),
|
|
4277
|
-
__httpClient: httpClient,
|
|
4278
|
-
__wsClient: wsClient
|
|
4279
|
-
});
|
|
4280
|
-
} catch (error) {
|
|
4281
|
-
reject(error);
|
|
4282
|
-
}
|
|
4283
|
-
})).catch((error) => {
|
|
4284
|
-
instance = null;
|
|
4285
|
-
throw error;
|
|
4286
|
-
});
|
|
4287
|
-
}
|
|
4288
|
-
return instance;
|
|
4289
|
-
};
|
|
4290
|
-
})();
|
|
4291
|
-
|
|
4292
|
-
// src/video/index.ts
|
|
4293
|
-
var video_exports = {};
|
|
4294
|
-
__export(video_exports, {
|
|
4295
|
-
RoomSession: () => RoomSession,
|
|
4296
|
-
createClient: () => createClient,
|
|
4297
|
-
createRoomObject: () => createRoomObject,
|
|
4298
|
-
isVideoRoomSession: () => isVideoRoomSession,
|
|
4299
|
-
joinRoom: () => joinRoom
|
|
4300
|
-
});
|
|
4301
|
-
|
|
4302
|
-
// src/createRoomObject.ts
|
|
4303
|
-
var import_core43 = require("@signalwire/core");
|
|
4304
|
-
var VIDEO_CONSTRAINTS = {
|
|
4305
|
-
aspectRatio: { ideal: 16 / 9 }
|
|
4306
|
-
};
|
|
4307
|
-
var createRoomObject = (roomOptions) => {
|
|
4308
|
-
return new Promise((resolve, reject) => __async(void 0, null, function* () {
|
|
4309
|
-
const _a = roomOptions, {
|
|
4310
|
-
audio = true,
|
|
4311
|
-
video = true,
|
|
4312
|
-
iceServers,
|
|
4313
|
-
rootElementId,
|
|
4314
|
-
applyLocalVideoOverlay = true,
|
|
4315
|
-
autoJoin = false,
|
|
4316
|
-
stopCameraWhileMuted = true,
|
|
4317
|
-
stopMicrophoneWhileMuted = true,
|
|
4318
|
-
speakerId
|
|
4319
|
-
} = _a, userOptions = __objRest(_a, [
|
|
4320
|
-
"audio",
|
|
4321
|
-
"video",
|
|
4322
|
-
"iceServers",
|
|
4323
|
-
"rootElementId",
|
|
4324
|
-
"applyLocalVideoOverlay",
|
|
4325
|
-
"autoJoin",
|
|
4326
|
-
"stopCameraWhileMuted",
|
|
4327
|
-
"stopMicrophoneWhileMuted",
|
|
4328
|
-
"speakerId"
|
|
4329
|
-
]);
|
|
4330
|
-
const client = createClient(__spreadValues({}, userOptions));
|
|
4331
|
-
yield client.connect();
|
|
4332
|
-
if (!client) {
|
|
4333
|
-
return;
|
|
4334
|
-
}
|
|
4335
|
-
let rootElement;
|
|
4336
|
-
if (rootElementId) {
|
|
4337
|
-
const el = document.getElementById(rootElementId);
|
|
4338
|
-
if (el) {
|
|
4339
|
-
rootElement = el;
|
|
4340
|
-
} else {
|
|
4341
|
-
rootElement = document.body;
|
|
4342
|
-
(0, import_core43.getLogger)().warn(
|
|
4343
|
-
`We couldn't find an element with id: ${rootElementId}: using 'document.body' instead.`
|
|
4344
|
-
);
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
const roomObject = client.rooms.makeRoomObject({
|
|
4348
|
-
audio,
|
|
4349
|
-
video: video === true ? VIDEO_CONSTRAINTS : video,
|
|
4350
|
-
negotiateAudio: true,
|
|
4351
|
-
negotiateVideo: true,
|
|
4352
|
-
iceServers,
|
|
4353
|
-
rootElement,
|
|
4354
|
-
applyLocalVideoOverlay,
|
|
4355
|
-
stopCameraWhileMuted,
|
|
4356
|
-
stopMicrophoneWhileMuted,
|
|
4357
|
-
speakerId
|
|
4358
|
-
});
|
|
4359
|
-
roomObject.once("destroy", () => {
|
|
4360
|
-
roomObject.emit("room.left");
|
|
4361
|
-
client.disconnect();
|
|
4362
|
-
});
|
|
4363
|
-
const join = () => {
|
|
4364
|
-
return new Promise((resolve2, reject2) => __async(void 0, null, function* () {
|
|
4365
|
-
try {
|
|
4366
|
-
roomObject.once("room.subscribed", (_payload) => {
|
|
4367
|
-
resolve2(roomObject);
|
|
4368
|
-
});
|
|
4369
|
-
yield roomObject.join();
|
|
4370
|
-
} catch (error) {
|
|
4371
|
-
(0, import_core43.getLogger)().error("Join", error);
|
|
4372
|
-
client.disconnect();
|
|
4373
|
-
reject2(error);
|
|
4374
|
-
}
|
|
4375
|
-
}));
|
|
4376
|
-
};
|
|
4377
|
-
const room = new Proxy(roomObject, {
|
|
4378
|
-
get(target, prop, receiver) {
|
|
4379
|
-
if (prop === "join") {
|
|
4380
|
-
return join;
|
|
4381
|
-
}
|
|
4382
|
-
return Reflect.get(target, prop, receiver);
|
|
4383
|
-
}
|
|
4384
|
-
});
|
|
4385
|
-
if (autoJoin) {
|
|
4386
|
-
try {
|
|
4387
|
-
yield room.join();
|
|
4388
|
-
resolve(room);
|
|
4389
|
-
} catch (error) {
|
|
4390
|
-
reject(error);
|
|
4391
|
-
}
|
|
4392
|
-
} else {
|
|
4393
|
-
resolve(room);
|
|
4394
|
-
}
|
|
4395
|
-
}));
|
|
4396
|
-
};
|
|
4397
|
-
|
|
4398
|
-
// src/joinRoom.ts
|
|
4399
|
-
var joinRoom = (roomOptions) => {
|
|
4400
|
-
return createRoomObject(__spreadProps(__spreadValues({}, roomOptions), {
|
|
4401
|
-
autoJoin: true
|
|
4402
|
-
}));
|
|
4403
|
-
};
|
|
4404
|
-
|
|
4405
|
-
// src/video/RoomSession.ts
|
|
4406
|
-
var import_core44 = require("@signalwire/core");
|
|
4407
|
-
var UNSAFE_PROP_ACCESS = [
|
|
4408
|
-
"audioMute",
|
|
4409
|
-
"audioUnmute",
|
|
4410
|
-
"deaf",
|
|
4411
|
-
"getLayouts",
|
|
4412
|
-
"getMembers",
|
|
4413
|
-
"getRecordings",
|
|
4414
|
-
"hideVideoMuted",
|
|
4415
|
-
"leave",
|
|
4416
|
-
"removerMember",
|
|
4417
|
-
"restoreOutboundAudio",
|
|
4418
|
-
"restoreOutboundVideo",
|
|
4419
|
-
"setInputSensitivity",
|
|
4420
|
-
"setInputVolume",
|
|
4421
|
-
"setLayout",
|
|
4422
|
-
"setPositions",
|
|
4423
|
-
"setMemberPosition",
|
|
4424
|
-
"setOutputVolume",
|
|
4425
|
-
"showVideoMuted",
|
|
4426
|
-
"startRecording",
|
|
4427
|
-
"stopOutboundAudio",
|
|
4428
|
-
"stopOutboundVideo",
|
|
4429
|
-
"undeaf",
|
|
4430
|
-
"videoMute",
|
|
4431
|
-
"videoUnmute",
|
|
4432
|
-
"setMicrophoneVolume",
|
|
4433
|
-
"setSpeakerVolume",
|
|
4434
|
-
"getMeta",
|
|
4435
|
-
"setMeta",
|
|
4436
|
-
"updateMeta",
|
|
4437
|
-
"deleteMeta",
|
|
4438
|
-
"getMemberMeta",
|
|
4439
|
-
"setMemberMeta",
|
|
4440
|
-
"updateMemberMeta",
|
|
4441
|
-
"deleteMemberMeta",
|
|
4442
|
-
"promote",
|
|
4443
|
-
"demote",
|
|
4444
|
-
"lock",
|
|
4445
|
-
"unlock"
|
|
4446
|
-
];
|
|
4447
|
-
var REQUIRED_EVENTS = [
|
|
4448
|
-
"member.joined",
|
|
4449
|
-
"layout.changed"
|
|
4450
|
-
];
|
|
4451
|
-
var noop2 = () => {
|
|
4452
|
-
};
|
|
4453
|
-
var RoomSession = function(roomOptions) {
|
|
4454
|
-
const _a = roomOptions, {
|
|
4455
|
-
audio: audioFromConstructor = true,
|
|
4456
|
-
video: videoFromConstructor = true,
|
|
4457
|
-
iceServers,
|
|
4458
|
-
rootElement,
|
|
4459
|
-
applyLocalVideoOverlay = true,
|
|
4460
|
-
mirrorLocalVideoOverlay = false,
|
|
4461
|
-
stopCameraWhileMuted = true,
|
|
4462
|
-
stopMicrophoneWhileMuted = true,
|
|
4463
|
-
speakerId,
|
|
4464
|
-
destinationNumber,
|
|
4465
|
-
localStream,
|
|
4466
|
-
watchMediaPackets,
|
|
4467
|
-
watchMediaPacketsTimeout,
|
|
4468
|
-
disableUdpIceServers = false
|
|
4469
|
-
} = _a, userOptions = __objRest(_a, [
|
|
4470
|
-
"audio",
|
|
4471
|
-
"video",
|
|
4472
|
-
"iceServers",
|
|
4473
|
-
"rootElement",
|
|
4474
|
-
"applyLocalVideoOverlay",
|
|
4475
|
-
"mirrorLocalVideoOverlay",
|
|
4476
|
-
"stopCameraWhileMuted",
|
|
4477
|
-
"stopMicrophoneWhileMuted",
|
|
4478
|
-
"speakerId",
|
|
4479
|
-
"destinationNumber",
|
|
4480
|
-
"localStream",
|
|
4481
|
-
"watchMediaPackets",
|
|
4482
|
-
"watchMediaPacketsTimeout",
|
|
4483
|
-
"disableUdpIceServers"
|
|
4484
|
-
]);
|
|
4485
|
-
const deprecatedParams = ["audio", "video"];
|
|
4486
|
-
deprecatedParams.forEach((param) => {
|
|
4487
|
-
if (param in roomOptions) {
|
|
4488
|
-
(0, import_core44.getLogger)().warn(
|
|
4489
|
-
`The '${param}' parameter on the RoomSession constructor is deprecated. Set it on the '.join()' function instead.`
|
|
4490
|
-
);
|
|
4491
|
-
}
|
|
4492
|
-
});
|
|
4493
|
-
const allowReattach = (roomOptions == null ? void 0 : roomOptions.reattach) !== false;
|
|
4494
|
-
const { callIdKey } = sessionStorageManager(userOptions.token);
|
|
4495
|
-
const reattachManager = {
|
|
4496
|
-
joined: ({ call_id }) => {
|
|
4497
|
-
var _a2;
|
|
4498
|
-
if (allowReattach && callIdKey) {
|
|
4499
|
-
(_a2 = getStorage()) == null ? void 0 : _a2.setItem(callIdKey, call_id);
|
|
4500
|
-
}
|
|
4501
|
-
},
|
|
4502
|
-
init: () => {
|
|
4503
|
-
if (allowReattach) {
|
|
4504
|
-
room.on("room.subscribed", reattachManager.joined);
|
|
4505
|
-
}
|
|
4506
|
-
room.options.prevCallId = reattachManager.getPrevCallId();
|
|
4507
|
-
},
|
|
4508
|
-
destroy: () => {
|
|
4509
|
-
var _a2;
|
|
4510
|
-
if (!allowReattach) {
|
|
4511
|
-
return;
|
|
4512
|
-
}
|
|
4513
|
-
room.off("room.subscribed", reattachManager.joined);
|
|
4514
|
-
if (callIdKey) {
|
|
4515
|
-
(_a2 = getStorage()) == null ? void 0 : _a2.removeItem(callIdKey);
|
|
4516
|
-
}
|
|
4517
|
-
},
|
|
4518
|
-
getPrevCallId: () => {
|
|
4519
|
-
var _a2, _b;
|
|
4520
|
-
if (!allowReattach || !callIdKey) {
|
|
4521
|
-
return;
|
|
4522
|
-
}
|
|
4523
|
-
return (_b = (_a2 = getStorage()) == null ? void 0 : _a2.getItem(callIdKey)) != null ? _b : void 0;
|
|
4524
|
-
}
|
|
4525
|
-
};
|
|
4526
|
-
const client = createClient(userOptions);
|
|
4527
|
-
const room = client.rooms.makeRoomObject({
|
|
4528
|
-
// audio,
|
|
4529
|
-
// video: video === true ? VIDEO_CONSTRAINTS : video,
|
|
4530
|
-
negotiateAudio: true,
|
|
4531
|
-
negotiateVideo: true,
|
|
4532
|
-
iceServers,
|
|
4533
|
-
rootElement,
|
|
4534
|
-
applyLocalVideoOverlay,
|
|
4535
|
-
mirrorLocalVideoOverlay,
|
|
4536
|
-
stopCameraWhileMuted,
|
|
4537
|
-
stopMicrophoneWhileMuted,
|
|
4538
|
-
speakerId,
|
|
4539
|
-
destinationNumber,
|
|
4540
|
-
localStream,
|
|
4541
|
-
watchMediaPackets,
|
|
4542
|
-
watchMediaPacketsTimeout,
|
|
4543
|
-
prevCallId: reattachManager.getPrevCallId(),
|
|
4544
|
-
disableUdpIceServers
|
|
4545
|
-
});
|
|
4546
|
-
room.once("destroy", () => {
|
|
4547
|
-
room.emit("room.left", { reason: room.leaveReason });
|
|
4548
|
-
reattachManager.destroy();
|
|
4549
|
-
client.disconnect();
|
|
4550
|
-
});
|
|
4551
|
-
client.session.once("session.disconnected", () => {
|
|
4552
|
-
room.destroy();
|
|
4553
|
-
});
|
|
4554
|
-
const join = (params) => {
|
|
4555
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
4556
|
-
var _a2, _b;
|
|
4557
|
-
try {
|
|
4558
|
-
room.attachPreConnectWorkers();
|
|
4559
|
-
yield client.connect();
|
|
4560
|
-
const audio = (_a2 = params == null ? void 0 : params.audio) != null ? _a2 : audioFromConstructor;
|
|
4561
|
-
const video = (_b = params == null ? void 0 : params.video) != null ? _b : videoFromConstructor;
|
|
4562
|
-
const authorization = client._sessionAuthorization;
|
|
4563
|
-
(0, import_core44.getLogger)().debug("getJoinMediaParams authorization?", authorization);
|
|
4564
|
-
if (authorization && authorization.type === "video") {
|
|
4565
|
-
const mediaOptions = getJoinMediaParams(__spreadValues({
|
|
4566
|
-
authorization,
|
|
4567
|
-
// constructor values override the send
|
|
4568
|
-
sendAudio: Boolean(audio),
|
|
4569
|
-
sendVideo: Boolean(video)
|
|
4570
|
-
}, params));
|
|
4571
|
-
if (!checkMediaParams(mediaOptions)) {
|
|
4572
|
-
client.disconnect();
|
|
4573
|
-
return reject(
|
|
4574
|
-
new Error(
|
|
4575
|
-
`Invalid arguments to join the room. The token used has join_as: '${authorization.join_as}'.
|
|
4576
|
-
${JSON.stringify(params, null, 2)}
|
|
4577
|
-
`
|
|
4578
|
-
)
|
|
4579
|
-
);
|
|
4580
|
-
}
|
|
4581
|
-
(0, import_core44.getLogger)().debug("Set mediaOptions", mediaOptions);
|
|
4582
|
-
room.updateMediaOptions({
|
|
4583
|
-
audio: mediaOptions.mustSendAudio ? audio || true : false,
|
|
4584
|
-
video: mediaOptions.mustSendVideo ? video || true : false,
|
|
4585
|
-
negotiateAudio: mediaOptions.mustRecvAudio,
|
|
4586
|
-
negotiateVideo: mediaOptions.mustRecvVideo
|
|
4587
|
-
});
|
|
4588
|
-
}
|
|
4589
|
-
room.once("room.subscribed", () => {
|
|
4590
|
-
resolve(room);
|
|
4591
|
-
});
|
|
4592
|
-
reattachManager.init();
|
|
4593
|
-
REQUIRED_EVENTS.forEach((event) => room.once(event, noop2));
|
|
4594
|
-
yield room.join();
|
|
4595
|
-
} catch (error) {
|
|
4596
|
-
(0, import_core44.getLogger)().error("RoomSession Join", error);
|
|
4597
|
-
client.disconnect();
|
|
4598
|
-
reject(error);
|
|
4599
|
-
}
|
|
4600
|
-
}));
|
|
4601
|
-
};
|
|
4602
|
-
const interceptors = {
|
|
4603
|
-
join
|
|
4604
|
-
};
|
|
4605
|
-
return new Proxy(room, {
|
|
4606
|
-
get(target, prop, receiver) {
|
|
4607
|
-
if (prop in interceptors) {
|
|
4608
|
-
return interceptors[prop];
|
|
4609
|
-
}
|
|
4610
|
-
if (!target.active && UNSAFE_PROP_ACCESS.includes(prop)) {
|
|
4611
|
-
throw new Error(
|
|
4612
|
-
`Tried to access the property/method "${prop}" before the room was connected. Please call roomSession.join() first.`
|
|
4613
|
-
);
|
|
4614
|
-
}
|
|
4615
|
-
return Reflect.get(target, prop, receiver);
|
|
4616
|
-
}
|
|
4617
|
-
});
|
|
4618
|
-
};
|
|
4619
|
-
|
|
4620
|
-
// src/webrtc.ts
|
|
4621
|
-
var webrtc_exports = {};
|
|
4622
|
-
__export(webrtc_exports, {
|
|
4623
|
-
checkCameraPermissions: () => import_webrtc6.checkCameraPermissions,
|
|
4624
|
-
checkMicrophonePermissions: () => import_webrtc6.checkMicrophonePermissions,
|
|
4625
|
-
checkPermissions: () => import_webrtc6.checkPermissions,
|
|
4626
|
-
checkSpeakerPermissions: () => import_webrtc6.checkSpeakerPermissions,
|
|
4627
|
-
createCameraDeviceWatcher: () => import_webrtc6.createCameraDeviceWatcher,
|
|
4628
|
-
createDeviceWatcher: () => import_webrtc6.createDeviceWatcher,
|
|
4629
|
-
createMicrophoneAnalyzer: () => import_webrtc6.createMicrophoneAnalyzer,
|
|
4630
|
-
createMicrophoneDeviceWatcher: () => import_webrtc6.createMicrophoneDeviceWatcher,
|
|
4631
|
-
createSpeakerDeviceWatcher: () => import_webrtc6.createSpeakerDeviceWatcher,
|
|
4632
|
-
enumerateDevices: () => import_webrtc6.enumerateDevices,
|
|
4633
|
-
enumerateDevicesByKind: () => import_webrtc6.enumerateDevicesByKind,
|
|
4634
|
-
getCameraDevices: () => import_webrtc6.getCameraDevices,
|
|
4635
|
-
getCameraDevicesWithPermissions: () => import_webrtc6.getCameraDevicesWithPermissions,
|
|
4636
|
-
getDevices: () => import_webrtc6.getDevices,
|
|
4637
|
-
getDevicesWithPermissions: () => import_webrtc6.getDevicesWithPermissions,
|
|
4638
|
-
getDisplayMedia: () => import_webrtc6.getDisplayMedia,
|
|
4639
|
-
getMicrophoneDevices: () => import_webrtc6.getMicrophoneDevices,
|
|
4640
|
-
getMicrophoneDevicesWithPermissions: () => import_webrtc6.getMicrophoneDevicesWithPermissions,
|
|
4641
|
-
getSpeakerDevices: () => import_webrtc6.getSpeakerDevices,
|
|
4642
|
-
getSpeakerDevicesWithPermissions: () => import_webrtc6.getSpeakerDevicesWithPermissions,
|
|
4643
|
-
getSupportedConstraints: () => import_webrtc6.getSupportedConstraints,
|
|
4644
|
-
getUserMedia: () => import_webrtc6.getUserMedia,
|
|
4645
|
-
requestPermissions: () => import_webrtc6.requestPermissions,
|
|
4646
|
-
setMediaElementSinkId: () => import_webrtc6.setMediaElementSinkId,
|
|
4647
|
-
stopStream: () => import_webrtc6.stopStream,
|
|
4648
|
-
stopTrack: () => import_webrtc6.stopTrack,
|
|
4649
|
-
supportsGetDisplayMedia: () => import_webrtc6.supportsGetDisplayMedia,
|
|
4650
|
-
supportsGetUserMedia: () => import_webrtc6.supportsGetUserMedia,
|
|
4651
|
-
supportsMediaDevices: () => import_webrtc6.supportsMediaDevices,
|
|
4652
|
-
supportsMediaOutput: () => import_webrtc6.supportsMediaOutput
|
|
4653
|
-
});
|
|
4654
|
-
var import_webrtc6 = require("@signalwire/webrtc");
|
|
4655
|
-
//# sourceMappingURL=index.js.map
|