UNPKG

iframe-bridge-sdk

Version:

Universal iframe communication SDK - unified package for host and guest applications

66 lines 1.58 kB
import { BaseMessenger, type Message, type HostConfig } from './shared'; /** * Host SDK - 在宿主应用中运行,创建iframe并与Guest SDK通信 */ export declare class HostSDK extends BaseMessenger { /** iframe元素 */ private iframe?; /** 配置选项 */ private config; /** 是否已初始化 */ private initialized; /** 消息监听器引用(用于清理) */ private messageListener?; constructor(config: Partial<HostConfig>); /** * 初始化Host SDK * @param container 容器元素 * @returns Promise<void> */ init(): Promise<void>; /** * 销毁Host SDK */ destroy(): void; /** * 获取iframe元素 */ getIframe(): HTMLIFrameElement | undefined; /** * 获取配置 */ getConfig(): HostConfig; /** * 更新配置 * @param newConfig 新配置 */ updateConfig(newConfig: Partial<HostConfig>): void; /** * 重新加载iframe */ reload(): void; /** * 实现抽象方法:发送消息到iframe * @param message 要发送的消息 */ protected sendMessage(message: Message): void; /** * 创建iframe元素 */ private createIframe; /** * 设置消息监听器 */ private setupMessageListener; /** * 验证消息来源是否有效 * @param event 消息事件 */ private isValidMessageSource; /** * 等待Guest SDK就绪 * @returns Promise<void> */ private waitForReady; } //# sourceMappingURL=host.d.ts.map