@replit/river 0.13.10 → 0.14.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/README.md +11 -3
- package/dist/{builder-8c80cf47.d.ts → builder-0547e840.d.ts} +1 -1
- package/dist/{chunk-5ETR5EVH.js → chunk-NJ25LQPI.js} +1 -3
- package/dist/{chunk-KUQ4OT4D.js → chunk-TVRCTAL2.js} +52 -48
- package/dist/{chunk-IPSTJ7NW.js → chunk-WYUFVZC3.js} +1 -1
- package/dist/{chunk-44GN4JUR.js → chunk-ZD5NJJXR.js} +1 -1
- package/dist/{connection-ebd00fd5.d.ts → connection-6c569569.d.ts} +1 -1
- package/dist/{connection-88c9269b.d.ts → connection-ec72fdb0.d.ts} +1 -1
- package/dist/{index-047087cb.d.ts → index-d1452d8f.d.ts} +1 -2
- package/dist/router/index.cjs +52 -48
- package/dist/router/index.d.cts +4 -4
- package/dist/router/index.d.ts +4 -4
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/uds/client.cjs +3 -8
- package/dist/transport/impls/uds/client.d.cts +3 -4
- package/dist/transport/impls/uds/client.d.ts +3 -4
- package/dist/transport/impls/uds/client.js +4 -7
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/uds/server.js +2 -2
- package/dist/transport/impls/ws/client.cjs +3 -15
- package/dist/transport/impls/ws/client.d.cts +3 -5
- package/dist/transport/impls/ws/client.d.ts +3 -5
- package/dist/transport/impls/ws/client.js +4 -14
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +1 -3
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# River
|
|
2
|
+
|
|
3
|
+
## Long-lived Streaming Remote Procedure Calls
|
|
2
4
|
|
|
3
5
|
It's like tRPC/gRPC but with
|
|
4
6
|
|
|
@@ -23,6 +25,9 @@ npm i @replit/river @sinclair/typebox
|
|
|
23
25
|
npm i ws isomorphic-ws
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
If you are planning on using River with React, also check out [`@replit/river-react`](https://npmjs.com/package/@replit/river-react)
|
|
29
|
+
which provides some handy hooks and contexts for playing nicely with the React lifecycle.
|
|
30
|
+
|
|
26
31
|
## Writing Services
|
|
27
32
|
|
|
28
33
|
### Concepts
|
|
@@ -103,10 +108,13 @@ const websocketUrl = `ws://localhost:3000`;
|
|
|
103
108
|
const transport = new WebSocketClientTransport(
|
|
104
109
|
async () => new WebSocket(websocketUrl),
|
|
105
110
|
'my-client-id',
|
|
106
|
-
'SERVER',
|
|
107
111
|
);
|
|
108
112
|
|
|
109
|
-
const client = createClient<ServiceSurface>(
|
|
113
|
+
const client = createClient<ServiceSurface>(
|
|
114
|
+
transport,
|
|
115
|
+
'SERVER', // transport id of the server in the previous step
|
|
116
|
+
true, // whether to eagerly connect to the server on creation (optional argument)
|
|
117
|
+
);
|
|
110
118
|
|
|
111
119
|
// we get full type safety on `client`
|
|
112
120
|
// client.<service name>.<procedure name>.<procedure type>()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
|
|
2
2
|
import { Pushable } from 'it-pushable';
|
|
3
|
-
import { b as TransportClientId, d as Session, C as Connection } from './index-
|
|
3
|
+
import { b as TransportClientId, d as Session, C as Connection } from './index-d1452d8f.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The context for services/procedures. This is used only on
|
|
@@ -530,10 +530,8 @@ var ClientTransport = class extends Transport {
|
|
|
530
530
|
*/
|
|
531
531
|
inflightConnectionPromises;
|
|
532
532
|
tryReconnecting = true;
|
|
533
|
-
|
|
534
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
533
|
+
constructor(clientId, providedOptions) {
|
|
535
534
|
super(clientId, providedOptions);
|
|
536
|
-
this.connectedTo = connectedTo;
|
|
537
535
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
538
536
|
}
|
|
539
537
|
handleConnection(conn, to) {
|
|
@@ -428,56 +428,60 @@ function _createRecursiveProxy(callback, path) {
|
|
|
428
428
|
});
|
|
429
429
|
return proxy;
|
|
430
430
|
}
|
|
431
|
-
var createClient = (transport
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (!(serviceName && procName && procType)) {
|
|
435
|
-
throw new Error(
|
|
436
|
-
"invalid river call, ensure the service and procedure you are calling exists"
|
|
437
|
-
);
|
|
431
|
+
var createClient = (transport, serverId, eagerlyConnect = true) => {
|
|
432
|
+
if (eagerlyConnect) {
|
|
433
|
+
void transport.connect(serverId);
|
|
438
434
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
procName
|
|
452
|
-
);
|
|
453
|
-
} else if (procType === "stream") {
|
|
454
|
-
return handleStream(
|
|
455
|
-
transport,
|
|
456
|
-
serverId,
|
|
457
|
-
input,
|
|
458
|
-
serviceName,
|
|
459
|
-
procName
|
|
460
|
-
);
|
|
461
|
-
} else if (procType === "subscribe") {
|
|
462
|
-
return handleSubscribe(
|
|
463
|
-
transport,
|
|
464
|
-
serverId,
|
|
465
|
-
input,
|
|
466
|
-
serviceName,
|
|
467
|
-
procName
|
|
468
|
-
);
|
|
469
|
-
} else if (procType === "upload") {
|
|
470
|
-
return handleUpload(
|
|
471
|
-
transport,
|
|
472
|
-
serverId,
|
|
473
|
-
input,
|
|
474
|
-
serviceName,
|
|
475
|
-
procName
|
|
435
|
+
return _createRecursiveProxy(async (opts) => {
|
|
436
|
+
const [serviceName, procName, procType] = [...opts.path];
|
|
437
|
+
if (!(serviceName && procName && procType)) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
"invalid river call, ensure the service and procedure you are calling exists"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
const [input] = opts.args;
|
|
443
|
+
log?.info(
|
|
444
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
445
|
+
input
|
|
446
|
+
)}`
|
|
476
447
|
);
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
448
|
+
if (procType === "rpc") {
|
|
449
|
+
return handleRpc(
|
|
450
|
+
transport,
|
|
451
|
+
serverId,
|
|
452
|
+
input,
|
|
453
|
+
serviceName,
|
|
454
|
+
procName
|
|
455
|
+
);
|
|
456
|
+
} else if (procType === "stream") {
|
|
457
|
+
return handleStream(
|
|
458
|
+
transport,
|
|
459
|
+
serverId,
|
|
460
|
+
input,
|
|
461
|
+
serviceName,
|
|
462
|
+
procName
|
|
463
|
+
);
|
|
464
|
+
} else if (procType === "subscribe") {
|
|
465
|
+
return handleSubscribe(
|
|
466
|
+
transport,
|
|
467
|
+
serverId,
|
|
468
|
+
input,
|
|
469
|
+
serviceName,
|
|
470
|
+
procName
|
|
471
|
+
);
|
|
472
|
+
} else if (procType === "upload") {
|
|
473
|
+
return handleUpload(
|
|
474
|
+
transport,
|
|
475
|
+
serverId,
|
|
476
|
+
input,
|
|
477
|
+
serviceName,
|
|
478
|
+
procName
|
|
479
|
+
);
|
|
480
|
+
} else {
|
|
481
|
+
throw new Error(`invalid river call, unknown procedure type ${procType}`);
|
|
482
|
+
}
|
|
483
|
+
}, []);
|
|
484
|
+
};
|
|
481
485
|
function createSessionDisconnectHandler(from, cb) {
|
|
482
486
|
return (evt) => {
|
|
483
487
|
if (evt.status === "disconnect" && evt.session.to === from) {
|
|
@@ -386,8 +386,7 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
|
|
|
386
386
|
*/
|
|
387
387
|
inflightConnectionPromises: Map<TransportClientId, Promise<ConnType>>;
|
|
388
388
|
tryReconnecting: boolean;
|
|
389
|
-
|
|
390
|
-
constructor(clientId: TransportClientId, connectedTo: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
389
|
+
constructor(clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
391
390
|
protected handleConnection(conn: ConnType, to: TransportClientId): void;
|
|
392
391
|
receiveHandshakeResponseMessage(data: Uint8Array): false | {
|
|
393
392
|
instanceId: string;
|
package/dist/router/index.cjs
CHANGED
|
@@ -514,56 +514,60 @@ function _createRecursiveProxy(callback, path) {
|
|
|
514
514
|
});
|
|
515
515
|
return proxy;
|
|
516
516
|
}
|
|
517
|
-
var createClient = (transport
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (!(serviceName && procName && procType)) {
|
|
521
|
-
throw new Error(
|
|
522
|
-
"invalid river call, ensure the service and procedure you are calling exists"
|
|
523
|
-
);
|
|
517
|
+
var createClient = (transport, serverId, eagerlyConnect = true) => {
|
|
518
|
+
if (eagerlyConnect) {
|
|
519
|
+
void transport.connect(serverId);
|
|
524
520
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
procName
|
|
538
|
-
);
|
|
539
|
-
} else if (procType === "stream") {
|
|
540
|
-
return handleStream(
|
|
541
|
-
transport,
|
|
542
|
-
serverId,
|
|
543
|
-
input,
|
|
544
|
-
serviceName,
|
|
545
|
-
procName
|
|
546
|
-
);
|
|
547
|
-
} else if (procType === "subscribe") {
|
|
548
|
-
return handleSubscribe(
|
|
549
|
-
transport,
|
|
550
|
-
serverId,
|
|
551
|
-
input,
|
|
552
|
-
serviceName,
|
|
553
|
-
procName
|
|
554
|
-
);
|
|
555
|
-
} else if (procType === "upload") {
|
|
556
|
-
return handleUpload(
|
|
557
|
-
transport,
|
|
558
|
-
serverId,
|
|
559
|
-
input,
|
|
560
|
-
serviceName,
|
|
561
|
-
procName
|
|
521
|
+
return _createRecursiveProxy(async (opts) => {
|
|
522
|
+
const [serviceName, procName, procType] = [...opts.path];
|
|
523
|
+
if (!(serviceName && procName && procType)) {
|
|
524
|
+
throw new Error(
|
|
525
|
+
"invalid river call, ensure the service and procedure you are calling exists"
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
const [input] = opts.args;
|
|
529
|
+
log?.info(
|
|
530
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
531
|
+
input
|
|
532
|
+
)}`
|
|
562
533
|
);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
534
|
+
if (procType === "rpc") {
|
|
535
|
+
return handleRpc(
|
|
536
|
+
transport,
|
|
537
|
+
serverId,
|
|
538
|
+
input,
|
|
539
|
+
serviceName,
|
|
540
|
+
procName
|
|
541
|
+
);
|
|
542
|
+
} else if (procType === "stream") {
|
|
543
|
+
return handleStream(
|
|
544
|
+
transport,
|
|
545
|
+
serverId,
|
|
546
|
+
input,
|
|
547
|
+
serviceName,
|
|
548
|
+
procName
|
|
549
|
+
);
|
|
550
|
+
} else if (procType === "subscribe") {
|
|
551
|
+
return handleSubscribe(
|
|
552
|
+
transport,
|
|
553
|
+
serverId,
|
|
554
|
+
input,
|
|
555
|
+
serviceName,
|
|
556
|
+
procName
|
|
557
|
+
);
|
|
558
|
+
} else if (procType === "upload") {
|
|
559
|
+
return handleUpload(
|
|
560
|
+
transport,
|
|
561
|
+
serverId,
|
|
562
|
+
input,
|
|
563
|
+
serviceName,
|
|
564
|
+
procName
|
|
565
|
+
);
|
|
566
|
+
} else {
|
|
567
|
+
throw new Error(`invalid river call, unknown procedure type ${procType}`);
|
|
568
|
+
}
|
|
569
|
+
}, []);
|
|
570
|
+
};
|
|
567
571
|
function createSessionDisconnectHandler(from, cb) {
|
|
568
572
|
return (evt) => {
|
|
569
573
|
if (evt.status === "disconnect" && evt.session.to === from) {
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-0547e840.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-0547e840.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-d1452d8f.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -110,6 +110,6 @@ type ServerClient<Srv extends Server<ServiceDefs>> = {
|
|
|
110
110
|
* @param {Transport} transport - The transport to use for communication.
|
|
111
111
|
* @returns The client for the server.
|
|
112
112
|
*/
|
|
113
|
-
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection
|
|
113
|
+
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection>, serverId: TransportClientId, eagerlyConnect?: boolean) => ServerClient<Srv>;
|
|
114
114
|
|
|
115
115
|
export { PayloadType, ProcInput, ProcOutput, ProcType, Result, RiverError, Server, ServerClient, ServiceContext, ServiceDefs, buildServiceDefs, createClient, createServer };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-0547e840.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-0547e840.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-d1452d8f.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -110,6 +110,6 @@ type ServerClient<Srv extends Server<ServiceDefs>> = {
|
|
|
110
110
|
* @param {Transport} transport - The transport to use for communication.
|
|
111
111
|
* @returns The client for the server.
|
|
112
112
|
*/
|
|
113
|
-
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection
|
|
113
|
+
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection>, serverId: TransportClientId, eagerlyConnect?: boolean) => ServerClient<Srv>;
|
|
114
114
|
|
|
115
115
|
export { PayloadType, ProcInput, ProcOutput, ProcType, Result, RiverError, Server, ServerClient, ServiceContext, ServiceDefs, buildServiceDefs, createClient, createServer };
|
package/dist/router/index.js
CHANGED
|
@@ -771,10 +771,8 @@ var ClientTransport = class extends Transport {
|
|
|
771
771
|
*/
|
|
772
772
|
inflightConnectionPromises;
|
|
773
773
|
tryReconnecting = true;
|
|
774
|
-
|
|
775
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
774
|
+
constructor(clientId, providedOptions) {
|
|
776
775
|
super(clientId, providedOptions);
|
|
777
|
-
this.connectedTo = connectedTo;
|
|
778
776
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
779
777
|
}
|
|
780
778
|
handleConnection(conn, to) {
|
|
@@ -899,12 +897,9 @@ var ClientTransport = class extends Transport {
|
|
|
899
897
|
// transport/impls/uds/client.ts
|
|
900
898
|
var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
901
899
|
path;
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
super(clientId, serverId, providedOptions);
|
|
900
|
+
constructor(socketPath, clientId, providedOptions) {
|
|
901
|
+
super(clientId, providedOptions);
|
|
905
902
|
this.path = socketPath;
|
|
906
|
-
this.serverId = serverId;
|
|
907
|
-
void this.connect(serverId);
|
|
908
903
|
}
|
|
909
904
|
async createNewOutgoingConnection(to) {
|
|
910
905
|
const oldConnection = this.connections.get(to);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport,
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as TransportOptions, b as TransportClientId } from '../../../index-d1452d8f.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -7,8 +7,7 @@ import 'node:stream';
|
|
|
7
7
|
|
|
8
8
|
declare class UnixDomainSocketClientTransport extends ClientTransport<UdsConnection> {
|
|
9
9
|
path: string;
|
|
10
|
-
|
|
11
|
-
constructor(socketPath: string, clientId: string, serverId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
10
|
+
constructor(socketPath: string, clientId: string, providedOptions?: Partial<TransportOptions>);
|
|
12
11
|
createNewOutgoingConnection(to: TransportClientId): Promise<UdsConnection>;
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport,
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as TransportOptions, b as TransportClientId } from '../../../index-d1452d8f.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -7,8 +7,7 @@ import 'node:stream';
|
|
|
7
7
|
|
|
8
8
|
declare class UnixDomainSocketClientTransport extends ClientTransport<UdsConnection> {
|
|
9
9
|
path: string;
|
|
10
|
-
|
|
11
|
-
constructor(socketPath: string, clientId: string, serverId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
10
|
+
constructor(socketPath: string, clientId: string, providedOptions?: Partial<TransportOptions>);
|
|
12
11
|
createNewOutgoingConnection(to: TransportClientId): Promise<UdsConnection>;
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZD5NJJXR.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -14,12 +14,9 @@ import "../../../chunk-GZ7HCLLM.js";
|
|
|
14
14
|
import { Socket } from "node:net";
|
|
15
15
|
var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
16
16
|
path;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
super(clientId, serverId, providedOptions);
|
|
17
|
+
constructor(socketPath, clientId, providedOptions) {
|
|
18
|
+
super(clientId, providedOptions);
|
|
20
19
|
this.path = socketPath;
|
|
21
|
-
this.serverId = serverId;
|
|
22
|
-
void this.connect(serverId);
|
|
23
20
|
}
|
|
24
21
|
async createNewOutgoingConnection(to) {
|
|
25
22
|
const oldConnection = this.connections.get(to);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZD5NJJXR.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -677,10 +677,8 @@ var ClientTransport = class extends Transport {
|
|
|
677
677
|
*/
|
|
678
678
|
inflightConnectionPromises;
|
|
679
679
|
tryReconnecting = true;
|
|
680
|
-
|
|
681
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
680
|
+
constructor(clientId, providedOptions) {
|
|
682
681
|
super(clientId, providedOptions);
|
|
683
|
-
this.connectedTo = connectedTo;
|
|
684
682
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
685
683
|
}
|
|
686
684
|
handleConnection(conn, to) {
|
|
@@ -841,7 +839,6 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
841
839
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
842
840
|
*/
|
|
843
841
|
wsGetter;
|
|
844
|
-
serverId;
|
|
845
842
|
/**
|
|
846
843
|
* Creates a new WebSocketClientTransport instance.
|
|
847
844
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -849,18 +846,9 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
849
846
|
* @param serverId The ID of the server this transport is connecting to.
|
|
850
847
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
851
848
|
*/
|
|
852
|
-
constructor(wsGetter, clientId,
|
|
853
|
-
super(clientId,
|
|
849
|
+
constructor(wsGetter, clientId, providedOptions) {
|
|
850
|
+
super(clientId, providedOptions);
|
|
854
851
|
this.wsGetter = wsGetter;
|
|
855
|
-
this.serverId = serverId;
|
|
856
|
-
void this.connect(this.serverId);
|
|
857
|
-
}
|
|
858
|
-
reopen() {
|
|
859
|
-
if (this.state === "destroyed") {
|
|
860
|
-
throw new Error("cant reopen a destroyed connection");
|
|
861
|
-
}
|
|
862
|
-
this.state = "open";
|
|
863
|
-
void this.connect(this.serverId);
|
|
864
852
|
}
|
|
865
853
|
async createNewOutgoingConnection(to) {
|
|
866
854
|
const wsRes = await new Promise((resolve) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
14
14
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
15
15
|
*/
|
|
16
16
|
wsGetter: (to: TransportClientId) => Promise<WebSocket>;
|
|
17
|
-
serverId: TransportClientId;
|
|
18
17
|
/**
|
|
19
18
|
* Creates a new WebSocketClientTransport instance.
|
|
20
19
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -22,8 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
22
21
|
* @param serverId The ID of the server this transport is connecting to.
|
|
23
22
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
24
23
|
*/
|
|
25
|
-
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId,
|
|
26
|
-
reopen(): void;
|
|
24
|
+
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
27
25
|
createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
14
14
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
15
15
|
*/
|
|
16
16
|
wsGetter: (to: TransportClientId) => Promise<WebSocket>;
|
|
17
|
-
serverId: TransportClientId;
|
|
18
17
|
/**
|
|
19
18
|
* Creates a new WebSocketClientTransport instance.
|
|
20
19
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -22,8 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
22
21
|
* @param serverId The ID of the server this transport is connecting to.
|
|
23
22
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
24
23
|
*/
|
|
25
|
-
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId,
|
|
26
|
-
reopen(): void;
|
|
24
|
+
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
27
25
|
createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-WYUFVZC3.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -16,7 +16,6 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
16
16
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
17
17
|
*/
|
|
18
18
|
wsGetter;
|
|
19
|
-
serverId;
|
|
20
19
|
/**
|
|
21
20
|
* Creates a new WebSocketClientTransport instance.
|
|
22
21
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -24,18 +23,9 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
24
23
|
* @param serverId The ID of the server this transport is connecting to.
|
|
25
24
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
26
25
|
*/
|
|
27
|
-
constructor(wsGetter, clientId,
|
|
28
|
-
super(clientId,
|
|
26
|
+
constructor(wsGetter, clientId, providedOptions) {
|
|
27
|
+
super(clientId, providedOptions);
|
|
29
28
|
this.wsGetter = wsGetter;
|
|
30
|
-
this.serverId = serverId;
|
|
31
|
-
void this.connect(this.serverId);
|
|
32
|
-
}
|
|
33
|
-
reopen() {
|
|
34
|
-
if (this.state === "destroyed") {
|
|
35
|
-
throw new Error("cant reopen a destroyed connection");
|
|
36
|
-
}
|
|
37
|
-
this.state = "open";
|
|
38
|
-
void this.connect(this.serverId);
|
|
39
29
|
}
|
|
40
30
|
async createNewOutgoingConnection(to) {
|
|
41
31
|
const wsRes = await new Promise((resolve) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-d1452d8f.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-WYUFVZC3.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import "../../../chunk-H4BYJELI.js";
|
|
9
9
|
import "../../../chunk-GZ7HCLLM.js";
|
package/dist/transport/index.cjs
CHANGED
|
@@ -707,10 +707,8 @@ var ClientTransport = class extends Transport {
|
|
|
707
707
|
*/
|
|
708
708
|
inflightConnectionPromises;
|
|
709
709
|
tryReconnecting = true;
|
|
710
|
-
|
|
711
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
710
|
+
constructor(clientId, providedOptions) {
|
|
712
711
|
super(clientId, providedOptions);
|
|
713
|
-
this.connectedTo = connectedTo;
|
|
714
712
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
715
713
|
}
|
|
716
714
|
handleConnection(conn, to) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-
|
|
1
|
+
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-d1452d8f.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-
|
|
1
|
+
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-d1452d8f.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
package/dist/transport/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-d1452d8f.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-0547e840.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-d1452d8f.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-0547e840.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-TVRCTAL2.js";
|
|
5
5
|
import "../chunk-5IZ2UHWV.js";
|
|
6
6
|
import {
|
|
7
7
|
Session,
|
|
8
8
|
defaultSessionOptions
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NJ25LQPI.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
12
|
} from "../chunk-GFRAOY75.js";
|
package/package.json
CHANGED