@100mslive/react-sdk 0.0.1-alpha → 0.0.2-alpha
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/hooks/useAudioLevel.d.ts +5 -0
- package/dist/hooks/usePreview.d.ts +1 -1
- package/dist/hooks/useVideo.d.ts +2 -0
- package/dist/hooks/useVideoList.d.ts +26 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/node_modules/react-intersection-observer/react-intersection-observer.m.js +244 -0
- package/dist/packages/react-sdk/src/hooks/HmsRoomProvider.js +131 -0
- package/dist/packages/react-sdk/src/hooks/store.js +25 -0
- package/dist/packages/react-sdk/src/hooks/useAVToggle.js +35 -0
- package/dist/packages/react-sdk/src/hooks/useAudioLevel.js +24 -0
- package/dist/packages/react-sdk/src/hooks/useDevices.js +62 -0
- package/dist/packages/react-sdk/src/hooks/usePreview.js +40 -0
- package/dist/packages/react-sdk/src/hooks/useVideo.js +44 -0
- package/dist/packages/react-sdk/src/hooks/useVideoListLayout.js +65 -0
- package/dist/packages/react-sdk/src/hooks/useVideoTile.js +36 -0
- package/dist/packages/react-sdk/src/index.js +9 -0
- package/dist/packages/react-sdk/src/utils/isBrowser.js +2 -0
- package/dist/packages/react-sdk/src/utils/layout.js +434 -0
- package/dist/packages/react-sdk/src/utils/logger.js +74 -0
- package/dist/src/hooks/useAudioLevel.js +1 -0
- package/dist/src/hooks/usePreview.js +1 -1
- package/dist/src/hooks/useVideo.js +1 -0
- package/dist/src/hooks/useVideoList.js +1 -0
- package/dist/src/hooks/useVideoListLayout.js +65 -1
- package/dist/src/index.js +1 -1
- package/package.json +2 -1
- package/CHANGELOG.md +0 -5
|
@@ -1 +1,65 @@
|
|
|
1
|
-
import{selectTracksMap
|
|
1
|
+
import { selectTracksMap } from '@100mslive/hms-video-store';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { getVideoTracksFromPeers, getModeAspectRatio, calculateLayoutSizes, chunkElements } from '../utils/layout.js';
|
|
4
|
+
import { useHMSVanillaStore } from './HmsRoomProvider.js';
|
|
5
|
+
|
|
6
|
+
const useVideoList = ({
|
|
7
|
+
maxTileCount,
|
|
8
|
+
maxColCount,
|
|
9
|
+
maxRowCount,
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
showScreenFn,
|
|
13
|
+
peers,
|
|
14
|
+
overflow,
|
|
15
|
+
aspectRatio
|
|
16
|
+
}) => {
|
|
17
|
+
const store = useHMSVanillaStore();
|
|
18
|
+
const tracksMap = store.getState(selectTracksMap);
|
|
19
|
+
const tracksWithPeer = getVideoTracksFromPeers(peers, tracksMap, showScreenFn);
|
|
20
|
+
const finalAspectRatio = useMemo(() => {
|
|
21
|
+
if (aspectRatio) {
|
|
22
|
+
return aspectRatio;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const modeAspectRatio = getModeAspectRatio(tracksWithPeer); // Default to 1 if there are no video tracks
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
width: modeAspectRatio || 1,
|
|
29
|
+
height: 1
|
|
30
|
+
};
|
|
31
|
+
}, [aspectRatio, tracksWithPeer]);
|
|
32
|
+
const count = tracksWithPeer.length;
|
|
33
|
+
const {
|
|
34
|
+
tilesInFirstPage,
|
|
35
|
+
defaultWidth,
|
|
36
|
+
defaultHeight,
|
|
37
|
+
lastPageWidth,
|
|
38
|
+
lastPageHeight,
|
|
39
|
+
isLastPageDifferentFromFirstPage
|
|
40
|
+
} = useMemo(() => // Flooring since there's a bug in react-slick where it converts widdh into a number
|
|
41
|
+
calculateLayoutSizes({
|
|
42
|
+
count,
|
|
43
|
+
parentWidth: Math.floor(width),
|
|
44
|
+
parentHeight: Math.floor(height),
|
|
45
|
+
maxTileCount,
|
|
46
|
+
maxRowCount,
|
|
47
|
+
maxColCount,
|
|
48
|
+
aspectRatio: finalAspectRatio
|
|
49
|
+
}), [count, width, height, maxTileCount, maxRowCount, maxColCount, finalAspectRatio]);
|
|
50
|
+
const chunkedTracksWithPeer = useMemo(() => chunkElements({
|
|
51
|
+
elements: tracksWithPeer,
|
|
52
|
+
tilesInFirstPage,
|
|
53
|
+
onlyOnePage: overflow === 'hidden',
|
|
54
|
+
isLastPageDifferentFromFirstPage,
|
|
55
|
+
defaultWidth,
|
|
56
|
+
defaultHeight,
|
|
57
|
+
lastPageWidth,
|
|
58
|
+
lastPageHeight
|
|
59
|
+
}), [tracksWithPeer, tilesInFirstPage, overflow, isLastPageDifferentFromFirstPage, defaultWidth, defaultHeight, lastPageWidth, lastPageHeight]);
|
|
60
|
+
return {
|
|
61
|
+
chunkedTracksWithPeer
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { useVideoList };
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{HMSRoomProvider,useHMSActions,useHMSNotifications,useHMSStore,useHMSVanillaStore}from"./hooks/HmsRoomProvider.js";export{calculateLayoutSizes,chunkElements,getModeAspectRatio}from"./utils/layout.js";export{usePreview}from"./hooks/usePreview.js";export{useVideoTile}from"./hooks/useVideoTile.js";export{useVideoList}from"./hooks/
|
|
1
|
+
export{HMSRoomProvider,useHMSActions,useHMSNotifications,useHMSStore,useHMSVanillaStore}from"./hooks/HmsRoomProvider.js";export{calculateLayoutSizes,chunkElements,getModeAspectRatio}from"./utils/layout.js";export{usePreview}from"./hooks/usePreview.js";export{useVideoTile}from"./hooks/useVideoTile.js";export{useVideoList}from"./hooks/useVideoList.js";export{useAVToggle}from"./hooks/useAVToggle.js";export{useDevices}from"./hooks/useDevices.js";export{useVideo}from"./hooks/useVideo.js";export{useAudioLevel}from"./hooks/useAudioLevel.js";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.2-alpha",
|
|
8
8
|
"author": "100ms",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"files": [
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@100mslive/hms-video": "^0.1.23",
|
|
32
32
|
"@100mslive/hms-video-store": "^0.2.71",
|
|
33
|
+
"react-intersection-observer": "^8.33.1",
|
|
33
34
|
"zustand": "^3.6.2"
|
|
34
35
|
}
|
|
35
36
|
}
|