@replit/river 0.18.3 → 0.18.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-7OS34AWW.js → chunk-6Q3MSICL.js} +19 -12
- package/dist/{procedures-85e52b9c.d.ts → procedures-bfffcb0b.d.ts} +1 -1
- package/dist/router/index.cjs +22 -14
- package/dist/router/index.d.cts +6 -6
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.js +4 -2
- package/dist/util/testHelpers.d.cts +1 -1
- package/dist/util/testHelpers.d.ts +1 -1
- package/dist/util/testHelpers.js +1 -1
- package/package.json +3 -2
|
@@ -10,6 +10,15 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// router/services.ts
|
|
12
12
|
import { Type } from "@sinclair/typebox";
|
|
13
|
+
function serializeSchema(services) {
|
|
14
|
+
return Object.entries(services).reduce(
|
|
15
|
+
(acc, [name, value]) => {
|
|
16
|
+
acc[name] = value.serialize();
|
|
17
|
+
return acc;
|
|
18
|
+
},
|
|
19
|
+
{}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
13
22
|
var ServiceSchema = class _ServiceSchema {
|
|
14
23
|
/**
|
|
15
24
|
* Factory function for creating a fresh state.
|
|
@@ -887,7 +896,6 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
887
896
|
import { Value } from "@sinclair/typebox/value";
|
|
888
897
|
var RiverServer = class {
|
|
889
898
|
transport;
|
|
890
|
-
serviceDefs;
|
|
891
899
|
services;
|
|
892
900
|
contextMap;
|
|
893
901
|
// map of streamId to ProcStream
|
|
@@ -896,7 +904,6 @@ var RiverServer = class {
|
|
|
896
904
|
clientStreams;
|
|
897
905
|
disconnectedSessions;
|
|
898
906
|
constructor(transport, services, extendedContext) {
|
|
899
|
-
this.serviceDefs = services;
|
|
900
907
|
const instances = {};
|
|
901
908
|
this.services = instances;
|
|
902
909
|
this.contextMap = /* @__PURE__ */ new Map();
|
|
@@ -918,15 +925,6 @@ var RiverServer = class {
|
|
|
918
925
|
get streams() {
|
|
919
926
|
return this.streamMap;
|
|
920
927
|
}
|
|
921
|
-
serialize() {
|
|
922
|
-
return Object.entries(this.serviceDefs).reduce(
|
|
923
|
-
(acc, [name, value]) => {
|
|
924
|
-
acc[name] = value.serialize();
|
|
925
|
-
return acc;
|
|
926
|
-
},
|
|
927
|
-
{}
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
928
|
onMessage = async (message) => {
|
|
931
929
|
if (message.to !== this.transport.clientId) {
|
|
932
930
|
log?.info(`got msg with destination that isn't this server, ignoring`, {
|
|
@@ -966,6 +964,14 @@ var RiverServer = class {
|
|
|
966
964
|
this.transport.removeEventListener("message", this.onMessage);
|
|
967
965
|
this.transport.removeEventListener("sessionStatus", this.onSessionStatus);
|
|
968
966
|
await Promise.all([...this.streamMap.keys()].map(this.cleanupStream));
|
|
967
|
+
for (const context of this.contextMap.values()) {
|
|
968
|
+
if (Symbol.dispose in context.state) {
|
|
969
|
+
const dispose = context.state[Symbol.dispose];
|
|
970
|
+
if (typeof dispose === "function") {
|
|
971
|
+
dispose();
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
969
975
|
}
|
|
970
976
|
createNewProcStream(message) {
|
|
971
977
|
if (!isStreamOpen(message.controlFlags)) {
|
|
@@ -1241,9 +1247,10 @@ function createServer(transport, services, extendedContext) {
|
|
|
1241
1247
|
}
|
|
1242
1248
|
|
|
1243
1249
|
// package.json
|
|
1244
|
-
var version = "0.18.
|
|
1250
|
+
var version = "0.18.5";
|
|
1245
1251
|
|
|
1246
1252
|
export {
|
|
1253
|
+
serializeSchema,
|
|
1247
1254
|
ServiceSchema,
|
|
1248
1255
|
Procedure,
|
|
1249
1256
|
pushable,
|
|
@@ -58,7 +58,7 @@ type ServiceContextWithState<State> = ServiceContext & {
|
|
|
58
58
|
state: State;
|
|
59
59
|
};
|
|
60
60
|
type ServiceContextWithTransportInfo<State> = ServiceContext & {
|
|
61
|
-
state: State
|
|
61
|
+
state: Omit<State, typeof Symbol.dispose>;
|
|
62
62
|
to: TransportClientId;
|
|
63
63
|
from: TransportClientId;
|
|
64
64
|
streamId: string;
|
package/dist/router/index.cjs
CHANGED
|
@@ -28,12 +28,22 @@ __export(router_exports, {
|
|
|
28
28
|
ServiceSchema: () => ServiceSchema,
|
|
29
29
|
UNCAUGHT_ERROR: () => UNCAUGHT_ERROR,
|
|
30
30
|
createClient: () => createClient,
|
|
31
|
-
createServer: () => createServer
|
|
31
|
+
createServer: () => createServer,
|
|
32
|
+
serializeSchema: () => serializeSchema
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(router_exports);
|
|
34
35
|
|
|
35
36
|
// router/services.ts
|
|
36
37
|
var import_typebox = require("@sinclair/typebox");
|
|
38
|
+
function serializeSchema(services) {
|
|
39
|
+
return Object.entries(services).reduce(
|
|
40
|
+
(acc, [name, value]) => {
|
|
41
|
+
acc[name] = value.serialize();
|
|
42
|
+
return acc;
|
|
43
|
+
},
|
|
44
|
+
{}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
37
47
|
var ServiceSchema = class _ServiceSchema {
|
|
38
48
|
/**
|
|
39
49
|
* Factory function for creating a fresh state.
|
|
@@ -983,7 +993,6 @@ function coerceErrorString(err) {
|
|
|
983
993
|
// router/server.ts
|
|
984
994
|
var RiverServer = class {
|
|
985
995
|
transport;
|
|
986
|
-
serviceDefs;
|
|
987
996
|
services;
|
|
988
997
|
contextMap;
|
|
989
998
|
// map of streamId to ProcStream
|
|
@@ -992,7 +1001,6 @@ var RiverServer = class {
|
|
|
992
1001
|
clientStreams;
|
|
993
1002
|
disconnectedSessions;
|
|
994
1003
|
constructor(transport, services, extendedContext) {
|
|
995
|
-
this.serviceDefs = services;
|
|
996
1004
|
const instances = {};
|
|
997
1005
|
this.services = instances;
|
|
998
1006
|
this.contextMap = /* @__PURE__ */ new Map();
|
|
@@ -1014,15 +1022,6 @@ var RiverServer = class {
|
|
|
1014
1022
|
get streams() {
|
|
1015
1023
|
return this.streamMap;
|
|
1016
1024
|
}
|
|
1017
|
-
serialize() {
|
|
1018
|
-
return Object.entries(this.serviceDefs).reduce(
|
|
1019
|
-
(acc, [name, value]) => {
|
|
1020
|
-
acc[name] = value.serialize();
|
|
1021
|
-
return acc;
|
|
1022
|
-
},
|
|
1023
|
-
{}
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
1025
|
onMessage = async (message) => {
|
|
1027
1026
|
if (message.to !== this.transport.clientId) {
|
|
1028
1027
|
log?.info(`got msg with destination that isn't this server, ignoring`, {
|
|
@@ -1062,6 +1061,14 @@ var RiverServer = class {
|
|
|
1062
1061
|
this.transport.removeEventListener("message", this.onMessage);
|
|
1063
1062
|
this.transport.removeEventListener("sessionStatus", this.onSessionStatus);
|
|
1064
1063
|
await Promise.all([...this.streamMap.keys()].map(this.cleanupStream));
|
|
1064
|
+
for (const context of this.contextMap.values()) {
|
|
1065
|
+
if (Symbol.dispose in context.state) {
|
|
1066
|
+
const dispose = context.state[Symbol.dispose];
|
|
1067
|
+
if (typeof dispose === "function") {
|
|
1068
|
+
dispose();
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1065
1072
|
}
|
|
1066
1073
|
createNewProcStream(message) {
|
|
1067
1074
|
if (!isStreamOpen(message.controlFlags)) {
|
|
@@ -1337,7 +1344,7 @@ function createServer(transport, services, extendedContext) {
|
|
|
1337
1344
|
}
|
|
1338
1345
|
|
|
1339
1346
|
// package.json
|
|
1340
|
-
var version = "0.18.
|
|
1347
|
+
var version = "0.18.5";
|
|
1341
1348
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1342
1349
|
0 && (module.exports = {
|
|
1343
1350
|
Err,
|
|
@@ -1348,5 +1355,6 @@ var version = "0.18.3";
|
|
|
1348
1355
|
ServiceSchema,
|
|
1349
1356
|
UNCAUGHT_ERROR,
|
|
1350
1357
|
createClient,
|
|
1351
|
-
createServer
|
|
1358
|
+
createServer,
|
|
1359
|
+
serializeSchema
|
|
1352
1360
|
});
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TUnion, Static } from '@sinclair/typebox';
|
|
2
|
-
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-
|
|
3
|
-
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-
|
|
2
|
+
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-bfffcb0b.js';
|
|
3
|
+
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-bfffcb0b.js';
|
|
4
4
|
import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-d412ca83.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import { T as TransportClientId } from '../index-46ed19d8.js';
|
|
@@ -103,6 +103,8 @@ interface SerializedServiceSchema {
|
|
|
103
103
|
init?: PayloadType;
|
|
104
104
|
}>;
|
|
105
105
|
}
|
|
106
|
+
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
107
|
+
declare function serializeSchema(services: AnyServiceSchemaMap): SerializedServerSchema;
|
|
106
108
|
/**
|
|
107
109
|
* The schema for a {@link Service}. This is used to define a service, specifically
|
|
108
110
|
* its initial state and procedures.
|
|
@@ -387,7 +389,6 @@ declare const createClient: <ServiceSchemaMap extends AnyServiceSchemaMap>(trans
|
|
|
387
389
|
interface Server<Services extends AnyServiceSchemaMap> {
|
|
388
390
|
services: InstantiatedServiceSchemaMap<Services>;
|
|
389
391
|
streams: Map<string, ProcStream>;
|
|
390
|
-
serialize(): SerializedServerSchema;
|
|
391
392
|
close(): Promise<void>;
|
|
392
393
|
}
|
|
393
394
|
interface ProcStream {
|
|
@@ -401,7 +402,6 @@ interface ProcStream {
|
|
|
401
402
|
inputHandler: Promise<unknown>;
|
|
402
403
|
};
|
|
403
404
|
}
|
|
404
|
-
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
405
405
|
/**
|
|
406
406
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
407
407
|
* The server tracks the state of each service along with open streams and the extended context object.
|
|
@@ -412,6 +412,6 @@ type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
|
412
412
|
*/
|
|
413
413
|
declare function createServer<Services extends AnyServiceSchemaMap>(transport: ServerTransport<Connection>, services: Services, extendedContext?: Omit<ServiceContext, 'state'>): Server<Services>;
|
|
414
414
|
|
|
415
|
-
var version = "0.18.
|
|
415
|
+
var version = "0.18.5";
|
|
416
416
|
|
|
417
|
-
export { Client, PayloadType, ProcErrors, ProcHandler, ProcInit, ProcInput, ProcOutput, ProcType, ProcedureMap, version as RIVER_VERSION, Result, RiverError, RiverUncaughtSchema, Server, Service, ServiceConfiguration, ServiceContext, ServiceSchema, createClient, createServer };
|
|
417
|
+
export { Client, PayloadType, ProcErrors, ProcHandler, ProcInit, ProcInput, ProcOutput, ProcType, ProcedureMap, version as RIVER_VERSION, Result, RiverError, RiverUncaughtSchema, SerializedServerSchema, Server, Service, ServiceConfiguration, ServiceContext, ServiceSchema, createClient, createServer, serializeSchema };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TUnion, Static } from '@sinclair/typebox';
|
|
2
|
-
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-
|
|
3
|
-
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-
|
|
2
|
+
import { e as ProcedureMap, P as PayloadType, c as RiverUncaughtSchema, U as Unbranded, B as Branded, A as AnyProcedure, R as RiverError, b as Result, S as ServiceContext } from '../procedures-bfffcb0b.js';
|
|
3
|
+
export { E as Err, O as Ok, a as Procedure, d as ProcedureResult, f as RPCProcedure, m as RiverErrorSchema, j as ServiceContextWithState, k as ServiceContextWithTransportInfo, i as StreamProcedure, h as SubscriptionProcedure, l as UNCAUGHT_ERROR, g as UploadProcedure, V as ValidProcType } from '../procedures-bfffcb0b.js';
|
|
4
4
|
import { b as ClientTransport, C as Connection, c as ServerTransport } from '../index-d412ca83.js';
|
|
5
5
|
import { Pushable } from 'it-pushable';
|
|
6
6
|
import { T as TransportClientId } from '../index-46ed19d8.js';
|
|
@@ -103,6 +103,8 @@ interface SerializedServiceSchema {
|
|
|
103
103
|
init?: PayloadType;
|
|
104
104
|
}>;
|
|
105
105
|
}
|
|
106
|
+
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
107
|
+
declare function serializeSchema(services: AnyServiceSchemaMap): SerializedServerSchema;
|
|
106
108
|
/**
|
|
107
109
|
* The schema for a {@link Service}. This is used to define a service, specifically
|
|
108
110
|
* its initial state and procedures.
|
|
@@ -387,7 +389,6 @@ declare const createClient: <ServiceSchemaMap extends AnyServiceSchemaMap>(trans
|
|
|
387
389
|
interface Server<Services extends AnyServiceSchemaMap> {
|
|
388
390
|
services: InstantiatedServiceSchemaMap<Services>;
|
|
389
391
|
streams: Map<string, ProcStream>;
|
|
390
|
-
serialize(): SerializedServerSchema;
|
|
391
392
|
close(): Promise<void>;
|
|
392
393
|
}
|
|
393
394
|
interface ProcStream {
|
|
@@ -401,7 +402,6 @@ interface ProcStream {
|
|
|
401
402
|
inputHandler: Promise<unknown>;
|
|
402
403
|
};
|
|
403
404
|
}
|
|
404
|
-
type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
405
405
|
/**
|
|
406
406
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
407
407
|
* The server tracks the state of each service along with open streams and the extended context object.
|
|
@@ -412,6 +412,6 @@ type SerializedServerSchema = Record<string, SerializedServiceSchema>;
|
|
|
412
412
|
*/
|
|
413
413
|
declare function createServer<Services extends AnyServiceSchemaMap>(transport: ServerTransport<Connection>, services: Services, extendedContext?: Omit<ServiceContext, 'state'>): Server<Services>;
|
|
414
414
|
|
|
415
|
-
var version = "0.18.
|
|
415
|
+
var version = "0.18.5";
|
|
416
416
|
|
|
417
|
-
export { Client, PayloadType, ProcErrors, ProcHandler, ProcInit, ProcInput, ProcOutput, ProcType, ProcedureMap, version as RIVER_VERSION, Result, RiverError, RiverUncaughtSchema, Server, Service, ServiceConfiguration, ServiceContext, ServiceSchema, createClient, createServer };
|
|
417
|
+
export { Client, PayloadType, ProcErrors, ProcHandler, ProcInit, ProcInput, ProcOutput, ProcType, ProcedureMap, version as RIVER_VERSION, Result, RiverError, RiverUncaughtSchema, SerializedServerSchema, Server, Service, ServiceConfiguration, ServiceContext, ServiceSchema, createClient, createServer, serializeSchema };
|
package/dist/router/index.js
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
UNCAUGHT_ERROR,
|
|
8
8
|
createClient,
|
|
9
9
|
createServer,
|
|
10
|
+
serializeSchema,
|
|
10
11
|
version
|
|
11
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-6Q3MSICL.js";
|
|
12
13
|
import "../chunk-VH3NGOXQ.js";
|
|
13
14
|
import "../chunk-WER2DWCP.js";
|
|
14
15
|
export {
|
|
@@ -20,5 +21,6 @@ export {
|
|
|
20
21
|
ServiceSchema,
|
|
21
22
|
UNCAUGHT_ERROR,
|
|
22
23
|
createClient,
|
|
23
|
-
createServer
|
|
24
|
+
createServer,
|
|
25
|
+
serializeSchema
|
|
24
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Static } from '@sinclair/typebox';
|
|
2
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-
|
|
2
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-bfffcb0b.js';
|
|
3
3
|
import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-d412ca83.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-46ed19d8.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Static } from '@sinclair/typebox';
|
|
2
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-
|
|
2
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema, d as ProcedureResult } from '../procedures-bfffcb0b.js';
|
|
3
3
|
import { T as Transport, C as Connection, S as SessionOptions, a as Session } from '../index-d412ca83.js';
|
|
4
4
|
import * as it_pushable from 'it-pushable';
|
|
5
5
|
import { P as PartialTransportMessage, O as OpaqueTransportMessage } from '../index-46ed19d8.js';
|
package/dist/util/testHelpers.js
CHANGED
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.18.
|
|
4
|
+
"version": "0.18.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
"prettier": "^3.0.0",
|
|
69
69
|
"tsup": "^7.2.0",
|
|
70
70
|
"typescript": "^5.2.2",
|
|
71
|
-
"vitest": "^1.3.1"
|
|
71
|
+
"vitest": "^1.3.1",
|
|
72
|
+
"vscode-langservers-extracted": "4.8.0"
|
|
72
73
|
},
|
|
73
74
|
"scripts": {
|
|
74
75
|
"check": "tsc --noEmit && npm run format && npm run lint",
|