import { _ as ConfigRecord, a as IEntity, c as IEntityProxy, f as ComponentTypeUid, i as EntityUid, n as IdentityComponent, o as IEntityModel, p as IComponent, r as EntityTypeUid } from "./index-BlP67nCr.mjs"; import { n as DeepPartial } from "./types-C1ojaDL4.mjs"; //#region src/entities/entity-config.d.ts /** * Config-only entity state update. * * Unlike an entity snapshot, this payload is only for component-backed config * values. Runtime patches the matching component's `config` object after the * regular snapshot payload, then runs the config system phase before the normal * update/render/sync phases. */ interface IEntityConfigSnapshot { readonly components: Record>; } //#endregion //#region src/entities/entity-context-cache.d.ts /** * A generic per-entity key-value store for runtime contexts. * * Each package registers its own per-entity data using its own key constants. * Disposal removes all entries for an entity in a single call, covering all packages. * * @example * // Core stores SystemContext: * cache.set(entityUid, SYSTEM_KEY, systemContext); * * // AI stores per-module StateContexts: * cache.set(entityUid, `state:${moduleName}`, stateContext); * * // On removal, one call cleans up everything: * cache.disposeEntity(entityUid); */ interface IEntityContextCache { /** * Retrieves a cached value by entity UID and key. * @template T - The expected value type. * @param entityUid - The entity's unique identifier. * @param key - The key to look up. * @returns The cached value, or undefined if not found. */ get(entityUid: EntityUid, key: string | symbol): T | undefined; /** * Stores a value for an entity under the given key. * @param entityUid - The entity's unique identifier. * @param key - The key to store under. * @param value - The value to cache. */ set(entityUid: EntityUid, key: string | symbol, value: unknown): void; /** * Checks whether a cached entry exists. * @param entityUid - The entity's unique identifier. * @param key - Optional key to check. If omitted, checks if any entry exists for the entity. */ has(entityUid: EntityUid, key?: string | symbol): boolean; /** * Returns an iterator over all key-value pairs cached for the given entity. * @param entityUid - The entity's unique identifier. * @returns An iterable iterator of [key, value] pairs, or undefined if the entity has no entries. */ getEntries(entityUid: EntityUid): IterableIterator<[string | symbol, unknown]> | undefined; /** * Removes all cached entries for the given entity. * Should be called when an entity is removed from the system. * @param entityUid - The entity's unique identifier. */ disposeEntity(entityUid: EntityUid): void; } //#endregion //#region src/entities/entity-events.d.ts /** * Represents a unique identifier for an entity event. * Can be either a string or a number. */ type EntityEventUid = string | number; /** * A filter function for entity event subscriptions. * Returns true if the event should be processed, false otherwise. */ type EntityEventSubscriptionFilter = (event: IEntityEvent) => boolean; /** * The `IEventData` interface represents the data associated with an entity event. * It contains at least the `Event Unique Identifier`. */ interface IEventData { uid: EntityEventUid; } /** * Represents a publishable event in the entity system. * Enables loosely-coupled communication between entities through an Observer pattern. * Events include origin, optional target, and typed data payload. * * @template TEventData - The type of data carried by this event. */ interface IEntityEvent { /** * The entity that originated this event. */ origin: IEntityProxy; /** * Optional target entity for this event. * If omitted, the event is broadcast to all subscribers. */ target?: IEntityProxy; /** * The event payload containing type-specific data. */ data: TEventData; /** * The scope of the dispatching entity. * When set, the event is only delivered to subscribers in the same scope. */ scopeId?: string; } /** * Options for subscribing to an entity event. */ interface EntityEventSubscriptionOptions { /** * Optional function to determine which specific events are processed. */ filter?: EntityEventSubscriptionFilter; /** * The scope of the subscribing entity. * When set, the subscriber only receives events from the same scope. */ scopeId?: string; } /** * Manages subscriptions and dispatching for entity events. * Implements the Observer pattern to decouple event producers from consumers. * Tracks which entities are interested in which event types and maintains subscription state. */ interface IEntityEventsManager { /** * Subscribes an entity to a specific event type. * The entity will be notified when events of that type are dispatched. * @param uid - The event type to subscribe to. * @param entity - The entity registering for this event type. * @param options - Optional subscription options (filter, scopeId). */ subscribe(uid: EntityEventUid, entity: IEntityProxy, options?: EntityEventSubscriptionOptions): void; /** * Unsubscribes an entity from a specific event type. * The entity will no longer receive notifications for this event type. * @param uid - The event type to unsubscribe from. * @param entity - The entity unregistering from this event type. */ unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void; /** * Retrieves all entities subscribed to a specific event. * @param event - The event to get subscriptions for. * @returns Array of entities subscribed to this event. */ getSubscriptions(event: IEntityEvent): IEntityProxy[]; /** * Retrieves all event types an entity is subscribed to. * @param entity - The entity to query. * @returns Array of event type identifiers this entity is listening to. */ getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[]; /** * Removes all subscriptions system-wide. */ clearSubscriptions(): void; /** * Removes all subscriptions for a specific event type. * @param uid - The event type to remove subscriptions from. */ clearSubscriptionsForEvent(uid: EntityEventUid): void; /** * Removes all subscriptions for a specific entity. * @param entity - The entity to remove all subscriptions for. */ clearSubscriptionsForEntity(entity: IEntityProxy): void; } /** * Event dispatcher for publishing events to interested entities. * Responsible for routing events to their subscribers through the update queue. * * Use `dispatchEvent` / `dispatchEvents` for targeted delivery (requires explicit targets). * Use `broadcastEvent` / `broadcastEvents` for subscription-based delivery to all subscribers. */ interface IEntityEventsDispatcher { /** * Publishes a single event to one or more explicit targets. * The event is sent only to the specified target(s) — it does NOT fall back to subscriptions. * @param event - The event to dispatch. * @param target - The entity or entities to send the event to. */ dispatchEvent(event: IEntityEvent, target: IEntityProxy | IEntityProxy[]): void; /** * Publishes multiple events to one or more explicit targets. * Each target receives all events in a single update. * @param events - The events to dispatch. * @param target - The entity or entities to send the events to. */ dispatchEvents(events: IEntityEvent[], target: IEntityProxy | IEntityProxy[]): void; /** * Broadcasts a single event to all subscribers registered for that event type. * Uses the subscription registry to resolve targets. Use intentionally — this can * generate O(N) queue entries where N is the subscriber count. * @param event - The event to broadcast. */ broadcastEvent(event: IEntityEvent): void; /** * Broadcasts multiple events to all subscribers. * Events are grouped per subscriber so each receives a single update. * @param events - The events to broadcast. */ broadcastEvents(events: IEntityEvent[]): void; } //#endregion //#region src/entities/entity-snapshot.d.ts /** * A serializable representation of entity state. * Captures full or partial entity state including components, relationships, and events. * Snapshots enable state replication, persistence, and delta updates from external sources. */ interface IEntitySnapshot { /** * The entity's identity information if included in the snapshot. */ readonly identity?: Readonly>; /** * Entity components to be included in the snapshot. * Only components marked as serializable are typically included. */ readonly components?: IComponent[]; /** * Entity relationships (proxies) to include in the snapshot. */ readonly proxies?: IEntityProxy[]; /** * Events associated with the entity to include in the snapshot. */ readonly events?: IEntityEvent[]; } /** * Handles snapshot creation and application. * Provides abstraction for converting between entities and their serializable snapshots. * Used for state persistence, synchronization, and entity updates from external sources. */ interface IEntitySnapshotProvider { /** * Applies a snapshot state to an entity. * Updates the entity's components, relationships, and events based on the snapshot. * @param entity - The entity to update. * @param snapshot - The state to apply. */ applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void; /** * Creates a snapshot capturing the current state of an entity. * Serializes all or specified parts of the entity for storage or transmission. * @param entity - The entity to snapshot. * @returns A serializable representation of the entity state. */ createSnapshot(entity: IEntity): IEntitySnapshot; } //#endregion //#region src/entities/entity-queue.d.ts /** * Specifies the action to be performed on an entity. * Updates are categorized to enable different processing paths in the runtime. */ declare enum EntityUpdateType { /** * Indicates the entity should be updated with new data. */ update = "update", /** * Indicates the entity should be removed from the system. */ remove = "remove" } /** * Represents a queued entity state change or removal. * Updates flow through the system to be processed by entity update handlers. */ interface IEntityUpdate { /** * The type of operation: update or remove. */ readonly type: EntityUpdateType; /** * The entity being affected by this update. */ readonly entity: IEntityProxy; /** * Optional model data for initialization or reconfiguration. */ readonly model?: IEntityModel; /** * Optional serialized state to apply to the entity. */ readonly snapshot?: IEntitySnapshot; /** * Optional config-only component state to apply to the entity. * When present on an update, the runtime applies it after `snapshot` and * includes the config system phase in the same tick. */ readonly config?: IEntityConfigSnapshot; } /** * Queue interface for managing pending entity updates. * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type). * Updates are consumed by the runtime and dispatched to appropriate entity systems. */ interface IEntityUpdateQueue { /** * The current number of updates in the queue. */ readonly size: number; /** * Adds an update to the queue for processing. * @param change - The update to queue. */ enqueue(change: IEntityUpdate): void; /** * Removes and returns the next update from the queue. * The specific update returned depends on the queue's prioritization strategy. * @returns The next queued update. */ dequeue(): IEntityUpdate; /** * Views the next update without removing it. * Useful for inspection before dequeuing. * @returns The next update in the queue. */ peek(): IEntityUpdate; /** * Returns a read-only snapshot of all queued updates without removing them. * Useful for inspection/debugging UIs. * @returns An array of all currently queued updates. */ items(): ReadonlyArray; /** * Removes all updates from the queue. */ clear(): void; } //#endregion //#region src/entities/entity-repository.d.ts /** * Central storage for all active entities in the system. * The repository provides CRUD operations and is the source of truth for entity existence and state. * All entity access and modifications go through this repository. */ interface IEntityRepository { /** * The total number of entities currently stored. */ readonly size: number; /** * Checks if an entity exists in storage. * @param proxy - Reference to the entity to check. * @returns True if the entity exists, false otherwise. */ has(proxy: IEntityProxy): boolean; /** * Retrieves an entity from storage by proxy. * @template TEntity - The expected entity type. * @param proxy - Reference to the entity to retrieve. * @returns The requested entity. */ get(proxy: IEntityProxy): TEntity; /** * Retrieves all entities of a specific type. * @template TEntity - The entity type to retrieve. * @param entityType - The type identifier to filter by. * @returns Array of all entities matching the type. */ getAll(entityType: EntityTypeUid): TEntity[]; /** * Iterates over all entities regardless of type. * @returns An iterator over all stored entities. */ listAll(): IterableIterator; /** * Stores or updates an entity. * @param entity - The entity to store. */ set(entity: IEntity): void; /** * Removes an entity from storage. * @param proxy - Reference to the entity to remove. */ delete(proxy: IEntityProxy): void; /** * Removes all entities of a specific type from storage. * @param entityType - The type identifier for entities to remove. */ clear(entityType: EntityTypeUid): void; } //#endregion //#region src/entities/entity-scheduler.d.ts /** * Describes a scheduled entity update, including the target entity and optional interval. */ type EntitySchedule = { readonly proxy: IEntityProxy; readonly intervalMs?: number; }; /** * Controls which scheduling modes are paused. */ declare enum SchedulerPauseType { /** Pause both interval timers and frame subscriptions. */ full = "full", /** Pause only frame subscriptions. Interval timers continue firing. */ perFrame = "perFrame", /** Pause only interval timers. Frame subscriptions continue. */ intervals = "intervals" } /** * Manages time-based scheduling of entity updates. * * Entities can be scheduled with an interval (timer-driven) or without one (per-frame). * The runtime pulls pending entities each tick via the {@link pending} iterator, * which yields both per-frame subscriptions and interval entities whose timer has fired. */ interface IEntityScheduler { /** * Returns all currently scheduled entities with their configuration. * Useful for inspection and debugging. */ readonly schedules: ReadonlyArray; /** * Yields entities pending processing this tick: per-frame subscriptions * followed by interval entities whose timer has fired since the last drain. * Iterating drains the due interval buckets; a second iteration without * timer advancement yields only per-frame subscriptions. */ readonly pending: IterableIterator; /** * The set of entities scheduled for per-frame updates (no interval). */ readonly frameSubscriptions: ReadonlySet; /** * Entity types currently excluded from {@link pending} iteration. */ readonly skippedEntityTypes: ReadonlySet; /** * The number of entities currently awaiting processing: * per-frame subscriptions (if not paused) plus interval entities whose timer has fired. */ readonly pendingCount: number; /** * Whether the scheduler is currently paused in any mode. */ readonly isPaused: boolean; /** * Registers or replaces an entity schedule. * @param entityProxy - The entity to schedule. * @param intervalMs - Update frequency in milliseconds. If omitted, the entity is scheduled per-frame. */ schedule(entityProxy: IEntityProxy, intervalMs?: number): void; /** * Unregisters an entity from the scheduler. * @param entityProxy - The entity to unschedule. */ remove(entityProxy: IEntityProxy): void; /** * Checks if an entity is currently scheduled for updates. * @param entityProxy - The entity to check. * @returns True if the entity is scheduled, false otherwise. */ has(entityProxy: IEntityProxy): boolean; /** * Removes all schedules and clears all timers. */ clear(): void; /** * Excludes an entity type from {@link pending} iteration. * Entities remain registered; only yielding is suppressed. */ skipEntityType(entityType: EntityTypeUid): void; /** * Re-includes a previously skipped entity type in {@link pending} iteration. */ unskipEntityType(entityType: EntityTypeUid): void; /** * Pauses the scheduler. * @param type - Which scheduling modes to pause. Defaults to {@link SchedulerPauseType.full}. */ pause(type?: SchedulerPauseType): void; /** * Resumes the scheduler from any paused state. */ resume(): void; } //#endregion export { IEntityContextCache as _, EntityUpdateType as a, IEntitySnapshot as c, EntityEventSubscriptionOptions as d, EntityEventUid as f, IEventData as g, IEntityEventsManager as h, IEntityRepository as i, IEntitySnapshotProvider as l, IEntityEventsDispatcher as m, IEntityScheduler as n, IEntityUpdate as o, IEntityEvent as p, SchedulerPauseType as r, IEntityUpdateQueue as s, EntitySchedule as t, EntityEventSubscriptionFilter as u, IEntityConfigSnapshot as v }; //# sourceMappingURL=index-vpjRaGIC.d.mts.map