12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { DependencyIdentifier } from './dependencyIdentifier';
- import { Ctor, DependencyItem } from './dependencyItem';
- import { IDisposable } from './dispose';
- import { Quantity } from './types';
- import { RediError } from './error';
- export type DependencyPair<T> = [DependencyIdentifier<T>, DependencyItem<T>];
- export type DependencyClass<T> = [Ctor<T>];
- export type Dependency<T = any> = DependencyPair<T> | DependencyClass<T>;
- export type DependencyWithInstance<T = any> = [
- Ctor<T> | DependencyIdentifier<T>,
- T
- ];
- export type DependencyOrInstance<T = any> = Dependency<T> | DependencyWithInstance<T>;
- export declare function isBareClassDependency<T>(thing: Dependency<T>): thing is DependencyClass<T>;
- export declare function pushResolvingStack(id: DependencyIdentifier<unknown>): void;
- export declare function popupResolvingStack(): void;
- export declare function clearResolvingStack(): void;
- export declare class DependencyNotFoundForModuleError extends RediError {
- constructor(toInstantiate: Ctor<any> | DependencyIdentifier<any>, id: DependencyIdentifier<any>, index: number);
- }
- export declare class DependencyNotFoundError extends RediError {
- constructor(id: DependencyIdentifier<any>);
- }
- /**
- * Store unresolved dependencies in an injector.
- *
- * @internal
- */
- export declare class DependencyCollection implements IDisposable {
- private readonly dependencyMap;
- constructor(dependencies: Dependency[]);
- add<T>(ctor: Ctor<T>): void;
- add<T>(id: DependencyIdentifier<T>, val: DependencyItem<T>): void;
- delete<T>(id: DependencyIdentifier<T>): void;
- get<T>(id: DependencyIdentifier<T>): DependencyItem<T>;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.REQUIRED): DependencyItem<T>;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.MANY): DependencyItem<T>[];
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.OPTIONAL): DependencyItem<T> | null;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity): DependencyItem<T> | DependencyItem<T>[] | null;
- has<T>(id: DependencyIdentifier<T>): boolean;
- append(dependencies: Dependency<any>[]): void;
- dispose(): void;
- /**
- * normalize dependencies to `DependencyItem`
- */
- private normalizeDependencies;
- }
- /**
- * Store resolved dependencies.
- *
- * @internal
- */
- export declare class ResolvedDependencyCollection implements IDisposable {
- private readonly resolvedDependencies;
- add<T>(id: DependencyIdentifier<T>, val: T | null): void;
- has<T>(id: DependencyIdentifier<T>): boolean;
- delete<T>(id: DependencyIdentifier<T>): void;
- get<T>(id: DependencyIdentifier<T>): T;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.OPTIONAL): T | null;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.REQUIRED): T;
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity.MANY): T[];
- get<T>(id: DependencyIdentifier<T>, quantity: Quantity): T[] | T | null;
- dispose(): void;
- }
|