insite-ws 2.5.0 → 2.6.0
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.
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +2 -2
- package/package.json +4 -3
package/dist/client/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import v from"eventemitter3";import{noop as S,StatefulPromise as g}from"@nesvet/n";var f=Number.MAX_SAFE_INTEGER/2,r={NORMAL:1e3,PROTOCOL_ERROR:1002,ABNORMAL:1006,NO_HEARTBEAT:3e3,OFFLINE:3001,MANUAL:3500,REOPEN:4e3},N=[r.PROTOCOL_ERROR,r.MANUAL,r.REOPEN],E={REQUEST:"~r-q",RESPONSE:"~r-s"};var R=0,O=class a extends v{constructor(e={}){super();let{url:t=globalThis.__insite?.wss_url||"/",name:s=(R++).toString(),protocols:o,immediately:i=!0,reconnectAfter:n=2e3,on:h,once:l,quiet:u=!1,signal:d}=e;if(this.url=t,this.name=s,this.protocols=o,this.reconnectAfter=n,h)for(let c in h)h[c]&&this.on(c,h[c]);if(l)for(let c in l)l[c]&&this.once(c,l[c]);this.#c=u,this.#l=d,this.#l?.addEventListener("abort",this.#p,{once:!0}),this.url&&i&&this.open().catch(S),this.#c||this.on("error",c=>c&&console.error("\u{1F50C}\u2757\uFE0F WS",`${this.name}:`,c))}on(e,t){return super.on(e,t)}isWebSocket=!0;isWebSocketServer=!1;isWebSocketServerClient=!1;url;name;protocols;reconnectAfter;#c;#l;isUsed=!1;connectionQuality=0;#n(e){if(e!==this.connectionQuality){let t=this.connectionQuality;this.connectionQuality=e,this.emit("connection-quality-change",this.connectionQuality,t)}}webSocket=null;#o;#T(){clearTimeout(this.#o),this.#o=setTimeout(()=>this.close(r.NO_HEARTBEAT,"no-heartbeat",!1),35e3),this.#t&&(clearTimeout(this.#t),this.#t=void 0),this.#r=!1,this.#s&&(clearTimeout(this.#s),this.#s=void 0),this.#i&&(this.#i=!1,this.emit("responsive")),this.#n(a.CONNECTION_QUALITY.OPEN)}#t;#r=!1;#s;#i=!1;get state(){if(!this.webSocket)return"closed";switch(this.webSocket.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return this.#i?"unresponsive":"open";case WebSocket.CLOSING:return"closing"}return"closed"}get isConnecting(){return this.webSocket?.readyState===WebSocket.CONNECTING}get isOpen(){return this.webSocket?.readyState===WebSocket.OPEN}get isClosing(){return this.webSocket?.readyState===WebSocket.CLOSING}get isClosed(){return!this.webSocket}isDestroyed=!1;#e;#E=!1;#S=()=>{this.#E=!0,this.closedWith=null,this.#e.resolve(),this.#T(),this.emit("open")};#O=({data:e})=>{if(this.#T(),e){if(e!=="!")try{let[t,...s]=JSON.parse(e);t===E.REQUEST?this.#g(...s):(this.emit("message",t,...s),this.emit(`message:${t}`,...s))}catch(t){this.#u(t)}}else this.webSocket.send("")};#u=e=>{e instanceof Event&&(e=void 0),this.#e?.isPending&&this.#e.reject(e),this.emit("error",e)};#a;#m(e){this.#a&&clearTimeout(this.#a),this.reconnectAfter&&!N.includes(e)?(process.env.NODE_ENV==="development"&&!this.#c&&console.info(`\u{1F50C} WS ${this.name} will try to reconnect in ${Math.round(this.reconnectAfter/1e3)} seconds`),this.#a=setTimeout(()=>this.open().catch(S),this.reconnectAfter),this.#n(a.CONNECTION_QUALITY.RECONNECTING)):(this.#a=void 0,this.#n(e===r.REOPEN?a.CONNECTION_QUALITY.RECONNECTING:a.CONNECTION_QUALITY.CLOSED))}#d=e=>{let{code:t,reason:s,wasClean:o}=e;if(this.closedWith={code:t,reason:s,wasClean:o},this.#o&&(clearTimeout(this.#o),this.#o=void 0),this.#t&&(clearTimeout(this.#t),this.#t=void 0),this.#r=!1,this.#s&&(clearTimeout(this.#s),this.#s=void 0),this.#i=!1,this.#e?.isPending&&this.#e.reject(new Error("Closed")),process.env.NODE_ENV==="development"&&!this.#c){let n=`\u{1F50C} WS ${this.name} is closed`;t&&(n+=` with code ${t}`),t&&s&&(n+=" and"),s&&(n+=` reason "${s}"`),s==="no-heartbeat"&&(n+=". Going offline"),!o||t===r.ABNORMAL?(n+=" [UNEXPECTED]",console.warn(n)):console.info(n)}let i=this.webSocket;i.removeEventListener("open",this.#S),i.removeEventListener("message",this.#O),i.removeEventListener("error",this.#u),this.#E&&(this.emit("close",e),this.#E=!1),this.webSocket=null,this.#m(t),"navigator"in globalThis&&"addEventListener"in globalThis&&globalThis.removeEventListener("offline",this.#b)};#p=()=>this.#e?.isPending&&this.#e.reject(new DOMException("Operation aborted","AbortError"));async open(e={}){if(this.isDestroyed)throw new Error("WS has been destroyed");if(this.#l?.aborted)throw new DOMException("Operation aborted","AbortError");if(this.closedWith=null,this.#e?.isPending)return this.#e;this.isUsed?this.close(r.REOPEN,"reopen"):this.isUsed=!0;let t;return e.url&&this.url!==e.url&&(t=this.url,this.url=e.url),e.protocols&&(this.protocols=e.protocols),this.#e=new g((s,o)=>{if(this.url){let i=new WebSocket(this.url,this.protocols);i.addEventListener("open",this.#S,{once:!0}),i.addEventListener("message",this.#O),i.addEventListener("error",this.#u),i.addEventListener("close",this.#d,{once:!0}),this.webSocket=i,t&&this.emit("server-change",this.url,t),this.emit("connecting"),"navigator"in globalThis&&"addEventListener"in globalThis&&globalThis.addEventListener("offline",this.#b)}else this.webSocket=null,o(new Error("url prop is not set"))}),this.#e}connect=this.open;close(e=r.MANUAL,t="manual",s=!0){this.isClosed?this.#m(e):(this.webSocket.removeEventListener("close",this.#d),this.webSocket.close(e,t),this.#d(Object.assign(new Event("close"),{code:e,reason:t,wasClean:s})))}closedWith=null;disconnect=this.close;#h=[];#v=()=>{for(let e of this.#h)this.webSocket.send(e);this.#h.length=0};send(e){this.isOpen?this.webSocket.send(e):(this.#h.length||this.once("open",this.#v),this.#h.push(e))}sendMessage(...e){return this.send(JSON.stringify(e))}#f=0;sendRequest(...e){let t=this.#f++;this.#f>=f&&(this.#f=0);let s=`message:${E.RESPONSE}-${t}`,o=e.at(-1);return typeof o=="function"?(this.once(s,o),this.sendMessage(E.REQUEST,t,...e.slice(0,-1)),this):new Promise((i,n)=>{this.once(s,(h,l)=>{if(h){let{message:u,...d}=h;n(Object.assign(new Error(u),d))}else i(l)}),this.sendMessage(E.REQUEST,t,...e)})}#N=new Map;addRequestListener(e,t){return this.#N.set(e,t),this}onRequest=this.addRequestListener;removeRequestListener(e){return this.#N.delete(e),this}offRequest=this.removeRequestListener;#g=async(e,t,...s)=>{let o=this.#N.get(t),i,n=null;if(o)try{i=await o.apply(this,s)}catch(h){if(h instanceof Error){let{message:l,...u}=h;n={message:l,...u}}}else n={message:`Unknown request kind "${t}"`};this.sendMessage(`${E.RESPONSE}-${e}`,n,i)};#b=()=>{this.isOpen&&!this.#r&&(this.#r=!0,this.#n(a.CONNECTION_QUALITY.CHECKING_RESPONSIVENESS),this.#t=setTimeout(()=>{this.#r=!1,this.#i=!0,this.#n(a.CONNECTION_QUALITY.UNRESPONSIVE),this.emit("unresponsive"),this.#s=setTimeout(()=>{this.#i=!1,this.close(r.OFFLINE,"offline",!1)},4e3)},1e3),this.webSocket.send("?"))};destroy(){this.isDestroyed=!0,this.#h.length=0,this.close(r.NORMAL,"destroy"),this.emit("destroy"),this.removeAllListeners(),this.#l?.removeEventListener("abort",this.#p)}static CONNECTION_QUALITY={CLOSED:0,RECONNECTING:1,UNRESPONSIVE:2,CHECKING_RESPONSIVENESS:3,OPEN:4}};export{O as WS};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/client/WS.ts", "../../src/common.ts"],
|
|
4
4
|
"sourcesContent": ["import EventEmitter from \"eventemitter3\";\nimport { noop, StatefulPromise } from \"@nesvet/n\";\nimport {\n\tCODES,\n\tHEARTBEAT_GAP,\n\tHEARTBEAT_INTERVAL,\n\tNON_RECONNECTABLE_CODES,\n\tOFFLINE_TIMEOUT,\n\tREQUEST_COUNTER_LIMIT,\n\tREQUEST_HEADERS,\n\tRESPONSIVENESS_TIMEOUT\n} from \"../common\";\nimport type { ConnectionQuality, Options, RequestListener } from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nlet i = 0;\n\n\nexport class WS extends EventEmitter {\n\tconstructor(options: Options = {}) {\n\t\tsuper();\n\t\t\n\t\tconst {\n\t\t\turl = globalThis.__insite?.wss_url || \"/\",\n\t\t\tname = (i++).toString(),\n\t\t\tprotocols,\n\t\t\timmediately = true,\n\t\t\treconnectAfter = 2000,\n\t\t\ton,\n\t\t\tonce,\n\t\t\tquiet = false,\n\t\t\tsignal\n\t\t} = options;\n\t\t\n\t\tthis.url = url;\n\t\tthis.name = name;\n\t\t\n\t\tthis.protocols = protocols;\n\t\t\n\t\tthis.reconnectAfter = reconnectAfter;\n\t\t\n\t\tif (on)\n\t\t\tfor (const eventName in on)\n\t\t\t\tif (on[eventName])\n\t\t\t\t\tthis.on(eventName, on[eventName]);\n\t\t\n\t\tif (once)\n\t\t\tfor (const eventName in once)\n\t\t\t\tif (once[eventName])\n\t\t\t\t\tthis.once(eventName, once[eventName]);\n\t\t\n\t\tthis.#isQuiet = quiet;\n\t\t\n\t\tthis.#abortSignal = signal;\n\t\tthis.#abortSignal?.addEventListener(\"abort\", this.#handleAbortSignalAbort, { once: true });\n\t\t\n\t\tif (this.url && immediately)\n\t\t\tthis.open().catch(noop);\n\t\t\n\t\tif (!this.#isQuiet)\n\t\t\tthis.on(\"error\", (error: Error) => error && console.error(\"\uD83D\uDD0C\u2757\uFE0F WS\", `${this.name}:`, error));\n\t\t\n\t}\n\t\n\ton(event: \"connecting\" | \"destroy\" | \"open\" | \"responsive\" | \"unresponsive\", callback: (this: this) => void): this;\n\ton<T extends unknown[]>(event: \"message\", callback: (this: this, kind: string, ...rest: T) => void): this;\n\ton<T extends unknown[]>(event: `message:${string}`, callback: (this: this, ...rest: T) => void): this;\n\ton(event: \"connection-quality-change\", callback: (this: this, connectionQuality: ConnectionQuality, prevConnectionQuality: ConnectionQuality) => void): this;\n\ton(event: \"close\", callback: (this: this, closeEvent: CloseEvent) => void): this;\n\ton(event: \"server-change\", callback: (this: this, url: string, prevURL: string) => void): this;\n\ton(event: \"error\", callback: (this: this, error: Error) => void): this;\n\t\n\ton<T extends string | symbol>(event: T, fn: (...args: any[]) => void): this;\n\ton(event: string | symbol, listener: (this: this, ...args: any[]) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\t\n\treadonly isWebSocket = true;\n\treadonly isWebSocketServer = false;\n\treadonly isWebSocketServerClient = false;\n\t\n\turl;\n\t\n\treadonly name;\n\t\n\tprotocols?;\n\t\n\treconnectAfter;\n\t\n\t#isQuiet;\n\t\n\t#abortSignal?: AbortSignal;\n\t\n\tisUsed = false;\n\t\n\tconnectionQuality: ConnectionQuality = 0;\n\t\n\t#updateConnectionQuality(connectionQuality: ConnectionQuality) {\n\t\tif (connectionQuality !== this.connectionQuality) {\n\t\t\tconst prevConnectionQuality = this.connectionQuality;\n\t\t\tthis.connectionQuality = connectionQuality;\n\t\t\t\n\t\t\tthis.emit(\"connection-quality-change\", this.connectionQuality, prevConnectionQuality);\n\t\t}\n\t\t\n\t}\n\t\n\twebSocket: WebSocket | null = null;\n\t\n\t#heartbeatTimeout?: ReturnType<typeof setTimeout>;\n\t\n\t#defib() {\n\t\t\n\t\tclearTimeout(this.#heartbeatTimeout);\n\t\tthis.#heartbeatTimeout = setTimeout(\n\t\t\t() => this.close(CODES.NO_HEARTBEAT, \"no-heartbeat\", false),\n\t\t\tHEARTBEAT_INTERVAL + HEARTBEAT_GAP\n\t\t);\n\t\t\n\t\tif (this.#unresponsiveTimeout) {\n\t\t\tclearTimeout(this.#unresponsiveTimeout);\n\t\t\tthis.#unresponsiveTimeout = undefined;\n\t\t}\n\t\t\n\t\tthis.#isCheckingResponsiveness = false;\n\t\t\n\t\tif (this.#offlineTimeout) {\n\t\t\tclearTimeout(this.#offlineTimeout);\n\t\t\tthis.#offlineTimeout = undefined;\n\t\t}\n\t\t\n\t\tif (this.#isUnresponsive) {\n\t\t\tthis.#isUnresponsive = false;\n\t\t\t\n\t\t\tthis.emit(\"responsive\");\n\t\t}\n\t\t\n\t\tthis.#updateConnectionQuality(WS.CONNECTION_QUALITY.OPEN);\n\t\t\n\t}\n\t\n\t#unresponsiveTimeout?: ReturnType<typeof setTimeout>;\n\t#isCheckingResponsiveness = false;\n\t\n\t#offlineTimeout?: ReturnType<typeof setTimeout>;\n\t#isUnresponsive = false;\n\t\n\tget state() {\n\t\t\n\t\tif (!this.webSocket)\n\t\t\treturn \"closed\";\n\t\t\n\t\tswitch (this.webSocket.readyState) {\n\t\t\tcase WebSocket.CONNECTING:\n\t\t\t\treturn \"connecting\";\n\t\t\t\n\t\t\tcase WebSocket.OPEN:\n\t\t\t\treturn this.#isUnresponsive ? \"unresponsive\" : \"open\";\n\t\t\t\n\t\t\tcase WebSocket.CLOSING:\n\t\t\t\treturn \"closing\";\n\t\t}\n\t\t\n\t\treturn \"closed\";\n\t}\n\t\n\tget isConnecting() {\n\t\treturn this.webSocket?.readyState === WebSocket.CONNECTING;\n\t}\n\t\n\tget isOpen() {\n\t\treturn this.webSocket?.readyState === WebSocket.OPEN;\n\t}\n\t\n\tget isClosing() {\n\t\treturn this.webSocket?.readyState === WebSocket.CLOSING;\n\t}\n\t\n\tget isClosed() {\n\t\treturn !this.webSocket;\n\t}\n\t\n\tisDestroyed = false;\n\t\n\t#openPromise?: StatefulPromise<void>;\n\t\n\t#wasOpened = false;\n\t\n\t#handleWebSocketOpen = () => {\n\t\t\n\t\tthis.#wasOpened = true;\n\t\t\n\t\tthis.closedWith = null;\n\t\t\n\t\tthis.#openPromise!.resolve();\n\t\t\n\t\tthis.#defib();\n\t\t\n\t\tthis.emit(\"open\");\n\t\t\n\t};\n\t\n\t#handleWebSocketMessage = ({ data: message }: MessageEvent<string>) => {\n\t\t\n\t\tthis.#defib();\n\t\t\n\t\tif (message) {\n\t\t\tif (message !== \"!\")\n\t\t\t\ttry {\n\t\t\t\t\tconst [ kind, ...rest ] = JSON.parse(message);\n\t\t\t\t\t\n\t\t\t\t\tswitch (kind) {\n\t\t\t\t\t\tcase REQUEST_HEADERS.REQUEST:\n\t\t\t\t\t\t\tvoid this.#handleRequest(...rest as [ id: number, kind: string, ...rest: unknown[] ]);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthis.emit(\"message\", kind, ...rest);\n\t\t\t\t\t\t\tthis.emit(`message:${kind}`, ...rest);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.#handleWebSocketError(error as Error);\n\t\t\t\t}\n\t\t} else\n\t\t\tthis.webSocket!.send(\"\");\n\t\t\n\t};\n\t\n\t#handleWebSocketError = (error: Error | Event | undefined) => {\n\t\tif (error instanceof Event)\n\t\t\terror = undefined;\n\t\t\n\t\tif (this.#openPromise?.isPending)\n\t\t\tthis.#openPromise.reject(error as Error);\n\t\t\n\t\tthis.emit(\"error\", error);\n\t\t\n\t};\n\t\n\t#reconnectTimeout?: ReturnType<typeof setTimeout>;\n\t\n\t#decideReconnect(code: number) {\n\t\t\n\t\tif (this.#reconnectTimeout)\n\t\t\tclearTimeout(this.#reconnectTimeout);\n\t\t\n\t\tif (this.reconnectAfter && !NON_RECONNECTABLE_CODES.includes(code as typeof NON_RECONNECTABLE_CODES[number])) {\n\t\t\tif (process.env.NODE_ENV === \"development\" && !this.#isQuiet)\n\t\t\t\tconsole.info(`\uD83D\uDD0C WS ${this.name} will try to reconnect in ${Math.round(this.reconnectAfter / 1000)} seconds`);\n\t\t\t\n\t\t\tthis.#reconnectTimeout = setTimeout(() => this.open().catch(noop), this.reconnectAfter);\n\t\t\t\n\t\t\tthis.#updateConnectionQuality(WS.CONNECTION_QUALITY.RECONNECTING);\n\t\t} else {\n\t\t\tthis.#reconnectTimeout = undefined;\n\t\t\t\n\t\t\tthis.#updateConnectionQuality(code === CODES.REOPEN ? WS.CONNECTION_QUALITY.RECONNECTING : WS.CONNECTION_QUALITY.CLOSED);\n\t\t}\n\t\t\n\t}\n\t\n\t#handleWebSocketClose = (event: CloseEvent) => {\n\t\tconst { code, reason, wasClean } = event;\n\t\t\n\t\tthis.closedWith = { code, reason, wasClean };\n\t\t\n\t\tif (this.#heartbeatTimeout) {\n\t\t\tclearTimeout(this.#heartbeatTimeout);\n\t\t\tthis.#heartbeatTimeout = undefined;\n\t\t}\n\t\t\n\t\tif (this.#unresponsiveTimeout) {\n\t\t\tclearTimeout(this.#unresponsiveTimeout);\n\t\t\tthis.#unresponsiveTimeout = undefined;\n\t\t}\n\t\t\n\t\tthis.#isCheckingResponsiveness = false;\n\t\t\n\t\tif (this.#offlineTimeout) {\n\t\t\tclearTimeout(this.#offlineTimeout);\n\t\t\tthis.#offlineTimeout = undefined;\n\t\t}\n\t\t\n\t\tthis.#isUnresponsive = false;\n\t\t\n\t\tif (this.#openPromise?.isPending)\n\t\t\tthis.#openPromise.reject(new Error(\"Closed\"));\n\t\t\n\t\tif (process.env.NODE_ENV === \"development\" && !this.#isQuiet) {\n\t\t\tlet message = `\uD83D\uDD0C WS ${this.name} is closed`;\n\t\t\t\n\t\t\tif (code)\n\t\t\t\tmessage += ` with code ${code}`;\n\t\t\t\n\t\t\tif (code && reason)\n\t\t\t\tmessage += \" and\";\n\t\t\t\n\t\t\tif (reason)\n\t\t\t\tmessage += ` reason \"${reason}\"`;\n\t\t\t\n\t\t\tswitch (reason) {\n\t\t\t\tcase \"no-heartbeat\":\n\t\t\t\t\tmessage += \". Going offline\";\n\t\t\t}\n\t\t\t\n\t\t\tif (!wasClean || code === CODES.ABNORMAL) {\n\t\t\t\tmessage += \" [UNEXPECTED]\";\n\t\t\t\tconsole.warn(message);\n\t\t\t} else\n\t\t\t\tconsole.info(message);\n\t\t}\n\t\t\n\t\tconst webSocket = this.webSocket!;\n\t\t\n\t\twebSocket.removeEventListener(\"open\", this.#handleWebSocketOpen);\n\t\twebSocket.removeEventListener(\"message\", this.#handleWebSocketMessage);\n\t\twebSocket.removeEventListener(\"error\", this.#handleWebSocketError);\n\t\t\n\t\tif (this.#wasOpened) {\n\t\t\tthis.emit(\"close\", event);\n\t\t\t\n\t\t\tthis.#wasOpened = false;\n\t\t}\n\t\t\n\t\tthis.webSocket = null;\n\t\t\n\t\tthis.#decideReconnect(code);\n\t\t\n\t\tif (\"navigator\" in globalThis && \"addEventListener\" in globalThis)\n\t\t\tglobalThis.removeEventListener(\"offline\", this.#handleOffline);\n\t\t\n\t};\n\t\n\t#handleAbortSignalAbort = () =>\n\t\tthis.#openPromise?.isPending &&\n\t\tthis.#openPromise.reject(new DOMException(\"Operation aborted\", \"AbortError\"));\n\t\n\tasync open(options: Pick<Options, \"protocols\" | \"url\"> = {}): Promise<void> {\n\t\t\n\t\tif (this.isDestroyed)\n\t\t\tthrow new Error(\"WS has been destroyed\");\n\t\t\n\t\tif (this.#abortSignal?.aborted)\n\t\t\tthrow new DOMException(\"Operation aborted\", \"AbortError\");\n\t\t\n\t\tthis.closedWith = null;\n\t\t\n\t\tif (this.#openPromise?.isPending)\n\t\t\treturn this.#openPromise;\n\t\t\n\t\tif (this.isUsed)\n\t\t\tthis.close(CODES.REOPEN, \"reopen\");\n\t\telse\n\t\t\tthis.isUsed = true;\n\t\t\n\t\tlet prevURL: URL | string | undefined;\n\t\tif (options.url && this.url !== options.url) {\n\t\t\tprevURL = this.url;\n\t\t\tthis.url = options.url;\n\t\t}\n\t\t\n\t\tif (options.protocols)\n\t\t\tthis.protocols = options.protocols;\n\t\t\n\t\tthis.#openPromise = new StatefulPromise((_, reject) => {\n\t\t\t\n\t\t\tif (this.url) {\n\t\t\t\tconst webSocket = new WebSocket(this.url, this.protocols);\n\t\t\t\t\n\t\t\t\twebSocket.addEventListener(\"open\", this.#handleWebSocketOpen, { once: true });\n\t\t\t\twebSocket.addEventListener(\"message\", this.#handleWebSocketMessage);\n\t\t\t\twebSocket.addEventListener(\"error\", this.#handleWebSocketError);\n\t\t\t\twebSocket.addEventListener(\"close\", this.#handleWebSocketClose, { once: true });\n\t\t\t\t\n\t\t\t\tthis.webSocket = webSocket;\n\t\t\t\t\n\t\t\t\tif (prevURL)\n\t\t\t\t\tthis.emit(\"server-change\", this.url, prevURL);\n\t\t\t\t\n\t\t\t\tthis.emit(\"connecting\");\n\t\t\t\t\n\t\t\t\tif (\"navigator\" in globalThis && \"addEventListener\" in globalThis)\n\t\t\t\t\tglobalThis.addEventListener(\"offline\", this.#handleOffline);\n\t\t\t} else {\n\t\t\t\tthis.webSocket = null;\n\t\t\t\t\n\t\t\t\treject(new Error(\"url prop is not set\"));\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\treturn this.#openPromise;\n\t}\n\t\n\t/**\n\t * Alias for `open()`\n\t */\n\tconnect = this.open;\n\t\n\tclose(code: number = CODES.MANUAL, reason = \"manual\", wasClean: boolean = true) {\n\t\t\n\t\tif (this.isClosed)\n\t\t\tthis.#decideReconnect(code);\n\t\telse {\n\t\t\tthis.webSocket!.removeEventListener(\"close\", this.#handleWebSocketClose);\n\t\t\t\n\t\t\tthis.webSocket!.close(code, reason);\n\t\t\t\n\t\t\tthis.#handleWebSocketClose(Object.assign(new Event(\"close\"), {\n\t\t\t\tcode,\n\t\t\t\treason,\n\t\t\t\twasClean\n\t\t\t}));\n\t\t}\n\t\t\n\t}\n\t\n\tclosedWith: { code: number; reason: string; wasClean: boolean } | null = null;\n\t\n\t/**\n\t * Alias for `close()`\n\t */\n\tdisconnect = this.close;\n\t\n\t#queue: (ArrayBufferLike | ArrayBufferView | Blob | string)[] = [];\n\t\n\t#releaseQueue = () => {\n\t\t\n\t\tfor (const message of this.#queue)\n\t\t\tthis.webSocket!.send(message);\n\t\t\n\t\tthis.#queue.length = 0;\n\t\t\n\t};\n\t\n\tsend(data: ArrayBufferLike | ArrayBufferView | Blob | string) {\n\t\t\n\t\tif (this.isOpen)\n\t\t\tthis.webSocket!.send(data);\n\t\telse {\n\t\t\tif (!this.#queue.length)\n\t\t\t\tthis.once(\"open\", this.#releaseQueue);\n\t\t\t\n\t\t\tthis.#queue.push(data);\n\t\t}\n\t\t\n\t}\n\t\n\tsendMessage(...args: unknown[]) {\n\t\treturn this.send(JSON.stringify(args));\n\t}\n\t\n\t#requestCounter = 0;\n\t\n\tsendRequest<T>(...args: [...unknown[], callback: (error: Error | null, result: T) => void]): this;\n\tsendRequest<T>(...args: unknown[]): Promise<T>;\n\tsendRequest<T>(...args: unknown[]) {\n\t\t\n\t\tconst id = this.#requestCounter++;\n\t\t\n\t\tif (this.#requestCounter >= REQUEST_COUNTER_LIMIT)\n\t\t\tthis.#requestCounter = 0;\n\t\t\n\t\tconst eventName = `message:${REQUEST_HEADERS.RESPONSE}-${id}`;\n\t\t\n\t\tconst lastArg = args.at(-1);\n\t\t\n\t\tif (typeof lastArg == \"function\") {\n\t\t\tthis.once(eventName, lastArg as (error: Error, result: T) => void);\n\t\t\t\n\t\t\tthis.sendMessage(REQUEST_HEADERS.REQUEST, id, ...args.slice(0, -1));\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\t\n\t\t\tthis.once(eventName, (error, result: T) => {\n\t\t\t\tif (error) {\n\t\t\t\t\tconst { message, ...restProps } = error;\n\t\t\t\t\treject(Object.assign(new Error(message), restProps) as Error);\n\t\t\t\t} else\n\t\t\t\t\tresolve(result);\n\t\t\t\t\n\t\t\t});\n\t\t\t\n\t\t\tthis.sendMessage(REQUEST_HEADERS.REQUEST, id, ...args);\n\t\t\t\n\t\t});\n\t}\n\t\n\t#requestListeners = new Map<string, RequestListener>();\n\t\n\taddRequestListener(kind: string, listener: RequestListener) {\n\t\tthis.#requestListeners.set(kind, listener);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t/**\n\t * Alias for `addRequestListener()`\n\t */\n\tonRequest = this.addRequestListener;\n\t\n\tremoveRequestListener(kind: string) {\n\t\tthis.#requestListeners.delete(kind);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t/**\n\t * Alias for `removeRequestListener()`\n\t */\n\toffRequest = this.removeRequestListener;\n\t\n\t#handleRequest = async (id: number, kind: string, ...rest: unknown[]) => {\n\t\tconst listener = this.#requestListeners.get(kind);\n\t\t\n\t\tlet result;\n\t\tlet requestError = null;\n\t\t\n\t\tif (listener)\n\t\t\ttry {\n\t\t\t\tresult = await listener.apply(this, rest);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error) {\n\t\t\t\t\tconst { message, ...restProps } = error;\n\t\t\t\t\trequestError = { message, ...restProps };\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\trequestError = { message: `Unknown request kind \"${kind}\"` };\n\t\t\n\t\tthis.sendMessage(`${REQUEST_HEADERS.RESPONSE}-${id}`, requestError, result);\n\t\t\n\t};\n\t\n\t#handleOffline = () => {\n\t\t\n\t\tif (this.isOpen && !this.#isCheckingResponsiveness) {\n\t\t\tthis.#isCheckingResponsiveness = true;\n\t\t\t\n\t\t\tthis.#updateConnectionQuality(WS.CONNECTION_QUALITY.CHECKING_RESPONSIVENESS);\n\t\t\t\n\t\t\tthis.#unresponsiveTimeout = setTimeout(() => {\n\t\t\t\t\n\t\t\t\tthis.#isCheckingResponsiveness = false;\n\t\t\t\tthis.#isUnresponsive = true;\n\t\t\t\t\n\t\t\t\tthis.#updateConnectionQuality(WS.CONNECTION_QUALITY.UNRESPONSIVE);\n\t\t\t\t\n\t\t\t\tthis.emit(\"unresponsive\");\n\t\t\t\t\n\t\t\t\tthis.#offlineTimeout = setTimeout(() => {\n\t\t\t\t\t\n\t\t\t\t\tthis.#isUnresponsive = false;\n\t\t\t\t\t\n\t\t\t\t\tthis.close(CODES.OFFLINE, \"offline\", false);\n\t\t\t\t\t\n\t\t\t\t}, OFFLINE_TIMEOUT - RESPONSIVENESS_TIMEOUT);\n\t\t\t\t\n\t\t\t}, RESPONSIVENESS_TIMEOUT);\n\t\t\t\n\t\t\tthis.webSocket!.send(\"?\");\n\t\t}\n\t\t\n\t};\n\t\n\tdestroy() {\n\t\t\n\t\tthis.isDestroyed = true;\n\t\t\n\t\tthis.#queue.length = 0;\n\t\t\n\t\tthis.close(CODES.NORMAL, \"destroy\");\n\t\t\n\t\tthis.emit(\"destroy\");\n\t\t\n\t\tthis.removeAllListeners();\n\t\t\n\t\tthis.#abortSignal?.removeEventListener(\"abort\", this.#handleAbortSignalAbort);\n\t\t\n\t}\n\t\n\t\n\tstatic CONNECTION_QUALITY = {\n\t\tCLOSED: 0,\n\t\tRECONNECTING: 1,\n\t\tUNRESPONSIVE: 2,\n\t\tCHECKING_RESPONSIVENESS: 3,\n\t\tOPEN: 4\n\t} as const;\n\t\n}\n", "export const HEARTBEAT_INTERVAL = 5_000;\nexport const HEARTBEAT_GAP = 30_000;\nexport const RESPONSIVENESS_TIMEOUT = 1000;\nexport const OFFLINE_TIMEOUT = 5000;\nexport const REQUEST_COUNTER_LIMIT = Number.MAX_SAFE_INTEGER / 2;\n\nexport const CODES = {\n\tNORMAL: 1000,\n\tPROTOCOL_ERROR: 1002,\n\tABNORMAL: 1006,\n\tNO_HEARTBEAT: 3000,\n\tOFFLINE: 3001,\n\tMANUAL: 3500,\n\tREOPEN: 4000\n} as const;\n\nexport const NON_RECONNECTABLE_CODES = [\n\tCODES.PROTOCOL_ERROR,\n\tCODES.MANUAL,\n\tCODES.REOPEN\n];\n\nexport const REQUEST_HEADERS = {\n\tREQUEST: \"~r-q\",\n\tRESPONSE: \"~r-s\"\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["EventEmitter", "noop", "StatefulPromise", "REQUEST_COUNTER_LIMIT", "CODES", "NON_RECONNECTABLE_CODES", "REQUEST_HEADERS", "i", "
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAkB,gBACzB,OAAS,QAAAC,EAAM,mBAAAC,MAAuB,YCG/B,IAAMC,EAAwB,OAAO,iBAAmB,EAElDC,EAAQ,CACpB,O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ACzB,KAAM,CACP,CAED",
|
|
6
|
+
"names": ["EventEmitter", "noop", "StatefulPromise", "REQUEST_COUNTER_LIMIT", "CODES", "NON_RECONNECTABLE_CODES", "REQUEST_HEADERS", "i", "WS", "_WS", "EventEmitter", "options", "url", "name", "protocols", "immediately", "reconnectAfter", "on", "once", "quiet", "signal", "eventName", "#isQuiet", "#abortSignal", "#handleAbortSignalAbort", "noop", "error", "event", "listener", "#updateConnectionQuality", "connectionQuality", "prevConnectionQuality", "#heartbeatTimeout", "#defib", "CODES", "#unresponsiveTimeout", "#isCheckingResponsiveness", "#offlineTimeout", "#isUnresponsive", "#openPromise", "#wasOpened", "#handleWebSocketOpen", "#handleWebSocketMessage", "message", "kind", "rest", "REQUEST_HEADERS", "#handleRequest", "#handleWebSocketError", "#reconnectTimeout", "#decideReconnect", "code", "NON_RECONNECTABLE_CODES", "#handleWebSocketClose", "reason", "wasClean", "webSocket", "#handleOffline", "prevURL", "StatefulPromise", "_", "reject", "#queue", "#releaseQueue", "data", "args", "#requestCounter", "id", "REQUEST_COUNTER_LIMIT", "lastArg", "resolve", "result", "restProps", "#requestListeners", "requestError"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-ws",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "WebSocket abstraction (server + client, heartbeat, RPC)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"insite",
|
|
@@ -44,10 +44,11 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@nesvet/n": "^1.2.1",
|
|
46
46
|
"eventemitter3": "^5.0.4",
|
|
47
|
-
"insite-common": "^2.
|
|
47
|
+
"insite-common": "^2.6.0",
|
|
48
48
|
"ws": "^8.19.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"
|
|
51
|
+
"bun": ">=1.4.4",
|
|
52
|
+
"node": ">=22.0.0"
|
|
52
53
|
}
|
|
53
54
|
}
|