@awesome-ecs/abstract 0.5.3 → 0.6.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/LICENSE.md +201 -0
- package/README.md +99 -99
- package/dist/components/component.d.ts +17 -17
- package/dist/components/component.js +2 -2
- package/dist/components/identity-component.d.ts +19 -25
- package/dist/components/identity-component.js +7 -7
- package/dist/components/identity-component.js.map +1 -1
- package/dist/entities/entity-events.d.ts +37 -37
- package/dist/entities/entity-events.js +2 -2
- package/dist/entities/entity-proxy.d.ts +14 -14
- package/dist/entities/entity-proxy.js +2 -2
- package/dist/entities/entity-queue.d.ts +30 -30
- package/dist/entities/entity-queue.js +11 -11
- package/dist/entities/entity-repository.d.ts +24 -23
- package/dist/entities/entity-repository.js +2 -2
- package/dist/entities/entity-scheduler.d.ts +11 -10
- package/dist/entities/entity-scheduler.js +2 -2
- package/dist/entities/entity.d.ts +17 -17
- package/dist/entities/entity.js +2 -2
- package/dist/index.d.ts +16 -16
- package/dist/index.js +32 -32
- package/dist/pipelines/middleware.d.ts +26 -26
- package/dist/pipelines/middleware.js +2 -2
- package/dist/pipelines/pipeline.d.ts +18 -18
- package/dist/pipelines/pipeline.js +2 -2
- package/dist/systems/system-middleware.d.ts +8 -8
- package/dist/systems/system-middleware.js +2 -2
- package/dist/systems/system-pipeline-context.d.ts +39 -39
- package/dist/systems/system-pipeline-context.js +2 -2
- package/dist/systems/system-pipeline-type.d.ts +6 -6
- package/dist/systems/system-pipeline-type.js +10 -10
- package/dist/systems/systems-module.d.ts +21 -21
- package/dist/systems/systems-module.js +2 -2
- package/dist/systems/systems-runtime.d.ts +26 -21
- package/dist/systems/systems-runtime.js +2 -2
- package/dist/utils/performance-timer.d.ts +10 -10
- package/dist/utils/performance-timer.js +2 -2
- package/package.json +5 -5
- package/LICENSE +0 -21
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { IEntityModel } from "./entity";
|
|
2
|
-
import { IEntityEvent, IEventData } from "./entity-events";
|
|
3
|
-
import { IEntityProxy } from "./entity-proxy";
|
|
4
|
-
/**
|
|
5
|
-
* The Entity update state for this change.
|
|
6
|
-
*/
|
|
7
|
-
export declare enum EntityUpdateType {
|
|
8
|
-
update = "update",
|
|
9
|
-
remove = "remove"
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Represents an Entity update that should be applied over an (existing) Entity.
|
|
13
|
-
*/
|
|
14
|
-
export interface IEntityUpdate {
|
|
15
|
-
type: EntityUpdateType;
|
|
16
|
-
entity: IEntityProxy;
|
|
17
|
-
model?: IEntityModel;
|
|
18
|
-
events?: IEntityEvent<IEventData>[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The Entity Updates will be queued up, and can be picked up in order.
|
|
22
|
-
* The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
|
|
23
|
-
*/
|
|
24
|
-
export interface IEntityUpdateQueue {
|
|
25
|
-
readonly size: number;
|
|
26
|
-
enqueue(change: IEntityUpdate): void;
|
|
27
|
-
dequeue(): IEntityUpdate;
|
|
28
|
-
peek(): IEntityUpdate;
|
|
29
|
-
clear(): void;
|
|
30
|
-
}
|
|
1
|
+
import { IEntityModel } from "./entity";
|
|
2
|
+
import { IEntityEvent, IEventData } from "./entity-events";
|
|
3
|
+
import { IEntityProxy } from "./entity-proxy";
|
|
4
|
+
/**
|
|
5
|
+
* The Entity update state for this change.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum EntityUpdateType {
|
|
8
|
+
update = "update",
|
|
9
|
+
remove = "remove"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Represents an Entity update that should be applied over an (existing) Entity.
|
|
13
|
+
*/
|
|
14
|
+
export interface IEntityUpdate {
|
|
15
|
+
type: EntityUpdateType;
|
|
16
|
+
entity: IEntityProxy;
|
|
17
|
+
model?: IEntityModel;
|
|
18
|
+
events?: IEntityEvent<IEventData>[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Entity Updates will be queued up, and can be picked up in order.
|
|
22
|
+
* The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
|
|
23
|
+
*/
|
|
24
|
+
export interface IEntityUpdateQueue {
|
|
25
|
+
readonly size: number;
|
|
26
|
+
enqueue(change: IEntityUpdate): void;
|
|
27
|
+
dequeue(): IEntityUpdate;
|
|
28
|
+
peek(): IEntityUpdate;
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityUpdateType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The Entity update state for this change.
|
|
6
|
-
*/
|
|
7
|
-
var EntityUpdateType;
|
|
8
|
-
(function (EntityUpdateType) {
|
|
9
|
-
EntityUpdateType["update"] = "update";
|
|
10
|
-
EntityUpdateType["remove"] = "remove";
|
|
11
|
-
})(EntityUpdateType = exports.EntityUpdateType || (exports.EntityUpdateType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityUpdateType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The Entity update state for this change.
|
|
6
|
+
*/
|
|
7
|
+
var EntityUpdateType;
|
|
8
|
+
(function (EntityUpdateType) {
|
|
9
|
+
EntityUpdateType["update"] = "update";
|
|
10
|
+
EntityUpdateType["remove"] = "remove";
|
|
11
|
+
})(EntityUpdateType = exports.EntityUpdateType || (exports.EntityUpdateType = {}));
|
|
12
12
|
//# sourceMappingURL=entity-queue.js.map
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { EntityUid, EntityTypeUid, IEntity } from "./entity";
|
|
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
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The Entity Repository is the main storage for keeping track of existing Entities.
|
|
11
|
-
* It provides basic CRUD functionality.
|
|
12
|
-
*/
|
|
13
|
-
export interface IEntityRepository {
|
|
14
|
-
has(type: EntityTypeUid, uid: EntityUid): boolean;
|
|
15
|
-
get<TEntity extends IEntity>(type: EntityTypeUid, uid: EntityUid): TEntity;
|
|
16
|
-
getWithTime<TEntity extends IEntity>(type: EntityTypeUid, uid: EntityUid): StoredEntity<TEntity>;
|
|
17
|
-
getAll<TEntity extends IEntity>(type: EntityTypeUid): TEntity[];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { EntityUid, EntityTypeUid, IEntity } from "./entity";
|
|
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
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The Entity Repository is the main storage for keeping track of existing Entities.
|
|
11
|
+
* It provides basic CRUD functionality.
|
|
12
|
+
*/
|
|
13
|
+
export interface IEntityRepository {
|
|
14
|
+
has(type: EntityTypeUid, uid: EntityUid): boolean;
|
|
15
|
+
get<TEntity extends IEntity>(type: EntityTypeUid, uid: EntityUid): TEntity;
|
|
16
|
+
getWithTime<TEntity extends IEntity>(type: EntityTypeUid, uid: EntityUid): StoredEntity<TEntity>;
|
|
17
|
+
getAll<TEntity extends IEntity>(type: EntityTypeUid): TEntity[];
|
|
18
|
+
listAll(): StoredEntity<IEntity>[];
|
|
19
|
+
set(entity: IEntity): void;
|
|
20
|
+
delete(type: EntityTypeUid, uid: EntityUid): void;
|
|
21
|
+
clear(entityType: EntityTypeUid): void;
|
|
22
|
+
onEntitySetCallback?: (entity: IEntity) => void;
|
|
23
|
+
onEntityDeletedCallback?: (entity: IEntity) => void;
|
|
24
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-repository.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IEntityProxy } from "./entity-proxy";
|
|
2
|
-
/**
|
|
3
|
-
* The Entity Scheduler is the main way of scheduling Entity Updates on a Time Interval.
|
|
4
|
-
* It usually reads the Entities from the Entity Repository,
|
|
5
|
-
* and uses the Entity Update Queue to enqueue Entity updates.
|
|
6
|
-
*/
|
|
7
|
-
export interface IEntityScheduler {
|
|
8
|
-
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
9
|
-
remove(entityProxy: IEntityProxy): void;
|
|
10
|
-
|
|
1
|
+
import { IEntityProxy } from "./entity-proxy";
|
|
2
|
+
/**
|
|
3
|
+
* The Entity Scheduler is the main way of scheduling Entity Updates on a Time Interval.
|
|
4
|
+
* It usually reads the Entities from the Entity Repository,
|
|
5
|
+
* and uses the Entity Update Queue to enqueue Entity updates.
|
|
6
|
+
*/
|
|
7
|
+
export interface IEntityScheduler {
|
|
8
|
+
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
9
|
+
remove(entityProxy: IEntityProxy): void;
|
|
10
|
+
has(entityProxy: IEntityProxy): boolean;
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-scheduler.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
-
import { ComponentTypeUid, IComponent } from "../components/component";
|
|
3
|
-
import { IEntityProxy } from "./entity-proxy";
|
|
4
|
-
export declare type EntityTypeUid = string | number;
|
|
5
|
-
export declare type EntityUid = string | number;
|
|
6
|
-
export interface IEntityModel {
|
|
7
|
-
uid: EntityUid;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* An Entity is a container of Components and Entity Proxies. Only Systems can manipulate the internal state of the Entity.
|
|
11
|
-
*/
|
|
12
|
-
export interface IEntity {
|
|
13
|
-
readonly components: Map<ComponentTypeUid, IComponent>;
|
|
14
|
-
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
15
|
-
readonly identity: IdentityComponent<IEntityModel>;
|
|
16
|
-
readonly myProxy: IEntityProxy;
|
|
17
|
-
}
|
|
1
|
+
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
+
import { ComponentTypeUid, IComponent } from "../components/component";
|
|
3
|
+
import { IEntityProxy } from "./entity-proxy";
|
|
4
|
+
export declare type EntityTypeUid = string | number;
|
|
5
|
+
export declare type EntityUid = string | number;
|
|
6
|
+
export interface IEntityModel {
|
|
7
|
+
uid: EntityUid;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* An Entity is a container of Components and Entity Proxies. Only Systems can manipulate the internal state of the Entity.
|
|
11
|
+
*/
|
|
12
|
+
export interface IEntity {
|
|
13
|
+
readonly components: Map<ComponentTypeUid, IComponent>;
|
|
14
|
+
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
15
|
+
readonly identity: IdentityComponent<IEntityModel>;
|
|
16
|
+
readonly myProxy: IEntityProxy;
|
|
17
|
+
}
|
package/dist/entities/entity.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from './components/component';
|
|
2
|
-
export * from './components/identity-component';
|
|
3
|
-
export * from './entities/entity';
|
|
4
|
-
export * from './entities/entity-events';
|
|
5
|
-
export * from './entities/entity-proxy';
|
|
6
|
-
export * from './entities/entity-queue';
|
|
7
|
-
export * from './entities/entity-repository';
|
|
8
|
-
export * from './entities/entity-scheduler';
|
|
9
|
-
export * from './pipelines/middleware';
|
|
10
|
-
export * from './pipelines/pipeline';
|
|
11
|
-
export * from './systems/system-middleware';
|
|
12
|
-
export * from './systems/systems-module';
|
|
13
|
-
export * from './systems/system-pipeline-context';
|
|
14
|
-
export * from './systems/system-pipeline-type';
|
|
15
|
-
export * from './systems/systems-runtime';
|
|
16
|
-
export * from './utils/performance-timer';
|
|
1
|
+
export * from './components/component';
|
|
2
|
+
export * from './components/identity-component';
|
|
3
|
+
export * from './entities/entity';
|
|
4
|
+
export * from './entities/entity-events';
|
|
5
|
+
export * from './entities/entity-proxy';
|
|
6
|
+
export * from './entities/entity-queue';
|
|
7
|
+
export * from './entities/entity-repository';
|
|
8
|
+
export * from './entities/entity-scheduler';
|
|
9
|
+
export * from './pipelines/middleware';
|
|
10
|
+
export * from './pipelines/pipeline';
|
|
11
|
+
export * from './systems/system-middleware';
|
|
12
|
+
export * from './systems/systems-module';
|
|
13
|
+
export * from './systems/system-pipeline-context';
|
|
14
|
+
export * from './systems/system-pipeline-type';
|
|
15
|
+
export * from './systems/systems-runtime';
|
|
16
|
+
export * from './utils/performance-timer';
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components/component"), exports);
|
|
18
|
-
__exportStar(require("./components/identity-component"), exports);
|
|
19
|
-
__exportStar(require("./entities/entity"), exports);
|
|
20
|
-
__exportStar(require("./entities/entity-events"), exports);
|
|
21
|
-
__exportStar(require("./entities/entity-proxy"), exports);
|
|
22
|
-
__exportStar(require("./entities/entity-queue"), exports);
|
|
23
|
-
__exportStar(require("./entities/entity-repository"), exports);
|
|
24
|
-
__exportStar(require("./entities/entity-scheduler"), exports);
|
|
25
|
-
__exportStar(require("./pipelines/middleware"), exports);
|
|
26
|
-
__exportStar(require("./pipelines/pipeline"), exports);
|
|
27
|
-
__exportStar(require("./systems/system-middleware"), exports);
|
|
28
|
-
__exportStar(require("./systems/systems-module"), exports);
|
|
29
|
-
__exportStar(require("./systems/system-pipeline-context"), exports);
|
|
30
|
-
__exportStar(require("./systems/system-pipeline-type"), exports);
|
|
31
|
-
__exportStar(require("./systems/systems-runtime"), exports);
|
|
32
|
-
__exportStar(require("./utils/performance-timer"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components/component"), exports);
|
|
18
|
+
__exportStar(require("./components/identity-component"), exports);
|
|
19
|
+
__exportStar(require("./entities/entity"), exports);
|
|
20
|
+
__exportStar(require("./entities/entity-events"), exports);
|
|
21
|
+
__exportStar(require("./entities/entity-proxy"), exports);
|
|
22
|
+
__exportStar(require("./entities/entity-queue"), exports);
|
|
23
|
+
__exportStar(require("./entities/entity-repository"), exports);
|
|
24
|
+
__exportStar(require("./entities/entity-scheduler"), exports);
|
|
25
|
+
__exportStar(require("./pipelines/middleware"), exports);
|
|
26
|
+
__exportStar(require("./pipelines/pipeline"), exports);
|
|
27
|
+
__exportStar(require("./systems/system-middleware"), exports);
|
|
28
|
+
__exportStar(require("./systems/systems-module"), exports);
|
|
29
|
+
__exportStar(require("./systems/system-pipeline-context"), exports);
|
|
30
|
+
__exportStar(require("./systems/system-pipeline-type"), exports);
|
|
31
|
+
__exportStar(require("./systems/systems-runtime"), exports);
|
|
32
|
+
__exportStar(require("./utils/performance-timer"), exports);
|
|
33
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 'Stop' function, passed to a middleware. Call it to break the pipeline execution.
|
|
3
|
-
*/
|
|
4
|
-
export declare type Stop = () => void;
|
|
5
|
-
/**
|
|
6
|
-
* A middleware, the building block of a Pipeline. The middlewares will get called in the same order they get registered in the Pipeline.
|
|
7
|
-
*/
|
|
8
|
-
export interface IMiddleware<TContext> {
|
|
9
|
-
/**
|
|
10
|
-
* This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
|
|
11
|
-
* being met so this middleware's action should run.
|
|
12
|
-
* @param context The Context to determine whether the run condition is satisfied.
|
|
13
|
-
*/
|
|
14
|
-
shouldRun?(context: TContext): Promise<boolean> | boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The function gets called as part of the pipeline, based on the registration order.
|
|
17
|
-
* @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
|
|
18
|
-
* @param stop The function to halt the execution of the Pipeline. The next Middlewares won't be called anymore.
|
|
19
|
-
*/
|
|
20
|
-
action(context: TContext, stop: Stop): Promise<void> | void;
|
|
21
|
-
/**
|
|
22
|
-
* This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
|
|
23
|
-
* @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
|
|
24
|
-
*/
|
|
25
|
-
cleanup?(context: TContext): Promise<void> | void;
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 'Stop' function, passed to a middleware. Call it to break the pipeline execution.
|
|
3
|
+
*/
|
|
4
|
+
export declare type Stop = () => void;
|
|
5
|
+
/**
|
|
6
|
+
* A middleware, the building block of a Pipeline. The middlewares will get called in the same order they get registered in the Pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export interface IMiddleware<TContext> {
|
|
9
|
+
/**
|
|
10
|
+
* This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
|
|
11
|
+
* being met so this middleware's action should run.
|
|
12
|
+
* @param context The Context to determine whether the run condition is satisfied.
|
|
13
|
+
*/
|
|
14
|
+
shouldRun?(context: TContext): Promise<boolean> | boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The function gets called as part of the pipeline, based on the registration order.
|
|
17
|
+
* @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
|
|
18
|
+
* @param stop The function to halt the execution of the Pipeline. The next Middlewares won't be called anymore.
|
|
19
|
+
*/
|
|
20
|
+
action(context: TContext, stop: Stop): Promise<void> | void;
|
|
21
|
+
/**
|
|
22
|
+
* This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
|
|
23
|
+
* @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
|
|
24
|
+
*/
|
|
25
|
+
cleanup?(context: TContext): Promise<void> | void;
|
|
26
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { IMiddleware } from "./middleware";
|
|
2
|
-
/**
|
|
3
|
-
* A middleware container and dispatcher.
|
|
4
|
-
*/
|
|
5
|
-
export interface IPipeline<TContext> {
|
|
6
|
-
/**
|
|
7
|
-
* Register middlewares for this pipeline, in order.
|
|
8
|
-
*/
|
|
9
|
-
use(...mw: IMiddleware<TContext>[]): void;
|
|
10
|
-
/**
|
|
11
|
-
* Execute the chain of middlewares, in the order they were added on a given Context.
|
|
12
|
-
*/
|
|
13
|
-
dispatch(context: TContext): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Runs the Cleanup function on all middlewares.
|
|
16
|
-
*/
|
|
17
|
-
cleanup(context: TContext): void;
|
|
18
|
-
}
|
|
1
|
+
import { IMiddleware } from "./middleware";
|
|
2
|
+
/**
|
|
3
|
+
* A middleware container and dispatcher.
|
|
4
|
+
*/
|
|
5
|
+
export interface IPipeline<TContext> {
|
|
6
|
+
/**
|
|
7
|
+
* Register middlewares for this pipeline, in order.
|
|
8
|
+
*/
|
|
9
|
+
use(...mw: IMiddleware<TContext>[]): void;
|
|
10
|
+
/**
|
|
11
|
+
* Execute the chain of middlewares, in the order they were added on a given Context.
|
|
12
|
+
*/
|
|
13
|
+
dispatch(context: TContext): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Runs the Cleanup function on all middlewares.
|
|
16
|
+
*/
|
|
17
|
+
cleanup(context: TContext): void;
|
|
18
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IEntity } from "../entities/entity";
|
|
2
|
-
import { IMiddleware } from "../pipelines/middleware";
|
|
3
|
-
import { ISystemPipelineContext } from "./system-pipeline-context";
|
|
4
|
-
/**
|
|
5
|
-
* The SystemMiddleware is the basic System implementation that can be registered as a Middleware in a SystemPipeline.
|
|
6
|
-
* It provides a SystemPipelineContext to it's exposed methods.
|
|
7
|
-
*/
|
|
8
|
-
export declare type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemPipelineContext<TEntity>>;
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { IMiddleware } from "../pipelines/middleware";
|
|
3
|
+
import { ISystemPipelineContext } from "./system-pipeline-context";
|
|
4
|
+
/**
|
|
5
|
+
* The SystemMiddleware is the basic System implementation that can be registered as a Middleware in a SystemPipeline.
|
|
6
|
+
* It provides a SystemPipelineContext to it's exposed methods.
|
|
7
|
+
*/
|
|
8
|
+
export declare type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemPipelineContext<TEntity>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=system-middleware.js.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { EntityTypeUid, IEntity, IEntityModel } from "../entities/entity";
|
|
2
|
-
import { EntityEventUid, IEntityEvent, IEventData } from "../entities/entity-events";
|
|
3
|
-
import { EntityProxy, IEntityProxy } from "../entities/entity-proxy";
|
|
4
|
-
export interface ISystemContextRepository {
|
|
5
|
-
addEntity(entityType: EntityTypeUid, model: IEntityModel, events?: IEntityEvent<IEventData>[]): void;
|
|
6
|
-
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): TEntity;
|
|
7
|
-
updateEntity(target?: IEntityProxy
|
|
8
|
-
removeEntity(target: IEntityProxy): void;
|
|
9
|
-
}
|
|
10
|
-
export interface ISystemContextScheduler {
|
|
11
|
-
scheduleUpdateOnInterval(target?: IEntityProxy, intervalMs?: number): void;
|
|
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
|
-
}
|
|
32
|
-
export interface ISystemPipelineContext<TEntity extends IEntity> {
|
|
33
|
-
readonly entity: TEntity;
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly
|
|
39
|
-
}
|
|
1
|
+
import { EntityTypeUid, IEntity, IEntityModel } from "../entities/entity";
|
|
2
|
+
import { EntityEventUid, IEntityEvent, IEventData } from "../entities/entity-events";
|
|
3
|
+
import { EntityProxy, IEntityProxy } from "../entities/entity-proxy";
|
|
4
|
+
export interface ISystemContextRepository {
|
|
5
|
+
addEntity(entityType: EntityTypeUid, model: IEntityModel, events?: IEntityEvent<IEventData>[]): void;
|
|
6
|
+
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): TEntity;
|
|
7
|
+
updateEntity(target?: IEntityProxy): void;
|
|
8
|
+
removeEntity(target: IEntityProxy): void;
|
|
9
|
+
}
|
|
10
|
+
export interface ISystemContextScheduler {
|
|
11
|
+
scheduleUpdateOnInterval(target?: IEntityProxy, intervalMs?: number): void;
|
|
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
|
+
}
|
|
32
|
+
export interface ISystemPipelineContext<TEntity extends IEntity> {
|
|
33
|
+
readonly entity: TEntity;
|
|
34
|
+
readonly deltaTimeMs: number;
|
|
35
|
+
readonly repository: ISystemContextRepository;
|
|
36
|
+
readonly scheduler: ISystemContextScheduler;
|
|
37
|
+
readonly proxies: ISystemContextProxies;
|
|
38
|
+
readonly events: ISystemContextEvents;
|
|
39
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=system-pipeline-context.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare enum SystemPipelineType {
|
|
2
|
-
initialize = "initialize",
|
|
3
|
-
update = "update",
|
|
4
|
-
render = "render",
|
|
5
|
-
sync = "sync"
|
|
6
|
-
}
|
|
1
|
+
export declare enum SystemPipelineType {
|
|
2
|
+
initialize = "initialize",
|
|
3
|
+
update = "update",
|
|
4
|
+
render = "render",
|
|
5
|
+
sync = "sync"
|
|
6
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SystemPipelineType = void 0;
|
|
4
|
-
var SystemPipelineType;
|
|
5
|
-
(function (SystemPipelineType) {
|
|
6
|
-
SystemPipelineType["initialize"] = "initialize";
|
|
7
|
-
SystemPipelineType["update"] = "update";
|
|
8
|
-
SystemPipelineType["render"] = "render";
|
|
9
|
-
SystemPipelineType["sync"] = "sync";
|
|
10
|
-
})(SystemPipelineType = exports.SystemPipelineType || (exports.SystemPipelineType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SystemPipelineType = void 0;
|
|
4
|
+
var SystemPipelineType;
|
|
5
|
+
(function (SystemPipelineType) {
|
|
6
|
+
SystemPipelineType["initialize"] = "initialize";
|
|
7
|
+
SystemPipelineType["update"] = "update";
|
|
8
|
+
SystemPipelineType["render"] = "render";
|
|
9
|
+
SystemPipelineType["sync"] = "sync";
|
|
10
|
+
})(SystemPipelineType = exports.SystemPipelineType || (exports.SystemPipelineType = {}));
|
|
11
11
|
//# sourceMappingURL=system-pipeline-type.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { IEntity } from "../entities/entity";
|
|
2
|
-
import { IEntityUpdate } from "../entities/entity-queue";
|
|
3
|
-
import { ISystemMiddleware } from "./system-middleware";
|
|
4
|
-
import { SystemPipelineType } from "./system-pipeline-type";
|
|
5
|
-
/**
|
|
6
|
-
* The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
|
|
7
|
-
* It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
|
|
8
|
-
*/
|
|
9
|
-
export interface ISystemsModule {
|
|
10
|
-
/**
|
|
11
|
-
* The method allows triggering all registered SystemPipelines, to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
12
|
-
* @param update The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
13
|
-
*/
|
|
14
|
-
triggerSystems(update: IEntityUpdate): void | Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* @param type The SystemPipelineType to append the provided SystemMiddlewares to.
|
|
17
|
-
* @param systems The SystemMiddlewares will be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
18
|
-
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
19
|
-
*/
|
|
20
|
-
registerSystems(type: SystemPipelineType, systems: ISystemMiddleware<IEntity>[]): void;
|
|
21
|
-
}
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { IEntityUpdate } from "../entities/entity-queue";
|
|
3
|
+
import { ISystemMiddleware } from "./system-middleware";
|
|
4
|
+
import { SystemPipelineType } from "./system-pipeline-type";
|
|
5
|
+
/**
|
|
6
|
+
* The SystemModule is the main way of registering and triggering the SystemMiddlewares registered for an Entity.
|
|
7
|
+
* It can handle EntityUpdate objects and decides which SystemPipelines to trigger based on the information in the EntityUpdate.
|
|
8
|
+
*/
|
|
9
|
+
export interface ISystemsModule {
|
|
10
|
+
/**
|
|
11
|
+
* The method allows triggering all registered SystemPipelines, to apply the changes from the provided EntityUpdate to an Entity instance.
|
|
12
|
+
* @param update The EntityUpdate containing the desired changes to be applied on an Entity instance.
|
|
13
|
+
*/
|
|
14
|
+
triggerSystems(update: IEntityUpdate): void | Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* @param type The SystemPipelineType to append the provided SystemMiddlewares to.
|
|
17
|
+
* @param systems The SystemMiddlewares will be registered in the provided SystemPipelineType in the same order as the provided array.
|
|
18
|
+
* The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
|
|
19
|
+
*/
|
|
20
|
+
registerSystems(type: SystemPipelineType, systems: ISystemMiddleware<IEntity>[]): void;
|
|
21
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=systems-module.js.map
|