import type { KangarooMessageTypes } from './messages.types'; import type { extension } from './privileges/privilege-resolver'; export type extensions = { [key: string]: extension; }; export declare let adminExtensions: extensions; export declare function setExtensions(extensions: extensions): void; /** * ---------------- * GENERAL TYPES * ---------------- */ /** * This type contains the data of the type without the responseType * @internal */ export type MessageDataType = Omit; /** * This is the structure of the data which will be send with {@link send} * @internal */ export type KangarooMessageSendData = { _type: MESSAGE_TYPE; _data: MessageDataType; _callbackId: string; }; /** * This is the structure of the data which will be send back when the admin gives a response * @internal */ export type KangarooMessageResponseData = { _type: MESSAGE_TYPE; _response: KangarooMessageTypes[MESSAGE_TYPE]['responseType'] | null; _callbackId: string; }; /** * ---------------- * DATA STORES FOR REGISTRIES * ---------------- */ declare const sourceRegistry: Set<{ source: Window; origin: string; }>; /** * ---------------- * MAIN FUNCTIONS FOR EXPORT * ---------------- */ /** * With this method you can send actions or you can request data: * * @param type Choose a type of action from the send-types * @param data The matching data for the type * @returns A promise with the response data in the given responseType */ export declare function send(type: MESSAGE_TYPE, data: MessageDataType, _targetWindow?: Window, _origin?: string): Promise; /** * @param type Choose a type of action from the {@link send-types} * @param method This method should return the response value * @returns The return value is a cancel function to stop listening to the events */ export declare function handle(type: MESSAGE_TYPE, method: (data: MessageDataType, additionalInformation: { _event_: MessageEvent; }) => Promise | KangarooMessageTypes[MESSAGE_TYPE]['responseType']): () => void; export declare function publish(type: MESSAGE_TYPE, data: KangarooMessageTypes[MESSAGE_TYPE]['responseType']): void; export declare function subscribe(type: MESSAGE_TYPE, method: (data: KangarooMessageTypes[MESSAGE_TYPE]['responseType']) => void | Promise): () => void; /** * Factory method which creates a sender so that the type doesn't need to be * defined and can be hidden. Also this allows to use a send method without * a required second argument if the default options are defined. */ export declare function createSender(messageType: MESSAGE_TYPE, baseMessageOptions: MessageDataType): (messageOptions?: MessageDataType) => Promise; export declare function createSender>>(messageType: MESSAGE_TYPE, baseMessageOptions: BASE_OPTIONS): (messageOptions: Omit, keyof BASE_OPTIONS>) => Promise; export declare function createSender(messageType: MESSAGE_TYPE): (messageOptions: MessageDataType) => Promise; /** * Factory method which creates a handler so that the type don't need to be * defined and can be hidden. */ export declare function createHandler(messageType: MESSAGE_TYPE): (method: (data: MessageDataType) => Promise | KangarooMessageTypes[MESSAGE_TYPE]['responseType']) => () => void; /** * Factory method which creates a handler so that the type don't need to be * defined and can be hidden. */ export declare function createSubscriber(messageType: MESSAGE_TYPE): (method: (data: KangarooMessageTypes[MESSAGE_TYPE]['responseType']) => void | Promise, id?: string) => () => void; declare const datasets: Map; /** * Add utils to global window object for * testing */ declare global { interface Window { _swsdk: { sourceRegistry: typeof sourceRegistry; datasets: typeof datasets; }; } } export {};