import { History } from 'history'; import { DefaultTheme } from 'styled-components'; import { ScriptingObjectTypes, Events } from '@elliemae/pui-scripting-object'; import type { EventListeners, ScriptingObjects, SubscribeParam, UnsubscribeParam } from '@elliemae/microfe-common'; import { FrameOptions } from '../frame.js'; export type AppWindowSize = { appId: string; size: { width: number; height: number; }; }; /** * Parameters to open a guest application */ export type OpenAppParams = { /** * Unique identifier for the application * This should be a globally unique identifier to avoid conflicts * across different applications in the micro frontend ecosystem. */ id: string; /** * iframe options for the application */ frameOptions?: Partial; /** * browser history object to use for navigation */ history?: History; /** * ui theme for the application */ theme?: DefaultTheme; /** * home route for the application */ homeRoute?: string; /** * default route to navigate to when the application is opened. * by default it is the home route defined by the application. * This setting is useful only when the application doesn't share parent history */ initialRoute?: string; /** * Arbitrary metadata the host associates with this guest * (e.g. security role, tenant id, permissions). * Propagated in the callChain when the guest's calls are * forwarded through cloned scripting objects. */ metadata?: Record; /** * When true the guest drives its own lifecycle via initialize() and * the bridge skips calling init() / mount() on the guest. */ selfInitialize?: boolean; }; /** * Interface to connect and communicate with parent host * @template AppObjects type of the scripting objects that the application supports * @template AppEvents type of the events that the application supports */ export interface IMicroFEHost, AppEvents extends EventListeners = Events> { /** * application release version */ version: string; /** * Get reference to the scripting object (or proxy) by name * @param name unique name of the scripting object * @returns scripting object reference */ getObject>(objectId: ObjectId): Promise; /** * set the size of the guest application iframe window * @param {AppWindowSize} appSize window size of the application */ setAppWindowSize(appSize: AppWindowSize): void; /** * add listener to the scripting object event * @param params parameters to add event listener * @returns subscription id */ subscribe: >(params: SubscribeParam) => string; /** * removes listener from the scripting object event * @param params parameters to remove event listener */ unsubscribe: >(params: UnsubscribeParam) => void; }