@chainflip/rpc 2.0.7 → 2.1.0-beta.1

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 (44) hide show
  1. package/dist/Client.cjs +88 -91
  2. package/dist/Client.d.cts +30 -33
  3. package/dist/Client.d.mts +40 -0
  4. package/dist/Client.mjs +87 -90
  5. package/dist/HttpClient.cjs +33 -32
  6. package/dist/HttpClient.d.cts +5 -10
  7. package/dist/HttpClient.d.mts +9 -0
  8. package/dist/HttpClient.mjs +32 -31
  9. package/dist/WsClient.cjs +119 -124
  10. package/dist/WsClient.d.cts +22 -24
  11. package/dist/WsClient.d.mts +26 -0
  12. package/dist/WsClient.mjs +117 -122
  13. package/dist/_virtual/rolldown_runtime.cjs +19 -0
  14. package/dist/_virtual/rolldown_runtime.mjs +18 -0
  15. package/dist/common.cjs +55 -98
  16. package/dist/common.d.cts +30509 -26329
  17. package/dist/common.d.mts +31128 -0
  18. package/dist/common.mjs +54 -98
  19. package/dist/constants.cjs +16 -7
  20. package/dist/constants.d.cts +11 -1
  21. package/dist/constants.d.mts +11 -0
  22. package/dist/constants.mjs +12 -9
  23. package/dist/index.cjs +12 -10
  24. package/dist/index.d.cts +7 -11
  25. package/dist/index.d.mts +7 -0
  26. package/dist/index.mjs +5 -10
  27. package/dist/parsers.cjs +794 -750
  28. package/dist/parsers.d.cts +36279 -31216
  29. package/dist/parsers.d.mts +37053 -0
  30. package/dist/parsers.mjs +738 -746
  31. package/dist/types.cjs +0 -1
  32. package/dist/types.d.cts +6 -9
  33. package/dist/{types.d.ts → types.d.mts} +6 -9
  34. package/dist/types.mjs +1 -0
  35. package/package.json +6 -6
  36. package/dist/Client.d.ts +0 -43
  37. package/dist/HttpClient.d.ts +0 -13
  38. package/dist/WsClient.d.ts +0 -27
  39. package/dist/common.d.ts +0 -26948
  40. package/dist/constants-jLrn-AnI.d.cts +0 -13
  41. package/dist/constants-jLrn-AnI.d.ts +0 -13
  42. package/dist/constants.d.ts +0 -1
  43. package/dist/index.d.ts +0 -11
  44. package/dist/parsers.d.ts +0 -31990
package/dist/WsClient.cjs CHANGED
@@ -1,126 +1,121 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/WsClient.ts
2
- var _async = require('@chainflip/utils/async');
3
- var _zod = require('zod');
4
- var _Clientcjs = require('./Client.cjs'); var _Clientcjs2 = _interopRequireDefault(_Clientcjs);
5
- var _commoncjs = require('./common.cjs');
6
- var CONNECTING = "CONNECTING";
7
- var READY = "READY";
8
- var DISCONNECT = "DISCONNECT";
9
- var WsClient = (_class = class extends _Clientcjs2.default {
10
-
11
- __init() {this.reconnectAttempts = 0}
12
- __init2() {this.emitter = new EventTarget()}
13
- __init3() {this.inFlightRequestMap = /* @__PURE__ */ new Map()}
14
-
15
- __init4() {this.shouldConnect = true}
16
- constructor(url, { timeout = 3e4, ...opts } = {}) {
17
- super(url, opts);_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);;
18
- this.timeout = timeout;
19
- }
20
- async close() {
21
- this.shouldConnect = false;
22
- if (!this.ws) return;
23
- await this.handleDisconnect();
24
- const waitForClose = this.ws.readyState === WebSocket.OPEN;
25
- this.ws.close();
26
- if (waitForClose) await _async.once.call(void 0, this.ws, "close");
27
- this.ws = void 0;
28
- }
29
- async connectionReady() {
30
- if (!this.ws) {
31
- return this.connect();
32
- }
33
- if (this.ws.readyState !== WebSocket.OPEN) {
34
- await _async.once.call(void 0, this.emitter, READY, { timeout: 3e4 });
35
- }
36
- return this.ws;
37
- }
38
- __init5() {this.handleDisconnect = async () => {
39
- this.emitter.dispatchEvent(new Event(DISCONNECT));
40
- this.inFlightRequestMap.forEach((request) => {
41
- request.reject(new Error("disconnected"));
42
- });
43
- this.inFlightRequestMap.clear();
44
- if (!this.shouldConnect) return;
45
- const backoff = 250 * 2 ** this.reconnectAttempts;
46
- await _async.sleep.call(void 0, backoff);
47
- await this.connect().catch(() => {
48
- this.reconnectAttempts = Math.min(this.reconnectAttempts + 1, 6);
49
- });
50
- }}
51
- __init6() {this.handleMessage = (data) => {
52
- const parsedData = JSON.parse(data.data);
53
- const responses = _zod.z.array(_commoncjs.rpcResponse).safeParse(parsedData);
54
- if (!responses.success) return;
55
- for (const response of responses.data) {
56
- const { id } = response;
57
- _optionalChain([this, 'access', _6 => _6.inFlightRequestMap, 'access', _7 => _7.get, 'call', _8 => _8(id), 'optionalAccess', _9 => _9.resolve, 'call', _10 => _10(response)]);
58
- }
59
- }}
60
- async connect() {
61
- this.shouldConnect = true;
62
- this.emitter.dispatchEvent(new Event(CONNECTING));
63
- const socket = new WebSocket(this.url);
64
- this.ws = socket;
65
- this.ws.addEventListener("message", this.handleMessage);
66
- let connected = false;
67
- const handleConnectionError = () => {
68
- if (!connected) {
69
- void this.handleDisconnect();
70
- }
71
- };
72
- this.ws.addEventListener("close", this.handleDisconnect, { once: true });
73
- this.ws.addEventListener("error", handleConnectionError, { once: true });
74
- await _async.once.call(void 0, this.ws, "open", { timeout: this.timeout });
75
- connected = true;
76
- this.ws.addEventListener("error", () => {
77
- socket.close();
78
- });
79
- this.emitter.dispatchEvent(new Event(READY));
80
- this.ws.removeEventListener("error", handleConnectionError);
81
- this.reconnectAttempts = 0;
82
- return socket;
83
- }
84
- async send(requests, requestMap) {
85
- const MAX_RETRIES = 5;
86
- let socket;
87
- for (let i = 0; i < MAX_RETRIES; i += 1) {
88
- try {
89
- socket = await this.connectionReady();
90
- } catch (e) {
91
- continue;
92
- }
93
- }
94
- if (!socket) {
95
- this.handleErrorResponse(new Error("failed to connect"), requestMap);
96
- return;
97
- }
98
- socket.send(JSON.stringify(requests));
99
- const promises = [];
100
- for (const [id] of requestMap) {
101
- const result = _async.deferredPromise.call(void 0, );
102
- const controller = new AbortController();
103
- this.inFlightRequestMap.set(id, result);
104
- promises.push(
105
- Promise.race([
106
- _async.sleep.call(void 0, this.timeout, { signal: controller.signal }).then(
107
- () => ({ id, success: false, error: new Error("timeout") })
108
- ),
109
- result.promise.then(
110
- (r) => ({ id, success: true, result: r }),
111
- (error) => ({ id, success: false, error })
112
- )
113
- ]).then((response) => {
114
- this.handleResponse(response, requestMap);
115
- }).finally(() => {
116
- this.inFlightRequestMap.delete(id);
117
- controller.abort();
118
- })
119
- );
120
- }
121
- await Promise.all(promises);
122
- }
123
- }, _class);
1
+ const require_parsers = require('./parsers.cjs');
2
+ require('./common.cjs');
3
+ const require_Client = require('./Client.cjs');
4
+ let _chainflip_utils_async = require("@chainflip/utils/async");
5
+ let zod = require("zod");
124
6
 
7
+ //#region src/WsClient.ts
8
+ const CONNECTING = "CONNECTING";
9
+ const READY = "READY";
10
+ const DISCONNECT = "DISCONNECT";
11
+ var WsClient = class extends require_Client {
12
+ ws;
13
+ reconnectAttempts = 0;
14
+ emitter = new EventTarget();
15
+ inFlightRequestMap = /* @__PURE__ */ new Map();
16
+ timeout;
17
+ shouldConnect = true;
18
+ constructor(url, { timeout = 3e4, ...opts } = {}) {
19
+ super(url, opts);
20
+ this.timeout = timeout;
21
+ }
22
+ async close() {
23
+ this.shouldConnect = false;
24
+ if (!this.ws) return;
25
+ await this.handleDisconnect();
26
+ const waitForClose = this.ws.readyState === WebSocket.OPEN;
27
+ this.ws.close();
28
+ if (waitForClose) await (0, _chainflip_utils_async.once)(this.ws, "close");
29
+ this.ws = void 0;
30
+ }
31
+ async connectionReady() {
32
+ if (!this.ws) return this.connect();
33
+ if (this.ws.readyState !== WebSocket.OPEN) await (0, _chainflip_utils_async.once)(this.emitter, READY, { timeout: 3e4 });
34
+ return this.ws;
35
+ }
36
+ handleDisconnect = async () => {
37
+ this.emitter.dispatchEvent(new Event(DISCONNECT));
38
+ this.inFlightRequestMap.forEach((request) => {
39
+ request.reject(/* @__PURE__ */ new Error("disconnected"));
40
+ });
41
+ this.inFlightRequestMap.clear();
42
+ if (!this.shouldConnect) return;
43
+ await (0, _chainflip_utils_async.sleep)(250 * 2 ** this.reconnectAttempts);
44
+ await this.connect().catch(() => {
45
+ this.reconnectAttempts = Math.min(this.reconnectAttempts + 1, 6);
46
+ });
47
+ };
48
+ handleMessage = (data) => {
49
+ const parsedData = JSON.parse(data.data);
50
+ const responses = zod.z.array(require_parsers.rpcResponse).safeParse(parsedData);
51
+ if (!responses.success) return;
52
+ for (const response of responses.data) {
53
+ const { id } = response;
54
+ this.inFlightRequestMap.get(id)?.resolve(response);
55
+ }
56
+ };
57
+ async connect() {
58
+ this.shouldConnect = true;
59
+ this.emitter.dispatchEvent(new Event(CONNECTING));
60
+ const socket = new WebSocket(this.url);
61
+ this.ws = socket;
62
+ this.ws.addEventListener("message", this.handleMessage);
63
+ let connected = false;
64
+ const handleConnectionError = () => {
65
+ if (!connected) this.handleDisconnect();
66
+ };
67
+ this.ws.addEventListener("close", this.handleDisconnect, { once: true });
68
+ this.ws.addEventListener("error", handleConnectionError, { once: true });
69
+ await (0, _chainflip_utils_async.once)(this.ws, "open", { timeout: this.timeout });
70
+ connected = true;
71
+ this.ws.addEventListener("error", () => {
72
+ socket.close();
73
+ });
74
+ this.emitter.dispatchEvent(new Event(READY));
75
+ this.ws.removeEventListener("error", handleConnectionError);
76
+ this.reconnectAttempts = 0;
77
+ return socket;
78
+ }
79
+ async send(requests, requestMap) {
80
+ const MAX_RETRIES = 5;
81
+ let socket;
82
+ for (let i = 0; i < MAX_RETRIES; i += 1) try {
83
+ socket = await this.connectionReady();
84
+ } catch {
85
+ continue;
86
+ }
87
+ if (!socket) {
88
+ this.handleErrorResponse(/* @__PURE__ */ new Error("failed to connect"), requestMap);
89
+ return;
90
+ }
91
+ socket.send(JSON.stringify(requests));
92
+ const promises = [];
93
+ for (const [id] of requestMap) {
94
+ const result = (0, _chainflip_utils_async.deferredPromise)();
95
+ const controller = new AbortController();
96
+ this.inFlightRequestMap.set(id, result);
97
+ promises.push(Promise.race([(0, _chainflip_utils_async.sleep)(this.timeout, { signal: controller.signal }).then(() => ({
98
+ id,
99
+ success: false,
100
+ error: /* @__PURE__ */ new Error("timeout")
101
+ })), result.promise.then((r) => ({
102
+ id,
103
+ success: true,
104
+ result: r
105
+ }), (error) => ({
106
+ id,
107
+ success: false,
108
+ error
109
+ }))]).then((response) => {
110
+ this.handleResponse(response, requestMap);
111
+ }).finally(() => {
112
+ this.inFlightRequestMap.delete(id);
113
+ controller.abort();
114
+ }));
115
+ }
116
+ await Promise.all(promises);
117
+ }
118
+ };
125
119
 
126
- exports.default = WsClient;
120
+ //#endregion
121
+ module.exports = WsClient;
@@ -1,27 +1,25 @@
1
- import Client, { ClientOpts, RequestMap } from './Client.cjs';
2
- import { JsonRpcRequest, RpcMethod } from './common.cjs';
3
- import '@chainflip/utils/async';
4
- import '@chainflip/utils/chainflip';
5
- import '@chainflip/utils/types';
6
- import 'zod';
7
- import './parsers.cjs';
1
+ import { JsonRpcRequest, RpcMethod } from "./common.cjs";
2
+ import Client, { ClientOpts, RequestMap } from "./Client.cjs";
8
3
 
4
+ //#region src/WsClient.d.ts
9
5
  declare class WsClient extends Client {
10
- private ws?;
11
- private reconnectAttempts;
12
- private emitter;
13
- private inFlightRequestMap;
14
- private readonly timeout;
15
- private shouldConnect;
16
- constructor(url: string, { timeout, ...opts }?: {
17
- timeout?: number;
18
- } & ClientOpts);
19
- close(): Promise<void>;
20
- private connectionReady;
21
- private handleDisconnect;
22
- private handleMessage;
23
- private connect;
24
- protected send(requests: JsonRpcRequest<RpcMethod>[], requestMap: RequestMap): Promise<void>;
6
+ private ws?;
7
+ private reconnectAttempts;
8
+ private emitter;
9
+ private inFlightRequestMap;
10
+ private readonly timeout;
11
+ private shouldConnect;
12
+ constructor(url: string, {
13
+ timeout,
14
+ ...opts
15
+ }?: {
16
+ timeout?: number;
17
+ } & ClientOpts);
18
+ close(): Promise<void>;
19
+ private connectionReady;
20
+ private handleDisconnect;
21
+ private handleMessage;
22
+ private connect;
23
+ protected send(requests: JsonRpcRequest<RpcMethod>[], requestMap: RequestMap): Promise<void>;
25
24
  }
26
-
27
- export { WsClient as default };
25
+ export = WsClient;
@@ -0,0 +1,26 @@
1
+ import { JsonRpcRequest, RpcMethod } from "./common.mjs";
2
+ import Client, { ClientOpts, RequestMap } from "./Client.mjs";
3
+
4
+ //#region src/WsClient.d.ts
5
+ declare class WsClient extends Client {
6
+ private ws?;
7
+ private reconnectAttempts;
8
+ private emitter;
9
+ private inFlightRequestMap;
10
+ private readonly timeout;
11
+ private shouldConnect;
12
+ constructor(url: string, {
13
+ timeout,
14
+ ...opts
15
+ }?: {
16
+ timeout?: number;
17
+ } & ClientOpts);
18
+ close(): Promise<void>;
19
+ private connectionReady;
20
+ private handleDisconnect;
21
+ private handleMessage;
22
+ private connect;
23
+ protected send(requests: JsonRpcRequest<RpcMethod>[], requestMap: RequestMap): Promise<void>;
24
+ }
25
+ //#endregion
26
+ export { WsClient as default };
package/dist/WsClient.mjs CHANGED
@@ -1,126 +1,121 @@
1
- // src/WsClient.ts
1
+ import { rpcResponse } from "./parsers.mjs";
2
+ import "./common.mjs";
3
+ import Client from "./Client.mjs";
2
4
  import { deferredPromise, once, sleep } from "@chainflip/utils/async";
3
5
  import { z } from "zod";
4
- import Client from "./Client.mjs";
5
- import { rpcResponse } from "./common.mjs";
6
- var CONNECTING = "CONNECTING";
7
- var READY = "READY";
8
- var DISCONNECT = "DISCONNECT";
6
+
7
+ //#region src/WsClient.ts
8
+ const CONNECTING = "CONNECTING";
9
+ const READY = "READY";
10
+ const DISCONNECT = "DISCONNECT";
9
11
  var WsClient = class extends Client {
10
- ws;
11
- reconnectAttempts = 0;
12
- emitter = new EventTarget();
13
- inFlightRequestMap = /* @__PURE__ */ new Map();
14
- timeout;
15
- shouldConnect = true;
16
- constructor(url, { timeout = 3e4, ...opts } = {}) {
17
- super(url, opts);
18
- this.timeout = timeout;
19
- }
20
- async close() {
21
- this.shouldConnect = false;
22
- if (!this.ws) return;
23
- await this.handleDisconnect();
24
- const waitForClose = this.ws.readyState === WebSocket.OPEN;
25
- this.ws.close();
26
- if (waitForClose) await once(this.ws, "close");
27
- this.ws = void 0;
28
- }
29
- async connectionReady() {
30
- if (!this.ws) {
31
- return this.connect();
32
- }
33
- if (this.ws.readyState !== WebSocket.OPEN) {
34
- await once(this.emitter, READY, { timeout: 3e4 });
35
- }
36
- return this.ws;
37
- }
38
- handleDisconnect = async () => {
39
- this.emitter.dispatchEvent(new Event(DISCONNECT));
40
- this.inFlightRequestMap.forEach((request) => {
41
- request.reject(new Error("disconnected"));
42
- });
43
- this.inFlightRequestMap.clear();
44
- if (!this.shouldConnect) return;
45
- const backoff = 250 * 2 ** this.reconnectAttempts;
46
- await sleep(backoff);
47
- await this.connect().catch(() => {
48
- this.reconnectAttempts = Math.min(this.reconnectAttempts + 1, 6);
49
- });
50
- };
51
- handleMessage = (data) => {
52
- const parsedData = JSON.parse(data.data);
53
- const responses = z.array(rpcResponse).safeParse(parsedData);
54
- if (!responses.success) return;
55
- for (const response of responses.data) {
56
- const { id } = response;
57
- this.inFlightRequestMap.get(id)?.resolve(response);
58
- }
59
- };
60
- async connect() {
61
- this.shouldConnect = true;
62
- this.emitter.dispatchEvent(new Event(CONNECTING));
63
- const socket = new WebSocket(this.url);
64
- this.ws = socket;
65
- this.ws.addEventListener("message", this.handleMessage);
66
- let connected = false;
67
- const handleConnectionError = () => {
68
- if (!connected) {
69
- void this.handleDisconnect();
70
- }
71
- };
72
- this.ws.addEventListener("close", this.handleDisconnect, { once: true });
73
- this.ws.addEventListener("error", handleConnectionError, { once: true });
74
- await once(this.ws, "open", { timeout: this.timeout });
75
- connected = true;
76
- this.ws.addEventListener("error", () => {
77
- socket.close();
78
- });
79
- this.emitter.dispatchEvent(new Event(READY));
80
- this.ws.removeEventListener("error", handleConnectionError);
81
- this.reconnectAttempts = 0;
82
- return socket;
83
- }
84
- async send(requests, requestMap) {
85
- const MAX_RETRIES = 5;
86
- let socket;
87
- for (let i = 0; i < MAX_RETRIES; i += 1) {
88
- try {
89
- socket = await this.connectionReady();
90
- } catch {
91
- continue;
92
- }
93
- }
94
- if (!socket) {
95
- this.handleErrorResponse(new Error("failed to connect"), requestMap);
96
- return;
97
- }
98
- socket.send(JSON.stringify(requests));
99
- const promises = [];
100
- for (const [id] of requestMap) {
101
- const result = deferredPromise();
102
- const controller = new AbortController();
103
- this.inFlightRequestMap.set(id, result);
104
- promises.push(
105
- Promise.race([
106
- sleep(this.timeout, { signal: controller.signal }).then(
107
- () => ({ id, success: false, error: new Error("timeout") })
108
- ),
109
- result.promise.then(
110
- (r) => ({ id, success: true, result: r }),
111
- (error) => ({ id, success: false, error })
112
- )
113
- ]).then((response) => {
114
- this.handleResponse(response, requestMap);
115
- }).finally(() => {
116
- this.inFlightRequestMap.delete(id);
117
- controller.abort();
118
- })
119
- );
120
- }
121
- await Promise.all(promises);
122
- }
123
- };
124
- export {
125
- WsClient as default
12
+ ws;
13
+ reconnectAttempts = 0;
14
+ emitter = new EventTarget();
15
+ inFlightRequestMap = /* @__PURE__ */ new Map();
16
+ timeout;
17
+ shouldConnect = true;
18
+ constructor(url, { timeout = 3e4, ...opts } = {}) {
19
+ super(url, opts);
20
+ this.timeout = timeout;
21
+ }
22
+ async close() {
23
+ this.shouldConnect = false;
24
+ if (!this.ws) return;
25
+ await this.handleDisconnect();
26
+ const waitForClose = this.ws.readyState === WebSocket.OPEN;
27
+ this.ws.close();
28
+ if (waitForClose) await once(this.ws, "close");
29
+ this.ws = void 0;
30
+ }
31
+ async connectionReady() {
32
+ if (!this.ws) return this.connect();
33
+ if (this.ws.readyState !== WebSocket.OPEN) await once(this.emitter, READY, { timeout: 3e4 });
34
+ return this.ws;
35
+ }
36
+ handleDisconnect = async () => {
37
+ this.emitter.dispatchEvent(new Event(DISCONNECT));
38
+ this.inFlightRequestMap.forEach((request) => {
39
+ request.reject(/* @__PURE__ */ new Error("disconnected"));
40
+ });
41
+ this.inFlightRequestMap.clear();
42
+ if (!this.shouldConnect) return;
43
+ await sleep(250 * 2 ** this.reconnectAttempts);
44
+ await this.connect().catch(() => {
45
+ this.reconnectAttempts = Math.min(this.reconnectAttempts + 1, 6);
46
+ });
47
+ };
48
+ handleMessage = (data) => {
49
+ const parsedData = JSON.parse(data.data);
50
+ const responses = z.array(rpcResponse).safeParse(parsedData);
51
+ if (!responses.success) return;
52
+ for (const response of responses.data) {
53
+ const { id } = response;
54
+ this.inFlightRequestMap.get(id)?.resolve(response);
55
+ }
56
+ };
57
+ async connect() {
58
+ this.shouldConnect = true;
59
+ this.emitter.dispatchEvent(new Event(CONNECTING));
60
+ const socket = new WebSocket(this.url);
61
+ this.ws = socket;
62
+ this.ws.addEventListener("message", this.handleMessage);
63
+ let connected = false;
64
+ const handleConnectionError = () => {
65
+ if (!connected) this.handleDisconnect();
66
+ };
67
+ this.ws.addEventListener("close", this.handleDisconnect, { once: true });
68
+ this.ws.addEventListener("error", handleConnectionError, { once: true });
69
+ await once(this.ws, "open", { timeout: this.timeout });
70
+ connected = true;
71
+ this.ws.addEventListener("error", () => {
72
+ socket.close();
73
+ });
74
+ this.emitter.dispatchEvent(new Event(READY));
75
+ this.ws.removeEventListener("error", handleConnectionError);
76
+ this.reconnectAttempts = 0;
77
+ return socket;
78
+ }
79
+ async send(requests, requestMap) {
80
+ const MAX_RETRIES = 5;
81
+ let socket;
82
+ for (let i = 0; i < MAX_RETRIES; i += 1) try {
83
+ socket = await this.connectionReady();
84
+ } catch {
85
+ continue;
86
+ }
87
+ if (!socket) {
88
+ this.handleErrorResponse(/* @__PURE__ */ new Error("failed to connect"), requestMap);
89
+ return;
90
+ }
91
+ socket.send(JSON.stringify(requests));
92
+ const promises = [];
93
+ for (const [id] of requestMap) {
94
+ const result = deferredPromise();
95
+ const controller = new AbortController();
96
+ this.inFlightRequestMap.set(id, result);
97
+ promises.push(Promise.race([sleep(this.timeout, { signal: controller.signal }).then(() => ({
98
+ id,
99
+ success: false,
100
+ error: /* @__PURE__ */ new Error("timeout")
101
+ })), result.promise.then((r) => ({
102
+ id,
103
+ success: true,
104
+ result: r
105
+ }), (error) => ({
106
+ id,
107
+ success: false,
108
+ error
109
+ }))]).then((response) => {
110
+ this.handleResponse(response, requestMap);
111
+ }).finally(() => {
112
+ this.inFlightRequestMap.delete(id);
113
+ controller.abort();
114
+ }));
115
+ }
116
+ await Promise.all(promises);
117
+ }
126
118
  };
119
+
120
+ //#endregion
121
+ export { WsClient as default };
@@ -0,0 +1,19 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+
19
+ exports.__exportAll = __exportAll;
@@ -0,0 +1,18 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll };