@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
package/README.md CHANGED
@@ -1,228 +1,126 @@
1
- # Awesome ECS (Entity-Component-System)
2
-
3
- ## What is it?
4
-
5
- The Entity-Component-System is a well-known Architecture type used for responsive, complex applications, not only restricted to the Web.
6
- It's mostly associated with Game Engines, because of it's way of segregating Behavior from State, and allowing fine-control of the Runtime.
7
-
8
- ## Real-World Usage Patterns
9
-
10
- Based on the analysis of real-world usage in project-anchor, here are the key patterns that have proven effective:
11
-
12
- ### Component Patterns
13
-
14
- - **Component Type Enumeration**: Components are identified using a `ComponentType` enum, making component retrieval and identification type-safe and consistent
15
- - **Specialized Component Focus**: Components focus on specific concerns (e.g., `CoordinatesComponent`, `RenderingComponent`, `AssetsComponent`)
16
- - **Component Serialization**: Components can be marked with `isSerializable` to control which components get synchronized with external systems
17
- - **Component Factories**: Using factory patterns to create and configure components with standard defaults
18
-
19
- ### Entity Patterns
20
-
21
- - **Type-Safe Entity Access**: Entities expose strongly-typed getters for their components
22
- - **Entity Proxies**: Entities use proxy objects to reference other entities, maintaining relationships while avoiding direct dependencies
23
- - **Entity Type Enumeration**: Entities are categorized using an `EntityType` enum
24
- - **Entity Hierarchy**: Entities often form hierarchical relationships (e.g., scene → grid → tile)
25
-
26
- ### System Organization
27
-
28
- - **System Pipelines**: Systems are organized into distinct pipelines (initialize, update, render) that execute in sequence
29
- - **System Modules**: Systems are grouped in modules that target specific entity types
30
- - **Middleware Approach**: Systems implement the middleware pattern for clean, composable behavior
31
-
32
- ## Building blocks
33
-
34
- ### Entities
35
-
36
- Entities are really just collections of Components.
37
-
38
- In this Awesome ECS Architecture implementation, an Entity is built of:
39
-
40
- - one or more Components
41
- - proxies to other Entities
42
-
43
- Entity changes can triggered from outside systems (e.g. UI events, data from backend, a Redux Store change), or on ran a Schedule (e.g. Engine Loop).
44
-
45
- ### Components
46
-
47
- Components are data-holders. They are instantiated for each Entity, and hold the state for the Entity.
48
- An Entity can have many different types of Components, based on what the Entity State is.
49
-
50
- Components should not contain any behavior, only keep data (e.g. Plain-Objects).
51
-
52
- ### Systems
53
-
54
- Systems are behaviors of the ECS Architecture. They receive an Entity as input, and run Behaviors, altering the data contained in the Entity's Components.
55
- Systems are usually Entity-specific, but they can be shared (e.g. Two Entities having the same Component Type, can in fact, share a System's Behavior).
56
-
57
- ## Awesome ECS Architecture
58
-
59
- ### Pipeline
60
-
61
- The Pipelines are at the heart of the Easy ECS Architecture implementation, and it's a way of declaring which Systems are run as part of the Runtime Loop.
62
-
63
- ### Middleware
64
-
65
- The Middleware is the Unit-of-Work implementation of a System, and allows for a System to achieve Single-Responsibility (part of SOLID principles.).
66
-
67
- A Middleware has 3 methods:
68
- - `shouldRun: boolean` -> specifies whether the current System should run it's `action` method, to introduce State changes on the Entity's Components
69
- - `action: void` -> the System implementation that allows for altering Entity Component state, can use Entity Proxies, or Schedule updates for itself or other Entities
70
- - `cleanup: void` -> the System implementation method that gets called when the Entity Model Change Type is Removed. It handles the disposal of any internal objects the System might have instantiated
71
-
72
- Each Middleware method will receive a `context: SystemPipelineContext<TEntity>`, which contains the current Entity state, as well as the Entity Model Change, and any Entity changes Scheduled for Dispatch at the end of the current Tick
73
-
74
- ## Entity Changes
75
-
76
- Each Entity has a mandatory Identity Component. This Identity Component will hold the current Entity Model, and it's Entity Unique Identifier.
77
- Model changes will prompt an Entity to introduce itself on a Entity Change Queue, to be processed on the next Tick by the Runtime.
78
-
79
- ### The Runtime
80
-
81
- The Awesome ECS Architecture implementation Runtime is structured in Loops of Ticks.
82
-
83
- Each Tick has an allocated time for running, and will process Entity Changes during that Tick.
84
- If there is more time left in the current Loop, and the Entity Change Queue is not empty, the next Entity Change in the Entity Change Queue, will be processed.
85
-
86
- ### The Ticks
87
-
88
- Each Tick will receive as an input an Entity Model Change, which will contain: the Current Model, the Previous Model (if available), and the Change Type (Added, Updated or Removed).
89
-
90
- Based on the Change Type and Model, the Entity Identifier is being searched.
91
- Based on the found Entity Identifier and Change Type, The Runtime instantiates the System Pipeline associated with that change.
92
-
93
- ## Runtime Stages
94
-
95
- The Runtime has a few Stages, that will run in this order:
96
-
97
- - Initializer Systems
98
- - Updater Systems
99
- - Renderer Systems
100
- - (Dispatcher) Systems
101
-
102
- Each Stage is a System Pipeline, which will run it's associated System Middlewares, in the order they were registered in.
103
-
104
- ### Generator Systems
105
-
106
- The Generator Systems will be ran once per Entity, when the Model Change Type is Added.
107
- All the Middlewares registered for this stage will contribute to enrich the Entity Components with bootstrap data.
108
-
109
- ### Updater Systems
110
-
111
- The Updater Systems will be ran on each Model Change, and it's the main way of altering the Entity's Components state.
112
-
113
- ### Render Systems
114
-
115
- The Render Systems will make sure to update the underlying Render system with the Entity's `RenderingComponent` state. It's useful as an abstraction layer to lower-lever Rendering (e.g. a Game Engine, WebGL, Canvas)
116
-
117
- The Render Systems can be skipped from the Runtime, if needed. That can be useful to simulate the same Runtime in a non-rendered system, like the Backend.
118
-
119
- ### (Dispatch) Systems
120
-
121
- The Dispatch Systems are built-in Systems in the Awesome ECS, and will take care of Dispatching Actions, Scheduling Entity updates, or synchronizing the Entity Repository with the latest Entity State in the current Context.
122
-
123
- The Dispatch Systems, as well as any other Runtime Stage, can be extended as needed by registering more System Middlewares in the Stage Pipeline.
124
-
125
- ## Integration Examples
126
-
127
- ### Component Definition Example
128
-
129
- ```typescript
130
- import { IComponent } from "@awesome-ecs/abstract";
131
- import { ComponentType } from "../abstract/components/component-type";
132
-
133
- export class CoordinatesComponent implements IComponent {
134
- readonly componentType = ComponentType.coordinates;
135
- readonly isSerializable = false;
136
-
137
- // Component state
138
- private coordinates: GridCoordinates;
139
-
140
- // Component methods
141
- setTileRadius(value: SpaceMeasurement) {
142
- this.coordinates = new GridCoordinates(value);
143
- }
144
-
145
- getCenterPointFor(position: GridPosition): GridPoint {
146
- return this.coordinates.getCenterPointFor(position);
147
- }
148
- }
149
- ```
150
-
151
- ### Entity Definition Example
152
-
153
- ```typescript
154
- import { EntityBase } from "@awesome-ecs/core";
155
- import { EntityProxy, EntityUid, IEntityModel, IEntityProxy } from "@awesome-ecs/abstract";
156
- import { ComponentType } from "../abstract/components/component-type";
157
- import { EntityType } from "../abstract/entities/entity-type";
158
-
159
- export class GridEntity extends EntityBase<GridModel> {
160
- // Entity proxies for relationships
161
- get sceneProxy(): EntityProxy<SceneEntity> {
162
- return this.getProxy(EntityType.scene);
163
- }
164
-
165
- get buildingProxies(): IterableIterator<EntityProxy<BuildingEntity>> {
166
- return this.getProxies(EntityType.building);
167
- }
168
-
169
- // Component accessors
170
- get coordinates(): CoordinatesComponent {
171
- return this.getComponent(ComponentType.coordinates);
172
- }
173
-
174
- get rendering(): RenderingComponent<GridRenderingContext> {
175
- return this.getComponent(ComponentType.rendering);
176
- }
177
- }
178
- ```
179
-
180
- ### System Module Example
181
-
182
- ```typescript
183
- import { SystemPipelineType } from "@awesome-ecs/abstract";
184
- import { LocalSystemsModuleBase } from "../abstract/systems/system-module-base";
185
-
186
- export class GridSystemsModule extends LocalSystemsModuleBase<GridEntity> {
187
- constructor(
188
- // Systems injected via dependency injection
189
- gridContainerInitializerSystem: GridContainerInitializerSystem,
190
- gridCoordinatesInitializerSystem: GridCoordinatesInitializerSystem,
191
- gridPerimeterRenderingSystem: GridPerimeterRenderingSystem
192
- ) {
193
- super();
194
-
195
- // Register systems for different pipeline stages
196
- this.registerSystems(SystemPipelineType.initialize, [
197
- gridContainerInitializerSystem,
198
- gridCoordinatesInitializerSystem
199
- ]);
200
-
201
- this.registerSystems(SystemPipelineType.render, [
202
- gridPerimeterRenderingSystem
203
- ]);
204
- }
205
-
206
- // Entity factory method
207
- protected initEntity(model: GridModel): GridEntity {
208
- // Create and return entity instance
209
- const entity = new GridEntity(
210
- ComponentFactory.identity(EntityType.grid, model),
211
- [
212
- ComponentFactory.coordinates(),
213
- ComponentFactory.rendering()
214
- ],
215
- [
216
- // Entity relationships via proxies
217
- model.parent,
218
- {
219
- entityType: EntityType.scene,
220
- entityUid: IdGenerator.sceneUid(),
221
- }
222
- ]
223
- );
224
-
225
- return entity;
226
- }
227
- }
228
- ```
1
+ # Awesome ECS - Abstract Package
2
+
3
+ ## Overview
4
+
5
+ The Abstract package defines all core interfaces and abstractions for the Entity-Component-System (ECS) framework. It provides the foundational contracts that all other packages implement, including:
6
+
7
+ - **Components**: Data-storage contracts
8
+ - **Entities**: Container contracts for components and relationships
9
+ - **Pipelines**: Middleware-based execution chains
10
+ - **Systems**: Modular logic execution patterns
11
+ - **Utilities**: Serialization, events, and scheduling
12
+
13
+ This package has **zero external dependencies** and serves as the contract layer for the entire ECS framework.
14
+
15
+ ## Core Concepts
16
+
17
+ ### Components (`src/components/`)
18
+
19
+ Components are **data-only containers**. They should never contain business logic.
20
+
21
+ ```typescript
22
+ import { IComponent } from "@awesome-ecs/abstract";
23
+
24
+ export class HealthComponent implements IComponent {
25
+ readonly componentType = ComponentType.health;
26
+ readonly isSerializable = true; // Include in snapshots
27
+
28
+ current: number = 100;
29
+ max: number = 100;
30
+ }
31
+ ```
32
+
33
+ **Key interfaces:**
34
+ - `IComponent`: Base component interface with `componentType` and `isSerializable`
35
+ - `IdentityComponent`: Mandatory component tracking entity UID and model
36
+
37
+ ### Entities (`src/entities/`)
38
+
39
+ Entities are immutable **containers of components** and **proxies to other entities**. They never directly reference other entities—they use proxies for loose coupling.
40
+
41
+ ```typescript
42
+ export class GridEntity extends EntityBase<GridModel> {
43
+ // Strongly-typed component getters
44
+ get coordinates(): CoordinatesComponent {
45
+ return this.getComponent(ComponentType.coordinates);
46
+ }
47
+
48
+ // Entity proxies for relationships (not direct references)
49
+ get sceneProxy(): EntityProxy<SceneEntity> {
50
+ return this.getProxy(EntityType.scene);
51
+ }
52
+ }
53
+ ```
54
+
55
+ **Key files:**
56
+ - `entity.ts`: Base `IEntity` interface and `EntityTypeUid` types
57
+ - `entity-proxies.ts`: `EntityProxy` for loose-coupling relationships
58
+ - `entity-snapshot.ts`: `IEntitySnapshot` for serialization
59
+ - `entity-queue.ts`: `IEntityUpdate` and `IEntityUpdateQueue` for batching changes
60
+ - `entity-repository.ts`: `IEntityRepository` for entity lookups
61
+ - `entity-scheduler.ts`: `IEntityScheduler` for deferred updates
62
+ - `entity-events.ts`: `IEntityEvents` for reactive patterns
63
+
64
+ ### Pipelines (`src/pipelines/`)
65
+
66
+ Pipelines execute **middleware chains** with two phases:
67
+
68
+ 1. **dispatch(context)**: Main execution phase
69
+ 2. **cleanup(context)**: Resource cleanup phase
70
+
71
+ ```typescript
72
+ export interface IPipeline<TContext extends IPipelineContext> {
73
+ use(middleware: IMiddleware<TContext>): this;
74
+ dispatch(context: Partial<TContext>): PipelineResult;
75
+ cleanup(context: Partial<TContext>): PipelineResult;
76
+ }
77
+ ```
78
+
79
+ **Key files:**
80
+ - `pipeline.ts`: Core `IPipeline` interface
81
+ - `middleware.ts`: `IMiddleware` contract (action + optional cleanup)
82
+ - `middleware-runner.ts`: Middleware execution engine
83
+ - `pipeline-context.ts`: Context passed to middleware
84
+ - `pipeline-runner.ts`: Pipeline execution orchestration
85
+ - `pipeline-result.ts`: Result type for success/failure
86
+
87
+ ### Systems (`src/systems/`)
88
+
89
+ Systems are **modular logic units** that operate on entities. They implement the middleware pattern.
90
+
91
+ **Pipeline-based systems:**
92
+ - `system-middleware.ts`: `ISystemMiddleware<TEntity>` - middleware for a specific entity type
93
+ - `system-context.ts`: Context passed to system middleware (entity, events, repository, etc.)
94
+
95
+ **Module-based organization:**
96
+ - `systems-module.ts`: `ISystemsModule<TEntity>` - groups related systems targeting an entity type
97
+ - `systems-module-definition.ts`: Module definition and pipeline registration
98
+ - `systems-module-repository.ts`: Module lifecycle and registration
99
+
100
+ **Runtime execution:**
101
+ - `systems-runtime.ts`: `ISystemsRuntime` - core tick-based execution loop
102
+ - `systems-runtime-context.ts`: Context for runtime execution
103
+ - `systems-runtime-middleware.ts`: Middleware for runtime operations
104
+
105
+ ### Utilities (`src/utils/`)
106
+
107
+ - `types.ts`: Common types (`Immutable`, `BooleanProps`, `Readonly`)
108
+ - `json-serializer.ts`: JSON serialization contracts
109
+ - `logger.ts`: Logging interface
110
+ - `performance-timer.ts`: Performance measurement
111
+
112
+ ## Key Design Principles
113
+
114
+ 1. **Components are data-only** - no behavior, just properties
115
+ 2. **Entities are immutable** - modifications through systems only
116
+ 3. **Relationships use proxies** - loose coupling between entities
117
+ 4. **Systems are middleware** - pluggable into pipelines
118
+ 5. **Pipelines are composable** - middleware chains with dispatch + cleanup
119
+
120
+ ## What's NOT in Abstract
121
+
122
+ - Concrete entity implementations (→ @awesome-ecs/core)
123
+ - System module base classes (→ @awesome-ecs/core)
124
+ - Component factories (→ @awesome-ecs/core)
125
+ - Multi-threading (→ @awesome-ecs/workers)
126
+ - AI patterns (→ @awesome-ecs/ai)
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * The `BasicComponentType` enum defines the types of basic components available.
5
5
  */
6
- let BasicComponentType = /* @__PURE__ */ function(BasicComponentType$1) {
7
- BasicComponentType$1["identity"] = "identity";
8
- return BasicComponentType$1;
6
+ let BasicComponentType = /* @__PURE__ */ function(BasicComponentType) {
7
+ BasicComponentType["identity"] = "identity";
8
+ return BasicComponentType;
9
9
  }({});
10
10
 
11
11
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\nimport { Immutable } from '../utils/types';\nimport { IComponent } from './component';\n\n/**\n * The `BasicComponentType` enum defines the types of basic components available.\n */\nexport enum BasicComponentType {\n identity = 'identity'\n}\n\n/**\n * IdentityComponent interface represents the basic information regarding what makes the current Entity unique.\n * It extends the IComponent interface.\n *\n * @template TModel - The type of the model that extends IEntityModel.\n */\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\n /**\n * The Entity Type that defines what Category type the Entity is part of.\n * There can be multiple Entities sharing the same EntityType.\n */\n readonly entityType: EntityTypeUid;\n\n /**\n * The Model is the basic information needed to create an `IEntity` when it's first initialized.\n * It provides a first snapshot of information needed for the successful creation of an Entity instance.\n *\n * @type {Immutable<TModel>}\n */\n readonly model: Immutable<TModel>;\n\n /**\n * Keeps track when the Entity's systems have ran last.\n * Useful to calculate the `DeltaTime` between runs.\n *\n * @type {Date | undefined}\n */\n readonly lastUpdated?: Date;\n}\n"],"mappings":";;;;;AAOA,IAAY,oEAAL;AACL;;AACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\r\nimport { Immutable } from '../utils/types';\r\nimport { IComponent } from './component';\r\n\r\n/**\r\n * The `BasicComponentType` enum defines the types of basic components available.\r\n */\r\nexport enum BasicComponentType {\r\n identity = 'identity'\r\n}\r\n\r\n/**\r\n * The mandatory metadata component for every entity.\r\n * Contains core information that defines what an entity is and when it was last updated.\r\n * This component is immutable after creation and uniquely identifies each entity.\r\n *\r\n * @template TModel - The entity model type containing initialization data.\r\n */\r\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\r\n /**\r\n * The entity type classification.\r\n * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.\r\n */\r\n readonly entityType: EntityTypeUid;\r\n\r\n /**\r\n * The initialization model for this entity.\r\n * Provides the minimal data structure used when the entity was first created.\r\n * Serves as a reference point for the entity's initial configuration.\r\n *\r\n * @type {Immutable<TModel>}\r\n */\r\n readonly model: Immutable<TModel>;\r\n\r\n /**\r\n * The timestamp of the entity's last system update.\r\n * Useful for calculating elapsed time (delta time) between consecutive updates.\r\n * Helps systems make time-aware decisions.\r\n *\r\n * @type {Date | undefined}\r\n */\r\n readonly lastUpdated?: Date;\r\n}\r\n"],"mappings":";;;;;AAOA,IAAY,kEAAL;AACL"}
@@ -1,3 +1,2 @@
1
- import { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent } from "../identity-component-BDWEtAXA.cjs";
2
- import "../types-DvzdpbLu.cjs";
1
+ import { f as ComponentTypeUid, n as IdentityComponent, p as IComponent, t as BasicComponentType } from "../identity-component-uU0yDR-y.cjs";
3
2
  export { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent };
@@ -0,0 +1,2 @@
1
+ import { f as ComponentTypeUid, n as IdentityComponent, p as IComponent, t as BasicComponentType } from "../identity-component-CgzvgBVh.mjs";
2
+ export { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent };
@@ -2,11 +2,11 @@
2
2
  /**
3
3
  * The `BasicComponentType` enum defines the types of basic components available.
4
4
  */
5
- let BasicComponentType = /* @__PURE__ */ function(BasicComponentType$1) {
6
- BasicComponentType$1["identity"] = "identity";
7
- return BasicComponentType$1;
5
+ let BasicComponentType = /* @__PURE__ */ function(BasicComponentType) {
6
+ BasicComponentType["identity"] = "identity";
7
+ return BasicComponentType;
8
8
  }({});
9
9
 
10
10
  //#endregion
11
11
  export { BasicComponentType };
12
- //# sourceMappingURL=index.js.map
12
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\r\nimport { Immutable } from '../utils/types';\r\nimport { IComponent } from './component';\r\n\r\n/**\r\n * The `BasicComponentType` enum defines the types of basic components available.\r\n */\r\nexport enum BasicComponentType {\r\n identity = 'identity'\r\n}\r\n\r\n/**\r\n * The mandatory metadata component for every entity.\r\n * Contains core information that defines what an entity is and when it was last updated.\r\n * This component is immutable after creation and uniquely identifies each entity.\r\n *\r\n * @template TModel - The entity model type containing initialization data.\r\n */\r\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\r\n /**\r\n * The entity type classification.\r\n * Categorizes entities into logical types, allowing systems to selectively operate on specific entity categories.\r\n */\r\n readonly entityType: EntityTypeUid;\r\n\r\n /**\r\n * The initialization model for this entity.\r\n * Provides the minimal data structure used when the entity was first created.\r\n * Serves as a reference point for the entity's initial configuration.\r\n *\r\n * @type {Immutable<TModel>}\r\n */\r\n readonly model: Immutable<TModel>;\r\n\r\n /**\r\n * The timestamp of the entity's last system update.\r\n * Useful for calculating elapsed time (delta time) between consecutive updates.\r\n * Helps systems make time-aware decisions.\r\n *\r\n * @type {Date | undefined}\r\n */\r\n readonly lastUpdated?: Date;\r\n}\r\n"],"mappings":";;;;AAOA,IAAY,kEAAL;AACL"}
@@ -1,12 +1,19 @@
1
1
 
2
2
  //#region src/entities/entity-queue.ts
3
3
  /**
4
- * The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.
4
+ * Specifies the action to be performed on an entity.
5
+ * Updates are categorized to enable different processing paths in the runtime.
5
6
  */
6
- let EntityUpdateType = /* @__PURE__ */ function(EntityUpdateType$1) {
7
- EntityUpdateType$1["update"] = "update";
8
- EntityUpdateType$1["remove"] = "remove";
9
- return EntityUpdateType$1;
7
+ let EntityUpdateType = /* @__PURE__ */ function(EntityUpdateType) {
8
+ /**
9
+ * Indicates the entity should be updated with new data.
10
+ */
11
+ EntityUpdateType["update"] = "update";
12
+ /**
13
+ * Indicates the entity should be removed from the system.
14
+ */
15
+ EntityUpdateType["remove"] = "remove";
16
+ return EntityUpdateType;
10
17
  }({});
11
18
 
12
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\nimport { IEntityProxy } from './entity-proxies';\nimport { IEntitySnapshot } from './entity-snapshot';\n\n/**\n * The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.\n */\nexport enum EntityUpdateType {\n update = 'update',\n remove = 'remove'\n}\n\n/**\n * The `IEntityUpdate` interface represents an Entity update that should be applied over an existing Entity.\n */\nexport interface IEntityUpdate {\n /**\n * The type of the update, which can be either `update` or `remove`.\n */\n type: EntityUpdateType;\n\n /**\n * The proxy of the Entity that needs to be updated.\n */\n entity: IEntityProxy;\n\n /**\n * Optional. The model of the Entity that needs to be updated.\n */\n model?: IEntityModel;\n\n /**\n * Optional. The snapshot of the Entity that needs to be updated.\n */\n snapshot?: IEntitySnapshot;\n}\n\n/**\n * The `IEntityUpdateQueue` interface is the main mechanism to queue and retrieve `EntityUpdate` instances.\n *\n * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.\n */\nexport interface IEntityUpdateQueue {\n /**\n * The number of `EntityUpdate` instances currently in the queue.\n */\n readonly size: number;\n\n /**\n * Adds an `EntityUpdate` instance to the end of the queue.\n * @param change - The `EntityUpdate` instance to be added.\n */\n enqueue(change: IEntityUpdate): void;\n\n /**\n * Removes and returns the `EntityUpdate` instance at the front of the queue.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n dequeue(): IEntityUpdate;\n\n /**\n * Returns the `EntityUpdate` instance at the front of the queue without removing it.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n peek(): IEntityUpdate;\n\n /**\n * Removes all `EntityUpdate` instances from the queue.\n */\n clear(): void;\n}\n"],"mappings":";;;;;AAOA,IAAY,gEAAL;AACL;AACA;;AACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\r\nimport { IEntityProxy } from './entity-proxies';\r\nimport { IEntitySnapshot } from './entity-snapshot';\r\n\r\n/**\r\n * Specifies the action to be performed on an entity.\r\n * Updates are categorized to enable different processing paths in the runtime.\r\n */\r\nexport enum EntityUpdateType {\r\n /**\r\n * Indicates the entity should be updated with new data.\r\n */\r\n update = 'update',\r\n /**\r\n * Indicates the entity should be removed from the system.\r\n */\r\n remove = 'remove'\r\n}\r\n\r\n/**\r\n * Represents a queued entity state change or removal.\r\n * Updates flow through the system to be processed by entity update handlers.\r\n */\r\nexport interface IEntityUpdate {\r\n /**\r\n * The type of operation: update or remove.\r\n */\r\n readonly type: EntityUpdateType;\r\n\r\n /**\r\n * The entity being affected by this update.\r\n */\r\n readonly entity: IEntityProxy;\r\n\r\n /**\r\n * Optional model data for initialization or reconfiguration.\r\n */\r\n readonly model?: IEntityModel;\r\n\r\n /**\r\n * Optional serialized state to apply to the entity.\r\n */\r\n readonly snapshot?: IEntitySnapshot;\r\n}\r\n\r\n/**\r\n * Queue interface for managing pending entity updates.\r\n * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).\r\n * Updates are consumed by the runtime and dispatched to appropriate entity systems.\r\n */\r\nexport interface IEntityUpdateQueue {\r\n /**\r\n * The current number of updates in the queue.\r\n */\r\n readonly size: number;\r\n\r\n /**\r\n * Adds an update to the queue for processing.\r\n * @param change - The update to queue.\r\n */\r\n enqueue(change: IEntityUpdate): void;\r\n\r\n /**\r\n * Removes and returns the next update from the queue.\r\n * The specific update returned depends on the queue's prioritization strategy.\r\n * @returns The next queued update.\r\n */\r\n dequeue(): IEntityUpdate;\r\n\r\n /**\r\n * Views the next update without removing it.\r\n * Useful for inspection before dequeuing.\r\n * @returns The next update in the queue.\r\n */\r\n peek(): IEntityUpdate;\r\n\r\n /**\r\n * Removes all updates from the queue.\r\n */\r\n clear(): void;\r\n}\r\n"],"mappings":";;;;;;AAQA,IAAY,8DAAL;;;;AAIL;;;;AAIA"}
@@ -1,4 +1,3 @@
1
- import { EntityProxy, EntityTypeUid, EntityUid, IEntity, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, RequiredProxies, TypedEntityProxy } from "../identity-component-BDWEtAXA.cjs";
2
- import "../types-DvzdpbLu.cjs";
3
- import { EntityEventSubscriptionFilter, EntityEventUid, EntityUpdateType, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData } from "../index-DLm-DKAk.cjs";
4
- export { EntityEventSubscriptionFilter, EntityEventUid, EntityProxy, EntityTypeUid, EntityUid, EntityUpdateType, IEntity, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData, RequiredProxies, TypedEntityProxy };
1
+ import { a as IEntity, c as IEntityProxy, d as TypedEntityProxy, i as EntityUid, l as IEntityProxyRepository, o as IEntityModel, r as EntityTypeUid, s as EntityProxy, u as RequiredProxies } from "../identity-component-uU0yDR-y.cjs";
2
+ import { a as IEntityUpdateQueue, c as EntityEventSubscriptionFilter, d as IEntityEvent, f as IEntityEventsDispatcher, i as IEntityUpdate, l as EntityEventSubscriptionOptions, m as IEventData, n as IEntityRepository, o as IEntitySnapshot, p as IEntityEventsManager, r as EntityUpdateType, s as IEntitySnapshotProvider, t as IEntityScheduler, u as EntityEventUid } from "../index-qSeVF9hf.cjs";
3
+ export { EntityEventSubscriptionFilter, EntityEventSubscriptionOptions, EntityEventUid, EntityProxy, EntityTypeUid, EntityUid, EntityUpdateType, IEntity, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityModel, IEntityProxy, IEntityProxyRepository, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData, RequiredProxies, TypedEntityProxy };
@@ -0,0 +1,3 @@
1
+ import { a as IEntity, c as IEntityProxy, d as TypedEntityProxy, i as EntityUid, l as IEntityProxyRepository, o as IEntityModel, r as EntityTypeUid, s as EntityProxy, u as RequiredProxies } from "../identity-component-CgzvgBVh.mjs";
2
+ import { a as IEntityUpdateQueue, c as EntityEventSubscriptionFilter, d as IEntityEvent, f as IEntityEventsDispatcher, i as IEntityUpdate, l as EntityEventSubscriptionOptions, m as IEventData, n as IEntityRepository, o as IEntitySnapshot, p as IEntityEventsManager, r as EntityUpdateType, s as IEntitySnapshotProvider, t as IEntityScheduler, u as EntityEventUid } from "../index-CfEs8NEA.mjs";
3
+ export { EntityEventSubscriptionFilter, EntityEventSubscriptionOptions, EntityEventUid, EntityProxy, EntityTypeUid, EntityUid, EntityUpdateType, IEntity, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityModel, IEntityProxy, IEntityProxyRepository, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData, RequiredProxies, TypedEntityProxy };
@@ -0,0 +1,20 @@
1
+ //#region src/entities/entity-queue.ts
2
+ /**
3
+ * Specifies the action to be performed on an entity.
4
+ * Updates are categorized to enable different processing paths in the runtime.
5
+ */
6
+ let EntityUpdateType = /* @__PURE__ */ function(EntityUpdateType) {
7
+ /**
8
+ * Indicates the entity should be updated with new data.
9
+ */
10
+ EntityUpdateType["update"] = "update";
11
+ /**
12
+ * Indicates the entity should be removed from the system.
13
+ */
14
+ EntityUpdateType["remove"] = "remove";
15
+ return EntityUpdateType;
16
+ }({});
17
+
18
+ //#endregion
19
+ export { EntityUpdateType };
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\r\nimport { IEntityProxy } from './entity-proxies';\r\nimport { IEntitySnapshot } from './entity-snapshot';\r\n\r\n/**\r\n * Specifies the action to be performed on an entity.\r\n * Updates are categorized to enable different processing paths in the runtime.\r\n */\r\nexport enum EntityUpdateType {\r\n /**\r\n * Indicates the entity should be updated with new data.\r\n */\r\n update = 'update',\r\n /**\r\n * Indicates the entity should be removed from the system.\r\n */\r\n remove = 'remove'\r\n}\r\n\r\n/**\r\n * Represents a queued entity state change or removal.\r\n * Updates flow through the system to be processed by entity update handlers.\r\n */\r\nexport interface IEntityUpdate {\r\n /**\r\n * The type of operation: update or remove.\r\n */\r\n readonly type: EntityUpdateType;\r\n\r\n /**\r\n * The entity being affected by this update.\r\n */\r\n readonly entity: IEntityProxy;\r\n\r\n /**\r\n * Optional model data for initialization or reconfiguration.\r\n */\r\n readonly model?: IEntityModel;\r\n\r\n /**\r\n * Optional serialized state to apply to the entity.\r\n */\r\n readonly snapshot?: IEntitySnapshot;\r\n}\r\n\r\n/**\r\n * Queue interface for managing pending entity updates.\r\n * Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).\r\n * Updates are consumed by the runtime and dispatched to appropriate entity systems.\r\n */\r\nexport interface IEntityUpdateQueue {\r\n /**\r\n * The current number of updates in the queue.\r\n */\r\n readonly size: number;\r\n\r\n /**\r\n * Adds an update to the queue for processing.\r\n * @param change - The update to queue.\r\n */\r\n enqueue(change: IEntityUpdate): void;\r\n\r\n /**\r\n * Removes and returns the next update from the queue.\r\n * The specific update returned depends on the queue's prioritization strategy.\r\n * @returns The next queued update.\r\n */\r\n dequeue(): IEntityUpdate;\r\n\r\n /**\r\n * Views the next update without removing it.\r\n * Useful for inspection before dequeuing.\r\n * @returns The next update in the queue.\r\n */\r\n peek(): IEntityUpdate;\r\n\r\n /**\r\n * Removes all updates from the queue.\r\n */\r\n clear(): void;\r\n}\r\n"],"mappings":";;;;;AAQA,IAAY,8DAAL;;;;AAIL;;;;AAIA"}
@@ -1,57 +1,69 @@
1
- import { IEntity } from "../identity-component-BDWEtAXA.cjs";
2
- import "../types-DvzdpbLu.cjs";
3
- import "../index-DLm-DKAk.cjs";
4
- import { IPipeline, IPipelineContext } from "../index-D81Fo9XN.cjs";
5
- import "../index-ChV4Q5j6.cjs";
6
- import { ISystemContext, ISystemsRuntimeContext } from "../index-CjNeb3ML.cjs";
1
+ import { a as IEntity } from "../identity-component-uU0yDR-y.cjs";
2
+ import { l as IPipelineContext, o as IPipeline } from "../index-DZvjMjYZ.cjs";
3
+ import { n as ISystemsRuntimeContext, o as ISystemsModuleBuilder, u as ISystemContext } from "../index-J5AU4JAU.cjs";
7
4
 
8
5
  //#region src/factories/context-factory.d.ts
9
- /**
10
- * The IContextFactory interface is used to create abstraction layers for quickly creating Pipeline Contexts.
11
- * It helps to avoid manually resolving all dependencies when creating these contexts.
12
- */
13
6
  interface IContextFactory {
14
7
  /**
15
- * Creates a new instance of ISystemsRuntimeContext.
16
- *
17
- * @template TEntity - The type of entity to be used in the runtime context. It must extend IEntity.
18
- * @returns A new instance of ISystemsRuntimeContext with the specified entity type.
8
+ * Creates a new system context for the given entity type.
9
+ * @template TEntity - The entity type for which the system context is being created.
10
+ * @returns A new context instance.
19
11
  */
20
- createRuntimeContext<TEntity extends IEntity>(): ISystemsRuntimeContext<TEntity>;
12
+ createSystemContext<TEntity extends IEntity>(): ISystemContext<TEntity>;
21
13
  }
22
14
  //#endregion
23
15
  //#region src/factories/pipeline-factory.d.ts
24
16
  /**
25
- * The PipelineFactory interface provides methods to create different types of pipelines.
26
- * It helps to quickly create IPipeline objects without manually resolving their dependencies.
17
+ * Creates pipeline instances for various contexts.
18
+ * Abstracts pipeline creation to support different implementations.
19
+ * Used by the system to instantiate pipelines without coupling to specific implementations.
27
20
  */
28
21
  interface IPipelineFactory {
29
22
  /**
30
- * Creates a new pipeline with the specified context and result type.
31
- *
32
- * @template TContext - The type of the pipeline context. It must extend IPipelineContext.
33
- * @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
34
- * @returns A new instance of IPipeline with the specified context and result type.
23
+ * Creates a new pipeline for the specified context type.
24
+ * @template TContext - The context type for the pipeline. Must extend IPipelineContext.
25
+ * @param name - Optional name for the pipeline (useful for debugging).
26
+ * @returns A new pipeline instance ready for middleware registration.
35
27
  */
36
28
  createPipeline<TContext extends IPipelineContext>(name?: string): IPipeline<TContext>;
29
+ }
30
+ //#endregion
31
+ //#region src/factories/runtime-factory.d.ts
32
+ /**
33
+ * Creates runtime contexts and pipelines for system execution.
34
+ * Provides factory methods for constructing runtime infrastructure.
35
+ * Allows different runtime strategies through multiple implementations.
36
+ */
37
+ interface IRuntimeFactory {
37
38
  /**
38
- * Creates a new pipeline specifically for systems with the specified entity type and result type.
39
- *
40
- * @template TEntity - The type of the entity. It must extend IEntity.
41
- * @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
42
- * @returns A new instance of IPipeline with the specified system context and result type.
39
+ * Creates a new runtime context for system execution.
40
+ * @template TEntity - The entity type for the runtime context.
41
+ * @returns A new systems runtime context instance.
43
42
  */
44
- createSystemsPipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemContext<TEntity>>;
43
+ createRuntimeContext<TEntity extends IEntity>(): ISystemsRuntimeContext<TEntity>;
45
44
  /**
46
- * Creates a new pipeline specifically for systems runtime with the specified entity type and result type.
47
- *
48
- * @template TEntity - The type of the entity. It must extend IEntity.
49
- * @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
50
- * @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
51
- * @returns A new instance of IPipeline with the specified systems runtime context and result type.
45
+ * Creates a pipeline for systems runtime orchestration.
46
+ * @template TEntity - The entity type for this runtime pipeline.
47
+ * @param name - Optional name for debugging.
48
+ * @returns A new runtime pipeline for system execution.
52
49
  */
53
50
  createRuntimePipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>>;
54
51
  }
55
52
  //#endregion
56
- export { IContextFactory, IPipelineFactory };
53
+ //#region src/factories/systems-factory.d.ts
54
+ /**
55
+ * Creates systems module builders for constructing entity system pipelines.
56
+ * Provides factory access to module builder instances.
57
+ * Enables composition of systems for different entity types.
58
+ */
59
+ interface ISystemsFactory {
60
+ /**
61
+ * Creates a new builder for constructing a systems module.
62
+ * @template TEntity - The entity type for which systems are being built.
63
+ * @returns A new systems module builder instance.
64
+ */
65
+ createSystemsModuleBuilder<TEntity extends IEntity>(): ISystemsModuleBuilder<TEntity>;
66
+ }
67
+ //#endregion
68
+ export { IContextFactory, IPipelineFactory, IRuntimeFactory, ISystemsFactory };
57
69
  //# sourceMappingURL=index.d.cts.map