@awesome-ecs/abstract 0.7.0 → 0.8.2
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/dist/components/identity-component.d.ts +4 -0
- package/dist/entities/entity-repository.d.ts +7 -16
- package/dist/entities/entity.d.ts +4 -4
- package/dist/factories/context-factory.d.ts +9 -0
- package/dist/{systems/system-middleware.js → factories/context-factory.js} +1 -1
- package/dist/factories/context-factory.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +11 -0
- package/dist/factories/pipeline-factory.js +3 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/runtime-factory.d.ts +10 -0
- package/dist/factories/runtime-factory.js +3 -0
- package/dist/factories/runtime-factory.js.map +1 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/pipelines/middleware-result.d.ts +5 -0
- package/dist/pipelines/middleware-result.js +3 -0
- package/dist/pipelines/middleware-result.js.map +1 -0
- package/dist/pipelines/middleware-stop.d.ts +4 -0
- package/dist/pipelines/middleware-stop.js +3 -0
- package/dist/pipelines/middleware-stop.js.map +1 -0
- package/dist/pipelines/middleware.d.ts +5 -7
- package/dist/pipelines/pipeline-type.d.ts +7 -0
- package/dist/pipelines/pipeline-type.js +12 -0
- package/dist/pipelines/pipeline-type.js.map +1 -0
- package/dist/pipelines/pipeline.d.ts +8 -13
- package/dist/pipelines/pipeline.js +0 -6
- package/dist/pipelines/pipeline.js.map +1 -1
- package/dist/runtime/runtime-pipeline.d.ts +11 -0
- package/dist/runtime/runtime-pipeline.js +3 -0
- package/dist/runtime/runtime-pipeline.js.map +1 -0
- package/dist/runtime/runtime-result.d.ts +20 -0
- package/dist/runtime/runtime-result.js +3 -0
- package/dist/runtime/runtime-result.js.map +1 -0
- package/dist/runtime/runtime-status.d.ts +7 -0
- package/dist/runtime/runtime-status.js +12 -0
- package/dist/runtime/runtime-status.js.map +1 -0
- package/dist/systems/context/system-context-events.d.ts +19 -0
- package/dist/systems/context/system-context-events.js +3 -0
- package/dist/systems/context/system-context-events.js.map +1 -0
- package/dist/systems/context/system-context-proxies.d.ts +12 -0
- package/dist/systems/context/system-context-proxies.js +3 -0
- package/dist/systems/context/system-context-proxies.js.map +1 -0
- package/dist/systems/context/system-context-repository.d.ts +13 -0
- package/dist/systems/context/system-context-repository.js +3 -0
- package/dist/systems/context/system-context-repository.js.map +1 -0
- package/dist/systems/context/system-context-scheduler.d.ts +9 -0
- package/dist/systems/context/system-context-scheduler.js +3 -0
- package/dist/systems/context/system-context-scheduler.js.map +1 -0
- package/dist/systems/runtime/systems-runtime-context.d.ts +18 -0
- package/dist/systems/runtime/systems-runtime-context.js +3 -0
- package/dist/systems/runtime/systems-runtime-context.js.map +1 -0
- package/dist/systems/runtime/systems-runtime-middleware.d.ts +8 -0
- package/dist/systems/runtime/systems-runtime-middleware.js +3 -0
- package/dist/systems/runtime/systems-runtime-middleware.js.map +1 -0
- package/dist/systems/system-pipeline-context.d.ts +16 -36
- package/dist/systems/{system-middleware.d.ts → system-pipeline-middleware.d.ts} +0 -0
- package/dist/systems/system-pipeline-middleware.js +3 -0
- package/dist/systems/system-pipeline-middleware.js.map +1 -0
- package/dist/systems/system-pipeline-type.d.ts +4 -0
- package/dist/systems/system-pipeline-type.js +4 -0
- package/dist/systems/system-pipeline-type.js.map +1 -1
- package/dist/systems/systems-module.d.ts +9 -12
- package/dist/systems/systems-runtime.d.ts +4 -8
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +2 -2
- package/dist/systems/system-middleware.js.map +0 -1
|
@@ -16,4 +16,8 @@ export interface IdentityComponent<TModel extends IEntityModel> extends ICompone
|
|
|
16
16
|
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
17
17
|
*/
|
|
18
18
|
readonly model: TModel;
|
|
19
|
+
/**
|
|
20
|
+
* Keeps track when it was the last time the Entity's systems have ran. Useful to calculate the DeltaTime between runs.
|
|
21
|
+
*/
|
|
22
|
+
readonly lastUpdated: Date;
|
|
19
23
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* The Entity Repository internal structure. Holds the Entity as well as LastUpdate time.
|
|
4
|
-
*/
|
|
5
|
-
export interface StoredEntity<TEntity extends IEntity> {
|
|
6
|
-
entity: TEntity;
|
|
7
|
-
lastUpdate: Date;
|
|
8
|
-
}
|
|
1
|
+
import { EntityTypeUid, IEntity } from "./entity";
|
|
2
|
+
import { IEntityProxy } from "./entity-proxy";
|
|
9
3
|
/**
|
|
10
4
|
* The Entity Repository is the main storage for keeping track of existing Entities.
|
|
11
5
|
* It provides basic CRUD functionality.
|
|
12
6
|
*/
|
|
13
7
|
export interface IEntityRepository {
|
|
14
|
-
has(
|
|
15
|
-
get<TEntity extends IEntity>(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
listAll(): StoredEntity<IEntity>[];
|
|
8
|
+
has(proxy: IEntityProxy): boolean;
|
|
9
|
+
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
10
|
+
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
11
|
+
listAll(): IEntity[];
|
|
19
12
|
set(entity: IEntity): void;
|
|
20
|
-
delete(
|
|
13
|
+
delete(proxy: IEntityProxy): void;
|
|
21
14
|
clear(entityType: EntityTypeUid): void;
|
|
22
|
-
onEntitySetCallback?: (entity: IEntity) => void;
|
|
23
|
-
onEntityDeletedCallback?: (entity: IEntity) => void;
|
|
24
15
|
}
|
|
@@ -4,14 +4,14 @@ import { IEntityProxy } from "./entity-proxy";
|
|
|
4
4
|
export declare type EntityTypeUid = string | number;
|
|
5
5
|
export declare type EntityUid = string | number;
|
|
6
6
|
export interface IEntityModel {
|
|
7
|
-
uid: EntityUid;
|
|
7
|
+
readonly uid: EntityUid;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* An Entity is a container of Components and Entity Proxies. Only Systems can manipulate the internal state of the Entity.
|
|
11
11
|
*/
|
|
12
12
|
export interface IEntity {
|
|
13
|
-
readonly components:
|
|
13
|
+
readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
|
|
14
14
|
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
15
|
-
readonly identity: IdentityComponent<IEntityModel
|
|
16
|
-
readonly myProxy: IEntityProxy
|
|
15
|
+
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
16
|
+
readonly myProxy: Readonly<IEntityProxy>;
|
|
17
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { ISystemPipelineContext } from "../systems/system-pipeline-context";
|
|
3
|
+
/**
|
|
4
|
+
* The IContextFactory can be used as an abstraction layer to quickly create SystemPipelineContext objects,
|
|
5
|
+
* without having to manually resolve all of their dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export interface IContextFactory {
|
|
8
|
+
createPipelineContext<TEntity extends IEntity>(entity: TEntity): ISystemPipelineContext<TEntity>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-factory.js","sourceRoot":"","sources":["../../src/factories/context-factory.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IPipeline } from "../pipelines/pipeline";
|
|
2
|
+
import { PipelineType } from "../pipelines/pipeline-type";
|
|
3
|
+
/**
|
|
4
|
+
* The PipelineFactory can be used as an abstraction layer to quickly create IPipeline objects,
|
|
5
|
+
* without having to manually resolve all of their dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export interface IPipelineFactory {
|
|
8
|
+
createPipeline<TContext>(type: PipelineType): IPipeline<TContext>;
|
|
9
|
+
createAsyncPipeline<TContext>(): IPipeline<TContext>;
|
|
10
|
+
createSyncPipeline<TContext>(): IPipeline<TContext>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-factory.js","sourceRoot":"","sources":["../../src/factories/pipeline-factory.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { PipelineType } from "../pipelines/pipeline-type";
|
|
3
|
+
import { IRuntimePipeline } from "../runtime/runtime-pipeline";
|
|
4
|
+
/**
|
|
5
|
+
* The RuntimeFactory can be used as an abstraction layer to quickly create IRuntimePipeline objects,
|
|
6
|
+
* without having to manually resolve all of their dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export interface IRuntimeFactory {
|
|
9
|
+
createRuntimePipeline<TEntity extends IEntity>(type: PipelineType): IRuntimePipeline<TEntity>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-factory.js","sourceRoot":"","sources":["../../src/factories/runtime-factory.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,27 @@ export * from './entities/entity-proxy';
|
|
|
6
6
|
export * from './entities/entity-queue';
|
|
7
7
|
export * from './entities/entity-repository';
|
|
8
8
|
export * from './entities/entity-scheduler';
|
|
9
|
+
export * from './factories/context-factory';
|
|
10
|
+
export * from './factories/pipeline-factory';
|
|
11
|
+
export * from './factories/runtime-factory';
|
|
12
|
+
export * from './runtime/runtime-pipeline';
|
|
13
|
+
export * from './runtime/runtime-result';
|
|
14
|
+
export * from './runtime/runtime-status';
|
|
9
15
|
export * from './pipelines/middleware';
|
|
16
|
+
export * from './pipelines/middleware-result';
|
|
17
|
+
export * from './pipelines/middleware-stop';
|
|
10
18
|
export * from './pipelines/pipeline';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './systems/
|
|
19
|
+
export * from './pipelines/pipeline-type';
|
|
20
|
+
export * from './systems/context/system-context-events';
|
|
21
|
+
export * from './systems/context/system-context-proxies';
|
|
22
|
+
export * from './systems/context/system-context-repository';
|
|
23
|
+
export * from './systems/context/system-context-scheduler';
|
|
24
|
+
export * from './systems/runtime/systems-runtime-context';
|
|
25
|
+
export * from './systems/runtime/systems-runtime-middleware';
|
|
26
|
+
export * from './systems/system-pipeline-middleware';
|
|
13
27
|
export * from './systems/system-pipeline-context';
|
|
14
28
|
export * from './systems/system-pipeline-type';
|
|
29
|
+
export * from './systems/systems-module';
|
|
15
30
|
export * from './systems/systems-runtime';
|
|
16
31
|
export * from './utils/performance-timer';
|
|
32
|
+
export * from './utils/types';
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,28 @@ __exportStar(require("./entities/entity-proxy"), exports);
|
|
|
22
22
|
__exportStar(require("./entities/entity-queue"), exports);
|
|
23
23
|
__exportStar(require("./entities/entity-repository"), exports);
|
|
24
24
|
__exportStar(require("./entities/entity-scheduler"), exports);
|
|
25
|
+
__exportStar(require("./factories/context-factory"), exports);
|
|
26
|
+
__exportStar(require("./factories/pipeline-factory"), exports);
|
|
27
|
+
__exportStar(require("./factories/runtime-factory"), exports);
|
|
28
|
+
__exportStar(require("./runtime/runtime-pipeline"), exports);
|
|
29
|
+
__exportStar(require("./runtime/runtime-result"), exports);
|
|
30
|
+
__exportStar(require("./runtime/runtime-status"), exports);
|
|
25
31
|
__exportStar(require("./pipelines/middleware"), exports);
|
|
32
|
+
__exportStar(require("./pipelines/middleware-result"), exports);
|
|
33
|
+
__exportStar(require("./pipelines/middleware-stop"), exports);
|
|
26
34
|
__exportStar(require("./pipelines/pipeline"), exports);
|
|
27
|
-
__exportStar(require("./
|
|
28
|
-
__exportStar(require("./systems/
|
|
35
|
+
__exportStar(require("./pipelines/pipeline-type"), exports);
|
|
36
|
+
__exportStar(require("./systems/context/system-context-events"), exports);
|
|
37
|
+
__exportStar(require("./systems/context/system-context-proxies"), exports);
|
|
38
|
+
__exportStar(require("./systems/context/system-context-repository"), exports);
|
|
39
|
+
__exportStar(require("./systems/context/system-context-scheduler"), exports);
|
|
40
|
+
__exportStar(require("./systems/runtime/systems-runtime-context"), exports);
|
|
41
|
+
__exportStar(require("./systems/runtime/systems-runtime-middleware"), exports);
|
|
42
|
+
__exportStar(require("./systems/system-pipeline-middleware"), exports);
|
|
29
43
|
__exportStar(require("./systems/system-pipeline-context"), exports);
|
|
30
44
|
__exportStar(require("./systems/system-pipeline-type"), exports);
|
|
45
|
+
__exportStar(require("./systems/systems-module"), exports);
|
|
31
46
|
__exportStar(require("./systems/systems-runtime"), exports);
|
|
32
47
|
__exportStar(require("./utils/performance-timer"), exports);
|
|
48
|
+
__exportStar(require("./utils/types"), exports);
|
|
33
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,kEAA+C;AAE/C,oDAAiC;AACjC,2DAAwC;AACxC,0DAAuC;AACvC,0DAAuC;AACvC,+DAA4C;AAC5C,8DAA2C;AAE3C,yDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,kEAA+C;AAE/C,oDAAiC;AACjC,2DAAwC;AACxC,0DAAuC;AACvC,0DAAuC;AACvC,+DAA4C;AAC5C,8DAA2C;AAE3C,8DAA2C;AAC3C,+DAA4C;AAC5C,8DAA2C;AAE3C,6DAA0C;AAC1C,2DAAwC;AACxC,2DAAwC;AAExC,yDAAsC;AACtC,gEAA6C;AAC7C,8DAA2C;AAC3C,uDAAoC;AACpC,4DAAyC;AAEzC,0EAAuD;AACvD,2EAAwD;AACxD,8EAA2D;AAC3D,6EAA0D;AAE1D,4EAAyD;AACzD,+EAA4D;AAE5D,uEAAoD;AACpD,oEAAiD;AACjD,iEAA8C;AAC9C,2DAAwC;AACxC,4DAAyC;AAEzC,4DAAyC;AACzC,gDAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-result.js","sourceRoot":"","sources":["../../src/pipelines/middleware-result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-stop.js","sourceRoot":"","sources":["../../src/pipelines/middleware-stop.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export declare type Stop = () => void;
|
|
1
|
+
import { Stop } from "./middleware-stop";
|
|
2
|
+
import { MiddlewareResult } from "./middleware-result";
|
|
5
3
|
/**
|
|
6
4
|
* A middleware, the building block of a Pipeline. The middlewares will get called in the same order they get registered in the Pipeline.
|
|
7
5
|
*/
|
|
8
|
-
export interface IMiddleware<TContext> {
|
|
6
|
+
export interface IMiddleware<TContext, TResult = MiddlewareResult> {
|
|
9
7
|
/**
|
|
10
8
|
* This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
|
|
11
9
|
* being met so this middleware's action should run.
|
|
@@ -17,10 +15,10 @@ export interface IMiddleware<TContext> {
|
|
|
17
15
|
* @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
|
|
18
16
|
* @param stop The function to halt the execution of the Pipeline. The next Middlewares won't be called anymore.
|
|
19
17
|
*/
|
|
20
|
-
action(context: TContext, stop: Stop): Promise<
|
|
18
|
+
action(context: TContext, stop: Stop): Promise<TResult> | TResult;
|
|
21
19
|
/**
|
|
22
20
|
* This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
|
|
23
21
|
* @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
|
|
24
22
|
*/
|
|
25
|
-
cleanup?(context: TContext): Promise<
|
|
23
|
+
cleanup?(context: TContext): Promise<TResult> | TResult;
|
|
26
24
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PipelineType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Specify how the runtime of the Pipeline should be handled.
|
|
6
|
+
*/
|
|
7
|
+
var PipelineType;
|
|
8
|
+
(function (PipelineType) {
|
|
9
|
+
PipelineType[PipelineType["sync"] = 0] = "sync";
|
|
10
|
+
PipelineType[PipelineType["async"] = 1] = "async";
|
|
11
|
+
})(PipelineType = exports.PipelineType || (exports.PipelineType = {}));
|
|
12
|
+
//# sourceMappingURL=pipeline-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-type.js","sourceRoot":"","sources":["../../src/pipelines/pipeline-type.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+CAAI,CAAA;IACJ,iDAAK,CAAA;AACP,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRuntimeResult } from "../runtime/runtime-result";
|
|
2
2
|
import { IMiddleware } from "./middleware";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
halted = 1
|
|
6
|
-
}
|
|
7
|
-
export interface IPipelineResult {
|
|
8
|
-
readonly status: PipelineStatus;
|
|
9
|
-
readonly metrics: PerformanceTimeEntry[];
|
|
10
|
-
}
|
|
3
|
+
import { MiddlewareResult } from "./middleware-result";
|
|
4
|
+
import { PipelineType } from "./pipeline-type";
|
|
11
5
|
/**
|
|
12
6
|
* A middleware container and dispatcher.
|
|
13
7
|
*/
|
|
14
|
-
export interface IPipeline<TContext> {
|
|
8
|
+
export interface IPipeline<TContext, TMiddlewareResult = MiddlewareResult> {
|
|
9
|
+
readonly type: PipelineType;
|
|
15
10
|
/**
|
|
16
11
|
* Register middlewares for this pipeline, in order.
|
|
17
12
|
*/
|
|
18
|
-
use(...middleware: IMiddleware<TContext>[]): void;
|
|
13
|
+
use(...middleware: IMiddleware<TContext, TMiddlewareResult>[]): void;
|
|
19
14
|
/**
|
|
20
15
|
* Execute the chain of middlewares, in the order they were added on a given Context.
|
|
21
16
|
*/
|
|
22
|
-
dispatch(context: TContext):
|
|
17
|
+
dispatch(context: TContext): IRuntimeResult<TMiddlewareResult> | Promise<IRuntimeResult<TMiddlewareResult>>;
|
|
23
18
|
/**
|
|
24
19
|
* Runs the Cleanup function on all middlewares.
|
|
25
20
|
*/
|
|
26
|
-
cleanup(context: TContext):
|
|
21
|
+
cleanup(context: TContext): IRuntimeResult<TMiddlewareResult> | Promise<IRuntimeResult<TMiddlewareResult>>;
|
|
27
22
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PipelineStatus = void 0;
|
|
4
|
-
var PipelineStatus;
|
|
5
|
-
(function (PipelineStatus) {
|
|
6
|
-
PipelineStatus[PipelineStatus["completed"] = 0] = "completed";
|
|
7
|
-
PipelineStatus[PipelineStatus["halted"] = 1] = "halted";
|
|
8
|
-
})(PipelineStatus = exports.PipelineStatus || (exports.PipelineStatus = {}));
|
|
9
3
|
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/pipelines/pipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/pipelines/pipeline.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { ISystemsRuntimeContext } from "../systems/runtime/systems-runtime-context";
|
|
3
|
+
import { IRuntimeResult } from "./runtime-result";
|
|
4
|
+
/**
|
|
5
|
+
* The RuntimePipeline is the main way of orchestrating the steps taken on a System Tick.
|
|
6
|
+
* It should provide a way to make the runtime SYNC or ASYNC by setting the PipelineType flag.
|
|
7
|
+
*/
|
|
8
|
+
export interface IRuntimePipeline<TEntity extends IEntity> {
|
|
9
|
+
dispatch(context: ISystemsRuntimeContext<TEntity>): IRuntimeResult | Promise<IRuntimeResult>;
|
|
10
|
+
cleanup(context: ISystemsRuntimeContext<TEntity>): IRuntimeResult | Promise<IRuntimeResult>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-pipeline.js","sourceRoot":"","sources":["../../src/runtime/runtime-pipeline.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MiddlewareResult } from "../pipelines/middleware-result";
|
|
2
|
+
import { RuntimeStatus } from "./runtime-status";
|
|
3
|
+
import { PerformanceTimeEntry } from "../utils/performance-timer";
|
|
4
|
+
/**
|
|
5
|
+
* The IRuntimeResult contains the RuntimeStatus of the completed runtime operation.
|
|
6
|
+
* Can provide Performance metrics collected from inner runtime calls.
|
|
7
|
+
*/
|
|
8
|
+
export interface IRuntimeResult<TMiddlewareResult = MiddlewareResult> {
|
|
9
|
+
readonly status: RuntimeStatus;
|
|
10
|
+
readonly performance?: IRuntimeResultPerformance<TMiddlewareResult>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The IRuntimeResultPerformance contains the PerformanceTimeEntry for the runtime operation.
|
|
14
|
+
* Can also contain a nested structure of Performance metrics that contain the metrics captured from
|
|
15
|
+
* inner runtime calls.
|
|
16
|
+
*/
|
|
17
|
+
export interface IRuntimeResultPerformance<TResult = MiddlewareResult> {
|
|
18
|
+
performance: PerformanceTimeEntry;
|
|
19
|
+
result?: TResult;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-result.js","sourceRoot":"","sources":["../../src/runtime/runtime-result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The RuntimeStatus tells whether the Runtime components have ran to completion or not.
|
|
6
|
+
*/
|
|
7
|
+
var RuntimeStatus;
|
|
8
|
+
(function (RuntimeStatus) {
|
|
9
|
+
RuntimeStatus["completed"] = "completed";
|
|
10
|
+
RuntimeStatus["halted"] = "halted";
|
|
11
|
+
})(RuntimeStatus = exports.RuntimeStatus || (exports.RuntimeStatus = {}));
|
|
12
|
+
//# sourceMappingURL=runtime-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-status.js","sourceRoot":"","sources":["../../src/runtime/runtime-status.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EntityEventUid, IEntityEvent, IEventData } from "../../entities/entity-events";
|
|
2
|
+
import { IEntityProxy } from "../../entities/entity-proxy";
|
|
3
|
+
/**
|
|
4
|
+
* The ISystemContextEvents is the access point for Event related APIs.
|
|
5
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISystemContextEvents {
|
|
8
|
+
dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
|
|
9
|
+
dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
|
|
10
|
+
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData>;
|
|
11
|
+
listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
|
|
12
|
+
hasEvent(uid?: EntityEventUid): boolean;
|
|
13
|
+
subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
|
|
14
|
+
unsubscribeFrom(uid: EntityEventUid): void;
|
|
15
|
+
clearSubscriptions(uid?: EntityEventUid): void;
|
|
16
|
+
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
17
|
+
setContextEvent(event: IEntityEvent<IEventData>): void;
|
|
18
|
+
clearContextEvents(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-context-events.js","sourceRoot":"","sources":["../../../src/systems/context/system-context-events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EntityTypeUid } from "../../entities/entity";
|
|
2
|
+
import { IEntityProxy } from "../../entities/entity-proxy";
|
|
3
|
+
/**
|
|
4
|
+
* The ISystemContextProxies is the access point for EntityProxy related APIs.
|
|
5
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISystemContextProxies {
|
|
8
|
+
registerProxy(proxy: IEntityProxy, cleanup?: boolean): void;
|
|
9
|
+
registerProxies(proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
10
|
+
removeProxy(proxy: IEntityProxy): void;
|
|
11
|
+
removeProxies(proxyEntityType?: EntityTypeUid): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-context-proxies.js","sourceRoot":"","sources":["../../../src/systems/context/system-context-proxies.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EntityTypeUid, IEntityModel, IEntity } from "../../entities/entity";
|
|
2
|
+
import { IEntityEvent, IEventData } from "../../entities/entity-events";
|
|
3
|
+
import { EntityProxy, IEntityProxy } from "../../entities/entity-proxy";
|
|
4
|
+
/**
|
|
5
|
+
* The ISystemContextRepository is the access point for EntityRepository related APIs.
|
|
6
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
7
|
+
*/
|
|
8
|
+
export interface ISystemContextRepository {
|
|
9
|
+
addEntity(entityType: EntityTypeUid, model: IEntityModel, events?: IEntityEvent<IEventData>[]): void;
|
|
10
|
+
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): TEntity;
|
|
11
|
+
updateEntity(target?: IEntityProxy): void;
|
|
12
|
+
removeEntity(target: IEntityProxy): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-context-repository.js","sourceRoot":"","sources":["../../../src/systems/context/system-context-repository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEntityProxy } from "../../entities/entity-proxy";
|
|
2
|
+
/**
|
|
3
|
+
* The ISystemContextRepository is the access point for Scheduler related APIs.
|
|
4
|
+
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
5
|
+
*/
|
|
6
|
+
export interface ISystemContextScheduler {
|
|
7
|
+
scheduleUpdateOnInterval(target?: IEntityProxy, intervalMs?: number): void;
|
|
8
|
+
clearUpdateOnInterval(target?: IEntityProxy): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-context-scheduler.js","sourceRoot":"","sources":["../../../src/systems/context/system-context-scheduler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IEntity } from "../../entities/entity";
|
|
2
|
+
import { IEntityUpdate } from "../../entities/entity-queue";
|
|
3
|
+
import { IEntityRepository } from "../../entities/entity-repository";
|
|
4
|
+
import { IPipeline } from "../../pipelines/pipeline";
|
|
5
|
+
import { ISystemPipelineContext } from "../system-pipeline-context";
|
|
6
|
+
import { SystemPipelineType } from "../system-pipeline-type";
|
|
7
|
+
/**
|
|
8
|
+
* The ISystemsRuntimeContext is the Context passed by a SystemsRuntimePipeline.
|
|
9
|
+
* It helps orchestrate the execution of SystemPipelines registered in the SystemsModule.
|
|
10
|
+
*/
|
|
11
|
+
export interface ISystemsRuntimeContext<TEntity extends IEntity> {
|
|
12
|
+
readonly entityRepository: IEntityRepository;
|
|
13
|
+
readonly entityUpdate: IEntityUpdate;
|
|
14
|
+
readonly initializeEntity?: boolean;
|
|
15
|
+
readonly allowedSteps: Map<SystemPipelineType, boolean>;
|
|
16
|
+
readonly pipelineContext: ISystemPipelineContext<TEntity>;
|
|
17
|
+
readonly systemPipelines: ReadonlyMap<SystemPipelineType, IPipeline<ISystemPipelineContext<TEntity>>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systems-runtime-context.js","sourceRoot":"","sources":["../../../src/systems/runtime/systems-runtime-context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IEntity } from "../../entities/entity";
|
|
2
|
+
import { IMiddleware } from "../../pipelines/middleware";
|
|
3
|
+
import { ISystemsRuntimeContext } from "./systems-runtime-context";
|
|
4
|
+
/**
|
|
5
|
+
* The ISystemsRuntimeMiddleware represents the building blocks of executing SystemsModule registered Pipelines.
|
|
6
|
+
* It receives the current State in the Context, and can decide which SystemPipelines to execute.
|
|
7
|
+
*/
|
|
8
|
+
export declare type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systems-runtime-middleware.js","sourceRoot":"","sources":["../../../src/systems/runtime/systems-runtime-middleware.ts"],"names":[],"mappings":""}
|
|
@@ -1,39 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
clearUpdateOnInterval(target?: IEntityProxy): void;
|
|
13
|
-
}
|
|
14
|
-
export interface ISystemContextProxies {
|
|
15
|
-
registerProxy(proxy: IEntityProxy, cleanup?: boolean): void;
|
|
16
|
-
registerProxies(proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
17
|
-
removeProxy(proxy: IEntityProxy): void;
|
|
18
|
-
removeProxies(proxyEntityType?: EntityTypeUid): void;
|
|
19
|
-
}
|
|
20
|
-
export interface ISystemContextEvents {
|
|
21
|
-
dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
|
|
22
|
-
dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
|
|
23
|
-
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData>;
|
|
24
|
-
listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
|
|
25
|
-
hasEvent(uid?: EntityEventUid): boolean;
|
|
26
|
-
subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
|
|
27
|
-
unsubscribeFrom(uid: EntityEventUid): void;
|
|
28
|
-
clearSubscriptions(uid?: EntityEventUid): void;
|
|
29
|
-
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
30
|
-
setContextEvent(event: IEntityEvent<IEventData>): void;
|
|
31
|
-
}
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { ISystemContextEvents } from "./context/system-context-events";
|
|
3
|
+
import { ISystemContextProxies } from "./context/system-context-proxies";
|
|
4
|
+
import { ISystemContextRepository } from "./context/system-context-repository";
|
|
5
|
+
import { ISystemContextScheduler } from "./context/system-context-scheduler";
|
|
6
|
+
/**
|
|
7
|
+
* The ISystemPipelineContext is the Context passed to a SystemMiddleware as part of the Pipeline Dispatch.
|
|
8
|
+
* It's an abstraction layer so that the Middleware code won't have explicit dependencies on other parts of the ECS.
|
|
9
|
+
*
|
|
10
|
+
* Any State changes done by the SystemMiddleware are executed using the APIs provided by the ISystemPipelineContext.
|
|
11
|
+
*/
|
|
32
12
|
export interface ISystemPipelineContext<TEntity extends IEntity> {
|
|
33
|
-
readonly entity: TEntity;
|
|
34
13
|
readonly deltaTimeMs: number;
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly proxies: ISystemContextProxies
|
|
38
|
-
readonly
|
|
14
|
+
readonly entity: Readonly<TEntity>;
|
|
15
|
+
readonly events: Readonly<ISystemContextEvents>;
|
|
16
|
+
readonly proxies: Readonly<ISystemContextProxies>;
|
|
17
|
+
readonly repository: Readonly<ISystemContextRepository>;
|
|
18
|
+
readonly scheduler: Readonly<ISystemContextScheduler>;
|
|
39
19
|
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-pipeline-middleware.js","sourceRoot":"","sources":["../../src/systems/system-pipeline-middleware.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in ECS pipeline types. They can be extended to introduce more types, and the SystemRuntimePipeline should
|
|
3
|
+
* add Middlewares to handle the newly added types.
|
|
4
|
+
*/
|
|
1
5
|
export declare enum SystemPipelineType {
|
|
2
6
|
initialize = "initialize",
|
|
3
7
|
update = "update",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SystemPipelineType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The built-in ECS pipeline types. They can be extended to introduce more types, and the SystemRuntimePipeline should
|
|
6
|
+
* add Middlewares to handle the newly added types.
|
|
7
|
+
*/
|
|
4
8
|
var SystemPipelineType;
|
|
5
9
|
(function (SystemPipelineType) {
|
|
6
10
|
SystemPipelineType["initialize"] = "initialize";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-pipeline-type.js","sourceRoot":"","sources":["../../src/systems/system-pipeline-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B"}
|
|
1
|
+
{"version":3,"file":"system-pipeline-type.js","sourceRoot":"","sources":["../../src/systems/system-pipeline-type.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { IEntity } from "../entities/entity";
|
|
2
2
|
import { IEntityUpdate } from "../entities/entity-queue";
|
|
3
|
-
import {
|
|
4
|
-
import { ISystemMiddleware } from "./system-middleware";
|
|
3
|
+
import { IRuntimeResult } from "../runtime/runtime-result";
|
|
4
|
+
import { ISystemMiddleware } from "./system-pipeline-middleware";
|
|
5
5
|
import { SystemPipelineType } from "./system-pipeline-type";
|
|
6
|
-
export interface ISystemsModuleRuntimeResult {
|
|
7
|
-
metrics: PerformanceTimeEntry[];
|
|
8
|
-
}
|
|
9
6
|
/**
|
|
10
7
|
* The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
|
|
11
8
|
* It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
|
|
12
9
|
*/
|
|
13
|
-
export interface ISystemsModule {
|
|
14
|
-
/**
|
|
15
|
-
* The method allows triggering all registered SystemPipelines, to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
16
|
-
* @param update The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
17
|
-
*/
|
|
18
|
-
triggerSystems(update: IEntityUpdate): ISystemsModuleRuntimeResult | Promise<ISystemsModuleRuntimeResult>;
|
|
10
|
+
export interface ISystemsModule<TEntity extends IEntity> {
|
|
19
11
|
/**
|
|
20
12
|
* @param type The SystemPipelineType to append the provided SystemMiddlewares to.
|
|
21
13
|
* @param systems The SystemMiddlewares will be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
22
14
|
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
23
15
|
*/
|
|
24
|
-
registerSystems(type: SystemPipelineType, systems: ISystemMiddleware<
|
|
16
|
+
registerSystems(type: SystemPipelineType, systems: ISystemMiddleware<TEntity>[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Trigger all registered SystemPipelines, to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
19
|
+
* @param update The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
20
|
+
*/
|
|
21
|
+
triggerSystems(update: IEntityUpdate): IRuntimeResult | Promise<IRuntimeResult>;
|
|
25
22
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { EntityTypeUid } from "../entities/entity";
|
|
2
|
-
import {
|
|
1
|
+
import { EntityTypeUid, IEntity } from "../entities/entity";
|
|
2
|
+
import { IRuntimeResult } from "../runtime/runtime-result";
|
|
3
3
|
import { ISystemsModule } from "./systems-module";
|
|
4
|
-
export interface ISystemsRuntimeTickResult {
|
|
5
|
-
readonly remainingUpdatesCount: number;
|
|
6
|
-
readonly metrics: PerformanceTimeEntry[];
|
|
7
|
-
}
|
|
8
4
|
/**
|
|
9
5
|
* The System Runtime allows running a loop of Ticks.
|
|
10
6
|
*
|
|
@@ -18,9 +14,9 @@ export interface ISystemsRuntime {
|
|
|
18
14
|
* @param entityType The EntityType this module will be registered for.
|
|
19
15
|
* @param module The Module implementation that will be triggered when executing updates for the given EntityType.
|
|
20
16
|
*/
|
|
21
|
-
registerModule(entityType: EntityTypeUid, module: ISystemsModule): void;
|
|
17
|
+
registerModule<TEntity extends IEntity>(entityType: EntityTypeUid, module: ISystemsModule<TEntity>): void;
|
|
22
18
|
/**
|
|
23
19
|
* The method allows for an Unit of Work implementation, and returns the remaining quantity of items scheduled to be processed next.
|
|
24
20
|
*/
|
|
25
|
-
runTick():
|
|
21
|
+
runTick(): IRuntimeResult | Promise<IRuntimeResult>;
|
|
26
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesome-ecs/abstract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"url": "https://github.com/andreicojocaru/awesome-ecs/issues"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/andreicojocaru/awesome-ecs#readme",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "2243dd084e05965e28caa678e9f4689613902236"
|
|
36
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-middleware.js","sourceRoot":"","sources":["../../src/systems/system-middleware.ts"],"names":[],"mappings":""}
|