12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204 |
- /*!
- * Socket.IO v4.4.1
- * (c) 2014-2022 Guillermo Rauch
- * Released under the MIT License.
- */
- !(function (t, e) {
- 'object' == typeof exports && 'undefined' != typeof module
- ? (module.exports = e())
- : 'function' == typeof define && define.amd
- ? define(e)
- : ((t = 'undefined' != typeof globalThis ? globalThis : t || self).io = e())
- })(this, function () {
- 'use strict'
- function t(t, e) {
- return (
- e.forEach(function (e) {
- Object.keys(e).forEach(function (n) {
- if ('default' !== n && !(n in t)) {
- var r = Object.getOwnPropertyDescriptor(e, n)
- Object.defineProperty(
- t,
- n,
- r.get
- ? r
- : {
- enumerable: !0,
- get: function () {
- return e[n]
- },
- }
- )
- }
- })
- }),
- Object.freeze(t)
- )
- }
- function e(t) {
- return (
- (e =
- 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
- ? function (t) {
- return typeof t
- }
- : function (t) {
- return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t
- }),
- e(t)
- )
- }
- function n(t, e) {
- if (!(t instanceof e)) throw new TypeError('Cannot call a class as a function')
- }
- function r(t, e) {
- for (var n = 0; n < e.length; n++) {
- var r = e[n]
- ;(r.enumerable = r.enumerable || !1), (r.configurable = !0), 'value' in r && (r.writable = !0), Object.defineProperty(t, r.key, r)
- }
- }
- function i(t, e, n) {
- return e && r(t.prototype, e), n && r(t, n), t
- }
- function o() {
- return (
- (o =
- Object.assign ||
- function (t) {
- for (var e = 1; e < arguments.length; e++) {
- var n = arguments[e]
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r])
- }
- return t
- }),
- o.apply(this, arguments)
- )
- }
- function s(t, e) {
- if ('function' != typeof e && null !== e) throw new TypeError('Super expression must either be null or a function')
- ;(t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && c(t, e)
- }
- function a(t) {
- return (
- (a = Object.setPrototypeOf
- ? Object.getPrototypeOf
- : function (t) {
- return t.__proto__ || Object.getPrototypeOf(t)
- }),
- a(t)
- )
- }
- function c(t, e) {
- return (
- (c =
- Object.setPrototypeOf ||
- function (t, e) {
- return (t.__proto__ = e), t
- }),
- c(t, e)
- )
- }
- function h(t) {
- if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
- return t
- }
- function u(t, e) {
- if (e && ('object' == typeof e || 'function' == typeof e)) return e
- if (void 0 !== e) throw new TypeError('Derived constructors may only return object or undefined')
- return h(t)
- }
- function f(t) {
- var e = (function () {
- if ('undefined' == typeof Reflect || !Reflect.construct) return !1
- if (Reflect.construct.sham) return !1
- if ('function' == typeof Proxy) return !0
- try {
- return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0
- } catch (t) {
- return !1
- }
- })()
- return function () {
- var n,
- r = a(t)
- if (e) {
- var i = a(this).constructor
- n = Reflect.construct(r, arguments, i)
- } else n = r.apply(this, arguments)
- return u(this, n)
- }
- }
- function p(t, e, n) {
- return (
- (p =
- 'undefined' != typeof Reflect && Reflect.get
- ? Reflect.get
- : function (t, e, n) {
- var r = (function (t, e) {
- for (; !Object.prototype.hasOwnProperty.call(t, e) && null !== (t = a(t)); );
- return t
- })(t, e)
- if (r) {
- var i = Object.getOwnPropertyDescriptor(r, e)
- return i.get ? i.get.call(n) : i.value
- }
- }),
- p(t, e, n || t)
- )
- }
- function l(t, e) {
- ;(null == e || e > t.length) && (e = t.length)
- for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]
- return r
- }
- function d(t, e) {
- var n = ('undefined' != typeof Symbol && t[Symbol.iterator]) || t['@@iterator']
- if (!n) {
- if (
- Array.isArray(t) ||
- (n = (function (t, e) {
- if (t) {
- if ('string' == typeof t) return l(t, e)
- var n = Object.prototype.toString.call(t).slice(8, -1)
- return (
- 'Object' === n && t.constructor && (n = t.constructor.name),
- 'Map' === n || 'Set' === n ? Array.from(t) : 'Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? l(t, e) : void 0
- )
- }
- })(t)) ||
- (e && t && 'number' == typeof t.length)
- ) {
- n && (t = n)
- var r = 0,
- i = function () {}
- return {
- s: i,
- n: function () {
- return r >= t.length ? { done: !0 } : { done: !1, value: t[r++] }
- },
- e: function (t) {
- throw t
- },
- f: i,
- }
- }
- throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.')
- }
- var o,
- s = !0,
- a = !1
- return {
- s: function () {
- n = n.call(t)
- },
- n: function () {
- var t = n.next()
- return (s = t.done), t
- },
- e: function (t) {
- ;(a = !0), (o = t)
- },
- f: function () {
- try {
- s || null == n.return || n.return()
- } finally {
- if (a) throw o
- }
- },
- }
- }
- var y =
- /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
- v = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],
- g = function (t) {
- var e = t,
- n = t.indexOf('['),
- r = t.indexOf(']')
- ;-1 != n && -1 != r && (t = t.substring(0, n) + t.substring(n, r).replace(/:/g, ';') + t.substring(r, t.length))
- for (var i, o, s = y.exec(t || ''), a = {}, c = 14; c--; ) a[v[c]] = s[c] || ''
- return (
- -1 != n &&
- -1 != r &&
- ((a.source = e),
- (a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ':')),
- (a.authority = a.authority.replace('[', '').replace(']', '').replace(/;/g, ':')),
- (a.ipv6uri = !0)),
- (a.pathNames = (function (t, e) {
- var n = /\/{2,9}/g,
- r = e.replace(n, '/').split('/')
- ;('/' != e.substr(0, 1) && 0 !== e.length) || r.splice(0, 1)
- '/' == e.substr(e.length - 1, 1) && r.splice(r.length - 1, 1)
- return r
- })(0, a.path)),
- (a.queryKey =
- ((i = a.query),
- (o = {}),
- i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (t, e, n) {
- e && (o[e] = n)
- }),
- o)),
- a
- )
- }
- var m = { exports: {} }
- try {
- m.exports = 'undefined' != typeof XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()
- } catch (t) {
- m.exports = !1
- }
- var _ = m.exports,
- b = 'undefined' != typeof self ? self : 'undefined' != typeof window ? window : Function('return this')()
- function k(t) {
- var e = t.xdomain
- try {
- if ('undefined' != typeof XMLHttpRequest && (!e || _)) return new XMLHttpRequest()
- } catch (t) {}
- if (!e)
- try {
- return new b[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP')
- } catch (t) {}
- }
- function w(t) {
- for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r]
- return n.reduce(function (e, n) {
- return t.hasOwnProperty(n) && (e[n] = t[n]), e
- }, {})
- }
- var E = setTimeout,
- C = clearTimeout
- function O(t, e) {
- e.useNativeTimers ? ((t.setTimeoutFn = E.bind(b)), (t.clearTimeoutFn = C.bind(b))) : ((t.setTimeoutFn = setTimeout.bind(b)), (t.clearTimeoutFn = clearTimeout.bind(b)))
- }
- var T = S
- function S(t) {
- if (t)
- return (function (t) {
- for (var e in S.prototype) t[e] = S.prototype[e]
- return t
- })(t)
- }
- ;(S.prototype.on = S.prototype.addEventListener =
- function (t, e) {
- return (this._callbacks = this._callbacks || {}), (this._callbacks['$' + t] = this._callbacks['$' + t] || []).push(e), this
- }),
- (S.prototype.once = function (t, e) {
- function n() {
- this.off(t, n), e.apply(this, arguments)
- }
- return (n.fn = e), this.on(t, n), this
- }),
- (S.prototype.off =
- S.prototype.removeListener =
- S.prototype.removeAllListeners =
- S.prototype.removeEventListener =
- function (t, e) {
- if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) return (this._callbacks = {}), this
- var n,
- r = this._callbacks['$' + t]
- if (!r) return this
- if (1 == arguments.length) return delete this._callbacks['$' + t], this
- for (var i = 0; i < r.length; i++)
- if ((n = r[i]) === e || n.fn === e) {
- r.splice(i, 1)
- break
- }
- return 0 === r.length && delete this._callbacks['$' + t], this
- }),
- (S.prototype.emit = function (t) {
- this._callbacks = this._callbacks || {}
- for (var e = new Array(arguments.length - 1), n = this._callbacks['$' + t], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]
- if (n) {
- r = 0
- for (var i = (n = n.slice(0)).length; r < i; ++r) n[r].apply(this, e)
- }
- return this
- }),
- (S.prototype.emitReserved = S.prototype.emit),
- (S.prototype.listeners = function (t) {
- return (this._callbacks = this._callbacks || {}), this._callbacks['$' + t] || []
- }),
- (S.prototype.hasListeners = function (t) {
- return !!this.listeners(t).length
- })
- var R = Object.create(null)
- ;(R.open = '0'), (R.close = '1'), (R.ping = '2'), (R.pong = '3'), (R.message = '4'), (R.upgrade = '5'), (R.noop = '6')
- var A = Object.create(null)
- Object.keys(R).forEach(function (t) {
- A[R[t]] = t
- })
- for (
- var x = { type: 'error', data: 'parser error' },
- U = 'function' == typeof Blob || ('undefined' != typeof Blob && '[object BlobConstructor]' === Object.prototype.toString.call(Blob)),
- L = 'function' == typeof ArrayBuffer,
- B = function (t, e, n) {
- var r,
- i = t.type,
- o = t.data
- return U && o instanceof Blob
- ? e
- ? n(o)
- : j(o, n)
- : L && (o instanceof ArrayBuffer || ((r = o), 'function' == typeof ArrayBuffer.isView ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer))
- ? e
- ? n(o)
- : j(new Blob([o]), n)
- : n(R[i] + (o || ''))
- },
- j = function (t, e) {
- var n = new FileReader()
- return (
- (n.onload = function () {
- var t = n.result.split(',')[1]
- e('b' + t)
- }),
- n.readAsDataURL(t)
- )
- },
- N = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
- P = 'undefined' == typeof Uint8Array ? [] : new Uint8Array(256),
- q = 0;
- q < N.length;
- q++
- )
- P[N.charCodeAt(q)] = q
- var D,
- I = 'function' == typeof ArrayBuffer,
- M = function (t, e) {
- if ('string' != typeof t) return { type: 'message', data: H(t, e) }
- var n = t.charAt(0)
- return 'b' === n ? { type: 'message', data: F(t.substring(1), e) } : A[n] ? (t.length > 1 ? { type: A[n], data: t.substring(1) } : { type: A[n] }) : x
- },
- F = function (t, e) {
- if (I) {
- var n = (function (t) {
- var e,
- n,
- r,
- i,
- o,
- s = 0.75 * t.length,
- a = t.length,
- c = 0
- '=' === t[t.length - 1] && (s--, '=' === t[t.length - 2] && s--)
- var h = new ArrayBuffer(s),
- u = new Uint8Array(h)
- for (e = 0; e < a; e += 4)
- (n = P[t.charCodeAt(e)]),
- (r = P[t.charCodeAt(e + 1)]),
- (i = P[t.charCodeAt(e + 2)]),
- (o = P[t.charCodeAt(e + 3)]),
- (u[c++] = (n << 2) | (r >> 4)),
- (u[c++] = ((15 & r) << 4) | (i >> 2)),
- (u[c++] = ((3 & i) << 6) | (63 & o))
- return h
- })(t)
- return H(n, e)
- }
- return { base64: !0, data: t }
- },
- H = function (t, e) {
- return 'blob' === e && t instanceof ArrayBuffer ? new Blob([t]) : t
- },
- $ = String.fromCharCode(30),
- z = (function (t) {
- s(r, t)
- var e = f(r)
- function r(t) {
- var i
- return n(this, r), ((i = e.call(this)).writable = !1), O(h(i), t), (i.opts = t), (i.query = t.query), (i.readyState = ''), (i.socket = t.socket), i
- }
- return (
- i(r, [
- {
- key: 'onError',
- value: function (t, e) {
- var n = new Error(t)
- return (n.type = 'TransportError'), (n.description = e), p(a(r.prototype), 'emit', this).call(this, 'error', n), this
- },
- },
- {
- key: 'open',
- value: function () {
- return ('closed' !== this.readyState && '' !== this.readyState) || ((this.readyState = 'opening'), this.doOpen()), this
- },
- },
- {
- key: 'close',
- value: function () {
- return ('opening' !== this.readyState && 'open' !== this.readyState) || (this.doClose(), this.onClose()), this
- },
- },
- {
- key: 'send',
- value: function (t) {
- 'open' === this.readyState && this.write(t)
- },
- },
- {
- key: 'onOpen',
- value: function () {
- ;(this.readyState = 'open'), (this.writable = !0), p(a(r.prototype), 'emit', this).call(this, 'open')
- },
- },
- {
- key: 'onData',
- value: function (t) {
- var e = M(t, this.socket.binaryType)
- this.onPacket(e)
- },
- },
- {
- key: 'onPacket',
- value: function (t) {
- p(a(r.prototype), 'emit', this).call(this, 'packet', t)
- },
- },
- {
- key: 'onClose',
- value: function () {
- ;(this.readyState = 'closed'), p(a(r.prototype), 'emit', this).call(this, 'close')
- },
- },
- ]),
- r
- )
- })(T),
- V = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''),
- W = {},
- X = 0,
- K = 0
- function J(t) {
- var e = ''
- do {
- ;(e = V[t % 64] + e), (t = Math.floor(t / 64))
- } while (t > 0)
- return e
- }
- function Y() {
- var t = J(+new Date())
- return t !== D ? ((X = 0), (D = t)) : t + '.' + J(X++)
- }
- for (; K < 64; K++) W[V[K]] = K
- ;(Y.encode = J),
- (Y.decode = function (t) {
- var e = 0
- for (K = 0; K < t.length; K++) e = 64 * e + W[t.charAt(K)]
- return e
- })
- var G = Y,
- Q = {
- 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, i = n.length; r < i; r++) {
- var o = n[r].split('=')
- e[decodeURIComponent(o[0])] = decodeURIComponent(o[1])
- }
- return e
- },
- },
- Z = (function (t) {
- s(r, t)
- var e = f(r)
- function r() {
- var t
- return n(this, r), ((t = e.apply(this, arguments)).polling = !1), t
- }
- return (
- i(r, [
- {
- key: 'name',
- get: function () {
- return 'polling'
- },
- },
- {
- key: 'doOpen',
- value: function () {
- this.poll()
- },
- },
- {
- key: 'pause',
- value: function (t) {
- var e = this
- this.readyState = 'pausing'
- var n = function () {
- ;(e.readyState = 'paused'), t()
- }
- if (this.polling || !this.writable) {
- var r = 0
- this.polling &&
- (r++,
- this.once('pollComplete', function () {
- --r || n()
- })),
- this.writable ||
- (r++,
- this.once('drain', function () {
- --r || n()
- }))
- } else n()
- },
- },
- {
- key: 'poll',
- value: function () {
- ;(this.polling = !0), this.doPoll(), this.emit('poll')
- },
- },
- {
- key: 'onData',
- value: function (t) {
- var e = this
- ;(function (t, e) {
- for (var n = t.split($), r = [], i = 0; i < n.length; i++) {
- var o = M(n[i], e)
- if ((r.push(o), 'error' === o.type)) break
- }
- return r
- })(t, this.socket.binaryType).forEach(function (t) {
- if (('opening' === e.readyState && 'open' === t.type && e.onOpen(), 'close' === t.type)) return e.onClose(), !1
- e.onPacket(t)
- }),
- 'closed' !== this.readyState && ((this.polling = !1), this.emit('pollComplete'), 'open' === this.readyState && this.poll())
- },
- },
- {
- key: 'doClose',
- value: function () {
- var t = this,
- e = function () {
- t.write([{ type: 'close' }])
- }
- 'open' === this.readyState ? e() : this.once('open', e)
- },
- },
- {
- key: 'write',
- value: function (t) {
- var e = this
- ;(this.writable = !1),
- (function (t, e) {
- var n = t.length,
- r = new Array(n),
- i = 0
- t.forEach(function (t, o) {
- B(t, !1, function (t) {
- ;(r[o] = t), ++i === n && e(r.join($))
- })
- })
- })(t, function (t) {
- e.doWrite(t, function () {
- ;(e.writable = !0), e.emit('drain')
- })
- })
- },
- },
- {
- key: 'uri',
- value: function () {
- var t = this.query || {},
- e = this.opts.secure ? 'https' : 'http',
- n = ''
- !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = G()),
- this.supportsBinary || t.sid || (t.b64 = 1),
- this.opts.port && (('https' === e && 443 !== Number(this.opts.port)) || ('http' === e && 80 !== Number(this.opts.port))) && (n = ':' + this.opts.port)
- var r = Q.encode(t)
- return e + '://' + (-1 !== this.opts.hostname.indexOf(':') ? '[' + this.opts.hostname + ']' : this.opts.hostname) + n + this.opts.path + (r.length ? '?' + r : '')
- },
- },
- ]),
- r
- )
- })(z)
- function tt() {}
- var et = null != new k({ xdomain: !1 }).responseType,
- nt = (function (t) {
- s(r, t)
- var e = f(r)
- function r(t) {
- var i
- if ((n(this, r), (i = e.call(this, t)), 'undefined' != typeof location)) {
- var o = 'https:' === location.protocol,
- s = location.port
- s || (s = o ? '443' : '80'), (i.xd = ('undefined' != typeof location && t.hostname !== location.hostname) || s !== t.port), (i.xs = t.secure !== o)
- }
- var a = t && t.forceBase64
- return (i.supportsBinary = et && !a), i
- }
- return (
- i(r, [
- {
- key: 'request',
- value: function () {
- var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}
- return o(t, { xd: this.xd, xs: this.xs }, this.opts), new rt(this.uri(), t)
- },
- },
- {
- key: 'doWrite',
- value: function (t, e) {
- var n = this,
- r = this.request({ method: 'POST', data: t })
- r.on('success', e),
- r.on('error', function (t) {
- n.onError('xhr post error', t)
- })
- },
- },
- {
- key: 'doPoll',
- value: function () {
- var t = this,
- e = this.request()
- e.on('data', this.onData.bind(this)),
- e.on('error', function (e) {
- t.onError('xhr poll error', e)
- }),
- (this.pollXhr = e)
- },
- },
- ]),
- r
- )
- })(Z),
- rt = (function (t) {
- s(r, t)
- var e = f(r)
- function r(t, i) {
- var o
- return (
- n(this, r),
- O(h((o = e.call(this))), i),
- (o.opts = i),
- (o.method = i.method || 'GET'),
- (o.uri = t),
- (o.async = !1 !== i.async),
- (o.data = void 0 !== i.data ? i.data : null),
- o.create(),
- o
- )
- }
- return (
- i(r, [
- {
- key: 'create',
- value: function () {
- var t = this,
- e = w(this.opts, 'agent', 'pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'autoUnref')
- ;(e.xdomain = !!this.opts.xd), (e.xscheme = !!this.opts.xs)
- var n = (this.xhr = new k(e))
- try {
- n.open(this.method, this.uri, this.async)
- try {
- if (this.opts.extraHeaders)
- for (var i in (n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0), this.opts.extraHeaders))
- this.opts.extraHeaders.hasOwnProperty(i) && n.setRequestHeader(i, this.opts.extraHeaders[i])
- } catch (t) {}
- if ('POST' === this.method)
- try {
- n.setRequestHeader('Content-type', 'text/plain;charset=UTF-8')
- } catch (t) {}
- try {
- n.setRequestHeader('Accept', '*/*')
- } catch (t) {}
- 'withCredentials' in n && (n.withCredentials = this.opts.withCredentials),
- this.opts.requestTimeout && (n.timeout = this.opts.requestTimeout),
- (n.onreadystatechange = function () {
- 4 === n.readyState &&
- (200 === n.status || 1223 === n.status
- ? t.onLoad()
- : t.setTimeoutFn(function () {
- t.onError('number' == typeof n.status ? n.status : 0)
- }, 0))
- }),
- n.send(this.data)
- } catch (e) {
- return void this.setTimeoutFn(function () {
- t.onError(e)
- }, 0)
- }
- 'undefined' != typeof document && ((this.index = r.requestsCount++), (r.requests[this.index] = this))
- },
- },
- {
- key: 'onSuccess',
- value: function () {
- this.emit('success'), this.cleanup()
- },
- },
- {
- key: 'onData',
- value: function (t) {
- this.emit('data', t), this.onSuccess()
- },
- },
- {
- key: 'onError',
- value: function (t) {
- this.emit('error', t), this.cleanup(!0)
- },
- },
- {
- key: 'cleanup',
- value: function (t) {
- if (void 0 !== this.xhr && null !== this.xhr) {
- if (((this.xhr.onreadystatechange = tt), t))
- try {
- this.xhr.abort()
- } catch (t) {}
- 'undefined' != typeof document && delete r.requests[this.index], (this.xhr = null)
- }
- },
- },
- {
- key: 'onLoad',
- value: function () {
- var t = this.xhr.responseText
- null !== t && this.onData(t)
- },
- },
- {
- key: 'abort',
- value: function () {
- this.cleanup()
- },
- },
- ]),
- r
- )
- })(T)
- if (((rt.requestsCount = 0), (rt.requests = {}), 'undefined' != typeof document))
- if ('function' == typeof attachEvent) attachEvent('onunload', it)
- else if ('function' == typeof addEventListener) {
- addEventListener('onpagehide' in b ? 'pagehide' : 'unload', it, !1)
- }
- function it() {
- for (var t in rt.requests) rt.requests.hasOwnProperty(t) && rt.requests[t].abort()
- }
- var ot =
- 'function' == typeof Promise && 'function' == typeof Promise.resolve
- ? function (t) {
- return Promise.resolve().then(t)
- }
- : function (t, e) {
- return e(t, 0)
- },
- st = b.WebSocket || b.MozWebSocket,
- at = 'undefined' != typeof navigator && 'string' == typeof navigator.product && 'reactnative' === navigator.product.toLowerCase(),
- ct = (function (t) {
- s(r, t)
- var e = f(r)
- function r(t) {
- var i
- return n(this, r), ((i = e.call(this, t)).supportsBinary = !t.forceBase64), i
- }
- return (
- i(r, [
- {
- key: 'name',
- get: function () {
- return 'websocket'
- },
- },
- {
- key: 'doOpen',
- value: function () {
- if (this.check()) {
- var t = this.uri(),
- e = this.opts.protocols,
- n = at
- ? {}
- : w(
- this.opts,
- 'agent',
- 'perMessageDeflate',
- 'pfx',
- 'key',
- 'passphrase',
- 'cert',
- 'ca',
- 'ciphers',
- 'rejectUnauthorized',
- 'localAddress',
- 'protocolVersion',
- 'origin',
- 'maxPayload',
- 'family',
- 'checkServerIdentity'
- )
- this.opts.extraHeaders && (n.headers = this.opts.extraHeaders)
- try {
- this.ws = at ? new st(t, e, n) : e ? new st(t, e) : new st(t)
- } catch (t) {
- return this.emit('error', t)
- }
- ;(this.ws.binaryType = this.socket.binaryType || 'arraybuffer'), this.addEventListeners()
- }
- },
- },
- {
- key: 'addEventListeners',
- value: function () {
- var t = this
- ;(this.ws.onopen = function () {
- t.opts.autoUnref && t.ws._socket.unref(), t.onOpen()
- }),
- (this.ws.onclose = this.onClose.bind(this)),
- (this.ws.onmessage = function (e) {
- return t.onData(e.data)
- }),
- (this.ws.onerror = function (e) {
- return t.onError('websocket error', e)
- })
- },
- },
- {
- key: 'write',
- value: function (t) {
- var e = this
- this.writable = !1
- for (
- var n = function (n) {
- var r = t[n],
- i = n === t.length - 1
- B(r, e.supportsBinary, function (t) {
- try {
- e.ws.send(t)
- } catch (t) {}
- i &&
- ot(function () {
- ;(e.writable = !0), e.emit('drain')
- }, e.setTimeoutFn)
- })
- },
- r = 0;
- r < t.length;
- r++
- )
- n(r)
- },
- },
- {
- key: 'doClose',
- value: function () {
- void 0 !== this.ws && (this.ws.close(), (this.ws = null))
- },
- },
- {
- key: 'uri',
- value: function () {
- var t = this.query || {},
- e = this.opts.secure ? 'wss' : 'ws',
- n = ''
- this.opts.port && (('wss' === e && 443 !== Number(this.opts.port)) || ('ws' === e && 80 !== Number(this.opts.port))) && (n = ':' + this.opts.port),
- this.opts.timestampRequests && (t[this.opts.timestampParam] = G()),
- this.supportsBinary || (t.b64 = 1)
- var r = Q.encode(t)
- return e + '://' + (-1 !== this.opts.hostname.indexOf(':') ? '[' + this.opts.hostname + ']' : this.opts.hostname) + n + this.opts.path + (r.length ? '?' + r : '')
- },
- },
- {
- key: 'check',
- value: function () {
- return !(!st || ('__initialize' in st && this.name === r.prototype.name))
- },
- },
- ]),
- r
- )
- })(z),
- ht = { websocket: ct, polling: nt },
- ut = (function (t) {
- s(a, t)
- var r = f(a)
- function a(t) {
- var i,
- s = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}
- return (
- n(this, a),
- (i = r.call(this)),
- t && 'object' === e(t) && ((s = t), (t = null)),
- t
- ? ((t = g(t)), (s.hostname = t.host), (s.secure = 'https' === t.protocol || 'wss' === t.protocol), (s.port = t.port), t.query && (s.query = t.query))
- : s.host && (s.hostname = g(s.host).host),
- O(h(i), s),
- (i.secure = null != s.secure ? s.secure : 'undefined' != typeof location && 'https:' === location.protocol),
- s.hostname && !s.port && (s.port = i.secure ? '443' : '80'),
- (i.hostname = s.hostname || ('undefined' != typeof location ? location.hostname : 'localhost')),
- (i.port = s.port || ('undefined' != typeof location && location.port ? location.port : i.secure ? '443' : '80')),
- (i.transports = s.transports || ['polling', 'websocket']),
- (i.readyState = ''),
- (i.writeBuffer = []),
- (i.prevBufferLen = 0),
- (i.opts = o(
- {
- path: '/engine.io',
- agent: !1,
- withCredentials: !1,
- upgrade: !0,
- timestampParam: 't',
- rememberUpgrade: !1,
- rejectUnauthorized: !0,
- perMessageDeflate: { threshold: 1024 },
- transportOptions: {},
- closeOnBeforeunload: !0,
- },
- s
- )),
- (i.opts.path = i.opts.path.replace(/\/$/, '') + '/'),
- 'string' == typeof i.opts.query && (i.opts.query = Q.decode(i.opts.query)),
- (i.id = null),
- (i.upgrades = null),
- (i.pingInterval = null),
- (i.pingTimeout = null),
- (i.pingTimeoutTimer = null),
- 'function' == typeof addEventListener &&
- (i.opts.closeOnBeforeunload &&
- addEventListener(
- 'beforeunload',
- function () {
- i.transport && (i.transport.removeAllListeners(), i.transport.close())
- },
- !1
- ),
- 'localhost' !== i.hostname &&
- ((i.offlineEventListener = function () {
- i.onClose('transport close')
- }),
- addEventListener('offline', i.offlineEventListener, !1))),
- i.open(),
- i
- )
- }
- return (
- i(a, [
- {
- key: 'createTransport',
- value: function (t) {
- var e = (function (t) {
- var e = {}
- for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
- return e
- })(this.opts.query)
- ;(e.EIO = 4), (e.transport = t), this.id && (e.sid = this.id)
- var n = o({}, this.opts.transportOptions[t], this.opts, { query: e, socket: this, hostname: this.hostname, secure: this.secure, port: this.port })
- return new ht[t](n)
- },
- },
- {
- key: 'open',
- value: function () {
- var t,
- e = this
- if (this.opts.rememberUpgrade && a.priorWebsocketSuccess && -1 !== this.transports.indexOf('websocket')) t = 'websocket'
- else {
- if (0 === this.transports.length)
- return void this.setTimeoutFn(function () {
- e.emitReserved('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)
- },
- },
- {
- key: 'setTransport',
- value: function (t) {
- var e = this
- this.transport && this.transport.removeAllListeners(),
- (this.transport = t),
- t
- .on('drain', this.onDrain.bind(this))
- .on('packet', this.onPacket.bind(this))
- .on('error', this.onError.bind(this))
- .on('close', function () {
- e.onClose('transport close')
- })
- },
- },
- {
- key: 'probe',
- value: function (t) {
- var e = this,
- n = this.createTransport(t),
- r = !1
- a.priorWebsocketSuccess = !1
- var i = function () {
- r ||
- (n.send([{ type: 'ping', data: 'probe' }]),
- n.once('packet', function (t) {
- if (!r)
- if ('pong' === t.type && 'probe' === t.data) {
- if (((e.upgrading = !0), e.emitReserved('upgrading', n), !n)) return
- ;(a.priorWebsocketSuccess = 'websocket' === n.name),
- e.transport.pause(function () {
- r ||
- ('closed' !== e.readyState &&
- (f(), e.setTransport(n), n.send([{ type: 'upgrade' }]), e.emitReserved('upgrade', n), (n = null), (e.upgrading = !1), e.flush()))
- })
- } else {
- var i = new Error('probe error')
- ;(i.transport = n.name), e.emitReserved('upgradeError', i)
- }
- }))
- }
- function o() {
- r || ((r = !0), f(), n.close(), (n = null))
- }
- var s = function (t) {
- var r = new Error('probe error: ' + t)
- ;(r.transport = n.name), o(), e.emitReserved('upgradeError', r)
- }
- function c() {
- s('transport closed')
- }
- function h() {
- s('socket closed')
- }
- function u(t) {
- n && t.name !== n.name && o()
- }
- var f = function () {
- n.removeListener('open', i), n.removeListener('error', s), n.removeListener('close', c), e.off('close', h), e.off('upgrading', u)
- }
- n.once('open', i), n.once('error', s), n.once('close', c), this.once('close', h), this.once('upgrading', u), n.open()
- },
- },
- {
- key: 'onOpen',
- value: function () {
- if (
- ((this.readyState = 'open'),
- (a.priorWebsocketSuccess = 'websocket' === this.transport.name),
- this.emitReserved('open'),
- this.flush(),
- 'open' === this.readyState && this.opts.upgrade && this.transport.pause)
- )
- for (var t = 0, e = this.upgrades.length; t < e; t++) this.probe(this.upgrades[t])
- },
- },
- {
- key: 'onPacket',
- value: function (t) {
- if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState)
- switch ((this.emitReserved('packet', t), this.emitReserved('heartbeat'), t.type)) {
- case 'open':
- this.onHandshake(JSON.parse(t.data))
- break
- case 'ping':
- this.resetPingTimeout(), this.sendPacket('pong'), this.emitReserved('ping'), this.emitReserved('pong')
- break
- case 'error':
- var e = new Error('server error')
- ;(e.code = t.data), this.onError(e)
- break
- case 'message':
- this.emitReserved('data', t.data), this.emitReserved('message', t.data)
- }
- },
- },
- {
- key: 'onHandshake',
- value: function (t) {
- this.emitReserved('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.resetPingTimeout()
- },
- },
- {
- key: 'resetPingTimeout',
- value: function () {
- var t = this
- this.clearTimeoutFn(this.pingTimeoutTimer),
- (this.pingTimeoutTimer = this.setTimeoutFn(function () {
- t.onClose('ping timeout')
- }, this.pingInterval + this.pingTimeout)),
- this.opts.autoUnref && this.pingTimeoutTimer.unref()
- },
- },
- {
- key: 'onDrain',
- value: function () {
- this.writeBuffer.splice(0, this.prevBufferLen), (this.prevBufferLen = 0), 0 === this.writeBuffer.length ? this.emitReserved('drain') : this.flush()
- },
- },
- {
- key: 'flush',
- value: function () {
- 'closed' !== this.readyState &&
- this.transport.writable &&
- !this.upgrading &&
- this.writeBuffer.length &&
- (this.transport.send(this.writeBuffer), (this.prevBufferLen = this.writeBuffer.length), this.emitReserved('flush'))
- },
- },
- {
- key: 'write',
- value: function (t, e, n) {
- return this.sendPacket('message', t, e, n), this
- },
- },
- {
- key: 'send',
- value: function (t, e, n) {
- return this.sendPacket('message', t, e, n), this
- },
- },
- {
- key: 'sendPacket',
- value: 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 i = { type: t, data: e, options: n }
- this.emitReserved('packetCreate', i), this.writeBuffer.push(i), r && this.once('flush', r), this.flush()
- }
- },
- },
- {
- key: 'close',
- value: function () {
- var t = this,
- e = function () {
- t.onClose('forced close'), t.transport.close()
- },
- n = function n() {
- t.off('upgrade', n), t.off('upgradeError', n), e()
- },
- r = function () {
- t.once('upgrade', n), t.once('upgradeError', n)
- }
- return (
- ('opening' !== this.readyState && 'open' !== this.readyState) ||
- ((this.readyState = 'closing'),
- this.writeBuffer.length
- ? this.once('drain', function () {
- t.upgrading ? r() : e()
- })
- : this.upgrading
- ? r()
- : e()),
- this
- )
- },
- },
- {
- key: 'onError',
- value: function (t) {
- ;(a.priorWebsocketSuccess = !1), this.emitReserved('error', t), this.onClose('transport error', t)
- },
- },
- {
- key: 'onClose',
- value: function (t, e) {
- ;('opening' !== this.readyState && 'open' !== this.readyState && 'closing' !== this.readyState) ||
- (this.clearTimeoutFn(this.pingTimeoutTimer),
- this.transport.removeAllListeners('close'),
- this.transport.close(),
- this.transport.removeAllListeners(),
- 'function' == typeof removeEventListener && removeEventListener('offline', this.offlineEventListener, !1),
- (this.readyState = 'closed'),
- (this.id = null),
- this.emitReserved('close', t, e),
- (this.writeBuffer = []),
- (this.prevBufferLen = 0))
- },
- },
- {
- key: 'filterUpgrades',
- value: function (t) {
- for (var e = [], n = 0, r = t.length; n < r; n++) ~this.transports.indexOf(t[n]) && e.push(t[n])
- return e
- },
- },
- ]),
- a
- )
- })(T)
- ut.protocol = 4
- var ft = {},
- pt = {}
- function lt(t, e, n) {
- for (var r = 0, i = 0, o = n.length; i < o; i++)
- (r = n.charCodeAt(i)) < 128
- ? t.setUint8(e++, r)
- : r < 2048
- ? (t.setUint8(e++, 192 | (r >> 6)), t.setUint8(e++, 128 | (63 & r)))
- : r < 55296 || r >= 57344
- ? (t.setUint8(e++, 224 | (r >> 12)), t.setUint8(e++, 128 | ((r >> 6) & 63)), t.setUint8(e++, 128 | (63 & r)))
- : (i++,
- (r = 65536 + (((1023 & r) << 10) | (1023 & n.charCodeAt(i)))),
- t.setUint8(e++, 240 | (r >> 18)),
- t.setUint8(e++, 128 | ((r >> 12) & 63)),
- t.setUint8(e++, 128 | ((r >> 6) & 63)),
- t.setUint8(e++, 128 | (63 & r)))
- }
- function dt(t, n, r) {
- var i = e(r),
- o = 0,
- s = 0,
- a = 0,
- c = 0,
- h = 0,
- u = 0
- if ('string' === i) {
- if (
- ((h = (function (t) {
- for (var e = 0, n = 0, r = 0, i = t.length; r < i; r++) (e = t.charCodeAt(r)) < 128 ? (n += 1) : e < 2048 ? (n += 2) : e < 55296 || e >= 57344 ? (n += 3) : (r++, (n += 4))
- return n
- })(r)),
- h < 32)
- )
- t.push(160 | h), (u = 1)
- else if (h < 256) t.push(217, h), (u = 2)
- else if (h < 65536) t.push(218, h >> 8, h), (u = 3)
- else {
- if (!(h < 4294967296)) throw new Error('String too long')
- t.push(219, h >> 24, h >> 16, h >> 8, h), (u = 5)
- }
- return n.push({ _str: r, _length: h, _offset: t.length }), u + h
- }
- if ('number' === i)
- return Math.floor(r) === r && isFinite(r)
- ? r >= 0
- ? r < 128
- ? (t.push(r), 1)
- : r < 256
- ? (t.push(204, r), 2)
- : r < 65536
- ? (t.push(205, r >> 8, r), 3)
- : r < 4294967296
- ? (t.push(206, r >> 24, r >> 16, r >> 8, r), 5)
- : ((a = (r / Math.pow(2, 32)) >> 0), (c = r >>> 0), t.push(207, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9)
- : r >= -32
- ? (t.push(r), 1)
- : r >= -128
- ? (t.push(208, r), 2)
- : r >= -32768
- ? (t.push(209, r >> 8, r), 3)
- : r >= -2147483648
- ? (t.push(210, r >> 24, r >> 16, r >> 8, r), 5)
- : ((a = Math.floor(r / Math.pow(2, 32))), (c = r >>> 0), t.push(211, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9)
- : (t.push(203), n.push({ _float: r, _length: 8, _offset: t.length }), 9)
- if ('object' === i) {
- if (null === r) return t.push(192), 1
- if (Array.isArray(r)) {
- if ((h = r.length) < 16) t.push(144 | h), (u = 1)
- else if (h < 65536) t.push(220, h >> 8, h), (u = 3)
- else {
- if (!(h < 4294967296)) throw new Error('Array too large')
- t.push(221, h >> 24, h >> 16, h >> 8, h), (u = 5)
- }
- for (o = 0; o < h; o++) u += dt(t, n, r[o])
- return u
- }
- if (r instanceof Date) {
- var f = r.getTime()
- return (a = Math.floor(f / Math.pow(2, 32))), (c = f >>> 0), t.push(215, 0, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 10
- }
- if (r instanceof ArrayBuffer) {
- if ((h = r.byteLength) < 256) t.push(196, h), (u = 2)
- else if (h < 65536) t.push(197, h >> 8, h), (u = 3)
- else {
- if (!(h < 4294967296)) throw new Error('Buffer too large')
- t.push(198, h >> 24, h >> 16, h >> 8, h), (u = 5)
- }
- return n.push({ _bin: r, _length: h, _offset: t.length }), u + h
- }
- if ('function' == typeof r.toJSON) return dt(t, n, r.toJSON())
- var p = [],
- l = '',
- d = Object.keys(r)
- for (o = 0, s = d.length; o < s; o++) 'function' != typeof r[(l = d[o])] && p.push(l)
- if ((h = p.length) < 16) t.push(128 | h), (u = 1)
- else if (h < 65536) t.push(222, h >> 8, h), (u = 3)
- else {
- if (!(h < 4294967296)) throw new Error('Object too large')
- t.push(223, h >> 24, h >> 16, h >> 8, h), (u = 5)
- }
- for (o = 0; o < h; o++) (u += dt(t, n, (l = p[o]))), (u += dt(t, n, r[l]))
- return u
- }
- if ('boolean' === i) return t.push(r ? 195 : 194), 1
- if ('undefined' === i) return t.push(212, 0, 0), 3
- throw new Error('Could not encode')
- }
- var yt = function (t) {
- var e = [],
- n = [],
- r = dt(e, n, t),
- i = new ArrayBuffer(r),
- o = new DataView(i),
- s = 0,
- a = 0,
- c = -1
- n.length > 0 && (c = n[0]._offset)
- for (var h, u = 0, f = 0, p = 0, l = e.length; p < l; p++)
- if ((o.setUint8(a + p, e[p]), p + 1 === c)) {
- if (((u = (h = n[s])._length), (f = a + c), h._bin)) for (var d = new Uint8Array(h._bin), y = 0; y < u; y++) o.setUint8(f + y, d[y])
- else h._str ? lt(o, f, h._str) : void 0 !== h._float && o.setFloat64(f, h._float)
- ;(a += u), n[++s] && (c = n[s]._offset)
- }
- return i
- }
- function vt(t) {
- if (((this._offset = 0), t instanceof ArrayBuffer)) (this._buffer = t), (this._view = new DataView(this._buffer))
- else {
- if (!ArrayBuffer.isView(t)) throw new Error('Invalid argument')
- ;(this._buffer = t.buffer), (this._view = new DataView(this._buffer, t.byteOffset, t.byteLength))
- }
- }
- ;(vt.prototype._array = function (t) {
- for (var e = new Array(t), n = 0; n < t; n++) e[n] = this._parse()
- return e
- }),
- (vt.prototype._map = function (t) {
- for (var e = {}, n = 0; n < t; n++) e[this._parse()] = this._parse()
- return e
- }),
- (vt.prototype._str = function (t) {
- var e = (function (t, e, n) {
- for (var r = '', i = 0, o = e, s = e + n; o < s; o++) {
- var a = t.getUint8(o)
- if (0 != (128 & a))
- if (192 != (224 & a))
- if (224 != (240 & a)) {
- if (240 != (248 & a)) throw new Error('Invalid byte ' + a.toString(16))
- ;(i = ((7 & a) << 18) | ((63 & t.getUint8(++o)) << 12) | ((63 & t.getUint8(++o)) << 6) | ((63 & t.getUint8(++o)) << 0)) >= 65536
- ? ((i -= 65536), (r += String.fromCharCode(55296 + (i >>> 10), 56320 + (1023 & i))))
- : (r += String.fromCharCode(i))
- } else r += String.fromCharCode(((15 & a) << 12) | ((63 & t.getUint8(++o)) << 6) | ((63 & t.getUint8(++o)) << 0))
- else r += String.fromCharCode(((31 & a) << 6) | (63 & t.getUint8(++o)))
- else r += String.fromCharCode(a)
- }
- return r
- })(this._view, this._offset, t)
- return (this._offset += t), e
- }),
- (vt.prototype._bin = function (t) {
- var e = this._buffer.slice(this._offset, this._offset + t)
- return (this._offset += t), e
- }),
- (vt.prototype._parse = function () {
- var t,
- e = this._view.getUint8(this._offset++),
- n = 0,
- r = 0,
- i = 0,
- o = 0
- if (e < 192) return e < 128 ? e : e < 144 ? this._map(15 & e) : e < 160 ? this._array(15 & e) : this._str(31 & e)
- if (e > 223) return -1 * (255 - e + 1)
- switch (e) {
- case 192:
- return null
- case 194:
- return !1
- case 195:
- return !0
- case 196:
- return (n = this._view.getUint8(this._offset)), (this._offset += 1), this._bin(n)
- case 197:
- return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._bin(n)
- case 198:
- return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._bin(n)
- case 199:
- return (n = this._view.getUint8(this._offset)), (r = this._view.getInt8(this._offset + 1)), (this._offset += 2), [r, this._bin(n)]
- case 200:
- return (n = this._view.getUint16(this._offset)), (r = this._view.getInt8(this._offset + 2)), (this._offset += 3), [r, this._bin(n)]
- case 201:
- return (n = this._view.getUint32(this._offset)), (r = this._view.getInt8(this._offset + 4)), (this._offset += 5), [r, this._bin(n)]
- case 202:
- return (t = this._view.getFloat32(this._offset)), (this._offset += 4), t
- case 203:
- return (t = this._view.getFloat64(this._offset)), (this._offset += 8), t
- case 204:
- return (t = this._view.getUint8(this._offset)), (this._offset += 1), t
- case 205:
- return (t = this._view.getUint16(this._offset)), (this._offset += 2), t
- case 206:
- return (t = this._view.getUint32(this._offset)), (this._offset += 4), t
- case 207:
- return (i = this._view.getUint32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), i + o
- case 208:
- return (t = this._view.getInt8(this._offset)), (this._offset += 1), t
- case 209:
- return (t = this._view.getInt16(this._offset)), (this._offset += 2), t
- case 210:
- return (t = this._view.getInt32(this._offset)), (this._offset += 4), t
- case 211:
- return (i = this._view.getInt32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), i + o
- case 212:
- return (r = this._view.getInt8(this._offset)), (this._offset += 1), 0 === r ? void (this._offset += 1) : [r, this._bin(1)]
- case 213:
- return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(2)]
- case 214:
- return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(4)]
- case 215:
- return (
- (r = this._view.getInt8(this._offset)),
- (this._offset += 1),
- 0 === r ? ((i = this._view.getInt32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), new Date(i + o)) : [r, this._bin(8)]
- )
- case 216:
- return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(16)]
- case 217:
- return (n = this._view.getUint8(this._offset)), (this._offset += 1), this._str(n)
- case 218:
- return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._str(n)
- case 219:
- return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._str(n)
- case 220:
- return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._array(n)
- case 221:
- return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._array(n)
- case 222:
- return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._map(n)
- case 223:
- return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._map(n)
- }
- throw new Error('Could not parse')
- })
- var gt = function (t) {
- var e = new vt(t),
- n = e._parse()
- if (e._offset !== t.byteLength) throw new Error(t.byteLength - e._offset + ' trailing bytes')
- return n
- }
- ;(pt.encode = yt), (pt.decode = gt)
- var mt,
- _t = { exports: {} }
- !(function (t) {
- function e(t) {
- if (t)
- return (function (t) {
- for (var n in e.prototype) t[n] = e.prototype[n]
- return t
- })(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,
- r = this._callbacks['$' + t]
- if (!r) return this
- if (1 == arguments.length) return delete this._callbacks['$' + t], this
- for (var i = 0; i < r.length; i++)
- if ((n = r[i]) === e || n.fn === e) {
- r.splice(i, 1)
- break
- }
- return 0 === r.length && delete this._callbacks['$' + t], this
- }),
- (e.prototype.emit = function (t) {
- this._callbacks = this._callbacks || {}
- for (var e = new Array(arguments.length - 1), n = this._callbacks['$' + t], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]
- if (n) {
- r = 0
- for (var i = (n = n.slice(0)).length; r < i; ++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
- })
- })(_t)
- var bt = pt,
- kt = _t.exports,
- wt = (ft.protocol = 5),
- Et = (mt = ft.PacketType = { CONNECT: 0, DISCONNECT: 1, EVENT: 2, ACK: 3, CONNECT_ERROR: 4 }),
- Ct =
- Number.isInteger ||
- function (t) {
- return 'number' == typeof t && isFinite(t) && Math.floor(t) === t
- },
- Ot = function (t) {
- return 'string' == typeof t
- },
- Tt = function (t) {
- return '[object Object]' === Object.prototype.toString.call(t)
- }
- function St() {}
- function Rt() {}
- ;(St.prototype.encode = function (t) {
- return [bt.encode(t)]
- }),
- kt(Rt.prototype),
- (Rt.prototype.add = function (t) {
- var e = bt.decode(t)
- this.checkPacket(e), this.emit('decoded', e)
- }),
- (Rt.prototype.checkPacket = function (t) {
- if (!(Ct(t.type) && t.type >= Et.CONNECT && t.type <= Et.CONNECT_ERROR)) throw new Error('invalid packet type')
- if (!Ot(t.nsp)) throw new Error('invalid namespace')
- if (
- !(function (t) {
- switch (t.type) {
- case Et.CONNECT:
- return void 0 === t.data || Tt(t.data)
- case Et.DISCONNECT:
- return void 0 === t.data
- case Et.CONNECT_ERROR:
- return Ot(t.data) || Tt(t.data)
- default:
- return Array.isArray(t.data)
- }
- })(t)
- )
- throw new Error('invalid payload')
- if (!(void 0 === t.id || Ct(t.id))) throw new Error('invalid packet id')
- }),
- (Rt.prototype.destroy = function () {})
- var At = (ft.Encoder = St),
- xt = (ft.Decoder = Rt),
- Ut = Object.freeze(
- t(
- {
- __proto__: null,
- default: ft,
- protocol: wt,
- get PacketType() {
- return mt
- },
- Encoder: At,
- Decoder: xt,
- },
- [ft]
- )
- )
- function Lt(t, e, n) {
- return (
- t.on(e, n),
- function () {
- t.off(e, n)
- }
- )
- }
- var Bt = Object.freeze({ connect: 1, connect_error: 1, disconnect: 1, disconnecting: 1, newListener: 1, removeListener: 1 }),
- jt = (function (t) {
- s(r, t)
- var e = f(r)
- function r(t, i, o) {
- var s
- return (
- n(this, r),
- ((s = e.call(this)).connected = !1),
- (s.disconnected = !0),
- (s.receiveBuffer = []),
- (s.sendBuffer = []),
- (s.ids = 0),
- (s.acks = {}),
- (s.flags = {}),
- (s.io = t),
- (s.nsp = i),
- o && o.auth && (s.auth = o.auth),
- s.io._autoConnect && s.open(),
- s
- )
- }
- return (
- i(r, [
- {
- key: 'subEvents',
- value: function () {
- if (!this.subs) {
- var t = this.io
- this.subs = [
- Lt(t, 'open', this.onopen.bind(this)),
- Lt(t, 'packet', this.onpacket.bind(this)),
- Lt(t, 'error', this.onerror.bind(this)),
- Lt(t, 'close', this.onclose.bind(this)),
- ]
- }
- },
- },
- {
- key: 'active',
- get: function () {
- return !!this.subs
- },
- },
- {
- key: 'connect',
- value: function () {
- return this.connected || (this.subEvents(), this.io._reconnecting || this.io.open(), 'open' === this.io._readyState && this.onopen()), this
- },
- },
- {
- key: 'open',
- value: function () {
- return this.connect()
- },
- },
- {
- key: 'send',
- value: function () {
- for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n]
- return e.unshift('message'), this.emit.apply(this, e), this
- },
- },
- {
- key: 'emit',
- value: function (t) {
- if (Bt.hasOwnProperty(t)) throw new Error('"' + t + '" is a reserved event name')
- for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r]
- n.unshift(t)
- var i = { type: mt.EVENT, data: n, options: {} }
- if (((i.options.compress = !1 !== this.flags.compress), 'function' == typeof n[n.length - 1])) {
- var o = this.ids++,
- s = n.pop()
- this._registerAckCallback(o, s), (i.id = o)
- }
- var a = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable,
- c = this.flags.volatile && (!a || !this.connected)
- return c || (this.connected ? this.packet(i) : this.sendBuffer.push(i)), (this.flags = {}), this
- },
- },
- {
- key: '_registerAckCallback',
- value: function (t, e) {
- var n = this,
- r = this.flags.timeout
- if (void 0 !== r) {
- var i = this.io.setTimeoutFn(function () {
- delete n.acks[t]
- for (var r = 0; r < n.sendBuffer.length; r++) n.sendBuffer[r].id === t && n.sendBuffer.splice(r, 1)
- e.call(n, new Error('operation has timed out'))
- }, r)
- this.acks[t] = function () {
- n.io.clearTimeoutFn(i)
- for (var t = arguments.length, r = new Array(t), o = 0; o < t; o++) r[o] = arguments[o]
- e.apply(n, [null].concat(r))
- }
- } else this.acks[t] = e
- },
- },
- {
- key: 'packet',
- value: function (t) {
- ;(t.nsp = this.nsp), this.io._packet(t)
- },
- },
- {
- key: 'onopen',
- value: function () {
- var t = this
- 'function' == typeof this.auth
- ? this.auth(function (e) {
- t.packet({ type: mt.CONNECT, data: e })
- })
- : this.packet({ type: mt.CONNECT, data: this.auth })
- },
- },
- {
- key: 'onerror',
- value: function (t) {
- this.connected || this.emitReserved('connect_error', t)
- },
- },
- {
- key: 'onclose',
- value: function (t) {
- ;(this.connected = !1), (this.disconnected = !0), delete this.id, this.emitReserved('disconnect', t)
- },
- },
- {
- key: 'onpacket',
- value: function (t) {
- if (t.nsp === this.nsp)
- switch (t.type) {
- case mt.CONNECT:
- if (t.data && t.data.sid) {
- var e = t.data.sid
- this.onconnect(e)
- } else
- this.emitReserved(
- 'connect_error',
- new Error(
- 'It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)'
- )
- )
- break
- case mt.EVENT:
- case mt.BINARY_EVENT:
- this.onevent(t)
- break
- case mt.ACK:
- case mt.BINARY_ACK:
- this.onack(t)
- break
- case mt.DISCONNECT:
- this.ondisconnect()
- break
- case mt.CONNECT_ERROR:
- this.destroy()
- var n = new Error(t.data.message)
- ;(n.data = t.data.data), this.emitReserved('connect_error', n)
- }
- },
- },
- {
- key: 'onevent',
- value: function (t) {
- var e = t.data || []
- null != t.id && e.push(this.ack(t.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e))
- },
- },
- {
- key: 'emitEvent',
- value: function (t) {
- if (this._anyListeners && this._anyListeners.length) {
- var e,
- n = d(this._anyListeners.slice())
- try {
- for (n.s(); !(e = n.n()).done; ) {
- e.value.apply(this, t)
- }
- } catch (t) {
- n.e(t)
- } finally {
- n.f()
- }
- }
- p(a(r.prototype), 'emit', this).apply(this, t)
- },
- },
- {
- key: 'ack',
- value: function (t) {
- var e = this,
- n = !1
- return function () {
- if (!n) {
- n = !0
- for (var r = arguments.length, i = new Array(r), o = 0; o < r; o++) i[o] = arguments[o]
- e.packet({ type: mt.ACK, id: t, data: i })
- }
- }
- },
- },
- {
- key: 'onack',
- value: function (t) {
- var e = this.acks[t.id]
- 'function' == typeof e && (e.apply(this, t.data), delete this.acks[t.id])
- },
- },
- {
- key: 'onconnect',
- value: function (t) {
- ;(this.id = t), (this.connected = !0), (this.disconnected = !1), this.emitBuffered(), this.emitReserved('connect')
- },
- },
- {
- key: 'emitBuffered',
- value: function () {
- var t = this
- this.receiveBuffer.forEach(function (e) {
- return t.emitEvent(e)
- }),
- (this.receiveBuffer = []),
- this.sendBuffer.forEach(function (e) {
- return t.packet(e)
- }),
- (this.sendBuffer = [])
- },
- },
- {
- key: 'ondisconnect',
- value: function () {
- this.destroy(), this.onclose('io server disconnect')
- },
- },
- {
- key: 'destroy',
- value: function () {
- this.subs &&
- (this.subs.forEach(function (t) {
- return t()
- }),
- (this.subs = void 0)),
- this.io._destroy(this)
- },
- },
- {
- key: 'disconnect',
- value: function () {
- return this.connected && this.packet({ type: mt.DISCONNECT }), this.destroy(), this.connected && this.onclose('io client disconnect'), this
- },
- },
- {
- key: 'close',
- value: function () {
- return this.disconnect()
- },
- },
- {
- key: 'compress',
- value: function (t) {
- return (this.flags.compress = t), this
- },
- },
- {
- key: 'volatile',
- get: function () {
- return (this.flags.volatile = !0), this
- },
- },
- {
- key: 'timeout',
- value: function (t) {
- return (this.flags.timeout = t), this
- },
- },
- {
- key: 'onAny',
- value: function (t) {
- return (this._anyListeners = this._anyListeners || []), this._anyListeners.push(t), this
- },
- },
- {
- key: 'prependAny',
- value: function (t) {
- return (this._anyListeners = this._anyListeners || []), this._anyListeners.unshift(t), this
- },
- },
- {
- key: 'offAny',
- value: function (t) {
- if (!this._anyListeners) return this
- if (t) {
- for (var e = this._anyListeners, n = 0; n < e.length; n++) if (t === e[n]) return e.splice(n, 1), this
- } else this._anyListeners = []
- return this
- },
- },
- {
- key: 'listenersAny',
- value: function () {
- return this._anyListeners || []
- },
- },
- ]),
- r
- )
- })(T),
- Nt = Pt
- function Pt(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)
- }
- ;(Pt.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)
- }),
- (Pt.prototype.reset = function () {
- this.attempts = 0
- }),
- (Pt.prototype.setMin = function (t) {
- this.ms = t
- }),
- (Pt.prototype.setMax = function (t) {
- this.max = t
- }),
- (Pt.prototype.setJitter = function (t) {
- this.jitter = t
- })
- var qt = (function (t) {
- s(o, t)
- var r = f(o)
- function o(t, i) {
- var s, a
- n(this, o),
- ((s = r.call(this)).nsps = {}),
- (s.subs = []),
- t && 'object' === e(t) && ((i = t), (t = void 0)),
- ((i = i || {}).path = i.path || '/socket.io'),
- (s.opts = i),
- O(h(s), i),
- s.reconnection(!1 !== i.reconnection),
- s.reconnectionAttempts(i.reconnectionAttempts || 1 / 0),
- s.reconnectionDelay(i.reconnectionDelay || 1e3),
- s.reconnectionDelayMax(i.reconnectionDelayMax || 5e3),
- s.randomizationFactor(null !== (a = i.randomizationFactor) && void 0 !== a ? a : 0.5),
- (s.backoff = new Nt({ min: s.reconnectionDelay(), max: s.reconnectionDelayMax(), jitter: s.randomizationFactor() })),
- s.timeout(null == i.timeout ? 2e4 : i.timeout),
- (s._readyState = 'closed'),
- (s.uri = t)
- var c = i.parser || Ut
- return (s.encoder = new c.Encoder()), (s.decoder = new c.Decoder()), (s._autoConnect = !1 !== i.autoConnect), s._autoConnect && s.open(), s
- }
- return (
- i(o, [
- {
- key: 'reconnection',
- value: function (t) {
- return arguments.length ? ((this._reconnection = !!t), this) : this._reconnection
- },
- },
- {
- key: 'reconnectionAttempts',
- value: function (t) {
- return void 0 === t ? this._reconnectionAttempts : ((this._reconnectionAttempts = t), this)
- },
- },
- {
- key: 'reconnectionDelay',
- value: function (t) {
- var e
- return void 0 === t ? this._reconnectionDelay : ((this._reconnectionDelay = t), null === (e = this.backoff) || void 0 === e || e.setMin(t), this)
- },
- },
- {
- key: 'randomizationFactor',
- value: function (t) {
- var e
- return void 0 === t ? this._randomizationFactor : ((this._randomizationFactor = t), null === (e = this.backoff) || void 0 === e || e.setJitter(t), this)
- },
- },
- {
- key: 'reconnectionDelayMax',
- value: function (t) {
- var e
- return void 0 === t ? this._reconnectionDelayMax : ((this._reconnectionDelayMax = t), null === (e = this.backoff) || void 0 === e || e.setMax(t), this)
- },
- },
- {
- key: 'timeout',
- value: function (t) {
- return arguments.length ? ((this._timeout = t), this) : this._timeout
- },
- },
- {
- key: 'maybeReconnectOnOpen',
- value: function () {
- !this._reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect()
- },
- },
- {
- key: 'open',
- value: function (t) {
- var e = this
- if (~this._readyState.indexOf('open')) return this
- this.engine = new ut(this.uri, this.opts)
- var n = this.engine,
- r = this
- ;(this._readyState = 'opening'), (this.skipReconnect = !1)
- var i = Lt(n, 'open', function () {
- r.onopen(), t && t()
- }),
- o = Lt(n, 'error', function (n) {
- r.cleanup(), (r._readyState = 'closed'), e.emitReserved('error', n), t ? t(n) : r.maybeReconnectOnOpen()
- })
- if (!1 !== this._timeout) {
- var s = this._timeout
- 0 === s && i()
- var a = this.setTimeoutFn(function () {
- i(), n.close(), n.emit('error', new Error('timeout'))
- }, s)
- this.opts.autoUnref && a.unref(),
- this.subs.push(function () {
- clearTimeout(a)
- })
- }
- return this.subs.push(i), this.subs.push(o), this
- },
- },
- {
- key: 'connect',
- value: function (t) {
- return this.open(t)
- },
- },
- {
- key: 'onopen',
- value: function () {
- this.cleanup(), (this._readyState = 'open'), this.emitReserved('open')
- var t = this.engine
- this.subs.push(
- Lt(t, 'ping', this.onping.bind(this)),
- Lt(t, 'data', this.ondata.bind(this)),
- Lt(t, 'error', this.onerror.bind(this)),
- Lt(t, 'close', this.onclose.bind(this)),
- Lt(this.decoder, 'decoded', this.ondecoded.bind(this))
- )
- },
- },
- {
- key: 'onping',
- value: function () {
- this.emitReserved('ping')
- },
- },
- {
- key: 'ondata',
- value: function (t) {
- this.decoder.add(t)
- },
- },
- {
- key: 'ondecoded',
- value: function (t) {
- this.emitReserved('packet', t)
- },
- },
- {
- key: 'onerror',
- value: function (t) {
- this.emitReserved('error', t)
- },
- },
- {
- key: 'socket',
- value: function (t, e) {
- var n = this.nsps[t]
- return n || ((n = new jt(this, t, e)), (this.nsps[t] = n)), n
- },
- },
- {
- key: '_destroy',
- value: function (t) {
- for (var e = 0, n = Object.keys(this.nsps); e < n.length; e++) {
- var r = n[e]
- if (this.nsps[r].active) return
- }
- this._close()
- },
- },
- {
- key: '_packet',
- value: function (t) {
- for (var e = this.encoder.encode(t), n = 0; n < e.length; n++) this.engine.write(e[n], t.options)
- },
- },
- {
- key: 'cleanup',
- value: function () {
- this.subs.forEach(function (t) {
- return t()
- }),
- (this.subs.length = 0),
- this.decoder.destroy()
- },
- },
- {
- key: '_close',
- value: function () {
- ;(this.skipReconnect = !0), (this._reconnecting = !1), this.onclose('forced close'), this.engine && this.engine.close()
- },
- },
- {
- key: 'disconnect',
- value: function () {
- return this._close()
- },
- },
- {
- key: 'onclose',
- value: function (t) {
- this.cleanup(), this.backoff.reset(), (this._readyState = 'closed'), this.emitReserved('close', t), this._reconnection && !this.skipReconnect && this.reconnect()
- },
- },
- {
- key: 'reconnect',
- value: function () {
- var t = this
- if (this._reconnecting || this.skipReconnect) return this
- var e = this
- if (this.backoff.attempts >= this._reconnectionAttempts) this.backoff.reset(), this.emitReserved('reconnect_failed'), (this._reconnecting = !1)
- else {
- var n = this.backoff.duration()
- this._reconnecting = !0
- var r = this.setTimeoutFn(function () {
- e.skipReconnect ||
- (t.emitReserved('reconnect_attempt', e.backoff.attempts),
- e.skipReconnect ||
- e.open(function (n) {
- n ? ((e._reconnecting = !1), e.reconnect(), t.emitReserved('reconnect_error', n)) : e.onreconnect()
- }))
- }, n)
- this.opts.autoUnref && r.unref(),
- this.subs.push(function () {
- clearTimeout(r)
- })
- }
- },
- },
- {
- key: 'onreconnect',
- value: function () {
- var t = this.backoff.attempts
- ;(this._reconnecting = !1), this.backoff.reset(), this.emitReserved('reconnect', t)
- },
- },
- ]),
- o
- )
- })(T),
- Dt = {}
- function It(t, n) {
- 'object' === e(t) && ((n = t), (t = void 0))
- var r,
- i = (function (t) {
- var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : '',
- n = arguments.length > 2 ? arguments[2] : void 0,
- r = t
- ;(n = n || ('undefined' != typeof location && location)),
- null == t && (t = n.protocol + '//' + n.host),
- 'string' == typeof t &&
- ('/' === t.charAt(0) && (t = '/' === t.charAt(1) ? n.protocol + t : n.host + t),
- /^(https?|wss?):\/\//.test(t) || (t = void 0 !== n ? n.protocol + '//' + t : 'https://' + t),
- (r = g(t))),
- r.port || (/^(http|ws)$/.test(r.protocol) ? (r.port = '80') : /^(http|ws)s$/.test(r.protocol) && (r.port = '443')),
- (r.path = r.path || '/')
- var i = -1 !== r.host.indexOf(':') ? '[' + r.host + ']' : r.host
- return (r.id = r.protocol + '://' + i + ':' + r.port + e), (r.href = r.protocol + '://' + i + (n && n.port === r.port ? '' : ':' + r.port)), r
- })(t, (n = n || {}).path || '/socket.io'),
- o = i.source,
- s = i.id,
- a = i.path,
- c = Dt[s] && a in Dt[s].nsps
- return (
- n.forceNew || n['force new connection'] || !1 === n.multiplex || c ? (r = new qt(o, n)) : (Dt[s] || (Dt[s] = new qt(o, n)), (r = Dt[s])),
- i.query && !n.query && (n.query = i.queryKey),
- r.socket(i.path, n)
- )
- }
- return o(It, { Manager: qt, Socket: jt, io: It, connect: It }), It
- })
- //# sourceMappingURL=socket.io.msgpack.min.js.map
|