chromatic-lattice/assets/engine.io-client.6ba5801d.js

2 lines
16 KiB
JavaScript
Raw Normal View History

import{d as F,a as I,e as W,b as M,p as q}from"./engine.io-parser.730afdce.js";import{E as y}from"./@socket.io.aec831e2.js";const h=(()=>typeof self!="undefined"?self:typeof window!="undefined"?window:Function("return this")())();function C(r,...e){return e.reduce((t,s)=>(r.hasOwnProperty(s)&&(t[s]=r[s]),t),{})}const D=setTimeout,N=clearTimeout;function g(r,e){e.useNativeTimers?(r.setTimeoutFn=D.bind(h),r.clearTimeoutFn=N.bind(h)):(r.setTimeoutFn=setTimeout.bind(h),r.clearTimeoutFn=clearTimeout.bind(h))}const z=1.33;function X(r){return typeof r=="string"?V(r):Math.ceil((r.byteLength||r.size)*z)}function V(r){let e=0,t=0;for(let s=0,i=r.length;s<i;s++)e=r.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}class j extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class L extends y{constructor(e){super(),this.writable=!1,g(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t,s){return super.emitReserved("error",new j(e,t,s)),this}open(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=F(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}}const O="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),m=64,K={};let T=0,u=0,x;function S(r){let e="";do e=O[r%m]+e,r=Math.floor(r/m);while(r>0);return e}function B(){const r=S(+new Date);return r!==x?(T=0,x=r):r+"."+S(T++)}for(;u<m;u++)K[O[u]]=u;function H(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Q(r){let e={},t=r.split("&");for(let s=0,i=t.length;s<i;s++){let o=t[s].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}let U=!1;try{U=typeof XMLHttpRequest!="undefined"&&"withCredentials"in new XMLHttpRequest}catch{}const $=U;function A(r){const e=r.xdomain;try{if(typeof XMLHttpRequest!="undefined"&&(!e||$))return new XMLHttpRequest}catch{}if(!e)try{return new h[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function G(){}const J=function(){return new A({xdomain:!1}).responseType!=null}();class Y extends L{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){const s=location.protocol==="https:";let i=location.port;i||(i=s?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||i!==e.port,this.xs=e.secure!==s}const t=e&&e.forceBase64;this.supportsBinary=J&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let s=0;this.polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};I(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,W(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let s="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=B()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(s=":"+this.opts.po