{"version":3,"file":"index.mjs","names":[],"sources":["../../src/entities/entity-queue.ts","../../src/entities/entity-scheduler.ts"],"sourcesContent":["import { IEntityModel } from './entity';\nimport { IEntityConfigSnapshot } from './entity-config';\nimport { IEntityProxy } from './entity-proxies';\nimport { IEntitySnapshot } from './entity-snapshot';\n\n/**\n * Specifies the action to be performed on an entity.\n * Updates are categorized to enable different processing paths in the runtime.\n */\nexport enum EntityUpdateType {\n  /**\n   * Indicates the entity should be updated with new data.\n   */\n  update = 'update',\n  /**\n   * Indicates the entity should be removed from the system.\n   */\n  remove = 'remove'\n}\n\n/**\n * Represents a queued entity state change or removal.\n * Updates flow through the system to be processed by entity update handlers.\n */\nexport interface IEntityUpdate {\n  /**\n   * The type of operation: update or remove.\n   */\n  readonly type: EntityUpdateType;\n\n  /**\n   * The entity being affected by this update.\n   */\n  readonly entity: IEntityProxy;\n\n  /**\n   * Optional model data for initialization or reconfiguration.\n   */\n  readonly model?: IEntityModel;\n\n  /**\n   * Optional serialized state to apply to the entity.\n   */\n  readonly snapshot?: IEntitySnapshot;\n\n  /**\n   * Optional config-only component state to apply to the entity.\n   * When present on an update, the runtime applies it after `snapshot` and\n   * includes the config system phase in the same tick.\n   */\n  readonly config?: IEntityConfigSnapshot;\n}\n\n/**\n * Queue interface for managing pending entity updates.\n * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).\n * Updates are consumed by the runtime and dispatched to appropriate entity systems.\n */\nexport interface IEntityUpdateQueue {\n  /**\n   * The current number of updates in the queue.\n   */\n  readonly size: number;\n\n  /**\n   * Adds an update to the queue for processing.\n   * @param change - The update to queue.\n   */\n  enqueue(change: IEntityUpdate): void;\n\n  /**\n   * Removes and returns the next update from the queue.\n   * The specific update returned depends on the queue's prioritization strategy.\n   * @returns The next queued update.\n   */\n  dequeue(): IEntityUpdate;\n\n  /**\n   * Views the next update without removing it.\n   * Useful for inspection before dequeuing.\n   * @returns The next update in the queue.\n   */\n  peek(): IEntityUpdate;\n\n  /**\n   * Returns a read-only snapshot of all queued updates without removing them.\n   * Useful for inspection/debugging UIs.\n   * @returns An array of all currently queued updates.\n   */\n  items(): ReadonlyArray<IEntityUpdate>;\n\n  /**\n   * Removes all updates from the queue.\n   */\n  clear(): void;\n}\n","import { EntityTypeUid } from './entity';\nimport { IEntityProxy } from './entity-proxies';\n\n/**\n * Describes a scheduled entity update, including the target entity and optional interval.\n */\nexport type EntitySchedule = {\n  readonly proxy: IEntityProxy;\n  readonly intervalMs?: number;\n};\n\n/**\n * Controls which scheduling modes are paused.\n */\nexport enum SchedulerPauseType {\n  /** Pause both interval timers and frame subscriptions. */\n  full = 'full',\n  /** Pause only frame subscriptions. Interval timers continue firing. */\n  perFrame = 'perFrame',\n  /** Pause only interval timers. Frame subscriptions continue. */\n  intervals = 'intervals'\n}\n\n/**\n * Manages time-based scheduling of entity updates.\n *\n * Entities can be scheduled with an interval (timer-driven) or without one (per-frame).\n * The runtime pulls pending entities each tick via the {@link pending} iterator,\n * which yields both per-frame subscriptions and interval entities whose timer has fired.\n */\nexport interface IEntityScheduler {\n  /**\n   * Returns all currently scheduled entities with their configuration.\n   * Useful for inspection and debugging.\n   */\n  readonly schedules: ReadonlyArray<EntitySchedule>;\n\n  /**\n   * Yields entities pending processing this tick: per-frame subscriptions\n   * followed by interval entities whose timer has fired since the last drain.\n   * Iterating drains the due interval buckets; a second iteration without\n   * timer advancement yields only per-frame subscriptions.\n   */\n  readonly pending: IterableIterator<IEntityProxy>;\n\n  /**\n   * The set of entities scheduled for per-frame updates (no interval).\n   */\n  readonly frameSubscriptions: ReadonlySet<IEntityProxy>;\n\n  /**\n   * Entity types currently excluded from {@link pending} iteration.\n   */\n  readonly skippedEntityTypes: ReadonlySet<EntityTypeUid>;\n\n  /**\n   * The number of entities currently awaiting processing:\n   * per-frame subscriptions (if not paused) plus interval entities whose timer has fired.\n   */\n  readonly pendingCount: number;\n\n  /**\n   * Whether the scheduler is currently paused in any mode.\n   */\n  readonly isPaused: boolean;\n\n  /**\n   * Registers or replaces an entity schedule.\n   * @param entityProxy - The entity to schedule.\n   * @param intervalMs - Update frequency in milliseconds. If omitted, the entity is scheduled per-frame.\n   */\n  schedule(entityProxy: IEntityProxy, intervalMs?: number): void;\n\n  /**\n   * Unregisters an entity from the scheduler.\n   * @param entityProxy - The entity to unschedule.\n   */\n  remove(entityProxy: IEntityProxy): void;\n\n  /**\n   * Checks if an entity is currently scheduled for updates.\n   * @param entityProxy - The entity to check.\n   * @returns True if the entity is scheduled, false otherwise.\n   */\n  has(entityProxy: IEntityProxy): boolean;\n\n  /**\n   * Removes all schedules and clears all timers.\n   */\n  clear(): void;\n\n  /**\n   * Excludes an entity type from {@link pending} iteration.\n   * Entities remain registered; only yielding is suppressed.\n   */\n  skipEntityType(entityType: EntityTypeUid): void;\n\n  /**\n   * Re-includes a previously skipped entity type in {@link pending} iteration.\n   */\n  unskipEntityType(entityType: EntityTypeUid): void;\n\n  /**\n   * Pauses the scheduler.\n   * @param type - Which scheduling modes to pause. Defaults to {@link SchedulerPauseType.full}.\n   */\n  pause(type?: SchedulerPauseType): void;\n\n  /**\n   * Resumes the scheduler from any paused state.\n   */\n  resume(): void;\n}\n"],"mappings":";;;;;AASA,IAAY,mBAAL,yBAAA,kBAAA;;;;CAIL,iBAAA,YAAA;;;;CAIA,iBAAA,YAAA;;AACF,EAAA,CAAA,CAAA;;;;;;ACJA,IAAY,qBAAL,yBAAA,oBAAA;;CAEL,mBAAA,UAAA;;CAEA,mBAAA,cAAA;;CAEA,mBAAA,eAAA;;AACF,EAAA,CAAA,CAAA"}