2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
|
import{n as _}from"./@babel.16688d44.js";import{r as N}from"./engine.io-client.81030771.js";import{r as S}from"./debug.b392f131.js";import{r as C}from"./socket.io-parser.b7256298.js";import{r as x}from"./@socket.io.77accf6a.js";var R={exports:{}},v={},q;function Q(){if(q)return v;q=1;var d=_&&_.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(v,"__esModule",{value:!0}),v.url=void 0;const o=N(),p=d(S()).default("socket.io-client:url");function g(r,y="",f){let a=r;f=f||typeof location<"u"&&location,r==null&&(r=f.protocol+"//"+f.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=f.protocol+r:r=f.host+r),/^(https?|wss?):\/\//.test(r)||(p("protocol-less url %s",r),typeof f<"u"?r=f.protocol+"//"+r:r="https://"+r),p("parse %s",r),a=o.parse(r)),a.port||(/^(http|ws)$/.test(a.protocol)?a.port="80":/^(http|ws)s$/.test(a.protocol)&&(a.port="443")),a.path=a.path||"/";const s=a.host.indexOf(":")!==-1?"["+a.host+"]":a.host;return a.id=a.protocol+"://"+s+":"+a.port+y,a.href=a.protocol+"://"+s+(f&&f.port===a.port?"":":"+a.port),a}return v.url=g,v}var O={},j={},w={},L;function F(){if(L)return w;L=1,Object.defineProperty(w,"__esModule",{value:!0}),w.on=void 0;function d(o,l,p){return o.on(l,p),function(){o.off(l,p)}}return w.on=d,w}var P;function z(){if(P)return j;P=1;var d=_&&_.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(j,"__esModule",{value:!0}),j.Socket=void 0;const o=C(),l=F(),p=x,r=d(S()).default("socket.io-client:socket"),y=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class f extends p.Emitter{constructor(e,s,n){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,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[l.on(e,"open",this.onopen.bind(this)),l.on(e,"packet",this.onpacket.bind(this)),l.on(e,"error",this.onerror.bind(this)),l.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){if(y.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 n={type:o.PacketType.EVENT,data:s};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof s[s.length-1]=="function"){const t=this.ids++;r("emitting packet with ack id %d",t);const i=s.pop();this._registerAckCallback(t,i),n.id=t}const u=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!u||!this.connected)?r("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n),this.flags={},this}_registerAckCallback(e,s){var n;const u=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(u===void 0){this.acks[e]=s;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let i=0;i<this.sendBuffer.length;i++)this.sendBuffer[i].id===e&&(r("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(i,1));r("event with ack id %d has timed out after %d ms",e,u),s.call(this,new Error("operation has timed out"))},u),t=(...i)=>{this.io.clearTimeoutFn(c),s.apply(this,i)};t.withError=!0,this.acks[e]=t}emitWithAck(e,...s){return new Promise((n,u)=>{const c=(t,i)=>t?u(t):n(i);c.withError=!0,s.push(c),this.emit(e,...s)})}_addToQueue(e){let s;typeof e[e.length-1]=="function"&&(s=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((u,.
|