55import { RpcTarget as RpcTargetImpl , RpcStub as RpcStubImpl , RpcPromise as RpcPromiseImpl } from "./core.js" ;
66import { serialize , deserialize } from "./serialize.js" ;
77import { RpcTransport , RpcSession as RpcSessionImpl , RpcSessionOptions } from "./rpc.js" ;
8- import { RpcTargetBranded , Serializable , Stub , Stubify , __RPC_TARGET_BRAND } from "./types.js" ;
8+ import { RpcTargetBranded , RpcCompatible , Stub , Stubify , __RPC_TARGET_BRAND } from "./types.js" ;
99import { newWebSocketRpcSession as newWebSocketRpcSessionImpl ,
1010 newWorkersWebSocketRpcResponse } from "./websocket.js" ;
1111import { newHttpBatchRpcSession as newHttpBatchRpcSessionImpl ,
@@ -18,7 +18,7 @@ forceInitMap();
1818// Re-export public API types.
1919export { serialize , deserialize , newWorkersWebSocketRpcResponse , newHttpBatchRpcResponse ,
2020 nodeHttpBatchRpcResponse } ;
21- export type { RpcTransport , RpcSessionOptions } ;
21+ export type { RpcTransport , RpcSessionOptions , RpcCompatible } ;
2222
2323// Hack the type system to make RpcStub's types work nicely!
2424/**
@@ -31,9 +31,9 @@ export type { RpcTransport, RpcSessionOptions };
3131 * such method exists on the remote object, an exception is thrown back. But the client does not
3232 * actually know, until that point, what methods exist.
3333 */
34- export type RpcStub < T extends Serializable < T > > = Stub < T > ;
34+ export type RpcStub < T extends RpcCompatible < T > > = Stub < T > ;
3535export const RpcStub : {
36- new < T extends Serializable < T > > ( value : T ) : RpcStub < T > ;
36+ new < T extends RpcCompatible < T > > ( value : T ) : RpcStub < T > ;
3737} = < any > RpcStubImpl ;
3838
3939/**
@@ -54,7 +54,7 @@ export const RpcStub: {
5454 * if you only intend to use the promise for pipelining and you never await it, then there's no
5555 * need to transmit the resolution!
5656 */
57- export type RpcPromise < T extends Serializable < T > > = Stub < T > & Promise < Stubify < T > > ;
57+ export type RpcPromise < T extends RpcCompatible < T > > = Stub < T > & Promise < Stubify < T > > ;
5858export const RpcPromise : {
5959 // Note: Cannot construct directly!
6060} = < any > RpcPromiseImpl ;
@@ -64,7 +64,7 @@ export const RpcPromise: {
6464 *
6565 * Most people won't use this. You only need it if you've implemented your own `RpcTransport`.
6666 */
67- export interface RpcSession < T extends Serializable < T > = undefined > {
67+ export interface RpcSession < T extends RpcCompatible < T > = undefined > {
6868 getRemoteMain ( ) : RpcStub < T > ;
6969 getStats ( ) : { imports : number , exports : number } ;
7070
@@ -73,7 +73,7 @@ export interface RpcSession<T extends Serializable<T> = undefined> {
7373 drain ( ) : Promise < void > ;
7474}
7575export const RpcSession : {
76- new < T extends Serializable < T > = undefined > (
76+ new < T extends RpcCompatible < T > = undefined > (
7777 transport : RpcTransport , localMain ?: any , options ?: RpcSessionOptions ) : RpcSession < T > ;
7878} = < any > RpcSessionImpl ;
7979
@@ -106,7 +106,7 @@ interface Empty {}
106106 * @param localMain The main RPC interface to expose to the peer. Returns a stub for the main
107107 * interface exposed from the peer.
108108 */
109- export let newWebSocketRpcSession :< T extends Serializable < T > = Empty >
109+ export let newWebSocketRpcSession :< T extends RpcCompatible < T > = Empty >
110110 ( webSocket : WebSocket | string , localMain ?: any , options ?: RpcSessionOptions ) => RpcStub < T > =
111111 < any > newWebSocketRpcSessionImpl ;
112112
@@ -117,7 +117,7 @@ export let newWebSocketRpcSession:<T extends Serializable<T> = Empty>
117117 * value is an RpcStub. You can customize anything about the request except for the method
118118 * (it will always be set to POST) and the body (which the RPC system will fill in).
119119 */
120- export let newHttpBatchRpcSession :< T extends Serializable < T > >
120+ export let newHttpBatchRpcSession :< T extends RpcCompatible < T > >
121121 ( urlOrRequest : string | Request , options ?: RpcSessionOptions ) => RpcStub < T > =
122122 < any > newHttpBatchRpcSessionImpl ;
123123
@@ -126,7 +126,7 @@ export let newHttpBatchRpcSession:<T extends Serializable<T>>
126126 * between an iframe and its parent frame in a browser context. Each side should call this function
127127 * on its own end of the MessageChannel.
128128 */
129- export let newMessagePortRpcSession :< T extends Serializable < T > = Empty >
129+ export let newMessagePortRpcSession :< T extends RpcCompatible < T > = Empty >
130130 ( port : MessagePort , localMain ?: any , options ?: RpcSessionOptions ) => RpcStub < T > =
131131 < any > newMessagePortRpcSessionImpl ;
132132
0 commit comments