@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.
@@ -1 +1,65 @@
1
- import{selectTracksMap as t}from"@100mslive/hms-video-store";import{useMemo as e}from"react";import{getVideoTracksFromPeers as o,getModeAspectRatio as a,calculateLayoutSizes as i,chunkElements as r}from"../utils/layout.js";import{useHMSVanillaStore as s}from"./HmsRoomProvider.js";const n=({maxTileCount:n,maxColCount:h,maxRowCount:l,width:m,height:g,showScreenFn:u,peers:d,overflow:f,aspectRatio:P})=>{const p=s().getState(t),c=o(d,p,u),C=e((()=>{if(P)return P;return{width:a(c)||1,height:1}}),[P,c]),x=c.length,{tilesInFirstPage:F,defaultWidth:w,defaultHeight:H,lastPageWidth:W,lastPageHeight:R,isLastPageDifferentFromFirstPage:v}=e((()=>i({count:x,parentWidth:Math.floor(m),parentHeight:Math.floor(g),maxTileCount:n,maxRowCount:l,maxColCount:h,aspectRatio:C})),[x,m,g,n,l,h,C]);return{chunkedTracksWithPeer:e((()=>r({elements:c,tilesInFirstPage:F,onlyOnePage:"hidden"===f,isLastPageDifferentFromFirstPage:v,defaultWidth:w,defaultHeight:H,lastPageWidth:W,lastPageHeight:R})),[c,F,f,v,w,H,W,R])}};export{n as useVideoList};
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/useVideoListLayout.js";export{useAVToggle}from"./hooks/useAVToggle.js";export{useDevices}from"./hooks/useDevices.js";
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.1-alpha",
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
  }
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## 0.0.1-alpha
2
-
3
- - `useVideoList()` take config as an object instead of params
4
-
5
- ## 0.0.0-alpha