/** * Contains type information for global variables that are either preloaded or injected on to the * global (window) object. Some members are only available when running under FEA but not as * freestanding apps. * * Use Globals and IGlobals whenever possible to ensure compatibility with freestanding apps. * Use feature detection: `if(Globals.finsembleWindow) finsembleWindow`; * * Only when absolutely certain that code will only run in FEA should you use FEAGlobals and IFEAGlobals. */ import { DesktopAgent } from "../typedefs/FDC3"; import { FEA } from "../FEA"; import { FSBLDesktop } from "../clients/Startup/FSBLDesktop"; import { FinsembleWindow } from "./FinsembleWindow"; import { FSBLFreestanding } from "../clients/Startup/FSBLFreestanding"; import { RouterClient } from "../clients"; export interface IGlobals { /** * @deprecated */ name: string; /** * The FSBL object is only available when running as a desktop app (under FEA). */ FSBL: FSBLDesktop; /** * The FSBLJSAdapter is only available when running as a freestanding app. */ FSBLJSAdapter: FSBLFreestanding; /** * The finsembleWindow object is only available when running under FEA. Be careful not to write * code that relies on finsembleWindow as it will not run correctly in freestanding apps. */ finsembleWindow?: FinsembleWindow; /** * In any service window, a pointer to the service * @private */ finsembleServices?: Array; /** * The FDC3 Desktop Agent. */ fdc3: DesktopAgent; /** * The fin object injected by FEA. This object is not available when running as a freestanding app. * @private */ fin?: FEA; /** * This will be set to true if the code is currently being executed in a unit test * @private */ runningInFSBLUnitTest?: boolean; } export interface IFEAGlobals extends IGlobals { fin: FEA; finsembleWindow: FinsembleWindow; } export interface IFreestandingGlobals { FSBLJSAdapter: FSBLFreestanding; fdc3: DesktopAgent; FSBL: { Clients: { RouterClient: typeof RouterClient; }; }; } /** * Use this Globals object in lieu of `window` (browser) or `global` (node). This provides typesafety! * * Fields from `window` are provided via typescript `Partial<>`. This means that code using Globals must * dynamically check for the existence of the window (because it's possible we could be running outside of a browser, such as in node or a unit test). * * If you are certain to be running in FEA then use FEAGlobals. * * @example * import { Globals } from "../common/Globals"; * * // Check to make sure the window function exists * if(Globals.addEventListener) Globals.addEventListener("onload", handler) * * // Globals contains types for Finsemble's globals * if(Globals.fin) console.log("we're in a desktop"); * */ export declare let Globals: IGlobals & Partial; /** * Use this Globals object *only* when you are certain to be running inside FEA. This object has guaranteed * fin and finsembleWindow members. */ export declare let FEAGlobals: IFEAGlobals & Partial; /** * Use this Globals object *only* when you are certain to be running as a Freestanding app. This object has guaranteed * fin and finsembleWindow members. */ export declare let FreestandingGlobals: IFreestandingGlobals & Partial; //# sourceMappingURL=Globals.d.ts.map