@replit/river 0.207.3 → 0.208.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.
- package/dist/{adapter-f2b6e211.d.ts → adapter-ChksXKVN.d.ts} +2 -2
- package/dist/adapter-Cuc4JtfV.d.cts +46 -0
- package/dist/{chunk-BO7MFCO6.js → chunk-2JNVDUMN.js} +55 -97
- package/dist/chunk-2JNVDUMN.js.map +1 -0
- package/dist/{chunk-B7REV3ZV.js → chunk-DKW3GC3M.js} +2 -2
- package/dist/{chunk-QGPYCXV4.js → chunk-ETZAHFGQ.js} +80 -61
- package/dist/chunk-ETZAHFGQ.js.map +1 -0
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/connection-BF4zg6Qv.d.cts +35 -0
- package/dist/{connection-06d72f2e.d.ts → connection-Donr3JRB.d.ts} +4 -4
- package/dist/index-C9tpZjBN.d.cts +37 -0
- package/dist/{index-02554794.d.ts → index-D8IOd3LG.d.ts} +2 -2
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-01c3e85a.d.ts → message-Di94OL80.d.cts} +1 -1
- package/dist/message-Di94OL80.d.ts +108 -0
- package/dist/router/index.cjs +62 -43
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +27 -8
- package/dist/router/index.d.ts +27 -8
- package/dist/router/index.js +1 -1
- package/dist/testUtil/index.cjs +56 -105
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +5 -5
- package/dist/testUtil/index.d.ts +5 -5
- package/dist/testUtil/index.js +7 -14
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +51 -80
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +6 -6
- package/dist/transport/impls/ws/client.d.ts +6 -6
- package/dist/transport/impls/ws/client.js +3 -3
- package/dist/transport/impls/ws/server.cjs +52 -85
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +6 -6
- package/dist/transport/impls/ws/server.d.ts +6 -6
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +52 -94
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +6 -6
- package/dist/transport/index.d.ts +6 -6
- package/dist/transport/index.js +3 -3
- package/dist/transport-CCaWx1Rb.d.cts +1566 -0
- package/dist/{services-87887bc5.d.ts → transport-CZb3vdB4.d.ts} +344 -347
- package/dist/{wslike-e0b32dd5.d.ts → wslike-Dng9H1C7.d.cts} +1 -1
- package/dist/wslike-Dng9H1C7.d.ts +40 -0
- package/package.json +3 -3
- package/dist/chunk-BO7MFCO6.js.map +0 -1
- package/dist/chunk-QGPYCXV4.js.map +0 -1
- /package/dist/{chunk-B7REV3ZV.js.map → chunk-DKW3GC3M.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OpaqueTransportMessage } from './message-
|
|
1
|
+
import { O as OpaqueTransportMessage } from './message-Di94OL80.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
@@ -43,4 +43,4 @@ declare class CodecMessageAdapter {
|
|
|
43
43
|
fromBuffer(buf: Uint8Array): DeserializeResult;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export { Codec as C, SendResult as S, CodecMessageAdapter as a, SendBufferResult as b };
|
|
46
|
+
export { type Codec as C, type SendResult as S, CodecMessageAdapter as a, type SendBufferResult as b };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { O as OpaqueTransportMessage } from './message-Di94OL80.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
5
|
+
* Used to prepare messages for use by the transport layer.
|
|
6
|
+
*/
|
|
7
|
+
interface Codec {
|
|
8
|
+
/**
|
|
9
|
+
* Encodes an object to a Uint8 buffer.
|
|
10
|
+
* @param obj - The object to encode.
|
|
11
|
+
* @returns The encoded Uint8 buffer.
|
|
12
|
+
*/
|
|
13
|
+
toBuffer(obj: object): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Decodes an object from a Uint8 buffer.
|
|
16
|
+
* @param buf - The Uint8 buffer to decode.
|
|
17
|
+
* @returns The decoded object, or null if decoding failed.
|
|
18
|
+
*/
|
|
19
|
+
fromBuffer(buf: Uint8Array): object;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SessionApiResult<T> = {
|
|
23
|
+
ok: true;
|
|
24
|
+
value: T;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
reason: string;
|
|
28
|
+
};
|
|
29
|
+
type SendResult = SessionApiResult<string>;
|
|
30
|
+
type SendBufferResult = SessionApiResult<undefined>;
|
|
31
|
+
type SerializeResult = SessionApiResult<Uint8Array>;
|
|
32
|
+
type DeserializeResult = SessionApiResult<OpaqueTransportMessage>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Adapts a {@link Codec} to the {@link OpaqueTransportMessage} format,
|
|
36
|
+
* accounting for fallibility of toBuffer and fromBuffer and wrapping
|
|
37
|
+
* it with a Result type.
|
|
38
|
+
*/
|
|
39
|
+
declare class CodecMessageAdapter {
|
|
40
|
+
private readonly codec;
|
|
41
|
+
constructor(codec: Codec);
|
|
42
|
+
toBuffer(msg: OpaqueTransportMessage): SerializeResult;
|
|
43
|
+
fromBuffer(buf: Uint8Array): DeserializeResult;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { type Codec as C, type SendResult as S, CodecMessageAdapter as a, type SendBufferResult as b };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseLogger,
|
|
3
|
+
createLogProxy
|
|
4
|
+
} from "./chunk-CC7RN7GI.js";
|
|
1
5
|
import {
|
|
2
6
|
ControlMessageHandshakeRequestSchema,
|
|
3
7
|
ControlMessageHandshakeResponseSchema,
|
|
@@ -16,11 +20,7 @@ import {
|
|
|
16
20
|
handshakeResponseMessage,
|
|
17
21
|
isAcceptedProtocolVersion,
|
|
18
22
|
isAck
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import {
|
|
21
|
-
BaseLogger,
|
|
22
|
-
createLogProxy
|
|
23
|
-
} from "./chunk-CC7RN7GI.js";
|
|
23
|
+
} from "./chunk-ETZAHFGQ.js";
|
|
24
24
|
|
|
25
25
|
// transport/events.ts
|
|
26
26
|
var ProtocolError = {
|
|
@@ -355,13 +355,11 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
|
|
|
355
355
|
this.listeners = props.listeners;
|
|
356
356
|
this.connPromise.then(
|
|
357
357
|
(conn) => {
|
|
358
|
-
if (this._isConsumed)
|
|
359
|
-
return;
|
|
358
|
+
if (this._isConsumed) return;
|
|
360
359
|
this.listeners.onConnectionEstablished(conn);
|
|
361
360
|
},
|
|
362
361
|
(err) => {
|
|
363
|
-
if (this._isConsumed)
|
|
364
|
-
return;
|
|
362
|
+
if (this._isConsumed) return;
|
|
365
363
|
this.listeners.onConnectionFailed(err);
|
|
366
364
|
}
|
|
367
365
|
);
|
|
@@ -423,9 +421,9 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
423
421
|
this.handshakeTimeout = setTimeout(() => {
|
|
424
422
|
this.listeners.onHandshakeTimeout();
|
|
425
423
|
}, this.options.handshakeTimeoutMs);
|
|
426
|
-
this.conn.
|
|
427
|
-
this.conn.
|
|
428
|
-
this.conn.
|
|
424
|
+
this.conn.setDataListener(this.onHandshakeData);
|
|
425
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
426
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
429
427
|
}
|
|
430
428
|
get loggingMetadata() {
|
|
431
429
|
return {
|
|
@@ -449,9 +447,9 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
449
447
|
return sendMessage(this.conn, this.codec, msg);
|
|
450
448
|
}
|
|
451
449
|
_handleStateExit() {
|
|
452
|
-
this.conn.removeDataListener(
|
|
453
|
-
this.conn.removeErrorListener(
|
|
454
|
-
this.conn.removeCloseListener(
|
|
450
|
+
this.conn.removeDataListener();
|
|
451
|
+
this.conn.removeErrorListener();
|
|
452
|
+
this.conn.removeCloseListener();
|
|
455
453
|
clearTimeout(this.handshakeTimeout);
|
|
456
454
|
this.handshakeTimeout = void 0;
|
|
457
455
|
}
|
|
@@ -473,9 +471,9 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
473
471
|
this.handshakeTimeout = setTimeout(() => {
|
|
474
472
|
this.listeners.onHandshakeTimeout();
|
|
475
473
|
}, this.options.handshakeTimeoutMs);
|
|
476
|
-
this.conn.
|
|
477
|
-
this.conn.
|
|
478
|
-
this.conn.
|
|
474
|
+
this.conn.setDataListener(this.onHandshakeData);
|
|
475
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
476
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
479
477
|
}
|
|
480
478
|
get loggingMetadata() {
|
|
481
479
|
return {
|
|
@@ -499,9 +497,9 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
499
497
|
}
|
|
500
498
|
_handleStateExit() {
|
|
501
499
|
super._handleStateExit();
|
|
502
|
-
this.conn.removeDataListener(
|
|
503
|
-
this.conn.removeErrorListener(
|
|
504
|
-
this.conn.removeCloseListener(
|
|
500
|
+
this.conn.removeDataListener();
|
|
501
|
+
this.conn.removeErrorListener();
|
|
502
|
+
this.conn.removeCloseListener();
|
|
505
503
|
if (this.handshakeTimeout) {
|
|
506
504
|
clearTimeout(this.handshakeTimeout);
|
|
507
505
|
this.handshakeTimeout = void 0;
|
|
@@ -557,9 +555,9 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
557
555
|
super(props);
|
|
558
556
|
this.conn = props.conn;
|
|
559
557
|
this.listeners = props.listeners;
|
|
560
|
-
this.conn.
|
|
561
|
-
this.conn.
|
|
562
|
-
this.conn.
|
|
558
|
+
this.conn.setDataListener(this.onMessageData);
|
|
559
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
560
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
563
561
|
}
|
|
564
562
|
sendBufferedMessages() {
|
|
565
563
|
if (this.sendBuffer.length > 0) {
|
|
@@ -668,9 +666,9 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
668
666
|
};
|
|
669
667
|
_handleStateExit() {
|
|
670
668
|
super._handleStateExit();
|
|
671
|
-
this.conn.removeDataListener(
|
|
672
|
-
this.conn.removeCloseListener(
|
|
673
|
-
this.conn.removeErrorListener(
|
|
669
|
+
this.conn.removeDataListener();
|
|
670
|
+
this.conn.removeCloseListener();
|
|
671
|
+
this.conn.removeErrorListener();
|
|
674
672
|
if (this.heartbeatHandle) {
|
|
675
673
|
clearInterval(this.heartbeatHandle);
|
|
676
674
|
this.heartbeatHandle = void 0;
|
|
@@ -1130,8 +1128,7 @@ var Transport = class {
|
|
|
1130
1128
|
* @param message The received message.
|
|
1131
1129
|
*/
|
|
1132
1130
|
handleMsg(message) {
|
|
1133
|
-
if (this.getStatus() !== "open")
|
|
1134
|
-
return;
|
|
1131
|
+
if (this.getStatus() !== "open") return;
|
|
1135
1132
|
this.eventDispatcher.dispatchEvent("message", message);
|
|
1136
1133
|
}
|
|
1137
1134
|
/**
|
|
@@ -1219,8 +1216,7 @@ var Transport = class {
|
|
|
1219
1216
|
});
|
|
1220
1217
|
}
|
|
1221
1218
|
deleteSession(session, options) {
|
|
1222
|
-
if (session._isConsumed)
|
|
1223
|
-
return;
|
|
1219
|
+
if (session._isConsumed) return;
|
|
1224
1220
|
const loggingMetadata = session.loggingMetadata;
|
|
1225
1221
|
if (loggingMetadata.tags && options?.unhealthy) {
|
|
1226
1222
|
loggingMetadata.tags.push("unhealthy-session");
|
|
@@ -1240,7 +1236,7 @@ var Transport = class {
|
|
|
1240
1236
|
}
|
|
1241
1237
|
// common listeners
|
|
1242
1238
|
onSessionGracePeriodElapsed(session) {
|
|
1243
|
-
this.log?.
|
|
1239
|
+
this.log?.info(
|
|
1244
1240
|
`session to ${session.to} grace period elapsed, closing`,
|
|
1245
1241
|
session.loggingMetadata
|
|
1246
1242
|
);
|
|
@@ -1597,15 +1593,6 @@ var ClientTransport = class extends Transport {
|
|
|
1597
1593
|
});
|
|
1598
1594
|
const res = connectedSession.sendBufferedMessages();
|
|
1599
1595
|
if (!res.ok) {
|
|
1600
|
-
this.log?.error(`failed to send buffered messages: ${res.reason}`, {
|
|
1601
|
-
...connectedSession.loggingMetadata,
|
|
1602
|
-
transportMessage: msg
|
|
1603
|
-
});
|
|
1604
|
-
this.protocolError({
|
|
1605
|
-
type: ProtocolError.MessageSendFailure,
|
|
1606
|
-
message: res.reason
|
|
1607
|
-
});
|
|
1608
|
-
this.deleteSession(connectedSession, { unhealthy: true });
|
|
1609
1596
|
return;
|
|
1610
1597
|
}
|
|
1611
1598
|
this.updateSession(connectedSession);
|
|
@@ -1807,8 +1794,7 @@ var ServerTransport = class extends Transport {
|
|
|
1807
1794
|
super.deleteSession(session, options);
|
|
1808
1795
|
}
|
|
1809
1796
|
handleConnection(conn) {
|
|
1810
|
-
if (this.getStatus() !== "open")
|
|
1811
|
-
return;
|
|
1797
|
+
if (this.getStatus() !== "open") return;
|
|
1812
1798
|
this.log?.info(`new incoming connection`, {
|
|
1813
1799
|
...conn.loggingMetadata,
|
|
1814
1800
|
clientId: this.clientId
|
|
@@ -2152,18 +2138,6 @@ var ServerTransport = class extends Transport {
|
|
|
2152
2138
|
);
|
|
2153
2139
|
const bufferSendRes = connectedSession.sendBufferedMessages();
|
|
2154
2140
|
if (!bufferSendRes.ok) {
|
|
2155
|
-
this.log?.error(
|
|
2156
|
-
`failed to send buffered messages: ${bufferSendRes.reason}`,
|
|
2157
|
-
{
|
|
2158
|
-
...connectedSession.loggingMetadata,
|
|
2159
|
-
transportMessage: msg
|
|
2160
|
-
}
|
|
2161
|
-
);
|
|
2162
|
-
this.protocolError({
|
|
2163
|
-
type: ProtocolError.MessageSendFailure,
|
|
2164
|
-
message: bufferSendRes.reason
|
|
2165
|
-
});
|
|
2166
|
-
this.deleteSession(connectedSession, { unhealthy: true });
|
|
2167
2141
|
return;
|
|
2168
2142
|
}
|
|
2169
2143
|
this.sessionHandshakeMetadata.set(connectedSession.to, parsedMetadata);
|
|
@@ -2194,60 +2168,44 @@ var Connection = class {
|
|
|
2194
2168
|
}
|
|
2195
2169
|
return metadata;
|
|
2196
2170
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
_errorListeners = /* @__PURE__ */ new Set();
|
|
2201
|
-
get dataListeners() {
|
|
2202
|
-
return [...this._dataListeners];
|
|
2203
|
-
}
|
|
2204
|
-
get closeListeners() {
|
|
2205
|
-
return [...this._closeListeners];
|
|
2206
|
-
}
|
|
2207
|
-
get errorListeners() {
|
|
2208
|
-
return [...this._errorListeners];
|
|
2209
|
-
}
|
|
2171
|
+
dataListener;
|
|
2172
|
+
closeListener;
|
|
2173
|
+
errorListener;
|
|
2210
2174
|
onData(msg) {
|
|
2211
|
-
|
|
2212
|
-
cb(msg);
|
|
2213
|
-
}
|
|
2175
|
+
this.dataListener?.(msg);
|
|
2214
2176
|
}
|
|
2215
2177
|
onError(err) {
|
|
2216
|
-
|
|
2217
|
-
cb(err);
|
|
2218
|
-
}
|
|
2178
|
+
this.errorListener?.(err);
|
|
2219
2179
|
}
|
|
2220
2180
|
onClose() {
|
|
2221
|
-
|
|
2222
|
-
cb();
|
|
2223
|
-
}
|
|
2181
|
+
this.closeListener?.();
|
|
2224
2182
|
this.telemetry?.span.end();
|
|
2225
2183
|
}
|
|
2226
2184
|
/**
|
|
2227
|
-
*
|
|
2228
|
-
* @param
|
|
2185
|
+
* Set the callback for when a message is received.
|
|
2186
|
+
* @param cb The message handler callback.
|
|
2229
2187
|
*/
|
|
2230
|
-
|
|
2231
|
-
this.
|
|
2188
|
+
setDataListener(cb) {
|
|
2189
|
+
this.dataListener = cb;
|
|
2232
2190
|
}
|
|
2233
|
-
removeDataListener(
|
|
2234
|
-
this.
|
|
2191
|
+
removeDataListener() {
|
|
2192
|
+
this.dataListener = void 0;
|
|
2235
2193
|
}
|
|
2236
2194
|
/**
|
|
2237
|
-
*
|
|
2238
|
-
* This should also be called if an error happens and after notifying
|
|
2195
|
+
* Set the callback for when the connection is closed.
|
|
2196
|
+
* This should also be called if an error happens and after notifying the error listener.
|
|
2239
2197
|
* @param cb The callback to call when the connection is closed.
|
|
2240
2198
|
*/
|
|
2241
|
-
|
|
2242
|
-
this.
|
|
2199
|
+
setCloseListener(cb) {
|
|
2200
|
+
this.closeListener = cb;
|
|
2243
2201
|
}
|
|
2244
|
-
removeCloseListener(
|
|
2245
|
-
this.
|
|
2202
|
+
removeCloseListener() {
|
|
2203
|
+
this.closeListener = void 0;
|
|
2246
2204
|
}
|
|
2247
2205
|
/**
|
|
2248
|
-
*
|
|
2249
|
-
* This should only be used for
|
|
2250
|
-
* should be delegated to
|
|
2206
|
+
* Set the callback for when an error is received.
|
|
2207
|
+
* This should only be used for logging errors, all cleanup
|
|
2208
|
+
* should be delegated to setCloseListener.
|
|
2251
2209
|
*
|
|
2252
2210
|
* The implementer should take care such that the implemented
|
|
2253
2211
|
* connection will call both the close and error callbacks
|
|
@@ -2255,11 +2213,11 @@ var Connection = class {
|
|
|
2255
2213
|
*
|
|
2256
2214
|
* @param cb The callback to call when an error is received.
|
|
2257
2215
|
*/
|
|
2258
|
-
|
|
2259
|
-
this.
|
|
2216
|
+
setErrorListener(cb) {
|
|
2217
|
+
this.errorListener = cb;
|
|
2260
2218
|
}
|
|
2261
|
-
removeErrorListener(
|
|
2262
|
-
this.
|
|
2219
|
+
removeErrorListener() {
|
|
2220
|
+
this.errorListener = void 0;
|
|
2263
2221
|
}
|
|
2264
2222
|
};
|
|
2265
2223
|
|
|
@@ -2277,4 +2235,4 @@ export {
|
|
|
2277
2235
|
Connection,
|
|
2278
2236
|
CodecMessageAdapter
|
|
2279
2237
|
};
|
|
2280
|
-
//# sourceMappingURL=chunk-
|
|
2238
|
+
//# sourceMappingURL=chunk-2JNVDUMN.js.map
|