import {Provider} from '../base/Provider'; import {ConnectHost} from './ConnectHost'; import {ConnectIframeDefinitions, LoadingState} from './ConnectIframe'; export interface ConnectIframeContext { url: string; appKey: string; moduleKey: string; options: object; } /** * Products must implement this interface in order to inject add-on iframe bahaviour into * the Connect framework. */ export interface ConnectIframeProvider extends Provider { onStoreNestedIframeJSON(connectIframeProps: ConnectIframeDefinitions.Props): void; /** * This method will be called by the add-ons when they wish to close the inline dialog * that the add-on is being displayed in. */ onHideInlineDialog(): void; /** * This method is invoked to determine the timeout (in milliseconds) that should be used for a * particular add-on. If this method is not implemented or the returned value falsy or less * than zero, then DEFAULT_APP_LOADING_TIMEOUT will be used. */ getLoadingTimeoutMilliseconds(appKey: string): number; /** * This method is called at the start of the creation of an add-on's iframe. * @param appKey the key of the add-on. */ handleIframeLoadingStarted(appKey: string): void; /** * This method is called once an add-on's iframe has been loaded. * @param appKey the key of the add-on. */ handleIframeLoadingComplete(appKey: string): void; /** * This method is called once an add-on's iframe has been unloaded. * @param appKey the key of the add-on. */ handleIframeUnload(appKey: string): void; /** * This method is called if the iframe is not loaded within a pre-determined timeout period. It is suggested * that this event is handled by presenting an option for the user to cancel the loading of the iframe. If the * user does cancel the loading of the iframe, the suggested behaviour is to present something in place of the * iframe that indicates the add-on failed to load. * @param appKey the key of the add-on. * @param cancelLoadingCallback a parameterless callback function that the product can call to cancel the * loading of the add-on. */ handleIframeLoadTimeout(appKey: string, cancelLoadingCallback: Function): void; /** * This method is called before rendering the iframe, and gives the product a chance to modify * the URL (eg. re-sign an expired JWT) * @param context the current iframe context * @param connectHost a reference to the ACJS connect host */ resolveIframeContext?(context: ConnectIframeContext, connectHost: ConnectHost): Promise; /** * This method is called to retrieve the styles to apply against the add-on iframe whilst it is loading, loaded or timeout. * If null is returned, then the connect framework will apply a set of default styles. * @param activeLoadingState the symbol of the active loading state or undefined. * @param loadingStates a frozen object with all loading state symbols. * @returns an object containing the styles. e.g {opacity: 0.0}. */ buildIframeStyles(activeLoadingState: Symbol | undefined, loadingStates: typeof LoadingState): any; }