@100mslive/roomkit-react 0.3.8-alpha.2 → 0.3.8-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.3.8-alpha.2",
13
+ "version": "0.3.8-alpha.4",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -82,11 +82,11 @@
82
82
  "react": ">=17.0.2 <19.0.0"
83
83
  },
84
84
  "dependencies": {
85
- "@100mslive/hls-player": "0.3.8-alpha.2",
85
+ "@100mslive/hls-player": "0.3.8-alpha.4",
86
86
  "@100mslive/hms-noise-cancellation": "0.0.1",
87
- "@100mslive/hms-virtual-background": "1.13.8-alpha.2",
88
- "@100mslive/react-icons": "0.10.8-alpha.2",
89
- "@100mslive/react-sdk": "0.10.8-alpha.2",
87
+ "@100mslive/hms-virtual-background": "1.13.8-alpha.4",
88
+ "@100mslive/react-icons": "0.10.8-alpha.4",
89
+ "@100mslive/react-sdk": "0.10.8-alpha.4",
90
90
  "@100mslive/types-prebuilt": "0.12.8",
91
91
  "@emoji-mart/data": "^1.0.6",
92
92
  "@emoji-mart/react": "^1.0.1",
@@ -122,5 +122,5 @@
122
122
  "uuid": "^8.3.2",
123
123
  "worker-timers": "^7.0.40"
124
124
  },
125
- "gitHead": "43ee35cc85faabb5a827f7f41a5affebffcfca18"
125
+ "gitHead": "1ac0f11a034d8e0aed06479e20671c86bffd77f8"
126
126
  }
@@ -68,7 +68,8 @@ const initialAppData = {
68
68
  [POLL_STATE.pollInView]: '',
69
69
  [POLL_STATE.view]: '',
70
70
  },
71
- [APP_DATA.caption]: true,
71
+ // by default off, so it will not appear in beam bots
72
+ [APP_DATA.caption]: false,
72
73
  };
73
74
 
74
75
  export const AppData = React.memo(() => {
@@ -1,5 +1,4 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { useMedia } from 'react-use';
3
2
  import { DefaultConferencingScreen_Elements } from '@100mslive/types-prebuilt';
4
3
  import { v4 as uuid } from 'uuid';
5
4
  import {
@@ -19,7 +18,6 @@ import { ActivatedPIP } from './PIP/PIPComponent';
19
18
  import { PictureInPicture } from './PIP/PIPManager';
20
19
  import { RoleChangeRequestModal } from './RoleChangeRequest/RoleChangeRequestModal';
21
20
  import { Box, Flex } from '../../Layout';
22
- import { config } from '../../Theme';
23
21
  import { useHMSPrebuiltContext } from '../AppContext';
24
22
  import { VideoStreamingSection } from '../layouts/VideoStreamingSection';
25
23
  // @ts-ignore: No implicit Any
@@ -28,21 +26,17 @@ import FullPageProgress from './FullPageProgress';
28
26
  import { Header } from './Header';
29
27
  import { PreviousRoleInMetadata } from './PreviousRoleInMetadata';
30
28
  import { RaiseHand } from './RaiseHand';
31
- import { CaptionsViewer } from '../plugins/CaptionsViewer';
32
29
  import {
33
30
  useRoomLayoutConferencingScreen,
34
31
  useRoomLayoutPreviewScreen,
35
32
  } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
36
33
  // @ts-ignore: No implicit Any
37
- import { useIsSidepaneTypeOpen } from './AppData/useSidepane';
38
- // @ts-ignore: No implicit Any
39
- import { useAuthToken, useIsCaptionEnabled, useSetAppDataByKey } from './AppData/useUISettings';
34
+ import { useAuthToken, useSetAppDataByKey } from './AppData/useUISettings';
40
35
  import { useLandscapeHLSStream, useMobileHLSStream } from '../common/hooks';
41
- import { APP_DATA, isAndroid, isIOS, isIPadOS, SIDE_PANE_OPTIONS } from '../common/constants';
36
+ import { APP_DATA, isAndroid, isIOS, isIPadOS } from '../common/constants';
42
37
 
43
38
  export const ConferenceScreen = () => {
44
39
  const { userName, endpoints, onJoin: onJoinFunc } = useHMSPrebuiltContext();
45
- const isMobile = useMedia(config.media.md);
46
40
  const screenProps = useRoomLayoutConferencingScreen();
47
41
  const { isPreviewScreenEnabled } = useRoomLayoutPreviewScreen();
48
42
  const roomState = useHMSStore(selectRoomState);
@@ -63,10 +57,6 @@ export const ConferenceScreen = () => {
63
57
  const isMobileHLSStream = useMobileHLSStream();
64
58
  const isLandscapeHLSStream = useLandscapeHLSStream();
65
59
  const isMwebHLSStream = isMobileHLSStream || isLandscapeHLSStream;
66
- const isCaptionEnabled = useIsCaptionEnabled();
67
- const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
68
-
69
- const showCaptionAtTop = screenProps.elements?.chat?.is_overlay && isChatOpen;
70
60
 
71
61
  const toggleControls = () => {
72
62
  if (dropdownListRef.current?.length === 0 && isMobileDevice && !isMwebHLSStream) {
@@ -134,28 +124,6 @@ export const ConferenceScreen = () => {
134
124
  <FullPageProgress text="Starting live stream..." css={{ opacity: 0.8, bg: '$background_dim' }} />
135
125
  </Box>
136
126
  ) : null}
137
- {isCaptionEnabled && screenProps.screenType !== 'hls_live_streaming' && (
138
- <Box
139
- css={{
140
- position: 'fixed',
141
- maxWidth: isMobile ? '100%' : '40%',
142
- bottom: showCaptionAtTop ? '' : hideControlsForStreaming ? '5%' : '10%',
143
- top: showCaptionAtTop ? (hideControlsForStreaming ? '5%' : '10%') : '',
144
- left: isMobile ? 0 : '50%',
145
- transform: isMobile ? '' : 'translateX(-50%)',
146
- background: '#000000A3',
147
- overflow: 'clip',
148
- zIndex: 10,
149
- height: 'fit-content',
150
- r: '$1',
151
- p: '$6',
152
- transition: 'bottom 0.3s ease-in-out',
153
- '&:empty': { display: 'none' },
154
- }}
155
- >
156
- <CaptionsViewer />
157
- </Box>
158
- )}
159
127
  <Flex css={{ size: '100%', overflow: 'hidden' }} direction="column">
160
128
  {!(screenProps.hideSections.includes('header') || isMwebHLSStream) && (
161
129
  <Box
@@ -16,6 +16,8 @@ import { PDFView } from './PDFView';
16
16
  import SidePane from './SidePane';
17
17
  // @ts-ignore: No implicit Any
18
18
  import { WaitingView } from './WaitingView';
19
+ import { CaptionsViewer } from '../plugins/CaptionsViewer';
20
+ // @ts-ignore: No implicit Any
19
21
  import {
20
22
  usePDFConfig,
21
23
  useUrlToEmbed,
@@ -25,7 +27,6 @@ import {
25
27
  import { useCloseScreenshareWhiteboard } from '../components/hooks/useCloseScreenshareWhiteboard';
26
28
  import { useLandscapeHLSStream, useMobileHLSStream } from '../common/hooks';
27
29
  import { SESSION_STORE_KEY } from '../common/constants';
28
-
29
30
  // @ts-ignore: No implicit Any
30
31
  const HLSView = React.lazy(() => import('./HLSView'));
31
32
 
@@ -105,6 +106,7 @@ export const VideoStreamingSection = ({
105
106
  // @ts-ignore
106
107
  return <GridLayout {...(elements as DefaultConferencingScreen_Elements)?.video_tile_layout?.grid} />;
107
108
  })}
109
+ <CaptionsViewer />
108
110
  <Box
109
111
  css={{
110
112
  flex: match({ isLandscapeHLSStream, isMobileHLSStream })
@@ -1,8 +1,15 @@
1
1
  import React, { useEffect, useState } from 'react';
2
+ import { useMedia } from 'react-use';
2
3
  import { HMSTranscript, selectPeerNameByID, useHMSStore, useTranscript } from '@100mslive/react-sdk';
3
- import { Flex } from '../../Layout';
4
+ import { Box, Flex } from '../../Layout';
4
5
  import { Text } from '../../Text';
5
-
6
+ import { config } from '../../Theme';
7
+ // @ts-ignore: No implicit Any
8
+ import { useIsSidepaneTypeOpen } from '../components/AppData/useSidepane';
9
+ // @ts-ignore: No implicit Any
10
+ import { useIsCaptionEnabled } from '../components/AppData/useUISettings';
11
+ import { useRoomLayoutConferencingScreen } from '../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
12
+ import { SIDE_PANE_OPTIONS } from '../common/constants';
6
13
  interface CaptionQueueData extends HMSTranscript {
7
14
  transcriptQueue: SimpleQueue;
8
15
  }
@@ -135,7 +142,7 @@ class CaptionMaintainerQueue {
135
142
  }
136
143
  }
137
144
  const TranscriptView = ({ peer_id, data }: { peer_id: string; data: string }) => {
138
- const peerName = useHMSStore(selectPeerNameByID(peer_id));
145
+ const peerName = useHMSStore(selectPeerNameByID(peer_id)) || 'Participant';
139
146
  data = data.trim();
140
147
  if (!data) return null;
141
148
  return (
@@ -145,15 +152,24 @@ const TranscriptView = ({ peer_id, data }: { peer_id: string; data: string }) =>
145
152
  fontWeight: '$normal',
146
153
  }}
147
154
  >
148
- {`${peerName}: ${data}`}
155
+ <b>{peerName}: </b>
156
+ {data}
149
157
  </Text>
150
158
  );
151
159
  };
152
160
 
153
161
  export const CaptionsViewer = () => {
162
+ const { elements, screenType } = useRoomLayoutConferencingScreen();
163
+ const isMobile = useMedia(config.media.md);
164
+ const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
165
+
166
+ const showCaptionAtTop = elements?.chat?.is_overlay && isChatOpen && isMobile;
167
+
154
168
  const [captionQueue] = useState<CaptionMaintainerQueue>(new CaptionMaintainerQueue());
155
169
  const [currentData, setCurrentData] = useState<{ [key: string]: string }[]>([]);
156
170
 
171
+ const isCaptionEnabled = useIsCaptionEnabled();
172
+
157
173
  useEffect(() => {
158
174
  const timeInterval = setInterval(() => {
159
175
  if (!captionQueue) {
@@ -177,15 +193,34 @@ export const CaptionsViewer = () => {
177
193
  }
178
194
  return false;
179
195
  });
180
- if (dataToShow.length <= 0) {
196
+ if (dataToShow.length <= 0 || screenType === 'hls_live_streaming' || !isCaptionEnabled) {
181
197
  return null;
182
198
  }
183
199
  return (
184
- <Flex direction="column" gap={1}>
185
- {dataToShow.map((data: { [key: string]: string }, index: number) => {
186
- const key = Object.keys(data)[0];
187
- return <TranscriptView key={index} peer_id={key} data={data[key]} />;
188
- })}
189
- </Flex>
200
+ <Box
201
+ css={{
202
+ position: 'absolute',
203
+ w: isMobile ? '100%' : '40%',
204
+ bottom: showCaptionAtTop ? '' : '0',
205
+ top: showCaptionAtTop ? '0' : '',
206
+ left: isMobile ? 0 : '50%',
207
+ transform: isMobile ? '' : 'translateX(-50%)',
208
+ background: '#000000A3',
209
+ overflow: 'clip',
210
+ zIndex: 10,
211
+ height: 'fit-content',
212
+ r: '$1',
213
+ p: '$6',
214
+ transition: 'bottom 0.3s ease-in-out',
215
+ '&:empty': { display: 'none' },
216
+ }}
217
+ >
218
+ <Flex direction="column">
219
+ {dataToShow.map((data: { [key: string]: string }, index: number) => {
220
+ const key = Object.keys(data)[0];
221
+ return <TranscriptView key={index} peer_id={key} data={data[key]} />;
222
+ })}
223
+ </Flex>
224
+ </Box>
190
225
  );
191
226
  };