@awesome-ecs/abstract 0.20.1 → 0.20.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.
Files changed (47) hide show
  1. package/dist/components/index.cjs.map +1 -1
  2. package/dist/components/index.d.cts +2 -2
  3. package/dist/components/index.d.ts +2 -2
  4. package/dist/components/index.js.map +1 -1
  5. package/dist/entities/index.cjs.map +1 -1
  6. package/dist/entities/index.d.cts +21 -4
  7. package/dist/entities/index.d.ts +21 -4
  8. package/dist/entities/index.js.map +1 -1
  9. package/dist/entity-repository-BlSpo-x2.d.ts +253 -0
  10. package/dist/entity-repository-DJ1xbvaN.d.cts +253 -0
  11. package/dist/factories/index.d.cts +40 -10
  12. package/dist/factories/index.d.ts +40 -10
  13. package/dist/index-B1KXekZD.d.ts +199 -0
  14. package/dist/index-CnlpX7ys.d.cts +199 -0
  15. package/dist/performance-timer-BVyl0SRs.d.cts +45 -0
  16. package/dist/performance-timer-BVyl0SRs.d.ts +45 -0
  17. package/dist/pipeline-BGsQiSer.d.ts +161 -0
  18. package/dist/pipeline-DunwPUPZ.d.cts +161 -0
  19. package/dist/pipelines/index.cjs.map +1 -1
  20. package/dist/pipelines/index.d.cts +23 -11
  21. package/dist/pipelines/index.d.ts +23 -11
  22. package/dist/pipelines/index.js.map +1 -1
  23. package/dist/systems/index.cjs.map +1 -1
  24. package/dist/systems/index.d.cts +58 -19
  25. package/dist/systems/index.d.ts +58 -19
  26. package/dist/systems/index.js.map +1 -1
  27. package/dist/systems-runtime-context-BTNdV8Z-.d.ts +330 -0
  28. package/dist/systems-runtime-context-DhtHMczN.d.cts +330 -0
  29. package/dist/types-cZ-1lGPD.d.cts +77 -0
  30. package/dist/types-cZ-1lGPD.d.ts +77 -0
  31. package/dist/utils/index.cjs.map +1 -1
  32. package/dist/utils/index.d.cts +63 -3
  33. package/dist/utils/index.d.ts +63 -3
  34. package/dist/utils/index.js.map +1 -1
  35. package/package.json +2 -2
  36. package/dist/entity-repository-BASmOrq7.d.ts +0 -120
  37. package/dist/entity-repository-DmfcUSrX.d.cts +0 -120
  38. package/dist/index-BPDsRt_F.d.ts +0 -117
  39. package/dist/index-DK2CXVZ8.d.cts +0 -117
  40. package/dist/performance-timer-XvdCbcAE.d.cts +0 -13
  41. package/dist/performance-timer-XvdCbcAE.d.ts +0 -13
  42. package/dist/pipeline-BowCAITe.d.cts +0 -83
  43. package/dist/pipeline-D43CXxWG.d.ts +0 -83
  44. package/dist/systems-runtime-context-CDVzeB9f.d.ts +0 -162
  45. package/dist/systems-runtime-context-CpgxOdc8.d.cts +0 -162
  46. package/dist/types-BNwBqRWY.d.cts +0 -22
  47. package/dist/types-BNwBqRWY.d.ts +0 -22
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logger.ts"],"sourcesContent":["/**\n * An ILogger instance allows printing messages to console or other targets.\n */\nexport interface ILogger {\n log(level: LogLevel, message: any, ...args: any[]): void;\n\n trace(message: any, ...args: any[]): void;\n debug(message: any, ...args: any[]): void;\n warn(message: any, ...args: any[]): void;\n error(message: any, ...args: any[]): void;\n}\n\nexport enum LogLevel {\n trace,\n debug,\n warn,\n error,\n}\n\nexport interface ILoggerOptions {\n enabled: Map<LogLevel, boolean>;\n}\n"],"mappings":";AAYO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,oBAAA;AACA,EAAAA,oBAAA;AACA,EAAAA,oBAAA;AACA,EAAAA,oBAAA;AAJU,SAAAA;AAAA,GAAA;","names":["LogLevel"]}
1
+ {"version":3,"sources":["../../src/utils/logger.ts"],"sourcesContent":["/**\n * An ILogger instance allows printing messages to console or other targets.\n */\nexport interface ILogger {\n /**\n * Logs a message with a specified level.\n * @param level The level of the message.\n * @param message The message to be logged.\n * @param ...args Additional arguments to be included in the message.\n */\n log(level: LogLevel, message: any, ...args: any[]): void;\n\n /**\n * Logs a trace-level message.\n * @param message The message to be logged.\n * @param ...args Additional arguments to be included in the message.\n */\n trace(message: any, ...args: any[]): void;\n\n /**\n * Logs a debug-level message.\n * @param message The message to be logged.\n * @param ...args Additional arguments to be included in the message.\n */\n debug(message: any, ...args: any[]): void;\n\n /**\n * Logs a warning-level message.\n * @param message The message to be logged.\n * @param ...args Additional arguments to be included in the message.\n */\n warn(message: any, ...args: any[]): void;\n\n /**\n * Logs an error-level message.\n * @param message The message to be logged.\n * @param ...args Additional arguments to be included in the message.\n */\n error(message: any, ...args: any[]): void;\n}\n\n/**\n * An enumeration of log levels.\n */\nexport enum LogLevel {\n /**\n * Trace-level logging.\n */\n trace,\n\n /**\n * Debug-level logging.\n */\n debug,\n\n /**\n * Warning-level logging.\n */\n warn,\n\n /**\n * Error-level logging.\n */\n error\n}\n\n/**\n * Options for configuring an ILogger instance.\n */\nexport interface ILoggerOptions {\n /**\n * A map of log levels to their corresponding enabled status.\n */\n enabled: Map<LogLevel, boolean>;\n}\n"],"mappings":";AA4CO,IAAK,WAAL,kBAAKA,cAAL;AAIL,EAAAA,oBAAA;AAKA,EAAAA,oBAAA;AAKA,EAAAA,oBAAA;AAKA,EAAAA,oBAAA;AAnBU,SAAAA;AAAA,GAAA;","names":["LogLevel"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesome-ecs/abstract",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -97,5 +97,5 @@
97
97
  "url": "https://github.com/privatebytes/awesome-ecs/issues"
98
98
  },
99
99
  "homepage": "https://github.com/privatebytes/awesome-ecs#readme",
100
- "gitHead": "1e449163cdde8d3740783b3c052bafb0d577b796"
100
+ "gitHead": "6849938d4b396cddfa1e7f80211ef06b9ac6c511"
101
101
  }
@@ -1,120 +0,0 @@
1
- import { I as IEntityProxy, f as IdentityComponent, b as IEntityModel, g as IComponent, c as IEntity, E as EntityTypeUid } from './index-BPDsRt_F.js';
2
-
3
- type EntityEventUid = string | number;
4
- type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
5
- /**
6
- * The `IEventData` contains the event-specific state. At the very least, it contains the `Event Unique Identifier`.
7
- */
8
- interface IEventData {
9
- uid: EntityEventUid;
10
- }
11
- /**
12
- * The `IEntityEvent` represents the basic building block for a Pub/Sub pattern, to synchronize state between multiple Entities.
13
- *
14
- * The Events are scheduled as part of the `EntityUpdate` model. Systems subscribe and receive updates with the Events included in their `SystemContext`.
15
- */
16
- interface IEntityEvent<TEventData extends IEventData> {
17
- origin: IEntityProxy;
18
- target?: IEntityProxy;
19
- data: TEventData;
20
- }
21
- /**
22
- * The `IEntityEventsManager` represents the Pub/Sub broker for `IEntityEvent` instances.
23
- * It keeps track of Entity Subscriptions (as part of the Observer design-pattern).
24
- */
25
- interface IEntityEventsManager {
26
- subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
27
- unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
28
- getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
29
- getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[];
30
- /**
31
- * Removes all Subscriptions for all Entities.
32
- */
33
- clearSubscriptions(): void;
34
- /**
35
- * Removes all Subscriptions for the given Event.
36
- * @param uid The Event UID to remove all Subscribers from.
37
- */
38
- clearSubscriptionsForEvent(uid: EntityEventUid): void;
39
- /**
40
- * Removes all Event Subscriptions for the given Entity.
41
- * @param entity The Entity to remove all of it's Event Subscriptions.
42
- */
43
- clearSubscriptionsForEntity(entity: IEntityProxy): void;
44
- }
45
- /**
46
- * The `IEntityEventsDispatcher` is the main access point for dispatching events to Entities.
47
- *
48
- * It can leverage the `IEntityEventsManager` to find Subscribers, and the `IEntityUpdateQueue` to register events
49
- * into each Observer Entity's next update.
50
- */
51
- interface IEntityEventsDispatcher {
52
- dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
53
- dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
54
- }
55
-
56
- /**
57
- * The `IEntitySnapshot` contains the full or partial serializable state of an Entity.
58
- *
59
- * It can be used to capture Entity state changes (deltas) or update existing Entity with changes coming from a remote source (e.g. server or other peers).
60
- */
61
- interface IEntitySnapshot {
62
- readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
63
- readonly components?: IComponent[];
64
- readonly proxies?: IEntityProxy[];
65
- readonly events?: IEntityEvent<IEventData>[];
66
- }
67
- /**
68
- * The `IEntitySnapshotProvider` is the main provider for both creating snapshots for an Entity,
69
- * as well as updating Entity state based off an `IEntitySnapshot`.
70
- */
71
- interface IEntitySnapshotProvider {
72
- applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
73
- createSnapshot(entity: IEntity): IEntitySnapshot;
74
- }
75
-
76
- /**
77
- * The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
78
- */
79
- declare enum EntityUpdateType {
80
- update = "update",
81
- remove = "remove"
82
- }
83
- /**
84
- * The `IEntityUpdate` represents an Entity update that should be applied over an (existing) Entity.
85
- */
86
- interface IEntityUpdate {
87
- type: EntityUpdateType;
88
- entity: IEntityProxy;
89
- model?: IEntityModel;
90
- snapshot?: IEntitySnapshot;
91
- }
92
- /**
93
- * The `IEntityUpdateQueue` is the main mechanism to queue and retrieve `EntityUpdate` instances.
94
- *
95
- * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
96
- */
97
- interface IEntityUpdateQueue {
98
- readonly size: number;
99
- enqueue(change: IEntityUpdate): void;
100
- dequeue(): IEntityUpdate;
101
- peek(): IEntityUpdate;
102
- clear(): void;
103
- }
104
-
105
- /**
106
- * The `IEntityRepository` is the central storage for keeping track of existing Entities.
107
- * It provides basic CRUD functionality.
108
- */
109
- interface IEntityRepository {
110
- readonly size: number;
111
- has(proxy: IEntityProxy): boolean;
112
- get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
113
- getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
114
- listAll(): IEntity[];
115
- set(entity: IEntity): void;
116
- delete(proxy: IEntityProxy): void;
117
- clear(entityType: EntityTypeUid): void;
118
- }
119
-
120
- export { type EntityEventUid as E, type IEventData as I, type EntityEventSubscriptionFilter as a, type IEntityEvent as b, type IEntityEventsManager as c, type IEntityEventsDispatcher as d, EntityUpdateType as e, type IEntityUpdate as f, type IEntityUpdateQueue as g, type IEntityRepository as h, type IEntitySnapshot as i, type IEntitySnapshotProvider as j };
@@ -1,120 +0,0 @@
1
- import { I as IEntityProxy, f as IdentityComponent, b as IEntityModel, g as IComponent, c as IEntity, E as EntityTypeUid } from './index-DK2CXVZ8.cjs';
2
-
3
- type EntityEventUid = string | number;
4
- type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
5
- /**
6
- * The `IEventData` contains the event-specific state. At the very least, it contains the `Event Unique Identifier`.
7
- */
8
- interface IEventData {
9
- uid: EntityEventUid;
10
- }
11
- /**
12
- * The `IEntityEvent` represents the basic building block for a Pub/Sub pattern, to synchronize state between multiple Entities.
13
- *
14
- * The Events are scheduled as part of the `EntityUpdate` model. Systems subscribe and receive updates with the Events included in their `SystemContext`.
15
- */
16
- interface IEntityEvent<TEventData extends IEventData> {
17
- origin: IEntityProxy;
18
- target?: IEntityProxy;
19
- data: TEventData;
20
- }
21
- /**
22
- * The `IEntityEventsManager` represents the Pub/Sub broker for `IEntityEvent` instances.
23
- * It keeps track of Entity Subscriptions (as part of the Observer design-pattern).
24
- */
25
- interface IEntityEventsManager {
26
- subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
27
- unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
28
- getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
29
- getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[];
30
- /**
31
- * Removes all Subscriptions for all Entities.
32
- */
33
- clearSubscriptions(): void;
34
- /**
35
- * Removes all Subscriptions for the given Event.
36
- * @param uid The Event UID to remove all Subscribers from.
37
- */
38
- clearSubscriptionsForEvent(uid: EntityEventUid): void;
39
- /**
40
- * Removes all Event Subscriptions for the given Entity.
41
- * @param entity The Entity to remove all of it's Event Subscriptions.
42
- */
43
- clearSubscriptionsForEntity(entity: IEntityProxy): void;
44
- }
45
- /**
46
- * The `IEntityEventsDispatcher` is the main access point for dispatching events to Entities.
47
- *
48
- * It can leverage the `IEntityEventsManager` to find Subscribers, and the `IEntityUpdateQueue` to register events
49
- * into each Observer Entity's next update.
50
- */
51
- interface IEntityEventsDispatcher {
52
- dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
53
- dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
54
- }
55
-
56
- /**
57
- * The `IEntitySnapshot` contains the full or partial serializable state of an Entity.
58
- *
59
- * It can be used to capture Entity state changes (deltas) or update existing Entity with changes coming from a remote source (e.g. server or other peers).
60
- */
61
- interface IEntitySnapshot {
62
- readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
63
- readonly components?: IComponent[];
64
- readonly proxies?: IEntityProxy[];
65
- readonly events?: IEntityEvent<IEventData>[];
66
- }
67
- /**
68
- * The `IEntitySnapshotProvider` is the main provider for both creating snapshots for an Entity,
69
- * as well as updating Entity state based off an `IEntitySnapshot`.
70
- */
71
- interface IEntitySnapshotProvider {
72
- applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
73
- createSnapshot(entity: IEntity): IEntitySnapshot;
74
- }
75
-
76
- /**
77
- * The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
78
- */
79
- declare enum EntityUpdateType {
80
- update = "update",
81
- remove = "remove"
82
- }
83
- /**
84
- * The `IEntityUpdate` represents an Entity update that should be applied over an (existing) Entity.
85
- */
86
- interface IEntityUpdate {
87
- type: EntityUpdateType;
88
- entity: IEntityProxy;
89
- model?: IEntityModel;
90
- snapshot?: IEntitySnapshot;
91
- }
92
- /**
93
- * The `IEntityUpdateQueue` is the main mechanism to queue and retrieve `EntityUpdate` instances.
94
- *
95
- * The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
96
- */
97
- interface IEntityUpdateQueue {
98
- readonly size: number;
99
- enqueue(change: IEntityUpdate): void;
100
- dequeue(): IEntityUpdate;
101
- peek(): IEntityUpdate;
102
- clear(): void;
103
- }
104
-
105
- /**
106
- * The `IEntityRepository` is the central storage for keeping track of existing Entities.
107
- * It provides basic CRUD functionality.
108
- */
109
- interface IEntityRepository {
110
- readonly size: number;
111
- has(proxy: IEntityProxy): boolean;
112
- get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
113
- getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
114
- listAll(): IEntity[];
115
- set(entity: IEntity): void;
116
- delete(proxy: IEntityProxy): void;
117
- clear(entityType: EntityTypeUid): void;
118
- }
119
-
120
- export { type EntityEventUid as E, type IEventData as I, type EntityEventSubscriptionFilter as a, type IEntityEvent as b, type IEntityEventsManager as c, type IEntityEventsDispatcher as d, EntityUpdateType as e, type IEntityUpdate as f, type IEntityUpdateQueue as g, type IEntityRepository as h, type IEntitySnapshot as i, type IEntitySnapshotProvider as j };
@@ -1,117 +0,0 @@
1
- import { B as BooleanProps, I as Immutable } from './types-BNwBqRWY.js';
2
-
3
- type ComponentTypeUid = string | number;
4
- /**
5
- * The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
6
- *
7
- * The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
8
- */
9
- interface IComponent {
10
- /**
11
- * The `ComponentTypeUid` is an Unique Identifier for each Component type.
12
- */
13
- readonly componentType: ComponentTypeUid;
14
- /**
15
- * Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
16
- * Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
17
- */
18
- readonly isSerializable: boolean;
19
- /**
20
- * @optional
21
- * Specifies the current version of the component.
22
- * Useful for keeping backwards-compatibility when the stored state might be of a different version.
23
- */
24
- readonly version?: number;
25
- /**
26
- * @optional
27
- * The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
28
- * If not provided, the standard `JSON.stringify()` functionality applies.
29
- */
30
- toJSON?(): string | object;
31
- /**
32
- * Allows for custom logic when loading the current from an `IEntitySnapshot`.
33
- * The default behavior simply overwrites the fields with the target state.
34
- */
35
- load?(targetState: this): void;
36
- }
37
-
38
- /**
39
- * The `IEntityProxy` represents a pointer to another `Entity`.
40
- */
41
- interface IEntityProxy {
42
- readonly entityType: EntityTypeUid;
43
- readonly entityUid: EntityUid;
44
- }
45
- /**
46
- * A utility extension of `IEntityProxy`.
47
- * Useful for providing strong `Type` information when using the IEntityProxy.
48
- */
49
- interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
50
- }
51
- /**
52
- * The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
53
- *
54
- * It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
55
- */
56
- interface IEntityProxiesManager {
57
- registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
58
- registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
59
- removeProxy(entity: IEntity, proxy: IEntityProxy): void;
60
- removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
61
- }
62
-
63
- type EntityTypeUid = string | number;
64
- type EntityUid = string | number;
65
- /**
66
- * The `IEntityModel` represents the basic identity information about the current `IEntity`.
67
- * It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
68
- *
69
- * The Features property can be used to toggle Entity features on and off.
70
- */
71
- interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
72
- readonly uid: EntityUid;
73
- readonly features?: TFeatures;
74
- }
75
- /**
76
- * The `IEntity` is basically a container of Components and Entity Proxies.
77
- * Only Systems can manipulate the internal state of the Entity, by altering its Components' data.
78
- *
79
- * The implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies` but should not contain any logic
80
- * apart from quick-access functionality.
81
- */
82
- interface IEntity {
83
- readonly components: Map<ComponentTypeUid, IComponent>;
84
- readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
85
- /**
86
- * The IdentityComponent represents mandatory state any Entity needs to have.
87
- */
88
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
89
- /**
90
- * Own Proxy reference, points to this Entity. Useful for quick access of Proxy data.
91
- */
92
- readonly myProxy: Readonly<IEntityProxy>;
93
- }
94
-
95
- declare enum BasicComponentType {
96
- identity = "identity"
97
- }
98
- /**
99
- * The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
100
- */
101
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
102
- /**
103
- * The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
104
- */
105
- readonly entityType: EntityTypeUid;
106
- /**
107
- * The Model is the basic information needed to create an `IEntity` when it's first initialized.
108
- * It provides a first snapshot of information needed for the successful creation of an Entity instance.
109
- */
110
- readonly model: Immutable<TModel>;
111
- /**
112
- * Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
113
- */
114
- readonly lastUpdated?: Date;
115
- }
116
-
117
- export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
@@ -1,117 +0,0 @@
1
- import { B as BooleanProps, I as Immutable } from './types-BNwBqRWY.cjs';
2
-
3
- type ComponentTypeUid = string | number;
4
- /**
5
- * The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
6
- *
7
- * The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
8
- */
9
- interface IComponent {
10
- /**
11
- * The `ComponentTypeUid` is an Unique Identifier for each Component type.
12
- */
13
- readonly componentType: ComponentTypeUid;
14
- /**
15
- * Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
16
- * Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
17
- */
18
- readonly isSerializable: boolean;
19
- /**
20
- * @optional
21
- * Specifies the current version of the component.
22
- * Useful for keeping backwards-compatibility when the stored state might be of a different version.
23
- */
24
- readonly version?: number;
25
- /**
26
- * @optional
27
- * The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
28
- * If not provided, the standard `JSON.stringify()` functionality applies.
29
- */
30
- toJSON?(): string | object;
31
- /**
32
- * Allows for custom logic when loading the current from an `IEntitySnapshot`.
33
- * The default behavior simply overwrites the fields with the target state.
34
- */
35
- load?(targetState: this): void;
36
- }
37
-
38
- /**
39
- * The `IEntityProxy` represents a pointer to another `Entity`.
40
- */
41
- interface IEntityProxy {
42
- readonly entityType: EntityTypeUid;
43
- readonly entityUid: EntityUid;
44
- }
45
- /**
46
- * A utility extension of `IEntityProxy`.
47
- * Useful for providing strong `Type` information when using the IEntityProxy.
48
- */
49
- interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
50
- }
51
- /**
52
- * The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
53
- *
54
- * It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
55
- */
56
- interface IEntityProxiesManager {
57
- registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
58
- registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
59
- removeProxy(entity: IEntity, proxy: IEntityProxy): void;
60
- removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
61
- }
62
-
63
- type EntityTypeUid = string | number;
64
- type EntityUid = string | number;
65
- /**
66
- * The `IEntityModel` represents the basic identity information about the current `IEntity`.
67
- * It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
68
- *
69
- * The Features property can be used to toggle Entity features on and off.
70
- */
71
- interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
72
- readonly uid: EntityUid;
73
- readonly features?: TFeatures;
74
- }
75
- /**
76
- * The `IEntity` is basically a container of Components and Entity Proxies.
77
- * Only Systems can manipulate the internal state of the Entity, by altering its Components' data.
78
- *
79
- * The implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies` but should not contain any logic
80
- * apart from quick-access functionality.
81
- */
82
- interface IEntity {
83
- readonly components: Map<ComponentTypeUid, IComponent>;
84
- readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
85
- /**
86
- * The IdentityComponent represents mandatory state any Entity needs to have.
87
- */
88
- readonly identity: Readonly<IdentityComponent<IEntityModel>>;
89
- /**
90
- * Own Proxy reference, points to this Entity. Useful for quick access of Proxy data.
91
- */
92
- readonly myProxy: Readonly<IEntityProxy>;
93
- }
94
-
95
- declare enum BasicComponentType {
96
- identity = "identity"
97
- }
98
- /**
99
- * The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
100
- */
101
- interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
102
- /**
103
- * The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
104
- */
105
- readonly entityType: EntityTypeUid;
106
- /**
107
- * The Model is the basic information needed to create an `IEntity` when it's first initialized.
108
- * It provides a first snapshot of information needed for the successful creation of an Entity instance.
109
- */
110
- readonly model: Immutable<TModel>;
111
- /**
112
- * Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
113
- */
114
- readonly lastUpdated?: Date;
115
- }
116
-
117
- export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
@@ -1,13 +0,0 @@
1
- type PerformanceTimerUid = number;
2
- interface PerformanceTimeEntry {
3
- name: string;
4
- startedAt: number;
5
- endedAt?: number;
6
- msPassed?: number;
7
- }
8
- interface IPerformanceTimer {
9
- startTimer(name: string): PerformanceTimerUid;
10
- endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
11
- }
12
-
13
- export type { IPerformanceTimer as I, PerformanceTimeEntry as P, PerformanceTimerUid as a };
@@ -1,13 +0,0 @@
1
- type PerformanceTimerUid = number;
2
- interface PerformanceTimeEntry {
3
- name: string;
4
- startedAt: number;
5
- endedAt?: number;
6
- msPassed?: number;
7
- }
8
- interface IPerformanceTimer {
9
- startTimer(name: string): PerformanceTimerUid;
10
- endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
11
- }
12
-
13
- export type { IPerformanceTimer as I, PerformanceTimeEntry as P, PerformanceTimerUid as a };
@@ -1,83 +0,0 @@
1
- import { P as PerformanceTimeEntry } from './performance-timer-XvdCbcAE.cjs';
2
-
3
- /**
4
- * The PipelineResult can provide Performance metrics collected from self or inner middleware & pipeline calls.
5
- */
6
- type PipelineResult = {
7
- readonly performance?: PerformanceTimeEntry;
8
- readonly inner?: PipelineResult[];
9
- };
10
-
11
- /**
12
- * The MiddlewareResult can provide Pipeline Results inner pipeline calls.
13
- */
14
- type MiddlewareResult = void | PipelineResult;
15
-
16
- /**
17
- * The PipelineStatus tracks the current status of the pipeline.
18
- */
19
- declare enum PipelineStatus {
20
- idle = "idle",
21
- ongoing = "ongoing",
22
- completed = "completed",
23
- halted = "halted"
24
- }
25
-
26
- /**
27
- * The Pipeline Context allows exposing state to the Pipeline's middlewares.
28
- */
29
- interface IPipelineContext {
30
- readonly runtime: PipelineRuntime;
31
- }
32
- /**
33
- * The Pipeline Runtime exposes runtime status controls for Middlewares, as part of tbe PipelineContext.
34
- */
35
- type PipelineRuntime = {
36
- shouldStop: boolean;
37
- status?: PipelineStatus;
38
- };
39
-
40
- /**
41
- * A middleware, the building block of a Pipeline. The middlewares will provide a unit-of-work implementation
42
- * dealing with potential state changes over the input Context, or running cleanup logic over the input Context.
43
- */
44
- interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareResult> {
45
- readonly name?: string;
46
- /**
47
- * This (optional) function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
48
- * being met so this middleware's action should run.
49
- * @param context The Context to determine whether the run condition is satisfied.
50
- */
51
- shouldRun?(context: TContext): boolean;
52
- /**
53
- * The function gets called as part of the pipeline, based on the registration order.
54
- * @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
55
- */
56
- action(context: TContext): TResult;
57
- /**
58
- * This (optional) function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
59
- * @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
60
- */
61
- cleanup?(context: TContext): TResult;
62
- }
63
-
64
- /**
65
- * An {@link IMiddleware} container and dispatcher.
66
- */
67
- interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResult> {
68
- readonly name?: string;
69
- /**
70
- * Register middleware for this pipeline.
71
- */
72
- use(middleware: IMiddleware<TContext, TResult>): this;
73
- /**
74
- * Execute the Dispatch on the chain of middleware, with the given Context.
75
- */
76
- dispatch(context: TContext): PipelineResult;
77
- /**
78
- * Execute the Cleanup on the chain of middleware, with the given Context.
79
- */
80
- cleanup(context: TContext): PipelineResult;
81
- }
82
-
83
- export { type IPipelineContext as I, type MiddlewareResult as M, type PipelineResult as P, type IPipeline as a, type IMiddleware as b, type PipelineRuntime as c, PipelineStatus as d };