@100mslive/react-sdk 0.0.10 → 0.0.11-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Je=Object.create;var G=Object.defineProperty,Ue=Object.defineProperties,_e=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,Xe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var ae=(t,e,o)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,q=(t,e)=>{for(var o in e||(e={}))ne.call(e,o)&&ae(t,o,e[o]);if(ie)for(var o of ie(e))Ye.call(e,o)&&ae(t,o,e[o]);return t},j=(t,e)=>Ue(t,Ke(e)),ce=t=>G(t,"__esModule",{value:!0});var Ze=(t,e)=>{ce(t);for(var o in e)G(t,o,{get:e[o],enumerable:!0})},H=(t,e,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qe(e))!ne.call(t,s)&&s!=="default"&&G(t,s,{get:()=>e[s],enumerable:!(o=_e(e,s))||o.enumerable});return t},m=t=>H(ce(G(t!=null?Je(Xe(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var g=(t,e,o)=>new Promise((s,r)=>{var i=u=>{try{a(o.next(u))}catch(c){r(c)}},n=u=>{try{a(o.throw(u))}catch(c){r(c)}},a=u=>u.done?s(u.value):Promise.resolve(u.value).then(i,n);a((o=o.apply(t,e)).next())});Ze(exports,{DeviceType:()=>R,HMSRoomProvider:()=>Se,throwErrorHandler:()=>he,useAVToggle:()=>ge,useAudioLevelStyles:()=>De,useAutoplayError:()=>Ge,useCustomEvent:()=>je,useDevices:()=>Ne,useHMSActions:()=>M,useHMSNotifications:()=>Q,useHMSStatsStore:()=>fe,useHMSStore:()=>l,useHMSVanillaNotifications:()=>K,useHMSVanillaStore:()=>N,useParticipantList:()=>Fe,usePreviewJoin:()=>pe,useRecordingStreaming:()=>Be,useRemoteAVToggle:()=>Pe,useScreenShare:()=>ke,useVideo:()=>ve,useVideoList:()=>Ae});var b=m(require("react")),de=m(require("@100mslive/hms-video-store")),J=m(require("zustand"));var Z=m(require("react")),$=m(require("zustand/shallow"));var k;(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"})(k||(k={}));var P=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}}}};P.level=0;var I="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 ue(t){return(o,s=$.default)=>{o||P.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Z.useContext)(t);if(!r)throw new Error(I);return r.store(o,s)}}function le(t){return(o,s=$.default)=>{o||P.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Z.useContext)(t);if(!r)throw new Error(I);let i=r.statsStore;return i==null?void 0:i(o,s)}}var me=typeof window!="undefined";var A=(0,b.createContext)(null),y,Se=({children:t,actions:e,store:o,notifications:s,stats:r,isHMSStatsOn:i=!1})=>{if(!y){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&o)y={actions:e,store:(0,J.default)(j(q({},o),{setState:n,destroy:n}))},s&&(y.notifications=s),r&&(y.statsStore=(0,J.default)({getState:r.getState,subscribe:r.subscribe,setState:n,destroy:n}));else{let a=new de.HMSReactiveStore;if(y={actions:a.getActions(),store:(0,J.default)(j(q({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let u=a.getStats();y.statsStore=(0,J.default)({getState:u.getState,subscribe:u.subscribe,setState:n,destroy:n})}}}return(0,b.useEffect)(()=>{me&&(window.addEventListener("beforeunload",()=>y.actions.leave()),window.addEventListener("onunload",()=>y.actions.leave()))},[]),b.default.createElement(A.Provider,{value:y},t)},l=ue(A),fe=le(A),N=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.store},K=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.notifications},M=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.actions},Q=t=>{let e=(0,b.useContext)(A),[o,s]=(0,b.useState)(null);if(!e)throw new Error(I);return(0,b.useEffect)(()=>e.notifications?e.notifications.onNotification(i=>s(i),t):void 0,[e.notifications,t]),o};var V=m(require("@100mslive/hms-video-store")),U=m(require("react"));var $e="react-sdk",w=(t,e)=>P.e($e,e,t),he=t=>{throw t};var pe=({name:t="",token:e,metadata:o,handleError:s=w,initEndpoint:r,initialSettings:i})=>{let n=M(),a=l(V.selectRoomState),u=l(V.selectIsConnectedToRoom)||!1,c=a===V.HMSRoomState.Preview,S=(0,U.useMemo)(()=>({userName:t,authToken:e,metaData:o,rememberDeviceSelection:!0,settings:i,initEndpoint:r}),[t,e,o,r,i]),h=(0,U.useCallback)(()=>{(()=>g(void 0,null,function*(){if(!!e){a!==V.HMSRoomState.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(d){s(d,"preview")}}}))()},[n,s,e,a,S]),f=(0,U.useCallback)(()=>{if(!!e)try{n.join(S)}catch(d){s(d,"join")}},[n,S,s,e]);return{enableJoin:c,join:f,isConnected:u,preview:h}};var L=m(require("@100mslive/hms-video-store")),ee=m(require("react"));var ge=(t=w)=>{let e=l(L.selectIsLocalAudioEnabled),o=l(L.selectIsLocalVideoEnabled),s=l(L.selectIsAllowedToPublish),r=M(),i=(0,ee.useCallback)(()=>g(void 0,null,function*(){try{yield r.setLocalAudioEnabled(!e)}catch(a){t(a,"toggleAudio")}}),[r,e,t]),n=(0,ee.useCallback)(()=>g(void 0,null,function*(){try{yield r.setLocalVideoEnabled(!o)}catch(a){t(a,"toggleVideo")}}),[r,o,t]);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}};var He=m(require("@100mslive/hms-video-store")),C=m(require("react")),Me=m(require("react-intersection-observer"));var ve=({trackId:t,attach:e})=>{let o=M(),s=(0,C.useRef)(null),r=l((0,He.selectTrackByID)(t)),{ref:i,inView:n}=(0,Me.useInView)({threshold:.5}),a=(0,C.useCallback)(u=>{s.current=u,i(u)},[i]);return(0,C.useEffect)(()=>{(()=>g(void 0,null,function*(){s.current&&(r==null?void 0:r.id)&&(n&&r.enabled&&e!==!1?yield o.attachVideo(r.id,s.current):yield o.detachVideo(r.id,s.current))}))()},[o,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,C.useEffect)(()=>()=>{(()=>g(void 0,null,function*(){if(s.current&&r)try{yield o.detachVideo(r.id,s.current)}catch(u){P.w("detach video error for track",r.id,u)}}))()},[]),{videoRef:a}};var W=m(require("@100mslive/hms-video-store"));var be=m(require("react")),et=t=>console.log("Error: ",t),ke=(t=et)=>{var n,a;let e=M(),o=l(W.selectIsLocalScreenShared),s=l(W.selectPeerScreenSharing),r=l((0,W.selectScreenSharesByPeerId)(s==null?void 0:s.id)),i=(0,be.useCallback)((u=!1)=>g(void 0,null,function*(){try{yield e.setScreenShareEnabled(!o,u)}catch(c){t(c)}}),[e,o,t]);return{amIScreenSharing:o,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 D=m(require("@100mslive/hms-video-store"));var X=m(require("react"));var Re=(t,e,o)=>g(void 0,null,function*(){if(e)try{yield t.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){o(s,"remoteToggle")}}),Pe=(t,e,o=w)=>{let s=M(),r=l((0,D.selectTrackByID)(t)),i=l((0,D.selectTrackByID)(e)),n=l((0,D.selectAudioTrackVolume)(r==null?void 0:r.id)),a=l(D.selectPermissions),u=(i==null?void 0:i.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=(0,X.useCallback)(()=>g(void 0,null,function*(){yield Re(s,r,o)}),[s,r,o]),h=(0,X.useCallback)(()=>g(void 0,null,function*(){yield Re(s,i,o)}),[s,o,i]),f=(0,X.useCallback)(d=>{r&&s.setVolume(d,r.id)},[s,r]);return{isAudioEnabled:!!(r==null?void 0:r.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:r&&c?S:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&u?h:void 0,setVolume:r?f:void 0}};var Ee=m(require("@100mslive/hms-video-store")),Y=m(require("react"));var tt=(t,e,o)=>t.reduce((s,r,i)=>{let n=Math.floor(i/e);return n>0&&o||(s[n]||(s[n]=[]),s[n].push(r)),s},[]),we=({elements:t,tilesInFirstPage:e,onlyOnePage:o,isLastPageDifferentFromFirstPage:s,defaultWidth:r,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let u=tt(t,e,o);return u.map((c,S)=>c.map(h=>{let f=S===u.length-1,d=s&&f?n:r,p=s&&f?a:i;return j(q({},h),{height:p,width:d})}))};function ot(t){if(t.length===0)return null;let e={},o=t[0],s=1;for(let r=0;r<t.length;r++){let i=t[r];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(o=i,s=e[i])}return o}var Te=t=>ot(t.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 r,i;let o=(r=e.track)==null?void 0:r.width,s=(i=e.track)==null?void 0:i.height;return(o||1)/(s||1)})),te=(t,e,o,s,r)=>{if(t<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&&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=o,u=-1;if(i!==void 0)for(let c=a;c>0;c+=u){let S=Math.ceil(o/c),h=t/(c*i),f=e/S,d,p;h<=f?(d=t/c,p=d/i):(p=e/S,d=p*i);let v=d*p;v>n.area&&(n={area:v,width:d,height:p,rows:S,cols:c})}return n},rt=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,f=Math.min(Math.ceil(Math.sqrt(o*(t/e)/(r.width/r.height))),s),d=t/f,p=d/(r.width/r.height);p>e&&(p=e,d=p/(r.height/r.width));let v=Math.floor(e/p);if(n=p,i=d,S=Math.min(o,v*f),h=o%(v*f),c=h>0&&o>v*f,c){let O=Math.min(Math.ceil(Math.sqrt(h*(t/e)/(r.width/r.height))),s),T=t/O,x=T/(r.width/r.height);x>e&&(x=e,T=x/(r.height/r.width)),u=x,a=T}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},st=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,{width:f,height:d}=te(t,e,Math.min(o,s),r.width,r.height);if(i=f,n=d,S=Math.min(o,s),h=o%s,c=h>0&&o>s,c){let{width:p,height:v}=te(t,e,h,r.width,r.height);a=p,u=v}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},it=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,f=Math.min(Math.ceil(Math.sqrt(o*(r.width/r.height)/(t/e))),s),d=e/f,p=d*(r.width/r.height),v=Math.floor(t/p);if(i=p,n=d,S=Math.min(o,f*v),h=o%(f*v),c=h>0&&o>f*v,c){let O=Math.min(Math.ceil(Math.sqrt(h*(r.width/r.height)/(t/e))),s),T=e/O,x=T*(r.width/r.height);u=T,a=x}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}};function xe({count:t,parentWidth:e,parentHeight:o,maxTileCount:s,maxRowCount:r,maxColCount:i,aspectRatio:n}){let a=0,u=0,c=0,S=0,h=!1,f=0;if(t===0)return{tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h};if(s)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=st({parentWidth:e,parentHeight:o,count:t,maxCount:s,aspectRatio:n}));else if(r)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=it({parentWidth:e,parentHeight:o,count:t,maxCount:r,aspectRatio:n}));else if(i)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=rt({parentWidth:e,parentHeight:o,count:t,maxCount:i,aspectRatio:n}));else{let{width:d,height:p}=te(e,o,t,n.width,n.height);a=d,u=p,f=t}return{tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}}var ye=(t,e,o,s=!0)=>{if(!t||!e||!o)return[];let r=[];for(let i of t)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}),o(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(u=>{let c=e[u];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&r.push({track:e[a],peer:i})}return r};var Ie=m(require("react-resize-detector")),nt={aspectRatio:{width:1,height:1}},Ae=({peers:t,maxTileCount:e,maxColCount:o,maxRowCount:s,includeScreenShareForPeer:r=()=>!1,aspectRatio:i=nt.aspectRatio,filterNonPublishingPeers:n=!0,offsetY:a=0})=>{let{width:u=0,height:c=0,ref:S}=(0,Ie.useResizeDetector)(),f=N().getState(Ee.selectTracksMap),d=ye(t,f,r,n),p=(0,Y.useMemo)(()=>i||{width:Te(d)||1,height:1},[i,d]),v=d.length,{tilesInFirstPage:O,defaultWidth:T,defaultHeight:x,lastPageWidth:oe,lastPageHeight:re,isLastPageDifferentFromFirstPage:se}=(0,Y.useMemo)(()=>xe({count:v,parentWidth:Math.floor(u),parentHeight:Math.floor(c)-Math.min(c,a),maxTileCount:e,maxRowCount:s,maxColCount:o,aspectRatio:p}),[v,u,c,e,s,o,p,a]);return{pagesWithTiles:(0,Y.useMemo)(()=>we({elements:d,tilesInFirstPage:O,onlyOnePage:!1,isLastPageDifferentFromFirstPage:se,defaultWidth:T,defaultHeight:x,lastPageWidth:oe,lastPageHeight:re}),[d,O,se,T,x,oe,re]),ref:S}};var Ve=m(require("react")),Ce=m(require("@100mslive/hms-video-store"));function De({trackId:t,getStyle:e,ref:o}){let s=N();(0,Ve.useEffect)(()=>s.subscribe(r=>{if(!o.current)return;let i=e(r);for(let n in i)o.current.style[n]=i[n]},(0,Ce.selectTrackAudioByID)(t)),[e,o,s,t])}var F=m(require("@100mslive/hms-video-store")),Oe=m(require("react"));var R;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(R||(R={}));var Ne=(t=w)=>{let e=M(),o=l(F.selectDevices),s=l(F.selectLocalMediaSettings),r=l(F.selectIsAllowedToPublish),i={[R.audioOutput]:s.audioOutputDeviceId},n={[R.audioOutput]:o.audioOutput};r.video&&(n[R.videoInput]=o.videoInput,i[R.videoInput]=s.videoInputDeviceId),r.audio&&(n[R.audioInput]=o.audioInput,i[R.audioInput]=s.audioInputDeviceId);let a=(0,Oe.useCallback)(S=>g(void 0,[S],function*({deviceType:u,deviceId:c}){try{switch(u){case R.audioInput:yield e.setAudioSettings({deviceId:c});break;case R.videoInput:yield e.setVideoSettings({deviceId:c});break;case R.audioOutput:e.setAudioOutputDevice(c);break}}catch(h){t(h,"updateDevices")}}),[t,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};var We=m(require("react")),E=m(require("@100mslive/hms-video-store"));var Le=t=>!t||!Array.isArray(t)||t.length===0?{}:t.reduce((e,o)=>(o.roleName&&(e[o.roleName]||(e[o.roleName]=[]),e[o.roleName].push(o)),e),{});var Fe=()=>{let t=l(E.selectIsConnectedToRoom),e=l(t?E.selectPeers:E.selectRemotePeers),o=l(E.selectPeerCount),s=(0,We.useMemo)(()=>Le(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:o,isConnected:t}};var B=m(require("@100mslive/hms-video-store"));var Be=()=>{let t=l(B.selectRecordingState),e=l(B.selectRTMPState),o=l(B.selectHLSState),s=t.server.running,r=t.browser.running,i=t.hls.running,n=o.running||e.running,a=s||r||i;return{isServerRecordingOn:s,isBrowserRecordingOn:r,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:o.running,isRTMPRunning:e.running,isRecordingOn:a}};var z=m(require("react")),ze=m(require("@100mslive/hms-video-store"));var Ge=()=>{let t=Q(ze.HMSNotificationTypes.ERROR),[e,o]=(0,z.useState)(""),s=M(),r=(0,z.useCallback)(()=>g(void 0,null,function*(){yield s.unblockAudio()}),[s]);return(0,z.useEffect)(()=>{(t==null?void 0:t.data.code)===3008&&o(t==null?void 0:t.data.message)},[t]),{error:e,unblockAudio:r,resetError:()=>o("")}};var _=m(require("react")),qe=m(require("@100mslive/hms-video-store"));var je=({type:t,onEvent:e,handleError:o=w})=>{let s=M(),r=K();return(0,_.useEffect)(()=>{s.ignoreMessageTypes([t])},[s,t]),(0,_.useEffect)(()=>r?r.onNotification(a=>{let u=a.data;if(u&&u.type===t)try{let c=JSON.parse(u.message);e==null||e(c)}catch(c){o(c,"handleCustomEvent")}},qe.HMSNotificationTypes.NEW_MESSAGE):void 0,[r,t,e,o]),{sendEvent:(0,_.useCallback)(n=>g(void 0,null,function*(){try{let a=JSON.stringify(n||"");yield s.sendBroadcastMessage(a,t),e==null||e(n)}catch(a){o(a,"sendCustomEvent")}}),[s,o,e,t])}};H(exports,m(require("@100mslive/hms-video-store")));
|
|
1
|
+
var Je=Object.create;var G=Object.defineProperty,Ue=Object.defineProperties,_e=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,Xe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var ae=(t,e,o)=>e in t?G(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,q=(t,e)=>{for(var o in e||(e={}))ne.call(e,o)&&ae(t,o,e[o]);if(ie)for(var o of ie(e))Ye.call(e,o)&&ae(t,o,e[o]);return t},j=(t,e)=>Ue(t,Ke(e)),ce=t=>G(t,"__esModule",{value:!0});var Ze=(t,e)=>{ce(t);for(var o in e)G(t,o,{get:e[o],enumerable:!0})},H=(t,e,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qe(e))!ne.call(t,s)&&s!=="default"&&G(t,s,{get:()=>e[s],enumerable:!(o=_e(e,s))||o.enumerable});return t},m=t=>H(ce(G(t!=null?Je(Xe(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var g=(t,e,o)=>new Promise((s,r)=>{var i=u=>{try{a(o.next(u))}catch(c){r(c)}},n=u=>{try{a(o.throw(u))}catch(c){r(c)}},a=u=>u.done?s(u.value):Promise.resolve(u.value).then(i,n);a((o=o.apply(t,e)).next())});Ze(exports,{DeviceType:()=>R,HMSRoomProvider:()=>Se,throwErrorHandler:()=>he,useAVToggle:()=>ge,useAudioLevelStyles:()=>De,useAutoplayError:()=>Ge,useCustomEvent:()=>je,useDevices:()=>Ne,useHMSActions:()=>M,useHMSNotifications:()=>Q,useHMSStatsStore:()=>fe,useHMSStore:()=>l,useHMSVanillaNotifications:()=>K,useHMSVanillaStore:()=>N,useParticipantList:()=>Fe,usePreviewJoin:()=>pe,useRecordingStreaming:()=>Be,useRemoteAVToggle:()=>Pe,useScreenShare:()=>ke,useVideo:()=>ve,useVideoList:()=>Ae});var b=m(require("react")),de=m(require("@100mslive/hms-video-store")),J=m(require("zustand"));var Z=m(require("react")),$=m(require("zustand/shallow"));var k;(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"})(k||(k={}));var w=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}}}};w.level=0;var I="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 ue(t){return(o,s=$.default)=>{o||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Z.useContext)(t);if(!r)throw new Error(I);return r.store(o,s)}}function le(t){return(o,s=$.default)=>{o||w.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let r=(0,Z.useContext)(t);if(!r)throw new Error(I);let i=r.statsStore;return i==null?void 0:i(o,s)}}var me=typeof window!="undefined";var A=(0,b.createContext)(null),y,Se=({children:t,actions:e,store:o,notifications:s,stats:r,isHMSStatsOn:i=!1})=>{if(!y){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&o)y={actions:e,store:(0,J.default)(j(q({},o),{setState:n,destroy:n}))},s&&(y.notifications=s),r&&(y.statsStore=(0,J.default)({getState:r.getState,subscribe:r.subscribe,setState:n,destroy:n}));else{let a=new de.HMSReactiveStore;if(y={actions:a.getActions(),store:(0,J.default)(j(q({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let u=a.getStats();y.statsStore=(0,J.default)({getState:u.getState,subscribe:u.subscribe,setState:n,destroy:n})}}}return(0,b.useEffect)(()=>{me&&(window.addEventListener("beforeunload",()=>y.actions.leave()),window.addEventListener("onunload",()=>y.actions.leave()))},[]),b.default.createElement(A.Provider,{value:y},t)},l=ue(A),fe=le(A),N=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.store},K=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.notifications},M=()=>{let t=(0,b.useContext)(A);if(!t)throw new Error(I);return t.actions},Q=t=>{let e=(0,b.useContext)(A),[o,s]=(0,b.useState)(null);if(!e)throw new Error(I);return(0,b.useEffect)(()=>e.notifications?e.notifications.onNotification(i=>s(i),t):void 0,[e.notifications,t]),o};var V=m(require("@100mslive/hms-video-store")),U=m(require("react"));var $e="react-sdk",P=(t,e)=>w.e($e,e,t),he=t=>{throw t};var pe=({name:t="",token:e,metadata:o,handleError:s=P,initEndpoint:r,initialSettings:i})=>{let n=M(),a=l(V.selectRoomState),u=l(V.selectIsConnectedToRoom)||!1,c=a===V.HMSRoomState.Preview,S=(0,U.useMemo)(()=>({userName:t,authToken:e,metaData:o,rememberDeviceSelection:!0,settings:i,initEndpoint:r}),[t,e,o,r,i]),h=(0,U.useCallback)(()=>{(()=>g(void 0,null,function*(){if(!!e){a!==V.HMSRoomState.Disconnected&&(yield n.leave());try{yield n.preview(S)}catch(d){s(d,"preview")}}}))()},[n,s,e,a,S]),f=(0,U.useCallback)(()=>{if(!!e)try{n.join(S)}catch(d){s(d,"join")}},[n,S,s,e]);return{enableJoin:c,join:f,isConnected:u,preview:h}};var L=m(require("@100mslive/hms-video-store")),ee=m(require("react"));var ge=(t=P)=>{let e=l(L.selectIsLocalAudioEnabled),o=l(L.selectIsLocalVideoEnabled),s=l(L.selectIsAllowedToPublish),r=M(),i=(0,ee.useCallback)(()=>g(void 0,null,function*(){try{yield r.setLocalAudioEnabled(!e)}catch(a){t(a,"toggleAudio")}}),[r,e,t]),n=(0,ee.useCallback)(()=>g(void 0,null,function*(){try{yield r.setLocalVideoEnabled(!o)}catch(a){t(a,"toggleVideo")}}),[r,o,t]);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}};var He=m(require("@100mslive/hms-video-store")),C=m(require("react")),Me=m(require("react-intersection-observer"));var ve=({trackId:t,attach:e})=>{let o=M(),s=(0,C.useRef)(null),r=l((0,He.selectTrackByID)(t)),{ref:i,inView:n}=(0,Me.useInView)({threshold:.5}),a=(0,C.useCallback)(u=>{s.current=u,i(u)},[i]);return(0,C.useEffect)(()=>{(()=>g(void 0,null,function*(){s.current&&(r==null?void 0:r.id)&&(n&&r.enabled&&e!==!1?yield o.attachVideo(r.id,s.current):yield o.detachVideo(r.id,s.current))}))()},[o,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,C.useEffect)(()=>()=>{(()=>g(void 0,null,function*(){if(s.current&&r)try{yield o.detachVideo(r.id,s.current)}catch(u){w.w("detach video error for track",r.id,u)}}))()},[]),{videoRef:a}};var W=m(require("@100mslive/hms-video-store"));var be=m(require("react"));var ke=(t=P)=>{var n,a;let e=M(),o=l(W.selectIsLocalScreenShared),s=l(W.selectPeerScreenSharing),r=l((0,W.selectScreenSharesByPeerId)(s==null?void 0:s.id)),i=(0,be.useCallback)((u=!1)=>g(void 0,null,function*(){try{yield e.setScreenShareEnabled(!o,u)}catch(c){t(c,"toggleScreenShare")}}),[e,o,t]);return{amIScreenSharing:o,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 D=m(require("@100mslive/hms-video-store"));var X=m(require("react"));var Re=(t,e,o)=>g(void 0,null,function*(){if(e)try{yield t.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){o(s,"remoteToggle")}}),Pe=(t,e,o=P)=>{let s=M(),r=l((0,D.selectTrackByID)(t)),i=l((0,D.selectTrackByID)(e)),n=l((0,D.selectAudioTrackVolume)(r==null?void 0:r.id)),a=l(D.selectPermissions),u=(i==null?void 0:i.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=(0,X.useCallback)(()=>g(void 0,null,function*(){yield Re(s,r,o)}),[s,r,o]),h=(0,X.useCallback)(()=>g(void 0,null,function*(){yield Re(s,i,o)}),[s,o,i]),f=(0,X.useCallback)(d=>{r&&s.setVolume(d,r.id)},[s,r]);return{isAudioEnabled:!!(r==null?void 0:r.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:r&&c?S:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&u?h:void 0,setVolume:r?f:void 0}};var Ee=m(require("@100mslive/hms-video-store")),Y=m(require("react"));var et=(t,e,o)=>t.reduce((s,r,i)=>{let n=Math.floor(i/e);return n>0&&o||(s[n]||(s[n]=[]),s[n].push(r)),s},[]),we=({elements:t,tilesInFirstPage:e,onlyOnePage:o,isLastPageDifferentFromFirstPage:s,defaultWidth:r,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let u=et(t,e,o);return u.map((c,S)=>c.map(h=>{let f=S===u.length-1,d=s&&f?n:r,p=s&&f?a:i;return j(q({},h),{height:p,width:d})}))};function tt(t){if(t.length===0)return null;let e={},o=t[0],s=1;for(let r=0;r<t.length;r++){let i=t[r];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(o=i,s=e[i])}return o}var Te=t=>tt(t.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 r,i;let o=(r=e.track)==null?void 0:r.width,s=(i=e.track)==null?void 0:i.height;return(o||1)/(s||1)})),te=(t,e,o,s,r)=>{if(t<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&&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=o,u=-1;if(i!==void 0)for(let c=a;c>0;c+=u){let S=Math.ceil(o/c),h=t/(c*i),f=e/S,d,p;h<=f?(d=t/c,p=d/i):(p=e/S,d=p*i);let v=d*p;v>n.area&&(n={area:v,width:d,height:p,rows:S,cols:c})}return n},ot=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,f=Math.min(Math.ceil(Math.sqrt(o*(t/e)/(r.width/r.height))),s),d=t/f,p=d/(r.width/r.height);p>e&&(p=e,d=p/(r.height/r.width));let v=Math.floor(e/p);if(n=p,i=d,S=Math.min(o,v*f),h=o%(v*f),c=h>0&&o>v*f,c){let O=Math.min(Math.ceil(Math.sqrt(h*(t/e)/(r.width/r.height))),s),T=t/O,x=T/(r.width/r.height);x>e&&(x=e,T=x/(r.height/r.width)),u=x,a=T}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},rt=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,{width:f,height:d}=te(t,e,Math.min(o,s),r.width,r.height);if(i=f,n=d,S=Math.min(o,s),h=o%s,c=h>0&&o>s,c){let{width:p,height:v}=te(t,e,h,r.width,r.height);a=p,u=v}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},st=({parentWidth:t,parentHeight:e,count:o,maxCount:s,aspectRatio:r})=>{let i=0,n=0,a=0,u=0,c=!1,S=0,h=0,f=Math.min(Math.ceil(Math.sqrt(o*(r.width/r.height)/(t/e))),s),d=e/f,p=d*(r.width/r.height),v=Math.floor(t/p);if(i=p,n=d,S=Math.min(o,f*v),h=o%(f*v),c=h>0&&o>f*v,c){let O=Math.min(Math.ceil(Math.sqrt(h*(r.width/r.height)/(t/e))),s),T=e/O,x=T*(r.width/r.height);u=T,a=x}return{tilesInFirstPage:S,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}};function xe({count:t,parentWidth:e,parentHeight:o,maxTileCount:s,maxRowCount:r,maxColCount:i,aspectRatio:n}){let a=0,u=0,c=0,S=0,h=!1,f=0;if(t===0)return{tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h};if(s)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=rt({parentWidth:e,parentHeight:o,count:t,maxCount:s,aspectRatio:n}));else if(r)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=st({parentWidth:e,parentHeight:o,count:t,maxCount:r,aspectRatio:n}));else if(i)({tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}=ot({parentWidth:e,parentHeight:o,count:t,maxCount:i,aspectRatio:n}));else{let{width:d,height:p}=te(e,o,t,n.width,n.height);a=d,u=p,f=t}return{tilesInFirstPage:f,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:S,isLastPageDifferentFromFirstPage:h}}var ye=(t,e,o,s=!0)=>{if(!t||!e||!o)return[];let r=[];for(let i of t)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}),o(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(u=>{let c=e[u];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&r.push({track:e[a],peer:i})}return r};var Ie=m(require("react-resize-detector")),it={aspectRatio:{width:1,height:1}},Ae=({peers:t,maxTileCount:e,maxColCount:o,maxRowCount:s,includeScreenShareForPeer:r=()=>!1,aspectRatio:i=it.aspectRatio,filterNonPublishingPeers:n=!0,offsetY:a=0})=>{let{width:u=0,height:c=0,ref:S}=(0,Ie.useResizeDetector)(),f=N().getState(Ee.selectTracksMap),d=ye(t,f,r,n),p=(0,Y.useMemo)(()=>i||{width:Te(d)||1,height:1},[i,d]),v=d.length,{tilesInFirstPage:O,defaultWidth:T,defaultHeight:x,lastPageWidth:oe,lastPageHeight:re,isLastPageDifferentFromFirstPage:se}=(0,Y.useMemo)(()=>xe({count:v,parentWidth:Math.floor(u),parentHeight:Math.floor(c)-Math.min(c,a),maxTileCount:e,maxRowCount:s,maxColCount:o,aspectRatio:p}),[v,u,c,e,s,o,p,a]);return{pagesWithTiles:(0,Y.useMemo)(()=>we({elements:d,tilesInFirstPage:O,onlyOnePage:!1,isLastPageDifferentFromFirstPage:se,defaultWidth:T,defaultHeight:x,lastPageWidth:oe,lastPageHeight:re}),[d,O,se,T,x,oe,re]),ref:S}};var Ve=m(require("react")),Ce=m(require("@100mslive/hms-video-store"));function De({trackId:t,getStyle:e,ref:o}){let s=N();(0,Ve.useEffect)(()=>s.subscribe(r=>{if(!o.current)return;let i=e(r);for(let n in i)o.current.style[n]=i[n]},(0,Ce.selectTrackAudioByID)(t)),[e,o,s,t])}var F=m(require("@100mslive/hms-video-store")),Oe=m(require("react"));var R;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(R||(R={}));var Ne=(t=P)=>{let e=M(),o=l(F.selectDevices),s=l(F.selectLocalMediaSettings),r=l(F.selectIsAllowedToPublish),i={[R.audioOutput]:s.audioOutputDeviceId},n={[R.audioOutput]:o.audioOutput};r.video&&(n[R.videoInput]=o.videoInput,i[R.videoInput]=s.videoInputDeviceId),r.audio&&(n[R.audioInput]=o.audioInput,i[R.audioInput]=s.audioInputDeviceId);let a=(0,Oe.useCallback)(S=>g(void 0,[S],function*({deviceType:u,deviceId:c}){try{switch(u){case R.audioInput:yield e.setAudioSettings({deviceId:c});break;case R.videoInput:yield e.setVideoSettings({deviceId:c});break;case R.audioOutput:e.setAudioOutputDevice(c);break}}catch(h){t(h,"updateDevices")}}),[t,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};var We=m(require("react")),E=m(require("@100mslive/hms-video-store"));var Le=t=>!t||!Array.isArray(t)||t.length===0?{}:t.reduce((e,o)=>(o.roleName&&(e[o.roleName]||(e[o.roleName]=[]),e[o.roleName].push(o)),e),{});var Fe=()=>{let t=l(E.selectIsConnectedToRoom),e=l(t?E.selectPeers:E.selectRemotePeers),o=l(E.selectPeerCount),s=(0,We.useMemo)(()=>Le(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:o,isConnected:t}};var B=m(require("@100mslive/hms-video-store"));var Be=()=>{let t=l(B.selectRecordingState),e=l(B.selectRTMPState),o=l(B.selectHLSState),s=t.server.running,r=t.browser.running,i=t.hls.running,n=o.running||e.running,a=s||r||i;return{isServerRecordingOn:s,isBrowserRecordingOn:r,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:o.running,isRTMPRunning:e.running,isRecordingOn:a}};var z=m(require("react")),ze=m(require("@100mslive/hms-video-store"));var Ge=()=>{let t=Q(ze.HMSNotificationTypes.ERROR),[e,o]=(0,z.useState)(""),s=M(),r=(0,z.useCallback)(()=>g(void 0,null,function*(){yield s.unblockAudio()}),[s]);return(0,z.useEffect)(()=>{(t==null?void 0:t.data.code)===3008&&o(t==null?void 0:t.data.message)},[t]),{error:e,unblockAudio:r,resetError:()=>o("")}};var _=m(require("react")),qe=m(require("@100mslive/hms-video-store"));var je=({type:t,onEvent:e,handleError:o=P})=>{let s=M(),r=K();return(0,_.useEffect)(()=>{s.ignoreMessageTypes([t])},[s,t]),(0,_.useEffect)(()=>r?r.onNotification(a=>{let u=a.data;if(u&&u.type===t)try{let c=JSON.parse(u.message);e==null||e(c)}catch(c){o(c,"handleCustomEvent")}},qe.HMSNotificationTypes.NEW_MESSAGE):void 0,[r,t,e,o]),{sendEvent:(0,_.useCallback)(n=>g(void 0,null,function*(){try{let a=JSON.stringify(n||"");yield s.sendBroadcastMessage(a,t),e==null||e(n)}catch(a){o(a,"sendCustomEvent")}}),[s,o,e,t])}};H(exports,m(require("@100mslive/hms-video-store")));
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ce=Object.defineProperty,ue=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var q=(r,e,t)=>e in r?ce(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,E=(r,e)=>{for(var t in e||(e={}))me.call(e,t)&&q(r,t,e[t]);if(G)for(var t of G(e))de.call(e,t)&&q(r,t,e[t]);return r},I=(r,e)=>ue(r,le(e));var p=(r,e,t)=>new Promise((s,o)=>{var i=u=>{try{a(t.next(u))}catch(c){o(c)}},n=u=>{try{a(t.throw(u))}catch(c){o(c)}},a=u=>u.done?s(u.value):Promise.resolve(u.value).then(i,n);a((t=t.apply(r,e)).next())});import Se,{createContext as fe,useContext as V,useEffect as Q,useState as he}from"react";import{HMSReactiveStore as pe}from"@100mslive/hms-video-store";import C from"zustand";import{useContext as j}from"react";import J 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,...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}}}};b.level=0;var T="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function U(r){return(t,s=J)=>{t||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=j(r);if(!o)throw new Error(T);return o.store(t,s)}}function _(r){return(t,s=J)=>{t||b.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=j(r);if(!o)throw new Error(T);let i=o.statsStore;return i==null?void 0:i(t,s)}}var K=typeof window!="undefined";var x=fe(null),w,ge=({children:r,actions:e,store:t,notifications:s,stats:o,isHMSStatsOn:i=!1})=>{if(!w){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)w={actions:e,store:C(I(E({},t),{setState:n,destroy:n}))},s&&(w.notifications=s),o&&(w.statsStore=C({getState:o.getState,subscribe:o.subscribe,setState:n,destroy:n}));else{let a=new pe;if(w={actions:a.getActions(),store:C(I(E({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let u=a.getStats();w.statsStore=C({getState:u.getState,subscribe:u.subscribe,setState:n,destroy:n})}}}return Q(()=>{K&&(window.addEventListener("beforeunload",()=>w.actions.leave()),window.addEventListener("onunload",()=>w.actions.leave()))},[]),Se.createElement(x.Provider,{value:w},r)},l=U(x),He=_(x),A=()=>{let r=V(x);if(!r)throw new Error(T);return r.store},D=()=>{let r=V(x);if(!r)throw new Error(T);return r.notifications},g=()=>{let r=V(x);if(!r)throw new Error(T);return r.actions},O=r=>{let e=V(x),[t,s]=he(null);if(!e)throw new Error(T);return Q(()=>e.notifications?e.notifications.onNotification(i=>s(i),r):void 0,[e.notifications,r]),t};import{HMSRoomState as X,selectIsConnectedToRoom as be,selectRoomState as ke}from"@100mslive/hms-video-store";import{useCallback as Y,useMemo as Re}from"react";var Me="react-sdk",k=(r,e)=>b.e(Me,e,r),ve=r=>{throw r};var Pe=({name:r="",token:e,metadata:t,handleError:s=k,initEndpoint:o,initialSettings:i})=>{let n=g(),a=l(ke),u=l(be)||!1,c=a===X.Preview,d=Re(()=>({userName:r,authToken:e,metaData:t,rememberDeviceSelection:!0,settings:i,initEndpoint:o}),[r,e,t,o,i]),f=Y(()=>{(()=>p(void 0,null,function*(){if(!!e){a!==X.Disconnected&&(yield n.leave());try{yield n.preview(d)}catch(m){s(m,"preview")}}}))()},[n,s,e,a,d]),S=Y(()=>{if(!!e)try{n.join(d)}catch(m){s(m,"join")}},[n,d,s,e]);return{enableJoin:c,join:S,isConnected:u,preview:f}};import{selectIsAllowedToPublish as we,selectIsLocalAudioEnabled as Te,selectIsLocalVideoEnabled as xe}from"@100mslive/hms-video-store";import{useCallback as Z}from"react";var ye=(r=k)=>{let e=l(Te),t=l(xe),s=l(we),o=g(),i=Z(()=>p(void 0,null,function*(){try{yield o.setLocalAudioEnabled(!e)}catch(a){r(a,"toggleAudio")}}),[o,e,r]),n=Z(()=>p(void 0,null,function*(){try{yield o.setLocalVideoEnabled(!t)}catch(a){r(a,"toggleVideo")}}),[o,t,r]);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}};import{selectTrackByID as Ee}from"@100mslive/hms-video-store";import{useCallback as Ie,useEffect as $,useRef as Ae}from"react";import{useInView as Ve}from"react-intersection-observer";var Ce=({trackId:r,attach:e})=>{let t=g(),s=Ae(null),o=l(Ee(r)),{ref:i,inView:n}=Ve({threshold:.5}),a=Ie(u=>{s.current=u,i(u)},[i]);return $(()=>{(()=>p(void 0,null,function*(){s.current&&(o==null?void 0:o.id)&&(n&&o.enabled&&e!==!1?yield t.attachVideo(o.id,s.current):yield t.detachVideo(o.id,s.current))}))()},[t,n,s,o==null?void 0:o.id,o==null?void 0:o.enabled,o==null?void 0:o.deviceID,o==null?void 0:o.plugins,e]),$(()=>()=>{(()=>p(void 0,null,function*(){if(s.current&&o)try{yield t.detachVideo(o.id,s.current)}catch(u){b.w("detach video error for track",o.id,u)}}))()},[]),{videoRef:a}};import{selectIsLocalScreenShared as De,selectPeerScreenSharing as Oe,selectScreenSharesByPeerId as Ne}from"@100mslive/hms-video-store";import{useCallback as Le}from"react";var We=r=>console.log("Error: ",r),Fe=(r=We)=>{var n,a;let e=g(),t=l(De),s=l(Oe),o=l(Ne(s==null?void 0:s.id)),i=Le((u=!1)=>p(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t,u)}catch(c){r(c)}}),[e,t,r]);return{amIScreenSharing:t,screenSharingPeerId:s==null?void 0:s.id,screenShareVideoTrackId:(n=o==null?void 0:o.video)==null?void 0:n.id,screenShareAudioTrackId:(a=o==null?void 0:o.audio)==null?void 0:a.id,toggleScreenShare:i}};import{selectAudioTrackVolume as Be,selectPermissions as ze,selectTrackByID as ee}from"@100mslive/hms-video-store";import{useCallback as N}from"react";var te=(r,e,t)=>p(void 0,null,function*(){if(e)try{yield r.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){t(s,"remoteToggle")}}),Ge=(r,e,t=k)=>{let s=g(),o=l(ee(r)),i=l(ee(e)),n=l(Be(o==null?void 0:o.id)),a=l(ze),u=(i==null?void 0:i.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,c=(o==null?void 0:o.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,d=N(()=>p(void 0,null,function*(){yield te(s,o,t)}),[s,o,t]),f=N(()=>p(void 0,null,function*(){yield te(s,i,t)}),[s,t,i]),S=N(m=>{o&&s.setVolume(m,o.id)},[s,o]);return{isAudioEnabled:!!(o==null?void 0:o.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:o&&c?d:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&u?f:void 0,setVolume:o?S:void 0}};import{selectTracksMap as Ke}from"@100mslive/hms-video-store";import{useMemo as W}from"react";var qe=(r,e,t)=>r.reduce((s,o,i)=>{let n=Math.floor(i/e);return n>0&&t||(s[n]||(s[n]=[]),s[n].push(o)),s},[]),oe=({elements:r,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:s,defaultWidth:o,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let u=qe(r,e,t);return u.map((c,d)=>c.map(f=>{let S=d===u.length-1,m=s&&S?n:o,h=s&&S?a:i;return I(E({},f),{height:h,width:m})}))};function je(r){if(r.length===0)return null;let e={},t=r[0],s=1;for(let o=0;o<r.length;o++){let i=r[o];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(t=i,s=e[i])}return t}var re=r=>je(r.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 o,i;let t=(o=e.track)==null?void 0:o.width,s=(i=e.track)==null?void 0:i.height;return(t||1)/(s||1)})),L=(r,e,t,s,o)=>{if(r<0||e<0)throw new Error("Container must have a non-negative area");if(t<1||!Number.isInteger(t))throw new Error("Number of shapes to place must be a positive integer");let i=s&&o&&s/o;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,u=-1;if(i!==void 0)for(let c=a;c>0;c+=u){let d=Math.ceil(t/c),f=r/(c*i),S=e/d,m,h;f<=S?(m=r/c,h=m/i):(h=e/d,m=h*i);let H=m*h;H>n.area&&(n={area:H,width:m,height:h,rows:d,cols:c})}return n},Je=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,S=Math.min(Math.ceil(Math.sqrt(t*(r/e)/(o.width/o.height))),s),m=r/S,h=m/(o.width/o.height);h>e&&(h=e,m=h/(o.height/o.width));let H=Math.floor(e/h);if(n=h,i=m,d=Math.min(t,H*S),f=t%(H*S),c=f>0&&t>H*S,c){let y=Math.min(Math.ceil(Math.sqrt(f*(r/e)/(o.width/o.height))),s),R=r/y,P=R/(o.width/o.height);P>e&&(P=e,R=P/(o.height/o.width)),u=P,a=R}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},Ue=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,{width:S,height:m}=L(r,e,Math.min(t,s),o.width,o.height);if(i=S,n=m,d=Math.min(t,s),f=t%s,c=f>0&&t>s,c){let{width:h,height:H}=L(r,e,f,o.width,o.height);a=h,u=H}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},_e=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,S=Math.min(Math.ceil(Math.sqrt(t*(o.width/o.height)/(r/e))),s),m=e/S,h=m*(o.width/o.height),H=Math.floor(r/h);if(i=h,n=m,d=Math.min(t,S*H),f=t%(S*H),c=f>0&&t>S*H,c){let y=Math.min(Math.ceil(Math.sqrt(f*(o.width/o.height)/(r/e))),s),R=e/y,P=R*(o.width/o.height);u=R,a=P}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}};function se({count:r,parentWidth:e,parentHeight:t,maxTileCount:s,maxRowCount:o,maxColCount:i,aspectRatio:n}){let a=0,u=0,c=0,d=0,f=!1,S=0;if(r===0)return{tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f};if(s)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=Ue({parentWidth:e,parentHeight:t,count:r,maxCount:s,aspectRatio:n}));else if(o)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=_e({parentWidth:e,parentHeight:t,count:r,maxCount:o,aspectRatio:n}));else if(i)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=Je({parentWidth:e,parentHeight:t,count:r,maxCount:i,aspectRatio:n}));else{let{width:m,height:h}=L(e,t,r,n.width,n.height);a=m,u=h,S=r}return{tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}}var ie=(r,e,t,s=!0)=>{if(!r||!e||!t)return[];let o=[];for(let i of r)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}),t(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(u=>{let c=e[u];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&o.push({track:e[a],peer:i})}return o};import{useResizeDetector as Qe}from"react-resize-detector";var Xe={aspectRatio:{width:1,height:1}},Ye=({peers:r,maxTileCount:e,maxColCount:t,maxRowCount:s,includeScreenShareForPeer:o=()=>!1,aspectRatio:i=Xe.aspectRatio,filterNonPublishingPeers:n=!0,offsetY:a=0})=>{let{width:u=0,height:c=0,ref:d}=Qe(),S=A().getState(Ke),m=ie(r,S,o,n),h=W(()=>i||{width:re(m)||1,height:1},[i,m]),H=m.length,{tilesInFirstPage:y,defaultWidth:R,defaultHeight:P,lastPageWidth:F,lastPageHeight:B,isLastPageDifferentFromFirstPage:z}=W(()=>se({count:H,parentWidth:Math.floor(u),parentHeight:Math.floor(c)-Math.min(c,a),maxTileCount:e,maxRowCount:s,maxColCount:t,aspectRatio:h}),[H,u,c,e,s,t,h,a]);return{pagesWithTiles:W(()=>oe({elements:m,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:z,defaultWidth:R,defaultHeight:P,lastPageWidth:F,lastPageHeight:B}),[m,y,z,R,P,F,B]),ref:d}};import{useEffect as Ze}from"react";import{selectTrackAudioByID as $e}from"@100mslive/hms-video-store";function et({trackId:r,getStyle:e,ref:t}){let s=A();Ze(()=>s.subscribe(o=>{if(!t.current)return;let i=e(o);for(let n in i)t.current.style[n]=i[n]},$e(r)),[e,t,s,r])}import{selectDevices as tt,selectIsAllowedToPublish as ot,selectLocalMediaSettings as rt}from"@100mslive/hms-video-store";import{useCallback as st}from"react";var v;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(v||(v={}));var it=(r=k)=>{let e=g(),t=l(tt),s=l(rt),o=l(ot),i={[v.audioOutput]:s.audioOutputDeviceId},n={[v.audioOutput]:t.audioOutput};o.video&&(n[v.videoInput]=t.videoInput,i[v.videoInput]=s.videoInputDeviceId),o.audio&&(n[v.audioInput]=t.audioInput,i[v.audioInput]=s.audioInputDeviceId);let a=st(d=>p(void 0,[d],function*({deviceType:u,deviceId:c}){try{switch(u){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(f){r(f,"updateDevices")}}),[r,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};import{useMemo as nt}from"react";import{selectIsConnectedToRoom as at,selectPeerCount as ct,selectPeers as ut,selectRemotePeers as lt}from"@100mslive/hms-video-store";var ne=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 mt=()=>{let r=l(at),e=l(r?ut:lt),t=l(ct),s=nt(()=>ne(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:t,isConnected:r}};import{selectHLSState as dt,selectRecordingState as St,selectRTMPState as ft}from"@100mslive/hms-video-store";var ht=()=>{let r=l(St),e=l(ft),t=l(dt),s=r.server.running,o=r.browser.running,i=r.hls.running,n=t.running||e.running,a=s||o||i;return{isServerRecordingOn:s,isBrowserRecordingOn:o,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:t.running,isRTMPRunning:e.running,isRecordingOn:a}};import{useCallback as pt,useEffect as gt,useState as Ht}from"react";import{HMSNotificationTypes as Mt}from"@100mslive/hms-video-store";var vt=()=>{let r=O(Mt.ERROR),[e,t]=Ht(""),s=g(),o=pt(()=>p(void 0,null,function*(){yield s.unblockAudio()}),[s]);return gt(()=>{(r==null?void 0:r.data.code)===3008&&t(r==null?void 0:r.data.message)},[r]),{error:e,unblockAudio:o,resetError:()=>t("")}};import{useCallback as bt,useEffect as ae}from"react";import{HMSNotificationTypes as kt}from"@100mslive/hms-video-store";var Rt=({type:r,onEvent:e,handleError:t=k})=>{let s=g(),o=D();return ae(()=>{s.ignoreMessageTypes([r])},[s,r]),ae(()=>o?o.onNotification(a=>{let u=a.data;if(u&&u.type===r)try{let c=JSON.parse(u.message);e==null||e(c)}catch(c){t(c,"handleCustomEvent")}},kt.NEW_MESSAGE):void 0,[o,r,e,t]),{sendEvent:bt(n=>p(void 0,null,function*(){try{let a=JSON.stringify(n||"");yield s.sendBroadcastMessage(a,r),e==null||e(n)}catch(a){t(a,"sendCustomEvent")}}),[s,t,e,r])}};export*from"@100mslive/hms-video-store";export{v as DeviceType,ge as HMSRoomProvider,ve as throwErrorHandler,ye as useAVToggle,et as useAudioLevelStyles,vt as useAutoplayError,Rt as useCustomEvent,it as useDevices,g as useHMSActions,O as useHMSNotifications,He as useHMSStatsStore,l as useHMSStore,D as useHMSVanillaNotifications,A as useHMSVanillaStore,mt as useParticipantList,Pe as usePreviewJoin,ht as useRecordingStreaming,Ge as useRemoteAVToggle,Fe as useScreenShare,Ce as useVideo,Ye as useVideoList};
|
|
1
|
+
var ce=Object.defineProperty,ue=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var q=(r,e,t)=>e in r?ce(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,E=(r,e)=>{for(var t in e||(e={}))me.call(e,t)&&q(r,t,e[t]);if(G)for(var t of G(e))de.call(e,t)&&q(r,t,e[t]);return r},I=(r,e)=>ue(r,le(e));var p=(r,e,t)=>new Promise((s,o)=>{var i=u=>{try{a(t.next(u))}catch(c){o(c)}},n=u=>{try{a(t.throw(u))}catch(c){o(c)}},a=u=>u.done?s(u.value):Promise.resolve(u.value).then(i,n);a((t=t.apply(r,e)).next())});import Se,{createContext as fe,useContext as V,useEffect as Q,useState as he}from"react";import{HMSReactiveStore as pe}from"@100mslive/hms-video-store";import C from"zustand";import{useContext as j}from"react";import J 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 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,...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}}}};k.level=0;var T="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";function U(r){return(t,s=J)=>{t||k.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=j(r);if(!o)throw new Error(T);return o.store(t,s)}}function _(r){return(t,s=J)=>{t||k.w("fetching full store without passing any selector may have a heavy performance impact on your website.");let o=j(r);if(!o)throw new Error(T);let i=o.statsStore;return i==null?void 0:i(t,s)}}var K=typeof window!="undefined";var x=fe(null),w,ge=({children:r,actions:e,store:t,notifications:s,stats:o,isHMSStatsOn:i=!1})=>{if(!w){let n=()=>{throw new Error("modifying store is not allowed")};if(e&&t)w={actions:e,store:C(I(E({},t),{setState:n,destroy:n}))},s&&(w.notifications=s),o&&(w.statsStore=C({getState:o.getState,subscribe:o.subscribe,setState:n,destroy:n}));else{let a=new pe;if(w={actions:a.getActions(),store:C(I(E({},a.getStore()),{setState:n,destroy:n})),notifications:a.getNotifications()},i){let u=a.getStats();w.statsStore=C({getState:u.getState,subscribe:u.subscribe,setState:n,destroy:n})}}}return Q(()=>{K&&(window.addEventListener("beforeunload",()=>w.actions.leave()),window.addEventListener("onunload",()=>w.actions.leave()))},[]),Se.createElement(x.Provider,{value:w},r)},l=U(x),He=_(x),A=()=>{let r=V(x);if(!r)throw new Error(T);return r.store},D=()=>{let r=V(x);if(!r)throw new Error(T);return r.notifications},g=()=>{let r=V(x);if(!r)throw new Error(T);return r.actions},O=r=>{let e=V(x),[t,s]=he(null);if(!e)throw new Error(T);return Q(()=>e.notifications?e.notifications.onNotification(i=>s(i),r):void 0,[e.notifications,r]),t};import{HMSRoomState as X,selectIsConnectedToRoom as be,selectRoomState as ke}from"@100mslive/hms-video-store";import{useCallback as Y,useMemo as Re}from"react";var Me="react-sdk",v=(r,e)=>k.e(Me,e,r),ve=r=>{throw r};var Pe=({name:r="",token:e,metadata:t,handleError:s=v,initEndpoint:o,initialSettings:i})=>{let n=g(),a=l(ke),u=l(be)||!1,c=a===X.Preview,d=Re(()=>({userName:r,authToken:e,metaData:t,rememberDeviceSelection:!0,settings:i,initEndpoint:o}),[r,e,t,o,i]),f=Y(()=>{(()=>p(void 0,null,function*(){if(!!e){a!==X.Disconnected&&(yield n.leave());try{yield n.preview(d)}catch(m){s(m,"preview")}}}))()},[n,s,e,a,d]),S=Y(()=>{if(!!e)try{n.join(d)}catch(m){s(m,"join")}},[n,d,s,e]);return{enableJoin:c,join:S,isConnected:u,preview:f}};import{selectIsAllowedToPublish as we,selectIsLocalAudioEnabled as Te,selectIsLocalVideoEnabled as xe}from"@100mslive/hms-video-store";import{useCallback as Z}from"react";var ye=(r=v)=>{let e=l(Te),t=l(xe),s=l(we),o=g(),i=Z(()=>p(void 0,null,function*(){try{yield o.setLocalAudioEnabled(!e)}catch(a){r(a,"toggleAudio")}}),[o,e,r]),n=Z(()=>p(void 0,null,function*(){try{yield o.setLocalVideoEnabled(!t)}catch(a){r(a,"toggleVideo")}}),[o,t,r]);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}};import{selectTrackByID as Ee}from"@100mslive/hms-video-store";import{useCallback as Ie,useEffect as $,useRef as Ae}from"react";import{useInView as Ve}from"react-intersection-observer";var Ce=({trackId:r,attach:e})=>{let t=g(),s=Ae(null),o=l(Ee(r)),{ref:i,inView:n}=Ve({threshold:.5}),a=Ie(u=>{s.current=u,i(u)},[i]);return $(()=>{(()=>p(void 0,null,function*(){s.current&&(o==null?void 0:o.id)&&(n&&o.enabled&&e!==!1?yield t.attachVideo(o.id,s.current):yield t.detachVideo(o.id,s.current))}))()},[t,n,s,o==null?void 0:o.id,o==null?void 0:o.enabled,o==null?void 0:o.deviceID,o==null?void 0:o.plugins,e]),$(()=>()=>{(()=>p(void 0,null,function*(){if(s.current&&o)try{yield t.detachVideo(o.id,s.current)}catch(u){k.w("detach video error for track",o.id,u)}}))()},[]),{videoRef:a}};import{selectIsLocalScreenShared as De,selectPeerScreenSharing as Oe,selectScreenSharesByPeerId as Ne}from"@100mslive/hms-video-store";import{useCallback as Le}from"react";var We=(r=v)=>{var n,a;let e=g(),t=l(De),s=l(Oe),o=l(Ne(s==null?void 0:s.id)),i=Le((u=!1)=>p(void 0,null,function*(){try{yield e.setScreenShareEnabled(!t,u)}catch(c){r(c,"toggleScreenShare")}}),[e,t,r]);return{amIScreenSharing:t,screenSharingPeerId:s==null?void 0:s.id,screenShareVideoTrackId:(n=o==null?void 0:o.video)==null?void 0:n.id,screenShareAudioTrackId:(a=o==null?void 0:o.audio)==null?void 0:a.id,toggleScreenShare:i}};import{selectAudioTrackVolume as Fe,selectPermissions as Be,selectTrackByID as ee}from"@100mslive/hms-video-store";import{useCallback as N}from"react";var te=(r,e,t)=>p(void 0,null,function*(){if(e)try{yield r.setRemoteTrackEnabled(e.id,!e.enabled)}catch(s){t(s,"remoteToggle")}}),ze=(r,e,t=v)=>{let s=g(),o=l(ee(r)),i=l(ee(e)),n=l(Fe(o==null?void 0:o.id)),a=l(Be),u=(i==null?void 0:i.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,c=(o==null?void 0:o.enabled)?a==null?void 0:a.mute:a==null?void 0:a.unmute,d=N(()=>p(void 0,null,function*(){yield te(s,o,t)}),[s,o,t]),f=N(()=>p(void 0,null,function*(){yield te(s,i,t)}),[s,t,i]),S=N(m=>{o&&s.setVolume(m,o.id)},[s,o]);return{isAudioEnabled:!!(o==null?void 0:o.enabled),isVideoEnabled:!!(i==null?void 0:i.enabled),volume:n,toggleAudio:o&&c?d:void 0,toggleVideo:(i==null?void 0:i.source)==="regular"&&u?f:void 0,setVolume:o?S:void 0}};import{selectTracksMap as _e}from"@100mslive/hms-video-store";import{useMemo as W}from"react";var Ge=(r,e,t)=>r.reduce((s,o,i)=>{let n=Math.floor(i/e);return n>0&&t||(s[n]||(s[n]=[]),s[n].push(o)),s},[]),oe=({elements:r,tilesInFirstPage:e,onlyOnePage:t,isLastPageDifferentFromFirstPage:s,defaultWidth:o,defaultHeight:i,lastPageWidth:n,lastPageHeight:a})=>{let u=Ge(r,e,t);return u.map((c,d)=>c.map(f=>{let S=d===u.length-1,m=s&&S?n:o,h=s&&S?a:i;return I(E({},f),{height:h,width:m})}))};function qe(r){if(r.length===0)return null;let e={},t=r[0],s=1;for(let o=0;o<r.length;o++){let i=r[o];e[i]===null?e[i]=1:e[i]++,e[i]>s&&(t=i,s=e[i])}return t}var re=r=>qe(r.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 o,i;let t=(o=e.track)==null?void 0:o.width,s=(i=e.track)==null?void 0:i.height;return(t||1)/(s||1)})),L=(r,e,t,s,o)=>{if(r<0||e<0)throw new Error("Container must have a non-negative area");if(t<1||!Number.isInteger(t))throw new Error("Number of shapes to place must be a positive integer");let i=s&&o&&s/o;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,u=-1;if(i!==void 0)for(let c=a;c>0;c+=u){let d=Math.ceil(t/c),f=r/(c*i),S=e/d,m,h;f<=S?(m=r/c,h=m/i):(h=e/d,m=h*i);let H=m*h;H>n.area&&(n={area:H,width:m,height:h,rows:d,cols:c})}return n},je=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,S=Math.min(Math.ceil(Math.sqrt(t*(r/e)/(o.width/o.height))),s),m=r/S,h=m/(o.width/o.height);h>e&&(h=e,m=h/(o.height/o.width));let H=Math.floor(e/h);if(n=h,i=m,d=Math.min(t,H*S),f=t%(H*S),c=f>0&&t>H*S,c){let y=Math.min(Math.ceil(Math.sqrt(f*(r/e)/(o.width/o.height))),s),R=r/y,P=R/(o.width/o.height);P>e&&(P=e,R=P/(o.height/o.width)),u=P,a=R}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},Je=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,{width:S,height:m}=L(r,e,Math.min(t,s),o.width,o.height);if(i=S,n=m,d=Math.min(t,s),f=t%s,c=f>0&&t>s,c){let{width:h,height:H}=L(r,e,f,o.width,o.height);a=h,u=H}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}},Ue=({parentWidth:r,parentHeight:e,count:t,maxCount:s,aspectRatio:o})=>{let i=0,n=0,a=0,u=0,c=!1,d=0,f=0,S=Math.min(Math.ceil(Math.sqrt(t*(o.width/o.height)/(r/e))),s),m=e/S,h=m*(o.width/o.height),H=Math.floor(r/h);if(i=h,n=m,d=Math.min(t,S*H),f=t%(S*H),c=f>0&&t>S*H,c){let y=Math.min(Math.ceil(Math.sqrt(f*(o.width/o.height)/(r/e))),s),R=e/y,P=R*(o.width/o.height);u=R,a=P}return{tilesInFirstPage:d,defaultWidth:i,defaultHeight:n,lastPageWidth:a,lastPageHeight:u,isLastPageDifferentFromFirstPage:c}};function se({count:r,parentWidth:e,parentHeight:t,maxTileCount:s,maxRowCount:o,maxColCount:i,aspectRatio:n}){let a=0,u=0,c=0,d=0,f=!1,S=0;if(r===0)return{tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f};if(s)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=Je({parentWidth:e,parentHeight:t,count:r,maxCount:s,aspectRatio:n}));else if(o)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=Ue({parentWidth:e,parentHeight:t,count:r,maxCount:o,aspectRatio:n}));else if(i)({tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}=je({parentWidth:e,parentHeight:t,count:r,maxCount:i,aspectRatio:n}));else{let{width:m,height:h}=L(e,t,r,n.width,n.height);a=m,u=h,S=r}return{tilesInFirstPage:S,defaultWidth:a,defaultHeight:u,lastPageWidth:c,lastPageHeight:d,isLastPageDifferentFromFirstPage:f}}var ie=(r,e,t,s=!0)=>{if(!r||!e||!t)return[];let o=[];for(let i of r)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}),t(i)&&i.auxiliaryTracks.length>0){let a=i.auxiliaryTracks.find(u=>{let c=e[u];return(c==null?void 0:c.type)==="video"&&(c==null?void 0:c.source)==="screen"});a&&o.push({track:e[a],peer:i})}return o};import{useResizeDetector as Ke}from"react-resize-detector";var Qe={aspectRatio:{width:1,height:1}},Xe=({peers:r,maxTileCount:e,maxColCount:t,maxRowCount:s,includeScreenShareForPeer:o=()=>!1,aspectRatio:i=Qe.aspectRatio,filterNonPublishingPeers:n=!0,offsetY:a=0})=>{let{width:u=0,height:c=0,ref:d}=Ke(),S=A().getState(_e),m=ie(r,S,o,n),h=W(()=>i||{width:re(m)||1,height:1},[i,m]),H=m.length,{tilesInFirstPage:y,defaultWidth:R,defaultHeight:P,lastPageWidth:F,lastPageHeight:B,isLastPageDifferentFromFirstPage:z}=W(()=>se({count:H,parentWidth:Math.floor(u),parentHeight:Math.floor(c)-Math.min(c,a),maxTileCount:e,maxRowCount:s,maxColCount:t,aspectRatio:h}),[H,u,c,e,s,t,h,a]);return{pagesWithTiles:W(()=>oe({elements:m,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:z,defaultWidth:R,defaultHeight:P,lastPageWidth:F,lastPageHeight:B}),[m,y,z,R,P,F,B]),ref:d}};import{useEffect as Ye}from"react";import{selectTrackAudioByID as Ze}from"@100mslive/hms-video-store";function $e({trackId:r,getStyle:e,ref:t}){let s=A();Ye(()=>s.subscribe(o=>{if(!t.current)return;let i=e(o);for(let n in i)t.current.style[n]=i[n]},Ze(r)),[e,t,s,r])}import{selectDevices as et,selectIsAllowedToPublish as tt,selectLocalMediaSettings as ot}from"@100mslive/hms-video-store";import{useCallback as rt}from"react";var b;(function(s){s.videoInput="videoInput",s.audioInput="audioInput",s.audioOutput="audioOutput"})(b||(b={}));var st=(r=v)=>{let e=g(),t=l(et),s=l(ot),o=l(tt),i={[b.audioOutput]:s.audioOutputDeviceId},n={[b.audioOutput]:t.audioOutput};o.video&&(n[b.videoInput]=t.videoInput,i[b.videoInput]=s.videoInputDeviceId),o.audio&&(n[b.audioInput]=t.audioInput,i[b.audioInput]=s.audioInputDeviceId);let a=rt(d=>p(void 0,[d],function*({deviceType:u,deviceId:c}){try{switch(u){case b.audioInput:yield e.setAudioSettings({deviceId:c});break;case b.videoInput:yield e.setVideoSettings({deviceId:c});break;case b.audioOutput:e.setAudioOutputDevice(c);break}}catch(f){r(f,"updateDevices")}}),[r,e]);return{allDevices:n,selectedDeviceIDs:i,updateDevice:a}};import{useMemo as it}from"react";import{selectIsConnectedToRoom as nt,selectPeerCount as at,selectPeers as ct,selectRemotePeers as ut}from"@100mslive/hms-video-store";var ne=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 lt=()=>{let r=l(nt),e=l(r?ct:ut),t=l(at),s=it(()=>ne(e),[e]);return{roles:Object.keys(s),participantsByRoles:s,peerCount:t,isConnected:r}};import{selectHLSState as mt,selectRecordingState as dt,selectRTMPState as St}from"@100mslive/hms-video-store";var ft=()=>{let r=l(dt),e=l(St),t=l(mt),s=r.server.running,o=r.browser.running,i=r.hls.running,n=t.running||e.running,a=s||o||i;return{isServerRecordingOn:s,isBrowserRecordingOn:o,isHLSRecordingOn:i,isStreamingOn:n,isHLSRunning:t.running,isRTMPRunning:e.running,isRecordingOn:a}};import{useCallback as ht,useEffect as pt,useState as gt}from"react";import{HMSNotificationTypes as Ht}from"@100mslive/hms-video-store";var Mt=()=>{let r=O(Ht.ERROR),[e,t]=gt(""),s=g(),o=ht(()=>p(void 0,null,function*(){yield s.unblockAudio()}),[s]);return pt(()=>{(r==null?void 0:r.data.code)===3008&&t(r==null?void 0:r.data.message)},[r]),{error:e,unblockAudio:o,resetError:()=>t("")}};import{useCallback as vt,useEffect as ae}from"react";import{HMSNotificationTypes as bt}from"@100mslive/hms-video-store";var kt=({type:r,onEvent:e,handleError:t=v})=>{let s=g(),o=D();return ae(()=>{s.ignoreMessageTypes([r])},[s,r]),ae(()=>o?o.onNotification(a=>{let u=a.data;if(u&&u.type===r)try{let c=JSON.parse(u.message);e==null||e(c)}catch(c){t(c,"handleCustomEvent")}},bt.NEW_MESSAGE):void 0,[o,r,e,t]),{sendEvent:vt(n=>p(void 0,null,function*(){try{let a=JSON.stringify(n||"");yield s.sendBroadcastMessage(a,r),e==null||e(n)}catch(a){t(a,"sendCustomEvent")}}),[s,t,e,r])}};export*from"@100mslive/hms-video-store";export{b as DeviceType,ge as HMSRoomProvider,ve as throwErrorHandler,ye as useAVToggle,$e as useAudioLevelStyles,Mt as useAutoplayError,kt as useCustomEvent,st as useDevices,g as useHMSActions,O as useHMSNotifications,He as useHMSStatsStore,l as useHMSStore,D as useHMSVanillaNotifications,A as useHMSVanillaStore,lt as useParticipantList,Pe as usePreviewJoin,ft as useRecordingStreaming,ze as useRemoteAVToggle,We as useScreenShare,Ce as useVideo,Xe 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
|
+
"version": "0.0.11-alpha.2",
|
|
8
8
|
"author": "100ms",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prestart": "rm -rf dist && yarn types:build",
|
|
16
16
|
"start": "concurrently \"yarn dev\" \"yarn types\"",
|
|
17
|
-
"dev": "node ../../scripts/dev
|
|
17
|
+
"dev": "node ../../scripts/dev",
|
|
18
18
|
"build:only": "node ../../scripts/build",
|
|
19
19
|
"build": "yarn build:only && yarn types:build",
|
|
20
20
|
"types": "tsc -w",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"react": "^17.0.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@100mslive/hms-video-store": "0.2.
|
|
35
|
+
"@100mslive/hms-video-store": "0.2.94-alpha.2",
|
|
36
36
|
"react-intersection-observer": "^8.33.1",
|
|
37
37
|
"react-resize-detector": "^7.0.0",
|
|
38
38
|
"zustand": "^3.6.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a50567c36b48097760a7afb32769ae716330bca6"
|
|
41
41
|
}
|