12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { DependencyIdentifier } from './dependencyIdentifier';
- import { Self, SkipSelf } from './dependencyLookUp';
- import { Many, Optional } from './dependencyQuantity';
- import { WithNew } from './dependencyWithNew';
- export interface Ctor<T> {
- new (...args: any[]): T;
- name: string;
- }
- export declare function isCtor<T>(thing: unknown): thing is Ctor<T>;
- export interface DependencyItemHooks<T> {
- onInstantiation?: (instance: T) => void;
- }
- export interface ClassDependencyItem<T> extends DependencyItemHooks<T> {
- useClass: Ctor<T>;
- lazy?: boolean;
- }
- export declare function isClassDependencyItem<T>(thing: unknown): thing is ClassDependencyItem<T>;
- export type FactoryDepModifier = typeof Self | typeof SkipSelf | typeof Optional | typeof Many | typeof WithNew;
- export type FactoryDep<T> = [...FactoryDepModifier[], DependencyIdentifier<T>] | DependencyIdentifier<T>;
- export interface FactoryDependencyItem<T> extends DependencyItemHooks<T> {
- useFactory: (...deps: any[]) => T;
- dynamic?: true;
- deps?: FactoryDep<any>[];
- }
- export declare function isFactoryDependencyItem<T>(thing: unknown): thing is FactoryDependencyItem<T>;
- export interface ValueDependencyItem<T> extends DependencyItemHooks<T> {
- useValue: T;
- }
- export declare function isValueDependencyItem<T>(thing: unknown): thing is ValueDependencyItem<T>;
- /**
- * Reuse an existing dependency. You can consider it as an alias to another dependency.
- */
- export interface ExistingDependencyItem<T> extends DependencyItemHooks<T> {
- /**
- * The identifier of the existing dependency.
- */
- useExisting: DependencyIdentifier<T>;
- }
- export declare function isExistingDependencyItem<T>(thing: unknown): thing is ExistingDependencyItem<T>;
- export interface AsyncDependencyItem<T> extends DependencyItemHooks<T> {
- useAsync: () => Promise<T | Ctor<T> | [DependencyIdentifier<T>, SyncDependencyItem<T>]>;
- }
- export declare function isAsyncDependencyItem<T>(thing: unknown): thing is AsyncDependencyItem<T>;
- export declare const AsyncHookSymbol: unique symbol;
- export interface AsyncHook<T> {
- __symbol: typeof AsyncHookSymbol;
- whenReady(): Promise<T>;
- }
- export declare function isAsyncHook<T>(thing: unknown): thing is AsyncHook<T>;
- export type SyncDependencyItem<T> = ClassDependencyItem<T> | FactoryDependencyItem<T> | ExistingDependencyItem<T> | ValueDependencyItem<T>;
- export type DependencyItem<T> = SyncDependencyItem<T> | AsyncDependencyItem<T>;
- export declare function prettyPrintIdentifier<T>(id: DependencyIdentifier<T>): string;
|