@quartal/bridge-client
Version:
Universal client library for embedding applications with URL-configurable transport support (iframe, postMessage) and framework adapters for Angular and Vue
63 lines • 2.06 kB
TypeScript
/**
* Transport layer abstraction for different embedding technologies
* Allows the bridge client to work with iframe, postMessage, WebWorker, etc.
*/
export interface TransportAdapter {
/**
* Connect to the target (iframe, worker, window, etc.)
* @param target - The target element/window/worker to connect to
*/
connect(target?: any): Promise<void>;
/**
* Disconnect from the target
*/
disconnect(): Promise<void>;
/**
* Send a message to the target
* @param type - Message type/event name
* @param data - Message payload
*/
send(type: string, data: any): void;
/**
* Listen for messages from the target
* @param event - Event name to listen for
* @param handler - Event handler function
*/
on(event: string, handler: (data?: any) => void): void;
/**
* Remove event listener
* @param event - Event name to remove listener from
* @param handler - Optional specific handler to remove
*/
off(event: string, handler?: (data?: any) => void): void;
/**
* Destroy the transport and clean up resources
*/
destroy(): void;
/**
* Check if transport is connected
*/
isConnected(): boolean;
/**
* Get transport type identifier
*/
getType(): string;
}
/**
* Base transport adapter with common functionality
*/
export declare abstract class BaseTransportAdapter implements TransportAdapter {
protected eventListeners: Map<string, Set<(data?: any) => void>>;
protected connected: boolean;
protected destroyed: boolean;
abstract connect(target?: any): Promise<void>;
abstract disconnect(): Promise<void>;
abstract send(type: string, data: any): void;
abstract destroy(): void;
abstract getType(): string;
on(event: string, handler: (data?: any) => void): void;
off(event: string, handler?: (data?: any) => void): void;
protected emit(event: string, data?: any): void;
isConnected(): boolean;
}
//# sourceMappingURL=transport-adapter.d.ts.map