/** * @public * @template {{}} ApiType * Create an RPC client that will relay any method that is called via `send`. It * listens to replies from the server via `receiver`. * * @param {MessagePort | MessagePortLike | MessagePortNode} channel MessagePort-like object that must implement an `.on('message')` event handler and a `.postMessage()` method. * @param {object} [options] Options object * @param {number} [options.timeout=5000] Optionally set timeout (default 5000) * @param {false | Omit} [options.logger = false] options.logger Set to `false` to disable logging, or pass a pino logger instance to enable logging * @param {(request: Omit, next: (request: MsgRequestObj) => Promise) => void} [options.onRequestHook] Optional hook to observe and modify a request and its metadata, and to await the response. * @returns {ClientApi} */ export function createClient(channel: MessagePort | MessagePortLike | MessagePortNode, { timeout, logger, onRequestHook }?: { timeout?: number | undefined; logger?: false | Omit | undefined; onRequestHook?: ((request: Omit, next: (request: MsgRequestObj) => Promise) => void) | undefined; }): ClientApi; export namespace createClient { /** * Close a client. Note this is a static method on `createClient` and it expects * a client created with `createClient` as its argument. * * @param {any} client A client created with `createClient` */ function close(client: any): any; } export type MsgRequest = import("./lib/types.js").MsgRequest; export type MsgResponse = import("./lib/types.js").MsgResponse; export type MsgOn = import("./lib/types.js").MsgOn; export type MsgOff = import("./lib/types.js").MsgOff; export type MsgEmit = import("./lib/types.js").MsgEmit; export type Message = import("./lib/types.js").Message; export type Client = import("./lib/types.js").Client; export type SubClient = import("./lib/types.js").SubClient; export type ClientApi = import("./lib/types.js").ClientApi; export type MessagePortLike = import("./lib/types.js").MessagePortLike; export type MessagePortNode = import("worker_threads").MessagePort; import type { MsgRequestObj } from './lib/types.js';