@celljs/rpc 4.33.0 → 4.35.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.
Files changed (90) hide show
  1. package/README.md +6 -0
  2. package/README.zh-cn.md +6 -0
  3. package/esm/common/protocol/json-rpc.d.ts +2 -0
  4. package/esm/common/protocol/json-rpc.js +2 -0
  5. package/esm/common/protocol/json-rpc.js.map +1 -1
  6. package/esm/common/transport/index.d.ts +1 -0
  7. package/esm/common/transport/index.js +1 -0
  8. package/esm/common/transport/index.js.map +1 -1
  9. package/esm/common/transport/rpc-websocket-client.d.ts +139 -0
  10. package/esm/common/transport/rpc-websocket-client.js +404 -0
  11. package/esm/common/transport/rpc-websocket-client.js.map +1 -0
  12. package/esm/common/transport/websocket-transport.d.ts +10 -19
  13. package/esm/common/transport/websocket-transport.js +50 -121
  14. package/esm/common/transport/websocket-transport.js.map +1 -1
  15. package/esm/node/connection/index.d.ts +1 -0
  16. package/esm/node/connection/index.js +1 -0
  17. package/esm/node/connection/index.js.map +1 -1
  18. package/esm/node/connection/rpc-push-channel.d.ts +43 -0
  19. package/esm/node/connection/rpc-push-channel.js +83 -0
  20. package/esm/node/connection/rpc-push-channel.js.map +1 -0
  21. package/esm/node/websocket/index.d.ts +1 -0
  22. package/esm/node/websocket/index.js +1 -0
  23. package/esm/node/websocket/index.js.map +1 -1
  24. package/esm/node/websocket/rpc-websocket-server.d.ts +1 -2
  25. package/esm/node/websocket/rpc-websocket-server.js +10 -19
  26. package/esm/node/websocket/rpc-websocket-server.js.map +1 -1
  27. package/esm/node/websocket/websocket-upgrades.d.ts +46 -0
  28. package/esm/node/websocket/websocket-upgrades.js +76 -0
  29. package/esm/node/websocket/websocket-upgrades.js.map +1 -0
  30. package/lib/common/protocol/json-rpc.d.ts +2 -0
  31. package/lib/common/protocol/json-rpc.d.ts.map +1 -1
  32. package/lib/common/protocol/json-rpc.js +2 -0
  33. package/lib/common/protocol/json-rpc.js.map +1 -1
  34. package/lib/common/transport/index.d.ts +1 -0
  35. package/lib/common/transport/index.d.ts.map +1 -1
  36. package/lib/common/transport/index.js +1 -0
  37. package/lib/common/transport/index.js.map +1 -1
  38. package/lib/common/transport/rpc-websocket-client.d.ts +140 -0
  39. package/lib/common/transport/rpc-websocket-client.d.ts.map +1 -0
  40. package/lib/common/transport/rpc-websocket-client.js +408 -0
  41. package/lib/common/transport/rpc-websocket-client.js.map +1 -0
  42. package/lib/common/transport/rpc-websocket-client.spec.d.ts +2 -0
  43. package/lib/common/transport/rpc-websocket-client.spec.d.ts.map +1 -0
  44. package/lib/common/transport/rpc-websocket-client.spec.js +162 -0
  45. package/lib/common/transport/rpc-websocket-client.spec.js.map +1 -0
  46. package/lib/common/transport/websocket-transport.d.ts +10 -19
  47. package/lib/common/transport/websocket-transport.d.ts.map +1 -1
  48. package/lib/common/transport/websocket-transport.js +50 -121
  49. package/lib/common/transport/websocket-transport.js.map +1 -1
  50. package/lib/node/connection/index.d.ts +1 -0
  51. package/lib/node/connection/index.d.ts.map +1 -1
  52. package/lib/node/connection/index.js +1 -0
  53. package/lib/node/connection/index.js.map +1 -1
  54. package/lib/node/connection/rpc-push-channel.d.ts +44 -0
  55. package/lib/node/connection/rpc-push-channel.d.ts.map +1 -0
  56. package/lib/node/connection/rpc-push-channel.js +87 -0
  57. package/lib/node/connection/rpc-push-channel.js.map +1 -0
  58. package/lib/node/connection/rpc-push-channel.spec.d.ts +2 -0
  59. package/lib/node/connection/rpc-push-channel.spec.d.ts.map +1 -0
  60. package/lib/node/connection/rpc-push-channel.spec.js +59 -0
  61. package/lib/node/connection/rpc-push-channel.spec.js.map +1 -0
  62. package/lib/node/websocket/index.d.ts +1 -0
  63. package/lib/node/websocket/index.d.ts.map +1 -1
  64. package/lib/node/websocket/index.js +1 -0
  65. package/lib/node/websocket/index.js.map +1 -1
  66. package/lib/node/websocket/rpc-websocket-server.d.ts +1 -2
  67. package/lib/node/websocket/rpc-websocket-server.d.ts.map +1 -1
  68. package/lib/node/websocket/rpc-websocket-server.js +10 -19
  69. package/lib/node/websocket/rpc-websocket-server.js.map +1 -1
  70. package/lib/node/websocket/websocket-upgrades.d.ts +47 -0
  71. package/lib/node/websocket/websocket-upgrades.d.ts.map +1 -0
  72. package/lib/node/websocket/websocket-upgrades.js +80 -0
  73. package/lib/node/websocket/websocket-upgrades.js.map +1 -0
  74. package/lib/node/websocket/websocket-upgrades.spec.d.ts +2 -0
  75. package/lib/node/websocket/websocket-upgrades.spec.d.ts.map +1 -0
  76. package/lib/node/websocket/websocket-upgrades.spec.js +64 -0
  77. package/lib/node/websocket/websocket-upgrades.spec.js.map +1 -0
  78. package/package.json +4 -4
  79. package/src/common/protocol/json-rpc.ts +2 -0
  80. package/src/common/transport/index.ts +1 -0
  81. package/src/common/transport/rpc-websocket-client.spec.ts +164 -0
  82. package/src/common/transport/rpc-websocket-client.ts +476 -0
  83. package/src/common/transport/websocket-transport.ts +51 -126
  84. package/src/node/connection/index.ts +3 -1
  85. package/src/node/connection/rpc-push-channel.spec.ts +61 -0
  86. package/src/node/connection/rpc-push-channel.ts +98 -0
  87. package/src/node/websocket/index.ts +1 -0
  88. package/src/node/websocket/rpc-websocket-server.ts +5 -16
  89. package/src/node/websocket/websocket-upgrades.spec.ts +64 -0
  90. package/src/node/websocket/websocket-upgrades.ts +95 -0
package/README.md CHANGED
@@ -116,6 +116,12 @@ The server side is part of the package (no dependency); it needs a runtime whose
116
116
 
117
117
  A `RpcWebSocketGuard` component (`allows(request): boolean`) decides on the upgrade request whether a connection may open, before anything runs over it; refused connections get a 401. All guards must agree.
118
118
 
119
+ ### Clients, routes and pushes
120
+
121
+ - `RpcWebSocketClient` (`@celljs/rpc/lib/common/transport/rpc-websocket-client`, no other dependency) is a client for a browser, Electron, a mobile app or a backend: it reconnects with a wait that doubles, lets a call made while it is down wait for it (`waitForOpenMs`), sends a call again on the next connection when `resendable` says doing it twice does what doing it once does (a read, a message the server takes once by its id), and checks a connection when a call stalls while nothing comes (`stallMs`). Calls answer `JsonRpc.Response`s; `-32005` is a call that was not sent. `WebSocketTransport` is one.
122
+ - `WebSocketUpgrades.of(server).route(path, handler)` (`@celljs/rpc/lib/node`) routes the upgrade requests of one HTTP server by path, with one listener: the RPC socket is one route, an application's own sockets others; a request no route takes is refused with 404.
123
+ - `RpcPushChannel` (`@celljs/rpc/lib/node`) is what the server pushes to one client: the next batch leaves once the client answered the last, items that come by the hundred (`streamed`) at most once an interval, any other at once, and a client too far behind (`maxBacklogBytes`) is told by `overflow`.
124
+
119
125
  ## Batching
120
126
 
121
127
  Over HTTP, `rpc.merge.enabled: true` makes the proxies send the calls made within `timerDelay` (35 ms) in one request (a JSON-RPC batch), up to `maxCount` calls or `maxLength` bytes.
package/README.zh-cn.md CHANGED
@@ -116,6 +116,12 @@ export class OrderServerImpl implements OrderServer {
116
116
 
117
117
  一个 `RpcWebSocketGuard` 组件(`allows(request): boolean`)在升级请求上决定连接是否可打开,在任何东西运行前;拒绝的连接得 401。所有守卫必须同意。
118
118
 
119
+ ### 客户端、路由与推送
120
+
121
+ - `RpcWebSocketClient`(`@celljs/rpc/lib/common/transport/rpc-websocket-client`,无其他依赖)是给浏览器、Electron、手机 App 或后端用的客户端:断线后按加倍的等待重连;断线时发出的调用会等连接回来(`waitForOpenMs`);`resendable` 判定做两次与做一次相同的调用(读取、服务端按 id 只收一次的消息)会在下一条连接上重发;调用卡住且一直没有消息时检查连接(`stallMs`)。调用返回 `JsonRpc.Response`,`-32005` 表示没有发出。`WebSocketTransport` 就基于它。
122
+ - `WebSocketUpgrades.of(server).route(path, handler)`(`@celljs/rpc/lib/node`)按路径分发一台 HTTP 服务器的升级请求,只用一个监听:RPC 的 socket 是一条路由,应用自己的 socket 是其他路由;没有路由接的请求回 404。
123
+ - `RpcPushChannel`(`@celljs/rpc/lib/node`)是服务端推给一个客户端的通道:上一批得到回应后才发下一批;成百条涌来的项(`streamed`)每个间隔最多发一次,其他的立即发;落后太多(`maxBacklogBytes`)的客户端由 `overflow` 告知。
124
+
119
125
  ## 批处理
120
126
 
121
127
  基于 HTTP,`rpc.merge.enabled: true` 让代理在 `timerDelay` 内发起的调用(35 毫秒)在一个请求中发送(JSON-RPC 批处理),最多 `maxCount` 个调用或 `maxLength` 字节。
@@ -34,6 +34,8 @@ export declare namespace JsonRpc {
34
34
  const CONNECTION_CLOSED = -32003;
35
35
  /** No response within the timeout. */
36
36
  const TIMEOUT = -32004;
37
+ /** No connection came within the wait: the call was not sent. */
38
+ const NOT_CONNECTED = -32005;
37
39
  function isRequest(message: unknown): message is Request;
38
40
  function isResponse(message: unknown): message is Response;
39
41
  function request(id: Id | undefined, method: string, params: unknown[]): Request;
@@ -15,6 +15,8 @@ export var JsonRpc;
15
15
  JsonRpc.CONNECTION_CLOSED = -32003;
16
16
  /** No response within the timeout. */
17
17
  JsonRpc.TIMEOUT = -32004;
18
+ /** No connection came within the wait: the call was not sent. */
19
+ JsonRpc.NOT_CONNECTED = -32005;
18
20
  function isRequest(message) {
19
21
  return isObject(message) && message.jsonrpc === '2.0' && typeof message.method === 'string'
20
22
  && (message.params === undefined || Array.isArray(message.params)) && (message.id === undefined || isId(message.id));
@@ -1 +1 @@
1
- {"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../../src/common/protocol/json-rpc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,KAAW,OAAO,CAqEvB;AArED,WAAiB,OAAO;IA2BP,mBAAW,GAAG,CAAC,KAAK,CAAC;IACrB,uBAAe,GAAG,CAAC,KAAK,CAAC;IACzB,wBAAgB,GAAG,CAAC,KAAK,CAAC;IAC1B,sBAAc,GAAG,CAAC,KAAK,CAAC;IACxB,sBAAc,GAAG,CAAC,KAAK,CAAC;IACrC,+EAA+E;IAClE,oBAAY,GAAG,CAAC,KAAK,CAAC;IACnC,mEAAmE;IACtD,yBAAiB,GAAG,CAAC,KAAK,CAAC;IACxC,sCAAsC;IACzB,eAAO,GAAG,CAAC,KAAK,CAAC;IAE9B,SAAgB,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AAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9E,CAAC;IAHe,QAAA,MAAM,SAGrB,CAAA;IAED,SAAgB,KAAK,CAAC,EAAa,EAAE,IAAY,EAAE,OAAe,EAAE,IAAc;QAC9E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;IAC3G,CAAC;IAFe,QAAA,KAAK,QAEpB,CAAA;IAED,SAAS,IAAI,CAAC,EAAW;QACrB,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,SAAS,QAAQ,CAAC,KAAc;QAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;AACL,CAAC,EAvEgB,OAAO,KAAP,OAAO,QAuEvB"}
@@ -1,4 +1,5 @@
1
1
  export * from './transport-protocol.js';
2
2
  export * from './http-transport.js';
3
+ export * from './rpc-websocket-client.js';
3
4
  export * from './websocket-transport.js';
4
5
  export * from './transport-provider.js';
@@ -1,5 +1,6 @@
1
1
  export * from './transport-protocol.js';
2
2
  export * from './http-transport.js';
3
+ export * from './rpc-websocket-client.js';
3
4
  export * from './websocket-transport.js';
4
5
  export * from './transport-provider.js';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/transport/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/transport/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,139 @@
1
+ import { JsonRpc } from '../protocol/json-rpc.js';
2
+ /** What the client uses of a WebSocket: that of the platform (browsers, Bun, Deno, Node.js 22), or another way (a relay). */
3
+ export interface RpcSocket {
4
+ readonly readyState: number;
5
+ onopen: ((event?: unknown) => void) | null;
6
+ onmessage: ((message: {
7
+ data: unknown;
8
+ }) => void) | null;
9
+ onclose: ((event?: unknown) => void) | null;
10
+ onerror?: ((event?: unknown) => void) | null;
11
+ send(text: string): void;
12
+ close(code?: number, reason?: string): void;
13
+ }
14
+ export interface RpcWebSocketClientOptions {
15
+ /** A new socket for each connection. */
16
+ createSocket(): RpcSocket;
17
+ /** Makes the connection again after a loss, until closed. Default true. */
18
+ reconnect?: boolean;
19
+ /** First wait before making it again; it doubles up to `maxReconnectDelayMs`. Default 250. */
20
+ reconnectDelayMs?: number;
21
+ /** Default 10000. */
22
+ maxReconnectDelayMs?: number;
23
+ /** A socket not open within this is given up (a server that never answers the upgrade). Default 0: no limit. */
24
+ openTimeoutMs?: number;
25
+ /**
26
+ * How long a call made while the connection is down waits for it, so that a short drop goes unnoticed; it was not
27
+ * sent. Default 5000; 0 answers {@link JsonRpc.NOT_CONNECTED} at once.
28
+ */
29
+ waitForOpenMs?: number;
30
+ /**
31
+ * Whether a call may go again on the next connection when the one it went on is lost, as doing it twice does
32
+ * what doing it once does (a read; a message the server takes once by its id). Default: none.
33
+ */
34
+ resendable?(method: string, params: readonly unknown[]): boolean;
35
+ /** How long a resendable call keeps trying across lost connections. Default `waitForOpenMs`. */
36
+ retryForMs?: number;
37
+ /**
38
+ * A call unanswered this long while nothing at all came makes the client check the connection ({@link wake}):
39
+ * one gone without a word is made again in seconds, not when the system notices. Default 5000; 0 never.
40
+ */
41
+ stallMs?: number;
42
+ /** What the check asks: any answer but a lost connection says it is alive. Default `rpc.ping`. */
43
+ probe?: {
44
+ method: string;
45
+ params: unknown[];
46
+ };
47
+ /** A call unanswered this long answers {@link JsonRpc.TIMEOUT}. Default 0: no limit. */
48
+ callTimeoutMs?: number;
49
+ /**
50
+ * Answers what the server asks (`@RpcClient`, events it pushes). An answer that is not a promise leaves at once,
51
+ * in the same turn; one that throws or rejects answers {@link JsonRpc.SERVER_ERROR}.
52
+ */
53
+ handle?(request: JsonRpc.Request): JsonRpc.Response | Promise<JsonRpc.Response>;
54
+ }
55
+ interface Pending {
56
+ resolve(response: JsonRpc.Response): void;
57
+ /** When it was sent, on the clock of Date.now(). */
58
+ sentAt: number;
59
+ timer?: ReturnType<typeof setTimeout>;
60
+ }
61
+ /**
62
+ * JSON-RPC 2.0 over one WebSocket to a server, for a browser, Electron, a mobile app or a backend, with no other
63
+ * dependency. Calls answer {@link JsonRpc.Response}s; they do not throw.
64
+ *
65
+ * - It makes the connection again after a loss (`reconnect`), after a wait that doubles; `onOpen` runs each time.
66
+ * A first connection that cannot be made rejects `connect`, and is not tried again on its own.
67
+ * - A call made while it is down waits a little for it (`waitForOpenMs`).
68
+ * - A call sent on a connection lost before its answer answers {@link JsonRpc.CONNECTION_CLOSED}, unless it is
69
+ * `resendable`: it goes again on the next one, for up to `retryForMs`.
70
+ * - A call that stalls while nothing comes makes it check the connection (`stallMs`), and make another at once
71
+ * when the check goes unanswered.
72
+ */
73
+ export declare class RpcWebSocketClient {
74
+ protected readonly options: RpcWebSocketClientOptions;
75
+ protected socket?: RpcSocket;
76
+ protected closed: boolean;
77
+ protected attempts: number;
78
+ protected reconnectTimer?: ReturnType<typeof setTimeout>;
79
+ protected nextId: number;
80
+ protected readonly pending: Map<number, Pending>;
81
+ protected readonly waiting: Set<{
82
+ go(): void;
83
+ fail(): void;
84
+ }>;
85
+ protected readonly openListeners: Set<() => void>;
86
+ protected readonly closeListeners: Set<() => void>;
87
+ protected readonly reconnectingListeners: Set<(delayMs: number, attempt: number) => void>;
88
+ /** When the last message came, on the clock of Date.now(). */
89
+ protected lastReceivedAt: number;
90
+ protected stallTimer?: ReturnType<typeof setInterval>;
91
+ protected probing: boolean;
92
+ constructor(options: RpcWebSocketClientOptions);
93
+ get connected(): boolean;
94
+ /**
95
+ * Opens a connection unless one is open or opening: resolves once it is open, rejects when it cannot be made.
96
+ * With `reconnect`, losses after the first are made again on their own.
97
+ */
98
+ connect(): Promise<void>;
99
+ /** Closes it for good: what waits for it fails. */
100
+ close(code?: number): void;
101
+ onOpen(listener: () => void): () => void;
102
+ /** Runs each time an open connection is lost. */
103
+ onClose(listener: () => void): () => void;
104
+ /** Runs each time it waits to try again: how long, and which try it is (1 for the first after a loss). */
105
+ onReconnecting(listener: (delayMs: number, attempt: number) => void): () => void;
106
+ /** While the connection is down, tries again now rather than at the end of the wait, which starts over. */
107
+ reconnect(): void;
108
+ /**
109
+ * After the device slept or its network changed, when a connection may be gone without a word: one that is down
110
+ * is tried at once, and an open one that does not answer the probe within `timeoutMs` is given up and made again.
111
+ */
112
+ wake(timeoutMs?: number): void;
113
+ /** `<service>/<method>` as the server names it. */
114
+ call(method: string, params: unknown[]): Promise<JsonRpc.Response>;
115
+ /** Sends a call on the open connection: its answer, or {@link JsonRpc.CONNECTION_CLOSED} when it is lost first. */
116
+ protected send(method: string, params: unknown[]): Promise<JsonRpc.Response>;
117
+ /** With `resolve` and `reject`: a connection asked for, whose failure is the caller's to handle. */
118
+ protected open(resolve?: () => void, reject?: (error: Error) => void): void;
119
+ /**
120
+ * A socket that never opened: the caller who asked for it is told, and decides what next (`connect` again,
121
+ * `reconnect`, `close`); one opened to make a lost connection again is tried again.
122
+ */
123
+ protected unopened(socket: RpcSocket, reject?: (error: Error) => void): void;
124
+ /** The connection on `socket` is gone: the calls sent on it fail, and another is made, `atOnce` or after the wait. */
125
+ protected lost(socket: RpcSocket, opened: boolean, atOnce?: boolean): void;
126
+ protected scheduleReconnect(): void;
127
+ /** The socket opening now, for one who asks to connect meanwhile: open, or given up after `openTimeoutMs` (else 5 s). */
128
+ protected opening(): Promise<void>;
129
+ /** Resolves once the connection is open; rejects with {@link JsonRpc.NOT_CONNECTED} after the wait, or at once when it is closed. */
130
+ protected waitForOpen(waitMs?: number): Promise<void>;
131
+ protected failPending(): void;
132
+ /** While calls wait for answers: one that waits past `stallMs` with nothing come since makes it check the connection. */
133
+ protected watchStalls(): void;
134
+ protected receive(socket: RpcSocket, text: string): void;
135
+ /** What the server asks, answered on the socket it came on, when it has an id. */
136
+ protected answer(socket: RpcSocket, request: JsonRpc.Request): void;
137
+ protected static notConnected(id: JsonRpc.Id | null): JsonRpc.Response;
138
+ }
139
+ export {};
@@ -0,0 +1,404 @@
1
+ import { JsonRpc } from '../protocol/json-rpc.js';
2
+ const OPEN = 1;
3
+ const CONNECTING = 0;
4
+ /**
5
+ * JSON-RPC 2.0 over one WebSocket to a server, for a browser, Electron, a mobile app or a backend, with no other
6
+ * dependency. Calls answer {@link JsonRpc.Response}s; they do not throw.
7
+ *
8
+ * - It makes the connection again after a loss (`reconnect`), after a wait that doubles; `onOpen` runs each time.
9
+ * A first connection that cannot be made rejects `connect`, and is not tried again on its own.
10
+ * - A call made while it is down waits a little for it (`waitForOpenMs`).
11
+ * - A call sent on a connection lost before its answer answers {@link JsonRpc.CONNECTION_CLOSED}, unless it is
12
+ * `resendable`: it goes again on the next one, for up to `retryForMs`.
13
+ * - A call that stalls while nothing comes makes it check the connection (`stallMs`), and make another at once
14
+ * when the check goes unanswered.
15
+ */
16
+ export class RpcWebSocketClient {
17
+ constructor(options) {
18
+ this.options = options;
19
+ this.closed = false;
20
+ this.attempts = 0;
21
+ this.nextId = 0;
22
+ this.pending = new Map();
23
+ this.waiting = new Set();
24
+ this.openListeners = new Set();
25
+ this.closeListeners = new Set();
26
+ this.reconnectingListeners = new Set();
27
+ /** When the last message came, on the clock of Date.now(). */
28
+ this.lastReceivedAt = 0;
29
+ this.probing = false;
30
+ }
31
+ get connected() {
32
+ var _a;
33
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === OPEN;
34
+ }
35
+ /**
36
+ * Opens a connection unless one is open or opening: resolves once it is open, rejects when it cannot be made.
37
+ * With `reconnect`, losses after the first are made again on their own.
38
+ */
39
+ connect() {
40
+ var _a;
41
+ if (this.closed) {
42
+ return Promise.reject(new Error('The connection is closed.'));
43
+ }
44
+ if (this.connected) {
45
+ return Promise.resolve();
46
+ }
47
+ if (((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === CONNECTING) {
48
+ return this.opening();
49
+ }
50
+ return new Promise((resolve, reject) => {
51
+ clearTimeout(this.reconnectTimer);
52
+ this.open(resolve, reject);
53
+ });
54
+ }
55
+ /** Closes it for good: what waits for it fails. */
56
+ close(code = 1000) {
57
+ var _a;
58
+ this.closed = true;
59
+ clearTimeout(this.reconnectTimer);
60
+ clearInterval(this.stallTimer);
61
+ for (const call of [...this.waiting]) {
62
+ call.fail();
63
+ }
64
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close(code);
65
+ this.failPending();
66
+ }
67
+ onOpen(listener) {
68
+ this.openListeners.add(listener);
69
+ return () => this.openListeners.delete(listener);
70
+ }
71
+ /** Runs each time an open connection is lost. */
72
+ onClose(listener) {
73
+ this.closeListeners.add(listener);
74
+ return () => this.closeListeners.delete(listener);
75
+ }
76
+ /** Runs each time it waits to try again: how long, and which try it is (1 for the first after a loss). */
77
+ onReconnecting(listener) {
78
+ this.reconnectingListeners.add(listener);
79
+ return () => this.reconnectingListeners.delete(listener);
80
+ }
81
+ /** While the connection is down, tries again now rather than at the end of the wait, which starts over. */
82
+ reconnect() {
83
+ var _a;
84
+ const state = (_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState;
85
+ if (this.closed || state === OPEN || state === CONNECTING) {
86
+ return;
87
+ }
88
+ clearTimeout(this.reconnectTimer);
89
+ this.attempts = 0;
90
+ this.open();
91
+ }
92
+ /**
93
+ * After the device slept or its network changed, when a connection may be gone without a word: one that is down
94
+ * is tried at once, and an open one that does not answer the probe within `timeoutMs` is given up and made again.
95
+ */
96
+ wake(timeoutMs = 3000) {
97
+ var _a;
98
+ const socket = this.socket;
99
+ if (this.closed || (socket === null || socket === void 0 ? void 0 : socket.readyState) === CONNECTING) {
100
+ return;
101
+ }
102
+ if ((socket === null || socket === void 0 ? void 0 : socket.readyState) !== OPEN) {
103
+ this.reconnect();
104
+ return;
105
+ }
106
+ let answered = false;
107
+ const since = Date.now();
108
+ this.probing = true;
109
+ const timer = setTimeout(() => {
110
+ this.probing = false;
111
+ // Anything that came meanwhile says it is alive, only slow: the answer waits behind it.
112
+ if (!answered && this.socket === socket && this.lastReceivedAt <= since) {
113
+ socket.onclose = null;
114
+ socket.onmessage = null;
115
+ socket.close();
116
+ this.attempts = 0;
117
+ this.lost(socket, true, true);
118
+ }
119
+ }, timeoutMs);
120
+ const { method, params } = (_a = this.options.probe) !== null && _a !== void 0 ? _a : { method: 'rpc.ping', params: [] };
121
+ // Sent once, not again after a loss: it asks about this connection.
122
+ void this.send(method, params).then(response => {
123
+ var _a;
124
+ if (((_a = response.error) === null || _a === void 0 ? void 0 : _a.code) !== JsonRpc.CONNECTION_CLOSED) {
125
+ answered = true;
126
+ this.probing = false;
127
+ clearTimeout(timer);
128
+ }
129
+ });
130
+ }
131
+ /** `<service>/<method>` as the server names it. */
132
+ async call(method, params) {
133
+ var _a, _b, _c;
134
+ var _d;
135
+ const resendable = (_d = (_b = (_a = this.options).resendable) === null || _b === void 0 ? void 0 : _b.call(_a, method, params)) !== null && _d !== void 0 ? _d : false;
136
+ if (!resendable) {
137
+ if (!this.connected) {
138
+ const failed = await this.waitForOpen().then(() => undefined, (response) => response);
139
+ if (failed) {
140
+ return failed;
141
+ }
142
+ }
143
+ return this.send(method, params);
144
+ }
145
+ const { waitForOpenMs = 5000, retryForMs = waitForOpenMs } = this.options;
146
+ const deadline = Date.now() + Math.max(retryForMs, 1);
147
+ for (;;) {
148
+ if (!this.connected) {
149
+ const failed = await this.waitForOpen(Math.max(1, deadline - Date.now())).then(() => undefined, (response) => response);
150
+ if (failed) {
151
+ return failed;
152
+ }
153
+ }
154
+ const response = await this.send(method, params);
155
+ if (((_c = response.error) === null || _c === void 0 ? void 0 : _c.code) !== JsonRpc.CONNECTION_CLOSED || this.closed || Date.now() >= deadline) {
156
+ return response;
157
+ }
158
+ }
159
+ }
160
+ /** Sends a call on the open connection: its answer, or {@link JsonRpc.CONNECTION_CLOSED} when it is lost first. */
161
+ send(method, params) {
162
+ const socket = this.socket;
163
+ const id = ++this.nextId;
164
+ if ((socket === null || socket === void 0 ? void 0 : socket.readyState) !== OPEN) {
165
+ return Promise.resolve(RpcWebSocketClient.notConnected(id));
166
+ }
167
+ // JSON has no undefined: a left-out optional argument must not arrive as null.
168
+ let length = params.length;
169
+ while (length > 0 && params[length - 1] === undefined) {
170
+ length--;
171
+ }
172
+ return new Promise(resolve => {
173
+ const pending = { resolve, sentAt: Date.now() };
174
+ const { callTimeoutMs = 0 } = this.options;
175
+ if (callTimeoutMs > 0) {
176
+ pending.timer = setTimeout(() => {
177
+ this.pending.delete(id);
178
+ resolve(JsonRpc.error(id, JsonRpc.TIMEOUT, `No response to ${method} within ${callTimeoutMs} ms.`));
179
+ }, callTimeoutMs);
180
+ }
181
+ this.pending.set(id, pending);
182
+ this.watchStalls();
183
+ socket.send(JSON.stringify(JsonRpc.request(id, method, params.slice(0, length))));
184
+ });
185
+ }
186
+ /** With `resolve` and `reject`: a connection asked for, whose failure is the caller's to handle. */
187
+ open(resolve, reject) {
188
+ let opened = false;
189
+ const socket = this.options.createSocket();
190
+ this.socket = socket;
191
+ const { openTimeoutMs = 0 } = this.options;
192
+ const timer = openTimeoutMs > 0
193
+ ? setTimeout(() => {
194
+ if (!opened && this.socket === socket) {
195
+ socket.onclose = null;
196
+ socket.close();
197
+ this.unopened(socket, reject);
198
+ }
199
+ }, openTimeoutMs)
200
+ : undefined;
201
+ socket.onopen = () => {
202
+ clearTimeout(timer);
203
+ if (this.socket !== socket) {
204
+ socket.close(1000);
205
+ return;
206
+ }
207
+ opened = true;
208
+ this.attempts = 0;
209
+ resolve === null || resolve === void 0 ? void 0 : resolve();
210
+ for (const call of [...this.waiting]) {
211
+ call.go();
212
+ }
213
+ for (const listener of [...this.openListeners]) {
214
+ listener();
215
+ }
216
+ };
217
+ socket.onmessage = message => this.receive(socket, String(message.data));
218
+ socket.onerror = () => undefined;
219
+ socket.onclose = () => {
220
+ clearTimeout(timer);
221
+ // A socket given up for another (`wake`, `reconnect`) closes late: the one after it is not lost.
222
+ if (this.socket !== socket) {
223
+ return;
224
+ }
225
+ if (!opened) {
226
+ this.unopened(socket, reject);
227
+ return;
228
+ }
229
+ this.lost(socket, true);
230
+ };
231
+ }
232
+ /**
233
+ * A socket that never opened: the caller who asked for it is told, and decides what next (`connect` again,
234
+ * `reconnect`, `close`); one opened to make a lost connection again is tried again.
235
+ */
236
+ unopened(socket, reject) {
237
+ if (reject) {
238
+ this.failPending();
239
+ reject(new Error('Cannot connect.'));
240
+ return;
241
+ }
242
+ this.lost(socket, false);
243
+ }
244
+ /** The connection on `socket` is gone: the calls sent on it fail, and another is made, `atOnce` or after the wait. */
245
+ lost(socket, opened, atOnce = false) {
246
+ this.failPending();
247
+ if (opened) {
248
+ for (const listener of [...this.closeListeners]) {
249
+ listener();
250
+ }
251
+ }
252
+ if (this.socket !== socket || this.closed) {
253
+ return;
254
+ }
255
+ if (this.options.reconnect === false) {
256
+ for (const call of [...this.waiting]) {
257
+ call.fail();
258
+ }
259
+ return;
260
+ }
261
+ if (atOnce) {
262
+ this.open();
263
+ }
264
+ else {
265
+ this.scheduleReconnect();
266
+ }
267
+ }
268
+ scheduleReconnect() {
269
+ if (this.closed) {
270
+ return;
271
+ }
272
+ const { reconnectDelayMs = 250, maxReconnectDelayMs = 10000 } = this.options;
273
+ const delay = Math.min(reconnectDelayMs * 2 ** this.attempts++, maxReconnectDelayMs);
274
+ clearTimeout(this.reconnectTimer);
275
+ this.reconnectTimer = setTimeout(() => this.open(), delay);
276
+ for (const listener of [...this.reconnectingListeners]) {
277
+ listener(delay, this.attempts);
278
+ }
279
+ }
280
+ /** The socket opening now, for one who asks to connect meanwhile: open, or given up after `openTimeoutMs` (else 5 s). */
281
+ opening() {
282
+ return new Promise((resolve, reject) => {
283
+ const call = {
284
+ go: () => {
285
+ clearTimeout(timer);
286
+ this.waiting.delete(call);
287
+ resolve();
288
+ },
289
+ fail: () => {
290
+ clearTimeout(timer);
291
+ this.waiting.delete(call);
292
+ reject(new Error('Cannot connect.'));
293
+ },
294
+ };
295
+ const timer = setTimeout(call.fail, this.options.openTimeoutMs || 5000);
296
+ this.waiting.add(call);
297
+ });
298
+ }
299
+ /** Resolves once the connection is open; rejects with {@link JsonRpc.NOT_CONNECTED} after the wait, or at once when it is closed. */
300
+ waitForOpen(waitMs) {
301
+ const { waitForOpenMs: configured = 5000 } = this.options;
302
+ const wait = configured <= 0 ? 0 : (waitMs !== null && waitMs !== void 0 ? waitMs : configured);
303
+ if (this.closed || wait <= 0) {
304
+ return Promise.reject(RpcWebSocketClient.notConnected(null));
305
+ }
306
+ return new Promise((resolve, reject) => {
307
+ const call = {
308
+ go: () => {
309
+ clearTimeout(timer);
310
+ this.waiting.delete(call);
311
+ resolve();
312
+ },
313
+ fail: () => {
314
+ clearTimeout(timer);
315
+ this.waiting.delete(call);
316
+ reject(RpcWebSocketClient.notConnected(null));
317
+ },
318
+ };
319
+ const timer = setTimeout(call.fail, wait);
320
+ this.waiting.add(call);
321
+ });
322
+ }
323
+ failPending() {
324
+ const pending = [...this.pending];
325
+ this.pending.clear();
326
+ for (const [id, call] of pending) {
327
+ clearTimeout(call.timer);
328
+ call.resolve(JsonRpc.error(id, JsonRpc.CONNECTION_CLOSED, 'The connection was lost before the response arrived; the call may or may not have run.'));
329
+ }
330
+ }
331
+ /** While calls wait for answers: one that waits past `stallMs` with nothing come since makes it check the connection. */
332
+ watchStalls() {
333
+ const { stallMs = 5000 } = this.options;
334
+ if (this.stallTimer !== undefined || stallMs <= 0) {
335
+ return;
336
+ }
337
+ this.stallTimer = setInterval(() => {
338
+ const [oldest] = this.pending.values();
339
+ if (!oldest) {
340
+ clearInterval(this.stallTimer);
341
+ this.stallTimer = undefined;
342
+ return;
343
+ }
344
+ if (!this.probing && Date.now() - Math.max(oldest.sentAt, this.lastReceivedAt) >= stallMs) {
345
+ this.wake(stallMs);
346
+ }
347
+ }, Math.min(1000, stallMs));
348
+ }
349
+ receive(socket, text) {
350
+ this.lastReceivedAt = Date.now();
351
+ let message;
352
+ try {
353
+ message = JSON.parse(text);
354
+ }
355
+ catch (_a) {
356
+ return;
357
+ }
358
+ if (JsonRpc.isRequest(message)) {
359
+ this.answer(socket, message);
360
+ return;
361
+ }
362
+ if (JsonRpc.isResponse(message) && typeof message.id === 'number') {
363
+ const call = this.pending.get(message.id);
364
+ if (call) {
365
+ clearTimeout(call.timer);
366
+ this.pending.delete(message.id);
367
+ call.resolve(message);
368
+ }
369
+ }
370
+ }
371
+ /** What the server asks, answered on the socket it came on, when it has an id. */
372
+ answer(socket, request) {
373
+ var _a;
374
+ const reply = (response) => {
375
+ if (request.id !== undefined && socket === this.socket && socket.readyState === OPEN) {
376
+ socket.send(JSON.stringify(response));
377
+ }
378
+ };
379
+ const id = (_a = request.id) !== null && _a !== void 0 ? _a : null;
380
+ const failed = (error) => reply(JsonRpc.error(id, JsonRpc.SERVER_ERROR, error instanceof Error ? error.message : String(error)));
381
+ if (!this.options.handle) {
382
+ reply(JsonRpc.error(id, JsonRpc.METHOD_NOT_FOUND, `No handler for ${request.method}.`));
383
+ return;
384
+ }
385
+ let response;
386
+ try {
387
+ response = this.options.handle(request);
388
+ }
389
+ catch (error) {
390
+ failed(error);
391
+ return;
392
+ }
393
+ if (response instanceof Promise) {
394
+ response.then(reply, failed);
395
+ }
396
+ else {
397
+ reply(response);
398
+ }
399
+ }
400
+ static notConnected(id) {
401
+ return JsonRpc.error(id, JsonRpc.NOT_CONNECTED, 'Not connected; the call was not sent.');
402
+ }
403
+ }
404
+ //# sourceMappingURL=rpc-websocket-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-websocket-client.js","sourceRoot":"","sources":["../../../src/common/transport/rpc-websocket-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AA2D/C,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAkB;IAgB3B,YAA+B,OAAkC;QAAlC,YAAO,GAAP,OAAO,CAA2B;QAdvD,WAAM,GAAG,KAAK,CAAC;QACf,aAAQ,GAAG,CAAC,CAAC;QAEb,WAAM,GAAG,CAAC,CAAC;QACF,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QACrC,YAAO,GAAG,IAAI,GAAG,EAAgC,CAAC;QAClD,kBAAa,GAAG,IAAI,GAAG,EAAc,CAAC;QACtC,mBAAc,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,0BAAqB,GAAG,IAAI,GAAG,EAA8C,CAAC;QACjG,8DAA8D;QACpD,mBAAc,GAAG,CAAC,CAAC;QAEnB,YAAO,GAAG,KAAK,CAAC;IAE0C,CAAC;IAErE,IAAI,SAAS;;QACT,OAAO,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,MAAK,IAAI,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,OAAO;;QACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,E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