@replit/river 0.10.6 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-SCULZ4KS.js → chunk-3JGVFWKQ.js} +1 -1
- package/dist/{chunk-XWRKNZSC.js → chunk-3MQETIGZ.js} +1 -1
- package/dist/{chunk-KRYKORQT.js → chunk-L7D75G4K.js} +1 -1
- package/dist/{chunk-MF3Z3IDF.js → chunk-LQXPKF3A.js} +4 -4
- package/dist/{chunk-LRQGTUTI.js → chunk-PJ2EUO7O.js} +3 -3
- package/dist/{chunk-SLUSVGQH.js → chunk-T7M7OKPE.js} +3 -0
- package/dist/{chunk-5735JCTZ.js → chunk-WKVQ64U6.js} +23 -7
- package/dist/logging/index.cjs +3 -0
- package/dist/logging/index.d.cts +1 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +1 -1
- package/dist/router/index.js +2 -2
- package/dist/transport/impls/stdio/stdio.cjs +3 -3
- package/dist/transport/impls/stdio/stdio.js +3 -3
- package/dist/transport/impls/unixsocket/client.cjs +3 -3
- package/dist/transport/impls/unixsocket/client.js +3 -3
- package/dist/transport/impls/unixsocket/server.cjs +3 -3
- package/dist/transport/impls/unixsocket/server.js +3 -3
- package/dist/transport/impls/ws/client.cjs +23 -7
- package/dist/transport/impls/ws/client.d.cts +2 -0
- package/dist/transport/impls/ws/client.d.ts +2 -0
- package/dist/transport/impls/ws/client.js +4 -4
- package/dist/transport/impls/ws/server.cjs +3 -3
- package/dist/transport/impls/ws/server.js +4 -4
- package/dist/transport/index.cjs +3 -3
- package/dist/transport/index.js +2 -2
- package/dist/util/testHelpers.cjs +23 -7
- package/dist/util/testHelpers.js +6 -6
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ZE4MX7DF.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-T7M7OKPE.js";
|
|
10
10
|
|
|
11
11
|
// transport/transport.ts
|
|
12
12
|
import { Value } from "@sinclair/typebox/value";
|
|
@@ -178,12 +178,12 @@ var Transport = class {
|
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
180
|
if (isAck(msg.controlFlags) && Value.Check(TransportAckSchema, msg)) {
|
|
181
|
-
log?.
|
|
181
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
182
182
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
183
183
|
this.sendBuffer.delete(msg.payload.ack);
|
|
184
184
|
}
|
|
185
185
|
} else {
|
|
186
|
-
log?.
|
|
186
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
187
187
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
188
188
|
if (!isAck(msg.controlFlags)) {
|
|
189
189
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -233,7 +233,7 @@ var Transport = class {
|
|
|
233
233
|
this.sendBuffer.set(msg.id, msg);
|
|
234
234
|
}
|
|
235
235
|
if (conn) {
|
|
236
|
-
log?.
|
|
236
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
237
237
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
238
238
|
if (ok) {
|
|
239
239
|
return msg.id;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L7D75G4K.js";
|
|
4
4
|
import {
|
|
5
5
|
NaiveJsonCodec
|
|
6
6
|
} from "./chunk-R6H2BIMC.js";
|
|
7
7
|
import {
|
|
8
8
|
Transport
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LQXPKF3A.js";
|
|
10
10
|
import {
|
|
11
11
|
log
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-T7M7OKPE.js";
|
|
13
13
|
|
|
14
14
|
// transport/impls/ws/server.ts
|
|
15
15
|
var defaultOptions = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// logging/index.ts
|
|
2
2
|
var LoggingLevels = {
|
|
3
|
+
debug: -1,
|
|
3
4
|
info: 0,
|
|
4
5
|
warn: 1,
|
|
5
6
|
error: 2
|
|
@@ -7,10 +8,12 @@ var LoggingLevels = {
|
|
|
7
8
|
var log;
|
|
8
9
|
var defaultLoggingLevel = "warn";
|
|
9
10
|
function bindLogger(write, color) {
|
|
11
|
+
const debug = color ? "\x1B[37mdebug\x1B[0m" : "debug";
|
|
10
12
|
const info = color ? "\x1B[37minfo\x1B[0m" : "info";
|
|
11
13
|
const warn = color ? "\x1B[33mwarn\x1B[0m" : "warn";
|
|
12
14
|
const error = color ? "\x1B[31merr\x1B[0m" : "err";
|
|
13
15
|
log = {
|
|
16
|
+
debug: (msg) => log && LoggingLevels[log.minLevel] <= -1 && write(`[river:${debug}] ${msg}`),
|
|
14
17
|
info: (msg) => log && LoggingLevels[log.minLevel] <= 0 && write(`[river:${info}] ${msg}`),
|
|
15
18
|
warn: (msg) => log && LoggingLevels[log.minLevel] <= 1 && write(`[river:${warn}] ${msg}`),
|
|
16
19
|
error: (msg) => log && LoggingLevels[log.minLevel] <= 2 && write(`[river:${error}] ${msg}`),
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L7D75G4K.js";
|
|
4
4
|
import {
|
|
5
5
|
NaiveJsonCodec
|
|
6
6
|
} from "./chunk-R6H2BIMC.js";
|
|
7
7
|
import {
|
|
8
8
|
Transport
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LQXPKF3A.js";
|
|
10
10
|
import {
|
|
11
11
|
log
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-T7M7OKPE.js";
|
|
13
13
|
|
|
14
14
|
// transport/impls/ws/client.ts
|
|
15
15
|
var defaultOptions = {
|
|
@@ -57,19 +57,27 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
57
57
|
log?.info(`${this.clientId} -- establishing a new websocket to ${to}`);
|
|
58
58
|
const ws = await this.wsGetter(to);
|
|
59
59
|
if (ws.readyState === ws.OPEN) {
|
|
60
|
+
if (this.state !== "open")
|
|
61
|
+
return resolve({ err: "transport is closed" });
|
|
60
62
|
return resolve({ ws });
|
|
61
63
|
}
|
|
62
64
|
if (ws.readyState === ws.CLOSING || ws.readyState === ws.CLOSED) {
|
|
63
65
|
return resolve({ err: "ws is closing or closed" });
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
const onOpen = () => {
|
|
66
68
|
ws.removeEventListener("open", onOpen);
|
|
69
|
+
if (this.state !== "open")
|
|
70
|
+
return resolve({ err: "transport is closed" });
|
|
67
71
|
resolve({ ws });
|
|
68
|
-
}
|
|
69
|
-
|
|
72
|
+
};
|
|
73
|
+
const onClose = (evt) => {
|
|
70
74
|
ws.removeEventListener("close", onClose);
|
|
75
|
+
if (this.state !== "open")
|
|
76
|
+
return resolve({ err: "transport is closed" });
|
|
71
77
|
resolve({ err: evt.reason });
|
|
72
|
-
}
|
|
78
|
+
};
|
|
79
|
+
ws.addEventListener("open", onOpen);
|
|
80
|
+
ws.addEventListener("close", onClose);
|
|
73
81
|
});
|
|
74
82
|
this.reconnectPromises.set(to, reconnectPromise);
|
|
75
83
|
}
|
|
@@ -103,6 +111,14 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
103
111
|
);
|
|
104
112
|
}
|
|
105
113
|
}
|
|
114
|
+
async close() {
|
|
115
|
+
super.close();
|
|
116
|
+
this.reconnectPromises.clear();
|
|
117
|
+
}
|
|
118
|
+
async destroy() {
|
|
119
|
+
super.destroy();
|
|
120
|
+
this.reconnectPromises.clear();
|
|
121
|
+
}
|
|
106
122
|
};
|
|
107
123
|
|
|
108
124
|
export {
|
package/dist/logging/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(logging_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(logging_exports);
|
|
28
28
|
var LoggingLevels = {
|
|
29
|
+
debug: -1,
|
|
29
30
|
info: 0,
|
|
30
31
|
warn: 1,
|
|
31
32
|
error: 2
|
|
@@ -33,10 +34,12 @@ var LoggingLevels = {
|
|
|
33
34
|
var log;
|
|
34
35
|
var defaultLoggingLevel = "warn";
|
|
35
36
|
function bindLogger(write, color) {
|
|
37
|
+
const debug = color ? "\x1B[37mdebug\x1B[0m" : "debug";
|
|
36
38
|
const info = color ? "\x1B[37minfo\x1B[0m" : "info";
|
|
37
39
|
const warn = color ? "\x1B[33mwarn\x1B[0m" : "warn";
|
|
38
40
|
const error = color ? "\x1B[31merr\x1B[0m" : "err";
|
|
39
41
|
log = {
|
|
42
|
+
debug: (msg) => log && LoggingLevels[log.minLevel] <= -1 && write(`[river:${debug}] ${msg}`),
|
|
40
43
|
info: (msg) => log && LoggingLevels[log.minLevel] <= 0 && write(`[river:${info}] ${msg}`),
|
|
41
44
|
warn: (msg) => log && LoggingLevels[log.minLevel] <= 1 && write(`[river:${warn}] ${msg}`),
|
|
42
45
|
error: (msg) => log && LoggingLevels[log.minLevel] <= 2 && write(`[river:${error}] ${msg}`),
|
package/dist/logging/index.d.cts
CHANGED
package/dist/logging/index.d.ts
CHANGED
package/dist/logging/index.js
CHANGED
package/dist/router/index.js
CHANGED
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
createClient,
|
|
9
9
|
createServer,
|
|
10
10
|
serializeService
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-3JGVFWKQ.js";
|
|
12
12
|
import "../chunk-ZE4MX7DF.js";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-T7M7OKPE.js";
|
|
14
14
|
export {
|
|
15
15
|
Err,
|
|
16
16
|
Ok,
|
|
@@ -335,12 +335,12 @@ var Transport = class {
|
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
if (isAck(msg.controlFlags) && import_value.Value.Check(TransportAckSchema, msg)) {
|
|
338
|
-
log?.
|
|
338
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
339
339
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
340
340
|
this.sendBuffer.delete(msg.payload.ack);
|
|
341
341
|
}
|
|
342
342
|
} else {
|
|
343
|
-
log?.
|
|
343
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
344
344
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
345
345
|
if (!isAck(msg.controlFlags)) {
|
|
346
346
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -390,7 +390,7 @@ var Transport = class {
|
|
|
390
390
|
this.sendBuffer.set(msg.id, msg);
|
|
391
391
|
}
|
|
392
392
|
if (conn) {
|
|
393
|
-
log?.
|
|
393
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
394
394
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
395
395
|
if (ok) {
|
|
396
396
|
return msg.id;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StreamConnection,
|
|
3
3
|
createDelimitedStream
|
|
4
|
-
} from "../../../chunk-
|
|
4
|
+
} from "../../../chunk-3MQETIGZ.js";
|
|
5
5
|
import "../../../chunk-ORAG7IAU.js";
|
|
6
6
|
import {
|
|
7
7
|
NaiveJsonCodec
|
|
8
8
|
} from "../../../chunk-R6H2BIMC.js";
|
|
9
9
|
import {
|
|
10
10
|
Transport
|
|
11
|
-
} from "../../../chunk-
|
|
11
|
+
} from "../../../chunk-LQXPKF3A.js";
|
|
12
12
|
import "../../../chunk-ZE4MX7DF.js";
|
|
13
13
|
import {
|
|
14
14
|
log
|
|
15
|
-
} from "../../../chunk-
|
|
15
|
+
} from "../../../chunk-T7M7OKPE.js";
|
|
16
16
|
|
|
17
17
|
// transport/impls/stdio/stdio.ts
|
|
18
18
|
var defaultOptions = {
|
|
@@ -235,12 +235,12 @@ var Transport = class {
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
if (isAck(msg.controlFlags) && import_value.Value.Check(TransportAckSchema, msg)) {
|
|
238
|
-
log?.
|
|
238
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
239
239
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
240
240
|
this.sendBuffer.delete(msg.payload.ack);
|
|
241
241
|
}
|
|
242
242
|
} else {
|
|
243
|
-
log?.
|
|
243
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
244
244
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
245
245
|
if (!isAck(msg.controlFlags)) {
|
|
246
246
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -290,7 +290,7 @@ var Transport = class {
|
|
|
290
290
|
this.sendBuffer.set(msg.id, msg);
|
|
291
291
|
}
|
|
292
292
|
if (conn) {
|
|
293
|
-
log?.
|
|
293
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
294
294
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
295
295
|
if (ok) {
|
|
296
296
|
return msg.id;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StreamConnection,
|
|
3
3
|
createDelimitedStream
|
|
4
|
-
} from "../../../chunk-
|
|
4
|
+
} from "../../../chunk-3MQETIGZ.js";
|
|
5
5
|
import "../../../chunk-ORAG7IAU.js";
|
|
6
6
|
import "../../../chunk-WVT5QXMZ.js";
|
|
7
7
|
import {
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "../../../chunk-R6H2BIMC.js";
|
|
10
10
|
import {
|
|
11
11
|
Transport
|
|
12
|
-
} from "../../../chunk-
|
|
12
|
+
} from "../../../chunk-LQXPKF3A.js";
|
|
13
13
|
import "../../../chunk-ZE4MX7DF.js";
|
|
14
14
|
import {
|
|
15
15
|
log
|
|
16
|
-
} from "../../../chunk-
|
|
16
|
+
} from "../../../chunk-T7M7OKPE.js";
|
|
17
17
|
|
|
18
18
|
// transport/impls/unixsocket/client.ts
|
|
19
19
|
import { createConnection } from "node:net";
|
|
@@ -235,12 +235,12 @@ var Transport = class {
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
if (isAck(msg.controlFlags) && import_value.Value.Check(TransportAckSchema, msg)) {
|
|
238
|
-
log?.
|
|
238
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
239
239
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
240
240
|
this.sendBuffer.delete(msg.payload.ack);
|
|
241
241
|
}
|
|
242
242
|
} else {
|
|
243
|
-
log?.
|
|
243
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
244
244
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
245
245
|
if (!isAck(msg.controlFlags)) {
|
|
246
246
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -290,7 +290,7 @@ var Transport = class {
|
|
|
290
290
|
this.sendBuffer.set(msg.id, msg);
|
|
291
291
|
}
|
|
292
292
|
if (conn) {
|
|
293
|
-
log?.
|
|
293
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
294
294
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
295
295
|
if (ok) {
|
|
296
296
|
return msg.id;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StreamConnection,
|
|
3
3
|
createDelimitedStream
|
|
4
|
-
} from "../../../chunk-
|
|
4
|
+
} from "../../../chunk-3MQETIGZ.js";
|
|
5
5
|
import "../../../chunk-ORAG7IAU.js";
|
|
6
6
|
import "../../../chunk-WVT5QXMZ.js";
|
|
7
7
|
import {
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "../../../chunk-R6H2BIMC.js";
|
|
10
10
|
import {
|
|
11
11
|
Transport
|
|
12
|
-
} from "../../../chunk-
|
|
12
|
+
} from "../../../chunk-LQXPKF3A.js";
|
|
13
13
|
import "../../../chunk-ZE4MX7DF.js";
|
|
14
14
|
import {
|
|
15
15
|
log
|
|
16
|
-
} from "../../../chunk-
|
|
16
|
+
} from "../../../chunk-T7M7OKPE.js";
|
|
17
17
|
|
|
18
18
|
// transport/impls/unixsocket/server.ts
|
|
19
19
|
var defaultOptions = {
|
|
@@ -235,12 +235,12 @@ var Transport = class {
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
if (isAck(msg.controlFlags) && import_value.Value.Check(TransportAckSchema, msg)) {
|
|
238
|
-
log?.
|
|
238
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
239
239
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
240
240
|
this.sendBuffer.delete(msg.payload.ack);
|
|
241
241
|
}
|
|
242
242
|
} else {
|
|
243
|
-
log?.
|
|
243
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
244
244
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
245
245
|
if (!isAck(msg.controlFlags)) {
|
|
246
246
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -290,7 +290,7 @@ var Transport = class {
|
|
|
290
290
|
this.sendBuffer.set(msg.id, msg);
|
|
291
291
|
}
|
|
292
292
|
if (conn) {
|
|
293
|
-
log?.
|
|
293
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
294
294
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
295
295
|
if (ok) {
|
|
296
296
|
return msg.id;
|
|
@@ -447,19 +447,27 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
447
447
|
log?.info(`${this.clientId} -- establishing a new websocket to ${to}`);
|
|
448
448
|
const ws = await this.wsGetter(to);
|
|
449
449
|
if (ws.readyState === ws.OPEN) {
|
|
450
|
+
if (this.state !== "open")
|
|
451
|
+
return resolve({ err: "transport is closed" });
|
|
450
452
|
return resolve({ ws });
|
|
451
453
|
}
|
|
452
454
|
if (ws.readyState === ws.CLOSING || ws.readyState === ws.CLOSED) {
|
|
453
455
|
return resolve({ err: "ws is closing or closed" });
|
|
454
456
|
}
|
|
455
|
-
|
|
457
|
+
const onOpen = () => {
|
|
456
458
|
ws.removeEventListener("open", onOpen);
|
|
459
|
+
if (this.state !== "open")
|
|
460
|
+
return resolve({ err: "transport is closed" });
|
|
457
461
|
resolve({ ws });
|
|
458
|
-
}
|
|
459
|
-
|
|
462
|
+
};
|
|
463
|
+
const onClose = (evt) => {
|
|
460
464
|
ws.removeEventListener("close", onClose);
|
|
465
|
+
if (this.state !== "open")
|
|
466
|
+
return resolve({ err: "transport is closed" });
|
|
461
467
|
resolve({ err: evt.reason });
|
|
462
|
-
}
|
|
468
|
+
};
|
|
469
|
+
ws.addEventListener("open", onOpen);
|
|
470
|
+
ws.addEventListener("close", onClose);
|
|
463
471
|
});
|
|
464
472
|
this.reconnectPromises.set(to, reconnectPromise);
|
|
465
473
|
}
|
|
@@ -493,6 +501,14 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
493
501
|
);
|
|
494
502
|
}
|
|
495
503
|
}
|
|
504
|
+
async close() {
|
|
505
|
+
super.close();
|
|
506
|
+
this.reconnectPromises.clear();
|
|
507
|
+
}
|
|
508
|
+
async destroy() {
|
|
509
|
+
super.destroy();
|
|
510
|
+
this.reconnectPromises.clear();
|
|
511
|
+
}
|
|
496
512
|
};
|
|
497
513
|
// Annotate the CommonJS export names for ESM import in node:
|
|
498
514
|
0 && (module.exports = {
|
|
@@ -36,6 +36,8 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
|
|
38
38
|
createNewConnection(to: string, attempt?: number): Promise<void>;
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
destroy(): Promise<void>;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export { WebSocketClientTransport };
|
|
@@ -36,6 +36,8 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
|
|
38
38
|
createNewConnection(to: string, attempt?: number): Promise<void>;
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
destroy(): Promise<void>;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export { WebSocketClientTransport };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketClientTransport
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-WKVQ64U6.js";
|
|
4
|
+
import "../../../chunk-L7D75G4K.js";
|
|
5
5
|
import "../../../chunk-R6H2BIMC.js";
|
|
6
|
-
import "../../../chunk-
|
|
6
|
+
import "../../../chunk-LQXPKF3A.js";
|
|
7
7
|
import "../../../chunk-ZE4MX7DF.js";
|
|
8
|
-
import "../../../chunk-
|
|
8
|
+
import "../../../chunk-T7M7OKPE.js";
|
|
9
9
|
export {
|
|
10
10
|
WebSocketClientTransport
|
|
11
11
|
};
|
|
@@ -281,12 +281,12 @@ var Transport = class {
|
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
if (isAck(msg.controlFlags) && import_value.Value.Check(TransportAckSchema, msg)) {
|
|
284
|
-
log?.
|
|
284
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg)}`);
|
|
285
285
|
if (this.sendBuffer.has(msg.payload.ack)) {
|
|
286
286
|
this.sendBuffer.delete(msg.payload.ack);
|
|
287
287
|
}
|
|
288
288
|
} else {
|
|
289
|
-
log?.
|
|
289
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
|
|
290
290
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
291
291
|
if (!isAck(msg.controlFlags)) {
|
|
292
292
|
const ackMsg = reply(msg, { ack: msg.id });
|
|
@@ -336,7 +336,7 @@ var Transport = class {
|
|
|
336
336
|
this.sendBuffer.set(msg.id, msg);
|
|
337
337
|
}
|
|
338
338
|
if (conn) {
|
|
339
|
-
log?.
|
|
339
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg)}`);
|
|
340
340
|
const ok = conn.send(this.codec.toBuffer(msg));
|
|
341
341
|
if (ok) {
|
|
342
342
|
return msg.id;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketServerTransport
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-PJ2EUO7O.js";
|
|
4
|
+
import "../../../chunk-L7D75G4K.js";
|
|
5
5
|
import "../../../chunk-WVT5QXMZ.js";
|
|
6
6
|
import "../../../chunk-R6H2BIMC.js";
|
|
7
|
-
import "../../../chunk-
|
|
7
|
+
import "../../../chunk-LQXPKF3A.js";
|
|
8
8
|
import "../../../chunk-ZE4MX7DF.js";
|
|
9
|
-
import "../../../chunk-
|
|
9
|
+
import "../../../chunk-T7M7OKPE.js";
|
|
10
10
|
export {
|
|
11
11
|
WebSocketServerTransport
|
|
12
12
|
};
|
package/dist/transport/index.cjs
CHANGED
|
@@ -252,12 +252,12 @@ var Transport = class {
|
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
254
|
if (isAck(msg2.controlFlags) && import_value.Value.Check(TransportAckSchema, msg2)) {
|
|
255
|
-
log?.
|
|
255
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg2)}`);
|
|
256
256
|
if (this.sendBuffer.has(msg2.payload.ack)) {
|
|
257
257
|
this.sendBuffer.delete(msg2.payload.ack);
|
|
258
258
|
}
|
|
259
259
|
} else {
|
|
260
|
-
log?.
|
|
260
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg2)}`);
|
|
261
261
|
this.eventDispatcher.dispatchEvent("message", msg2);
|
|
262
262
|
if (!isAck(msg2.controlFlags)) {
|
|
263
263
|
const ackMsg = reply(msg2, { ack: msg2.id });
|
|
@@ -307,7 +307,7 @@ var Transport = class {
|
|
|
307
307
|
this.sendBuffer.set(msg2.id, msg2);
|
|
308
308
|
}
|
|
309
309
|
if (conn) {
|
|
310
|
-
log?.
|
|
310
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg2)}`);
|
|
311
311
|
const ok = conn.send(this.codec.toBuffer(msg2));
|
|
312
312
|
if (ok) {
|
|
313
313
|
return msg2.id;
|
package/dist/transport/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import "../chunk-ORAG7IAU.js";
|
|
|
2
2
|
import {
|
|
3
3
|
Connection,
|
|
4
4
|
Transport
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-LQXPKF3A.js";
|
|
6
6
|
import {
|
|
7
7
|
OpaqueTransportMessageSchema,
|
|
8
8
|
TransportMessageSchema,
|
|
9
9
|
msg,
|
|
10
10
|
reply
|
|
11
11
|
} from "../chunk-ZE4MX7DF.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-T7M7OKPE.js";
|
|
13
13
|
export {
|
|
14
14
|
Connection,
|
|
15
15
|
OpaqueTransportMessageSchema,
|
|
@@ -272,12 +272,12 @@ var Transport = class {
|
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
274
|
if (isAck(msg2.controlFlags) && import_value.Value.Check(TransportAckSchema, msg2)) {
|
|
275
|
-
log?.
|
|
275
|
+
log?.debug(`${this.clientId} -- received ack: ${JSON.stringify(msg2)}`);
|
|
276
276
|
if (this.sendBuffer.has(msg2.payload.ack)) {
|
|
277
277
|
this.sendBuffer.delete(msg2.payload.ack);
|
|
278
278
|
}
|
|
279
279
|
} else {
|
|
280
|
-
log?.
|
|
280
|
+
log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg2)}`);
|
|
281
281
|
this.eventDispatcher.dispatchEvent("message", msg2);
|
|
282
282
|
if (!isAck(msg2.controlFlags)) {
|
|
283
283
|
const ackMsg = reply(msg2, { ack: msg2.id });
|
|
@@ -327,7 +327,7 @@ var Transport = class {
|
|
|
327
327
|
this.sendBuffer.set(msg2.id, msg2);
|
|
328
328
|
}
|
|
329
329
|
if (conn) {
|
|
330
|
-
log?.
|
|
330
|
+
log?.debug(`${this.clientId} -- sending ${JSON.stringify(msg2)}`);
|
|
331
331
|
const ok = conn.send(this.codec.toBuffer(msg2));
|
|
332
332
|
if (ok) {
|
|
333
333
|
return msg2.id;
|
|
@@ -484,19 +484,27 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
484
484
|
log?.info(`${this.clientId} -- establishing a new websocket to ${to}`);
|
|
485
485
|
const ws = await this.wsGetter(to);
|
|
486
486
|
if (ws.readyState === ws.OPEN) {
|
|
487
|
+
if (this.state !== "open")
|
|
488
|
+
return resolve({ err: "transport is closed" });
|
|
487
489
|
return resolve({ ws });
|
|
488
490
|
}
|
|
489
491
|
if (ws.readyState === ws.CLOSING || ws.readyState === ws.CLOSED) {
|
|
490
492
|
return resolve({ err: "ws is closing or closed" });
|
|
491
493
|
}
|
|
492
|
-
|
|
494
|
+
const onOpen = () => {
|
|
493
495
|
ws.removeEventListener("open", onOpen);
|
|
496
|
+
if (this.state !== "open")
|
|
497
|
+
return resolve({ err: "transport is closed" });
|
|
494
498
|
resolve({ ws });
|
|
495
|
-
}
|
|
496
|
-
|
|
499
|
+
};
|
|
500
|
+
const onClose = (evt) => {
|
|
497
501
|
ws.removeEventListener("close", onClose);
|
|
502
|
+
if (this.state !== "open")
|
|
503
|
+
return resolve({ err: "transport is closed" });
|
|
498
504
|
resolve({ err: evt.reason });
|
|
499
|
-
}
|
|
505
|
+
};
|
|
506
|
+
ws.addEventListener("open", onOpen);
|
|
507
|
+
ws.addEventListener("close", onClose);
|
|
500
508
|
});
|
|
501
509
|
this.reconnectPromises.set(to, reconnectPromise);
|
|
502
510
|
}
|
|
@@ -530,6 +538,14 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
530
538
|
);
|
|
531
539
|
}
|
|
532
540
|
}
|
|
541
|
+
async close() {
|
|
542
|
+
super.close();
|
|
543
|
+
this.reconnectPromises.clear();
|
|
544
|
+
}
|
|
545
|
+
async destroy() {
|
|
546
|
+
super.destroy();
|
|
547
|
+
this.reconnectPromises.clear();
|
|
548
|
+
}
|
|
533
549
|
};
|
|
534
550
|
|
|
535
551
|
// node_modules/p-defer/index.js
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-3JGVFWKQ.js";
|
|
5
5
|
import {
|
|
6
6
|
WebSocketClientTransport
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-WKVQ64U6.js";
|
|
8
8
|
import {
|
|
9
9
|
WebSocketServerTransport
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-PJ2EUO7O.js";
|
|
11
|
+
import "../chunk-L7D75G4K.js";
|
|
12
12
|
import "../chunk-ORAG7IAU.js";
|
|
13
13
|
import "../chunk-WVT5QXMZ.js";
|
|
14
14
|
import "../chunk-R6H2BIMC.js";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-LQXPKF3A.js";
|
|
16
16
|
import {
|
|
17
17
|
msg
|
|
18
18
|
} from "../chunk-ZE4MX7DF.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-T7M7OKPE.js";
|
|
20
20
|
|
|
21
21
|
// util/testHelpers.ts
|
|
22
22
|
import WebSocket from "isomorphic-ws";
|
package/package.json
CHANGED