interfaces.ts
52 lines
| 1.5 KiB
| video/mp2t
|
TypeScriptLexer
|
|
r49 | import { ActivationContext } from "./ActivationContext"; | |
|
|
r129 | import { IDestroyable } from "../interfaces"; | |
|
|
r49 | ||
|
|
r120 | export interface Descriptor<S extends object = any, T = any> { | |
|
|
r115 | activate(context: ActivationContext<S>): T; | |
|
|
r49 | } | |
|
|
r120 | export type ServiceMap<S extends object> = { | |
|
|
r118 | [k in keyof S]: Descriptor<S, S[k]>; | |
|
|
r115 | }; | |
|
|
r120 | export type ContainerKeys<S extends object> = keyof S | keyof ContainerProvided<S>; | |
| export type ContainerResolve<S extends object, K> = | |||
| K extends keyof ContainerProvided<S> ? ContainerProvided<S>[K] : | |||
| K extends keyof S ? S[K] : never; | |||
| export type ContainerServiceMap<S extends object> = { | |||
| [K in ContainerKeys<S>]: Descriptor<S, ContainerResolve<S, K>>; | |||
| }; | |||
| export type PartialServiceMap<S extends object> = { | |||
|
|
r118 | [k in keyof S]?: Descriptor<S, S[k]>; | |
| }; | |||
|
|
r115 | ||
|
|
r120 | export interface Resolver<S extends object> { | |
| resolve<K extends ContainerKeys<S>>(name: K, def?: ContainerResolve<S, K>): ContainerResolve<S, K>; | |||
| } | |||
| export interface ContainerProvided<S extends object> { | |||
| container: Resolver<S>; | |||
|
|
r115 | } | |
|
|
r120 | ||
| export type ContainerRegistered<S extends object> = /*{ | |||
| [K in Exclude<keyof S, keyof ContainerProvided<S>>]: S[K]; | |||
| };*/ | |||
| Exclude<S, ContainerProvided<S>>; | |||
|
|
r118 | export type ActivationType = "singleton" | "container" | "hierarchy" | "context" | "call"; | |
|
|
r129 | ||
| export interface ILifetimeManager extends IDestroyable { | |||
| initialize(id: string, context: ActivationContext<any>): ILifetime; | |||
| } | |||
| export interface ILifetime { | |||
| has(): boolean; | |||
|
|
r130 | ||
|
|
r129 | get(): any; | |
|
|
r130 | ||
| enter(): void; | |||
|
|
r129 | store(item: any, cleanup?: (item: any) => void): void; | |
| } |
