import { type WindowLabel } from '../window'; import { type EventName } from '../event'; export interface Event { /** Event name */ event: EventName; /** The label of the window that emitted this event. */ windowLabel: string; /** Event identifier used to unlisten */ id: number; /** Event payload */ payload: T; } export type EventCallback = (event: Event) => void; export type UnlistenFn = () => void; /** * Emits an event to the backend. * * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param [windowLabel] The label of the window to which the event is sent, if null/undefined the event will be sent to all windows * @param [payload] Event payload * @returns */ declare function emit(event: string, windowLabel?: WindowLabel, payload?: unknown): Promise; /** * Listen to an event from the backend. * * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param handler Event handler callback. * @return A promise resolving to a function to unlisten to the event. */ declare function listen(event: EventName, windowLabel: string | null, handler: EventCallback): Promise; /** * Listen to an one-off event from the backend. * * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param handler Event handler callback. * @returns A promise resolving to a function to unlisten to the event. */ declare function once(event: EventName, windowLabel: string | null, handler: EventCallback): Promise; export { emit, listen, once };