@awesome-ecs/abstract 0.20.2 → 0.21.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 +129 -0
- package/dist/factories/index.d.cts +5 -7
- package/dist/factories/index.d.ts +5 -7
- package/dist/{pipeline-BGsQiSer.d.ts → pipeline-9bVMwJKD.d.ts} +36 -36
- package/dist/{pipeline-DunwPUPZ.d.cts → pipeline-CzwetuCd.d.cts} +36 -36
- package/dist/pipelines/index.cjs.map +1 -1
- package/dist/pipelines/index.d.cts +40 -7
- package/dist/pipelines/index.d.ts +40 -7
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +24 -11
- package/dist/systems/index.d.ts +24 -11
- package/dist/{systems-runtime-context-DhtHMczN.d.cts → systems-runtime-context-Bz9hIdKT.d.cts} +1 -1
- package/dist/{systems-runtime-context-BTNdV8Z-.d.ts → systems-runtime-context-C_Tsvoym.d.ts} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,6 +5,30 @@
|
|
|
5
5
|
The Entity-Component-System is a well-known Architecture type used for responsive, complex applications, not only restricted to the Web.
|
|
6
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
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
|
+
|
|
8
32
|
## Building blocks
|
|
9
33
|
|
|
10
34
|
### Entities
|
|
@@ -97,3 +121,108 @@ The Render Systems can be skipped from the Runtime, if needed. That can be usefu
|
|
|
97
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.
|
|
98
122
|
|
|
99
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,6 +1,6 @@
|
|
|
1
1
|
import { c as IEntity } from '../index-CnlpX7ys.cjs';
|
|
2
|
-
import { I as ISystemsRuntimeContext, a as ISystemContext } from '../systems-runtime-context-
|
|
3
|
-
import { I as IPipelineContext,
|
|
2
|
+
import { I as ISystemsRuntimeContext, a as ISystemContext } from '../systems-runtime-context-Bz9hIdKT.cjs';
|
|
3
|
+
import { I as IPipelineContext, a as IPipeline } from '../pipeline-CzwetuCd.cjs';
|
|
4
4
|
import '../types-cZ-1lGPD.cjs';
|
|
5
5
|
import '../entity-repository-DJ1xbvaN.cjs';
|
|
6
6
|
import '../utils/index.cjs';
|
|
@@ -29,20 +29,18 @@ interface IPipelineFactory {
|
|
|
29
29
|
* Creates a new pipeline with the specified context and result type.
|
|
30
30
|
*
|
|
31
31
|
* @template TContext - The type of the pipeline context. It must extend IPipelineContext.
|
|
32
|
-
* @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
|
|
33
32
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
34
33
|
* @returns A new instance of IPipeline with the specified context and result type.
|
|
35
34
|
*/
|
|
36
|
-
createPipeline<TContext extends IPipelineContext
|
|
35
|
+
createPipeline<TContext extends IPipelineContext>(name?: string): IPipeline<TContext>;
|
|
37
36
|
/**
|
|
38
37
|
* Creates a new pipeline specifically for systems with the specified entity type and result type.
|
|
39
38
|
*
|
|
40
39
|
* @template TEntity - The type of the entity. It must extend IEntity.
|
|
41
|
-
* @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
|
|
42
40
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
43
41
|
* @returns A new instance of IPipeline with the specified system context and result type.
|
|
44
42
|
*/
|
|
45
|
-
createSystemsPipeline<TEntity extends IEntity
|
|
43
|
+
createSystemsPipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemContext<TEntity>>;
|
|
46
44
|
/**
|
|
47
45
|
* Creates a new pipeline specifically for systems runtime with the specified entity type and result type.
|
|
48
46
|
*
|
|
@@ -51,7 +49,7 @@ interface IPipelineFactory {
|
|
|
51
49
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
52
50
|
* @returns A new instance of IPipeline with the specified systems runtime context and result type.
|
|
53
51
|
*/
|
|
54
|
-
createRuntimePipeline<TEntity extends IEntity
|
|
52
|
+
createRuntimePipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>>;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
export type { IContextFactory, IPipelineFactory };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as IEntity } from '../index-B1KXekZD.js';
|
|
2
|
-
import { I as ISystemsRuntimeContext, a as ISystemContext } from '../systems-runtime-context-
|
|
3
|
-
import { I as IPipelineContext,
|
|
2
|
+
import { I as ISystemsRuntimeContext, a as ISystemContext } from '../systems-runtime-context-C_Tsvoym.js';
|
|
3
|
+
import { I as IPipelineContext, a as IPipeline } from '../pipeline-9bVMwJKD.js';
|
|
4
4
|
import '../types-cZ-1lGPD.js';
|
|
5
5
|
import '../entity-repository-BlSpo-x2.js';
|
|
6
6
|
import '../utils/index.js';
|
|
@@ -29,20 +29,18 @@ interface IPipelineFactory {
|
|
|
29
29
|
* Creates a new pipeline with the specified context and result type.
|
|
30
30
|
*
|
|
31
31
|
* @template TContext - The type of the pipeline context. It must extend IPipelineContext.
|
|
32
|
-
* @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
|
|
33
32
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
34
33
|
* @returns A new instance of IPipeline with the specified context and result type.
|
|
35
34
|
*/
|
|
36
|
-
createPipeline<TContext extends IPipelineContext
|
|
35
|
+
createPipeline<TContext extends IPipelineContext>(name?: string): IPipeline<TContext>;
|
|
37
36
|
/**
|
|
38
37
|
* Creates a new pipeline specifically for systems with the specified entity type and result type.
|
|
39
38
|
*
|
|
40
39
|
* @template TEntity - The type of the entity. It must extend IEntity.
|
|
41
|
-
* @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
|
|
42
40
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
43
41
|
* @returns A new instance of IPipeline with the specified system context and result type.
|
|
44
42
|
*/
|
|
45
|
-
createSystemsPipeline<TEntity extends IEntity
|
|
43
|
+
createSystemsPipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemContext<TEntity>>;
|
|
46
44
|
/**
|
|
47
45
|
* Creates a new pipeline specifically for systems runtime with the specified entity type and result type.
|
|
48
46
|
*
|
|
@@ -51,7 +49,7 @@ interface IPipelineFactory {
|
|
|
51
49
|
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
52
50
|
* @returns A new instance of IPipeline with the specified systems runtime context and result type.
|
|
53
51
|
*/
|
|
54
|
-
createRuntimePipeline<TEntity extends IEntity
|
|
52
|
+
createRuntimePipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>>;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
export type { IContextFactory, IPipelineFactory };
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
+
import { I as Immutable } from './types-cZ-1lGPD.js';
|
|
1
2
|
import { P as PerformanceTimeEntry } from './performance-timer-BVyl0SRs.js';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Represents the result of a pipeline operation.
|
|
5
|
-
* It can provide performance metrics collected from self or inner middleware & pipeline calls.
|
|
6
|
-
*/
|
|
7
|
-
type PipelineResult = {
|
|
8
|
-
/**
|
|
9
|
-
* Performance metrics collected from the current pipeline operation.
|
|
10
|
-
* This field is optional and can be `undefined` if no performance metrics were collected.
|
|
11
|
-
*/
|
|
12
|
-
readonly performance?: PerformanceTimeEntry;
|
|
13
|
-
/**
|
|
14
|
-
* An array of results from inner middleware & pipeline calls.
|
|
15
|
-
* This field is optional and can be `undefined` if there were no inner calls.
|
|
16
|
-
*/
|
|
17
|
-
readonly inner?: PipelineResult[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represents the result that can be returned from a middleware function.
|
|
22
|
-
* It can either be void (indicating no result) or a PipelineResult instance.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* MiddlewareResult is used to provide Pipeline Results from inner pipeline calls.
|
|
26
|
-
* This is useful when a middleware function needs to return a result from an inner pipeline call.
|
|
27
|
-
**/
|
|
28
|
-
type MiddlewareResult = void | PipelineResult;
|
|
29
|
-
|
|
30
4
|
/**
|
|
31
5
|
* The PipelineStatus enum represents the different states a pipeline can be in.
|
|
32
6
|
*
|
|
@@ -59,7 +33,7 @@ interface IPipelineContext {
|
|
|
59
33
|
/**
|
|
60
34
|
* The runtime state of the pipeline.
|
|
61
35
|
*/
|
|
62
|
-
readonly runtime
|
|
36
|
+
readonly runtime?: PipelineRuntime;
|
|
63
37
|
}
|
|
64
38
|
/**
|
|
65
39
|
* The Pipeline Runtime exposes runtime status controls for Middlewares, as part of the PipelineContext.
|
|
@@ -76,6 +50,27 @@ type PipelineRuntime = {
|
|
|
76
50
|
* It can be undefined if the status is not set.
|
|
77
51
|
*/
|
|
78
52
|
status?: PipelineStatus;
|
|
53
|
+
/**
|
|
54
|
+
* An optional error that occurred during the pipeline operation.
|
|
55
|
+
*/
|
|
56
|
+
error?: any;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents the result of a pipeline operation.
|
|
61
|
+
* It can provide performance metrics collected from self or inner middleware & pipeline calls.
|
|
62
|
+
*/
|
|
63
|
+
type PipelineResult = {
|
|
64
|
+
/**
|
|
65
|
+
* Performance metrics collected from the current pipeline operation.
|
|
66
|
+
* This field is optional and can be `undefined` if no performance metrics were collected.
|
|
67
|
+
*/
|
|
68
|
+
readonly performance?: PerformanceTimeEntry;
|
|
69
|
+
/**
|
|
70
|
+
* An array of results from inner middleware & pipeline calls.
|
|
71
|
+
* This field is optional and can be `undefined` if there were no inner calls.
|
|
72
|
+
*/
|
|
73
|
+
readonly inner?: PipelineResult[];
|
|
79
74
|
};
|
|
80
75
|
|
|
81
76
|
/**
|
|
@@ -85,7 +80,7 @@ type PipelineRuntime = {
|
|
|
85
80
|
* @template TContext The type of the context that the middleware will operate on.
|
|
86
81
|
* @template TResult The type of the result that the middleware will return.
|
|
87
82
|
*/
|
|
88
|
-
interface IMiddleware<TContext extends IPipelineContext
|
|
83
|
+
interface IMiddleware<TContext extends IPipelineContext> {
|
|
89
84
|
/**
|
|
90
85
|
* An optional name for the middleware.
|
|
91
86
|
*/
|
|
@@ -104,14 +99,14 @@ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareRes
|
|
|
104
99
|
* @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
|
|
105
100
|
* @returns The result of the middleware's action.
|
|
106
101
|
*/
|
|
107
|
-
action(context: TContext):
|
|
102
|
+
action(context: TContext): void | PipelineResult;
|
|
108
103
|
/**
|
|
109
104
|
* This optional function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
|
|
110
105
|
*
|
|
111
106
|
* @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
|
|
112
107
|
* @returns The result of the middleware's cleanup.
|
|
113
108
|
*/
|
|
114
|
-
cleanup?(context: TContext):
|
|
109
|
+
cleanup?(context: TContext): void | PipelineResult;
|
|
115
110
|
}
|
|
116
111
|
|
|
117
112
|
/**
|
|
@@ -122,7 +117,7 @@ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareRes
|
|
|
122
117
|
* @template TResult - The type of the result that each middleware function will return.
|
|
123
118
|
* Defaults to {@link MiddlewareResult}.
|
|
124
119
|
*/
|
|
125
|
-
interface IPipeline<TContext extends IPipelineContext
|
|
120
|
+
interface IPipeline<TContext extends IPipelineContext> {
|
|
126
121
|
/**
|
|
127
122
|
* Represents the name of the pipeline.
|
|
128
123
|
* This property is optional and can be used for debugging purposes.
|
|
@@ -133,13 +128,18 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
133
128
|
* This property is optional.
|
|
134
129
|
*/
|
|
135
130
|
readonly length?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Represents the middleware functions registered in the pipeline.
|
|
133
|
+
* This property is optional.
|
|
134
|
+
*/
|
|
135
|
+
readonly middleware?: Immutable<IMiddleware<TContext>[]>;
|
|
136
136
|
/**
|
|
137
137
|
* Register middleware for this pipeline.
|
|
138
138
|
*
|
|
139
139
|
* @param middleware - The middleware function to be added to the pipeline.
|
|
140
140
|
* @returns This instance of the pipeline, allowing for method chaining.
|
|
141
141
|
*/
|
|
142
|
-
use(middleware: IMiddleware<TContext
|
|
142
|
+
use(middleware: Immutable<IMiddleware<TContext>>): this;
|
|
143
143
|
/**
|
|
144
144
|
* Execute the Dispatch phase on the chain of middleware, with the given Context.
|
|
145
145
|
* The Dispatch phase is responsible for invoking the middleware functions in the pipeline.
|
|
@@ -147,7 +147,7 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
147
147
|
* @param context - The context object that will be passed to each middleware function.
|
|
148
148
|
* @returns A {@link PipelineResult} object representing the result of the pipeline execution.
|
|
149
149
|
*/
|
|
150
|
-
dispatch(context: TContext): PipelineResult;
|
|
150
|
+
dispatch(context: Partial<TContext>): PipelineResult;
|
|
151
151
|
/**
|
|
152
152
|
* Execute the Cleanup phase on the chain of middleware, with the given Context.
|
|
153
153
|
* The Cleanup phase is responsible for performing any necessary cleanup operations after the pipeline execution.
|
|
@@ -155,7 +155,7 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
155
155
|
* @param context - The context object that will be passed to each middleware function.
|
|
156
156
|
* @returns A {@link PipelineResult} object representing the result of the cleanup execution.
|
|
157
157
|
*/
|
|
158
|
-
cleanup(context: TContext): PipelineResult;
|
|
158
|
+
cleanup(context: Partial<TContext>): PipelineResult;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
export { type IPipelineContext as I, type
|
|
161
|
+
export { type IPipelineContext as I, type PipelineResult as P, type IPipeline as a, type IMiddleware as b, type PipelineRuntime as c, PipelineStatus as d };
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
+
import { I as Immutable } from './types-cZ-1lGPD.cjs';
|
|
1
2
|
import { P as PerformanceTimeEntry } from './performance-timer-BVyl0SRs.cjs';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Represents the result of a pipeline operation.
|
|
5
|
-
* It can provide performance metrics collected from self or inner middleware & pipeline calls.
|
|
6
|
-
*/
|
|
7
|
-
type PipelineResult = {
|
|
8
|
-
/**
|
|
9
|
-
* Performance metrics collected from the current pipeline operation.
|
|
10
|
-
* This field is optional and can be `undefined` if no performance metrics were collected.
|
|
11
|
-
*/
|
|
12
|
-
readonly performance?: PerformanceTimeEntry;
|
|
13
|
-
/**
|
|
14
|
-
* An array of results from inner middleware & pipeline calls.
|
|
15
|
-
* This field is optional and can be `undefined` if there were no inner calls.
|
|
16
|
-
*/
|
|
17
|
-
readonly inner?: PipelineResult[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Represents the result that can be returned from a middleware function.
|
|
22
|
-
* It can either be void (indicating no result) or a PipelineResult instance.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* MiddlewareResult is used to provide Pipeline Results from inner pipeline calls.
|
|
26
|
-
* This is useful when a middleware function needs to return a result from an inner pipeline call.
|
|
27
|
-
**/
|
|
28
|
-
type MiddlewareResult = void | PipelineResult;
|
|
29
|
-
|
|
30
4
|
/**
|
|
31
5
|
* The PipelineStatus enum represents the different states a pipeline can be in.
|
|
32
6
|
*
|
|
@@ -59,7 +33,7 @@ interface IPipelineContext {
|
|
|
59
33
|
/**
|
|
60
34
|
* The runtime state of the pipeline.
|
|
61
35
|
*/
|
|
62
|
-
readonly runtime
|
|
36
|
+
readonly runtime?: PipelineRuntime;
|
|
63
37
|
}
|
|
64
38
|
/**
|
|
65
39
|
* The Pipeline Runtime exposes runtime status controls for Middlewares, as part of the PipelineContext.
|
|
@@ -76,6 +50,27 @@ type PipelineRuntime = {
|
|
|
76
50
|
* It can be undefined if the status is not set.
|
|
77
51
|
*/
|
|
78
52
|
status?: PipelineStatus;
|
|
53
|
+
/**
|
|
54
|
+
* An optional error that occurred during the pipeline operation.
|
|
55
|
+
*/
|
|
56
|
+
error?: any;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents the result of a pipeline operation.
|
|
61
|
+
* It can provide performance metrics collected from self or inner middleware & pipeline calls.
|
|
62
|
+
*/
|
|
63
|
+
type PipelineResult = {
|
|
64
|
+
/**
|
|
65
|
+
* Performance metrics collected from the current pipeline operation.
|
|
66
|
+
* This field is optional and can be `undefined` if no performance metrics were collected.
|
|
67
|
+
*/
|
|
68
|
+
readonly performance?: PerformanceTimeEntry;
|
|
69
|
+
/**
|
|
70
|
+
* An array of results from inner middleware & pipeline calls.
|
|
71
|
+
* This field is optional and can be `undefined` if there were no inner calls.
|
|
72
|
+
*/
|
|
73
|
+
readonly inner?: PipelineResult[];
|
|
79
74
|
};
|
|
80
75
|
|
|
81
76
|
/**
|
|
@@ -85,7 +80,7 @@ type PipelineRuntime = {
|
|
|
85
80
|
* @template TContext The type of the context that the middleware will operate on.
|
|
86
81
|
* @template TResult The type of the result that the middleware will return.
|
|
87
82
|
*/
|
|
88
|
-
interface IMiddleware<TContext extends IPipelineContext
|
|
83
|
+
interface IMiddleware<TContext extends IPipelineContext> {
|
|
89
84
|
/**
|
|
90
85
|
* An optional name for the middleware.
|
|
91
86
|
*/
|
|
@@ -104,14 +99,14 @@ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareRes
|
|
|
104
99
|
* @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
|
|
105
100
|
* @returns The result of the middleware's action.
|
|
106
101
|
*/
|
|
107
|
-
action(context: TContext):
|
|
102
|
+
action(context: TContext): void | PipelineResult;
|
|
108
103
|
/**
|
|
109
104
|
* This optional function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
|
|
110
105
|
*
|
|
111
106
|
* @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
|
|
112
107
|
* @returns The result of the middleware's cleanup.
|
|
113
108
|
*/
|
|
114
|
-
cleanup?(context: TContext):
|
|
109
|
+
cleanup?(context: TContext): void | PipelineResult;
|
|
115
110
|
}
|
|
116
111
|
|
|
117
112
|
/**
|
|
@@ -122,7 +117,7 @@ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareRes
|
|
|
122
117
|
* @template TResult - The type of the result that each middleware function will return.
|
|
123
118
|
* Defaults to {@link MiddlewareResult}.
|
|
124
119
|
*/
|
|
125
|
-
interface IPipeline<TContext extends IPipelineContext
|
|
120
|
+
interface IPipeline<TContext extends IPipelineContext> {
|
|
126
121
|
/**
|
|
127
122
|
* Represents the name of the pipeline.
|
|
128
123
|
* This property is optional and can be used for debugging purposes.
|
|
@@ -133,13 +128,18 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
133
128
|
* This property is optional.
|
|
134
129
|
*/
|
|
135
130
|
readonly length?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Represents the middleware functions registered in the pipeline.
|
|
133
|
+
* This property is optional.
|
|
134
|
+
*/
|
|
135
|
+
readonly middleware?: Immutable<IMiddleware<TContext>[]>;
|
|
136
136
|
/**
|
|
137
137
|
* Register middleware for this pipeline.
|
|
138
138
|
*
|
|
139
139
|
* @param middleware - The middleware function to be added to the pipeline.
|
|
140
140
|
* @returns This instance of the pipeline, allowing for method chaining.
|
|
141
141
|
*/
|
|
142
|
-
use(middleware: IMiddleware<TContext
|
|
142
|
+
use(middleware: Immutable<IMiddleware<TContext>>): this;
|
|
143
143
|
/**
|
|
144
144
|
* Execute the Dispatch phase on the chain of middleware, with the given Context.
|
|
145
145
|
* The Dispatch phase is responsible for invoking the middleware functions in the pipeline.
|
|
@@ -147,7 +147,7 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
147
147
|
* @param context - The context object that will be passed to each middleware function.
|
|
148
148
|
* @returns A {@link PipelineResult} object representing the result of the pipeline execution.
|
|
149
149
|
*/
|
|
150
|
-
dispatch(context: TContext): PipelineResult;
|
|
150
|
+
dispatch(context: Partial<TContext>): PipelineResult;
|
|
151
151
|
/**
|
|
152
152
|
* Execute the Cleanup phase on the chain of middleware, with the given Context.
|
|
153
153
|
* The Cleanup phase is responsible for performing any necessary cleanup operations after the pipeline execution.
|
|
@@ -155,7 +155,7 @@ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResul
|
|
|
155
155
|
* @param context - The context object that will be passed to each middleware function.
|
|
156
156
|
* @returns A {@link PipelineResult} object representing the result of the cleanup execution.
|
|
157
157
|
*/
|
|
158
|
-
cleanup(context: TContext): PipelineResult;
|
|
158
|
+
cleanup(context: Partial<TContext>): PipelineResult;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
export { type IPipelineContext as I, type
|
|
161
|
+
export { type IPipelineContext as I, type PipelineResult as P, type IPipeline as a, type IMiddleware as b, type PipelineRuntime as c, PipelineStatus as d };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pipelines/index.ts","../../src/pipelines/pipeline-status.ts"],"sourcesContent":["export * from './middleware-
|
|
1
|
+
{"version":3,"sources":["../../src/pipelines/index.ts","../../src/pipelines/pipeline-status.ts"],"sourcesContent":["export * from './middleware-runner';\nexport * from './middleware';\nexport * from './pipeline-context';\nexport * from './pipeline-nested';\nexport * from './pipeline-result';\nexport * from './pipeline-runner';\nexport * from './pipeline-status';\nexport * from './pipeline';\n","/**\n * The PipelineStatus enum represents the different states a pipeline can be in.\n *\n * @remarks\n * This enum is used to track the current status of the pipeline.\n */\nexport enum PipelineStatus {\n /**\n * The pipeline is currently idle and not processing any tasks.\n */\n idle = 'idle',\n\n /**\n * The pipeline is currently processing tasks.\n */\n ongoing = 'ongoing',\n\n /**\n * The pipeline has completed all tasks successfully.\n */\n completed = 'completed',\n\n /**\n * The pipeline has been halted due to an error or middleware intervention.\n */\n halted = 'halted'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAK,iBAAL,kBAAKA,oBAAL;AAIL,EAAAA,gBAAA,UAAO;AAKP,EAAAA,gBAAA,aAAU;AAKV,EAAAA,gBAAA,eAAY;AAKZ,EAAAA,gBAAA,YAAS;AAnBC,SAAAA;AAAA,GAAA;","names":["PipelineStatus"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { I as IPipelineContext, b as IMiddleware,
|
|
2
|
-
export {
|
|
1
|
+
import { I as IPipelineContext, b as IMiddleware, P as PipelineResult, a as IPipeline } from '../pipeline-CzwetuCd.cjs';
|
|
2
|
+
export { c as PipelineRuntime, d as PipelineStatus } from '../pipeline-CzwetuCd.cjs';
|
|
3
|
+
import '../types-cZ-1lGPD.cjs';
|
|
3
4
|
import '../performance-timer-BVyl0SRs.cjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -16,7 +17,7 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
|
16
17
|
* @param middleware The {@link IMiddleware} to call the {@link IMiddleware.action} method on.
|
|
17
18
|
* @returns A {@link MiddlewareResult} indicating the outcome of the middleware's action.
|
|
18
19
|
*/
|
|
19
|
-
dispatch(context: TContext, middleware: IMiddleware<TContext>):
|
|
20
|
+
dispatch(context: TContext, middleware: IMiddleware<TContext>): void | PipelineResult;
|
|
20
21
|
/**
|
|
21
22
|
* The `cleanup` method decides how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
|
|
22
23
|
*
|
|
@@ -24,9 +25,41 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
|
24
25
|
* @param middleware The {@link IMiddleware} to call the {@link IMiddleware.cleanup} method on.
|
|
25
26
|
* @returns A {@link MiddlewareResult} indicating the outcome of the middleware's cleanup.
|
|
26
27
|
*/
|
|
27
|
-
cleanup(context: TContext, middleware: IMiddleware<TContext>):
|
|
28
|
+
cleanup(context: TContext, middleware: IMiddleware<TContext>): void | PipelineResult;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A context that is passed to a parent pipeline in a nested setup.
|
|
33
|
+
*
|
|
34
|
+
* @template N - The context type of the nested pipeline.
|
|
35
|
+
*/
|
|
36
|
+
interface IParentContext<N extends IPipelineContext> extends IPipelineContext {
|
|
37
|
+
readonly nestedPipeline: IPipeline<INestedContext<this>>;
|
|
38
|
+
readonly nestedContexts: Partial<N>[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A context that is passed to a nested pipeline.
|
|
42
|
+
*
|
|
43
|
+
* @template P - The context type of the parent pipeline.
|
|
44
|
+
*/
|
|
45
|
+
interface INestedContext<P extends IParentContext<any>> extends IPipelineContext {
|
|
46
|
+
readonly current: P extends IParentContext<infer N> ? N : never;
|
|
47
|
+
readonly previous?: P extends IParentContext<infer N> ? N : never;
|
|
48
|
+
readonly parent: P;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A middleware that is ran as part of a nested pipeline.
|
|
52
|
+
*
|
|
53
|
+
* @template P - The context type of the parent pipeline.
|
|
54
|
+
*/
|
|
55
|
+
type INestedMiddleware<P extends IParentContext<any>> = IMiddleware<INestedContext<P>>;
|
|
56
|
+
/**
|
|
57
|
+
* A middleware that is ran as part of a parent pipeline.
|
|
58
|
+
*
|
|
59
|
+
* @template P - The context type of the parent pipeline.
|
|
60
|
+
*/
|
|
61
|
+
type IParentMiddleware<P extends IParentContext<any>> = IMiddleware<P>;
|
|
62
|
+
|
|
30
63
|
/**
|
|
31
64
|
* The `Pipeline Runner` allows for custom logic when running an {@link IMiddleware} Array.
|
|
32
65
|
* It's useful for implementing different `Decorators` to compose extensible runtime logic.
|
|
@@ -41,7 +74,7 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
|
41
74
|
*
|
|
42
75
|
* @returns A {@link PipelineResult} indicating the success or failure of the operation.
|
|
43
76
|
*/
|
|
44
|
-
dispatch(context: TContext
|
|
77
|
+
dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): PipelineResult;
|
|
45
78
|
/**
|
|
46
79
|
* The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instances.
|
|
47
80
|
*
|
|
@@ -50,7 +83,7 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
|
50
83
|
*
|
|
51
84
|
* @returns A {@link PipelineResult} indicating the success or failure of the operation.
|
|
52
85
|
*/
|
|
53
|
-
cleanup(context: TContext
|
|
86
|
+
cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): PipelineResult;
|
|
54
87
|
}
|
|
55
88
|
|
|
56
|
-
export { IMiddleware, type IMiddlewareRunner, IPipelineContext, type IPipelineRunner,
|
|
89
|
+
export { IMiddleware, type IMiddlewareRunner, type INestedContext, type INestedMiddleware, type IParentContext, type IParentMiddleware, IPipeline, IPipelineContext, type IPipelineRunner, PipelineResult };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { I as IPipelineContext, b as IMiddleware,
|
|
2
|
-
export {
|
|
1
|
+
import { I as IPipelineContext, b as IMiddleware, P as PipelineResult, a as IPipeline } from '../pipeline-9bVMwJKD.js';
|
|
2
|
+
export { c as PipelineRuntime, d as PipelineStatus } from '../pipeline-9bVMwJKD.js';
|
|
3
|
+
import '../types-cZ-1lGPD.js';
|
|
3
4
|
import '../performance-timer-BVyl0SRs.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -16,7 +17,7 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
|
16
17
|
* @param middleware The {@link IMiddleware} to call the {@link IMiddleware.action} method on.
|
|
17
18
|
* @returns A {@link MiddlewareResult} indicating the outcome of the middleware's action.
|
|
18
19
|
*/
|
|
19
|
-
dispatch(context: TContext, middleware: IMiddleware<TContext>):
|
|
20
|
+
dispatch(context: TContext, middleware: IMiddleware<TContext>): void | PipelineResult;
|
|
20
21
|
/**
|
|
21
22
|
* The `cleanup` method decides how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
|
|
22
23
|
*
|
|
@@ -24,9 +25,41 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
|
24
25
|
* @param middleware The {@link IMiddleware} to call the {@link IMiddleware.cleanup} method on.
|
|
25
26
|
* @returns A {@link MiddlewareResult} indicating the outcome of the middleware's cleanup.
|
|
26
27
|
*/
|
|
27
|
-
cleanup(context: TContext, middleware: IMiddleware<TContext>):
|
|
28
|
+
cleanup(context: TContext, middleware: IMiddleware<TContext>): void | PipelineResult;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* A context that is passed to a parent pipeline in a nested setup.
|
|
33
|
+
*
|
|
34
|
+
* @template N - The context type of the nested pipeline.
|
|
35
|
+
*/
|
|
36
|
+
interface IParentContext<N extends IPipelineContext> extends IPipelineContext {
|
|
37
|
+
readonly nestedPipeline: IPipeline<INestedContext<this>>;
|
|
38
|
+
readonly nestedContexts: Partial<N>[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A context that is passed to a nested pipeline.
|
|
42
|
+
*
|
|
43
|
+
* @template P - The context type of the parent pipeline.
|
|
44
|
+
*/
|
|
45
|
+
interface INestedContext<P extends IParentContext<any>> extends IPipelineContext {
|
|
46
|
+
readonly current: P extends IParentContext<infer N> ? N : never;
|
|
47
|
+
readonly previous?: P extends IParentContext<infer N> ? N : never;
|
|
48
|
+
readonly parent: P;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A middleware that is ran as part of a nested pipeline.
|
|
52
|
+
*
|
|
53
|
+
* @template P - The context type of the parent pipeline.
|
|
54
|
+
*/
|
|
55
|
+
type INestedMiddleware<P extends IParentContext<any>> = IMiddleware<INestedContext<P>>;
|
|
56
|
+
/**
|
|
57
|
+
* A middleware that is ran as part of a parent pipeline.
|
|
58
|
+
*
|
|
59
|
+
* @template P - The context type of the parent pipeline.
|
|
60
|
+
*/
|
|
61
|
+
type IParentMiddleware<P extends IParentContext<any>> = IMiddleware<P>;
|
|
62
|
+
|
|
30
63
|
/**
|
|
31
64
|
* The `Pipeline Runner` allows for custom logic when running an {@link IMiddleware} Array.
|
|
32
65
|
* It's useful for implementing different `Decorators` to compose extensible runtime logic.
|
|
@@ -41,7 +74,7 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
|
41
74
|
*
|
|
42
75
|
* @returns A {@link PipelineResult} indicating the success or failure of the operation.
|
|
43
76
|
*/
|
|
44
|
-
dispatch(context: TContext
|
|
77
|
+
dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): PipelineResult;
|
|
45
78
|
/**
|
|
46
79
|
* The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instances.
|
|
47
80
|
*
|
|
@@ -50,7 +83,7 @@ interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
|
50
83
|
*
|
|
51
84
|
* @returns A {@link PipelineResult} indicating the success or failure of the operation.
|
|
52
85
|
*/
|
|
53
|
-
cleanup(context: TContext
|
|
86
|
+
cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): PipelineResult;
|
|
54
87
|
}
|
|
55
88
|
|
|
56
|
-
export { IMiddleware, type IMiddlewareRunner, IPipelineContext, type IPipelineRunner,
|
|
89
|
+
export { IMiddleware, type IMiddlewareRunner, type INestedContext, type INestedMiddleware, type IParentContext, type IParentMiddleware, IPipeline, IPipelineContext, type IPipelineRunner, PipelineResult };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/systems/index.ts","../../src/systems/module/system-type.ts"],"sourcesContent":["export * from './pipeline/system-context-entity';\nexport * from './pipeline/system-context-events';\nexport * from './pipeline/system-context-proxies';\nexport * from './pipeline/system-context-repository';\nexport * from './pipeline/system-context-scheduler';\nexport * from './pipeline/system-context-snapshot';\nexport * from './runtime/systems-runtime-context';\nexport * from './runtime/systems-runtime-middleware';\nexport * from './pipeline/system-middleware';\nexport * from './pipeline/system-context';\nexport * from './module/system-type';\nexport * from './module/systems-module';\nexport * from './module/systems-module-repository';\nexport * from './runtime/systems-runtime';\n","/**\n * Enum representing the built-in System pipeline types.\n * These types can be extended to introduce more types, and the System Runtime Pipeline should\n * add Middleware to handle the newly added types.\n */\nexport enum SystemType {\n /**\n * The initialization phase of the Module pipeline.\n * This phase is typically used for setting up initial state and resources.\n */\n initialize = 'initialize',\n\n /**\n * The update phase of the Module pipeline.\n * This phase is responsible for updating the game logic and state of entities.\n */\n update = 'update',\n\n /**\n * The render phase of the Module pipeline.\n * This phase is used for rendering the game to the screen.\n */\n render = 'render',\n\n /**\n * The synchronization phase of the Module pipeline.\n * This phase is used for synchronizing game state with external systems or other components.\n */\n sync = 'sync'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAK,aAAL,kBAAKA,gBAAL;AAKL,EAAAA,YAAA,gBAAa;AAMb,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,UAAO;AAvBG,SAAAA;AAAA,GAAA;","names":["SystemType"]}
|
|
1
|
+
{"version":3,"sources":["../../src/systems/index.ts","../../src/systems/module/system-type.ts"],"sourcesContent":["export * from './pipeline/system-context-entity';\nexport * from './pipeline/system-context-events';\nexport * from './pipeline/system-context-proxies';\nexport * from './pipeline/system-context-repository';\nexport * from './pipeline/system-context-scheduler';\nexport * from './pipeline/system-context-snapshot';\nexport * from './runtime/systems-runtime-context';\nexport * from './runtime/systems-runtime-middleware';\nexport * from './pipeline/system-middleware';\nexport * from './pipeline/system-context';\nexport * from './module/system-type';\nexport * from './module/systems-module';\nexport * from './module/systems-module-definition';\nexport * from './module/systems-module-repository';\nexport * from './runtime/systems-runtime';\n","/**\n * Enum representing the built-in System pipeline types.\n * These types can be extended to introduce more types, and the System Runtime Pipeline should\n * add Middleware to handle the newly added types.\n */\nexport enum SystemType {\n /**\n * The initialization phase of the Module pipeline.\n * This phase is typically used for setting up initial state and resources.\n */\n initialize = 'initialize',\n\n /**\n * The update phase of the Module pipeline.\n * This phase is responsible for updating the game logic and state of entities.\n */\n update = 'update',\n\n /**\n * The render phase of the Module pipeline.\n * This phase is used for rendering the game to the screen.\n */\n render = 'render',\n\n /**\n * The synchronization phase of the Module pipeline.\n * This phase is used for synchronizing game state with external systems or other components.\n */\n sync = 'sync'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAK,aAAL,kBAAKA,gBAAL;AAKL,EAAAA,YAAA,gBAAa;AAMb,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,UAAO;AAvBG,SAAAA;AAAA,GAAA;","names":["SystemType"]}
|
package/dist/systems/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-
|
|
2
|
-
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-
|
|
1
|
+
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-Bz9hIdKT.cjs';
|
|
2
|
+
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-Bz9hIdKT.cjs';
|
|
3
3
|
import { c as IEntity, E as EntityTypeUid } from '../index-CnlpX7ys.cjs';
|
|
4
|
-
import { b as IMiddleware, P as PipelineResult } from '../pipeline-
|
|
5
|
-
import { f as IEntityUpdate } from '../entity-repository-DJ1xbvaN.cjs';
|
|
4
|
+
import { b as IMiddleware, a as IPipeline, P as PipelineResult } from '../pipeline-CzwetuCd.cjs';
|
|
6
5
|
import { I as Immutable } from '../types-cZ-1lGPD.cjs';
|
|
6
|
+
import { f as IEntityUpdate } from '../entity-repository-DJ1xbvaN.cjs';
|
|
7
7
|
import '../utils/index.cjs';
|
|
8
8
|
import '../performance-timer-BVyl0SRs.cjs';
|
|
9
9
|
|
|
@@ -26,10 +26,11 @@ type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRu
|
|
|
26
26
|
type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* The
|
|
30
|
-
* It can
|
|
29
|
+
* The SystemModuleDefinition is the main way of composing SystemsModules for an Entity.
|
|
30
|
+
* It can be used as building blocks for SystemsModules as a way to register common SystemMiddlewares and share across different Entities.
|
|
31
31
|
*/
|
|
32
|
-
interface
|
|
32
|
+
interface ISystemsModuleDefinition<TEntity extends IEntity> {
|
|
33
|
+
readonly systems: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
|
|
33
34
|
/**
|
|
34
35
|
* Registers SystemMiddlewares to the specified SystemPipelineType.
|
|
35
36
|
*
|
|
@@ -37,14 +38,26 @@ interface ISystemsModule<TEntity extends IEntity> {
|
|
|
37
38
|
* @param systems - The SystemMiddlewares to be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
38
39
|
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
39
40
|
*/
|
|
40
|
-
registerSystems?(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
|
|
41
|
+
registerSystems?(type: SystemType, systems: Immutable<ISystemMiddleware<TEntity>[]>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Registers the middleware of the provided SystemsModule in the current SystemsModule. Keeps the same system types.
|
|
44
|
+
* @param module - The SystemsModule to be registered.
|
|
45
|
+
*/
|
|
46
|
+
registerModule?(module: Immutable<ISystemsModuleDefinition<TEntity>>): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
|
|
51
|
+
* It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
|
|
52
|
+
*/
|
|
53
|
+
interface ISystemsModule<TEntity extends IEntity> extends ISystemsModuleDefinition<TEntity> {
|
|
41
54
|
/**
|
|
42
55
|
* Triggers all registered SystemPipelines to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
43
56
|
*
|
|
44
57
|
* @param update - The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
45
|
-
* @returns
|
|
58
|
+
* @returns An optional PipelineResult indicating the success or failure of the triggered SystemPipelines.
|
|
46
59
|
*/
|
|
47
|
-
triggerSystems(update: IEntityUpdate): PipelineResult;
|
|
60
|
+
triggerSystems(update: Immutable<IEntityUpdate>): void | PipelineResult;
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
/**
|
|
@@ -98,4 +111,4 @@ interface ISystemsRuntime {
|
|
|
98
111
|
runTick(update?: IEntityUpdate): PipelineResult;
|
|
99
112
|
}
|
|
100
113
|
|
|
101
|
-
export { ISystemContext, type ISystemMiddleware, type ISystemsModule, type ISystemsModuleRepository, type ISystemsRuntime, ISystemsRuntimeContext, type ISystemsRuntimeMiddleware, SystemType };
|
|
114
|
+
export { ISystemContext, type ISystemMiddleware, type ISystemsModule, type ISystemsModuleDefinition, type ISystemsModuleRepository, type ISystemsRuntime, ISystemsRuntimeContext, type ISystemsRuntimeMiddleware, SystemType };
|
package/dist/systems/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-
|
|
2
|
-
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-
|
|
1
|
+
import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-C_Tsvoym.js';
|
|
2
|
+
export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-C_Tsvoym.js';
|
|
3
3
|
import { c as IEntity, E as EntityTypeUid } from '../index-B1KXekZD.js';
|
|
4
|
-
import { b as IMiddleware, P as PipelineResult } from '../pipeline-
|
|
5
|
-
import { f as IEntityUpdate } from '../entity-repository-BlSpo-x2.js';
|
|
4
|
+
import { b as IMiddleware, a as IPipeline, P as PipelineResult } from '../pipeline-9bVMwJKD.js';
|
|
6
5
|
import { I as Immutable } from '../types-cZ-1lGPD.js';
|
|
6
|
+
import { f as IEntityUpdate } from '../entity-repository-BlSpo-x2.js';
|
|
7
7
|
import '../utils/index.js';
|
|
8
8
|
import '../performance-timer-BVyl0SRs.js';
|
|
9
9
|
|
|
@@ -26,10 +26,11 @@ type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRu
|
|
|
26
26
|
type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* The
|
|
30
|
-
* It can
|
|
29
|
+
* The SystemModuleDefinition is the main way of composing SystemsModules for an Entity.
|
|
30
|
+
* It can be used as building blocks for SystemsModules as a way to register common SystemMiddlewares and share across different Entities.
|
|
31
31
|
*/
|
|
32
|
-
interface
|
|
32
|
+
interface ISystemsModuleDefinition<TEntity extends IEntity> {
|
|
33
|
+
readonly systems: Map<SystemType, IPipeline<ISystemContext<TEntity>>>;
|
|
33
34
|
/**
|
|
34
35
|
* Registers SystemMiddlewares to the specified SystemPipelineType.
|
|
35
36
|
*
|
|
@@ -37,14 +38,26 @@ interface ISystemsModule<TEntity extends IEntity> {
|
|
|
37
38
|
* @param systems - The SystemMiddlewares to be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
38
39
|
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
39
40
|
*/
|
|
40
|
-
registerSystems?(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
|
|
41
|
+
registerSystems?(type: SystemType, systems: Immutable<ISystemMiddleware<TEntity>[]>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Registers the middleware of the provided SystemsModule in the current SystemsModule. Keeps the same system types.
|
|
44
|
+
* @param module - The SystemsModule to be registered.
|
|
45
|
+
*/
|
|
46
|
+
registerModule?(module: Immutable<ISystemsModuleDefinition<TEntity>>): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
|
|
51
|
+
* It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
|
|
52
|
+
*/
|
|
53
|
+
interface ISystemsModule<TEntity extends IEntity> extends ISystemsModuleDefinition<TEntity> {
|
|
41
54
|
/**
|
|
42
55
|
* Triggers all registered SystemPipelines to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
43
56
|
*
|
|
44
57
|
* @param update - The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
45
|
-
* @returns
|
|
58
|
+
* @returns An optional PipelineResult indicating the success or failure of the triggered SystemPipelines.
|
|
46
59
|
*/
|
|
47
|
-
triggerSystems(update: IEntityUpdate): PipelineResult;
|
|
60
|
+
triggerSystems(update: Immutable<IEntityUpdate>): void | PipelineResult;
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
/**
|
|
@@ -98,4 +111,4 @@ interface ISystemsRuntime {
|
|
|
98
111
|
runTick(update?: IEntityUpdate): PipelineResult;
|
|
99
112
|
}
|
|
100
113
|
|
|
101
|
-
export { ISystemContext, type ISystemMiddleware, type ISystemsModule, type ISystemsModuleRepository, type ISystemsRuntime, ISystemsRuntimeContext, type ISystemsRuntimeMiddleware, SystemType };
|
|
114
|
+
export { ISystemContext, type ISystemMiddleware, type ISystemsModule, type ISystemsModuleDefinition, type ISystemsModuleRepository, type ISystemsRuntime, ISystemsRuntimeContext, type ISystemsRuntimeMiddleware, SystemType };
|
package/dist/{systems-runtime-context-DhtHMczN.d.cts → systems-runtime-context-Bz9hIdKT.d.cts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I as IEntityProxy, E as EntityTypeUid, b as IEntityModel, c as IEntity, d as EntityProxy } from './index-CnlpX7ys.cjs';
|
|
2
2
|
import { I as IEventData, E as EntityEventUid, b as IEntityEvent, i as IEntitySnapshot, f as IEntityUpdate, h as IEntityRepository } from './entity-repository-DJ1xbvaN.cjs';
|
|
3
|
-
import { I as IPipelineContext, a as IPipeline } from './pipeline-
|
|
3
|
+
import { I as IPipelineContext, a as IPipeline } from './pipeline-CzwetuCd.cjs';
|
|
4
4
|
import { IJsonSerializer, ILogger } from './utils/index.cjs';
|
|
5
5
|
import { I as Immutable } from './types-cZ-1lGPD.cjs';
|
|
6
6
|
|
package/dist/{systems-runtime-context-BTNdV8Z-.d.ts → systems-runtime-context-C_Tsvoym.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I as IEntityProxy, E as EntityTypeUid, b as IEntityModel, c as IEntity, d as EntityProxy } from './index-B1KXekZD.js';
|
|
2
2
|
import { I as IEventData, E as EntityEventUid, b as IEntityEvent, i as IEntitySnapshot, f as IEntityUpdate, h as IEntityRepository } from './entity-repository-BlSpo-x2.js';
|
|
3
|
-
import { I as IPipelineContext, a as IPipeline } from './pipeline-
|
|
3
|
+
import { I as IPipelineContext, a as IPipeline } from './pipeline-9bVMwJKD.js';
|
|
4
4
|
import { IJsonSerializer, ILogger } from './utils/index.js';
|
|
5
5
|
import { I as Immutable } from './types-cZ-1lGPD.js';
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesome-ecs/abstract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"url": "https://github.com/privatebytes/awesome-ecs/issues"
|
|
98
98
|
},
|
|
99
99
|
"homepage": "https://github.com/privatebytes/awesome-ecs#readme",
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "e045e329bd5770494fb8707df627c52a5f4ae8a4"
|
|
101
101
|
}
|