@replit/river 0.5.1 → 0.5.2

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.
@@ -4,7 +4,7 @@ import type { Pushable } from 'it-pushable';
4
4
  import { Server } from './server';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import { Result } from './result';
7
- type AsyncIter<T> = AsyncGenerator<T, T, T>;
7
+ type AsyncIter<T> = AsyncGenerator<T, T, unknown>;
8
8
  /**
9
9
  * A helper type to transform an actual service type into a type
10
10
  * we can case to in the proxy.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../router/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACT,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAMlC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,KAAK,SAAS,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,MAAM,SAAS,UAAU,IAAI;KAC7C,QAAQ,IAAI,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAChD,MAAM,EACN,QAAQ,CACT,SAAS,KAAK,GAEX,CACE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,KACvC,OAAO,CACV,MAAM,CACJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EACpC,MAAM,CAAC,UAAU,CAAC,MAAM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QAAQ,IAAI,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAChD,MAAM,EACN,QAAQ,CACT,SAAS,KAAK,GAEX,CACE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,KACvC,OAAO,CACV,MAAM,CACJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EACpC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CACrC,CACF,GAED,MAAM,OAAO,CACX;QACE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC7C,SAAS,CACP,MAAM,CACJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EACpC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CACrC,CACF;QACD,MAAM,IAAI;KACX,CACF;CACN,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI;KACxE,OAAO,IAAI,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;CAC5E,CAAC;AAgCF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,8DACZ,SAAS,sBAgFO,CAAC"}
@@ -1,6 +1,10 @@
1
1
  /// <reference types="node" />
2
+ import { Codec } from '../../codec';
2
3
  import { OpaqueTransportMessage, TransportClientId } from '../message';
3
4
  import { Transport } from '../types';
5
+ interface Options {
6
+ codec: Codec;
7
+ }
4
8
  /**
5
9
  * A transport implementation that uses standard input and output streams.
6
10
  * @extends Transport
@@ -20,7 +24,7 @@ export declare class StdioTransport extends Transport {
20
24
  * @param input - The readable stream to use as input. Defaults to process.stdin.
21
25
  * @param output - The writable stream to use as output. Defaults to process.stdout.
22
26
  */
23
- constructor(clientId: TransportClientId, input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream);
27
+ constructor(clientId: TransportClientId, input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream, providedOptions?: Partial<Options>);
24
28
  /**
25
29
  * Sends a message over the transport.
26
30
  * @param msg - The message to send.
@@ -32,4 +36,5 @@ export declare class StdioTransport extends Transport {
32
36
  */
33
37
  close(): Promise<void>;
34
38
  }
39
+ export {};
35
40
  //# sourceMappingURL=stdio.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../../transport/impls/stdio.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;;GAGG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC3C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAE9B;;;;;OAKG;gBAED,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,GAAE,MAAM,CAAC,cAA8B,EAC5C,MAAM,GAAE,MAAM,CAAC,cAA+B;IAYhD;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM;IAMzC;;OAEG;IACG,KAAK;CACZ"}
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../../transport/impls/stdio.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,UAAU,OAAO;IACf,KAAK,EAAE,KAAK,CAAC;CACd;AAMD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC3C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAE9B;;;;;OAKG;gBAED,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,GAAE,MAAM,CAAC,cAA8B,EAC5C,MAAM,GAAE,MAAM,CAAC,cAA+B,EAC9C,eAAe,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC;IAapC;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM;IAMzC;;OAEG;IACG,KAAK;CACZ"}
@@ -1,6 +1,9 @@
1
1
  import { NaiveJsonCodec } from '../../codec/json';
2
2
  import { Transport } from '../types';
3
3
  import readline from 'readline';
4
+ const defaultOptions = {
5
+ codec: NaiveJsonCodec,
6
+ };
4
7
  /**
5
8
  * A transport implementation that uses standard input and output streams.
6
9
  * @extends Transport
@@ -20,8 +23,9 @@ export class StdioTransport extends Transport {
20
23
  * @param input - The readable stream to use as input. Defaults to process.stdin.
21
24
  * @param output - The writable stream to use as output. Defaults to process.stdout.
22
25
  */
23
- constructor(clientId, input = process.stdin, output = process.stdout) {
24
- super(NaiveJsonCodec, clientId);
26
+ constructor(clientId, input = process.stdin, output = process.stdout, providedOptions) {
27
+ const options = { ...defaultOptions, ...providedOptions };
28
+ super(options.codec, clientId);
25
29
  this.input = input;
26
30
  this.output = output;
27
31
  const rl = readline.createInterface({
@@ -2,8 +2,10 @@
2
2
  import WebSocket from 'isomorphic-ws';
3
3
  import { Transport } from '../types';
4
4
  import { MessageId, OpaqueTransportMessage, TransportClientId } from '../message';
5
+ import { type Codec } from '../../codec';
5
6
  interface Options {
6
7
  retryIntervalMs: number;
8
+ codec: Codec;
7
9
  }
8
10
  type WebSocketResult = {
9
11
  ws: WebSocket;
@@ -41,9 +43,9 @@ export declare class WebSocketTransport extends Transport {
41
43
  * Creates a new WebSocketTransport instance.
42
44
  * @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
43
45
  * @param clientId The ID of the client using the transport.
44
- * @param options An optional object containing configuration options for the transport.
46
+ * @param providedOptions An optional object containing configuration options for the transport.
45
47
  */
46
- constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, options?: Partial<Options>);
48
+ constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<Options>);
47
49
  /**
48
50
  * Begins a new attempt to establish a WebSocket connection.
49
51
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../transport/impls/ws.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,UAAU,OAAO;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAMD,KAAK,eAAe,GAAG;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5C;;;OAGG;IACH,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAE5B;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,EAClC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,OAAO,CA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;OAEG;IACG,KAAK;CAKZ"}
@@ -3,6 +3,7 @@ import { NaiveJsonCodec } from '../../codec/json';
3
3
  import { log } from '../../logging';
4
4
  const defaultOptions = {
5
5
  retryIntervalMs: 250,
6
+ codec: NaiveJsonCodec,
6
7
  };
7
8
  /**
8
9
  * A transport implementation that uses a WebSocket connection with automatic reconnection.
@@ -35,13 +36,14 @@ export class WebSocketTransport extends Transport {
35
36
  * Creates a new WebSocketTransport instance.
36
37
  * @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
37
38
  * @param clientId The ID of the client using the transport.
38
- * @param options An optional object containing configuration options for the transport.
39
+ * @param providedOptions An optional object containing configuration options for the transport.
39
40
  */
40
- constructor(wsGetter, clientId, options) {
41
- super(NaiveJsonCodec, clientId);
41
+ constructor(wsGetter, clientId, providedOptions) {
42
+ const options = { ...defaultOptions, ...providedOptions };
43
+ super(options.codec, clientId);
42
44
  this.destroyed = false;
43
45
  this.wsGetter = wsGetter;
44
- this.options = { ...defaultOptions, ...options };
46
+ this.options = options;
45
47
  this.sendQueue = [];
46
48
  this.tryConnect();
47
49
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@replit/river",
3
3
  "sideEffects": false,
4
4
  "description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
5
- "version": "0.5.1",
5
+ "version": "0.5.2",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dist/router/index.js",