@100mslive/roomkit-react 0.3.17-alpha.0 → 0.3.17-alpha.10

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,4 +1,4 @@
1
- import React, { Fragment, useEffect, useState } from 'react';
1
+ import React, { Fragment, useCallback, useEffect, useState } from 'react';
2
2
  import { HMSKrispPlugin } from '@100mslive/hms-noise-cancellation';
3
3
  import {
4
4
  DeviceType,
@@ -14,6 +14,7 @@ import {
14
14
  useDevices,
15
15
  useHMSActions,
16
16
  useHMSStore,
17
+ useHMSVanillaStore,
17
18
  } from '@100mslive/react-sdk';
18
19
  import {
19
20
  AudioLevelIcon,
@@ -105,22 +106,26 @@ const useNoiseCancellationWithPlugin = () => {
105
106
  const actions = useHMSActions();
106
107
  const [inProgress, setInProgress] = useState(false);
107
108
  const [, setNoiseCancellationEnabled] = useSetNoiseCancellation();
108
- const setNoiseCancellationWithPlugin = async (enabled: boolean) => {
109
- if (inProgress) {
110
- return;
111
- }
112
- if (!krispPlugin.checkSupport().isSupported) {
113
- throw Error('Krisp plugin is not supported');
114
- }
115
- setInProgress(true);
116
- if (enabled) {
117
- await actions.addPluginToAudioTrack(krispPlugin);
118
- } else {
119
- await actions.removePluginFromAudioTrack(krispPlugin);
120
- }
121
- setNoiseCancellationEnabled(enabled);
122
- setInProgress(false);
123
- };
109
+ const isEnabledForRoom = useHMSStore(selectRoom)?.isNoiseCancellationEnabled;
110
+ const setNoiseCancellationWithPlugin = useCallback(
111
+ async (enabled: boolean) => {
112
+ if (!isEnabledForRoom || inProgress) {
113
+ return;
114
+ }
115
+ if (!krispPlugin.checkSupport().isSupported) {
116
+ throw Error('Krisp plugin is not supported');
117
+ }
118
+ setInProgress(true);
119
+ if (enabled) {
120
+ await actions.addPluginToAudioTrack(krispPlugin);
121
+ } else {
122
+ await actions.removePluginFromAudioTrack(krispPlugin);
123
+ }
124
+ setNoiseCancellationEnabled(enabled);
125
+ setInProgress(false);
126
+ },
127
+ [actions, inProgress, isEnabledForRoom, setNoiseCancellationEnabled],
128
+ );
124
129
  return {
125
130
  setNoiseCancellationWithPlugin,
126
131
  inProgress,
@@ -274,6 +279,7 @@ export const AudioVideoToggle = ({ hideOptions = false }: { hideOptions?: boolea
274
279
  const localPeer = useHMSStore(selectLocalPeer);
275
280
  const { isLocalVideoEnabled, isLocalAudioEnabled, toggleAudio, toggleVideo } = useAVToggle();
276
281
  const actions = useHMSActions();
282
+ const vanillaStore = useHMSVanillaStore();
277
283
  const videoTrackId = useHMSStore(selectLocalVideoTrackID);
278
284
  const localVideoTrack = useHMSStore(selectVideoTrackByID(videoTrackId));
279
285
  const roomState = useHMSStore(selectRoomState);
@@ -289,7 +295,14 @@ export const AudioVideoToggle = ({ hideOptions = false }: { hideOptions?: boolea
289
295
 
290
296
  useEffect(() => {
291
297
  (async () => {
292
- if (isNoiseCancellationEnabled && !isKrispPluginAdded && !inProgress && localPeer?.audioTrack) {
298
+ const isEnabledForRoom = vanillaStore.getState(selectRoom)?.isNoiseCancellationEnabled;
299
+ if (
300
+ isEnabledForRoom &&
301
+ isNoiseCancellationEnabled &&
302
+ !isKrispPluginAdded &&
303
+ !inProgress &&
304
+ localPeer?.audioTrack
305
+ ) {
293
306
  try {
294
307
  await setNoiseCancellationWithPlugin(true);
295
308
  ToastManager.addToast({
@@ -10,3 +10,5 @@ export const trackTypeOptions = [
10
10
  { label: 'audio', value: 'audio' },
11
11
  { label: 'video', value: 'video' },
12
12
  ];
13
+
14
+ export const DEFAULT_TILES_IN_VIEW = { MWEB: 4, DESKTOP: 9 };
@@ -131,23 +131,20 @@ const PreviewJoin = ({
131
131
 
132
132
  return roomState === HMSRoomState.Preview ? (
133
133
  <Flex justify="center" css={{ size: '100%', position: 'relative' }}>
134
- <Container css={{ h: '100%', pt: '$10', '@md': { justifyContent: 'space-between' } }}>
134
+ <Container css={{ h: '100%', pt: '$6', '@md': { justifyContent: 'space-between', pt: '$10' } }}>
135
135
  {toggleVideo ? null : <Box />}
136
- <Flex direction="column" justify="center" css={{ w: '100%', maxWidth: '640px' }}>
136
+ <Flex direction="column" justify="center" css={{ w: '100%', maxWidth: '600px', gap: '$8' }}>
137
137
  <Logo />
138
- <Text
139
- variant="h4"
140
- css={{ wordBreak: 'break-word', textAlign: 'center', mt: '$14', mb: '$4', '@md': { mt: '$8', mb: '$2' } }}
141
- >
138
+ <Text variant="h4" css={{ wordBreak: 'break-word', textAlign: 'center' }}>
142
139
  {previewHeader.title}
143
140
  </Text>
144
141
  <Text
145
- css={{ c: '$on_surface_medium', my: '0', textAlign: 'center', maxWidth: '100%', wordWrap: 'break-word' }}
142
+ css={{ c: '$on_surface_medium', textAlign: 'center', maxWidth: '100%', wordWrap: 'break-word' }}
146
143
  variant="sm"
147
144
  >
148
145
  {previewHeader.sub_title}
149
146
  </Text>
150
- <Flex justify="center" css={{ mt: '$14', '@md': { mt: '$8', mb: '0' }, gap: '$4' }}>
147
+ <Flex justify="center" css={{ gap: '$4' }}>
151
148
  {isStreamingOn ? (
152
149
  <Chip
153
150
  content="LIVE"
@@ -160,7 +157,7 @@ const PreviewJoin = ({
160
157
  </Flex>
161
158
  </Flex>
162
159
  {toggleVideo ? <PreviewTile name={name} error={previewError} /> : null}
163
- <Box css={{ w: '100%', maxWidth: `${Math.max(aspectRatio, 1) * 360}px` }}>
160
+ <Box css={{ w: '100%', maxWidth: `${Math.max(aspectRatio, 1) * 340}px` }}>
164
161
  <PreviewControls hideSettings={!toggleVideo && !toggleAudio} vbEnabled={!!virtual_background} />
165
162
  <PreviewForm
166
163
  name={name}
@@ -210,11 +207,11 @@ export const PreviewTile = ({ name, error }: { name: string; error?: boolean })
210
207
  css={{
211
208
  bg: '$surface_default',
212
209
  aspectRatio,
213
- height: 'min(360px, 70vh)',
210
+ height: 'min(340px, 70vh)',
214
211
  width: 'auto',
215
- maxWidth: '640px',
212
+ maxWidth: '600px',
216
213
  overflow: 'clip',
217
- mt: '$14',
214
+ mt: '$10',
218
215
  '@md': {
219
216
  mt: 0,
220
217
  width: 'min(220px, 70vw)',
@@ -261,7 +258,7 @@ export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boo
261
258
  justify={hideSettings && isMobile ? 'center' : 'between'}
262
259
  css={{
263
260
  width: '100%',
264
- mt: '$8',
261
+ mt: '$6',
265
262
  }}
266
263
  >
267
264
  <Flex css={{ gap: '$4' }}>
@@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
2
2
  import { selectIsAllowedToPublish, useAwayNotifications, useHMSStore, useScreenShare } from '@100mslive/react-sdk';
3
3
  import { ShareScreenIcon } from '@100mslive/react-icons';
4
4
  import { ShareScreenOptions } from './pdfAnnotator/shareScreenOptions';
5
+ import { ToastManager } from './Toast/ToastManager';
5
6
  import { Box, Flex } from '../../Layout';
6
7
  import { Tooltip } from '../../Tooltip';
7
8
  import { ScreenShareButton } from './ShareMenuIcon';
@@ -13,7 +14,17 @@ export const ScreenshareToggle = ({ css = {} }) => {
13
14
  const isAllowedToPublish = useHMSStore(selectIsAllowedToPublish);
14
15
  const isAudioOnly = useUISettings(UI_SETTINGS.isAudioOnly);
15
16
 
16
- const { amIScreenSharing, screenShareVideoTrackId: video, toggleScreenShare } = useScreenShare();
17
+ const {
18
+ amIScreenSharing,
19
+ screenShareVideoTrackId: video,
20
+ toggleScreenShare,
21
+ } = useScreenShare(error => {
22
+ ToastManager.addToast({
23
+ title: error.message,
24
+ variant: 'error',
25
+ duration: 2000,
26
+ });
27
+ });
17
28
  const { requestPermission } = useAwayNotifications();
18
29
  const isVideoScreenshare = amIScreenSharing && !!video;
19
30
  if (!isAllowedToPublish.screen || !isScreenshareSupported()) {
@@ -30,7 +30,6 @@ import { useSidepaneResetOnLayoutUpdate } from '../AppData/useSidepaneResetOnLay
30
30
  // @ts-ignore
31
31
  import { useSetAppDataByKey, useUISettings } from '../AppData/useUISettings';
32
32
  import { APP_DATA, SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
33
- import { defaultMedia } from './constants';
34
33
 
35
34
  const iconDims = { height: '40px', width: '40px' };
36
35
 
@@ -52,9 +51,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
52
51
  const [loadingEffects, setLoadingEffects] = useSetAppDataByKey(APP_DATA.loadingEffects);
53
52
  const isPluginAdded = useHMSStore(selectIsLocalVideoPluginPresent(VBHandler?.getName() || ''));
54
53
  const background = useHMSStore(selectAppData(APP_DATA.background));
55
- const mediaList = backgroundMedia.length
56
- ? backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '')
57
- : defaultMedia;
54
+ const mediaList = backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '');
58
55
 
59
56
  const inPreview = roomState === HMSRoomState.Preview;
60
57
  // Hidden in preview as the effect will be visible in the preview tile
@@ -1 +0,0 @@
1
- export declare const defaultMedia: string[];