@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,6 +1,15 @@
1
- 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-C5nragoq.cjs";
2
- import { n as DeepPartial } from "./types-Bbmnq4ni.cjs";
1
+ import { T as ConfigRecord, a as IEntityProxy, b as ComponentTypeUid, f as IEntity, p as IEntityModel, u as EntityTypeUid, x as IComponent, y as IdentityComponent } from "./index-DMZSrHoB.cjs";
2
+ import { n as DeepPartial } from "./types-BaCGIrym.cjs";
3
3
 
4
+ //#region src/entities/context-repository.d.ts
5
+ declare const SYSTEM_CONTEXT_KEY: unique symbol;
6
+ interface IContextRepository {
7
+ get<TContext>(proxy: IEntityProxy, key: string | symbol): TContext | undefined;
8
+ set<TContext>(proxy: IEntityProxy, key: string | symbol, context: TContext): TContext;
9
+ delete(proxy: IEntityProxy, key: string | symbol): boolean;
10
+ deleteAll(proxy: IEntityProxy): boolean;
11
+ }
12
+ //#endregion
4
13
  //#region src/entities/entity-config.d.ts
5
14
  /**
6
15
  * Config-only entity state update.
@@ -14,59 +23,6 @@ interface IEntityConfigSnapshot<TConfig extends ConfigRecord = ConfigRecord> {
14
23
  readonly components: Record<ComponentTypeUid, DeepPartial<TConfig>>;
15
24
  }
16
25
  //#endregion
17
- //#region src/entities/entity-context-cache.d.ts
18
- /**
19
- * A generic per-entity key-value store for runtime contexts.
20
- *
21
- * Each package registers its own per-entity data using its own key constants.
22
- * Disposal removes all entries for an entity in a single call, covering all packages.
23
- *
24
- * @example
25
- * // Core stores SystemContext:
26
- * cache.set(entityUid, SYSTEM_KEY, systemContext);
27
- *
28
- * // AI stores per-module StateContexts:
29
- * cache.set(entityUid, `state:${moduleName}`, stateContext);
30
- *
31
- * // On removal, one call cleans up everything:
32
- * cache.disposeEntity(entityUid);
33
- */
34
- interface IEntityContextCache {
35
- /**
36
- * Retrieves a cached value by entity UID and key.
37
- * @template T - The expected value type.
38
- * @param entityUid - The entity's unique identifier.
39
- * @param key - The key to look up.
40
- * @returns The cached value, or undefined if not found.
41
- */
42
- get<T>(entityUid: EntityUid, key: string | symbol): T | undefined;
43
- /**
44
- * Stores a value for an entity under the given key.
45
- * @param entityUid - The entity's unique identifier.
46
- * @param key - The key to store under.
47
- * @param value - The value to cache.
48
- */
49
- set(entityUid: EntityUid, key: string | symbol, value: unknown): void;
50
- /**
51
- * Checks whether a cached entry exists.
52
- * @param entityUid - The entity's unique identifier.
53
- * @param key - Optional key to check. If omitted, checks if any entry exists for the entity.
54
- */
55
- has(entityUid: EntityUid, key?: string | symbol): boolean;
56
- /**
57
- * Returns an iterator over all key-value pairs cached for the given entity.
58
- * @param entityUid - The entity's unique identifier.
59
- * @returns An iterable iterator of [key, value] pairs, or undefined if the entity has no entries.
60
- */
61
- getEntries(entityUid: EntityUid): IterableIterator<[string | symbol, unknown]> | undefined;
62
- /**
63
- * Removes all cached entries for the given entity.
64
- * Should be called when an entity is removed from the system.
65
- * @param entityUid - The entity's unique identifier.
66
- */
67
- disposeEntity(entityUid: EntityUid): void;
68
- }
69
- //#endregion
70
26
  //#region src/entities/entity-events.d.ts
71
27
  /**
72
28
  * Represents a unique identifier for an entity event.
@@ -211,6 +167,59 @@ interface IEntityEventsDispatcher {
211
167
  broadcastEvents(events: IEntityEvent<IEventData>[]): void;
212
168
  }
213
169
  //#endregion
170
+ //#region src/entities/entity-repository.d.ts
171
+ /**
172
+ * Central storage for all active entities in the system.
173
+ * The repository provides CRUD operations and is the source of truth for entity existence and state.
174
+ * All entity access and modifications go through this repository.
175
+ */
176
+ interface IEntityRepository {
177
+ /**
178
+ * The total number of entities currently stored.
179
+ */
180
+ readonly size: number;
181
+ /**
182
+ * Checks if an entity exists in storage.
183
+ * @param proxy - Reference to the entity to check.
184
+ * @returns True if the entity exists, false otherwise.
185
+ */
186
+ has(proxy: IEntityProxy): boolean;
187
+ /**
188
+ * Retrieves an entity from storage by proxy.
189
+ * @template TEntity - The expected entity type.
190
+ * @param proxy - Reference to the entity to retrieve.
191
+ * @returns The requested entity.
192
+ */
193
+ getEntity<TEntity extends IEntity>(proxy: IEntityProxy): TEntity | undefined;
194
+ /**
195
+ * Retrieves all entities of a specific type.
196
+ * @template TEntity - The entity type to retrieve.
197
+ * @param entityType - The type identifier to filter by.
198
+ * @returns Array of all entities matching the type.
199
+ */
200
+ getEntities<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
201
+ /**
202
+ * Iterates over all entities regardless of type.
203
+ * @returns An iterator over all stored entities.
204
+ */
205
+ listAll(): IterableIterator<IEntity>;
206
+ /**
207
+ * Stores or updates an entity.
208
+ * @param entity - The entity to store.
209
+ */
210
+ set<TEntity extends IEntity>(entity: TEntity): TEntity;
211
+ /**
212
+ * Removes an entity from storage.
213
+ * @param proxy - Reference to the entity to remove.
214
+ */
215
+ delete(proxy: IEntityProxy): void;
216
+ /**
217
+ * Removes all entities of a specific type from storage.
218
+ * @param entityType - The type identifier for entities to remove.
219
+ */
220
+ clear(entityType: EntityTypeUid): void;
221
+ }
222
+ //#endregion
214
223
  //#region src/entities/entity-snapshot.d.ts
215
224
  /**
216
225
  * A serializable representation of entity state.
@@ -258,237 +267,69 @@ interface IEntitySnapshotProvider {
258
267
  createSnapshot(entity: IEntity): IEntitySnapshot;
259
268
  }
260
269
  //#endregion
261
- //#region src/entities/entity-queue.d.ts
262
- /**
263
- * Specifies the action to be performed on an entity.
264
- * Updates are categorized to enable different processing paths in the runtime.
265
- */
270
+ //#region src/entities/entity-scheduler.d.ts
266
271
  declare enum EntityUpdateType {
267
- /**
268
- * Indicates the entity should be updated with new data.
269
- */
270
272
  update = "update",
271
- /**
272
- * Indicates the entity should be removed from the system.
273
- */
274
273
  remove = "remove"
275
274
  }
276
- /**
277
- * Represents a queued entity state change or removal.
278
- * Updates flow through the system to be processed by entity update handlers.
279
- */
280
275
  interface IEntityUpdate {
281
- /**
282
- * The type of operation: update or remove.
283
- */
284
276
  readonly type: EntityUpdateType;
285
- /**
286
- * The entity being affected by this update.
287
- */
288
277
  readonly entity: IEntityProxy;
289
- /**
290
- * Optional model data for initialization or reconfiguration.
291
- */
292
278
  readonly model?: IEntityModel;
293
- /**
294
- * Optional serialized state to apply to the entity.
295
- */
296
279
  readonly snapshot?: IEntitySnapshot;
297
- /**
298
- * Optional config-only component state to apply to the entity.
299
- * When present on an update, the runtime applies it after `snapshot` and
300
- * includes the config system phase in the same tick.
301
- */
302
280
  readonly config?: IEntityConfigSnapshot;
303
281
  }
304
- /**
305
- * Queue interface for managing pending entity updates.
306
- * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).
307
- * Updates are consumed by the runtime and dispatched to appropriate entity systems.
308
- */
309
- interface IEntityUpdateQueue {
310
- /**
311
- * The current number of updates in the queue.
312
- */
313
- readonly size: number;
314
- /**
315
- * Adds an update to the queue for processing.
316
- * @param change - The update to queue.
317
- */
318
- enqueue(change: IEntityUpdate): void;
319
- /**
320
- * Removes and returns the next update from the queue.
321
- * The specific update returned depends on the queue's prioritization strategy.
322
- * @returns The next queued update.
323
- */
324
- dequeue(): IEntityUpdate;
325
- /**
326
- * Views the next update without removing it.
327
- * Useful for inspection before dequeuing.
328
- * @returns The next update in the queue.
329
- */
330
- peek(): IEntityUpdate;
331
- /**
332
- * Returns a read-only snapshot of all queued updates without removing them.
333
- * Useful for inspection/debugging UIs.
334
- * @returns An array of all currently queued updates.
335
- */
336
- items(): ReadonlyArray<IEntityUpdate>;
337
- /**
338
- * Removes all updates from the queue.
339
- */
340
- clear(): void;
341
- }
342
- //#endregion
343
- //#region src/entities/entity-repository.d.ts
344
- /**
345
- * Central storage for all active entities in the system.
346
- * The repository provides CRUD operations and is the source of truth for entity existence and state.
347
- * All entity access and modifications go through this repository.
348
- */
349
- interface IEntityRepository {
350
- /**
351
- * The total number of entities currently stored.
352
- */
353
- readonly size: number;
354
- /**
355
- * Checks if an entity exists in storage.
356
- * @param proxy - Reference to the entity to check.
357
- * @returns True if the entity exists, false otherwise.
358
- */
359
- has(proxy: IEntityProxy): boolean;
360
- /**
361
- * Retrieves an entity from storage by proxy.
362
- * @template TEntity - The expected entity type.
363
- * @param proxy - Reference to the entity to retrieve.
364
- * @returns The requested entity.
365
- */
366
- get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
367
- /**
368
- * Retrieves all entities of a specific type.
369
- * @template TEntity - The entity type to retrieve.
370
- * @param entityType - The type identifier to filter by.
371
- * @returns Array of all entities matching the type.
372
- */
373
- getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
374
- /**
375
- * Iterates over all entities regardless of type.
376
- * @returns An iterator over all stored entities.
377
- */
378
- listAll(): IterableIterator<IEntity>;
379
- /**
380
- * Stores or updates an entity.
381
- * @param entity - The entity to store.
382
- */
383
- set(entity: IEntity): void;
384
- /**
385
- * Removes an entity from storage.
386
- * @param proxy - Reference to the entity to remove.
387
- */
388
- delete(proxy: IEntityProxy): void;
389
- /**
390
- * Removes all entities of a specific type from storage.
391
- * @param entityType - The type identifier for entities to remove.
392
- */
393
- clear(entityType: EntityTypeUid): void;
282
+ interface IEntityDispatchGroup {
283
+ readonly entityType: EntityTypeUid;
284
+ readonly updates: ReadonlyArray<IEntityUpdate>;
285
+ readonly dirtyUpdates: number;
286
+ readonly scheduledUpdates: number;
287
+ readonly removeUpdates: number;
288
+ readonly pipelineMask?: number;
394
289
  }
395
- //#endregion
396
- //#region src/entities/entity-scheduler.d.ts
397
- /**
398
- * Describes a scheduled entity update, including the target entity and optional interval.
399
- */
290
+ type EntityRuntimePendingGroupOptions = {
291
+ readonly includeFrameSubscriptions?: boolean;
292
+ };
400
293
  type EntitySchedule = {
401
294
  readonly proxy: IEntityProxy;
402
295
  readonly intervalMs?: number;
403
296
  };
404
- /**
405
- * Controls which scheduling modes are paused.
406
- */
297
+ type EntityPriorityModel = {
298
+ readonly defaultPriority?: number;
299
+ readonly entityTypes?: ReadonlyMap<EntityTypeUid, number>;
300
+ };
407
301
  declare enum SchedulerPauseType {
408
- /** Pause both interval timers and frame subscriptions. */
409
302
  full = "full",
410
- /** Pause only frame subscriptions. Interval timers continue firing. */
411
303
  perFrame = "perFrame",
412
- /** Pause only interval timers. Frame subscriptions continue. */
413
304
  intervals = "intervals"
414
305
  }
415
- /**
416
- * Manages time-based scheduling of entity updates.
417
- *
418
- * Entities can be scheduled with an interval (timer-driven) or without one (per-frame).
419
- * The runtime pulls pending entities each tick via the {@link pending} iterator,
420
- * which yields both per-frame subscriptions and interval entities whose timer has fired.
421
- */
422
- interface IEntityScheduler {
423
- /**
424
- * Returns all currently scheduled entities with their configuration.
425
- * Useful for inspection and debugging.
426
- */
427
- readonly schedules: ReadonlyArray<EntitySchedule>;
428
- /**
429
- * Yields entities pending processing this tick: per-frame subscriptions
430
- * followed by interval entities whose timer has fired since the last drain.
431
- * Iterating drains the due interval buckets; a second iteration without
432
- * timer advancement yields only per-frame subscriptions.
433
- */
434
- readonly pending: IterableIterator<IEntityProxy>;
435
- /**
436
- * The set of entities scheduled for per-frame updates (no interval).
437
- */
438
- readonly frameSubscriptions: ReadonlySet<IEntityProxy>;
439
- /**
440
- * Entity types currently excluded from {@link pending} iteration.
441
- */
442
- readonly skippedEntityTypes: ReadonlySet<EntityTypeUid>;
443
- /**
444
- * The number of entities currently awaiting processing:
445
- * per-frame subscriptions (if not paused) plus interval entities whose timer has fired.
446
- */
447
- readonly pendingCount: number;
448
- /**
449
- * Whether the scheduler is currently paused in any mode.
450
- */
451
- readonly isPaused: boolean;
452
- /**
453
- * Registers or replaces an entity schedule.
454
- * @param entityProxy - The entity to schedule.
455
- * @param intervalMs - Update frequency in milliseconds. If omitted, the entity is scheduled per-frame.
456
- */
457
- schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
458
- /**
459
- * Unregisters an entity from the scheduler.
460
- * @param entityProxy - The entity to unschedule.
461
- */
462
- remove(entityProxy: IEntityProxy): void;
463
- /**
464
- * Checks if an entity is currently scheduled for updates.
465
- * @param entityProxy - The entity to check.
466
- * @returns True if the entity is scheduled, false otherwise.
467
- */
468
- has(entityProxy: IEntityProxy): boolean;
469
- /**
470
- * Removes all schedules and clears all timers.
471
- */
472
- clear(): void;
473
- /**
474
- * Excludes an entity type from {@link pending} iteration.
475
- * Entities remain registered; only yielding is suppressed.
476
- */
306
+ interface IEntityRuntimeScheduler {
307
+ enqueue(update: IEntityUpdate): void;
308
+ enqueueEvent(entity: IEntityProxy, event: IEntityEvent<IEventData>): void;
309
+ enqueueEvents(entity: IEntityProxy, events: ReadonlyArray<IEntityEvent<IEventData>>): void;
310
+ clearDirtyUpdates(): void;
311
+ schedule(proxy: IEntityProxy, intervalMs?: number): void;
312
+ removeSchedule(proxy: IEntityProxy): void;
313
+ hasSchedule(proxy: IEntityProxy): boolean;
314
+ clearSchedules(): void;
315
+ takePendingGroups(maxItems?: number, options?: EntityRuntimePendingGroupOptions): ReadonlyArray<IEntityDispatchGroup>;
477
316
  skipEntityType(entityType: EntityTypeUid): void;
478
- /**
479
- * Re-includes a previously skipped entity type in {@link pending} iteration.
480
- */
481
317
  unskipEntityType(entityType: EntityTypeUid): void;
482
- /**
483
- * Pauses the scheduler.
484
- * @param type - Which scheduling modes to pause. Defaults to {@link SchedulerPauseType.full}.
485
- */
486
318
  pause(type?: SchedulerPauseType): void;
487
- /**
488
- * Resumes the scheduler from any paused state.
489
- */
490
319
  resume(): void;
491
320
  }
321
+ interface IEntityRuntimeSchedulerInspector extends IEntityRuntimeScheduler {
322
+ readonly dirtyCount: number;
323
+ readonly frameSubscriptions: ReadonlySet<IEntityProxy>;
324
+ readonly isPaused: boolean;
325
+ readonly pauseType: SchedulerPauseType | null;
326
+ readonly pendingGroupCount: number;
327
+ readonly pendingCount: number;
328
+ readonly rawDirtyCount: number;
329
+ readonly schedules: ReadonlyArray<EntitySchedule>;
330
+ readonly skippedEntityTypes: ReadonlySet<EntityTypeUid>;
331
+ inspectDirtyUpdates(): ReadonlyArray<IEntityUpdate>;
332
+ }
492
333
  //#endregion
493
- 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 };
494
- //# sourceMappingURL=index-BOsrKTWm.d.cts.map
334
+ export { SYSTEM_CONTEXT_KEY as S, IEntityEventsDispatcher as _, IEntityDispatchGroup as a, IEntityConfigSnapshot as b, IEntityUpdate as c, IEntitySnapshotProvider as d, IEntityRepository as f, IEntityEvent as g, EntityEventUid as h, EntityUpdateType as i, SchedulerPauseType as l, EntityEventSubscriptionOptions as m, EntityRuntimePendingGroupOptions as n, IEntityRuntimeScheduler as o, EntityEventSubscriptionFilter as p, EntitySchedule as r, IEntityRuntimeSchedulerInspector as s, EntityPriorityModel as t, IEntitySnapshot as u, IEntityEventsManager as v, IContextRepository as x, IEventData as y };
335
+ //# sourceMappingURL=index-CSaKdQe-.d.cts.map