/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ /** * Simple dependency injection container for managing service instances and dependencies */ export declare class Container { private services; private factories; private singletons; private resolving; /** * Register a service factory * @param token The identifier token for the service * @param factory A factory function that creates the service * @param singleton Whether the service should be a singleton (created once) */ register(token: string, factory: () => T, singleton?: boolean): void; /** * Register a service factory only if the token is not already registered. * This is an atomic check-and-register to avoid TOCTOU races. * @param token The identifier token for the service * @param factory A factory function that creates the service * @param singleton Whether the service should be a singleton (created once) */ registerIfAbsent(token: string, factory: () => T, singleton?: boolean): void; /** * Register an instance as a service * @param token The identifier token for the service * @param instance The instance to register */ registerInstance(token: string, instance: T): void; /** * Get a service by its token * @param token The identifier token for the service * @returns The service instance */ get(token: string): T; /** * Check if a service is registered * @param token The identifier token for the service * @returns True if the service is registered */ has(token: string): boolean; /** * Remove a service registration * @param token The identifier token for the service */ remove(token: string): void; /** * Dispose all instantiated singleton services and clear registrations. * Services implementing dispose(), Symbol.asyncDispose, or Symbol.dispose will be cleaned up. */ dispose(): Promise; [Symbol.asyncDispose](): Promise; /** * Create a child container that inherits registrations from the parent * @returns A new child container */ createChildContainer(): Container; } export declare const globalContainer: Container; //# sourceMappingURL=Container.d.ts.map