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

@100mslive/100ms-web-sdk

Package Overview
Dependencies
Maintainers
8
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@100mslive/100ms-web-sdk - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

dist/media/tracks/index.d.ts

2

dist/100ms-web-sdk.cjs.production.min.js

@@ -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("uuid"),n=e(require("loglevel")),r=e(require("jsonwebtoken"));function i(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)}))}}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function l(e,t,n){return(l=f()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&h(i,n.prototype),i}).apply(null,arguments)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return l(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)})(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return v(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var E,k,b,g,y=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),o=new x(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=g(a,n);if(s){if(s===h)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),i}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function f(){}function l(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(T([])));m&&m!==t&&n.call(m,i)&&(p=m);var E=d.prototype=f.prototype=Object.create(p);function k(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var h=c.arg,f=h.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(f).then((function(e){h.value=e,a(h)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function g(e,t){var n=e.iterator[t.method];if(void 0===n){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 h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,h;var i=r.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,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}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 w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(y,this),this.reset(!0)}function T(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 r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return l.prototype=E.constructor=d,d.constructor=l,l.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},k(b.prototype),b.prototype[o]=function(){return this},e.AsyncIterator=b,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new b(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(E),s(E,a,"Generator"),E[i]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,x.prototype={constructor:x,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(w),!e)for(var t in this)"t"===t.charAt(0)&&n.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 r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(g={exports:{}}),g.exports);!function(e){e[e.OFF=0]="OFF",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.VERBOSE=4]="VERBOSE"}(E||(E={})),function(e){e[e.OFF=0]="OFF",e[e.ERROR=1]="ERROR",e[e.INFO=2]="INFO",e[e.VERBOSE=3]="VERBOSE"}(k||(k={})),function(e){e[e.VERBOSE=0]="VERBOSE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE"}(b||(b={}));var w=function(){function e(){}return e.v=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[b.VERBOSE,e].concat(n))},e.d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[b.DEBUG,e].concat(n))},e.i=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[b.INFO,e].concat(n))},e.w=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[b.WARN,e].concat(n))},e.e=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[b.ERROR,e].concat(n))},e.log=function(e,t){if(!(this.level.valueOf()>e.valueOf())){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];switch(e){case b.VERBOSE:var o;(o=console).log.apply(o,[t].concat(r));break;case b.DEBUG:var a;(a=console).debug.apply(a,[t].concat(r));break;case b.INFO:var s;(s=console).info.apply(s,[t].concat(r));break;case b.WARN:var c;(c=console).warn.apply(c,[t].concat(r));break;case b.ERROR:var u;(u=console).error.apply(u,[t].concat(r))}}},e}();w.level=b.VERBOSE;var x,T="HMSConnection",R=function(){function e(e,t){this.candidates=new Array,this.role=e,this.signal=t}var t=e.prototype;return t.addTransceiver=function(e,t){return this.nativeConnection.addTransceiver(e,t)},t.createOffer=function(){var e=o(y.mark((function e(t){var n;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=void 0),e.next=3,this.nativeConnection.createOffer(t);case 3:return n=e.sent,w.d(T,"[role="+this.role+"] createOffer offer="+JSON.stringify(n,null,1)),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.createAnswer=function(){var e=o(y.mark((function e(t){var n;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=void 0),e.next=3,this.nativeConnection.createAnswer(t);case 3:return n=e.sent,w.d(T,"[role="+this.role+"] createAnswer answer="+JSON.stringify(n,null,1)),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalDescription=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] setLocalDescription description="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.setLocalDescription(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setRemoteDescription=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] setRemoteDescription description="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.setRemoteDescription(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addIceCandidate=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] addIceCandidate candidate="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.addIceCandidate(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getSenders=function(){return this.nativeConnection.getSenders()},t.removeTrack=function(e){this.nativeConnection.removeTrack(e)},t.close=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.nativeConnection.close();case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),s(e,[{key:"remoteDescription",get:function(){return this.nativeConnection.remoteDescription}}]),e}();!function(e){e[e.PUBLISH=0]="PUBLISH",e[e.SUBSCRIBE=1]="SUBSCRIBE"}(x||(x={}));var C,I,A=function(e){function t(t,n,r){var i;return(i=e.call(this,x.PUBLISH,t)||this).observer=r,i.nativeConnection=new RTCPeerConnection(n),i.nativeConnection.createDataChannel("ion-sfu",{protocol:"SCTP"}),i.nativeConnection.onicecandidate=function(e){var n=e.candidate;n&&t.trickle({target:i.role,candidate:n})},i.nativeConnection.oniceconnectionstatechange=function(){i.observer.onIceConnectionChange(i.nativeConnection.iceConnectionState)},i}return c(t,e),t.prototype.initAfterJoin=function(){var e=this;this.nativeConnection.onnegotiationneeded=o(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return w.d("HMSPublishConnection","onnegotiationneeded"),t.next=3,e.observer.onRenegotiationNeeded();case 3:case"end":return t.stop()}}),t)})))},t}(R),O=function(e){this.tracks=new Array,this.nativeStream=e,this.id=e.id};!function(e){e.VP8="vp8",e.VP9="vp9",e.H264="h264"}(C||(C={})),function(e){e.OPUS="opus"}(I||(I={}));var _,S=function(){function e(){this._resolution=new N(320,180),this._codec=C.VP8,this._maxFrameRate=24,this._maxBitRate=15e4,this._deviceId="default",this._advanced=[]}var t=e.prototype;return t.resolution=function(e){return this._resolution=e,this},t.codec=function(e){return this._codec=e,this},t.maxFrameRate=function(e){if(e<=0)throw Error("maxFrameRate should be >= 1");return this._maxFrameRate=e,this},t.maxBitRate=function(e){if(e<=0)throw Error("maxBitRate should be >= 1");return this._maxBitRate=e,this},t.deviceId=function(e){return this._deviceId=e,this},t.advanced=function(e){return this._advanced=e,this},t.build=function(){return new D(this._resolution,this._codec,this._maxFrameRate,this._maxBitRate,this._deviceId,this._advanced)},e}(),D=function(){function e(e,t,n,r,i,o){this.resolution=e,this.codec=t,this.maxFrameRate=n,this.maxBitRate=r,this.deviceId=i,this.advanced=o}return e.prototype.toConstraints=function(){return{width:this.resolution.width,height:this.resolution.height,frameRate:this.maxFrameRate,deviceId:this.deviceId}},e}();!function(e){e.NONE="none",e.LOW="low",e.MEDIUM="medium",e.HIGH="high"}(_||(_={}));var P,N=function(e,t){if(e<=0)throw Error("Height should be >= 1");if(t<=0)throw Error("Height should be >= 1");this.width=e,this.height=t},L={QVGA:(new S).resolution(new N(320,180)).maxBitRate(15e4).build(),VGA:(new S).resolution(new N(640,360)).maxBitRate(5e5).build(),SHD:(new S).resolution(new N(960,540)).maxBitRate(12e5).build(),HD:(new S).resolution(new N(1280,720)).maxBitRate(25e5).build(),FHD:(new S).resolution(new N(1920,1080)).maxBitRate(4e6).build(),QHD:(new S).resolution(new N(2560,1440)).maxBitRate(8e6).build()},M=function(e){function t(t,n){var r;return(r=e.call(this,t)||this).audio=!0,r.video=_.HIGH,r.frameRate=_.HIGH,r.connection=n,r}c(t,e);var n=t.prototype;return n.setAudio=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.audio=t,e.next=3,this.syncWithApiChannel();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setVideo=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.video=t?_.HIGH:_.NONE,e.next=3,this.syncWithApiChannel();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.syncWithApiChannel=function(){var e=o(y.mark((function e(){var t;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={streamId:this.nativeStream.id,video:this.video,audio:this.audio,framerate:this.frameRate},e.next=3,this.connection.apiChannel.send(JSON.stringify(t));case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(O),U=function(){function e(e,t,n){var r=this;void 0===n&&(n=""),this.TAG="HMSDataChannel",this.nativeChannel=e,this.observer=t,this.metadata=n,e.onmessage=function(e){w.d(r.TAG,"["+r.metadata+"] onMessage: label="+r.label+", message="+e.data),r.observer.onMessage(e.data)}}var t=e.prototype;return t.send=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("open"===this.nativeChannel.readyState){e.next=2;break}throw Error("Channel "+this.label+" not yet ready");case 2:w.d(this.TAG,"["+this.metadata+"] Sending [size="+t.length+"] message="+t),this.nativeChannel.send(t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.close=function(){this.nativeChannel.close()},s(e,[{key:"id",get:function(){return this.nativeChannel.id}},{key:"label",get:function(){return this.nativeChannel.label}}]),e}(),B=function(){function e(e,t){this.stream=e,this.nativeTrack=t}return e.prototype.setEnabled=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.nativeTrack.enabled=t;case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),s(e,[{key:"enabled",get:function(){return this.nativeTrack.enabled}},{key:"trackId",get:function(){return this.nativeTrack.id}}]),e}();!function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO"}(P||(P={}));var G=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).type=P.AUDIO,"audio"!==n.kind)throw new Error("Expected 'track' kind = 'audio'");return r}return c(t,e),t}(B),V=function(e){function t(t,n){return e.call(this,t,n)||this}return c(t,e),t.prototype.setEnabled=function(){var t=o(y.mark((function t(n){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:return t.next=6,this.stream.setAudio(n);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(G),F=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).type=P.VIDEO,"video"!==n.kind)throw new Error("Expected 'track' kind = 'video'");return r}return c(t,e),t}(B),j=function(e){function t(t,n){return e.call(this,t,n)||this}return c(t,e),t.prototype.setEnabled=function(){var t=o(y.mark((function t(n){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:return t.next=6,this.stream.setVideo(n);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(F),H=function(e){function t(t,n,r){var i;return(i=e.call(this,x.SUBSCRIBE,t)||this).remoteStreams=new Map,i._apiChannel=null,i.observer=r,i.nativeConnection=new RTCPeerConnection(n),i.initNativeConnectionCallbacks(),i}c(t,e);var n=t.prototype;return n.initNativeConnectionCallbacks=function(){var e=this;this.nativeConnection.oniceconnectionstatechange=function(){e.observer.onIceConnectionChange(e.nativeConnection.iceConnectionState)},this.nativeConnection.ondatachannel=function(t){"ion-sfu"===t.channel.label&&(e._apiChannel=new U(t.channel,{onMessage:function(t){e.observer.onApiChannelMessage(t)}},"role="+e.role))},this.nativeConnection.onicecandidate=function(t){null!==t.candidate&&e.signal.trickle({candidate:t.candidate,target:e.role})},this.nativeConnection.ontrack=function(t){var n=t.streams[0];if(!e.remoteStreams.has(n.id)){var r=new M(n,e);e.remoteStreams.set(n.id,r),n.onremovetrack=function(t){var i=r.tracks.findIndex((function(e){return e.trackId===t.track.id}));i>=0&&(e.observer.onTrackRemove(r.tracks[i]),r.tracks.splice(i,1),0===r.tracks.length&&e.remoteStreams.delete(n.id))}}var i=e.remoteStreams.get(n.id),o=new("audio"===t.track.kind?V:j)(i,t.track);i.tracks.push(o),e.observer.onTrackAdd(o)}},n.close=function(){var t=o(y.mark((function t(){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.prototype.close.call(this);case 2:this.apiChannel.close();case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),s(t,[{key:"apiChannel",get:function(){return this._apiChannel}}]),t}(R),J=function(){function e(){}return e.fetchInitConfig=function(){var e=o(y.mark((function e(t,n){var r,i;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n=""),w.d("InitService","fetchInitConfig: token="+t+" region="+n),r="https://qa2-us.100ms.live/init?token="+t,n.length>0&&(r+="&region="+n),e.next=6,fetch(r);case 6:return i=e.sent,e.next=9,i.json();case 9:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),e}(),K=function(){function e(e,t){this.code=e,this.message=t}return e.prototype.build=function(){return new W(this.code,this.message)},e}(),W=function(e){function t(t,n){var r;return(r=e.call(this,n)||this).code=t,r}return c(t,e),t}(d(Error)),Y=function(){function e(e){this.TAG="JsonRpcSignal",this.isJoinCompleted=!1,this.pendingTrickle=[],this.socket=null,this.callbacks=new Map,this.observer=e}var n=e.prototype;return n.call=function(){var e=o(y.mark((function e(n,r){var i,o=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.v4(),this.socket.send(JSON.stringify({method:n,params:r,id:i})),e.next=5,new Promise((function(e,t){o.callbacks.set(i,{resolve:e,reject:t})}));case 5:return e.abrupt("return",JSON.parse(e.sent));case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.notify=function(e,t){this.socket.send(JSON.stringify({method:e,params:t}))},n.open=function(e){var t=this;return new Promise((function(n){t.socket=new WebSocket(e),t.socket.addEventListener("open",(function e(){n(),t.socket.removeEventListener("open",e)})),t.socket.addEventListener("message",(function(e){return t.onMessageHandler(e.data)}))}))},n.close=function(){var e=o(y.mark((function e(){var t,n=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Promise((function(e){n.socket.addEventListener("close",(function(){return e()}))})),this.socket.close(1e3,"Normal Close"),e.abrupt("return",t);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.join=function(){var e=o(y.mark((function e(t,n,r,i){var o,a,s=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={sid:t,uid:n,offer:r,info:i},e.next=3,this.call("join",o);case 3:return a=e.sent,this.isJoinCompleted=!0,this.pendingTrickle.forEach((function(e){return s.trickle(e)})),this.pendingTrickle.length=0,w.d(this.TAG,"join: response="+JSON.stringify(a,null,1)),e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),n.offer=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("offer",{desc:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.answer=function(e){this.notify("answer",{desc:e})},n.trickle=function(e){this.isJoinCompleted?this.notify("trickle",e):this.pendingTrickle.push(e)},n.onMessageHandler=function(e){var t=JSON.parse(e);if(t.hasOwnProperty("id")){var n=t.id;if(this.callbacks.has(n)){var r=this.callbacks.get(n);if(this.callbacks.delete(n),t.result)r.resolve(JSON.stringify(t.result));else{var i=t.error,o=new K(i.code,i.message).build();r.reject(o)}}else this.observer.onNotification(t)}else{if(!t.hasOwnProperty("method"))throw Error("WebSocket message has no 'method' or 'id' field, message="+t);"offer"===t.method?this.observer.onOffer(t.params):"trickle"===t.method?this.observer.onTrickle(t.params):this.observer.onNotification(t)}},e}();function q(e){return Q.apply(this,arguments)}function Q(){return(Q=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({audio:t.toConstraints()});case 2:return e.abrupt("return",e.sent.getAudioTracks()[0]);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function z(e){return $.apply(this,arguments)}function $(){return($=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({video:t.toConstraints()});case 2:return e.abrupt("return",e.sent.getVideoTracks()[0]);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var X=function(e){function t(t,n,r){var i;return i=e.call(this,t,n)||this,t.tracks.push(p(i)),i.settings=r,i}c(t,e);var n=t.prototype;return n.replaceTrackWith=function(){var e=o(y.mark((function e(t){var n;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(t);case 2:return n=e.sent,e.next=5,this.stream.replaceTrack(this,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setEnabled=function(){var t=o(y.mark((function t(n){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:if(!n){t.next=9;break}return t.next=7,this.replaceTrackWith(this.settings);case 7:t.next=10;break;case 9:this.nativeTrack.stop();case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.setSettings=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.settings.codec===t.codec){e.next=2;break}throw Error("Audio Codec can't be changed mid call.");case 2:if(this.settings.deviceId===t.deviceId){e.next=5;break}return e.next=5,this.replaceTrackWith(t);case 5:return e.next=7,this.nativeTrack.applyConstraints(t.toConstraints());case 7:this.settings=t;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(G);function Z(e){if(e<=0)throw Error("`ms` should be a positive integer");return new Promise((function(t){return setTimeout(t,e)}))}var ee,te,ne,re,ie=function(e){function t(t,n,r){var i;return i=e.call(this,t,n)||this,t.tracks.push(p(i)),i.settings=r,i}c(t,e);var n=t.prototype;return n.replaceTrackWith=function(){var e=o(y.mark((function e(t){var n;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z(t);case 2:return n=e.sent,e.next=5,this.stream.replaceTrack(this,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setEnabled=function(){var t=o(y.mark((function t(n){return y.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:if(!n){t.next=9;break}return t.next=7,this.replaceTrackWith(this.settings);case 7:t.next=12;break;case 9:return t.next=11,Z(100);case 11:this.nativeTrack.stop();case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.setSettings=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.settings.codec===t.codec){e.next=2;break}throw Error("Video Codec can't be changed mid call.");case 2:if(this.settings.deviceId===t.deviceId){e.next=5;break}return e.next=5,this.replaceTrackWith(t);case 5:return e.next=7,this.nativeTrack.applyConstraints(t.toConstraints());case 7:this.settings=t;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(F),oe=function(e){function t(t){var n;return(n=e.call(this,t)||this).connection=null,n}c(t,e);var n=t.prototype;return n.setConnection=function(e){this.connection=e},t.getLocalScreen=function(){var e=o(y.mark((function e(n){var r,i,o,a,s;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={video:n.toConstraints(),audio:!1},e.next=3,navigator.mediaDevices.getDisplayMedia(r);case 3:return o=new t(i=e.sent),a=i.getVideoTracks()[0],s=new ie(o,a,n),w.v("HMSLocalStream","getLocalScreen",s),e.abrupt("return",s);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.getLocalTracks=function(){var e=o(y.mark((function e(n){var r,i,o,a,s,c,u;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({audio:null!=n.audio&&n.audio.toConstraints(),video:null!=n.video&&n.video.toConstraints()});case 2:return i=new t(r=e.sent),o=[],null!=n.audio&&(a=r.getAudioTracks()[0],s=new X(i,a,n.audio),o.push(s)),null!=n.video&&(c=r.getVideoTracks()[0],u=new ie(i,c,n.video),o.push(u)),w.v("HMSLocalStream","getLocalTracks",o),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.addTransceiver=function(e){var t=this.connection.addTransceiver(e.nativeTrack,{streams:[this.nativeStream],direction:"sendonly",sendEncodings:void 0});return this.setPreferredCodec(t,e.nativeTrack.kind),t},n.setPreferredCodec=function(e,t){},n.replaceTrack=function(){var e=o(y.mark((function e(t,n){var r;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(r=this.connection.getSenders().find((function(e){return e.track&&e.track.id===t.trackId})))){e.next=3;break}throw Error("No sender found for trackId="+t.trackId);case 3:return this.nativeStream.removeTrack(t.nativeTrack),r.track.stop(),e.next=7,r.replaceTrack(n);case 7:this.nativeStream.addTrack(n),t.nativeTrack=n;case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.removeSender=function(e){var t=this,n=0;if(this.connection.getSenders().forEach((function(r){if(r.track&&r.track.id===e.trackId){t.connection.removeTrack(r),n+=1;var i=t.tracks.indexOf(e);if(-1===i)throw Error("Cannot find "+e+" in locally stored tracks");t.tracks.splice(i,1)}})),1!=n)throw Error("Removed "+n+" sender's, expected to remove 1")},t}(O),ae="HMSTransport",se=function(){function e(e){var t,n,r,i=this;this.publishConnection=null,this.subscribeConnection=null,this.callbacks=new Map,this.signalObserver={onOffer:(n=o(y.mark((function e(t){var n,r,o,a;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.subscribeConnection.setRemoteDescription(t);case 2:n=m(i.subscribeConnection.candidates);case 3:if((r=n()).done){e.next=9;break}return o=r.value,e.next=7,i.subscribeConnection.addIceCandidate(o);case 7:e.next=3;break;case 9:return i.subscribeConnection.candidates.length=0,e.next=12,i.subscribeConnection.createAnswer();case 12:return a=e.sent,e.next=15,i.subscribeConnection.setLocalDescription(a);case 15:i.signal.answer(a);case 16:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)}),onTrickle:(t=o(y.mark((function e(t){var n;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=t.target===x.PUBLISH?i.publishConnection:i.subscribeConnection).remoteDescription){e.next=5;break}n.candidates.push(t.candidate),e.next=7;break;case 5:return e.next=7,n.addIceCandidate(t.candidate);case 7:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)}),onNotification:function(e){return i.observer.onNotification(e)},onFailure:function(e){i.observer.onFailure(e)}},this.signal=new Y(this.signalObserver),this.publishConnectionObserver={onRenegotiationNeeded:(r=o(y.mark((function e(){var t,n,r;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"[role=PUBLISH] onRenegotiationNeeded START ⏰"),t=i.callbacks.get("renegotiation-callback-id"),i.callbacks.delete("renegotiation-callback-id"),e.next=5,i.publishConnection.createOffer();case 5:return n=e.sent,e.next=8,i.publishConnection.setLocalDescription(n);case 8:return e.next=10,i.signal.offer(n);case 10:return r=e.sent,e.next=13,i.publishConnection.setRemoteDescription(r);case 13:null==t||t.resolve(!0),w.d(ae,"[role=PUBLISH] onRenegotiationNeeded DONE ✅");case 15:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)}),onIceConnectionChange:function(e){}},this.subscribeConnectionObserver={onApiChannelMessage:function(e){var t={method:"active-speakers",params:JSON.parse(e)};i.observer.onNotification(t)},onTrackAdd:function(e){return i.observer.onTrackAdd(e)},onTrackRemove:function(e){return i.observer.onTrackRemove(e)},onIceConnectionChange:function(e){}},this.observer=e}var t=e.prototype;return t.getLocalScreen=function(){var e=o(y.mark((function e(t,n){var r;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe.getLocalScreen(t);case 2:return(r=e.sent).nativeTrack.onended=function(){return n()},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.getLocalTracks=function(){var e=o(y.mark((function e(t){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe.getLocalTracks(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.join=function(){var e=o(y.mark((function e(t,n,r,i){var o,a,s,c,u,h;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"join: started ⏰"),e.next=3,J.fetchInitConfig(t);case 3:return o=e.sent,e.next=6,this.signal.open(o.endpoint+"?peer="+r+"&token="+t);case 6:return w.d(ae,"join: connected to ws endpoint"),this.publishConnection=new A(this.signal,o.rtcConfiguration,this.publishConnectionObserver),this.subscribeConnection=new H(this.signal,o.rtcConfiguration,this.subscribeConnectionObserver),w.d(ae,"join: Negotiating over PUBLISH connection ⏰"),e.next=12,this.publishConnection.createOffer();case 12:return a=e.sent,e.next=15,this.publishConnection.setLocalDescription(a);case 15:return e.next=17,this.signal.join(n,r,a,i);case 17:return s=e.sent,e.next=20,this.publishConnection.setRemoteDescription(s);case 20:c=m(this.publishConnection.candidates);case 21:if((u=c()).done){e.next=27;break}return h=u.value,e.next=25,this.publishConnection.addIceCandidate(h);case 25:e.next=21;break;case 27:this.publishConnection.initAfterJoin(),w.d(ae,"join: Negotiating over PUBLISH connection ✅"),w.d(ae,"join: successful ✅");case 30:case"end":return e.stop()}}),e,this)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),t.leave=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.publishConnection.close();case 2:return e.next=4,this.subscribeConnection.close();case 4:return e.next=6,this.signal.close();case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.publishTrack=function(){var e=o(y.mark((function e(t){var n,r,i=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"publishTrack: trackId="+t.trackId+" ⏰",t),n=new Promise((function(e,t){i.callbacks.set("renegotiation-callback-id",{resolve:e,reject:t})})),(r=t.stream).setConnection(this.publishConnection),r.addTransceiver(t),e.next=7,n;case 7:w.d(ae,"publishTrack: trackId="+t.trackId+" ✅",this.callbacks);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unpublishTrack=function(){var e=o(y.mark((function e(t){var n,r=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"unpublishTrack: trackId="+t.trackId+" ⏰",t),n=new Promise((function(e,t){r.callbacks.set("renegotiation-callback-id",{resolve:e,reject:t})})),t.stream.removeSender(t),e.next=6,n;case 6:w.d(ae,"unpublishTrack: trackId="+t.trackId+" ✅",this.callbacks);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.publish=function(){var e=o(y.mark((function e(t){var n,r,i;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m(t);case 1:if((r=n()).done){e.next=7;break}return i=r.value,e.next=5,this.publishTrack(i);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unpublish=function(){var e=o(y.mark((function e(t){var n,r,i;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m(t);case 1:if((r=n()).done){e.next=7;break}return i=r.value,e.next=5,this.unpublishTrack(i);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();!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"}(ee||(ee={})),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"}(te||(te={})),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"}(ne||(ne={})),function(e){e[e.PEER_JOIN=0]="PEER_JOIN",e[e.PEER_LEAVE=1]="PEER_LEAVE",e[e.PEER_LIST=2]="PEER_LIST",e[e.STREAM_ADD=3]="STREAM_ADD",e[e.ACTIVE_SPEAKERS=4]="ACTIVE_SPEAKERS"}(re||(re={}));var ce=function(e){this.userName=null==e?void 0:e.userName,this.metadata=null==e?void 0:e.metadata},ue=function(e){this.uid=e.uid,this.sid=e.sid,this.info=new ce(e.info)},he=function(e){this.uid=e.uid,this.stream=e.stream,this.streamId=this.stream.streamId},fe=function(e){this.peers=e.peers,this.streams=e.streams},le=function(e){var t=e.peerId,n=e.name,r=e.isLocal,i=e.customerDescription;this.customerDescription="",this.name=n,this.peerId=t,this.isLocal=r,this.customerDescription=i},de=function(){var e=this;this.hmsPeerList=[],this.TAG="NotificationManager",this.streamIdToUIDMap=new Map,this.streamIdToTrackMap=new Map,this.handleNotification=function(t,r){var i;switch(t){case re.PEER_JOIN:n.debug(e.TAG,"PEER_JOIN event",i=r),e.handlePeerJoin(i);break;case re.PEER_LEAVE:n.debug(e.TAG,"PEER_LEAVE event",i=r),e.handlePeerLeave(i);break;case re.PEER_LIST:var o=r;n.debug(e.TAG,"PEER_LIST event",o),e.handlePeerList(o);break;case re.STREAM_ADD:var a=r;n.debug(e.TAG,"STREAM_ADD event",a),e.handleStreamAdd(a.stream);break;case re.ACTIVE_SPEAKERS:default:return}},this.handleOnTrackAdd=function(t){n.debug(e.TAG,"ONTRACKADD",t);var r=t.stream.id,i=e.streamIdToUIDMap.get(r)?e.findPeerByUID(e.streamIdToUIDMap.get(r)):null;if(i)switch(t.type){case P.AUDIO:i.audioTrack=t;break;case P.VIDEO:i.videoTrack=t}else e.streamIdToTrackMap.set(r,t);return i},this.handleOnTrackRemove=function(t){n.debug(e.TAG,"ONTRACKREMOVE",t);var r=e.streamIdToUIDMap.get(t.stream.id),i=r&&e.findPeerByUID(r);if(i)switch(t.type){case P.AUDIO:i.audioTrack=null;break;case P.VIDEO:i.videoTrack=null}else n.error(e.TAG,"No peer found for track "+t);return i},this.findPeerByUID=function(t){return e.hmsPeerList.find((function(e){return e.peerId===t}))},this.handlePeerJoin=function(t){var n=new le({peerId:t.uid,name:t.info&&t.info.userName?t.info.userName:"",isLocal:!1,customerDescription:t.info&&t.info.metadata?t.info.metadata:""});e.hmsPeerList.push(n)},this.handlePeerLeave=function(t){var n=e.findPeerByUID(t.uid),r=n&&e.hmsPeerList.indexOf(n);r&&r>-1&&e.hmsPeerList.splice(r,1)},this.handlePeerList=function(t){var n=t.peers,r=t.streams;n&&n.forEach((function(t){return e.handlePeerJoin(t)})),r&&r.forEach((function(t){return e.handleStreamAdd(t)}))},this.handleStreamAdd=function(t){if(e.streamIdToUIDMap.set(t.streamId,t.uid),e.streamIdToTrackMap.has(t.streamId)){var n=e.findPeerByUID(t.uid),r=e.streamIdToTrackMap.get(t.streamId);if(r&&n)switch(r.type){case P.AUDIO:n.audioTrack=r;break;case P.VIDEO:n.videoTrack=r}}}},pe=function(){function e(){this._volume=1,this._codec=I.OPUS,this._maxBitRate=32e3,this._deviceId="default",this._advanced=[{googEchoCancellation:{exact:!0}},{googExperimentalEchoCancellation:{exact:!0}},{autoGainControl:{exact:!0}},{noiseSuppression:{exact:!0}},{googHighpassFilter:{exact:!0}},{googAudioMirroring:{exact:!0}}]}var t=e.prototype;return t.volume=function(e){if(!(0<=e&&e<=1))throw Error("volume can only be in range [0.0, 1.0]");return this._volume=e,this},t.codec=function(e){return this._codec=e,this},t.maxBitRate=function(e){if(e<=0)throw Error("maxBitRate should be >= 1");return this._maxBitRate=e,this},t.deviceId=function(e){return this._deviceId=e,this},t.advanced=function(e){return this._advanced=e,this},t.build=function(){return new ve(this._volume,this._codec,this._maxBitRate,this._deviceId,this._advanced)},e}(),ve=function(){function e(e,t,n,r,i){this.volume=e,this.codec=t,this.maxBitRate=n,this.deviceId=r,this.advanced=i}return e.prototype.toConstraints=function(){return{deviceId:this.deviceId,advanced:this.advanced}},e}(),me=function(){function e(){this._video=L.QVGA,this._audio=(new pe).build(),this._simulcast=!1}var t=e.prototype;return t.video=function(e){return this._video=e,this},t.audio=function(e){return this._audio=e,this},t.simulcast=function(e){return this._simulcast=e,this},t.build=function(){if(null===this._audio&&null===this._video)throw Error("There is no media to return. Please select either video or audio or both");if(null===this._video&&this._simulcast)throw Error("Cannot enable simulcast when no video settings are provided");return new Ee(this._video,this._audio,this._simulcast)},e}(),Ee=function(e,t,n){this.video=e,this.audio=t,this.simulcast=n},ke=function(e,t,n){this.id=e,this.name=t,this.peers=n};exports.default=function(){function e(){var e=this;this.logLevel=E.OFF,this.analyticsLevel=k.OFF,this.TAG="HMSSdk",this.notificationManager=new de,this.observer={onNotification:function(t){var n=function(e){switch(e){case"peer-join":return re.PEER_JOIN;case"peer-leave":return re.PEER_LEAVE;case"peer-list":return re.PEER_LIST;case"stream-add":return re.STREAM_ADD;case"active-speakers":return re.ACTIVE_SPEAKERS;default:throw Error("Unsupported method="+e+" received")}}(t.method);if(n!==re.ACTIVE_SPEAKERS){var r=function(e,t){switch(e){case re.PEER_JOIN:case re.PEER_LEAVE:return new ue(t);case re.PEER_LIST:return new fe(t);case re.STREAM_ADD:return new he(t);case re.ACTIVE_SPEAKERS:return;default:throw Error("Unsupported method="+e+" received")}}(n,t.params);e.notificationManager.handleNotification(n,r),e.onNotificationHandled(n,r)}},onTrackAdd:function(t){var r=e.notificationManager.handleOnTrackAdd(t);r?e.listener.onTrackUpdate(ne.TRACK_ADDED,t,r):n.error(e.TAG,"No Peer found for added track:: "+t)},onTrackRemove:function(t){var r=e.notificationManager.handleOnTrackRemove(t);r?e.listener.onTrackUpdate(ne.TRACK_REMOVED,t,r):n.error(e.TAG,"No Peer found for added track:: "+t)},onFailure:function(t){e.listener.onError(t)}},this.transport=new se(this.observer),n.setLevel(n.levels.DEBUG)}var i=e.prototype;return i.join=function(e,n){var i=this;this.listener=n;var o=r.decode(e.authToken,{json:!0}).room_id,a=t.v4();this.localPeer=new le({peerId:a,name:e.userName,isLocal:!0,customerDescription:e.metaData}),this.transport.join(e.authToken,o,a,{userName:e.userName}).then((function(){console.log("JOINED!",o),i.roomId=o}))},i.leave=function(){var e,t;this.roomId&&(null==(e=this.localPeer.audioTrack)||e.nativeTrack.stop(),null==(t=this.localPeer.videoTrack)||t.nativeTrack.stop(),this.transport.leave(),this.roomId=null)},i.getLocalPeer=function(){return this.localPeer},i.getPeers=function(){return[].concat(this.notificationManager.hmsPeerList,[this.localPeer])},i.sendMessage=function(e){throw console.log(e),"Yet to implement"},i.onMessageReceived=function(e){throw console.log(e),"Yet to implement"},i.startScreenShare=function(){var e=o(y.mark((function e(){var t,n,r=this;return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(((null==(t=this.localPeer.auxiliaryTracks)?void 0:t.length)||0)>0)){e.next=2;break}throw Error("Cannot share multiple screens");case 2:return e.next=4,this.transport.getLocalScreen((new S).build(),(function(){return r.stopScreenShare()}));case 4:return n=e.sent,e.next=7,this.transport.publish([n]);case 7:this.localPeer.auxiliaryTracks=[n];case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.stopScreenShare=function(){var e=o(y.mark((function e(){return y.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.transport.unpublish(this.localPeer.auxiliaryTracks),this.localPeer.auxiliaryTracks.length=0;case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.onNotificationHandled=function(e,t){var r,i,o=this;switch(e){case re.PEER_JOIN:(i=this.notificationManager.findPeerByUID((r=t).uid))?this.listener.onPeerUpdate(te.PEER_JOINED,i):n.error(this.TAG,"peer not found in peer-list "+r);break;case re.PEER_LEAVE:var a=new le({peerId:t.uid,name:t.info.userName,isLocal:!1,customerDescription:t.info.metadata});this.listener.onPeerUpdate(te.PEER_LEFT,a);break;case re.PEER_LIST:this.transport.getLocalTracks((new me).build()).then((function(e){e.forEach((function(e){switch(e.type){case P.AUDIO:o.localPeer.audioTrack=e;break;case P.VIDEO:o.localPeer.videoTrack=e}})),o.listener.onJoin(o.createRoom()),o.transport.publish(e)}));break;case re.STREAM_ADD:case re.ACTIVE_SPEAKERS:return}},i.createRoom=function(){var e=this.getPeers();return this.hmsRoom=new ke(this.localPeer.peerId,"",e),this.hmsRoom},e}();
"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("uuid"),n=e(require("loglevel")),r=e(require("jsonwebtoken"));function i(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)}))}}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function f(e,t,n){return(f=l()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&h(i,n.prototype),i}).apply(null,arguments)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return f(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)})(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return v(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var E,k,y,b,g=(function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var i=Object.create((t&&t.prototype instanceof l?t:l).prototype),o=new x(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=b(a,n);if(s){if(s===h)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),i}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function l(){}function f(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(T([])));m&&m!==t&&n.call(m,i)&&(p=m);var E=d.prototype=l.prototype=Object.create(p);function k(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function y(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,s){var c=u(e[i],e,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){h.value=e,a(h)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,h;var i=r.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,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function g(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 w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(g,this),this.reset(!0)}function T(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 r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return f.prototype=E.constructor=d,d.constructor=f,f.displayName=s(d,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,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},k(y.prototype),y.prototype[o]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new y(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(E),s(E,a,"Generator"),E[i]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,x.prototype={constructor:x,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(w),!e)for(var t in this)"t"===t.charAt(0)&&n.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 r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.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,h):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),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(b={exports:{}}),b.exports);!function(e){e[e.OFF=0]="OFF",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.VERBOSE=4]="VERBOSE"}(E||(E={})),function(e){e[e.OFF=0]="OFF",e[e.ERROR=1]="ERROR",e[e.INFO=2]="INFO",e[e.VERBOSE=3]="VERBOSE"}(k||(k={})),function(e){e[e.VERBOSE=0]="VERBOSE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE"}(y||(y={}));var w=function(){function e(){}return e.v=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[y.VERBOSE,e].concat(n))},e.d=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[y.DEBUG,e].concat(n))},e.i=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[y.INFO,e].concat(n))},e.w=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[y.WARN,e].concat(n))},e.e=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];this.log.apply(this,[y.ERROR,e].concat(n))},e.log=function(e,t){if(!(this.level.valueOf()>e.valueOf())){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];switch(e){case y.VERBOSE:var o;(o=console).log.apply(o,[t].concat(r));break;case y.DEBUG:var a;(a=console).debug.apply(a,[t].concat(r));break;case y.INFO:var s;(s=console).info.apply(s,[t].concat(r));break;case y.WARN:var c;(c=console).warn.apply(c,[t].concat(r));break;case y.ERROR:var u;(u=console).error.apply(u,[t].concat(r))}}},e}();w.level=y.VERBOSE;var x,T="HMSConnection",R=function(){function e(e,t){this.candidates=new Array,this.role=e,this.signal=t}var t=e.prototype;return t.addTransceiver=function(e,t){return this.nativeConnection.addTransceiver(e,t)},t.createOffer=function(){var e=o(g.mark((function e(t){var n;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=void 0),e.next=3,this.nativeConnection.createOffer(t);case 3:return n=e.sent,w.d(T,"[role="+this.role+"] createOffer offer="+JSON.stringify(n,null,1)),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.createAnswer=function(){var e=o(g.mark((function e(t){var n;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=void 0),e.next=3,this.nativeConnection.createAnswer(t);case 3:return n=e.sent,w.d(T,"[role="+this.role+"] createAnswer answer="+JSON.stringify(n,null,1)),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setLocalDescription=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] setLocalDescription description="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.setLocalDescription(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setRemoteDescription=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] setRemoteDescription description="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.setRemoteDescription(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.addIceCandidate=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(T,"[role="+this.role+"] addIceCandidate candidate="+JSON.stringify(t,null,1)),e.next=3,this.nativeConnection.addIceCandidate(t);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getSenders=function(){return this.nativeConnection.getSenders()},t.removeTrack=function(e){this.nativeConnection.removeTrack(e)},t.close=function(){var e=o(g.mark((function e(){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.nativeConnection.close();case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),s(e,[{key:"remoteDescription",get:function(){return this.nativeConnection.remoteDescription}}]),e}();!function(e){e[e.PUBLISH=0]="PUBLISH",e[e.SUBSCRIBE=1]="SUBSCRIBE"}(x||(x={}));var S,C,I=function(e){function t(t,n,r){var i;return(i=e.call(this,x.PUBLISH,t)||this).observer=r,i.nativeConnection=new RTCPeerConnection(n),i.nativeConnection.createDataChannel("ion-sfu",{protocol:"SCTP"}),i.nativeConnection.onicecandidate=function(e){var n=e.candidate;n&&t.trickle({target:i.role,candidate:n})},i.nativeConnection.oniceconnectionstatechange=function(){i.observer.onIceConnectionChange(i.nativeConnection.iceConnectionState)},i}return c(t,e),t.prototype.initAfterJoin=function(){var e=this;this.nativeConnection.onnegotiationneeded=o(g.mark((function t(){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return w.d("HMSPublishConnection","onnegotiationneeded"),t.next=3,e.observer.onRenegotiationNeeded();case 3:case"end":return t.stop()}}),t)})))},t}(R),A=function(e){this.tracks=new Array,this.nativeStream=e,this.id=e.id};!function(e){e.VP8="vp8",e.VP9="vp9",e.H264="h264"}(S||(S={})),function(e){e.OPUS="opus"}(C||(C={}));var O,_=function(){function e(){this._resolution=new N(320,180),this._codec=S.VP8,this._maxFrameRate=24,this._maxBitRate=15e4,this._deviceId="default",this._advanced=[]}var t=e.prototype;return t.resolution=function(e){return this._resolution=e,this},t.codec=function(e){return this._codec=e,this},t.maxFrameRate=function(e){if(e<=0)throw Error("maxFrameRate should be >= 1");return this._maxFrameRate=e,this},t.maxBitRate=function(e){if(e<=0)throw Error("maxBitRate should be >= 1");return this._maxBitRate=e,this},t.deviceId=function(e){return this._deviceId=e,this},t.advanced=function(e){return this._advanced=e,this},t.build=function(){return new D(this._resolution,this._codec,this._maxFrameRate,this._maxBitRate,this._deviceId,this._advanced)},e}(),D=function(){function e(e,t,n,r,i,o){this.resolution=e,this.codec=t,this.maxFrameRate=n,this.maxBitRate=r,this.deviceId=i,this.advanced=o}return e.prototype.toConstraints=function(){return{width:this.resolution.width,height:this.resolution.height,frameRate:this.maxFrameRate,deviceId:this.deviceId}},e}();!function(e){e.NONE="none",e.LOW="low",e.MEDIUM="medium",e.HIGH="high"}(O||(O={}));var P,N=function(e,t){if(e<=0)throw Error("Height should be >= 1");if(t<=0)throw Error("Height should be >= 1");this.width=e,this.height=t},L={QVGA:(new _).resolution(new N(320,180)).maxBitRate(15e4).build(),VGA:(new _).resolution(new N(640,360)).maxBitRate(5e5).build(),SHD:(new _).resolution(new N(960,540)).maxBitRate(12e5).build(),HD:(new _).resolution(new N(1280,720)).maxBitRate(25e5).build(),FHD:(new _).resolution(new N(1920,1080)).maxBitRate(4e6).build(),QHD:(new _).resolution(new N(2560,1440)).maxBitRate(8e6).build()},M=function(e){function t(t,n){var r;return(r=e.call(this,t)||this).audio=!0,r.video=O.HIGH,r.frameRate=O.HIGH,r.connection=n,r}c(t,e);var n=t.prototype;return n.setAudio=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.audio=t,e.next=3,this.syncWithApiChannel();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setVideo=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.video=t?O.HIGH:O.NONE,e.next=3,this.syncWithApiChannel();case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.syncWithApiChannel=function(){var e=o(g.mark((function e(){var t;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={streamId:this.nativeStream.id,video:this.video,audio:this.audio,framerate:this.frameRate},e.next=3,this.connection.apiChannel.send(JSON.stringify(t));case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(A),U=function(){function e(e,t,n){var r=this;void 0===n&&(n=""),this.TAG="HMSDataChannel",this.nativeChannel=e,this.observer=t,this.metadata=n,e.onmessage=function(e){w.d(r.TAG,"["+r.metadata+"] onMessage: label="+r.label+", message="+e.data),r.observer.onMessage(e.data)}}var t=e.prototype;return t.send=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("open"===this.nativeChannel.readyState){e.next=2;break}throw Error("Channel "+this.label+" not yet ready");case 2:w.d(this.TAG,"["+this.metadata+"] Sending [size="+t.length+"] message="+t),this.nativeChannel.send(t);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.close=function(){this.nativeChannel.close()},s(e,[{key:"id",get:function(){return this.nativeChannel.id}},{key:"label",get:function(){return this.nativeChannel.label}}]),e}(),H=function(){function e(e,t){this.stream=e,this.nativeTrack=t}return e.prototype.setEnabled=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.nativeTrack.enabled=t;case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),s(e,[{key:"enabled",get:function(){return this.nativeTrack.enabled}},{key:"trackId",get:function(){return this.nativeTrack.id}}]),e}();(P=exports.HMSTrackType||(exports.HMSTrackType={}))[P.AUDIO=0]="AUDIO",P[P.VIDEO=1]="VIDEO";var B=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).type=exports.HMSTrackType.AUDIO,"audio"!==n.kind)throw new Error("Expected 'track' kind = 'audio'");return r}return c(t,e),t}(H),G=function(e){function t(t,n){return e.call(this,t,n)||this}return c(t,e),t.prototype.setEnabled=function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:return t.next=6,this.stream.setAudio(n);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(B),V=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).type=exports.HMSTrackType.VIDEO,"video"!==n.kind)throw new Error("Expected 'track' kind = 'video'");return r}return c(t,e),t}(H),F=function(e){function t(t,n){return e.call(this,t,n)||this}return c(t,e),t.prototype.setEnabled=function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:return t.next=6,this.stream.setVideo(n);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(V),j=function(e){function t(t,n,r){var i;return(i=e.call(this,x.SUBSCRIBE,t)||this).remoteStreams=new Map,i._apiChannel=null,i.observer=r,i.nativeConnection=new RTCPeerConnection(n),i.initNativeConnectionCallbacks(),i}c(t,e);var n=t.prototype;return n.initNativeConnectionCallbacks=function(){var e=this;this.nativeConnection.oniceconnectionstatechange=function(){e.observer.onIceConnectionChange(e.nativeConnection.iceConnectionState)},this.nativeConnection.ondatachannel=function(t){"ion-sfu"===t.channel.label&&(e._apiChannel=new U(t.channel,{onMessage:function(t){e.observer.onApiChannelMessage(t)}},"role="+e.role))},this.nativeConnection.onicecandidate=function(t){null!==t.candidate&&e.signal.trickle({candidate:t.candidate,target:e.role})},this.nativeConnection.ontrack=function(t){var n=t.streams[0];if(!e.remoteStreams.has(n.id)){var r=new M(n,e);e.remoteStreams.set(n.id,r),n.onremovetrack=function(t){var i=r.tracks.findIndex((function(e){return e.trackId===t.track.id}));i>=0&&(e.observer.onTrackRemove(r.tracks[i]),r.tracks.splice(i,1),0===r.tracks.length&&e.remoteStreams.delete(n.id))}}var i=e.remoteStreams.get(n.id),o=new("audio"===t.track.kind?G:F)(i,t.track);i.tracks.push(o),e.observer.onTrackAdd(o)}},n.close=function(){var t=o(g.mark((function t(){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.prototype.close.call(this);case 2:this.apiChannel.close();case 3:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),s(t,[{key:"apiChannel",get:function(){return this._apiChannel}}]),t}(R),J=function(){function e(){}return e.fetchInitConfig=function(){var e=o(g.mark((function e(t,n){var r,i;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n=""),w.d("InitService","fetchInitConfig: token="+t+" region="+n),r="https://qa2-us.100ms.live/init?token="+t,n.length>0&&(r+="&region="+n),e.next=6,fetch(r);case 6:return i=e.sent,e.next=9,i.json();case 9:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),e}(),K=function(){function e(e,t){this.code=e,this.message=t}return e.prototype.build=function(){return new W(this.code,this.message)},e}(),W=function(e){function t(t,n){var r;return(r=e.call(this,n)||this).code=t,r}return c(t,e),t}(d(Error)),Y=function(){function e(e){this.TAG="JsonRpcSignal",this.isJoinCompleted=!1,this.pendingTrickle=[],this.socket=null,this.callbacks=new Map,this.observer=e}var n=e.prototype;return n.call=function(){var e=o(g.mark((function e(n,r){var i,o=this;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.v4(),this.socket.send(JSON.stringify({method:n,params:r,id:i})),e.next=5,new Promise((function(e,t){o.callbacks.set(i,{resolve:e,reject:t})}));case 5:return e.abrupt("return",JSON.parse(e.sent));case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.notify=function(e,t){this.socket.send(JSON.stringify({method:e,params:t}))},n.open=function(e){var t=this;return new Promise((function(n){t.socket=new WebSocket(e),t.socket.addEventListener("open",(function e(){n(),t.socket.removeEventListener("open",e)})),t.socket.addEventListener("message",(function(e){return t.onMessageHandler(e.data)}))}))},n.close=function(){var e=o(g.mark((function e(){var t,n=this;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Promise((function(e){n.socket.addEventListener("close",(function(){return e()}))})),this.socket.close(1e3,"Normal Close"),e.abrupt("return",t);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.join=function(){var e=o(g.mark((function e(t,n,r,i){var o,a,s=this;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={sid:t,uid:n,offer:r,info:i},e.next=3,this.call("join",o);case 3:return a=e.sent,this.isJoinCompleted=!0,this.pendingTrickle.forEach((function(e){return s.trickle(e)})),this.pendingTrickle.length=0,w.d(this.TAG,"join: response="+JSON.stringify(a,null,1)),e.abrupt("return",a);case 9:case"end":return e.stop()}}),e,this)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),n.offer=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.call("offer",{desc:t});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.answer=function(e){this.notify("answer",{desc:e})},n.trickle=function(e){this.isJoinCompleted?this.notify("trickle",e):this.pendingTrickle.push(e)},n.onMessageHandler=function(e){var t=JSON.parse(e);if(t.hasOwnProperty("id")){var n=t.id;if(this.callbacks.has(n)){var r=this.callbacks.get(n);if(this.callbacks.delete(n),t.result)r.resolve(JSON.stringify(t.result));else{var i=t.error,o=new K(i.code,i.message).build();r.reject(o)}}else this.observer.onNotification(t)}else{if(!t.hasOwnProperty("method"))throw Error("WebSocket message has no 'method' or 'id' field, message="+t);"offer"===t.method?this.observer.onOffer(t.params):"trickle"===t.method?this.observer.onTrickle(t.params):this.observer.onNotification(t)}},e}();function q(e){return Q.apply(this,arguments)}function Q(){return(Q=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({audio:t.toConstraints()});case 2:return e.abrupt("return",e.sent.getAudioTracks()[0]);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function z(e){return $.apply(this,arguments)}function $(){return($=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({video:t.toConstraints()});case 2:return e.abrupt("return",e.sent.getVideoTracks()[0]);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var X=function(e){function t(t,n,r){var i;return i=e.call(this,t,n)||this,t.tracks.push(p(i)),i.settings=r,i}c(t,e);var n=t.prototype;return n.replaceTrackWith=function(){var e=o(g.mark((function e(t){var n;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q(t);case 2:return n=e.sent,e.next=5,this.stream.replaceTrack(this,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setEnabled=function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:if(!n){t.next=9;break}return t.next=7,this.replaceTrackWith(this.settings);case 7:t.next=10;break;case 9:this.nativeTrack.stop();case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.setSettings=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.settings.codec===t.codec){e.next=2;break}throw Error("Audio Codec can't be changed mid call.");case 2:if(this.settings.deviceId===t.deviceId){e.next=5;break}return e.next=5,this.replaceTrackWith(t);case 5:return e.next=7,this.nativeTrack.applyConstraints(t.toConstraints());case 7:this.settings=t;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(B);function Z(e){if(e<=0)throw Error("`ms` should be a positive integer");return new Promise((function(t){return setTimeout(t,e)}))}var ee,te,ne,re,ie=function(e){function t(t,n,r){var i;return i=e.call(this,t,n)||this,t.tracks.push(p(i)),i.settings=r,i}c(t,e);var n=t.prototype;return n.replaceTrackWith=function(){var e=o(g.mark((function e(t){var n;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z(t);case 2:return n=e.sent,e.next=5,this.stream.replaceTrack(this,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.setEnabled=function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==this.enabled){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.prototype.setEnabled.call(this,n);case 4:if(!n){t.next=9;break}return t.next=7,this.replaceTrackWith(this.settings);case 7:t.next=12;break;case 9:return t.next=11,Z(100);case 11:this.nativeTrack.stop();case 12:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.setSettings=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.settings.codec===t.codec){e.next=2;break}throw Error("Video Codec can't be changed mid call.");case 2:if(this.settings.deviceId===t.deviceId){e.next=5;break}return e.next=5,this.replaceTrackWith(t);case 5:return e.next=7,this.nativeTrack.applyConstraints(t.toConstraints());case 7:this.settings=t;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(V),oe=function(e){function t(t){var n;return(n=e.call(this,t)||this).connection=null,n}c(t,e);var n=t.prototype;return n.setConnection=function(e){this.connection=e},t.getLocalScreen=function(){var e=o(g.mark((function e(n){var r,i,o,a,s;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={video:n.toConstraints(),audio:!1},e.next=3,navigator.mediaDevices.getDisplayMedia(r);case 3:return o=new t(i=e.sent),a=i.getVideoTracks()[0],s=new ie(o,a,n),w.v("HMSLocalStream","getLocalScreen",s),e.abrupt("return",s);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.getLocalTracks=function(){var e=o(g.mark((function e(n){var r,i,o,a,s,c,u;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia({audio:null!=n.audio&&n.audio.toConstraints(),video:null!=n.video&&n.video.toConstraints()});case 2:return i=new t(r=e.sent),o=[],null!=n.audio&&(a=r.getAudioTracks()[0],s=new X(i,a,n.audio),o.push(s)),null!=n.video&&(c=r.getVideoTracks()[0],u=new ie(i,c,n.video),o.push(u)),w.v("HMSLocalStream","getLocalTracks",o),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.addTransceiver=function(e){var t=this.connection.addTransceiver(e.nativeTrack,{streams:[this.nativeStream],direction:"sendonly",sendEncodings:void 0});return this.setPreferredCodec(t,e.nativeTrack.kind),t},n.setPreferredCodec=function(e,t){},n.replaceTrack=function(){var e=o(g.mark((function e(t,n){var r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(r=this.connection.getSenders().find((function(e){return e.track&&e.track.id===t.trackId})))){e.next=3;break}throw Error("No sender found for trackId="+t.trackId);case 3:return this.nativeStream.removeTrack(t.nativeTrack),r.track.stop(),e.next=7,r.replaceTrack(n);case 7:this.nativeStream.addTrack(n),t.nativeTrack=n;case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.removeSender=function(e){var t=this,n=0;if(this.connection.getSenders().forEach((function(r){if(r.track&&r.track.id===e.trackId){t.connection.removeTrack(r),n+=1;var i=t.tracks.indexOf(e);if(-1===i)throw Error("Cannot find "+e+" in locally stored tracks");t.tracks.splice(i,1)}})),1!=n)throw Error("Removed "+n+" sender's, expected to remove 1")},t}(A),ae="HMSTransport",se=function(){function e(e){var t,n,r,i=this;this.publishConnection=null,this.subscribeConnection=null,this.callbacks=new Map,this.signalObserver={onOffer:(n=o(g.mark((function e(t){var n,r,o,a;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.subscribeConnection.setRemoteDescription(t);case 2:n=m(i.subscribeConnection.candidates);case 3:if((r=n()).done){e.next=9;break}return o=r.value,e.next=7,i.subscribeConnection.addIceCandidate(o);case 7:e.next=3;break;case 9:return i.subscribeConnection.candidates.length=0,e.next=12,i.subscribeConnection.createAnswer();case 12:return a=e.sent,e.next=15,i.subscribeConnection.setLocalDescription(a);case 15:i.signal.answer(a);case 16:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)}),onTrickle:(t=o(g.mark((function e(t){var n;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=t.target===x.PUBLISH?i.publishConnection:i.subscribeConnection).remoteDescription){e.next=5;break}n.candidates.push(t.candidate),e.next=7;break;case 5:return e.next=7,n.addIceCandidate(t.candidate);case 7:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)}),onNotification:function(e){return i.observer.onNotification(e)},onFailure:function(e){i.observer.onFailure(e)}},this.signal=new Y(this.signalObserver),this.publishConnectionObserver={onRenegotiationNeeded:(r=o(g.mark((function e(){var t,n,r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"[role=PUBLISH] onRenegotiationNeeded START ⏰"),t=i.callbacks.get("renegotiation-callback-id"),i.callbacks.delete("renegotiation-callback-id"),e.next=5,i.publishConnection.createOffer();case 5:return n=e.sent,e.next=8,i.publishConnection.setLocalDescription(n);case 8:return e.next=10,i.signal.offer(n);case 10:return r=e.sent,e.next=13,i.publishConnection.setRemoteDescription(r);case 13:null==t||t.resolve(!0),w.d(ae,"[role=PUBLISH] onRenegotiationNeeded DONE ✅");case 15:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)}),onIceConnectionChange:function(e){}},this.subscribeConnectionObserver={onApiChannelMessage:function(e){var t={method:"active-speakers",params:JSON.parse(e)};i.observer.onNotification(t)},onTrackAdd:function(e){return i.observer.onTrackAdd(e)},onTrackRemove:function(e){return i.observer.onTrackRemove(e)},onIceConnectionChange:function(e){}},this.observer=e}var t=e.prototype;return t.getLocalScreen=function(){var e=o(g.mark((function e(t,n){var r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe.getLocalScreen(t);case 2:return(r=e.sent).nativeTrack.onended=function(){return n()},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.getLocalTracks=function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe.getLocalTracks(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.join=function(){var e=o(g.mark((function e(t,n,r,i){var o,a,s,c,u,h;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"join: started ⏰"),e.next=3,J.fetchInitConfig(t);case 3:return o=e.sent,e.next=6,this.signal.open(o.endpoint+"?peer="+r+"&token="+t);case 6:return w.d(ae,"join: connected to ws endpoint"),this.publishConnection=new I(this.signal,o.rtcConfiguration,this.publishConnectionObserver),this.subscribeConnection=new j(this.signal,o.rtcConfiguration,this.subscribeConnectionObserver),w.d(ae,"join: Negotiating over PUBLISH connection ⏰"),e.next=12,this.publishConnection.createOffer();case 12:return a=e.sent,e.next=15,this.publishConnection.setLocalDescription(a);case 15:return e.next=17,this.signal.join(n,r,a,i);case 17:return s=e.sent,e.next=20,this.publishConnection.setRemoteDescription(s);case 20:c=m(this.publishConnection.candidates);case 21:if((u=c()).done){e.next=27;break}return h=u.value,e.next=25,this.publishConnection.addIceCandidate(h);case 25:e.next=21;break;case 27:this.publishConnection.initAfterJoin(),w.d(ae,"join: Negotiating over PUBLISH connection ✅"),w.d(ae,"join: successful ✅");case 30:case"end":return e.stop()}}),e,this)})));return function(t,n,r,i){return e.apply(this,arguments)}}(),t.leave=function(){var e=o(g.mark((function e(){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.publishConnection.close();case 2:return e.next=4,this.subscribeConnection.close();case 4:return e.next=6,this.signal.close();case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.publishTrack=function(){var e=o(g.mark((function e(t){var n,r,i=this;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"publishTrack: trackId="+t.trackId+" ⏰",t),n=new Promise((function(e,t){i.callbacks.set("renegotiation-callback-id",{resolve:e,reject:t})})),(r=t.stream).setConnection(this.publishConnection),r.addTransceiver(t),e.next=7,n;case 7:w.d(ae,"publishTrack: trackId="+t.trackId+" ✅",this.callbacks);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unpublishTrack=function(){var e=o(g.mark((function e(t){var n,r=this;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w.d(ae,"unpublishTrack: trackId="+t.trackId+" ⏰",t),n=new Promise((function(e,t){r.callbacks.set("renegotiation-callback-id",{resolve:e,reject:t})})),t.stream.removeSender(t),e.next=6,n;case 6:w.d(ae,"unpublishTrack: trackId="+t.trackId+" ✅",this.callbacks);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.publish=function(){var e=o(g.mark((function e(t){var n,r,i;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m(t);case 1:if((r=n()).done){e.next=7;break}return i=r.value,e.next=5,this.publishTrack(i);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unpublish=function(){var e=o(g.mark((function e(t){var n,r,i;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=m(t);case 1:if((r=n()).done){e.next=7;break}return i=r.value,e.next=5,this.unpublishTrack(i);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();(ee=exports.HMSRoomUpdate||(exports.HMSRoomUpdate={}))[ee.PEER_ADDED=0]="PEER_ADDED",ee[ee.PEER_REMOVED=1]="PEER_REMOVED",ee[ee.PEER_KNOCKED=2]="PEER_KNOCKED",ee[ee.ROOM_TYPE_CHANGED=3]="ROOM_TYPE_CHANGED",ee[ee.METADATA_UPDATED=4]="METADATA_UPDATED",ee[ee.SCREENSHARE_STARTED=5]="SCREENSHARE_STARTED",ee[ee.SCREENSHARE_STOPPED=6]="SCREENSHARE_STOPPED",ee[ee.DEFAULT_UPDATE=7]="DEFAULT_UPDATE",(te=exports.HMSPeerUpdate||(exports.HMSPeerUpdate={}))[te.PEER_JOINED=0]="PEER_JOINED",te[te.PEER_LEFT=1]="PEER_LEFT",te[te.AUDIO_TOGGLED=2]="AUDIO_TOGGLED",te[te.VIDEO_TOGGLED=3]="VIDEO_TOGGLED",(ne=exports.HMSTrackUpdate||(exports.HMSTrackUpdate={}))[ne.TRACK_ADDED=0]="TRACK_ADDED",ne[ne.TRACK_REMOVED=1]="TRACK_REMOVED",ne[ne.TRACK_MUTED=2]="TRACK_MUTED",ne[ne.TRACK_UNMUTED=3]="TRACK_UNMUTED",ne[ne.TRACK_DESCRIPTION_CHANGED=4]="TRACK_DESCRIPTION_CHANGED",function(e){e[e.PEER_JOIN=0]="PEER_JOIN",e[e.PEER_LEAVE=1]="PEER_LEAVE",e[e.PEER_LIST=2]="PEER_LIST",e[e.STREAM_ADD=3]="STREAM_ADD",e[e.ACTIVE_SPEAKERS=4]="ACTIVE_SPEAKERS"}(re||(re={}));var ce=function(e){this.userName=null==e?void 0:e.userName,this.metadata=null==e?void 0:e.metadata},ue=function(e){this.uid=e.uid,this.sid=e.sid,this.info=new ce(e.info)},he=function(e){this.uid=e.uid,this.stream=e.stream,this.streamId=this.stream.streamId},le=function(e){this.peers=e.peers,this.streams=e.streams},fe=function(e){var t=e.peerId,n=e.name,r=e.isLocal,i=e.customerDescription;this.customerDescription="",this.name=n,this.peerId=t,this.isLocal=r,this.customerDescription=i},de=function(){var e=this;this.hmsPeerList=[],this.TAG="NotificationManager",this.streamIdToUIDMap=new Map,this.streamIdToTrackMap=new Map,this.handleNotification=function(t,r){var i;switch(t){case re.PEER_JOIN:n.debug(e.TAG,"PEER_JOIN event",i=r),e.handlePeerJoin(i);break;case re.PEER_LEAVE:n.debug(e.TAG,"PEER_LEAVE event",i=r),e.handlePeerLeave(i);break;case re.PEER_LIST:var o=r;n.debug(e.TAG,"PEER_LIST event",o),e.handlePeerList(o);break;case re.STREAM_ADD:var a=r;n.debug(e.TAG,"STREAM_ADD event",a),e.handleStreamAdd(a.stream);break;case re.ACTIVE_SPEAKERS:default:return}},this.handleOnTrackAdd=function(t){n.debug(e.TAG,"ONTRACKADD",t);var r=t.stream.id,i=e.streamIdToUIDMap.get(r)?e.findPeerByUID(e.streamIdToUIDMap.get(r)):null;if(i)switch(t.type){case exports.HMSTrackType.AUDIO:i.audioTrack=t;break;case exports.HMSTrackType.VIDEO:i.videoTrack=t}else e.streamIdToTrackMap.set(r,t);return i},this.handleOnTrackRemove=function(t){n.debug(e.TAG,"ONTRACKREMOVE",t);var r=e.streamIdToUIDMap.get(t.stream.id),i=r&&e.findPeerByUID(r);if(i)switch(t.type){case exports.HMSTrackType.AUDIO:i.audioTrack=null;break;case exports.HMSTrackType.VIDEO:i.videoTrack=null}else n.error(e.TAG,"No peer found for track "+t);return i},this.findPeerByUID=function(t){return e.hmsPeerList.find((function(e){return e.peerId===t}))},this.handlePeerJoin=function(t){var n=new fe({peerId:t.uid,name:t.info&&t.info.userName?t.info.userName:"",isLocal:!1,customerDescription:t.info&&t.info.metadata?t.info.metadata:""});e.hmsPeerList.push(n)},this.handlePeerLeave=function(t){var n=e.findPeerByUID(t.uid),r=n&&e.hmsPeerList.indexOf(n);r&&r>-1&&e.hmsPeerList.splice(r,1)},this.handlePeerList=function(t){var n=t.peers,r=t.streams;n&&n.forEach((function(t){return e.handlePeerJoin(t)})),r&&r.forEach((function(t){return e.handleStreamAdd(t)}))},this.handleStreamAdd=function(t){if(e.streamIdToUIDMap.set(t.streamId,t.uid),e.streamIdToTrackMap.has(t.streamId)){var n=e.findPeerByUID(t.uid),r=e.streamIdToTrackMap.get(t.streamId);if(r&&n)switch(r.type){case exports.HMSTrackType.AUDIO:n.audioTrack=r;break;case exports.HMSTrackType.VIDEO:n.videoTrack=r}}}},pe=function(){function e(){this._volume=1,this._codec=C.OPUS,this._maxBitRate=32e3,this._deviceId="default",this._advanced=[{googEchoCancellation:{exact:!0}},{googExperimentalEchoCancellation:{exact:!0}},{autoGainControl:{exact:!0}},{noiseSuppression:{exact:!0}},{googHighpassFilter:{exact:!0}},{googAudioMirroring:{exact:!0}}]}var t=e.prototype;return t.volume=function(e){if(!(0<=e&&e<=1))throw Error("volume can only be in range [0.0, 1.0]");return this._volume=e,this},t.codec=function(e){return this._codec=e,this},t.maxBitRate=function(e){if(e<=0)throw Error("maxBitRate should be >= 1");return this._maxBitRate=e,this},t.deviceId=function(e){return this._deviceId=e,this},t.advanced=function(e){return this._advanced=e,this},t.build=function(){return new ve(this._volume,this._codec,this._maxBitRate,this._deviceId,this._advanced)},e}(),ve=function(){function e(e,t,n,r,i){this.volume=e,this.codec=t,this.maxBitRate=n,this.deviceId=r,this.advanced=i}return e.prototype.toConstraints=function(){return{deviceId:this.deviceId,advanced:this.advanced}},e}(),me=function(){function e(){this._video=L.QVGA,this._audio=(new pe).build(),this._simulcast=!1}var t=e.prototype;return t.video=function(e){return this._video=e,this},t.audio=function(e){return this._audio=e,this},t.simulcast=function(e){return this._simulcast=e,this},t.build=function(){if(null===this._audio&&null===this._video)throw Error("There is no media to return. Please select either video or audio or both");if(null===this._video&&this._simulcast)throw Error("Cannot enable simulcast when no video settings are provided");return new Ee(this._video,this._audio,this._simulcast)},e}(),Ee=function(e,t,n){this.video=e,this.audio=t,this.simulcast=n},ke=function(e,t,n){this.id=e,this.name=t,this.peers=n};exports.HMSSdk=function(){function e(){var e=this;this.logLevel=E.OFF,this.analyticsLevel=k.OFF,this.TAG="HMSSdk",this.notificationManager=new de,this.observer={onNotification:function(t){var n=function(e){switch(e){case"peer-join":return re.PEER_JOIN;case"peer-leave":return re.PEER_LEAVE;case"peer-list":return re.PEER_LIST;case"stream-add":return re.STREAM_ADD;case"active-speakers":return re.ACTIVE_SPEAKERS;default:throw Error("Unsupported method="+e+" received")}}(t.method);if(n!==re.ACTIVE_SPEAKERS){var r=function(e,t){switch(e){case re.PEER_JOIN:case re.PEER_LEAVE:return new ue(t);case re.PEER_LIST:return new le(t);case re.STREAM_ADD:return new he(t);case re.ACTIVE_SPEAKERS:return;default:throw Error("Unsupported method="+e+" received")}}(n,t.params);e.notificationManager.handleNotification(n,r),e.onNotificationHandled(n,r)}},onTrackAdd:function(t){var r=e.notificationManager.handleOnTrackAdd(t);r?e.listener.onTrackUpdate(exports.HMSTrackUpdate.TRACK_ADDED,t,r):n.error(e.TAG,"No Peer found for added track:: "+t)},onTrackRemove:function(t){var r=e.notificationManager.handleOnTrackRemove(t);r?e.listener.onTrackUpdate(exports.HMSTrackUpdate.TRACK_REMOVED,t,r):n.error(e.TAG,"No Peer found for added track:: "+t)},onFailure:function(t){e.listener.onError(t)}},this.transport=new se(this.observer),n.setLevel(n.levels.DEBUG)}var i=e.prototype;return i.join=function(e,n){var i=this;this.listener=n;var o=r.decode(e.authToken,{json:!0}).room_id,a=t.v4();this.localPeer=new fe({peerId:a,name:e.userName,isLocal:!0,customerDescription:e.metaData}),this.transport.join(e.authToken,o,a,{userName:e.userName}).then((function(){console.log("JOINED!",o),i.roomId=o}))},i.leave=function(){var e,t;this.roomId&&(null==(e=this.localPeer.audioTrack)||e.nativeTrack.stop(),null==(t=this.localPeer.videoTrack)||t.nativeTrack.stop(),this.transport.leave(),this.roomId=null)},i.getLocalPeer=function(){return this.localPeer},i.getPeers=function(){return[].concat(this.notificationManager.hmsPeerList,[this.localPeer])},i.sendMessage=function(e){throw console.log(e),"Yet to implement"},i.onMessageReceived=function(e){throw console.log(e),"Yet to implement"},i.startScreenShare=function(){var e=o(g.mark((function e(t){var n,r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(((null==(n=this.localPeer.auxiliaryTracks)?void 0:n.length)||0)>0)){e.next=2;break}throw Error("Cannot share multiple screens");case 2:return e.next=4,this.transport.getLocalScreen(L.HD,t);case 4:return r=e.sent,e.next=7,this.transport.publish([r]);case 7:this.localPeer.auxiliaryTracks=[r];case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),i.stopScreenShare=function(){var e=o(g.mark((function e(){var t;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.localPeer.auxiliaryTracks[0],e.next=3,t.setEnabled(!1);case 3:this.transport.unpublish([t]),this.localPeer.auxiliaryTracks.length=0;case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),i.onNotificationHandled=function(e,t){var r,i,o=this;switch(e){case re.PEER_JOIN:(i=this.notificationManager.findPeerByUID((r=t).uid))?this.listener.onPeerUpdate(exports.HMSPeerUpdate.PEER_JOINED,i):n.error(this.TAG,"peer not found in peer-list "+r);break;case re.PEER_LEAVE:var a=new fe({peerId:t.uid,name:t.info.userName,isLocal:!1,customerDescription:t.info.metadata});this.listener.onPeerUpdate(exports.HMSPeerUpdate.PEER_LEFT,a);break;case re.PEER_LIST:this.transport.getLocalTracks((new me).build()).then((function(e){e.forEach((function(e){switch(e.type){case exports.HMSTrackType.AUDIO:o.localPeer.audioTrack=e;break;case exports.HMSTrackType.VIDEO:o.localPeer.videoTrack=e}})),o.listener.onJoin(o.createRoom()),o.transport.publish(e)}));break;case re.STREAM_ADD:case re.ACTIVE_SPEAKERS:return}},i.createRoom=function(){var e=this.getPeers();return this.hmsRoom=new ke(this.localPeer.peerId,"",e),this.hmsRoom},e}();
//# sourceMappingURL=100ms-web-sdk.cjs.production.min.js.map

@@ -1,32 +0,3 @@

import HMSConfig from './interfaces/config';
import HMSInterface, { HMSAnalyticsLevel, HMSlogLevel } from './interfaces/hms';
import HMSMessage, { HMSMessageListener } from './interfaces/message';
import HMSPeer from './interfaces/hms-peer';
import HMSTransport from './transport';
import HMSUpdateListener from './interfaces/update-listener';
import { HMSNotificationMethod } from './sdk/models/enums/HMSNotificationMethod';
import { HMSNotifications } from './sdk/models/HMSNotifications';
import HMSRoom from './sdk/models/HMSRoom';
export default class HMSSdk implements HMSInterface {
logLevel: HMSlogLevel;
analyticsLevel: HMSAnalyticsLevel;
transport: HMSTransport;
roomId: string | null;
localPeer: HMSPeer;
private TAG;
private notificationManager;
private listener;
private hmsRoom?;
private observer;
constructor();
join(config: HMSConfig, listener: HMSUpdateListener): void;
leave(): void;
getLocalPeer(): HMSPeer;
getPeers(): HMSPeer[];
sendMessage(message: HMSMessage): void;
onMessageReceived(cb: HMSMessageListener): void;
startScreenShare(): Promise<void>;
stopScreenShare(): Promise<void>;
onNotificationHandled(method: HMSNotificationMethod, notification: HMSNotifications): void;
createRoom(): HMSRoom;
}
export * from './sdk';
export * from './media/tracks';
export * from './interfaces/update-listener';

@@ -27,4 +27,4 @@ import HMSConfig from './config';

onMessageReceived(callback: HMSMessageListener): void;
startScreenShare(): void;
startScreenShare(onStop: () => void): void;
stopScreenShare(): void;
}
{
"version": "0.0.7",
"version": "0.0.8",
"license": "UNLICENSED",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -1,183 +0,3 @@

import HMSConfig from './interfaces/config';
import HMSInterface, { HMSAnalyticsLevel, HMSlogLevel } from './interfaces/hms';
import HMSMessage, { HMSMessageListener } from './interfaces/message';
import HMSPeer from './interfaces/hms-peer';
import HMSTransport from './transport';
import ITransportObserver from './transport/ITransportObserver';
import HMSUpdateListener, { HMSPeerUpdate, HMSTrackUpdate } from './interfaces/update-listener';
import log from 'loglevel';
import { getRoomId } from './utils/room';
import { getNotificationMethod, HMSNotificationMethod } from './sdk/models/enums/HMSNotificationMethod';
import { getNotification, HMSNotifications, Peer as PeerNotification } from './sdk/models/HMSNotifications';
import NotificationManager from './sdk/NotificationManager';
import HMSTrack from './media/tracks/HMSTrack';
import { HMSTrackType } from './media/tracks/HMSTrackType';
import HMSException from './error/HMSException';
import { HMSTrackSettingsBuilder } from './media/settings/HMSTrackSettings';
// import { HMSTrackType } from './media/tracks/HMSTrackType';
import HMSRoom from './sdk/models/HMSRoom';
import { v4 as uuidv4 } from 'uuid';
import Peer from './peer';
import { HMSVideoTrackSettingsBuilder } from './media/settings/HMSVideoTrackSettings';
export default class HMSSdk implements HMSInterface {
logLevel: HMSlogLevel = HMSlogLevel.OFF;
analyticsLevel: HMSAnalyticsLevel = HMSAnalyticsLevel.OFF;
transport: HMSTransport;
roomId!: string | null;
localPeer!: HMSPeer;
private TAG: string = 'HMSSdk';
private notificationManager: NotificationManager = new NotificationManager();
private listener!: HMSUpdateListener;
private hmsRoom?: HMSRoom;
private observer: ITransportObserver = {
onNotification: (message: any) => {
const method = getNotificationMethod(message!.method);
// TODO: WRITE CODE FOR THIS
if (method === HMSNotificationMethod.ACTIVE_SPEAKERS) return;
const notification = getNotification(method, message!.params);
this.notificationManager.handleNotification(method, notification);
this.onNotificationHandled(method, notification);
},
onTrackAdd: (track: HMSTrack) => {
const hmsPeer = this.notificationManager.handleOnTrackAdd(track);
hmsPeer
? this.listener.onTrackUpdate(HMSTrackUpdate.TRACK_ADDED, track, hmsPeer)
: log.error(this.TAG, `No Peer found for added track:: ${track}`);
},
onTrackRemove: (track: HMSTrack) => {
const hmsPeer = this.notificationManager.handleOnTrackRemove(track);
hmsPeer
? this.listener.onTrackUpdate(HMSTrackUpdate.TRACK_REMOVED, track, hmsPeer)
: log.error(this.TAG, `No Peer found for added track:: ${track}`);
},
onFailure: (exception: HMSException) => {
this.listener.onError(exception);
},
};
constructor() {
this.transport = new HMSTransport(this.observer);
log.setLevel(log.levels.DEBUG);
}
join(config: HMSConfig, listener: HMSUpdateListener) {
this.listener = listener;
const roomId = getRoomId(config.authToken);
const peerId = uuidv4();
this.localPeer = new Peer({ peerId, name: config.userName, isLocal: true, customerDescription: config.metaData });
this.transport.join(config.authToken, roomId, peerId, { userName: config.userName }).then(() => {
console.log('JOINED!', roomId);
this.roomId = roomId;
});
}
leave() {
if (this.roomId) {
this.localPeer.audioTrack?.nativeTrack.stop();
this.localPeer.videoTrack?.nativeTrack.stop();
this.transport.leave();
this.roomId = null;
}
}
getLocalPeer(): HMSPeer {
return this.localPeer;
}
getPeers(): HMSPeer[] {
return [...this.notificationManager.hmsPeerList, this.localPeer];
}
sendMessage(message: HMSMessage) {
console.log(message);
throw 'Yet to implement';
}
onMessageReceived(cb: HMSMessageListener) {
console.log(cb);
throw 'Yet to implement';
}
async startScreenShare() {
if ((this.localPeer.auxiliaryTracks?.length || 0) > 0) {
throw Error('Cannot share multiple screens');
}
const track = await this.transport.getLocalScreen(new HMSVideoTrackSettingsBuilder().build(), () =>
this.stopScreenShare(),
);
await this.transport.publish([track]);
this.localPeer.auxiliaryTracks = [track];
}
async stopScreenShare() {
// TODO: Right now we assume for now that there is only one aux track -- screen-share
this.transport.unpublish(this.localPeer.auxiliaryTracks!);
this.localPeer.auxiliaryTracks!.length = 0;
}
onNotificationHandled(method: HMSNotificationMethod, notification: HMSNotifications) {
let peer, hmsPeer;
switch (method) {
case HMSNotificationMethod.PEER_JOIN:
peer = notification as PeerNotification;
hmsPeer = this.notificationManager.findPeerByUID(peer.uid);
hmsPeer
? this.listener.onPeerUpdate(HMSPeerUpdate.PEER_JOINED, hmsPeer!)
: log.error(this.TAG, `peer not found in peer-list ${peer}`);
break;
case HMSNotificationMethod.PEER_LEAVE: {
const peer = notification as PeerNotification;
const hmsPeer = new Peer({
peerId: peer.uid,
name: peer.info.userName,
isLocal: false,
customerDescription: peer.info.metadata,
}); //@TODO: There should be a cleaner way
this.listener.onPeerUpdate(HMSPeerUpdate.PEER_LEFT, hmsPeer);
break;
}
case HMSNotificationMethod.PEER_LIST:
// TODO: Move getLocalTracks to immediate after `transportLayer.join`
this.transport.getLocalTracks(new HMSTrackSettingsBuilder().build()).then((hmsTracks) => {
hmsTracks.forEach((hmsTrack) => {
switch (hmsTrack.type) {
case HMSTrackType.AUDIO:
this.localPeer.audioTrack = hmsTrack;
break;
case HMSTrackType.VIDEO:
this.localPeer.videoTrack = hmsTrack;
}
});
this.listener.onJoin(this.createRoom());
this.transport.publish(hmsTracks);
});
break;
case HMSNotificationMethod.STREAM_ADD: // TODO: Write code for this
return;
case HMSNotificationMethod.ACTIVE_SPEAKERS: // TODO: Write code for this
return;
}
}
createRoom() {
const hmsPeerList = this.getPeers();
this.hmsRoom = new HMSRoom(this.localPeer.peerId, '', hmsPeerList);
return this.hmsRoom;
}
}
export * from './sdk';
export * from './media/tracks';
export * from './interfaces/update-listener';

@@ -30,4 +30,4 @@ import HMSConfig from './config';

onMessageReceived(callback: HMSMessageListener): void;
startScreenShare(): void;
startScreenShare(onStop: () => void): void;
stopScreenShare(): void;
}

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