Detects circular dependencies during container resolution.
-
enter(token: string): void
Marks a token as currently being resolved.
-
isActive(): boolean
Reports whether any tokens are currently being resolved.
-
leave(): void
Removes the most recently entered token from the resolution chain.
Fluent builder for IContainer instances.
-
build(): IContainer
Creates the container with all queued registrations applied.
-
register<T>(): thistoken: string,provider: Provider<T>,options?: ProviderOptions
Queues a provider registration to be applied at
buildtime. -
setAutoRegister(enabled: boolean): this
Enables or disables auto-registration fallback to the external resolver.
-
setDefaultScope(scope: ServiceScope): this
Sets the default lifecycle scope for providers registered without an explicit scope.
-
setExternalResolver(resolver: ExternalResolver): this
Sets the external resolver used when auto-registration is enabled.
Dependency injection container implementing IContainer.
Token-keyed store of provider entries with optional parent inheritance.
-
createChild(): ProviderRegistry
Creates a child registry that inherits lookups from this one.
-
get(token: string): ProviderEntry | undefined
Looks up a provider entry, walking the parent chain.
-
has(token: string): boolean
Reports whether a token is registered anywhere in this chain.
-
register(): voidtoken: string,entry: ProviderEntry
Registers a provider entry under a token.
Manages singleton and scoped instance caches for a container.
-
createChild(): ScopeManager
Creates a child scope that shares singletons but has its own scoped map.
-
getScoped(token: string): unknown
Retrieves a cached scoped instance.
-
getSingleton(token: string): unknown
Retrieves a cached singleton instance.
-
hasScoped(token: string): boolean
Reports whether a scoped instance is cached.
-
hasSingleton(token: string): boolean
Reports whether a singleton is cached.
-
setScoped(): voidtoken: string,instance: unknown
Stores a scoped instance (local to this scope).
-
setSingleton(): voidtoken: string,instance: unknown
Stores a singleton instance (shared across all scopes).
Convenience factory for creating a standalone DI container.
Creates the DiPlugin.
Configuration for constructing a DiContainer.
-
autoRegister: boolean
When
true, resolving an unregistered token falls back to the external resolver and caches the result as a singleton. -
defaultScope: ServiceScope
Default lifecycle scope for providers without an explicit scope.
-
externalResolver: ExternalResolver
Optional external resolver for auto-registration fallback.
-
parentRegistry: ProviderRegistry
Parent registry for hierarchical lookups (internal).
-
parentScopes: ScopeManager
Parent scope manager sharing singletons (internal).
Options for DiPlugin.
-
autoRegister: boolean
When
true, resolving a token not registered in the container automatically falls back to the kernel's ServiceRegistry. The first successful fallback is cached as a singleton so subsequent resolves are fast. Explicit DI registrations always take precedence. Defaults tofalse. -
defaultScope: ServiceScope
Default lifecycle scope for providers registered without an explicit scope. Defaults to
'singleton'.
External resolver used for auto-registration fallback. A subset of
IServiceRegistry — when a token is not in the DI container
and autoRegister is enabled, the container delegates here.
-
has(token: string): boolean
Reports whether the external source can resolve the token.
-
resolve(token: string): unknown
Resolves a token from the external source.
Usage
import * as Optional_dependency_injection_container_plugin___Provides__DiPlugin__which_registers_an___linkcode_IContainer__under__CAPABILITIES_DI_CONTAINER___The_container_supports_singleton__scoped__and_transient_lifecycles__constructor_injection__factory_and_value_providers__circular_dependency_detection__hierarchical_scopes__and_optional_auto_registration_fallback_to_the_kernel_s_ServiceRegistry___Every_export_here_is_public_API_and_documented_in_PUBLIC_API_md__AI_GUIDELINES__10__ from "di-plugin/src/index.ts";