@awesome-ecs/abstract 0.20.0 → 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 +3 -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-B2ch9kB3.d.ts +0 -163
  45. package/dist/systems-runtime-context-C-PeYs1I.d.cts +0 -163
  46. package/dist/types-BNwBqRWY.d.cts +0 -22
  47. package/dist/types-BNwBqRWY.d.ts +0 -22
@@ -0,0 +1,161 @@
1
+ import { P as PerformanceTimeEntry } from './performance-timer-BVyl0SRs.js';
2
+
3
+ /**
4
+ * Represents the result of a pipeline operation.
5
+ * It can provide performance metrics collected from self or inner middleware & pipeline calls.
6
+ */
7
+ type PipelineResult = {
8
+ /**
9
+ * Performance metrics collected from the current pipeline operation.
10
+ * This field is optional and can be `undefined` if no performance metrics were collected.
11
+ */
12
+ readonly performance?: PerformanceTimeEntry;
13
+ /**
14
+ * An array of results from inner middleware & pipeline calls.
15
+ * This field is optional and can be `undefined` if there were no inner calls.
16
+ */
17
+ readonly inner?: PipelineResult[];
18
+ };
19
+
20
+ /**
21
+ * Represents the result that can be returned from a middleware function.
22
+ * It can either be void (indicating no result) or a PipelineResult instance.
23
+ *
24
+ * @remarks
25
+ * MiddlewareResult is used to provide Pipeline Results from inner pipeline calls.
26
+ * This is useful when a middleware function needs to return a result from an inner pipeline call.
27
+ **/
28
+ type MiddlewareResult = void | PipelineResult;
29
+
30
+ /**
31
+ * The PipelineStatus enum represents the different states a pipeline can be in.
32
+ *
33
+ * @remarks
34
+ * This enum is used to track the current status of the pipeline.
35
+ */
36
+ declare enum PipelineStatus {
37
+ /**
38
+ * The pipeline is currently idle and not processing any tasks.
39
+ */
40
+ idle = "idle",
41
+ /**
42
+ * The pipeline is currently processing tasks.
43
+ */
44
+ ongoing = "ongoing",
45
+ /**
46
+ * The pipeline has completed all tasks successfully.
47
+ */
48
+ completed = "completed",
49
+ /**
50
+ * The pipeline has been halted due to an error or middleware intervention.
51
+ */
52
+ halted = "halted"
53
+ }
54
+
55
+ /**
56
+ * The Pipeline Context allows exposing state to the Pipeline's middlewares.
57
+ */
58
+ interface IPipelineContext {
59
+ /**
60
+ * The runtime state of the pipeline.
61
+ */
62
+ readonly runtime: PipelineRuntime;
63
+ }
64
+ /**
65
+ * The Pipeline Runtime exposes runtime status controls for Middlewares, as part of the PipelineContext.
66
+ * It allows controlling the pipeline's execution flow.
67
+ */
68
+ type PipelineRuntime = {
69
+ /**
70
+ * A flag indicating whether the pipeline should stop executing.
71
+ * If true, the pipeline execution will be stopped.
72
+ */
73
+ shouldStop: boolean;
74
+ /**
75
+ * The current status of the pipeline.
76
+ * It can be undefined if the status is not set.
77
+ */
78
+ status?: PipelineStatus;
79
+ };
80
+
81
+ /**
82
+ * A middleware, the building block of a Pipeline. Middlewares will provide a unit-of-work implementation
83
+ * dealing with potential state changes over the input Context, or running cleanup logic over the input Context.
84
+ *
85
+ * @template TContext The type of the context that the middleware will operate on.
86
+ * @template TResult The type of the result that the middleware will return.
87
+ */
88
+ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareResult> {
89
+ /**
90
+ * An optional name for the middleware.
91
+ */
92
+ readonly name?: string;
93
+ /**
94
+ * This optional function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
95
+ * being met so this middleware's action should run.
96
+ *
97
+ * @param context The Context to determine whether the run condition is satisfied.
98
+ * @returns A boolean indicating whether the middleware should run.
99
+ */
100
+ shouldRun?(context: TContext): boolean;
101
+ /**
102
+ * The function gets called as part of the pipeline, based on the registration order.
103
+ *
104
+ * @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
105
+ * @returns The result of the middleware's action.
106
+ */
107
+ action(context: TContext): TResult;
108
+ /**
109
+ * This optional function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
110
+ *
111
+ * @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
112
+ * @returns The result of the middleware's cleanup.
113
+ */
114
+ cleanup?(context: TContext): TResult;
115
+ }
116
+
117
+ /**
118
+ * An interface representing a middleware container and dispatcher.
119
+ * It allows registering and executing middleware functions in a pipeline.
120
+ *
121
+ * @template TContext - The type of the context object that will be passed to each middleware function.
122
+ * @template TResult - The type of the result that each middleware function will return.
123
+ * Defaults to {@link MiddlewareResult}.
124
+ */
125
+ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResult> {
126
+ /**
127
+ * Represents the name of the pipeline.
128
+ * This property is optional and can be used for debugging purposes.
129
+ */
130
+ readonly name?: string;
131
+ /**
132
+ * Represents the number of middleware functions registered in the pipeline.
133
+ * This property is optional.
134
+ */
135
+ readonly length?: number;
136
+ /**
137
+ * Register middleware for this pipeline.
138
+ *
139
+ * @param middleware - The middleware function to be added to the pipeline.
140
+ * @returns This instance of the pipeline, allowing for method chaining.
141
+ */
142
+ use(middleware: IMiddleware<TContext, TResult>): this;
143
+ /**
144
+ * Execute the Dispatch phase on the chain of middleware, with the given Context.
145
+ * The Dispatch phase is responsible for invoking the middleware functions in the pipeline.
146
+ *
147
+ * @param context - The context object that will be passed to each middleware function.
148
+ * @returns A {@link PipelineResult} object representing the result of the pipeline execution.
149
+ */
150
+ dispatch(context: TContext): PipelineResult;
151
+ /**
152
+ * Execute the Cleanup phase on the chain of middleware, with the given Context.
153
+ * The Cleanup phase is responsible for performing any necessary cleanup operations after the pipeline execution.
154
+ *
155
+ * @param context - The context object that will be passed to each middleware function.
156
+ * @returns A {@link PipelineResult} object representing the result of the cleanup execution.
157
+ */
158
+ cleanup(context: TContext): PipelineResult;
159
+ }
160
+
161
+ 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 };
@@ -0,0 +1,161 @@
1
+ import { P as PerformanceTimeEntry } from './performance-timer-BVyl0SRs.cjs';
2
+
3
+ /**
4
+ * Represents the result of a pipeline operation.
5
+ * It can provide performance metrics collected from self or inner middleware & pipeline calls.
6
+ */
7
+ type PipelineResult = {
8
+ /**
9
+ * Performance metrics collected from the current pipeline operation.
10
+ * This field is optional and can be `undefined` if no performance metrics were collected.
11
+ */
12
+ readonly performance?: PerformanceTimeEntry;
13
+ /**
14
+ * An array of results from inner middleware & pipeline calls.
15
+ * This field is optional and can be `undefined` if there were no inner calls.
16
+ */
17
+ readonly inner?: PipelineResult[];
18
+ };
19
+
20
+ /**
21
+ * Represents the result that can be returned from a middleware function.
22
+ * It can either be void (indicating no result) or a PipelineResult instance.
23
+ *
24
+ * @remarks
25
+ * MiddlewareResult is used to provide Pipeline Results from inner pipeline calls.
26
+ * This is useful when a middleware function needs to return a result from an inner pipeline call.
27
+ **/
28
+ type MiddlewareResult = void | PipelineResult;
29
+
30
+ /**
31
+ * The PipelineStatus enum represents the different states a pipeline can be in.
32
+ *
33
+ * @remarks
34
+ * This enum is used to track the current status of the pipeline.
35
+ */
36
+ declare enum PipelineStatus {
37
+ /**
38
+ * The pipeline is currently idle and not processing any tasks.
39
+ */
40
+ idle = "idle",
41
+ /**
42
+ * The pipeline is currently processing tasks.
43
+ */
44
+ ongoing = "ongoing",
45
+ /**
46
+ * The pipeline has completed all tasks successfully.
47
+ */
48
+ completed = "completed",
49
+ /**
50
+ * The pipeline has been halted due to an error or middleware intervention.
51
+ */
52
+ halted = "halted"
53
+ }
54
+
55
+ /**
56
+ * The Pipeline Context allows exposing state to the Pipeline's middlewares.
57
+ */
58
+ interface IPipelineContext {
59
+ /**
60
+ * The runtime state of the pipeline.
61
+ */
62
+ readonly runtime: PipelineRuntime;
63
+ }
64
+ /**
65
+ * The Pipeline Runtime exposes runtime status controls for Middlewares, as part of the PipelineContext.
66
+ * It allows controlling the pipeline's execution flow.
67
+ */
68
+ type PipelineRuntime = {
69
+ /**
70
+ * A flag indicating whether the pipeline should stop executing.
71
+ * If true, the pipeline execution will be stopped.
72
+ */
73
+ shouldStop: boolean;
74
+ /**
75
+ * The current status of the pipeline.
76
+ * It can be undefined if the status is not set.
77
+ */
78
+ status?: PipelineStatus;
79
+ };
80
+
81
+ /**
82
+ * A middleware, the building block of a Pipeline. Middlewares will provide a unit-of-work implementation
83
+ * dealing with potential state changes over the input Context, or running cleanup logic over the input Context.
84
+ *
85
+ * @template TContext The type of the context that the middleware will operate on.
86
+ * @template TResult The type of the result that the middleware will return.
87
+ */
88
+ interface IMiddleware<TContext extends IPipelineContext, TResult = MiddlewareResult> {
89
+ /**
90
+ * An optional name for the middleware.
91
+ */
92
+ readonly name?: string;
93
+ /**
94
+ * This optional function gets called before executing the middleware. It acts as a boolean gateway whether enough conditions are
95
+ * being met so this middleware's action should run.
96
+ *
97
+ * @param context The Context to determine whether the run condition is satisfied.
98
+ * @returns A boolean indicating whether the middleware should run.
99
+ */
100
+ shouldRun?(context: TContext): boolean;
101
+ /**
102
+ * The function gets called as part of the pipeline, based on the registration order.
103
+ *
104
+ * @param context The Context can be read or updated. The Context holds all the state necessary for the execution of the middleware.
105
+ * @returns The result of the middleware's action.
106
+ */
107
+ action(context: TContext): TResult;
108
+ /**
109
+ * This optional function gets called when the cleanup of the Pipeline is necessary, based on reverse order of Middleware registration.
110
+ *
111
+ * @param context Part of the Context should be cleaned, and any allocated resources in the Action, should be disposed.
112
+ * @returns The result of the middleware's cleanup.
113
+ */
114
+ cleanup?(context: TContext): TResult;
115
+ }
116
+
117
+ /**
118
+ * An interface representing a middleware container and dispatcher.
119
+ * It allows registering and executing middleware functions in a pipeline.
120
+ *
121
+ * @template TContext - The type of the context object that will be passed to each middleware function.
122
+ * @template TResult - The type of the result that each middleware function will return.
123
+ * Defaults to {@link MiddlewareResult}.
124
+ */
125
+ interface IPipeline<TContext extends IPipelineContext, TResult = MiddlewareResult> {
126
+ /**
127
+ * Represents the name of the pipeline.
128
+ * This property is optional and can be used for debugging purposes.
129
+ */
130
+ readonly name?: string;
131
+ /**
132
+ * Represents the number of middleware functions registered in the pipeline.
133
+ * This property is optional.
134
+ */
135
+ readonly length?: number;
136
+ /**
137
+ * Register middleware for this pipeline.
138
+ *
139
+ * @param middleware - The middleware function to be added to the pipeline.
140
+ * @returns This instance of the pipeline, allowing for method chaining.
141
+ */
142
+ use(middleware: IMiddleware<TContext, TResult>): this;
143
+ /**
144
+ * Execute the Dispatch phase on the chain of middleware, with the given Context.
145
+ * The Dispatch phase is responsible for invoking the middleware functions in the pipeline.
146
+ *
147
+ * @param context - The context object that will be passed to each middleware function.
148
+ * @returns A {@link PipelineResult} object representing the result of the pipeline execution.
149
+ */
150
+ dispatch(context: TContext): PipelineResult;
151
+ /**
152
+ * Execute the Cleanup phase on the chain of middleware, with the given Context.
153
+ * The Cleanup phase is responsible for performing any necessary cleanup operations after the pipeline execution.
154
+ *
155
+ * @param context - The context object that will be passed to each middleware function.
156
+ * @returns A {@link PipelineResult} object representing the result of the cleanup execution.
157
+ */
158
+ cleanup(context: TContext): PipelineResult;
159
+ }
160
+
161
+ 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 };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pipelines/index.ts","../../src/pipelines/pipeline-status.ts"],"sourcesContent":["export * from './middleware';\nexport * from './middleware-result';\nexport * from './middleware-runner';\n\nexport * from './pipeline-context';\nexport * from './pipeline-result';\nexport * from './pipeline-runner';\nexport * from './pipeline-status';\nexport * from './pipeline';\n","/**\n * The PipelineStatus tracks the current status of the pipeline.\n */\nexport enum PipelineStatus {\n idle = 'idle',\n ongoing = 'ongoing',\n completed = 'completed',\n halted = 'halted',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,YAAS;AAJC,SAAAA;AAAA,GAAA;","names":["PipelineStatus"]}
1
+ {"version":3,"sources":["../../src/pipelines/index.ts","../../src/pipelines/pipeline-status.ts"],"sourcesContent":["export * from './middleware-result';\nexport * from './middleware-runner';\nexport * from './middleware';\nexport * from './pipeline-context';\nexport * from './pipeline-result';\nexport * from './pipeline-runner';\nexport * from './pipeline-status';\nexport * from './pipeline';\n","/**\n * The PipelineStatus enum represents the different states a pipeline can be in.\n *\n * @remarks\n * This enum is used to track the current status of the pipeline.\n */\nexport enum PipelineStatus {\n /**\n * The pipeline is currently idle and not processing any tasks.\n */\n idle = 'idle',\n\n /**\n * The pipeline is currently processing tasks.\n */\n ongoing = 'ongoing',\n\n /**\n * The pipeline has completed all tasks successfully.\n */\n completed = 'completed',\n\n /**\n * The pipeline has been halted due to an error or middleware intervention.\n */\n halted = 'halted'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAK,iBAAL,kBAAKA,oBAAL;AAIL,EAAAA,gBAAA,UAAO;AAKP,EAAAA,gBAAA,aAAU;AAKV,EAAAA,gBAAA,eAAY;AAKZ,EAAAA,gBAAA,YAAS;AAnBC,SAAAA;AAAA,GAAA;","names":["PipelineStatus"]}
@@ -1,22 +1,28 @@
1
- import { I as IPipelineContext, b as IMiddleware, M as MiddlewareResult, P as PipelineResult } from '../pipeline-BowCAITe.cjs';
2
- export { a as IPipeline, c as PipelineRuntime, d as PipelineStatus } from '../pipeline-BowCAITe.cjs';
3
- import '../performance-timer-XvdCbcAE.cjs';
1
+ import { I as IPipelineContext, b as IMiddleware, M as MiddlewareResult, P as PipelineResult } from '../pipeline-DunwPUPZ.cjs';
2
+ export { a as IPipeline, c as PipelineRuntime, d as PipelineStatus } from '../pipeline-DunwPUPZ.cjs';
3
+ import '../performance-timer-BVyl0SRs.cjs';
4
4
 
5
5
  /**
6
- * The `Middleware Runner` allows for custom logic when running an {@link IMiddleware} method.
6
+ * The `IMiddlewareRunner` interface allows for custom logic when running an {@link IMiddleware} method.
7
7
  * It's useful for implementing different `Decorators` to compose extensible runtime logic.
8
+ *
9
+ * @template TContext The type of the context that will be passed to the middleware methods.
8
10
  */
9
11
  interface IMiddlewareRunner<TContext extends IPipelineContext> {
10
12
  /**
11
- * The {@link dispatch} method will decide how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instance.
13
+ * The `dispatch` method decides how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instance.
14
+ *
12
15
  * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
13
16
  * @param middleware The {@link IMiddleware} to call the {@link IMiddleware.action} method on.
17
+ * @returns A {@link MiddlewareResult} indicating the outcome of the middleware's action.
14
18
  */
15
19
  dispatch(context: TContext, middleware: IMiddleware<TContext>): MiddlewareResult;
16
20
  /**
17
- * The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
21
+ * The `cleanup` method decides how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
22
+ *
18
23
  * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
19
24
  * @param middleware The {@link IMiddleware} to call the {@link IMiddleware.cleanup} method on.
25
+ * @returns A {@link MiddlewareResult} indicating the outcome of the middleware's cleanup.
20
26
  */
21
27
  cleanup(context: TContext, middleware: IMiddleware<TContext>): MiddlewareResult;
22
28
  }
@@ -28,15 +34,21 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
28
34
  interface IPipelineRunner<TContext extends IPipelineContext> {
29
35
  /**
30
36
  * The {@link dispatch} method will decide how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instances, starting with the provided {@link startIndex} (optional).
31
- * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
32
- * @param middleware The {@link IMiddleware} Array to call the {@link IMiddleware.action} methods on.
33
- * @param startIndex (optional) the Start Index to run in the Middleware Array.
37
+ *
38
+ * @param context - The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
39
+ * @param middleware - The {@link IMiddleware} Array to call the {@link IMiddleware.action} methods on.
40
+ * @param startIndex - (optional) the Start Index to run in the Middleware Array.
41
+ *
42
+ * @returns A {@link PipelineResult} indicating the success or failure of the operation.
34
43
  */
35
44
  dispatch(context: TContext, middleware: IMiddleware<TContext>[], startIndex?: number): PipelineResult;
36
45
  /**
37
46
  * The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instances.
38
- * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
39
- * @param middleware The {@link IMiddleware} Array to call the {@link IMiddleware.cleanup} methods on.
47
+ *
48
+ * @param context - The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
49
+ * @param middleware - The {@link IMiddleware} Array to call the {@link IMiddleware.cleanup} methods on.
50
+ *
51
+ * @returns A {@link PipelineResult} indicating the success or failure of the operation.
40
52
  */
41
53
  cleanup(context: TContext, middleware: IMiddleware<TContext>[]): PipelineResult;
42
54
  }
@@ -1,22 +1,28 @@
1
- import { I as IPipelineContext, b as IMiddleware, M as MiddlewareResult, P as PipelineResult } from '../pipeline-D43CXxWG.js';
2
- export { a as IPipeline, c as PipelineRuntime, d as PipelineStatus } from '../pipeline-D43CXxWG.js';
3
- import '../performance-timer-XvdCbcAE.js';
1
+ import { I as IPipelineContext, b as IMiddleware, M as MiddlewareResult, P as PipelineResult } from '../pipeline-BGsQiSer.js';
2
+ export { a as IPipeline, c as PipelineRuntime, d as PipelineStatus } from '../pipeline-BGsQiSer.js';
3
+ import '../performance-timer-BVyl0SRs.js';
4
4
 
5
5
  /**
6
- * The `Middleware Runner` allows for custom logic when running an {@link IMiddleware} method.
6
+ * The `IMiddlewareRunner` interface allows for custom logic when running an {@link IMiddleware} method.
7
7
  * It's useful for implementing different `Decorators` to compose extensible runtime logic.
8
+ *
9
+ * @template TContext The type of the context that will be passed to the middleware methods.
8
10
  */
9
11
  interface IMiddlewareRunner<TContext extends IPipelineContext> {
10
12
  /**
11
- * The {@link dispatch} method will decide how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instance.
13
+ * The `dispatch` method decides how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instance.
14
+ *
12
15
  * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
13
16
  * @param middleware The {@link IMiddleware} to call the {@link IMiddleware.action} method on.
17
+ * @returns A {@link MiddlewareResult} indicating the outcome of the middleware's action.
14
18
  */
15
19
  dispatch(context: TContext, middleware: IMiddleware<TContext>): MiddlewareResult;
16
20
  /**
17
- * The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
21
+ * The `cleanup` method decides how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instance.
22
+ *
18
23
  * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
19
24
  * @param middleware The {@link IMiddleware} to call the {@link IMiddleware.cleanup} method on.
25
+ * @returns A {@link MiddlewareResult} indicating the outcome of the middleware's cleanup.
20
26
  */
21
27
  cleanup(context: TContext, middleware: IMiddleware<TContext>): MiddlewareResult;
22
28
  }
@@ -28,15 +34,21 @@ interface IMiddlewareRunner<TContext extends IPipelineContext> {
28
34
  interface IPipelineRunner<TContext extends IPipelineContext> {
29
35
  /**
30
36
  * The {@link dispatch} method will decide how to run the {@link IMiddleware.action} method on the provided {@link IMiddleware} instances, starting with the provided {@link startIndex} (optional).
31
- * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
32
- * @param middleware The {@link IMiddleware} Array to call the {@link IMiddleware.action} methods on.
33
- * @param startIndex (optional) the Start Index to run in the Middleware Array.
37
+ *
38
+ * @param context - The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.action} method.
39
+ * @param middleware - The {@link IMiddleware} Array to call the {@link IMiddleware.action} methods on.
40
+ * @param startIndex - (optional) the Start Index to run in the Middleware Array.
41
+ *
42
+ * @returns A {@link PipelineResult} indicating the success or failure of the operation.
34
43
  */
35
44
  dispatch(context: TContext, middleware: IMiddleware<TContext>[], startIndex?: number): PipelineResult;
36
45
  /**
37
46
  * The {@link cleanup} method will decide how to run the {@link IMiddleware.cleanup} method on the provided {@link IMiddleware} instances.
38
- * @param context The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
39
- * @param middleware The {@link IMiddleware} Array to call the {@link IMiddleware.cleanup} methods on.
47
+ *
48
+ * @param context - The {@link IPipelineContext} passed to the Middleware's {@link IMiddleware.cleanup} method.
49
+ * @param middleware - The {@link IMiddleware} Array to call the {@link IMiddleware.cleanup} methods on.
50
+ *
51
+ * @returns A {@link PipelineResult} indicating the success or failure of the operation.
40
52
  */
41
53
  cleanup(context: TContext, middleware: IMiddleware<TContext>[]): PipelineResult;
42
54
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pipelines/pipeline-status.ts"],"sourcesContent":["/**\n * The PipelineStatus tracks the current status of the pipeline.\n */\nexport enum PipelineStatus {\n idle = 'idle',\n ongoing = 'ongoing',\n completed = 'completed',\n halted = 'halted',\n}\n"],"mappings":";AAGO,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,YAAS;AAJC,SAAAA;AAAA,GAAA;","names":["PipelineStatus"]}
1
+ {"version":3,"sources":["../../src/pipelines/pipeline-status.ts"],"sourcesContent":["/**\n * The PipelineStatus enum represents the different states a pipeline can be in.\n *\n * @remarks\n * This enum is used to track the current status of the pipeline.\n */\nexport enum PipelineStatus {\n /**\n * The pipeline is currently idle and not processing any tasks.\n */\n idle = 'idle',\n\n /**\n * The pipeline is currently processing tasks.\n */\n ongoing = 'ongoing',\n\n /**\n * The pipeline has completed all tasks successfully.\n */\n completed = 'completed',\n\n /**\n * The pipeline has been halted due to an error or middleware intervention.\n */\n halted = 'halted'\n}\n"],"mappings":";AAMO,IAAK,iBAAL,kBAAKA,oBAAL;AAIL,EAAAA,gBAAA,UAAO;AAKP,EAAAA,gBAAA,aAAU;AAKV,EAAAA,gBAAA,eAAY;AAKZ,EAAAA,gBAAA,YAAS;AAnBC,SAAAA;AAAA,GAAA;","names":["PipelineStatus"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/systems/index.ts","../../src/systems/module/system-type.ts"],"sourcesContent":["export * from './pipeline/system-context-entity';\nexport * from './pipeline/system-context-events';\nexport * from './pipeline/system-context-proxies';\nexport * from './pipeline/system-context-repository';\nexport * from './pipeline/system-context-scheduler';\nexport * from './pipeline/system-context-snapshot';\nexport * from './runtime/systems-runtime-context';\nexport * from './runtime/systems-runtime-middleware';\nexport * from './pipeline/system-middleware';\nexport * from './pipeline/system-context';\nexport * from './module/system-type';\nexport * from './module/systems-module';\nexport * from './module/systems-module-repository';\nexport * from './runtime/systems-runtime';\n","/**\n * The built-in ECS pipeline types. They can be extended to introduce more types, and the System Runtime Pipeline should\n * add Middleware to handle the newly added types.\n */\nexport enum SystemType {\n initialize = 'initialize',\n update = 'update',\n render = 'render',\n sync = 'sync',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,UAAO;AAJG,SAAAA;AAAA,GAAA;","names":["SystemType"]}
1
+ {"version":3,"sources":["../../src/systems/index.ts","../../src/systems/module/system-type.ts"],"sourcesContent":["export * from './pipeline/system-context-entity';\nexport * from './pipeline/system-context-events';\nexport * from './pipeline/system-context-proxies';\nexport * from './pipeline/system-context-repository';\nexport * from './pipeline/system-context-scheduler';\nexport * from './pipeline/system-context-snapshot';\nexport * from './runtime/systems-runtime-context';\nexport * from './runtime/systems-runtime-middleware';\nexport * from './pipeline/system-middleware';\nexport * from './pipeline/system-context';\nexport * from './module/system-type';\nexport * from './module/systems-module';\nexport * from './module/systems-module-repository';\nexport * from './runtime/systems-runtime';\n","/**\n * Enum representing the built-in System pipeline types.\n * These types can be extended to introduce more types, and the System Runtime Pipeline should\n * add Middleware to handle the newly added types.\n */\nexport enum SystemType {\n /**\n * The initialization phase of the Module pipeline.\n * This phase is typically used for setting up initial state and resources.\n */\n initialize = 'initialize',\n\n /**\n * The update phase of the Module pipeline.\n * This phase is responsible for updating the game logic and state of entities.\n */\n update = 'update',\n\n /**\n * The render phase of the Module pipeline.\n * This phase is used for rendering the game to the screen.\n */\n render = 'render',\n\n /**\n * The synchronization phase of the Module pipeline.\n * This phase is used for synchronizing game state with external systems or other components.\n */\n sync = 'sync'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAK,aAAL,kBAAKA,gBAAL;AAKL,EAAAA,YAAA,gBAAa;AAMb,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,YAAS;AAMT,EAAAA,YAAA,UAAO;AAvBG,SAAAA;AAAA,GAAA;","names":["SystemType"]}
@@ -1,21 +1,27 @@
1
- import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-C-PeYs1I.cjs';
2
- export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-C-PeYs1I.cjs';
3
- import { c as IEntity, E as EntityTypeUid } from '../index-DK2CXVZ8.cjs';
4
- import { b as IMiddleware, P as PipelineResult } from '../pipeline-BowCAITe.cjs';
5
- import { f as IEntityUpdate } from '../entity-repository-DmfcUSrX.cjs';
6
- import { I as Immutable } from '../types-BNwBqRWY.cjs';
1
+ import { I as ISystemsRuntimeContext, a as ISystemContext, S as SystemType } from '../systems-runtime-context-DhtHMczN.cjs';
2
+ export { b as ISystemContextEntity, c as ISystemContextEvents, d as ISystemContextProxies, e as ISystemContextRepository, f as ISystemContextScheduler, g as ISystemContextSnapshot } from '../systems-runtime-context-DhtHMczN.cjs';
3
+ import { c as IEntity, E as EntityTypeUid } from '../index-CnlpX7ys.cjs';
4
+ import { b as IMiddleware, P as PipelineResult } from '../pipeline-DunwPUPZ.cjs';
5
+ import { f as IEntityUpdate } from '../entity-repository-DJ1xbvaN.cjs';
6
+ import { I as Immutable } from '../types-cZ-1lGPD.cjs';
7
7
  import '../utils/index.cjs';
8
- import '../performance-timer-XvdCbcAE.cjs';
8
+ import '../performance-timer-BVyl0SRs.cjs';
9
9
 
10
10
  /**
11
- * The ISystemsRuntimeMiddleware represents the building blocks of executing SystemsModule's registered Pipelines.
11
+ * The `ISystemsRuntimeMiddleware` represents the building blocks of executing SystemsModule's registered Pipelines.
12
12
  * It receives the current State in the Context, and can decide which SystemPipelines to execute.
13
+ *
14
+ * @typeParam TEntity - The type of entity that the middleware operates on.
15
+ * @extends {IMiddleware<ISystemsRuntimeContext<TEntity>>} - Extends the base `IMiddleware` interface, which is used for defining middleware functions.
13
16
  */
14
17
  type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
15
18
 
16
19
  /**
17
- * The SystemMiddleware is the basic System implementation that can be registered as a Middleware in a SystemPipeline.
18
- * It provides a SystemPipelineContext to it's exposed methods.
20
+ * The `ISystemMiddleware` is a basic System implementation that can be registered as a Middleware in a SystemPipeline.
21
+ * It provides a `SystemPipelineContext` to its exposed methods.
22
+ *
23
+ * @template TEntity - The type of entity that this middleware operates on.
24
+ * @extends {IMiddleware<ISystemContext<TEntity>>} - Extends the base `IMiddleware` interface, which requires a `SystemPipelineContext` to be provided.
19
25
  */
20
26
  type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEntity>>;
21
27
 
@@ -25,36 +31,69 @@ type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemContext<TEn
25
31
  */
26
32
  interface ISystemsModule<TEntity extends IEntity> {
27
33
  /**
28
- * @param type The SystemPipelineType to append the provided SystemMiddlewares to.
29
- * @param systems The SystemMiddlewares will be registered in the provided SystemPipelineType in the same order as the provided array.
34
+ * Registers SystemMiddlewares to the specified SystemPipelineType.
35
+ *
36
+ * @param type - The SystemPipelineType to append the provided SystemMiddlewares to.
37
+ * @param systems - The SystemMiddlewares to be registered in the provided SystemPipelineType in the same order as the provided array.
30
38
  * The SystemMiddlewares will be appended to existing Pipelines to allow easy extension of existing behaviors.
31
39
  */
32
- registerSystems(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
40
+ registerSystems?(type: SystemType, systems: ISystemMiddleware<TEntity>[]): void;
33
41
  /**
34
- * Trigger all registered SystemPipelines, to apply the changes from the provided EntityUpdate to an Entity instance.
35
- * @param update The EntityUpdate containing the desired changes to be applied on an Entity instance.
42
+ * Triggers all registered SystemPipelines to apply the changes from the provided EntityUpdate to an Entity instance.
43
+ *
44
+ * @param update - The EntityUpdate containing the desired changes to be applied on an Entity instance.
45
+ * @returns A PipelineResult indicating the success or failure of the triggered SystemPipelines.
36
46
  */
37
47
  triggerSystems(update: IEntityUpdate): PipelineResult;
38
48
  }
39
49
 
50
+ /**
51
+ * Interface for managing systems modules.
52
+ *
53
+ * @template TEntity - The type of entity that the systems module operates on.
54
+ */
40
55
  interface ISystemsModuleRepository {
56
+ /**
57
+ * The number of systems modules in the repository.
58
+ */
41
59
  readonly size: number;
60
+ /**
61
+ * Retrieves a systems module for a specific entity type.
62
+ *
63
+ * @param type - The unique identifier of the entity type.
64
+ * @returns The systems module for the specified entity type.
65
+ */
42
66
  get<TEntity extends IEntity>(type: EntityTypeUid): ISystemsModule<TEntity>;
67
+ /**
68
+ * Adds or updates a systems module for a specific entity type.
69
+ *
70
+ * @param type - The unique identifier of the entity type.
71
+ * @param module - The systems module to add or update.
72
+ */
43
73
  set(type: EntityTypeUid, module: ISystemsModule<IEntity>): void;
74
+ /**
75
+ * Retrieves a read-only map of all systems modules in the repository.
76
+ *
77
+ * @returns A read-only map of entity type unique identifiers to systems modules.
78
+ */
44
79
  list(): ReadonlyMap<EntityTypeUid, Immutable<ISystemsModule<IEntity>>>;
45
80
  }
46
81
 
47
82
  /**
48
83
  * The System Runtime allows running a loop of Ticks.
49
84
  *
50
- * Each RunTick can process one or more Entity Updates, from the EntityQueue.
51
- * We can have multiple implementations of a SystemRuntime, based on the use-case.
85
+ * Each `runTick` method can process one or more Entity Updates.
86
+ *
87
+ * We can have multiple implementations of a `SystemsRuntime`, based on the use-case.
52
88
  * A different implementation can be chosen at runtime, based for example on performance.
53
89
  */
54
90
  interface ISystemsRuntime {
55
91
  /**
56
- * The method should trigger the SystemsModule logic for the provided IEntityUpdate.
57
- * If no EntityUpdate is given, the SystemRuntime implementation can choose to dequeue one from the IEntityUpdateQueue.
92
+ * The method should trigger the SystemsModule logic for the provided `IEntityUpdate`.
93
+ * If no EntityUpdate is given, the `SystemRuntime` implementation can choose to dequeue one from the `IEntityUpdateQueue`.
94
+ *
95
+ * @param update - An optional `IEntityUpdate` to process. If not provided, the method will dequeue one from the `IEntityUpdateQueue`.
96
+ * @returns A `PipelineResult` representing the outcome of the SystemsModule logic execution.
58
97
  */
59
98
  runTick(update?: IEntityUpdate): PipelineResult;
60
99
  }