@nice2dev/game-engine 1.3.15 → 1.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1031 +1,1044 @@
1
- import React from 'react';
2
- import { EventBus } from '../core/EventBus.js';
3
-
4
- /* ────────────────────────────────────────────────────────────────
5
- Dialogue System — Visual Dialogue Tree Editor
6
-
7
- A comprehensive dialogue system with:
8
- - Visual node-based dialogue tree editor
9
- - Variables and conditions support
10
- - Character portraits and emotions
11
- - Branching conversations
12
- - Localization support
13
- ──────────────────────────────────────────────────────────────── */
14
- /* ═══════════════════════════════════════════════════════════════
15
- DIALOGUE ENGINE
16
- ══════════════════════════════════════════════════════════════════ */
1
+ import React from "react";
2
+ import { EventBus } from "../core/EventBus.js";
17
3
  class DialogueEngine {
18
- constructor(events) {
19
- this.trees = new Map();
20
- this.globalVariables = new Map();
21
- this.currentState = null;
22
- this.events = events ?? new EventBus();
23
- }
24
- /* ── Tree Management ──────────────────────────────────────────── */
25
- registerTree(tree) {
26
- this.trees.set(tree.id, tree);
27
- }
28
- unregisterTree(treeId) {
29
- this.trees.delete(treeId);
30
- }
31
- getTree(treeId) {
32
- return this.trees.get(treeId);
33
- }
34
- getAllTrees() {
35
- return Array.from(this.trees.values());
36
- }
37
- /* ── Variable Management ──────────────────────────────────────── */
38
- setGlobalVariable(name, value) {
39
- this.globalVariables.set(name, value);
40
- this.emitEvent('dialogue:variable-changed', { name, value, scope: 'global' });
41
- }
42
- getGlobalVariable(name) {
43
- return this.globalVariables.get(name);
44
- }
45
- getVariable(variableId) {
46
- if (!this.currentState) {
47
- return this.globalVariables.get(variableId);
48
- }
49
- return this.currentState.variables[variableId] ?? this.globalVariables.get(variableId);
50
- }
51
- setVariable(variableId, value, scope) {
52
- if (scope === 'global') {
53
- this.globalVariables.set(variableId, value);
54
- }
55
- else if (this.currentState) {
56
- this.currentState.variables[variableId] = value;
57
- }
58
- this.emitEvent('dialogue:variable-changed', { variableId, value, scope });
59
- }
60
- /* ── Dialogue Flow ────────────────────────────────────────────── */
61
- startDialogue(treeId, startLabel) {
62
- const tree = this.trees.get(treeId);
63
- if (!tree) {
64
- return false;
65
- }
66
- // Find start node
67
- let startNode;
68
- if (startLabel) {
69
- startNode = tree.nodes.find((n) => n.type === 'start' && n.label === startLabel);
70
- }
71
- if (!startNode) {
72
- startNode = tree.nodes.find((n) => n.id === tree.startNodeId);
73
- }
74
- if (!startNode) {
75
- return false;
76
- }
77
- // Initialize state
78
- const variables = {};
79
- for (const v of tree.variables) {
80
- if (v.scope === 'conversation') {
81
- variables[v.id] = v.defaultValue;
82
- }
83
- }
84
- this.currentState = {
85
- treeId,
86
- currentNodeId: startNode.id,
87
- variables,
88
- history: [startNode.id],
89
- choicesMade: [],
90
- startTime: Date.now(),
91
- isActive: true,
92
- isPaused: false,
93
- };
94
- this.emitEvent('dialogue:started', { treeId, startNodeId: startNode.id });
95
- // Advance to first content node
96
- if (startNode.nextNode) {
97
- this.goToNode(startNode.nextNode);
98
- }
99
- return true;
100
- }
101
- endDialogue() {
102
- if (!this.currentState) {
103
- return;
104
- }
105
- const treeId = this.currentState.treeId;
106
- this.currentState.isActive = false;
107
- this.emitEvent('dialogue:ended', { treeId, state: { ...this.currentState } });
108
- this.currentState = null;
109
- }
110
- pauseDialogue() {
111
- if (!this.currentState || !this.currentState.isActive) {
112
- return;
113
- }
114
- this.currentState.isPaused = true;
115
- this.emitEvent('dialogue:paused', {});
116
- }
117
- resumeDialogue() {
118
- if (!this.currentState || !this.currentState.isActive) {
119
- return;
120
- }
121
- this.currentState.isPaused = false;
122
- this.emitEvent('dialogue:resumed', {});
123
- }
124
- getState() {
125
- return this.currentState ? { ...this.currentState } : null;
126
- }
127
- isActive() {
128
- return this.currentState?.isActive ?? false;
129
- }
130
- /* ── Node Navigation ──────────────────────────────────────────── */
131
- goToNode(nodeId) {
132
- if (!this.currentState) {
133
- return;
134
- }
135
- const tree = this.trees.get(this.currentState.treeId);
136
- if (!tree) {
137
- return;
138
- }
139
- const node = tree.nodes.find((n) => n.id === nodeId);
140
- if (!node) {
141
- return;
142
- }
143
- this.currentState.currentNodeId = nodeId;
144
- this.currentState.history.push(nodeId);
145
- this.emitEvent('dialogue:node-entered', { nodeId, nodeType: node.type });
146
- this.processNode(node, tree);
147
- }
148
- processNode(node, tree) {
149
- switch (node.type) {
150
- case 'start':
151
- if (node.nextNode) {
152
- this.goToNode(node.nextNode);
153
- }
154
- break;
155
- case 'text':
156
- this.processTextNode(node, tree);
157
- break;
158
- case 'choice':
159
- this.processChoiceNode(node, tree);
160
- break;
161
- case 'branch':
162
- case 'check_variable':
163
- this.processBranchNode(node);
164
- break;
165
- case 'set_variable':
166
- this.processSetVariableNode(node, tree);
167
- break;
168
- case 'event':
169
- this.processEventNode(node);
170
- break;
171
- case 'random':
172
- this.processRandomNode(node);
173
- break;
174
- case 'end':
175
- this.processEndNode(node);
176
- break;
177
- }
178
- }
179
- processTextNode(node, tree) {
180
- const character = tree.characters.find((c) => c.id === node.characterId);
181
- if (character && this.onTextCallback) {
182
- this.onTextCallback(node, character);
183
- }
184
- this.emitEvent('dialogue:text-displayed', {
185
- nodeId: node.id,
186
- characterId: node.characterId,
187
- text: node.text,
188
- emotion: node.emotion,
189
- });
190
- }
191
- processChoiceNode(node, _tree) {
192
- // Filter valid options based on conditions
193
- const validOptions = node.options.filter((opt) => {
194
- if (opt.disabled) {
195
- return false;
196
- }
197
- if (!opt.conditions || opt.conditions.length === 0) {
198
- return true;
199
- }
200
- return opt.conditions.every((c) => this.evaluateCondition(c));
201
- });
202
- if (this.onChoiceCallback) {
203
- this.onChoiceCallback(node, validOptions);
204
- }
205
- }
206
- processBranchNode(node) {
207
- const result = this.evaluateConditions(node.conditions, node.logic);
208
- const nextNode = result ? node.trueNode : node.falseNode;
209
- if (nextNode) {
210
- this.goToNode(nextNode);
211
- }
212
- }
213
- processSetVariableNode(node, tree) {
214
- const variable = tree.variables.find((v) => v.id === node.variableId);
215
- if (!variable) {
216
- if (node.nextNode) {
217
- this.goToNode(node.nextNode);
218
- }
219
- return;
220
- }
221
- const currentValue = this.getVariable(node.variableId) ?? variable.defaultValue;
222
- let newValue;
223
- switch (node.operation) {
224
- case 'set':
225
- newValue = node.value;
226
- break;
227
- case 'add':
228
- newValue = currentValue + node.value;
229
- break;
230
- case 'subtract':
231
- newValue = currentValue - node.value;
232
- break;
233
- case 'multiply':
234
- newValue = currentValue * node.value;
235
- break;
236
- case 'toggle':
237
- newValue = !currentValue;
238
- break;
239
- case 'append':
240
- newValue = currentValue + node.value;
241
- break;
242
- default:
243
- newValue = node.value;
244
- }
245
- this.setVariable(node.variableId, newValue, variable.scope);
246
- if (node.nextNode) {
247
- this.goToNode(node.nextNode);
248
- }
249
- }
250
- processEventNode(node) {
251
- this.events.emit(node.eventType, node.eventData);
252
- this.emitEvent('dialogue:event-triggered', {
253
- eventType: node.eventType,
254
- eventData: node.eventData,
255
- });
4
+ constructor(events) {
5
+ this.trees = /* @__PURE__ */ new Map();
6
+ this.globalVariables = /* @__PURE__ */ new Map();
7
+ this.currentState = null;
8
+ this.events = events ?? new EventBus();
9
+ }
10
+ /* ── Tree Management ──────────────────────────────────────────── */
11
+ registerTree(tree) {
12
+ this.trees.set(tree.id, tree);
13
+ }
14
+ unregisterTree(treeId) {
15
+ this.trees.delete(treeId);
16
+ }
17
+ getTree(treeId) {
18
+ return this.trees.get(treeId);
19
+ }
20
+ getAllTrees() {
21
+ return Array.from(this.trees.values());
22
+ }
23
+ /* ── Variable Management ──────────────────────────────────────── */
24
+ setGlobalVariable(name, value) {
25
+ this.globalVariables.set(name, value);
26
+ this.emitEvent("dialogue:variable-changed", { name, value, scope: "global" });
27
+ }
28
+ getGlobalVariable(name) {
29
+ return this.globalVariables.get(name);
30
+ }
31
+ getVariable(variableId) {
32
+ if (!this.currentState) {
33
+ return this.globalVariables.get(variableId);
34
+ }
35
+ return this.currentState.variables[variableId] ?? this.globalVariables.get(variableId);
36
+ }
37
+ setVariable(variableId, value, scope) {
38
+ if (scope === "global") {
39
+ this.globalVariables.set(variableId, value);
40
+ } else if (this.currentState) {
41
+ this.currentState.variables[variableId] = value;
42
+ }
43
+ this.emitEvent("dialogue:variable-changed", { variableId, value, scope });
44
+ }
45
+ /* ── Dialogue Flow ────────────────────────────────────────────── */
46
+ startDialogue(treeId, startLabel) {
47
+ const tree = this.trees.get(treeId);
48
+ if (!tree) {
49
+ return false;
50
+ }
51
+ let startNode;
52
+ if (startLabel) {
53
+ startNode = tree.nodes.find(
54
+ (n) => n.type === "start" && n.label === startLabel
55
+ );
56
+ }
57
+ if (!startNode) {
58
+ startNode = tree.nodes.find((n) => n.id === tree.startNodeId);
59
+ }
60
+ if (!startNode) {
61
+ return false;
62
+ }
63
+ const variables = {};
64
+ for (const v of tree.variables) {
65
+ if (v.scope === "conversation") {
66
+ variables[v.id] = v.defaultValue;
67
+ }
68
+ }
69
+ this.currentState = {
70
+ treeId,
71
+ currentNodeId: startNode.id,
72
+ variables,
73
+ history: [startNode.id],
74
+ choicesMade: [],
75
+ startTime: Date.now(),
76
+ isActive: true,
77
+ isPaused: false
78
+ };
79
+ this.emitEvent("dialogue:started", { treeId, startNodeId: startNode.id });
80
+ if (startNode.nextNode) {
81
+ this.goToNode(startNode.nextNode);
82
+ }
83
+ return true;
84
+ }
85
+ endDialogue() {
86
+ if (!this.currentState) {
87
+ return;
88
+ }
89
+ const treeId = this.currentState.treeId;
90
+ this.currentState.isActive = false;
91
+ this.emitEvent("dialogue:ended", { treeId, state: { ...this.currentState } });
92
+ this.currentState = null;
93
+ }
94
+ pauseDialogue() {
95
+ if (!this.currentState || !this.currentState.isActive) {
96
+ return;
97
+ }
98
+ this.currentState.isPaused = true;
99
+ this.emitEvent("dialogue:paused", {});
100
+ }
101
+ resumeDialogue() {
102
+ if (!this.currentState || !this.currentState.isActive) {
103
+ return;
104
+ }
105
+ this.currentState.isPaused = false;
106
+ this.emitEvent("dialogue:resumed", {});
107
+ }
108
+ getState() {
109
+ return this.currentState ? { ...this.currentState } : null;
110
+ }
111
+ isActive() {
112
+ return this.currentState?.isActive ?? false;
113
+ }
114
+ /* ── Node Navigation ──────────────────────────────────────────── */
115
+ goToNode(nodeId) {
116
+ if (!this.currentState) {
117
+ return;
118
+ }
119
+ const tree = this.trees.get(this.currentState.treeId);
120
+ if (!tree) {
121
+ return;
122
+ }
123
+ const node = tree.nodes.find((n) => n.id === nodeId);
124
+ if (!node) {
125
+ return;
126
+ }
127
+ this.currentState.currentNodeId = nodeId;
128
+ this.currentState.history.push(nodeId);
129
+ this.emitEvent("dialogue:node-entered", { nodeId, nodeType: node.type });
130
+ this.processNode(node, tree);
131
+ }
132
+ processNode(node, tree) {
133
+ switch (node.type) {
134
+ case "start":
256
135
  if (node.nextNode) {
257
- this.goToNode(node.nextNode);
258
- }
259
- }
260
- processRandomNode(node) {
261
- const totalWeight = node.outputs.reduce((sum, out) => sum + out.weight, 0);
262
- let random = Math.random() * totalWeight;
263
- for (const output of node.outputs) {
264
- random -= output.weight;
265
- if (random <= 0 && output.nextNode) {
266
- this.goToNode(output.nextNode);
267
- return;
268
- }
269
- }
270
- // Fallback to first output
271
- const first = node.outputs[0];
272
- if (first?.nextNode) {
273
- this.goToNode(first.nextNode);
274
- }
275
- }
276
- processEndNode(node) {
277
- // Apply final variable changes
278
- if (node.setVariables && this.currentState) {
279
- const tree = this.trees.get(this.currentState.treeId);
280
- if (tree) {
281
- for (const sv of node.setVariables) {
282
- const variable = tree.variables.find((v) => v.id === sv.variableId);
283
- if (variable) {
284
- this.setVariable(sv.variableId, sv.value, variable.scope);
285
- }
286
- }
287
- }
288
- }
289
- if (this.onEndCallback && this.currentState) {
290
- this.onEndCallback(node, this.currentState);
291
- }
292
- this.endDialogue();
293
- }
294
- /* ── Choice Selection ─────────────────────────────────────────── */
295
- selectChoice(optionId) {
296
- if (!this.currentState || !this.currentState.isActive) {
297
- return false;
298
- }
299
- const tree = this.trees.get(this.currentState.treeId);
300
- if (!tree) {
301
- return false;
302
- }
303
- const node = tree.nodes.find((n) => n.id === this.currentState.currentNodeId);
304
- if (!node || node.type !== 'choice') {
305
- return false;
306
- }
307
- const choice = node.options.find((o) => o.id === optionId);
308
- if (!choice) {
309
- return false;
310
- }
311
- // Apply variables from choice
312
- if (choice.setVariables) {
313
- for (const sv of choice.setVariables) {
314
- const variable = tree.variables.find((v) => v.id === sv.variableId);
315
- if (variable) {
316
- this.setVariable(sv.variableId, sv.value, variable.scope);
317
- }
318
- }
319
- }
320
- this.currentState.choicesMade.push({
321
- nodeId: node.id,
322
- optionId,
323
- timestamp: Date.now(),
324
- });
325
- this.emitEvent('dialogue:choice-selected', {
326
- nodeId: node.id,
327
- optionId,
328
- text: choice.text,
329
- });
330
- if (choice.nextNode) {
331
- this.goToNode(choice.nextNode);
136
+ this.goToNode(node.nextNode);
332
137
  }
138
+ break;
139
+ case "text":
140
+ this.processTextNode(node, tree);
141
+ break;
142
+ case "choice":
143
+ this.processChoiceNode(node, tree);
144
+ break;
145
+ case "branch":
146
+ case "check_variable":
147
+ this.processBranchNode(node);
148
+ break;
149
+ case "set_variable":
150
+ this.processSetVariableNode(node, tree);
151
+ break;
152
+ case "event":
153
+ this.processEventNode(node);
154
+ break;
155
+ case "random":
156
+ this.processRandomNode(node);
157
+ break;
158
+ case "end":
159
+ this.processEndNode(node);
160
+ break;
161
+ }
162
+ }
163
+ processTextNode(node, tree) {
164
+ const character = tree.characters.find((c) => c.id === node.characterId);
165
+ if (character && this.onTextCallback) {
166
+ this.onTextCallback(node, character);
167
+ }
168
+ this.emitEvent("dialogue:text-displayed", {
169
+ nodeId: node.id,
170
+ characterId: node.characterId,
171
+ text: node.text,
172
+ emotion: node.emotion
173
+ });
174
+ }
175
+ processChoiceNode(node, _tree) {
176
+ const validOptions = node.options.filter((opt) => {
177
+ if (opt.disabled) {
178
+ return false;
179
+ }
180
+ if (!opt.conditions || opt.conditions.length === 0) {
333
181
  return true;
334
- }
335
- /** Advance to next node (for text nodes) */
336
- advance() {
337
- if (!this.currentState || !this.currentState.isActive) {
338
- return false;
339
- }
340
- const tree = this.trees.get(this.currentState.treeId);
341
- if (!tree) {
342
- return false;
182
+ }
183
+ return opt.conditions.every((c) => this.evaluateCondition(c));
184
+ });
185
+ if (this.onChoiceCallback) {
186
+ this.onChoiceCallback(node, validOptions);
187
+ }
188
+ }
189
+ processBranchNode(node) {
190
+ const result = this.evaluateConditions(node.conditions, node.logic);
191
+ const nextNode = result ? node.trueNode : node.falseNode;
192
+ if (nextNode) {
193
+ this.goToNode(nextNode);
194
+ }
195
+ }
196
+ processSetVariableNode(node, tree) {
197
+ const variable = tree.variables.find((v) => v.id === node.variableId);
198
+ if (!variable) {
199
+ if (node.nextNode) {
200
+ this.goToNode(node.nextNode);
201
+ }
202
+ return;
203
+ }
204
+ const currentValue = this.getVariable(node.variableId) ?? variable.defaultValue;
205
+ let newValue;
206
+ switch (node.operation) {
207
+ case "set":
208
+ newValue = node.value;
209
+ break;
210
+ case "add":
211
+ newValue = currentValue + node.value;
212
+ break;
213
+ case "subtract":
214
+ newValue = currentValue - node.value;
215
+ break;
216
+ case "multiply":
217
+ newValue = currentValue * node.value;
218
+ break;
219
+ case "toggle":
220
+ newValue = !currentValue;
221
+ break;
222
+ case "append":
223
+ newValue = currentValue + node.value;
224
+ break;
225
+ default:
226
+ newValue = node.value;
227
+ }
228
+ this.setVariable(node.variableId, newValue, variable.scope);
229
+ if (node.nextNode) {
230
+ this.goToNode(node.nextNode);
231
+ }
232
+ }
233
+ processEventNode(node) {
234
+ this.events.emit(node.eventType, node.eventData);
235
+ this.emitEvent("dialogue:event-triggered", {
236
+ eventType: node.eventType,
237
+ eventData: node.eventData
238
+ });
239
+ if (node.nextNode) {
240
+ this.goToNode(node.nextNode);
241
+ }
242
+ }
243
+ processRandomNode(node) {
244
+ const totalWeight = node.outputs.reduce((sum, out) => sum + out.weight, 0);
245
+ let random = Math.random() * totalWeight;
246
+ for (const output of node.outputs) {
247
+ random -= output.weight;
248
+ if (random <= 0 && output.nextNode) {
249
+ this.goToNode(output.nextNode);
250
+ return;
251
+ }
252
+ }
253
+ const first = node.outputs[0];
254
+ if (first?.nextNode) {
255
+ this.goToNode(first.nextNode);
256
+ }
257
+ }
258
+ processEndNode(node) {
259
+ if (node.setVariables && this.currentState) {
260
+ const tree = this.trees.get(this.currentState.treeId);
261
+ if (tree) {
262
+ for (const sv of node.setVariables) {
263
+ const variable = tree.variables.find((v) => v.id === sv.variableId);
264
+ if (variable) {
265
+ this.setVariable(sv.variableId, sv.value, variable.scope);
266
+ }
343
267
  }
344
- const node = tree.nodes.find((n) => n.id === this.currentState.currentNodeId);
345
- if (!node) {
346
- return false;
347
- }
348
- if (node.type === 'text' && node.nextNode) {
349
- this.goToNode(node.nextNode);
350
- return true;
268
+ }
269
+ }
270
+ if (this.onEndCallback && this.currentState) {
271
+ this.onEndCallback(node, this.currentState);
272
+ }
273
+ this.endDialogue();
274
+ }
275
+ /* ── Choice Selection ─────────────────────────────────────────── */
276
+ selectChoice(optionId) {
277
+ if (!this.currentState || !this.currentState.isActive) {
278
+ return false;
279
+ }
280
+ const tree = this.trees.get(this.currentState.treeId);
281
+ if (!tree) {
282
+ return false;
283
+ }
284
+ const node = tree.nodes.find((n) => n.id === this.currentState.currentNodeId);
285
+ if (!node || node.type !== "choice") {
286
+ return false;
287
+ }
288
+ const choice = node.options.find((o) => o.id === optionId);
289
+ if (!choice) {
290
+ return false;
291
+ }
292
+ if (choice.setVariables) {
293
+ for (const sv of choice.setVariables) {
294
+ const variable = tree.variables.find((v) => v.id === sv.variableId);
295
+ if (variable) {
296
+ this.setVariable(sv.variableId, sv.value, variable.scope);
351
297
  }
298
+ }
299
+ }
300
+ this.currentState.choicesMade.push({
301
+ nodeId: node.id,
302
+ optionId,
303
+ timestamp: Date.now()
304
+ });
305
+ this.emitEvent("dialogue:choice-selected", {
306
+ nodeId: node.id,
307
+ optionId,
308
+ text: choice.text
309
+ });
310
+ if (choice.nextNode) {
311
+ this.goToNode(choice.nextNode);
312
+ }
313
+ return true;
314
+ }
315
+ /** Advance to next node (for text nodes) */
316
+ advance() {
317
+ if (!this.currentState || !this.currentState.isActive) {
318
+ return false;
319
+ }
320
+ const tree = this.trees.get(this.currentState.treeId);
321
+ if (!tree) {
322
+ return false;
323
+ }
324
+ const node = tree.nodes.find((n) => n.id === this.currentState.currentNodeId);
325
+ if (!node) {
326
+ return false;
327
+ }
328
+ if (node.type === "text" && node.nextNode) {
329
+ this.goToNode(node.nextNode);
330
+ return true;
331
+ }
332
+ return false;
333
+ }
334
+ /* ── Condition Evaluation ─────────────────────────────────────── */
335
+ evaluateConditions(conditions, logic) {
336
+ if (conditions.length === 0) {
337
+ return true;
338
+ }
339
+ if (logic === "and") {
340
+ return conditions.every((c) => this.evaluateCondition(c));
341
+ } else {
342
+ return conditions.some((c) => this.evaluateCondition(c));
343
+ }
344
+ }
345
+ evaluateCondition(condition) {
346
+ const varValue = this.getVariable(condition.variableId);
347
+ if (varValue === void 0) {
348
+ return false;
349
+ }
350
+ const { operator, value } = condition;
351
+ switch (operator) {
352
+ case "eq":
353
+ return varValue === value;
354
+ case "neq":
355
+ return varValue !== value;
356
+ case "gt":
357
+ return varValue > value;
358
+ case "lt":
359
+ return varValue < value;
360
+ case "gte":
361
+ return varValue >= value;
362
+ case "lte":
363
+ return varValue <= value;
364
+ case "contains":
365
+ return String(varValue).includes(String(value));
366
+ case "startsWith":
367
+ return String(varValue).startsWith(String(value));
368
+ case "endsWith":
369
+ return String(varValue).endsWith(String(value));
370
+ default:
352
371
  return false;
353
372
  }
354
- /* ── Condition Evaluation ─────────────────────────────────────── */
355
- evaluateConditions(conditions, logic) {
356
- if (conditions.length === 0) {
357
- return true;
358
- }
359
- if (logic === 'and') {
360
- return conditions.every((c) => this.evaluateCondition(c));
361
- }
362
- else {
363
- return conditions.some((c) => this.evaluateCondition(c));
364
- }
365
- }
366
- evaluateCondition(condition) {
367
- const varValue = this.getVariable(condition.variableId);
368
- if (varValue === undefined) {
369
- return false;
370
- }
371
- const { operator, value } = condition;
372
- switch (operator) {
373
- case 'eq':
374
- return varValue === value;
375
- case 'neq':
376
- return varValue !== value;
377
- case 'gt':
378
- return varValue > value;
379
- case 'lt':
380
- return varValue < value;
381
- case 'gte':
382
- return varValue >= value;
383
- case 'lte':
384
- return varValue <= value;
385
- case 'contains':
386
- return String(varValue).includes(String(value));
387
- case 'startsWith':
388
- return String(varValue).startsWith(String(value));
389
- case 'endsWith':
390
- return String(varValue).endsWith(String(value));
391
- default:
392
- return false;
393
- }
394
- }
395
- /* ── Callbacks ────────────────────────────────────────────────── */
396
- onText(callback) {
397
- this.onTextCallback = callback;
398
- }
399
- onChoice(callback) {
400
- this.onChoiceCallback = callback;
401
- }
402
- onEnd(callback) {
403
- this.onEndCallback = callback;
404
- }
405
- /* ── Events ───────────────────────────────────────────────────── */
406
- emitEvent(type, data) {
407
- this.events.emit(type, {
408
- type,
409
- treeId: this.currentState?.treeId ?? '',
410
- nodeId: this.currentState?.currentNodeId ?? undefined,
411
- data,
412
- timestamp: Date.now(),
413
- });
414
- }
415
- subscribe(eventType, handler) {
416
- return this.events.on(eventType, handler);
417
- }
373
+ }
374
+ /* ── Callbacks ────────────────────────────────────────────────── */
375
+ onText(callback) {
376
+ this.onTextCallback = callback;
377
+ }
378
+ onChoice(callback) {
379
+ this.onChoiceCallback = callback;
380
+ }
381
+ onEnd(callback) {
382
+ this.onEndCallback = callback;
383
+ }
384
+ /* ── Events ───────────────────────────────────────────────────── */
385
+ emitEvent(type, data) {
386
+ this.events.emit(type, {
387
+ type,
388
+ treeId: this.currentState?.treeId ?? "",
389
+ nodeId: this.currentState?.currentNodeId ?? void 0,
390
+ data,
391
+ timestamp: Date.now()
392
+ });
393
+ }
394
+ subscribe(eventType, handler) {
395
+ return this.events.on(eventType, handler);
396
+ }
418
397
  }
419
- /* ═══════════════════════════════════════════════════════════════
420
- DIALOGUE TREE BUILDER (Fluent API)
421
- ══════════════════════════════════════════════════════════════════ */
422
398
  class DialogueTreeBuilder {
423
- constructor(id, name) {
424
- this.nodeCounter = 0;
425
- this.tree = {
426
- id,
427
- name,
428
- version: '1.0.0',
429
- characters: [],
430
- variables: [],
431
- nodes: [],
432
- startNodeId: '',
433
- metadata: {
434
- created: new Date().toISOString(),
435
- modified: new Date().toISOString(),
436
- locale: 'en',
437
- },
438
- };
439
- }
440
- generateId() {
441
- return `node_${++this.nodeCounter}`;
442
- }
443
- /* ── Metadata ─────────────────────────────────────────────────── */
444
- description(desc) {
445
- this.tree.description = desc;
446
- return this;
447
- }
448
- author(author) {
449
- this.tree.metadata.author = author;
450
- return this;
451
- }
452
- locale(locale) {
453
- this.tree.metadata.locale = locale;
454
- return this;
455
- }
456
- tags(tags) {
457
- this.tree.metadata.tags = tags;
458
- return this;
459
- }
460
- /* ── Characters ───────────────────────────────────────────────── */
461
- addCharacter(character) {
462
- this.tree.characters.push(character);
463
- return this;
464
- }
465
- /* ── Variables ────────────────────────────────────────────────── */
466
- addVariable(variable) {
467
- this.tree.variables.push(variable);
468
- return this;
469
- }
470
- boolVar(id, name, defaultValue = false, scope = 'conversation') {
471
- return this.addVariable({ id, name, type: 'boolean', defaultValue, scope });
472
- }
473
- numVar(id, name, defaultValue = 0, scope = 'conversation') {
474
- return this.addVariable({ id, name, type: 'number', defaultValue, scope });
475
- }
476
- strVar(id, name, defaultValue = '', scope = 'conversation') {
477
- return this.addVariable({ id, name, type: 'string', defaultValue, scope });
478
- }
479
- /* ── Nodes ────────────────────────────────────────────────────── */
480
- addStart(label, nextNode = null, position = { x: 0, y: 0 }) {
481
- const id = this.generateId();
482
- const node = { id, type: 'start', label, nextNode, position };
483
- this.tree.nodes.push(node);
484
- if (!this.tree.startNodeId) {
485
- this.tree.startNodeId = id;
486
- }
487
- return this;
488
- }
489
- addText(characterId, text, nextNode = null, options = {}) {
490
- const id = this.generateId();
491
- const node = {
492
- id,
493
- type: 'text',
494
- characterId,
495
- text,
496
- nextNode,
497
- position: options.position ?? { x: 100, y: 0 },
498
- ...options,
499
- };
500
- this.tree.nodes.push(node);
501
- return this;
502
- }
503
- addChoice(options, settings = {}) {
504
- const id = this.generateId();
505
- const node = {
506
- id,
507
- type: 'choice',
508
- options,
509
- position: settings.position ?? { x: 200, y: 0 },
510
- ...settings,
511
- };
512
- this.tree.nodes.push(node);
513
- return this;
514
- }
515
- addBranch(conditions, trueNode, falseNode, logic = 'and', position = { x: 150, y: 0 }) {
516
- const id = this.generateId();
517
- const node = {
518
- id,
519
- type: 'branch',
520
- conditions,
521
- logic,
522
- trueNode,
523
- falseNode,
524
- position,
525
- };
526
- this.tree.nodes.push(node);
527
- return this;
528
- }
529
- addSetVariable(variableId, operation, value, nextNode = null, position = { x: 150, y: 0 }) {
530
- const id = this.generateId();
531
- const node = {
532
- id,
533
- type: 'set_variable',
534
- variableId,
535
- operation,
536
- value,
537
- nextNode,
538
- position,
539
- };
540
- this.tree.nodes.push(node);
541
- return this;
542
- }
543
- addEvent(eventType, eventData, nextNode = null, position = { x: 150, y: 0 }) {
544
- const id = this.generateId();
545
- const node = {
546
- id,
547
- type: 'event',
548
- eventType,
549
- eventData,
550
- nextNode,
551
- position,
552
- };
553
- this.tree.nodes.push(node);
554
- return this;
555
- }
556
- addRandom(outputs, position = { x: 150, y: 0 }) {
557
- const id = this.generateId();
558
- const node = {
559
- id,
560
- type: 'random',
561
- outputs: outputs.map((o, i) => ({ ...o, id: `out_${i}` })),
562
- position,
563
- };
564
- this.tree.nodes.push(node);
565
- return this;
566
- }
567
- addEnd(result = 'success', setVariables, position = { x: 300, y: 0 }) {
568
- const id = this.generateId();
569
- const node = {
570
- id,
571
- type: 'end',
572
- result,
573
- setVariables,
574
- position,
575
- };
576
- this.tree.nodes.push(node);
577
- return this;
578
- }
579
- /* ── Build ────────────────────────────────────────────────────── */
580
- build() {
581
- this.tree.metadata.modified = new Date().toISOString();
582
- return { ...this.tree };
583
- }
584
- /** Get the ID of the last added node */
585
- lastNodeId() {
586
- const lastNode = this.tree.nodes[this.tree.nodes.length - 1];
587
- return lastNode?.id ?? '';
588
- }
589
- /** Get node by index (1-based for readability) */
590
- nodeId(index) {
591
- return `node_${index}`;
592
- }
399
+ constructor(id, name) {
400
+ this.nodeCounter = 0;
401
+ this.tree = {
402
+ id,
403
+ name,
404
+ version: "1.0.0",
405
+ characters: [],
406
+ variables: [],
407
+ nodes: [],
408
+ startNodeId: "",
409
+ metadata: {
410
+ created: (/* @__PURE__ */ new Date()).toISOString(),
411
+ modified: (/* @__PURE__ */ new Date()).toISOString(),
412
+ locale: "en"
413
+ }
414
+ };
415
+ }
416
+ generateId() {
417
+ return `node_${++this.nodeCounter}`;
418
+ }
419
+ /* ── Metadata ─────────────────────────────────────────────────── */
420
+ description(desc) {
421
+ this.tree.description = desc;
422
+ return this;
423
+ }
424
+ author(author) {
425
+ this.tree.metadata.author = author;
426
+ return this;
427
+ }
428
+ locale(locale) {
429
+ this.tree.metadata.locale = locale;
430
+ return this;
431
+ }
432
+ tags(tags) {
433
+ this.tree.metadata.tags = tags;
434
+ return this;
435
+ }
436
+ /* ── Characters ───────────────────────────────────────────────── */
437
+ addCharacter(character) {
438
+ this.tree.characters.push(character);
439
+ return this;
440
+ }
441
+ /* ── Variables ────────────────────────────────────────────────── */
442
+ addVariable(variable) {
443
+ this.tree.variables.push(variable);
444
+ return this;
445
+ }
446
+ boolVar(id, name, defaultValue = false, scope = "conversation") {
447
+ return this.addVariable({ id, name, type: "boolean", defaultValue, scope });
448
+ }
449
+ numVar(id, name, defaultValue = 0, scope = "conversation") {
450
+ return this.addVariable({ id, name, type: "number", defaultValue, scope });
451
+ }
452
+ strVar(id, name, defaultValue = "", scope = "conversation") {
453
+ return this.addVariable({ id, name, type: "string", defaultValue, scope });
454
+ }
455
+ /* ── Nodes ────────────────────────────────────────────────────── */
456
+ addStart(label, nextNode = null, position = { x: 0, y: 0 }) {
457
+ const id = this.generateId();
458
+ const node = { id, type: "start", label, nextNode, position };
459
+ this.tree.nodes.push(node);
460
+ if (!this.tree.startNodeId) {
461
+ this.tree.startNodeId = id;
462
+ }
463
+ return this;
464
+ }
465
+ addText(characterId, text, nextNode = null, options = {}) {
466
+ const id = this.generateId();
467
+ const node = {
468
+ id,
469
+ type: "text",
470
+ characterId,
471
+ text,
472
+ nextNode,
473
+ position: options.position ?? { x: 100, y: 0 },
474
+ ...options
475
+ };
476
+ this.tree.nodes.push(node);
477
+ return this;
478
+ }
479
+ addChoice(options, settings = {}) {
480
+ const id = this.generateId();
481
+ const node = {
482
+ id,
483
+ type: "choice",
484
+ options,
485
+ position: settings.position ?? { x: 200, y: 0 },
486
+ ...settings
487
+ };
488
+ this.tree.nodes.push(node);
489
+ return this;
490
+ }
491
+ addBranch(conditions, trueNode, falseNode, logic = "and", position = { x: 150, y: 0 }) {
492
+ const id = this.generateId();
493
+ const node = {
494
+ id,
495
+ type: "branch",
496
+ conditions,
497
+ logic,
498
+ trueNode,
499
+ falseNode,
500
+ position
501
+ };
502
+ this.tree.nodes.push(node);
503
+ return this;
504
+ }
505
+ addSetVariable(variableId, operation, value, nextNode = null, position = { x: 150, y: 0 }) {
506
+ const id = this.generateId();
507
+ const node = {
508
+ id,
509
+ type: "set_variable",
510
+ variableId,
511
+ operation,
512
+ value,
513
+ nextNode,
514
+ position
515
+ };
516
+ this.tree.nodes.push(node);
517
+ return this;
518
+ }
519
+ addEvent(eventType, eventData, nextNode = null, position = { x: 150, y: 0 }) {
520
+ const id = this.generateId();
521
+ const node = {
522
+ id,
523
+ type: "event",
524
+ eventType,
525
+ eventData,
526
+ nextNode,
527
+ position
528
+ };
529
+ this.tree.nodes.push(node);
530
+ return this;
531
+ }
532
+ addRandom(outputs, position = { x: 150, y: 0 }) {
533
+ const id = this.generateId();
534
+ const node = {
535
+ id,
536
+ type: "random",
537
+ outputs: outputs.map((o, i) => ({ ...o, id: `out_${i}` })),
538
+ position
539
+ };
540
+ this.tree.nodes.push(node);
541
+ return this;
542
+ }
543
+ addEnd(result = "success", setVariables, position = { x: 300, y: 0 }) {
544
+ const id = this.generateId();
545
+ const node = {
546
+ id,
547
+ type: "end",
548
+ result,
549
+ setVariables,
550
+ position
551
+ };
552
+ this.tree.nodes.push(node);
553
+ return this;
554
+ }
555
+ /* ── Build ────────────────────────────────────────────────────── */
556
+ build() {
557
+ this.tree.metadata.modified = (/* @__PURE__ */ new Date()).toISOString();
558
+ return { ...this.tree };
559
+ }
560
+ /** Get the ID of the last added node */
561
+ lastNodeId() {
562
+ const lastNode = this.tree.nodes[this.tree.nodes.length - 1];
563
+ return lastNode?.id ?? "";
564
+ }
565
+ /** Get node by index (1-based for readability) */
566
+ nodeId(index) {
567
+ return `node_${index}`;
568
+ }
593
569
  }
594
- /**
595
- * React hook for typewriter text effect
596
- */
597
570
  function useTypewriter(text, speed = 50, enabled = true) {
598
- const [displayedText, setDisplayedText] = React.useState('');
599
- const [isComplete, setIsComplete] = React.useState(!enabled);
600
- const indexRef = React.useRef(0);
601
- React.useEffect(() => {
602
- if (!enabled) {
603
- setDisplayedText(text);
604
- setIsComplete(true);
605
- return;
606
- }
607
- setDisplayedText('');
608
- setIsComplete(false);
609
- indexRef.current = 0;
610
- const interval = setInterval(() => {
611
- if (indexRef.current >= text.length) {
612
- setIsComplete(true);
613
- clearInterval(interval);
614
- return;
615
- }
616
- indexRef.current++;
617
- setDisplayedText(text.slice(0, indexRef.current));
618
- }, 1000 / speed);
619
- return () => clearInterval(interval);
620
- }, [text, speed, enabled]);
621
- const skip = React.useCallback(() => {
622
- setDisplayedText(text);
571
+ const [displayedText, setDisplayedText] = React.useState("");
572
+ const [isComplete, setIsComplete] = React.useState(!enabled);
573
+ const indexRef = React.useRef(0);
574
+ React.useEffect(() => {
575
+ if (!enabled) {
576
+ setDisplayedText(text);
577
+ setIsComplete(true);
578
+ return;
579
+ }
580
+ setDisplayedText("");
581
+ setIsComplete(false);
582
+ indexRef.current = 0;
583
+ const interval = setInterval(() => {
584
+ if (indexRef.current >= text.length) {
623
585
  setIsComplete(true);
624
- }, [text]);
625
- return { displayedText, isComplete, skip };
586
+ clearInterval(interval);
587
+ return;
588
+ }
589
+ indexRef.current++;
590
+ setDisplayedText(text.slice(0, indexRef.current));
591
+ }, 1e3 / speed);
592
+ return () => clearInterval(interval);
593
+ }, [text, speed, enabled]);
594
+ const skip = React.useCallback(() => {
595
+ setDisplayedText(text);
596
+ setIsComplete(true);
597
+ }, [text]);
598
+ return { displayedText, isComplete, skip };
626
599
  }
627
- /**
628
- * DialogueBox component for displaying dialogue text
629
- */
630
- const DialogueBox = ({ text, characterName, portrait, emotion = 'neutral', textEffect = 'typewriter', textSpeed = 50, onComplete, onAdvance, className = '', style, }) => {
631
- const { displayedText, isComplete, skip } = useTypewriter(text, textSpeed, textEffect === 'typewriter');
632
- React.useEffect(() => {
633
- if (isComplete && onComplete) {
634
- onComplete();
635
- }
636
- }, [isComplete, onComplete]);
637
- const handleClick = () => {
638
- if (!isComplete) {
639
- skip();
640
- }
641
- else if (onAdvance) {
642
- onAdvance();
643
- }
644
- };
645
- return React.createElement('div', {
646
- className: `nice-dialogue-box ${className}`,
647
- style: {
648
- display: 'flex',
649
- gap: '16px',
650
- padding: '16px',
651
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
652
- borderRadius: '8px',
653
- color: 'white',
654
- cursor: 'pointer',
655
- ...style,
600
+ const DialogueBox = ({
601
+ text,
602
+ characterName,
603
+ portrait,
604
+ emotion = "neutral",
605
+ textEffect = "typewriter",
606
+ textSpeed = 50,
607
+ onComplete,
608
+ onAdvance,
609
+ className = "",
610
+ style
611
+ }) => {
612
+ const { displayedText, isComplete, skip } = useTypewriter(
613
+ text,
614
+ textSpeed,
615
+ textEffect === "typewriter"
616
+ );
617
+ React.useEffect(() => {
618
+ if (isComplete && onComplete) {
619
+ onComplete();
620
+ }
621
+ }, [isComplete, onComplete]);
622
+ const handleClick = () => {
623
+ if (!isComplete) {
624
+ skip();
625
+ } else if (onAdvance) {
626
+ onAdvance();
627
+ }
628
+ };
629
+ return React.createElement(
630
+ "div",
631
+ {
632
+ className: `nice-dialogue-box ${className}`,
633
+ style: {
634
+ display: "flex",
635
+ gap: "16px",
636
+ padding: "16px",
637
+ backgroundColor: "rgba(0, 0, 0, 0.8)",
638
+ borderRadius: "8px",
639
+ color: "white",
640
+ cursor: "pointer",
641
+ ...style
642
+ },
643
+ onClick: handleClick,
644
+ "data-emotion": emotion
645
+ },
646
+ [
647
+ portrait && React.createElement(
648
+ "div",
649
+ {
650
+ key: "portrait",
651
+ className: "nice-dialogue-portrait",
652
+ style: {
653
+ width: "80px",
654
+ height: "80px",
655
+ flexShrink: 0,
656
+ borderRadius: "8px",
657
+ overflow: "hidden"
658
+ }
659
+ },
660
+ React.createElement("img", {
661
+ src: portrait,
662
+ alt: characterName ?? "Character",
663
+ style: { width: "100%", height: "100%", objectFit: "cover" }
664
+ })
665
+ ),
666
+ React.createElement(
667
+ "div",
668
+ {
669
+ key: "content",
670
+ className: "nice-dialogue-content",
671
+ style: { flex: 1 }
656
672
  },
657
- onClick: handleClick,
658
- 'data-emotion': emotion,
659
- }, [
660
- portrait &&
661
- React.createElement('div', {
662
- key: 'portrait',
663
- className: 'nice-dialogue-portrait',
664
- style: {
665
- width: '80px',
666
- height: '80px',
667
- flexShrink: 0,
668
- borderRadius: '8px',
669
- overflow: 'hidden',
670
- },
671
- }, React.createElement('img', {
672
- src: portrait,
673
- alt: characterName ?? 'Character',
674
- style: { width: '100%', height: '100%', objectFit: 'cover' },
675
- })),
676
- React.createElement('div', {
677
- key: 'content',
678
- className: 'nice-dialogue-content',
679
- style: { flex: 1 },
680
- }, [
681
- characterName &&
682
- React.createElement('div', {
683
- key: 'name',
684
- className: 'nice-dialogue-name',
685
- style: {
686
- fontWeight: 'bold',
687
- marginBottom: '8px',
688
- color: '#64b5f6',
689
- },
690
- }, characterName),
691
- React.createElement('div', {
692
- key: 'text',
693
- className: 'nice-dialogue-text',
694
- style: { lineHeight: 1.6 },
695
- }, displayedText),
696
- React.createElement('div', {
697
- key: 'indicator',
698
- className: 'nice-dialogue-indicator',
699
- style: {
700
- marginTop: '8px',
701
- textAlign: 'right',
702
- opacity: isComplete ? 1 : 0.5,
703
- fontSize: '12px',
704
- },
705
- }, isComplete ? 'Click to continue' : '...'),
706
- ]),
707
- ]);
673
+ [
674
+ characterName && React.createElement(
675
+ "div",
676
+ {
677
+ key: "name",
678
+ className: "nice-dialogue-name",
679
+ style: {
680
+ fontWeight: "bold",
681
+ marginBottom: "8px",
682
+ color: "#64b5f6"
683
+ }
684
+ },
685
+ characterName
686
+ ),
687
+ React.createElement(
688
+ "div",
689
+ {
690
+ key: "text",
691
+ className: "nice-dialogue-text",
692
+ style: { lineHeight: 1.6 }
693
+ },
694
+ displayedText
695
+ ),
696
+ React.createElement(
697
+ "div",
698
+ {
699
+ key: "indicator",
700
+ className: "nice-dialogue-indicator",
701
+ style: {
702
+ marginTop: "8px",
703
+ textAlign: "right",
704
+ opacity: isComplete ? 1 : 0.5,
705
+ fontSize: "12px"
706
+ }
707
+ },
708
+ isComplete ? "Click to continue" : "..."
709
+ )
710
+ ]
711
+ )
712
+ ]
713
+ );
708
714
  };
709
- /**
710
- * ChoiceList component for displaying dialogue choices
711
- */
712
- const ChoiceList = ({ options, prompt, onSelect, timeout, className = '', style, }) => {
713
- const [timeLeft, setTimeLeft] = React.useState(timeout ?? 0);
714
- const [selectedIndex, setSelectedIndex] = React.useState(0);
715
- // Timeout countdown
716
- React.useEffect(() => {
717
- if (!timeout) {
718
- return;
715
+ const ChoiceList = ({
716
+ options,
717
+ prompt,
718
+ onSelect,
719
+ timeout,
720
+ className = "",
721
+ style
722
+ }) => {
723
+ const [timeLeft, setTimeLeft] = React.useState(timeout ?? 0);
724
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
725
+ React.useEffect(() => {
726
+ if (!timeout) {
727
+ return;
728
+ }
729
+ setTimeLeft(timeout);
730
+ const interval = setInterval(() => {
731
+ setTimeLeft((prev) => {
732
+ if (prev <= 100) {
733
+ const firstValid = options.find((o) => !o.disabled);
734
+ if (firstValid) {
735
+ onSelect(firstValid.id);
736
+ }
737
+ return 0;
719
738
  }
720
- setTimeLeft(timeout);
721
- const interval = setInterval(() => {
722
- setTimeLeft((prev) => {
723
- if (prev <= 100) {
724
- // Auto-select first option
725
- const firstValid = options.find((o) => !o.disabled);
726
- if (firstValid) {
727
- onSelect(firstValid.id);
728
- }
729
- return 0;
730
- }
731
- return prev - 100;
732
- });
733
- }, 100);
734
- return () => clearInterval(interval);
735
- }, [timeout, options, onSelect]);
736
- // Keyboard navigation
737
- React.useEffect(() => {
738
- const handleKeyDown = (e) => {
739
- const validOptions = options.filter((o) => !o.disabled);
740
- switch (e.key) {
741
- case 'ArrowUp':
742
- e.preventDefault();
743
- setSelectedIndex((prev) => (prev - 1 + validOptions.length) % validOptions.length);
744
- break;
745
- case 'ArrowDown':
746
- e.preventDefault();
747
- setSelectedIndex((prev) => (prev + 1) % validOptions.length);
748
- break;
749
- case 'Enter':
750
- case ' ':
751
- e.preventDefault();
752
- if (validOptions[selectedIndex]) {
753
- onSelect(validOptions[selectedIndex].id);
754
- }
755
- break;
756
- }
757
- };
758
- window.addEventListener('keydown', handleKeyDown);
759
- return () => window.removeEventListener('keydown', handleKeyDown);
760
- }, [options, selectedIndex, onSelect]);
761
- const validOptions = options.filter((o) => !o.disabled);
762
- return React.createElement('div', {
763
- className: `nice-choice-list ${className}`,
764
- style: {
765
- padding: '16px',
766
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
767
- borderRadius: '8px',
768
- color: 'white',
769
- ...style,
739
+ return prev - 100;
740
+ });
741
+ }, 100);
742
+ return () => clearInterval(interval);
743
+ }, [timeout, options, onSelect]);
744
+ React.useEffect(() => {
745
+ const handleKeyDown = (e) => {
746
+ const validOptions2 = options.filter((o) => !o.disabled);
747
+ switch (e.key) {
748
+ case "ArrowUp":
749
+ e.preventDefault();
750
+ setSelectedIndex((prev) => (prev - 1 + validOptions2.length) % validOptions2.length);
751
+ break;
752
+ case "ArrowDown":
753
+ e.preventDefault();
754
+ setSelectedIndex((prev) => (prev + 1) % validOptions2.length);
755
+ break;
756
+ case "Enter":
757
+ case " ":
758
+ e.preventDefault();
759
+ if (validOptions2[selectedIndex]) {
760
+ onSelect(validOptions2[selectedIndex].id);
761
+ }
762
+ break;
763
+ }
764
+ };
765
+ window.addEventListener("keydown", handleKeyDown);
766
+ return () => window.removeEventListener("keydown", handleKeyDown);
767
+ }, [options, selectedIndex, onSelect]);
768
+ const validOptions = options.filter((o) => !o.disabled);
769
+ return React.createElement(
770
+ "div",
771
+ {
772
+ className: `nice-choice-list ${className}`,
773
+ style: {
774
+ padding: "16px",
775
+ backgroundColor: "rgba(0, 0, 0, 0.8)",
776
+ borderRadius: "8px",
777
+ color: "white",
778
+ ...style
779
+ }
780
+ },
781
+ [
782
+ prompt && React.createElement(
783
+ "div",
784
+ {
785
+ key: "prompt",
786
+ className: "nice-choice-prompt",
787
+ style: {
788
+ marginBottom: "16px",
789
+ fontStyle: "italic",
790
+ opacity: 0.9
791
+ }
792
+ },
793
+ prompt
794
+ ),
795
+ timeout && timeLeft > 0 && React.createElement(
796
+ "div",
797
+ {
798
+ key: "timer",
799
+ className: "nice-choice-timer",
800
+ style: {
801
+ marginBottom: "8px",
802
+ height: "4px",
803
+ backgroundColor: "rgba(255, 255, 255, 0.2)",
804
+ borderRadius: "2px",
805
+ overflow: "hidden"
806
+ }
770
807
  },
771
- }, [
772
- prompt &&
773
- React.createElement('div', {
774
- key: 'prompt',
775
- className: 'nice-choice-prompt',
776
- style: {
777
- marginBottom: '16px',
778
- fontStyle: 'italic',
779
- opacity: 0.9,
780
- },
781
- }, prompt),
782
- timeout &&
783
- timeLeft > 0 &&
784
- React.createElement('div', {
785
- key: 'timer',
786
- className: 'nice-choice-timer',
787
- style: {
788
- marginBottom: '8px',
789
- height: '4px',
790
- backgroundColor: 'rgba(255, 255, 255, 0.2)',
791
- borderRadius: '2px',
792
- overflow: 'hidden',
793
- },
794
- }, React.createElement('div', {
795
- style: {
796
- width: `${(timeLeft / timeout) * 100}%`,
797
- height: '100%',
798
- backgroundColor: timeLeft < 3000 ? '#f44336' : '#4caf50',
799
- transition: 'width 0.1s linear',
800
- },
801
- })),
802
- React.createElement('div', {
803
- key: 'options',
804
- className: 'nice-choice-options',
805
- style: { display: 'flex', flexDirection: 'column', gap: '8px' },
806
- }, validOptions.map((option, index) => React.createElement('button', {
807
- key: option.id,
808
- className: `nice-choice-option ${index === selectedIndex ? 'selected' : ''}`,
809
- onClick: () => onSelect(option.id),
810
- title: option.tooltip,
811
- style: {
812
- padding: '12px 16px',
813
- backgroundColor: index === selectedIndex ? 'rgba(100, 181, 246, 0.3)' : 'rgba(255, 255, 255, 0.1)',
814
- border: index === selectedIndex ? '2px solid #64b5f6' : '2px solid transparent',
815
- borderRadius: '4px',
816
- color: 'white',
817
- cursor: 'pointer',
818
- textAlign: 'left',
819
- transition: 'all 0.2s ease',
808
+ React.createElement("div", {
809
+ style: {
810
+ width: `${timeLeft / timeout * 100}%`,
811
+ height: "100%",
812
+ backgroundColor: timeLeft < 3e3 ? "#f44336" : "#4caf50",
813
+ transition: "width 0.1s linear"
814
+ }
815
+ })
816
+ ),
817
+ React.createElement(
818
+ "div",
819
+ {
820
+ key: "options",
821
+ className: "nice-choice-options",
822
+ style: { display: "flex", flexDirection: "column", gap: "8px" }
823
+ },
824
+ validOptions.map(
825
+ (option, index) => React.createElement(
826
+ "button",
827
+ {
828
+ key: option.id,
829
+ className: `nice-choice-option ${index === selectedIndex ? "selected" : ""}`,
830
+ onClick: () => onSelect(option.id),
831
+ title: option.tooltip,
832
+ style: {
833
+ padding: "12px 16px",
834
+ backgroundColor: index === selectedIndex ? "rgba(100, 181, 246, 0.3)" : "rgba(255, 255, 255, 0.1)",
835
+ border: index === selectedIndex ? "2px solid #64b5f6" : "2px solid transparent",
836
+ borderRadius: "4px",
837
+ color: "white",
838
+ cursor: "pointer",
839
+ textAlign: "left",
840
+ transition: "all 0.2s ease"
841
+ }
820
842
  },
821
- }, option.text))),
822
- ]);
843
+ option.text
844
+ )
845
+ )
846
+ )
847
+ ]
848
+ );
823
849
  };
824
- /* ═══════════════════════════════════════════════════════════════
825
- SERIALIZATION & VALIDATION
826
- ══════════════════════════════════════════════════════════════════ */
827
- /**
828
- * Serialize dialogue tree to JSON string
829
- */
830
850
  function serializeDialogueTree(tree) {
831
- return JSON.stringify(tree, null, 2);
851
+ return JSON.stringify(tree, null, 2);
832
852
  }
833
- /**
834
- * Deserialize dialogue tree from JSON string
835
- */
836
853
  function deserializeDialogueTree(json) {
837
- const parsed = JSON.parse(json);
838
- return validateDialogueTree(parsed);
854
+ const parsed = JSON.parse(json);
855
+ return validateDialogueTree(parsed);
839
856
  }
840
- /**
841
- * Validate dialogue tree structure
842
- */
843
857
  function validateDialogueTree(tree) {
844
- if (!tree || typeof tree !== 'object') {
845
- throw new Error('Invalid dialogue tree: must be an object');
846
- }
847
- const t = tree;
848
- if (typeof t.id !== 'string' || !t.id) {
849
- throw new Error('Invalid dialogue tree: missing id');
850
- }
851
- if (typeof t.name !== 'string' || !t.name) {
852
- throw new Error('Invalid dialogue tree: missing name');
853
- }
854
- if (!Array.isArray(t.nodes)) {
855
- throw new Error('Invalid dialogue tree: nodes must be an array');
856
- }
857
- if (!Array.isArray(t.characters)) {
858
- throw new Error('Invalid dialogue tree: characters must be an array');
859
- }
860
- if (!Array.isArray(t.variables)) {
861
- throw new Error('Invalid dialogue tree: variables must be an array');
862
- }
863
- if (typeof t.startNodeId !== 'string') {
864
- throw new Error('Invalid dialogue tree: missing startNodeId');
865
- }
866
- // Validate all node connections
867
- const nodeIds = new Set(t.nodes.map((n) => n.id));
868
- for (const node of t.nodes) {
869
- validateNodeConnections(node, nodeIds);
870
- }
871
- return t;
858
+ if (!tree || typeof tree !== "object") {
859
+ throw new Error("Invalid dialogue tree: must be an object");
860
+ }
861
+ const t = tree;
862
+ if (typeof t.id !== "string" || !t.id) {
863
+ throw new Error("Invalid dialogue tree: missing id");
864
+ }
865
+ if (typeof t.name !== "string" || !t.name) {
866
+ throw new Error("Invalid dialogue tree: missing name");
867
+ }
868
+ if (!Array.isArray(t.nodes)) {
869
+ throw new Error("Invalid dialogue tree: nodes must be an array");
870
+ }
871
+ if (!Array.isArray(t.characters)) {
872
+ throw new Error("Invalid dialogue tree: characters must be an array");
873
+ }
874
+ if (!Array.isArray(t.variables)) {
875
+ throw new Error("Invalid dialogue tree: variables must be an array");
876
+ }
877
+ if (typeof t.startNodeId !== "string") {
878
+ throw new Error("Invalid dialogue tree: missing startNodeId");
879
+ }
880
+ const nodeIds = new Set(t.nodes.map((n) => n.id));
881
+ for (const node of t.nodes) {
882
+ validateNodeConnections(node, nodeIds);
883
+ }
884
+ return t;
872
885
  }
873
886
  function validateNodeConnections(node, validIds) {
874
- const checkId = (id, context) => {
875
- if (id !== null && !validIds.has(id)) {
876
- throw new Error(`Invalid node reference "${id}" in ${context} of node "${node.id}"`);
877
- }
878
- };
879
- switch (node.type) {
880
- case 'start':
881
- case 'text':
882
- case 'set_variable':
883
- case 'event':
884
- checkId(node.nextNode, 'nextNode');
885
- break;
886
- case 'choice':
887
- for (const opt of node.options) {
888
- checkId(opt.nextNode, `option "${opt.id}"`);
889
- }
890
- break;
891
- case 'branch':
892
- case 'check_variable':
893
- checkId(node.trueNode, 'trueNode');
894
- checkId(node.falseNode, 'falseNode');
895
- break;
896
- case 'random':
897
- for (const out of node.outputs) {
898
- checkId(out.nextNode, `output "${out.id}"`);
899
- }
900
- break;
901
- }
887
+ const checkId = (id, context) => {
888
+ if (id !== null && !validIds.has(id)) {
889
+ throw new Error(`Invalid node reference "${id}" in ${context} of node "${node.id}"`);
890
+ }
891
+ };
892
+ switch (node.type) {
893
+ case "start":
894
+ case "text":
895
+ case "set_variable":
896
+ case "event":
897
+ checkId(node.nextNode, "nextNode");
898
+ break;
899
+ case "choice":
900
+ for (const opt of node.options) {
901
+ checkId(opt.nextNode, `option "${opt.id}"`);
902
+ }
903
+ break;
904
+ case "branch":
905
+ case "check_variable":
906
+ checkId(node.trueNode, "trueNode");
907
+ checkId(node.falseNode, "falseNode");
908
+ break;
909
+ case "random":
910
+ for (const out of node.outputs) {
911
+ checkId(out.nextNode, `output "${out.id}"`);
912
+ }
913
+ break;
914
+ }
902
915
  }
903
- /**
904
- * Find unreachable nodes in dialogue tree
905
- */
906
916
  function findUnreachableNodes(tree) {
907
- const reachable = new Set();
908
- const toVisit = [tree.startNodeId];
909
- while (toVisit.length > 0) {
910
- const nodeId = toVisit.pop();
911
- if (reachable.has(nodeId)) {
912
- continue;
913
- }
914
- reachable.add(nodeId);
915
- const node = tree.nodes.find((n) => n.id === nodeId);
916
- if (!node) {
917
- continue;
918
- }
919
- const nextIds = getNextNodeIds(node);
920
- for (const id of nextIds) {
921
- if (id && !reachable.has(id)) {
922
- toVisit.push(id);
923
- }
924
- }
925
- }
926
- return tree.nodes.filter((n) => !reachable.has(n.id) && n.type !== 'start').map((n) => n.id);
917
+ const reachable = /* @__PURE__ */ new Set();
918
+ const toVisit = [tree.startNodeId];
919
+ while (toVisit.length > 0) {
920
+ const nodeId = toVisit.pop();
921
+ if (reachable.has(nodeId)) {
922
+ continue;
923
+ }
924
+ reachable.add(nodeId);
925
+ const node = tree.nodes.find((n) => n.id === nodeId);
926
+ if (!node) {
927
+ continue;
928
+ }
929
+ const nextIds = getNextNodeIds(node);
930
+ for (const id of nextIds) {
931
+ if (id && !reachable.has(id)) {
932
+ toVisit.push(id);
933
+ }
934
+ }
935
+ }
936
+ return tree.nodes.filter((n) => !reachable.has(n.id) && n.type !== "start").map((n) => n.id);
927
937
  }
928
938
  function getNextNodeIds(node) {
929
- switch (node.type) {
930
- case 'start':
931
- case 'text':
932
- case 'set_variable':
933
- case 'event':
934
- return [node.nextNode];
935
- case 'choice':
936
- return node.options.map((o) => o.nextNode);
937
- case 'branch':
938
- case 'check_variable':
939
- return [node.trueNode, node.falseNode];
940
- case 'random':
941
- return node.outputs.map((o) => o.nextNode);
942
- case 'end':
943
- return [];
944
- default:
945
- return [];
946
- }
939
+ switch (node.type) {
940
+ case "start":
941
+ case "text":
942
+ case "set_variable":
943
+ case "event":
944
+ return [node.nextNode];
945
+ case "choice":
946
+ return node.options.map((o) => o.nextNode);
947
+ case "branch":
948
+ case "check_variable":
949
+ return [node.trueNode, node.falseNode];
950
+ case "random":
951
+ return node.outputs.map((o) => o.nextNode);
952
+ case "end":
953
+ return [];
954
+ default:
955
+ return [];
956
+ }
947
957
  }
948
- /**
949
- * Extract all translatable strings from a dialogue tree
950
- */
951
958
  function extractTranslatableStrings(tree) {
952
- const nodeTexts = {};
953
- const characterNames = {};
954
- for (const node of tree.nodes) {
955
- if (node.type === 'text') {
956
- nodeTexts[node.id] = node.text;
959
+ const nodeTexts = {};
960
+ const characterNames = {};
961
+ for (const node of tree.nodes) {
962
+ if (node.type === "text") {
963
+ nodeTexts[node.id] = node.text;
964
+ } else if (node.type === "choice") {
965
+ const choiceNode = node;
966
+ if (choiceNode.prompt) {
967
+ nodeTexts[`${node.id}_prompt`] = choiceNode.prompt;
968
+ }
969
+ for (const opt of choiceNode.options) {
970
+ nodeTexts[`${node.id}_${opt.id}`] = opt.text;
971
+ if (opt.tooltip) {
972
+ nodeTexts[`${node.id}_${opt.id}_tooltip`] = opt.tooltip;
957
973
  }
958
- else if (node.type === 'choice') {
959
- const choiceNode = node;
960
- if (choiceNode.prompt) {
961
- nodeTexts[`${node.id}_prompt`] = choiceNode.prompt;
962
- }
963
- for (const opt of choiceNode.options) {
964
- nodeTexts[`${node.id}_${opt.id}`] = opt.text;
965
- if (opt.tooltip) {
966
- nodeTexts[`${node.id}_${opt.id}_tooltip`] = opt.tooltip;
967
- }
968
- }
969
- }
970
- }
971
- for (const char of tree.characters) {
972
- characterNames[char.id] = char.displayName;
974
+ }
973
975
  }
974
- return { nodeTexts, characterNames };
976
+ }
977
+ for (const char of tree.characters) {
978
+ characterNames[char.id] = char.displayName;
979
+ }
980
+ return { nodeTexts, characterNames };
975
981
  }
976
- /**
977
- * Apply localization to a dialogue tree (creates a copy)
978
- */
979
982
  function applyLocalization(tree, localization) {
980
- const localized = JSON.parse(JSON.stringify(tree));
981
- localized.metadata.locale = localization.locale;
982
- for (const node of localized.nodes) {
983
- if (node.type === 'text' && localization.texts[node.id]) {
984
- node.text = localization.texts[node.id];
983
+ const localized = JSON.parse(JSON.stringify(tree));
984
+ localized.metadata.locale = localization.locale;
985
+ for (const node of localized.nodes) {
986
+ if (node.type === "text" && localization.texts[node.id]) {
987
+ node.text = localization.texts[node.id];
988
+ } else if (node.type === "choice") {
989
+ const choiceNode = node;
990
+ if (localization.texts[`${node.id}_prompt`]) {
991
+ choiceNode.prompt = localization.texts[`${node.id}_prompt`];
992
+ }
993
+ for (const opt of choiceNode.options) {
994
+ if (localization.texts[`${node.id}_${opt.id}`]) {
995
+ opt.text = localization.texts[`${node.id}_${opt.id}`];
985
996
  }
986
- else if (node.type === 'choice') {
987
- const choiceNode = node;
988
- if (localization.texts[`${node.id}_prompt`]) {
989
- choiceNode.prompt = localization.texts[`${node.id}_prompt`];
990
- }
991
- for (const opt of choiceNode.options) {
992
- if (localization.texts[`${node.id}_${opt.id}`]) {
993
- opt.text = localization.texts[`${node.id}_${opt.id}`];
994
- }
995
- if (localization.texts[`${node.id}_${opt.id}_tooltip`]) {
996
- opt.tooltip = localization.texts[`${node.id}_${opt.id}_tooltip`];
997
- }
998
- }
997
+ if (localization.texts[`${node.id}_${opt.id}_tooltip`]) {
998
+ opt.tooltip = localization.texts[`${node.id}_${opt.id}_tooltip`];
999
999
  }
1000
+ }
1000
1001
  }
1001
- for (const char of localized.characters) {
1002
- if (localization.characterNames[char.id]) {
1003
- char.displayName = localization.characterNames[char.id];
1004
- }
1002
+ }
1003
+ for (const char of localized.characters) {
1004
+ if (localization.characterNames[char.id]) {
1005
+ char.displayName = localization.characterNames[char.id];
1005
1006
  }
1006
- return localized;
1007
+ }
1008
+ return localized;
1007
1009
  }
1008
- /* ═══════════════════════════════════════════════════════════════
1009
- DEFAULT EXPORTS
1010
- ══════════════════════════════════════════════════════════════════ */
1011
- const DEFAULT_TEXT_SPEED = 50; // characters per second
1010
+ const DEFAULT_TEXT_SPEED = 50;
1012
1011
  const EMOTION_COLORS = {
1013
- neutral: '#9e9e9e',
1014
- happy: '#4caf50',
1015
- sad: '#2196f3',
1016
- angry: '#f44336',
1017
- surprised: '#ff9800',
1018
- scared: '#9c27b0',
1019
- disgusted: '#795548',
1020
- confused: '#607d8b',
1021
- thoughtful: '#3f51b5',
1022
- excited: '#ffeb3b',
1023
- tired: '#455a64',
1024
- love: '#e91e63',
1025
- custom: '#ffffff',
1012
+ neutral: "#9e9e9e",
1013
+ happy: "#4caf50",
1014
+ sad: "#2196f3",
1015
+ angry: "#f44336",
1016
+ surprised: "#ff9800",
1017
+ scared: "#9c27b0",
1018
+ disgusted: "#795548",
1019
+ confused: "#607d8b",
1020
+ thoughtful: "#3f51b5",
1021
+ excited: "#ffeb3b",
1022
+ tired: "#455a64",
1023
+ love: "#e91e63",
1024
+ custom: "#ffffff"
1026
1025
  };
1027
1026
  function createEmptyDialogueTree(id, name) {
1028
- return new DialogueTreeBuilder(id, name).addStart('main', null).addEnd('success').build();
1027
+ return new DialogueTreeBuilder(id, name).addStart("main", null).addEnd("success").build();
1029
1028
  }
1030
-
1031
- export { ChoiceList, DEFAULT_TEXT_SPEED, DialogueBox, DialogueEngine, DialogueTreeBuilder, EMOTION_COLORS, applyLocalization, createEmptyDialogueTree, deserializeDialogueTree, extractTranslatableStrings, findUnreachableNodes, serializeDialogueTree, useTypewriter, validateDialogueTree };
1029
+ export {
1030
+ ChoiceList,
1031
+ DEFAULT_TEXT_SPEED,
1032
+ DialogueBox,
1033
+ DialogueEngine,
1034
+ DialogueTreeBuilder,
1035
+ EMOTION_COLORS,
1036
+ applyLocalization,
1037
+ createEmptyDialogueTree,
1038
+ deserializeDialogueTree,
1039
+ extractTranslatableStrings,
1040
+ findUnreachableNodes,
1041
+ serializeDialogueTree,
1042
+ useTypewriter,
1043
+ validateDialogueTree
1044
+ };