@lppedd/di-wise-neo 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +69 -19
- package/dist/cjs/index.js +82 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.d.mts +69 -19
- package/dist/es/index.mjs +80 -24
- package/dist/es/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/errors.ts","../../src/hookRegistry.ts","../../src/utils/keyedStack.ts","../../src/utils/weakRefMap.ts","../../src/injectionContext.ts","../../src/injectAll.ts","../../src/inject.ts","../../src/injectBy.ts","../../src/tokenRef.ts","../../src/metadata.ts","../../src/optionalAll.ts","../../src/optional.ts","../../src/optionalBy.ts","../../src/provider.ts","../../src/decorators/utils.ts","../../src/token.ts","../../src/utils/typeName.ts","../../src/tokenRegistry.ts","../../src/utils/disposable.ts","../../src/containerImpl.ts","../../src/container.ts","../../src/decorators/autoRegister.ts","../../src/decorators/eagerInstantiate.ts","../../src/decorators/inject.ts","../../src/decorators/injectable.ts","../../src/decorators/injectAll.ts","../../src/decorators/named.ts","../../src/decorators/optional.ts","../../src/decorators/optionalAll.ts","../../src/decorators/scoped.ts","../../src/injector.ts","../../src/scope.ts"],"sourcesContent":["import type { Constructor, Token } from \"./token\";\nimport type { MethodDependency } from \"./tokenRegistry\";\n\n// @internal\nexport type TokenInfo = [Token<any>?, (string | undefined)?];\n\n// @internal\nexport function check(condition: false, message: string): never;\nexport function check(condition: unknown, message: string | (() => string)): asserts condition;\nexport function check(condition: unknown, message: string | (() => string)): asserts condition {\n if (!condition) {\n throw new Error(tag(typeof message === \"string\" ? message : message()));\n }\n}\n\n// @internal\nexport function throwUnregisteredError(tokenInfo: TokenInfo): never {\n throw new Error(tag(`unregistered token ${getFullTokenName(tokenInfo)}`));\n}\n\n// @internal\nexport function throwTargetUnregisteredError(tokenInfo: TokenInfo, aliases: TokenInfo[]): never {\n const path = aliases.length > 0 ? ` (alias for ${getTokenPath(aliases)})` : \"\";\n const desc = getFullTokenName(tokenInfo) + path;\n const cause = `\\n [cause] useExisting points to unregistered token ${getFullTokenName(aliases.at(-1)!)}`;\n throw new Error(tag(`failed to resolve token ${desc}`) + cause);\n}\n\n// @internal\nexport function throwCircularAliasError(aliases: TokenInfo[]): never {\n const path = getTokenPath(aliases);\n throw new Error(tag(`circular alias detected while resolving ${path}`));\n}\n\n// @internal\nexport function throwResolutionError(tokenInfo: TokenInfo, aliases: TokenInfo[], cause: any): never {\n const path = aliases.length > 0 ? ` (alias for ${getTokenPath(aliases)})` : \"\";\n const desc = getFullTokenName(tokenInfo) + path;\n throw new Error(tag(`failed to resolve token ${desc}`) + getCause(cause), { cause });\n}\n\n// @internal\nexport function throwParameterResolutionError(\n ctor: Constructor<object>,\n methodKey: string | symbol | undefined,\n dependency: MethodDependency,\n cause: any,\n): never {\n const location = getLocation(ctor, methodKey);\n const tokenName = getFullTokenName([dependency.tokenRef!.getRefToken(), dependency.name]);\n const msg = tag(`failed to resolve dependency for ${location}(parameter #${dependency.index}: ${tokenName})`);\n throw new Error(msg + getCause(cause), { cause });\n}\n\n// @internal\nexport function getLocation(ctor: Constructor<object>, methodKey?: string | symbol): string {\n const ctorName = ctor.name || \"<unnamed>\";\n return methodKey ? `${ctorName}.${String(methodKey)}` : ctorName;\n}\n\n// @internal\nexport function getTokenPath(tokens: TokenInfo[]): string {\n return tokens.map(getFullTokenName).join(\" \\u2192 \");\n}\n\n// @internal\nexport function getTokenName(token: Token<any>): string {\n return token.name || \"<unnamed>\";\n}\n\nfunction getFullTokenName([token, name]: TokenInfo): string {\n const tokenName = token ? token.name || \"<unnamed>\" : \"<undefined token>\";\n return name !== undefined ? `${tokenName}[\"${name}\"]` : tokenName;\n}\n\nfunction getCause(error: any): string {\n if (!error) {\n return \"\";\n }\n\n const msg = isError(error) ? error.message : String(error);\n return `\\n [cause] ${untag(msg)}`;\n}\n\nfunction isError(value: any): value is Error {\n return value?.stack && typeof value?.message === \"string\";\n}\n\nfunction tag(message: string): string {\n return `[di-wise-neo] ${message}`;\n}\n\nfunction untag(message: string): string {\n return message.startsWith(\"[di-wise-neo]\") ? message.substring(13).trimStart() : message;\n}\n","import type { ContainerHook } from \"./container\";\n\n// @internal\nexport class HookRegistry {\n private readonly myHooks: Set<ContainerHook>;\n\n constructor(parent?: HookRegistry) {\n this.myHooks = new Set(parent?.myHooks);\n }\n\n clear(): void {\n this.myHooks.clear();\n }\n\n get(): Set<ContainerHook> {\n return this.myHooks;\n }\n\n add(hook: ContainerHook): void {\n this.myHooks.add(hook);\n }\n\n delete(hook: ContainerHook): void {\n this.myHooks.delete(hook);\n }\n}\n","import { check } from \"../errors\";\n\n// @internal\nexport class KeyedStack<K extends object, V> {\n private readonly myEntries: { key: K; value: V }[] = [];\n private readonly myKeys = new WeakSet<K>();\n\n has(key: K): boolean {\n return this.myKeys.has(key);\n }\n\n peek(): V | undefined {\n return this.myEntries.at(-1)?.value;\n }\n\n push(key: K, value: V): () => void {\n check(!this.has(key), \"internal: invariant violation\");\n this.myKeys.add(key);\n this.myEntries.push({ key, value });\n return () => {\n this.myEntries.pop();\n this.myKeys.delete(key);\n };\n }\n}\n","import { check } from \"../errors\";\n\n// @internal\nexport class WeakRefMap<K extends WeakKey, V extends object> {\n private readonly myMap = new WeakMap<K, WeakRef<V>>();\n\n get(key: K): V | undefined {\n const ref = this.myMap.get(key);\n\n if (ref) {\n const value = ref.deref();\n\n if (value) {\n return value;\n }\n\n this.myMap.delete(key);\n }\n\n return undefined;\n }\n\n set(key: K, value: V): () => void {\n check(!this.get(key), \"internal: invariant violation\");\n this.myMap.set(key, new WeakRef(value));\n return () => {\n this.myMap.delete(key);\n };\n }\n}\n","import type { Container } from \"./container\";\nimport { check } from \"./errors\";\nimport type { Provider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport type { Token } from \"./token\";\nimport { KeyedStack } from \"./utils/keyedStack\";\nimport { WeakRefMap } from \"./utils/weakRefMap\";\nimport type { ValueRef } from \"./valueRef\";\n\n// @internal\nexport interface ResolutionFrame {\n readonly scope: Scope;\n readonly provider: Provider<any>;\n}\n\n// @internal\nexport interface Resolution {\n readonly tokens: Token<any>[];\n readonly stack: KeyedStack<Provider<any>, ResolutionFrame>;\n readonly values: WeakRefMap<Provider<any>, ValueRef<any>>;\n readonly dependents: WeakRefMap<Provider<any>, ValueRef<any>>;\n}\n\n// @internal\nexport interface InjectionContext {\n readonly container: Container;\n readonly resolution: Resolution;\n}\n\n// @internal\nexport function createResolution(): Resolution {\n return {\n tokens: [],\n stack: new KeyedStack(),\n values: new WeakRefMap(),\n dependents: new WeakRefMap(),\n };\n}\n\n// @internal\nexport const [provideInjectionContext, useInjectionContext] = createInjectionContext<InjectionContext>();\n\n// @internal\nexport function ensureInjectionContext(name: string): InjectionContext {\n const context = useInjectionContext();\n check(context, `${name} can only be invoked within an injection context`);\n return context;\n}\n\n/**\n * Asserts that the current stack frame is within an injection context,\n * meaning it has access to injection functions (`inject`, `optional`, etc.).\n *\n * @param fn - The function performing the assertion, or a string name used in the error message.\n * @throws {Error} If the current stack frame is not within an injection context.\n */\nexport function assertInjectionContext(fn: Function | string): void {\n const name = typeof fn === \"function\" ? `${fn.name || \"<unnamed>\"}()` : fn;\n ensureInjectionContext(name);\n}\n\nfunction createInjectionContext<T extends {}>(): readonly [(next: T) => () => T | null, () => T | null] {\n let current: T | null = null;\n\n function provide(next: T): () => T | null {\n const prev = current;\n current = next;\n return () => (current = prev);\n }\n\n function use(): T | null {\n return current;\n }\n\n return [provide, use] as const;\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects all instances provided by the registrations associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function injectAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n/**\n * Injects all values provided by the registrations associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function injectAll<Value>(token: Token<Value>): Value[];\n\nexport function injectAll<T>(token: Token<T>): T[] {\n const context = ensureInjectionContext(\"injectAll()\");\n return context.container.resolveAll(token);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected. Use {@link injectBy} if resolving\n * circular dependencies is necessary.\n */\nexport function inject<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n/**\n * Injects the value associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected. Use {@link injectBy} if resolving\n * circular dependencies is necessary.\n */\nexport function inject<Value>(token: Token<Value>, name?: string): Value;\n\nexport function inject<T>(token: Token<T>, name?: string): T {\n const context = ensureInjectionContext(\"inject()\");\n return context.container.resolve(token, name);\n}\n","import { inject } from \"./inject\";\nimport { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n *\n * Compared to {@link inject}, `injectBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wand {\n * owner = inject(Wizard);\n * }\n *\n * class Wizard {\n * wand = injectBy(this, Wand);\n * }\n * ```\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param Class - The class to resolve.\n * @param name - The name qualifier of the class to resolve.\n */\nexport function injectBy<Instance extends object>(thisArg: any, Class: Constructor<Instance>, name?: string): Instance;\n\n/**\n * Injects the value associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n *\n * Compared to {@link inject}, `injectBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wand {\n * owner = inject(Wizard);\n * }\n *\n * class Wizard {\n * wand = injectBy(this, Wand);\n * }\n * ```\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param token - The token to resolve.\n * @param name - The name qualifier of the token to resolve.\n */\nexport function injectBy<Value>(thisArg: any, token: Token<Value>, name?: string): Value;\n\nexport function injectBy<T>(thisArg: any, token: Token<T>, name?: string): T {\n const context = ensureInjectionContext(\"injectBy()\");\n const resolution = context.resolution;\n const currentFrame = resolution.stack.peek();\n\n if (!currentFrame) {\n return inject(token, name);\n }\n\n const cleanup = resolution.dependents.set(currentFrame.provider, { current: thisArg });\n\n try {\n return inject(token, name);\n } finally {\n cleanup();\n }\n}\n","import { check } from \"./errors\";\nimport type { Constructor, Token, Tokens } from \"./token\";\n\nexport interface ClassRef<Instance extends object> {\n readonly getRefClass: () => Constructor<Instance>;\n}\n\nexport interface TokenRef<Value> {\n readonly getRefToken: () => Token<Value>;\n\n /**\n * @internal\n */\n readonly getRefTokens: () => Set<Token<Value>>;\n}\n\n/**\n * Allows referencing a class declared later in the file by wrapping it\n * into a lazily evaluated function.\n */\n// @__NO_SIDE_EFFECTS__\nexport function classRef<Instance extends object>(Class: () => Constructor<Instance>): ClassRef<Instance> {\n return {\n getRefClass: () => Class(),\n };\n}\n\n/**\n * Allows referencing a token declared later in the file by wrapping it\n * into a lazily evaluated function.\n */\nexport function tokenRef<Value>(token: () => Token<Value>): TokenRef<Value>;\n\n// @internal\nexport function tokenRef<Value>(token: () => Tokens<Value>): TokenRef<Value>;\n\n// @__NO_SIDE_EFFECTS__\nexport function tokenRef<Value>(token: () => Token<Value> | Tokens<Value>): TokenRef<Value> {\n return {\n getRefToken: () => {\n const tokenOrTokens = token();\n check(!Array.isArray(tokenOrTokens), \"internal: unexpected array of tokens\");\n return tokenOrTokens;\n },\n getRefTokens: () => {\n // Normalize the single token here so that we don't have to do it at every getRefTokens call site\n const tokenOrTokens = token();\n const tokensArray = Array.isArray(tokenOrTokens) ? tokenOrTokens : [tokenOrTokens];\n return new Set(tokensArray);\n },\n };\n}\n\n// @internal\nexport function isClassRef<T extends object>(value: any): value is ClassRef<T> {\n return value != null && typeof value === \"object\" && typeof value.getRefClass === \"function\";\n}\n\n// @internal\nexport function isTokenRef<T>(value: any): value is TokenRef<T> {\n return value != null && typeof value === \"object\" && typeof value.getRefToken === \"function\";\n}\n","import { check } from \"./errors\";\nimport type { Scope } from \"./scope\";\nimport type { Constructor } from \"./token\";\nimport { type ClassRef, isClassRef, type TokenRef } from \"./tokenRef\";\nimport type { ConstructorProvider, Dependencies, MethodDependency } from \"./tokenRegistry\";\nimport type { Writable } from \"./utils/writable\";\n\n// @internal\nexport interface ScopeMetadata {\n readonly value: Scope;\n readonly appliedBy: \"Scoped\" | \"EagerInstantiate\";\n}\n\n// @internal\nexport class Metadata<This extends object> {\n readonly provider: Writable<ConstructorProvider<This>>;\n readonly dependencies: Dependencies = {\n ctor: [],\n methods: new Map(),\n };\n\n eagerInstantiate?: boolean | undefined;\n autoRegister?: boolean | undefined;\n scope?: ScopeMetadata;\n tokenRef: TokenRef<This> = {\n getRefToken: () => check(false, \"internal: unexpected getRefToken call\"),\n getRefTokens: () => new Set(),\n };\n\n constructor(Class: Constructor<This>) {\n this.provider = {\n useClass: Class,\n };\n }\n\n get name(): string | undefined {\n return this.provider.name;\n }\n\n set name(name: string) {\n this.provider.name = name;\n }\n\n getCtorDependency(index: number): MethodDependency {\n const i = this.dependencies.ctor.findIndex((d) => d.index === index);\n\n if (i > -1) {\n return this.dependencies.ctor[i]!;\n }\n\n const dependency: MethodDependency = {\n index: index,\n };\n\n this.dependencies.ctor.push(dependency);\n return dependency;\n }\n\n getMethodDependency(method: string | symbol, index: number): MethodDependency {\n let methodDeps = this.dependencies.methods.get(method);\n\n if (!methodDeps) {\n this.dependencies.methods.set(method, (methodDeps = []));\n }\n\n const i = methodDeps.findIndex((d) => d.index === index);\n\n if (i > -1) {\n return methodDeps[i]!;\n }\n\n const dependency: MethodDependency = {\n index: index,\n };\n\n methodDeps.push(dependency);\n return dependency;\n }\n}\n\n// @internal\nexport function getMetadata<T extends object>(classOrRef: Constructor<T> | ClassRef<T>): Metadata<T> {\n const Class = isClassRef(classOrRef) ? classOrRef.getRefClass() : classOrRef;\n const originalClass = classIdentityMap.get(Class) ?? Class;\n let metadata = metadataMap.get(originalClass);\n\n if (!metadata) {\n metadataMap.set(originalClass, (metadata = new Metadata(originalClass)));\n }\n\n if (metadata.provider.useClass !== Class) {\n // This is part of the class identity mapping API (see setClassIdentityMapping).\n //\n // Scenario:\n // 1. Metadata is created for class A (the original class) because of a parameter decorator.\n // 2. Later, because of a class decorator that extends the decorated class, a third-party\n // registers a class identity mapping from class B to class A, where B is the class\n // generated from the class decorator by extending A.\n //\n // We must update useClass to be the extender class B so that instances created by the\n // DI container match the consumer's registered class. Without this update, the DI\n // system would instantiate the original class A, causing behavior inconsistencies.\n metadata.provider.useClass = Class;\n }\n\n return metadata;\n}\n\n/**\n * Registers a mapping between a generated (e.g., decorated or proxied) constructor\n * and its original, underlying constructor.\n *\n * This allows libraries or consumers that manipulate constructors, such as through\n * class decorators, to inform the DI system about the real \"identity\" of a class.\n *\n * **IMPORTANT**:\n * this API affects the core class identity resolution mechanism of the DI system.\n * Incorrect usage may cause metadata to be misassociated, leading to subtle errors.\n * Use only when manipulating constructors (e.g., via decorators or proxies),\n * and ensure the mapping is correct.\n *\n * @param transformedClass - The constructor function returned by a class decorator or factory.\n * @param originalClass - The original constructor function.\n */\nexport function setClassIdentityMapping<T extends object>(transformedClass: Constructor<T>, originalClass: Constructor<T>): void {\n classIdentityMap.set(transformedClass, originalClass);\n}\n\nconst classIdentityMap = new WeakMap<Constructor<object>, Constructor<object>>();\nconst metadataMap = new WeakMap<Constructor<object>, Metadata<any>>();\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects all instances provided by the registrations associated with the given class\n * or an empty array if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n/**\n * Injects all values provided by the registrations associated with the given token\n * or an empty array if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function optionalAll<Value>(token: Token<Value>): Value[];\n\nexport function optionalAll<T>(token: Token<T>): T[] {\n const context = ensureInjectionContext(\"optionalAll()\");\n return context.container.tryResolveAll(token);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n * Use {@link optionalBy} if resolving circular dependencies is necessary.\n */\nexport function optional<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n/**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n * Use {@link optionalBy} if resolving circular dependencies is necessary.\n */\nexport function optional<Value>(token: Token<Value>, name?: string): Value | undefined;\n\nexport function optional<T>(token: Token<T>, name?: string): T | undefined {\n const context = ensureInjectionContext(\"optional()\");\n return context.container.tryResolve(token, name);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport { optional } from \"./optional\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param Class - The class to resolve.\n * @param name - The name qualifier of the class to resolve.\n */\nexport function optionalBy<Instance extends object>(\n thisArg: any,\n Class: Constructor<Instance>,\n name?: string,\n): Instance | undefined;\n\n/**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param token - The token to resolve.\n * @param name - The name qualifier of the token to resolve.\n */\nexport function optionalBy<Value>(thisArg: any, token: Token<Value>, name?: string): Value | undefined;\n\nexport function optionalBy<T>(thisArg: any, token: Token<T>, name?: string): T | undefined {\n const context = ensureInjectionContext(\"optionalBy()\");\n const resolution = context.resolution;\n const currentFrame = resolution.stack.peek();\n\n if (!currentFrame) {\n return optional(token, name);\n }\n\n const cleanup = resolution.dependents.set(currentFrame.provider, { current: thisArg });\n\n try {\n return optional(token, name);\n } finally {\n cleanup();\n }\n}\n","import type { Constructor, Token } from \"./token\";\nimport type { ClassRef } from \"./tokenRef\";\n\n/**\n * Provides a class instance for a token via a class constructor.\n */\nexport interface ClassProvider<Instance extends object> {\n /**\n * The class to instantiate for the token.\n */\n readonly useClass: Constructor<Instance> | ClassRef<Instance>;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Equivalent to decorating the class with `@Named(...)`.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Provides a value for a token via a factory function.\n */\nexport interface FactoryProvider<Value> {\n /**\n * A function that produces the value at resolution time.\n *\n * The function runs inside the injection context and can\n * access dependencies via {@link inject}-like helpers.\n */\n readonly useFactory: (...args: []) => Value;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Provides a static - already constructed - value for a token.\n */\nexport interface ValueProvider<Value> {\n /**\n * The static value to associate with the token.\n */\n readonly useValue: Value;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Aliases another registered token.\n *\n * Resolving this token will return the value of the aliased one.\n */\nexport interface ExistingProvider<Value> {\n /**\n * The existing token to alias, with an optional name qualifier.\n *\n * Example:\n * ```ts\n * container.register(ISecretStorage, {\n * useExisting: PersistentSecretStorage,\n * });\n *\n * // Or in case we need to alias a name-qualified token\n * container.register(ISecretStorage, {\n * useExisting: [PersistentSecretStorage, \"fileSystem\"],\n * });\n * ```\n */\n readonly useExisting: Token<Value> | [Token<Value>, (string | undefined)?];\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * A token provider.\n */\nexport type Provider<Value> =\n | ClassProvider<Value & object>\n | FactoryProvider<Value>\n | ValueProvider<Value>\n | ExistingProvider<Value>;\n\n// @internal\nexport function isClassProvider<T>(provider: Provider<T>): provider is ClassProvider<T & object> {\n return \"useClass\" in provider;\n}\n\n// @internal\nexport function isFactoryProvider<T>(provider: Provider<T>): provider is FactoryProvider<T> {\n return \"useFactory\" in provider;\n}\n\n// @internal\nexport function isValueProvider<T>(provider: Provider<T>): provider is ValueProvider<T> {\n return \"useValue\" in provider;\n}\n\n// @internal\nexport function isExistingProvider<T>(provider: Provider<T>): provider is ExistingProvider<T> {\n return \"useExisting\" in provider;\n}\n","import { check } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { Constructor } from \"../token\";\nimport type { MethodDependency } from \"../tokenRegistry\";\n\n// @internal\nexport function updateParameterMetadata(\n decorator: string,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n updateFn: (dependency: MethodDependency) => void,\n): void {\n // Error out immediately if the decorator has been applied to a static method\n if (methodKey !== undefined && typeof target === \"function\") {\n check(false, `@${decorator} cannot be used on static method ${target.name}.${String(methodKey)}`);\n }\n\n if (methodKey === undefined) {\n // Constructor\n const metadata = getMetadata(target as Constructor<object>);\n const dependency = metadata.getCtorDependency(parameterIndex);\n updateFn(dependency);\n } else {\n // Instance method\n const metadata = getMetadata(target.constructor as Constructor<object>);\n const dependency = metadata.getMethodDependency(methodKey, parameterIndex);\n updateFn(dependency);\n }\n}\n\n// Checks that a constructor or method parameter has only one injection decorator.\n// For example, if both `@Inject` and `@Optional` are used, it becomes difficult to\n// understand which one \"wins\", unless the user is aware of the decorator evaluation order.\n//\n// @internal\nexport function checkSingleDecorator(\n dependency: MethodDependency,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n): void {\n check(dependency.appliedBy === undefined, () => {\n const param = describeParam(target, methodKey, parameterIndex);\n return `multiple injection decorators on ${param}, but only one is allowed`;\n });\n}\n\n// Checks that the `@Named` decorator is not used in combination with\n// `@InjectAll` or `@OptionalAll`, which ignore the name qualification.\n//\n// @internal\nexport function checkNamedDecorator(\n dependency: MethodDependency,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n): void {\n const { appliedBy, name } = dependency;\n check(name === undefined || (appliedBy !== \"InjectAll\" && appliedBy !== \"OptionalAll\"), () => {\n const param = describeParam(target, methodKey, parameterIndex);\n return `@Named has no effect on ${param} when used with @${appliedBy}`;\n });\n}\n\n// Returns a human-readable description of the parameter location.\n// For example: \"Wizard constructor parameter 2\" or \"Wizard.set parameter 0\"\n//\n// @internal\nexport function describeParam(target: object, methodKey: string | symbol | undefined, parameterIndex: number): string {\n const location =\n methodKey === undefined //\n ? (target as Constructor<object>).name\n : `${target.constructor.name}.${String(methodKey)}`;\n return `${location}(parameter #${parameterIndex})`;\n}\n","import type { ParameterDecorator } from \"./decorators/decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./decorators/utils\";\nimport type { Provider } from \"./provider\";\nimport { tokenRef } from \"./tokenRef\";\nimport type { RegistrationOptions } from \"./tokenRegistry\";\nimport type { Writable } from \"./utils/writable\";\n\n/**\n * An injectable type `T`.\n */\nexport interface Type<T> extends ParameterDecorator {\n /**\n * The name of the type.\n */\n readonly name: string;\n\n /**\n * Ensures that different `Type<T>` types are not structurally compatible.\n *\n * This property is always `undefined` and is never used at runtime.\n *\n * @private\n */\n readonly __type: T | undefined;\n\n /**\n * Returns the type's {@link Type.name|name}.\n */\n readonly toString: () => string;\n}\n\n/**\n * An injectable type `T` with a default {@link Provider} and optional default registration options.\n */\nexport interface ProviderType<T> extends Type<T> {\n /**\n * The type's default provider.\n */\n readonly provider: Provider<T>;\n\n /**\n * The type's default registration options.\n */\n readonly options?: RegistrationOptions | undefined;\n}\n\n/**\n * Constructor type.\n */\nexport interface Constructor<Instance extends object> {\n new (...args: any[]): Instance;\n readonly name: string;\n}\n\n/**\n * Token type.\n */\nexport type Token<Value> = [Value] extends [object] // Avoids distributive union behavior\n ? Type<Value> | Constructor<Value & object>\n : Type<Value>;\n\n/**\n * Describes a {@link Token} array with at least one element.\n */\nexport type Tokens<Value> = [Token<Value>, ...Token<Value>[]];\n\n/**\n * Creates a type token.\n *\n * Example:\n * ```ts\n * const ISpell = createType<Spell>(\"Spell\");\n * container.register(ISpell, {\n * useFactory: () => getDefaultSpell(),\n * });\n * ```\n */\nexport function createType<T>(typeName: string): Type<T>;\n\n/**\n * Creates a type token with a default {@link Provider} and optional default registration options.\n *\n * Example:\n * ```ts\n * // Notice how we pass in a Provider directly at type creation site\n * const ISpell = createType<Spell>(\"Spell\", {\n * useFactory: () => getDefaultSpell(),\n * });\n *\n * container.register(ISpell);\n * ```\n */\nexport function createType<T>(typeName: string, provider: Provider<T>, options?: RegistrationOptions): ProviderType<T>;\n\n// @__NO_SIDE_EFFECTS__\nexport function createType<T>(\n typeName: string,\n provider?: Provider<T>,\n options?: RegistrationOptions,\n): Type<T> | ProviderType<T> {\n const name = `Type<${typeName}>`;\n const decorator: ParameterDecorator = (target, propertyKey, parameterIndex) => {\n updateParameterMetadata(name, target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Inject\";\n dependency.tokenRef = tokenRef(() => decorator as Type<T>);\n });\n };\n\n const type = decorator as ParameterDecorator & Writable<ProviderType<T>>;\n Object.defineProperty(type, \"name\", { value: name });\n\n if (provider) {\n type.provider = provider;\n type.options = options;\n }\n\n type.__type = undefined;\n type.toString = () => name;\n return type;\n}\n\n// @internal\nexport function isConstructor<T>(token: Type<T> | Constructor<T & object>): token is Constructor<T & object> {\n return !(\"__type\" in token);\n}\n","// @internal\nexport function getTypeName(value: unknown): string {\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (typeof value) {\n case \"string\":\n return `\"${value}\"`;\n case \"function\":\n return (value.name && `typeof ${value.name}`) || \"Function\";\n case \"object\": {\n if (value === null) {\n return \"null\";\n }\n\n const proto: object | null = Object.getPrototypeOf(value);\n\n if (proto && proto !== Object.prototype) {\n const ctor: unknown = proto.constructor;\n\n if (typeof ctor === \"function\" && ctor.name) {\n return ctor.name;\n }\n }\n }\n }\n\n return typeof value;\n}\n","import { check, getTokenName } from \"./errors\";\nimport type { ExistingProvider, FactoryProvider, Provider, ValueProvider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport { type Constructor, createType, type Token, type Type } from \"./token\";\nimport type { TokenRef } from \"./tokenRef\";\nimport { getTypeName } from \"./utils/typeName\";\nimport type { ValueRef } from \"./valueRef\";\n\n// @internal\nexport interface ConstructorProvider<Instance extends object> {\n readonly useClass: Constructor<Instance>;\n readonly name?: string;\n}\n\n// @internal\nexport type RegistrationProvider<Value> =\n | ConstructorProvider<Value & object>\n | FactoryProvider<Value>\n | ValueProvider<Value>\n | ExistingProvider<Value>;\n\n/**\n * Token registration options.\n */\nexport interface RegistrationOptions {\n /**\n * The scope of the registration.\n */\n readonly scope?: Scope | undefined;\n}\n\n// @internal\nexport type InjectDecorator = \"Inject\" | \"InjectAll\" | \"Optional\" | \"OptionalAll\";\n\n// @internal\nexport interface MethodDependency {\n // The index of the annotated parameter (zero-based)\n readonly index: number;\n\n appliedBy?: InjectDecorator;\n tokenRef?: TokenRef<any>;\n name?: string;\n}\n\n// @internal\nexport interface Dependencies {\n readonly ctor: MethodDependency[];\n readonly methods: Map<string | symbol, MethodDependency[]>;\n}\n\n// @internal\nexport interface Registration<T> {\n readonly provider: RegistrationProvider<T>;\n readonly name?: string | undefined;\n readonly options?: RegistrationOptions | undefined;\n readonly dependencies?: Dependencies;\n\n valueRef?: ValueRef<T> | undefined;\n}\n\n// @internal\nexport class TokenRegistry {\n private readonly myParent: TokenRegistry | undefined;\n private readonly myRegistrations = new Map<Token<any>, Registration<any>[]>();\n\n constructor(parent?: TokenRegistry) {\n this.myParent = parent;\n }\n\n get<T extends object>(token: Constructor<T>, name?: string): Registration<T> | undefined;\n get<T>(token: Token<T>, name?: string): Registration<T> | undefined;\n get<T>(token: Token<T>, name?: string): Registration<T> | undefined {\n // To clarify, at(-1) means we take the last added registration for this token\n return this.getAll(token, name).at(-1);\n }\n\n getAll<T>(token: Token<T>, name?: string): Registration<T>[] {\n // Internal registrations cannot have a name\n const internal = name !== undefined ? undefined : internals.get(token);\n return (internal && [internal]) || this.getAllFromParent(token, name);\n }\n\n put<T>(token: Token<T>, registration: Registration<T>): void;\n put<T extends object>(token: Type<T> | Constructor<T>, registration: Registration<T>): void;\n put<T>(token: Token<T>, registration: Registration<T>): void {\n check(!internals.has(token), `internal: cannot register reserved token ${token.name}`);\n let registrations = this.myRegistrations.get(token);\n\n if (registrations) {\n const name = registration.name;\n\n if (name !== undefined) {\n const existing = registrations.filter((r) => r.name === name);\n check(existing.length === 0, `token ${getTokenName(token)} with name '${name}' is already registered`);\n }\n } else {\n this.myRegistrations.set(token, (registrations = []));\n }\n\n registrations.push(registration);\n }\n\n delete<T>(token: Token<T>, name?: string): Registration<T>[] {\n const registrations = this.myRegistrations.get(token);\n\n if (!registrations) {\n return [];\n }\n\n if (name !== undefined) {\n const removed: Registration<T>[] = [];\n const updated: Registration<T>[] = [];\n\n for (const registration of registrations) {\n (registration.name === name ? removed : updated).push(registration);\n }\n\n if (removed.length > 0) {\n this.myRegistrations.set(token, updated);\n return removed;\n }\n }\n\n this.myRegistrations.delete(token);\n return registrations;\n }\n\n deleteAll(): [Token<any>[], Registration<any>[]] {\n const tokens = [...this.myRegistrations.keys()];\n const registrations = [...this.myRegistrations.values()].flat();\n this.myRegistrations.clear();\n return [tokens, registrations];\n }\n\n clearCache(): unknown[] {\n const values = new Set<unknown>();\n\n for (const registrations of this.myRegistrations.values()) {\n for (const registration of registrations) {\n const valueRef = registration.valueRef;\n\n if (valueRef) {\n values.add(valueRef.current);\n }\n\n registration.valueRef = undefined;\n }\n }\n\n return [...values];\n }\n\n private getAllFromParent<T>(token: Token<T>, name?: string): Registration<T>[] {\n let registrations = this.myRegistrations.get(token) || this.myParent?.getAllFromParent(token, name);\n\n if (registrations && name !== undefined) {\n registrations = registrations.filter((r) => r.name === name);\n check(registrations.length < 2, `internal: multiple registrations with name '${name}'`);\n }\n\n return registrations ?? [];\n }\n}\n\n// @internal\nexport function isBuilder(provider: Provider<any>): boolean {\n return builders.has(provider);\n}\n\n/**\n * Create a one-off type token from a factory function.\n *\n * Example:\n * ```ts\n * class Wizard {\n * wand = inject(\n * build(() => {\n * const wand = inject(Wand);\n * wand.owner = this;\n * // ...\n * return wand;\n * }),\n * );\n * }\n * ```\n */\nexport function build<Value>(factory: (...args: []) => Value): Type<Value>;\n\n// @internal\nexport function build<Value>(factory: (...args: []) => Value, name: string): Type<Value>;\n\n// @__NO_SIDE_EFFECTS__\nexport function build<Value>(factory: (...args: []) => Value, name?: string): Type<Value> {\n const token = createType<Value>(name ?? `Build<${getTypeName(factory)}>`);\n const provider: FactoryProvider<Value> = {\n useFactory: factory,\n };\n\n internals.set(token, {\n provider: provider,\n options: {\n scope: \"Transient\",\n },\n });\n\n builders.add(provider);\n return token;\n}\n\nconst internals = new WeakMap<Token<any>, Registration<any>>();\nconst builders = new WeakSet<Provider<any>>();\n","// @internal\nexport interface Disposable {\n dispose(): void | PromiseLike<void>;\n}\n\n// @internal\nexport function isDisposable(value: any): value is Disposable {\n return value != null && typeof value === \"object\" && typeof value.dispose === \"function\";\n}\n","import type { ChildContainerOptions, Container, ContainerHook, ContainerOptions } from \"./container\";\nimport {\n check,\n getLocation,\n getTokenName,\n getTokenPath,\n throwCircularAliasError,\n throwParameterResolutionError,\n throwResolutionError,\n throwTargetUnregisteredError,\n throwUnregisteredError,\n type TokenInfo,\n} from \"./errors\";\nimport { HookRegistry } from \"./hookRegistry\";\nimport { injectAll } from \"./injectAll\";\nimport { injectBy } from \"./injectBy\";\nimport { createResolution, provideInjectionContext, useInjectionContext } from \"./injectionContext\";\nimport { getMetadata } from \"./metadata\";\nimport { optionalAll } from \"./optionalAll\";\nimport { optionalBy } from \"./optionalBy\";\nimport {\n type ExistingProvider,\n isClassProvider,\n isExistingProvider,\n isFactoryProvider,\n isValueProvider,\n type Provider,\n} from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport { type Constructor, isConstructor, type ProviderType, type Token } from \"./token\";\nimport { isBuilder, type MethodDependency, type Registration, type RegistrationOptions, TokenRegistry } from \"./tokenRegistry\";\nimport { isDisposable } from \"./utils/disposable\";\nimport type { RequiredNonNullable } from \"./utils/requiredNonNullable\";\n\n/**\n * The default implementation of a di-wise-neo {@link Container}.\n */\nexport class ContainerImpl implements Container {\n private readonly myParent: ContainerImpl | undefined;\n private readonly myChildren: Set<ContainerImpl> = new Set();\n private readonly myOptions: RequiredNonNullable<ContainerOptions>;\n private readonly myHookRegistry: HookRegistry;\n private readonly myTokenRegistry: TokenRegistry;\n private myDisposed: boolean = false;\n\n constructor(parent?: ContainerImpl, options?: ChildContainerOptions) {\n this.myParent = parent;\n this.myOptions = {\n defaultScope: options?.defaultScope ?? \"Transient\",\n autoRegister: options?.autoRegister ?? false,\n disposeUnmanaged: options?.disposeUnmanaged ?? false,\n };\n\n const copyHooks = options?.copyHooks ?? true;\n this.myHookRegistry = new HookRegistry(copyHooks ? parent?.myHookRegistry : undefined);\n this.myTokenRegistry = new TokenRegistry(parent?.myTokenRegistry);\n }\n\n get registry(): TokenRegistry {\n return this.myTokenRegistry;\n }\n\n get options(): RequiredNonNullable<ContainerOptions> {\n return {\n ...this.myOptions,\n };\n }\n\n get parent(): Container | undefined {\n return this.myParent;\n }\n\n get isDisposed(): boolean {\n return this.myDisposed;\n }\n\n createChild(options?: Partial<ChildContainerOptions>): Container {\n this.checkDisposed();\n const container = new ContainerImpl(this, {\n defaultScope: options?.defaultScope ?? this.myOptions.defaultScope,\n autoRegister: options?.autoRegister ?? this.myOptions.autoRegister,\n disposeUnmanaged: options?.disposeUnmanaged ?? this.myOptions.disposeUnmanaged,\n copyHooks: options?.copyHooks ?? true,\n });\n\n this.myChildren.add(container);\n return container;\n }\n\n clearCache(): unknown[] {\n this.checkDisposed();\n return this.myTokenRegistry.clearCache();\n }\n\n getCached<T>(token: Token<T>): T | undefined {\n this.checkDisposed();\n const registration = this.myTokenRegistry.get(token);\n return registration?.valueRef?.current;\n }\n\n getAllCached<T>(token: Token<T>): T[] {\n this.checkDisposed();\n const registrations = this.myTokenRegistry.getAll(token);\n const values = new Set<T>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n resetRegistry(): unknown[] {\n this.checkDisposed();\n const [, registrations] = this.myTokenRegistry.deleteAll();\n const values = new Set<unknown>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n isRegistered<T>(token: Token<T>, name?: string): boolean {\n this.checkDisposed();\n return this.myTokenRegistry.get(token, name) !== undefined;\n }\n\n register<T>(\n ...args:\n | [Constructor<T & object> | ProviderType<T>] //\n | [Token<T>, Provider<T>, (RegistrationOptions | undefined)?]\n ): Container {\n this.checkDisposed();\n\n if (args.length === 1) {\n const [token] = args;\n\n if (isConstructor(token)) {\n this.registerClass(token);\n } else {\n this.registerToken(token, token.provider, token.options);\n }\n } else {\n this.registerToken(...args);\n }\n\n return this;\n }\n\n unregister<T>(token: Token<T>, name?: string): T[] {\n this.checkDisposed();\n const registrations = this.myTokenRegistry.delete(token, name);\n const values = new Set<T>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n resolve<T>(token: Token<T>, name?: string): T {\n this.checkDisposed();\n return this.resolveToken(token, name, false);\n }\n\n tryResolve<T>(token: Token<T>, name?: string): T | undefined {\n this.checkDisposed();\n return this.resolveToken(token, name, true);\n }\n\n resolveAll<T>(token: Token<T>): T[] {\n this.checkDisposed();\n return this.resolveAllToken(token, false);\n }\n\n tryResolveAll<T>(token: Token<T>): T[] {\n this.checkDisposed();\n return this.resolveAllToken(token, true);\n }\n\n addHook(hook: ContainerHook): void {\n this.checkDisposed();\n this.myHookRegistry.add(hook);\n }\n\n removeHook(hook: ContainerHook): void {\n this.checkDisposed();\n this.myHookRegistry.delete(hook);\n }\n\n dispose(): Promise<unknown>[] {\n if (this.myDisposed) {\n return [];\n }\n\n this.myDisposed = true;\n const promises: Promise<unknown>[] = [];\n\n // Dispose children containers first\n for (const child of this.myChildren) {\n promises.push(...child.dispose());\n }\n\n this.myChildren.clear();\n this.myParent?.myChildren?.delete(this);\n\n const [, registrations] = this.myTokenRegistry.deleteAll();\n const disposeUnmanaged = this.myOptions.disposeUnmanaged;\n const cacheValues = new Set<unknown>();\n const allValues = new Set<unknown>();\n\n for (const { provider, valueRef } of registrations) {\n if (valueRef) {\n cacheValues.add(valueRef.current);\n allValues.add(valueRef.current);\n } else if (disposeUnmanaged && isValueProvider(provider)) {\n allValues.add(provider.useValue);\n }\n }\n\n for (const value of allValues) {\n if (isDisposable(value)) {\n try {\n promises.push(Promise.resolve(value.dispose()));\n } catch (e) {\n promises.push(Promise.reject(e));\n }\n }\n }\n\n this.notifyDisposeHooks([...cacheValues]);\n this.myHookRegistry.clear();\n return promises;\n }\n\n private registerClass<T extends object>(Class: Constructor<T>): void {\n const metadata = getMetadata(Class);\n const name = metadata.name;\n const registration: Registration<T> = {\n name: name,\n // The provider is of type ClassProvider, initialized by getMetadata\n provider: metadata.provider,\n options: {\n scope: metadata.scope?.value ?? this.myOptions.defaultScope,\n },\n dependencies: metadata.dependencies,\n };\n\n // Register the class itself\n this.myTokenRegistry.put(Class, registration);\n\n // Register the additional tokens specified via class decorators.\n // These tokens will point to the original Class token and will have the same scope.\n for (const token of metadata.tokenRef.getRefTokens()) {\n this.myTokenRegistry.put(token, {\n name: name,\n provider: {\n useExisting: [Class, name],\n },\n });\n }\n\n // Eager-instantiate only if the class is container-scoped.\n // Note that we are comparing the scope using the registration configured just above,\n // which takes into account both the metadata and the container option as a fallback.\n if (metadata.eagerInstantiate && registration.options?.scope === \"Container\") {\n this.resolveProviderValue(Class, registration);\n }\n }\n\n private registerToken<T>(token: Token<T>, provider: Provider<T>, options?: RegistrationOptions): void {\n const name = provider.name;\n check(name === undefined || name.trim(), `name qualifier for token ${getTokenName(token)} must not be empty`);\n\n if (isClassProvider(provider)) {\n const metadata = getMetadata(provider.useClass);\n const registration: Registration<T> = {\n // An explicit provider name overrides what is specified via @Named\n name: metadata.name ?? name,\n provider: metadata.provider,\n options: {\n // Explicit registration options override what is specified via class decorators (e.g., @Scoped)\n scope: metadata.scope?.value ?? this.myOptions.defaultScope,\n ...options,\n },\n dependencies: metadata.dependencies,\n };\n\n this.myTokenRegistry.put(token, registration);\n\n // Eager-instantiate only if the provided class is container-scoped.\n // Note that we are comparing the scope using the registration configured just above,\n // which takes into account both the metadata and the container option as a fallback.\n if (metadata.eagerInstantiate && registration.options?.scope === \"Container\") {\n this.resolveProviderValue(token, registration);\n }\n } else {\n if (isExistingProvider(provider)) {\n const [targetToken] = this.getTargetToken(provider);\n check(token !== targetToken, `token ${getTokenName(token)} cannot alias itself via useExisting`);\n }\n\n this.myTokenRegistry.put(token, {\n name: name,\n provider: provider,\n options: options,\n });\n }\n }\n\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: false): T;\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: true): T | undefined;\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: boolean): T | undefined {\n let registration = this.myTokenRegistry.get(token, name);\n\n if (!registration && isConstructor(token)) {\n registration = this.autoRegisterClass(token, name);\n }\n\n return this.resolveRegistration(token, registration, optional, name)?.value;\n }\n\n private resolveAllToken<T>(token: Token<T>, optional: boolean): T[] {\n let registrations = this.myTokenRegistry.getAll(token);\n\n if (registrations.length === 0 && isConstructor(token)) {\n const registration = this.autoRegisterClass(token);\n\n if (registration) {\n registrations = [registration];\n }\n }\n\n if (registrations.length === 0 && !optional) {\n throwUnregisteredError([token]);\n }\n\n return registrations\n .map((registration) => this.resolveRegistration(token, registration, optional))\n .filter((result) => result !== undefined)\n .map((result) => result.value);\n }\n\n private resolveRegistration<T>(\n token: Token<T>,\n registration: Registration<T> | undefined,\n optional?: boolean,\n name?: string,\n ): { value: T } | undefined {\n const aliases: TokenInfo[] = [];\n\n while (registration && isExistingProvider(registration.provider)) {\n const [targetToken, targetName] = this.getTargetToken(registration.provider);\n\n if (aliases.some(([t]) => t === targetToken)) {\n throwCircularAliasError([[token, name], ...aliases]);\n }\n\n // eslint-disable-next-line no-param-reassign\n registration = this.myTokenRegistry.get(targetToken, targetName);\n aliases.push([targetToken, targetName]);\n\n if (!registration && !optional) {\n throwTargetUnregisteredError([token, name], aliases);\n }\n }\n\n if (!registration) {\n return optional ? undefined : throwUnregisteredError([token, name]);\n }\n\n try {\n return {\n value: this.resolveProviderValue(token, registration),\n };\n } catch (e) {\n throwResolutionError([token, name], aliases, e);\n }\n }\n\n private getTargetToken<T>(provider: ExistingProvider<T>): [Token<T>, (string | undefined)?] {\n const token = provider.useExisting;\n return Array.isArray(token) ? token : [token];\n }\n\n private autoRegisterClass<T extends object>(Class: Constructor<T>, name?: string): Registration<T> | undefined {\n const metadata = getMetadata(Class);\n const autoRegister = metadata.autoRegister ?? this.myOptions.autoRegister;\n\n if (autoRegister && (name === undefined || metadata.name === name)) {\n // Temporarily set eagerInstantiate to false to avoid potentially resolving\n // the class inside register()\n const eagerInstantiate = metadata.eagerInstantiate;\n metadata.eagerInstantiate = false;\n\n try {\n this.register(Class);\n return this.myTokenRegistry.get(Class, name ?? metadata.name);\n } finally {\n metadata.eagerInstantiate = eagerInstantiate;\n }\n }\n\n return undefined;\n }\n\n private resolveProviderValue<T>(token: Token<T>, registration: Registration<T>): T;\n private resolveProviderValue<T extends object>(token: Constructor<T>, registration: Registration<T>): T;\n private resolveProviderValue<T>(token: Token<T>, registration: Registration<T>): T {\n const provider = registration.provider;\n\n if (isClassProvider(provider)) {\n const Class = provider.useClass;\n return this.resolveScopedValue(token, registration, (args) => new Class(...args));\n }\n\n if (isFactoryProvider(provider)) {\n const factory = provider.useFactory;\n return this.resolveScopedValue(token, registration, () => factory());\n }\n\n if (isValueProvider(provider)) {\n return provider.useValue;\n }\n\n check(false, \"internal: unexpected ExistingProvider\");\n }\n\n private resolveScopedValue<T>(token: Token<T>, registration: Registration<T>, factory: (...args: any[]) => T): T {\n let context = useInjectionContext();\n\n if (!context || context.container !== this) {\n context = {\n container: this,\n resolution: createResolution(),\n };\n }\n\n const resolution = context.resolution;\n const provider = registration.provider;\n\n if (resolution.stack.has(provider)) {\n const dependentRef = resolution.dependents.get(provider);\n check(dependentRef, () => {\n const path = getTokenPath(resolution.tokens.concat(token).map((t) => [t]));\n return `circular dependency detected while resolving ${path}`;\n });\n\n return dependentRef.current;\n }\n\n const scope = registration.options?.scope ?? this.myOptions.defaultScope;\n const cleanups = [\n provideInjectionContext(context),\n resolution.tokens.push(token) && (() => resolution.tokens.pop()),\n !isBuilder(provider) && resolution.stack.push(provider, { provider, scope }),\n ];\n\n try {\n switch (scope) {\n case \"Container\": {\n const valueRef = registration.valueRef;\n\n if (valueRef) {\n return valueRef.current;\n }\n\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n registration.valueRef = { current: value };\n this.notifyProvideHooks(value, scope);\n return value;\n }\n case \"Resolution\": {\n const valueRef = resolution.values.get(provider);\n\n if (valueRef) {\n return valueRef.current;\n }\n\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n resolution.values.set(provider, { current: value });\n this.notifyProvideHooks(value, scope);\n return value;\n }\n case \"Transient\": {\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n this.notifyProvideHooks(value, scope);\n return value;\n }\n }\n } finally {\n cleanups.forEach((cleanup) => cleanup && cleanup());\n }\n }\n\n private resolveCtorDependencies<T>(registration: Registration<T>): any[] {\n const dependencies = registration.dependencies;\n\n if (dependencies) {\n check(isClassProvider(registration.provider), `internal: expected a ClassProvider`);\n const ctorDeps = dependencies.ctor.filter((d) => d.appliedBy);\n\n if (ctorDeps.length > 0) {\n // Let's check if all necessary constructor parameters are decorated.\n // If not, we cannot safely create an instance.\n const ctor = registration.provider.useClass;\n check(ctor.length === ctorDeps.length, () => {\n const location = getLocation(ctor);\n const msg = `${location} expected ${ctor.length} decorated constructor parameters`;\n return `${msg}, but found ${ctorDeps.length}`;\n });\n\n return this.resolveArgs(ctorDeps, ctor);\n }\n }\n\n return [];\n }\n\n private injectMethodDependencies<T>(registration: Registration<T>, instance: T): T {\n const dependencies = registration.dependencies;\n\n if (dependencies) {\n check(isClassProvider(registration.provider), `internal: expected a ClassProvider`);\n const ctor = registration.provider.useClass;\n\n // Perform method injection\n for (const entry of dependencies.methods) {\n const methodKey = entry[0];\n const methodDeps = entry[1].filter((d) => d.appliedBy);\n\n // Let's check if all necessary method parameters are decorated.\n // If not, we cannot safely invoke the method.\n const method = (instance as any)[methodKey] as Function;\n check(methodDeps.length === method.length, () => {\n const location = getLocation(ctor, methodKey);\n const msg = `${location} expected ${method.length} decorated method parameters`;\n return `${msg}, but found ${methodDeps.length}`;\n });\n\n const args = this.resolveArgs(methodDeps, ctor, instance, methodKey);\n method.bind(instance)(...args);\n }\n }\n\n return instance;\n }\n\n // Call context: decorator-based injection\n private resolveArgs(deps: MethodDependency[], ctor: Constructor<object>, instance?: any, methodKey?: string | symbol): any[] {\n const sortedDeps = deps.sort((a, b) => a.index - b.index);\n const args: any[] = [];\n\n for (const dep of sortedDeps) {\n try {\n args.push(this.resolveDependency(dep, instance));\n } catch (e) {\n throwParameterResolutionError(ctor, methodKey, dep, e);\n }\n }\n\n return args;\n }\n\n // Call context: decorator-based injection\n private resolveDependency(dependency: MethodDependency, instance?: any): any {\n const token = dependency.tokenRef!.getRefToken();\n check(token, `token passed to @${dependency.appliedBy} was undefined (possible circular imports)`);\n const name = dependency.name;\n\n switch (dependency.appliedBy) {\n case \"Inject\":\n return instance ? injectBy(instance, token, name) : this.resolve(token, name);\n case \"InjectAll\":\n return instance ? injectAll(token) : this.resolveAll(token);\n case \"Optional\":\n return instance ? optionalBy(instance, token, name) : this.tryResolve(token, name);\n case \"OptionalAll\":\n return instance ? optionalAll(token) : this.tryResolveAll(token);\n case undefined:\n check(false, \"internal: unexpected undefined appliedBy\");\n }\n }\n\n private notifyProvideHooks(value: unknown, scope: Scope): void {\n for (const hook of this.myHookRegistry.get()) {\n hook.onProvide?.(value, scope);\n }\n }\n\n private notifyDisposeHooks(values: unknown[]): void {\n for (const hook of this.myHookRegistry.get()) {\n hook.onDispose?.(values);\n }\n }\n\n private checkDisposed(): void {\n check(!this.myDisposed, \"container is disposed\");\n }\n}\n","import { ContainerImpl } from \"./containerImpl\";\nimport type { ClassProvider, ExistingProvider, FactoryProvider, Provider, ValueProvider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport type { Constructor, ProviderType, Token } from \"./token\";\nimport type { RegistrationOptions, TokenRegistry } from \"./tokenRegistry\";\nimport type { RequiredNonNullable } from \"./utils/requiredNonNullable\";\n\ntype ProviderFor<V> = V extends object ? Provider<V> : Exclude<Provider<V>, ClassProvider<any>>;\ntype RegistrationOptionsFor<P> = P extends ValueProvider<any> ? never : RegistrationOptions;\n\n/**\n * Container creation options.\n */\nexport interface ContainerOptions {\n /**\n * The default scope for registrations.\n *\n * @defaultValue Transient\n */\n readonly defaultScope?: Scope | undefined;\n\n /**\n * Whether to automatically register an unregistered class when resolving it as a token.\n *\n * @defaultValue false\n */\n readonly autoRegister?: boolean | undefined;\n\n /**\n * Whether to also dispose values provided via {@link ValueProvider}, which are not\n * created or managed by the container, when the container itself is disposed.\n *\n * @defaultValue false\n */\n readonly disposeUnmanaged?: boolean | undefined;\n}\n\n/**\n * Child container creation options.\n */\nexport interface ChildContainerOptions extends ContainerOptions {\n /**\n * Whether to copy {@link ContainerHook}(s) from the parent container.\n *\n * @defaultValue true\n */\n readonly copyHooks?: boolean | undefined;\n}\n\n/**\n * A hook into the lifecycle of a {@link Container}.\n */\nexport interface ContainerHook {\n /**\n * Called when the container provides a value for a {@link Token}.\n * - For **Container**-scoped tokens, it is called only once when the token is first resolved and cached.\n * - For **Resolution**-scoped tokens, it is called once per token resolution graph.\n * - For **Transient**-scoped tokens, it is called each time the token is resolved,\n * which might mean multiple times per resolution graph.\n *\n * @param value - The provided value.\n * @param scope - The {@link Scope} of the provided value.\n */\n readonly onProvide?: ((value: unknown, scope: Scope) => void) | undefined;\n\n /**\n * Called after the container has been disposed.\n *\n * @param values - All distinct values that were cached by the disposed container.\n * Currently, only **Container**-scoped token values are cached.\n */\n readonly onDispose?: ((values: unknown[]) => void) | undefined;\n}\n\n/**\n * A Dependency Injection container.\n */\nexport interface Container {\n /**\n * @internal\n */\n readonly registry: TokenRegistry;\n\n /**\n * The options used to create this container.\n */\n readonly options: RequiredNonNullable<ContainerOptions>;\n\n /**\n * The parent container, or `undefined` if this is the root container.\n */\n readonly parent: Container | undefined;\n\n /**\n * Whether this container is disposed.\n */\n readonly isDisposed: boolean;\n\n /**\n * Creates a new child container that inherits this container's options.\n *\n * You can pass specific options to override the inherited ones.\n */\n createChild(options?: ChildContainerOptions): Container;\n\n /**\n * Clears and returns all distinct values cached by this container.\n * Values from {@link ValueProvider} registrations are not included, as they are never cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n clearCache(): unknown[];\n\n /**\n * Returns the cached value from the most recent registration of the token,\n * or `undefined` if no value has been cached yet (the token has not been resolved yet).\n *\n * If the token has at least one registration in this container,\n * the cached value is taken from the most recent of those registrations.\n * Otherwise, it may be retrieved from parent containers, if any.\n *\n * Values are never cached for tokens with **Transient** or **Resolution** scope,\n * or for {@link ValueProvider} registrations.\n */\n getCached<Value>(token: Token<Value>): Value | undefined;\n\n /**\n * Returns all cached values associated with registrations of the token,\n * in the order they were registered, or an empty array if none have been cached.\n *\n * If the token has at least one registration in the current container,\n * cached values are taken from those registrations.\n * Otherwise, cached values may be retrieved from parent containers, if any.\n *\n * Values are never cached for tokens with **Transient** or **Resolution** scope,\n * or for {@link ValueProvider} registrations.\n */\n getAllCached<Value>(token: Token<Value>): Value[];\n\n /**\n * Removes all registrations from this container's internal registry.\n *\n * Returns an array of the distinct values that were cached by this container for the\n * removed registrations. Values from {@link ValueProvider} registrations are not included,\n * as they are not cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n resetRegistry(): unknown[];\n\n /**\n * Returns whether the token is registered in this container or in parent containers, if any.\n */\n isRegistered<Value>(token: Token<Value>, name?: string): boolean;\n\n /**\n * Registers a {@link ClassProvider}, using the class itself as its token.\n *\n * Tokens provided via the {@link Injectable} decorator applied to the class\n * are also registered as aliases.\n *\n * The scope is determined by the {@link Scoped} decorator - if present -\n * or by the {@link ContainerOptions.defaultScope} value.\n */\n register<Instance extends object>(Class: Constructor<Instance>): Container;\n\n /**\n * Registers a token type with a default {@link Provider} and optional default registration options.\n */\n register<Value>(token: ProviderType<Value>): Container;\n\n /**\n * Registers a {@link Provider} with a token or class.\n *\n * The provider must be one of:\n * - {@link ClassProvider} via `useClass`\n * - {@link FactoryProvider} via `useFactory`\n * - {@link ValueProvider} via `useValue`\n * - {@link ExistingProvider} via `useExisting`\n *\n * For {@link ClassProvider} registrations, the default scope is determined by the {@link Scoped}\n * decorator applied to the provided class - if present - or by the {@link ContainerOptions.defaultScope}\n * value, but it can be overridden by passing explicit registration options.\n *\n * For {@link ValueProvider} registrations, the provided value is returned as-is and never cached,\n * and registration options do not apply.\n */\n register<Value, ProviderValue extends Value, Provider extends ProviderFor<ProviderValue>>(\n token: Token<Value>,\n provider: ProviderFor<ProviderValue> & Provider,\n options?: RegistrationOptionsFor<Provider>,\n ): Container;\n\n /**\n * Registers a {@link ClassProvider} with a token.\n *\n * The default registration scope is determined by the {@link Scoped} decorator\n * applied to the provided class - if present - or by the {@link ContainerOptions.defaultScope}\n * value, but it can be overridden by passing explicit registration options.\n */\n register<Instance extends object, ProviderInstance extends Instance>(\n token: Token<Instance>,\n provider: ClassProvider<ProviderInstance>,\n options?: RegistrationOptions,\n ): Container;\n\n /**\n * Registers a {@link FactoryProvider} with a token.\n */\n register<Value, ProviderValue extends Value>(\n token: Token<Value>,\n provider: FactoryProvider<ProviderValue>,\n options?: RegistrationOptions,\n ): Container;\n\n /**\n * Registers an {@link ExistingProvider} with a token.\n *\n * The token will alias the one set in `useExisting`.\n */\n register<Value, ProviderValue extends Value>(token: Token<Value>, provider: ExistingProvider<ProviderValue>): Container;\n\n /**\n * Registers a {@link ValueProvider} with a token.\n *\n * Values provided via `useValue` are never cached (scopes do not apply)\n * and are simply returned as-is.\n */\n register<Value, ProviderValue extends Value>(token: Token<Value>, provider: ValueProvider<ProviderValue>): Container;\n\n /**\n * Removes all registrations for the given token from the container's internal registry.\n *\n * Returns an array of the distinct values that were cached by this container for the\n * removed registrations. Values from {@link ValueProvider} registrations are not included,\n * as they are not cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n unregister<Value>(token: Token<Value>, name?: string): Value[];\n\n /**\n * Resolves the given class to the instance associated with it.\n *\n * If the class is registered in this container or any of its parent containers,\n * an instance is created using the most recent registration.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instance is cached\n * in the container's internal registry.\n */\n resolve<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n /**\n * Resolves the given token to the value associated with it.\n *\n * If the token is registered in this container or any of its parent containers,\n * its value is resolved using the most recent registration.\n *\n * If the token is not registered in this container or any of its parent containers, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved value is cached\n * in the container's internal registry.\n */\n resolve<Value>(token: Token<Value>, name?: string): Value;\n\n /**\n * Resolves the given class to the instance associated with it.\n *\n * If the class is registered in this container or any of its parent containers,\n * an instance is created using the most recent registration.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, `undefined` is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instance is cached\n * in the container's internal registry.\n */\n tryResolve<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n /**\n * Tries to resolve the given token to the value associated with it.\n *\n * If the token is registered in this container or any of its parent containers,\n * its value is resolved using the most recent registration.\n *\n * If the token is not registered in this container or any of its parent containers,\n * `undefined` is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved value is cached\n * in the container's internal registry.\n */\n tryResolve<Value>(token: Token<Value>, name?: string): Value | undefined;\n\n /**\n * Resolves the given class to all instances provided by the registrations associated with it.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instances are cached\n * in the container's internal registry.\n *\n * A separate instance of the class is created for each provider.\n */\n resolveAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Resolves the given token to all values provided by the registrations associated with it.\n *\n * If the token is not registered in this container or any of its parent containers, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved values are cached\n * in the container's internal registry.\n */\n resolveAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Resolves the given class to all instances provided by the registrations associated with it.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an empty array is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instances are cached\n * in the container's internal registry.\n *\n * A separate instance of the class is created for each provider.\n */\n tryResolveAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Resolves the given token to all values provided by the registrations associated with it.\n *\n * If the token is not registered in this container or any of its parent containers,\n * an empty array is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved values are cached\n * in the container's internal registry.\n */\n tryResolveAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Adds a hook to observe the lifecycle of container-managed values.\n *\n * Does nothing if the hook has already been added.\n */\n addHook(hook: ContainerHook): void;\n\n /**\n * Removes a previously added hook.\n *\n * Does nothing if the hook has not been added yet.\n */\n removeHook(hook: ContainerHook): void;\n\n /**\n * Disposes this container and all its cached values.\n *\n * Token values implementing a `Disposable` interface (e.g., objects with a `dispose()` function)\n * are also disposed. All disposals, whether synchronous or asynchronous, are returned as promises\n * in an array. Callers may await these promises (e.g., using `Promise.allSettled()`) if they want\n * to ensure that all async work has completed.\n *\n * Note that children containers are disposed first, in creation order.\n */\n dispose(): Promise<unknown>[];\n}\n\n/**\n * Creates a new container.\n */\nexport function createContainer(options?: ContainerOptions): Container {\n return new ContainerImpl(undefined, options);\n}\n","import { getMetadata } from \"../metadata\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that enables auto-registration of an unregistered class\n * when the class is first resolved from the container.\n *\n * Example:\n * ```ts\n * @AutoRegister()\n * class Wizard {}\n *\n * const wizard = container.resolve(Wizard);\n * container.isRegistered(Wizard); // => true\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function AutoRegister<This extends object>(): ClassDecorator<This> {\n return function (Class): void {\n const metadata = getMetadata(Class);\n metadata.autoRegister = true;\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that sets the class scope to **Container** and enables\n * eager instantiation when the class is registered in the container.\n *\n * This causes the container to immediately create and cache the instance of the class,\n * instead of deferring instantiation until the first resolution.\n *\n * Example:\n * ```ts\n * @EagerInstantiate()\n * class Wizard {}\n *\n * // Wizard is registered with Container scope, and an instance\n * // is immediately created and cached by the container\n * container.register(Wizard);\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function EagerInstantiate<This extends object>(): ClassDecorator<This> {\n return function (Class): void {\n const metadata = getMetadata(Class);\n const currentScope = metadata.scope;\n check(!currentScope || currentScope.value === \"Container\", () => {\n const { value, appliedBy } = currentScope!;\n const className = getTokenName(Class);\n return (\n `class ${className}: scope ${value} was already set by @${appliedBy},\\n ` +\n `but @EagerInstantiate is trying to set a conflicting scope Container.\\n ` +\n `Only one decorator should set the class scope, or all must agree on the same value.`\n );\n });\n\n metadata.eagerInstantiate = true;\n metadata.scope = {\n value: \"Container\",\n appliedBy: \"EagerInstantiate\",\n };\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects the instance associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected. Use function injection with {@link injectBy}\n * if resolving circular dependencies is necessary.\n */\nexport function Inject<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected. Use function injection with {@link injectBy}\n * if resolving circular dependencies is necessary.\n */\nexport function Inject<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected. Use function injection with {@link injectBy}\n * if resolving circular dependencies is necessary.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@Inject(tokenRef(() => Wand)) readonly wand: Wand) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function Inject<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function Inject<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return function (target, propertyKey, parameterIndex): void {\n updateParameterMetadata(\"Inject\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Inject\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n });\n };\n}\n","import { getMetadata } from \"../metadata\";\nimport type { Token, Tokens } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that registers additional aliasing tokens for the decorated type.\n *\n * The aliases are added using {@link ExistingProvider}(s) when the class is first\n * registered in the container.\n *\n * Example:\n * ```ts\n * @Injectable(Weapon)\n * class Rifle {}\n * ```\n *\n * Note that `@Injectable` decorators can be stacked to add multiple aliases.\n *\n * Example:\n * ```ts\n * @Injectable(Weapon)\n * @Injectable(Gun) // Or just @Injectable(Weapon, Gun)\n * class Rifle {}\n * ```\n */\nexport function Injectable<Value, This extends Value & object>(token: Token<Value>): ClassDecorator<This>;\nexport function Injectable<VA, VB, This extends VA & VB & object>(tokenA: Token<VA>, tokenB: Token<VB>): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, This extends VA & VB & VC & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, This extends VA & VB & VC & VD & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, VE, This extends VA & VB & VC & VD & VE & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n tokenE: Token<VE>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, VE, VF, This extends VA & VB & VC & VD & VE & VF & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n tokenE: Token<VE>,\n tokenF: Token<VF>,\n): ClassDecorator<This>;\n\n/**\n * Class decorator that registers an additional aliasing token for the decorated type.\n *\n * The alias is added using an {@link ExistingProvider} when the class is first\n * registered in the container.\n *\n * This overload allows referencing tokens that are declared later in the file\n * by using the {@link tokenRef} helper function.\n *\n * Example:\n * ```ts\n * @Injectable(tokenRef(() => Weapon)) // Weapon is declared after Rifle\n * class Rifle {}\n * // Other code...\n * const Weapon = createType(\"Weapon\");\n * ```\n *\n * Note that `@Injectable` decorators can be stacked to add multiple aliases.\n *\n * Example:\n * ```ts\n * @Injectable(tokenRef(() => Weapon))\n * @Injectable(Gun)\n * class Rifle {}\n * ```\n */\nexport function Injectable<Value, This extends Value & object>(tokens: TokenRef<Value>): ClassDecorator<This>;\n\n// @__NO_SIDE_EFFECTS__\nexport function Injectable<This extends object>(...args: [...Tokens<This>] | [TokenRef<This>]): ClassDecorator<This> {\n return function (Class): void {\n const metadata = getMetadata(Class);\n const arg0 = args[0];\n const ref = isTokenRef(arg0) ? arg0 : tokenRef(() => args as Tokens<This>);\n const currentRef = metadata.tokenRef;\n metadata.tokenRef = {\n getRefToken: () => currentRef.getRefToken(),\n getRefTokens: () => {\n const existingTokens = currentRef.getRefTokens();\n\n for (const token of ref.getRefTokens()) {\n existingTokens.add(token);\n }\n\n return existingTokens;\n },\n };\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects all instances provided by the registrations\n * associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function InjectAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function InjectAll<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@InjectAll(tokenRef(() => Wand)) readonly wands: Wand[]) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function InjectAll<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function InjectAll<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return function (target, propertyKey, parameterIndex): void {\n updateParameterMetadata(\"InjectAll\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"InjectAll\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { Constructor } from \"../token\";\nimport type { ClassDecorator, ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, describeParam, updateParameterMetadata } from \"./utils\";\n\n/**\n * Qualifies a class or an injected parameter with a unique name.\n *\n * This allows the container to distinguish between multiple implementations\n * of the same interface or type during registration and injection.\n *\n * Example:\n * ```ts\n * @Named(\"dumbledore\")\n * class Dumbledore implements Wizard {}\n *\n * // Register Dumbledore with Type<Wizard>\n * container.register(IWizard, { useClass: Dumbledore });\n * const dumbledore = container.resolve(IWizard, \"dumbledore\");\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function Named<This extends object>(name: string): ClassDecorator<This> & ParameterDecorator {\n check(name.trim(), \"@Named qualifier must not be empty\");\n return function (target: object, propertyKey?: string | symbol, parameterIndex?: number): void {\n if (parameterIndex === undefined) {\n // The decorator has been applied to the class\n const Class = target as Constructor<This>;\n const metadata = getMetadata(Class);\n const className = getTokenName(Class);\n check(metadata.name === undefined, `multiple @Named decorators on class ${className}, but only one is allowed`);\n metadata.name = name;\n } else {\n // The decorator has been applied to a method parameter\n updateParameterMetadata(\"Named\", target, propertyKey, parameterIndex, (dependency) => {\n check(dependency.name === undefined, () => {\n const param = describeParam(target, propertyKey, parameterIndex);\n return `multiple @Named decorators on ${param}, but only one is allowed`;\n });\n\n dependency.name = name;\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n }\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} if resolving circular dependencies is necessary.\n */\nexport function Optional<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} if resolving circular dependencies is necessary.\n */\nexport function Optional<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} if resolving circular dependencies is necessary.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@Optional(tokenRef(() => Wand)) readonly wand: Wand | undefined) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function Optional<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function Optional<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return function (target, propertyKey, parameterIndex): void {\n updateParameterMetadata(\"Optional\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Optional\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n });\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects all instances provided by the registrations\n * associated with the given class or an empty array if the class is not registered\n * in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function OptionalAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token or an empty array if the token is not registered\n * in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function OptionalAll<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token or an empty array if the token is not registered\n * in the container.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if a circular dependency is detected.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@OptionalAll(tokenRef(() => Wand)) readonly wands: Wand[]) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function OptionalAll<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function OptionalAll<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return function (target, propertyKey, parameterIndex): void {\n updateParameterMetadata(\"OptionalAll\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"OptionalAll\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { Scope } from \"../scope\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator for setting the scope of the decorated type when registering it.\n *\n * The scope set by this decorator can be overridden by explicit registration options, if provided.\n *\n * Example:\n * ```ts\n * @Scoped(\"Container\")\n * class Wizard {}\n *\n * container.register(Wizard);\n *\n * // Under the hood\n * container.register(\n * Wizard,\n * { useClass: Wizard },\n * { scope: \"Container\" },\n * );\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function Scoped<This extends object>(scope: Scope): ClassDecorator<This> {\n return function (Class): void {\n const metadata = getMetadata(Class);\n const currentScope = metadata.scope;\n check(!currentScope || currentScope.value === scope, () => {\n const { value, appliedBy } = currentScope!;\n const by = appliedBy === \"Scoped\" ? `another @${appliedBy} decorator` : `@${appliedBy}`;\n const className = getTokenName(Class);\n return (\n `class ${className}: scope ${value} was already set by ${by},\\n ` +\n `but @Scoped is trying to set a conflicting scope ${scope}.\\n ` +\n `Only one decorator should set the class scope, or all must agree on the same value.`\n );\n });\n\n metadata.scope = {\n value: scope,\n appliedBy: \"Scoped\",\n };\n };\n}\n","import { inject } from \"./inject\";\nimport { injectAll } from \"./injectAll\";\nimport { ensureInjectionContext, provideInjectionContext, useInjectionContext } from \"./injectionContext\";\nimport { optional } from \"./optional\";\nimport { optionalAll } from \"./optionalAll\";\nimport type { Constructor, Token, Type } from \"./token\";\nimport { build } from \"./tokenRegistry\";\n\n/**\n * Allows performing injections outside the normal injection context window.\n *\n * Example:\n * ```ts\n * class Wizard {\n * private injector = inject(Injector);\n *\n * // Lazily initialize the wand property\n * private wand?: Wand;\n *\n * getWand(): Wand {\n * // An injection context does not exist here, but the\n * // Injector instance retains and reuses the context\n * // that was present at the time of its injection\n * return (this.wand ??= this.injector.inject(Wand));\n * }\n * }\n * ```\n */\nexport interface Injector {\n /**\n * Injects the instance associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n */\n inject<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n /**\n * Injects the value associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n */\n inject<Value>(token: Token<Value>, name?: string): Value;\n\n /**\n * Injects all instances provided by the registrations associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n */\n injectAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Injects all values provided by the registrations associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n */\n injectAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n */\n optional<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n /**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n */\n optional<Value>(token: Token<Value>, name?: string): Value | undefined;\n\n /**\n * Injects all instances provided by the registrations associated with the given class\n * or an empty array if the class is not registered in the container.\n */\n optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Injects all values provided by the registrations associated with the given token\n * or an empty array if the token is not registered in the container.\n */\n optionalAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Runs a function inside the injection context of this injector.\n *\n * Note that injection functions (`inject`, `injectAll`, `optional`, `optionalAll`)\n * are only usable synchronously: they cannot be called from asynchronous callbacks\n * or after any `await` points.\n *\n * @param fn - The function to be run in the context of this injector.\n * @returns The return value of the function, if any.\n */\n runInContext<ReturnType>(fn: () => ReturnType): ReturnType;\n}\n\n/**\n * Allows performing injections outside the normal injection context window.\n *\n * Example:\n * ```ts\n * class Wizard {\n * private injector = inject(Injector);\n *\n * // Lazily initialize the wand property\n * private wand?: Wand;\n *\n * getWand(): Wand {\n * // An injection context does not exist here, but the\n * // Injector instance retains and reuses the context\n * // that was present at the time of its injection\n * return (this.wand ??= this.injector.inject(Wand));\n * }\n * }\n * ```\n */\nexport const Injector: Type<Injector> = /* @__PURE__ */ build<Injector>(() => {\n const context = ensureInjectionContext(\"Injector factory\");\n const runInContext = <R>(fn: () => R): R => {\n if (useInjectionContext()) {\n return fn();\n }\n\n const cleanup = provideInjectionContext(context);\n\n try {\n return fn();\n } finally {\n cleanup();\n }\n };\n\n return {\n inject: <T>(token: Token<T>, name?: string) => runInContext(() => inject(token, name)),\n injectAll: <T>(token: Token<T>) => runInContext(() => injectAll(token)),\n optional: <T>(token: Token<T>, name?: string) => runInContext(() => optional(token, name)),\n optionalAll: <T>(token: Token<T>) => runInContext(() => optionalAll(token)),\n runInContext: runInContext,\n };\n}, \"Injector\");\n","export const Scope = {\n /**\n * Creates a new value every time the token is resolved.\n */\n Transient: \"Transient\",\n\n /**\n * Creates and caches a single value per token resolution graph.\n *\n * The same value is reused during a single resolution request and is subsequently discarded.\n */\n Resolution: \"Resolution\",\n\n /**\n * Creates and caches a single value per container.\n *\n * If the value is not found in the current container, it is looked up in the parent container,\n * and so on. It effectively behaves like a _singleton_ scope but allows container-specific overrides.\n */\n Container: \"Container\",\n} as const;\n\nexport type Scope = (typeof Scope)[keyof typeof Scope];\n"],"names":["check","condition","message","Error","tag","throwUnregisteredError","tokenInfo","getFullTokenName","throwTargetUnregisteredError","aliases","path","length","getTokenPath","desc","cause","at","throwCircularAliasError","throwResolutionError","getCause","throwParameterResolutionError","ctor","methodKey","dependency","location","getLocation","tokenName","tokenRef","getRefToken","name","msg","index","ctorName","String","tokens","map","join","getTokenName","token","undefined","error","isError","untag","value","stack","startsWith","substring","trimStart","HookRegistry","parent","myHooks","Set","clear","get","add","hook","delete","KeyedStack","has","key","myKeys","peek","myEntries","push","pop","WeakSet","WeakRefMap","ref","myMap","deref","set","WeakRef","WeakMap","createResolution","values","dependents","provideInjectionContext","useInjectionContext","createInjectionContext","ensureInjectionContext","context","assertInjectionContext","fn","current","provide","next","prev","use","injectAll","container","resolveAll","inject","resolve","injectBy","thisArg","resolution","currentFrame","cleanup","provider","classRef","Class","getRefClass","tokenOrTokens","Array","isArray","getRefTokens","tokensArray","isClassRef","isTokenRef","Metadata","dependencies","methods","Map","useClass","getCtorDependency","i","findIndex","d","getMethodDependency","method","methodDeps","getMetadata","classOrRef","originalClass","classIdentityMap","metadata","metadataMap","setClassIdentityMapping","transformedClass","optionalAll","tryResolveAll","optional","tryResolve","optionalBy","isClassProvider","isFactoryProvider","isValueProvider","isExistingProvider","updateParameterMetadata","decorator","target","parameterIndex","updateFn","checkSingleDecorator","appliedBy","param","describeParam","checkNamedDecorator","createType","typeName","options","propertyKey","type","Object","defineProperty","__type","toString","isConstructor","getTypeName","proto","getPrototypeOf","prototype","TokenRegistry","myRegistrations","myParent","getAll","internal","internals","getAllFromParent","put","registration","registrations","existing","filter","r","removed","updated","deleteAll","keys","flat","clearCache","valueRef","isBuilder","builders","build","factory","useFactory","scope","isDisposable","dispose","ContainerImpl","myChildren","myDisposed","myOptions","defaultScope","autoRegister","disposeUnmanaged","copyHooks","myHookRegistry","myTokenRegistry","registry","isDisposed","createChild","checkDisposed","getCached","getAllCached","resetRegistry","isRegistered","register","args","registerClass","registerToken","unregister","resolveToken","resolveAllToken","addHook","removeHook","promises","child","cacheValues","allValues","useValue","Promise","e","reject","notifyDisposeHooks","useExisting","eagerInstantiate","resolveProviderValue","trim","targetToken","getTargetToken","autoRegisterClass","resolveRegistration","result","targetName","some","t","resolveScopedValue","dependentRef","concat","cleanups","resolveCtorDependencies","injectMethodDependencies","notifyProvideHooks","forEach","ctorDeps","resolveArgs","instance","entry","bind","deps","sortedDeps","sort","a","b","dep","resolveDependency","onProvide","onDispose","createContainer","AutoRegister","EagerInstantiate","currentScope","className","Inject","Injectable","arg0","currentRef","existingTokens","InjectAll","Named","Optional","OptionalAll","Scoped","by","Injector","runInContext","Scope","Transient","Resolution","Container"],"mappings":";;AASO,SAASA,KAAAA,CAAMC,SAAkB,EAAEC,OAAgC,EAAA;AACxE,IAAA,IAAI,CAACD,SAAAA,EAAW;AACd,QAAA,MAAM,IAAIE,KAAAA,CAAMC,GAAAA,CAAI,OAAOF,OAAAA,KAAY,WAAWA,OAAAA,GAAUA,OAAAA,EAAAA,CAAAA,CAAAA;AAC9D,IAAA;AACF;AAEA;AACO,SAASG,uBAAuBC,SAAoB,EAAA;AACzD,IAAA,MAAM,IAAIH,KAAAA,CAAMC,GAAAA,CAAI,CAAC,mBAAmB,EAAEG,iBAAiBD,SAAAA,CAAAA,CAAAA,CAAY,CAAA,CAAA;AACzE;AAEA;AACO,SAASE,4BAAAA,CAA6BF,SAAoB,EAAEG,OAAoB,EAAA;AACrF,IAAA,MAAMC,IAAAA,GAAOD,OAAAA,CAAQE,MAAM,GAAG,CAAA,GAAI,CAAC,YAAY,EAAEC,YAAAA,CAAaH,OAAAA,CAAAA,CAAS,CAAC,CAAC,GAAG,EAAA;IAC5E,MAAMI,IAAAA,GAAON,iBAAiBD,SAAAA,CAAAA,GAAaI,IAAAA;IAC3C,MAAMI,KAAAA,GAAQ,CAAC,qDAAqD,EAAEP,iBAAiBE,OAAAA,CAAQM,EAAE,CAAC,EAAC,CAAA,CAAA,CAAA,CAAM;AACzG,IAAA,MAAM,IAAIZ,KAAAA,CAAMC,GAAAA,CAAI,CAAC,wBAAwB,EAAES,MAAM,CAAA,GAAIC,KAAAA,CAAAA;AAC3D;AAEA;AACO,SAASE,wBAAwBP,OAAoB,EAAA;AAC1D,IAAA,MAAMC,OAAOE,YAAAA,CAAaH,OAAAA,CAAAA;AAC1B,IAAA,MAAM,IAAIN,KAAAA,CAAMC,GAAAA,CAAI,CAAC,wCAAwC,EAAEM,IAAAA,CAAAA,CAAM,CAAA,CAAA;AACvE;AAEA;AACO,SAASO,oBAAAA,CAAqB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,CAAAA;AAChF2D,QAAAA,SAAAA,EAAW,CAAIlD,KAAAA,GAAoB+O,YAAAA,CAAa,IAAM7L,SAAAA,CAAUlD,KAAAA,CAAAA,CAAAA;AAChE6F,QAAAA,QAAAA,EAAU,CAAI7F,KAAAA,EAAiBT,IAAAA,GAAkBwP,YAAAA,CAAa,IAAMlJ,SAAS7F,KAAAA,EAAOT,IAAAA,CAAAA,CAAAA;AACpFoG,QAAAA,WAAAA,EAAa,CAAI3F,KAAAA,GAAoB+O,YAAAA,CAAa,IAAMpJ,WAAAA,CAAY3F,KAAAA,CAAAA,CAAAA;QACpE+O,YAAAA,EAAcA;AAChB,KAAA;AACF,CAAA,EAAG,UAAA;;MCzIUC,KAAAA,GAAQ;AACnB;;AAEC,MACDC,SAAAA,EAAW,WAAA;AAEX;;;;AAIC,MACDC,UAAAA,EAAY,YAAA;AAEZ;;;;;AAKC,MACDC,SAAAA,EAAW;AACb;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/errors.ts","../../src/hookRegistry.ts","../../src/utils/keyedStack.ts","../../src/utils/weakRefMap.ts","../../src/injectionContext.ts","../../src/injectAll.ts","../../src/inject.ts","../../src/injectBy.ts","../../src/tokenRef.ts","../../src/metadata.ts","../../src/optionalAll.ts","../../src/optional.ts","../../src/optionalBy.ts","../../src/provider.ts","../../src/decorators/utils.ts","../../src/token.ts","../../src/utils/typeName.ts","../../src/tokenRegistry.ts","../../src/utils/disposable.ts","../../src/containerImpl.ts","../../src/container.ts","../../src/decorators/autoRegister.ts","../../src/decorators/eagerInstantiate.ts","../../src/decorators/inject.ts","../../src/decorators/injectable.ts","../../src/decorators/injectAll.ts","../../src/decorators/named.ts","../../src/decorators/optional.ts","../../src/decorators/optionalAll.ts","../../src/decorators/scoped.ts","../../src/injector.ts","../../src/scope.ts"],"sourcesContent":["import type { Constructor, Token } from \"./token\";\nimport type { MethodDependency } from \"./tokenRegistry\";\n\n// @internal\nexport type TokenInfo = [Token<any>?, (string | undefined)?];\n\n// @internal\nexport function check(condition: false, message: string): never;\nexport function check(condition: unknown, message: string | (() => string)): asserts condition;\nexport function check(condition: unknown, message: string | (() => string)): asserts condition {\n if (!condition) {\n throw new Error(tag(typeof message === \"string\" ? message : message()));\n }\n}\n\n// @internal\nexport function throwUnregisteredError(tokenInfo: TokenInfo): never {\n throw new Error(tag(`unregistered token ${getFullTokenName(tokenInfo)}`));\n}\n\n// @internal\nexport function throwTargetUnregisteredError(tokenInfo: TokenInfo, aliases: TokenInfo[]): never {\n const path = aliases.length > 0 ? ` (alias for ${getTokenPath(aliases)})` : \"\";\n const desc = getFullTokenName(tokenInfo) + path;\n const cause = `\\n [cause] useExisting points to unregistered token ${getFullTokenName(aliases.at(-1)!)}`;\n throw new Error(tag(`failed to resolve token ${desc}`) + cause);\n}\n\n// @internal\nexport function throwCircularAliasError(aliases: TokenInfo[]): never {\n const path = getTokenPath(aliases);\n throw new Error(tag(`circular alias detected while resolving ${path}`));\n}\n\n// @internal\nexport function throwResolutionError(tokenInfo: TokenInfo, aliases: TokenInfo[], cause: any): never {\n const path = aliases.length > 0 ? ` (alias for ${getTokenPath(aliases)})` : \"\";\n const desc = getFullTokenName(tokenInfo) + path;\n throw new Error(tag(`failed to resolve token ${desc}`) + getCause(cause), { cause });\n}\n\n// @internal\nexport function throwParameterResolutionError(\n ctor: Constructor<object>,\n methodKey: string | symbol | undefined,\n dependency: MethodDependency,\n cause: any,\n): never {\n const location = getLocation(ctor, methodKey);\n const tokenName = getFullTokenName([dependency.tokenRef!.getRefToken(), dependency.name]);\n const msg = tag(`failed to resolve dependency for ${location}(parameter #${dependency.index}: ${tokenName})`);\n throw new Error(msg + getCause(cause), { cause });\n}\n\n// @internal\nexport function getLocation(ctor: Constructor<object>, methodKey?: string | symbol): string {\n const ctorName = ctor.name || \"<unnamed>\";\n return methodKey ? `${ctorName}.${String(methodKey)}` : ctorName;\n}\n\n// @internal\nexport function getTokenPath(tokens: TokenInfo[]): string {\n return tokens.map(getFullTokenName).join(\" \\u2192 \");\n}\n\n// @internal\nexport function getTokenName(token: Token<any>): string {\n return token.name || \"<unnamed>\";\n}\n\nfunction getFullTokenName([token, name]: TokenInfo): string {\n const tokenName = token ? token.name || \"<unnamed>\" : \"<undefined token>\";\n return name !== undefined ? `${tokenName}[\"${name}\"]` : tokenName;\n}\n\nfunction getCause(error: any): string {\n if (!error) {\n return \"\";\n }\n\n const msg = isError(error) ? error.message : String(error);\n return `\\n [cause] ${untag(msg)}`;\n}\n\nfunction isError(value: any): value is Error {\n return value?.stack && typeof value?.message === \"string\";\n}\n\nfunction tag(message: string): string {\n return `[di-wise-neo] ${message}`;\n}\n\nfunction untag(message: string): string {\n return message.startsWith(\"[di-wise-neo]\") ? message.substring(13).trimStart() : message;\n}\n","import type { ContainerHook } from \"./container\";\n\n// @internal\nexport class HookRegistry {\n private readonly myHooks: Set<ContainerHook>;\n\n constructor(parent?: HookRegistry) {\n this.myHooks = new Set(parent?.myHooks);\n }\n\n clear(): void {\n this.myHooks.clear();\n }\n\n get(): Set<ContainerHook> {\n return this.myHooks;\n }\n\n add(hook: ContainerHook): void {\n this.myHooks.add(hook);\n }\n\n delete(hook: ContainerHook): void {\n this.myHooks.delete(hook);\n }\n}\n","import { check } from \"../errors\";\n\n// @internal\nexport class KeyedStack<K extends object, V> {\n private readonly myEntries: { key: K; value: V }[] = [];\n private readonly myKeys = new WeakSet<K>();\n\n has(key: K): boolean {\n return this.myKeys.has(key);\n }\n\n peek(): V | undefined {\n return this.myEntries.at(-1)?.value;\n }\n\n push(key: K, value: V): () => void {\n check(!this.has(key), \"internal: invariant violation\");\n this.myKeys.add(key);\n this.myEntries.push({ key, value });\n return () => {\n this.myEntries.pop();\n this.myKeys.delete(key);\n };\n }\n}\n","import { check } from \"../errors\";\n\n// @internal\nexport class WeakRefMap<K extends WeakKey, V extends object> {\n private readonly myMap = new WeakMap<K, WeakRef<V>>();\n\n get(key: K): V | undefined {\n const ref = this.myMap.get(key);\n\n if (ref) {\n const value = ref.deref();\n\n if (value) {\n return value;\n }\n\n this.myMap.delete(key);\n }\n\n return undefined;\n }\n\n set(key: K, value: V): () => void {\n check(!this.get(key), \"internal: invariant violation\");\n this.myMap.set(key, new WeakRef(value));\n return () => {\n this.myMap.delete(key);\n };\n }\n}\n","import type { Container } from \"./container\";\nimport { check } from \"./errors\";\nimport type { Provider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport type { Token } from \"./token\";\nimport { KeyedStack } from \"./utils/keyedStack\";\nimport { WeakRefMap } from \"./utils/weakRefMap\";\nimport type { ValueRef } from \"./valueRef\";\n\n// @internal\nexport interface ResolutionFrame {\n readonly scope: Scope;\n readonly provider: Provider<any>;\n}\n\n// @internal\nexport interface Resolution {\n readonly tokens: Token<any>[];\n readonly stack: KeyedStack<Provider<any>, ResolutionFrame>;\n readonly values: WeakRefMap<Provider<any>, ValueRef<any>>;\n readonly dependents: WeakRefMap<Provider<any>, ValueRef<any>>;\n}\n\n// @internal\nexport interface InjectionContext {\n readonly container: Container;\n readonly resolution: Resolution;\n}\n\n// @internal\nexport function createResolution(): Resolution {\n return {\n tokens: [],\n stack: new KeyedStack(),\n values: new WeakRefMap(),\n dependents: new WeakRefMap(),\n };\n}\n\n// @internal\nexport const [provideInjectionContext, useInjectionContext] = createInjectionContext<InjectionContext>();\n\n// @internal\nexport function ensureInjectionContext(name: string): InjectionContext {\n const context = useInjectionContext();\n check(context, `${name} can only be invoked within an injection context`);\n return context;\n}\n\n/**\n * Asserts that the current stack frame is within an injection context,\n * meaning it has access to injection functions (`inject`, `optional`, etc.).\n *\n * @param fn - The function performing the assertion, or a string name used in the error message.\n * @throws {Error} If the current stack frame is not within an injection context.\n */\nexport function assertInjectionContext(fn: Function | string): void {\n const name = typeof fn === \"function\" ? `${fn.name || \"<unnamed>\"}()` : fn;\n ensureInjectionContext(name);\n}\n\nfunction createInjectionContext<T extends {}>(): readonly [(next: T) => () => T | null, () => T | null] {\n let current: T | null = null;\n\n function provide(next: T): () => T | null {\n const prev = current;\n current = next;\n return () => (current = prev);\n }\n\n function use(): T | null {\n return current;\n }\n\n return [provide, use] as const;\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects all instances provided by the registrations associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function injectAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n/**\n * Injects all values provided by the registrations associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function injectAll<Value>(token: Token<Value>): Value[];\n\nexport function injectAll<T>(token: Token<T>): T[] {\n const context = ensureInjectionContext(\"injectAll()\");\n return context.container.resolveAll(token);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected. Use {@link injectBy} if resolving\n * circular dependencies is necessary.\n */\nexport function inject<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n/**\n * Injects the value associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected. Use {@link injectBy} if resolving\n * circular dependencies is necessary.\n */\nexport function inject<Value>(token: Token<Value>, name?: string): Value;\n\nexport function inject<T>(token: Token<T>, name?: string): T {\n const context = ensureInjectionContext(\"inject()\");\n return context.container.resolve(token, name);\n}\n","import { inject } from \"./inject\";\nimport { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n *\n * Compared to {@link inject}, `injectBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wand {\n * owner = inject(Wizard);\n * }\n *\n * class Wizard {\n * wand = injectBy(this, Wand);\n * }\n * ```\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param Class - The class to resolve.\n * @param name - The name qualifier of the class to resolve.\n */\nexport function injectBy<Instance extends object>(thisArg: any, Class: Constructor<Instance>, name?: string): Instance;\n\n/**\n * Injects the value associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n *\n * Compared to {@link inject}, `injectBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wand {\n * owner = inject(Wizard);\n * }\n *\n * class Wizard {\n * wand = injectBy(this, Wand);\n * }\n * ```\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param token - The token to resolve.\n * @param name - The name qualifier of the token to resolve.\n */\nexport function injectBy<Value>(thisArg: any, token: Token<Value>, name?: string): Value;\n\nexport function injectBy<T>(thisArg: any, token: Token<T>, name?: string): T {\n const context = ensureInjectionContext(\"injectBy()\");\n const resolution = context.resolution;\n const currentFrame = resolution.stack.peek();\n\n if (!currentFrame) {\n return inject(token, name);\n }\n\n const cleanup = resolution.dependents.set(currentFrame.provider, { current: thisArg });\n\n try {\n return inject(token, name);\n } finally {\n cleanup();\n }\n}\n","import { check } from \"./errors\";\nimport type { Constructor, Token, Tokens } from \"./token\";\n\nexport interface ClassRef<Instance extends object> {\n readonly getRefClass: () => Constructor<Instance>;\n}\n\nexport interface TokenRef<Value> {\n readonly getRefToken: () => Token<Value>;\n\n /**\n * @internal\n */\n readonly getRefTokens: () => Set<Token<Value>>;\n}\n\n/**\n * Allows referencing a class declared later in the file by wrapping it\n * into a lazily evaluated function.\n */\n// @__NO_SIDE_EFFECTS__\nexport function classRef<Instance extends object>(Class: () => Constructor<Instance>): ClassRef<Instance> {\n return {\n getRefClass: () => Class(),\n };\n}\n\n/**\n * Allows referencing a token declared later in the file by wrapping it\n * into a lazily evaluated function.\n */\nexport function tokenRef<Value>(token: () => Token<Value>): TokenRef<Value>;\n\n// @internal\nexport function tokenRef<Value>(token: () => Tokens<Value>): TokenRef<Value>;\n\n// @__NO_SIDE_EFFECTS__\nexport function tokenRef<Value>(token: () => Token<Value> | Tokens<Value>): TokenRef<Value> {\n return {\n getRefToken: () => {\n const tokenOrTokens = token();\n check(!Array.isArray(tokenOrTokens), \"internal: unexpected array of tokens\");\n return tokenOrTokens;\n },\n getRefTokens: () => {\n // Normalize the single token here so that we don't have to do it at every getRefTokens call site\n const tokenOrTokens = token();\n const tokensArray = Array.isArray(tokenOrTokens) ? tokenOrTokens : [tokenOrTokens];\n return new Set(tokensArray);\n },\n };\n}\n\n// @internal\nexport function isClassRef<T extends object>(value: any): value is ClassRef<T> {\n return value != null && typeof value === \"object\" && typeof value.getRefClass === \"function\";\n}\n\n// @internal\nexport function isTokenRef<T>(value: any): value is TokenRef<T> {\n return value != null && typeof value === \"object\" && typeof value.getRefToken === \"function\";\n}\n","import { check } from \"./errors\";\nimport type { Scope } from \"./scope\";\nimport type { Constructor } from \"./token\";\nimport { type ClassRef, isClassRef, type TokenRef } from \"./tokenRef\";\nimport type { ConstructorProvider, Dependencies, MethodDependency } from \"./tokenRegistry\";\nimport type { Writable } from \"./utils/writable\";\n\n// @internal\nexport type ScopeDecorator = \"Scoped\" | \"TransientScoped\" | \"ResolutionScoped\" | \"ContainerScoped\";\n\n// @internal\nexport interface ScopeMetadata {\n readonly value: Scope;\n readonly appliedBy: ScopeDecorator | \"EagerInstantiate\";\n}\n\n// @internal\nexport class Metadata<This extends object> {\n readonly provider: Writable<ConstructorProvider<This>>;\n readonly dependencies: Dependencies = {\n ctor: [],\n methods: new Map(),\n };\n\n eagerInstantiate?: boolean | undefined;\n autoRegister?: boolean | undefined;\n scope?: ScopeMetadata;\n tokenRef: TokenRef<This> = {\n getRefToken: () => check(false, \"internal: unexpected getRefToken call\"),\n getRefTokens: () => new Set(),\n };\n\n constructor(Class: Constructor<This>) {\n this.provider = {\n useClass: Class,\n };\n }\n\n get name(): string | undefined {\n return this.provider.name;\n }\n\n set name(name: string) {\n this.provider.name = name;\n }\n\n getCtorDependency(index: number): MethodDependency {\n const i = this.dependencies.ctor.findIndex((d) => d.index === index);\n\n if (i > -1) {\n return this.dependencies.ctor[i]!;\n }\n\n const dependency: MethodDependency = {\n index: index,\n };\n\n this.dependencies.ctor.push(dependency);\n return dependency;\n }\n\n getMethodDependency(method: string | symbol, index: number): MethodDependency {\n let methodDeps = this.dependencies.methods.get(method);\n\n if (!methodDeps) {\n this.dependencies.methods.set(method, (methodDeps = []));\n }\n\n const i = methodDeps.findIndex((d) => d.index === index);\n\n if (i > -1) {\n return methodDeps[i]!;\n }\n\n const dependency: MethodDependency = {\n index: index,\n };\n\n methodDeps.push(dependency);\n return dependency;\n }\n}\n\n// @internal\nexport function getMetadata<T extends object>(classOrRef: Constructor<T> | ClassRef<T>): Metadata<T> {\n const Class = isClassRef(classOrRef) ? classOrRef.getRefClass() : classOrRef;\n const originalClass = classIdentityMap.get(Class) ?? Class;\n let metadata = metadataMap.get(originalClass);\n\n if (!metadata) {\n metadataMap.set(originalClass, (metadata = new Metadata(originalClass)));\n }\n\n if (metadata.provider.useClass !== Class) {\n // This is part of the class identity mapping API (see setClassIdentityMapping).\n //\n // Scenario:\n // 1. Metadata is created for class A (the original class) because of a parameter decorator.\n // 2. Later, because of a class decorator that extends the decorated class, a third-party\n // registers a class identity mapping from class B to class A, where B is the class\n // generated from the class decorator by extending A.\n //\n // We must update useClass to be the extender class B so that instances created by the\n // DI container match the consumer's registered class. Without this update, the DI\n // system would instantiate the original class A, causing behavior inconsistencies.\n metadata.provider.useClass = Class;\n }\n\n return metadata;\n}\n\n/**\n * Registers a mapping between a generated (e.g., decorated or proxied) constructor\n * and its original, underlying constructor.\n *\n * This allows libraries or consumers that manipulate constructors, such as through\n * class decorators, to inform the DI system about the real \"identity\" of a class.\n *\n * **IMPORTANT**:\n * this API affects the core class identity resolution mechanism of the DI system.\n * Incorrect usage may cause metadata to be misassociated, leading to subtle errors.\n * Use only when manipulating constructors (e.g., via decorators or proxies),\n * and ensure the mapping is correct.\n *\n * @param transformedClass - The constructor function returned by a class decorator or factory.\n * @param originalClass - The original constructor function.\n */\nexport function setClassIdentityMapping<T extends object>(transformedClass: Constructor<T>, originalClass: Constructor<T>): void {\n classIdentityMap.set(transformedClass, originalClass);\n}\n\nconst classIdentityMap = new WeakMap<Constructor<object>, Constructor<object>>();\nconst metadataMap = new WeakMap<Constructor<object>, Metadata<any>>();\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects all instances provided by the registrations associated with the given class\n * or an empty array if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n/**\n * Injects all values provided by the registrations associated with the given token\n * or an empty array if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function optionalAll<Value>(token: Token<Value>): Value[];\n\nexport function optionalAll<T>(token: Token<T>): T[] {\n const context = ensureInjectionContext(\"optionalAll()\");\n return context.container.tryResolveAll(token);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n * Use {@link optionalBy} when you need to resolve circular dependencies.\n */\nexport function optional<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n/**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected.\n * Use {@link optionalBy} when you need to resolve circular dependencies.\n */\nexport function optional<Value>(token: Token<Value>, name?: string): Value | undefined;\n\nexport function optional<T>(token: Token<T>, name?: string): T | undefined {\n const context = ensureInjectionContext(\"optional()\");\n return context.container.tryResolve(token, name);\n}\n","import { ensureInjectionContext } from \"./injectionContext\";\nimport { optional } from \"./optional\";\nimport type { Constructor, Token } from \"./token\";\n\n/**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param Class - The class to resolve.\n * @param name - The name qualifier of the class to resolve.\n */\nexport function optionalBy<Instance extends object>(\n thisArg: any,\n Class: Constructor<Instance>,\n name?: string,\n): Instance | undefined;\n\n/**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Compared to {@link optional}, `optionalBy` accepts a `thisArg` argument\n * (e.g., the containing class instance) which is used to resolve circular dependencies.\n *\n * @param thisArg - The containing instance, used to help resolve circular dependencies.\n * @param token - The token to resolve.\n * @param name - The name qualifier of the token to resolve.\n */\nexport function optionalBy<Value>(thisArg: any, token: Token<Value>, name?: string): Value | undefined;\n\nexport function optionalBy<T>(thisArg: any, token: Token<T>, name?: string): T | undefined {\n const context = ensureInjectionContext(\"optionalBy()\");\n const resolution = context.resolution;\n const currentFrame = resolution.stack.peek();\n\n if (!currentFrame) {\n return optional(token, name);\n }\n\n const cleanup = resolution.dependents.set(currentFrame.provider, { current: thisArg });\n\n try {\n return optional(token, name);\n } finally {\n cleanup();\n }\n}\n","import type { Constructor, Token } from \"./token\";\nimport type { ClassRef } from \"./tokenRef\";\n\n/**\n * Provides a class instance for a token via a class constructor.\n */\nexport interface ClassProvider<Instance extends object> {\n /**\n * The class to instantiate for the token.\n */\n readonly useClass: Constructor<Instance> | ClassRef<Instance>;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Equivalent to decorating the class with `@Named(...)`.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Provides a value for a token via a factory function.\n */\nexport interface FactoryProvider<Value> {\n /**\n * A function that produces the value at resolution time.\n *\n * The function runs inside the injection context and can\n * access dependencies via {@link inject}-like helpers.\n */\n readonly useFactory: (...args: []) => Value;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Provides a static - already constructed - value for a token.\n */\nexport interface ValueProvider<Value> {\n /**\n * The static value to associate with the token.\n */\n readonly useValue: Value;\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * Aliases another registered token.\n *\n * Resolving this token will return the value of the aliased one.\n */\nexport interface ExistingProvider<Value> {\n /**\n * The existing token to alias, with an optional name qualifier.\n *\n * Example:\n * ```ts\n * container.register(ISecretStorage, {\n * useExisting: PersistentSecretStorage,\n * });\n *\n * // Or in case we need to alias a name-qualified token\n * container.register(ISecretStorage, {\n * useExisting: [PersistentSecretStorage, \"fileSystem\"],\n * });\n * ```\n */\n readonly useExisting: Token<Value> | [Token<Value>, (string | undefined)?];\n\n /**\n * An optional name to qualify this provider.\n * If specified, the token must be resolved using the same name.\n *\n * Example:\n * ```ts\n * export class ExtensionContext {\n * // Decorator-based injection\n * constructor(@Inject(ISecretStorage) @Named(\"persistent\") secretStorage: SecretStorage) {}\n *\n * // Function-based injection\n * constructor(secretStorage = inject(ISecretStorage, \"persistent\")) {}\n * }\n * ```\n */\n readonly name?: string | undefined;\n}\n\n/**\n * A token provider.\n */\nexport type Provider<Value> =\n | ClassProvider<Value & object>\n | FactoryProvider<Value>\n | ValueProvider<Value>\n | ExistingProvider<Value>;\n\n// @internal\nexport function isClassProvider<T>(provider: Provider<T>): provider is ClassProvider<T & object> {\n return \"useClass\" in provider;\n}\n\n// @internal\nexport function isFactoryProvider<T>(provider: Provider<T>): provider is FactoryProvider<T> {\n return \"useFactory\" in provider;\n}\n\n// @internal\nexport function isValueProvider<T>(provider: Provider<T>): provider is ValueProvider<T> {\n return \"useValue\" in provider;\n}\n\n// @internal\nexport function isExistingProvider<T>(provider: Provider<T>): provider is ExistingProvider<T> {\n return \"useExisting\" in provider;\n}\n","import { check } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { Constructor } from \"../token\";\nimport type { MethodDependency } from \"../tokenRegistry\";\n\n// @internal\nexport function updateParameterMetadata(\n decorator: string,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n updateFn: (dependency: MethodDependency) => void,\n): void {\n // Error out immediately if the decorator has been applied to a static method\n if (methodKey !== undefined && typeof target === \"function\") {\n check(false, `@${decorator} cannot be used on static method ${target.name}.${String(methodKey)}`);\n }\n\n if (methodKey === undefined) {\n // Constructor\n const metadata = getMetadata(target as Constructor<object>);\n const dependency = metadata.getCtorDependency(parameterIndex);\n updateFn(dependency);\n } else {\n // Instance method\n const metadata = getMetadata(target.constructor as Constructor<object>);\n const dependency = metadata.getMethodDependency(methodKey, parameterIndex);\n updateFn(dependency);\n }\n}\n\n// Checks that a constructor or method parameter has only one injection decorator.\n// For example, if both `@Inject` and `@Optional` are used, it becomes difficult to\n// understand which one \"wins\", unless the user is aware of the decorator evaluation order.\n//\n// @internal\nexport function checkSingleDecorator(\n dependency: MethodDependency,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n): void {\n check(dependency.appliedBy === undefined, () => {\n const param = describeParam(target, methodKey, parameterIndex);\n return `multiple injection decorators on ${param}, but only one is allowed`;\n });\n}\n\n// Checks that the `@Named` decorator is not used in combination with\n// `@InjectAll` or `@OptionalAll`, which ignore the name qualification.\n//\n// @internal\nexport function checkNamedDecorator(\n dependency: MethodDependency,\n target: object,\n methodKey: string | symbol | undefined,\n parameterIndex: number,\n): void {\n const { appliedBy, name } = dependency;\n check(name === undefined || (appliedBy !== \"InjectAll\" && appliedBy !== \"OptionalAll\"), () => {\n const param = describeParam(target, methodKey, parameterIndex);\n return `@Named has no effect on ${param} when used with @${appliedBy}`;\n });\n}\n\n// Returns a human-readable description of the parameter location.\n// For example: \"Wizard constructor parameter 2\" or \"Wizard.set parameter 0\"\n//\n// @internal\nexport function describeParam(target: object, methodKey: string | symbol | undefined, parameterIndex: number): string {\n const location =\n methodKey === undefined //\n ? (target as Constructor<object>).name\n : `${target.constructor.name}.${String(methodKey)}`;\n return `${location}(parameter #${parameterIndex})`;\n}\n","import type { ParameterDecorator } from \"./decorators/decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./decorators/utils\";\nimport type { Provider } from \"./provider\";\nimport { tokenRef } from \"./tokenRef\";\nimport type { RegistrationOptions } from \"./tokenRegistry\";\nimport type { Writable } from \"./utils/writable\";\n\n/**\n * An injectable type `T`.\n */\nexport interface Type<T> extends ParameterDecorator {\n /**\n * The name of the type.\n */\n readonly name: string;\n\n /**\n * Ensures that different `Type<T>` types are not structurally compatible.\n *\n * This property is always `undefined` and is never used at runtime.\n *\n * @private\n */\n readonly __type: T | undefined;\n\n /**\n * Returns the type's {@link Type.name|name}.\n */\n readonly toString: () => string;\n}\n\n/**\n * An injectable type `T` with a default {@link Provider} and optional default registration options.\n */\nexport interface ProviderType<T> extends Type<T> {\n /**\n * The type's default provider.\n */\n readonly provider: Provider<T>;\n\n /**\n * The type's default registration options.\n */\n readonly options?: RegistrationOptions | undefined;\n}\n\n/**\n * Constructor type.\n */\nexport interface Constructor<Instance extends object> {\n new (...args: any[]): Instance;\n readonly name: string;\n}\n\n/**\n * Token type.\n */\nexport type Token<Value> = [Value] extends [object] // Avoids distributive union behavior\n ? Type<Value> | Constructor<Value & object>\n : Type<Value>;\n\n/**\n * Describes a {@link Token} array with at least one element.\n */\nexport type Tokens<Value> = [Token<Value>, ...Token<Value>[]];\n\n/**\n * Creates a type token.\n *\n * Example:\n * ```ts\n * const ISpell = createType<Spell>(\"Spell\");\n * container.register(ISpell, {\n * useFactory: () => getDefaultSpell(),\n * });\n * ```\n */\nexport function createType<T>(typeName: string): Type<T>;\n\n/**\n * Creates a type token with a default {@link Provider} and optional default registration options.\n *\n * Example:\n * ```ts\n * // Notice how we pass in a Provider directly at type creation site\n * const ISpell = createType<Spell>(\"Spell\", {\n * useFactory: () => getDefaultSpell(),\n * });\n *\n * container.register(ISpell);\n * ```\n */\nexport function createType<T>(typeName: string, provider: Provider<T>, options?: RegistrationOptions): ProviderType<T>;\n\n// @__NO_SIDE_EFFECTS__\nexport function createType<T>(\n typeName: string,\n provider?: Provider<T>,\n options?: RegistrationOptions,\n): Type<T> | ProviderType<T> {\n const name = `Type<${typeName}>`;\n const type = ((target, propertyKey, parameterIndex): void => {\n updateParameterMetadata(name, target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Inject\";\n dependency.tokenRef = tokenRef(() => type as Type<T>);\n });\n }) as ParameterDecorator & Writable<ProviderType<T>>;\n\n Object.defineProperty(type, \"name\", { value: name });\n\n if (provider) {\n type.provider = provider;\n type.options = options;\n }\n\n type.__type = undefined;\n type.toString = () => name;\n return type;\n}\n\n// @internal\nexport function isConstructor<T>(token: Type<T> | Constructor<T & object>): token is Constructor<T & object> {\n return !(\"__type\" in token);\n}\n","// @internal\nexport function getTypeName(value: unknown): string {\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (typeof value) {\n case \"string\":\n return `\"${value}\"`;\n case \"function\":\n return (value.name && `typeof ${value.name}`) || \"Function\";\n case \"object\": {\n if (value === null) {\n return \"null\";\n }\n\n const proto: object | null = Object.getPrototypeOf(value);\n\n if (proto && proto !== Object.prototype) {\n const ctor: unknown = proto.constructor;\n\n if (typeof ctor === \"function\" && ctor.name) {\n return ctor.name;\n }\n }\n }\n }\n\n return typeof value;\n}\n","import { check, getTokenName } from \"./errors\";\nimport type { ExistingProvider, FactoryProvider, Provider, ValueProvider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport { type Constructor, createType, type Token, type Type } from \"./token\";\nimport type { TokenRef } from \"./tokenRef\";\nimport { getTypeName } from \"./utils/typeName\";\nimport type { ValueRef } from \"./valueRef\";\n\n// @internal\nexport interface ConstructorProvider<Instance extends object> {\n readonly useClass: Constructor<Instance>;\n readonly name?: string;\n}\n\n// @internal\nexport type RegistrationProvider<Value> =\n | ConstructorProvider<Value & object>\n | FactoryProvider<Value>\n | ValueProvider<Value>\n | ExistingProvider<Value>;\n\n/**\n * Token registration options.\n */\nexport interface RegistrationOptions {\n /**\n * The scope of the registration.\n */\n readonly scope?: Scope | undefined;\n}\n\n// @internal\nexport type InjectDecorator = \"Inject\" | \"InjectAll\" | \"Optional\" | \"OptionalAll\";\n\n// @internal\nexport interface MethodDependency {\n // The index of the annotated parameter (zero-based)\n readonly index: number;\n\n appliedBy?: InjectDecorator;\n tokenRef?: TokenRef<any>;\n name?: string;\n}\n\n// @internal\nexport interface Dependencies {\n readonly ctor: MethodDependency[];\n readonly methods: Map<string | symbol, MethodDependency[]>;\n}\n\n// @internal\nexport interface Registration<T> {\n readonly provider: RegistrationProvider<T>;\n readonly name?: string | undefined;\n readonly options?: RegistrationOptions | undefined;\n readonly dependencies?: Dependencies;\n\n valueRef?: ValueRef<T> | undefined;\n}\n\n// @internal\nexport class TokenRegistry {\n private readonly myParent: TokenRegistry | undefined;\n private readonly myRegistrations = new Map<Token<any>, Registration<any>[]>();\n\n constructor(parent?: TokenRegistry) {\n this.myParent = parent;\n }\n\n get<T extends object>(token: Constructor<T>, name?: string): Registration<T> | undefined;\n get<T>(token: Token<T>, name?: string): Registration<T> | undefined;\n get<T>(token: Token<T>, name?: string): Registration<T> | undefined {\n // To clarify, at(-1) means we take the last added registration for this token\n return this.getAll(token, name).at(-1);\n }\n\n getAll<T>(token: Token<T>, name?: string): Registration<T>[] {\n // Internal registrations cannot have a name\n const internal = name !== undefined ? undefined : internals.get(token);\n return (internal && [internal]) || this.getAllFromParent(token, name);\n }\n\n put<T>(token: Token<T>, registration: Registration<T>): void;\n put<T extends object>(token: Type<T> | Constructor<T>, registration: Registration<T>): void;\n put<T>(token: Token<T>, registration: Registration<T>): void {\n check(!internals.has(token), `internal: cannot register reserved token ${token.name}`);\n let registrations = this.myRegistrations.get(token);\n\n if (registrations) {\n const name = registration.name;\n\n if (name !== undefined) {\n const existing = registrations.filter((r) => r.name === name);\n check(existing.length === 0, `token ${getTokenName(token)} with name '${name}' is already registered`);\n }\n } else {\n this.myRegistrations.set(token, (registrations = []));\n }\n\n registrations.push(registration);\n }\n\n delete<T>(token: Token<T>, name?: string): Registration<T>[] {\n const registrations = this.myRegistrations.get(token);\n\n if (!registrations) {\n return [];\n }\n\n if (name !== undefined) {\n const removed: Registration<T>[] = [];\n const updated: Registration<T>[] = [];\n\n for (const registration of registrations) {\n (registration.name === name ? removed : updated).push(registration);\n }\n\n if (removed.length > 0) {\n this.myRegistrations.set(token, updated);\n return removed;\n }\n }\n\n this.myRegistrations.delete(token);\n return registrations;\n }\n\n deleteAll(): [Token<any>[], Registration<any>[]] {\n const tokens = [...this.myRegistrations.keys()];\n const registrations = [...this.myRegistrations.values()].flat();\n this.myRegistrations.clear();\n return [tokens, registrations];\n }\n\n clearCache(): unknown[] {\n const values = new Set<unknown>();\n\n for (const registrations of this.myRegistrations.values()) {\n for (const registration of registrations) {\n const valueRef = registration.valueRef;\n\n if (valueRef) {\n values.add(valueRef.current);\n }\n\n registration.valueRef = undefined;\n }\n }\n\n return [...values];\n }\n\n private getAllFromParent<T>(token: Token<T>, name?: string): Registration<T>[] {\n let registrations = this.myRegistrations.get(token) || this.myParent?.getAllFromParent(token, name);\n\n if (registrations && name !== undefined) {\n registrations = registrations.filter((r) => r.name === name);\n check(registrations.length < 2, `internal: multiple registrations with name '${name}'`);\n }\n\n return registrations ?? [];\n }\n}\n\n// @internal\nexport function isBuilder(provider: Provider<any>): boolean {\n return builders.has(provider);\n}\n\n/**\n * Create a one-off type token from a factory function.\n *\n * Example:\n * ```ts\n * class Wizard {\n * wand = inject(\n * build(() => {\n * const wand = inject(Wand);\n * wand.owner = this;\n * // ...\n * return wand;\n * }),\n * );\n * }\n * ```\n */\nexport function build<Value>(factory: (...args: []) => Value): Type<Value>;\n\n// @internal\nexport function build<Value>(factory: (...args: []) => Value, name: string): Type<Value>;\n\n// @__NO_SIDE_EFFECTS__\nexport function build<Value>(factory: (...args: []) => Value, name?: string): Type<Value> {\n const token = createType<Value>(name ?? `Build<${getTypeName(factory)}>`);\n const provider: FactoryProvider<Value> = {\n useFactory: factory,\n };\n\n internals.set(token, {\n provider: provider,\n options: {\n scope: \"Transient\",\n },\n });\n\n builders.add(provider);\n return token;\n}\n\nconst internals = new WeakMap<Token<any>, Registration<any>>();\nconst builders = new WeakSet<Provider<any>>();\n","// @internal\nexport interface Disposable {\n dispose(): void | PromiseLike<void>;\n}\n\n// @internal\nexport function isDisposable(value: any): value is Disposable {\n return value != null && typeof value === \"object\" && typeof value.dispose === \"function\";\n}\n","import type { ChildContainerOptions, Container, ContainerHook, ContainerOptions } from \"./container\";\nimport {\n check,\n getLocation,\n getTokenName,\n getTokenPath,\n throwCircularAliasError,\n throwParameterResolutionError,\n throwResolutionError,\n throwTargetUnregisteredError,\n throwUnregisteredError,\n type TokenInfo,\n} from \"./errors\";\nimport { HookRegistry } from \"./hookRegistry\";\nimport { injectAll } from \"./injectAll\";\nimport { injectBy } from \"./injectBy\";\nimport { createResolution, provideInjectionContext, useInjectionContext } from \"./injectionContext\";\nimport { getMetadata } from \"./metadata\";\nimport { optionalAll } from \"./optionalAll\";\nimport { optionalBy } from \"./optionalBy\";\nimport {\n type ExistingProvider,\n isClassProvider,\n isExistingProvider,\n isFactoryProvider,\n isValueProvider,\n type Provider,\n} from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport { type Constructor, isConstructor, type ProviderType, type Token } from \"./token\";\nimport { isBuilder, type MethodDependency, type Registration, type RegistrationOptions, TokenRegistry } from \"./tokenRegistry\";\nimport { isDisposable } from \"./utils/disposable\";\nimport type { RequiredNonNullable } from \"./utils/requiredNonNullable\";\n\n/**\n * The default implementation of a di-wise-neo {@link Container}.\n */\nexport class ContainerImpl implements Container {\n private readonly myParent: ContainerImpl | undefined;\n private readonly myChildren: Set<ContainerImpl> = new Set();\n private readonly myOptions: RequiredNonNullable<ContainerOptions>;\n private readonly myHookRegistry: HookRegistry;\n private readonly myTokenRegistry: TokenRegistry;\n private myDisposed: boolean = false;\n\n constructor(parent?: ContainerImpl, options?: ChildContainerOptions) {\n this.myParent = parent;\n this.myOptions = {\n defaultScope: options?.defaultScope ?? \"Transient\",\n autoRegister: options?.autoRegister ?? false,\n disposeUnmanaged: options?.disposeUnmanaged ?? false,\n };\n\n const copyHooks = options?.copyHooks ?? true;\n this.myHookRegistry = new HookRegistry(copyHooks ? parent?.myHookRegistry : undefined);\n this.myTokenRegistry = new TokenRegistry(parent?.myTokenRegistry);\n }\n\n get registry(): TokenRegistry {\n return this.myTokenRegistry;\n }\n\n get options(): RequiredNonNullable<ContainerOptions> {\n return {\n ...this.myOptions,\n };\n }\n\n get parent(): Container | undefined {\n return this.myParent;\n }\n\n get isDisposed(): boolean {\n return this.myDisposed;\n }\n\n createChild(options?: Partial<ChildContainerOptions>): Container {\n this.checkDisposed();\n const container = new ContainerImpl(this, {\n defaultScope: options?.defaultScope ?? this.myOptions.defaultScope,\n autoRegister: options?.autoRegister ?? this.myOptions.autoRegister,\n disposeUnmanaged: options?.disposeUnmanaged ?? this.myOptions.disposeUnmanaged,\n copyHooks: options?.copyHooks ?? true,\n });\n\n this.myChildren.add(container);\n return container;\n }\n\n clearCache(): unknown[] {\n this.checkDisposed();\n return this.myTokenRegistry.clearCache();\n }\n\n getCached<T>(token: Token<T>): T | undefined {\n this.checkDisposed();\n const registration = this.myTokenRegistry.get(token);\n return registration?.valueRef?.current;\n }\n\n getAllCached<T>(token: Token<T>): T[] {\n this.checkDisposed();\n const registrations = this.myTokenRegistry.getAll(token);\n const values = new Set<T>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n resetRegistry(): unknown[] {\n this.checkDisposed();\n const [, registrations] = this.myTokenRegistry.deleteAll();\n const values = new Set<unknown>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n isRegistered<T>(token: Token<T>, name?: string): boolean {\n this.checkDisposed();\n return this.myTokenRegistry.get(token, name) !== undefined;\n }\n\n register<T>(\n ...args:\n | [Constructor<T & object> | ProviderType<T>] //\n | [Token<T>, Provider<T>, (RegistrationOptions | undefined)?]\n ): Container {\n this.checkDisposed();\n\n if (args.length === 1) {\n const [token] = args;\n\n if (isConstructor(token)) {\n this.registerClass(token);\n } else {\n this.registerToken(token, token.provider, token.options);\n }\n } else {\n this.registerToken(...args);\n }\n\n return this;\n }\n\n unregister<T>(token: Token<T>, name?: string): T[] {\n this.checkDisposed();\n const registrations = this.myTokenRegistry.delete(token, name);\n const values = new Set<T>();\n\n for (const { valueRef } of registrations) {\n if (valueRef) {\n values.add(valueRef.current);\n }\n }\n\n return [...values];\n }\n\n resolve<T>(token: Token<T>, name?: string): T {\n this.checkDisposed();\n return this.resolveToken(token, name, false);\n }\n\n tryResolve<T>(token: Token<T>, name?: string): T | undefined {\n this.checkDisposed();\n return this.resolveToken(token, name, true);\n }\n\n resolveAll<T>(token: Token<T>): T[] {\n this.checkDisposed();\n return this.resolveAllToken(token, false);\n }\n\n tryResolveAll<T>(token: Token<T>): T[] {\n this.checkDisposed();\n return this.resolveAllToken(token, true);\n }\n\n addHook(hook: ContainerHook): void {\n this.checkDisposed();\n this.myHookRegistry.add(hook);\n }\n\n removeHook(hook: ContainerHook): void {\n this.checkDisposed();\n this.myHookRegistry.delete(hook);\n }\n\n dispose(): Promise<unknown>[] {\n if (this.myDisposed) {\n return [];\n }\n\n this.myDisposed = true;\n const promises: Promise<unknown>[] = [];\n\n // Dispose children containers first\n for (const child of this.myChildren) {\n promises.push(...child.dispose());\n }\n\n this.myChildren.clear();\n this.myParent?.myChildren?.delete(this);\n\n const [, registrations] = this.myTokenRegistry.deleteAll();\n const disposeUnmanaged = this.myOptions.disposeUnmanaged;\n const cacheValues = new Set<unknown>();\n const allValues = new Set<unknown>();\n\n for (const { provider, valueRef } of registrations) {\n if (valueRef) {\n cacheValues.add(valueRef.current);\n allValues.add(valueRef.current);\n } else if (disposeUnmanaged && isValueProvider(provider)) {\n allValues.add(provider.useValue);\n }\n }\n\n for (const value of allValues) {\n if (isDisposable(value)) {\n try {\n promises.push(Promise.resolve(value.dispose()));\n } catch (e) {\n promises.push(Promise.reject(e));\n }\n }\n }\n\n this.notifyDisposeHooks([...cacheValues]);\n this.myHookRegistry.clear();\n return promises;\n }\n\n private registerClass<T extends object>(Class: Constructor<T>): void {\n const metadata = getMetadata(Class);\n const name = metadata.name;\n const registration: Registration<T> = {\n name: name,\n // The provider is of type ClassProvider, initialized by getMetadata\n provider: metadata.provider,\n options: {\n scope: metadata.scope?.value ?? this.myOptions.defaultScope,\n },\n dependencies: metadata.dependencies,\n };\n\n // Register the class itself\n this.myTokenRegistry.put(Class, registration);\n\n // Register the additional tokens specified via class decorators.\n // These tokens will point to the original Class token and will have the same scope.\n for (const token of metadata.tokenRef.getRefTokens()) {\n this.myTokenRegistry.put(token, {\n name: name,\n provider: {\n useExisting: [Class, name],\n },\n });\n }\n\n // Eager-instantiate only if the class is container-scoped.\n // Note that we are comparing the scope using the registration configured just above,\n // which takes into account both the metadata and the container option as a fallback.\n if (metadata.eagerInstantiate && registration.options?.scope === \"Container\") {\n this.resolveProviderValue(Class, registration);\n }\n }\n\n private registerToken<T>(token: Token<T>, provider: Provider<T>, options?: RegistrationOptions): void {\n const name = provider.name;\n check(name === undefined || name.trim(), `name qualifier for token ${getTokenName(token)} must not be empty`);\n\n if (isClassProvider(provider)) {\n const metadata = getMetadata(provider.useClass);\n const registration: Registration<T> = {\n // An explicit provider name overrides what is specified via @Named\n name: metadata.name ?? name,\n provider: metadata.provider,\n options: {\n // Explicit registration options override what is specified via class decorators (e.g., @Scoped)\n scope: metadata.scope?.value ?? this.myOptions.defaultScope,\n ...options,\n },\n dependencies: metadata.dependencies,\n };\n\n this.myTokenRegistry.put(token, registration);\n\n // Eager-instantiate only if the provided class is container-scoped.\n // Note that we are comparing the scope using the registration configured just above,\n // which takes into account both the metadata and the container option as a fallback.\n if (metadata.eagerInstantiate && registration.options?.scope === \"Container\") {\n this.resolveProviderValue(token, registration);\n }\n } else {\n if (isExistingProvider(provider)) {\n const [targetToken] = this.getTargetToken(provider);\n check(token !== targetToken, `token ${getTokenName(token)} cannot alias itself via useExisting`);\n }\n\n this.myTokenRegistry.put(token, {\n name: name,\n provider: provider,\n options: options,\n });\n }\n }\n\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: false): T;\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: true): T | undefined;\n private resolveToken<T>(token: Token<T>, name: string | undefined, optional: boolean): T | undefined {\n let registration = this.myTokenRegistry.get(token, name);\n\n if (!registration && isConstructor(token)) {\n registration = this.autoRegisterClass(token, name);\n }\n\n return this.resolveRegistration(token, registration, optional, name)?.value;\n }\n\n private resolveAllToken<T>(token: Token<T>, optional: boolean): T[] {\n let registrations = this.myTokenRegistry.getAll(token);\n\n if (registrations.length === 0 && isConstructor(token)) {\n const registration = this.autoRegisterClass(token);\n\n if (registration) {\n registrations = [registration];\n }\n }\n\n if (registrations.length === 0 && !optional) {\n throwUnregisteredError([token]);\n }\n\n return registrations\n .map((registration) => this.resolveRegistration(token, registration, optional))\n .filter((result) => result !== undefined)\n .map((result) => result.value);\n }\n\n private resolveRegistration<T>(\n token: Token<T>,\n registration: Registration<T> | undefined,\n optional?: boolean,\n name?: string,\n ): { value: T } | undefined {\n const aliases: TokenInfo[] = [];\n\n while (registration && isExistingProvider(registration.provider)) {\n const [targetToken, targetName] = this.getTargetToken(registration.provider);\n\n if (aliases.some(([t]) => t === targetToken)) {\n throwCircularAliasError([[token, name], ...aliases]);\n }\n\n // eslint-disable-next-line no-param-reassign\n registration = this.myTokenRegistry.get(targetToken, targetName);\n aliases.push([targetToken, targetName]);\n\n if (!registration && !optional) {\n throwTargetUnregisteredError([token, name], aliases);\n }\n }\n\n if (!registration) {\n return optional ? undefined : throwUnregisteredError([token, name]);\n }\n\n try {\n return {\n value: this.resolveProviderValue(token, registration),\n };\n } catch (e) {\n throwResolutionError([token, name], aliases, e);\n }\n }\n\n private getTargetToken<T>(provider: ExistingProvider<T>): [Token<T>, (string | undefined)?] {\n const token = provider.useExisting;\n return Array.isArray(token) ? token : [token];\n }\n\n private autoRegisterClass<T extends object>(Class: Constructor<T>, name?: string): Registration<T> | undefined {\n const metadata = getMetadata(Class);\n const autoRegister = metadata.autoRegister ?? this.myOptions.autoRegister;\n\n if (autoRegister && (name === undefined || metadata.name === name)) {\n // Temporarily set eagerInstantiate to false to avoid potentially resolving\n // the class inside register()\n const eagerInstantiate = metadata.eagerInstantiate;\n metadata.eagerInstantiate = false;\n\n try {\n this.register(Class);\n return this.myTokenRegistry.get(Class, name ?? metadata.name);\n } finally {\n metadata.eagerInstantiate = eagerInstantiate;\n }\n }\n\n return undefined;\n }\n\n private resolveProviderValue<T>(token: Token<T>, registration: Registration<T>): T;\n private resolveProviderValue<T extends object>(token: Constructor<T>, registration: Registration<T>): T;\n private resolveProviderValue<T>(token: Token<T>, registration: Registration<T>): T {\n const provider = registration.provider;\n\n if (isClassProvider(provider)) {\n const Class = provider.useClass;\n return this.resolveScopedValue(token, registration, (args) => new Class(...args));\n }\n\n if (isFactoryProvider(provider)) {\n const factory = provider.useFactory;\n return this.resolveScopedValue(token, registration, () => factory());\n }\n\n if (isValueProvider(provider)) {\n return provider.useValue;\n }\n\n check(false, \"internal: unexpected ExistingProvider\");\n }\n\n private resolveScopedValue<T>(token: Token<T>, registration: Registration<T>, factory: (...args: any[]) => T): T {\n let context = useInjectionContext();\n\n if (!context || context.container !== this) {\n context = {\n container: this,\n resolution: createResolution(),\n };\n }\n\n const resolution = context.resolution;\n const provider = registration.provider;\n\n if (resolution.stack.has(provider)) {\n const dependentRef = resolution.dependents.get(provider);\n check(dependentRef, () => {\n const path = getTokenPath(resolution.tokens.concat(token).map((t) => [t]));\n return `circular dependency detected while resolving ${path}`;\n });\n\n return dependentRef.current;\n }\n\n const scope = registration.options?.scope ?? this.myOptions.defaultScope;\n const cleanups = [\n provideInjectionContext(context),\n resolution.tokens.push(token) && (() => resolution.tokens.pop()),\n !isBuilder(provider) && resolution.stack.push(provider, { provider, scope }),\n ];\n\n try {\n switch (scope) {\n case \"Container\": {\n const valueRef = registration.valueRef;\n\n if (valueRef) {\n return valueRef.current;\n }\n\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n registration.valueRef = { current: value };\n this.notifyProvideHooks(value, scope);\n return value;\n }\n case \"Resolution\": {\n const valueRef = resolution.values.get(provider);\n\n if (valueRef) {\n return valueRef.current;\n }\n\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n resolution.values.set(provider, { current: value });\n this.notifyProvideHooks(value, scope);\n return value;\n }\n case \"Transient\": {\n const args = this.resolveCtorDependencies(registration);\n const value = this.injectMethodDependencies(registration, factory(args));\n this.notifyProvideHooks(value, scope);\n return value;\n }\n }\n } finally {\n cleanups.forEach((cleanup) => cleanup && cleanup());\n }\n }\n\n private resolveCtorDependencies<T>(registration: Registration<T>): any[] {\n const dependencies = registration.dependencies;\n\n if (dependencies) {\n check(isClassProvider(registration.provider), `internal: expected a ClassProvider`);\n const ctorDeps = dependencies.ctor.filter((d) => d.appliedBy);\n\n if (ctorDeps.length > 0) {\n // Let's check if all necessary constructor parameters are decorated.\n // If not, we cannot safely create an instance.\n const ctor = registration.provider.useClass;\n check(ctor.length === ctorDeps.length, () => {\n const location = getLocation(ctor);\n const msg = `${location} expected ${ctor.length} decorated constructor parameters`;\n return `${msg}, but found ${ctorDeps.length}`;\n });\n\n return this.resolveArgs(ctorDeps, ctor);\n }\n }\n\n return [];\n }\n\n private injectMethodDependencies<T>(registration: Registration<T>, instance: T): T {\n const dependencies = registration.dependencies;\n\n if (dependencies) {\n check(isClassProvider(registration.provider), `internal: expected a ClassProvider`);\n const ctor = registration.provider.useClass;\n\n // Perform method injection\n for (const entry of dependencies.methods) {\n const methodKey = entry[0];\n const methodDeps = entry[1].filter((d) => d.appliedBy);\n\n // Let's check if all necessary method parameters are decorated.\n // If not, we cannot safely invoke the method.\n const method = (instance as any)[methodKey] as Function;\n check(methodDeps.length === method.length, () => {\n const location = getLocation(ctor, methodKey);\n const msg = `${location} expected ${method.length} decorated method parameters`;\n return `${msg}, but found ${methodDeps.length}`;\n });\n\n const args = this.resolveArgs(methodDeps, ctor, instance, methodKey);\n method.bind(instance)(...args);\n }\n }\n\n return instance;\n }\n\n // Call context: decorator-based injection\n private resolveArgs(deps: MethodDependency[], ctor: Constructor<object>, instance?: any, methodKey?: string | symbol): any[] {\n const sortedDeps = deps.sort((a, b) => a.index - b.index);\n const args: any[] = [];\n\n for (const dep of sortedDeps) {\n try {\n args.push(this.resolveDependency(dep, instance));\n } catch (e) {\n throwParameterResolutionError(ctor, methodKey, dep, e);\n }\n }\n\n return args;\n }\n\n // Call context: decorator-based injection\n private resolveDependency(dependency: MethodDependency, instance?: any): any {\n const token = dependency.tokenRef!.getRefToken();\n check(token, `token passed to @${dependency.appliedBy} was undefined (possible circular imports)`);\n const name = dependency.name;\n\n switch (dependency.appliedBy) {\n case \"Inject\":\n return instance ? injectBy(instance, token, name) : this.resolve(token, name);\n case \"InjectAll\":\n return instance ? injectAll(token) : this.resolveAll(token);\n case \"Optional\":\n return instance ? optionalBy(instance, token, name) : this.tryResolve(token, name);\n case \"OptionalAll\":\n return instance ? optionalAll(token) : this.tryResolveAll(token);\n case undefined:\n check(false, \"internal: unexpected undefined appliedBy\");\n }\n }\n\n private notifyProvideHooks(value: unknown, scope: Scope): void {\n for (const hook of this.myHookRegistry.get()) {\n hook.onProvide?.(value, scope);\n }\n }\n\n private notifyDisposeHooks(values: unknown[]): void {\n for (const hook of this.myHookRegistry.get()) {\n hook.onDispose?.(values);\n }\n }\n\n private checkDisposed(): void {\n check(!this.myDisposed, \"container is disposed\");\n }\n}\n","import { ContainerImpl } from \"./containerImpl\";\nimport type { ClassProvider, ExistingProvider, FactoryProvider, Provider, ValueProvider } from \"./provider\";\nimport type { Scope } from \"./scope\";\nimport type { Constructor, ProviderType, Token } from \"./token\";\nimport type { RegistrationOptions, TokenRegistry } from \"./tokenRegistry\";\nimport type { RequiredNonNullable } from \"./utils/requiredNonNullable\";\n\ntype ProviderFor<V> = V extends object ? Provider<V> : Exclude<Provider<V>, ClassProvider<any>>;\ntype RegistrationOptionsFor<P> = P extends ValueProvider<any> ? never : RegistrationOptions;\n\n/**\n * Container creation options.\n */\nexport interface ContainerOptions {\n /**\n * The default scope for registrations.\n *\n * @defaultValue Transient\n */\n readonly defaultScope?: Scope | undefined;\n\n /**\n * Whether to automatically register an unregistered class when resolving it as a token.\n *\n * @defaultValue false\n */\n readonly autoRegister?: boolean | undefined;\n\n /**\n * Whether to also dispose values provided via {@link ValueProvider}, which are not\n * created or managed by the container, when the container itself is disposed.\n *\n * @defaultValue false\n */\n readonly disposeUnmanaged?: boolean | undefined;\n}\n\n/**\n * Child container creation options.\n */\nexport interface ChildContainerOptions extends ContainerOptions {\n /**\n * Whether to copy {@link ContainerHook}(s) from the parent container.\n *\n * @defaultValue true\n */\n readonly copyHooks?: boolean | undefined;\n}\n\n/**\n * A hook into the lifecycle of a {@link Container}.\n */\nexport interface ContainerHook {\n /**\n * Called when the container provides a value for a {@link Token}.\n * - For **Container**-scoped tokens, it is called only once when the token is first resolved and cached.\n * - For **Resolution**-scoped tokens, it is called once per token resolution graph.\n * - For **Transient**-scoped tokens, it is called each time the token is resolved,\n * which might mean multiple times per resolution graph.\n *\n * @param value - The provided value.\n * @param scope - The {@link Scope} of the provided value.\n */\n readonly onProvide?: ((value: unknown, scope: Scope) => void) | undefined;\n\n /**\n * Called after the container has been disposed.\n *\n * @param values - All distinct values that were cached by the disposed container.\n * Currently, only **Container**-scoped token values are cached.\n */\n readonly onDispose?: ((values: unknown[]) => void) | undefined;\n}\n\n/**\n * A Dependency Injection container.\n */\nexport interface Container {\n /**\n * @internal\n */\n readonly registry: TokenRegistry;\n\n /**\n * The options used to create this container.\n */\n readonly options: RequiredNonNullable<ContainerOptions>;\n\n /**\n * The parent container, or `undefined` if this is the root container.\n */\n readonly parent: Container | undefined;\n\n /**\n * Whether this container is disposed.\n */\n readonly isDisposed: boolean;\n\n /**\n * Creates a new child container that inherits this container's options.\n *\n * You can pass specific options to override the inherited ones.\n */\n createChild(options?: ChildContainerOptions): Container;\n\n /**\n * Clears and returns all distinct values cached by this container.\n * Values from {@link ValueProvider} registrations are not included, as they are never cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n clearCache(): unknown[];\n\n /**\n * Returns the cached value from the most recent registration of the token,\n * or `undefined` if no value has been cached yet (the token has not been resolved yet).\n *\n * If the token has at least one registration in this container,\n * the cached value is taken from the most recent of those registrations.\n * Otherwise, it may be retrieved from parent containers, if any.\n *\n * Values are never cached for tokens with **Transient** or **Resolution** scope,\n * or for {@link ValueProvider} registrations.\n */\n getCached<Value>(token: Token<Value>): Value | undefined;\n\n /**\n * Returns all cached values associated with registrations of the token,\n * in the order they were registered, or an empty array if none have been cached.\n *\n * If the token has at least one registration in the current container,\n * cached values are taken from those registrations.\n * Otherwise, cached values may be retrieved from parent containers, if any.\n *\n * Values are never cached for tokens with **Transient** or **Resolution** scope,\n * or for {@link ValueProvider} registrations.\n */\n getAllCached<Value>(token: Token<Value>): Value[];\n\n /**\n * Removes all registrations from this container's internal registry.\n *\n * Returns an array of the distinct values that were cached by this container for the\n * removed registrations. Values from {@link ValueProvider} registrations are not included,\n * as they are not cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n resetRegistry(): unknown[];\n\n /**\n * Returns whether the token is registered in this container or in parent containers, if any.\n */\n isRegistered<Value>(token: Token<Value>, name?: string): boolean;\n\n /**\n * Registers a {@link ClassProvider}, using the class itself as its token.\n *\n * Tokens provided via the {@link Injectable} decorator applied to the class\n * are also registered as aliases.\n *\n * The scope is determined by the {@link Scoped} decorator - if present -\n * or by the {@link ContainerOptions.defaultScope} value.\n */\n register<Instance extends object>(Class: Constructor<Instance>): Container;\n\n /**\n * Registers a token type with a default {@link Provider} and optional default registration options.\n */\n register<Value>(token: ProviderType<Value>): Container;\n\n /**\n * Registers a {@link Provider} with a token or class.\n *\n * The provider must be one of:\n * - {@link ClassProvider} via `useClass`\n * - {@link FactoryProvider} via `useFactory`\n * - {@link ValueProvider} via `useValue`\n * - {@link ExistingProvider} via `useExisting`\n *\n * For {@link ClassProvider} registrations, the default scope is determined by the {@link Scoped}\n * decorator applied to the provided class - if present - or by the {@link ContainerOptions.defaultScope}\n * value, but it can be overridden by passing explicit registration options.\n *\n * For {@link ValueProvider} registrations, the provided value is returned as-is and never cached,\n * and registration options do not apply.\n */\n register<Value, ProviderValue extends Value, Provider extends ProviderFor<ProviderValue>>(\n token: Token<Value>,\n provider: ProviderFor<ProviderValue> & Provider,\n options?: RegistrationOptionsFor<Provider>,\n ): Container;\n\n /**\n * Registers a {@link ClassProvider} with a token.\n *\n * The default registration scope is determined by the {@link Scoped} decorator\n * applied to the provided class - if present - or by the {@link ContainerOptions.defaultScope}\n * value, but it can be overridden by passing explicit registration options.\n */\n register<Instance extends object, ProviderInstance extends Instance>(\n token: Token<Instance>,\n provider: ClassProvider<ProviderInstance>,\n options?: RegistrationOptions,\n ): Container;\n\n /**\n * Registers a {@link FactoryProvider} with a token.\n */\n register<Value, ProviderValue extends Value>(\n token: Token<Value>,\n provider: FactoryProvider<ProviderValue>,\n options?: RegistrationOptions,\n ): Container;\n\n /**\n * Registers an {@link ExistingProvider} with a token.\n *\n * The token will alias the one set in `useExisting`.\n */\n register<Value, ProviderValue extends Value>(token: Token<Value>, provider: ExistingProvider<ProviderValue>): Container;\n\n /**\n * Registers a {@link ValueProvider} with a token.\n *\n * Values provided via `useValue` are never cached (scopes do not apply)\n * and are simply returned as-is.\n */\n register<Value, ProviderValue extends Value>(token: Token<Value>, provider: ValueProvider<ProviderValue>): Container;\n\n /**\n * Removes all registrations for the given token from the container's internal registry.\n *\n * Returns an array of the distinct values that were cached by this container for the\n * removed registrations. Values from {@link ValueProvider} registrations are not included,\n * as they are not cached.\n *\n * Note that only this container is affected. Parent or child containers, if any, remain unchanged.\n */\n unregister<Value>(token: Token<Value>, name?: string): Value[];\n\n /**\n * Resolves the given class to the instance associated with it.\n *\n * If the class is registered in this container or any of its parent containers,\n * an instance is created using the most recent registration.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instance is cached\n * in the container's internal registry.\n */\n resolve<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n /**\n * Resolves the given token to the value associated with it.\n *\n * If the token is registered in this container or any of its parent containers,\n * its value is resolved using the most recent registration.\n *\n * If the token is not registered in this container or any of its parent containers, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved value is cached\n * in the container's internal registry.\n */\n resolve<Value>(token: Token<Value>, name?: string): Value;\n\n /**\n * Resolves the given class to the instance associated with it.\n *\n * If the class is registered in this container or any of its parent containers,\n * an instance is created using the most recent registration.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, `undefined` is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instance is cached\n * in the container's internal registry.\n */\n tryResolve<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n /**\n * Tries to resolve the given token to the value associated with it.\n *\n * If the token is registered in this container or any of its parent containers,\n * its value is resolved using the most recent registration.\n *\n * If the token is not registered in this container or any of its parent containers,\n * `undefined` is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved value is cached\n * in the container's internal registry.\n */\n tryResolve<Value>(token: Token<Value>, name?: string): Value | undefined;\n\n /**\n * Resolves the given class to all instances provided by the registrations associated with it.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instances are cached\n * in the container's internal registry.\n *\n * A separate instance of the class is created for each provider.\n */\n resolveAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Resolves the given token to all values provided by the registrations associated with it.\n *\n * If the token is not registered in this container or any of its parent containers, an error is thrown.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved values are cached\n * in the container's internal registry.\n */\n resolveAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Resolves the given class to all instances provided by the registrations associated with it.\n *\n * If the class is not registered, but it is decorated with {@link AutoRegister},\n * or {@link ContainerOptions.autoRegister} is true, the class is registered automatically.\n * Otherwise, the resolution fails.\n *\n * The scope for the automatic registration is determined by either\n * the {@link Scoped} decorator on the class, or {@link ContainerOptions.defaultScope}.\n *\n * If the class is not registered in this container or any of its parent containers\n * and could not be auto-registered, an empty array is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided instance is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the instance.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the instance is resolved by referring to another registered token.\n *\n * If the class is registered with **Container** scope, the resolved instances are cached\n * in the container's internal registry.\n *\n * A separate instance of the class is created for each provider.\n */\n tryResolveAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Resolves the given token to all values provided by the registrations associated with it.\n *\n * If the token is not registered in this container or any of its parent containers,\n * an empty array is returned instead.\n *\n * The resolution behavior depends on the {@link Provider} used during registration:\n * - For {@link ValueProvider}, the explicitly provided value is returned.\n * - For {@link FactoryProvider}, the factory function is invoked to create the value.\n * - For {@link ClassProvider}, a new instance of the class is created according to its scope.\n * - For {@link ExistingProvider}, the value is resolved by referring to another registered token.\n *\n * If the token is registered with **Container** scope, the resolved values are cached\n * in the container's internal registry.\n */\n tryResolveAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Adds a hook to observe the lifecycle of container-managed values.\n *\n * Does nothing if the hook has already been added.\n */\n addHook(hook: ContainerHook): void;\n\n /**\n * Removes a previously added hook.\n *\n * Does nothing if the hook has not been added yet.\n */\n removeHook(hook: ContainerHook): void;\n\n /**\n * Disposes this container and all its cached values.\n *\n * Token values implementing a `Disposable` interface (e.g., objects with a `dispose()` function)\n * are also disposed. All disposals, whether synchronous or asynchronous, are returned as promises\n * in an array. Callers may await these promises (e.g., using `Promise.allSettled()`) if they want\n * to ensure that all async work has completed.\n *\n * Note that children containers are disposed first, in creation order.\n */\n dispose(): Promise<unknown>[];\n}\n\n/**\n * Creates a new container.\n */\nexport function createContainer(options?: ContainerOptions): Container {\n return new ContainerImpl(undefined, options);\n}\n","import { getMetadata } from \"../metadata\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that enables auto-registration of an unregistered class\n * when the class is first resolved from the container.\n *\n * Example:\n * ```ts\n * @AutoRegister()\n * class Wizard {}\n *\n * const wizard = container.resolve(Wizard);\n * container.isRegistered(Wizard); // => true\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function AutoRegister<This extends object>(): ClassDecorator<This> {\n return (Class): void => {\n const metadata = getMetadata(Class);\n metadata.autoRegister = true;\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that sets the class scope to **Container** and enables\n * eager instantiation when the class is registered in the container.\n *\n * This causes the container to create and cache the instance of the class\n * immediately, instead of deferring it until the first resolution.\n *\n * If the class cannot be resolved at registration time, registration fails.\n *\n * Example:\n * ```ts\n * @EagerInstantiate()\n * class Wizard {}\n *\n * // Wizard is registered with Container scope, and an instance\n * // is created and cached immediately by the container\n * container.register(Wizard);\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function EagerInstantiate<This extends object>(): ClassDecorator<This> {\n return (Class): void => {\n const metadata = getMetadata(Class);\n const currentScope = metadata.scope;\n check(!currentScope || currentScope.value === \"Container\", () => {\n const { value, appliedBy } = currentScope!;\n const by = appliedBy === \"Scoped\" ? `${appliedBy}(${value})` : appliedBy;\n const className = getTokenName(Class);\n return (\n `class ${className}: scope ${value} was already set by @${by},\\n ` +\n `but @EagerInstantiate is trying to set a conflicting scope Container.\\n ` +\n `Only one decorator should set the class scope, or all must use the same value.`\n );\n });\n\n metadata.eagerInstantiate = true;\n metadata.scope = {\n value: \"Container\",\n appliedBy: \"EagerInstantiate\",\n };\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects the instance associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected.\n *\n * Use {@link injectBy} when you need to resolve circular dependencies.\n */\nexport function Inject<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n *\n * Use {@link injectBy} when you need to resolve circular dependencies.\n */\nexport function Inject<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n *\n * Use function injection with {@link injectBy} when you need to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@Inject(tokenRef(() => Wand)) readonly wand: Wand) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function Inject<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function Inject<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return (target, propertyKey, parameterIndex): void => {\n updateParameterMetadata(\"Inject\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Inject\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n });\n };\n}\n","import { getMetadata } from \"../metadata\";\nimport type { Token, Tokens } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that registers additional aliasing tokens for the decorated type.\n *\n * The aliases are added using {@link ExistingProvider}(s) when the class is first\n * registered in the container.\n *\n * Example:\n * ```ts\n * @Injectable(Weapon)\n * class Rifle {}\n * ```\n *\n * Note that `@Injectable` decorators can be stacked to add multiple aliases.\n *\n * Example:\n * ```ts\n * @Injectable(Weapon)\n * @Injectable(Gun) // Or just @Injectable(Weapon, Gun)\n * class Rifle {}\n * ```\n */\nexport function Injectable<Value, This extends Value & object>(token: Token<Value>): ClassDecorator<This>;\nexport function Injectable<VA, VB, This extends VA & VB & object>(tokenA: Token<VA>, tokenB: Token<VB>): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, This extends VA & VB & VC & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, This extends VA & VB & VC & VD & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, VE, This extends VA & VB & VC & VD & VE & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n tokenE: Token<VE>,\n): ClassDecorator<This>;\nexport function Injectable<VA, VB, VC, VD, VE, VF, This extends VA & VB & VC & VD & VE & VF & object>(\n tokenA: Token<VA>,\n tokenB: Token<VB>,\n tokenC: Token<VC>,\n tokenD: Token<VD>,\n tokenE: Token<VE>,\n tokenF: Token<VF>,\n): ClassDecorator<This>;\n\n/**\n * Class decorator that registers an additional aliasing token for the decorated type.\n *\n * The alias is added using an {@link ExistingProvider} when the class is first\n * registered in the container.\n *\n * This overload allows referencing tokens that are declared later in the file\n * by using the {@link tokenRef} helper function.\n *\n * Example:\n * ```ts\n * @Injectable(tokenRef(() => Weapon)) // Weapon is declared after Rifle\n * class Rifle {}\n * // Other code...\n * const Weapon = createType(\"Weapon\");\n * ```\n *\n * Note that `@Injectable` decorators can be stacked to add multiple aliases.\n *\n * Example:\n * ```ts\n * @Injectable(tokenRef(() => Weapon))\n * @Injectable(Gun)\n * class Rifle {}\n * ```\n */\nexport function Injectable<Value, This extends Value & object>(tokens: TokenRef<Value>): ClassDecorator<This>;\n\n// @__NO_SIDE_EFFECTS__\nexport function Injectable<This extends object>(...args: [...Tokens<This>] | [TokenRef<This>]): ClassDecorator<This> {\n return (Class): void => {\n const metadata = getMetadata(Class);\n const arg0 = args[0];\n const ref = isTokenRef(arg0) ? arg0 : tokenRef(() => args as Tokens<This>);\n const currentRef = metadata.tokenRef;\n metadata.tokenRef = {\n getRefToken: () => currentRef.getRefToken(),\n getRefTokens: () => {\n const existingTokens = currentRef.getRefTokens();\n\n for (const token of ref.getRefTokens()) {\n existingTokens.add(token);\n }\n\n return existingTokens;\n },\n };\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects all instances provided by the registrations\n * associated with the given class.\n *\n * Throws an error if:\n * - The class is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function InjectAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n */\nexport function InjectAll<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if:\n * - The token is not registered in the container.\n * - A circular dependency is detected.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@InjectAll(tokenRef(() => Wand)) readonly wands: Wand[]) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function InjectAll<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function InjectAll<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return (target, propertyKey, parameterIndex): void => {\n updateParameterMetadata(\"InjectAll\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"InjectAll\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata } from \"../metadata\";\nimport type { Constructor } from \"../token\";\nimport type { ClassDecorator, ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, describeParam, updateParameterMetadata } from \"./utils\";\n\n/**\n * Qualifies a class or an injected parameter with a name.\n *\n * On a class, the name is used when registering that class with the container.\n * On a parameter, the name selects a named registration or alias during injection.\n *\n * This is useful when multiple registrations exist for the same token.\n *\n * Example:\n * ```ts\n * @Named(\"dumbledore\")\n * class Dumbledore implements Wizard {}\n *\n * container.register(IWizard, { useClass: Dumbledore });\n * const dumbledore = container.resolve(IWizard, \"dumbledore\");\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function Named<This extends object>(name: string): ClassDecorator<This> & ParameterDecorator {\n check(name.trim(), \"@Named qualifier must not be empty\");\n return (target: object, propertyKey?: string | symbol, parameterIndex?: number): void => {\n if (parameterIndex === undefined) {\n // The decorator has been applied to the class\n const Class = target as Constructor<This>;\n const metadata = getMetadata(Class);\n const className = getTokenName(Class);\n check(metadata.name === undefined, `multiple @Named decorators on class ${className}, but only one is allowed`);\n metadata.name = name;\n } else {\n // The decorator has been applied to a method parameter\n updateParameterMetadata(\"Named\", target, propertyKey, parameterIndex, (dependency) => {\n check(dependency.name === undefined, () => {\n const param = describeParam(target, propertyKey, parameterIndex);\n return `multiple @Named decorators on ${param}, but only one is allowed`;\n });\n\n dependency.name = name;\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n }\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} when you need to resolve circular dependencies.\n */\nexport function Optional<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} when you need to resolve circular dependencies.\n */\nexport function Optional<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if a circular dependency is detected. Use function injection\n * with {@link optionalBy} when you need to resolve circular dependencies.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@Optional(tokenRef(() => Wand)) readonly wand: Wand | undefined) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function Optional<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function Optional<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return (target, propertyKey, parameterIndex): void => {\n updateParameterMetadata(\"Optional\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"Optional\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n });\n };\n}\n","import type { Constructor, Token } from \"../token\";\nimport { isTokenRef, type TokenRef, tokenRef } from \"../tokenRef\";\nimport type { ParameterDecorator } from \"./decorators\";\nimport { checkNamedDecorator, checkSingleDecorator, updateParameterMetadata } from \"./utils\";\n\n/**\n * Parameter decorator that injects all instances provided by the registrations\n * associated with the given class or an empty array if the class is not registered\n * in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function OptionalAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token or an empty array if the token is not registered\n * in the container.\n *\n * Throws an error if a circular dependency is detected.\n */\nexport function OptionalAll<Value>(token: Token<Value>): ParameterDecorator;\n\n/**\n * Parameter decorator that injects all values provided by the registrations\n * associated with the given token or an empty array if the token is not registered\n * in the container.\n *\n * This overload allows referencing a token declared later in the file by using\n * the {@link tokenRef} helper function.\n *\n * Throws an error if a circular dependency is detected.\n *\n * Example:\n * ```ts\n * class Wizard {\n * constructor(@OptionalAll(tokenRef(() => Wand)) readonly wands: Wand[]) {}\n * }\n * // Other code...\n * class Wand {}\n * ```\n */\nexport function OptionalAll<Value>(tokens: TokenRef<Value>): ParameterDecorator;\n\n// @__NO_SIDE_EFFECTS__\nexport function OptionalAll<T>(token: Token<T> | TokenRef<T>): ParameterDecorator {\n return (target, propertyKey, parameterIndex): void => {\n updateParameterMetadata(\"OptionalAll\", target, propertyKey, parameterIndex, (dependency) => {\n checkSingleDecorator(dependency, target, propertyKey, parameterIndex);\n dependency.appliedBy = \"OptionalAll\";\n dependency.tokenRef = isTokenRef(token) ? token : tokenRef(() => token);\n checkNamedDecorator(dependency, target, propertyKey, parameterIndex);\n });\n };\n}\n","import { check, getTokenName } from \"../errors\";\nimport { getMetadata, type ScopeDecorator } from \"../metadata\";\nimport type { Scope } from \"../scope\";\nimport type { ClassDecorator } from \"./decorators\";\n\n/**\n * Class decorator that registers the decorated type with the **Container** scope.\n *\n * Use this scope when you want one cached instance per container,\n * with parent-container lookup fallback.\n *\n * Example:\n * ```ts\n * @ContainerScoped()\n * class Wizard {\n * // ...\n * }\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function ContainerScoped<This extends object>(): ClassDecorator<This> {\n return scoped(\"Container\", \"ContainerScoped\");\n}\n\n/**\n * Class decorator that registers the decorated type with the **Resolution** scope.\n *\n * Use this scope when you want one cached instance per resolution graph,\n * so repeated resolutions within the same request reuse the same value.\n *\n * Example:\n * ```ts\n * @ResolutionScoped()\n * class Wand {\n * // ...\n * }\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function ResolutionScoped<This extends object>(): ClassDecorator<This> {\n return scoped(\"Resolution\", \"ResolutionScoped\");\n}\n\n/**\n * Class decorator that registers the decorated type with the **Transient** scope.\n *\n * Use this scope when you want a fresh instance every time the class is resolved.\n *\n * Example:\n * ```ts\n * @TransientScoped()\n * class Wand {\n * // ...\n * }\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function TransientScoped<This extends object>(): ClassDecorator<This> {\n return scoped(\"Transient\", \"TransientScoped\");\n}\n\n/**\n * Class decorator for setting the scope of the decorated type when registering it.\n *\n * The scope set by this decorator can be overridden by explicit registration options, if provided.\n *\n * Example:\n * ```ts\n * @Scoped(\"Container\")\n * class Wizard {}\n *\n * container.register(Wizard);\n *\n * // Under the hood\n * container.register(\n * Wizard,\n * { useClass: Wizard },\n * { scope: \"Container\" },\n * );\n * ```\n */\n// @__NO_SIDE_EFFECTS__\nexport function Scoped<This extends object>(scope: Scope): ClassDecorator<This> {\n return scoped(scope, \"Scoped\");\n}\n\nfunction scoped<This extends object>(scope: Scope, decorator: ScopeDecorator): ClassDecorator<This> {\n return (Class): void => {\n const metadata = getMetadata(Class);\n const currentScope = metadata.scope;\n check(!currentScope || currentScope.value === scope, () => {\n const { value, appliedBy } = currentScope!;\n const by = appliedBy === \"Scoped\" ? `${appliedBy}(${value})` : appliedBy;\n const className = getTokenName(Class);\n return (\n `class ${className}: scope ${value} was already set by @${by},\\n ` +\n `but @${decorator} is trying to set a conflicting scope ${scope}.\\n ` +\n `Only one decorator should set the class scope, or all must use the same value.`\n );\n });\n\n metadata.scope = {\n value: scope,\n appliedBy: decorator,\n };\n };\n}\n","import { inject } from \"./inject\";\nimport { injectAll } from \"./injectAll\";\nimport { ensureInjectionContext, provideInjectionContext, useInjectionContext } from \"./injectionContext\";\nimport { optional } from \"./optional\";\nimport { optionalAll } from \"./optionalAll\";\nimport type { Constructor, Token, Type } from \"./token\";\nimport { build } from \"./tokenRegistry\";\n\n/**\n * Allows performing injections outside the normal injection context window.\n *\n * Example:\n * ```ts\n * class Wizard {\n * private injector = inject(Injector);\n *\n * // Lazily initialize the wand property\n * private wand?: Wand;\n *\n * getWand(): Wand {\n * // An injection context does not exist here, but the\n * // Injector instance retains and reuses the context\n * // that was present at the time of its injection\n * return (this.wand ??= this.injector.inject(Wand));\n * }\n * }\n * ```\n */\nexport interface Injector {\n /**\n * Injects the instance associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n */\n inject<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance;\n\n /**\n * Injects the value associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n */\n inject<Value>(token: Token<Value>, name?: string): Value;\n\n /**\n * Injects all instances provided by the registrations associated with the given class.\n *\n * Throws an error if the class is not registered in the container.\n */\n injectAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Injects all values provided by the registrations associated with the given token.\n *\n * Throws an error if the token is not registered in the container.\n */\n injectAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Injects the instance associated with the given class,\n * or `undefined` if the class is not registered in the container.\n */\n optional<Instance extends object>(Class: Constructor<Instance>, name?: string): Instance | undefined;\n\n /**\n * Injects the value associated with the given token,\n * or `undefined` if the token is not registered in the container.\n */\n optional<Value>(token: Token<Value>, name?: string): Value | undefined;\n\n /**\n * Injects all instances provided by the registrations associated with the given class\n * or an empty array if the class is not registered in the container.\n */\n optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];\n\n /**\n * Injects all values provided by the registrations associated with the given token\n * or an empty array if the token is not registered in the container.\n */\n optionalAll<Value>(token: Token<Value>): Value[];\n\n /**\n * Runs a function inside the injection context of this injector.\n *\n * Note that injection functions (`inject`, `injectAll`, `optional`, `optionalAll`)\n * are only usable synchronously: they cannot be called from asynchronous callbacks\n * or after any `await` points.\n *\n * @param fn - The function to be run in the context of this injector.\n * @returns The return value of the function, if any.\n */\n runInContext<ReturnType>(fn: () => ReturnType): ReturnType;\n}\n\n/**\n * Allows performing injections outside the normal injection context window.\n *\n * Example:\n * ```ts\n * class Wizard {\n * private injector = inject(Injector);\n *\n * // Lazily initialize the wand property\n * private wand?: Wand;\n *\n * getWand(): Wand {\n * // An injection context does not exist here, but the\n * // Injector instance retains and reuses the context\n * // that was present at the time of its injection\n * return (this.wand ??= this.injector.inject(Wand));\n * }\n * }\n * ```\n */\nexport const Injector: Type<Injector> = /* @__PURE__ */ build<Injector>(() => {\n const context = ensureInjectionContext(\"Injector factory\");\n const runInContext = <R>(fn: () => R): R => {\n if (useInjectionContext()) {\n return fn();\n }\n\n const cleanup = provideInjectionContext(context);\n\n try {\n return fn();\n } finally {\n cleanup();\n }\n };\n\n return {\n inject: <T>(token: Token<T>, name?: string) => runInContext(() => inject(token, name)),\n injectAll: <T>(token: Token<T>) => runInContext(() => injectAll(token)),\n optional: <T>(token: Token<T>, name?: string) => runInContext(() => optional(token, name)),\n optionalAll: <T>(token: Token<T>) => runInContext(() => optionalAll(token)),\n runInContext: runInContext,\n };\n}, \"Injector\");\n","export const Scope = {\n /**\n * Creates a new value every time the token is resolved.\n */\n Transient: \"Transient\",\n\n /**\n * Creates and caches a single value per token resolution graph.\n *\n * The same value is reused during a single resolution request and is subsequently discarded.\n */\n Resolution: \"Resolution\",\n\n /**\n * Creates and caches a single value per container.\n *\n * If the value is not found in the current container, it is looked up in the parent container,\n * and so on. It effectively behaves like a _singleton_ scope but allows container-specific overrides.\n */\n Container: \"Container\",\n} as const;\n\nexport type Scope = (typeof Scope)[keyof typeof Scope];\n"],"names":["check","condition","message","Error","tag","throwUnregisteredError","tokenInfo","getFullTokenName","throwTargetUnregisteredError","aliases","path","length","getTokenPath","desc","cause","at","throwCircularAliasError","throwResolutionError","getCause","throwParameterResolutionError","ctor","methodKey","dependency","location","getLocation","tokenName","tokenRef","getRefToken","name","msg","index","ctorName","String","tokens","map","join","getTokenName","token","undefined","error","isError","untag","value","stack","startsWith","substring","trimStart","HookRegistry","parent","myHooks","Set","clear","get","add","hook","delete","KeyedStack","has","key","myKeys","peek","myEntries","push","pop","WeakSet","WeakRefMap","ref","myMap","deref","set","WeakRef","WeakMap","createResolution","values","dependents","provideInjectionContext","useInjectionContext","createInjectionContext","ensureInjectionContext","context","assertInjectionContext","fn","current","provide","next","prev","use","injectAll","container","resolveAll","inject","resolve","injectBy","thisArg","resolution","currentFrame","cleanup","provider","classRef","Class","getRefClass","tokenOrTokens","Array","isArray","getRefTokens","tokensArray","isClassRef","isTokenRef","Metadata","dependencies","methods","Map","useClass","getCtorDependency","i","findIndex","d","getMethodDependency","method","methodDeps","getMetadata","classOrRef","originalClass","classIdentityMap","metadata","metadataMap","setClassIdentityMapping","transformedClass","optionalAll","tryResolveAll","optional","tryResolve","optionalBy","isClassProvider","isFactoryProvider","isValueProvider","isExistingProvider","updateParameterMetadata","decorator","target","parameterIndex","updateFn","checkSingleDecorator","appliedBy","param","describeParam","checkNamedDecorator","createType","typeName","options","type","propertyKey","Object","defineProperty","__type","toString","isConstructor","getTypeName","proto","getPrototypeOf","prototype","TokenRegistry","myRegistrations","myParent","getAll","internal","internals","getAllFromParent","put","registration","registrations","existing","filter","r","removed","updated","deleteAll","keys","flat","clearCache","valueRef","isBuilder","builders","build","factory","useFactory","scope","isDisposable","dispose","ContainerImpl","myChildren","myDisposed","myOptions","defaultScope","autoRegister","disposeUnmanaged","copyHooks","myHookRegistry","myTokenRegistry","registry","isDisposed","createChild","checkDisposed","getCached","getAllCached","resetRegistry","isRegistered","register","args","registerClass","registerToken","unregister","resolveToken","resolveAllToken","addHook","removeHook","promises","child","cacheValues","allValues","useValue","Promise","e","reject","notifyDisposeHooks","useExisting","eagerInstantiate","resolveProviderValue","trim","targetToken","getTargetToken","autoRegisterClass","resolveRegistration","result","targetName","some","t","resolveScopedValue","dependentRef","concat","cleanups","resolveCtorDependencies","injectMethodDependencies","notifyProvideHooks","forEach","ctorDeps","resolveArgs","instance","entry","bind","deps","sortedDeps","sort","a","b","dep","resolveDependency","onProvide","onDispose","createContainer","AutoRegister","EagerInstantiate","currentScope","by","className","Inject","Injectable","arg0","currentRef","existingTokens","InjectAll","Named","Optional","OptionalAll","ContainerScoped","scoped","ResolutionScoped","TransientScoped","Scoped","Injector","runInContext","Scope","Transient","Resolution","Container"],"mappings":";;AASO,SAASA,KAAAA,CAAMC,SAAkB,EAAEC,OAAgC,EAAA;AACxE,IAAA,IAAI,CAACD,SAAAA,EAAW;AACd,QAAA,MAAM,IAAIE,KAAAA,CAAMC,GAAAA,CAAI,OAAOF,OAAAA,KAAY,WAAWA,OAAAA,GAAUA,OAAAA,EAAAA,CAAAA,CAAAA;AAC9D,IAAA;AACF;AAEA;AACO,SAASG,uBAAuBC,SAAoB,EAAA;AACzD,IAAA,MAAM,IAAIH,KAAAA,CAAMC,GAAAA,CAAI,CAAC,mBAAmB,EAAEG,iBAAiBD,SAAAA,CAAAA,CAAAA,CAAY,CAAA,CAAA;AACzE;AAEA;AACO,SAASE,4BAAAA,CAA6BF,SAAoB,EAAEG,OAAoB,EAAA;AACrF,IAAA,MAAMC,IAAAA,GAAOD,OAAAA,CAAQE,MAAM,GAAG,CAAA,GAAI,CAAC,YAAY,EAAEC,YAAAA,CAAaH,OAAAA,CAAAA,CAAS,CAAC,CAAC,GAAG,EAAA;IAC5E,MAAMI,IAAAA,GAAON,iBAAiBD,SAAAA,CAAAA,GAAaI,IAAAA;IAC3C,MAAMI,KAAAA,GAAQ,CAAC,qDAAqD,EAAEP,iBAAiBE,OAAAA,CAAQM,EAAE,CAAC,EAAC,CAAA,CAAA,CAAA,CAAM;AACzG,IAAA,MAAM,IAAIZ,KAAAA,CAAMC,GAAAA,CAAI,CAAC,wBAAwB,EAAES,MAAM,CAAA,GAAIC,KAAAA,CAAAA;AAC3D;AAEA;AACO,SAASE,wBAAwBP,OAAoB,EAAA;AAC1D,IAAA,MAAMC,OAAOE,YAAAA,CAAaH,OAAAA,CAAAA;AAC1B,IAAA,MAAM,IAAIN,KAAAA,CAAMC,GAAAA,CAAI,CAAC,wCAAwC,EAAEM,IAAAA,CAAAA,CAAM,CAAA,CAAA;AAC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