@nice2dev/game-engine 1.3.15 → 1.3.16

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