@quartal/bridge-client
Version:
Universal client library for embedding applications with URL-configurable transport support (iframe, postMessage) and framework adapters for Angular and Vue
59 lines • 1.85 kB
TypeScript
/**
* Generic Internal Event Bridge for hybrid client applications
*
* Allows applications that act as both parent and child (like invoicing-ui)
* to internally forward specific events from their parent component to their child component.
*
* Use cases:
* - quartal-invoicing-ui: iframe.component (parent) -> app.service (child) -> partner-ui
* - Other hybrid apps in the future
*/
import { INTERNAL_EVENTS } from '../types';
import { QuartalLogger } from './logger';
export interface InternalEventMessage {
type: keyof typeof INTERNAL_EVENTS | string;
data: any;
timestamp: number;
source?: string;
}
export declare class QuartalEventBridge {
private static instances;
private listeners;
private instanceId;
private logger;
private constructor();
/**
* Get or create named instance for specific application
*/
static getInstance(instanceId?: string, logger?: QuartalLogger): QuartalEventBridge;
/**
* Update logger for this instance
*/
private updateLogger;
/**
* Send internal event (parent component -> child component)
*/
sendEvent(type: keyof typeof INTERNAL_EVENTS | string, data: any, source?: string): void;
/**
* Handle incoming message
*/
private handleMessage;
/**
* Listen for specific event type (app.service listens to these)
*/
on(eventType: keyof typeof INTERNAL_EVENTS | string, callback: (message: InternalEventMessage) => void): () => void;
/**
* Cleanup instance
*/
destroy(): void;
/**
* Static method to destroy specific instance
*/
static destroyInstance(instanceId?: string): void;
/**
* Get all active instance IDs
*/
static getActiveInstances(): string[];
}
export default QuartalEventBridge;
//# sourceMappingURL=event-bridge.d.ts.map