/** * `client.lifeCycle` from `aaf_sdk.js` — app iframe lifecycle (modal close, unload). */ export interface AafLifeCycleApi { register: (eventName: string, eventCallback: (data: unknown) => void) => Promise; unRegister: (eventName: string, eventCallback: (data: unknown) => void) => void; } export interface HasLifeCycle { lifeCycle: AafLifeCycleApi; } /** Events documented for the lifeCycle service. */ export const GwtLifeCycleEventNames = { /** Host clicked modal close; app may respond with `modalCloseConfirmation` within ~5s. Modal-only slot. */ appModalClose: "appModalClose", /** Iframe / app is being torn down. All locations. */ appUnload: "appUnload" } as const; export type GwtLifeCycleEventName = (typeof GwtLifeCycleEventNames)[keyof typeof GwtLifeCycleEventNames]; export function registerLifeCycleEvent( client: HasLifeCycle, eventName: GwtLifeCycleEventName | (string & {}), callback: (data: unknown) => void ): Promise { return client.lifeCycle.register(eventName, callback); } export function unregisterLifeCycleEvent( client: HasLifeCycle, eventName: GwtLifeCycleEventName | (string & {}), callback: (data: unknown) => void ): void { client.lifeCycle.unRegister(eventName, callback); }