@awesome-ecs/abstract 0.30.0 → 0.32.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.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs.map +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.cjs +1 -1
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +2 -2
- package/dist/factories/index.d.mts +2 -2
- package/dist/factories/index.mjs +1 -1
- package/dist/factories/index.mjs.map +1 -1
- package/dist/{index-8XDo0pla.d.mts → index-B1OYkMOx.d.cts} +298 -379
- package/dist/{index-BguFn1Xj.d.cts → index-BGLTfuj8.d.cts} +24 -4
- package/dist/{identity-component-CuWHf7jX.d.mts → index-C0jDrUBA.d.cts} +81 -70
- package/dist/{index-kNcUiDBd.d.mts → index-C1hRAjM-.d.mts} +24 -4
- package/dist/index-CeqaKmWR.d.mts +218 -0
- package/dist/{index-BVkmidEx.d.cts → index-D3rS2RFG.d.mts} +298 -379
- package/dist/index-DMTkNY1e.d.cts +218 -0
- package/dist/{identity-component-DLDaOTyK.d.cts → index-b5BtWAvO.d.mts} +81 -70
- package/dist/pipelines/index.d.cts +1 -1
- package/dist/pipelines/index.d.mts +1 -1
- package/dist/systems/index.cjs +20 -4
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.mts +2 -2
- package/dist/systems/index.mjs +20 -5
- package/dist/systems/index.mjs.map +1 -1
- package/dist/types-Bbmnq4ni.d.cts +74 -0
- package/dist/types-C1ojaDL4.d.mts +74 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.mts +3 -3
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { r as Immutable } from "./types-Bbmnq4ni.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/pipelines/pipeline-context.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for all pipeline context objects.
|
|
6
|
+
* Provides hooks for runtime state and control flow during pipeline execution.
|
|
7
|
+
*/
|
|
8
|
+
interface IPipelineContext {
|
|
9
|
+
/**
|
|
10
|
+
* The runtime state and control interface for the pipeline.
|
|
11
|
+
* Allows middleware to query and influence pipeline behavior.
|
|
12
|
+
*/
|
|
13
|
+
readonly runtime?: PipelineRuntime;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runtime state and control interface for pipeline execution.
|
|
17
|
+
* Allows middleware to query status and influence pipeline flow.
|
|
18
|
+
*/
|
|
19
|
+
type PipelineRuntime = {
|
|
20
|
+
/**
|
|
21
|
+
* Flag to request pipeline halt.
|
|
22
|
+
* Set to true to stop executing remaining middleware (cleanup still runs).
|
|
23
|
+
*/
|
|
24
|
+
shouldStop?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional error state if an exception occurred during execution.
|
|
27
|
+
*/
|
|
28
|
+
error?: any;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/pipelines/middleware.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* The basic unit of work in a pipeline.
|
|
34
|
+
* Middleware are chained together to form processing pipelines.
|
|
35
|
+
* Each middleware can inspect/modify context during dispatch and perform cleanup on their changes.
|
|
36
|
+
*
|
|
37
|
+
* @template TContext The context type passed through the middleware chain.
|
|
38
|
+
*/
|
|
39
|
+
interface IMiddleware<TContext extends IPipelineContext> {
|
|
40
|
+
/**
|
|
41
|
+
* Optional name for debugging and logging purposes.
|
|
42
|
+
*/
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional guard condition before running the action.
|
|
46
|
+
* Allows middleware to skip execution based on context state.
|
|
47
|
+
* @param context The current pipeline context.
|
|
48
|
+
* @returns True to execute action, false to skip.
|
|
49
|
+
*/
|
|
50
|
+
shouldRun?(context: TContext): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The main unit of work executed as part of the pipeline.
|
|
53
|
+
* Middlewares execute in registration order during dispatch phase.
|
|
54
|
+
* Can read and modify the context to influence downstream middleware and results.
|
|
55
|
+
* @param context The pipeline context containing all relevant state.
|
|
56
|
+
*/
|
|
57
|
+
action(context: TContext): void | Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Optional cleanup function executed during pipeline teardown.
|
|
60
|
+
* Middlewares execute in reverse registration order during cleanup phase.
|
|
61
|
+
* Used to release resources, clear temporary state, and perform final operations.
|
|
62
|
+
* @param context The pipeline context (may be in modified state from action phases).
|
|
63
|
+
*/
|
|
64
|
+
cleanup?(context: TContext): void | Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/pipelines/middleware-runner.d.ts
|
|
68
|
+
/**
|
|
69
|
+
* Customizes how middleware is executed within a pipeline.
|
|
70
|
+
* Allows decorators to wrap, intercept, or modify middleware execution behavior.
|
|
71
|
+
* Useful for implementing middleware decorators (logging, timing, error handling, etc.).
|
|
72
|
+
*
|
|
73
|
+
* @template TContext The type of context passed to middleware.
|
|
74
|
+
*/
|
|
75
|
+
interface IMiddlewareRunner<TContext extends IPipelineContext> {
|
|
76
|
+
/**
|
|
77
|
+
* Decides how to execute a middleware's action.
|
|
78
|
+
* Can add pre/post processing, error handling, or performance tracking around the middleware.
|
|
79
|
+
* @param context The current pipeline context.
|
|
80
|
+
* @param middleware The middleware whose action should be executed.
|
|
81
|
+
*/
|
|
82
|
+
dispatch(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Decides how to execute a middleware's cleanup.
|
|
85
|
+
* Can add pre/post processing or error handling around cleanup operations.
|
|
86
|
+
* @param context The current pipeline context.
|
|
87
|
+
* @param middleware The middleware whose cleanup should be executed.
|
|
88
|
+
*/
|
|
89
|
+
cleanup(context: TContext, middleware: IMiddleware<TContext>): void | Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/pipelines/pipeline.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* A composable middleware chain for ordered execution of operations.
|
|
95
|
+
* Pipelines provide a framework for registering and executing middleware with dispatch and cleanup phases.
|
|
96
|
+
* Used throughout the ECS system for entity initialization, updates, rendering, and synchronization.
|
|
97
|
+
*
|
|
98
|
+
* @template TContext - The context type passed to all registered middleware.
|
|
99
|
+
*/
|
|
100
|
+
interface IPipeline<TContext extends IPipelineContext> {
|
|
101
|
+
/**
|
|
102
|
+
* The pipeline's name, useful for debugging and logging.
|
|
103
|
+
*/
|
|
104
|
+
readonly name?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The number of middleware currently registered in this pipeline.
|
|
107
|
+
*/
|
|
108
|
+
readonly length?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Direct access to the ordered list of registered middleware.
|
|
111
|
+
* Allows inspection of the execution chain.
|
|
112
|
+
*/
|
|
113
|
+
readonly middleware?: Immutable<IMiddleware<TContext>[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Registers middleware to be executed as part of this pipeline.
|
|
116
|
+
* Middleware is added to the end of the chain and executed in registration order during dispatch.
|
|
117
|
+
* @param middleware - The middleware to register.
|
|
118
|
+
* @returns This instance for method chaining.
|
|
119
|
+
*/
|
|
120
|
+
use(middleware: Immutable<IMiddleware<TContext>>): this;
|
|
121
|
+
/**
|
|
122
|
+
* Executes the dispatch phase with all registered middleware in order.
|
|
123
|
+
* Each middleware's action is called, allowing modifications to context state.
|
|
124
|
+
* Execution continues until all middleware complete or a middleware requests early termination.
|
|
125
|
+
* @param context - The context object passed to all middleware.
|
|
126
|
+
*/
|
|
127
|
+
dispatch(context: Partial<TContext>): void | Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Executes the cleanup phase with all registered middleware in reverse order.
|
|
130
|
+
* Allows middleware to perform resource cleanup and final operations.
|
|
131
|
+
* Typically called after dispatch to ensure proper teardown.
|
|
132
|
+
*
|
|
133
|
+
* @param context - The context object that will be passed to each middleware function.
|
|
134
|
+
*/
|
|
135
|
+
cleanup(context: Partial<TContext>): void | Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/pipelines/pipeline-nested.d.ts
|
|
139
|
+
/**
|
|
140
|
+
* Context for a parent pipeline containing nested pipelines.
|
|
141
|
+
* Allows coordination between outer and inner pipeline execution.
|
|
142
|
+
*
|
|
143
|
+
* @template N - The context type for the nested pipelines.
|
|
144
|
+
*/
|
|
145
|
+
interface IParentContext<N extends IPipelineContext> extends IPipelineContext {
|
|
146
|
+
/**
|
|
147
|
+
* The nested pipeline to execute for each context in nestedContexts.
|
|
148
|
+
*/
|
|
149
|
+
readonly nestedPipeline: IPipeline<INestedContext<this>>;
|
|
150
|
+
/**
|
|
151
|
+
* Contexts to pass to the nested pipeline.
|
|
152
|
+
* The parent pipeline iterates these and executes the nested pipeline for each.
|
|
153
|
+
*/
|
|
154
|
+
readonly nestedContexts: Partial<N>[];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Context for a nested pipeline.
|
|
158
|
+
* Provides access to both current and previous nested context data plus the parent context.
|
|
159
|
+
*
|
|
160
|
+
* @template P - The context type of the parent pipeline.
|
|
161
|
+
*/
|
|
162
|
+
interface INestedContext<P extends IParentContext<any>> extends IPipelineContext {
|
|
163
|
+
/**
|
|
164
|
+
* The current context item being processed in the nested pipeline.
|
|
165
|
+
*/
|
|
166
|
+
readonly current: P extends IParentContext<infer N> ? N : never;
|
|
167
|
+
/**
|
|
168
|
+
* The previous context item (if this is not the first iteration).
|
|
169
|
+
*/
|
|
170
|
+
readonly previous?: P extends IParentContext<infer N> ? N : never;
|
|
171
|
+
/**
|
|
172
|
+
* Reference back to the parent pipeline context.
|
|
173
|
+
*/
|
|
174
|
+
readonly parent: P;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Middleware executing within a nested pipeline.
|
|
178
|
+
*
|
|
179
|
+
* @template P - The context type of the parent pipeline.
|
|
180
|
+
*/
|
|
181
|
+
type INestedMiddleware<P extends IParentContext<any>> = IMiddleware<INestedContext<P>>;
|
|
182
|
+
/**
|
|
183
|
+
* Middleware executing within a parent pipeline (containing nested pipelines).
|
|
184
|
+
*
|
|
185
|
+
* @template P - The context type of the parent pipeline.
|
|
186
|
+
*/
|
|
187
|
+
type IParentMiddleware<P extends IParentContext<any>> = IMiddleware<P>;
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/pipelines/pipeline-runner.d.ts
|
|
190
|
+
/**
|
|
191
|
+
* Executes an array of middleware in a controlled sequence.
|
|
192
|
+
* Supports custom execution strategies through implementation flexibility.
|
|
193
|
+
* Used by pipelines to manage complex middleware chains with features like early termination and nested pipelines.
|
|
194
|
+
*
|
|
195
|
+
* @template TContext - The context type passed to all middleware.
|
|
196
|
+
*/
|
|
197
|
+
interface IPipelineRunner<TContext extends IPipelineContext> {
|
|
198
|
+
/**
|
|
199
|
+
* Executes the action phase of all middleware in sequence.
|
|
200
|
+
* Middleware at startIndex and onward are executed in order.
|
|
201
|
+
* Execution may terminate early if middleware requests it via context.runtime.shouldStop.
|
|
202
|
+
* @param context - The context passed to each middleware action.
|
|
203
|
+
* @param middleware - The ordered middleware array to execute.
|
|
204
|
+
* @param startIndex - Optional starting position in the middleware array (default: 0).
|
|
205
|
+
*/
|
|
206
|
+
dispatch(context: Partial<TContext>, middleware: IMiddleware<TContext>[], startIndex?: number): void | Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Executes the cleanup phase of all middleware in reverse order.
|
|
209
|
+
* All middleware cleanup functions are called (if defined), regardless of errors.
|
|
210
|
+
* Allows proper resource release and final state management.
|
|
211
|
+
* @param context - The context passed to each middleware cleanup.
|
|
212
|
+
* @param middleware - The ordered middleware array for cleanup (reversed during execution).
|
|
213
|
+
*/
|
|
214
|
+
cleanup(context: Partial<TContext>, middleware: IMiddleware<TContext>[]): void | Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { IParentMiddleware as a, IMiddleware as c, IParentContext as i, IPipelineContext as l, INestedContext as n, IPipeline as o, INestedMiddleware as r, IMiddlewareRunner as s, IPipelineRunner as t, PipelineRuntime as u };
|
|
218
|
+
//# sourceMappingURL=index-DMTkNY1e.d.cts.map
|
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
import { r as Immutable } from "./types-C1ojaDL4.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Extension point for application-specific config controls.
|
|
6
|
+
*
|
|
7
|
+
* Consumers can augment this interface to add extra controls while still
|
|
8
|
+
* preserving value-aware option typing.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* declare module '@awesome-ecs/abstract/components' {
|
|
13
|
+
* interface ConfigCustomControlOptions<TValue> {
|
|
14
|
+
* slider: NonNullable<TValue> extends number
|
|
15
|
+
* ? { readonly min?: number; readonly max?: number; readonly step?: number }
|
|
16
|
+
* : never;
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
interface ConfigCustomControlOptions<TValue> {}
|
|
22
|
+
/**
|
|
23
|
+
* A generic configuration object for a component, where keys are config paths and values are the corresponding config values.
|
|
24
|
+
*/
|
|
25
|
+
type ConfigRecord = Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Defines a single configuration option for a specific key in a component's config record.
|
|
28
|
+
* If the config value is itself a nested config record, it can include an `inner` array of further config options.
|
|
29
|
+
*/
|
|
30
|
+
type ConfigOption<TConfig extends object> = keyof TConfig & string extends infer K ? K extends keyof TConfig & string ? ConfigOptionForKey<TConfig, K> : never : never;
|
|
31
|
+
type ConfigOptionForKey<TConfig extends object, K extends keyof TConfig & string> = ConfigOptionForValue<NonNullable<TConfig[K]>, K>;
|
|
32
|
+
type ConfigOptionForValue<TValue, K extends string> = ConfigNestedOptionForValue<TValue, K> | ConfigLeafOptionForValue<TValue, K> | ConfigCustomControlOption<TValue, K>;
|
|
33
|
+
type ConfigNestedOptionForValue<TValue, K extends string> = TValue extends readonly unknown[] ? never : TValue extends ((...args: never[]) => unknown) ? never : TValue extends object ? ConfigNestedOption<TValue, K> : never;
|
|
34
|
+
type ConfigLeafOptionForValue<TValue, K extends string> = [TValue] extends [number] ? ConfigNumberOption<K> | ConfigChoiceOption<K, Extract<TValue, ConfigChoiceValue>> : [TValue] extends [boolean] ? ConfigBooleanOption<K> | ConfigChoiceOption<K, Extract<TValue, ConfigChoiceValue>> : [TValue] extends [string] ? ConfigStringOption<K> | ConfigColorOption<K> | ConfigChoiceOption<K, Extract<TValue, ConfigChoiceValue>> : never;
|
|
35
|
+
type ConfigCustomControlOption<TValue, K extends string> = { [TControl in keyof ConfigCustomControlOptions<TValue> & string]: ConfigOptionBase<K> & {
|
|
36
|
+
readonly control: TControl;
|
|
37
|
+
} & ConfigCustomControlOptions<TValue>[TControl] }[keyof ConfigCustomControlOptions<TValue> & string];
|
|
38
|
+
type ConfigNumberOption<K extends string> = ConfigOptionBase<K> & {
|
|
39
|
+
readonly control: 'number';
|
|
40
|
+
readonly min?: number;
|
|
41
|
+
readonly max?: number;
|
|
42
|
+
readonly step?: number;
|
|
43
|
+
};
|
|
44
|
+
type ConfigBooleanOption<K extends string> = ConfigOptionBase<K> & {
|
|
45
|
+
readonly control: 'boolean';
|
|
46
|
+
};
|
|
47
|
+
type ConfigStringOption<K extends string> = ConfigOptionBase<K> & {
|
|
48
|
+
readonly control: 'string';
|
|
49
|
+
};
|
|
50
|
+
type ConfigColorOption<K extends string> = ConfigOptionBase<K> & {
|
|
51
|
+
readonly control: 'color';
|
|
52
|
+
};
|
|
53
|
+
type ConfigNestedOption<TValue extends object, K extends string> = ConfigOptionBase<K> & {
|
|
54
|
+
readonly inner?: ConfigOption<TValue>[];
|
|
55
|
+
};
|
|
56
|
+
type ConfigChoiceOption<K extends string, TValue extends ConfigChoiceValue = ConfigChoiceValue> = ConfigOptionBase<K> & {
|
|
57
|
+
readonly control: 'select' | 'radio';
|
|
58
|
+
readonly options: ReadonlyArray<ConfigChoice<TValue>>;
|
|
59
|
+
};
|
|
60
|
+
type ConfigOptionBase<K extends string> = {
|
|
61
|
+
readonly key: K;
|
|
62
|
+
readonly label: string;
|
|
63
|
+
readonly group?: string;
|
|
64
|
+
};
|
|
65
|
+
type ConfigChoice<TValue extends ConfigChoiceValue = ConfigChoiceValue> = {
|
|
66
|
+
readonly label: string;
|
|
67
|
+
readonly value: TValue;
|
|
68
|
+
};
|
|
69
|
+
type ConfigChoiceValue = string | number | boolean;
|
|
70
|
+
//#endregion
|
|
1
71
|
//#region src/components/component.d.ts
|
|
2
72
|
type ComponentTypeUid = string | number;
|
|
3
73
|
/**
|
|
@@ -39,6 +109,15 @@ interface IComponent {
|
|
|
39
109
|
*/
|
|
40
110
|
load?(targetState: this): void;
|
|
41
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Component variant that exposes live, mutable configuration values.
|
|
114
|
+
*
|
|
115
|
+
* `config` is the runtime value object systems read from and config
|
|
116
|
+
* updates patch into.
|
|
117
|
+
*/
|
|
118
|
+
interface IComponentWithConfig<TConfig extends ConfigRecord> extends IComponent {
|
|
119
|
+
readonly config: TConfig;
|
|
120
|
+
}
|
|
42
121
|
//#endregion
|
|
43
122
|
//#region src/entities/entity-proxies.d.ts
|
|
44
123
|
/**
|
|
@@ -210,74 +289,6 @@ interface IEntity {
|
|
|
210
289
|
readonly myProxy: Readonly<EntityProxy<this>>;
|
|
211
290
|
}
|
|
212
291
|
//#endregion
|
|
213
|
-
//#region src/utils/types.d.ts
|
|
214
|
-
/**
|
|
215
|
-
* Maps all properties of a type to boolean flags.
|
|
216
|
-
* Useful for feature flags, capability indicators, or boolean option sets.
|
|
217
|
-
*
|
|
218
|
-
* @template T - The type whose properties are mapped to booleans.
|
|
219
|
-
* @example type Features = BooleanProps<{health: any; armor: any}>; // => {health: boolean, armor: boolean}
|
|
220
|
-
*/
|
|
221
|
-
type BooleanProps<T> = { [Property in keyof T]: boolean };
|
|
222
|
-
/**
|
|
223
|
-
* Removes readonly modifiers from all properties, making them mutable.
|
|
224
|
-
* One level of immutability removal (see MutableDeep for recursive removal).
|
|
225
|
-
*
|
|
226
|
-
* @template T - The type to make mutable.
|
|
227
|
-
* @example type Mut = Mutable<{readonly x: number}>; // => {x: number}
|
|
228
|
-
*/
|
|
229
|
-
type Mutable<T> = { -readonly [K in keyof T]: T[K] };
|
|
230
|
-
/**
|
|
231
|
-
* Recursively removes readonly modifiers from all properties at all nesting levels.
|
|
232
|
-
* Makes entire object graph mutable.
|
|
233
|
-
*
|
|
234
|
-
* @template T - The type to make mutable recursively.
|
|
235
|
-
*/
|
|
236
|
-
type MutableDeep<T> = { -readonly [K in keyof T]: Mutable<T[K]> };
|
|
237
|
-
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
238
|
-
/**
|
|
239
|
-
* Makes a type fully immutable at the top level only.
|
|
240
|
-
* Primitives and functions remain unchanged.
|
|
241
|
-
* Collections (Array, Map, Set) become readonly.
|
|
242
|
-
* Objects have their properties made readonly.
|
|
243
|
-
*
|
|
244
|
-
* @template T - The type to make immutable.
|
|
245
|
-
* @example type Imm = Immutable<{x: number}>; // => {readonly x: number}
|
|
246
|
-
*/
|
|
247
|
-
type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
248
|
-
/**
|
|
249
|
-
* Readonly array variant for use in Immutable type transformation.
|
|
250
|
-
*
|
|
251
|
-
* @template T - Element type of the array.
|
|
252
|
-
*/
|
|
253
|
-
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
254
|
-
/**
|
|
255
|
-
* Readonly map variant for use in Immutable type transformation.
|
|
256
|
-
*
|
|
257
|
-
* @template K - Key type of the map.
|
|
258
|
-
* @template V - Value type of the map.
|
|
259
|
-
*/
|
|
260
|
-
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
261
|
-
/**
|
|
262
|
-
* Readonly set variant for use in Immutable type transformation.
|
|
263
|
-
*
|
|
264
|
-
* @template T - Element type of the set.
|
|
265
|
-
*/
|
|
266
|
-
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
267
|
-
/**
|
|
268
|
-
* Makes all object properties readonly (one level only).
|
|
269
|
-
*
|
|
270
|
-
* @template T - The type to make immutable.
|
|
271
|
-
*/
|
|
272
|
-
type ImmutableObject<T> = { readonly [K in keyof T]: T[K] };
|
|
273
|
-
/**
|
|
274
|
-
* Recursively makes all properties readonly at all nesting levels.
|
|
275
|
-
* Provides complete immutability guarantee for the entire object graph.
|
|
276
|
-
*
|
|
277
|
-
* @template T - The type to make deeply immutable.
|
|
278
|
-
*/
|
|
279
|
-
type ImmutableObjectDeep<T> = { readonly [K in keyof T]: Immutable<T[K]> };
|
|
280
|
-
//#endregion
|
|
281
292
|
//#region src/components/identity-component.d.ts
|
|
282
293
|
/**
|
|
283
294
|
* The `BasicComponentType` enum defines the types of basic components available.
|
|
@@ -316,5 +327,5 @@ interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
|
316
327
|
readonly lastUpdated?: Date;
|
|
317
328
|
}
|
|
318
329
|
//#endregion
|
|
319
|
-
export {
|
|
320
|
-
//# sourceMappingURL=
|
|
330
|
+
export { ConfigRecord as _, IEntity as a, IEntityProxy as c, TypedEntityProxy as d, ComponentTypeUid as f, ConfigOption as g, ConfigCustomControlOptions as h, EntityUid as i, IEntityProxyRepository as l, IComponentWithConfig as m, IdentityComponent as n, IEntityModel as o, IComponent as p, EntityTypeUid as r, EntityProxy as s, BasicComponentType as t, RequiredProxies as u };
|
|
331
|
+
//# sourceMappingURL=index-b5BtWAvO.d.mts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as IParentMiddleware, c as IMiddleware, i as IParentContext, l as IPipelineContext, n as INestedContext, o as IPipeline, r as INestedMiddleware, s as IMiddlewareRunner, t as IPipelineRunner, u as PipelineRuntime } from "../index-DMTkNY1e.cjs";
|
|
2
2
|
export { IMiddleware, IMiddlewareRunner, INestedContext, INestedMiddleware, IParentContext, IParentMiddleware, IPipeline, IPipelineContext, IPipelineRunner, PipelineRuntime };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as IParentMiddleware, c as IMiddleware, i as IParentContext, l as IPipelineContext, n as INestedContext, o as IPipeline, r as INestedMiddleware, s as IMiddlewareRunner, t as IPipelineRunner, u as PipelineRuntime } from "../index-CeqaKmWR.mjs";
|
|
2
2
|
export { IMiddleware, IMiddlewareRunner, INestedContext, INestedMiddleware, IParentContext, IParentMiddleware, IPipeline, IPipelineContext, IPipelineRunner, PipelineRuntime };
|
package/dist/systems/index.cjs
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/systems/pipeline/system-context-control.ts
|
|
3
|
+
let SystemContextControlState = /* @__PURE__ */ function(SystemContextControlState) {
|
|
4
|
+
SystemContextControlState["none"] = "none";
|
|
5
|
+
SystemContextControlState["enableCurrentSystem"] = "enableCurrentSystem";
|
|
6
|
+
SystemContextControlState["disableCurrentSystem"] = "disableCurrentSystem";
|
|
7
|
+
SystemContextControlState["enableCurrentModule"] = "enableCurrentModule";
|
|
8
|
+
SystemContextControlState["disableCurrentModule"] = "disableCurrentModule";
|
|
9
|
+
return SystemContextControlState;
|
|
10
|
+
}({});
|
|
11
|
+
//#endregion
|
|
2
12
|
//#region src/systems/system-type.ts
|
|
3
13
|
/**
|
|
4
|
-
* The
|
|
14
|
+
* The five phases of entity system execution in each frame.
|
|
5
15
|
* Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.
|
|
6
16
|
* The runtime handles each phase in order, allowing systems to perform stage-specific operations.
|
|
7
17
|
*/
|
|
@@ -12,23 +22,29 @@ let SystemType = /* @__PURE__ */ function(SystemType) {
|
|
|
12
22
|
*/
|
|
13
23
|
SystemType[SystemType["initialize"] = 0] = "initialize";
|
|
14
24
|
/**
|
|
25
|
+
* Config application and config-dependent resource reconciliation.
|
|
26
|
+
* Runs on entity creation and on updates that carry a config payload.
|
|
27
|
+
*/
|
|
28
|
+
SystemType[SystemType["config"] = 1] = "config";
|
|
29
|
+
/**
|
|
15
30
|
* Main logic and state updates for the entity.
|
|
16
31
|
* Runs on every update to change entity behavior and properties.
|
|
17
32
|
*/
|
|
18
|
-
SystemType[SystemType["update"] =
|
|
33
|
+
SystemType[SystemType["update"] = 2] = "update";
|
|
19
34
|
/**
|
|
20
35
|
* Output and visualization operations.
|
|
21
36
|
* Runs after updates to render or display the entity state.
|
|
22
37
|
*/
|
|
23
|
-
SystemType[SystemType["render"] =
|
|
38
|
+
SystemType[SystemType["render"] = 3] = "render";
|
|
24
39
|
/**
|
|
25
40
|
* Synchronization and persistence.
|
|
26
41
|
* Runs last to synchronize state with external systems or storage.
|
|
27
42
|
*/
|
|
28
|
-
SystemType[SystemType["sync"] =
|
|
43
|
+
SystemType[SystemType["sync"] = 4] = "sync";
|
|
29
44
|
return SystemType;
|
|
30
45
|
}({});
|
|
31
46
|
//#endregion
|
|
47
|
+
exports.SystemContextControlState = SystemContextControlState;
|
|
32
48
|
exports.SystemType = SystemType;
|
|
33
49
|
|
|
34
50
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/systems/system-type.ts"],"sourcesContent":["/**\r\n * The
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/systems/pipeline/system-context-control.ts","../../src/systems/system-type.ts"],"sourcesContent":["import { IEntity } from '@awesome-ecs/abstract/entities';\nimport { ISystemMiddleware } from './system-middleware';\n\nexport enum SystemContextControlState {\n none = 'none',\n enableCurrentSystem = 'enableCurrentSystem',\n disableCurrentSystem = 'disableCurrentSystem',\n enableCurrentModule = 'enableCurrentModule',\n disableCurrentModule = 'disableCurrentModule'\n}\n\n/**\n * Interface for controlling the execution of systems and modules within a system context.\n * This allows middleware to enable or disable specific systems or entire modules for the current entity.\n */\nexport interface ISystemContextControl {\n /**\n * Disables the current system for the current entity.\n */\n disableCurrentSystem(): void;\n\n /**\n * Re-enables the current system for the current entity.\n */\n enableCurrentSystem(): void;\n\n /**\n * Disables the current module for the current entity.\n */\n disableCurrentModule(): void;\n\n /**\n * Re-enables the current module for the current entity.\n */\n enableCurrentModule(): void;\n}\n\n/**\n * Extended system context interface that includes control state for middleware to manage system and module execution.\n * This allows middleware to query and modify the execution state of systems and modules during pipeline processing.\n */\nexport interface ISystemContextControlState extends ISystemContextControl {\n /**\n * Current state of system/module execution control, indicating whether the current system or module is enabled or disabled.\n */\n readonly state: SystemContextControlState;\n\n /**\n * Checks if a specific middleware is currently disabled in the context, allowing middleware to conditionally execute logic based on the enabled/disabled state of other middleware.\n * @param middleware - The middleware to check for disabled state.\n * @returns True if the specified middleware is currently disabled, false otherwise.\n */\n isMiddlewareDisabled(middleware: ISystemMiddleware<IEntity>): boolean;\n\n /**\n * Disables a specific middleware in the context.\n * @param middleware - The middleware to disable.\n */\n disableMiddleware(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Enables a specific middleware in the context.\n * @param middleware - The middleware to enable.\n */\n enableMiddleware(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Disables an entire module of middleware in the context.\n * @param middleware - A middleware from the module to disable.\n */\n disableModule(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Enables an entire module of middleware in the context.\n * @param middleware - A middleware from the module to enable.\n */\n enableModule(middleware: ISystemMiddleware<IEntity>): void;\n}\n","/**\r\n * The five phases of entity system execution in each frame.\r\n * Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.\r\n * The runtime handles each phase in order, allowing systems to perform stage-specific operations.\r\n */\r\nexport enum SystemType {\r\n /**\r\n * Initial setup and resource allocation for the entity.\r\n * Runs once when the entity is first created or initialized.\r\n */\r\n initialize = 0,\r\n\r\n /**\r\n * Config application and config-dependent resource reconciliation.\r\n * Runs on entity creation and on updates that carry a config payload.\r\n */\r\n config = 1,\r\n\r\n /**\r\n * Main logic and state updates for the entity.\r\n * Runs on every update to change entity behavior and properties.\r\n */\r\n update = 2,\r\n\r\n /**\r\n * Output and visualization operations.\r\n * Runs after updates to render or display the entity state.\r\n */\r\n render = 3,\r\n\r\n /**\r\n * Synchronization and persistence.\r\n * Runs last to synchronize state with external systems or storage.\r\n */\r\n sync = 4\r\n}\r\n"],"mappings":";;AAGA,IAAY,4BAAL,yBAAA,2BAAA;CACL,0BAAA,UAAA;CACA,0BAAA,yBAAA;CACA,0BAAA,0BAAA;CACA,0BAAA,yBAAA;CACA,0BAAA,0BAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;;ACJA,IAAY,aAAL,yBAAA,YAAA;;;;;CAKL,WAAA,WAAA,gBAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,UAAA,KAAA;;AACF,EAAA,CAAA,CAAA"}
|
package/dist/systems/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { IMutableSystemContext, ISystemContext, ISystemContextEvents, ISystemContextProxies, ISystemContextRepository, ISystemContextScheduler, ISystemContextSnapshot, ISystemMiddleware, ISystemsModule, ISystemsModuleBuilder, ISystemsModuleRepository, ISystemsRuntime, ISystemsRuntimeContext, ISystemsRuntimeMiddleware, SystemType };
|
|
1
|
+
import { A as ISystemContextRepository, B as SystemModuleName, D as ISystemContextSnapshot, E as ISystemContext, F as SystemContextControlState, H as ISystemContextConfigReadonly, I as ISystemMiddleware, L as MiddlewareRegistry, M as ISystemContextEvents, N as ISystemContextControl, P as ISystemContextControlState, R as MiddlewareRegistryReadonly, T as IMutableSystemContext, V as ISystemContextConfig, a as ISystemsRuntime, c as ISystemsModuleBuilder, i as ISystemsRuntimeContext, j as ISystemContextProxies, k as ISystemContextScheduler, l as ISystemsModuleBuilderReadonly, o as ISystemsModuleRepository, r as ISystemsRuntimeMiddleware, s as ISystemsModule, u as SystemType, z as SystemMiddlewareName } from "../index-B1OYkMOx.cjs";
|
|
2
|
+
export { IMutableSystemContext, ISystemContext, ISystemContextConfig, ISystemContextConfigReadonly, ISystemContextControl, ISystemContextControlState, ISystemContextEvents, ISystemContextProxies, ISystemContextRepository, ISystemContextScheduler, ISystemContextSnapshot, ISystemMiddleware, ISystemsModule, ISystemsModuleBuilder, ISystemsModuleBuilderReadonly, ISystemsModuleRepository, ISystemsRuntime, ISystemsRuntimeContext, ISystemsRuntimeMiddleware, MiddlewareRegistry, MiddlewareRegistryReadonly, SystemContextControlState, SystemMiddlewareName, SystemModuleName, SystemType };
|
package/dist/systems/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { IMutableSystemContext, ISystemContext, ISystemContextEvents, ISystemContextProxies, ISystemContextRepository, ISystemContextScheduler, ISystemContextSnapshot, ISystemMiddleware, ISystemsModule, ISystemsModuleBuilder, ISystemsModuleRepository, ISystemsRuntime, ISystemsRuntimeContext, ISystemsRuntimeMiddleware, SystemType };
|
|
1
|
+
import { A as ISystemContextRepository, B as SystemModuleName, D as ISystemContextSnapshot, E as ISystemContext, F as SystemContextControlState, H as ISystemContextConfigReadonly, I as ISystemMiddleware, L as MiddlewareRegistry, M as ISystemContextEvents, N as ISystemContextControl, P as ISystemContextControlState, R as MiddlewareRegistryReadonly, T as IMutableSystemContext, V as ISystemContextConfig, a as ISystemsRuntime, c as ISystemsModuleBuilder, i as ISystemsRuntimeContext, j as ISystemContextProxies, k as ISystemContextScheduler, l as ISystemsModuleBuilderReadonly, o as ISystemsModuleRepository, r as ISystemsRuntimeMiddleware, s as ISystemsModule, u as SystemType, z as SystemMiddlewareName } from "../index-D3rS2RFG.mjs";
|
|
2
|
+
export { IMutableSystemContext, ISystemContext, ISystemContextConfig, ISystemContextConfigReadonly, ISystemContextControl, ISystemContextControlState, ISystemContextEvents, ISystemContextProxies, ISystemContextRepository, ISystemContextScheduler, ISystemContextSnapshot, ISystemMiddleware, ISystemsModule, ISystemsModuleBuilder, ISystemsModuleBuilderReadonly, ISystemsModuleRepository, ISystemsRuntime, ISystemsRuntimeContext, ISystemsRuntimeMiddleware, MiddlewareRegistry, MiddlewareRegistryReadonly, SystemContextControlState, SystemMiddlewareName, SystemModuleName, SystemType };
|
package/dist/systems/index.mjs
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
//#region src/systems/pipeline/system-context-control.ts
|
|
2
|
+
let SystemContextControlState = /* @__PURE__ */ function(SystemContextControlState) {
|
|
3
|
+
SystemContextControlState["none"] = "none";
|
|
4
|
+
SystemContextControlState["enableCurrentSystem"] = "enableCurrentSystem";
|
|
5
|
+
SystemContextControlState["disableCurrentSystem"] = "disableCurrentSystem";
|
|
6
|
+
SystemContextControlState["enableCurrentModule"] = "enableCurrentModule";
|
|
7
|
+
SystemContextControlState["disableCurrentModule"] = "disableCurrentModule";
|
|
8
|
+
return SystemContextControlState;
|
|
9
|
+
}({});
|
|
10
|
+
//#endregion
|
|
1
11
|
//#region src/systems/system-type.ts
|
|
2
12
|
/**
|
|
3
|
-
* The
|
|
13
|
+
* The five phases of entity system execution in each frame.
|
|
4
14
|
* Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.
|
|
5
15
|
* The runtime handles each phase in order, allowing systems to perform stage-specific operations.
|
|
6
16
|
*/
|
|
@@ -11,23 +21,28 @@ let SystemType = /* @__PURE__ */ function(SystemType) {
|
|
|
11
21
|
*/
|
|
12
22
|
SystemType[SystemType["initialize"] = 0] = "initialize";
|
|
13
23
|
/**
|
|
24
|
+
* Config application and config-dependent resource reconciliation.
|
|
25
|
+
* Runs on entity creation and on updates that carry a config payload.
|
|
26
|
+
*/
|
|
27
|
+
SystemType[SystemType["config"] = 1] = "config";
|
|
28
|
+
/**
|
|
14
29
|
* Main logic and state updates for the entity.
|
|
15
30
|
* Runs on every update to change entity behavior and properties.
|
|
16
31
|
*/
|
|
17
|
-
SystemType[SystemType["update"] =
|
|
32
|
+
SystemType[SystemType["update"] = 2] = "update";
|
|
18
33
|
/**
|
|
19
34
|
* Output and visualization operations.
|
|
20
35
|
* Runs after updates to render or display the entity state.
|
|
21
36
|
*/
|
|
22
|
-
SystemType[SystemType["render"] =
|
|
37
|
+
SystemType[SystemType["render"] = 3] = "render";
|
|
23
38
|
/**
|
|
24
39
|
* Synchronization and persistence.
|
|
25
40
|
* Runs last to synchronize state with external systems or storage.
|
|
26
41
|
*/
|
|
27
|
-
SystemType[SystemType["sync"] =
|
|
42
|
+
SystemType[SystemType["sync"] = 4] = "sync";
|
|
28
43
|
return SystemType;
|
|
29
44
|
}({});
|
|
30
45
|
//#endregion
|
|
31
|
-
export { SystemType };
|
|
46
|
+
export { SystemContextControlState, SystemType };
|
|
32
47
|
|
|
33
48
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/systems/system-type.ts"],"sourcesContent":["/**\r\n * The
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/systems/pipeline/system-context-control.ts","../../src/systems/system-type.ts"],"sourcesContent":["import { IEntity } from '@awesome-ecs/abstract/entities';\nimport { ISystemMiddleware } from './system-middleware';\n\nexport enum SystemContextControlState {\n none = 'none',\n enableCurrentSystem = 'enableCurrentSystem',\n disableCurrentSystem = 'disableCurrentSystem',\n enableCurrentModule = 'enableCurrentModule',\n disableCurrentModule = 'disableCurrentModule'\n}\n\n/**\n * Interface for controlling the execution of systems and modules within a system context.\n * This allows middleware to enable or disable specific systems or entire modules for the current entity.\n */\nexport interface ISystemContextControl {\n /**\n * Disables the current system for the current entity.\n */\n disableCurrentSystem(): void;\n\n /**\n * Re-enables the current system for the current entity.\n */\n enableCurrentSystem(): void;\n\n /**\n * Disables the current module for the current entity.\n */\n disableCurrentModule(): void;\n\n /**\n * Re-enables the current module for the current entity.\n */\n enableCurrentModule(): void;\n}\n\n/**\n * Extended system context interface that includes control state for middleware to manage system and module execution.\n * This allows middleware to query and modify the execution state of systems and modules during pipeline processing.\n */\nexport interface ISystemContextControlState extends ISystemContextControl {\n /**\n * Current state of system/module execution control, indicating whether the current system or module is enabled or disabled.\n */\n readonly state: SystemContextControlState;\n\n /**\n * Checks if a specific middleware is currently disabled in the context, allowing middleware to conditionally execute logic based on the enabled/disabled state of other middleware.\n * @param middleware - The middleware to check for disabled state.\n * @returns True if the specified middleware is currently disabled, false otherwise.\n */\n isMiddlewareDisabled(middleware: ISystemMiddleware<IEntity>): boolean;\n\n /**\n * Disables a specific middleware in the context.\n * @param middleware - The middleware to disable.\n */\n disableMiddleware(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Enables a specific middleware in the context.\n * @param middleware - The middleware to enable.\n */\n enableMiddleware(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Disables an entire module of middleware in the context.\n * @param middleware - A middleware from the module to disable.\n */\n disableModule(middleware: ISystemMiddleware<IEntity>): void;\n\n /**\n * Enables an entire module of middleware in the context.\n * @param middleware - A middleware from the module to enable.\n */\n enableModule(middleware: ISystemMiddleware<IEntity>): void;\n}\n","/**\r\n * The five phases of entity system execution in each frame.\r\n * Each phase serves a specific purpose in the entity lifecycle and can be extended by custom system types.\r\n * The runtime handles each phase in order, allowing systems to perform stage-specific operations.\r\n */\r\nexport enum SystemType {\r\n /**\r\n * Initial setup and resource allocation for the entity.\r\n * Runs once when the entity is first created or initialized.\r\n */\r\n initialize = 0,\r\n\r\n /**\r\n * Config application and config-dependent resource reconciliation.\r\n * Runs on entity creation and on updates that carry a config payload.\r\n */\r\n config = 1,\r\n\r\n /**\r\n * Main logic and state updates for the entity.\r\n * Runs on every update to change entity behavior and properties.\r\n */\r\n update = 2,\r\n\r\n /**\r\n * Output and visualization operations.\r\n * Runs after updates to render or display the entity state.\r\n */\r\n render = 3,\r\n\r\n /**\r\n * Synchronization and persistence.\r\n * Runs last to synchronize state with external systems or storage.\r\n */\r\n sync = 4\r\n}\r\n"],"mappings":";AAGA,IAAY,4BAAL,yBAAA,2BAAA;CACL,0BAAA,UAAA;CACA,0BAAA,yBAAA;CACA,0BAAA,0BAAA;CACA,0BAAA,yBAAA;CACA,0BAAA,0BAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;;ACJA,IAAY,aAAL,yBAAA,YAAA;;;;;CAKL,WAAA,WAAA,gBAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,YAAA,KAAA;;;;;CAMA,WAAA,WAAA,UAAA,KAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/utils/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Maps all properties of a type to boolean flags.
|
|
4
|
+
* Useful for feature flags, capability indicators, or boolean option sets.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type whose properties are mapped to booleans.
|
|
7
|
+
* @example type Features = BooleanProps<{health: any; armor: any}>; // => {health: boolean, armor: boolean}
|
|
8
|
+
*/
|
|
9
|
+
type BooleanProps<T> = { [Property in keyof T]: boolean };
|
|
10
|
+
/**
|
|
11
|
+
* Removes readonly modifiers from all properties, making them mutable.
|
|
12
|
+
* One level of immutability removal (see MutableDeep for recursive removal).
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type to make mutable.
|
|
15
|
+
* @example type Mut = Mutable<{readonly x: number}>; // => {x: number}
|
|
16
|
+
*/
|
|
17
|
+
type Mutable<T> = { -readonly [K in keyof T]: T[K] };
|
|
18
|
+
/**
|
|
19
|
+
* Recursively removes readonly modifiers from all properties at all nesting levels.
|
|
20
|
+
* Makes entire object graph mutable.
|
|
21
|
+
*
|
|
22
|
+
* @template T - The type to make mutable recursively.
|
|
23
|
+
*/
|
|
24
|
+
type MutableDeep<T> = { -readonly [K in keyof T]: Mutable<T[K]> };
|
|
25
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
26
|
+
/**
|
|
27
|
+
* Makes a type fully immutable at the top level only.
|
|
28
|
+
* Primitives and functions remain unchanged.
|
|
29
|
+
* Collections (Array, Map, Set) become readonly.
|
|
30
|
+
* Objects have their properties made readonly.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type to make immutable.
|
|
33
|
+
* @example type Imm = Immutable<{x: number}>; // => {readonly x: number}
|
|
34
|
+
*/
|
|
35
|
+
type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Readonly array variant for use in Immutable type transformation.
|
|
38
|
+
*
|
|
39
|
+
* @template T - Element type of the array.
|
|
40
|
+
*/
|
|
41
|
+
type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
42
|
+
/**
|
|
43
|
+
* Readonly map variant for use in Immutable type transformation.
|
|
44
|
+
*
|
|
45
|
+
* @template K - Key type of the map.
|
|
46
|
+
* @template V - Value type of the map.
|
|
47
|
+
*/
|
|
48
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
49
|
+
/**
|
|
50
|
+
* Readonly set variant for use in Immutable type transformation.
|
|
51
|
+
*
|
|
52
|
+
* @template T - Element type of the set.
|
|
53
|
+
*/
|
|
54
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
55
|
+
/**
|
|
56
|
+
* Makes all object properties readonly (one level only).
|
|
57
|
+
*
|
|
58
|
+
* @template T - The type to make immutable.
|
|
59
|
+
*/
|
|
60
|
+
type ImmutableObject<T> = { readonly [K in keyof T]: T[K] };
|
|
61
|
+
/**
|
|
62
|
+
* Recursively makes all properties readonly at all nesting levels.
|
|
63
|
+
* Provides complete immutability guarantee for the entire object graph.
|
|
64
|
+
*
|
|
65
|
+
* @template T - The type to make deeply immutable.
|
|
66
|
+
*/
|
|
67
|
+
type ImmutableObjectDeep<T> = { readonly [K in keyof T]: Immutable<T[K]> };
|
|
68
|
+
/**
|
|
69
|
+
* Recursively makes all properties optional at all nesting levels.
|
|
70
|
+
*/
|
|
71
|
+
type DeepPartial<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends readonly unknown[] ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ImmutableMap as a, ImmutableSet as c, ImmutableArray as i, Mutable as l, DeepPartial as n, ImmutableObject as o, Immutable as r, ImmutableObjectDeep as s, BooleanProps as t, MutableDeep as u };
|
|
74
|
+
//# sourceMappingURL=types-Bbmnq4ni.d.cts.map
|