@100mslive/roomkit-react 0.3.12 → 0.3.13-alpha.0
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/dist/{HLSView-ZPNPCOF2.css → HLSView-CU536VT4.css} +3 -3
- package/dist/{HLSView-ZPNPCOF2.css.map → HLSView-CU536VT4.css.map} +1 -1
- package/dist/{HLSView-C2U74KCJ.js → HLSView-K2ETVPZ6.js} +2 -2
- package/dist/Prebuilt/common/constants.d.ts +1 -0
- package/dist/Prebuilt/plugins/CaptionsViewer.d.ts +5 -1
- package/dist/{chunk-K7H5ZUXQ.js → chunk-3FTUSPXW.js} +291 -226
- package/dist/chunk-3FTUSPXW.js.map +7 -0
- package/dist/index.cjs.css +2 -2
- package/dist/index.cjs.css.map +1 -1
- package/dist/index.cjs.js +258 -192
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +52 -32
- package/dist/meta.esbuild.json +62 -42
- package/package.json +8 -8
- package/src/Prebuilt/common/constants.ts +1 -0
- package/src/Prebuilt/components/AppData/AppData.tsx +9 -1
- package/src/Prebuilt/components/AppData/useUISettings.js +10 -0
- package/src/Prebuilt/components/AudioVideoToggle.tsx +27 -8
- package/src/Prebuilt/components/MoreSettings/CaptionContent.tsx +3 -0
- package/src/Prebuilt/components/Streaming/Common.jsx +5 -4
- package/src/Prebuilt/layouts/VideoStreamingSection.tsx +5 -7
- package/src/Prebuilt/plugins/CaptionsViewer.tsx +47 -25
- package/dist/chunk-K7H5ZUXQ.js.map +0 -7
- /package/dist/{HLSView-C2U74KCJ.js.map → HLSView-K2ETVPZ6.js.map} +0 -0
@@ -1,4 +1,5 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
2
|
+
import Draggable, { ControlPosition } from 'react-draggable';
|
2
3
|
import { useMedia } from 'react-use';
|
3
4
|
import {
|
4
5
|
HMSTranscript,
|
@@ -27,6 +28,9 @@ class SimpleQueue {
|
|
27
28
|
private storage: TranscriptData[] = [];
|
28
29
|
constructor(private capacity: number = 3, private MAX_STORAGE_TIME: number = 5000) {}
|
29
30
|
enqueue(data: TranscriptData): void {
|
31
|
+
if (!data.transcript.trim()) {
|
32
|
+
return;
|
33
|
+
}
|
30
34
|
if (this.size() === this.capacity && this.storage[this.size() - 1].final) {
|
31
35
|
this.dequeue(this.storage[this.size() - 1]);
|
32
36
|
}
|
@@ -164,7 +168,13 @@ const TranscriptView = ({ peer_id, data }: { peer_id: string; data: string }) =>
|
|
164
168
|
);
|
165
169
|
};
|
166
170
|
|
167
|
-
export const CaptionsViewer = (
|
171
|
+
export const CaptionsViewer = ({
|
172
|
+
defaultPosition,
|
173
|
+
setDefaultPosition,
|
174
|
+
}: {
|
175
|
+
defaultPosition: ControlPosition;
|
176
|
+
setDefaultPosition: (position: ControlPosition) => void;
|
177
|
+
}) => {
|
168
178
|
const { elements, screenType } = useRoomLayoutConferencingScreen();
|
169
179
|
const isMobile = useMedia(config.media.md);
|
170
180
|
const isChatOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.CHAT);
|
@@ -178,6 +188,8 @@ export const CaptionsViewer = () => {
|
|
178
188
|
|
179
189
|
const isTranscriptionEnabled = useHMSStore(selectIsTranscriptionEnabled);
|
180
190
|
|
191
|
+
const nodeRef = useRef<HTMLDivElement>(null);
|
192
|
+
|
181
193
|
useEffect(() => {
|
182
194
|
const timeInterval = setInterval(() => {
|
183
195
|
if (!captionQueue) {
|
@@ -205,30 +217,40 @@ export const CaptionsViewer = () => {
|
|
205
217
|
return null;
|
206
218
|
}
|
207
219
|
return (
|
208
|
-
<
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
left: isMobile ? 0 : '50%',
|
215
|
-
transform: isMobile ? '' : 'translateX(-50%)',
|
216
|
-
background: '#000000A3',
|
217
|
-
overflow: 'clip',
|
218
|
-
zIndex: 10,
|
219
|
-
height: 'fit-content',
|
220
|
-
r: '$1',
|
221
|
-
p: '$6',
|
222
|
-
transition: 'bottom 0.3s ease-in-out',
|
223
|
-
'&:empty': { display: 'none' },
|
220
|
+
<Draggable
|
221
|
+
bounds="parent"
|
222
|
+
nodeRef={nodeRef}
|
223
|
+
defaultPosition={defaultPosition}
|
224
|
+
onStop={(_, data) => {
|
225
|
+
setDefaultPosition({ x: data.lastX, y: data.lastY });
|
224
226
|
}}
|
225
227
|
>
|
226
|
-
<
|
227
|
-
{
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
228
|
+
<Box
|
229
|
+
ref={nodeRef}
|
230
|
+
css={{
|
231
|
+
position: 'absolute',
|
232
|
+
w: isMobile ? '100%' : '40%',
|
233
|
+
bottom: showCaptionAtTop ? '' : '0',
|
234
|
+
top: showCaptionAtTop ? '0' : '',
|
235
|
+
left: isMobile ? 0 : '50%',
|
236
|
+
transform: isMobile ? '' : 'translateX(-50%)',
|
237
|
+
background: '#000000A3',
|
238
|
+
overflow: 'clip',
|
239
|
+
zIndex: 10,
|
240
|
+
height: 'fit-content',
|
241
|
+
r: '$1',
|
242
|
+
p: '$6',
|
243
|
+
transition: 'bottom 0.3s ease-in-out',
|
244
|
+
'&:empty': { display: 'none' },
|
245
|
+
}}
|
246
|
+
>
|
247
|
+
<Flex direction="column">
|
248
|
+
{dataToShow.map((data: { [key: string]: string }, index: number) => {
|
249
|
+
const key = Object.keys(data)[0];
|
250
|
+
return <TranscriptView key={index} peer_id={key} data={data[key]} />;
|
251
|
+
})}
|
252
|
+
</Flex>
|
253
|
+
</Box>
|
254
|
+
</Draggable>
|
233
255
|
);
|
234
256
|
};
|