export type ChannelFactory = (handler: IChannelHandler) => IChannel; export interface IChannel { sendNotification(data: unknown): void; sendRequest(data: unknown): Promise; } export interface IChannelHandler { handleNotification(notificationData: unknown): void; handleRequest(requestData: unknown): Promise | RpcRequestResult; } export type RpcRequestResult = { type: 'result'; value: unknown; } | { type: 'error'; value: unknown; }; export type API = { host: Side; client: Side; }; export type Side = { notifications: Record void>; requests: Record Promise | unknown>; }; type MakeAsyncIfNot = TFn extends (...args: infer TArgs) => infer TResult ? TResult extends Promise ? TFn : (...args: TArgs) => Promise : never; export type MakeSideAsync = { notifications: T['notifications']; requests: { [K in keyof T['requests']]: MakeAsyncIfNot; }; }; export declare class SimpleTypedRpcConnection { private readonly _channelFactory; private readonly _getHandler; static createHost(channelFactory: ChannelFactory, getHandler: () => T['host']): SimpleTypedRpcConnection>; static createClient(channelFactory: ChannelFactory, getHandler: () => T['client']): SimpleTypedRpcConnection>; readonly api: T; private readonly _channel; private constructor(); } export {}; //# sourceMappingURL=rpc.d.ts.map