@@ -12,33 +12,30 @@ export type RpcDescription = {
1212 [ method : string ] : [ args : any , returnType : any ] | [ args : any ] | [ ] ;
1313} ;
1414
15- export type MethodsDefinition < Description extends RpcDescription , Meta > = {
15+ export type MethodsDefinition < Description extends RpcDescription > = {
1616 [ Method in keyof Description ] : (
17- ...args : Description [ Method ] extends [ infer A , ...any [ ] ]
18- ? [ Meta , A ]
19- : [ Meta ]
20- ) => Description [ Method ] extends [ ...any [ ] , infer R ]
17+ ...args : Description [ Method ] extends [ infer A , ...any [ ] ] ? [ A ] : [ ]
18+ ) => Description [ Method ] extends [ any , infer R ]
2119 ? Promise < [ R , Transferable [ ] ] >
2220 : Promise < void > ;
2321} ;
2422
25- class RpcHelper <
23+ export class RpcHelper <
2624 Local extends RpcDescription ,
2725 Remote extends RpcDescription ,
28- Meta ,
2926> {
3027 counter : number = 0 ;
3128 promiseCallbacks : Map <
3229 number ,
3330 { resolve : ( value : any ) => void ; reject : ( reason ?: any ) => void }
3431 > = new Map ( ) ;
3532 constructor (
36- private methods : MethodsDefinition < Local , Meta > ,
33+ private methods : MethodsDefinition < Local > ,
3734 private id : string ,
3835 private sendRaw : ( data : any , transfer : Transferable [ ] ) => void
3936 ) { }
4037
41- recieve ( data : any , meta : Meta ) {
38+ recieve ( data : any ) {
4239 if ( data === undefined || data === null || typeof data !== "object" ) return ;
4340 const dt = data [ this . id ] ;
4441 if ( dt === undefined || dt === null || typeof dt !== "object" ) return ;
@@ -60,7 +57,7 @@ class RpcHelper<
6057 } else if ( type === "request" ) {
6158 const method = dt . $method as keyof Local ;
6259 const args = dt . $args as Local [ typeof method ] [ 0 ] ;
63- ( this . methods [ method ] as any ) ( meta , args )
60+ ( this . methods [ method ] as any ) ( args )
6461 . then ( ( [ res , transfer ] ) => {
6562 this . sendRaw (
6663 {
@@ -91,7 +88,7 @@ class RpcHelper<
9188 call < Method extends keyof Remote > (
9289 method : Method ,
9390 args : Remote [ Method ] [ 0 ] ,
94- transfer : Transferable [ ]
91+ transfer : Transferable [ ] = [ ]
9592 ) : Promise < Remote [ Method ] [ 1 ] > {
9693 let token = this . counter ++ ;
9794 return new Promise ( ( resolve , reject ) => {
0 commit comments