import { Container } from "./container.ts"; import type { ResolutionChain } from "./factory.ts"; import type { Token } from "./tokens.ts"; /** * Injects a service within the current injection context, using the token provided. */ export declare function inject(token: Token): T; export declare function inject(token: Token, options: { multi: true; }): T[]; export declare function inject(token: Token, options: { optional: true; }): T | undefined; export declare function inject(token: Token, options: { multi: true; optional: true; }): T[] | undefined; export declare function inject(token: Token, options: { lazy: true; }): () => T; export declare function inject(token: Token, options: { lazy: true; multi: true; }): () => T[]; export declare function inject(token: Token, options: { lazy: true; optional: true; }): () => T | undefined; export declare function inject(token: Token, options: { lazy: true; multi: true; optional: true; }): () => T[] | undefined; /** * Injects a service asynchronously within the current injection context, using the token provided. */ export declare function injectAsync(token: Token): Promise; export declare function injectAsync(token: Token, options: { multi: true; }): Promise; export declare function injectAsync(token: Token, options: { optional: true; }): Promise; export declare function injectAsync(token: Token, options: { multi: true; optional: true; }): Promise; export declare function injectAsync(token: Token, options: { lazy: true; }): () => Promise; export declare function injectAsync(token: Token, options: { lazy: true; multi: true; }): () => Promise; export declare function injectAsync(token: Token, options: { lazy: true; optional: true; }): () => Promise; export declare function injectAsync(token: Token, options: { lazy: true; multi: true; optional: true; }): () => Promise; /** * A context has a specific container associated to it and allows you to run sync or async code. * * It also carries the {@link ResolutionChain} of the resolution it belongs to, so that * `inject()` and `injectAsync()` calls made by user code continue that chain instead of * starting a new one. * * @internal */ export interface Context { readonly chain: ResolutionChain; run(block: (container: Container) => T): T; runAsync(block: (container: Container) => Promise): Promise; } /** * Creates a new injection context. * * @internal */ export declare function injectionContext(container: Container, chain?: ResolutionChain): Context; /** * Returns the resolution chain of the injection context that is currently active, or an * empty chain when there is none (i.e., when a resolution is started from user code). * * Like `inject()` and `injectAsync()`, this must be read synchronously while the context * is still active: the context is restored as soon as the current synchronous block * returns, so it cannot be read after an `await`. * * @internal */ export declare function currentResolutionChain(): ResolutionChain;