@100mslive/react-sdk 0.6.5-alpha.2 → 0.7.1-alpha.0

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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("zustand"),i=require("@100mslive/hms-video-store"),o=require("react-resize-detector");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r,a,s=n(e),l=n(t);function c(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let o=0;o<i.length;o++)if(!Object.prototype.hasOwnProperty.call(t,i[o])||!Object.is(e[i[o]],t[i[o]]))return!1;return!0}(a=r||(r={}))[a.VERBOSE=0]="VERBOSE",a[a.DEBUG=1]="DEBUG",a[a.INFO=2]="INFO",a[a.WARN=3]="WARN",a[a.ERROR=4]="ERROR",a[a.NONE=5]="NONE";class u{static v(e,...t){this.log(r.VERBOSE,e,...t)}static d(e,...t){this.log(r.DEBUG,e,...t)}static i(e,...t){this.log(r.INFO,e,...t)}static w(e,...t){this.log(r.WARN,e,...t)}static e(e,...t){this.log(r.ERROR,e,...t)}static log(e,t,...i){if(!(this.level.valueOf()>e.valueOf()))switch(e){case r.VERBOSE:console.log("HMSui-components: ",t,...i);break;case r.DEBUG:console.debug("HMSui-components: ",t,...i);break;case r.INFO:console.info("HMSui-components: ",t,...i);break;case r.WARN:console.warn("HMSui-components: ",t,...i);break;case r.ERROR:console.error("HMSui-components: ",t,...i)}}}u.level=r.VERBOSE;const d="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";const h="undefined"!=typeof window,g=e.createContext(null),f=(v=g,(t,i=c)=>{t||u.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const o=e.useContext(v);if(!o)throw new Error(d);return(0,o.store)(t,i)});var v;const p=function(t){return(i,o=c)=>{i||u.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const n=e.useContext(t);if(!n)throw new Error(d);const r=n.statsStore;return null==r?void 0:r(i,o)}}(g),m=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.store},y=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.notifications},w=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.actions},P=t=>{const i=e.useContext(g),[o,n]=e.useState(null);if(!i)throw new Error(d);return e.useEffect((()=>{if(!i.notifications)return;return i.notifications.onNotification((e=>{n(e)}),t)}),[i.notifications,t]),o};function S(e,t,i,o){return new(i||(i=Promise))((function(n,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const b=(e,t)=>u.e("react-sdk",t,e),E=(e,t,i)=>S(void 0,void 0,void 0,(function*(){if(t)try{yield e.setRemoteTrackEnabled(t.id,!t.enabled)}catch(e){i(e,"remoteToggle")}})),R=({elements:e,tilesInFirstPage:t,onlyOnePage:i,isLastPageDifferentFromFirstPage:o,defaultWidth:n,defaultHeight:r,lastPageWidth:a,lastPageHeight:s})=>{const l=((e,t,i)=>e.reduce(((e,o,n)=>{const r=Math.floor(n/t);return r>0&&i||(e[r]||(e[r]=[]),e[r].push(o)),e}),[]))(e,t,i);return l.map(((e,t)=>e.map((e=>{const i=t===l.length-1,c=o&&i?a:n,u=o&&i?s:r;return Object.assign(Object.assign({},e),{height:u,width:c})}))))};const k=(e,t,i,o,n)=>{if(e<0||t<0)throw new Error("Container must have a non-negative area");if(i<1||!Number.isInteger(i))throw new Error("Number of shapes to place must be a positive integer");const r=o&&n&&o/n;if(void 0!==r&&isNaN(r))throw new Error("Aspect ratio must be a number");let a={area:0,cols:0,rows:0,width:0,height:0};if(void 0!==r)for(let o=i;o>0;o+=-1){const n=Math.ceil(i/o);let s,l;e/(o*r)<=t/n?(s=e/o,l=s/r):(l=t/n,s=l*r);const c=s*l;c>a.area&&(a={area:c,width:s,height:l,rows:n,cols:o})}return a};function M({count:e,parentWidth:t,parentHeight:i,maxTileCount:o,maxRowCount:n,maxColCount:r,aspectRatio:a}){let s=0,l=0,c=0,u=0,d=!1,h=0;if(0===e)return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const{width:h,height:g}=k(e,t,Math.min(i,o),n.width,n.height);if(r=h,a=g,u=Math.min(i,o),d=i%o,c=d>0&&i>o,c){const{width:i,height:o}=k(e,t,d,n.width,n.height);s=i,l=o}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:o,aspectRatio:a}));else if(n)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(n.width/n.height)/(e/t))),o),g=t/h,f=g*(n.width/n.height),v=Math.floor(e/f);if(r=f,a=g,u=Math.min(i,h*v),d=i%(h*v),c=d>0&&i>h*v,c){const i=t/Math.min(Math.ceil(Math.sqrt(d*(n.width/n.height)/(e/t))),o);l=i,s=i*(n.width/n.height)}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:n,aspectRatio:a}));else if(r)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(e/t)/(n.width/n.height))),o);let g=e/h,f=g/(n.width/n.height);f>t&&(f=t,g=f/(n.height/n.width));const v=Math.floor(t/f);if(a=f,r=g,u=Math.min(i,v*h),d=i%(v*h),c=d>0&&i>v*h,c){let i=e/Math.min(Math.ceil(Math.sqrt(d*(e/t)/(n.width/n.height))),o),r=i/(n.width/n.height);r>t&&(r=t,i=r/(n.height/n.width)),l=r,s=i}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:r,aspectRatio:a}));else{const{width:o,height:n}=k(t,i,e,a.width,a.height);s=o,l=n,h=e}return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}}const I={width:1,height:1};exports.HMSRoomProvider=({children:t,actions:o,store:n,notifications:r,stats:a,isHMSStatsOn:c=!1,leaveOnUnload:u=!0})=>{const d=e.useMemo((()=>{let e;const t=()=>{throw new Error("modifying store is not allowed")};if(o&&n)e={actions:o,store:l.default(Object.assign(Object.assign({},n),{setState:t,destroy:t}))},r&&(e.notifications=r),a&&(e.statsStore=l.default({getState:a.getState,subscribe:a.subscribe,setState:t,destroy:t}));else{const o=new i.HMSReactiveStore;if(e={actions:o.getActions(),store:l.default(Object.assign(Object.assign({},o.getStore()),{setState:t,destroy:t})),notifications:o.getNotifications()},c){const i=o.getStats();e.statsStore=l.default({getState:i.getState,subscribe:i.subscribe,setState:t,destroy:t})}}return e.actions.setFrameworkInfo({type:"react-web",version:s.default.version,sdkVersion:"0.6.5-alpha.2"}),e}),[o,n,r,a,c]);return e.useEffect((()=>{if(h&&u){const e=()=>d.actions.leave();return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}}return()=>{}}),[u,d]),s.default.createElement(g.Provider,{value:d},t)},exports.throwErrorHandler=e=>{throw e},exports.useAVToggle=(t=b)=>{const o=f(i.selectIsLocalAudioEnabled),n=f(i.selectIsLocalVideoEnabled),r=f(i.selectIsInPreview)?i.selectIsAllowedToPreviewMedia:i.selectIsAllowedToPublish,a=f(r),s=w(),l=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){try{yield s.setLocalAudioEnabled(!o)}catch(e){t(e,"toggleAudio")}}))),[s,o,t]),c=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){try{yield s.setLocalVideoEnabled(!n)}catch(e){t(e,"toggleVideo")}}))),[s,n,t]);return{isLocalAudioEnabled:o,isLocalVideoEnabled:n,toggleAudio:(null==a?void 0:a.audio)?l:void 0,toggleVideo:(null==a?void 0:a.video)?c:void 0}},exports.useAudioLevelStyles=function({trackId:t,getStyle:o,ref:n}){const r=m();e.useEffect((()=>r.subscribe((e=>{if(!n.current)return;const t=o(e);for(const e in t)n.current.style[e]=t[e]}),i.selectTrackAudioByID(t))),[o,n,r,t])},exports.useAutoplayError=()=>{const t=P(i.HMSNotificationTypes.ERROR),[o,n]=e.useState(""),r=w(),a=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield r.unblockAudio()}))),[r]);return e.useEffect((()=>{3008===(null==t?void 0:t.data.code)&&n(null==t?void 0:t.data.message)}),[t]),{error:o,unblockAudio:a,resetError:()=>n("")}},exports.useCustomEvent=({type:t,json:o=!0,onEvent:n,handleError:r=b})=>{const a=w(),s=y();e.useEffect((()=>{a.ignoreMessageTypes([t])}),[a,t]),e.useEffect((()=>{if(!s)return;return s.onNotification((e=>{const i=e.data;if(i&&i.type===t)try{const e=o?JSON.parse(i.message):i.message;null==n||n(e)}catch(e){r(e,"handleCustomEvent")}}),i.HMSNotificationTypes.NEW_MESSAGE)}),[s,t,o,n,r]);return{sendEvent:e.useCallback(((e,i)=>S(void 0,void 0,void 0,(function*(){try{const r=((e,t)=>t?JSON.stringify(e||""):e)(e,o);i&&Array.isArray(null==i?void 0:i.roleNames)?yield a.sendGroupMessage(r,i.roleNames,t):"string"==typeof(null==i?void 0:i.peerId)?yield a.sendDirectMessage(r,i.peerId,t):yield a.sendBroadcastMessage(r,t),null==n||n(e)}catch(e){r(e,"sendCustomEvent")}}))),[a,r,n,t,o])}},exports.useDevices=(t=b)=>{const o=w(),n=f(i.selectDevices),r=f(i.selectLocalMediaSettings),a=f(i.selectIsAllowedToPublish),s={[i.DeviceType.audioOutput]:r.audioOutputDeviceId},l={[i.DeviceType.audioOutput]:n.audioOutput};a.video&&(l[i.DeviceType.videoInput]=n.videoInput,s[i.DeviceType.videoInput]=r.videoInputDeviceId),a.audio&&(l[i.DeviceType.audioInput]=n.audioInput,s[i.DeviceType.audioInput]=r.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:s,updateDevice:e.useCallback((({deviceType:e,deviceId:n})=>S(void 0,void 0,void 0,(function*(){try{switch(e){case i.DeviceType.audioInput:yield o.setAudioSettings({deviceId:n});break;case i.DeviceType.videoInput:yield o.setVideoSettings({deviceId:n});break;case i.DeviceType.audioOutput:yield o.setAudioOutputDevice(n)}}catch(e){t(e,"updateDevices")}}))),[t,o])}},exports.useHMSActions=w,exports.useHMSNotifications=P,exports.useHMSStatsStore=p,exports.useHMSStore=f,exports.useHMSVanillaNotifications=y,exports.useHMSVanillaStore=m,exports.useParticipantList=()=>{const t=f(i.selectIsConnectedToRoom),o=f(t?i.selectPeers:i.selectRemotePeers),n=f(i.selectPeerCount),r=e.useMemo((()=>{return(e=o)&&Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>t.roleName?(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t),e):e),{}):{};var e}),[o]);return{roles:Object.keys(r),participantsByRoles:r,peerCount:n,isConnected:t}},exports.useParticipants=e=>{var t;const o=f(i.selectIsConnectedToRoom),n=f(i.selectPeerCount),r=f(i.selectAvailableRoleNames);let a=f(o?i.selectPeers:i.selectRemotePeers);const s=Array.from(new Set(a.map((e=>e.roleName)))),l=m();if((null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.isHandRaised)&&(a=a.filter((e=>l.getState(i.selectPeerMetadata(e.id)).isHandRaised))),(null==e?void 0:e.role)&&r.includes(e.role)&&(a=a.filter((t=>t.roleName===e.role))),null==e?void 0:e.search){const t=e.search.toLowerCase();a=a.filter((e=>{var i;return(null===(i=e.roleName)||void 0===i?void 0:i.toLowerCase().includes(t))||e.name.toLowerCase().includes(t)}))}return{participants:a,isConnected:o,peerCount:n,rolesWithParticipants:s}},exports.usePreviewJoin=({name:t="",token:o,metadata:n,handleError:r=b,initEndpoint:a,initialSettings:s,captureNetworkQualityInPreview:l,asRole:c,autoManageVideo:u})=>{const d=w(),h=f(i.selectRoomState),g=f(i.selectIsConnectedToRoom)||!1,v=h===i.HMSRoomState.Preview,p=e.useMemo((()=>({userName:t,authToken:o,metaData:n,rememberDeviceSelection:!0,settings:s,initEndpoint:a,asRole:c,captureNetworkQualityInPreview:l,autoManageVideo:u})),[t,o,n,a,s,l,c,u]),m=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){if(o&&h===i.HMSRoomState.Disconnected){g&&(yield d.leave());try{yield d.preview(p)}catch(e){r(e,"preview")}}}))),[d,r,o,h,p,g]);return{enableJoin:v,join:e.useCallback((()=>S(void 0,void 0,void 0,(function*(){if(o)try{yield d.join(p)}catch(e){r(e,"join")}}))),[d,p,r,o]),isConnected:g,preview:m}},exports.useRecordingStreaming=()=>{const e=f(i.selectRecordingState),t=f(i.selectRTMPState),o=f(i.selectHLSState),n=e.server.running,r=e.browser.running,a=e.hls.running,s=n||r||a;return{isServerRecordingOn:n,isBrowserRecordingOn:r,isHLSRecordingOn:a,isStreamingOn:o.running||t.running,isHLSRunning:o.running,isRTMPRunning:t.running,isRecordingOn:s}},exports.useRemoteAVToggle=(t,o,n=b)=>{const r=w(),a=f(i.selectAudioTrackByID(t)),s=f(i.selectVideoTrackByID(o)),l=f(i.selectAudioTrackVolume(null==a?void 0:a.id)),c=f(i.selectPermissions),u=(null==s?void 0:s.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,d=(null==a?void 0:a.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,h=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield E(r,a,n)}))),[r,a,n]),g=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield E(r,s,n)}))),[r,n,s]),v=e.useCallback((e=>{a&&r.setVolume(e,a.id)}),[r,a]);return{isAudioEnabled:!!(null==a?void 0:a.enabled),isVideoEnabled:!!(null==s?void 0:s.enabled),volume:l,toggleAudio:a&&d?h:void 0,toggleVideo:"regular"===(null==s?void 0:s.source)&&u?g:void 0,setVolume:a?v:void 0}},exports.useScreenShare=(t=b)=>{var o,n;const r=w(),a=f(i.selectIsLocalScreenShared),s=f(i.selectPeerScreenSharing),l=f(i.selectScreenSharesByPeerId(null==s?void 0:s.id)),c=e.useCallback((e=>S(void 0,void 0,void 0,(function*(){try{yield r.setScreenShareEnabled(!a,e)}catch(e){t(e,"toggleScreenShare")}}))),[r,a,t]);return{amIScreenSharing:a,screenSharingPeerId:null==s?void 0:s.id,screenSharingPeerName:null==s?void 0:s.name,screenShareVideoTrackId:null===(o=null==l?void 0:l.video)||void 0===o?void 0:o.id,screenShareAudioTrackId:null===(n=null==l?void 0:l.audio)||void 0===n?void 0:n.id,toggleScreenShare:c}},exports.useVideo=({trackId:t,attach:o})=>{const n=w(),r=e.useRef(null),a=f(i.selectVideoTrackByID(t)),s=e.useCallback((e=>{e&&(r.current=e)}),[]);return e.useEffect((()=>{S(void 0,void 0,void 0,(function*(){(null==a?void 0:a.id)&&r.current&&(!1!==o?yield n.attachVideo(a.id,r.current):yield n.detachVideo(a.id,r.current))}))}),[null==a?void 0:a.id,o,n]),e.useEffect((()=>()=>{S(void 0,void 0,void 0,(function*(){if(r.current&&a)try{yield n.detachVideo(a.id,r.current)}catch(e){u.w("detach video error for track",a.id,e)}}))}),[]),{videoRef:s}},exports.useVideoList=({peers:t,maxTileCount:n,maxColCount:r,maxRowCount:a,includeScreenShareForPeer:s=(()=>!1),aspectRatio:l=I,filterNonPublishingPeers:c=!0,offsetY:u=0})=>{const{width:d=0,height:h=0,ref:g}=o.useResizeDetector(),f=((e,t,i,o=!0)=>{if(!e||!t||!i)return[];const n=[];for(const r of e)if(void 0===r.videoTrack&&r.audioTrack&&t[r.audioTrack]?n.push({peer:r}):r.videoTrack&&t[r.videoTrack]?n.push({track:t[r.videoTrack],peer:r}):o||n.push({peer:r}),r.auxiliaryTracks.length>0&&r.auxiliaryTracks.forEach((e=>{const i=t[e];"video"===(null==i?void 0:i.type)&&"regular"===(null==i?void 0:i.source)&&n.push({track:i,peer:r})})),i(r)&&r.auxiliaryTracks.length>0){const e=r.auxiliaryTracks.find((e=>{const i=t[e];return"video"===(null==i?void 0:i.type)&&"screen"===(null==i?void 0:i.source)}));e&&n.push({track:t[e],peer:r})}return n})(t,m().getState(i.selectTracksMap),s,c),v=e.useMemo((()=>{if(l)return l;return{width:function(e){if(0===e.length)return null;const t={};let i=e[0],o=1;for(let n=0;n<e.length;n++){const r=e[n];null===t[r]?t[r]=1:t[r]++,t[r]>o&&(i=r,o=t[r])}return i}(f.filter((e=>{var t,i;return(null===(t=e.track)||void 0===t?void 0:t.width)&&(null===(i=e.track)||void 0===i?void 0:i.height)})).map((e=>{var t,i;return((null===(t=e.track)||void 0===t?void 0:t.width)||1)/((null===(i=e.track)||void 0===i?void 0:i.height)||1)})))||1,height:1}}),[l,f]),p=f.length,{tilesInFirstPage:y,defaultWidth:w,defaultHeight:P,lastPageWidth:S,lastPageHeight:b,isLastPageDifferentFromFirstPage:E}=e.useMemo((()=>M({count:p,parentWidth:Math.floor(d),parentHeight:Math.floor(h)-Math.min(h,u),maxTileCount:n,maxRowCount:a,maxColCount:r,aspectRatio:v})),[p,d,h,n,a,r,v,u]);return{pagesWithTiles:e.useMemo((()=>R({elements:f,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:E,defaultWidth:w,defaultHeight:P,lastPageWidth:S,lastPageHeight:b})),[f,y,E,w,P,S,b]),ref:g}},Object.keys(i).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("zustand"),i=require("@100mslive/hms-video-store"),o=require("react-resize-detector");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r,a,s=n(e),l=n(t);function c(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(let o=0;o<i.length;o++)if(!Object.prototype.hasOwnProperty.call(t,i[o])||!Object.is(e[i[o]],t[i[o]]))return!1;return!0}(a=r||(r={}))[a.VERBOSE=0]="VERBOSE",a[a.DEBUG=1]="DEBUG",a[a.INFO=2]="INFO",a[a.WARN=3]="WARN",a[a.ERROR=4]="ERROR",a[a.NONE=5]="NONE";class u{static v(e,...t){this.log(r.VERBOSE,e,...t)}static d(e,...t){this.log(r.DEBUG,e,...t)}static i(e,...t){this.log(r.INFO,e,...t)}static w(e,...t){this.log(r.WARN,e,...t)}static e(e,...t){this.log(r.ERROR,e,...t)}static log(e,t,...i){if(!(this.level.valueOf()>e.valueOf()))switch(e){case r.VERBOSE:console.log("HMSui-components: ",t,...i);break;case r.DEBUG:console.debug("HMSui-components: ",t,...i);break;case r.INFO:console.info("HMSui-components: ",t,...i);break;case r.WARN:console.warn("HMSui-components: ",t,...i);break;case r.ERROR:console.error("HMSui-components: ",t,...i)}}}u.level=r.VERBOSE;const d="It seems like you forgot to add your component within a top level HMSRoomProvider, please refer to 100ms react docs(https://docs.100ms.live/javascript/v2/features/integration#react-hooks) to check on the required steps for using this hook.";const h="undefined"!=typeof window,g=e.createContext(null),f=(v=g,(t,i=c)=>{t||u.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const o=e.useContext(v);if(!o)throw new Error(d);return(0,o.store)(t,i)});var v;const p=function(t){return(i,o=c)=>{i||u.w("fetching full store without passing any selector may have a heavy performance impact on your website.");const n=e.useContext(t);if(!n)throw new Error(d);const r=n.statsStore;return null==r?void 0:r(i,o)}}(g),m=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.store},y=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.notifications},w=()=>{const t=e.useContext(g);if(!t)throw new Error(d);return t.actions},P=t=>{const i=e.useContext(g),[o,n]=e.useState(null);if(!i)throw new Error(d);return e.useEffect((()=>{if(!i.notifications)return;return i.notifications.onNotification((e=>{n(e)}),t)}),[i.notifications,t]),o};function S(e,t,i,o){return new(i||(i=Promise))((function(n,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}const b=(e,t)=>u.e("react-sdk",t,e),E=(e,t,i)=>S(void 0,void 0,void 0,(function*(){if(t)try{yield e.setRemoteTrackEnabled(t.id,!t.enabled)}catch(e){i(e,"remoteToggle")}})),R=({elements:e,tilesInFirstPage:t,onlyOnePage:i,isLastPageDifferentFromFirstPage:o,defaultWidth:n,defaultHeight:r,lastPageWidth:a,lastPageHeight:s})=>{const l=((e,t,i)=>e.reduce(((e,o,n)=>{const r=Math.floor(n/t);return r>0&&i||(e[r]||(e[r]=[]),e[r].push(o)),e}),[]))(e,t,i);return l.map(((e,t)=>e.map((e=>{const i=t===l.length-1,c=o&&i?a:n,u=o&&i?s:r;return Object.assign(Object.assign({},e),{height:u,width:c})}))))};const k=(e,t,i,o,n)=>{if(e<0||t<0)throw new Error("Container must have a non-negative area");if(i<1||!Number.isInteger(i))throw new Error("Number of shapes to place must be a positive integer");const r=o&&n&&o/n;if(void 0!==r&&isNaN(r))throw new Error("Aspect ratio must be a number");let a={area:0,cols:0,rows:0,width:0,height:0};if(void 0!==r)for(let o=i;o>0;o+=-1){const n=Math.ceil(i/o);let s,l;e/(o*r)<=t/n?(s=e/o,l=s/r):(l=t/n,s=l*r);const c=s*l;c>a.area&&(a={area:c,width:s,height:l,rows:n,cols:o})}return a};function M({count:e,parentWidth:t,parentHeight:i,maxTileCount:o,maxRowCount:n,maxColCount:r,aspectRatio:a}){let s=0,l=0,c=0,u=0,d=!1,h=0;if(0===e)return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d};if(o)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const{width:h,height:g}=k(e,t,Math.min(i,o),n.width,n.height);if(r=h,a=g,u=Math.min(i,o),d=i%o,c=d>0&&i>o,c){const{width:i,height:o}=k(e,t,d,n.width,n.height);s=i,l=o}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:o,aspectRatio:a}));else if(n)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(n.width/n.height)/(e/t))),o),g=t/h,f=g*(n.width/n.height),v=Math.floor(e/f);if(r=f,a=g,u=Math.min(i,h*v),d=i%(h*v),c=d>0&&i>h*v,c){const i=t/Math.min(Math.ceil(Math.sqrt(d*(n.width/n.height)/(e/t))),o);l=i,s=i*(n.width/n.height)}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:n,aspectRatio:a}));else if(r)({tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}=(({parentWidth:e,parentHeight:t,count:i,maxCount:o,aspectRatio:n})=>{let r=0,a=0,s=0,l=0,c=!1,u=0,d=0;const h=Math.min(Math.ceil(Math.sqrt(i*(e/t)/(n.width/n.height))),o);let g=e/h,f=g/(n.width/n.height);f>t&&(f=t,g=f/(n.height/n.width));const v=Math.floor(t/f);if(a=f,r=g,u=Math.min(i,v*h),d=i%(v*h),c=d>0&&i>v*h,c){let i=e/Math.min(Math.ceil(Math.sqrt(d*(e/t)/(n.width/n.height))),o),r=i/(n.width/n.height);r>t&&(r=t,i=r/(n.height/n.width)),l=r,s=i}return{tilesInFirstPage:u,defaultWidth:r,defaultHeight:a,lastPageWidth:s,lastPageHeight:l,isLastPageDifferentFromFirstPage:c}})({parentWidth:t,parentHeight:i,count:e,maxCount:r,aspectRatio:a}));else{const{width:o,height:n}=k(t,i,e,a.width,a.height);s=o,l=n,h=e}return{tilesInFirstPage:h,defaultWidth:s,defaultHeight:l,lastPageWidth:c,lastPageHeight:u,isLastPageDifferentFromFirstPage:d}}const I={width:1,height:1};exports.HMSRoomProvider=({children:t,actions:o,store:n,notifications:r,stats:a,isHMSStatsOn:c=!1,leaveOnUnload:u=!0})=>{const d=e.useMemo((()=>{let e;const t=()=>{throw new Error("modifying store is not allowed")};if(o&&n)e={actions:o,store:l.default(Object.assign(Object.assign({},n),{setState:t,destroy:t}))},r&&(e.notifications=r),a&&(e.statsStore=l.default({getState:a.getState,subscribe:a.subscribe,setState:t,destroy:t}));else{const o=new i.HMSReactiveStore;if(e={actions:o.getActions(),store:l.default(Object.assign(Object.assign({},o.getStore()),{setState:t,destroy:t})),notifications:o.getNotifications()},c){const i=o.getStats();e.statsStore=l.default({getState:i.getState,subscribe:i.subscribe,setState:t,destroy:t})}}return e.actions.setFrameworkInfo({type:"react-web",version:s.default.version,sdkVersion:"0.7.1-alpha.0"}),e}),[o,n,r,a,c]);return e.useEffect((()=>{if(h&&u){const e=()=>d.actions.leave();return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}}return()=>{}}),[u,d]),s.default.createElement(g.Provider,{value:d},t)},exports.throwErrorHandler=e=>{throw e},exports.useAVToggle=(t=b)=>{const o=f(i.selectIsLocalAudioEnabled),n=f(i.selectIsLocalVideoEnabled),r=f(i.selectIsInPreview)?i.selectIsAllowedToPreviewMedia:i.selectIsAllowedToPublish,a=f(r),s=w(),l=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){try{yield s.setLocalAudioEnabled(!o)}catch(e){t(e,"toggleAudio")}}))),[s,o,t]),c=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){try{yield s.setLocalVideoEnabled(!n)}catch(e){t(e,"toggleVideo")}}))),[s,n,t]);return{isLocalAudioEnabled:o,isLocalVideoEnabled:n,toggleAudio:(null==a?void 0:a.audio)?l:void 0,toggleVideo:(null==a?void 0:a.video)?c:void 0}},exports.useAudioLevelStyles=function({trackId:t,getStyle:o,ref:n}){const r=m();e.useEffect((()=>r.subscribe((e=>{if(!n.current)return;const t=o(e);for(const e in t)n.current.style[e]=t[e]}),i.selectTrackAudioByID(t))),[o,n,r,t])},exports.useAutoplayError=()=>{const t=P(i.HMSNotificationTypes.ERROR),[o,n]=e.useState(""),r=w(),a=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield r.unblockAudio()}))),[r]);return e.useEffect((()=>{3008===(null==t?void 0:t.data.code)&&n(null==t?void 0:t.data.message)}),[t]),{error:o,unblockAudio:a,resetError:()=>n("")}},exports.useCustomEvent=({type:t,json:o=!0,onEvent:n,handleError:r=b})=>{const a=w(),s=y();e.useEffect((()=>{a.ignoreMessageTypes([t])}),[a,t]),e.useEffect((()=>{if(!s)return;return s.onNotification((e=>{const i=e.data;if(i&&i.type===t)try{const e=o?JSON.parse(i.message):i.message;null==n||n(e)}catch(e){r(e,"handleCustomEvent")}}),i.HMSNotificationTypes.NEW_MESSAGE)}),[s,t,o,n,r]);return{sendEvent:e.useCallback(((e,i)=>S(void 0,void 0,void 0,(function*(){try{const r=((e,t)=>t?JSON.stringify(e||""):e)(e,o);i&&Array.isArray(null==i?void 0:i.roleNames)?yield a.sendGroupMessage(r,i.roleNames,t):"string"==typeof(null==i?void 0:i.peerId)?yield a.sendDirectMessage(r,i.peerId,t):yield a.sendBroadcastMessage(r,t),null==n||n(e)}catch(e){r(e,"sendCustomEvent")}}))),[a,r,n,t,o])}},exports.useDevices=(t=b)=>{const o=w(),n=f(i.selectDevices),r=f(i.selectLocalMediaSettings),a=f(i.selectIsAllowedToPublish),s={[i.DeviceType.audioOutput]:r.audioOutputDeviceId},l={[i.DeviceType.audioOutput]:n.audioOutput};a.video&&(l[i.DeviceType.videoInput]=n.videoInput,s[i.DeviceType.videoInput]=r.videoInputDeviceId),a.audio&&(l[i.DeviceType.audioInput]=n.audioInput,s[i.DeviceType.audioInput]=r.audioInputDeviceId);return{allDevices:l,selectedDeviceIDs:s,updateDevice:e.useCallback((({deviceType:e,deviceId:n})=>S(void 0,void 0,void 0,(function*(){try{switch(e){case i.DeviceType.audioInput:yield o.setAudioSettings({deviceId:n});break;case i.DeviceType.videoInput:yield o.setVideoSettings({deviceId:n});break;case i.DeviceType.audioOutput:yield o.setAudioOutputDevice(n)}}catch(e){t(e,"updateDevices")}}))),[t,o])}},exports.useHMSActions=w,exports.useHMSNotifications=P,exports.useHMSStatsStore=p,exports.useHMSStore=f,exports.useHMSVanillaNotifications=y,exports.useHMSVanillaStore=m,exports.useParticipantList=()=>{const t=f(i.selectIsConnectedToRoom),o=f(t?i.selectPeers:i.selectRemotePeers),n=f(i.selectPeerCount),r=e.useMemo((()=>{return(e=o)&&Array.isArray(e)&&0!==e.length?e.reduce(((e,t)=>t.roleName?(e[t.roleName]||(e[t.roleName]=[]),e[t.roleName].push(t),e):e),{}):{};var e}),[o]);return{roles:Object.keys(r),participantsByRoles:r,peerCount:n,isConnected:t}},exports.useParticipants=e=>{var t;const o=f(i.selectIsConnectedToRoom),n=f(i.selectPeerCount),r=f(i.selectAvailableRoleNames);let a=f(o?i.selectPeers:i.selectRemotePeers);const s=Array.from(new Set(a.map((e=>e.roleName)))),l=m();if((null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.isHandRaised)&&(a=a.filter((e=>l.getState(i.selectPeerMetadata(e.id)).isHandRaised))),(null==e?void 0:e.role)&&r.includes(e.role)&&(a=a.filter((t=>t.roleName===e.role))),null==e?void 0:e.search){const t=e.search.toLowerCase();a=a.filter((e=>{var i;return(null===(i=e.roleName)||void 0===i?void 0:i.toLowerCase().includes(t))||e.name.toLowerCase().includes(t)}))}return{participants:a,isConnected:o,peerCount:n,rolesWithParticipants:s}},exports.usePreviewJoin=({name:t="",token:o,metadata:n,handleError:r=b,initEndpoint:a,initialSettings:s,captureNetworkQualityInPreview:l,asRole:c,autoManageVideo:u})=>{const d=w(),h=f(i.selectRoomState),g=f(i.selectIsConnectedToRoom)||!1,v=h===i.HMSRoomState.Preview,p=e.useMemo((()=>({userName:t,authToken:o,metaData:n,rememberDeviceSelection:!0,settings:s,initEndpoint:a,asRole:c,captureNetworkQualityInPreview:l,autoManageVideo:u})),[t,o,n,a,s,l,c,u]),m=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){if(o&&h===i.HMSRoomState.Disconnected){g&&(yield d.leave());try{yield d.preview(p)}catch(e){r(e,"preview")}}}))),[d,r,o,h,p,g]);return{enableJoin:v,join:e.useCallback((()=>S(void 0,void 0,void 0,(function*(){if(o)try{yield d.join(p)}catch(e){r(e,"join")}}))),[d,p,r,o]),isConnected:g,preview:m}},exports.useRecordingStreaming=()=>{const e=f(i.selectRecordingState),t=f(i.selectRTMPState),o=f(i.selectHLSState),n=e.server.running,r=e.browser.running,a=e.hls.running,s=n||r||a;return{isServerRecordingOn:n,isBrowserRecordingOn:r,isHLSRecordingOn:a,isStreamingOn:o.running||t.running,isHLSRunning:o.running,isRTMPRunning:t.running,isRecordingOn:s}},exports.useRemoteAVToggle=(t,o,n=b)=>{const r=w(),a=f(i.selectAudioTrackByID(t)),s=f(i.selectVideoTrackByID(o)),l=f(i.selectAudioTrackVolume(null==a?void 0:a.id)),c=f(i.selectPermissions),u=(null==s?void 0:s.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,d=(null==a?void 0:a.enabled)?null==c?void 0:c.mute:null==c?void 0:c.unmute,h=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield E(r,a,n)}))),[r,a,n]),g=e.useCallback((()=>S(void 0,void 0,void 0,(function*(){yield E(r,s,n)}))),[r,n,s]),v=e.useCallback((e=>{a&&r.setVolume(e,a.id)}),[r,a]);return{isAudioEnabled:!!(null==a?void 0:a.enabled),isVideoEnabled:!!(null==s?void 0:s.enabled),volume:l,toggleAudio:a&&d?h:void 0,toggleVideo:"regular"===(null==s?void 0:s.source)&&u?g:void 0,setVolume:a?v:void 0}},exports.useScreenShare=(t=b)=>{var o,n;const r=w(),a=f(i.selectIsLocalScreenShared),s=f(i.selectPeerScreenSharing),l=f(i.selectScreenSharesByPeerId(null==s?void 0:s.id)),c=e.useCallback((e=>S(void 0,void 0,void 0,(function*(){try{yield r.setScreenShareEnabled(!a,e)}catch(e){t(e,"toggleScreenShare")}}))),[r,a,t]);return{amIScreenSharing:a,screenSharingPeerId:null==s?void 0:s.id,screenSharingPeerName:null==s?void 0:s.name,screenShareVideoTrackId:null===(o=null==l?void 0:l.video)||void 0===o?void 0:o.id,screenShareAudioTrackId:null===(n=null==l?void 0:l.audio)||void 0===n?void 0:n.id,toggleScreenShare:c}},exports.useVideo=({trackId:t,attach:o})=>{const n=w(),r=e.useRef(null),a=f(i.selectVideoTrackByID(t)),s=e.useCallback((e=>{e&&(r.current=e)}),[]);return e.useEffect((()=>{S(void 0,void 0,void 0,(function*(){(null==a?void 0:a.id)&&r.current&&(!1!==o?yield n.attachVideo(a.id,r.current):yield n.detachVideo(a.id,r.current))}))}),[null==a?void 0:a.id,o,n]),e.useEffect((()=>()=>{S(void 0,void 0,void 0,(function*(){if(r.current&&a)try{yield n.detachVideo(a.id,r.current)}catch(e){u.w("detach video error for track",a.id,e)}}))}),[]),{videoRef:s}},exports.useVideoList=({peers:t,maxTileCount:n,maxColCount:r,maxRowCount:a,includeScreenShareForPeer:s=(()=>!1),aspectRatio:l=I,filterNonPublishingPeers:c=!0,offsetY:u=0})=>{const{width:d=0,height:h=0,ref:g}=o.useResizeDetector(),f=((e,t,i,o=!0)=>{if(!e||!t||!i)return[];const n=[];for(const r of e)if(void 0===r.videoTrack&&r.audioTrack&&t[r.audioTrack]?n.push({peer:r}):r.videoTrack&&t[r.videoTrack]?n.push({track:t[r.videoTrack],peer:r}):o||n.push({peer:r}),r.auxiliaryTracks.length>0&&r.auxiliaryTracks.forEach((e=>{const i=t[e];"video"===(null==i?void 0:i.type)&&"regular"===(null==i?void 0:i.source)&&n.push({track:i,peer:r})})),i(r)&&r.auxiliaryTracks.length>0){const e=r.auxiliaryTracks.find((e=>{const i=t[e];return"video"===(null==i?void 0:i.type)&&"screen"===(null==i?void 0:i.source)}));e&&n.push({track:t[e],peer:r})}return n})(t,m().getState(i.selectTracksMap),s,c),v=e.useMemo((()=>{if(l)return l;return{width:function(e){if(0===e.length)return null;const t={};let i=e[0],o=1;for(let n=0;n<e.length;n++){const r=e[n];null===t[r]?t[r]=1:t[r]++,t[r]>o&&(i=r,o=t[r])}return i}(f.filter((e=>{var t,i;return(null===(t=e.track)||void 0===t?void 0:t.width)&&(null===(i=e.track)||void 0===i?void 0:i.height)})).map((e=>{var t,i;return((null===(t=e.track)||void 0===t?void 0:t.width)||1)/((null===(i=e.track)||void 0===i?void 0:i.height)||1)})))||1,height:1}}),[l,f]),p=f.length,{tilesInFirstPage:y,defaultWidth:w,defaultHeight:P,lastPageWidth:S,lastPageHeight:b,isLastPageDifferentFromFirstPage:E}=e.useMemo((()=>M({count:p,parentWidth:Math.floor(d),parentHeight:Math.floor(h)-Math.min(h,u),maxTileCount:n,maxRowCount:a,maxColCount:r,aspectRatio:v})),[p,d,h,n,a,r,v,u]);return{pagesWithTiles:e.useMemo((()=>R({elements:f,tilesInFirstPage:y,onlyOnePage:!1,isLastPageDifferentFromFirstPage:E,defaultWidth:w,defaultHeight:P,lastPageWidth:S,lastPageHeight:b})),[f,y,E,w,P,S,b]),ref:g}},Object.keys(i).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return i[e]}})}));
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1,2 +1,2 @@
1
- import t,{createContext as e,useMemo as o,useEffect as r,useContext as s,useState as n}from"react";import i from"zustand";import{HMSReactiveStore as a}from"@100mslive/hms-video-store";import{makeHMSStoreHook as c,makeHMSStatsStoreHook as f,hooksErrorMessage as u}from"./store.js";import{isBrowser as l}from"../utils/isBrowser.js";const w=e(null),d=({children:e,actions:s,store:n,notifications:c,stats:f,isHMSStatsOn:u=!1,leaveOnUnload:d=!0})=>{const m=o((()=>{let e;const o=()=>{throw new Error("modifying store is not allowed")};if(s&&n)e={actions:s,store:i(Object.assign(Object.assign({},n),{setState:o,destroy:o}))},c&&(e.notifications=c),f&&(e.statsStore=i({getState:f.getState,subscribe:f.subscribe,setState:o,destroy:o}));else{const t=new a;if(e={actions:t.getActions(),store:i(Object.assign(Object.assign({},t.getStore()),{setState:o,destroy:o})),notifications:t.getNotifications()},u){const r=t.getStats();e.statsStore=i({getState:r.getState,subscribe:r.subscribe,setState:o,destroy:o})}}return e.actions.setFrameworkInfo({type:"react-web",version:t.version,sdkVersion:"0.6.5-alpha.2"}),e}),[s,n,c,f,u]);return r((()=>{if(l&&d){const t=()=>m.actions.leave();return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}}return()=>{}}),[d,m]),t.createElement(w.Provider,{value:m},e)},m=c(w),b=f(w),S=()=>{const t=s(w);if(!t)throw new Error(u);return t.store},g=()=>{const t=s(w);if(!t)throw new Error(u);return t.notifications},v=()=>{const t=s(w);if(!t)throw new Error(u);return t.actions},h=t=>{const e=s(w),[o,i]=n(null);if(!e)throw new Error(u);return r((()=>{if(!e.notifications)return;return e.notifications.onNotification((t=>{i(t)}),t)}),[e.notifications,t]),o};export{d as HMSRoomProvider,v as useHMSActions,h as useHMSNotifications,b as useHMSStatsStore,m as useHMSStore,g as useHMSVanillaNotifications,S as useHMSVanillaStore};
1
+ import t,{createContext as e,useMemo as o,useEffect as r,useContext as s,useState as n}from"react";import i from"zustand";import{HMSReactiveStore as a}from"@100mslive/hms-video-store";import{makeHMSStoreHook as c,makeHMSStatsStoreHook as f,hooksErrorMessage as u}from"./store.js";import{isBrowser as l}from"../utils/isBrowser.js";const w=e(null),d=({children:e,actions:s,store:n,notifications:c,stats:f,isHMSStatsOn:u=!1,leaveOnUnload:d=!0})=>{const m=o((()=>{let e;const o=()=>{throw new Error("modifying store is not allowed")};if(s&&n)e={actions:s,store:i(Object.assign(Object.assign({},n),{setState:o,destroy:o}))},c&&(e.notifications=c),f&&(e.statsStore=i({getState:f.getState,subscribe:f.subscribe,setState:o,destroy:o}));else{const t=new a;if(e={actions:t.getActions(),store:i(Object.assign(Object.assign({},t.getStore()),{setState:o,destroy:o})),notifications:t.getNotifications()},u){const r=t.getStats();e.statsStore=i({getState:r.getState,subscribe:r.subscribe,setState:o,destroy:o})}}return e.actions.setFrameworkInfo({type:"react-web",version:t.version,sdkVersion:"0.7.1-alpha.0"}),e}),[s,n,c,f,u]);return r((()=>{if(l&&d){const t=()=>m.actions.leave();return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}}return()=>{}}),[d,m]),t.createElement(w.Provider,{value:m},e)},m=c(w),b=f(w),S=()=>{const t=s(w);if(!t)throw new Error(u);return t.store},g=()=>{const t=s(w);if(!t)throw new Error(u);return t.notifications},v=()=>{const t=s(w);if(!t)throw new Error(u);return t.actions},h=t=>{const e=s(w),[o,i]=n(null);if(!e)throw new Error(u);return r((()=>{if(!e.notifications)return;return e.notifications.onNotification((t=>{i(t)}),t)}),[e.notifications,t]),o};export{d as HMSRoomProvider,v as useHMSActions,h as useHMSNotifications,b as useHMSStatsStore,m as useHMSStore,g as useHMSVanillaNotifications,S as useHMSVanillaStore};
2
2
  //# sourceMappingURL=HmsRoomProvider.js.map
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.6.5-alpha.2",
7
+ "version": "0.7.1-alpha.0",
8
8
  "author": "100ms",
9
9
  "license": "MIT",
10
10
  "files": [
@@ -36,9 +36,9 @@
36
36
  "react": ">=16.8 <19.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@100mslive/hms-video-store": "0.8.5-alpha.2",
39
+ "@100mslive/hms-video-store": "0.9.1-alpha.0",
40
40
  "react-resize-detector": "^7.0.0",
41
41
  "zustand": "^3.6.2"
42
42
  },
43
- "gitHead": "2c9b127a10783f0a5d2f73f4fdd8bed866800c7e"
43
+ "gitHead": "a2c7d3e49fa4de149b85e3576ebcbec51306c3fa"
44
44
  }