import { ObjectMap } from './private_utils'; interface EventEmitterTransport { send(message: SendMessage): void; on(event: 'close', handle: () => void): this; on(event: 'message', handle: (message: ReceiveMessage) => void): this; removeListener(event: 'close', handle: () => void): this; removeListener(event: 'message', handle: (message: ReceiveMessage) => void): this; } /** * A communication link between two concurrent operations which may be * executing in separate operating system processes. */ interface Channel { send(message: TX): void; [Symbol.asyncIterator](): AsyncIterator; } interface Closeable { close(): void; } /** * An object that receives requests to invoke methods (by receiving "request" * messages) and sends the result (by transmitting "response" and "error" * messages). */ declare class ResponseChannelImplementation Promise; }> { private _inner; private _handles; private _observer; channelClosedPromise: Promise; constructor(inner: any, handles: Local); private _handleRequestsAsync; [Symbol.asyncIterator](): AsyncIterator<{ method: keyof ChannelMethods; args: any; result: Promise; }>; } export declare function createEventEmitterChannel(transport: EventEmitterTransport): Channel & Closeable; export declare function createRequestChannel>(inner: any): RequestChannel; export declare function createResponseChannel>(inner: any, handles: H): ResponseChannelImplementation; /** * Values that can be sent over a channel. */ export declare type ChannelArg = null | boolean | number | string | ChannelArg[] | { [key: string]: ChannelArg; }; declare type ChannelReturn = Promise | ChannelArg | void; declare type Anonymize = T extends Promise ? Promise> : T extends ObjectMap ? { [key in keyof T]: Anonymize; } : T; /** * A function with argument and return types that can be sent over a channel. */ export declare type ChannelFunction any> = T extends (...args: infer Args) => infer Return ? (...args: Extract, [] | ChannelArg[]>) => Extract, ChannelReturn> : never; /** * Keys of an object whose values are anything except never. */ declare type CallableKeys = { [key in Extract]: T[key] extends (...args: any[]) => any ? T[key] extends ChannelFunction ? key : never : never; }[Extract]; /** * An object with methods that can be called over a channel. */ export declare type ChannelMethods = any> = { [key in K]: T[key]; }; /** * An object that can request the remote invocation of methods (by transmitting * "request" messages) and receive the result (by receiving "response" and * "error" messages). */ export interface RequestChannel> { requestAsync(method: any, ...args: any): Promise; } export declare class RequestChannelAdapter { private _remote; constructor(remote: any); requestAsyncany(method: any, ...args: any): Promise; } export {};