@replit/river 0.11.0 → 0.12.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.
- package/README.md +28 -8
- package/dist/{builder-1f26296b.d.ts → builder-c593de11.d.ts} +14 -13
- package/dist/{chunk-3JGVFWKQ.js → chunk-55XUAPC6.js} +205 -180
- package/dist/{chunk-R6H2BIMC.js → chunk-GZ7HCLLM.js} +31 -7
- package/dist/{chunk-T7M7OKPE.js → chunk-H4BYJELI.js} +5 -1
- package/dist/{chunk-GKPT5YQE.js → chunk-IIBVKYDB.js} +6 -34
- package/dist/chunk-M6LY25P2.js +47 -0
- package/dist/chunk-QEYN2Z6O.js +726 -0
- package/dist/chunk-RDTTKCGV.js +40 -0
- package/dist/chunk-TKINU53F.js +44 -0
- package/dist/chunk-XFFS4UOD.js +127 -0
- package/dist/codec/index.cjs +13 -7
- package/dist/codec/index.js +2 -4
- package/dist/connection-bf7811aa.d.ts +17 -0
- package/dist/connection-d880aa4a.d.ts +18 -0
- package/dist/connection-eb10d250.d.ts +15 -0
- package/dist/index-0c0a69f6.d.ts +440 -0
- package/dist/logging/index.cjs +8 -3
- package/dist/logging/index.d.cts +6 -1
- package/dist/logging/index.d.ts +6 -1
- package/dist/logging/index.js +5 -3
- package/dist/messageFraming-b200ef25.d.ts +20 -0
- package/dist/router/index.cjs +250 -211
- package/dist/router/index.d.cts +6 -7
- package/dist/router/index.d.ts +6 -7
- package/dist/router/index.js +3 -3
- package/dist/transport/impls/stdio/client.cjs +909 -0
- package/dist/transport/impls/stdio/client.d.cts +27 -0
- package/dist/transport/impls/stdio/client.d.ts +27 -0
- package/dist/transport/impls/stdio/client.js +42 -0
- package/dist/transport/impls/stdio/server.cjs +883 -0
- package/dist/transport/impls/stdio/server.d.cts +25 -0
- package/dist/transport/impls/stdio/server.d.ts +25 -0
- package/dist/transport/impls/stdio/server.js +33 -0
- package/dist/transport/impls/uds/client.cjs +911 -0
- package/dist/transport/impls/uds/client.d.cts +16 -0
- package/dist/transport/impls/uds/client.d.ts +16 -0
- package/dist/transport/impls/uds/client.js +44 -0
- package/dist/transport/impls/uds/server.cjs +885 -0
- package/dist/transport/impls/uds/server.d.cts +16 -0
- package/dist/transport/impls/uds/server.d.ts +16 -0
- package/dist/transport/impls/uds/server.js +39 -0
- package/dist/transport/impls/ws/client.cjs +612 -249
- package/dist/transport/impls/ws/client.d.cts +6 -21
- package/dist/transport/impls/ws/client.d.ts +6 -21
- package/dist/transport/impls/ws/client.js +83 -7
- package/dist/transport/impls/ws/server.cjs +565 -196
- package/dist/transport/impls/ws/server.d.cts +6 -10
- package/dist/transport/impls/ws/server.d.ts +6 -10
- package/dist/transport/impls/ws/server.js +31 -8
- package/dist/transport/index.cjs +673 -130
- package/dist/transport/index.d.cts +3 -276
- package/dist/transport/index.d.ts +3 -276
- package/dist/transport/index.js +13 -10
- package/dist/util/testHelpers.cjs +40 -602
- package/dist/util/testHelpers.d.cts +18 -37
- package/dist/util/testHelpers.d.ts +18 -37
- package/dist/util/testHelpers.js +27 -47
- package/package.json +29 -14
- package/dist/chunk-5IC5XMWK.js +0 -140
- package/dist/chunk-L7D75G4K.js +0 -29
- package/dist/chunk-LQXPKF3A.js +0 -282
- package/dist/chunk-PJ2EUO7O.js +0 -63
- package/dist/chunk-WVT5QXMZ.js +0 -20
- package/dist/chunk-ZE4MX7DF.js +0 -75
- package/dist/connection-2529fc14.d.ts +0 -10
- package/dist/connection-316d6e3a.d.ts +0 -10
- package/dist/connection-8e19874c.d.ts +0 -11
- package/dist/connection-f7688cc1.d.ts +0 -11
- package/dist/transport/impls/stdio/stdio.cjs +0 -518
- package/dist/transport/impls/stdio/stdio.d.cts +0 -26
- package/dist/transport/impls/stdio/stdio.d.ts +0 -26
- package/dist/transport/impls/stdio/stdio.js +0 -70
- package/dist/transport/impls/unixsocket/client.cjs +0 -516
- package/dist/transport/impls/unixsocket/client.d.cts +0 -16
- package/dist/transport/impls/unixsocket/client.d.ts +0 -16
- package/dist/transport/impls/unixsocket/client.js +0 -67
- package/dist/transport/impls/unixsocket/server.cjs +0 -520
- package/dist/transport/impls/unixsocket/server.d.cts +0 -18
- package/dist/transport/impls/unixsocket/server.d.ts +0 -18
- package/dist/transport/impls/unixsocket/server.js +0 -73
- /package/dist/{chunk-ORAG7IAU.js → chunk-5IZ2UHWV.js} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Connection
|
|
3
|
+
} from "./chunk-QEYN2Z6O.js";
|
|
4
|
+
|
|
5
|
+
// transport/impls/ws/connection.ts
|
|
6
|
+
var WebSocketConnection = class extends Connection {
|
|
7
|
+
ws;
|
|
8
|
+
constructor(ws) {
|
|
9
|
+
super();
|
|
10
|
+
this.ws = ws;
|
|
11
|
+
this.ws.binaryType = "arraybuffer";
|
|
12
|
+
}
|
|
13
|
+
addDataListener(cb) {
|
|
14
|
+
this.ws.onmessage = (msg) => cb(msg.data);
|
|
15
|
+
}
|
|
16
|
+
removeDataListener() {
|
|
17
|
+
this.ws.onmessage = null;
|
|
18
|
+
}
|
|
19
|
+
addCloseListener(cb) {
|
|
20
|
+
this.ws.onclose = cb;
|
|
21
|
+
}
|
|
22
|
+
addErrorListener(cb) {
|
|
23
|
+
this.ws.onerror = (err) => cb(new Error(err.message));
|
|
24
|
+
}
|
|
25
|
+
send(payload) {
|
|
26
|
+
if (this.ws.readyState === this.ws.OPEN) {
|
|
27
|
+
this.ws.send(payload);
|
|
28
|
+
return true;
|
|
29
|
+
} else {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
close() {
|
|
34
|
+
this.ws.close();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
WebSocketConnection
|
|
40
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MessageFramer
|
|
3
|
+
} from "./chunk-IIBVKYDB.js";
|
|
4
|
+
import {
|
|
5
|
+
Connection
|
|
6
|
+
} from "./chunk-QEYN2Z6O.js";
|
|
7
|
+
|
|
8
|
+
// transport/impls/uds/connection.ts
|
|
9
|
+
var UdsConnection = class extends Connection {
|
|
10
|
+
sock;
|
|
11
|
+
input;
|
|
12
|
+
framer;
|
|
13
|
+
constructor(sock) {
|
|
14
|
+
super();
|
|
15
|
+
this.framer = MessageFramer.createFramedStream();
|
|
16
|
+
this.sock = sock;
|
|
17
|
+
this.input = sock.pipe(this.framer);
|
|
18
|
+
}
|
|
19
|
+
addDataListener(cb) {
|
|
20
|
+
this.input.on("data", cb);
|
|
21
|
+
}
|
|
22
|
+
removeDataListener(cb) {
|
|
23
|
+
this.input.off("data", cb);
|
|
24
|
+
}
|
|
25
|
+
addCloseListener(cb) {
|
|
26
|
+
this.sock.on("close", cb);
|
|
27
|
+
}
|
|
28
|
+
addErrorListener(cb) {
|
|
29
|
+
this.sock.on("error", cb);
|
|
30
|
+
}
|
|
31
|
+
send(payload) {
|
|
32
|
+
if (this.framer.destroyed || !this.sock.writable)
|
|
33
|
+
return false;
|
|
34
|
+
return this.sock.write(MessageFramer.write(payload));
|
|
35
|
+
}
|
|
36
|
+
close() {
|
|
37
|
+
this.sock.destroy();
|
|
38
|
+
this.framer.destroy();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
UdsConnection
|
|
44
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// transport/message.ts
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
var TransportMessageSchema = (t) => Type.Object({
|
|
5
|
+
id: Type.String(),
|
|
6
|
+
from: Type.String(),
|
|
7
|
+
to: Type.String(),
|
|
8
|
+
seq: Type.Integer(),
|
|
9
|
+
ack: Type.Integer(),
|
|
10
|
+
serviceName: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
11
|
+
procedureName: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
12
|
+
streamId: Type.String(),
|
|
13
|
+
controlFlags: Type.Integer(),
|
|
14
|
+
payload: t
|
|
15
|
+
});
|
|
16
|
+
var ControlMessageAckSchema = Type.Object({
|
|
17
|
+
type: Type.Literal("ACK")
|
|
18
|
+
});
|
|
19
|
+
var ControlMessageCloseSchema = Type.Object({
|
|
20
|
+
type: Type.Literal("CLOSE")
|
|
21
|
+
});
|
|
22
|
+
var PROTOCOL_VERSION = "v1";
|
|
23
|
+
var ControlMessageHandshakeRequestSchema = Type.Object({
|
|
24
|
+
type: Type.Literal("HANDSHAKE_REQ"),
|
|
25
|
+
protocolVersion: Type.Literal(PROTOCOL_VERSION),
|
|
26
|
+
instanceId: Type.String()
|
|
27
|
+
});
|
|
28
|
+
var ControlMessageHandshakeResponseSchema = Type.Object({
|
|
29
|
+
type: Type.Literal("HANDSHAKE_RESP"),
|
|
30
|
+
status: Type.Union([
|
|
31
|
+
Type.Object({
|
|
32
|
+
ok: Type.Literal(true),
|
|
33
|
+
instanceId: Type.String()
|
|
34
|
+
}),
|
|
35
|
+
Type.Object({
|
|
36
|
+
ok: Type.Literal(false),
|
|
37
|
+
reason: Type.Union([Type.Literal("VERSION_MISMATCH")])
|
|
38
|
+
})
|
|
39
|
+
])
|
|
40
|
+
});
|
|
41
|
+
var ControlMessagePayloadSchema = Type.Union([
|
|
42
|
+
ControlMessageCloseSchema,
|
|
43
|
+
ControlMessageAckSchema,
|
|
44
|
+
ControlMessageHandshakeRequestSchema,
|
|
45
|
+
ControlMessageHandshakeResponseSchema
|
|
46
|
+
]);
|
|
47
|
+
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
48
|
+
Type.Unknown()
|
|
49
|
+
);
|
|
50
|
+
function bootRequestMessage(from, to, instanceId) {
|
|
51
|
+
return {
|
|
52
|
+
id: nanoid(),
|
|
53
|
+
from,
|
|
54
|
+
to,
|
|
55
|
+
seq: 0,
|
|
56
|
+
ack: 0,
|
|
57
|
+
streamId: nanoid(),
|
|
58
|
+
controlFlags: 0,
|
|
59
|
+
payload: {
|
|
60
|
+
type: "HANDSHAKE_REQ",
|
|
61
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
62
|
+
instanceId
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function bootResponseMessage(from, instanceId, to, ok) {
|
|
67
|
+
return {
|
|
68
|
+
id: nanoid(),
|
|
69
|
+
from,
|
|
70
|
+
to,
|
|
71
|
+
seq: 0,
|
|
72
|
+
ack: 0,
|
|
73
|
+
streamId: nanoid(),
|
|
74
|
+
controlFlags: 0,
|
|
75
|
+
payload: ok ? {
|
|
76
|
+
type: "HANDSHAKE_RESP",
|
|
77
|
+
status: {
|
|
78
|
+
ok: true,
|
|
79
|
+
instanceId
|
|
80
|
+
}
|
|
81
|
+
} : {
|
|
82
|
+
type: "HANDSHAKE_RESP",
|
|
83
|
+
status: {
|
|
84
|
+
ok: false,
|
|
85
|
+
reason: "VERSION_MISMATCH"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function isAck(controlFlag) {
|
|
91
|
+
return (controlFlag & 1 /* AckBit */) === 1 /* AckBit */;
|
|
92
|
+
}
|
|
93
|
+
function isStreamOpen(controlFlag) {
|
|
94
|
+
return (
|
|
95
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */
|
|
96
|
+
(controlFlag & 2 /* StreamOpenBit */) === 2 /* StreamOpenBit */
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
function isStreamClose(controlFlag) {
|
|
100
|
+
return (
|
|
101
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */
|
|
102
|
+
(controlFlag & 4 /* StreamClosedBit */) === 4 /* StreamClosedBit */
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// util/stringify.ts
|
|
107
|
+
function coerceErrorString(err) {
|
|
108
|
+
if (err instanceof Error) {
|
|
109
|
+
return err.message;
|
|
110
|
+
}
|
|
111
|
+
return `[coerced to error] ${String(err)}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
TransportMessageSchema,
|
|
116
|
+
PROTOCOL_VERSION,
|
|
117
|
+
ControlMessageHandshakeRequestSchema,
|
|
118
|
+
ControlMessageHandshakeResponseSchema,
|
|
119
|
+
ControlMessagePayloadSchema,
|
|
120
|
+
OpaqueTransportMessageSchema,
|
|
121
|
+
bootRequestMessage,
|
|
122
|
+
bootResponseMessage,
|
|
123
|
+
isAck,
|
|
124
|
+
isStreamOpen,
|
|
125
|
+
isStreamClose,
|
|
126
|
+
coerceErrorString
|
|
127
|
+
};
|
package/dist/codec/index.cjs
CHANGED
|
@@ -64,7 +64,7 @@ var NaiveJsonCodec = {
|
|
|
64
64
|
toBuffer: (obj) => {
|
|
65
65
|
return encoder.encode(
|
|
66
66
|
JSON.stringify(obj, function replacer(key) {
|
|
67
|
-
|
|
67
|
+
const val = this[key];
|
|
68
68
|
if (val instanceof Uint8Array) {
|
|
69
69
|
return { $t: uint8ArrayToBase64(val) };
|
|
70
70
|
} else {
|
|
@@ -75,13 +75,19 @@ var NaiveJsonCodec = {
|
|
|
75
75
|
},
|
|
76
76
|
fromBuffer: (buff) => {
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
const parsed = JSON.parse(
|
|
79
|
+
decoder.decode(buff),
|
|
80
|
+
function reviver(_key, val) {
|
|
81
|
+
if (val?.$t) {
|
|
82
|
+
return base64ToUint8Array(val.$t);
|
|
83
|
+
} else {
|
|
84
|
+
return val;
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
|
-
|
|
87
|
+
);
|
|
88
|
+
if (typeof parsed === "object")
|
|
89
|
+
return parsed;
|
|
90
|
+
return null;
|
|
85
91
|
} catch {
|
|
86
92
|
return null;
|
|
87
93
|
}
|
package/dist/codec/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { C as Connection } from './index-0c0a69f6.js';
|
|
2
|
+
import { U as Uint32LengthPrefixFraming } from './messageFraming-b200ef25.js';
|
|
3
|
+
|
|
4
|
+
declare class StreamConnection extends Connection {
|
|
5
|
+
input: NodeJS.ReadableStream;
|
|
6
|
+
output: NodeJS.WritableStream;
|
|
7
|
+
framer: Uint32LengthPrefixFraming;
|
|
8
|
+
constructor(input: NodeJS.ReadableStream, output: NodeJS.WritableStream);
|
|
9
|
+
addDataListener(cb: (msg: Uint8Array) => void): void;
|
|
10
|
+
removeDataListener(cb: (msg: Uint8Array) => void): void;
|
|
11
|
+
addCloseListener(cb: () => void): void;
|
|
12
|
+
addErrorListener(cb: (err: Error) => void): void;
|
|
13
|
+
send(payload: Uint8Array): boolean;
|
|
14
|
+
close(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { StreamConnection as S };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { C as Connection } from './index-0c0a69f6.js';
|
|
2
|
+
import { Socket } from 'node:net';
|
|
3
|
+
import { U as Uint32LengthPrefixFraming } from './messageFraming-b200ef25.js';
|
|
4
|
+
|
|
5
|
+
declare class UdsConnection extends Connection {
|
|
6
|
+
sock: Socket;
|
|
7
|
+
input: NodeJS.ReadableStream;
|
|
8
|
+
framer: Uint32LengthPrefixFraming;
|
|
9
|
+
constructor(sock: Socket);
|
|
10
|
+
addDataListener(cb: (msg: Uint8Array) => void): void;
|
|
11
|
+
removeDataListener(cb: (msg: Uint8Array) => void): void;
|
|
12
|
+
addCloseListener(cb: () => void): void;
|
|
13
|
+
addErrorListener(cb: (err: Error) => void): void;
|
|
14
|
+
send(payload: Uint8Array): boolean;
|
|
15
|
+
close(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { UdsConnection as U };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import WebSocket from 'isomorphic-ws';
|
|
2
|
+
import { C as Connection } from './index-0c0a69f6.js';
|
|
3
|
+
|
|
4
|
+
declare class WebSocketConnection extends Connection {
|
|
5
|
+
ws: WebSocket;
|
|
6
|
+
constructor(ws: WebSocket);
|
|
7
|
+
addDataListener(cb: (msg: Uint8Array) => void): void;
|
|
8
|
+
removeDataListener(): void;
|
|
9
|
+
addCloseListener(cb: () => void): void;
|
|
10
|
+
addErrorListener(cb: (err: Error) => void): void;
|
|
11
|
+
send(payload: Uint8Array): boolean;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { WebSocketConnection as W };
|