idlerpg.sh 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -0
- package/dist/affix/AffixRegistry.d.ts +68 -0
- package/dist/affix/AffixRegistry.d.ts.map +1 -0
- package/dist/affix/AffixRegistry.js +245 -0
- package/dist/affix/AffixRegistry.js.map +1 -0
- package/dist/affix/PluginLoader.d.ts +66 -0
- package/dist/affix/PluginLoader.d.ts.map +1 -0
- package/dist/affix/PluginLoader.js +321 -0
- package/dist/affix/PluginLoader.js.map +1 -0
- package/dist/affix/builtin.d.ts +6 -0
- package/dist/affix/builtin.d.ts.map +1 -0
- package/dist/affix/builtin.js +311 -0
- package/dist/affix/builtin.js.map +1 -0
- package/dist/affix/index.d.ts +8 -0
- package/dist/affix/index.d.ts.map +1 -0
- package/dist/affix/index.js +11 -0
- package/dist/affix/index.js.map +1 -0
- package/dist/affix/types.d.ts +152 -0
- package/dist/affix/types.d.ts.map +1 -0
- package/dist/affix/types.js +8 -0
- package/dist/affix/types.js.map +1 -0
- package/dist/ai/PlayKitClient.d.ts +208 -0
- package/dist/ai/PlayKitClient.d.ts.map +1 -0
- package/dist/ai/PlayKitClient.js +721 -0
- package/dist/ai/PlayKitClient.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +8 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/app/App.d.ts +85 -0
- package/dist/app/App.d.ts.map +1 -0
- package/dist/app/App.js +296 -0
- package/dist/app/App.js.map +1 -0
- package/dist/app/EventBus.d.ts +222 -0
- package/dist/app/EventBus.d.ts.map +1 -0
- package/dist/app/EventBus.js +88 -0
- package/dist/app/EventBus.js.map +1 -0
- package/dist/app/Keybind.d.ts +83 -0
- package/dist/app/Keybind.d.ts.map +1 -0
- package/dist/app/Keybind.js +184 -0
- package/dist/app/Keybind.js.map +1 -0
- package/dist/app/Router.d.ts +123 -0
- package/dist/app/Router.d.ts.map +1 -0
- package/dist/app/Router.js +142 -0
- package/dist/app/Router.js.map +1 -0
- package/dist/app/ScreenManager.d.ts +97 -0
- package/dist/app/ScreenManager.d.ts.map +1 -0
- package/dist/app/ScreenManager.js +216 -0
- package/dist/app/ScreenManager.js.map +1 -0
- package/dist/app/index.d.ts +14 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +19 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/screens/BaseScreen.d.ts +101 -0
- package/dist/app/screens/BaseScreen.d.ts.map +1 -0
- package/dist/app/screens/BaseScreen.js +132 -0
- package/dist/app/screens/BaseScreen.js.map +1 -0
- package/dist/app/screens/CharacterCreationScreen.d.ts +42 -0
- package/dist/app/screens/CharacterCreationScreen.d.ts.map +1 -0
- package/dist/app/screens/CharacterCreationScreen.js +467 -0
- package/dist/app/screens/CharacterCreationScreen.js.map +1 -0
- package/dist/app/screens/CombatScreen.d.ts +30 -0
- package/dist/app/screens/CombatScreen.d.ts.map +1 -0
- package/dist/app/screens/CombatScreen.js +309 -0
- package/dist/app/screens/CombatScreen.js.map +1 -0
- package/dist/app/screens/DialogScreen.d.ts +29 -0
- package/dist/app/screens/DialogScreen.d.ts.map +1 -0
- package/dist/app/screens/DialogScreen.js +295 -0
- package/dist/app/screens/DialogScreen.js.map +1 -0
- package/dist/app/screens/ExploreScreen.d.ts +50 -0
- package/dist/app/screens/ExploreScreen.d.ts.map +1 -0
- package/dist/app/screens/ExploreScreen.js +308 -0
- package/dist/app/screens/ExploreScreen.js.map +1 -0
- package/dist/app/screens/HelpScreen.d.ts +12 -0
- package/dist/app/screens/HelpScreen.d.ts.map +1 -0
- package/dist/app/screens/HelpScreen.js +155 -0
- package/dist/app/screens/HelpScreen.js.map +1 -0
- package/dist/app/screens/InventoryScreen.d.ts +27 -0
- package/dist/app/screens/InventoryScreen.d.ts.map +1 -0
- package/dist/app/screens/InventoryScreen.js +326 -0
- package/dist/app/screens/InventoryScreen.js.map +1 -0
- package/dist/app/screens/PrologueScreen.d.ts +24 -0
- package/dist/app/screens/PrologueScreen.d.ts.map +1 -0
- package/dist/app/screens/PrologueScreen.js +176 -0
- package/dist/app/screens/PrologueScreen.js.map +1 -0
- package/dist/app/screens/TitleScreen.d.ts +42 -0
- package/dist/app/screens/TitleScreen.d.ts.map +1 -0
- package/dist/app/screens/TitleScreen.js +380 -0
- package/dist/app/screens/TitleScreen.js.map +1 -0
- package/dist/app/screens/TravelScreen.d.ts +22 -0
- package/dist/app/screens/TravelScreen.d.ts.map +1 -0
- package/dist/app/screens/TravelScreen.js +122 -0
- package/dist/app/screens/TravelScreen.js.map +1 -0
- package/dist/app/screens/index.d.ts +14 -0
- package/dist/app/screens/index.d.ts.map +1 -0
- package/dist/app/screens/index.js +17 -0
- package/dist/app/screens/index.js.map +1 -0
- package/dist/commands/CommandRegistry.d.ts +91 -0
- package/dist/commands/CommandRegistry.d.ts.map +1 -0
- package/dist/commands/CommandRegistry.js +159 -0
- package/dist/commands/CommandRegistry.js.map +1 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +10 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/core/Actor.d.ts +103 -0
- package/dist/core/Actor.d.ts.map +1 -0
- package/dist/core/Actor.js +409 -0
- package/dist/core/Actor.js.map +1 -0
- package/dist/core/Combat.d.ts +37 -0
- package/dist/core/Combat.d.ts.map +1 -0
- package/dist/core/Combat.js +294 -0
- package/dist/core/Combat.js.map +1 -0
- package/dist/core/DungeonRunner.d.ts +169 -0
- package/dist/core/DungeonRunner.d.ts.map +1 -0
- package/dist/core/DungeonRunner.js +627 -0
- package/dist/core/DungeonRunner.js.map +1 -0
- package/dist/core/Game.d.ts +133 -0
- package/dist/core/Game.d.ts.map +1 -0
- package/dist/core/Game.js +644 -0
- package/dist/core/Game.js.map +1 -0
- package/dist/core/IdleCombat.d.ts +61 -0
- package/dist/core/IdleCombat.d.ts.map +1 -0
- package/dist/core/IdleCombat.js +461 -0
- package/dist/core/IdleCombat.js.map +1 -0
- package/dist/core/IdleGameManager.d.ts +198 -0
- package/dist/core/IdleGameManager.d.ts.map +1 -0
- package/dist/core/IdleGameManager.js +688 -0
- package/dist/core/IdleGameManager.js.map +1 -0
- package/dist/core/IdleSaveManager.d.ts +109 -0
- package/dist/core/IdleSaveManager.d.ts.map +1 -0
- package/dist/core/IdleSaveManager.js +296 -0
- package/dist/core/IdleSaveManager.js.map +1 -0
- package/dist/core/NewGameFlowManager.d.ts +64 -0
- package/dist/core/NewGameFlowManager.d.ts.map +1 -0
- package/dist/core/NewGameFlowManager.js +153 -0
- package/dist/core/NewGameFlowManager.js.map +1 -0
- package/dist/core/Player.d.ts +65 -0
- package/dist/core/Player.d.ts.map +1 -0
- package/dist/core/Player.js +261 -0
- package/dist/core/Player.js.map +1 -0
- package/dist/core/RoomHandlers.d.ts +75 -0
- package/dist/core/RoomHandlers.d.ts.map +1 -0
- package/dist/core/RoomHandlers.js +383 -0
- package/dist/core/RoomHandlers.js.map +1 -0
- package/dist/core/SaveManager.d.ts +84 -0
- package/dist/core/SaveManager.d.ts.map +1 -0
- package/dist/core/SaveManager.js +281 -0
- package/dist/core/SaveManager.js.map +1 -0
- package/dist/core/SaveMigration.d.ts +69 -0
- package/dist/core/SaveMigration.d.ts.map +1 -0
- package/dist/core/SaveMigration.js +408 -0
- package/dist/core/SaveMigration.js.map +1 -0
- package/dist/core/StateAdapter.d.ts +79 -0
- package/dist/core/StateAdapter.d.ts.map +1 -0
- package/dist/core/StateAdapter.js +397 -0
- package/dist/core/StateAdapter.js.map +1 -0
- package/dist/core/Team.d.ts +145 -0
- package/dist/core/Team.d.ts.map +1 -0
- package/dist/core/Team.js +371 -0
- package/dist/core/Team.js.map +1 -0
- package/dist/core/TeamCombat.d.ts +88 -0
- package/dist/core/TeamCombat.d.ts.map +1 -0
- package/dist/core/TeamCombat.js +405 -0
- package/dist/core/TeamCombat.js.map +1 -0
- package/dist/core/TeamDungeonRunner.d.ts +186 -0
- package/dist/core/TeamDungeonRunner.d.ts.map +1 -0
- package/dist/core/TeamDungeonRunner.js +758 -0
- package/dist/core/TeamDungeonRunner.js.map +1 -0
- package/dist/core/TimeManager.d.ts +114 -0
- package/dist/core/TimeManager.d.ts.map +1 -0
- package/dist/core/TimeManager.js +318 -0
- package/dist/core/TimeManager.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/timeConstants.d.ts +135 -0
- package/dist/core/timeConstants.d.ts.map +1 -0
- package/dist/core/timeConstants.js +157 -0
- package/dist/core/timeConstants.js.map +1 -0
- package/dist/core/types.d.ts +780 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +16 -0
- package/dist/core/types.js.map +1 -0
- package/dist/data/continents/index.d.ts +163 -0
- package/dist/data/continents/index.d.ts.map +1 -0
- package/dist/data/continents/index.js +31 -0
- package/dist/data/continents/index.js.map +1 -0
- package/dist/data/continents/verdantia.d.ts +294 -0
- package/dist/data/continents/verdantia.d.ts.map +1 -0
- package/dist/data/continents/verdantia.js +327 -0
- package/dist/data/continents/verdantia.js.map +1 -0
- package/dist/handlers/DialogHandler.d.ts +95 -0
- package/dist/handlers/DialogHandler.d.ts.map +1 -0
- package/dist/handlers/DialogHandler.js +450 -0
- package/dist/handlers/DialogHandler.js.map +1 -0
- package/dist/handlers/SaveLoadHandler.d.ts +60 -0
- package/dist/handlers/SaveLoadHandler.d.ts.map +1 -0
- package/dist/handlers/SaveLoadHandler.js +187 -0
- package/dist/handlers/SaveLoadHandler.js.map +1 -0
- package/dist/handlers/TitleScreenHandler.d.ts +43 -0
- package/dist/handlers/TitleScreenHandler.d.ts.map +1 -0
- package/dist/handlers/TitleScreenHandler.js +508 -0
- package/dist/handlers/TitleScreenHandler.js.map +1 -0
- package/dist/handlers/WorkshopHandler.d.ts +75 -0
- package/dist/handlers/WorkshopHandler.d.ts.map +1 -0
- package/dist/handlers/WorkshopHandler.js +401 -0
- package/dist/handlers/WorkshopHandler.js.map +1 -0
- package/dist/handlers/index.d.ts +12 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +14 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/types.d.ts +34 -0
- package/dist/handlers/types.d.ts.map +1 -0
- package/dist/handlers/types.js +8 -0
- package/dist/handlers/types.js.map +1 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +130 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +40 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +105 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/types.d.ts +133 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +8 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/i18n/zh.d.ts +3 -0
- package/dist/i18n/zh.d.ts.map +1 -0
- package/dist/i18n/zh.js +130 -0
- package/dist/i18n/zh.js.map +1 -0
- package/dist/instrument.d.ts +8 -0
- package/dist/instrument.d.ts.map +1 -0
- package/dist/instrument.js +33 -0
- package/dist/instrument.js.map +1 -0
- package/dist/main-new.d.ts +12 -0
- package/dist/main-new.d.ts.map +1 -0
- package/dist/main-new.js +32 -0
- package/dist/main-new.js.map +1 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +2816 -0
- package/dist/main.js.map +1 -0
- package/dist/map/ContinentManager.d.ts +88 -0
- package/dist/map/ContinentManager.d.ts.map +1 -0
- package/dist/map/ContinentManager.js +241 -0
- package/dist/map/ContinentManager.js.map +1 -0
- package/dist/map/DungeonGenerator.d.ts +32 -0
- package/dist/map/DungeonGenerator.d.ts.map +1 -0
- package/dist/map/DungeonGenerator.js +615 -0
- package/dist/map/DungeonGenerator.js.map +1 -0
- package/dist/map/MapGenerator.d.ts +27 -0
- package/dist/map/MapGenerator.d.ts.map +1 -0
- package/dist/map/MapGenerator.js +485 -0
- package/dist/map/MapGenerator.js.map +1 -0
- package/dist/map/index.d.ts +5 -0
- package/dist/map/index.d.ts.map +1 -0
- package/dist/map/index.js +8 -0
- package/dist/map/index.js.map +1 -0
- package/dist/npc/NPCGenerator.d.ts +68 -0
- package/dist/npc/NPCGenerator.d.ts.map +1 -0
- package/dist/npc/NPCGenerator.js +468 -0
- package/dist/npc/NPCGenerator.js.map +1 -0
- package/dist/npc/NPCManager.d.ts +86 -0
- package/dist/npc/NPCManager.d.ts.map +1 -0
- package/dist/npc/NPCManager.js +217 -0
- package/dist/npc/NPCManager.js.map +1 -0
- package/dist/npc/fixedNPCs.d.ts +7 -0
- package/dist/npc/fixedNPCs.d.ts.map +1 -0
- package/dist/npc/fixedNPCs.js +196 -0
- package/dist/npc/fixedNPCs.js.map +1 -0
- package/dist/npc/index.d.ts +9 -0
- package/dist/npc/index.d.ts.map +1 -0
- package/dist/npc/index.js +12 -0
- package/dist/npc/index.js.map +1 -0
- package/dist/npc/traits.d.ts +33 -0
- package/dist/npc/traits.d.ts.map +1 -0
- package/dist/npc/traits.js +795 -0
- package/dist/npc/traits.js.map +1 -0
- package/dist/npc/types.d.ts +193 -0
- package/dist/npc/types.d.ts.map +1 -0
- package/dist/npc/types.js +9 -0
- package/dist/npc/types.js.map +1 -0
- package/dist/quest/QuestManager.d.ts +79 -0
- package/dist/quest/QuestManager.d.ts.map +1 -0
- package/dist/quest/QuestManager.js +273 -0
- package/dist/quest/QuestManager.js.map +1 -0
- package/dist/quest/index.d.ts +6 -0
- package/dist/quest/index.d.ts.map +1 -0
- package/dist/quest/index.js +9 -0
- package/dist/quest/index.js.map +1 -0
- package/dist/quest/types.d.ts +81 -0
- package/dist/quest/types.d.ts.map +1 -0
- package/dist/quest/types.js +8 -0
- package/dist/quest/types.js.map +1 -0
- package/dist/strategy/StrategyExecutor.d.ts +159 -0
- package/dist/strategy/StrategyExecutor.d.ts.map +1 -0
- package/dist/strategy/StrategyExecutor.js +479 -0
- package/dist/strategy/StrategyExecutor.js.map +1 -0
- package/dist/strategy/StrategyParser.d.ts +48 -0
- package/dist/strategy/StrategyParser.d.ts.map +1 -0
- package/dist/strategy/StrategyParser.js +321 -0
- package/dist/strategy/StrategyParser.js.map +1 -0
- package/dist/strategy/defaultStrategy.d.ts +40 -0
- package/dist/strategy/defaultStrategy.d.ts.map +1 -0
- package/dist/strategy/defaultStrategy.js +254 -0
- package/dist/strategy/defaultStrategy.js.map +1 -0
- package/dist/strategy/index.d.ts +8 -0
- package/dist/strategy/index.d.ts.map +1 -0
- package/dist/strategy/index.js +14 -0
- package/dist/strategy/index.js.map +1 -0
- package/dist/tui/ExploreMenu.d.ts +106 -0
- package/dist/tui/ExploreMenu.d.ts.map +1 -0
- package/dist/tui/ExploreMenu.js +282 -0
- package/dist/tui/ExploreMenu.js.map +1 -0
- package/dist/tui/GameUI.d.ts +313 -0
- package/dist/tui/GameUI.d.ts.map +1 -0
- package/dist/tui/GameUI.js +2116 -0
- package/dist/tui/GameUI.js.map +1 -0
- package/dist/tui/GameUIAdapter.d.ts +207 -0
- package/dist/tui/GameUIAdapter.d.ts.map +1 -0
- package/dist/tui/GameUIAdapter.js +1342 -0
- package/dist/tui/GameUIAdapter.js.map +1 -0
- package/dist/tui/Input.d.ts +139 -0
- package/dist/tui/Input.d.ts.map +1 -0
- package/dist/tui/Input.js +278 -0
- package/dist/tui/Input.js.map +1 -0
- package/dist/tui/Menu.d.ts +110 -0
- package/dist/tui/Menu.d.ts.map +1 -0
- package/dist/tui/Menu.js +365 -0
- package/dist/tui/Menu.js.map +1 -0
- package/dist/tui/Screen.d.ts +228 -0
- package/dist/tui/Screen.d.ts.map +1 -0
- package/dist/tui/Screen.js +502 -0
- package/dist/tui/Screen.js.map +1 -0
- package/dist/tui/components/Box.d.ts +36 -0
- package/dist/tui/components/Box.d.ts.map +1 -0
- package/dist/tui/components/Box.js +43 -0
- package/dist/tui/components/Box.js.map +1 -0
- package/dist/tui/components/List.d.ts +69 -0
- package/dist/tui/components/List.d.ts.map +1 -0
- package/dist/tui/components/List.js +136 -0
- package/dist/tui/components/List.js.map +1 -0
- package/dist/tui/components/ProgressBar.d.ts +42 -0
- package/dist/tui/components/ProgressBar.d.ts.map +1 -0
- package/dist/tui/components/ProgressBar.js +75 -0
- package/dist/tui/components/ProgressBar.js.map +1 -0
- package/dist/tui/components/index.d.ts +8 -0
- package/dist/tui/components/index.d.ts.map +1 -0
- package/dist/tui/components/index.js +11 -0
- package/dist/tui/components/index.js.map +1 -0
- package/dist/tui/core/BaseSection.d.ts +98 -0
- package/dist/tui/core/BaseSection.d.ts.map +1 -0
- package/dist/tui/core/BaseSection.js +174 -0
- package/dist/tui/core/BaseSection.js.map +1 -0
- package/dist/tui/core/Component.d.ts +61 -0
- package/dist/tui/core/Component.d.ts.map +1 -0
- package/dist/tui/core/Component.js +32 -0
- package/dist/tui/core/Component.js.map +1 -0
- package/dist/tui/core/Section.d.ts +101 -0
- package/dist/tui/core/Section.d.ts.map +1 -0
- package/dist/tui/core/Section.js +24 -0
- package/dist/tui/core/Section.js.map +1 -0
- package/dist/tui/core/SectionManager.d.ts +108 -0
- package/dist/tui/core/SectionManager.d.ts.map +1 -0
- package/dist/tui/core/SectionManager.js +258 -0
- package/dist/tui/core/SectionManager.js.map +1 -0
- package/dist/tui/core/index.d.ts +9 -0
- package/dist/tui/core/index.d.ts.map +1 -0
- package/dist/tui/core/index.js +12 -0
- package/dist/tui/core/index.js.map +1 -0
- package/dist/tui/index.d.ts +15 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +23 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/screens/BaseScreen.d.ts +62 -0
- package/dist/tui/screens/BaseScreen.d.ts.map +1 -0
- package/dist/tui/screens/BaseScreen.js +55 -0
- package/dist/tui/screens/BaseScreen.js.map +1 -0
- package/dist/tui/screens/CombatScreen.d.ts +43 -0
- package/dist/tui/screens/CombatScreen.d.ts.map +1 -0
- package/dist/tui/screens/CombatScreen.js +125 -0
- package/dist/tui/screens/CombatScreen.js.map +1 -0
- package/dist/tui/screens/DialogScreen.d.ts +53 -0
- package/dist/tui/screens/DialogScreen.d.ts.map +1 -0
- package/dist/tui/screens/DialogScreen.js +90 -0
- package/dist/tui/screens/DialogScreen.js.map +1 -0
- package/dist/tui/screens/DungeonScreen.d.ts +80 -0
- package/dist/tui/screens/DungeonScreen.d.ts.map +1 -0
- package/dist/tui/screens/DungeonScreen.js +317 -0
- package/dist/tui/screens/DungeonScreen.js.map +1 -0
- package/dist/tui/screens/ExploreScreen.d.ts +69 -0
- package/dist/tui/screens/ExploreScreen.d.ts.map +1 -0
- package/dist/tui/screens/ExploreScreen.js +224 -0
- package/dist/tui/screens/ExploreScreen.js.map +1 -0
- package/dist/tui/screens/SectionScreen.d.ts +84 -0
- package/dist/tui/screens/SectionScreen.d.ts.map +1 -0
- package/dist/tui/screens/SectionScreen.js +156 -0
- package/dist/tui/screens/SectionScreen.js.map +1 -0
- package/dist/tui/screens/TitleScreen.d.ts +40 -0
- package/dist/tui/screens/TitleScreen.d.ts.map +1 -0
- package/dist/tui/screens/TitleScreen.js +253 -0
- package/dist/tui/screens/TitleScreen.js.map +1 -0
- package/dist/tui/screens/TownScreen.d.ts +98 -0
- package/dist/tui/screens/TownScreen.d.ts.map +1 -0
- package/dist/tui/screens/TownScreen.js +370 -0
- package/dist/tui/screens/TownScreen.js.map +1 -0
- package/dist/tui/screens/TravelScreen.d.ts +67 -0
- package/dist/tui/screens/TravelScreen.d.ts.map +1 -0
- package/dist/tui/screens/TravelScreen.js +286 -0
- package/dist/tui/screens/TravelScreen.js.map +1 -0
- package/dist/tui/screens/index.d.ts +8 -0
- package/dist/tui/screens/index.d.ts.map +1 -0
- package/dist/tui/screens/index.js +17 -0
- package/dist/tui/screens/index.js.map +1 -0
- package/dist/tui/sections/ActionsSection.d.ts +71 -0
- package/dist/tui/sections/ActionsSection.d.ts.map +1 -0
- package/dist/tui/sections/ActionsSection.js +184 -0
- package/dist/tui/sections/ActionsSection.js.map +1 -0
- package/dist/tui/sections/DungeonSection.d.ts +65 -0
- package/dist/tui/sections/DungeonSection.d.ts.map +1 -0
- package/dist/tui/sections/DungeonSection.js +144 -0
- package/dist/tui/sections/DungeonSection.js.map +1 -0
- package/dist/tui/sections/EventsSection.d.ts +50 -0
- package/dist/tui/sections/EventsSection.d.ts.map +1 -0
- package/dist/tui/sections/EventsSection.js +134 -0
- package/dist/tui/sections/EventsSection.js.map +1 -0
- package/dist/tui/sections/MapSection.d.ts +66 -0
- package/dist/tui/sections/MapSection.d.ts.map +1 -0
- package/dist/tui/sections/MapSection.js +669 -0
- package/dist/tui/sections/MapSection.js.map +1 -0
- package/dist/tui/sections/StatusSection.d.ts +47 -0
- package/dist/tui/sections/StatusSection.d.ts.map +1 -0
- package/dist/tui/sections/StatusSection.js +133 -0
- package/dist/tui/sections/StatusSection.js.map +1 -0
- package/dist/tui/sections/TeamSection.d.ts +71 -0
- package/dist/tui/sections/TeamSection.d.ts.map +1 -0
- package/dist/tui/sections/TeamSection.js +224 -0
- package/dist/tui/sections/TeamSection.js.map +1 -0
- package/dist/tui/sections/TravelingSection.d.ts +51 -0
- package/dist/tui/sections/TravelingSection.d.ts.map +1 -0
- package/dist/tui/sections/TravelingSection.js +106 -0
- package/dist/tui/sections/TravelingSection.js.map +1 -0
- package/dist/tui/sections/index.d.ts +9 -0
- package/dist/tui/sections/index.d.ts.map +1 -0
- package/dist/tui/sections/index.js +12 -0
- package/dist/tui/sections/index.js.map +1 -0
- package/dist/ui/Terminal.d.ts +68 -0
- package/dist/ui/Terminal.d.ts.map +1 -0
- package/dist/ui/Terminal.js +297 -0
- package/dist/ui/Terminal.js.map +1 -0
- package/dist/ui/index.d.ts +5 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +8 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/utils/configMigration.d.ts +14 -0
- package/dist/utils/configMigration.d.ts.map +1 -0
- package/dist/utils/configMigration.js +92 -0
- package/dist/utils/configMigration.js.map +1 -0
- package/dist/utils/errorHandler.d.ts +86 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/errorHandler.js +224 -0
- package/dist/utils/errorHandler.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +43 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/weapon/WeaponFactory.d.ts +32 -0
- package/dist/weapon/WeaponFactory.d.ts.map +1 -0
- package/dist/weapon/WeaponFactory.js +216 -0
- package/dist/weapon/WeaponFactory.js.map +1 -0
- package/dist/weapon/index.d.ts +5 -0
- package/dist/weapon/index.d.ts.map +1 -0
- package/dist/weapon/index.js +8 -0
- package/dist/weapon/index.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Bus - Centralized event system for cross-component communication
|
|
3
|
+
* Inspired by opencode's bus system
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import type { Player, Dungeon, Town } from '../core/types.js';
|
|
7
|
+
import type { DungeonRunnerState } from '../core/DungeonRunner.js';
|
|
8
|
+
import type { IdleCombatState } from '../core/IdleCombat.js';
|
|
9
|
+
/**
|
|
10
|
+
* IdleGameManager phase type
|
|
11
|
+
*/
|
|
12
|
+
export type IdleGamePhase = 'in_town' | 'traveling_to_dungeon' | 'in_dungeon' | 'returning_to_town' | 'resting' | 'dead';
|
|
13
|
+
/**
|
|
14
|
+
* Game event types
|
|
15
|
+
*/
|
|
16
|
+
export interface GameEvents {
|
|
17
|
+
'game:init': {
|
|
18
|
+
playerName: string;
|
|
19
|
+
};
|
|
20
|
+
'game:start': void;
|
|
21
|
+
'game:pause': void;
|
|
22
|
+
'game:resume': void;
|
|
23
|
+
'game:save': {
|
|
24
|
+
slot: number;
|
|
25
|
+
};
|
|
26
|
+
'game:load': {
|
|
27
|
+
slot: number;
|
|
28
|
+
};
|
|
29
|
+
'game:exit': void;
|
|
30
|
+
'player:move': {
|
|
31
|
+
roomId: string;
|
|
32
|
+
};
|
|
33
|
+
'player:damage': {
|
|
34
|
+
amount: number;
|
|
35
|
+
source: string;
|
|
36
|
+
};
|
|
37
|
+
'player:heal': {
|
|
38
|
+
amount: number;
|
|
39
|
+
};
|
|
40
|
+
'player:levelup': {
|
|
41
|
+
level: number;
|
|
42
|
+
};
|
|
43
|
+
'player:death': void;
|
|
44
|
+
'player:gold': {
|
|
45
|
+
amount: number;
|
|
46
|
+
};
|
|
47
|
+
'player:xp': {
|
|
48
|
+
amount: number;
|
|
49
|
+
};
|
|
50
|
+
'player:update': {
|
|
51
|
+
player: Player;
|
|
52
|
+
};
|
|
53
|
+
'combat:start': {
|
|
54
|
+
encounterId: string;
|
|
55
|
+
enemies: string[];
|
|
56
|
+
};
|
|
57
|
+
'combat:turn': {
|
|
58
|
+
turnNumber: number;
|
|
59
|
+
};
|
|
60
|
+
'combat:action': {
|
|
61
|
+
action: string;
|
|
62
|
+
target?: string;
|
|
63
|
+
};
|
|
64
|
+
'combat:damage': {
|
|
65
|
+
target: string;
|
|
66
|
+
amount: number;
|
|
67
|
+
};
|
|
68
|
+
'combat:end': {
|
|
69
|
+
victory: boolean;
|
|
70
|
+
};
|
|
71
|
+
'npc:interact': {
|
|
72
|
+
npcId: string;
|
|
73
|
+
};
|
|
74
|
+
'npc:dialog': {
|
|
75
|
+
npcId: string;
|
|
76
|
+
message: string;
|
|
77
|
+
};
|
|
78
|
+
'npc:trade': {
|
|
79
|
+
npcId: string;
|
|
80
|
+
};
|
|
81
|
+
'npc:quest': {
|
|
82
|
+
npcId: string;
|
|
83
|
+
questId: string;
|
|
84
|
+
};
|
|
85
|
+
'quest:accept': {
|
|
86
|
+
questId: string;
|
|
87
|
+
};
|
|
88
|
+
'quest:progress': {
|
|
89
|
+
questId: string;
|
|
90
|
+
objectiveId: string;
|
|
91
|
+
};
|
|
92
|
+
'quest:complete': {
|
|
93
|
+
questId: string;
|
|
94
|
+
};
|
|
95
|
+
'quest:abandon': {
|
|
96
|
+
questId: string;
|
|
97
|
+
};
|
|
98
|
+
'ui:toast': {
|
|
99
|
+
message: string;
|
|
100
|
+
type: 'info' | 'success' | 'warning' | 'error';
|
|
101
|
+
};
|
|
102
|
+
'ui:log': {
|
|
103
|
+
message: string;
|
|
104
|
+
};
|
|
105
|
+
'ui:refresh': void;
|
|
106
|
+
'ui:modal': {
|
|
107
|
+
title: string;
|
|
108
|
+
content: string;
|
|
109
|
+
};
|
|
110
|
+
'ui:confirm': {
|
|
111
|
+
title: string;
|
|
112
|
+
message: string;
|
|
113
|
+
onConfirm: () => void;
|
|
114
|
+
};
|
|
115
|
+
'travel:start': {
|
|
116
|
+
from: string;
|
|
117
|
+
to: string;
|
|
118
|
+
duration: number;
|
|
119
|
+
};
|
|
120
|
+
'travel:progress': {
|
|
121
|
+
progress: number;
|
|
122
|
+
duration: number;
|
|
123
|
+
};
|
|
124
|
+
'travel:event': {
|
|
125
|
+
type: string;
|
|
126
|
+
description: string;
|
|
127
|
+
};
|
|
128
|
+
'travel:complete': {
|
|
129
|
+
roomId: string;
|
|
130
|
+
};
|
|
131
|
+
'travel:cancel': void;
|
|
132
|
+
'inventory:add': {
|
|
133
|
+
itemId: string;
|
|
134
|
+
count: number;
|
|
135
|
+
};
|
|
136
|
+
'inventory:remove': {
|
|
137
|
+
itemId: string;
|
|
138
|
+
count: number;
|
|
139
|
+
};
|
|
140
|
+
'inventory:equip': {
|
|
141
|
+
itemId: string;
|
|
142
|
+
slot: string;
|
|
143
|
+
};
|
|
144
|
+
'inventory:unequip': {
|
|
145
|
+
slot: string;
|
|
146
|
+
};
|
|
147
|
+
'system:error': {
|
|
148
|
+
error: Error | string;
|
|
149
|
+
};
|
|
150
|
+
'system:resize': {
|
|
151
|
+
width: number;
|
|
152
|
+
height: number;
|
|
153
|
+
};
|
|
154
|
+
'idle:phaseChange': {
|
|
155
|
+
phase: IdleGamePhase;
|
|
156
|
+
town: Town;
|
|
157
|
+
dungeon: Dungeon | null;
|
|
158
|
+
};
|
|
159
|
+
'idle:dungeonProgress': {
|
|
160
|
+
runnerState: DungeonRunnerState;
|
|
161
|
+
combat: IdleCombatState | null;
|
|
162
|
+
};
|
|
163
|
+
'idle:dungeonComplete': {
|
|
164
|
+
success: boolean;
|
|
165
|
+
rewards: {
|
|
166
|
+
gold: number;
|
|
167
|
+
exp: number;
|
|
168
|
+
items: string[];
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Event payload type helper
|
|
174
|
+
*/
|
|
175
|
+
type EventPayload<K extends keyof GameEvents> = GameEvents[K];
|
|
176
|
+
/**
|
|
177
|
+
* Event Bus class
|
|
178
|
+
*/
|
|
179
|
+
declare class EventBus extends EventEmitter {
|
|
180
|
+
private eventLog;
|
|
181
|
+
private maxLogSize;
|
|
182
|
+
constructor();
|
|
183
|
+
/**
|
|
184
|
+
* Emit a typed event
|
|
185
|
+
*/
|
|
186
|
+
dispatch<K extends keyof GameEvents>(event: K, payload: EventPayload<K>): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Subscribe to a typed event
|
|
189
|
+
*/
|
|
190
|
+
subscribe<K extends keyof GameEvents>(event: K, handler: (payload: EventPayload<K>) => void): () => void;
|
|
191
|
+
/**
|
|
192
|
+
* Subscribe once to a typed event
|
|
193
|
+
*/
|
|
194
|
+
subscribeOnce<K extends keyof GameEvents>(event: K, handler: (payload: EventPayload<K>) => void): void;
|
|
195
|
+
/**
|
|
196
|
+
* Get recent events
|
|
197
|
+
*/
|
|
198
|
+
getRecentEvents(count?: number): Array<{
|
|
199
|
+
event: string;
|
|
200
|
+
payload: unknown;
|
|
201
|
+
time: number;
|
|
202
|
+
}>;
|
|
203
|
+
/**
|
|
204
|
+
* Clear event log
|
|
205
|
+
*/
|
|
206
|
+
clearLog(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Helper to dispatch UI toast
|
|
209
|
+
*/
|
|
210
|
+
toast(message: string, type?: 'info' | 'success' | 'warning' | 'error'): void;
|
|
211
|
+
/**
|
|
212
|
+
* Helper to dispatch UI log
|
|
213
|
+
*/
|
|
214
|
+
log(message: string): void;
|
|
215
|
+
/**
|
|
216
|
+
* Helper to dispatch error
|
|
217
|
+
*/
|
|
218
|
+
error(error: Error | string): void;
|
|
219
|
+
}
|
|
220
|
+
export declare function getEventBus(): EventBus;
|
|
221
|
+
export { EventBus };
|
|
222
|
+
//# sourceMappingURL=EventBus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventBus.d.ts","sourceRoot":"/","sources":["app/EventBus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,sBAAsB,GACtB,YAAY,GACZ,mBAAmB,GACnB,SAAS,GACT,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,UAAU;IAEzB,WAAW,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,YAAY,EAAE,IAAI,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;IACnB,aAAa,EAAE,IAAI,CAAC;IACpB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,WAA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,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,MAAM,IAAI;IAKb;;OAEG;IACH,aAAa,CAAC,CAAC,SAAS,MAAM,UAAU,EACtC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAC1C,IAAI;IAIP;;OAEG;IACH,eAAe,CAAC,KAAK,GAAE,MAAW,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAI7F;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAgB,GAAG,IAAI;IAIrF;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI;CAGnC;AAKD,wBAAgB,WAAW,IAAI,QAAQ,CAKtC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Bus - Centralized event system for cross-component communication
|
|
3
|
+
* Inspired by opencode's bus system
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3cd1e8b8-6605-5d6b-aff6-ddadc2b73921")}catch(e){}}();
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
/**
|
|
9
|
+
* Event Bus class
|
|
10
|
+
*/
|
|
11
|
+
class EventBus extends EventEmitter {
|
|
12
|
+
eventLog = [];
|
|
13
|
+
maxLogSize = 100;
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.setMaxListeners(100); // Allow many listeners
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Emit a typed event
|
|
20
|
+
*/
|
|
21
|
+
dispatch(event, payload) {
|
|
22
|
+
// Log event
|
|
23
|
+
this.eventLog.push({
|
|
24
|
+
event,
|
|
25
|
+
payload,
|
|
26
|
+
time: Date.now(),
|
|
27
|
+
});
|
|
28
|
+
// Trim log
|
|
29
|
+
if (this.eventLog.length > this.maxLogSize) {
|
|
30
|
+
this.eventLog = this.eventLog.slice(-this.maxLogSize);
|
|
31
|
+
}
|
|
32
|
+
return this.emit(event, payload);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to a typed event
|
|
36
|
+
*/
|
|
37
|
+
subscribe(event, handler) {
|
|
38
|
+
this.on(event, handler);
|
|
39
|
+
return () => this.off(event, handler);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Subscribe once to a typed event
|
|
43
|
+
*/
|
|
44
|
+
subscribeOnce(event, handler) {
|
|
45
|
+
this.once(event, handler);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get recent events
|
|
49
|
+
*/
|
|
50
|
+
getRecentEvents(count = 10) {
|
|
51
|
+
return this.eventLog.slice(-count);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clear event log
|
|
55
|
+
*/
|
|
56
|
+
clearLog() {
|
|
57
|
+
this.eventLog = [];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Helper to dispatch UI toast
|
|
61
|
+
*/
|
|
62
|
+
toast(message, type = 'info') {
|
|
63
|
+
this.dispatch('ui:toast', { message, type });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Helper to dispatch UI log
|
|
67
|
+
*/
|
|
68
|
+
log(message) {
|
|
69
|
+
this.dispatch('ui:log', { message });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Helper to dispatch error
|
|
73
|
+
*/
|
|
74
|
+
error(error) {
|
|
75
|
+
this.dispatch('system:error', { error });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Singleton instance
|
|
79
|
+
let busInstance = null;
|
|
80
|
+
export function getEventBus() {
|
|
81
|
+
if (!busInstance) {
|
|
82
|
+
busInstance = new EventBus();
|
|
83
|
+
}
|
|
84
|
+
return busInstance;
|
|
85
|
+
}
|
|
86
|
+
export { EventBus };
|
|
87
|
+
//# sourceMappingURL=EventBus.js.map
|
|
88
|
+
//# debugId=3cd1e8b8-6605-5d6b-aff6-ddadc2b73921
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventBus.js","sources":["app/EventBus.ts"],"sourceRoot":"/","sourcesContent":["/**\r\n * Event Bus - Centralized event system for cross-component communication\r\n * Inspired by opencode's bus system\r\n */\r\n\r\nimport { EventEmitter } from 'events';\r\n\r\n// Import types for event payloads\r\nimport type { Player, Dungeon, Town } from '../core/types.js';\r\nimport type { DungeonRunnerState } from '../core/DungeonRunner.js';\r\nimport type { IdleCombatState } from '../core/IdleCombat.js';\r\n\r\n/**\r\n * IdleGameManager phase type\r\n */\r\nexport type IdleGamePhase =\r\n | 'in_town'\r\n | 'traveling_to_dungeon'\r\n | 'in_dungeon'\r\n | 'returning_to_town'\r\n | 'resting'\r\n | 'dead';\r\n\r\n/**\r\n * Game event types\r\n */\r\nexport interface GameEvents {\r\n // Game lifecycle\r\n 'game:init': { playerName: string };\r\n 'game:start': void;\r\n 'game:pause': void;\r\n 'game:resume': void;\r\n 'game:save': { slot: number };\r\n 'game:load': { slot: number };\r\n 'game:exit': void;\r\n\r\n // Player events\r\n 'player:move': { roomId: string };\r\n 'player:damage': { amount: number; source: string };\r\n 'player:heal': { amount: number };\r\n 'player:levelup': { level: number };\r\n 'player:death': void;\r\n 'player:gold': { amount: number };\r\n 'player:xp': { amount: number };\r\n 'player:update': { player: Player };\r\n\r\n // Combat events\r\n 'combat:start': { encounterId: string; enemies: string[] };\r\n 'combat:turn': { turnNumber: number };\r\n 'combat:action': { action: string; target?: string };\r\n 'combat:damage': { target: string; amount: number };\r\n 'combat:end': { victory: boolean };\r\n\r\n // NPC events\r\n 'npc:interact': { npcId: string };\r\n 'npc:dialog': { npcId: string; message: string };\r\n 'npc:trade': { npcId: string };\r\n 'npc:quest': { npcId: string; questId: string };\r\n\r\n // Quest events\r\n 'quest:accept': { questId: string };\r\n 'quest:progress': { questId: string; objectiveId: string };\r\n 'quest:complete': { questId: string };\r\n 'quest:abandon': { questId: string };\r\n\r\n // UI events\r\n 'ui:toast': { message: string; type: 'info' | 'success' | 'warning' | 'error' };\r\n 'ui:log': { message: string };\r\n 'ui:refresh': void;\r\n 'ui:modal': { title: string; content: string };\r\n 'ui:confirm': { title: string; message: string; onConfirm: () => void };\r\n\r\n // Travel events\r\n 'travel:start': { from: string; to: string; duration: number };\r\n 'travel:progress': { progress: number; duration: number };\r\n 'travel:event': { type: string; description: string };\r\n 'travel:complete': { roomId: string };\r\n 'travel:cancel': void;\r\n\r\n // Inventory events\r\n 'inventory:add': { itemId: string; count: number };\r\n 'inventory:remove': { itemId: string; count: number };\r\n 'inventory:equip': { itemId: string; slot: string };\r\n 'inventory:unequip': { slot: string };\r\n\r\n // System events\r\n 'system:error': { error: Error | string };\r\n 'system:resize': { width: number; height: number };\r\n\r\n // IdleGameManager events (new)\r\n 'idle:phaseChange': { phase: IdleGamePhase; town: Town; dungeon: Dungeon | null };\r\n 'idle:dungeonProgress': { runnerState: DungeonRunnerState; combat: IdleCombatState | null };\r\n 'idle:dungeonComplete': { success: boolean; rewards: { gold: number; exp: number; items: string[] } };\r\n}\r\n\r\n/**\r\n * Event payload type helper\r\n */\r\ntype EventPayload<K extends keyof GameEvents> = GameEvents[K];\r\n\r\n/**\r\n * Event Bus class\r\n */\r\nclass EventBus extends EventEmitter {\r\n private eventLog: Array<{ event: string; payload: unknown; time: number }> = [];\r\n private maxLogSize = 100;\r\n\r\n constructor() {\r\n super();\r\n this.setMaxListeners(100); // Allow many listeners\r\n }\r\n\r\n /**\r\n * Emit a typed event\r\n */\r\n dispatch<K extends keyof GameEvents>(\r\n event: K,\r\n payload: EventPayload<K>\r\n ): boolean {\r\n // Log event\r\n this.eventLog.push({\r\n event,\r\n payload,\r\n time: Date.now(),\r\n });\r\n\r\n // Trim log\r\n if (this.eventLog.length > this.maxLogSize) {\r\n this.eventLog = this.eventLog.slice(-this.maxLogSize);\r\n }\r\n\r\n return this.emit(event, payload);\r\n }\r\n\r\n /**\r\n * Subscribe to a typed event\r\n */\r\n subscribe<K extends keyof GameEvents>(\r\n event: K,\r\n handler: (payload: EventPayload<K>) => void\r\n ): () => void {\r\n this.on(event, handler);\r\n return () => this.off(event, handler);\r\n }\r\n\r\n /**\r\n * Subscribe once to a typed event\r\n */\r\n subscribeOnce<K extends keyof GameEvents>(\r\n event: K,\r\n handler: (payload: EventPayload<K>) => void\r\n ): void {\r\n this.once(event, handler);\r\n }\r\n\r\n /**\r\n * Get recent events\r\n */\r\n getRecentEvents(count: number = 10): Array<{ event: string; payload: unknown; time: number }> {\r\n return this.eventLog.slice(-count);\r\n }\r\n\r\n /**\r\n * Clear event log\r\n */\r\n clearLog(): void {\r\n this.eventLog = [];\r\n }\r\n\r\n /**\r\n * Helper to dispatch UI toast\r\n */\r\n toast(message: string, type: 'info' | 'success' | 'warning' | 'error' = 'info'): void {\r\n this.dispatch('ui:toast', { message, type });\r\n }\r\n\r\n /**\r\n * Helper to dispatch UI log\r\n */\r\n log(message: string): void {\r\n this.dispatch('ui:log', { message });\r\n }\r\n\r\n /**\r\n * Helper to dispatch error\r\n */\r\n error(error: Error | string): void {\r\n this.dispatch('system:error', { error });\r\n }\r\n}\r\n\r\n// Singleton instance\r\nlet busInstance: EventBus | null = null;\r\n\r\nexport function getEventBus(): EventBus {\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AAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,OAAiD,MAAM;QAC5E,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,OAAe;QACjB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAqB;QACzB,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,WAAW,GAAoB,IAAI,CAAC;AAExC,MAAM,UAAU,WAAW;IACzB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","debug_id":"3cd1e8b8-6605-5d6b-aff6-ddadc2b73921"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keybind System - Centralized keyboard shortcut management
|
|
3
|
+
* Inspired by opencode's keybind system
|
|
4
|
+
*/
|
|
5
|
+
import type { KeyEvent } from '../tui/Input.js';
|
|
6
|
+
/**
|
|
7
|
+
* Keybind definition
|
|
8
|
+
*/
|
|
9
|
+
export interface KeybindDef {
|
|
10
|
+
key: string;
|
|
11
|
+
ctrl?: boolean;
|
|
12
|
+
shift?: boolean;
|
|
13
|
+
alt?: boolean;
|
|
14
|
+
meta?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Action definition
|
|
18
|
+
*/
|
|
19
|
+
export interface KeyAction {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
keybind: KeybindDef | KeybindDef[];
|
|
24
|
+
context?: string[];
|
|
25
|
+
global?: boolean;
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
action: () => void | Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Keybind manager
|
|
31
|
+
*/
|
|
32
|
+
declare class KeybindManager {
|
|
33
|
+
private actions;
|
|
34
|
+
private contextStack;
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Register default keybinds
|
|
38
|
+
*/
|
|
39
|
+
private registerDefaults;
|
|
40
|
+
/**
|
|
41
|
+
* Register a keybind action
|
|
42
|
+
*/
|
|
43
|
+
register(action: KeyAction): void;
|
|
44
|
+
/**
|
|
45
|
+
* Unregister a keybind action
|
|
46
|
+
*/
|
|
47
|
+
unregister(id: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Push a context (e.g., entering a dialog)
|
|
50
|
+
*/
|
|
51
|
+
pushContext(context: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Pop a context
|
|
54
|
+
*/
|
|
55
|
+
popContext(): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get current context
|
|
58
|
+
*/
|
|
59
|
+
getCurrentContext(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a key event matches a keybind
|
|
62
|
+
*/
|
|
63
|
+
matches(key: KeyEvent, bind: KeybindDef): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Handle a key event
|
|
66
|
+
*/
|
|
67
|
+
handleKey(key: KeyEvent): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Get all actions for a context
|
|
70
|
+
*/
|
|
71
|
+
getActionsForContext(context?: string): KeyAction[];
|
|
72
|
+
/**
|
|
73
|
+
* Get keybind string for display
|
|
74
|
+
*/
|
|
75
|
+
static formatKeybind(bind: KeybindDef): string;
|
|
76
|
+
/**
|
|
77
|
+
* Parse a keybind string
|
|
78
|
+
*/
|
|
79
|
+
static parseKeybind(str: string): KeybindDef;
|
|
80
|
+
}
|
|
81
|
+
export declare function getKeybindManager(): KeybindManager;
|
|
82
|
+
export { KeybindManager };
|
|
83
|
+
//# sourceMappingURL=Keybind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Keybind.d.ts","sourceRoot":"/","sources":["app/Keybind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,YAAY,CAAwB;;IAO5C;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIjC;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS;IAOhC;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO;IAgBjD;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBhD;;OAEG;IACH,oBAAoB,CAAC,OAAO,GAAE,MAAiC,GAAG,SAAS,EAAE;IAS7E;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAkB9C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAiC7C;AAKD,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keybind System - Centralized keyboard shortcut management
|
|
3
|
+
* Inspired by opencode's keybind system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Keybind manager
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2fda64f4-187c-5769-b55e-f99fb6582a8e")}catch(e){}}();
|
|
10
|
+
class KeybindManager {
|
|
11
|
+
actions = new Map();
|
|
12
|
+
contextStack = ['global'];
|
|
13
|
+
constructor() {
|
|
14
|
+
// Register default global keybinds
|
|
15
|
+
this.registerDefaults();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register default keybinds
|
|
19
|
+
*/
|
|
20
|
+
registerDefaults() {
|
|
21
|
+
// These will be registered by the App when it starts
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Register a keybind action
|
|
25
|
+
*/
|
|
26
|
+
register(action) {
|
|
27
|
+
this.actions.set(action.id, action);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Unregister a keybind action
|
|
31
|
+
*/
|
|
32
|
+
unregister(id) {
|
|
33
|
+
this.actions.delete(id);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Push a context (e.g., entering a dialog)
|
|
37
|
+
*/
|
|
38
|
+
pushContext(context) {
|
|
39
|
+
this.contextStack.push(context);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Pop a context
|
|
43
|
+
*/
|
|
44
|
+
popContext() {
|
|
45
|
+
if (this.contextStack.length > 1) {
|
|
46
|
+
return this.contextStack.pop();
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get current context
|
|
52
|
+
*/
|
|
53
|
+
getCurrentContext() {
|
|
54
|
+
return this.contextStack[this.contextStack.length - 1];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if a key event matches a keybind
|
|
58
|
+
*/
|
|
59
|
+
matches(key, bind) {
|
|
60
|
+
// Check key name
|
|
61
|
+
if (key.name !== bind.key && key.raw !== bind.key) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// Check modifiers
|
|
65
|
+
if (bind.ctrl !== undefined && key.ctrl !== bind.ctrl)
|
|
66
|
+
return false;
|
|
67
|
+
if (bind.shift !== undefined && key.shift !== bind.shift)
|
|
68
|
+
return false;
|
|
69
|
+
// Note: Terminal KeyEvent doesn't have separate 'alt' - alt is often reported as 'meta'
|
|
70
|
+
if (bind.alt !== undefined && key.meta !== bind.alt)
|
|
71
|
+
return false;
|
|
72
|
+
if (bind.meta !== undefined && key.meta !== bind.meta)
|
|
73
|
+
return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handle a key event
|
|
78
|
+
*/
|
|
79
|
+
async handleKey(key) {
|
|
80
|
+
const currentContext = this.getCurrentContext();
|
|
81
|
+
for (const action of this.actions.values()) {
|
|
82
|
+
// Check context
|
|
83
|
+
if (!action.global && action.context) {
|
|
84
|
+
if (!action.context.includes(currentContext)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Check keybind(s)
|
|
89
|
+
const binds = Array.isArray(action.keybind) ? action.keybind : [action.keybind];
|
|
90
|
+
for (const bind of binds) {
|
|
91
|
+
if (this.matches(key, bind)) {
|
|
92
|
+
await action.action();
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get all actions for a context
|
|
101
|
+
*/
|
|
102
|
+
getActionsForContext(context = this.getCurrentContext()) {
|
|
103
|
+
return Array.from(this.actions.values()).filter(action => {
|
|
104
|
+
if (action.hidden)
|
|
105
|
+
return false;
|
|
106
|
+
if (action.global)
|
|
107
|
+
return true;
|
|
108
|
+
if (action.context?.includes(context))
|
|
109
|
+
return true;
|
|
110
|
+
return false;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get keybind string for display
|
|
115
|
+
*/
|
|
116
|
+
static formatKeybind(bind) {
|
|
117
|
+
const parts = [];
|
|
118
|
+
if (bind.ctrl)
|
|
119
|
+
parts.push('Ctrl');
|
|
120
|
+
if (bind.alt)
|
|
121
|
+
parts.push('Alt');
|
|
122
|
+
if (bind.shift)
|
|
123
|
+
parts.push('Shift');
|
|
124
|
+
if (bind.meta)
|
|
125
|
+
parts.push('Cmd');
|
|
126
|
+
// Format key name
|
|
127
|
+
let keyName = bind.key;
|
|
128
|
+
if (keyName === 'return')
|
|
129
|
+
keyName = 'Enter';
|
|
130
|
+
if (keyName === 'escape')
|
|
131
|
+
keyName = 'Esc';
|
|
132
|
+
if (keyName === 'space')
|
|
133
|
+
keyName = 'Space';
|
|
134
|
+
if (keyName.length === 1)
|
|
135
|
+
keyName = keyName.toUpperCase();
|
|
136
|
+
parts.push(keyName);
|
|
137
|
+
return parts.join('+');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Parse a keybind string
|
|
141
|
+
*/
|
|
142
|
+
static parseKeybind(str) {
|
|
143
|
+
const parts = str.toLowerCase().split('+');
|
|
144
|
+
const bind = { key: '' };
|
|
145
|
+
for (const part of parts) {
|
|
146
|
+
switch (part) {
|
|
147
|
+
case 'ctrl':
|
|
148
|
+
case 'control':
|
|
149
|
+
bind.ctrl = true;
|
|
150
|
+
break;
|
|
151
|
+
case 'alt':
|
|
152
|
+
bind.alt = true;
|
|
153
|
+
break;
|
|
154
|
+
case 'shift':
|
|
155
|
+
bind.shift = true;
|
|
156
|
+
break;
|
|
157
|
+
case 'cmd':
|
|
158
|
+
case 'meta':
|
|
159
|
+
bind.meta = true;
|
|
160
|
+
break;
|
|
161
|
+
case 'enter':
|
|
162
|
+
bind.key = 'return';
|
|
163
|
+
break;
|
|
164
|
+
case 'esc':
|
|
165
|
+
bind.key = 'escape';
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
bind.key = part;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return bind;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Singleton
|
|
175
|
+
let keybindInstance = null;
|
|
176
|
+
export function getKeybindManager() {
|
|
177
|
+
if (!keybindInstance) {
|
|
178
|
+
keybindInstance = new KeybindManager();
|
|
179
|
+
}
|
|
180
|
+
return keybindInstance;
|
|
181
|
+
}
|
|
182
|
+
export { KeybindManager };
|
|
183
|
+
//# sourceMappingURL=Keybind.js.map
|
|
184
|
+
//# debugId=2fda64f4-187c-5769-b55e-f99fb6582a8e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Keybind.js","sources":["app/Keybind.ts"],"sourceRoot":"/","sourcesContent":["/**\r\n * Keybind System - Centralized keyboard shortcut management\r\n * Inspired by opencode's keybind system\r\n */\r\n\r\nimport type { KeyEvent } from '../tui/Input.js';\r\n\r\n/**\r\n * Keybind definition\r\n */\r\nexport interface KeybindDef {\r\n key: string;\r\n ctrl?: boolean;\r\n shift?: boolean;\r\n alt?: boolean;\r\n meta?: boolean;\r\n}\r\n\r\n/**\r\n * Action definition\r\n */\r\nexport interface KeyAction {\r\n id: string;\r\n name: string;\r\n description?: string;\r\n keybind: KeybindDef | KeybindDef[];\r\n context?: string[]; // Only active in these route contexts\r\n global?: boolean; // Active in all contexts\r\n hidden?: boolean; // Don't show in help\r\n action: () => void | Promise<void>;\r\n}\r\n\r\n/**\r\n * Keybind manager\r\n */\r\nclass KeybindManager {\r\n private actions: Map<string, KeyAction> = new Map();\r\n private contextStack: string[] = ['global'];\r\n\r\n constructor() {\r\n // Register default global keybinds\r\n this.registerDefaults();\r\n }\r\n\r\n /**\r\n * Register default keybinds\r\n */\r\n private registerDefaults(): void {\r\n // These will be registered by the App when it starts\r\n }\r\n\r\n /**\r\n * Register a keybind action\r\n */\r\n register(action: KeyAction): void {\r\n this.actions.set(action.id, action);\r\n }\r\n\r\n /**\r\n * Unregister a keybind action\r\n */\r\n unregister(id: string): void {\r\n this.actions.delete(id);\r\n }\r\n\r\n /**\r\n * Push a context (e.g., entering a dialog)\r\n */\r\n pushContext(context: string): void {\r\n this.contextStack.push(context);\r\n }\r\n\r\n /**\r\n * Pop a context\r\n */\r\n popContext(): string | undefined {\r\n if (this.contextStack.length > 1) {\r\n return this.contextStack.pop();\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get current context\r\n */\r\n getCurrentContext(): string {\r\n return this.contextStack[this.contextStack.length - 1];\r\n }\r\n\r\n /**\r\n * Check if a key event matches a keybind\r\n */\r\n matches(key: KeyEvent, bind: KeybindDef): boolean {\r\n // Check key name\r\n if (key.name !== bind.key && key.raw !== bind.key) {\r\n return false;\r\n }\r\n\r\n // Check modifiers\r\n if (bind.ctrl !== undefined && key.ctrl !== bind.ctrl) return false;\r\n if (bind.shift !== undefined && key.shift !== bind.shift) return false;\r\n // Note: Terminal KeyEvent doesn't have separate 'alt' - alt is often reported as 'meta'\r\n if (bind.alt !== undefined && key.meta !== bind.alt) return false;\r\n if (bind.meta !== undefined && key.meta !== bind.meta) return false;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Handle a key event\r\n */\r\n async handleKey(key: KeyEvent): Promise<boolean> {\r\n const currentContext = this.getCurrentContext();\r\n\r\n for (const action of this.actions.values()) {\r\n // Check context\r\n if (!action.global && action.context) {\r\n if (!action.context.includes(currentContext)) {\r\n continue;\r\n }\r\n }\r\n\r\n // Check keybind(s)\r\n const binds = Array.isArray(action.keybind) ? action.keybind : [action.keybind];\r\n for (const bind of binds) {\r\n if (this.matches(key, bind)) {\r\n await action.action();\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Get all actions for a context\r\n */\r\n getActionsForContext(context: string = this.getCurrentContext()): KeyAction[] {\r\n return Array.from(this.actions.values()).filter(action => {\r\n if (action.hidden) return false;\r\n if (action.global) return true;\r\n if (action.context?.includes(context)) return true;\r\n return false;\r\n });\r\n }\r\n\r\n /**\r\n * Get keybind string for display\r\n */\r\n static formatKeybind(bind: KeybindDef): string {\r\n const parts: string[] = [];\r\n if (bind.ctrl) parts.push('Ctrl');\r\n if (bind.alt) parts.push('Alt');\r\n if (bind.shift) parts.push('Shift');\r\n if (bind.meta) parts.push('Cmd');\r\n\r\n // Format key name\r\n let keyName = bind.key;\r\n if (keyName === 'return') keyName = 'Enter';\r\n if (keyName === 'escape') keyName = 'Esc';\r\n if (keyName === 'space') keyName = 'Space';\r\n if (keyName.length === 1) keyName = keyName.toUpperCase();\r\n\r\n parts.push(keyName);\r\n return parts.join('+');\r\n }\r\n\r\n /**\r\n * Parse a keybind string\r\n */\r\n static parseKeybind(str: string): KeybindDef {\r\n const parts = str.toLowerCase().split('+');\r\n const bind: KeybindDef = { key: '' };\r\n\r\n for (const part of parts) {\r\n switch (part) {\r\n case 'ctrl':\r\n case 'control':\r\n bind.ctrl = true;\r\n break;\r\n case 'alt':\r\n bind.alt = true;\r\n break;\r\n case 'shift':\r\n bind.shift = true;\r\n break;\r\n case 'cmd':\r\n case 'meta':\r\n bind.meta = true;\r\n break;\r\n case 'enter':\r\n bind.key = 'return';\r\n break;\r\n case 'esc':\r\n bind.key = 'escape';\r\n break;\r\n default:\r\n bind.key = part;\r\n }\r\n }\r\n\r\n return bind;\r\n }\r\n}\r\n\r\n// Singleton\r\nlet keybindInstance: KeybindManager | null = null;\r\n\r\nexport function getKeybindManager(): KeybindManager {\r\n if (!keybindInstance) {\r\n keybindInstance = new KeybindManager();\r\n }\r\n return keybindInstance;\r\n}\r\n\r\nexport { KeybindManager };\r\n"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH;;GAEG;;;AACH,MAAM,cAAc;IACV,OAAO,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC5C,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;IAE5C;QACE,mCAAmC;QACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,gBAAgB;QACtB,qDAAqD;IACvD,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,MAAiB;QACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,EAAU;QACnB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAAe;QACzB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAA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