@replit/river 0.10.11 → 0.10.13

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.
@@ -42,6 +42,13 @@ var WebSocketClientTransport = class extends Transport {
42
42
  this.reconnectPromises = /* @__PURE__ */ new Map();
43
43
  this.createNewConnection(this.serverId);
44
44
  }
45
+ reopen() {
46
+ if (this.state === "destroyed") {
47
+ throw new Error("cant reopen a destroyed connection");
48
+ }
49
+ this.state = "open";
50
+ this.createNewConnection(this.serverId);
51
+ }
45
52
  async createNewConnection(to, attempt = 0) {
46
53
  if (this.state === "destroyed") {
47
54
  throw new Error("cant reopen a destroyed connection");
@@ -11,7 +11,9 @@ import '../types-3e5768ec.js';
11
11
  * @template T - An array of services.
12
12
  */
13
13
  type ServiceDefs<T extends AnyService[] = AnyService[]> = {
14
- [K in T[number]['name']]: T[number];
14
+ [K in T[number]['name']]: Extract<T[number], {
15
+ name: K;
16
+ }>;
15
17
  };
16
18
  /**
17
19
  * Builds service definitions based on an array of services.
@@ -11,7 +11,9 @@ import '../types-3e5768ec.js';
11
11
  * @template T - An array of services.
12
12
  */
13
13
  type ServiceDefs<T extends AnyService[] = AnyService[]> = {
14
- [K in T[number]['name']]: T[number];
14
+ [K in T[number]['name']]: Extract<T[number], {
15
+ name: K;
16
+ }>;
15
17
  };
16
18
  /**
17
19
  * Builds service definitions based on an array of services.
@@ -432,6 +432,13 @@ var WebSocketClientTransport = class extends Transport {
432
432
  this.reconnectPromises = /* @__PURE__ */ new Map();
433
433
  this.createNewConnection(this.serverId);
434
434
  }
435
+ reopen() {
436
+ if (this.state === "destroyed") {
437
+ throw new Error("cant reopen a destroyed connection");
438
+ }
439
+ this.state = "open";
440
+ this.createNewConnection(this.serverId);
441
+ }
435
442
  async createNewConnection(to, attempt = 0) {
436
443
  if (this.state === "destroyed") {
437
444
  throw new Error("cant reopen a destroyed connection");
@@ -36,6 +36,7 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
36
36
  * @param providedOptions An optional object containing configuration options for the transport.
37
37
  */
38
38
  constructor(wsGetter: () => Promise<WebSocket>, sessionId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
39
+ reopen(): void;
39
40
  createNewConnection(to: string, attempt?: number): Promise<void>;
40
41
  close(): Promise<void>;
41
42
  destroy(): Promise<void>;
@@ -36,6 +36,7 @@ declare class WebSocketClientTransport extends Transport<WebSocketConnection> {
36
36
  * @param providedOptions An optional object containing configuration options for the transport.
37
37
  */
38
38
  constructor(wsGetter: () => Promise<WebSocket>, sessionId: TransportClientId, serverId: TransportClientId, providedOptions?: Partial<Options>);
39
+ reopen(): void;
39
40
  createNewConnection(to: string, attempt?: number): Promise<void>;
40
41
  close(): Promise<void>;
41
42
  destroy(): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WebSocketClientTransport
3
- } from "../../../chunk-KW5VFJRN.js";
3
+ } from "../../../chunk-5IC5XMWK.js";
4
4
  import "../../../chunk-L7D75G4K.js";
5
5
  import "../../../chunk-R6H2BIMC.js";
6
6
  import "../../../chunk-LQXPKF3A.js";
@@ -205,6 +205,10 @@ declare abstract class Transport<ConnType extends Connection> {
205
205
  * The downstream implementation needs to implement this. If the downstream
206
206
  * transport cannot make new outgoing connections (e.g. a server transport),
207
207
  * it is ok to log an error and return.
208
+ *
209
+ * Consumers of river should never need to call this directly.
210
+ * Instead, look for a `reopen` method on the transport.
211
+ *
208
212
  * @param to The client ID of the node to connect to.
209
213
  * @returns The new connection object.
210
214
  */
@@ -205,6 +205,10 @@ declare abstract class Transport<ConnType extends Connection> {
205
205
  * The downstream implementation needs to implement this. If the downstream
206
206
  * transport cannot make new outgoing connections (e.g. a server transport),
207
207
  * it is ok to log an error and return.
208
+ *
209
+ * Consumers of river should never need to call this directly.
210
+ * Instead, look for a `reopen` method on the transport.
211
+ *
208
212
  * @param to The client ID of the node to connect to.
209
213
  * @returns The new connection object.
210
214
  */
@@ -469,6 +469,13 @@ var WebSocketClientTransport = class extends Transport {
469
469
  this.reconnectPromises = /* @__PURE__ */ new Map();
470
470
  this.createNewConnection(this.serverId);
471
471
  }
472
+ reopen() {
473
+ if (this.state === "destroyed") {
474
+ throw new Error("cant reopen a destroyed connection");
475
+ }
476
+ this.state = "open";
477
+ this.createNewConnection(this.serverId);
478
+ }
472
479
  async createNewConnection(to, attempt = 0) {
473
480
  if (this.state === "destroyed") {
474
481
  throw new Error("cant reopen a destroyed connection");
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-3JGVFWKQ.js";
5
5
  import {
6
6
  WebSocketClientTransport
7
- } from "../chunk-KW5VFJRN.js";
7
+ } from "../chunk-5IC5XMWK.js";
8
8
  import {
9
9
  WebSocketServerTransport
10
10
  } from "../chunk-PJ2EUO7O.js";
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.11",
4
+ "version": "0.10.13",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -63,11 +63,11 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/ws": "^8.5.5",
66
- "@vitest/ui": "^1.1.0",
66
+ "@vitest/ui": "^1.2.1",
67
67
  "prettier": "^3.0.0",
68
68
  "tsup": "^7.2.0",
69
69
  "typescript": "^5.2.2",
70
- "vitest": "^1.1.0"
70
+ "vitest": "^1.2.1"
71
71
  },
72
72
  "scripts": {
73
73
  "check": "tsc --noEmit && npx prettier . --check",