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