@testrtc/watchrtc-sdk
Advanced tools
Comparing version 1.30.0 to 1.30.1
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.watchRTC=n():e.watchRTC=n()}(self,(function(){return(e={607:(e,n,t)=>{"use strict";n.xt=n.Zt=n.UN=n.IO=n.zl=n.v6=n.S1=void 0,t(699);var o=t(231);n.S1=function(e){o.initSDK(e,["","webkit","moz"])},n.v6=function(e){o.setConfig(e)},n.zl=function(e){},n.IO=function(e,n){o.setUserRating(e,n)},n.UN=function(e){o.addKeys(e)},n.Zt=function(){o.disableDataCollection()},n.xt=function(){o.enableDataCollection()},n.default={init:n.S1,addTags:n.zl,setUserRating:n.IO,addKeys:n.UN,setConfig:n.v6,disableDataCollection:n.Zt,enableDataCollection:n.xt}},231:function(e,n,t){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)},r=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0}),n.enableDataCollection=n.disableDataCollection=n.addKeys=n.setUserRating=n.setConfig=n.initSDK=void 0;var i,a,c=t(85),l=t(911),s=t(593),d=t(412),u=!!window.mozRTCPeerConnection,f=!!window.RTCIceGatherer,p=(!u&&window.RTCPeerConnection&&window.navigator.webkitGetUserMedia,{}),g={rtcRoomId:void 0,rtcPeerId:void 0,projectId:void 0},h=null,v=null,m=null,y=0,b=!1,w=function(e){var n;if(void 0===e&&(e=!1),(null===(n=null==m?void 0:m.connection)||void 0===n?void 0:n.readyState)===WebSocket.OPEN){if(!s.isRoomIdOrPeerIdChanged(g,h)||!e)return void((null==h?void 0:h.debug)&&console.log.apply(console,r(s.logPrefix("info"),["maybeOpenWebsocketConnection. WS connection already opened"])));(null==h?void 0:h.debug)&&console.log.apply(console,r(s.logPrefix("info"),["maybeOpenWebsocketConnection. Closing WS connection"])),null==m||m.close()}var t=s.countOfValidConnections(p);if(t>0&&!b){var c=s.validateConfig(h),l=Object.keys(p)[t-1];if(c){var u=!!h.rtcToken,v=s.getConnectionData("ws",u?h.rtcToken:h.rtcApiKey,h.proxyUrl||h.wsUrl);b=!0,y=Date.now(),null==m||m.connect(v.url+"?"+(u?"token":"apiKey")+"="+v.key+"×tamp="+Date.now(),(function(e){g.rtcRoomId=h.rtcRoomId,g.rtcPeerId=h.rtcPeerId,g.projectId=e.projectId,b=!1,console.info.apply(console,r(s.logPrefix("info"),["Connection established. watchRTCConnectionId: "+e.connectionId+" sdkVersion:"+d.default])),i("watchrtc",l,o(o(o({},h),e),{sdkVersion:d.default}));var n=Date.now();s.getHardwareInfo().then((function(e){var t=Date.now()-n;t<=5e4?i("hardware",l,e):(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("info"),["Could not get hardware information. timeout: "+t+"ms"]))})).catch((function(e){(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("error"),["Could not get hardware information. "+e.message,{err:e.stack}]))})),f||(window.clearInterval(a),a=window.setInterval((function(){0===s.countOfValidConnections(p)?y&&y+2e4<Date.now()&&(window.clearInterval(a),null==m||m.close(),console.info.apply(console,r(s.logPrefix("info"),["Last connection closed. watchRTCConnectionId: "+e.connectionId+" sdkVersion: "+d.default]))):(y=Date.now(),Object.values(p).forEach((function(e){"closed"!==e.pc.signalingState&&C(e)})))}),e.interval))}),(function(){b=!1,y=0}))}else b=!1}},C=function(e){if(e){var n=e.id,t=e.pc,o=e.prev;t.getStats(null).then((function(t){var r=s.map2obj(t),a=JSON.parse(JSON.stringify(r)),c=s.deltaCompression(o,r);null!==(null==c?void 0:c.timestamp)&&(null==c?void 0:c.timestamp)!==-1/0&&i("getstats",n,s.deltaCompression(e.prev,r)),e.prev=a}))}};n.initSDK=function(e,n){if(!window.watchRTCInitialized){window.watchRTCInitialized=!0;var t=0;if(m=new c.default({debug:null==e?void 0:e.debug}),v=new l.default({debug:null==e?void 0:e.debug}),h=e,i=m.trace,n.forEach((function(e){if(window[e+"RTCPeerConnection"]&&("webkit"!==e||!f)){var n=window[e+"RTCPeerConnection"],a=function(e,a){(null==e?void 0:e.watchrtc)&&(h=o(o({},h),e.watchrtc)),(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("info"),["new RTCPeerConnection called.",{config:e,constraints:a}]));var c=new n(e,a),l="PC_"+t++;return c.__rtcStatsId=l,p[l]={id:l,pc:c,validConnection:!1},e||(e={nullConfig:!0}),((e=JSON.parse(JSON.stringify(e)))&&e.iceServers||[]).forEach((function(e){delete e.credential})),(null==e?void 0:e.watchrtc)&&delete e.watchrtc,e.browserType=u?"moz":f?"edge":"webkit",i("create",l,e),a&&i("constraints",l,a),c.addEventListener("icecandidate",(function(e){i("onicecandidate",l,e.candidate)})),c.addEventListener("addstream",(function(e){i("onaddstream",l,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),c.addEventListener("track",(function(e){i("ontrack",l,e.track.kind+":"+e.track.id+" "+e.streams.map((function(e){return"stream:"+e.id})))})),c.addEventListener("removestream",(function(e){i("onremovestream",l,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),c.addEventListener("signalingstatechange",(function(){p[l]&&!p[l].validConnection&&(p[l].validConnection=!0,setTimeout((function(){w(!0)}),5e3)),i("onsignalingstatechange",l,c.signalingState)})),c.addEventListener("iceconnectionstatechange",(function(){i("oniceconnectionstatechange",l,c.iceConnectionState)})),c.addEventListener("icegatheringstatechange",(function(){i("onicegatheringstatechange",l,c.iceGatheringState)})),c.addEventListener("connectionstatechange",(function(){i("onconnectionstatechange",l,c.connectionState)})),c.addEventListener("negotiationneeded",(function(){i("onnegotiationneeded",l,void 0)})),c.addEventListener("datachannel",(function(e){i("ondatachannel",l,[e.channel.id,e.channel.label])})),f||c.addEventListener("iceconnectionstatechange",(function(){"connected"===c.iceConnectionState&&C(p[l])})),c};["createDataChannel"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){return i(e,this.__rtcStatsId,arguments),t.apply(this,arguments)})})),["close"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){return i(e,this.__rtcStatsId,arguments),delete p[this.__rtcStatsId],t.apply(this,arguments)})})),["addStream","removeStream"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0],o=n.getTracks().map((function(e){return e.kind+":"+e.id})).join(",");return i(e,this.__rtcStatsId,n.id+" "+o),t.apply(this,arguments)})})),["addTrack"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0],o=[].slice.call(arguments,1);return i(e,this.__rtcStatsId,n.kind+":"+n.id+" "+(o.map((function(e){return"stream:"+e.id})).join(";")||"-")),t.apply(this,arguments)})})),["removeTrack"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0].track;return i(e,this.__rtcStatsId,n?n.kind+":"+n.id:"null"),t.apply(this,arguments)})})),["createOffer","createAnswer"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n,o=this.__rtcStatsId,r=arguments;return 1===arguments.length&&"object"==typeof arguments[0]?n=arguments[0]:3===arguments.length&&"object"==typeof arguments[2]&&(n=arguments[2]),i(e,this.__rtcStatsId,n),t.apply(this,n?[n]:void 0).then((function(n){if(i(e+"OnSuccess",o,n),!(r.length>0&&"function"==typeof r[0]))return n;r[0].apply(null,[n])}),(function(n){if(i(e+"OnFailure",o,n.toString()),!(r.length>1&&"function"==typeof r[1]))throw n;r[1].apply(null,[n])}))})})),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=this.__rtcStatsId,o=arguments;return i(e,this.__rtcStatsId,o[0]),t.apply(this,[o[0]]).then((function(){i(e+"OnSuccess",n,void 0),o.length>=2&&"function"==typeof o[1]&&o[1].apply(null,[])}),(function(t){if(i(e+"OnFailure",n,t.toString()),!(o.length>=3&&"function"==typeof o[2]))throw t;o[2].apply(null,[t])}))})})),n.generateCertificate&&Object.defineProperty(a,"generateCertificate",{get:function(){return arguments.length?n.generateCertificate.apply(null,arguments):n.generateCertificate}}),window[e+"RTCPeerConnection"]=a,window[e+"RTCPeerConnection"].prototype=n.prototype}})),n.forEach((function(e){var n=e+(e.length?"GetUserMedia":"getUserMedia");if(navigator[n]){var t=navigator[n].bind(navigator);navigator[n]=function(){i("getUserMedia",null,arguments[0]);var e=arguments[1],n=arguments[2];t(arguments[0],(function(n){i("getUserMediaOnSuccess",null,s.dumpStream(n)),e&&e(n)}),(function(e){i("getUserMediaOnFailure",null,e.name),n&&n(e)}))}.bind(navigator)}})),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){var a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(){return i("navigator.mediaDevices.getUserMedia",null,arguments[0]),a.apply(navigator.mediaDevices,arguments).then((function(e){return i("navigator.mediaDevices.getUserMediaOnSuccess",null,s.dumpStream(e)),e}),(function(e){return i("navigator.mediaDevices.getUserMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){var d=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getDisplayMedia=function(){return i("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),d.apply(navigator.mediaDevices,arguments).then((function(e){return i("navigator.mediaDevices.getDisplayMediaOnSuccess",null,s.dumpStream(e)),e}),(function(e){return i("navigator.mediaDevices.getDisplayMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}}},n.setConfig=function(e){window.watchRTCInitialized?(void 0!==e.debug&&e.debug!==h.debug&&(null==m||m.toggleDebug(e.debug)),h=o(o({},h),e),w()):console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.setUserRating=function(e,n){var t;if(window.watchRTCInitialized){if(s.validateRating(e)){var o=["userRating",null,{rating:e,ratingComment:n}];(null===(t=null==m?void 0:m.connection)||void 0===t?void 0:t.readyState)===WebSocket.OPEN?i.apply(void 0,o):S.apply(void 0,o)}}else console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.addKeys=function(e){var n;if(window.watchRTCInitialized){var t=["keys",null,e];(null===(n=null==m?void 0:m.connection)||void 0===n?void 0:n.readyState)===WebSocket.OPEN?i.apply(void 0,t):S.apply(void 0,t)}else console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.disableDataCollection=function(){window.watchRTCInitialized?null==m||m.disableDataCollection():console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.enableDataCollection=function(){window.watchRTCInitialized?null==m||m.enableDataCollection():console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))};var S=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(g.rtcRoomId&&g.rtcPeerId&&g.projectId){var t=s.getConnectionData("http",h.rtcApiKey);null==v||v.trace.apply(v,r([t.url+"/trace",g.projectId,g.rtcRoomId,g.rtcPeerId],e))}else console.log.apply(console,r(s.logPrefix("info"),["Cannot do http trace before connection established"]))}},699:(e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0})},593:function(e,n,t){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)},r=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function c(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}l((o=o.apply(e,n||[])).next())}))},i=this&&this.__generator||function(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},a=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0}),n.getHardwareInfo=n.validateRating=n.isRoomIdOrPeerIdChanged=n.countOfValidConnections=n.validateConfig=n.getConnectionData=n.dumpStream=n.map2obj=n.mangleChromeStats=n.deltaCompression=n.logPrefix=void 0;var c=t(240);n.logPrefix=function(e){return void 0===e&&(e="info"),"error"===e?["%cwatchRTC %cERROR","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;","background: red; color: white; padding: 2px 0.5em; border-radius: 0.5em;"]:["%cwatchRTC","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;"]},n.deltaCompression=function(e,n){e=e||{},n=n||{},n=JSON.parse(JSON.stringify(n)),Object.keys(n).forEach((function(t){var o=n[t];delete o.id,e[t]&&Object.keys(o).forEach((function(r){o[r]===e[t][r]&&delete n[t][r],(0===Object.keys(o).length||1===Object.keys(o).length&&o.timestamp)&&delete n[t]}))}));var t=-1/0;return Object.keys(n).forEach((function(e){var o=n[e];o.timestamp>t&&(t=o.timestamp)})),Object.keys(n).forEach((function(e){var o=n[e];o.timestamp===t&&(o.timestamp=0)})),n.timestamp=t,n},n.mangleChromeStats=function(e,n){var t={};return n.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp.getTime(),type:e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t},n.map2obj=function(e){if(!e.entries)return e;var n={};return e.forEach((function(e,t){n[t]=e})),n},n.dumpStream=function(e){return{id:e.id,tracks:e.getTracks().map((function(e){return{id:e.id,kind:e.kind,label:e.label,enabled:e.enabled,muted:e.muted,readyState:e.readyState}}))}},n.getConnectionData=function(e,n,t){var o=("ws"==e?"ws":"http")+"://localhost:9101",r=("ws"==e?"wss":"https")+"://watchrtc-staging2.testrtc.com",i=("ws"==e?"wss":"https")+"://watchrtc.testrtc.com",a=n.split(":");return-1!==n.indexOf("local")?{url:t||o,key:a[1]}:-1!==n.indexOf("staging")?{url:t||r,key:a[1]}:-1!==n.indexOf("production")?{url:t||i,key:a[1]}:{url:t||i,key:a[0]}},n.validateConfig=function(e){return!(null==e?void 0:e.rtcApiKey)&&(null==e?void 0:e.debug)?(console.info.apply(console,a(n.logPrefix("error"),["config.rtcApiKey or config.rtcToken need to be provided."])),!1):!(!(null==e?void 0:e.rtcRoomId)||!(null==e?void 0:e.rtcPeerId))||((null==e?void 0:e.debug)&&console.info.apply(console,a(n.logPrefix("info"),["rtcRoomId or rtcPeerId is empty."])),!1)},n.countOfValidConnections=function(e){return Object.keys(e).filter((function(n){return e[n].validConnection})).length},n.isRoomIdOrPeerIdChanged=function(e,t){var o=!1;return t.rtcRoomId&&e.rtcRoomId&&e.rtcRoomId!==t.rtcRoomId&&(o=!0),t.rtcPeerId&&e.rtcPeerId&&e.rtcPeerId!==t.rtcPeerId&&(o=!0),o&&t.debug&&console.log.apply(console,a(n.logPrefix("info"),["maybeOpenWebsocketConnection. rtcRoomId or rtcPeerId has been changed",{old:{rtcRoomId:e.rtcRoomId,rtcPeerId:e.rtcPeerId},new:{rtcRoomId:t.rtcRoomId,rtcPeerId:t.rtcPeerId}}])),o},n.validateRating=function(e){return e?!("number"!=typeof e||e<1||e>5)||(console.info.apply(console,a(n.logPrefix("error"),["rating parameter should be number from 1 to 5"])),!1):(console.info.apply(console,a(n.logPrefix("error"),["rating parameter is required"])),!1)},n.getHardwareInfo=function(){return r(void 0,void 0,void 0,(function(){function e(e){return(Math.round(100*e)/100).toFixed(2)}var n,t,r;return i(this,(function(i){switch(i.label){case 0:return[4,c.getGPUTier()];case 1:return n=i.sent(),t=o(o({},n),{cores_count:window.navigator.hardwareConcurrency}),(r=window.performance.memory)&&(t.jsHeapSizeLimit=e(r.jsHeapSizeLimit/1048576),t.totalJSHeapSize=e(r.totalJSHeapSize/1048576),t.usedJSHeapSize=e(r.usedJSHeapSize/1048576)),[2,t]}}))}))}},412:(e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default="1.30.0"},911:function(e,n,t){"use strict";var o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0});var r=t(593),i=function(){function e(n){this.debug=!1,e._instance?console.info.apply(console,o(r.logPrefix("info"),["WatchRTCSocket instance already created"])):(e._instance=this,this.debug=!!n.debug)}return e.prototype.trace=function(e,n,t,i){for(var a=[],c=4;c<arguments.length;c++)a[c-4]=arguments[c];var l=Array.prototype.slice.call(a);l.push(Date.now()),l[1]instanceof RTCPeerConnection&&(l[1]=l[1].__rtcStatsId);var s=fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:a,projectId:n,rtcRoomId:t,rtcPeerId:i})});s.then().catch((function(e){return console.log.apply(console,o(r.logPrefix("error"),[e.message,{err:e.stack}]))}))},e}();n.default=i},85:function(e,n,t){"use strict";var o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0});var r=t(593),i=t(354),a=function(){function e(n){this.connection=null,this.buffer=[],this.sendInterval=1,this.onClose=function(){},this.debug=!1,this.dataCollection=!0,e._instance?console.info.apply(console,o(r.logPrefix("info"),["WatchRTCSocket instance already created"])):(e._instance=this,this.debug=!!n.debug)}return e.prototype.connect=function(n,t,i){e._instance.connection&&e._instance.connection.close();var a=e._instance;e._instance.connection=new WebSocket(n,"2.0"),e._instance.connection.onopen=function(e){},e._instance.connection.onclose=function(e){},e._instance.connection.onmessage=function(n){var c;try{var l=JSON.parse(n.data);l.error?(null===(c=null==a?void 0:a.connection)||void 0===c||c.close(),a.connection=null,console.info.apply(console,o(r.logPrefix("error"),["\n"+l.error])),i(l.error)):(l.sendInterval&&(e._instance.sendInterval=l.sendInterval),t(l))}catch(e){console.info.apply(console,o(r.logPrefix("error"),[{err:e.stack}])),i(e.message)}},e._instance.connection.onerror=function(e){console.info.apply(console,o(r.logPrefix("error"),["\n",e])),i(e)}},e.prototype.trace=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var a=Array.prototype.slice.call(n);if(a.push(Date.now()),a[1]instanceof RTCPeerConnection&&(a[1]=a[1].__rtcStatsId),e._instance.dataCollection)if(e._instance.connection){if(e._instance.connection.readyState===WebSocket.OPEN&&(e._instance.buffer.push(a),e._instance.buffer.length>=e._instance.sendInterval)){var c=JSON.stringify(e._instance.buffer),l=i.compressToEncodedURIComponent(c);e._instance.debug&&(console.log.apply(console,o(r.logPrefix("info"),["lines: "+c.length])),console.log.apply(console,o(r.logPrefix("info"),["compressedMessage: "+l.length]))),e._instance.buffer=[],e._instance.connection.send(l)}}else{if(e._instance.buffer.length>1e3)return;e._instance.buffer.push(a)}},e.prototype.close=function(){e._instance.buffer=[],e._instance.connection&&(e._instance.connection.close(),e._instance.onClose(),e._instance.connection=null)},e.prototype.disableDataCollection=function(){e._instance.debug&&console.log.apply(console,o(r.logPrefix("info"),["Data collection disabled."])),e._instance.dataCollection=!1},e.prototype.enableDataCollection=function(){e._instance.debug&&console.log.apply(console,o(r.logPrefix("info"),["Data collection enabled."])),e._instance.dataCollection=!0},e.prototype.toggleDebug=function(n){e._instance.debug=n},e}();n.default=a},240:function(e,n){!function(e){"use strict";function n(e,n,t,o){return new(t||(t=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function c(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}l((o=o.apply(e,n||[])).next())}))}function t(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","radeon r9 200","sgx 543","sgx543"],r=function(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"")},i="undefined"==typeof window,a=function(){if(!i){var e=window.navigator,n=e.userAgent,t=e.platform,o=e.maxTouchPoints,r=/(iphone|ipod|ipad)/i.test(n),a="iPad"===t||"MacIntel"===t&&o>0&&!window.MSStream;return{isIpad:a,isMobile:/android/i.test(n)||r||a,isSafari12:/Version\/12.+Safari/.test(n)}}}(),c=[],l=[],s=function(e,n){if(e===n)return 0;var t=e;e.length>n.length&&(e=n,n=t);for(var o=e.length,r=n.length;o>0&&e.charCodeAt(~-o)===n.charCodeAt(~-r);)o--,r--;for(var i,a=0;a<o&&e.charCodeAt(a)===n.charCodeAt(a);)a++;if(r-=a,0==(o-=a))return r;for(var s,d,u=0,f=0,p=0;f<o;)l[f]=e.charCodeAt(a+f),c[f]=++f;for(;p<r;)for(i=n.charCodeAt(a+p),s=p++,u=p,f=0;f<o;f++)d=i===l[f]?s:s+1,s=c[f],u=c[f]=s>u?d>u?u+1:d:d>s?s+1:d;return u};e.getGPUTier=function(e){var c=void 0===e?{}:e,l=c.mobileTiers,d=void 0===l?[0,15,30,60]:l,u=c.desktopTiers,f=void 0===u?[0,15,30,60]:u,p=c.override,g=void 0===p?{}:p,h=c.glContext,v=c.failIfMajorPerformanceCaveat,m=void 0!==v&&v,y=c.benchmarksURL,b=void 0===y?"https://unpkg.com/detect-gpu@3.1.14/dist/benchmarks":y;return n(void 0,void 0,void 0,(function(){var e,c,l,u,p,v,y,w,C,S,_,P,I,x,k,O,D,R,A,T,E,j,M,U,L,z;return t(this,(function(K){switch(K.label){case 0:if(e={},i)return[2,{tier:0,type:"SSR"}];if(c=g.isIpad,l=void 0===c?!!(null==a?void 0:a.isIpad):c,u=g.isMobile,p=void 0===u?!!(null==a?void 0:a.isMobile):u,v=g.screenSize,y=void 0===v?window.screen:v,w=g.loadBenchmarks,C=void 0===w?function(e){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,fetch(b+"/"+e).then((function(e){return e.json()}))];case 1:return(n=t.sent()).shift(),[2,n]}}))}))}:w,S=g.renderer,_=function(e){for(var n=0,t=p?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","amd","radeon","nvidia","geforce"];n<t.length;n++){var o=t[n];if(e.includes(o))return o}},P=function(o){return n(void 0,void 0,void 0,(function(){var n,r,i,a,c,d,u,f,g,h,v,m,b,w,S,P,I,x,k,O,D,R,A,T,E;return t(this,(function(t){switch(t.label){case 0:if(!(n=_(o)))return[2];i=e[r=(p?"m":"d")+"-"+n+".json"]=e[r]||C(r),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,i];case 2:return a=t.sent(),[3,4];case 3:return t.sent(),[2];case 4:if(c=function(e){var n,t=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(n=null==t?void 0:t.join("").replace(/\W|amd/g,""))&&void 0!==n?n:""}(o),d="apple"===n,(u=a.filter((function(e){return e[1]===c}))).length||(u=a.filter((function(e){return e[0].includes(o)}))),0===(f=u.length))return[2];for(g=f>1?u.map((function(e){return[e,s(o,e[0])]})).sort((function(e,n){return e[1]-n[1]}))[0][0]:u[0],h=g[0],v=g[3],m=Number.MAX_VALUE,w=window.devicePixelRatio,S=y.width*w*(y.height*w),d&&p&&(v=v.filter((function(e){var n,t=e[3];return(null!==(n=null==t?void 0:t.indexOf(l?"ipad":"iphone"))&&void 0!==n?n:-1)>-1}))),P=0,I=v;P<I.length;P++)x=I[P],k=x[0],O=x[1],D=k*O,(R=Math.abs(S-D))<m&&(m=R,b=x);return b?(T=(A=b)[2],E=A[3],[2,[m,T,h,E]]):[2]}}))}))},I=function(e,n,t,o,r){return{device:r,fps:o,gpu:t,isMobile:p,tier:e,type:n}},k="",S)S=r(S),x=[S];else{if(!(O=h||function(e,n){void 0===n&&(n=!1);var t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:n,powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;var o=window.document.createElement("canvas"),r=o.getContext("webgl",t)||o.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==a?void 0:a.isSafari12,m)))return[2,I(0,"WEBGL_UNSUPPORTED")];if((D=O.getExtension("WEBGL_debug_renderer_info"))&&(S=O.getParameter(D.UNMASKED_RENDERER_WEBGL)),!S)return[2,I(1,"FALLBACK")];k=S,S=r(S),x=function(e,n,t){return"apple gpu"===n?function(e,n,t){var o=[n];if(t){var r=e.createShader(35633),i=e.createShader(35632),c=e.createProgram();if(i&&r&&c){e.shaderSource(r,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(i,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(r),e.compileShader(i),e.attachShader(c,r),e.attachShader(c,i),e.linkProgram(c),e.detachShader(c,r),e.detachShader(c,i),e.deleteShader(r),e.deleteShader(i),e.useProgram(c);var l=e.createBuffer();e.bindBuffer(34962,l),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);var s=e.getAttribLocation(c,"aPosition");e.vertexAttribPointer(s,3,5126,!1,0,0),e.enableVertexAttribArray(s),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);var d=new Uint8Array(4);e.readPixels(0,0,1,1,6408,5121,d),e.deleteProgram(c),e.deleteBuffer(l),o={801621810:(null==a?void 0:a.isIpad)?["apple a12x gpu"]:["apple a11 gpu","apple a12 gpu","apple a13 gpu","apple a14 gpu"],8016218135:(null==a?void 0:a.isIpad)?["apple a9x gpu","apple a10 gpu","apple a10x gpu"]:["apple a9 gpu","apple a10 gpu"]}[d.join("")]||o}}return o}(e,n,t):[n]}(O,S,p)}return[4,Promise.all(x.map(P))];case 1:if(!(R=K.sent().filter((function(e){return!!e}))).length)return[2,(A=o.find((function(e){return S.includes(e)})))?I(0,"BLOCKLISTED",A):I(1,"FALLBACK",S+" ("+k+")")];if(T=R.sort((function(e,n){var t=e[0],o=void 0===t?Number.MAX_VALUE:t,r=n[0];return o-(void 0===r?Number.MAX_VALUE:r)}))[0],E=T[1],j=T[2],M=T[3],-1===E)return[2,I(0,"BLOCKLISTED",j,E,M)];for(U=p?d:f,L=0,z=0;z<U.length;z++)E>=U[z]&&(L=z);return[2,I(L,"BENCHMARK",j,E,M)]}}))}))},Object.defineProperty(e,"__esModule",{value:!0})}(n)},354:(e,n,t)=>{var o,r=function(){function e(e,n){if(!r[e]){r[e]={};for(var t=0;t<e.length;t++)r[e][e.charAt(t)]=t}return r[e][n]}var n=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={},i={compressToBase64:function(e){if(null==e)return"";var n=i._compress(e,6,(function(e){return t.charAt(e)}));switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(n){return null==n?"":""==n?null:i._decompress(n.length,32,(function(o){return e(t,n.charAt(o))}))},compressToUTF16:function(e){return null==e?"":i._compress(e,15,(function(e){return n(e+32)}))+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:i._decompress(e.length,16384,(function(n){return e.charCodeAt(n)-32}))},compressToUint8Array:function(e){for(var n=i.compress(e),t=new Uint8Array(2*n.length),o=0,r=n.length;r>o;o++){var a=n.charCodeAt(o);t[2*o]=a>>>8,t[2*o+1]=a%256}return t},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var t=new Array(e.length/2),o=0,r=t.length;r>o;o++)t[o]=256*e[2*o]+e[2*o+1];var a=[];return t.forEach((function(e){a.push(n(e))})),i.decompress(a.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":i._compress(e,6,(function(e){return o.charAt(e)}))},decompressFromEncodedURIComponent:function(n){return null==n?"":""==n?null:(n=n.replace(/ /g,"+"),i._decompress(n.length,32,(function(t){return e(o,n.charAt(t))})))},compress:function(e){return i._compress(e,16,(function(e){return n(e)}))},_compress:function(e,n,t){if(null==e)return"";var o,r,i,a={},c={},l="",s="",d="",u=2,f=3,p=2,g=[],h=0,v=0;for(i=0;i<e.length;i+=1)if(l=e.charAt(i),Object.prototype.hasOwnProperty.call(a,l)||(a[l]=f++,c[l]=!0),s=d+l,Object.prototype.hasOwnProperty.call(a,s))d=s;else{if(Object.prototype.hasOwnProperty.call(c,d)){if(d.charCodeAt(0)<256){for(o=0;p>o;o++)h<<=1,v==n-1?(v=0,g.push(t(h)),h=0):v++;for(r=d.charCodeAt(0),o=0;8>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}else{for(r=1,o=0;p>o;o++)h=h<<1|r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r=0;for(r=d.charCodeAt(0),o=0;16>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}0==--u&&(u=Math.pow(2,p),p++),delete c[d]}else for(r=a[d],o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;0==--u&&(u=Math.pow(2,p),p++),a[s]=f++,d=String(l)}if(""!==d){if(Object.prototype.hasOwnProperty.call(c,d)){if(d.charCodeAt(0)<256){for(o=0;p>o;o++)h<<=1,v==n-1?(v=0,g.push(t(h)),h=0):v++;for(r=d.charCodeAt(0),o=0;8>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}else{for(r=1,o=0;p>o;o++)h=h<<1|r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r=0;for(r=d.charCodeAt(0),o=0;16>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}0==--u&&(u=Math.pow(2,p),p++),delete c[d]}else for(r=a[d],o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;0==--u&&(u=Math.pow(2,p),p++)}for(r=2,o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;for(;;){if(h<<=1,v==n-1){g.push(t(h));break}v++}return g.join("")},decompress:function(e){return null==e?"":""==e?null:i._decompress(e.length,32768,(function(n){return e.charCodeAt(n)}))},_decompress:function(e,t,o){var r,i,a,c,l,s,d,u=[],f=4,p=4,g=3,h="",v=[],m={val:o(0),position:t,index:1};for(r=0;3>r;r+=1)u[r]=r;for(a=0,l=Math.pow(2,2),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,l=Math.pow(2,8),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;d=n(a);break;case 1:for(a=0,l=Math.pow(2,16),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;d=n(a);break;case 2:return""}for(u[3]=d,i=d,v.push(d);;){if(m.index>e)return"";for(a=0,l=Math.pow(2,g),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;switch(d=a){case 0:for(a=0,l=Math.pow(2,8),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;u[p++]=n(a),d=p-1,f--;break;case 1:for(a=0,l=Math.pow(2,16),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;u[p++]=n(a),d=p-1,f--;break;case 2:return v.join("")}if(0==f&&(f=Math.pow(2,g),g++),u[d])h=u[d];else{if(d!==p)return null;h=i+i.charAt(0)}v.push(h),u[p++]=i+h.charAt(0),i=h,0==--f&&(f=Math.pow(2,g),g++)}}};return i}();void 0===(o=function(){return r}.call(n,t,n,e))||(e.exports=o)}},n={},function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{}};return e[o].call(r.exports,r,r.exports,t),r.exports}(607)).default;var e,n})); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.watchRTC=n():e.watchRTC=n()}(self,(function(){return(e={607:(e,n,t)=>{"use strict";n.xt=n.Zt=n.UN=n.IO=n.zl=n.v6=n.S1=void 0,t(699);var o=t(231);n.S1=function(e){o.initSDK(e,["","webkit","moz"])},n.v6=function(e){o.setConfig(e)},n.zl=function(e){},n.IO=function(e,n){o.setUserRating(e,n)},n.UN=function(e){o.addKeys(e)},n.Zt=function(){o.disableDataCollection()},n.xt=function(){o.enableDataCollection()},n.default={init:n.S1,addTags:n.zl,setUserRating:n.IO,addKeys:n.UN,setConfig:n.v6,disableDataCollection:n.Zt,enableDataCollection:n.xt}},231:function(e,n,t){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)},r=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0}),n.enableDataCollection=n.disableDataCollection=n.addKeys=n.setUserRating=n.setConfig=n.initSDK=void 0;var i,a,c=t(85),l=t(911),s=t(593),d=t(412),u=!!window.mozRTCPeerConnection,f=!!window.RTCIceGatherer,p=(!u&&window.RTCPeerConnection&&window.navigator.webkitGetUserMedia,{}),g={rtcRoomId:void 0,rtcPeerId:void 0,projectId:void 0},h=null,v=null,m=null,y=0,b=!1,w=function(e){var n;if(void 0===e&&(e=!1),(null===(n=null==m?void 0:m.connection)||void 0===n?void 0:n.readyState)===WebSocket.OPEN){if(!s.isRoomIdOrPeerIdChanged(g,h)||!e)return void((null==h?void 0:h.debug)&&console.log.apply(console,r(s.logPrefix("info"),["maybeOpenWebsocketConnection. WS connection already opened"])));(null==h?void 0:h.debug)&&console.log.apply(console,r(s.logPrefix("info"),["maybeOpenWebsocketConnection. Closing WS connection"])),null==m||m.close()}var t=s.countOfValidConnections(p);if(t>0&&!b){var c=s.validateConfig(h),l=Object.keys(p)[t-1];if(c){var u=!!h.rtcToken,v=s.getConnectionData("ws",u?h.rtcToken:h.rtcApiKey,h.proxyUrl||h.wsUrl);b=!0,y=Date.now(),null==m||m.connect(v.url+"?"+(u?"token":"apiKey")+"="+v.key+"×tamp="+Date.now(),(function(e){g.rtcRoomId=h.rtcRoomId,g.rtcPeerId=h.rtcPeerId,g.projectId=e.projectId,b=!1,console.info.apply(console,r(s.logPrefix("info"),["Connection established. watchRTCConnectionId: "+e.connectionId+" sdkVersion:"+d.default])),i("watchrtc",l,o(o(o({},h),e),{sdkVersion:d.default}));var n=Date.now();s.getHardwareInfo().then((function(e){var t=Date.now()-n;t<=5e4?i("hardware",l,e):(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("info"),["Could not get hardware information. timeout: "+t+"ms"]))})).catch((function(e){(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("error"),["Could not get hardware information. "+e.message,{err:e.stack}]))})),f||(window.clearInterval(a),a=window.setInterval((function(){0===s.countOfValidConnections(p)?y&&y+2e4<Date.now()&&(window.clearInterval(a),null==m||m.close(),console.info.apply(console,r(s.logPrefix("info"),["Last connection closed. watchRTCConnectionId: "+e.connectionId+" sdkVersion: "+d.default]))):(y=Date.now(),Object.values(p).forEach((function(e){"closed"!==e.pc.signalingState&&C(e)})))}),e.interval))}),(function(){b=!1,y=0}))}else b=!1}},C=function(e){if(e){var n=e.id,t=e.pc,o=e.prev;t.getStats(null).then((function(t){var r=s.map2obj(t),a=JSON.parse(JSON.stringify(r)),c=s.deltaCompression(o,r);null!==(null==c?void 0:c.timestamp)&&(null==c?void 0:c.timestamp)!==-1/0&&i("getstats",n,s.deltaCompression(e.prev,r)),e.prev=a}))}};n.initSDK=function(e,n){if(!window.watchRTCInitialized){window.watchRTCInitialized=!0;var t=0;if(m=new c.default({debug:null==e?void 0:e.debug}),v=new l.default({debug:null==e?void 0:e.debug}),h=e,i=m.trace,n.forEach((function(e){if(window[e+"RTCPeerConnection"]&&("webkit"!==e||!f)){var n=window[e+"RTCPeerConnection"],a=function(e,a){(null==e?void 0:e.watchrtc)&&(h=o(o({},h),e.watchrtc)),(null==h?void 0:h.debug)&&console.info.apply(console,r(s.logPrefix("info"),["new RTCPeerConnection called.",{config:e,constraints:a}]));var c=new n(e,a),l="PC_"+t++;return c.__rtcStatsId=l,p[l]={id:l,pc:c,validConnection:!1},e||(e={nullConfig:!0}),((e=JSON.parse(JSON.stringify(e)))&&e.iceServers||[]).forEach((function(e){delete e.credential})),(null==e?void 0:e.watchrtc)&&delete e.watchrtc,e.browserType=u?"moz":f?"edge":"webkit",i("create",l,e),a&&i("constraints",l,a),c.addEventListener("icecandidate",(function(e){i("onicecandidate",l,e.candidate)})),c.addEventListener("addstream",(function(e){i("onaddstream",l,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),c.addEventListener("track",(function(e){i("ontrack",l,e.track.kind+":"+e.track.id+" "+e.streams.map((function(e){return"stream:"+e.id})))})),c.addEventListener("removestream",(function(e){i("onremovestream",l,e.stream.id+" "+e.stream.getTracks().map((function(e){return e.kind+":"+e.id})))})),c.addEventListener("signalingstatechange",(function(){p[l]&&!p[l].validConnection&&(p[l].validConnection=!0,setTimeout((function(){w(!0)}),5e3)),i("onsignalingstatechange",l,c.signalingState)})),c.addEventListener("iceconnectionstatechange",(function(){i("oniceconnectionstatechange",l,c.iceConnectionState)})),c.addEventListener("icegatheringstatechange",(function(){i("onicegatheringstatechange",l,c.iceGatheringState)})),c.addEventListener("connectionstatechange",(function(){i("onconnectionstatechange",l,c.connectionState)})),c.addEventListener("negotiationneeded",(function(){i("onnegotiationneeded",l,void 0)})),c.addEventListener("datachannel",(function(e){i("ondatachannel",l,[e.channel.id,e.channel.label])})),f||c.addEventListener("iceconnectionstatechange",(function(){"connected"===c.iceConnectionState&&C(p[l])})),c};["createDataChannel"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){return i(e,this.__rtcStatsId,arguments),t.apply(this,arguments)})})),["close"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){return i(e,this.__rtcStatsId,arguments),delete p[this.__rtcStatsId],t.apply(this,arguments)})})),["addStream","removeStream"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0],o=n.getTracks().map((function(e){return e.kind+":"+e.id})).join(",");return i(e,this.__rtcStatsId,n.id+" "+o),t.apply(this,arguments)})})),["addTrack"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0],o=[].slice.call(arguments,1);return i(e,this.__rtcStatsId,n.kind+":"+n.id+" "+(o.map((function(e){return"stream:"+e.id})).join(";")||"-")),t.apply(this,arguments)})})),["removeTrack"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=arguments[0].track;return i(e,this.__rtcStatsId,n?n.kind+":"+n.id:"null"),t.apply(this,arguments)})})),["createOffer","createAnswer"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n,o=this.__rtcStatsId,r=arguments;return 1===arguments.length&&"object"==typeof arguments[0]?n=arguments[0]:3===arguments.length&&"object"==typeof arguments[2]&&(n=arguments[2]),i(e,this.__rtcStatsId,n),t.apply(this,n?[n]:void 0).then((function(n){if(i(e+"OnSuccess",o,n),!(r.length>0&&"function"==typeof r[0]))return n;r[0].apply(null,[n])}),(function(n){if(i(e+"OnFailure",o,n.toString()),!(r.length>1&&"function"==typeof r[1]))throw n;r[1].apply(null,[n])}))})})),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(e){var t=n.prototype[e];t&&(n.prototype[e]=function(){var n=this.__rtcStatsId,o=arguments;return i(e,this.__rtcStatsId,o[0]),t.apply(this,[o[0]]).then((function(){i(e+"OnSuccess",n,void 0),o.length>=2&&"function"==typeof o[1]&&o[1].apply(null,[])}),(function(t){if(i(e+"OnFailure",n,t.toString()),!(o.length>=3&&"function"==typeof o[2]))throw t;o[2].apply(null,[t])}))})})),n.generateCertificate&&Object.defineProperty(a,"generateCertificate",{get:function(){return arguments.length?n.generateCertificate.apply(null,arguments):n.generateCertificate}}),window[e+"RTCPeerConnection"]=a,window[e+"RTCPeerConnection"].prototype=n.prototype}})),n.forEach((function(e){var n=e+(e.length?"GetUserMedia":"getUserMedia");if(navigator[n]){var t=navigator[n].bind(navigator);navigator[n]=function(){i("getUserMedia",null,arguments[0]);var e=arguments[1],n=arguments[2];t(arguments[0],(function(n){i("getUserMediaOnSuccess",null,s.dumpStream(n)),e&&e(n)}),(function(e){i("getUserMediaOnFailure",null,e.name),n&&n(e)}))}.bind(navigator)}})),navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){var a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(){return i("navigator.mediaDevices.getUserMedia",null,arguments[0]),a.apply(navigator.mediaDevices,arguments).then((function(e){return i("navigator.mediaDevices.getUserMediaOnSuccess",null,s.dumpStream(e)),e}),(function(e){return i("navigator.mediaDevices.getUserMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia){var d=navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getDisplayMedia=function(){return i("navigator.mediaDevices.getDisplayMedia",null,arguments[0]),d.apply(navigator.mediaDevices,arguments).then((function(e){return i("navigator.mediaDevices.getDisplayMediaOnSuccess",null,s.dumpStream(e)),e}),(function(e){return i("navigator.mediaDevices.getDisplayMediaOnFailure",null,e.name),Promise.reject(e)}))}.bind(navigator.mediaDevices)}}},n.setConfig=function(e){window.watchRTCInitialized?(void 0!==e.debug&&e.debug!==h.debug&&(null==m||m.toggleDebug(e.debug)),h=o(o({},h),e),w()):console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.setUserRating=function(e,n){var t;if(window.watchRTCInitialized){if(s.validateRating(e)){var o=["userRating",null,{rating:e,ratingComment:n}];(null===(t=null==m?void 0:m.connection)||void 0===t?void 0:t.readyState)===WebSocket.OPEN?i.apply(void 0,o):S.apply(void 0,o)}}else console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.addKeys=function(e){var n;if(window.watchRTCInitialized){var t=["keys",null,e];(null===(n=null==m?void 0:m.connection)||void 0===n?void 0:n.readyState)===WebSocket.OPEN?i.apply(void 0,t):S.apply(void 0,t)}else console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.disableDataCollection=function(){window.watchRTCInitialized?null==m||m.disableDataCollection():console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))},n.enableDataCollection=function(){window.watchRTCInitialized?null==m||m.enableDataCollection():console.info.apply(console,r(s.logPrefix("error"),["SDK is not initialized. Use 'init' function fisrt."]))};var S=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(g.rtcRoomId&&g.rtcPeerId&&g.projectId){var t=s.getConnectionData("http",h.rtcApiKey);null==v||v.trace.apply(v,r([t.url+"/trace",g.projectId,g.rtcRoomId,g.rtcPeerId],e))}else console.log.apply(console,r(s.logPrefix("info"),["Cannot do http trace before connection established"]))}},699:(e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0})},593:function(e,n,t){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)},r=this&&this.__awaiter||function(e,n,t,o){return new(t||(t=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function c(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}l((o=o.apply(e,n||[])).next())}))},i=this&&this.__generator||function(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},a=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0}),n.getHardwareInfo=n.validateRating=n.isRoomIdOrPeerIdChanged=n.countOfValidConnections=n.validateConfig=n.getConnectionData=n.dumpStream=n.map2obj=n.mangleChromeStats=n.deltaCompression=n.logPrefix=void 0;var c=t(240);n.logPrefix=function(e){return void 0===e&&(e="info"),"error"===e?["%cwatchRTC %cERROR","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;","background: red; color: white; padding: 2px 0.5em; border-radius: 0.5em;"]:["%cwatchRTC","background: gold; color: black; padding: 2px 0.5em; border-radius: 0.5em;"]},n.deltaCompression=function(e,n){e=e||{},n=n||{},n=JSON.parse(JSON.stringify(n)),Object.keys(n).forEach((function(t){var o=n[t];delete o.id,e[t]&&Object.keys(o).forEach((function(r){o[r]===e[t][r]&&delete n[t][r],(0===Object.keys(o).length||1===Object.keys(o).length&&o.timestamp)&&delete n[t]}))}));var t=-1/0;return Object.keys(n).forEach((function(e){var o=n[e];o.timestamp>t&&(t=o.timestamp)})),Object.keys(n).forEach((function(e){var o=n[e];o.timestamp===t&&(o.timestamp=0)})),n.timestamp=t,n},n.mangleChromeStats=function(e,n){var t={};return n.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp.getTime(),type:e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t},n.map2obj=function(e){if(!e.entries)return e;var n={};return e.forEach((function(e,t){n[t]=e})),n},n.dumpStream=function(e){return{id:e.id,tracks:e.getTracks().map((function(e){return{id:e.id,kind:e.kind,label:e.label,enabled:e.enabled,muted:e.muted,readyState:e.readyState}}))}},n.getConnectionData=function(e,n,t){var o=("ws"==e?"ws":"http")+"://localhost:9101",r=("ws"==e?"wss":"https")+"://watchrtc-staging2.testrtc.com",i=("ws"==e?"wss":"https")+"://watchrtc.testrtc.com",a=n.split(":");return-1!==n.indexOf("local")?{url:t||o,key:a[1]}:-1!==n.indexOf("staging")?{url:t||r,key:a[1]}:-1!==n.indexOf("production")?{url:t||i,key:a[1]}:{url:t||i,key:a[0]}},n.validateConfig=function(e){return!(null==e?void 0:e.rtcApiKey)&&(null==e?void 0:e.debug)?(console.info.apply(console,a(n.logPrefix("error"),["config.rtcApiKey or config.rtcToken need to be provided."])),!1):!(!(null==e?void 0:e.rtcRoomId)||!(null==e?void 0:e.rtcPeerId))||((null==e?void 0:e.debug)&&console.info.apply(console,a(n.logPrefix("info"),["rtcRoomId or rtcPeerId is empty."])),!1)},n.countOfValidConnections=function(e){return Object.keys(e).filter((function(n){return e[n].validConnection})).length},n.isRoomIdOrPeerIdChanged=function(e,t){var o=!1;return t.rtcRoomId&&e.rtcRoomId&&e.rtcRoomId!==t.rtcRoomId&&(o=!0),t.rtcPeerId&&e.rtcPeerId&&e.rtcPeerId!==t.rtcPeerId&&(o=!0),o&&t.debug&&console.log.apply(console,a(n.logPrefix("info"),["maybeOpenWebsocketConnection. rtcRoomId or rtcPeerId has been changed",{old:{rtcRoomId:e.rtcRoomId,rtcPeerId:e.rtcPeerId},new:{rtcRoomId:t.rtcRoomId,rtcPeerId:t.rtcPeerId}}])),o},n.validateRating=function(e){return e?!("number"!=typeof e||e<1||e>5)||(console.info.apply(console,a(n.logPrefix("error"),["rating parameter should be number from 1 to 5"])),!1):(console.info.apply(console,a(n.logPrefix("error"),["rating parameter is required"])),!1)},n.getHardwareInfo=function(){return r(void 0,void 0,void 0,(function(){function e(e){return(Math.round(100*e)/100).toFixed(2)}var n,t,r;return i(this,(function(i){switch(i.label){case 0:return[4,c.getGPUTier()];case 1:return n=i.sent(),t=o(o({},n),{cores_count:window.navigator.hardwareConcurrency}),(r=window.performance.memory)&&(t.jsHeapSizeLimit=e(r.jsHeapSizeLimit/1048576),t.totalJSHeapSize=e(r.totalJSHeapSize/1048576),t.usedJSHeapSize=e(r.usedJSHeapSize/1048576)),[2,t]}}))}))}},412:(e,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default="1.30.1"},911:function(e,n,t){"use strict";var o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0});var r=t(593),i=function(){function e(n){this.debug=!1,e._instance?console.info.apply(console,o(r.logPrefix("info"),["WatchRTCSocket instance already created"])):(e._instance=this,this.debug=!!n.debug)}return e.prototype.trace=function(e,n,t,i){for(var a=[],c=4;c<arguments.length;c++)a[c-4]=arguments[c];var l=Array.prototype.slice.call(a);l.push(Date.now()),l[1]instanceof RTCPeerConnection&&(l[1]=l[1].__rtcStatsId);var s=fetch(e,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:a,projectId:n,rtcRoomId:t,rtcPeerId:i})});s.then().catch((function(e){return console.log.apply(console,o(r.logPrefix("error"),[e.message,{err:e.stack}]))}))},e}();n.default=i},85:function(e,n,t){"use strict";var o=this&&this.__spreadArrays||function(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var o=Array(e),r=0;for(n=0;n<t;n++)for(var i=arguments[n],a=0,c=i.length;a<c;a++,r++)o[r]=i[a];return o};Object.defineProperty(n,"__esModule",{value:!0});var r=t(593),i=t(354),a=function(){function e(n){this.connection=null,this.buffer=[],this.sendInterval=1,this.onClose=function(){},this.debug=!1,this.dataCollection=!0,e._instance?console.info.apply(console,o(r.logPrefix("info"),["WatchRTCSocket instance already created"])):(e._instance=this,this.debug=!!n.debug)}return e.prototype.connect=function(n,t,i){e._instance.connection&&e._instance.connection.close();var a=e._instance;e._instance.connection=new WebSocket(n,"2.0"),e._instance.connection.onopen=function(e){},e._instance.connection.onclose=function(e){},e._instance.connection.onmessage=function(n){var c;try{var l=JSON.parse(n.data);l.error?(null===(c=null==a?void 0:a.connection)||void 0===c||c.close(),a.connection=null,console.info.apply(console,o(r.logPrefix("error"),["\n"+l.error])),i(l.error)):(l.sendInterval&&(e._instance.sendInterval=l.sendInterval),t(l))}catch(e){console.info.apply(console,o(r.logPrefix("error"),[{err:e.stack}])),i(e.message)}},e._instance.connection.onerror=function(e){console.info.apply(console,o(r.logPrefix("error"),["\n",e])),i(e)}},e.prototype.trace=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var a=Array.prototype.slice.call(n);if(a.push(Date.now()),a[1]instanceof RTCPeerConnection&&(a[1]=a[1].__rtcStatsId),e._instance.dataCollection)if(e._instance.connection){if(e._instance.connection.readyState===WebSocket.OPEN&&(e._instance.buffer.push(a),e._instance.buffer.length>=e._instance.sendInterval)){var c=JSON.stringify(e._instance.buffer),l=i.compressToEncodedURIComponent(c);e._instance.debug&&(console.log.apply(console,o(r.logPrefix("info"),["lines: "+c.length])),console.log.apply(console,o(r.logPrefix("info"),["compressedMessage: "+l.length]))),e._instance.buffer=[],e._instance.connection.send(l)}}else{if(e._instance.buffer.length>1e3)return;e._instance.buffer.push(a)}},e.prototype.close=function(){e._instance.buffer=[],e._instance.connection&&(e._instance.connection.close(),e._instance.onClose(),e._instance.connection=null)},e.prototype.disableDataCollection=function(){e._instance.debug&&console.log.apply(console,o(r.logPrefix("info"),["Data collection disabled."])),e._instance.dataCollection=!1},e.prototype.enableDataCollection=function(){e._instance.debug&&console.log.apply(console,o(r.logPrefix("info"),["Data collection enabled."])),e._instance.dataCollection=!0},e.prototype.toggleDebug=function(n){e._instance.debug=n},e}();n.default=a},240:function(e,n){!function(e){"use strict";function n(e,n,t,o){return new(t||(t=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function c(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}l((o=o.apply(e,n||[])).next())}))}function t(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","radeon r9 200","sgx 543","sgx543"],r=function(e){return e.toLowerCase().replace(/^angle ?\((.+)\)*$/,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"")},i="undefined"==typeof window,a=function(){if(!i){var e=window.navigator,n=e.userAgent,t=e.platform,o=e.maxTouchPoints,r=/(iphone|ipod|ipad)/i.test(n),a="iPad"===t||"MacIntel"===t&&o>0&&!window.MSStream;return{isIpad:a,isMobile:/android/i.test(n)||r||a,isSafari12:/Version\/12.+Safari/.test(n)}}}(),c=[],l=[],s=function(e,n){if(e===n)return 0;var t=e;e.length>n.length&&(e=n,n=t);for(var o=e.length,r=n.length;o>0&&e.charCodeAt(~-o)===n.charCodeAt(~-r);)o--,r--;for(var i,a=0;a<o&&e.charCodeAt(a)===n.charCodeAt(a);)a++;if(r-=a,0==(o-=a))return r;for(var s,d,u=0,f=0,p=0;f<o;)l[f]=e.charCodeAt(a+f),c[f]=++f;for(;p<r;)for(i=n.charCodeAt(a+p),s=p++,u=p,f=0;f<o;f++)d=i===l[f]?s:s+1,s=c[f],u=c[f]=s>u?d>u?u+1:d:d>s?s+1:d;return u};e.getGPUTier=function(e){var c=void 0===e?{}:e,l=c.mobileTiers,d=void 0===l?[0,15,30,60]:l,u=c.desktopTiers,f=void 0===u?[0,15,30,60]:u,p=c.override,g=void 0===p?{}:p,h=c.glContext,v=c.failIfMajorPerformanceCaveat,m=void 0!==v&&v,y=c.benchmarksURL,b=void 0===y?"https://unpkg.com/detect-gpu@3.1.14/dist/benchmarks":y;return n(void 0,void 0,void 0,(function(){var e,c,l,u,p,v,y,w,C,S,_,P,I,x,k,O,D,R,A,T,E,j,M,U,L,z;return t(this,(function(K){switch(K.label){case 0:if(e={},i)return[2,{tier:0,type:"SSR"}];if(c=g.isIpad,l=void 0===c?!!(null==a?void 0:a.isIpad):c,u=g.isMobile,p=void 0===u?!!(null==a?void 0:a.isMobile):u,v=g.screenSize,y=void 0===v?window.screen:v,w=g.loadBenchmarks,C=void 0===w?function(e){return n(void 0,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:return[4,fetch(b+"/"+e).then((function(e){return e.json()}))];case 1:return(n=t.sent()).shift(),[2,n]}}))}))}:w,S=g.renderer,_=function(e){for(var n=0,t=p?["adreno","apple","mali-t","mali","nvidia","powervr"]:["intel","amd","radeon","nvidia","geforce"];n<t.length;n++){var o=t[n];if(e.includes(o))return o}},P=function(o){return n(void 0,void 0,void 0,(function(){var n,r,i,a,c,d,u,f,g,h,v,m,b,w,S,P,I,x,k,O,D,R,A,T,E;return t(this,(function(t){switch(t.label){case 0:if(!(n=_(o)))return[2];i=e[r=(p?"m":"d")+"-"+n+".json"]=e[r]||C(r),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,i];case 2:return a=t.sent(),[3,4];case 3:return t.sent(),[2];case 4:if(c=function(e){var n,t=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(n=null==t?void 0:t.join("").replace(/\W|amd/g,""))&&void 0!==n?n:""}(o),d="apple"===n,(u=a.filter((function(e){return e[1]===c}))).length||(u=a.filter((function(e){return e[0].includes(o)}))),0===(f=u.length))return[2];for(g=f>1?u.map((function(e){return[e,s(o,e[0])]})).sort((function(e,n){return e[1]-n[1]}))[0][0]:u[0],h=g[0],v=g[3],m=Number.MAX_VALUE,w=window.devicePixelRatio,S=y.width*w*(y.height*w),d&&p&&(v=v.filter((function(e){var n,t=e[3];return(null!==(n=null==t?void 0:t.indexOf(l?"ipad":"iphone"))&&void 0!==n?n:-1)>-1}))),P=0,I=v;P<I.length;P++)x=I[P],k=x[0],O=x[1],D=k*O,(R=Math.abs(S-D))<m&&(m=R,b=x);return b?(T=(A=b)[2],E=A[3],[2,[m,T,h,E]]):[2]}}))}))},I=function(e,n,t,o,r){return{device:r,fps:o,gpu:t,isMobile:p,tier:e,type:n}},k="",S)S=r(S),x=[S];else{if(!(O=h||function(e,n){void 0===n&&(n=!1);var t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:n,powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;var o=window.document.createElement("canvas"),r=o.getContext("webgl",t)||o.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==a?void 0:a.isSafari12,m)))return[2,I(0,"WEBGL_UNSUPPORTED")];if((D=O.getExtension("WEBGL_debug_renderer_info"))&&(S=O.getParameter(D.UNMASKED_RENDERER_WEBGL)),!S)return[2,I(1,"FALLBACK")];k=S,S=r(S),x=function(e,n,t){return"apple gpu"===n?function(e,n,t){var o=[n];if(t){var r=e.createShader(35633),i=e.createShader(35632),c=e.createProgram();if(i&&r&&c){e.shaderSource(r,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(i,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(r),e.compileShader(i),e.attachShader(c,r),e.attachShader(c,i),e.linkProgram(c),e.detachShader(c,r),e.detachShader(c,i),e.deleteShader(r),e.deleteShader(i),e.useProgram(c);var l=e.createBuffer();e.bindBuffer(34962,l),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);var s=e.getAttribLocation(c,"aPosition");e.vertexAttribPointer(s,3,5126,!1,0,0),e.enableVertexAttribArray(s),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);var d=new Uint8Array(4);e.readPixels(0,0,1,1,6408,5121,d),e.deleteProgram(c),e.deleteBuffer(l),o={801621810:(null==a?void 0:a.isIpad)?["apple a12x gpu"]:["apple a11 gpu","apple a12 gpu","apple a13 gpu","apple a14 gpu"],8016218135:(null==a?void 0:a.isIpad)?["apple a9x gpu","apple a10 gpu","apple a10x gpu"]:["apple a9 gpu","apple a10 gpu"]}[d.join("")]||o}}return o}(e,n,t):[n]}(O,S,p)}return[4,Promise.all(x.map(P))];case 1:if(!(R=K.sent().filter((function(e){return!!e}))).length)return[2,(A=o.find((function(e){return S.includes(e)})))?I(0,"BLOCKLISTED",A):I(1,"FALLBACK",S+" ("+k+")")];if(T=R.sort((function(e,n){var t=e[0],o=void 0===t?Number.MAX_VALUE:t,r=n[0];return o-(void 0===r?Number.MAX_VALUE:r)}))[0],E=T[1],j=T[2],M=T[3],-1===E)return[2,I(0,"BLOCKLISTED",j,E,M)];for(U=p?d:f,L=0,z=0;z<U.length;z++)E>=U[z]&&(L=z);return[2,I(L,"BENCHMARK",j,E,M)]}}))}))},Object.defineProperty(e,"__esModule",{value:!0})}(n)},354:(e,n,t)=>{var o,r=function(){function e(e,n){if(!r[e]){r[e]={};for(var t=0;t<e.length;t++)r[e][e.charAt(t)]=t}return r[e][n]}var n=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={},i={compressToBase64:function(e){if(null==e)return"";var n=i._compress(e,6,(function(e){return t.charAt(e)}));switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(n){return null==n?"":""==n?null:i._decompress(n.length,32,(function(o){return e(t,n.charAt(o))}))},compressToUTF16:function(e){return null==e?"":i._compress(e,15,(function(e){return n(e+32)}))+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:i._decompress(e.length,16384,(function(n){return e.charCodeAt(n)-32}))},compressToUint8Array:function(e){for(var n=i.compress(e),t=new Uint8Array(2*n.length),o=0,r=n.length;r>o;o++){var a=n.charCodeAt(o);t[2*o]=a>>>8,t[2*o+1]=a%256}return t},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var t=new Array(e.length/2),o=0,r=t.length;r>o;o++)t[o]=256*e[2*o]+e[2*o+1];var a=[];return t.forEach((function(e){a.push(n(e))})),i.decompress(a.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":i._compress(e,6,(function(e){return o.charAt(e)}))},decompressFromEncodedURIComponent:function(n){return null==n?"":""==n?null:(n=n.replace(/ /g,"+"),i._decompress(n.length,32,(function(t){return e(o,n.charAt(t))})))},compress:function(e){return i._compress(e,16,(function(e){return n(e)}))},_compress:function(e,n,t){if(null==e)return"";var o,r,i,a={},c={},l="",s="",d="",u=2,f=3,p=2,g=[],h=0,v=0;for(i=0;i<e.length;i+=1)if(l=e.charAt(i),Object.prototype.hasOwnProperty.call(a,l)||(a[l]=f++,c[l]=!0),s=d+l,Object.prototype.hasOwnProperty.call(a,s))d=s;else{if(Object.prototype.hasOwnProperty.call(c,d)){if(d.charCodeAt(0)<256){for(o=0;p>o;o++)h<<=1,v==n-1?(v=0,g.push(t(h)),h=0):v++;for(r=d.charCodeAt(0),o=0;8>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}else{for(r=1,o=0;p>o;o++)h=h<<1|r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r=0;for(r=d.charCodeAt(0),o=0;16>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}0==--u&&(u=Math.pow(2,p),p++),delete c[d]}else for(r=a[d],o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;0==--u&&(u=Math.pow(2,p),p++),a[s]=f++,d=String(l)}if(""!==d){if(Object.prototype.hasOwnProperty.call(c,d)){if(d.charCodeAt(0)<256){for(o=0;p>o;o++)h<<=1,v==n-1?(v=0,g.push(t(h)),h=0):v++;for(r=d.charCodeAt(0),o=0;8>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}else{for(r=1,o=0;p>o;o++)h=h<<1|r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r=0;for(r=d.charCodeAt(0),o=0;16>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1}0==--u&&(u=Math.pow(2,p),p++),delete c[d]}else for(r=a[d],o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;0==--u&&(u=Math.pow(2,p),p++)}for(r=2,o=0;p>o;o++)h=h<<1|1&r,v==n-1?(v=0,g.push(t(h)),h=0):v++,r>>=1;for(;;){if(h<<=1,v==n-1){g.push(t(h));break}v++}return g.join("")},decompress:function(e){return null==e?"":""==e?null:i._decompress(e.length,32768,(function(n){return e.charCodeAt(n)}))},_decompress:function(e,t,o){var r,i,a,c,l,s,d,u=[],f=4,p=4,g=3,h="",v=[],m={val:o(0),position:t,index:1};for(r=0;3>r;r+=1)u[r]=r;for(a=0,l=Math.pow(2,2),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,l=Math.pow(2,8),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;d=n(a);break;case 1:for(a=0,l=Math.pow(2,16),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;d=n(a);break;case 2:return""}for(u[3]=d,i=d,v.push(d);;){if(m.index>e)return"";for(a=0,l=Math.pow(2,g),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;switch(d=a){case 0:for(a=0,l=Math.pow(2,8),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;u[p++]=n(a),d=p-1,f--;break;case 1:for(a=0,l=Math.pow(2,16),s=1;s!=l;)c=m.val&m.position,m.position>>=1,0==m.position&&(m.position=t,m.val=o(m.index++)),a|=(c>0?1:0)*s,s<<=1;u[p++]=n(a),d=p-1,f--;break;case 2:return v.join("")}if(0==f&&(f=Math.pow(2,g),g++),u[d])h=u[d];else{if(d!==p)return null;h=i+i.charAt(0)}v.push(h),u[p++]=i+h.charAt(0),i=h,0==--f&&(f=Math.pow(2,g),g++)}}};return i}();void 0===(o=function(){return r}.call(n,t,n,e))||(e.exports=o)}},n={},function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{}};return e[o].call(r.exports,r,r.exports,t),r.exports}(607)).default;var e,n})); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.30.0"; | ||
declare const _default: "1.30.1"; | ||
export default _default; |
{ | ||
"name": "@testrtc/watchrtc-sdk", | ||
"version": "1.30.0", | ||
"version": "1.30.1", | ||
"description": "Monitor your WebRTC application by collecting WebRTC statistics from end users", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# watchRTC JS SDK | ||
watchRTC enables application developers to collect, track and analyze telemetry and metrics of real users on any WebRTC application. | ||
This is done by including our watchRTC SDK which connects to the testRTC backend and collects the relevant data. | ||
Please check out our [watchRTC knowledge base](https://testrtc.com/article-categories/watchrtc/) to learn more about the features and capabilities of this WebRTC monitoring service. | ||
@@ -36,3 +34,2 @@ | ||
The watchRTC.init() needs to take place prior to including or loading any 3rd party SDKs that interact with WebRTC - failing to do so may hinder our ability to collect data. | ||
Use the following initialization sequence: | ||
@@ -75,12 +72,12 @@ | ||
Before you start, be sure to also read our [Getting started with watchRTC](https://testrtc.com/docs/getting-started-with-watchrtc/) guide. | ||
Configuring the SDK to connect to the watchRTC backend requires passing the following parameters to the SDK: | ||
- rtcApiKey - watchRTC API key, as provided by testRTC | ||
- rtcRoomId - an identifier to the session/room/conference. This will enable an analysis of all participants in the same room as a single logical unit | ||
- rtcRoomId - an identifier to the session/room/conference. This will enable an analysis of all participants in the same room as a single logical unit. Read more about [rooms and peers in watchRTC](https://testrtc.com/docs/rooms-and-peers-in-watchrtc/). | ||
- rtcPeerId - an identifer of this peer/user in the session. This will make it easier to identify and troubleshoot users. It is recommended to use non-PII data here as much as possible (no emails or names for example) | ||
- rtcTags - tags to associate with this peer connection. These can later be searched for or filtered | ||
- keys - key value object. Used to associate with this peer connection. These can later be searched for or filtered. Read more about [keys in watchRTC](https://testrtc.com/docs/using-custom-keys-in-watchrtc/). | ||
- proxyUrl - (optional) secured web socket proxy server address, the proxy server should forward the connection to testRTC's watchRTC servers | ||
Based on your application's logic, you can and should pass these configuration parameters at different stages. | ||
Based on your application's logic, you can and should pass these configuration parameters at different stages. | ||
1. In the call to the `watchRTC.init()` | ||
@@ -93,7 +90,4 @@ 2. In the call to `watchRTC.setConfig()` | ||
Passing configuration parameters in the init() is the direct/easy way to provide this information. | ||
This is useful if you are planning to use a known/specific roomId for this session. | ||
The disadvantage of this approach is that it is rigid, and doesn't allow much flexibility. | ||
You can call the init() function multiple times but it will be initialized only on the first call. | ||
@@ -106,3 +100,3 @@ | ||
rtcPeerId: "identifier for the current peer", | ||
rtcTags: ["tag1", "tag2", "tag3"], | ||
keys: { key1: "value1", key2: "value2" }, | ||
}); | ||
@@ -114,7 +108,4 @@ ``` | ||
You can use `watchRTC.setConfig()` function to set watchRTC configuration after calling `watchRTC.init()` and before the creation of RTCPeerConnection objects. | ||
This approach is useful if you don't have the information needed in your `watchRTC.init()` call or when you don't have direct/easy access to the RTCPeerConnection objects (for example, when using a third party CPaaS SDK). | ||
If needed, you can pass the rtcApiKey in the `watchRTC.init()` call while passing the rtcRomId, rtcPeerId and rtcTags in the `watchRTC.setConfig()` call. | ||
If needed, you can pass the rtcApiKey in the `watchRTC.init()` call while passing the rtcRomId, rtcPeerId and keys in the `watchRTC.setConfig()` call. | ||
You can call this function multiple times, usually whenever a new session/room needs to be created or entered. | ||
@@ -127,3 +118,3 @@ | ||
rtcPeerId: "identifier for the current peer", | ||
rtcTags: ["tag1", "tag2", "tag3"], | ||
keys: { key1: "value1", key2: "value2" }, | ||
}); | ||
@@ -143,3 +134,3 @@ ``` | ||
rtcPeerId: "identifier for the current peer", | ||
rtcTags: ["tag1", "tag2", "tag3"] | ||
keys: { key1: "value1", key2: "value2" }, | ||
} | ||
@@ -149,10 +140,10 @@ }); | ||
### Adding tags | ||
### Adding keys | ||
You can also add tags to a room after joining the room. This can be done by calling `watchRTC.addTags()` function. | ||
You can also add keys to a room after joining the room. This can be done by calling `watchRTC.addKeys()` function. | ||
- rtcTags - These can later be searched for or filtered | ||
- keys - These can later be searched for or filtered. Read more about [keys in watchRTC](https://testrtc.com/docs/using-custom-keys-in-watchrtc/). | ||
```javascript | ||
watchRTC.addTags(["tag1", "tag2", "tag3"]); | ||
watchRTC.addKeys({ key1: "value1", key2: "value2" }); | ||
``` | ||
@@ -163,3 +154,2 @@ | ||
When needed, you can temporarily disable data collection. This is important for example if you want to conduct a pre-call test but you aren't interesting in collecting that data. | ||
For that, you can use `watchRTC.disableDataCollection()` and `watchRTC.disableDataCollection()` to control what data you want to send. | ||
@@ -183,3 +173,2 @@ | ||
Additional samples on how to integrate the watchRTC SDK can be found on our official github reporistory: | ||
https://github.com/testRTC/sample-Twilio-video-app-React-TypeScript-watchRTC | ||
@@ -195,1 +184,8 @@ | ||
- `watchRTC.setUserRating()` was added | ||
### 1.30.0 (September 26, 2021) | ||
#### New features | ||
- `watchRTC.addTags()` was deprecated. We no longer support tags. These have been replaced with a key/value system | ||
- `watchRTC.addKeys()` was added. Read more about [keys in watchRTC](https://testrtc.com/docs/using-custom-keys-in-watchrtc/). |
Sorry, the diff of this file is not supported yet
204653
181