@100mslive/react-sdk 0.12.0 → 0.12.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var He=Object.defineProperty,Pe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var
|
|
2
|
-
at the top level, check the yarn.lock/package-lock.json, if there are multiple versions of @100mslive/react-sdk. Please ensure the versions of @100mslive/react-sdk and @100mslive/roomkit-react are the same versions from the release notes(https://www.100ms.live/docs/javascript/v2/changelog/release-notes) that you are trying to update to.`;function X(t){return(r,s=Q)=>{r||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=K(t);if(!o)throw new Error(R);let i=o.store;return i(r,s)}}function Z(t){return(r,s=Q)=>{r||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=K(t);if(!o)throw new Error(R);let i=o.statsStore;return i==null?void 0:i(r,s)}}var ee=typeof window!="undefined";var x=Te(null),xe=({children:t,actions:e,store:r,notifications:s,stats:o,isHMSStatsOn:i=!1,leaveOnUnload:c=!0})=>{let n=ye(()=>{let a,u=()=>{throw new Error("modifying store is not allowed")};if(e&&r)a={actions:e,store:D(I(E({},r),{setState:u,destroy:u}))},s&&(a.notifications=s),o&&(a.statsStore=D({getState:o.getState,subscribe:o.subscribe,setState:u,destroy:u}));else{let l=new Re;if(a={actions:l.getActions(),store:D(I(E({},l.getStore()),{setState:u,destroy:u})),notifications:l.getNotifications()},i){let d=l.getStats();a.statsStore=D({getState:d.getState,subscribe:d.subscribe,setState:u,destroy:u})}}return a.actions.setFrameworkInfo({type:"react-web",version:te.version,sdkVersion:process.env.REACT_SDK_VERSION}),a},[e,r,s,o,i]);return re(()=>{if(ee&&c){let a=()=>n.actions.leave();return window.addEventListener("unload",a),()=>{window.removeEventListener("unload",a)}}return()=>{}},[c,n]),te.createElement(x.Provider,{value:n},t)},m=X(x),ke=Z(x),v=()=>{let t=N(x);if(!t)throw new Error(R);return t.store},A=()=>{let t=N(x);if(!t)throw new Error(R);return t.notifications},g=()=>{let t=N(x);if(!t)throw new Error(R);return t.actions},O=t=>{let e=N(x),[r,s]=Ee(null);if(!e)throw new Error(R);return re(()=>e.notifications?e.notifications.onNotification(i=>{s(i)},t):void 0,[e.notifications,t]),r};import{useCallback as se,useMemo as Le}from"react";import{HMSRoomState as ie,selectIsConnectedToRoom as Oe,selectRoomState as Fe}from"@100mslive/hms-video-store";import{useEffect as Ie,useRef as Ae}from"react";import{parsedUserAgent as Ce}from"@100mslive/hms-video-store";var Ve="react-sdk",H=(t,e)=>b.e(Ve,e,t),De=t=>{throw t};function C(t){let e=Ae();return Ie(()=>{e.current=t}),e.current}var Ne=["blink"],k=Ne.some(t=>{var e,r;return((r=(e=Ce.getEngine())==null?void 0:e.name)==null?void 0:r.toLowerCase())===t}),oe="https://pdf-annotation.100ms.live/generic/web/viewer.html";var We=({name:t="",token:e,metadata:r,handleError:s=H,initEndpoint:o,initialSettings:i,captureNetworkQualityInPreview:c,asRole:n,autoManageVideo:a,autoManageWakeLock:u,iceServers:l})=>{let d=g(),f=m(Fe),S=m(Oe)||!1,h=f===ie.Preview,M=Le(()=>({userName:t,authToken:e,metaData:r,rememberDeviceSelection:!0,settings:i,initEndpoint:o,asRole:n,captureNetworkQualityInPreview:c,autoManageVideo:a,autoManageWakeLock:u,iceServers:l}),[t,e,r,o,i,c,n,a,u,l]),y=se(()=>p(null,null,function*(){if(e)try{(S||f!==ie.Disconnected)&&(yield d.leave().catch(()=>{})),yield d.preview(M)}catch(P){s(P,"preview")}}),[e,S,f,d,M,s]),w=se(()=>p(null,null,function*(){if(e)try{yield d.join(M)}catch(P){s(P,"join")}}),[d,M,s,e]);return{enableJoin:h,join:w,isConnected:S,preview:y}};import{useCallback as ne}from"react";import{selectIsAllowedToPreviewMedia as Be,selectIsAllowedToPublish as Ge,selectIsInPreview as Ue,selectIsLocalAudioEnabled as qe,selectIsLocalVideoEnabled as ze}from"@100mslive/hms-video-store";var je=(t=H)=>{let e=m(qe),r=m(ze),o=m(Ue)?Be:Ge,i=m(o),c=g(),n=ne(()=>p(null,null,function*(){try{yield c.setLocalAudioEnabled(!e)}catch(u){t(u,"toggleAudio")}}),[c,e,t]),a=ne(()=>p(null,null,function*(){try{yield c.setLocalVideoEnabled(!r)}catch(u){t(u,"toggleVideo")}}),[c,r,t]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:r,toggleAudio:i!=null&&i.audio?n:void 0,toggleVideo:i!=null&&i.video?a:void 0}};import{useCallback as _e,useEffect as F,useRef as ae}from"react";import{selectVideoTrackByID as Je}from"@100mslive/hms-video-store";var $e=({trackId:t,attach:e})=>{let r=g(),s=ae(null),o=m(Je(t)),i=ae(),c=_e(n=>{n&&(s.current=n)},[]);return F(()=>{i.current?o!=null&&o.id&&i.current!==(o==null?void 0:o.id)&&p(null,null,function*(){if(s.current)try{b.d("detaching because different track is passed"),yield r.detachVideo(i.current,s.current)}catch(n){b.w("detach video error for track",i.current,n)}i.current=o==null?void 0:o.id}):i.current=o==null?void 0:o.id},[o==null?void 0:o.id,r]),F(()=>{p(null,null,function*(){o!=null&&o.id&&s.current&&(e!==!1?yield r.attachVideo(o.id,s.current):yield r.detachVideo(o.id,s.current))})},[o,e,r]),F(()=>()=>{p(null,null,function*(){if(s.current&&o)try{yield r.detachVideo(o.id,s.current)}catch(n){b.w("detach video error for track",o.id,n)}})},[]),{videoRef:c}};import{useCallback as Ye}from"react";import{selectIsLocalScreenShared as Ke,selectPeerScreenSharing as Qe,selectScreenSharesByPeerId as Xe}from"@100mslive/hms-video-store";var V=(t=H)=>{var c,n;let e=g(),r=m(Ke),s=m(Qe),o=m(Xe(s==null?void 0:s.id)),i=Ye(a=>p(null,null,function*(){try{yield e.setScreenShareEnabled(!r,a)}catch(u){t(u,"toggleScreenShare")}}),[e,r,t]);return{amIScreenSharing:r,screenSharingPeerId:s==null?void 0:s.id,screenSharingPeerName:s==null?void 0:s.name,screenShareVideoTrackId:(c=o==null?void 0:o.video)==null?void 0:c.id,screenShareAudioTrackId:(n=o==null?void 0:o.audio)==null?void 0:n.id,toggleScreenShare:i}};import{useCallback as W}from"react";import{selectAudioTrackByID as Ze,selectAudioTrackVolume as et,selectPermissions as tt,selectVideoTrackByID as rt}from"@100mslive/hms-video-store";var ce=(t,e,r)=>p(null,null,function*(){if(e)try{yield t.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){r(s,"remoteToggle")}}),ot=(t,e,r=H)=>{let s=g(),o=m(Ze(t)),i=m(rt(e)),c=m(et(o==null?void 0:o.id)),n=m(tt),a=i!=null&&i.enabled?n==null?void 0:n.mute:n==null?void 0:n.unmute,u=o!=null&&o.enabled?n==null?void 0:n.mute:n==null?void 0:n.unmute,l=W(()=>p(null,null,function*(){yield ce(s,o,r)}),[s,o,r]),d=W(()=>p(null,null,function*(){yield ce(s,i,r)}),[s,r,i]),f=W(S=>{o&&s.setVolume(S,o.id)},[s,o]);return{isAudioEnabled:!!(o!=null&&o.enabled),isVideoEnabled:!!(i!=null&&i.enabled),volume:c,toggleAudio:o&&u?l:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&a?d:void 0,setVolume:o?f:void 0}};import{useMemo as U}from"react";import{useResizeDetector as ut}from"react-resize-detector";import{selectTracksMap as lt}from"@100mslive/hms-video-store";var st=(t,e,r)=>t.reduce((s,o,i)=>{let c=Math.floor(i/e);return c>0&&r||(s[c]||(s[c]=[]),s[c].push(o)),s},[]),ue=({elements:t,tilesInFirstPage:e,onlyOnePage:r,isLastPageDifferentFromFirstPage:s,defaultWidth:o,defaultHeight:i,lastPageWidth:c,lastPageHeight:n})=>{let a=st(t,e,r);return a.map((u,l)=>u.map(d=>{let f=l===a.length-1,S=s&&f?c:o,h=s&&f?n:i;return I(E({},d),{height:h,width:S})}))};function it(t){if(t.length===0)return null;let e={},r=t[0],s=1;for(let o=0;o<t.length;o++){let i=t[o];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(r=i,s=e[i])}return r}var le=t=>it(t.filter(e=>{var r,s;return((r=e.track)==null?void 0:r.width)&&((s=e.track)==null?void 0:s.height)}).map(e=>{var o,i;let r=(o=e.track)==null?void 0:o.width,s=(i=e.track)==null?void 0:i.height;return(r||1)/(s||1)})),B=(t,e,r,s,o)=>{if(t<0||e<0)throw new Error("Container must have a non-negative area");if(r<1||!Number.isInteger(r))throw new Error("Number of shapes to place must be a positive integer");let i=s&&o&&s/o;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let c={area:0,cols:0,rows:0,width:0,height:0},n=r,a=-1;if(i!==void 0)for(let u=n;u>0;u+=a){let l=Math.ceil(r/u),d=t/(u*i),f=e/l,S,h;d<=f?(S=t/u,h=S/i):(h=e/l,S=h*i);let M=S*h;M>c.area&&(c={area:M,width:S,height:h,rows:l,cols:u})}return c},nt=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,c=0,n=0,a=0,u=!1,l=0,d=0,f=Math.min(Math.ceil(Math.sqrt(r*(t/e)/(o.width/o.height))),s),S=t/f,h=S/(o.width/o.height);h>e&&(h=e,S=h/(o.height/o.width));let M=Math.floor(e/h);if(c=h,i=S,l=Math.min(r,M*f),d=r%(M*f),u=d>0&&r>M*f,u){let y=Math.min(Math.ceil(Math.sqrt(d*(t/e)/(o.width/o.height))),s),w=t/y,P=w/(o.width/o.height);P>e&&(P=e,w=P/(o.height/o.width)),a=P,n=w}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:c,lastPageWidth:n,lastPageHeight:a,isLastPageDifferentFromFirstPage:u}},at=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,c=0,n=0,a=0,u=!1,l=0,d=0,{width:f,height:S}=B(t,e,Math.min(r,s),o.width,o.height);if(i=f,c=S,l=Math.min(r,s),d=r%s,u=d>0&&r>s,u){let{width:h,height:M}=B(t,e,d,o.width,o.height);n=h,a=M}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:c,lastPageWidth:n,lastPageHeight:a,isLastPageDifferentFromFirstPage:u}},ct=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,c=0,n=0,a=0,u=!1,l=0,d=0,f=Math.min(Math.ceil(Math.sqrt(r*(o.width/o.height)/(t/e))),s),S=e/f,h=S*(o.width/o.height),M=Math.floor(t/h);if(i=h,c=S,l=Math.min(r,f*M),d=r%(f*M),u=d>0&&r>f*M,u){let y=Math.min(Math.ceil(Math.sqrt(d*(o.width/o.height)/(t/e))),s),w=e/y,P=w*(o.width/o.height);a=w,n=P}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:c,lastPageWidth:n,lastPageHeight:a,isLastPageDifferentFromFirstPage:u}};function de({count:t,parentWidth:e,parentHeight:r,maxTileCount:s,maxRowCount:o,maxColCount:i,aspectRatio:c}){let n=0,a=0,u=0,l=0,d=!1,f=0;if(t===0)return{tilesInFirstPage:f,defaultWidth:n,defaultHeight:a,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d};if(s)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:a,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=at({parentWidth:e,parentHeight:r,count:t,maxCount:s,aspectRatio:c}));else if(o)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:a,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=ct({parentWidth:e,parentHeight:r,count:t,maxCount:o,aspectRatio:c}));else if(i)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:a,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=nt({parentWidth:e,parentHeight:r,count:t,maxCount:i,aspectRatio:c}));else{let{width:S,height:h}=B(e,r,t,c.width,c.height);n=S,a=h,f=t}return{tilesInFirstPage:f,defaultWidth:n,defaultHeight:a,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}}var G=(t,e,r,s=!0)=>{if(!t||!e||!r)return[];let o=[];for(let i of t)if(i.videoTrack===void 0&&i.audioTrack&&e[i.audioTrack]?o.push({peer:i}):i.videoTrack&&e[i.videoTrack]?o.push({track:e[i.videoTrack],peer:i}):s||o.push({peer:i}),i.auxiliaryTracks.length>0&&i.auxiliaryTracks.forEach(n=>{let a=e[n];(a==null?void 0:a.type)==="video"&&(a==null?void 0:a.source)==="regular"&&o.push({track:a,peer:i})}),r(i)&&i.auxiliaryTracks.length>0){let n=i.auxiliaryTracks.find(a=>{let u=e[a];return(u==null?void 0:u.type)==="video"&&(u==null?void 0:u.source)==="screen"});n&&o.push({track:e[n],peer:i})}return o};var dt={aspectRatio:{width:1,height:1}},mt=({peers:t,maxTileCount:e,maxColCount:r,maxRowCount:s,includeScreenShareForPeer:o=()=>!1,aspectRatio:i=dt.aspectRatio,filterNonPublishingPeers:c=!0,offsetY:n=0})=>{let{width:a=0,height:u=0,ref:l}=ut(),f=v().getState(lt),S=G(t,f,o,c),h=U(()=>i||{width:le(S)||1,height:1},[i,S]),M=S.length,{tilesInFirstPage:y,defaultWidth:w,defaultHeight:P,lastPageWidth:j,lastPageHeight:_,isLastPageDifferentFromFirstPage:J}=U(()=>de({count:M,parentWidth:Math.floor(a),parentHeight:Math.floor(u)-Math.min(u,n),maxTileCount:e,maxRowCount:s,maxColCount:r,aspectRatio:h}),[M,a,u,e,s,r,h,n]);return{pagesWithTiles:U(()=>ue({elements:S,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:J,defaultWidth:w,defaultHeight:P,lastPageWidth:j,lastPageHeight:_}),[S,y,J,w,P,j,_]),ref:l}};import{useEffect as ft}from"react";import{selectTrackAudioByID as St}from"@100mslive/hms-video-store";function pt({trackId:t,getStyle:e,ref:r}){let s=v();ft(()=>s.subscribe(o=>{if(!r.current)return;let i=e(o);for(let c in i)r.current.style[c]=i[c]},St(t)),[e,r,s,t])}import{useCallback as ht}from"react";import{DeviceType as T,selectDevices as gt,selectIsAllowedToPreviewMedia as Mt,selectIsAllowedToPublish as Ht,selectIsInPreview as Pt,selectLocalMediaSettings as bt}from"@100mslive/hms-video-store";var wt=(t=H)=>{let e=g(),r=m(gt),s=m(bt),i=m(Pt)?Mt:Ht,c=m(i),n={[T.audioOutput]:s.audioOutputDeviceId},a={[T.audioOutput]:r.audioOutput};c.video&&(a[T.videoInput]=r.videoInput,n[T.videoInput]=s.videoInputDeviceId),c.audio&&(a[T.audioInput]=r.audioInput,n[T.audioInput]=s.audioInputDeviceId);let u=ht(f=>p(null,[f],function*({deviceType:l,deviceId:d}){try{switch(l){case T.audioInput:yield e.setAudioSettings({deviceId:d});break;case T.videoInput:yield e.setVideoSettings({deviceId:d});break;case T.audioOutput:yield e.setAudioOutputDevice(d);break}}catch(S){t(S,"updateDevices")}}),[t,e]);return{allDevices:a,selectedDeviceIDs:n,updateDevice:u}};import{useMemo as vt}from"react";import{selectIsConnectedToRoom as Tt,selectPeerCount as yt,selectPeers as Et,selectRemotePeers as Rt}from"@100mslive/hms-video-store";var me=t=>!t||!Array.isArray(t)||t.length===0?{}:t.reduce((e,r)=>(r.roleName&&(e[r.roleName]||(e[r.roleName]=[]),e[r.roleName].push(r)),e),{});var xt=()=>{let t=m(Tt),e=m(t?Et:Rt),r=m(yt),s=vt(()=>me(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:r,isConnected:t}};import{selectHLSState as kt,selectRecordingState as It,selectRTMPState as At}from"@100mslive/hms-video-store";var Ct=()=>{let t=m(It),e=m(At),r=m(kt),s=t.server.running,o=t.browser.running,i=t.hls.running,c=r.running||e.running,n=s||o||i;return{isServerRecordingOn:s,isBrowserRecordingOn:o,isHLSRecordingOn:i,isStreamingOn:c,isHLSRunning:r.running,isRTMPRunning:e.running,isRecordingOn:n}};import{useCallback as Vt,useEffect as Dt,useState as Nt}from"react";import{HMSNotificationTypes as Lt}from"@100mslive/hms-video-store";var Ot=()=>{let t=O(Lt.ERROR),[e,r]=Nt(""),s=g(),o=Vt(()=>p(null,null,function*(){yield s.unblockAudio()}),[s]);return Dt(()=>{(t==null?void 0:t.data.code)===3008&&r(t==null?void 0:t.data.message)},[t]),{error:e,unblockAudio:o,resetError:()=>r("")}};import{useCallback as Ft,useEffect as fe}from"react";import{HMSNotificationTypes as Wt}from"@100mslive/hms-video-store";var Bt=(t,e)=>e?JSON.stringify(t||""):t,Gt=({type:t,json:e=!0,onEvent:r,handleError:s=H})=>{let o=g(),i=A();return fe(()=>{o.ignoreMessageTypes([t])},[o,t]),fe(()=>i?i.onNotification(a=>{let u=a.data;if(u&&u.type===t)try{let l=e?JSON.parse(u.message):u.message;r==null||r(l)}catch(l){s(l,"handleCustomEvent")}},Wt.NEW_MESSAGE):void 0,[i,t,e,r,s]),{sendEvent:Ft((n,a)=>p(null,null,function*(){try{let u=Bt(n,e);a&&Array.isArray(a==null?void 0:a.roleNames)?yield o.sendGroupMessage(u,a.roleNames,t):typeof(a==null?void 0:a.peerId)=="string"?yield o.sendDirectMessage(u,a.peerId,t):yield o.sendBroadcastMessage(u,t),r==null||r(n)}catch(u){s(u,"sendCustomEvent")}}),[o,s,r,t,e])}};import{selectAvailableRoleNames as Ut,selectIsConnectedToRoom as qt,selectPeerCount as zt,selectPeerMetadata as jt,selectPeers as _t,selectRemotePeers as Jt}from"@100mslive/hms-video-store";var $t=t=>{var n;let e=m(qt),r=m(zt),s=m(Ut),o=m(e?_t:Jt),i=Array.from(new Set(o.map(a=>a.roleName))),c=v();if((n=t==null?void 0:t.metadata)!=null&&n.isHandRaised&&(o=o.filter(a=>c.getState(jt(a.id)).isHandRaised)),t!=null&&t.role&&s.includes(t.role)&&(o=o.filter(a=>a.roleName===t.role)),t!=null&&t.search){let a=t.search.toLowerCase();o=o.filter(u=>{var l;return((l=u.roleName)==null?void 0:l.toLowerCase().includes(a))||u.name.toLowerCase().includes(a)})}return{participants:o,isConnected:e,peerCount:r,rolesWithParticipants:i}};import{useCallback as q,useEffect as Yt,useRef as Se,useState as Kt}from"react";var Qt=t=>{let e=Se(null),[r,s]=Kt(!1),o=q(()=>{throw new Error("unable to start screen share")},[]),i=Se(!1),{amIScreenSharing:c,toggleScreenShare:n}=V(o),a=C(c),u=q(()=>p(null,null,function*(){c&&(yield n==null?void 0:n(),e.current=null)}),[c,n]),l=q(d=>p(null,null,function*(){if(!i.current){if(!d)throw new Error("URL not found");if(c)throw new Error("You are already sharing");if(!e.current)throw new Error("Attach a reference `iframeRef` to iframe for sharing");e.current.src=d,i.current=!0,s(!0),yield n==null?void 0:n({forceCurrentTab:k,cropElement:e.current,preferCurrentTab:k})}}),[c,n]);return Yt(()=>{a&&!c&&(t==null||t(),e.current&&(e.current.src=""),i.current=!1,s(!1))},[c,a,t]),{startEmbedShare:l,stopEmbedShare:u,iframeRef:e,isEmbedShareInProgress:r}};import{useCallback as L,useEffect as Xt,useRef as pe,useState as Zt}from"react";var er=t=>{let e=pe(null),[r,s]=Zt(!1),o=L(()=>{throw new Error("unable to start screen share")},[]),i=pe(!1),{amIScreenSharing:c,toggleScreenShare:n}=V(o),a=C(c),u=L(f=>{var S;e.current&&((S=e.current.contentWindow)==null||S.postMessage({theme:2,file:f},"*"))},[]),l=L(()=>p(null,null,function*(){c&&(yield n==null?void 0:n())}),[c,n]),d=L(f=>p(null,null,function*(){if(i.current)return;if(!f)throw new Error("File or url not found");if(c)throw new Error("You are already sharing");if(!e.current)throw new Error("Attach a reference `iframeRef` to iframe for sharing");e.current.src=`${oe}${typeof f=="string"?`?file=${f}`:""}`,e.current.onload=()=>{requestAnimationFrame(()=>{f instanceof File&&u(f)})},i.current=!0,s(!0);let S=window.self!==window.top;yield n==null?void 0:n({forceCurrentTab:k&&!S,cropElement:e.current,preferCurrentTab:k&&!S})}),[c,u,n]);return Xt(()=>{a&&!c&&(t==null||t(),e.current&&e.current.removeAttribute("src"),i.current=!1,s(!1))},[c,a,t]),{startPDFShare:d,stopPDFShare:l,iframeRef:e,isPDFShareInProgress:r}};import{useRef as tr,useState as he}from"react";var ge=t=>t.reduce((e,r)=>(e[r.id]=r,e),{}),rr=t=>{let e=g(),r=tr(e.getPeerListIterator(t)),[s,o]=he({}),[i,c]=he(0);return{loadPeers:()=>r.current.findPeers().then(n=>{o(ge(n)),c(r.current.getTotal())}),loadMorePeers:()=>r.current.next().then(n=>{o(a=>E(E({},a),ge(n))),c(r.current.getTotal())}),hasNext:()=>r.current.hasNext(),total:i,peers:Object.values(s)}};import{useCallback as or,useEffect as sr,useState as ir}from"react";import{selectAppData as nr,selectIsConnectedToRoom as ar,selectLocalPeer as cr,selectPermissions as ur,selectWhiteboard as lr}from"@100mslive/hms-video-store";var dr=(t=!1)=>{var S,h;let e=m(ar),r=(S=m(cr))==null?void 0:S.customerUserId,s=m(lr),o=m(nr("disableNotifications")),i=!!(s!=null&&s.open),c=(s==null?void 0:s.owner)===r,n=g(),[a,u]=ir(!1),l=(h=m(ur))==null?void 0:h.whiteboard,d=!!(l!=null&&l.includes("admin"));sr(()=>{e&&u(n.interactivityCenter.whiteboard.isEnabled)},[e,n]);let f=or(()=>p(null,null,function*(){!e||!d||(i?c&&(yield n.interactivityCenter.whiteboard.close()):yield n.interactivityCenter.whiteboard.open())}),[n,c,d,i,e]);return{open:i,token:s==null?void 0:s.token,endpoint:s==null?void 0:s.addr,isOwner:c,isAdmin:d,zoomToContent:o||t,toggle:a&&d?f:void 0}};import{useCallback as Me}from"react";import{selectLocalPeerRoleName as mr}from"@100mslive/hms-video-store";var fr=()=>{let t=v(),e=Me(()=>p(null,null,function*(){if(!("Notification"in window)||navigator.webdriver){console.debug("Request Permsissions : Notifications not supported or headless browser");return}if((Notification==null?void 0:Notification.permission)==="granted"||(Notification==null?void 0:Notification.permission)==="denied")return;let s=t.subscribe(o=>p(null,null,function*(){o&&o!=="__internal_recorder"&&(yield Notification.requestPermission(),s==null||s())}),mr)}),[t]),r=Me((s,o)=>{if(!("Notification"in window)){console.debug("Show Notifications: Notifications not supported or headless browser");return}if((Notification==null?void 0:Notification.permission)==="denied"||document.visibilityState==="visible"&&document.hasFocus())return;let i=new Notification(s,o),c=()=>{document.visibilityState==="visible"&&document.hasFocus()&&(i==null||i.close(),document.removeEventListener("visibilitychange",c))};document.addEventListener("visibilitychange",c)},[]);return{requestPermission:e,showNotification:r}};import{useEffect as Sr}from"react";import{HMSNotificationTypes as pr}from"@100mslive/hms-video-store";var hr=({onTranscript:t,handleError:e=H})=>{let r="hms_transcript",s=A();Sr(()=>s?s.onNotification(i=>{let c=i.data;if(c&&c.type===r)try{let a=JSON.parse(c.message).results;t==null||t(a)}catch(n){e(n,"handleCaptionEvent")}},pr.NEW_MESSAGE):void 0,[s,r,e,t])};import{HMSAudioMode as z,selectLocalMediaSettings as gr}from"@100mslive/hms-video-store";var Mr=()=>{let t=g(),{audioMode:e}=m(gr),r=e===z.MUSIC;return{toggleMusicMode:()=>p(null,null,function*(){return yield t.setAudioSettings({audioMode:r?z.VOICE:z.MUSIC})}),isMusicModeEnabled:r}};export*from"@100mslive/hms-video-store";export{xe as HMSRoomProvider,G as getPeersWithTiles,De as throwErrorHandler,je as useAVToggle,pt as useAudioLevelStyles,Mr as useAudioMode,Ot as useAutoplayError,fr as useAwayNotifications,Gt as useCustomEvent,wt as useDevices,Qt as useEmbedShare,g as useHMSActions,O as useHMSNotifications,ke as useHMSStatsStore,m as useHMSStore,A as useHMSVanillaNotifications,v as useHMSVanillaStore,er as usePDFShare,rr as usePaginatedParticipants,xt as useParticipantList,$t as useParticipants,We as usePreviewJoin,Ct as useRecordingStreaming,ot as useRemoteAVToggle,V as useScreenShare,hr as useTranscript,$e as useVideo,mt as useVideoList,dr as useWhiteboard};
|
|
1
|
+
var He=Object.defineProperty,Pe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var Q=(t,e,r)=>e in t?He(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,E=(t,e)=>{for(var r in e||(e={}))we.call(e,r)&&Q(t,r,e[r]);if(K)for(var r of K(e))ve.call(e,r)&&Q(t,r,e[r]);return t},I=(t,e)=>Pe(t,be(e));var p=(t,e,r)=>new Promise((s,o)=>{var i=c=>{try{n(r.next(c))}catch(u){o(u)}},a=c=>{try{n(r.throw(c))}catch(u){o(u)}},n=c=>c.done?s(c.value):Promise.resolve(c.value).then(i,a);n((r=r.apply(t,e)).next())});import re,{createContext as Te,useContext as N,useEffect as F,useMemo as ye,useState as Ee}from"react";import D from"zustand";import{HMSReactiveStore as Re}from"@100mslive/hms-video-store";import{useContext as X}from"react";import Z from"zustand/shallow";var b=class{static v(e,...r){this.log(0,e,...r)}static d(e,...r){this.log(1,e,...r)}static i(e,...r){this.log(2,e,...r)}static w(e,...r){this.log(3,e,...r)}static e(e,...r){this.log(4,e,...r)}static log(e,r,...s){if(!(this.level.valueOf()>e.valueOf()))switch(e){case 0:{console.log("HMSui-components: ",r,...s);break}case 1:{console.debug("HMSui-components: ",r,...s);break}case 2:{console.info("HMSui-components: ",r,...s);break}case 3:{console.warn("HMSui-components: ",r,...s);break}case 4:{console.error("HMSui-components: ",r,...s);break}}}};b.level=0;var R=`It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://www.100ms.live/docs/javascript/v2/how-to-guides/install-the-sdk/integration#react-hooks) to check on the required steps for using this hook. If the provider is present
|
|
2
|
+
at the top level, check the yarn.lock/package-lock.json, if there are multiple versions of @100mslive/react-sdk. Please ensure the versions of @100mslive/react-sdk and @100mslive/roomkit-react are the same versions from the release notes(https://www.100ms.live/docs/javascript/v2/changelog/release-notes) that you are trying to update to.`;function ee(t){return(r,s=Z)=>{r||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=X(t);if(!o)throw new Error(R);let i=o.store;return i(r,s)}}function te(t){return(r,s=Z)=>{r||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=X(t);if(!o)throw new Error(R);let i=o.statsStore;return i==null?void 0:i(r,s)}}var O=typeof window!="undefined";var x=Te(null),xe=({children:t,actions:e,store:r,notifications:s,stats:o,isHMSStatsOn:i=!1,leaveOnUnload:a=!0})=>{let n=ye(()=>{let u,l=()=>{throw new Error("modifying store is not allowed")};if(e&&r)u={actions:e,store:D(I(E({},r),{setState:l,destroy:l}))},s&&(u.notifications=s),o&&(u.statsStore=D({getState:o.getState,subscribe:o.subscribe,setState:l,destroy:l}));else{let d=new Re;if(u={actions:d.getActions(),store:D(I(E({},d.getStore()),{setState:l,destroy:l})),notifications:d.getNotifications()},i){let f=d.getStats();u.statsStore=D({getState:f.getState,subscribe:f.subscribe,setState:l,destroy:l})}}return u.actions.setFrameworkInfo({type:"react-web",version:re.version,sdkVersion:process.env.REACT_SDK_VERSION}),u},[e,r,s,o,i]);F(()=>{if(O&&a){let u=()=>n.actions.leave();return window.addEventListener("unload",u),()=>{window.removeEventListener("unload",u)}}return()=>{}},[a,n]);let c=!e&&!r;return F(()=>{if(!(!c||!O||!a))return()=>{n.actions.leave()}},[c,a,n]),re.createElement(x.Provider,{value:n},t)},m=ee(x),ke=te(x),v=()=>{let t=N(x);if(!t)throw new Error(R);return t.store},A=()=>{let t=N(x);if(!t)throw new Error(R);return t.notifications},g=()=>{let t=N(x);if(!t)throw new Error(R);return t.actions},W=t=>{let e=N(x),[r,s]=Ee(null);if(!e)throw new Error(R);return F(()=>e.notifications?e.notifications.onNotification(i=>{s(i)},t):void 0,[e.notifications,t]),r};import{useCallback as se,useMemo as Le}from"react";import{HMSRoomState as ie,selectIsConnectedToRoom as Oe,selectRoomState as Fe}from"@100mslive/hms-video-store";import{useEffect as Ie,useRef as Ae}from"react";import{parsedUserAgent as Ce}from"@100mslive/hms-video-store";var Ve="react-sdk",H=(t,e)=>b.e(Ve,e,t),De=t=>{throw t};function C(t){let e=Ae();return Ie(()=>{e.current=t}),e.current}var Ne=["blink"],k=Ne.some(t=>{var e,r;return((r=(e=Ce.getEngine())==null?void 0:e.name)==null?void 0:r.toLowerCase())===t}),oe="https://pdf-annotation.100ms.live/generic/web/viewer.html";var We=({name:t="",token:e,metadata:r,handleError:s=H,initEndpoint:o,initialSettings:i,captureNetworkQualityInPreview:a,asRole:n,autoManageVideo:c,autoManageWakeLock:u,iceServers:l})=>{let d=g(),f=m(Fe),S=m(Oe)||!1,h=f===ie.Preview,M=Le(()=>({userName:t,authToken:e,metaData:r,rememberDeviceSelection:!0,settings:i,initEndpoint:o,asRole:n,captureNetworkQualityInPreview:a,autoManageVideo:c,autoManageWakeLock:u,iceServers:l}),[t,e,r,o,i,a,n,c,u,l]),y=se(()=>p(null,null,function*(){if(e)try{(S||f!==ie.Disconnected)&&(yield d.leave().catch(()=>{})),yield d.preview(M)}catch(P){s(P,"preview")}}),[e,S,f,d,M,s]),w=se(()=>p(null,null,function*(){if(e)try{yield d.join(M)}catch(P){s(P,"join")}}),[d,M,s,e]);return{enableJoin:h,join:w,isConnected:S,preview:y}};import{useCallback as ne}from"react";import{selectIsAllowedToPreviewMedia as Be,selectIsAllowedToPublish as Ge,selectIsInPreview as qe,selectIsLocalAudioEnabled as Ue,selectIsLocalVideoEnabled as ze}from"@100mslive/hms-video-store";var je=(t=H)=>{let e=m(Ue),r=m(ze),o=m(qe)?Be:Ge,i=m(o),a=g(),n=ne(()=>p(null,null,function*(){try{yield a.setLocalAudioEnabled(!e)}catch(u){t(u,"toggleAudio")}}),[a,e,t]),c=ne(()=>p(null,null,function*(){try{yield a.setLocalVideoEnabled(!r)}catch(u){t(u,"toggleVideo")}}),[a,r,t]);return{isLocalAudioEnabled:e,isLocalVideoEnabled:r,toggleAudio:i!=null&&i.audio?n:void 0,toggleVideo:i!=null&&i.video?c:void 0}};import{useCallback as _e,useEffect as B,useRef as ae}from"react";import{selectVideoTrackByID as Je}from"@100mslive/hms-video-store";var $e=({trackId:t,attach:e})=>{let r=g(),s=ae(null),o=m(Je(t)),i=ae(),a=_e(n=>{n&&(s.current=n)},[]);return B(()=>{i.current?o!=null&&o.id&&i.current!==(o==null?void 0:o.id)&&p(null,null,function*(){if(s.current)try{b.d("detaching because different track is passed"),yield r.detachVideo(i.current,s.current)}catch(n){b.w("detach video error for track",i.current,n)}i.current=o==null?void 0:o.id}):i.current=o==null?void 0:o.id},[o==null?void 0:o.id,r]),B(()=>{p(null,null,function*(){o!=null&&o.id&&s.current&&(e!==!1?yield r.attachVideo(o.id,s.current):yield r.detachVideo(o.id,s.current))})},[o,e,r]),B(()=>()=>{p(null,null,function*(){if(s.current&&o)try{yield r.detachVideo(o.id,s.current)}catch(n){b.w("detach video error for track",o.id,n)}})},[]),{videoRef:a}};import{useCallback as Ye}from"react";import{selectIsLocalScreenShared as Ke,selectPeerScreenSharing as Qe,selectScreenSharesByPeerId as Xe}from"@100mslive/hms-video-store";var V=(t=H)=>{var a,n;let e=g(),r=m(Ke),s=m(Qe),o=m(Xe(s==null?void 0:s.id)),i=Ye(c=>p(null,null,function*(){try{yield e.setScreenShareEnabled(!r,c)}catch(u){t(u,"toggleScreenShare")}}),[e,r,t]);return{amIScreenSharing:r,screenSharingPeerId:s==null?void 0:s.id,screenSharingPeerName:s==null?void 0:s.name,screenShareVideoTrackId:(a=o==null?void 0:o.video)==null?void 0:a.id,screenShareAudioTrackId:(n=o==null?void 0:o.audio)==null?void 0:n.id,toggleScreenShare:i}};import{useCallback as G}from"react";import{selectAudioTrackByID as Ze,selectAudioTrackVolume as et,selectPermissions as tt,selectVideoTrackByID as rt}from"@100mslive/hms-video-store";var ce=(t,e,r)=>p(null,null,function*(){if(e)try{yield t.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){r(s,"remoteToggle")}}),ot=(t,e,r=H)=>{let s=g(),o=m(Ze(t)),i=m(rt(e)),a=m(et(o==null?void 0:o.id)),n=m(tt),c=i!=null&&i.enabled?n==null?void 0:n.mute:n==null?void 0:n.unmute,u=o!=null&&o.enabled?n==null?void 0:n.mute:n==null?void 0:n.unmute,l=G(()=>p(null,null,function*(){yield ce(s,o,r)}),[s,o,r]),d=G(()=>p(null,null,function*(){yield ce(s,i,r)}),[s,r,i]),f=G(S=>{o&&s.setVolume(S,o.id)},[s,o]);return{isAudioEnabled:!!(o!=null&&o.enabled),isVideoEnabled:!!(i!=null&&i.enabled),volume:a,toggleAudio:o&&u?l:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&c?d:void 0,setVolume:o?f:void 0}};import{useMemo as z}from"react";import{useResizeDetector as ut}from"react-resize-detector";import{selectTracksMap as lt}from"@100mslive/hms-video-store";var st=(t,e,r)=>t.reduce((s,o,i)=>{let a=Math.floor(i/e);return a>0&&r||(s[a]||(s[a]=[]),s[a].push(o)),s},[]),ue=({elements:t,tilesInFirstPage:e,onlyOnePage:r,isLastPageDifferentFromFirstPage:s,defaultWidth:o,defaultHeight:i,lastPageWidth:a,lastPageHeight:n})=>{let c=st(t,e,r);return c.map((u,l)=>u.map(d=>{let f=l===c.length-1,S=s&&f?a:o,h=s&&f?n:i;return I(E({},d),{height:h,width:S})}))};function it(t){if(t.length===0)return null;let e={},r=t[0],s=1;for(let o=0;o<t.length;o++){let i=t[o];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(r=i,s=e[i])}return r}var le=t=>it(t.filter(e=>{var r,s;return((r=e.track)==null?void 0:r.width)&&((s=e.track)==null?void 0:s.height)}).map(e=>{var o,i;let r=(o=e.track)==null?void 0:o.width,s=(i=e.track)==null?void 0:i.height;return(r||1)/(s||1)})),q=(t,e,r,s,o)=>{if(t<0||e<0)throw new Error("Container must have a non-negative area");if(r<1||!Number.isInteger(r))throw new Error("Number of shapes to place must be a positive integer");let i=s&&o&&s/o;if(i!==void 0&&isNaN(i))throw new Error("Aspect ratio must be a number");let a={area:0,cols:0,rows:0,width:0,height:0},n=r,c=-1;if(i!==void 0)for(let u=n;u>0;u+=c){let l=Math.ceil(r/u),d=t/(u*i),f=e/l,S,h;d<=f?(S=t/u,h=S/i):(h=e/l,S=h*i);let M=S*h;M>a.area&&(a={area:M,width:S,height:h,rows:l,cols:u})}return a},nt=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,a=0,n=0,c=0,u=!1,l=0,d=0,f=Math.min(Math.ceil(Math.sqrt(r*(t/e)/(o.width/o.height))),s),S=t/f,h=S/(o.width/o.height);h>e&&(h=e,S=h/(o.height/o.width));let M=Math.floor(e/h);if(a=h,i=S,l=Math.min(r,M*f),d=r%(M*f),u=d>0&&r>M*f,u){let y=Math.min(Math.ceil(Math.sqrt(d*(t/e)/(o.width/o.height))),s),w=t/y,P=w/(o.width/o.height);P>e&&(P=e,w=P/(o.height/o.width)),c=P,n=w}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:a,lastPageWidth:n,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},at=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,a=0,n=0,c=0,u=!1,l=0,d=0,{width:f,height:S}=q(t,e,Math.min(r,s),o.width,o.height);if(i=f,a=S,l=Math.min(r,s),d=r%s,u=d>0&&r>s,u){let{width:h,height:M}=q(t,e,d,o.width,o.height);n=h,c=M}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:a,lastPageWidth:n,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}},ct=({parentWidth:t,parentHeight:e,count:r,maxCount:s,aspectRatio:o})=>{let i=0,a=0,n=0,c=0,u=!1,l=0,d=0,f=Math.min(Math.ceil(Math.sqrt(r*(o.width/o.height)/(t/e))),s),S=e/f,h=S*(o.width/o.height),M=Math.floor(t/h);if(i=h,a=S,l=Math.min(r,f*M),d=r%(f*M),u=d>0&&r>f*M,u){let y=Math.min(Math.ceil(Math.sqrt(d*(o.width/o.height)/(t/e))),s),w=e/y,P=w*(o.width/o.height);c=w,n=P}return{tilesInFirstPage:l,defaultWidth:i,defaultHeight:a,lastPageWidth:n,lastPageHeight:c,isLastPageDifferentFromFirstPage:u}};function de({count:t,parentWidth:e,parentHeight:r,maxTileCount:s,maxRowCount:o,maxColCount:i,aspectRatio:a}){let n=0,c=0,u=0,l=0,d=!1,f=0;if(t===0)return{tilesInFirstPage:f,defaultWidth:n,defaultHeight:c,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d};if(s)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:c,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=at({parentWidth:e,parentHeight:r,count:t,maxCount:s,aspectRatio:a}));else if(o)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:c,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=ct({parentWidth:e,parentHeight:r,count:t,maxCount:o,aspectRatio:a}));else if(i)({tilesInFirstPage:f,defaultWidth:n,defaultHeight:c,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}=nt({parentWidth:e,parentHeight:r,count:t,maxCount:i,aspectRatio:a}));else{let{width:S,height:h}=q(e,r,t,a.width,a.height);n=S,c=h,f=t}return{tilesInFirstPage:f,defaultWidth:n,defaultHeight:c,lastPageWidth:u,lastPageHeight:l,isLastPageDifferentFromFirstPage:d}}var U=(t,e,r,s=!0)=>{if(!t||!e||!r)return[];let o=[];for(let i of t)if(i.videoTrack===void 0&&i.audioTrack&&e[i.audioTrack]?o.push({peer:i}):i.videoTrack&&e[i.videoTrack]?o.push({track:e[i.videoTrack],peer:i}):s||o.push({peer:i}),i.auxiliaryTracks.length>0&&i.auxiliaryTracks.forEach(n=>{let c=e[n];(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="regular"&&o.push({track:c,peer:i})}),r(i)&&i.auxiliaryTracks.length>0){let n=i.auxiliaryTracks.find(c=>{let u=e[c];return(u==null?void 0:u.type)==="video"&&(u==null?void 0:u.source)==="screen"});n&&o.push({track:e[n],peer:i})}return o};var dt={aspectRatio:{width:1,height:1}},mt=({peers:t,maxTileCount:e,maxColCount:r,maxRowCount:s,includeScreenShareForPeer:o=()=>!1,aspectRatio:i=dt.aspectRatio,filterNonPublishingPeers:a=!0,offsetY:n=0})=>{let{width:c=0,height:u=0,ref:l}=ut(),f=v().getState(lt),S=U(t,f,o,a),h=z(()=>i||{width:le(S)||1,height:1},[i,S]),M=S.length,{tilesInFirstPage:y,defaultWidth:w,defaultHeight:P,lastPageWidth:J,lastPageHeight:$,isLastPageDifferentFromFirstPage:Y}=z(()=>de({count:M,parentWidth:Math.floor(c),parentHeight:Math.floor(u)-Math.min(u,n),maxTileCount:e,maxRowCount:s,maxColCount:r,aspectRatio:h}),[M,c,u,e,s,r,h,n]);return{pagesWithTiles:z(()=>ue({elements:S,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:Y,defaultWidth:w,defaultHeight:P,lastPageWidth:J,lastPageHeight:$}),[S,y,Y,w,P,J,$]),ref:l}};import{useEffect as ft}from"react";import{selectTrackAudioByID as St}from"@100mslive/hms-video-store";function pt({trackId:t,getStyle:e,ref:r}){let s=v();ft(()=>s.subscribe(o=>{if(!r.current)return;let i=e(o);for(let a in i)r.current.style[a]=i[a]},St(t)),[e,r,s,t])}import{useCallback as ht}from"react";import{DeviceType as T,selectDevices as gt,selectIsAllowedToPreviewMedia as Mt,selectIsAllowedToPublish as Ht,selectIsInPreview as Pt,selectLocalMediaSettings as bt}from"@100mslive/hms-video-store";var wt=(t=H)=>{let e=g(),r=m(gt),s=m(bt),i=m(Pt)?Mt:Ht,a=m(i),n={[T.audioOutput]:s.audioOutputDeviceId},c={[T.audioOutput]:r.audioOutput};a.video&&(c[T.videoInput]=r.videoInput,n[T.videoInput]=s.videoInputDeviceId),a.audio&&(c[T.audioInput]=r.audioInput,n[T.audioInput]=s.audioInputDeviceId);let u=ht(f=>p(null,[f],function*({deviceType:l,deviceId:d}){try{switch(l){case T.audioInput:yield e.setAudioSettings({deviceId:d});break;case T.videoInput:yield e.setVideoSettings({deviceId:d});break;case T.audioOutput:yield e.setAudioOutputDevice(d);break}}catch(S){t(S,"updateDevices")}}),[t,e]);return{allDevices:c,selectedDeviceIDs:n,updateDevice:u}};import{useMemo as vt}from"react";import{selectIsConnectedToRoom as Tt,selectPeerCount as yt,selectPeers as Et,selectRemotePeers as Rt}from"@100mslive/hms-video-store";var me=t=>!t||!Array.isArray(t)||t.length===0?{}:t.reduce((e,r)=>(r.roleName&&(e[r.roleName]||(e[r.roleName]=[]),e[r.roleName].push(r)),e),{});var xt=()=>{let t=m(Tt),e=m(t?Et:Rt),r=m(yt),s=vt(()=>me(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:r,isConnected:t}};import{selectHLSState as kt,selectRecordingState as It,selectRTMPState as At}from"@100mslive/hms-video-store";var Ct=()=>{let t=m(It),e=m(At),r=m(kt),s=t.server.running,o=t.browser.running,i=t.hls.running,a=r.running||e.running,n=s||o||i;return{isServerRecordingOn:s,isBrowserRecordingOn:o,isHLSRecordingOn:i,isStreamingOn:a,isHLSRunning:r.running,isRTMPRunning:e.running,isRecordingOn:n}};import{useCallback as Vt,useEffect as Dt,useState as Nt}from"react";import{HMSNotificationTypes as Lt}from"@100mslive/hms-video-store";var Ot=()=>{let t=W(Lt.ERROR),[e,r]=Nt(""),s=g(),o=Vt(()=>p(null,null,function*(){yield s.unblockAudio()}),[s]);return Dt(()=>{(t==null?void 0:t.data.code)===3008&&r(t==null?void 0:t.data.message)},[t]),{error:e,unblockAudio:o,resetError:()=>r("")}};import{useCallback as Ft,useEffect as fe}from"react";import{HMSNotificationTypes as Wt}from"@100mslive/hms-video-store";var Bt=(t,e)=>e?JSON.stringify(t||""):t,Gt=({type:t,json:e=!0,onEvent:r,handleError:s=H})=>{let o=g(),i=A();return fe(()=>{o.ignoreMessageTypes([t])},[o,t]),fe(()=>i?i.onNotification(c=>{let u=c.data;if(u&&u.type===t)try{let l=e?JSON.parse(u.message):u.message;r==null||r(l)}catch(l){s(l,"handleCustomEvent")}},Wt.NEW_MESSAGE):void 0,[i,t,e,r,s]),{sendEvent:Ft((n,c)=>p(null,null,function*(){try{let u=Bt(n,e);c&&Array.isArray(c==null?void 0:c.roleNames)?yield o.sendGroupMessage(u,c.roleNames,t):typeof(c==null?void 0:c.peerId)=="string"?yield o.sendDirectMessage(u,c.peerId,t):yield o.sendBroadcastMessage(u,t),r==null||r(n)}catch(u){s(u,"sendCustomEvent")}}),[o,s,r,t,e])}};import{selectAvailableRoleNames as qt,selectIsConnectedToRoom as Ut,selectPeerCount as zt,selectPeerMetadata as jt,selectPeers as _t,selectRemotePeers as Jt}from"@100mslive/hms-video-store";var $t=t=>{var n;let e=m(Ut),r=m(zt),s=m(qt),o=m(e?_t:Jt),i=Array.from(new Set(o.map(c=>c.roleName))),a=v();if((n=t==null?void 0:t.metadata)!=null&&n.isHandRaised&&(o=o.filter(c=>a.getState(jt(c.id)).isHandRaised)),t!=null&&t.role&&s.includes(t.role)&&(o=o.filter(c=>c.roleName===t.role)),t!=null&&t.search){let c=t.search.toLowerCase();o=o.filter(u=>{var l;return((l=u.roleName)==null?void 0:l.toLowerCase().includes(c))||u.name.toLowerCase().includes(c)})}return{participants:o,isConnected:e,peerCount:r,rolesWithParticipants:i}};import{useCallback as j,useEffect as Yt,useRef as Se,useState as Kt}from"react";var Qt=t=>{let e=Se(null),[r,s]=Kt(!1),o=j(()=>{throw new Error("unable to start screen share")},[]),i=Se(!1),{amIScreenSharing:a,toggleScreenShare:n}=V(o),c=C(a),u=j(()=>p(null,null,function*(){a&&(yield n==null?void 0:n(),e.current=null)}),[a,n]),l=j(d=>p(null,null,function*(){if(!i.current){if(!d)throw new Error("URL not found");if(a)throw new Error("You are already sharing");if(!e.current)throw new Error("Attach a reference `iframeRef` to iframe for sharing");e.current.src=d,i.current=!0,s(!0),yield n==null?void 0:n({forceCurrentTab:k,cropElement:e.current,preferCurrentTab:k})}}),[a,n]);return Yt(()=>{c&&!a&&(t==null||t(),e.current&&(e.current.src=""),i.current=!1,s(!1))},[a,c,t]),{startEmbedShare:l,stopEmbedShare:u,iframeRef:e,isEmbedShareInProgress:r}};import{useCallback as L,useEffect as Xt,useRef as pe,useState as Zt}from"react";var er=t=>{let e=pe(null),[r,s]=Zt(!1),o=L(()=>{throw new Error("unable to start screen share")},[]),i=pe(!1),{amIScreenSharing:a,toggleScreenShare:n}=V(o),c=C(a),u=L(f=>{var S;e.current&&((S=e.current.contentWindow)==null||S.postMessage({theme:2,file:f},"*"))},[]),l=L(()=>p(null,null,function*(){a&&(yield n==null?void 0:n())}),[a,n]),d=L(f=>p(null,null,function*(){if(i.current)return;if(!f)throw new Error("File or url not found");if(a)throw new Error("You are already sharing");if(!e.current)throw new Error("Attach a reference `iframeRef` to iframe for sharing");e.current.src=`${oe}${typeof f=="string"?`?file=${f}`:""}`,e.current.onload=()=>{requestAnimationFrame(()=>{f instanceof File&&u(f)})},i.current=!0,s(!0);let S=window.self!==window.top;yield n==null?void 0:n({forceCurrentTab:k&&!S,cropElement:e.current,preferCurrentTab:k&&!S})}),[a,u,n]);return Xt(()=>{c&&!a&&(t==null||t(),e.current&&e.current.removeAttribute("src"),i.current=!1,s(!1))},[a,c,t]),{startPDFShare:d,stopPDFShare:l,iframeRef:e,isPDFShareInProgress:r}};import{useRef as tr,useState as he}from"react";var ge=t=>t.reduce((e,r)=>(e[r.id]=r,e),{}),rr=t=>{let e=g(),r=tr(e.getPeerListIterator(t)),[s,o]=he({}),[i,a]=he(0);return{loadPeers:()=>r.current.findPeers().then(n=>{o(ge(n)),a(r.current.getTotal())}),loadMorePeers:()=>r.current.next().then(n=>{o(c=>E(E({},c),ge(n))),a(r.current.getTotal())}),hasNext:()=>r.current.hasNext(),total:i,peers:Object.values(s)}};import{useCallback as or,useEffect as sr,useState as ir}from"react";import{selectAppData as nr,selectIsConnectedToRoom as ar,selectLocalPeer as cr,selectPermissions as ur,selectWhiteboard as lr}from"@100mslive/hms-video-store";var dr=(t=!1)=>{var S,h;let e=m(ar),r=(S=m(cr))==null?void 0:S.customerUserId,s=m(lr),o=m(nr("disableNotifications")),i=!!(s!=null&&s.open),a=(s==null?void 0:s.owner)===r,n=g(),[c,u]=ir(!1),l=(h=m(ur))==null?void 0:h.whiteboard,d=!!(l!=null&&l.includes("admin"));sr(()=>{e&&u(n.interactivityCenter.whiteboard.isEnabled)},[e,n]);let f=or(()=>p(null,null,function*(){!e||!d||(i?a&&(yield n.interactivityCenter.whiteboard.close()):yield n.interactivityCenter.whiteboard.open())}),[n,a,d,i,e]);return{open:i,token:s==null?void 0:s.token,endpoint:s==null?void 0:s.addr,isOwner:a,isAdmin:d,zoomToContent:o||t,toggle:c&&d?f:void 0}};import{useCallback as Me}from"react";import{selectLocalPeerRoleName as mr}from"@100mslive/hms-video-store";var fr=()=>{let t=v(),e=Me(()=>p(null,null,function*(){if(!("Notification"in window)||navigator.webdriver){console.debug("Request Permsissions : Notifications not supported or headless browser");return}if((Notification==null?void 0:Notification.permission)==="granted"||(Notification==null?void 0:Notification.permission)==="denied")return;let s=t.subscribe(o=>p(null,null,function*(){o&&o!=="__internal_recorder"&&(yield Notification.requestPermission(),s==null||s())}),mr)}),[t]),r=Me((s,o)=>{if(!("Notification"in window)){console.debug("Show Notifications: Notifications not supported or headless browser");return}if((Notification==null?void 0:Notification.permission)==="denied"||document.visibilityState==="visible"&&document.hasFocus())return;let i=new Notification(s,o),a=()=>{document.visibilityState==="visible"&&document.hasFocus()&&(i==null||i.close(),document.removeEventListener("visibilitychange",a))};document.addEventListener("visibilitychange",a)},[]);return{requestPermission:e,showNotification:r}};import{useEffect as Sr}from"react";import{HMSNotificationTypes as pr}from"@100mslive/hms-video-store";var hr=({onTranscript:t,handleError:e=H})=>{let r="hms_transcript",s=A();Sr(()=>s?s.onNotification(i=>{let a=i.data;if(a&&a.type===r)try{let c=JSON.parse(a.message).results;t==null||t(c)}catch(n){e(n,"handleCaptionEvent")}},pr.NEW_MESSAGE):void 0,[s,r,e,t])};import{HMSAudioMode as _,selectLocalMediaSettings as gr}from"@100mslive/hms-video-store";var Mr=()=>{let t=g(),{audioMode:e}=m(gr),r=e===_.MUSIC;return{toggleMusicMode:()=>p(null,null,function*(){return yield t.setAudioSettings({audioMode:r?_.VOICE:_.MUSIC})}),isMusicModeEnabled:r}};export*from"@100mslive/hms-video-store";export{xe as HMSRoomProvider,U as getPeersWithTiles,De as throwErrorHandler,je as useAVToggle,pt as useAudioLevelStyles,Mr as useAudioMode,Ot as useAutoplayError,fr as useAwayNotifications,Gt as useCustomEvent,wt as useDevices,Qt as useEmbedShare,g as useHMSActions,W as useHMSNotifications,ke as useHMSStatsStore,m as useHMSStore,A as useHMSVanillaNotifications,v as useHMSVanillaStore,er as usePDFShare,rr as usePaginatedParticipants,xt as useParticipantList,$t as useParticipants,We as usePreviewJoin,Ct as useRecordingStreaming,ot as useRemoteAVToggle,V as useScreenShare,hr as useTranscript,$e as useVideo,mt as useVideoList,dr as useWhiteboard};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|