diff --git a/packages/engine.io-client/CHANGELOG.md b/packages/engine.io-client/CHANGELOG.md index 2a090dcb1..3553b84b6 100644 --- a/packages/engine.io-client/CHANGELOG.md +++ b/packages/engine.io-client/CHANGELOG.md @@ -2,6 +2,7 @@ | Version | Release date | Bundle size (UMD min+gzip) | |-------------------------------------------------------------------------------------------------------------|----------------|----------------------------| +| [6.6.3](#663-2025-01-23) | January 2025 | `8.7 KB` | | [6.6.2](#662-2024-10-23) | October 2024 | `8.7 KB` | | [6.6.1](#661-2024-09-21) | September 2024 | `8.7 KB` | | [6.6.0](#660-2024-06-21) | June 2024 | `8.6 KB` | @@ -40,6 +41,20 @@ # Release notes +## [6.6.3](https://github.com/socketio/socket.io/compare/engine.io-client@6.6.2...engine.io-client@6.6.3) (2025-01-23) + + +### Bug Fixes + +* correctly consume the `ws` package ([#5220](https://github.com/socketio/socket.io/issues/5220)) ([7fcddcb](https://github.com/socketio/socket.io/commit/7fcddcb3bbd236b46aa8fee6f4ce6c45afb7b03a)) + + +### Dependencies + +- [`ws@~8.17.1`](https://github.com/websockets/ws/releases/tag/8.17.1) (no change) + + + ## [6.6.2](https://github.com/socketio/socket.io/compare/engine.io-client@6.6.1...engine.io-client@6.6.2) (2024-10-23) diff --git a/packages/engine.io-client/dist/engine.io.esm.min.js b/packages/engine.io-client/dist/engine.io.esm.min.js index a37741a87..4dc071a83 100644 --- a/packages/engine.io-client/dist/engine.io.esm.min.js +++ b/packages/engine.io-client/dist/engine.io.esm.min.js @@ -1,6 +1,6 @@ /*! - * Engine.IO v6.6.2 - * (c) 2014-2024 Guillermo Rauch + * Engine.IO v6.6.3 + * (c) 2014-2025 Guillermo Rauch * Released under the MIT License. */ const t=Object.create(null);t.open="0",t.close="1",t.ping="2",t.pong="3",t.message="4",t.upgrade="5",t.noop="6";const s=Object.create(null);Object.keys(t).forEach((e=>{s[t[e]]=e}));const e={type:"error",data:"parser error"},i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),n="function"==typeof ArrayBuffer,r=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,o=({type:s,data:e},o,c)=>i&&e instanceof Blob?o?c(e):h(e,c):n&&(e instanceof ArrayBuffer||r(e))?o?c(e):h(new Blob([e]),c):c(t[s]+(e||"")),h=(t,s)=>{const e=new FileReader;return e.onload=function(){const t=e.result.split(",")[1];s("b"+(t||""))},e.readAsDataURL(t)};function c(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let a;const u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)f[u.charCodeAt(t)]=t;const l="function"==typeof ArrayBuffer,p=(t,i)=>{if("string"!=typeof t)return{type:"message",data:y(t,i)};const n=t.charAt(0);if("b"===n)return{type:"message",data:d(t.substring(1),i)};return s[n]?t.length>1?{type:s[n],data:t.substring(1)}:{type:s[n]}:e},d=(t,s)=>{if(l){const e=(t=>{let s,e,i,n,r,o=.75*t.length,h=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const a=new ArrayBuffer(o),u=new Uint8Array(a);for(s=0;s>4,u[c++]=(15&i)<<4|n>>2,u[c++]=(3&n)<<6|63&r;return a})(t);return y(e,s)}return{base64:!0,data:t}},y=(t,s)=>"blob"===s?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,g=String.fromCharCode(30);function w(){return new TransformStream({transform(t,s){!function(t,s){i&&t.data instanceof Blob?t.data.arrayBuffer().then(c).then(s):n&&(t.data instanceof ArrayBuffer||r(t.data))?s(c(t.data)):o(t,!1,(t=>{a||(a=new TextEncoder),s(a.encode(t))}))}(t,(e=>{const i=e.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,i)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(i))}t.data&&"string"!=typeof t.data&&(n[0]|=128),s.enqueue(n),s.enqueue(e)}))}})}let b;function m(t){return t.reduce(((t,s)=>t+s.length),0)}function v(t,s){if(t[0].length===s)return t.shift();const e=new Uint8Array(s);let i=0;for(let n=0;nPromise.resolve().then(t):(t,s)=>s(t,0),E="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function A(t,...s){return s.reduce(((s,e)=>(t.hasOwnProperty(e)&&(s[e]=t[e]),s)),{})}const U=E.setTimeout,B=E.clearTimeout;function O(t,s){s.useNativeTimers?(t.setTimeoutFn=U.bind(E),t.clearTimeoutFn=B.bind(E)):(t.setTimeoutFn=E.setTimeout.bind(E),t.clearTimeoutFn=E.clearTimeout.bind(E))}function T(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class _ extends Error{constructor(t,s,e){super(t),this.description=s,this.context=e,this.type="TransportError"}}class C extends k{constructor(t){super(),this.writable=!1,O(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,s,e){return super.emitReserved("error",new _(t,s,e)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const s=p(t,this.socket.binaryType);this.onPacket(s)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,s={}){return t+"://"+this.i()+this.o()+this.opts.path+this.h(s)}i(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}o(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}h(t){const s=function(t){let s="";for(let e in t)t.hasOwnProperty(e)&&(s.length&&(s+="&"),s+=encodeURIComponent(e)+"="+encodeURIComponent(t[e]));return s}(t);return s.length?"?"+s:""}}class P extends C{constructor(){super(...arguments),this.u=!1}get name(){return"polling"}doOpen(){this.l()}pause(t){this.readyState="pausing";const s=()=>{this.readyState="paused",t()};if(this.u||!this.writable){let t=0;this.u&&(t++,this.once("pollComplete",(function(){--t||s()}))),this.writable||(t++,this.once("drain",(function(){--t||s()})))}else s()}l(){this.u=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,s)=>{const e=t.split(g),i=[];for(let t=0;t{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.u=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.l())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,s)=>{const e=t.length,i=new Array(e);let n=0;t.forEach(((t,r)=>{o(t,!1,(t=>{i[r]=t,++n===e&&s(i.join(g))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",s=this.query||{};return!1!==this.opts.timestampRequests&&(s[this.opts.timestampParam]=T()),this.supportsBinary||s.sid||(s.b64=1),this.createUri(t,s)}}let j=!1;try{j="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const D=j;function L(){}class M extends P{constructor(t){if(super(t),"undefined"!=typeof location){const s="https:"===location.protocol;let e=location.port;e||(e=s?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||e!==t.port}}doWrite(t,s){const e=this.request({method:"POST",data:t});e.on("success",s),e.on("error",((t,s)=>{this.onError("xhr post error",t,s)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,s)=>{this.onError("xhr poll error",t,s)})),this.pollXhr=t}}class S extends k{constructor(t,s,e){super(),this.createRequest=t,O(this,e),this.p=e,this.m=e.method||"GET",this.v=s,this.k=void 0!==e.data?e.data:null,this.A()}A(){var t;const s=A(this.p,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");s.xdomain=!!this.p.xd;const e=this.U=this.createRequest(s);try{e.open(this.m,this.v,!0);try{if(this.p.extraHeaders){e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0);for(let t in this.p.extraHeaders)this.p.extraHeaders.hasOwnProperty(t)&&e.setRequestHeader(t,this.p.extraHeaders[t])}}catch(t){}if("POST"===this.m)try{e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{e.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.p.cookieJar)||void 0===t||t.addCookies(e),"withCredentials"in e&&(e.withCredentials=this.p.withCredentials),this.p.requestTimeout&&(e.timeout=this.p.requestTimeout),e.onreadystatechange=()=>{var t;3===e.readyState&&(null===(t=this.p.cookieJar)||void 0===t||t.parseCookies(e.getResponseHeader("set-cookie"))),4===e.readyState&&(200===e.status||1223===e.status?this.B():this.setTimeoutFn((()=>{this.O("number"==typeof e.status?e.status:0)}),0))},e.send(this.k)}catch(t){return void this.setTimeoutFn((()=>{this.O(t)}),0)}"undefined"!=typeof document&&(this.T=S.requestsCount++,S.requests[this.T]=this)}O(t){this.emitReserved("error",t,this.U),this._(!0)}_(t){if(void 0!==this.U&&null!==this.U){if(this.U.onreadystatechange=L,t)try{this.U.abort()}catch(t){}"undefined"!=typeof document&&delete S.requests[this.T],this.U=null}}B(){const t=this.U.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this._())}abort(){this._()}}if(S.requestsCount=0,S.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",R);else if("function"==typeof addEventListener){addEventListener("onpagehide"in E?"pagehide":"unload",R,!1)}function R(){for(let t in S.requests)S.requests.hasOwnProperty(t)&&S.requests[t].abort()}const H=function(){const t=q({xdomain:!1});return t&&null!==t.responseType}();class $ extends M{constructor(t){super(t);const s=t&&t.forceBase64;this.supportsBinary=H&&!s}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new S(q,this.uri(),t)}}function q(t){const s=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!s||D))return new XMLHttpRequest}catch(t){}if(!s)try{return new(E[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}const I="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class W extends C{get name(){return"websocket"}doOpen(){const t=this.uri(),s=this.opts.protocols,e=I?{}:A(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(e.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,s,e)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws.C.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let s=0;s{try{this.doWrite(e,t)}catch(t){}i&&x((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",s=this.query||{};return this.opts.timestampRequests&&(s[this.opts.timestampParam]=T()),this.supportsBinary||(s.b64=1),this.createUri(t,s)}}const N=E.WebSocket||E.MozWebSocket;class X extends W{createSocket(t,s,e){return I?new N(t,s,e):s?new N(t,s):new N(t)}doWrite(t,s){this.ws.send(s)}}class V extends C{get name(){return"webtransport"}doOpen(){try{this.P=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this.P.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.P.ready.then((()=>{this.P.createBidirectionalStream().then((t=>{const s=function(t,s){b||(b=new TextDecoder);const i=[];let n=0,r=-1,o=!1;return new TransformStream({transform(h,c){for(i.push(h);;){if(0===n){if(m(i)<1)break;const t=v(i,1);o=!(128&~t[0]),r=127&t[0],n=r<126?3:126===r?1:2}else if(1===n){if(m(i)<2)break;const t=v(i,2);r=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),n=3}else if(2===n){if(m(i)<8)break;const t=v(i,8),s=new DataView(t.buffer,t.byteOffset,t.length),o=s.getUint32(0);if(o>Math.pow(2,21)-1){c.enqueue(e);break}r=o*Math.pow(2,32)+s.getUint32(4),n=3}else{if(m(i)t){c.enqueue(e);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(s).getReader(),n=w();n.readable.pipeTo(t.writable),this.j=n.writable.getWriter();const r=()=>{i.read().then((({done:t,value:s})=>{t||(this.onPacket(s),r())})).catch((t=>{}))};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.j.write(o).then((()=>this.onOpen()))}))}))}write(t){this.writable=!1;for(let s=0;s{i&&x((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.P)||void 0===t||t.close()}}const F={websocket:X,webtransport:V,polling:$},z=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,G=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function J(t){if(t.length>8e3)throw"URI too long";const s=t,e=t.indexOf("["),i=t.indexOf("]");-1!=e&&-1!=i&&(t=t.substring(0,e)+t.substring(e,i).replace(/:/g,";")+t.substring(i,t.length));let n=z.exec(t||""),r={},o=14;for(;o--;)r[G[o]]=n[o]||"";return-1!=e&&-1!=i&&(r.source=s,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(t,s){const e=/\/{2,9}/g,i=s.replace(e,"/").split("/");"/"!=s.slice(0,1)&&0!==s.length||i.splice(0,1);"/"==s.slice(-1)&&i.splice(i.length-1,1);return i}(0,r.path),r.queryKey=function(t,s){const e={};return s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,s,i){s&&(e[s]=i)})),e}(0,r.query),r}const K="function"==typeof addEventListener&&"function"==typeof removeEventListener,Q=[];K&&addEventListener("offline",(()=>{Q.forEach((t=>t()))}),!1);class Y extends k{constructor(t,s){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this.D=0,this.L=-1,this.M=-1,this.S=-1,this.R=1/0,t&&"object"==typeof t&&(s=t,t=null),t){const e=J(t);s.hostname=e.host,s.secure="https"===e.protocol||"wss"===e.protocol,s.port=e.port,e.query&&(s.query=e.query)}else s.host&&(s.hostname=J(s.host).host);O(this,s),this.secure=null!=s.secure?s.secure:"undefined"!=typeof location&&"https:"===location.protocol,s.hostname&&!s.port&&(s.port=this.secure?"443":"80"),this.hostname=s.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=s.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this.H={},s.transports.forEach((t=>{const s=t.prototype.name;this.transports.push(s),this.H[s]=t})),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},s),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let s={},e=t.split("&");for(let t=0,i=e.length;t{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.$,!1)),"localhost"!==this.hostname&&(this.q=()=>{this.I("transport close",{description:"network connection lost"})},Q.push(this.q))),this.opts.withCredentials&&(this.W=void 0),this.N()}createTransport(t){const s=Object.assign({},this.opts.query);s.EIO=4,s.transport=t,this.id&&(s.sid=this.id);const e=Object.assign({},this.opts,{query:s,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this.H[t](e)}N(){if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);const t=this.opts.rememberUpgrade&&Y.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const s=this.createTransport(t);s.open(),this.setTransport(s)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.X.bind(this)).on("packet",this.V.bind(this)).on("error",this.O.bind(this)).on("close",(t=>this.I("transport close",t)))}onOpen(){this.readyState="open",Y.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}V(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.F("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this.G();break;case"error":const s=new Error("server error");s.code=t.data,this.O(s);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.L=t.pingInterval,this.M=t.pingTimeout,this.S=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.G()}G(){this.clearTimeoutFn(this.J);const t=this.L+this.M;this.R=Date.now()+t,this.J=this.setTimeoutFn((()=>{this.I("ping timeout")}),t),this.opts.autoUnref&&this.J.unref()}X(){this.writeBuffer.splice(0,this.D),this.D=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.K();this.transport.send(t),this.D=t.length,this.emitReserved("flush")}}K(){if(!(this.S&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let e=0;e=57344?e+=3:(i++,e+=4);return e}(s):Math.ceil(1.33*(s.byteLength||s.size))),e>0&&t>this.S)return this.writeBuffer.slice(0,e);t+=2}var s;return this.writeBuffer}Y(){if(!this.R)return!0;const t=Date.now()>this.R;return t&&(this.R=0,x((()=>{this.I("ping timeout")}),this.setTimeoutFn)),t}write(t,s,e){return this.F("message",t,s,e),this}send(t,s,e){return this.F("message",t,s,e),this}F(t,s,e,i){if("function"==typeof s&&(i=s,s=void 0),"function"==typeof e&&(i=e,e=null),"closing"===this.readyState||"closed"===this.readyState)return;(e=e||{}).compress=!1!==e.compress;const n={type:t,data:s,options:e};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this.I("forced close"),this.transport.close()},s=()=>{this.off("upgrade",s),this.off("upgradeError",s),t()},e=()=>{this.once("upgrade",s),this.once("upgradeError",s)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?e():t()})):this.upgrading?e():t()),this}O(t){if(Y.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this.N();this.emitReserved("error",t),this.I("transport error",t)}I(t,s){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this.J),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),K&&(this.$&&removeEventListener("beforeunload",this.$,!1),this.q)){const t=Q.indexOf(this.q);-1!==t&&Q.splice(t,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,s),this.writeBuffer=[],this.D=0}}}Y.protocol=4;class Z extends Y{constructor(){super(...arguments),this.Z=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let t=0;t{e||(s.send([{type:"ping",data:"probe"}]),s.once("packet",(t=>{if(!e)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",s),!s)return;Y.priorWebsocketSuccess="websocket"===s.name,this.transport.pause((()=>{e||"closed"!==this.readyState&&(a(),this.setTransport(s),s.send([{type:"upgrade"}]),this.emitReserved("upgrade",s),s=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=s.name,this.emitReserved("upgradeError",t)}})))};function n(){e||(e=!0,a(),s.close(),s=null)}const r=t=>{const e=new Error("probe error: "+t);e.transport=s.name,n(),this.emitReserved("upgradeError",e)};function o(){r("transport closed")}function h(){r("socket closed")}function c(t){s&&t.name!==s.name&&n()}const a=()=>{s.removeListener("open",i),s.removeListener("error",r),s.removeListener("close",o),this.off("close",h),this.off("upgrading",c)};s.once("open",i),s.once("error",r),s.once("close",o),this.once("close",h),this.once("upgrading",c),-1!==this.Z.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{e||s.open()}),200):s.open()}onHandshake(t){this.Z=this.st(t.upgrades),super.onHandshake(t)}st(t){const s=[];for(let e=0;eF[t])).filter((t=>!!t))),super(t,e)}}class st extends P{doPoll(){this.et().then((t=>{if(!t.ok)return this.onError("fetch read error",t.status,t);t.text().then((t=>this.onData(t)))})).catch((t=>{this.onError("fetch read error",t)}))}doWrite(t,s){this.et(t).then((t=>{if(!t.ok)return this.onError("fetch write error",t.status,t);s()})).catch((t=>{this.onError("fetch write error",t)}))}et(t){var s;const e=void 0!==t,i=new Headers(this.opts.extraHeaders);return e&&i.set("content-type","text/plain;charset=UTF-8"),null===(s=this.socket.W)||void 0===s||s.appendCookies(i),fetch(this.uri(),{method:e?"POST":"GET",body:e?t:null,headers:i,credentials:this.opts.withCredentials?"include":"omit"}).then((t=>{var s;return null===(s=this.socket.W)||void 0===s||s.parseCookies(t.headers.getSetCookie()),t}))}}const et=tt.protocol;export{st as Fetch,X as NodeWebSocket,$ as NodeXHR,tt as Socket,Z as SocketWithUpgrade,Y as SocketWithoutUpgrade,C as Transport,_ as TransportError,X as WebSocket,V as WebTransport,$ as XHR,O as installTimerFunctions,x as nextTick,J as parse,et as protocol,F as transports}; diff --git a/packages/engine.io-client/dist/engine.io.js b/packages/engine.io-client/dist/engine.io.js index cb2100204..83d420513 100644 --- a/packages/engine.io-client/dist/engine.io.js +++ b/packages/engine.io-client/dist/engine.io.js @@ -1,6 +1,6 @@ /*! - * Engine.IO v6.6.2 - * (c) 2014-2024 Guillermo Rauch + * Engine.IO v6.6.3 + * (c) 2014-2025 Guillermo Rauch * Released under the MIT License. */ (function (global, factory) { diff --git a/packages/engine.io-client/dist/engine.io.min.js b/packages/engine.io-client/dist/engine.io.min.js index 76a48e1c6..782d498ee 100644 --- a/packages/engine.io-client/dist/engine.io.min.js +++ b/packages/engine.io-client/dist/engine.io.min.js @@ -1,6 +1,6 @@ /*! - * Engine.IO v6.6.2 - * (c) 2014-2024 Guillermo Rauch + * Engine.IO v6.6.3 + * (c) 2014-2025 Guillermo Rauch * Released under the MIT License. */ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).eio=n()}(this,(function(){"use strict";function t(t,n){for(var i=0;i1?{type:a[i],data:t.substring(1)}:{type:a[i]}:l},O=function(t,n){if(B){var i=function(t){var n,i,r,e,o,s=.75*t.length,u=t.length,f=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var h=new ArrayBuffer(s),c=new Uint8Array(h);for(n=0;n>4,c[f++]=(15&r)<<4|e>>2,c[f++]=(3&e)<<6|63&o;return h}(t);return U(i,n)}return{base64:!0,data:t}},U=function(t,n){return"blob"===n?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer},T=String.fromCharCode(30);function S(){return new TransformStream({transform:function(t,n){!function(t,n){v&&t.data instanceof Blob?t.data.arrayBuffer().then(w).then(n):d&&(t.data instanceof ArrayBuffer||y(t.data))?n(w(t.data)):b(t,!1,(function(t){p||(p=new TextEncoder),n(p.encode(t))}))}(t,(function(i){var r,e=i.length;if(e<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,e);else if(e<65536){r=new Uint8Array(3);var o=new DataView(r.buffer);o.setUint8(0,126),o.setUint16(1,e)}else{r=new Uint8Array(9);var s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(e))}t.data&&"string"!=typeof t.data&&(r[0]|=128),n.enqueue(r),n.enqueue(i)}))}})}function M(t){return t.reduce((function(t,n){return t+n.length}),0)}function x(t,n){if(t[0].length===n)return t.shift();for(var i=new Uint8Array(n),r=0,e=0;e1?n-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:{};return t+"://"+this.i()+this.o()+this.opts.path+this.u(n)},i.i=function(){var t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"},i.o=function(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""},i.u=function(t){var n=function(t){var n="";for(var i in t)t.hasOwnProperty(i)&&(n.length&&(n+="&"),n+=encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n}(t);return n.length?"?"+n:""},n}(C),X=function(t){function i(){var n;return(n=t.apply(this,arguments)||this).h=!1,n}e(i,t);var r=i.prototype;return r.doOpen=function(){this.p()},r.pause=function(t){var n=this;this.readyState="pausing";var i=function(){n.readyState="paused",t()};if(this.h||!this.writable){var r=0;this.h&&(r++,this.once("pollComplete",(function(){--r||i()}))),this.writable||(r++,this.once("drain",(function(){--r||i()})))}else i()},r.p=function(){this.h=!0,this.doPoll(),this.emitReserved("poll")},r.onData=function(t){var n=this;(function(t,n){for(var i=t.split(T),r=[],e=0;e0&&void 0!==arguments[0]?arguments[0]:{};return i(t,{xd:this.xd},this.opts),new J(Z,this.uri(),t)},n}(G);function Z(t){var n=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!n||F))return new XMLHttpRequest}catch(t){}if(!n)try{return new(R[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}var _="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),tt=function(t){function i(){return t.apply(this,arguments)||this}e(i,t);var r=i.prototype;return r.doOpen=function(){var t=this.uri(),n=this.opts.protocols,i=_?{}:D(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,i)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()},r.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws.S.unref(),t.onOpen()},this.ws.onclose=function(n){return t.onClose({description:"websocket connection closed",context:n})},this.ws.onmessage=function(n){return t.onData(n.data)},this.ws.onerror=function(n){return t.onError("websocket error",n)}},r.write=function(t){var n=this;this.writable=!1;for(var i=function(){var i=t[r],e=r===t.length-1;b(i,n.supportsBinary,(function(t){try{n.doWrite(i,t)}catch(t){}e&&L((function(){n.writable=!0,n.emitReserved("drain")}),n.setTimeoutFn)}))},r=0;rMath.pow(2,21)-1){u.enqueue(l);break}e=p*Math.pow(2,32)+a.getUint32(4),r=3}else{if(M(i)t){u.enqueue(l);break}}}})}(Number.MAX_SAFE_INTEGER,t.socket.binaryType),r=n.readable.pipeThrough(i).getReader(),e=S();e.readable.pipeTo(n.writable),t.C=e.writable.getWriter();!function n(){r.read().then((function(i){var r=i.done,e=i.value;r||(t.onPacket(e),n())})).catch((function(t){}))}();var o={type:"open"};t.query.sid&&(o.data='{"sid":"'.concat(t.query.sid,'"}')),t.C.write(o).then((function(){return t.onOpen()}))}))}))},r.write=function(t){var n=this;this.writable=!1;for(var i=function(){var i=t[r],e=r===t.length-1;n.C.write(i).then((function(){e&&L((function(){n.writable=!0,n.emitReserved("drain")}),n.setTimeoutFn)}))},r=0;r8e3)throw"URI too long";var n=t,i=t.indexOf("["),r=t.indexOf("]");-1!=i&&-1!=r&&(t=t.substring(0,i)+t.substring(i,r).replace(/:/g,";")+t.substring(r,t.length));for(var e,o,s=ot.exec(t||""),u={},f=14;f--;)u[st[f]]=s[f]||"";return-1!=i&&-1!=r&&(u.source=n,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=function(t,n){var i=/\/{2,9}/g,r=n.replace(i,"/").split("/");"/"!=n.slice(0,1)&&0!==n.length||r.splice(0,1);"/"==n.slice(-1)&&r.splice(r.length-1,1);return r}(0,u.path),u.queryKey=(e=u.query,o={},e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,n,i){n&&(o[n]=i)})),o),u}var ft="function"==typeof addEventListener&&"function"==typeof removeEventListener,ht=[];ft&&addEventListener("offline",(function(){ht.forEach((function(t){return t()}))}),!1);var ct=function(t){function n(n,r){var e;if((e=t.call(this)||this).binaryType="arraybuffer",e.writeBuffer=[],e.L=0,e.R=-1,e.D=-1,e.P=-1,e.I=1/0,n&&"object"===f(n)&&(r=n,n=null),n){var o=ut(n);r.hostname=o.host,r.secure="https"===o.protocol||"wss"===o.protocol,r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=ut(r.host).host);return $(e,r),e.secure=null!=r.secure?r.secure:"undefined"!=typeof location&&"https:"===location.protocol,r.hostname&&!r.port&&(r.port=e.secure?"443":"80"),e.hostname=r.hostname||("undefined"!=typeof location?location.hostname:"localhost"),e.port=r.port||("undefined"!=typeof location&&location.port?location.port:e.secure?"443":"80"),e.transports=[],e.$={},r.transports.forEach((function(t){var n=t.prototype.name;e.transports.push(n),e.$[n]=t})),e.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),e.opts.path=e.opts.path.replace(/\/$/,"")+(e.opts.addTrailingSlash?"/":""),"string"==typeof e.opts.query&&(e.opts.query=function(t){for(var n={},i=t.split("&"),r=0,e=i.length;r1))return this.writeBuffer;for(var t,n=1,i=0;i=57344?i+=3:(r++,i+=4);return i}(t):Math.ceil(1.33*(t.byteLength||t.size))),i>0&&n>this.P)return this.writeBuffer.slice(0,i);n+=2}return this.writeBuffer},r.Z=function(){var t=this;if(!this.I)return!0;var n=Date.now()>this.I;return n&&(this.I=0,L((function(){t.V("ping timeout")}),this.setTimeoutFn)),n},r.write=function(t,n,i){return this.J("message",t,n,i),this},r.send=function(t,n,i){return this.J("message",t,n,i),this},r.J=function(t,n,i,r){if("function"==typeof n&&(r=n,n=void 0),"function"==typeof i&&(r=i,i=null),"closing"!==this.readyState&&"closed"!==this.readyState){(i=i||{}).compress=!1!==i.compress;var e={type:t,data:n,options:i};this.emitReserved("packetCreate",e),this.writeBuffer.push(e),r&&this.once("flush",r),this.flush()}},r.close=function(){var t=this,n=function(){t.V("forced close"),t.transport.close()},i=function i(){t.off("upgrade",i),t.off("upgradeError",i),n()},r=function(){t.once("upgrade",i),t.once("upgradeError",i)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():n()})):this.upgrading?r():n()),this},r.O=function(t){if(n.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this.H();this.emitReserved("error",t),this.V("transport error",t)},r.V=function(t,n){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this.K),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),ft&&(this.q&&removeEventListener("beforeunload",this.q,!1),this.N)){var i=ht.indexOf(this.N);-1!==i&&ht.splice(i,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this.L=0}},n}(C);ct.protocol=4;var at=function(t){function n(){var n;return(n=t.apply(this,arguments)||this)._=[],n}e(n,t);var i=n.prototype;return i.onOpen=function(){if(t.prototype.onOpen.call(this),"open"===this.readyState&&this.opts.upgrade)for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{},r="object"===f(n)?n:i;return(!r.transports||r.transports&&"string"==typeof r.transports[0])&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map((function(t){return et[t]})).filter((function(t){return!!t}))),t.call(this,n,r)||this}return e(n,t),n}(at);return function(t,n){return new pt(t,n)}})); diff --git a/packages/engine.io-client/package.json b/packages/engine.io-client/package.json index 95c5f2bba..6cad94074 100644 --- a/packages/engine.io-client/package.json +++ b/packages/engine.io-client/package.json @@ -2,7 +2,7 @@ "name": "engine.io-client", "description": "Client for the realtime Engine", "license": "MIT", - "version": "6.6.2", + "version": "6.6.3", "main": "./build/cjs/index.js", "module": "./build/esm/index.js", "exports": {