@awesome-ecs/abstract 0.29.0 → 0.30.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.
@@ -1,544 +0,0 @@
1
- import { a as IEntity, c as IEntityProxy, l as IEntityProxyRepository, o as IEntityModel, r as EntityTypeUid, s as EntityProxy } from "./identity-component-CsU-wYTX.cjs";
2
- import { n as Immutable } from "./types-DqWnkvhp.cjs";
3
- import { c as IEntitySnapshot, d as EntityEventSubscriptionOptions, f as EntityEventUid, g as IEventData, o as IEntityUpdate, p as IEntityEvent } from "./index-DTHsTJ1j.cjs";
4
- import { a as ILogger, c as IJsonSerializer, r as PerformanceTimeEntry } from "./index-DCx0PjvH.cjs";
5
- import { c as IMiddleware, l as IPipelineContext, o as IPipeline } from "./index-BRkKPsOV.cjs";
6
-
7
- //#region src/systems/pipeline/system-context-events.d.ts
8
- /**
9
- * System context API for event-driven entity communication.
10
- * Allows middleware to dispatch events, manage subscriptions, and query event state.
11
- * Events enable decoupled communication between distant or unrelated entities.
12
- */
13
- interface ISystemContextEvents {
14
- /**
15
- * Publishes an event to one or more explicit targets.
16
- * The event is sent only to the specified target(s) — it does NOT fall back to subscriptions.
17
- * @param data - The event payload.
18
- * @param target - The entity or entities to send the event to.
19
- */
20
- dispatchEvent<TEventData extends IEventData>(data: TEventData, target: IEntityProxy | IEntityProxy[]): void;
21
- /**
22
- * Publishes multiple events to one or more explicit targets.
23
- * Each target receives all events in a single update.
24
- * @param data - Array of event payloads to dispatch.
25
- * @param target - The entity or entities to send the events to.
26
- */
27
- dispatchEvents<TEventData extends IEventData>(data: TEventData[], target: IEntityProxy | IEntityProxy[]): void;
28
- /**
29
- * Broadcasts an event to all subscribers registered for that event type.
30
- * Uses the subscription registry to resolve targets.
31
- * @param data - The event payload.
32
- */
33
- broadcastEvent<TEventData extends IEventData>(data: TEventData): void;
34
- /**
35
- * Broadcasts multiple events to all subscribers.
36
- * Events are grouped per subscriber so each receives a single update.
37
- * @param data - Array of event payloads to broadcast.
38
- */
39
- broadcastEvents<TEventData extends IEventData>(data: TEventData[]): void;
40
- /**
41
- * Retrieves an event from the current context by its identifier.
42
- * Useful for checking if an event was received this frame.
43
- * @param uid - The event type identifier.
44
- * @returns The event if present, undefined otherwise.
45
- */
46
- getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData> | undefined;
47
- /**
48
- * Retrieves all events currently set on this context.
49
- * Events are cleared between frames.
50
- * @returns Array of all active events for this context.
51
- */
52
- listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
53
- /**
54
- * Checks if a specific event is present in the current context.
55
- * If no uid is provided, checks if any events exist.
56
- * @param uid - Optional event type to check for. If omitted, checks for any event.
57
- * @returns True if matching event(s) found, false otherwise.
58
- */
59
- hasEvent(uid?: EntityEventUid): boolean;
60
- /**
61
- * Subscribes to events of a specific type.
62
- * The entity will be notified of matching events through the update system.
63
- * @param uid - The event type to listen for.
64
- * @param options - Optional subscription options (filter, scopeId).
65
- */
66
- subscribeTo(uid: EntityEventUid, options?: EntityEventSubscriptionOptions): void;
67
- /**
68
- * Stops listening for events of a specific type.
69
- * @param uid - The event type to stop listening for.
70
- */
71
- unsubscribeFrom(uid: EntityEventUid): void;
72
- /**
73
- * Adds events to the current context for processing by this and downstream middleware.
74
- * @param events - Event array to add to context.
75
- */
76
- setContextEvents(events: IEntityEvent<IEventData>[]): void;
77
- /**
78
- * Adds a single event to the current context.
79
- * @param event - Event to add to context.
80
- */
81
- setContextEvent(event: IEntityEvent<IEventData>): void;
82
- /**
83
- * Removes all events from the current context.
84
- */
85
- clearContextEvents(): void;
86
- /**
87
- * Clears all event subscriptions for the current entity.
88
- */
89
- clearSubscriptions(): void;
90
- }
91
- //#endregion
92
- //#region src/systems/pipeline/system-context-proxies.d.ts
93
- /**
94
- * System context API for managing entity relationships (proxies).
95
- * Provides context-bound operations for establishing and managing entity links.
96
- * All operations apply to the current entity in the context.
97
- */
98
- interface ISystemContextProxies {
99
- /**
100
- * Establishes a reference to another entity from the current entity.
101
- * Creates a bidirectional link between the entities.
102
- * @param proxy - The entity to establish a reference to.
103
- * @param cleanup - If true, removes existing proxies of the same type before adding.
104
- */
105
- register(proxy: IEntityProxy, cleanup?: boolean): void;
106
- /**
107
- * Establishes multiple references from the current entity.
108
- * Batch version of register for efficiency.
109
- * @param proxies - The entities to establish references to.
110
- * @param cleanup - If true, removes existing proxies of matching types before adding.
111
- */
112
- registerMany(proxies: readonly IEntityProxy[], cleanup?: boolean): void;
113
- /**
114
- * Removes a reference from the current entity to another entity.
115
- * Breaks the bidirectional link.
116
- * @param proxy - The entity reference to remove.
117
- */
118
- remove(proxy: IEntityProxy): void;
119
- /**
120
- * Removes all entity references from the current entity.
121
- * Optionally filter by target entity type.
122
- * @param targetType - If provided, only removes references to entities of this type.
123
- */
124
- removeAll(targetType?: EntityTypeUid): void;
125
- /**
126
- * Retrieves a single reference of a specific entity type from the current entity.
127
- * @param targetType - The entity type to find.
128
- * @returns The first matching proxy, or null if not found.
129
- */
130
- get(targetType: EntityTypeUid): IEntityProxy | null;
131
- /**
132
- * Retrieves all references to entities of a specific type from the current entity.
133
- * @param targetType - The entity type to find.
134
- * @returns Array of matching proxies.
135
- */
136
- getMany(targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
137
- /**
138
- * Retrieves all entity references from the current entity.
139
- * Organized by target entity type.
140
- * @returns Map of entity type to their proxies.
141
- */
142
- getAll(): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
143
- }
144
- //#endregion
145
- //#region src/systems/pipeline/system-context-repository.d.ts
146
- /**
147
- * System context API for entity repository operations.
148
- * Provides controlled access to entity storage for creating, updating, and removing entities.
149
- * All changes go through the repository to maintain system consistency.
150
- */
151
- interface ISystemContextRepository {
152
- /**
153
- * Queues a new entity for creation.
154
- * The entity is created with the provided model and optional initial snapshot.
155
- * @param entityType - The type of entity to create.
156
- * @param model - The entity initialization data.
157
- * @param snapshot - Optional initial state for the entity.
158
- */
159
- addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
160
- /**
161
- * Retrieves an entity from storage.
162
- * @template TEntity - The expected entity type.
163
- * @param proxy - Reference to the entity.
164
- * @returns The immutable entity instance.
165
- */
166
- getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity> | EntityTypeUid): Immutable<TEntity>;
167
- /**
168
- * Queues an entity for update.
169
- * Triggers the update pipeline for the entity.
170
- * @param target - Optional specific entity to update. Defaults to current entity in context.
171
- */
172
- updateEntity(target?: IEntityProxy): void;
173
- /**
174
- * Removes an entity from storage.
175
- * Triggers entity cleanup and removal from all systems.
176
- * @param target - The entity to remove.
177
- */
178
- removeEntity(target: IEntityProxy): void;
179
- }
180
- //#endregion
181
- //#region src/systems/pipeline/system-context-scheduler.d.ts
182
- /**
183
- * System context API for scheduling and managing entity updates.
184
- * Allows middleware to request that an entity (or another) be updated again on the next or subsequent frame.
185
- * Supports both immediate (next frame) and interval-based scheduling.
186
- */
187
- interface ISystemContextScheduler {
188
- /**
189
- * Schedules an entity for update.
190
- * If no target is specified, schedules the current entity.
191
- * If no interval is specified, schedules on a default interval.
192
- * @param target - Optional entity to schedule. Defaults to current entity in context.
193
- * @param intervalMs - Optional update interval in milliseconds. Undefined uses default interval.
194
- */
195
- scheduleUpdate(target?: IEntityProxy, intervalMs?: number): void;
196
- /**
197
- * Cancels scheduled updates for an entity.
198
- * If no target is specified, removes schedule for the current entity.
199
- * @param target - Optional entity to unschedule. Defaults to current entity in context.
200
- */
201
- removeSchedule(target?: IEntityProxy): void;
202
- /**
203
- * Checks whether an entity has a scheduled update.
204
- * If no target is specified, checks the current entity.
205
- * @param target - Optional entity to check. Defaults to current entity in context.
206
- */
207
- hasSchedule(target?: IEntityProxy): boolean;
208
- }
209
- //#endregion
210
- //#region src/systems/pipeline/system-context-snapshot.d.ts
211
- /**
212
- * System context API for entity serialization and state transfer.
213
- * Handles conversion between entities and their serializable snapshots.
214
- * Used for state persistence, synchronization, and applying external updates.
215
- */
216
- interface ISystemContextSnapshot {
217
- /**
218
- * The JSON serializer instance used by this context.
219
- * Handles serialization of complex types within snapshots.
220
- */
221
- readonly serializer: Immutable<IJsonSerializer>;
222
- /**
223
- * Applies serialized state to the current entity.
224
- * Updates the entity's components based on the snapshot.
225
- * @param snapshot - The state to apply.
226
- */
227
- applyToEntity(snapshot: IEntitySnapshot): void;
228
- /**
229
- * Creates a serialized snapshot of an entity.
230
- * Captures the current state for transmission or storage.
231
- * @param entity - The entity to snapshot. If omitted, snapshots current entity in context.
232
- * @returns The serialized entity state.
233
- */
234
- createFromEntity(entity?: IEntity): IEntitySnapshot;
235
- /**
236
- * Queues a snapshot-based update for an entity.
237
- * Applies the snapshot through the entity update system.
238
- * @param snapshot - The state to apply.
239
- * @param proxy - The entity to update.
240
- */
241
- dispatchToUpdate(snapshot: IEntitySnapshot, proxy: IEntityProxy): void;
242
- }
243
- //#endregion
244
- //#region src/systems/pipeline/system-context.d.ts
245
- /**
246
- * The execution context passed to system middleware.
247
- * Provides comprehensive access to entity state, scheduling, events, and repository operations.
248
- * Serves as the primary interface between middleware and the ECS framework.
249
- *
250
- * @template TEntity - The specific entity type this context operates on.
251
- */
252
- interface ISystemContext<TEntity extends IEntity> extends IPipelineContext {
253
- /**
254
- * Time elapsed since the last system update for this entity, in milliseconds.
255
- * Useful for time-based calculations and animations.
256
- */
257
- readonly deltaTimeMs: Immutable<number>;
258
- /**
259
- * The entity currently being processed by this middleware.
260
- */
261
- readonly entity: Immutable<TEntity>;
262
- /**
263
- * Information about the update triggering this system execution.
264
- * Contains type (update/remove) and optional model/snapshot data.
265
- */
266
- readonly update: Immutable<IEntityUpdate>;
267
- /**
268
- * Event system API for publishing and subscribing to entity events.
269
- */
270
- readonly events: Immutable<ISystemContextEvents>;
271
- /**
272
- * Proxy management API for establishing and managing entity relationships.
273
- */
274
- readonly proxies: Immutable<ISystemContextProxies>;
275
- /**
276
- * Repository access API for querying and modifying entity storage.
277
- */
278
- readonly repository: Immutable<ISystemContextRepository>;
279
- /**
280
- * Scheduling API for requesting follow-up entity updates.
281
- */
282
- readonly scheduler: Immutable<ISystemContextScheduler>;
283
- /**
284
- * Snapshot management API for serialization and state transfer.
285
- */
286
- readonly snapshot: Immutable<ISystemContextSnapshot>;
287
- /**
288
- * Logging interface for debug and diagnostic output.
289
- */
290
- readonly logger: Immutable<ILogger>;
291
- }
292
- //#endregion
293
- //#region src/systems/system-type.d.ts
294
- /**
295
- * The four phases of entity system execution in each frame.
296
- * Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.
297
- * The runtime handles each phase in order, allowing systems to perform stage-specific operations.
298
- */
299
- declare enum SystemType {
300
- /**
301
- * Initial setup and resource allocation for the entity.
302
- * Runs once when the entity is first created or initialized.
303
- */
304
- initialize = 0,
305
- /**
306
- * Main logic and state updates for the entity.
307
- * Runs on every update to change entity behavior and properties.
308
- */
309
- update = 1,
310
- /**
311
- * Output and visualization operations.
312
- * Runs after updates to render or display the entity state.
313
- */
314
- render = 2,
315
- /**
316
- * Synchronization and persistence.
317
- * Runs last to synchronize state with external systems or storage.
318
- */
319
- sync = 3
320
- }
321
- //#endregion
322
- //#region src/systems/module/systems-module.d.ts
323
- /**
324
- * Collection of pipelines for a specific entity type.
325
- * Defines the complete system processing flow for one entity category.
326
- *
327
- * @template TEntity - The entity type this module processes.
328
- */
329
- interface ISystemsModule<TEntity extends IEntity> {
330
- /**
331
- * The pipelines for this entity type.
332
- * Each pipeline contains middleware that operates on the entity.
333
- */
334
- readonly pipelines: ReadonlyMap<SystemType, Immutable<IPipeline<ISystemContext<TEntity>>>>;
335
- /**
336
- * Optional factory function to initialize new entity instances.
337
- * If provided, is called when a new entity of this type is created.
338
- * @param model - The initialization model.
339
- * @returns The initialized entity.
340
- */
341
- readonly initEntity?: (model: IEntityModel) => TEntity;
342
- /**
343
- * If true, this entity type creates a new scope boundary when initialized.
344
- * A new scope ID is auto-generated. All child entities inherit this scope.
345
- * Typically used for root entities like Engine.
346
- */
347
- readonly scopeRoot?: boolean;
348
- /**
349
- * If true, this entity type registers itself as a scoped proxy when initialized.
350
- * It joins the inherited scope and becomes resolvable via `context.proxies.get()`
351
- * by any entity in the same scope. Throws if no scope exists.
352
- * Typically used for scope-wide entities like Scene, Input, AssetsManager.
353
- */
354
- readonly scopedProxy?: boolean;
355
- }
356
- //#endregion
357
- //#region src/systems/pipeline/system-middleware.d.ts
358
- /**
359
- * A middleware unit that operates within the system pipeline.
360
- * System middleware receive comprehensive context about the entity being processed
361
- * and can influence entity state and behavior through various APIs.
362
- *
363
- * @template TEntity - The entity type this middleware handles.
364
- */
365
- type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
366
- //#endregion
367
- //#region src/systems/module/systems-module-builder.d.ts
368
- /**
369
- * Builder pattern interface for constructing system modules.
370
- * Allows incremental registration of systems and modules for an entity type.
371
- * Supports adding individual systems or entire pre-configured modules.
372
- *
373
- * @template TEntity - The entity type for which systems are being added.
374
- */
375
- interface ISystemsModuleBuilder<TEntity extends IEntity> {
376
- /**
377
- * The Module Builder's name.
378
- */
379
- readonly name: string;
380
- /**
381
- * The pipelines being built.
382
- * Accessible during and after construction.
383
- */
384
- readonly pipelines: ReadonlyMap<SystemType, IPipeline<ISystemContext<TEntity>>>;
385
- /**
386
- * Whether this entity type is a scope root.
387
- */
388
- readonly scopeRoot: boolean;
389
- /**
390
- * Whether this entity type is a scoped proxy.
391
- */
392
- readonly scopedProxy: boolean;
393
- /**
394
- * Registers middleware systems for a specific pipeline stage.
395
- * The middleware are added to the pipeline in the order provided.
396
- * @param type - The pipeline stage (initialize, update, render, sync).
397
- * @param systems - Array of middleware to add.
398
- * @returns This builder for method chaining.
399
- */
400
- addSystems(type: SystemType, systems: Immutable<ISystemMiddleware<TEntity>[]>): this;
401
- /**
402
- * Integrates an entire module's pipelines into this builder.
403
- * Allows composition of multiple modules into one.
404
- * @template TModuleEntity - The module's entity type (must extend current type).
405
- * @param module - The module to integrate.
406
- * @param systemType - Optional specific pipeline to integrate from module. If omitted, integrates all.
407
- * @returns This builder for method chaining.
408
- */
409
- addModule<TModuleEntity extends TEntity>(module: ISystemsModule<TModuleEntity>, systemType?: SystemType): this;
410
- /**
411
- * Marks this entity type as a scope root.
412
- * When initialized, a new scope is auto-generated and all child entities inherit it.
413
- * @returns This builder for method chaining.
414
- */
415
- setScopeRoot(): this;
416
- /**
417
- * Marks this entity type as a scoped proxy.
418
- * When initialized, the entity registers itself in the inherited scope,
419
- * making it resolvable via `context.proxies.get()` by any entity in the same scope.
420
- * @returns This builder for method chaining.
421
- */
422
- setScopedProxy(): this;
423
- }
424
- //#endregion
425
- //#region src/systems/module/systems-module-repository.d.ts
426
- /**
427
- * Central registry for all systems modules in the ECS.
428
- * Maintains a module for each entity type, providing access to all system pipelines.
429
- * This is the authoritative source for system module data.
430
- *
431
- * @template TEntity - The entity types managed by modules in this repository.
432
- */
433
- interface ISystemsModuleRepository {
434
- /**
435
- * The total number of modules in the repository.
436
- */
437
- readonly size: number;
438
- /**
439
- * Retrieves the module for a specific entity type.
440
- * @template TEntity - The entity type to retrieve module for.
441
- * @param type - The entity type identifier.
442
- * @returns The systems module for that entity type.
443
- */
444
- get<TEntity extends IEntity>(type: EntityTypeUid): ISystemsModule<TEntity>;
445
- /**
446
- * Registers or updates a module for an entity type.
447
- * @param type - The entity type identifier.
448
- * @param module - The systems module to register.
449
- */
450
- set(type: EntityTypeUid, module: ISystemsModule<IEntity>): void;
451
- /**
452
- * Retrieves all registered modules.
453
- * @returns A read-only map of entity type to module.
454
- */
455
- list(): ReadonlyMap<EntityTypeUid, Immutable<ISystemsModule<IEntity>>>;
456
- }
457
- //#endregion
458
- //#region src/systems/pipeline/system-context-entity.d.ts
459
- /**
460
- * Manages the current entity and update being processed in the system context.
461
- * Provides internal state management for the system execution pipeline.
462
- * Typically used by runtime infrastructure rather than system middleware directly.
463
- */
464
- interface ISystemContextEntity {
465
- /**
466
- * The entity currently being processed.
467
- */
468
- readonly entity: Immutable<IEntity>;
469
- /**
470
- * The update that triggered processing of this entity.
471
- */
472
- readonly update: Immutable<IEntityUpdate>;
473
- /**
474
- * Updates the entity being processed.
475
- * @param entity - The new entity for this context.
476
- */
477
- setEntity(entity: IEntity): void;
478
- /**
479
- * Updates the entity update being processed.
480
- * @param update - The new update for this context.
481
- */
482
- setUpdate(update: IEntityUpdate): void;
483
- /**
484
- * Clears the current entity and update from the context and the IEntityRepository.
485
- * @param deep - If true, also removes the entity from the IEntityRepository; otherwise, just clears the context reference.
486
- */
487
- clear(deep?: boolean): void;
488
- }
489
- //#endregion
490
- //#region src/systems/runtime/systems-runtime.d.ts
491
- /**
492
- * Executes system middleware for entities.
493
- * Processes entity updates by dispatching them through appropriate system modules.
494
- * Different implementations may use different execution strategies or optimizations.
495
- */
496
- interface ISystemsRuntime {
497
- /**
498
- * Processes a single entity update through its system pipeline.
499
- * If no update is provided, may dequeue one from an internal queue.
500
- * @param update - Optional specific update to process. If omitted, dequeues the next update.
501
- * @returns Array of pipeline results containing execution metrics and data.
502
- */
503
- runTick(update?: IEntityUpdate): PerformanceTimeEntry[] | void;
504
- }
505
- //#endregion
506
- //#region src/systems/runtime/systems-runtime-context.d.ts
507
- /**
508
- * Runtime context for system pipeline execution.
509
- * Coordinates the execution of system pipelines across all entities.
510
- * Maintains state about the current entity being processed and enabled pipeline stages.
511
- *
512
- * @template TEntity - The entity type being processed.
513
- */
514
- interface ISystemsRuntimeContext<TEntity extends IEntity> extends IPipelineContext {
515
- /**
516
- * Indicates if the system pipeline should perform initialization for the current entity.
517
- */
518
- readonly shouldInitialize?: boolean;
519
- /**
520
- * The systems module for the current entity type.
521
- */
522
- readonly systemsModule: ISystemsModule<TEntity>;
523
- /**
524
- * The system context for the current entity execution.
525
- */
526
- readonly systemContext: ISystemContext<TEntity>;
527
- /**
528
- * The proxy repository for managing entity proxy relationships and scopes.
529
- */
530
- readonly proxyRepository: IEntityProxyRepository;
531
- }
532
- //#endregion
533
- //#region src/systems/runtime/systems-runtime-middleware.d.ts
534
- /**
535
- * Middleware for orchestrating system execution across entities.
536
- * Operates at the runtime level to coordinate system module pipelines.
537
- * Can influence which pipelines execute and in what order.
538
- *
539
- * @template TEntity - The entity type being processed.
540
- */
541
- type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
542
- //#endregion
543
- export { ISystemsModuleRepository as a, ISystemsModule as c, ISystemContextSnapshot as d, ISystemContextScheduler as f, ISystemContextEvents as h, ISystemContextEntity as i, SystemType as l, ISystemContextProxies as m, ISystemsRuntimeContext as n, ISystemsModuleBuilder as o, ISystemContextRepository as p, ISystemsRuntime as r, ISystemMiddleware as s, ISystemsRuntimeMiddleware as t, ISystemContext as u };
544
- //# sourceMappingURL=index-Df4VhCPr.d.cts.map