@100mslive/react-sdk 0.0.7-alpha.1 → 0.0.7

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.
@@ -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,10 +1,23 @@
1
1
  import { HMSTrackID } from '@100mslive/hms-video-store';
2
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
+ }
3
17
  /**
4
18
  * This hooks can be used to implement a video tile component. Given a track id it will return a ref.
5
19
  * The returned ref can be used to set on a video element meant to display the video.
6
20
  * The hook will take care of attaching and detaching video, and will automatically detach when the video
7
21
  * goes out of view to save on bandwidth.
8
- * @param trackId {HMSTrackID}
9
22
  */
10
- export declare const useVideo: (trackId: HMSTrackID) => React.RefCallback<HTMLVideoElement>;
23
+ export declare const useVideo: ({ trackId, attach }: useVideoInput) => useVideoOutput;
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- var Ne=Object.create;var z=Object.defineProperty,We=Object.defineProperties,Fe=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyDescriptors,ze=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,qe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var oe=(r,e,t)=>e in r?z(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,q=(r,e)=>{for(var t in e||(e={}))te.call(e,t)&&oe(r,t,e[t]);if(ee)for(var t of ee(e))Ge.call(e,t)&&oe(r,t,e[t]);return r},G=(r,e)=>We(r,Be(e)),re=r=>z(r,"__esModule",{value:!0});var je=(r,e)=>{re(r);for(var t in e)z(r,t,{get:e[t],enumerable:!0})},p=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ze(e))!te.call(r,o)&&o!=="default"&&z(r,o,{get:()=>e[o],enumerable:!(t=Fe(e,o))||t.enumerable});return r},f=r=>p(re(z(r!=null?Ne(qe(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var H=(r,e,t)=>new Promise((o,i)=>{var s=l=>{try{a(t.next(l))}catch(c){i(c)}},n=l=>{try{a(t.throw(l))}catch(c){i(c)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,n);a((t=t.apply(r,e)).next())});je(exports,{DeviceType:()=>w,HMSRoomProvider:()=>ce,throwErrorHandler:()=>me,useAVToggle:()=>Se,useAudioLevelStyles:()=>Ee,useDevices:()=>Ae,useHMSActions:()=>v,useHMSNotifications:()=>ue,useHMSStatsStore:()=>le,useHMSStore:()=>m,useHMSVanillaStore:()=>L,useParticipantList:()=>Oe,usePreviewJoin:()=>de,useRecordingStreaming:()=>Le,useRemoteAVToggle:()=>ve,useScreenShare:()=>He,useVideo:()=>ge,useVideoList:()=>xe});var P=f(require("react")),ae=f(require("@100mslive/hms-video-store")),j=f(require("zustand"));var Q=f(require("react")),X=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 k=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}}}};k.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 ie(r){return(t,o=X.default)=>{t||k.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let i=(0,Q.useContext)(r);if(!i)throw new Error(C);return i.store(t,o)}}function se(r){return(t,o=X.default)=>{t||k.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let i=(0,Q.useContext)(r);if(!i)throw new Error(C);let s=i.statsStore;return s==null?void 0:s(t,o)}}var ne=typeof window!="undefined";var O=(0,P.createContext)(null),x,ce=({children:r,actions:e,store:t,notifications:o,stats:i,isHMSStatsOn:s=!1})=>{if(!x){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)x={actions:e,store:(0,j.default)(G(q({},t),{setState:n,destroy:n}))},o&&(x.notifications=o),i&&(x.statsStore=(0,j.default)({getState:i.getState,subscribe:i.subscribe,setState:n,destroy:n}));else{let a=new ae.HMSReactiveStore;if(x={actions:a.getActions(),store:(0,j.default)(G(q({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},s){let l=a.getStats();x.statsStore=(0,j.default)({getState:l.getState,subscribe:l.subscribe,setState:n,destroy:n})}}}return(0,P.useEffect)(()=>{ne&&(window.addEventListener("beforeunload",()=>x.actions.leave()),window.addEventListener("onunload",()=>x.actions.leave()))},[]),P.default.createElement(O.Provider,{value:x},r)},m=ie(O),le=se(O),L=()=>{let r=(0,P.useContext)(O);if(!r)throw new Error(C);return r.store},v=()=>{let r=(0,P.useContext)(O);if(!r)throw new Error(C);return r.actions},ue=()=>{let r=(0,P.useContext)(O),[e,t]=(0,P.useState)(null);if(!r)throw new Error(C);return(0,P.useEffect)(()=>r.notifications?r.notifications.onNotification(i=>t(i)):void 0,[r.notifications]),e};var E=f(require("@100mslive/hms-video-store")),U=f(require("react"));var Ue="react-sdk",y=(r,e)=>k.e(Ue,e,r),me=r=>{throw r};var de=({name:r="",token:e,metadata:t,handleError:o=y,initEndpoint:i,initialSettings:s})=>{let n=v(),a=m(E.selectRoomState),l=m(E.selectIsConnectedToRoom)||!1,c=a===E.HMSRoomState.Preview,S=(0,U.useMemo)(()=>({userName:r,authToken:e,metaData:t,rememberDeviceSelection:!0,settings:s,initEndpoint:i}),[r,e,t,i,s]),d=(0,U.useCallback)(()=>{(()=>H(void 0,null,function*(){if(!!e){a!==E.HMSRoomState.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(h){o(h,"preview")}}}))()},[n,o,e,a,S]),u=(0,U.useCallback)(()=>{if(!!e)try{n.join(S)}catch(h){o(h,"join")}},[n,S,o,e]);return{enableJoin:c,join:u,isConnected:l,preview:d}};var N=f(require("@100mslive/hms-video-store")),Y=f(require("react"));var Se=(r=y)=>{let e=m(N.selectIsLocalAudioEnabled),t=m(N.selectIsLocalVideoEnabled),o=m(N.selectIsAllowedToPublish),i=v(),s=(0,Y.useCallback)(()=>H(void 0,null,function*(){try{yield i.setLocalAudioEnabled(!e)}catch(a){r(a,"toggleAudio")}}),[i,e,r]),n=(0,Y.useCallback)(()=>H(void 0,null,function*(){try{yield i.setLocalVideoEnabled(!t)}catch(a){r(a,"toggleVideo")}}),[i,t,r]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:t,toggleAudio:(o==null?void 0:o.audio)?s:void 0,toggleVideo:(o==null?void 0:o.video)?n:void 0}};var he=f(require("@100mslive/hms-video-store")),V=f(require("react")),fe=f(require("react-intersection-observer"));var ge=r=>{let e=v(),t=(0,V.useRef)(null),o=m((0,he.selectTrackByID)(r)),{ref:i,inView:s}=(0,fe.useInView)({threshold:.5}),n=(0,V.useCallback)(a=>{t.current=a,i(a)},[i]);return(0,V.useEffect)(()=>{(()=>H(void 0,null,function*(){t.current&&(o==null?void 0:o.id)&&(s?o.enabled?yield e.attachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current))}))()},[e,s,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,V.useEffect)(()=>()=>{(()=>H(void 0,null,function*(){if(t.current&&o)try{yield e.detachVideo(o.id,t.current)}catch(a){k.w("detach video error for track",o.id,a)}}))()},[]),n};var W=f(require("@100mslive/hms-video-store"));var pe=f(require("react")),Je=r=>console.log("Error: ",r),He=(r=Je)=>{var n,a;let e=v(),t=m(W.selectIsLocalScreenShared),o=m(W.selectPeerScreenSharing),i=m((0,W.selectScreenSharesByPeerId)(o==null?void 0:o.id)),s=(0,pe.useCallback)(()=>H(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t)}catch(l){r(l)}}),[e,t,r]);return{amIScreenSharing:t,screenSharingPeerId:o==null?void 0:o.id,screenShareVideoTrackId:(n=i==null?void 0:i.video)==null?void 0:n.id,screenShareAudioTrackId:(a=i==null?void 0:i.audio)==null?void 0:a.id,toggleScreenShare:s}};var A=f(require("@100mslive/hms-video-store"));var J=f(require("react"));var Me=(r,e,t)=>H(void 0,null,function*(){if(e)try{yield r.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){t(o,"remoteToggle")}}),ve=(r,e,t=y)=>{let o=v(),i=m((0,A.selectTrackByID)(r)),s=m((0,A.selectTrackByID)(e)),n=m((0,A.selectAudioTrackVolume)(i==null?void 0:i.id)),a=m(A.selectPermissions),l=(s==null?void 0:s.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,c=(i==null?void 0:i.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,S=(0,J.useCallback)(()=>H(void 0,null,function*(){yield Me(o,i,t)}),[o,i,t]),d=(0,J.useCallback)(()=>H(void 0,null,function*(){yield Me(o,s,t)}),[o,t,s]),u=(0,J.useCallback)(h=>{i&&o.setVolume(h,i.id)},[o,i]);return{isAudioEnabled:!!(i==null?void 0:i.enabled),isVideoEnabled:!!(s==null?void 0:s.enabled),volume:n,toggleAudio:i&&c?S:void 0,toggleVideo:(s==null?void 0:s.source)==="regular"&&l?d:void 0,setVolume:i?u:void 0}};var Re=f(require("@100mslive/hms-video-store")),K=f(require("react"));var Ke=(r,e,t)=>r.reduce((o,i,s)=>{let n=Math.floor(s/e);return n>0&&t||(o[n]||(o[n]=[]),o[n].push(i)),o},[]),be=({elements:r,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:o,defaultWidth:i,defaultHeight:s,lastPageWidth:n,lastPageHeight:a})=>{let l=Ke(r,e,t);return l.map((c,S)=>c.map(d=>{let u=S===l.length-1,h=o&&u?n:i,g=o&&u?a:s;return G(q({},d),{height:g,width:h})}))};function Qe(r){if(r.length===0)return null;let e={},t=r[0],o=1;for(let i=0;i<r.length;i++){let s=r[i];e[s]===null?e[s]=1:e[s]++,e[s]>o&&(t=s,o=e[s])}return t}var Pe=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 i,s;let t=(i=e.track)==null?void 0:i.width,o=(s=e.track)==null?void 0:s.height;return(t||1)/(o||1)})),Z=(r,e,t,o,i)=>{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 s=o&&i&&o/i;if(s!==void 0&&isNaN(s))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},a=t,l=-1;if(s!==void 0)for(let c=a;c>0;c+=l){let S=Math.ceil(t/c),d=r/(c*s),u=e/S,h,g;d<=u?(h=r/c,g=h/s):(g=e/S,h=g*s);let M=h*g;M>n.area&&(n={area:M,width:h,height:g,rows:S,cols:c})}return n},Xe=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:i})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,u=Math.min(Math.ceil(Math.sqrt(t*(r/e)/(i.width/i.height))),o),h=r/u,g=h/(i.width/i.height);g>e&&(g=e,h=g/(i.height/i.width));let M=Math.floor(e/g);if(n=g,s=h,S=Math.min(t,M*u),d=t%(M*u),c=d>0&&t>M*u,c){let D=Math.min(Math.ceil(Math.sqrt(d*(r/e)/(i.width/i.height))),o),R=r/D,T=R/(i.width/i.height);T>e&&(T=e,R=T/(i.height/i.width)),l=T,a=R}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}},Ye=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:i})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,{width:u,height:h}=Z(r,e,Math.min(t,o),i.width,i.height);if(s=u,n=h,S=Math.min(t,o),d=t%o,c=d>0&&t>o,c){let{width:g,height:M}=Z(r,e,d,i.width,i.height);a=g,l=M}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}},Ze=({parentWidth:r,parentHeight:e,count:t,maxCount:o,aspectRatio:i})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,u=Math.min(Math.ceil(Math.sqrt(t*(i.width/i.height)/(r/e))),o),h=e/u,g=h*(i.width/i.height),M=Math.floor(r/g);if(s=g,n=h,S=Math.min(t,u*M),d=t%(u*M),c=d>0&&t>u*M,c){let D=Math.min(Math.ceil(Math.sqrt(d*(i.width/i.height)/(r/e))),o),R=e/D,T=R*(i.width/i.height);l=R,a=T}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}};function we({count:r,parentWidth:e,parentHeight:t,maxTileCount:o,maxRowCount:i,maxColCount:s,aspectRatio:n}){let a=0,l=0,c=0,S=0,d=!1,u=0;if(r===0)return{tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=Ye({parentWidth:e,parentHeight:t,count:r,maxCount:o,aspectRatio:n}));else if(i)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=Ze({parentWidth:e,parentHeight:t,count:r,maxCount:i,aspectRatio:n}));else if(s)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=Xe({parentWidth:e,parentHeight:t,count:r,maxCount:s,aspectRatio:n}));else{let{width:h,height:g}=Z(e,t,r,n.width,n.height);a=h,l=g,u=r}return{tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}}var ke=(r,e,t,o=!0)=>{if(!r||!e||!t)return[];let i=[];for(let s of r)if(s.videoTrack===void 0&&s.audioTrack&&e[s.audioTrack]?i.push({peer:s}):s.videoTrack&&e[s.videoTrack]?i.push({track:e[s.videoTrack],peer:s}):o||i.push({peer:s}),t(s)&&s.auxiliaryTracks.length>0){let a=s.auxiliaryTracks.find(l=>{let c=e[l];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&i.push({track:e[a],peer:s})}return i};var Te=f(require("react-resize-detector")),_e={aspectRatio:{width:1,height:1}},xe=({peers:r,maxTileCount:e,maxColCount:t,maxRowCount:o,includeScreenShareForPeer:i=()=>!1,aspectRatio:s=_e.aspectRatio,filterNonPublishingPeers:n=!0})=>{let{width:a=0,height:l=0,ref:c}=(0,Te.useResizeDetector)(),d=L().getState(Re.selectTracksMap),u=ke(r,d,i,n),h=(0,K.useMemo)(()=>s||{width:Pe(u)||1,height:1},[s,u]),g=u.length,{tilesInFirstPage:M,defaultWidth:D,defaultHeight:R,lastPageWidth:T,lastPageHeight:_,isLastPageDifferentFromFirstPage:$}=(0,K.useMemo)(()=>we({count:g,parentWidth:Math.floor(a),parentHeight:Math.floor(l),maxTileCount:e,maxRowCount:o,maxColCount:t,aspectRatio:h}),[g,a,l,e,o,t,h]);return{pagesWithTiles:(0,K.useMemo)(()=>be({elements:u,tilesInFirstPage:M,onlyOnePage:!1,isLastPageDifferentFromFirstPage:$,defaultWidth:D,defaultHeight:R,lastPageWidth:T,lastPageHeight:_}),[u,M,$,D,R,T,_]),ref:c}};var ye=f(require("react")),Ie=f(require("@100mslive/hms-video-store"));function Ee({trackId:r,getStyle:e,ref:t}){let o=L();(0,ye.useEffect)(()=>o.subscribe(i=>{if(!t.current)return;let s=e(i);for(let n in s)t.current.style[n]=s[n]},(0,Ie.selectTrackAudioByID)(r)),[e,t,o,r])}var F=f(require("@100mslive/hms-video-store")),Ve=f(require("react"));var w;(function(o){o.videoInput="videoInput",o.audioInput="audioInput",o.audioOutput="audioOutput"})(w||(w={}));var Ae=(r=y)=>{let e=v(),t=m(F.selectDevices),o=m(F.selectLocalMediaSettings),i=m(F.selectIsAllowedToPublish),s={[w.audioOutput]:o.audioOutputDeviceId},n={[w.audioOutput]:t.audioOutput};i.video&&(n[w.videoInput]=t.videoInput,s[w.videoInput]=o.videoInputDeviceId),i.audio&&(n[w.audioInput]=t.audioInput,s[w.audioInput]=o.audioInputDeviceId);let a=(0,Ve.useCallback)(S=>H(void 0,[S],function*({deviceType:l,deviceId:c}){try{switch(l){case w.audioInput:yield e.setAudioSettings({deviceId:c});break;case w.videoInput:yield e.setVideoSettings({deviceId:c});break;case w.audioOutput:e.setAudioOutputDevice(c);break}}catch(d){r(d,"updateDevices")}}),[r,e]);return{allDevices:n,selectedDeviceIDs:s,updateDevice:a}};var Ce=f(require("react")),I=f(require("@100mslive/hms-video-store"));var De=r=>!r||!Array.isArray(r)||r.length===0?{}:r.reduce((e,t)=>(t.roleName&&(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t)),e),{});var Oe=()=>{let r=m(I.selectIsConnectedToRoom),e=m(r?I.selectPeers:I.selectRemotePeers),t=m(I.selectPeerCount),o=(0,Ce.useMemo)(()=>De(e),[e]);return{roles:Object.keys(o),participantsByRoles:o,peerCount:t,isConnected:r}};var B=f(require("@100mslive/hms-video-store"));var Le=()=>{let r=m(B.selectRecordingState),e=m(B.selectRTMPState),t=m(B.selectHLSState),o=r.server.running,i=r.browser.running,s=r.hls.running,n=t.running||e.running,a=o||i||s;return{isServerRecordingOn:o,isBrowserRecordingOn:i,isHLSRecordingOn:s,isStreamingOn:n,isHLSRunning:t.running,isRTMPRunning:e.running,isRecordingOn:a}};p(exports,f(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
@@ -9,6 +9,7 @@ export { useAudioLevelStyles } from './hooks/useAudioLevelStyles';
9
9
  export { useDevices, DeviceType } from './hooks/useDevices';
10
10
  export { useParticipantList } from './hooks/useParticipantList';
11
11
  export { useRecordingStreaming } from './hooks/useRecordingStreaming';
12
+ export { useAutoplayError } from './hooks/useAutoplayError';
12
13
  export type { hooksErrHandler } from './hooks/types';
13
14
  export type { usePreviewInput, usePreviewResult } from './hooks/usePreviewJoin';
14
15
  export type { useVideoListInput, useVideoResult, useVideoListTile } from './hooks/useVideoList';
@@ -18,5 +19,7 @@ export type { useScreenShareResult } from './hooks/useScreenShare';
18
19
  export type { useRemoteAVToggleResult } from './hooks/useRemoteAVToggle';
19
20
  export type { useRecordingStreamingResult } from './hooks/useRecordingStreaming';
20
21
  export type { useParticipantListResult } from './hooks/useParticipantList';
22
+ export type { useVideoInput, useVideoOutput } from './hooks/useVideo';
23
+ export type { useAutoplayErrorResult } from './hooks/useAutoplayError';
21
24
  export { throwErrorHandler } from './utils/commons';
22
25
  export * from '@100mslive/hms-video-store';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var ie=Object.defineProperty,se=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var B=(i,e,t)=>e in i?ie(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,I=(i,e)=>{for(var t in e||(e={}))ae.call(e,t)&&B(i,t,e[t]);if(F)for(var t of F(e))ce.call(e,t)&&B(i,t,e[t]);return i},E=(i,e)=>se(i,ne(e));var g=(i,e,t)=>new Promise((o,r)=>{var s=l=>{try{a(t.next(l))}catch(c){r(c)}},n=l=>{try{a(t.throw(l))}catch(c){r(c)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,n);a((t=t.apply(i,e)).next())});import le,{createContext as ue,useContext as D,useEffect as J,useState as me}from"react";import{HMSReactiveStore as de}from"@100mslive/hms-video-store";import A from"zustand";import{useContext as z}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 b=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}}}};b.level=0;var x="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(i){return(t,o=q)=>{t||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=z(i);if(!r)throw new Error(x);return r.store(t,o)}}function j(i){return(t,o=q)=>{t||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=z(i);if(!r)throw new Error(x);let s=r.statsStore;return s==null?void 0:s(t,o)}}var U=typeof window!="undefined";var y=ue(null),k,Se=({children:i,actions:e,store:t,notifications:o,stats:r,isHMSStatsOn:s=!1})=>{if(!k){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)k={actions:e,store:A(E(I({},t),{setState:n,destroy:n}))},o&&(k.notifications=o),r&&(k.statsStore=A({getState:r.getState,subscribe:r.subscribe,setState:n,destroy:n}));else{let a=new de;if(k={actions:a.getActions(),store:A(E(I({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},s){let l=a.getStats();k.statsStore=A({getState:l.getState,subscribe:l.subscribe,setState:n,destroy:n})}}}return J(()=>{U&&(window.addEventListener("beforeunload",()=>k.actions.leave()),window.addEventListener("onunload",()=>k.actions.leave()))},[]),le.createElement(y.Provider,{value:k},i)},m=G(y),he=j(y),V=()=>{let i=D(y);if(!i)throw new Error(x);return i.store},M=()=>{let i=D(y);if(!i)throw new Error(x);return i.actions},fe=()=>{let i=D(y),[e,t]=me(null);if(!i)throw new Error(x);return J(()=>i.notifications?i.notifications.onNotification(r=>t(r)):void 0,[i.notifications]),e};import{HMSRoomState as K,selectIsConnectedToRoom as He,selectRoomState as Me}from"@100mslive/hms-video-store";import{useCallback as Q,useMemo as ve}from"react";var ge="react-sdk",R=(i,e)=>b.e(ge,e,i),pe=i=>{throw i};var be=({name:i="",token:e,metadata:t,handleError:o=R,initEndpoint:r,initialSettings:s})=>{let n=M(),a=m(Me),l=m(He)||!1,c=a===K.Preview,S=ve(()=>({userName:i,authToken:e,metaData:t,rememberDeviceSelection:!0,settings:s,initEndpoint:r}),[i,e,t,r,s]),d=Q(()=>{(()=>g(void 0,null,function*(){if(!!e){a!==K.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(h){o(h,"preview")}}}))()},[n,o,e,a,S]),u=Q(()=>{if(!!e)try{n.join(S)}catch(h){o(h,"join")}},[n,S,o,e]);return{enableJoin:c,join:u,isConnected:l,preview:d}};import{selectIsAllowedToPublish as Pe,selectIsLocalAudioEnabled as we,selectIsLocalVideoEnabled as ke}from"@100mslive/hms-video-store";import{useCallback as X}from"react";var Re=(i=R)=>{let e=m(we),t=m(ke),o=m(Pe),r=M(),s=X(()=>g(void 0,null,function*(){try{yield r.setLocalAudioEnabled(!e)}catch(a){i(a,"toggleAudio")}}),[r,e,i]),n=X(()=>g(void 0,null,function*(){try{yield r.setLocalVideoEnabled(!t)}catch(a){i(a,"toggleVideo")}}),[r,t,i]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:t,toggleAudio:(o==null?void 0:o.audio)?s:void 0,toggleVideo:(o==null?void 0:o.video)?n:void 0}};import{selectTrackByID as Te}from"@100mslive/hms-video-store";import{useCallback as xe,useEffect as Y,useRef as ye}from"react";import{useInView as Ie}from"react-intersection-observer";var Ee=i=>{let e=M(),t=ye(null),o=m(Te(i)),{ref:r,inView:s}=Ie({threshold:.5}),n=xe(a=>{t.current=a,r(a)},[r]);return Y(()=>{(()=>g(void 0,null,function*(){t.current&&(o==null?void 0:o.id)&&(s?o.enabled?yield e.attachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current):yield e.detachVideo(o.id,t.current))}))()},[e,s,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]),Y(()=>()=>{(()=>g(void 0,null,function*(){if(t.current&&o)try{yield e.detachVideo(o.id,t.current)}catch(a){b.w("detach video error for track",o.id,a)}}))()},[]),n};import{selectIsLocalScreenShared as Ve,selectPeerScreenSharing as Ae,selectScreenSharesByPeerId as De}from"@100mslive/hms-video-store";import{useCallback as Ce}from"react";var Oe=i=>console.log("Error: ",i),Le=(i=Oe)=>{var n,a;let e=M(),t=m(Ve),o=m(Ae),r=m(De(o==null?void 0:o.id)),s=Ce(()=>g(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t)}catch(l){i(l)}}),[e,t,i]);return{amIScreenSharing:t,screenSharingPeerId:o==null?void 0:o.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:s}};import{selectAudioTrackVolume as Ne,selectPermissions as We,selectTrackByID as Z}from"@100mslive/hms-video-store";import{useCallback as C}from"react";var _=(i,e,t)=>g(void 0,null,function*(){if(e)try{yield i.setRemoteTrackEnabled(e.id,!e.enabled)}catch(o){t(o,"remoteToggle")}}),Fe=(i,e,t=R)=>{let o=M(),r=m(Z(i)),s=m(Z(e)),n=m(Ne(r==null?void 0:r.id)),a=m(We),l=(s==null?void 0:s.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,c=(r==null?void 0:r.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,S=C(()=>g(void 0,null,function*(){yield _(o,r,t)}),[o,r,t]),d=C(()=>g(void 0,null,function*(){yield _(o,s,t)}),[o,t,s]),u=C(h=>{r&&o.setVolume(h,r.id)},[o,r]);return{isAudioEnabled:!!(r==null?void 0:r.enabled),isVideoEnabled:!!(s==null?void 0:s.enabled),volume:n,toggleAudio:r&&c?S:void 0,toggleVideo:(s==null?void 0:s.source)==="regular"&&l?d:void 0,setVolume:r?u:void 0}};import{selectTracksMap as Ue}from"@100mslive/hms-video-store";import{useMemo as L}from"react";var Be=(i,e,t)=>i.reduce((o,r,s)=>{let n=Math.floor(s/e);return n>0&&t||(o[n]||(o[n]=[]),o[n].push(r)),o},[]),$=({elements:i,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:o,defaultWidth:r,defaultHeight:s,lastPageWidth:n,lastPageHeight:a})=>{let l=Be(i,e,t);return l.map((c,S)=>c.map(d=>{let u=S===l.length-1,h=o&&u?n:r,f=o&&u?a:s;return E(I({},d),{height:f,width:h})}))};function ze(i){if(i.length===0)return null;let e={},t=i[0],o=1;for(let r=0;r<i.length;r++){let s=i[r];e[s]===null?e[s]=1:e[s]++,e[s]>o&&(t=s,o=e[s])}return t}var ee=i=>ze(i.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 r,s;let t=(r=e.track)==null?void 0:r.width,o=(s=e.track)==null?void 0:s.height;return(t||1)/(o||1)})),O=(i,e,t,o,r)=>{if(i<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 s=o&&r&&o/r;if(s!==void 0&&isNaN(s))throw new Error("Aspect ratio must be a number");let n={area:0,cols:0,rows:0,width:0,height:0},a=t,l=-1;if(s!==void 0)for(let c=a;c>0;c+=l){let S=Math.ceil(t/c),d=i/(c*s),u=e/S,h,f;d<=u?(h=i/c,f=h/s):(f=e/S,h=f*s);let p=h*f;p>n.area&&(n={area:p,width:h,height:f,rows:S,cols:c})}return n},qe=({parentWidth:i,parentHeight:e,count:t,maxCount:o,aspectRatio:r})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,u=Math.min(Math.ceil(Math.sqrt(t*(i/e)/(r.width/r.height))),o),h=i/u,f=h/(r.width/r.height);f>e&&(f=e,h=f/(r.height/r.width));let p=Math.floor(e/f);if(n=f,s=h,S=Math.min(t,p*u),d=t%(p*u),c=d>0&&t>p*u,c){let T=Math.min(Math.ceil(Math.sqrt(d*(i/e)/(r.width/r.height))),o),P=i/T,w=P/(r.width/r.height);w>e&&(w=e,P=w/(r.height/r.width)),l=w,a=P}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}},Ge=({parentWidth:i,parentHeight:e,count:t,maxCount:o,aspectRatio:r})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,{width:u,height:h}=O(i,e,Math.min(t,o),r.width,r.height);if(s=u,n=h,S=Math.min(t,o),d=t%o,c=d>0&&t>o,c){let{width:f,height:p}=O(i,e,d,r.width,r.height);a=f,l=p}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}},je=({parentWidth:i,parentHeight:e,count:t,maxCount:o,aspectRatio:r})=>{let s=0,n=0,a=0,l=0,c=!1,S=0,d=0,u=Math.min(Math.ceil(Math.sqrt(t*(r.width/r.height)/(i/e))),o),h=e/u,f=h*(r.width/r.height),p=Math.floor(i/f);if(s=f,n=h,S=Math.min(t,u*p),d=t%(u*p),c=d>0&&t>u*p,c){let T=Math.min(Math.ceil(Math.sqrt(d*(r.width/r.height)/(i/e))),o),P=e/T,w=P*(r.width/r.height);l=P,a=w}return{tilesInFirstPage:S,defaultWidth:s,defaultHeight:n,lastPageWidth:a,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}};function te({count:i,parentWidth:e,parentHeight:t,maxTileCount:o,maxRowCount:r,maxColCount:s,aspectRatio:n}){let a=0,l=0,c=0,S=0,d=!1,u=0;if(i===0)return{tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=Ge({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n}));else if(r)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=je({parentWidth:e,parentHeight:t,count:i,maxCount:r,aspectRatio:n}));else if(s)({tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}=qe({parentWidth:e,parentHeight:t,count:i,maxCount:s,aspectRatio:n}));else{let{width:h,height:f}=O(e,t,i,n.width,n.height);a=h,l=f,u=i}return{tilesInFirstPage:u,defaultWidth:a,defaultHeight:l,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:d}}var oe=(i,e,t,o=!0)=>{if(!i||!e||!t)return[];let r=[];for(let s of i)if(s.videoTrack===void 0&&s.audioTrack&&e[s.audioTrack]?r.push({peer:s}):s.videoTrack&&e[s.videoTrack]?r.push({track:e[s.videoTrack],peer:s}):o||r.push({peer:s}),t(s)&&s.auxiliaryTracks.length>0){let a=s.auxiliaryTracks.find(l=>{let c=e[l];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&r.push({track:e[a],peer:s})}return r};import{useResizeDetector as Je}from"react-resize-detector";var Ke={aspectRatio:{width:1,height:1}},Qe=({peers:i,maxTileCount:e,maxColCount:t,maxRowCount:o,includeScreenShareForPeer:r=()=>!1,aspectRatio:s=Ke.aspectRatio,filterNonPublishingPeers:n=!0})=>{let{width:a=0,height:l=0,ref:c}=Je(),d=V().getState(Ue),u=oe(i,d,r,n),h=L(()=>s||{width:ee(u)||1,height:1},[s,u]),f=u.length,{tilesInFirstPage:p,defaultWidth:T,defaultHeight:P,lastPageWidth:w,lastPageHeight:N,isLastPageDifferentFromFirstPage:W}=L(()=>te({count:f,parentWidth:Math.floor(a),parentHeight:Math.floor(l),maxTileCount:e,maxRowCount:o,maxColCount:t,aspectRatio:h}),[f,a,l,e,o,t,h]);return{pagesWithTiles:L(()=>$({elements:u,tilesInFirstPage:p,onlyOnePage:!1,isLastPageDifferentFromFirstPage:W,defaultWidth:T,defaultHeight:P,lastPageWidth:w,lastPageHeight:N}),[u,p,W,T,P,w,N]),ref:c}};import{useEffect as Xe}from"react";import{selectTrackAudioByID as Ye}from"@100mslive/hms-video-store";function Ze({trackId:i,getStyle:e,ref:t}){let o=V();Xe(()=>o.subscribe(r=>{if(!t.current)return;let s=e(r);for(let n in s)t.current.style[n]=s[n]},Ye(i)),[e,t,o,i])}import{selectDevices as _e,selectIsAllowedToPublish as $e,selectLocalMediaSettings as et}from"@100mslive/hms-video-store";import{useCallback as tt}from"react";var v;(function(o){o.videoInput="videoInput",o.audioInput="audioInput",o.audioOutput="audioOutput"})(v||(v={}));var ot=(i=R)=>{let e=M(),t=m(_e),o=m(et),r=m($e),s={[v.audioOutput]:o.audioOutputDeviceId},n={[v.audioOutput]:t.audioOutput};r.video&&(n[v.videoInput]=t.videoInput,s[v.videoInput]=o.videoInputDeviceId),r.audio&&(n[v.audioInput]=t.audioInput,s[v.audioInput]=o.audioInputDeviceId);let a=tt(S=>g(void 0,[S],function*({deviceType:l,deviceId:c}){try{switch(l){case v.audioInput:yield e.setAudioSettings({deviceId:c});break;case v.videoInput:yield e.setVideoSettings({deviceId:c});break;case v.audioOutput:e.setAudioOutputDevice(c);break}}catch(d){i(d,"updateDevices")}}),[i,e]);return{allDevices:n,selectedDeviceIDs:s,updateDevice:a}};import{useMemo as rt}from"react";import{selectIsConnectedToRoom as it,selectPeerCount as st,selectPeers as nt,selectRemotePeers as at}from"@100mslive/hms-video-store";var re=i=>!i||!Array.isArray(i)||i.length===0?{}:i.reduce((e,t)=>(t.roleName&&(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t)),e),{});var ct=()=>{let i=m(it),e=m(i?nt:at),t=m(st),o=rt(()=>re(e),[e]);return{roles:Object.keys(o),participantsByRoles:o,peerCount:t,isConnected:i}};import{selectHLSState as lt,selectRecordingState as ut,selectRTMPState as mt}from"@100mslive/hms-video-store";var dt=()=>{let i=m(ut),e=m(mt),t=m(lt),o=i.server.running,r=i.browser.running,s=i.hls.running,n=t.running||e.running,a=o||r||s;return{isServerRecordingOn:o,isBrowserRecordingOn:r,isHLSRecordingOn:s,isStreamingOn:n,isHLSRunning:t.running,isRTMPRunning:e.running,isRecordingOn:a}};export*from"@100mslive/hms-video-store";export{v as DeviceType,Se as HMSRoomProvider,pe as throwErrorHandler,Re as useAVToggle,Ze as useAudioLevelStyles,ot as useDevices,M as useHMSActions,fe as useHMSNotifications,he as useHMSStatsStore,m as useHMSStore,V as useHMSVanillaStore,ct as useParticipantList,be as usePreviewJoin,dt as useRecordingStreaming,Fe as useRemoteAVToggle,Le as useScreenShare,Ee as useVideo,Qe 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};
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.7-alpha.1",
7
+ "version": "0.0.7",
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.90-alpha.1",
35
+ "@100mslive/hms-video-store": "0.2.90",
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": "bbffdb7ed958ffc689ca31418fdae1ab8f50e1e3"
40
+ "gitHead": "9f75a15b565db67866765745fc1a7495d5047a6e"
41
41
  }