ecspresso 0.10.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -148
- package/dist/asset-manager.d.ts +16 -16
- package/dist/asset-types.d.ts +18 -16
- package/dist/command-buffer.d.ts +30 -20
- package/dist/ecspresso-builder.d.ts +193 -0
- package/dist/ecspresso.d.ts +323 -209
- package/dist/entity-manager.d.ts +76 -30
- package/dist/event-bus.d.ts +6 -1
- package/dist/index.d.ts +6 -13
- package/dist/plugin.d.ts +61 -0
- package/dist/plugins/audio.d.ts +273 -0
- package/dist/{bundles/utils → plugins}/bounds.d.ts +20 -26
- package/dist/plugins/camera.d.ts +88 -0
- package/dist/plugins/collision.d.ts +285 -0
- package/dist/plugins/coroutine.d.ts +126 -0
- package/dist/plugins/diagnostics.d.ts +49 -0
- package/dist/{bundles/utils → plugins}/input.d.ts +22 -29
- package/dist/plugins/particles.d.ts +225 -0
- package/dist/plugins/physics2D.d.ts +163 -0
- package/dist/plugins/renderers/renderer2D.d.ts +262 -0
- package/dist/plugins/spatial-index.d.ts +58 -0
- package/dist/plugins/sprite-animation.d.ts +150 -0
- package/dist/plugins/state-machine.d.ts +244 -0
- package/dist/plugins/timers.d.ts +151 -0
- package/dist/{bundles/utils → plugins}/transform.d.ts +21 -22
- package/dist/plugins/tween.d.ts +162 -0
- package/dist/reactive-query-manager.d.ts +14 -3
- package/dist/resource-manager.d.ts +64 -23
- package/dist/screen-manager.d.ts +21 -15
- package/dist/screen-types.d.ts +15 -11
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +25 -0
- package/dist/src/plugins/audio.js +4 -0
- package/dist/src/plugins/audio.js.map +10 -0
- package/dist/src/plugins/bounds.js +4 -0
- package/dist/src/plugins/bounds.js.map +10 -0
- package/dist/src/plugins/camera.js +4 -0
- package/dist/src/plugins/camera.js.map +10 -0
- package/dist/src/plugins/collision.js +4 -0
- package/dist/src/plugins/collision.js.map +11 -0
- package/dist/src/plugins/coroutine.js +4 -0
- package/dist/src/plugins/coroutine.js.map +10 -0
- package/dist/src/plugins/diagnostics.js +5 -0
- package/dist/src/plugins/diagnostics.js.map +10 -0
- package/dist/src/plugins/input.js +4 -0
- package/dist/src/plugins/input.js.map +10 -0
- package/dist/src/plugins/particles.js +4 -0
- package/dist/src/plugins/particles.js.map +10 -0
- package/dist/src/plugins/physics2D.js +4 -0
- package/dist/src/plugins/physics2D.js.map +11 -0
- package/dist/src/plugins/renderers/renderer2D.js +4 -0
- package/dist/src/plugins/renderers/renderer2D.js.map +10 -0
- package/dist/src/plugins/spatial-index.js +4 -0
- package/dist/src/plugins/spatial-index.js.map +11 -0
- package/dist/src/plugins/sprite-animation.js +4 -0
- package/dist/src/plugins/sprite-animation.js.map +10 -0
- package/dist/src/plugins/state-machine.js +4 -0
- package/dist/src/plugins/state-machine.js.map +10 -0
- package/dist/src/plugins/timers.js +4 -0
- package/dist/src/plugins/timers.js.map +10 -0
- package/dist/src/plugins/transform.js +4 -0
- package/dist/src/plugins/transform.js.map +10 -0
- package/dist/src/plugins/tween.js +4 -0
- package/dist/src/plugins/tween.js.map +11 -0
- package/dist/system-builder.d.ts +75 -112
- package/dist/type-utils.d.ts +247 -7
- package/dist/types.d.ts +58 -39
- package/dist/utils/check-required-cycle.d.ts +12 -0
- package/dist/utils/easing.d.ts +71 -0
- package/dist/utils/math.d.ts +67 -0
- package/dist/utils/narrowphase.d.ts +63 -0
- package/dist/utils/spatial-hash.d.ts +53 -0
- package/package.json +65 -27
- package/dist/bundle.d.ts +0 -123
- package/dist/bundles/renderers/renderer2D.d.ts +0 -220
- package/dist/bundles/renderers/renderer2D.js +0 -4
- package/dist/bundles/renderers/renderer2D.js.map +0 -10
- package/dist/bundles/utils/bounds.js +0 -4
- package/dist/bundles/utils/bounds.js.map +0 -10
- package/dist/bundles/utils/collision.d.ts +0 -204
- package/dist/bundles/utils/collision.js +0 -4
- package/dist/bundles/utils/collision.js.map +0 -10
- package/dist/bundles/utils/input.js +0 -4
- package/dist/bundles/utils/input.js.map +0 -10
- package/dist/bundles/utils/movement.d.ts +0 -86
- package/dist/bundles/utils/movement.js +0 -4
- package/dist/bundles/utils/movement.js.map +0 -10
- package/dist/bundles/utils/timers.d.ts +0 -172
- package/dist/bundles/utils/timers.js +0 -4
- package/dist/bundles/utils/timers.js.map +0 -10
- package/dist/bundles/utils/transform.js +0 -4
- package/dist/bundles/utils/transform.js.map +0 -10
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -22
|
@@ -1,37 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resource factory with declared dependencies and optional disposal callback
|
|
3
3
|
*/
|
|
4
|
-
interface ResourceFactoryWithDeps<T> {
|
|
5
|
-
dependsOn?: readonly
|
|
6
|
-
factory: (context
|
|
7
|
-
onDispose?: (resource: T, context
|
|
4
|
+
export interface ResourceFactoryWithDeps<T, Context = unknown, D extends string = string> {
|
|
5
|
+
dependsOn?: readonly D[];
|
|
6
|
+
factory: (context: Context) => T | Promise<T>;
|
|
7
|
+
onDispose?: (resource: T, context: Context) => void | Promise<void>;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare const RESOURCE_DIRECT: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* Branded wrapper for storing a value as-is, bypassing factory detection.
|
|
13
|
+
* The value is carried on the symbol key to avoid structural conflicts
|
|
14
|
+
* with user resource types that have a `value` property.
|
|
15
|
+
* Create via the `directValue()` helper.
|
|
16
|
+
*/
|
|
17
|
+
export interface ResourceDirectValue<T> {
|
|
18
|
+
[RESOURCE_DIRECT]: T;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Wrap a value to store it as-is, bypassing factory detection.
|
|
22
|
+
* Use when the resource itself is a function or class that should not be invoked.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { directValue } from 'ecspresso';
|
|
27
|
+
* world.addResource('handler', directValue(myFunction));
|
|
28
|
+
* world.addResource('MyClass', directValue(MyClass));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function directValue<T>(value: T): ResourceDirectValue<T>;
|
|
32
|
+
/**
|
|
33
|
+
* When Context is unknown (default), context args are optional.
|
|
34
|
+
* When Context is a specific type (e.g. ECSpresso<...>), context is required.
|
|
35
|
+
*/
|
|
36
|
+
type ContextArgs<Context> = unknown extends Context ? [context?: Context] : [context: Context];
|
|
37
|
+
export default class ResourceManager<ResourceTypes extends Record<string, any> = Record<string, any>, Context = unknown> {
|
|
10
38
|
private resources;
|
|
11
39
|
private resourceFactories;
|
|
12
40
|
private resourceDependencies;
|
|
13
41
|
private resourceDisposers;
|
|
14
42
|
private initializedResourceKeys;
|
|
15
43
|
/**
|
|
16
|
-
* Add a resource to the manager
|
|
44
|
+
* Add a resource to the manager.
|
|
45
|
+
*
|
|
46
|
+
* Resolution order:
|
|
47
|
+
* 1. `{ factory, dependsOn?, onDispose? }` → factory with optional deps/disposal
|
|
48
|
+
* 2. `{ value }` → direct value wrapper (use to store functions/classes as-is)
|
|
49
|
+
* 3. `typeof === 'function'` → bare factory (no deps)
|
|
50
|
+
* 4. Anything else → direct value
|
|
51
|
+
*
|
|
17
52
|
* @param label The resource key
|
|
18
53
|
* @param resource The resource value, a factory function, or a factory with dependencies
|
|
19
54
|
* @returns The resource manager instance for chaining
|
|
20
55
|
*/
|
|
21
|
-
add<K extends keyof ResourceTypes>(label: K, resource: ResourceTypes[K] | ((context
|
|
56
|
+
add<K extends keyof ResourceTypes>(label: K, resource: ResourceTypes[K] | ((context: Context) => ResourceTypes[K] | Promise<ResourceTypes[K]>) | ResourceFactoryWithDeps<ResourceTypes[K], Context, keyof ResourceTypes & string> | ResourceDirectValue<ResourceTypes[K]>): this;
|
|
22
57
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
58
|
+
* Try to get a resource from the manager.
|
|
59
|
+
* Returns the resource value if it exists, or undefined if not found.
|
|
60
|
+
* Like `get`, initializes factory resources on first access.
|
|
61
|
+
* @param label The resource key
|
|
62
|
+
* @param context Context to pass to factory functions (usually the ECSpresso instance)
|
|
63
|
+
* @returns The resource value, or undefined if not found
|
|
64
|
+
* @see get — the throwing alternative
|
|
25
65
|
*/
|
|
26
|
-
|
|
66
|
+
tryGet<K extends keyof ResourceTypes>(label: K, ...args: ContextArgs<Context>): ResourceTypes[K] | undefined;
|
|
27
67
|
/**
|
|
28
68
|
* Get a resource from the manager
|
|
29
69
|
* @param label The resource key
|
|
30
|
-
* @param context
|
|
70
|
+
* @param context Context to pass to factory functions (usually the ECSpresso instance)
|
|
31
71
|
* @returns The resource value
|
|
32
72
|
* @throws Error if resource not found
|
|
73
|
+
* @see tryGet — the non-throwing alternative
|
|
33
74
|
*/
|
|
34
|
-
get<K extends keyof ResourceTypes>(label: K,
|
|
75
|
+
get<K extends keyof ResourceTypes>(label: K, ...args: ContextArgs<Context>): ResourceTypes[K];
|
|
35
76
|
/**
|
|
36
77
|
* Check if a resource exists
|
|
37
78
|
* @param label The resource key
|
|
@@ -48,7 +89,7 @@ export default class ResourceManager<ResourceTypes extends Record<string, any> =
|
|
|
48
89
|
* Get all resource keys
|
|
49
90
|
* @returns Array of resource keys
|
|
50
91
|
*/
|
|
51
|
-
getKeys(): Array<
|
|
92
|
+
getKeys(): Array<keyof ResourceTypes>;
|
|
52
93
|
/**
|
|
53
94
|
* Check if a resource needs to be initialized
|
|
54
95
|
* @param label The resource key
|
|
@@ -59,40 +100,40 @@ export default class ResourceManager<ResourceTypes extends Record<string, any> =
|
|
|
59
100
|
* Get all resource keys that need to be initialized
|
|
60
101
|
* @returns Array of resource keys that need initialization
|
|
61
102
|
*/
|
|
62
|
-
getPendingInitializationKeys(): Array<
|
|
103
|
+
getPendingInitializationKeys(): Array<keyof ResourceTypes>;
|
|
63
104
|
/**
|
|
64
105
|
* Initialize a specific resource if it's a factory function
|
|
65
106
|
* @param label The resource key
|
|
66
|
-
* @param context
|
|
107
|
+
* @param context Context to pass to factory functions
|
|
67
108
|
* @returns Promise that resolves when the resource is initialized
|
|
68
109
|
*/
|
|
69
|
-
initializeResource<K extends keyof ResourceTypes>(label: K,
|
|
110
|
+
initializeResource<K extends keyof ResourceTypes>(label: K, ...args: ContextArgs<Context>): Promise<void>;
|
|
70
111
|
/**
|
|
71
112
|
* Initialize specific resources or all resources that haven't been initialized yet.
|
|
72
113
|
* Resources are initialized in topological order based on their dependencies.
|
|
73
|
-
* @param context
|
|
114
|
+
* @param context Context to pass to factory functions (usually the ECSpresso instance)
|
|
74
115
|
* @param keys Optional array of resource keys to initialize
|
|
75
116
|
* @returns Promise that resolves when the specified resources are initialized
|
|
76
117
|
*/
|
|
77
|
-
initializeResources<K extends keyof ResourceTypes>(
|
|
118
|
+
initializeResources<K extends keyof ResourceTypes>(...args: [...ContextArgs<Context>, ...K[]]): Promise<void>;
|
|
78
119
|
/**
|
|
79
120
|
* Get the dependencies of a resource
|
|
80
121
|
* @param label The resource key
|
|
81
122
|
* @returns Array of resource keys that this resource depends on
|
|
82
123
|
*/
|
|
83
|
-
getDependencies<K extends keyof ResourceTypes>(label: K): readonly string[];
|
|
124
|
+
getDependencies<K extends keyof ResourceTypes>(label: K): readonly (keyof ResourceTypes & string)[];
|
|
84
125
|
/**
|
|
85
126
|
* Dispose a single resource, calling its onDispose callback if it exists
|
|
86
127
|
* @param label The resource key to dispose
|
|
87
|
-
* @param context
|
|
128
|
+
* @param context Context to pass to the onDispose callback
|
|
88
129
|
* @returns True if the resource existed and was disposed, false if it didn't exist
|
|
89
130
|
*/
|
|
90
|
-
disposeResource<K extends keyof ResourceTypes>(label: K,
|
|
131
|
+
disposeResource<K extends keyof ResourceTypes>(label: K, ...args: ContextArgs<Context>): Promise<boolean>;
|
|
91
132
|
/**
|
|
92
133
|
* Dispose all initialized resources in reverse dependency order.
|
|
93
134
|
* Resources that depend on others are disposed first.
|
|
94
|
-
* @param context
|
|
135
|
+
* @param context Context to pass to onDispose callbacks
|
|
95
136
|
*/
|
|
96
|
-
disposeResources(
|
|
137
|
+
disposeResources(...args: ContextArgs<Context>): Promise<void>;
|
|
97
138
|
}
|
|
98
139
|
export {};
|
package/dist/screen-manager.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type EventBus from './event-bus';
|
|
5
5
|
import type AssetManager from './asset-manager';
|
|
6
6
|
import type ECSpresso from './ecspresso';
|
|
7
|
-
import type { ScreenDefinition, ScreenResource, ScreenEvents, ScreenConfigurator } from './screen-types';
|
|
7
|
+
import type { ScreenDefinition, ScreenResource, ScreenEvents, ScreenConfigurator, ScreenConfig, ScreenState } from './screen-types';
|
|
8
8
|
/**
|
|
9
9
|
* Manages screen/state transitions for ECSpresso
|
|
10
10
|
*/
|
|
@@ -19,7 +19,8 @@ export default class ScreenManager<Screens extends Record<string, ScreenDefiniti
|
|
|
19
19
|
* Set dependencies for screen transitions
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
setDependencies(eventBus: EventBus<ScreenEvents
|
|
22
|
+
setDependencies(eventBus: EventBus<ScreenEvents<keyof Screens & string>>, assetManager: AssetManager<any> | null, ecs: ECSpresso<any, any, any, any, any>): void;
|
|
23
|
+
private requireEcs;
|
|
23
24
|
/**
|
|
24
25
|
* Register a screen definition
|
|
25
26
|
*/
|
|
@@ -49,25 +50,30 @@ export default class ScreenManager<Screens extends Record<string, ScreenDefiniti
|
|
|
49
50
|
*/
|
|
50
51
|
getCurrentScreen(): keyof Screens | null;
|
|
51
52
|
/**
|
|
52
|
-
* Get the current screen config (immutable)
|
|
53
|
+
* Get the current screen config (immutable).
|
|
54
|
+
* If `screen` is provided, asserts that the current screen matches.
|
|
53
55
|
*/
|
|
54
|
-
getConfig
|
|
56
|
+
getConfig(screen?: keyof Screens): Readonly<ScreenConfig<Screens[keyof Screens]>>;
|
|
55
57
|
/**
|
|
56
|
-
* Get the current screen config or
|
|
58
|
+
* Get the current screen config or undefined.
|
|
59
|
+
* If `screen` is provided, returns undefined when the current screen doesn't match.
|
|
57
60
|
*/
|
|
58
|
-
|
|
61
|
+
tryGetConfig(screen?: keyof Screens): Readonly<ScreenConfig<Screens[keyof Screens]>> | undefined;
|
|
59
62
|
/**
|
|
60
|
-
* Get the current screen state (mutable)
|
|
63
|
+
* Get the current screen state (mutable).
|
|
64
|
+
* If `screen` is provided, asserts that the current screen matches.
|
|
61
65
|
*/
|
|
62
|
-
getState
|
|
66
|
+
getState(screen?: keyof Screens): ScreenState<Screens[keyof Screens]>;
|
|
63
67
|
/**
|
|
64
|
-
* Get the current screen state or
|
|
68
|
+
* Get the current screen state or undefined.
|
|
69
|
+
* If `screen` is provided, returns undefined when the current screen doesn't match.
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
tryGetState(screen?: keyof Screens): ScreenState<Screens[keyof Screens]> | undefined;
|
|
67
72
|
/**
|
|
68
|
-
* Update the current screen state
|
|
73
|
+
* Update the current screen state.
|
|
74
|
+
* If `screen` is provided, asserts that the current screen matches.
|
|
69
75
|
*/
|
|
70
|
-
updateState
|
|
76
|
+
updateState(update: unknown, screen?: keyof Screens): void;
|
|
71
77
|
/**
|
|
72
78
|
* Get the screen stack depth
|
|
73
79
|
*/
|
|
@@ -100,10 +106,10 @@ export default class ScreenManager<Screens extends Record<string, ScreenDefiniti
|
|
|
100
106
|
/**
|
|
101
107
|
* Implementation of ScreenConfigurator for builder pattern
|
|
102
108
|
*/
|
|
103
|
-
export declare class ScreenConfiguratorImpl<Screens extends Record<string, ScreenDefinition<any, any
|
|
109
|
+
export declare class ScreenConfiguratorImpl<Screens extends Record<string, ScreenDefinition<any, any>>, W = unknown> implements ScreenConfigurator<Screens, W> {
|
|
104
110
|
private readonly manager;
|
|
105
111
|
constructor(manager: ScreenManager<Screens>);
|
|
106
|
-
add<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(name: K, definition: ScreenDefinition<Config, State>): ScreenConfigurator<Screens & Record<K, ScreenDefinition<Config, State
|
|
112
|
+
add<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(name: K, definition: ScreenDefinition<Config, State, W>): ScreenConfigurator<Screens & Record<K, ScreenDefinition<Config, State, W>>, W>;
|
|
107
113
|
/**
|
|
108
114
|
* Get the underlying manager
|
|
109
115
|
* @internal
|
|
@@ -113,4 +119,4 @@ export declare class ScreenConfiguratorImpl<Screens extends Record<string, Scree
|
|
|
113
119
|
/**
|
|
114
120
|
* Create a new ScreenConfigurator for builder pattern usage
|
|
115
121
|
*/
|
|
116
|
-
export declare function createScreenConfigurator<Screens extends Record<string, ScreenDefinition<any, any>> = Record<string, never
|
|
122
|
+
export declare function createScreenConfigurator<Screens extends Record<string, ScreenDefinition<any, any>> = Record<string, never>, W = unknown>(manager?: ScreenManager<Screens>): ScreenConfiguratorImpl<Screens, W>;
|
package/dist/screen-types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type ECSpresso from './ecspresso';
|
|
|
5
5
|
/**
|
|
6
6
|
* Definition for a screen including its state, lifecycle hooks, and requirements
|
|
7
7
|
*/
|
|
8
|
-
export interface ScreenDefinition<Config extends Record<string, unknown> = Record<string, never>, State extends Record<string, unknown> = Record<string, never>> {
|
|
8
|
+
export interface ScreenDefinition<Config extends Record<string, unknown> = Record<string, never>, State extends Record<string, unknown> = Record<string, never>, W = ECSpresso<any>> {
|
|
9
9
|
/**
|
|
10
10
|
* Function to create initial state from config
|
|
11
11
|
*/
|
|
@@ -13,11 +13,14 @@ export interface ScreenDefinition<Config extends Record<string, unknown> = Recor
|
|
|
13
13
|
/**
|
|
14
14
|
* Lifecycle hook called when entering this screen
|
|
15
15
|
*/
|
|
16
|
-
readonly onEnter?: (
|
|
16
|
+
readonly onEnter?: (ctx: {
|
|
17
|
+
config: Config;
|
|
18
|
+
ecs: W;
|
|
19
|
+
}) => void | Promise<void>;
|
|
17
20
|
/**
|
|
18
21
|
* Lifecycle hook called when exiting this screen
|
|
19
22
|
*/
|
|
20
|
-
readonly onExit?: (ecs:
|
|
23
|
+
readonly onExit?: (ecs: W) => void | Promise<void>;
|
|
21
24
|
/**
|
|
22
25
|
* Asset keys that must be loaded before entering this screen
|
|
23
26
|
*/
|
|
@@ -82,32 +85,33 @@ export interface ScreenResource<Screens extends Record<string, ScreenDefinition<
|
|
|
82
85
|
isCurrent(screenName: keyof Screens): boolean;
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
|
-
* Events emitted by the screen system
|
|
88
|
+
* Events emitted by the screen system.
|
|
89
|
+
* @typeParam S - Screen name type (defaults to `string` for backward compatibility)
|
|
86
90
|
*/
|
|
87
|
-
export interface ScreenEvents {
|
|
91
|
+
export interface ScreenEvents<S extends string = string> {
|
|
88
92
|
screenEnter: {
|
|
89
|
-
screen:
|
|
93
|
+
screen: S;
|
|
90
94
|
config: unknown;
|
|
91
95
|
};
|
|
92
96
|
screenExit: {
|
|
93
|
-
screen:
|
|
97
|
+
screen: S;
|
|
94
98
|
};
|
|
95
99
|
screenPush: {
|
|
96
|
-
screen:
|
|
100
|
+
screen: S;
|
|
97
101
|
config: unknown;
|
|
98
102
|
};
|
|
99
103
|
screenPop: {
|
|
100
|
-
screen:
|
|
104
|
+
screen: S;
|
|
101
105
|
};
|
|
102
106
|
}
|
|
103
107
|
/**
|
|
104
108
|
* Configuration for screen definitions during builder setup
|
|
105
109
|
*/
|
|
106
|
-
export interface ScreenConfigurator<Screens extends Record<string, ScreenDefinition<any, any
|
|
110
|
+
export interface ScreenConfigurator<Screens extends Record<string, ScreenDefinition<any, any>>, W = unknown> {
|
|
107
111
|
/**
|
|
108
112
|
* Add a screen definition
|
|
109
113
|
*/
|
|
110
|
-
add<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(name: K, definition: ScreenDefinition<Config, State>): ScreenConfigurator<Screens & Record<K, ScreenDefinition<Config, State
|
|
114
|
+
add<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(name: K, definition: ScreenDefinition<Config, State, W>): ScreenConfigurator<Screens & Record<K, ScreenDefinition<Config, State, W>>, W>;
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
117
|
* Type-safe screen state getter result
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var{defineProperty:C,getOwnPropertyNames:i,getOwnPropertyDescriptor:o}=Object,r=Object.prototype.hasOwnProperty;function a(j){return this[j]}var t=(j)=>{var $=(k??=new WeakMap).get(j),L;if($)return $;if($=C({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var J of i(j))if(!r.call($,J))C($,J,{get:a.bind(j,J),enumerable:!(L=o(j,J))||L.enumerable})}return k.set(j,$),$},k;var n=(j)=>j;function e(j,$){this[j]=n.bind(null,$)}var jj=(j,$)=>{for(var L in $)C(j,L,{get:$[L],enumerable:!0,configurable:!0,set:e.bind($,L)})};var V=(j,$)=>()=>(j&&($=j(j=0)),$);var Yj=((j)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(j,{get:($,L)=>(typeof require<"u"?require:$)[L]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});class H{parentMap=new Map;childrenMap=new Map;setParent(j,$){if(j===$)throw Error(`Cannot set entity ${j} as its own parent`);if(this.wouldCreateCycle(j,$))throw Error("Cannot set parent: would create circular reference");let L=this.parentMap.get(j);if(L!==void 0){let X=this.childrenMap.get(L);if(X){let Y=X.indexOf(j);if(Y!==-1)X.splice(Y,1)}}this.parentMap.set(j,$);let J=this.childrenMap.get($);if(J)J.push(j);else this.childrenMap.set($,[j]);return this}removeParent(j){let $=this.parentMap.get(j);if($===void 0)return!1;let L=this.childrenMap.get($);if(L){let J=L.indexOf(j);if(J!==-1)L.splice(J,1)}return this.parentMap.delete(j),!0}getParent(j){return this.parentMap.get(j)??null}getChildren(j){let $=this.childrenMap.get(j);return $?[...$]:[]}getChildAt(j,$){if($<0)return null;let L=this.childrenMap.get(j);if(!L||$>=L.length)return null;return L[$]??null}getChildIndex(j,$){let L=this.childrenMap.get(j);if(!L)return-1;return L.indexOf($)}removeEntity(j){let $=this.parentMap.get(j)??null;if($!==null){let X=this.childrenMap.get($);if(X){let Y=X.indexOf(j);if(Y!==-1)X.splice(Y,1)}}this.parentMap.delete(j);let L=this.childrenMap.get(j)??[],J=[...L];for(let X of L)this.parentMap.delete(X);return this.childrenMap.delete(j),{oldParent:$,orphanedChildren:J}}getAncestors(j){let $=[],L=this.parentMap.get(j);while(L!==void 0)$.push(L),L=this.parentMap.get(L);return $}getDescendants(j){let $=[],L=this.childrenMap.get(j);if(!L)return $;let J=L.slice().reverse();while(J.length>0){let X=J.pop();$.push(X);let Y=this.childrenMap.get(X);if(Y)for(let Z=Y.length-1;Z>=0;Z--)J.push(Y[Z])}return $}getRoot(j){let $=j,L=this.parentMap.get($);while(L!==void 0)$=L,L=this.parentMap.get($);return $}getSiblings(j){let $=this.parentMap.get(j);if($===void 0)return[];let L=this.childrenMap.get($);if(!L)return[];return L.filter((J)=>J!==j)}isDescendantOf(j,$){if(j===$)return!1;let L=this.parentMap.get(j);while(L!==void 0){if(L===$)return!0;L=this.parentMap.get(L)}return!1}isAncestorOf(j,$){return this.isDescendantOf($,j)}getRootEntities(){let j=[];for(let $ of this.childrenMap.keys())if(!this.parentMap.has($))j.push($);return j}wouldCreateCycle(j,$){let L=$;while(L!==void 0){if(L===j)return!0;L=this.parentMap.get(L)}return!1}forEachInHierarchy(j,$){let L=$?.roots??this.getRootEntities(),J=[];for(let X of L)J.push({entityId:X,parentId:null,depth:0});for(let X of J){j(X.entityId,X.parentId,X.depth);let Y=this.childrenMap.get(X.entityId);if(Y)for(let Z of Y)J.push({entityId:Z,parentId:X.entityId,depth:X.depth+1})}}*hierarchyIterator(j){let $=j?.roots??this.getRootEntities(),L=[];for(let J of $)L.push({entityId:J,parentId:null,depth:0});for(let J of L){yield J;let X=this.childrenMap.get(J.entityId);if(X)for(let Y of X)L.push({entityId:Y,parentId:J.entityId,depth:J.depth+1})}}}class E{nextId=1;entities=new Map;componentIndices=new Map;addedCallbacks=new Map;removedCallbacks=new Map;hierarchyManager=new H;disposeCallbacks=new Map;changeSeqs=new Map;_changeSeq=0;_afterComponentAddedHooks=[];_afterEntityMutatedHooks=[];_afterComponentRemovedHooks=[];_beforeEntityRemovedHooks=[];_afterParentChangedHooks=[];_batchingDepth=0;_batchedEntityIds=new Set;_pendingBatchKeys=null;get entityCount(){return this.entities.size}createEntity(){let j=this.nextId++,$={id:j,components:{}};return this.entities.set(j,$),$}registerDispose(j,$){this.disposeCallbacks.set(j,$)}getDisposeCallbacks(){return this.disposeCallbacks}invokeDispose(j,$,L){let J=this.disposeCallbacks.get(j);if(!J)return;try{J({value:$,entityId:L})}catch(X){console.warn(`Component dispose callback for '${String(j)}' threw:`,X)}}addComponent(j,$,L){let J=this.entities.get(j);if(!J)throw Error(`Cannot add component '${String($)}': Entity with ID ${j} does not exist`);let X=J.components[$];if(X!==void 0)this.invokeDispose($,X,J.id);if(J.components[$]=L,!this.componentIndices.has($))this.componentIndices.set($,new Set);this.componentIndices.get($)?.add(J.id);let Y=this.addedCallbacks.get($);if(Y)for(let Z of[...Y])Z({value:L,entity:J});this._batchingDepth++;for(let Z of this._afterComponentAddedHooks)Z(J.id,$);if(this._batchedEntityIds.add(J.id),this._batchingDepth--,this._batchingDepth===0){for(let Z of this._batchedEntityIds)for(let B of this._afterEntityMutatedHooks)B(Z);this._batchedEntityIds.clear()}return this}addComponents(j,$){let L=this.entities.get(j);if(!L)throw Error(`Cannot add components: Entity with ID ${j} does not exist`);let J=this._pendingBatchKeys;this._pendingBatchKeys=new Set(Object.keys($)),this._batchingDepth++;for(let X in $)this.addComponent(L.id,X,$[X]);if(this._batchingDepth--,this._pendingBatchKeys=J,this._batchingDepth===0){for(let X of this._batchedEntityIds)for(let Y of this._afterEntityMutatedHooks)Y(X);this._batchedEntityIds.clear()}return this}removeComponent(j,$){let L=this.entities.get(j);if(!L)throw Error(`Cannot remove component '${String($)}': Entity with ID ${j} does not exist`);let J=L.components[$];if(J!==void 0)this.invokeDispose($,J,L.id);delete L.components[$];let X=this.removedCallbacks.get($);if(X&&J!==void 0)for(let Y of[...X])Y({value:J,entity:L});if(this.componentIndices.get($)?.delete(L.id),J!==void 0)for(let Y of this._afterComponentRemovedHooks)Y(L.id,$);return this}getComponent(j,$){let L=this.entities.get(j);if(!L)throw Error(`Cannot get component '${String($)}': Entity with ID ${j} does not exist`);return L.components[$]}getEntitiesWithQuery(j=[],$=[],L,J,X){let Y=L!==void 0&&L.length>0&&J!==void 0,Z=X!==void 0&&X.length>0;if(j.length===0){if($.length===0&&!Y&&!Z)return Array.from(this.entities.values());return Array.from(this.entities.values()).filter((D)=>{if($.length>0&&!$.every((_)=>!(_ in D.components)))return!1;if(Y){let _=this.changeSeqs.get(D.id);if(!_)return!1;if(!L.some((Q)=>(_.get(Q)??-1)>J))return!1}if(Z&&!this.parentHasComponents(D.id,X))return!1;return!0})}let B=j[0];if(B===void 0)return[];let K=j.reduce((D,_)=>{let Q=this.componentIndices.get(_)?.size??0,A=this.componentIndices.get(D)?.size??1/0;return Q<A?_:D},B),U=this.componentIndices.get(K);if(!U||U.size===0)return[];let W=[],F=$.length>0;for(let D of U){let _=this.entities.get(D);if(_&&j.every((Q)=>(Q in _.components))&&(!F||$.every((Q)=>!(Q in _.components)))){if(Y){let Q=this.changeSeqs.get(D);if(!Q||!L.some((A)=>(Q.get(A)??-1)>J))continue}if(Z&&!this.parentHasComponents(D,X))continue;W.push(_)}}return W}parentHasComponents(j,$){let L=this.hierarchyManager.getParent(j);if(L===null)return!1;let J=this.entities.get(L);if(!J)return!1;for(let X of $)if(!(X in J.components))return!1;return!0}removeEntity(j,$){let L=this.entities.get(j);if(!L)return!1;if($?.cascade??!0){let X=this.hierarchyManager.getDescendants(L.id);for(let Y=X.length-1;Y>=0;Y--){let Z=X[Y];if(Z===void 0)continue;for(let B of this._beforeEntityRemovedHooks)B(Z)}for(let Y of this._beforeEntityRemovedHooks)Y(L.id);for(let Y=X.length-1;Y>=0;Y--){let Z=X[Y];if(Z===void 0)continue;this.removeEntityInternal(Z)}}else for(let X of this._beforeEntityRemovedHooks)X(L.id);return this.removeEntityInternal(L.id)}removeEntityInternal(j){let $=this.entities.get(j);if(!$)return!1;this.hierarchyManager.removeEntity(j);for(let L of Object.keys($.components)){let J=$.components[L];if(J!==void 0){this.invokeDispose(L,J,$.id);let X=this.removedCallbacks.get(L);if(X)for(let Y of[...X])Y({value:J,entity:$})}this.componentIndices.get(L)?.delete($.id)}return this.changeSeqs.delete($.id),this.entities.delete($.id)}getEntity(j){return this.entities.get(j)}onComponentAdded(j,$){let L=$,J=this.addedCallbacks.get(j);if(!J)J=new Set,this.addedCallbacks.set(j,J);return J.add(L),()=>{this.addedCallbacks.get(j)?.delete(L)}}onComponentRemoved(j,$){let L=$,J=this.removedCallbacks.get(j);if(!J)J=new Set,this.removedCallbacks.set(j,J);return J.add(L),()=>{this.removedCallbacks.get(j)?.delete(L)}}onAfterComponentAdded(j){return this._afterComponentAddedHooks.push(j),()=>{let $=this._afterComponentAddedHooks.indexOf(j);if($!==-1)this._afterComponentAddedHooks.splice($,1)}}onAfterEntityMutated(j){return this._afterEntityMutatedHooks.push(j),()=>{let $=this._afterEntityMutatedHooks.indexOf(j);if($!==-1)this._afterEntityMutatedHooks.splice($,1)}}onAfterComponentRemoved(j){return this._afterComponentRemovedHooks.push(j),()=>{let $=this._afterComponentRemovedHooks.indexOf(j);if($!==-1)this._afterComponentRemovedHooks.splice($,1)}}onBeforeEntityRemoved(j){return this._beforeEntityRemovedHooks.push(j),()=>{let $=this._beforeEntityRemovedHooks.indexOf(j);if($!==-1)this._beforeEntityRemovedHooks.splice($,1)}}onAfterParentChanged(j){return this._afterParentChangedHooks.push(j),()=>{let $=this._afterParentChangedHooks.indexOf(j);if($!==-1)this._afterParentChangedHooks.splice($,1)}}get changeSeq(){return this._changeSeq}markChanged(j,$){let L=++this._changeSeq,J=this.changeSeqs.get(j);if(!J)J=new Map,this.changeSeqs.set(j,J);J.set($,L)}getChangeSeq(j,$){return this.changeSeqs.get(j)?.get($)??-1}spawnChild(j,$){let L=this.createEntity();return this.addComponents(L.id,$),this.setParent(L.id,j),L}setParent(j,$){this.hierarchyManager.setParent(j,$);for(let L of this._afterParentChangedHooks)L(j);return this}removeParent(j){let $=this.hierarchyManager.removeParent(j);if($)for(let L of this._afterParentChangedHooks)L(j);return $}getParent(j){return this.hierarchyManager.getParent(j)}getChildren(j){return this.hierarchyManager.getChildren(j)}getChildAt(j,$){return this.hierarchyManager.getChildAt(j,$)}getChildIndex(j,$){return this.hierarchyManager.getChildIndex(j,$)}getAncestors(j){return this.hierarchyManager.getAncestors(j)}getDescendants(j){return this.hierarchyManager.getDescendants(j)}getRoot(j){return this.hierarchyManager.getRoot(j)}getSiblings(j){return this.hierarchyManager.getSiblings(j)}isDescendantOf(j,$){return this.hierarchyManager.isDescendantOf(j,$)}isAncestorOf(j,$){return this.hierarchyManager.isAncestorOf(j,$)}getRootEntities(){return this.hierarchyManager.getRootEntities()}forEachInHierarchy(j,$){this.hierarchyManager.forEachInHierarchy(j,$)}hierarchyIterator(j){return this.hierarchyManager.hierarchyIterator(j)}}var h=()=>{};class w{handlers=new Map;subscribe(j,$){return this.addHandler(j,$,!1)}once(j,$){return this.addHandler(j,$,!0)}unsubscribe(j,$){let L=this.handlers.get(j);if(!L)return!1;let J=L.findIndex((X)=>X.callback===$);if(J===-1)return!1;return L.splice(J,1),!0}addHandler(j,$,L){let J=this.handlers.get(j);if(!J)J=[],this.handlers.set(j,J);let X={callback:$,once:L};return J.push(X),()=>{let Y=this.handlers.get(j);if(Y){let Z=Y.indexOf(X);if(Z!==-1)Y.splice(Z,1)}}}publish(...[j,$]){let L=this.handlers.get(j);if(!L||L.length===0)return;let J=!1,X=L.length;for(let Y=0;Y<X&&Y<L.length;Y++){let Z=L[Y];if(!Z)continue;if(Z.callback($),Z.once)J=!0}if(J){for(let Y=L.length-1;Y>=0;Y--)if(L[Y]?.once)L.splice(Y,1)}}clear(){this.handlers.clear()}clearEvent(j){this.handlers.delete(j)}}function $j(j){return{[q]:j}}function Lj(j){return typeof j==="object"&&j!==null&&"factory"in j&&typeof j.factory==="function"}function Jj(j){return typeof j==="object"&&j!==null&&q in j}function u(j,$){let L=[],J=new Set,X=new Set;function Y(Z,B=[]){if(J.has(Z))return;if(X.has(Z))throw Error(`Circular resource dependency: ${[...B,Z].join(" -> ")}`);X.add(Z);for(let K of $(Z)){let U=j.find((W)=>W===K);if(U)Y(U,[...B,Z])}X.delete(Z),J.add(Z),L.push(Z)}for(let Z of j)Y(Z);return L}class R{resources=new Map;resourceFactories=new Map;resourceDependencies=new Map;resourceDisposers=new Map;initializedResourceKeys=new Set;add(j,$){let L=(J)=>{this.resources.set(j,J),this.initializedResourceKeys.add(j),this.resourceDependencies.set(j,[])};if(Lj($)){if(this.resourceFactories.set(j,$.factory),this.resourceDependencies.set(j,$.dependsOn??[]),$.onDispose)this.resourceDisposers.set(j,$.onDispose)}else if(Jj($))L($[q]);else if(typeof $==="function")this.resourceFactories.set(j,$),this.resourceDependencies.set(j,[]);else L($);return this}tryGet(j,...$){if(!this.has(j))return;return this.get(j,...$)}get(j,...$){let L=this.resources.get(j);if(L!==void 0)return L;let J=this.resourceFactories.get(j);if(J===void 0)throw Error(`Resource ${String(j)} not found`);let X=$[0],Y=J(X);if(!(Y instanceof Promise))this.resources.set(j,Y),this.initializedResourceKeys.add(j);return Y}has(j){return this.resources.has(j)||this.resourceFactories.has(j)}remove(j){let $=this.resources.delete(j),L=this.resourceFactories.delete(j);return this.resourceDependencies.delete(j),this.resourceDisposers.delete(j),this.initializedResourceKeys.delete(j),$||L}getKeys(){let j=new Set([...this.resources.keys(),...this.resourceFactories.keys()]);return Array.from(j)}needsInitialization(j){return this.resourceFactories.has(j)&&!this.initializedResourceKeys.has(j)}getPendingInitializationKeys(){return Array.from(this.resourceFactories.keys()).filter((j)=>!this.initializedResourceKeys.has(j))}async initializeResource(j,...$){if(!this.resourceFactories.has(j)||this.initializedResourceKeys.has(j))return;let L=this.resourceFactories.get(j);if(!L)return;let J=$[0],X=await L(J);this.resources.set(j,X),this.initializedResourceKeys.add(j),this.resourceFactories.delete(j)}async initializeResources(...j){let $=j.slice(1),L=$.length===0?this.getPendingInitializationKeys():$;if(L.length===0)return;let J=u(L,(X)=>[...this.resourceDependencies.get(X)??[]]);for(let X of J)await this.initializeResource(X,...j.slice(0,1))}getDependencies(j){return this.resourceDependencies.get(j)??[]}async disposeResource(j,...$){if(!this.resources.has(j)&&!this.resourceFactories.has(j))return!1;if(this.initializedResourceKeys.has(j)){let L=this.resourceDisposers.get(j),J=this.resources.get(j);if(L&&J!==void 0){let X=$[0];await L(J,X)}}return this.resources.delete(j),this.resourceFactories.delete(j),this.resourceDependencies.delete(j),this.resourceDisposers.delete(j),this.initializedResourceKeys.delete(j),!0}async disposeResources(...j){let $=Array.from(this.initializedResourceKeys);if($.length===0)return;let L=u($,(J)=>[...this.resourceDependencies.get(J)??[]]).reverse();for(let J of L)await this.disposeResource(J,...j)}}var q;var v=V(()=>{q=Symbol("resource-direct")});class S{queries=new Map;entityManager;_hasParentHasQueries=!1;constructor(j){this.entityManager=j}get hasParentHasQueries(){return this._hasParentHasQueries}addQuery(j,$){let L={definition:$,matchingEntities:new Set};if(this.queries.set(j,L),$.parentHas?.length)this._hasParentHasQueries=!0;let J=this.entityManager.getEntitiesWithQuery($.with,$.without??[]);for(let X of J)if(this.entityMatchesQuery(X,L.definition))L.matchingEntities.add(X.id),L.definition.onEnter?.(X)}removeQuery(j){let $=this.queries.delete(j);if($)this._recalcParentHasFlag();return $}entityMatchesQuery(j,$){for(let L of $.with)if(!(L in j.components))return!1;if($.without){for(let L of $.without)if(L in j.components)return!1}if($.parentHas?.length){let L=this.entityManager.getParent(j.id);if(L===null)return!1;let J=this.entityManager.getEntity(L);if(!J)return!1;for(let X of $.parentHas)if(!(X in J.components))return!1}return!0}_applyQueryTransition(j,$){let L=$.matchingEntities.has(j.id),J=this.entityMatchesQuery(j,$.definition);if(!L&&J)$.matchingEntities.add(j.id),$.definition.onEnter?.(j);else if(L&&!J)$.matchingEntities.delete(j.id),$.definition.onExit?.(j.id)}onComponentAdded(j,$){for(let[,L]of this.queries)this._applyQueryTransition(j,L);if(this._hasParentHasQueries)this._recheckChildren(j.id)}onComponentRemoved(j,$){for(let[,L]of this.queries)this._applyQueryTransition(j,L);if(this._hasParentHasQueries)this._recheckChildren(j.id)}onEntityRemoved(j){for(let[$,L]of this.queries)if(L.matchingEntities.has(j))L.matchingEntities.delete(j),L.definition.onExit?.(j)}recheckEntity(j){for(let[,$]of this.queries)this._applyQueryTransition(j,$)}recheckEntityAndChildren(j){if(this.recheckEntity(j),this._hasParentHasQueries)this._recheckChildren(j.id)}_recheckChildren(j){let $=this.entityManager.getChildren(j);for(let L of $){let J=this.entityManager.getEntity(L);if(J)this.recheckEntity(J)}}_recalcParentHasFlag(){this._hasParentHasQueries=!1;for(let[,j]of this.queries)if(j.definition.parentHas?.length){this._hasParentHasQueries=!0;return}}}class x{commands=[];removeEntity(j,$){this.commands.push((L)=>{L.removeEntity(j,$)})}addComponent(j,$,L){this.commands.push((J)=>{J.addComponent(j,$,L)})}removeComponent(j,$){this.commands.push((L)=>{L.removeComponent(j,$)})}spawn(j){this.commands.push(($)=>{$.spawn(j)})}spawnChild(j,$){this.commands.push((L)=>{L.spawnChild(j,$)})}addComponents(j,$){this.commands.push((L)=>{L.addComponents(j,$)})}setParent(j,$){this.commands.push((L)=>{L.setParent(j,$)})}mutateComponent(j,$,L){this.commands.push((J)=>{J.mutateComponent(j,$,L)})}markChanged(j,$){this.commands.push((L)=>{L.markChanged(j,$)})}removeParent(j){this.commands.push(($)=>{$.removeParent(j)})}playback(j){for(let $ of this.commands)try{$(j)}catch(L){console.warn("CommandBuffer: Command failed during playback:",L)}this.commands=[]}clear(){this.commands=[]}get length(){return this.commands.length}}function z(j){return j}class T{_label;queries={};processFunction;detachFunction;initializeFunction;eventHandlers;_priority=0;_phase="update";_groups=[];_inScreens;_excludeScreens;_requiredAssets;_runWhenEmpty=!1;_entityEnterHandlers={};_resourceKeys;constructor(j){this._label=j}get label(){return this._label}_createSystemObject(){let j={label:this._label,entityQueries:this.queries,priority:this._priority,phase:this._phase};if(this.processFunction)j.process=this.processFunction;if(this.detachFunction)j.onDetach=this.detachFunction;if(this.initializeFunction)j.onInitialize=this.initializeFunction;if(this.eventHandlers)j.eventHandlers=this.eventHandlers;if(this._groups.length>0)j.groups=[...this._groups];if(this._inScreens)j.inScreens=this._inScreens;if(this._excludeScreens)j.excludeScreens=this._excludeScreens;if(this._requiredAssets)j.requiredAssets=this._requiredAssets;if(this._runWhenEmpty)j.runWhenEmpty=!0;if(Object.keys(this._entityEnterHandlers).length>0)j.onEntityEnter={...this._entityEnterHandlers};return j}setPriority(j){return this._priority=j,this}inPhase(j){return this._phase=j,this}inGroup(j){if(!this._groups.includes(j))this._groups.push(j);return this}inScreens(j){return this._inScreens=[...j],this}excludeScreens(j){return this._excludeScreens=[...j],this}requiresAssets(j){return this._requiredAssets=[...j],this}runWhenEmpty(){return this._runWhenEmpty=!0,this}withResources(j){return this._resourceKeys=[...j],this}addQuery(j,$){let L=this;return L.queries={...this.queries,[j]:$},L}setProcess(j){if(this._resourceKeys?.length){let $=this._resourceKeys,L;this.processFunction=(J)=>{if(!L){L={};for(let X of $)L[X]=J.ecs.getResource(X)}J.resources=L,j(J)}}else this.processFunction=j;return this}setOnEntityEnter(j,$){return this._entityEnterHandlers[j]=$,this}setOnDetach(j){return this.detachFunction=j,this}setOnInitialize(j){return this.initializeFunction=j,this}setEventHandlers(j){return this.eventHandlers=j,this}}function I(j,$,L){let J=new Set,X=[$];while(X.length>0){let Y=X.pop();if(Y===void 0)break;if(Y===j)throw Error(`Circular required component dependency: '${String(j)}' -> '${String($)}' -> ... -> '${String(j)}'`);if(J.has(Y))continue;J.add(Y);let Z=L(Y);if(Z)for(let B of Z)X.push(B.component)}}var m="0.12.0";var p=()=>{};class O{assets=new Map;groups=new Map;eventBus=null;setEventBus(j){this.eventBus=j}register(j,$){if(this.assets.set(j,{definition:$,status:"pending"}),$.group){let L=this.groups.get($.group)??new Set;L.add(j),this.groups.set($.group,L)}}async loadEagerAssets(){let j=[];for(let[$,L]of this.assets)if(L.definition.eager&&L.status==="pending")j.push($);await Promise.all(j.map(($)=>this.loadAsset($)))}async loadAsset(j){let $=this.assets.get(j);if(!$)throw Error(`Asset '${String(j)}' not found`);if($.status==="loaded"&&$.value!==void 0)return $.value;if($.status==="loading"&&$.loadPromise)return $.loadPromise;if($.status==="failed")$.status="pending";$.status="loading",$.loadPromise=$.definition.loader();try{let L=await $.loadPromise;return $.value=L,$.status="loaded",$.loadPromise=void 0,this.eventBus?.publish("assetLoaded",{key:j}),this.checkGroupProgress($.definition.group),L}catch(L){let J=L instanceof Error?L:Error(String(L));throw $.status="failed",$.error=J,$.loadPromise=void 0,this.eventBus?.publish("assetFailed",{key:j,error:J}),J}}async loadAssetGroup(j){let $=this.groups.get(j);if(!$||$.size===0)throw Error(`Asset group '${j}' not found or empty`);await Promise.all(Array.from($).map((L)=>this.loadAsset(L)))}get(j){let $=this.assets.get(j);if(!$)throw Error(`Asset '${String(j)}' not found`);if($.status!=="loaded"||$.value===void 0)throw Error(`Asset '${String(j)}' is not loaded (status: ${$.status})`);return $.value}tryGet(j){let $=this.assets.get(j);if(!$||$.status!=="loaded")return;return $.value}getHandle(j){let $=this.assets.get(j);if(!$)throw Error(`Asset '${String(j)}' not found`);let L=this;return{get status(){return $.status},get isLoaded(){return $.status==="loaded"},get(){return L.get(j)},tryGet(){return L.tryGet(j)}}}getStatus(j){let $=this.assets.get(j);if(!$)throw Error(`Asset '${String(j)}' not found`);return $.status}isLoaded(j){return this.assets.get(j)?.status==="loaded"}isGroupLoaded(j){let $=this.groups.get(j);if(!$||$.size===0)return!1;for(let L of $){let J=this.assets.get(L);if(!J||J.status!=="loaded")return!1}return!0}getGroupProgress(j){return this.getGroupProgressDetails(j).progress}getGroupProgressDetails(j){let $=this.groups.get(j);if(!$||$.size===0)return{loaded:0,total:0,progress:0};let L=0;for(let X of $)if(this.assets.get(X)?.status==="loaded")L++;let J=$.size;return{loaded:L,total:J,progress:L/J}}checkGroupProgress(j){if(!j||!this.eventBus)return;let $=j,L=this.getGroupProgressDetails($);if(this.eventBus.publish("assetGroupProgress",{group:$,...L}),L.loaded===L.total)this.eventBus.publish("assetGroupLoaded",{group:$})}createResource(){let j=this;return{getStatus($){return j.getStatus($)},isLoaded($){return j.isLoaded($)},isGroupLoaded($){return j.isGroupLoaded($)},getGroupProgress($){return j.getGroupProgress($)},get($){return j.get($)},tryGet($){return j.tryGet($)},getHandle($){return j.getHandle($)}}}getKeys(){return Array.from(this.assets.keys())}getGroupNames(){return Array.from(this.groups.keys())}getGroupKeys(j){let $=this.groups.get(j);return $?Array.from($):[]}}class l{manager;constructor(j){this.manager=j}add(j,$){return this.manager.register(j,{loader:$,eager:!0}),this}addWithConfig(j,$){return this.manager.register(j,$),this}addGroup(j,$){for(let[L,J]of Object.entries($))this.manager.register(L,{loader:J,eager:!1,group:j});return this}getManager(){return this.manager}}function f(j){return new l(j??new O)}class P{screens=new Map;currentScreen=null;screenStack=[];eventBus=null;assetManager=null;ecs=null;setDependencies(j,$,L){this.eventBus=j,this.assetManager=$,this.ecs=L}requireEcs(){if(!this.ecs)throw Error("ScreenManager: dependencies not set. Call setDependencies() first.");return this.ecs}register(j,$){this.screens.set(j,{definition:$})}async setScreen(j,$){let L=this.screens.get(j);if(!L)throw Error(`Screen '${String(j)}' not found`);await this.verifyRequiredAssets(L.definition);while(this.screenStack.length>0){let X=this.screenStack.pop();if(X)await this.exitScreen(X.name)}if(this.currentScreen)await this.exitScreen(this.currentScreen.name);let J=L.definition.initialState($);this.currentScreen={name:j,config:$,state:J},await L.definition.onEnter?.({config:$,ecs:this.requireEcs()}),this.eventBus?.publish("screenEnter",{screen:j,config:$})}async pushScreen(j,$){let L=this.screens.get(j);if(!L)throw Error(`Screen '${String(j)}' not found`);if(await this.verifyRequiredAssets(L.definition),this.currentScreen)this.screenStack.push(this.currentScreen);let J=L.definition.initialState($);this.currentScreen={name:j,config:$,state:J},await L.definition.onEnter?.({config:$,ecs:this.requireEcs()}),this.eventBus?.publish("screenPush",{screen:j,config:$})}async popScreen(){if(this.screenStack.length===0)throw Error("Cannot pop screen: stack is empty");if(this.currentScreen)await this.exitScreen(this.currentScreen.name),this.eventBus?.publish("screenPop",{screen:this.currentScreen.name});this.currentScreen=this.screenStack.pop()??null}async exitScreen(j){let $=this.screens.get(j);if($?.definition.onExit)await $.definition.onExit(this.requireEcs());this.eventBus?.publish("screenExit",{screen:j})}async verifyRequiredAssets(j){if(!this.assetManager)return;if(j.requiredAssets){for(let $ of j.requiredAssets)if(!this.assetManager.isLoaded($))await this.assetManager.loadAsset($)}if(j.requiredAssetGroups){for(let $ of j.requiredAssetGroups)if(!this.assetManager.isGroupLoaded($))await this.assetManager.loadAssetGroup($)}}getCurrentScreen(){return this.currentScreen?.name??null}getConfig(j){if(!this.currentScreen)throw Error("No current screen");if(j!==void 0&&this.currentScreen.name!==j)throw Error(`Expected current screen '${String(j)}', but current is '${String(this.currentScreen.name)}'`);return this.currentScreen.config}tryGetConfig(j){if(!this.currentScreen)return;if(j!==void 0&&this.currentScreen.name!==j)return;return this.currentScreen.config}getState(j){if(!this.currentScreen)throw Error("No current screen");if(j!==void 0&&this.currentScreen.name!==j)throw Error(`Expected current screen '${String(j)}', but current is '${String(this.currentScreen.name)}'`);return this.currentScreen.state}tryGetState(j){if(!this.currentScreen)return;if(j!==void 0&&this.currentScreen.name!==j)return;return this.currentScreen.state}updateState(j,$){if(!this.currentScreen)throw Error("No current screen");if($!==void 0&&this.currentScreen.name!==$)throw Error(`Expected current screen '${String($)}', but current is '${String(this.currentScreen.name)}'`);let L=typeof j==="function"?j(this.currentScreen.state):j;this.currentScreen.state={...this.currentScreen.state,...L}}getStackDepth(){return this.screenStack.length}isOverlay(){return this.screenStack.length>0}isActive(j){if(this.currentScreen?.name===j)return!0;return this.screenStack.some(($)=>$.name===j)}isCurrent(j){return this.currentScreen?.name===j}createResource(){let j=this;return{get current(){return j.getCurrentScreen()},get config(){return j.tryGetConfig()??null},get state(){return j.tryGetState()??null},set state($){if(j.currentScreen&&$!==null)j.currentScreen.state=$},get stack(){return j.screenStack},get isOverlay(){return j.isOverlay()},get stackDepth(){return j.getStackDepth()},isActive($){return j.isActive($)},isCurrent($){return j.isCurrent($)}}}getScreenNames(){return Array.from(this.screens.keys())}hasScreen(j){return this.screens.has(j)}}class s{manager;constructor(j){this.manager=j}add(j,$){return this.manager.register(j,$),this}getManager(){return this.manager}}function b(j){return new s(j??new P)}class N{ecspresso;assetConfigurator=null;screenConfigurator=null;pendingResources=[];pendingDisposeCallbacks=[];pendingRequiredComponents=[];pendingPlugins=[];_fixedDt=null;constructor(){let{default:j}=(g(),t(c));this.ecspresso=new j}withPlugin(j){return this.pendingPlugins.push(j),this}withComponentTypes(){return this}withEventTypes(){return this}withResourceTypes(){return this}withResource(j,$){return this.pendingResources.push({key:j,value:$}),this}withDispose(j,$){return this.pendingDisposeCallbacks.push({key:j,callback:$}),this}withRequired(j,$,L){return this.pendingRequiredComponents.push({trigger:j,required:$,factory:L}),this}withAssets(j){let $=f();return j($),this.assetConfigurator=$,this}withScreens(j){let $=b();return j($),this.screenConfigurator=$,this}withFixedTimestep(j){return this._fixedDt=j,this}withReactiveQueryNames(){return this}pluginFactory(){return z}build(){for(let j of this.pendingPlugins)this.ecspresso.installPlugin(j);for(let{key:j,value:$}of this.pendingResources)this.ecspresso.addResource(j,$);for(let{key:j,callback:$}of this.pendingDisposeCallbacks)this.ecspresso.registerDispose(j,$);for(let{trigger:j,required:$,factory:L}of this.pendingRequiredComponents)this.ecspresso.registerRequired(j,$,L);if(this.assetConfigurator)this.ecspresso._setAssetManager(this.assetConfigurator.getManager());else if(this.ecspresso._hasPendingPluginAssets())this.ecspresso._setAssetManager(new O);if(this.screenConfigurator)this.ecspresso._setScreenManager(this.screenConfigurator.getManager());else if(this.ecspresso._hasPendingPluginScreens())this.ecspresso._setScreenManager(new P);if(this._fixedDt!==null)this.ecspresso._setFixedDt(this._fixedDt);return this.ecspresso}}var y=()=>{};var c={};jj(c,{default:()=>M});var d,M;var g=V(()=>{h();v();p();y();d=["preUpdate","fixedUpdate","update","postUpdate","render"];M=class M{static VERSION=m;_entityManager;_eventBus;_resourceManager;_commandBuffer;_systems=[];_phaseSystems={preUpdate:[],fixedUpdate:[],update:[],postUpdate:[],render:[]};_installedPlugins=new Set;_disabledGroups=new Set;_assetManager=null;_screenManager=null;_reactiveQueryManager;_postUpdateHooks=[];_currentTick=0;_systemLastSeqs=new Map;_changeThreshold=0;_fixedDt=0.016666666666666666;_fixedAccumulator=0;_interpolationAlpha=0;_maxFixedSteps=8;_requiredComponents=new Map;_pendingPluginAssets=[];_pendingPluginScreens=[];_diagnosticsEnabled=!1;_systemTimings=new Map;_phaseTimings={preUpdate:0,fixedUpdate:0,update:0,postUpdate:0,render:0};_entityEnterTracking=new Map;_entityEnterFrameSet=new Set;_systemContexts=new WeakMap;_pendingFinalizers=[];_batchingRegistrations=!1;constructor(){this._entityManager=new E,this._eventBus=new w,this._resourceManager=new R,this._reactiveQueryManager=new S(this._entityManager),this._commandBuffer=new x,this._subscribeLifecycleHooks()}_subscribeLifecycleHooks(){this._entityManager.onAfterComponentAdded((j,$)=>{this._entityManager.markChanged(j,$);let L=this._requiredComponents.get($);if(L){let J=this._entityManager.getEntity(j);if(J){let X=J.components[$];for(let{component:Y,factory:Z}of L){if(this._entityManager._pendingBatchKeys?.has(Y))continue;if(!(Y in J.components))this._entityManager.addComponent(j,Y,Z(X))}}}}),this._entityManager.onAfterEntityMutated((j)=>{let $=this._entityManager.getEntity(j);if($)this._reactiveQueryManager.recheckEntityAndChildren($)}),this._entityManager.onAfterComponentRemoved((j,$)=>{let L=this._entityManager.getEntity(j);if(L)this._reactiveQueryManager.onComponentRemoved(L,$)}),this._entityManager.onBeforeEntityRemoved((j)=>{this._reactiveQueryManager.onEntityRemoved(j)}),this._entityManager.onAfterParentChanged((j)=>{if(this._reactiveQueryManager.hasParentHasQueries){let $=this._entityManager.getEntity(j);if($)this._reactiveQueryManager.recheckEntity($)}})}static create(){return new N}addSystem(j){let $=new T(j);return this._pendingFinalizers.push(()=>{this._registerSystem($._createSystemObject())}),$}_finalizePendingBuilders(){if(this._pendingFinalizers.length===0)return;this._batchingRegistrations=!0;while(this._pendingFinalizers.length>0){let j=this._pendingFinalizers;this._pendingFinalizers=[];for(let $ of j)$()}this._batchingRegistrations=!1,this._rebuildPhaseSystems()}update(j){this._finalizePendingBuilders();let $=this._screenManager?.getCurrentScreen()??null,L=this._diagnosticsEnabled;this._runPhase("preUpdate",j,$,L);let J=L?performance.now():0;this._fixedAccumulator+=j;let X=0;while(this._fixedAccumulator>=this._fixedDt&&X<this._maxFixedSteps)this._executePhase(this._phaseSystems.fixedUpdate,this._fixedDt,$),this._commandBuffer.playback(this),this._fixedAccumulator-=this._fixedDt,X++;if(this._fixedAccumulator>=this._fixedDt)this._fixedAccumulator=0;if(L)this._phaseTimings.fixedUpdate=performance.now()-J;this._interpolationAlpha=this._fixedAccumulator/this._fixedDt,this._runPhase("update",j,$,L),this._runPhase("postUpdate",j,$,L);for(let Y of this._postUpdateHooks)Y({ecs:this,dt:j});this._runPhase("render",j,$,L),this._changeThreshold=this._entityManager.changeSeq,this._currentTick++}_executePhase(j,$,L){for(let J of j){if(!J.process&&!J.onEntityEnter)continue;if(J.groups?.length){let W=!1;for(let F of J.groups)if(this._disabledGroups.has(F)){W=!0;break}if(W)continue}if(J.inScreens?.length){if(L===null||!J.inScreens.includes(L))continue}if(J.excludeScreens?.length){if(L!==null&&J.excludeScreens.includes(L))continue}if(J.requiredAssets?.length&&this._assetManager){let W=!0;for(let F of J.requiredAssets)if(!this._assetManager.isLoaded(F)){W=!1;break}if(!W)continue}let X=this._systemLastSeqs.get(J)??0;this._changeThreshold=X;let Y=this._systemContexts.get(J);if(!Y)Y={queries:{},dt:0,ecs:this},this._systemContexts.set(J,Y);Y.dt=$;let Z=Y.queries,B=!1,K=!1;if(J.entityQueries)for(let W in J.entityQueries){K=!0;let F=J.entityQueries[W];if(F){if(Z[W]=this._entityManager.getEntitiesWithQuery(F.with,F.without||[],F.changed,F.changed?this._changeThreshold:void 0,F.parentHas),Z[W].length)B=!0}}let U=this._entityEnterTracking.get(J);if(U&&J.onEntityEnter)for(let W in J.onEntityEnter){let F=Z[W],D=U.get(W);if(!F||!D)continue;let _=J.onEntityEnter[W];if(!_)continue;let Q=this._entityEnterFrameSet;Q.clear();for(let A of F)if(Q.add(A.id),!D.has(A.id))D.add(A.id),_({entity:A,ecs:this});for(let A of D)if(!Q.has(A))D.delete(A)}if(J.process){if(this._diagnosticsEnabled){let W=performance.now();if(B||J.runWhenEmpty)J.process(Y);else if(!K)J.process(Y);this._systemTimings.set(J.label,performance.now()-W)}else if(B||J.runWhenEmpty)J.process(Y);else if(!K)J.process(Y)}this._systemLastSeqs.set(J,this._entityManager.changeSeq)}}_runPhase(j,$,L,J){if(J){let X=performance.now();this._executePhase(this._phaseSystems[j],$,L),this._phaseTimings[j]=performance.now()-X}else this._executePhase(this._phaseSystems[j],$,L);this._commandBuffer.playback(this)}async initialize(){if(this._finalizePendingBuilders(),await this.initializeResources(),this._assetManager)this._assetManager.setEventBus(this._eventBus),await this._assetManager.loadEagerAssets(),this._resourceManager.add("$assets",this._assetManager.createResource());if(this._screenManager)this._screenManager.setDependencies(this._eventBus,this._assetManager,this),this._resourceManager.add("$screen",this._screenManager.createResource());for(let j of this._systems)await j.onInitialize?.(this)}async initializeResources(...j){await this._resourceManager.initializeResources(this,...j)}_rebuildPhaseSystems(){for(let j of d)this._phaseSystems[j]=[];for(let j of this._systems){let $=j.phase??"update";this._phaseSystems[$].push(j)}for(let j of d)this._phaseSystems[j].sort(($,L)=>{let J=$.priority??0;return(L.priority??0)-J})}updateSystemPriority(j,$){this._finalizePendingBuilders();let L=this._systems.find((J)=>J.label===j);if(!L)return!1;return L.priority=$,this._rebuildPhaseSystems(),!0}updateSystemPhase(j,$){this._finalizePendingBuilders();let L=this._systems.find((J)=>J.label===j);if(!L)return!1;return L.phase=$,this._rebuildPhaseSystems(),!0}get interpolationAlpha(){return this._interpolationAlpha}get fixedDt(){return this._fixedDt}disableSystemGroup(j){this._disabledGroups.add(j)}enableSystemGroup(j){this._disabledGroups.delete(j)}isSystemGroupEnabled(j){return!this._disabledGroups.has(j)}getSystemsInGroup(j){return this._finalizePendingBuilders(),this._systems.filter(($)=>$.groups?.includes(j)).map(($)=>$.label)}removeSystem(j){this._finalizePendingBuilders();let $=this._systems.findIndex((J)=>J.label===j);if($===-1)return!1;let L=this._systems[$];if(!L)return!1;if(L.onDetach)L.onDetach(this);return this._systems.splice($,1),this._systemLastSeqs.delete(L),this._entityEnterTracking.delete(L),this._rebuildPhaseSystems(),!0}_registerSystem(j){if(this._systems.push(j),this._systemLastSeqs.set(j,this._changeThreshold),!this._batchingRegistrations)this._rebuildPhaseSystems();if(j.onEntityEnter){let $=new Map;for(let L in j.onEntityEnter)$.set(L,new Set);this._entityEnterTracking.set(j,$)}if(!j.eventHandlers)return;for(let $ in j.eventHandlers){let L=j.eventHandlers[$];if(L)this._eventBus.subscribe($,(J)=>{L({data:J,ecs:this})})}}hasResource(j){return this._resourceManager.has(j)}getResource(j){if(!this._resourceManager.has(j))throw Error(`Resource '${String(j)}' not found. Available resources: [${this.getResourceKeys().map(($)=>String($)).join(", ")}]`);return this._resourceManager.get(j,this)}tryGetResource(j){let $=j;if(!this._resourceManager.has($))return;return this._resourceManager.get($,this)}addResource(j,$){return this._resourceManager.add(j,$),this}removeResource(j){return this._resourceManager.remove(j)}async disposeResource(j){return this._resourceManager.disposeResource(j,this)}async disposeResources(){return this._resourceManager.disposeResources(this)}updateResource(j,$){let L=this.getResource(j),J=$(L);return this._resourceManager.add(j,J),this}getResourceKeys(){return this._resourceManager.getKeys()}resourceNeedsInitialization(j){return this._resourceManager.needsInitialization(j)}getComponent(j,$){return this._entityManager.getComponent(j,$)}addComponent(j,$,L){this._entityManager.addComponent(j,$,L)}addComponents(j,$){this._entityManager.addComponents(j,$)}removeComponent(j,$){this._entityManager.removeComponent(j,$)}hasComponent(j,$){return this._entityManager.getComponent(j,$)!==void 0}spawn(j){let $=this._entityManager.createEntity();return this._entityManager.addComponents($.id,j),$}getEntitiesWithQuery(j,$=[],L,J){return this._entityManager.getEntitiesWithQuery(j,$,L,L?this._changeThreshold:void 0,J)}getSingleton(j,$=[]){let L=this._entityManager.getEntitiesWithQuery(j,$);if(L.length===0)throw Error(`getSingleton: no entity matches query with=[${String(j)}] without=[${String($)}]`);if(L.length>1)throw Error(`getSingleton: expected 1 entity but found ${L.length} matching query with=[${String(j)}] without=[${String($)}]`);let J=L[0];if(!J)throw Error("getSingleton: unexpected empty result");return J}tryGetSingleton(j,$=[]){let L=this._entityManager.getEntitiesWithQuery(j,$);if(L.length===0)return;if(L.length>1)throw Error(`tryGetSingleton: expected 0 or 1 entity but found ${L.length} matching query with=[${String(j)}] without=[${String($)}]`);return L[0]}removeEntity(j,$){return this._entityManager.removeEntity(j,$)}spawnChild(j,$){let L=this._entityManager.spawnChild(j,$);return this._emitHierarchyChanged(L.id,null,j),L}setParent(j,$){let L=this._entityManager.getParent(j);return this._entityManager.setParent(j,$),this._emitHierarchyChanged(j,L,$),this}removeParent(j){let $=this._entityManager.getParent(j),L=this._entityManager.removeParent(j);if(L)this._emitHierarchyChanged(j,$,null);return L}getParent(j){return this._entityManager.getParent(j)}getChildren(j){return this._entityManager.getChildren(j)}getChildAt(j,$){return this._entityManager.getChildAt(j,$)}getChildIndex(j,$){return this._entityManager.getChildIndex(j,$)}getAncestors(j){return this._entityManager.getAncestors(j)}getDescendants(j){return this._entityManager.getDescendants(j)}getRoot(j){return this._entityManager.getRoot(j)}getSiblings(j){return this._entityManager.getSiblings(j)}isDescendantOf(j,$){return this._entityManager.isDescendantOf(j,$)}isAncestorOf(j,$){return this._entityManager.isAncestorOf(j,$)}getRootEntities(){return this._entityManager.getRootEntities()}forEachInHierarchy(j,$){this._entityManager.forEachInHierarchy(j,$)}hierarchyIterator(j){return this._entityManager.hierarchyIterator(j)}_emitHierarchyChanged(j,$,L){this._eventBus.publish("hierarchyChanged",{entityId:j,oldParent:$,newParent:L})}get installedPlugins(){return Array.from(this._installedPlugins)}get entityManager(){return this._entityManager}get eventBus(){return this._finalizePendingBuilders(),this._eventBus}get commands(){return this._commandBuffer}get currentTick(){return this._currentTick}get changeThreshold(){return this._changeThreshold}enableDiagnostics(j){if(this._diagnosticsEnabled=j,!j)this._systemTimings.clear(),this._phaseTimings={preUpdate:0,fixedUpdate:0,update:0,postUpdate:0,render:0}}get diagnosticsEnabled(){return this._diagnosticsEnabled}get systemTimings(){return this._systemTimings}get phaseTimings(){return this._phaseTimings}get entityCount(){return this._entityManager.entityCount}mutateComponent(j,$,L){let J=this._entityManager.getComponent(j,$);if(J===void 0)throw Error(`Entity ${j} does not have component "${String($)}"`);return L(J),this._entityManager.markChanged(j,$),J}markChanged(j,$){this._entityManager.markChanged(j,$)}registerDispose(j,$){this._entityManager.registerDispose(j,$)}registerRequired(j,$,L){if(String(j)===String($))throw Error(`Cannot require a component to depend on itself: '${String(j)}'`);let J=this._requiredComponents.get(j)??[];if(J.some((X)=>X.component===$))throw Error(`Required component '${String($)}' already registered for trigger '${String(j)}'`);this._checkRequiredCycle(j,$),J.push({component:$,factory:L}),this._requiredComponents.set(j,J)}_checkRequiredCycle(j,$){I(j,$,(L)=>this._requiredComponents.get(L))}onComponentAdded(j,$){return this._entityManager.onComponentAdded(j,$)}onComponentRemoved(j,$){return this._entityManager.onComponentRemoved(j,$)}addReactiveQuery(j,$){this._reactiveQueryManager.addQuery(j,$)}removeReactiveQuery(j){return this._reactiveQueryManager.removeQuery(j)}on(j,$){return this._eventBus.subscribe(j,$)}off(j,$){return this._eventBus.unsubscribe(j,$)}onPostUpdate(j){return this._postUpdateHooks.push(j),()=>{let $=this._postUpdateHooks.indexOf(j);if($!==-1)this._postUpdateHooks.splice($,1)}}requireAssetManager(){if(!this._assetManager)throw Error("Asset manager not configured. Use withAssets() in builder.");return this._assetManager}getAsset(j){return this.requireAssetManager().get(j)}tryGetAsset(j){return this._assetManager?.tryGet(j)}getAssetHandle(j){return this.requireAssetManager().getHandle(j)}isAssetLoaded(j){return this._assetManager?.isLoaded(j)??!1}async loadAsset(j){return this.requireAssetManager().loadAsset(j)}async loadAssetGroup(j){return this.requireAssetManager().loadAssetGroup(j)}isAssetGroupLoaded(j){return this._assetManager?.isGroupLoaded(j)??!1}getAssetGroupProgress(j){return this._assetManager?.getGroupProgress(j)??0}requireScreenManager(){if(!this._screenManager)throw Error("Screen manager not configured. Use withScreens() in builder.");return this._screenManager}async setScreen(j,$){return this.requireScreenManager().setScreen(j,$)}async pushScreen(j,$){return this.requireScreenManager().pushScreen(j,$)}async popScreen(){return this.requireScreenManager().popScreen()}getCurrentScreen(){return this._screenManager?.getCurrentScreen()??null}getScreenConfig(j){return this.requireScreenManager().getConfig(j)}tryGetScreenConfig(j){return this._screenManager?.tryGetConfig(j)??void 0}getScreenState(j){return this.requireScreenManager().getState(j)}tryGetScreenState(j){return this._screenManager?.tryGetState(j)??void 0}updateScreenState(j,$){if(typeof j==="string")this.requireScreenManager().updateState($,j);else this.requireScreenManager().updateState(j)}isCurrentScreen(j){return this._screenManager?.isCurrent(j)??!1}isScreenActive(j){return this._screenManager?.isActive(j)??!1}getScreenStackDepth(){return this._screenManager?.getStackDepth()??0}_setAssetManager(j){this._assetManager=j;for(let[$,L]of this._pendingPluginAssets)this._assetManager.register($,L);this._pendingPluginAssets=[]}_setScreenManager(j){this._screenManager=j;for(let[$,L]of this._pendingPluginScreens)this._screenManager.register($,L);this._pendingPluginScreens=[]}_hasPendingPluginAssets(){return this._pendingPluginAssets.length>0}_hasPendingPluginScreens(){return this._pendingPluginScreens.length>0}_setFixedDt(j){this._fixedDt=j}_registerAsset(j,$){this._pendingPluginAssets.push([j,$])}_registerScreen(j,$){this._pendingPluginScreens.push([j,$])}installPlugin(j){if(this._installedPlugins.has(j.id))return this;return this._installedPlugins.add(j.id),j.install(this),this}pluginFactory(){return z}getHelpers(j){return j(this)}}});g();function kj(j){return j}function uj(j,$){return{x:j,y:$}}function Ij(){return{x:0,y:0}}function pj(j,$){return{x:j.x+$.x,y:j.y+$.y}}function mj(j,$){return{x:j.x-$.x,y:j.y-$.y}}function lj(j,$){return{x:j.x*$,y:j.y*$}}function sj(j){return{x:-j.x,y:-j.y}}function yj(j,$){return j.x*$.x+j.y*$.y}function cj(j,$){return j.x*$.y-j.y*$.x}function dj(j){return j.x*j.x+j.y*j.y}function ij(j){return Math.sqrt(j.x*j.x+j.y*j.y)}function oj(j){let $=Math.sqrt(j.x*j.x+j.y*j.y);if($===0)return{x:0,y:0};return{x:j.x/$,y:j.y/$}}function rj(j,$){let L=j.x-$.x,J=j.y-$.y;return L*L+J*J}function aj(j,$){let L=j.x-$.x,J=j.y-$.y;return Math.sqrt(L*L+J*J)}function tj(j,$,L=0.0000000001){return Math.abs(j.x-$.x)<=L&&Math.abs(j.y-$.y)<=L}v();var B2=M;export{Ij as vec2Zero,mj as vec2Sub,lj as vec2Scale,oj as vec2Normalize,sj as vec2Negate,dj as vec2LengthSq,ij as vec2Length,tj as vec2Equals,yj as vec2Dot,rj as vec2DistanceSq,aj as vec2Distance,cj as vec2Cross,pj as vec2Add,uj as vec2,$j as directValue,z as definePlugin,B2 as default,b as createScreenConfigurator,kj as createQueryDefinition,f as createAssetConfigurator,T as SystemBuilder,P as ScreenManager,O as AssetManager};
|
|
2
|
+
|
|
3
|
+
//# debugId=A4AFCA1F564A5FB464756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|