@awesome-ecs/abstract 0.20.2 → 0.21.1
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/components/index.cjs +10 -32
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -2
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +11 -8
- package/dist/components/index.js.map +1 -1
- package/dist/entities/index.cjs +11 -33
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +4 -34
- package/dist/entities/index.d.ts +4 -34
- package/dist/entities/index.js +12 -9
- package/dist/entities/index.js.map +1 -1
- package/dist/factories/index.cjs +0 -18
- package/dist/factories/index.d.cts +44 -44
- package/dist/factories/index.d.ts +44 -44
- package/dist/factories/index.js +0 -1
- package/dist/identity-component-BDWEtAXA.d.cts +238 -0
- package/dist/identity-component-CR1ULadR.d.ts +238 -0
- package/dist/index-C3UGZqUG.d.ts +288 -0
- package/dist/index-CKh4A7mH.d.cts +460 -0
- package/dist/index-ChV4Q5j6.d.cts +137 -0
- package/dist/index-Cm-YSPhK.d.ts +254 -0
- package/dist/index-D81Fo9XN.d.cts +254 -0
- package/dist/index-DLm-DKAk.d.cts +288 -0
- package/dist/index-oenqxDCa.d.ts +137 -0
- package/dist/index-zpj0YApu.d.ts +460 -0
- package/dist/pipelines/index.cjs +28 -35
- package/dist/pipelines/index.cjs.map +1 -1
- package/dist/pipelines/index.d.cts +4 -56
- package/dist/pipelines/index.d.ts +4 -56
- package/dist/pipelines/index.js +29 -11
- package/dist/pipelines/index.js.map +1 -1
- package/dist/systems/index.cjs +31 -35
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +7 -101
- package/dist/systems/index.d.ts +7 -101
- package/dist/systems/index.js +32 -11
- package/dist/systems/index.js.map +1 -1
- package/dist/{types-cZ-1lGPD.d.ts → types-DvzdpbLu.d.cts} +9 -17
- package/dist/{types-cZ-1lGPD.d.cts → types-yh4pOGEm.d.ts} +9 -17
- package/dist/utils/index.cjs +25 -35
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -92
- package/dist/utils/index.d.ts +3 -92
- package/dist/utils/index.js +26 -11
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/entity-repository-BlSpo-x2.d.ts +0 -253
- package/dist/entity-repository-DJ1xbvaN.d.cts +0 -253
- package/dist/factories/index.cjs.map +0 -1
- package/dist/factories/index.js.map +0 -1
- package/dist/index-B1KXekZD.d.ts +0 -199
- package/dist/index-CnlpX7ys.d.cts +0 -199
- package/dist/performance-timer-BVyl0SRs.d.cts +0 -45
- package/dist/performance-timer-BVyl0SRs.d.ts +0 -45
- package/dist/pipeline-BGsQiSer.d.ts +0 -161
- package/dist/pipeline-DunwPUPZ.d.cts +0 -161
- package/dist/systems-runtime-context-BTNdV8Z-.d.ts +0 -330
- package/dist/systems-runtime-context-DhtHMczN.d.cts +0 -330
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,35 +1,13 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
1
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
//#region src/components/identity-component.ts
|
|
3
|
+
/**
|
|
4
|
+
* The `BasicComponentType` enum defines the types of basic components available.
|
|
5
|
+
*/
|
|
6
|
+
let BasicComponentType = /* @__PURE__ */ function(BasicComponentType$1) {
|
|
7
|
+
BasicComponentType$1["identity"] = "identity";
|
|
8
|
+
return BasicComponentType$1;
|
|
9
|
+
}({});
|
|
25
10
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
BasicComponentType2["identity"] = "identity";
|
|
29
|
-
return BasicComponentType2;
|
|
30
|
-
})(BasicComponentType || {});
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
BasicComponentType
|
|
34
|
-
});
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.BasicComponentType = BasicComponentType;
|
|
35
13
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\nimport { Immutable } from '../utils/types';\nimport { IComponent } from './component';\n\n/**\n * The `BasicComponentType` enum defines the types of basic components available.\n */\nexport enum BasicComponentType {\n identity = 'identity'\n}\n\n/**\n * IdentityComponent interface represents the basic information regarding what makes the current Entity unique.\n * It extends the IComponent interface.\n *\n * @template TModel - The type of the model that extends IEntityModel.\n */\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\n /**\n * The Entity Type that defines what Category type the Entity is part of.\n * There can be multiple Entities sharing the same EntityType.\n */\n readonly entityType: EntityTypeUid;\n\n /**\n * The Model is the basic information needed to create an `IEntity` when it's first initialized.\n * It provides a first snapshot of information needed for the successful creation of an Entity instance.\n *\n * @type {Immutable<TModel>}\n */\n readonly model: Immutable<TModel>;\n\n /**\n * Keeps track when the Entity's systems have ran last.\n * Useful to calculate the `DeltaTime` between runs.\n *\n * @type {Date | undefined}\n */\n readonly lastUpdated?: Date;\n}\n"],"mappings":";;;;;AAOA,IAAY,oEAAL;AACL;;AACD"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent } from "../identity-component-BDWEtAXA.cjs";
|
|
2
|
+
import "../types-DvzdpbLu.cjs";
|
|
3
|
+
export { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent } from "../identity-component-CR1ULadR.js";
|
|
2
|
+
import "../types-yh4pOGEm.js";
|
|
3
|
+
export { BasicComponentType, ComponentTypeUid, IComponent, IdentityComponent };
|
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
1
|
+
//#region src/components/identity-component.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `BasicComponentType` enum defines the types of basic components available.
|
|
4
|
+
*/
|
|
5
|
+
let BasicComponentType = /* @__PURE__ */ function(BasicComponentType$1) {
|
|
6
|
+
BasicComponentType$1["identity"] = "identity";
|
|
7
|
+
return BasicComponentType$1;
|
|
8
|
+
}({});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { BasicComponentType };
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\nimport { Immutable } from '../utils/types';\nimport { IComponent } from './component';\n\n/**\n * The `BasicComponentType` enum defines the types of basic components available.\n */\nexport enum BasicComponentType {\n identity = 'identity'\n}\n\n/**\n * IdentityComponent interface represents the basic information regarding what makes the current Entity unique.\n * It extends the IComponent interface.\n *\n * @template TModel - The type of the model that extends IEntityModel.\n */\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\n /**\n * The Entity Type that defines what Category type the Entity is part of.\n * There can be multiple Entities sharing the same EntityType.\n */\n readonly entityType: EntityTypeUid;\n\n /**\n * The Model is the basic information needed to create an `IEntity` when it's first initialized.\n * It provides a first snapshot of information needed for the successful creation of an Entity instance.\n *\n * @type {Immutable<TModel>}\n */\n readonly model: Immutable<TModel>;\n\n /**\n * Keeps track when the Entity's systems have ran last.\n * Useful to calculate the `DeltaTime` between runs.\n *\n * @type {Date | undefined}\n */\n readonly lastUpdated?: Date;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/components/identity-component.ts"],"sourcesContent":["import { EntityTypeUid, IEntityModel } from '../entities/entity';\nimport { Immutable } from '../utils/types';\nimport { IComponent } from './component';\n\n/**\n * The `BasicComponentType` enum defines the types of basic components available.\n */\nexport enum BasicComponentType {\n identity = 'identity'\n}\n\n/**\n * IdentityComponent interface represents the basic information regarding what makes the current Entity unique.\n * It extends the IComponent interface.\n *\n * @template TModel - The type of the model that extends IEntityModel.\n */\nexport interface IdentityComponent<TModel extends IEntityModel> extends IComponent {\n /**\n * The Entity Type that defines what Category type the Entity is part of.\n * There can be multiple Entities sharing the same EntityType.\n */\n readonly entityType: EntityTypeUid;\n\n /**\n * The Model is the basic information needed to create an `IEntity` when it's first initialized.\n * It provides a first snapshot of information needed for the successful creation of an Entity instance.\n *\n * @type {Immutable<TModel>}\n */\n readonly model: Immutable<TModel>;\n\n /**\n * Keeps track when the Entity's systems have ran last.\n * Useful to calculate the `DeltaTime` between runs.\n *\n * @type {Date | undefined}\n */\n readonly lastUpdated?: Date;\n}\n"],"mappings":";;;;AAOA,IAAY,oEAAL;AACL;;AACD"}
|
package/dist/entities/index.cjs
CHANGED
|
@@ -1,36 +1,14 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
1
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
//#region src/entities/entity-queue.ts
|
|
3
|
+
/**
|
|
4
|
+
* The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.
|
|
5
|
+
*/
|
|
6
|
+
let EntityUpdateType = /* @__PURE__ */ function(EntityUpdateType$1) {
|
|
7
|
+
EntityUpdateType$1["update"] = "update";
|
|
8
|
+
EntityUpdateType$1["remove"] = "remove";
|
|
9
|
+
return EntityUpdateType$1;
|
|
10
|
+
}({});
|
|
25
11
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
EntityUpdateType2["update"] = "update";
|
|
29
|
-
EntityUpdateType2["remove"] = "remove";
|
|
30
|
-
return EntityUpdateType2;
|
|
31
|
-
})(EntityUpdateType || {});
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
EntityUpdateType
|
|
35
|
-
});
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.EntityUpdateType = EntityUpdateType;
|
|
36
14
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\nimport { IEntityProxy } from './entity-proxies';\nimport { IEntitySnapshot } from './entity-snapshot';\n\n/**\n * The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.\n */\nexport enum EntityUpdateType {\n update = 'update',\n remove = 'remove'\n}\n\n/**\n * The `IEntityUpdate` interface represents an Entity update that should be applied over an existing Entity.\n */\nexport interface IEntityUpdate {\n /**\n * The type of the update, which can be either `update` or `remove`.\n */\n type: EntityUpdateType;\n\n /**\n * The proxy of the Entity that needs to be updated.\n */\n entity: IEntityProxy;\n\n /**\n * Optional. The model of the Entity that needs to be updated.\n */\n model?: IEntityModel;\n\n /**\n * Optional. The snapshot of the Entity that needs to be updated.\n */\n snapshot?: IEntitySnapshot;\n}\n\n/**\n * The `IEntityUpdateQueue` interface is the main mechanism to queue and retrieve `EntityUpdate` instances.\n *\n * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.\n */\nexport interface IEntityUpdateQueue {\n /**\n * The number of `EntityUpdate` instances currently in the queue.\n */\n readonly size: number;\n\n /**\n * Adds an `EntityUpdate` instance to the end of the queue.\n * @param change - The `EntityUpdate` instance to be added.\n */\n enqueue(change: IEntityUpdate): void;\n\n /**\n * Removes and returns the `EntityUpdate` instance at the front of the queue.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n dequeue(): IEntityUpdate;\n\n /**\n * Returns the `EntityUpdate` instance at the front of the queue without removing it.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n peek(): IEntityUpdate;\n\n /**\n * Removes all `EntityUpdate` instances from the queue.\n */\n clear(): void;\n}\n"],"mappings":";;;;;AAOA,IAAY,gEAAL;AACL;AACA;;AACD"}
|
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `IEntityScheduler` is the main way of queuing `IEntityUpdate` instances on an Interval (based on time or a custom implementation).
|
|
8
|
-
*
|
|
9
|
-
* It usually reads the Entities from the `IEntityRepository`, and uses the `IEntityUpdateQueue` to enqueue Entity updates.
|
|
10
|
-
*/
|
|
11
|
-
interface IEntityScheduler {
|
|
12
|
-
/**
|
|
13
|
-
* Schedules an entity for updates at a specified interval.
|
|
14
|
-
*
|
|
15
|
-
* @param entityProxy - The entity to schedule for updates.
|
|
16
|
-
* @param intervalMs - The interval at which to schedule updates, in milliseconds. If not provided, the default interval will be used.
|
|
17
|
-
*/
|
|
18
|
-
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
19
|
-
/**
|
|
20
|
-
* Removes an entity from the scheduler.
|
|
21
|
-
*
|
|
22
|
-
* @param entityProxy - The entity to remove from the scheduler.
|
|
23
|
-
*/
|
|
24
|
-
remove(entityProxy: IEntityProxy): void;
|
|
25
|
-
/**
|
|
26
|
-
* Checks if an entity is currently scheduled for updates.
|
|
27
|
-
*
|
|
28
|
-
* @param entityProxy - The entity to check.
|
|
29
|
-
* @returns `true` if the entity is scheduled, `false` otherwise.
|
|
30
|
-
*/
|
|
31
|
-
has(entityProxy: IEntityProxy): boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { IEntityProxy, type IEntityScheduler };
|
|
1
|
+
import { EntityProxy, EntityTypeUid, EntityUid, IEntity, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, RequiredProxies, TypedEntityProxy } from "../identity-component-BDWEtAXA.cjs";
|
|
2
|
+
import "../types-DvzdpbLu.cjs";
|
|
3
|
+
import { EntityEventSubscriptionFilter, EntityEventUid, EntityUpdateType, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData } from "../index-DLm-DKAk.cjs";
|
|
4
|
+
export { EntityEventSubscriptionFilter, EntityEventUid, EntityProxy, EntityTypeUid, EntityUid, EntityUpdateType, IEntity, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData, RequiredProxies, TypedEntityProxy };
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,34 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `IEntityScheduler` is the main way of queuing `IEntityUpdate` instances on an Interval (based on time or a custom implementation).
|
|
8
|
-
*
|
|
9
|
-
* It usually reads the Entities from the `IEntityRepository`, and uses the `IEntityUpdateQueue` to enqueue Entity updates.
|
|
10
|
-
*/
|
|
11
|
-
interface IEntityScheduler {
|
|
12
|
-
/**
|
|
13
|
-
* Schedules an entity for updates at a specified interval.
|
|
14
|
-
*
|
|
15
|
-
* @param entityProxy - The entity to schedule for updates.
|
|
16
|
-
* @param intervalMs - The interval at which to schedule updates, in milliseconds. If not provided, the default interval will be used.
|
|
17
|
-
*/
|
|
18
|
-
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
19
|
-
/**
|
|
20
|
-
* Removes an entity from the scheduler.
|
|
21
|
-
*
|
|
22
|
-
* @param entityProxy - The entity to remove from the scheduler.
|
|
23
|
-
*/
|
|
24
|
-
remove(entityProxy: IEntityProxy): void;
|
|
25
|
-
/**
|
|
26
|
-
* Checks if an entity is currently scheduled for updates.
|
|
27
|
-
*
|
|
28
|
-
* @param entityProxy - The entity to check.
|
|
29
|
-
* @returns `true` if the entity is scheduled, `false` otherwise.
|
|
30
|
-
*/
|
|
31
|
-
has(entityProxy: IEntityProxy): boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { IEntityProxy, type IEntityScheduler };
|
|
1
|
+
import { EntityProxy, EntityTypeUid, EntityUid, IEntity, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, RequiredProxies, TypedEntityProxy } from "../identity-component-CR1ULadR.js";
|
|
2
|
+
import "../types-yh4pOGEm.js";
|
|
3
|
+
import { EntityEventSubscriptionFilter, EntityEventUid, EntityUpdateType, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData } from "../index-C3UGZqUG.js";
|
|
4
|
+
export { EntityEventSubscriptionFilter, EntityEventUid, EntityProxy, EntityTypeUid, EntityUid, EntityUpdateType, IEntity, IEntityEvent, IEntityEventsDispatcher, IEntityEventsManager, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, IEntityRepository, IEntityScheduler, IEntitySnapshot, IEntitySnapshotProvider, IEntityUpdate, IEntityUpdateQueue, IEventData, RequiredProxies, TypedEntityProxy };
|
package/dist/entities/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
1
|
+
//#region src/entities/entity-queue.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.
|
|
4
|
+
*/
|
|
5
|
+
let EntityUpdateType = /* @__PURE__ */ function(EntityUpdateType$1) {
|
|
6
|
+
EntityUpdateType$1["update"] = "update";
|
|
7
|
+
EntityUpdateType$1["remove"] = "remove";
|
|
8
|
+
return EntityUpdateType$1;
|
|
9
|
+
}({});
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { EntityUpdateType };
|
|
10
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\nimport { IEntityProxy } from './entity-proxies';\nimport { IEntitySnapshot } from './entity-snapshot';\n\n/**\n * The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.\n */\nexport enum EntityUpdateType {\n update = 'update',\n remove = 'remove'\n}\n\n/**\n * The `IEntityUpdate` interface represents an Entity update that should be applied over an existing Entity.\n */\nexport interface IEntityUpdate {\n /**\n * The type of the update, which can be either `update` or `remove`.\n */\n type: EntityUpdateType;\n\n /**\n * The proxy of the Entity that needs to be updated.\n */\n entity: IEntityProxy;\n\n /**\n * Optional. The model of the Entity that needs to be updated.\n */\n model?: IEntityModel;\n\n /**\n * Optional. The snapshot of the Entity that needs to be updated.\n */\n snapshot?: IEntitySnapshot;\n}\n\n/**\n * The `IEntityUpdateQueue` interface is the main mechanism to queue and retrieve `EntityUpdate` instances.\n *\n * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.\n */\nexport interface IEntityUpdateQueue {\n /**\n * The number of `EntityUpdate` instances currently in the queue.\n */\n readonly size: number;\n\n /**\n * Adds an `EntityUpdate` instance to the end of the queue.\n * @param change - The `EntityUpdate` instance to be added.\n */\n enqueue(change: IEntityUpdate): void;\n\n /**\n * Removes and returns the `EntityUpdate` instance at the front of the queue.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n dequeue(): IEntityUpdate;\n\n /**\n * Returns the `EntityUpdate` instance at the front of the queue without removing it.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n peek(): IEntityUpdate;\n\n /**\n * Removes all `EntityUpdate` instances from the queue.\n */\n clear(): void;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/entities/entity-queue.ts"],"sourcesContent":["import { IEntityModel } from './entity';\nimport { IEntityProxy } from './entity-proxies';\nimport { IEntitySnapshot } from './entity-snapshot';\n\n/**\n * The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.\n */\nexport enum EntityUpdateType {\n update = 'update',\n remove = 'remove'\n}\n\n/**\n * The `IEntityUpdate` interface represents an Entity update that should be applied over an existing Entity.\n */\nexport interface IEntityUpdate {\n /**\n * The type of the update, which can be either `update` or `remove`.\n */\n type: EntityUpdateType;\n\n /**\n * The proxy of the Entity that needs to be updated.\n */\n entity: IEntityProxy;\n\n /**\n * Optional. The model of the Entity that needs to be updated.\n */\n model?: IEntityModel;\n\n /**\n * Optional. The snapshot of the Entity that needs to be updated.\n */\n snapshot?: IEntitySnapshot;\n}\n\n/**\n * The `IEntityUpdateQueue` interface is the main mechanism to queue and retrieve `EntityUpdate` instances.\n *\n * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.\n */\nexport interface IEntityUpdateQueue {\n /**\n * The number of `EntityUpdate` instances currently in the queue.\n */\n readonly size: number;\n\n /**\n * Adds an `EntityUpdate` instance to the end of the queue.\n * @param change - The `EntityUpdate` instance to be added.\n */\n enqueue(change: IEntityUpdate): void;\n\n /**\n * Removes and returns the `EntityUpdate` instance at the front of the queue.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n dequeue(): IEntityUpdate;\n\n /**\n * Returns the `EntityUpdate` instance at the front of the queue without removing it.\n * @returns The `EntityUpdate` instance at the front of the queue.\n */\n peek(): IEntityUpdate;\n\n /**\n * Removes all `EntityUpdate` instances from the queue.\n */\n clear(): void;\n}\n"],"mappings":";;;;AAOA,IAAY,gEAAL;AACL;AACA;;AACD"}
|
package/dist/factories/index.cjs
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
|
|
15
|
-
// src/factories/index.ts
|
|
16
|
-
var factories_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(factories_exports);
|
|
18
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import '../performance-timer-BVyl0SRs.cjs';
|
|
1
|
+
import { IEntity } from "../identity-component-BDWEtAXA.cjs";
|
|
2
|
+
import "../types-DvzdpbLu.cjs";
|
|
3
|
+
import "../index-DLm-DKAk.cjs";
|
|
4
|
+
import { IPipeline, IPipelineContext } from "../index-D81Fo9XN.cjs";
|
|
5
|
+
import "../index-ChV4Q5j6.cjs";
|
|
6
|
+
import { ISystemContext, ISystemsRuntimeContext } from "../index-CKh4A7mH.cjs";
|
|
8
7
|
|
|
8
|
+
//#region src/factories/context-factory.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* The IContextFactory interface is used to create abstraction layers for quickly creating Pipeline Contexts.
|
|
11
11
|
* It helps to avoid manually resolving all dependencies when creating these contexts.
|
|
12
12
|
*/
|
|
13
13
|
interface IContextFactory {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of ISystemsRuntimeContext.
|
|
16
|
+
*
|
|
17
|
+
* @template TEntity - The type of entity to be used in the runtime context. It must extend IEntity.
|
|
18
|
+
* @returns A new instance of ISystemsRuntimeContext with the specified entity type.
|
|
19
|
+
*/
|
|
20
|
+
createRuntimeContext<TEntity extends IEntity>(): ISystemsRuntimeContext<TEntity>;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/factories/pipeline-factory.d.ts
|
|
23
24
|
/**
|
|
24
25
|
* The PipelineFactory interface provides methods to create different types of pipelines.
|
|
25
26
|
* It helps to quickly create IPipeline objects without manually resolving their dependencies.
|
|
26
27
|
*/
|
|
27
28
|
interface IPipelineFactory {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*/
|
|
54
|
-
createRuntimePipeline<TEntity extends IEntity, TResult = MiddlewareResult>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>, TResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new pipeline with the specified context and result type.
|
|
31
|
+
*
|
|
32
|
+
* @template TContext - The type of the pipeline context. It must extend IPipelineContext.
|
|
33
|
+
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
34
|
+
* @returns A new instance of IPipeline with the specified context and result type.
|
|
35
|
+
*/
|
|
36
|
+
createPipeline<TContext extends IPipelineContext>(name?: string): IPipeline<TContext>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new pipeline specifically for systems with the specified entity type and result type.
|
|
39
|
+
*
|
|
40
|
+
* @template TEntity - The type of the entity. It must extend IEntity.
|
|
41
|
+
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
42
|
+
* @returns A new instance of IPipeline with the specified system context and result type.
|
|
43
|
+
*/
|
|
44
|
+
createSystemsPipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemContext<TEntity>>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new pipeline specifically for systems runtime with the specified entity type and result type.
|
|
47
|
+
*
|
|
48
|
+
* @template TEntity - The type of the entity. It must extend IEntity.
|
|
49
|
+
* @template TResult - The type of the result returned by the pipeline. Default is MiddlewareResult.
|
|
50
|
+
* @param name - Optional name for the pipeline. If not provided, a default name will be assigned.
|
|
51
|
+
* @returns A new instance of IPipeline with the specified systems runtime context and result type.
|
|
52
|
+
*/
|
|
53
|
+
createRuntimePipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>>;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
export
|
|
55
|
+
//#endregion
|
|
56
|
+
export { IContextFactory, IPipelineFactory };
|
|
57
|
+
//# sourceMappingURL=index.d.cts.map
|