Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@100mslive/hms-video-store

Package Overview
Dependencies
Maintainers
15
Versions
730
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@100mslive/hms-video-store - npm Package Compare versions

Comparing version 0.1.38 to 0.1.39

4

dist/core/hmsSDKStore/adapter.d.ts

@@ -0,9 +1,9 @@

import { HMSTrack as SDKHMSTrack, HMSRemoteAudioTrack as SDKHMSRemoteAudioTrack, HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack } from '@100mslive/hms-video';
import { HMSPeer, HMSMessage, HMSTrack, HMSRoom } from '../schema';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';
import * as sdkTypes from './sdkTypes';
export declare class SDKToHMS {
static convertPeer(sdkPeer: sdkTypes.HMSPeer): Partial<HMSPeer> & Pick<HMSPeer, 'id'>;
static convertTrack(sdkTrack: SDKHMSTrack): HMSTrack;
static convertTrack(sdkTrack: SDKHMSTrack | SDKHMSRemoteVideoTrack | SDKHMSRemoteAudioTrack): HMSTrack;
static convertRoom(sdkRoom: sdkTypes.HMSRoom): Partial<HMSRoom>;
static convertMessage(sdkMessage: sdkTypes.HMSMessage): Partial<HMSMessage> & Pick<HMSMessage, 'sender'>;
}
import { HMSMessage, HMSTrackSource } from '../schema';
import { IHMSActions } from '../IHMSActions';
import * as sdkTypes from './sdkTypes';
import { HMSSdk } from '@100mslive/hms-video';
import { HMSSdk, HMSTrack as SDKHMSTrack, HMSException as SDKHMSException } from '@100mslive/hms-video';
import { IHMSStore } from '../IHMSStore';
import SDKHMSException from '@100mslive/hms-video/dist/error/HMSException';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';
import { HMSNotifications } from './HMSNotifications';

@@ -36,2 +34,3 @@ /**

constructor(store: IHMSStore, sdk: HMSSdk, notificationManager: HMSNotifications);
setVolume(trackId: string, value: number): void;
preview(config: sdkTypes.HMSConfig): void;

@@ -38,0 +37,0 @@ join(config: sdkTypes.HMSConfig): void;

@@ -8,3 +8,3 @@ import HMSPeer from '@100mslive/hms-video/dist/interfaces/hms-peer';

import SDKHMSVideoTrackSettings from '@100mslive/hms-video/dist/media/settings/HMSVideoTrackSettings';
import SDKHMSException from '@100mslive/hms-video/dist/error/HMSException';
import { HMSException as SDKHMSException } from '@100mslive/hms-video';
declare type HMSAudioTrackSettings = SDKHMSAudioTrackSettings;

@@ -11,0 +11,0 @@ declare type HMSVideoTrackSettings = SDKHMSVideoTrackSettings;

import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';
import { HMSTrack as SDKHMSTrack } from '@100mslive/hms-video';
/**

@@ -4,0 +4,0 @@ * updates draftPeers with newPeers ensuring minimal reference changes

@@ -107,2 +107,8 @@ import { HMSAudioTrackSettings, HMSVideoTrackSettings } from './hmsSDKStore/sdkTypes';

detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
/**
* set the volume of selected audio track locally
* @param trackId trackId as stored in the store
* @param value number between 0-100
*/
setVolume(trackId: string, value: number): void;
}

@@ -109,0 +115,0 @@ /**

@@ -37,2 +37,3 @@ export declare type HMSPeerID = string;

displayEnabled?: boolean;
volume?: number;
}

@@ -39,0 +40,0 @@ /**

@@ -8,4 +8,11 @@ import { HMSStore, HMSTrack } from '../schema';

export declare const selectScreenShareByPeerID: (id?: string | undefined) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectScreenShareAudioByPeerID: (id?: string | undefined) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectCameraStreamByPeerID: (id?: string | undefined) => (store: HMSStore) => HMSTrack | undefined;
export declare const selectIsPeerAudioEnabled: (id?: string | undefined) => (store: HMSStore) => boolean;
export declare const selectIsPeerVideoEnabled: (id?: string | undefined) => (store: HMSStore) => boolean;
export declare const selectIsAudioLocallyMuted: (id?: string | undefined) => (store: HMSStore) => boolean | undefined;
export declare const selectIsLocallyMutedByPeerID: (id?: string | undefined) => (store: HMSStore) => boolean | undefined;
export declare const selectIsScreenShareLocallyMutedByPeerID: (id?: string | undefined) => (store: HMSStore) => boolean | undefined;
export declare const selectAudioTrackVolume: (id?: string | undefined) => (store: HMSStore) => number | undefined;
export declare const selectAudioVolumeByPeerID: (id?: string | undefined) => (store: HMSStore) => number | undefined;
export declare const selectScreenshareAudioVolumeByPeerID: (id?: string | undefined) => (store: HMSStore) => number | undefined;
import { HMSPeer, HMSStore, HMSTrack } from '../schema';
export declare function isScreenSharing(store: HMSStore, peer: HMSPeer): boolean;
export declare function isAudio(track: HMSTrack | undefined): boolean | undefined;
export declare function isVideo(track: HMSTrack | undefined): boolean | undefined;
export declare function isScreenShare(track: HMSTrack | undefined): boolean | undefined;

@@ -5,0 +6,0 @@ export declare function isTrackEnabled(store: HMSStore, trackID?: string): boolean;

@@ -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")),o=e(require("zustand/vanilla")),i=e(require("zustand/shallow")),s=require("@100mslive/hms-video"),a=e(require("events"));function c(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){c(i,n,o,s,a,"next",e)}function a(e){c(i,n,o,s,a,"throw",e)}s(void 0)}))}}function l(){return(l=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 f(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 d(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 f(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)?f(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 h,v,p=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new b(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=k(s,r);if(a){if(a===l)continue;return a}}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,i),o}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 f(){}function d(){}function h(){}var v={};v[o]=function(){return this};var p=Object.getPrototypeOf,E=p&&p(p(x([])));E&&E!==t&&r.call(E,o)&&(v=E);var S=h.prototype=f.prototype=Object.create(v);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(f).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function k(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,k(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 o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function T(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 y(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function x(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:D}}function D(){return{value:void 0,done:!0}}return d.prototype=S.constructor=h,h.constructor=d,d.displayName=a(h,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a(e,s,"GeneratorFunction")),e.prototype=Object.create(S),e},e.awrap=function(e){return{__await:e}},m(g.prototype),g.prototype[i]=function(){return this},e.AsyncIterator=g,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new g(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},m(S),a(S,s,"Generator"),S[o]=function(){return this},S.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,b.prototype={constructor:b,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(y),!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 s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},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),y(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 o=n.arg;y(r)}return o}}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)}}(v={exports:{}}),v.exports);(h=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",h.Preview="Preview",h.Connecting="Connecting",h.Connected="Connected",h.Reconnecting="Reconnecting",h.Failed="Failed";var E=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat";var S=function(){};S.INFO="info",S.ERROR="error",S.CRITICAL="critical";var m,g,k,T=function(){};T.PEER_JOINED="PEER_JOINED",T.PEER_LEFT="PEER_LEFT",T.NEW_MESSAGE="NEW_MESSAGE",T.ERROR="ERROR",T.RECONNECTING="RECONNECTING",T.RECONNECTED="RECONNECTED",T.TRACK_ADDED="TRACK_ADDED",T.TRACK_REMOVED="TRACK_REMOVED",T.TRACK_MUTED="TRACK_MUTED",T.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"}(m||(m={})),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"}(g||(g={})),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"}(k||(k={}));var y=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 b(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&x(e.tracks[t])}))}function x(e){return e&&"video"===e.type&&"screen"===e.source}function D(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var R=function(e){return e.room},I=function(e){return e.peers},w=function(e){return e.messages.byID},A=function(e){return e.messages.allIDs},P=function(e){return e.tracks},M=function(e){return e.settings},O=t.createSelector(M,(function(e){return e.maxTileCount})),_=function(e){return e.speakers},N=t.createSelector([R],(function(e){return e&&e.isConnected})),C=t.createSelector([R,I],(function(e,t){return e.peers.map((function(e){return t[e]}))})),L=t.createSelector(C,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),K=t.createSelector(L,(function(e){return null==e?void 0:e.id})),U=t.createSelector(L,(function(e){return null==e?void 0:e.audioTrack})),H=t.createSelector(L,(function(e){return null==e?void 0:e.videoTrack})),j=t.createSelector(C,(function(e){return e.filter((function(e){return!e.isLocal}))})),G=t.createSelector(I,_,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?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})),V=function(e){var t=L(e);return D(e,null==t?void 0:t.videoTrack)},F=function(e){var t=L(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 b(e,L(e))},W=t.createSelector(A,(function(e){return e.length})),B=t.createSelector(w,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),q=t.createSelector(A,w,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),Y=t.createSelector([R],(function(e){return e&&e.roomState})),z=t.createSelector([R],(function(e){return!!e&&e.roomState===exports.HMSRoomState.Preview}));function $(e){return function(t){return function(r){return e(r,t)}}}var Q=function(e,t){return t},X=t.createSelector([I,Q],(function(e,t){return t?e[t]:null})),Z=t.createSelector([P,Q],(function(e,t){return t?e[t]:null})),ee=$(X),te=$(t.createSelector(X,(function(e){return null==e?void 0:e.name}))),re=$(Z),ne=$(t.createSelector((function(e,t){return t?e.speakers[t]:null}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),oe=$((function(e,t){var r=X(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}})),ie=$((function(e,t){var r=X(e,t);if(r&&b(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return x(e.tracks[t])}));return n?e.tracks[n]:void 0}})),se=$((function(e,t){var r=X(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),ae=$((function(e,t){var r=X(e,t);return D(e,null==r?void 0:r.audioTrack)})),ce=$((function(e,t){var r=X(e,t);return D(e,null==r?void 0:r.videoTrack)})),ue=t.createSelector([I,P],(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)}}))})),le="HMS-Store:",fe=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,[le].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,[le].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,[le].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,[le].concat(r))},e}(),de=function(e,t){return e&&t},he=function(e,t){return e&&!t},ve=function(e,t){return!e&&t},pe=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},Ee=function(e,t){for(var r,n=new Set,o=d(e);!(r=o()).done;)n.add(r.value);for(var i,s=d(t);!(i=s()).done;)n.add(i.value);return Array.from(n)};function Se(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 me,ge,ke=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.preview=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("attempting to call preview after join was called");else try{this.sdkPreviewWithListeners(e),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}))}catch(e){throw fe.e("Cannot show preview. Failed to connect to room - ",e),e}},t.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0,this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}))}catch(e){throw this.isRoomJoinCalled=!1,fe.e("Failed to connect to room - ",e),e}},t.leave=function(){var e=u(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(N)){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(),fe.i("left room")})).catch((function(e){fe.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=u(p.mark((function e(t){return p.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=u(p.mark((function e(t,r){return p.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=u(p.mark((function e(t){return p.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=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(U))){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=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(H))){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=u(p.mark((function e(t,r){var n,o=this;return p.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:o.logPossibleInconsistency("track id not found for setEnabled")})),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncPeers(),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.store.setState((function(e){e.tracks[t].displayEnabled=!r})),e.t0;case 15:this.hmsNotifications.sendTrackUpdate(r?k.TRACK_UNMUTED:k.TRACK_MUTED,t);case 17:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),t.setAudioSettings=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(U))){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=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(H))){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=y.convertMessage(t);r.read=!0,r.senderName="You",this.onHMSMessage(r)}else fe.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=u(p.mark((function e(t,r){var n=this;return p.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 o=n.store.subscribe(function(){var i=u(p.mark((function i(s){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}(),V)})));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=u(p.mark((function e(t,r){var n;return p.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,E())})),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.sdkPreviewWithListeners=function(e){this.sdk.preview(e,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this)})},t.startScreenShare=function(){var e=u(p.mark((function e(){return p.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=u(p.mark((function e(){return p.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=u(p.mark((function e(t,r){var n,o,i;return p.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!==(o=r.srcObject)&&o instanceof MediaStream)){e.next=7;break}if((null==(i=o.getVideoTracks()[0])?void 0:i.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=[],o={},i={},s={},a=d(this.sdk.getPeers());!(e=a()).done;){var c=e.value,u=y.convertPeer(c);r[u.id]=u,n.push(u.id);for(var l,f=d([c.audioTrack,c.videoTrack].concat(c.auxiliaryTracks));!(l=f()).done;){var h=l.value;if(h){var v=y.convertTrack(h);this.enrichHMSTrack(v,h),o[v.id]=v,i[h.trackId]=h}}u.isLocal&&Object.assign(s,this.getMediaSettings(c))}this.store.setState((function(e){e.room.peers=n;var a=e.tracks;!function(e,t,r,n){for(var o,i=d(Ee(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];de(a,c)?(pe(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),Se(a,c,r,n),Object.assign(a,c)):he(a,c)?delete e[s]:ve(a,c)&&(e[s]=c)}}(e.peers,r,o,i),function(e,t){for(var r,n=d(Ee(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];de(i,s)?Object.assign(i,s):he(i,s)?delete e[o]:ve(i,s)&&(e[o]=s)}}(a,o),Object.assign(e.settings,s),t.hmsSDKTracks=i}))},t.onPreview=function(e){this.store.setState((function(t){Object.assign(t.room,y.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview})),this.syncPeers()},t.onJoin=function(e){this.store.setState((function(t){Object.assign(t.room,y.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected})),this.syncPeers()},t.onRoomUpdate=function(){this.syncPeers()},t.onPeerUpdate=function(e,t){if(e!==m.BECAME_DOMINANT_SPEAKER&&e!==m.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(ee(t.peerId));this.syncPeers(),r||(r=this.store.getState(ee(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},t.onTrackUpdate=function(e,t,r){e===k.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 o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,o.audioTrack))delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,o.videoTrack))delete o.videoTrack;else{var s=o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,o.auxiliaryTracks[s])&&o.auxiliaryTracks.splice(s,1)}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}))},t.onMessageReceived=function(e){var t=y.convertMessage(e);t.read=!1,t.senderName=this.store.getState(te(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(W)+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,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}))},t.onReconnected=function(){this.syncPeers(),this.hmsNotifications.sendReconnected(),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}))},t.onReconnecting=function(e){fe.e("Reconnection: received error from sdk",e),this.hmsNotifications.sendReconnecting(e),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting}))},t.onError=function(e){e.isTerminal&&(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed}))),this.hmsNotifications.sendError(e),fe.e("received error from sdk",e)},t.setEnabledSDKTrack=function(){var e=u(p.mark((function e(t,r){var n;return p.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=u(p.mark((function e(t,r){var n;return p.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=u(p.mark((function e(t,r){var n;return p.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,o;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId}},t.localAndVideoUnmuting=function(e){if(this.store.getState(L).videoTrack!==e)return!1;var t=this.store.getState(F),r=this.store.getState(V);return t&&!r},t.logPossibleInconsistency=function(e){fe.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}(),Te=((me={})[m.PEER_JOINED]=T.PEER_JOINED,me[m.PEER_LEFT]=T.PEER_LEFT,me[m.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",me[m.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",me),ye=((ge={})[k.TRACK_ADDED]=T.TRACK_ADDED,ge[k.TRACK_REMOVED]=T.TRACK_REMOVED,ge[k.TRACK_MUTED]=T.TRACK_MUTED,ge[k.TRACK_UNMUTED]=T.TRACK_UNMUTED,ge),be=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new a}var t=e.prototype;return t.sendPeerUpdate=function(e,t){var r=this.store.getState(ee(null==t?void 0:t.id))||t,n=Te[e];if(n){var o=this.createNotification(n,r,S.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(re(t)),n=ye[e];if(n){var o=this.createNotification(n,r,S.INFO);this.emitEvent(o)}},t.sendMessageReceived=function(e){var t=this.createNotification(T.NEW_MESSAGE,e,S.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(T.ERROR,e,S.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(T.RECONNECTING,e,S.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(T.RECONNECTED,null,S.INFO);this.emitEvent(e)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},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}(),xe=function(){function e(t,r,n){this.store=t||e.createNewHMSStore(),this.notifications=n||new be(this.store),this.actions=r||new ke(this.store,new s.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var t=e.prototype;return t.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(fe.d("turning on trigger on subscribe"),e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},t.getStore=function(){return l({},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=o(r.devtools(e.immerMiddleware((function(){return E()})),"HMSStore")),s=t.setState;t.setState=function(e){return s(n(e))};var a=t.getState;t.getState=function(e){return e?e(a()):a()};var c=t.subscribe;return t.subscribe=function(e,t,r){return t||(t=function(e){return e}),c(e,t,r=r||i)},t},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.immerMiddleware=function(e){return function(t,r,o){return e((function(e){return t(n(e))}),r,o)}},e}();exports.HMSNoticiationSeverity=S,exports.HMSNotificationTypes=T,exports.HMSReactiveStore=xe,exports.HMSSDKActions=ke,exports.createDefaultStoreState=E,exports.selectAuxiliaryAudioByPeerID=oe,exports.selectCameraStreamByPeerID=se,exports.selectDominantSpeaker=G,exports.selectHMSMessages=q,exports.selectHMSMessagesCount=W,exports.selectIsConnectedToRoom=N,exports.selectIsInPreview=z,exports.selectIsLocalAudioEnabled=function(e){var t=L(e);return D(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=J,exports.selectIsLocalVideoDisplayEnabled=F,exports.selectIsLocalVideoEnabled=V,exports.selectIsPeerAudioEnabled=ae,exports.selectIsPeerVideoEnabled=ce,exports.selectIsSomeoneScreenSharing=function(e){return C(e).some((function(t){return b(e,t)}))},exports.selectLocalAudioTrackID=U,exports.selectLocalMediaSettings=M,exports.selectLocalPeer=L,exports.selectLocalPeerID=K,exports.selectLocalVideoTrackID=H,exports.selectMaxTilesCount=O,exports.selectMessageIDsInOrder=A,exports.selectMessagesMap=w,exports.selectPeerAudioByID=ne,exports.selectPeerByID=ee,exports.selectPeerNameByID=te,exports.selectPeerScreenSharing=function(e){return C(e).find((function(t){return b(e,t)}))},exports.selectPeers=C,exports.selectPeersMap=I,exports.selectPeersScreenSharing=function(e){return C(e).filter((function(t){return b(e,t)}))},exports.selectPeersWithAudioStatus=ue,exports.selectRemotePeers=j,exports.selectRoom=R,exports.selectRoomState=Y,exports.selectScreenShareByPeerID=ie,exports.selectSpeakers=_,exports.selectTrackByID=re,exports.selectTracksMap=P,exports.selectUnreadHMSMessagesCount=B;
"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("@100mslive/hms-video"),r=require("reselect"),n=require("zustand/middleware"),o=e(require("immer")),i=e(require("zustand/vanilla")),s=e(require("zustand/shallow")),a=e(require("events"));function c(e,t,r,n,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,o)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){c(i,n,o,s,a,"next",e)}function a(e){c(i,n,o,s,a,"throw",e)}s(void 0)}))}}function l(){return(l=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 d(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 f(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 d(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)?d(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 h,v,p=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new b(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=g(s,r);if(a){if(a===l)continue;return a}}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,i),o}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[o]=function(){return this};var p=Object.getPrototypeOf,S=p&&p(p(x([])));S&&S!==t&&r.call(S,o)&&(v=S);var E=h.prototype=d.prototype=Object.create(v);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){var n;this._invoke=function(o,i){function s(){return new t((function(n,s){!function n(o,i,s,a){var c=u(e[o],e,i);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,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function g(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,g(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 o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function x(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=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 i.next=i}}return{next:D}}function D(){return{value:void 0,done:!0}}return f.prototype=E.constructor=h,h.constructor=f,f.displayName=a(h,s,"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,a(e,s,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},m(k.prototype),k.prototype[i]=function(){return this},e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new k(c(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},m(E),a(E,s,"Generator"),E[o]=function(){return this},E.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,b.prototype={constructor:b,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(T),!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 s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},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),T(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 o=n.arg;T(r)}return o}}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)}}(v={exports:{}}),v.exports);(h=exports.HMSRoomState||(exports.HMSRoomState={})).Disconnected="Disconnected",h.Preview="Preview",h.Connecting="Connecting",h.Connected="Connected",h.Reconnecting="Reconnecting",h.Failed="Failed";var S=function(){return{room:{id:"",isConnected:!1,name:"",peers:[],shareableLink:"",hasWaitingRoom:!1,roomState:exports.HMSRoomState.Disconnected},peers:{},tracks:{},messages:{byID:{},allIDs:[]},speakers:{},settings:{audioInputDeviceId:"",audioOutputDeviceId:"",videoInputDeviceId:"",maxTileCount:9}}};(exports.HMSMessageType||(exports.HMSMessageType={})).CHAT="chat";var E=function(){};E.INFO="info",E.ERROR="error",E.CRITICAL="critical";var m,k,g,y=function(){};y.PEER_JOINED="PEER_JOINED",y.PEER_LEFT="PEER_LEFT",y.NEW_MESSAGE="NEW_MESSAGE",y.ERROR="ERROR",y.RECONNECTING="RECONNECTING",y.RECONNECTED="RECONNECTED",y.TRACK_ADDED="TRACK_ADDED",y.TRACK_REMOVED="TRACK_REMOVED",y.TRACK_MUTED="TRACK_MUTED",y.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"}(m||(m={})),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"}(k||(k={})),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"}(g||(g={}));var T=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){var r={id:e.trackId,source:e.source,type:e.type,enabled:e.enabled,displayEnabled:e.enabled};if(e instanceof t.HMSRemoteAudioTrack){var n=e.getVolume();r.volume=n}return r},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 b(e,t){return t&&t.auxiliaryTracks.some((function(t){return!(!t||!e.tracks[t])&&D(e.tracks[t])}))}function x(e){return e&&"audio"===e.type}function D(e){return e&&"screen"===e.source}function R(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].enabled}var I=function(e){return e.room},w=function(e){return e.peers},A=function(e){return e.messages.byID},P=function(e){return e.messages.allIDs},M=function(e){return e.tracks},O=function(e){return e.settings},_=r.createSelector(O,(function(e){return e.maxTileCount})),N=function(e){return e.speakers},L=r.createSelector([I],(function(e){return e&&e.isConnected})),C=r.createSelector([I,w],(function(e,t){return e.peers.map((function(e){return t[e]}))})),K=r.createSelector(C,(function(e){return e.filter((function(e){return e.isLocal}))[0]})),U=r.createSelector(K,(function(e){return null==e?void 0:e.id})),H=r.createSelector(K,(function(e){return null==e?void 0:e.audioTrack})),j=r.createSelector(K,(function(e){return null==e?void 0:e.videoTrack})),G=r.createSelector(C,(function(e){return e.filter((function(e){return!e.isLocal}))})),V=r.createSelector(w,N,(function(e,t){var r=Object.entries(t).sort((function(e,t){var r,n,o=(null==(r=e[1])?void 0:r.audioLevel)||0;return((null==(n=t[1])?void 0:n.audioLevel)||0)>o?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})),F=function(e){var t=K(e);return R(e,null==t?void 0:t.videoTrack)},J=function(e){var t=K(e);return function(e,t){return!(!t||!e.tracks[t])&&e.tracks[t].displayEnabled}(e,null==t?void 0:t.videoTrack)},B=function(e){return b(e,K(e))},W=r.createSelector(P,(function(e){return e.length})),q=r.createSelector(A,(function(e){return Object.values(e).filter((function(e){return!e.read})).length})),Y=r.createSelector(P,A,(function(e,t){var r=[];return e.forEach((function(e){r.push(t[e])})),r})),z=r.createSelector([I],(function(e){return e&&e.roomState})),$=r.createSelector([I],(function(e){return!!e&&e.roomState===exports.HMSRoomState.Preview})),Q="HMS-Store:",X=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,[Q].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,[Q].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,[Q].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,[Q].concat(r))},e}();function Z(e){return function(t){return function(r){return e(r,t)}}}var ee=function(e,t){return t},te=r.createSelector([w,ee],(function(e,t){return t?e[t]:null})),re=r.createSelector([M,ee],(function(e,t){return t?e[t]:null})),ne=Z(te),oe=Z(r.createSelector(te,(function(e){return null==e?void 0:e.name}))),ie=Z(re),se=Z(r.createSelector((function(e,t){return t?e.speakers[t]:null}),(function(e){return(null==e?void 0:e.audioLevel)||0}))),ae=Z((function(e,t){var r=te(e,t);if(r){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){return x(e.tracks[t])}));return n?e.tracks[n]:void 0}})),ce=Z((function(e,t){var r=te(e,t);if(r&&b(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return function(e){return e&&"video"===e.type}(r)&&D(r)}));return n?e.tracks[n]:void 0}})),ue=Z((function(e,t){var r=te(e,t);if(r&&b(e,r)){var n=null==r?void 0:r.auxiliaryTracks.find((function(t){var r=e.tracks[t];return x(r)&&D(r)}));return n?e.tracks[n]:void 0}})),le=Z((function(e,t){var r=te(e,t);if(r&&r.videoTrack&&""!==r.videoTrack)return e.tracks[r.videoTrack]})),de=Z((function(e,t){var r=te(e,t);return R(e,null==r?void 0:r.audioTrack)})),fe=Z((function(e,t){var r=te(e,t);return R(e,null==r?void 0:r.videoTrack)})),he=Z((function(e,t){if(t&&e.tracks[t])return 0===e.tracks[t].volume;X.w("Track not found",t)})),ve=Z((function(e,t){var r=te(e,t);return he(null==r?void 0:r.audioTrack)(e)})),pe=Z((function(e,t){var r=ue(t)(e);return he(null==r?void 0:r.id)(e)})),Se=Z((function(e,t){var r=re(e,t);if(r)return"audio"!==r.type?void X.w("Please pass audio track here"):r.volume})),Ee=Z((function(e,t){var r=te(e,t);return Se(null==r?void 0:r.audioTrack)(e)})),me=Z((function(e,t){var r=ue(t)(e);return Se(null==r?void 0:r.id)(e)})),ke=r.createSelector([w,M],(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)}}))})),ge=function(e,t){return e&&t},ye=function(e,t){return e&&!t},Te=function(e,t){return!e&&t},be=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},xe=function(e,t){for(var r,n=new Set,o=f(e);!(r=o()).done;)n.add(r.value);for(var i,s=f(t);!(i=s()).done;)n.add(i.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 Re,Ie,we=function(){function e(e,t,r){this.hmsSDKTracks={},this.isRoomJoinCalled=!1,this.store=e,this.sdk=t,this.hmsNotifications=r}var r=e.prototype;return r.setVolume=function(e,r){var n=this.hmsSDKTracks[e];n?n instanceof t.HMSAudioTrack?(n.setVolume(r),this.syncPeers()):X.w("track "+e+" is not an audio track"):this.logPossibleInconsistency("track "+e+" not present, unable to set volume")},r.preview=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("attempting to call preview after join was called");else try{this.sdkPreviewWithListeners(e),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}))}catch(e){throw X.e("Cannot show preview. Failed to connect to room - ",e),e}},r.join=function(e){if(this.isRoomJoinCalled)this.logPossibleInconsistency("room join is called again");else try{this.sdkJoinWithListeners(e),this.isRoomJoinCalled=!0,this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connecting}))}catch(e){throw this.isRoomJoinCalled=!1,X.e("Failed to connect to room - ",e),e}},r.leave=function(){var e=u(p.mark((function e(){var t=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(L)){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(),X.i("left room")})).catch((function(e){X.e("error in leaving room - ",e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.setScreenShareEnabled=function(){var e=u(p.mark((function e(t){return p.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)}}(),r.addTrack=function(){var e=u(p.mark((function e(t,r){return p.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)}}(),r.removeTrack=function(){var e=u(p.mark((function e(t){return p.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)}}(),r.setLocalAudioEnabled=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(H))){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)}}(),r.setLocalVideoEnabled=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(j))){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)}}(),r.setEnabledTrack=function(){var e=u(p.mark((function e(t,r){var n,o=this;return p.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:o.logPossibleInconsistency("track id not found for setEnabled")})),e.prev=5,e.next=8,this.setEnabledSDKTrack(t,r);case 8:this.syncPeers(),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(5),this.store.setState((function(e){e.tracks[t].displayEnabled=!r})),e.t0;case 15:this.hmsNotifications.sendTrackUpdate(r?g.TRACK_UNMUTED:g.TRACK_MUTED,t);case 17:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(t,r){return e.apply(this,arguments)}}(),r.setAudioSettings=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(H))){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)}}(),r.setVideoSettings=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.store.getState(j))){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)}}(),r.sendMessage=function(e){if(""!==e.trim()){var t=this.sdk.sendMessage(exports.HMSMessageType.CHAT,e),r=T.convertMessage(t);r.read=!0,r.senderName="You",this.onHMSMessage(r)}else X.d("Ignoring empty message send")},r.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}))}))},r.attachVideo=function(){var e=u(p.mark((function e(t,r){var n=this;return p.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 o=n.store.subscribe(function(){var i=u(p.mark((function i(s){return p.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!s){i.next=5;break}return i.next=3,n.attachVideoInternal(t,r);case 3:o(),e();case 5:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}(),F)})));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)}}(),r.detachVideo=function(){var e=u(p.mark((function e(t,r){var n;return p.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)}}(),r.resetState=function(){this.store.setState((function(e){Object.assign(e,S())})),this.isRoomJoinCalled=!1,this.hmsSDKTracks={}},r.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)})},r.sdkPreviewWithListeners=function(e){this.sdk.preview(e,{onPreview:this.onPreview.bind(this),onError:this.onError.bind(this)})},r.startScreenShare=function(){var e=u(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.store.getState(B)){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)}}(),r.stopScreenShare=function(){var e=u(p.mark((function e(){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.store.getState(B)){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)}}(),r.attachVideoInternal=function(){var e=u(p.mark((function e(t,r){var n,o,i;return p.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!==(o=r.srcObject)&&o instanceof MediaStream)){e.next=7;break}if((null==(i=o.getVideoTracks()[0])?void 0:i.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)}}(),r.syncPeers=function(){for(var e,t=this,r={},n=[],o={},i={},s={},a=f(this.sdk.getPeers());!(e=a()).done;){var c=e.value,u=T.convertPeer(c);r[u.id]=u,n.push(u.id);for(var l,d=f([c.audioTrack,c.videoTrack].concat(c.auxiliaryTracks));!(l=d()).done;){var h=l.value;if(h){var v=T.convertTrack(h);this.enrichHMSTrack(v,h),o[v.id]=v,i[h.trackId]=h}}u.isLocal&&Object.assign(s,this.getMediaSettings(c))}this.store.setState((function(e){e.room.peers=n;var a=e.tracks;!function(e,t,r,n){for(var o,i=f(xe(Object.keys(e),Object.keys(t)));!(o=i()).done;){var s=o.value,a=e[s],c=t[s];ge(a,c)?(be(a.auxiliaryTracks,c.auxiliaryTracks)&&(c.auxiliaryTracks=a.auxiliaryTracks),De(a,c,r,n),Object.assign(a,c)):ye(a,c)?delete e[s]:Te(a,c)&&(e[s]=c)}}(e.peers,r,o,i),function(e,t){for(var r,n=f(xe(Object.keys(e),Object.keys(t)));!(r=n()).done;){var o=r.value,i=e[o],s=t[o];ge(i,s)?Object.assign(i,s):ye(i,s)?delete e[o]:Te(i,s)&&(e[o]=s)}}(a,o),Object.assign(e.settings,s),t.hmsSDKTracks=i}))},r.onPreview=function(e){this.store.setState((function(t){Object.assign(t.room,T.convertRoom(e)),t.room.roomState=exports.HMSRoomState.Preview})),this.syncPeers()},r.onJoin=function(e){this.store.setState((function(t){Object.assign(t.room,T.convertRoom(e)),t.room.isConnected=!0,t.room.roomState=exports.HMSRoomState.Connected})),this.syncPeers()},r.onRoomUpdate=function(){this.syncPeers()},r.onPeerUpdate=function(e,t){if(e!==m.BECAME_DOMINANT_SPEAKER&&e!==m.RESIGNED_DOMINANT_SPEAKER){var r=this.store.getState(ne(t.peerId));this.syncPeers(),r||(r=this.store.getState(ne(t.peerId))),this.hmsNotifications.sendPeerUpdate(e,r)}},r.onTrackUpdate=function(e,t,r){e===g.TRACK_REMOVED?(this.hmsNotifications.sendTrackUpdate(e,t.trackId),this.handleTrackRemove(t,r)):(this.syncPeers(),this.hmsNotifications.sendTrackUpdate(e,t.trackId))},r.handleTrackRemove=function(e,t){var r=this;this.store.setState((function(n){var o=n.peers[t.peerId],i=n.tracks;if(r.isSameStoreSDKTrack(e.trackId,o.audioTrack))delete o.audioTrack;else if(r.isSameStoreSDKTrack(e.trackId,o.videoTrack))delete o.videoTrack;else{var s=o.auxiliaryTracks.indexOf(e.trackId);s>-1&&r.isSameStoreSDKTrack(e.trackId,o.auxiliaryTracks[s])&&o.auxiliaryTracks.splice(s,1)}delete i[e.trackId],delete r.hmsSDKTracks[e.trackId]}))},r.onMessageReceived=function(e){var t=T.convertMessage(e);t.read=!1,t.senderName=this.store.getState(oe(t.sender)),this.onHMSMessage(t),this.hmsNotifications.sendMessageReceived(t)},r.onHMSMessage=function(e){var t=this;this.store.setState((function(r){e.id=String(t.store.getState(W)+1),r.messages.byID[e.id]=e,r.messages.allIDs.push(e.id)}))},r.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,o=Object.entries(t.speakers);n<o.length;n++){var i=o[n],s=i[0],a=i[1];a.audioLevel=r[s]||0,0===a.audioLevel&&delete t.speakers[s]}}))},r.onReconnected=function(){this.syncPeers(),this.hmsNotifications.sendReconnected(),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Connected}))},r.onReconnecting=function(e){X.e("Reconnection: received error from sdk",e),this.hmsNotifications.sendReconnecting(e),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Reconnecting}))},r.onError=function(e){e.isTerminal&&(this.leave().then((function(){return console.log("error from SDK, left room.")})),this.store.setState((function(e){e.room.roomState=exports.HMSRoomState.Failed}))),this.hmsNotifications.sendError(e),X.e("received error from sdk",e)},r.setEnabledSDKTrack=function(){var e=u(p.mark((function e(t,r){var n;return p.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)}}(),r.setSDKLocalVideoTrackSettings=function(){var e=u(p.mark((function e(t,r){var n;return p.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)}}(),r.setSDKLocalAudioTrackSettings=function(){var e=u(p.mark((function e(t,r){var n;return p.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)}}(),r.enrichHMSTrack=function(e,t){var r=t.getMediaTrackSettings();e.height=r.height,e.width=r.width,e.deviceID=r.deviceId},r.getMediaSettings=function(e){var t,r,n,o;return{audioInputDeviceId:null==(t=e.audioTrack)||null==(r=t.getMediaTrackSettings())?void 0:r.deviceId,videoInputDeviceId:null==(n=e.videoTrack)||null==(o=n.getMediaTrackSettings())?void 0:o.deviceId}},r.localAndVideoUnmuting=function(e){if(this.store.getState(K).videoTrack!==e)return!1;var t=this.store.getState(J),r=this.store.getState(F);return t&&!r},r.logPossibleInconsistency=function(e){X.w("possible inconsistency detected - ",e)},r.isSameStoreSDKTrack=function(e,t){var r;return!!t&&(null==(r=this.hmsSDKTracks[t])?void 0:r.trackId)===e},e}(),Ae=((Re={})[m.PEER_JOINED]=y.PEER_JOINED,Re[m.PEER_LEFT]=y.PEER_LEFT,Re[m.AUDIO_TOGGLED]="PEER_AUDIO_UPDATED",Re[m.VIDEO_TOGGLED]="PEER_VIDEO_UPDATED",Re),Pe=((Ie={})[g.TRACK_ADDED]=y.TRACK_ADDED,Ie[g.TRACK_REMOVED]=y.TRACK_REMOVED,Ie[g.TRACK_MUTED]=y.TRACK_MUTED,Ie[g.TRACK_UNMUTED]=y.TRACK_UNMUTED,Ie),Me=function(){function e(e){var t=this;this.id=0,this.onNotification=function(e){return t.eventEmitter.addListener("hmsNotification",e),function(){t.eventEmitter.removeListener("hmsNotification",e)}},this.store=e,this.eventEmitter=new a}var t=e.prototype;return t.sendPeerUpdate=function(e,t){var r=this.store.getState(ne(null==t?void 0:t.id))||t,n=Ae[e];if(n){var o=this.createNotification(n,r,E.INFO);this.emitEvent(o)}},t.sendTrackUpdate=function(e,t){var r=this.store.getState(ie(t)),n=Pe[e];if(n){var o=this.createNotification(n,r,E.INFO);this.emitEvent(o)}},t.sendMessageReceived=function(e){var t=this.createNotification(y.NEW_MESSAGE,e,E.INFO);this.emitEvent(t)},t.sendError=function(e){var t=this.createNotification(y.ERROR,e,E.ERROR);this.emitEvent(t)},t.sendReconnecting=function(e){var t=this.createNotification(y.RECONNECTING,e,E.ERROR);this.emitEvent(t)},t.sendReconnected=function(){var e=this.createNotification(y.RECONNECTED,null,E.INFO);this.emitEvent(e)},t.emitEvent=function(e){this.eventEmitter.emit("hmsNotification",e)},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}(),Oe=function(){function e(r,n,o){this.store=r||e.createNewHMSStore(),this.notifications=o||new Me(this.store),this.actions=n||new we(this.store,new t.HMSSdk,this.notifications),this.initialTriggerOnSubscribe=!1}var r=e.prototype;return r.triggerOnSubscribe=function(){this.initialTriggerOnSubscribe||(X.d("turning on trigger on subscribe"),e.makeStoreTriggerOnSubscribe(this.store),this.initialTriggerOnSubscribe=!0)},r.getStore=function(){return l({},this.store,{setState:function(){throw new Error("Mutating store is not allowed")}})},r.getHMSActions=function(){return this.actions},r.getNotifications=function(){return{onNotification:this.notifications.onNotification}},e.createNewHMSStore=function(){var t=i(n.devtools(e.immerMiddleware((function(){return S()})),"HMSStore")),r=t.setState;t.setState=function(e){return r(o(e))};var a=t.getState;t.getState=function(e){return e?e(a()):a()};var c=t.subscribe;return t.subscribe=function(e,t,r){return t||(t=function(e){return e}),c(e,t,r=r||s)},t},e.makeStoreTriggerOnSubscribe=function(e){var t=e.subscribe;e.subscribe=function(r,n,o){return r(e.getState(n),void 0),t(r,n,o)}},e.immerMiddleware=function(e){return function(t,r,n){return e((function(e){return t(o(e))}),r,n)}},e}();exports.HMSNoticiationSeverity=E,exports.HMSNotificationTypes=y,exports.HMSReactiveStore=Oe,exports.HMSSDKActions=we,exports.createDefaultStoreState=S,exports.selectAudioTrackVolume=Se,exports.selectAudioVolumeByPeerID=Ee,exports.selectAuxiliaryAudioByPeerID=ae,exports.selectCameraStreamByPeerID=le,exports.selectDominantSpeaker=V,exports.selectHMSMessages=Y,exports.selectHMSMessagesCount=W,exports.selectIsAudioLocallyMuted=he,exports.selectIsConnectedToRoom=L,exports.selectIsInPreview=$,exports.selectIsLocalAudioEnabled=function(e){var t=K(e);return R(e,null==t?void 0:t.audioTrack)},exports.selectIsLocalScreenShared=B,exports.selectIsLocalVideoDisplayEnabled=J,exports.selectIsLocalVideoEnabled=F,exports.selectIsLocallyMutedByPeerID=ve,exports.selectIsPeerAudioEnabled=de,exports.selectIsPeerVideoEnabled=fe,exports.selectIsScreenShareLocallyMutedByPeerID=pe,exports.selectIsSomeoneScreenSharing=function(e){return C(e).some((function(t){return b(e,t)}))},exports.selectLocalAudioTrackID=H,exports.selectLocalMediaSettings=O,exports.selectLocalPeer=K,exports.selectLocalPeerID=U,exports.selectLocalVideoTrackID=j,exports.selectMaxTilesCount=_,exports.selectMessageIDsInOrder=P,exports.selectMessagesMap=A,exports.selectPeerAudioByID=se,exports.selectPeerByID=ne,exports.selectPeerNameByID=oe,exports.selectPeerScreenSharing=function(e){return C(e).find((function(t){return b(e,t)}))},exports.selectPeers=C,exports.selectPeersMap=w,exports.selectPeersScreenSharing=function(e){return C(e).filter((function(t){return b(e,t)}))},exports.selectPeersWithAudioStatus=ke,exports.selectRemotePeers=G,exports.selectRoom=I,exports.selectRoomState=z,exports.selectScreenShareAudioByPeerID=ue,exports.selectScreenShareByPeerID=ce,exports.selectScreenshareAudioVolumeByPeerID=me,exports.selectSpeakers=N,exports.selectTrackByID=ie,exports.selectTracksMap=M,exports.selectUnreadHMSMessagesCount=q;
//# sourceMappingURL=hms-video-store.cjs.production.min.js.map

@@ -9,2 +9,3 @@ import { HMSPeer, HMSSpeaker, HMSStore, HMSTrack } from '../core';

export declare let localSpeaker: HMSSpeaker;
export declare let screenshareAudio: HMSTrack;
export declare const makeFakeStore: () => HMSStore;
{
"version": "0.1.38",
"version": "0.1.39",
"license": "MIT",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

"reselect": "^4.0.0",
"zustand": "^3.5.1"
"zustand": "3.5.4"
},

@@ -61,3 +61,3 @@ "peerDependencies": {

"devDependencies": {
"@100mslive/hms-video": "^0.0.73",
"@100mslive/hms-video": "^0.0.75",
"events": "^3.3.0",

@@ -64,0 +64,0 @@ "@size-limit/preset-small-lib": "^4.11.0",

@@ -0,3 +1,7 @@

import {
HMSTrack as SDKHMSTrack,
HMSRemoteAudioTrack as SDKHMSRemoteAudioTrack,
HMSRemoteVideoTrack as SDKHMSRemoteVideoTrack,
} from '@100mslive/hms-video';
import { HMSPeer, HMSMessage, HMSTrack, HMSRoom } from '../schema';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';

@@ -21,4 +25,6 @@ import * as sdkTypes from './sdkTypes';

static convertTrack(sdkTrack: SDKHMSTrack): HMSTrack {
return {
static convertTrack(
sdkTrack: SDKHMSTrack | SDKHMSRemoteVideoTrack | SDKHMSRemoteAudioTrack,
): HMSTrack {
const track: HMSTrack = {
id: sdkTrack.trackId,

@@ -30,2 +36,7 @@ source: sdkTrack.source,

};
if (sdkTrack instanceof SDKHMSRemoteAudioTrack) {
const volume = sdkTrack.getVolume();
track.volume = volume;
}
return track;
}

@@ -32,0 +43,0 @@

@@ -29,9 +29,12 @@ import {

import { HMSLogger } from '../../common/ui-logger';
import { HMSSdk } from '@100mslive/hms-video';
import {
HMSSdk,
HMSTrack as SDKHMSTrack,
HMSLocalAudioTrack,
HMSLocalVideoTrack,
HMSAudioTrack as SDKHMSAudioTrack,
HMSVideoTrack as SDKHMSVideoTrack,
HMSException as SDKHMSException,
} from '@100mslive/hms-video';
import { IHMSStore } from '../IHMSStore';
import SDKHMSException from '@100mslive/hms-video/dist/error/HMSException';
import SDKHMSVideoTrack from '@100mslive/hms-video/dist/media/tracks/HMSVideoTrack';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';
import HMSLocalAudioTrack from '@100mslive/hms-video/dist/media/tracks/HMSLocalAudioTrack';
import HMSLocalVideoTrack from '@100mslive/hms-video/dist/media/tracks/HMSLocalVideoTrack';

@@ -75,2 +78,16 @@ import { mergeNewPeersInDraft, mergeNewTracksInDraft } from './sdkUtils/storeMergeUtils';

setVolume(trackId: string, value: number): void {
const track = this.hmsSDKTracks[trackId];
if (track) {
if (track instanceof SDKHMSAudioTrack) {
track.setVolume(value);
this.syncPeers();
} else {
HMSLogger.w(`track ${trackId} is not an audio track`);
}
} else {
this.logPossibleInconsistency(`track ${trackId} not present, unable to set volume`);
}
}
preview(config: sdkTypes.HMSConfig) {

@@ -77,0 +94,0 @@ if (this.isRoomJoinCalled) {

@@ -8,3 +8,3 @@ import HMSPeer from '@100mslive/hms-video/dist/interfaces/hms-peer';

import SDKHMSVideoTrackSettings from '@100mslive/hms-video/dist/media/settings/HMSVideoTrackSettings';
import SDKHMSException from '@100mslive/hms-video/dist/error/HMSException';
import { HMSException as SDKHMSException } from '@100mslive/hms-video';

@@ -11,0 +11,0 @@ type HMSAudioTrackSettings = SDKHMSAudioTrackSettings;

import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../schema';
import SDKHMSTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';
import { HMSTrack as SDKHMSTrack } from '@100mslive/hms-video';

@@ -4,0 +4,0 @@ /**

@@ -118,2 +118,8 @@ import { HMSAudioTrackSettings, HMSVideoTrackSettings } from './hmsSDKStore/sdkTypes';

detachVideo(trackID: string, videoElement: HTMLVideoElement): Promise<void>;
/**
* set the volume of selected audio track locally
* @param trackId trackId as stored in the store
* @param value number between 0-100
*/
setVolume(trackId: string, value: number): void;
}

@@ -120,0 +126,0 @@

@@ -39,2 +39,3 @@ export type HMSPeerID = string;

displayEnabled?: boolean;
volume?: number;
}

@@ -41,0 +42,0 @@

import { createSelector } from 'reselect';
import { selectPeersMap, selectTracksMap } from './selectors';
import { HMSPeerID, HMSStore, HMSTrack } from '../schema';
import { isAudio, isScreenShare, isScreenSharing, isTrackEnabled } from './selectorUtils';
import { isAudio, isScreenShare, isScreenSharing, isTrackEnabled, isVideo } from './selectorUtils';
import { HMSLogger } from '../../common/ui-logger';

@@ -60,3 +61,6 @@ type byIDSelector<T> = (store: HMSStore, id?: string) => T;

if (peer && isScreenSharing(store, peer)) {
const trackID = peer?.auxiliaryTracks.find(trackID => isScreenShare(store.tracks[trackID]));
const trackID = peer?.auxiliaryTracks.find(trackId => {
const track = store.tracks[trackId];
return isVideo(track) && isScreenShare(track);
});
return trackID ? store.tracks[trackID] : undefined;

@@ -67,2 +71,16 @@ }

export const selectScreenShareAudioByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID):
| HMSTrack
| undefined => {
const peer = selectPeerByIDBare(store, peerID);
if (peer && isScreenSharing(store, peer)) {
const trackID = peer?.auxiliaryTracks.find(trackId => {
const track = store.tracks[trackId];
return isAudio(track) && isScreenShare(track);
});
return trackID ? store.tracks[trackID] : undefined;
}
return undefined;
});
export const selectCameraStreamByPeerID = byIDCurry((store: HMSStore, peerID?: HMSPeerID):

@@ -87,1 +105,45 @@ | HMSTrack

});
export const selectIsAudioLocallyMuted = byIDCurry((store: HMSStore, trackID?: string) => {
if (trackID && store.tracks[trackID]) {
return store.tracks[trackID].volume === 0;
}
HMSLogger.w('Track not found', trackID);
return undefined;
});
export const selectIsLocallyMutedByPeerID = byIDCurry((store: HMSStore, peerID?: string) => {
const peer = selectPeerByIDBare(store, peerID);
return selectIsAudioLocallyMuted(peer?.audioTrack)(store);
});
export const selectIsScreenShareLocallyMutedByPeerID = byIDCurry(
(store: HMSStore, peerID?: string) => {
const track = selectScreenShareAudioByPeerID(peerID)(store);
return selectIsAudioLocallyMuted(track?.id)(store);
},
);
export const selectAudioTrackVolume = byIDCurry((store: HMSStore, trackID?: string) => {
const track = selectTrackByIDBare(store, trackID);
if (track) {
if (track.type !== 'audio') {
HMSLogger.w('Please pass audio track here');
return undefined;
}
return track.volume;
}
return undefined;
});
export const selectAudioVolumeByPeerID = byIDCurry((store: HMSStore, peerID?: string) => {
const peer = selectPeerByIDBare(store, peerID);
return selectAudioTrackVolume(peer?.audioTrack)(store);
});
export const selectScreenshareAudioVolumeByPeerID = byIDCurry(
(store: HMSStore, peerID?: string) => {
const track = selectScreenShareAudioByPeerID(peerID)(store);
return selectAudioTrackVolume(track?.id)(store);
},
);

@@ -20,4 +20,8 @@ import { HMSPeer, HMSStore, HMSTrack } from '../schema';

export function isVideo(track: HMSTrack | undefined) {
return track && track.type === 'video';
}
export function isScreenShare(track: HMSTrack | undefined) {
return track && track.type === 'video' && track.source === 'screen';
return track && track.source === 'screen';
}

@@ -24,0 +28,0 @@

@@ -25,2 +25,3 @@ import {

displayEnabled: true,
volume: type === 'audio' ? 10 : undefined,
};

@@ -36,2 +37,3 @@ }

export let localSpeaker: HMSSpeaker;
export let screenshareAudio: HMSTrack;

@@ -66,3 +68,3 @@ export const makeFakeStore = (): HMSStore => {

audioTrack: '104',
auxiliaryTracks: ['105', '106'],
auxiliaryTracks: ['105', '106', '107'],
},

@@ -77,2 +79,3 @@ },

'106': makeTrack('106', 'audio', 'regular'),
'107': makeTrack('107', 'audio', 'screen'),
},

@@ -118,4 +121,5 @@ messages: {

auxiliaryAudio = fakeStore.tracks['106'];
screenshareAudio = fakeStore.tracks['107'];
localSpeaker = fakeStore.speakers[localPeer.id];
return fakeStore;
};

@@ -10,2 +10,3 @@ import {

screenShare,
screenshareAudio,
} from '../fakeStore';

@@ -43,2 +44,7 @@ import {

selectUnreadHMSMessagesCount,
selectScreenShareAudioByPeerID,
selectAudioVolumeByPeerID,
selectAudioTrackVolume,
selectIsLocallyMutedByPeerID,
selectIsAudioLocallyMuted,
} from '../../core';

@@ -144,2 +150,20 @@

});
test('selectScreenshareAudio', () => {
expect(selectScreenShareAudioByPeerID(peerScreenSharing.id)(fakeStore)).toBe(screenshareAudio);
});
test('selectAudioVolumeByPeerID', () => {
expect(selectAudioVolumeByPeerID(localPeer.id)(fakeStore)).toBe(localAudio.volume);
});
test('selectAudioVolumeByTrackID', () => {
expect(selectAudioTrackVolume(localPeer.audioTrack)(fakeStore)).toBe(localAudio.volume);
});
test('selectLocallyMutedByPeerID', () => {
expect(selectIsLocallyMutedByPeerID(localPeer.id)(fakeStore)).toBe(false);
});
test('selectLocallyMutedByTrackID', () => {
expect(selectIsAudioLocallyMuted(localPeer.audioTrack)(fakeStore)).toBe(false);
});
});

@@ -146,0 +170,0 @@

@@ -0,1 +1,2 @@

import { HMSTrack as SDKTrack } from '@100mslive/hms-video';
import { HMSPeer, HMSPeerID, HMSTrack, HMSTrackID } from '../../core';

@@ -7,3 +8,2 @@ import {

import { makeFakePeer, makeFakeTrack } from '../fixtures';
import SDKTrack from '@100mslive/hms-video/dist/media/tracks/HMSTrack';

@@ -10,0 +10,0 @@ type trackMap = Record<HMSTrackID, HMSTrack>;

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc