import { Authentication, Header, Hub, OnGlobalStateChangeCallback } from './interface/hub.type'; import { ServiceBus } from './interface/service-bus.type'; /** * 微前端之间交互通道 */ export class HubService implements Hub { /** * window对象 */ window: Window; /** * 认证 */ authentication: Authentication; /** * 消息 */ serviceBus: ServiceBus; /** * 配置信息 */ config: any; singleSpa: any; name!: string; container!: string | HTMLElement; header: Header; onGlobalStateChange!: (callback: OnGlobalStateChangeCallback, fireImmediately?: boolean) => void; setGlobalState!: (state: Record) => boolean; offGlobalStateChange!: () => boolean; constructor(message: ServiceBus, authentication: Authentication) { this.serviceBus = message; this.authentication = authentication; this.window = window; this.header = {} as Header; } }