@replit/river 0.10.3 → 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-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/transport/impls/stdio/stdio.cjs +511 -0
- package/dist/transport/impls/stdio/stdio.d.cts +26 -0
- package/dist/transport/impls/stdio/stdio.d.ts +26 -0
- package/dist/transport/impls/stdio/stdio.js +70 -0
- 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 +21 -12
- package/dist/util/testHelpers.d.cts +6 -3
- package/dist/util/testHelpers.d.ts +6 -3
- package/dist/util/testHelpers.js +18 -7
- package/package.json +12 -4
|
@@ -35,7 +35,6 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
|
|
|
35
35
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
36
36
|
*/
|
|
37
37
|
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
|
|
38
|
-
setupConnectionStatusListeners(): void;
|
|
39
38
|
createNewConnection(to: string, attempt?: number): Promise<void>;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -35,7 +35,6 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
|
|
|
35
35
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
36
36
|
*/
|
|
37
37
|
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
|
|
38
|
-
setupConnectionStatusListeners(): void;
|
|
39
38
|
createNewConnection(to: string, attempt?: number): Promise<void>;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketClientTransport
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-IEU7OE5W.js";
|
|
4
|
+
import "../../../chunk-SZTOUKL7.js";
|
|
5
5
|
import "../../../chunk-R6H2BIMC.js";
|
|
6
|
-
import "../../../chunk-
|
|
6
|
+
import "../../../chunk-V2YJRBRX.js";
|
|
7
7
|
import "../../../chunk-ZE4MX7DF.js";
|
|
8
8
|
import "../../../chunk-SLUSVGQH.js";
|
|
9
9
|
export {
|
|
@@ -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) {
|
|
@@ -823,13 +823,14 @@ var defaultOptions2 = {
|
|
|
823
823
|
};
|
|
824
824
|
var WebSocketServerTransport = class extends Transport {
|
|
825
825
|
wss;
|
|
826
|
-
clientId;
|
|
827
826
|
constructor(wss, clientId, providedOptions) {
|
|
828
827
|
const options = { ...defaultOptions2, ...providedOptions };
|
|
829
828
|
super(options.codec, clientId);
|
|
830
829
|
this.wss = wss;
|
|
831
|
-
|
|
832
|
-
|
|
830
|
+
wss.on("listening", () => {
|
|
831
|
+
log?.info(`${this.clientId} -- server is listening`);
|
|
832
|
+
});
|
|
833
|
+
this.wss.on("connection", this.connectionHandler);
|
|
833
834
|
}
|
|
834
835
|
connectionHandler = (ws) => {
|
|
835
836
|
let conn = void 0;
|
|
@@ -852,9 +853,6 @@ var WebSocketServerTransport = class extends Transport {
|
|
|
852
853
|
);
|
|
853
854
|
};
|
|
854
855
|
};
|
|
855
|
-
setupConnectionStatusListeners() {
|
|
856
|
-
this.wss.on("connection", this.connectionHandler);
|
|
857
|
-
}
|
|
858
856
|
async createNewConnection(to) {
|
|
859
857
|
const err = `${this.clientId} -- failed to send msg to ${to}, client probably dropped`;
|
|
860
858
|
log?.warn(err);
|
|
@@ -879,10 +877,11 @@ var RiverUncaughtSchema = import_typebox2.Type.Object({
|
|
|
879
877
|
});
|
|
880
878
|
|
|
881
879
|
// util/testHelpers.ts
|
|
880
|
+
var import_nanoid2 = require("nanoid");
|
|
882
881
|
async function createWebSocketServer(server) {
|
|
883
882
|
return new import_ws.WebSocketServer({ server });
|
|
884
883
|
}
|
|
885
|
-
|
|
884
|
+
function onWsServerReady(server) {
|
|
886
885
|
return new Promise((resolve, reject) => {
|
|
887
886
|
server.listen(() => {
|
|
888
887
|
const addr = server.address();
|
|
@@ -894,6 +893,11 @@ async function onServerReady(server) {
|
|
|
894
893
|
});
|
|
895
894
|
});
|
|
896
895
|
}
|
|
896
|
+
function onUnixSocketServeReady(server, path) {
|
|
897
|
+
return new Promise((resolve) => {
|
|
898
|
+
server.listen(path, resolve);
|
|
899
|
+
});
|
|
900
|
+
}
|
|
897
901
|
async function createLocalWebSocketClient(port) {
|
|
898
902
|
const sock = new import_isomorphic_ws.default(`ws://localhost:${port}`);
|
|
899
903
|
sock.binaryType = "arraybuffer";
|
|
@@ -993,6 +997,9 @@ async function asClientUpload(state, proc, init, extendedContext) {
|
|
|
993
997
|
return [input, result];
|
|
994
998
|
}
|
|
995
999
|
}
|
|
1000
|
+
var getUnixSocketPath = () => {
|
|
1001
|
+
return process.platform === "win32" ? `\\\\?\\pipe\\${(0, import_nanoid2.nanoid)()}` : `/tmp/${(0, import_nanoid2.nanoid)()}.sock`;
|
|
1002
|
+
};
|
|
996
1003
|
// Annotate the CommonJS export names for ESM import in node:
|
|
997
1004
|
0 && (module.exports = {
|
|
998
1005
|
asClientRpc,
|
|
@@ -1003,8 +1010,10 @@ async function asClientUpload(state, proc, init, extendedContext) {
|
|
|
1003
1010
|
createLocalWebSocketClient,
|
|
1004
1011
|
createWebSocketServer,
|
|
1005
1012
|
createWsTransports,
|
|
1013
|
+
getUnixSocketPath,
|
|
1006
1014
|
iterNext,
|
|
1007
|
-
|
|
1015
|
+
onUnixSocketServeReady,
|
|
1016
|
+
onWsServerReady,
|
|
1008
1017
|
payloadToTransportMessage,
|
|
1009
1018
|
waitForMessage
|
|
1010
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
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
4
|
} from "../chunk-IYRPZPSQ.js";
|
|
5
|
-
import "../chunk-ORAG7IAU.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,16 +63,16 @@
|
|
|
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"
|
|
63
71
|
},
|
|
64
72
|
"scripts": {
|
|
65
73
|
"check": "tsc --noEmit && npx prettier . --check",
|
|
66
74
|
"format": "npx prettier . --write",
|
|
67
|
-
"build": "tsup && du -sh dist",
|
|
75
|
+
"build": "rm -rf dist && tsup && du -sh dist",
|
|
68
76
|
"prepack": "npm run build",
|
|
69
77
|
"release": "npm publish --access public",
|
|
70
78
|
"test:ui": "echo \"remember to go to /__vitest__ in the webview\" && vitest --ui --api.host 0.0.0.0 --api.port 3000",
|