import { Observable } from 'rxjs'; import { Service } from './metadata'; import { MessageEnvelope } from '@scion/workbench-application-platform.api'; /** * Message bus to communicate with workbench application platform. */ export declare abstract class MessageBus implements Service { /** * Allows to receive messages sent by application platform. */ abstract get receive$(): Observable; /** * Initiates a request and receives replies continuously. * * Provide options object to control the subscription. */ abstract requestReceive$(envelope: MessageEnvelope, options?: { once: boolean; }): Observable; /** * Posts a message to the application platform. */ abstract postMessage(envelope: MessageEnvelope): void; /** * Initiates a request-reply communication with the application platform. */ abstract requestReply(envelope: MessageEnvelope): Promise; /** * Lifecycle hook that is called when this service is destroyed. */ abstract onDestroy(): void; } /** * Default implementation of {MessageBus}. * * Communication is based on `postMessage` and `onmessage` to safely communicate cross-origin with the window parent. */ export declare class DefaultMessageBus implements MessageBus { private _destroy$; private _ancestorOrigin; private _stream$; constructor(); installHostMessageListener(): void; get receive$(): Observable; postMessage(envelope: MessageEnvelope): void; requestReceive$(envelope: MessageEnvelope, options?: { once: boolean; }): Observable; requestReply(envelope: MessageEnvelope): Promise; onDestroy(): void; } /** * Returns the ancestor origin, or `null` if not supported by the user agent. */ export declare function determineAncestorOrigin(): string;