@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,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useTextStream } from './useTextStream';
|
|
3
|
+
import { DataTopic, ParticipantAgentAttributes } from '@livekit/components-core';
|
|
4
|
+
import { Room } from 'livekit-client';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface UseTranscriptionsOptions {
|
|
10
|
+
room?: Room;
|
|
11
|
+
participantIdentities?: string[];
|
|
12
|
+
trackSids?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @beta
|
|
17
|
+
* useTranscriptions is a hook that returns the transcriptions for the given participant identities and track sids,
|
|
18
|
+
* if no options are provided, it will return all transcriptions
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const transcriptions = useTranscriptions();
|
|
22
|
+
* return <div>{transcriptions.map((transcription) => transcription.text)}</div>;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function useTranscriptions(opts?: UseTranscriptionsOptions) {
|
|
26
|
+
const { participantIdentities, trackSids } = opts ?? {};
|
|
27
|
+
const { textStreams } = useTextStream(DataTopic.TRANSCRIPTION, { room: opts?.room });
|
|
28
|
+
|
|
29
|
+
const filteredMessages = React.useMemo(
|
|
30
|
+
() =>
|
|
31
|
+
textStreams
|
|
32
|
+
.filter((stream) =>
|
|
33
|
+
participantIdentities
|
|
34
|
+
? participantIdentities.includes(stream.participantInfo.identity)
|
|
35
|
+
: true,
|
|
36
|
+
)
|
|
37
|
+
.filter((stream) =>
|
|
38
|
+
trackSids
|
|
39
|
+
? trackSids.includes(
|
|
40
|
+
stream.streamInfo.attributes?.[ParticipantAgentAttributes.TranscribedTrackId] ?? '',
|
|
41
|
+
)
|
|
42
|
+
: true,
|
|
43
|
+
),
|
|
44
|
+
[textStreams, participantIdentities, trackSids],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return filteredMessages;
|
|
48
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { TrackReferenceOrPlaceholder } from '@livekit/components-core';
|
|
2
|
+
import { log, sortTrackReferences, updatePages } from '@livekit/components-core';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export interface UseVisualStableUpdateOptions {
|
|
7
|
+
/** Overwrites the default sort function. */
|
|
8
|
+
customSortFunction?: (
|
|
9
|
+
trackReferences: TrackReferenceOrPlaceholder[],
|
|
10
|
+
) => TrackReferenceOrPlaceholder[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The `useVisualStableUpdate` hook is used to prevent visually jarring jumps and shifts of elements
|
|
15
|
+
* in an array. The algorithm only starts to update when there are more items than visually fit
|
|
16
|
+
* on a page. If this is the case, it will make sure that speaking participants move to the first
|
|
17
|
+
* page and are always visible.
|
|
18
|
+
* @remarks
|
|
19
|
+
* Updating the array can occur because attendees leave or join a room, or because they mute/unmute
|
|
20
|
+
* or start speaking.
|
|
21
|
+
* The hook is used for the `GridLayout` and `CarouselLayout` components.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const trackRefs = useTracks();
|
|
26
|
+
* const updatedTrackRefs = useVisualStableUpdate(trackRefs, itemPerPage);
|
|
27
|
+
* ```
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export function useVisualStableUpdate(
|
|
31
|
+
/** `TrackReference`s to display in the grid. */
|
|
32
|
+
trackReferences: TrackReferenceOrPlaceholder[],
|
|
33
|
+
maxItemsOnPage: number,
|
|
34
|
+
options: UseVisualStableUpdateOptions = {},
|
|
35
|
+
): TrackReferenceOrPlaceholder[] {
|
|
36
|
+
const lastTrackRefs = React.useRef<TrackReferenceOrPlaceholder[]>([]);
|
|
37
|
+
const lastMaxItemsOnPage = React.useRef<number>(-1);
|
|
38
|
+
const layoutChanged = maxItemsOnPage !== lastMaxItemsOnPage.current;
|
|
39
|
+
|
|
40
|
+
const sortedTrackRefs =
|
|
41
|
+
typeof options.customSortFunction === 'function'
|
|
42
|
+
? options.customSortFunction(trackReferences)
|
|
43
|
+
: sortTrackReferences(trackReferences);
|
|
44
|
+
|
|
45
|
+
let updatedTrackRefs: TrackReferenceOrPlaceholder[] = [...sortedTrackRefs];
|
|
46
|
+
if (layoutChanged === false) {
|
|
47
|
+
try {
|
|
48
|
+
updatedTrackRefs = updatePages(lastTrackRefs.current, sortedTrackRefs, maxItemsOnPage);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
log.error('Error while running updatePages(): ', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Save info for to compare against in the next update cycle.
|
|
55
|
+
if (layoutChanged) {
|
|
56
|
+
lastTrackRefs.current = sortedTrackRefs;
|
|
57
|
+
} else {
|
|
58
|
+
lastTrackRefs.current = updatedTrackRefs;
|
|
59
|
+
}
|
|
60
|
+
lastMaxItemsOnPage.current = maxItemsOnPage;
|
|
61
|
+
|
|
62
|
+
return updatedTrackRefs;
|
|
63
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ConnectionState, ParticipantKind, Track } from 'livekit-client';
|
|
3
|
+
import type { RemoteParticipant } from 'livekit-client';
|
|
4
|
+
import {
|
|
5
|
+
ParticipantAgentAttributes,
|
|
6
|
+
type ReceivedTranscriptionSegment,
|
|
7
|
+
type TrackReference,
|
|
8
|
+
} from '@livekit/components-core';
|
|
9
|
+
import { useRemoteParticipants } from './useRemoteParticipants';
|
|
10
|
+
import { useParticipantTracks } from './useParticipantTracks';
|
|
11
|
+
import { useTrackTranscription } from './useTrackTranscription';
|
|
12
|
+
import { useConnectionState } from './useConnectionStatus';
|
|
13
|
+
import { useParticipantAttributes } from './useParticipantAttributes';
|
|
14
|
+
import { AgentState } from './useAgent';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface VoiceAssistant {
|
|
20
|
+
/**
|
|
21
|
+
* The agent participant.
|
|
22
|
+
*/
|
|
23
|
+
agent: RemoteParticipant | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The current state of the agent.
|
|
26
|
+
*/
|
|
27
|
+
state: AgentState;
|
|
28
|
+
/**
|
|
29
|
+
* The microphone track published by the agent or associated avatar worker (if any).
|
|
30
|
+
*/
|
|
31
|
+
audioTrack: TrackReference | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The camera track published by the agent or associated avatar worker (if any).
|
|
34
|
+
*/
|
|
35
|
+
videoTrack: TrackReference | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The transcriptions of the agent's microphone track (if any).
|
|
38
|
+
*/
|
|
39
|
+
agentTranscriptions: ReceivedTranscriptionSegment[];
|
|
40
|
+
/**
|
|
41
|
+
* The agent's participant attributes.
|
|
42
|
+
*/
|
|
43
|
+
agentAttributes: RemoteParticipant['attributes'] | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const state_attribute = ParticipantAgentAttributes.AgentState;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This hook looks for the first agent-participant in the room.
|
|
50
|
+
* @remarks This hook requires an agent running with livekit-agents \>= 0.9.0
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const { state, audioTrack, agentTranscriptions, agentAttributes } = useVoiceAssistant();
|
|
54
|
+
* ```
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export function useVoiceAssistant(): VoiceAssistant {
|
|
58
|
+
const remoteParticipants = useRemoteParticipants();
|
|
59
|
+
const agent = remoteParticipants.find(
|
|
60
|
+
(p) =>
|
|
61
|
+
p.kind === ParticipantKind.AGENT &&
|
|
62
|
+
!(ParticipantAgentAttributes.PublishOnBehalf in p.attributes),
|
|
63
|
+
);
|
|
64
|
+
const worker = remoteParticipants.find(
|
|
65
|
+
(p) =>
|
|
66
|
+
p.kind === ParticipantKind.AGENT &&
|
|
67
|
+
p.attributes[ParticipantAgentAttributes.PublishOnBehalf] === agent?.identity,
|
|
68
|
+
);
|
|
69
|
+
const agentTracks = useParticipantTracks(
|
|
70
|
+
[Track.Source.Microphone, Track.Source.Camera],
|
|
71
|
+
agent?.identity,
|
|
72
|
+
);
|
|
73
|
+
const workerTracks = useParticipantTracks(
|
|
74
|
+
[Track.Source.Microphone, Track.Source.Camera],
|
|
75
|
+
worker?.identity,
|
|
76
|
+
);
|
|
77
|
+
const audioTrack =
|
|
78
|
+
agentTracks.find((t) => t.source === Track.Source.Microphone) ??
|
|
79
|
+
workerTracks.find((t) => t.source === Track.Source.Microphone);
|
|
80
|
+
const videoTrack =
|
|
81
|
+
agentTracks.find((t) => t.source === Track.Source.Camera) ??
|
|
82
|
+
workerTracks.find((t) => t.source === Track.Source.Camera);
|
|
83
|
+
const { segments: agentTranscriptions } = useTrackTranscription(audioTrack);
|
|
84
|
+
const connectionState = useConnectionState();
|
|
85
|
+
const { attributes } = useParticipantAttributes({ participant: agent });
|
|
86
|
+
|
|
87
|
+
const state: AgentState = React.useMemo(() => {
|
|
88
|
+
if (connectionState === ConnectionState.Disconnected) {
|
|
89
|
+
return 'disconnected';
|
|
90
|
+
} else if (
|
|
91
|
+
connectionState === ConnectionState.Connecting ||
|
|
92
|
+
!agent ||
|
|
93
|
+
!attributes?.[state_attribute]
|
|
94
|
+
) {
|
|
95
|
+
return 'connecting';
|
|
96
|
+
} else {
|
|
97
|
+
return attributes[state_attribute] as AgentState;
|
|
98
|
+
}
|
|
99
|
+
}, [attributes, agent, connectionState]);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
agent,
|
|
103
|
+
state,
|
|
104
|
+
audioTrack,
|
|
105
|
+
videoTrack,
|
|
106
|
+
agentTranscriptions,
|
|
107
|
+
agentAttributes: attributes,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used to merge the exports from the main index.ts file with the exports from the cloud/krisp/useKrispNoiseFilter.ts file for docs generation.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Regular exports
|
|
6
|
+
export * from './index';
|
|
7
|
+
|
|
8
|
+
// Cloud/Krisp exports
|
|
9
|
+
export {
|
|
10
|
+
useKrispNoiseFilter,
|
|
11
|
+
type useKrispNoiseFilterOptions,
|
|
12
|
+
} from './hooks/cloud/krisp/useKrispNoiseFilter';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export * from './components';
|
|
2
|
+
|
|
3
|
+
export * from './hooks';
|
|
4
|
+
|
|
5
|
+
export * from './prefabs';
|
|
6
|
+
|
|
7
|
+
export * from './context';
|
|
8
|
+
|
|
9
|
+
export * from './assets/icons';
|
|
10
|
+
|
|
11
|
+
export * from './assets/images';
|
|
12
|
+
|
|
13
|
+
// Re-exports from core
|
|
14
|
+
export { setLogLevel, setLogExtension, isTrackReference } from '@livekit/components-core';
|
|
15
|
+
export type {
|
|
16
|
+
ChatMessage,
|
|
17
|
+
ReceivedMessage,
|
|
18
|
+
ReceivedChatMessage,
|
|
19
|
+
ReceivedUserTranscriptionMessage,
|
|
20
|
+
ReceivedAgentTranscriptionMessage,
|
|
21
|
+
MessageDecoder,
|
|
22
|
+
MessageEncoder,
|
|
23
|
+
LocalUserChoices,
|
|
24
|
+
TrackReference,
|
|
25
|
+
TrackReferenceOrPlaceholder,
|
|
26
|
+
ParticipantClickEvent,
|
|
27
|
+
ParticipantIdentifier,
|
|
28
|
+
PinState,
|
|
29
|
+
WidgetState,
|
|
30
|
+
GridLayoutDefinition,
|
|
31
|
+
TextStreamData,
|
|
32
|
+
} from '@livekit/components-core';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export function chain(...callbacks: any[]): (...args: any[]) => void {
|
|
20
|
+
return (...args: any[]) => {
|
|
21
|
+
for (const callback of callbacks) {
|
|
22
|
+
if (typeof callback === 'function') {
|
|
23
|
+
try {
|
|
24
|
+
callback(...args);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Props {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// taken from: https://stackoverflow.com/questions/51603250/typescript-3-parameter-list-intersection-type/51604379#51604379
|
|
38
|
+
type TupleTypes<T> = { [P in keyof T]: T[P] } extends { [key: number]: infer V } ? V : never;
|
|
39
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void
|
|
40
|
+
? I
|
|
41
|
+
: never;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Merges multiple props objects together. Event handlers are chained,
|
|
45
|
+
* classNames are combined, and ids are deduplicated - different ids
|
|
46
|
+
* will trigger a side-effect and re-render components hooked up with `useId`.
|
|
47
|
+
* For all other props, the last prop object overrides all previous ones.
|
|
48
|
+
* @param args - Multiple sets of props to merge together.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export function mergeProps<T extends Props[]>(...args: T): UnionToIntersection<TupleTypes<T>> {
|
|
52
|
+
// Start with a base clone of the first argument. This is a lot faster than starting
|
|
53
|
+
// with an empty object and adding properties as we go.
|
|
54
|
+
const result: Props = { ...args[0] };
|
|
55
|
+
for (let i = 1; i < args.length; i++) {
|
|
56
|
+
const props = args[i];
|
|
57
|
+
for (const key in props) {
|
|
58
|
+
const a = result[key];
|
|
59
|
+
const b = props[key];
|
|
60
|
+
|
|
61
|
+
// Chain events
|
|
62
|
+
if (
|
|
63
|
+
typeof a === 'function' &&
|
|
64
|
+
typeof b === 'function' &&
|
|
65
|
+
// This is a lot faster than a regex.
|
|
66
|
+
key[0] === 'o' &&
|
|
67
|
+
key[1] === 'n' &&
|
|
68
|
+
key.charCodeAt(2) >= /* 'A' */ 65 &&
|
|
69
|
+
key.charCodeAt(2) <= /* 'Z' */ 90
|
|
70
|
+
) {
|
|
71
|
+
result[key] = chain(a, b);
|
|
72
|
+
|
|
73
|
+
// Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
|
|
74
|
+
} else if (
|
|
75
|
+
(key === 'className' || key === 'UNSAFE_className') &&
|
|
76
|
+
typeof a === 'string' &&
|
|
77
|
+
typeof b === 'string'
|
|
78
|
+
) {
|
|
79
|
+
result[key] = clsx(a, b);
|
|
80
|
+
} else {
|
|
81
|
+
result[key] = b !== undefined ? b : a;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return result as UnionToIntersection<TupleTypes<T>>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ControlBar } from './ControlBar';
|
|
3
|
+
|
|
4
|
+
import { ParticipantAudioTile } from '../components/participant/ParticipantAudioTile';
|
|
5
|
+
import { LayoutContextProvider } from '../components/layout/LayoutContextProvider';
|
|
6
|
+
import type { WidgetState } from '@livekit/components-core';
|
|
7
|
+
import { Chat } from './Chat';
|
|
8
|
+
import { TrackLoop } from '../components';
|
|
9
|
+
import { useTracks } from '../hooks';
|
|
10
|
+
import { useWarnAboutMissingStyles } from '../hooks/useWarnAboutMissingStyles';
|
|
11
|
+
import { Track } from 'livekit-client';
|
|
12
|
+
|
|
13
|
+
/** @public */
|
|
14
|
+
export interface AudioConferenceProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This component is the default setup of a classic LiveKit audio conferencing app.
|
|
18
|
+
* It provides functionality like switching between participant grid view and focus view.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* The component is implemented with other LiveKit components like `FocusContextProvider`,
|
|
22
|
+
* `GridLayout`, `ControlBar`, `FocusLayoutContainer` and `FocusLayout`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <LiveKitRoom>
|
|
27
|
+
* <AudioConference />
|
|
28
|
+
* <LiveKitRoom>
|
|
29
|
+
* ```
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export function AudioConference({ ...props }: AudioConferenceProps) {
|
|
33
|
+
const [widgetState, setWidgetState] = React.useState<WidgetState>({
|
|
34
|
+
showChat: false,
|
|
35
|
+
unreadMessages: 0,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const audioTracks = useTracks([Track.Source.Microphone]);
|
|
39
|
+
|
|
40
|
+
useWarnAboutMissingStyles();
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<LayoutContextProvider onWidgetChange={setWidgetState}>
|
|
44
|
+
<div className="lk-audio-conference" {...props}>
|
|
45
|
+
<div className="lk-audio-conference-stage">
|
|
46
|
+
<TrackLoop tracks={audioTracks}>
|
|
47
|
+
<ParticipantAudioTile />
|
|
48
|
+
</TrackLoop>
|
|
49
|
+
</div>
|
|
50
|
+
<ControlBar
|
|
51
|
+
controls={{ microphone: true, screenShare: false, camera: false, chat: true }}
|
|
52
|
+
/>
|
|
53
|
+
{widgetState.showChat && <Chat />}
|
|
54
|
+
</div>
|
|
55
|
+
</LayoutContextProvider>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { type ChatMessage, type ChatOptions } from '@livekit/components-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useMaybeLayoutContext } from '../context';
|
|
4
|
+
import { cloneSingleChild } from '../utils';
|
|
5
|
+
import type { MessageFormatter } from '../components/ChatEntry';
|
|
6
|
+
import { ChatEntry } from '../components/ChatEntry';
|
|
7
|
+
import { useChat } from '../hooks/useChat';
|
|
8
|
+
import { ChatToggle } from '../components';
|
|
9
|
+
import ChatCloseIcon from '../assets/icons/ChatCloseIcon';
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
export interface ChatProps extends React.HTMLAttributes<HTMLDivElement>, ChatOptions {
|
|
13
|
+
messageFormatter?: MessageFormatter;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The Chat component provides ready-to-use chat functionality in a LiveKit room.
|
|
18
|
+
* Messages are distributed to all participants in the room in real-time.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* - Only users who are in the room at the time of dispatch will receive messages
|
|
22
|
+
* - Message history is not persisted between sessions
|
|
23
|
+
* - Requires `@livekit/components-styles` to be imported for styling
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* import '@livekit/components-styles';
|
|
28
|
+
*
|
|
29
|
+
* function Room() {
|
|
30
|
+
* return (
|
|
31
|
+
* <LiveKitRoom data-lk-theme="default">
|
|
32
|
+
* <Chat />
|
|
33
|
+
* </LiveKitRoom>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* For custom styling, refer to: https://docs.livekit.io/reference/components/react/concepts/style-components/
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export function Chat({
|
|
43
|
+
messageFormatter,
|
|
44
|
+
messageDecoder,
|
|
45
|
+
messageEncoder,
|
|
46
|
+
channelTopic,
|
|
47
|
+
...props
|
|
48
|
+
}: ChatProps) {
|
|
49
|
+
const ulRef = React.useRef<HTMLUListElement>(null);
|
|
50
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
51
|
+
|
|
52
|
+
const chatOptions: ChatOptions = React.useMemo(() => {
|
|
53
|
+
return { messageDecoder, messageEncoder, channelTopic };
|
|
54
|
+
}, [messageDecoder, messageEncoder, channelTopic]);
|
|
55
|
+
|
|
56
|
+
const { chatMessages, send, isSending } = useChat(chatOptions);
|
|
57
|
+
|
|
58
|
+
const layoutContext = useMaybeLayoutContext();
|
|
59
|
+
const lastReadMsgAt = React.useRef<ChatMessage['timestamp']>(0);
|
|
60
|
+
|
|
61
|
+
async function handleSubmit(event: React.FormEvent) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
if (inputRef.current && inputRef.current.value.trim() !== '') {
|
|
64
|
+
await send(inputRef.current.value);
|
|
65
|
+
inputRef.current.value = '';
|
|
66
|
+
inputRef.current.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (ulRef) {
|
|
72
|
+
ulRef.current?.scrollTo({ top: ulRef.current.scrollHeight });
|
|
73
|
+
}
|
|
74
|
+
}, [ulRef, chatMessages]);
|
|
75
|
+
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (!layoutContext || chatMessages.length === 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
layoutContext.widget.state?.showChat &&
|
|
83
|
+
chatMessages.length > 0 &&
|
|
84
|
+
lastReadMsgAt.current !== chatMessages[chatMessages.length - 1]?.timestamp
|
|
85
|
+
) {
|
|
86
|
+
lastReadMsgAt.current = chatMessages[chatMessages.length - 1]?.timestamp;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const unreadMessageCount = chatMessages.filter(
|
|
91
|
+
(msg) => !lastReadMsgAt.current || msg.timestamp > lastReadMsgAt.current,
|
|
92
|
+
).length;
|
|
93
|
+
|
|
94
|
+
const { widget } = layoutContext;
|
|
95
|
+
if (unreadMessageCount > 0 && widget.state?.unreadMessages !== unreadMessageCount) {
|
|
96
|
+
widget.dispatch?.({ msg: 'unread_msg', count: unreadMessageCount });
|
|
97
|
+
}
|
|
98
|
+
}, [chatMessages, layoutContext?.widget]);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div {...props} className="lk-chat">
|
|
102
|
+
<div className="lk-chat-header">
|
|
103
|
+
Messages
|
|
104
|
+
{layoutContext && (
|
|
105
|
+
<ChatToggle className="lk-close-button">
|
|
106
|
+
<ChatCloseIcon />
|
|
107
|
+
</ChatToggle>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<ul className="lk-list lk-chat-messages" ref={ulRef}>
|
|
112
|
+
{props.children
|
|
113
|
+
? chatMessages.map((msg, idx) =>
|
|
114
|
+
cloneSingleChild(props.children, {
|
|
115
|
+
entry: msg,
|
|
116
|
+
key: msg.id ?? idx,
|
|
117
|
+
messageFormatter,
|
|
118
|
+
}),
|
|
119
|
+
)
|
|
120
|
+
: chatMessages.map((msg, idx, allMsg) => {
|
|
121
|
+
const hideName = idx >= 1 && allMsg[idx - 1].from === msg.from;
|
|
122
|
+
// If the time delta between two messages is bigger than 60s show timestamp.
|
|
123
|
+
const hideTimestamp = idx >= 1 && msg.timestamp - allMsg[idx - 1].timestamp < 60_000;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<ChatEntry
|
|
127
|
+
key={msg.id ?? idx}
|
|
128
|
+
hideName={hideName}
|
|
129
|
+
hideTimestamp={hideName === false ? false : hideTimestamp} // If we show the name always show the timestamp as well.
|
|
130
|
+
entry={msg}
|
|
131
|
+
messageFormatter={messageFormatter}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
})}
|
|
135
|
+
</ul>
|
|
136
|
+
<form className="lk-chat-form" onSubmit={handleSubmit}>
|
|
137
|
+
<input
|
|
138
|
+
className="lk-form-control lk-chat-form-input"
|
|
139
|
+
disabled={isSending}
|
|
140
|
+
ref={inputRef}
|
|
141
|
+
type="text"
|
|
142
|
+
placeholder="Enter a message..."
|
|
143
|
+
onInput={(ev) => ev.stopPropagation()}
|
|
144
|
+
onKeyDown={(ev) => ev.stopPropagation()}
|
|
145
|
+
onKeyUp={(ev) => ev.stopPropagation()}
|
|
146
|
+
/>
|
|
147
|
+
<button type="submit" className="lk-button lk-chat-form-button" disabled={isSending}>
|
|
148
|
+
Send
|
|
149
|
+
</button>
|
|
150
|
+
</form>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|