import { P as Protocol, A as API, W as WrapAPIToClient } from '../caller-CuhDuQrt.cjs';

/**
 * A prefix for all messages sent. Used to identify messages
 * from the `computers` library specifically.
 */
declare const MESSAGE_SOURCE_NAMESPACE = "::computers::";
interface MessageEventLike<T> {
    data: T;
}
interface PostMessageMessageJSON {
    source: typeof MESSAGE_SOURCE_NAMESPACE;
    payload: Protocol.Message;
}
type MessageEventListener = (event: MessageEventLike<PostMessageMessageJSON>) => void;
interface HasMessageEvents {
    addEventListener(event: 'message', listener: MessageEventListener): void;
    removeEventListener(event: 'message', listener: MessageEventListener): void;
}
interface HasPostMessage {
    postMessage(message: PostMessageMessageJSON): void;
}
interface WebConnectionOptions {
    target: HasPostMessage;
    self: HasMessageEvents;
}
/**
 * Create a new web instance with the given api and immediately
 * start listening for messages. Since no type parameter was passed,
 * this simply returns an empty object
 *
 * @param options The options for how to connect
 * @param api The api to expose to the other side
 */
declare function web(options: WebConnectionOptions, api: API): WrapAPIToClient<{}>;
/**
 * Create a new one-way communication link for making requests only.
 * This does not expose any functions to the other side.
 *
 * @param options The options for how to connect
 *
 * @returns A proxy that will asyncronously call the methods exposed by the other side
 */
declare function web<T extends API>(options: WebConnectionOptions): WrapAPIToClient<T>;
/**
 * Create a new two-way communcation link for bi-directional communication.
 * This exposes functions to the other side, and allows you to call functions
 * already exposed by the other side.
 *
 * @param options The options for how to connect
 * @param api The api to expose to the other side
 *
 * @returns A proxy that will asyncronously call the methods exposed by the other side
 */
declare function web<T extends API>(options: WebConnectionOptions, api: API): WrapAPIToClient<T>;

export { type HasMessageEvents, type HasPostMessage, MESSAGE_SOURCE_NAMESPACE, type MessageEventLike, type MessageEventListener, type PostMessageMessageJSON, type WebConnectionOptions, web };
