2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
|
import{n as g}from"./@babel.80d29b7b.js";import{r as P}from"./engine.io-client.6bbd7bb9.js";import{r as S}from"./debug.b392f131.js";import{r as T}from"./socket.io-parser.4db37fe5.js";import{r as F}from"./@socket.io.573b606e.js";var w={exports:{}},E={},q;function z(){if(q)return E;q=1;var l=g&&g.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(E,"__esModule",{value:!0}),E.url=m;const r=P(),_=(0,l(S()).default)("socket.io-client:url");function m(o,k="",f){let h=o;f=f||typeof location<"u"&&location,o==null&&(o=f.protocol+"//"+f.host),typeof o=="string"&&(o.charAt(0)==="/"&&(o.charAt(1)==="/"?o=f.protocol+o:o=f.host+o),/^(https?|wss?):\/\//.test(o)||(_("protocol-less url %s",o),typeof f<"u"?o=f.protocol+"//"+o:o="https://"+o),_("parse %s",o),h=(0,r.parse)(o)),h.port||(/^(http|ws)$/.test(h.protocol)?h.port="80":/^(http|ws)s$/.test(h.protocol)&&(h.port="443")),h.path=h.path||"/";const s=h.host.indexOf(":")!==-1?"["+h.host+"]":h.host;return h.id=h.protocol+"://"+s+":"+h.port+k,h.href=h.protocol+"://"+s+(f&&f.port===h.port?"":":"+h.port),h}return E}var O={},j={},R={},L;function W(){if(L)return R;L=1,Object.defineProperty(R,"__esModule",{value:!0}),R.on=l;function l(r,p,_){return r.on(p,_),function(){r.off(p,_)}}return R}var D;function x(){if(D)return j;D=1;var l=g&&g.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(j,"__esModule",{value:!0}),j.Socket=void 0;const r=T(),p=W(),_=F,o=(0,l(S()).default)("socket.io-client:socket"),k=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class f extends _.Emitter{constructor(e,s,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=s,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,p.on)(e,"open",this.onopen.bind(this)),(0,p.on)(e,"packet",this.onpacket.bind(this)),(0,p.on)(e,"error",this.onerror.bind(this)),(0,p.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...s){var i,u,c;if(k.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(s.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(s),this;const t={type:r.PacketType.EVENT,data:s};if(t.options={},t.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const b=this.ids++;o("emitting packet with ack id %d",b);const v=s.pop();this._registerAckCallback(b,v),t.id=b}const n=(u=(i=this.io.engine)===null||i===void 0?void 0:i.transport)===null||u===void 0?void 0:u.writable,a=this.connected&&!(!((c=this.io.engine)===null||c===void 0)&&c._hasPingExpired());return this.flags.volatile&&!n?o("discard packet as the transport is not currently writable"):a?(this.notifyOutgoingListeners(t),this.packet(t)):this.sendBuffer.push(t),this.flags={},this}_registerAckCallback(e,s){var i;const u=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(u===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let n=0;n<this.sendBuffer.length;n++)this.sendBuffer[n].id===e&&(o("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(n,1));o("event with ack id %d has timed out after %d ms",e,u),s.call(this,new Error("operation has timed out"))},u),t=(...n)=>{this.io.clearTimeoutFn(c),s.apply(this,n)};t.withError=!0,this.acks[e]=t}emitWithAck(e,...s){return new Promise((i,u)=>{const c=(t,n)=>t?u(t):i(n);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const i={id:this._queueSeq++,tr
|