/** @packageDocumentation * @module IpcSocket */ import { LoggingMetaData, PickAsyncMethods } from "@itwin/core-bentley"; import { IpcInvokeReturn } from "./IpcSocket"; /** * Unwrap an [[IpcInvokeReturn]] produced by an Ipc handler: return its `result` on success, or rethrow the * serialized `error` on failure (rebuilt via [[rebuildIpcError]]; non-object values are rethrown as-is). * * Shared by both Ipc directions. By default the error is rebuilt as a plain `Error` following the `ITwinError` * paradigm (identify via [ITwinError.isError]($bentley)); the backend (`IpcHost`) uses this. A caller may pass * `typedErrorClass` to rebuild a legacy typed error instead — the frontend (`IpcApp`) passes [BackendError]($common) * to preserve `instanceof BackendError` for existing consumers. * @param retVal The [[IpcInvokeReturn]] returned by the remote handler. * @param typedErrorClass Optional constructor for a legacy typed error to build when the serialized error carries * `BentleyError` identity (e.g. [BackendError]($common) on the frontend). Omit it for the ITwinError paradigm. * @returns The handler's `result` value, typed as `T` (defaults to `unknown`, so untyped callers must narrow). * @throws The reconstructed error when `retVal` carries an `error`. * @internal */ export declare function unwrapIpcInvokeReturn(retVal: IpcInvokeReturn, typedErrorClass?: new (errorNumber: number, name: string, message: string, getMetaData?: LoggingMetaData) => Error): T; /** * Create a type-safe `Proxy` that routes every method access to `call`, forwarding the accessed method name and * its arguments. Shared by the frontend (`IpcApp.makeIpcProxy`) and backend (`IpcHost.makeIpcProxy`) so both build * their remote-interface proxies identically; each supplies a `call` bound to its own `callIpcChannel`. * @param call Invoked with the accessed method name followed by the call arguments. * @returns A `Proxy` exposing `K`'s async methods. * @internal */ export declare function createIpcProxy(call: (methodName: string, ...args: any[]) => Promise): PickAsyncMethods; /** * Create the handler that an `IpcHandler` registers on its channel: it looks up `funcName` on `impl`, invokes it * with `args`, and packages the outcome as an [[IpcInvokeReturn]] (`{ result }` on success, or a serialized `error` * via [[serializeIpcError]] on failure). Shared by the frontend and backend `IpcHandler.register` implementations * so method dispatch and error packaging behave identically in both directions. * @param impl The handler instance whose methods are exposed over the channel. * @param channelName The channel `impl` is registered on, used for diagnostic messages. * @param includeStack Whether to include `Error.stack` in serialized errors, or a function evaluated per * invocation to decide (the backend omits stacks when [[IpcHost.noStack]] is set, which can change at runtime). * @returns An async dispatcher `(funcName, ...args) => Promise`. * @internal */ export declare function createIpcDispatcher(impl: object, channelName: string, includeStack: boolean | (() => boolean)): (funcName: string, ...args: any[]) => Promise; //# sourceMappingURL=IpcInvoke.d.ts.map