import 'reflect-metadata'; export type Factory = () => T; export type Constructor = new (...args: unknown[]) => T; /** * Optional hooks for container integration (e.g. deferred service providers). */ export interface ContainerOptions { /** * Invoked before resolving a string abstract (after alias resolution), so callers can register deferred bindings. * * @param resolvedAbstractKey - Fully alias-resolved abstract key. */ beforeResolveString?: (resolvedAbstractKey: string) => void; } /** * IoC container: bindings, aliases, auto-wiring, contextual rules, and circular detection. */ export declare class Container { private readonly bindings; private readonly aliases; private readonly classSingletonCache; private readonly contextualBindings; private readonly stringResolutionStack; private readonly beforeResolveString; constructor(options?: ContainerOptions); /** * Register a transient factory binding. * * @param abstractKey - Abstract service name. * @param factory - Factory invoked on every resolution. */ bind(abstractKey: string, factory: Factory): void; /** * Register a singleton factory binding (instantiated once on first resolve). * * @param abstractKey - Abstract service name. * @param factory - Factory invoked on first resolution only. */ singleton(abstractKey: string, factory: Factory): void; /** * Bind a pre-built instance. * * @param abstractKey - Abstract service name. * @param value - Concrete instance. */ instance(abstractKey: string, value: T): void; /** * Map one abstract name to another (chains are followed on resolve). * * @param abstractKey - Alias to register. * @param targetAbstractKey - Existing abstract key or another alias. */ alias(abstractKey: string, targetAbstractKey: string): void; /** * Whether a binding (or alias chain target) exists for the given abstract key. * * @param abstractKey - Abstract name or alias. */ hasBinding(abstractKey: string): boolean; /** * Fluent contextual binding: when building `consumer`, dependencies typed as `need` resolve to `give`. * * @param consumer - Class currently being constructed. * @returns Builder with `needs` / `give`. */ when(consumer: Constructor): { /** * @param need - Requested dependency type (constructor). * @returns Builder with `give`. */ needs(need: Constructor): { /** * @param give - Implementation constructor to instantiate instead of `need`. */ give(give: Constructor): void; }; }; /** * Resolve a string abstract or an `@Injectable()` class. * * @typeParam TValue - Resolved type. * @param abstractKey - Registered abstract name. * @returns The resolved service. * @throws AtlexError when the abstract is missing or aliases cycle. * @throws CircularDependencyError when string bindings recurse in a cycle. */ make(abstractKey: string): TValue; /** * Resolve an `@Injectable()` class with constructor auto-wiring. * * @typeParam TInstance - Instance type. * @param ctor - Injectable class constructor. * @returns The resolved instance. * @throws AtlexError when metadata is invalid. * @throws CircularDependencyError when constructors recurse in a cycle. */ make(ctor: Constructor): TInstance; /** * @deprecated Prefer {@link Container.make} with a class argument. */ resolveInjectable(ctor: Constructor): T; private resolveAliasChain; private makeFromString; private findContextualGive; private instantiateInjectable; } //# sourceMappingURL=Container.d.ts.map