import { r as Immutable } from "./types-Bbmnq4ni.cjs"; //#region src/components/config.d.ts /** * Extension point for application-specific config controls. * * Consumers can augment this interface to add extra controls while still * preserving value-aware option typing. * * @example * ```ts * declare module '@awesome-ecs/abstract/components' { * interface ConfigCustomControlOptions { * slider: NonNullable extends number * ? { readonly min?: number; readonly max?: number; readonly step?: number } * : never; * } * } * ``` */ interface ConfigCustomControlOptions {} /** * A generic configuration object for a component, where keys are config paths * and values are the corresponding config values. */ type ConfigRecord = Record; /** * Defines a single configuration option for a specific key in a component's config record. * If the config value is itself a nested config record, it can include an `inner` array of further config options. */ type ConfigOption = keyof TConfig & string extends infer K ? K extends keyof TConfig & string ? ConfigOptionForKey : never : never; type ConfigOptionForKey = ConfigOptionForValue, K>; type ConfigOptionForValue = ConfigNestedOptionForValue | ConfigLeafOptionForValue | ConfigCustomControlOption; type ConfigNestedOptionForValue = TValue extends readonly unknown[] ? never : TValue extends ((...args: never[]) => unknown) ? never : TValue extends object ? ConfigNestedOption : never; type ConfigLeafOptionForValue = [TValue] extends [number] ? ConfigNumberOption | ConfigChoiceOption> : [TValue] extends [boolean] ? ConfigBooleanOption | ConfigChoiceOption> : [TValue] extends [string] ? ConfigStringOption | ConfigColorOption | ConfigChoiceOption> : never; type ConfigCustomControlOption = { [TControl in keyof ConfigCustomControlOptions & string]: ConfigOptionBase & { readonly control: TControl; } & ConfigCustomControlOptions[TControl] }[keyof ConfigCustomControlOptions & string]; type ConfigNumberOption = ConfigOptionBase & { readonly control: 'number'; readonly min?: number; readonly max?: number; readonly step?: number; }; type ConfigBooleanOption = ConfigOptionBase & { readonly control: 'boolean'; }; type ConfigStringOption = ConfigOptionBase & { readonly control: 'string'; }; type ConfigColorOption = ConfigOptionBase & { readonly control: 'color'; }; type ConfigNestedOption = ConfigOptionBase & { readonly inner?: ConfigOption[]; }; type ConfigChoiceOption = ConfigOptionBase & { readonly control: 'select' | 'radio'; readonly options: ReadonlyArray>; }; type ConfigOptionBase = { readonly key: K; readonly label: string; readonly group?: string; }; type ConfigChoice = { readonly label: string; readonly value: TValue; }; type ConfigChoiceValue = string | number | boolean; //#endregion //#region src/components/component.d.ts type ComponentTypeUid = string | number; /** * The foundational data storage interface for all entity state. * Components are pure data holders without behavior. * They are the primary mechanism for organizing and accessing entity state. * Systems read and modify components to drive entity behavior. */ interface IComponent { /** * The unique type identifier for this component. * Enables type-safe component retrieval and categorization. */ readonly componentType: ComponentTypeUid; /** * Indicates whether this component's state should be included in entity snapshots. * Set to false for local-only state (UI, caches, transient data). * Set to true for state that needs replication or persistence. */ readonly isSerializable: boolean; /** * Optional version number for this component. * Useful for managing backwards-compatibility when component schemas evolve. * Allows deserialization to handle multiple component versions. */ readonly version?: number; /** * Optional custom serialization function. * Converts the component to a transmittable or storable format. * If not provided, standard JSON stringification is used. * @returns Serialized representation of the component. */ toJSON?(): string | object; /** * Optional custom deserialization function. * Updates the component's state from a previously serialized form. * If not provided, fields are overwritten directly from the target state. * @param targetState The serialized state to restore. */ load?(targetState: this): void; } /** * Component variant that exposes live, mutable configuration values. * * `config` is the runtime value object systems read from and config * updates patch into. */ interface IComponentWithConfig extends IComponent { readonly config: TConfig; } //#endregion //#region src/entities/entity-proxies.d.ts /** * Represents a reference (pointer) to another entity. * Proxies are the primary mechanism for establishing and maintaining relationships between entities, * enabling decoupled entity-to-entity communication without direct dependencies. */ interface IEntityProxy { /** * The type identifier of the entity being referenced. * Allows filtering and categorizing proxy relationships by entity type. */ readonly entityType: EntityTypeUid; /** * The unique identifier of the referenced entity instance. */ readonly entityUid: EntityUid; } /** * A typed variant of `IEntityProxy` that carries compile-time type information. * This allows IDEs to provide better type inference and type-checking when working with entity relationships. * * @template TEntity - The specific entity type that this proxy references. */ interface EntityProxy extends IEntityProxy {} /** * A helper type to create a typed entity proxy. */ type TypedEntityProxy = { entityType: T; entityUid: EntityUid; }; /** * A mapped type that transforms an array of EntityType into an array of TypedEntityProxy. */ type RequiredProxies = [...{ [I in keyof TProxyTypes]: TypedEntityProxy }, ...IEntityProxy[]]; /** * Central registry for managing entity-to-entity relationships through proxies. * Maintains bidirectional proxy links, ensuring consistency across all entity references. * This is the authoritative source for proxy data and manages the complete relationship lifecycle. */ interface IEntityProxyRepository { /** * Establishes a bidirectional proxy relationship between two entities. * @param source - The entity establishing the reference. * @param target - The entity being referenced. * @param cleanup - If true, removes existing proxies of the same type before registering new relationship. */ register(source: IEntityProxy, target: IEntityProxy, cleanup?: boolean): void; /** * Establishes multiple bidirectional proxy relationships for a source entity. * Efficiently batch-registers relationships to multiple target entities. * @param source - The entity establishing the references. * @param targets - The entities being referenced. * @param cleanup - If true, removes existing proxies of matching types before registering new relationships. */ registerMany(source: IEntityProxy, targets: readonly IEntityProxy[], cleanup?: boolean): void; /** * Removes a bidirectional proxy relationship between two entities. * @param source - The entity from which the reference is removed. * @param target - The entity whose reference is being removed. */ remove(source: IEntityProxy, target: IEntityProxy): void; /** * Removes all proxies from an entity, optionally filtered by target entity type. * Also cleans up corresponding back-references from target entities. * @param source - The entity from which proxies are removed. * @param targetType - Optional entity type filter. If provided, only proxies to entities of this type are removed. */ removeAllFor(source: IEntityProxy, targetType?: EntityTypeUid): void; /** * Retrieves a single proxy of a specific type for a source entity. * If multiple proxies of the same type exist, it returns the first one found. * @param source - The proxy of the source entity. * @param targetType - The entity type of the target proxy to retrieve. * @returns The entity proxy, or null if not found. */ get(source: IEntityProxy, targetType: EntityTypeUid): IEntityProxy | null; /** * Retrieves all proxies of a specific type for a source entity. * @param source - The proxy of the source entity. * @param targetType - The entity type of the target proxies to retrieve. * @returns A readonly array of entity proxies. */ getMany(source: IEntityProxy, targetType: EntityTypeUid): Readonly; /** * Retrieves all proxies for a source entity. * @param source - The proxy of the source entity. * @returns A readonly map of entity type UIDs to an array of their proxies. */ getAll(source: IEntityProxy): ReadonlyMap>; /** * Registers an entity as a scoped proxy, making it resolvable by any entity in the same scope. * Only entity types marked as scopeRoot or scopedProxy should be registered. * @param entity - The entity to register as a scoped proxy. * @param scopeId - The scope in which to register. */ setScopedProxy(entity: IEntityProxy, scopeId: string): void; /** * Retrieves a scoped proxy by scope ID and entity type. * @param scopeId - The scope to look up. * @param entityType - The entity type to resolve. * @returns The scoped proxy, or null if none exists. */ getScopedProxy(scopeId: string, entityType: EntityTypeUid): IEntityProxy | null; /** * Removes an entity from the scoped proxy index. * Called during entity cleanup to unregister from scope resolution. * @param entity - The entity to remove. * @param scopeId - The scope to remove from. */ removeScopedProxy(entity: IEntityProxy, scopeId: string): void; } //#endregion //#region src/entities/entity.d.ts /** * Represents the unique identifier for an entity type. * Can be either a string or a number. */ type EntityTypeUid = string | number; /** * Represents the unique identifier for an entity. * Can be either a string or a number. */ type EntityUid = string | number; /** * Represents the core identification and initialization data for an entity. * @template TProxyTypes - A readonly array of entity type IDs that must be provided as proxies when creating an entity. * When non-empty, the `proxies` property is required on the model. */ type IEntityModel = { /** * The unique identifier for this entity instance. */ readonly uid: EntityUid; /** * The scope this entity belongs to. * Automatically set by the framework — scopeRoot entities generate a UUID, * child entities inherit from their parent via addEntity(). */ readonly scopeId?: string; } & (TProxyTypes extends readonly [] ? { readonly proxies?: RequiredProxies; } : { readonly proxies: RequiredProxies; }); /** * The core entity interface representing a composition of components and relationships. * Entities are immutable containers that store data (components) and maintain relationships (proxies) to other entities. * State modifications occur exclusively through system operations, maintaining data integrity and enabling safe concurrent access. * * Implementations should provide strongly-typed accessors for components and proxies specific to their entity type, * enhancing IDE support and type safety without adding behavior beyond data access. */ interface IEntity { /** * The set of components attached to this entity. * Components are the primary data storage mechanism, mapped by their unique type identifiers. */ readonly components: ReadonlyMap; /** * The identity component containing core entity metadata and initialization information. * Every entity has exactly one identity component that persists for the entity's lifetime. */ readonly identity: Readonly>; /** * A reference to this entity's own proxy. */ readonly myProxy: Readonly>; } //#endregion //#region src/components/identity-component.d.ts /** * The `BasicComponentType` enum defines the types of basic components available. */ declare enum BasicComponentType { identity = "identity" } /** * The mandatory metadata component for every entity. * Contains core information that defines what an entity is and when it was last updated. * This component is immutable after creation and uniquely identifies each entity. * * @template TModel - The entity model type containing initialization data. */ interface IdentityComponent extends IComponent { /** * The entity type classification. * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories. */ readonly entityType: EntityTypeUid; /** * The initialization model for this entity. * Provides the minimal data structure used when the entity was first created. * Serves as a reference point for the entity's initial configuration. * * @type {Immutable} */ readonly model: Immutable; /** * The timestamp of the entity's last system update. * Useful for calculating elapsed time (delta time) between consecutive updates. * Helps systems make time-aware decisions. * * @type {Date | undefined} */ readonly lastUpdated?: Date; } //#endregion export { ConfigRecord as _, IEntity as a, IEntityProxy as c, TypedEntityProxy as d, ComponentTypeUid as f, ConfigOption as g, ConfigCustomControlOptions as h, EntityUid as i, IEntityProxyRepository as l, IComponentWithConfig as m, IdentityComponent as n, IEntityModel as o, IComponent as p, EntityTypeUid as r, EntityProxy as s, BasicComponentType as t, RequiredProxies as u }; //# sourceMappingURL=index-C5nragoq.d.cts.map