@100mslive/roomkit-react 0.3.17-alpha.1 → 0.3.17-alpha.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/dist/{HLSView-O4KQ2SQJ.js → HLSView-42EL65Z3.js} +2 -2
  2. package/dist/{HLSView-DIQJQC42.css → HLSView-7NVZOZKG.css} +3 -3
  3. package/dist/{HLSView-DIQJQC42.css.map → HLSView-7NVZOZKG.css.map} +1 -1
  4. package/dist/Prebuilt/components/MoreSettings/constants.d.ts +4 -0
  5. package/dist/Prebuilt/components/Notifications/ReconnectNotifications.d.ts +1 -2
  6. package/dist/{chunk-SCKPBPAN.js → chunk-Y4ZC5NAS.js} +774 -773
  7. package/dist/chunk-Y4ZC5NAS.js.map +7 -0
  8. package/dist/index.cjs.css +2 -2
  9. package/dist/index.cjs.css.map +1 -1
  10. package/dist/index.cjs.js +589 -593
  11. package/dist/index.cjs.js.map +4 -4
  12. package/dist/index.css +2 -2
  13. package/dist/index.css.map +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/meta.cjs.json +83 -68
  16. package/dist/meta.esbuild.json +95 -80
  17. package/package.json +7 -7
  18. package/src/Prebuilt/components/AppData/AppData.tsx +8 -2
  19. package/src/Prebuilt/components/AudioVideoToggle.tsx +31 -18
  20. package/src/Prebuilt/components/MoreSettings/constants.ts +2 -0
  21. package/src/Prebuilt/components/Notifications/ReconnectNotifications.tsx +10 -37
  22. package/src/Prebuilt/components/Preview/PreviewJoin.tsx +13 -14
  23. package/src/Prebuilt/components/Toast/ToastConfig.jsx +2 -2
  24. package/src/Prebuilt/components/VirtualBackground/VBHandler.tsx +1 -2
  25. package/src/Prebuilt/components/VirtualBackground/VBPicker.tsx +2 -1
  26. package/src/Prebuilt/components/VirtualBackground/VBToggle.tsx +9 -2
  27. package/dist/chunk-SCKPBPAN.js.map +0 -7
  28. /package/dist/{HLSView-O4KQ2SQJ.js.map → HLSView-42EL65Z3.js.map} +0 -0
@@ -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 };
@@ -1,6 +1,5 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
  import { HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk';
3
- import { Dialog, Flex, Loading, Text } from '../../..';
4
3
  // @ts-ignore: No implicit Any
5
4
  import { ToastConfig } from '../Toast/ToastConfig';
6
5
  // @ts-ignore: No implicit Any
@@ -15,50 +14,24 @@ let notificationId: string | null = null;
15
14
 
16
15
  export const ReconnectNotifications = () => {
17
16
  const notification = useHMSNotifications(notificationTypes);
18
- const [open, setOpen] = useState(false);
17
+ const prevErrorCode = useRef(0);
19
18
  useEffect(() => {
20
19
  if (!notification) {
21
20
  return;
22
21
  }
23
- if (notification.type === HMSNotificationTypes.ERROR && notification.data?.isTerminal) {
24
- setOpen(false);
25
- } else if (notification.type === HMSNotificationTypes.RECONNECTED) {
26
- notificationId = ToastManager.replaceToast(notificationId, ToastConfig.RECONNECTED.single());
27
- setOpen(false);
22
+ if (notification.type === HMSNotificationTypes.RECONNECTED) {
23
+ notificationId = ToastManager.replaceToast(
24
+ notificationId,
25
+ ToastConfig.RECONNECTED.single([4005, 4006].includes(prevErrorCode.current)),
26
+ );
28
27
  } else if (notification.type === HMSNotificationTypes.RECONNECTING) {
28
+ prevErrorCode.current = notification.data?.code || 0;
29
29
  notificationId = ToastManager.replaceToast(
30
30
  notificationId,
31
31
  ToastConfig.RECONNECTING.single(notification.data?.message),
32
32
  );
33
33
  }
34
34
  }, [notification]);
35
- if (!open) return null;
36
- return (
37
- <Dialog.Root open={open} modal={true}>
38
- <Dialog.Portal container={document.getElementById('conferencing')}>
39
- <Dialog.Overlay />
40
- <Dialog.Content
41
- css={{
42
- width: 'fit-content',
43
- maxWidth: '80%',
44
- p: '$4 $8',
45
- position: 'relative',
46
- top: 'unset',
47
- bottom: '$9',
48
- transform: 'translate(-50%, -100%)',
49
- animation: 'none !important',
50
- }}
51
- >
52
- <Flex align="center">
53
- <div style={{ display: 'inline', margin: '0.25rem' }}>
54
- <Loading size={16} />
55
- </div>
56
- <Text css={{ fontSize: '$space$8', color: '$on_surface_high' }}>
57
- You lost your network connection. Trying to reconnect.
58
- </Text>
59
- </Flex>
60
- </Dialog.Content>
61
- </Dialog.Portal>
62
- </Dialog.Root>
63
- );
35
+
36
+ return null;
64
37
  };
@@ -4,6 +4,7 @@ import {
4
4
  HMSRoomState,
5
5
  selectAppData,
6
6
  selectIsLocalVideoEnabled,
7
+ selectIsVBEnabled,
7
8
  selectLocalPeer,
8
9
  selectRoomState,
9
10
  selectVideoTrackByID,
@@ -131,23 +132,20 @@ const PreviewJoin = ({
131
132
 
132
133
  return roomState === HMSRoomState.Preview ? (
133
134
  <Flex justify="center" css={{ size: '100%', position: 'relative' }}>
134
- <Container css={{ h: '100%', pt: '$10', '@md': { justifyContent: 'space-between' } }}>
135
+ <Container css={{ h: '100%', pt: '$6', '@md': { justifyContent: 'space-between', pt: '$10' } }}>
135
136
  {toggleVideo ? null : <Box />}
136
- <Flex direction="column" justify="center" css={{ w: '100%', maxWidth: '640px' }}>
137
+ <Flex direction="column" justify="center" css={{ w: '100%', maxWidth: '600px', gap: '$8' }}>
137
138
  <Logo />
138
- <Text
139
- variant="h4"
140
- css={{ wordBreak: 'break-word', textAlign: 'center', mt: '$14', mb: '$4', '@md': { mt: '$8', mb: '$2' } }}
141
- >
139
+ <Text variant="h4" css={{ wordBreak: 'break-word', textAlign: 'center' }}>
142
140
  {previewHeader.title}
143
141
  </Text>
144
142
  <Text
145
- css={{ c: '$on_surface_medium', my: '0', textAlign: 'center', maxWidth: '100%', wordWrap: 'break-word' }}
143
+ css={{ c: '$on_surface_medium', textAlign: 'center', maxWidth: '100%', wordWrap: 'break-word' }}
146
144
  variant="sm"
147
145
  >
148
146
  {previewHeader.sub_title}
149
147
  </Text>
150
- <Flex justify="center" css={{ mt: '$14', '@md': { mt: '$8', mb: '0' }, gap: '$4' }}>
148
+ <Flex justify="center" css={{ gap: '$4' }}>
151
149
  {isStreamingOn ? (
152
150
  <Chip
153
151
  content="LIVE"
@@ -160,7 +158,7 @@ const PreviewJoin = ({
160
158
  </Flex>
161
159
  </Flex>
162
160
  {toggleVideo ? <PreviewTile name={name} error={previewError} /> : null}
163
- <Box css={{ w: '100%', maxWidth: `${Math.max(aspectRatio, 1) * 360}px` }}>
161
+ <Box css={{ w: '100%', maxWidth: `${Math.max(aspectRatio, 1) * 340}px` }}>
164
162
  <PreviewControls hideSettings={!toggleVideo && !toggleAudio} vbEnabled={!!virtual_background} />
165
163
  <PreviewForm
166
164
  name={name}
@@ -210,11 +208,11 @@ export const PreviewTile = ({ name, error }: { name: string; error?: boolean })
210
208
  css={{
211
209
  bg: '$surface_default',
212
210
  aspectRatio,
213
- height: 'min(360px, 70vh)',
211
+ height: 'min(340px, 70vh)',
214
212
  width: 'auto',
215
- maxWidth: '640px',
213
+ maxWidth: '600px',
216
214
  overflow: 'clip',
217
- mt: '$14',
215
+ mt: '$10',
218
216
  '@md': {
219
217
  mt: 0,
220
218
  width: 'min(220px, 70vw)',
@@ -256,17 +254,18 @@ export const PreviewTile = ({ name, error }: { name: string; error?: boolean })
256
254
 
257
255
  export const PreviewControls = ({ hideSettings, vbEnabled }: { hideSettings: boolean; vbEnabled: boolean }) => {
258
256
  const isMobile = useMedia(cssConfig.media.md);
257
+ const isVBEnabledForUser = useHMSStore(selectIsVBEnabled);
259
258
  return (
260
259
  <Flex
261
260
  justify={hideSettings && isMobile ? 'center' : 'between'}
262
261
  css={{
263
262
  width: '100%',
264
- mt: '$8',
263
+ mt: '$6',
265
264
  }}
266
265
  >
267
266
  <Flex css={{ gap: '$4' }}>
268
267
  <AudioVideoToggle />
269
- {vbEnabled ? <VBToggle /> : null}
268
+ {vbEnabled && isVBEnabledForUser ? <VBToggle /> : null}
270
269
  </Flex>
271
270
  <Flex align="center" gap="1">
272
271
  {isMobile && <NoiseCancellation iconOnly />}
@@ -153,9 +153,9 @@ export const ToastConfig = {
153
153
  },
154
154
  },
155
155
  RECONNECTED: {
156
- single: () => {
156
+ single: online => {
157
157
  return {
158
- title: `You are now connected`,
158
+ title: `You are now ${online ? 'online' : 'connected'}`,
159
159
  icon: <ConnectivityIcon />,
160
160
  variant: 'success',
161
161
  duration: 3000,
@@ -1,8 +1,7 @@
1
1
  import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
2
-
3
2
  export class VBPlugin {
4
3
  private hmsPlugin?: HMSVBPlugin;
5
- private effectsPlugin?: HMSEffectsPlugin | undefined;
4
+ private effectsPlugin?: HMSEffectsPlugin;
6
5
 
7
6
  initialisePlugin = (effectsSDKKey?: string, onInit?: () => void) => {
8
7
  if (this.getVBObject()) {
@@ -61,7 +61,8 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
61
61
  if (!track?.id) {
62
62
  return;
63
63
  }
64
- if (!isPluginAdded) {
64
+ const vbObject = VBHandler.getVBObject();
65
+ if (!isPluginAdded && !vbObject) {
65
66
  setLoadingEffects(true);
66
67
  let vbObject = VBHandler.getVBObject();
67
68
  if (!vbObject) {
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
- import { selectAppData, selectIsEffectsEnabled, selectIsLocalVideoEnabled, useHMSStore } from '@100mslive/react-sdk';
2
+ import {
3
+ selectAppData,
4
+ selectIsEffectsEnabled,
5
+ selectIsLocalVideoEnabled,
6
+ selectIsVBEnabled,
7
+ useHMSStore,
8
+ } from '@100mslive/react-sdk';
3
9
  import { VirtualBackgroundIcon } from '@100mslive/react-icons';
4
10
  import { Loading } from '../../../Loading';
5
11
  import { Tooltip } from '../../../Tooltip';
@@ -12,10 +18,11 @@ export const VBToggle = () => {
12
18
  const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
13
19
  const isVBOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.VB);
14
20
  const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
21
+ const isVBEnabled = useHMSStore(selectIsVBEnabled);
15
22
  const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
16
23
  const loadingEffects = useHMSStore(selectAppData(APP_DATA.loadingEffects));
17
24
 
18
- if (!isVideoOn || (!isEffectsEnabled && isSafari)) {
25
+ if (!isVideoOn || (!isEffectsEnabled && isSafari) || !isVBEnabled) {
19
26
  return null;
20
27
  }
21
28