@replit/river 0.10.4 → 0.10.5
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-UU2Z7LDR.js → chunk-IEU7OE5W.js} +2 -5
- package/dist/{chunk-FWPZDOFL.js → chunk-IYRPZPSQ.js} +3 -0
- package/dist/{chunk-RGMHF6PF.js → chunk-PNZXYQME.js} +6 -8
- package/dist/{chunk-PC65ZFWJ.js → chunk-SZTOUKL7.js} +1 -1
- package/dist/chunk-TZSX5KM2.js +80 -0
- package/dist/{chunk-AJQU4AZG.js → chunk-V2YJRBRX.js} +1 -0
- package/dist/connection-2529fc14.d.ts +10 -0
- package/dist/connection-316d6e3a.d.ts +10 -0
- package/dist/router/index.cjs +3 -0
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/stdio/stdio.cjs +78 -35
- package/dist/transport/impls/stdio/stdio.d.cts +4 -11
- package/dist/transport/impls/stdio/stdio.d.ts +4 -11
- package/dist/transport/impls/stdio/stdio.js +21 -36
- package/dist/transport/impls/unixsocket/client.cjs +509 -0
- package/dist/transport/impls/unixsocket/client.d.cts +16 -0
- package/dist/transport/impls/unixsocket/client.d.ts +16 -0
- package/dist/transport/impls/unixsocket/client.js +67 -0
- package/dist/transport/impls/unixsocket/server.cjs +513 -0
- package/dist/transport/impls/unixsocket/server.d.cts +18 -0
- package/dist/transport/impls/unixsocket/server.d.ts +18 -0
- package/dist/transport/impls/unixsocket/server.js +73 -0
- package/dist/transport/impls/ws/client.cjs +1 -3
- package/dist/transport/impls/ws/client.d.cts +0 -1
- package/dist/transport/impls/ws/client.d.ts +0 -1
- package/dist/transport/impls/ws/client.js +3 -3
- package/dist/transport/impls/ws/server.cjs +5 -6
- package/dist/transport/impls/ws/server.d.cts +0 -2
- package/dist/transport/impls/ws/server.d.ts +0 -2
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +1 -0
- package/dist/transport/index.d.cts +6 -7
- package/dist/transport/index.d.ts +6 -7
- package/dist/transport/index.js +1 -1
- package/dist/util/testHelpers.cjs +24 -12
- package/dist/util/testHelpers.d.cts +6 -3
- package/dist/util/testHelpers.d.ts +6 -3
- package/dist/util/testHelpers.js +19 -8
- package/package.json +23 -14
|
@@ -184,6 +184,7 @@ var Transport = class {
|
|
|
184
184
|
eventDispatcher;
|
|
185
185
|
/**
|
|
186
186
|
* Creates a new Transport instance.
|
|
187
|
+
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
187
188
|
* @param codec The codec used to encode and decode messages.
|
|
188
189
|
* @param clientId The client ID of this transport.
|
|
189
190
|
*/
|
|
@@ -409,13 +410,14 @@ var defaultOptions = {
|
|
|
409
410
|
};
|
|
410
411
|
var WebSocketServerTransport = class extends Transport {
|
|
411
412
|
wss;
|
|
412
|
-
clientId;
|
|
413
413
|
constructor(wss, clientId, providedOptions) {
|
|
414
414
|
const options = { ...defaultOptions, ...providedOptions };
|
|
415
415
|
super(options.codec, clientId);
|
|
416
416
|
this.wss = wss;
|
|
417
|
-
|
|
418
|
-
|
|
417
|
+
wss.on("listening", () => {
|
|
418
|
+
log?.info(`${this.clientId} -- server is listening`);
|
|
419
|
+
});
|
|
420
|
+
this.wss.on("connection", this.connectionHandler);
|
|
419
421
|
}
|
|
420
422
|
connectionHandler = (ws) => {
|
|
421
423
|
let conn = void 0;
|
|
@@ -438,9 +440,6 @@ var WebSocketServerTransport = class extends Transport {
|
|
|
438
440
|
);
|
|
439
441
|
};
|
|
440
442
|
};
|
|
441
|
-
setupConnectionStatusListeners() {
|
|
442
|
-
this.wss.on("connection", this.connectionHandler);
|
|
443
|
-
}
|
|
444
443
|
async createNewConnection(to) {
|
|
445
444
|
const err = `${this.clientId} -- failed to send msg to ${to}, client probably dropped`;
|
|
446
445
|
log?.warn(err);
|
|
@@ -10,10 +10,8 @@ interface Options {
|
|
|
10
10
|
}
|
|
11
11
|
declare class WebSocketServerTransport extends Transport<WebSocketConnection> {
|
|
12
12
|
wss: WebSocketServer;
|
|
13
|
-
clientId: TransportClientId;
|
|
14
13
|
constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<Options>);
|
|
15
14
|
connectionHandler: (ws: WebSocket) => void;
|
|
16
|
-
setupConnectionStatusListeners(): void;
|
|
17
15
|
createNewConnection(to: string): Promise<void>;
|
|
18
16
|
close(): Promise<void>;
|
|
19
17
|
}
|
|
@@ -10,10 +10,8 @@ interface Options {
|
|
|
10
10
|
}
|
|
11
11
|
declare class WebSocketServerTransport extends Transport<WebSocketConnection> {
|
|
12
12
|
wss: WebSocketServer;
|
|
13
|
-
clientId: TransportClientId;
|
|
14
13
|
constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<Options>);
|
|
15
14
|
connectionHandler: (ws: WebSocket) => void;
|
|
16
|
-
setupConnectionStatusListeners(): void;
|
|
17
15
|
createNewConnection(to: string): Promise<void>;
|
|
18
16
|
close(): Promise<void>;
|
|
19
17
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketServerTransport
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-PNZXYQME.js";
|
|
4
|
+
import "../../../chunk-SZTOUKL7.js";
|
|
4
5
|
import "../../../chunk-WVT5QXMZ.js";
|
|
5
|
-
import "../../../chunk-PC65ZFWJ.js";
|
|
6
6
|
import "../../../chunk-R6H2BIMC.js";
|
|
7
|
-
import "../../../chunk-
|
|
7
|
+
import "../../../chunk-V2YJRBRX.js";
|
|
8
8
|
import "../../../chunk-ZE4MX7DF.js";
|
|
9
9
|
import "../../../chunk-SLUSVGQH.js";
|
|
10
10
|
export {
|
package/dist/transport/index.cjs
CHANGED
|
@@ -155,6 +155,7 @@ var Transport = class {
|
|
|
155
155
|
eventDispatcher;
|
|
156
156
|
/**
|
|
157
157
|
* Creates a new Transport instance.
|
|
158
|
+
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
158
159
|
* @param codec The codec used to encode and decode messages.
|
|
159
160
|
* @param clientId The client ID of this transport.
|
|
160
161
|
*/
|
|
@@ -194,18 +194,17 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
194
194
|
eventDispatcher: EventDispatcher<EventTypes>;
|
|
195
195
|
/**
|
|
196
196
|
* Creates a new Transport instance.
|
|
197
|
+
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
197
198
|
* @param codec The codec used to encode and decode messages.
|
|
198
199
|
* @param clientId The client ID of this transport.
|
|
199
200
|
*/
|
|
200
201
|
constructor(codec: Codec, clientId: TransportClientId);
|
|
201
202
|
/**
|
|
202
|
-
* Abstract method that
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
* Abstract method that creates a new {@link Connection} object. This should call
|
|
208
|
-
* {@link onConnect} when the connection is established. The downstream implementation needs to implement this.
|
|
203
|
+
* Abstract method that creates a new {@link Connection} object.
|
|
204
|
+
* This should call {@link onConnect} when the connection is established.
|
|
205
|
+
* The downstream implementation needs to implement this. If the downstream
|
|
206
|
+
* transport cannot make new outgoing connections (e.g. a server transport),
|
|
207
|
+
* it is ok to log an error and return.
|
|
209
208
|
* @param to The client ID of the node to connect to.
|
|
210
209
|
* @returns The new connection object.
|
|
211
210
|
*/
|
|
@@ -194,18 +194,17 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
194
194
|
eventDispatcher: EventDispatcher<EventTypes>;
|
|
195
195
|
/**
|
|
196
196
|
* Creates a new Transport instance.
|
|
197
|
+
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
197
198
|
* @param codec The codec used to encode and decode messages.
|
|
198
199
|
* @param clientId The client ID of this transport.
|
|
199
200
|
*/
|
|
200
201
|
constructor(codec: Codec, clientId: TransportClientId);
|
|
201
202
|
/**
|
|
202
|
-
* Abstract method that
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
* Abstract method that creates a new {@link Connection} object. This should call
|
|
208
|
-
* {@link onConnect} when the connection is established. The downstream implementation needs to implement this.
|
|
203
|
+
* Abstract method that creates a new {@link Connection} object.
|
|
204
|
+
* This should call {@link onConnect} when the connection is established.
|
|
205
|
+
* The downstream implementation needs to implement this. If the downstream
|
|
206
|
+
* transport cannot make new outgoing connections (e.g. a server transport),
|
|
207
|
+
* it is ok to log an error and return.
|
|
209
208
|
* @param to The client ID of the node to connect to.
|
|
210
209
|
* @returns The new connection object.
|
|
211
210
|
*/
|
package/dist/transport/index.js
CHANGED
|
@@ -38,8 +38,10 @@ __export(testHelpers_exports, {
|
|
|
38
38
|
createLocalWebSocketClient: () => createLocalWebSocketClient,
|
|
39
39
|
createWebSocketServer: () => createWebSocketServer,
|
|
40
40
|
createWsTransports: () => createWsTransports,
|
|
41
|
+
getUnixSocketPath: () => getUnixSocketPath,
|
|
41
42
|
iterNext: () => iterNext,
|
|
42
|
-
|
|
43
|
+
onUnixSocketServeReady: () => onUnixSocketServeReady,
|
|
44
|
+
onWsServerReady: () => onWsServerReady,
|
|
43
45
|
payloadToTransportMessage: () => payloadToTransportMessage,
|
|
44
46
|
waitForMessage: () => waitForMessage
|
|
45
47
|
});
|
|
@@ -173,6 +175,7 @@ var Transport = class {
|
|
|
173
175
|
eventDispatcher;
|
|
174
176
|
/**
|
|
175
177
|
* Creates a new Transport instance.
|
|
178
|
+
* This should also set up {@link onConnect}, and {@link onDisconnect} listeners.
|
|
176
179
|
* @param codec The codec used to encode and decode messages.
|
|
177
180
|
* @param clientId The client ID of this transport.
|
|
178
181
|
*/
|
|
@@ -466,9 +469,6 @@ var WebSocketClientTransport = class extends Transport {
|
|
|
466
469
|
this.serverId = serverId;
|
|
467
470
|
this.options = options;
|
|
468
471
|
this.reconnectPromises = /* @__PURE__ */ new Map();
|
|
469
|
-
this.setupConnectionStatusListeners();
|
|
470
|
-
}
|
|
471
|
-
setupConnectionStatusListeners() {
|
|
472
472
|
this.createNewConnection(this.serverId);
|
|
473
473
|
}
|
|
474
474
|
async createNewConnection(to, attempt = 0) {
|
|
@@ -809,6 +809,9 @@ function _pushable(getNext, options) {
|
|
|
809
809
|
},
|
|
810
810
|
get readableLength() {
|
|
811
811
|
return _pushable2.readableLength;
|
|
812
|
+
},
|
|
813
|
+
onEmpty: (opts) => {
|
|
814
|
+
return _pushable2.onEmpty(opts);
|
|
812
815
|
}
|
|
813
816
|
};
|
|
814
817
|
return pushable2;
|
|
@@ -820,13 +823,14 @@ var defaultOptions2 = {
|
|
|
820
823
|
};
|
|
821
824
|
var WebSocketServerTransport = class extends Transport {
|
|
822
825
|
wss;
|
|
823
|
-
clientId;
|
|
824
826
|
constructor(wss, clientId, providedOptions) {
|
|
825
827
|
const options = { ...defaultOptions2, ...providedOptions };
|
|
826
828
|
super(options.codec, clientId);
|
|
827
829
|
this.wss = wss;
|
|
828
|
-
|
|
829
|
-
|
|
830
|
+
wss.on("listening", () => {
|
|
831
|
+
log?.info(`${this.clientId} -- server is listening`);
|
|
832
|
+
});
|
|
833
|
+
this.wss.on("connection", this.connectionHandler);
|
|
830
834
|
}
|
|
831
835
|
connectionHandler = (ws) => {
|
|
832
836
|
let conn = void 0;
|
|
@@ -849,9 +853,6 @@ var WebSocketServerTransport = class extends Transport {
|
|
|
849
853
|
);
|
|
850
854
|
};
|
|
851
855
|
};
|
|
852
|
-
setupConnectionStatusListeners() {
|
|
853
|
-
this.wss.on("connection", this.connectionHandler);
|
|
854
|
-
}
|
|
855
856
|
async createNewConnection(to) {
|
|
856
857
|
const err = `${this.clientId} -- failed to send msg to ${to}, client probably dropped`;
|
|
857
858
|
log?.warn(err);
|
|
@@ -876,10 +877,11 @@ var RiverUncaughtSchema = import_typebox2.Type.Object({
|
|
|
876
877
|
});
|
|
877
878
|
|
|
878
879
|
// util/testHelpers.ts
|
|
880
|
+
var import_nanoid2 = require("nanoid");
|
|
879
881
|
async function createWebSocketServer(server) {
|
|
880
882
|
return new import_ws.WebSocketServer({ server });
|
|
881
883
|
}
|
|
882
|
-
|
|
884
|
+
function onWsServerReady(server) {
|
|
883
885
|
return new Promise((resolve, reject) => {
|
|
884
886
|
server.listen(() => {
|
|
885
887
|
const addr = server.address();
|
|
@@ -891,6 +893,11 @@ async function onServerReady(server) {
|
|
|
891
893
|
});
|
|
892
894
|
});
|
|
893
895
|
}
|
|
896
|
+
function onUnixSocketServeReady(server, path) {
|
|
897
|
+
return new Promise((resolve) => {
|
|
898
|
+
server.listen(path, resolve);
|
|
899
|
+
});
|
|
900
|
+
}
|
|
894
901
|
async function createLocalWebSocketClient(port) {
|
|
895
902
|
const sock = new import_isomorphic_ws.default(`ws://localhost:${port}`);
|
|
896
903
|
sock.binaryType = "arraybuffer";
|
|
@@ -990,6 +997,9 @@ async function asClientUpload(state, proc, init, extendedContext) {
|
|
|
990
997
|
return [input, result];
|
|
991
998
|
}
|
|
992
999
|
}
|
|
1000
|
+
var getUnixSocketPath = () => {
|
|
1001
|
+
return process.platform === "win32" ? `\\\\?\\pipe\\${(0, import_nanoid2.nanoid)()}` : `/tmp/${(0, import_nanoid2.nanoid)()}.sock`;
|
|
1002
|
+
};
|
|
993
1003
|
// Annotate the CommonJS export names for ESM import in node:
|
|
994
1004
|
0 && (module.exports = {
|
|
995
1005
|
asClientRpc,
|
|
@@ -1000,8 +1010,10 @@ async function asClientUpload(state, proc, init, extendedContext) {
|
|
|
1000
1010
|
createLocalWebSocketClient,
|
|
1001
1011
|
createWebSocketServer,
|
|
1002
1012
|
createWsTransports,
|
|
1013
|
+
getUnixSocketPath,
|
|
1003
1014
|
iterNext,
|
|
1004
|
-
|
|
1015
|
+
onUnixSocketServeReady,
|
|
1016
|
+
onWsServerReady,
|
|
1005
1017
|
payloadToTransportMessage,
|
|
1006
1018
|
waitForMessage
|
|
1007
1019
|
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import { WebSocketServer } from 'ws';
|
|
4
|
-
import http from 'http';
|
|
4
|
+
import http from 'node:http';
|
|
5
5
|
import { WebSocketClientTransport } from '../transport/impls/ws/client.cjs';
|
|
6
6
|
import { TransportClientId, TransportMessage, OpaqueTransportMessage, Transport, Connection } from '../transport/index.cjs';
|
|
7
7
|
import { C as Codec } from '../types-3e5768ec.js';
|
|
8
8
|
import { WebSocketServerTransport } from '../transport/impls/ws/server.cjs';
|
|
9
9
|
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-87111051.js';
|
|
10
10
|
import { Static } from '@sinclair/typebox';
|
|
11
|
+
import net from 'node:net';
|
|
11
12
|
import '../connection-f7688cc1.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -24,7 +25,8 @@ declare function createWebSocketServer(server: http.Server): Promise<WebSocket.S
|
|
|
24
25
|
* @returns A promise that resolves with the allocated port number.
|
|
25
26
|
* @throws An error if a port cannot be allocated.
|
|
26
27
|
*/
|
|
27
|
-
declare function
|
|
28
|
+
declare function onWsServerReady(server: http.Server): Promise<number>;
|
|
29
|
+
declare function onUnixSocketServeReady(server: net.Server, path: string): Promise<void>;
|
|
28
30
|
/**
|
|
29
31
|
* Creates a WebSocket client that connects to a local server at the specified port.
|
|
30
32
|
* This should only be used for testing.
|
|
@@ -75,5 +77,6 @@ declare function asClientUpload<State extends object | unknown, I extends Payloa
|
|
|
75
77
|
message: string;
|
|
76
78
|
};
|
|
77
79
|
} | Result<Static<O>, Static<E>>>]>;
|
|
80
|
+
declare const getUnixSocketPath: () => string;
|
|
78
81
|
|
|
79
|
-
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, createWsTransports, iterNext,
|
|
82
|
+
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, createWsTransports, getUnixSocketPath, iterNext, onUnixSocketServeReady, onWsServerReady, payloadToTransportMessage, waitForMessage };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import { WebSocketServer } from 'ws';
|
|
4
|
-
import http from 'http';
|
|
4
|
+
import http from 'node:http';
|
|
5
5
|
import { WebSocketClientTransport } from '../transport/impls/ws/client.js';
|
|
6
6
|
import { TransportClientId, TransportMessage, OpaqueTransportMessage, Transport, Connection } from '../transport/index.js';
|
|
7
7
|
import { C as Codec } from '../types-3e5768ec.js';
|
|
8
8
|
import { WebSocketServerTransport } from '../transport/impls/ws/server.js';
|
|
9
9
|
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-87111051.js';
|
|
10
10
|
import { Static } from '@sinclair/typebox';
|
|
11
|
+
import net from 'node:net';
|
|
11
12
|
import '../connection-8e19874c.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -24,7 +25,8 @@ declare function createWebSocketServer(server: http.Server): Promise<WebSocket.S
|
|
|
24
25
|
* @returns A promise that resolves with the allocated port number.
|
|
25
26
|
* @throws An error if a port cannot be allocated.
|
|
26
27
|
*/
|
|
27
|
-
declare function
|
|
28
|
+
declare function onWsServerReady(server: http.Server): Promise<number>;
|
|
29
|
+
declare function onUnixSocketServeReady(server: net.Server, path: string): Promise<void>;
|
|
28
30
|
/**
|
|
29
31
|
* Creates a WebSocket client that connects to a local server at the specified port.
|
|
30
32
|
* This should only be used for testing.
|
|
@@ -75,5 +77,6 @@ declare function asClientUpload<State extends object | unknown, I extends Payloa
|
|
|
75
77
|
message: string;
|
|
76
78
|
};
|
|
77
79
|
} | Result<Static<O>, Static<E>>>]>;
|
|
80
|
+
declare const getUnixSocketPath: () => string;
|
|
78
81
|
|
|
79
|
-
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, createWsTransports, iterNext,
|
|
82
|
+
export { asClientRpc, asClientStream, asClientSubscription, asClientUpload, createDummyTransportMessage, createLocalWebSocketClient, createWebSocketServer, createWsTransports, getUnixSocketPath, iterNext, onUnixSocketServeReady, onWsServerReady, payloadToTransportMessage, waitForMessage };
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-ORAG7IAU.js";
|
|
4
|
+
} from "../chunk-IYRPZPSQ.js";
|
|
6
5
|
import {
|
|
7
6
|
WebSocketClientTransport
|
|
8
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-IEU7OE5W.js";
|
|
9
8
|
import {
|
|
10
9
|
WebSocketServerTransport
|
|
11
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-PNZXYQME.js";
|
|
11
|
+
import "../chunk-SZTOUKL7.js";
|
|
12
|
+
import "../chunk-ORAG7IAU.js";
|
|
12
13
|
import "../chunk-WVT5QXMZ.js";
|
|
13
|
-
import "../chunk-PC65ZFWJ.js";
|
|
14
14
|
import "../chunk-R6H2BIMC.js";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-V2YJRBRX.js";
|
|
16
16
|
import {
|
|
17
17
|
msg
|
|
18
18
|
} from "../chunk-ZE4MX7DF.js";
|
|
@@ -21,10 +21,11 @@ import "../chunk-SLUSVGQH.js";
|
|
|
21
21
|
// util/testHelpers.ts
|
|
22
22
|
import WebSocket from "isomorphic-ws";
|
|
23
23
|
import { WebSocketServer } from "ws";
|
|
24
|
+
import { nanoid } from "nanoid";
|
|
24
25
|
async function createWebSocketServer(server) {
|
|
25
26
|
return new WebSocketServer({ server });
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
function onWsServerReady(server) {
|
|
28
29
|
return new Promise((resolve, reject) => {
|
|
29
30
|
server.listen(() => {
|
|
30
31
|
const addr = server.address();
|
|
@@ -36,6 +37,11 @@ async function onServerReady(server) {
|
|
|
36
37
|
});
|
|
37
38
|
});
|
|
38
39
|
}
|
|
40
|
+
function onUnixSocketServeReady(server, path) {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
server.listen(path, resolve);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
39
45
|
async function createLocalWebSocketClient(port) {
|
|
40
46
|
const sock = new WebSocket(`ws://localhost:${port}`);
|
|
41
47
|
sock.binaryType = "arraybuffer";
|
|
@@ -135,6 +141,9 @@ async function asClientUpload(state, proc, init, extendedContext) {
|
|
|
135
141
|
return [input, result];
|
|
136
142
|
}
|
|
137
143
|
}
|
|
144
|
+
var getUnixSocketPath = () => {
|
|
145
|
+
return process.platform === "win32" ? `\\\\?\\pipe\\${nanoid()}` : `/tmp/${nanoid()}.sock`;
|
|
146
|
+
};
|
|
138
147
|
export {
|
|
139
148
|
asClientRpc,
|
|
140
149
|
asClientStream,
|
|
@@ -144,8 +153,10 @@ export {
|
|
|
144
153
|
createLocalWebSocketClient,
|
|
145
154
|
createWebSocketServer,
|
|
146
155
|
createWsTransports,
|
|
156
|
+
getUnixSocketPath,
|
|
147
157
|
iterNext,
|
|
148
|
-
|
|
158
|
+
onUnixSocketServeReady,
|
|
159
|
+
onWsServerReady,
|
|
149
160
|
payloadToTransportMessage,
|
|
150
161
|
waitForMessage
|
|
151
162
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replit/river",
|
|
3
3
|
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
"import": "./dist/transport/impls/ws/server.js",
|
|
29
29
|
"require": "./dist/transport/impls/ws/server.cjs"
|
|
30
30
|
},
|
|
31
|
+
"./transport/unixsocket/client": {
|
|
32
|
+
"import": "./dist/transport/impls/unixsocket/client.js",
|
|
33
|
+
"require": "./dist/transport/impls/unixsocket/client.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./transport/unixsocket/server": {
|
|
36
|
+
"import": "./dist/transport/impls/unixsocket/server.js",
|
|
37
|
+
"require": "./dist/transport/impls/unixsocket/server.cjs"
|
|
38
|
+
},
|
|
31
39
|
"./transport/stdio": {
|
|
32
40
|
"import": "./dist/transport/impls/stdio/stdio.js",
|
|
33
41
|
"require": "./dist/transport/impls/stdio/stdio.cjs"
|
|
@@ -55,11 +63,21 @@
|
|
|
55
63
|
},
|
|
56
64
|
"devDependencies": {
|
|
57
65
|
"@types/ws": "^8.5.5",
|
|
58
|
-
"@vitest/ui": "^1.0
|
|
66
|
+
"@vitest/ui": "^1.1.0",
|
|
59
67
|
"prettier": "^3.0.0",
|
|
60
68
|
"tsup": "^7.2.0",
|
|
61
69
|
"typescript": "^5.2.2",
|
|
62
|
-
"vitest": "^1.0
|
|
70
|
+
"vitest": "^1.1.0"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"check": "tsc --noEmit && npx prettier . --check",
|
|
74
|
+
"format": "npx prettier . --write",
|
|
75
|
+
"build": "rm -rf dist && tsup && du -sh dist",
|
|
76
|
+
"prepack": "npm run build",
|
|
77
|
+
"release": "npm publish --access public",
|
|
78
|
+
"test:ui": "echo \"remember to go to /__vitest__ in the webview\" && vitest --ui --api.host 0.0.0.0 --api.port 3000",
|
|
79
|
+
"test": "vitest --test-timeout=500",
|
|
80
|
+
"bench": "vitest bench"
|
|
63
81
|
},
|
|
64
82
|
"engines": {
|
|
65
83
|
"node": ">=16"
|
|
@@ -70,14 +88,5 @@
|
|
|
70
88
|
"jsonschema"
|
|
71
89
|
],
|
|
72
90
|
"author": "Jacky Zhao",
|
|
73
|
-
"license": "MIT"
|
|
74
|
-
|
|
75
|
-
"check": "tsc --noEmit && npx prettier . --check",
|
|
76
|
-
"format": "npx prettier . --write",
|
|
77
|
-
"build": "rm -rf dist && tsup && du -sh dist",
|
|
78
|
-
"release": "npm publish --access public",
|
|
79
|
-
"test:ui": "echo \"remember to go to /__vitest__ in the webview\" && vitest --ui --api.host 0.0.0.0 --api.port 3000",
|
|
80
|
-
"test": "vitest --test-timeout=500",
|
|
81
|
-
"bench": "vitest bench"
|
|
82
|
-
}
|
|
83
|
-
}
|
|
91
|
+
"license": "MIT"
|
|
92
|
+
}
|