@igoforth/ws-rpc 1.0.0 → 1.0.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.
Files changed (59) hide show
  1. package/README.md +21 -20
  2. package/dist/adapters/client.d.ts +6 -6
  3. package/dist/adapters/cloudflare-do.d.ts +16 -11
  4. package/dist/adapters/cloudflare-do.js +10 -5
  5. package/dist/adapters/index.d.ts +7 -7
  6. package/dist/adapters/server.d.ts +7 -7
  7. package/dist/adapters/types.d.ts +6 -6
  8. package/dist/codecs/cbor.d.ts +2 -2
  9. package/dist/codecs/factory.d.ts +2 -2
  10. package/dist/codecs/index.d.ts +3 -3
  11. package/dist/codecs/json.d.ts +3 -3
  12. package/dist/codecs/msgpack.d.ts +2 -2
  13. package/dist/{default-xDNNMrg0.d.ts → default-C5z3UDd1.d.ts} +3 -3
  14. package/dist/{factory-C1v0AEHY.d.ts → factory-BGezZgAP.d.ts} +1 -1
  15. package/dist/index.d.ts +8 -8
  16. package/dist/{interface-C4S-WCqW.d.ts → interface-CuTDe_Pq.d.ts} +1 -1
  17. package/dist/{json-54Z2bIIs.d.ts → json-BZzd4eNj.d.ts} +1 -1
  18. package/dist/{memory-D1nGjzzH.d.ts → memory-BbN1TQZi.d.ts} +2 -2
  19. package/dist/peers/default.d.ts +6 -6
  20. package/dist/peers/durable.d.ts +7 -7
  21. package/dist/peers/index.d.ts +7 -7
  22. package/dist/{protocol-DA84zrc2.d.ts → protocol-ipDMUaRc.d.ts} +1 -1
  23. package/dist/protocol.d.ts +4 -4
  24. package/dist/{schema-CN5HHHku.d.ts → schema-BPJJ9slm.d.ts} +3 -3
  25. package/dist/schema.d.ts +1 -1
  26. package/dist/{server-zTjpJpoX.d.ts → server-C5EvcG9T.d.ts} +3 -3
  27. package/dist/{sql-DPmHOeZy.d.ts → sql-BpEL9udW.d.ts} +2 -2
  28. package/dist/storage/index.d.ts +6 -6
  29. package/dist/storage/interface.d.ts +2 -2
  30. package/dist/storage/memory.d.ts +5 -5
  31. package/dist/storage/sql.d.ts +5 -5
  32. package/dist/{types-Be-qmQu0.d.ts → types-BVaXox7F.d.ts} +2 -2
  33. package/dist/types.d.ts +5 -5
  34. package/package.json +1 -2
  35. package/src/adapters/client.ts +0 -396
  36. package/src/adapters/cloudflare-do.ts +0 -346
  37. package/src/adapters/index.ts +0 -16
  38. package/src/adapters/multi-peer.ts +0 -404
  39. package/src/adapters/server.ts +0 -192
  40. package/src/adapters/types.ts +0 -202
  41. package/src/codecs/cbor.ts +0 -42
  42. package/src/codecs/factory.ts +0 -210
  43. package/src/codecs/index.ts +0 -30
  44. package/src/codecs/json.ts +0 -42
  45. package/src/codecs/msgpack.ts +0 -36
  46. package/src/errors.ts +0 -105
  47. package/src/index.ts +0 -102
  48. package/src/peers/default.ts +0 -433
  49. package/src/peers/durable.ts +0 -280
  50. package/src/peers/index.ts +0 -13
  51. package/src/protocol.ts +0 -306
  52. package/src/schema.ts +0 -167
  53. package/src/storage/index.ts +0 -20
  54. package/src/storage/interface.ts +0 -146
  55. package/src/storage/memory.ts +0 -84
  56. package/src/storage/sql.ts +0 -266
  57. package/src/types.ts +0 -158
  58. package/src/utils/index.ts +0 -9
  59. package/src/utils/reconnect.ts +0 -51
package/README.md CHANGED
@@ -187,13 +187,10 @@ import { Actor } from "@cloudflare/actors";
187
187
  import { withRpc } from "@igoforth/ws-rpc/adapters/cloudflare-do";
188
188
  import { ServerSchema, ClientSchema } from "./schemas";
189
189
 
190
- // The mixin adds RPC capabilities to your Actor
191
- // Your class must implement the methods defined in localSchema
192
- export class GameRoom extends withRpc(Actor, {
193
- localSchema: ServerSchema,
194
- remoteSchema: ClientSchema,
195
- }) {
196
- private gameState = { players: [] as string[] };
190
+ // First, create an Actor with the RPC method implementations
191
+ // Methods from localSchema MUST be defined here for type checking
192
+ class GameRoomActor extends Actor<Env> {
193
+ protected gameState = { players: [] as string[] };
197
194
 
198
195
  // Implement methods from ServerSchema
199
196
  async getUser({ id }: { id: string }) {
@@ -203,10 +200,15 @@ export class GameRoom extends withRpc(Actor, {
203
200
  async createOrder({ product, quantity }: { product: string; quantity: number }) {
204
201
  return { orderId: crypto.randomUUID() };
205
202
  }
203
+ }
206
204
 
205
+ // Then apply the RPC mixin to get driver, emit, etc.
206
+ export class GameRoom extends withRpc(GameRoomActor, {
207
+ localSchema: ServerSchema,
208
+ remoteSchema: ClientSchema,
209
+ }) {
207
210
  // Use this.driver to call methods on connected clients
208
211
  async notifyAllPlayers() {
209
- // Call ping on all connected clients
210
212
  const results = await this.driver.ping({});
211
213
  console.log("Ping results:", results);
212
214
  }
@@ -396,25 +398,24 @@ class MyDO extends Actor<Env> {
396
398
 
397
399
  ## Performance
398
400
 
399
- Real WebSocket RPC round-trip benchmarks (localhost, Node.js):
401
+ Real WebSocket RPC round-trip benchmarks (GitHub Actions runner, Node.js 22):
400
402
 
401
403
  **Wire sizes:**
402
404
  | Payload | JSON | MessagePack | CBOR |
403
405
  |---------|------|-------------|------|
404
406
  | Small | 93 B | 71 B | 112 B |
405
- | Medium | 3.5 KB | 2.1 KB | 1.4 KB |
406
- | Large | 24.5 KB | 19.6 KB | 14.1 KB |
407
+ | Medium | 3.4 KB | 2.1 KB | 1.3 KB |
408
+ | Large | 24.4 KB | 19.5 KB | 14.1 KB |
407
409
 
408
410
  **Throughput (ops/sec):**
409
- | Payload | JSON | MessagePack | CBOR |
410
- |---------|------|-------------|------|
411
- | Small | 1,371 | 2,208 | **2,423** |
412
- | Medium | 2,218 | 2,221 | **2,249** |
413
- | Large | 1,334 | 1,245 | **1,562** |
414
-
415
- CBOR provides the best balance of speed and wire size for most payloads. MessagePack excels with smaller payloads. JSON is the most portable but largest.
416
-
417
- Run benchmarks yourself: `pnpm bench`
411
+ | Payload | JSON | MessagePack | CBOR | Fastest |
412
+ |---------|------|-------------|------|---------|
413
+ | Small | 0 | 0 | 0 | JSON |
414
+ | Medium | 0 | 0 | 0 | JSON |
415
+ | Large | 0 | 0 | 0 | JSON |
416
+
417
+ > Benchmarks run automatically via GitHub Actions. Results may vary based on runner load.
418
+ > Run locally with `pnpm bench` for your environment.
418
419
 
419
420
  ## Multi-Peer Driver Results
420
421
 
@@ -1,10 +1,10 @@
1
- import { a as InferEventData, h as StringKeys, m as RpcSchema, n as EventDef, p as Provider, t as Driver } from "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import { a as InferEventData, h as StringKeys, m as RpcSchema, n as EventDef, p as Provider, t as Driver } from "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import { a as IRpcOptions, c as WebSocketOptions, o as IWebSocket } from "../types-Be-qmQu0.js";
7
- import "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import { a as IRpcOptions, c as WebSocketOptions, o as IWebSocket } from "../types-BVaXox7F.js";
7
+ import "../default-C5z3UDd1.js";
8
8
  import { t as ReconnectOptions } from "../reconnect-DbcN0R_1.js";
9
9
  import { IAdapterHooks, IConnectionAdapter } from "./types.js";
10
10
 
@@ -1,10 +1,10 @@
1
- import { m as RpcSchema, p as Provider } from "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import { m as RpcSchema, p as Provider } from "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import { a as IRpcOptions } from "../types-Be-qmQu0.js";
7
- import { t as RpcPeer } from "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import { a as IRpcOptions } from "../types-BVaXox7F.js";
7
+ import { t as RpcPeer } from "../default-C5z3UDd1.js";
8
8
  import { IMultiAdapterHooks, IMultiConnectionAdapter } from "./types.js";
9
9
  import { Constructor } from "type-fest";
10
10
  import { Actor } from "@cloudflare/actors";
@@ -49,15 +49,20 @@ type RpcActorConstructor<TBase extends Constructor<Actor<unknown>>, TLocalSchema
49
49
  * events: {},
50
50
  * } as const;
51
51
  *
52
- * class MyDO extends withRpc(Actor, {
53
- * localSchema: ServerSchema,
54
- * remoteSchema: ClientSchema,
55
- * }) {
56
- * // Required: implement methods from ServerSchema
52
+ * // Define methods on the base Actor class
53
+ * class MyActorBase extends Actor<Env> {
54
+ * protected dataList: string[] = [];
55
+ *
57
56
  * async getData() {
58
57
  * return { data: this.dataList };
59
58
  * }
59
+ * }
60
60
  *
61
+ * // Apply the RPC mixin
62
+ * class MyDO extends withRpc(MyActorBase, {
63
+ * localSchema: ServerSchema,
64
+ * remoteSchema: ClientSchema,
65
+ * }) {
61
66
  * // Call methods on connected clients
62
67
  * async notifyClients() {
63
68
  * const results = await this.driver.clientMethod({ info: "update" });
@@ -102,15 +102,20 @@ var DOMultiPeer = class extends MultiPeerBase {
102
102
  * events: {},
103
103
  * } as const;
104
104
  *
105
- * class MyDO extends withRpc(Actor, {
106
- * localSchema: ServerSchema,
107
- * remoteSchema: ClientSchema,
108
- * }) {
109
- * // Required: implement methods from ServerSchema
105
+ * // Define methods on the base Actor class
106
+ * class MyActorBase extends Actor<Env> {
107
+ * protected dataList: string[] = [];
108
+ *
110
109
  * async getData() {
111
110
  * return { data: this.dataList };
112
111
  * }
112
+ * }
113
113
  *
114
+ * // Apply the RPC mixin
115
+ * class MyDO extends withRpc(MyActorBase, {
116
+ * localSchema: ServerSchema,
117
+ * remoteSchema: ClientSchema,
118
+ * }) {
114
119
  * // Call methods on connected clients
115
120
  * async notifyClients() {
116
121
  * const results = await this.driver.clientMethod({ info: "update" });
@@ -1,13 +1,13 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import "../types-Be-qmQu0.js";
7
- import "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import "../types-BVaXox7F.js";
7
+ import "../default-C5z3UDd1.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 { RpcActorConstructor, withRpc } from "./cloudflare-do.js";
12
- import { n as RpcServerOptions, r as MultiPeerBase, t as RpcServer } from "../server-zTjpJpoX.js";
12
+ import { n as RpcServerOptions, r as MultiPeerBase, t as RpcServer } from "../server-C5EvcG9T.js";
13
13
  export { type ConnectionState, IAdapterHooks, IConnectionAdapter, IMultiAdapterHooks, IMultiConnectionAdapter, MultiCallOptions, MultiCallResult, MultiDriver, MultiPeerBase, ReconnectOptions, type RpcActorConstructor, RpcClient, type RpcClientOptions, RpcServer, type RpcServerOptions, calculateReconnectDelay, defaultReconnectOptions, withRpc };
@@ -1,10 +1,10 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import "../types-Be-qmQu0.js";
7
- import "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import "../types-BVaXox7F.js";
7
+ import "../default-C5z3UDd1.js";
8
8
  import "./types.js";
9
- import { n as RpcServerOptions, t as RpcServer } from "../server-zTjpJpoX.js";
9
+ import { n as RpcServerOptions, t as RpcServer } from "../server-C5EvcG9T.js";
10
10
  export { RpcServer, RpcServerOptions };
@@ -1,10 +1,10 @@
1
- import { f as MethodDef, h as StringKeys, i as EventHandler, l as InferOutput, m as RpcSchema, s as InferInput, t as Driver } from "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import { f as MethodDef, h as StringKeys, i as EventHandler, l as InferOutput, m as RpcSchema, s as InferInput, t as Driver } from "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import { a as IRpcOptions, n as IMethodController, t as IEventController } from "../types-Be-qmQu0.js";
7
- import { t as RpcPeer } from "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import { a as IRpcOptions, n as IMethodController, t as IEventController } from "../types-BVaXox7F.js";
7
+ import { t as RpcPeer } from "../default-C5z3UDd1.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
@@ -1,5 +1,5 @@
1
- import "../schema-CN5HHHku.js";
2
- import { n as CodecFactory } from "../factory-C1v0AEHY.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import { n as CodecFactory } from "../factory-BGezZgAP.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-CN5HHHku.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-C1v0AEHY.js";
1
+ import "../schema-BPJJ9slm.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-BGezZgAP.js";
3
3
  export { BinaryCodec, CodecFactory, CodecOptions, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createStringCodecFactory, isBinaryCodec, isStringCodec };
@@ -1,5 +1,5 @@
1
- import "../schema-CN5HHHku.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-C1v0AEHY.js";
3
- import { n as createJsonCodec, t as JsonCodec } from "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.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-BGezZgAP.js";
3
+ import { n as createJsonCodec, t as JsonCodec } from "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
5
  export { BinaryCodec, CodecFactory, CodecOptions, JsonCodec, StringCodec, WireCodec, WireData, createBinaryCodecFactory, createJsonCodec, createStringCodecFactory, isBinaryCodec, isStringCodec };
@@ -1,4 +1,4 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import { n as createJsonCodec, t as JsonCodec } from "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import { n as createJsonCodec, t as JsonCodec } from "../json-BZzd4eNj.js";
4
4
  export { JsonCodec, createJsonCodec };
@@ -1,5 +1,5 @@
1
- import "../schema-CN5HHHku.js";
2
- import { n as CodecFactory } from "../factory-C1v0AEHY.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import { n as CodecFactory } from "../factory-BGezZgAP.js";
3
3
  import * as z from "zod";
4
4
 
5
5
  //#region src/codecs/msgpack.d.ts
@@ -1,6 +1,6 @@
1
- import { a as InferEventData, h as StringKeys, i as EventHandler, m as RpcSchema, n as EventDef, p as Provider, t as Driver } from "./schema-CN5HHHku.js";
2
- import { g as WireInput, u as RpcProtocol } from "./protocol-DA84zrc2.js";
3
- import { a as IRpcOptions, r as IMinWebSocket } from "./types-Be-qmQu0.js";
1
+ import { a as InferEventData, h as StringKeys, i as EventHandler, m as RpcSchema, n as EventDef, p as Provider, t as Driver } from "./schema-BPJJ9slm.js";
2
+ import { g as WireInput, u as RpcProtocol } from "./protocol-ipDMUaRc.js";
3
+ import { a as IRpcOptions, r as IMinWebSocket } from "./types-BVaXox7F.js";
4
4
 
5
5
  //#region src/peers/default.d.ts
6
6
 
@@ -1,4 +1,4 @@
1
- import { d as LiteralStringUnion } from "./schema-CN5HHHku.js";
1
+ import { d as LiteralStringUnion } from "./schema-BPJJ9slm.js";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/codecs/factory.d.ts
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { _ as method, a as InferEventData, c as InferMethods, f as MethodDef, g as event, i as EventHandler, l as InferOutput, m as RpcSchema, n as EventDef, o as InferEvents, p as Provider, s as InferInput, t as Driver } from "./schema-CN5HHHku.js";
2
- import "./factory-C1v0AEHY.js";
3
- import "./json-54Z2bIIs.js";
1
+ import { _ as method, a as InferEventData, c as InferMethods, f as MethodDef, g as event, i as EventHandler, l as InferOutput, m as RpcSchema, n as EventDef, o as InferEvents, p as Provider, s as InferInput, t as Driver } from "./schema-BPJJ9slm.js";
2
+ import "./factory-BGezZgAP.js";
3
+ import "./json-BZzd4eNj.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-DA84zrc2.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-Be-qmQu0.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-ipDMUaRc.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-BVaXox7F.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-C4S-WCqW.js";
10
- import { t as MemoryPendingCallStorage } from "./memory-D1nGjzzH.js";
11
- import { t as SqlPendingCallStorage } from "./sql-DPmHOeZy.js";
9
+ import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "./interface-CuTDe_Pq.js";
10
+ import { t as MemoryPendingCallStorage } from "./memory-BbN1TQZi.js";
11
+ import { t as SqlPendingCallStorage } from "./sql-BpEL9udW.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,4 +1,4 @@
1
- import { m as RpcSchema } from "./schema-CN5HHHku.js";
1
+ import { m as RpcSchema } from "./schema-BPJJ9slm.js";
2
2
 
3
3
  //#region src/storage/interface.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as CodecFactory } from "./factory-C1v0AEHY.js";
1
+ import { n as CodecFactory } from "./factory-BGezZgAP.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-C1v0AEHY.js";
2
- import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-C4S-WCqW.js";
1
+ import { i as StringCodec } from "./factory-BGezZgAP.js";
2
+ import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-CuTDe_Pq.js";
3
3
 
4
4
  //#region src/storage/memory.d.ts
5
5
 
@@ -1,8 +1,8 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import "../types-Be-qmQu0.js";
7
- import { n as RpcPeerOptions, t as RpcPeer } from "../default-xDNNMrg0.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import "../types-BVaXox7F.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-C5z3UDd1.js";
8
8
  export { RpcPeer, RpcPeerOptions };
@@ -1,11 +1,11 @@
1
- import { m as RpcSchema } from "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import { m as RpcSchema } from "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import { g as WireInput } from "../protocol-DA84zrc2.js";
6
- import "../types-Be-qmQu0.js";
7
- import { n as RpcPeerOptions, t as RpcPeer } from "../default-xDNNMrg0.js";
8
- import { i as PendingCall, s as SyncPendingCallStorage } from "../interface-C4S-WCqW.js";
5
+ import { g as WireInput } from "../protocol-ipDMUaRc.js";
6
+ import "../types-BVaXox7F.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-C5z3UDd1.js";
8
+ import { i as PendingCall, s as SyncPendingCallStorage } from "../interface-CuTDe_Pq.js";
9
9
 
10
10
  //#region src/peers/durable.d.ts
11
11
 
@@ -1,10 +1,10 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../protocol-DA84zrc2.js";
6
- import "../types-Be-qmQu0.js";
7
- import { n as RpcPeerOptions, t as RpcPeer } from "../default-xDNNMrg0.js";
8
- import "../interface-C4S-WCqW.js";
5
+ import "../protocol-ipDMUaRc.js";
6
+ import "../types-BVaXox7F.js";
7
+ import { n as RpcPeerOptions, t as RpcPeer } from "../default-C5z3UDd1.js";
8
+ import "../interface-CuTDe_Pq.js";
9
9
  import { CallContext, DurableRpcPeer, DurableRpcPeerOptions } from "./durable.js";
10
10
  export { type CallContext, DurableRpcPeer, type DurableRpcPeerOptions, RpcPeer, type RpcPeerOptions };
@@ -1,4 +1,4 @@
1
- import { a as WireCodec } from "./factory-C1v0AEHY.js";
1
+ import { a as WireCodec } from "./factory-BGezZgAP.js";
2
2
  import * as z from "zod";
3
3
 
4
4
  //#region src/protocol.d.ts
@@ -1,6 +1,6 @@
1
- import "./schema-CN5HHHku.js";
2
- import "./factory-C1v0AEHY.js";
3
- import "./json-54Z2bIIs.js";
1
+ import "./schema-BPJJ9slm.js";
2
+ import "./factory-BGezZgAP.js";
3
+ import "./json-BZzd4eNj.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-DA84zrc2.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-ipDMUaRc.js";
6
6
  export { JsonProtocol, RpcError, RpcErrorCodes, RpcErrorSchema, RpcEvent, RpcEventSchema, RpcMessage, RpcMessageCodec, RpcMessageSchema, RpcProtocol, RpcRequest, RpcRequestSchema, RpcResponse, RpcResponseSchema, RpcWireCodec, WireInput, createProtocol };
@@ -67,13 +67,13 @@ interface RpcSchema {
67
67
  *
68
68
  * @typeParam T - A MethodDef type to extract the input from
69
69
  */
70
- type InferInput<T> = T extends MethodDef<infer TInput, z.ZodType> ? z.infer<TInput> : never;
70
+ type InferInput<T> = T extends MethodDef<infer TInput, z.ZodType> ? z.input<TInput> : never;
71
71
  /**
72
72
  * Infer the output type from a method definition
73
73
  *
74
74
  * @typeParam T - A MethodDef type to extract the output from
75
75
  */
76
- type InferOutput<T> = T extends MethodDef<z.ZodType, infer TOutput> ? z.infer<TOutput> : never;
76
+ type InferOutput<T> = T extends MethodDef<z.ZodType, infer TOutput> ? z.output<TOutput> : never;
77
77
  /**
78
78
  * Infer the data type from an event definition
79
79
  *
@@ -83,7 +83,7 @@ type InferEventData<T> = T extends EventDef<infer TData> ? z.infer<TData> : neve
83
83
  /**
84
84
  * Infer method signatures from a schema's methods
85
85
  */
86
- type InferMethods<T extends RpcSchema> = T["methods"] extends Record<string, MethodDef> ? { [K in StringKeys<T["methods"]>]: (input: InferInput<T["methods"][K]>) => Promise<InferOutput<T["methods"][K]>> } : object;
86
+ type InferMethods<T extends RpcSchema> = T["methods"] extends Record<string, MethodDef> ? { [K in StringKeys<T["methods"]>]: (input: InferInput<T["methods"][K]>) => InferOutput<T["methods"][K]> | Promise<InferOutput<T["methods"][K]>> } : object;
87
87
  /**
88
88
  * Infer event emitter signatures from a schema's events
89
89
  */
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as method, a as InferEventData, c as InferMethods, d as LiteralStringUnion, f as MethodDef, g as event, h as StringKeys, i as EventHandler, l as InferOutput, m as RpcSchema, n as EventDef, o as InferEvents, p as Provider, r as EventEmitter, s as InferInput, t as Driver, u as LiteralString } from "./schema-CN5HHHku.js";
1
+ import { _ as method, a as InferEventData, c as InferMethods, d as LiteralStringUnion, f as MethodDef, g as event, h as StringKeys, i as EventHandler, l as InferOutput, m as RpcSchema, n as EventDef, o as InferEvents, p as Provider, r as EventEmitter, s as InferInput, t as Driver, u as LiteralString } from "./schema-BPJJ9slm.js";
2
2
  export { Driver, EventDef, EventEmitter, EventHandler, InferEventData, InferEvents, InferInput, InferMethods, InferOutput, LiteralString, LiteralStringUnion, MethodDef, Provider, RpcSchema, StringKeys, event, method };
@@ -1,6 +1,6 @@
1
- import { a as InferEventData, h as StringKeys, m as RpcSchema, n as EventDef, p as Provider } from "./schema-CN5HHHku.js";
2
- import { a as IRpcOptions, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, u as WebSocketServerOptions } from "./types-Be-qmQu0.js";
3
- import { t as RpcPeer } from "./default-xDNNMrg0.js";
1
+ import { a as InferEventData, h as StringKeys, m as RpcSchema, n as EventDef, p as Provider } from "./schema-BPJJ9slm.js";
2
+ import { a as IRpcOptions, o as IWebSocket, r as IMinWebSocket, s as IWebSocketServer, u as WebSocketServerOptions } from "./types-BVaXox7F.js";
3
+ import { t as RpcPeer } from "./default-C5z3UDd1.js";
4
4
  import { IMultiAdapterHooks, IMultiConnectionAdapter, MultiDriver } from "./adapters/types.js";
5
5
 
6
6
  //#region src/adapters/multi-peer.d.ts
@@ -1,5 +1,5 @@
1
- import { i as StringCodec } from "./factory-C1v0AEHY.js";
2
- import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-C4S-WCqW.js";
1
+ import { i as StringCodec } from "./factory-BGezZgAP.js";
2
+ import { i as PendingCall, s as SyncPendingCallStorage } from "./interface-CuTDe_Pq.js";
3
3
 
4
4
  //#region src/storage/sql.d.ts
5
5
 
@@ -1,8 +1,8 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.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-C4S-WCqW.js";
6
- import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-D1nGjzzH.js";
7
- import { n as SqlPendingCallStorageOptions, t as SqlPendingCallStorage } from "../sql-DPmHOeZy.js";
5
+ import { a as PendingCallStorage, i as PendingCall, o as StorageMode, r as MaybePromise, s as SyncPendingCallStorage, t as AsyncPendingCallStorage } from "../interface-CuTDe_Pq.js";
6
+ import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-BbN1TQZi.js";
7
+ import { n as SqlPendingCallStorageOptions, t as SqlPendingCallStorage } from "../sql-BpEL9udW.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-CN5HHHku.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-C4S-WCqW.js";
1
+ import "../schema-BPJJ9slm.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-CuTDe_Pq.js";
3
3
  export { AsyncPendingCallStorage, IContinuationHandler, MaybePromise, PendingCall, PendingCallStorage, StorageMode, SyncPendingCallStorage };
@@ -1,7 +1,7 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../interface-C4S-WCqW.js";
6
- import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-D1nGjzzH.js";
5
+ import "../interface-CuTDe_Pq.js";
6
+ import { n as MemoryPendingCallStorageOptions, t as MemoryPendingCallStorage } from "../memory-BbN1TQZi.js";
7
7
  export { MemoryPendingCallStorage, MemoryPendingCallStorageOptions };
@@ -1,7 +1,7 @@
1
- import "../schema-CN5HHHku.js";
2
- import "../factory-C1v0AEHY.js";
3
- import "../json-54Z2bIIs.js";
1
+ import "../schema-BPJJ9slm.js";
2
+ import "../factory-BGezZgAP.js";
3
+ import "../json-BZzd4eNj.js";
4
4
  import "../index-Be7jjS77.js";
5
- import "../interface-C4S-WCqW.js";
6
- import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-DPmHOeZy.js";
5
+ import "../interface-CuTDe_Pq.js";
6
+ import { i as SqlStorageCursor, n as SqlPendingCallStorageOptions, r as SqlStorage, t as SqlPendingCallStorage } from "../sql-BpEL9udW.js";
7
7
  export { SqlPendingCallStorage, SqlPendingCallStorageOptions, SqlStorage, SqlStorageCursor };
@@ -1,5 +1,5 @@
1
- import { i as EventHandler, m as RpcSchema, p as Provider, r as EventEmitter } from "./schema-CN5HHHku.js";
2
- import { g as WireInput } from "./protocol-DA84zrc2.js";
1
+ import { i as EventHandler, m as RpcSchema, p as Provider, r as EventEmitter } from "./schema-BPJJ9slm.js";
2
+ import { g as WireInput } from "./protocol-ipDMUaRc.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-CN5HHHku.js";
2
- import "./factory-C1v0AEHY.js";
3
- import "./json-54Z2bIIs.js";
1
+ import "./schema-BPJJ9slm.js";
2
+ import "./factory-BGezZgAP.js";
3
+ import "./json-BZzd4eNj.js";
4
4
  import "./index-Be7jjS77.js";
5
- import "./protocol-DA84zrc2.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-Be-qmQu0.js";
5
+ import "./protocol-ipDMUaRc.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-BVaXox7F.js";
7
7
  export { IEventController, IMethodController, IMinWebSocket, IRpcConnection, IRpcOptions, IWebSocket, IWebSocketServer, WebSocketOptions, WebSocketReadyState, WebSocketServerOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igoforth/ws-rpc",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",
@@ -38,7 +38,6 @@
38
38
  "types": "./dist/index.d.ts",
39
39
  "files": [
40
40
  "dist",
41
- "src",
42
41
  "LICENSE",
43
42
  "README.md"
44
43
  ],