@nice2dev/game-engine 1.3.14 → 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 +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,673 +1,663 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
-
5
- /* ────────────────────────────────────────────────────────────────
6
- Gameplay Analytics — Telemetry, heatmaps & session recording
7
-
8
- Comprehensive gameplay analytics with:
9
- - Event-based telemetry pipeline with batching
10
- - Spatial heatmaps (death, traversal, interaction, combat)
11
- - Session recording and playback
12
- - Funnel analysis and retention tracking
13
- - Performance metrics collection
14
- ──────────────────────────────────────────────────────────────── */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
15
4
  const DEFAULT_TELEMETRY_CONFIG = {
16
- enabled: true,
17
- batchSize: 50,
18
- flushIntervalMs: 30000,
19
- maxBufferSize: 10000,
20
- categories: [],
21
- sampleRate: 1,
5
+ enabled: true,
6
+ batchSize: 50,
7
+ flushIntervalMs: 3e4,
8
+ maxBufferSize: 1e4,
9
+ categories: [],
10
+ sampleRate: 1
22
11
  };
23
12
  const DEFAULT_HEATMAP_CONFIG = {
24
- type: 'death',
25
- cellSize: 1,
26
- bounds: { minX: -50, minY: -50, maxX: 50, maxY: 50 },
27
- colorStops: [
28
- { value: 0, color: 'rgba(0, 0, 255, 0)' },
29
- { value: 0.25, color: 'rgba(0, 0, 255, 0.5)' },
30
- { value: 0.5, color: 'rgba(0, 255, 0, 0.7)' },
31
- { value: 0.75, color: 'rgba(255, 255, 0, 0.8)' },
32
- { value: 1, color: 'rgba(255, 0, 0, 1)' },
33
- ],
34
- maxValue: 0,
35
- blurRadius: 1,
13
+ type: "death",
14
+ cellSize: 1,
15
+ bounds: { minX: -50, minY: -50, maxX: 50, maxY: 50 },
16
+ colorStops: [
17
+ { value: 0, color: "rgba(0, 0, 255, 0)" },
18
+ { value: 0.25, color: "rgba(0, 0, 255, 0.5)" },
19
+ { value: 0.5, color: "rgba(0, 255, 0, 0.7)" },
20
+ { value: 0.75, color: "rgba(255, 255, 0, 0.8)" },
21
+ { value: 1, color: "rgba(255, 0, 0, 1)" }
22
+ ],
23
+ maxValue: 0,
24
+ blurRadius: 1
36
25
  };
37
26
  const DEFAULT_RECORDING_CONFIG = {
38
- enabled: false,
39
- fps: 10,
40
- maxDurationMs: 600000, // 10 minutes
41
- recordTypes: ['position', 'action', 'state-change'],
42
- recordPosition: true,
43
- compress: true,
27
+ enabled: false,
28
+ fps: 10,
29
+ maxDurationMs: 6e5,
30
+ // 10 minutes
31
+ recordTypes: ["position", "action", "state-change"],
32
+ recordPosition: true,
33
+ compress: true
44
34
  };
45
- /* ══════════════════════════════════════════════════════════════
46
- TELEMETRY PIPELINE
47
- ══════════════════════════════════════════════════════════════ */
48
35
  class TelemetryPipeline {
49
- constructor(eventBus, config = {}) {
50
- this.buffer = [];
51
- this.flushed = [];
52
- this.flushTimer = null;
53
- this.eventCounter = 0;
54
- this.config = { ...DEFAULT_TELEMETRY_CONFIG, ...config };
55
- this.eventBus = eventBus;
56
- this.sessionId = this.generateId();
57
- if (this.config.enabled) {
58
- this.startFlushTimer();
59
- }
60
- }
61
- generateId() {
62
- return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
63
- }
64
- /** Track a telemetry event */
65
- track(category, name, data = {}, position) {
66
- if (!this.config.enabled) {
67
- return;
68
- }
69
- if (this.config.categories.length > 0 && !this.config.categories.includes(category)) {
70
- return;
71
- }
72
- if (this.config.sampleRate < 1 && Math.random() > this.config.sampleRate) {
73
- return;
74
- }
75
- const event = {
76
- id: `evt-${++this.eventCounter}`,
77
- category,
78
- name,
79
- timestamp: Date.now(),
80
- sessionId: this.sessionId,
81
- data,
82
- position,
83
- };
84
- this.buffer.push(event);
85
- if (this.buffer.length >= this.config.batchSize) {
86
- this.flush();
87
- }
88
- // Trim buffer if too large
89
- if (this.buffer.length > this.config.maxBufferSize) {
90
- this.buffer = this.buffer.slice(-this.config.maxBufferSize);
91
- }
92
- }
93
- /** Flush buffered events */
94
- flush() {
95
- if (this.buffer.length === 0) {
96
- return [];
97
- }
98
- const batch = [...this.buffer];
99
- this.buffer = [];
100
- this.flushed.push(batch);
101
- this.eventBus.emit('analytics:flush', { count: batch.length });
102
- return batch;
103
- }
104
- startFlushTimer() {
105
- this.flushTimer = setInterval(() => this.flush(), this.config.flushIntervalMs);
106
- }
107
- /** Get all events (current buffer + flushed) */
108
- getAllEvents() {
109
- return [...this.flushed.flat(), ...this.buffer];
110
- }
111
- /** Get events by category */
112
- getByCategory(category) {
113
- return this.getAllEvents().filter((e) => e.category === category);
114
- }
115
- /** Get event count by name */
116
- countByName(name) {
117
- return this.getAllEvents().filter((e) => e.name === name).length;
118
- }
119
- getSessionId() {
120
- return this.sessionId;
121
- }
122
- getBufferSize() {
123
- return this.buffer.length;
124
- }
125
- getTotalEvents() {
126
- return this.flushed.reduce((s, b) => s + b.length, 0) + this.buffer.length;
127
- }
128
- clear() {
129
- this.buffer = [];
130
- this.flushed = [];
131
- this.eventCounter = 0;
132
- }
133
- destroy() {
134
- if (this.flushTimer) {
135
- clearInterval(this.flushTimer);
136
- }
137
- this.flush();
138
- }
36
+ constructor(eventBus, config = {}) {
37
+ this.buffer = [];
38
+ this.flushed = [];
39
+ this.flushTimer = null;
40
+ this.eventCounter = 0;
41
+ this.config = { ...DEFAULT_TELEMETRY_CONFIG, ...config };
42
+ this.eventBus = eventBus;
43
+ this.sessionId = this.generateId();
44
+ if (this.config.enabled) {
45
+ this.startFlushTimer();
46
+ }
47
+ }
48
+ generateId() {
49
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
50
+ }
51
+ /** Track a telemetry event */
52
+ track(category, name, data = {}, position) {
53
+ if (!this.config.enabled) {
54
+ return;
55
+ }
56
+ if (this.config.categories.length > 0 && !this.config.categories.includes(category)) {
57
+ return;
58
+ }
59
+ if (this.config.sampleRate < 1 && Math.random() > this.config.sampleRate) {
60
+ return;
61
+ }
62
+ const event = {
63
+ id: `evt-${++this.eventCounter}`,
64
+ category,
65
+ name,
66
+ timestamp: Date.now(),
67
+ sessionId: this.sessionId,
68
+ data,
69
+ position
70
+ };
71
+ this.buffer.push(event);
72
+ if (this.buffer.length >= this.config.batchSize) {
73
+ this.flush();
74
+ }
75
+ if (this.buffer.length > this.config.maxBufferSize) {
76
+ this.buffer = this.buffer.slice(-this.config.maxBufferSize);
77
+ }
78
+ }
79
+ /** Flush buffered events */
80
+ flush() {
81
+ if (this.buffer.length === 0) {
82
+ return [];
83
+ }
84
+ const batch = [...this.buffer];
85
+ this.buffer = [];
86
+ this.flushed.push(batch);
87
+ this.eventBus.emit("analytics:flush", { count: batch.length });
88
+ return batch;
89
+ }
90
+ startFlushTimer() {
91
+ this.flushTimer = setInterval(() => this.flush(), this.config.flushIntervalMs);
92
+ }
93
+ /** Get all events (current buffer + flushed) */
94
+ getAllEvents() {
95
+ return [...this.flushed.flat(), ...this.buffer];
96
+ }
97
+ /** Get events by category */
98
+ getByCategory(category) {
99
+ return this.getAllEvents().filter((e) => e.category === category);
100
+ }
101
+ /** Get event count by name */
102
+ countByName(name) {
103
+ return this.getAllEvents().filter((e) => e.name === name).length;
104
+ }
105
+ getSessionId() {
106
+ return this.sessionId;
107
+ }
108
+ getBufferSize() {
109
+ return this.buffer.length;
110
+ }
111
+ getTotalEvents() {
112
+ return this.flushed.reduce((s, b) => s + b.length, 0) + this.buffer.length;
113
+ }
114
+ clear() {
115
+ this.buffer = [];
116
+ this.flushed = [];
117
+ this.eventCounter = 0;
118
+ }
119
+ destroy() {
120
+ if (this.flushTimer) {
121
+ clearInterval(this.flushTimer);
122
+ }
123
+ this.flush();
124
+ }
139
125
  }
140
- /* ══════════════════════════════════════════════════════════════
141
- HEATMAP GENERATOR
142
- ══════════════════════════════════════════════════════════════ */
143
126
  class HeatmapGenerator {
144
- constructor(config = {}) {
145
- this.grid = new Map();
146
- this.totalEvents = 0;
147
- this.config = { ...DEFAULT_HEATMAP_CONFIG, ...config };
148
- }
149
- cellKey(cx, cy) {
150
- return `${cx},${cy}`;
151
- }
152
- worldToCell(wx, wy) {
153
- return [
154
- Math.floor((wx - this.config.bounds.minX) / this.config.cellSize),
155
- Math.floor((wy - this.config.bounds.minY) / this.config.cellSize),
156
- ];
157
- }
158
- /** Add an event at a world position */
159
- addEvent(x, y, weight = 1) {
160
- if (x < this.config.bounds.minX ||
161
- x > this.config.bounds.maxX ||
162
- y < this.config.bounds.minY ||
163
- y > this.config.bounds.maxY) {
164
- return;
165
- }
166
- const [cx, cy] = this.worldToCell(x, y);
167
- const key = this.cellKey(cx, cy);
168
- this.grid.set(key, (this.grid.get(key) ?? 0) + weight);
169
- this.totalEvents++;
170
- }
171
- /** Add events from telemetry data */
172
- addFromTelemetry(events) {
173
- for (const event of events) {
174
- if (event.position) {
175
- this.addEvent(event.position.x, event.position.y);
176
- }
177
- }
178
- }
179
- /** Get the grid as an array of cells with normalized values */
180
- getCells() {
181
- const cells = [];
182
- let maxVal = this.config.maxValue;
183
- if (maxVal <= 0) {
184
- // Auto-detect max value
185
- maxVal = 0;
186
- for (const v of this.grid.values()) {
187
- if (v > maxVal) {
188
- maxVal = v;
189
- }
127
+ constructor(config = {}) {
128
+ this.grid = /* @__PURE__ */ new Map();
129
+ this.totalEvents = 0;
130
+ this.config = { ...DEFAULT_HEATMAP_CONFIG, ...config };
131
+ }
132
+ cellKey(cx, cy) {
133
+ return `${cx},${cy}`;
134
+ }
135
+ worldToCell(wx, wy) {
136
+ return [
137
+ Math.floor((wx - this.config.bounds.minX) / this.config.cellSize),
138
+ Math.floor((wy - this.config.bounds.minY) / this.config.cellSize)
139
+ ];
140
+ }
141
+ /** Add an event at a world position */
142
+ addEvent(x, y, weight = 1) {
143
+ if (x < this.config.bounds.minX || x > this.config.bounds.maxX || y < this.config.bounds.minY || y > this.config.bounds.maxY) {
144
+ return;
145
+ }
146
+ const [cx, cy] = this.worldToCell(x, y);
147
+ const key = this.cellKey(cx, cy);
148
+ this.grid.set(key, (this.grid.get(key) ?? 0) + weight);
149
+ this.totalEvents++;
150
+ }
151
+ /** Add events from telemetry data */
152
+ addFromTelemetry(events) {
153
+ for (const event of events) {
154
+ if (event.position) {
155
+ this.addEvent(event.position.x, event.position.y);
156
+ }
157
+ }
158
+ }
159
+ /** Get the grid as an array of cells with normalized values */
160
+ getCells() {
161
+ const cells = [];
162
+ let maxVal = this.config.maxValue;
163
+ if (maxVal <= 0) {
164
+ maxVal = 0;
165
+ for (const v of this.grid.values()) {
166
+ if (v > maxVal) {
167
+ maxVal = v;
168
+ }
169
+ }
170
+ }
171
+ if (maxVal === 0) {
172
+ maxVal = 1;
173
+ }
174
+ for (const [key, value] of this.grid) {
175
+ const [cx, cy] = key.split(",").map(Number);
176
+ cells.push({
177
+ x: cx,
178
+ y: cy,
179
+ value: Math.min(value / maxVal, 1),
180
+ events: value
181
+ });
182
+ }
183
+ return cells;
184
+ }
185
+ /** Apply Gaussian blur to the grid */
186
+ getBlurredCells() {
187
+ const cells = this.getCells();
188
+ if (this.config.blurRadius <= 0) {
189
+ return cells;
190
+ }
191
+ const radius = this.config.blurRadius;
192
+ const cellMap = /* @__PURE__ */ new Map();
193
+ for (const cell of cells) {
194
+ cellMap.set(this.cellKey(cell.x, cell.y), cell.events);
195
+ }
196
+ const blurred = [];
197
+ const sigma = radius / 2;
198
+ const kernel = [];
199
+ for (let dy = -radius; dy <= radius; dy++) {
200
+ const row = [];
201
+ for (let dx = -radius; dx <= radius; dx++) {
202
+ row.push(Math.exp(-(dx * dx + dy * dy) / (2 * sigma * sigma)));
203
+ }
204
+ kernel.push(row);
205
+ }
206
+ let kernelSum = 0;
207
+ for (const row of kernel) {
208
+ for (const v of row) {
209
+ kernelSum += v;
210
+ }
211
+ }
212
+ const visited = /* @__PURE__ */ new Set();
213
+ for (const cell of cells) {
214
+ for (let dy = -radius; dy <= radius; dy++) {
215
+ for (let dx = -radius; dx <= radius; dx++) {
216
+ const nx = cell.x + dx;
217
+ const ny = cell.y + dy;
218
+ const key = this.cellKey(nx, ny);
219
+ if (visited.has(key)) {
220
+ continue;
221
+ }
222
+ visited.add(key);
223
+ let sum = 0;
224
+ for (let ky = -radius; ky <= radius; ky++) {
225
+ for (let kx = -radius; kx <= radius; kx++) {
226
+ const srcKey = this.cellKey(nx + kx, ny + ky);
227
+ const srcVal = cellMap.get(srcKey) ?? 0;
228
+ sum += srcVal * kernel[ky + radius][kx + radius];
190
229
  }
191
- }
192
- if (maxVal === 0) {
193
- maxVal = 1;
194
- }
195
- for (const [key, value] of this.grid) {
196
- const [cx, cy] = key.split(',').map(Number);
197
- cells.push({
198
- x: cx,
199
- y: cy,
200
- value: Math.min(value / maxVal, 1),
201
- events: value,
202
- });
203
- }
204
- return cells;
205
- }
206
- /** Apply Gaussian blur to the grid */
207
- getBlurredCells() {
208
- const cells = this.getCells();
209
- if (this.config.blurRadius <= 0) {
210
- return cells;
211
- }
212
- const radius = this.config.blurRadius;
213
- const cellMap = new Map();
214
- // Build raw map
215
- for (const cell of cells) {
216
- cellMap.set(this.cellKey(cell.x, cell.y), cell.events);
217
- }
218
- // Apply blur
219
- const blurred = [];
220
- const sigma = radius / 2;
221
- const kernel = [];
222
- for (let dy = -radius; dy <= radius; dy++) {
223
- const row = [];
224
- for (let dx = -radius; dx <= radius; dx++) {
225
- row.push(Math.exp(-(dx * dx + dy * dy) / (2 * sigma * sigma)));
226
- }
227
- kernel.push(row);
228
- }
229
- // Normalize kernel
230
- let kernelSum = 0;
231
- for (const row of kernel) {
232
- for (const v of row) {
233
- kernelSum += v;
234
- }
235
- }
236
- const visited = new Set();
237
- for (const cell of cells) {
238
- for (let dy = -radius; dy <= radius; dy++) {
239
- for (let dx = -radius; dx <= radius; dx++) {
240
- const nx = cell.x + dx;
241
- const ny = cell.y + dy;
242
- const key = this.cellKey(nx, ny);
243
- if (visited.has(key)) {
244
- continue;
245
- }
246
- visited.add(key);
247
- let sum = 0;
248
- for (let ky = -radius; ky <= radius; ky++) {
249
- for (let kx = -radius; kx <= radius; kx++) {
250
- const srcKey = this.cellKey(nx + kx, ny + ky);
251
- const srcVal = cellMap.get(srcKey) ?? 0;
252
- sum += srcVal * kernel[ky + radius][kx + radius];
253
- }
254
- }
255
- const normalized = sum / kernelSum;
256
- if (normalized > 0.001) {
257
- blurred.push({ x: nx, y: ny, value: 0, events: normalized });
258
- }
259
- }
260
- }
261
- }
262
- // Normalize values
263
- let maxVal = this.config.maxValue;
264
- if (maxVal <= 0) {
265
- maxVal = Math.max(...blurred.map((c) => c.events), 1);
266
- }
267
- for (const cell of blurred) {
268
- cell.value = Math.min(cell.events / maxVal, 1);
269
- }
270
- return blurred;
271
- }
272
- /** Render heatmap to a canvas */
273
- renderToCanvas(ctx, width, height) {
274
- const cells = this.getBlurredCells();
275
- const { bounds, cellSize, colorStops } = this.config;
276
- const worldW = bounds.maxX - bounds.minX;
277
- const worldH = bounds.maxY - bounds.minY;
278
- const scaleX = width / worldW;
279
- const scaleY = height / worldH;
280
- const cellW = cellSize * scaleX;
281
- const cellH = cellSize * scaleY;
282
- ctx.clearRect(0, 0, width, height);
283
- for (const cell of cells) {
284
- const screenX = cell.x * cellSize * scaleX;
285
- const screenY = cell.y * cellSize * scaleY;
286
- // Interpolate color from stops
287
- const color = this.interpolateColor(cell.value, colorStops);
288
- ctx.fillStyle = color;
289
- ctx.fillRect(screenX, screenY, cellW + 1, cellH + 1);
290
- }
291
- }
292
- interpolateColor(value, stops) {
293
- if (stops.length === 0) {
294
- return 'transparent';
295
- }
296
- if (stops.length === 1) {
297
- return stops[0].color;
298
- }
299
- for (let i = 0; i < stops.length - 1; i++) {
300
- if (value >= stops[i].value && value <= stops[i + 1].value) {
301
- const t = (value - stops[i].value) / (stops[i + 1].value - stops[i].value);
302
- return this.lerpColor(stops[i].color, stops[i + 1].color, t);
303
- }
304
- }
305
- return stops[stops.length - 1].color;
306
- }
307
- lerpColor(a, b, t) {
308
- const parse = (c) => {
309
- const m = c.match(/[\d.]+/g);
310
- return m ? m.map(Number) : [0, 0, 0, 1];
311
- };
312
- const ca = parse(a);
313
- const cb = parse(b);
314
- const r = Math.round(ca[0] + (cb[0] - ca[0]) * t);
315
- const g = Math.round(ca[1] + (cb[1] - ca[1]) * t);
316
- const bl = Math.round(ca[2] + (cb[2] - ca[2]) * t);
317
- const al = ca[3] + (cb[3] - ca[3]) * t;
318
- return `rgba(${r}, ${g}, ${bl}, ${al.toFixed(2)})`;
319
- }
320
- getTotalEvents() {
321
- return this.totalEvents;
322
- }
323
- getConfig() {
324
- return this.config;
325
- }
326
- clear() {
327
- this.grid.clear();
328
- this.totalEvents = 0;
329
- }
230
+ }
231
+ const normalized = sum / kernelSum;
232
+ if (normalized > 1e-3) {
233
+ blurred.push({ x: nx, y: ny, value: 0, events: normalized });
234
+ }
235
+ }
236
+ }
237
+ }
238
+ let maxVal = this.config.maxValue;
239
+ if (maxVal <= 0) {
240
+ maxVal = Math.max(...blurred.map((c) => c.events), 1);
241
+ }
242
+ for (const cell of blurred) {
243
+ cell.value = Math.min(cell.events / maxVal, 1);
244
+ }
245
+ return blurred;
246
+ }
247
+ /** Render heatmap to a canvas */
248
+ renderToCanvas(ctx, width, height) {
249
+ const cells = this.getBlurredCells();
250
+ const { bounds, cellSize, colorStops } = this.config;
251
+ const worldW = bounds.maxX - bounds.minX;
252
+ const worldH = bounds.maxY - bounds.minY;
253
+ const scaleX = width / worldW;
254
+ const scaleY = height / worldH;
255
+ const cellW = cellSize * scaleX;
256
+ const cellH = cellSize * scaleY;
257
+ ctx.clearRect(0, 0, width, height);
258
+ for (const cell of cells) {
259
+ const screenX = cell.x * cellSize * scaleX;
260
+ const screenY = cell.y * cellSize * scaleY;
261
+ const color = this.interpolateColor(cell.value, colorStops);
262
+ ctx.fillStyle = color;
263
+ ctx.fillRect(screenX, screenY, cellW + 1, cellH + 1);
264
+ }
265
+ }
266
+ interpolateColor(value, stops) {
267
+ if (stops.length === 0) {
268
+ return "transparent";
269
+ }
270
+ if (stops.length === 1) {
271
+ return stops[0].color;
272
+ }
273
+ for (let i = 0; i < stops.length - 1; i++) {
274
+ if (value >= stops[i].value && value <= stops[i + 1].value) {
275
+ const t = (value - stops[i].value) / (stops[i + 1].value - stops[i].value);
276
+ return this.lerpColor(stops[i].color, stops[i + 1].color, t);
277
+ }
278
+ }
279
+ return stops[stops.length - 1].color;
280
+ }
281
+ lerpColor(a, b, t) {
282
+ const parse = (c) => {
283
+ const m = c.match(/[\d.]+/g);
284
+ return m ? m.map(Number) : [0, 0, 0, 1];
285
+ };
286
+ const ca = parse(a);
287
+ const cb = parse(b);
288
+ const r = Math.round(ca[0] + (cb[0] - ca[0]) * t);
289
+ const g = Math.round(ca[1] + (cb[1] - ca[1]) * t);
290
+ const bl = Math.round(ca[2] + (cb[2] - ca[2]) * t);
291
+ const al = ca[3] + (cb[3] - ca[3]) * t;
292
+ return `rgba(${r}, ${g}, ${bl}, ${al.toFixed(2)})`;
293
+ }
294
+ getTotalEvents() {
295
+ return this.totalEvents;
296
+ }
297
+ getConfig() {
298
+ return this.config;
299
+ }
300
+ clear() {
301
+ this.grid.clear();
302
+ this.totalEvents = 0;
303
+ }
330
304
  }
331
- /* ══════════════════════════════════════════════════════════════
332
- SESSION RECORDER
333
- ══════════════════════════════════════════════════════════════ */
334
305
  class SessionRecorder {
335
- constructor(config = {}) {
336
- this.recording = false;
337
- this.frames = [];
338
- this.startedAt = 0;
339
- this.lastFrameTime = 0;
340
- this.pendingEvents = [];
341
- this.recordTimer = null;
342
- this.config = { ...DEFAULT_RECORDING_CONFIG, ...config };
343
- this.sessionId = `sess-${Date.now().toString(36)}`;
344
- }
345
- /** Start recording */
346
- start() {
347
- if (this.recording) {
348
- return;
349
- }
350
- this.recording = true;
351
- this.startedAt = Date.now();
352
- this.lastFrameTime = this.startedAt;
353
- this.frames = [];
354
- const intervalMs = 1000 / this.config.fps;
355
- this.recordTimer = setInterval(() => this.captureFrame(), intervalMs);
356
- }
357
- /** Stop recording and return the session */
358
- stop(sceneId = 'unknown', buildVersion = '0.0.0') {
359
- this.recording = false;
360
- if (this.recordTimer) {
361
- clearInterval(this.recordTimer);
362
- this.recordTimer = null;
363
- }
364
- // Capture any remaining events
365
- if (this.pendingEvents.length > 0) {
366
- this.captureFrame();
367
- }
368
- const endedAt = Date.now();
369
- const recording = {
370
- id: `rec-${Date.now().toString(36)}`,
371
- sessionId: this.sessionId,
372
- startedAt: this.startedAt,
373
- endedAt,
374
- durationMs: endedAt - this.startedAt,
375
- frameCount: this.frames.length,
376
- frames: this.frames,
377
- metadata: { sceneId, buildVersion, tags: [] },
378
- sizeBytes: 0,
379
- };
380
- // Estimate size
381
- recording.sizeBytes = JSON.stringify(recording.frames).length;
382
- return recording;
383
- }
384
- /** Add an event to the current frame batch */
385
- recordEvent(type, data) {
386
- if (!this.recording) {
387
- return;
388
- }
389
- if (this.config.recordTypes.length > 0 && !this.config.recordTypes.includes(type)) {
390
- return;
391
- }
392
- this.pendingEvents.push({ type, data });
393
- }
394
- /** Record player position (convenience) */
395
- recordPosition(x, y, z) {
396
- if (!this.config.recordPosition) {
397
- return;
398
- }
399
- this.recordEvent('position', { x, y, z });
400
- }
401
- captureFrame() {
402
- const now = Date.now();
403
- // Check max duration
404
- if (this.config.maxDurationMs > 0 && now - this.startedAt > this.config.maxDurationMs) {
405
- this.stop();
406
- return;
407
- }
408
- const frame = {
409
- timestamp: now,
410
- delta: now - this.lastFrameTime,
411
- events: [...this.pendingEvents],
412
- };
413
- this.frames.push(frame);
414
- this.pendingEvents = [];
415
- this.lastFrameTime = now;
416
- }
417
- isRecording() {
418
- return this.recording;
419
- }
420
- getFrameCount() {
421
- return this.frames.length;
422
- }
423
- getDurationMs() {
424
- return this.recording ? Date.now() - this.startedAt : 0;
425
- }
306
+ constructor(config = {}) {
307
+ this.recording = false;
308
+ this.frames = [];
309
+ this.startedAt = 0;
310
+ this.lastFrameTime = 0;
311
+ this.pendingEvents = [];
312
+ this.recordTimer = null;
313
+ this.config = { ...DEFAULT_RECORDING_CONFIG, ...config };
314
+ this.sessionId = `sess-${Date.now().toString(36)}`;
315
+ }
316
+ /** Start recording */
317
+ start() {
318
+ if (this.recording) {
319
+ return;
320
+ }
321
+ this.recording = true;
322
+ this.startedAt = Date.now();
323
+ this.lastFrameTime = this.startedAt;
324
+ this.frames = [];
325
+ const intervalMs = 1e3 / this.config.fps;
326
+ this.recordTimer = setInterval(() => this.captureFrame(), intervalMs);
327
+ }
328
+ /** Stop recording and return the session */
329
+ stop(sceneId = "unknown", buildVersion = "0.0.0") {
330
+ this.recording = false;
331
+ if (this.recordTimer) {
332
+ clearInterval(this.recordTimer);
333
+ this.recordTimer = null;
334
+ }
335
+ if (this.pendingEvents.length > 0) {
336
+ this.captureFrame();
337
+ }
338
+ const endedAt = Date.now();
339
+ const recording = {
340
+ id: `rec-${Date.now().toString(36)}`,
341
+ sessionId: this.sessionId,
342
+ startedAt: this.startedAt,
343
+ endedAt,
344
+ durationMs: endedAt - this.startedAt,
345
+ frameCount: this.frames.length,
346
+ frames: this.frames,
347
+ metadata: { sceneId, buildVersion, tags: [] },
348
+ sizeBytes: 0
349
+ };
350
+ recording.sizeBytes = JSON.stringify(recording.frames).length;
351
+ return recording;
352
+ }
353
+ /** Add an event to the current frame batch */
354
+ recordEvent(type, data) {
355
+ if (!this.recording) {
356
+ return;
357
+ }
358
+ if (this.config.recordTypes.length > 0 && !this.config.recordTypes.includes(type)) {
359
+ return;
360
+ }
361
+ this.pendingEvents.push({ type, data });
362
+ }
363
+ /** Record player position (convenience) */
364
+ recordPosition(x, y, z) {
365
+ if (!this.config.recordPosition) {
366
+ return;
367
+ }
368
+ this.recordEvent("position", { x, y, z });
369
+ }
370
+ captureFrame() {
371
+ const now = Date.now();
372
+ if (this.config.maxDurationMs > 0 && now - this.startedAt > this.config.maxDurationMs) {
373
+ this.stop();
374
+ return;
375
+ }
376
+ const frame = {
377
+ timestamp: now,
378
+ delta: now - this.lastFrameTime,
379
+ events: [...this.pendingEvents]
380
+ };
381
+ this.frames.push(frame);
382
+ this.pendingEvents = [];
383
+ this.lastFrameTime = now;
384
+ }
385
+ isRecording() {
386
+ return this.recording;
387
+ }
388
+ getFrameCount() {
389
+ return this.frames.length;
390
+ }
391
+ getDurationMs() {
392
+ return this.recording ? Date.now() - this.startedAt : 0;
393
+ }
426
394
  }
427
- /* ══════════════════════════════════════════════════════════════
428
- SESSION PLAYER (Playback)
429
- ══════════════════════════════════════════════════════════════ */
430
395
  class SessionPlayer {
431
- constructor() {
432
- this.recording = null;
433
- this.currentFrame = 0;
434
- this.playing = false;
435
- this.speed = 1;
436
- this.playTimer = null;
437
- this.onFrame = null;
438
- }
439
- load(recording) {
440
- this.recording = recording;
441
- this.currentFrame = 0;
442
- this.stop();
443
- }
444
- /** Start playback */
445
- play(onFrame) {
446
- if (!this.recording || this.playing) {
447
- return;
448
- }
449
- this.playing = true;
450
- this.onFrame = onFrame;
451
- this.advanceFrame();
452
- }
453
- advanceFrame() {
454
- if (!this.recording || !this.playing || this.currentFrame >= this.recording.frames.length) {
455
- this.stop();
456
- return;
457
- }
458
- const frame = this.recording.frames[this.currentFrame];
459
- if (this.onFrame) {
460
- this.onFrame(frame, this.currentFrame);
461
- }
462
- this.currentFrame++;
463
- if (this.currentFrame < this.recording.frames.length) {
464
- const nextFrame = this.recording.frames[this.currentFrame];
465
- const delay = (nextFrame.delta || 100) / this.speed;
466
- this.playTimer = setTimeout(() => this.advanceFrame(), delay);
467
- }
468
- else {
469
- this.stop();
470
- }
471
- }
472
- stop() {
473
- this.playing = false;
474
- if (this.playTimer) {
475
- clearTimeout(this.playTimer);
476
- this.playTimer = null;
477
- }
478
- }
479
- pause() {
480
- this.playing = false;
481
- if (this.playTimer) {
482
- clearTimeout(this.playTimer);
483
- this.playTimer = null;
484
- }
485
- }
486
- seek(frameIndex) {
487
- if (!this.recording) {
488
- return;
489
- }
490
- this.currentFrame = Math.max(0, Math.min(frameIndex, this.recording.frameCount - 1));
491
- }
492
- setSpeed(speed) {
493
- this.speed = Math.max(0.1, Math.min(10, speed));
494
- }
495
- getProgress() {
496
- if (!this.recording || this.recording.frameCount === 0) {
497
- return 0;
498
- }
499
- return this.currentFrame / this.recording.frameCount;
500
- }
501
- isPlaying() {
502
- return this.playing;
503
- }
396
+ constructor() {
397
+ this.recording = null;
398
+ this.currentFrame = 0;
399
+ this.playing = false;
400
+ this.speed = 1;
401
+ this.playTimer = null;
402
+ this.onFrame = null;
403
+ }
404
+ load(recording) {
405
+ this.recording = recording;
406
+ this.currentFrame = 0;
407
+ this.stop();
408
+ }
409
+ /** Start playback */
410
+ play(onFrame) {
411
+ if (!this.recording || this.playing) {
412
+ return;
413
+ }
414
+ this.playing = true;
415
+ this.onFrame = onFrame;
416
+ this.advanceFrame();
417
+ }
418
+ advanceFrame() {
419
+ if (!this.recording || !this.playing || this.currentFrame >= this.recording.frames.length) {
420
+ this.stop();
421
+ return;
422
+ }
423
+ const frame = this.recording.frames[this.currentFrame];
424
+ if (this.onFrame) {
425
+ this.onFrame(frame, this.currentFrame);
426
+ }
427
+ this.currentFrame++;
428
+ if (this.currentFrame < this.recording.frames.length) {
429
+ const nextFrame = this.recording.frames[this.currentFrame];
430
+ const delay = (nextFrame.delta || 100) / this.speed;
431
+ this.playTimer = setTimeout(() => this.advanceFrame(), delay);
432
+ } else {
433
+ this.stop();
434
+ }
435
+ }
436
+ stop() {
437
+ this.playing = false;
438
+ if (this.playTimer) {
439
+ clearTimeout(this.playTimer);
440
+ this.playTimer = null;
441
+ }
442
+ }
443
+ pause() {
444
+ this.playing = false;
445
+ if (this.playTimer) {
446
+ clearTimeout(this.playTimer);
447
+ this.playTimer = null;
448
+ }
449
+ }
450
+ seek(frameIndex) {
451
+ if (!this.recording) {
452
+ return;
453
+ }
454
+ this.currentFrame = Math.max(0, Math.min(frameIndex, this.recording.frameCount - 1));
455
+ }
456
+ setSpeed(speed) {
457
+ this.speed = Math.max(0.1, Math.min(10, speed));
458
+ }
459
+ getProgress() {
460
+ if (!this.recording || this.recording.frameCount === 0) {
461
+ return 0;
462
+ }
463
+ return this.currentFrame / this.recording.frameCount;
464
+ }
465
+ isPlaying() {
466
+ return this.playing;
467
+ }
504
468
  }
505
- /* ══════════════════════════════════════════════════════════════
506
- FUNNEL TRACKER
507
- ══════════════════════════════════════════════════════════════ */
508
469
  class FunnelTracker {
509
- constructor() {
510
- this.funnels = new Map();
511
- this.progress = new Map(); // funnelId → stepId → sessionIds
512
- }
513
- define(funnel) {
514
- this.funnels.set(funnel.id, funnel);
515
- const stepMap = new Map();
516
- for (const step of funnel.steps) {
517
- stepMap.set(step.id, new Set());
518
- }
519
- this.progress.set(funnel.id, stepMap);
520
- }
521
- /** Record that a session reached a funnel step */
522
- recordStep(funnelId, stepEventName, sessionId) {
523
- const funnel = this.funnels.get(funnelId);
524
- if (!funnel) {
525
- return;
526
- }
527
- const step = funnel.steps.find((s) => s.eventName === stepEventName);
528
- if (!step) {
529
- return;
530
- }
531
- const stepMap = this.progress.get(funnelId);
532
- stepMap?.get(step.id)?.add(sessionId);
533
- }
534
- /** Get funnel analysis */
535
- analyze(funnelId) {
536
- const funnel = this.funnels.get(funnelId);
537
- const stepMap = this.progress.get(funnelId);
538
- if (!funnel || !stepMap) {
539
- return [];
540
- }
541
- const result = [];
542
- let prevCount = 0;
543
- for (const step of funnel.steps) {
544
- const count = stepMap.get(step.id)?.size ?? 0;
545
- const dropOff = prevCount > 0 ? 1 - count / prevCount : 0;
546
- result.push({
547
- id: step.id,
548
- name: step.name,
549
- count,
550
- dropOffRate: result.length === 0 ? 0 : dropOff,
551
- });
552
- prevCount = count;
553
- }
554
- return result;
555
- }
556
- getFunnels() {
557
- return Array.from(this.funnels.values());
558
- }
470
+ constructor() {
471
+ this.funnels = /* @__PURE__ */ new Map();
472
+ this.progress = /* @__PURE__ */ new Map();
473
+ }
474
+ // funnelId → stepId → sessionIds
475
+ define(funnel) {
476
+ this.funnels.set(funnel.id, funnel);
477
+ const stepMap = /* @__PURE__ */ new Map();
478
+ for (const step of funnel.steps) {
479
+ stepMap.set(step.id, /* @__PURE__ */ new Set());
480
+ }
481
+ this.progress.set(funnel.id, stepMap);
482
+ }
483
+ /** Record that a session reached a funnel step */
484
+ recordStep(funnelId, stepEventName, sessionId) {
485
+ const funnel = this.funnels.get(funnelId);
486
+ if (!funnel) {
487
+ return;
488
+ }
489
+ const step = funnel.steps.find((s) => s.eventName === stepEventName);
490
+ if (!step) {
491
+ return;
492
+ }
493
+ const stepMap = this.progress.get(funnelId);
494
+ stepMap?.get(step.id)?.add(sessionId);
495
+ }
496
+ /** Get funnel analysis */
497
+ analyze(funnelId) {
498
+ const funnel = this.funnels.get(funnelId);
499
+ const stepMap = this.progress.get(funnelId);
500
+ if (!funnel || !stepMap) {
501
+ return [];
502
+ }
503
+ const result = [];
504
+ let prevCount = 0;
505
+ for (const step of funnel.steps) {
506
+ const count = stepMap.get(step.id)?.size ?? 0;
507
+ const dropOff = prevCount > 0 ? 1 - count / prevCount : 0;
508
+ result.push({
509
+ id: step.id,
510
+ name: step.name,
511
+ count,
512
+ dropOffRate: result.length === 0 ? 0 : dropOff
513
+ });
514
+ prevCount = count;
515
+ }
516
+ return result;
517
+ }
518
+ getFunnels() {
519
+ return Array.from(this.funnels.values());
520
+ }
559
521
  }
560
- /* ══════════════════════════════════════════════════════════════
561
- GAMEPLAY ANALYTICS (Main class)
562
- ══════════════════════════════════════════════════════════════ */
563
522
  class GameplayAnalytics {
564
- constructor(eventBus, telemetryConfig, recordingConfig) {
565
- this.heatmaps = new Map();
566
- this.eventBus = eventBus;
567
- this.telemetry = new TelemetryPipeline(eventBus, telemetryConfig);
568
- this.recorder = new SessionRecorder(recordingConfig);
569
- this.funnels = new FunnelTracker();
570
- }
571
- /** Create or get a heatmap */
572
- heatmap(id, config) {
573
- let hm = this.heatmaps.get(id);
574
- if (!hm) {
575
- hm = new HeatmapGenerator(config);
576
- this.heatmaps.set(id, hm);
577
- }
578
- return hm;
579
- }
580
- /** Track and automatically distribute to relevant heatmaps */
581
- trackEvent(category, name, data = {}, position) {
582
- this.telemetry.track(category, name, data, position);
583
- // Auto-feed heatmaps
584
- if (position) {
585
- for (const [_, hm] of this.heatmaps) {
586
- hm.addEvent(position.x, position.y);
587
- }
588
- }
589
- // Auto-feed session recorder
590
- this.recorder.recordEvent('action', { category, name, ...data });
591
- if (position) {
592
- this.recorder.recordPosition(position.x, position.y, position.z);
593
- }
594
- // Auto-feed funnel tracker
595
- for (const funnel of this.funnels.getFunnels()) {
596
- this.funnels.recordStep(funnel.id, name, this.telemetry.getSessionId());
597
- }
598
- }
599
- /** Get summary stats */
600
- getSummary() {
601
- return {
602
- totalEvents: this.telemetry.getTotalEvents(),
603
- sessionId: this.telemetry.getSessionId(),
604
- heatmapCount: this.heatmaps.size,
605
- isRecording: this.recorder.isRecording(),
606
- recordedFrames: this.recorder.getFrameCount(),
607
- };
608
- }
609
- destroy() {
610
- this.telemetry.destroy();
611
- if (this.recorder.isRecording()) {
612
- this.recorder.stop();
613
- }
614
- this.heatmaps.clear();
615
- }
616
- }
617
- /* ══════════════════════════════════════════════════════════════
618
- REACT HOOK
619
- ══════════════════════════════════════════════════════════════ */
620
- function useGameplayAnalytics(eventBus, telemetryConfig, recordingConfig) {
621
- const analyticsRef = React.useRef(null);
622
- const analytics = React.useMemo(() => {
623
- if (!analyticsRef.current) {
624
- analyticsRef.current = new GameplayAnalytics(eventBus, telemetryConfig, recordingConfig);
625
- }
626
- return analyticsRef.current;
627
- // eslint-disable-next-line react-hooks/exhaustive-deps -- the configs are read once, when the instance is made (it has no setters for them)
628
- }, [eventBus]);
629
- React.useEffect(() => {
630
- return () => {
631
- analytics.destroy();
632
- analyticsRef.current = null;
633
- };
634
- }, [analytics]);
635
- const trackEvent = React.useCallback((category, name, data, position) => analytics.trackEvent(category, name, data, position), [analytics]);
636
- const [summary, setSummary] = React.useState(analytics.getSummary());
637
- const refreshSummary = React.useCallback(() => {
638
- setSummary(analytics.getSummary());
639
- }, [analytics]);
523
+ constructor(eventBus, telemetryConfig, recordingConfig) {
524
+ this.heatmaps = /* @__PURE__ */ new Map();
525
+ this.eventBus = eventBus;
526
+ this.telemetry = new TelemetryPipeline(eventBus, telemetryConfig);
527
+ this.recorder = new SessionRecorder(recordingConfig);
528
+ this.funnels = new FunnelTracker();
529
+ }
530
+ /** Create or get a heatmap */
531
+ heatmap(id, config) {
532
+ let hm = this.heatmaps.get(id);
533
+ if (!hm) {
534
+ hm = new HeatmapGenerator(config);
535
+ this.heatmaps.set(id, hm);
536
+ }
537
+ return hm;
538
+ }
539
+ /** Track and automatically distribute to relevant heatmaps */
540
+ trackEvent(category, name, data = {}, position) {
541
+ this.telemetry.track(category, name, data, position);
542
+ if (position) {
543
+ for (const [_, hm] of this.heatmaps) {
544
+ hm.addEvent(position.x, position.y);
545
+ }
546
+ }
547
+ this.recorder.recordEvent("action", { category, name, ...data });
548
+ if (position) {
549
+ this.recorder.recordPosition(position.x, position.y, position.z);
550
+ }
551
+ for (const funnel of this.funnels.getFunnels()) {
552
+ this.funnels.recordStep(funnel.id, name, this.telemetry.getSessionId());
553
+ }
554
+ }
555
+ /** Get summary stats */
556
+ getSummary() {
640
557
  return {
641
- analytics,
642
- trackEvent,
643
- summary,
644
- refreshSummary,
645
- startRecording: () => analytics.recorder.start(),
646
- stopRecording: (sceneId) => analytics.recorder.stop(sceneId),
647
- heatmap: (id, config) => analytics.heatmap(id, config),
558
+ totalEvents: this.telemetry.getTotalEvents(),
559
+ sessionId: this.telemetry.getSessionId(),
560
+ heatmapCount: this.heatmaps.size,
561
+ isRecording: this.recorder.isRecording(),
562
+ recordedFrames: this.recorder.getFrameCount()
648
563
  };
564
+ }
565
+ destroy() {
566
+ this.telemetry.destroy();
567
+ if (this.recorder.isRecording()) {
568
+ this.recorder.stop();
569
+ }
570
+ this.heatmaps.clear();
571
+ }
649
572
  }
650
- const AnalyticsDashboard = ({ analytics, className, style, }) => {
651
- const [summary, setSummary] = React.useState(analytics.getSummary());
652
- React.useEffect(() => {
653
- const timer = setInterval(() => setSummary(analytics.getSummary()), 1000);
654
- return () => clearInterval(timer);
655
- }, [analytics]);
656
- const statStyle = {
657
- display: 'flex',
658
- justifyContent: 'space-between',
659
- padding: '4px 0',
660
- borderBottom: '1px solid rgba(128,128,128,0.2)',
573
+ function useGameplayAnalytics(eventBus, telemetryConfig, recordingConfig) {
574
+ const analyticsRef = React.useRef(null);
575
+ const analytics = React.useMemo(() => {
576
+ if (!analyticsRef.current) {
577
+ analyticsRef.current = new GameplayAnalytics(eventBus, telemetryConfig, recordingConfig);
578
+ }
579
+ return analyticsRef.current;
580
+ }, [eventBus]);
581
+ React.useEffect(() => {
582
+ return () => {
583
+ analytics.destroy();
584
+ analyticsRef.current = null;
661
585
  };
662
- return React.createElement('div', {
663
- className: `nice-analytics-dashboard ${className ?? ''}`.trim(),
664
- style: { padding: 16, fontFamily: 'monospace', fontSize: 13, ...style },
665
- }, React.createElement('h3', { style: { margin: '0 0 12px 0' } }, 'Gameplay Analytics'), React.createElement('div', { style: statStyle }, React.createElement('span', null, 'Session ID'), React.createElement('code', null, summary.sessionId)), React.createElement('div', { style: statStyle }, React.createElement('span', null, 'Total Events'), React.createElement('span', null, String(summary.totalEvents))), React.createElement('div', { style: statStyle }, React.createElement('span', null, 'Heatmaps'), React.createElement('span', null, String(summary.heatmapCount))), React.createElement('div', { style: statStyle }, React.createElement('span', null, 'Recording'), React.createElement('span', null, summary.isRecording ? `ON (${summary.recordedFrames} frames)` : 'OFF')));
586
+ }, [analytics]);
587
+ const trackEvent = React.useCallback(
588
+ (category, name, data, position) => analytics.trackEvent(category, name, data, position),
589
+ [analytics]
590
+ );
591
+ const [summary, setSummary] = React.useState(analytics.getSummary());
592
+ const refreshSummary = React.useCallback(() => {
593
+ setSummary(analytics.getSummary());
594
+ }, [analytics]);
595
+ return {
596
+ analytics,
597
+ trackEvent,
598
+ summary,
599
+ refreshSummary,
600
+ startRecording: () => analytics.recorder.start(),
601
+ stopRecording: (sceneId) => analytics.recorder.stop(sceneId),
602
+ heatmap: (id, config) => analytics.heatmap(id, config)
603
+ };
604
+ }
605
+ const AnalyticsDashboard = ({
606
+ analytics,
607
+ className,
608
+ style
609
+ }) => {
610
+ const [summary, setSummary] = React.useState(analytics.getSummary());
611
+ React.useEffect(() => {
612
+ const timer = setInterval(() => setSummary(analytics.getSummary()), 1e3);
613
+ return () => clearInterval(timer);
614
+ }, [analytics]);
615
+ const statStyle = {
616
+ display: "flex",
617
+ justifyContent: "space-between",
618
+ padding: "4px 0",
619
+ borderBottom: "1px solid rgba(128,128,128,0.2)"
620
+ };
621
+ return React.createElement(
622
+ "div",
623
+ {
624
+ className: `nice-analytics-dashboard ${className ?? ""}`.trim(),
625
+ style: { padding: 16, fontFamily: "monospace", fontSize: 13, ...style }
626
+ },
627
+ React.createElement("h3", { style: { margin: "0 0 12px 0" } }, "Gameplay Analytics"),
628
+ React.createElement(
629
+ "div",
630
+ { style: statStyle },
631
+ React.createElement("span", null, "Session ID"),
632
+ React.createElement("code", null, summary.sessionId)
633
+ ),
634
+ React.createElement(
635
+ "div",
636
+ { style: statStyle },
637
+ React.createElement("span", null, "Total Events"),
638
+ React.createElement("span", null, String(summary.totalEvents))
639
+ ),
640
+ React.createElement(
641
+ "div",
642
+ { style: statStyle },
643
+ React.createElement("span", null, "Heatmaps"),
644
+ React.createElement("span", null, String(summary.heatmapCount))
645
+ ),
646
+ React.createElement(
647
+ "div",
648
+ { style: statStyle },
649
+ React.createElement("span", null, "Recording"),
650
+ React.createElement(
651
+ "span",
652
+ null,
653
+ summary.isRecording ? `ON (${summary.recordedFrames} frames)` : "OFF"
654
+ )
655
+ )
656
+ );
666
657
  };
667
- if (process.env.NODE_ENV !== 'production') {
668
- AnalyticsDashboard.displayName = 'AnalyticsDashboard';
658
+ if (process.env.NODE_ENV !== "production") {
659
+ AnalyticsDashboard.displayName = "AnalyticsDashboard";
669
660
  }
670
-
671
661
  exports.AnalyticsDashboard = AnalyticsDashboard;
672
662
  exports.DEFAULT_HEATMAP_CONFIG = DEFAULT_HEATMAP_CONFIG;
673
663
  exports.DEFAULT_RECORDING_CONFIG = DEFAULT_RECORDING_CONFIG;