@100mslive/react-sdk 0.4.5-alpha.2 → 0.4.5-alpha.3

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,2 +1,2 @@
1
- import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{selectIsLocalAudioEnabled as i,selectIsLocalVideoEnabled as d,selectIsAllowedToPublish as e}from"@100mslive/hms-video-store";import{useCallback as t}from"react";import{useHMSStore as l,useHMSActions as r}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";const m=(m=s)=>{const n=l(i),v=l(d),c=l(e),a=r(),u=t((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalAudioEnabled(!n)}catch(o){m(o,"toggleAudio")}}))),[a,n,m]),g=t((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalVideoEnabled(!v)}catch(o){m(o,"toggleVideo")}}))),[a,v,m]);return{isLocalAudioEnabled:n,isLocalVideoEnabled:v,toggleAudio:(null==c?void 0:c.audio)?u:void 0,toggleVideo:(null==c?void 0:c.video)?g:void 0}};export{m as useAVToggle};
1
+ import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{useCallback as i}from"react";import{selectIsLocalAudioEnabled as d,selectIsLocalVideoEnabled as e,selectIsAllowedToPublish as t}from"@100mslive/hms-video-store";import{useHMSStore as l,useHMSActions as r}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";const m=(m=s)=>{const n=l(d),v=l(e),c=l(t),a=r(),u=i((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalAudioEnabled(!n)}catch(o){m(o,"toggleAudio")}}))),[a,n,m]),g=i((()=>o(void 0,void 0,void 0,(function*(){try{yield a.setLocalVideoEnabled(!v)}catch(o){m(o,"toggleVideo")}}))),[a,v,m]);return{isLocalAudioEnabled:n,isLocalVideoEnabled:v,toggleAudio:(null==c?void 0:c.audio)?u:void 0,toggleVideo:(null==c?void 0:c.video)?g:void 0}};export{m as useAVToggle};
2
2
  //# sourceMappingURL=useAVToggle.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useHMSActions as s,useHMSVanillaNotifications as o}from"../primitives/HmsRoomProvider.js";import{useEffect as r,useCallback as t}from"react";import{HMSNotificationTypes as i}from"@100mslive/hms-video-store";import{logErrorHandler as n}from"../utils/commons.js";const m=({type:m,json:d=!0,onEvent:a,handleError:l=n})=>{const c=s(),p=o();r((()=>{c.ignoreMessageTypes([m])}),[c,m]),r((()=>{if(!p)return;return p.onNotification((e=>{const s=e.data;if(s&&s.type===m)try{const e=d?JSON.parse(s.message):s.message;null==a||a(e)}catch(e){l(e,"handleCustomEvent")}}),i.NEW_MESSAGE)}),[p,m,d,a,l]);return{sendEvent:t(((s,o)=>e(void 0,void 0,void 0,(function*(){try{const e=((e,s)=>s?JSON.stringify(e||""):e)(s,d);o&&Array.isArray(null==o?void 0:o.roleNames)?yield c.sendGroupMessage(e,o.roleNames,m):"string"==typeof(null==o?void 0:o.peerId)?yield c.sendDirectMessage(e,o.peerId,m):yield c.sendBroadcastMessage(e,m),null==a||a(s)}catch(e){l(e,"sendCustomEvent")}}))),[c,l,a,m,d])}};export{m as useCustomEvent};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useEffect as s,useCallback as o}from"react";import{HMSNotificationTypes as r}from"@100mslive/hms-video-store";import{useHMSActions as t,useHMSVanillaNotifications as i}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as n}from"../utils/commons.js";const m=({type:m,json:d=!0,onEvent:a,handleError:l=n})=>{const c=t(),p=i();s((()=>{c.ignoreMessageTypes([m])}),[c,m]),s((()=>{if(!p)return;return p.onNotification((e=>{const s=e.data;if(s&&s.type===m)try{const e=d?JSON.parse(s.message):s.message;null==a||a(e)}catch(e){l(e,"handleCustomEvent")}}),r.NEW_MESSAGE)}),[p,m,d,a,l]);return{sendEvent:o(((s,o)=>e(void 0,void 0,void 0,(function*(){try{const e=((e,s)=>s?JSON.stringify(e||""):e)(s,d);o&&Array.isArray(null==o?void 0:o.roleNames)?yield c.sendGroupMessage(e,o.roleNames,m):"string"==typeof(null==o?void 0:o.peerId)?yield c.sendDirectMessage(e,o.peerId,m):yield c.sendBroadcastMessage(e,m),null==a||a(s)}catch(e){l(e,"sendCustomEvent")}}))),[c,l,a,m,d])}};export{m as useCustomEvent};
2
2
  //# sourceMappingURL=useCustomEvent.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{selectDevices as i,selectLocalMediaSettings as t,selectIsAllowedToPublish as u}from"@100mslive/hms-video-store";import{useCallback as o}from"react";import{useHMSActions as d,useHMSStore as p}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";var v,a;(a=v||(v={})).videoInput="videoInput",a.audioInput="audioInput",a.audioOutput="audioOutput";const c=(a=s)=>{const c=d(),n=p(i),r=p(t),I=p(u),m={[v.audioOutput]:r.audioOutputDeviceId},l={[v.audioOutput]:n.audioOutput};I.video&&(l[v.videoInput]=n.videoInput,m[v.videoInput]=r.videoInputDeviceId),I.audio&&(l[v.audioInput]=n.audioInput,m[v.audioInput]=r.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:m,updateDevice:o((({deviceType:i,deviceId:t})=>e(void 0,void 0,void 0,(function*(){try{switch(i){case v.audioInput:yield c.setAudioSettings({deviceId:t});break;case v.videoInput:yield c.setVideoSettings({deviceId:t});break;case v.audioOutput:yield c.setAudioOutputDevice(t)}}catch(e){a(e,"updateDevices")}}))),[a,c])}};export{v as DeviceType,c as useDevices};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useCallback as i}from"react";import{selectDevices as t,selectLocalMediaSettings as u,selectIsAllowedToPublish as o}from"@100mslive/hms-video-store";import{useHMSActions as d,useHMSStore as p}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as s}from"../utils/commons.js";var v,a;(a=v||(v={})).videoInput="videoInput",a.audioInput="audioInput",a.audioOutput="audioOutput";const c=(a=s)=>{const c=d(),n=p(t),r=p(u),I=p(o),m={[v.audioOutput]:r.audioOutputDeviceId},l={[v.audioOutput]:n.audioOutput};I.video&&(l[v.videoInput]=n.videoInput,m[v.videoInput]=r.videoInputDeviceId),I.audio&&(l[v.audioInput]=n.audioInput,m[v.audioInput]=r.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:m,updateDevice:i((({deviceType:i,deviceId:t})=>e(void 0,void 0,void 0,(function*(){try{switch(i){case v.audioInput:yield c.setAudioSettings({deviceId:t});break;case v.videoInput:yield c.setVideoSettings({deviceId:t});break;case v.audioOutput:yield c.setAudioOutputDevice(t)}}catch(e){a(e,"updateDevices")}}))),[a,c])}};export{v as DeviceType,c as useDevices};
2
2
  //# sourceMappingURL=useDevices.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{selectRoomState as i,selectIsConnectedToRoom as t,HMSRoomState as o}from"@100mslive/hms-video-store";import{useMemo as r,useCallback as n}from"react";import{useHMSActions as m,useHMSStore as s}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as a}from"../utils/commons.js";const d=({name:d="",token:v,metadata:c,handleError:l=a,initEndpoint:p,initialSettings:u,captureNetworkQualityInPreview:f})=>{const w=m(),y=s(i),j=s(t)||!1,h=y===o.Preview,b=r((()=>({userName:d,authToken:v,metaData:c,rememberDeviceSelection:!0,settings:u,initEndpoint:p,captureNetworkQualityInPreview:f})),[d,v,c,p,u,f]),k=n((()=>e(void 0,void 0,void 0,(function*(){if(v&&y===o.Disconnected){j&&(yield w.leave());try{yield w.preview(b)}catch(e){l(e,"preview")}}}))),[w,l,v,y,b,j]);return{enableJoin:h,join:n((()=>e(void 0,void 0,void 0,(function*(){if(v)try{yield w.join(b)}catch(e){l(e,"join")}}))),[w,b,l,v]),isConnected:j,preview:k}};export{d as usePreviewJoin};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useMemo as i,useCallback as t}from"react";import{selectRoomState as o,selectIsConnectedToRoom as r,HMSRoomState as n}from"@100mslive/hms-video-store";import{useHMSActions as m,useHMSStore as s}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as a}from"../utils/commons.js";const d=({name:d="",token:v,metadata:c,handleError:l=a,initEndpoint:p,initialSettings:u,captureNetworkQualityInPreview:f})=>{const w=m(),y=s(o),j=s(r)||!1,h=y===n.Preview,b=i((()=>({userName:d,authToken:v,metaData:c,rememberDeviceSelection:!0,settings:u,initEndpoint:p,captureNetworkQualityInPreview:f})),[d,v,c,p,u,f]),k=t((()=>e(void 0,void 0,void 0,(function*(){if(v&&y===n.Disconnected){j&&(yield w.leave());try{yield w.preview(b)}catch(e){l(e,"preview")}}}))),[w,l,v,y,b,j]);return{enableJoin:h,join:t((()=>e(void 0,void 0,void 0,(function*(){if(v)try{yield w.join(b)}catch(e){l(e,"join")}}))),[w,b,l,v]),isConnected:j,preview:k}};export{d as usePreviewJoin};
2
2
  //# sourceMappingURL=usePreviewJoin.js.map
@@ -1,2 +1,2 @@
1
- import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{selectAudioTrackByID as i,selectVideoTrackByID as e,selectAudioTrackVolume as d,selectPermissions as l}from"@100mslive/hms-video-store";import{useHMSActions as n,useHMSStore as t}from"../primitives/HmsRoomProvider.js";import{useCallback as u}from"react";import{logErrorHandler as m}from"../utils/commons.js";const v=(i,e,d)=>o(void 0,void 0,void 0,(function*(){if(e)try{yield i.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){d(o,"remoteToggle")}})),r=(r,s,a=m)=>{const c=n(),b=t(i(r)),f=t(e(s)),g=t(d(null==b?void 0:b.id)),p=t(l),y=(null==f?void 0:f.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,V=(null==b?void 0:b.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,j=u((()=>o(void 0,void 0,void 0,(function*(){yield v(c,b,a)}))),[c,b,a]),E=u((()=>o(void 0,void 0,void 0,(function*(){yield v(c,f,a)}))),[c,a,f]),h=u((o=>{b&&c.setVolume(o,b.id)}),[c,b]);return{isAudioEnabled:!!(null==b?void 0:b.enabled),isVideoEnabled:!!(null==f?void 0:f.enabled),volume:g,toggleAudio:b&&V?j:void 0,toggleVideo:"regular"===(null==f?void 0:f.source)&&y?E:void 0,setVolume:b?h:void 0}};export{r as useRemoteAVToggle};
1
+ import{__awaiter as o}from"../node_modules/tslib/tslib.es6.js";import{useCallback as i}from"react";import{selectAudioTrackByID as e,selectVideoTrackByID as d,selectAudioTrackVolume as l,selectPermissions as n}from"@100mslive/hms-video-store";import{useHMSActions as t,useHMSStore as u}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as m}from"../utils/commons.js";const v=(i,e,d)=>o(void 0,void 0,void 0,(function*(){if(e)try{yield i.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){d(o,"remoteToggle")}})),r=(r,s,a=m)=>{const c=t(),b=u(e(r)),f=u(d(s)),g=u(l(null==b?void 0:b.id)),p=u(n),y=(null==f?void 0:f.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,V=(null==b?void 0:b.enabled)?null==p?void 0:p.mute:null==p?void 0:p.unmute,j=i((()=>o(void 0,void 0,void 0,(function*(){yield v(c,b,a)}))),[c,b,a]),E=i((()=>o(void 0,void 0,void 0,(function*(){yield v(c,f,a)}))),[c,a,f]),h=i((o=>{b&&c.setVolume(o,b.id)}),[c,b]);return{isAudioEnabled:!!(null==b?void 0:b.enabled),isVideoEnabled:!!(null==f?void 0:f.enabled),volume:g,toggleAudio:b&&V?j:void 0,toggleVideo:"regular"===(null==f?void 0:f.source)&&y?E:void 0,setVolume:b?h:void 0}};export{r as useRemoteAVToggle};
2
2
  //# sourceMappingURL=useRemoteAVToggle.js.map
@@ -1,5 +1,5 @@
1
- import { hooksErrHandler } from '../hooks/types';
2
1
  import { HMSPeerID, HMSTrackID } from '@100mslive/hms-video-store';
2
+ import { hooksErrHandler } from '../hooks/types';
3
3
  export interface useScreenShareResult {
4
4
  /**
5
5
  * true if the local user is screensharing, false otherwise
@@ -1,2 +1,2 @@
1
- import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{selectIsLocalScreenShared as o,selectPeerScreenSharing as r,selectScreenSharesByPeerId as i}from"@100mslive/hms-video-store";import{useHMSActions as d,useHMSStore as n}from"../primitives/HmsRoomProvider.js";import{useCallback as l}from"react";import{logErrorHandler as m}from"../utils/commons.js";const s=(s=m)=>{var t,a;const v=d(),c=n(o),u=n(r),S=n(i(null==u?void 0:u.id)),h=l(((o=!1)=>e(void 0,void 0,void 0,(function*(){try{yield v.setScreenShareEnabled(!c,o)}catch(e){s(e,"toggleScreenShare")}}))),[v,c,s]);return{amIScreenSharing:c,screenSharingPeerId:null==u?void 0:u.id,screenSharingPeerName:null==u?void 0:u.name,screenShareVideoTrackId:null===(t=null==S?void 0:S.video)||void 0===t?void 0:t.id,screenShareAudioTrackId:null===(a=null==S?void 0:S.audio)||void 0===a?void 0:a.id,toggleScreenShare:h}};export{s as useScreenShare};
1
+ import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{useCallback as o}from"react";import{selectIsLocalScreenShared as r,selectPeerScreenSharing as i,selectScreenSharesByPeerId as d}from"@100mslive/hms-video-store";import{useHMSActions as n,useHMSStore as l}from"../primitives/HmsRoomProvider.js";import{logErrorHandler as m}from"../utils/commons.js";const s=(s=m)=>{var t,a;const v=n(),c=l(r),u=l(i),S=l(d(null==u?void 0:u.id)),h=o(((o=!1)=>e(void 0,void 0,void 0,(function*(){try{yield v.setScreenShareEnabled(!c,o)}catch(e){s(e,"toggleScreenShare")}}))),[v,c,s]);return{amIScreenSharing:c,screenSharingPeerId:null==u?void 0:u.id,screenSharingPeerName:null==u?void 0:u.name,screenShareVideoTrackId:null===(t=null==S?void 0:S.video)||void 0===t?void 0:t.id,screenShareAudioTrackId:null===(a=null==S?void 0:S.audio)||void 0===a?void 0:a.id,toggleScreenShare:h}};export{s as useScreenShare};
2
2
  //# sourceMappingURL=useScreenShare.js.map
@@ -1,5 +1,5 @@
1
- import { HMSTrackID } from '@100mslive/hms-video-store';
2
1
  import React from 'react';
2
+ import { HMSTrackID } from '@100mslive/hms-video-store';
3
3
  export interface useVideoInput {
4
4
  /**
5
5
  * TrackId that is to be rendered
@@ -1,2 +1,2 @@
1
- import{__awaiter as i}from"../node_modules/tslib/tslib.es6.js";import{selectVideoTrackByID as o}from"@100mslive/hms-video-store";import{useRef as r,useCallback as e,useEffect as t}from"react";import{useInView as d}from"react-intersection-observer";import{useHMSActions as l,useHMSStore as n}from"../primitives/HmsRoomProvider.js";import c from"../utils/logger.js";const s=({trackId:s,attach:v,threshold:m=.5})=>{const u=l(),a=r(null),f=n(o(s)),{ref:h,inView:p}=d({threshold:m}),b=e((i=>{i&&(a.current=i,h(i))}),[h]);return t((()=>{i(void 0,void 0,void 0,(function*(){a.current&&(null==f?void 0:f.id)&&(p&&f.enabled&&!1!==v?yield u.attachVideo(f.id,a.current):yield u.detachVideo(f.id,a.current))}))}),[u,p,a,null==f?void 0:f.id,null==f?void 0:f.enabled,null==f?void 0:f.deviceID,null==f?void 0:f.plugins,v]),t((()=>()=>{i(void 0,void 0,void 0,(function*(){if(a.current&&f)try{yield u.detachVideo(f.id,a.current)}catch(i){c.w("detach video error for track",f.id,i)}}))}),[]),{videoRef:b}};export{s as useVideo};
1
+ import{__awaiter as i}from"../node_modules/tslib/tslib.es6.js";import{useRef as o,useCallback as r,useEffect as e}from"react";import{useInView as t}from"react-intersection-observer";import{selectVideoTrackByID as d}from"@100mslive/hms-video-store";import{useHMSActions as l,useHMSStore as n}from"../primitives/HmsRoomProvider.js";import c from"../utils/logger.js";const s=({trackId:s,attach:v,threshold:m=.5})=>{const u=l(),a=o(null),f=n(d(s)),{ref:h,inView:p}=t({threshold:m}),b=r((i=>{i&&(a.current=i,h(i))}),[h]);return e((()=>{i(void 0,void 0,void 0,(function*(){a.current&&(null==f?void 0:f.id)&&(p&&f.enabled&&!1!==v?yield u.attachVideo(f.id,a.current):yield u.detachVideo(f.id,a.current))}))}),[u,p,a,null==f?void 0:f.id,null==f?void 0:f.enabled,null==f?void 0:f.deviceID,null==f?void 0:f.plugins,v]),e((()=>()=>{i(void 0,void 0,void 0,(function*(){if(a.current&&f)try{yield u.detachVideo(f.id,a.current)}catch(i){c.w("detach video error for track",f.id,i)}}))}),[]),{videoRef:b}};export{s as useVideo};
2
2
  //# sourceMappingURL=useVideo.js.map
@@ -1,5 +1,5 @@
1
- import { HMSPeer } from '@100mslive/hms-video-store';
2
1
  import React from 'react';
2
+ import { HMSPeer } from '@100mslive/hms-video-store';
3
3
  import { TrackWithPeer } from '../utils/layout';
4
4
  export interface useVideoListInput {
5
5
  /**
@@ -1,2 +1,2 @@
1
- import{selectTracksMap as t}from"@100mslive/hms-video-store";import{useMemo as e}from"react";import{getVideoTracksFromPeers as i,getModeAspectRatio as r,calculateLayoutSizes as o,chunkElements as a}from"../utils/layout.js";import{useHMSVanillaStore as s}from"../primitives/HmsRoomProvider.js";import{useResizeDetector as h}from"react-resize-detector";const n={width:1,height:1},l=({peers:l,maxTileCount:m,maxColCount:g,maxRowCount:f,includeScreenShareForPeer:u=(()=>!1),aspectRatio:d=n,filterNonPublishingPeers:P=!0,offsetY:p=0})=>{const{width:c=0,height:C=0,ref:x}=h(),F=s().getState(t),H=i(l,F,u,P),W=e((()=>{if(d)return d;return{width:r(H)||1,height:1}}),[d,H]),w=H.length,{tilesInFirstPage:R,defaultWidth:v,defaultHeight:M,lastPageWidth:S,lastPageHeight:T,isLastPageDifferentFromFirstPage:j}=e((()=>o({count:w,parentWidth:Math.floor(c),parentHeight:Math.floor(C)-Math.min(C,p),maxTileCount:m,maxRowCount:f,maxColCount:g,aspectRatio:W})),[w,c,C,m,f,g,W,p]);return{pagesWithTiles:e((()=>a({elements:H,tilesInFirstPage:R,onlyOnePage:!1,isLastPageDifferentFromFirstPage:j,defaultWidth:v,defaultHeight:M,lastPageWidth:S,lastPageHeight:T})),[H,R,j,v,M,S,T]),ref:x}};export{l as useVideoList};
1
+ import{useMemo as t}from"react";import{useResizeDetector as e}from"react-resize-detector";import{selectTracksMap as i}from"@100mslive/hms-video-store";import{useHMSVanillaStore as r}from"../primitives/HmsRoomProvider.js";import{getVideoTracksFromPeers as o,getModeAspectRatio as a,calculateLayoutSizes as s,chunkElements as h}from"../utils/layout.js";const n={width:1,height:1},l=({peers:l,maxTileCount:m,maxColCount:g,maxRowCount:f,includeScreenShareForPeer:u=(()=>!1),aspectRatio:d=n,filterNonPublishingPeers:P=!0,offsetY:p=0})=>{const{width:c=0,height:C=0,ref:x}=e(),F=r().getState(i),H=o(l,F,u,P),W=t((()=>{if(d)return d;return{width:a(H)||1,height:1}}),[d,H]),w=H.length,{tilesInFirstPage:R,defaultWidth:v,defaultHeight:M,lastPageWidth:S,lastPageHeight:T,isLastPageDifferentFromFirstPage:j}=t((()=>s({count:w,parentWidth:Math.floor(c),parentHeight:Math.floor(C)-Math.min(C,p),maxTileCount:m,maxRowCount:f,maxColCount:g,aspectRatio:W})),[w,c,C,m,f,g,W,p]);return{pagesWithTiles:t((()=>h({elements:H,tilesInFirstPage:R,onlyOnePage:!1,isLastPageDifferentFromFirstPage:j,defaultWidth:v,defaultHeight:M,lastPageWidth:S,lastPageHeight:T})),[H,R,j,v,M,S,T]),ref:x}};export{l as useVideoList};
2
2
  //# sourceMappingURL=useVideoList.js.map
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@100mslive/hms-video-store"),i=require("zustand"),o=require("react-intersection-observer"),r=require("react-resize-detector");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a,s,l=n(e),c=n(i);function u(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let o=0;o<i.length;o++)if(!Object.prototype.hasOwnProperty.call(t,i[o])||!Object.is(e[i[o]],t[i[o]]))return!1;return!0}(s=a||(a={}))[s.VERBOSE=0]="VERBOSE",s[s.DEBUG=1]="DEBUG",s[s.INFO=2]="INFO",s[s.WARN=3]="WARN",s[s.ERROR=4]="ERROR",s[s.NONE=5]="NONE";class d{static v(e,...t){this.log(a.VERBOSE,e,...t)}static d(e,...t){this.log(a.DEBUG,e,...t)}static i(e,...t){this.log(a.INFO,e,...t)}static w(e,...t){this.log(a.WARN,e,...t)}static e(e,...t){this.log(a.ERROR,e,...t)}static log(e,t,...i){if(!(this.level.valueOf()>e.valueOf()))switch(e){case a.VERBOSE:console.log("HMSui-components: ",t,...i);break;case a.DEBUG:console.debug("HMSui-components: ",t,...i);break;case a.INFO:console.info("HMSui-components: ",t,...i);break;case a.WARN:console.warn("HMSui-components: ",t,...i);break;case a.ERROR:console.error("HMSui-components: ",t,...i)}}}d.level=a.VERBOSE;const h="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.";const g="undefined"!=typeof window,v=e.createContext(null);let f;const p=(m=v,(t,i=u)=>{t||d.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const o=e.useContext(m);if(!o)throw new Error(h);return(0,o.store)(t,i)});var m;const y=function(t){return(i,o=u)=>{i||d.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const r=e.useContext(t);if(!r)throw new Error(h);const n=r.statsStore;return null==n?void 0:n(i,o)}}(v),w=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.store},S=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.notifications},P=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.actions},b=t=>{const i=e.useContext(v),[o,r]=e.useState(null);if(!i)throw new Error(h);return e.useEffect((()=>{if(!i.notifications)return;return i.notifications.onNotification((e=>{r(e)}),t)}),[i.notifications,t]),o};function E(e,t,i,o){return new(i||(i=Promise))((function(r,n){function a(e){try{l(o.next(e))}catch(e){n(e)}}function s(e){try{l(o.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const R=(e,t)=>d.e("react-sdk",t,e),k=(e,t,i)=>E(void 0,void 0,void 0,(function*(){if(t)try{yield e.setRemoteTrackEnabled(t.id,!t.enabled)}catch(e){i(e,"remoteToggle")}})),x=({elements:e,tilesInFirstPage:t,onlyOnePage:i,isLastPageDifferentFromFirstPage:o,defaultWidth:r,defaultHeight:n,lastPageWidth:a,lastPageHeight:s})=>{const l=((e,t,i)=>e.reduce(((e,o,r)=>{const n=Math.floor(r/t);return n>0&&i||(e[n]||(e[n]=[]),e[n].push(o)),e}),[]))(e,t,i);return l.map(((e,t)=>e.map((e=>{const i=t===l.length-1,c=o&&i?a:r,u=o&&i?s:n;return Object.assign(Object.assign({},e),{height:u,width:c})}))))};const I=(e,t,i,o,r)=>{if(e<0||t<0)throw new Error("Container must have a non-negative area");if(i<1||!Number.isInteger(i))throw new Error("Number of shapes to place must be a positive integer");const n=o&&r&&o/r;if(void 0!==n&&isNaN(n))throw new Error("Aspect ratio must be a number");let a={area:0,cols:0,rows:0,width:0,height:0};if(void 0!==n)for(let o=i;o>0;o+=-1){const r=Math.ceil(i/o);let s,l;e/(o*n)<=t/r?(s=e/o,l=s/n):(l=t/r,s=l*n);const c=s*l;c>a.area&&(a={area:c,width:s,height:l,rows:r,cols:o})}return a};function M({count:e,parentWidth:t,parentHeight:i,maxTileCount:o,maxRowCount:r,maxColCount:n,aspectRatio:a}){let s=0,l=0,c=0,u=0,d=!1,h=0;if(0===e)return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const{width:h,height:g}=I(e,t,Math.min(i,o),r.width,r.height);if(n=h,a=g,u=Math.min(i,o),d=i%o,c=d>0&&i>o,c){const{width:i,height:o}=I(e,t,d,r.width,r.height);s=i,l=o}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:o,aspectRatio:a}));else if(r)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(r.width/r.height)/(e/t))),o),g=t/h,v=g*(r.width/r.height),f=Math.floor(e/v);if(n=v,a=g,u=Math.min(i,h*f),d=i%(h*f),c=d>0&&i>h*f,c){const i=t/Math.min(Math.ceil(Math.sqrt(d*(r.width/r.height)/(e/t))),o);l=i,s=i*(r.width/r.height)}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:r,aspectRatio:a}));else if(n)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(e/t)/(r.width/r.height))),o);let g=e/h,v=g/(r.width/r.height);v>t&&(v=t,g=v/(r.height/r.width));const f=Math.floor(t/v);if(a=v,n=g,u=Math.min(i,f*h),d=i%(f*h),c=d>0&&i>f*h,c){let i=e/Math.min(Math.ceil(Math.sqrt(d*(e/t)/(r.width/r.height))),o),n=i/(r.width/r.height);n>t&&(n=t,i=n/(r.height/r.width)),l=n,s=i}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:n,aspectRatio:a}));else{const{width:o,height:r}=I(t,i,e,a.width,a.height);s=o,l=r,h=e}return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}}const H={width:1,height:1};var C;exports.DeviceType=void 0,(C=exports.DeviceType||(exports.DeviceType={})).videoInput="videoInput",C.audioInput="audioInput",C.audioOutput="audioOutput";exports.HMSRoomProvider=({children:i,actions:o,store:r,notifications:n,stats:a,isHMSStatsOn:s=!1,leaveOnUnload:u=!0})=>{if(!f){const e=()=>{throw new Error("modifying store is not allowed")};if(o&&r)f={actions:o,store:c.default(Object.assign(Object.assign({},r),{setState:e,destroy:e}))},n&&(f.notifications=n),a&&(f.statsStore=c.default({getState:a.getState,subscribe:a.subscribe,setState:e,destroy:e}));else{const i=new t.HMSReactiveStore;if(f={actions:i.getActions(),store:c.default(Object.assign(Object.assign({},i.getStore()),{setState:e,destroy:e})),notifications:i.getNotifications()},s){const t=i.getStats();f.statsStore=c.default({getState:t.getState,subscribe:t.subscribe,setState:e,destroy:e})}}f.actions.setFrameworkInfo({type:"react-web",version:l.default.version,sdkVersion:require("../../package.json").version})}return e.useEffect((()=>{g&&u&&(window.addEventListener("beforeunload",(()=>f.actions.leave())),window.addEventListener("onunload",(()=>f.actions.leave())))}),[u]),l.default.createElement(v.Provider,{value:f},i)},exports.throwErrorHandler=e=>{throw e},exports.useAVToggle=(i=R)=>{const o=p(t.selectIsLocalAudioEnabled),r=p(t.selectIsLocalVideoEnabled),n=p(t.selectIsAllowedToPublish),a=P(),s=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){try{yield a.setLocalAudioEnabled(!o)}catch(e){i(e,"toggleAudio")}}))),[a,o,i]),l=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){try{yield a.setLocalVideoEnabled(!r)}catch(e){i(e,"toggleVideo")}}))),[a,r,i]);return{isLocalAudioEnabled:o,isLocalVideoEnabled:r,toggleAudio:(null==n?void 0:n.audio)?s:void 0,toggleVideo:(null==n?void 0:n.video)?l:void 0}},exports.useAudioLevelStyles=function({trackId:i,getStyle:o,ref:r}){const n=w();e.useEffect((()=>n.subscribe((e=>{if(!r.current)return;const t=o(e);for(const e in t)r.current.style[e]=t[e]}),t.selectTrackAudioByID(i))),[o,r,n,i])},exports.useAutoplayError=()=>{const i=b(t.HMSNotificationTypes.ERROR),[o,r]=e.useState(""),n=P(),a=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield n.unblockAudio()}))),[n]);return e.useEffect((()=>{3008===(null==i?void 0:i.data.code)&&r(null==i?void 0:i.data.message)}),[i]),{error:o,unblockAudio:a,resetError:()=>r("")}},exports.useCustomEvent=({type:i,json:o=!0,onEvent:r,handleError:n=R})=>{const a=P(),s=S();e.useEffect((()=>{a.ignoreMessageTypes([i])}),[a,i]),e.useEffect((()=>{if(!s)return;return s.onNotification((e=>{const t=e.data;if(t&&t.type===i)try{const e=o?JSON.parse(t.message):t.message;null==r||r(e)}catch(e){n(e,"handleCustomEvent")}}),t.HMSNotificationTypes.NEW_MESSAGE)}),[s,i,o,r,n]);return{sendEvent:e.useCallback(((e,t)=>E(void 0,void 0,void 0,(function*(){try{const n=((e,t)=>t?JSON.stringify(e||""):e)(e,o);t&&Array.isArray(null==t?void 0:t.roleNames)?yield a.sendGroupMessage(n,t.roleNames,i):"string"==typeof(null==t?void 0:t.peerId)?yield a.sendDirectMessage(n,t.peerId,i):yield a.sendBroadcastMessage(n,i),null==r||r(e)}catch(e){n(e,"sendCustomEvent")}}))),[a,n,r,i,o])}},exports.useDevices=(i=R)=>{const o=P(),r=p(t.selectDevices),n=p(t.selectLocalMediaSettings),a=p(t.selectIsAllowedToPublish),s={[exports.DeviceType.audioOutput]:n.audioOutputDeviceId},l={[exports.DeviceType.audioOutput]:r.audioOutput};a.video&&(l[exports.DeviceType.videoInput]=r.videoInput,s[exports.DeviceType.videoInput]=n.videoInputDeviceId),a.audio&&(l[exports.DeviceType.audioInput]=r.audioInput,s[exports.DeviceType.audioInput]=n.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:s,updateDevice:e.useCallback((({deviceType:e,deviceId:t})=>E(void 0,void 0,void 0,(function*(){try{switch(e){case exports.DeviceType.audioInput:yield o.setAudioSettings({deviceId:t});break;case exports.DeviceType.videoInput:yield o.setVideoSettings({deviceId:t});break;case exports.DeviceType.audioOutput:yield o.setAudioOutputDevice(t)}}catch(e){i(e,"updateDevices")}}))),[i,o])}},exports.useHMSActions=P,exports.useHMSNotifications=b,exports.useHMSStatsStore=y,exports.useHMSStore=p,exports.useHMSVanillaNotifications=S,exports.useHMSVanillaStore=w,exports.useParticipantList=()=>{const i=p(t.selectIsConnectedToRoom),o=p(i?t.selectPeers:t.selectRemotePeers),r=p(t.selectPeerCount),n=e.useMemo((()=>{return(e=o)&&Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>t.roleName?(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t),e):e),{}):{};var e}),[o]);return{roles:Object.keys(n),participantsByRoles:n,peerCount:r,isConnected:i}},exports.useParticipants=e=>{var i;const o=p(t.selectIsConnectedToRoom),r=p(t.selectPeerCount),n=p(t.selectAvailableRoleNames);let a=p(o?t.selectPeers:t.selectRemotePeers);const s=Array.from(new Set(a.map((e=>e.roleName)))),l=w();if((null===(i=null==e?void 0:e.metadata)||void 0===i?void 0:i.isHandRaised)&&(a=a.filter((e=>l.getState(t.selectPeerMetadata(e.id)).isHandRaised))),(null==e?void 0:e.role)&&n.includes(e.role)&&(a=a.filter((t=>t.roleName===e.role))),null==e?void 0:e.search){const t=e.search.toLowerCase();a=a.filter((e=>{var i;return(null===(i=e.roleName)||void 0===i?void 0:i.toLowerCase().includes(t))||e.name.toLowerCase().includes(t)}))}return{participants:a,isConnected:o,peerCount:r,rolesWithParticipants:s}},exports.usePreviewJoin=({name:i="",token:o,metadata:r,handleError:n=R,initEndpoint:a,initialSettings:s,captureNetworkQualityInPreview:l})=>{const c=P(),u=p(t.selectRoomState),d=p(t.selectIsConnectedToRoom)||!1,h=u===t.HMSRoomState.Preview,g=e.useMemo((()=>({userName:i,authToken:o,metaData:r,rememberDeviceSelection:!0,settings:s,initEndpoint:a,captureNetworkQualityInPreview:l})),[i,o,r,a,s,l]),v=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){if(o&&u===t.HMSRoomState.Disconnected){d&&(yield c.leave());try{yield c.preview(g)}catch(e){n(e,"preview")}}}))),[c,n,o,u,g,d]);return{enableJoin:h,join:e.useCallback((()=>E(void 0,void 0,void 0,(function*(){if(o)try{yield c.join(g)}catch(e){n(e,"join")}}))),[c,g,n,o]),isConnected:d,preview:v}},exports.useRecordingStreaming=()=>{const e=p(t.selectRecordingState),i=p(t.selectRTMPState),o=p(t.selectHLSState),r=e.server.running,n=e.browser.running,a=e.hls.running,s=r||n||a;return{isServerRecordingOn:r,isBrowserRecordingOn:n,isHLSRecordingOn:a,isStreamingOn:o.running||i.running,isHLSRunning:o.running,isRTMPRunning:i.running,isRecordingOn:s}},exports.useRemoteAVToggle=(i,o,r=R)=>{const n=P(),a=p(t.selectAudioTrackByID(i)),s=p(t.selectVideoTrackByID(o)),l=p(t.selectAudioTrackVolume(null==a?void 0:a.id)),c=p(t.selectPermissions),u=(null==s?void 0:s.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,d=(null==a?void 0:a.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,h=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield k(n,a,r)}))),[n,a,r]),g=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield k(n,s,r)}))),[n,r,s]),v=e.useCallback((e=>{a&&n.setVolume(e,a.id)}),[n,a]);return{isAudioEnabled:!!(null==a?void 0:a.enabled),isVideoEnabled:!!(null==s?void 0:s.enabled),volume:l,toggleAudio:a&&d?h:void 0,toggleVideo:"regular"===(null==s?void 0:s.source)&&u?g:void 0,setVolume:a?v:void 0}},exports.useScreenShare=(i=R)=>{var o,r;const n=P(),a=p(t.selectIsLocalScreenShared),s=p(t.selectPeerScreenSharing),l=p(t.selectScreenSharesByPeerId(null==s?void 0:s.id)),c=e.useCallback(((e=!1)=>E(void 0,void 0,void 0,(function*(){try{yield n.setScreenShareEnabled(!a,e)}catch(e){i(e,"toggleScreenShare")}}))),[n,a,i]);return{amIScreenSharing:a,screenSharingPeerId:null==s?void 0:s.id,screenSharingPeerName:null==s?void 0:s.name,screenShareVideoTrackId:null===(o=null==l?void 0:l.video)||void 0===o?void 0:o.id,screenShareAudioTrackId:null===(r=null==l?void 0:l.audio)||void 0===r?void 0:r.id,toggleScreenShare:c}},exports.useVideo=({trackId:i,attach:r,threshold:n=.5})=>{const a=P(),s=e.useRef(null),l=p(t.selectVideoTrackByID(i)),{ref:c,inView:u}=o.useInView({threshold:n}),h=e.useCallback((e=>{e&&(s.current=e,c(e))}),[c]);return e.useEffect((()=>{E(void 0,void 0,void 0,(function*(){s.current&&(null==l?void 0:l.id)&&(u&&l.enabled&&!1!==r?yield a.attachVideo(l.id,s.current):yield a.detachVideo(l.id,s.current))}))}),[a,u,s,null==l?void 0:l.id,null==l?void 0:l.enabled,null==l?void 0:l.deviceID,null==l?void 0:l.plugins,r]),e.useEffect((()=>()=>{E(void 0,void 0,void 0,(function*(){if(s.current&&l)try{yield a.detachVideo(l.id,s.current)}catch(e){d.w("detach video error for track",l.id,e)}}))}),[]),{videoRef:h}},exports.useVideoList=({peers:i,maxTileCount:o,maxColCount:n,maxRowCount:a,includeScreenShareForPeer:s=(()=>!1),aspectRatio:l=H,filterNonPublishingPeers:c=!0,offsetY:u=0})=>{const{width:d=0,height:h=0,ref:g}=r.useResizeDetector(),v=((e,t,i,o=!0)=>{if(!e||!t||!i)return[];const r=[];for(const n of e)if(void 0===n.videoTrack&&n.audioTrack&&t[n.audioTrack]?r.push({peer:n}):n.videoTrack&&t[n.videoTrack]?r.push({track:t[n.videoTrack],peer:n}):o||r.push({peer:n}),n.auxiliaryTracks.length>0&&n.auxiliaryTracks.forEach((e=>{const i=t[e];"video"===(null==i?void 0:i.type)&&"regular"===(null==i?void 0:i.source)&&r.push({track:i,peer:n})})),i(n)&&n.auxiliaryTracks.length>0){const e=n.auxiliaryTracks.find((e=>{const i=t[e];return"video"===(null==i?void 0:i.type)&&"screen"===(null==i?void 0:i.source)}));e&&r.push({track:t[e],peer:n})}return r})(i,w().getState(t.selectTracksMap),s,c),f=e.useMemo((()=>{if(l)return l;return{width:function(e){if(0===e.length)return null;const t={};let i=e[0],o=1;for(let r=0;r<e.length;r++){const n=e[r];null===t[n]?t[n]=1:t[n]++,t[n]>o&&(i=n,o=t[n])}return i}(v.filter((e=>{var t,i;return(null===(t=e.track)||void 0===t?void 0:t.width)&&(null===(i=e.track)||void 0===i?void 0:i.height)})).map((e=>{var t,i;return((null===(t=e.track)||void 0===t?void 0:t.width)||1)/((null===(i=e.track)||void 0===i?void 0:i.height)||1)})))||1,height:1}}),[l,v]),p=v.length,{tilesInFirstPage:m,defaultWidth:y,defaultHeight:S,lastPageWidth:P,lastPageHeight:b,isLastPageDifferentFromFirstPage:E}=e.useMemo((()=>M({count:p,parentWidth:Math.floor(d),parentHeight:Math.floor(h)-Math.min(h,u),maxTileCount:o,maxRowCount:a,maxColCount:n,aspectRatio:f})),[p,d,h,o,a,n,f,u]);return{pagesWithTiles:e.useMemo((()=>x({elements:v,tilesInFirstPage:m,onlyOnePage:!1,isLastPageDifferentFromFirstPage:E,defaultWidth:y,defaultHeight:S,lastPageWidth:P,lastPageHeight:b})),[v,m,E,y,S,P,b]),ref:g}},Object.keys(t).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("zustand"),i=require("@100mslive/hms-video-store"),o=require("react-intersection-observer"),r=require("react-resize-detector");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a,s,l=n(e),c=n(t);function u(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let o=0;o<i.length;o++)if(!Object.prototype.hasOwnProperty.call(t,i[o])||!Object.is(e[i[o]],t[i[o]]))return!1;return!0}(s=a||(a={}))[s.VERBOSE=0]="VERBOSE",s[s.DEBUG=1]="DEBUG",s[s.INFO=2]="INFO",s[s.WARN=3]="WARN",s[s.ERROR=4]="ERROR",s[s.NONE=5]="NONE";class d{static v(e,...t){this.log(a.VERBOSE,e,...t)}static d(e,...t){this.log(a.DEBUG,e,...t)}static i(e,...t){this.log(a.INFO,e,...t)}static w(e,...t){this.log(a.WARN,e,...t)}static e(e,...t){this.log(a.ERROR,e,...t)}static log(e,t,...i){if(!(this.level.valueOf()>e.valueOf()))switch(e){case a.VERBOSE:console.log("HMSui-components: ",t,...i);break;case a.DEBUG:console.debug("HMSui-components: ",t,...i);break;case a.INFO:console.info("HMSui-components: ",t,...i);break;case a.WARN:console.warn("HMSui-components: ",t,...i);break;case a.ERROR:console.error("HMSui-components: ",t,...i)}}}d.level=a.VERBOSE;const h="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.";const g="undefined"!=typeof window,v=e.createContext(null);let f;const p=(m=v,(t,i=u)=>{t||d.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const o=e.useContext(m);if(!o)throw new Error(h);return(0,o.store)(t,i)});var m;const y=function(t){return(i,o=u)=>{i||d.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const r=e.useContext(t);if(!r)throw new Error(h);const n=r.statsStore;return null==n?void 0:n(i,o)}}(v),w=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.store},S=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.notifications},P=()=>{const t=e.useContext(v);if(!t)throw new Error(h);return t.actions},b=t=>{const i=e.useContext(v),[o,r]=e.useState(null);if(!i)throw new Error(h);return e.useEffect((()=>{if(!i.notifications)return;return i.notifications.onNotification((e=>{r(e)}),t)}),[i.notifications,t]),o};function E(e,t,i,o){return new(i||(i=Promise))((function(r,n){function a(e){try{l(o.next(e))}catch(e){n(e)}}function s(e){try{l(o.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const R=(e,t)=>d.e("react-sdk",t,e),k=(e,t,i)=>E(void 0,void 0,void 0,(function*(){if(t)try{yield e.setRemoteTrackEnabled(t.id,!t.enabled)}catch(e){i(e,"remoteToggle")}})),x=({elements:e,tilesInFirstPage:t,onlyOnePage:i,isLastPageDifferentFromFirstPage:o,defaultWidth:r,defaultHeight:n,lastPageWidth:a,lastPageHeight:s})=>{const l=((e,t,i)=>e.reduce(((e,o,r)=>{const n=Math.floor(r/t);return n>0&&i||(e[n]||(e[n]=[]),e[n].push(o)),e}),[]))(e,t,i);return l.map(((e,t)=>e.map((e=>{const i=t===l.length-1,c=o&&i?a:r,u=o&&i?s:n;return Object.assign(Object.assign({},e),{height:u,width:c})}))))};const I=(e,t,i,o,r)=>{if(e<0||t<0)throw new Error("Container must have a non-negative area");if(i<1||!Number.isInteger(i))throw new Error("Number of shapes to place must be a positive integer");const n=o&&r&&o/r;if(void 0!==n&&isNaN(n))throw new Error("Aspect ratio must be a number");let a={area:0,cols:0,rows:0,width:0,height:0};if(void 0!==n)for(let o=i;o>0;o+=-1){const r=Math.ceil(i/o);let s,l;e/(o*n)<=t/r?(s=e/o,l=s/n):(l=t/r,s=l*n);const c=s*l;c>a.area&&(a={area:c,width:s,height:l,rows:r,cols:o})}return a};function M({count:e,parentWidth:t,parentHeight:i,maxTileCount:o,maxRowCount:r,maxColCount:n,aspectRatio:a}){let s=0,l=0,c=0,u=0,d=!1,h=0;if(0===e)return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const{width:h,height:g}=I(e,t,Math.min(i,o),r.width,r.height);if(n=h,a=g,u=Math.min(i,o),d=i%o,c=d>0&&i>o,c){const{width:i,height:o}=I(e,t,d,r.width,r.height);s=i,l=o}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:o,aspectRatio:a}));else if(r)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(r.width/r.height)/(e/t))),o),g=t/h,v=g*(r.width/r.height),f=Math.floor(e/v);if(n=v,a=g,u=Math.min(i,h*f),d=i%(h*f),c=d>0&&i>h*f,c){const i=t/Math.min(Math.ceil(Math.sqrt(d*(r.width/r.height)/(e/t))),o);l=i,s=i*(r.width/r.height)}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:r,aspectRatio:a}));else if(n)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:r})=>{let n=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(e/t)/(r.width/r.height))),o);let g=e/h,v=g/(r.width/r.height);v>t&&(v=t,g=v/(r.height/r.width));const f=Math.floor(t/v);if(a=v,n=g,u=Math.min(i,f*h),d=i%(f*h),c=d>0&&i>f*h,c){let i=e/Math.min(Math.ceil(Math.sqrt(d*(e/t)/(r.width/r.height))),o),n=i/(r.width/r.height);n>t&&(n=t,i=n/(r.height/r.width)),l=n,s=i}return{tilesInFirstPage:u,defaultWidth:n,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:n,aspectRatio:a}));else{const{width:o,height:r}=I(t,i,e,a.width,a.height);s=o,l=r,h=e}return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}}const H={width:1,height:1};var C;exports.DeviceType=void 0,(C=exports.DeviceType||(exports.DeviceType={})).videoInput="videoInput",C.audioInput="audioInput",C.audioOutput="audioOutput";exports.HMSRoomProvider=({children:t,actions:o,store:r,notifications:n,stats:a,isHMSStatsOn:s=!1,leaveOnUnload:u=!0})=>{if(!f){const e=()=>{throw new Error("modifying store is not allowed")};if(o&&r)f={actions:o,store:c.default(Object.assign(Object.assign({},r),{setState:e,destroy:e}))},n&&(f.notifications=n),a&&(f.statsStore=c.default({getState:a.getState,subscribe:a.subscribe,setState:e,destroy:e}));else{const t=new i.HMSReactiveStore;if(f={actions:t.getActions(),store:c.default(Object.assign(Object.assign({},t.getStore()),{setState:e,destroy:e})),notifications:t.getNotifications()},s){const i=t.getStats();f.statsStore=c.default({getState:i.getState,subscribe:i.subscribe,setState:e,destroy:e})}}f.actions.setFrameworkInfo({type:"react-web",version:l.default.version,sdkVersion:require("../../package.json").version})}return e.useEffect((()=>{g&&u&&(window.addEventListener("beforeunload",(()=>f.actions.leave())),window.addEventListener("onunload",(()=>f.actions.leave())))}),[u]),l.default.createElement(v.Provider,{value:f},t)},exports.throwErrorHandler=e=>{throw e},exports.useAVToggle=(t=R)=>{const o=p(i.selectIsLocalAudioEnabled),r=p(i.selectIsLocalVideoEnabled),n=p(i.selectIsAllowedToPublish),a=P(),s=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){try{yield a.setLocalAudioEnabled(!o)}catch(e){t(e,"toggleAudio")}}))),[a,o,t]),l=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){try{yield a.setLocalVideoEnabled(!r)}catch(e){t(e,"toggleVideo")}}))),[a,r,t]);return{isLocalAudioEnabled:o,isLocalVideoEnabled:r,toggleAudio:(null==n?void 0:n.audio)?s:void 0,toggleVideo:(null==n?void 0:n.video)?l:void 0}},exports.useAudioLevelStyles=function({trackId:t,getStyle:o,ref:r}){const n=w();e.useEffect((()=>n.subscribe((e=>{if(!r.current)return;const t=o(e);for(const e in t)r.current.style[e]=t[e]}),i.selectTrackAudioByID(t))),[o,r,n,t])},exports.useAutoplayError=()=>{const t=b(i.HMSNotificationTypes.ERROR),[o,r]=e.useState(""),n=P(),a=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield n.unblockAudio()}))),[n]);return e.useEffect((()=>{3008===(null==t?void 0:t.data.code)&&r(null==t?void 0:t.data.message)}),[t]),{error:o,unblockAudio:a,resetError:()=>r("")}},exports.useCustomEvent=({type:t,json:o=!0,onEvent:r,handleError:n=R})=>{const a=P(),s=S();e.useEffect((()=>{a.ignoreMessageTypes([t])}),[a,t]),e.useEffect((()=>{if(!s)return;return s.onNotification((e=>{const i=e.data;if(i&&i.type===t)try{const e=o?JSON.parse(i.message):i.message;null==r||r(e)}catch(e){n(e,"handleCustomEvent")}}),i.HMSNotificationTypes.NEW_MESSAGE)}),[s,t,o,r,n]);return{sendEvent:e.useCallback(((e,i)=>E(void 0,void 0,void 0,(function*(){try{const n=((e,t)=>t?JSON.stringify(e||""):e)(e,o);i&&Array.isArray(null==i?void 0:i.roleNames)?yield a.sendGroupMessage(n,i.roleNames,t):"string"==typeof(null==i?void 0:i.peerId)?yield a.sendDirectMessage(n,i.peerId,t):yield a.sendBroadcastMessage(n,t),null==r||r(e)}catch(e){n(e,"sendCustomEvent")}}))),[a,n,r,t,o])}},exports.useDevices=(t=R)=>{const o=P(),r=p(i.selectDevices),n=p(i.selectLocalMediaSettings),a=p(i.selectIsAllowedToPublish),s={[exports.DeviceType.audioOutput]:n.audioOutputDeviceId},l={[exports.DeviceType.audioOutput]:r.audioOutput};a.video&&(l[exports.DeviceType.videoInput]=r.videoInput,s[exports.DeviceType.videoInput]=n.videoInputDeviceId),a.audio&&(l[exports.DeviceType.audioInput]=r.audioInput,s[exports.DeviceType.audioInput]=n.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:s,updateDevice:e.useCallback((({deviceType:e,deviceId:i})=>E(void 0,void 0,void 0,(function*(){try{switch(e){case exports.DeviceType.audioInput:yield o.setAudioSettings({deviceId:i});break;case exports.DeviceType.videoInput:yield o.setVideoSettings({deviceId:i});break;case exports.DeviceType.audioOutput:yield o.setAudioOutputDevice(i)}}catch(e){t(e,"updateDevices")}}))),[t,o])}},exports.useHMSActions=P,exports.useHMSNotifications=b,exports.useHMSStatsStore=y,exports.useHMSStore=p,exports.useHMSVanillaNotifications=S,exports.useHMSVanillaStore=w,exports.useParticipantList=()=>{const t=p(i.selectIsConnectedToRoom),o=p(t?i.selectPeers:i.selectRemotePeers),r=p(i.selectPeerCount),n=e.useMemo((()=>{return(e=o)&&Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>t.roleName?(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t),e):e),{}):{};var e}),[o]);return{roles:Object.keys(n),participantsByRoles:n,peerCount:r,isConnected:t}},exports.useParticipants=e=>{var t;const o=p(i.selectIsConnectedToRoom),r=p(i.selectPeerCount),n=p(i.selectAvailableRoleNames);let a=p(o?i.selectPeers:i.selectRemotePeers);const s=Array.from(new Set(a.map((e=>e.roleName)))),l=w();if((null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.isHandRaised)&&(a=a.filter((e=>l.getState(i.selectPeerMetadata(e.id)).isHandRaised))),(null==e?void 0:e.role)&&n.includes(e.role)&&(a=a.filter((t=>t.roleName===e.role))),null==e?void 0:e.search){const t=e.search.toLowerCase();a=a.filter((e=>{var i;return(null===(i=e.roleName)||void 0===i?void 0:i.toLowerCase().includes(t))||e.name.toLowerCase().includes(t)}))}return{participants:a,isConnected:o,peerCount:r,rolesWithParticipants:s}},exports.usePreviewJoin=({name:t="",token:o,metadata:r,handleError:n=R,initEndpoint:a,initialSettings:s,captureNetworkQualityInPreview:l})=>{const c=P(),u=p(i.selectRoomState),d=p(i.selectIsConnectedToRoom)||!1,h=u===i.HMSRoomState.Preview,g=e.useMemo((()=>({userName:t,authToken:o,metaData:r,rememberDeviceSelection:!0,settings:s,initEndpoint:a,captureNetworkQualityInPreview:l})),[t,o,r,a,s,l]),v=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){if(o&&u===i.HMSRoomState.Disconnected){d&&(yield c.leave());try{yield c.preview(g)}catch(e){n(e,"preview")}}}))),[c,n,o,u,g,d]);return{enableJoin:h,join:e.useCallback((()=>E(void 0,void 0,void 0,(function*(){if(o)try{yield c.join(g)}catch(e){n(e,"join")}}))),[c,g,n,o]),isConnected:d,preview:v}},exports.useRecordingStreaming=()=>{const e=p(i.selectRecordingState),t=p(i.selectRTMPState),o=p(i.selectHLSState),r=e.server.running,n=e.browser.running,a=e.hls.running,s=r||n||a;return{isServerRecordingOn:r,isBrowserRecordingOn:n,isHLSRecordingOn:a,isStreamingOn:o.running||t.running,isHLSRunning:o.running,isRTMPRunning:t.running,isRecordingOn:s}},exports.useRemoteAVToggle=(t,o,r=R)=>{const n=P(),a=p(i.selectAudioTrackByID(t)),s=p(i.selectVideoTrackByID(o)),l=p(i.selectAudioTrackVolume(null==a?void 0:a.id)),c=p(i.selectPermissions),u=(null==s?void 0:s.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,d=(null==a?void 0:a.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,h=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield k(n,a,r)}))),[n,a,r]),g=e.useCallback((()=>E(void 0,void 0,void 0,(function*(){yield k(n,s,r)}))),[n,r,s]),v=e.useCallback((e=>{a&&n.setVolume(e,a.id)}),[n,a]);return{isAudioEnabled:!!(null==a?void 0:a.enabled),isVideoEnabled:!!(null==s?void 0:s.enabled),volume:l,toggleAudio:a&&d?h:void 0,toggleVideo:"regular"===(null==s?void 0:s.source)&&u?g:void 0,setVolume:a?v:void 0}},exports.useScreenShare=(t=R)=>{var o,r;const n=P(),a=p(i.selectIsLocalScreenShared),s=p(i.selectPeerScreenSharing),l=p(i.selectScreenSharesByPeerId(null==s?void 0:s.id)),c=e.useCallback(((e=!1)=>E(void 0,void 0,void 0,(function*(){try{yield n.setScreenShareEnabled(!a,e)}catch(e){t(e,"toggleScreenShare")}}))),[n,a,t]);return{amIScreenSharing:a,screenSharingPeerId:null==s?void 0:s.id,screenSharingPeerName:null==s?void 0:s.name,screenShareVideoTrackId:null===(o=null==l?void 0:l.video)||void 0===o?void 0:o.id,screenShareAudioTrackId:null===(r=null==l?void 0:l.audio)||void 0===r?void 0:r.id,toggleScreenShare:c}},exports.useVideo=({trackId:t,attach:r,threshold:n=.5})=>{const a=P(),s=e.useRef(null),l=p(i.selectVideoTrackByID(t)),{ref:c,inView:u}=o.useInView({threshold:n}),h=e.useCallback((e=>{e&&(s.current=e,c(e))}),[c]);return e.useEffect((()=>{E(void 0,void 0,void 0,(function*(){s.current&&(null==l?void 0:l.id)&&(u&&l.enabled&&!1!==r?yield a.attachVideo(l.id,s.current):yield a.detachVideo(l.id,s.current))}))}),[a,u,s,null==l?void 0:l.id,null==l?void 0:l.enabled,null==l?void 0:l.deviceID,null==l?void 0:l.plugins,r]),e.useEffect((()=>()=>{E(void 0,void 0,void 0,(function*(){if(s.current&&l)try{yield a.detachVideo(l.id,s.current)}catch(e){d.w("detach video error for track",l.id,e)}}))}),[]),{videoRef:h}},exports.useVideoList=({peers:t,maxTileCount:o,maxColCount:n,maxRowCount:a,includeScreenShareForPeer:s=(()=>!1),aspectRatio:l=H,filterNonPublishingPeers:c=!0,offsetY:u=0})=>{const{width:d=0,height:h=0,ref:g}=r.useResizeDetector(),v=((e,t,i,o=!0)=>{if(!e||!t||!i)return[];const r=[];for(const n of e)if(void 0===n.videoTrack&&n.audioTrack&&t[n.audioTrack]?r.push({peer:n}):n.videoTrack&&t[n.videoTrack]?r.push({track:t[n.videoTrack],peer:n}):o||r.push({peer:n}),n.auxiliaryTracks.length>0&&n.auxiliaryTracks.forEach((e=>{const i=t[e];"video"===(null==i?void 0:i.type)&&"regular"===(null==i?void 0:i.source)&&r.push({track:i,peer:n})})),i(n)&&n.auxiliaryTracks.length>0){const e=n.auxiliaryTracks.find((e=>{const i=t[e];return"video"===(null==i?void 0:i.type)&&"screen"===(null==i?void 0:i.source)}));e&&r.push({track:t[e],peer:n})}return r})(t,w().getState(i.selectTracksMap),s,c),f=e.useMemo((()=>{if(l)return l;return{width:function(e){if(0===e.length)return null;const t={};let i=e[0],o=1;for(let r=0;r<e.length;r++){const n=e[r];null===t[n]?t[n]=1:t[n]++,t[n]>o&&(i=n,o=t[n])}return i}(v.filter((e=>{var t,i;return(null===(t=e.track)||void 0===t?void 0:t.width)&&(null===(i=e.track)||void 0===i?void 0:i.height)})).map((e=>{var t,i;return((null===(t=e.track)||void 0===t?void 0:t.width)||1)/((null===(i=e.track)||void 0===i?void 0:i.height)||1)})))||1,height:1}}),[l,v]),p=v.length,{tilesInFirstPage:m,defaultWidth:y,defaultHeight:S,lastPageWidth:P,lastPageHeight:b,isLastPageDifferentFromFirstPage:E}=e.useMemo((()=>M({count:p,parentWidth:Math.floor(d),parentHeight:Math.floor(h)-Math.min(h,u),maxTileCount:o,maxRowCount:a,maxColCount:n,aspectRatio:f})),[p,d,h,o,a,n,f,u]);return{pagesWithTiles:e.useMemo((()=>x({elements:v,tilesInFirstPage:m,onlyOnePage:!1,isLastPageDifferentFromFirstPage:E,defaultWidth:y,defaultHeight:S,lastPageWidth:P,lastPageHeight:b})),[v,m,E,y,S,P,b]),ref:g}},Object.keys(i).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})}));
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1,5 +1,5 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import { HMSStore, HMSActions, HMSNotificationInCallback, HMSNotifications, HMSStatsStore, HMSStats, HMSStoreWrapper, HMSNotificationTypeParam } from '@100mslive/hms-video-store';
2
+ import { HMSActions, HMSNotificationInCallback, HMSNotifications, HMSNotificationTypeParam, HMSStats, HMSStatsStore, HMSStore, HMSStoreWrapper } from '@100mslive/hms-video-store';
3
3
  export interface HMSRoomProviderProps {
4
4
  actions?: HMSActions;
5
5
  store?: HMSStoreWrapper;
@@ -1,2 +1,2 @@
1
- import t,{createContext as e,useEffect as o,useContext as s,useState as r}from"react";import{HMSReactiveStore as n}from"@100mslive/hms-video-store";import i from"zustand";import{makeHMSStoreHook as a,makeHMSStatsStoreHook as c,hooksErrorMessage as f}from"./store.js";import{isBrowser as d}from"../utils/isBrowser.js";const l=e(null);let u;const w=({children:e,actions:s,store:r,notifications:a,stats:c,isHMSStatsOn:f=!1,leaveOnUnload:w=!0})=>{if(!u){const e=()=>{throw new Error("modifying store is not allowed")};if(s&&r)u={actions:s,store:i(Object.assign(Object.assign({},r),{setState:e,destroy:e}))},a&&(u.notifications=a),c&&(u.statsStore=i({getState:c.getState,subscribe:c.subscribe,setState:e,destroy:e}));else{const t=new n;if(u={actions:t.getActions(),store:i(Object.assign(Object.assign({},t.getStore()),{setState:e,destroy:e})),notifications:t.getNotifications()},f){const o=t.getStats();u.statsStore=i({getState:o.getState,subscribe:o.subscribe,setState:e,destroy:e})}}u.actions.setFrameworkInfo({type:"react-web",version:t.version,sdkVersion:require("../../package.json").version})}return o((()=>{d&&w&&(window.addEventListener("beforeunload",(()=>u.actions.leave())),window.addEventListener("onunload",(()=>u.actions.leave())))}),[w]),t.createElement(l.Provider,{value:u},e)},m=a(l),b=c(l),g=()=>{const t=s(l);if(!t)throw new Error(f);return t.store},S=()=>{const t=s(l);if(!t)throw new Error(f);return t.notifications},v=()=>{const t=s(l);if(!t)throw new Error(f);return t.actions},p=t=>{const e=s(l),[n,i]=r(null);if(!e)throw new Error(f);return o((()=>{if(!e.notifications)return;return e.notifications.onNotification((t=>{i(t)}),t)}),[e.notifications,t]),n};export{w as HMSRoomProvider,v as useHMSActions,p as useHMSNotifications,b as useHMSStatsStore,m as useHMSStore,S as useHMSVanillaNotifications,g as useHMSVanillaStore};
1
+ import t,{createContext as e,useEffect as o,useContext as s,useState as r}from"react";import n from"zustand";import{HMSReactiveStore as i}from"@100mslive/hms-video-store";import{makeHMSStoreHook as a,makeHMSStatsStoreHook as c,hooksErrorMessage as f}from"./store.js";import{isBrowser as d}from"../utils/isBrowser.js";const l=e(null);let u;const w=({children:e,actions:s,store:r,notifications:a,stats:c,isHMSStatsOn:f=!1,leaveOnUnload:w=!0})=>{if(!u){const e=()=>{throw new Error("modifying store is not allowed")};if(s&&r)u={actions:s,store:n(Object.assign(Object.assign({},r),{setState:e,destroy:e}))},a&&(u.notifications=a),c&&(u.statsStore=n({getState:c.getState,subscribe:c.subscribe,setState:e,destroy:e}));else{const t=new i;if(u={actions:t.getActions(),store:n(Object.assign(Object.assign({},t.getStore()),{setState:e,destroy:e})),notifications:t.getNotifications()},f){const o=t.getStats();u.statsStore=n({getState:o.getState,subscribe:o.subscribe,setState:e,destroy:e})}}u.actions.setFrameworkInfo({type:"react-web",version:t.version,sdkVersion:require("../../package.json").version})}return o((()=>{d&&w&&(window.addEventListener("beforeunload",(()=>u.actions.leave())),window.addEventListener("onunload",(()=>u.actions.leave())))}),[w]),t.createElement(l.Provider,{value:u},e)},m=a(l),b=c(l),g=()=>{const t=s(l);if(!t)throw new Error(f);return t.store},S=()=>{const t=s(l);if(!t)throw new Error(f);return t.notifications},v=()=>{const t=s(l);if(!t)throw new Error(f);return t.actions},p=t=>{const e=s(l),[n,i]=r(null);if(!e)throw new Error(f);return o((()=>{if(!e.notifications)return;return e.notifications.onNotification((t=>{i(t)}),t)}),[e.notifications,t]),n};export{w as HMSRoomProvider,v as useHMSActions,p as useHMSNotifications,b as useHMSStatsStore,m as useHMSStore,S as useHMSVanillaNotifications,g as useHMSVanillaStore};
2
2
  //# sourceMappingURL=HmsRoomProvider.js.map
@@ -1,6 +1,6 @@
1
- import { EqualityChecker, StateSelector } from 'zustand';
2
1
  import React from 'react';
3
- import { HMSActions, HMSStore, HMSNotifications, HMSStatsStore, IStoreReadOnly } from '@100mslive/hms-video-store';
2
+ import { EqualityChecker, StateSelector } from 'zustand';
3
+ import { HMSActions, HMSNotifications, HMSStatsStore, HMSStore, IStoreReadOnly } from '@100mslive/hms-video-store';
4
4
  export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
5
5
  <U>(selector: StateSelector<S, U>, equalityFn?: EqualityChecker<U>): U;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import { EqualityChecker, StateSelector } from 'zustand';
2
- import { HMSStore, IStoreReadOnly, HMSStatsStore } from '@100mslive/hms-video-store';
2
+ import { HMSStatsStore, HMSStore, IStoreReadOnly } from '@100mslive/hms-video-store';
3
3
  export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
4
4
  <U>(selector: StateSelector<S, U>, equalityFn?: EqualityChecker<U>): U;
5
5
  }
@@ -1,4 +1,4 @@
1
- import { HMSPeer, HMSTrack, HMSTrackID, HMSVideoTrack, HMSScreenVideoTrack } from '@100mslive/hms-video-store';
1
+ import { HMSPeer, HMSScreenVideoTrack, HMSTrack, HMSTrackID, HMSVideoTrack } from '@100mslive/hms-video-store';
2
2
  export declare const chunk: <T>(elements: T[], chunkSize: number, onlyOnePage: boolean) => T[][];
3
3
  interface ChunkElements<T> {
4
4
  elements: T[];
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.4.5-alpha.2",
7
+ "version": "0.4.5-alpha.3",
8
8
  "author": "100ms",
9
9
  "license": "MIT",
10
10
  "files": [
@@ -35,10 +35,10 @@
35
35
  "react": ">=16.8 <19.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@100mslive/hms-video-store": "0.6.5-alpha.2",
38
+ "@100mslive/hms-video-store": "0.6.5-alpha.3",
39
39
  "react-intersection-observer": "^8.33.1",
40
40
  "react-resize-detector": "^7.0.0",
41
41
  "zustand": "^3.6.2"
42
42
  },
43
- "gitHead": "f83ed0bebf1c1309187220e23b83baf5e1ab164f"
43
+ "gitHead": "1df0837546be5dd4d3fa3263717f8042c544d584"
44
44
  }
@@ -1,12 +1,12 @@
1
+ import { useCallback } from 'react';
1
2
  import {
2
3
  selectIsAllowedToPublish,
3
4
  selectIsLocalAudioEnabled,
4
5
  selectIsLocalVideoEnabled,
5
6
  } from '@100mslive/hms-video-store';
6
- import { useCallback } from 'react';
7
+ import { hooksErrHandler } from '../hooks/types';
7
8
  import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
8
9
  import { logErrorHandler } from '../utils/commons';
9
- import { hooksErrHandler } from '../hooks/types';
10
10
 
11
11
  export interface useAVToggleResult {
12
12
  /**
@@ -1,7 +1,7 @@
1
- import { useHMSActions, useHMSVanillaNotifications } from '../primitives/HmsRoomProvider';
2
1
  import { useCallback, useEffect } from 'react';
3
2
  import { HMSNotificationTypes, HMSPeerID, HMSRoleName } from '@100mslive/hms-video-store';
4
3
  import { hooksErrHandler } from './types';
4
+ import { useHMSActions, useHMSVanillaNotifications } from '../primitives/HmsRoomProvider';
5
5
  import { logErrorHandler } from '../utils/commons';
6
6
 
7
7
  export interface useCustomEventInput<T> {
@@ -1,8 +1,8 @@
1
- import { selectDevices, selectIsAllowedToPublish, selectLocalMediaSettings } from '@100mslive/hms-video-store';
2
1
  import { useCallback } from 'react';
2
+ import { selectDevices, selectIsAllowedToPublish, selectLocalMediaSettings } from '@100mslive/hms-video-store';
3
+ import { hooksErrHandler } from '../hooks/types';
3
4
  import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
4
5
  import { logErrorHandler } from '../utils/commons';
5
- import { hooksErrHandler } from '../hooks/types';
6
6
 
7
7
  export enum DeviceType {
8
8
  videoInput = 'videoInput',
@@ -1,14 +1,14 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ import { HMSConfig } from '@100mslive/hms-video';
1
3
  import {
4
+ HMSConfigInitialSettings,
2
5
  HMSRoomState,
3
6
  selectIsConnectedToRoom,
4
7
  selectRoomState,
5
- HMSConfigInitialSettings,
6
8
  } from '@100mslive/hms-video-store';
7
- import { useCallback, useMemo } from 'react';
8
- import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
9
9
  import { hooksErrHandler } from './types';
10
+ import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
10
11
  import { logErrorHandler } from '../utils/commons';
11
- import { HMSConfig } from '@100mslive/hms-video';
12
12
 
13
13
  export interface usePreviewInput {
14
14
  /**
@@ -1,16 +1,16 @@
1
1
  /* eslint-disable complexity */
2
+ import { useCallback } from 'react';
2
3
  import {
3
4
  HMSActions,
4
5
  HMSTrack,
5
6
  HMSTrackID,
7
+ selectAudioTrackByID,
6
8
  selectAudioTrackVolume,
7
9
  selectPermissions,
8
- selectAudioTrackByID,
9
10
  selectVideoTrackByID,
10
11
  } from '@100mslive/hms-video-store';
11
- import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
12
- import { useCallback } from 'react';
13
12
  import { hooksErrHandler } from './types';
13
+ import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
14
14
  import { logErrorHandler } from '../utils/commons';
15
15
 
16
16
  export interface useRemoteAVToggleResult {
@@ -1,4 +1,4 @@
1
- import { hooksErrHandler } from '../hooks/types';
1
+ import { useCallback } from 'react';
2
2
  import {
3
3
  HMSPeerID,
4
4
  HMSTrackID,
@@ -6,8 +6,8 @@ import {
6
6
  selectPeerScreenSharing,
7
7
  selectScreenSharesByPeerId,
8
8
  } from '@100mslive/hms-video-store';
9
+ import { hooksErrHandler } from '../hooks/types';
9
10
  import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
10
- import { useCallback } from 'react';
11
11
  import { logErrorHandler } from '../utils/commons';
12
12
 
13
13
  export interface useScreenShareResult {
@@ -1,6 +1,6 @@
1
- import { selectVideoTrackByID, HMSTrackID } from '@100mslive/hms-video-store';
2
1
  import React, { useCallback, useEffect, useRef } from 'react';
3
2
  import { useInView } from 'react-intersection-observer';
3
+ import { HMSTrackID, selectVideoTrackByID } from '@100mslive/hms-video-store';
4
4
  import { useHMSActions, useHMSStore } from '../primitives/HmsRoomProvider';
5
5
  import HMSLogger from '../utils/logger';
6
6
 
@@ -1,5 +1,7 @@
1
- import { HMSPeer, HMSTrack, HMSTrackID, selectTracksMap } from '@100mslive/hms-video-store';
2
1
  import React, { useMemo } from 'react';
2
+ import { useResizeDetector } from 'react-resize-detector';
3
+ import { HMSPeer, HMSTrack, HMSTrackID, selectTracksMap } from '@100mslive/hms-video-store';
4
+ import { useHMSVanillaStore } from '../primitives/HmsRoomProvider';
3
5
  import {
4
6
  calculateLayoutSizes,
5
7
  chunkElements,
@@ -7,8 +9,6 @@ import {
7
9
  getVideoTracksFromPeers,
8
10
  TrackWithPeer,
9
11
  } from '../utils/layout';
10
- import { useHMSVanillaStore } from '../primitives/HmsRoomProvider';
11
- import { useResizeDetector } from 'react-resize-detector';
12
12
 
13
13
  export interface useVideoListInput {
14
14
  /**
@@ -1,17 +1,17 @@
1
1
  import React, { createContext, PropsWithChildren, useContext, useEffect, useState } from 'react';
2
+ import create from 'zustand';
2
3
  import {
3
- HMSReactiveStore,
4
- HMSStore,
5
4
  HMSActions,
6
5
  HMSNotificationInCallback,
7
6
  HMSNotifications,
8
- HMSStatsStore,
7
+ HMSNotificationTypeParam,
8
+ HMSReactiveStore,
9
9
  HMSStats,
10
+ HMSStatsStore,
11
+ HMSStore,
10
12
  HMSStoreWrapper,
11
- HMSNotificationTypeParam,
12
13
  } from '@100mslive/hms-video-store';
13
- import create from 'zustand';
14
- import { HMSContextProviderProps, makeHMSStoreHook, hooksErrorMessage, makeHMSStatsStoreHook } from './store';
14
+ import { HMSContextProviderProps, hooksErrorMessage, makeHMSStatsStoreHook, makeHMSStoreHook } from './store';
15
15
  import { isBrowser } from '../utils/isBrowser';
16
16
 
17
17
  export interface HMSRoomProviderProps {
@@ -1,7 +1,7 @@
1
- import { EqualityChecker, StateSelector } from 'zustand';
2
1
  import React, { useContext } from 'react';
2
+ import { EqualityChecker, StateSelector } from 'zustand';
3
3
  import shallow from 'zustand/shallow';
4
- import { HMSActions, HMSStore, HMSNotifications, HMSStatsStore, IStoreReadOnly } from '@100mslive/hms-video-store';
4
+ import { HMSActions, HMSNotifications, HMSStatsStore, HMSStore, IStoreReadOnly } from '@100mslive/hms-video-store';
5
5
  import HMSLogger from '../utils/logger';
6
6
 
7
7
  export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
@@ -1,5 +1,5 @@
1
1
  import { EqualityChecker, StateSelector } from 'zustand';
2
- import { HMSStore, IStoreReadOnly, HMSStatsStore } from '@100mslive/hms-video-store';
2
+ import { HMSStatsStore, HMSStore, IStoreReadOnly } from '@100mslive/hms-video-store';
3
3
 
4
4
  export interface IHMSReactStore<S extends HMSStore | HMSStatsStore> extends IStoreReadOnly<S> {
5
5
  <U>(selector: StateSelector<S, U>, equalityFn?: EqualityChecker<U>): U;
@@ -1,5 +1,5 @@
1
- import { hooksErrHandler } from '../hooks/types';
2
1
  import HMSLogger from './logger';
2
+ import { hooksErrHandler } from '../hooks/types';
3
3
 
4
4
  const TAG = 'react-sdk';
5
5
 
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable complexity */
2
2
  /* eslint-disable no-plusplus */
3
3
  /* eslint-disable @typescript-eslint/no-shadow */
4
- import { HMSPeer, HMSTrack, HMSTrackID, HMSVideoTrack, HMSScreenVideoTrack } from '@100mslive/hms-video-store';
4
+ import { HMSPeer, HMSScreenVideoTrack, HMSTrack, HMSTrackID, HMSVideoTrack } from '@100mslive/hms-video-store';
5
5
 
6
6
  export const chunk = <T>(elements: T[], chunkSize: number, onlyOnePage: boolean) =>
7
7
  elements.reduce((resultArray: T[][], tile: T, index: number) => {