@zyzgroup/core-web 0.1.67 → 0.1.69

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zyzgroup/core-web",
3
3
  "private": false,
4
- "version": "0.1.67",
4
+ "version": "0.1.69",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "browser": {
@@ -1,20 +1,55 @@
1
- type SocketMessage = string | Blob | ArrayBuffer;
2
1
  type WebSocketClientRequest = {
3
2
  requestid: number;
4
3
  resolve?: (value: any) => void;
5
4
  };
5
+ type SocketCreator = (url: string, protocols?: string | string[], options?: Record<string, any>) => WebSocket;
6
+ export declare function createWebSocket(url: string, protocols?: string | string[], options?: Record<string, any>): WebSocket;
7
+ export declare function getVertxRegisterBaseUrl(baseUrl: string): string;
6
8
  export declare class WebSocketClient {
7
- requestid: number;
9
+ static CONNECTING: 0;
10
+ static OPEN: 1;
11
+ static CLOSING: 2;
12
+ static CLOSED: 3;
8
13
  url: string;
14
+ socketCreatorProtocols?: string | string[];
15
+ socketCreatorOptions: Record<string, any>;
16
+ socketCreator: SocketCreator;
9
17
  socket?: WebSocket;
18
+ state: typeof WebSocketClient.CONNECTING | typeof WebSocketClient.OPEN | typeof WebSocketClient.CLOSING | typeof WebSocketClient.CLOSED;
19
+ messageQueue: Record<string, any>[];
20
+ pingInterval: number;
21
+ pingTimerID?: ReturnType<typeof setInterval>;
22
+ reconnect: boolean;
23
+ reconnectAttempts: number;
24
+ maxReconnectAttempts: number;
25
+ reconnectTimerID?: ReturnType<typeof setTimeout>;
26
+ onopen?: () => void;
27
+ onclose?: (e: CloseEvent) => void;
28
+ onerror?: (e: any) => void;
29
+ requestid: number;
10
30
  waitings: Record<number, WebSocketClientRequest>;
11
- messageQueue: SocketMessage[];
12
- constructor(url: string);
13
- private _connect;
14
- private _send;
31
+ listeners: Record<string, ((err: any, message?: string) => void)[]>;
32
+ constructor(url?: string, options?: {
33
+ socketCreatorProtocols?: string | string[];
34
+ socketCreatorOptions?: Record<string, any>;
35
+ socketCreator?: SocketCreator;
36
+ pingInterval?: number;
37
+ onopen?: () => void;
38
+ onclose?: (e: CloseEvent) => void;
39
+ onerror?: (e: Event) => void;
40
+ reconnect?: boolean;
41
+ maxReconnectAttempts?: number;
42
+ });
15
43
  open(): void;
16
44
  close(): void;
17
- send(details: Record<string, string> | string | Blob | ArrayBuffer, ms?: number): Promise<SocketMessage>;
45
+ private _connect;
46
+ private onunhandled;
47
+ private _send;
48
+ ping(): void;
49
+ register(address: string, listener: (err: any, message?: string) => void, headers?: Record<string, string>): void;
50
+ unregister(address: string, listener: (err: any, message?: string) => void, headers?: Record<string, string>): void;
51
+ publish(address: string, body: Record<string, any>, headers?: Record<string, string>): void;
52
+ send(address: string, body: Record<string, any>, headers?: Record<string, string>, timeout?: number): Promise<string>;
18
53
  }
19
54
  export {};
20
55
  //# sourceMappingURL=WebSocketClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketClient.d.ts","sourceRoot":"","sources":["../src/WebSocketClient.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,WAAW,CAAC;AAEjD,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,qBAAa,eAAe;IAC1B,SAAS,SAAK;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAM;IACtD,YAAY,EAAE,aAAa,EAAE,CAAM;gBAGvB,GAAG,EAAE,MAAM;IAKvB,OAAO,CAAC,QAAQ;IA8ChB,OAAO,CAAC,KAAK;IAaN,IAAI;IAIJ,KAAK;IAMC,IAAI,C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,KAAK;IAKZ,OAAO,CAAC,QAAQ;IAyHhB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,KAAK;IAUN,IAAI;IAKJ,QAAQ,CACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,EAC9C,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAe/B,UAAU,CACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,EAC9C,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAqB/B,OAAO,CACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAWzB,IAAI,CACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,SAAQ,GACd,OAAO,CAAC,MAAM,CAAC;CA2BnB"}
@@ -1,9 +0,0 @@
1
- export declare const EventBus: {
2
- (this: any, socketClientCreator: (url: string, options: Record<string, string | number>) => any, url: string, options?: Record<string, string | number>): void;
3
- CONNECTING: number;
4
- OPEN: number;
5
- CLOSING: number;
6
- CLOSED: number;
7
- };
8
- export default EventBus;
9
- //# sourceMappingURL=WebSocketClientEventbus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocketClientEventbus.d.ts","sourceRoot":"","sources":["../src/WebSocketClientEventbus.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,QAAQ;WACb,GAAG,uBACY,CACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACrC,GAAG,OACH,MAAM,YACF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;;;;;CAiIzC,CAAC;AA0KF,eAAe,QAAQ,CAAC"}