moreShopAdmin/build/admin/assets/socket.io-client.3d1dc32f.js

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++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((u,...c)=>i!==this._queue[0]?void 0:(u!==null?i.tryCount>this._opts.retries&&(o("packet [%d] is discarded after %d tries",i.id,i.tryCount),this._queue.shift(),s&&s(u)):(o("packet [%d] was successfully sent",i.id),this._queue.shift(),s&&s(null,...c)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(o("draining queue"),!this.connected||this._queue.length===0)return;const s=this._queue[0];if(s.pending&&!e){o("packet [%d] has already been sent and is waiting for an ack",s.id);return}s.pending=!0,s.tryCount++,o("sending packet [%d] (try n\xB0%d)",s.id,s.tryCount),this.flags=s.flags,this.emit.apply(this,s.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){o("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:r.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,s){o("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,s),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(i=>String(i.id)===e)){const i=this.acks[e];delete this.acks[e],i.withError&&i.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case r.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):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 r.PacketType.EVENT:case r.PacketType.BINARY_EVENT:this.onevent(e);break;case r.PacketType.ACK:case r.PacketType.BINARY_ACK:this.onack(e);break;case r.PacketType.DISCONNECT:this.ondisconnect();break;case r.PacketType.CONNECT_ERROR:this.destroy();const i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){const s=e.data||[];o("emitting event %j",s),e.id!=null&&(o("attaching ack callback to event"),s.push(this.ack(e.id))),this.connected?this.emitEvent(s):this.receiveBuffer.push(Object.freeze(s))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const s=this._anyListeners.slice();for(const i of s)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const s=this;let i=!1;return function(...u){i||(i=!0,o("sending ack %j",u),s.packet({type:r.PacketType.ACK,id:e,data:u}))}}onack(e){const s=this.acks[e.id];if(typeof s!="function"){o("bad ack %s",e.id);return}delete this.acks[e.id],o("calling ack %s with %j",e.id,e.data),s.withError&&e.data.unshift(null),s.apply(this,e.data)}onconnect(e,s){o("socket connected with id %s",e),this.id=e,this.recovered=s&&this._pid===s,this._pid=s,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){o("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(o("performing disconnect (%s)",this.nsp),this.packet({type:r.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const s=this._anyListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const s=this._anyOutgoingListeners;for(let i=0;i<s.length;i++)if(e===s[i])return s.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const s=this._anyOutgoingListeners.slice();for(const i of s)i.apply(this,e.data)}}}return j.Socket=f,j}var M={},A;function Q(){if(A)return M;A=1,Object.defineProperty(M,"__esModule",{value:!0}),M.Backoff=l;function l(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}return l.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var p=Math.random(),_=Math.floor(p*this.jitter*r);r=(Math.floor(p*10)&1)==0?r-_:r+_}return Math.min(r,this.max)|0},l.prototype.reset=function(){this.attempts=0},l.prototype.setMin=function(r){this.ms=r},l.prototype.setMax=function(r){this.max=r},l.prototype.setJitter=function(r){this.jitter=r},M}var B;function $(){if(B)return O;B=1;var l=g&&g.__createBinding||(Object.create?function(c,t,n,a){a===void 0&&(a=n);var d=Object.getOwnPropertyDescriptor(t,n);(!d||("get"in d?!t.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(c,a,d)}:function(c,t,n,a){a===void 0&&(a=n),c[a]=t[n]}),r=g&&g.__setModuleDefault||(Object.create?function(c,t){Object.defineProperty(c,"default",{enumerable:!0,value:t})}:function(c,t){c.default=t}),p=g&&g.__importStar||function(c){if(c&&c.__esModule)return c;var t={};if(c!=null)for(var n in c)n!=="default"&&Object.prototype.hasOwnProperty.call(c,n)&&l(t,c,n);return r(t,c),t},_=g&&g.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(O,"__esModule",{value:!0}),O.Manager=void 0;const m=P(),o=x(),k=p(T()),f=W(),h=Q(),e=F,i=(0,_(S()).default)("socket.io-client:manager");class u extends e.Emitter{constructor(t,n){var a;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,(0,m.installTimerFunctions)(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((a=n.randomizationFactor)!==null&&a!==void 0?a:.5),this.backoff=new h.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const d=n.parser||k;this.encoder=new d.Encoder,this.decoder=new d.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(i("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;i("opening %s",this.uri),this.engine=new m.Socket(this.uri,this.opts);const n=this.engine,a=this;this._readyState="opening",this.skipReconnect=!1;const d=(0,f.on)(n,"open",function(){a.onopen(),t&&t()}),b=y=>{i("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",y),t?t(y):this.maybeReconnectOnOpen()},v=(0,f.on)(n,"error",b);if(this._timeout!==!1){const y=this._timeout;i("connect attempt will timeout after %d",y);const C=this.setTimeoutFn(()=>{i("connect attempt timed out after %d",y),d(),b(new Error("timeout")),n.close()},y);this.opts.autoUnref&&C.unref(),this.subs.push(()=>{this.clearTimeoutFn(C)})}return this.subs.push(d),this.subs.push(v),this}connect(t){return this.open(t)}onopen(){i("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push((0,f.on)(t,"ping",this.onping.bind(this)),(0,f.on)(t,"data",this.ondata.bind(this)),(0,f.on)(t,"error",this.onerror.bind(this)),(0,f.on)(t,"close",this.onclose.bind(this)),(0,f.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){(0,m.nextTick)(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){i("error",t),this.emitReserved("error",t)}socket(t,n){let a=this.nsps[t];return a?this._autoConnect&&!a.active&&a.connect():(a=new o.Socket(this,t,n),this.nsps[t]=a),a}_destroy(t){const n=Object.keys(this.nsps);for(const a of n)if(this.nsps[a].active){i("socket %s is still active, skipping close",a);return}this._close()}_packet(t){i("writing packet %j",t);const n=this.encoder.encode(t);for(let a=0;a<n.length;a++)this.engine.write(n[a],t.options)}cleanup(){i("cleanup"),this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){i("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var a;i("closed due to %s",t),this.cleanup(),(a=this.engine)===null||a===void 0||a.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)i("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();i("will wait %dms before reconnect attempt",n),this._reconnecting=!0;const a=this.setTimeoutFn(()=>{t.skipReconnect||(i("attempting reconnect"),this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(d=>{d?(i("reconnect attempt error"),t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",d)):(i("reconnect success"),t.onreconnect())}))},n);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}return O.Manager=u,O}var N;function U(){return N||(N=1,function(l,r){var p=g&&g.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0}),r.WebTransport=r.WebSocket=r.NodeWebSocket=r.XHR=r.NodeXHR=r.Fetch=r.Socket=r.Manager=r.protocol=void 0,r.io=e,r.connect=e,r.default=e;const _=z(),m=$();Object.defineProperty(r,"Manager",{enumerable:!0,get:function(){return m.Manager}});const o=x();Object.defineProperty(r,"Socket",{enumerable:!0,get:function(){return o.Socket}});const f=(0,p(S()).default)("socket.io-client"),h={};function e(u,c){typeof u=="object"&&(c=u,u=void 0),c=c||{};const t=(0,_.url)(u,c.path||"/socket.io"),n=t.source,a=t.id,d=t.path,b=h[a]&&d in h[a].nsps,v=c.forceNew||c["force new connection"]||c.multiplex===!1||b;let y;return v?(f("ignoring socket cache for %s",n),y=new m.Manager(n,c)):(h[a]||(f("new io instance for %s",n),h[a]=new m.Manager(n,c)),y=h[a]),t.query&&!c.query&&(c.query=t.queryKey),y.socket(t.path,c)}Object.assign(e,{Manager:m.Manager,Socket:o.Socket,io:e,connect:e});var s=T();Object.defineProperty(r,"protocol",{enumerable:!0,get:function(){return s.protocol}});var i=P();Object.defineProperty(r,"Fetch",{enumerable:!0,get:function(){return i.Fetch}}),Object.defineProperty(r,"NodeXHR",{enumerable:!0,get:function(){return i.NodeXHR}}),Object.defineProperty(r,"XHR",{enumerable:!0,get:function(){return i.XHR}}),Object.defineProperty(r,"NodeWebSocket",{enumerable:!0,get:function(){return i.NodeWebSocket}}),Object.defineProperty(r,"WebSocket",{enumerable:!0,get:function(){return i.WebSocket}}),Object.defineProperty(r,"WebTransport",{enumerable:!0,get:function(){return i.WebTransport}}),l.exports=e}(w,w.exports)),w.exports}export{U as r};