@awesome-ecs/abstract 0.29.0 → 0.30.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/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.mts +1 -1
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +3 -3
- package/dist/entities/index.d.mts +3 -3
- package/dist/entities/index.mjs.map +1 -1
- package/dist/factories/index.d.cts +2 -95
- package/dist/factories/index.d.mts +2 -95
- package/dist/{identity-component-B3VGtdQW.d.mts → identity-component-CuWHf7jX.d.mts} +76 -10
- package/dist/{identity-component-CsU-wYTX.d.cts → identity-component-DLDaOTyK.d.cts} +76 -10
- package/dist/index-8XDo0pla.d.mts +1065 -0
- package/dist/index-BVkmidEx.d.cts +1065 -0
- package/dist/{index-DTHsTJ1j.d.cts → index-BguFn1Xj.d.cts} +62 -3
- package/dist/{index-CBxqWVDf.d.mts → index-kNcUiDBd.d.mts} +62 -3
- package/dist/pipelines/index.d.cts +1 -1
- package/dist/pipelines/index.d.mts +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.mts +2 -2
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.mts +3 -3
- package/package.json +2 -2
- package/dist/index-BC8RgFVd.d.mts +0 -544
- package/dist/index-BRkKPsOV.d.cts +0 -224
- package/dist/index-C8yZ7-zP.d.mts +0 -224
- package/dist/index-DCx0PjvH.d.cts +0 -175
- package/dist/index-Df4VhCPr.d.cts +0 -544
- package/dist/index-EpAQRAeF.d.mts +0 -175
- package/dist/types-DqWnkvhp.d.cts +0 -70
- package/dist/types-aD9p7TDy.d.mts +0 -70
|
@@ -0,0 +1,1065 @@
|
|
|
1
|
+
import { _ as IEntityProxy, f as EntityTypeUid, g as EntityProxy, h as IEntityModel, i as Immutable, m as IEntity, p as EntityUid, v as IEntityProxyRepository } from "./identity-component-CuWHf7jX.mjs";
|
|
2
|
+
import { c as IEntitySnapshot, d as EntityEventSubscriptionOptions, f as EntityEventUid, g as IEventData, o as IEntityUpdate, p as IEntityEvent } from "./index-kNcUiDBd.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/dispatch-sequential.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Executes a function for each item in an iterable, sequentially.
|
|
7
|
+
*
|
|
8
|
+
* Uses a sync fast-path: iterates synchronously until the first Promise is
|
|
9
|
+
* encountered, then switches to async for the remainder. If no item produces
|
|
10
|
+
* a Promise, the entire call stays synchronous with zero async overhead.
|
|
11
|
+
*
|
|
12
|
+
* @param items - The iterable to iterate over.
|
|
13
|
+
* @param fn - The function to call for each item. May return void or a Promise.
|
|
14
|
+
* @returns void if all calls were synchronous, or a Promise if any were async.
|
|
15
|
+
*/
|
|
16
|
+
declare function dispatchSequential<T>(items: Iterable<T>, fn: (item: T) => void | Promise<void>): void | Promise<void>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/utils/json-serializer.d.ts
|
|
19
|
+
/**
|
|
20
|
+
* Custom JSON serialization and deserialization interface.
|
|
21
|
+
* Allows different serialization strategies for handling complex types.
|
|
22
|
+
* Used for entity snapshots, events, and any data needing JSON conversion.
|
|
23
|
+
*/
|
|
24
|
+
interface IJsonSerializer {
|
|
25
|
+
/**
|
|
26
|
+
* Converts an object to a serializable JSON representation.
|
|
27
|
+
* Handles types that don't serialize naturally (dates, maps, custom objects, etc.).
|
|
28
|
+
* @param value - The object to serialize.
|
|
29
|
+
* @returns A JSON-serializable representation.
|
|
30
|
+
*/
|
|
31
|
+
serializeCustom(value: object): string;
|
|
32
|
+
/**
|
|
33
|
+
* Converts a JSON string back to its original object type.
|
|
34
|
+
* Reconstructs complex types from their serialized form.
|
|
35
|
+
* @template TObject - The target object type.
|
|
36
|
+
* @param text - The JSON string to deserialize.
|
|
37
|
+
* @returns The deserialized object of the specified type.
|
|
38
|
+
*/
|
|
39
|
+
parseCustom<TObject>(text: string): TObject;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/utils/logger.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Logger interface for debug and diagnostic output.
|
|
45
|
+
* Supports multiple log levels for controlling verbosity.
|
|
46
|
+
* Implementations can target different outputs (console, file, remote, etc.).
|
|
47
|
+
*/
|
|
48
|
+
interface ILogger {
|
|
49
|
+
/**
|
|
50
|
+
* Logs a message with a specified severity level.
|
|
51
|
+
* @param level - The severity level of the message.
|
|
52
|
+
* @param message - The primary message content.
|
|
53
|
+
* @param args - Additional arguments to include in the log output.
|
|
54
|
+
*/
|
|
55
|
+
log(level: LogLevel, message: any, ...args: any[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Logs detailed diagnostic information.
|
|
58
|
+
* Typically the lowest level, most verbose output.
|
|
59
|
+
* @param message - The message to log.
|
|
60
|
+
* @param args - Additional data.
|
|
61
|
+
*/
|
|
62
|
+
trace(message: any, ...args: any[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Logs debug-level information.
|
|
65
|
+
* Useful during development and troubleshooting.
|
|
66
|
+
* @param message - The message to log.
|
|
67
|
+
* @param args - Additional data.
|
|
68
|
+
*/
|
|
69
|
+
debug(message: any, ...args: any[]): void;
|
|
70
|
+
/**
|
|
71
|
+
* Logs warning-level messages.
|
|
72
|
+
* Indicates potentially problematic conditions.
|
|
73
|
+
* @param message - The message to log.
|
|
74
|
+
* @param args - Additional data.
|
|
75
|
+
*/
|
|
76
|
+
warn(message: any, ...args: any[]): void;
|
|
77
|
+
/**
|
|
78
|
+
* Logs error-level messages.
|
|
79
|
+
* Indicates error conditions that may require attention.
|
|
80
|
+
* @param message - The message to log.
|
|
81
|
+
* @param args - Additional data.
|
|
82
|
+
*/
|
|
83
|
+
error(message: any, ...args: any[]): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Logging severity levels in increasing order.
|
|
87
|
+
*/
|
|
88
|
+
declare enum LogLevel {
|
|
89
|
+
/**
|
|
90
|
+
* Most detailed, diagnostic-level logging.
|
|
91
|
+
*/
|
|
92
|
+
trace = 0,
|
|
93
|
+
/**
|
|
94
|
+
* Development and debugging information.
|
|
95
|
+
*/
|
|
96
|
+
debug = 1,
|
|
97
|
+
/**
|
|
98
|
+
* Warning-level conditions.
|
|
99
|
+
*/
|
|
100
|
+
warn = 2,
|
|
101
|
+
/**
|
|
102
|
+
* Error-level conditions.
|
|
103
|
+
*/
|
|
104
|
+
error = 3
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configuration options for logger instances.
|
|
108
|
+
*/
|
|
109
|
+
interface ILoggerOptions {
|
|
110
|
+
/**
|
|
111
|
+
* Enables/disables each log level.
|
|
112
|
+
* If a level is disabled, log calls at that level are ignored.
|
|
113
|
+
*/
|
|
114
|
+
enabled: Map<LogLevel, boolean>;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/utils/performance.d.ts
|
|
118
|
+
type TickMetricEntry = {
|
|
119
|
+
name: string;
|
|
120
|
+
category: string;
|
|
121
|
+
totalMs: number;
|
|
122
|
+
count: number;
|
|
123
|
+
};
|
|
124
|
+
type TickSnapshot = {
|
|
125
|
+
tickIndex: number;
|
|
126
|
+
tickDurationMs: number;
|
|
127
|
+
fps: number;
|
|
128
|
+
queueSize: number;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
metrics: TickMetricEntry[];
|
|
131
|
+
render?: RenderSnapshot;
|
|
132
|
+
};
|
|
133
|
+
type RenderSnapshot = {
|
|
134
|
+
frameTimeMs: number;
|
|
135
|
+
renderTimeMs: number;
|
|
136
|
+
gpuFrameTimeMs: number;
|
|
137
|
+
drawCalls: number;
|
|
138
|
+
activeMeshesEvalMs: number;
|
|
139
|
+
cameraRenderMs: number;
|
|
140
|
+
totalVertices: number;
|
|
141
|
+
activeIndices: number;
|
|
142
|
+
};
|
|
143
|
+
type MiddlewareMetricsSummary = {
|
|
144
|
+
name: string;
|
|
145
|
+
category: PipelineCategoryName;
|
|
146
|
+
count: number;
|
|
147
|
+
totalMs: number;
|
|
148
|
+
avgMs: number;
|
|
149
|
+
minMs: number;
|
|
150
|
+
maxMs: number;
|
|
151
|
+
lastMs: number;
|
|
152
|
+
};
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/utils/performance-timer.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Unique identifier for a timer instance.
|
|
157
|
+
*/
|
|
158
|
+
type PerformanceTimerUid = number;
|
|
159
|
+
/**
|
|
160
|
+
* Options for identifying and categorizing performance metrics.
|
|
161
|
+
* Used by pipeline factories and performance decorators.
|
|
162
|
+
*/
|
|
163
|
+
type PerformanceMetricOptions = {
|
|
164
|
+
name?: string;
|
|
165
|
+
category?: string;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Record of a completed timer measurement.
|
|
169
|
+
* Captures timing information for performance analysis and profiling.
|
|
170
|
+
*/
|
|
171
|
+
interface PerformanceTimeEntry {
|
|
172
|
+
/**
|
|
173
|
+
* The name identifying this timer.
|
|
174
|
+
*/
|
|
175
|
+
name: string;
|
|
176
|
+
/**
|
|
177
|
+
* The category of this metric (e.g. 'module', 'runtime', 'system').
|
|
178
|
+
*/
|
|
179
|
+
category?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Timestamp in milliseconds when the timer started.
|
|
182
|
+
*/
|
|
183
|
+
startedAt: number;
|
|
184
|
+
/**
|
|
185
|
+
* Timestamp in milliseconds when the timer ended.
|
|
186
|
+
*/
|
|
187
|
+
endedAt?: number;
|
|
188
|
+
/**
|
|
189
|
+
* Duration in milliseconds that elapsed.
|
|
190
|
+
*/
|
|
191
|
+
msPassed?: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Interface for measuring operation duration.
|
|
195
|
+
* Provides start/stop functionality for performance profiling.
|
|
196
|
+
* Used throughout the system to collect timing metrics.
|
|
197
|
+
*/
|
|
198
|
+
interface IPerformanceTimer {
|
|
199
|
+
/**
|
|
200
|
+
* Starts a new timer.
|
|
201
|
+
* @param name - Label for this timer (used in results).
|
|
202
|
+
* @param category - Optional category for grouping metrics.
|
|
203
|
+
* @returns A unique identifier for this timer instance.
|
|
204
|
+
*/
|
|
205
|
+
startTimer(name: string, category?: string): PerformanceTimerUid;
|
|
206
|
+
/**
|
|
207
|
+
* Stops a timer and returns the recorded metrics.
|
|
208
|
+
* @param timerUid - The timer identifier returned by startTimer.
|
|
209
|
+
* @returns Complete timing entry with start, end, and duration.
|
|
210
|
+
*/
|
|
211
|
+
endTimer(timerUid: PerformanceTimerUid): PerformanceTimeEntry;
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/pipelines/pipeline-context.d.ts
|
|
215
|
+
/**
|
|
216
|
+
* Base interface for all pipeline context objects.
|
|
217
|
+
* Provides hooks for runtime state and control flow during pipeline execution.
|
|
218
|
+
*/
|
|
219
|
+
interface IPipelineContext {
|
|
220
|
+
/**
|
|
221
|
+
* The runtime state and control interface for the pipeline.
|
|
222
|
+
* Allows middleware to query and influence pipeline behavior.
|
|
223
|
+
*/
|
|
224
|
+
readonly runtime?: PipelineRuntime;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Runtime state and control interface for pipeline execution.
|
|
228
|
+
* Allows middleware to query status and influence pipeline flow.
|
|
229
|
+
*/
|
|
230
|
+
type PipelineRuntime = {
|
|
231
|
+
/**
|
|
232
|
+
* Flag to request pipeline halt.
|
|
233
|
+
* Set to true to stop executing remaining middleware (cleanup still runs).
|
|
234
|
+
*/
|
|
235
|
+
shouldStop?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Optional error state if an exception occurred during execution.
|
|
238
|
+
*/
|
|
239
|
+
error?: any;
|
|
240
|
+
/**
|
|
241
|
+
* Results collected from middleware execution.
|
|
242
|
+
* Typically includes performance metrics and operational results.
|
|
243
|
+
*/
|
|
244
|
+
readonly metrics?: PerformanceTimeEntry[];
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/pipelines/middleware.d.ts
|
|
248
|
+
/**
|
|
249
|
+
* The basic unit of work in a pipeline.
|
|
250
|
+
* Middleware are chained together to form processing pipelines.
|
|
251
|
+
* Each middleware can inspect/modify context during dispatch and perform cleanup on their changes.
|
|
252
|
+
*
|
|
253
|
+
* @template TContext The context type passed through the middleware chain.
|
|
254
|
+
*/
|
|
255
|
+
interface IMiddleware<TContext extends IPipelineContext> {
|
|
256
|
+
/**
|
|
257
|
+
* Optional name for debugging and logging purposes.
|
|
258
|
+
*/
|
|
259
|
+
readonly name?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Optional guard condition before running the action.
|
|
262
|
+
* Allows middleware to skip execution based on context state.
|
|
263
|
+
* @param context The current pipeline context.
|
|
264
|
+
* @returns True to execute action, false to skip.
|
|
265
|
+
*/
|
|
266
|
+
shouldRun?(context: TContext): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* The main unit of work executed as part of the pipeline.
|
|
269
|
+
* Middlewares execute in registration order during dispatch phase.
|
|
270
|
+
* Can read and modify the context to influence downstream middleware and results.
|
|
271
|
+
* @param context The pipeline context containing all relevant state.
|
|
272
|
+
*/
|
|
273
|
+
action(context: TContext): void | Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Optional cleanup function executed during pipeline teardown.
|
|
276
|
+
* Middlewares execute in reverse registration order during cleanup phase.
|
|
277
|
+
* Used to release resources, clear temporary state, and perform final operations.
|
|
278
|
+
* @param context The pipeline context (may be in modified state from action phases).
|
|
279
|
+
*/
|
|
280
|
+
cleanup?(context: TContext): void | Promise<void>;
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/pipelines/middleware-runner.d.ts
|
|
284
|
+
/**
|
|
285
|
+
* Customizes how middleware is executed within a pipeline.
|
|
286
|
+
* Allows decorators to wrap, intercept, or modify middleware execution behavior.
|
|
287
|
+
* Useful for implementing middleware decorators (logging, timing, error handling, etc.).
|
|
288
|
+
*
|
|
289
|
+
* @template TContext The type of context passed to middleware.
|
|
290
|
+
*/
|
|
291
|
+
interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
292
|
+
/**
|
|
293
|
+
* Decides how to execute a middleware's action.
|
|
294
|
+
* Can add pre/post processing, error handling, or performance tracking around the middleware.
|
|
295
|
+
* @param context The current pipeline context.
|
|
296
|
+
* @param middleware The middleware whose action should be executed.
|
|
297
|
+
*/
|
|
298
|
+
dispatch(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Decides how to execute a middleware's cleanup.
|
|
301
|
+
* Can add pre/post processing or error handling around cleanup operations.
|
|
302
|
+
* @param context The current pipeline context.
|
|
303
|
+
* @param middleware The middleware whose cleanup should be executed.
|
|
304
|
+
*/
|
|
305
|
+
cleanup(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/pipelines/pipeline.d.ts
|
|
309
|
+
/**
|
|
310
|
+
* A composable middleware chain for ordered execution of operations.
|
|
311
|
+
* Pipelines provide a framework for registering and executing middleware with dispatch and cleanup phases.
|
|
312
|
+
* Used throughout the ECS system for entity initialization, updates, rendering, and synchronization.
|
|
313
|
+
*
|
|
314
|
+
* @template TContext - The context type passed to all registered middleware.
|
|
315
|
+
*/
|
|
316
|
+
interface IPipeline<TContext extends IPipelineContext> {
|
|
317
|
+
/**
|
|
318
|
+
* The pipeline's name, useful for debugging and logging.
|
|
319
|
+
*/
|
|
320
|
+
readonly name?: string;
|
|
321
|
+
/**
|
|
322
|
+
* The number of middleware currently registered in this pipeline.
|
|
323
|
+
*/
|
|
324
|
+
readonly length?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Direct access to the ordered list of registered middleware.
|
|
327
|
+
* Allows inspection of the execution chain.
|
|
328
|
+
*/
|
|
329
|
+
readonly middleware?: Immutable<IMiddleware<TContext>[]>;
|
|
330
|
+
/**
|
|
331
|
+
* Registers middleware to be executed as part of this pipeline.
|
|
332
|
+
* Middleware is added to the end of the chain and executed in registration order during dispatch.
|
|
333
|
+
* @param middleware - The middleware to register.
|
|
334
|
+
* @returns This instance for method chaining.
|
|
335
|
+
*/
|
|
336
|
+
use(middleware: Immutable<IMiddleware<TContext>>): this;
|
|
337
|
+
/**
|
|
338
|
+
* Executes the dispatch phase with all registered middleware in order.
|
|
339
|
+
* Each middleware's action is called, allowing modifications to context state.
|
|
340
|
+
* Execution continues until all middleware complete or a middleware requests early termination.
|
|
341
|
+
* @param context - The context object passed to all middleware.
|
|
342
|
+
*/
|
|
343
|
+
dispatch(context: Partial<TContext>): void | Promise<void>;
|
|
344
|
+
/**
|
|
345
|
+
* Executes the cleanup phase with all registered middleware in reverse order.
|
|
346
|
+
* Allows middleware to perform resource cleanup and final operations.
|
|
347
|
+
* Typically called after dispatch to ensure proper teardown.
|
|
348
|
+
*
|
|
349
|
+
* @param context - The context object that will be passed to each middleware function.
|
|
350
|
+
*/
|
|
351
|
+
cleanup(context: Partial<TContext>): void | Promise<void>;
|
|
352
|
+
}
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/pipelines/pipeline-nested.d.ts
|
|
355
|
+
/**
|
|
356
|
+
* Context for a parent pipeline containing nested pipelines.
|
|
357
|
+
* Allows coordination between outer and inner pipeline execution.
|
|
358
|
+
*
|
|
359
|
+
* @template N - The context type for the nested pipelines.
|
|
360
|
+
*/
|
|
361
|
+
interface IParentContext<N extends IPipelineContext> extends IPipelineContext {
|
|
362
|
+
/**
|
|
363
|
+
* The nested pipeline to execute for each context in nestedContexts.
|
|
364
|
+
*/
|
|
365
|
+
readonly nestedPipeline: IPipeline<INestedContext<this>>;
|
|
366
|
+
/**
|
|
367
|
+
* Contexts to pass to the nested pipeline.
|
|
368
|
+
* The parent pipeline iterates these and executes the nested pipeline for each.
|
|
369
|
+
*/
|
|
370
|
+
readonly nestedContexts: Partial<N>[];
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Context for a nested pipeline.
|
|
374
|
+
* Provides access to both current and previous nested context data plus the parent context.
|
|
375
|
+
*
|
|
376
|
+
* @template P - The context type of the parent pipeline.
|
|
377
|
+
*/
|
|
378
|
+
interface INestedContext<P extends IParentContext<any>> extends IPipelineContext {
|
|
379
|
+
/**
|
|
380
|
+
* The current context item being processed in the nested pipeline.
|
|
381
|
+
*/
|
|
382
|
+
readonly current: P extends IParentContext<infer N> ? N : never;
|
|
383
|
+
/**
|
|
384
|
+
* The previous context item (if this is not the first iteration).
|
|
385
|
+
*/
|
|
386
|
+
readonly previous?: P extends IParentContext<infer N> ? N : never;
|
|
387
|
+
/**
|
|
388
|
+
* Reference back to the parent pipeline context.
|
|
389
|
+
*/
|
|
390
|
+
readonly parent: P;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Middleware executing within a nested pipeline.
|
|
394
|
+
*
|
|
395
|
+
* @template P - The context type of the parent pipeline.
|
|
396
|
+
*/
|
|
397
|
+
type INestedMiddleware<P extends IParentContext<any>> = IMiddleware<INestedContext<P>>;
|
|
398
|
+
/**
|
|
399
|
+
* Middleware executing within a parent pipeline (containing nested pipelines).
|
|
400
|
+
*
|
|
401
|
+
* @template P - The context type of the parent pipeline.
|
|
402
|
+
*/
|
|
403
|
+
type IParentMiddleware<P extends IParentContext<any>> = IMiddleware<P>;
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/pipelines/pipeline-runner.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* Executes an array of middleware in a controlled sequence.
|
|
408
|
+
* Supports custom execution strategies through implementation flexibility.
|
|
409
|
+
* Used by pipelines to manage complex middleware chains with features like early termination and nested pipelines.
|
|
410
|
+
*
|
|
411
|
+
* @template TContext - The context type passed to all middleware.
|
|
412
|
+
*/
|
|
413
|
+
interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
414
|
+
/**
|
|
415
|
+
* Executes the action phase of all middleware in sequence.
|
|
416
|
+
* Middleware at startIndex and onward are executed in order.
|
|
417
|
+
* Execution may terminate early if middleware requests it via context.runtime.shouldStop.
|
|
418
|
+
* @param context - The context passed to each middleware action.
|
|
419
|
+
* @param middleware - The ordered middleware array to execute.
|
|
420
|
+
* @param startIndex - Optional starting position in the middleware array (default: 0).
|
|
421
|
+
*/
|
|
422
|
+
dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): void | Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Executes the cleanup phase of all middleware in reverse order.
|
|
425
|
+
* All middleware cleanup functions are called (if defined), regardless of errors.
|
|
426
|
+
* Allows proper resource release and final state management.
|
|
427
|
+
* @param context - The context passed to each middleware cleanup.
|
|
428
|
+
* @param middleware - The ordered middleware array for cleanup (reversed during execution).
|
|
429
|
+
*/
|
|
430
|
+
cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): void | Promise<void>;
|
|
431
|
+
}
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/systems/pipeline/system-context-events.d.ts
|
|
434
|
+
/**
|
|
435
|
+
* System context API for event-driven entity communication.
|
|
436
|
+
* Allows middleware to dispatch events, manage subscriptions, and query event state.
|
|
437
|
+
* Events enable decoupled communication between distant or unrelated entities.
|
|
438
|
+
*/
|
|
439
|
+
interface ISystemContextEvents {
|
|
440
|
+
/**
|
|
441
|
+
* Publishes an event to one or more explicit targets.
|
|
442
|
+
* The event is sent only to the specified target(s) — it does NOT fall back to subscriptions.
|
|
443
|
+
* @param data - The event payload.
|
|
444
|
+
* @param target - The entity or entities to send the event to.
|
|
445
|
+
*/
|
|
446
|
+
dispatchEvent<TEventData extends IEventData>(data: TEventData, target: IEntityProxy | IEntityProxy[]): void;
|
|
447
|
+
/**
|
|
448
|
+
* Publishes multiple events to one or more explicit targets.
|
|
449
|
+
* Each target receives all events in a single update.
|
|
450
|
+
* @param data - Array of event payloads to dispatch.
|
|
451
|
+
* @param target - The entity or entities to send the events to.
|
|
452
|
+
*/
|
|
453
|
+
dispatchEvents<TEventData extends IEventData>(data: TEventData[], target: IEntityProxy | IEntityProxy[]): void;
|
|
454
|
+
/**
|
|
455
|
+
* Broadcasts an event to all subscribers registered for that event type.
|
|
456
|
+
* Uses the subscription registry to resolve targets.
|
|
457
|
+
* @param data - The event payload.
|
|
458
|
+
*/
|
|
459
|
+
broadcastEvent<TEventData extends IEventData>(data: TEventData): void;
|
|
460
|
+
/**
|
|
461
|
+
* Broadcasts multiple events to all subscribers.
|
|
462
|
+
* Events are grouped per subscriber so each receives a single update.
|
|
463
|
+
* @param data - Array of event payloads to broadcast.
|
|
464
|
+
*/
|
|
465
|
+
broadcastEvents<TEventData extends IEventData>(data: TEventData[]): void;
|
|
466
|
+
/**
|
|
467
|
+
* Retrieves an event from the current context by its identifier.
|
|
468
|
+
* Useful for checking if an event was received this frame.
|
|
469
|
+
* @param uid - The event type identifier.
|
|
470
|
+
* @returns The event if present, undefined otherwise.
|
|
471
|
+
*/
|
|
472
|
+
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData> | undefined;
|
|
473
|
+
/**
|
|
474
|
+
* Retrieves all events currently set on this context.
|
|
475
|
+
* Events are cleared between frames.
|
|
476
|
+
* @returns Array of all active events for this context.
|
|
477
|
+
*/
|
|
478
|
+
listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
|
|
479
|
+
/**
|
|
480
|
+
* Checks if a specific event is present in the current context.
|
|
481
|
+
* If no uid is provided, checks if any events exist.
|
|
482
|
+
* @param uid - Optional event type to check for. If omitted, checks for any event.
|
|
483
|
+
* @returns True if matching event(s) found, false otherwise.
|
|
484
|
+
*/
|
|
485
|
+
hasEvent(uid?: EntityEventUid): boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Subscribes to events of a specific type.
|
|
488
|
+
* The entity will be notified of matching events through the update system.
|
|
489
|
+
* @param uid - The event type to listen for.
|
|
490
|
+
* @param options - Optional subscription options (filter, scopeId).
|
|
491
|
+
*/
|
|
492
|
+
subscribeTo(uid: EntityEventUid, options?: EntityEventSubscriptionOptions): void;
|
|
493
|
+
/**
|
|
494
|
+
* Stops listening for events of a specific type.
|
|
495
|
+
* @param uid - The event type to stop listening for.
|
|
496
|
+
*/
|
|
497
|
+
unsubscribeFrom(uid: EntityEventUid): void;
|
|
498
|
+
/**
|
|
499
|
+
* Adds events to the current context for processing by this and downstream middleware.
|
|
500
|
+
* @param events - Event array to add to context.
|
|
501
|
+
*/
|
|
502
|
+
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
503
|
+
/**
|
|
504
|
+
* Adds a single event to the current context.
|
|
505
|
+
* @param event - Event to add to context.
|
|
506
|
+
*/
|
|
507
|
+
setContextEvent(event: IEntityEvent<IEventData>): void;
|
|
508
|
+
/**
|
|
509
|
+
* Removes all events from the current context.
|
|
510
|
+
*/
|
|
511
|
+
clearContextEvents(): void;
|
|
512
|
+
/**
|
|
513
|
+
* Clears all event subscriptions for the current entity.
|
|
514
|
+
*/
|
|
515
|
+
clearSubscriptions(): void;
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/systems/pipeline/system-context-proxies.d.ts
|
|
519
|
+
/**
|
|
520
|
+
* System context API for managing entity relationships (proxies).
|
|
521
|
+
* Provides context-bound operations for establishing and managing entity links.
|
|
522
|
+
* All operations apply to the current entity in the context.
|
|
523
|
+
*/
|
|
524
|
+
interface ISystemContextProxies {
|
|
525
|
+
/**
|
|
526
|
+
* Establishes a reference to another entity from the current entity.
|
|
527
|
+
* Creates a bidirectional link between the entities.
|
|
528
|
+
* @param proxy - The entity to establish a reference to.
|
|
529
|
+
* @param cleanup - If true, removes existing proxies of the same type before adding.
|
|
530
|
+
*/
|
|
531
|
+
register(proxy: IEntityProxy, cleanup?: boolean): void;
|
|
532
|
+
/**
|
|
533
|
+
* Establishes multiple references from the current entity.
|
|
534
|
+
* Batch version of register for efficiency.
|
|
535
|
+
* @param proxies - The entities to establish references to.
|
|
536
|
+
* @param cleanup - If true, removes existing proxies of matching types before adding.
|
|
537
|
+
*/
|
|
538
|
+
registerMany(proxies: readonly IEntityProxy[], cleanup?: boolean): void;
|
|
539
|
+
/**
|
|
540
|
+
* Removes a reference from the current entity to another entity.
|
|
541
|
+
* Breaks the bidirectional link.
|
|
542
|
+
* @param proxy - The entity reference to remove.
|
|
543
|
+
*/
|
|
544
|
+
remove(proxy: IEntityProxy): void;
|
|
545
|
+
/**
|
|
546
|
+
* Removes all entity references from the current entity.
|
|
547
|
+
* Optionally filter by target entity type.
|
|
548
|
+
* @param targetType - If provided, only removes references to entities of this type.
|
|
549
|
+
*/
|
|
550
|
+
removeAll(targetType?: EntityTypeUid): void;
|
|
551
|
+
/**
|
|
552
|
+
* Retrieves a single reference of a specific entity type from the current entity.
|
|
553
|
+
* @param targetType - The entity type to find.
|
|
554
|
+
* @returns The first matching proxy, or null if not found.
|
|
555
|
+
*/
|
|
556
|
+
get(targetType: EntityTypeUid): IEntityProxy | null;
|
|
557
|
+
/**
|
|
558
|
+
* Retrieves all references to entities of a specific type from the current entity.
|
|
559
|
+
* @param targetType - The entity type to find.
|
|
560
|
+
* @returns Array of matching proxies.
|
|
561
|
+
*/
|
|
562
|
+
getMany(targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
|
|
563
|
+
/**
|
|
564
|
+
* Retrieves all entity references from the current entity.
|
|
565
|
+
* Organized by target entity type.
|
|
566
|
+
* @returns Map of entity type to their proxies.
|
|
567
|
+
*/
|
|
568
|
+
getAll(): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
|
|
569
|
+
}
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region src/systems/pipeline/system-context-repository.d.ts
|
|
572
|
+
/**
|
|
573
|
+
* System context API for entity repository operations.
|
|
574
|
+
* Provides controlled access to entity storage for creating, updating, and removing entities.
|
|
575
|
+
* All changes go through the repository to maintain system consistency.
|
|
576
|
+
*/
|
|
577
|
+
interface ISystemContextRepository {
|
|
578
|
+
/**
|
|
579
|
+
* Queues a new entity for creation.
|
|
580
|
+
* The entity is created with the provided model and optional initial snapshot.
|
|
581
|
+
* @param entityType - The type of entity to create.
|
|
582
|
+
* @param model - The entity initialization data.
|
|
583
|
+
* @param snapshot - Optional initial state for the entity.
|
|
584
|
+
*/
|
|
585
|
+
addEntity(entityType: EntityTypeUid, model: IEntityModel, snapshot?: IEntitySnapshot): void;
|
|
586
|
+
/**
|
|
587
|
+
* Retrieves an entity from storage.
|
|
588
|
+
* @template TEntity - The expected entity type.
|
|
589
|
+
* @param proxy - Reference to the entity.
|
|
590
|
+
* @returns The immutable entity instance.
|
|
591
|
+
*/
|
|
592
|
+
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity> | EntityTypeUid): Immutable<TEntity>;
|
|
593
|
+
/**
|
|
594
|
+
* Queues an entity for update.
|
|
595
|
+
* Triggers the update pipeline for the entity.
|
|
596
|
+
* @param target - Optional specific entity to update. Defaults to current entity in context.
|
|
597
|
+
*/
|
|
598
|
+
updateEntity(target?: IEntityProxy): void;
|
|
599
|
+
/**
|
|
600
|
+
* Removes an entity from storage.
|
|
601
|
+
* Triggers entity cleanup and removal from all systems.
|
|
602
|
+
* @param target - The entity to remove.
|
|
603
|
+
*/
|
|
604
|
+
removeEntity(target: IEntityProxy): void;
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/systems/pipeline/system-context-scheduler.d.ts
|
|
608
|
+
/**
|
|
609
|
+
* System context API for scheduling and managing entity updates.
|
|
610
|
+
* Allows middleware to request that an entity (or another) be updated again on the next or subsequent frame.
|
|
611
|
+
* Supports both immediate (next frame) and interval-based scheduling.
|
|
612
|
+
*/
|
|
613
|
+
interface ISystemContextScheduler {
|
|
614
|
+
/**
|
|
615
|
+
* Schedules an entity for update.
|
|
616
|
+
* If no target is specified, schedules the current entity.
|
|
617
|
+
* If no interval is specified, schedules on a default interval.
|
|
618
|
+
* @param target - Optional entity to schedule. Defaults to current entity in context.
|
|
619
|
+
* @param intervalMs - Optional update interval in milliseconds. Undefined uses default interval.
|
|
620
|
+
*/
|
|
621
|
+
scheduleUpdate(target?: IEntityProxy, intervalMs?: number): void;
|
|
622
|
+
/**
|
|
623
|
+
* Cancels scheduled updates for an entity.
|
|
624
|
+
* If no target is specified, removes schedule for the current entity.
|
|
625
|
+
* @param target - Optional entity to unschedule. Defaults to current entity in context.
|
|
626
|
+
*/
|
|
627
|
+
removeSchedule(target?: IEntityProxy): void;
|
|
628
|
+
/**
|
|
629
|
+
* Checks whether an entity has a scheduled update.
|
|
630
|
+
* If no target is specified, checks the current entity.
|
|
631
|
+
* @param target - Optional entity to check. Defaults to current entity in context.
|
|
632
|
+
*/
|
|
633
|
+
hasSchedule(target?: IEntityProxy): boolean;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/systems/pipeline/system-context-snapshot.d.ts
|
|
637
|
+
/**
|
|
638
|
+
* System context API for entity serialization and state transfer.
|
|
639
|
+
* Handles conversion between entities and their serializable snapshots.
|
|
640
|
+
* Used for state persistence, synchronization, and applying external updates.
|
|
641
|
+
*/
|
|
642
|
+
interface ISystemContextSnapshot {
|
|
643
|
+
/**
|
|
644
|
+
* The JSON serializer instance used by this context.
|
|
645
|
+
* Handles serialization of complex types within snapshots.
|
|
646
|
+
*/
|
|
647
|
+
readonly serializer: Immutable<IJsonSerializer>;
|
|
648
|
+
/**
|
|
649
|
+
* Applies serialized state to the current entity.
|
|
650
|
+
* Updates the entity's components based on the snapshot.
|
|
651
|
+
* @param snapshot - The state to apply.
|
|
652
|
+
*/
|
|
653
|
+
applyToEntity(snapshot: IEntitySnapshot): void;
|
|
654
|
+
/**
|
|
655
|
+
* Creates a serialized snapshot of an entity.
|
|
656
|
+
* Captures the current state for transmission or storage.
|
|
657
|
+
* @param entity - The entity to snapshot. If omitted, snapshots current entity in context.
|
|
658
|
+
* @returns The serialized entity state.
|
|
659
|
+
*/
|
|
660
|
+
createFromEntity(entity?: IEntity): IEntitySnapshot;
|
|
661
|
+
/**
|
|
662
|
+
* Queues a snapshot-based update for an entity.
|
|
663
|
+
* Applies the snapshot through the entity update system.
|
|
664
|
+
* @param snapshot - The state to apply.
|
|
665
|
+
* @param proxy - The entity to update.
|
|
666
|
+
*/
|
|
667
|
+
dispatchToUpdate(snapshot: IEntitySnapshot, proxy: IEntityProxy): void;
|
|
668
|
+
}
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region src/systems/pipeline/system-context.d.ts
|
|
671
|
+
/**
|
|
672
|
+
* The execution context passed to system middleware.
|
|
673
|
+
* Provides comprehensive access to entity state, scheduling, events, and repository operations.
|
|
674
|
+
* Serves as the primary interface between middleware and the ECS framework.
|
|
675
|
+
*
|
|
676
|
+
* @template TEntity - The specific entity type this context operates on.
|
|
677
|
+
*/
|
|
678
|
+
interface ISystemContext<TEntity extends IEntity> extends IPipelineContext {
|
|
679
|
+
/**
|
|
680
|
+
* Time elapsed since the last system update for this entity, in milliseconds.
|
|
681
|
+
* Useful for time-based calculations and animations.
|
|
682
|
+
*/
|
|
683
|
+
readonly deltaTimeMs: Immutable<number>;
|
|
684
|
+
/**
|
|
685
|
+
* The entity currently being processed by this middleware.
|
|
686
|
+
*/
|
|
687
|
+
readonly entity: Immutable<TEntity>;
|
|
688
|
+
/**
|
|
689
|
+
* Information about the update triggering this system execution.
|
|
690
|
+
* Contains type (update/remove) and optional model/snapshot data.
|
|
691
|
+
*/
|
|
692
|
+
readonly update: Immutable<IEntityUpdate>;
|
|
693
|
+
/**
|
|
694
|
+
* Event system API for publishing and subscribing to entity events.
|
|
695
|
+
*/
|
|
696
|
+
readonly events: Immutable<ISystemContextEvents>;
|
|
697
|
+
/**
|
|
698
|
+
* Proxy management API for establishing and managing entity relationships.
|
|
699
|
+
*/
|
|
700
|
+
readonly proxies: Immutable<ISystemContextProxies>;
|
|
701
|
+
/**
|
|
702
|
+
* Repository access API for querying and modifying entity storage.
|
|
703
|
+
*/
|
|
704
|
+
readonly repository: Immutable<ISystemContextRepository>;
|
|
705
|
+
/**
|
|
706
|
+
* Scheduling API for requesting follow-up entity updates.
|
|
707
|
+
*/
|
|
708
|
+
readonly scheduler: Immutable<ISystemContextScheduler>;
|
|
709
|
+
/**
|
|
710
|
+
* Snapshot management API for serialization and state transfer.
|
|
711
|
+
*/
|
|
712
|
+
readonly snapshot: Immutable<ISystemContextSnapshot>;
|
|
713
|
+
/**
|
|
714
|
+
* Logging interface for debug and diagnostic output.
|
|
715
|
+
*/
|
|
716
|
+
readonly logger: Immutable<ILogger>;
|
|
717
|
+
}
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/systems/pipeline/system-context-mutable.d.ts
|
|
720
|
+
/**
|
|
721
|
+
* Mutable extension of ISystemContext for infrastructure use.
|
|
722
|
+
* Provides setters for update, delta time, and runtime state that should not be
|
|
723
|
+
* exposed to system middleware. Used by the dispatcher and runtime middleware.
|
|
724
|
+
*
|
|
725
|
+
* @template TEntity - The specific entity type this context operates on.
|
|
726
|
+
*/
|
|
727
|
+
interface IMutableSystemContext<TEntity extends IEntity> extends ISystemContext<TEntity> {
|
|
728
|
+
setUpdate(update: IEntityUpdate): void;
|
|
729
|
+
setDeltaTime(deltaTimeMs: number): void;
|
|
730
|
+
setRuntime(runtime: PipelineRuntime): void;
|
|
731
|
+
}
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region src/factories/context-factory.d.ts
|
|
734
|
+
/**
|
|
735
|
+
* Creates and caches per-entity system contexts.
|
|
736
|
+
*
|
|
737
|
+
* On the first call for a given entity, creates a new SystemContext with all sub-contexts
|
|
738
|
+
* (events, proxies, repository, scheduler, snapshot) bound to that entity.
|
|
739
|
+
* Subsequent calls return the cached context. Disposal removes all cache entries for an entity.
|
|
740
|
+
*/
|
|
741
|
+
interface IContextFactory {
|
|
742
|
+
/**
|
|
743
|
+
* Creates or retrieves the cached system context for the given entity.
|
|
744
|
+
* On first call, creates sub-contexts bound to the entity.
|
|
745
|
+
* On subsequent calls, returns the cached context.
|
|
746
|
+
* @template TEntity - The entity type for which the system context is being created.
|
|
747
|
+
* @param entity - The entity to create or retrieve the context for.
|
|
748
|
+
* @returns The mutable system context for the entity.
|
|
749
|
+
*/
|
|
750
|
+
getOrCreateContext<TEntity extends IEntity>(entity: Immutable<TEntity>): IMutableSystemContext<TEntity>;
|
|
751
|
+
/**
|
|
752
|
+
* Retrieves a previously cached system context by entity UID.
|
|
753
|
+
* @template TEntity - The entity type.
|
|
754
|
+
* @param entityUid - The entity's unique identifier.
|
|
755
|
+
* @returns The cached context, or undefined if not found.
|
|
756
|
+
*/
|
|
757
|
+
getContext<TEntity extends IEntity>(entityUid: EntityUid): IMutableSystemContext<TEntity> | undefined;
|
|
758
|
+
/**
|
|
759
|
+
* Disposes all cached contexts for the given entity.
|
|
760
|
+
* Removes the entity from the repository and clears all cache entries.
|
|
761
|
+
* @param entityUid - The entity's unique identifier.
|
|
762
|
+
*/
|
|
763
|
+
disposeEntity(entityUid: EntityUid): void;
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region src/factories/pipeline-factory.d.ts
|
|
767
|
+
/**
|
|
768
|
+
* Category identifier for grouping performance metrics.
|
|
769
|
+
* Typed as string to allow extension beyond the built-in {@link PipelineCategory} values.
|
|
770
|
+
*/
|
|
771
|
+
type PipelineCategoryName = string;
|
|
772
|
+
/**
|
|
773
|
+
* Built-in metric categories for classifying pipeline and middleware performance entries.
|
|
774
|
+
*
|
|
775
|
+
* - `module` — System module pipelines (initialize, update, render, sync phases).
|
|
776
|
+
* - `runtime` — Runtime orchestration pipeline and its middleware.
|
|
777
|
+
* - `system` — Individual system middleware within a module pipeline.
|
|
778
|
+
*/
|
|
779
|
+
declare enum PipelineCategory {
|
|
780
|
+
module = "module",
|
|
781
|
+
runtime = "runtime",
|
|
782
|
+
system = "system"
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Options for identifying and categorizing performance metrics on pipelines.
|
|
786
|
+
*/
|
|
787
|
+
type PipelineMetricOptions = {
|
|
788
|
+
/** Display name for the pipeline in performance metrics. */pipelineName: string; /** Category assigned to pipeline-level metric entries. */
|
|
789
|
+
pipelineCategory: PipelineCategoryName; /** Category assigned to per-middleware metric entries within this pipeline. */
|
|
790
|
+
middlewareCategory: PipelineCategoryName;
|
|
791
|
+
};
|
|
792
|
+
/**
|
|
793
|
+
* Creates pipeline instances for various contexts.
|
|
794
|
+
* Abstracts pipeline creation to support different implementations.
|
|
795
|
+
* Used by the system to instantiate pipelines without coupling to specific implementations.
|
|
796
|
+
*/
|
|
797
|
+
interface IPipelineFactory {
|
|
798
|
+
/**
|
|
799
|
+
* Creates a new pipeline for the specified context type.
|
|
800
|
+
* @template TContext - The context type for the pipeline. Must extend IPipelineContext.
|
|
801
|
+
* @param options - Optional performance metric options (name, category) for the pipeline.
|
|
802
|
+
* @returns A new pipeline instance ready for middleware registration.
|
|
803
|
+
*/
|
|
804
|
+
createPipeline<TContext extends IPipelineContext>(options?: PipelineMetricOptions): IPipeline<TContext>;
|
|
805
|
+
}
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/systems/system-type.d.ts
|
|
808
|
+
/**
|
|
809
|
+
* The four phases of entity system execution in each frame.
|
|
810
|
+
* Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.
|
|
811
|
+
* The runtime handles each phase in order, allowing systems to perform stage-specific operations.
|
|
812
|
+
*/
|
|
813
|
+
declare enum SystemType {
|
|
814
|
+
/**
|
|
815
|
+
* Initial setup and resource allocation for the entity.
|
|
816
|
+
* Runs once when the entity is first created or initialized.
|
|
817
|
+
*/
|
|
818
|
+
initialize = 0,
|
|
819
|
+
/**
|
|
820
|
+
* Main logic and state updates for the entity.
|
|
821
|
+
* Runs on every update to change entity behavior and properties.
|
|
822
|
+
*/
|
|
823
|
+
update = 1,
|
|
824
|
+
/**
|
|
825
|
+
* Output and visualization operations.
|
|
826
|
+
* Runs after updates to render or display the entity state.
|
|
827
|
+
*/
|
|
828
|
+
render = 2,
|
|
829
|
+
/**
|
|
830
|
+
* Synchronization and persistence.
|
|
831
|
+
* Runs last to synchronize state with external systems or storage.
|
|
832
|
+
*/
|
|
833
|
+
sync = 3
|
|
834
|
+
}
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/systems/module/systems-module.d.ts
|
|
837
|
+
/**
|
|
838
|
+
* Collection of pipelines for a specific entity type.
|
|
839
|
+
* Defines the complete system processing flow for one entity category.
|
|
840
|
+
*
|
|
841
|
+
* @template TEntity - The entity type this module processes.
|
|
842
|
+
*/
|
|
843
|
+
interface ISystemsModule<TEntity extends IEntity> {
|
|
844
|
+
/**
|
|
845
|
+
* The pipelines for this entity type.
|
|
846
|
+
* Each pipeline contains middleware that operates on the entity.
|
|
847
|
+
*/
|
|
848
|
+
readonly pipelines: ReadonlyMap<SystemType, Immutable<IPipeline<ISystemContext<TEntity>>>>;
|
|
849
|
+
/**
|
|
850
|
+
* Optional factory function to initialize new entity instances.
|
|
851
|
+
* If provided, is called when a new entity of this type is created.
|
|
852
|
+
* @param model - The initialization model.
|
|
853
|
+
* @returns The initialized entity.
|
|
854
|
+
*/
|
|
855
|
+
readonly initEntity?: (model: IEntityModel) => TEntity;
|
|
856
|
+
/**
|
|
857
|
+
* If true, this entity type creates a new scope boundary when initialized.
|
|
858
|
+
* A new scope ID is auto-generated. All child entities inherit this scope.
|
|
859
|
+
* Typically used for root entities like Engine.
|
|
860
|
+
*/
|
|
861
|
+
readonly scopeRoot?: boolean;
|
|
862
|
+
/**
|
|
863
|
+
* If true, this entity type registers itself as a scoped proxy when initialized.
|
|
864
|
+
* It joins the inherited scope and becomes resolvable via `context.proxies.get()`
|
|
865
|
+
* by any entity in the same scope. Throws if no scope exists.
|
|
866
|
+
* Typically used for scope-wide entities like Scene, Input, AssetsManager.
|
|
867
|
+
*/
|
|
868
|
+
readonly scopedProxy?: boolean;
|
|
869
|
+
}
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/systems/pipeline/system-middleware.d.ts
|
|
872
|
+
/**
|
|
873
|
+
* A middleware unit that operates within the system pipeline.
|
|
874
|
+
* System middleware receive comprehensive context about the entity being processed
|
|
875
|
+
* and can influence entity state and behavior through various APIs.
|
|
876
|
+
*
|
|
877
|
+
* @template TEntity - The entity type this middleware handles.
|
|
878
|
+
*/
|
|
879
|
+
type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
|
|
880
|
+
//#endregion
|
|
881
|
+
//#region src/systems/module/systems-module-builder.d.ts
|
|
882
|
+
/**
|
|
883
|
+
* Builder pattern interface for constructing system modules.
|
|
884
|
+
* Allows incremental registration of systems and modules for an entity type.
|
|
885
|
+
* Supports adding individual systems or entire pre-configured modules.
|
|
886
|
+
*
|
|
887
|
+
* @template TEntity - The entity type for which systems are being added.
|
|
888
|
+
*/
|
|
889
|
+
interface ISystemsModuleBuilder<TEntity extends IEntity> {
|
|
890
|
+
/**
|
|
891
|
+
* The Module Builder's name.
|
|
892
|
+
*/
|
|
893
|
+
readonly name: string;
|
|
894
|
+
/**
|
|
895
|
+
* The pipelines being built.
|
|
896
|
+
* Accessible during and after construction.
|
|
897
|
+
*/
|
|
898
|
+
readonly pipelines: ReadonlyMap<SystemType, IPipeline<ISystemContext<TEntity>>>;
|
|
899
|
+
/**
|
|
900
|
+
* Whether this entity type is a scope root.
|
|
901
|
+
*/
|
|
902
|
+
readonly scopeRoot: boolean;
|
|
903
|
+
/**
|
|
904
|
+
* Whether this entity type is a scoped proxy.
|
|
905
|
+
*/
|
|
906
|
+
readonly scopedProxy: boolean;
|
|
907
|
+
/**
|
|
908
|
+
* Registers middleware systems for a specific pipeline stage.
|
|
909
|
+
* The middleware are added to the pipeline in the order provided.
|
|
910
|
+
* @param type - The pipeline stage (initialize, update, render, sync).
|
|
911
|
+
* @param systems - Array of middleware to add.
|
|
912
|
+
* @returns This builder for method chaining.
|
|
913
|
+
*/
|
|
914
|
+
addSystems(type: SystemType, systems: Immutable<ISystemMiddleware<TEntity>[]>): this;
|
|
915
|
+
/**
|
|
916
|
+
* Integrates an entire module's pipelines into this builder.
|
|
917
|
+
* Allows composition of multiple modules into one.
|
|
918
|
+
* @template TModuleEntity - The module's entity type (must extend current type).
|
|
919
|
+
* @param module - The module to integrate.
|
|
920
|
+
* @param systemType - Optional specific pipeline to integrate from module. If omitted, integrates all.
|
|
921
|
+
* @returns This builder for method chaining.
|
|
922
|
+
*/
|
|
923
|
+
addModule<TModuleEntity extends TEntity>(module: ISystemsModule<TModuleEntity>, systemType?: SystemType): this;
|
|
924
|
+
/**
|
|
925
|
+
* Marks this entity type as a scope root.
|
|
926
|
+
* When initialized, a new scope is auto-generated and all child entities inherit it.
|
|
927
|
+
* @returns This builder for method chaining.
|
|
928
|
+
*/
|
|
929
|
+
setScopeRoot(): this;
|
|
930
|
+
/**
|
|
931
|
+
* Marks this entity type as a scoped proxy.
|
|
932
|
+
* When initialized, the entity registers itself in the inherited scope,
|
|
933
|
+
* making it resolvable via `context.proxies.get()` by any entity in the same scope.
|
|
934
|
+
* @returns This builder for method chaining.
|
|
935
|
+
*/
|
|
936
|
+
setScopedProxy(): this;
|
|
937
|
+
}
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region src/systems/module/systems-module-repository.d.ts
|
|
940
|
+
/**
|
|
941
|
+
* Central registry for all systems modules in the ECS.
|
|
942
|
+
* Maintains a module for each entity type, providing access to all system pipelines.
|
|
943
|
+
* This is the authoritative source for system module data.
|
|
944
|
+
*
|
|
945
|
+
* @template TEntity - The entity types managed by modules in this repository.
|
|
946
|
+
*/
|
|
947
|
+
interface ISystemsModuleRepository {
|
|
948
|
+
/**
|
|
949
|
+
* The total number of modules in the repository.
|
|
950
|
+
*/
|
|
951
|
+
readonly size: number;
|
|
952
|
+
/**
|
|
953
|
+
* Retrieves the module for a specific entity type.
|
|
954
|
+
* @template TEntity - The entity type to retrieve module for.
|
|
955
|
+
* @param type - The entity type identifier.
|
|
956
|
+
* @returns The systems module for that entity type.
|
|
957
|
+
*/
|
|
958
|
+
get<TEntity extends IEntity>(type: EntityTypeUid): ISystemsModule<TEntity>;
|
|
959
|
+
/**
|
|
960
|
+
* Registers or updates a module for an entity type.
|
|
961
|
+
* @param type - The entity type identifier.
|
|
962
|
+
* @param module - The systems module to register.
|
|
963
|
+
*/
|
|
964
|
+
set(type: EntityTypeUid, module: ISystemsModule<IEntity>): void;
|
|
965
|
+
/**
|
|
966
|
+
* Retrieves all registered modules.
|
|
967
|
+
* @returns A read-only map of entity type to module.
|
|
968
|
+
*/
|
|
969
|
+
list(): ReadonlyMap<EntityTypeUid, Immutable<ISystemsModule<IEntity>>>;
|
|
970
|
+
}
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/systems/runtime/systems-runtime.d.ts
|
|
973
|
+
/**
|
|
974
|
+
* Executes system middleware for entities.
|
|
975
|
+
* Processes entity updates by dispatching them through appropriate system modules.
|
|
976
|
+
* Different implementations may use different execution strategies or optimizations.
|
|
977
|
+
*/
|
|
978
|
+
interface ISystemsRuntime {
|
|
979
|
+
/**
|
|
980
|
+
* Processes a single entity update through its system pipeline.
|
|
981
|
+
* If no update is provided, may dequeue one from an internal queue.
|
|
982
|
+
* @param update - Optional specific update to process. If omitted, dequeues the next update.
|
|
983
|
+
* @returns Array of pipeline results containing execution metrics and data.
|
|
984
|
+
*/
|
|
985
|
+
runTick(update?: IEntityUpdate): PerformanceTimeEntry[] | void;
|
|
986
|
+
}
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region src/systems/runtime/systems-runtime-context.d.ts
|
|
989
|
+
/**
|
|
990
|
+
* Runtime context for system pipeline execution.
|
|
991
|
+
* Coordinates the execution of system pipelines across all entities.
|
|
992
|
+
* Maintains state about the current entity being processed and enabled pipeline stages.
|
|
993
|
+
*
|
|
994
|
+
* @template TEntity - The entity type being processed.
|
|
995
|
+
*/
|
|
996
|
+
interface ISystemsRuntimeContext<TEntity extends IEntity> extends IPipelineContext {
|
|
997
|
+
/**
|
|
998
|
+
* Indicates if the system pipeline should perform initialization for the current entity.
|
|
999
|
+
*/
|
|
1000
|
+
readonly shouldInitialize?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* The systems module for the current entity type.
|
|
1003
|
+
*/
|
|
1004
|
+
readonly systemsModule: ISystemsModule<TEntity>;
|
|
1005
|
+
/**
|
|
1006
|
+
* The mutable system context for the current entity execution.
|
|
1007
|
+
* Provides infrastructure setters for update, delta time, and runtime state.
|
|
1008
|
+
*/
|
|
1009
|
+
readonly systemContext: IMutableSystemContext<TEntity>;
|
|
1010
|
+
/**
|
|
1011
|
+
* The proxy repository for managing entity proxy relationships and scopes.
|
|
1012
|
+
*/
|
|
1013
|
+
readonly proxyRepository: IEntityProxyRepository;
|
|
1014
|
+
}
|
|
1015
|
+
//#endregion
|
|
1016
|
+
//#region src/systems/runtime/systems-runtime-middleware.d.ts
|
|
1017
|
+
/**
|
|
1018
|
+
* Middleware for orchestrating system execution across entities.
|
|
1019
|
+
* Operates at the runtime level to coordinate system module pipelines.
|
|
1020
|
+
* Can influence which pipelines execute and in what order.
|
|
1021
|
+
*
|
|
1022
|
+
* @template TEntity - The entity type being processed.
|
|
1023
|
+
*/
|
|
1024
|
+
type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/factories/runtime-factory.d.ts
|
|
1027
|
+
/**
|
|
1028
|
+
* Creates runtime contexts and pipelines for system execution.
|
|
1029
|
+
* Provides factory methods for constructing runtime infrastructure.
|
|
1030
|
+
* Allows different runtime strategies through multiple implementations.
|
|
1031
|
+
*/
|
|
1032
|
+
interface IRuntimeFactory {
|
|
1033
|
+
/**
|
|
1034
|
+
* Creates a new runtime context for system execution.
|
|
1035
|
+
* @template TEntity - The entity type for the runtime context.
|
|
1036
|
+
* @returns A new systems runtime context instance.
|
|
1037
|
+
*/
|
|
1038
|
+
createRuntimeContext<TEntity extends IEntity>(): ISystemsRuntimeContext<TEntity>;
|
|
1039
|
+
/**
|
|
1040
|
+
* Creates a pipeline for systems runtime orchestration.
|
|
1041
|
+
* @template TEntity - The entity type for this runtime pipeline.
|
|
1042
|
+
* @param name - Optional name for debugging.
|
|
1043
|
+
* @returns A new runtime pipeline for system execution.
|
|
1044
|
+
*/
|
|
1045
|
+
createRuntimePipeline<TEntity extends IEntity>(name?: string): IPipeline<ISystemsRuntimeContext<TEntity>>;
|
|
1046
|
+
}
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/factories/systems-factory.d.ts
|
|
1049
|
+
/**
|
|
1050
|
+
* Creates systems module builders for constructing entity system pipelines.
|
|
1051
|
+
* Provides factory access to module builder instances.
|
|
1052
|
+
* Enables composition of systems for different entity types.
|
|
1053
|
+
*/
|
|
1054
|
+
interface ISystemsFactory {
|
|
1055
|
+
/**
|
|
1056
|
+
* Creates a new builder for constructing a systems module.
|
|
1057
|
+
* @template TEntity - The entity type for which systems are being built.
|
|
1058
|
+
* @param name - The System Builder's name.
|
|
1059
|
+
* @returns A new systems module builder instance.
|
|
1060
|
+
*/
|
|
1061
|
+
createSystemsModuleBuilder<TEntity extends IEntity>(name: string): ISystemsModuleBuilder<TEntity>;
|
|
1062
|
+
}
|
|
1063
|
+
//#endregion
|
|
1064
|
+
export { IMiddleware as A, TickSnapshot as B, IPipelineRunner as C, IParentMiddleware as D, IParentContext as E, PerformanceTimeEntry as F, dispatchSequential as G, ILoggerOptions as H, PerformanceTimerUid as I, MiddlewareMetricsSummary as L, PipelineRuntime as M, IPerformanceTimer as N, IPipeline as O, PerformanceMetricOptions as P, RenderSnapshot as R, ISystemContextEvents as S, INestedMiddleware as T, LogLevel as U, ILogger as V, IJsonSerializer as W, ISystemContext as _, ISystemsRuntime as a, ISystemContextRepository as b, ISystemMiddleware as c, IPipelineFactory as d, PipelineCategory as f, IMutableSystemContext as g, IContextFactory as h, ISystemsRuntimeContext as i, IPipelineContext as j, IMiddlewareRunner as k, ISystemsModule as l, PipelineMetricOptions as m, IRuntimeFactory as n, ISystemsModuleRepository as o, PipelineCategoryName as p, ISystemsRuntimeMiddleware as r, ISystemsModuleBuilder as s, ISystemsFactory as t, SystemType as u, ISystemContextSnapshot as v, INestedContext as w, ISystemContextProxies as x, ISystemContextScheduler as y, TickMetricEntry as z };
|
|
1065
|
+
//# sourceMappingURL=index-8XDo0pla.d.mts.map
|