@igoforth/ws-rpc 1.1.1 → 1.1.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.
- package/dist/adapters/client.d.ts +9 -9
- package/dist/adapters/cloudflare-do.d.ts +7 -7
- package/dist/adapters/index.d.ts +7 -7
- package/dist/adapters/server.d.ts +7 -7
- package/dist/adapters/types.d.ts +11 -11
- package/dist/codecs/cbor.d.ts +2 -2
- package/dist/codecs/factory.d.ts +2 -2
- package/dist/codecs/index.d.ts +3 -3
- package/dist/codecs/json.d.ts +3 -3
- package/dist/codecs/msgpack.d.ts +2 -2
- package/dist/{default-DY19RYXA.d.ts → default-CKJtfuap.d.ts} +4 -4
- package/dist/{factory-Dapk2aA3.d.ts → factory-CZioNF7N.d.ts} +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/{interface-CoVQ0KnO.d.ts → interface-RK7s4DQf.d.ts} +1 -1
- package/dist/{json-ZQ5sjEbW.d.ts → json-1pVWk4mJ.d.ts} +1 -1
- package/dist/{memory-DSlJL2of.d.ts → memory-BxojNC-D.d.ts} +2 -2
- package/dist/peers/default.d.ts +6 -6
- package/dist/peers/durable.d.ts +7 -7
- package/dist/peers/index.d.ts +7 -7
- package/dist/{protocol-4AgHYQBE.d.ts → protocol-DxoHWqMA.d.ts} +1 -1
- package/dist/protocol.d.ts +4 -4
- package/dist/{schema-BzaFWzeV.d.ts → schema-B0zKtaPR.d.ts} +15 -5
- package/dist/schema.d.ts +2 -2
- package/dist/{server-Dp8DSL5I.d.ts → server-q205-WY8.d.ts} +5 -5
- package/dist/{sql-bFsho2vn.d.ts → sql-xafn7bdx.d.ts} +2 -2
- package/dist/storage/index.d.ts +6 -6
- package/dist/storage/interface.d.ts +2 -2
- package/dist/storage/memory.d.ts +5 -5
- package/dist/storage/sql.d.ts +5 -5
- package/dist/{types-NYBscFQZ.d.ts → types-BUYZxMco.d.ts} +8 -8
- package/dist/types.d.ts +5 -5
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import { _ as RpcSchema, h as Provider, s as InferEvents, t as Driver, v as StringKeys } from "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import { u as RpcProtocol } from "../protocol-
|
|
6
|
-
import { a as IRpcOptions, c as WebSocketOptions, o as IWebSocket } from "../types-
|
|
7
|
-
import "../default-
|
|
5
|
+
import { u as RpcProtocol } from "../protocol-DxoHWqMA.js";
|
|
6
|
+
import { a as IRpcOptions, c as WebSocketOptions, o as IWebSocket } from "../types-BUYZxMco.js";
|
|
7
|
+
import "../default-CKJtfuap.js";
|
|
8
8
|
import { t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
|
|
9
9
|
import { IAdapterHooks, IConnectionAdapter } from "./types.js";
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ import { IAdapterHooks, IConnectionAdapter } from "./types.js";
|
|
|
13
13
|
/**
|
|
14
14
|
* Options for creating an RpcClient
|
|
15
15
|
*/
|
|
16
|
-
interface RpcClientOptions<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IAdapterHooks<TRemoteSchema>, IRpcOptions<TLocalSchema, TRemoteSchema> {
|
|
16
|
+
interface RpcClientOptions<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IAdapterHooks<TRemoteSchema["events"]>, IRpcOptions<TLocalSchema, TRemoteSchema> {
|
|
17
17
|
/** WebSocket URL to connect to */
|
|
18
18
|
url: string;
|
|
19
19
|
/** Implementation of local methods */
|
|
@@ -44,7 +44,7 @@ declare class RpcClient<TLocalSchema extends RpcSchema, TRemoteSchema extends Rp
|
|
|
44
44
|
readonly timeout: number;
|
|
45
45
|
readonly protocol?: RpcProtocol;
|
|
46
46
|
readonly provider: Provider<TLocalSchema["methods"]>;
|
|
47
|
-
readonly hooks: IAdapterHooks<TRemoteSchema>;
|
|
47
|
+
readonly hooks: IAdapterHooks<TRemoteSchema["events"]>;
|
|
48
48
|
private readonly reconnectOptions;
|
|
49
49
|
private readonly createWebSocket;
|
|
50
50
|
private ws;
|
|
@@ -75,7 +75,7 @@ declare class RpcClient<TLocalSchema extends RpcSchema, TRemoteSchema extends Rp
|
|
|
75
75
|
* @param event - Event name from local schema
|
|
76
76
|
* @param data - Event data matching the schema
|
|
77
77
|
*/
|
|
78
|
-
emit<K extends StringKeys<TLocalSchema["events"]
|
|
78
|
+
emit<K extends StringKeys<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K]): void;
|
|
79
79
|
/**
|
|
80
80
|
* Connect to the WebSocket server
|
|
81
81
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import { _ as RpcSchema, h as Provider, s as InferEvents, v as StringKeys } from "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import { a as IRpcOptions } from "../types-
|
|
7
|
-
import { t as RpcPeer } from "../default-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import { a as IRpcOptions } from "../types-BUYZxMco.js";
|
|
7
|
+
import { t as RpcPeer } from "../default-CKJtfuap.js";
|
|
8
8
|
import { IMultiAdapterHooks, IMultiConnectionAdapter } from "./types.js";
|
|
9
9
|
import { Constructor } from "type-fest";
|
|
10
10
|
import { Actor } from "@cloudflare/actors";
|
|
@@ -28,7 +28,7 @@ interface IRpcActorHooks<TLocalSchema extends RpcSchema, TRemoteSchema extends R
|
|
|
28
28
|
/** Called when a peer disconnects. Override to handle disconnection events. */
|
|
29
29
|
onRpcDisconnect(peer: RpcPeer<TLocalSchema, TRemoteSchema>): void;
|
|
30
30
|
/** Called when an event is received from a peer. Override to handle events. */
|
|
31
|
-
onRpcEvent<K extends StringKeys<TRemoteSchema["events"]
|
|
31
|
+
onRpcEvent<K extends StringKeys<InferEvents<TRemoteSchema["events"]>>>(peer: RpcPeer<TLocalSchema, TRemoteSchema>, event: K, data: InferEvents<TRemoteSchema["events"]>[K]): void;
|
|
32
32
|
/** Called when a peer encounters an error. Override to handle errors. */
|
|
33
33
|
onRpcError(peer: RpcPeer<TLocalSchema, TRemoteSchema> | null, error: Error): void;
|
|
34
34
|
/** Called when a peer is recreated after hibernation. Override to handle recovery. */
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import "../types-
|
|
7
|
-
import "../default-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import "../types-BUYZxMco.js";
|
|
7
|
+
import "../default-CKJtfuap.js";
|
|
8
8
|
import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
|
|
9
9
|
import { IAdapterHooks, IConnectionAdapter, IMultiAdapterHooks, IMultiConnectionAdapter, MultiCallOptions, MultiCallResult, MultiDriver } from "./types.js";
|
|
10
10
|
import { ConnectionState, RpcClient, RpcClientOptions } from "./client.js";
|
|
11
11
|
import { IDOHooks, IRpcActorHooks, RpcActorConstructor, withRpc } from "./cloudflare-do.js";
|
|
12
|
-
import { n as RpcServerOptions, r as MultiPeerBase, t as RpcServer } from "../server-
|
|
12
|
+
import { n as RpcServerOptions, r as MultiPeerBase, t as RpcServer } from "../server-q205-WY8.js";
|
|
13
13
|
export { type ConnectionState, IAdapterHooks, IConnectionAdapter, type IDOHooks, IMultiAdapterHooks, IMultiConnectionAdapter, type IRpcActorHooks, MultiCallOptions, MultiCallResult, MultiDriver, MultiPeerBase, ReconnectOptions, type RpcActorConstructor, RpcClient, type RpcClientOptions, RpcServer, type RpcServerOptions, calculateReconnectDelay, defaultReconnectOptions, withRpc };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import "../types-
|
|
7
|
-
import "../default-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import "../types-BUYZxMco.js";
|
|
7
|
+
import "../default-CKJtfuap.js";
|
|
8
8
|
import "./types.js";
|
|
9
|
-
import { n as RpcServerOptions, t as RpcServer } from "../server-
|
|
9
|
+
import { n as RpcServerOptions, t as RpcServer } from "../server-q205-WY8.js";
|
|
10
10
|
export { RpcServer, RpcServerOptions };
|
package/dist/adapters/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import { _ as RpcSchema, a as EventHandler, c as InferInput, m as MethodDef, r as EventDef, t as Driver, u as InferOutput, v as StringKeys } from "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import { a as IRpcOptions, n as IMethodController, t as IEventController } from "../types-
|
|
7
|
-
import { t as RpcPeer } from "../default-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import { a as IRpcOptions, n as IMethodController, t as IEventController } from "../types-BUYZxMco.js";
|
|
7
|
+
import { t as RpcPeer } from "../default-CKJtfuap.js";
|
|
8
8
|
import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
|
|
9
9
|
|
|
10
10
|
//#region src/adapters/types.d.ts
|
|
@@ -78,7 +78,7 @@ type MultiDriver<TRemoteSchema extends RpcSchema> = TRemoteSchema["methods"] ext
|
|
|
78
78
|
/**
|
|
79
79
|
* Event emitter type for client callbacks
|
|
80
80
|
*/
|
|
81
|
-
interface IAdapterHooks<
|
|
81
|
+
interface IAdapterHooks<TRemoteEvents extends Record<string, EventDef> | undefined> {
|
|
82
82
|
/** Called when WebSocket connection opens */
|
|
83
83
|
onConnect?(): void;
|
|
84
84
|
/** Called when WebSocket connection closes */
|
|
@@ -88,7 +88,7 @@ interface IAdapterHooks<TRemoteSchema extends RpcSchema> {
|
|
|
88
88
|
/** Called when reconnection fails after max attempts */
|
|
89
89
|
onReconnectFailed?(): void;
|
|
90
90
|
/** Called when receiving an event from the server */
|
|
91
|
-
onEvent?: EventHandler<
|
|
91
|
+
onEvent?: EventHandler<TRemoteEvents>;
|
|
92
92
|
}
|
|
93
93
|
interface IMultiAdapterHooks<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> {
|
|
94
94
|
/** Called when a peer connects */
|
|
@@ -101,10 +101,10 @@ interface IMultiAdapterHooks<TLocalSchema extends RpcSchema, TRemoteSchema exten
|
|
|
101
101
|
onError?(peer: RpcPeer<TLocalSchema, TRemoteSchema> | null, error: Error): void;
|
|
102
102
|
onClose?(): void;
|
|
103
103
|
}
|
|
104
|
-
interface IConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema>, IEventController<TLocalSchema, TRemoteSchema> {
|
|
104
|
+
interface IConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema["methods"]>, IEventController<TLocalSchema["events"], TRemoteSchema["events"]> {
|
|
105
105
|
/** Driver for calling remote methods on connected peer */
|
|
106
106
|
readonly driver: Driver<TRemoteSchema["methods"]>;
|
|
107
|
-
readonly hooks: IAdapterHooks<TRemoteSchema>;
|
|
107
|
+
readonly hooks: IAdapterHooks<TRemoteSchema["events"]>;
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Interface for adapters that manage multiple connections
|
|
@@ -112,7 +112,7 @@ interface IConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema exten
|
|
|
112
112
|
* Extends IRpcConnection - `emit()` broadcasts to all connected peers.
|
|
113
113
|
* Implemented by RpcServer and Cloudflare DO adapter.
|
|
114
114
|
*/
|
|
115
|
-
interface IMultiConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema>, IEventController<TLocalSchema, TRemoteSchema, [ids?: string[]]> {
|
|
115
|
+
interface IMultiConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema["methods"]>, IEventController<TLocalSchema["events"], TRemoteSchema["events"], [ids?: string[]]> {
|
|
116
116
|
/** Driver for calling remote methods on connected peers */
|
|
117
117
|
readonly driver: MultiDriver<TRemoteSchema>;
|
|
118
118
|
readonly hooks: IMultiAdapterHooks<TLocalSchema, TRemoteSchema>;
|
package/dist/codecs/cbor.d.ts
CHANGED
package/dist/codecs/factory.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import { a as WireCodec, c as createStringCodecFactory, i as StringCodec, l as isBinaryCodec, n as CodecFactory, o as WireData, r as CodecOptions, s as createBinaryCodecFactory, t as BinaryCodec, u as isStringCodec } from "../factory-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import { a as WireCodec, c as createStringCodecFactory, i as StringCodec, l as isBinaryCodec, n as CodecFactory, o as WireData, r as CodecOptions, s as createBinaryCodecFactory, t as BinaryCodec, u as isStringCodec } from "../factory-CZioNF7N.js";
|
|
3
3
|
export { BinaryCodec, CodecFactory, CodecOptions, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createStringCodecFactory, isBinaryCodec, isStringCodec };
|
package/dist/codecs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import { a as WireCodec, c as createStringCodecFactory, i as StringCodec, l as isBinaryCodec, n as CodecFactory, o as WireData, r as CodecOptions, s as createBinaryCodecFactory, t as BinaryCodec, u as isStringCodec } from "../factory-
|
|
3
|
-
import { n as createJsonCodec, t as JsonCodec } from "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import { a as WireCodec, c as createStringCodecFactory, i as StringCodec, l as isBinaryCodec, n as CodecFactory, o as WireData, r as CodecOptions, s as createBinaryCodecFactory, t as BinaryCodec, u as isStringCodec } from "../factory-CZioNF7N.js";
|
|
3
|
+
import { n as createJsonCodec, t as JsonCodec } from "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
5
|
export { BinaryCodec, CodecFactory, CodecOptions, JsonCodec, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createJsonCodec, createStringCodecFactory, isBinaryCodec, isStringCodec };
|
package/dist/codecs/json.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import { n as createJsonCodec, t as JsonCodec } from "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import { n as createJsonCodec, t as JsonCodec } from "../json-1pVWk4mJ.js";
|
|
4
4
|
export { JsonCodec, createJsonCodec };
|
package/dist/codecs/msgpack.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as WireInput, u as RpcProtocol } from "./protocol-
|
|
3
|
-
import { a as IRpcOptions, r as IMinWebSocket } from "./types-
|
|
1
|
+
import { _ as RpcSchema, a as EventHandler, h as Provider, s as InferEvents, t as Driver, v as StringKeys } from "./schema-B0zKtaPR.js";
|
|
2
|
+
import { g as WireInput, u as RpcProtocol } from "./protocol-DxoHWqMA.js";
|
|
3
|
+
import { a as IRpcOptions, r as IMinWebSocket } from "./types-BUYZxMco.js";
|
|
4
4
|
|
|
5
5
|
//#region src/peers/default.d.ts
|
|
6
6
|
|
|
@@ -55,7 +55,7 @@ declare class RpcPeer<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcS
|
|
|
55
55
|
/**
|
|
56
56
|
* Emit an event to the remote peer (fire-and-forget)
|
|
57
57
|
*/
|
|
58
|
-
emit<K extends StringKeys<TLocalSchema["events"]
|
|
58
|
+
emit<K extends StringKeys<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K]): void;
|
|
59
59
|
/**
|
|
60
60
|
* Handle an incoming WebSocket message
|
|
61
61
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import "./factory-
|
|
3
|
-
import "./json-
|
|
1
|
+
import { _ as RpcSchema, a as EventHandler, b as method, c as InferInput, h as Provider, l as InferMethods, m as MethodDef, o as InferEventData, r as EventDef, s as InferEvents, t as Driver, u as InferOutput, y as event } from "./schema-B0zKtaPR.js";
|
|
2
|
+
import "./factory-CZioNF7N.js";
|
|
3
|
+
import "./json-1pVWk4mJ.js";
|
|
4
4
|
import "./index-Be7jjS77.js";
|
|
5
|
-
import { _ as createProtocol, a as RpcEvent, c as RpcMessageCodec, d as RpcRequest, f as RpcRequestSchema, h as RpcWireCodec, i as RpcErrorSchema, l as RpcMessageSchema, m as RpcResponseSchema, n as RpcError$1, o as RpcEventSchema, p as RpcResponse, r as RpcErrorCodes, s as RpcMessage, t as JsonProtocol, u as RpcProtocol } from "./protocol-
|
|
6
|
-
import { a as IRpcOptions, c as WebSocketOptions, i as IRpcConnection, l as WebSocketReadyState, n as IMethodController, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, t as IEventController, u as WebSocketServerOptions } from "./types-
|
|
5
|
+
import { _ as createProtocol, a as RpcEvent, c as RpcMessageCodec, d as RpcRequest, f as RpcRequestSchema, h as RpcWireCodec, i as RpcErrorSchema, l as RpcMessageSchema, m as RpcResponseSchema, n as RpcError$1, o as RpcEventSchema, p as RpcResponse, r as RpcErrorCodes, s as RpcMessage, t as JsonProtocol, u as RpcProtocol } from "./protocol-DxoHWqMA.js";
|
|
6
|
+
import { a as IRpcOptions, c as WebSocketOptions, i as IRpcConnection, l as WebSocketReadyState, n as IMethodController, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, t as IEventController, u as WebSocketServerOptions } from "./types-BUYZxMco.js";
|
|
7
7
|
import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "./reconnect-DbcN0R_1.js";
|
|
8
8
|
import { RpcConnectionClosed, RpcError, RpcMethodNotFoundError, RpcRemoteError, RpcTimeoutError, RpcValidationError } from "./errors.js";
|
|
9
|
-
import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "./interface-
|
|
10
|
-
import { t as MemoryPendingCallStorage } from "./memory-
|
|
11
|
-
import { t as SqlPendingCallStorage } from "./sql-
|
|
9
|
+
import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "./interface-RK7s4DQf.js";
|
|
10
|
+
import { t as MemoryPendingCallStorage } from "./memory-BxojNC-D.js";
|
|
11
|
+
import { t as SqlPendingCallStorage } from "./sql-xafn7bdx.js";
|
|
12
12
|
import "./storage/index.js";
|
|
13
13
|
import "./utils/index.js";
|
|
14
14
|
export { type AsyncPendingCallStorage, type Driver, type EventDef, type EventHandler, type IEventController, type IMethodController, type IMinWebSocket, type IRpcConnection, type IRpcOptions, type IWebSocket, type IWebSocketServer, type InferEventData, type InferEvents, type InferInput, type InferMethods, type InferOutput, JsonProtocol, type MaybePromise, MemoryPendingCallStorage, type MethodDef, type PendingCall, type PendingCallStorage, type Provider, type ReconnectOptions, RpcConnectionClosed, RpcError, RpcErrorCodes, type RpcError$1 as RpcErrorMessage, RpcErrorSchema, type RpcEvent, RpcEventSchema, type RpcMessage, RpcMessageCodec, RpcMessageSchema, RpcMethodNotFoundError, type RpcProtocol, RpcRemoteError, type RpcRequest, RpcRequestSchema, type RpcResponse, RpcResponseSchema, type RpcSchema, RpcTimeoutError, RpcValidationError, type RpcWireCodec, SqlPendingCallStorage, type StorageMode, type SyncPendingCallStorage, type WebSocketOptions, WebSocketReadyState, type WebSocketServerOptions, calculateReconnectDelay, createProtocol, defaultReconnectOptions, event, method };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as StringCodec } from "./factory-
|
|
2
|
-
import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-
|
|
1
|
+
import { i as StringCodec } from "./factory-CZioNF7N.js";
|
|
2
|
+
import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-RK7s4DQf.js";
|
|
3
3
|
|
|
4
4
|
//#region src/storage/memory.d.ts
|
|
5
5
|
|
package/dist/peers/default.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import "../types-
|
|
7
|
-
import { n as RpcPeerOptions, t as RpcPeer } from "../default-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import "../types-BUYZxMco.js";
|
|
7
|
+
import { n as RpcPeerOptions, t as RpcPeer } from "../default-CKJtfuap.js";
|
|
8
8
|
export { RpcPeer, RpcPeerOptions };
|
package/dist/peers/durable.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import { _ as RpcSchema } from "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import { g as WireInput } from "../protocol-
|
|
6
|
-
import "../types-
|
|
7
|
-
import { n as RpcPeerOptions, t as RpcPeer } from "../default-
|
|
8
|
-
import { i as PendingCall, s as SyncPendingCallStorage } from "../interface-
|
|
5
|
+
import { g as WireInput } from "../protocol-DxoHWqMA.js";
|
|
6
|
+
import "../types-BUYZxMco.js";
|
|
7
|
+
import { n as RpcPeerOptions, t as RpcPeer } from "../default-CKJtfuap.js";
|
|
8
|
+
import { i as PendingCall, s as SyncPendingCallStorage } from "../interface-RK7s4DQf.js";
|
|
9
9
|
|
|
10
10
|
//#region src/peers/durable.d.ts
|
|
11
11
|
|
package/dist/peers/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../protocol-
|
|
6
|
-
import "../types-
|
|
7
|
-
import { n as RpcPeerOptions, t as RpcPeer } from "../default-
|
|
8
|
-
import "../interface-
|
|
5
|
+
import "../protocol-DxoHWqMA.js";
|
|
6
|
+
import "../types-BUYZxMco.js";
|
|
7
|
+
import { n as RpcPeerOptions, t as RpcPeer } from "../default-CKJtfuap.js";
|
|
8
|
+
import "../interface-RK7s4DQf.js";
|
|
9
9
|
import { CallContext, DurableRpcPeer, DurableRpcPeerOptions } from "./durable.js";
|
|
10
10
|
export { type CallContext, DurableRpcPeer, type DurableRpcPeerOptions, RpcPeer, type RpcPeerOptions };
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./schema-
|
|
2
|
-
import "./factory-
|
|
3
|
-
import "./json-
|
|
1
|
+
import "./schema-B0zKtaPR.js";
|
|
2
|
+
import "./factory-CZioNF7N.js";
|
|
3
|
+
import "./json-1pVWk4mJ.js";
|
|
4
4
|
import "./index-Be7jjS77.js";
|
|
5
|
-
import { _ as createProtocol, a as RpcEvent, c as RpcMessageCodec, d as RpcRequest, f as RpcRequestSchema, g as WireInput, h as RpcWireCodec, i as RpcErrorSchema, l as RpcMessageSchema, m as RpcResponseSchema, n as RpcError, o as RpcEventSchema, p as RpcResponse, r as RpcErrorCodes, s as RpcMessage, t as JsonProtocol, u as RpcProtocol } from "./protocol-
|
|
5
|
+
import { _ as createProtocol, a as RpcEvent, c as RpcMessageCodec, d as RpcRequest, f as RpcRequestSchema, g as WireInput, h as RpcWireCodec, i as RpcErrorSchema, l as RpcMessageSchema, m as RpcResponseSchema, n as RpcError, o as RpcEventSchema, p as RpcResponse, r as RpcErrorCodes, s as RpcMessage, t as JsonProtocol, u as RpcProtocol } from "./protocol-DxoHWqMA.js";
|
|
6
6
|
export { JsonProtocol, RpcError, RpcErrorCodes, RpcErrorSchema, RpcEvent, RpcEventSchema, RpcMessage, RpcMessageCodec, RpcMessageSchema, RpcProtocol, RpcRequest, RpcRequestSchema, RpcResponse, RpcResponseSchema, RpcWireCodec, WireInput, createProtocol };
|
|
@@ -14,6 +14,7 @@ interface MethodDef<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodT
|
|
|
14
14
|
input: TInput;
|
|
15
15
|
output: TOutput;
|
|
16
16
|
}
|
|
17
|
+
type Method = (input: unknown) => unknown | Promise<unknown>;
|
|
17
18
|
/**
|
|
18
19
|
* Event definition with data schema
|
|
19
20
|
*/
|
|
@@ -21,6 +22,7 @@ interface EventDef<TData extends z.ZodType = z.ZodType> {
|
|
|
21
22
|
_type: "event";
|
|
22
23
|
data: TData;
|
|
23
24
|
}
|
|
25
|
+
type Event = unknown;
|
|
24
26
|
/**
|
|
25
27
|
* Define an RPC method with input/output schemas
|
|
26
28
|
*
|
|
@@ -62,6 +64,10 @@ interface RpcSchema {
|
|
|
62
64
|
methods?: Record<string, MethodDef>;
|
|
63
65
|
events?: Record<string, EventDef>;
|
|
64
66
|
}
|
|
67
|
+
interface RpcCollection {
|
|
68
|
+
methods?: Record<string, Method>;
|
|
69
|
+
events?: Record<string, Event>;
|
|
70
|
+
}
|
|
65
71
|
/**
|
|
66
72
|
* Infer the input type from a method definition
|
|
67
73
|
*
|
|
@@ -83,11 +89,11 @@ type InferEventData<T extends EventDef> = z.infer<T["data"]>;
|
|
|
83
89
|
/**
|
|
84
90
|
* Infer method signatures from a schema's methods
|
|
85
91
|
*/
|
|
86
|
-
type InferMethods<T extends Record<string, MethodDef
|
|
92
|
+
type InferMethods<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef> ? { [K in StringKeys<T>]: (input: z.input<T[K]["input"]>) => z.output<T[K]["output"]> | Promise<z.output<T[K]["output"]>> } : Record<string, Method>;
|
|
87
93
|
/**
|
|
88
94
|
* Infer event emitter signatures from a schema's events
|
|
89
95
|
*/
|
|
90
|
-
type InferEvents<T extends Record<string, EventDef
|
|
96
|
+
type InferEvents<T extends RpcSchema["events"]> = T extends Record<string, EventDef> ? { [K in StringKeys<T>]: z.infer<T[K]["data"]> } : Record<string, Event>;
|
|
91
97
|
/**
|
|
92
98
|
* Provider type - implements the local methods defined in a schema
|
|
93
99
|
*/
|
|
@@ -99,10 +105,14 @@ type Driver<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef
|
|
|
99
105
|
/**
|
|
100
106
|
* Event handler type - handles incoming events
|
|
101
107
|
*/
|
|
102
|
-
|
|
108
|
+
interface EventHandler<T extends RpcSchema["events"], ExtraArgs extends any[] = []> {
|
|
109
|
+
<K$1 extends StringKeys<InferEvents<T>>>(...args: [...ExtraArgs, event: K$1, data: InferEvents<T>[K$1]]): void;
|
|
110
|
+
}
|
|
103
111
|
/**
|
|
104
112
|
* Event emitter type - emits outgoing events
|
|
105
113
|
*/
|
|
106
|
-
|
|
114
|
+
interface EventEmitter<T extends RpcSchema["events"], ExtraArgs extends any[] = []> {
|
|
115
|
+
<K$1 extends StringKeys<InferEvents<T>>>(...args: [event: K$1, data: InferEvents<T>[K$1], ...ExtraArgs]): void;
|
|
116
|
+
}
|
|
107
117
|
//#endregion
|
|
108
|
-
export {
|
|
118
|
+
export { RpcSchema as _, EventHandler as a, method as b, InferInput as c, LiteralString as d, LiteralStringUnion as f, RpcCollection as g, Provider as h, EventEmitter as i, InferMethods as l, MethodDef as m, Event as n, InferEventData as o, Method as p, EventDef as r, InferEvents as s, Driver as t, InferOutput as u, StringKeys as v, event as y };
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
export { Driver, EventDef, EventEmitter, EventHandler, InferEventData, InferEvents, InferInput, InferMethods, InferOutput, LiteralString, LiteralStringUnion, MethodDef, Provider, RpcSchema, StringKeys, event, method };
|
|
1
|
+
import { _ as RpcSchema, a as EventHandler, b as method, c as InferInput, d as LiteralString, f as LiteralStringUnion, g as RpcCollection, h as Provider, i as EventEmitter, l as InferMethods, m as MethodDef, n as Event, o as InferEventData, p as Method, r as EventDef, s as InferEvents, t as Driver, u as InferOutput, v as StringKeys, y as event } from "./schema-B0zKtaPR.js";
|
|
2
|
+
export { Driver, Event, EventDef, EventEmitter, EventHandler, InferEventData, InferEvents, InferInput, InferMethods, InferOutput, LiteralString, LiteralStringUnion, Method, MethodDef, Provider, RpcCollection, RpcSchema, StringKeys, event, method };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as RpcProtocol } from "./protocol-
|
|
3
|
-
import { a as IRpcOptions, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, u as WebSocketServerOptions } from "./types-
|
|
4
|
-
import { t as RpcPeer } from "./default-
|
|
1
|
+
import { _ as RpcSchema, h as Provider, s as InferEvents, v as StringKeys } from "./schema-B0zKtaPR.js";
|
|
2
|
+
import { u as RpcProtocol } from "./protocol-DxoHWqMA.js";
|
|
3
|
+
import { a as IRpcOptions, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, u as WebSocketServerOptions } from "./types-BUYZxMco.js";
|
|
4
|
+
import { t as RpcPeer } from "./default-CKJtfuap.js";
|
|
5
5
|
import { IMultiAdapterHooks, IMultiConnectionAdapter, MultiDriver } from "./adapters/types.js";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/multi-peer.d.ts
|
|
@@ -115,7 +115,7 @@ declare abstract class MultiPeerBase<TLocalSchema extends RpcSchema, TRemoteSche
|
|
|
115
115
|
* @param data - Event data matching the schema
|
|
116
116
|
* @param ids - Optional array of peer IDs to emit to (broadcasts to all if omitted)
|
|
117
117
|
*/
|
|
118
|
-
emit<K extends StringKeys<TLocalSchema["events"]
|
|
118
|
+
emit<K extends StringKeys<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K], ids?: string[]): void;
|
|
119
119
|
/**
|
|
120
120
|
* Close a specific peer by ID
|
|
121
121
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as StringCodec } from "./factory-
|
|
2
|
-
import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-
|
|
1
|
+
import { i as StringCodec } from "./factory-CZioNF7N.js";
|
|
2
|
+
import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-RK7s4DQf.js";
|
|
3
3
|
|
|
4
4
|
//#region src/storage/sql.d.ts
|
|
5
5
|
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-
|
|
6
|
-
import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-
|
|
7
|
-
import { n as SqlPendingCallStorageOptions, t as SqlPendingCallStorage } from "../sql-
|
|
5
|
+
import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-RK7s4DQf.js";
|
|
6
|
+
import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-BxojNC-D.js";
|
|
7
|
+
import { n as SqlPendingCallStorageOptions, t as SqlPendingCallStorage } from "../sql-xafn7bdx.js";
|
|
8
8
|
export { type AsyncPendingCallStorage, type MaybePromise, MemoryPendingCallStorage, type MemoryPendingCallStorageOptions, type PendingCall, type PendingCallStorage, SqlPendingCallStorage, type SqlPendingCallStorageOptions, type StorageMode, type SyncPendingCallStorage };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import { a as PendingCallStorage, i as PendingCall, n as IContinuationHandler, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import { a as PendingCallStorage, i as PendingCall, n as IContinuationHandler, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-RK7s4DQf.js";
|
|
3
3
|
export { AsyncPendingCallStorage, IContinuationHandler, MaybePromise, PendingCall, PendingCallStorage, StorageMode, SyncPendingCallStorage };
|
package/dist/storage/memory.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../interface-
|
|
6
|
-
import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-
|
|
5
|
+
import "../interface-RK7s4DQf.js";
|
|
6
|
+
import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-BxojNC-D.js";
|
|
7
7
|
export { MemoryPendingCallStorage, MemoryPendingCallStorageOptions };
|
package/dist/storage/sql.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../schema-
|
|
2
|
-
import "../factory-
|
|
3
|
-
import "../json-
|
|
1
|
+
import "../schema-B0zKtaPR.js";
|
|
2
|
+
import "../factory-CZioNF7N.js";
|
|
3
|
+
import "../json-1pVWk4mJ.js";
|
|
4
4
|
import "../index-Be7jjS77.js";
|
|
5
|
-
import "../interface-
|
|
6
|
-
import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-
|
|
5
|
+
import "../interface-RK7s4DQf.js";
|
|
6
|
+
import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-xafn7bdx.js";
|
|
7
7
|
export { SqlPendingCallStorage, SqlPendingCallStorageOptions, SqlStorage, SqlStorageCursor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as WireInput, u as RpcProtocol } from "./protocol-
|
|
1
|
+
import { _ as RpcSchema, a as EventHandler, h as Provider, i as EventEmitter, m as MethodDef, r as EventDef } from "./schema-B0zKtaPR.js";
|
|
2
|
+
import { g as WireInput, u as RpcProtocol } from "./protocol-DxoHWqMA.js";
|
|
3
3
|
|
|
4
4
|
//#region src/types.d.ts
|
|
5
5
|
|
|
@@ -83,9 +83,9 @@ interface IRpcOptions<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcS
|
|
|
83
83
|
*
|
|
84
84
|
* @typeParam TLocalSchema - Schema defining local methods
|
|
85
85
|
*/
|
|
86
|
-
interface IMethodController<
|
|
86
|
+
interface IMethodController<TLocalMethods extends Record<string, MethodDef> | undefined> {
|
|
87
87
|
/** Implementation of local methods */
|
|
88
|
-
readonly provider: Provider<
|
|
88
|
+
readonly provider: Provider<TLocalMethods>;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Interface for types that can emit and receive events
|
|
@@ -95,18 +95,18 @@ interface IMethodController<TLocalSchema extends RpcSchema> {
|
|
|
95
95
|
* @typeParam EmitArgs - Additional arguments for emit (e.g., peer IDs)
|
|
96
96
|
* @typeParam EventArgs - Additional arguments for event handler
|
|
97
97
|
*/
|
|
98
|
-
interface IEventController<
|
|
98
|
+
interface IEventController<TLocalEvents extends Record<string, EventDef> | undefined, TRemoteEvents extends Record<string, EventDef> | undefined, EmitArgs extends any[] = [], EventArgs extends any[] = []> {
|
|
99
99
|
/** Emit an event to the connected peer */
|
|
100
|
-
emit: EventEmitter<
|
|
100
|
+
emit: EventEmitter<TLocalEvents, EmitArgs>;
|
|
101
101
|
/** Called when receiving an event from the connected peer */
|
|
102
|
-
onEvent?: EventHandler<
|
|
102
|
+
onEvent?: EventHandler<TRemoteEvents, EventArgs>;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Base interface for RPC connections (1-1)
|
|
106
106
|
*
|
|
107
107
|
* Implemented by RpcPeer.
|
|
108
108
|
*/
|
|
109
|
-
interface IRpcConnection<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema>, IEventController<TLocalSchema, TRemoteSchema> {
|
|
109
|
+
interface IRpcConnection<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema["methods"]>, IEventController<TLocalSchema["events"], TRemoteSchema["events"]> {
|
|
110
110
|
/** Timeout for RPC calls in ms */
|
|
111
111
|
readonly timeout: number;
|
|
112
112
|
/** Handle an incoming WebSocket message */
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./schema-
|
|
2
|
-
import "./factory-
|
|
3
|
-
import "./json-
|
|
1
|
+
import "./schema-B0zKtaPR.js";
|
|
2
|
+
import "./factory-CZioNF7N.js";
|
|
3
|
+
import "./json-1pVWk4mJ.js";
|
|
4
4
|
import "./index-Be7jjS77.js";
|
|
5
|
-
import "./protocol-
|
|
6
|
-
import { a as IRpcOptions, c as WebSocketOptions, i as IRpcConnection, l as WebSocketReadyState, n as IMethodController, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, t as IEventController, u as WebSocketServerOptions } from "./types-
|
|
5
|
+
import "./protocol-DxoHWqMA.js";
|
|
6
|
+
import { a as IRpcOptions, c as WebSocketOptions, i as IRpcConnection, l as WebSocketReadyState, n as IMethodController, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, t as IEventController, u as WebSocketServerOptions } from "./types-BUYZxMco.js";
|
|
7
7
|
export { IEventController, IMethodController, IMinWebSocket, IRpcConnection, IRpcOptions, IWebSocket, IWebSocketServer, WebSocketOptions, WebSocketReadyState, WebSocketServerOptions };
|
package/package.json
CHANGED