ecspresso 0.7.0 → 0.7.1

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/index.js.map CHANGED
@@ -12,11 +12,11 @@
12
12
  "import type ECSpresso from './ecspresso';\nimport type { RemoveEntityOptions } from './types';\n\n/**\n * CommandBuffer queues structural changes to be executed later.\n * This prevents ordering issues when modifying entities during system execution.\n *\n * Commands are executed in FIFO order when playback() is called.\n *\n * @example\n * ```typescript\n * // In a system\n * ecs.commands.removeEntity(entityId);\n * ecs.commands.spawn({ position: { x: 0, y: 0 } });\n *\n * // Later (automatically at end of update())\n * ecs.commands.playback(ecs);\n * ```\n */\nexport default class CommandBuffer<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {}\n> {\n\tprivate commands: Array<(ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes, any, any>) => void> = [];\n\n\t/**\n\t * Queue an entity removal command\n\t * @param entityId The ID of the entity to remove\n\t * @param options Optional removal options (cascade, etc.)\n\t */\n\tremoveEntity(entityId: number, options?: RemoveEntityOptions): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.removeEntity(entityId, options);\n\t\t});\n\t}\n\n\t/**\n\t * Queue a component addition command\n\t * @param entityId The ID of the entity\n\t * @param componentName The name of the component to add\n\t * @param componentValue The component data\n\t */\n\taddComponent<K extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: K,\n\t\tcomponentValue: ComponentTypes[K]\n\t): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.entityManager.addComponent(entityId, componentName, componentValue);\n\t\t});\n\t}\n\n\t/**\n\t * Queue a component removal command\n\t * @param entityId The ID of the entity\n\t * @param componentName The name of the component to remove\n\t */\n\tremoveComponent<K extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: K\n\t): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.entityManager.removeComponent(entityId, componentName);\n\t\t});\n\t}\n\n\t/**\n\t * Queue an entity spawn command\n\t * @param components The initial components for the new entity\n\t * @returns void (entity ID not available until playback)\n\t */\n\tspawn<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.spawn(components);\n\t\t});\n\t}\n\n\t/**\n\t * Queue a child entity spawn command\n\t * @param parentId The ID of the parent entity\n\t * @param components The initial components for the new child entity\n\t */\n\tspawnChild<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tparentId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.spawnChild(parentId, components);\n\t\t});\n\t}\n\n\t/**\n\t * Queue multiple component additions\n\t * @param entityId The ID of the entity\n\t * @param components Object with component names as keys and component data as values\n\t */\n\taddComponents<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tentityId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.entityManager.addComponents(entityId, components);\n\t\t});\n\t}\n\n\t/**\n\t * Queue a parent assignment command\n\t * @param childId The ID of the child entity\n\t * @param parentId The ID of the parent entity\n\t */\n\tsetParent(childId: number, parentId: number): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.setParent(childId, parentId);\n\t\t});\n\t}\n\n\t/**\n\t * Queue a parent removal command\n\t * @param childId The ID of the child entity\n\t */\n\tremoveParent(childId: number): void {\n\t\tthis.commands.push((ecs) => {\n\t\t\tecs.removeParent(childId);\n\t\t});\n\t}\n\n\t/**\n\t * Execute all queued commands in FIFO order.\n\t * Errors from individual commands are caught and logged, but do not stop playback.\n\t * @param ecs The ECSpresso instance to execute commands on\n\t */\n\tplayback<AssetTypes extends Record<string, any> = {}, ScreenStates extends Record<string, any> = {}>(\n\t\tecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>\n\t): void {\n\t\t// Execute all commands, catching errors to prevent one bad command from stopping all playback\n\t\tfor (const command of this.commands) {\n\t\t\ttry {\n\t\t\t\tcommand(ecs);\n\t\t\t} catch (error) {\n\t\t\t\t// Log error but continue with remaining commands\n\t\t\t\t// This matches Unity DOTS behavior where invalid commands are silently skipped\n\t\t\t\tconsole.warn('CommandBuffer: Command failed during playback:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Clear the queue\n\t\tthis.commands = [];\n\t}\n\n\t/**\n\t * Clear all queued commands without executing them\n\t */\n\tclear(): void {\n\t\tthis.commands = [];\n\t}\n\n\t/**\n\t * Get the number of queued commands\n\t * @returns The number of commands waiting to be executed\n\t */\n\tget length(): number {\n\t\treturn this.commands.length;\n\t}\n}\n",
13
13
  "import Bundle from \"./bundle\";\nimport ECSpresso from \"./ecspresso\";\nimport type { FilteredEntity, System } from \"./types\";\n\n/**\n * Builder class for creating type-safe ECS Systems with proper query inference\n */\nexport class SystemBuilder<\n\tComponentTypes extends Record<string, any> = Record<string, any>,\n\tEventTypes extends Record<string, any> = Record<string, any>,\n\tResourceTypes extends Record<string, any> = Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {},\n> {\n\tprivate queries: Queries = {} as Queries;\n\tprivate processFunction?: ProcessFunction<ComponentTypes, EventTypes, ResourceTypes, Queries>;\n\tprivate detachFunction?: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>;\n\tprivate initializeFunction?: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>;\n\tprivate eventHandlers?: {\n\t\t[EventName in keyof EventTypes]?: {\n\t\t\thandler(\n\t\t\t\tdata: EventTypes[EventName],\n\t\t\t\tecs: ECSpresso<\n\t\t\t\t\tComponentTypes,\n\t\t\t\t\tEventTypes,\n\t\t\t\t\tResourceTypes\n\t\t\t\t>,\n\t\t\t): void;\n\t\t};\n\t};\n\tprivate _priority = 0; // Default priority is 0\n\tprivate _isRegistered = false; // Track if system has been auto-registered\n\tprivate _groups: string[] = [];\n\tprivate _inScreens?: string[];\n\tprivate _excludeScreens?: string[];\n\tprivate _requiredAssets?: string[];\n\n\tconstructor(\n\t\tprivate _label: string,\n\t\tprivate _ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes> | null = null,\n\t\tprivate _bundle: Bundle<ComponentTypes, EventTypes, ResourceTypes> | null = null,\n\t) {}\n\n\tget label() {\n\t\treturn this._label;\n\t}\n\n\t/**\n\t * Returns the associated bundle if one was provided in the constructor\n\t */\n\tget bundle() {\n\t\treturn this._bundle;\n\t}\n\n\t/**\n\t * Returns the associated ECSpresso instance if one was provided in the constructor\n\t */\n\tget ecspresso() {\n\t\treturn this._ecspresso;\n\t}\n\n\t/**\n\t * Auto-register this system with its ECSpresso instance if not already registered\n\t * @private\n\t */\n\tprivate _autoRegister(): void {\n\t\tif (this._isRegistered || !this._ecspresso) return;\n\t\t\n\t\tconst system = this._buildSystemObject();\n\t\tregisterSystemWithEcspresso(system, this._ecspresso);\n\t\tthis._isRegistered = true;\n\t}\n\n\t/**\n\t * Create the system object without registering it\n\t * @private\n\t */\n\tprivate _buildSystemObject(): System<ComponentTypes, any, any, EventTypes, ResourceTypes> {\n\t\treturn this._createSystemObject();\n\t}\n\n\t/**\n\t * Create a system object with all configured properties\n\t * @private\n\t */\n\tprivate _createSystemObject(): System<ComponentTypes, any, any, EventTypes, ResourceTypes> {\n\t\tconst system: System<ComponentTypes, any, any, EventTypes, ResourceTypes> = {\n\t\t\tlabel: this._label,\n\t\t\tentityQueries: this.queries,\n\t\t\tpriority: this._priority,\n\t\t};\n\n\t\tif (this.processFunction) {\n\t\t\tsystem.process = this.processFunction;\n\t\t}\n\n\t\tif (this.detachFunction) {\n\t\t\tsystem.onDetach = this.detachFunction;\n\t\t}\n\n\t\tif (this.initializeFunction) {\n\t\t\tsystem.onInitialize = this.initializeFunction;\n\t\t}\n\n\t\tif (this.eventHandlers) {\n\t\t\tsystem.eventHandlers = this.eventHandlers;\n\t\t}\n\n\t\tif (this._groups.length > 0) {\n\t\t\tsystem.groups = [...this._groups];\n\t\t}\n\n\t\tif (this._inScreens) {\n\t\t\tsystem.inScreens = this._inScreens;\n\t\t}\n\n\t\tif (this._excludeScreens) {\n\t\t\tsystem.excludeScreens = this._excludeScreens;\n\t\t}\n\n\t\tif (this._requiredAssets) {\n\t\t\tsystem.requiredAssets = this._requiredAssets;\n\t\t}\n\n\t\treturn system;\n\t}\n\n\t// TODO: Should this be a setter?\n\t/**\n\t * Set the priority of this system. Systems with higher priority values\n\t * execute before those with lower values. Systems with the same priority\n\t * execute in the order they were registered.\n\t * @param priority The priority value (default: 0)\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetPriority(priority: number): this {\n\t\tthis._priority = priority;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add this system to a group. Systems can belong to multiple groups.\n\t * When any group a system belongs to is disabled, the system will be skipped.\n\t * @param groupName The name of the group to add the system to\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tinGroup(groupName: string): this {\n\t\tif (!this._groups.includes(groupName)) {\n\t\t\tthis._groups.push(groupName);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Restrict this system to only run in specified screens.\n\t * System will be skipped during update() when the current screen\n\t * is not in this list.\n\t * @param screens Array of screen names where this system should run\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tinScreens(screens: ReadonlyArray<string>): this {\n\t\tthis._inScreens = [...screens];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Exclude this system from running in specified screens.\n\t * System will be skipped during update() when the current screen\n\t * is in this list.\n\t * @param screens Array of screen names where this system should NOT run\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\texcludeScreens(screens: ReadonlyArray<string>): this {\n\t\tthis._excludeScreens = [...screens];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Require specific assets to be loaded for this system to run.\n\t * System will be skipped during update() if any required asset\n\t * is not loaded.\n\t * @param assets Array of asset keys that must be loaded\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\trequiresAssets(assets: ReadonlyArray<string>): this {\n\t\tthis._requiredAssets = [...assets];\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a query definition to the system\n\t */\n\taddQuery<\n\t\tQueryName extends string,\n\t\tWithComponents extends keyof ComponentTypes,\n\t\tWithoutComponents extends keyof ComponentTypes = never,\n\t\tNewQueries extends Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>> =\n\t\t\tQueries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>>\n\t>(\n\t\tname: QueryName,\n\t\tdefinition: {\n\t\t\twith: ReadonlyArray<WithComponents>;\n\t\t\twithout?: ReadonlyArray<WithoutComponents>;\n\t\t}\n\t): this extends SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t\t? SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, NewQueries>\n\t\t: this extends SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t\t\t? SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, NewQueries>\n\t\t\t: SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, NewQueries> {\n\t\t// Cast is needed because TypeScript can't preserve the type information\n\t\t// when modifying an object property\n\t\tconst newBuilder = this as any;\n\t\tnewBuilder.queries = {\n\t\t\t...this.queries,\n\t\t\t[name]: definition,\n\t\t};\n\t\treturn newBuilder;\n\t}\n\n\t/**\n\t * Set the system's process function that runs each update\n\t * @param process Function to process entities matching the system's queries each update\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetProcess(\n\t\tprocess: ProcessFunction<ComponentTypes, EventTypes, ResourceTypes, Queries>\n\t): this {\n\t\tthis.processFunction = process;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Register this system with its ECSpresso instance and return the ECSpresso for chaining\n\t * This enables seamless method chaining: .registerAndContinue().addSystem(...)\n\t * @returns ECSpresso instance if attached to one, otherwise throws an error\n\t */\n\tregisterAndContinue(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes> {\n\t\tif (!this._ecspresso) {\n\t\t\tthrow new Error(`Cannot register system '${this._label}': SystemBuilder is not attached to an ECSpresso instance. Use Bundle.addSystem() or ECSpresso.addSystem() instead.`);\n\t\t}\n\t\t\n\t\tthis._autoRegister();\n\t\treturn this._ecspresso;\n\t}\n\n\t/**\n\t * Complete this system and return the parent container for seamless chaining\n\t * - For ECSpresso-attached builders: registers the system and returns ECSpresso\n\t * - For Bundle-attached builders: returns the Bundle\n\t * This method is typed via the specialized interfaces (SystemBuilderWithEcspresso, SystemBuilderWithBundle)\n\t */\n\tand(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes> | Bundle<ComponentTypes, EventTypes, ResourceTypes> {\n\t\tif (this._ecspresso) {\n\t\t\tthis._autoRegister();\n\t\t\treturn this._ecspresso;\n\t\t}\n\n\t\tif (this._bundle) {\n\t\t\treturn this._bundle;\n\t\t}\n\n\t\tthrow new Error(`Cannot use and() on system '${this._label}': not attached to ECSpresso or Bundle.`);\n\t}\n\n\t/**\n\t * Set the onDetach lifecycle hook\n\t * Called when the system is removed from the ECS\n\t * @param onDetach Function to run when this system is detached from the ECS\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetOnDetach(\n\t\tonDetach: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>\n\t): this {\n\t\tthis.detachFunction = onDetach;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set the onInitialize lifecycle hook\n\t * Called when the system is initialized via ECSpresso.initialize() method\n\t * @param onInitialize Function to run when this system is initialized\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetOnInitialize(\n\t\tonInitialize: LifecycleFunction<ComponentTypes, EventTypes, ResourceTypes>\n\t): this {\n\t\tthis.initializeFunction = onInitialize;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set event handlers for the system\n\t * These handlers will be automatically subscribed when the system is attached\n\t * @param handlers Object mapping event names to handler functions\n\t * @returns This SystemBuilder instance for method chaining\n\t */\n\tsetEventHandlers(\n\t\thandlers: {\n\t\t\t[EventName in keyof EventTypes]?: {\n\t\t\t\thandler(\n\t\t\t\t\tdata: EventTypes[EventName],\n\t\t\t\t\tecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n\t\t\t\t): void;\n\t\t\t};\n\t\t}\n\t): this {\n\t\tthis.eventHandlers = handlers;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Build the final system object\n\t */\n\tbuild(ecspresso?: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) {\n\t\tconst system = this._createSystemObject();\n\n\t\tif (this._ecspresso) {\n\t\t\tregisterSystemWithEcspresso(system, this._ecspresso);\n\t\t}\n\n\t\tif(ecspresso) {\n\t\t\tregisterSystemWithEcspresso(system, ecspresso);\n\t\t}\n\n\t\treturn this;\n\t}\n}\n\n/**\n * Helper function to register a system with an ECSpresso instance\n * This handles attaching the system and setting up event handlers\n * @internal Used by SystemBuilder and Bundle\n */\nexport function registerSystemWithEcspresso<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tsystem: System<ComponentTypes, any, any, EventTypes, ResourceTypes>,\n\tecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n) {\n\t// Use the new internal registration method instead of direct property access\n\tecspresso._registerSystem(system);\n}\n\n// Helper type definitions\ntype QueryDefinition<\n\tComponentTypes,\n\tWithComponents extends keyof ComponentTypes = any,\n\tWithoutComponents extends keyof ComponentTypes = any,\n> = {\n\twith: ReadonlyArray<WithComponents>;\n\twithout?: ReadonlyArray<WithoutComponents>;\n};\n\ntype QueryResults<\n\tComponentTypes,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>>,\n> = {\n\t[QueryName in keyof Queries]: QueryName extends string\n\t\t? FilteredEntity<\n\t\t\tComponentTypes,\n\t\t\tQueries[QueryName] extends QueryDefinition<ComponentTypes, infer W, any> ? W : never,\n\t\t\tQueries[QueryName] extends QueryDefinition<ComponentTypes, any, infer WO> ? WO : never\n\t\t>[]\n\t\t: never;\n};\n\n/**\n * Function signature for system process methods\n * @param queries Results of entity queries defined by the system\n * @param deltaTime Time elapsed since last update in seconds\n * @param ecs The ECSpresso instance providing access to all ECS functionality\n */\ntype ProcessFunction<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>>,\n> = (\n\tqueries: QueryResults<ComponentTypes, Queries>,\n\tdeltaTime: number,\n\tecs: ECSpresso<\n\t\tComponentTypes,\n\t\tEventTypes,\n\t\tResourceTypes\n\t>\n) => void;\n\n/**\n * Type for system initialization functions\n * These can be asynchronous\n */\ntype LifecycleFunction<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n> = (\n\tecs: ECSpresso<\n\t\tComponentTypes,\n\t\tEventTypes,\n\t\tResourceTypes\n\t>,\n) => void | Promise<void>;\n\n/**\n * Create a SystemBuilder attached to an ECSpresso instance\n * Helper function used by ECSpresso.addSystem\n */\nexport function createEcspressoSystemBuilder<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tlabel: string,\n\tecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>\n): SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes> {\n\treturn new SystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(\n\t\tlabel,\n\t\tecspresso\n\t) as SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n/**\n * Create a SystemBuilder attached to a Bundle\n * Helper function used by Bundle.addSystem\n */\nexport function createBundleSystemBuilder<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>\n>(\n\tlabel: string,\n\tbundle: Bundle<ComponentTypes, EventTypes, ResourceTypes>\n): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes> {\n\treturn new SystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(\n\t\tlabel,\n\t\tnull,\n\t\tbundle\n\t) as SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n// Type interfaces for specialized SystemBuilders\n\n/**\n * SystemBuilder with a guaranteed non-null reference to an ECSpresso instance\n */\nexport interface SystemBuilderWithEcspresso<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {}\n> extends SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, Queries> {\n\treadonly ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>;\n\t\n\t/**\n\t * Complete this system and return ECSpresso for seamless chaining\n\t * Automatically registers the system when called\n\t */\n\tand(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes>;\n}\n\n/**\n * SystemBuilder with a guaranteed non-null reference to a Bundle\n */\nexport interface SystemBuilderWithBundle<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tQueries extends Record<string, QueryDefinition<ComponentTypes>> = {}\n> extends SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, Queries> {\n\treadonly bundle: Bundle<ComponentTypes, EventTypes, ResourceTypes>;\n\n\t/**\n\t * Complete this system and return the Bundle for chaining\n\t * Enables fluent API: bundle.addSystem(...).and().addSystem(...)\n\t */\n\tand(): Bundle<ComponentTypes, EventTypes, ResourceTypes>;\n}\n",
14
14
  "import EntityManager from \"./entity-manager\";\nimport EventBus from \"./event-bus\";\nimport ResourceManager from \"./resource-manager\";\nimport AssetManager, { AssetConfiguratorImpl, createAssetConfigurator } from \"./asset-manager\";\nimport ScreenManager, { ScreenConfiguratorImpl, createScreenConfigurator } from \"./screen-manager\";\nimport ReactiveQueryManager, { type ReactiveQueryDefinition } from \"./reactive-query-manager\";\nimport CommandBuffer from \"./command-buffer\";\nimport type { System, FilteredEntity, Entity, RemoveEntityOptions, HierarchyEntry, HierarchyIteratorOptions } from \"./types\";\nimport type Bundle from \"./bundle\";\nimport { createEcspressoSystemBuilder } from \"./system-builder\";\nimport { version } from \"../package.json\";\nimport type { BundlesAreCompatible } from \"./type-utils\";\nimport type { AssetHandle, AssetConfigurator } from \"./asset-types\";\nimport type { ScreenDefinition, ScreenConfigurator } from \"./screen-types\";\n\n/**\n\t* Interface declaration for ECSpresso constructor to ensure type augmentation works properly.\n\t* This merges with the class declaration below.\n*/\nexport default interface ECSpresso<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\t/**\n\t\t* Default constructor\n\t*/\n\tnew(): ECSpresso<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>;\n}\n\nconst EmptyQueryResults = {};\n\n/**\n\t* ECSpresso is the central ECS framework class that connects all features.\n\t* It handles creation and management of entities, components, and systems, and provides lifecycle hooks.\n*/\nexport default class ECSpresso<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\t/** Library version*/\n\tpublic static readonly VERSION = version;\n\n\t/** Access/modify stored components and entities*/\n\tprivate _entityManager: EntityManager<ComponentTypes>;\n\t/** Publish/subscribe to events*/\n\tprivate _eventBus: EventBus<EventTypes>;\n\t/** Access/modify registered resources*/\n\tprivate _resourceManager: ResourceManager<ResourceTypes>;\n\t/** Command buffer for deferred structural changes */\n\tprivate _commandBuffer: CommandBuffer<ComponentTypes, EventTypes, ResourceTypes>;\n\n\t/** Registered systems that will be updated in order*/\n\tprivate _systems: Array<System<ComponentTypes, any, any, EventTypes, ResourceTypes, AssetTypes, ScreenStates>> = [];\n\t/** Cached sorted systems for efficient updates */\n\tprivate _sortedSystems: Array<System<ComponentTypes, any, any, EventTypes, ResourceTypes, AssetTypes, ScreenStates>> = [];\n\t/** Track installed bundles to prevent duplicates*/\n\tprivate _installedBundles: Set<string> = new Set();\n\t/** Disabled system groups */\n\tprivate _disabledGroups: Set<string> = new Set();\n\t/** Asset manager for loading and accessing assets */\n\tprivate _assetManager: AssetManager<AssetTypes> | null = null;\n\t/** Screen manager for state/screen transitions */\n\tprivate _screenManager: ScreenManager<ScreenStates> | null = null;\n\t/** Reactive query manager for enter/exit callbacks */\n\tprivate _reactiveQueryManager: ReactiveQueryManager<ComponentTypes>;\n\t/** Post-update hooks to be called after all systems in update() */\n\tprivate _postUpdateHooks: Array<(ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>, deltaTime: number) => void> = [];\n\n\t/**\n\t\t* Creates a new ECSpresso instance.\n\t*/\n\tconstructor() {\n\t\tthis._entityManager = new EntityManager<ComponentTypes>();\n\t\tthis._eventBus = new EventBus<EventTypes>();\n\t\tthis._resourceManager = new ResourceManager<ResourceTypes>();\n\t\tthis._reactiveQueryManager = new ReactiveQueryManager<ComponentTypes>(this._entityManager);\n\t\tthis._commandBuffer = new CommandBuffer<ComponentTypes, EventTypes, ResourceTypes>();\n\t\tthis._sortedSystems = []; // Initialize the sorted systems array\n\n\t\t// Wire up component lifecycle hooks for reactive queries\n\t\tthis._setupReactiveQueryHooks();\n\t}\n\n\t/**\n\t * Sets up component lifecycle hooks for reactive query tracking\n\t * @private\n\t */\n\tprivate _setupReactiveQueryHooks(): void {\n\t\t// Batching mechanism: during addComponents, we defer reactive query checks\n\t\t// until all components are added to avoid intermediate state triggers\n\t\tlet batchingDepth = 0;\n\t\tconst pendingChecks = new Set<number>();\n\n\t\tconst flushPendingChecks = () => {\n\t\t\tfor (const entityId of pendingChecks) {\n\t\t\t\tconst entity = this._entityManager.getEntity(entityId);\n\t\t\t\tif (entity) {\n\t\t\t\t\t// Do a full recheck of the entity against all queries\n\t\t\t\t\tthis._reactiveQueryManager.recheckEntity(entity);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpendingChecks.clear();\n\t\t};\n\n\t\t// Track added components for reactive queries\n\t\tconst originalAddComponent = this._entityManager.addComponent.bind(this._entityManager);\n\t\tthis._entityManager.addComponent = <K extends keyof ComponentTypes>(\n\t\t\tentityOrId: number | Entity<ComponentTypes>,\n\t\t\tcomponentName: K,\n\t\t\tdata: ComponentTypes[K]\n\t\t) => {\n\t\t\tconst result = originalAddComponent(entityOrId, componentName, data);\n\t\t\tconst entityId = typeof entityOrId === 'number' ? entityOrId : entityOrId.id;\n\n\t\t\tif (batchingDepth > 0) {\n\t\t\t\t// During batching, just track that this entity needs checking\n\t\t\t\tpendingChecks.add(entityId);\n\t\t\t} else {\n\t\t\t\t// Not batching, check immediately\n\t\t\t\tconst entity = this._entityManager.getEntity(entityId);\n\t\t\t\tif (entity) {\n\t\t\t\t\tthis._reactiveQueryManager.onComponentAdded(entity, componentName);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\t// Wrap addComponents to enable batching\n\t\tconst originalAddComponents = this._entityManager.addComponents.bind(this._entityManager);\n\t\tthis._entityManager.addComponents = <T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\t\tentityOrId: number | Entity<ComponentTypes>,\n\t\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t\t) => {\n\t\t\tbatchingDepth++;\n\t\t\tconst result = originalAddComponents(entityOrId, components);\n\t\t\tbatchingDepth--;\n\t\t\tif (batchingDepth === 0) {\n\t\t\t\tflushPendingChecks();\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\t// Track removed components for reactive queries\n\t\tconst originalRemoveComponent = this._entityManager.removeComponent.bind(this._entityManager);\n\t\tthis._entityManager.removeComponent = <K extends keyof ComponentTypes>(\n\t\t\tentityOrId: number | Entity<ComponentTypes>,\n\t\t\tcomponentName: K\n\t\t) => {\n\t\t\tconst entityId = typeof entityOrId === 'number' ? entityOrId : entityOrId.id;\n\t\t\tconst entity = this._entityManager.getEntity(entityId);\n\t\t\tconst result = originalRemoveComponent(entityOrId, componentName);\n\t\t\tif (entity) {\n\t\t\t\tthis._reactiveQueryManager.onComponentRemoved(entity, componentName);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\t// Track entity removal for reactive queries\n\t\tconst originalRemoveEntity = this._entityManager.removeEntity.bind(this._entityManager);\n\t\tthis._entityManager.removeEntity = (entityOrId, options?) => {\n\t\t\tconst entityId = typeof entityOrId === 'number' ? entityOrId : entityOrId.id;\n\t\t\t// Notify reactive query manager about all entities being removed (including descendants)\n\t\t\tconst entity = this._entityManager.getEntity(entityId);\n\t\t\tif (entity) {\n\t\t\t\tconst cascade = options?.cascade ?? true;\n\t\t\t\tif (cascade) {\n\t\t\t\t\tconst descendants = this._entityManager.getDescendants(entityId);\n\t\t\t\t\tfor (const descId of descendants) {\n\t\t\t\t\t\tthis._reactiveQueryManager.onEntityRemoved(descId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis._reactiveQueryManager.onEntityRemoved(entityId);\n\t\t\t}\n\t\t\treturn originalRemoveEntity(entityOrId, options);\n\t\t};\n\t}\n\n\t/**\n\t\t* Creates a new ECSpresso builder for type-safe bundle installation.\n\t\t* This is the preferred way to create an ECSpresso instance with bundles.\n\t *\n\t\t* @returns A builder instance for fluent method chaining\n\t *\n\t\t* @example\n\t\t* ```typescript\n\t\t* const ecs = ECSpresso.create<BaseComponents, BaseEvents, BaseResources>()\n\t *\t .withBundle(bundle1)\n\t *\t .withBundle(bundle2)\n\t *\t .build();\n\t\t* ```\n\t*/\n\tstatic create<\n\t\tC extends Record<string, any> = {},\n\t\tE extends Record<string, any> = {},\n\t\tR extends Record<string, any> = {},\n\t\tA extends Record<string, unknown> = {},\n\t\tS extends Record<string, ScreenDefinition<any, any>> = {},\n\t>(): ECSpressoBuilder<C, E, R, A, S> {\n\t\treturn new ECSpressoBuilder<C, E, R, A, S>();\n\t}\n\n\t/**\n\t\t* Adds a system directly to this ECSpresso instance\n\t\t* @param label Unique name to identify the system\n\t\t* @returns A SystemBuilder instance for method chaining\n\t*/\n\taddSystem(label: string) {\n\t\treturn createEcspressoSystemBuilder<\n\t\t\tComponentTypes,\n\t\t\tEventTypes,\n\t\t\tResourceTypes\n\t\t>(label, this);\n\t}\n\n\t/**\n\t\t* Update all systems, passing deltaTime and query results to each system's process function\n\t\t* @param deltaTime Time elapsed since the last update (in seconds)\n\t*/\n\tupdate(deltaTime: number) {\n\t\tconst currentScreen = this._screenManager?.getCurrentScreen() ?? null;\n\n\t\t// Use the cached sorted systems array instead of re-sorting on every update\n\t\tfor (const system of this._sortedSystems) {\n\t\t\tif (!system.process) continue;\n\n\t\t\t// Group filtering - skip if any of the system's groups is disabled (check first for efficiency)\n\t\t\tif (system.groups?.length) {\n\t\t\t\tlet anyDisabled = false;\n\t\t\t\tfor (const group of system.groups) {\n\t\t\t\t\tif (this._disabledGroups.has(group)) {\n\t\t\t\t\t\tanyDisabled = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (anyDisabled) continue;\n\t\t\t}\n\n\t\t\t// Screen filtering - skip if system is restricted to specific screens\n\t\t\tif (system.inScreens?.length) {\n\t\t\t\tif (currentScreen === null || !system.inScreens.includes(currentScreen as string)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Screen exclusion - skip if system excludes current screen\n\t\t\tif (system.excludeScreens?.length) {\n\t\t\t\tif (currentScreen !== null && system.excludeScreens.includes(currentScreen as string)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Asset requirements - skip if required assets not loaded\n\t\t\tif (system.requiredAssets?.length && this._assetManager) {\n\t\t\t\tlet assetsReady = true;\n\t\t\t\tfor (const assetKey of system.requiredAssets) {\n\t\t\t\t\tif (!this._assetManager.isLoaded(assetKey as keyof AssetTypes)) {\n\t\t\t\t\t\tassetsReady = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!assetsReady) continue;\n\t\t\t}\n\n\t\t\t// Prepare query results for each defined query in the system\n\t\t\tconst queryResults: Record<string, any> = {};\n\t\t\tlet hasResults = false;\n\t\t\tlet hasQueries = false;\n\n\t\t\tif (system.entityQueries) {\n\t\t\t\tfor (const queryName in system.entityQueries) {\n\t\t\t\t\thasQueries = true;\n\n\t\t\t\t\tconst query = system.entityQueries[queryName];\n\n\t\t\t\t\tif (query) {\n\t\t\t\t\t\tqueryResults[queryName] = this._entityManager.getEntitiesWithQuery(\n\t\t\t\t\t\t\tquery.with,\n\t\t\t\t\t\t\tquery.without || []\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif(queryResults[queryName].length) {\n\t\t\t\t\t\t\thasResults = true; // At least one query has results\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Call the system's process function only if there are results or there is no query.\n\t\t\tif (hasResults) {\n\t\t\t\tsystem.process(queryResults, deltaTime, this);\n\t\t\t} else if(!hasQueries) {\n\t\t\t\tsystem.process(EmptyQueryResults, deltaTime, this);\n\t\t\t}\n\t\t}\n\n\t\t// Call post-update hooks\n\t\tfor (const hook of this._postUpdateHooks) {\n\t\t\thook(this as unknown as ECSpresso<ComponentTypes, EventTypes, ResourceTypes>, deltaTime);\n\t\t}\n\n\t\t// Execute queued commands (automatic playback)\n\t\tthis._commandBuffer.playback(this);\n\t}\n\n\t/**\n\t * Initialize all resources and systems\n\t * This method:\n\t * 1. Initializes all resources that were added as factory functions\n\t * 2. Sets up asset manager and loads eager assets\n\t * 3. Sets up screen manager\n\t * 4. Calls the onInitialize lifecycle hook on all systems\n\t *\n\t * This is useful for game startup to ensure all resources are ready\n\t * and systems are properly initialized before the game loop begins.\n\t *\n\t * @param resourceKeys Optional array of specific resource keys to initialize\n\t * @returns Promise that resolves when everything is initialized\n\t */\n\tasync initialize(): Promise<void> {\n\t\tawait this.initializeResources();\n\n\t\t// Set up asset manager if present\n\t\tif (this._assetManager) {\n\t\t\tthis._assetManager.setEventBus(this._eventBus as unknown as EventBus<any>);\n\t\t\tawait this._assetManager.loadEagerAssets();\n\t\t\tthis._resourceManager.add('$assets' as keyof ResourceTypes, this._assetManager.createResource() as unknown as ResourceTypes[keyof ResourceTypes]);\n\t\t}\n\n\t\t// Set up screen manager if present\n\t\tif (this._screenManager) {\n\t\t\tthis._screenManager.setDependencies(\n\t\t\t\tthis._eventBus as unknown as EventBus<any>,\n\t\t\t\tthis._assetManager,\n\t\t\t\tthis as unknown as ECSpresso<any, any, any, any, any>\n\t\t\t);\n\t\t\tthis._resourceManager.add('$screen' as keyof ResourceTypes, this._screenManager.createResource() as unknown as ResourceTypes[keyof ResourceTypes]);\n\t\t}\n\n\t\tfor (const system of this._systems) {\n\t\t\tawait system.onInitialize?.(this);\n\t\t}\n\t}\n\n\t/**\n\t * Initialize specific resources or all resources that were added as factory functions but haven't been initialized yet.\n\t * This is useful when you need to ensure resources are ready before proceeding.\n\t * @param keys Optional array of resource keys to initialize. If not provided, all pending resources will be initialized.\n\t * @returns Promise that resolves when the specified resources are initialized\n\t */\n\tasync initializeResources<K extends keyof ResourceTypes>(...keys: K[]): Promise<void> {\n\t\tawait this._resourceManager.initializeResources(this, ...keys);\n\t}\n\n\t/**\n\t\t* Sort the systems array by priority (higher priority first)\n\t\t* Called internally when system list changes\n\t\t* @private\n\t*/\n\tprivate _sortSystems(): void {\n\t\tthis._sortedSystems = [...this._systems].sort((a, b) => {\n\t\t\tconst priorityA = a.priority ?? 0;\n\t\t\tconst priorityB = b.priority ?? 0;\n\t\t\treturn priorityB - priorityA; // Higher priority executes first\n\t\t});\n\t}\n\n\t/**\n\t\t* Update the priority of a system\n\t\t* @param label The unique label of the system to update\n\t\t* @param priority The new priority value (higher values execute first)\n\t\t* @returns true if the system was found and updated, false otherwise\n\t*/\n\tupdateSystemPriority(label: string, priority: number): boolean {\n\t\tconst system = this._systems.find(system => system.label === label);\n\t\tif (!system) return false;\n\n\t\t// Set the new priority\n\t\tsystem.priority = priority;\n\n\t\t// Re-sort the systems array\n\t\tthis._sortSystems();\n\n\t\treturn true;\n\t}\n\n\t// ==================== System Group Control ====================\n\n\t/**\n\t * Disable a system group. Systems in this group will be skipped during update().\n\t * @param groupName The name of the group to disable\n\t */\n\tdisableSystemGroup(groupName: string): void {\n\t\tthis._disabledGroups.add(groupName);\n\t}\n\n\t/**\n\t * Enable a system group. Systems in this group will run during update().\n\t * @param groupName The name of the group to enable\n\t */\n\tenableSystemGroup(groupName: string): void {\n\t\tthis._disabledGroups.delete(groupName);\n\t}\n\n\t/**\n\t * Check if a system group is enabled.\n\t * @param groupName The name of the group to check\n\t * @returns true if the group is enabled (or doesn't exist), false if disabled\n\t */\n\tisSystemGroupEnabled(groupName: string): boolean {\n\t\treturn !this._disabledGroups.has(groupName);\n\t}\n\n\t/**\n\t * Get all system labels that belong to a specific group.\n\t * @param groupName The name of the group\n\t * @returns Array of system labels in the group\n\t */\n\tgetSystemsInGroup(groupName: string): string[] {\n\t\treturn this._systems\n\t\t\t.filter(system => system.groups?.includes(groupName))\n\t\t\t.map(system => system.label);\n\t}\n\n\t/**\n\t\t* Remove a system by its label\n\t\t* Calls the system's onDetach method with this ECSpresso instance if defined\n\t\t* @param label The unique label of the system to remove\n\t\t* @returns true if the system was found and removed, false otherwise\n\t*/\n\tremoveSystem(label: string): boolean {\n\t\tconst index = this._systems.findIndex(system => system.label === label);\n\t\tif (index === -1) return false;\n\n\t\tconst system = this._systems[index];\n\t\t// This should never happen since we just found the system by index\n\t\tif (!system) return false;\n\n\t\t// Call the onDetach lifecycle hook if defined\n\t\tif (system.onDetach) {\n\t\t\tsystem.onDetach(this);\n\t\t}\n\n\t\t// Remove system\n\t\tthis._systems.splice(index, 1);\n\n\t\t// Re-sort systems\n\t\tthis._sortSystems();\n\n\t\treturn true;\n\t}\n\n\t/**\n\t\t* Internal method to register a system with this ECSpresso instance\n\t\t* @internal Used by SystemBuilder - replaces direct private property access\n\t*/\n\t_registerSystem(system: System<ComponentTypes, any, any, EventTypes, ResourceTypes, AssetTypes, ScreenStates>): void {\n\t\tthis._systems.push(system);\n\t\tthis._sortSystems();\n\n\t\t// Set up event handlers if they exist\n\t\tif (!system.eventHandlers) return;\n\n\t\tfor (const eventName in system.eventHandlers) {\n\t\t\tconst handler = system.eventHandlers[eventName]?.handler;\n\t\t\tif (handler) {\n\t\t\t\tthis._eventBus.subscribe(eventName, (data) => {\n\t\t\t\t\thandler(data, this);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t\t* Check if a resource exists\n\t*/\n\thasResource<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resourceManager.has(key);\n\t}\n\n\t/**\n\t\t* Get a resource if it exists, or undefined if not\n\t*/\n\tgetResource<K extends keyof ResourceTypes>(key: K): ResourceTypes[K] {\n\t\tconst resource = this._resourceManager.get(key, this);\n\n\t\tif (!resource) throw new Error(`Resource '${String(key)}' not found. Available resources: [${this.getResourceKeys().map(k => String(k)).join(', ')}]`);\n\n\t\treturn resource;\n\t}\n\n\t/**\n\t\t* Add a resource to the ECS instance\n\t*/\n\taddResource<K extends keyof ResourceTypes>(\n\t\tkey: K,\n\t\tresource:\n\t\t\t| ResourceTypes[K]\n\t\t\t| ((ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]>)\n\t\t\t| {\n\t\t\t\tdependsOn?: readonly string[];\n\t\t\t\tfactory: (ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]>;\n\t\t\t\tonDispose?: (resource: ResourceTypes[K], ecs?: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => void | Promise<void>;\n\t\t\t}\n\t): this {\n\t\tthis._resourceManager.add(key, resource);\n\t\treturn this;\n\t}\n\n\t/**\n\t\t* Remove a resource from the ECS instance (without calling onDispose)\n\t\t* @param key The resource key to remove\n\t\t* @returns True if the resource was removed, false if it didn't exist\n\t*/\n\tremoveResource<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resourceManager.remove(key);\n\t}\n\n\t/**\n\t * Dispose a single resource, calling its onDispose callback if defined\n\t * @param key The resource key to dispose\n\t * @returns True if the resource existed and was disposed, false if it didn't exist\n\t */\n\tasync disposeResource<K extends keyof ResourceTypes>(key: K): Promise<boolean> {\n\t\treturn this._resourceManager.disposeResource(key, this);\n\t}\n\n\t/**\n\t * Dispose all initialized resources in reverse dependency order.\n\t * Resources that depend on others are disposed first.\n\t * Calls each resource's onDispose callback if defined.\n\t */\n\tasync disposeResources(): Promise<void> {\n\t\treturn this._resourceManager.disposeResources(this);\n\t}\n\n\t/**\n\t\t* Update an existing resource using an updater function\n\t\t* @param key The resource key to update\n\t\t* @param updater Function that receives the current resource value and returns the new value\n\t\t* @returns This ECSpresso instance for chaining\n\t\t* @throws Error if the resource doesn't exist\n\t*/\n\tupdateResource<K extends keyof ResourceTypes>(\n\t\tkey: K,\n\t\tupdater: (current: ResourceTypes[K]) => ResourceTypes[K]\n\t): this {\n\t\tconst currentResource = this.getResource(key);\n\t\tconst updatedResource = updater(currentResource);\n\t\tthis._resourceManager.add(key, updatedResource);\n\t\treturn this;\n\t}\n\n\t/**\n\t\t* Get all resource keys that are currently registered\n\t\t* @returns Array of resource keys\n\t*/\n\tgetResourceKeys(): Array<keyof ResourceTypes> {\n\t\treturn this._resourceManager.getKeys() as Array<keyof ResourceTypes>;\n\t}\n\n\t/**\n\t\t* Check if a resource needs initialization (was added as a factory function)\n\t\t* @param key The resource key to check\n\t\t* @returns True if the resource needs initialization\n\t*/\n\tresourceNeedsInitialization<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resourceManager.needsInitialization(key);\n\t}\n\n\t/**\n\t\t* Check if an entity has a component\n\t*/\n\thasComponent<K extends keyof ComponentTypes>(\n\t\tentityId: number,\n\t\tcomponentName: K\n\t): boolean {\n\t\tconst component = this._entityManager.getComponent(entityId, componentName);\n\t\treturn component !== null;\n\t}\n\n\t/**\n\t\t* Create an entity and add components to it in one call\n\t\t* @param components Object with component names as keys and component data as values\n\t\t* @returns The created entity with all components added\n\t\t*/\n\tspawn<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes, never> {\n\t\tconst entity = this._entityManager.createEntity();\n\t\tthis._entityManager.addComponents(entity, components);\n\t\treturn entity as FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes, never>;\n\t}\n\n\t/**\n\t\t* Get all entities with specific components\n\t*/\n\tgetEntitiesWithQuery<\n\t\tWithComponents extends keyof ComponentTypes,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\twithComponents: ReadonlyArray<WithComponents>,\n\t\twithoutComponents: ReadonlyArray<WithoutComponents> = []\n\t): Array<FilteredEntity<ComponentTypes, WithComponents, WithoutComponents>> {\n\t\treturn this._entityManager.getEntitiesWithQuery(\n\t\t\twithComponents,\n\t\t\twithoutComponents\n\t\t);\n\t}\n\n\t/**\n\t * Remove an entity (and optionally its descendants)\n\t * @param entityOrId Entity or entity ID to remove\n\t * @param options Options for removal (cascade: true by default)\n\t * @returns true if entity was removed\n\t */\n\tremoveEntity(entityOrId: number | Entity<ComponentTypes>, options?: RemoveEntityOptions): boolean {\n\t\treturn this._entityManager.removeEntity(entityOrId, options);\n\t}\n\n\t// ==================== Hierarchy Methods ====================\n\n\t/**\n\t * Create an entity as a child of another entity with initial components\n\t * @param parentId The parent entity ID\n\t * @param components Initial components to add\n\t * @returns The created child entity\n\t */\n\tspawnChild<T extends { [K in keyof ComponentTypes]?: ComponentTypes[K] }>(\n\t\tparentId: number,\n\t\tcomponents: T & Record<Exclude<keyof T, keyof ComponentTypes>, never>\n\t): FilteredEntity<ComponentTypes, keyof T & keyof ComponentTypes, never> {\n\t\tconst entity = this._entityManager.spawnChild(parentId, components);\n\t\tthis._emitHierarchyChanged(entity.id, null, parentId);\n\t\treturn entity;\n\t}\n\n\t/**\n\t * Set the parent of an entity\n\t * @param childId The entity to set as a child\n\t * @param parentId The entity to set as the parent\n\t */\n\tsetParent(childId: number, parentId: number): this {\n\t\tconst oldParent = this._entityManager.getParent(childId);\n\t\tthis._entityManager.setParent(childId, parentId);\n\t\tthis._emitHierarchyChanged(childId, oldParent, parentId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove the parent relationship for an entity (orphan it)\n\t * @param childId The entity to orphan\n\t * @returns true if a parent was removed, false if entity had no parent\n\t */\n\tremoveParent(childId: number): boolean {\n\t\tconst oldParent = this._entityManager.getParent(childId);\n\t\tconst result = this._entityManager.removeParent(childId);\n\t\tif (result) {\n\t\t\tthis._emitHierarchyChanged(childId, oldParent, null);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get the parent of an entity\n\t * @param entityId The entity to get the parent of\n\t * @returns The parent entity ID, or null if no parent\n\t */\n\tgetParent(entityId: number): number | null {\n\t\treturn this._entityManager.getParent(entityId);\n\t}\n\n\t/**\n\t * Get all children of an entity in insertion order\n\t * @param parentId The parent entity\n\t * @returns Readonly array of child entity IDs\n\t */\n\tgetChildren(parentId: number): readonly number[] {\n\t\treturn this._entityManager.getChildren(parentId);\n\t}\n\n\t/**\n\t * Get a child at a specific index\n\t * @param parentId The parent entity\n\t * @param index The index of the child\n\t * @returns The child entity ID, or null if index is out of bounds\n\t */\n\tgetChildAt(parentId: number, index: number): number | null {\n\t\treturn this._entityManager.getChildAt(parentId, index);\n\t}\n\n\t/**\n\t * Get the index of a child within its parent's children list\n\t * @param parentId The parent entity\n\t * @param childId The child entity to find\n\t * @returns The index of the child, or -1 if not found\n\t */\n\tgetChildIndex(parentId: number, childId: number): number {\n\t\treturn this._entityManager.getChildIndex(parentId, childId);\n\t}\n\n\t/**\n\t * Get all ancestors of an entity in order [parent, grandparent, ...]\n\t * @param entityId The entity to get ancestors of\n\t * @returns Readonly array of ancestor entity IDs\n\t */\n\tgetAncestors(entityId: number): readonly number[] {\n\t\treturn this._entityManager.getAncestors(entityId);\n\t}\n\n\t/**\n\t * Get all descendants of an entity in depth-first order\n\t * @param entityId The entity to get descendants of\n\t * @returns Readonly array of descendant entity IDs\n\t */\n\tgetDescendants(entityId: number): readonly number[] {\n\t\treturn this._entityManager.getDescendants(entityId);\n\t}\n\n\t/**\n\t * Get the root ancestor of an entity (topmost parent), or self if no parent\n\t * @param entityId The entity to get the root of\n\t * @returns The root entity ID\n\t */\n\tgetRoot(entityId: number): number {\n\t\treturn this._entityManager.getRoot(entityId);\n\t}\n\n\t/**\n\t * Get siblings of an entity (other children of the same parent)\n\t * @param entityId The entity to get siblings of\n\t * @returns Readonly array of sibling entity IDs\n\t */\n\tgetSiblings(entityId: number): readonly number[] {\n\t\treturn this._entityManager.getSiblings(entityId);\n\t}\n\n\t/**\n\t * Check if an entity is a descendant of another entity\n\t * @param entityId The potential descendant\n\t * @param ancestorId The potential ancestor\n\t * @returns true if entityId is a descendant of ancestorId\n\t */\n\tisDescendantOf(entityId: number, ancestorId: number): boolean {\n\t\treturn this._entityManager.isDescendantOf(entityId, ancestorId);\n\t}\n\n\t/**\n\t * Check if an entity is an ancestor of another entity\n\t * @param entityId The potential ancestor\n\t * @param descendantId The potential descendant\n\t * @returns true if entityId is an ancestor of descendantId\n\t */\n\tisAncestorOf(entityId: number, descendantId: number): boolean {\n\t\treturn this._entityManager.isAncestorOf(entityId, descendantId);\n\t}\n\n\t/**\n\t * Get all root entities (entities that have children but no parent)\n\t * @returns Readonly array of root entity IDs\n\t */\n\tgetRootEntities(): readonly number[] {\n\t\treturn this._entityManager.getRootEntities();\n\t}\n\n\t/**\n\t * Traverse the hierarchy in parent-first (breadth-first) order.\n\t * Parents are guaranteed to be visited before their children.\n\t * @param callback Function called for each entity with (entityId, parentId, depth)\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t */\n\tforEachInHierarchy(\n\t\tcallback: (entityId: number, parentId: number | null, depth: number) => void,\n\t\toptions?: HierarchyIteratorOptions\n\t): void {\n\t\tthis._entityManager.forEachInHierarchy(callback, options);\n\t}\n\n\t/**\n\t * Generator-based hierarchy traversal in parent-first (breadth-first) order.\n\t * Supports early termination via break.\n\t * @param options Optional traversal options (roots to filter to specific subtrees)\n\t * @yields HierarchyEntry for each entity in parent-first order\n\t */\n\thierarchyIterator(options?: HierarchyIteratorOptions): Generator<HierarchyEntry, void, unknown> {\n\t\treturn this._entityManager.hierarchyIterator(options);\n\t}\n\n\t/**\n\t * Emit a hierarchy changed event\n\t * @internal\n\t */\n\tprivate _emitHierarchyChanged(entityId: number, oldParent: number | null, newParent: number | null): void {\n\t\t// Publish the event - if the user has declared hierarchyChanged in their EventTypes, it will be handled\n\t\ttype HierarchyEventBus = EventBus<{ hierarchyChanged: { entityId: number; oldParent: number | null; newParent: number | null } }>;\n\t\t(this._eventBus as unknown as HierarchyEventBus).publish('hierarchyChanged', { entityId, oldParent, newParent });\n\t}\n\n\t/**\n\t\t* Get all installed bundle IDs\n\t*/\n\tget installedBundles(): string[] {\n\t\treturn Array.from(this._installedBundles);\n\t}\n\n\t// Getters for the internal managers\n\tget entityManager() {\n\t\treturn this._entityManager;\n\t}\n\n\tget eventBus() {\n\t\treturn this._eventBus;\n\t}\n\n\t/**\n\t * Command buffer for queuing deferred structural changes.\n\t * Commands are executed automatically at the end of each update() cycle.\n\t *\n\t * @example\n\t * ```typescript\n\t * // In a system or event handler\n\t * ecs.commands.removeEntity(entityId);\n\t * ecs.commands.spawn({ position: { x: 0, y: 0 } });\n\t * ```\n\t */\n\tget commands() {\n\t\treturn this._commandBuffer;\n\t}\n\n\t// ==================== Component Lifecycle Hooks ====================\n\n\t/**\n\t * Register a callback when a specific component is added to any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the new component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentAdded<K extends keyof ComponentTypes>(\n\t\tcomponentName: K,\n\t\thandler: (value: ComponentTypes[K], entity: Entity<ComponentTypes>) => void\n\t): () => void {\n\t\treturn this._entityManager.onComponentAdded(componentName, handler);\n\t}\n\n\t/**\n\t * Register a callback when a specific component is removed from any entity\n\t * @param componentName The component key\n\t * @param handler Function receiving the old component value and the entity\n\t * @returns Unsubscribe function to remove the callback\n\t */\n\tonComponentRemoved<K extends keyof ComponentTypes>(\n\t\tcomponentName: K,\n\t\thandler: (oldValue: ComponentTypes[K], entity: Entity<ComponentTypes>) => void\n\t): () => void {\n\t\treturn this._entityManager.onComponentRemoved(componentName, handler);\n\t}\n\n\t// ==================== Reactive Queries ====================\n\n\t/**\n\t * Add a reactive query that triggers callbacks when entities enter/exit the query match.\n\t * @param name Unique name for the query\n\t * @param definition Query definition with with/without arrays and onEnter/onExit callbacks\n\t */\n\taddReactiveQuery<\n\t\tWithComponents extends keyof ComponentTypes,\n\t\tWithoutComponents extends keyof ComponentTypes = never\n\t>(\n\t\tname: string,\n\t\tdefinition: ReactiveQueryDefinition<ComponentTypes, WithComponents, WithoutComponents>\n\t): void {\n\t\tthis._reactiveQueryManager.addQuery(name, definition);\n\t}\n\n\t/**\n\t * Remove a reactive query by name.\n\t * @param name Name of the query to remove\n\t * @returns true if the query existed and was removed, false otherwise\n\t */\n\tremoveReactiveQuery(name: string): boolean {\n\t\treturn this._reactiveQueryManager.removeQuery(name);\n\t}\n\n\t// ==================== Event Convenience Methods ====================\n\n\t/**\n\t * Subscribe to an event (convenience wrapper for eventBus.subscribe)\n\t * @param eventType The event type to subscribe to\n\t * @param callback The callback to invoke when the event is published\n\t * @returns An unsubscribe function\n\t */\n\ton<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void\n\t): () => void {\n\t\treturn this._eventBus.subscribe(eventType, callback);\n\t}\n\n\t/**\n\t * Unsubscribe from an event by callback reference (convenience wrapper for eventBus.unsubscribe)\n\t * @param eventType The event type to unsubscribe from\n\t * @param callback The callback to remove\n\t * @returns true if the callback was found and removed, false otherwise\n\t */\n\toff<E extends keyof EventTypes>(\n\t\teventType: E,\n\t\tcallback: (data: EventTypes[E]) => void\n\t): boolean {\n\t\treturn this._eventBus.unsubscribe(eventType, callback);\n\t}\n\n\t/**\n\t * Register a hook that runs after all systems in update()\n\t * @param callback The hook to call after all systems have processed\n\t * @returns An unsubscribe function to remove the hook\n\t */\n\tonPostUpdate(\n\t\tcallback: (ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>, deltaTime: number) => void\n\t): () => void {\n\t\tthis._postUpdateHooks.push(callback);\n\t\treturn () => {\n\t\t\tconst index = this._postUpdateHooks.indexOf(callback);\n\t\t\tif (index !== -1) {\n\t\t\t\tthis._postUpdateHooks.splice(index, 1);\n\t\t\t}\n\t\t};\n\t}\n\n\t// ==================== Asset Management ====================\n\n\t/**\n\t * Get a loaded asset by key. Throws if not loaded.\n\t */\n\tgetAsset<K extends keyof AssetTypes>(key: K): AssetTypes[K] {\n\t\tif (!this._assetManager) {\n\t\t\tthrow new Error('Asset manager not configured. Use withAssets() in builder.');\n\t\t}\n\t\treturn this._assetManager.get(key);\n\t}\n\n\t/**\n\t * Get a loaded asset or undefined if not loaded\n\t */\n\tgetAssetOrUndefined<K extends keyof AssetTypes>(key: K): AssetTypes[K] | undefined {\n\t\treturn this._assetManager?.getOrUndefined(key);\n\t}\n\n\t/**\n\t * Get a handle to an asset with status information\n\t */\n\tgetAssetHandle<K extends keyof AssetTypes>(key: K): AssetHandle<AssetTypes[K]> {\n\t\tif (!this._assetManager) {\n\t\t\tthrow new Error('Asset manager not configured. Use withAssets() in builder.');\n\t\t}\n\t\treturn this._assetManager.getHandle(key);\n\t}\n\n\t/**\n\t * Check if an asset is loaded\n\t */\n\tisAssetLoaded<K extends keyof AssetTypes>(key: K): boolean {\n\t\treturn this._assetManager?.isLoaded(key) ?? false;\n\t}\n\n\t/**\n\t * Load a single asset\n\t */\n\tasync loadAsset<K extends keyof AssetTypes>(key: K): Promise<AssetTypes[K]> {\n\t\tif (!this._assetManager) {\n\t\t\tthrow new Error('Asset manager not configured. Use withAssets() in builder.');\n\t\t}\n\t\treturn this._assetManager.loadAsset(key);\n\t}\n\n\t/**\n\t * Load all assets in a group\n\t */\n\tasync loadAssetGroup(groupName: string): Promise<void> {\n\t\tif (!this._assetManager) {\n\t\t\tthrow new Error('Asset manager not configured. Use withAssets() in builder.');\n\t\t}\n\t\treturn this._assetManager.loadAssetGroup(groupName);\n\t}\n\n\t/**\n\t * Check if all assets in a group are loaded\n\t */\n\tisAssetGroupLoaded(groupName: string): boolean {\n\t\treturn this._assetManager?.isGroupLoaded(groupName) ?? false;\n\t}\n\n\t/**\n\t * Get the loading progress of a group (0-1)\n\t */\n\tgetAssetGroupProgress(groupName: string): number {\n\t\treturn this._assetManager?.getGroupProgress(groupName) ?? 0;\n\t}\n\n\t// ==================== Screen Management ====================\n\n\t/**\n\t * Transition to a new screen, clearing the stack\n\t */\n\tasync setScreen<K extends keyof ScreenStates>(\n\t\tname: K,\n\t\tconfig: ScreenStates[K] extends ScreenDefinition<infer C, any> ? C : never\n\t): Promise<void> {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\treturn this._screenManager.setScreen(name, config);\n\t}\n\n\t/**\n\t * Push a screen onto the stack (overlay)\n\t */\n\tasync pushScreen<K extends keyof ScreenStates>(\n\t\tname: K,\n\t\tconfig: ScreenStates[K] extends ScreenDefinition<infer C, any> ? C : never\n\t): Promise<void> {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\treturn this._screenManager.pushScreen(name, config);\n\t}\n\n\t/**\n\t * Pop the current screen and return to the previous one\n\t */\n\tasync popScreen(): Promise<void> {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\treturn this._screenManager.popScreen();\n\t}\n\n\t/**\n\t * Get the current screen name\n\t */\n\tgetCurrentScreen(): keyof ScreenStates | null {\n\t\treturn this._screenManager?.getCurrentScreen() ?? null;\n\t}\n\n\t/**\n\t * Get the current screen config (immutable)\n\t */\n\tgetScreenConfig<K extends keyof ScreenStates>(): ScreenStates[K] extends ScreenDefinition<infer C, any> ? Readonly<C> : never {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\treturn this._screenManager.getConfig();\n\t}\n\n\t/**\n\t * Get the current screen config or null\n\t */\n\tgetScreenConfigOrNull<K extends keyof ScreenStates>(): (ScreenStates[K] extends ScreenDefinition<infer C, any> ? Readonly<C> : never) | null {\n\t\treturn this._screenManager?.getConfigOrNull() ?? null;\n\t}\n\n\t/**\n\t * Get the current screen state (mutable)\n\t */\n\tgetScreenState<K extends keyof ScreenStates>(): ScreenStates[K] extends ScreenDefinition<any, infer S> ? S : never {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\treturn this._screenManager.getState();\n\t}\n\n\t/**\n\t * Get the current screen state or null\n\t */\n\tgetScreenStateOrNull<K extends keyof ScreenStates>(): (ScreenStates[K] extends ScreenDefinition<any, infer S> ? S : never) | null {\n\t\treturn this._screenManager?.getStateOrNull() ?? null;\n\t}\n\n\t/**\n\t * Update the current screen state\n\t */\n\tupdateScreenState<K extends keyof ScreenStates>(\n\t\tupdate: Partial<ScreenStates[K] extends ScreenDefinition<any, infer S> ? S : never> |\n\t\t\t((current: ScreenStates[K] extends ScreenDefinition<any, infer S> ? S : never) => Partial<ScreenStates[K] extends ScreenDefinition<any, infer S> ? S : never>)\n\t): void {\n\t\tif (!this._screenManager) {\n\t\t\tthrow new Error('Screen manager not configured. Use withScreens() in builder.');\n\t\t}\n\t\tthis._screenManager.updateState(update as any);\n\t}\n\n\t/**\n\t * Check if a screen is the current screen\n\t */\n\tisCurrentScreen(screenName: keyof ScreenStates): boolean {\n\t\treturn this._screenManager?.isCurrent(screenName) ?? false;\n\t}\n\n\t/**\n\t * Check if a screen is active (current or in stack)\n\t */\n\tisScreenActive(screenName: keyof ScreenStates): boolean {\n\t\treturn this._screenManager?.isActive(screenName) ?? false;\n\t}\n\n\t/**\n\t * Get the screen stack depth\n\t */\n\tgetScreenStackDepth(): number {\n\t\treturn this._screenManager?.getStackDepth() ?? 0;\n\t}\n\n\t// ==================== Internal Methods ====================\n\n\t/**\n\t * Internal method to set the asset manager\n\t * @internal Used by ECSpressoBuilder\n\t */\n\t_setAssetManager(manager: AssetManager<AssetTypes>): void {\n\t\tthis._assetManager = manager;\n\t}\n\n\t/**\n\t * Internal method to set the screen manager\n\t * @internal Used by ECSpressoBuilder\n\t */\n\t_setScreenManager(manager: ScreenManager<ScreenStates>): void {\n\t\tthis._screenManager = manager;\n\t}\n\n\t/**\n\t\t* Internal method to install a bundle into this ECSpresso instance.\n\t\t* Called by the ECSpressoBuilder during the build process.\n\t\t* The type safety is guaranteed by the builder's type system.\n\t*/\n\t_installBundle<\n\t\tC extends Record<string, any>,\n\t\tE extends Record<string, any>,\n\t\tR extends Record<string, any>,\n\t\tA extends Record<string, unknown> = {},\n\t\tS extends Record<string, ScreenDefinition<any, any>> = {},\n\t>(bundle: Bundle<C, E, R, A, S>): this {\n\t\t// Prevent duplicate installation of the same bundle\n\t\tif (this._installedBundles.has(bundle.id)) {\n\t\t\treturn this;\n\t\t}\n\n\t\t// Mark this bundle as installed\n\t\tthis._installedBundles.add(bundle.id);\n\n\t\t// Register systems from the bundle\n\t\t// The type compatibility is ensured by the builder's withBundle method\n\t\t// We need this cast due to TypeScript's limitations with generics\n\t\ttype BundleEcspresso = ECSpresso<C, E, R>;\n\t\tbundle.registerSystemsWithEcspresso(this as unknown as BundleEcspresso);\n\n\t\t// Register resources from the bundle\n\t\tconst resources = bundle.getResources();\n\t\tfor (const [key, value] of resources.entries()) {\n\t\t\t// Instead of casting, use the add method's flexibility\n\t\t\tthis._resourceManager.add(key as string, value);\n\t\t}\n\n\t\t// Register assets from the bundle if asset manager exists\n\t\tif (this._assetManager) {\n\t\t\tconst assets = bundle.getAssets();\n\t\t\tfor (const [key, definition] of assets.entries()) {\n\t\t\t\tthis._assetManager.register(key, definition as any);\n\t\t\t}\n\t\t}\n\n\t\t// Register screens from the bundle if screen manager exists\n\t\tif (this._screenManager) {\n\t\t\tconst screens = bundle.getScreens();\n\t\t\tfor (const [name, definition] of screens.entries()) {\n\t\t\t\tthis._screenManager.register(name, definition as any);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n}\n\n/**\n * Resource factory with optional dependencies and disposal callback\n */\ntype ResourceFactoryWithDeps<T> = {\n\tdependsOn?: readonly string[];\n\tfactory: (context?: any) => T | Promise<T>;\n\tonDispose?: (resource: T, context?: any) => void | Promise<void>;\n};\n\n/**\n\t* Builder class for ECSpresso that provides fluent type-safe bundle installation.\n\t* Handles type checking during build process to ensure type safety.\n*/\nexport class ECSpressoBuilder<\n\tC extends Record<string, any> = {},\n\tE extends Record<string, any> = {},\n\tR extends Record<string, any> = {},\n\tA extends Record<string, unknown> = {},\n\tS extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\t/** The ECSpresso instance being built*/\n\tprivate ecspresso: ECSpresso<C, E, R, A, S>;\n\t/** Asset configurator for collecting asset definitions */\n\tprivate assetConfigurator: AssetConfiguratorImpl<A> | null = null;\n\t/** Screen configurator for collecting screen definitions */\n\tprivate screenConfigurator: ScreenConfiguratorImpl<S> | null = null;\n\t/** Pending resources to add during build */\n\tprivate pendingResources: Array<{ key: string; value: unknown }> = [];\n\n\tconstructor() {\n\t\tthis.ecspresso = new ECSpresso<C, E, R, A, S>();\n\t}\n\n\t/**\n\t\t* Add the first bundle when starting with empty types.\n\t\t* This overload allows any bundle to be added to an empty ECSpresso instance.\n\t*/\n\twithBundle<\n\t\tBC extends Record<string, any>,\n\t\tBE extends Record<string, any>,\n\t\tBR extends Record<string, any>\n\t>(\n\t\tthis: ECSpressoBuilder<{}, {}, {}, A, S>,\n\t\tbundle: Bundle<BC, BE, BR>\n\t): ECSpressoBuilder<BC, BE, BR, A, S>;\n\n\t/**\n\t\t* Add a subsequent bundle with type checking.\n\t\t* This overload enforces bundle type compatibility.\n\t*/\n\twithBundle<\n\t\tBC extends Record<string, any>,\n\t\tBE extends Record<string, any>,\n\t\tBR extends Record<string, any>\n\t>(\n\t\tbundle: BundlesAreCompatible<C, BC, E, BE, R, BR> extends true\n\t\t\t? Bundle<BC, BE, BR>\n\t\t\t: never\n\t): ECSpressoBuilder<C & BC, E & BE, R & BR, A, S>;\n\n\t/**\n\t\t* Implementation of both overloads.\n\t\t* Since the type compatibility is checked in the method signature,\n\t\t* we can safely assume the bundle is compatible here.\n\t*/\n\twithBundle<\n\t\tBC extends Record<string, any>,\n\t\tBE extends Record<string, any>,\n\t\tBR extends Record<string, any>\n\t>(\n\t\tbundle: Bundle<BC, BE, BR>\n\t): ECSpressoBuilder<C & BC, E & BE, R & BR, A, S> {\n\t\t// Install the bundle\n\t\t// Type compatibility is guaranteed by method overloads\n\t\tthis.ecspresso._installBundle(bundle);\n\n\t\t// Return a builder with the updated type parameters\n\t\treturn this as unknown as ECSpressoBuilder<C & BC, E & BE, R & BR, A, S>;\n\t}\n\n\t/**\n\t * Add a resource during ECSpresso construction\n\t * @param key The resource key\n\t * @param resource The resource value, factory function, or factory with dependencies/disposal\n\t * @returns This builder with updated resource types\n\t *\n\t * @example\n\t * ```typescript\n\t * ECSpresso.create<Components, Events, Resources>()\n\t * .withResource('config', { debug: true })\n\t * .withResource('counter', () => 42)\n\t * .withResource('derived', {\n\t * dependsOn: ['base'],\n\t * factory: (ecs) => ecs.getResource('base') * 2,\n\t * onDispose: (value) => console.log('Disposed:', value)\n\t * })\n\t * .build();\n\t * ```\n\t */\n\twithResource<K extends string, V>(\n\t\tkey: K,\n\t\tresource: V | ((context?: any) => V | Promise<V>) | ResourceFactoryWithDeps<V>\n\t): ECSpressoBuilder<C, E, R & Record<K, V>, A, S> {\n\t\tthis.pendingResources.push({ key, value: resource });\n\t\treturn this as unknown as ECSpressoBuilder<C, E, R & Record<K, V>, A, S>;\n\t}\n\n\t/**\n\t * Configure assets for this ECSpresso instance\n\t * @param configurator Function that receives an AssetConfigurator and returns it after adding assets\n\t * @returns This builder with updated asset types\n\t *\n\t * @example\n\t * ```typescript\n\t * ECSpresso.create<Components, Events, Resources>()\n\t * .withAssets(assets => assets\n\t * .add('playerSprite', () => loadTexture('player.png'))\n\t * .addGroup('level1', {\n\t * background: () => loadTexture('level1-bg.png'),\n\t * music: () => loadAudio('level1.mp3'),\n\t * })\n\t * )\n\t * .build();\n\t * ```\n\t */\n\twithAssets<NewA extends Record<string, unknown>>(\n\t\tconfigurator: (assets: AssetConfigurator<{}>) => AssetConfigurator<NewA>\n\t): ECSpressoBuilder<C, E, R, A & NewA, S> {\n\t\tconst assetConfig = createAssetConfigurator<{}>();\n\t\tconfigurator(assetConfig);\n\t\tthis.assetConfigurator = assetConfig as unknown as AssetConfiguratorImpl<A>;\n\t\treturn this as unknown as ECSpressoBuilder<C, E, R, A & NewA, S>;\n\t}\n\n\t/**\n\t * Configure screens for this ECSpresso instance\n\t * @param configurator Function that receives a ScreenConfigurator and returns it after adding screens\n\t * @returns This builder with updated screen types\n\t *\n\t * @example\n\t * ```typescript\n\t * ECSpresso.create<Components, Events, Resources>()\n\t * .withScreens(screens => screens\n\t * .add('loading', {\n\t * initialState: () => ({ progress: 0 }),\n\t * })\n\t * .add('gameplay', {\n\t * initialState: ({ level }) => ({ score: 0, level }),\n\t * requiredAssetGroups: ['level1'],\n\t * })\n\t * )\n\t * .build();\n\t * ```\n\t */\n\twithScreens<NewS extends Record<string, ScreenDefinition<any, any>>>(\n\t\tconfigurator: (screens: ScreenConfigurator<{}>) => ScreenConfigurator<NewS>\n\t): ECSpressoBuilder<C, E, R, A, S & NewS> {\n\t\tconst screenConfig = createScreenConfigurator<{}>();\n\t\tconfigurator(screenConfig);\n\t\tthis.screenConfigurator = screenConfig as unknown as ScreenConfiguratorImpl<S>;\n\t\treturn this as unknown as ECSpressoBuilder<C, E, R, A, S & NewS>;\n\t}\n\n\t/**\n\t\t* Complete the build process and return the built ECSpresso instance\n\t*/\n\tbuild(): ECSpresso<C, E, R, A, S> {\n\t\t// Apply pending resources\n\t\tfor (const { key, value } of this.pendingResources) {\n\t\t\tthis.ecspresso.addResource(key as keyof R, value as any);\n\t\t}\n\n\t\t// Set up asset manager if configured\n\t\tif (this.assetConfigurator) {\n\t\t\tthis.ecspresso._setAssetManager(this.assetConfigurator.getManager() as unknown as AssetManager<A>);\n\t\t}\n\n\t\t// Set up screen manager if configured\n\t\tif (this.screenConfigurator) {\n\t\t\tthis.ecspresso._setScreenManager(this.screenConfigurator.getManager() as unknown as ScreenManager<S>);\n\t\t}\n\n\t\treturn this.ecspresso;\n\t}\n}\n",
15
- "import { createBundleSystemBuilder, SystemBuilderWithBundle } from './system-builder';\nimport type ECSpresso from './ecspresso';\nimport type { AssetDefinition } from './asset-types';\nimport type { ScreenDefinition } from './screen-types';\n\n/**\n * Generates a unique ID for a bundle\n */\nfunction generateBundleId(): string {\n\treturn `bundle_${Date.now().toString(36)}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Bundle class that encapsulates a set of components, resources, events, and systems\n * that can be merged into a ECSpresso instance\n */\nexport default class Bundle<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\tprivate _systems: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] = [];\n\tprivate _resources: Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> = new Map();\n\tprivate _assets: Map<string, AssetDefinition<unknown>> = new Map();\n\tprivate _assetGroups: Map<string, Map<string, () => Promise<unknown>>> = new Map();\n\tprivate _screens: Map<string, ScreenDefinition<any, any>> = new Map();\n\tprivate _id: string;\n\n\tconstructor(id?: string) {\n\t\tthis._id = id || generateBundleId();\n\t}\n\n\t/**\n\t * Get the unique ID of this bundle\n\t */\n\tget id(): string {\n\t\treturn this._id;\n\t}\n\n\t/**\n\t * Set the ID of this bundle\n\t * @internal Used by combineBundles\n\t */\n\tset id(value: string) {\n\t\tthis._id = value;\n\t}\n\n\t/**\n\t * Add a system to this bundle, by label (creating a new builder) or by reusing an existing one\n\t */\n\taddSystem<Q extends Record<string, any>>(builder: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>;\n\taddSystem(label: string): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, {}>;\n\taddSystem(builderOrLabel: string | SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>) {\n\t\tif (typeof builderOrLabel === 'string') {\n\t\t\tconst system = createBundleSystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(builderOrLabel, this);\n\t\t\tthis._systems.push(system);\n\t\t\treturn system;\n\t\t} else {\n\t\t\tthis._systems.push(builderOrLabel);\n\t\t\treturn builderOrLabel;\n\t\t}\n\t}\n\n\t/**\n\t * Add a resource to this bundle\n\t * @param label The resource key\n\t * @param resource The resource value, a factory function, or a factory with dependencies\n\t */\n\taddResource<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\tresource:\n\t\t\t| ResourceTypes[K]\n\t\t\t| ((ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]>)\n\t\t\t| { dependsOn: readonly string[]; factory: (ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]> }\n\t) {\n\t\t// We need this cast because TypeScript doesn't recognize that a value of type\n\t\t// ResourceTypes[K] | (() => ResourceTypes[K] | Promise<ResourceTypes[K]>) | { dependsOn, factory }\n\t\t// can be properly assigned to Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]>\n\t\tthis._resources.set(label, resource as unknown as ResourceTypes[K]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an asset to this bundle\n\t * @param key The asset key\n\t * @param loader Function that loads and returns the asset\n\t * @param options Optional asset configuration\n\t */\n\taddAsset<K extends string, T>(\n\t\tkey: K,\n\t\tloader: () => Promise<T>,\n\t\toptions?: { eager?: boolean; group?: string }\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates> {\n\t\tthis._assets.set(key, {\n\t\t\tloader,\n\t\t\teager: options?.eager ?? true,\n\t\t\tgroup: options?.group,\n\t\t});\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a group of assets to this bundle\n\t * @param groupName The group name\n\t * @param assets Object mapping asset keys to loader functions\n\t */\n\taddAssetGroup<G extends string, T extends Record<string, () => Promise<unknown>>>(\n\t\tgroupName: G,\n\t\tassets: T\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates> {\n\t\tconst groupAssets = new Map<string, () => Promise<unknown>>();\n\t\tfor (const [key, loader] of Object.entries(assets)) {\n\t\t\tgroupAssets.set(key, loader as () => Promise<unknown>);\n\t\t\tthis._assets.set(key, {\n\t\t\t\tloader: loader as () => Promise<unknown>,\n\t\t\t\teager: false,\n\t\t\t\tgroup: groupName,\n\t\t\t});\n\t\t}\n\t\tthis._assetGroups.set(groupName, groupAssets);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a screen to this bundle\n\t * @param name The screen name\n\t * @param definition The screen definition\n\t */\n\taddScreen<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(\n\t\tname: K,\n\t\tdefinition: ScreenDefinition<Config, State>\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>> {\n\t\tthis._screens.set(name, definition);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>>;\n\t}\n\n\t/**\n\t * Get all asset definitions in this bundle\n\t */\n\tgetAssets(): Map<string, AssetDefinition<unknown>> {\n\t\treturn new Map(this._assets);\n\t}\n\n\t/**\n\t * Get all screen definitions in this bundle\n\t */\n\tgetScreens(): Map<string, ScreenDefinition<any, any>> {\n\t\treturn new Map(this._screens);\n\t}\n\n\t/**\n\t * Internal method to set a resource\n\t * @internal Used by mergeBundles\n\t */\n\t_setResource(key: string, value: unknown): void {\n\t\tthis._resources.set(key as keyof ResourceTypes, value as ResourceTypes[keyof ResourceTypes]);\n\t}\n\n\t/**\n\t * Internal method to set an asset definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setAsset(key: string, definition: AssetDefinition<unknown>): void {\n\t\tthis._assets.set(key, definition);\n\t}\n\n\t/**\n\t * Internal method to set a screen definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setScreen(name: string, definition: ScreenDefinition<any, any>): void {\n\t\tthis._screens.set(name, definition);\n\t}\n\n\t/**\n\t * Get all systems defined in this bundle\n\t * Returns built System objects instead of SystemBuilders\n\t */\n\tgetSystems() {\n\t\treturn this._systems.map(system => system.build());\n\t}\n\n\t/**\n\t * Register all systems in this bundle with an ECSpresso instance\n\t * @internal Used by ECSpresso when adding a bundle\n\t */\n\tregisterSystemsWithEcspresso(ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) {\n\t\tfor (const systemBuilder of this._systems) {\n\t\t\tsystemBuilder.build(ecspresso);\n\t\t}\n\t}\n\n\t/**\n\t * Get all resources defined in this bundle\n\t */\n\tgetResources(): Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> {\n\t\treturn new Map(this._resources);\n\t}\n\n\t/**\n\t * Get a specific resource by key\n\t * @param key The resource key\n\t * @returns The resource value or undefined if not found\n\t */\n\tgetResource<K extends keyof ResourceTypes>(key: K): ResourceTypes[K] {\n\t\treturn this._resources.get(key) as ResourceTypes[K];\n\t}\n\n\t/**\n\t * Get all system builders in this bundle\n\t */\n\tgetSystemBuilders(): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] {\n\t\treturn [...this._systems];\n\t}\n\n\t/**\n\t * Check if this bundle has a specific resource\n\t * @param key The resource key to check\n\t * @returns True if the resource exists\n\t */\n\thasResource<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resources.has(key);\n\t}\n}\n\n/**\n * Utility type to check if two types are exactly the same\n */\ntype Exactly<T, U> = T extends U ? U extends T ? true : false : false;\n\n/**\n * Simplified type constraint for bundle compatibility\n * Ensures that overlapping keys have exactly the same types\n */\ntype CompatibleBundles<\n\tC1 extends Record<string, any>,\n\tC2 extends Record<string, any>,\n\tE1 extends Record<string, any>,\n\tE2 extends Record<string, any>,\n\tR1 extends Record<string, any>,\n\tR2 extends Record<string, any>,\n\tA1 extends Record<string, unknown> = {},\n\tA2 extends Record<string, unknown> = {},\n\tS1 extends Record<string, ScreenDefinition<any, any>> = {},\n\tS2 extends Record<string, ScreenDefinition<any, any>> = {},\n> = {\n\t[K in keyof C1 & keyof C2]: Exactly<C1[K], C2[K]> extends true ? C1[K] : never;\n} & {\n\t[K in keyof E1 & keyof E2]: Exactly<E1[K], E2[K]> extends true ? E1[K] : never;\n} & {\n\t[K in keyof R1 & keyof R2]: Exactly<R1[K], R2[K]> extends true ? R1[K] : never;\n} & {\n\t[K in keyof A1 & keyof A2]: Exactly<A1[K], A2[K]> extends true ? A1[K] : never;\n} & {\n\t[K in keyof S1 & keyof S2]: Exactly<S1[K], S2[K]> extends true ? S1[K] : never;\n};\n\n/**\n * Function that merges multiple bundles into a single bundle\n */\nexport function mergeBundles<\n\tC1 extends Record<string, any>,\n\tE1 extends Record<string, any>,\n\tR1 extends Record<string, any>,\n\tA1 extends Record<string, unknown>,\n\tS1 extends Record<string, ScreenDefinition<any, any>>,\n\tC2 extends Record<string, any>,\n\tE2 extends Record<string, any>,\n\tR2 extends Record<string, any>,\n\tA2 extends Record<string, unknown>,\n\tS2 extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\tbundle1: Bundle<C1, E1, R1, A1, S1>,\n\tbundle2: Bundle<C2, E2, R2, A2, S2> & CompatibleBundles<C1, C2, E1, E2, R1, R2, A1, A2, S1, S2>\n): Bundle<C1 & C2, E1 & E2, R1 & R2, A1 & A2, S1 & S2>;\n\nexport function mergeBundles<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tAssetTypes extends Record<string, unknown>,\n\tScreenStates extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\t...bundles: Array<Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>>\n): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>;\n\nexport function mergeBundles(\n\tid: string,\n\t...bundles: Array<Bundle<any, any, any, any, any>>\n): Bundle<any, any, any, any, any> {\n\tif (bundles.length === 0) {\n\t\treturn new Bundle(id);\n\t}\n\n\tconst combined = new Bundle(id);\n\n\tfor (const bundle of bundles) {\n\t\tfor (const system of bundle.getSystemBuilders()) {\n\t\t\t// reuse the full builder so we carry over queries, hooks, and handlers\n\t\t\tcombined.addSystem(system);\n\t\t}\n\n\t\t// Add resources from this bundle\n\t\tfor (const [label, resource] of bundle.getResources().entries()) {\n\t\t\tcombined._setResource(label as string, resource);\n\t\t}\n\n\t\t// Add assets from this bundle\n\t\tfor (const [key, definition] of bundle.getAssets().entries()) {\n\t\t\tcombined._setAsset(key, definition);\n\t\t}\n\n\t\t// Add screens from this bundle\n\t\tfor (const [name, definition] of bundle.getScreens().entries()) {\n\t\t\tcombined._setScreen(name, definition);\n\t\t}\n\t}\n\n\treturn combined;\n}\n",
15
+ "import { createBundleSystemBuilder, SystemBuilderWithBundle } from './system-builder';\nimport type ECSpresso from './ecspresso';\nimport type { AssetDefinition } from './asset-types';\nimport type { ScreenDefinition } from './screen-types';\nimport type { BundlesAreCompatible } from './type-utils';\n\n/**\n * Generates a unique ID for a bundle\n */\nfunction generateBundleId(): string {\n\treturn `bundle_${Date.now().toString(36)}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Bundle class that encapsulates a set of components, resources, events, and systems\n * that can be merged into a ECSpresso instance\n */\nexport default class Bundle<\n\tComponentTypes extends Record<string, any> = {},\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, ScreenDefinition<any, any>> = {},\n> {\n\tprivate _systems: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] = [];\n\tprivate _resources: Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> = new Map();\n\tprivate _assets: Map<string, AssetDefinition<unknown>> = new Map();\n\tprivate _assetGroups: Map<string, Map<string, () => Promise<unknown>>> = new Map();\n\tprivate _screens: Map<string, ScreenDefinition<any, any>> = new Map();\n\tprivate _id: string;\n\n\tconstructor(id?: string) {\n\t\tthis._id = id || generateBundleId();\n\t}\n\n\t/**\n\t * Get the unique ID of this bundle\n\t */\n\tget id(): string {\n\t\treturn this._id;\n\t}\n\n\t/**\n\t * Set the ID of this bundle\n\t * @internal Used by combineBundles\n\t */\n\tset id(value: string) {\n\t\tthis._id = value;\n\t}\n\n\t/**\n\t * Add a system to this bundle, by label (creating a new builder) or by reusing an existing one\n\t */\n\taddSystem<Q extends Record<string, any>>(builder: SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Q>;\n\taddSystem(label: string): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, {}>;\n\taddSystem(builderOrLabel: string | SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>) {\n\t\tif (typeof builderOrLabel === 'string') {\n\t\t\tconst system = createBundleSystemBuilder<ComponentTypes, EventTypes, ResourceTypes>(builderOrLabel, this);\n\t\t\tthis._systems.push(system);\n\t\t\treturn system;\n\t\t} else {\n\t\t\tthis._systems.push(builderOrLabel);\n\t\t\treturn builderOrLabel;\n\t\t}\n\t}\n\n\t/**\n\t * Add a resource to this bundle\n\t * @param label The resource key\n\t * @param resource The resource value, a factory function, or a factory with dependencies\n\t */\n\taddResource<K extends keyof ResourceTypes>(\n\t\tlabel: K,\n\t\tresource:\n\t\t\t| ResourceTypes[K]\n\t\t\t| ((ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]>)\n\t\t\t| { dependsOn: readonly string[]; factory: (ecs: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) => ResourceTypes[K] | Promise<ResourceTypes[K]> }\n\t) {\n\t\t// We need this cast because TypeScript doesn't recognize that a value of type\n\t\t// ResourceTypes[K] | (() => ResourceTypes[K] | Promise<ResourceTypes[K]>) | { dependsOn, factory }\n\t\t// can be properly assigned to Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]>\n\t\tthis._resources.set(label, resource as unknown as ResourceTypes[K]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an asset to this bundle\n\t * @param key The asset key\n\t * @param loader Function that loads and returns the asset\n\t * @param options Optional asset configuration\n\t */\n\taddAsset<K extends string, T>(\n\t\tkey: K,\n\t\tloader: () => Promise<T>,\n\t\toptions?: { eager?: boolean; group?: string }\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates> {\n\t\tthis._assets.set(key, {\n\t\t\tloader,\n\t\t\teager: options?.eager ?? true,\n\t\t\tgroup: options?.group,\n\t\t});\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & Record<K, T>, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a group of assets to this bundle\n\t * @param groupName The group name\n\t * @param assets Object mapping asset keys to loader functions\n\t */\n\taddAssetGroup<G extends string, T extends Record<string, () => Promise<unknown>>>(\n\t\tgroupName: G,\n\t\tassets: T\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates> {\n\t\tconst groupAssets = new Map<string, () => Promise<unknown>>();\n\t\tfor (const [key, loader] of Object.entries(assets)) {\n\t\t\tgroupAssets.set(key, loader as () => Promise<unknown>);\n\t\t\tthis._assets.set(key, {\n\t\t\t\tloader: loader as () => Promise<unknown>,\n\t\t\t\teager: false,\n\t\t\t\tgroup: groupName,\n\t\t\t});\n\t\t}\n\t\tthis._assetGroups.set(groupName, groupAssets);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes & { [K in keyof T]: Awaited<ReturnType<T[K]>> }, ScreenStates>;\n\t}\n\n\t/**\n\t * Add a screen to this bundle\n\t * @param name The screen name\n\t * @param definition The screen definition\n\t */\n\taddScreen<K extends string, Config extends Record<string, unknown>, State extends Record<string, unknown>>(\n\t\tname: K,\n\t\tdefinition: ScreenDefinition<Config, State>\n\t): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>> {\n\t\tthis._screens.set(name, definition);\n\t\treturn this as unknown as Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates & Record<K, ScreenDefinition<Config, State>>>;\n\t}\n\n\t/**\n\t * Get all asset definitions in this bundle\n\t */\n\tgetAssets(): Map<string, AssetDefinition<unknown>> {\n\t\treturn new Map(this._assets);\n\t}\n\n\t/**\n\t * Get all screen definitions in this bundle\n\t */\n\tgetScreens(): Map<string, ScreenDefinition<any, any>> {\n\t\treturn new Map(this._screens);\n\t}\n\n\t/**\n\t * Internal method to set a resource\n\t * @internal Used by mergeBundles\n\t */\n\t_setResource(key: string, value: unknown): void {\n\t\tthis._resources.set(key as keyof ResourceTypes, value as ResourceTypes[keyof ResourceTypes]);\n\t}\n\n\t/**\n\t * Internal method to set an asset definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setAsset(key: string, definition: AssetDefinition<unknown>): void {\n\t\tthis._assets.set(key, definition);\n\t}\n\n\t/**\n\t * Internal method to set a screen definition\n\t * @internal Used by mergeBundles\n\t */\n\t_setScreen(name: string, definition: ScreenDefinition<any, any>): void {\n\t\tthis._screens.set(name, definition);\n\t}\n\n\t/**\n\t * Get all systems defined in this bundle\n\t * Returns built System objects instead of SystemBuilders\n\t */\n\tgetSystems() {\n\t\treturn this._systems.map(system => system.build());\n\t}\n\n\t/**\n\t * Register all systems in this bundle with an ECSpresso instance\n\t * @internal Used by ECSpresso when adding a bundle\n\t */\n\tregisterSystemsWithEcspresso(ecspresso: ECSpresso<ComponentTypes, EventTypes, ResourceTypes>) {\n\t\tfor (const systemBuilder of this._systems) {\n\t\t\tsystemBuilder.build(ecspresso);\n\t\t}\n\t}\n\n\t/**\n\t * Get all resources defined in this bundle\n\t */\n\tgetResources(): Map<keyof ResourceTypes, ResourceTypes[keyof ResourceTypes]> {\n\t\treturn new Map(this._resources);\n\t}\n\n\t/**\n\t * Get a specific resource by key\n\t * @param key The resource key\n\t * @returns The resource value or undefined if not found\n\t */\n\tgetResource<K extends keyof ResourceTypes>(key: K): ResourceTypes[K] {\n\t\treturn this._resources.get(key) as ResourceTypes[K];\n\t}\n\n\t/**\n\t * Get all system builders in this bundle\n\t */\n\tgetSystemBuilders(): SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, any>[] {\n\t\treturn [...this._systems];\n\t}\n\n\t/**\n\t * Check if this bundle has a specific resource\n\t * @param key The resource key to check\n\t * @returns True if the resource exists\n\t */\n\thasResource<K extends keyof ResourceTypes>(key: K): boolean {\n\t\treturn this._resources.has(key);\n\t}\n}\n\n/**\n * Function that merges multiple bundles into a single bundle\n */\nexport function mergeBundles<\n\tC1 extends Record<string, any>,\n\tE1 extends Record<string, any>,\n\tR1 extends Record<string, any>,\n\tA1 extends Record<string, unknown>,\n\tS1 extends Record<string, ScreenDefinition<any, any>>,\n\tC2 extends Record<string, any>,\n\tE2 extends Record<string, any>,\n\tR2 extends Record<string, any>,\n\tA2 extends Record<string, unknown>,\n\tS2 extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\tbundle1: Bundle<C1, E1, R1, A1, S1>,\n\tbundle2: BundlesAreCompatible<C1, C2, E1, E2, R1, R2, A1, A2, S1, S2> extends true\n\t\t? Bundle<C2, E2, R2, A2, S2>\n\t\t: never\n): Bundle<C1 & C2, E1 & E2, R1 & R2, A1 & A2, S1 & S2>;\n\nexport function mergeBundles<\n\tComponentTypes extends Record<string, any>,\n\tEventTypes extends Record<string, any>,\n\tResourceTypes extends Record<string, any>,\n\tAssetTypes extends Record<string, unknown>,\n\tScreenStates extends Record<string, ScreenDefinition<any, any>>,\n>(\n\tid: string,\n\t...bundles: Array<Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>>\n): Bundle<ComponentTypes, EventTypes, ResourceTypes, AssetTypes, ScreenStates>;\n\nexport function mergeBundles(\n\tid: string,\n\t...bundles: Array<Bundle<any, any, any, any, any>>\n): Bundle<any, any, any, any, any> {\n\tif (bundles.length === 0) {\n\t\treturn new Bundle(id);\n\t}\n\n\tconst combined = new Bundle(id);\n\n\tfor (const bundle of bundles) {\n\t\tfor (const system of bundle.getSystemBuilders()) {\n\t\t\t// reuse the full builder so we carry over queries, hooks, and handlers\n\t\t\tcombined.addSystem(system);\n\t\t}\n\n\t\t// Add resources from this bundle\n\t\tfor (const [label, resource] of bundle.getResources().entries()) {\n\t\t\tcombined._setResource(label as string, resource);\n\t\t}\n\n\t\t// Add assets from this bundle\n\t\tfor (const [key, definition] of bundle.getAssets().entries()) {\n\t\t\tcombined._setAsset(key, definition);\n\t\t}\n\n\t\t// Add screens from this bundle\n\t\tfor (const [name, definition] of bundle.getScreens().entries()) {\n\t\t\tcombined._setScreen(name, definition);\n\t\t}\n\t}\n\n\treturn combined;\n}\n",
16
16
  "import ECSpresso from \"./ecspresso\";\n\nexport\ninterface Entity<ComponentTypes> {\n\tid: number;\n\tcomponents: Partial<ComponentTypes>;\n}\n\n/**\n * Options for removing an entity\n */\nexport\ninterface RemoveEntityOptions {\n\t/**\n\t * Whether to also remove all descendants (default: true)\n\t */\n\tcascade?: boolean;\n}\n\n/**\n * Event data emitted when an entity's parent changes\n */\nexport\ninterface HierarchyChangedEvent {\n\t/** The entity whose parent changed */\n\tentityId: number;\n\t/** The previous parent, or null if entity had no parent */\n\toldParent: number | null;\n\t/** The new parent, or null if entity was orphaned */\n\tnewParent: number | null;\n}\n\n/**\n * Options for hierarchy traversal methods\n */\nexport\ninterface HierarchyIteratorOptions {\n\t/** Specific root entities to start traversal from. If not provided, all root entities are used. */\n\troots?: readonly number[];\n}\n\n/**\n * Entry yielded during hierarchy traversal\n */\nexport\ninterface HierarchyEntry {\n\t/** The entity being visited */\n\tentityId: number;\n\t/** The parent entity ID, or null for root entities */\n\tparentId: number | null;\n\t/** Depth in the hierarchy (0 for roots) */\n\tdepth: number;\n}\n\nexport\ninterface EventHandler<T> {\n\tcallback: (data: T) => void;\n\tonce: boolean;\n}\n\nexport\ninterface FilteredEntity<\n\tComponentTypes,\n\tWithComponents extends keyof ComponentTypes = never,\n\tWithoutComponents extends keyof ComponentTypes = never,\n> {\n\tid: number;\n\tcomponents: Omit<Partial<ComponentTypes>, WithoutComponents> & {\n\t\t[K in WithComponents]: ComponentTypes[K]\n\t};\n}\n\nexport\ninterface QueryConfig<\n\tComponentTypes,\n\tWithComponents extends keyof ComponentTypes,\n\tWithoutComponents extends keyof ComponentTypes,\n> {\n\twith: ReadonlyArray<WithComponents>;\n\twithout?: ReadonlyArray<WithoutComponents>;\n}\n\n/**\n * Utility type to derive the entity type that would result from a query definition.\n * This is useful for creating helper functions that operate on query results.\n *\n * @example\n * ```typescript\n * const queryDef = {\n * with: ['position', 'sprite'],\n * without: ['dead']\n * };\n *\n * type EntityType = QueryResultEntity<Components, typeof queryDef>;\n *\n * function updateSpritePosition(entity: EntityType) {\n * entity.components.sprite.position.set(\n * entity.components.position.x,\n * entity.components.position.y\n * );\n * }\n * ```\n */\nexport type QueryResultEntity<\n\tComponentTypes extends Record<string, any>,\n\tQueryDef extends {\n\t\twith: ReadonlyArray<keyof ComponentTypes>;\n\t\twithout?: ReadonlyArray<keyof ComponentTypes>;\n\t}\n> = FilteredEntity<\n\tComponentTypes,\n\tQueryDef['with'][number],\n\tQueryDef['without'] extends ReadonlyArray<any> ? QueryDef['without'][number] : never\n>;\n\n/**\n * Simplified query definition type for creating reusable queries\n */\nexport type QueryDefinition<\n\tComponentTypes extends Record<string, any>,\n\tWithComponents extends keyof ComponentTypes = keyof ComponentTypes,\n\tWithoutComponents extends keyof ComponentTypes = keyof ComponentTypes,\n> = {\n\twith: ReadonlyArray<WithComponents>;\n\twithout?: ReadonlyArray<WithoutComponents>;\n};\n\n/**\n * Helper function to create a query definition with proper type inference.\n * This enables better TypeScript inference when creating reusable queries.\n *\n * @example\n * ```typescript\n * const movingEntitiesQuery = createQueryDefinition({\n * with: ['position', 'velocity'],\n * without: ['dead']\n * });\n *\n * type MovingEntity = QueryResultEntity<Components, typeof movingEntitiesQuery>;\n *\n * function updatePosition(entity: MovingEntity) {\n * entity.components.position.x += entity.components.velocity.x;\n * entity.components.position.y += entity.components.velocity.y;\n * }\n *\n * world.addSystem('movement')\n * .addQuery('entities', movingEntitiesQuery)\n * .setProcess((queries) => {\n * for (const entity of queries.entities) {\n * updatePosition(entity);\n * }\n * });\n * ```\n */\nexport function createQueryDefinition<\n\tComponentTypes extends Record<string, any>,\n\tconst QueryDef extends {\n\t\twith: ReadonlyArray<keyof ComponentTypes>;\n\t\twithout?: ReadonlyArray<keyof ComponentTypes>;\n\t}\n>(queryDef: QueryDef): QueryDef {\n\treturn queryDef;\n}\n\nexport\ninterface System<\n\tComponentTypes extends Record<string, any> = {},\n\tWithComponents extends keyof ComponentTypes = never,\n\tWithoutComponents extends keyof ComponentTypes = never,\n\tEventTypes extends Record<string, any> = {},\n\tResourceTypes extends Record<string, any> = {},\n\tAssetTypes extends Record<string, unknown> = {},\n\tScreenStates extends Record<string, any> = {},\n> {\n\tlabel: string;\n\t/**\n\t * System priority - higher values execute first (default: 0)\n\t * When systems have the same priority, they execute in registration order\n\t */\n\tpriority?: number;\n\t/**\n\t * Groups this system belongs to. If any group is disabled, the system will be skipped.\n\t */\n\tgroups?: string[];\n\t/**\n\t * Screens where this system should run. If specified, system only runs\n\t * when current screen is in this list.\n\t */\n\tinScreens?: string[];\n\t/**\n\t * Screens where this system should NOT run. If specified, system skips\n\t * when current screen is in this list.\n\t */\n\texcludeScreens?: string[];\n\t/**\n\t * Assets that must be loaded for this system to run.\n\t * System will be skipped if any required asset is not loaded.\n\t */\n\trequiredAssets?: string[];\n\tentityQueries?: {\n\t\t[queryName: string]: QueryConfig<ComponentTypes, WithComponents, WithoutComponents>;\n\t};\n\t/**\n\t * Process method that runs during each update cycle\n\t * @param queries The entity queries results based on system's entityQueries definition\n\t * @param deltaTime Time elapsed since the last update in seconds\n\t * @param ecs The ECSpresso instance providing access to all ECS functionality\n\t */\n\tprocess?(\n\t\tqueries: {\n\t\t\t[queryName: string]: Array<FilteredEntity<ComponentTypes, WithComponents, WithoutComponents>>;\n\t\t} | Array<FilteredEntity<ComponentTypes, WithComponents, WithoutComponents>>,\n\t\tdeltaTime: number,\n\t\tecs: ECSpresso<\n\t\t\tComponentTypes,\n\t\t\tEventTypes,\n\t\t\tResourceTypes,\n\t\t\tAssetTypes,\n\t\t\tScreenStates\n\t\t>\n\t): void;\n\n\t/**\n\t * Lifecycle hook called when the system is initialized\n\t * This is called when ECSpresso.initialize() is invoked, after resources are initialized\n\t * Use this for one-time initialization that depends on resources\n\t * @param ecs The ECSpresso instance providing access to all ECS functionality\n\t */\n\tonInitialize?(\n\t\tecs: ECSpresso<\n\t\t\tComponentTypes,\n\t\t\tEventTypes,\n\t\t\tResourceTypes,\n\t\t\tAssetTypes,\n\t\t\tScreenStates\n\t\t>\n\t): void | Promise<void>;\n\n\t/**\n\t * Lifecycle hook called when the system is detached from the ECS\n\t * @param ecs The ECSpresso instance providing access to all ECS functionality\n\t */\n\tonDetach?(\n\t\tecs: import(\"./ecspresso\").default<\n\t\t\tComponentTypes,\n\t\t\tEventTypes,\n\t\t\tResourceTypes,\n\t\t\tAssetTypes,\n\t\t\tScreenStates\n\t\t>\n\t): void;\n\n\t/**\n\t * Event handlers for specific event types\n\t */\n\teventHandlers?: {\n\t\t[EventName in keyof EventTypes]?: {\n\t\t\t/**\n\t\t\t * Event handler function\n\t\t\t * @param data The event data specific to this event type\n\t\t\t * @param ecs The ECSpresso instance providing access to all ECS functionality\n\t\t\t */\n\t\t\thandler(\n\t\t\t\tdata: EventTypes[EventName],\n\t\t\t\tecs: ECSpresso<\n\t\t\t\t\tComponentTypes,\n\t\t\t\t\tEventTypes,\n\t\t\t\t\tResourceTypes,\n\t\t\t\t\tAssetTypes,\n\t\t\t\t\tScreenStates\n\t\t\t\t>\n\t\t\t): void;\n\t\t};\n\t};\n}\n\n// Re-export utility types from type-utils to maintain backward compatibility\nexport type { Merge, MergeAll } from './type-utils';\n",
17
17
  "import ECSpresso from './ecspresso';\nimport { SystemBuilder } from './system-builder';\nimport Bundle, { mergeBundles } from './bundle';\n\nexport * from './types';\nexport * from './asset-types';\nexport * from './screen-types';\nexport type { ReactiveQueryDefinition } from './reactive-query-manager';\nexport { default as EntityManager } from './entity-manager';\nexport { default as EventBus } from './event-bus';\nexport { default as CommandBuffer } from './command-buffer';\nexport { default as HierarchyManager } from './hierarchy-manager';\n/**\n * @internal ResourceManager is exported for testing purposes only.\n * Use ECSpresso resource methods instead: getResource(), addResource(), removeResource(), updateResource(), hasResource()\n */\nexport { default as ResourceManager } from './resource-manager';\nexport { default as AssetManager, createAssetConfigurator } from './asset-manager';\nexport { default as ScreenManager, createScreenConfigurator } from './screen-manager';\nexport { SystemBuilder };\nexport { Bundle, mergeBundles };\nexport default ECSpresso;\n"
18
18
  ],
19
- "mappings": "kjBAMA,MAAqB,CAAiB,CAE7B,UAAiC,IAAI,IAErC,YAAqC,IAAI,IAQjD,SAAS,CAAC,EAAiB,EAAwB,CAClD,GAAI,IAAY,EACf,MAAU,MAAM,qBAAqB,qBAA2B,EAIjE,GAAI,KAAK,iBAAiB,EAAS,CAAQ,EAC1C,MAAU,MAAM,oDAAoD,EAIrE,IAAM,EAAY,KAAK,UAAU,IAAI,CAAO,EAC5C,GAAI,IAAc,OAAW,CAC5B,IAAM,EAAc,KAAK,YAAY,IAAI,CAAS,EAClD,GAAI,EAAa,CAChB,IAAM,EAAM,EAAY,QAAQ,CAAO,EACvC,GAAI,IAAQ,GACX,EAAY,OAAO,EAAK,CAAC,GAM5B,KAAK,UAAU,IAAI,EAAS,CAAQ,EAGpC,IAAM,EAAW,KAAK,YAAY,IAAI,CAAQ,EAC9C,GAAI,EACH,EAAS,KAAK,CAAO,EAErB,UAAK,YAAY,IAAI,EAAU,CAAC,CAAO,CAAC,EAGzC,OAAO,KAQR,YAAY,CAAC,EAA0B,CACtC,IAAM,EAAW,KAAK,UAAU,IAAI,CA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EAA8B,CAC/B,OAAO,EC5IR,IAAe",
20
+ "debugId": "BB975495804CE50E64756E2164756E21",
21
21
  "names": []
22
22
  }
@@ -7,17 +7,20 @@
7
7
  */
8
8
  type ExactlyCompatible<T, U> = T extends U ? U extends T ? true : false : false;
9
9
  /**
10
- * Check if two record types are compatible (no conflicting keys)
10
+ * Check if two record types are compatible (no conflicting keys).
11
+ * Returns true if no overlapping keys or all overlapping keys have exactly the same type.
11
12
  */
12
- export type TypesAreCompatible<T extends Record<string, any>, U extends Record<string, any>> = {
13
+ export type TypesAreCompatible<T extends Record<string, any>, U extends Record<string, any>> = [
14
+ keyof T & keyof U
15
+ ] extends [never] ? true : {
13
16
  [K in keyof T & keyof U]: ExactlyCompatible<T[K], U[K]>;
14
17
  }[keyof T & keyof U] extends false ? false : true;
15
18
  /**
16
- * Simplified bundle compatibility checker
17
- * Returns true if bundles can be merged without type conflicts
18
- * More lenient - allows bundles without shared keys to be merged
19
+ * Bundle compatibility checker.
20
+ * Returns true if bundles can be merged without type conflicts.
21
+ * All overlapping keys across all type categories must have identical types.
19
22
  */
20
- export type BundlesAreCompatible<C1 extends Record<string, any>, C2 extends Record<string, any>, E1 extends Record<string, any>, E2 extends Record<string, any>, R1 extends Record<string, any>, R2 extends Record<string, any>> = keyof C1 & keyof C2 extends never ? keyof E1 & keyof E2 extends never ? keyof R1 & keyof R2 extends never ? true : TypesAreCompatible<R1, R2> : TypesAreCompatible<E1, E2> : TypesAreCompatible<C1, C2>;
23
+ export type BundlesAreCompatible<C1 extends Record<string, any>, C2 extends Record<string, any>, E1 extends Record<string, any>, E2 extends Record<string, any>, R1 extends Record<string, any>, R2 extends Record<string, any>, A1 extends Record<string, unknown> = {}, A2 extends Record<string, unknown> = {}, S1 extends Record<string, any> = {}, S2 extends Record<string, any> = {}> = TypesAreCompatible<C1, C2> extends true ? TypesAreCompatible<E1, E2> extends true ? TypesAreCompatible<R1, R2> extends true ? TypesAreCompatible<A1, A2> extends true ? TypesAreCompatible<S1, S2> : false : false : false : false;
21
24
  /**
22
25
  * Utility type for merging two types
23
26
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecspresso",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",