@werxt/livekit-components-react 2.9.20
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/LICENSE +201 -0
- package/README.md +36 -0
- package/dist/assets/icons/CameraDisabledIcon.d.ts +11 -0
- package/dist/assets/icons/CameraDisabledIcon.d.ts.map +1 -0
- package/dist/assets/icons/CameraIcon.d.ts +11 -0
- package/dist/assets/icons/CameraIcon.d.ts.map +1 -0
- package/dist/assets/icons/ChatCloseIcon.d.ts +11 -0
- package/dist/assets/icons/ChatCloseIcon.d.ts.map +1 -0
- package/dist/assets/icons/ChatIcon.d.ts +11 -0
- package/dist/assets/icons/ChatIcon.d.ts.map +1 -0
- package/dist/assets/icons/Chevron.d.ts +11 -0
- package/dist/assets/icons/Chevron.d.ts.map +1 -0
- package/dist/assets/icons/FocusToggleIcon.d.ts +11 -0
- package/dist/assets/icons/FocusToggleIcon.d.ts.map +1 -0
- package/dist/assets/icons/GearIcon.d.ts +11 -0
- package/dist/assets/icons/GearIcon.d.ts.map +1 -0
- package/dist/assets/icons/LeaveIcon.d.ts +11 -0
- package/dist/assets/icons/LeaveIcon.d.ts.map +1 -0
- package/dist/assets/icons/LockLockedIcon.d.ts +11 -0
- package/dist/assets/icons/LockLockedIcon.d.ts.map +1 -0
- package/dist/assets/icons/MicDisabledIcon.d.ts +11 -0
- package/dist/assets/icons/MicDisabledIcon.d.ts.map +1 -0
- package/dist/assets/icons/MicIcon.d.ts +11 -0
- package/dist/assets/icons/MicIcon.d.ts.map +1 -0
- package/dist/assets/icons/QualityExcellentIcon.d.ts +11 -0
- package/dist/assets/icons/QualityExcellentIcon.d.ts.map +1 -0
- package/dist/assets/icons/QualityGoodIcon.d.ts +11 -0
- package/dist/assets/icons/QualityGoodIcon.d.ts.map +1 -0
- package/dist/assets/icons/QualityPoorIcon.d.ts +11 -0
- package/dist/assets/icons/QualityPoorIcon.d.ts.map +1 -0
- package/dist/assets/icons/QualityUnknownIcon.d.ts +11 -0
- package/dist/assets/icons/QualityUnknownIcon.d.ts.map +1 -0
- package/dist/assets/icons/ScreenShareIcon.d.ts +11 -0
- package/dist/assets/icons/ScreenShareIcon.d.ts.map +1 -0
- package/dist/assets/icons/ScreenShareStopIcon.d.ts +11 -0
- package/dist/assets/icons/ScreenShareStopIcon.d.ts.map +1 -0
- package/dist/assets/icons/SpinnerIcon.d.ts +11 -0
- package/dist/assets/icons/SpinnerIcon.d.ts.map +1 -0
- package/dist/assets/icons/UnfocusToggleIcon.d.ts +11 -0
- package/dist/assets/icons/UnfocusToggleIcon.d.ts.map +1 -0
- package/dist/assets/icons/index.d.ts +20 -0
- package/dist/assets/icons/index.d.ts.map +1 -0
- package/dist/assets/icons/util.d.ts +11 -0
- package/dist/assets/icons/util.d.ts.map +1 -0
- package/dist/assets/images/ParticipantPlaceholder.d.ts +11 -0
- package/dist/assets/images/ParticipantPlaceholder.d.ts.map +1 -0
- package/dist/assets/images/index.d.ts +2 -0
- package/dist/assets/images/index.d.ts.map +1 -0
- package/dist/components/ChatEntry.d.ts +35 -0
- package/dist/components/ChatEntry.d.ts.map +1 -0
- package/dist/components/ConnectionState.d.ts +23 -0
- package/dist/components/ConnectionState.d.ts.map +1 -0
- package/dist/components/ConnectionStateToast.d.ts +13 -0
- package/dist/components/ConnectionStateToast.d.ts.map +1 -0
- package/dist/components/LiveKitRoom.d.ts +92 -0
- package/dist/components/LiveKitRoom.d.ts.map +1 -0
- package/dist/components/ParticipantLoop.d.ts +28 -0
- package/dist/components/ParticipantLoop.d.ts.map +1 -0
- package/dist/components/RoomAudioRenderer.d.ts +29 -0
- package/dist/components/RoomAudioRenderer.d.ts.map +1 -0
- package/dist/components/RoomName.d.ts +20 -0
- package/dist/components/RoomName.d.ts.map +1 -0
- package/dist/components/SessionProvider.d.ts +13 -0
- package/dist/components/SessionProvider.d.ts.map +1 -0
- package/dist/components/Toast.d.ts +14 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/TrackLoop.d.ts +26 -0
- package/dist/components/TrackLoop.d.ts.map +1 -0
- package/dist/components/controls/ChatToggle.d.ts +19 -0
- package/dist/components/controls/ChatToggle.d.ts.map +1 -0
- package/dist/components/controls/ClearPinButton.d.ts +20 -0
- package/dist/components/controls/ClearPinButton.d.ts.map +1 -0
- package/dist/components/controls/DisconnectButton.d.ts +19 -0
- package/dist/components/controls/DisconnectButton.d.ts.map +1 -0
- package/dist/components/controls/FocusToggle.d.ts +21 -0
- package/dist/components/controls/FocusToggle.d.ts.map +1 -0
- package/dist/components/controls/MediaDeviceSelect.d.ts +40 -0
- package/dist/components/controls/MediaDeviceSelect.d.ts.map +1 -0
- package/dist/components/controls/PaginationControl.d.ts +9 -0
- package/dist/components/controls/PaginationControl.d.ts.map +1 -0
- package/dist/components/controls/PaginationIndicator.d.ts +7 -0
- package/dist/components/controls/PaginationIndicator.d.ts.map +1 -0
- package/dist/components/controls/SettingsMenuToggle.d.ts +13 -0
- package/dist/components/controls/SettingsMenuToggle.d.ts.map +1 -0
- package/dist/components/controls/StartAudio.d.ts +24 -0
- package/dist/components/controls/StartAudio.d.ts.map +1 -0
- package/dist/components/controls/StartMediaButton.d.ts +22 -0
- package/dist/components/controls/StartMediaButton.d.ts.map +1 -0
- package/dist/components/controls/TrackToggle.d.ts +32 -0
- package/dist/components/controls/TrackToggle.d.ts.map +1 -0
- package/dist/components/index.d.ts +30 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/layout/CarouselLayout.d.ts +27 -0
- package/dist/components/layout/CarouselLayout.d.ts.map +1 -0
- package/dist/components/layout/FocusLayout.d.ts +25 -0
- package/dist/components/layout/FocusLayout.d.ts.map +1 -0
- package/dist/components/layout/GridLayout.d.ts +26 -0
- package/dist/components/layout/GridLayout.d.ts.map +1 -0
- package/dist/components/layout/LayoutContextProvider.d.ts +12 -0
- package/dist/components/layout/LayoutContextProvider.d.ts.map +1 -0
- package/dist/components/layout/index.d.ts +4 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/participant/AudioTrack.d.ts +33 -0
- package/dist/components/participant/AudioTrack.d.ts.map +1 -0
- package/dist/components/participant/AudioVisualizer.d.ts +22 -0
- package/dist/components/participant/AudioVisualizer.d.ts.map +1 -0
- package/dist/components/participant/BarVisualizer.d.ts +77 -0
- package/dist/components/participant/BarVisualizer.d.ts.map +1 -0
- package/dist/components/participant/ConnectionQualityIndicator.d.ts +16 -0
- package/dist/components/participant/ConnectionQualityIndicator.d.ts.map +1 -0
- package/dist/components/participant/ParticipantAudioTile.d.ts +14 -0
- package/dist/components/participant/ParticipantAudioTile.d.ts.map +1 -0
- package/dist/components/participant/ParticipantName.d.ts +17 -0
- package/dist/components/participant/ParticipantName.d.ts.map +1 -0
- package/dist/components/participant/ParticipantTile.d.ts +49 -0
- package/dist/components/participant/ParticipantTile.d.ts.map +1 -0
- package/dist/components/participant/TrackMutedIndicator.d.ts +19 -0
- package/dist/components/participant/TrackMutedIndicator.d.ts.map +1 -0
- package/dist/components/participant/VideoTrack.d.ts +23 -0
- package/dist/components/participant/VideoTrack.d.ts.map +1 -0
- package/dist/components/participant/animationSequences/connectingSequence.d.ts +2 -0
- package/dist/components/participant/animationSequences/connectingSequence.d.ts.map +1 -0
- package/dist/components/participant/animationSequences/listeningSequence.d.ts +2 -0
- package/dist/components/participant/animationSequences/listeningSequence.d.ts.map +1 -0
- package/dist/components/participant/animationSequences/thinkingSequence.d.ts +2 -0
- package/dist/components/participant/animationSequences/thinkingSequence.d.ts.map +1 -0
- package/dist/components/participant/animators/useBarAnimator.d.ts +3 -0
- package/dist/components/participant/animators/useBarAnimator.d.ts.map +1 -0
- package/dist/components-lNrIMTWQ.mjs +1051 -0
- package/dist/components-lNrIMTWQ.mjs.map +1 -0
- package/dist/context/chat-context.d.ts +23 -0
- package/dist/context/chat-context.d.ts.map +1 -0
- package/dist/context/feature-context.d.ts +14 -0
- package/dist/context/feature-context.d.ts.map +1 -0
- package/dist/context/index.d.ts +10 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/layout-context.d.ts +32 -0
- package/dist/context/layout-context.d.ts.map +1 -0
- package/dist/context/participant-context.d.ts +22 -0
- package/dist/context/participant-context.d.ts.map +1 -0
- package/dist/context/pin-context.d.ts +17 -0
- package/dist/context/pin-context.d.ts.map +1 -0
- package/dist/context/room-context.d.ts +22 -0
- package/dist/context/room-context.d.ts.map +1 -0
- package/dist/context/session-context.d.ts +22 -0
- package/dist/context/session-context.d.ts.map +1 -0
- package/dist/context/track-reference-context.d.ts +25 -0
- package/dist/context/track-reference-context.d.ts.map +1 -0
- package/dist/contexts-D4V9wQRc.mjs +4026 -0
- package/dist/contexts-D4V9wQRc.mjs.map +1 -0
- package/dist/hooks/cloud/krisp/useKrispNoiseFilter.d.ts +42 -0
- package/dist/hooks/cloud/krisp/useKrispNoiseFilter.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +54 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/internal/index.d.ts +10 -0
- package/dist/hooks/internal/index.d.ts.map +1 -0
- package/dist/hooks/internal/useMediaQuery.d.ts +7 -0
- package/dist/hooks/internal/useMediaQuery.d.ts.map +1 -0
- package/dist/hooks/internal/useObservableState.d.ts +6 -0
- package/dist/hooks/internal/useObservableState.d.ts.map +1 -0
- package/dist/hooks/internal/useResizeObserver.d.ts +14 -0
- package/dist/hooks/internal/useResizeObserver.d.ts.map +1 -0
- package/dist/hooks/useAgent.d.ts +219 -0
- package/dist/hooks/useAgent.d.ts.map +1 -0
- package/dist/hooks/useAudioPlayback.d.ts +15 -0
- package/dist/hooks/useAudioPlayback.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +43 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useChatToggle.d.ts +21 -0
- package/dist/hooks/useChatToggle.d.ts.map +1 -0
- package/dist/hooks/useClearPinButton.d.ts +15 -0
- package/dist/hooks/useClearPinButton.d.ts.map +1 -0
- package/dist/hooks/useConnectionQualityIndicator.d.ts +20 -0
- package/dist/hooks/useConnectionQualityIndicator.d.ts.map +1 -0
- package/dist/hooks/useConnectionStatus.d.ts +12 -0
- package/dist/hooks/useConnectionStatus.d.ts.map +1 -0
- package/dist/hooks/useDataChannel.d.ts +38 -0
- package/dist/hooks/useDataChannel.d.ts.map +1 -0
- package/dist/hooks/useDisconnectButton.d.ts +21 -0
- package/dist/hooks/useDisconnectButton.d.ts.map +1 -0
- package/dist/hooks/useEvents.d.ts +9 -0
- package/dist/hooks/useEvents.d.ts.map +1 -0
- package/dist/hooks/useFacingMode.d.ts +10 -0
- package/dist/hooks/useFacingMode.d.ts.map +1 -0
- package/dist/hooks/useFocusToggle.d.ts +26 -0
- package/dist/hooks/useFocusToggle.d.ts.map +1 -0
- package/dist/hooks/useGridLayout.d.ts +27 -0
- package/dist/hooks/useGridLayout.d.ts.map +1 -0
- package/dist/hooks/useIsEncrypted.d.ts +12 -0
- package/dist/hooks/useIsEncrypted.d.ts.map +1 -0
- package/dist/hooks/useIsMuted.d.ts +22 -0
- package/dist/hooks/useIsMuted.d.ts.map +1 -0
- package/dist/hooks/useIsRecording.d.ts +11 -0
- package/dist/hooks/useIsRecording.d.ts.map +1 -0
- package/dist/hooks/useIsSpeaking.d.ts +11 -0
- package/dist/hooks/useIsSpeaking.d.ts.map +1 -0
- package/dist/hooks/useLiveKitRoom.d.ts +19 -0
- package/dist/hooks/useLiveKitRoom.d.ts.map +1 -0
- package/dist/hooks/useLocalParticipant.d.ts +29 -0
- package/dist/hooks/useLocalParticipant.d.ts.map +1 -0
- package/dist/hooks/useLocalParticipantPermissions.d.ts +12 -0
- package/dist/hooks/useLocalParticipantPermissions.d.ts.map +1 -0
- package/dist/hooks/useMediaDeviceSelect.d.ts +41 -0
- package/dist/hooks/useMediaDeviceSelect.d.ts.map +1 -0
- package/dist/hooks/useMediaDevices.d.ts +15 -0
- package/dist/hooks/useMediaDevices.d.ts.map +1 -0
- package/dist/hooks/useMediaTrackBySourceOrName.d.ts +18 -0
- package/dist/hooks/useMediaTrackBySourceOrName.d.ts.map +1 -0
- package/dist/hooks/usePagination.d.ts +24 -0
- package/dist/hooks/usePagination.d.ts.map +1 -0
- package/dist/hooks/useParticipantAttributes.d.ts +30 -0
- package/dist/hooks/useParticipantAttributes.d.ts.map +1 -0
- package/dist/hooks/useParticipantInfo.d.ts +21 -0
- package/dist/hooks/useParticipantInfo.d.ts.map +1 -0
- package/dist/hooks/useParticipantPermissions.d.ts +17 -0
- package/dist/hooks/useParticipantPermissions.d.ts.map +1 -0
- package/dist/hooks/useParticipantTile.d.ts +22 -0
- package/dist/hooks/useParticipantTile.d.ts.map +1 -0
- package/dist/hooks/useParticipantTracks.d.ts +14 -0
- package/dist/hooks/useParticipantTracks.d.ts.map +1 -0
- package/dist/hooks/useParticipants.d.ts +30 -0
- package/dist/hooks/useParticipants.d.ts.map +1 -0
- package/dist/hooks/usePersistentUserChoices.d.ts +35 -0
- package/dist/hooks/usePersistentUserChoices.d.ts.map +1 -0
- package/dist/hooks/usePinnedTracks.d.ts +14 -0
- package/dist/hooks/usePinnedTracks.d.ts.map +1 -0
- package/dist/hooks/useRemoteParticipant.d.ts +35 -0
- package/dist/hooks/useRemoteParticipant.d.ts.map +1 -0
- package/dist/hooks/useRemoteParticipants.d.ts +30 -0
- package/dist/hooks/useRemoteParticipants.d.ts.map +1 -0
- package/dist/hooks/useRoomInfo.d.ts +21 -0
- package/dist/hooks/useRoomInfo.d.ts.map +1 -0
- package/dist/hooks/useSequentialRoomConnectDisconnect.d.ts +27 -0
- package/dist/hooks/useSequentialRoomConnectDisconnect.d.ts.map +1 -0
- package/dist/hooks/useSession.d.ts +130 -0
- package/dist/hooks/useSession.d.ts.map +1 -0
- package/dist/hooks/useSessionMessages.d.ts +29 -0
- package/dist/hooks/useSessionMessages.d.ts.map +1 -0
- package/dist/hooks/useSettingsToggle.d.ts +20 -0
- package/dist/hooks/useSettingsToggle.d.ts.map +1 -0
- package/dist/hooks/useSortedParticipants.d.ts +7 -0
- package/dist/hooks/useSortedParticipants.d.ts.map +1 -0
- package/dist/hooks/useSpeakingParticipants.d.ts +16 -0
- package/dist/hooks/useSpeakingParticipants.d.ts.map +1 -0
- package/dist/hooks/useStartAudio.d.ts +27 -0
- package/dist/hooks/useStartAudio.d.ts.map +1 -0
- package/dist/hooks/useStartVideo.d.ts +26 -0
- package/dist/hooks/useStartVideo.d.ts.map +1 -0
- package/dist/hooks/useSwipe.d.ts +24 -0
- package/dist/hooks/useSwipe.d.ts.map +1 -0
- package/dist/hooks/useTextStream.d.ts +20 -0
- package/dist/hooks/useTextStream.d.ts.map +1 -0
- package/dist/hooks/useToken.d.ts +20 -0
- package/dist/hooks/useToken.d.ts.map +1 -0
- package/dist/hooks/useTrack.d.ts +4 -0
- package/dist/hooks/useTrack.d.ts.map +1 -0
- package/dist/hooks/useTrackByName.d.ts +10 -0
- package/dist/hooks/useTrackByName.d.ts.map +1 -0
- package/dist/hooks/useTrackMutedIndicator.d.ts +18 -0
- package/dist/hooks/useTrackMutedIndicator.d.ts.map +1 -0
- package/dist/hooks/useTrackRefBySourceOrName.d.ts +7 -0
- package/dist/hooks/useTrackRefBySourceOrName.d.ts.map +1 -0
- package/dist/hooks/useTrackSyncTime.d.ts +10 -0
- package/dist/hooks/useTrackSyncTime.d.ts.map +1 -0
- package/dist/hooks/useTrackToggle.d.ts +27 -0
- package/dist/hooks/useTrackToggle.d.ts.map +1 -0
- package/dist/hooks/useTrackTranscription.d.ts +26 -0
- package/dist/hooks/useTrackTranscription.d.ts.map +1 -0
- package/dist/hooks/useTrackVolume.d.ts +49 -0
- package/dist/hooks/useTrackVolume.d.ts.map +1 -0
- package/dist/hooks/useTracks.d.ts +29 -0
- package/dist/hooks/useTracks.d.ts.map +1 -0
- package/dist/hooks/useTranscriptions.d.ts +21 -0
- package/dist/hooks/useTranscriptions.d.ts.map +1 -0
- package/dist/hooks/useVisualStableUpdate.d.ts +27 -0
- package/dist/hooks/useVisualStableUpdate.d.ts.map +1 -0
- package/dist/hooks/useVoiceAssistant.d.ts +43 -0
- package/dist/hooks/useVoiceAssistant.d.ts.map +1 -0
- package/dist/hooks/useWarnAboutMissingStyles.d.ts +5 -0
- package/dist/hooks/useWarnAboutMissingStyles.d.ts.map +1 -0
- package/dist/hooks-hQJmeINB.mjs +1992 -0
- package/dist/hooks-hQJmeINB.mjs.map +1 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hooks.mjs +64 -0
- package/dist/hooks.mjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.docs.d.ts +6 -0
- package/dist/index.docs.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +157 -0
- package/dist/index.mjs.map +1 -0
- package/dist/krisp.d.ts +2 -0
- package/dist/krisp.js +2 -0
- package/dist/krisp.js.map +1 -0
- package/dist/krisp.mjs +45 -0
- package/dist/krisp.mjs.map +1 -0
- package/dist/mergeProps.d.ts +25 -0
- package/dist/mergeProps.d.ts.map +1 -0
- package/dist/prefabs/AudioConference.d.ts +22 -0
- package/dist/prefabs/AudioConference.d.ts.map +1 -0
- package/dist/prefabs/Chat.d.ts +35 -0
- package/dist/prefabs/Chat.d.ts.map +1 -0
- package/dist/prefabs/ControlBar.d.ts +45 -0
- package/dist/prefabs/ControlBar.d.ts.map +1 -0
- package/dist/prefabs/MediaDeviceMenu.d.ts +36 -0
- package/dist/prefabs/MediaDeviceMenu.d.ts.map +1 -0
- package/dist/prefabs/PreJoin.d.ts +59 -0
- package/dist/prefabs/PreJoin.d.ts.map +1 -0
- package/dist/prefabs/VideoConference.d.ts +35 -0
- package/dist/prefabs/VideoConference.d.ts.map +1 -0
- package/dist/prefabs/VoiceAssistantControlBar.d.ts +32 -0
- package/dist/prefabs/VoiceAssistantControlBar.d.ts.map +1 -0
- package/dist/prefabs/index.d.ts +8 -0
- package/dist/prefabs/index.d.ts.map +1 -0
- package/dist/prefabs.d.ts +2 -0
- package/dist/prefabs.js +2 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/prefabs.mjs +579 -0
- package/dist/prefabs.mjs.map +1 -0
- package/dist/room-BP3SCCCd.mjs +191 -0
- package/dist/room-BP3SCCCd.mjs.map +1 -0
- package/dist/shared-88J2fzv7.js +2 -0
- package/dist/shared-88J2fzv7.js.map +1 -0
- package/dist/shared-BDr0qLg4.js +4 -0
- package/dist/shared-BDr0qLg4.js.map +1 -0
- package/dist/shared-CjI_UuOX.js +2 -0
- package/dist/shared-CjI_UuOX.js.map +1 -0
- package/dist/shared-DTHOl3uJ.js +2 -0
- package/dist/shared-DTHOl3uJ.js.map +1 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +104 -0
- package/src/assets/icons/CameraDisabledIcon.tsx +15 -0
- package/src/assets/icons/CameraIcon.tsx +14 -0
- package/src/assets/icons/ChatCloseIcon.tsx +17 -0
- package/src/assets/icons/ChatIcon.tsx +25 -0
- package/src/assets/icons/Chevron.tsx +19 -0
- package/src/assets/icons/FocusToggleIcon.tsx +16 -0
- package/src/assets/icons/GearIcon.tsx +19 -0
- package/src/assets/icons/LeaveIcon.tsx +25 -0
- package/src/assets/icons/LockLockedIcon.tsx +19 -0
- package/src/assets/icons/MicDisabledIcon.tsx +15 -0
- package/src/assets/icons/MicIcon.tsx +19 -0
- package/src/assets/icons/QualityExcellentIcon.tsx +15 -0
- package/src/assets/icons/QualityGoodIcon.tsx +19 -0
- package/src/assets/icons/QualityPoorIcon.tsx +20 -0
- package/src/assets/icons/QualityUnknownIcon.tsx +17 -0
- package/src/assets/icons/ScreenShareIcon.tsx +25 -0
- package/src/assets/icons/ScreenShareStopIcon.tsx +21 -0
- package/src/assets/icons/SpinnerIcon.tsx +93 -0
- package/src/assets/icons/UnfocusToggleIcon.tsx +16 -0
- package/src/assets/icons/index.ts +19 -0
- package/src/assets/icons/util.tsx +47 -0
- package/src/assets/images/ParticipantPlaceholder.tsx +31 -0
- package/src/assets/images/index.ts +1 -0
- package/src/assets/template.js +21 -0
- package/src/components/ChatEntry.tsx +112 -0
- package/src/components/ConnectionState.tsx +36 -0
- package/src/components/ConnectionStateToast.tsx +47 -0
- package/src/components/LiveKitRoom.tsx +122 -0
- package/src/components/ParticipantLoop.tsx +41 -0
- package/src/components/RoomAudioRenderer.tsx +57 -0
- package/src/components/RoomName.tsx +36 -0
- package/src/components/SessionProvider.tsx +22 -0
- package/src/components/Toast.tsx +18 -0
- package/src/components/TrackLoop.tsx +45 -0
- package/src/components/controls/ChatToggle.tsx +32 -0
- package/src/components/controls/ClearPinButton.tsx +32 -0
- package/src/components/controls/DisconnectButton.tsx +32 -0
- package/src/components/controls/FocusToggle.tsx +54 -0
- package/src/components/controls/MediaDeviceSelect.tsx +144 -0
- package/src/components/controls/PaginationControl.tsx +51 -0
- package/src/components/controls/PaginationIndicator.tsx +26 -0
- package/src/components/controls/SettingsMenuToggle.tsx +26 -0
- package/src/components/controls/StartAudio.tsx +40 -0
- package/src/components/controls/StartMediaButton.tsx +41 -0
- package/src/components/controls/TrackToggle.tsx +54 -0
- package/src/components/index.ts +34 -0
- package/src/components/layout/CarouselLayout.tsx +80 -0
- package/src/components/layout/FocusLayout.tsx +37 -0
- package/src/components/layout/GridLayout.tsx +63 -0
- package/src/components/layout/LayoutContextProvider.tsx +36 -0
- package/src/components/layout/index.ts +3 -0
- package/src/components/participant/AudioTrack.tsx +89 -0
- package/src/components/participant/AudioVisualizer.tsx +67 -0
- package/src/components/participant/BarVisualizer.tsx +164 -0
- package/src/components/participant/ConnectionQualityIndicator.tsx +36 -0
- package/src/components/participant/ParticipantAudioTile.tsx +67 -0
- package/src/components/participant/ParticipantName.tsx +50 -0
- package/src/components/participant/ParticipantTile.tsx +192 -0
- package/src/components/participant/TrackMutedIndicator.tsx +53 -0
- package/src/components/participant/VideoTrack.tsx +92 -0
- package/src/components/participant/animationSequences/connectingSequence.ts +9 -0
- package/src/components/participant/animationSequences/listeningSequence.ts +6 -0
- package/src/components/participant/animationSequences/thinkingSequence.ts +12 -0
- package/src/components/participant/animators/useBarAnimator.ts +55 -0
- package/src/context/chat-context.ts +37 -0
- package/src/context/feature-context.ts +28 -0
- package/src/context/index.ts +27 -0
- package/src/context/layout-context.ts +72 -0
- package/src/context/participant-context.ts +44 -0
- package/src/context/pin-context.ts +27 -0
- package/src/context/room-context.ts +42 -0
- package/src/context/session-context.ts +43 -0
- package/src/context/track-reference-context.ts +47 -0
- package/src/hooks/cloud/krisp/useKrispNoiseFilter.ts +110 -0
- package/src/hooks/index.ts +72 -0
- package/src/hooks/internal/index.ts +10 -0
- package/src/hooks/internal/useMediaQuery.ts +46 -0
- package/src/hooks/internal/useObservableState.ts +24 -0
- package/src/hooks/internal/useResizeObserver.ts +124 -0
- package/src/hooks/useAgent.ts +945 -0
- package/src/hooks/useAudioPlayback.ts +34 -0
- package/src/hooks/useChat.ts +57 -0
- package/src/hooks/useChatToggle.ts +38 -0
- package/src/hooks/useClearPinButton.ts +29 -0
- package/src/hooks/useConnectionQualityIndicator.ts +33 -0
- package/src/hooks/useConnectionStatus.ts +22 -0
- package/src/hooks/useDataChannel.ts +73 -0
- package/src/hooks/useDisconnectButton.ts +36 -0
- package/src/hooks/useEvents.ts +39 -0
- package/src/hooks/useFacingMode.ts +22 -0
- package/src/hooks/useFocusToggle.ts +59 -0
- package/src/hooks/useGridLayout.ts +44 -0
- package/src/hooks/useIsEncrypted.ts +29 -0
- package/src/hooks/useIsMuted.ts +51 -0
- package/src/hooks/useIsRecording.ts +23 -0
- package/src/hooks/useIsSpeaking.ts +21 -0
- package/src/hooks/useLiveKitRoom.ts +186 -0
- package/src/hooks/useLocalParticipant.ts +73 -0
- package/src/hooks/useLocalParticipantPermissions.ts +24 -0
- package/src/hooks/useMediaDeviceSelect.ts +81 -0
- package/src/hooks/useMediaDevices.ts +28 -0
- package/src/hooks/useMediaTrackBySourceOrName.ts +97 -0
- package/src/hooks/usePagination.test.ts +77 -0
- package/src/hooks/usePagination.ts +67 -0
- package/src/hooks/useParticipantAttributes.ts +69 -0
- package/src/hooks/useParticipantInfo.ts +35 -0
- package/src/hooks/useParticipantPermissions.ts +29 -0
- package/src/hooks/useParticipantTile.ts +81 -0
- package/src/hooks/useParticipantTracks.ts +54 -0
- package/src/hooks/useParticipants.ts +42 -0
- package/src/hooks/usePersistentUserChoices.ts +64 -0
- package/src/hooks/usePinnedTracks.ts +24 -0
- package/src/hooks/useRemoteParticipant.ts +79 -0
- package/src/hooks/useRemoteParticipants.ts +45 -0
- package/src/hooks/useRoomInfo.ts +32 -0
- package/src/hooks/useSequentialRoomConnectDisconnect.ts +171 -0
- package/src/hooks/useSession.ts +642 -0
- package/src/hooks/useSessionMessages.ts +158 -0
- package/src/hooks/useSettingsToggle.ts +32 -0
- package/src/hooks/useSortedParticipants.ts +20 -0
- package/src/hooks/useSpeakingParticipants.ts +27 -0
- package/src/hooks/useStartAudio.ts +50 -0
- package/src/hooks/useStartVideo.ts +49 -0
- package/src/hooks/useSwipe.ts +68 -0
- package/src/hooks/useTextStream.ts +35 -0
- package/src/hooks/useToken.ts +54 -0
- package/src/hooks/useTrack.ts +11 -0
- package/src/hooks/useTrackByName.ts +15 -0
- package/src/hooks/useTrackMutedIndicator.ts +44 -0
- package/src/hooks/useTrackRefBySourceOrName.ts +30 -0
- package/src/hooks/useTrackSyncTime.ts +18 -0
- package/src/hooks/useTrackToggle.ts +93 -0
- package/src/hooks/useTrackTranscription.ts +75 -0
- package/src/hooks/useTrackVolume.ts +283 -0
- package/src/hooks/useTracks.test.ts +60 -0
- package/src/hooks/useTracks.ts +154 -0
- package/src/hooks/useTranscriptions.ts +48 -0
- package/src/hooks/useVisualStableUpdate.ts +63 -0
- package/src/hooks/useVoiceAssistant.ts +109 -0
- package/src/hooks/useWarnAboutMissingStyles.ts +11 -0
- package/src/index.docs.ts +12 -0
- package/src/index.ts +32 -0
- package/src/mergeProps.ts +87 -0
- package/src/prefabs/AudioConference.tsx +57 -0
- package/src/prefabs/Chat.tsx +153 -0
- package/src/prefabs/ControlBar.tsx +227 -0
- package/src/prefabs/MediaDeviceMenu.tsx +159 -0
- package/src/prefabs/PreJoin.tsx +439 -0
- package/src/prefabs/VideoConference.tsx +184 -0
- package/src/prefabs/VoiceAssistantControlBar.tsx +109 -0
- package/src/prefabs/index.ts +11 -0
- package/src/utils.ts +78 -0
|
@@ -0,0 +1,1992 @@
|
|
|
1
|
+
import * as s from "react";
|
|
2
|
+
import { useRef as ue, useMemo as Be, useCallback as ne, useEffect as Ve } from "react";
|
|
3
|
+
import { u as U, r as qe, a as De, b as je, c as Y, d as We, e as ze, f as ce, g as Ge, h as Je, i as fe, j as $e, k as Qe, m as Ke, G as Ye, n as Xe, o as Ze, p as me, q as et, t as tt, v as Ie, w as pe, x as Ne, y as nt, l as j, z as rt, A as st, B as he, C as ot, D as at, E as it, F as ct, H as ut, I as dt, J as lt, K as ft, M as Te, N as mt, O as pt, P as ht, Q as bt, S as vt, T as gt, U as St, V as yt, W as _e, X as Ct, Y as Mt, Z as Tt, _ as Et, $ as kt, a0 as wt, a1 as Pt, a2 as Lt, a3 as At, a4 as Rt, a5 as Ot, a6 as Dt, a7 as le, a8 as $, a9 as It, aa as Nt, ab as _t, ac as Ft, ad as xt } from "./contexts-D4V9wQRc.mjs";
|
|
4
|
+
import { m as Q } from "./room-BP3SCCCd.mjs";
|
|
5
|
+
import { ConnectionState as I, LocalTrackPublication as Ut, facingModeFromLocalTrack as Ht, Room as Fe, Track as E, createAudioAnalyser as be, ParticipantKind as ae, Mutex as Bt, ParticipantEvent as ee, RoomEvent as V, decodeTokenPayload as Vt, TokenSourceConfigurable as qt } from "livekit-client";
|
|
6
|
+
const jt = (e) => {
|
|
7
|
+
const n = s.useRef(e);
|
|
8
|
+
return s.useEffect(() => {
|
|
9
|
+
n.current = e;
|
|
10
|
+
}), n;
|
|
11
|
+
};
|
|
12
|
+
function Wt(e, n) {
|
|
13
|
+
const t = Gt(), r = jt(n);
|
|
14
|
+
return s.useLayoutEffect(() => {
|
|
15
|
+
let o = !1;
|
|
16
|
+
const i = e.current;
|
|
17
|
+
if (!i) return;
|
|
18
|
+
function a(c, u) {
|
|
19
|
+
o || r.current(c, u);
|
|
20
|
+
}
|
|
21
|
+
return t == null || t.subscribe(i, a), () => {
|
|
22
|
+
o = !0, t == null || t.unsubscribe(i, a);
|
|
23
|
+
};
|
|
24
|
+
}, [e.current, t, r]), t == null ? void 0 : t.observer;
|
|
25
|
+
}
|
|
26
|
+
function zt() {
|
|
27
|
+
let e = !1, n = [];
|
|
28
|
+
const t = /* @__PURE__ */ new Map();
|
|
29
|
+
if (typeof window > "u")
|
|
30
|
+
return;
|
|
31
|
+
const r = new ResizeObserver((o, i) => {
|
|
32
|
+
n = n.concat(o), e || window.requestAnimationFrame(() => {
|
|
33
|
+
const a = /* @__PURE__ */ new Set();
|
|
34
|
+
for (let c = 0; c < n.length; c++) {
|
|
35
|
+
if (a.has(n[c].target)) continue;
|
|
36
|
+
a.add(n[c].target);
|
|
37
|
+
const u = t.get(n[c].target);
|
|
38
|
+
u == null || u.forEach((p) => p(n[c], i));
|
|
39
|
+
}
|
|
40
|
+
n = [], e = !1;
|
|
41
|
+
}), e = !0;
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
observer: r,
|
|
45
|
+
subscribe(o, i) {
|
|
46
|
+
r.observe(o);
|
|
47
|
+
const a = t.get(o) ?? [];
|
|
48
|
+
a.push(i), t.set(o, a);
|
|
49
|
+
},
|
|
50
|
+
unsubscribe(o, i) {
|
|
51
|
+
const a = t.get(o) ?? [];
|
|
52
|
+
if (a.length === 1) {
|
|
53
|
+
r.unobserve(o), t.delete(o);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const c = a.indexOf(i);
|
|
57
|
+
c !== -1 && a.splice(c, 1), t.set(o, a);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
let de;
|
|
62
|
+
const Gt = () => de || (de = zt()), Jt = (e) => {
|
|
63
|
+
const [n, t] = s.useState({ width: 0, height: 0 });
|
|
64
|
+
s.useLayoutEffect(() => {
|
|
65
|
+
if (e.current) {
|
|
66
|
+
const { width: o, height: i } = e.current.getBoundingClientRect();
|
|
67
|
+
t({ width: o, height: i });
|
|
68
|
+
}
|
|
69
|
+
}, [e.current]);
|
|
70
|
+
const r = s.useCallback(
|
|
71
|
+
(o) => t(o.contentRect),
|
|
72
|
+
[]
|
|
73
|
+
);
|
|
74
|
+
return Wt(e, r), n;
|
|
75
|
+
};
|
|
76
|
+
function O(e, n, t = !0) {
|
|
77
|
+
const [r, o] = s.useState(n);
|
|
78
|
+
return s.useEffect(() => {
|
|
79
|
+
if (t && o(n), typeof window > "u" || !e) return;
|
|
80
|
+
const i = e.subscribe(o);
|
|
81
|
+
return () => i.unsubscribe();
|
|
82
|
+
}, [e, t]), r;
|
|
83
|
+
}
|
|
84
|
+
function Dn(e) {
|
|
85
|
+
const n = (i) => typeof window < "u" ? window.matchMedia(i).matches : !1, [t, r] = s.useState(n(e));
|
|
86
|
+
function o() {
|
|
87
|
+
r(n(e));
|
|
88
|
+
}
|
|
89
|
+
return s.useEffect(() => {
|
|
90
|
+
const i = window.matchMedia(e);
|
|
91
|
+
return o(), i.addListener ? i.addListener(o) : i.addEventListener("change", o), () => {
|
|
92
|
+
i.removeListener ? i.removeListener(o) : i.removeEventListener("change", o);
|
|
93
|
+
};
|
|
94
|
+
}, [e]), t;
|
|
95
|
+
}
|
|
96
|
+
function In(e) {
|
|
97
|
+
const n = U(e), t = s.useCallback(async () => {
|
|
98
|
+
await n.startAudio();
|
|
99
|
+
}, [n]), r = s.useMemo(
|
|
100
|
+
() => qe(n),
|
|
101
|
+
[n]
|
|
102
|
+
), { canPlayAudio: o } = O(r, {
|
|
103
|
+
canPlayAudio: n.canPlaybackAudio
|
|
104
|
+
});
|
|
105
|
+
return { canPlayAudio: o, startAudio: t };
|
|
106
|
+
}
|
|
107
|
+
function Nn(e) {
|
|
108
|
+
const { state: n, dispatch: t } = De().pin;
|
|
109
|
+
return { buttonProps: s.useMemo(() => {
|
|
110
|
+
const { className: o } = je();
|
|
111
|
+
return Q(e, {
|
|
112
|
+
className: o,
|
|
113
|
+
disabled: !(n != null && n.length),
|
|
114
|
+
onClick: () => {
|
|
115
|
+
t && t({ msg: "clear_pin" });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}, [e, t, n]) };
|
|
119
|
+
}
|
|
120
|
+
function _n(e = {}) {
|
|
121
|
+
const n = Y(e.participant), { className: t, connectionQualityObserver: r } = s.useMemo(
|
|
122
|
+
() => We(n),
|
|
123
|
+
[n]
|
|
124
|
+
), o = O(r, n.connectionQuality);
|
|
125
|
+
return { className: t, quality: o };
|
|
126
|
+
}
|
|
127
|
+
function re(e) {
|
|
128
|
+
const n = U(e), t = s.useMemo(() => ze(n), [n]);
|
|
129
|
+
return O(t, n.state);
|
|
130
|
+
}
|
|
131
|
+
function Fn(e, n) {
|
|
132
|
+
const t = typeof e == "function" ? e : n, r = typeof e == "string" ? e : void 0, o = ce(), { send: i, messageObservable: a, isSendingObservable: c } = s.useMemo(
|
|
133
|
+
() => Ge(o, r, t),
|
|
134
|
+
[o, r, t]
|
|
135
|
+
), u = O(a, void 0), p = O(c, !1);
|
|
136
|
+
return {
|
|
137
|
+
message: u,
|
|
138
|
+
send: i,
|
|
139
|
+
isSending: p
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function xn(e) {
|
|
143
|
+
const n = ce(), t = re(n);
|
|
144
|
+
return { buttonProps: s.useMemo(() => {
|
|
145
|
+
const { className: o, disconnect: i } = Je(n);
|
|
146
|
+
return Q(e, {
|
|
147
|
+
className: o,
|
|
148
|
+
onClick: () => i(e.stopTracks ?? !0),
|
|
149
|
+
disabled: t === I.Disconnected
|
|
150
|
+
});
|
|
151
|
+
}, [n, e, t]) };
|
|
152
|
+
}
|
|
153
|
+
function $t(e) {
|
|
154
|
+
if (e.publication instanceof Ut) {
|
|
155
|
+
const n = e.publication.track;
|
|
156
|
+
if (n) {
|
|
157
|
+
const { facingMode: t } = Ht(n);
|
|
158
|
+
return t;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return "undefined";
|
|
162
|
+
}
|
|
163
|
+
function Un({ trackRef: e, props: n }) {
|
|
164
|
+
const t = fe(e), r = $e(), { className: o } = s.useMemo(() => Qe(), []), i = s.useMemo(() => Ke(t, r == null ? void 0 : r.pin.state), [t, r == null ? void 0 : r.pin.state]);
|
|
165
|
+
return { mergedProps: s.useMemo(
|
|
166
|
+
() => Q(n, {
|
|
167
|
+
className: o,
|
|
168
|
+
onClick: (c) => {
|
|
169
|
+
var u, p, h, l, d;
|
|
170
|
+
(u = n.onClick) == null || u.call(n, c), i ? (h = r == null ? void 0 : (p = r.pin).dispatch) == null || h.call(p, {
|
|
171
|
+
msg: "clear_pin"
|
|
172
|
+
}) : (d = r == null ? void 0 : (l = r.pin).dispatch) == null || d.call(l, {
|
|
173
|
+
msg: "set_pin",
|
|
174
|
+
trackReference: t
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}),
|
|
178
|
+
[n, o, t, i, r == null ? void 0 : r.pin]
|
|
179
|
+
), inFocus: i };
|
|
180
|
+
}
|
|
181
|
+
function Hn(e, n, t = {}) {
|
|
182
|
+
const r = t.gridLayouts ?? Ye, { width: o, height: i } = Jt(e), a = Xe(r, n, o, i);
|
|
183
|
+
return s.useEffect(() => {
|
|
184
|
+
e.current && a && (e.current.style.setProperty("--lk-col-count", a == null ? void 0 : a.columns.toString()), e.current.style.setProperty("--lk-row-count", a == null ? void 0 : a.rows.toString()));
|
|
185
|
+
}, [e, a]), {
|
|
186
|
+
layout: a,
|
|
187
|
+
containerWidth: o,
|
|
188
|
+
containerHeight: i
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function Ee(e, n = {}) {
|
|
192
|
+
var c, u;
|
|
193
|
+
const t = typeof e == "string" ? n.participant : e.participant, r = Y(t), o = typeof e == "string" ? { participant: r, source: e } : e, [i, a] = s.useState(
|
|
194
|
+
!!((c = o.publication) != null && c.isMuted || (u = r.getTrackPublication(o.source)) != null && u.isMuted)
|
|
195
|
+
);
|
|
196
|
+
return s.useEffect(() => {
|
|
197
|
+
const p = Ze(o).subscribe(a);
|
|
198
|
+
return () => p.unsubscribe();
|
|
199
|
+
}, [me(o)]), i;
|
|
200
|
+
}
|
|
201
|
+
function Qt(e) {
|
|
202
|
+
const n = Y(e), t = s.useMemo(() => et(n), [n]);
|
|
203
|
+
return O(t, n.isSpeaking);
|
|
204
|
+
}
|
|
205
|
+
function xe(e = {}) {
|
|
206
|
+
const n = U(e.room), [t, r] = s.useState(n.localParticipant), [o, i] = s.useState(
|
|
207
|
+
t.isMicrophoneEnabled
|
|
208
|
+
), [a, c] = s.useState(t.isCameraEnabled), [u, p] = s.useState(
|
|
209
|
+
t.isScreenShareEnabled
|
|
210
|
+
), [h, l] = s.useState(
|
|
211
|
+
t.lastMicrophoneError
|
|
212
|
+
), [d, v] = s.useState(t.lastCameraError), [M, w] = s.useState(
|
|
213
|
+
void 0
|
|
214
|
+
), [A, P] = s.useState(void 0), D = (R) => {
|
|
215
|
+
c(R.isCameraEnabled), i(R.isMicrophoneEnabled), p(R.isScreenShareEnabled), P(R.cameraTrack), w(R.microphoneTrack), l(R.participant.lastMicrophoneError), v(R.participant.lastCameraError), r(R.participant);
|
|
216
|
+
};
|
|
217
|
+
return s.useEffect(() => {
|
|
218
|
+
const R = tt(n.localParticipant).subscribe(D);
|
|
219
|
+
return () => R.unsubscribe();
|
|
220
|
+
}, [n]), {
|
|
221
|
+
isMicrophoneEnabled: o,
|
|
222
|
+
isScreenShareEnabled: u,
|
|
223
|
+
isCameraEnabled: a,
|
|
224
|
+
microphoneTrack: M,
|
|
225
|
+
cameraTrack: A,
|
|
226
|
+
lastMicrophoneError: h,
|
|
227
|
+
lastCameraError: d,
|
|
228
|
+
localParticipant: t
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function Bn() {
|
|
232
|
+
const e = ce(), n = s.useMemo(
|
|
233
|
+
() => Ie(e.localParticipant),
|
|
234
|
+
[e]
|
|
235
|
+
);
|
|
236
|
+
return O(n, e.localParticipant.permissions);
|
|
237
|
+
}
|
|
238
|
+
function Vn({
|
|
239
|
+
kind: e,
|
|
240
|
+
room: n,
|
|
241
|
+
track: t,
|
|
242
|
+
requestPermissions: r,
|
|
243
|
+
onError: o
|
|
244
|
+
}) {
|
|
245
|
+
const i = pe(), a = s.useMemo(() => n ?? i ?? new Fe(), [n, i]), c = s.useMemo(
|
|
246
|
+
() => Ne(e, o, r),
|
|
247
|
+
[e, r, o]
|
|
248
|
+
), u = O(c, []), [p, h] = s.useState(
|
|
249
|
+
(a == null ? void 0 : a.getActiveDevice(e)) ?? "default"
|
|
250
|
+
), { className: l, activeDeviceObservable: d, setActiveMediaDevice: v } = s.useMemo(
|
|
251
|
+
() => nt(e, a),
|
|
252
|
+
[e, a, t]
|
|
253
|
+
);
|
|
254
|
+
return s.useEffect(() => {
|
|
255
|
+
const M = d.subscribe((w) => {
|
|
256
|
+
w && (j.info("setCurrentDeviceId", w), h(w));
|
|
257
|
+
});
|
|
258
|
+
return () => {
|
|
259
|
+
M == null || M.unsubscribe();
|
|
260
|
+
};
|
|
261
|
+
}, [d]), { devices: u, className: l, activeDeviceId: p, setActiveMediaDevice: v };
|
|
262
|
+
}
|
|
263
|
+
function qn({
|
|
264
|
+
kind: e,
|
|
265
|
+
onError: n
|
|
266
|
+
}) {
|
|
267
|
+
const t = s.useMemo(
|
|
268
|
+
() => Ne(e, n),
|
|
269
|
+
[e, n]
|
|
270
|
+
);
|
|
271
|
+
return O(t, []);
|
|
272
|
+
}
|
|
273
|
+
function Kt(e, n, t = {}) {
|
|
274
|
+
const r = s.useRef([]), o = s.useRef(-1), i = n !== o.current, a = typeof t.customSortFunction == "function" ? t.customSortFunction(e) : rt(e);
|
|
275
|
+
let c = [...a];
|
|
276
|
+
if (i === !1)
|
|
277
|
+
try {
|
|
278
|
+
c = st(r.current, a, n);
|
|
279
|
+
} catch (u) {
|
|
280
|
+
j.error("Error while running updatePages(): ", u);
|
|
281
|
+
}
|
|
282
|
+
return i ? r.current = a : r.current = c, o.current = n, c;
|
|
283
|
+
}
|
|
284
|
+
function jn(e, n) {
|
|
285
|
+
const [t, r] = s.useState(1), o = Math.max(Math.ceil(n.length / e), 1);
|
|
286
|
+
t > o && r(o);
|
|
287
|
+
const i = t * e, a = i - e, c = (l) => {
|
|
288
|
+
r((d) => l === "next" ? d === o ? d : d + 1 : d === 1 ? d : d - 1);
|
|
289
|
+
}, u = (l) => {
|
|
290
|
+
l > o ? r(o) : l < 1 ? r(1) : r(l);
|
|
291
|
+
}, h = Kt(n, e).slice(a, i);
|
|
292
|
+
return {
|
|
293
|
+
totalPageCount: o,
|
|
294
|
+
nextPage: () => c("next"),
|
|
295
|
+
prevPage: () => c("previous"),
|
|
296
|
+
setPage: u,
|
|
297
|
+
firstItemIndex: a,
|
|
298
|
+
lastItemIndex: i,
|
|
299
|
+
tracks: h,
|
|
300
|
+
currentPage: t
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function Yt(e = {}) {
|
|
304
|
+
let n = he();
|
|
305
|
+
e.participant && (n = e.participant);
|
|
306
|
+
const t = s.useMemo(() => ot(n), [n]), { identity: r, name: o, metadata: i } = O(t, {
|
|
307
|
+
name: n == null ? void 0 : n.name,
|
|
308
|
+
identity: n == null ? void 0 : n.identity,
|
|
309
|
+
metadata: n == null ? void 0 : n.metadata
|
|
310
|
+
});
|
|
311
|
+
return { identity: r, name: o, metadata: i };
|
|
312
|
+
}
|
|
313
|
+
function Wn(e = {}) {
|
|
314
|
+
const n = Y(e.participant), t = s.useMemo(() => Ie(n), [n]);
|
|
315
|
+
return O(t, n.permissions);
|
|
316
|
+
}
|
|
317
|
+
function zn({
|
|
318
|
+
trackRef: e,
|
|
319
|
+
onParticipantClick: n,
|
|
320
|
+
disableSpeakingIndicator: t,
|
|
321
|
+
htmlProps: r
|
|
322
|
+
}) {
|
|
323
|
+
const o = fe(e), i = s.useMemo(() => {
|
|
324
|
+
const { className: d } = at();
|
|
325
|
+
return Q(r, {
|
|
326
|
+
className: d,
|
|
327
|
+
onClick: (v) => {
|
|
328
|
+
var M;
|
|
329
|
+
if ((M = r.onClick) == null || M.call(r, v), typeof n == "function") {
|
|
330
|
+
const w = o.publication ?? o.participant.getTrackPublication(o.source);
|
|
331
|
+
n({ participant: o.participant, track: w });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}, [
|
|
336
|
+
r,
|
|
337
|
+
n,
|
|
338
|
+
o.publication,
|
|
339
|
+
o.source,
|
|
340
|
+
o.participant
|
|
341
|
+
]), a = o.participant.getTrackPublication(E.Source.Microphone), c = s.useMemo(() => ({
|
|
342
|
+
participant: o.participant,
|
|
343
|
+
source: E.Source.Microphone,
|
|
344
|
+
publication: a
|
|
345
|
+
}), [a, o.participant]), u = Ee(o), p = Ee(c), h = Qt(o.participant), l = $t(o);
|
|
346
|
+
return {
|
|
347
|
+
elementProps: {
|
|
348
|
+
"data-lk-audio-muted": p,
|
|
349
|
+
"data-lk-video-muted": u,
|
|
350
|
+
"data-lk-speaking": t === !0 ? !1 : h,
|
|
351
|
+
"data-lk-local-participant": o.participant.isLocal,
|
|
352
|
+
"data-lk-source": o.source,
|
|
353
|
+
"data-lk-facing-mode": l,
|
|
354
|
+
...i
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function ve(e = {}) {
|
|
359
|
+
const n = U(e.room), [t, r] = s.useState([]);
|
|
360
|
+
return s.useEffect(() => {
|
|
361
|
+
const o = it(n, {
|
|
362
|
+
additionalRoomEvents: e.updateOnlyOn
|
|
363
|
+
}).subscribe(r);
|
|
364
|
+
return () => o.unsubscribe();
|
|
365
|
+
}, [n, JSON.stringify(e.updateOnlyOn)]), t;
|
|
366
|
+
}
|
|
367
|
+
function Xt(e = {}) {
|
|
368
|
+
const n = ve(e), { localParticipant: t } = xe(e);
|
|
369
|
+
return s.useMemo(
|
|
370
|
+
() => [t, ...n],
|
|
371
|
+
[t, n]
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
function Gn(e) {
|
|
375
|
+
return e = ct(e), s.useMemo(() => (e == null ? void 0 : e.pin.state) !== void 0 && e.pin.state.length >= 1 ? e.pin.state : [], [e.pin.state]);
|
|
376
|
+
}
|
|
377
|
+
function Jn(e, n = {}) {
|
|
378
|
+
const t = ce(), [r] = s.useState(n.updateOnlyOn), o = s.useMemo(() => typeof e == "string" ? ut(t, e, {
|
|
379
|
+
additionalEvents: r
|
|
380
|
+
}) : dt(t, e, {
|
|
381
|
+
additionalEvents: r
|
|
382
|
+
}), [t, JSON.stringify(e), r]), [i, a] = s.useState({
|
|
383
|
+
p: void 0
|
|
384
|
+
});
|
|
385
|
+
return s.useEffect(() => {
|
|
386
|
+
const c = o.subscribe((u) => a({ p: u }));
|
|
387
|
+
return () => c.unsubscribe();
|
|
388
|
+
}, [o]), i.p;
|
|
389
|
+
}
|
|
390
|
+
function $n(e = {}) {
|
|
391
|
+
const n = U(e.room), t = s.useMemo(() => lt(n), [n]), { name: r, metadata: o } = O(t, {
|
|
392
|
+
name: n.name,
|
|
393
|
+
metadata: n.metadata
|
|
394
|
+
});
|
|
395
|
+
return { name: r, metadata: o };
|
|
396
|
+
}
|
|
397
|
+
function Zt(e) {
|
|
398
|
+
const n = U(e == null ? void 0 : e.room), t = s.useMemo(() => ft(n), [n]);
|
|
399
|
+
return O(t, n.activeSpeakers);
|
|
400
|
+
}
|
|
401
|
+
function Qn(e) {
|
|
402
|
+
const [n, t] = s.useState(
|
|
403
|
+
Te(e)
|
|
404
|
+
), r = Zt();
|
|
405
|
+
return s.useEffect(() => {
|
|
406
|
+
t(Te(e));
|
|
407
|
+
}, [r, e]), n;
|
|
408
|
+
}
|
|
409
|
+
function Kn({ room: e, props: n }) {
|
|
410
|
+
const t = U(e), { className: r, roomAudioPlaybackAllowedObservable: o, handleStartAudioPlayback: i } = s.useMemo(
|
|
411
|
+
() => mt(),
|
|
412
|
+
[]
|
|
413
|
+
), a = s.useMemo(
|
|
414
|
+
() => o(t),
|
|
415
|
+
[t, o]
|
|
416
|
+
), { canPlayAudio: c } = O(a, {
|
|
417
|
+
canPlayAudio: t.canPlaybackAudio
|
|
418
|
+
});
|
|
419
|
+
return { mergedProps: s.useMemo(
|
|
420
|
+
() => Q(n, {
|
|
421
|
+
className: r,
|
|
422
|
+
onClick: () => {
|
|
423
|
+
i(t);
|
|
424
|
+
},
|
|
425
|
+
style: { display: c ? "none" : "block" }
|
|
426
|
+
}),
|
|
427
|
+
[n, r, c, i, t]
|
|
428
|
+
), canPlayAudio: c };
|
|
429
|
+
}
|
|
430
|
+
function Yn({ room: e, props: n }) {
|
|
431
|
+
const t = U(e), { className: r, roomVideoPlaybackAllowedObservable: o, handleStartVideoPlayback: i } = s.useMemo(
|
|
432
|
+
() => pt(),
|
|
433
|
+
[]
|
|
434
|
+
), a = s.useMemo(
|
|
435
|
+
() => o(t),
|
|
436
|
+
[t, o]
|
|
437
|
+
), { canPlayVideo: c } = O(a, {
|
|
438
|
+
canPlayVideo: t.canPlaybackVideo
|
|
439
|
+
});
|
|
440
|
+
return { mergedProps: s.useMemo(
|
|
441
|
+
() => Q(n, {
|
|
442
|
+
className: r,
|
|
443
|
+
onClick: () => {
|
|
444
|
+
i(t);
|
|
445
|
+
},
|
|
446
|
+
style: { display: c ? "none" : "block" }
|
|
447
|
+
}),
|
|
448
|
+
[n, r, c, i, t]
|
|
449
|
+
), canPlayVideo: c };
|
|
450
|
+
}
|
|
451
|
+
function Xn(e, n = {}) {
|
|
452
|
+
const t = s.useRef(null), r = s.useRef(null), o = n.minSwipeDistance ?? 50, i = (u) => {
|
|
453
|
+
r.current = null, t.current = u.targetTouches[0].clientX;
|
|
454
|
+
}, a = (u) => {
|
|
455
|
+
r.current = u.targetTouches[0].clientX;
|
|
456
|
+
}, c = s.useCallback(() => {
|
|
457
|
+
if (!t.current || !r.current)
|
|
458
|
+
return;
|
|
459
|
+
const u = t.current - r.current, p = u > o, h = u < -o;
|
|
460
|
+
p && n.onLeftSwipe && n.onLeftSwipe(), h && n.onRightSwipe && n.onRightSwipe();
|
|
461
|
+
}, [o, n]);
|
|
462
|
+
s.useEffect(() => {
|
|
463
|
+
const u = e.current;
|
|
464
|
+
return u && (u.addEventListener("touchstart", i, { passive: !0 }), u.addEventListener("touchmove", a, { passive: !0 }), u.addEventListener("touchend", c, { passive: !0 })), () => {
|
|
465
|
+
u && (u.removeEventListener("touchstart", i), u.removeEventListener("touchmove", a), u.removeEventListener("touchend", c));
|
|
466
|
+
};
|
|
467
|
+
}, [e, c]);
|
|
468
|
+
}
|
|
469
|
+
function Zn({ props: e }) {
|
|
470
|
+
const { dispatch: n, state: t } = De().widget, { className: r } = s.useMemo(() => ht(), []);
|
|
471
|
+
return { mergedProps: s.useMemo(() => Q(e, {
|
|
472
|
+
className: r,
|
|
473
|
+
onClick: () => {
|
|
474
|
+
n && n({ msg: "toggle_chat" });
|
|
475
|
+
},
|
|
476
|
+
"aria-pressed": t != null && t.showChat ? "true" : "false",
|
|
477
|
+
"data-lk-unread-msgs": t ? t.unreadMessages < 10 ? t.unreadMessages.toFixed(0) : "9+" : "0"
|
|
478
|
+
}), [e, r, n, t]) };
|
|
479
|
+
}
|
|
480
|
+
function er(e, n, t = {}) {
|
|
481
|
+
const [r, o] = s.useState(void 0);
|
|
482
|
+
return s.useEffect(() => {
|
|
483
|
+
var a;
|
|
484
|
+
if (e === void 0)
|
|
485
|
+
throw Error("token endpoint needs to be defined");
|
|
486
|
+
if (((a = t.userInfo) == null ? void 0 : a.identity) === void 0)
|
|
487
|
+
return;
|
|
488
|
+
(async () => {
|
|
489
|
+
j.debug("fetching token");
|
|
490
|
+
const c = new URLSearchParams({ ...t.userInfo, roomName: n }), u = await fetch(`${e}?${c.toString()}`);
|
|
491
|
+
if (!u.ok) {
|
|
492
|
+
j.error(
|
|
493
|
+
`Could not fetch token. Server responded with status ${u.status}: ${u.statusText}`
|
|
494
|
+
);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const { accessToken: p } = await u.json();
|
|
498
|
+
o(p);
|
|
499
|
+
})();
|
|
500
|
+
}, [e, n, JSON.stringify(t)]), r;
|
|
501
|
+
}
|
|
502
|
+
function tr(e) {
|
|
503
|
+
var i, a;
|
|
504
|
+
const n = fe(e), { className: t, mediaMutedObserver: r } = s.useMemo(
|
|
505
|
+
() => bt(n),
|
|
506
|
+
[me(n)]
|
|
507
|
+
);
|
|
508
|
+
return { isMuted: O(
|
|
509
|
+
r,
|
|
510
|
+
!!((i = n.publication) != null && i.isMuted || (a = n.participant.getTrackPublication(n.source)) != null && a.isMuted)
|
|
511
|
+
), className: t };
|
|
512
|
+
}
|
|
513
|
+
function nr({
|
|
514
|
+
source: e,
|
|
515
|
+
onChange: n,
|
|
516
|
+
initialState: t,
|
|
517
|
+
captureOptions: r,
|
|
518
|
+
publishOptions: o,
|
|
519
|
+
onDeviceError: i,
|
|
520
|
+
room: a,
|
|
521
|
+
...c
|
|
522
|
+
}) {
|
|
523
|
+
var m;
|
|
524
|
+
const u = pe(), p = s.useMemo(() => a ?? u, [a, u]), h = (m = p == null ? void 0 : p.localParticipant) == null ? void 0 : m.getTrackPublication(e), l = s.useRef(!1), { toggle: d, className: v, pendingObserver: M, enabledObserver: w } = s.useMemo(
|
|
525
|
+
() => p ? vt(e, p, r, o, i) : gt(),
|
|
526
|
+
[p, e, JSON.stringify(r), o]
|
|
527
|
+
), A = O(M, !1), P = O(w, t ?? !!(h != null && h.isEnabled));
|
|
528
|
+
s.useEffect(() => {
|
|
529
|
+
n == null || n(P, l.current), l.current = !1;
|
|
530
|
+
}, [P, n]), s.useEffect(() => {
|
|
531
|
+
t !== void 0 && (j.debug("forcing initial toggle state", e, t), d(t));
|
|
532
|
+
}, []);
|
|
533
|
+
const D = s.useMemo(() => Q(c, { className: v }), [c, v]), R = s.useCallback(
|
|
534
|
+
(f) => {
|
|
535
|
+
var b;
|
|
536
|
+
l.current = !0, d().catch(() => l.current = !1), (b = c.onClick) == null || b.call(c, f);
|
|
537
|
+
},
|
|
538
|
+
[c, d]
|
|
539
|
+
);
|
|
540
|
+
return {
|
|
541
|
+
toggle: d,
|
|
542
|
+
enabled: P,
|
|
543
|
+
pending: A,
|
|
544
|
+
track: h,
|
|
545
|
+
buttonProps: {
|
|
546
|
+
...D,
|
|
547
|
+
"aria-pressed": P,
|
|
548
|
+
"data-lk-source": e,
|
|
549
|
+
"data-lk-enabled": P,
|
|
550
|
+
disabled: A,
|
|
551
|
+
onClick: R
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function rr(e = [
|
|
556
|
+
E.Source.Camera,
|
|
557
|
+
E.Source.Microphone,
|
|
558
|
+
E.Source.ScreenShare,
|
|
559
|
+
E.Source.ScreenShareAudio,
|
|
560
|
+
E.Source.Unknown
|
|
561
|
+
], n = {}) {
|
|
562
|
+
const t = U(n.room), [r, o] = s.useState([]), [i, a] = s.useState([]), c = s.useMemo(() => e.map((p) => St(p) ? p.source : p), [JSON.stringify(e)]);
|
|
563
|
+
return s.useEffect(() => {
|
|
564
|
+
const p = yt(t, c, {
|
|
565
|
+
additionalRoomEvents: n.updateOnlyOn,
|
|
566
|
+
onlySubscribed: n.onlySubscribed
|
|
567
|
+
}).subscribe(({ trackReferences: h, participants: l }) => {
|
|
568
|
+
j.debug("setting track bundles", h, l), o(h), a(l);
|
|
569
|
+
});
|
|
570
|
+
return () => p.unsubscribe();
|
|
571
|
+
}, [
|
|
572
|
+
t,
|
|
573
|
+
JSON.stringify(n.onlySubscribed),
|
|
574
|
+
JSON.stringify(n.updateOnlyOn),
|
|
575
|
+
JSON.stringify(e)
|
|
576
|
+
]), s.useMemo(() => {
|
|
577
|
+
if (_e(e)) {
|
|
578
|
+
const p = tn(e, i), h = Array.from(r);
|
|
579
|
+
return i.forEach((l) => {
|
|
580
|
+
p.has(l.identity) && (p.get(l.identity) ?? []).forEach((v) => {
|
|
581
|
+
if (r.find(
|
|
582
|
+
({ participant: w, publication: A }) => l.identity === w.identity && A.source === v
|
|
583
|
+
))
|
|
584
|
+
return;
|
|
585
|
+
j.debug(
|
|
586
|
+
`Add ${v} placeholder for participant ${l.identity}.`
|
|
587
|
+
);
|
|
588
|
+
const M = {
|
|
589
|
+
participant: l,
|
|
590
|
+
source: v
|
|
591
|
+
};
|
|
592
|
+
h.push(M);
|
|
593
|
+
});
|
|
594
|
+
}), h;
|
|
595
|
+
} else
|
|
596
|
+
return r;
|
|
597
|
+
}, [r, i, e]);
|
|
598
|
+
}
|
|
599
|
+
function en(e, n) {
|
|
600
|
+
const t = new Set(e);
|
|
601
|
+
for (const r of n)
|
|
602
|
+
t.delete(r);
|
|
603
|
+
return t;
|
|
604
|
+
}
|
|
605
|
+
function tn(e, n) {
|
|
606
|
+
const t = /* @__PURE__ */ new Map();
|
|
607
|
+
if (_e(e)) {
|
|
608
|
+
const r = e.filter((o) => o.withPlaceholder).map((o) => o.source);
|
|
609
|
+
n.forEach((o) => {
|
|
610
|
+
const i = o.getTrackPublications().map((c) => {
|
|
611
|
+
var u;
|
|
612
|
+
return (u = c.track) == null ? void 0 : u.source;
|
|
613
|
+
}).filter((c) => c !== void 0), a = Array.from(
|
|
614
|
+
en(new Set(r), new Set(i))
|
|
615
|
+
);
|
|
616
|
+
a.length > 0 && t.set(o.identity, a);
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return t;
|
|
620
|
+
}
|
|
621
|
+
function nn(e) {
|
|
622
|
+
const [n, t] = s.useState(Ct(e)), { trackObserver: r } = s.useMemo(() => Mt(e), [e.participant.sid ?? e.participant.identity, e.source]);
|
|
623
|
+
return s.useEffect(() => {
|
|
624
|
+
const o = r.subscribe((i) => {
|
|
625
|
+
t(i);
|
|
626
|
+
});
|
|
627
|
+
return () => o == null ? void 0 : o.unsubscribe();
|
|
628
|
+
}, [r]), {
|
|
629
|
+
participant: e.participant,
|
|
630
|
+
source: e.source ?? E.Source.Unknown,
|
|
631
|
+
publication: n
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function sr(e, n) {
|
|
635
|
+
const t = Y(n);
|
|
636
|
+
return nn({ name: e, participant: t });
|
|
637
|
+
}
|
|
638
|
+
function rn(e) {
|
|
639
|
+
const n = U(e == null ? void 0 : e.room), t = re(n), r = s.useMemo(
|
|
640
|
+
() => t === I.Disconnected,
|
|
641
|
+
[t]
|
|
642
|
+
), o = s.useMemo(
|
|
643
|
+
() => Tt(n, e),
|
|
644
|
+
[n, e, r]
|
|
645
|
+
), i = O(o.isSendingObservable, !1), a = O(o.messageObservable, []);
|
|
646
|
+
return { send: o.send, chatMessages: a, isSending: i };
|
|
647
|
+
}
|
|
648
|
+
function or(e = {}) {
|
|
649
|
+
const [n, t] = s.useState(
|
|
650
|
+
Et(e.defaults, e.preventLoad ?? !1)
|
|
651
|
+
), r = s.useCallback((u) => {
|
|
652
|
+
t((p) => ({ ...p, audioEnabled: u }));
|
|
653
|
+
}, []), o = s.useCallback((u) => {
|
|
654
|
+
t((p) => ({ ...p, videoEnabled: u }));
|
|
655
|
+
}, []), i = s.useCallback((u) => {
|
|
656
|
+
t((p) => ({ ...p, audioDeviceId: u }));
|
|
657
|
+
}, []), a = s.useCallback((u) => {
|
|
658
|
+
t((p) => ({ ...p, videoDeviceId: u }));
|
|
659
|
+
}, []), c = s.useCallback((u) => {
|
|
660
|
+
t((p) => ({ ...p, username: u }));
|
|
661
|
+
}, []);
|
|
662
|
+
return s.useEffect(() => {
|
|
663
|
+
kt(n, e.preventSave ?? !1);
|
|
664
|
+
}, [n, e.preventSave]), {
|
|
665
|
+
userChoices: n,
|
|
666
|
+
saveAudioInputEnabled: r,
|
|
667
|
+
saveVideoInputEnabled: o,
|
|
668
|
+
saveAudioInputDeviceId: i,
|
|
669
|
+
saveVideoInputDeviceId: a,
|
|
670
|
+
saveUsername: c
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function ar(e, n = {}) {
|
|
674
|
+
const t = Y(e), r = U(n.room), o = s.useMemo(() => wt(r, t), [r, t]);
|
|
675
|
+
return O(
|
|
676
|
+
o,
|
|
677
|
+
t.isLocal ? t.isE2EEEnabled : !!(t != null && t.isEncrypted)
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
function ir(e, n = { fftSize: 32, smoothingTimeConstant: 0 }) {
|
|
681
|
+
const t = Pt(e) ? e.publication.track : e, [r, o] = s.useState(0);
|
|
682
|
+
return s.useEffect(() => {
|
|
683
|
+
if (!t || !t.mediaStream)
|
|
684
|
+
return;
|
|
685
|
+
const { cleanup: i, analyser: a } = be(t, n), c = a.frequencyBinCount, u = new Uint8Array(c), h = setInterval(() => {
|
|
686
|
+
a.getByteFrequencyData(u);
|
|
687
|
+
let l = 0;
|
|
688
|
+
for (let d = 0; d < u.length; d++) {
|
|
689
|
+
const v = u[d];
|
|
690
|
+
l += v * v;
|
|
691
|
+
}
|
|
692
|
+
o(Math.sqrt(l / u.length) / 255);
|
|
693
|
+
}, 1e3 / 30);
|
|
694
|
+
return () => {
|
|
695
|
+
i(), clearInterval(h);
|
|
696
|
+
};
|
|
697
|
+
}, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), r;
|
|
698
|
+
}
|
|
699
|
+
const sn = (e) => {
|
|
700
|
+
const n = (t) => {
|
|
701
|
+
let i = 1 - Math.max(-100, Math.min(-10, t)) * -1 / 100;
|
|
702
|
+
return i = Math.sqrt(i), i;
|
|
703
|
+
};
|
|
704
|
+
return e.map((t) => t === -1 / 0 ? 0 : n(t));
|
|
705
|
+
}, on = {
|
|
706
|
+
bands: 5,
|
|
707
|
+
loPass: 100,
|
|
708
|
+
hiPass: 600,
|
|
709
|
+
updateInterval: 32,
|
|
710
|
+
analyserOptions: { fftSize: 2048 }
|
|
711
|
+
};
|
|
712
|
+
function cr(e, n = {}) {
|
|
713
|
+
var a;
|
|
714
|
+
const t = e instanceof E ? e : (a = e == null ? void 0 : e.publication) == null ? void 0 : a.track, r = { ...on, ...n }, [o, i] = s.useState(
|
|
715
|
+
new Array(r.bands).fill(0)
|
|
716
|
+
);
|
|
717
|
+
return s.useEffect(() => {
|
|
718
|
+
if (!t || !(t != null && t.mediaStream)) {
|
|
719
|
+
i((v) => v.slice().fill(0));
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
const { analyser: c, cleanup: u } = be(t, r.analyserOptions), p = c.frequencyBinCount, h = new Float32Array(p), d = setInterval(() => {
|
|
723
|
+
c.getFloatFrequencyData(h);
|
|
724
|
+
let v = new Float32Array(h.length);
|
|
725
|
+
for (let P = 0; P < h.length; P++)
|
|
726
|
+
v[P] = h[P];
|
|
727
|
+
v = v.slice(r.loPass, r.hiPass);
|
|
728
|
+
const M = sn(v), w = M.length, A = [];
|
|
729
|
+
for (let P = 0; P < r.bands; P++) {
|
|
730
|
+
const D = Math.floor(P * w / r.bands), R = Math.floor((P + 1) * w / r.bands), m = M.slice(D, R), f = m.length;
|
|
731
|
+
if (f === 0)
|
|
732
|
+
A.push(0);
|
|
733
|
+
else {
|
|
734
|
+
const b = m.reduce((g, y) => g += y, 0);
|
|
735
|
+
A.push(b / f);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
i(A);
|
|
739
|
+
}, r.updateInterval);
|
|
740
|
+
return () => {
|
|
741
|
+
u(), clearInterval(d);
|
|
742
|
+
};
|
|
743
|
+
}, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), o;
|
|
744
|
+
}
|
|
745
|
+
const an = {
|
|
746
|
+
barCount: 120,
|
|
747
|
+
volMultiplier: 5,
|
|
748
|
+
updateInterval: 20
|
|
749
|
+
};
|
|
750
|
+
function ur(e, n = {}) {
|
|
751
|
+
var h;
|
|
752
|
+
const t = e instanceof E ? e : (h = e == null ? void 0 : e.publication) == null ? void 0 : h.track, r = { ...an, ...n }, o = s.useRef(new Float32Array()), i = s.useRef(performance.now()), a = s.useRef(0), [c, u] = s.useState([]), p = s.useCallback((l) => {
|
|
753
|
+
u(
|
|
754
|
+
Array.from(
|
|
755
|
+
un(l, r.barCount).map((d) => Math.sqrt(d) * r.volMultiplier)
|
|
756
|
+
// wave.slice(0, opts.barCount).map((v) => sigmoid(v * opts.volMultiplier, 0.08, 0.2)),
|
|
757
|
+
)
|
|
758
|
+
);
|
|
759
|
+
}, []);
|
|
760
|
+
return s.useEffect(() => {
|
|
761
|
+
if (!t || !(t != null && t.mediaStream))
|
|
762
|
+
return;
|
|
763
|
+
const { analyser: l, cleanup: d } = be(t, {
|
|
764
|
+
fftSize: ke(r.barCount)
|
|
765
|
+
}), v = ke(r.barCount), M = new Float32Array(v), w = () => {
|
|
766
|
+
if (A = requestAnimationFrame(w), l.getFloatTimeDomainData(M), o.current.map((P, D) => P + M[D]), a.current += 1, performance.now() - i.current >= r.updateInterval) {
|
|
767
|
+
const P = M.map((D) => D / a.current);
|
|
768
|
+
p(P), i.current = performance.now(), a.current = 0;
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
let A = requestAnimationFrame(w);
|
|
772
|
+
return () => {
|
|
773
|
+
d(), cancelAnimationFrame(A);
|
|
774
|
+
};
|
|
775
|
+
}, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n), p]), {
|
|
776
|
+
bars: c
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function ke(e) {
|
|
780
|
+
return e < 32 ? 32 : cn(e);
|
|
781
|
+
}
|
|
782
|
+
function cn(e) {
|
|
783
|
+
let n = 2;
|
|
784
|
+
for (; e >>= 1; )
|
|
785
|
+
n <<= 1;
|
|
786
|
+
return n;
|
|
787
|
+
}
|
|
788
|
+
function un(e, n) {
|
|
789
|
+
const t = Math.floor(e.length / n), r = new Float32Array(n);
|
|
790
|
+
for (let o = 0; o < n; o++) {
|
|
791
|
+
const i = t * o;
|
|
792
|
+
let a = 0;
|
|
793
|
+
for (let c = 0; c < t; c++)
|
|
794
|
+
a = a + Math.abs(e[i + c]);
|
|
795
|
+
r[o] = a / t;
|
|
796
|
+
}
|
|
797
|
+
return r;
|
|
798
|
+
}
|
|
799
|
+
function ie(e, n = {}) {
|
|
800
|
+
let t, r;
|
|
801
|
+
typeof n == "string" ? t = n : (t = n == null ? void 0 : n.participantIdentity, r = n == null ? void 0 : n.room);
|
|
802
|
+
const o = he(), i = Xt({ room: r, updateOnlyOn: [] }), a = s.useMemo(() => t ? i.find((p) => p.identity === t) : o, [t, i, o]), c = s.useMemo(() => {
|
|
803
|
+
if (a)
|
|
804
|
+
return Lt(a, { sources: e });
|
|
805
|
+
}, [a, JSON.stringify(e)]);
|
|
806
|
+
return O(c, []);
|
|
807
|
+
}
|
|
808
|
+
function dn(e) {
|
|
809
|
+
var t, r, o;
|
|
810
|
+
const n = s.useMemo(
|
|
811
|
+
() => {
|
|
812
|
+
var i;
|
|
813
|
+
return (i = e == null ? void 0 : e.publication) != null && i.track ? At(e == null ? void 0 : e.publication.track) : void 0;
|
|
814
|
+
},
|
|
815
|
+
[(t = e == null ? void 0 : e.publication) == null ? void 0 : t.track]
|
|
816
|
+
);
|
|
817
|
+
return O(n, {
|
|
818
|
+
timestamp: Date.now(),
|
|
819
|
+
rtpTimestamp: (o = (r = e == null ? void 0 : e.publication) == null ? void 0 : r.track) == null ? void 0 : o.rtpTimestamp
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
const ln = {
|
|
823
|
+
bufferSize: 100
|
|
824
|
+
// maxAge: 2_000,
|
|
825
|
+
};
|
|
826
|
+
function fn(e, n) {
|
|
827
|
+
const t = { ...ln, ...n }, [r, o] = s.useState([]), i = dn(e), a = (c) => {
|
|
828
|
+
var u;
|
|
829
|
+
(u = t.onTranscription) == null || u.call(t, c), o(
|
|
830
|
+
(p) => Ot(
|
|
831
|
+
p,
|
|
832
|
+
// when first receiving a segment, add the current media timestamp to it
|
|
833
|
+
c.map((h) => Dt(h, i)),
|
|
834
|
+
t.bufferSize
|
|
835
|
+
)
|
|
836
|
+
);
|
|
837
|
+
};
|
|
838
|
+
return s.useEffect(() => {
|
|
839
|
+
if (!(e != null && e.publication))
|
|
840
|
+
return;
|
|
841
|
+
const c = Rt(e.publication).subscribe((u) => {
|
|
842
|
+
a(...u);
|
|
843
|
+
});
|
|
844
|
+
return () => {
|
|
845
|
+
c.unsubscribe();
|
|
846
|
+
};
|
|
847
|
+
}, [e && me(e), a]), { segments: r };
|
|
848
|
+
}
|
|
849
|
+
function mn(e = {}) {
|
|
850
|
+
const n = he(), t = e.participant ?? n, r = s.useMemo(
|
|
851
|
+
// weird typescript constraint
|
|
852
|
+
() => t ? le(t) : le(t),
|
|
853
|
+
[t]
|
|
854
|
+
);
|
|
855
|
+
return O(r, {
|
|
856
|
+
attributes: t == null ? void 0 : t.attributes
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function dr(e, n = {}) {
|
|
860
|
+
const t = Y(n.participant), [r, o] = s.useState(t.attributes[e]);
|
|
861
|
+
return s.useEffect(() => {
|
|
862
|
+
if (!t)
|
|
863
|
+
return;
|
|
864
|
+
const i = le(t).subscribe((a) => {
|
|
865
|
+
a.changed[e] !== void 0 && o(a.attributes[e]);
|
|
866
|
+
});
|
|
867
|
+
return () => {
|
|
868
|
+
i.unsubscribe();
|
|
869
|
+
};
|
|
870
|
+
}, [t, e]), r;
|
|
871
|
+
}
|
|
872
|
+
const we = $.AgentState;
|
|
873
|
+
function lr() {
|
|
874
|
+
const e = ve(), n = e.find(
|
|
875
|
+
(l) => l.kind === ae.AGENT && !($.PublishOnBehalf in l.attributes)
|
|
876
|
+
), t = e.find(
|
|
877
|
+
(l) => l.kind === ae.AGENT && l.attributes[$.PublishOnBehalf] === (n == null ? void 0 : n.identity)
|
|
878
|
+
), r = ie(
|
|
879
|
+
[E.Source.Microphone, E.Source.Camera],
|
|
880
|
+
n == null ? void 0 : n.identity
|
|
881
|
+
), o = ie(
|
|
882
|
+
[E.Source.Microphone, E.Source.Camera],
|
|
883
|
+
t == null ? void 0 : t.identity
|
|
884
|
+
), i = r.find((l) => l.source === E.Source.Microphone) ?? o.find((l) => l.source === E.Source.Microphone), a = r.find((l) => l.source === E.Source.Camera) ?? o.find((l) => l.source === E.Source.Camera), { segments: c } = fn(i), u = re(), { attributes: p } = mn({ participant: n }), h = s.useMemo(() => u === I.Disconnected ? "disconnected" : u === I.Connecting || !n || !(p != null && p[we]) ? "connecting" : p[we], [p, n, u]);
|
|
885
|
+
return {
|
|
886
|
+
agent: n,
|
|
887
|
+
state: h,
|
|
888
|
+
audioTrack: i,
|
|
889
|
+
videoTrack: a,
|
|
890
|
+
agentTranscriptions: c,
|
|
891
|
+
agentAttributes: p
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function fr(e) {
|
|
895
|
+
const n = U(e), t = re(n), r = s.useMemo(() => It(n), [n, t]);
|
|
896
|
+
return O(r, n.isRecording);
|
|
897
|
+
}
|
|
898
|
+
function pn(e, n) {
|
|
899
|
+
const t = U(n == null ? void 0 : n.room), o = re(t) === I.Disconnected, i = s.useMemo(() => Nt(t, e), [t, e]);
|
|
900
|
+
return { textStreams: O(o ? void 0 : i, []) };
|
|
901
|
+
}
|
|
902
|
+
function hn(e) {
|
|
903
|
+
const { participantIdentities: n, trackSids: t } = e ?? {}, { textStreams: r } = pn(_t.TRANSCRIPTION, { room: e == null ? void 0 : e.room });
|
|
904
|
+
return s.useMemo(
|
|
905
|
+
() => r.filter(
|
|
906
|
+
(i) => n ? n.includes(i.participantInfo.identity) : !0
|
|
907
|
+
).filter(
|
|
908
|
+
(i) => {
|
|
909
|
+
var a;
|
|
910
|
+
return t ? t.includes(
|
|
911
|
+
((a = i.streamInfo.attributes) == null ? void 0 : a[$.TranscribedTrackId]) ?? ""
|
|
912
|
+
) : !0;
|
|
913
|
+
}
|
|
914
|
+
),
|
|
915
|
+
[r, n, t]
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
const Pe = 2, Le = 400, Ae = 3, Re = 1e3;
|
|
919
|
+
function mr(e) {
|
|
920
|
+
const n = ue([]), t = Be(() => new Bt(), []), r = ne(async () => t.lock().then(async (h) => {
|
|
921
|
+
for (; ; ) {
|
|
922
|
+
const l = n.current.pop();
|
|
923
|
+
if (!l) {
|
|
924
|
+
h();
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
switch (l.type) {
|
|
928
|
+
case "connect":
|
|
929
|
+
await l.room.connect(...l.args).then(l.resolve).catch(l.reject);
|
|
930
|
+
break;
|
|
931
|
+
case "disconnect":
|
|
932
|
+
await l.room.disconnect(...l.args).then(l.resolve).catch(l.reject);
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}), []), o = ue([]), i = ne((h) => {
|
|
937
|
+
let l = 0;
|
|
938
|
+
o.current = o.current.filter((d) => {
|
|
939
|
+
const v = h.getTime() - d.getTime() < Re;
|
|
940
|
+
return v && (l += 1), v;
|
|
941
|
+
}), l > Ae && j.warn(
|
|
942
|
+
`useSequentialRoomConnectDisconnect: room changed reference rapidly (over ${Ae}x in ${Re}ms). This is not recommended.`
|
|
943
|
+
);
|
|
944
|
+
}, []);
|
|
945
|
+
Ve(() => {
|
|
946
|
+
n.current = [];
|
|
947
|
+
const h = /* @__PURE__ */ new Date();
|
|
948
|
+
o.current.push(h), i(h);
|
|
949
|
+
}, [e, i]);
|
|
950
|
+
const a = ue([]), c = ne((h) => {
|
|
951
|
+
let l = 0;
|
|
952
|
+
a.current = a.current.filter((d) => {
|
|
953
|
+
const v = h.getTime() - d.getTime() < Le;
|
|
954
|
+
return v && (l += 1), v;
|
|
955
|
+
}), l > Pe && j.warn(
|
|
956
|
+
`useSequentialRoomConnectDisconnect: room connect / disconnect occurring in rapid sequence (over ${Pe}x in ${Le}ms). This is not recommended and may be the sign of a bug like a useEffect dependency changing every render.`
|
|
957
|
+
);
|
|
958
|
+
}, []), u = ne(
|
|
959
|
+
async (...h) => new Promise((l, d) => {
|
|
960
|
+
if (!e)
|
|
961
|
+
throw new Error("Called connect(), but room was unset");
|
|
962
|
+
const v = /* @__PURE__ */ new Date();
|
|
963
|
+
c(v), n.current.push({ type: "connect", room: e, args: h, resolve: l, reject: d }), a.current.push(v), r();
|
|
964
|
+
}),
|
|
965
|
+
[e, c, r]
|
|
966
|
+
), p = ne(
|
|
967
|
+
async (...h) => new Promise((l, d) => {
|
|
968
|
+
if (!e)
|
|
969
|
+
throw new Error("Called discconnect(), but room was unset");
|
|
970
|
+
const v = /* @__PURE__ */ new Date();
|
|
971
|
+
c(v), n.current.push({ type: "disconnect", room: e, args: h, resolve: l, reject: d }), a.current.push(v), r();
|
|
972
|
+
}),
|
|
973
|
+
[e, c, r]
|
|
974
|
+
);
|
|
975
|
+
return {
|
|
976
|
+
connect: e ? u : null,
|
|
977
|
+
disconnect: e ? p : null
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
var oe = { exports: {} }, Oe;
|
|
981
|
+
function bn() {
|
|
982
|
+
if (Oe) return oe.exports;
|
|
983
|
+
Oe = 1;
|
|
984
|
+
var e = typeof Reflect == "object" ? Reflect : null, n = e && typeof e.apply == "function" ? e.apply : function(f, b, g) {
|
|
985
|
+
return Function.prototype.apply.call(f, b, g);
|
|
986
|
+
}, t;
|
|
987
|
+
e && typeof e.ownKeys == "function" ? t = e.ownKeys : Object.getOwnPropertySymbols ? t = function(f) {
|
|
988
|
+
return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f));
|
|
989
|
+
} : t = function(f) {
|
|
990
|
+
return Object.getOwnPropertyNames(f);
|
|
991
|
+
};
|
|
992
|
+
function r(m) {
|
|
993
|
+
console && console.warn && console.warn(m);
|
|
994
|
+
}
|
|
995
|
+
var o = Number.isNaN || function(f) {
|
|
996
|
+
return f !== f;
|
|
997
|
+
};
|
|
998
|
+
function i() {
|
|
999
|
+
i.init.call(this);
|
|
1000
|
+
}
|
|
1001
|
+
oe.exports = i, oe.exports.once = P, i.EventEmitter = i, i.prototype._events = void 0, i.prototype._eventsCount = 0, i.prototype._maxListeners = void 0;
|
|
1002
|
+
var a = 10;
|
|
1003
|
+
function c(m) {
|
|
1004
|
+
if (typeof m != "function")
|
|
1005
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof m);
|
|
1006
|
+
}
|
|
1007
|
+
Object.defineProperty(i, "defaultMaxListeners", {
|
|
1008
|
+
enumerable: !0,
|
|
1009
|
+
get: function() {
|
|
1010
|
+
return a;
|
|
1011
|
+
},
|
|
1012
|
+
set: function(m) {
|
|
1013
|
+
if (typeof m != "number" || m < 0 || o(m))
|
|
1014
|
+
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + m + ".");
|
|
1015
|
+
a = m;
|
|
1016
|
+
}
|
|
1017
|
+
}), i.init = function() {
|
|
1018
|
+
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
1019
|
+
}, i.prototype.setMaxListeners = function(f) {
|
|
1020
|
+
if (typeof f != "number" || f < 0 || o(f))
|
|
1021
|
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + f + ".");
|
|
1022
|
+
return this._maxListeners = f, this;
|
|
1023
|
+
};
|
|
1024
|
+
function u(m) {
|
|
1025
|
+
return m._maxListeners === void 0 ? i.defaultMaxListeners : m._maxListeners;
|
|
1026
|
+
}
|
|
1027
|
+
i.prototype.getMaxListeners = function() {
|
|
1028
|
+
return u(this);
|
|
1029
|
+
}, i.prototype.emit = function(f) {
|
|
1030
|
+
for (var b = [], g = 1; g < arguments.length; g++) b.push(arguments[g]);
|
|
1031
|
+
var y = f === "error", T = this._events;
|
|
1032
|
+
if (T !== void 0)
|
|
1033
|
+
y = y && T.error === void 0;
|
|
1034
|
+
else if (!y)
|
|
1035
|
+
return !1;
|
|
1036
|
+
if (y) {
|
|
1037
|
+
var C;
|
|
1038
|
+
if (b.length > 0 && (C = b[0]), C instanceof Error)
|
|
1039
|
+
throw C;
|
|
1040
|
+
var k = new Error("Unhandled error." + (C ? " (" + C.message + ")" : ""));
|
|
1041
|
+
throw k.context = C, k;
|
|
1042
|
+
}
|
|
1043
|
+
var F = T[f];
|
|
1044
|
+
if (F === void 0)
|
|
1045
|
+
return !1;
|
|
1046
|
+
if (typeof F == "function")
|
|
1047
|
+
n(F, this, b);
|
|
1048
|
+
else
|
|
1049
|
+
for (var B = F.length, H = M(F, B), g = 0; g < B; ++g)
|
|
1050
|
+
n(H[g], this, b);
|
|
1051
|
+
return !0;
|
|
1052
|
+
};
|
|
1053
|
+
function p(m, f, b, g) {
|
|
1054
|
+
var y, T, C;
|
|
1055
|
+
if (c(b), T = m._events, T === void 0 ? (T = m._events = /* @__PURE__ */ Object.create(null), m._eventsCount = 0) : (T.newListener !== void 0 && (m.emit(
|
|
1056
|
+
"newListener",
|
|
1057
|
+
f,
|
|
1058
|
+
b.listener ? b.listener : b
|
|
1059
|
+
), T = m._events), C = T[f]), C === void 0)
|
|
1060
|
+
C = T[f] = b, ++m._eventsCount;
|
|
1061
|
+
else if (typeof C == "function" ? C = T[f] = g ? [b, C] : [C, b] : g ? C.unshift(b) : C.push(b), y = u(m), y > 0 && C.length > y && !C.warned) {
|
|
1062
|
+
C.warned = !0;
|
|
1063
|
+
var k = new Error("Possible EventEmitter memory leak detected. " + C.length + " " + String(f) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1064
|
+
k.name = "MaxListenersExceededWarning", k.emitter = m, k.type = f, k.count = C.length, r(k);
|
|
1065
|
+
}
|
|
1066
|
+
return m;
|
|
1067
|
+
}
|
|
1068
|
+
i.prototype.addListener = function(f, b) {
|
|
1069
|
+
return p(this, f, b, !1);
|
|
1070
|
+
}, i.prototype.on = i.prototype.addListener, i.prototype.prependListener = function(f, b) {
|
|
1071
|
+
return p(this, f, b, !0);
|
|
1072
|
+
};
|
|
1073
|
+
function h() {
|
|
1074
|
+
if (!this.fired)
|
|
1075
|
+
return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
|
|
1076
|
+
}
|
|
1077
|
+
function l(m, f, b) {
|
|
1078
|
+
var g = { fired: !1, wrapFn: void 0, target: m, type: f, listener: b }, y = h.bind(g);
|
|
1079
|
+
return y.listener = b, g.wrapFn = y, y;
|
|
1080
|
+
}
|
|
1081
|
+
i.prototype.once = function(f, b) {
|
|
1082
|
+
return c(b), this.on(f, l(this, f, b)), this;
|
|
1083
|
+
}, i.prototype.prependOnceListener = function(f, b) {
|
|
1084
|
+
return c(b), this.prependListener(f, l(this, f, b)), this;
|
|
1085
|
+
}, i.prototype.removeListener = function(f, b) {
|
|
1086
|
+
var g, y, T, C, k;
|
|
1087
|
+
if (c(b), y = this._events, y === void 0)
|
|
1088
|
+
return this;
|
|
1089
|
+
if (g = y[f], g === void 0)
|
|
1090
|
+
return this;
|
|
1091
|
+
if (g === b || g.listener === b)
|
|
1092
|
+
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete y[f], y.removeListener && this.emit("removeListener", f, g.listener || b));
|
|
1093
|
+
else if (typeof g != "function") {
|
|
1094
|
+
for (T = -1, C = g.length - 1; C >= 0; C--)
|
|
1095
|
+
if (g[C] === b || g[C].listener === b) {
|
|
1096
|
+
k = g[C].listener, T = C;
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
if (T < 0)
|
|
1100
|
+
return this;
|
|
1101
|
+
T === 0 ? g.shift() : w(g, T), g.length === 1 && (y[f] = g[0]), y.removeListener !== void 0 && this.emit("removeListener", f, k || b);
|
|
1102
|
+
}
|
|
1103
|
+
return this;
|
|
1104
|
+
}, i.prototype.off = i.prototype.removeListener, i.prototype.removeAllListeners = function(f) {
|
|
1105
|
+
var b, g, y;
|
|
1106
|
+
if (g = this._events, g === void 0)
|
|
1107
|
+
return this;
|
|
1108
|
+
if (g.removeListener === void 0)
|
|
1109
|
+
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : g[f] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete g[f]), this;
|
|
1110
|
+
if (arguments.length === 0) {
|
|
1111
|
+
var T = Object.keys(g), C;
|
|
1112
|
+
for (y = 0; y < T.length; ++y)
|
|
1113
|
+
C = T[y], C !== "removeListener" && this.removeAllListeners(C);
|
|
1114
|
+
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
|
|
1115
|
+
}
|
|
1116
|
+
if (b = g[f], typeof b == "function")
|
|
1117
|
+
this.removeListener(f, b);
|
|
1118
|
+
else if (b !== void 0)
|
|
1119
|
+
for (y = b.length - 1; y >= 0; y--)
|
|
1120
|
+
this.removeListener(f, b[y]);
|
|
1121
|
+
return this;
|
|
1122
|
+
};
|
|
1123
|
+
function d(m, f, b) {
|
|
1124
|
+
var g = m._events;
|
|
1125
|
+
if (g === void 0)
|
|
1126
|
+
return [];
|
|
1127
|
+
var y = g[f];
|
|
1128
|
+
return y === void 0 ? [] : typeof y == "function" ? b ? [y.listener || y] : [y] : b ? A(y) : M(y, y.length);
|
|
1129
|
+
}
|
|
1130
|
+
i.prototype.listeners = function(f) {
|
|
1131
|
+
return d(this, f, !0);
|
|
1132
|
+
}, i.prototype.rawListeners = function(f) {
|
|
1133
|
+
return d(this, f, !1);
|
|
1134
|
+
}, i.listenerCount = function(m, f) {
|
|
1135
|
+
return typeof m.listenerCount == "function" ? m.listenerCount(f) : v.call(m, f);
|
|
1136
|
+
}, i.prototype.listenerCount = v;
|
|
1137
|
+
function v(m) {
|
|
1138
|
+
var f = this._events;
|
|
1139
|
+
if (f !== void 0) {
|
|
1140
|
+
var b = f[m];
|
|
1141
|
+
if (typeof b == "function")
|
|
1142
|
+
return 1;
|
|
1143
|
+
if (b !== void 0)
|
|
1144
|
+
return b.length;
|
|
1145
|
+
}
|
|
1146
|
+
return 0;
|
|
1147
|
+
}
|
|
1148
|
+
i.prototype.eventNames = function() {
|
|
1149
|
+
return this._eventsCount > 0 ? t(this._events) : [];
|
|
1150
|
+
};
|
|
1151
|
+
function M(m, f) {
|
|
1152
|
+
for (var b = new Array(f), g = 0; g < f; ++g)
|
|
1153
|
+
b[g] = m[g];
|
|
1154
|
+
return b;
|
|
1155
|
+
}
|
|
1156
|
+
function w(m, f) {
|
|
1157
|
+
for (; f + 1 < m.length; f++)
|
|
1158
|
+
m[f] = m[f + 1];
|
|
1159
|
+
m.pop();
|
|
1160
|
+
}
|
|
1161
|
+
function A(m) {
|
|
1162
|
+
for (var f = new Array(m.length), b = 0; b < f.length; ++b)
|
|
1163
|
+
f[b] = m[b].listener || m[b];
|
|
1164
|
+
return f;
|
|
1165
|
+
}
|
|
1166
|
+
function P(m, f) {
|
|
1167
|
+
return new Promise(function(b, g) {
|
|
1168
|
+
function y(C) {
|
|
1169
|
+
m.removeListener(f, T), g(C);
|
|
1170
|
+
}
|
|
1171
|
+
function T() {
|
|
1172
|
+
typeof m.removeListener == "function" && m.removeListener("error", y), b([].slice.call(arguments));
|
|
1173
|
+
}
|
|
1174
|
+
R(m, f, T, { once: !0 }), f !== "error" && D(m, y, { once: !0 });
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
function D(m, f, b) {
|
|
1178
|
+
typeof m.on == "function" && R(m, "error", f, b);
|
|
1179
|
+
}
|
|
1180
|
+
function R(m, f, b, g) {
|
|
1181
|
+
if (typeof m.on == "function")
|
|
1182
|
+
g.once ? m.once(f, b) : m.on(f, b);
|
|
1183
|
+
else if (typeof m.addEventListener == "function")
|
|
1184
|
+
m.addEventListener(f, function y(T) {
|
|
1185
|
+
g.once && m.removeEventListener(f, y), b(T);
|
|
1186
|
+
});
|
|
1187
|
+
else
|
|
1188
|
+
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof m);
|
|
1189
|
+
}
|
|
1190
|
+
return oe.exports;
|
|
1191
|
+
}
|
|
1192
|
+
var ge = bn();
|
|
1193
|
+
const vn = 2e4;
|
|
1194
|
+
var gn = /* @__PURE__ */ ((e) => (e.CameraChanged = "cameraChanged", e.MicrophoneChanged = "microphoneChanged", e.StateChanged = "stateChanged", e))(gn || {});
|
|
1195
|
+
const x = (e) => ({
|
|
1196
|
+
isConnected: e === "listening" || e === "thinking" || e === "speaking",
|
|
1197
|
+
canListen: e === "pre-connect-buffering" || e === "listening" || e === "thinking" || e === "speaking",
|
|
1198
|
+
isFinished: e === "disconnected" || e === "failed",
|
|
1199
|
+
isPending: e === "connecting" || e === "initializing" || e === "idle"
|
|
1200
|
+
}), Sn = () => {
|
|
1201
|
+
const [e, n] = s.useState(
|
|
1202
|
+
null
|
|
1203
|
+
), [t, r] = s.useState(
|
|
1204
|
+
null
|
|
1205
|
+
), o = s.useRef("connecting"), i = s.useRef(!1), a = (c) => setTimeout(() => {
|
|
1206
|
+
if (!i.current) {
|
|
1207
|
+
n("Agent did not join the room.");
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
const { isConnected: u } = x(o.current);
|
|
1211
|
+
if (!u) {
|
|
1212
|
+
n("Agent joined the room but did not complete initializing.");
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
}, c ?? vn);
|
|
1216
|
+
return {
|
|
1217
|
+
agentTimeoutFailureReason: e,
|
|
1218
|
+
startAgentTimeout: s.useCallback(
|
|
1219
|
+
(c) => {
|
|
1220
|
+
t && clearTimeout(t), n(null), r(a(c)), o.current = "connecting", i.current = !1;
|
|
1221
|
+
},
|
|
1222
|
+
[t]
|
|
1223
|
+
),
|
|
1224
|
+
clearAgentTimeout: s.useCallback(() => {
|
|
1225
|
+
t && clearTimeout(t), n(null), r(null), o.current = "connecting", i.current = !1;
|
|
1226
|
+
}, [t]),
|
|
1227
|
+
clearAgentTimeoutFailureReason: s.useCallback(() => {
|
|
1228
|
+
n(null);
|
|
1229
|
+
}, []),
|
|
1230
|
+
updateAgentTimeoutState: s.useCallback((c) => {
|
|
1231
|
+
o.current = c;
|
|
1232
|
+
}, []),
|
|
1233
|
+
updateAgentTimeoutParticipantExists: s.useCallback((c) => {
|
|
1234
|
+
i.current = c;
|
|
1235
|
+
}, [])
|
|
1236
|
+
};
|
|
1237
|
+
};
|
|
1238
|
+
function yn(e, n) {
|
|
1239
|
+
const t = s.useRef(n);
|
|
1240
|
+
s.useEffect(() => {
|
|
1241
|
+
t.current = n;
|
|
1242
|
+
}, [n]);
|
|
1243
|
+
const r = s.useCallback(
|
|
1244
|
+
async (a) => {
|
|
1245
|
+
const { isConnected: c } = x(t.current);
|
|
1246
|
+
if (!c)
|
|
1247
|
+
return new Promise((u, p) => {
|
|
1248
|
+
const h = (v) => {
|
|
1249
|
+
const { isConnected: M } = x(v);
|
|
1250
|
+
M && (d(), u());
|
|
1251
|
+
}, l = () => {
|
|
1252
|
+
d(), p(new Error("useAgent(/* ... */).waitUntilConnected - signal aborted"));
|
|
1253
|
+
}, d = () => {
|
|
1254
|
+
e.off("stateChanged", h), a == null || a.removeEventListener("abort", l);
|
|
1255
|
+
};
|
|
1256
|
+
e.on("stateChanged", h), a == null || a.addEventListener("abort", l);
|
|
1257
|
+
});
|
|
1258
|
+
},
|
|
1259
|
+
[e]
|
|
1260
|
+
), o = s.useCallback(
|
|
1261
|
+
async (a) => {
|
|
1262
|
+
const { canListen: c } = x(t.current);
|
|
1263
|
+
if (!c)
|
|
1264
|
+
return new Promise((u, p) => {
|
|
1265
|
+
const h = (v) => {
|
|
1266
|
+
const { canListen: M } = x(v);
|
|
1267
|
+
M && (d(), u());
|
|
1268
|
+
}, l = () => {
|
|
1269
|
+
d(), p(new Error("useAgent(/* ... */).waitUntilCouldBeListening - signal aborted"));
|
|
1270
|
+
}, d = () => {
|
|
1271
|
+
e.off("stateChanged", h), a == null || a.removeEventListener("abort", l);
|
|
1272
|
+
};
|
|
1273
|
+
e.on("stateChanged", h), a == null || a.addEventListener("abort", l);
|
|
1274
|
+
});
|
|
1275
|
+
},
|
|
1276
|
+
[e]
|
|
1277
|
+
), i = s.useCallback(
|
|
1278
|
+
async (a) => {
|
|
1279
|
+
const { isFinished: c } = x(t.current);
|
|
1280
|
+
if (!c)
|
|
1281
|
+
return new Promise((u, p) => {
|
|
1282
|
+
const h = (v) => {
|
|
1283
|
+
const { isFinished: M } = x(v);
|
|
1284
|
+
M && (d(), u());
|
|
1285
|
+
}, l = () => {
|
|
1286
|
+
d(), p(new Error("useAgent(/* ... */).waitUntilFinished - signal aborted"));
|
|
1287
|
+
}, d = () => {
|
|
1288
|
+
e.off("stateChanged", h), a == null || a.removeEventListener("abort", l);
|
|
1289
|
+
};
|
|
1290
|
+
e.on("stateChanged", h), a == null || a.addEventListener("abort", l);
|
|
1291
|
+
});
|
|
1292
|
+
},
|
|
1293
|
+
[e]
|
|
1294
|
+
);
|
|
1295
|
+
return { waitUntilConnected: r, waitUntilCouldBeListening: o, waitUntilFinished: i };
|
|
1296
|
+
}
|
|
1297
|
+
function Ue(e) {
|
|
1298
|
+
const n = Ft();
|
|
1299
|
+
if (e = e ?? n, !e)
|
|
1300
|
+
throw new Error(
|
|
1301
|
+
"No session provided, make sure you are inside a Session context or pass the session explicitly"
|
|
1302
|
+
);
|
|
1303
|
+
const {
|
|
1304
|
+
room: t,
|
|
1305
|
+
internal: {
|
|
1306
|
+
agentConnectTimeoutMilliseconds: r,
|
|
1307
|
+
agentTimeoutFailureReason: o,
|
|
1308
|
+
startAgentTimeout: i,
|
|
1309
|
+
clearAgentTimeout: a,
|
|
1310
|
+
clearAgentTimeoutFailureReason: c,
|
|
1311
|
+
updateAgentTimeoutState: u,
|
|
1312
|
+
updateAgentTimeoutParticipantExists: p
|
|
1313
|
+
}
|
|
1314
|
+
} = e, h = s.useMemo(() => new ge.EventEmitter(), []), l = ve({ room: t }), d = s.useMemo(() => l.find(
|
|
1315
|
+
(S) => S.kind === ae.AGENT && !($.PublishOnBehalf in S.attributes)
|
|
1316
|
+
) ?? null, [l]), v = s.useMemo(() => d ? l.find(
|
|
1317
|
+
(S) => S.kind === ae.AGENT && S.attributes[$.PublishOnBehalf] === d.identity
|
|
1318
|
+
) ?? null : null, [d, l]), [M, w] = s.useState((d == null ? void 0 : d.attributes) ?? {});
|
|
1319
|
+
s.useEffect(() => {
|
|
1320
|
+
if (!d)
|
|
1321
|
+
return;
|
|
1322
|
+
const S = (_) => {
|
|
1323
|
+
w(_);
|
|
1324
|
+
};
|
|
1325
|
+
return d.on(ee.AttributesChanged, S), () => {
|
|
1326
|
+
d.off(ee.AttributesChanged, S);
|
|
1327
|
+
};
|
|
1328
|
+
}, [d, h]);
|
|
1329
|
+
const A = ie([E.Source.Camera, E.Source.Microphone], {
|
|
1330
|
+
room: t,
|
|
1331
|
+
participantIdentity: d == null ? void 0 : d.identity
|
|
1332
|
+
}), P = ie([E.Source.Camera, E.Source.Microphone], {
|
|
1333
|
+
room: t,
|
|
1334
|
+
participantIdentity: v == null ? void 0 : v.identity
|
|
1335
|
+
}), D = s.useMemo(
|
|
1336
|
+
() => A.find((S) => S.source === E.Source.Camera) ?? P.find((S) => S.source === E.Source.Camera),
|
|
1337
|
+
[A, P]
|
|
1338
|
+
);
|
|
1339
|
+
s.useEffect(() => {
|
|
1340
|
+
h.emit("cameraChanged", D);
|
|
1341
|
+
}, [h, D]);
|
|
1342
|
+
const R = s.useMemo(
|
|
1343
|
+
() => A.find((S) => S.source === E.Source.Microphone) ?? P.find((S) => S.source === E.Source.Microphone),
|
|
1344
|
+
[A, P]
|
|
1345
|
+
);
|
|
1346
|
+
s.useEffect(() => {
|
|
1347
|
+
h.emit("microphoneChanged", R);
|
|
1348
|
+
}, [h, R]);
|
|
1349
|
+
const [m, f] = s.useState(t.state);
|
|
1350
|
+
s.useEffect(() => {
|
|
1351
|
+
const S = (_) => {
|
|
1352
|
+
f(_);
|
|
1353
|
+
};
|
|
1354
|
+
return t.on(V.ConnectionStateChanged, S), () => {
|
|
1355
|
+
t.off(V.ConnectionStateChanged, S);
|
|
1356
|
+
};
|
|
1357
|
+
}, [t]), s.useEffect(() => {
|
|
1358
|
+
d && c();
|
|
1359
|
+
}, [d]);
|
|
1360
|
+
const [b, g] = s.useState(null);
|
|
1361
|
+
s.useEffect(() => {
|
|
1362
|
+
if (!d)
|
|
1363
|
+
return;
|
|
1364
|
+
const S = (_) => {
|
|
1365
|
+
_.identity === (d == null ? void 0 : d.identity) && g("Agent left the room unexpectedly.");
|
|
1366
|
+
};
|
|
1367
|
+
return t.on(V.ParticipantDisconnected, S), () => {
|
|
1368
|
+
t.off(V.ParticipantDisconnected, S);
|
|
1369
|
+
};
|
|
1370
|
+
}, [d, t]), s.useEffect(() => {
|
|
1371
|
+
m === I.Disconnected && g(null);
|
|
1372
|
+
}, [m]);
|
|
1373
|
+
const [y, T] = s.useState(
|
|
1374
|
+
() => t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null
|
|
1375
|
+
);
|
|
1376
|
+
s.useEffect(() => {
|
|
1377
|
+
const S = () => {
|
|
1378
|
+
T(t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null);
|
|
1379
|
+
}, _ = () => {
|
|
1380
|
+
T(null);
|
|
1381
|
+
};
|
|
1382
|
+
return t.localParticipant.on(
|
|
1383
|
+
ee.LocalTrackPublished,
|
|
1384
|
+
S
|
|
1385
|
+
), t.localParticipant.on(
|
|
1386
|
+
ee.LocalTrackUnpublished,
|
|
1387
|
+
_
|
|
1388
|
+
), () => {
|
|
1389
|
+
t.localParticipant.off(
|
|
1390
|
+
ee.LocalTrackPublished,
|
|
1391
|
+
S
|
|
1392
|
+
), t.localParticipant.off(
|
|
1393
|
+
ee.LocalTrackUnpublished,
|
|
1394
|
+
_
|
|
1395
|
+
);
|
|
1396
|
+
};
|
|
1397
|
+
}, [t.localParticipant]);
|
|
1398
|
+
const C = s.useMemo(() => {
|
|
1399
|
+
const S = [];
|
|
1400
|
+
return o && S.push(o), b && S.push(b), S;
|
|
1401
|
+
}, [o, b]), k = s.useMemo(() => {
|
|
1402
|
+
if (C.length > 0)
|
|
1403
|
+
return "failed";
|
|
1404
|
+
let S = "disconnected";
|
|
1405
|
+
return m !== I.Disconnected && (S = "connecting"), y && (S = "pre-connect-buffering"), d && M[$.AgentState] && (S = M[$.AgentState]), S;
|
|
1406
|
+
}, [
|
|
1407
|
+
C,
|
|
1408
|
+
m,
|
|
1409
|
+
y,
|
|
1410
|
+
d,
|
|
1411
|
+
M
|
|
1412
|
+
]);
|
|
1413
|
+
s.useEffect(() => {
|
|
1414
|
+
h.emit("stateChanged", k), u(k);
|
|
1415
|
+
}, [h, k]), s.useEffect(() => {
|
|
1416
|
+
p(d !== null);
|
|
1417
|
+
}, [d]);
|
|
1418
|
+
const F = e.connectionState === "disconnected";
|
|
1419
|
+
s.useEffect(() => {
|
|
1420
|
+
if (!F)
|
|
1421
|
+
return i(r), () => {
|
|
1422
|
+
a();
|
|
1423
|
+
};
|
|
1424
|
+
}, [F, r]);
|
|
1425
|
+
const {
|
|
1426
|
+
identity: B,
|
|
1427
|
+
name: H,
|
|
1428
|
+
metadata: K
|
|
1429
|
+
} = Yt({ participant: d ?? void 0 }), te = s.useMemo(() => {
|
|
1430
|
+
const S = {
|
|
1431
|
+
attributes: M,
|
|
1432
|
+
internal: {
|
|
1433
|
+
agentParticipant: d,
|
|
1434
|
+
workerParticipant: v,
|
|
1435
|
+
emitter: h
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
switch (k) {
|
|
1439
|
+
case "disconnected":
|
|
1440
|
+
return {
|
|
1441
|
+
...S,
|
|
1442
|
+
identity: void 0,
|
|
1443
|
+
name: void 0,
|
|
1444
|
+
metadata: void 0,
|
|
1445
|
+
state: k,
|
|
1446
|
+
...x(k),
|
|
1447
|
+
failureReasons: null,
|
|
1448
|
+
// Clear inner values if no longer connected
|
|
1449
|
+
cameraTrack: void 0,
|
|
1450
|
+
microphoneTrack: void 0
|
|
1451
|
+
};
|
|
1452
|
+
case "connecting":
|
|
1453
|
+
return {
|
|
1454
|
+
...S,
|
|
1455
|
+
identity: void 0,
|
|
1456
|
+
name: void 0,
|
|
1457
|
+
metadata: void 0,
|
|
1458
|
+
state: k,
|
|
1459
|
+
...x(k),
|
|
1460
|
+
failureReasons: null,
|
|
1461
|
+
// Clear inner values if no longer connected
|
|
1462
|
+
cameraTrack: void 0,
|
|
1463
|
+
microphoneTrack: void 0
|
|
1464
|
+
};
|
|
1465
|
+
case "initializing":
|
|
1466
|
+
case "idle":
|
|
1467
|
+
return {
|
|
1468
|
+
...S,
|
|
1469
|
+
identity: B,
|
|
1470
|
+
name: H,
|
|
1471
|
+
metadata: K,
|
|
1472
|
+
state: k,
|
|
1473
|
+
...x(k),
|
|
1474
|
+
failureReasons: null,
|
|
1475
|
+
cameraTrack: D,
|
|
1476
|
+
microphoneTrack: R
|
|
1477
|
+
};
|
|
1478
|
+
case "pre-connect-buffering":
|
|
1479
|
+
return {
|
|
1480
|
+
...S,
|
|
1481
|
+
identity: B,
|
|
1482
|
+
name: H,
|
|
1483
|
+
metadata: K,
|
|
1484
|
+
state: k,
|
|
1485
|
+
...x(k),
|
|
1486
|
+
failureReasons: null,
|
|
1487
|
+
cameraTrack: D,
|
|
1488
|
+
microphoneTrack: R
|
|
1489
|
+
};
|
|
1490
|
+
case "listening":
|
|
1491
|
+
case "thinking":
|
|
1492
|
+
case "speaking":
|
|
1493
|
+
return {
|
|
1494
|
+
...S,
|
|
1495
|
+
identity: B,
|
|
1496
|
+
name: H,
|
|
1497
|
+
metadata: K,
|
|
1498
|
+
state: k,
|
|
1499
|
+
...x(k),
|
|
1500
|
+
failureReasons: null,
|
|
1501
|
+
cameraTrack: D,
|
|
1502
|
+
microphoneTrack: R
|
|
1503
|
+
};
|
|
1504
|
+
case "failed":
|
|
1505
|
+
return {
|
|
1506
|
+
...S,
|
|
1507
|
+
identity: void 0,
|
|
1508
|
+
name: void 0,
|
|
1509
|
+
metadata: void 0,
|
|
1510
|
+
state: "failed",
|
|
1511
|
+
...x("failed"),
|
|
1512
|
+
failureReasons: C,
|
|
1513
|
+
// Clear inner values if no longer connected
|
|
1514
|
+
cameraTrack: void 0,
|
|
1515
|
+
microphoneTrack: void 0
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
}, [
|
|
1519
|
+
B,
|
|
1520
|
+
H,
|
|
1521
|
+
K,
|
|
1522
|
+
M,
|
|
1523
|
+
h,
|
|
1524
|
+
d,
|
|
1525
|
+
k,
|
|
1526
|
+
D,
|
|
1527
|
+
R
|
|
1528
|
+
]), { waitUntilConnected: X, waitUntilCouldBeListening: L, waitUntilFinished: N } = yn(h, k), q = s.useCallback(
|
|
1529
|
+
(S) => new Promise((_, Z) => {
|
|
1530
|
+
const W = (J) => {
|
|
1531
|
+
J && (G(), _(J));
|
|
1532
|
+
}, z = () => {
|
|
1533
|
+
G(), Z(new Error("useAgent(/* ... */).waitUntilCamera - signal aborted"));
|
|
1534
|
+
}, G = () => {
|
|
1535
|
+
h.off("cameraChanged", W), S == null || S.removeEventListener("abort", z);
|
|
1536
|
+
};
|
|
1537
|
+
h.on("cameraChanged", W), S == null || S.addEventListener("abort", z);
|
|
1538
|
+
}),
|
|
1539
|
+
[h]
|
|
1540
|
+
), se = s.useCallback(
|
|
1541
|
+
(S) => new Promise((_, Z) => {
|
|
1542
|
+
const W = (J) => {
|
|
1543
|
+
J && (G(), _(J));
|
|
1544
|
+
}, z = () => {
|
|
1545
|
+
G(), Z(new Error("useAgent(/* ... */).waitUntilMicrophone - signal aborted"));
|
|
1546
|
+
}, G = () => {
|
|
1547
|
+
h.off("microphoneChanged", W), S == null || S.removeEventListener("abort", z);
|
|
1548
|
+
};
|
|
1549
|
+
h.on("microphoneChanged", W), S == null || S.addEventListener("abort", z);
|
|
1550
|
+
}),
|
|
1551
|
+
[h]
|
|
1552
|
+
);
|
|
1553
|
+
return s.useMemo(() => ({
|
|
1554
|
+
...te,
|
|
1555
|
+
waitUntilConnected: X,
|
|
1556
|
+
waitUntilCouldBeListening: L,
|
|
1557
|
+
waitUntilFinished: N,
|
|
1558
|
+
waitUntilCamera: q,
|
|
1559
|
+
waitUntilMicrophone: se
|
|
1560
|
+
}), [
|
|
1561
|
+
te,
|
|
1562
|
+
X,
|
|
1563
|
+
L,
|
|
1564
|
+
N,
|
|
1565
|
+
q,
|
|
1566
|
+
se
|
|
1567
|
+
]);
|
|
1568
|
+
}
|
|
1569
|
+
var Cn = /* @__PURE__ */ ((e) => (e.ConnectionStateChanged = "connectionStateChanged", e.MediaDevicesError = "mediaDevicesError", e.EncryptionError = "encryptionError", e))(Cn || {});
|
|
1570
|
+
function Mn(e, n) {
|
|
1571
|
+
const t = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)]);
|
|
1572
|
+
for (const r of t)
|
|
1573
|
+
switch (r) {
|
|
1574
|
+
case "roomName":
|
|
1575
|
+
case "participantName":
|
|
1576
|
+
case "participantIdentity":
|
|
1577
|
+
case "participantMetadata":
|
|
1578
|
+
case "participantAttributes":
|
|
1579
|
+
case "agentName":
|
|
1580
|
+
case "agentMetadata":
|
|
1581
|
+
if (e[r] !== n[r])
|
|
1582
|
+
return !1;
|
|
1583
|
+
break;
|
|
1584
|
+
default:
|
|
1585
|
+
const o = r;
|
|
1586
|
+
throw new Error(`Options key ${o} not being checked for equality!`);
|
|
1587
|
+
}
|
|
1588
|
+
return !0;
|
|
1589
|
+
}
|
|
1590
|
+
function Tn(e, n) {
|
|
1591
|
+
const t = s.useRef(n);
|
|
1592
|
+
return s.useEffect(() => {
|
|
1593
|
+
t.current = n;
|
|
1594
|
+
}, [n]), s.useCallback(
|
|
1595
|
+
async (o, i) => {
|
|
1596
|
+
if (t.current !== o)
|
|
1597
|
+
return new Promise((a, c) => {
|
|
1598
|
+
const u = (l) => {
|
|
1599
|
+
l === o && (h(), a());
|
|
1600
|
+
}, p = () => {
|
|
1601
|
+
h(), c(
|
|
1602
|
+
new Error(
|
|
1603
|
+
`useSession(/* ... */).waitUntilConnectionState(${o}, /* signal */) - signal aborted`
|
|
1604
|
+
)
|
|
1605
|
+
);
|
|
1606
|
+
}, h = () => {
|
|
1607
|
+
e.off("connectionStateChanged", u), i == null || i.removeEventListener("abort", p);
|
|
1608
|
+
};
|
|
1609
|
+
e.on("connectionStateChanged", u), i == null || i.addEventListener("abort", p);
|
|
1610
|
+
});
|
|
1611
|
+
},
|
|
1612
|
+
[e]
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
function En(e, n) {
|
|
1616
|
+
const t = e instanceof qt, r = s.useRef(
|
|
1617
|
+
t ? n : null
|
|
1618
|
+
);
|
|
1619
|
+
return s.useEffect(() => {
|
|
1620
|
+
if (!t) {
|
|
1621
|
+
r.current = null;
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
r.current !== null && Mn(r.current, n) || (r.current = n);
|
|
1625
|
+
}, [t, n]), s.useCallback(async () => {
|
|
1626
|
+
if (t) {
|
|
1627
|
+
if (!r.current)
|
|
1628
|
+
throw new Error(
|
|
1629
|
+
"AgentSession - memoized token fetch options are not set, but the passed tokenSource was an instance of TokenSourceConfigurable. If you are seeing this please make a new GitHub issue!"
|
|
1630
|
+
);
|
|
1631
|
+
return e.fetch(r.current);
|
|
1632
|
+
} else
|
|
1633
|
+
return e.fetch();
|
|
1634
|
+
}, [t, e]);
|
|
1635
|
+
}
|
|
1636
|
+
function pr(e, n = {}) {
|
|
1637
|
+
const { room: t, agentConnectTimeoutMilliseconds: r, ...o } = n, i = pe(), a = s.useMemo(
|
|
1638
|
+
() => i ?? t ?? new Fe(),
|
|
1639
|
+
[i, t]
|
|
1640
|
+
), c = s.useMemo(
|
|
1641
|
+
() => new ge.EventEmitter(),
|
|
1642
|
+
[]
|
|
1643
|
+
), u = s.useCallback(
|
|
1644
|
+
(L) => ({
|
|
1645
|
+
isConnected: L === I.Connected || L === I.Reconnecting || L === I.SignalReconnecting
|
|
1646
|
+
}),
|
|
1647
|
+
[]
|
|
1648
|
+
), [p, h] = s.useState(a.state);
|
|
1649
|
+
s.useEffect(() => {
|
|
1650
|
+
const L = (N) => {
|
|
1651
|
+
h(N);
|
|
1652
|
+
};
|
|
1653
|
+
return a.on(V.ConnectionStateChanged, L), () => {
|
|
1654
|
+
a.off(V.ConnectionStateChanged, L);
|
|
1655
|
+
};
|
|
1656
|
+
}, [a]), s.useEffect(() => {
|
|
1657
|
+
const L = async (N) => {
|
|
1658
|
+
c.emit("mediaDevicesError", N);
|
|
1659
|
+
};
|
|
1660
|
+
return a.on(V.MediaDevicesError, L), () => {
|
|
1661
|
+
a.off(V.MediaDevicesError, L);
|
|
1662
|
+
};
|
|
1663
|
+
}, [a, c]), s.useEffect(() => {
|
|
1664
|
+
const L = async (N) => {
|
|
1665
|
+
c.emit("encryptionError", N);
|
|
1666
|
+
};
|
|
1667
|
+
return a.on(V.EncryptionError, L), () => {
|
|
1668
|
+
a.off(V.EncryptionError, L);
|
|
1669
|
+
};
|
|
1670
|
+
}, [a, c]);
|
|
1671
|
+
const { localParticipant: l } = xe({ room: a }), d = l.getTrackPublication(E.Source.Camera), v = s.useMemo(() => {
|
|
1672
|
+
if (d)
|
|
1673
|
+
return {
|
|
1674
|
+
source: E.Source.Camera,
|
|
1675
|
+
participant: l,
|
|
1676
|
+
publication: d
|
|
1677
|
+
};
|
|
1678
|
+
}, [l, d]), M = l.getTrackPublication(E.Source.Microphone), w = s.useMemo(() => {
|
|
1679
|
+
if (M)
|
|
1680
|
+
return {
|
|
1681
|
+
source: E.Source.Microphone,
|
|
1682
|
+
participant: l,
|
|
1683
|
+
publication: M
|
|
1684
|
+
};
|
|
1685
|
+
}, [l, M]), A = l.getTrackPublication(E.Source.ScreenShare), P = s.useMemo(() => {
|
|
1686
|
+
if (A)
|
|
1687
|
+
return {
|
|
1688
|
+
source: E.Source.ScreenShare,
|
|
1689
|
+
participant: l,
|
|
1690
|
+
publication: A
|
|
1691
|
+
};
|
|
1692
|
+
}, [l, A]), {
|
|
1693
|
+
agentTimeoutFailureReason: D,
|
|
1694
|
+
startAgentTimeout: R,
|
|
1695
|
+
clearAgentTimeout: m,
|
|
1696
|
+
clearAgentTimeoutFailureReason: f,
|
|
1697
|
+
updateAgentTimeoutState: b,
|
|
1698
|
+
updateAgentTimeoutParticipantExists: g
|
|
1699
|
+
} = Sn(), y = s.useMemo(
|
|
1700
|
+
() => ({
|
|
1701
|
+
emitter: c,
|
|
1702
|
+
tokenSource: e,
|
|
1703
|
+
agentConnectTimeoutMilliseconds: r,
|
|
1704
|
+
agentTimeoutFailureReason: D,
|
|
1705
|
+
startAgentTimeout: R,
|
|
1706
|
+
clearAgentTimeout: m,
|
|
1707
|
+
clearAgentTimeoutFailureReason: f,
|
|
1708
|
+
updateAgentTimeoutState: b,
|
|
1709
|
+
updateAgentTimeoutParticipantExists: g
|
|
1710
|
+
}),
|
|
1711
|
+
[
|
|
1712
|
+
c,
|
|
1713
|
+
r,
|
|
1714
|
+
e,
|
|
1715
|
+
D,
|
|
1716
|
+
R,
|
|
1717
|
+
m,
|
|
1718
|
+
f,
|
|
1719
|
+
b,
|
|
1720
|
+
g
|
|
1721
|
+
]
|
|
1722
|
+
), T = s.useMemo(() => {
|
|
1723
|
+
const L = {
|
|
1724
|
+
room: a,
|
|
1725
|
+
internal: y
|
|
1726
|
+
};
|
|
1727
|
+
switch (p) {
|
|
1728
|
+
case I.Connecting:
|
|
1729
|
+
return {
|
|
1730
|
+
...L,
|
|
1731
|
+
connectionState: I.Connecting,
|
|
1732
|
+
...u(I.Connecting),
|
|
1733
|
+
local: {
|
|
1734
|
+
cameraTrack: void 0,
|
|
1735
|
+
microphoneTrack: void 0,
|
|
1736
|
+
screenShareTrack: void 0
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
case I.Connected:
|
|
1740
|
+
case I.Reconnecting:
|
|
1741
|
+
case I.SignalReconnecting:
|
|
1742
|
+
return {
|
|
1743
|
+
...L,
|
|
1744
|
+
connectionState: p,
|
|
1745
|
+
...u(p),
|
|
1746
|
+
local: {
|
|
1747
|
+
cameraTrack: v,
|
|
1748
|
+
microphoneTrack: w,
|
|
1749
|
+
screenShareTrack: P
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
case I.Disconnected:
|
|
1753
|
+
return {
|
|
1754
|
+
...L,
|
|
1755
|
+
connectionState: I.Disconnected,
|
|
1756
|
+
...u(I.Disconnected),
|
|
1757
|
+
local: {
|
|
1758
|
+
cameraTrack: void 0,
|
|
1759
|
+
microphoneTrack: void 0,
|
|
1760
|
+
screenShareTrack: void 0
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
}, [
|
|
1765
|
+
y,
|
|
1766
|
+
a,
|
|
1767
|
+
p,
|
|
1768
|
+
v,
|
|
1769
|
+
w,
|
|
1770
|
+
u
|
|
1771
|
+
]);
|
|
1772
|
+
s.useEffect(() => {
|
|
1773
|
+
c.emit("connectionStateChanged", T.connectionState);
|
|
1774
|
+
}, [c, T.connectionState]);
|
|
1775
|
+
const C = Tn(
|
|
1776
|
+
c,
|
|
1777
|
+
T.connectionState
|
|
1778
|
+
), k = s.useCallback(
|
|
1779
|
+
async (L) => C(
|
|
1780
|
+
I.Connected,
|
|
1781
|
+
L
|
|
1782
|
+
),
|
|
1783
|
+
[C]
|
|
1784
|
+
), F = s.useCallback(
|
|
1785
|
+
async (L) => C(I.Disconnected, L),
|
|
1786
|
+
[C]
|
|
1787
|
+
), B = Ue(
|
|
1788
|
+
s.useMemo(
|
|
1789
|
+
() => ({
|
|
1790
|
+
connectionState: T.connectionState,
|
|
1791
|
+
room: a,
|
|
1792
|
+
internal: y
|
|
1793
|
+
}),
|
|
1794
|
+
[T, a, y]
|
|
1795
|
+
)
|
|
1796
|
+
), H = En(e, o), K = s.useCallback(
|
|
1797
|
+
async (L = {}) => {
|
|
1798
|
+
var Z, W, z, G, J, Se;
|
|
1799
|
+
const {
|
|
1800
|
+
signal: N,
|
|
1801
|
+
tracks: q = { microphone: { enabled: !0, publishOptions: { preConnectBuffer: !0 } } },
|
|
1802
|
+
roomConnectOptions: se
|
|
1803
|
+
} = L;
|
|
1804
|
+
await F(N);
|
|
1805
|
+
const S = () => {
|
|
1806
|
+
a.disconnect();
|
|
1807
|
+
};
|
|
1808
|
+
N == null || N.addEventListener("abort", S);
|
|
1809
|
+
let _ = !1;
|
|
1810
|
+
await Promise.all([
|
|
1811
|
+
H().then(({ serverUrl: He, participantToken: ye }) => {
|
|
1812
|
+
var Ce, Me;
|
|
1813
|
+
return _ = (((Me = (Ce = Vt(ye).roomConfig) == null ? void 0 : Ce.agents) == null ? void 0 : Me.length) ?? 0) > 0, a.connect(He, ye, se);
|
|
1814
|
+
}),
|
|
1815
|
+
// Start microphone (with preconnect buffer) by default
|
|
1816
|
+
(Z = q.microphone) != null && Z.enabled ? a.localParticipant.setMicrophoneEnabled(
|
|
1817
|
+
!0,
|
|
1818
|
+
void 0,
|
|
1819
|
+
((W = q.microphone) == null ? void 0 : W.publishOptions) ?? {}
|
|
1820
|
+
) : Promise.resolve(),
|
|
1821
|
+
(z = q.camera) != null && z.enabled ? a.localParticipant.setCameraEnabled(
|
|
1822
|
+
!0,
|
|
1823
|
+
void 0,
|
|
1824
|
+
((G = q.camera) == null ? void 0 : G.publishOptions) ?? {}
|
|
1825
|
+
) : Promise.resolve(),
|
|
1826
|
+
(J = q.screenShare) != null && J.enabled ? a.localParticipant.setScreenShareEnabled(
|
|
1827
|
+
!0,
|
|
1828
|
+
void 0,
|
|
1829
|
+
((Se = q.screenShare) == null ? void 0 : Se.publishOptions) ?? {}
|
|
1830
|
+
) : Promise.resolve()
|
|
1831
|
+
]), await k(N), _ && await B.waitUntilConnected(N), N == null || N.removeEventListener("abort", S);
|
|
1832
|
+
},
|
|
1833
|
+
[a, F, H, k, B.waitUntilConnected]
|
|
1834
|
+
), te = s.useCallback(async () => {
|
|
1835
|
+
await a.disconnect();
|
|
1836
|
+
}, [a]), X = s.useCallback(async () => {
|
|
1837
|
+
const L = await H();
|
|
1838
|
+
await a.prepareConnection(L.serverUrl, L.participantToken);
|
|
1839
|
+
}, [H, a]);
|
|
1840
|
+
return s.useEffect(
|
|
1841
|
+
() => {
|
|
1842
|
+
X().catch((L) => {
|
|
1843
|
+
console.warn("WARNING: Room.prepareConnection failed:", L);
|
|
1844
|
+
});
|
|
1845
|
+
},
|
|
1846
|
+
[
|
|
1847
|
+
/* note: no prepareConnection here, this effect should only ever run once! */
|
|
1848
|
+
]
|
|
1849
|
+
), s.useMemo(
|
|
1850
|
+
() => ({
|
|
1851
|
+
...T,
|
|
1852
|
+
waitUntilConnected: k,
|
|
1853
|
+
waitUntilDisconnected: F,
|
|
1854
|
+
prepareConnection: X,
|
|
1855
|
+
start: K,
|
|
1856
|
+
end: te
|
|
1857
|
+
}),
|
|
1858
|
+
[T, k, F, X, K, te]
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1861
|
+
function hr(e, n, t, r) {
|
|
1862
|
+
const o = s.useMemo(() => () => {
|
|
1863
|
+
}, []), i = s.useCallback(t ?? o, r ?? []), a = r ? i : t, c = s.useMemo(() => e ? "internal" in e ? e.internal.emitter : e : null, [e]);
|
|
1864
|
+
s.useEffect(() => {
|
|
1865
|
+
if (!(!c || !a))
|
|
1866
|
+
return c.on(n, a), () => {
|
|
1867
|
+
c.off(n, a);
|
|
1868
|
+
};
|
|
1869
|
+
}, [c, n, a]);
|
|
1870
|
+
}
|
|
1871
|
+
var kn = /* @__PURE__ */ ((e) => (e.MessageReceived = "messageReceived", e))(kn || {});
|
|
1872
|
+
function br(e) {
|
|
1873
|
+
const { room: n } = xt(e), t = s.useMemo(
|
|
1874
|
+
() => new ge.EventEmitter(),
|
|
1875
|
+
[]
|
|
1876
|
+
), r = Ue(e), o = hn({ room: n }), i = s.useMemo(() => ({ room: n }), [n]), a = rn(i), c = s.useMemo(() => o.map((d) => {
|
|
1877
|
+
var v, M, w;
|
|
1878
|
+
switch (d.participantInfo.identity) {
|
|
1879
|
+
case n.localParticipant.identity:
|
|
1880
|
+
return {
|
|
1881
|
+
type: "userTranscript",
|
|
1882
|
+
message: d.text,
|
|
1883
|
+
id: d.streamInfo.id,
|
|
1884
|
+
timestamp: d.streamInfo.timestamp,
|
|
1885
|
+
from: n.localParticipant
|
|
1886
|
+
};
|
|
1887
|
+
case ((v = r.internal.agentParticipant) == null ? void 0 : v.identity):
|
|
1888
|
+
case ((M = r.internal.workerParticipant) == null ? void 0 : M.identity):
|
|
1889
|
+
return {
|
|
1890
|
+
type: "agentTranscript",
|
|
1891
|
+
message: d.text,
|
|
1892
|
+
id: d.streamInfo.id,
|
|
1893
|
+
timestamp: d.streamInfo.timestamp,
|
|
1894
|
+
from: ((w = r.internal.agentParticipant) == null ? void 0 : w.identity) === d.participantInfo.identity ? r.internal.agentParticipant : r.internal.workerParticipant
|
|
1895
|
+
};
|
|
1896
|
+
default:
|
|
1897
|
+
return {
|
|
1898
|
+
type: "agentTranscript",
|
|
1899
|
+
message: d.text,
|
|
1900
|
+
id: d.streamInfo.id,
|
|
1901
|
+
timestamp: d.streamInfo.timestamp,
|
|
1902
|
+
from: Array.from(n.remoteParticipants.values()).find(
|
|
1903
|
+
(A) => A.identity === d.participantInfo.identity
|
|
1904
|
+
)
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
}), [o, n]), u = s.useMemo(() => [...c, ...a.chatMessages], [c, a.chatMessages]), p = s.useRef(/* @__PURE__ */ new Map()), h = s.useMemo(() => {
|
|
1908
|
+
const d = /* @__PURE__ */ new Date();
|
|
1909
|
+
for (const v of u)
|
|
1910
|
+
p.current.has(v.id) || p.current.set(v.id, d);
|
|
1911
|
+
return u.sort((v, M) => {
|
|
1912
|
+
const w = p.current.get(v.id), A = p.current.get(M.id);
|
|
1913
|
+
return typeof w > "u" || typeof A > "u" ? 0 : w.getTime() - A.getTime();
|
|
1914
|
+
});
|
|
1915
|
+
}, [u]), l = s.useRef(/* @__PURE__ */ new Set());
|
|
1916
|
+
return s.useEffect(() => {
|
|
1917
|
+
for (const d of h)
|
|
1918
|
+
l.current.has(d.id) || (l.current.add(d.id), t.emit("messageReceived", d));
|
|
1919
|
+
}, [h]), s.useMemo(
|
|
1920
|
+
() => ({
|
|
1921
|
+
messages: h,
|
|
1922
|
+
send: a.send,
|
|
1923
|
+
isSending: a.isSending,
|
|
1924
|
+
internal: { emitter: t }
|
|
1925
|
+
}),
|
|
1926
|
+
[h, a.send, a.isSending]
|
|
1927
|
+
);
|
|
1928
|
+
}
|
|
1929
|
+
export {
|
|
1930
|
+
pn as $,
|
|
1931
|
+
Bn as A,
|
|
1932
|
+
Gn as B,
|
|
1933
|
+
xe as C,
|
|
1934
|
+
In as D,
|
|
1935
|
+
Fn as E,
|
|
1936
|
+
$t as F,
|
|
1937
|
+
Ee as G,
|
|
1938
|
+
Qt as H,
|
|
1939
|
+
Yt as I,
|
|
1940
|
+
Wn as J,
|
|
1941
|
+
Xt as K,
|
|
1942
|
+
Jn as L,
|
|
1943
|
+
ve as M,
|
|
1944
|
+
Qn as N,
|
|
1945
|
+
Zt as O,
|
|
1946
|
+
er as P,
|
|
1947
|
+
sr as Q,
|
|
1948
|
+
gn as R,
|
|
1949
|
+
Ue as S,
|
|
1950
|
+
ir as T,
|
|
1951
|
+
ur as U,
|
|
1952
|
+
ie as V,
|
|
1953
|
+
fn as W,
|
|
1954
|
+
lr as X,
|
|
1955
|
+
mn as Y,
|
|
1956
|
+
dr as Z,
|
|
1957
|
+
fr as _,
|
|
1958
|
+
re as a,
|
|
1959
|
+
hn as a0,
|
|
1960
|
+
mr as a1,
|
|
1961
|
+
Cn as a2,
|
|
1962
|
+
pr as a3,
|
|
1963
|
+
hr as a4,
|
|
1964
|
+
kn as a5,
|
|
1965
|
+
br as a6,
|
|
1966
|
+
Zn as b,
|
|
1967
|
+
xn as c,
|
|
1968
|
+
Un as d,
|
|
1969
|
+
Vn as e,
|
|
1970
|
+
Kn as f,
|
|
1971
|
+
Yn as g,
|
|
1972
|
+
nr as h,
|
|
1973
|
+
_n as i,
|
|
1974
|
+
O as j,
|
|
1975
|
+
tr as k,
|
|
1976
|
+
zn as l,
|
|
1977
|
+
ar as m,
|
|
1978
|
+
Hn as n,
|
|
1979
|
+
jn as o,
|
|
1980
|
+
Xn as p,
|
|
1981
|
+
Jt as q,
|
|
1982
|
+
Kt as r,
|
|
1983
|
+
cr as s,
|
|
1984
|
+
rr as t,
|
|
1985
|
+
Nn as u,
|
|
1986
|
+
$n as v,
|
|
1987
|
+
rn as w,
|
|
1988
|
+
or as x,
|
|
1989
|
+
qn as y,
|
|
1990
|
+
Dn as z
|
|
1991
|
+
};
|
|
1992
|
+
//# sourceMappingURL=hooks-hQJmeINB.mjs.map
|