import { Data } from '../atom'; import type { AnyFunction } from '../@types'; /********************************************************************************************************************* * * Predicate * *********************************************************************************************************************/ /** * @param tar anything * @return whether the target is a ScopeManager instance. */ export declare const isScopeManager: (tar: any) => tar is ScopeManager; /********************************************************************************************************************* * * ScopeManager Auxiliary * *********************************************************************************************************************/ /** * */ declare type ScopableCreator = AnyFunction; /** * */ interface ScopeManagerOptions { isStray?: boolean; strayFlag?: string; } interface InstanceGetOptions { acceptPromise?: boolean; } /********************************************************************************************************************* * * Main ScopeManager * *********************************************************************************************************************/ /** * */ export declare class ScopeManager { private readonly _options; private readonly _creator; private readonly _scopes; private readonly _promises; constructor(creator: Creator, options?: ScopeManagerOptions); get isScopeManager(): true; get creator(): Creator; get options(): Required; /** * Create a ScopeManager instance with given `creator` and `options`, * put it in global `SCOPE_MANAGERS` map as well. */ static of(creator: Creator, options?: ScopeManagerOptions): ScopeManager; /** * @param scope scope name to be checked. * @return whether the given scope name is registered. */ isRegistered(scope: string): boolean; /** * @param scope scope name to be released. * @return whether the given scope name is successfully released. */ releaseScope(scope: string): boolean; release(): boolean; /** * Register an instance with given scope name & options, * if there is none, create one, * if there is one, just return it. */ registerScope(scope: string, options?: { instance: ReturnType; }): ReturnType; registerScope(scope: string, options?: { params?: Parameters[0]; }): ReturnType; getInstance(scope: string): ReturnType | Data>; getInstance(scope: string, options?: InstanceGetOptions & { acceptPromise: true; }): ReturnType | Data>; getInstance(scope: string, options?: InstanceGetOptions & { acceptPromise: false; }): ReturnType | undefined; /** * Synchronously get an instance with given scope name. */ scope(scope: string, params?: Parameters[0]): ReturnType; } export {}; //# sourceMappingURL=scope.d.ts.map