@stomp/stompjs 6.1.2 → 7.0.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("StompJs",[],t):"object"==typeof exports?exports.StompJs=t():e.StompJs=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function s(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)s.d(n,i,function(t){return e[t]}.bind(null,i));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){e.exports=s(1)},function(e,t,s){"use strict";s.r(t),s.d(t,"Client",(function(){return u})),s.d(t,"FrameImpl",(function(){return o})),s.d(t,"Parser",(function(){return r})),s.d(t,"StompConfig",(function(){return m})),s.d(t,"StompHeaders",(function(){return _})),s.d(t,"StompSubscription",(function(){return b})),s.d(t,"StompSocketState",(function(){return c})),s.d(t,"ActivationState",(function(){return a})),s.d(t,"Versions",(function(){return h})),s.d(t,"CompatClient",(function(){return p})),s.d(t,"Stomp",(function(){return y}));const n="\n",i="\0";class o{constructor(e){const{command:t,headers:s,body:n,binaryBody:i,escapeHeaderValues:o,skipContentLengthHeader:r}=e;this.command=t,this.headers=Object.assign({},s||{}),i?(this._binaryBody=i,this.isBinaryBody=!0):(this._body=n||"",this.isBinaryBody=!1),this.escapeHeaderValues=o||!1,this.skipContentLengthHeader=r||!1}get body(){return!this._body&&this.isBinaryBody&&(this._body=(new TextDecoder).decode(this._binaryBody)),this._body}get binaryBody(){return this._binaryBody||this.isBinaryBody||(this._binaryBody=(new TextEncoder).encode(this._body)),this._binaryBody}static fromRawFrame(e,t){const s={},n=e=>e.replace(/^\s+|\s+$/g,"");for(const i of e.headers.reverse()){i.indexOf(":");const r=n(i[0]);let c=n(i[1]);t&&"CONNECT"!==e.command&&"CONNECTED"!==e.command&&(c=o.hdrValueUnEscape(c)),s[r]=c}return new o({command:e.command,headers:s,binaryBody:e.binaryBody,escapeHeaderValues:t})}toString(){return this.serializeCmdAndHeaders()}serialize(){const e=this.serializeCmdAndHeaders();return this.isBinaryBody?o.toUnit8Array(e,this._binaryBody).buffer:e+this._body+i}serializeCmdAndHeaders(){const e=[this.command];this.skipContentLengthHeader&&delete this.headers["content-length"];for(const t of Object.keys(this.headers||{})){const s=this.headers[t];this.escapeHeaderValues&&"CONNECT"!==this.command&&"CONNECTED"!==this.command?e.push(`${t}:${o.hdrValueEscape(""+s)}`):e.push(`${t}:${s}`)}return(this.isBinaryBody||!this.isBodyEmpty()&&!this.skipContentLengthHeader)&&e.push("content-length:"+this.bodyLength()),e.join(n)+n+n}isBodyEmpty(){return 0===this.bodyLength()}bodyLength(){const e=this.binaryBody;return e?e.length:0}static sizeOfUTF8(e){return e?(new TextEncoder).encode(e).length:0}static toUnit8Array(e,t){const s=(new TextEncoder).encode(e),n=new Uint8Array([0]),i=new Uint8Array(s.length+t.length+n.length);return i.set(s),i.set(t,s.length),i.set(n,s.length+t.length),i}static marshall(e){return new o(e).serialize()}static hdrValueEscape(e){return e.replace(/\\/g,"\\\\").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/:/g,"\\c")}static hdrValueUnEscape(e){return e.replace(/\\r/g,"\r").replace(/\\n/g,"\n").replace(/\\c/g,":").replace(/\\\\/g,"\\")}}class r{constructor(e,t){this.onFrame=e,this.onIncomingPing=t,this._encoder=new TextEncoder,this._decoder=new TextDecoder,this._token=[],this._initState()}parseChunk(e,t=!1){let s;if(s=e instanceof ArrayBuffer?new Uint8Array(e):this._encoder.encode(e),t&&0!==s[s.length-1]){const e=new Uint8Array(s.length+1);e.set(s,0),e[s.length]=0,s=e}for(let e=0;e<s.length;e++){const t=s[e];this._onByte(t)}}_collectFrame(e){0!==e&&13!==e&&(10!==e?(this._onByte=this._collectCommand,this._reinjectByte(e)):this.onIncomingPing())}_collectCommand(e){if(13!==e)return 10===e?(this._results.command=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_collectHeaders(e){13!==e&&(10!==e?(this._onByte=this._collectHeaderKey,this._reinjectByte(e)):this._setupCollectBody())}_reinjectByte(e){this._onByte(e)}_collectHeaderKey(e){if(58===e)return this._headerKey=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaderValue);this._consumeByte(e)}_collectHeaderValue(e){if(13!==e)return 10===e?(this._results.headers.push([this._headerKey,this._consumeTokenAsUTF8()]),this._headerKey=void 0,void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_setupCollectBody(){const e=this._results.headers.filter(e=>"content-length"===e[0])[0];e?(this._bodyBytesRemaining=parseInt(e[1],10),this._onByte=this._collectBodyFixedSize):this._onByte=this._collectBodyNullTerminated}_collectBodyNullTerminated(e){0!==e?this._consumeByte(e):this._retrievedBody()}_collectBodyFixedSize(e){0!=this._bodyBytesRemaining--?this._consumeByte(e):this._retrievedBody()}_retrievedBody(){this._results.binaryBody=this._consumeTokenAsRaw(),this.onFrame(this._results),this._initState()}_consumeByte(e){this._token.push(e)}_consumeTokenAsUTF8(){return this._decoder.decode(this._consumeTokenAsRaw())}_consumeTokenAsRaw(){const e=new Uint8Array(this._token);return this._token=[],e}_initState(){this._results={command:void 0,headers:[],binaryBody:void 0},this._token=[],this._headerKey=void 0,this._onByte=this._collectFrame}}var c,a;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(c||(c={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.DEACTIVATING=1]="DEACTIVATING",e[e.INACTIVE=2]="INACTIVE"}(a||(a={}));class h{constructor(e){this.versions=e}supportedVersions(){return this.versions.join(",")}protocolVersions(){return this.versions.map(e=>`v${e.replace(".","")}.stomp`)}}h.V1_0="1.0",h.V1_1="1.1",h.V1_2="1.2",h.default=new h([h.V1_0,h.V1_1,h.V1_2]);class d{constructor(e,t,s={}){this._client=e,this._webSocket=t,this._serverFrameHandlers={CONNECTED:e=>{this.debug("connected to server "+e.headers.server),this._connected=!0,this._connectedVersion=e.headers.version,this._connectedVersion===h.V1_2&&(this._escapeHeaderValues=!0),this._setupHeartbeat(e.headers),this.onConnect(e)},MESSAGE:e=>{const t=e.headers.subscription,s=this._subscriptions[t]||this.onUnhandledMessage,n=e,i=this,o=this._connectedVersion===h.V1_2?n.headers.ack:n.headers["message-id"];n.ack=(e={})=>i.ack(o,t,e),n.nack=(e={})=>i.nack(o,t,e),s(n)},RECEIPT:e=>{const t=this._receiptWatchers[e.headers["receipt-id"]];t?(t(e),delete this._receiptWatchers[e.headers["receipt-id"]]):this.onUnhandledReceipt(e)},ERROR:e=>{this.onStompError(e)}},this._counter=0,this._subscriptions={},this._receiptWatchers={},this._partialData="",this._escapeHeaderValues=!1,this._lastServerActivityTS=Date.now(),this.configure(s)}get connectedVersion(){return this._connectedVersion}get connected(){return this._connected}configure(e){Object.assign(this,e)}start(){const e=new r(e=>{const t=o.fromRawFrame(e,this._escapeHeaderValues);this.logRawCommunication||this.debug("<<< "+t);(this._serverFrameHandlers[t.command]||this.onUnhandledFrame)(t)},()=>{this.debug("<<< PONG")});this._webSocket.onmessage=t=>{if(this.debug("Received data"),this._lastServerActivityTS=Date.now(),this.logRawCommunication){const e=t.data instanceof ArrayBuffer?(new TextDecoder).decode(t.data):t.data;this.debug("<<< "+e)}e.parseChunk(t.data,this.appendMissingNULLonIncoming)},this._onclose=e=>{this.debug("Connection closed to "+this._client.brokerURL),this._cleanUp(),this.onWebSocketClose(e)},this._webSocket.onclose=this._onclose,this._webSocket.onerror=e=>{this.onWebSocketError(e)},this._webSocket.onopen=()=>{const e=Object.assign({},this.connectHeaders);this.debug("Web Socket Opened..."),e["accept-version"]=this.stompVersions.supportedVersions(),e["heart-beat"]=[this.heartbeatOutgoing,this.heartbeatIncoming].join(","),this._transmit({command:"CONNECT",headers:e})}}_setupHeartbeat(e){if(e.version!==h.V1_1&&e.version!==h.V1_2)return;if(!e["heart-beat"])return;const[t,s]=e["heart-beat"].split(",").map(e=>parseInt(e,10));if(0!==this.heartbeatOutgoing&&0!==s){const e=Math.max(this.heartbeatOutgoing,s);this.debug(`send PING every ${e}ms`),this._pinger=setInterval(()=>{this._webSocket.readyState===c.OPEN&&(this._webSocket.send(n),this.debug(">>> PING"))},e)}if(0!==this.heartbeatIncoming&&0!==t){const e=Math.max(this.heartbeatIncoming,t);this.debug(`check PONG every ${e}ms`),this._ponger=setInterval(()=>{const t=Date.now()-this._lastServerActivityTS;t>2*e&&(this.debug(`did not receive server activity for the last ${t}ms`),this._closeOrDiscardWebsocket())},e)}}_closeOrDiscardWebsocket(){this.discardWebsocketOnCommFailure?(this.debug("Discarding websocket, the underlying socket may linger for a while"),this._discardWebsocket()):(this.debug("Issuing close on the websocket"),this._closeWebsocket())}forceDisconnect(){this._webSocket&&(this._webSocket.readyState!==c.CONNECTING&&this._webSocket.readyState!==c.OPEN||this._closeOrDiscardWebsocket())}_closeWebsocket(){this._webSocket.onmessage=()=>{},this._webSocket.close()}_discardWebsocket(){var e,t;this._webSocket.terminate||(e=this._webSocket,t=e=>this.debug(e),e.terminate=function(){const e=()=>{};this.onerror=e,this.onmessage=e,this.onopen=e;const s=new Date,n=this.onclose;this.onclose=e=>{const n=(new Date).getTime()-s.getTime();t(`Discarded socket closed after ${n}ms, with code/reason: ${e.code}/${e.reason}`)},this.close(),n.call(this,{code:4001,reason:"Heartbeat failure, discarding the socket",wasClean:!1})}),this._webSocket.terminate()}_transmit(e){const{command:t,headers:s,body:n,binaryBody:i,skipContentLengthHeader:r}=e,c=new o({command:t,headers:s,body:n,binaryBody:i,escapeHeaderValues:this._escapeHeaderValues,skipContentLengthHeader:r});let a=c.serialize();if(this.logRawCommunication?this.debug(">>> "+a):this.debug(">>> "+c),this.forceBinaryWSFrames&&"string"==typeof a&&(a=(new TextEncoder).encode(a)),"string"==typeof a&&this.splitLargeFrames){let e=a;for(;e.length>0;){const t=e.substring(0,this.maxWebSocketChunkSize);e=e.substring(this.maxWebSocketChunkSize),this._webSocket.send(t),this.debug(`chunk sent = ${t.length}, remaining = ${e.length}`)}}else this._webSocket.send(a)}dispose(){if(this.connected)try{const e=Object.assign({},this.disconnectHeaders);e.receipt||(e.receipt="close-"+this._counter++),this.watchForReceipt(e.receipt,e=>{this._closeWebsocket(),this._cleanUp(),this.onDisconnect(e)}),this._transmit({command:"DISCONNECT",headers:e})}catch(e){this.debug("Ignoring error during disconnect "+e)}else this._webSocket.readyState!==c.CONNECTING&&this._webSocket.readyState!==c.OPEN||this._closeWebsocket()}_cleanUp(){this._connected=!1,this._pinger&&clearInterval(this._pinger),this._ponger&&clearInterval(this._ponger)}publish(e){const{destination:t,headers:s,body:n,binaryBody:i,skipContentLengthHeader:o}=e,r=Object.assign({destination:t},s);this._transmit({command:"SEND",headers:r,body:n,binaryBody:i,skipContentLengthHeader:o})}watchForReceipt(e,t){this._receiptWatchers[e]=t}subscribe(e,t,s={}){(s=Object.assign({},s)).id||(s.id="sub-"+this._counter++),s.destination=e,this._subscriptions[s.id]=t,this._transmit({command:"SUBSCRIBE",headers:s});const n=this;return{id:s.id,unsubscribe:e=>n.unsubscribe(s.id,e)}}unsubscribe(e,t={}){t=Object.assign({},t),delete this._subscriptions[e],t.id=e,this._transmit({command:"UNSUBSCRIBE",headers:t})}begin(e){const t=e||"tx-"+this._counter++;this._transmit({command:"BEGIN",headers:{transaction:t}});const s=this;return{id:t,commit(){s.commit(t)},abort(){s.abort(t)}}}commit(e){this._transmit({command:"COMMIT",headers:{transaction:e}})}abort(e){this._transmit({command:"ABORT",headers:{transaction:e}})}ack(e,t,s={}){s=Object.assign({},s),this._connectedVersion===h.V1_2?s.id=e:s["message-id"]=e,s.subscription=t,this._transmit({command:"ACK",headers:s})}nack(e,t,s={}){return s=Object.assign({},s),this._connectedVersion===h.V1_2?s.id=e:s["message-id"]=e,s.subscription=t,this._transmit({command:"NACK",headers:s})}}var l=function(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{a(n.next(e))}catch(e){o(e)}}function c(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,c)}a((n=n.apply(e,t||[])).next())}))};class u{constructor(e={}){this.stompVersions=h.default,this.connectionTimeout=0,this.reconnectDelay=5e3,this.heartbeatIncoming=1e4,this.heartbeatOutgoing=1e4,this.splitLargeFrames=!1,this.maxWebSocketChunkSize=8192,this.forceBinaryWSFrames=!1,this.appendMissingNULLonIncoming=!1,this.state=a.INACTIVE;const t=()=>{};this.debug=t,this.beforeConnect=t,this.onConnect=t,this.onDisconnect=t,this.onUnhandledMessage=t,this.onUnhandledReceipt=t,this.onUnhandledFrame=t,this.onStompError=t,this.onWebSocketClose=t,this.onWebSocketError=t,this.logRawCommunication=!1,this.onChangeState=t,this.connectHeaders={},this._disconnectHeaders={},this.configure(e)}get webSocket(){return this._stompHandler?this._stompHandler._webSocket:void 0}get disconnectHeaders(){return this._disconnectHeaders}set disconnectHeaders(e){this._disconnectHeaders=e,this._stompHandler&&(this._stompHandler.disconnectHeaders=this._disconnectHeaders)}get connected(){return!!this._stompHandler&&this._stompHandler.connected}get connectedVersion(){return this._stompHandler?this._stompHandler.connectedVersion:void 0}get active(){return this.state===a.ACTIVE}_changeState(e){this.state=e,this.onChangeState(e)}configure(e){Object.assign(this,e)}activate(){if(this.state===a.DEACTIVATING)throw this.debug("Still DEACTIVATING, please await call to deactivate before trying to re-activate"),new Error("Still DEACTIVATING, can not activate now");this.active?this.debug("Already ACTIVE, ignoring request to activate"):(this._changeState(a.ACTIVE),this._connect())}_connect(){return l(this,void 0,void 0,(function*(){if(this.connected)return void this.debug("STOMP: already connected, nothing to do");if(yield this.beforeConnect(),!this.active)return void this.debug("Client has been marked inactive, will not attempt to connect");this.connectionTimeout>0&&(this._connectionWatcher&&clearTimeout(this._connectionWatcher),this._connectionWatcher=setTimeout(()=>{this.connected||(this.debug(`Connection not established in ${this.connectionTimeout}ms, closing socket`),this.forceDisconnect())},this.connectionTimeout)),this.debug("Opening Web Socket...");const e=this._createWebSocket();this._stompHandler=new d(this,e,{debug:this.debug,stompVersions:this.stompVersions,connectHeaders:this.connectHeaders,disconnectHeaders:this._disconnectHeaders,heartbeatIncoming:this.heartbeatIncoming,heartbeatOutgoing:this.heartbeatOutgoing,splitLargeFrames:this.splitLargeFrames,maxWebSocketChunkSize:this.maxWebSocketChunkSize,forceBinaryWSFrames:this.forceBinaryWSFrames,logRawCommunication:this.logRawCommunication,appendMissingNULLonIncoming:this.appendMissingNULLonIncoming,discardWebsocketOnCommFailure:this.discardWebsocketOnCommFailure,onConnect:e=>{if(this._connectionWatcher&&(clearTimeout(this._connectionWatcher),this._connectionWatcher=void 0),!this.active)return this.debug("STOMP got connected while deactivate was issued, will disconnect now"),void this._disposeStompHandler();this.onConnect(e)},onDisconnect:e=>{this.onDisconnect(e)},onStompError:e=>{this.onStompError(e)},onWebSocketClose:e=>{this._stompHandler=void 0,this.state===a.DEACTIVATING&&(this._resolveSocketClose(),this._resolveSocketClose=void 0,this._changeState(a.INACTIVE)),this.onWebSocketClose(e),this.active&&this._schedule_reconnect()},onWebSocketError:e=>{this.onWebSocketError(e)},onUnhandledMessage:e=>{this.onUnhandledMessage(e)},onUnhandledReceipt:e=>{this.onUnhandledReceipt(e)},onUnhandledFrame:e=>{this.onUnhandledFrame(e)}}),this._stompHandler.start()}))}_createWebSocket(){let e;return e=this.webSocketFactory?this.webSocketFactory():new WebSocket(this.brokerURL,this.stompVersions.protocolVersions()),e.binaryType="arraybuffer",e}_schedule_reconnect(){this.reconnectDelay>0&&(this.debug(`STOMP: scheduling reconnection in ${this.reconnectDelay}ms`),this._reconnector=setTimeout(()=>{this._connect()},this.reconnectDelay))}deactivate(){return l(this,void 0,void 0,(function*(){let e;return this.state!==a.ACTIVE?(this.debug(`Already ${a[this.state]}, ignoring call to deactivate`),Promise.resolve()):(this._changeState(a.DEACTIVATING),this._reconnector&&clearTimeout(this._reconnector),this._stompHandler&&this.webSocket.readyState!==c.CLOSED?(e=new Promise((e,t)=>{this._resolveSocketClose=e}),this._disposeStompHandler(),e):(this._changeState(a.INACTIVE),Promise.resolve()))}))}forceDisconnect(){this._stompHandler&&this._stompHandler.forceDisconnect()}_disposeStompHandler(){this._stompHandler&&(this._stompHandler.dispose(),this._stompHandler=null)}publish(e){this._stompHandler.publish(e)}watchForReceipt(e,t){this._stompHandler.watchForReceipt(e,t)}subscribe(e,t,s={}){return this._stompHandler.subscribe(e,t,s)}unsubscribe(e,t={}){this._stompHandler.unsubscribe(e,t)}begin(e){return this._stompHandler.begin(e)}commit(e){this._stompHandler.commit(e)}abort(e){this._stompHandler.abort(e)}ack(e,t,s={}){this._stompHandler.ack(e,t,s)}nack(e,t,s={}){this._stompHandler.nack(e,t,s)}}class m{}class _{}class b{}class g{constructor(e){this.client=e}get outgoing(){return this.client.heartbeatOutgoing}set outgoing(e){this.client.heartbeatOutgoing=e}get incoming(){return this.client.heartbeatIncoming}set incoming(e){this.client.heartbeatIncoming=e}}class p extends u{constructor(e){super(),this.maxWebSocketFrameSize=16384,this._heartbeatInfo=new g(this),this.reconnect_delay=0,this.webSocketFactory=e,this.debug=(...e)=>{console.log(...e)}}_parseConnect(...e){let t,s,n,i={};if(e.length<2)throw new Error("Connect requires at least 2 arguments");if("function"==typeof e[1])[i,s,n,t]=e;else switch(e.length){case 6:[i.login,i.passcode,s,n,t,i.host]=e;break;default:[i.login,i.passcode,s,n,t]=e}return[i,s,n,t]}connect(...e){const t=this._parseConnect(...e);t[0]&&(this.connectHeaders=t[0]),t[1]&&(this.onConnect=t[1]),t[2]&&(this.onStompError=t[2]),t[3]&&(this.onWebSocketClose=t[3]),super.activate()}disconnect(e,t={}){e&&(this.onDisconnect=e),this.disconnectHeaders=t,super.deactivate()}send(e,t={},s=""){const n=!1===(t=Object.assign({},t))["content-length"];n&&delete t["content-length"],this.publish({destination:e,headers:t,body:s,skipContentLengthHeader:n})}set reconnect_delay(e){this.reconnectDelay=e}get ws(){return this.webSocket}get version(){return this.connectedVersion}get onreceive(){return this.onUnhandledMessage}set onreceive(e){this.onUnhandledMessage=e}get onreceipt(){return this.onUnhandledReceipt}set onreceipt(e){this.onUnhandledReceipt=e}get heartbeat(){return this._heartbeatInfo}set heartbeat(e){this.heartbeatIncoming=e.incoming,this.heartbeatOutgoing=e.outgoing}}class y{static client(e,t){null==t&&(t=h.default.protocolVersions());return new p(()=>new(y.WebSocketClass||WebSocket)(e,t))}static over(e){let t;return"function"==typeof e?t=e:(console.warn("Stomp.over did not receive a factory, auto reconnect will not work. Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over"),t=()=>e),new p(t)}}y.WebSocketClass=null}])}));
2
- //# sourceMappingURL=stomp.umd.min.js.map
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("StompJs",[],t):"object"==typeof exports?exports.StompJs=t():e.StompJs=t()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ActivationState:()=>r,Client:()=>d,CompatClient:()=>_,FrameImpl:()=>s,Parser:()=>i,Stomp:()=>g,StompConfig:()=>l,StompHeaders:()=>m,StompSocketState:()=>o,Versions:()=>c});const n="\n";class s{constructor(e){const{command:t,headers:n,body:s,binaryBody:i,escapeHeaderValues:o,skipContentLengthHeader:r}=e;this.command=t,this.headers=Object.assign({},n||{}),i?(this._binaryBody=i,this.isBinaryBody=!0):(this._body=s||"",this.isBinaryBody=!1),this.escapeHeaderValues=o||!1,this.skipContentLengthHeader=r||!1}get body(){return!this._body&&this.isBinaryBody&&(this._body=(new TextDecoder).decode(this._binaryBody)),this._body||""}get binaryBody(){return this._binaryBody||this.isBinaryBody||(this._binaryBody=(new TextEncoder).encode(this._body)),this._binaryBody}static fromRawFrame(e,t){const n={},i=e=>e.replace(/^\s+|\s+$/g,"");for(const o of e.headers.reverse()){o.indexOf(":");const r=i(o[0]);let c=i(o[1]);t&&"CONNECT"!==e.command&&"CONNECTED"!==e.command&&(c=s.hdrValueUnEscape(c)),n[r]=c}return new s({command:e.command,headers:n,binaryBody:e.binaryBody,escapeHeaderValues:t})}toString(){return this.serializeCmdAndHeaders()}serialize(){const e=this.serializeCmdAndHeaders();return this.isBinaryBody?s.toUnit8Array(e,this._binaryBody).buffer:e+this._body+"\0"}serializeCmdAndHeaders(){const e=[this.command];this.skipContentLengthHeader&&delete this.headers["content-length"];for(const t of Object.keys(this.headers||{})){const n=this.headers[t];this.escapeHeaderValues&&"CONNECT"!==this.command&&"CONNECTED"!==this.command?e.push(`${t}:${s.hdrValueEscape(`${n}`)}`):e.push(`${t}:${n}`)}return(this.isBinaryBody||!this.isBodyEmpty()&&!this.skipContentLengthHeader)&&e.push(`content-length:${this.bodyLength()}`),e.join(n)+n+n}isBodyEmpty(){return 0===this.bodyLength()}bodyLength(){const e=this.binaryBody;return e?e.length:0}static sizeOfUTF8(e){return e?(new TextEncoder).encode(e).length:0}static toUnit8Array(e,t){const n=(new TextEncoder).encode(e),s=new Uint8Array([0]),i=new Uint8Array(n.length+t.length+s.length);return i.set(n),i.set(t,n.length),i.set(s,n.length+t.length),i}static marshall(e){return new s(e).serialize()}static hdrValueEscape(e){return e.replace(/\\/g,"\\\\").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/:/g,"\\c")}static hdrValueUnEscape(e){return e.replace(/\\r/g,"\r").replace(/\\n/g,"\n").replace(/\\c/g,":").replace(/\\\\/g,"\\")}}class i{constructor(e,t){this.onFrame=e,this.onIncomingPing=t,this._encoder=new TextEncoder,this._decoder=new TextDecoder,this._token=[],this._initState()}parseChunk(e,t=!1){let n;if(n=e instanceof ArrayBuffer?new Uint8Array(e):this._encoder.encode(e),t&&0!==n[n.length-1]){const e=new Uint8Array(n.length+1);e.set(n,0),e[n.length]=0,n=e}for(let e=0;e<n.length;e++){const t=n[e];this._onByte(t)}}_collectFrame(e){0!==e&&13!==e&&(10!==e?(this._onByte=this._collectCommand,this._reinjectByte(e)):this.onIncomingPing())}_collectCommand(e){if(13!==e)return 10===e?(this._results.command=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_collectHeaders(e){13!==e&&(10!==e?(this._onByte=this._collectHeaderKey,this._reinjectByte(e)):this._setupCollectBody())}_reinjectByte(e){this._onByte(e)}_collectHeaderKey(e){if(58===e)return this._headerKey=this._consumeTokenAsUTF8(),void(this._onByte=this._collectHeaderValue);this._consumeByte(e)}_collectHeaderValue(e){if(13!==e)return 10===e?(this._results.headers.push([this._headerKey,this._consumeTokenAsUTF8()]),this._headerKey=void 0,void(this._onByte=this._collectHeaders)):void this._consumeByte(e)}_setupCollectBody(){const e=this._results.headers.filter((e=>"content-length"===e[0]))[0];e?(this._bodyBytesRemaining=parseInt(e[1],10),this._onByte=this._collectBodyFixedSize):this._onByte=this._collectBodyNullTerminated}_collectBodyNullTerminated(e){0!==e?this._consumeByte(e):this._retrievedBody()}_collectBodyFixedSize(e){0!=this._bodyBytesRemaining--?this._consumeByte(e):this._retrievedBody()}_retrievedBody(){this._results.binaryBody=this._consumeTokenAsRaw();try{this.onFrame(this._results)}catch(e){console.log("Ignoring an exception thrown by a frame handler. Original exception: ",e)}this._initState()}_consumeByte(e){this._token.push(e)}_consumeTokenAsUTF8(){return this._decoder.decode(this._consumeTokenAsRaw())}_consumeTokenAsRaw(){const e=new Uint8Array(this._token);return this._token=[],e}_initState(){this._results={command:void 0,headers:[],binaryBody:void 0},this._token=[],this._headerKey=void 0,this._onByte=this._collectFrame}}var o,r;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(o||(o={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.DEACTIVATING=1]="DEACTIVATING",e[e.INACTIVE=2]="INACTIVE"}(r||(r={}));class c{constructor(e){this.versions=e}supportedVersions(){return this.versions.join(",")}protocolVersions(){return this.versions.map((e=>`v${e.replace(".","")}.stomp`))}}c.V1_0="1.0",c.V1_1="1.1",c.V1_2="1.2",c.default=new c([c.V1_2,c.V1_1,c.V1_0]);class a{constructor(e,t,n){this._client=e,this._webSocket=t,this._connected=!1,this._serverFrameHandlers={CONNECTED:e=>{this.debug(`connected to server ${e.headers.server}`),this._connected=!0,this._connectedVersion=e.headers.version,this._connectedVersion===c.V1_2&&(this._escapeHeaderValues=!0),this._setupHeartbeat(e.headers),this.onConnect(e)},MESSAGE:e=>{const t=e.headers.subscription,n=this._subscriptions[t]||this.onUnhandledMessage,s=e,i=this,o=this._connectedVersion===c.V1_2?s.headers.ack:s.headers["message-id"];s.ack=(e={})=>i.ack(o,t,e),s.nack=(e={})=>i.nack(o,t,e),n(s)},RECEIPT:e=>{const t=this._receiptWatchers[e.headers["receipt-id"]];t?(t(e),delete this._receiptWatchers[e.headers["receipt-id"]]):this.onUnhandledReceipt(e)},ERROR:e=>{this.onStompError(e)}},this._counter=0,this._subscriptions={},this._receiptWatchers={},this._partialData="",this._escapeHeaderValues=!1,this._lastServerActivityTS=Date.now(),this.debug=n.debug,this.stompVersions=n.stompVersions,this.connectHeaders=n.connectHeaders,this.disconnectHeaders=n.disconnectHeaders,this.heartbeatIncoming=n.heartbeatIncoming,this.heartbeatOutgoing=n.heartbeatOutgoing,this.splitLargeFrames=n.splitLargeFrames,this.maxWebSocketChunkSize=n.maxWebSocketChunkSize,this.forceBinaryWSFrames=n.forceBinaryWSFrames,this.logRawCommunication=n.logRawCommunication,this.appendMissingNULLonIncoming=n.appendMissingNULLonIncoming,this.discardWebsocketOnCommFailure=n.discardWebsocketOnCommFailure,this.onConnect=n.onConnect,this.onDisconnect=n.onDisconnect,this.onStompError=n.onStompError,this.onWebSocketClose=n.onWebSocketClose,this.onWebSocketError=n.onWebSocketError,this.onUnhandledMessage=n.onUnhandledMessage,this.onUnhandledReceipt=n.onUnhandledReceipt,this.onUnhandledFrame=n.onUnhandledFrame}get connectedVersion(){return this._connectedVersion}get connected(){return this._connected}start(){const e=new i((e=>{const t=s.fromRawFrame(e,this._escapeHeaderValues);this.logRawCommunication||this.debug(`<<< ${t}`),(this._serverFrameHandlers[t.command]||this.onUnhandledFrame)(t)}),(()=>{this.debug("<<< PONG")}));this._webSocket.onmessage=t=>{if(this.debug("Received data"),this._lastServerActivityTS=Date.now(),this.logRawCommunication){const e=t.data instanceof ArrayBuffer?(new TextDecoder).decode(t.data):t.data;this.debug(`<<< ${e}`)}e.parseChunk(t.data,this.appendMissingNULLonIncoming)},this._webSocket.onclose=e=>{this.debug(`Connection closed to ${this._client.brokerURL}`),this._cleanUp(),this.onWebSocketClose(e)},this._webSocket.onerror=e=>{this.onWebSocketError(e)},this._webSocket.onopen=()=>{const e=Object.assign({},this.connectHeaders);this.debug("Web Socket Opened..."),e["accept-version"]=this.stompVersions.supportedVersions(),e["heart-beat"]=[this.heartbeatOutgoing,this.heartbeatIncoming].join(","),this._transmit({command:"CONNECT",headers:e})}}_setupHeartbeat(e){if(e.version!==c.V1_1&&e.version!==c.V1_2)return;if(!e["heart-beat"])return;const[t,s]=e["heart-beat"].split(",").map((e=>parseInt(e,10)));if(0!==this.heartbeatOutgoing&&0!==s){const e=Math.max(this.heartbeatOutgoing,s);this.debug(`send PING every ${e}ms`),this._pinger=setInterval((()=>{this._webSocket.readyState===o.OPEN&&(this._webSocket.send(n),this.debug(">>> PING"))}),e)}if(0!==this.heartbeatIncoming&&0!==t){const e=Math.max(this.heartbeatIncoming,t);this.debug(`check PONG every ${e}ms`),this._ponger=setInterval((()=>{const t=Date.now()-this._lastServerActivityTS;t>2*e&&(this.debug(`did not receive server activity for the last ${t}ms`),this._closeOrDiscardWebsocket())}),e)}}_closeOrDiscardWebsocket(){this.discardWebsocketOnCommFailure?(this.debug("Discarding websocket, the underlying socket may linger for a while"),this.discardWebsocket()):(this.debug("Issuing close on the websocket"),this._closeWebsocket())}forceDisconnect(){this._webSocket&&(this._webSocket.readyState!==o.CONNECTING&&this._webSocket.readyState!==o.OPEN||this._closeOrDiscardWebsocket())}_closeWebsocket(){this._webSocket.onmessage=()=>{},this._webSocket.close()}discardWebsocket(){var e,t;"function"!=typeof this._webSocket.terminate&&(e=this._webSocket,t=e=>this.debug(e),e.terminate=function(){const n=()=>{};this.onerror=n,this.onmessage=n,this.onopen=n;const s=new Date,i=Math.random().toString().substring(2,8),o=this.onclose;this.onclose=e=>{const n=(new Date).getTime()-s.getTime();t(`Discarded socket (#${i}) closed after ${n}ms, with code/reason: ${e.code}/${e.reason}`)},this.close(),null==o||o.call(e,{code:4001,reason:`Quick discarding socket (#${i}) without waiting for the shutdown sequence.`,wasClean:!1})}),this._webSocket.terminate()}_transmit(e){const{command:t,headers:n,body:i,binaryBody:o,skipContentLengthHeader:r}=e,c=new s({command:t,headers:n,body:i,binaryBody:o,escapeHeaderValues:this._escapeHeaderValues,skipContentLengthHeader:r});let a=c.serialize();if(this.logRawCommunication?this.debug(`>>> ${a}`):this.debug(`>>> ${c}`),this.forceBinaryWSFrames&&"string"==typeof a&&(a=(new TextEncoder).encode(a)),"string"==typeof a&&this.splitLargeFrames){let e=a;for(;e.length>0;){const t=e.substring(0,this.maxWebSocketChunkSize);e=e.substring(this.maxWebSocketChunkSize),this._webSocket.send(t),this.debug(`chunk sent = ${t.length}, remaining = ${e.length}`)}}else this._webSocket.send(a)}dispose(){if(this.connected)try{const e=Object.assign({},this.disconnectHeaders);e.receipt||(e.receipt="close-"+this._counter++),this.watchForReceipt(e.receipt,(e=>{this._closeWebsocket(),this._cleanUp(),this.onDisconnect(e)})),this._transmit({command:"DISCONNECT",headers:e})}catch(e){this.debug(`Ignoring error during disconnect ${e}`)}else this._webSocket.readyState!==o.CONNECTING&&this._webSocket.readyState!==o.OPEN||this._closeWebsocket()}_cleanUp(){this._connected=!1,this._pinger&&(clearInterval(this._pinger),this._pinger=void 0),this._ponger&&(clearInterval(this._ponger),this._ponger=void 0)}publish(e){const{destination:t,headers:n,body:s,binaryBody:i,skipContentLengthHeader:o}=e,r=Object.assign({destination:t},n);this._transmit({command:"SEND",headers:r,body:s,binaryBody:i,skipContentLengthHeader:o})}watchForReceipt(e,t){this._receiptWatchers[e]=t}subscribe(e,t,n={}){(n=Object.assign({},n)).id||(n.id="sub-"+this._counter++),n.destination=e,this._subscriptions[n.id]=t,this._transmit({command:"SUBSCRIBE",headers:n});const s=this;return{id:n.id,unsubscribe:e=>s.unsubscribe(n.id,e)}}unsubscribe(e,t={}){t=Object.assign({},t),delete this._subscriptions[e],t.id=e,this._transmit({command:"UNSUBSCRIBE",headers:t})}begin(e){const t=e||"tx-"+this._counter++;this._transmit({command:"BEGIN",headers:{transaction:t}});const n=this;return{id:t,commit(){n.commit(t)},abort(){n.abort(t)}}}commit(e){this._transmit({command:"COMMIT",headers:{transaction:e}})}abort(e){this._transmit({command:"ABORT",headers:{transaction:e}})}ack(e,t,n={}){n=Object.assign({},n),this._connectedVersion===c.V1_2?n.id=e:n["message-id"]=e,n.subscription=t,this._transmit({command:"ACK",headers:n})}nack(e,t,n={}){return n=Object.assign({},n),this._connectedVersion===c.V1_2?n.id=e:n["message-id"]=e,n.subscription=t,this._transmit({command:"NACK",headers:n})}}var h=function(e,t,n,s){return new(n||(n=Promise))((function(i,o){function r(e){try{a(s.next(e))}catch(e){o(e)}}function c(e){try{a(s.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,c)}a((s=s.apply(e,t||[])).next())}))};class d{constructor(e={}){this.stompVersions=c.default,this.connectionTimeout=0,this.reconnectDelay=5e3,this.heartbeatIncoming=1e4,this.heartbeatOutgoing=1e4,this.splitLargeFrames=!1,this.maxWebSocketChunkSize=8192,this.forceBinaryWSFrames=!1,this.appendMissingNULLonIncoming=!1,this.discardWebsocketOnCommFailure=!1,this.state=r.INACTIVE;const t=()=>{};this.debug=t,this.beforeConnect=t,this.onConnect=t,this.onDisconnect=t,this.onUnhandledMessage=t,this.onUnhandledReceipt=t,this.onUnhandledFrame=t,this.onStompError=t,this.onWebSocketClose=t,this.onWebSocketError=t,this.logRawCommunication=!1,this.onChangeState=t,this.connectHeaders={},this._disconnectHeaders={},this.configure(e)}get webSocket(){var e;return null===(e=this._stompHandler)||void 0===e?void 0:e._webSocket}get disconnectHeaders(){return this._disconnectHeaders}set disconnectHeaders(e){this._disconnectHeaders=e,this._stompHandler&&(this._stompHandler.disconnectHeaders=this._disconnectHeaders)}get connected(){return!!this._stompHandler&&this._stompHandler.connected}get connectedVersion(){return this._stompHandler?this._stompHandler.connectedVersion:void 0}get active(){return this.state===r.ACTIVE}_changeState(e){this.state=e,this.onChangeState(e)}configure(e){Object.assign(this,e)}activate(){if(this.state===r.DEACTIVATING)throw this.debug("Still DEACTIVATING, please await call to deactivate before trying to re-activate"),new Error("Still DEACTIVATING, can not activate now");this.active?this.debug("Already ACTIVE, ignoring request to activate"):(this._changeState(r.ACTIVE),this._connect())}_connect(){return h(this,void 0,void 0,(function*(){if(this.connected)return void this.debug("STOMP: already connected, nothing to do");if(yield this.beforeConnect(),!this.active)return void this.debug("Client has been marked inactive, will not attempt to connect");this.connectionTimeout>0&&(this._connectionWatcher&&clearTimeout(this._connectionWatcher),this._connectionWatcher=setTimeout((()=>{this.connected||(this.debug(`Connection not established in ${this.connectionTimeout}ms, closing socket`),this.forceDisconnect())}),this.connectionTimeout)),this.debug("Opening Web Socket...");const e=this._createWebSocket();this._stompHandler=new a(this,e,{debug:this.debug,stompVersions:this.stompVersions,connectHeaders:this.connectHeaders,disconnectHeaders:this._disconnectHeaders,heartbeatIncoming:this.heartbeatIncoming,heartbeatOutgoing:this.heartbeatOutgoing,splitLargeFrames:this.splitLargeFrames,maxWebSocketChunkSize:this.maxWebSocketChunkSize,forceBinaryWSFrames:this.forceBinaryWSFrames,logRawCommunication:this.logRawCommunication,appendMissingNULLonIncoming:this.appendMissingNULLonIncoming,discardWebsocketOnCommFailure:this.discardWebsocketOnCommFailure,onConnect:e=>{if(this._connectionWatcher&&(clearTimeout(this._connectionWatcher),this._connectionWatcher=void 0),!this.active)return this.debug("STOMP got connected while deactivate was issued, will disconnect now"),void this._disposeStompHandler();this.onConnect(e)},onDisconnect:e=>{this.onDisconnect(e)},onStompError:e=>{this.onStompError(e)},onWebSocketClose:e=>{this._stompHandler=void 0,this.state===r.DEACTIVATING&&this._changeState(r.INACTIVE),this.onWebSocketClose(e),this.active&&this._schedule_reconnect()},onWebSocketError:e=>{this.onWebSocketError(e)},onUnhandledMessage:e=>{this.onUnhandledMessage(e)},onUnhandledReceipt:e=>{this.onUnhandledReceipt(e)},onUnhandledFrame:e=>{this.onUnhandledFrame(e)}}),this._stompHandler.start()}))}_createWebSocket(){let e;if(this.webSocketFactory)e=this.webSocketFactory();else{if(!this.brokerURL)throw new Error("Either brokerURL or webSocketFactory must be provided");e=new WebSocket(this.brokerURL,this.stompVersions.protocolVersions())}return e.binaryType="arraybuffer",e}_schedule_reconnect(){this.reconnectDelay>0&&(this.debug(`STOMP: scheduling reconnection in ${this.reconnectDelay}ms`),this._reconnector=setTimeout((()=>{this._connect()}),this.reconnectDelay))}deactivate(e={}){var t;return h(this,void 0,void 0,(function*(){const n=e.force||!1,s=this.active;let i;if(this.state===r.INACTIVE)return this.debug("Already INACTIVE, nothing more to do"),Promise.resolve();if(this._changeState(r.DEACTIVATING),this._reconnector&&(clearTimeout(this._reconnector),this._reconnector=void 0),!this._stompHandler||this.webSocket.readyState===o.CLOSED)return this._changeState(r.INACTIVE),Promise.resolve();{const e=this._stompHandler.onWebSocketClose;i=new Promise(((t,n)=>{this._stompHandler.onWebSocketClose=n=>{e(n),t()}}))}return n?null===(t=this._stompHandler)||void 0===t||t.discardWebsocket():s&&this._disposeStompHandler(),i}))}forceDisconnect(){this._stompHandler&&this._stompHandler.forceDisconnect()}_disposeStompHandler(){this._stompHandler&&this._stompHandler.dispose()}publish(e){this._checkConnection(),this._stompHandler.publish(e)}_checkConnection(){if(!this.connected)throw new TypeError("There is no underlying STOMP connection")}watchForReceipt(e,t){this._checkConnection(),this._stompHandler.watchForReceipt(e,t)}subscribe(e,t,n={}){return this._checkConnection(),this._stompHandler.subscribe(e,t,n)}unsubscribe(e,t={}){this._checkConnection(),this._stompHandler.unsubscribe(e,t)}begin(e){return this._checkConnection(),this._stompHandler.begin(e)}commit(e){this._checkConnection(),this._stompHandler.commit(e)}abort(e){this._checkConnection(),this._stompHandler.abort(e)}ack(e,t,n={}){this._checkConnection(),this._stompHandler.ack(e,t,n)}nack(e,t,n={}){this._checkConnection(),this._stompHandler.nack(e,t,n)}}class l{}class m{}class u{constructor(e){this.client=e}get outgoing(){return this.client.heartbeatOutgoing}set outgoing(e){this.client.heartbeatOutgoing=e}get incoming(){return this.client.heartbeatIncoming}set incoming(e){this.client.heartbeatIncoming=e}}class _ extends d{constructor(e){super(),this.maxWebSocketFrameSize=16384,this._heartbeatInfo=new u(this),this.reconnect_delay=0,this.webSocketFactory=e,this.debug=(...e)=>{console.log(...e)}}_parseConnect(...e){let t,n,s,i={};if(e.length<2)throw new Error("Connect requires at least 2 arguments");return"function"==typeof e[1]?[i,n,s,t]=e:6===e.length?[i.login,i.passcode,n,s,t,i.host]=e:[i.login,i.passcode,n,s,t]=e,[i,n,s,t]}connect(...e){const t=this._parseConnect(...e);t[0]&&(this.connectHeaders=t[0]),t[1]&&(this.onConnect=t[1]),t[2]&&(this.onStompError=t[2]),t[3]&&(this.onWebSocketClose=t[3]),super.activate()}disconnect(e,t={}){e&&(this.onDisconnect=e),this.disconnectHeaders=t,super.deactivate()}send(e,t={},n=""){const s=!1===(t=Object.assign({},t))["content-length"];s&&delete t["content-length"],this.publish({destination:e,headers:t,body:n,skipContentLengthHeader:s})}set reconnect_delay(e){this.reconnectDelay=e}get ws(){return this.webSocket}get version(){return this.connectedVersion}get onreceive(){return this.onUnhandledMessage}set onreceive(e){this.onUnhandledMessage=e}get onreceipt(){return this.onUnhandledReceipt}set onreceipt(e){this.onUnhandledReceipt=e}get heartbeat(){return this._heartbeatInfo}set heartbeat(e){this.heartbeatIncoming=e.incoming,this.heartbeatOutgoing=e.outgoing}}class g{static client(e,t){return null==t&&(t=c.default.protocolVersions()),new _((()=>new(g.WebSocketClass||WebSocket)(e,t)))}static over(e){let t;return"function"==typeof e?t=e:(console.warn("Stomp.over did not receive a factory, auto reconnect will not work. Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over"),t=()=>e),new _(t)}}return g.WebSocketClass=null,t})()));
@@ -9,16 +9,17 @@ export function augmentWebsocket(webSocket, debug) {
9
9
  this.onmessage = noOp;
10
10
  this.onopen = noOp;
11
11
  const ts = new Date();
12
+ const id = Math.random().toString().substring(2, 8); // A simulated id
12
13
  const origOnClose = this.onclose;
13
14
  // Track delay in actual closure of the socket
14
15
  this.onclose = closeEvent => {
15
16
  const delay = new Date().getTime() - ts.getTime();
16
- debug(`Discarded socket closed after ${delay}ms, with code/reason: ${closeEvent.code}/${closeEvent.reason}`);
17
+ debug(`Discarded socket (#${id}) closed after ${delay}ms, with code/reason: ${closeEvent.code}/${closeEvent.reason}`);
17
18
  };
18
19
  this.close();
19
- origOnClose.call(this, {
20
+ origOnClose === null || origOnClose === void 0 ? void 0 : origOnClose.call(webSocket, {
20
21
  code: 4001,
21
- reason: 'Heartbeat failure, discarding the socket',
22
+ reason: `Quick discarding socket (#${id}) without waiting for the shutdown sequence.`,
22
23
  wasClean: false,
23
24
  });
24
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"augment-websocket.js","sourceRoot":"","sources":["../src/augment-websocket.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAuB,EACvB,KAA4B;IAE5B,SAAS,CAAC,SAAS,GAAG;QACpB,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEtB,6BAA6B;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QAEtB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC;QAEjC,8CAA8C;QAC9C,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,EAAE;YAC1B,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YAClD,KAAK,CACH,iCAAiC,KAAK,yBAAyB,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,CACtG,CAAC;QACJ,CAAC,CAAC;QAEF,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YACrB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,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CHANGED
@@ -20,7 +20,7 @@ export declare class Client {
20
20
  * If your environment does not support WebSockets natively, please refer to
21
21
  * [Polyfills]{@link https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/pollyfils-for-stompjs-v5.html}.
22
22
  */
23
- brokerURL: string;
23
+ brokerURL: string | undefined;
24
24
  /**
25
25
  * STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
26
26
  *
@@ -52,7 +52,7 @@ export declare class Client {
52
52
  * };
53
53
  * ```
54
54
  */
55
- webSocketFactory: () => IStompSocket;
55
+ webSocketFactory: (() => IStompSocket) | undefined;
56
56
  /**
57
57
  * Will retry if Stomp connection is not established in specified milliseconds.
58
58
  * Default 0, which implies wait for ever.
@@ -113,7 +113,7 @@ export declare class Client {
113
113
  /**
114
114
  * Underlying WebSocket instance, READONLY.
115
115
  */
116
- readonly webSocket: IStompSocket;
116
+ get webSocket(): IStompSocket | undefined;
117
117
  /**
118
118
  * Connection headers, important keys - `login`, `passcode`, `host`.
119
119
  * Though STOMP 1.2 standard marks these keys to be present, check your broker documentation for
@@ -123,7 +123,8 @@ export declare class Client {
123
123
  /**
124
124
  * Disconnection headers.
125
125
  */
126
- disconnectHeaders: StompHeaders;
126
+ get disconnectHeaders(): StompHeaders;
127
+ set disconnectHeaders(value: StompHeaders);
127
128
  private _disconnectHeaders;
128
129
  /**
129
130
  * This function will be called for any unhandled messages.
@@ -153,7 +154,7 @@ export declare class Client {
153
154
  /**
154
155
  * `true` if there is a active connection with STOMP Broker
155
156
  */
156
- readonly connected: boolean;
157
+ get connected(): boolean;
157
158
  /**
158
159
  * Callback, invoked on before a connection connection to the STOMP broker.
159
160
  *
@@ -242,12 +243,12 @@ export declare class Client {
242
243
  /**
243
244
  * version of STOMP protocol negotiated with the server, READONLY
244
245
  */
245
- readonly connectedVersion: string;
246
+ get connectedVersion(): string | undefined;
246
247
  private _stompHandler;
247
248
  /**
248
249
  * if the client is active (connected or going to reconnect)
249
250
  */
250
- readonly active: boolean;
251
+ get active(): boolean;
251
252
  /**
252
253
  * It will be called on state change.
253
254
  *
@@ -255,7 +256,6 @@ export declare class Client {
255
256
  */
256
257
  onChangeState: (state: ActivationState) => void;
257
258
  private _changeState;
258
- private _resolveSocketClose;
259
259
  /**
260
260
  * Activation state.
261
261
  *
@@ -285,14 +285,29 @@ export declare class Client {
285
285
  private _schedule_reconnect;
286
286
  /**
287
287
  * Disconnect if connected and stop auto reconnect loop.
288
- * Appropriate callbacks will be invoked if underlying STOMP connection was connected.
288
+ * Appropriate callbacks will be invoked if there is an underlying STOMP connection.
289
289
  *
290
- * This call is async, it will resolve immediately if there is no underlying active websocket,
291
- * otherwise, it will resolve after underlying websocket is properly disposed.
290
+ * This call is async. It will resolve immediately if there is no underlying active websocket,
291
+ * otherwise, it will resolve after the underlying websocket is properly disposed of.
292
292
  *
293
- * To reactivate you can call [Client#activate]{@link Client#activate}.
293
+ * It is not an error to invoke this method more than once.
294
+ * Each of those would resolve on completion of deactivation.
295
+ *
296
+ * To reactivate, you can call [Client#activate]{@link Client#activate}.
297
+ *
298
+ * Experimental: pass `force: true` to immediately discard the underlying connection.
299
+ * This mode will skip both the STOMP and the Websocket shutdown sequences.
300
+ * In some cases, browsers take a long time in the Websocket shutdown if the underlying connection had gone stale.
301
+ * Using this mode can speed up.
302
+ * When this mode is used, the actual Websocket may linger for a while
303
+ * and the broker may not realize that the connection is no longer in use.
304
+ *
305
+ * It is possible to invoke this method initially without the `force` option
306
+ * and subsequently, say after a wait, with the `force` option.
294
307
  */
295
- deactivate(): Promise<void>;
308
+ deactivate(options?: {
309
+ force?: boolean;
310
+ }): Promise<void>;
296
311
  /**
297
312
  * Force disconnect if there is an active connection by directly closing the underlying WebSocket.
298
313
  * This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
@@ -338,6 +353,7 @@ export declare class Client {
338
353
  * ```
339
354
  */
340
355
  publish(params: IPublishParams): void;
356
+ private _checkConnection;
341
357
  /**
342
358
  * STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
343
359
  * To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
package/esm6/client.js CHANGED
@@ -86,6 +86,13 @@ export class Client {
86
86
  * This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
87
87
  */
88
88
  this.appendMissingNULLonIncoming = false;
89
+ /**
90
+ * Browsers do not immediately close WebSockets when `.close` is issued.
91
+ * This may cause reconnection to take a longer on certain type of failures.
92
+ * In case of incoming heartbeat failure, this experimental flag instructs the library
93
+ * to discard the socket immediately (even before it is actually closed).
94
+ */
95
+ this.discardWebsocketOnCommFailure = false;
89
96
  /**
90
97
  * Activation state.
91
98
  *
@@ -117,7 +124,8 @@ export class Client {
117
124
  * Underlying WebSocket instance, READONLY.
118
125
  */
119
126
  get webSocket() {
120
- return this._stompHandler ? this._stompHandler._webSocket : undefined;
127
+ var _a;
128
+ return (_a = this._stompHandler) === null || _a === void 0 ? void 0 : _a._webSocket;
121
129
  }
122
130
  /**
123
131
  * Disconnection headers.
@@ -245,13 +253,11 @@ export class Client {
245
253
  this._stompHandler = undefined; // a new one will be created in case of a reconnect
246
254
  if (this.state === ActivationState.DEACTIVATING) {
247
255
  // Mark deactivation complete
248
- this._resolveSocketClose();
249
- this._resolveSocketClose = undefined;
250
256
  this._changeState(ActivationState.INACTIVE);
251
257
  }
252
- this.onWebSocketClose(evt);
253
258
  // The callback is called before attempting to reconnect, this would allow the client
254
259
  // to be `deactivated` in the callback.
260
+ this.onWebSocketClose(evt);
255
261
  if (this.active) {
256
262
  this._schedule_reconnect();
257
263
  }
@@ -277,9 +283,12 @@ export class Client {
277
283
  if (this.webSocketFactory) {
278
284
  webSocket = this.webSocketFactory();
279
285
  }
280
- else {
286
+ else if (this.brokerURL) {
281
287
  webSocket = new WebSocket(this.brokerURL, this.stompVersions.protocolVersions());
282
288
  }
289
+ else {
290
+ throw new Error('Either brokerURL or webSocketFactory must be provided');
291
+ }
283
292
  webSocket.binaryType = 'arraybuffer';
284
293
  return webSocket;
285
294
  }
@@ -293,30 +302,53 @@ export class Client {
293
302
  }
294
303
  /**
295
304
  * Disconnect if connected and stop auto reconnect loop.
296
- * Appropriate callbacks will be invoked if underlying STOMP connection was connected.
305
+ * Appropriate callbacks will be invoked if there is an underlying STOMP connection.
297
306
  *
298
- * This call is async, it will resolve immediately if there is no underlying active websocket,
299
- * otherwise, it will resolve after underlying websocket is properly disposed.
307
+ * This call is async. It will resolve immediately if there is no underlying active websocket,
308
+ * otherwise, it will resolve after the underlying websocket is properly disposed of.
300
309
  *
301
- * To reactivate you can call [Client#activate]{@link Client#activate}.
310
+ * It is not an error to invoke this method more than once.
311
+ * Each of those would resolve on completion of deactivation.
312
+ *
313
+ * To reactivate, you can call [Client#activate]{@link Client#activate}.
314
+ *
315
+ * Experimental: pass `force: true` to immediately discard the underlying connection.
316
+ * This mode will skip both the STOMP and the Websocket shutdown sequences.
317
+ * In some cases, browsers take a long time in the Websocket shutdown if the underlying connection had gone stale.
318
+ * Using this mode can speed up.
319
+ * When this mode is used, the actual Websocket may linger for a while
320
+ * and the broker may not realize that the connection is no longer in use.
321
+ *
322
+ * It is possible to invoke this method initially without the `force` option
323
+ * and subsequently, say after a wait, with the `force` option.
302
324
  */
303
- deactivate() {
325
+ deactivate(options = {}) {
326
+ var _a;
304
327
  return __awaiter(this, void 0, void 0, function* () {
328
+ const force = options.force || false;
329
+ const needToDispose = this.active;
305
330
  let retPromise;
306
- if (this.state !== ActivationState.ACTIVE) {
307
- this.debug(`Already ${ActivationState[this.state]}, ignoring call to deactivate`);
331
+ if (this.state === ActivationState.INACTIVE) {
332
+ this.debug(`Already INACTIVE, nothing more to do`);
308
333
  return Promise.resolve();
309
334
  }
310
335
  this._changeState(ActivationState.DEACTIVATING);
311
336
  // Clear if a reconnection was scheduled
312
337
  if (this._reconnector) {
313
338
  clearTimeout(this._reconnector);
339
+ this._reconnector = undefined;
314
340
  }
315
341
  if (this._stompHandler &&
342
+ // @ts-ignore - if there is a _stompHandler, there is the webSocket
316
343
  this.webSocket.readyState !== StompSocketState.CLOSED) {
317
- // we need to wait for underlying websocket to close
344
+ const origOnWebSocketClose = this._stompHandler.onWebSocketClose;
345
+ // we need to wait for the underlying websocket to close
318
346
  retPromise = new Promise((resolve, reject) => {
319
- this._resolveSocketClose = resolve;
347
+ // @ts-ignore - there is a _stompHandler
348
+ this._stompHandler.onWebSocketClose = evt => {
349
+ origOnWebSocketClose(evt);
350
+ resolve();
351
+ };
320
352
  });
321
353
  }
322
354
  else {
@@ -324,7 +356,12 @@ export class Client {
324
356
  this._changeState(ActivationState.INACTIVE);
325
357
  return Promise.resolve();
326
358
  }
327
- this._disposeStompHandler();
359
+ if (force) {
360
+ (_a = this._stompHandler) === null || _a === void 0 ? void 0 : _a.discardWebsocket();
361
+ }
362
+ else if (needToDispose) {
363
+ this._disposeStompHandler();
364
+ }
328
365
  return retPromise;
329
366
  });
330
367
  }
@@ -343,7 +380,6 @@ export class Client {
343
380
  // Dispose STOMP Handler
344
381
  if (this._stompHandler) {
345
382
  this._stompHandler.dispose();
346
- this._stompHandler = null;
347
383
  }
348
384
  }
349
385
  /**
@@ -383,8 +419,15 @@ export class Client {
383
419
  * ```
384
420
  */
385
421
  publish(params) {
422
+ this._checkConnection();
423
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
386
424
  this._stompHandler.publish(params);
387
425
  }
426
+ _checkConnection() {
427
+ if (!this.connected) {
428
+ throw new TypeError('There is no underlying STOMP connection');
429
+ }
430
+ }
388
431
  /**
389
432
  * STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
390
433
  * To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
@@ -421,6 +464,8 @@ export class Client {
421
464
  * ```
422
465
  */
423
466
  watchForReceipt(receiptId, callback) {
467
+ this._checkConnection();
468
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
424
469
  this._stompHandler.watchForReceipt(receiptId, callback);
425
470
  }
426
471
  /**
@@ -448,6 +493,8 @@ export class Client {
448
493
  * ```
449
494
  */
450
495
  subscribe(destination, callback, headers = {}) {
496
+ this._checkConnection();
497
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
451
498
  return this._stompHandler.subscribe(destination, callback, headers);
452
499
  }
453
500
  /**
@@ -463,6 +510,8 @@ export class Client {
463
510
  * See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
464
511
  */
465
512
  unsubscribe(id, headers = {}) {
513
+ this._checkConnection();
514
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
466
515
  this._stompHandler.unsubscribe(id, headers);
467
516
  }
468
517
  /**
@@ -472,6 +521,8 @@ export class Client {
472
521
  * `transactionId` is optional, if not passed the library will generate it internally.
473
522
  */
474
523
  begin(transactionId) {
524
+ this._checkConnection();
525
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
475
526
  return this._stompHandler.begin(transactionId);
476
527
  }
477
528
  /**
@@ -487,6 +538,8 @@ export class Client {
487
538
  * ```
488
539
  */
489
540
  commit(transactionId) {
541
+ this._checkConnection();
542
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
490
543
  this._stompHandler.commit(transactionId);
491
544
  }
492
545
  /**
@@ -501,6 +554,8 @@ export class Client {
501
554
  * ```
502
555
  */
503
556
  abort(transactionId) {
557
+ this._checkConnection();
558
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
504
559
  this._stompHandler.abort(transactionId);
505
560
  }
506
561
  /**
@@ -517,6 +572,8 @@ export class Client {
517
572
  * ```
518
573
  */
519
574
  ack(messageId, subscriptionId, headers = {}) {
575
+ this._checkConnection();
576
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
520
577
  this._stompHandler.ack(messageId, subscriptionId, headers);
521
578
  }
522
579
  /**
@@ -533,6 +590,8 @@ export class Client {
533
590
  * ```
534
591
  */
535
592
  nack(messageId, subscriptionId, headers = {}) {
593
+ this._checkConnection();
594
+ // @ts-ignore - we already checked that there is a _stompHandler, and it is connected
536
595
  this._stompHandler.nack(messageId, subscriptionId, headers);
537
596
  }
538
597
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EACL,eAAe,EAOf,gBAAgB,GAEjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC;;;;GAIG;AACH,MAAM,OAAO,MAAM;IAwTjB;;OAEG;IACH,YAAY,OAAoB,EAAE;QA9SlC;;;;;;;;WAQG;QACI,kBAAa,GAAG,QAAQ,CAAC,OAAO,CAAC;QAyBxC;;;WAGG;QACI,sBAAiB,GAAW,CAAC,CAAC;QAIrC;;WAEG;QACI,mBAAc,GAAW,IAAI,CAAC;QAErC;;WAEG;QACI,sBAAiB,GAAW,KAAK,CAAC;QAEzC;;WAEG;QACI,sBAAiB,GAAW,KAAK,CAAC;QAEzC;;;;;;;;;;;;WAYG;QACI,qBAAgB,GAAY,KAAK,CAAC;QAEzC;;;WAGG;QACI,0BAAqB,GAAW,CAAC,GAAG,IAAI,CAAC;QAEhD;;;;;;;WAOG;QACI,wBAAmB,GAAY,KAAK,CAAC;QAE5C;;;;;;;;;WASG;QACI,gCAA2B,GAAY,KAAK,CAAC;QA+LpD;;;;;WAKG;QACI,UAAK,GAAoB,eAAe,CAAC,QAAQ,CAAC;QAQvD,kBAAkB;QAClB,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,I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,CAAC;IAC7D,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,IAAI,CACT,SAAiB,EACjB,cAAsB,EACtB,UAAwB,EAAE;QAE1B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,qFAAqF;QACrF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -93,42 +93,44 @@ export declare class CompatClient extends Client {
93
93
  *
94
94
  * **Deprecated**
95
95
  */
96
- reconnect_delay: number;
96
+ set reconnect_delay(value: number);
97
97
  /**
98
98
  * Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
99
99
  *
100
100
  * **Deprecated**
101
101
  */
102
- readonly ws: any;
102
+ get ws(): any;
103
103
  /**
104
104
  * Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
105
105
  *
106
106
  * **Deprecated**
107
107
  */
108
- readonly version: string;
108
+ get version(): string | undefined;
109
109
  /**
110
110
  * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
111
111
  *
112
112
  * **Deprecated**
113
113
  */
114
+ get onreceive(): messageCallbackType;
114
115
  /**
115
- * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
116
- *
117
- * **Deprecated**
118
- */
119
- onreceive: messageCallbackType;
116
+ * Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
117
+ *
118
+ * **Deprecated**
119
+ */
120
+ set onreceive(value: messageCallbackType);
120
121
  /**
121
122
  * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
122
123
  * Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
123
124
  *
124
125
  * **Deprecated**
125
126
  */
127
+ get onreceipt(): frameCallbackType;
126
128
  /**
127
- * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
128
- *
129
- * **Deprecated**
130
- */
131
- onreceipt: frameCallbackType;
129
+ * Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
130
+ *
131
+ * **Deprecated**
132
+ */
133
+ set onreceipt(value: frameCallbackType);
132
134
  private _heartbeatInfo;
133
135
  /**
134
136
  * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
@@ -136,14 +138,18 @@ export declare class CompatClient extends Client {
136
138
  *
137
139
  * **Deprecated**
138
140
  */
139
- /**
140
- * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
141
- * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
142
- *
143
- * **Deprecated**
144
- */
145
- heartbeat: {
141
+ get heartbeat(): {
146
142
  incoming: number;
147
143
  outgoing: number;
148
144
  };
145
+ /**
146
+ * Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
147
+ * [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
148
+ *
149
+ * **Deprecated**
150
+ */
151
+ set heartbeat(value: {
152
+ incoming: number;
153
+ outgoing: number;
154
+ });
149
155
  }
@@ -7,6 +7,8 @@ import { CompatClient } from './compat-client';
7
7
  export declare class HeartbeatInfo {
8
8
  private client;
9
9
  constructor(client: CompatClient);
10
- outgoing: number;
11
- incoming: number;
10
+ get outgoing(): number;
11
+ set outgoing(value: number);
12
+ get incoming(): number;
13
+ set incoming(value: number);
12
14
  }
@@ -22,12 +22,12 @@ export declare class FrameImpl implements IFrame {
22
22
  /**
23
23
  * body of the frame
24
24
  */
25
- readonly body: string;
25
+ get body(): string;
26
26
  private _body;
27
27
  /**
28
28
  * body as Uint8Array
29
29
  */
30
- readonly binaryBody: Uint8Array;
30
+ get binaryBody(): Uint8Array;
31
31
  private _binaryBody;
32
32
  private escapeHeaderValues;
33
33
  private skipContentLengthHeader;
@@ -32,7 +32,7 @@ export class FrameImpl {
32
32
  if (!this._body && this.isBinaryBody) {
33
33
  this._body = new TextDecoder().decode(this._binaryBody);
34
34
  }
35
- return this._body;
35
+ return this._body || '';
36
36
  }
37
37
  /**
38
38
  * body as Uint8Array
@@ -41,6 +41,7 @@ export class FrameImpl {
41
41
  if (!this._binaryBody && !this.isBinaryBody) {
42
42
  this._binaryBody = new TextEncoder().encode(this._body);
43
43
  }
44
+ // At this stage it will definitely have a valid value
44
45
  return this._binaryBody;
45
46
  }
46
47
  /**