@awesome-ecs/abstract 0.22.0 → 0.24.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 (74) hide show
  1. package/README.md +126 -228
  2. package/dist/components/index.cjs +3 -3
  3. package/dist/components/index.cjs.map +1 -1
  4. package/dist/components/index.d.cts +1 -2
  5. package/dist/components/index.d.mts +2 -0
  6. package/dist/components/{index.js → index.mjs} +4 -4
  7. package/dist/components/index.mjs.map +1 -0
  8. package/dist/entities/index.cjs +12 -5
  9. package/dist/entities/index.cjs.map +1 -1
  10. package/dist/entities/index.d.cts +3 -4
  11. package/dist/entities/index.d.mts +3 -0
  12. package/dist/entities/index.mjs +20 -0
  13. package/dist/entities/index.mjs.map +1 -0
  14. package/dist/factories/index.d.cts +47 -35
  15. package/dist/factories/index.d.mts +69 -0
  16. package/dist/factories/index.mjs +1 -0
  17. package/dist/identity-component-CgzvgBVh.d.mts +254 -0
  18. package/dist/identity-component-uU0yDR-y.d.cts +254 -0
  19. package/dist/index-BWmhFdFg.d.mts +148 -0
  20. package/dist/index-CfEs8NEA.d.mts +328 -0
  21. package/dist/index-D4jK3qG1.d.mts +224 -0
  22. package/dist/index-DULE7rVz.d.mts +515 -0
  23. package/dist/index-DZvjMjYZ.d.cts +224 -0
  24. package/dist/index-J5AU4JAU.d.cts +515 -0
  25. package/dist/index-eECJUE_O.d.cts +148 -0
  26. package/dist/index-qSeVF9hf.d.cts +328 -0
  27. package/dist/pipelines/index.cjs +0 -31
  28. package/dist/pipelines/index.d.cts +2 -4
  29. package/dist/pipelines/index.d.mts +2 -0
  30. package/dist/pipelines/index.mjs +1 -0
  31. package/dist/systems/index.cjs +18 -18
  32. package/dist/systems/index.cjs.map +1 -1
  33. package/dist/systems/index.d.cts +2 -7
  34. package/dist/systems/index.d.mts +2 -0
  35. package/dist/systems/index.mjs +33 -0
  36. package/dist/systems/index.mjs.map +1 -0
  37. package/dist/types-CnDtpKsY.d.mts +70 -0
  38. package/dist/types-DLOd2zXO.d.cts +70 -0
  39. package/dist/utils/index.cjs +11 -11
  40. package/dist/utils/index.cjs.map +1 -1
  41. package/dist/utils/index.d.cts +2 -2
  42. package/dist/utils/index.d.mts +3 -0
  43. package/dist/utils/index.mjs +27 -0
  44. package/dist/utils/index.mjs.map +1 -0
  45. package/package.json +14 -14
  46. package/dist/components/index.d.ts +0 -3
  47. package/dist/components/index.js.map +0 -1
  48. package/dist/entities/index.d.ts +0 -4
  49. package/dist/entities/index.js +0 -13
  50. package/dist/entities/index.js.map +0 -1
  51. package/dist/factories/index.d.ts +0 -57
  52. package/dist/factories/index.js +0 -0
  53. package/dist/identity-component-BDWEtAXA.d.cts +0 -238
  54. package/dist/identity-component-CR1ULadR.d.ts +0 -238
  55. package/dist/index-C3UGZqUG.d.ts +0 -288
  56. package/dist/index-CH8ucsKZ.d.ts +0 -472
  57. package/dist/index-ChV4Q5j6.d.cts +0 -137
  58. package/dist/index-CjNeb3ML.d.cts +0 -472
  59. package/dist/index-Cm-YSPhK.d.ts +0 -254
  60. package/dist/index-D81Fo9XN.d.cts +0 -254
  61. package/dist/index-DLm-DKAk.d.cts +0 -288
  62. package/dist/index-oenqxDCa.d.ts +0 -137
  63. package/dist/pipelines/index.cjs.map +0 -1
  64. package/dist/pipelines/index.d.ts +0 -4
  65. package/dist/pipelines/index.js +0 -30
  66. package/dist/pipelines/index.js.map +0 -1
  67. package/dist/systems/index.d.ts +0 -7
  68. package/dist/systems/index.js +0 -33
  69. package/dist/systems/index.js.map +0 -1
  70. package/dist/types-DvzdpbLu.d.cts +0 -69
  71. package/dist/types-yh4pOGEm.d.ts +0 -69
  72. package/dist/utils/index.d.ts +0 -3
  73. package/dist/utils/index.js +0 -27
  74. package/dist/utils/index.js.map +0 -1
@@ -0,0 +1,148 @@
1
+ //#region src/utils/json-serializer.d.ts
2
+ /**
3
+ * Custom JSON serialization and deserialization interface.
4
+ * Allows different serialization strategies for handling complex types.
5
+ * Used for entity snapshots, events, and any data needing JSON conversion.
6
+ */
7
+ interface IJsonSerializer {
8
+ /**
9
+ * Converts an object to a serializable JSON representation.
10
+ * Handles types that don't serialize naturally (dates, maps, custom objects, etc.).
11
+ * @param value - The object to serialize.
12
+ * @returns A JSON-serializable representation.
13
+ */
14
+ serializeCustom(value: object): string;
15
+ /**
16
+ * Converts a JSON string back to its original object type.
17
+ * Reconstructs complex types from their serialized form.
18
+ * @template TObject - The target object type.
19
+ * @param text - The JSON string to deserialize.
20
+ * @returns The deserialized object of the specified type.
21
+ */
22
+ parseCustom<TObject>(text: string): TObject;
23
+ }
24
+ //#endregion
25
+ //#region src/utils/logger.d.ts
26
+ /**
27
+ * Logger interface for debug and diagnostic output.
28
+ * Supports multiple log levels for controlling verbosity.
29
+ * Implementations can target different outputs (console, file, remote, etc.).
30
+ */
31
+ interface ILogger {
32
+ /**
33
+ * Logs a message with a specified severity level.
34
+ * @param level - The severity level of the message.
35
+ * @param message - The primary message content.
36
+ * @param args - Additional arguments to include in the log output.
37
+ */
38
+ log(level: LogLevel, message: any, ...args: any[]): void;
39
+ /**
40
+ * Logs detailed diagnostic information.
41
+ * Typically the lowest level, most verbose output.
42
+ * @param message - The message to log.
43
+ * @param args - Additional data.
44
+ */
45
+ trace(message: any, ...args: any[]): void;
46
+ /**
47
+ * Logs debug-level information.
48
+ * Useful during development and troubleshooting.
49
+ * @param message - The message to log.
50
+ * @param args - Additional data.
51
+ */
52
+ debug(message: any, ...args: any[]): void;
53
+ /**
54
+ * Logs warning-level messages.
55
+ * Indicates potentially problematic conditions.
56
+ * @param message - The message to log.
57
+ * @param args - Additional data.
58
+ */
59
+ warn(message: any, ...args: any[]): void;
60
+ /**
61
+ * Logs error-level messages.
62
+ * Indicates error conditions that may require attention.
63
+ * @param message - The message to log.
64
+ * @param args - Additional data.
65
+ */
66
+ error(message: any, ...args: any[]): void;
67
+ }
68
+ /**
69
+ * Logging severity levels in increasing order.
70
+ */
71
+ declare enum LogLevel {
72
+ /**
73
+ * Most detailed, diagnostic-level logging.
74
+ */
75
+ trace = 0,
76
+ /**
77
+ * Development and debugging information.
78
+ */
79
+ debug = 1,
80
+ /**
81
+ * Warning-level conditions.
82
+ */
83
+ warn = 2,
84
+ /**
85
+ * Error-level conditions.
86
+ */
87
+ error = 3
88
+ }
89
+ /**
90
+ * Configuration options for logger instances.
91
+ */
92
+ interface ILoggerOptions {
93
+ /**
94
+ * Enables/disables each log level.
95
+ * If a level is disabled, log calls at that level are ignored.
96
+ */
97
+ enabled: Map<LogLevel, boolean>;
98
+ }
99
+ //#endregion
100
+ //#region src/utils/performance-timer.d.ts
101
+ /**
102
+ * Unique identifier for a timer instance.
103
+ */
104
+ type PerformanceTimerUid = number;
105
+ /**
106
+ * Record of a completed timer measurement.
107
+ * Captures timing information for performance analysis and profiling.
108
+ */
109
+ interface PerformanceTimeEntry {
110
+ /**
111
+ * The name identifying this timer.
112
+ */
113
+ name: string;
114
+ /**
115
+ * Timestamp in milliseconds when the timer started.
116
+ */
117
+ startedAt: number;
118
+ /**
119
+ * Timestamp in milliseconds when the timer ended.
120
+ */
121
+ endedAt?: number;
122
+ /**
123
+ * Duration in milliseconds that elapsed.
124
+ */
125
+ msPassed?: number;
126
+ }
127
+ /**
128
+ * Interface for measuring operation duration.
129
+ * Provides start/stop functionality for performance profiling.
130
+ * Used throughout the system to collect timing metrics.
131
+ */
132
+ interface IPerformanceTimer {
133
+ /**
134
+ * Starts a new timer.
135
+ * @param name - Label for this timer (used in results).
136
+ * @returns A unique identifier for this timer instance.
137
+ */
138
+ startTimer(name: string): PerformanceTimerUid;
139
+ /**
140
+ * Stops a timer and returns the recorded metrics.
141
+ * @param timerUid - The timer identifier returned by startTimer.
142
+ * @returns Complete timing entry with start, end, and duration.
143
+ */
144
+ endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
145
+ }
146
+ //#endregion
147
+ export { ILoggerOptions as a, ILogger as i, PerformanceTimeEntry as n, LogLevel as o, PerformanceTimerUid as r, IJsonSerializer as s, IPerformanceTimer as t };
148
+ //# sourceMappingURL=index-BWmhFdFg.d.mts.map
@@ -0,0 +1,328 @@
1
+ import { a as IEntity, c as IEntityProxy, n as IdentityComponent, o as IEntityModel, p as IComponent, r as EntityTypeUid } from "./identity-component-CgzvgBVh.mjs";
2
+
3
+ //#region src/entities/entity-events.d.ts
4
+ /**
5
+ * Represents a unique identifier for an entity event.
6
+ * Can be either a string or a number.
7
+ */
8
+ type EntityEventUid = string | number;
9
+ /**
10
+ * A filter function for entity event subscriptions.
11
+ * Returns true if the event should be processed, false otherwise.
12
+ */
13
+ type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
14
+ /**
15
+ * The `IEventData` interface represents the data associated with an entity event.
16
+ * It contains at least the `Event Unique Identifier`.
17
+ */
18
+ interface IEventData {
19
+ uid: EntityEventUid;
20
+ }
21
+ /**
22
+ * Represents a publishable event in the entity system.
23
+ * Enables loosely-coupled communication between entities through an Observer pattern.
24
+ * Events include origin, optional target, and typed data payload.
25
+ *
26
+ * @template TEventData - The type of data carried by this event.
27
+ */
28
+ interface IEntityEvent<TEventData extends IEventData> {
29
+ /**
30
+ * The entity that originated this event.
31
+ */
32
+ origin: IEntityProxy;
33
+ /**
34
+ * Optional target entity for this event.
35
+ * If omitted, the event is broadcast to all subscribers.
36
+ */
37
+ target?: IEntityProxy;
38
+ /**
39
+ * The event payload containing type-specific data.
40
+ */
41
+ data: TEventData;
42
+ /**
43
+ * The scope of the dispatching entity.
44
+ * When set, the event is only delivered to subscribers in the same scope.
45
+ */
46
+ scopeId?: string;
47
+ }
48
+ /**
49
+ * Options for subscribing to an entity event.
50
+ */
51
+ interface EntityEventSubscriptionOptions {
52
+ /**
53
+ * Optional function to determine which specific events are processed.
54
+ */
55
+ filter?: EntityEventSubscriptionFilter;
56
+ /**
57
+ * The scope of the subscribing entity.
58
+ * When set, the subscriber only receives events from the same scope.
59
+ */
60
+ scopeId?: string;
61
+ }
62
+ /**
63
+ * Manages subscriptions and dispatching for entity events.
64
+ * Implements the Observer pattern to decouple event producers from consumers.
65
+ * Tracks which entities are interested in which event types and maintains subscription state.
66
+ */
67
+ interface IEntityEventsManager {
68
+ /**
69
+ * Subscribes an entity to a specific event type.
70
+ * The entity will be notified when events of that type are dispatched.
71
+ * @param uid - The event type to subscribe to.
72
+ * @param entity - The entity registering for this event type.
73
+ * @param options - Optional subscription options (filter, scopeId).
74
+ */
75
+ subscribe(uid: EntityEventUid, entity: IEntityProxy, options?: EntityEventSubscriptionOptions): void;
76
+ /**
77
+ * Unsubscribes an entity from a specific event type.
78
+ * The entity will no longer receive notifications for this event type.
79
+ * @param uid - The event type to unsubscribe from.
80
+ * @param entity - The entity unregistering from this event type.
81
+ */
82
+ unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
83
+ /**
84
+ * Retrieves all entities subscribed to a specific event.
85
+ * @param event - The event to get subscriptions for.
86
+ * @returns Array of entities subscribed to this event.
87
+ */
88
+ getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
89
+ /**
90
+ * Retrieves all event types an entity is subscribed to.
91
+ * @param entity - The entity to query.
92
+ * @returns Array of event type identifiers this entity is listening to.
93
+ */
94
+ getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[];
95
+ /**
96
+ * Removes all subscriptions system-wide.
97
+ */
98
+ clearSubscriptions(): void;
99
+ /**
100
+ * Removes all subscriptions for a specific event type.
101
+ * @param uid - The event type to remove subscriptions from.
102
+ */
103
+ clearSubscriptionsForEvent(uid: EntityEventUid): void;
104
+ /**
105
+ * Removes all subscriptions for a specific entity.
106
+ * @param entity - The entity to remove all subscriptions for.
107
+ */
108
+ clearSubscriptionsForEntity(entity: IEntityProxy): void;
109
+ }
110
+ /**
111
+ * Event dispatcher for publishing events to interested entities.
112
+ * Responsible for routing events to their subscribers through the update queue.
113
+ */
114
+ interface IEntityEventsDispatcher {
115
+ /**
116
+ * Publishes a single event to subscribers.
117
+ * The event is routed based on subscriptions or explicit target(s).
118
+ * @param event - The event to dispatch.
119
+ * @param targets - Optional specific entities to send to. If provided, event is only sent to these targets.
120
+ */
121
+ dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
122
+ /**
123
+ * Publishes multiple events to subscribers.
124
+ * Efficiently dispatches an array of events in bulk.
125
+ * @param events - The events to dispatch.
126
+ * @param targets - Optional specific entities to send to. If provided, events are only sent to these targets.
127
+ */
128
+ dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
129
+ }
130
+ //#endregion
131
+ //#region src/entities/entity-snapshot.d.ts
132
+ /**
133
+ * A serializable representation of entity state.
134
+ * Captures full or partial entity state including components, relationships, and events.
135
+ * Snapshots enable state replication, persistence, and delta updates from external sources.
136
+ */
137
+ interface IEntitySnapshot {
138
+ /**
139
+ * The entity's identity information if included in the snapshot.
140
+ */
141
+ readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
142
+ /**
143
+ * Entity components to be included in the snapshot.
144
+ * Only components marked as serializable are typically included.
145
+ */
146
+ readonly components?: IComponent[];
147
+ /**
148
+ * Entity relationships (proxies) to include in the snapshot.
149
+ */
150
+ readonly proxies?: IEntityProxy[];
151
+ /**
152
+ * Events associated with the entity to include in the snapshot.
153
+ */
154
+ readonly events?: IEntityEvent<IEventData>[];
155
+ }
156
+ /**
157
+ * Handles snapshot creation and application.
158
+ * Provides abstraction for converting between entities and their serializable snapshots.
159
+ * Used for state persistence, synchronization, and entity updates from external sources.
160
+ */
161
+ interface IEntitySnapshotProvider {
162
+ /**
163
+ * Applies a snapshot state to an entity.
164
+ * Updates the entity's components, relationships, and events based on the snapshot.
165
+ * @param entity - The entity to update.
166
+ * @param snapshot - The state to apply.
167
+ */
168
+ applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
169
+ /**
170
+ * Creates a snapshot capturing the current state of an entity.
171
+ * Serializes all or specified parts of the entity for storage or transmission.
172
+ * @param entity - The entity to snapshot.
173
+ * @returns A serializable representation of the entity state.
174
+ */
175
+ createSnapshot(entity: IEntity): IEntitySnapshot;
176
+ }
177
+ //#endregion
178
+ //#region src/entities/entity-queue.d.ts
179
+ /**
180
+ * Specifies the action to be performed on an entity.
181
+ * Updates are categorized to enable different processing paths in the runtime.
182
+ */
183
+ declare enum EntityUpdateType {
184
+ /**
185
+ * Indicates the entity should be updated with new data.
186
+ */
187
+ update = "update",
188
+ /**
189
+ * Indicates the entity should be removed from the system.
190
+ */
191
+ remove = "remove"
192
+ }
193
+ /**
194
+ * Represents a queued entity state change or removal.
195
+ * Updates flow through the system to be processed by entity update handlers.
196
+ */
197
+ interface IEntityUpdate {
198
+ /**
199
+ * The type of operation: update or remove.
200
+ */
201
+ readonly type: EntityUpdateType;
202
+ /**
203
+ * The entity being affected by this update.
204
+ */
205
+ readonly entity: IEntityProxy;
206
+ /**
207
+ * Optional model data for initialization or reconfiguration.
208
+ */
209
+ readonly model?: IEntityModel;
210
+ /**
211
+ * Optional serialized state to apply to the entity.
212
+ */
213
+ readonly snapshot?: IEntitySnapshot;
214
+ }
215
+ /**
216
+ * Queue interface for managing pending entity updates.
217
+ * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).
218
+ * Updates are consumed by the runtime and dispatched to appropriate entity systems.
219
+ */
220
+ interface IEntityUpdateQueue {
221
+ /**
222
+ * The current number of updates in the queue.
223
+ */
224
+ readonly size: number;
225
+ /**
226
+ * Adds an update to the queue for processing.
227
+ * @param change - The update to queue.
228
+ */
229
+ enqueue(change: IEntityUpdate): void;
230
+ /**
231
+ * Removes and returns the next update from the queue.
232
+ * The specific update returned depends on the queue's prioritization strategy.
233
+ * @returns The next queued update.
234
+ */
235
+ dequeue(): IEntityUpdate;
236
+ /**
237
+ * Views the next update without removing it.
238
+ * Useful for inspection before dequeuing.
239
+ * @returns The next update in the queue.
240
+ */
241
+ peek(): IEntityUpdate;
242
+ /**
243
+ * Removes all updates from the queue.
244
+ */
245
+ clear(): void;
246
+ }
247
+ //#endregion
248
+ //#region src/entities/entity-repository.d.ts
249
+ /**
250
+ * Central storage for all active entities in the system.
251
+ * The repository provides CRUD operations and is the source of truth for entity existence and state.
252
+ * All entity access and modifications go through this repository.
253
+ */
254
+ interface IEntityRepository {
255
+ /**
256
+ * The total number of entities currently stored.
257
+ */
258
+ readonly size: number;
259
+ /**
260
+ * Checks if an entity exists in storage.
261
+ * @param proxy - Reference to the entity to check.
262
+ * @returns True if the entity exists, false otherwise.
263
+ */
264
+ has(proxy: IEntityProxy): boolean;
265
+ /**
266
+ * Retrieves an entity from storage by proxy.
267
+ * @template TEntity - The expected entity type.
268
+ * @param proxy - Reference to the entity to retrieve.
269
+ * @returns The requested entity.
270
+ */
271
+ get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
272
+ /**
273
+ * Retrieves all entities of a specific type.
274
+ * @template TEntity - The entity type to retrieve.
275
+ * @param entityType - The type identifier to filter by.
276
+ * @returns Array of all entities matching the type.
277
+ */
278
+ getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
279
+ /**
280
+ * Iterates over all entities regardless of type.
281
+ * @returns An iterator over all stored entities.
282
+ */
283
+ listAll(): IterableIterator<IEntity>;
284
+ /**
285
+ * Stores or updates an entity.
286
+ * @param entity - The entity to store.
287
+ */
288
+ set(entity: IEntity): void;
289
+ /**
290
+ * Removes an entity from storage.
291
+ * @param proxy - Reference to the entity to remove.
292
+ */
293
+ delete(proxy: IEntityProxy): void;
294
+ /**
295
+ * Removes all entities of a specific type from storage.
296
+ * @param entityType - The type identifier for entities to remove.
297
+ */
298
+ clear(entityType: EntityTypeUid): void;
299
+ }
300
+ //#endregion
301
+ //#region src/entities/entity-scheduler.d.ts
302
+ /**
303
+ * Manages time-based scheduling of entity updates.
304
+ * Entities are registered with intervals and receive updates at the specified cadence, or on the next frame (engine-dependent).
305
+ */
306
+ interface IEntityScheduler {
307
+ /**
308
+ * Registers an entity for periodic updates.
309
+ * @param entityProxy - The entity to schedule.
310
+ * @param intervalMs - Update frequency in milliseconds. If omitted, a default interval is used.
311
+ */
312
+ schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
313
+ /**
314
+ * Unregisters an entity from the scheduler.
315
+ * The entity will no longer receive periodic updates.
316
+ * @param entityProxy - The entity to unschedule.
317
+ */
318
+ remove(entityProxy: IEntityProxy): void;
319
+ /**
320
+ * Checks if an entity is currently scheduled for updates.
321
+ * @param entityProxy - The entity to check.
322
+ * @returns True if the entity is scheduled, false otherwise.
323
+ */
324
+ has(entityProxy: IEntityProxy): boolean;
325
+ }
326
+ //#endregion
327
+ export { IEntityUpdateQueue as a, EntityEventSubscriptionFilter as c, IEntityEvent as d, IEntityEventsDispatcher as f, IEntityUpdate as i, EntityEventSubscriptionOptions as l, IEventData as m, IEntityRepository as n, IEntitySnapshot as o, IEntityEventsManager as p, EntityUpdateType as r, IEntitySnapshotProvider as s, IEntityScheduler as t, EntityEventUid as u };
328
+ //# sourceMappingURL=index-CfEs8NEA.d.mts.map
@@ -0,0 +1,224 @@
1
+ import { n as Immutable } from "./types-CnDtpKsY.mjs";
2
+ import { n as PerformanceTimeEntry } from "./index-BWmhFdFg.mjs";
3
+
4
+ //#region src/pipelines/pipeline-context.d.ts
5
+ /**
6
+ * Base interface for all pipeline context objects.
7
+ * Provides hooks for runtime state and control flow during pipeline execution.
8
+ */
9
+ interface IPipelineContext {
10
+ /**
11
+ * The runtime state and control interface for the pipeline.
12
+ * Allows middleware to query and influence pipeline behavior.
13
+ */
14
+ readonly runtime?: PipelineRuntime;
15
+ }
16
+ /**
17
+ * Runtime state and control interface for pipeline execution.
18
+ * Allows middleware to query status and influence pipeline flow.
19
+ */
20
+ type PipelineRuntime = {
21
+ /**
22
+ * Flag to request pipeline halt.
23
+ * Set to true to stop executing remaining middleware (cleanup still runs).
24
+ */
25
+ shouldStop?: boolean;
26
+ /**
27
+ * Optional error state if an exception occurred during execution.
28
+ */
29
+ error?: any;
30
+ /**
31
+ * Results collected from middleware execution.
32
+ * Typically includes performance metrics and operational results.
33
+ */
34
+ readonly metrics?: PerformanceTimeEntry[];
35
+ };
36
+ //#endregion
37
+ //#region src/pipelines/middleware.d.ts
38
+ /**
39
+ * The basic unit of work in a pipeline.
40
+ * Middleware are chained together to form processing pipelines.
41
+ * Each middleware can inspect/modify context during dispatch and perform cleanup on their changes.
42
+ *
43
+ * @template TContext The context type passed through the middleware chain.
44
+ */
45
+ interface IMiddleware<TContext extends IPipelineContext> {
46
+ /**
47
+ * Optional name for debugging and logging purposes.
48
+ */
49
+ readonly name?: string;
50
+ /**
51
+ * Optional guard condition before running the action.
52
+ * Allows middleware to skip execution based on context state.
53
+ * @param context The current pipeline context.
54
+ * @returns True to execute action, false to skip.
55
+ */
56
+ shouldRun?(context: TContext): boolean;
57
+ /**
58
+ * The main unit of work executed as part of the pipeline.
59
+ * Middlewares execute in registration order during dispatch phase.
60
+ * Can read and modify the context to influence downstream middleware and results.
61
+ * @param context The pipeline context containing all relevant state.
62
+ */
63
+ action(context: TContext): void | Promise<void>;
64
+ /**
65
+ * Optional cleanup function executed during pipeline teardown.
66
+ * Middlewares execute in reverse registration order during cleanup phase.
67
+ * Used to release resources, clear temporary state, and perform final operations.
68
+ * @param context The pipeline context (may be in modified state from action phases).
69
+ */
70
+ cleanup?(context: TContext): void | Promise<void>;
71
+ }
72
+ //#endregion
73
+ //#region src/pipelines/middleware-runner.d.ts
74
+ /**
75
+ * Customizes how middleware is executed within a pipeline.
76
+ * Allows decorators to wrap, intercept, or modify middleware execution behavior.
77
+ * Useful for implementing middleware decorators (logging, timing, error handling, etc.).
78
+ *
79
+ * @template TContext The type of context passed to middleware.
80
+ */
81
+ interface IMiddlewareRunner<TContext extends IPipelineContext> {
82
+ /**
83
+ * Decides how to execute a middleware's action.
84
+ * Can add pre/post processing, error handling, or performance tracking around the middleware.
85
+ * @param context The current pipeline context.
86
+ * @param middleware The middleware whose action should be executed.
87
+ */
88
+ dispatch(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
89
+ /**
90
+ * Decides how to execute a middleware's cleanup.
91
+ * Can add pre/post processing or error handling around cleanup operations.
92
+ * @param context The current pipeline context.
93
+ * @param middleware The middleware whose cleanup should be executed.
94
+ */
95
+ cleanup(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
96
+ }
97
+ //#endregion
98
+ //#region src/pipelines/pipeline.d.ts
99
+ /**
100
+ * A composable middleware chain for ordered execution of operations.
101
+ * Pipelines provide a framework for registering and executing middleware with dispatch and cleanup phases.
102
+ * Used throughout the ECS system for entity initialization, updates, rendering, and synchronization.
103
+ *
104
+ * @template TContext - The context type passed to all registered middleware.
105
+ */
106
+ interface IPipeline<TContext extends IPipelineContext> {
107
+ /**
108
+ * The pipeline's name, useful for debugging and logging.
109
+ */
110
+ readonly name?: string;
111
+ /**
112
+ * The number of middleware currently registered in this pipeline.
113
+ */
114
+ readonly length?: number;
115
+ /**
116
+ * Direct access to the ordered list of registered middleware.
117
+ * Allows inspection of the execution chain.
118
+ */
119
+ readonly middleware?: Immutable<IMiddleware<TContext>[]>;
120
+ /**
121
+ * Registers middleware to be executed as part of this pipeline.
122
+ * Middleware is added to the end of the chain and executed in registration order during dispatch.
123
+ * @param middleware - The middleware to register.
124
+ * @returns This instance for method chaining.
125
+ */
126
+ use(middleware: Immutable<IMiddleware<TContext>>): this;
127
+ /**
128
+ * Executes the dispatch phase with all registered middleware in order.
129
+ * Each middleware's action is called, allowing modifications to context state.
130
+ * Execution continues until all middleware complete or a middleware requests early termination.
131
+ * @param context - The context object passed to all middleware.
132
+ */
133
+ dispatch(context: Partial<TContext>): void | Promise<void>;
134
+ /**
135
+ * Executes the cleanup phase with all registered middleware in reverse order.
136
+ * Allows middleware to perform resource cleanup and final operations.
137
+ * Typically called after dispatch to ensure proper teardown.
138
+ *
139
+ * @param context - The context object that will be passed to each middleware function.
140
+ */
141
+ cleanup(context: Partial<TContext>): void | Promise<void>;
142
+ }
143
+ //#endregion
144
+ //#region src/pipelines/pipeline-nested.d.ts
145
+ /**
146
+ * Context for a parent pipeline containing nested pipelines.
147
+ * Allows coordination between outer and inner pipeline execution.
148
+ *
149
+ * @template N - The context type for the nested pipelines.
150
+ */
151
+ interface IParentContext<N extends IPipelineContext> extends IPipelineContext {
152
+ /**
153
+ * The nested pipeline to execute for each context in nestedContexts.
154
+ */
155
+ readonly nestedPipeline: IPipeline<INestedContext<this>>;
156
+ /**
157
+ * Contexts to pass to the nested pipeline.
158
+ * The parent pipeline iterates these and executes the nested pipeline for each.
159
+ */
160
+ readonly nestedContexts: Partial<N>[];
161
+ }
162
+ /**
163
+ * Context for a nested pipeline.
164
+ * Provides access to both current and previous nested context data plus the parent context.
165
+ *
166
+ * @template P - The context type of the parent pipeline.
167
+ */
168
+ interface INestedContext<P extends IParentContext<any>> extends IPipelineContext {
169
+ /**
170
+ * The current context item being processed in the nested pipeline.
171
+ */
172
+ readonly current: P extends IParentContext<infer N> ? N : never;
173
+ /**
174
+ * The previous context item (if this is not the first iteration).
175
+ */
176
+ readonly previous?: P extends IParentContext<infer N> ? N : never;
177
+ /**
178
+ * Reference back to the parent pipeline context.
179
+ */
180
+ readonly parent: P;
181
+ }
182
+ /**
183
+ * Middleware executing within a nested pipeline.
184
+ *
185
+ * @template P - The context type of the parent pipeline.
186
+ */
187
+ type INestedMiddleware<P extends IParentContext<any>> = IMiddleware<INestedContext<P>>;
188
+ /**
189
+ * Middleware executing within a parent pipeline (containing nested pipelines).
190
+ *
191
+ * @template P - The context type of the parent pipeline.
192
+ */
193
+ type IParentMiddleware<P extends IParentContext<any>> = IMiddleware<P>;
194
+ //#endregion
195
+ //#region src/pipelines/pipeline-runner.d.ts
196
+ /**
197
+ * Executes an array of middleware in a controlled sequence.
198
+ * Supports custom execution strategies through implementation flexibility.
199
+ * Used by pipelines to manage complex middleware chains with features like early termination and nested pipelines.
200
+ *
201
+ * @template TContext - The context type passed to all middleware.
202
+ */
203
+ interface IPipelineRunner<TContext extends IPipelineContext> {
204
+ /**
205
+ * Executes the action phase of all middleware in sequence.
206
+ * Middleware at startIndex and onward are executed in order.
207
+ * Execution may terminate early if middleware requests it via context.runtime.shouldStop.
208
+ * @param context - The context passed to each middleware action.
209
+ * @param middleware - The ordered middleware array to execute.
210
+ * @param startIndex - Optional starting position in the middleware array (default: 0).
211
+ */
212
+ dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): void | Promise<void>;
213
+ /**
214
+ * Executes the cleanup phase of all middleware in reverse order.
215
+ * All middleware cleanup functions are called (if defined), regardless of errors.
216
+ * Allows proper resource release and final state management.
217
+ * @param context - The context passed to each middleware cleanup.
218
+ * @param middleware - The ordered middleware array for cleanup (reversed during execution).
219
+ */
220
+ cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): void | Promise<void>;
221
+ }
222
+ //#endregion
223
+ 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 };
224
+ //# sourceMappingURL=index-D4jK3qG1.d.mts.map