@igoforth/ws-rpc 1.1.2 → 1.1.4

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.
Files changed (58) hide show
  1. package/dist/adapters/client.d.ts +10 -11
  2. package/dist/adapters/client.js +8 -9
  3. package/dist/adapters/cloudflare-do.d.ts +8 -8
  4. package/dist/adapters/cloudflare-do.js +11 -11
  5. package/dist/adapters/index.d.ts +9 -9
  6. package/dist/adapters/index.js +6 -6
  7. package/dist/adapters/server.d.ts +8 -8
  8. package/dist/adapters/server.js +6 -6
  9. package/dist/adapters/types.d.ts +14 -12
  10. package/dist/adapters/types.js +1 -1
  11. package/dist/codecs/cbor.d.ts +2 -2
  12. package/dist/codecs/factory.d.ts +2 -2
  13. package/dist/codecs/index.d.ts +4 -4
  14. package/dist/codecs/json.d.ts +3 -3
  15. package/dist/codecs/msgpack.d.ts +2 -2
  16. package/dist/{default-B6CVJfTD.js → default-DwjN80sT.js} +13 -5
  17. package/dist/{default-CKJtfuap.d.ts → default-s4vvfkK4.d.ts} +4 -4
  18. package/dist/{durable-DENcbnTp.js → durable-BIdilnMO.js} +1 -1
  19. package/dist/{errors-5BfreE63.js → errors-C5IC-13X.js} +1 -1
  20. package/dist/errors.js +2 -2
  21. package/dist/{factory-CZioNF7N.d.ts → factory-uZbj772l.d.ts} +1 -1
  22. package/dist/index-xZrKqrOZ.d.ts +7 -0
  23. package/dist/index.d.ts +11 -12
  24. package/dist/index.js +3 -3
  25. package/dist/{interface-RK7s4DQf.d.ts → interface-Dwr9zDR6.d.ts} +1 -1
  26. package/dist/{json-1pVWk4mJ.d.ts → json-BBnW1n_D.d.ts} +1 -1
  27. package/dist/{memory-BxojNC-D.d.ts → memory-CPEAGd76.d.ts} +2 -2
  28. package/dist/{multi-peer-DFUqFBsx.js → multi-peer-T1uQHC-l.js} +15 -14
  29. package/dist/peers/default.d.ts +7 -7
  30. package/dist/peers/default.js +3 -3
  31. package/dist/peers/durable.d.ts +8 -8
  32. package/dist/peers/durable.js +4 -4
  33. package/dist/peers/index.d.ts +8 -8
  34. package/dist/peers/index.js +4 -4
  35. package/dist/promise-CjrOX-DI.js +8 -0
  36. package/dist/{protocol-DxoHWqMA.d.ts → protocol-B6z2_jyb.d.ts} +6 -6
  37. package/dist/{protocol-_mpoOPp6.js → protocol-C5QIKXey.js} +2 -2
  38. package/dist/protocol.d.ts +5 -5
  39. package/dist/protocol.js +1 -1
  40. package/dist/{schema-B0zKtaPR.d.ts → schema-DVufxLYY.d.ts} +37 -13
  41. package/dist/schema.d.ts +2 -2
  42. package/dist/schema.js +0 -14
  43. package/dist/{server-q205-WY8.d.ts → server-Cp7xKF5w.d.ts} +7 -9
  44. package/dist/{sql-xafn7bdx.d.ts → sql-DYEHo09F.d.ts} +2 -2
  45. package/dist/storage/index.d.ts +7 -7
  46. package/dist/storage/interface.d.ts +2 -2
  47. package/dist/storage/memory.d.ts +6 -6
  48. package/dist/storage/sql.d.ts +6 -6
  49. package/dist/{types-BUYZxMco.d.ts → types-DTHyD7n1.d.ts} +2 -2
  50. package/dist/types.d.ts +6 -6
  51. package/dist/utils/index.d.ts +3 -2
  52. package/dist/utils/index.js +3 -2
  53. package/dist/utils/reconnect.d.ts +1 -1
  54. package/dist/utils/reconnect.js +1 -1
  55. package/package.json +1 -1
  56. /package/dist/{index-Be7jjS77.d.ts → index-DAwMsCZ3.d.ts} +0 -0
  57. /package/dist/{reconnect-DbcN0R_1.d.ts → reconnect-CYt5_8Xy.d.ts} +0 -0
  58. /package/dist/{reconnect-CGAA_1Gf.js → reconnect-Cdr_3mjN.js} +0 -0
@@ -1,11 +1,11 @@
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
- import "../index-Be7jjS77.js";
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
- import { t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
1
+ import { g as Provider, o as EventTuple, t as Driver, v as RpcSchema } from "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import { u as RpcProtocol } from "../protocol-B6z2_jyb.js";
6
+ import { a as IRpcOptions, c as WebSocketOptions, o as IWebSocket } from "../types-DTHyD7n1.js";
7
+ import "../default-s4vvfkK4.js";
8
+ import { t as ReconnectOptions } from "../reconnect-CYt5_8Xy.js";
9
9
  import { IAdapterHooks, IConnectionAdapter } from "./types.js";
10
10
 
11
11
  //#region src/adapters/client.d.ts
@@ -72,10 +72,9 @@ declare class RpcClient<TLocalSchema extends RpcSchema, TRemoteSchema extends Rp
72
72
  /**
73
73
  * Emit an event to the server (fire-and-forget)
74
74
  *
75
- * @param event - Event name from local schema
76
- * @param data - Event data matching the schema
75
+ * @param args - Event name and data as tuple
77
76
  */
78
- emit<K extends StringKeys<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K]): void;
77
+ emit(...args: EventTuple<TLocalSchema["events"]>): void;
79
78
  /**
80
79
  * Connect to the WebSocket server
81
80
  *
@@ -1,11 +1,11 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
6
  import { t as WebSocketReadyState } from "../types-D_psiH09.js";
7
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-CGAA_1Gf.js";
8
- import { t as RpcPeer } from "../default-B6CVJfTD.js";
7
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
8
+ import { t as RpcPeer } from "../default-DwjN80sT.js";
9
9
  import "./types.js";
10
10
 
11
11
  //#region src/adapters/client.ts
@@ -81,15 +81,14 @@ var RpcClient = class {
81
81
  /**
82
82
  * Emit an event to the server (fire-and-forget)
83
83
  *
84
- * @param event - Event name from local schema
85
- * @param data - Event data matching the schema
84
+ * @param args - Event name and data as tuple
86
85
  */
87
- emit(event, data) {
86
+ emit(...args) {
88
87
  if (!this.peer) {
89
- console.warn(`Cannot emit event '${String(event)}': not connected`);
88
+ console.warn(`Cannot emit event '${args[0]}': not connected`);
90
89
  return;
91
90
  }
92
- this.peer.emit(event, data);
91
+ this.peer.emit(...args);
93
92
  }
94
93
  /**
95
94
  * Connect to the WebSocket server
@@ -1,10 +1,10 @@
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
- import "../index-Be7jjS77.js";
5
- import "../protocol-DxoHWqMA.js";
6
- import { a as IRpcOptions } from "../types-BUYZxMco.js";
7
- import { t as RpcPeer } from "../default-CKJtfuap.js";
1
+ import { g as Provider, o as EventTuple, v as RpcSchema } from "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import { a as IRpcOptions } from "../types-DTHyD7n1.js";
7
+ import { t as RpcPeer } from "../default-s4vvfkK4.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<InferEvents<TRemoteSchema["events"]>>>(peer: RpcPeer<TLocalSchema, TRemoteSchema>, event: K, data: InferEvents<TRemoteSchema["events"]>[K]): void;
31
+ onRpcEvent(peer: RpcPeer<TLocalSchema, TRemoteSchema>, ...args: EventTuple<TRemoteSchema["events"]>): 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. */
@@ -1,12 +1,12 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
6
  import { t as SqlPendingCallStorage } from "../sql-CCjc6Bid.js";
7
- import "../default-B6CVJfTD.js";
8
- import { n as createDurableRpcPeerFactory } from "../durable-DENcbnTp.js";
9
- import { t as MultiPeerBase } from "../multi-peer-DFUqFBsx.js";
7
+ import "../default-DwjN80sT.js";
8
+ import { n as createDurableRpcPeerFactory } from "../durable-BIdilnMO.js";
9
+ import { t as MultiPeerBase } from "../multi-peer-T1uQHC-l.js";
10
10
 
11
11
  //#region src/adapters/cloudflare-do.ts
12
12
  /**
@@ -35,8 +35,8 @@ var DOMultiPeer = class extends MultiPeerBase {
35
35
  remoteSchema: this.remoteSchema,
36
36
  provider,
37
37
  ...this.protocol !== void 0 && { protocol: this.protocol },
38
- onEvent: (event, data) => {
39
- this.hooks.onEvent?.(peer, event, data);
38
+ onEvent: (...args) => {
39
+ this.hooks.onEvent?.(peer, ...args);
40
40
  },
41
41
  timeout: this.timeout
42
42
  });
@@ -148,7 +148,7 @@ function withRpc(Base, options) {
148
148
  hooks: {
149
149
  onConnect: (peer) => this.onRpcConnect(peer),
150
150
  onDisconnect: (peer) => this.onRpcDisconnect(peer),
151
- onEvent: (peer, event, data) => this.onRpcEvent(peer, event, data),
151
+ onEvent: (peer, ...args) => this.onRpcEvent(peer, ...args),
152
152
  onError: (peer, error) => this.onRpcError(peer, error),
153
153
  onPeerRecreated: (peer, ws) => this.onRpcPeerRecreated(peer, ws)
154
154
  }
@@ -159,7 +159,7 @@ function withRpc(Base, options) {
159
159
  /** Called when a peer disconnects. Override to handle disconnection events. */
160
160
  onRpcDisconnect(_peer) {}
161
161
  /** Called when an event is received from a peer. Override to handle events. */
162
- onRpcEvent(_peer, _event, _data) {}
162
+ onRpcEvent(_peer, ...[_event, _data]) {}
163
163
  /** Called when a peer encounters an error. Override to handle errors. */
164
164
  onRpcError(_peer, _error) {}
165
165
  /** Called when a peer is recreated after hibernation. Override to handle recovery. */
@@ -177,8 +177,8 @@ function withRpc(Base, options) {
177
177
  * @param data - Event data matching the schema
178
178
  * @param ids - Optional array of peer IDs to emit to (broadcasts to all if omitted)
179
179
  */
180
- emit(event, data, ids) {
181
- this._rpc.emit(event, data, ids);
180
+ emit(...args) {
181
+ this._rpc.emit(...args);
182
182
  }
183
183
  /**
184
184
  * Get the number of connected peers
@@ -1,13 +1,13 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
5
- import "../protocol-DxoHWqMA.js";
6
- import "../types-BUYZxMco.js";
7
- import "../default-CKJtfuap.js";
8
- import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import "../types-DTHyD7n1.js";
7
+ import "../default-s4vvfkK4.js";
8
+ import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-CYt5_8Xy.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-q205-WY8.js";
12
+ import { n as RpcServerOptions, r as MultiPeerBase, t as RpcServer } from "../server-Cp7xKF5w.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,15 +1,15 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
6
  import "../sql-CCjc6Bid.js";
7
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-CGAA_1Gf.js";
8
- import "../default-B6CVJfTD.js";
9
- import "../durable-DENcbnTp.js";
7
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
8
+ import "../default-DwjN80sT.js";
9
+ import "../durable-BIdilnMO.js";
10
10
  import "./types.js";
11
11
  import { RpcClient } from "./client.js";
12
- import { t as MultiPeerBase } from "../multi-peer-DFUqFBsx.js";
12
+ import { t as MultiPeerBase } from "../multi-peer-T1uQHC-l.js";
13
13
  import { withRpc } from "./cloudflare-do.js";
14
14
  import { RpcServer } from "./server.js";
15
15
 
@@ -1,10 +1,10 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
5
- import "../protocol-DxoHWqMA.js";
6
- import "../types-BUYZxMco.js";
7
- import "../default-CKJtfuap.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import "../types-DTHyD7n1.js";
7
+ import "../default-s4vvfkK4.js";
8
8
  import "./types.js";
9
- import { n as RpcServerOptions, t as RpcServer } from "../server-q205-WY8.js";
9
+ import { n as RpcServerOptions, t as RpcServer } from "../server-Cp7xKF5w.js";
10
10
  export { RpcServer, RpcServerOptions };
@@ -1,11 +1,11 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
6
  import { t as WebSocketReadyState } from "../types-D_psiH09.js";
7
- import { t as RpcPeer } from "../default-B6CVJfTD.js";
8
- import { t as MultiPeerBase } from "../multi-peer-DFUqFBsx.js";
7
+ import { t as RpcPeer } from "../default-DwjN80sT.js";
8
+ import { t as MultiPeerBase } from "../multi-peer-T1uQHC-l.js";
9
9
 
10
10
  //#region src/adapters/server.ts
11
11
  /**
@@ -80,8 +80,8 @@ var RpcServer = class extends MultiPeerBase {
80
80
  provider: this.provider,
81
81
  ...this.protocol !== void 0 && { protocol: this.protocol },
82
82
  timeout: this.timeout,
83
- onEvent: (event, data) => {
84
- this.hooks.onEvent?.(peer, event, data);
83
+ onEvent: (...args) => {
84
+ this.hooks.onEvent?.(peer, ...args);
85
85
  }
86
86
  });
87
87
  this.addPeer(ws, peer);
@@ -1,11 +1,11 @@
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
- import "../index-Be7jjS77.js";
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
- import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
1
+ import { a as EventHandler, d as InferOutput, h as MethodDef, l as InferInput, r as EventDef, t as Driver, v as RpcSchema, y as StringKeys } from "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import { a as IRpcOptions, n as IMethodController, t as IEventController } from "../types-DTHyD7n1.js";
7
+ import { t as RpcPeer } from "../default-s4vvfkK4.js";
8
+ import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-CYt5_8Xy.js";
9
9
 
10
10
  //#region src/adapters/types.d.ts
11
11
 
@@ -72,9 +72,11 @@ type MultiCallResult<T> = {
72
72
  * });
73
73
  * ```
74
74
  */
75
- type MultiDriver<TRemoteSchema extends RpcSchema> = TRemoteSchema["methods"] extends Record<string, MethodDef> ? { [K in StringKeys<TRemoteSchema["methods"]>]: <O extends MultiCallOptions>(input: TRemoteSchema["methods"] extends Record<string, MethodDef> ? InferInput<TRemoteSchema["methods"][K]> : never, options?: O) => Promise<O extends {
76
- ids: infer I;
77
- } ? string extends I ? MultiCallResult<TRemoteSchema["methods"] extends Record<string, MethodDef> ? InferOutput<TRemoteSchema["methods"][K]> : never> : Array<MultiCallResult<TRemoteSchema["methods"] extends Record<string, MethodDef> ? InferOutput<TRemoteSchema["methods"][K]> : never>> : never> } : never;
75
+ type MultiDriver<TRemoteMethods extends RpcSchema["methods"]> = TRemoteMethods extends Record<string, MethodDef> ? { [K in StringKeys<TRemoteMethods>]: <O extends MultiCallOptions = {}>(...args: TRemoteMethods[K] extends {
76
+ input: any;
77
+ } ? [input: InferInput<TRemoteMethods[K]>, options?: O] : [options?: O]) => Promise<O extends {
78
+ ids: string;
79
+ } ? MultiCallResult<InferOutput<TRemoteMethods[K]>> : Array<MultiCallResult<InferOutput<TRemoteMethods[K]>>>> } : never;
78
80
  /**
79
81
  * Event emitter type for client callbacks
80
82
  */
@@ -114,7 +116,7 @@ interface IConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema exten
114
116
  */
115
117
  interface IMultiConnectionAdapter<TLocalSchema extends RpcSchema, TRemoteSchema extends RpcSchema> extends IRpcOptions<TLocalSchema, TRemoteSchema>, IMethodController<TLocalSchema["methods"]>, IEventController<TLocalSchema["events"], TRemoteSchema["events"], [ids?: string[]]> {
116
118
  /** Driver for calling remote methods on connected peers */
117
- readonly driver: MultiDriver<TRemoteSchema>;
119
+ readonly driver: MultiDriver<TRemoteSchema["methods"]>;
118
120
  readonly hooks: IMultiAdapterHooks<TLocalSchema, TRemoteSchema>;
119
121
  /** Get count of connected peers */
120
122
  getConnectionCount(): number;
@@ -1,3 +1,3 @@
1
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-CGAA_1Gf.js";
1
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
2
2
 
3
3
  export { calculateReconnectDelay, defaultReconnectOptions };
@@ -1,5 +1,5 @@
1
- import "../schema-B0zKtaPR.js";
2
- import { n as CodecFactory } from "../factory-CZioNF7N.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import { n as CodecFactory } from "../factory-uZbj772l.js";
3
3
  import * as z from "zod";
4
4
 
5
5
  //#region src/codecs/cbor.d.ts
@@ -1,3 +1,3 @@
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";
1
+ import "../schema-DVufxLYY.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-uZbj772l.js";
3
3
  export { BinaryCodec, CodecFactory, CodecOptions, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createStringCodecFactory, isBinaryCodec, isStringCodec };
@@ -1,5 +1,5 @@
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
- import "../index-Be7jjS77.js";
1
+ import "../schema-DVufxLYY.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-uZbj772l.js";
3
+ import { n as createJsonCodec, t as JsonCodec } from "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
5
  export { BinaryCodec, CodecFactory, CodecOptions, JsonCodec, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createJsonCodec, createStringCodecFactory, isBinaryCodec, isStringCodec };
@@ -1,4 +1,4 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import { n as createJsonCodec, t as JsonCodec } from "../json-1pVWk4mJ.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import { n as createJsonCodec, t as JsonCodec } from "../json-BBnW1n_D.js";
4
4
  export { JsonCodec, createJsonCodec };
@@ -1,5 +1,5 @@
1
- import "../schema-B0zKtaPR.js";
2
- import { n as CodecFactory } from "../factory-CZioNF7N.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import { n as CodecFactory } from "../factory-uZbj772l.js";
3
3
  import * as z from "zod";
4
4
 
5
5
  //#region src/codecs/msgpack.d.ts
@@ -1,5 +1,5 @@
1
- import { n as RpcErrorCodes, t as JsonProtocol } from "./protocol-_mpoOPp6.js";
2
- import { a as RpcTimeoutError, i as RpcRemoteError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-5BfreE63.js";
1
+ import { n as RpcErrorCodes, t as JsonProtocol } from "./protocol-C5QIKXey.js";
2
+ import { a as RpcTimeoutError, i as RpcRemoteError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-C5IC-13X.js";
3
3
  import { v7 } from "uuid";
4
4
 
5
5
  //#region src/peers/default.ts
@@ -61,7 +61,11 @@ var RpcPeer = class {
61
61
  if (this.closed || this.ws.readyState !== 1) throw new RpcConnectionClosed();
62
62
  const methodDef = this.remoteSchema.methods?.[method];
63
63
  if (!methodDef) throw new RpcMethodNotFoundError(method);
64
- const parseResult = methodDef.input.safeParse(input);
64
+ let parseResult = {
65
+ success: true,
66
+ data: void 0
67
+ };
68
+ if (methodDef.input) parseResult = methodDef.input.safeParse(input);
65
69
  if (!parseResult.success) throw new RpcValidationError(`Invalid input for method '${method}'`, parseResult.error);
66
70
  const id = this.generateId();
67
71
  const timeoutMs = timeout ?? this.defaultTimeout;
@@ -82,7 +86,7 @@ var RpcPeer = class {
82
86
  /**
83
87
  * Emit an event to the remote peer (fire-and-forget)
84
88
  */
85
- emit(event, data) {
89
+ emit(...[event, data]) {
86
90
  if (this.closed || this.ws.readyState !== 1) {
87
91
  console.warn(`Cannot emit event '${String(event)}': connection closed`);
88
92
  return;
@@ -143,7 +147,11 @@ var RpcPeer = class {
143
147
  this.sendError(id, RpcErrorCodes.METHOD_NOT_FOUND, `Method '${method}' not found`);
144
148
  return;
145
149
  }
146
- const parseResult = await methodDef.input.safeParseAsync(params);
150
+ let parseResult = {
151
+ success: true,
152
+ data: void 0
153
+ };
154
+ if (methodDef.input) parseResult = await methodDef.input.safeParseAsync(params);
147
155
  if (!parseResult.success) {
148
156
  this.sendError(id, RpcErrorCodes.INVALID_PARAMS, `Invalid params for '${method}'`, parseResult.error);
149
157
  return;
@@ -1,6 +1,6 @@
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";
1
+ import { a as EventHandler, g as Provider, o as EventTuple, t as Driver, v as RpcSchema } from "./schema-DVufxLYY.js";
2
+ import { g as WireInput, u as RpcProtocol } from "./protocol-B6z2_jyb.js";
3
+ import { a as IRpcOptions, r as IMinWebSocket } from "./types-DTHyD7n1.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<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K]): void;
58
+ emit(...[event, data]: EventTuple<TLocalSchema["events"]>): void;
59
59
  /**
60
60
  * Handle an incoming WebSocket message
61
61
  *
@@ -1,4 +1,4 @@
1
- import { t as RpcPeer } from "./default-B6CVJfTD.js";
1
+ import { t as RpcPeer } from "./default-DwjN80sT.js";
2
2
 
3
3
  //#region src/peers/durable.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { n as RpcErrorCodes } from "./protocol-_mpoOPp6.js";
1
+ import { n as RpcErrorCodes } from "./protocol-C5QIKXey.js";
2
2
 
3
3
  //#region src/errors.ts
4
4
  /**
package/dist/errors.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./factory-3ziwTuZe.js";
2
2
  import "./json-Bshec-bZ.js";
3
3
  import "./codecs-BmYG2d_U.js";
4
- import "./protocol-_mpoOPp6.js";
5
- import { a as RpcTimeoutError, i as RpcRemoteError, n as RpcError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-5BfreE63.js";
4
+ import "./protocol-C5QIKXey.js";
5
+ import { a as RpcTimeoutError, i as RpcRemoteError, n as RpcError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-C5IC-13X.js";
6
6
 
7
7
  export { RpcConnectionClosed, RpcError, RpcMethodNotFoundError, RpcRemoteError, RpcTimeoutError, RpcValidationError };
@@ -1,4 +1,4 @@
1
- import { f as LiteralStringUnion } from "./schema-B0zKtaPR.js";
1
+ import { p as LiteralStringUnion } from "./schema-DVufxLYY.js";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/codecs/factory.d.ts
@@ -0,0 +1,7 @@
1
+ //#region src/utils/promise.d.ts
2
+ /**
3
+ * Checks if a value is a Promise.
4
+ */
5
+ declare const isPromise: <T>(value: T | Promise<T>) => value is Promise<T>;
6
+ //#endregion
7
+ export { isPromise as t };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
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
- 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-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
- import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "./reconnect-DbcN0R_1.js";
1
+ import { a as EventHandler, b as event, c as InferEvents, d as InferOutput, g as Provider, h as MethodDef, l as InferInput, o as EventTuple, r as EventDef, s as InferEventData, t as Driver, u as InferMethods, v as RpcSchema, x as method } from "./schema-DVufxLYY.js";
2
+ import "./factory-uZbj772l.js";
3
+ import "./json-BBnW1n_D.js";
4
+ import "./index-DAwMsCZ3.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-B6z2_jyb.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-DTHyD7n1.js";
7
+ import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "./reconnect-CYt5_8Xy.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-RK7s4DQf.js";
10
- import { t as MemoryPendingCallStorage } from "./memory-BxojNC-D.js";
11
- import { t as SqlPendingCallStorage } from "./sql-xafn7bdx.js";
9
+ import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "./interface-Dwr9zDR6.js";
10
+ import { t as MemoryPendingCallStorage } from "./memory-CPEAGd76.js";
11
+ import { t as SqlPendingCallStorage } from "./sql-DYEHo09F.js";
12
12
  import "./storage/index.js";
13
- import "./utils/index.js";
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 };
13
+ export { type AsyncPendingCallStorage, type Driver, type EventDef, type EventHandler, type EventTuple, 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 };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import "./factory-3ziwTuZe.js";
2
2
  import "./json-Bshec-bZ.js";
3
3
  import "./codecs-BmYG2d_U.js";
4
- import { a as RpcMessageCodec, c as RpcResponseSchema, i as RpcEventSchema, l as createProtocol, n as RpcErrorCodes, o as RpcMessageSchema, r as RpcErrorSchema, s as RpcRequestSchema, t as JsonProtocol } from "./protocol-_mpoOPp6.js";
5
- import { a as RpcTimeoutError, i as RpcRemoteError, n as RpcError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-5BfreE63.js";
4
+ import { a as RpcMessageCodec, c as RpcResponseSchema, i as RpcEventSchema, l as createProtocol, n as RpcErrorCodes, o as RpcMessageSchema, r as RpcErrorSchema, s as RpcRequestSchema, t as JsonProtocol } from "./protocol-C5QIKXey.js";
5
+ import { a as RpcTimeoutError, i as RpcRemoteError, n as RpcError, o as RpcValidationError, r as RpcMethodNotFoundError, t as RpcConnectionClosed } from "./errors-C5IC-13X.js";
6
6
  import { event, method } from "./schema.js";
7
7
  import { t as MemoryPendingCallStorage } from "./memory-Bqb3KEVr.js";
8
8
  import { t as SqlPendingCallStorage } from "./sql-CCjc6Bid.js";
9
9
  import "./storage/index.js";
10
10
  import { t as WebSocketReadyState } from "./types-D_psiH09.js";
11
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "./reconnect-CGAA_1Gf.js";
11
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "./reconnect-Cdr_3mjN.js";
12
12
  import "./utils/index.js";
13
13
 
14
14
  export { JsonProtocol, MemoryPendingCallStorage, RpcConnectionClosed, RpcError, RpcErrorCodes, RpcErrorSchema, RpcEventSchema, RpcMessageCodec, RpcMessageSchema, RpcMethodNotFoundError, RpcRemoteError, RpcRequestSchema, RpcResponseSchema, RpcTimeoutError, RpcValidationError, SqlPendingCallStorage, WebSocketReadyState, calculateReconnectDelay, createProtocol, defaultReconnectOptions, event, method };
@@ -1,4 +1,4 @@
1
- import { _ as RpcSchema } from "./schema-B0zKtaPR.js";
1
+ import { v as RpcSchema } from "./schema-DVufxLYY.js";
2
2
 
3
3
  //#region src/storage/interface.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as CodecFactory } from "./factory-CZioNF7N.js";
1
+ import { n as CodecFactory } from "./factory-uZbj772l.js";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/codecs/json.d.ts
@@ -1,5 +1,5 @@
1
- import { i as StringCodec } from "./factory-CZioNF7N.js";
2
- import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-RK7s4DQf.js";
1
+ import { i as StringCodec } from "./factory-uZbj772l.js";
2
+ import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-Dwr9zDR6.js";
3
3
 
4
4
  //#region src/storage/memory.d.ts
5
5
 
@@ -1,4 +1,5 @@
1
- import { t as RpcPeer } from "./default-B6CVJfTD.js";
1
+ import { t as isPromise } from "./promise-CjrOX-DI.js";
2
+ import { t as RpcPeer } from "./default-DwjN80sT.js";
2
3
 
3
4
  //#region src/adapters/multi-peer.ts
4
5
  /**
@@ -53,9 +54,9 @@ var MultiPeerBase = class {
53
54
  remoteSchema: this.remoteSchema,
54
55
  provider: this.provider,
55
56
  ...this.protocol !== void 0 && { protocol: this.protocol },
56
- onEvent: this.hooks.onEvent ? (event, data) => {
57
+ onEvent: this.hooks.onEvent ? (...args) => {
57
58
  const peer = this.findPeerByWs(ws);
58
- if (peer) this.hooks.onEvent(peer, event, data);
59
+ if (peer) this.hooks.onEvent?.(peer, ...args);
59
60
  } : void 0,
60
61
  timeout: this.timeout
61
62
  });
@@ -154,13 +155,13 @@ var MultiPeerBase = class {
154
155
  /**
155
156
  * Emit an event to connected peers
156
157
  *
157
- * @param event - Event name from local schema
158
- * @param data - Event data matching the schema
159
- * @param ids - Optional array of peer IDs to emit to (broadcasts to all if omitted)
158
+ * @param args - Event tuple followed by optional peer IDs
160
159
  */
161
- emit(event, data, ids) {
160
+ emit(...args) {
161
+ const ids = args[2];
162
+ const eventArgs = args.slice(0, 2);
162
163
  const validPeers = ids ? this.peers.values().filter((p) => ids.includes(p.id) && p.isOpen) : this.peers.values().filter((p) => p.isOpen);
163
- for (const peer of validPeers) peer.emit(event, data);
164
+ for (const peer of validPeers) peer.emit(...eventArgs);
164
165
  }
165
166
  /**
166
167
  * Close a specific peer by ID
@@ -195,8 +196,8 @@ var MultiPeerBase = class {
195
196
  createMultiDriver() {
196
197
  const methods = this.remoteSchema.methods ?? {};
197
198
  const driver = {};
198
- for (const methodName of Object.keys(methods)) driver[methodName] = async (input, options) => {
199
- return this.callMethod(methodName, input, options);
199
+ for (const methodName of Object.keys(methods)) driver[methodName] = async (...args) => {
200
+ return this.callMethod(methodName, ...args);
200
201
  };
201
202
  return driver;
202
203
  }
@@ -208,9 +209,9 @@ var MultiPeerBase = class {
208
209
  * @param options - Call options including target peer IDs and timeout
209
210
  * @returns Array of results from each peer (success or error)
210
211
  */
211
- async callMethod(method, input, options) {
212
- const ids = options?.ids;
213
- const timeout = options?.timeout ?? this.timeout;
212
+ async callMethod(method, ...args) {
213
+ const [input, options] = args.length === 2 ? args : [void 0, args[0]];
214
+ const { ids, timeout = this.timeout } = options ?? {};
214
215
  let targetPeers;
215
216
  if (ids === void 0) targetPeers = Array.from(this.peers.values()).filter((p) => p.isOpen);
216
217
  else if (typeof ids === "string") {
@@ -220,7 +221,7 @@ var MultiPeerBase = class {
220
221
  const promises = targetPeers.map(async (peer) => {
221
222
  try {
222
223
  const callPromise = peer.driver[method](input);
223
- const value = await Promise.race([callPromise, new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error(`Timeout after ${timeout}ms`)), timeout))]);
224
+ const value = await Promise.race([isPromise(callPromise) ? callPromise : Promise.resolve(callPromise), new Promise((_, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error(`Timeout after ${timeout}ms`)), timeout))]);
224
225
  return {
225
226
  id: peer.id,
226
227
  result: {
@@ -1,8 +1,8 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
5
- import "../protocol-DxoHWqMA.js";
6
- import "../types-BUYZxMco.js";
7
- import { n as RpcPeerOptions, t as RpcPeer } from "../default-CKJtfuap.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import "../types-DTHyD7n1.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-s4vvfkK4.js";
8
8
  export { RpcPeer, RpcPeerOptions };
@@ -1,8 +1,8 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
6
- import { t as RpcPeer } from "../default-B6CVJfTD.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
+ import { t as RpcPeer } from "../default-DwjN80sT.js";
7
7
 
8
8
  export { RpcPeer };
@@ -1,11 +1,11 @@
1
- import { _ as RpcSchema } from "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
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";
1
+ import { v as RpcSchema } from "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import { g as WireInput } from "../protocol-B6z2_jyb.js";
6
+ import "../types-DTHyD7n1.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-s4vvfkK4.js";
8
+ import { i as PendingCall, s as SyncPendingCallStorage } from "../interface-Dwr9zDR6.js";
9
9
 
10
10
  //#region src/peers/durable.d.ts
11
11
 
@@ -1,9 +1,9 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
6
- import "../default-B6CVJfTD.js";
7
- import { n as createDurableRpcPeerFactory, t as DurableRpcPeer } from "../durable-DENcbnTp.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
+ import "../default-DwjN80sT.js";
7
+ import { n as createDurableRpcPeerFactory, t as DurableRpcPeer } from "../durable-BIdilnMO.js";
8
8
 
9
9
  export { DurableRpcPeer, createDurableRpcPeerFactory };
@@ -1,10 +1,10 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
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";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../protocol-B6z2_jyb.js";
6
+ import "../types-DTHyD7n1.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-s4vvfkK4.js";
8
+ import "../interface-Dwr9zDR6.js";
9
9
  import { CallContext, DurableRpcPeer, DurableRpcPeerOptions } from "./durable.js";
10
10
  export { type CallContext, DurableRpcPeer, type DurableRpcPeerOptions, RpcPeer, type RpcPeerOptions };
@@ -1,9 +1,9 @@
1
1
  import "../factory-3ziwTuZe.js";
2
2
  import "../json-Bshec-bZ.js";
3
3
  import "../codecs-BmYG2d_U.js";
4
- import "../protocol-_mpoOPp6.js";
5
- import "../errors-5BfreE63.js";
6
- import { t as RpcPeer } from "../default-B6CVJfTD.js";
7
- import { t as DurableRpcPeer } from "../durable-DENcbnTp.js";
4
+ import "../protocol-C5QIKXey.js";
5
+ import "../errors-C5IC-13X.js";
6
+ import { t as RpcPeer } from "../default-DwjN80sT.js";
7
+ import { t as DurableRpcPeer } from "../durable-BIdilnMO.js";
8
8
 
9
9
  export { DurableRpcPeer, RpcPeer };
@@ -0,0 +1,8 @@
1
+ //#region src/utils/promise.ts
2
+ /**
3
+ * Checks if a value is a Promise.
4
+ */
5
+ const isPromise = (value) => value != null && typeof value.then === "function";
6
+
7
+ //#endregion
8
+ export { isPromise as t };
@@ -1,4 +1,4 @@
1
- import { a as WireCodec } from "./factory-CZioNF7N.js";
1
+ import { a as WireCodec } from "./factory-uZbj772l.js";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/protocol.d.ts
@@ -10,7 +10,7 @@ declare const RpcRequestSchema: z.ZodObject<{
10
10
  type: z.ZodLiteral<"rpc:request">;
11
11
  id: z.ZodString;
12
12
  method: z.ZodString;
13
- params: z.ZodUnknown;
13
+ params: z.ZodOptional<z.ZodUnknown>;
14
14
  }, z.core.$strip>;
15
15
  type RpcRequest = z.infer<typeof RpcRequestSchema>;
16
16
  /**
@@ -49,7 +49,7 @@ declare const RpcMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
49
49
  type: z.ZodLiteral<"rpc:request">;
50
50
  id: z.ZodString;
51
51
  method: z.ZodString;
52
- params: z.ZodUnknown;
52
+ params: z.ZodOptional<z.ZodUnknown>;
53
53
  }, z.core.$strip>, z.ZodObject<{
54
54
  type: z.ZodLiteral<"rpc:response">;
55
55
  id: z.ZodString;
@@ -97,7 +97,7 @@ declare const RpcMessageCodec: z.ZodCodec<z.ZodString, z.ZodUnion<readonly [z.Zo
97
97
  type: z.ZodLiteral<"rpc:request">;
98
98
  id: z.ZodString;
99
99
  method: z.ZodString;
100
- params: z.ZodUnknown;
100
+ params: z.ZodOptional<z.ZodUnknown>;
101
101
  }, z.core.$strip>, z.ZodObject<{
102
102
  type: z.ZodLiteral<"rpc:response">;
103
103
  id: z.ZodString;
@@ -137,7 +137,7 @@ interface RpcProtocol<TWire extends RpcWireCodec = RpcWireCodec> {
137
137
  /** The underlying codec */
138
138
  readonly codec: TWire;
139
139
  /** Create and encode an RPC request */
140
- createRequest(id: string, method: string, params: unknown): WireDataOf<TWire>;
140
+ createRequest(id: string, method: string, params?: unknown): WireDataOf<TWire>;
141
141
  /** Create and encode an RPC response */
142
142
  createResponse(id: string, result: unknown): WireDataOf<TWire>;
143
143
  /** Create and encode an RPC error */
@@ -191,7 +191,7 @@ declare const JsonProtocol: RpcProtocol<z.ZodCodec<z.ZodString, z.ZodUnion<reado
191
191
  type: z.ZodLiteral<"rpc:request">;
192
192
  id: z.ZodString;
193
193
  method: z.ZodString;
194
- params: z.ZodUnknown;
194
+ params: z.ZodOptional<z.ZodUnknown>;
195
195
  }, z.core.$strip>, z.ZodObject<{
196
196
  type: z.ZodLiteral<"rpc:response">;
197
197
  id: z.ZodString;
@@ -16,7 +16,7 @@ const RpcRequestSchema = z.object({
16
16
  type: z.literal("rpc:request"),
17
17
  id: z.string(),
18
18
  method: z.string(),
19
- params: z.unknown()
19
+ params: z.unknown().optional()
20
20
  });
21
21
  /**
22
22
  * RPC Response - sent as success response to a request
@@ -143,7 +143,7 @@ function createProtocol(codec = RpcMessageCodec) {
143
143
  type: "rpc:request",
144
144
  id,
145
145
  method,
146
- params
146
+ ...params !== void 0 && { params }
147
147
  });
148
148
  },
149
149
  createResponse(id, result) {
@@ -1,6 +1,6 @@
1
- import "./schema-B0zKtaPR.js";
2
- import "./factory-CZioNF7N.js";
3
- import "./json-1pVWk4mJ.js";
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-DxoHWqMA.js";
1
+ import "./schema-DVufxLYY.js";
2
+ import "./factory-uZbj772l.js";
3
+ import "./json-BBnW1n_D.js";
4
+ import "./index-DAwMsCZ3.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-B6z2_jyb.js";
6
6
  export { JsonProtocol, RpcError, RpcErrorCodes, RpcErrorSchema, RpcEvent, RpcEventSchema, RpcMessage, RpcMessageCodec, RpcMessageSchema, RpcProtocol, RpcRequest, RpcRequestSchema, RpcResponse, RpcResponseSchema, RpcWireCodec, WireInput, createProtocol };
package/dist/protocol.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./factory-3ziwTuZe.js";
2
2
  import "./json-Bshec-bZ.js";
3
3
  import "./codecs-BmYG2d_U.js";
4
- import { a as RpcMessageCodec, c as RpcResponseSchema, i as RpcEventSchema, l as createProtocol, n as RpcErrorCodes, o as RpcMessageSchema, r as RpcErrorSchema, s as RpcRequestSchema, t as JsonProtocol } from "./protocol-_mpoOPp6.js";
4
+ import { a as RpcMessageCodec, c as RpcResponseSchema, i as RpcEventSchema, l as createProtocol, n as RpcErrorCodes, o as RpcMessageSchema, r as RpcErrorSchema, s as RpcRequestSchema, t as JsonProtocol } from "./protocol-C5QIKXey.js";
5
5
 
6
6
  export { JsonProtocol, RpcErrorCodes, RpcErrorSchema, RpcEventSchema, RpcMessageCodec, RpcMessageSchema, RpcRequestSchema, RpcResponseSchema, createProtocol };
@@ -11,10 +11,13 @@ type LiteralStringUnion<T> = LiteralUnion<T, string>;
11
11
  */
12
12
  interface MethodDef<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> {
13
13
  _type: "method";
14
- input: TInput;
14
+ input?: TInput;
15
15
  output: TOutput;
16
16
  }
17
- type Method = (input: unknown) => unknown | Promise<unknown>;
17
+ type Method = {
18
+ (): unknown | Promise<unknown>;
19
+ (input: unknown): unknown | Promise<unknown>;
20
+ };
18
21
  /**
19
22
  * Event definition with data schema
20
23
  */
@@ -40,7 +43,17 @@ type Event = unknown;
40
43
  declare function method<TInput extends z.ZodType, TOutput extends z.ZodType>(def: {
41
44
  input: TInput;
42
45
  output: TOutput;
43
- }): MethodDef<TInput, TOutput>;
46
+ }): {
47
+ _type: "method";
48
+ input: TInput;
49
+ output: TOutput;
50
+ };
51
+ declare function method<TOutput extends z.ZodType>(def: {
52
+ output: TOutput;
53
+ }): {
54
+ _type: "method";
55
+ output: TOutput;
56
+ };
44
57
  /**
45
58
  * Define a fire-and-forget event with data schema
46
59
  *
@@ -73,7 +86,9 @@ interface RpcCollection {
73
86
  *
74
87
  * @typeParam T - A MethodDef type to extract the input from
75
88
  */
76
- type InferInput<T extends MethodDef> = z.input<T["input"]>;
89
+ type InferInput<T extends MethodDef> = T extends {
90
+ input: infer I extends z.ZodType;
91
+ } ? z.input<I> : void;
77
92
  /**
78
93
  * Infer the output type from a method definition
79
94
  *
@@ -89,30 +104,39 @@ type InferEventData<T extends EventDef> = z.infer<T["data"]>;
89
104
  /**
90
105
  * Infer method signatures from a schema's methods
91
106
  */
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>;
107
+ type InferMethods<T extends Record<string, MethodDef>> = { [K in StringKeys<T>]: T[K] extends {
108
+ input?: infer I;
109
+ output: infer O;
110
+ } ? (...args: undefined extends I ? [] : [input: z.input<I>]) => z.output<O> | Promise<z.output<O>> : never };
93
111
  /**
94
112
  * Infer event emitter signatures from a schema's events
95
113
  */
96
- type InferEvents<T extends RpcSchema["events"]> = T extends Record<string, EventDef> ? { [K in StringKeys<T>]: z.infer<T[K]["data"]> } : Record<string, Event>;
114
+ type InferEvents<T extends RpcSchema["events"]> = T extends Record<string, EventDef> ? { [K in StringKeys<T>]: InferEventData<T[K]> } : Record<string, Event>;
97
115
  /**
98
116
  * Provider type - implements the local methods defined in a schema
99
117
  */
100
- type Provider<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef> ? InferMethods<T> : {};
118
+ type Provider<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef> ? InferMethods<T> : Record<string, Method>;
101
119
  /**
102
120
  * Driver type - proxy to call remote methods defined in a schema
103
121
  */
104
- type Driver<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef> ? InferMethods<T> : {};
122
+ type Driver<T extends RpcSchema["methods"]> = T extends Record<string, MethodDef> ? InferMethods<T> : Record<string, Method>;
123
+ /**
124
+ * Discriminated event tuple union - enables proper narrowing in switch statements.
125
+ */
126
+ type EventTuple<T extends RpcSchema["events"]> = T extends Record<string, EventDef> ? { [K in keyof T]: [event: K, data: InferEventData<T[K]>] }[keyof T] : [event: string, data: unknown];
105
127
  /**
106
- * Event handler type - handles incoming events
128
+ * Event handler type - handles incoming events.
129
+ * Uses discriminated tuple union for proper type narrowing in switch statements.
107
130
  */
108
131
  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;
132
+ (...args: [...ExtraArgs, ...EventTuple<T>]): void;
110
133
  }
111
134
  /**
112
- * Event emitter type - emits outgoing events
135
+ * Event emitter type - emits outgoing events.
136
+ * Uses discriminated tuple union for proper type narrowing.
113
137
  */
114
138
  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;
139
+ (...args: [...EventTuple<T>, ...ExtraArgs]): void;
116
140
  }
117
141
  //#endregion
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 };
142
+ export { RpcCollection as _, EventHandler as a, event as b, InferEvents as c, InferOutput as d, LiteralString as f, Provider as g, MethodDef as h, EventEmitter as i, InferInput as l, Method as m, Event as n, EventTuple as o, LiteralStringUnion as p, EventDef as r, InferEventData as s, Driver as t, InferMethods as u, RpcSchema as v, method as x, StringKeys as y };
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,2 @@
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
+ import { _ as RpcCollection, a as EventHandler, b as event, c as InferEvents, d as InferOutput, f as LiteralString, g as Provider, h as MethodDef, i as EventEmitter, l as InferInput, m as Method, n as Event, o as EventTuple, p as LiteralStringUnion, r as EventDef, s as InferEventData, t as Driver, u as InferMethods, v as RpcSchema, x as method, y as StringKeys } from "./schema-DVufxLYY.js";
2
+ export { Driver, Event, EventDef, EventEmitter, EventHandler, EventTuple, InferEventData, InferEvents, InferInput, InferMethods, InferOutput, LiteralString, LiteralStringUnion, Method, MethodDef, Provider, RpcCollection, RpcSchema, StringKeys, event, method };
package/dist/schema.js CHANGED
@@ -1,18 +1,4 @@
1
1
  //#region src/schema.ts
2
- /**
3
- * Define an RPC method with input/output schemas
4
- *
5
- * @param def - Object containing input and output Zod schemas
6
- * @returns MethodDef with preserved type information
7
- *
8
- * @example
9
- * ```ts
10
- * const getUser = method({
11
- * input: z.object({ id: z.string() }),
12
- * output: z.object({ name: z.string(), email: z.string() }),
13
- * });
14
- * ```
15
- */
16
2
  function method(def) {
17
3
  return {
18
4
  _type: "method",
@@ -1,7 +1,7 @@
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";
1
+ import { g as Provider, o as EventTuple, v as RpcSchema } from "./schema-DVufxLYY.js";
2
+ import { u as RpcProtocol } from "./protocol-B6z2_jyb.js";
3
+ import { a as IRpcOptions, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, u as WebSocketServerOptions } from "./types-DTHyD7n1.js";
4
+ import { t as RpcPeer } from "./default-s4vvfkK4.js";
5
5
  import { IMultiAdapterHooks, IMultiConnectionAdapter, MultiDriver } from "./adapters/types.js";
6
6
 
7
7
  //#region src/adapters/multi-peer.d.ts
@@ -107,15 +107,13 @@ declare abstract class MultiPeerBase<TLocalSchema extends RpcSchema, TRemoteSche
107
107
  *
108
108
  * @returns MultiDriver proxy for calling methods on all or specific peers
109
109
  */
110
- get driver(): MultiDriver<TRemoteSchema>;
110
+ get driver(): MultiDriver<TRemoteSchema["methods"]>;
111
111
  /**
112
112
  * Emit an event to connected peers
113
113
  *
114
- * @param event - Event name from local schema
115
- * @param data - Event data matching the schema
116
- * @param ids - Optional array of peer IDs to emit to (broadcasts to all if omitted)
114
+ * @param args - Event tuple followed by optional peer IDs
117
115
  */
118
- emit<K extends StringKeys<InferEvents<TLocalSchema["events"]>>>(event: K, data: InferEvents<TLocalSchema["events"]>[K], ids?: string[]): void;
116
+ emit(...args: [...EventTuple<TLocalSchema["events"]>, ids?: string[] | undefined]): void;
119
117
  /**
120
118
  * Close a specific peer by ID
121
119
  *
@@ -1,5 +1,5 @@
1
- import { i as StringCodec } from "./factory-CZioNF7N.js";
2
- import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-RK7s4DQf.js";
1
+ import { i as StringCodec } from "./factory-uZbj772l.js";
2
+ import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-Dwr9zDR6.js";
3
3
 
4
4
  //#region src/storage/sql.d.ts
5
5
 
@@ -1,8 +1,8 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
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-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";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-Dwr9zDR6.js";
6
+ import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-CPEAGd76.js";
7
+ import { n as SqlPendingCallStorageOptions, t as SqlPendingCallStorage } from "../sql-DYEHo09F.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-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";
1
+ import "../schema-DVufxLYY.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-Dwr9zDR6.js";
3
3
  export { AsyncPendingCallStorage, IContinuationHandler, MaybePromise, PendingCall, PendingCallStorage, StorageMode, SyncPendingCallStorage };
@@ -1,7 +1,7 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
5
- import "../interface-RK7s4DQf.js";
6
- import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-BxojNC-D.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../interface-Dwr9zDR6.js";
6
+ import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-CPEAGd76.js";
7
7
  export { MemoryPendingCallStorage, MemoryPendingCallStorageOptions };
@@ -1,7 +1,7 @@
1
- import "../schema-B0zKtaPR.js";
2
- import "../factory-CZioNF7N.js";
3
- import "../json-1pVWk4mJ.js";
4
- import "../index-Be7jjS77.js";
5
- import "../interface-RK7s4DQf.js";
6
- import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-xafn7bdx.js";
1
+ import "../schema-DVufxLYY.js";
2
+ import "../factory-uZbj772l.js";
3
+ import "../json-BBnW1n_D.js";
4
+ import "../index-DAwMsCZ3.js";
5
+ import "../interface-Dwr9zDR6.js";
6
+ import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-DYEHo09F.js";
7
7
  export { SqlPendingCallStorage, SqlPendingCallStorageOptions, SqlStorage, SqlStorageCursor };
@@ -1,5 +1,5 @@
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";
1
+ import { a as EventHandler, g as Provider, h as MethodDef, i as EventEmitter, r as EventDef, v as RpcSchema } from "./schema-DVufxLYY.js";
2
+ import { g as WireInput, u as RpcProtocol } from "./protocol-B6z2_jyb.js";
3
3
 
4
4
  //#region src/types.d.ts
5
5
 
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import "./schema-B0zKtaPR.js";
2
- import "./factory-CZioNF7N.js";
3
- import "./json-1pVWk4mJ.js";
4
- import "./index-Be7jjS77.js";
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";
1
+ import "./schema-DVufxLYY.js";
2
+ import "./factory-uZbj772l.js";
3
+ import "./json-BBnW1n_D.js";
4
+ import "./index-DAwMsCZ3.js";
5
+ import "./protocol-B6z2_jyb.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-DTHyD7n1.js";
7
7
  export { IEventController, IMethodController, IMinWebSocket, IRpcConnection, IRpcOptions, IWebSocket, IWebSocketServer, WebSocketOptions, WebSocketReadyState, WebSocketServerOptions };
@@ -1,2 +1,3 @@
1
- import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
2
- export { type ReconnectOptions, calculateReconnectDelay, defaultReconnectOptions };
1
+ import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-CYt5_8Xy.js";
2
+ import { t as isPromise } from "../index-xZrKqrOZ.js";
3
+ export { ReconnectOptions, calculateReconnectDelay, defaultReconnectOptions, isPromise };
@@ -1,3 +1,4 @@
1
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-CGAA_1Gf.js";
1
+ import { t as isPromise } from "../promise-CjrOX-DI.js";
2
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
2
3
 
3
- export { calculateReconnectDelay, defaultReconnectOptions };
4
+ export { calculateReconnectDelay, defaultReconnectOptions, isPromise };
@@ -1,2 +1,2 @@
1
- import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
1
+ import { n as calculateReconnectDelay, r as defaultReconnectOptions, t as ReconnectOptions } from "../reconnect-CYt5_8Xy.js";
2
2
  export { ReconnectOptions, calculateReconnectDelay, defaultReconnectOptions };
@@ -1,3 +1,3 @@
1
- import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-CGAA_1Gf.js";
1
+ import { n as defaultReconnectOptions, t as calculateReconnectDelay } from "../reconnect-Cdr_3mjN.js";
2
2
 
3
3
  export { calculateReconnectDelay, defaultReconnectOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igoforth/ws-rpc",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Bidirectional RPC over WebSocket with Zod schema validation, TypeScript inference, and Cloudflare Durable Object support",
5
5
  "type": "module",
6
6
  "license": "MIT",