@mrksbnc/livekit-vue 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -30
- package/dist/background/BackgroundEffectSelect.vue.d.cts +55 -0
- package/dist/background/BackgroundEffectSelect.vue.d.mts +55 -0
- package/dist/background/index.d.cts +3 -0
- package/dist/background/index.d.mts +3 -0
- package/dist/background.cjs +2 -0
- package/dist/background.cjs.map +1 -0
- package/dist/background.js +239 -0
- package/dist/background.js.map +1 -0
- package/dist/components/chat/ChatEntry.vue.d.cts +16 -0
- package/dist/components/chat/ChatEntry.vue.d.mts +16 -0
- package/dist/components/chat/chat.utils.d.cts +3 -0
- package/dist/components/chat/chat.utils.d.mts +3 -0
- package/dist/components/chat/index.d.cts +3 -0
- package/dist/components/chat/index.d.mts +3 -0
- package/dist/components/chat/render-node.d.cts +8 -0
- package/dist/components/chat/render-node.d.mts +8 -0
- package/dist/components/context/ParticipantContextProvider.vue.d.cts +16 -0
- package/dist/components/context/ParticipantContextProvider.vue.d.mts +16 -0
- package/dist/components/context/RoomContextProvider.vue.d.cts +16 -0
- package/dist/components/context/RoomContextProvider.vue.d.mts +16 -0
- package/dist/components/context/SessionProvider.vue.d.cts +16 -0
- package/dist/components/context/SessionProvider.vue.d.mts +16 -0
- package/dist/components/context/TrackRefContextProvider.vue.d.cts +16 -0
- package/dist/components/context/TrackRefContextProvider.vue.d.mts +16 -0
- package/dist/components/context/index.d.cts +4 -0
- package/dist/components/context/index.d.mts +4 -0
- package/dist/components/controls/ChatToggle.vue.d.cts +17 -0
- package/dist/components/controls/ChatToggle.vue.d.mts +17 -0
- package/dist/components/controls/ClearPinButton.vue.d.cts +22 -0
- package/dist/components/controls/ClearPinButton.vue.d.mts +22 -0
- package/dist/components/controls/DisconnectButton.vue.d.cts +18 -0
- package/dist/components/controls/DisconnectButton.vue.d.mts +18 -0
- package/dist/components/controls/FocusToggle.vue.d.cts +19 -0
- package/dist/components/controls/FocusToggle.vue.d.mts +19 -0
- package/dist/components/controls/MediaDeviceSelect.vue.d.cts +45 -0
- package/dist/components/controls/MediaDeviceSelect.vue.d.mts +45 -0
- package/dist/components/controls/PaginationControl.vue.d.cts +18 -0
- package/dist/components/controls/PaginationControl.vue.d.mts +18 -0
- package/dist/components/controls/PaginationIndicator.vue.d.cts +8 -0
- package/dist/components/controls/PaginationIndicator.vue.d.mts +8 -0
- package/dist/components/controls/SettingsMenuToggle.vue.d.cts +16 -0
- package/dist/components/controls/SettingsMenuToggle.vue.d.mts +16 -0
- package/dist/components/controls/StartAudio.vue.d.cts +21 -0
- package/dist/components/controls/StartAudio.vue.d.mts +21 -0
- package/dist/components/controls/StartMediaButton.vue.d.cts +24 -0
- package/dist/components/controls/StartMediaButton.vue.d.mts +24 -0
- package/dist/components/controls/TrackToggle.vue.d.cts +43 -0
- package/dist/components/controls/TrackToggle.vue.d.mts +43 -0
- package/dist/components/controls/VideoQualitySelect.vue.d.cts +33 -0
- package/dist/components/controls/VideoQualitySelect.vue.d.mts +33 -0
- package/dist/components/controls/index.d.cts +24 -0
- package/dist/components/controls/index.d.mts +24 -0
- package/dist/components/icons/CameraDisabledIcon.vue.d.cts +3 -0
- package/dist/components/icons/CameraDisabledIcon.vue.d.mts +3 -0
- package/dist/components/icons/CameraIcon.vue.d.cts +3 -0
- package/dist/components/icons/CameraIcon.vue.d.mts +3 -0
- package/dist/components/icons/ChatCloseIcon.vue.d.cts +3 -0
- package/dist/components/icons/ChatCloseIcon.vue.d.mts +3 -0
- package/dist/components/icons/ChatIcon.vue.d.cts +3 -0
- package/dist/components/icons/ChatIcon.vue.d.mts +3 -0
- package/dist/components/icons/ChevronIcon.vue.d.cts +3 -0
- package/dist/components/icons/ChevronIcon.vue.d.mts +3 -0
- package/dist/components/icons/FocusToggleIcon.vue.d.cts +3 -0
- package/dist/components/icons/FocusToggleIcon.vue.d.mts +3 -0
- package/dist/components/icons/GearIcon.vue.d.cts +3 -0
- package/dist/components/icons/GearIcon.vue.d.mts +3 -0
- package/dist/components/icons/LeaveIcon.vue.d.cts +3 -0
- package/dist/components/icons/LeaveIcon.vue.d.mts +3 -0
- package/dist/components/icons/LockLockedIcon.vue.d.cts +3 -0
- package/dist/components/icons/LockLockedIcon.vue.d.mts +3 -0
- package/dist/components/icons/MicDisabledIcon.vue.d.cts +3 -0
- package/dist/components/icons/MicDisabledIcon.vue.d.mts +3 -0
- package/dist/components/icons/MicIcon.vue.d.cts +3 -0
- package/dist/components/icons/MicIcon.vue.d.mts +3 -0
- package/dist/components/icons/ParticipantPlaceholder.vue.d.cts +3 -0
- package/dist/components/icons/ParticipantPlaceholder.vue.d.mts +3 -0
- package/dist/components/icons/QualityExcellentIcon.vue.d.cts +3 -0
- package/dist/components/icons/QualityExcellentIcon.vue.d.mts +3 -0
- package/dist/components/icons/QualityGoodIcon.vue.d.cts +3 -0
- package/dist/components/icons/QualityGoodIcon.vue.d.mts +3 -0
- package/dist/components/icons/QualityPoorIcon.vue.d.cts +3 -0
- package/dist/components/icons/QualityPoorIcon.vue.d.mts +3 -0
- package/dist/components/icons/QualityUnknownIcon.vue.d.cts +3 -0
- package/dist/components/icons/QualityUnknownIcon.vue.d.mts +3 -0
- package/dist/components/icons/ScreenShareIcon.vue.d.cts +3 -0
- package/dist/components/icons/ScreenShareIcon.vue.d.mts +3 -0
- package/dist/components/icons/ScreenShareStopIcon.vue.d.cts +3 -0
- package/dist/components/icons/ScreenShareStopIcon.vue.d.mts +3 -0
- package/dist/components/icons/SpinnerIcon.vue.d.cts +3 -0
- package/dist/components/icons/SpinnerIcon.vue.d.mts +3 -0
- package/dist/components/icons/UnfocusToggleIcon.vue.d.cts +3 -0
- package/dist/components/icons/UnfocusToggleIcon.vue.d.mts +3 -0
- package/dist/components/icons/index.d.cts +21 -0
- package/dist/components/icons/index.d.mts +21 -0
- package/dist/components/icons/utils.d.cts +4 -0
- package/dist/components/icons/utils.d.mts +4 -0
- package/dist/components/index.d.cts +9 -0
- package/dist/components/index.d.mts +9 -0
- package/dist/components/layout/CarouselLayout.vue.d.cts +24 -0
- package/dist/components/layout/CarouselLayout.vue.d.mts +24 -0
- package/dist/components/layout/FocusLayout.vue.d.cts +16 -0
- package/dist/components/layout/FocusLayout.vue.d.mts +16 -0
- package/dist/components/layout/FocusLayoutContainer.vue.d.cts +14 -0
- package/dist/components/layout/FocusLayoutContainer.vue.d.mts +14 -0
- package/dist/components/layout/GridLayout.vue.d.cts +24 -0
- package/dist/components/layout/GridLayout.vue.d.mts +24 -0
- package/dist/components/layout/LayoutContextProvider.vue.d.cts +27 -0
- package/dist/components/layout/LayoutContextProvider.vue.d.mts +27 -0
- package/dist/components/layout/index.d.cts +10 -0
- package/dist/components/layout/index.d.mts +10 -0
- package/dist/components/participant/AudioTrack.vue.d.cts +17 -0
- package/dist/components/participant/AudioTrack.vue.d.mts +17 -0
- package/dist/components/participant/AudioVisualizer.vue.d.cts +10 -0
- package/dist/components/participant/AudioVisualizer.vue.d.mts +10 -0
- package/dist/components/participant/BarVisualizer.vue.d.cts +46 -0
- package/dist/components/participant/BarVisualizer.vue.d.mts +46 -0
- package/dist/components/participant/ConnectionQualityIndicator.vue.d.cts +19 -0
- package/dist/components/participant/ConnectionQualityIndicator.vue.d.mts +19 -0
- package/dist/components/participant/ParticipantAudioTile.vue.d.cts +23 -0
- package/dist/components/participant/ParticipantAudioTile.vue.d.mts +23 -0
- package/dist/components/participant/ParticipantAvatar.vue.d.cts +10 -0
- package/dist/components/participant/ParticipantAvatar.vue.d.mts +10 -0
- package/dist/components/participant/ParticipantName.vue.d.cts +17 -0
- package/dist/components/participant/ParticipantName.vue.d.mts +17 -0
- package/dist/components/participant/ParticipantTile.vue.d.cts +27 -0
- package/dist/components/participant/ParticipantTile.vue.d.mts +27 -0
- package/dist/components/participant/TrackMutedIndicator.vue.d.cts +22 -0
- package/dist/components/participant/TrackMutedIndicator.vue.d.mts +22 -0
- package/dist/components/participant/VideoTrack.vue.d.cts +17 -0
- package/dist/components/participant/VideoTrack.vue.d.mts +17 -0
- package/dist/components/participant/index.d.cts +19 -0
- package/dist/components/participant/index.d.mts +19 -0
- package/dist/components/prefabs/AudioConference.vue.d.cts +26 -0
- package/dist/components/prefabs/AudioConference.vue.d.mts +26 -0
- package/dist/components/prefabs/Chat.vue.d.cts +36 -0
- package/dist/components/prefabs/Chat.vue.d.mts +36 -0
- package/dist/components/prefabs/ControlBar.vue.d.cts +52 -0
- package/dist/components/prefabs/ControlBar.vue.d.mts +52 -0
- package/dist/components/prefabs/MediaDeviceMenu.vue.d.cts +46 -0
- package/dist/components/prefabs/MediaDeviceMenu.vue.d.mts +46 -0
- package/dist/components/prefabs/PreJoin.vue.d.cts +45 -0
- package/dist/components/prefabs/PreJoin.vue.d.mts +45 -0
- package/dist/components/prefabs/VideoConference.vue.d.cts +28 -0
- package/dist/components/prefabs/VideoConference.vue.d.mts +28 -0
- package/dist/components/prefabs/VoiceAssistantControlBar.vue.d.cts +33 -0
- package/dist/components/prefabs/VoiceAssistantControlBar.vue.d.mts +33 -0
- package/dist/components/prefabs/index.d.cts +14 -0
- package/dist/components/prefabs/index.d.mts +14 -0
- package/dist/components/room/ConnectionStateToast.vue.d.cts +8 -0
- package/dist/components/room/ConnectionStateToast.vue.d.mts +8 -0
- package/dist/components/room/ConnectionStatus.vue.d.cts +19 -0
- package/dist/components/room/ConnectionStatus.vue.d.mts +19 -0
- package/dist/components/room/LiveKitRoom.vue.d.cts +47 -0
- package/dist/components/room/LiveKitRoom.vue.d.mts +47 -0
- package/dist/components/room/ParticipantLoop.vue.d.cts +18 -0
- package/dist/components/room/ParticipantLoop.vue.d.mts +18 -0
- package/dist/components/room/RoomAudioRenderer.vue.d.cts +13 -0
- package/dist/components/room/RoomAudioRenderer.vue.d.mts +13 -0
- package/dist/components/room/RoomName.vue.d.cts +20 -0
- package/dist/components/room/RoomName.vue.d.mts +20 -0
- package/dist/components/room/Toast.vue.d.cts +14 -0
- package/dist/components/room/Toast.vue.d.mts +14 -0
- package/dist/components/room/TrackLoop.vue.d.cts +18 -0
- package/dist/components/room/TrackLoop.vue.d.mts +18 -0
- package/dist/components/room/index.d.cts +16 -0
- package/dist/components/room/index.d.mts +16 -0
- package/dist/components/style.d.cts +11 -0
- package/dist/components/style.d.mts +11 -0
- package/dist/composables/index.d.cts +66 -0
- package/dist/composables/index.d.mts +66 -0
- package/dist/composables/useAgent.d.cts +67 -0
- package/dist/composables/useAgent.d.mts +67 -0
- package/dist/composables/useAgentExpression.d.cts +20 -0
- package/dist/composables/useAgentExpression.d.mts +20 -0
- package/dist/composables/useAudioPlayback.d.cts +10 -0
- package/dist/composables/useAudioPlayback.d.mts +10 -0
- package/dist/composables/useBackgroundEffect.d.cts +43 -0
- package/dist/composables/useBackgroundEffect.d.mts +43 -0
- package/dist/composables/useBarAnimator.d.cts +11 -0
- package/dist/composables/useBarAnimator.d.mts +11 -0
- package/dist/composables/useChat.d.cts +13 -0
- package/dist/composables/useChat.d.mts +13 -0
- package/dist/composables/useChatToggle.d.cts +13 -0
- package/dist/composables/useChatToggle.d.mts +13 -0
- package/dist/composables/useClearPinButton.d.cts +14 -0
- package/dist/composables/useClearPinButton.d.mts +14 -0
- package/dist/composables/useConnectionQualityIndicator.d.cts +9 -0
- package/dist/composables/useConnectionQualityIndicator.d.mts +9 -0
- package/dist/composables/useConnectionState.d.cts +13 -0
- package/dist/composables/useConnectionState.d.mts +13 -0
- package/dist/composables/useConnectionStatus.d.cts +16 -0
- package/dist/composables/useConnectionStatus.d.mts +16 -0
- package/dist/composables/useDataChannel.d.cts +14 -0
- package/dist/composables/useDataChannel.d.mts +14 -0
- package/dist/composables/useDisconnectButton.d.cts +9 -0
- package/dist/composables/useDisconnectButton.d.mts +9 -0
- package/dist/composables/useEvents.d.cts +15 -0
- package/dist/composables/useEvents.d.mts +15 -0
- package/dist/composables/useFacingMode.d.cts +17 -0
- package/dist/composables/useFacingMode.d.mts +17 -0
- package/dist/composables/useFocusToggle.d.cts +14 -0
- package/dist/composables/useFocusToggle.d.mts +14 -0
- package/dist/composables/useGridLayout.d.cts +13 -0
- package/dist/composables/useGridLayout.d.mts +13 -0
- package/dist/composables/useIsEncrypted.d.cts +10 -0
- package/dist/composables/useIsEncrypted.d.mts +10 -0
- package/dist/composables/useIsMuted.d.cts +11 -0
- package/dist/composables/useIsMuted.d.mts +11 -0
- package/dist/composables/useIsRecording.d.cts +9 -0
- package/dist/composables/useIsRecording.d.mts +9 -0
- package/dist/composables/useIsSpeaking.d.cts +9 -0
- package/dist/composables/useIsSpeaking.d.mts +9 -0
- package/dist/composables/useKrispNoiseFilter.d.cts +16 -0
- package/dist/composables/useKrispNoiseFilter.d.mts +16 -0
- package/dist/composables/useLiveKitRoom.d.cts +15 -0
- package/dist/composables/useLiveKitRoom.d.mts +15 -0
- package/dist/composables/useLocalParticipant.d.cts +16 -0
- package/dist/composables/useLocalParticipant.d.mts +16 -0
- package/dist/composables/useLocalParticipantPermissions.d.cts +13 -0
- package/dist/composables/useLocalParticipantPermissions.d.mts +13 -0
- package/dist/composables/useMediaDeviceSelect.d.cts +16 -0
- package/dist/composables/useMediaDeviceSelect.d.mts +16 -0
- package/dist/composables/useMediaDevices.d.cts +12 -0
- package/dist/composables/useMediaDevices.d.mts +12 -0
- package/dist/composables/useMediaTrackBySourceOrName.d.cts +30 -0
- package/dist/composables/useMediaTrackBySourceOrName.d.mts +30 -0
- package/dist/composables/usePagination.d.cts +26 -0
- package/dist/composables/usePagination.d.mts +26 -0
- package/dist/composables/useParticipantAttributes.d.cts +14 -0
- package/dist/composables/useParticipantAttributes.d.mts +14 -0
- package/dist/composables/useParticipantAvatar.d.cts +17 -0
- package/dist/composables/useParticipantAvatar.d.mts +17 -0
- package/dist/composables/useParticipantInfo.d.cts +14 -0
- package/dist/composables/useParticipantInfo.d.mts +14 -0
- package/dist/composables/useParticipantPermissions.d.cts +10 -0
- package/dist/composables/useParticipantPermissions.d.mts +10 -0
- package/dist/composables/useParticipantTile.d.cts +22 -0
- package/dist/composables/useParticipantTile.d.mts +22 -0
- package/dist/composables/useParticipantTracks.d.cts +12 -0
- package/dist/composables/useParticipantTracks.d.mts +12 -0
- package/dist/composables/useParticipants.d.cts +11 -0
- package/dist/composables/useParticipants.d.mts +11 -0
- package/dist/composables/usePersistentUserChoices.d.cts +16 -0
- package/dist/composables/usePersistentUserChoices.d.mts +16 -0
- package/dist/composables/usePinnedTracks.d.cts +10 -0
- package/dist/composables/usePinnedTracks.d.mts +10 -0
- package/dist/composables/usePreviewTracks.d.cts +15 -0
- package/dist/composables/usePreviewTracks.d.mts +15 -0
- package/dist/composables/useRemoteParticipant.d.cts +14 -0
- package/dist/composables/useRemoteParticipant.d.mts +14 -0
- package/dist/composables/useRemoteParticipants.d.cts +10 -0
- package/dist/composables/useRemoteParticipants.d.mts +10 -0
- package/dist/composables/useRoomInfo.d.cts +13 -0
- package/dist/composables/useRoomInfo.d.mts +13 -0
- package/dist/composables/useRpc.d.cts +18 -0
- package/dist/composables/useRpc.d.mts +18 -0
- package/dist/composables/useSequentialRoomConnectDisconnect.d.cts +10 -0
- package/dist/composables/useSequentialRoomConnectDisconnect.d.mts +10 -0
- package/dist/composables/useSession.d.cts +83 -0
- package/dist/composables/useSession.d.mts +83 -0
- package/dist/composables/useSessionMessages.d.cts +22 -0
- package/dist/composables/useSessionMessages.d.mts +22 -0
- package/dist/composables/useSettingsToggle.d.cts +10 -0
- package/dist/composables/useSettingsToggle.d.mts +10 -0
- package/dist/composables/useSortedParticipants.d.cts +9 -0
- package/dist/composables/useSortedParticipants.d.mts +9 -0
- package/dist/composables/useSpeakingParticipants.d.cts +6 -0
- package/dist/composables/useSpeakingParticipants.d.mts +6 -0
- package/dist/composables/useStartAudio.d.cts +10 -0
- package/dist/composables/useStartAudio.d.mts +10 -0
- package/dist/composables/useStartVideo.d.cts +10 -0
- package/dist/composables/useStartVideo.d.mts +10 -0
- package/dist/composables/useSwipe.d.cts +16 -0
- package/dist/composables/useSwipe.d.mts +16 -0
- package/dist/composables/useTextStream.d.cts +27 -0
- package/dist/composables/useTextStream.d.mts +27 -0
- package/dist/composables/useToast.d.cts +9 -0
- package/dist/composables/useToast.d.mts +9 -0
- package/dist/composables/useToken.d.cts +23 -0
- package/dist/composables/useToken.d.mts +23 -0
- package/dist/composables/useTrack.d.cts +12 -0
- package/dist/composables/useTrack.d.mts +12 -0
- package/dist/composables/useTrackByName.d.cts +11 -0
- package/dist/composables/useTrackByName.d.mts +11 -0
- package/dist/composables/useTrackMutedIndicator.d.cts +9 -0
- package/dist/composables/useTrackMutedIndicator.d.mts +9 -0
- package/dist/composables/useTrackRefBySource.d.cts +9 -0
- package/dist/composables/useTrackRefBySource.d.mts +9 -0
- package/dist/composables/useTrackRefBySourceOrName.d.cts +7 -0
- package/dist/composables/useTrackRefBySourceOrName.d.mts +7 -0
- package/dist/composables/useTrackSyncTime.d.cts +13 -0
- package/dist/composables/useTrackSyncTime.d.mts +13 -0
- package/dist/composables/useTrackToggle.d.cts +28 -0
- package/dist/composables/useTrackToggle.d.mts +28 -0
- package/dist/composables/useTrackTranscription.d.cts +15 -0
- package/dist/composables/useTrackTranscription.d.mts +15 -0
- package/dist/composables/useTrackVolume.d.cts +39 -0
- package/dist/composables/useTrackVolume.d.mts +39 -0
- package/dist/composables/useTracks.d.cts +18 -0
- package/dist/composables/useTracks.d.mts +18 -0
- package/dist/composables/useTranscriptions.d.cts +12 -0
- package/dist/composables/useTranscriptions.d.mts +12 -0
- package/dist/composables/useVideoQuality.d.cts +29 -0
- package/dist/composables/useVideoQuality.d.mts +29 -0
- package/dist/composables/useVisualStableUpdate.d.cts +13 -0
- package/dist/composables/useVisualStableUpdate.d.mts +13 -0
- package/dist/composables/useVoiceAssistant.d.cts +16 -0
- package/dist/composables/useVoiceAssistant.d.mts +16 -0
- package/dist/context/connection-state.context.d.cts +18 -0
- package/dist/context/connection-state.context.d.mts +18 -0
- package/dist/context/error.d.cts +3 -0
- package/dist/context/error.d.mts +3 -0
- package/dist/context/feature.context.d.cts +8 -0
- package/dist/context/feature.context.d.mts +8 -0
- package/dist/context/index.d.cts +9 -0
- package/dist/context/index.d.mts +9 -0
- package/dist/context/layout.context.d.cts +15 -0
- package/dist/context/layout.context.d.mts +15 -0
- package/dist/context/participant.context.d.cts +8 -0
- package/dist/context/participant.context.d.mts +8 -0
- package/dist/context/pin.context.d.cts +21 -0
- package/dist/context/pin.context.d.mts +21 -0
- package/dist/context/room.context.d.cts +8 -0
- package/dist/context/room.context.d.mts +8 -0
- package/dist/context/session.context.d.cts +8 -0
- package/dist/context/session.context.d.mts +8 -0
- package/dist/context/toast.context.d.cts +17 -0
- package/dist/context/toast.context.d.mts +17 -0
- package/dist/context/track-reference.context.d.cts +8 -0
- package/dist/context/track-reference.context.d.mts +8 -0
- package/dist/context/widget.context.d.cts +21 -0
- package/dist/context/widget.context.d.mts +21 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/internal/emitter.d.cts +17 -0
- package/dist/internal/emitter.d.mts +17 -0
- package/dist/internal/index.d.cts +4 -0
- package/dist/internal/index.d.mts +4 -0
- package/dist/internal/observable.d.cts +3 -0
- package/dist/internal/observable.d.mts +3 -0
- package/dist/internal/permissions.d.cts +4 -0
- package/dist/internal/permissions.d.mts +4 -0
- package/dist/internal/refs.d.cts +1 -0
- package/dist/internal/refs.d.mts +1 -0
- package/dist/krisp/index.d.cts +1 -0
- package/dist/krisp/index.d.mts +1 -0
- package/dist/krisp.cjs +2 -0
- package/dist/krisp.cjs.map +1 -0
- package/dist/krisp.js +62 -0
- package/dist/krisp.js.map +1 -0
- package/dist/livekit-vue.cjs +2 -0
- package/dist/livekit-vue.cjs.map +1 -0
- package/dist/livekit-vue.js +5095 -20519
- package/dist/livekit-vue.js.map +1 -0
- package/dist/livekit-vue.umd.js +4 -0
- package/dist/livekit-vue.umd.js.map +1 -0
- package/dist/style-CDggj9VO.js +14 -0
- package/dist/style-CDggj9VO.js.map +1 -0
- package/dist/style-CkQyDSsh.cjs +2 -0
- package/dist/style-CkQyDSsh.cjs.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/types/agent.types.d.cts +2 -0
- package/dist/types/agent.types.d.mts +2 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/livekit-room.types.d.cts +19 -0
- package/dist/types/livekit-room.types.d.mts +19 -0
- package/dist/types/participant.types.d.cts +2 -0
- package/dist/types/participant.types.d.mts +2 -0
- package/dist/useLocalParticipant-ByBAgL8i.js +50 -0
- package/dist/useLocalParticipant-ByBAgL8i.js.map +1 -0
- package/dist/useLocalParticipant-Dn5NE_KM.cjs +2 -0
- package/dist/useLocalParticipant-Dn5NE_KM.cjs.map +1 -0
- package/dist/utils/media-choices.utils.d.cts +7 -0
- package/dist/utils/media-choices.utils.d.mts +7 -0
- package/dist/{src/utils/room.utils.d.ts → utils/room.utils.d.cts} +1 -1
- package/dist/utils/room.utils.d.mts +1 -0
- package/package.json +103 -66
- package/dist/favicon.ico +0 -0
- package/dist/index.css +0 -1
- package/dist/livekit-vue.umd.cjs +0 -62
- package/dist/src/assets/index.d.ts +0 -0
- package/dist/src/components/controls/TrackToggle.vue.d.ts +0 -3
- package/dist/src/components/controls/buttons.d.ts +0 -4
- package/dist/src/components/controls/index.d.ts +0 -3
- package/dist/src/components/controls/track_toggle.d.ts +0 -12
- package/dist/src/components/icons/ParticipantPlaceholderIcon.vue.d.ts +0 -2
- package/dist/src/components/icons/TrackIcon.vue.d.ts +0 -7
- package/dist/src/components/index.d.ts +0 -3
- package/dist/src/components/participant/audio_track.d.ts +0 -7
- package/dist/src/composables/index.d.ts +0 -37
- package/dist/src/composables/private/useObservableState.d.ts +0 -8
- package/dist/src/composables/useAudioPlayback.d.ts +0 -11
- package/dist/src/composables/useClearPinButton.d.ts +0 -5
- package/dist/src/composables/useConnectionQualityIndicator.d.ts +0 -10
- package/dist/src/composables/useConnectionState.d.ts +0 -3
- package/dist/src/composables/useDataChannel.d.ts +0 -15
- package/dist/src/composables/useDisconnectButton.d.ts +0 -5
- package/dist/src/composables/useFacingMode.d.ts +0 -10
- package/dist/src/composables/useFocusToggle.d.ts +0 -11
- package/dist/src/composables/useGridLayout.d.ts +0 -10
- package/dist/src/composables/useIsEncrypted.d.ts +0 -8
- package/dist/src/composables/useIsMuted.d.ts +0 -7
- package/dist/src/composables/useIsRecording.d.ts +0 -5
- package/dist/src/composables/useIsSpeaking.d.ts +0 -5
- package/dist/src/composables/useLiveKitRoom.d.ts +0 -8
- package/dist/src/composables/useLocalParticipant.d.ts +0 -16
- package/dist/src/composables/useParticipantTile.d.ts +0 -11
- package/dist/src/composables/useParticipantTracks.d.ts +0 -4
- package/dist/src/composables/useParticipants.d.ts +0 -7
- package/dist/src/composables/usePersistentUserChoices.d.ts +0 -16
- package/dist/src/composables/usePinnedTracks.d.ts +0 -4
- package/dist/src/composables/useRemoteParticipant.d.ts +0 -7
- package/dist/src/composables/useRemoteParticipants.d.ts +0 -7
- package/dist/src/composables/useRoomInfo.d.ts +0 -13
- package/dist/src/composables/useSortedParticipants.d.ts +0 -3
- package/dist/src/composables/useSpeakingParticipants.d.ts +0 -3
- package/dist/src/composables/useStartAudio.d.ts +0 -11
- package/dist/src/composables/useStartVideo.d.ts +0 -11
- package/dist/src/composables/useToken.d.ts +0 -10
- package/dist/src/composables/useTrack.d.ts +0 -3
- package/dist/src/composables/useTrackByName.d.ts +0 -3
- package/dist/src/composables/useTrackMutedIndicator.d.ts +0 -6
- package/dist/src/composables/useTrackRefBySourceOrName.d.ts +0 -4
- package/dist/src/composables/useTrackSyncTime.d.ts +0 -6
- package/dist/src/composables/useTrackToggle.d.ts +0 -21
- package/dist/src/composables/useTrackVolume.d.ts +0 -28
- package/dist/src/composables/useTracks.d.ts +0 -10
- package/dist/src/composables/useVisualStableUpdate.d.ts +0 -8
- package/dist/src/context/index.d.ts +0 -6
- package/dist/src/context/layout.context.d.ts +0 -28
- package/dist/src/context/participant.context.d.ts +0 -9
- package/dist/src/context/pin.context.d.ts +0 -26
- package/dist/src/context/room.context.d.ts +0 -9
- package/dist/src/context/track_reference.context.d.ts +0 -6
- package/dist/src/context/widget.context.d.ts +0 -7
- package/dist/src/index.d.ts +0 -3
- package/dist/src/types/livekit_room.types.d.ts +0 -68
- package/src/assets/icons/chevron-down.svg +0 -4
- package/src/assets/icons/chevron-up.svg +0 -4
- package/src/assets/icons/frown.svg +0 -7
- package/src/assets/icons/heart.svg +0 -6
- package/src/assets/icons/mic-off.svg +0 -8
- package/src/assets/icons/mic.svg +0 -7
- package/src/assets/icons/phone-hang-up.svg +0 -9
- package/src/assets/icons/share-screen-off.svg +0 -6
- package/src/assets/icons/share-screen.svg +0 -7
- package/src/assets/icons/smile.svg +0 -7
- package/src/assets/icons/thumbs-down.svg +0 -6
- package/src/assets/icons/thumbs-up.svg +0 -6
- package/src/assets/icons/video-off.svg +0 -5
- package/src/assets/icons/video.svg +0 -5
- package/src/assets/index.ts +0 -1
- package/src/assets/placeholders/participant.svg +0 -8
- package/src/components/controls/TrackToggle.vue +0 -20
- package/src/components/controls/buttons.ts +0 -5
- package/src/components/controls/index.ts +0 -3
- package/src/components/controls/track_toggle.ts +0 -13
- package/src/components/icons/ParticipantPlaceholderIcon.vue +0 -7
- package/src/components/icons/TrackIcon.vue +0 -55
- package/src/components/index.ts +0 -3
- package/src/components/participant/AudioTrack.vue +0 -17
- package/src/components/participant/audio_track.ts +0 -8
- package/src/composables/index.ts +0 -89
- package/src/composables/private/useObservableState.ts +0 -44
- package/src/composables/useAudioPlayback.ts +0 -42
- package/src/composables/useClearPinButton.ts +0 -41
- package/src/composables/useConnectionQualityIndicator.ts +0 -39
- package/src/composables/useConnectionState.ts +0 -21
- package/src/composables/useDataChannel.ts +0 -56
- package/src/composables/useDisconnectButton.ts +0 -28
- package/src/composables/useFacingMode.ts +0 -28
- package/src/composables/useFocusToggle.ts +0 -38
- package/src/composables/useGridLayout.ts +0 -44
- package/src/composables/useIsEncrypted.ts +0 -34
- package/src/composables/useIsMuted.ts +0 -56
- package/src/composables/useIsRecording.ts +0 -30
- package/src/composables/useIsSpeaking.ts +0 -23
- package/src/composables/useLiveKitRoom.ts +0 -219
- package/src/composables/useLocalParticipant.ts +0 -64
- package/src/composables/useParticipantTile.ts +0 -68
- package/src/composables/useParticipantTracks.ts +0 -36
- package/src/composables/useParticipants.ts +0 -25
- package/src/composables/usePersistentUserChoices.ts +0 -64
- package/src/composables/usePinnedTracks.ts +0 -16
- package/src/composables/useRemoteParticipant.ts +0 -42
- package/src/composables/useRemoteParticipants.ts +0 -27
- package/src/composables/useRoomInfo.ts +0 -42
- package/src/composables/useSortedParticipants.ts +0 -21
- package/src/composables/useSpeakingParticipants.ts +0 -22
- package/src/composables/useStartAudio.ts +0 -53
- package/src/composables/useStartVideo.ts +0 -53
- package/src/composables/useToken.ts +0 -40
- package/src/composables/useTrack.ts +0 -11
- package/src/composables/useTrackByName.ts +0 -11
- package/src/composables/useTrackMutedIndicator.ts +0 -34
- package/src/composables/useTrackRefBySourceOrName.ts +0 -39
- package/src/composables/useTrackSyncTime.ts +0 -32
- package/src/composables/useTrackToggle.ts +0 -110
- package/src/composables/useTrackVolume.ts +0 -268
- package/src/composables/useTracks.ts +0 -122
- package/src/composables/useVisualStableUpdate.ts +0 -57
- package/src/context/index.ts +0 -6
- package/src/context/layout.context.ts +0 -46
- package/src/context/participant.context.ts +0 -33
- package/src/context/pin.context.ts +0 -50
- package/src/context/room.context.ts +0 -31
- package/src/context/track_reference.context.ts +0 -29
- package/src/context/widget.context.ts +0 -17
- package/src/index.css +0 -1
- package/src/index.ts +0 -5
- package/src/types/livekit_room.types.ts +0 -78
- package/src/utils/room.utils.ts +0 -9
package/README.md
CHANGED
|
@@ -1,45 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# LiveKit Vue
|
|
2
2
|
|
|
3
|
-
Vue
|
|
3
|
+
`@mrksbnc/livekit-vue` is a Vue 3 port of the LiveKit React components. It gives you components,
|
|
4
|
+
prefabs and composables to build video, audio and voice agent apps on
|
|
5
|
+
[LiveKit](https://livekit.io). The library builds on `@livekit/components-core` and `livekit-client`.
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Prerequisites
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
- Node.js 22.12 or later.
|
|
10
|
+
- Vue 3.5 or later, and `livekit-client` 2.26 or later.
|
|
11
|
+
- A LiveKit server URL, and a participant token that your backend issues.
|
|
8
12
|
|
|
9
|
-
##
|
|
13
|
+
## Quick start
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
1. Install the package and the LiveKit client:
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mrksbnc/livekit-vue livekit-client
|
|
19
|
+
```
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
2. Import the stylesheet once, in `main.ts`:
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import '@mrksbnc/livekit-vue/styles.css';
|
|
25
|
+
```
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
pnpm install
|
|
21
|
-
```
|
|
27
|
+
3. Join a room with `LiveKitRoom`, and render the `VideoConference` prefab in it:
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
```vue
|
|
30
|
+
<template>
|
|
31
|
+
<LiveKitRoom
|
|
32
|
+
:server-url="serverUrl"
|
|
33
|
+
:token="token"
|
|
34
|
+
:audio="true"
|
|
35
|
+
:video="true"
|
|
36
|
+
>
|
|
37
|
+
<VideoConference />
|
|
38
|
+
</LiveKitRoom>
|
|
39
|
+
</template>
|
|
24
40
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
import { LiveKitRoom, VideoConference } from '@mrksbnc/livekit-vue';
|
|
28
43
|
|
|
29
|
-
|
|
44
|
+
const serverUrl = 'wss://your-project.livekit.cloud';
|
|
45
|
+
const token = 'your-participant-token';
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
To filter noise with Krisp, install `@livekit/krisp-noise-filter` and import `useKrispNoiseFilter`
|
|
50
|
+
from `@mrksbnc/livekit-vue/krisp`. To blur or replace the camera background, install
|
|
51
|
+
`@livekit/track-processors` and import `BackgroundEffectSelect` or `useBackgroundEffect` from
|
|
52
|
+
`@mrksbnc/livekit-vue/background`.
|
|
34
53
|
|
|
35
|
-
|
|
54
|
+
## Documentation
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
pnpm lint
|
|
45
|
-
```
|
|
56
|
+
- [Architecture](https://github.com/mrksbnc/livekit-vue/blob/main/doc/architecture.md): the layers
|
|
57
|
+
of the library, its dependencies and its builds.
|
|
58
|
+
- [Room flows](https://github.com/mrksbnc/livekit-vue/blob/main/doc/room-flows.md): how the library
|
|
59
|
+
connects, renders tracks and starts an agent session.
|
|
60
|
+
- [Configuration](https://github.com/mrksbnc/livekit-vue/blob/main/doc/configuration.md): the props
|
|
61
|
+
of `LiveKitRoom`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { LocalVideoTrack } from 'livekit-client';
|
|
2
|
+
import { LkStyleProps } from '../components/style.cjs';
|
|
3
|
+
import { BackgroundEffect, BackgroundEffectProcessorOptions } from '../composables/useBackgroundEffect.cjs';
|
|
4
|
+
export interface BackgroundImage {
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly thumbnailUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BackgroundEffectSelectProps extends LkStyleProps {
|
|
10
|
+
track?: LocalVideoTrack;
|
|
11
|
+
images?: readonly BackgroundImage[];
|
|
12
|
+
blurRadius?: number;
|
|
13
|
+
processorOptions?: BackgroundEffectProcessorOptions;
|
|
14
|
+
allowUpload?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface BackgroundEffectOptionSlotProps {
|
|
17
|
+
effect: BackgroundEffect;
|
|
18
|
+
label: string;
|
|
19
|
+
active: boolean;
|
|
20
|
+
select: () => void;
|
|
21
|
+
}
|
|
22
|
+
type __VLS_Props = BackgroundEffectSelectProps;
|
|
23
|
+
type __VLS_Slots = {
|
|
24
|
+
heading?: () => unknown;
|
|
25
|
+
unsupported?: () => unknown;
|
|
26
|
+
option?: (props: BackgroundEffectOptionSlotProps) => unknown;
|
|
27
|
+
upload?: () => unknown;
|
|
28
|
+
};
|
|
29
|
+
type __VLS_ModelProps = {
|
|
30
|
+
'effect'?: BackgroundEffect;
|
|
31
|
+
};
|
|
32
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
33
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
34
|
+
error: (error: Error) => any;
|
|
35
|
+
upload: (file: File) => any;
|
|
36
|
+
"update:effect": (value: BackgroundEffect) => any;
|
|
37
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
38
|
+
onError?: ((error: Error) => any) | undefined;
|
|
39
|
+
onUpload?: ((file: File) => any) | undefined;
|
|
40
|
+
"onUpdate:effect"?: ((value: BackgroundEffect) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
track: LocalVideoTrack;
|
|
43
|
+
images: readonly BackgroundImage[];
|
|
44
|
+
blurRadius: number;
|
|
45
|
+
processorOptions: BackgroundEffectProcessorOptions;
|
|
46
|
+
allowUpload: boolean;
|
|
47
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
48
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
51
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
52
|
+
new (): {
|
|
53
|
+
$slots: S;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { LocalVideoTrack } from 'livekit-client';
|
|
2
|
+
import { LkStyleProps } from '../components/style.mjs';
|
|
3
|
+
import { BackgroundEffect, BackgroundEffectProcessorOptions } from '../composables/useBackgroundEffect.mjs';
|
|
4
|
+
export interface BackgroundImage {
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly thumbnailUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BackgroundEffectSelectProps extends LkStyleProps {
|
|
10
|
+
track?: LocalVideoTrack;
|
|
11
|
+
images?: readonly BackgroundImage[];
|
|
12
|
+
blurRadius?: number;
|
|
13
|
+
processorOptions?: BackgroundEffectProcessorOptions;
|
|
14
|
+
allowUpload?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface BackgroundEffectOptionSlotProps {
|
|
17
|
+
effect: BackgroundEffect;
|
|
18
|
+
label: string;
|
|
19
|
+
active: boolean;
|
|
20
|
+
select: () => void;
|
|
21
|
+
}
|
|
22
|
+
type __VLS_Props = BackgroundEffectSelectProps;
|
|
23
|
+
type __VLS_Slots = {
|
|
24
|
+
heading?: () => unknown;
|
|
25
|
+
unsupported?: () => unknown;
|
|
26
|
+
option?: (props: BackgroundEffectOptionSlotProps) => unknown;
|
|
27
|
+
upload?: () => unknown;
|
|
28
|
+
};
|
|
29
|
+
type __VLS_ModelProps = {
|
|
30
|
+
'effect'?: BackgroundEffect;
|
|
31
|
+
};
|
|
32
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
33
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
34
|
+
error: (error: Error) => any;
|
|
35
|
+
upload: (file: File) => any;
|
|
36
|
+
"update:effect": (value: BackgroundEffect) => any;
|
|
37
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
38
|
+
onError?: ((error: Error) => any) | undefined;
|
|
39
|
+
onUpload?: ((file: File) => any) | undefined;
|
|
40
|
+
"onUpdate:effect"?: ((value: BackgroundEffect) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
track: LocalVideoTrack;
|
|
43
|
+
images: readonly BackgroundImage[];
|
|
44
|
+
blurRadius: number;
|
|
45
|
+
processorOptions: BackgroundEffectProcessorOptions;
|
|
46
|
+
allowUpload: boolean;
|
|
47
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
48
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
51
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
52
|
+
new (): {
|
|
53
|
+
$slots: S;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as BackgroundEffectSelect } from './BackgroundEffectSelect.vue.cjs';
|
|
2
|
+
export type { BackgroundEffectOptionSlotProps, BackgroundEffectSelectProps, BackgroundImage, } from './BackgroundEffectSelect.vue.cjs';
|
|
3
|
+
export { BACKGROUND_EFFECT_MODE, BACKGROUND_PROCESSOR_NAME, DEFAULT_BLUR_RADIUS, useBackgroundEffect, type BackgroundEffect, type BackgroundEffectBlur, type BackgroundEffectImage, type BackgroundEffectNone, type BackgroundEffectProcessorOptions, type UseBackgroundEffect, type UseBackgroundEffectProps, } from '../composables/useBackgroundEffect.cjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as BackgroundEffectSelect } from './BackgroundEffectSelect.vue.mjs';
|
|
2
|
+
export type { BackgroundEffectOptionSlotProps, BackgroundEffectSelectProps, BackgroundImage, } from './BackgroundEffectSelect.vue.mjs';
|
|
3
|
+
export { BACKGROUND_EFFECT_MODE, BACKGROUND_PROCESSOR_NAME, DEFAULT_BLUR_RADIUS, useBackgroundEffect, type BackgroundEffect, type BackgroundEffectBlur, type BackgroundEffectImage, type BackgroundEffectNone, type BackgroundEffectProcessorOptions, type UseBackgroundEffect, type UseBackgroundEffectProps, } from '../composables/useBackgroundEffect.mjs';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue");const t=require("./style-CkQyDSsh.cjs");let n=require("@livekit/components-core"),r=require("@livekit/track-processors");var i={NONE:`none`,BLUR:`blur`,IMAGE:`image`},a=`lk-background-effect`,o=48;function s(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`lk-background-effect`&&`switchTo`in e}function c(e,t){return e.mode===i.BLUR?{mode:`background-blur`,blurRadius:e.radius??t}:{mode:`virtual-background`,imagePath:e.imageUrl}}function l(t){let o=t.effect??(0,e.ref)({mode:i.NONE}),l=(0,r.supportsBackgroundProcessors)(),u=(0,e.ref)(!1),d=(0,e.ref)(),f=t.blurRadius??48,p=Promise.resolve(),m=0;async function h(e,n){let o=e.getProcessor();if(n.mode===i.NONE){s(o)&&await e.stopProcessor();return}let l=c(n,f);if(s(o)){await o.switchTo(l);return}let u=(0,r.BackgroundProcessor)({...t.processorOptions,...l},a);await e.setProcessor(u)}function g(e,t){e!==void 0&&l&&(m+=1,u.value=!0,p=p.then(()=>h(e,t)).then(()=>{d.value=void 0}).catch(e=>{let t=e instanceof Error?e:Error(String(e));n.log.error(`Background effect: error applying the effect`,t),d.value=t}).finally(()=>{--m,u.value=m>0}))}async function _(e){o.value=e,await p}return(0,e.watch)(()=>(0,e.toValue)(t.track),e=>{g(e,o.value)},{immediate:!0}),(0,e.watch)(o,n=>{g((0,e.toValue)(t.track),n)},{flush:`sync`}),{effect:o,isSupported:l,isPending:(0,e.readonly)(u),error:(0,e.readonly)(d),setEffect:_}}var u=[`data-lk-pending`],d={key:0,class:`lk-device-menu-heading`},f={key:1,class:`lk-background-effect-unsupported`},p=[`aria-selected`,`data-lk-active`],m=[`data-lk-mode`,`title`,`aria-label`,`disabled`,`onClick`],h={key:0,class:`lk-icon`,"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`},g={key:1,class:`lk-icon`,"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`currentColor`},_=[`data-lk-disabled`],v=[`disabled`],y={key:0,class:`lk-icon`,"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`},b=(0,e.defineComponent)({__name:`BackgroundEffectSelect`,props:(0,e.mergeModels)({track:{default:void 0},images:{default:()=>[]},blurRadius:{default:void 0},processorOptions:{default:void 0},allowUpload:{type:Boolean,default:!0},size:{},unstyled:{type:Boolean}},{effect:{default:()=>({mode:i.NONE})},effectModifiers:{}}),emits:(0,e.mergeModels)([`error`,`upload`],[`update:effect`]),setup(n,{emit:r}){let a=n,o=r,s=(0,e.useModel)(n,`effect`),{isSupported:c,isPending:b,error:x}=l({track:()=>a.track,effect:s,blurRadius:a.blurRadius,processorOptions:a.processorOptions}),S=t.t(a,()=>[`lk-background-effect-select`]),C=(0,e.computed)(()=>{let e=a.images.map(e=>({key:`image:${e.url}`,label:e.label,effect:{mode:i.IMAGE,imageUrl:e.url},thumbnail:e.thumbnailUrl??e.url}));return[{key:`none`,label:`No effect`,effect:{mode:i.NONE}},{key:`blur`,label:`Blur`,effect:{mode:i.BLUR}},...e,...T(a.images)]}),w;function T(e){let t=s.value;return t.mode!==i.IMAGE||e.some(e=>e.url===t.imageUrl)?[]:[{key:`custom`,label:`Your image`,effect:t,thumbnail:t.imageUrl}]}function E(e){let t=e.target;if(!(t instanceof HTMLInputElement))return;let n=t.files?.[0];t.value=``,n!==void 0&&(w!==void 0&&URL.revokeObjectURL(w),w=URL.createObjectURL(n),s.value={mode:i.IMAGE,imageUrl:w},o(`upload`,n))}function D(e){let t=s.value;return e.mode===i.IMAGE?t.mode===i.IMAGE&&t.imageUrl===e.imageUrl:t.mode===e.mode}function O(e){D(e)||(s.value=e)}return(0,e.watch)(x,e=>{e!==void 0&&o(`error`,e)}),(t,r)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,(0,e.mergeProps)((0,e.unref)(S),{"data-lk-pending":(0,e.unref)(b)}),[n.unstyled?(0,e.createCommentVNode)(``,!0):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,d,[(0,e.renderSlot)(t.$slots,`heading`,{},()=>[r[0]||=(0,e.createTextVNode)(`Background`,-1)])])),(0,e.unref)(c)?((0,e.openBlock)(),(0,e.createElementBlock)(`ul`,{key:2,role:`listbox`,"aria-label":`Background effect`,class:(0,e.normalizeClass)(n.unstyled?void 0:`lk-background-effect-options`)},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(C.value,a=>((0,e.openBlock)(),(0,e.createElementBlock)(`li`,{key:a.key,role:`option`,"aria-selected":D(a.effect),"data-lk-active":D(a.effect)},[(0,e.renderSlot)(t.$slots,`option`,{effect:a.effect,label:a.label,active:D(a.effect),select:()=>O(a.effect)},()=>[(0,e.createElementVNode)(`button`,{type:`button`,class:(0,e.normalizeClass)(n.unstyled?void 0:`lk-background-effect-option`),"data-lk-mode":a.effect.mode,title:a.label,"aria-label":a.label,disabled:n.track===void 0,style:(0,e.normalizeStyle)(a.thumbnail===void 0?void 0:{backgroundImage:`url(${JSON.stringify(a.thumbnail)})`}),onClick:e=>O(a.effect)},[a.effect.mode===(0,e.unref)(i).NONE?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,h,[...r[2]||=[(0,e.createElementVNode)(`circle`,{cx:`8`,cy:`8`,r:`6`},null,-1),(0,e.createElementVNode)(`path`,{d:`m3.8 12.2 8.4-8.4`},null,-1)]])):a.effect.mode===(0,e.unref)(i).BLUR?((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,g,[...r[3]||=[(0,e.createStaticVNode)(`<circle cx="8" cy="5.75" r="2.5"></circle><path d="M3.75 14.5c0-2.6 1.9-4.5 4.25-4.5s4.25 1.9 4.25 4.5z"></path><g opacity=".45"><circle cx="1.75" cy="2.5" r=".9"></circle><circle cx="1.75" cy="6.25" r="1.1"></circle><circle cx="1.75" cy="10" r=".9"></circle><circle cx="1.75" cy="13.75" r=".7"></circle><circle cx="14.25" cy="2.5" r=".9"></circle><circle cx="14.25" cy="6.25" r="1.1"></circle><circle cx="14.25" cy="10" r=".9"></circle><circle cx="14.25" cy="13.75" r=".7"></circle><circle cx="4.5" cy="1.5" r=".7"></circle><circle cx="11.5" cy="1.5" r=".7"></circle></g>`,3)]])):(0,e.createCommentVNode)(``,!0)],14,m)])],8,p))),128))],2)):((0,e.openBlock)(),(0,e.createElementBlock)(`p`,f,[(0,e.renderSlot)(t.$slots,`unsupported`,{},()=>[r[1]||=(0,e.createTextVNode)(`This browser can't apply background effects.`,-1)])])),(0,e.unref)(c)&&n.allowUpload?((0,e.openBlock)(),(0,e.createElementBlock)(`label`,{key:3,class:(0,e.normalizeClass)(n.unstyled?void 0:`lk-button lk-background-effect-upload`),"data-lk-disabled":n.track===void 0},[(0,e.createElementVNode)(`input`,{type:`file`,accept:`image/*`,class:(0,e.normalizeClass)(n.unstyled?void 0:`lk-sr-only`),disabled:n.track===void 0,onChange:E},null,42,v),n.unstyled?(0,e.createCommentVNode)(``,!0):((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,y,[...r[4]||=[(0,e.createElementVNode)(`path`,{d:`M8 3v10M3 8h10`},null,-1)]])),(0,e.renderSlot)(t.$slots,`upload`,{},()=>[r[5]||=(0,e.createTextVNode)(`Upload image`,-1)])],10,_)):(0,e.createCommentVNode)(``,!0)],16,u))}});exports.BACKGROUND_EFFECT_MODE=i,exports.BACKGROUND_PROCESSOR_NAME=a,exports.BackgroundEffectSelect=b,exports.DEFAULT_BLUR_RADIUS=o,exports.useBackgroundEffect=l;
|
|
2
|
+
//# sourceMappingURL=background.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.cjs","names":["ref","supportsBackgroundProcessors","BackgroundProcessor","log","watch","toValue","readonly","_useModel","useStyleAttrs","computed","watch","_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot","_createTextVNode","_normalizeClass","_Fragment","_renderList","_createElementVNode","_normalizeStyle","vue","require_style","_livekit_components_core","_livekit_track_processors","BACKGROUND_EFFECT_MODE","BACKGROUND_PROCESSOR_NAME","DEFAULT_BLUR_RADIUS","isBackgroundProcessor","processor","toSwitchOptions","effect","blurRadius","useBackgroundEffect","props","isSupported","isPending","error","queue","pendingCount","apply","track","next","current","options","schedule","reason","failure","setEffect","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","BackgroundEffectSelect_default","\"effect\"","\"effectModifiers\"","__props","__emit","emits","styleAttrs","images","image","customOption","uploadedUrl","onUpload","event","input","file","isActive","candidate","select","_ctx","_cache","option","$event"],"sources":["../src/composables/useBackgroundEffect.ts","../src/background/BackgroundEffectSelect.vue"],"sourcesContent":["import { log } from '@livekit/components-core';\nimport {\n\tBackgroundProcessor,\n\tsupportsBackgroundProcessors,\n\ttype BackgroundProcessorWrapper,\n\ttype SegmenterOptions,\n\ttype SwitchBackgroundProcessorOptions,\n} from '@livekit/track-processors';\nimport type { LocalVideoTrack } from 'livekit-client';\nimport { readonly, ref, toValue, watch, type MaybeRefOrGetter, type Ref } from 'vue';\n\nexport const BACKGROUND_EFFECT_MODE = {\n\tNONE: 'none',\n\tBLUR: 'blur',\n\tIMAGE: 'image',\n} as const;\n\nexport interface BackgroundEffectNone {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.NONE;\n}\n\nexport interface BackgroundEffectBlur {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.BLUR;\n\treadonly radius?: number;\n}\n\nexport interface BackgroundEffectImage {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.IMAGE;\n\treadonly imageUrl: string;\n}\n\nexport type BackgroundEffect = BackgroundEffectNone | BackgroundEffectBlur | BackgroundEffectImage;\n\nexport interface BackgroundEffectProcessorOptions {\n\treadonly segmenterOptions?: SegmenterOptions;\n\treadonly assetPaths?: {\n\t\treadonly tasksVisionFileSet?: string;\n\t\treadonly modelAssetPath?: string;\n\t};\n}\n\nexport interface UseBackgroundEffectProps {\n\treadonly track: MaybeRefOrGetter<LocalVideoTrack | undefined>;\n\treadonly effect?: Ref<BackgroundEffect>;\n\treadonly blurRadius?: number;\n\treadonly processorOptions?: BackgroundEffectProcessorOptions;\n}\n\nexport interface UseBackgroundEffect {\n\treadonly effect: Ref<BackgroundEffect>;\n\treadonly isSupported: boolean;\n\treadonly isPending: Readonly<Ref<boolean>>;\n\treadonly error: Readonly<Ref<Error | undefined>>;\n\treadonly setEffect: (effect: BackgroundEffect) => Promise<void>;\n}\n\nexport const BACKGROUND_PROCESSOR_NAME = 'lk-background-effect';\n\nexport const DEFAULT_BLUR_RADIUS = 48;\n\nfunction isBackgroundProcessor(processor: unknown): processor is BackgroundProcessorWrapper {\n\treturn (\n\t\ttypeof processor === 'object' &&\n\t\tprocessor !== null &&\n\t\t'name' in processor &&\n\t\tprocessor.name === BACKGROUND_PROCESSOR_NAME &&\n\t\t'switchTo' in processor\n\t);\n}\n\nfunction toSwitchOptions(\n\teffect: BackgroundEffectBlur | BackgroundEffectImage,\n\tblurRadius: number,\n): SwitchBackgroundProcessorOptions {\n\tif (effect.mode === BACKGROUND_EFFECT_MODE.BLUR) {\n\t\treturn { mode: 'background-blur', blurRadius: effect.radius ?? blurRadius };\n\t}\n\n\treturn { mode: 'virtual-background', imagePath: effect.imageUrl };\n}\n\nexport function useBackgroundEffect(props: UseBackgroundEffectProps): UseBackgroundEffect {\n\tconst effect = props.effect ?? ref<BackgroundEffect>({ mode: BACKGROUND_EFFECT_MODE.NONE });\n\tconst isSupported = supportsBackgroundProcessors();\n\tconst isPending = ref<boolean>(false);\n\tconst error = ref<Error | undefined>();\n\tconst blurRadius = props.blurRadius ?? DEFAULT_BLUR_RADIUS;\n\n\tlet queue: Promise<void> = Promise.resolve();\n\tlet pendingCount = 0;\n\n\tasync function apply(track: LocalVideoTrack, next: BackgroundEffect): Promise<void> {\n\t\tconst current = track.getProcessor();\n\n\t\tif (next.mode === BACKGROUND_EFFECT_MODE.NONE) {\n\t\t\tif (isBackgroundProcessor(current)) {\n\t\t\t\tawait track.stopProcessor();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst options = toSwitchOptions(next, blurRadius);\n\n\t\tif (isBackgroundProcessor(current)) {\n\t\t\tawait current.switchTo(options);\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst processor = BackgroundProcessor(\n\t\t\t{ ...props.processorOptions, ...options },\n\t\t\tBACKGROUND_PROCESSOR_NAME,\n\t\t);\n\n\t\tawait track.setProcessor(processor);\n\t}\n\n\tfunction schedule(track: LocalVideoTrack | undefined, next: BackgroundEffect): void {\n\t\tif (track === undefined || !isSupported) {\n\t\t\treturn;\n\t\t}\n\n\t\tpendingCount += 1;\n\t\tisPending.value = true;\n\n\t\tqueue = queue\n\t\t\t.then(() => apply(track, next))\n\t\t\t.then(() => {\n\t\t\t\terror.value = undefined;\n\t\t\t})\n\t\t\t.catch((reason: unknown) => {\n\t\t\t\tconst failure = reason instanceof Error ? reason : new Error(String(reason));\n\n\t\t\t\tlog.error('Background effect: error applying the effect', failure);\n\t\t\t\terror.value = failure;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tpendingCount -= 1;\n\t\t\t\tisPending.value = pendingCount > 0;\n\t\t\t});\n\t}\n\n\tasync function setEffect(next: BackgroundEffect): Promise<void> {\n\t\teffect.value = next;\n\n\t\tawait queue;\n\t}\n\n\twatch(\n\t\t() => toValue(props.track),\n\t\t(track) => {\n\t\t\tschedule(track, effect.value);\n\t\t},\n\t\t{ immediate: true },\n\t);\n\n\twatch(\n\t\teffect,\n\t\t(next) => {\n\t\t\tschedule(toValue(props.track), next);\n\t\t},\n\t\t{ flush: 'sync' },\n\t);\n\n\tconst background: UseBackgroundEffect = {\n\t\teffect,\n\t\tisSupported,\n\t\tisPending: readonly(isPending),\n\t\terror: readonly(error),\n\t\tsetEffect,\n\t};\n\n\treturn background;\n}\n","<template>\n\t<div\n\t\tv-bind=\"styleAttrs\"\n\t\t:data-lk-pending=\"isPending\"\n\t>\n\t\t<div\n\t\t\tv-if=\"!unstyled\"\n\t\t\tclass=\"lk-device-menu-heading\"\n\t\t>\n\t\t\t<slot name=\"heading\">Background</slot>\n\t\t</div>\n\t\t<p\n\t\t\tv-if=\"!isSupported\"\n\t\t\tclass=\"lk-background-effect-unsupported\"\n\t\t>\n\t\t\t<slot name=\"unsupported\">This browser can't apply background effects.</slot>\n\t\t</p>\n\t\t<ul\n\t\t\tv-else\n\t\t\trole=\"listbox\"\n\t\t\taria-label=\"Background effect\"\n\t\t\t:class=\"unstyled ? undefined : 'lk-background-effect-options'\"\n\t\t>\n\t\t\t<li\n\t\t\t\tv-for=\"option in options\"\n\t\t\t\t:key=\"option.key\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isActive(option.effect)\"\n\t\t\t\t:data-lk-active=\"isActive(option.effect)\"\n\t\t\t>\n\t\t\t\t<slot\n\t\t\t\t\tname=\"option\"\n\t\t\t\t\t:effect=\"option.effect\"\n\t\t\t\t\t:label=\"option.label\"\n\t\t\t\t\t:active=\"isActive(option.effect)\"\n\t\t\t\t\t:select=\"() => select(option.effect)\"\n\t\t\t\t>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t:class=\"unstyled ? undefined : 'lk-background-effect-option'\"\n\t\t\t\t\t\t:data-lk-mode=\"option.effect.mode\"\n\t\t\t\t\t\t:title=\"option.label\"\n\t\t\t\t\t\t:aria-label=\"option.label\"\n\t\t\t\t\t\t:disabled=\"track === undefined\"\n\t\t\t\t\t\t:style=\"\n\t\t\t\t\t\t\toption.thumbnail === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: { backgroundImage: `url(${JSON.stringify(option.thumbnail)})` }\n\t\t\t\t\t\t\"\n\t\t\t\t\t\t@click=\"select(option.effect)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tv-if=\"option.effect.mode === BACKGROUND_EFFECT_MODE.NONE\"\n\t\t\t\t\t\t\tclass=\"lk-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\"\n\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\twidth=\"16\"\n\t\t\t\t\t\t\theight=\"16\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\tstroke-width=\"1.5\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\tcx=\"8\"\n\t\t\t\t\t\t\t\tcy=\"8\"\n\t\t\t\t\t\t\t\tr=\"6\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<path d=\"m3.8 12.2 8.4-8.4\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tv-else-if=\"option.effect.mode === BACKGROUND_EFFECT_MODE.BLUR\"\n\t\t\t\t\t\t\tclass=\"lk-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\"\n\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\twidth=\"16\"\n\t\t\t\t\t\t\theight=\"16\"\n\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<circle\n\t\t\t\t\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\t\tcy=\"10\"\n\t\t\t\t\t\t\t\t\tr=\".9\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"14.25\"\n\t\t\t\t\t\t\t\t\tcy=\"13.75\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"4.5\"\n\t\t\t\t\t\t\t\t\tcy=\"1.5\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"11.5\"\n\t\t\t\t\t\t\t\t\tcy=\"1.5\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t</button>\n\t\t\t\t</slot>\n\t\t\t</li>\n\t\t</ul>\n\t\t<label\n\t\t\tv-if=\"isSupported && allowUpload\"\n\t\t\t:class=\"unstyled ? undefined : 'lk-button lk-background-effect-upload'\"\n\t\t\t:data-lk-disabled=\"track === undefined\"\n\t\t>\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\"image/*\"\n\t\t\t\t:class=\"unstyled ? undefined : 'lk-sr-only'\"\n\t\t\t\t:disabled=\"track === undefined\"\n\t\t\t\t@change=\"onUpload\"\n\t\t\t/>\n\t\t\t<svg\n\t\t\t\tv-if=\"!unstyled\"\n\t\t\t\tclass=\"lk-icon\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\twidth=\"16\"\n\t\t\t\theight=\"16\"\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstroke-width=\"1.5\"\n\t\t\t\tstroke-linecap=\"round\"\n\t\t\t>\n\t\t\t\t<path d=\"M8 3v10M3 8h10\" />\n\t\t\t</svg>\n\t\t\t<slot name=\"upload\">Upload image</slot>\n\t\t</label>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\n\timport type { LocalVideoTrack } from 'livekit-client';\n\timport { computed, watch } from 'vue';\n\n\timport { useStyleAttrs, type LkStyleProps } from '@/components/style';\n\timport {\n\t\tBACKGROUND_EFFECT_MODE,\n\t\tuseBackgroundEffect,\n\t\ttype BackgroundEffect,\n\t\ttype BackgroundEffectProcessorOptions,\n\t} from '@/composables/useBackgroundEffect';\n\n\texport interface BackgroundImage {\n\t\treadonly url: string;\n\t\treadonly label: string;\n\t\treadonly thumbnailUrl?: string;\n\t}\n\n\texport interface BackgroundEffectSelectProps extends LkStyleProps {\n\t\ttrack?: LocalVideoTrack;\n\t\timages?: readonly BackgroundImage[];\n\t\tblurRadius?: number;\n\t\tprocessorOptions?: BackgroundEffectProcessorOptions;\n\t\tallowUpload?: boolean;\n\t}\n\n\texport interface BackgroundEffectOptionSlotProps {\n\t\teffect: BackgroundEffect;\n\t\tlabel: string;\n\t\tactive: boolean;\n\t\tselect: () => void;\n\t}\n\n\tinterface BackgroundEffectOption {\n\t\treadonly key: string;\n\t\treadonly label: string;\n\t\treadonly effect: BackgroundEffect;\n\t\treadonly thumbnail?: string;\n\t}\n\n\tconst props = withDefaults(defineProps<BackgroundEffectSelectProps>(), {\n\t\ttrack: undefined,\n\t\timages: () => [],\n\t\tblurRadius: undefined,\n\t\tprocessorOptions: undefined,\n\t\tallowUpload: true,\n\t});\n\n\tconst emits = defineEmits<{\n\t\terror: [error: Error];\n\t\tupload: [file: File];\n\t}>();\n\n\tconst effect = defineModel<BackgroundEffect>('effect', {\n\t\tdefault: () => ({ mode: BACKGROUND_EFFECT_MODE.NONE }),\n\t});\n\n\tdefineSlots<{\n\t\theading?: () => unknown;\n\t\tunsupported?: () => unknown;\n\t\toption?: (props: BackgroundEffectOptionSlotProps) => unknown;\n\t\tupload?: () => unknown;\n\t}>();\n\n\tconst { isSupported, isPending, error } = useBackgroundEffect({\n\t\ttrack: () => props.track,\n\t\teffect,\n\t\tblurRadius: props.blurRadius,\n\t\tprocessorOptions: props.processorOptions,\n\t});\n\n\tconst styleAttrs = useStyleAttrs(props, () => ['lk-background-effect-select']);\n\n\tconst options = computed<BackgroundEffectOption[]>(() => {\n\t\tconst images = props.images.map<BackgroundEffectOption>((image) => ({\n\t\t\tkey: `image:${image.url}`,\n\t\t\tlabel: image.label,\n\t\t\teffect: { mode: BACKGROUND_EFFECT_MODE.IMAGE, imageUrl: image.url },\n\t\t\tthumbnail: image.thumbnailUrl ?? image.url,\n\t\t}));\n\n\t\treturn [\n\t\t\t{ key: 'none', label: 'No effect', effect: { mode: BACKGROUND_EFFECT_MODE.NONE } },\n\t\t\t{ key: 'blur', label: 'Blur', effect: { mode: BACKGROUND_EFFECT_MODE.BLUR } },\n\t\t\t...images,\n\t\t\t...customOption(props.images),\n\t\t];\n\t});\n\n\tlet uploadedUrl: string | undefined;\n\n\tfunction customOption(images: readonly BackgroundImage[]): BackgroundEffectOption[] {\n\t\tconst current = effect.value;\n\n\t\tif (\n\t\t\tcurrent.mode !== BACKGROUND_EFFECT_MODE.IMAGE ||\n\t\t\timages.some((image) => image.url === current.imageUrl)\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [{ key: 'custom', label: 'Your image', effect: current, thumbnail: current.imageUrl }];\n\t}\n\n\tfunction onUpload(event: Event): void {\n\t\tconst input = event.target;\n\n\t\tif (!(input instanceof HTMLInputElement)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = input.files?.[0];\n\t\tinput.value = '';\n\n\t\tif (file === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (uploadedUrl !== undefined) {\n\t\t\tURL.revokeObjectURL(uploadedUrl);\n\t\t}\n\n\t\tuploadedUrl = URL.createObjectURL(file);\n\t\teffect.value = { mode: BACKGROUND_EFFECT_MODE.IMAGE, imageUrl: uploadedUrl };\n\t\temits('upload', file);\n\t}\n\n\tfunction isActive(candidate: BackgroundEffect): boolean {\n\t\tconst current = effect.value;\n\n\t\tif (candidate.mode === BACKGROUND_EFFECT_MODE.IMAGE) {\n\t\t\treturn (\n\t\t\t\tcurrent.mode === BACKGROUND_EFFECT_MODE.IMAGE && current.imageUrl === candidate.imageUrl\n\t\t\t);\n\t\t}\n\n\t\treturn current.mode === candidate.mode;\n\t}\n\n\tfunction select(next: BackgroundEffect): void {\n\t\tif (!isActive(next)) {\n\t\t\teffect.value = next;\n\t\t}\n\t}\n\n\twatch(error, (failure) => {\n\t\tif (failure !== undefined) {\n\t\t\temits('error', failure);\n\t\t}\n\t});\n</script>\n"],"mappings":"A,iNAWA,IAAa0B,EAAyB,CACrC,KAAM,OACN,KAAM,OACN,MAAO,OACR,EAyCaC,EAA4B,uBAE5BC,EAAsB,GAEnC,SAASC,EAAsBC,EAA6D,CAC3F,OACC,OAAOA,GAAc,YACrBA,GACA,SAAUA,GACVA,EAAU,OAAA,wBACV,aAAcA,CAEhB,CAEA,SAASC,EACRC,EACAC,EACmC,CAKnC,OAJID,EAAO,OAASN,EAAuB,KACnC,CAAE,KAAM,kBAAmB,WAAYM,EAAO,QAAUC,CAAW,EAGpE,CAAE,KAAM,qBAAsB,UAAWD,EAAO,QAAS,CACjE,CAEA,SAAgBE,EAAoBC,EAAsD,CACzF,IAAMH,EAASG,EAAM,SAAA,EAAUnC,EAAAA,IAAAA,CAAsB,CAAE,KAAM0B,EAAuB,IAAK,CAAC,EACpFU,GAAA,EAAcnC,EAAAA,6BAAAA,CAA6B,EAC3CoC,GAAA,EAAYrC,EAAAA,IAAAA,CAAa,EAAK,EAC9BsC,GAAA,EAAQtC,EAAAA,IAAAA,CAAuB,EAC/BiC,EAAaE,EAAM,YAAA,GAErBI,EAAuB,QAAQ,QAAQ,EACvCC,EAAe,EAEnB,eAAeC,EAAMC,EAAwBC,EAAuC,CACnF,IAAMC,EAAUF,EAAM,aA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gBAAAA,CAAA,eAAY,EAAA,C"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createStaticVNode as a, createTextVNode as o, defineComponent as s, mergeModels as c, mergeProps as l, normalizeClass as u, normalizeStyle as d, openBlock as f, readonly as p, ref as m, renderList as h, renderSlot as g, toValue as _, unref as v, useModel as y, watch as b } from "vue";
|
|
2
|
+
import { t as x } from "./style-CDggj9VO.js";
|
|
3
|
+
import { log as S } from "@livekit/components-core";
|
|
4
|
+
import { BackgroundProcessor as C, supportsBackgroundProcessors as w } from "@livekit/track-processors";
|
|
5
|
+
// src/composables/useBackgroundEffect.ts
|
|
6
|
+
var T = {
|
|
7
|
+
NONE: "none",
|
|
8
|
+
BLUR: "blur",
|
|
9
|
+
IMAGE: "image"
|
|
10
|
+
}, E = "lk-background-effect", D = 48;
|
|
11
|
+
function O(e) {
|
|
12
|
+
return typeof e == "object" && !!e && "name" in e && e.name === "lk-background-effect" && "switchTo" in e;
|
|
13
|
+
}
|
|
14
|
+
function k(e, t) {
|
|
15
|
+
return e.mode === T.BLUR ? {
|
|
16
|
+
mode: "background-blur",
|
|
17
|
+
blurRadius: e.radius ?? t
|
|
18
|
+
} : {
|
|
19
|
+
mode: "virtual-background",
|
|
20
|
+
imagePath: e.imageUrl
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function A(e) {
|
|
24
|
+
let t = e.effect ?? m({ mode: T.NONE }), n = w(), r = m(!1), i = m(), a = e.blurRadius ?? 48, o = Promise.resolve(), s = 0;
|
|
25
|
+
async function c(t, n) {
|
|
26
|
+
let r = t.getProcessor();
|
|
27
|
+
if (n.mode === T.NONE) {
|
|
28
|
+
O(r) && await t.stopProcessor();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let i = k(n, a);
|
|
32
|
+
if (O(r)) {
|
|
33
|
+
await r.switchTo(i);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let o = C({
|
|
37
|
+
...e.processorOptions,
|
|
38
|
+
...i
|
|
39
|
+
}, E);
|
|
40
|
+
await t.setProcessor(o);
|
|
41
|
+
}
|
|
42
|
+
function l(e, t) {
|
|
43
|
+
e !== void 0 && n && (s += 1, r.value = !0, o = o.then(() => c(e, t)).then(() => {
|
|
44
|
+
i.value = void 0;
|
|
45
|
+
}).catch((e) => {
|
|
46
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
47
|
+
S.error("Background effect: error applying the effect", t), i.value = t;
|
|
48
|
+
}).finally(() => {
|
|
49
|
+
--s, r.value = s > 0;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async function u(e) {
|
|
53
|
+
t.value = e, await o;
|
|
54
|
+
}
|
|
55
|
+
return b(() => _(e.track), (e) => {
|
|
56
|
+
l(e, t.value);
|
|
57
|
+
}, { immediate: !0 }), b(t, (t) => {
|
|
58
|
+
l(_(e.track), t);
|
|
59
|
+
}, { flush: "sync" }), {
|
|
60
|
+
effect: t,
|
|
61
|
+
isSupported: n,
|
|
62
|
+
isPending: p(r),
|
|
63
|
+
error: p(i),
|
|
64
|
+
setEffect: u
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// src/background/BackgroundEffectSelect.vue?vue&type=script&setup=true&lang.ts
|
|
68
|
+
var j = ["data-lk-pending"], M = {
|
|
69
|
+
key: 0,
|
|
70
|
+
class: "lk-device-menu-heading"
|
|
71
|
+
}, N = {
|
|
72
|
+
key: 1,
|
|
73
|
+
class: "lk-background-effect-unsupported"
|
|
74
|
+
}, P = ["aria-selected", "data-lk-active"], F = [
|
|
75
|
+
"data-lk-mode",
|
|
76
|
+
"title",
|
|
77
|
+
"aria-label",
|
|
78
|
+
"disabled",
|
|
79
|
+
"onClick"
|
|
80
|
+
], I = {
|
|
81
|
+
key: 0,
|
|
82
|
+
class: "lk-icon",
|
|
83
|
+
"aria-hidden": "true",
|
|
84
|
+
focusable: "false",
|
|
85
|
+
viewBox: "0 0 16 16",
|
|
86
|
+
width: "16",
|
|
87
|
+
height: "16",
|
|
88
|
+
fill: "none",
|
|
89
|
+
stroke: "currentColor",
|
|
90
|
+
"stroke-width": "1.5"
|
|
91
|
+
}, L = {
|
|
92
|
+
key: 1,
|
|
93
|
+
class: "lk-icon",
|
|
94
|
+
"aria-hidden": "true",
|
|
95
|
+
focusable: "false",
|
|
96
|
+
viewBox: "0 0 16 16",
|
|
97
|
+
width: "16",
|
|
98
|
+
height: "16",
|
|
99
|
+
fill: "currentColor"
|
|
100
|
+
}, R = ["data-lk-disabled"], z = ["disabled"], B = {
|
|
101
|
+
key: 0,
|
|
102
|
+
class: "lk-icon",
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
focusable: "false",
|
|
105
|
+
viewBox: "0 0 16 16",
|
|
106
|
+
width: "16",
|
|
107
|
+
height: "16",
|
|
108
|
+
fill: "none",
|
|
109
|
+
stroke: "currentColor",
|
|
110
|
+
"stroke-width": "1.5",
|
|
111
|
+
"stroke-linecap": "round"
|
|
112
|
+
}, V = /* @__PURE__ */ s({
|
|
113
|
+
__name: "BackgroundEffectSelect",
|
|
114
|
+
props: /*@__PURE__*/ c({
|
|
115
|
+
track: { default: void 0 },
|
|
116
|
+
images: { default: () => [] },
|
|
117
|
+
blurRadius: { default: void 0 },
|
|
118
|
+
processorOptions: { default: void 0 },
|
|
119
|
+
allowUpload: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: !0
|
|
122
|
+
},
|
|
123
|
+
size: {},
|
|
124
|
+
unstyled: { type: Boolean }
|
|
125
|
+
}, {
|
|
126
|
+
effect: { default: () => ({ mode: T.NONE }) },
|
|
127
|
+
effectModifiers: {}
|
|
128
|
+
}),
|
|
129
|
+
emits: /*@__PURE__*/ c(["error", "upload"], ["update:effect"]),
|
|
130
|
+
setup(s, { emit: c }) {
|
|
131
|
+
let p = s, m = c, _ = y(s, "effect"), { isSupported: S, isPending: C, error: w } = A({
|
|
132
|
+
track: () => p.track,
|
|
133
|
+
effect: _,
|
|
134
|
+
blurRadius: p.blurRadius,
|
|
135
|
+
processorOptions: p.processorOptions
|
|
136
|
+
}), E = x(p, () => ["lk-background-effect-select"]), D = t(() => {
|
|
137
|
+
let e = p.images.map((e) => ({
|
|
138
|
+
key: `image:${e.url}`,
|
|
139
|
+
label: e.label,
|
|
140
|
+
effect: {
|
|
141
|
+
mode: T.IMAGE,
|
|
142
|
+
imageUrl: e.url
|
|
143
|
+
},
|
|
144
|
+
thumbnail: e.thumbnailUrl ?? e.url
|
|
145
|
+
}));
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
key: "none",
|
|
149
|
+
label: "No effect",
|
|
150
|
+
effect: { mode: T.NONE }
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
key: "blur",
|
|
154
|
+
label: "Blur",
|
|
155
|
+
effect: { mode: T.BLUR }
|
|
156
|
+
},
|
|
157
|
+
...e,
|
|
158
|
+
...k(p.images)
|
|
159
|
+
];
|
|
160
|
+
}), O;
|
|
161
|
+
function k(e) {
|
|
162
|
+
let t = _.value;
|
|
163
|
+
return t.mode !== T.IMAGE || e.some((e) => e.url === t.imageUrl) ? [] : [{
|
|
164
|
+
key: "custom",
|
|
165
|
+
label: "Your image",
|
|
166
|
+
effect: t,
|
|
167
|
+
thumbnail: t.imageUrl
|
|
168
|
+
}];
|
|
169
|
+
}
|
|
170
|
+
function V(e) {
|
|
171
|
+
let t = e.target;
|
|
172
|
+
if (!(t instanceof HTMLInputElement)) return;
|
|
173
|
+
let n = t.files?.[0];
|
|
174
|
+
t.value = "", n !== void 0 && (O !== void 0 && URL.revokeObjectURL(O), O = URL.createObjectURL(n), _.value = {
|
|
175
|
+
mode: T.IMAGE,
|
|
176
|
+
imageUrl: O
|
|
177
|
+
}, m("upload", n));
|
|
178
|
+
}
|
|
179
|
+
function H(e) {
|
|
180
|
+
let t = _.value;
|
|
181
|
+
return e.mode === T.IMAGE ? t.mode === T.IMAGE && t.imageUrl === e.imageUrl : t.mode === e.mode;
|
|
182
|
+
}
|
|
183
|
+
function U(e) {
|
|
184
|
+
H(e) || (_.value = e);
|
|
185
|
+
}
|
|
186
|
+
return b(w, (e) => {
|
|
187
|
+
e !== void 0 && m("error", e);
|
|
188
|
+
}), (t, c) => (f(), r("div", l(v(E), { "data-lk-pending": v(C) }), [
|
|
189
|
+
s.unstyled ? n("", !0) : (f(), r("div", M, [g(t.$slots, "heading", {}, () => [c[0] ||= o("Background", -1)])])),
|
|
190
|
+
v(S) ? (f(), r("ul", {
|
|
191
|
+
key: 2,
|
|
192
|
+
role: "listbox",
|
|
193
|
+
"aria-label": "Background effect",
|
|
194
|
+
class: u(s.unstyled ? void 0 : "lk-background-effect-options")
|
|
195
|
+
}, [(f(!0), r(e, null, h(D.value, (e) => (f(), r("li", {
|
|
196
|
+
key: e.key,
|
|
197
|
+
role: "option",
|
|
198
|
+
"aria-selected": H(e.effect),
|
|
199
|
+
"data-lk-active": H(e.effect)
|
|
200
|
+
}, [g(t.$slots, "option", {
|
|
201
|
+
effect: e.effect,
|
|
202
|
+
label: e.label,
|
|
203
|
+
active: H(e.effect),
|
|
204
|
+
select: () => U(e.effect)
|
|
205
|
+
}, () => [i("button", {
|
|
206
|
+
type: "button",
|
|
207
|
+
class: u(s.unstyled ? void 0 : "lk-background-effect-option"),
|
|
208
|
+
"data-lk-mode": e.effect.mode,
|
|
209
|
+
title: e.label,
|
|
210
|
+
"aria-label": e.label,
|
|
211
|
+
disabled: s.track === void 0,
|
|
212
|
+
style: d(e.thumbnail === void 0 ? void 0 : { backgroundImage: `url(${JSON.stringify(e.thumbnail)})` }),
|
|
213
|
+
onClick: (t) => U(e.effect)
|
|
214
|
+
}, [e.effect.mode === v(T).NONE ? (f(), r("svg", I, [...c[2] ||= [i("circle", {
|
|
215
|
+
cx: "8",
|
|
216
|
+
cy: "8",
|
|
217
|
+
r: "6"
|
|
218
|
+
}, null, -1), i("path", { d: "m3.8 12.2 8.4-8.4" }, null, -1)]])) : e.effect.mode === v(T).BLUR ? (f(), r("svg", L, [...c[3] ||= [a("<circle cx=\"8\" cy=\"5.75\" r=\"2.5\"></circle><path d=\"M3.75 14.5c0-2.6 1.9-4.5 4.25-4.5s4.25 1.9 4.25 4.5z\"></path><g opacity=\".45\"><circle cx=\"1.75\" cy=\"2.5\" r=\".9\"></circle><circle cx=\"1.75\" cy=\"6.25\" r=\"1.1\"></circle><circle cx=\"1.75\" cy=\"10\" r=\".9\"></circle><circle cx=\"1.75\" cy=\"13.75\" r=\".7\"></circle><circle cx=\"14.25\" cy=\"2.5\" r=\".9\"></circle><circle cx=\"14.25\" cy=\"6.25\" r=\"1.1\"></circle><circle cx=\"14.25\" cy=\"10\" r=\".9\"></circle><circle cx=\"14.25\" cy=\"13.75\" r=\".7\"></circle><circle cx=\"4.5\" cy=\"1.5\" r=\".7\"></circle><circle cx=\"11.5\" cy=\"1.5\" r=\".7\"></circle></g>", 3)]])) : n("", !0)], 14, F)])], 8, P))), 128))], 2)) : (f(), r("p", N, [g(t.$slots, "unsupported", {}, () => [c[1] ||= o("This browser can't apply background effects.", -1)])])),
|
|
219
|
+
v(S) && s.allowUpload ? (f(), r("label", {
|
|
220
|
+
key: 3,
|
|
221
|
+
class: u(s.unstyled ? void 0 : "lk-button lk-background-effect-upload"),
|
|
222
|
+
"data-lk-disabled": s.track === void 0
|
|
223
|
+
}, [
|
|
224
|
+
i("input", {
|
|
225
|
+
type: "file",
|
|
226
|
+
accept: "image/*",
|
|
227
|
+
class: u(s.unstyled ? void 0 : "lk-sr-only"),
|
|
228
|
+
disabled: s.track === void 0,
|
|
229
|
+
onChange: V
|
|
230
|
+
}, null, 42, z),
|
|
231
|
+
s.unstyled ? n("", !0) : (f(), r("svg", B, [...c[4] ||= [i("path", { d: "M8 3v10M3 8h10" }, null, -1)]])),
|
|
232
|
+
g(t.$slots, "upload", {}, () => [c[5] ||= o("Upload image", -1)])
|
|
233
|
+
], 10, R)) : n("", !0)
|
|
234
|
+
], 16, j));
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
export { T as BACKGROUND_EFFECT_MODE, E as BACKGROUND_PROCESSOR_NAME, V as BackgroundEffectSelect, D as DEFAULT_BLUR_RADIUS, A as useBackgroundEffect };
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot","_createTextVNode","_normalizeClass","_Fragment","_renderList","_createElementVNode","_normalizeStyle","Fragment","computed","createCommentVNode","createElementBlock","createElementVNode","createStaticVNode","createTextVNode","defineComponent","mergeModels","mergeProps","normalizeClass","normalizeStyle","openBlock","readonly","ref","renderList","renderSlot","toValue","unref","useModel","watch","useStyleAttrs","log","BackgroundProcessor","supportsBackgroundProcessors","BACKGROUND_EFFECT_MODE","BACKGROUND_PROCESSOR_NAME","DEFAULT_BLUR_RADIUS","isBackgroundProcessor","processor","toSwitchOptions","effect","blurRadius","useBackgroundEffect","props","isSupported","isPending","error","queue","pendingCount","apply","track","next","current","options","schedule","reason","failure","setEffect","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","BackgroundEffectSelect_default","\"effect\"","\"effectModifiers\"","__props","__emit","emits","styleAttrs","images","image","customOption","uploadedUrl","onUpload","event","input","file","isActive","candidate","select","_ctx","_cache","option","$event"],"sources":["../src/composables/useBackgroundEffect.ts","../src/background/BackgroundEffectSelect.vue"],"sourcesContent":["import { log } from '@livekit/components-core';\nimport {\n\tBackgroundProcessor,\n\tsupportsBackgroundProcessors,\n\ttype BackgroundProcessorWrapper,\n\ttype SegmenterOptions,\n\ttype SwitchBackgroundProcessorOptions,\n} from '@livekit/track-processors';\nimport type { LocalVideoTrack } from 'livekit-client';\nimport { readonly, ref, toValue, watch, type MaybeRefOrGetter, type Ref } from 'vue';\n\nexport const BACKGROUND_EFFECT_MODE = {\n\tNONE: 'none',\n\tBLUR: 'blur',\n\tIMAGE: 'image',\n} as const;\n\nexport interface BackgroundEffectNone {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.NONE;\n}\n\nexport interface BackgroundEffectBlur {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.BLUR;\n\treadonly radius?: number;\n}\n\nexport interface BackgroundEffectImage {\n\treadonly mode: typeof BACKGROUND_EFFECT_MODE.IMAGE;\n\treadonly imageUrl: string;\n}\n\nexport type BackgroundEffect = BackgroundEffectNone | BackgroundEffectBlur | BackgroundEffectImage;\n\nexport interface BackgroundEffectProcessorOptions {\n\treadonly segmenterOptions?: SegmenterOptions;\n\treadonly assetPaths?: {\n\t\treadonly tasksVisionFileSet?: string;\n\t\treadonly modelAssetPath?: string;\n\t};\n}\n\nexport interface UseBackgroundEffectProps {\n\treadonly track: MaybeRefOrGetter<LocalVideoTrack | undefined>;\n\treadonly effect?: Ref<BackgroundEffect>;\n\treadonly blurRadius?: number;\n\treadonly processorOptions?: BackgroundEffectProcessorOptions;\n}\n\nexport interface UseBackgroundEffect {\n\treadonly effect: Ref<BackgroundEffect>;\n\treadonly isSupported: boolean;\n\treadonly isPending: Readonly<Ref<boolean>>;\n\treadonly error: Readonly<Ref<Error | undefined>>;\n\treadonly setEffect: (effect: BackgroundEffect) => Promise<void>;\n}\n\nexport const BACKGROUND_PROCESSOR_NAME = 'lk-background-effect';\n\nexport const DEFAULT_BLUR_RADIUS = 48;\n\nfunction isBackgroundProcessor(processor: unknown): processor is BackgroundProcessorWrapper {\n\treturn (\n\t\ttypeof processor === 'object' &&\n\t\tprocessor !== null &&\n\t\t'name' in processor &&\n\t\tprocessor.name === BACKGROUND_PROCESSOR_NAME &&\n\t\t'switchTo' in processor\n\t);\n}\n\nfunction toSwitchOptions(\n\teffect: BackgroundEffectBlur | BackgroundEffectImage,\n\tblurRadius: number,\n): SwitchBackgroundProcessorOptions {\n\tif (effect.mode === BACKGROUND_EFFECT_MODE.BLUR) {\n\t\treturn { mode: 'background-blur', blurRadius: effect.radius ?? blurRadius };\n\t}\n\n\treturn { mode: 'virtual-background', imagePath: effect.imageUrl };\n}\n\nexport function useBackgroundEffect(props: UseBackgroundEffectProps): UseBackgroundEffect {\n\tconst effect = props.effect ?? ref<BackgroundEffect>({ mode: BACKGROUND_EFFECT_MODE.NONE });\n\tconst isSupported = supportsBackgroundProcessors();\n\tconst isPending = ref<boolean>(false);\n\tconst error = ref<Error | undefined>();\n\tconst blurRadius = props.blurRadius ?? DEFAULT_BLUR_RADIUS;\n\n\tlet queue: Promise<void> = Promise.resolve();\n\tlet pendingCount = 0;\n\n\tasync function apply(track: LocalVideoTrack, next: BackgroundEffect): Promise<void> {\n\t\tconst current = track.getProcessor();\n\n\t\tif (next.mode === BACKGROUND_EFFECT_MODE.NONE) {\n\t\t\tif (isBackgroundProcessor(current)) {\n\t\t\t\tawait track.stopProcessor();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst options = toSwitchOptions(next, blurRadius);\n\n\t\tif (isBackgroundProcessor(current)) {\n\t\t\tawait current.switchTo(options);\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst processor = BackgroundProcessor(\n\t\t\t{ ...props.processorOptions, ...options },\n\t\t\tBACKGROUND_PROCESSOR_NAME,\n\t\t);\n\n\t\tawait track.setProcessor(processor);\n\t}\n\n\tfunction schedule(track: LocalVideoTrack | undefined, next: BackgroundEffect): void {\n\t\tif (track === undefined || !isSupported) {\n\t\t\treturn;\n\t\t}\n\n\t\tpendingCount += 1;\n\t\tisPending.value = true;\n\n\t\tqueue = queue\n\t\t\t.then(() => apply(track, next))\n\t\t\t.then(() => {\n\t\t\t\terror.value = undefined;\n\t\t\t})\n\t\t\t.catch((reason: unknown) => {\n\t\t\t\tconst failure = reason instanceof Error ? reason : new Error(String(reason));\n\n\t\t\t\tlog.error('Background effect: error applying the effect', failure);\n\t\t\t\terror.value = failure;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tpendingCount -= 1;\n\t\t\t\tisPending.value = pendingCount > 0;\n\t\t\t});\n\t}\n\n\tasync function setEffect(next: BackgroundEffect): Promise<void> {\n\t\teffect.value = next;\n\n\t\tawait queue;\n\t}\n\n\twatch(\n\t\t() => toValue(props.track),\n\t\t(track) => {\n\t\t\tschedule(track, effect.value);\n\t\t},\n\t\t{ immediate: true },\n\t);\n\n\twatch(\n\t\teffect,\n\t\t(next) => {\n\t\t\tschedule(toValue(props.track), next);\n\t\t},\n\t\t{ flush: 'sync' },\n\t);\n\n\tconst background: UseBackgroundEffect = {\n\t\teffect,\n\t\tisSupported,\n\t\tisPending: readonly(isPending),\n\t\terror: readonly(error),\n\t\tsetEffect,\n\t};\n\n\treturn background;\n}\n","<template>\n\t<div\n\t\tv-bind=\"styleAttrs\"\n\t\t:data-lk-pending=\"isPending\"\n\t>\n\t\t<div\n\t\t\tv-if=\"!unstyled\"\n\t\t\tclass=\"lk-device-menu-heading\"\n\t\t>\n\t\t\t<slot name=\"heading\">Background</slot>\n\t\t</div>\n\t\t<p\n\t\t\tv-if=\"!isSupported\"\n\t\t\tclass=\"lk-background-effect-unsupported\"\n\t\t>\n\t\t\t<slot name=\"unsupported\">This browser can't apply background effects.</slot>\n\t\t</p>\n\t\t<ul\n\t\t\tv-else\n\t\t\trole=\"listbox\"\n\t\t\taria-label=\"Background effect\"\n\t\t\t:class=\"unstyled ? undefined : 'lk-background-effect-options'\"\n\t\t>\n\t\t\t<li\n\t\t\t\tv-for=\"option in options\"\n\t\t\t\t:key=\"option.key\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isActive(option.effect)\"\n\t\t\t\t:data-lk-active=\"isActive(option.effect)\"\n\t\t\t>\n\t\t\t\t<slot\n\t\t\t\t\tname=\"option\"\n\t\t\t\t\t:effect=\"option.effect\"\n\t\t\t\t\t:label=\"option.label\"\n\t\t\t\t\t:active=\"isActive(option.effect)\"\n\t\t\t\t\t:select=\"() => select(option.effect)\"\n\t\t\t\t>\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t:class=\"unstyled ? undefined : 'lk-background-effect-option'\"\n\t\t\t\t\t\t:data-lk-mode=\"option.effect.mode\"\n\t\t\t\t\t\t:title=\"option.label\"\n\t\t\t\t\t\t:aria-label=\"option.label\"\n\t\t\t\t\t\t:disabled=\"track === undefined\"\n\t\t\t\t\t\t:style=\"\n\t\t\t\t\t\t\toption.thumbnail === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: { backgroundImage: `url(${JSON.stringify(option.thumbnail)})` }\n\t\t\t\t\t\t\"\n\t\t\t\t\t\t@click=\"select(option.effect)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tv-if=\"option.effect.mode === BACKGROUND_EFFECT_MODE.NONE\"\n\t\t\t\t\t\t\tclass=\"lk-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\"\n\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\twidth=\"16\"\n\t\t\t\t\t\t\theight=\"16\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\tstroke-width=\"1.5\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\tcx=\"8\"\n\t\t\t\t\t\t\t\tcy=\"8\"\n\t\t\t\t\t\t\t\tr=\"6\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<path d=\"m3.8 12.2 8.4-8.4\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tv-else-if=\"option.effect.mode === BACKGROUND_EFFECT_MODE.BLUR\"\n\t\t\t\t\t\t\tclass=\"lk-icon\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\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\t\t\t\tcx=\"14.25\"\n\t\t\t\t\t\t\t\t\tcy=\"6.25\"\n\t\t\t\t\t\t\t\t\tr=\"1.1\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"14.25\"\n\t\t\t\t\t\t\t\t\tcy=\"10\"\n\t\t\t\t\t\t\t\t\tr=\".9\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"14.25\"\n\t\t\t\t\t\t\t\t\tcy=\"13.75\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"4.5\"\n\t\t\t\t\t\t\t\t\tcy=\"1.5\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<circle\n\t\t\t\t\t\t\t\t\tcx=\"11.5\"\n\t\t\t\t\t\t\t\t\tcy=\"1.5\"\n\t\t\t\t\t\t\t\t\tr=\".7\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</g>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t</button>\n\t\t\t\t</slot>\n\t\t\t</li>\n\t\t</ul>\n\t\t<label\n\t\t\tv-if=\"isSupported && allowUpload\"\n\t\t\t:class=\"unstyled ? undefined : 'lk-button lk-background-effect-upload'\"\n\t\t\t:data-lk-disabled=\"track === undefined\"\n\t\t>\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\"image/*\"\n\t\t\t\t:class=\"unstyled ? undefined : 'lk-sr-only'\"\n\t\t\t\t:disabled=\"track === undefined\"\n\t\t\t\t@change=\"onUpload\"\n\t\t\t/>\n\t\t\t<svg\n\t\t\t\tv-if=\"!unstyled\"\n\t\t\t\tclass=\"lk-icon\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\twidth=\"16\"\n\t\t\t\theight=\"16\"\n\t\t\t\tfill=\"none\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstroke-width=\"1.5\"\n\t\t\t\tstroke-linecap=\"round\"\n\t\t\t>\n\t\t\t\t<path d=\"M8 3v10M3 8h10\" />\n\t\t\t</svg>\n\t\t\t<slot name=\"upload\">Upload image</slot>\n\t\t</label>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\n\timport type { LocalVideoTrack } from 'livekit-client';\n\timport { computed, watch } from 'vue';\n\n\timport { useStyleAttrs, type LkStyleProps } from '@/components/style';\n\timport {\n\t\tBACKGROUND_EFFECT_MODE,\n\t\tuseBackgroundEffect,\n\t\ttype BackgroundEffect,\n\t\ttype BackgroundEffectProcessorOptions,\n\t} from '@/composables/useBackgroundEffect';\n\n\texport interface BackgroundImage {\n\t\treadonly url: string;\n\t\treadonly label: string;\n\t\treadonly thumbnailUrl?: string;\n\t}\n\n\texport interface BackgroundEffectSelectProps extends LkStyleProps {\n\t\ttrack?: LocalVideoTrack;\n\t\timages?: readonly BackgroundImage[];\n\t\tblurRadius?: number;\n\t\tprocessorOptions?: BackgroundEffectProcessorOptions;\n\t\tallowUpload?: boolean;\n\t}\n\n\texport interface BackgroundEffectOptionSlotProps {\n\t\teffect: BackgroundEffect;\n\t\tlabel: string;\n\t\tactive: boolean;\n\t\tselect: () => void;\n\t}\n\n\tinterface BackgroundEffectOption {\n\t\treadonly key: string;\n\t\treadonly label: string;\n\t\treadonly effect: BackgroundEffect;\n\t\treadonly thumbnail?: string;\n\t}\n\n\tconst props = withDefaults(defineProps<BackgroundEffectSelectProps>(), {\n\t\ttrack: undefined,\n\t\timages: () => [],\n\t\tblurRadius: undefined,\n\t\tprocessorOptions: undefined,\n\t\tallowUpload: true,\n\t});\n\n\tconst emits = defineEmits<{\n\t\terror: [error: Error];\n\t\tupload: [file: File];\n\t}>();\n\n\tconst effect = defineModel<BackgroundEffect>('effect', {\n\t\tdefault: () => ({ mode: BACKGROUND_EFFECT_MODE.NONE }),\n\t});\n\n\tdefineSlots<{\n\t\theading?: () => unknown;\n\t\tunsupported?: () => unknown;\n\t\toption?: (props: BackgroundEffectOptionSlotProps) => unknown;\n\t\tupload?: () => unknown;\n\t}>();\n\n\tconst { isSupported, isPending, error } = useBackgroundEffect({\n\t\ttrack: () => props.track,\n\t\teffect,\n\t\tblurRadius: props.blurRadius,\n\t\tprocessorOptions: props.processorOptions,\n\t});\n\n\tconst styleAttrs = useStyleAttrs(props, () => ['lk-background-effect-select']);\n\n\tconst options = computed<BackgroundEffectOption[]>(() => {\n\t\tconst images = props.images.map<BackgroundEffectOption>((image) => ({\n\t\t\tkey: `image:${image.url}`,\n\t\t\tlabel: image.label,\n\t\t\teffect: { mode: BACKGROUND_EFFECT_MODE.IMAGE, imageUrl: image.url },\n\t\t\tthumbnail: image.thumbnailUrl ?? image.url,\n\t\t}));\n\n\t\treturn [\n\t\t\t{ key: 'none', label: 'No effect', effect: { mode: BACKGROUND_EFFECT_MODE.NONE } },\n\t\t\t{ key: 'blur', label: 'Blur', effect: { mode: BACKGROUND_EFFECT_MODE.BLUR } },\n\t\t\t...images,\n\t\t\t...customOption(props.images),\n\t\t];\n\t});\n\n\tlet uploadedUrl: string | undefined;\n\n\tfunction customOption(images: readonly BackgroundImage[]): BackgroundEffectOption[] {\n\t\tconst current = effect.value;\n\n\t\tif (\n\t\t\tcurrent.mode !== BACKGROUND_EFFECT_MODE.IMAGE ||\n\t\t\timages.some((image) => image.url === current.imageUrl)\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [{ key: 'custom', label: 'Your image', effect: current, thumbnail: current.imageUrl }];\n\t}\n\n\tfunction onUpload(event: Event): void {\n\t\tconst input = event.target;\n\n\t\tif (!(input instanceof HTMLInputElement)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst file = input.files?.[0];\n\t\tinput.value = '';\n\n\t\tif (file === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (uploadedUrl !== undefined) {\n\t\t\tURL.revokeObjectURL(uploadedUrl);\n\t\t}\n\n\t\tuploadedUrl = URL.createObjectURL(file);\n\t\teffect.value = { mode: BACKGROUND_EFFECT_MODE.IMAGE, imageUrl: uploadedUrl };\n\t\temits('upload', file);\n\t}\n\n\tfunction isActive(candidate: BackgroundEffect): boolean {\n\t\tconst current = effect.value;\n\n\t\tif (candidate.mode === BACKGROUND_EFFECT_MODE.IMAGE) {\n\t\t\treturn (\n\t\t\t\tcurrent.mode === BACKGROUND_EFFECT_MODE.IMAGE && current.imageUrl === candidate.imageUrl\n\t\t\t);\n\t\t}\n\n\t\treturn current.mode === candidate.mode;\n\t}\n\n\tfunction select(next: BackgroundEffect): void {\n\t\tif (!isActive(next)) {\n\t\t\teffect.value = next;\n\t\t}\n\t}\n\n\twatch(error, (failure) => {\n\t\tif (failure !== undefined) {\n\t\t\temits('error', failure);\n\t\t}\n\t});\n</script>\n"],"mappings":";;;;;AAWA,IAAaqC,IAAyB;CACrC,MAAM;CACN,MAAM;CACN,OAAO;AACR,GAyCaC,IAA4B,wBAE5BC,IAAsB;AAEnC,SAASC,EAAsBC,GAA6D;CAC3F,OACC,OAAOA,KAAc,cACrBA,KACA,UAAUA,KACVA,EAAU,SAAA,0BACV,cAAcA;AAEhB;AAEA,SAASC,EACRC,GACAC,GACmC;CAKnC,OAJID,EAAO,SAASN,EAAuB,OACnC;EAAE,MAAM;EAAmB,YAAYM,EAAO,UAAUC;CAAW,IAGpE;EAAE,MAAM;EAAsB,WAAWD,EAAO;CAAS;AACjE;AAEA,SAAgBE,EAAoBC,GAAsD;CACzF,IAAMH,IAASG,EAAM,UAAUpB,EAAsB,EAAE,MAAMW,EAAuB,KAAK,CAAC,GACpFU,IAAcX,EAA6B,GAC3CY,IAAYtB,EAAa,EAAK,GAC9BuB,IAAQvB,EAAuB,GAC/BkB,IAAaE,EAAM,cAAA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EAAA,UAAU,KAAA;KACpB,UAAQQ;;IAGFR,EAAA,W,aADRzE,EAAA,GAAAC,EAcM,OAdNoE,GAcM,CAAA,GAAAoB,EAAA,OAAA,CADLhF,EAA2B,QAAA,EAArB,GAAE,iBAAgB,GAAA,MAAA,EAAA,C;IAEzBL,EAAuCoF,EAAA,QAAA,UAAA,CAAA,SAAA,CAAnBC,EAAA,OAAApF,EAAA,gBAAY,EAAA,C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReceivedChatMessage } from '@livekit/components-core';
|
|
2
|
+
import { LkStyleProps } from '../style.cjs';
|
|
3
|
+
import { MessageFormatter } from './chat.utils.cjs';
|
|
4
|
+
export interface ChatEntryProps extends LkStyleProps {
|
|
5
|
+
entry: ReceivedChatMessage;
|
|
6
|
+
hideName?: boolean;
|
|
7
|
+
hideTimestamp?: boolean;
|
|
8
|
+
messageFormatter?: MessageFormatter;
|
|
9
|
+
}
|
|
10
|
+
declare const __VLS_export: import('vue').DefineComponent<ChatEntryProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ChatEntryProps> & Readonly<{}>, {
|
|
11
|
+
hideName: boolean;
|
|
12
|
+
hideTimestamp: boolean;
|
|
13
|
+
messageFormatter: MessageFormatter;
|
|
14
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReceivedChatMessage } from '@livekit/components-core';
|
|
2
|
+
import { LkStyleProps } from '../style.mjs';
|
|
3
|
+
import { MessageFormatter } from './chat.utils.mjs';
|
|
4
|
+
export interface ChatEntryProps extends LkStyleProps {
|
|
5
|
+
entry: ReceivedChatMessage;
|
|
6
|
+
hideName?: boolean;
|
|
7
|
+
hideTimestamp?: boolean;
|
|
8
|
+
messageFormatter?: MessageFormatter;
|
|
9
|
+
}
|
|
10
|
+
declare const __VLS_export: import('vue').DefineComponent<ChatEntryProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ChatEntryProps> & Readonly<{}>, {
|
|
11
|
+
hideName: boolean;
|
|
12
|
+
hideTimestamp: boolean;
|
|
13
|
+
messageFormatter: MessageFormatter;
|
|
14
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|