import { InjectableScope } from "../../enums/injectable-scope.enum.mjs"; import { InjectableType } from "../../enums/injectable-type.enum.mjs"; //#region src/internal/holder/instance-holder.d.mts /** * Represents the lifecycle status of an instance holder. */ declare enum InstanceStatus { /** Instance has been successfully created and is ready for use */ Created = "created", /** Instance is currently being created (async initialization in progress) */ Creating = "creating", /** Instance is being destroyed (cleanup in progress) */ Destroying = "destroying", /** Instance creation failed with an error */ Error = "error", } /** Callback function for instance destruction listeners */ type InstanceDestroyListener = () => void | Promise; /** * Instance holder in the Creating state. * The instance is null while creation is in progress. */ interface InstanceHolderCreating { status: InstanceStatus.Creating; name: string; instance: null; creationPromise: Promise<[undefined, Instance]> | null; destroyPromise: null; type: InjectableType; scope: InjectableScope; deps: Set; destroyListeners: InstanceDestroyListener[]; createdAt: number; /** Tracks which services this holder is currently waiting for (for circular dependency detection) */ waitingFor: Set; } /** * Instance holder in the Created state. * The instance is available and ready for use. */ interface InstanceHolderCreated { status: InstanceStatus.Created; name: string; instance: Instance; creationPromise: null; destroyPromise: null; type: InjectableType; scope: InjectableScope; deps: Set; destroyListeners: InstanceDestroyListener[]; createdAt: number; /** Tracks which services this holder is currently waiting for (for circular dependency detection) */ waitingFor: Set; } /** * Instance holder in the Destroying state. * The instance may still be available but is being cleaned up. */ interface InstanceHolderDestroying { status: InstanceStatus.Destroying; name: string; instance: Instance | null; creationPromise: null; destroyPromise: Promise; type: InjectableType; scope: InjectableScope; deps: Set; destroyListeners: InstanceDestroyListener[]; createdAt: number; /** Tracks which services this holder is currently waiting for (for circular dependency detection) */ waitingFor: Set; } /** * Instance holder in the Error state. * The instance field contains the error that occurred during creation. */ interface InstanceHolderError { status: InstanceStatus.Error; name: string; instance: Error; creationPromise: null; destroyPromise: null; type: InjectableType; scope: InjectableScope; deps: Set; destroyListeners: InstanceDestroyListener[]; createdAt: number; /** Tracks which services this holder is currently waiting for (for circular dependency detection) */ waitingFor: Set; } /** * Holds the state of a service instance throughout its lifecycle. * * Tracks creation/destruction promises, dependency relationships, * destroy listeners, and current status (Creating, Created, Destroying, Error). */ type InstanceHolder = InstanceHolderCreating | InstanceHolderCreated | InstanceHolderDestroying | InstanceHolderError; //#endregion export { InstanceDestroyListener, InstanceHolder, InstanceHolderCreated, InstanceHolderCreating, InstanceHolderDestroying, InstanceHolderError, InstanceStatus }; //# sourceMappingURL=instance-holder.d.mts.map