@awesome-ecs/abstract 0.20.2 → 0.21.1

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 (60) hide show
  1. package/README.md +129 -0
  2. package/dist/components/index.cjs +10 -32
  3. package/dist/components/index.cjs.map +1 -1
  4. package/dist/components/index.d.cts +3 -2
  5. package/dist/components/index.d.ts +3 -2
  6. package/dist/components/index.js +11 -8
  7. package/dist/components/index.js.map +1 -1
  8. package/dist/entities/index.cjs +11 -33
  9. package/dist/entities/index.cjs.map +1 -1
  10. package/dist/entities/index.d.cts +4 -34
  11. package/dist/entities/index.d.ts +4 -34
  12. package/dist/entities/index.js +12 -9
  13. package/dist/entities/index.js.map +1 -1
  14. package/dist/factories/index.cjs +0 -18
  15. package/dist/factories/index.d.cts +44 -44
  16. package/dist/factories/index.d.ts +44 -44
  17. package/dist/factories/index.js +0 -1
  18. package/dist/identity-component-BDWEtAXA.d.cts +238 -0
  19. package/dist/identity-component-CR1ULadR.d.ts +238 -0
  20. package/dist/index-C3UGZqUG.d.ts +288 -0
  21. package/dist/index-CKh4A7mH.d.cts +460 -0
  22. package/dist/index-ChV4Q5j6.d.cts +137 -0
  23. package/dist/index-Cm-YSPhK.d.ts +254 -0
  24. package/dist/index-D81Fo9XN.d.cts +254 -0
  25. package/dist/index-DLm-DKAk.d.cts +288 -0
  26. package/dist/index-oenqxDCa.d.ts +137 -0
  27. package/dist/index-zpj0YApu.d.ts +460 -0
  28. package/dist/pipelines/index.cjs +28 -35
  29. package/dist/pipelines/index.cjs.map +1 -1
  30. package/dist/pipelines/index.d.cts +4 -56
  31. package/dist/pipelines/index.d.ts +4 -56
  32. package/dist/pipelines/index.js +29 -11
  33. package/dist/pipelines/index.js.map +1 -1
  34. package/dist/systems/index.cjs +31 -35
  35. package/dist/systems/index.cjs.map +1 -1
  36. package/dist/systems/index.d.cts +7 -101
  37. package/dist/systems/index.d.ts +7 -101
  38. package/dist/systems/index.js +32 -11
  39. package/dist/systems/index.js.map +1 -1
  40. package/dist/{types-cZ-1lGPD.d.ts → types-DvzdpbLu.d.cts} +9 -17
  41. package/dist/{types-cZ-1lGPD.d.cts → types-yh4pOGEm.d.ts} +9 -17
  42. package/dist/utils/index.cjs +25 -35
  43. package/dist/utils/index.cjs.map +1 -1
  44. package/dist/utils/index.d.cts +3 -92
  45. package/dist/utils/index.d.ts +3 -92
  46. package/dist/utils/index.js +26 -11
  47. package/dist/utils/index.js.map +1 -1
  48. package/package.json +3 -3
  49. package/dist/entity-repository-BlSpo-x2.d.ts +0 -253
  50. package/dist/entity-repository-DJ1xbvaN.d.cts +0 -253
  51. package/dist/factories/index.cjs.map +0 -1
  52. package/dist/factories/index.js.map +0 -1
  53. package/dist/index-B1KXekZD.d.ts +0 -199
  54. package/dist/index-CnlpX7ys.d.cts +0 -199
  55. package/dist/performance-timer-BVyl0SRs.d.cts +0 -45
  56. package/dist/performance-timer-BVyl0SRs.d.ts +0 -45
  57. package/dist/pipeline-BGsQiSer.d.ts +0 -161
  58. package/dist/pipeline-DunwPUPZ.d.cts +0 -161
  59. package/dist/systems-runtime-context-BTNdV8Z-.d.ts +0 -330
  60. package/dist/systems-runtime-context-DhtHMczN.d.cts +0 -330
@@ -0,0 +1,460 @@
1
+ import { EntityProxy, EntityTypeUid, IEntity, IEntityModel, IEntityProxy } from "./identity-component-BDWEtAXA.cjs";
2
+ import { Immutable } from "./types-DvzdpbLu.cjs";
3
+ import { EntityEventUid, IEntityEvent, IEntityRepository, IEntitySnapshot, IEntityUpdate, IEventData } from "./index-DLm-DKAk.cjs";
4
+ import { IMiddleware, IPipeline, IPipelineContext, PipelineResult } from "./index-D81Fo9XN.cjs";
5
+ import { IJsonSerializer, ILogger } from "./index-ChV4Q5j6.cjs";
6
+
7
+ //#region src/systems/module/system-type.d.ts
8
+ /**
9
+ * Enum representing the built-in System pipeline types.
10
+ * These types can be extended to introduce more types, and the System Runtime Pipeline should
11
+ * add Middleware to handle the newly added types.
12
+ */
13
+ declare enum SystemType {
14
+ /**
15
+ * The initialization phase of the Module pipeline.
16
+ * This phase is typically used for setting up initial state and resources.
17
+ */
18
+ initialize = "initialize",
19
+ /**
20
+ * The update phase of the Module pipeline.
21
+ * This phase is responsible for updating the game logic and state of entities.
22
+ */
23
+ update = "update",
24
+ /**
25
+ * The render phase of the Module pipeline.
26
+ * This phase is used for rendering the game to the screen.
27
+ */
28
+ render = "render",
29
+ /**
30
+ * The synchronization phase of the Module pipeline.
31
+ * This phase is used for synchronizing game state with external systems or other components.
32
+ */
33
+ sync = "sync",
34
+ }
35
+ //#endregion
36
+ //#region src/systems/pipeline/system-context-events.d.ts
37
+ /**
38
+ * The ISystemContextEvents is the access point for Event related APIs.
39
+ * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
40
+ */
41
+ interface ISystemContextEvents {
42
+ /**
43
+ * Dispatches and schedules the Event to its Subscribers or provided Entity Targets.
44
+ * @param data - The EventData to dispatch.
45
+ * @param targets - (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
46
+ */
47
+ dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
48
+ /**
49
+ * Dispatches and schedules the Events to their Subscribers or provided Entity Targets.
50
+ * @param data - The EventData Array to dispatch.
51
+ * @param targets - (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
52
+ */
53
+ dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
54
+ /**
55
+ * Retrieves the Event with the given UID if it has been previously set on the current Context.
56
+ * @param uid - The Event UID to retrieve.
57
+ * @returns The Event with the given UID if it exists, otherwise undefined.
58
+ */
59
+ getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData> | undefined;
60
+ /**
61
+ * Retrieves all the Events currently set on the Context.
62
+ * @returns An array of all the Events currently set on the Context.
63
+ */
64
+ listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
65
+ /**
66
+ * Returns whether the Event with the given UID has previously been set on the current Context.
67
+ * @param uid - The Event UID to check for existence. If not provided, checks for any events in the context.
68
+ * @returns True if the Event with the given UID exists, otherwise false.
69
+ */
70
+ hasEvent(uid?: EntityEventUid): boolean;
71
+ /**
72
+ * Subscribes to Events with the given UID. When the matching Event is dispatched,
73
+ * the Entity update loop will set this Event on the Pipeline Context.
74
+ * @param uid - The Event UID to subscribe to.
75
+ * @param filter - (optional) Provides a callback function that will be executed on all matching Events.
76
+ * Can be used to filter what Event to schedule through to the current Entity update.
77
+ */
78
+ subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
79
+ /**
80
+ * Stops subscribing to Events with the given UID. The Entity will not receive any future Events with this UID.
81
+ * @param uid - The Event UID to stop listening to.
82
+ */
83
+ unsubscribeFrom(uid: EntityEventUid): void;
84
+ /**
85
+ * Adds the given Events into the Context instance.
86
+ * @param events - The Event instances to be set on the Context.
87
+ */
88
+ setContextEvents(events: IEntityEvent<IEventData>[]): void;
89
+ /**
90
+ * Adds the given Event into the Context instance.
91
+ * @param event - The Event instance to be set on the Context.
92
+ */
93
+ setContextEvent(event: IEntityEvent<IEventData>): void;
94
+ /**
95
+ * Removes all the Events currently set on the Context instance.
96
+ */
97
+ clearContextEvents(): void;
98
+ /**
99
+ * Removes all the Event Subscriptions for the current Entity.
100
+ */
101
+ clearSubscriptions(): void;
102
+ }
103
+ //#endregion
104
+ //#region src/systems/pipeline/system-context-proxies.d.ts
105
+ /**
106
+ * Provides a context-bound interface for managing proxy relationships for the current entity.
107
+ */
108
+ interface ISystemContextProxies {
109
+ /**
110
+ * Registers a proxy for the current entity, establishing a bi-directional link.
111
+ * @param proxy The proxy to register for the current entity.
112
+ * @param cleanup If true, removes all existing proxies of the same type before adding the new one.
113
+ */
114
+ register(proxy: IEntityProxy, cleanup?: boolean): void;
115
+ /**
116
+ * Registers multiple proxies for the current entity.
117
+ * @param proxies The proxies to register.
118
+ * @param cleanup If true, removes existing proxies of the same types as the new ones before adding.
119
+ */
120
+ registerMany(proxies: readonly IEntityProxy[], cleanup?: boolean): void;
121
+ /**
122
+ * Removes a proxy from the current entity, breaking the bi-directional link.
123
+ * @param proxy The proxy to remove from the current entity.
124
+ */
125
+ remove(proxy: IEntityProxy): void;
126
+ /**
127
+ * Removes all proxies for the current entity, optionally filtered by a target entity type.
128
+ * @param targetType The optional entity type to remove. If not provided, all proxies are removed.
129
+ */
130
+ removeAll(targetType?: EntityTypeUid): void;
131
+ /**
132
+ * Gets a single proxy for the current entity by its target type.
133
+ * If multiple proxies of the same type exist, the first one found is returned.
134
+ * @param targetType The entity type of the proxy to retrieve.
135
+ * @returns The entity proxy, or null if not found.
136
+ */
137
+ get(targetType: EntityTypeUid): IEntityProxy | null;
138
+ /**
139
+ * Gets all proxies for the current entity that match a given target type.
140
+ * @param targetType The entity type of the proxies to retrieve.
141
+ * @returns A readonly array of entity proxies.
142
+ */
143
+ getMany(targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
144
+ /**
145
+ * Gets all proxies associated with the current entity.
146
+ * @returns A readonly map of entity type UIDs to an array of their proxies.
147
+ */
148
+ getAll(): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
149
+ }
150
+ //#endregion
151
+ //#region src/systems/pipeline/system-context-repository.d.ts
152
+ /**
153
+ * The `ISystemContextRepository` is the access point for the `IEntityRepository` related APIs.
154
+ *
155
+ * The access is made in an `ISystemMiddleware` through the provided `ISystemPipelineContext`.
156
+ */
157
+ interface ISystemContextRepository {
158
+ /**
159
+ * Schedule adding a new entity to the repository.
160
+ *
161
+ * @param entityType - The type of the entity.
162
+ * @param model - The model of the entity.
163
+ * @param snapshot - Optional initial snapshot of the entity.
164
+ */
165
+ addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
166
+ /**
167
+ * Retrieves an entity from the repository.
168
+ *
169
+ * @template TEntity - The type of the entity.
170
+ * @param proxy - The proxy of the entity.
171
+ * @returns An immutable representation of the entity.
172
+ */
173
+ getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): Immutable<TEntity>;
174
+ /**
175
+ * Schedule updating an entity in the repository.
176
+ *
177
+ * @param target - Optional target entity proxy. If not provided, updates the current entity set on the system context.
178
+ */
179
+ updateEntity(target?: IEntityProxy): void;
180
+ /**
181
+ * Removes an entity from the repository.
182
+ *
183
+ * @param target - The entity proxy to be removed.
184
+ */
185
+ removeEntity(target: IEntityProxy): void;
186
+ }
187
+ //#endregion
188
+ //#region src/systems/pipeline/system-context-scheduler.d.ts
189
+ /**
190
+ * The `ISystemContextScheduler` interface represents the access point for Scheduler related APIs.
191
+ * The access is made in a `SystemMiddleware` through the provided `ISystemPipelineContext`.
192
+ */
193
+ interface ISystemContextScheduler {
194
+ /**
195
+ * Schedules an update for the specified `target` entity proxy at a given `intervalMs`.
196
+ * If no `target` is provided, update will be scheduled for the current entity set on the system context.
197
+ * If no `intervalMs` is provided, the default update interval will be used.
198
+ *
199
+ * @param target - The entity proxy for which the update is scheduled.
200
+ * @param intervalMs - The interval in milliseconds at which the update should be triggered.
201
+ */
202
+ scheduleUpdate(target?: IEntityProxy, intervalMs?: number): void;
203
+ /**
204
+ * Removes the scheduled update for the specified `target` entity proxy.
205
+ * If no `target` is provided, schedule is removed for the current entity set on the system context.
206
+ *
207
+ * @param target - The entity proxy for which the scheduled update should be removed.
208
+ */
209
+ removeSchedule(target?: IEntityProxy): void;
210
+ }
211
+ //#endregion
212
+ //#region src/systems/pipeline/system-context-snapshot.d.ts
213
+ /**
214
+ * The ISystemContextSnapshot is the access point for Snapshot related APIs.
215
+ * The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
216
+ */
217
+ interface ISystemContextSnapshot {
218
+ /**
219
+ * A read-only reference to the JSON serializer used for snapshot serialization.
220
+ */
221
+ readonly serializer: Immutable<IJsonSerializer>;
222
+ /**
223
+ * Applies the provided entity snapshot to the current entity set on the system context.
224
+ *
225
+ * @param snapshot - The entity snapshot to apply.
226
+ */
227
+ applyToEntity(snapshot: IEntitySnapshot): void;
228
+ /**
229
+ * Creates a new entity snapshot from the provided entity.
230
+ *
231
+ * @param entity - The entity to create a snapshot from. If not provided, a snapshot for the current entity set on the system context will be created.
232
+ * @returns A new entity snapshot.
233
+ */
234
+ createFromEntity(entity?: IEntity): IEntitySnapshot;
235
+ /**
236
+ * Dispatches an update to the entity using the provided snapshot and entity proxy.
237
+ *
238
+ * @param snapshot - The entity snapshot to use for the update.
239
+ * @param proxy - The entity proxy to use for the update.
240
+ */
241
+ dispatchToUpdate(snapshot: IEntitySnapshot, proxy: IEntityProxy): void;
242
+ }
243
+ //#endregion
244
+ //#region src/systems/pipeline/system-context.d.ts
245
+ /**
246
+ * The ISystemContext is the Context passed to a SystemMiddleware as part of the Pipeline Dispatch.
247
+ * It's an abstraction layer so that the Middleware code won't have explicit dependencies on other parts of the ECS.
248
+ *
249
+ * Any State changes done by the SystemMiddleware are executed using the APIs provided by the ISystemContext.
250
+ *
251
+ * @template TEntity - The type of entity that the SystemMiddleware operates on.
252
+ * @extends IPipelineContext - The ISystemContext extends the IPipelineContext interface.
253
+ */
254
+ interface ISystemContext<TEntity extends IEntity> extends IPipelineContext {
255
+ /**
256
+ * The time in milliseconds since the last entity update.
257
+ */
258
+ readonly deltaTimeMs: Immutable<number>;
259
+ /**
260
+ * The entity that the SystemMiddleware is operating on.
261
+ */
262
+ readonly entity: Immutable<TEntity>;
263
+ /**
264
+ * The update object containing information about the entity's changes.
265
+ */
266
+ readonly update: Immutable<IEntityUpdate>;
267
+ /**
268
+ * The events API for the SystemMiddleware to interact with the ECS events system.
269
+ */
270
+ readonly events: Immutable<ISystemContextEvents>;
271
+ /**
272
+ * The proxies API for the SystemMiddleware to interact with the ECS proxies system.
273
+ */
274
+ readonly proxies: Immutable<ISystemContextProxies>;
275
+ /**
276
+ * The repository API for the SystemMiddleware to interact with the ECS repository system.
277
+ */
278
+ readonly repository: Immutable<ISystemContextRepository>;
279
+ /**
280
+ * The scheduler API for the SystemMiddleware to interact with the ECS scheduler system.
281
+ */
282
+ readonly scheduler: Immutable<ISystemContextScheduler>;
283
+ /**
284
+ * The snapshot API for the SystemMiddleware to interact with the ECS snapshot system.
285
+ */
286
+ readonly snapshot: Immutable<ISystemContextSnapshot>;
287
+ /**
288
+ * The logger API for the SystemMiddleware to log messages.
289
+ */
290
+ readonly logger: Immutable<ILogger>;
291
+ }
292
+ //#endregion
293
+ //#region src/systems/pipeline/system-context-entity.d.ts
294
+ /**
295
+ * Interface representing a system context entity.
296
+ * This interface provides methods to manipulate and access entity and update data.
297
+ */
298
+ interface ISystemContextEntity {
299
+ /**
300
+ * The immutable entity associated with the system context.
301
+ */
302
+ readonly entity: Immutable<IEntity>;
303
+ /**
304
+ * The immutable entity update associated with the system context.
305
+ */
306
+ readonly update: Immutable<IEntityUpdate>;
307
+ /**
308
+ * Sets the entity associated with the system context entity.
309
+ *
310
+ * @param entity - The new entity to be associated with the system context.
311
+ */
312
+ setEntity(entity: IEntity): void;
313
+ /**
314
+ * Sets the entity update associated with the system context.
315
+ *
316
+ * @param update - The new entity update to be associated with the system context.
317
+ */
318
+ setUpdate(update: IEntityUpdate): void;
319
+ }
320
+ //#endregion
321
+ //#region src/systems/runtime/systems-runtime-context.d.ts
322
+ /**
323
+ * The ISystemsRuntimeContext is the Context passed by a SystemsRuntimePipeline.
324
+ * It helps orchestrate the execution of SystemPipelines registered in the SystemsModule.
325
+ */
326
+ interface ISystemsRuntimeContext<TEntity extends IEntity> extends IPipelineContext {
327
+ /**
328
+ * A Set of allowed steps for the SystemPipelines.
329
+ */
330
+ readonly allowedSteps: Set<SystemType>;
331
+ /**
332
+ * An entity provider for the SystemPipelines.
333
+ */
334
+ readonly entityProvider: ISystemContextEntity;
335
+ /**
336
+ * An entity repository for the SystemPipelines.
337
+ */
338
+ readonly entityRepository: IEntityRepository;
339
+ /**
340
+ * A Map of SystemPipelines registered in the SystemsModule.
341
+ */
342
+ readonly systemPipelines: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
343
+ /**
344
+ * The SystemContext for the SystemPipelines.
345
+ */
346
+ readonly systemContext: ISystemContext<TEntity>;
347
+ }
348
+ //#endregion
349
+ //#region src/systems/runtime/systems-runtime-middleware.d.ts
350
+ /**
351
+ * The `ISystemsRuntimeMiddleware` represents the building blocks of executing SystemsModule's registered Pipelines.
352
+ * It receives the current State in the Context, and can decide which SystemPipelines to execute.
353
+ *
354
+ * @typeParam TEntity - The type of entity that the middleware operates on.
355
+ * @extends {IMiddleware<ISystemsRuntimeContext<TEntity>>} - Extends the base `IMiddleware` interface, which is used for defining middleware functions.
356
+ */
357
+ type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
358
+ //#endregion
359
+ //#region src/systems/pipeline/system-middleware.d.ts
360
+ /**
361
+ * The `ISystemMiddleware` is a basic System implementation that can be registered as a Middleware in a SystemPipeline.
362
+ * It provides a `SystemPipelineContext` to its exposed methods.
363
+ *
364
+ * @template TEntity - The type of entity that this middleware operates on.
365
+ * @extends {IMiddleware<ISystemContext<TEntity>>} - Extends the base `IMiddleware` interface, which requires a `SystemPipelineContext` to be provided.
366
+ */
367
+ type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
368
+ //#endregion
369
+ //#region src/systems/module/systems-module-definition.d.ts
370
+ /**
371
+ * The SystemModuleDefinition is the main way of composing SystemsModules for an Entity.
372
+ * It can be used as building blocks for SystemsModules as a way to register common SystemMiddlewares and share across different Entities.
373
+ */
374
+ interface ISystemsModuleDefinition<TEntity extends IEntity> {
375
+ readonly systems: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
376
+ /**
377
+ * Registers SystemMiddlewares to the specified SystemPipelineType.
378
+ *
379
+ * @param type - The SystemPipelineType to append the provided SystemMiddlewares to.
380
+ * @param systems - The SystemMiddlewares to be registered in the provided SystemPipelineType in the same order as the provided array.
381
+ * The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
382
+ */
383
+ registerSystems?(type: SystemType, systems: Immutable<ISystemMiddleware<TEntity>[]>): void;
384
+ /**
385
+ * Registers the middleware of the provided SystemsModule in the current SystemsModule. Keeps the same system types.
386
+ * @param module - The SystemsModule to be registered.
387
+ */
388
+ registerModule?(module: Immutable<ISystemsModuleDefinition<TEntity>>): void;
389
+ }
390
+ //#endregion
391
+ //#region src/systems/module/systems-module.d.ts
392
+ /**
393
+ * The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
394
+ * It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
395
+ */
396
+ interface ISystemsModule<TEntity extends IEntity> extends ISystemsModuleDefinition<TEntity> {
397
+ /**
398
+ * Triggers all registered SystemPipelines to apply the changes from the provided EntityUpdate to an Entity instance.
399
+ *
400
+ * @param update - The EntityUpdate containing the desired changes to be applied on an Entity instance.
401
+ * @returns An optional PipelineResult indicating the success or failure of the triggered SystemPipelines.
402
+ */
403
+ triggerSystems(update: Immutable<IEntityUpdate>): void | PipelineResult;
404
+ }
405
+ //#endregion
406
+ //#region src/systems/module/systems-module-repository.d.ts
407
+ /**
408
+ * Interface for managing systems modules.
409
+ *
410
+ * @template TEntity - The type of entity that the systems module operates on.
411
+ */
412
+ interface ISystemsModuleRepository {
413
+ /**
414
+ * The number of systems modules in the repository.
415
+ */
416
+ readonly size: number;
417
+ /**
418
+ * Retrieves a systems module for a specific entity type.
419
+ *
420
+ * @param type - The unique identifier of the entity type.
421
+ * @returns The systems module for the specified entity type.
422
+ */
423
+ get<TEntity extends IEntity>(type: EntityTypeUid): ISystemsModule<TEntity>;
424
+ /**
425
+ * Adds or updates a systems module for a specific entity type.
426
+ *
427
+ * @param type - The unique identifier of the entity type.
428
+ * @param module - The systems module to add or update.
429
+ */
430
+ set(type: EntityTypeUid, module: ISystemsModule<IEntity>): void;
431
+ /**
432
+ * Retrieves a read-only map of all systems modules in the repository.
433
+ *
434
+ * @returns A read-only map of entity type unique identifiers to systems modules.
435
+ */
436
+ list(): ReadonlyMap<EntityTypeUid, Immutable<ISystemsModule<IEntity>>>;
437
+ }
438
+ //#endregion
439
+ //#region src/systems/runtime/systems-runtime.d.ts
440
+ /**
441
+ * The System Runtime allows running a loop of Ticks.
442
+ *
443
+ * Each `runTick` method can process one or more Entity Updates.
444
+ *
445
+ * We can have multiple implementations of a `SystemsRuntime`, based on the use-case.
446
+ * A different implementation can be chosen at runtime, based for example on performance.
447
+ */
448
+ interface ISystemsRuntime {
449
+ /**
450
+ * The method should trigger the SystemsModule logic for the provided `IEntityUpdate`.
451
+ * If no EntityUpdate is given, the `SystemRuntime` implementation can choose to dequeue one from the `IEntityUpdateQueue`.
452
+ *
453
+ * @param update - An optional `IEntityUpdate` to process. If not provided, the method will dequeue one from the `IEntityUpdateQueue`.
454
+ * @returns A `PipelineResult` representing the outcome of the SystemsModule logic execution.
455
+ */
456
+ runTick(update?: IEntityUpdate): PipelineResult;
457
+ }
458
+ //#endregion
459
+ export { ISystemContext, ISystemContextEntity, ISystemContextEvents, ISystemContextProxies, ISystemContextRepository, ISystemContextScheduler, ISystemContextSnapshot, ISystemMiddleware, ISystemsModule, ISystemsModuleDefinition, ISystemsModuleRepository, ISystemsRuntime, ISystemsRuntimeContext, ISystemsRuntimeMiddleware, SystemType };
460
+ //# sourceMappingURL=index-CKh4A7mH.d.cts.map
@@ -0,0 +1,137 @@
1
+ //#region src/utils/json-serializer.d.ts
2
+ /**
3
+ * A custom `IJsonSerializer` interface allows for different ways of serializing and parsing objects.
4
+ */
5
+ interface IJsonSerializer {
6
+ /**
7
+ * Serializes the given object into a JSON string.
8
+ *
9
+ * @param value The object to be serialized.
10
+ * @returns A JSON string representation of the object.
11
+ */
12
+ serializeCustom(value: object): string;
13
+ /**
14
+ * Parses a JSON string into the specified object type.
15
+ *
16
+ * @template TObject The type of the object to be parsed.
17
+ * @param text The JSON string to be parsed.
18
+ * @returns The parsed object of type `TObject`.
19
+ */
20
+ parseCustom<TObject>(text: string): TObject;
21
+ }
22
+ //#endregion
23
+ //#region src/utils/logger.d.ts
24
+ /**
25
+ * An ILogger instance allows printing messages to console or other targets.
26
+ */
27
+ interface ILogger {
28
+ /**
29
+ * Logs a message with a specified level.
30
+ * @param level The level of the message.
31
+ * @param message The message to be logged.
32
+ * @param ...args Additional arguments to be included in the message.
33
+ */
34
+ log(level: LogLevel, message: any, ...args: any[]): void;
35
+ /**
36
+ * Logs a trace-level message.
37
+ * @param message The message to be logged.
38
+ * @param ...args Additional arguments to be included in the message.
39
+ */
40
+ trace(message: any, ...args: any[]): void;
41
+ /**
42
+ * Logs a debug-level message.
43
+ * @param message The message to be logged.
44
+ * @param ...args Additional arguments to be included in the message.
45
+ */
46
+ debug(message: any, ...args: any[]): void;
47
+ /**
48
+ * Logs a warning-level message.
49
+ * @param message The message to be logged.
50
+ * @param ...args Additional arguments to be included in the message.
51
+ */
52
+ warn(message: any, ...args: any[]): void;
53
+ /**
54
+ * Logs an error-level message.
55
+ * @param message The message to be logged.
56
+ * @param ...args Additional arguments to be included in the message.
57
+ */
58
+ error(message: any, ...args: any[]): void;
59
+ }
60
+ /**
61
+ * An enumeration of log levels.
62
+ */
63
+ declare enum LogLevel {
64
+ /**
65
+ * Trace-level logging.
66
+ */
67
+ trace = 0,
68
+ /**
69
+ * Debug-level logging.
70
+ */
71
+ debug = 1,
72
+ /**
73
+ * Warning-level logging.
74
+ */
75
+ warn = 2,
76
+ /**
77
+ * Error-level logging.
78
+ */
79
+ error = 3,
80
+ }
81
+ /**
82
+ * Options for configuring an ILogger instance.
83
+ */
84
+ interface ILoggerOptions {
85
+ /**
86
+ * A map of log levels to their corresponding enabled status.
87
+ */
88
+ enabled: Map<LogLevel, boolean>;
89
+ }
90
+ //#endregion
91
+ //#region src/utils/performance-timer.d.ts
92
+ /**
93
+ * A unique identifier for a timer.
94
+ */
95
+ type PerformanceTimerUid = number;
96
+ /**
97
+ * A record of a timer's execution.
98
+ *
99
+ * @remarks
100
+ * This interface represents the details of a timer's execution.
101
+ * It includes the timer's name, start timestamp, end timestamp, and the duration of the timer's execution in milliseconds.
102
+ *
103
+ * @property {string} name - The name of the timer.
104
+ * @property {number} startedAt - The timestamp when the timer started.
105
+ * @property {number} [endedAt] - The timestamp when the timer ended.
106
+ * @property {number} [msPassed] - The time in milliseconds that the timer was active.
107
+ */
108
+ interface PerformanceTimeEntry {
109
+ name: string;
110
+ startedAt: number;
111
+ endedAt?: number;
112
+ msPassed?: number;
113
+ }
114
+ /**
115
+ * An interface for a performance timer.
116
+ * This interface provides methods to start and end timers,
117
+ * and retrieve information about their execution.
118
+ */
119
+ interface IPerformanceTimer {
120
+ /**
121
+ * Starts a new timer with the given name.
122
+ * @param {string} name - The name of the timer.
123
+ * @returns {PerformanceTimerUid} - A unique identifier for the newly started timer.
124
+ */
125
+ startTimer(name: string): PerformanceTimerUid;
126
+ /**
127
+ * Ends the timer with the given timerUid and returns a record of its execution.
128
+ * @param {PerformanceTimerUid} timerUid - The unique identifier of the timer to end.
129
+ * @returns {PerformanceTimeEntry} - A record of the timer's execution.
130
+ * The returned object contains the timer's name, start timestamp, end timestamp,
131
+ * and the duration of the timer's execution in milliseconds.
132
+ */
133
+ endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
134
+ }
135
+ //#endregion
136
+ export { IJsonSerializer, ILogger, ILoggerOptions, IPerformanceTimer, LogLevel, PerformanceTimeEntry, PerformanceTimerUid };
137
+ //# sourceMappingURL=index-ChV4Q5j6.d.cts.map