/// import { EventEmitter, type EventEmitterAPI } from './utils/event-emitter'; import { Widget, type WidgetConfig, type WidgetAPI } from './widget'; /** * Mediator configuration */ export interface MediatorConfig { /** Prefix for data-attributes */ prefix: string; /** Initialization function */ initialize?(this: Mediator): void; /** Factory that exports a facade available in an iframe */ externalizeAsProvider?(this: Mediator): Record; } /** * Mediator facade available to the widget and inside an iframe */ export interface MediatorAPI extends EventEmitterAPI, Record { buildWidget(name: string, containerElement: HTMLElement | string, params?: Record): Promise; buildWidget(name: string, params?: Record): Promise; initializeDOMElements(): void; } /** * Mediator - a widget factory */ export declare class Mediator extends EventEmitter { static provideId(): string; /** * Widget identifier counter */ private counterWidgetId; /** * Widgets */ widgets: Record; }>; /** * Widget instances */ widgetInstances: Record; /** * Mediator identifier */ id: string; /** * Prefix used for data-attributes */ prefix: string; private config; private properties; /** * Creating a new instance of the mediator * * @param config Widget configuration * @param properties Additional properties/methods for the mediator * You can specify an object with any properties, except for reserved ones (and properties starting with _): * - config * - prefix * - id * - properties * - initializeDOMElements * - counterWidgetId * - widgets * - widgetInstances * - destroy * - provideWidgetId * - defineWidget * - buildWidget * - updateViewport * - initializeDOMElements * - externalize * - externalizeAsProvider */ constructor(config: MediatorConfig, properties?: Record); /** * Destroy the mediator and stop listening to DOM events */ destroy(): void; /** * Get widget identifier */ private provideWidgetId; /** * Define a widget * * @param config Widget configuration * @param properties Additional widget properties, this object is copied to the widget as is and supplements it with these properties */ defineWidget(config: WidgetConfig, properties?: Record): void; /** * Create a widget and place it on the page * * @param name Widget name * @param containerElement Element/selector where the widget will be inserted * @param params Widget initialization parameters */ buildWidget(name: string, containerElement: HTMLElement | string, params?: Record): Promise; /** * Create a widget and place it on the page * * @param name Widget name * @param params Widget initialization parameters */ buildWidget(name: string, params?: Record): Promise; updateViewport: () => void; /** * Initialization of DOM elements */ private initializeDOMElements; /** * Factory that exports a facade available to the widget */ externalize(): { on: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; once: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; emit: (eventName: string | symbol, ...args: any[]) => boolean; buildWidget: { (name: string, containerElement: string | HTMLElement, params?: Record | undefined): Promise; (name: string, params?: Record | undefined): Promise; }; initializeDOMElements: () => void; }; /** * Factory that exports a facade available inside an iframe */ externalizeAsProvider(): { on: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; once: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; removeListener: (eventName: string | symbol, listener: (...args: any[]) => void) => import("events")<[never]>; emit: (eventName: string | symbol, ...args: any[]) => boolean; buildWidget: { (name: string, containerElement: string | HTMLElement, params?: Record | undefined): Promise; (name: string, params?: Record | undefined): Promise; }; initializeDOMElements: () => void; }; } /** * Creating a mediator * * @param config Configuration * @param properties Additional properties */ export declare function createMediator(config: MediatorConfig, properties?: Record): Mediator;