@@ -8,7 +8,7 @@ import * as cbor from "cbor-x";
8
8
import * as errors from "./errors" ;
9
9
import { logger } from "./log" ;
10
10
import { type WebSocketMessage as ConnMessage , messageLength } from "./utils" ;
11
- import { ACTOR_HANDLES_SYMBOL , ClientRaw , DynamicImports } from "./client" ;
11
+ import { ACTOR_CONNS_SYMBOL , ClientRaw , DynamicImports } from "./client" ;
12
12
import { ActorDefinition , AnyActorDefinition } from "@/actor/definition" ;
13
13
import pRetry , { AbortError } from "p-retry" ;
14
14
@@ -39,11 +39,11 @@ export type ConnTransport = { websocket: WebSocket } | { sse: EventSource };
39
39
export const CONNECT_SYMBOL = Symbol ( "connect" ) ;
40
40
41
41
/**
42
- * Provides underlying functions for {@link ActorHandle }. See {@link ActorHandle } for using type-safe remote procedure calls.
42
+ * Provides underlying functions for {@link ActorConn }. See {@link ActorConn } for using type-safe remote procedure calls.
43
43
*
44
- * @see {@link ActorHandle }
44
+ * @see {@link ActorConn }
45
45
*/
46
- export class ActorHandleRaw {
46
+ export class ActorConnRaw {
47
47
#disposed = false ;
48
48
49
49
/* Will be aborted on dispose. */
@@ -81,7 +81,7 @@ export class ActorHandleRaw {
81
81
/**
82
82
* Do not call this directly.
83
83
*
84
- * Creates an instance of ActorHandleRaw .
84
+ * Creates an instance of ActorConnRaw .
85
85
*
86
86
* @param {string } endpoint - The endpoint to connect to.
87
87
*
@@ -100,9 +100,9 @@ export class ActorHandleRaw {
100
100
}
101
101
102
102
/**
103
- * Call a raw RPC handle . See {@link ActorHandle } for type-safe RPC calls.
103
+ * Call a raw RPC connection . See {@link ActorConn } for type-safe RPC calls.
104
104
*
105
- * @see {@link ActorHandle }
105
+ * @see {@link ActorConn }
106
106
* @template Args - The type of arguments to pass to the RPC function.
107
107
* @template Response - The type of the response returned by the RPC function.
108
108
* @param {string } name - The name of the RPC function to call.
@@ -712,10 +712,10 @@ enc
712
712
* @returns {Promise<void> } A promise that resolves when the socket is gracefully closed.
713
713
*/
714
714
async dispose ( ) : Promise < void > {
715
- // Internally, this "disposes" the handle
715
+ // Internally, this "disposes" the connection
716
716
717
717
if ( this . #disposed) {
718
- logger ( ) . warn ( "handle already disconnected" ) ;
718
+ logger ( ) . warn ( "connection already disconnected" ) ;
719
719
return ;
720
720
}
721
721
this . #disposed = true ;
729
729
this . #abortController. abort ( ) ;
730
730
731
731
// Remove from registry
732
- this . client [ ACTOR_HANDLES_SYMBOL ] . delete ( this ) ;
732
+ this . client [ ACTOR_CONNS_SYMBOL ] . delete ( this ) ;
733
733
734
734
// Disconnect transport cleanly
735
735
if ( ! this . #transport) {
@@ -776,29 +776,29 @@ type ActorDefinitionRpcs<AD extends AnyActorDefinition> = {
776
776
} ;
777
777
778
778
/**
779
- * Connection to an actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorHandleRaw } for underlying methods.
779
+ * Connection to an actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw } for underlying methods.
780
780
*
781
781
* @example
782
782
* ```
783
- * const room = await client.get <ChatRoom>(...etc...);
783
+ * const room = await client.connect <ChatRoom>(...etc...);
784
784
* // This calls the rpc named `sendMessage` on the `ChatRoom` actor.
785
785
* await room.sendMessage('Hello, world!');
786
786
* ```
787
787
*
788
788
* Private methods (e.g. those starting with `_`) are automatically excluded.
789
789
*
790
- * @template AD The actor class that this handle is connected to .
791
- * @see {@link ActorHandleRaw }
790
+ * @template AD The actor class that this connection is for .
791
+ * @see {@link ActorConnRaw }
792
792
*/
793
793
794
- export type ActorHandle < AD extends AnyActorDefinition > = ActorHandleRaw &
794
+ export type ActorConn < AD extends AnyActorDefinition > = ActorConnRaw &
795
795
ActorDefinitionRpcs < AD > ;
796
796
797
797
//{
798
798
// [K in keyof A as K extends string ? K extends `_${string}` ? never : K : K]: A[K] extends (...args: infer Args) => infer Return ? ActorRPCFunction<Args, Return> : never;
799
799
//};
800
800
/**
801
- * RPC function returned by `ActorHandle `. This will call `ActorHandle .rpc` when triggered.
801
+ * RPC function returned by `ActorConn `. This will call `ActorConn .rpc` when triggered.
802
802
*
803
803
* @typedef {Function } ActorRPCFunction
804
804
* @template Args
0 commit comments