@100mslive/react-sdk 0.0.6 → 0.0.7-alpha.2

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/README.md CHANGED
@@ -7,6 +7,10 @@ over the primitive ones.
7
7
  If someone is using class based react components, they'll be better off
8
8
  with using the core sdk directly.
9
9
 
10
+ > If you're already using hooks from hms-video-react, this package will be a drop
11
+ > in replacement. hms-video-react is planned to be deprecated so please move your code
12
+ > to using this package instead.
13
+
10
14
  ### Primitive Hooks
11
15
 
12
16
  These are hooks wrapper over the sdk things.
@@ -38,3 +42,44 @@ the below things -
38
42
  - Prefer IDs to objects for both input arguments and in result object. This
39
43
  facilitates writing optimised code on the app layer, as objects are prone to change
40
44
  leading to unnecessary re renders on different levels.
45
+
46
+
47
+ ### TODO Planned Hooks
48
+
49
+ #### Breakout Rooms
50
+
51
+ ```ts
52
+ function useBreakoutRoles({filter: regexOrArray, filterOut: regexOrArray}) {
53
+ {
54
+ allRoles, // all breakout roles options for this user
55
+ currRole,
56
+ switchToRole() // takes in a role name
57
+ }
58
+ }
59
+ ```
60
+
61
+ #### Waiting Room
62
+
63
+ On the guest side who joins a waiting room -
64
+ ```ts
65
+ // onconfirm if role change is not forced, fn returns true/false
66
+ // onapprovval - use this to play a tone maybe
67
+ function useWaitingRoom({waitingRoomRole, postApprovalRole, onApproval}) {
68
+ {
69
+ amIInWaitingRoom,
70
+ isConfirmationPending, // boolean, true when role change is not forced
71
+ confirmOrDeny(confirm) // pass in true or false
72
+ }
73
+ }
74
+ ```
75
+
76
+ On the host side who needs to see who is in waiting room and let them in.
77
+ ```ts
78
+ function useWaitingRoomApprover({waitingRoomRole, postApprovalRole, approverRoles: []}) {
79
+ {
80
+ peersInWaitingRoom,
81
+ approvePeer = (peerID, ask) // force role change to postApprovalRole
82
+ }
83
+ }
84
+ ```
85
+
@@ -0,0 +1,17 @@
1
+ export interface useAutoplayErrorResult {
2
+ error: string;
3
+ /**
4
+ * call this method on a UI element click to unblock the blocked audio autoplay.
5
+ */
6
+ unblockAudio: () => Promise<void>;
7
+ /**
8
+ * Call this method to reset(hide) the UI that is rendered when there was an error
9
+ */
10
+ resetError: () => void;
11
+ }
12
+ /**
13
+ * Use this hook to show a UI(modal or a toast) when autoplay is blocked by browser and allow the user to
14
+ * unblock the browser autoplay block
15
+ * @returns {useAutoplayErrorResult}
16
+ */
17
+ export declare const useAutoplayError: () => useAutoplayErrorResult;
@@ -1,15 +1,24 @@
1
1
  import { hooksErrHandler } from '../hooks/types';
2
- declare enum DeviceType {
2
+ export declare enum DeviceType {
3
3
  videoInput = "videoInput",
4
4
  audioInput = "audioInput",
5
5
  audioOutput = "audioOutput"
6
6
  }
7
- declare type DeviceTypeInfo<T> = {
7
+ export declare type DeviceTypeAndInfo<T> = {
8
8
  [key in DeviceType]?: T;
9
9
  };
10
10
  export interface useDevicesResult {
11
- allDevices: DeviceTypeInfo<MediaDeviceInfo[]>;
12
- selectedDeviceIDs: DeviceTypeInfo<string>;
11
+ /**
12
+ * list of all devices by type
13
+ */
14
+ allDevices: DeviceTypeAndInfo<MediaDeviceInfo[]>;
15
+ /**
16
+ * selected device ids for all types
17
+ */
18
+ selectedDeviceIDs: DeviceTypeAndInfo<string>;
19
+ /**
20
+ * function to call to update device
21
+ */
13
22
  updateDevice: ({ deviceType, deviceId }: {
14
23
  deviceType: DeviceType;
15
24
  deviceId: string;
@@ -19,7 +28,7 @@ export interface useDevicesResult {
19
28
  * This hook can be used to implement a UI component which allows the user to manually change their
20
29
  * audio/video device. It returns the list of all devices as well as the currently selected one. The input
21
30
  * devices will be returned based on what the user is allowed to publish, so a audio only user won't get
22
- * the videInput field.
31
+ * the audioInput field. This can be used to show the UI dropdowns properly.
23
32
  *
24
33
  * Note:
25
34
  * - Browsers give access to the list of devices only if the user has given permission to access them
@@ -29,4 +38,3 @@ export interface useDevicesResult {
29
38
  * @param handleError error handler for any errors during device change
30
39
  */
31
40
  export declare const useDevices: (handleError?: hooksErrHandler) => useDevicesResult;
32
- export {};
@@ -0,0 +1,13 @@
1
+ import { HMSPeer, HMSRoleName } from '@100mslive/hms-video-store';
2
+ export interface useParticipantListResult {
3
+ roles: HMSRoleName[];
4
+ participantsByRoles: Record<string, HMSPeer[]>;
5
+ peerCount: number;
6
+ isConnected: boolean;
7
+ }
8
+ export declare const useParticipantList: () => {
9
+ roles: string[];
10
+ participantsByRoles: Record<string, HMSPeer[]>;
11
+ peerCount: number;
12
+ isConnected: boolean | undefined;
13
+ };
@@ -1,4 +1,5 @@
1
- import { hooksErrHandler } from '../hooks/types';
1
+ import { HMSConfigInitialSettings } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from './types';
2
3
  export interface usePreviewInput {
3
4
  /**
4
5
  * name of user who is joining, this is only required if join is called
@@ -16,6 +17,11 @@ export interface usePreviewInput {
16
17
  * function to handle errors happening during preview
17
18
  */
18
19
  handleError?: hooksErrHandler;
20
+ initEndpoint?: string;
21
+ /**
22
+ * initial settings for audio/video and device to be used.
23
+ */
24
+ initialSettings?: HMSConfigInitialSettings;
19
25
  }
20
26
  export interface usePreviewResult {
21
27
  /**
@@ -31,6 +37,10 @@ export interface usePreviewResult {
31
37
  * to decide to show between preview form and conferencing component/video tiles.
32
38
  */
33
39
  isConnected: boolean;
40
+ /**
41
+ * call this function to join the room
42
+ */
43
+ preview: () => void;
34
44
  }
35
45
  /**
36
46
  * This hook can be used to build a preview UI component, this lets you call preview everytime the passed in
@@ -38,4 +48,4 @@ export interface usePreviewResult {
38
48
  * muting/unmuting and useAudioLevelStyles for showing mic audio level to the user.
39
49
  * Any device change or mute/unmute will be carried across to join.
40
50
  */
41
- export declare const usePreview: ({ name, token, metadata, handleError, }: usePreviewInput) => usePreviewResult;
51
+ export declare const usePreviewJoin: ({ name, token, metadata, handleError, initEndpoint, initialSettings, }: usePreviewInput) => usePreviewResult;
@@ -0,0 +1,10 @@
1
+ export interface useRecordingStreamingResult {
2
+ isServerRecordingOn: boolean;
3
+ isBrowserRecordingOn: boolean;
4
+ isHLSRecordingOn: boolean;
5
+ isStreamingOn: boolean;
6
+ isHLSRunning: boolean;
7
+ isRTMPRunning: boolean;
8
+ isRecordingOn: boolean;
9
+ }
10
+ export declare const useRecordingStreaming: () => useRecordingStreamingResult;
@@ -0,0 +1,36 @@
1
+ import { HMSTrackID } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from './types';
3
+ export interface useRemoteAVToggleResult {
4
+ /**
5
+ * true if unmuted and vice versa
6
+ */
7
+ isAudioEnabled: boolean;
8
+ isVideoEnabled: boolean;
9
+ /**
10
+ * current volume of the audio track
11
+ */
12
+ volume?: number;
13
+ /**
14
+ * use this function to toggle audio state, the function will only be present if the user
15
+ * has permission to mute/unmute remote audio
16
+ */
17
+ toggleAudio?: () => void;
18
+ /**
19
+ * use this function to toggle video state, the function will only be present if the user
20
+ * has permission to mute/unmute remote video
21
+ */
22
+ toggleVideo?: () => void;
23
+ /**
24
+ * use this function to set the volume of peer's audio track for the local user, the function will
25
+ * only be present if the remote peer has an audio track to change volume for
26
+ */
27
+ setVolume?: (volume: number) => void;
28
+ }
29
+ /**
30
+ * This hook can be used to implement remote mute/unmute + audio volume changer on tile level.
31
+ * @param peerId of the peer whose tracks need to be managed
32
+ * @param audioTrackId of the peer whose tracks need to be managed
33
+ * @param videoTrackId of the peer whose tracks need to be managed
34
+ * @param handleError to handle any error during toggle of audio/video
35
+ */
36
+ export declare const useRemoteAVToggle: (audioTrackId: HMSTrackID, videoTrackId: HMSTrackID, handleError?: hooksErrHandler) => useRemoteAVToggleResult;
@@ -1,9 +1,23 @@
1
1
  import { HMSTrackID } from '@100mslive/hms-video-store';
2
+ import React from 'react';
3
+ export interface useVideoInput {
4
+ /**
5
+ * TrackId that is to be rendered
6
+ */
7
+ trackId?: HMSTrackID;
8
+ /**
9
+ * Boolean stating whether to override the internal behaviour.
10
+ * when attach is false, even if tile is inView or enabled, it won't be rendered
11
+ */
12
+ attach?: boolean;
13
+ }
14
+ export interface useVideoOutput {
15
+ videoRef: React.RefCallback<HTMLVideoElement>;
16
+ }
2
17
  /**
3
18
  * This hooks can be used to implement a video tile component. Given a track id it will return a ref.
4
19
  * The returned ref can be used to set on a video element meant to display the video.
5
20
  * The hook will take care of attaching and detaching video, and will automatically detach when the video
6
21
  * goes out of view to save on bandwidth.
7
- * @param trackId {HMSTrackID}
8
22
  */
9
- export declare const useVideo: (trackId: HMSTrackID) => (node: any) => void;
23
+ export declare const useVideo: ({ trackId, attach }: useVideoInput) => useVideoOutput;
@@ -1,20 +1,34 @@
1
1
  import { HMSPeer } from '@100mslive/hms-video-store';
2
+ import React from 'react';
2
3
  import { TrackWithPeer } from '../utils/layout';
3
- interface UseVideoListProps {
4
+ export interface useVideoListInput {
5
+ /**
6
+ * peers is the list of all peers you need to display
7
+ */
8
+ peers: HMSPeer[];
4
9
  /**
5
10
  * Max tiles in a page. Overrides maxRowCount and maxColCount
6
11
  */
7
12
  maxTileCount?: number;
13
+ /**
14
+ * Max rows in a page. Only applied if maxTileCount is not present
15
+ */
8
16
  maxRowCount?: number;
17
+ /**
18
+ * Max columns in a page. Only applied if maxTileCount and maxRowCount are not present
19
+ */
9
20
  maxColCount?: number;
10
21
  /**
11
- * Given a screensharing peer the function should return true if their screenshare should be included for the video tile, and false otherwise. This can be useful if there are multiple screenshares in the room where you may want to show one in the center view and others in video list along side other tiles.
22
+ * A function which tells whether to show the screenShare for a peer who is screensharing. A peer is passed
23
+ * and a boolean value is expected.
24
+ * This can be useful if there are multiple screenShares in the room where you may want to show the main one in the
25
+ * center view and others in video list along side other tiles. No screenShare is included by default.
26
+ * e.g. includeScreenShare = (peer) => return peer.id !== mainScreenSharingPeer.id
12
27
  */
13
- showScreenFn?: (peer: HMSPeer) => boolean;
14
- peers: HMSPeer[];
15
- overflow?: 'scroll-x' | 'scroll-y' | 'hidden';
28
+ includeScreenShareForPeer?: (peer: HMSPeer) => boolean;
16
29
  /**
17
- * Aspect ratio of VideoTiles
30
+ * Aspect ratio of VideoTiles, ideally this should be the same as the aspect ratio selected for
31
+ * capture in the dashboard template.
18
32
  */
19
33
  aspectRatio?: {
20
34
  width: number;
@@ -22,15 +36,29 @@ interface UseVideoListProps {
22
36
  };
23
37
  /**
24
38
  * By default this will be true. Only publishing(audio/video/screen) peers in the passed in peer list
25
- * will be filtered by default. If you wish to show all peers, pass false for this.
39
+ * will be filtered. If you wish to show all peers, pass false for this.
26
40
  */
27
41
  filterNonPublishingPeers?: boolean;
28
42
  }
29
- export declare const useVideoList: ({ maxTileCount, maxColCount, maxRowCount, showScreenFn, peers, overflow, aspectRatio, filterNonPublishingPeers, }: UseVideoListProps) => {
30
- pagesWithTiles: (TrackWithPeer & {
31
- width: number;
32
- height: number;
33
- })[][];
43
+ export interface useVideoListTile extends TrackWithPeer {
44
+ width: number;
45
+ height: number;
46
+ }
47
+ export interface useVideoResult {
48
+ /**
49
+ * This returns a list of all pages with every page containing the list of all tiles on it.
50
+ */
51
+ pagesWithTiles: useVideoListTile[][];
52
+ /**
53
+ * add the ref to the element going to render the video list, this is used to measure the available
54
+ * space/dimensions in order to calculate the best fit
55
+ */
34
56
  ref: React.MutableRefObject<any>;
35
- };
36
- export {};
57
+ }
58
+ /**
59
+ * This hook can be used to build a paginated gallery view of video tiles. You can give the hook
60
+ * a list of all the peers which need to be shown and it tells you how to structure the UI by giving
61
+ * a list of pages with every page having a list of video tiles.
62
+ * Please check the documentation of input and output types for more details.
63
+ */
64
+ export declare const useVideoList: ({ peers, maxTileCount, maxColCount, maxRowCount, includeScreenShareForPeer, aspectRatio, filterNonPublishingPeers, }: useVideoListInput) => useVideoResult;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- var De=Object.create;var z=Object.defineProperty,Ae=Object.defineProperties,Ve=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,Ne=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var $=(r,e,t)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,L=(r,e)=>{for(var t in e||(e={}))_.call(e,t)&&$(r,t,e[t]);if(Z)for(var t of Z(e))We.call(e,t)&&$(r,t,e[t]);return r},B=(r,e)=>Ae(r,Ce(e)),ee=r=>z(r,"__esModule",{value:!0});var Fe=(r,e)=>{ee(r);for(var t in e)z(r,t,{get:e[t],enumerable:!0})},H=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oe(e))!_.call(r,o)&&o!=="default"&&z(r,o,{get:()=>e[o],enumerable:!(t=Ve(e,o))||t.enumerable});return r},m=r=>H(ee(z(r!=null?De(Ne(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var v=(r,e,t)=>new Promise((o,s)=>{var i=a=>{try{c(t.next(a))}catch(l){s(l)}},n=a=>{try{c(t.throw(a))}catch(l){s(l)}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(i,n);c((t=t.apply(r,e)).next())});Fe(exports,{HMSRoomProvider:()=>ie,throwErrorHandler:()=>ce,useAVToggle:()=>ue,useAudio:()=>ve,useAudioLevelStyles:()=>Re,useDevices:()=>me,useHMSActions:()=>M,useHMSNotifications:()=>ae,useHMSStatsStore:()=>ne,useHMSStore:()=>f,useHMSVanillaStore:()=>A,usePreview:()=>le,useScreenShare:()=>ge,useVideo:()=>fe,useVideoList:()=>Ee});var b=m(require("react")),se=m(require("@100mslive/hms-video-store")),q=m(require("zustand"));var U=m(require("react")),j=m(require("zustand/shallow"));var w;(function(n){n[n.VERBOSE=0]="VERBOSE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.NONE=5]="NONE"})(w||(w={}));var P=class{static v(e,...t){this.log(0,e,...t)}static d(e,...t){this.log(1,e,...t)}static i(e,...t){this.log(2,e,...t)}static w(e,...t){this.log(3,e,...t)}static e(e,...t){this.log(4,e,...t)}static log(e,t,...o){if(!(this.level.valueOf()>e.valueOf()))switch(e){case 0:{console.log("HMSui-components: ",t,...o);break}case 1:{console.debug("HMSui-components: ",t,...o);break}case 2:{console.info("HMSui-components: ",t,...o);break}case 3:{console.warn("HMSui-components: ",t,...o);break}case 4:{console.error("HMSui-components: ",t,...o);break}}}};P.level=0;var R="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function te(r){return(t,o=j.default)=>{t||P.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let s=(0,U.useContext)(r);if(!s)throw new Error(R);return s.store(t,o)}}function oe(r){return(t,o=j.default)=>{t||P.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let s=(0,U.useContext)(r);if(!s)throw new Error(R);let i=s.statsStore;return i==null?void 0:i(t,o)}}var re=typeof window!="undefined";var D=(0,b.createContext)(null),T,ie=({children:r,actions:e,store:t,notifications:o,stats:s,isHMSStatsOn:i=!1})=>{if(!T){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)T={actions:e,store:(0,q.default)(B(L({},t),{setState:n,destroy:n}))},o&&(T.notifications=o),s&&(T.statsStore=(0,q.default)({getState:s.getState,subscribe:s.subscribe,setState:n,destroy:n}));else{let c=new se.HMSReactiveStore;if(T={actions:c.getActions(),store:(0,q.default)(B(L({},c.getStore()),{setState:n,destroy:n})),notifications:c.getNotifications()},i){let a=c.getStats();T.statsStore=(0,q.default)({getState:a.getState,subscribe:a.subscribe,setState:n,destroy:n})}}}return(0,b.useEffect)(()=>{re&&(window.addEventListener("beforeunload",()=>T.actions.leave()),window.addEventListener("onunload",()=>T.actions.leave()))},[]),b.default.createElement(D.Provider,{value:T},r)},f=te(D),ne=oe(D),A=()=>{let r=(0,b.useContext)(D);if(!r)throw new Error(R);return r.store},M=()=>{let r=(0,b.useContext)(D);if(!r)throw new Error(R);return r.actions},ae=()=>{let r=(0,b.useContext)(D),[e,t]=(0,b.useState)(null);if(!r)throw new Error(R);return(0,b.useEffect)(()=>r.notifications?r.notifications.onNotification(s=>t(s)):void 0,[r.notifications]),e};var E=m(require("@100mslive/hms-video-store")),C=m(require("react"));var ze="react-sdk",V=(r,e)=>P.e(ze,e,r),ce=r=>{throw r};var le=({name:r="",token:e,metadata:t,handleError:o=V})=>{let s=M(),i=f(E.selectRoomState),n=f(E.selectIsConnectedToRoom)||!1,c=i===E.HMSRoomState.Preview,a=(0,C.useMemo)(()=>({userName:r,authToken:e,metaData:t,rememberDeviceSelection:!0}),[r,e,t]);(0,C.useEffect)(()=>{(()=>v(void 0,null,function*(){if(!!e){i!==E.HMSRoomState.Disconnected&&(yield s.leave());try{yield s.preview(a)}catch(u){o(u,"preview")}}}))()},[s,e]);let l=(0,C.useCallback)(()=>v(void 0,null,function*(){if(!!e)try{yield s.join(a)}catch(u){o(u,"join")}}),[s,e]);return{enableJoin:c,join:l,isConnected:n}};var O=m(require("@100mslive/hms-video-store")),J=m(require("react"));var ue=(r=V)=>{let e=f(O.selectIsLocalAudioEnabled),t=f(O.selectIsLocalVideoEnabled),o=f(O.selectIsAllowedToPublish),s=M(),i=(0,J.useCallback)(()=>v(void 0,null,function*(){try{yield s.setLocalAudioEnabled(!e)}catch(c){r(c,"toggleAudio")}}),[e,s]),n=(0,J.useCallback)(()=>v(void 0,null,function*(){try{yield s.setLocalVideoEnabled(!t)}catch(c){r(c,"toggleVideo")}}),[t,s]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:t,toggleAudio:(o==null?void 0:o.audio)?i:void 0,toggleVideo:(o==null?void 0:o.video)?n:void 0}};var N=m(require("@100mslive/hms-video-store")),de=m(require("react"));var k;(function(o){o.videoInput="videoInput",o.audioInput="audioInput",o.audioOutput="audioOutput"})(k||(k={}));var me=(r=V)=>{let e=M(),t=f(N.selectDevices),o=f(N.selectLocalMediaSettings),s=f(N.selectIsAllowedToPublish),i={[k.audioInput]:o.audioInputDeviceId,[k.audioOutput]:o.audioOutputDeviceId,[k.videoInput]:o.videoInputDeviceId};s.video||(delete t[k.videoInput],delete i[k.videoInput]),s.audio||(delete t[k.audioInput],delete i[k.audioInput]);let n=(0,de.useCallback)(l=>v(void 0,[l],function*({deviceType:c,deviceId:a}){try{switch(c){case k.audioInput:yield e.setAudioSettings({deviceId:a});break;case k.videoInput:yield e.setVideoSettings({deviceId:a});break;case k.audioOutput:yield e.setAudioOutputDevice(a);break}}catch(u){r(u,"updateDevices")}}),[e]);return{allDevices:t,selectedDeviceIDs:i,updateDevice:n}};var he=m(require("@100mslive/hms-video-store")),I=m(require("react")),Se=m(require("react-intersection-observer"));var fe=r=>{let e=M(),t=(0,I.useRef)(null),o=f((0,he.selectTrackByID)(r)),{ref:s,inView:i}=(0,Se.useInView)({threshold:.5}),n=(0,I.useCallback)(c=>{t.current=c,s(c)},[s]);return(0,I.useEffect)(()=>{(()=>v(void 0,null,function*(){t.current&&o&&(i?o.enabled?yield e.attachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current))}))()},[i,t,o==null?void 0:o.id,o==null?void 0:o.enabled,o==null?void 0:o.deviceID,o==null?void 0:o.plugins]),(0,I.useEffect)(()=>()=>{(()=>v(void 0,null,function*(){if(t.current&&o)try{yield e.detachVideo(o.id,t.current)}catch(c){P.w("detach video error for track",o.id,c)}}))()},[]),n};var W=m(require("@100mslive/hms-video-store"));var pe=m(require("react")),Le=r=>console.log("Error: ",r),ge=(r=Le)=>{var n,c;let e=M(),t=f(W.selectIsLocalScreenShared),o=f(W.selectPeerScreenSharing),s=f((0,W.selectScreenSharesByPeerId)(o==null?void 0:o.id)),i=(0,pe.useCallback)(()=>v(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t)}catch(a){r(a)}}),[e]);return{amIScreenSharing:t,screenSharingPeerId:o==null?void 0:o.id,screenShareVideoTrackId:(n=s==null?void 0:s.video)==null?void 0:n.id,screenShareAudioTrackId:(c=s==null?void 0:s.audio)==null?void 0:c.id,toggleScreenShare:i}};var He=m(require("@100mslive/hms-video-store"));var Me=m(require("react")),ve=r=>{let e=M(),t=f((0,He.selectAudioTrackVolume)(r)),o=(0,Me.useCallback)(s=>{e.setVolume(s,r)},[e]);return{volume:t,setVolume:o}};var Te=m(require("@100mslive/hms-video-store")),G=m(require("react"));var Be=(r,e,t)=>r.reduce((o,s,i)=>{let n=Math.floor(i/e);return n>0&&t||(o[n]||(o[n]=[]),o[n].push(s)),o},[]),we=({elements:r,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:o,defaultWidth:s,defaultHeight:i,lastPageWidth:n,lastPageHeight:c})=>{let a=Be(r,e,t);return a.map((l,u)=>l.map(S=>{let d=u===a.length-1,h=o&&d?n:s,p=o&&d?c:i;return B(L({},S),{height:p,width:h})}))};function qe(r){if(r.length===0)return null;let e={},t=r[0],o=1;for(let s=0;s<r.length;s++){let i=r[s];e[i]===null?e[i]=1:e[i]++,e[i]>o&&(t=i,o=e[i])}return t}var be=r=>qe(r.filter(e=>{var t,o;return((t=e.track)==null?void 0:t.width)&&((o=e.track)==null?void 0:o.height)}).map(e=>{var s,i;let t=(s=e.track)==null?void 0:s.width,o=(i=e.track)==null?void 0:i.height;return(t||1)/(o||1)})),K=(r,e,t,o,s)=>{if(r<0||e<0)throw new Error("Container must have a non-negative area");if(t<1||!Number.isInteger(t))throw new Error("Number of shapes to place must be a positive integer");let i=o&&s&&o/s;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},c=t,a=-1;if(i!==void 0)for(let l=c;l>0;l+=a){let u=Math.ceil(t/l),S=r/(l*i),d=e/u,h,p;S<=d?(h=r/l,p=h/i):(p=e/u,h=p*i);let g=h*p;g>n.area&&(n={area:g,width:h,height:p,rows:u,cols:l})}return n},Ge=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,S=0,d=Math.min(Math.ceil(Math.sqrt(t*(r/e)/(s.width/s.height))),o),h=r/d,p=h/(s.width/s.height),g=Math.floor(e/p);if(n=p,i=h,u=Math.min(t,g*d),S=t%(g*d),l=S>0&&t>g*d,l){let y=Math.min(Math.ceil(Math.sqrt(S*(r/e)/(s.width/s.height))),o),x=r/y;a=x/(s.width/s.height),c=x}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}},Ue=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,S=0,{width:d,height:h}=K(r,e,Math.min(t,o),s.width,s.height);if(i=d,n=h,u=Math.min(t,o),S=t%o,l=S>0&&t>o,l){let{width:p,height:g}=K(r,e,S,s.width,s.height);c=p,a=g}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}},je=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,S=0,d=Math.min(Math.ceil(Math.sqrt(t*(s.width/s.height)/(r/e))),o),h=e/d,p=h*(s.width/s.height),g=Math.floor(r/p);if(i=p,n=h,u=Math.min(t,d*g),S=t%(d*g),l=S>0&&t>d*g,l){let y=Math.min(Math.ceil(Math.sqrt(S*(s.width/s.height)/(r/e))),o),x=e/y,F=x*(s.width/s.height);a=x,c=F}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}};function ke({count:r,parentWidth:e,parentHeight:t,maxTileCount:o,maxRowCount:s,maxColCount:i,aspectRatio:n}){let c=0,a=0,l=0,u=0,S=!1,d=0;if(r===0)return{tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:S};if(o)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:S}=Ue({parentWidth:e,parentHeight:t,count:r,maxCount:o,aspectRatio:n}));else if(s)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:S}=je({parentWidth:e,parentHeight:t,count:r,maxCount:s,aspectRatio:n}));else if(i)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:S}=Ge({parentWidth:e,parentHeight:t,count:r,maxCount:i,aspectRatio:n}));else{let{width:h,height:p}=K(e,t,r,n.width,n.height);c=h,a=p,d=r}return{tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:S}}var Pe=(r,e,t,o=!0)=>{if(!r||!e||!t)return[];let s=[];for(let i of r)if(i.videoTrack===void 0&&i.audioTrack&&e[i.audioTrack])s.push({peer:i});else if(i.videoTrack&&e[i.videoTrack])s.push({track:e[i.videoTrack],peer:i});else if(t(i)&&i.auxiliaryTracks.length>0){let n=i.auxiliaryTracks.find(c=>{let a=e[c];return(a==null?void 0:a.type)==="video"&&(a==null?void 0:a.source)==="screen"});n&&s.push({track:e[n],peer:i})}else o||s.push({peer:i});return s};var xe=m(require("react-resize-detector")),Je={aspectRatio:{width:1,height:1}},Ee=({maxTileCount:r,maxColCount:e,maxRowCount:t,showScreenFn:o=()=>!1,peers:s,overflow:i="scroll-x",aspectRatio:n=Je.aspectRatio,filterNonPublishingPeers:c=!0})=>{let{width:a=0,height:l=0,ref:u}=(0,xe.useResizeDetector)(),d=A().getState(Te.selectTracksMap),h=Pe(s,d,o,c),p=(0,G.useMemo)(()=>n||{width:be(h)||1,height:1},[n,h]),g=h.length,{tilesInFirstPage:y,defaultWidth:x,defaultHeight:F,lastPageWidth:Q,lastPageHeight:X,isLastPageDifferentFromFirstPage:Y}=(0,G.useMemo)(()=>ke({count:g,parentWidth:Math.floor(a),parentHeight:Math.floor(l),maxTileCount:r,maxRowCount:t,maxColCount:e,aspectRatio:p}),[g,a,l,r,t,e,p]);return{pagesWithTiles:(0,G.useMemo)(()=>we({elements:h,tilesInFirstPage:y,onlyOnePage:i==="hidden",isLastPageDifferentFromFirstPage:Y,defaultWidth:x,defaultHeight:F,lastPageWidth:Q,lastPageHeight:X}),[h,y,i,Y,x,F,Q,X]),ref:u}};var Ie=m(require("react")),ye=m(require("@100mslive/hms-video-store"));function Re({trackId:r,getStyle:e,ref:t}){let o=A();(0,Ie.useEffect)(()=>o.subscribe(s=>{if(!t.current)return;let i=e(s);for(let n in i)t.current.style[n]=i[n]},(0,ye.selectTrackAudioByID)(r)),[r])}H(exports,m(require("@100mslive/hms-video-store")));
1
+ var Fe=Object.create;var q=Object.defineProperty,Be=Object.defineProperties,ze=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,je=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var se=(o,e,t)=>e in o?q(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,G=(o,e)=>{for(var t in e||(e={}))re.call(e,t)&&se(o,t,e[t]);if(oe)for(var t of oe(e))Ue.call(e,t)&&se(o,t,e[t]);return o},j=(o,e)=>Be(o,qe(e)),ie=o=>q(o,"__esModule",{value:!0});var Je=(o,e)=>{ie(o);for(var t in e)q(o,t,{get:e[t],enumerable:!0})},H=(o,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ge(e))!re.call(o,s)&&s!=="default"&&q(o,s,{get:()=>e[s],enumerable:!(t=ze(e,s))||t.enumerable});return o},f=o=>H(ie(q(o!=null?Fe(je(o)):{},"default",o&&o.__esModule&&"default"in o?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var p=(o,e,t)=>new Promise((s,r)=>{var i=c=>{try{a(t.next(c))}catch(u){r(u)}},n=c=>{try{a(t.throw(c))}catch(u){r(u)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(i,n);a((t=t.apply(o,e)).next())});Je(exports,{DeviceType:()=>k,HMSRoomProvider:()=>le,throwErrorHandler:()=>me,useAVToggle:()=>fe,useAudioLevelStyles:()=>Ae,useAutoplayError:()=>We,useDevices:()=>De,useHMSActions:()=>M,useHMSNotifications:()=>K,useHMSStatsStore:()=>de,useHMSStore:()=>d,useHMSVanillaStore:()=>L,useParticipantList:()=>Le,usePreviewJoin:()=>Se,useRecordingStreaming:()=>Ne,useRemoteAVToggle:()=>be,useScreenShare:()=>Me,useVideo:()=>pe,useVideoList:()=>Te});var P=f(require("react")),ue=f(require("@100mslive/hms-video-store")),U=f(require("zustand"));var Y=f(require("react")),Z=f(require("zustand/shallow"));var b;(function(n){n[n.VERBOSE=0]="VERBOSE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.NONE=5]="NONE"})(b||(b={}));var w=class{static v(e,...t){this.log(0,e,...t)}static d(e,...t){this.log(1,e,...t)}static i(e,...t){this.log(2,e,...t)}static w(e,...t){this.log(3,e,...t)}static e(e,...t){this.log(4,e,...t)}static log(e,t,...s){if(!(this.level.valueOf()>e.valueOf()))switch(e){case 0:{console.log("HMSui-components: ",t,...s);break}case 1:{console.debug("HMSui-components: ",t,...s);break}case 2:{console.info("HMSui-components: ",t,...s);break}case 3:{console.warn("HMSui-components: ",t,...s);break}case 4:{console.error("HMSui-components: ",t,...s);break}}}};w.level=0;var C="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function ne(o){return(t,s=Z.default)=>{t||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Y.useContext)(o);if(!r)throw new Error(C);return r.store(t,s)}}function ae(o){return(t,s=Z.default)=>{t||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Y.useContext)(o);if(!r)throw new Error(C);let i=r.statsStore;return i==null?void 0:i(t,s)}}var ce=typeof window!="undefined";var O=(0,P.createContext)(null),y,le=({children:o,actions:e,store:t,notifications:s,stats:r,isHMSStatsOn:i=!1})=>{if(!y){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)y={actions:e,store:(0,U.default)(j(G({},t),{setState:n,destroy:n}))},s&&(y.notifications=s),r&&(y.statsStore=(0,U.default)({getState:r.getState,subscribe:r.subscribe,setState:n,destroy:n}));else{let a=new ue.HMSReactiveStore;if(y={actions:a.getActions(),store:(0,U.default)(j(G({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let c=a.getStats();y.statsStore=(0,U.default)({getState:c.getState,subscribe:c.subscribe,setState:n,destroy:n})}}}return(0,P.useEffect)(()=>{ce&&(window.addEventListener("beforeunload",()=>y.actions.leave()),window.addEventListener("onunload",()=>y.actions.leave()))},[]),P.default.createElement(O.Provider,{value:y},o)},d=ne(O),de=ae(O),L=()=>{let o=(0,P.useContext)(O);if(!o)throw new Error(C);return o.store},M=()=>{let o=(0,P.useContext)(O);if(!o)throw new Error(C);return o.actions},K=()=>{let o=(0,P.useContext)(O),[e,t]=(0,P.useState)(null);if(!o)throw new Error(C);return(0,P.useEffect)(()=>o.notifications?o.notifications.onNotification(r=>t(r)):void 0,[o.notifications]),e};var E=f(require("@100mslive/hms-video-store")),J=f(require("react"));var Ke="react-sdk",T=(o,e)=>w.e(Ke,e,o),me=o=>{throw o};var Se=({name:o="",token:e,metadata:t,handleError:s=T,initEndpoint:r,initialSettings:i})=>{let n=M(),a=d(E.selectRoomState),c=d(E.selectIsConnectedToRoom)||!1,u=a===E.HMSRoomState.Preview,S=(0,J.useMemo)(()=>({userName:o,authToken:e,metaData:t,rememberDeviceSelection:!0,settings:i,initEndpoint:r}),[o,e,t,r,i]),m=(0,J.useCallback)(()=>{(()=>p(void 0,null,function*(){if(!!e){a!==E.HMSRoomState.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(h){s(h,"preview")}}}))()},[n,s,e,a,S]),l=(0,J.useCallback)(()=>{if(!!e)try{n.join(S)}catch(h){s(h,"join")}},[n,S,s,e]);return{enableJoin:u,join:l,isConnected:c,preview:m}};var N=f(require("@100mslive/hms-video-store")),_=f(require("react"));var fe=(o=T)=>{let e=d(N.selectIsLocalAudioEnabled),t=d(N.selectIsLocalVideoEnabled),s=d(N.selectIsAllowedToPublish),r=M(),i=(0,_.useCallback)(()=>p(void 0,null,function*(){try{yield r.setLocalAudioEnabled(!e)}catch(a){o(a,"toggleAudio")}}),[r,e,o]),n=(0,_.useCallback)(()=>p(void 0,null,function*(){try{yield r.setLocalVideoEnabled(!t)}catch(a){o(a,"toggleVideo")}}),[r,t,o]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:t,toggleAudio:(s==null?void 0:s.audio)?i:void 0,toggleVideo:(s==null?void 0:s.video)?n:void 0}};var he=f(require("@100mslive/hms-video-store")),A=f(require("react")),ge=f(require("react-intersection-observer"));var pe=({trackId:o,attach:e})=>{let t=M(),s=(0,A.useRef)(null),r=d((0,he.selectTrackByID)(o)),{ref:i,inView:n}=(0,ge.useInView)({threshold:.5}),a=(0,A.useCallback)(c=>{s.current=c,i(c)},[i]);return(0,A.useEffect)(()=>{(()=>p(void 0,null,function*(){s.current&&(r==null?void 0:r.id)&&(n&&r.enabled&&e!==!1?yield t.attachVideo(r.id,s.current):yield t.detachVideo(r.id,s.current))}))()},[t,n,s,r==null?void 0:r.id,r==null?void 0:r.enabled,r==null?void 0:r.deviceID,r==null?void 0:r.plugins,e]),(0,A.useEffect)(()=>()=>{(()=>p(void 0,null,function*(){if(s.current&&r)try{yield t.detachVideo(r.id,s.current)}catch(c){w.w("detach video error for track",r.id,c)}}))()},[]),{videoRef:a}};var W=f(require("@100mslive/hms-video-store"));var He=f(require("react")),Qe=o=>console.log("Error: ",o),Me=(o=Qe)=>{var n,a;let e=M(),t=d(W.selectIsLocalScreenShared),s=d(W.selectPeerScreenSharing),r=d((0,W.selectScreenSharesByPeerId)(s==null?void 0:s.id)),i=(0,He.useCallback)((c=!1)=>p(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t,c)}catch(u){o(u)}}),[e,t,o]);return{amIScreenSharing:t,screenSharingPeerId:s==null?void 0:s.id,screenShareVideoTrackId:(n=r==null?void 0:r.video)==null?void 0:n.id,screenShareAudioTrackId:(a=r==null?void 0:r.audio)==null?void 0:a.id,toggleScreenShare:i}};var V=f(require("@100mslive/hms-video-store"));var Q=f(require("react"));var ve=(o,e,t)=>p(void 0,null,function*(){if(e)try{yield o.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){t(s,"remoteToggle")}}),be=(o,e,t=T)=>{let s=M(),r=d((0,V.selectTrackByID)(o)),i=d((0,V.selectTrackByID)(e)),n=d((0,V.selectAudioTrackVolume)(r==null?void 0:r.id)),a=d(V.selectPermissions),c=(i==null?void 0:i.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,u=(r==null?void 0:r.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,S=(0,Q.useCallback)(()=>p(void 0,null,function*(){yield ve(s,r,t)}),[s,r,t]),m=(0,Q.useCallback)(()=>p(void 0,null,function*(){yield ve(s,i,t)}),[s,t,i]),l=(0,Q.useCallback)(h=>{r&&s.setVolume(h,r.id)},[s,r]);return{isAudioEnabled:!!(r==null?void 0:r.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:r&&u?S:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&c?m:void 0,setVolume:r?l:void 0}};var xe=f(require("@100mslive/hms-video-store")),X=f(require("react"));var Xe=(o,e,t)=>o.reduce((s,r,i)=>{let n=Math.floor(i/e);return n>0&&t||(s[n]||(s[n]=[]),s[n].push(r)),s},[]),Pe=({elements:o,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:s,defaultWidth:r,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let c=Xe(o,e,t);return c.map((u,S)=>u.map(m=>{let l=S===c.length-1,h=s&&l?n:r,g=s&&l?a:i;return j(G({},m),{height:g,width:h})}))};function Ye(o){if(o.length===0)return null;let e={},t=o[0],s=1;for(let r=0;r<o.length;r++){let i=o[r];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(t=i,s=e[i])}return t}var ke=o=>Ye(o.filter(e=>{var t,s;return((t=e.track)==null?void 0:t.width)&&((s=e.track)==null?void 0:s.height)}).map(e=>{var r,i;let t=(r=e.track)==null?void 0:r.width,s=(i=e.track)==null?void 0:i.height;return(t||1)/(s||1)})),$=(o,e,t,s,r)=>{if(o<0||e<0)throw new Error("Container must have a non-negative area");if(t<1||!Number.isInteger(t))throw new Error("Number of shapes to place must be a positive integer");let i=s&&r&&s/r;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},a=t,c=-1;if(i!==void 0)for(let u=a;u>0;u+=c){let S=Math.ceil(t/u),m=o/(u*i),l=e/S,h,g;m<=l?(h=o/u,g=h/i):(g=e/S,h=g*i);let v=h*g;v>n.area&&(n={area:v,width:h,height:g,rows:S,cols:u})}return n},Ze=({parentWidth:o,parentHeight:e,count:t,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,l=Math.min(Math.ceil(Math.sqrt(t*(o/e)/(r.width/r.height))),s),h=o/l,g=h/(r.width/r.height);g>e&&(g=e,h=g/(r.height/r.width));let v=Math.floor(e/g);if(n=g,i=h,S=Math.min(t,v*l),m=t%(v*l),u=m>0&&t>v*l,u){let D=Math.min(Math.ceil(Math.sqrt(m*(o/e)/(r.width/r.height))),s),R=o/D,x=R/(r.width/r.height);x>e&&(x=e,R=x/(r.height/r.width)),c=x,a=R}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},_e=({parentWidth:o,parentHeight:e,count:t,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,{width:l,height:h}=$(o,e,Math.min(t,s),r.width,r.height);if(i=l,n=h,S=Math.min(t,s),m=t%s,u=m>0&&t>s,u){let{width:g,height:v}=$(o,e,m,r.width,r.height);a=g,c=v}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},$e=({parentWidth:o,parentHeight:e,count:t,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,l=Math.min(Math.ceil(Math.sqrt(t*(r.width/r.height)/(o/e))),s),h=e/l,g=h*(r.width/r.height),v=Math.floor(o/g);if(i=g,n=h,S=Math.min(t,l*v),m=t%(l*v),u=m>0&&t>l*v,u){let D=Math.min(Math.ceil(Math.sqrt(m*(r.width/r.height)/(o/e))),s),R=e/D,x=R*(r.width/r.height);c=R,a=x}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}};function we({count:o,parentWidth:e,parentHeight:t,maxTileCount:s,maxRowCount:r,maxColCount:i,aspectRatio:n}){let a=0,c=0,u=0,S=0,m=!1,l=0;if(o===0)return{tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m};if(s)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=_e({parentWidth:e,parentHeight:t,count:o,maxCount:s,aspectRatio:n}));else if(r)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=$e({parentWidth:e,parentHeight:t,count:o,maxCount:r,aspectRatio:n}));else if(i)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=Ze({parentWidth:e,parentHeight:t,count:o,maxCount:i,aspectRatio:n}));else{let{width:h,height:g}=$(e,t,o,n.width,n.height);a=h,c=g,l=o}return{tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}}var Re=(o,e,t,s=!0)=>{if(!o||!e||!t)return[];let r=[];for(let i of o)if(i.videoTrack===void 0&&i.audioTrack&&e[i.audioTrack]?r.push({peer:i}):i.videoTrack&&e[i.videoTrack]?r.push({track:e[i.videoTrack],peer:i}):s||r.push({peer:i}),t(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(c=>{let u=e[c];return(u==null?void 0:u.type)==="video"&&(u==null?void 0:u.source)==="screen"});a&&r.push({track:e[a],peer:i})}return r};var ye=f(require("react-resize-detector")),et={aspectRatio:{width:1,height:1}},Te=({peers:o,maxTileCount:e,maxColCount:t,maxRowCount:s,includeScreenShareForPeer:r=()=>!1,aspectRatio:i=et.aspectRatio,filterNonPublishingPeers:n=!0})=>{let{width:a=0,height:c=0,ref:u}=(0,ye.useResizeDetector)(),m=L().getState(xe.selectTracksMap),l=Re(o,m,r,n),h=(0,X.useMemo)(()=>i||{width:ke(l)||1,height:1},[i,l]),g=l.length,{tilesInFirstPage:v,defaultWidth:D,defaultHeight:R,lastPageWidth:x,lastPageHeight:ee,isLastPageDifferentFromFirstPage:te}=(0,X.useMemo)(()=>we({count:g,parentWidth:Math.floor(a),parentHeight:Math.floor(c),maxTileCount:e,maxRowCount:s,maxColCount:t,aspectRatio:h}),[g,a,c,e,s,t,h]);return{pagesWithTiles:(0,X.useMemo)(()=>Pe({elements:l,tilesInFirstPage:v,onlyOnePage:!1,isLastPageDifferentFromFirstPage:te,defaultWidth:D,defaultHeight:R,lastPageWidth:x,lastPageHeight:ee}),[l,v,te,D,R,x,ee]),ref:u}};var Ie=f(require("react")),Ee=f(require("@100mslive/hms-video-store"));function Ae({trackId:o,getStyle:e,ref:t}){let s=L();(0,Ie.useEffect)(()=>s.subscribe(r=>{if(!t.current)return;let i=e(r);for(let n in i)t.current.style[n]=i[n]},(0,Ee.selectTrackAudioByID)(o)),[e,t,s,o])}var F=f(require("@100mslive/hms-video-store")),Ve=f(require("react"));var k;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(k||(k={}));var De=(o=T)=>{let e=M(),t=d(F.selectDevices),s=d(F.selectLocalMediaSettings),r=d(F.selectIsAllowedToPublish),i={[k.audioOutput]:s.audioOutputDeviceId},n={[k.audioOutput]:t.audioOutput};r.video&&(n[k.videoInput]=t.videoInput,i[k.videoInput]=s.videoInputDeviceId),r.audio&&(n[k.audioInput]=t.audioInput,i[k.audioInput]=s.audioInputDeviceId);let a=(0,Ve.useCallback)(S=>p(void 0,[S],function*({deviceType:c,deviceId:u}){try{switch(c){case k.audioInput:yield e.setAudioSettings({deviceId:u});break;case k.videoInput:yield e.setVideoSettings({deviceId:u});break;case k.audioOutput:e.setAudioOutputDevice(u);break}}catch(m){o(m,"updateDevices")}}),[o,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};var Oe=f(require("react")),I=f(require("@100mslive/hms-video-store"));var Ce=o=>!o||!Array.isArray(o)||o.length===0?{}:o.reduce((e,t)=>(t.roleName&&(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t)),e),{});var Le=()=>{let o=d(I.selectIsConnectedToRoom),e=d(o?I.selectPeers:I.selectRemotePeers),t=d(I.selectPeerCount),s=(0,Oe.useMemo)(()=>Ce(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:t,isConnected:o}};var B=f(require("@100mslive/hms-video-store"));var Ne=()=>{let o=d(B.selectRecordingState),e=d(B.selectRTMPState),t=d(B.selectHLSState),s=o.server.running,r=o.browser.running,i=o.hls.running,n=t.running||e.running,a=s||r||i;return{isServerRecordingOn:s,isBrowserRecordingOn:r,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:t.running,isRTMPRunning:e.running,isRecordingOn:a}};var z=f(require("react"));var We=()=>{let o=K(),[e,t]=(0,z.useState)(""),s=M(),r=(0,z.useCallback)(()=>p(void 0,null,function*(){yield s.unblockAudio()}),[s]);return(0,z.useEffect)(()=>{var i,n;((i=o==null?void 0:o.data)==null?void 0:i.code)===3008&&t((n=o==null?void 0:o.data)==null?void 0:n.message)},[o]),{error:e,unblockAudio:r,resetError:()=>t("")}};H(exports,f(require("@100mslive/hms-video-store")));
package/dist/index.d.ts CHANGED
@@ -1,16 +1,25 @@
1
1
  export { HMSRoomProvider, useHMSStore, useHMSActions, useHMSNotifications, useHMSVanillaStore, useHMSStatsStore, } from './primitives/HmsRoomProvider';
2
- export { usePreview } from './hooks/usePreview';
2
+ export { usePreviewJoin } from './hooks/usePreviewJoin';
3
3
  export { useAVToggle } from './hooks/useAVToggle';
4
- export { useDevices } from './hooks/useDevices';
5
4
  export { useVideo } from './hooks/useVideo';
6
5
  export { useScreenShare } from './hooks/useScreenShare';
7
- export { useAudio } from './hooks/useAudio';
6
+ export { useRemoteAVToggle } from './hooks/useRemoteAVToggle';
8
7
  export { useVideoList } from './hooks/useVideoList';
9
8
  export { useAudioLevelStyles } from './hooks/useAudioLevelStyles';
10
- export * from '@100mslive/hms-video-store';
9
+ export { useDevices, DeviceType } from './hooks/useDevices';
10
+ export { useParticipantList } from './hooks/useParticipantList';
11
+ export { useRecordingStreaming } from './hooks/useRecordingStreaming';
12
+ export { useAutoplayError } from './hooks/useAutoplayError';
11
13
  export type { hooksErrHandler } from './hooks/types';
12
- export type { usePreviewInput, usePreviewResult } from './hooks/usePreview';
14
+ export type { usePreviewInput, usePreviewResult } from './hooks/usePreviewJoin';
15
+ export type { useVideoListInput, useVideoResult, useVideoListTile } from './hooks/useVideoList';
13
16
  export type { useAVToggleResult } from './hooks/useAVToggle';
14
17
  export type { useDevicesResult } from './hooks/useDevices';
15
18
  export type { useScreenShareResult } from './hooks/useScreenShare';
19
+ export type { useRemoteAVToggleResult } from './hooks/useRemoteAVToggle';
20
+ export type { useRecordingStreamingResult } from './hooks/useRecordingStreaming';
21
+ export type { useParticipantListResult } from './hooks/useParticipantList';
22
+ export type { useVideoInput, useVideoOutput } from './hooks/useVideo';
23
+ export type { useAutoplayErrorResult } from './hooks/useAutoplayError';
16
24
  export { throwErrorHandler } from './utils/commons';
25
+ export * from '@100mslive/hms-video-store';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var ee=Object.defineProperty,te=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var L=(r,t,e)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,y=(r,t)=>{for(var e in t||(t={}))re.call(t,e)&&L(r,e,t[e]);if(z)for(var e of z(t))se.call(t,e)&&L(r,e,t[e]);return r},R=(r,t)=>te(r,oe(t));var g=(r,t,e)=>new Promise((o,s)=>{var i=a=>{try{c(e.next(a))}catch(l){s(l)}},n=a=>{try{c(e.throw(a))}catch(l){s(l)}},c=a=>a.done?o(a.value):Promise.resolve(a.value).then(i,n);c((e=e.apply(r,t)).next())});import ie,{createContext as ne,useContext as V,useEffect as J,useState as ae}from"react";import{HMSReactiveStore as ce}from"@100mslive/hms-video-store";import A from"zustand";import{useContext as B}from"react";import q from"zustand/shallow";var H;(function(n){n[n.VERBOSE=0]="VERBOSE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.NONE=5]="NONE"})(H||(H={}));var w=class{static v(t,...e){this.log(0,t,...e)}static d(t,...e){this.log(1,t,...e)}static i(t,...e){this.log(2,t,...e)}static w(t,...e){this.log(3,t,...e)}static e(t,...e){this.log(4,t,...e)}static log(t,e,...o){if(!(this.level.valueOf()>t.valueOf()))switch(t){case 0:{console.log("HMSui-components: ",e,...o);break}case 1:{console.debug("HMSui-components: ",e,...o);break}case 2:{console.info("HMSui-components: ",e,...o);break}case 3:{console.warn("HMSui-components: ",e,...o);break}case 4:{console.error("HMSui-components: ",e,...o);break}}}};w.level=0;var T="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function G(r){return(e,o=q)=>{e||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let s=B(r);if(!s)throw new Error(T);return s.store(e,o)}}function U(r){return(e,o=q)=>{e||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let s=B(r);if(!s)throw new Error(T);let i=s.statsStore;return i==null?void 0:i(e,o)}}var j=typeof window!="undefined";var x=ne(null),b,le=({children:r,actions:t,store:e,notifications:o,stats:s,isHMSStatsOn:i=!1})=>{if(!b){let n=()=>{throw new Error("modifying store is not allowed")};if(t&&e)b={actions:t,store:A(R(y({},e),{setState:n,destroy:n}))},o&&(b.notifications=o),s&&(b.statsStore=A({getState:s.getState,subscribe:s.subscribe,setState:n,destroy:n}));else{let c=new ce;if(b={actions:c.getActions(),store:A(R(y({},c.getStore()),{setState:n,destroy:n})),notifications:c.getNotifications()},i){let a=c.getStats();b.statsStore=A({getState:a.getState,subscribe:a.subscribe,setState:n,destroy:n})}}}return J(()=>{j&&(window.addEventListener("beforeunload",()=>b.actions.leave()),window.addEventListener("onunload",()=>b.actions.leave()))},[]),ie.createElement(x.Provider,{value:b},r)},f=G(x),ue=U(x),D=()=>{let r=V(x);if(!r)throw new Error(T);return r.store},M=()=>{let r=V(x);if(!r)throw new Error(T);return r.actions},de=()=>{let r=V(x),[t,e]=ae(null);if(!r)throw new Error(T);return J(()=>r.notifications?r.notifications.onNotification(s=>e(s)):void 0,[r.notifications]),t};import{HMSRoomState as K,selectIsConnectedToRoom as Se,selectRoomState as fe}from"@100mslive/hms-video-store";import{useCallback as pe,useEffect as ge,useMemo as He}from"react";var me="react-sdk",E=(r,t)=>w.e(me,t,r),he=r=>{throw r};var Me=({name:r="",token:t,metadata:e,handleError:o=E})=>{let s=M(),i=f(fe),n=f(Se)||!1,c=i===K.Preview,a=He(()=>({userName:r,authToken:t,metaData:e,rememberDeviceSelection:!0}),[r,t,e]);ge(()=>{(()=>g(void 0,null,function*(){if(!!t){i!==K.Disconnected&&(yield s.leave());try{yield s.preview(a)}catch(u){o(u,"preview")}}}))()},[s,t]);let l=pe(()=>g(void 0,null,function*(){if(!!t)try{yield s.join(a)}catch(u){o(u,"join")}}),[s,t]);return{enableJoin:c,join:l,isConnected:n}};import{selectIsAllowedToPublish as ve,selectIsLocalAudioEnabled as we,selectIsLocalVideoEnabled as be}from"@100mslive/hms-video-store";import{useCallback as Q}from"react";var ke=(r=E)=>{let t=f(we),e=f(be),o=f(ve),s=M(),i=Q(()=>g(void 0,null,function*(){try{yield s.setLocalAudioEnabled(!t)}catch(c){r(c,"toggleAudio")}}),[t,s]),n=Q(()=>g(void 0,null,function*(){try{yield s.setLocalVideoEnabled(!e)}catch(c){r(c,"toggleVideo")}}),[e,s]);return{isLocalAudioEnabled:t,isLocalVideoEnabled:e,toggleAudio:(o==null?void 0:o.audio)?i:void 0,toggleVideo:(o==null?void 0:o.video)?n:void 0}};import{selectDevices as Pe,selectIsAllowedToPublish as Te,selectLocalMediaSettings as xe}from"@100mslive/hms-video-store";import{useCallback as Ee}from"react";var v;(function(o){o.videoInput="videoInput",o.audioInput="audioInput",o.audioOutput="audioOutput"})(v||(v={}));var Ie=(r=E)=>{let t=M(),e=f(Pe),o=f(xe),s=f(Te),i={[v.audioInput]:o.audioInputDeviceId,[v.audioOutput]:o.audioOutputDeviceId,[v.videoInput]:o.videoInputDeviceId};s.video||(delete e[v.videoInput],delete i[v.videoInput]),s.audio||(delete e[v.audioInput],delete i[v.audioInput]);let n=Ee(l=>g(void 0,[l],function*({deviceType:c,deviceId:a}){try{switch(c){case v.audioInput:yield t.setAudioSettings({deviceId:a});break;case v.videoInput:yield t.setVideoSettings({deviceId:a});break;case v.audioOutput:yield t.setAudioOutputDevice(a);break}}catch(u){r(u,"updateDevices")}}),[t]);return{allDevices:e,selectedDeviceIDs:i,updateDevice:n}};import{selectTrackByID as ye}from"@100mslive/hms-video-store";import{useCallback as Re,useEffect as X,useRef as De}from"react";import{useInView as Ae}from"react-intersection-observer";var Ve=r=>{let t=M(),e=De(null),o=f(ye(r)),{ref:s,inView:i}=Ae({threshold:.5}),n=Re(c=>{e.current=c,s(c)},[s]);return X(()=>{(()=>g(void 0,null,function*(){e.current&&o&&(i?o.enabled?yield t.attachVideo(o.id,e.current):yield t.detachVideo(o.id,e.current):yield t.detachVideo(o.id,e.current))}))()},[i,e,o==null?void 0:o.id,o==null?void 0:o.enabled,o==null?void 0:o.deviceID,o==null?void 0:o.plugins]),X(()=>()=>{(()=>g(void 0,null,function*(){if(e.current&&o)try{yield t.detachVideo(o.id,e.current)}catch(c){w.w("detach video error for track",o.id,c)}}))()},[]),n};import{selectIsLocalScreenShared as Ce,selectPeerScreenSharing as Oe,selectScreenSharesByPeerId as Ne}from"@100mslive/hms-video-store";import{useCallback as We}from"react";var Fe=r=>console.log("Error: ",r),ze=(r=Fe)=>{var n,c;let t=M(),e=f(Ce),o=f(Oe),s=f(Ne(o==null?void 0:o.id)),i=We(()=>g(void 0,null,function*(){try{yield t.setScreenShareEnabled(!e)}catch(a){r(a)}}),[t]);return{amIScreenSharing:e,screenSharingPeerId:o==null?void 0:o.id,screenShareVideoTrackId:(n=s==null?void 0:s.video)==null?void 0:n.id,screenShareAudioTrackId:(c=s==null?void 0:s.audio)==null?void 0:c.id,toggleScreenShare:i}};import{selectAudioTrackVolume as Le}from"@100mslive/hms-video-store";import{useCallback as Be}from"react";var qe=r=>{let t=M(),e=f(Le(r)),o=Be(s=>{t.setVolume(s,r)},[t]);return{volume:e,setVolume:o}};import{selectTracksMap as Qe}from"@100mslive/hms-video-store";import{useMemo as O}from"react";var Ge=(r,t,e)=>r.reduce((o,s,i)=>{let n=Math.floor(i/t);return n>0&&e||(o[n]||(o[n]=[]),o[n].push(s)),o},[]),Y=({elements:r,tilesInFirstPage:t,onlyOnePage:e,isLastPageDifferentFromFirstPage:o,defaultWidth:s,defaultHeight:i,lastPageWidth:n,lastPageHeight:c})=>{let a=Ge(r,t,e);return a.map((l,u)=>l.map(h=>{let d=u===a.length-1,m=o&&d?n:s,S=o&&d?c:i;return R(y({},h),{height:S,width:m})}))};function Ue(r){if(r.length===0)return null;let t={},e=r[0],o=1;for(let s=0;s<r.length;s++){let i=r[s];t[i]===null?t[i]=1:t[i]++,t[i]>o&&(e=i,o=t[i])}return e}var Z=r=>Ue(r.filter(t=>{var e,o;return((e=t.track)==null?void 0:e.width)&&((o=t.track)==null?void 0:o.height)}).map(t=>{var s,i;let e=(s=t.track)==null?void 0:s.width,o=(i=t.track)==null?void 0:i.height;return(e||1)/(o||1)})),C=(r,t,e,o,s)=>{if(r<0||t<0)throw new Error("Container must have a non-negative area");if(e<1||!Number.isInteger(e))throw new Error("Number of shapes to place must be a positive integer");let i=o&&s&&o/s;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},c=e,a=-1;if(i!==void 0)for(let l=c;l>0;l+=a){let u=Math.ceil(e/l),h=r/(l*i),d=t/u,m,S;h<=d?(m=r/l,S=m/i):(S=t/u,m=S*i);let p=m*S;p>n.area&&(n={area:p,width:m,height:S,rows:u,cols:l})}return n},je=({parentWidth:r,parentHeight:t,count:e,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,h=0,d=Math.min(Math.ceil(Math.sqrt(e*(r/t)/(s.width/s.height))),o),m=r/d,S=m/(s.width/s.height),p=Math.floor(t/S);if(n=S,i=m,u=Math.min(e,p*d),h=e%(p*d),l=h>0&&e>p*d,l){let P=Math.min(Math.ceil(Math.sqrt(h*(r/t)/(s.width/s.height))),o),k=r/P;a=k/(s.width/s.height),c=k}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}},Je=({parentWidth:r,parentHeight:t,count:e,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,h=0,{width:d,height:m}=C(r,t,Math.min(e,o),s.width,s.height);if(i=d,n=m,u=Math.min(e,o),h=e%o,l=h>0&&e>o,l){let{width:S,height:p}=C(r,t,h,s.width,s.height);c=S,a=p}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}},Ke=({parentWidth:r,parentHeight:t,count:e,maxCount:o,aspectRatio:s})=>{let i=0,n=0,c=0,a=0,l=!1,u=0,h=0,d=Math.min(Math.ceil(Math.sqrt(e*(s.width/s.height)/(r/t))),o),m=t/d,S=m*(s.width/s.height),p=Math.floor(r/S);if(i=S,n=m,u=Math.min(e,d*p),h=e%(d*p),l=h>0&&e>d*p,l){let P=Math.min(Math.ceil(Math.sqrt(h*(s.width/s.height)/(r/t))),o),k=t/P,I=k*(s.width/s.height);a=k,c=I}return{tilesInFirstPage:u,defaultWidth:i,defaultHeight:n,lastPageWidth:c,lastPageHeight:a,isLastPageDifferentFromFirstPage:l}};function _({count:r,parentWidth:t,parentHeight:e,maxTileCount:o,maxRowCount:s,maxColCount:i,aspectRatio:n}){let c=0,a=0,l=0,u=0,h=!1,d=0;if(r===0)return{tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:h};if(o)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:h}=Je({parentWidth:t,parentHeight:e,count:r,maxCount:o,aspectRatio:n}));else if(s)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:h}=Ke({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:n}));else if(i)({tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:h}=je({parentWidth:t,parentHeight:e,count:r,maxCount:i,aspectRatio:n}));else{let{width:m,height:S}=C(t,e,r,n.width,n.height);c=m,a=S,d=r}return{tilesInFirstPage:d,defaultWidth:c,defaultHeight:a,lastPageWidth:l,lastPageHeight:u,isLastPageDifferentFromFirstPage:h}}var $=(r,t,e,o=!0)=>{if(!r||!t||!e)return[];let s=[];for(let i of r)if(i.videoTrack===void 0&&i.audioTrack&&t[i.audioTrack])s.push({peer:i});else if(i.videoTrack&&t[i.videoTrack])s.push({track:t[i.videoTrack],peer:i});else if(e(i)&&i.auxiliaryTracks.length>0){let n=i.auxiliaryTracks.find(c=>{let a=t[c];return(a==null?void 0:a.type)==="video"&&(a==null?void 0:a.source)==="screen"});n&&s.push({track:t[n],peer:i})}else o||s.push({peer:i});return s};import{useResizeDetector as Xe}from"react-resize-detector";var Ye={aspectRatio:{width:1,height:1}},Ze=({maxTileCount:r,maxColCount:t,maxRowCount:e,showScreenFn:o=()=>!1,peers:s,overflow:i="scroll-x",aspectRatio:n=Ye.aspectRatio,filterNonPublishingPeers:c=!0})=>{let{width:a=0,height:l=0,ref:u}=Xe(),d=D().getState(Qe),m=$(s,d,o,c),S=O(()=>n||{width:Z(m)||1,height:1},[n,m]),p=m.length,{tilesInFirstPage:P,defaultWidth:k,defaultHeight:I,lastPageWidth:N,lastPageHeight:W,isLastPageDifferentFromFirstPage:F}=O(()=>_({count:p,parentWidth:Math.floor(a),parentHeight:Math.floor(l),maxTileCount:r,maxRowCount:e,maxColCount:t,aspectRatio:S}),[p,a,l,r,e,t,S]);return{pagesWithTiles:O(()=>Y({elements:m,tilesInFirstPage:P,onlyOnePage:i==="hidden",isLastPageDifferentFromFirstPage:F,defaultWidth:k,defaultHeight:I,lastPageWidth:N,lastPageHeight:W}),[m,P,i,F,k,I,N,W]),ref:u}};import{useEffect as _e}from"react";import{selectTrackAudioByID as $e}from"@100mslive/hms-video-store";function et({trackId:r,getStyle:t,ref:e}){let o=D();_e(()=>o.subscribe(s=>{if(!e.current)return;let i=t(s);for(let n in i)e.current.style[n]=i[n]},$e(r)),[r])}export*from"@100mslive/hms-video-store";export{le as HMSRoomProvider,he as throwErrorHandler,ke as useAVToggle,qe as useAudio,et as useAudioLevelStyles,Ie as useDevices,M as useHMSActions,de as useHMSNotifications,ue as useHMSStatsStore,f as useHMSStore,D as useHMSVanillaStore,Me as usePreview,ze as useScreenShare,Ve as useVideo,Ze as useVideoList};
1
+ var ie=Object.defineProperty,ne=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var z=(r,e,o)=>e in r?ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,I=(r,e)=>{for(var o in e||(e={}))ce.call(e,o)&&z(r,o,e[o]);if(B)for(var o of B(e))ue.call(e,o)&&z(r,o,e[o]);return r},E=(r,e)=>ne(r,ae(e));var g=(r,e,o)=>new Promise((s,t)=>{var i=c=>{try{a(o.next(c))}catch(u){t(u)}},n=c=>{try{a(o.throw(c))}catch(u){t(u)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(i,n);a((o=o.apply(r,e)).next())});import le,{createContext as de,useContext as D,useEffect as K,useState as me}from"react";import{HMSReactiveStore as Se}from"@100mslive/hms-video-store";import V from"zustand";import{useContext as q}from"react";import G from"zustand/shallow";var M;(function(n){n[n.VERBOSE=0]="VERBOSE",n[n.DEBUG=1]="DEBUG",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.NONE=5]="NONE"})(M||(M={}));var b=class{static v(e,...o){this.log(0,e,...o)}static d(e,...o){this.log(1,e,...o)}static i(e,...o){this.log(2,e,...o)}static w(e,...o){this.log(3,e,...o)}static e(e,...o){this.log(4,e,...o)}static log(e,o,...s){if(!(this.level.valueOf()>e.valueOf()))switch(e){case 0:{console.log("HMSui-components: ",o,...s);break}case 1:{console.debug("HMSui-components: ",o,...s);break}case 2:{console.info("HMSui-components: ",o,...s);break}case 3:{console.warn("HMSui-components: ",o,...s);break}case 4:{console.error("HMSui-components: ",o,...s);break}}}};b.level=0;var y="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function j(r){return(o,s=G)=>{o||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let t=q(r);if(!t)throw new Error(y);return t.store(o,s)}}function U(r){return(o,s=G)=>{o||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let t=q(r);if(!t)throw new Error(y);let i=t.statsStore;return i==null?void 0:i(o,s)}}var J=typeof window!="undefined";var T=de(null),w,fe=({children:r,actions:e,store:o,notifications:s,stats:t,isHMSStatsOn:i=!1})=>{if(!w){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&o)w={actions:e,store:V(E(I({},o),{setState:n,destroy:n}))},s&&(w.notifications=s),t&&(w.statsStore=V({getState:t.getState,subscribe:t.subscribe,setState:n,destroy:n}));else{let a=new Se;if(w={actions:a.getActions(),store:V(E(I({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let c=a.getStats();w.statsStore=V({getState:c.getState,subscribe:c.subscribe,setState:n,destroy:n})}}}return K(()=>{J&&(window.addEventListener("beforeunload",()=>w.actions.leave()),window.addEventListener("onunload",()=>w.actions.leave()))},[]),le.createElement(T.Provider,{value:w},r)},d=j(T),he=U(T),A=()=>{let r=D(T);if(!r)throw new Error(y);return r.store},H=()=>{let r=D(T);if(!r)throw new Error(y);return r.actions},C=()=>{let r=D(T),[e,o]=me(null);if(!r)throw new Error(y);return K(()=>r.notifications?r.notifications.onNotification(t=>o(t)):void 0,[r.notifications]),e};import{HMSRoomState as Q,selectIsConnectedToRoom as He,selectRoomState as Me}from"@100mslive/hms-video-store";import{useCallback as X,useMemo as ve}from"react";var ge="react-sdk",R=(r,e)=>b.e(ge,e,r),pe=r=>{throw r};var be=({name:r="",token:e,metadata:o,handleError:s=R,initEndpoint:t,initialSettings:i})=>{let n=H(),a=d(Me),c=d(He)||!1,u=a===Q.Preview,S=ve(()=>({userName:r,authToken:e,metaData:o,rememberDeviceSelection:!0,settings:i,initEndpoint:t}),[r,e,o,t,i]),m=X(()=>{(()=>g(void 0,null,function*(){if(!!e){a!==Q.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(f){s(f,"preview")}}}))()},[n,s,e,a,S]),l=X(()=>{if(!!e)try{n.join(S)}catch(f){s(f,"join")}},[n,S,s,e]);return{enableJoin:u,join:l,isConnected:c,preview:m}};import{selectIsAllowedToPublish as Pe,selectIsLocalAudioEnabled as ke,selectIsLocalVideoEnabled as we}from"@100mslive/hms-video-store";import{useCallback as Y}from"react";var Re=(r=R)=>{let e=d(ke),o=d(we),s=d(Pe),t=H(),i=Y(()=>g(void 0,null,function*(){try{yield t.setLocalAudioEnabled(!e)}catch(a){r(a,"toggleAudio")}}),[t,e,r]),n=Y(()=>g(void 0,null,function*(){try{yield t.setLocalVideoEnabled(!o)}catch(a){r(a,"toggleVideo")}}),[t,o,r]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:o,toggleAudio:(s==null?void 0:s.audio)?i:void 0,toggleVideo:(s==null?void 0:s.video)?n:void 0}};import{selectTrackByID as xe}from"@100mslive/hms-video-store";import{useCallback as ye,useEffect as Z,useRef as Te}from"react";import{useInView as Ie}from"react-intersection-observer";var Ee=({trackId:r,attach:e})=>{let o=H(),s=Te(null),t=d(xe(r)),{ref:i,inView:n}=Ie({threshold:.5}),a=ye(c=>{s.current=c,i(c)},[i]);return Z(()=>{(()=>g(void 0,null,function*(){s.current&&(t==null?void 0:t.id)&&(n&&t.enabled&&e!==!1?yield o.attachVideo(t.id,s.current):yield o.detachVideo(t.id,s.current))}))()},[o,n,s,t==null?void 0:t.id,t==null?void 0:t.enabled,t==null?void 0:t.deviceID,t==null?void 0:t.plugins,e]),Z(()=>()=>{(()=>g(void 0,null,function*(){if(s.current&&t)try{yield o.detachVideo(t.id,s.current)}catch(c){b.w("detach video error for track",t.id,c)}}))()},[]),{videoRef:a}};import{selectIsLocalScreenShared as Ae,selectPeerScreenSharing as Ve,selectScreenSharesByPeerId as De}from"@100mslive/hms-video-store";import{useCallback as Ce}from"react";var Oe=r=>console.log("Error: ",r),Le=(r=Oe)=>{var n,a;let e=H(),o=d(Ae),s=d(Ve),t=d(De(s==null?void 0:s.id)),i=Ce((c=!1)=>g(void 0,null,function*(){try{yield e.setScreenShareEnabled(!o,c)}catch(u){r(u)}}),[e,o,r]);return{amIScreenSharing:o,screenSharingPeerId:s==null?void 0:s.id,screenShareVideoTrackId:(n=t==null?void 0:t.video)==null?void 0:n.id,screenShareAudioTrackId:(a=t==null?void 0:t.audio)==null?void 0:a.id,toggleScreenShare:i}};import{selectAudioTrackVolume as Ne,selectPermissions as We,selectTrackByID as _}from"@100mslive/hms-video-store";import{useCallback as O}from"react";var $=(r,e,o)=>g(void 0,null,function*(){if(e)try{yield r.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){o(s,"remoteToggle")}}),Fe=(r,e,o=R)=>{let s=H(),t=d(_(r)),i=d(_(e)),n=d(Ne(t==null?void 0:t.id)),a=d(We),c=(i==null?void 0:i.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,u=(t==null?void 0:t.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,S=O(()=>g(void 0,null,function*(){yield $(s,t,o)}),[s,t,o]),m=O(()=>g(void 0,null,function*(){yield $(s,i,o)}),[s,o,i]),l=O(f=>{t&&s.setVolume(f,t.id)},[s,t]);return{isAudioEnabled:!!(t==null?void 0:t.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:t&&u?S:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&c?m:void 0,setVolume:t?l:void 0}};import{selectTracksMap as Ue}from"@100mslive/hms-video-store";import{useMemo as N}from"react";var Be=(r,e,o)=>r.reduce((s,t,i)=>{let n=Math.floor(i/e);return n>0&&o||(s[n]||(s[n]=[]),s[n].push(t)),s},[]),ee=({elements:r,tilesInFirstPage:e,onlyOnePage:o,isLastPageDifferentFromFirstPage:s,defaultWidth:t,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let c=Be(r,e,o);return c.map((u,S)=>u.map(m=>{let l=S===c.length-1,f=s&&l?n:t,h=s&&l?a:i;return E(I({},m),{height:h,width:f})}))};function ze(r){if(r.length===0)return null;let e={},o=r[0],s=1;for(let t=0;t<r.length;t++){let i=r[t];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(o=i,s=e[i])}return o}var te=r=>ze(r.filter(e=>{var o,s;return((o=e.track)==null?void 0:o.width)&&((s=e.track)==null?void 0:s.height)}).map(e=>{var t,i;let o=(t=e.track)==null?void 0:t.width,s=(i=e.track)==null?void 0:i.height;return(o||1)/(s||1)})),L=(r,e,o,s,t)=>{if(r<0||e<0)throw new Error("Container must have a non-negative area");if(o<1||!Number.isInteger(o))throw new Error("Number of shapes to place must be a positive integer");let i=s&&t&&s/t;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},a=o,c=-1;if(i!==void 0)for(let u=a;u>0;u+=c){let S=Math.ceil(o/u),m=r/(u*i),l=e/S,f,h;m<=l?(f=r/u,h=f/i):(h=e/S,f=h*i);let p=f*h;p>n.area&&(n={area:p,width:f,height:h,rows:S,cols:u})}return n},qe=({parentWidth:r,parentHeight:e,count:o,maxCount:s,aspectRatio:t})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,l=Math.min(Math.ceil(Math.sqrt(o*(r/e)/(t.width/t.height))),s),f=r/l,h=f/(t.width/t.height);h>e&&(h=e,f=h/(t.height/t.width));let p=Math.floor(e/h);if(n=h,i=f,S=Math.min(o,p*l),m=o%(p*l),u=m>0&&o>p*l,u){let x=Math.min(Math.ceil(Math.sqrt(m*(r/e)/(t.width/t.height))),s),P=r/x,k=P/(t.width/t.height);k>e&&(k=e,P=k/(t.height/t.width)),c=k,a=P}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},Ge=({parentWidth:r,parentHeight:e,count:o,maxCount:s,aspectRatio:t})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,{width:l,height:f}=L(r,e,Math.min(o,s),t.width,t.height);if(i=l,n=f,S=Math.min(o,s),m=o%s,u=m>0&&o>s,u){let{width:h,height:p}=L(r,e,m,t.width,t.height);a=h,c=p}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},je=({parentWidth:r,parentHeight:e,count:o,maxCount:s,aspectRatio:t})=>{let i=0,n=0,a=0,c=0,u=!1,S=0,m=0,l=Math.min(Math.ceil(Math.sqrt(o*(t.width/t.height)/(r/e))),s),f=e/l,h=f*(t.width/t.height),p=Math.floor(r/h);if(i=h,n=f,S=Math.min(o,l*p),m=o%(l*p),u=m>0&&o>l*p,u){let x=Math.min(Math.ceil(Math.sqrt(m*(t.width/t.height)/(r/e))),s),P=e/x,k=P*(t.width/t.height);c=P,a=k}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}};function oe({count:r,parentWidth:e,parentHeight:o,maxTileCount:s,maxRowCount:t,maxColCount:i,aspectRatio:n}){let a=0,c=0,u=0,S=0,m=!1,l=0;if(r===0)return{tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m};if(s)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=Ge({parentWidth:e,parentHeight:o,count:r,maxCount:s,aspectRatio:n}));else if(t)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=je({parentWidth:e,parentHeight:o,count:r,maxCount:t,aspectRatio:n}));else if(i)({tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}=qe({parentWidth:e,parentHeight:o,count:r,maxCount:i,aspectRatio:n}));else{let{width:f,height:h}=L(e,o,r,n.width,n.height);a=f,c=h,l=r}return{tilesInFirstPage:l,defaultWidth:a,defaultHeight:c,lastPageWidth:u,lastPageHeight:S,isLastPageDifferentFromFirstPage:m}}var re=(r,e,o,s=!0)=>{if(!r||!e||!o)return[];let t=[];for(let i of r)if(i.videoTrack===void 0&&i.audioTrack&&e[i.audioTrack]?t.push({peer:i}):i.videoTrack&&e[i.videoTrack]?t.push({track:e[i.videoTrack],peer:i}):s||t.push({peer:i}),o(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(c=>{let u=e[c];return(u==null?void 0:u.type)==="video"&&(u==null?void 0:u.source)==="screen"});a&&t.push({track:e[a],peer:i})}return t};import{useResizeDetector as Je}from"react-resize-detector";var Ke={aspectRatio:{width:1,height:1}},Qe=({peers:r,maxTileCount:e,maxColCount:o,maxRowCount:s,includeScreenShareForPeer:t=()=>!1,aspectRatio:i=Ke.aspectRatio,filterNonPublishingPeers:n=!0})=>{let{width:a=0,height:c=0,ref:u}=Je(),m=A().getState(Ue),l=re(r,m,t,n),f=N(()=>i||{width:te(l)||1,height:1},[i,l]),h=l.length,{tilesInFirstPage:p,defaultWidth:x,defaultHeight:P,lastPageWidth:k,lastPageHeight:W,isLastPageDifferentFromFirstPage:F}=N(()=>oe({count:h,parentWidth:Math.floor(a),parentHeight:Math.floor(c),maxTileCount:e,maxRowCount:s,maxColCount:o,aspectRatio:f}),[h,a,c,e,s,o,f]);return{pagesWithTiles:N(()=>ee({elements:l,tilesInFirstPage:p,onlyOnePage:!1,isLastPageDifferentFromFirstPage:F,defaultWidth:x,defaultHeight:P,lastPageWidth:k,lastPageHeight:W}),[l,p,F,x,P,k,W]),ref:u}};import{useEffect as Xe}from"react";import{selectTrackAudioByID as Ye}from"@100mslive/hms-video-store";function Ze({trackId:r,getStyle:e,ref:o}){let s=A();Xe(()=>s.subscribe(t=>{if(!o.current)return;let i=e(t);for(let n in i)o.current.style[n]=i[n]},Ye(r)),[e,o,s,r])}import{selectDevices as _e,selectIsAllowedToPublish as $e,selectLocalMediaSettings as et}from"@100mslive/hms-video-store";import{useCallback as tt}from"react";var v;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(v||(v={}));var ot=(r=R)=>{let e=H(),o=d(_e),s=d(et),t=d($e),i={[v.audioOutput]:s.audioOutputDeviceId},n={[v.audioOutput]:o.audioOutput};t.video&&(n[v.videoInput]=o.videoInput,i[v.videoInput]=s.videoInputDeviceId),t.audio&&(n[v.audioInput]=o.audioInput,i[v.audioInput]=s.audioInputDeviceId);let a=tt(S=>g(void 0,[S],function*({deviceType:c,deviceId:u}){try{switch(c){case v.audioInput:yield e.setAudioSettings({deviceId:u});break;case v.videoInput:yield e.setVideoSettings({deviceId:u});break;case v.audioOutput:e.setAudioOutputDevice(u);break}}catch(m){r(m,"updateDevices")}}),[r,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};import{useMemo as rt}from"react";import{selectIsConnectedToRoom as st,selectPeerCount as it,selectPeers as nt,selectRemotePeers as at}from"@100mslive/hms-video-store";var se=r=>!r||!Array.isArray(r)||r.length===0?{}:r.reduce((e,o)=>(o.roleName&&(e[o.roleName]||(e[o.roleName]=[]),e[o.roleName].push(o)),e),{});var ct=()=>{let r=d(st),e=d(r?nt:at),o=d(it),s=rt(()=>se(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:o,isConnected:r}};import{selectHLSState as ut,selectRecordingState as lt,selectRTMPState as dt}from"@100mslive/hms-video-store";var mt=()=>{let r=d(lt),e=d(dt),o=d(ut),s=r.server.running,t=r.browser.running,i=r.hls.running,n=o.running||e.running,a=s||t||i;return{isServerRecordingOn:s,isBrowserRecordingOn:t,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:o.running,isRTMPRunning:e.running,isRecordingOn:a}};import{useCallback as St,useEffect as ft,useState as ht}from"react";var gt=()=>{let r=C(),[e,o]=ht(""),s=H(),t=St(()=>g(void 0,null,function*(){yield s.unblockAudio()}),[s]);return ft(()=>{var i,n;((i=r==null?void 0:r.data)==null?void 0:i.code)===3008&&o((n=r==null?void 0:r.data)==null?void 0:n.message)},[r]),{error:e,unblockAudio:t,resetError:()=>o("")}};export*from"@100mslive/hms-video-store";export{v as DeviceType,fe as HMSRoomProvider,pe as throwErrorHandler,Re as useAVToggle,Ze as useAudioLevelStyles,gt as useAutoplayError,ot as useDevices,H as useHMSActions,C as useHMSNotifications,he as useHMSStatsStore,d as useHMSStore,A as useHMSVanillaStore,ct as useParticipantList,be as usePreviewJoin,mt as useRecordingStreaming,Fe as useRemoteAVToggle,Le as useScreenShare,Ee as useVideo,Qe as useVideoList};
@@ -1,9 +1,5 @@
1
1
  import React from 'react';
2
- import { HMSStore, HMSActions, HMSNotification, HMSNotifications, HMSStatsStore, IStoreReadOnly, HMSStats, HMSStoreWrapper } from '@100mslive/hms-video-store';
3
- import { EqualityChecker, StateSelector } from 'zustand';
4
- export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
5
- <U>(selector: StateSelector<S, U>, equalityFn?: EqualityChecker<U>): U;
6
- }
2
+ import { HMSStore, HMSActions, HMSNotification, HMSNotifications, HMSStatsStore, HMSStats, HMSStoreWrapper } from '@100mslive/hms-video-store';
7
3
  export interface HMSRoomProviderProps {
8
4
  actions?: HMSActions;
9
5
  store?: HMSStoreWrapper;
@@ -25,8 +21,8 @@ export declare const HMSRoomProvider: React.FC<HMSRoomProviderProps>;
25
21
  * `useHMSStore` is a read only hook which can be passed a selector to read data.
26
22
  * The hook can only be used in a component if HMSRoomProvider is present in its ancestors.
27
23
  */
28
- export declare const useHMSStore: <StateSlice>(selector: StateSelector<HMSStore, StateSlice>, equalityFn?: EqualityChecker<StateSlice>) => StateSlice;
29
- export declare const useHMSStatsStore: <StateSlice>(selector: StateSelector<HMSStatsStore, StateSlice>, equalityFn?: EqualityChecker<StateSlice>) => StateSlice | undefined;
24
+ export declare const useHMSStore: <StateSlice>(selector: import("zustand").StateSelector<HMSStore, StateSlice>, equalityFn?: import("zustand").EqualityChecker<StateSlice>) => StateSlice;
25
+ export declare const useHMSStatsStore: <StateSlice>(selector: import("zustand").StateSelector<HMSStatsStore, StateSlice>, equalityFn?: import("zustand").EqualityChecker<StateSlice>) => StateSlice | undefined;
30
26
  /**
31
27
  * `useHMSVanillaStore` is a read only hook which returns the vanilla HMSStore.
32
28
  * Usage:
@@ -39,7 +35,7 @@ export declare const useHMSStatsStore: <StateSlice>(selector: StateSelector<HMSS
39
35
  * This is used in rare cases where the store needs to be accessed outside a React component.
40
36
  * For almost every case, `useHMSStore` would get the job done.
41
37
  */
42
- export declare const useHMSVanillaStore: () => import("./types").IHMSReactStore<HMSStore>;
38
+ export declare const useHMSVanillaStore: () => import("./store").IHMSReactStore<HMSStore>;
43
39
  export declare const useHMSActions: () => HMSActions;
44
40
  /**
45
41
  * `useHMSNotifications` is a read only hook which gives the latest notification(HMSNotification) received.
@@ -1,7 +1,9 @@
1
1
  import { EqualityChecker, StateSelector } from 'zustand';
2
2
  import React from 'react';
3
- import { HMSActions, HMSStore, HMSNotifications, HMSStatsStore } from '@100mslive/hms-video-store';
4
- import { IHMSReactStore } from './types';
3
+ import { HMSActions, HMSStore, HMSNotifications, HMSStatsStore, IStoreReadOnly } from '@100mslive/hms-video-store';
4
+ export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
5
+ <U>(selector: StateSelector<S, U>, equalityFn?: EqualityChecker<U>): U;
6
+ }
5
7
  export declare const hooksErrorMessage = "It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";
6
8
  export interface HMSContextProviderProps {
7
9
  actions: HMSActions;
@@ -1,2 +1,15 @@
1
1
  import { HMSPeer } from '@100mslive/hms-video-store';
2
- export declare const groupBy: (peers: HMSPeer[]) => [string, HMSPeer[]][];
2
+ /**
3
+ * Give array like [
4
+ * { name: 'peer1', id: 1, roleName: 'role1' },
5
+ * { name: 'peer2', id: 2, roleName: 'role2' }
6
+ *]
7
+ * the output will be
8
+ * {
9
+ * 'role1': [{'name': 'peer1', id: 1, roleName: 'role1'}],
10
+ * 'role2': [{ name: 'peer2', id: 2, roleName: 'role2' }]
11
+ * }
12
+ * @param {HMSPeer[]} peers
13
+ * @returns
14
+ */
15
+ export declare const groupByRoles: (peers: HMSPeer[]) => Record<string, HMSPeer[]>;
@@ -105,5 +105,12 @@ export declare function calculateLayoutSizes({ count, parentWidth, parentHeight,
105
105
  lastPageHeight: number;
106
106
  isLastPageDifferentFromFirstPage: boolean;
107
107
  };
108
- export declare const getVideoTracksFromPeers: (peers: HMSPeer[], tracks: Record<HMSTrackID, HMSTrack>, showScreenFn: (peer: HMSPeer) => boolean, filterNonPublishingPeers?: boolean) => TrackWithPeer[];
108
+ /**
109
+ * given list of peers and all tracks in the room, get a list of tile objects to show in the UI
110
+ * @param peers
111
+ * @param tracks
112
+ * @param includeScreenShareForPeer - fn will be called to check whether to include screenShare for the peer in returned tiles
113
+ * @param filterNonPublishingPeers - by default a peer with no tracks won't be counted towards final tiles
114
+ */
115
+ export declare const getVideoTracksFromPeers: (peers: HMSPeer[], tracks: Record<HMSTrackID, HMSTrack>, includeScreenShareForPeer: (peer: HMSPeer) => boolean, filterNonPublishingPeers?: boolean) => TrackWithPeer[];
109
116
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
- "version": "0.0.6",
7
+ "version": "0.0.7-alpha.2",
8
8
  "author": "100ms",
9
9
  "license": "MIT",
10
10
  "files": [
@@ -32,10 +32,10 @@
32
32
  "react": "^17.0.1"
33
33
  },
34
34
  "dependencies": {
35
- "@100mslive/hms-video-store": "0.2.89",
35
+ "@100mslive/hms-video-store": "0.2.90-alpha.2",
36
36
  "react-intersection-observer": "^8.33.1",
37
37
  "react-resize-detector": "^7.0.0",
38
38
  "zustand": "^3.6.2"
39
39
  },
40
- "gitHead": "e51ffb5de18a08cc92c67d8b35f3cb6c095212ab"
40
+ "gitHead": "af1e4d5f3bb5e6f89833d0756916026f982e276a"
41
41
  }
@@ -1,9 +0,0 @@
1
- import { HMSTrackID } from '@100mslive/hms-video-store';
2
- /**
3
- * This hook can be used to implement an audio level changer on tile level.
4
- * @param trackId of the track whose volume is needed
5
- */
6
- export declare const useAudio: (trackId: HMSTrackID) => {
7
- volume: number | undefined;
8
- setVolume: (volume: number) => void;
9
- };