import { EventId, IClient, WorkspaceAPI, WorkspaceEventData } from "..";
/**
 * Event callback signature.
 * @param event The event identifier.
 * @param data The event data.
 */
export declare type EventCallback = (event: string, data: unknown) => void;
/**
 * Generic connection handler.
 */
interface IConnectHandler {
    /**
     * Handles a new connection.
     * @param client The connected client.
     */
    onConnect(client: IClient): void;
}
/**
 * Generic request handler.
 */
interface IRequestHandler {
    /**
     * Handles an API request.
     * @param client The request source client.
     * @param api The requested API entry point.
     * @param args The request arguments.
     * @returns A promise that resolves into a result, or nothing if the handler cannot handle the request.
     */
    onRequest(client: IClient, api: string, args: unknown[]): Promise<unknown> | undefined;
}
/**
 * Connects to an external API.
 * @param target The target dispatcher or iframe.
 * @param onEvent The callback that receives the events dispatched from the external API.
 * @returns A promise that resolves to the external API.
 */
export declare function connect(target: Window | HTMLIFrameElement, onEvent?: EventCallback, timeout?: number): Promise<unknown>;
/**
 * Destrory the connection made by the connect function.
 */
export declare function disconnect(): void;
/**
 * Exposes the API to clients.
 * @param api The api to expose.
 */
export declare function expose(api: Partial<IConnectHandler & IRequestHandler & WorkspaceAPI>): void;
/**
 * Pre-registers a client that is expected to connect.
 * @param client The client to register.
 */
export declare function preregister(client: IClient): IClient | void;
/**
 * Removes the registered client that is expected to unmount
 * @param client The client to be removed
 */
export declare function removeClient(client: IClient): void;
/**
 * Dispatches an event to all connected clients.
 * @param event The event identifier.
 * @param data The event data.
 * @param targetClient The client(optional), If specified then event will be sent to specified client with given `identifier`.
 * Otherwise event will be sent to all connected clients.
 * @param originClientId Optional {@link IClient.identifier}. Used to indicate that this event originated from a
 * Workspace API function call of the given client.
 */
export declare function sendEventToAllClients<TEvent extends EventId>(event: TEvent, data: WorkspaceEventData<TEvent>, targetClient?: IClient, originClientId?: string): void;
export declare function isApplicationEmbedded(): boolean;
export {};
