@awesome-ecs/abstract 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -228
- package/dist/components/index.cjs +3 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -2
- package/dist/components/index.d.mts +2 -0
- package/dist/components/{index.js → index.mjs} +4 -4
- package/dist/components/index.mjs.map +1 -0
- package/dist/entities/index.cjs +12 -5
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +3 -4
- package/dist/entities/index.d.mts +3 -0
- package/dist/entities/index.mjs +20 -0
- package/dist/entities/index.mjs.map +1 -0
- package/dist/factories/index.d.cts +47 -35
- package/dist/factories/index.d.mts +69 -0
- package/dist/factories/index.mjs +1 -0
- package/dist/identity-component-5neFUd2Q.d.cts +241 -0
- package/dist/identity-component-BCmEilvk.d.mts +241 -0
- package/dist/index-6OSsa_UD.d.cts +309 -0
- package/dist/index-BUadwkVZ.d.cts +224 -0
- package/dist/index-BWmhFdFg.d.mts +148 -0
- package/dist/index-BtPTY71-.d.cts +485 -0
- package/dist/index-CQpE-5sx.d.mts +309 -0
- package/dist/index-CW6-OhB4.d.mts +485 -0
- package/dist/index-DcirKLCP.d.mts +224 -0
- package/dist/index-eECJUE_O.d.cts +148 -0
- package/dist/pipelines/index.cjs +0 -31
- package/dist/pipelines/index.d.cts +2 -4
- package/dist/pipelines/index.d.mts +2 -0
- package/dist/pipelines/index.mjs +1 -0
- package/dist/systems/index.cjs +18 -18
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -7
- package/dist/systems/index.d.mts +2 -0
- package/dist/systems/index.mjs +33 -0
- package/dist/systems/index.mjs.map +1 -0
- package/dist/types-CnDtpKsY.d.mts +70 -0
- package/dist/types-DLOd2zXO.d.cts +70 -0
- package/dist/utils/index.cjs +11 -11
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.mts +3 -0
- package/dist/utils/index.mjs +27 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +14 -14
- package/dist/components/index.d.ts +0 -3
- package/dist/components/index.js.map +0 -1
- package/dist/entities/index.d.ts +0 -4
- package/dist/entities/index.js +0 -13
- package/dist/entities/index.js.map +0 -1
- package/dist/factories/index.d.ts +0 -57
- package/dist/factories/index.js +0 -0
- package/dist/identity-component-BDWEtAXA.d.cts +0 -238
- package/dist/identity-component-CR1ULadR.d.ts +0 -238
- package/dist/index-C3UGZqUG.d.ts +0 -288
- package/dist/index-CKh4A7mH.d.cts +0 -460
- package/dist/index-ChV4Q5j6.d.cts +0 -137
- package/dist/index-Cm-YSPhK.d.ts +0 -254
- package/dist/index-D81Fo9XN.d.cts +0 -254
- package/dist/index-DLm-DKAk.d.cts +0 -288
- package/dist/index-oenqxDCa.d.ts +0 -137
- package/dist/index-zpj0YApu.d.ts +0 -460
- package/dist/pipelines/index.cjs.map +0 -1
- package/dist/pipelines/index.d.ts +0 -4
- package/dist/pipelines/index.js +0 -30
- package/dist/pipelines/index.js.map +0 -1
- package/dist/systems/index.d.ts +0 -7
- package/dist/systems/index.js +0 -33
- package/dist/systems/index.js.map +0 -1
- package/dist/types-DvzdpbLu.d.cts +0 -69
- package/dist/types-yh4pOGEm.d.ts +0 -69
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -27
- package/dist/utils/index.js.map +0 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { a as IEntity, l as IEntityProxy, m as IComponent, n as IdentityComponent, o as IEntityModel, r as EntityTypeUid } from "./identity-component-BCmEilvk.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/entity-events.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Represents a unique identifier for an entity event.
|
|
6
|
+
* Can be either a string or a number.
|
|
7
|
+
*/
|
|
8
|
+
type EntityEventUid = string | number;
|
|
9
|
+
/**
|
|
10
|
+
* A filter function for entity event subscriptions.
|
|
11
|
+
* Returns true if the event should be processed, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The `IEventData` interface represents the data associated with an entity event.
|
|
16
|
+
* It contains at least the `Event Unique Identifier`.
|
|
17
|
+
*/
|
|
18
|
+
interface IEventData {
|
|
19
|
+
uid: EntityEventUid;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents a publishable event in the entity system.
|
|
23
|
+
* Enables loosely-coupled communication between entities through an Observer pattern.
|
|
24
|
+
* Events include origin, optional target, and typed data payload.
|
|
25
|
+
*
|
|
26
|
+
* @template TEventData - The type of data carried by this event.
|
|
27
|
+
*/
|
|
28
|
+
interface IEntityEvent<TEventData extends IEventData> {
|
|
29
|
+
/**
|
|
30
|
+
* The entity that originated this event.
|
|
31
|
+
*/
|
|
32
|
+
origin: IEntityProxy;
|
|
33
|
+
/**
|
|
34
|
+
* Optional target entity for this event.
|
|
35
|
+
* If omitted, the event is broadcast to all subscribers.
|
|
36
|
+
*/
|
|
37
|
+
target?: IEntityProxy;
|
|
38
|
+
/**
|
|
39
|
+
* The event payload containing type-specific data.
|
|
40
|
+
*/
|
|
41
|
+
data: TEventData;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Manages subscriptions and dispatching for entity events.
|
|
45
|
+
* Implements the Observer pattern to decouple event producers from consumers.
|
|
46
|
+
* Tracks which entities are interested in which event types and maintains subscription state.
|
|
47
|
+
*/
|
|
48
|
+
interface IEntityEventsManager {
|
|
49
|
+
/**
|
|
50
|
+
* Subscribes an entity to a specific event type.
|
|
51
|
+
* The entity will be notified when events of that type are dispatched.
|
|
52
|
+
* @param uid - The event type to subscribe to.
|
|
53
|
+
* @param entity - The entity registering for this event type.
|
|
54
|
+
* @param filter - Optional function to determine which specific events are processed.
|
|
55
|
+
*/
|
|
56
|
+
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
57
|
+
/**
|
|
58
|
+
* Unsubscribes an entity from a specific event type.
|
|
59
|
+
* The entity will no longer receive notifications for this event type.
|
|
60
|
+
* @param uid - The event type to unsubscribe from.
|
|
61
|
+
* @param entity - The entity unregistering from this event type.
|
|
62
|
+
*/
|
|
63
|
+
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all entities subscribed to a specific event.
|
|
66
|
+
* @param event - The event to get subscriptions for.
|
|
67
|
+
* @returns Array of entities subscribed to this event.
|
|
68
|
+
*/
|
|
69
|
+
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves all event types an entity is subscribed to.
|
|
72
|
+
* @param entity - The entity to query.
|
|
73
|
+
* @returns Array of event type identifiers this entity is listening to.
|
|
74
|
+
*/
|
|
75
|
+
getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[];
|
|
76
|
+
/**
|
|
77
|
+
* Removes all subscriptions system-wide.
|
|
78
|
+
*/
|
|
79
|
+
clearSubscriptions(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Removes all subscriptions for a specific event type.
|
|
82
|
+
* @param uid - The event type to remove subscriptions from.
|
|
83
|
+
*/
|
|
84
|
+
clearSubscriptionsForEvent(uid: EntityEventUid): void;
|
|
85
|
+
/**
|
|
86
|
+
* Removes all subscriptions for a specific entity.
|
|
87
|
+
* @param entity - The entity to remove all subscriptions for.
|
|
88
|
+
*/
|
|
89
|
+
clearSubscriptionsForEntity(entity: IEntityProxy): void;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Event dispatcher for publishing events to interested entities.
|
|
93
|
+
* Responsible for routing events to their subscribers through the update queue.
|
|
94
|
+
*/
|
|
95
|
+
interface IEntityEventsDispatcher {
|
|
96
|
+
/**
|
|
97
|
+
* Publishes a single event to subscribers.
|
|
98
|
+
* The event is routed based on subscriptions or explicit target(s).
|
|
99
|
+
* @param event - The event to dispatch.
|
|
100
|
+
* @param targets - Optional specific entities to send to. If provided, event is only sent to these targets.
|
|
101
|
+
*/
|
|
102
|
+
dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
|
|
103
|
+
/**
|
|
104
|
+
* Publishes multiple events to subscribers.
|
|
105
|
+
* Efficiently dispatches an array of events in bulk.
|
|
106
|
+
* @param events - The events to dispatch.
|
|
107
|
+
* @param targets - Optional specific entities to send to. If provided, events are only sent to these targets.
|
|
108
|
+
*/
|
|
109
|
+
dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/entities/entity-snapshot.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* A serializable representation of entity state.
|
|
115
|
+
* Captures full or partial entity state including components, relationships, and events.
|
|
116
|
+
* Snapshots enable state replication, persistence, and delta updates from external sources.
|
|
117
|
+
*/
|
|
118
|
+
interface IEntitySnapshot {
|
|
119
|
+
/**
|
|
120
|
+
* The entity's identity information if included in the snapshot.
|
|
121
|
+
*/
|
|
122
|
+
readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
|
|
123
|
+
/**
|
|
124
|
+
* Entity components to be included in the snapshot.
|
|
125
|
+
* Only components marked as serializable are typically included.
|
|
126
|
+
*/
|
|
127
|
+
readonly components?: IComponent[];
|
|
128
|
+
/**
|
|
129
|
+
* Entity relationships (proxies) to include in the snapshot.
|
|
130
|
+
*/
|
|
131
|
+
readonly proxies?: IEntityProxy[];
|
|
132
|
+
/**
|
|
133
|
+
* Events associated with the entity to include in the snapshot.
|
|
134
|
+
*/
|
|
135
|
+
readonly events?: IEntityEvent<IEventData>[];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Handles snapshot creation and application.
|
|
139
|
+
* Provides abstraction for converting between entities and their serializable snapshots.
|
|
140
|
+
* Used for state persistence, synchronization, and entity updates from external sources.
|
|
141
|
+
*/
|
|
142
|
+
interface IEntitySnapshotProvider {
|
|
143
|
+
/**
|
|
144
|
+
* Applies a snapshot state to an entity.
|
|
145
|
+
* Updates the entity's components, relationships, and events based on the snapshot.
|
|
146
|
+
* @param entity - The entity to update.
|
|
147
|
+
* @param snapshot - The state to apply.
|
|
148
|
+
*/
|
|
149
|
+
applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
|
|
150
|
+
/**
|
|
151
|
+
* Creates a snapshot capturing the current state of an entity.
|
|
152
|
+
* Serializes all or specified parts of the entity for storage or transmission.
|
|
153
|
+
* @param entity - The entity to snapshot.
|
|
154
|
+
* @returns A serializable representation of the entity state.
|
|
155
|
+
*/
|
|
156
|
+
createSnapshot(entity: IEntity): IEntitySnapshot;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/entities/entity-queue.d.ts
|
|
160
|
+
/**
|
|
161
|
+
* Specifies the action to be performed on an entity.
|
|
162
|
+
* Updates are categorized to enable different processing paths in the runtime.
|
|
163
|
+
*/
|
|
164
|
+
declare enum EntityUpdateType {
|
|
165
|
+
/**
|
|
166
|
+
* Indicates the entity should be updated with new data.
|
|
167
|
+
*/
|
|
168
|
+
update = "update",
|
|
169
|
+
/**
|
|
170
|
+
* Indicates the entity should be removed from the system.
|
|
171
|
+
*/
|
|
172
|
+
remove = "remove"
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Represents a queued entity state change or removal.
|
|
176
|
+
* Updates flow through the system to be processed by entity update handlers.
|
|
177
|
+
*/
|
|
178
|
+
interface IEntityUpdate {
|
|
179
|
+
/**
|
|
180
|
+
* The type of operation: update or remove.
|
|
181
|
+
*/
|
|
182
|
+
readonly type: EntityUpdateType;
|
|
183
|
+
/**
|
|
184
|
+
* The entity being affected by this update.
|
|
185
|
+
*/
|
|
186
|
+
readonly entity: IEntityProxy;
|
|
187
|
+
/**
|
|
188
|
+
* Optional model data for initialization or reconfiguration.
|
|
189
|
+
*/
|
|
190
|
+
readonly model?: IEntityModel;
|
|
191
|
+
/**
|
|
192
|
+
* Optional serialized state to apply to the entity.
|
|
193
|
+
*/
|
|
194
|
+
readonly snapshot?: IEntitySnapshot;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Queue interface for managing pending entity updates.
|
|
198
|
+
* Different implementations may use different prioritization strategies (e.g., priority queues, FIFO, ordered by entity type).
|
|
199
|
+
* Updates are consumed by the runtime and dispatched to appropriate entity systems.
|
|
200
|
+
*/
|
|
201
|
+
interface IEntityUpdateQueue {
|
|
202
|
+
/**
|
|
203
|
+
* The current number of updates in the queue.
|
|
204
|
+
*/
|
|
205
|
+
readonly size: number;
|
|
206
|
+
/**
|
|
207
|
+
* Adds an update to the queue for processing.
|
|
208
|
+
* @param change - The update to queue.
|
|
209
|
+
*/
|
|
210
|
+
enqueue(change: IEntityUpdate): void;
|
|
211
|
+
/**
|
|
212
|
+
* Removes and returns the next update from the queue.
|
|
213
|
+
* The specific update returned depends on the queue's prioritization strategy.
|
|
214
|
+
* @returns The next queued update.
|
|
215
|
+
*/
|
|
216
|
+
dequeue(): IEntityUpdate;
|
|
217
|
+
/**
|
|
218
|
+
* Views the next update without removing it.
|
|
219
|
+
* Useful for inspection before dequeuing.
|
|
220
|
+
* @returns The next update in the queue.
|
|
221
|
+
*/
|
|
222
|
+
peek(): IEntityUpdate;
|
|
223
|
+
/**
|
|
224
|
+
* Removes all updates from the queue.
|
|
225
|
+
*/
|
|
226
|
+
clear(): void;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/entities/entity-repository.d.ts
|
|
230
|
+
/**
|
|
231
|
+
* Central storage for all active entities in the system.
|
|
232
|
+
* The repository provides CRUD operations and is the source of truth for entity existence and state.
|
|
233
|
+
* All entity access and modifications go through this repository.
|
|
234
|
+
*/
|
|
235
|
+
interface IEntityRepository {
|
|
236
|
+
/**
|
|
237
|
+
* The total number of entities currently stored.
|
|
238
|
+
*/
|
|
239
|
+
readonly size: number;
|
|
240
|
+
/**
|
|
241
|
+
* Checks if an entity exists in storage.
|
|
242
|
+
* @param proxy - Reference to the entity to check.
|
|
243
|
+
* @returns True if the entity exists, false otherwise.
|
|
244
|
+
*/
|
|
245
|
+
has(proxy: IEntityProxy): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Retrieves an entity from storage by proxy.
|
|
248
|
+
* @template TEntity - The expected entity type.
|
|
249
|
+
* @param proxy - Reference to the entity to retrieve.
|
|
250
|
+
* @returns The requested entity.
|
|
251
|
+
*/
|
|
252
|
+
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
253
|
+
/**
|
|
254
|
+
* Retrieves all entities of a specific type.
|
|
255
|
+
* @template TEntity - The entity type to retrieve.
|
|
256
|
+
* @param entityType - The type identifier to filter by.
|
|
257
|
+
* @returns Array of all entities matching the type.
|
|
258
|
+
*/
|
|
259
|
+
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
260
|
+
/**
|
|
261
|
+
* Iterates over all entities regardless of type.
|
|
262
|
+
* @returns An iterator over all stored entities.
|
|
263
|
+
*/
|
|
264
|
+
listAll(): IterableIterator<IEntity>;
|
|
265
|
+
/**
|
|
266
|
+
* Stores or updates an entity.
|
|
267
|
+
* @param entity - The entity to store.
|
|
268
|
+
*/
|
|
269
|
+
set(entity: IEntity): void;
|
|
270
|
+
/**
|
|
271
|
+
* Removes an entity from storage.
|
|
272
|
+
* @param proxy - Reference to the entity to remove.
|
|
273
|
+
*/
|
|
274
|
+
delete(proxy: IEntityProxy): void;
|
|
275
|
+
/**
|
|
276
|
+
* Removes all entities of a specific type from storage.
|
|
277
|
+
* @param entityType - The type identifier for entities to remove.
|
|
278
|
+
*/
|
|
279
|
+
clear(entityType: EntityTypeUid): void;
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/entities/entity-scheduler.d.ts
|
|
283
|
+
/**
|
|
284
|
+
* Manages time-based scheduling of entity updates.
|
|
285
|
+
* Entities are registered with intervals and receive updates at the specified cadence, or on the next frame (engine-dependent).
|
|
286
|
+
*/
|
|
287
|
+
interface IEntityScheduler {
|
|
288
|
+
/**
|
|
289
|
+
* Registers an entity for periodic updates.
|
|
290
|
+
* @param entityProxy - The entity to schedule.
|
|
291
|
+
* @param intervalMs - Update frequency in milliseconds. If omitted, a default interval is used.
|
|
292
|
+
*/
|
|
293
|
+
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
294
|
+
/**
|
|
295
|
+
* Unregisters an entity from the scheduler.
|
|
296
|
+
* The entity will no longer receive periodic updates.
|
|
297
|
+
* @param entityProxy - The entity to unschedule.
|
|
298
|
+
*/
|
|
299
|
+
remove(entityProxy: IEntityProxy): void;
|
|
300
|
+
/**
|
|
301
|
+
* Checks if an entity is currently scheduled for updates.
|
|
302
|
+
* @param entityProxy - The entity to check.
|
|
303
|
+
* @returns True if the entity is scheduled, false otherwise.
|
|
304
|
+
*/
|
|
305
|
+
has(entityProxy: IEntityProxy): boolean;
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
export { IEntityUpdateQueue as a, EntityEventSubscriptionFilter as c, IEntityEventsDispatcher as d, IEntityEventsManager as f, IEntityUpdate as i, EntityEventUid as l, IEntityRepository as n, IEntitySnapshot as o, IEventData as p, EntityUpdateType as r, IEntitySnapshotProvider as s, IEntityScheduler as t, IEntityEvent as u };
|
|
309
|
+
//# sourceMappingURL=index-CQpE-5sx.d.mts.map
|