@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.
- package/README.md +126 -228
- package/dist/components/index.cjs +3 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -2
- package/dist/components/index.d.mts +2 -0
- package/dist/components/{index.js → index.mjs} +4 -4
- package/dist/components/index.mjs.map +1 -0
- package/dist/entities/index.cjs +12 -5
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +3 -4
- package/dist/entities/index.d.mts +3 -0
- package/dist/entities/index.mjs +20 -0
- package/dist/entities/index.mjs.map +1 -0
- package/dist/factories/index.d.cts +47 -35
- package/dist/factories/index.d.mts +69 -0
- package/dist/factories/index.mjs +1 -0
- package/dist/identity-component-CgzvgBVh.d.mts +254 -0
- package/dist/identity-component-uU0yDR-y.d.cts +254 -0
- package/dist/index-BWmhFdFg.d.mts +148 -0
- package/dist/index-CfEs8NEA.d.mts +328 -0
- package/dist/index-D4jK3qG1.d.mts +224 -0
- package/dist/index-DULE7rVz.d.mts +515 -0
- package/dist/index-DZvjMjYZ.d.cts +224 -0
- package/dist/index-J5AU4JAU.d.cts +515 -0
- package/dist/index-eECJUE_O.d.cts +148 -0
- package/dist/index-qSeVF9hf.d.cts +328 -0
- package/dist/pipelines/index.cjs +0 -31
- package/dist/pipelines/index.d.cts +2 -4
- package/dist/pipelines/index.d.mts +2 -0
- package/dist/pipelines/index.mjs +1 -0
- package/dist/systems/index.cjs +18 -18
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -7
- package/dist/systems/index.d.mts +2 -0
- package/dist/systems/index.mjs +33 -0
- package/dist/systems/index.mjs.map +1 -0
- package/dist/types-CnDtpKsY.d.mts +70 -0
- package/dist/types-DLOd2zXO.d.cts +70 -0
- package/dist/utils/index.cjs +11 -11
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +3 -0
- package/dist/utils/index.mjs +27 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +14 -14
- package/dist/components/index.d.ts +0 -3
- package/dist/components/index.js.map +0 -1
- package/dist/entities/index.d.ts +0 -4
- package/dist/entities/index.js +0 -13
- package/dist/entities/index.js.map +0 -1
- package/dist/factories/index.d.ts +0 -57
- package/dist/factories/index.js +0 -0
- package/dist/identity-component-BDWEtAXA.d.cts +0 -238
- package/dist/identity-component-CR1ULadR.d.ts +0 -238
- package/dist/index-C3UGZqUG.d.ts +0 -288
- package/dist/index-CH8ucsKZ.d.ts +0 -472
- package/dist/index-ChV4Q5j6.d.cts +0 -137
- package/dist/index-CjNeb3ML.d.cts +0 -472
- package/dist/index-Cm-YSPhK.d.ts +0 -254
- package/dist/index-D81Fo9XN.d.cts +0 -254
- package/dist/index-DLm-DKAk.d.cts +0 -288
- package/dist/index-oenqxDCa.d.ts +0 -137
- package/dist/pipelines/index.cjs.map +0 -1
- package/dist/pipelines/index.d.ts +0 -4
- package/dist/pipelines/index.js +0 -30
- package/dist/pipelines/index.js.map +0 -1
- package/dist/systems/index.d.ts +0 -7
- package/dist/systems/index.js +0 -33
- package/dist/systems/index.js.map +0 -1
- package/dist/types-DvzdpbLu.d.cts +0 -69
- package/dist/types-yh4pOGEm.d.ts +0 -69
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -27
- package/dist/utils/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,228 +1,126 @@
|
|
|
1
|
-
# Awesome ECS
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
The Entity-Component-System
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
7
|
-
BasicComponentType
|
|
8
|
-
return BasicComponentType
|
|
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 *
|
|
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 {
|
|
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 };
|
|
@@ -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
|
|
6
|
-
BasicComponentType
|
|
7
|
-
return BasicComponentType
|
|
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.
|
|
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"}
|
package/dist/entities/index.cjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/entities/entity-queue.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 *
|
|
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 {
|
|
2
|
-
import "../
|
|
3
|
-
|
|
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-
|
|
2
|
-
import "../
|
|
3
|
-
import "../index-
|
|
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
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
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
|
-
|
|
12
|
+
createSystemContext<TEntity extends IEntity>(): ISystemContext<TEntity>;
|
|
21
13
|
}
|
|
22
14
|
//#endregion
|
|
23
15
|
//#region src/factories/pipeline-factory.d.ts
|
|
24
16
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
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
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
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
|
-
|
|
43
|
+
createRuntimeContext<TEntity extends IEntity>(): ISystemsRuntimeContext<TEntity>;
|
|
45
44
|
/**
|
|
46
|
-
* Creates a
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
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
|
-
|
|
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
|