insite-ws 2.0.15 → 2.0.17
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,12 +1,19 @@
|
|
|
1
1
|
import EventEmitter from "eventemitter3";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export type Options = {
|
|
3
|
+
url?: string | URL;
|
|
4
|
+
name?: string;
|
|
5
|
+
protocols?: string[];
|
|
6
|
+
immediately?: boolean;
|
|
7
|
+
autoReconnect?: boolean;
|
|
8
|
+
on?: Record<string, (...args: any[]) => void>;
|
|
9
|
+
};
|
|
10
|
+
type RequestListener = (...args: any[]) => any | Promise<any>;
|
|
4
11
|
export declare class InSiteWebSocket extends EventEmitter {
|
|
5
|
-
constructor(
|
|
12
|
+
constructor(options?: Options);
|
|
6
13
|
readonly isWebSocket = true;
|
|
7
14
|
readonly isWebSocketServer = false;
|
|
8
15
|
readonly isWebSocketServerClient = false;
|
|
9
|
-
url: string;
|
|
16
|
+
url: string | URL | undefined;
|
|
10
17
|
readonly name: string;
|
|
11
18
|
protocols?: string[] | undefined;
|
|
12
19
|
autoReconnect: boolean;
|
|
@@ -24,8 +31,8 @@ export declare class InSiteWebSocket extends EventEmitter {
|
|
|
24
31
|
private handleWebSocketError;
|
|
25
32
|
private reconnectTimeout?;
|
|
26
33
|
private handleWebSocketClose;
|
|
27
|
-
open(options?: Options): Promise<
|
|
28
|
-
connect: (options?: Options) => Promise<
|
|
34
|
+
open(options?: Options): Promise<void>;
|
|
35
|
+
connect: (options?: Options) => Promise<void>;
|
|
29
36
|
close(code?: number, reason?: string): Promise<unknown>;
|
|
30
37
|
disconnect: (code?: number, reason?: string) => Promise<unknown>;
|
|
31
38
|
private queue;
|
|
@@ -40,4 +47,5 @@ export declare class InSiteWebSocket extends EventEmitter {
|
|
|
40
47
|
private handleRequest;
|
|
41
48
|
static defib(this: InSiteWebSocket): void;
|
|
42
49
|
}
|
|
50
|
+
export {};
|
|
43
51
|
//# sourceMappingURL=WebSocket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../src/client/WebSocket.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../src/client/WebSocket.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAWzC,MAAM,MAAM,OAAO,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAG9D,qBAAa,eAAgB,SAAQ,YAAY;gBACpC,OAAO,GAAE,OAAY;IA+BjC,QAAQ,CAAC,WAAW,QAAQ;IAC5B,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,uBAAuB,SAAS;IAEzC,GAAG,2BAAC;IAEJ,QAAQ,CAAC,IAAI,SAAC;IAEd,SAAS,CAAC,uBAAC;IAEX,aAAa,UAAC;IAEd,IAAI,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI;IAEpE,SAAS,EAAE,IAAI,GAAG,SAAS,CAAQ;IAEnC,OAAO,CAAC,KAAK,CAAqE;IAElF,IAAI,YAAY,mBAEf;IAED,IAAI,MAAM,mBAET;IAED,IAAI,SAAS,mBAEZ;IAED,IAAI,QAAQ,mBAEX;IAED,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,UAAU,CAAC,CAA6B;IAEhD,OAAO,CAAC,mBAAmB,CAUzB;IAEF,OAAO,CAAC,sBAAsB,CAgB5B;IAEF,OAAO,CAAC,oBAAoB,CAY1B;IAEF,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,OAAO,CAAC,oBAAoB,CAgB1B;IAEI,IAAI,CAAC,OAAO,GAAE,OAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAyChD,OAAO,aAzCa,OAAO,KAAQ,OAAO,CAAC,IAAI,CAAC,CAyC5B;IAEpB,KAAK,CAAC,IAAI,SAAO,EAAE,MAAM,SAAW;IAcpC,UAAU,uDAAc;IAExB,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,YAAY,CAOlB;IAEF,WAAW,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;IAc9B,WAAW,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;IA2B9B,OAAO,CAAC,gBAAgB,CAAsC;IAE9D,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe;IAM1D,SAAS,SANgB,MAAM,YAAY,eAAe,UAMtB;IAEpC,qBAAqB,CAAC,IAAI,EAAE,MAAM;IAMlC,UAAU,SANkB,MAAM,UAMM;IAExC,OAAO,CAAC,aAAa,CAoBnB;IAGF,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe;CAWlC"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var m=(c,o,e)=>o in c?k(c,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[o]=e;var t=(c,o,e)=>m(c,typeof o!="symbol"?o+"":o,e);import g from"eventemitter3";import{debounce as v,noop as p,uid as R}from"@nesvet/n";var u={request:"~r-q",response:"~r-s"};var q=2e3,E=0,b=new WeakMap,S=class c extends g{constructor(e={}){super();t(this,"isWebSocket",!0);t(this,"isWebSocketServer",!1);t(this,"isWebSocketServerClient",!1);t(this,"url");t(this,"name");t(this,"protocols");t(this,"autoReconnect");t(this,"webSocket",null);t(this,"defib",v(c.defib,65e3));t(this,"openResolve");t(this,"openReject");t(this,"handleWebSocketOpen",()=>{this.openResolve(),delete this.openResolve,delete this.openReject,this.emit("open"),this.defib()});t(this,"handleWebSocketMessage",({data:e})=>{if(this.defib(),e)try{let[s,...n]=JSON.parse(e);this.emit("message",s,...n),this.emit(`message:${s}`,...n)}catch(s){this.handleWebSocketError(s)}else this.webSocket.send("")});t(this,"handleWebSocketError",e=>{e instanceof Event&&(e=void 0),this.openReject&&(this.openReject(e),delete this.openResolve,delete this.openReject),this.emit("error",e)});t(this,"reconnectTimeout");t(this,"handleWebSocketClose",e=>{process.env.NODE_ENV==="development"&&console.info(`WebSocket ${this.name} is closed with code ${e.code} and reason "${e.reason}"`),this.defib.clear(),this.emit("close",e),this.autoReconnect&&![1002,3500,4e3].includes(e.code)&&(process.env.NODE_ENV==="development"&&console.info(`WebSocket ${this.name} will try to reconnect in 2 sec\u2026`),this.reconnectTimeout=setTimeout(()=>this.open().catch(p),q))});t(this,"connect",this.open);t(this,"disconnect",this.close);t(this,"queue",[]);t(this,"releaseQueue",()=>{for(let e of this.queue)this.webSocket.send(e);this.queue.length=0});t(this,"requestListeners",new Map);t(this,"onRequest",this.addRequestListener);t(this,"offRequest",this.removeRequestListener);t(this,"handleRequest",async(e,s,...n)=>{let h=this.requestListeners.get(s),l,r=null;if(h)try{l=await h.apply(this,n)}catch(i){if(i instanceof Error){let{message:a,...d}=i;r={message:a,...d}}}else r={message:`Unknown request kind "${s}"`};this.sendMessage(`${u.response}-${e}`,r,l)});let{url:s,name:n=(E++).toString(),protocols:h,immediately:l=!0,autoReconnect:r=!0,on:i}=e;if(this.url=s,this.name=n,this.protocols=h,this.autoReconnect=!!r,this.on(`message:${u.request}`,this.handleRequest),i)for(let a in i)i[a]&&this.on(a,i[a]);this.url&&l&&this.open().catch(p)}get isConnecting(){return this.webSocket?this.webSocket.readyState===this.webSocket.CONNECTING:null}get isOpen(){return this.webSocket?this.webSocket.readyState===this.webSocket.OPEN:null}get isClosing(){return this.webSocket?this.webSocket.readyState===this.webSocket.CLOSING:null}get isClosed(){return this.webSocket?this.webSocket.readyState===this.webSocket.CLOSED:null}async open(e={}){return clearTimeout(this.reconnectTimeout),await this.close(4e3,"reopen"),e.url&&(this.url=e.url),e.protocols&&(this.protocols=e.protocols),this.webSocket&&b.get(this.webSocket)!==this.url&&this.emit("server-change"),new Promise((s,n)=>{this.url?(this.openResolve=s,this.openReject=n,this.webSocket=new WebSocket(this.url,this.protocols),this.webSocket.addEventListener("open",this.handleWebSocketOpen),this.webSocket.addEventListener("message",this.handleWebSocketMessage),this.webSocket.addEventListener("error",this.handleWebSocketError),this.webSocket.addEventListener("close",this.handleWebSocketClose),this.send=this.webSocket.send.bind(this.webSocket),b.set(this.webSocket,this.url),this.emit("connecting")):(this.webSocket=null,delete this.send,n(new Error("url prop is not set")))})}close(e=3500,s="manual"){return clearTimeout(this.reconnectTimeout),new Promise(n=>{this.isConnecting||this.isOpen?(this.webSocket.addEventListener("close",n),this.webSocket.close(e,s)):n(null)})}sendMessage(...e){let s=JSON.stringify(e);this.isOpen?this.webSocket.send(s):(this.queue.length||this.once("open",this.releaseQueue),this.queue.push(s))}sendRequest(...e){let s=R(),n=`message:${u.response}-${s}`;return typeof e.at(-1)=="function"?(this.once(n,e.splice(-1,1)[0]),this.sendMessage(u.request,s,...e),this):new Promise((h,l)=>{this.once(n,(r,i)=>{if(r){let{message:a,...d}=r;l(Object.assign(new Error(a),d))}else h(i)}),this.sendMessage(u.request,s,...e)})}addRequestListener(e,s){return this.requestListeners.set(e,s),this}removeRequestListener(e){return this.requestListeners.delete(e),this}static defib(){this.isOpen&&(process.env.NODE_ENV==="development"&&console.info(`WebSocket ${this.name} has no heartbeat - going offline`),this.webSocket.close())}};export{S as InSiteWebSocket};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/client/WebSocket.ts", "../../src/common.ts"],
|
|
4
|
-
"sourcesContent": ["import EventEmitter from \"eventemitter3\";\nimport { debounce, noop, uid } from \"@nesvet/n\";\nimport { heartbeatGap, heartbeatInterval, requestHeaders } from \"../common\";\
|
|
5
|
-
"mappings": "oKAAA,OAAOA,MAAkB,gBACzB,OAAS,YAAAC,EAAU,QAAAC,EAAM,OAAAC,MAAW,YCE7B,IAAMC,EAAiB,CAC7B,QAAS,OACT,SAAU,MACX,
|
|
6
|
-
"names": ["EventEmitter", "debounce", "noop", "uid", "requestHeaders", "reconnectTimeout", "i", "webSocketUrlMap", "InSiteWebSocket", "_InSiteWebSocket", "EventEmitter", "
|
|
4
|
+
"sourcesContent": ["import EventEmitter from \"eventemitter3\";\nimport { debounce, noop, uid } from \"@nesvet/n\";\nimport { heartbeatGap, heartbeatInterval, requestHeaders } from \"../common\";\n\n\nconst reconnectTimeout = 2000;\n\nlet i = 0;\n\nconst webSocketUrlMap = new WeakMap<WebSocket, string | URL>();\n\nexport type Options = {\n\turl?: string | URL;\n\tname?: string;\n\tprotocols?: string[];\n\timmediately?: boolean;\n\tautoReconnect?: boolean;\n\ton?: Record<string, (...args: any[]) => void>;// eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\ntype RequestListener = (...args: any[]) => any | Promise<any>;// eslint-disable-line @typescript-eslint/no-explicit-any\n\n\nexport class InSiteWebSocket extends EventEmitter {\n\tconstructor(options: Options = {}) {\n\t\tsuper();\n\t\t\n\t\tconst {\n\t\t\turl,\n\t\t\tname = (i++).toString(),\n\t\t\tprotocols,\n\t\t\timmediately = true,\n\t\t\tautoReconnect = true,\n\t\t\ton\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.autoReconnect = !!autoReconnect;\n\t\t\n\t\tthis.on(`message:${requestHeaders.request}`, this.handleRequest);\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 (this.url && immediately)\n\t\t\tthis.open().catch(noop);\n\t\t\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\tautoReconnect;\n\t\n\tsend?(data: ArrayBufferLike | ArrayBufferView | Blob | string): void;\n\t\n\twebSocket: null | WebSocket = null;\n\t\n\tprivate defib = debounce(InSiteWebSocket.defib, heartbeatInterval + heartbeatGap);\n\t\n\tget isConnecting() {\n\t\treturn this.webSocket ? this.webSocket.readyState === this.webSocket.CONNECTING : null;\n\t}\n\t\n\tget isOpen() {\n\t\treturn this.webSocket ? this.webSocket.readyState === this.webSocket.OPEN : null;\n\t}\n\t\n\tget isClosing() {\n\t\treturn this.webSocket ? this.webSocket.readyState === this.webSocket.CLOSING : null;\n\t}\n\t\n\tget isClosed() {\n\t\treturn this.webSocket ? this.webSocket.readyState === this.webSocket.CLOSED : null;\n\t}\n\t\n\tprivate openResolve?: () => void;\n\tprivate openReject?: (reason?: unknown) => void;\n\t\n\tprivate handleWebSocketOpen = () => {\n\t\t\n\t\tthis.openResolve!();\n\t\tdelete this.openResolve;\n\t\tdelete this.openReject;\n\t\t\n\t\tthis.emit(\"open\");\n\t\t\n\t\tthis.defib();\n\t\t\n\t};\n\t\n\tprivate handleWebSocketMessage = ({ data: message }: MessageEvent) => {\n\t\t\n\t\tthis.defib();\n\t\t\n\t\tif (message)\n\t\t\ttry {\n\t\t\t\tconst [ kind, ...rest ] = JSON.parse(message);\n\t\t\t\t\n\t\t\t\tthis.emit(\"message\", kind, ...rest);\n\t\t\t\tthis.emit(`message:${kind}`, ...rest);\n\t\t\t} catch (error) {\n\t\t\t\tthis.handleWebSocketError(error as Error);\n\t\t\t}\n\t\telse\n\t\t\tthis.webSocket!.send(\"\");\n\t\t\n\t};\n\t\n\tprivate handleWebSocketError = (error: Error | Event | undefined) => {\n\t\tif (error instanceof Event)\n\t\t\terror = undefined;\n\t\t\n\t\tif (this.openReject) {\n\t\t\tthis.openReject(error);\n\t\t\tdelete this.openResolve;\n\t\t\tdelete this.openReject;\n\t\t}\n\t\t\n\t\tthis.emit(\"error\", error);\n\t\t\n\t};\n\t\n\tprivate reconnectTimeout?: number;\n\t\n\tprivate handleWebSocketClose = (event: CloseEvent) => {\n\t\t\n\t\tif (process.env.NODE_ENV === \"development\")\n\t\t\tconsole.info(`WebSocket ${this.name} is closed with code ${event.code} and reason \"${event.reason}\"`);\n\t\t\n\t\tthis.defib.clear();\n\t\t\n\t\tthis.emit(\"close\", event);\n\t\t\n\t\tif (this.autoReconnect && ![ 1002, 3500, 4000 ].includes(event.code)) {\n\t\t\tif (process.env.NODE_ENV === \"development\")\n\t\t\t\tconsole.info(`WebSocket ${this.name} will try to reconnect in 2 sec\u2026`);\n\t\t\t\n\t\t\tthis.reconnectTimeout = setTimeout(() => this.open().catch(noop), reconnectTimeout) as unknown as number;\n\t\t}\n\t\t\n\t};\n\t\n\tasync open(options: Options = {}): Promise<void> {\n\t\t\n\t\tclearTimeout(this.reconnectTimeout);\n\t\t\n\t\tawait this.close(4000, \"reopen\");\n\t\t\n\t\tif (options.url)\n\t\t\tthis.url = options.url;\n\t\t\n\t\tif (options.protocols)\n\t\t\tthis.protocols = options.protocols;\n\t\t\n\t\tif (this.webSocket && webSocketUrlMap.get(this.webSocket) !== this.url)\n\t\t\tthis.emit(\"server-change\");\n\t\t\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (this.url) {\n\t\t\t\tthis.openResolve = resolve;\n\t\t\t\tthis.openReject = reject;\n\t\t\t\t\n\t\t\t\tthis.webSocket = new WebSocket(this.url, this.protocols);\n\t\t\t\t\n\t\t\t\tthis.webSocket.addEventListener(\"open\", this.handleWebSocketOpen);\n\t\t\t\tthis.webSocket.addEventListener(\"message\", this.handleWebSocketMessage);\n\t\t\t\tthis.webSocket.addEventListener(\"error\", this.handleWebSocketError);\n\t\t\t\tthis.webSocket.addEventListener(\"close\", this.handleWebSocketClose);\n\t\t\t\t\n\t\t\t\tthis.send = this.webSocket.send.bind(this.webSocket);\n\t\t\t\t\n\t\t\t\twebSocketUrlMap.set(this.webSocket, this.url);\n\t\t\t\t\n\t\t\t\tthis.emit(\"connecting\");\n\t\t\t} else {\n\t\t\t\tthis.webSocket = null;\n\t\t\t\tdelete this.send;\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}\n\t\n\tconnect = this.open;\n\t\n\tclose(code = 3500, reason = \"manual\") {\n\t\t\n\t\tclearTimeout(this.reconnectTimeout);\n\t\t\n\t\treturn new Promise(resolve => {\n\t\t\tif (this.isConnecting || this.isOpen) {\n\t\t\t\tthis.webSocket!.addEventListener(\"close\", resolve);\n\t\t\t\tthis.webSocket!.close(code, reason);\n\t\t\t} else\n\t\t\t\tresolve(null);\n\t\t\t\n\t\t});\n\t}\n\t\n\tdisconnect = this.close;\n\t\n\tprivate queue: string[] = [];\n\t\n\tprivate 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\tsendMessage(...args: unknown[]) {\n\t\tconst message = JSON.stringify(args);\n\t\t\n\t\tif (this.isOpen)\n\t\t\tthis.webSocket!.send(message);\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(message);\n\t\t}\n\t\t\n\t}\n\t\n\tsendRequest(...args: unknown[]) {\n\t\t\n\t\tconst id = uid();\n\t\tconst eventName = `message:${requestHeaders.response}-${id}`;\n\t\t\n\t\tif (typeof args.at(-1) == \"function\") {\n\t\t\tthis.once(eventName, args.splice(-1, 1)[0] as () => void);\n\t\t\tthis.sendMessage(requestHeaders.request, id, ...args);\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t\n\t\t\tthis.once(eventName, (error, result) => {\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));\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\tthis.sendMessage(requestHeaders.request, id, ...args);\n\t\t\t\n\t\t});\n\t}\n\t\n\tprivate 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\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\toffRequest = this.removeRequestListener;\n\t\n\tprivate handleRequest = async (id: string, 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(`${requestHeaders.response}-${id}`, requestError, result);\n\t\t\n\t};\n\t\n\t\n\tstatic defib(this: InSiteWebSocket) {\n\t\t\n\t\tif (this.isOpen) {\n\t\t\tif (process.env.NODE_ENV === \"development\")\n\t\t\t\tconsole.info(`WebSocket ${this.name} has no heartbeat - going offline`);\n\t\t\t\n\t\t\tthis.webSocket!.close();\n\t\t}\n\t\t\n\t}\n\t\n}\n", "export const heartbeatInterval = 5_000;\nexport const heartbeatGap = 60_000;\n\nexport const requestHeaders = {\n\trequest: \"~r-q\",\n\tresponse: \"~r-s\"\n};\n"],
|
|
5
|
+
"mappings": "oKAAA,OAAOA,MAAkB,gBACzB,OAAS,YAAAC,EAAU,QAAAC,EAAM,OAAAC,MAAW,YCE7B,IAAMC,EAAiB,CAC7B,QAAS,OACT,SAAU,MACX,EDDA,IAAMC,EAAmB,IAErBC,EAAI,EAEFC,EAAkB,IAAI,QAcfC,EAAN,MAAMC,UAAwBC,CAAa,CACjD,YAAYC,EAAmB,CAAC,EAAG,CAClC,MAAM,EA8BPC,EAAA,KAAS,cAAc,IACvBA,EAAA,KAAS,oBAAoB,IAC7BA,EAAA,KAAS,0BAA0B,IAEnCA,EAAA,YAEAA,EAAA,KAAS,QAETA,EAAA,kBAEAA,EAAA,sBAIAA,EAAA,iBAA8B,MAE9BA,EAAA,KAAQ,QAAQC,EAASJ,EAAgB,MAAO,IAAgC,GAkBhFG,EAAA,KAAQ,eACRA,EAAA,KAAQ,cAERA,EAAA,KAAQ,sBAAsB,IAAM,CAEnC,KAAK,YAAa,EAClB,OAAO,KAAK,YACZ,OAAO,KAAK,WAEZ,KAAK,KAAK,MAAM,EAEhB,KAAK,MAAM,CAEZ,GAEAA,EAAA,KAAQ,yBAAyB,CAAC,CAAE,KAAME,CAAQ,IAAoB,CAIrE,GAFA,KAAK,MAAM,EAEPA,EACH,GAAI,CACH,GAAM,CAAEC,EAAM,GAAGC,CAAK,EAAI,KAAK,MAAMF,CAAO,EAE5C,KAAK,KAAK,UAAWC,EAAM,GAAGC,CAAI,EAClC,KAAK,KAAK,WAAWD,CAAI,GAAI,GAAGC,CAAI,CACrC,OAASC,EAAO,CACf,KAAK,qBAA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,OAAO,GAAI,CAAC,EAAE,CAAC,CAAe,EACxD,KAAK,YAAYZ,EAAe,QAASL,EAAI,GAAGiB,CAAI,EAE7C,MAGD,IAAI,QAAQ,CAACJ,EAASC,IAAW,CAEvC,KAAK,KAAKF,EAAW,CAACf,EAAOK,IAAW,CACvC,GAAIL,EAAO,CACV,GAAM,CAAE,QAAAH,EAAS,GAAGU,CAAU,EAAIP,EAClCiB,EAAO,OAAO,OAAO,IAAI,MAAMpB,CAAO,EAAGU,CAAS,CAAC,CACpD,MACCS,EAAQX,CAAM,CAEhB,CAAC,EACD,KAAK,YAAYG,EAAe,QAASL,EAAI,GAAGiB,CAAI,CAErD,CAAC,CACF,CAIA,mBAAmBtB,EAAcM,EAA2B,CAC3D,YAAK,iBAAiB,IAAIN,EAAMM,CAAQ,EAEjC,IACR,CAIA,sBAAsBN,EAAc,CACnC,YAAK,iBAAiB,OAAOA,CAAI,EAE1B,IACR,CA2BA,OAAO,OAA6B,CAE/B,KAAK,SACJ,QAAQ,IAAI,WAAa,eAC5B,QAAQ,KAAK,aAAa,KAAK,IAAI,mCAAmC,EAEvE,KAAK,UAAW,MAAM,EAGxB,CAED",
|
|
6
|
+
"names": ["EventEmitter", "debounce", "noop", "uid", "requestHeaders", "reconnectTimeout", "i", "webSocketUrlMap", "InSiteWebSocket", "_InSiteWebSocket", "EventEmitter", "options", "__publicField", "debounce", "message", "kind", "rest", "error", "event", "noop", "id", "listener", "result", "requestError", "restProps", "requestHeaders", "url", "name", "protocols", "immediately", "autoReconnect", "on", "eventName", "resolve", "reject", "code", "reason", "args", "uid"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-ws",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "inSite WebSockets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./server": "./dist/server/index.js",
|
|
8
8
|
"./client": "./dist/client/index.js"
|
|
9
9
|
},
|
|
10
|
-
"packageManager": "bun@1.1.
|
|
10
|
+
"packageManager": "bun@1.1.25",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
13
|
"build": "bun .conveyer.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@nesvet/conveyer": "^2.2.4",
|
|
34
34
|
"@nesvet/eslint-config": "^2.0.24",
|
|
35
|
-
"@types/node": "^22.
|
|
35
|
+
"@types/node": "^22.5.0",
|
|
36
36
|
"@types/ws": "^8.5.12",
|
|
37
37
|
"typescript": "^5.5.4"
|
|
38
38
|
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/dist/client/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC;CAClD,CAAC"}
|