@selfcommunity/react-ui 0.11.0-alpha.23 → 0.11.0-alpha.24
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/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +8 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +69 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +31 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +43 -4
- package/lib/cjs/constants/LiveStream.d.ts +1 -0
- package/lib/cjs/constants/LiveStream.js +2 -1
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +8 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +66 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +31 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +45 -6
- package/lib/esm/constants/LiveStream.d.ts +1 -0
- package/lib/esm/constants/LiveStream.js +1 -0
- package/lib/umd/{653.js → 212.js} +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -5
- /package/lib/umd/{653.js.LICENSE.txt → 212.js.LICENSE.txt} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { isEqualTrackRef, isTrackReference, isWeb, log } from '@livekit/components-core';
|
|
5
5
|
import { RoomEvent, Track } from 'livekit-client';
|
|
6
|
-
import { CarouselLayout, Chat, ConnectionStateToast, GridLayout, LayoutContextProvider, RoomAudioRenderer, useCreateLayoutContext, useParticipants, usePinnedTracks, useTracks } from '@livekit/components-react';
|
|
6
|
+
import { CarouselLayout, Chat, ConnectionStateToast, GridLayout, LayoutContextProvider, RoomAudioRenderer, useCreateLayoutContext, useLocalParticipant, useParticipants, usePinnedTracks, useTracks } from '@livekit/components-react';
|
|
7
7
|
import { ParticipantTile } from './ParticipantTile';
|
|
8
8
|
import { ControlBar } from './ControlBar';
|
|
9
9
|
import { useEffect, useMemo } from 'react';
|
|
@@ -15,6 +15,10 @@ import { styled } from '@mui/material/styles';
|
|
|
15
15
|
import { Box } from '@mui/material';
|
|
16
16
|
import { useThemeProps } from '@mui/system';
|
|
17
17
|
import NoParticipants from './NoParticipants';
|
|
18
|
+
import LiveStreamSettingsMenu from './LiveStreamSettingsMenu';
|
|
19
|
+
import { BackgroundBlur } from '@livekit/track-processors';
|
|
20
|
+
import { isClientSideRendering } from '@selfcommunity/utils';
|
|
21
|
+
import { CHOICE_VIDEO_BLUR_EFFECT } from '../../../constants/LiveStream';
|
|
18
22
|
const PREFIX = 'SCVideoConference';
|
|
19
23
|
const classes = {
|
|
20
24
|
root: `${PREFIX}-root`
|
|
@@ -35,7 +39,7 @@ const Root = styled(Box, {
|
|
|
35
39
|
*
|
|
36
40
|
*/
|
|
37
41
|
export function VideoConference(inProps) {
|
|
38
|
-
var _a, _b;
|
|
42
|
+
var _a, _b, _c;
|
|
39
43
|
// PROPS
|
|
40
44
|
const props = useThemeProps({
|
|
41
45
|
props: inProps,
|
|
@@ -52,16 +56,34 @@ export function VideoConference(inProps) {
|
|
|
52
56
|
const lastAutoFocusedScreenShareTrack = React.useRef(null);
|
|
53
57
|
// HOOKS
|
|
54
58
|
const scUserContext = useSCUser();
|
|
59
|
+
const [blurEnabled, setBlurEnabled] = React.useState(isClientSideRendering() ? Boolean((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(CHOICE_VIDEO_BLUR_EFFECT)) || false : false);
|
|
60
|
+
const [processorPending, setProcessorPending] = React.useState(false);
|
|
55
61
|
const tracks = useTracks([
|
|
56
62
|
{ source: Track.Source.Camera, withPlaceholder: true },
|
|
57
63
|
{ source: Track.Source.ScreenShare, withPlaceholder: false }
|
|
58
64
|
], { updateOnlyOn: [RoomEvent.ActiveSpeakersChanged], onlySubscribed: false });
|
|
59
65
|
const tracksNoParticipants = useMemo(() => tracks.filter((t) => t.participant.name === scUserContext.user.username || t.participant.name === speakerFocused.username || t.source === 'screen_share'), [tracks, scUserContext.user]);
|
|
66
|
+
const handleBlur = React.useCallback((event) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (event.target) {
|
|
69
|
+
if ('checked' in event.target) {
|
|
70
|
+
setBlurEnabled((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
setBlurEnabled((enabled) => !enabled);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
setBlurEnabled((enabled) => !enabled);
|
|
78
|
+
}
|
|
79
|
+
(_b = window === null || window === void 0 ? void 0 : window.localStorage) === null || _b === void 0 ? void 0 : _b.setItem(CHOICE_VIDEO_BLUR_EFFECT, (!blurEnabled).toString());
|
|
80
|
+
}, [setBlurEnabled, blurEnabled]);
|
|
60
81
|
const participants = useParticipants();
|
|
61
82
|
const layoutContext = useCreateLayoutContext();
|
|
62
83
|
const screenShareTracks = tracks.filter(isTrackReference).filter((track) => track.publication.source === Track.Source.ScreenShare);
|
|
63
|
-
const focusTrack = (
|
|
84
|
+
const focusTrack = (_b = usePinnedTracks(layoutContext)) === null || _b === void 0 ? void 0 : _b[0];
|
|
64
85
|
const carouselTracks = tracks.filter((track) => !isEqualTrackRef(track, focusTrack));
|
|
86
|
+
const { cameraTrack } = useLocalParticipant();
|
|
65
87
|
useLivestreamCheck();
|
|
66
88
|
/**
|
|
67
89
|
* widgetUpdate
|
|
@@ -117,7 +139,7 @@ export function VideoConference(inProps) {
|
|
|
117
139
|
}
|
|
118
140
|
}, [
|
|
119
141
|
screenShareTracks.map((ref) => `${ref.publication.trackSid}_${ref.publication.isSubscribed}`).join(),
|
|
120
|
-
(
|
|
142
|
+
(_c = focusTrack === null || focusTrack === void 0 ? void 0 : focusTrack.publication) === null || _c === void 0 ? void 0 : _c.trackSid,
|
|
121
143
|
tracks,
|
|
122
144
|
participants,
|
|
123
145
|
speakerFocused
|
|
@@ -140,10 +162,27 @@ export function VideoConference(inProps) {
|
|
|
140
162
|
}
|
|
141
163
|
}
|
|
142
164
|
}, [tracks, participants, speakerFocused]);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const localCamTrack = cameraTrack === null || cameraTrack === void 0 ? void 0 : cameraTrack.track;
|
|
167
|
+
if (localCamTrack) {
|
|
168
|
+
setProcessorPending(true);
|
|
169
|
+
try {
|
|
170
|
+
if (blurEnabled && !localCamTrack.getProcessor()) {
|
|
171
|
+
localCamTrack.setProcessor(BackgroundBlur(20));
|
|
172
|
+
}
|
|
173
|
+
else if (!blurEnabled) {
|
|
174
|
+
localCamTrack.stopProcessor();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
setProcessorPending(false);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [blurEnabled, cameraTrack]);
|
|
143
182
|
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root, 'lk-video-conference') }, rest, { children: [isWeb() && (_jsxs(LayoutContextProvider, Object.assign({ value: layoutContext, onPinChange: handleFocusStateChange, onWidgetChange: widgetUpdate }, { children: [_jsxs("div", Object.assign({ className: "lk-video-conference-inner" }, { children: [!focusTrack ? (_jsx("div", Object.assign({ className: "lk-grid-layout-wrapper" }, { children: _jsx(GridLayout, Object.assign({ tracks: hideParticipantsList ? tracksNoParticipants : tracks }, { children: _jsx(ParticipantTile, {}) })) }))) : (_jsx("div", Object.assign({ className: "lk-focus-layout-wrapper" }, { children: hideParticipantsList ? (_jsx(FocusLayoutContainerNoParticipants, { children: focusTrack && _jsx(FocusLayout, { trackRef: focusTrack }) })) : (_jsxs(FocusLayoutContainer, { children: [carouselTracks.length ? (_jsx(CarouselLayout, Object.assign({ tracks: carouselTracks }, { children: _jsx(ParticipantTile, {}) }))) : (_jsx(NoParticipants, {})), focusTrack && _jsx(FocusLayout, { trackRef: focusTrack })] })) }))), _jsx(ControlBar, { controls: Object.assign({
|
|
144
183
|
chat: !disableChat,
|
|
145
184
|
microphone: !disableMicrophone,
|
|
146
185
|
camera: !disableCamera,
|
|
147
186
|
screenShare: !disableShareScreen
|
|
148
|
-
}, { settings:
|
|
187
|
+
}, { settings: true }) })] })), !disableChat && (_jsx(Chat, { style: { display: widgetState.showChat ? 'grid' : 'none' }, messageFormatter: chatMessageFormatter, messageEncoder: chatMessageEncoder, messageDecoder: chatMessageDecoder })), _jsx("div", Object.assign({ className: "lk-settings-menu-modal", style: { display: widgetState.showSettings ? 'block' : 'none' } }, { children: SettingsComponent ? (_jsx(SettingsComponent, {})) : (_jsx(_Fragment, { children: _jsx(LiveStreamSettingsMenu, { onlyContentMenu: true, actionBlurDisabled: !cameraTrack && !disableCamera, blurEnabled: blurEnabled, handleBlur: handleBlur }) })) }))] }))), _jsx(RoomAudioRenderer, {}), _jsx(ConnectionStateToast, {})] })));
|
|
149
188
|
}
|