@100mslive/hms-video-store
Advanced tools
Comparing version 0.1.22 to 0.1.23
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("reselect"),r=require("zustand/middleware"),n=e(require("immer")),i=e(require("zustand/vanilla")),o=require("@100mslive/hms-video");function a(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,c,"next",e)}function c(e){a(o,n,i,s,c,"throw",e)}s(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var d,f=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new D(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function f(){}function h(){}var v={};v[i]=function(){return this};var p=Object.getPrototypeOf,E=p&&p(p(x([])));E&&E!==t&&r.call(E,i)&&(v=E);var k=h.prototype=d.prototype=Object.create(v);function m(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function x(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:b}}function b(){return{value:void 0,done:!0}}return f.prototype=k.constructor=h,h.constructor=f,f.displayName=s(h,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,a,"GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},m(g.prototype),g.prototype[o]=function(){return this},e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new g(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(k),s(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(d={exports:{}}),d.exports);(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat";var h=function(){};h.INFO="info",h.ERROR="error",h.CRITICAL="critical";var v,p,E,k=function(){};k.PEER_JOINED="PEER_JOINED",k.PEER_LEFT="PEER_LEFT",k.NEW_MESSAGE="NEW_MESSAGE",k.ERROR="ERROR",k.RECONNECTING="RECONNECTING",k.RECONNECTED="RECONNECTED",k.TRACK_ADDED="TRACK_ADDED",k.TRACK_REMOVED="TRACK_REMOVED",k.TRACK_MUTED="TRACK_MUTED",k.TRACK_UNMUTED="TRACK_UNMUTED",function(e){e[e.PEER_JOINED=0]="PEER_JOINED",e[e.PEER_LEFT=1]="PEER_LEFT",e[e.AUDIO_TOGGLED=2]="AUDIO_TOGGLED",e[e.VIDEO_TOGGLED=3]="VIDEO_TOGGLED",e[e.BECAME_DOMINANT_SPEAKER=4]="BECAME_DOMINANT_SPEAKER",e[e.RESIGNED_DOMINANT_SPEAKER=5]="RESIGNED_DOMINANT_SPEAKER",e[e.STARTED_SPEAKING=6]="STARTED_SPEAKING",e[e.STOPPED_SPEAKING=7]="STOPPED_SPEAKING"}(v||(v={})),function(e){e[e.PEER_ADDED=0]="PEER_ADDED",e[e.PEER_REMOVED=1]="PEER_REMOVED",e[e.PEER_KNOCKED=2]="PEER_KNOCKED",e[e.ROOM_TYPE_CHANGED=3]="ROOM_TYPE_CHANGED",e[e.METADATA_UPDATED=4]="METADATA_UPDATED",e[e.SCREENSHARE_STARTED=5]="SCREENSHARE_STARTED",e[e.SCREENSHARE_STOPPED=6]="SCREENSHARE_STOPPED",e[e.DEFAULT_UPDATE=7]="DEFAULT_UPDATE"}(p||(p={})),function(e){e[e.TRACK_ADDED=0]="TRACK_ADDED",e[e.TRACK_REMOVED=1]="TRACK_REMOVED",e[e.TRACK_MUTED=2]="TRACK_MUTED",e[e.TRACK_UNMUTED=3]="TRACK_UNMUTED",e[e.TRACK_DESCRIPTION_CHANGED=4]="TRACK_DESCRIPTION_CHANGED"}(E||(E={}));var m=function(){function e(){}return e.convertPeer=function(e){var t,r;return{id:e.peerId,name:e.name,role:e.role,isLocal:e.isLocal,videoTrack:null==(t=e.videoTrack)?void 0:t.trackId,audioTrack:null==(r=e.audioTrack)?void 0:r.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e){return{id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled}},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},e.convertMessage=function(e){return{sender:e.sender,time:e.time,type:e.type,message:e.message}},e}();function g(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&T(e.tracks[t])}))}function T(e){return e&&"video"===e.type&&"screen"===e.source}function y(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var S=function(e){return e.room},D=function(e){return e.peers},x=function(e){return e.messages.byID},b=function(e){return e.messages.allIDs},R=function(e){return e.tracks},I=function(e){return e.settings},A=t.createSelector(I,(function(e){return e.maxTileCount})),w=function(e){return e.speakers},P=t.createSelector([S],(function(e){return e&&e.isConnected})),_=t.createSelector([S,D],(function(e,t){return e.peers.map((function(e){return t[e]}))})),N=t.createSelector(_,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),O=t.createSelector(N,(function(e){return null==e?void 0:e.id})),M=t.createSelector(N,(function(e){return null==e?void 0:e.audioTrack})),L=t.createSelector(N,(function(e){return null==e?void 0:e.videoTrack})),C=t.createSelector(_,(function(e){return e.filter((function(e){return!e.isLocal}))})),K=t.createSelector(D,w,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,i=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>i?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][0];if(n in e)return e[n]}return null})),U=function(e){var t=N(e);return y(e,null==t?void 0:t.videoTrack)},G=function(e){var t=N(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},j=function(e){return g(e,N(e))},H=t.createSelector(b,(function(e){return e.length})),V=t.createSelector(x,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),F=t.createSelector(b,x,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r}));function J(e){return function(t){return function(r){return e(r,t)}}}var W=function(e,t){return t},B=t.createSelector([D,W],(function(e,t){return t?e[t]:null})),q=t.createSelector([R,W],(function(e,t){return t?e[t]:null})),Y=J(B),z=J(t.createSelector(B,(function(e){return null==e?void 0:e.name}))),$=J(q),Q=J(t.createSelector((function(e,t){return t?e.speakers[t]:null}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),X=J((function(e,t){var r=B(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return(r=e.tracks[t])&&"audio"===r.type;var r}));return n?e.tracks[n]:void 0}})),Z=J((function(e,t){var r=B(e,t);if(r&&g(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return T(e.tracks[t])}));return n?e.tracks[n]:void 0}})),ee=J((function(e,t){var r=B(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),te=J((function(e,t){var r=B(e,t);return y(e,null==r?void 0:r.audioTrack)})),re=J((function(e,t){var r=B(e,t);return y(e,null==r?void 0:r.videoTrack)})),ne=t.createSelector([D,R],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),ie="HMS-Store:",oe=function(){function e(){}return e.d=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).debug.apply(e,[ie].concat(r))},e.i=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[ie].concat(r))},e.w=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[ie].concat(r))},e.e=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[ie].concat(r))},e}(),ae=function(e,t){return e&&t},se=function(e,t){return e&&!t},ce=function(e,t){return!e&&t},ue=function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},le=function(e,t){for(var r,n=new Set,i=l(e);!(r=i()).done;)n.add(r.value);for(var o,a=l(t);!(o=a()).done;)n.add(o.value);return Array.from(n)};function de(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var fe,he,ve=function(){function e(e,t,r){this.hmsSDKTracks={},this.isRoomJoinCalled=!1,this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0}catch(e){throw this.isRoomJoinCalled=!1,oe.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=s(f.mark((function e(){var t=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(P)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){t.resetState(),oe.i("left room")})).catch((function(e){oe.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=s(f.mark((function e(t){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare();case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=s(f.mark((function e(t,r){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncPeers();case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=s(f.mark((function e(t){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncPeers();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(M))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(L))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=s(f.mark((function e(t,r){var n,i=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.store.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:i.logPossibleInconsistency("track id not found for setEnabled")})),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncPeers(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(5),this.store.setState((function(e){e.tracks[t].displayEnabled=!r}));case 14:this.hmsNotifications.sendTrackUpdate(r?E.TRACK_UNMUTED:E.TRACK_MUTED,t);case 16:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(M))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncPeers();case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(L))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncPeers();case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){if(""!==e.trim()){var t=this.sdk.sendMessage(exports.HMSMessageType.CHAT,e),r=m.convertMessage(t);r.read=!0,r.senderName="You",this.onHMSMessage(r)}else oe.d("Ignoring empty message send")},t.setMessageRead=function(e,t){var r=this;this.store.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}))},t.attachVideo=function(){var e=s(f.mark((function e(t,r){var n=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var i=n.store.subscribe(function(){var o=s(f.mark((function o(a){return f.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!a){o.next=5;break}return o.next=3,n.attachVideoInternal(t,r);case 3:i(),e();case 5:case"end":return o.stop()}}),o)})));return function(e){return o.apply(this,arguments)}}(),U)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.resetState=function(){this.store.setState((function(e){Object.assign(e,{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}})})),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.startScreenShare=function(){var e=s(f.mark((function e(){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(j)){e.next=7;break}return e.next=4,this.sdk.startScreenShare(this.syncPeers.bind(this));case 4:this.syncPeers(),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=s(f.mark((function e(){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(j)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncPeers(),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=s(f.mark((function e(t,r){var n,i,o;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=11;break}if(!(null!==(i=r.srcObject)&&i instanceof MediaStream)){e.next=7;break}if((null==(o=i.getVideoTracks()[0])?void 0:o.id)!==n.trackId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,n.addSink(r);case 9:e.next=12;break;case 11:this.logPossibleInconsistency("no video track found to add sink");case 12:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncPeers=function(){for(var e,t=this,r={},n=[],i={},o={},a={},s=l(this.sdk.getPeers());!(e=s()).done;){var c=e.value,u=m.convertPeer(c);r[u.id]=u,n.push(u.id);for(var d,f=l([c.audioTrack,c.videoTrack].concat(c.auxiliaryTracks));!(d=f()).done;){var h=d.value;if(h){var v=m.convertTrack(h);this.enrichHMSTrack(v,h),i[v.id]=v,o[h.trackId]=h}}u.isLocal&&Object.assign(a,this.getMediaSettings(c))}this.store.setState((function(e){e.room.peers=n;var s=e.tracks;!function(e,t,r,n){for(var i,o=l(le(Object.keys(e),Object.keys(t)));!(i=o()).done;){var a=i.value,s=e[a],c=t[a];ae(s,c)?(ue(s.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=s.auxiliaryTracks),de(s,c,r,n),Object.assign(s,c)):se(s,c)?delete e[a]:ce(s,c)&&(e[a]=c)}}(e.peers,r,i,o),function(e,t){for(var r,n=l(le(Object.keys(e),Object.keys(t)));!(r=n()).done;){var i=r.value,o=e[i],a=t[i];ae(o,a)?Object.assign(o,a):se(o,a)?delete e[i]:ce(o,a)&&(e[i]=a)}}(s,i),Object.assign(e.settings,a),t.hmsSDKTracks=o}))},t.onJoin=function(e){this.store.setState((function(t){Object.assign(t.room,m.convertRoom(e)),t.room.isConnected=!0})),this.syncPeers()},t.onRoomUpdate=function(){this.syncPeers()},t.onPeerUpdate=function(e,t){if(e!==v.BECAME_DOMINANT_SPEAKER&&e!==v.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Y(t.peerId));this.syncPeers(),this.hmsNotifications.sendPeerUpdate(e,r)}},t.onTrackUpdate=function(e,t,r){e===E.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncPeers(),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.handleTrackRemove=function(e,t){var r=this;this.store.setState((function(n){var i=n.peers[t.peerId],o=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,i.audioTrack))delete i.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,i.videoTrack))delete i.videoTrack;else{var a=i.auxiliaryTracks.indexOf(e.trackId);a>-1&&r.isSameStoreSDKTrack(e.trackId,i.auxiliaryTracks[a])&&i.auxiliaryTracks.splice(a,1)}delete o[e.trackId],delete r.hmsSDKTracks[e.trackId]}))},t.onMessageReceived=function(e){var t=m.convertMessage(e);t.read=!1,t.senderName=this.store.getState(z(t.sender)),this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.store.setState((function(r){e.id=String(t.store.getState(H)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}))},t.onAudioLevelUpdate=function(e){this.store.setState((function(t){var r={};e.forEach((function(e){r[e.peerId]=e.audioLevel,t.speakers[e.peerId]||(t.speakers[e.peerId]={})}));for(var n=0,i=Object.entries(t.speakers);n<i.length;n++){var o=i[n],a=o[0],s=o[1];s.audioLevel=r[a]||0,0===s.audioLevel&&delete t.speakers[a]}}))},t.onReconnected=function(){this.syncPeers(),this.hmsNotifications.sendReconnected()},t.onReconnecting=function(e){oe.e("Reconnection: received error from sdk",e),this.hmsNotifications.sendReconnecting(e)},t.onError=function(e){1===Math.floor(e.code/1e3)&&this.leave().then((function(){return console.log("error from SDK, left room.")})),this.hmsNotifications.sendError(e),oe.e("received error from sdk",e)},t.setEnabledSDKTrack=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.enrichHMSTrack=function(e,t){var r=t.getMediaTrackSettings();e.height=r.height,e.width=r.width,e.deviceID=r.deviceId},t.getMediaSettings=function(e){var t,r,n,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(i=n.getMediaTrackSettings())?void 0:i.deviceId}},t.localAndVideoUnmuting=function(e){if(this.store.getState(N).videoTrack!==e)return!1;var t=this.store.getState(G),r=this.store.getState(U);return t&&!r},t.logPossibleInconsistency=function(e){oe.w("possible inconsistency detected - ",e)},t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},e}(),pe=((fe={})[v.PEER_JOINED]=k.PEER_JOINED,fe[v.PEER_LEFT]=k.PEER_LEFT,fe[v.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",fe[v.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",fe),Ee=((he={})[E.TRACK_ADDED]=k.TRACK_ADDED,he[E.TRACK_REMOVED]=k.TRACK_REMOVED,he[E.TRACK_MUTED]=k.TRACK_MUTED,he[E.TRACK_UNMUTED]=k.TRACK_UNMUTED,he),ke=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){var r=function(t){e(t.detail)};return t.eventTarget.addEventListener("hmsNotification",r),function(){t.eventTarget.removeEventListener("hmsNotification",r)}},this.store=e,this.eventTarget=new EventTarget}var t=e.prototype;return t.sendPeerUpdate=function(e,t){var r=this.store.getState(Y(null==t?void 0:t.id))||t,n=pe[e];if(n){var i=this.createNotification(n,r,h.INFO);this.emitEvent(i)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState($(t)),n=Ee[e];if(n){var i=this.createNotification(n,r,h.INFO);this.emitEvent(i)}},t.sendMessageReceived=function(e){var t=this.createNotification(k.NEW_MESSAGE,e,h.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(k.ERROR,e,h.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(k.RECONNECTING,e,h.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(k.RECONNECTED,null,h.INFO);this.emitEvent(e)},t.emitEvent=function(e){var t=new CustomEvent("hmsNotification",{detail:e});this.eventTarget.dispatchEvent(t)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),me=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new ke(this.store),this.actions=r||new ve(this.store,new o.HMSSdk,this.notifications)}var t=e.prototype;return t.getStore=function(){return c({},this.store,{setState:function(){throw new Error("Mutating store is not allowed")}})},t.getHMSActions=function(){return this.actions},t.getNotifications=function(){return this.notifications},e.createNewHMSStore=function(){var t=i(r.devtools(e.immerMiddleware((function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}})),"HMSStore")),o=t.setState;t.setState=function(e){return o(n(e))};var a=t.getState;return t.getState=function(e){return e?e(a()):a()},t},e.immerMiddleware=function(e){return function(t,r,i){return e((function(e){return t(n(e))}),r,i)}},e}();exports.HMSNoticiationSeverity=h,exports.HMSNotificationTypes=k,exports.HMSReactiveStore=me,exports.HMSSDKActions=ve,exports.createDefaultStoreState=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}},exports.selectAuxiliaryAudioByPeerID=X,exports.selectCameraStreamByPeerID=ee,exports.selectDominantSpeaker=K,exports.selectHMSMessages=F,exports.selectHMSMessagesCount=H,exports.selectIsConnectedToRoom=P,exports.selectIsLocalAudioEnabled=function(e){var t=N(e);return y(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=j,exports.selectIsLocalVideoDisplayEnabled=G,exports.selectIsLocalVideoEnabled=U,exports.selectIsPeerAudioEnabled=te,exports.selectIsPeerVideoEnabled=re,exports.selectIsSomeoneScreenSharing=function(e){return _(e).some((function(t){return g(e,t)}))},exports.selectLocalAudioTrackID=M,exports.selectLocalMediaSettings=I,exports.selectLocalPeer=N,exports.selectLocalPeerID=O,exports.selectLocalVideoTrackID=L,exports.selectMaxTilesCount=A,exports.selectMessageIDsInOrder=b,exports.selectMessagesMap=x,exports.selectPeerAudioByID=Q,exports.selectPeerByID=Y,exports.selectPeerNameByID=z,exports.selectPeerScreenSharing=function(e){return _(e).find((function(t){return g(e,t)}))},exports.selectPeers=_,exports.selectPeersMap=D,exports.selectPeersScreenSharing=function(e){return _(e).filter((function(t){return g(e,t)}))},exports.selectPeersWithAudioStatus=ne,exports.selectRemotePeers=C,exports.selectRoom=S,exports.selectScreenShareByPeerID=Z,exports.selectSpeakers=w,exports.selectTrackByID=$,exports.selectTracksMap=R,exports.selectUnreadHMSMessagesCount=V; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("reselect"),r=require("zustand/middleware"),n=e(require("immer")),i=e(require("zustand/vanilla")),o=require("@100mslive/hms-video");function a(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){a(o,n,i,s,c,"next",e)}function c(e){a(o,n,i,s,c,"throw",e)}s(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var d,f=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new D(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var l={};function d(){}function f(){}function h(){}var v={};v[i]=function(){return this};var p=Object.getPrototypeOf,E=p&&p(p(x([])));E&&E!==t&&r.call(E,i)&&(v=E);var k=h.prototype=d.prototype=Object.create(v);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function T(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function y(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function x(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:b}}function b(){return{value:void 0,done:!0}}return f.prototype=k.constructor=h,h.constructor=f,f.displayName=s(h,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,a,"GeneratorFunction")),e.prototype=Object.create(k),e},e.awrap=function(e){return{__await:e}},g(m.prototype),m.prototype[o]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(k),s(k,a,"Generator"),k[i]=function(){return this},k.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=x,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;S(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(d={exports:{}}),d.exports);(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat";var h=function(){};h.INFO="info",h.ERROR="error",h.CRITICAL="critical";var v,p,E,k=function(){};k.PEER_JOINED="PEER_JOINED",k.PEER_LEFT="PEER_LEFT",k.NEW_MESSAGE="NEW_MESSAGE",k.ERROR="ERROR",k.RECONNECTING="RECONNECTING",k.RECONNECTED="RECONNECTED",k.TRACK_ADDED="TRACK_ADDED",k.TRACK_REMOVED="TRACK_REMOVED",k.TRACK_MUTED="TRACK_MUTED",k.TRACK_UNMUTED="TRACK_UNMUTED",function(e){e[e.PEER_JOINED=0]="PEER_JOINED",e[e.PEER_LEFT=1]="PEER_LEFT",e[e.AUDIO_TOGGLED=2]="AUDIO_TOGGLED",e[e.VIDEO_TOGGLED=3]="VIDEO_TOGGLED",e[e.BECAME_DOMINANT_SPEAKER=4]="BECAME_DOMINANT_SPEAKER",e[e.RESIGNED_DOMINANT_SPEAKER=5]="RESIGNED_DOMINANT_SPEAKER",e[e.STARTED_SPEAKING=6]="STARTED_SPEAKING",e[e.STOPPED_SPEAKING=7]="STOPPED_SPEAKING"}(v||(v={})),function(e){e[e.PEER_ADDED=0]="PEER_ADDED",e[e.PEER_REMOVED=1]="PEER_REMOVED",e[e.PEER_KNOCKED=2]="PEER_KNOCKED",e[e.ROOM_TYPE_CHANGED=3]="ROOM_TYPE_CHANGED",e[e.METADATA_UPDATED=4]="METADATA_UPDATED",e[e.SCREENSHARE_STARTED=5]="SCREENSHARE_STARTED",e[e.SCREENSHARE_STOPPED=6]="SCREENSHARE_STOPPED",e[e.DEFAULT_UPDATE=7]="DEFAULT_UPDATE"}(p||(p={})),function(e){e[e.TRACK_ADDED=0]="TRACK_ADDED",e[e.TRACK_REMOVED=1]="TRACK_REMOVED",e[e.TRACK_MUTED=2]="TRACK_MUTED",e[e.TRACK_UNMUTED=3]="TRACK_UNMUTED",e[e.TRACK_DESCRIPTION_CHANGED=4]="TRACK_DESCRIPTION_CHANGED"}(E||(E={}));var g=function(){function e(){}return e.convertPeer=function(e){var t,r;return{id:e.peerId,name:e.name,role:e.role,isLocal:e.isLocal,videoTrack:null==(t=e.videoTrack)?void 0:t.trackId,audioTrack:null==(r=e.audioTrack)?void 0:r.trackId,auxiliaryTracks:e.auxiliaryTracks.map((function(e){return e.trackId})),customerUserId:e.customerUserId,customerDescription:e.customerDescription}},e.convertTrack=function(e){return{id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled}},e.convertRoom=function(e){return{id:e.id,name:e.name,hasWaitingRoom:e.hasWaitingRoom,shareableLink:e.shareableLink}},e.convertMessage=function(e){return{sender:e.sender,time:e.time,type:e.type,message:e.message}},e}();function m(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&T(e.tracks[t])}))}function T(e){return e&&"video"===e.type&&"screen"===e.source}function y(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var S=function(e){return e.room},D=function(e){return e.peers},x=function(e){return e.messages.byID},b=function(e){return e.messages.allIDs},R=function(e){return e.tracks},I=function(e){return e.settings},A=t.createSelector(I,(function(e){return e.maxTileCount})),w=function(e){return e.speakers},P=t.createSelector([S],(function(e){return e&&e.isConnected})),_=t.createSelector([S,D],(function(e,t){return e.peers.map((function(e){return t[e]}))})),N=t.createSelector(_,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),O=t.createSelector(N,(function(e){return null==e?void 0:e.id})),M=t.createSelector(N,(function(e){return null==e?void 0:e.audioTrack})),L=t.createSelector(N,(function(e){return null==e?void 0:e.videoTrack})),C=t.createSelector(_,(function(e){return e.filter((function(e){return!e.isLocal}))})),K=t.createSelector(D,w,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,i=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>i?1:-1}));if(r.length>0&&r[0][1].audioLevel&&r[0][1].audioLevel>0){var n=r[0][0];if(n in e)return e[n]}return null})),U=function(e){var t=N(e);return y(e,null==t?void 0:t.videoTrack)},G=function(e){var t=N(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},j=function(e){return m(e,N(e))},H=t.createSelector(b,(function(e){return e.length})),V=t.createSelector(x,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),F=t.createSelector(b,x,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r}));function J(e){return function(t){return function(r){return e(r,t)}}}var W=function(e,t){return t},B=t.createSelector([D,W],(function(e,t){return t?e[t]:null})),q=t.createSelector([R,W],(function(e,t){return t?e[t]:null})),Y=J(B),z=J(t.createSelector(B,(function(e){return null==e?void 0:e.name}))),$=J(q),Q=J(t.createSelector((function(e,t){return t?e.speakers[t]:null}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),X=J((function(e,t){var r=B(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return(r=e.tracks[t])&&"audio"===r.type;var r}));return n?e.tracks[n]:void 0}})),Z=J((function(e,t){var r=B(e,t);if(r&&m(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return T(e.tracks[t])}));return n?e.tracks[n]:void 0}})),ee=J((function(e,t){var r=B(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),te=J((function(e,t){var r=B(e,t);return y(e,null==r?void 0:r.audioTrack)})),re=J((function(e,t){var r=B(e,t);return y(e,null==r?void 0:r.videoTrack)})),ne=t.createSelector([D,R],(function(e,t){return Object.values(e).map((function(e){var r;return{peer:e,isAudioEnabled:!!e.audioTrack&&(null==(r=t[e.audioTrack])?void 0:r.enabled)}}))})),ie="HMS-Store:",oe=function(){function e(){}return e.d=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).debug.apply(e,[ie].concat(r))},e.i=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,[ie].concat(r))},e.w=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).warn.apply(e,[ie].concat(r))},e.e=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).error.apply(e,[ie].concat(r))},e}(),ae=function(e,t){return e&&t},se=function(e,t){return e&&!t},ce=function(e,t){return!e&&t},ue=function(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},le=function(e,t){for(var r,n=new Set,i=l(e);!(r=i()).done;)n.add(r.value);for(var o,a=l(t);!(o=a()).done;)n.add(o.value);return Array.from(n)};function de(e,t,r,n){e.isLocal&&e.videoTrack&&t.videoTrack&&e.videoTrack!==t.videoTrack&&(n[e.videoTrack]=n[t.videoTrack],delete n[t.videoTrack],r[e.videoTrack]=r[t.videoTrack],r[e.videoTrack].id=e.videoTrack,delete r[t.videoTrack],t.videoTrack=e.videoTrack)}var fe,he,ve=function(){function e(e,t,r){this.hmsSDKTracks={},this.isRoomJoinCalled=!1,this.store=e,this.sdk=t,this.hmsNotifications=r}var t=e.prototype;return t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0}catch(e){throw this.isRoomJoinCalled=!1,oe.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=s(f.mark((function e(){var t=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(P)){e.next=4;break}return this.logPossibleInconsistency("room leave is called when no room is connected"),e.abrupt("return");case 4:return e.abrupt("return",this.sdk.leave().then((function(){t.resetState(),oe.i("left room")})).catch((function(e){oe.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.setScreenShareEnabled=function(){var e=s(f.mark((function e(t){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=5;break}return e.next=3,this.startScreenShare();case 3:e.next=7;break;case 5:return e.next=7,this.stopScreenShare();case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addTrack=function(){var e=s(f.mark((function e(t,r){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="regular"),e.next=3,this.sdk.addTrack(t,r);case 3:this.syncPeers();case 4:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.removeTrack=function(){var e=s(f.mark((function e(t){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sdk.removeTrack(t);case 2:this.syncPeers();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalAudioEnabled=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(M))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalVideoEnabled=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(L))){e.next=4;break}return e.next=4,this.setEnabledTrack(r,t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setEnabledTrack=function(){var e=s(f.mark((function e(t,r){var n,i=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null==(n=this.store.getState().tracks[t])?void 0:n.enabled)!==r){e.next=4;break}return this.logPossibleInconsistency("local track["+t+"] enabled state - "+r),e.abrupt("return");case 4:return this.store.setState((function(e){e.tracks[t]?e.tracks[t].displayEnabled=r:i.logPossibleInconsistency("track id not found for setEnabled")})),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncPeers(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(5),this.store.setState((function(e){e.tracks[t].displayEnabled=!r}));case 14:this.hmsNotifications.sendTrackUpdate(r?E.TRACK_UNMUTED:E.TRACK_MUTED,t);case 16:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(M))){e.next=5;break}return e.next=4,this.setSDKLocalAudioTrackSettings(r,t);case 4:this.syncPeers();case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setVideoSettings=function(){var e=s(f.mark((function e(t){var r;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(L))){e.next=5;break}return e.next=4,this.setSDKLocalVideoTrackSettings(r,t);case 4:this.syncPeers();case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.sendMessage=function(e){if(""!==e.trim()){var t=this.sdk.sendMessage(exports.HMSMessageType.CHAT,e),r=g.convertMessage(t);r.read=!0,r.senderName="You",this.onHMSMessage(r)}else oe.d("Ignoring empty message send")},t.setMessageRead=function(e,t){var r=this;this.store.setState((function(n){t?n.messages.byID[t]?n.messages.byID[t].read=e:r.logPossibleInconsistency("no message with id is found"):n.messages.allIDs.forEach((function(t){n.messages.byID[t].read=e}))}))},t.attachVideo=function(){var e=s(f.mark((function e(t,r){var n=this;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localAndVideoUnmuting(t)){e.next=4;break}return e.abrupt("return",new Promise((function(e){var i=n.store.subscribe(function(){var o=s(f.mark((function o(a){return f.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(!a){o.next=5;break}return o.next=3,n.attachVideoInternal(t,r);case 3:i(),e();case 5:case"end":return o.stop()}}),o)})));return function(e){return o.apply(this,arguments)}}(),U)})));case 4:return e.next=6,this.attachVideoInternal(t,r);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.detachVideo=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=6;break}return e.next=4,n.removeSink(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("no video track found to remove sink");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.resetState=function(){this.store.setState((function(e){Object.assign(e,{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}})})),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},t.sdkJoinWithListeners=function(e){this.sdk.join(e,{onJoin:this.onJoin.bind(this),onRoomUpdate:this.onRoomUpdate.bind(this),onPeerUpdate:this.onPeerUpdate.bind(this),onTrackUpdate:this.onTrackUpdate.bind(this),onMessageReceived:this.onMessageReceived.bind(this),onError:this.onError.bind(this),onReconnected:this.onReconnected.bind(this),onReconnecting:this.onReconnecting.bind(this)}),this.sdk.addAudioListener({onAudioLevelUpdate:this.onAudioLevelUpdate.bind(this)})},t.startScreenShare=function(){var e=s(f.mark((function e(){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(j)){e.next=7;break}return e.next=4,this.sdk.startScreenShare(this.syncPeers.bind(this));case 4:this.syncPeers(),e.next=8;break;case 7:this.logPossibleInconsistency("start screenshare is called while it's on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.stopScreenShare=function(){var e=s(f.mark((function e(){return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(j)){e.next=7;break}return e.next=4,this.sdk.stopScreenShare();case 4:this.syncPeers(),e.next=8;break;case 7:this.logPossibleInconsistency("stop screenshare is called while it's not on");case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.attachVideoInternal=function(){var e=s(f.mark((function e(t,r){var n,i,o;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])||"video"!==n.type){e.next=11;break}if(!(null!==(i=r.srcObject)&&i instanceof MediaStream)){e.next=7;break}if((null==(o=i.getVideoTracks()[0])?void 0:o.id)!==n.trackId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,n.addSink(r);case 9:e.next=12;break;case 11:this.logPossibleInconsistency("no video track found to add sink");case 12:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.syncPeers=function(){for(var e,t=this,r={},n=[],i={},o={},a={},s=l(this.sdk.getPeers());!(e=s()).done;){var c=e.value,u=g.convertPeer(c);r[u.id]=u,n.push(u.id);for(var d,f=l([c.audioTrack,c.videoTrack].concat(c.auxiliaryTracks));!(d=f()).done;){var h=d.value;if(h){var v=g.convertTrack(h);this.enrichHMSTrack(v,h),i[v.id]=v,o[h.trackId]=h}}u.isLocal&&Object.assign(a,this.getMediaSettings(c))}this.store.setState((function(e){e.room.peers=n;var s=e.tracks;!function(e,t,r,n){for(var i,o=l(le(Object.keys(e),Object.keys(t)));!(i=o()).done;){var a=i.value,s=e[a],c=t[a];ae(s,c)?(ue(s.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=s.auxiliaryTracks),de(s,c,r,n),Object.assign(s,c)):se(s,c)?delete e[a]:ce(s,c)&&(e[a]=c)}}(e.peers,r,i,o),function(e,t){for(var r,n=l(le(Object.keys(e),Object.keys(t)));!(r=n()).done;){var i=r.value,o=e[i],a=t[i];ae(o,a)?Object.assign(o,a):se(o,a)?delete e[i]:ce(o,a)&&(e[i]=a)}}(s,i),Object.assign(e.settings,a),t.hmsSDKTracks=o}))},t.onJoin=function(e){this.store.setState((function(t){Object.assign(t.room,g.convertRoom(e)),t.room.isConnected=!0})),this.syncPeers()},t.onRoomUpdate=function(){this.syncPeers()},t.onPeerUpdate=function(e,t){if(e!==v.BECAME_DOMINANT_SPEAKER&&e!==v.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(Y(t.peerId));this.syncPeers(),this.hmsNotifications.sendPeerUpdate(e,r)}},t.onTrackUpdate=function(e,t,r){e===E.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncPeers(),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},t.handleTrackRemove=function(e,t){var r=this;this.store.setState((function(n){var i=n.peers[t.peerId],o=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,i.audioTrack))delete i.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,i.videoTrack))delete i.videoTrack;else{var a=i.auxiliaryTracks.indexOf(e.trackId);a>-1&&r.isSameStoreSDKTrack(e.trackId,i.auxiliaryTracks[a])&&i.auxiliaryTracks.splice(a,1)}delete o[e.trackId],delete r.hmsSDKTracks[e.trackId]}))},t.onMessageReceived=function(e){var t=g.convertMessage(e);t.read=!1,t.senderName=this.store.getState(z(t.sender)),this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},t.onHMSMessage=function(e){var t=this;this.store.setState((function(r){e.id=String(t.store.getState(H)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}))},t.onAudioLevelUpdate=function(e){this.store.setState((function(t){var r={};e.forEach((function(e){r[e.peerId]=e.audioLevel,t.speakers[e.peerId]||(t.speakers[e.peerId]={})}));for(var n=0,i=Object.entries(t.speakers);n<i.length;n++){var o=i[n],a=o[0],s=o[1];s.audioLevel=r[a]||0,0===s.audioLevel&&delete t.speakers[a]}}))},t.onReconnected=function(){this.syncPeers(),this.hmsNotifications.sendReconnected()},t.onReconnecting=function(e){oe.e("Reconnection: received error from sdk",e),this.hmsNotifications.sendReconnecting(e)},t.onError=function(e){1===Math.floor(e.code/1e3)&&this.leave().then((function(){return console.log("error from SDK, left room.")})),this.hmsNotifications.sendError(e),oe.e("received error from sdk",e)},t.setEnabledSDKTrack=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setEnabled(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("track "+t+" not present, unable to enabled/disable");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalVideoTrackSettings=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.setSDKLocalAudioTrackSettings=function(){var e=s(f.mark((function e(t,r){var n;return f.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.hmsSDKTracks[t])){e.next=6;break}return e.next=4,n.setSettings(r);case 4:e.next=7;break;case 6:this.logPossibleInconsistency("local track "+t+" not present, unable to set settings");case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.enrichHMSTrack=function(e,t){var r=t.getMediaTrackSettings();e.height=r.height,e.width=r.width,e.deviceID=r.deviceId},t.getMediaSettings=function(e){var t,r,n,i;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(i=n.getMediaTrackSettings())?void 0:i.deviceId}},t.localAndVideoUnmuting=function(e){if(this.store.getState(N).videoTrack!==e)return!1;var t=this.store.getState(G),r=this.store.getState(U);return t&&!r},t.logPossibleInconsistency=function(e){oe.w("possible inconsistency detected - ",e)},t.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},e}(),pe=((fe={})[v.PEER_JOINED]=k.PEER_JOINED,fe[v.PEER_LEFT]=k.PEER_LEFT,fe[v.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",fe[v.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",fe),Ee=((he={})[E.TRACK_ADDED]=k.TRACK_ADDED,he[E.TRACK_REMOVED]=k.TRACK_REMOVED,he[E.TRACK_MUTED]=k.TRACK_MUTED,he[E.TRACK_UNMUTED]=k.TRACK_UNMUTED,he),ke=function(){var e=this;this.addEventListener=function(t,r){t in e.listeners||(e.listeners[t]=[]),e.listeners[t].push(r)},this.removeEventListener=function(t,r){if(t in e.listeners)for(var n=e.listeners[t],i=0,o=n.length;i<o;i++)if(n[i]===r)return void n.splice(i,1)},this.dispatchEvent=function(t){if(!(t.type in e.listeners))return!0;for(var r=e.listeners[t.type].slice(),n=0,i=r.length;n<i;n++)r[n].call(e,t);return!t.defaultPrevented},this.listeners={}},ge=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){var r=function(t){e(t.detail)};return t.eventTarget.addEventListener("hmsNotification",r),function(){t.eventTarget.removeEventListener("hmsNotification",r)}},this.store=e;var r="function"!=typeof EventTarget.constructor?ke:EventTarget;this.eventTarget=new r}var t=e.prototype;return t.sendPeerUpdate=function(e,t){var r=this.store.getState(Y(null==t?void 0:t.id))||t,n=pe[e];if(n){var i=this.createNotification(n,r,h.INFO);this.emitEvent(i)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState($(t)),n=Ee[e];if(n){var i=this.createNotification(n,r,h.INFO);this.emitEvent(i)}},t.sendMessageReceived=function(e){var t=this.createNotification(k.NEW_MESSAGE,e,h.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(k.ERROR,e,h.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(k.RECONNECTING,e,h.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(k.RECONNECTED,null,h.INFO);this.emitEvent(e)},t.emitEvent=function(e){var t=new CustomEvent("hmsNotification",{detail:e});this.eventTarget.dispatchEvent(t)},t.createNotification=function(e,t,r,n){return void 0===n&&(n=""),this.id++,{id:this.id,type:e,message:n,data:t,severity:r}},e}(),me=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new ge(this.store),this.actions=r||new ve(this.store,new o.HMSSdk,this.notifications)}var t=e.prototype;return t.getStore=function(){return c({},this.store,{setState:function(){throw new Error("Mutating store is not allowed")}})},t.getHMSActions=function(){return this.actions},t.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var t=i(r.devtools(e.immerMiddleware((function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}})),"HMSStore")),o=t.setState;t.setState=function(e){return o(n(e))};var a=t.getState;return t.getState=function(e){return e?e(a()):a()},t},e.immerMiddleware=function(e){return function(t,r,i){return e((function(e){return t(n(e))}),r,i)}},e}();exports.HMSNoticiationSeverity=h,exports.HMSNotificationTypes=k,exports.HMSReactiveStore=me,exports.HMSSDKActions=ve,exports.createDefaultStoreState=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}},exports.selectAuxiliaryAudioByPeerID=X,exports.selectCameraStreamByPeerID=ee,exports.selectDominantSpeaker=K,exports.selectHMSMessages=F,exports.selectHMSMessagesCount=H,exports.selectIsConnectedToRoom=P,exports.selectIsLocalAudioEnabled=function(e){var t=N(e);return y(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=j,exports.selectIsLocalVideoDisplayEnabled=G,exports.selectIsLocalVideoEnabled=U,exports.selectIsPeerAudioEnabled=te,exports.selectIsPeerVideoEnabled=re,exports.selectIsSomeoneScreenSharing=function(e){return _(e).some((function(t){return m(e,t)}))},exports.selectLocalAudioTrackID=M,exports.selectLocalMediaSettings=I,exports.selectLocalPeer=N,exports.selectLocalPeerID=O,exports.selectLocalVideoTrackID=L,exports.selectMaxTilesCount=A,exports.selectMessageIDsInOrder=b,exports.selectMessagesMap=x,exports.selectPeerAudioByID=Q,exports.selectPeerByID=Y,exports.selectPeerNameByID=z,exports.selectPeerScreenSharing=function(e){return _(e).find((function(t){return m(e,t)}))},exports.selectPeers=_,exports.selectPeersMap=D,exports.selectPeersScreenSharing=function(e){return _(e).filter((function(t){return m(e,t)}))},exports.selectPeersWithAudioStatus=ne,exports.selectRemotePeers=C,exports.selectRoom=S,exports.selectScreenShareByPeerID=Z,exports.selectSpeakers=w,exports.selectTrackByID=$,exports.selectTracksMap=R,exports.selectUnreadHMSMessagesCount=V; | ||
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map |
{ | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"license": "MIT", | ||
@@ -18,2 +18,3 @@ "main": "dist/index.js", | ||
"test:watch": "tsdx test --watch", | ||
"test:coverage": "tsdx test --coverage", | ||
"lint": "tsdx lint", | ||
@@ -20,0 +21,0 @@ "lint:fix": "tsdx lint --fix", |
@@ -13,2 +13,3 @@ import { IHMSNotifications } from '../IHMSNotifications'; | ||
} from '../schema'; | ||
import { getEventTarget, HMSNotificationCallback } from './EventTargetPolyfill'; | ||
@@ -24,7 +25,8 @@ const HMS_NOTIFICATION_EVENT = 'hmsNotification'; | ||
this.store = store; | ||
this.eventTarget = new EventTarget(); | ||
const EventTargetPolyfilled = getEventTarget(); | ||
this.eventTarget = new EventTargetPolyfilled(); | ||
} | ||
onNotification = (cb: (notification: HMSNotification) => void): (() => void) => { | ||
const listener = (e: any) => { | ||
const listener: HMSNotificationCallback = (e: any) => { | ||
cb(e.detail as HMSNotification); | ||
@@ -31,0 +33,0 @@ }; |
@@ -61,3 +61,3 @@ import { devtools } from 'zustand/middleware'; | ||
getNotifications(): IHMSNotifications { | ||
return this.notifications; | ||
return { onNotification: this.notifications.onNotification }; | ||
} | ||
@@ -64,0 +64,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
699014
71
7247