@selfcommunity/react-ui 0.8.0-live.42 → 0.8.0-live.44

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.
@@ -1,7 +1,5 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- // @ts-nocheck
5
3
  import { Box, CircularProgress } from '@mui/material';
6
4
  import { styled } from '@mui/material/styles';
7
5
  import { useThemeProps } from '@mui/system';
@@ -9,9 +7,7 @@ import { useSCPreferences, useSCUser } from '@selfcommunity/react-core';
9
7
  import classNames from 'classnames';
10
8
  import { PREFIX } from './constants';
11
9
  import { ConnectionState, formatChatMessageLinks, LiveKitRoom, VideoConference } from '@livekit/components-react';
12
- import { ExternalE2EEKeyProvider, VideoPresets, Room, DeviceUnsupportedError } from 'livekit-client';
13
- import { useCallback, useEffect, useMemo, useState } from 'react';
14
- import { decodePassphrase } from '../../../utils/liveStream';
10
+ import { useCallback, useMemo, useState } from 'react';
15
11
  import RecordingIndicator from './RecordingIndicator';
16
12
  import { defaultUserChoices } from '@livekit/components-core';
17
13
  import { defaultVideoOptions } from '../constants';
@@ -58,16 +54,15 @@ export default function LiveStreamVideoConference(inProps) {
58
54
  const scUserContext = useSCUser();
59
55
  const { preferences, features } = useSCPreferences();
60
56
  // Passphrase
61
- const e2eePassphrase = typeof window !== 'undefined' && decodePassphrase(location.hash.substring(1));
57
+ // const e2eePassphrase = typeof window !== 'undefined' && decodePassphrase(location.hash.substring(1));
62
58
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
63
59
  // @ts-ignore
64
- const worker = typeof window !== 'undefined' && e2eePassphrase && new Worker(new URL('livekit-client/e2ee-worker', import.meta.url));
65
- const e2eeEnabled = !!(e2eePassphrase && worker);
66
- const keyProvider = new ExternalE2EEKeyProvider();
67
- const [e2eeSetupComplete, setE2eeSetupComplete] = useState(false);
68
- const [liveActive, setLiveActive] = useState(false);
60
+ // const worker = typeof window !== 'undefined' && e2eePassphrase && new Worker(new URL('livekit-client/e2ee-worker', import.meta.url));
61
+ // const e2eeEnabled = !!(e2eePassphrase && worker);
62
+ // const keyProvider = new ExternalE2EEKeyProvider();
63
+ const [e2eeSetupComplete, setE2eeSetupComplete] = useState(true);
64
+ const [liveActive, setLiveActive] = useState(true);
69
65
  const [error, setError] = useState(null);
70
- const liveStreamRoomMaxParticipants = 25;
71
66
  /* const liveStreamRoomMaxParticipants = useMemo(
72
67
  () =>
73
68
  preferences &&
@@ -76,76 +71,74 @@ export default function LiveStreamVideoConference(inProps) {
76
71
  [preferences]
77
72
  ); */
78
73
  // Room options
79
- const roomOptions = useMemo(() => {
80
- var _a, _b;
81
- let videoCodec = options.codec ? options.codec : defaultVideoOptions.codec;
82
- if (e2eeEnabled && (videoCodec === 'av1' || videoCodec === 'vp9')) {
83
- videoCodec = undefined;
84
- }
85
- return {
86
- // emptyTimeout: 3 * 60, // 3 minutes
87
- // maxParticipants: liveStreamRoomMaxParticipants,
88
- videoCaptureDefaults: {
89
- deviceId: (_a = userChoices.videoDeviceId) !== null && _a !== void 0 ? _a : undefined,
90
- resolution: options.hq ? VideoPresets.h2160 : VideoPresets.h720
91
- },
92
- publishDefaults: {
93
- dtx: false,
94
- videoSimulcastLayers: options.hq ? [VideoPresets.h1080, VideoPresets.h720] : [VideoPresets.h540, VideoPresets.h216],
95
- red: !e2eeEnabled,
96
- videoCodec
97
- },
98
- audioCaptureDefaults: {
99
- deviceId: (_b = userChoices.audioDeviceId) !== null && _b !== void 0 ? _b : undefined
100
- },
101
- adaptiveStream: { pixelDensity: 'screen' },
102
- dynacast: true,
103
- e2ee: e2eeEnabled
104
- ? {
105
- keyProvider,
106
- worker
107
- }
108
- : undefined
109
- };
110
- }, [liveStreamRoomMaxParticipants, userChoices, options.hq, options.codec]);
74
+ /* const roomOptions = useMemo((): RoomOptions => {
75
+ let videoCodec: VideoCodec | undefined = options.codec ? options.codec : defaultVideoOptions.codec;
76
+ if (e2eeEnabled && (videoCodec === 'av1' || videoCodec === 'vp9')) {
77
+ videoCodec = undefined;
78
+ }
79
+ return {
80
+ // emptyTimeout: 3 * 60, // 3 minutes
81
+ // maxParticipants: liveStreamRoomMaxParticipants,
82
+ videoCaptureDefaults: {
83
+ deviceId: userChoices.videoDeviceId ?? undefined,
84
+ resolution: options.hq ? VideoPresets.h2160 : VideoPresets.h720
85
+ },
86
+ publishDefaults: {
87
+ dtx: false,
88
+ videoSimulcastLayers: options.hq ? [VideoPresets.h1080, VideoPresets.h720] : [VideoPresets.h540, VideoPresets.h216],
89
+ red: !e2eeEnabled,
90
+ videoCodec
91
+ },
92
+ audioCaptureDefaults: {
93
+ deviceId: userChoices.audioDeviceId ?? undefined
94
+ },
95
+ adaptiveStream: {pixelDensity: 'screen'},
96
+ dynacast: true,
97
+ e2ee: e2eeEnabled
98
+ ? {
99
+ keyProvider,
100
+ worker
101
+ }
102
+ : undefined
103
+ };
104
+ }, [liveStreamRoomMaxParticipants, userChoices, options.hq, options.codec]); */
111
105
  // Create room - only initial
112
- const room = useMemo(() => {
113
- if (liveStreamRoomMaxParticipants) {
114
- return new Room(roomOptions);
115
- }
116
- }, [liveStreamRoomMaxParticipants]);
106
+ /* const room = useMemo(() => {
107
+ const room = new Room();
108
+ return new Room(roomOptions);
109
+ }, [liveStreamRoomMaxParticipants]); */
117
110
  const connectOptions = useMemo(() => {
118
111
  return {
119
112
  autoSubscribe: true
120
113
  };
121
114
  }, []);
122
- useEffect(() => {
123
- if (room) {
124
- if (e2eeEnabled) {
125
- keyProvider
126
- .setKey(decodePassphrase(e2eePassphrase))
127
- .then(() => {
128
- room.setE2EEEnabled(true).catch((e) => {
129
- if (e instanceof DeviceUnsupportedError) {
130
- alert(`You're trying to join an encrypted meeting, but your browser does not support it. Please update it to the latest version and try again.`);
131
- console.error(e);
132
- }
133
- else {
134
- throw e;
135
- }
136
- });
137
- })
138
- .then(() => {
139
- setE2eeSetupComplete(true);
140
- setLiveActive(true);
141
- });
142
- }
143
- else {
144
- setE2eeSetupComplete(true);
145
- setLiveActive(true);
146
- }
115
+ /* useEffect(() => {
116
+ if (room) {
117
+ if (e2eeEnabled) {
118
+ keyProvider
119
+ .setKey(decodePassphrase(e2eePassphrase))
120
+ .then(() => {
121
+ room.setE2EEEnabled(true).catch((e) => {
122
+ if (e instanceof DeviceUnsupportedError) {
123
+ alert(
124
+ `You're trying to join an encrypted meeting, but your browser does not support it. Please update it to the latest version and try again.`
125
+ );
126
+ console.error(e);
127
+ } else {
128
+ throw e;
129
+ }
130
+ });
131
+ })
132
+ .then(() => {
133
+ setE2eeSetupComplete(true);
134
+ setLiveActive(true);
135
+ });
136
+ } else {
137
+ setE2eeSetupComplete(true);
138
+ setLiveActive(true);
147
139
  }
148
- }, [e2eeEnabled, room, e2eePassphrase]);
140
+ }
141
+ }, [e2eeEnabled, room, e2eePassphrase]); */
149
142
  // HANDLERS
150
143
  /**
151
144
  * Handle on leave
@@ -179,5 +172,5 @@ export default function LiveStreamVideoConference(inProps) {
179
172
  /**
180
173
  * Renders root object
181
174
  */
182
- return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: room && liveActive && !error ? (_jsx(_Fragment, { children: _jsxs(LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive && room), room: room, token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [_jsx(VideoConference, { chatMessageFormatter: formatChatMessageLinks }), _jsx(RecordingIndicator, {}), _jsx(ConnectionState, {})] })) })) : (_jsx(_Fragment, { children: error ? error : liveActive === false ? _jsx(_Fragment, { children: "Grazie!" }) : _jsx(CircularProgress, {}) })) })));
175
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: liveActive && !error ? (_jsx(_Fragment, { children: _jsxs(LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [_jsx(VideoConference, { chatMessageFormatter: formatChatMessageLinks }), _jsx(RecordingIndicator, {}), _jsx(ConnectionState, {})] })) })) : (_jsx(_Fragment, { children: error ? error : liveActive === false ? _jsx(_Fragment, { children: "Grazie!" }) : _jsx(CircularProgress, {}) })) })));
183
176
  }
@@ -9,7 +9,7 @@ import ScrollContainer from '../../shared/ScrollContainer';
9
9
  import DefaultDrawerContent from './DefaultDrawerContent';
10
10
  import DefaultHeaderContent from './DefaultHeaderContent';
11
11
  import CreateLiveStreamButton from '../CreateLiveStreamButton';
12
- import { useSCPreferences } from '@selfcommunity/react-core';
12
+ import { useSCPreferences, useSCUser } from '@selfcommunity/react-core';
13
13
  const PREFIX = 'SCNavigationMenuDrawer';
14
14
  const classes = {
15
15
  root: `${PREFIX}-root`,
@@ -36,6 +36,7 @@ export default function NavigationMenuDrawer(inProps) {
36
36
  });
37
37
  const { className = null, showDrawerHeader = true, drawerHeaderContent = _jsx(DefaultHeaderContent, {}), drawerContent = _jsx(DefaultDrawerContent, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = {}, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = __rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
38
38
  const { preferences, features } = useSCPreferences();
39
+ const scUserContext = useSCUser();
39
40
  // TODO
40
41
  const liveStreamEnabled = true;
41
42
  /* const liveStreamEnabled = useMemo(