/** * Postis options configuration. */ export interface PostisOptions { scope: string; window: Window; windowForEventListening?: Window; allowedOrigin?: string; } /** * Parameters for sending a message. */ export interface SendOptions { method: string; params?: any; } /** * Creates a postMessage-based communication channel between windows. */ export default class Postis { private scope; private targetWindow; private windowForEventListening; private allowedOrigin?; private listeners; private sendBuffer; private listenBuffer; private _ready; private readyMethod; private readynessCheck; private readyCheckID; private listener; /** * Creates a new Postis instance. * * @param {PostisOptions} options - Configuration options for the postis instance. */ constructor(options: PostisOptions); /** * Handles incoming postMessage events. * * @param {MessageEvent} event - The message event from postMessage. * @returns {void} */ private handleMessage; /** * Registers a listener for a specific method. * * @param {string} method - The method name to listen for. * @param {Function} callback - The callback function to invoke when the method is received. * @returns {void} */ listen(method: string, callback: (params: any) => void): void; /** * Sends a message to the target window. * * @param {SendOptions} opts - The message options containing method and params. * @returns {void} */ send(opts: SendOptions): void; /** * Executes the callback when the connection is ready. * * @param {Function} callback - The callback to execute when ready. * @returns {void} */ ready(callback: () => void): void; /** * Destroys the postis instance and cleans up resources. * * @param {Function} [callback] - Optional callback to execute after cleanup. * @returns {void} */ destroy(callback?: () => void): void; }