UNPKG

@sassoftware/vi-api

Version:
60 lines (59 loc) 2.9 kB
export declare const APP_INIT_TIMEOUT_MS: number; export declare const ERR_EXISTING_APP_DECLARED: (appName: string) => string; export declare const ERR_EXISTING_RESOURCE_BUNDLE_DECLARED: (appName: string) => string; export declare const ERR_INIT_TIMEOUT: (name: string, timeout?: number) => string; /** * An API to manage the asynchronous initialization of solution applications before the * Visual Investigator application is fully initialized. * * Accessed from the window at `window.sas.viInit` * @example window.sas.viInit.registerResourceBundle(bundleName, resources); * @category API */ export interface InitApi { /** * Declare an application. * Visual Investigator will await whenReady for each before continuing its own app initialization. * notifyAppReady should be called to indicate when the app initialization is complete. * if provided, registerResourceBundle should be called to indicate when the I18n resource bundle is ready. * @param appName appName of the app configuration. * @param i18nResourceBundleName I18n resource bundle name of the app configuration. */ declareApp(appName: string, i18nResourceBundleName?: string): void; /** * Notify listeners that the app has been initialized. * @param appName appName of the app configuration. */ notifyAppReady(appName: string): void; /** * Resolves once notifyAppReady has been called for the given app name, * or once the given {@link SviInitEvent} is ready. * Will reject with an error if timeout elapses before notifyAppReady is called. * @param name name of the app configuration or init event. * @param timeout max wait (milliseconds) before the promise is rejected (defaults to {@link APP_INIT_TIMEOUT_MS}). */ whenAppReady(name: SviInitEvent | string, timeout?: number): Promise<void>; /** * Register a resource bundle with the Resource Service. * @param bundleName {string} Name for the bundle to be stored in the resource cache. * @param resources {I18nResources} Object containing the resources to be added for the bundle * specified by the bundleName parameter. */ registerResourceBundle(bundleName: string, resources: I18nResources): void; } /** * Initialization events for the Visual Investigator application. * * These can be awaited using `window.sas.viInit.whenReady` */ export declare enum SviInitEvent { /** all apps which were declared through window.sas.viInit */ AllDeclaredApps = "viInit::all-apps", /** all I18n resource bundles which were declared through window.sas.viInit */ AllDeclaredI18nResourceBundles = "viInit::all-i18n-resources", /** the full window.sas.vi API, depends on {@link AllDeclaredI18nResourceBundles} */ SviClientApi = "viInit::sas-vi-api" } export interface I18nResources { [key: string]: string | I18nResources; }