import * as z from "zod"; export type IframeRpcChannelMethodConfig = Record; type MethodInput = z.input; type MethodOutput = z.output; type IsVoidMethod = MethodOutput extends void ? true : false; type CallResult = IsVoidMethod extends true ? void : Promise>; type MethodArgs = undefined extends MethodInput ? [input?: MethodInput] : [input: MethodInput]; export type IframeRpcChannelRemote = { [Method in keyof Config]: (...args: MethodArgs) => CallResult; }; export type IframeRpcChannelHandlerMeta = { channel: IframeRpcChannelRemote; }; export type IframeRpcChannelHandlers = { [Method in keyof IncomingMethods]: (input: z.output, meta: IframeRpcChannelHandlerMeta) => IsVoidMethod extends true ? void : unknown | Promise; }; export type IframeRpcChannelInputHandlers = { [Method in keyof IncomingMethods]: (input: z.output) => IsVoidMethod extends true ? void : unknown | Promise; }; export declare const iframeRpcCallSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"notify">; method: z.ZodString; data: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"request">; id: z.ZodUUID; method: z.ZodString; data: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"response">; id: z.ZodUUID; result: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"success">; data: z.ZodUnknown; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"error">; errorMessage: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>], "type">; export type IframeRpcCall = z.infer; type SubscriberWindow = { addEventListener: (type: "message", listener: (event: MessageEvent) => void) => void; removeEventListener: (type: "message", listener: (event: MessageEvent) => void) => void; }; type TargetIframeWindow = { postMessage: (message: unknown, targetOrigin: string) => void; }; type IframeRpcChannelOptions = { subscriberWindow: SubscriberWindow; channelIdentifier: string; version: number; getTargetWindow: () => TargetIframeWindow | null; targetOrigin: string; isExpectedMessage: (event: MessageEvent) => boolean; outgoingMethods: OutgoingMethods; incomingMethods: IncomingMethods; handlers: IframeRpcChannelHandlers; }; export type IframeRpcChannel = { subscribe: () => () => void; call: (input: { method: Method; input: MethodInput; }) => CallResult; outgoingMethods: OutgoingMethods; }; /** * Flat method-per-key facade over `channel.call`. Prefer this at call sites * over hand-writing `useMemo(() => ({ foo: (input) => channel.call(...) }))`. * * Pass a channel directly, or a getter (plus its method config) when the * channel is created lazily / may be unavailable (e.g. SSR). */ export declare function createIframeRpcRemote(channel: IframeRpcChannel): IframeRpcChannelRemote; export declare function createIframeRpcRemote(getChannel: () => IframeRpcChannel | null, methods: OutgoingMethods): IframeRpcChannelRemote; export declare function createIframeRpcChannel(options: IframeRpcChannelOptions): IframeRpcChannel; export {};