export type Ctor < T = any > = new ( ... args ) => T ; export const IdentifierSymbol = Symbol ( '$$WEDI_IDENTIFIER' ) ; export interface Identifier < T = any > { type ? : T ; toString ( ) : string ; [ IdentifierSymbol ] : boolean ; ( target , key , index ) : void ; } export function isIdentifier ( thing ) { return thing [ IdentifierSymbol ] ; } export interface DependencyMeta < T > { id : DependencyKey < T > ; index : number ; optional : boolean ; } export class InitPromise < T = any > { readonly ctor : any ; readonly lazyInstantiation : boolean ; constructor ( ctor , lazyInstantiation = false ) { this . ctor = ctor ; this . lazyInstantiation = lazyInstantiation ; } } export function isInitPromise ( thing ) { return thing instanceof InitPromise ; } export interface ClassItem < T > { useClass : Ctor < T > ; lazyInstantiation ? : boolean ; } export function isClassItem < T = any > ( thing ) { return ! ! ( thing as any ) . useClass ; } export interface ValueItem < T > { useValue : T ; } export function isValueItem < T = any > ( thing ) { return ! ! ( thing as any ) . useValue ; } export interface FactoryItem < T > { useFactory ( ... args ) : T ; deps ? : DependencyKey < any > [ ] ; } export function isFactoryItem < T = any > ( thing ) { return ! ! ( thing as any ) . useFactory ; } export type DependencyValue < T > = Ctor < T > | InitPromise < T > | ValueItem < T > | ClassItem < T > | FactoryItem < T > ; export type DependencyKey < T > = Identifier < T > | Ctor < T > ; export type DependencyItem < T > = [ Identifier < T > , DependencyValue < T > ] | Ctor < T > ; export interface Disposable { dispose ( ) : void ; } export function isDisposable ( thing ) { return ! ! ( thing as any ) . dispose ; }