@replit/river 0.215.0 → 0.216.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 +47 -0
- package/dist/adapter-BXCk-dmy.d.ts +29 -0
- package/dist/adapter-D5X11kmP.d.cts +29 -0
- package/dist/{chunk-VXRAFUA3.js → chunk-75ZMPCKC.js} +26 -6
- package/dist/{chunk-VXRAFUA3.js.map → chunk-75ZMPCKC.js.map} +1 -1
- package/dist/chunk-SHND2JG6.js +86 -0
- package/dist/chunk-SHND2JG6.js.map +1 -0
- package/dist/{chunk-RDTQZ7HO.js → chunk-ZLMQQI43.js} +12 -2
- package/dist/chunk-ZLMQQI43.js.map +1 -0
- package/dist/{client-BhwlY0-L.d.ts → client-BNc5Pj_4.d.ts} +2 -2
- package/dist/{client-Dk4H7qeg.d.cts → client-BZUvFL6B.d.cts} +2 -2
- package/dist/codec/index.cjs.map +1 -1
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/{connection-DU9v3y8a.d.ts → connection-ou9w2dSY.d.ts} +3 -3
- package/dist/{connection-CS00EWuS.d.cts → connection-xxgJHs2o.d.cts} +3 -3
- package/dist/{index-CHCzvZ9D.d.cts → index-BAGGleT3.d.cts} +1 -1
- package/dist/{index-uF0cBM7z.d.ts → index-ZWkoesQD.d.ts} +1 -1
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-aABg0s5M.d.cts → message-CpXWqmJw.d.cts} +1 -1
- package/dist/{message-aABg0s5M.d.ts → message-CpXWqmJw.d.ts} +1 -1
- package/dist/protobuf/codec.cjs +107 -0
- package/dist/protobuf/codec.cjs.map +1 -0
- package/dist/protobuf/codec.d.cts +13 -0
- package/dist/protobuf/codec.d.ts +13 -0
- package/dist/protobuf/codec.js +7 -0
- package/dist/protobuf/codec.js.map +1 -0
- package/dist/protobuf/index.cjs +1877 -0
- package/dist/protobuf/index.cjs.map +1 -0
- package/dist/protobuf/index.d.cts +488 -0
- package/dist/protobuf/index.d.ts +488 -0
- package/dist/protobuf/index.js +1260 -0
- package/dist/protobuf/index.js.map +1 -0
- package/dist/router/index.cjs +1 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +12 -11
- package/dist/router/index.d.ts +12 -11
- package/dist/router/index.js +1 -1
- package/dist/{server-uNzkzIRh.d.ts → server-BPu7Td80.d.ts} +4 -4
- package/dist/{server-BR0DZaWi.d.cts → server-JdnoVO11.d.cts} +4 -4
- package/dist/{services-B5SY771g.d.ts → services-BrTFTO5Q.d.ts} +104 -93
- package/dist/{services-DBv2nmly.d.cts → services-cwGAC2rB.d.cts} +104 -93
- package/dist/testUtil/index.cjs +25 -5
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +8 -7
- package/dist/testUtil/index.d.ts +8 -7
- package/dist/testUtil/index.js +2 -2
- package/dist/transport/impls/ws/client.cjs +5 -1
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +7 -6
- package/dist/transport/impls/ws/client.d.ts +7 -6
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +21 -5
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +7 -6
- package/dist/transport/impls/ws/server.d.ts +7 -6
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +25 -5
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +8 -7
- package/dist/transport/index.d.ts +8 -7
- package/dist/transport/index.js +2 -2
- package/dist/{transport-BOL2p5s-.d.ts → transport-B1MUtXL7.d.ts} +7 -5
- package/dist/{transport-D3jzhFSi.d.cts → transport-BnU3Zb0Q.d.cts} +7 -5
- package/dist/types-BGGvYIJM.d.cts +20 -0
- package/dist/types-BGGvYIJM.d.ts +20 -0
- package/package.json +12 -1
- package/dist/adapter-CgF7vQPu.d.ts +0 -47
- package/dist/adapter-IGrG4KLL.d.cts +0 -47
- package/dist/chunk-RDTQZ7HO.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-
|
|
5
|
-
export {
|
|
1
|
+
export { P as ClientTransportOptions, C as Connection, E as EventHandler, a as EventMap, b as EventTypes, c as ProtocolError, d as ProtocolErrorType, e as ServerTransportOptions, S as Session, f as SessionConnected, g as SessionConnecting, h as SessionHandshaking, i as SessionNoConnection, j as SessionState, T as Transport, k as TransportOptions, l as TransportStatus } from '../transport-BnU3Zb0Q.cjs';
|
|
2
|
+
export { C as ClientTransport } from '../client-BZUvFL6B.cjs';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-JdnoVO11.cjs';
|
|
4
|
+
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-xxgJHs2o.cjs';
|
|
5
|
+
export { O as OpaqueTransportMessage, a as OpaqueTransportMessageSchema, T as TransportClientId, b as TransportMessage, c as TransportMessageSchema, i as isStreamClose, d as isStreamOpen } from '../message-CpXWqmJw.cjs';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../
|
|
7
|
+
import '../index-BAGGleT3.cjs';
|
|
8
|
+
import '../types-BGGvYIJM.cjs';
|
|
9
|
+
import '../adapter-D5X11kmP.cjs';
|
|
9
10
|
import '@opentelemetry/api';
|
|
10
11
|
import '../wslike-Dng9H1C7.cjs';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-
|
|
5
|
-
export {
|
|
1
|
+
export { P as ClientTransportOptions, C as Connection, E as EventHandler, a as EventMap, b as EventTypes, c as ProtocolError, d as ProtocolErrorType, e as ServerTransportOptions, S as Session, f as SessionConnected, g as SessionConnecting, h as SessionHandshaking, i as SessionNoConnection, j as SessionState, T as Transport, k as TransportOptions, l as TransportStatus } from '../transport-B1MUtXL7.js';
|
|
2
|
+
export { C as ClientTransport } from '../client-BNc5Pj_4.js';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-BPu7Td80.js';
|
|
4
|
+
export { W as WebSocketCloseError, a as WebSocketConnection } from '../connection-ou9w2dSY.js';
|
|
5
|
+
export { O as OpaqueTransportMessage, a as OpaqueTransportMessageSchema, T as TransportClientId, b as TransportMessage, c as TransportMessageSchema, i as isStreamClose, d as isStreamOpen } from '../message-CpXWqmJw.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../
|
|
7
|
+
import '../index-ZWkoesQD.js';
|
|
8
|
+
import '../types-BGGvYIJM.js';
|
|
9
|
+
import '../adapter-BXCk-dmy.js';
|
|
9
10
|
import '@opentelemetry/api';
|
|
10
11
|
import '../wslike-Dng9H1C7.js';
|
package/dist/transport/index.js
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
Transport,
|
|
8
8
|
WebSocketCloseError,
|
|
9
9
|
WebSocketConnection
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-75ZMPCKC.js";
|
|
11
11
|
import "../chunk-CC7RN7GI.js";
|
|
12
12
|
import {
|
|
13
13
|
OpaqueTransportMessageSchema,
|
|
14
14
|
TransportMessageSchema
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-ZLMQQI43.js";
|
|
16
16
|
export {
|
|
17
17
|
ClientTransport,
|
|
18
18
|
Connection,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
3
|
-
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-
|
|
4
|
-
import { C as Codec
|
|
2
|
+
import { T as TransportClientId, g as TelemetryInfo, P as ProtocolVersion, e as PartialTransportMessage, E as EncodedTransportMessage, f as HandshakeErrorCustomHandlerFatalResponseCodes, O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, b as TransportMessage } from './message-CpXWqmJw.js';
|
|
3
|
+
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-ZWkoesQD.js';
|
|
4
|
+
import { C as Codec } from './types-BGGvYIJM.js';
|
|
5
|
+
import { C as CodecMessageAdapter, E as EncodeResult, S as SendResult, a as SendBufferResult } from './adapter-BXCk-dmy.js';
|
|
5
6
|
import { Tracer } from '@opentelemetry/api';
|
|
6
7
|
|
|
7
8
|
declare const enum SessionState {
|
|
@@ -226,7 +227,7 @@ interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema, Parse
|
|
|
226
227
|
*/
|
|
227
228
|
validate: ValidateHandshake<MetadataSchema, ParsedMetadata>;
|
|
228
229
|
}
|
|
229
|
-
declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions
|
|
230
|
+
declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions<MetadataSchema>;
|
|
230
231
|
declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema, ParsedMetadata extends object = object>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema, ParsedMetadata>): ServerHandshakeOptions<MetadataSchema, ParsedMetadata>;
|
|
231
232
|
|
|
232
233
|
/**
|
|
@@ -283,6 +284,7 @@ declare class LeakyBucketRateLimit {
|
|
|
283
284
|
hasBudget(): boolean;
|
|
284
285
|
startRestoringBudget(): void;
|
|
285
286
|
private stopLeak;
|
|
287
|
+
resetBudget(): void;
|
|
286
288
|
close(): void;
|
|
287
289
|
}
|
|
288
290
|
|
|
@@ -585,4 +587,4 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
585
587
|
getSessionBoundSendFn(to: TransportClientId, sessionId: SessionId): SessionBoundSendFn;
|
|
586
588
|
}
|
|
587
589
|
|
|
588
|
-
export { Connection as C, type DeleteSessionOptions as D, type
|
|
590
|
+
export { Connection as C, type DeleteSessionOptions as D, type EventHandler as E, LeakyBucketRateLimit as L, type ProvidedClientTransportOptions as P, type Session as S, Transport as T, type EventMap as a, type EventTypes as b, ProtocolError as c, type ProtocolErrorType as d, type ProvidedServerTransportOptions as e, SessionConnected as f, SessionConnecting as g, SessionHandshaking as h, SessionNoConnection as i, SessionState as j, type ProvidedTransportOptions as k, type TransportStatus as l, type ClientTransportOptions as m, type ClientHandshakeOptions as n, type ClientSession as o, SessionBackingOff as p, type ServerHandshakeOptions as q, createClientHandshakeOptions as r, createServerHandshakeOptions as s, CommonSession as t, type CommonSessionProps as u, type ServerTransportOptions as v, type ServerSession as w, type SessionBoundSendFn as x, type SessionOptions as y, type SessionId as z };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
2
|
-
import {
|
|
3
|
-
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-
|
|
4
|
-
import { C as Codec
|
|
2
|
+
import { T as TransportClientId, g as TelemetryInfo, P as ProtocolVersion, e as PartialTransportMessage, E as EncodedTransportMessage, f as HandshakeErrorCustomHandlerFatalResponseCodes, O as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, b as TransportMessage } from './message-CpXWqmJw.cjs';
|
|
3
|
+
import { L as Logger, M as MessageMetadata, T as Tags, a as LogFn, b as LoggingLevel } from './index-BAGGleT3.cjs';
|
|
4
|
+
import { C as Codec } from './types-BGGvYIJM.cjs';
|
|
5
|
+
import { C as CodecMessageAdapter, E as EncodeResult, S as SendResult, a as SendBufferResult } from './adapter-D5X11kmP.cjs';
|
|
5
6
|
import { Tracer } from '@opentelemetry/api';
|
|
6
7
|
|
|
7
8
|
declare const enum SessionState {
|
|
@@ -226,7 +227,7 @@ interface ServerHandshakeOptions<MetadataSchema extends TSchema = TSchema, Parse
|
|
|
226
227
|
*/
|
|
227
228
|
validate: ValidateHandshake<MetadataSchema, ParsedMetadata>;
|
|
228
229
|
}
|
|
229
|
-
declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions
|
|
230
|
+
declare function createClientHandshakeOptions<MetadataSchema extends TSchema = TSchema>(schema: MetadataSchema, construct: ConstructHandshake<MetadataSchema>): ClientHandshakeOptions<MetadataSchema>;
|
|
230
231
|
declare function createServerHandshakeOptions<MetadataSchema extends TSchema = TSchema, ParsedMetadata extends object = object>(schema: MetadataSchema, validate: ValidateHandshake<MetadataSchema, ParsedMetadata>): ServerHandshakeOptions<MetadataSchema, ParsedMetadata>;
|
|
231
232
|
|
|
232
233
|
/**
|
|
@@ -283,6 +284,7 @@ declare class LeakyBucketRateLimit {
|
|
|
283
284
|
hasBudget(): boolean;
|
|
284
285
|
startRestoringBudget(): void;
|
|
285
286
|
private stopLeak;
|
|
287
|
+
resetBudget(): void;
|
|
286
288
|
close(): void;
|
|
287
289
|
}
|
|
288
290
|
|
|
@@ -585,4 +587,4 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
585
587
|
getSessionBoundSendFn(to: TransportClientId, sessionId: SessionId): SessionBoundSendFn;
|
|
586
588
|
}
|
|
587
589
|
|
|
588
|
-
export { Connection as C, type DeleteSessionOptions as D, type
|
|
590
|
+
export { Connection as C, type DeleteSessionOptions as D, type EventHandler as E, LeakyBucketRateLimit as L, type ProvidedClientTransportOptions as P, type Session as S, Transport as T, type EventMap as a, type EventTypes as b, ProtocolError as c, type ProtocolErrorType as d, type ProvidedServerTransportOptions as e, SessionConnected as f, SessionConnecting as g, SessionHandshaking as h, SessionNoConnection as i, SessionState as j, type ProvidedTransportOptions as k, type TransportStatus as l, type ClientTransportOptions as m, type ClientHandshakeOptions as n, type ClientSession as o, SessionBackingOff as p, type ServerHandshakeOptions as q, createClientHandshakeOptions as r, createServerHandshakeOptions as s, CommonSession as t, type CommonSessionProps as u, type ServerTransportOptions as v, type ServerSession as w, type SessionBoundSendFn as x, type SessionOptions as y, type SessionId as z };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
3
|
+
* Used to prepare messages for use by the transport layer.
|
|
4
|
+
*/
|
|
5
|
+
interface Codec {
|
|
6
|
+
/**
|
|
7
|
+
* Encodes an object to a Uint8 buffer.
|
|
8
|
+
* @param obj - The object to encode.
|
|
9
|
+
* @returns The encoded Uint8 buffer.
|
|
10
|
+
*/
|
|
11
|
+
toBuffer(obj: object): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Decodes an object from a Uint8 buffer.
|
|
14
|
+
* @param buf - The Uint8 buffer to decode.
|
|
15
|
+
* @returns The decoded object, or null if decoding failed.
|
|
16
|
+
*/
|
|
17
|
+
fromBuffer(buf: Uint8Array): object;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type { Codec as C };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
3
|
+
* Used to prepare messages for use by the transport layer.
|
|
4
|
+
*/
|
|
5
|
+
interface Codec {
|
|
6
|
+
/**
|
|
7
|
+
* Encodes an object to a Uint8 buffer.
|
|
8
|
+
* @param obj - The object to encode.
|
|
9
|
+
* @returns The encoded Uint8 buffer.
|
|
10
|
+
*/
|
|
11
|
+
toBuffer(obj: object): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Decodes an object from a Uint8 buffer.
|
|
14
|
+
* @param buf - The Uint8 buffer to decode.
|
|
15
|
+
* @returns The decoded object, or null if decoding failed.
|
|
16
|
+
*/
|
|
17
|
+
fromBuffer(buf: Uint8Array): object;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type { Codec as C };
|
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.
|
|
4
|
+
"version": "0.216.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"import": "./dist/logging/index.js",
|
|
13
13
|
"require": "./dist/logging/index.cjs"
|
|
14
14
|
},
|
|
15
|
+
"./protobuf": {
|
|
16
|
+
"import": "./dist/protobuf/index.js",
|
|
17
|
+
"require": "./dist/protobuf/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./protobuf/codec": {
|
|
20
|
+
"import": "./dist/protobuf/codec.js",
|
|
21
|
+
"require": "./dist/protobuf/codec.cjs"
|
|
22
|
+
},
|
|
15
23
|
"./codec": {
|
|
16
24
|
"import": "./dist/codec/index.js",
|
|
17
25
|
"require": "./dist/codec/index.cjs"
|
|
@@ -40,6 +48,7 @@
|
|
|
40
48
|
"dist"
|
|
41
49
|
],
|
|
42
50
|
"dependencies": {
|
|
51
|
+
"@bufbuild/protobuf": "^2.11.0",
|
|
43
52
|
"@msgpack/msgpack": "^3.1.2",
|
|
44
53
|
"nanoid": "^5.0.9",
|
|
45
54
|
"ws": "^8.17.0"
|
|
@@ -49,6 +58,7 @@
|
|
|
49
58
|
"@sinclair/typebox": "~0.34.0"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
61
|
+
"@bufbuild/buf": "^1.67.0",
|
|
52
62
|
"@opentelemetry/api": "^1.7.0",
|
|
53
63
|
"@opentelemetry/context-async-hooks": "^1.26.0",
|
|
54
64
|
"@opentelemetry/core": "^1.7.0",
|
|
@@ -74,6 +84,7 @@
|
|
|
74
84
|
"lint": "eslint .",
|
|
75
85
|
"lint:fix": "eslint . --fix",
|
|
76
86
|
"fix": "npm run format:fix && npm run lint:fix",
|
|
87
|
+
"proto:generate": "buf generate --template buf.gen.yaml --clean --path proto/transport.proto && buf generate --template buf.gen.test.yaml --clean --path proto/test/test_service.proto",
|
|
77
88
|
"build": "rm -rf dist && tsup && du -sh dist",
|
|
78
89
|
"prepack": "npm run build",
|
|
79
90
|
"release": "npm publish --access public",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { b as OpaqueTransportMessage, E as EncodedTransportMessage } from './message-aABg0s5M.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
5
|
-
* Used to prepare messages for use by the transport layer.
|
|
6
|
-
*/
|
|
7
|
-
interface Codec {
|
|
8
|
-
/**
|
|
9
|
-
* Encodes an object to a Uint8 buffer.
|
|
10
|
-
* @param obj - The object to encode.
|
|
11
|
-
* @returns The encoded Uint8 buffer.
|
|
12
|
-
*/
|
|
13
|
-
toBuffer(obj: object): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Decodes an object from a Uint8 buffer.
|
|
16
|
-
* @param buf - The Uint8 buffer to decode.
|
|
17
|
-
* @returns The decoded object, or null if decoding failed.
|
|
18
|
-
*/
|
|
19
|
-
fromBuffer(buf: Uint8Array): object;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type SessionApiResult<T> = {
|
|
23
|
-
ok: true;
|
|
24
|
-
value: T;
|
|
25
|
-
} | {
|
|
26
|
-
ok: false;
|
|
27
|
-
reason: string;
|
|
28
|
-
};
|
|
29
|
-
type SendResult = SessionApiResult<string>;
|
|
30
|
-
type SendBufferResult = SessionApiResult<undefined>;
|
|
31
|
-
type EncodeResult = SessionApiResult<EncodedTransportMessage>;
|
|
32
|
-
type SerializeResult = SessionApiResult<Uint8Array>;
|
|
33
|
-
type DeserializeResult = SessionApiResult<OpaqueTransportMessage>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Adapts a {@link Codec} to the {@link OpaqueTransportMessage} format,
|
|
37
|
-
* accounting for fallibility of toBuffer and fromBuffer and wrapping
|
|
38
|
-
* it with a Result type.
|
|
39
|
-
*/
|
|
40
|
-
declare class CodecMessageAdapter {
|
|
41
|
-
private readonly codec;
|
|
42
|
-
constructor(codec: Codec);
|
|
43
|
-
toBuffer(msg: OpaqueTransportMessage): SerializeResult;
|
|
44
|
-
fromBuffer(buf: Uint8Array): DeserializeResult;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { type Codec as C, type EncodeResult as E, type SendResult as S, CodecMessageAdapter as a, type SendBufferResult as b };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { b as OpaqueTransportMessage, E as EncodedTransportMessage } from './message-aABg0s5M.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Codec interface for encoding and decoding objects to and from Uint8 buffers.
|
|
5
|
-
* Used to prepare messages for use by the transport layer.
|
|
6
|
-
*/
|
|
7
|
-
interface Codec {
|
|
8
|
-
/**
|
|
9
|
-
* Encodes an object to a Uint8 buffer.
|
|
10
|
-
* @param obj - The object to encode.
|
|
11
|
-
* @returns The encoded Uint8 buffer.
|
|
12
|
-
*/
|
|
13
|
-
toBuffer(obj: object): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Decodes an object from a Uint8 buffer.
|
|
16
|
-
* @param buf - The Uint8 buffer to decode.
|
|
17
|
-
* @returns The decoded object, or null if decoding failed.
|
|
18
|
-
*/
|
|
19
|
-
fromBuffer(buf: Uint8Array): object;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type SessionApiResult<T> = {
|
|
23
|
-
ok: true;
|
|
24
|
-
value: T;
|
|
25
|
-
} | {
|
|
26
|
-
ok: false;
|
|
27
|
-
reason: string;
|
|
28
|
-
};
|
|
29
|
-
type SendResult = SessionApiResult<string>;
|
|
30
|
-
type SendBufferResult = SessionApiResult<undefined>;
|
|
31
|
-
type EncodeResult = SessionApiResult<EncodedTransportMessage>;
|
|
32
|
-
type SerializeResult = SessionApiResult<Uint8Array>;
|
|
33
|
-
type DeserializeResult = SessionApiResult<OpaqueTransportMessage>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Adapts a {@link Codec} to the {@link OpaqueTransportMessage} format,
|
|
37
|
-
* accounting for fallibility of toBuffer and fromBuffer and wrapping
|
|
38
|
-
* it with a Result type.
|
|
39
|
-
*/
|
|
40
|
-
declare class CodecMessageAdapter {
|
|
41
|
-
private readonly codec;
|
|
42
|
-
constructor(codec: Codec);
|
|
43
|
-
toBuffer(msg: OpaqueTransportMessage): SerializeResult;
|
|
44
|
-
fromBuffer(buf: Uint8Array): DeserializeResult;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { type Codec as C, type EncodeResult as E, type SendResult as S, CodecMessageAdapter as a, type SendBufferResult as b };
|