/** * Facade over `client.instance` (`aaf_sdk.js`): * `getContext`, `create`, `getAllInfo`, `getInfo`, `sendData`, `receiveData`, `close`. * * ECC source: `com.drishti.ameyo.application.app.impl.InstanceService` * (service name **`instance`**). */ export type GwtInstanceSlotType = "MODAL" | "POPUP" | "BACKGROUND" | (string & {}); export interface InstanceCreationData { /** Modal title (slotType = "MODAL"). */ title?: string; /** Pixel sizes — modal/popup. */ width?: number; height?: number; /** Pixel offsets — popup. */ top?: number; left?: number; /** Auto-close modal/popup after (ms). */ autoClose?: number; /** Free-form per-slot overrides. */ [key: string]: unknown; } export interface AafInstanceApi { getContext: () => Promise; create: ( slotType: GwtInstanceSlotType, creationData: InstanceCreationData, contextData?: unknown ) => Promise; getAllInfo: (appId: string) => Promise; getInfo: (instanceId: string) => Promise; sendData: (instanceId: string, contextData: unknown) => Promise; receiveData: (eventCallback: (data: unknown) => void) => Promise; close: (instanceId: string) => Promise; } export interface HasInstance { instance: AafInstanceApi; } export function instanceGetContext(client: HasInstance): Promise { return client.instance.getContext(); } export function instanceCreate( client: HasInstance, slotType: GwtInstanceSlotType, creationData: InstanceCreationData, contextData?: unknown ): Promise { return client.instance.create(slotType, creationData, contextData); } export function instanceGetAllInfo(client: HasInstance, appId: string): Promise { return client.instance.getAllInfo(appId); } export function instanceGetInfo(client: HasInstance, instanceId: string): Promise { return client.instance.getInfo(instanceId); } export function instanceSendData( client: HasInstance, instanceId: string, contextData: unknown ): Promise { return client.instance.sendData(instanceId, contextData); } /** Subscribe to inbound `instance.sendData` payloads from sibling app instances. */ export function instanceReceiveData( client: HasInstance, callback: (data: unknown) => void ): Promise { return client.instance.receiveData(callback); } export function instanceClose(client: HasInstance, instanceId: string): Promise { return client.instance.close(instanceId); }