@celljs/rpc 4.34.0 → 4.36.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
@@ -1,4 +1,5 @@
1
1
  import { JsonRpc } from '../protocol';
2
+ import { RpcWebSocketClient } from './rpc-websocket-client';
2
3
  import { RpcTransport } from './transport-protocol';
3
4
  export interface WebSocketTransportOptions {
4
5
  /** `ws://` or `wss://` URL of the endpoint (`/<rpc.path>/ws` of the server). */
@@ -16,40 +17,30 @@ export interface WebSocketTransportOptions {
16
17
  /** Milliseconds to wait for a connection to open before using the fallback. Default 5000. */
17
18
  connectTimeout?: number;
18
19
  }
19
- interface Pending {
20
- resolve(response: JsonRpc.Response): void;
21
- timer: ReturnType<typeof setTimeout>;
22
- }
23
20
  /**
24
21
  * JSON-RPC over one WebSocket connection for all services (methods are `<service>/<method>`), which
25
- * the server can call back over (`@RpcClient`). While no connection can be opened (no `WebSocket` in
26
- * this runtime, a server or platform without WebSocket support) calls go to the fallback transport.
27
- * A connection that closes answers its pending calls with {@link JsonRpc.CONNECTION_CLOSED}: they are
28
- * not sent again, since they may have run.
22
+ * the server can call back over (`@RpcClient`): an {@link RpcWebSocketClient}. While no connection can
23
+ * be opened (no `WebSocket` in this runtime, a server or platform without WebSocket support) calls go
24
+ * to the fallback transport. A connection that closes answers its pending calls with
25
+ * {@link JsonRpc.CONNECTION_CLOSED}: they are not sent again, since they may have run.
29
26
  */
30
27
  export declare class WebSocketTransport implements RpcTransport {
31
28
  protected readonly options: WebSocketTransportOptions;
32
29
  static readonly MAX_RECONNECT_DELAY = 30000;
33
- protected socket?: WebSocket;
34
- protected opening?: Promise<WebSocket | undefined>;
35
- protected readonly pending: Map<JsonRpc.Id, Pending>;
36
- protected seq: number;
30
+ protected client?: RpcWebSocketClient;
31
+ protected resolving?: Promise<RpcWebSocketClient>;
37
32
  protected retryAt: number;
38
33
  protected delay: number;
39
- protected reconnectTimer?: ReturnType<typeof setTimeout>;
40
34
  protected closed: boolean;
35
+ protected retryTimer?: ReturnType<typeof setTimeout>;
41
36
  constructor(options: WebSocketTransportOptions);
42
37
  /** Whether calls go over a WebSocket connection now. */
43
38
  get connected(): boolean;
44
39
  call(service: string, method: string, params: unknown[]): Promise<JsonRpc.Response>;
45
40
  /** Opens the connection (calls open it when needed); undefined while none can be made. */
46
- connect(): Promise<WebSocket | undefined>;
41
+ connect(): Promise<RpcWebSocketClient | undefined>;
47
42
  /** Closes the connection for good: later calls use the fallback. */
48
43
  close(): void;
49
- protected open(): Promise<WebSocket | undefined>;
50
- protected scheduleReconnect(): void;
51
- protected failPending(): void;
52
- protected receive(socket: WebSocket, data: unknown): void;
44
+ protected create(): Promise<RpcWebSocketClient>;
53
45
  }
54
- export {};
55
46
  //# sourceMappingURL=websocket-transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"websocket-transport.d.ts","sourceRoot":"","sources":["../../../src/common/transport/websocket-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,WAAW,yBAAyB;IACtC,gFAAgF;IAChF,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACvB,kDAAkD;IAClD,QAAQ,EAAE,YAAY,CAAC;IACvB,oEAAoE;IACpE,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,yGAAyG;IACzG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,UAAU,OAAO;IACb,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1C,KAAK,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CACxC;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAavC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB;IAXjE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,SAAS;IAE5C,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC7B,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,OAAO,2BAAkC;IAC5D,SAAS,CAAC,GAAG,SAAK;IAClB,SAAS,CAAC,OAAO,SAAK;IACtB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,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AAO,CAAC;IACpB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAWvC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB;IATjE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,SAAS;IAE5C,SAAS,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACtC,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAClD,SAAS,CAAC,OAAO,SAAK;IACtB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,MAAM,UAAS;IACzB,SAAS,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAErD,YAA+B,OAAO,EAAE,yBAAyB,EAEhE;IAED,wDAAwD;IACxD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAEK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAMxF;IAED,0FAA0F;IACpF,OAAO,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAyBvD;IAED,oEAAoE;IACpE,KAAK,IAAI,IAAI,CAIZ;IAED,UAAgB,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAoBpD;CACJ"}
@@ -2,19 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebSocketTransport = void 0;
4
4
  const protocol_1 = require("../protocol");
5
+ const rpc_websocket_client_1 = require("./rpc-websocket-client");
5
6
  /**
6
7
  * JSON-RPC over one WebSocket connection for all services (methods are `<service>/<method>`), which
7
- * the server can call back over (`@RpcClient`). While no connection can be opened (no `WebSocket` in
8
- * this runtime, a server or platform without WebSocket support) calls go to the fallback transport.
9
- * A connection that closes answers its pending calls with {@link JsonRpc.CONNECTION_CLOSED}: they are
10
- * not sent again, since they may have run.
8
+ * the server can call back over (`@RpcClient`): an {@link RpcWebSocketClient}. While no connection can
9
+ * be opened (no `WebSocket` in this runtime, a server or platform without WebSocket support) calls go
10
+ * to the fallback transport. A connection that closes answers its pending calls with
11
+ * {@link JsonRpc.CONNECTION_CLOSED}: they are not sent again, since they may have run.
11
12
  */
12
13
  class WebSocketTransport {
13
14
  constructor(options) {
14
15
  var _a;
15
16
  this.options = options;
16
- this.pending = new Map();
17
- this.seq = 0;
18
17
  this.retryAt = 0;
19
18
  this.closed = false;
20
19
  this.delay = (_a = options.reconnectDelay) !== null && _a !== void 0 ? _a : 1000;
@@ -22,141 +21,71 @@ class WebSocketTransport {
22
21
  /** Whether calls go over a WebSocket connection now. */
23
22
  get connected() {
24
23
  var _a;
25
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 1;
24
+ var _b;
25
+ return (_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.connected) !== null && _b !== void 0 ? _b : false;
26
26
  }
27
27
  async call(service, method, params) {
28
- const socket = await this.connect();
29
- if (!socket) {
28
+ const client = await this.connect();
29
+ if (!client) {
30
30
  return this.options.fallback.call(service, method, params);
31
31
  }
32
- const id = ++this.seq;
33
- return new Promise(resolve => {
34
- var _a;
35
- const timeout = (_a = this.options.callTimeout) !== null && _a !== void 0 ? _a : 60000;
36
- const timer = setTimeout(() => {
37
- this.pending.delete(id);
38
- resolve(protocol_1.JsonRpc.error(id, protocol_1.JsonRpc.TIMEOUT, `No response to ${service}.${method} within ${timeout} ms.`));
39
- }, timeout);
40
- this.pending.set(id, { resolve, timer });
41
- socket.send(JSON.stringify(protocol_1.JsonRpc.request(id, `${service}/${method}`, params)));
42
- });
32
+ return client.call(`${service}/${method}`, params);
43
33
  }
44
34
  /** Opens the connection (calls open it when needed); undefined while none can be made. */
45
- connect() {
35
+ async connect() {
36
+ var _a, _b;
46
37
  if (this.closed || typeof WebSocket === 'undefined') {
47
- return Promise.resolve(undefined);
48
- }
49
- if (this.socket && this.socket.readyState === 1) {
50
- return Promise.resolve(this.socket);
38
+ return undefined;
51
39
  }
52
- if (this.opening) {
53
- return this.opening;
40
+ const client = await ((_a = this.resolving) !== null && _a !== void 0 ? _a : (this.resolving = this.create()));
41
+ if (client.connected) {
42
+ return client;
54
43
  }
55
44
  if (Date.now() < this.retryAt) {
56
- return Promise.resolve(undefined);
45
+ return undefined;
46
+ }
47
+ try {
48
+ await client.connect();
49
+ this.delay = (_b = this.options.reconnectDelay) !== null && _b !== void 0 ? _b : 1000;
50
+ return client;
51
+ }
52
+ catch (_c) {
53
+ // No WebSocket endpoint (yet): HTTP for a while, then try again; on its own when the server pushes.
54
+ this.retryAt = Date.now() + this.delay;
55
+ this.delay = Math.min(this.delay * 2, WebSocketTransport.MAX_RECONNECT_DELAY);
56
+ if (this.options.keepAlive) {
57
+ clearTimeout(this.retryTimer);
58
+ this.retryTimer = setTimeout(() => void this.connect(), this.retryAt - Date.now());
59
+ }
60
+ return undefined;
57
61
  }
58
- this.opening = this.open().finally(() => {
59
- this.opening = undefined;
60
- });
61
- return this.opening;
62
62
  }
63
63
  /** Closes the connection for good: later calls use the fallback. */
64
64
  close() {
65
65
  var _a;
66
66
  this.closed = true;
67
- clearTimeout(this.reconnectTimer);
68
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close(1000);
67
+ clearTimeout(this.retryTimer);
68
+ (_a = this.client) === null || _a === void 0 ? void 0 : _a.close();
69
69
  }
70
- async open() {
70
+ async create() {
71
+ var _a, _b, _c;
71
72
  const url = await this.options.url();
72
- return new Promise(resolve => {
73
- var _a;
74
- let opened = false;
75
- let failed = false;
76
- const socket = new WebSocket(url);
77
- // No WebSocket endpoint (yet): HTTP for a while, then try again.
78
- const fail = () => {
79
- clearTimeout(timer);
80
- if (failed) {
81
- return;
82
- }
83
- failed = true;
84
- this.retryAt = Date.now() + this.delay;
85
- this.delay = Math.min(this.delay * 2, WebSocketTransport.MAX_RECONNECT_DELAY);
86
- resolve(undefined);
87
- this.scheduleReconnect();
88
- };
89
- // A server that never answers the upgrade (Bun < 1.4 behind node:http) must not hold the calls;
90
- // nor a client whose close() of a connecting socket does not fire close (the WebSocket of Node.js 22).
91
- const timer = setTimeout(() => {
92
- socket.close();
93
- fail();
94
- }, (_a = this.options.connectTimeout) !== null && _a !== void 0 ? _a : 5000);
95
- socket.onopen = () => {
96
- var _a;
97
- if (failed) {
98
- socket.close(1000);
99
- return;
100
- }
101
- clearTimeout(timer);
102
- opened = true;
103
- this.socket = socket;
104
- this.delay = (_a = this.options.reconnectDelay) !== null && _a !== void 0 ? _a : 1000;
105
- resolve(socket);
106
- };
107
- socket.onmessage = event => this.receive(socket, event.data);
108
- socket.onerror = () => undefined;
109
- socket.onclose = () => {
110
- if (!opened) {
111
- fail();
112
- return;
113
- }
114
- this.socket = undefined;
115
- this.failPending();
116
- this.scheduleReconnect();
117
- };
73
+ this.client = new rpc_websocket_client_1.RpcWebSocketClient({
74
+ createSocket: () => new WebSocket(url),
75
+ reconnect: !!this.options.keepAlive,
76
+ reconnectDelayMs: (_a = this.options.reconnectDelay) !== null && _a !== void 0 ? _a : 1000,
77
+ maxReconnectDelayMs: WebSocketTransport.MAX_RECONNECT_DELAY,
78
+ // A server that never answers the upgrade (Bun < 1.4 behind node:http) must not hold the calls.
79
+ openTimeoutMs: (_b = this.options.connectTimeout) !== null && _b !== void 0 ? _b : 5000,
80
+ waitForOpenMs: 0,
81
+ stallMs: 0,
82
+ callTimeoutMs: (_c = this.options.callTimeout) !== null && _c !== void 0 ? _c : 60000,
83
+ handle: request => { var _a, _b; var _c, _d; return (_c = (_b = (_a = this.options).handle) === null || _b === void 0 ? void 0 : _b.call(_a, request)) !== null && _c !== void 0 ? _c : Promise.resolve(protocol_1.JsonRpc.error((_d = request.id) !== null && _d !== void 0 ? _d : null, protocol_1.JsonRpc.METHOD_NOT_FOUND, `No @RpcClient for ${request.method}.`)); },
118
84
  });
119
- }
120
- scheduleReconnect() {
121
- if (!this.options.keepAlive || this.closed) {
122
- return;
123
- }
124
- clearTimeout(this.reconnectTimer);
125
- this.reconnectTimer = setTimeout(() => void this.connect(), Math.max(this.retryAt - Date.now(), this.delay));
126
- }
127
- failPending() {
128
- for (const [id, pending] of this.pending) {
129
- clearTimeout(pending.timer);
130
- pending.resolve(protocol_1.JsonRpc.error(id, protocol_1.JsonRpc.CONNECTION_CLOSED, 'The WebSocket connection closed before the response arrived; the call may or may not have run.'));
131
- }
132
- this.pending.clear();
133
- }
134
- receive(socket, data) {
135
- var _a;
136
- let message;
137
- try {
138
- message = JSON.parse(String(data));
139
- }
140
- catch (_b) {
141
- return;
142
- }
143
- if (protocol_1.JsonRpc.isResponse(message)) {
144
- const pending = message.id === null ? undefined : this.pending.get(message.id);
145
- if (pending) {
146
- clearTimeout(pending.timer);
147
- this.pending.delete(message.id);
148
- pending.resolve(message);
149
- }
150
- }
151
- else if (protocol_1.JsonRpc.isRequest(message)) {
152
- const request = message;
153
- const handle = (_a = this.options.handle) !== null && _a !== void 0 ? _a : (async (r) => { var _a; return protocol_1.JsonRpc.error((_a = r.id) !== null && _a !== void 0 ? _a : null, protocol_1.JsonRpc.METHOD_NOT_FOUND, `No @RpcClient for ${r.method}.`); });
154
- void handle(request).then(response => {
155
- if (request.id !== undefined && socket.readyState === 1) {
156
- socket.send(JSON.stringify(response));
157
- }
158
- });
85
+ if (this.closed) {
86
+ this.client.close();
159
87
  }
88
+ return this.client;
160
89
  }
161
90
  }
162
91
  exports.WebSocketTransport = WebSocketTransport;
@@ -1 +1 @@
1
- {"version":3,"file":"websocket-transport.js","sourceRoot":"","sources":["../../../src/common/transport/websocket-transport.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AAyBtC;;;;;;GAMG;AACH;IAaI,YA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AQ,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ;;AAzJmB,sCAAmB,GAAG,KAAK,AAAR,CAAS"}
1
+ {"version":3,"file":"websocket-transport.js","sourceRoot":"","sources":["../../../src/common/transport/websocket-transport.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,iEAA4D;AAoB5D;;;;;;GAMG;AACH;IAWI,YAA+B,OAAkC;;QAAlC,YAAO,GAAP,OAAO,CAA2B;QALvD,YAAO,GAAG,CAAC,CAAC;QAEZ,WAAM,GAAG,KAAK,CAAC;QAIrB,IAAI,CAAC,KAAK,SAAG,OAAO,CAAC,cAAc,mCAAI,IAAI,CAAC;IAChD,CAAC;IAED,wDAAwD;IACxD,IAAI,SAAS;;;QACT,aAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,mCAAI,KAAK,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAe,EAAE,MAAc,EAAE,MAAiB;QACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,0FAA0F;IAC1F,KAAK,CAAC,OAAO;;QACT,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;YAClD,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,OAAC,IAAI,CAAC,SAAS,oCAAd,IAAI,CAAC,SAAS,GAAK,IAAI,CAAC,MAAM,EAAE,EAAC,CAAC;QACxD,IAAI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AAC;YACjC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC;YACtC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS;YACnC,gBAAgB,QAAE,IAAI,CAAC,OAAO,CAAC,cAAc,mCAAI,IAAI;YACrD,mBAAmB,EAAE,kBAAkB,CAAC,mBAAmB;YAC3D,gGAAgG;YAChG,aAAa,QAAE,IAAI,CAAC,OAAO,CAAC,cAAc,mCAAI,IAAI;YAClD,aAAa,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;YACV,aAAa,QAAE,IAAI,CAAC,OAAO,CAAC,WAAW,mCAAI,KAAK;YAChD,MAAM,EAAE,OAAO,CAAC,EAAE,wCACd,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,MAAM,mDAAG,OAAO,CAAC,mCAC9B,OAAO,CAAC,OAAO,CAAC,kBAAO,CAAC,KAAK,OAAC,OAAO,CAAC,EAAE,mCAAI,IAAI,EAAE,kBAAO,CAAC,gBAAgB,EAAE,qBAAqB,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAA;SAC3H,CAAC,CAAC;QACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;;AAlFmB,sCAAmB,GAAG,KAAK,AAAR,CAAS"}
@@ -2,4 +2,5 @@ export * from './connection-protocol';
2
2
  export * from './rpc-context';
3
3
  export * from './rpc-connection-manager';
4
4
  export * from './rpc-connection';
5
+ export * from './rpc-push-channel';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/connection/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AAAA,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/connection/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
@@ -18,4 +18,5 @@ __exportStar(require("./connection-protocol"), exports);
18
18
  __exportStar(require("./rpc-context"), exports);
19
19
  __exportStar(require("./rpc-connection-manager"), exports);
20
20
  __exportStar(require("./rpc-connection"), exports);
21
+ __exportStar(require("./rpc-push-channel"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,2DAAyC;AAAA,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,gDAA8B;AAC9B,2DAAyC;AACzC,mDAAiC;AACjC,qDAAmC"}
@@ -0,0 +1,44 @@
1
+ export interface RpcPushChannelOptions<T> {
2
+ /** Sends a batch to the client; the next waits until it settles (the client answered, or the call failed). */
3
+ send(batch: T[]): Promise<unknown>;
4
+ /** Whether the connection is closed: nothing is sent then. */
5
+ closed(): boolean;
6
+ /** Called once a client falls more than `maxBacklogBytes` behind; its queue is dropped. */
7
+ overflow(): void;
8
+ /** Bytes a client may fall behind. */
9
+ maxBacklogBytes: number;
10
+ /** Items of this kind leave at most once per `intervalMs`, the first of a while at once; others leave at once. */
11
+ streamed?(item: T): boolean;
12
+ /** Default 30. */
13
+ intervalMs?: number;
14
+ }
15
+ /**
16
+ * What the server pushes to one client (`@RpcClient`), one call at a time: the next batch leaves when the client has
17
+ * answered the last, so that a slow client costs a bounded queue (`maxBacklogBytes`, then `overflow`) and nothing
18
+ * while nothing flows. Items that come by the hundred (`streamed`: the deltas of a reply) leave at most once an
19
+ * interval, the first of them at once; any other leaves at once, with what is queued, so that nothing a user waits
20
+ * for is held back. Items of the same turn of the event loop leave together.
21
+ */
22
+ export declare class RpcPushChannel<T> {
23
+ protected readonly options: RpcPushChannelOptions<T>;
24
+ protected queue: T[];
25
+ protected queuedBytes: number;
26
+ protected timer?: ReturnType<typeof setTimeout>;
27
+ protected sending: boolean;
28
+ protected lastFlushAt: number;
29
+ /** When the timer fires, on the clock of `performance.now()`. */
30
+ protected dueAt: number;
31
+ /** The queue holds an item that should not wait. */
32
+ protected urgent: boolean;
33
+ /** The queue holds a streamed item. */
34
+ protected streamed: boolean;
35
+ constructor(options: RpcPushChannelOptions<T>);
36
+ /** Queues an item of `bytes` (its size as sent, about). */
37
+ push(item: T, bytes: number): void;
38
+ /** Drops what is queued. */
39
+ clear(): void;
40
+ /** A timer, not a direct send: the items of the same turn of the event loop leave together. */
41
+ protected schedule(): void;
42
+ protected flush(): void;
43
+ }
44
+ //# sourceMappingURL=rpc-push-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-push-channel.d.ts","sourceRoot":"","sources":["../../../src/node/connection/rpc-push-channel.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACpC,8GAA8G;IAC9G,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,8DAA8D;IAC9D,MAAM,IAAI,OAAO,CAAC;IAClB,2FAA2F;IAC3F,QAAQ,IAAI,IAAI,CAAC;IACjB,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,kHAAkH;IAClH,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IAC5B,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,qBAAa,cAAc,CAAC,CAAC;IAab,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAZhE,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAM;IAC1B,SAAS,CAAC,WAAW,SAAK;IAC1B,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAChD,SAAS,CAAC,OAAO,UAAS;IAC1B,SAAS,CAAC,WAAW,SAA4B;IACjD,iEAAiE;IACjE,SAAS,CAAC,KAAK,SAAK;IACpB,oDAAoD;IACpD,SAAS,CAAC,MAAM,UAAS;IACzB,uCAAuC;IACvC,SAAS,CAAC,QAAQ,UAAS;IAE3B,YAA+B,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAI;IAEpE,2DAA2D;IAC3D,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAYjC;IAED,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAOZ;IAED,+FAA+F;IAC/F,SAAS,CAAC,QAAQ,IAAI,IAAI,CAQzB;IAED,SAAS,CAAC,KAAK,IAAI,IAAI,CAuBtB;CACJ"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RpcPushChannel = void 0;
4
+ /**
5
+ * What the server pushes to one client (`@RpcClient`), one call at a time: the next batch leaves when the client has
6
+ * answered the last, so that a slow client costs a bounded queue (`maxBacklogBytes`, then `overflow`) and nothing
7
+ * while nothing flows. Items that come by the hundred (`streamed`: the deltas of a reply) leave at most once an
8
+ * interval, the first of them at once; any other leaves at once, with what is queued, so that nothing a user waits
9
+ * for is held back. Items of the same turn of the event loop leave together.
10
+ */
11
+ class RpcPushChannel {
12
+ constructor(options) {
13
+ this.options = options;
14
+ this.queue = [];
15
+ this.queuedBytes = 0;
16
+ this.sending = false;
17
+ this.lastFlushAt = Number.NEGATIVE_INFINITY;
18
+ /** When the timer fires, on the clock of `performance.now()`. */
19
+ this.dueAt = 0;
20
+ /** The queue holds an item that should not wait. */
21
+ this.urgent = false;
22
+ /** The queue holds a streamed item. */
23
+ this.streamed = false;
24
+ }
25
+ /** Queues an item of `bytes` (its size as sent, about). */
26
+ push(item, bytes) {
27
+ var _a, _b;
28
+ var _c;
29
+ this.queue.push(item);
30
+ this.queuedBytes += bytes;
31
+ if (this.queuedBytes > this.options.maxBacklogBytes) {
32
+ this.clear();
33
+ this.options.overflow();
34
+ return;
35
+ }
36
+ const streamed = (_c = (_b = (_a = this.options).streamed) === null || _b === void 0 ? void 0 : _b.call(_a, item)) !== null && _c !== void 0 ? _c : false;
37
+ this.streamed || (this.streamed = streamed);
38
+ this.urgent || (this.urgent = !streamed);
39
+ this.schedule();
40
+ }
41
+ /** Drops what is queued. */
42
+ clear() {
43
+ clearTimeout(this.timer);
44
+ this.timer = undefined;
45
+ this.queue = [];
46
+ this.queuedBytes = 0;
47
+ this.urgent = false;
48
+ this.streamed = false;
49
+ }
50
+ /** A timer, not a direct send: the items of the same turn of the event loop leave together. */
51
+ schedule() {
52
+ var _a;
53
+ const due = this.urgent ? 0 : this.lastFlushAt + ((_a = this.options.intervalMs) !== null && _a !== void 0 ? _a : 30);
54
+ if (this.timer !== undefined && this.dueAt <= due) {
55
+ return;
56
+ }
57
+ clearTimeout(this.timer);
58
+ this.dueAt = due;
59
+ this.timer = setTimeout(() => this.flush(), Math.max(0, due - performance.now()));
60
+ }
61
+ flush() {
62
+ this.timer = undefined;
63
+ if (this.sending || !this.queue.length || this.options.closed()) {
64
+ return;
65
+ }
66
+ const batch = this.queue;
67
+ this.queue = [];
68
+ this.queuedBytes = 0;
69
+ if (this.streamed) {
70
+ this.lastFlushAt = performance.now();
71
+ }
72
+ this.urgent = false;
73
+ this.streamed = false;
74
+ this.sending = true;
75
+ this.options
76
+ .send(batch)
77
+ .catch(() => undefined)
78
+ .finally(() => {
79
+ this.sending = false;
80
+ if (this.queue.length) {
81
+ this.schedule();
82
+ }
83
+ });
84
+ }
85
+ }
86
+ exports.RpcPushChannel = RpcPushChannel;
87
+ //# sourceMappingURL=rpc-push-channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-push-channel.js","sourceRoot":"","sources":["../../../src/node/connection/rpc-push-channel.ts"],"names":[],"mappings":";;;AAeA;;;;;;GAMG;AACH;IAaI,YAA+B,OAAiC;QAAjC,YAAO,GAAP,OAAO,CAA0B;QAZtD,UAAK,GAAQ,EAAE,CAAC;QAChB,gBAAW,GAAG,CAAC,CAAC;QAEhB,YAAO,GAAG,KAAK,CAAC;QAChB,gBAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACjD,iEAAiE;QACvD,UAAK,GAAG,CAAC,CAAC;QACpB,oDAAoD;QAC1C,WAAM,GAAG,KAAK,CAAC;QACzB,uCAAuC;QAC7B,aAAQ,GAAG,KAAK,CAAC;IAEwC,CAAC;IAEpE,2DAA2D;IAC3D,IAAI,CAAC,IAAO,EAAE,KAAa;;;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC;QAC1B,IAAI,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAClD,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,SAAG,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,QAAQ,mDAAG,IAAI,CAAC,mCAAI,KAAK,CAAC;QACxD,IAAI,CAAC,QAAQ,KAAb,IAAI,CAAC,QAAQ,GAAK,QAAQ,EAAC;QAC3B,IAAI,CAAC,MAAM,KAAX,IAAI,CAAC,MAAM,GAAK,CAAC,QAAQ,EAAC;QAC1B,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB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rB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO;aACP,IAAI,CAAC,KAAK,CAAC;aACX,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;aACtB,OAAO,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rpc-push-channel.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-push-channel.spec.d.ts","sourceRoot":"","sources":["../../../src/node/connection/rpc-push-channel.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bun_test_1 = require("bun:test");
4
+ const rpc_push_channel_1 = require("./rpc-push-channel");
5
+ function setup(maxBacklogBytes = 1000) {
6
+ const batches = [];
7
+ const answers = [];
8
+ const state = { closed: false, overflowed: 0 };
9
+ const channel = new rpc_push_channel_1.RpcPushChannel({
10
+ maxBacklogBytes,
11
+ streamed: item => item.startsWith('delta'),
12
+ send: batch => {
13
+ batches.push(batch);
14
+ return new Promise(done => answers.push(done));
15
+ },
16
+ closed: () => state.closed,
17
+ overflow: () => state.overflowed++,
18
+ });
19
+ return { channel, batches, answers, state };
20
+ }
21
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
22
+ (0, bun_test_1.describe)('RpcPushChannel', () => {
23
+ (0, bun_test_1.it)('sends what comes in one turn together, and the next batch once the client answered', async () => {
24
+ const { channel, batches, answers } = setup();
25
+ channel.push('a', 1);
26
+ channel.push('b', 1);
27
+ await sleep(5);
28
+ channel.push('c', 1);
29
+ await sleep(5);
30
+ (0, bun_test_1.expect)(batches).toEqual([['a', 'b']]);
31
+ answers[0]();
32
+ await sleep(5);
33
+ (0, bun_test_1.expect)(batches).toEqual([['a', 'b'], ['c']]);
34
+ });
35
+ (0, bun_test_1.it)('holds streamed items for the interval after the first, and sends any other at once with them', async () => {
36
+ const { channel, batches, answers } = setup();
37
+ channel.push('delta 1', 1);
38
+ await sleep(5);
39
+ answers[0]();
40
+ channel.push('delta 2', 1);
41
+ await sleep(5);
42
+ (0, bun_test_1.expect)(batches).toEqual([['delta 1']]);
43
+ channel.push('end', 1);
44
+ await sleep(5);
45
+ (0, bun_test_1.expect)(batches).toEqual([['delta 1'], ['delta 2', 'end']]);
46
+ });
47
+ (0, bun_test_1.it)('drops the queue and tells once a client falls too far behind, and sends nothing once closed', async () => {
48
+ const { channel, batches, state } = setup(2);
49
+ channel.push('a', 1);
50
+ channel.push('b', 1);
51
+ channel.push('c', 1);
52
+ (0, bun_test_1.expect)(state.overflowed).toBe(1);
53
+ channel.push('d', 1);
54
+ state.closed = true;
55
+ await sleep(5);
56
+ (0, bun_test_1.expect)(batches).toEqual([]);
57
+ });
58
+ });
59
+ //# sourceMappingURL=rpc-push-channel.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-push-channel.spec.js","sourceRoot":"","sources":["../../../src/node/connection/rpc-push-channel.spec.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,yDAAoD;AAEpD,SAAS,KAAK,CAAC,eAAe,GAAG,IAAI;IACjC,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,KAAK,EA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,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,IAAA,iBAAM,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;QACf,IAAA,iBAAM,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export * from './websocket-frames';
2
2
  export * from './websocket-connection';
3
3
  export * from './websocket-exchange';
4
+ export * from './websocket-upgrades';
4
5
  export * from './rpc-websocket-server';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/websocket/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/websocket/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./websocket-frames"), exports);
18
18
  __exportStar(require("./websocket-connection"), exports);
19
19
  __exportStar(require("./websocket-exchange"), exports);
20
+ __exportStar(require("./websocket-upgrades"), exports);
20
21
  __exportStar(require("./rpc-websocket-server"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/websocket/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,yDAAuC;AACvC,uDAAqC;AACrC,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/websocket/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,yDAAuC;AACvC,uDAAqC;AACrC,uDAAqC;AACrC,yDAAuC"}
@@ -32,10 +32,9 @@ export declare class RpcWebSocketServer implements ServerAware, ApplicationLifec
32
32
  protected readonly connections: RpcConnectionManager;
33
33
  protected readonly guards: RpcWebSocketGuard[];
34
34
  protected readonly logger: Logger;
35
- protected server?: Server;
36
35
  protected path: string;
37
36
  protected base: string;
38
- protected listener?: (request: IncomingMessage, socket: Duplex, head: Buffer) => void;
37
+ protected unroute?: () => void;
39
38
  setServer(server: Server): Promise<void>;
40
39
  onStop(): void;
41
40
  protected upgrade(request: IncomingMessage, socket: Duplex, head: Buffer): void;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-websocket-server.d.ts","sourceRoot":"","sources":["../../../src/node/websocket/rpc-websocket-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAwB,MAAM,EAAmB,MAAM,cAAc,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,OAAO,EAA+C,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtG,OAAO,EAAsB,o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