import { EventDispatcher } from "../eventDispatcher/EventDispatcher"; import { Injector } from "../injector/Injector"; import { Type } from "../type"; import { ContextExtension } from "./data/ContextExtension"; import { ModuleConfig } from "../metadata/data/ModuleConfig"; /** * Application context representation class - a hosting environment for application or its sub context * TODO: Add handling of child and parent contexts in this class */ export declare class Context extends EventDispatcher { private _initialized; private _destroyed; private extensions; private extensionInstances; private modules; private moduleMetadata; /** * @private */ constructor(); /** * Injector instance used within current Context * @type {Injector} */ readonly injector: Injector; /** * Whether Context is initialized. * Extension mappings and modules should be added only whilst Context is not initialized. * @returns {boolean} */ get initialized(): boolean; /** * Whether context is destroyed and thus unusable * @return {boolean} */ get destroyed(): boolean; /** * Install Context extensions * @param extension A single entry or list of Type entries * @returns {Context} Current context operation is performed on */ install(...extension: Type[]): this; /** * Uninstall Context extensions * @param extension A single entry or list of Type entries * @returns {Context} Current context operation is performed on */ uninstall(...extension: Type[]): this; /** * Check if an extension is installed * @param extension A context extension * @returns {boolean} */ hasExtension(extension: Type): boolean; /** * Configure application with application modules. * @param module A single entry or list of modules demarcated by @Module decorator. * @returns {Context} Current context operation is performed on */ configure(...module: (Type | ModuleConfig)[]): this; /** * Initialize context - install extensions, map modules and move through init lifecycle phases * @throws Error on repeated call */ initialize(): this; /** * Check if some module is mapped with Context via direct mapping via configure() call or as required module of any * directly mapped modules. * This method will return any valid data only after Context is initialized * @param module Module to check mapping of */ hasModule(module: Type): boolean; /** * Destroy context, its Injector, modules and extensions * @throws Error if context is not initialized or already destroyed */ destroy(): void; private throwErrorIfDestroyed; private initializeExtensions; private prepareModules; private registerModule; private getModuleDescriptorByType; private prepareInjector; private prepareInjectorMapping; private initializeModules; }