@awesome-ecs/abstract 0.32.1 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +119 -125
  2. package/dist/components/index.cjs.map +1 -1
  3. package/dist/components/index.d.cts +2 -2
  4. package/dist/components/index.d.mts +2 -2
  5. package/dist/components/index.mjs.map +1 -1
  6. package/dist/entities/index.cjs +5 -19
  7. package/dist/entities/index.cjs.map +1 -1
  8. package/dist/entities/index.d.cts +3 -3
  9. package/dist/entities/index.d.mts +3 -3
  10. package/dist/entities/index.mjs +5 -20
  11. package/dist/entities/index.mjs.map +1 -1
  12. package/dist/factories/index.cjs.map +1 -1
  13. package/dist/factories/index.d.cts +2 -2
  14. package/dist/factories/index.d.mts +2 -2
  15. package/dist/factories/index.mjs.map +1 -1
  16. package/dist/{index-CeqaKmWR.d.mts → index-B3DqdxE6.d.mts} +11 -11
  17. package/dist/{index-vpjRaGIC.d.mts → index-BanhgPCc.d.mts} +103 -262
  18. package/dist/{index-BD7sDB60.d.mts → index-BivyWazf.d.cts} +257 -407
  19. package/dist/{index-BOsrKTWm.d.cts → index-CSaKdQe-.d.cts} +103 -262
  20. package/dist/{index-BJFNTFDd.d.cts → index-DGyDijY7.d.mts} +257 -407
  21. package/dist/{index-C5nragoq.d.cts → index-DMZSrHoB.d.cts} +141 -100
  22. package/dist/{index-BlP67nCr.d.mts → index-Dbwzlrgp.d.mts} +141 -100
  23. package/dist/{index-DMTkNY1e.d.cts → index-aVjnG975.d.cts} +11 -11
  24. package/dist/pipelines/index.d.cts +2 -2
  25. package/dist/pipelines/index.d.mts +2 -2
  26. package/dist/systems/index.cjs +8 -5
  27. package/dist/systems/index.cjs.map +1 -1
  28. package/dist/systems/index.d.cts +90 -2
  29. package/dist/systems/index.d.mts +90 -2
  30. package/dist/systems/index.mjs +8 -5
  31. package/dist/systems/index.mjs.map +1 -1
  32. package/dist/{types-Bbmnq4ni.d.cts → types-BaCGIrym.d.cts} +19 -4
  33. package/dist/{types-C1ojaDL4.d.mts → types-BaCGIrym.d.mts} +19 -4
  34. package/dist/utils/index.cjs.map +1 -1
  35. package/dist/utils/index.d.cts +2 -2
  36. package/dist/utils/index.d.mts +2 -2
  37. package/dist/utils/index.mjs.map +1 -1
  38. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { r as Immutable } from "./types-Bbmnq4ni.cjs";
1
+ import { r as Immutable } from "./types-BaCGIrym.cjs";
2
2
 
3
3
  //#region src/components/config.d.ts
4
4
  /**
@@ -120,6 +120,117 @@ interface IComponentWithConfig<TConfig extends ConfigRecord> extends IComponent
120
120
  readonly config: TConfig;
121
121
  }
122
122
  //#endregion
123
+ //#region src/components/identity-component.d.ts
124
+ /**
125
+ * The `BasicComponentType` enum defines the types of basic components available.
126
+ */
127
+ declare enum BasicComponentType {
128
+ identity = "identity"
129
+ }
130
+ /**
131
+ * The mandatory metadata component for every entity.
132
+ * Contains core information that defines what an entity is and when it was last updated.
133
+ * This component is immutable after creation and uniquely identifies each entity.
134
+ *
135
+ * @template TModel - The entity model type containing initialization data.
136
+ */
137
+ interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
138
+ /**
139
+ * The entity type classification.
140
+ * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.
141
+ */
142
+ readonly entityType: EntityTypeUid;
143
+ /**
144
+ * The initialization model for this entity.
145
+ * Provides the minimal data structure used when the entity was first created.
146
+ * Serves as a reference point for the entity's initial configuration.
147
+ *
148
+ * @type {Immutable<TModel>}
149
+ */
150
+ readonly model: Immutable<TModel>;
151
+ /**
152
+ * The proxy for this entity, derived from `entityType` and `model.uid`.
153
+ */
154
+ readonly proxy: IEntityProxy;
155
+ /**
156
+ * The timestamp of the entity's last system update.
157
+ * Useful for calculating elapsed time (delta time) between consecutive updates.
158
+ * Helps systems make time-aware decisions.
159
+ *
160
+ * @type {Date | undefined}
161
+ */
162
+ readonly lastUpdated?: Date;
163
+ }
164
+ //#endregion
165
+ //#region src/entities/entity.d.ts
166
+ /**
167
+ * Represents the unique identifier for an entity type.
168
+ * Can be either a string or a number.
169
+ */
170
+ type EntityTypeUid = string | number;
171
+ /**
172
+ * Represents the unique identifier for an entity.
173
+ * Can be either a string or a number.
174
+ */
175
+ type EntityUid = string | number;
176
+ /**
177
+ * Represents the core identification and initialization data for an entity.
178
+ * @template TProxyTypes - A readonly array of entity type IDs that must be provided as proxies when creating an entity.
179
+ * Use `[]` for concrete models without creation-time proxies.
180
+ * Omit the generic only for broad infrastructure APIs that accept any model.
181
+ */
182
+ type IEntityModel<TProxyTypes extends readonly EntityTypeUid[] | void = void> = {
183
+ /**
184
+ * The unique identifier for this entity instance.
185
+ */
186
+ readonly uid: EntityUid;
187
+ /**
188
+ * The scope this entity belongs to.
189
+ * Automatically set by the framework — scopeRoot entities generate a UUID,
190
+ * child entities inherit from their parent via addEntity().
191
+ */
192
+ readonly scopeId?: string;
193
+ } & ([TProxyTypes] extends [void] ? {
194
+ readonly proxies?: Readonly<Record<EntityTypeUid, IEntityProxy>>;
195
+ } : TProxyTypes extends readonly [] ? {
196
+ readonly proxies?: Readonly<Record<EntityTypeUid, never>>;
197
+ } : TProxyTypes extends readonly EntityTypeUid[] ? {
198
+ readonly proxies: RequiredProxies<TProxyTypes>;
199
+ } : never);
200
+ declare const EntityModelType: unique symbol;
201
+ interface IEntityModelRef<TModel extends IEntityModel> {
202
+ readonly [EntityModelType]?: TModel;
203
+ }
204
+ /**
205
+ * Extract the model type carried by an entity's identity component.
206
+ */
207
+ type ModelOf<TEntity> = TEntity extends IEntityModelRef<infer TModel> ? TModel : IEntityModel;
208
+ /**
209
+ * Base entity contract.
210
+ *
211
+ * Concrete entity types extend this interface and declare their own component and proxy
212
+ * members directly, for example `readonly terrain: TerrainComponent` or
213
+ * `readonly gridProxy: EntityProxy<GridEntity>`.
214
+ */
215
+ interface IEntity {
216
+ /**
217
+ * The identity component containing core entity metadata and initialization information.
218
+ * Every entity has exactly one identity component that persists for the entity's lifetime.
219
+ */
220
+ readonly identity: Readonly<IdentityComponent<ModelOf<this>>>;
221
+ }
222
+ /**
223
+ * Entity contract carrying the concrete model type for `ModelOf<TEntity>` inference.
224
+ */
225
+ interface IEntityWith<TModel extends IEntityModel> extends IEntity, IEntityModelRef<TModel> {}
226
+ /**
227
+ * Runtime entity spec consumed by dispatchers.
228
+ */
229
+ type IEntitySpec<TEntity extends IEntity> = {
230
+ readonly type: EntityTypeUid;
231
+ readonly init: (model: ModelOf<TEntity>) => TEntity;
232
+ };
233
+ //#endregion
123
234
  //#region src/entities/entity-proxies.d.ts
124
235
  /**
125
236
  * Represents a reference (pointer) to another entity.
@@ -139,11 +250,13 @@ interface IEntityProxy {
139
250
  }
140
251
  /**
141
252
  * A typed variant of `IEntityProxy` that carries compile-time type information.
142
- * This allows IDEs to provide better type inference and type-checking when working with entity relationships.
253
+ * This allows IDEs to infer the entity type when resolving a proxy through a repository.
143
254
  *
144
255
  * @template TEntity - The specific entity type that this proxy references.
145
256
  */
146
257
  interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {}
258
+ type EntityProxyLookup<TEntity extends IEntity = IEntity> = EntityTypeUid | EntityProxy<TEntity>;
259
+ type EntityProxyManyLookup<TEntity extends IEntity = IEntity> = EntityProxyLookup<TEntity>;
147
260
  /**
148
261
  * A helper type to create a typed entity proxy.
149
262
  */
@@ -152,9 +265,17 @@ type TypedEntityProxy<T extends EntityTypeUid> = {
152
265
  entityUid: EntityUid;
153
266
  };
154
267
  /**
155
- * A mapped type that transforms an array of EntityType into an array of TypedEntityProxy.
268
+ * A model-level record of required entity proxies, keyed by entity type.
269
+ */
270
+ type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = { readonly [TType in TProxyTypes[number]]: TypedEntityProxy<TType> };
271
+ /**
272
+ * Extracts the union of EntityTypeUid values declared as required proxies on an entity model.
273
+ * Resolves to `never` if the model declares no required proxies, which makes proxy lookups
274
+ * via that union uncallable at compile time.
275
+ *
276
+ * @template TModel - The entity model to inspect.
156
277
  */
157
- type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = [...{ [I in keyof TProxyTypes]: TypedEntityProxy<TProxyTypes[I]> }, ...IEntityProxy[]];
278
+ type ProxyTypesOf<TModel> = TModel extends IEntityModel<infer P> ? P extends readonly EntityTypeUid[] ? P[number] : never : never;
158
279
  /**
159
280
  * Central registry for managing entity-to-entity relationships through proxies.
160
281
  * Maintains bidirectional proxy links, ensuring consistency across all entity references.
@@ -196,20 +317,20 @@ interface IEntityProxyRepository {
196
317
  * @param targetType - The entity type of the target proxy to retrieve.
197
318
  * @returns The entity proxy, or null if not found.
198
319
  */
199
- get(source: IEntityProxy, targetType: EntityTypeUid): IEntityProxy | null;
320
+ getProxy<TEntity extends IEntity = IEntity>(source: IEntityProxy, targetType: EntityTypeUid): EntityProxy<TEntity> | null;
200
321
  /**
201
322
  * Retrieves all proxies of a specific type for a source entity.
202
323
  * @param source - The proxy of the source entity.
203
324
  * @param targetType - The entity type of the target proxies to retrieve.
204
325
  * @returns A readonly array of entity proxies.
205
326
  */
206
- getMany(source: IEntityProxy, targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
327
+ getProxies<TEntity extends IEntity = IEntity>(source: IEntityProxy, targetType: EntityTypeUid): Readonly<EntityProxy<TEntity>[]>;
207
328
  /**
208
329
  * Retrieves all proxies for a source entity.
209
330
  * @param source - The proxy of the source entity.
210
331
  * @returns A readonly map of entity type UIDs to an array of their proxies.
211
332
  */
212
- getAll(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
333
+ getAllProxies(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
213
334
  /**
214
335
  * Registers an entity as a scoped proxy, making it resolvable by any entity in the same scope.
215
336
  * Only entity types marked as scopeRoot or scopedProxy should be registered.
@@ -223,7 +344,7 @@ interface IEntityProxyRepository {
223
344
  * @param entityType - The entity type to resolve.
224
345
  * @returns The scoped proxy, or null if none exists.
225
346
  */
226
- getScopedProxy(scopeId: string, entityType: EntityTypeUid): IEntityProxy | null;
347
+ getScopedProxy<TEntity extends IEntity = IEntity>(scopeId: string, entityType: EntityTypeUid): EntityProxy<TEntity> | null;
227
348
  /**
228
349
  * Removes an entity from the scoped proxy index.
229
350
  * Called during entity cleanup to unregister from scope resolution.
@@ -233,100 +354,20 @@ interface IEntityProxyRepository {
233
354
  removeScopedProxy(entity: IEntityProxy, scopeId: string): void;
234
355
  }
235
356
  //#endregion
236
- //#region src/entities/entity.d.ts
237
- /**
238
- * Represents the unique identifier for an entity type.
239
- * Can be either a string or a number.
240
- */
241
- type EntityTypeUid = string | number;
242
- /**
243
- * Represents the unique identifier for an entity.
244
- * Can be either a string or a number.
245
- */
246
- type EntityUid = string | number;
247
- /**
248
- * Represents the core identification and initialization data for an entity.
249
- * @template TProxyTypes - A readonly array of entity type IDs that must be provided as proxies when creating an entity.
250
- * When non-empty, the `proxies` property is required on the model.
251
- */
252
- type IEntityModel<TProxyTypes extends readonly EntityTypeUid[] = readonly []> = {
253
- /**
254
- * The unique identifier for this entity instance.
255
- */
256
- readonly uid: EntityUid;
257
- /**
258
- * The scope this entity belongs to.
259
- * Automatically set by the framework — scopeRoot entities generate a UUID,
260
- * child entities inherit from their parent via addEntity().
261
- */
262
- readonly scopeId?: string;
263
- } & (TProxyTypes extends readonly [] ? {
264
- readonly proxies?: RequiredProxies<TProxyTypes>;
265
- } : {
266
- readonly proxies: RequiredProxies<TProxyTypes>;
267
- });
268
- /**
269
- * The core entity interface representing a composition of components and relationships.
270
- * Entities are immutable containers that store data (components) and maintain relationships (proxies) to other entities.
271
- * State modifications occur exclusively through system operations, maintaining data integrity and enabling safe concurrent access.
272
- *
273
- * Implementations should provide strongly-typed accessors for components and proxies specific to their entity type,
274
- * enhancing IDE support and type safety without adding behavior beyond data access.
275
- */
276
- interface IEntity {
277
- /**
278
- * The set of components attached to this entity.
279
- * Components are the primary data storage mechanism, mapped by their unique type identifiers.
280
- */
281
- readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
282
- /**
283
- * The identity component containing core entity metadata and initialization information.
284
- * Every entity has exactly one identity component that persists for the entity's lifetime.
285
- */
286
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
287
- /**
288
- * A reference to this entity's own proxy.
289
- */
290
- readonly myProxy: Readonly<EntityProxy<this>>;
291
- }
292
- //#endregion
293
- //#region src/components/identity-component.d.ts
294
- /**
295
- * The `BasicComponentType` enum defines the types of basic components available.
296
- */
297
- declare enum BasicComponentType {
298
- identity = "identity"
299
- }
357
+ //#region src/components/component-repository.d.ts
300
358
  /**
301
- * The mandatory metadata component for every entity.
302
- * Contains core information that defines what an entity is and when it was last updated.
303
- * This component is immutable after creation and uniquely identifies each entity.
359
+ * The runtime source of truth for component instances, keyed by entity proxy.
304
360
  *
305
- * @template TModel - The entity model type containing initialization data.
361
+ * Generic `get<TComponent>` lets callsites narrow on demand without any global
362
+ * `ComponentTypeMap` augmentation. Most reads go through typed component fields on
363
+ * `context.entity`; direct `repository.get` is the escape hatch.
306
364
  */
307
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
308
- /**
309
- * The entity type classification.
310
- * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.
311
- */
312
- readonly entityType: EntityTypeUid;
313
- /**
314
- * The initialization model for this entity.
315
- * Provides the minimal data structure used when the entity was first created.
316
- * Serves as a reference point for the entity's initial configuration.
317
- *
318
- * @type {Immutable<TModel>}
319
- */
320
- readonly model: Immutable<TModel>;
321
- /**
322
- * The timestamp of the entity's last system update.
323
- * Useful for calculating elapsed time (delta time) between consecutive updates.
324
- * Helps systems make time-aware decisions.
325
- *
326
- * @type {Date | undefined}
327
- */
328
- readonly lastUpdated?: Date;
365
+ interface IComponentRepository {
366
+ setMany(key: IEntityProxy, components: readonly IComponent[]): void;
367
+ get<TComponent extends IComponent = IComponent>(key: IEntityProxy, type: ComponentTypeUid): TComponent | undefined;
368
+ getAll(key: IEntityProxy): readonly IComponent[];
369
+ removeAll(key: IEntityProxy): void;
329
370
  }
330
371
  //#endregion
331
- 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 };
332
- //# sourceMappingURL=index-C5nragoq.d.cts.map
372
+ export { ConfigCustomControlOptions as C, IComponentWithConfig as S, ConfigRecord as T, ModelOf as _, IEntityProxy as a, ComponentTypeUid as b, RequiredProxies as c, EntityUid as d, IEntity as f, IEntityWith as g, IEntitySpec as h, EntityProxyManyLookup as i, TypedEntityProxy as l, IEntityModelRef as m, EntityProxy as n, IEntityProxyRepository as o, IEntityModel as p, EntityProxyLookup as r, ProxyTypesOf as s, IComponentRepository as t, EntityTypeUid as u, BasicComponentType as v, ConfigOption as w, IComponent as x, IdentityComponent as y };
373
+ //# sourceMappingURL=index-DMZSrHoB.d.cts.map
@@ -1,4 +1,4 @@
1
- import { r as Immutable } from "./types-C1ojaDL4.mjs";
1
+ import { r as Immutable } from "./types-BaCGIrym.mjs";
2
2
 
3
3
  //#region src/components/config.d.ts
4
4
  /**
@@ -120,6 +120,117 @@ interface IComponentWithConfig<TConfig extends ConfigRecord> extends IComponent
120
120
  readonly config: TConfig;
121
121
  }
122
122
  //#endregion
123
+ //#region src/components/identity-component.d.ts
124
+ /**
125
+ * The `BasicComponentType` enum defines the types of basic components available.
126
+ */
127
+ declare enum BasicComponentType {
128
+ identity = "identity"
129
+ }
130
+ /**
131
+ * The mandatory metadata component for every entity.
132
+ * Contains core information that defines what an entity is and when it was last updated.
133
+ * This component is immutable after creation and uniquely identifies each entity.
134
+ *
135
+ * @template TModel - The entity model type containing initialization data.
136
+ */
137
+ interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
138
+ /**
139
+ * The entity type classification.
140
+ * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.
141
+ */
142
+ readonly entityType: EntityTypeUid;
143
+ /**
144
+ * The initialization model for this entity.
145
+ * Provides the minimal data structure used when the entity was first created.
146
+ * Serves as a reference point for the entity's initial configuration.
147
+ *
148
+ * @type {Immutable<TModel>}
149
+ */
150
+ readonly model: Immutable<TModel>;
151
+ /**
152
+ * The proxy for this entity, derived from `entityType` and `model.uid`.
153
+ */
154
+ readonly proxy: IEntityProxy;
155
+ /**
156
+ * The timestamp of the entity's last system update.
157
+ * Useful for calculating elapsed time (delta time) between consecutive updates.
158
+ * Helps systems make time-aware decisions.
159
+ *
160
+ * @type {Date | undefined}
161
+ */
162
+ readonly lastUpdated?: Date;
163
+ }
164
+ //#endregion
165
+ //#region src/entities/entity.d.ts
166
+ /**
167
+ * Represents the unique identifier for an entity type.
168
+ * Can be either a string or a number.
169
+ */
170
+ type EntityTypeUid = string | number;
171
+ /**
172
+ * Represents the unique identifier for an entity.
173
+ * Can be either a string or a number.
174
+ */
175
+ type EntityUid = string | number;
176
+ /**
177
+ * Represents the core identification and initialization data for an entity.
178
+ * @template TProxyTypes - A readonly array of entity type IDs that must be provided as proxies when creating an entity.
179
+ * Use `[]` for concrete models without creation-time proxies.
180
+ * Omit the generic only for broad infrastructure APIs that accept any model.
181
+ */
182
+ type IEntityModel<TProxyTypes extends readonly EntityTypeUid[] | void = void> = {
183
+ /**
184
+ * The unique identifier for this entity instance.
185
+ */
186
+ readonly uid: EntityUid;
187
+ /**
188
+ * The scope this entity belongs to.
189
+ * Automatically set by the framework — scopeRoot entities generate a UUID,
190
+ * child entities inherit from their parent via addEntity().
191
+ */
192
+ readonly scopeId?: string;
193
+ } & ([TProxyTypes] extends [void] ? {
194
+ readonly proxies?: Readonly<Record<EntityTypeUid, IEntityProxy>>;
195
+ } : TProxyTypes extends readonly [] ? {
196
+ readonly proxies?: Readonly<Record<EntityTypeUid, never>>;
197
+ } : TProxyTypes extends readonly EntityTypeUid[] ? {
198
+ readonly proxies: RequiredProxies<TProxyTypes>;
199
+ } : never);
200
+ declare const EntityModelType: unique symbol;
201
+ interface IEntityModelRef<TModel extends IEntityModel> {
202
+ readonly [EntityModelType]?: TModel;
203
+ }
204
+ /**
205
+ * Extract the model type carried by an entity's identity component.
206
+ */
207
+ type ModelOf<TEntity> = TEntity extends IEntityModelRef<infer TModel> ? TModel : IEntityModel;
208
+ /**
209
+ * Base entity contract.
210
+ *
211
+ * Concrete entity types extend this interface and declare their own component and proxy
212
+ * members directly, for example `readonly terrain: TerrainComponent` or
213
+ * `readonly gridProxy: EntityProxy<GridEntity>`.
214
+ */
215
+ interface IEntity {
216
+ /**
217
+ * The identity component containing core entity metadata and initialization information.
218
+ * Every entity has exactly one identity component that persists for the entity's lifetime.
219
+ */
220
+ readonly identity: Readonly<IdentityComponent<ModelOf<this>>>;
221
+ }
222
+ /**
223
+ * Entity contract carrying the concrete model type for `ModelOf<TEntity>` inference.
224
+ */
225
+ interface IEntityWith<TModel extends IEntityModel> extends IEntity, IEntityModelRef<TModel> {}
226
+ /**
227
+ * Runtime entity spec consumed by dispatchers.
228
+ */
229
+ type IEntitySpec<TEntity extends IEntity> = {
230
+ readonly type: EntityTypeUid;
231
+ readonly init: (model: ModelOf<TEntity>) => TEntity;
232
+ };
233
+ //#endregion
123
234
  //#region src/entities/entity-proxies.d.ts
124
235
  /**
125
236
  * Represents a reference (pointer) to another entity.
@@ -139,11 +250,13 @@ interface IEntityProxy {
139
250
  }
140
251
  /**
141
252
  * A typed variant of `IEntityProxy` that carries compile-time type information.
142
- * This allows IDEs to provide better type inference and type-checking when working with entity relationships.
253
+ * This allows IDEs to infer the entity type when resolving a proxy through a repository.
143
254
  *
144
255
  * @template TEntity - The specific entity type that this proxy references.
145
256
  */
146
257
  interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {}
258
+ type EntityProxyLookup<TEntity extends IEntity = IEntity> = EntityTypeUid | EntityProxy<TEntity>;
259
+ type EntityProxyManyLookup<TEntity extends IEntity = IEntity> = EntityProxyLookup<TEntity>;
147
260
  /**
148
261
  * A helper type to create a typed entity proxy.
149
262
  */
@@ -152,9 +265,17 @@ type TypedEntityProxy<T extends EntityTypeUid> = {
152
265
  entityUid: EntityUid;
153
266
  };
154
267
  /**
155
- * A mapped type that transforms an array of EntityType into an array of TypedEntityProxy.
268
+ * A model-level record of required entity proxies, keyed by entity type.
269
+ */
270
+ type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = { readonly [TType in TProxyTypes[number]]: TypedEntityProxy<TType> };
271
+ /**
272
+ * Extracts the union of EntityTypeUid values declared as required proxies on an entity model.
273
+ * Resolves to `never` if the model declares no required proxies, which makes proxy lookups
274
+ * via that union uncallable at compile time.
275
+ *
276
+ * @template TModel - The entity model to inspect.
156
277
  */
157
- type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = [...{ [I in keyof TProxyTypes]: TypedEntityProxy<TProxyTypes[I]> }, ...IEntityProxy[]];
278
+ type ProxyTypesOf<TModel> = TModel extends IEntityModel<infer P> ? P extends readonly EntityTypeUid[] ? P[number] : never : never;
158
279
  /**
159
280
  * Central registry for managing entity-to-entity relationships through proxies.
160
281
  * Maintains bidirectional proxy links, ensuring consistency across all entity references.
@@ -196,20 +317,20 @@ interface IEntityProxyRepository {
196
317
  * @param targetType - The entity type of the target proxy to retrieve.
197
318
  * @returns The entity proxy, or null if not found.
198
319
  */
199
- get(source: IEntityProxy, targetType: EntityTypeUid): IEntityProxy | null;
320
+ getProxy<TEntity extends IEntity = IEntity>(source: IEntityProxy, targetType: EntityTypeUid): EntityProxy<TEntity> | null;
200
321
  /**
201
322
  * Retrieves all proxies of a specific type for a source entity.
202
323
  * @param source - The proxy of the source entity.
203
324
  * @param targetType - The entity type of the target proxies to retrieve.
204
325
  * @returns A readonly array of entity proxies.
205
326
  */
206
- getMany(source: IEntityProxy, targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
327
+ getProxies<TEntity extends IEntity = IEntity>(source: IEntityProxy, targetType: EntityTypeUid): Readonly<EntityProxy<TEntity>[]>;
207
328
  /**
208
329
  * Retrieves all proxies for a source entity.
209
330
  * @param source - The proxy of the source entity.
210
331
  * @returns A readonly map of entity type UIDs to an array of their proxies.
211
332
  */
212
- getAll(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
333
+ getAllProxies(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
213
334
  /**
214
335
  * Registers an entity as a scoped proxy, making it resolvable by any entity in the same scope.
215
336
  * Only entity types marked as scopeRoot or scopedProxy should be registered.
@@ -223,7 +344,7 @@ interface IEntityProxyRepository {
223
344
  * @param entityType - The entity type to resolve.
224
345
  * @returns The scoped proxy, or null if none exists.
225
346
  */
226
- getScopedProxy(scopeId: string, entityType: EntityTypeUid): IEntityProxy | null;
347
+ getScopedProxy<TEntity extends IEntity = IEntity>(scopeId: string, entityType: EntityTypeUid): EntityProxy<TEntity> | null;
227
348
  /**
228
349
  * Removes an entity from the scoped proxy index.
229
350
  * Called during entity cleanup to unregister from scope resolution.
@@ -233,100 +354,20 @@ interface IEntityProxyRepository {
233
354
  removeScopedProxy(entity: IEntityProxy, scopeId: string): void;
234
355
  }
235
356
  //#endregion
236
- //#region src/entities/entity.d.ts
237
- /**
238
- * Represents the unique identifier for an entity type.
239
- * Can be either a string or a number.
240
- */
241
- type EntityTypeUid = string | number;
242
- /**
243
- * Represents the unique identifier for an entity.
244
- * Can be either a string or a number.
245
- */
246
- type EntityUid = string | number;
247
- /**
248
- * Represents the core identification and initialization data for an entity.
249
- * @template TProxyTypes - A readonly array of entity type IDs that must be provided as proxies when creating an entity.
250
- * When non-empty, the `proxies` property is required on the model.
251
- */
252
- type IEntityModel<TProxyTypes extends readonly EntityTypeUid[] = readonly []> = {
253
- /**
254
- * The unique identifier for this entity instance.
255
- */
256
- readonly uid: EntityUid;
257
- /**
258
- * The scope this entity belongs to.
259
- * Automatically set by the framework — scopeRoot entities generate a UUID,
260
- * child entities inherit from their parent via addEntity().
261
- */
262
- readonly scopeId?: string;
263
- } & (TProxyTypes extends readonly [] ? {
264
- readonly proxies?: RequiredProxies<TProxyTypes>;
265
- } : {
266
- readonly proxies: RequiredProxies<TProxyTypes>;
267
- });
268
- /**
269
- * The core entity interface representing a composition of components and relationships.
270
- * Entities are immutable containers that store data (components) and maintain relationships (proxies) to other entities.
271
- * State modifications occur exclusively through system operations, maintaining data integrity and enabling safe concurrent access.
272
- *
273
- * Implementations should provide strongly-typed accessors for components and proxies specific to their entity type,
274
- * enhancing IDE support and type safety without adding behavior beyond data access.
275
- */
276
- interface IEntity {
277
- /**
278
- * The set of components attached to this entity.
279
- * Components are the primary data storage mechanism, mapped by their unique type identifiers.
280
- */
281
- readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
282
- /**
283
- * The identity component containing core entity metadata and initialization information.
284
- * Every entity has exactly one identity component that persists for the entity's lifetime.
285
- */
286
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
287
- /**
288
- * A reference to this entity's own proxy.
289
- */
290
- readonly myProxy: Readonly<EntityProxy<this>>;
291
- }
292
- //#endregion
293
- //#region src/components/identity-component.d.ts
294
- /**
295
- * The `BasicComponentType` enum defines the types of basic components available.
296
- */
297
- declare enum BasicComponentType {
298
- identity = "identity"
299
- }
357
+ //#region src/components/component-repository.d.ts
300
358
  /**
301
- * The mandatory metadata component for every entity.
302
- * Contains core information that defines what an entity is and when it was last updated.
303
- * This component is immutable after creation and uniquely identifies each entity.
359
+ * The runtime source of truth for component instances, keyed by entity proxy.
304
360
  *
305
- * @template TModel - The entity model type containing initialization data.
361
+ * Generic `get<TComponent>` lets callsites narrow on demand without any global
362
+ * `ComponentTypeMap` augmentation. Most reads go through typed component fields on
363
+ * `context.entity`; direct `repository.get` is the escape hatch.
306
364
  */
307
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
308
- /**
309
- * The entity type classification.
310
- * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.
311
- */
312
- readonly entityType: EntityTypeUid;
313
- /**
314
- * The initialization model for this entity.
315
- * Provides the minimal data structure used when the entity was first created.
316
- * Serves as a reference point for the entity's initial configuration.
317
- *
318
- * @type {Immutable<TModel>}
319
- */
320
- readonly model: Immutable<TModel>;
321
- /**
322
- * The timestamp of the entity's last system update.
323
- * Useful for calculating elapsed time (delta time) between consecutive updates.
324
- * Helps systems make time-aware decisions.
325
- *
326
- * @type {Date | undefined}
327
- */
328
- readonly lastUpdated?: Date;
365
+ interface IComponentRepository {
366
+ setMany(key: IEntityProxy, components: readonly IComponent[]): void;
367
+ get<TComponent extends IComponent = IComponent>(key: IEntityProxy, type: ComponentTypeUid): TComponent | undefined;
368
+ getAll(key: IEntityProxy): readonly IComponent[];
369
+ removeAll(key: IEntityProxy): void;
329
370
  }
330
371
  //#endregion
331
- 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 };
332
- //# sourceMappingURL=index-BlP67nCr.d.mts.map
372
+ export { ConfigCustomControlOptions as C, IComponentWithConfig as S, ConfigRecord as T, ModelOf as _, IEntityProxy as a, ComponentTypeUid as b, RequiredProxies as c, EntityUid as d, IEntity as f, IEntityWith as g, IEntitySpec as h, EntityProxyManyLookup as i, TypedEntityProxy as l, IEntityModelRef as m, EntityProxy as n, IEntityProxyRepository as o, IEntityModel as p, EntityProxyLookup as r, ProxyTypesOf as s, IComponentRepository as t, EntityTypeUid as u, BasicComponentType as v, ConfigOption as w, IComponent as x, IdentityComponent as y };
373
+ //# sourceMappingURL=index-Dbwzlrgp.d.mts.map
@@ -1,4 +1,4 @@
1
- import { r as Immutable } from "./types-Bbmnq4ni.cjs";
1
+ import { r as Immutable } from "./types-BaCGIrym.cjs";
2
2
 
3
3
  //#region src/pipelines/pipeline-context.d.ts
4
4
  /**
@@ -7,16 +7,16 @@ import { r as Immutable } from "./types-Bbmnq4ni.cjs";
7
7
  */
8
8
  interface IPipelineContext {
9
9
  /**
10
- * The runtime state and control interface for the pipeline.
10
+ * The dispatch state and control interface for the pipeline.
11
11
  * Allows middleware to query and influence pipeline behavior.
12
12
  */
13
- readonly runtime?: PipelineRuntime;
13
+ readonly dispatch?: PipelineDispatch;
14
14
  }
15
15
  /**
16
- * Runtime state and control interface for pipeline execution.
16
+ * Dispatch state and control interface for pipeline execution.
17
17
  * Allows middleware to query status and influence pipeline flow.
18
18
  */
19
- type PipelineRuntime = {
19
+ type PipelineDispatch = {
20
20
  /**
21
21
  * Flag to request pipeline halt.
22
22
  * Set to true to stop executing remaining middleware (cleanup still runs).
@@ -25,7 +25,7 @@ type PipelineRuntime = {
25
25
  /**
26
26
  * Optional error state if an exception occurred during execution.
27
27
  */
28
- error?: any;
28
+ error?: unknown;
29
29
  };
30
30
  //#endregion
31
31
  //#region src/pipelines/middleware.d.ts
@@ -198,12 +198,12 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
198
198
  /**
199
199
  * Executes the action phase of all middleware in sequence.
200
200
  * Middleware at startIndex and onward are executed in order.
201
- * Execution may terminate early if middleware requests it via context.runtime.shouldStop.
201
+ * Execution may terminate early if middleware requests it via context.dispatch.shouldStop.
202
202
  * @param context - The context passed to each middleware action.
203
203
  * @param middleware - The ordered middleware array to execute.
204
204
  * @param startIndex - Optional starting position in the middleware array (default: 0).
205
205
  */
206
- dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): void | Promise<void>;
206
+ dispatch(context: Partial<TContext>, middleware: readonly IMiddleware<TContext>[], startIndex?: number): void | Promise<void>;
207
207
  /**
208
208
  * Executes the cleanup phase of all middleware in reverse order.
209
209
  * All middleware cleanup functions are called (if defined), regardless of errors.
@@ -211,8 +211,8 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
211
211
  * @param context - The context passed to each middleware cleanup.
212
212
  * @param middleware - The ordered middleware array for cleanup (reversed during execution).
213
213
  */
214
- cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): void | Promise<void>;
214
+ cleanup(context: Partial<TContext>, middleware: readonly IMiddleware<TContext>[]): void | Promise<void>;
215
215
  }
216
216
  //#endregion
217
- export { IParentMiddleware as a, IMiddleware as c, IParentContext as i, IPipelineContext as l, INestedContext as n, IPipeline as o, INestedMiddleware as r, IMiddlewareRunner as s, IPipelineRunner as t, PipelineRuntime as u };
218
- //# sourceMappingURL=index-DMTkNY1e.d.cts.map
217
+ export { IParentMiddleware as a, IMiddleware as c, IParentContext as i, IPipelineContext as l, INestedContext as n, IPipeline as o, INestedMiddleware as r, IMiddlewareRunner as s, IPipelineRunner as t, PipelineDispatch as u };
218
+ //# sourceMappingURL=index-aVjnG975.d.cts.map