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

peer-data

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peer-data - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

.hound.yml

1

dist/bundle.d.ts

@@ -57,2 +57,3 @@ // Generated by dts-bundle v0.7.2

import 'socket.io-client';
export class SocketChannel implements Signaling {

@@ -59,0 +60,0 @@ constructor(opts?: SocketIOClient.ConnectOpts);

3

dist/peer-data.js

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("socket.io-client")):"function"==typeof define&&define.amd?define(["exports","socket.io-client"],n):n(e["peer-data"]=e["peer-data"]||{},e.io)}(this,function(e,n){"use strict";var t={},r=function(){function e(){}return e.register=function(e,n){t[e]||(t[e]=[]),t[e].push(n)},e.dispatch=function(e,n){t[e].forEach(function(e){return e(n)})},e}(),o=function(){function e(){}return e}();o.CONNECT="CONNECT",o.DISCONNECT="DISCONNECT",o.CANDIDATE="CANDIDATE",o.OFFER="OFFER",o.ANSWER="ANSWER",o.ERROR="ERROR";var i=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=e,this._dataConstraints=n}return Object.defineProperty(e.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),e.prototype.addPeer=function(e,n){var t=this;return this._peers.hasOwnProperty(e)||(this._peers[e]=n,n.onconnectionstatechange=function(r){"closed"===n.connectionState&&t.removePeer(e)}),this},e.prototype.getPeer=function(e){return this._peers.hasOwnProperty(e)?this._peers[e]:null},e.prototype.removePeer=function(e){return this._peers.hasOwnProperty(e)&&(this._peers[e].close(),delete this._peers[e]),this},e.prototype.addChannel=function(e,n){var t=this;return this._channels.hasOwnProperty(e)||(this._channels[e]=n,n.onclose=function(n){return t.removeChannel(e)}),this},e.prototype.getChannel=function(e){return this._channels.hasOwnProperty(e)?this._channels[e]:null},e.prototype.removeChannel=function(e){return this._channels.hasOwnProperty(e)&&(this._channels[e].close(),delete this._channels[e]),this},Object.defineProperty(e.prototype,"servers",{get:function(){return this._servers},set:function(e){this._servers=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(e){this._dataConstraints=e},enumerable:!0,configurable:!0}),e}(),c=function(){function e(){}return e.get=function(e,n){var t=new RTCPeerConnection(e);return t.onicecandidate=function(e){if(e.candidate){var t={type:o.CANDIDATE,caller:null,callee:n.caller,room:n.room,data:e.candidate};r.dispatch("send",t)}},t},e}(),s=function(){function e(){}return e.get=function(e,n){var t=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return e.createDataChannel(t,n)},e}(),a=function(){function e(){}return e}();a.LOG="LOG",a.ERROR="ERROR",a.PEER="PEER",a.CHANNEL="CHANNEL";var h=function(){function e(e){this._connection=e,r.register(o.CONNECT,this.onConnect.bind(this)),r.register(o.DISCONNECT,this.onDisconnect.bind(this)),r.register(o.OFFER,this.onOffer.bind(this)),r.register(o.ANSWER,this.onAnswer.bind(this)),r.register(o.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(e.prototype,"connection",{get:function(){return this._connection},set:function(e){this._connection=e},enumerable:!0,configurable:!0}),e.prototype.onConnect=function(e){var n=this,t=c.get(this._connection.servers,e),r=s.get(t,this._connection.dataConstraints);this.dispatchPeer(t,e),this.dispatchChannel(r,e),this._connection.addChannel(e.caller.id,r),this._connection.addPeer(e.caller.id,t),t.createOffer(function(r){var i={type:o.OFFER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onDisconnect=function(e){this._connection.removeChannel(e.caller.id),this._connection.removePeer(e.caller.id)},e.prototype.onOffer=function(e){var n=this,t=c.get(this._connection.servers,e);this._connection.addPeer(e.caller.id,t),this.dispatchPeer(t,e),t.ondatachannel=function(t){n.dispatchChannel(t.channel,e),n._connection.addChannel(e.caller.id,t.channel)},t.setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)}),t.createAnswer(function(r){var i={type:o.ANSWER,caller:null,callee:e.caller,room:e.room,data:r};t.setLocalDescription(r,function(){return n.dispatchEvent(i)},function(t){return n.dispatchError(e,t)})},function(t){return n.dispatchError(e,t)})},e.prototype.onAnswer=function(e){var n=this;this._connection.getPeer(e.caller.id).setRemoteDescription(new RTCSessionDescription(e.data),function(){},function(t){return n.dispatchError(e,t)})},e.prototype.onCandidate=function(e){var n=this,t=this._connection.getPeer(e.caller.id),r=new RTCIceCandidate(e.data);t.addIceCandidate(r).then(function(){},function(t){return n.dispatchError(e,t)})},e.prototype.dispatchPeer=function(e,n){var t={caller:n.caller,room:n.room,data:e};r.dispatch(a.PEER,t)},e.prototype.dispatchChannel=function(e,n){var t={caller:n.caller,room:n.room,data:e};r.dispatch(a.CHANNEL,t)},e.prototype.dispatchEvent=function(e){r.dispatch("send",e)},e.prototype.dispatchError=function(e,n){var t={caller:e.caller,room:e.room,data:n.message};r.dispatch(a.ERROR,t)},e}(),u=function(){function e(e,n){void 0===e&&(e={}),void 0===n&&(n=null);var t=new i(e,n);this.bridge=new h(t)}return e.prototype.on=function(e,n){r.register(e,n)},e.prototype.send=function(e,n){if(n){var t=this.bridge.connection.channels[n];t&&"open"===t.readyState&&t.send(e)}else Object.entries(this.bridge.connection.channels).forEach(function(n){n[0];var t=n[1];"open"===t.readyState&&t.send(e)})},e.prototype.connect=function(e){var n={type:o.CONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",n)},e.prototype.disconnect=function(e){var n=this.bridge.connection;Object.entries(n.channels).forEach(function(e){var t=e[0];e[1];return n.removeChannel(t)}),Object.entries(n.peers).forEach(function(e){var t=e[0];e[1];return n.removePeer(t)});var t={type:o.DISCONNECT,caller:null,callee:null,room:{id:e},data:null};r.dispatch("send",t)},e.prototype.peers=function(e){return e?this.bridge.connection.peers[e]:this.bridge.connection.peers},e.prototype.channels=function(e){return e?this.bridge.connection.channels[e]:this.bridge.connection.channels},e}(),p=function(){function e(e){this.socket=n.connect(e),r.register("send",this.onSend.bind(this)),this.subscribeEvents()}return e.prototype.onSend=function(e){this.socket.emit("message",e)},e.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this))},e.prototype.onIp=function(e){r.dispatch(a.LOG,"Server IP address is: "+e)},e.prototype.onLog=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.dispatch(a.LOG,e)},e.prototype.onMessage=function(e){r.dispatch(e.type,e)},e}();e.default=u,e.EventDispatcher=r,e.AppEventType=a,e.SignalingEventType=o,e.SocketChannel=p,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=peer-data.js.map
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["peer-data"]=t["peer-data"]||{})}(this,function(t){"use strict";function e(t,e){return e={exports:{}},t(e,e.exports),e.exports}function n(t,e){var n=t;e=e||Wt.location,null==t&&(t=e.protocol+"//"+e.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(Xt("protocol-less url %s",t),t=void 0!==e?e.protocol+"//"+t:"https://"+t),Xt("parse %s",t),n=$t(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(e&&e.port===n.port?"":":"+n.port),n}function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(Qt===setTimeout)return setTimeout(t,0);if((Qt===r||!Qt)&&setTimeout)return Qt=setTimeout,setTimeout(t,0);try{return Qt(t,0)}catch(e){try{return Qt.call(null,t,0)}catch(e){return Qt.call(this,t,0)}}}function s(t){if(Zt===clearTimeout)return clearTimeout(t);if((Zt===o||!Zt)&&clearTimeout)return Zt=clearTimeout,clearTimeout(t);try{return Zt(t)}catch(e){try{return Zt.call(null,t)}catch(e){return Zt.call(this,t)}}}function a(){ne&&te&&(ne=!1,te.length?ee=te.concat(ee):re=-1,ee.length&&c())}function c(){if(!ne){var t=i(a);ne=!0;for(var e=ee.length;e;){for(te=ee,ee=[];++re<e;)te&&te[re].run();re=-1,e=ee.length}te=null,ne=!1,s(t)}}function h(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];ee.push(new u(t,e)),1!==ee.length||ne||i(c)}function u(t,e){this.fun=t,this.array=e}function f(){}function p(t){throw new Error("process.binding is not supported")}function l(){return"/"}function d(t){throw new Error("process.chdir is not supported")}function g(){return 0}function y(t){var e=.001*me.call(ye),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],(r-=t[1])<0&&(n--,r+=1e9)),[n,r]}function m(){return(new Date-ve)/1e3}function v(t){if(!t||"object"!=typeof t)return!1;if(Ae(t)){for(var e=0,n=t.length;e<n;e++)if(v(t[e]))return!0;return!1}if("function"==typeof Wt.Buffer&&Wt.Buffer.isBuffer&&Wt.Buffer.isBuffer(t)||"function"==typeof Wt.ArrayBuffer&&t instanceof ArrayBuffer||_e&&t instanceof Blob||Re&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return v(t.toJSON(),!0);for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&v(t[r]))return!0;return!1}function b(t,e){if(!t)return t;if(Be(t)){var n={_placeholder:!0,num:e.length};return e.push(t),n}if(Pe(t)){for(var r=new Array(t.length),o=0;o<t.length;o++)r[o]=b(t[o],e);return r}if("object"==typeof t&&!(t instanceof Date)){r={};for(var i in t)r[i]=b(t[i],e);return r}return t}function w(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Pe(t))for(var n=0;n<t.length;n++)t[n]=w(t[n],e);else if("object"==typeof t)for(var r in t)t[r]=w(t[r],e);return t}function E(t){return Wt.Buffer&&Wt.Buffer.isBuffer(t)||Wt.ArrayBuffer&&t instanceof ArrayBuffer}function A(t,e){if(!(this instanceof A))return new A(t,e);e=e||{},t&&"object"==typeof t&&(e=t,t=null),t?(t=He(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=He(e.host).host),this.secure=null!=e.secure?e.secure:Wt.location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||(Wt.location?location.hostname:"localhost"),this.port=e.port||(Wt.location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},"string"==typeof this.query&&(this.query=Je.decode(this.query)),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=!1!==e.jsonp,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=!1!==e.perMessageDeflate&&(e.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||null,this.key=e.key||null,this.passphrase=e.passphrase||null,this.cert=e.cert||null,this.ca=e.ca||null,this.ciphers=e.ciphers||null,this.rejectUnauthorized=void 0===e.rejectUnauthorized||e.rejectUnauthorized,this.forceNode=!!e.forceNode;var n="object"==typeof Wt&&Wt;n.global===n&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}function k(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function _(){Ge=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,n=t.length;e<n;++e)We[e]=t[e],$e[t.charCodeAt(e)]=e;$e["-".charCodeAt(0)]=62,$e["_".charCodeAt(0)]=63}function R(t){Ge||_();var e,n,r,o,i,s,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[a-2]?2:"="===t[a-1]?1:0,s=new Xe(3*a/4-i),r=i>0?a-4:a;var c=0;for(e=0,n=0;e<r;e+=4,n+=3)o=$e[t.charCodeAt(e)]<<18|$e[t.charCodeAt(e+1)]<<12|$e[t.charCodeAt(e+2)]<<6|$e[t.charCodeAt(e+3)],s[c++]=o>>16&255,s[c++]=o>>8&255,s[c++]=255&o;return 2===i?(o=$e[t.charCodeAt(e)]<<2|$e[t.charCodeAt(e+1)]>>4,s[c++]=255&o):1===i&&(o=$e[t.charCodeAt(e)]<<10|$e[t.charCodeAt(e+1)]<<4|$e[t.charCodeAt(e+2)]>>2,s[c++]=o>>8&255,s[c++]=255&o),s}function T(t){return We[t>>18&63]+We[t>>12&63]+We[t>>6&63]+We[63&t]}function P(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16)+(t[i+1]<<8)+t[i+2],o.push(T(r));return o.join("")}function B(t){Ge||_();for(var e,n=t.length,r=n%3,o="",i=[],s=0,a=n-r;s<a;s+=16383)i.push(P(t,s,s+16383>a?a:s+16383));return 1===r?(e=t[n-1],o+=We[e>>2],o+=We[e<<4&63],o+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],o+=We[e>>10],o+=We[e>>4&63],o+=We[e<<2&63],o+="="),i.push(o),i.join("")}function C(t,e,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,h=c>>1,u=-7,f=n?o-1:0,p=n?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=256*i+t[e+f],f+=p,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+t[e+f],f+=p,u-=8);if(0===i)i=1-h;else{if(i===c)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,r),i-=h}return(l?-1:1)*s*Math.pow(2,i-r)}function S(t,e,n,r,o,i){var s,a,c,h=8*i-o-1,u=(1<<h)-1,f=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,d=r?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+f>=1?p/c:p*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=u?(a=0,s=u):s+f>=1?(a=(e*c-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[n+l]=255&a,l+=d,a/=256,o-=8);for(s=s<<o|a,h+=o;h>0;t[n+l]=255&s,l+=d,s/=256,h-=8);t[n+l-d]|=128*g}function O(){return I.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function N(t,e){if(O()<e)throw new RangeError("Invalid typed array length");return I.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=I.prototype:(null===t&&(t=new I(e)),t.length=e),t}function I(t,e,n){if(!(I.TYPED_ARRAY_SUPPORT||this instanceof I))return new I(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return x(this,t)}return D(this,t,e,n)}function D(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?Y(t,e,n,r):"string"==typeof e?L(t,e,n):q(t,e)}function U(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function j(t,e,n,r){return U(e),e<=0?N(t,e):void 0!==n?"string"==typeof r?N(t,e).fill(n,r):N(t,e).fill(n):N(t,e)}function x(t,e){if(U(e),t=N(t,e<0?0:0|F(e)),!I.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function L(t,e,n){if("string"==typeof n&&""!==n||(n="utf8"),!I.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|H(e,n),o=(t=N(t,r)).write(e,n);return o!==r&&(t=t.slice(0,o)),t}function M(t,e){var n=e.length<0?0:0|F(e.length);t=N(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function Y(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r),I.TYPED_ARRAY_SUPPORT?(t=e).__proto__=I.prototype:t=M(t,e),t}function q(t,e){if(z(e)){var n=0|F(e.length);return 0===(t=N(t,n)).length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||kt(e.length)?N(t,0):M(t,e);if("Buffer"===e.type&&Ze(e.data))return M(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function F(t){if(t>=O())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+O().toString(16)+" bytes");return 0|t}function z(t){return!(null==t||!t._isBuffer)}function H(t,e){if(z(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return vt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Et(t).length;default:if(r)return vt(t).length;e=(""+e).toLowerCase(),r=!0}}function V(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return st(this,e,n);case"utf8":case"utf-8":return nt(this,e,n);case"ascii":return ot(this,e,n);case"latin1":case"binary":return it(this,e,n);case"base64":return et(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return at(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function J(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function K(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=I.from(e,r)),z(e))return 0===e.length?-1:W(t,e,n,r,o);if("number"==typeof e)return e&=255,I.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):W(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function W(t,e,n,r,o){function i(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}var h;if(o){var u=-1;for(h=n;h<a;h++)if(i(t,h)===i(e,-1===u?0:h-u)){if(-1===u&&(u=h),h-u+1===c)return u*s}else-1!==u&&(h-=h-u),u=-1}else for(n+c>a&&(n=a-c),h=n;h>=0;h--){for(var f=!0,p=0;p<c;p++)if(i(t,h+p)!==i(e,p)){f=!1;break}if(f)return h}return-1}function $(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[n+s]=a}return s}function X(t,e,n,r){return At(vt(e,t.length-n),t,n,r)}function G(t,e,n,r){return At(bt(e),t,n,r)}function Q(t,e,n,r){return G(t,e,n,r)}function Z(t,e,n,r){return At(Et(e),t,n,r)}function tt(t,e,n,r){return At(wt(e,t.length-n),t,n,r)}function et(t,e,n){return B(0===e&&n===t.length?t:t.slice(e,n))}function nt(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=n){var c,h,u,f;switch(a){case 1:i<128&&(s=i);break;case 2:128==(192&(c=t[o+1]))&&(f=(31&i)<<6|63&c)>127&&(s=f);break;case 3:c=t[o+1],h=t[o+2],128==(192&c)&&128==(192&h)&&(f=(15&i)<<12|(63&c)<<6|63&h)>2047&&(f<55296||f>57343)&&(s=f);break;case 4:c=t[o+1],h=t[o+2],u=t[o+3],128==(192&c)&&128==(192&h)&&128==(192&u)&&(f=(15&i)<<18|(63&c)<<12|(63&h)<<6|63&u)>65535&&f<1114112&&(s=f)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),o+=a}return rt(r)}function rt(t){var e=t.length;if(e<=tn)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=tn));return n}function ot(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function it(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function st(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=mt(t[i]);return o}function at(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function ct(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function ht(t,e,n,r,o,i){if(!z(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function ut(t,e,n,r){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);o<i;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function ft(t,e,n,r){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);o<i;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function pt(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function lt(t,e,n,r,o){return o||pt(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),S(t,e,n,r,23,4),n+4}function dt(t,e,n,r,o){return o||pt(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),S(t,e,n,r,52,8),n+8}function gt(t){if((t=yt(t).replace(en,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}function yt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function mt(t){return t<16?"0"+t.toString(16):t.toString(16)}function vt(t,e){e=e||1/0;for(var n,r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function bt(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}function wt(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function Et(t){return R(gt(t))}function At(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function kt(t){return t!==t}function _t(t){return null!=t&&(!!t._isBuffer||Rt(t)||Tt(t))}function Rt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function Tt(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Rt(t.slice(0,0))}function Pt(e,n,r){if(!n)return t.encodeBase64Packet(e,r);var o=e.data,i=new I(1);return i[0]=an[e.type],r(I.concat([i,o]))}function Bt(t){try{t=nn.decode(t,{strict:!1})}catch(t){return!1}return t}function Ct(t){return t.length+":"+t}function St(t,e,n){for(var r=new Array(t.length),o=on(t.length,n),i=0;i<t.length;i++)e(t[i],function(t,e){r[i]=e,o(t,r)})}function Ot(t){for(var e="",n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);return e}function Nt(t){for(var e=new I(t.length),n=0,r=t.length;n<r;n++)e.writeUInt8(t.charCodeAt(n),n);return e}function It(t){for(var e=new Uint8Array(t.buffer||t),n=t.byteLength||t.length,r=t.byteOffset||0,o=new I(n),i=0;i<n;i++)o[i]=e[r+i];return o}function Dt(e,n){function r(t){var e,r=""+t.length;if("string"==typeof t){(e=new I(r.length+2))[0]=0;for(o=0;o<r.length;o++)e[o+1]=parseInt(r[o],10);return e[e.length-1]=255,n(null,I.concat([e,Nt(t)]))}(e=new I(r.length+2))[0]=1;for(var o=0;o<r.length;o++)e[o+1]=parseInt(r[o],10);e[e.length-1]=255,n(null,I.concat([e,t]))}t.encodePacket(e,!0,!0,r)}function Ut(t,e){for(var n=[],r=(e=e||0)||0;r<t.length;r++)n[r-e]=t[r];return n}function jt(t,e,n){return t.on(e,n),{destroy:function(){t.removeListener(e,n)}}}function xt(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}function Lt(t,e){if(!(this instanceof Lt))return new Lt(t,e);t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new kn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=e.parser||Le;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==e.autoConnect,this.autoConnect&&this.open()}var Mt={},Yt=function(){function t(){}return t.register=function(t,e){Mt[t]||(Mt[t]=[]),Mt[t].push(e)},t.dispatch=function(t,e){Mt[t].forEach(function(t){return t(e)})},t}(),qt=function(){function t(){}return t}();qt.CONNECT="CONNECT",qt.DISCONNECT="DISCONNECT",qt.CANDIDATE="CANDIDATE",qt.OFFER="OFFER",qt.ANSWER="ANSWER",qt.ERROR="ERROR";var Ft=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e=null),this._servers={},this._dataConstraints=null,this._peers={},this._channels={},this._servers=t,this._dataConstraints=e}return Object.defineProperty(t.prototype,"peers",{get:function(){return this._peers},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"channels",{get:function(){return this._channels},enumerable:!0,configurable:!0}),t.prototype.addPeer=function(t,e){var n=this;return this._peers.hasOwnProperty(t)||(this._peers[t]=e,e.onconnectionstatechange=function(r){"closed"===e.connectionState&&n.removePeer(t)}),this},t.prototype.getPeer=function(t){return this._peers.hasOwnProperty(t)?this._peers[t]:null},t.prototype.removePeer=function(t){return this._peers.hasOwnProperty(t)&&(this._peers[t].close(),delete this._peers[t]),this},t.prototype.addChannel=function(t,e){var n=this;return this._channels.hasOwnProperty(t)||(this._channels[t]=e,e.onclose=function(e){return n.removeChannel(t)}),this},t.prototype.getChannel=function(t){return this._channels.hasOwnProperty(t)?this._channels[t]:null},t.prototype.removeChannel=function(t){return this._channels.hasOwnProperty(t)&&(this._channels[t].close(),delete this._channels[t]),this},Object.defineProperty(t.prototype,"servers",{get:function(){return this._servers},set:function(t){this._servers=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataConstraints",{get:function(){return this._dataConstraints},set:function(t){this._dataConstraints=t},enumerable:!0,configurable:!0}),t}(),zt=function(){function t(){}return t.get=function(t,e){var n=new RTCPeerConnection(t);return n.onicecandidate=function(t){if(t.candidate){var n={type:qt.CANDIDATE,caller:null,callee:e.caller,room:e.room,data:t.candidate};Yt.dispatch("send",n)}},n},t}(),Ht=function(){function t(){}return t.get=function(t,e){var n=Math.floor(1e16*(1+Math.random())).toString(16).substring(1);return t.createDataChannel(n,e)},t}(),Vt=function(){function t(){}return t}();Vt.LOG="LOG",Vt.ERROR="ERROR",Vt.PEER="PEER",Vt.CHANNEL="CHANNEL";var Jt=function(){function t(t){this._connection=t,Yt.register(qt.CONNECT,this.onConnect.bind(this)),Yt.register(qt.DISCONNECT,this.onDisconnect.bind(this)),Yt.register(qt.OFFER,this.onOffer.bind(this)),Yt.register(qt.ANSWER,this.onAnswer.bind(this)),Yt.register(qt.CANDIDATE,this.onCandidate.bind(this))}return Object.defineProperty(t.prototype,"connection",{get:function(){return this._connection},set:function(t){this._connection=t},enumerable:!0,configurable:!0}),t.prototype.onConnect=function(t){var e=this,n=zt.get(this._connection.servers,t),r=Ht.get(n,this._connection.dataConstraints);this.dispatchPeer(n,t),this.dispatchChannel(r,t),this._connection.addChannel(t.caller.id,r),this._connection.addPeer(t.caller.id,n),n.createOffer(function(r){var o={type:qt.OFFER,caller:null,callee:t.caller,room:t.room,data:r};n.setLocalDescription(r,function(){return e.dispatchEvent(o)},function(n){return e.dispatchError(t,n)})},function(n){return e.dispatchError(t,n)})},t.prototype.onDisconnect=function(t){this._connection.removeChannel(t.caller.id),this._connection.removePeer(t.caller.id)},t.prototype.onOffer=function(t){var e=this,n=zt.get(this._connection.servers,t);this._connection.addPeer(t.caller.id,n),this.dispatchPeer(n,t),n.ondatachannel=function(n){e.dispatchChannel(n.channel,t),e._connection.addChannel(t.caller.id,n.channel)},n.setRemoteDescription(new RTCSessionDescription(t.data),function(){},function(n){return e.dispatchError(t,n)}),n.createAnswer(function(r){var o={type:qt.ANSWER,caller:null,callee:t.caller,room:t.room,data:r};n.setLocalDescription(r,function(){return e.dispatchEvent(o)},function(n){return e.dispatchError(t,n)})},function(n){return e.dispatchError(t,n)})},t.prototype.onAnswer=function(t){var e=this;this._connection.getPeer(t.caller.id).setRemoteDescription(new RTCSessionDescription(t.data),function(){},function(n){return e.dispatchError(t,n)})},t.prototype.onCandidate=function(t){var e=this,n=this._connection.getPeer(t.caller.id),r=new RTCIceCandidate(t.data);n.addIceCandidate(r).then(function(){},function(n){return e.dispatchError(t,n)})},t.prototype.dispatchPeer=function(t,e){var n={caller:e.caller,room:e.room,data:t};Yt.dispatch(Vt.PEER,n)},t.prototype.dispatchChannel=function(t,e){var n={caller:e.caller,room:e.room,data:t};Yt.dispatch(Vt.CHANNEL,n)},t.prototype.dispatchEvent=function(t){Yt.dispatch("send",t)},t.prototype.dispatchError=function(t,e){var n={caller:t.caller,room:t.room,data:e.message};Yt.dispatch(Vt.ERROR,n)},t}(),Kt=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e=null);var n=new Ft(t,e);this.bridge=new Jt(n)}return t.prototype.on=function(t,e){Yt.register(t,e)},t.prototype.send=function(t,e){if(e){var n=this.bridge.connection.channels[e];n&&"open"===n.readyState&&n.send(t)}else Object.entries(this.bridge.connection.channels).forEach(function(e){e[0];var n=e[1];"open"===n.readyState&&n.send(t)})},t.prototype.connect=function(t){var e={type:qt.CONNECT,caller:null,callee:null,room:{id:t},data:null};Yt.dispatch("send",e)},t.prototype.disconnect=function(t){var e=this.bridge.connection;Object.entries(e.channels).forEach(function(t){var n=t[0];t[1];return e.removeChannel(n)}),Object.entries(e.peers).forEach(function(t){var n=t[0];t[1];return e.removePeer(n)});var n={type:qt.DISCONNECT,caller:null,callee:null,room:{id:t},data:null};Yt.dispatch("send",n)},t.prototype.peers=function(t){return t?this.bridge.connection.peers[t]:this.bridge.connection.peers},t.prototype.channels=function(t){return t?this.bridge.connection.channels[t]:this.bridge.connection.channels},t}(),Wt="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},$t=require("parseuri"),Xt=require("debug")("socket.io-client:url");module.exports=n;var Gt=Object.freeze({}),Qt=r,Zt=o;"function"==typeof Wt.setTimeout&&(Qt=setTimeout),"function"==typeof Wt.clearTimeout&&(Zt=clearTimeout);var te,ee=[],ne=!1,re=-1;u.prototype.run=function(){this.fun.apply(null,this.array)};var oe={},ie=[],se={},ae={},ce={},he=f,ue=f,fe=f,pe=f,le=f,de=f,ge=f,ye=Wt.performance||{},me=ye.now||ye.mozNow||ye.msNow||ye.oNow||ye.webkitNow||function(){return(new Date).getTime()},ve=new Date,be={nextTick:h,title:"browser",browser:!0,env:oe,argv:ie,version:"",versions:se,on:he,addListener:ue,once:fe,off:pe,removeListener:le,removeAllListeners:de,emit:ge,binding:p,cwd:l,chdir:d,umask:g,hrtime:y,platform:"browser",release:ae,config:ce,uptime:m};module.exports=void 0!==be&&"renderer"===be.type?require("./browser.js"):require("./node.js");var we=Object.freeze({}),Ee=e(function(t){function e(t){if(t)return n(t)}function n(t){for(var n in e.prototype)t[n]=e.prototype[n];return t}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},e.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r,o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return this},e.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,e);return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),Ae=require("isarray"),ke=Object.prototype.toString,_e="function"==typeof Wt.Blob||"[object BlobConstructor]"===ke.call(Wt.Blob),Re="function"==typeof Wt.File||"[object FileConstructor]"===ke.call(Wt.File);module.exports=v;var Te=Object.freeze({}),Pe=require("isarray"),Be=require("./is-buffer"),Ce=Object.prototype.toString,Se="function"==typeof Wt.Blob||"[object BlobConstructor]"===Ce.call(Wt.Blob),Oe="function"==typeof Wt.File||"[object FileConstructor]"===Ce.call(Wt.File);t.deconstructPacket=function(t){var e=[],n=t.data,r=t;return r.data=b(n,e),r.attachments=e.length,{packet:r,buffers:e}},t.reconstructPacket=function(t,e){return t.data=w(t.data,e),t.attachments=void 0,t},t.removeBlobs=function(t,e){function n(t,i,s){if(!t)return t;if(Se&&t instanceof Blob||Oe&&t instanceof File){r++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:o=this.result,--r||e(o)},a.readAsArrayBuffer(t)}else if(Pe(t))for(var c=0;c<t.length;c++)n(t[c],c,t);else if("object"==typeof t&&!Be(t))for(var h in t)n(t[h],h,t)}var r=0,o=t;n(o),r||e(o)};var Ne=Object.freeze({});module.exports=E;var Ie=Object.freeze({}),De=we&&void 0||we,Ue=Te&&void 0||Te,je=Ne&&void 0||Ne,xe=Ie&&void 0||Ie,Le=e(function(t,e){function n(){}function r(t){var n=""+t.type;return e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(n+=t.nsp+","),null!=t.id&&(n+=t.id),null!=t.data&&(n+=JSON.stringify(t.data)),u("encoded %j as %s",t,n),n}function o(t,e){function n(t){var n=je.deconstructPacket(t),o=r(n.packet),i=n.buffers;i.unshift(o),e(i)}je.removeBlobs(t,n)}function i(){this.reconstructor=null}function s(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return h();if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n&&","!==(s=t.charAt(n))&&(r.nsp+=s,n!==t.length););else r.nsp="/";var i=t.charAt(n+1);if(""!==i&&Number(i)==i){for(r.id="";++n;){var s=t.charAt(n);if(null==s||Number(s)!=s){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}return t.charAt(++n)&&(r=a(r,t.substr(n))),u("decoded %s as %j",t,r),r}function a(t,e){try{t.data=JSON.parse(e)}catch(t){return h()}return t}function c(t){this.reconPack=t,this.buffers=[]}function h(){return{type:e.ERROR,data:"parser error"}}var u=De("socket.io-parser");e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=n,e.Decoder=i,n.prototype.encode=function(t,n){t.type!==e.EVENT&&t.type!==e.ACK||!Ue(t.data)||(t.type=t.type===e.EVENT?e.BINARY_EVENT:e.BINARY_ACK),u("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type?o(t,n):n([r(t)])},Ee(i.prototype),i.prototype.add=function(t){var n;if("string"==typeof t)n=s(t),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type?(this.reconstructor=new c(n),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",n)):this.emit("decoded",n);else{if(!xe(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,this.emit("decoded",n))}},i.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},c.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=je.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},c.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}),Me=require("./transports/index"),Ye=require("component-emitter"),qe=require("debug")("engine.io-client:socket"),Fe=require("indexof"),ze=require("engine.io-parser"),He=require("parseuri"),Ve=require("parsejson"),Je=require("parseqs");module.exports=A,A.priorWebsocketSuccess=!1,Ye(A.prototype),A.protocol=ze.protocol,A.Socket=A,A.Transport=require("./transport"),A.transports=require("./transports/index"),A.parser=require("engine.io-parser"),A.prototype.createTransport=function(t){qe('creating transport "%s"',t);var e=k(this.query);e.EIO=ze.protocol,e.transport=t;var n=this.transportOptions[t]||{};return this.id&&(e.sid=this.id),new Me[t]({query:e,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0})},A.prototype.open=function(){var t;if(this.rememberUpgrade&&A.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout(function(){e.emit("error","No transports available")},0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},A.prototype.setTransport=function(t){qe("setting transport %s",t.name);var e=this;this.transport&&(qe("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},A.prototype.probe=function(t){function e(){if(u.onlyBinaryUpgrades){var e=!this.supportsBinary&&u.transport.supportsBinary;h=h||e}h||(qe('probe transport "%s" opened',t),c.send([{type:"ping",data:"probe"}]),c.once("packet",function(e){if(!h)if("pong"===e.type&&"probe"===e.data){if(qe('probe transport "%s" pong',t),u.upgrading=!0,u.emit("upgrading",c),!c)return;A.priorWebsocketSuccess="websocket"===c.name,qe('pausing current transport "%s"',u.transport.name),u.transport.pause(function(){h||"closed"!==u.readyState&&(qe("changing transport and sending upgrade packet"),a(),u.setTransport(c),c.send([{type:"upgrade"}]),u.emit("upgrade",c),c=null,u.upgrading=!1,u.flush())})}else{qe('probe transport "%s" failed',t);var n=new Error("probe error");n.transport=c.name,u.emit("upgradeError",n)}}))}function n(){h||(h=!0,a(),c.close(),c=null)}function r(e){var r=new Error("probe error: "+e);r.transport=c.name,n(),qe('probe transport "%s" failed because of error: %s',t,e),u.emit("upgradeError",r)}function o(){r("transport closed")}function i(){r("socket closed")}function s(t){c&&t.name!==c.name&&(qe('"%s" works - aborting "%s"',t.name,c.name),n())}function a(){c.removeListener("open",e),c.removeListener("error",r),c.removeListener("close",o),u.removeListener("close",i),u.removeListener("upgrading",s)}qe('probing transport "%s"',t);var c=this.createTransport(t,{probe:1}),h=!1,u=this;A.priorWebsocketSuccess=!1,c.once("open",e),c.once("error",r),c.once("close",o),this.once("close",i),this.once("upgrading",s),c.open()},A.prototype.onOpen=function(){if(qe("socket open"),this.readyState="open",A.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){qe("starting upgrade probes");for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},A.prototype.onPacket=function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(qe('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(Ve(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data)}else qe('packet received with socket readyState "%s"',this.readyState)},A.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},A.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){"closed"!==e.readyState&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},A.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){qe("writing ping packet - expecting pong within %sms",t.pingTimeout),t.ping(),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},A.prototype.ping=function(){var t=this;this.sendPacket("ping",function(){t.emit("ping")})},A.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},A.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(qe("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},A.prototype.write=A.prototype.send=function(t,e,n){return this.sendPacket("message",t,e,n),this},A.prototype.sendPacket=function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:t,data:e,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},A.prototype.close=function(){function t(){r.onClose("forced close"),qe("socket closing - telling transport to close"),r.transport.close()}function e(){r.removeListener("upgrade",e),r.removeListener("upgradeError",e),t()}function n(){r.once("upgrade",e),r.once("upgradeError",e)}if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var r=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?n():t()}):this.upgrading?n():t()}return this},A.prototype.onError=function(t){qe("socket error %j",t),A.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},A.prototype.onClose=function(t,e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){qe('socket close with reason: "%s"',t);var n=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",t,e),n.writeBuffer=[],n.prevBufferLen=0}},A.prototype.filterUpgrades=function(t){for(var e=[],n=0,r=t.length;n<r;n++)~Fe(this.transports,t[n])&&e.push(t[n]);return e};var Ke=Object.freeze({}),We=[],$e=[],Xe="undefined"!=typeof Uint8Array?Uint8Array:Array,Ge=!1,Qe={}.toString,Ze=Array.isArray||function(t){return"[object Array]"==Qe.call(t)};I.TYPED_ARRAY_SUPPORT=void 0===Wt.TYPED_ARRAY_SUPPORT||Wt.TYPED_ARRAY_SUPPORT,I.poolSize=8192,I._augment=function(t){return t.__proto__=I.prototype,t},I.from=function(t,e,n){return D(null,t,e,n)},I.TYPED_ARRAY_SUPPORT&&(I.prototype.__proto__=Uint8Array.prototype,I.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&I[Symbol.species]),I.alloc=function(t,e,n){return j(null,t,e,n)},I.allocUnsafe=function(t){return x(null,t)},I.allocUnsafeSlow=function(t){return x(null,t)},I.isBuffer=_t,I.compare=function(t,e){if(!z(t)||!z(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);o<i;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},I.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},I.concat=function(t,e){if(!Ze(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return I.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=I.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var i=t[n];if(!z(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},I.byteLength=H,I.prototype._isBuffer=!0,I.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)J(this,e,e+1);return this},I.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},I.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},I.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?nt(this,0,t):V.apply(this,arguments)},I.prototype.equals=function(t){if(!z(t))throw new TypeError("Argument must be a Buffer");return this===t||0===I.compare(this,t)},I.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},I.prototype.compare=function(t,e,n,r,o){if(!z(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;for(var i=o-r,s=n-e,a=Math.min(i,s),c=this.slice(r,o),h=t.slice(e,n),u=0;u<a;++u)if(c[u]!==h[u]){i=c[u],s=h[u];break}return i<s?-1:s<i?1:0},I.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},I.prototype.indexOf=function(t,e,n){return K(this,t,e,n,!0)},I.prototype.lastIndexOf=function(t,e,n){return K(this,t,e,n,!1)},I.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return $(this,t,e,n);case"utf8":case"utf-8":return X(this,t,e,n);case"ascii":return G(this,t,e,n);case"latin1":case"binary":return Q(this,t,e,n);case"base64":return Z(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tt(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},I.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tn=4096;I.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r;if(I.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=I.prototype;else{var o=e-t;r=new I(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},I.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||ct(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},I.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||ct(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},I.prototype.readUInt8=function(t,e){return e||ct(t,1,this.length),this[t]},I.prototype.readUInt16LE=function(t,e){return e||ct(t,2,this.length),this[t]|this[t+1]<<8},I.prototype.readUInt16BE=function(t,e){return e||ct(t,2,this.length),this[t]<<8|this[t+1]},I.prototype.readUInt32LE=function(t,e){return e||ct(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},I.prototype.readUInt32BE=function(t,e){return e||ct(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},I.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||ct(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},I.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||ct(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},I.prototype.readInt8=function(t,e){return e||ct(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},I.prototype.readInt16LE=function(t,e){e||ct(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},I.prototype.readInt16BE=function(t,e){e||ct(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},I.prototype.readInt32LE=function(t,e){return e||ct(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},I.prototype.readInt32BE=function(t,e){return e||ct(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},I.prototype.readFloatLE=function(t,e){return e||ct(t,4,this.length),C(this,t,!0,23,4)},I.prototype.readFloatBE=function(t,e){return e||ct(t,4,this.length),C(this,t,!1,23,4)},I.prototype.readDoubleLE=function(t,e){return e||ct(t,8,this.length),C(this,t,!0,52,8)},I.prototype.readDoubleBE=function(t,e){return e||ct(t,8,this.length),C(this,t,!1,52,8)},I.prototype.writeUIntLE=function(t,e,n,r){t=+t,e|=0,n|=0,r||ht(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},I.prototype.writeUIntBE=function(t,e,n,r){t=+t,e|=0,n|=0,r||ht(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},I.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,1,255,0),I.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},I.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):ut(this,t,e,!0),e+2},I.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):ut(this,t,e,!1),e+2},I.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):ft(this,t,e,!0),e+4},I.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ft(this,t,e,!1),e+4},I.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);ht(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},I.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);ht(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+n},I.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,1,127,-128),I.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},I.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):ut(this,t,e,!0),e+2},I.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):ut(this,t,e,!1),e+2},I.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,4,2147483647,-2147483648),I.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ft(this,t,e,!0),e+4},I.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||ht(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),I.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ft(this,t,e,!1),e+4},I.prototype.writeFloatLE=function(t,e,n){return lt(this,t,e,!0,n)},I.prototype.writeFloatBE=function(t,e,n){return lt(this,t,e,!1,n)},I.prototype.writeDoubleLE=function(t,e,n){return dt(this,t,e,!0,n)},I.prototype.writeDoubleBE=function(t,e,n){return dt(this,t,e,!1,n)},I.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o,i=r-n;if(this===t&&n<e&&e<r)for(o=i-1;o>=0;--o)t[o+e]=this[o+n];else if(i<1e3||!I.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},I.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!I.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{var s=z(t)?t:vt(new I(t,r).toString()),a=s.length;for(i=0;i<n-e;++i)this[i+e]=s[i%a]}return this};var en=/[^+\/0-9A-Za-z-_]/g,nn=require("./utf8"),rn=require("has-binary2"),on=require("after"),sn=require("./keys");t.protocol=3;var an=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},cn=sn(an),hn={type:"error",data:"parser error"};t.encodePacket=function(t,e,n,r){if("function"==typeof e&&(r=e,e=null),"function"==typeof n&&(r=n,n=null),_t(t.data))return Pt(t,e,r);if(t.data&&(t.data.buffer||t.data)instanceof ArrayBuffer)return t.data=It(t.data),Pt(t,e,r);var o=an[t.type];return void 0!==t.data&&(o+=n?nn.encode(String(t.data),{strict:!1}):String(t.data)),r(""+o)},t.encodeBase64Packet=function(t,e){_t(t.data)||(t.data=It(t.data));var n="b"+an[t.type];return n+=t.data.toString("base64"),e(n)},t.decodePacket=function(e,n,r){if(void 0===e)return hn;var o;if("string"==typeof e)return o=e.charAt(0),"b"===o?t.decodeBase64Packet(e.substr(1),n):r&&!1===(e=Bt(e))?hn:Number(o)==o&&cn[o]?e.length>1?{type:cn[o],data:e.substring(1)}:{type:cn[o]}:hn;if("arraybuffer"===n){var i=new Uint8Array(e);return o=i[0],{type:cn[o],data:i.buffer.slice(1)}}return e instanceof ArrayBuffer&&(e=It(e)),o=e[0],{type:cn[o],data:e.slice(1)}},t.decodeBase64Packet=function(t,e){var n=cn[t.charAt(0)],r=new I(t.substr(1),"base64");if("arraybuffer"===e){for(var o=new Uint8Array(r.length),i=0;i<o.length;i++)o[i]=r[i];r=o.buffer}return{type:n,data:r}},t.encodePayload=function(e,n,r){function o(e,r){t.encodePacket(e,n,!1,function(t){r(null,Ct(t))})}return"function"==typeof n&&(r=n,n=null),n&&rn(e)?t.encodePayloadAsBinary(e,r):e.length?void St(e,o,function(t,e){return r(e.join(""))}):r("0:")},t.decodePayload=function(e,n,r){if("string"!=typeof e)return t.decodePayloadAsBinary(e,n,r);if("function"==typeof n&&(r=n,n=null),""===e)return r(hn,0,1);for(var o,i,s,a="",c=0,h=e.length;c<h;c++){var u=e.charAt(c);if(":"===u){if(""===a||a!=(o=Number(a)))return r(hn,0,1);if(i=e.substr(c+1,o),a!=i.length)return r(hn,0,1);if(i.length){if(s=t.decodePacket(i,n,!1),hn.type===s.type&&hn.data===s.data)return r(hn,0,1);if(!1===r(s,c+o,h))return}c+=o,a=""}else a+=u}return""!==a?r(hn,0,1):void 0},t.encodePayloadAsBinary=function(t,e){if(!t.length)return e(new I(0));St(t,Dt,function(t,n){return e(I.concat(n))})},t.decodePayloadAsBinary=function(e,n,r){"function"==typeof n&&(r=n,n=null);for(var o,i=e,s=[];i.length>0;){var a="",c=0===i[0];for(o=1;255!==i[o];o++){if(a.length>310)return r(hn,0,1);a+=""+i[o]}i=i.slice(a.length+1);var h=parseInt(a,10),u=i.slice(1,h+1);c&&(u=Ot(u)),s.push(u),i=i.slice(h+1)}var f=s.length;for(o=0;o<f;o++){var p=s[o];r(t.decodePacket(p,n,!0),o,f)}};var un=Object.freeze({}),fn=un&&void 0||un,pn=Ke&&void 0||Ke,ln=fn;pn.parser=ln;var dn=pn,gn=Ut,yn=jt,mn=[].slice,vn=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var n=mn.call(arguments,2);return function(){return e.apply(t,n.concat(mn.call(arguments)))}},bn={encode:function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e},decode:function(t){for(var e={},n=t.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}},wn=e(function(t,e){function n(t,e,n){this.io=t,this.nsp=e,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}var r=De("socket.io-client:socket");t.exports=n;var o={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},i=Ee.prototype.emit;Ee(n.prototype),n.prototype.subEvents=function(){if(!this.subs){var t=this.io;this.subs=[yn(t,"open",vn(this,"onopen")),yn(t,"packet",vn(this,"onpacket")),yn(t,"close",vn(this,"onclose"))]}},n.prototype.open=n.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting"),this)},n.prototype.send=function(){var t=gn(arguments);return t.unshift("message"),this.emit.apply(this,t),this},n.prototype.emit=function(t){if(o.hasOwnProperty(t))return i.apply(this,arguments),this;var e=gn(arguments),n={type:Le.EVENT,data:e};return n.options={},n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(r("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),delete this.flags,this},n.prototype.packet=function(t){t.nsp=this.nsp,this.io.packet(t)},n.prototype.onopen=function(){if(r("transport is open - connecting"),"/"!==this.nsp)if(this.query){var t="object"==typeof this.query?bn.encode(this.query):this.query;r("sending connect packet with query %s",t),this.packet({type:Le.CONNECT,query:t})}else this.packet({type:Le.CONNECT})},n.prototype.onclose=function(t){r("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",t)},n.prototype.onpacket=function(t){if(t.nsp===this.nsp)switch(t.type){case Le.CONNECT:this.onconnect();break;case Le.EVENT:case Le.BINARY_EVENT:this.onevent(t);break;case Le.ACK:case Le.BINARY_ACK:this.onack(t);break;case Le.DISCONNECT:this.ondisconnect();break;case Le.ERROR:this.emit("error",t.data)}},n.prototype.onevent=function(t){var e=t.data||[];r("emitting event %j",e),null!=t.id&&(r("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?i.apply(this,e):this.receiveBuffer.push(e)},n.prototype.ack=function(t){var e=this,n=!1;return function(){if(!n){n=!0;var o=gn(arguments);r("sending ack %j",o),e.packet({type:Le.ACK,id:t,data:o})}}},n.prototype.onack=function(t){var e=this.acks[t.id];"function"==typeof e?(r("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):r("bad ack %s",t.id)},n.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},n.prototype.emitBuffered=function(){var t;for(t=0;t<this.receiveBuffer.length;t++)i.apply(this,this.receiveBuffer[t]);for(this.receiveBuffer=[],t=0;t<this.sendBuffer.length;t++)this.packet(this.sendBuffer[t]);this.sendBuffer=[]},n.prototype.ondisconnect=function(){r("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},n.prototype.destroy=function(){if(this.subs){for(var t=0;t<this.subs.length;t++)this.subs[t].destroy();this.subs=null}this.io.destroy(this)},n.prototype.close=n.prototype.disconnect=function(){return this.connected&&(r("performing disconnect (%s)",this.nsp),this.packet({type:Le.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},n.prototype.compress=function(t){return this.flags=this.flags||{},this.flags.compress=t,this}}),En=[].indexOf,An=function(t,e){if(En)return t.indexOf(e);for(var n=0;n<t.length;++n)if(t[n]===e)return n;return-1},kn=xt;xt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},xt.prototype.reset=function(){this.attempts=0},xt.prototype.setMin=function(t){this.ms=t},xt.prototype.setMax=function(t){this.max=t},xt.prototype.setJitter=function(t){this.jitter=t};var _n=De("socket.io-client:manager"),Rn=Object.prototype.hasOwnProperty,Tn=Lt;Lt.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var t in this.nsps)Rn.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},Lt.prototype.updateSocketIds=function(){for(var t in this.nsps)Rn.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},Lt.prototype.generateId=function(t){return("/"===t?"":t+"#")+this.engine.id},Ee(Lt.prototype),Lt.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},Lt.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},Lt.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},Lt.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},Lt.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},Lt.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},Lt.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},Lt.prototype.open=Lt.prototype.connect=function(t,e){if(_n("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;_n("opening %s",this.uri),this.engine=dn(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=yn(n,"open",function(){r.onopen(),t&&t()}),i=yn(n,"error",function(e){if(_n("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",e),t){var n=new Error("Connection error");n.data=e,t(n)}else r.maybeReconnectOnOpen()});if(!1!==this._timeout){var s=this._timeout;_n("connect attempt will timeout after %d",s);var a=setTimeout(function(){_n("connect attempt timed out after %d",s),o.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",s)},s);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(o),this.subs.push(i),this},Lt.prototype.onopen=function(){_n("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(yn(t,"data",vn(this,"ondata"))),this.subs.push(yn(t,"ping",vn(this,"onping"))),this.subs.push(yn(t,"pong",vn(this,"onpong"))),this.subs.push(yn(t,"error",vn(this,"onerror"))),this.subs.push(yn(t,"close",vn(this,"onclose"))),this.subs.push(yn(this.decoder,"decoded",vn(this,"ondecoded")))},Lt.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},Lt.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},Lt.prototype.ondata=function(t){this.decoder.add(t)},Lt.prototype.ondecoded=function(t){this.emit("packet",t)},Lt.prototype.onerror=function(t){_n("error",t),this.emitAll("error",t)},Lt.prototype.socket=function(t,e){function n(){~An(o.connecting,r)||o.connecting.push(r)}var r=this.nsps[t];if(!r){r=new wn(this,t,e),this.nsps[t]=r;var o=this;r.on("connecting",n),r.on("connect",function(){r.id=o.generateId(t)}),this.autoConnect&&n()}return r},Lt.prototype.destroy=function(t){var e=An(this.connecting,t);~e&&this.connecting.splice(e,1),this.connecting.length||this.close()},Lt.prototype.packet=function(t){_n("writing packet %j",t);var e=this;t.query&&0===t.type&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(n){for(var r=0;r<n.length;r++)e.engine.write(n[r],t.options);e.encoding=!1,e.processPacketQueue()}))},Lt.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},Lt.prototype.cleanup=function(){_n("cleanup");for(var t=this.subs.length,e=0;e<t;e++)this.subs.shift().destroy();this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},Lt.prototype.close=Lt.prototype.disconnect=function(){_n("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},Lt.prototype.onclose=function(t){_n("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},Lt.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)_n("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();_n("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var n=setTimeout(function(){t.skipReconnect||(_n("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(_n("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(_n("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(n)}})}},Lt.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)};var Pn=Gt&&void 0||Gt,Bn=(e(function(t,e){function n(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var n,i=Pn(t),s=i.source,a=i.id,c=i.path,h=o[a]&&c in o[a].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||h?(r("ignoring socket cache for %s",s),n=Tn(s,e)):(o[a]||(r("new io instance for %s",s),o[a]=Tn(s,e)),n=o[a]),i.query&&!e.query&&(e.query=i.query),n.socket(i.path,e)}var r=De("socket.io-client");t.exports=e=n;var o=e.managers={};e.protocol=Le.protocol,e.connect=n,e.Manager=Tn,e.Socket=wn}),function(){function t(t){this.socket=io.connect(t),Yt.register("send",this.onSend.bind(this)),this.subscribeEvents()}return t.prototype.onSend=function(t){this.socket.emit("message",t)},t.prototype.subscribeEvents=function(){this.socket.on("message",this.onMessage.bind(this)),this.socket.on("ipaddr",this.onIp.bind(this)),this.socket.on("log",this.onLog.bind(this))},t.prototype.onIp=function(t){Yt.dispatch(Vt.LOG,"Server IP address is: "+t)},t.prototype.onLog=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Yt.dispatch(Vt.LOG,t)},t.prototype.onMessage=function(t){Yt.dispatch(t.type,t)},t}());t.default=Kt,t.EventDispatcher=Yt,t.AppEventType=Vt,t.SignalingEventType=qt,t.SocketChannel=Bn,Object.defineProperty(t,"__esModule",{value:!0})});
/// <reference types="socket.io-client" />
import 'socket.io-client';
import { Signaling } from './signaling';

@@ -3,0 +4,0 @@ import { SignalingEvent } from './event';

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

import * as io from 'socket.io-client';
import 'socket.io-client';
import { EventDispatcher } from './../dispatcher/dispatcher';

@@ -3,0 +3,0 @@ import { AppEventType } from './../event-type';

@@ -25,6 +25,3 @@ #!/usr/bin/env node

},
testMatch: [
'**/__tests__/**/*.{t,j}s',
'**/?(*.)(spec|test).{t,j}s'
],
testMatch: ['**/?(*.)(spec|test).{t,j}s'],
testPathIgnorePatterns: [

@@ -31,0 +28,0 @@ '<rootDir>/(node_modules|lib|es|dist)'

/// <reference types="socket.io-client" />
import 'socket.io-client';
import { Signaling } from './signaling';

@@ -3,0 +4,0 @@ import { SignalingEvent } from './event';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var io = require("socket.io-client");
require("socket.io-client");
var dispatcher_1 = require("./../dispatcher/dispatcher");

@@ -5,0 +5,0 @@ var event_type_1 = require("./../event-type");

{
"name": "peer-data",
"version": "1.2.8",
"version": "1.2.9",
"description": "PeerData - library for files, media streaming/sharing using WebRTC",

@@ -58,3 +58,3 @@ "scripts": {

"@types/jest": "^19.2.4",
"@types/node": "^7.0.23",
"@types/node": "^7.0.31",
"@types/socket.io-client": "^1.4.29",

@@ -68,3 +68,3 @@ "@types/webrtc": "^0.0.21",

"rimraf": "^2.6.1",
"rollup": "^0.41.6",
"rollup": "^0.43.0",
"rollup-plugin-commonjs": "^8.0.2",

@@ -74,13 +74,13 @@ "rollup-plugin-node-builtins": "^2.1.2",

"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-uglify": "^2.0.1",
"semver": "^5.3.0",
"ts-jest": "^20.0.5",
"socket.io-client": "^2.0.3",
"ts-jest": "^20.0.6",
"tslib": "^1.7.1",
"tslint": "^5.4.2",
"tslint": "^5.4.3",
"typescript": "^2.3.4"
},
"dependencies": {
"webrtc-adapter": "^3.4.3"
"webrtc-adapter": "^4.0.1"
}
}

@@ -1,23 +0,15 @@

import sourcemaps from 'rollup-plugin-sourcemaps';
import resolve from 'rollup-plugin-node-resolve';
import globals from 'rollup-plugin-node-globals';
import builtins from 'rollup-plugin-node-builtins';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import resolve from "rollup-plugin-node-resolve";
import globals from "rollup-plugin-node-globals";
import builtins from "rollup-plugin-node-builtins";
import commonjs from "rollup-plugin-commonjs";
import uglify from "rollup-plugin-uglify";
export default {
format: 'umd',
moduleName: 'peer-data',
entry: 'es/index.js',
dest: 'dist/peer-data.js',
exports: 'named',
sourceMap: true,
globals: {
'socket.io-client': 'io'
},
format: "umd",
moduleName: "peer-data",
entry: "es/index.js",
dest: "dist/peer-data.js",
exports: "named",
plugins: [
sourcemaps(),
resolve({
jsnext: true
}),
resolve({ jsnext: true }),
globals(),

@@ -24,0 +16,0 @@ builtins(),

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 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