import { t as DiError } from "./error-B_g1YEwt.mjs"; import { a as DisposeHook, c as OptionalDependency, d as Token, f as Scope, i as DepsMap, l as Provider, n as RegisterOptions, o as Factory, p as Scopes, r as Dependency, s as FactoryProvider, t as Container, u as ValueProvider } from "./types-DHrRUW_I.mjs"; //#region src/core/provider/errors.d.ts /** * Error thrown when a provider configuration cannot be used safely. */ declare class InvalidProviderError extends DiError { constructor(message: string); } //#endregion //#region src/core/token/token.d.ts /** * Creates a unique typed token. * * The `name` is used only for diagnostics. Token identity is unique per call, * so two tokens with the same name do not collide. * * @example * ```ts * const CONFIG = createToken("config"); * ``` */ declare const createToken: (name: string) => Token; //#endregion //#region src/core/provider/provider.d.ts /** * Creates a provider for an already constructed value. * * The value must match the token type. * * @example * ```ts * provideValue(PORT, 3000); * ``` */ declare const provideValue: (token: Token, useValue: T) => ValueProvider; /** * Creates a provider that lazily builds a value. * * Dependencies declared in `deps` become the object passed to `useFactory`. * The factory return type must match the token type. * * @example * ```ts * provideFactory(HTTP, { * deps: { config: CONFIG }, * useFactory: ({ config }) => new HttpClient(config.apiUrl), * }); * ``` */ declare const provideFactory: >(token: Token, options: { readonly deps?: TDeps; readonly scope?: Scope; readonly useFactory: Factory; readonly onDispose?: DisposeHook; }) => FactoryProvider; /** * Marks a token as optional. * * Optional dependencies resolve to `undefined` instead of throwing when no * provider exists in the container chain. They can be used in factory `deps` * or passed directly to `container.get`. * * @example * ```ts * const logger = container.get(optional(LOGGER)); * ``` */ declare const optional: (token: Token) => OptionalDependency; //#endregion //#region src/core/registry/errors.d.ts /** * Error thrown when registering a provider for an already registered token. */ declare class DuplicateProviderError extends DiError { constructor(tokenName: string); } //#endregion //#region src/core/container/container.d.ts /** * Creates a root container with optional initial providers. * * Root containers own singleton instances for providers registered in them. */ declare const createContainer: (providers?: readonly Provider[]) => Container; /** * Creates a child container that can resolve providers from its parent. * * Child containers may register their own providers while still reusing parent * providers. Scoped providers create one cached instance per resolving child. */ declare const createChildContainer: (parent: Container, providers?: readonly Provider[]) => Container; //#endregion //#region src/core/annotation/types.d.ts type InjectableDeps = readonly Dependency[]; type DependencyValue = TDependency extends OptionalDependency ? T | undefined : TDependency extends Token ? T : never; type ResolveDependencyTuple = { -readonly [TKey in keyof TDeps]: DependencyValue; }; /** * Constructor type whose parameters match an injectable dependency tuple. */ type InjectableConstructor = new (...args: ResolveDependencyTuple) => T; /** * Class that can be passed to `provideInjectable`. * * `never[]` keeps classes with required constructor parameters assignable * without claiming arbitrary constructor arguments are valid. */ type InjectableClass = new (...args: never[]) => T; /** * Options stored by `@Injectable` and converted into a factory provider. */ type InjectableOptions = { /** * Token provided by the decorated class. */ readonly token: Token; /** * Ordered constructor dependencies. * * Each item is resolved and passed to the constructor at the same index. */ readonly deps?: TDeps; /** * Provider lifetime. * * Defaults to `Scopes.Singleton`. */ readonly scope?: Scope; /** * Cleanup hook for cached singleton and scoped instances. * * Not supported for transient providers. */ readonly onDispose?: DisposeHook; }; //#endregion //#region src/core/annotation/annotation.d.ts type InjectableDecorator = (target: TTarget, context: ClassDecoratorContext) => void; type InjectableOptionsWithoutDeps = Omit, "deps">; declare function Injectable[]>(options: InjectableOptions & { readonly deps: TDeps; }): InjectableDecorator>; declare function Injectable(options: InjectableOptionsWithoutDeps): InjectableDecorator>; /** * Creates a factory provider from a class marked with `@Injectable`. * * The returned provider is a normal di-craft factory provider, so scopes, * optional dependencies, disposal hooks, overrides, and cycle detection behave * the same as with `provideFactory`. */ declare function provideInjectable(target: InjectableClass): FactoryProvider; //#endregion //#region src/core/resolver/errors.d.ts /** * Error thrown when resolving a token without a registered provider. */ declare class MissingProviderError extends DiError { constructor(tokenName: string); } /** * Error thrown when a dependency descriptor is invalid. */ declare class InvalidDependencyError extends DiError { constructor(dependencyKey: string); } /** * Error thrown when provider dependencies form a cycle. */ declare class CircularDependencyError extends DiError { constructor(tokenNames: string[]); } //#endregion export { CircularDependencyError, type Container, type Dependency, DiError, type DisposeHook, DuplicateProviderError, type FactoryProvider, Injectable, InvalidDependencyError, InvalidProviderError, MissingProviderError, type OptionalDependency, type Provider, type RegisterOptions, type Scope, Scopes, type Token, type ValueProvider, createChildContainer, createContainer, createToken, optional, provideFactory, provideInjectable, provideValue }; //# sourceMappingURL=index.d.mts.map