@nice2dev/game-engine 1.3.15 → 1.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1024 +1,988 @@
1
- import { TypeScriptExporter } from '../scripting/exporters/TypeScriptExporter.js';
2
- import { GraphToAST } from '../scripting/GraphToAST.js';
3
- import { PlatformExporter } from './PlatformExporter.js';
4
-
5
- /* ────────────────────────────────────────────────────────────────
6
- Web/HTML5 Platform Exporter
7
-
8
- Base exporter for web-based game engines.
9
- Generates HTML, JavaScript/TypeScript, and bundled assets.
10
- ──────────────────────────────────────────────────────────────── */
11
- /* ── PixiJS Exporter ──────────────────────────────────────────── */
1
+ import { TypeScriptExporter } from "../scripting/exporters/TypeScriptExporter.js";
2
+ import { GraphToAST } from "../scripting/GraphToAST.js";
3
+ import { PlatformExporter } from "./PlatformExporter.js";
12
4
  class PixiJSExporter extends PlatformExporter {
13
- constructor() {
14
- super(...arguments);
15
- this.platformId = 'pixijs';
16
- this.platformInfo = {
17
- id: 'pixijs',
18
- name: 'PixiJS',
19
- description: 'Fast 2D WebGL renderer',
20
- website: 'https://pixijs.com',
21
- features: ['2d-rendering', 'particles', 'animation'],
22
- supportedAssets: ['sprite', 'tileset', 'audio', 'font', 'script', 'animation'],
23
- exportFormats: ['.html', '.js', '.ts'],
24
- };
25
- this.tsExporter = new TypeScriptExporter();
26
- this.graphToAST = new GraphToAST();
5
+ constructor() {
6
+ super(...arguments);
7
+ this.platformId = "pixijs";
8
+ this.platformInfo = {
9
+ id: "pixijs",
10
+ name: "PixiJS",
11
+ description: "Fast 2D WebGL renderer",
12
+ website: "https://pixijs.com",
13
+ features: ["2d-rendering", "particles", "animation"],
14
+ supportedAssets: ["sprite", "tileset", "audio", "font", "script", "animation"],
15
+ exportFormats: [".html", ".js", ".ts"]
16
+ };
17
+ this.tsExporter = new TypeScriptExporter();
18
+ this.graphToAST = new GraphToAST();
19
+ }
20
+ async doExport(project, options) {
21
+ const web = options.platformOptions;
22
+ const useTS = web?.typescript !== false;
23
+ const bundler = web?.bundler || "vite";
24
+ this.exportPackageJson(project, web);
25
+ this.exportIndexHtml(project, options, web);
26
+ this.exportMainGame(project, options, useTS);
27
+ this.exportScenes(project, options, useTS);
28
+ await this.exportScripts(project, options, useTS);
29
+ this.exportAssetManifest(project);
30
+ if (bundler !== "none") {
31
+ this.exportBundlerConfig(project, bundler, useTS);
27
32
  }
28
- async doExport(project, options) {
29
- const web = options.platformOptions;
30
- const useTS = web?.typescript !== false;
31
- const bundler = web?.bundler || 'vite';
32
- // 1. Generate package.json
33
- this.exportPackageJson(project, web);
34
- // 2. Generate HTML entry
35
- this.exportIndexHtml(project, options, web);
36
- // 3. Generate main game file
37
- this.exportMainGame(project, options, useTS);
38
- // 4. Export scenes
39
- this.exportScenes(project, options, useTS);
40
- // 5. Export scripts
41
- await this.exportScripts(project, options, useTS);
42
- // 6. Export asset manifest
43
- this.exportAssetManifest(project);
44
- // 7. Generate bundler config
45
- if (bundler !== 'none') {
46
- this.exportBundlerConfig(project, bundler, useTS);
47
- }
48
- // 8. Generate PWA files
49
- if (web?.pwa) {
50
- this.exportPWAFiles(project);
51
- }
52
- // 9. Generate utility classes
53
- this.exportUtilities(project, useTS);
54
- // 10. Generate tsconfig if TypeScript
55
- if (useTS) {
56
- this.exportTSConfig();
57
- }
33
+ if (web?.pwa) {
34
+ this.exportPWAFiles(project);
58
35
  }
59
- exportPackageJson(project, web) {
60
- const useTS = web?.typescript !== false;
61
- const bundler = web?.bundler || 'vite';
62
- const pixiVersion = web?.frameworkVersion || '^8.0.0';
63
- const packageJson = {
64
- name: project.name.toLowerCase().replace(/\s+/g, '-'),
65
- version: project.version,
66
- description: project.description || `${project.name} - Built with Nice2Dev`,
67
- type: 'module',
68
- scripts: {
69
- dev: bundler === 'vite'
70
- ? 'vite'
71
- : bundler === 'webpack'
72
- ? 'webpack serve'
73
- : 'parcel index.html',
74
- build: bundler === 'vite'
75
- ? 'vite build'
76
- : bundler === 'webpack'
77
- ? 'webpack'
78
- : 'parcel build index.html',
79
- preview: bundler === 'vite' ? 'vite preview' : 'serve dist',
80
- },
81
- dependencies: {
82
- pixi: pixiVersion,
83
- '@pixi/sound': '^5.0.0',
84
- },
85
- devDependencies: {
86
- ...(useTS ? { typescript: '^5.0.0' } : {}),
87
- ...(bundler === 'vite' ? { vite: '^5.0.0' } : {}),
88
- ...(bundler === 'webpack'
89
- ? { webpack: '^5.0.0', 'webpack-cli': '^5.0.0', 'webpack-dev-server': '^4.0.0' }
90
- : {}),
91
- ...(bundler === 'parcel' ? { parcel: '^2.0.0' } : {}),
92
- },
93
- };
94
- this.addTextFile('package.json', JSON.stringify(packageJson, null, 2));
36
+ this.exportUtilities(project, useTS);
37
+ if (useTS) {
38
+ this.exportTSConfig();
95
39
  }
96
- exportIndexHtml(project, options, web) {
97
- const responsive = web?.responsive !== false;
98
- const { width, height } = project.settings.resolution;
99
- const html = `<!DOCTYPE html>
100
- <html lang="en">
101
- <head>
102
- <meta charset="UTF-8">
103
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
104
- <title>${project.name}</title>
105
- <style>
106
- * {
107
- margin: 0;
108
- padding: 0;
109
- box-sizing: border-box;
110
- }
111
-
112
- body {
113
- background-color: ${project.settings.backgroundColor};
114
- overflow: hidden;
115
- display: flex;
116
- justify-content: center;
117
- align-items: center;
118
- min-height: 100vh;
119
- }
120
-
121
- #game-container {
122
- ${responsive
123
- ? `
124
- width: 100%;
125
- max-width: ${width}px;
126
- aspect-ratio: ${width} / ${height};
127
- `
128
- : `
129
- width: ${width}px;
130
- height: ${height}px;
131
- `}
132
- }
133
-
134
- canvas {
135
- display: block;
136
- width: 100%;
137
- height: 100%;
138
- ${project.settings.rendering?.pixelArt ? 'image-rendering: pixelated;' : ''}
139
- }
140
- </style>
141
- </head>
142
- <body>
143
- <div id="game-container"></div>
144
- <script type="module" src="/src/main.ts"></script>
145
- </body>
146
- </html>
147
- `;
148
- this.addTextFile('index.html', html);
40
+ }
41
+ exportPackageJson(project, web) {
42
+ const useTS = web?.typescript !== false;
43
+ const bundler = web?.bundler || "vite";
44
+ const pixiVersion = web?.frameworkVersion || "^8.0.0";
45
+ const packageJson = {
46
+ name: project.name.toLowerCase().replace(/\s+/g, "-"),
47
+ version: project.version,
48
+ description: project.description || `${project.name} - Built with Nice2Dev`,
49
+ type: "module",
50
+ scripts: {
51
+ dev: bundler === "vite" ? "vite" : bundler === "webpack" ? "webpack serve" : "parcel index.html",
52
+ build: bundler === "vite" ? "vite build" : bundler === "webpack" ? "webpack" : "parcel build index.html",
53
+ preview: bundler === "vite" ? "vite preview" : "serve dist"
54
+ },
55
+ dependencies: {
56
+ pixi: pixiVersion,
57
+ "@pixi/sound": "^5.0.0"
58
+ },
59
+ devDependencies: {
60
+ ...useTS ? { typescript: "^5.0.0" } : {},
61
+ ...bundler === "vite" ? { vite: "^5.0.0" } : {},
62
+ ...bundler === "webpack" ? { webpack: "^5.0.0", "webpack-cli": "^5.0.0", "webpack-dev-server": "^4.0.0" } : {},
63
+ ...bundler === "parcel" ? { parcel: "^2.0.0" } : {}
64
+ }
65
+ };
66
+ this.addTextFile("package.json", JSON.stringify(packageJson, null, 2));
67
+ }
68
+ exportIndexHtml(project, options, web) {
69
+ const responsive = web?.responsive !== false;
70
+ const { width, height } = project.settings.resolution;
71
+ const html = `<!DOCTYPE html>
72
+ <html lang="en">
73
+ <head>
74
+ <meta charset="UTF-8">
75
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
76
+ <title>${project.name}</title>
77
+ <style>
78
+ * {
79
+ margin: 0;
80
+ padding: 0;
81
+ box-sizing: border-box;
149
82
  }
150
- exportMainGame(project, options, useTS) {
151
- const { width, height } = project.settings.resolution;
152
- const ext = useTS ? 'ts' : 'js';
153
- const pixelArt = project.settings.rendering?.pixelArt;
154
- const main = `import { Application, Assets } from 'pixi.js';
155
- import { sound } from '@pixi/sound';
156
- import { assetManifest } from './assets/manifest${useTS ? '' : '.js'}';
157
- import { GameManager } from './game/GameManager${useTS ? '' : '.js'}';
158
- import { loadScene } from './scenes/index${useTS ? '' : '.js'}';
159
-
160
- ${useTS
161
- ? `
162
- interface GameConfig {
163
- width: number;
164
- height: number;
165
- backgroundColor: number;
166
- }
167
- `
168
- : ''}
169
-
170
- class Game {
171
- ${useTS ? 'private app: Application;' : ''}
172
- ${useTS ? 'private gameManager: GameManager;' : ''}
173
-
174
- async init()${useTS ? ': Promise<void>' : ''} {
175
- // Create PixiJS application
176
- this.app = new Application();
177
-
178
- await this.app.init({
179
- width: ${width},
180
- height: ${height},
181
- backgroundColor: ${this.hexToNumber(project.settings.backgroundColor)},
182
- resolution: window.devicePixelRatio || 1,
183
- autoDensity: true,
184
- ${pixelArt
185
- ? `
186
- roundPixels: true,
187
- antialias: false,`
188
- : `
189
- antialias: true,`}
190
- });
191
-
192
- // Add canvas to DOM
193
- const container = document.getElementById('game-container');
194
- if (container) {
195
- container.appendChild(this.app.canvas);
196
- }
197
-
198
- // Load assets
199
- await this.loadAssets();
200
-
201
- // Initialize game manager
202
- this.gameManager = new GameManager(this.app);
203
-
204
- // Load first scene
205
- await loadScene('${project.scenes[0]?.name || 'main'}', this.app, this.gameManager);
206
-
207
- // Start game loop
208
- this.app.ticker.add(this.update.bind(this));
209
-
210
- console.log('${project.name} initialized!');
211
- }
212
-
213
- private async loadAssets()${useTS ? ': Promise<void>' : ''} {
214
- // Register asset bundles
215
- await Assets.init({ manifest: assetManifest });
216
-
217
- // Load all bundles
218
- const bundles = assetManifest.bundles.map(b => b.name);
219
- await Assets.loadBundle(bundles);
220
- }
221
-
222
- private update(ticker${useTS ? ': { deltaTime: number }' : ''})${useTS ? ': void' : ''} {
223
- const delta = ticker.deltaTime;
224
- this.gameManager.update(delta);
225
- }
226
- }
227
-
228
- // Start game
229
- const game = new Game();
230
- game.init().catch(console.error);
83
+
84
+ body {
85
+ background-color: ${project.settings.backgroundColor};
86
+ overflow: hidden;
87
+ display: flex;
88
+ justify-content: center;
89
+ align-items: center;
90
+ min-height: 100vh;
91
+ }
92
+
93
+ #game-container {
94
+ ${responsive ? `
95
+ width: 100%;
96
+ max-width: ${width}px;
97
+ aspect-ratio: ${width} / ${height};
98
+ ` : `
99
+ width: ${width}px;
100
+ height: ${height}px;
101
+ `}
102
+ }
103
+
104
+ canvas {
105
+ display: block;
106
+ width: 100%;
107
+ height: 100%;
108
+ ${project.settings.rendering?.pixelArt ? "image-rendering: pixelated;" : ""}
109
+ }
110
+ </style>
111
+ </head>
112
+ <body>
113
+ <div id="game-container"></div>
114
+ <script type="module" src="/src/main.ts"><\/script>
115
+ </body>
116
+ </html>
231
117
  `;
232
- this.addTextFile(`src/main.${ext}`, main);
118
+ this.addTextFile("index.html", html);
119
+ }
120
+ exportMainGame(project, options, useTS) {
121
+ const { width, height } = project.settings.resolution;
122
+ const ext = useTS ? "ts" : "js";
123
+ const pixelArt = project.settings.rendering?.pixelArt;
124
+ const main = `import { Application, Assets } from 'pixi.js';
125
+ import { sound } from '@pixi/sound';
126
+ import { assetManifest } from './assets/manifest${useTS ? "" : ".js"}';
127
+ import { GameManager } from './game/GameManager${useTS ? "" : ".js"}';
128
+ import { loadScene } from './scenes/index${useTS ? "" : ".js"}';
129
+
130
+ ${useTS ? `
131
+ interface GameConfig {
132
+ width: number;
133
+ height: number;
134
+ backgroundColor: number;
135
+ }
136
+ ` : ""}
137
+
138
+ class Game {
139
+ ${useTS ? "private app: Application;" : ""}
140
+ ${useTS ? "private gameManager: GameManager;" : ""}
141
+
142
+ async init()${useTS ? ": Promise<void>" : ""} {
143
+ // Create PixiJS application
144
+ this.app = new Application();
145
+
146
+ await this.app.init({
147
+ width: ${width},
148
+ height: ${height},
149
+ backgroundColor: ${this.hexToNumber(project.settings.backgroundColor)},
150
+ resolution: window.devicePixelRatio || 1,
151
+ autoDensity: true,
152
+ ${pixelArt ? `
153
+ roundPixels: true,
154
+ antialias: false,` : `
155
+ antialias: true,`}
156
+ });
157
+
158
+ // Add canvas to DOM
159
+ const container = document.getElementById('game-container');
160
+ if (container) {
161
+ container.appendChild(this.app.canvas);
233
162
  }
234
- exportScenes(project, options, useTS) {
235
- const ext = useTS ? 'ts' : 'js';
236
- // Scene index
237
- let sceneIndex = `import { Application, Container } from 'pixi.js';
238
- import { GameManager } from '../game/GameManager${useTS ? '' : '.js'}';
239
-
240
- ${useTS
241
- ? `
242
- export interface Scene {
243
- name: string;
244
- container: Container;
245
- init: () => Promise<void>;
246
- update: (delta: number) => void;
247
- destroy: () => void;
248
- }
249
- `
250
- : ''}
251
-
252
- const scenes${useTS ? ': Map<string, () => Promise<Scene>>' : ''} = new Map();
253
-
163
+
164
+ // Load assets
165
+ await this.loadAssets();
166
+
167
+ // Initialize game manager
168
+ this.gameManager = new GameManager(this.app);
169
+
170
+ // Load first scene
171
+ await loadScene('${project.scenes[0]?.name || "main"}', this.app, this.gameManager);
172
+
173
+ // Start game loop
174
+ this.app.ticker.add(this.update.bind(this));
175
+
176
+ console.log('${project.name} initialized!');
177
+ }
178
+
179
+ private async loadAssets()${useTS ? ": Promise<void>" : ""} {
180
+ // Register asset bundles
181
+ await Assets.init({ manifest: assetManifest });
182
+
183
+ // Load all bundles
184
+ const bundles = assetManifest.bundles.map(b => b.name);
185
+ await Assets.loadBundle(bundles);
186
+ }
187
+
188
+ private update(ticker${useTS ? ": { deltaTime: number }" : ""})${useTS ? ": void" : ""} {
189
+ const delta = ticker.deltaTime;
190
+ this.gameManager.update(delta);
191
+ }
192
+ }
193
+
194
+ // Start game
195
+ const game = new Game();
196
+ game.init().catch(console.error);
254
197
  `;
255
- for (const scene of project.scenes) {
256
- const sceneName = this.sanitizeName(scene.name);
257
- sceneIndex += `scenes.set('${scene.name}', () => import('./${sceneName}${useTS ? '' : '.js'}').then(m => m.default));\n`;
258
- }
259
- sceneIndex += `
260
- export async function loadScene(
261
- name${useTS ? ': string' : ''},
262
- app${useTS ? ': Application' : ''},
263
- gameManager${useTS ? ': GameManager' : ''}
264
- )${useTS ? ': Promise<Scene | null>' : ''} {
265
- const loader = scenes.get(name);
266
- if (!loader) {
267
- console.error(\`Scene "\${name}" not found\`);
268
- return null;
269
- }
270
-
271
- const SceneClass = await loader();
272
- const scene = new SceneClass(app, gameManager);
273
- await scene.init();
274
-
275
- app.stage.addChild(scene.container);
276
- gameManager.setCurrentScene(scene);
277
-
278
- return scene;
279
- }
280
-
281
- export { scenes };
198
+ this.addTextFile(`src/main.${ext}`, main);
199
+ }
200
+ exportScenes(project, options, useTS) {
201
+ const ext = useTS ? "ts" : "js";
202
+ let sceneIndex = `import { Application, Container } from 'pixi.js';
203
+ import { GameManager } from '../game/GameManager${useTS ? "" : ".js"}';
204
+
205
+ ${useTS ? `
206
+ export interface Scene {
207
+ name: string;
208
+ container: Container;
209
+ init: () => Promise<void>;
210
+ update: (delta: number) => void;
211
+ destroy: () => void;
212
+ }
213
+ ` : ""}
214
+
215
+ const scenes${useTS ? ": Map<string, () => Promise<Scene>>" : ""} = new Map();
216
+
217
+ `;
218
+ for (const scene of project.scenes) {
219
+ const sceneName = this.sanitizeName(scene.name);
220
+ sceneIndex += `scenes.set('${scene.name}', () => import('./${sceneName}${useTS ? "" : ".js"}').then(m => m.default));
282
221
  `;
283
- this.addTextFile(`src/scenes/index.${ext}`, sceneIndex);
284
- // Individual scene files
285
- for (const scene of project.scenes) {
286
- this.exportScene(scene, project, useTS);
287
- }
288
222
  }
289
- exportScene(scene, project, useTS) {
290
- const ext = useTS ? 'ts' : 'js';
291
- const sceneName = this.sanitizeName(scene.name);
292
- let content = `import { Application, Container, Sprite, Assets } from 'pixi.js';
293
- import { GameManager } from '../game/GameManager${useTS ? '' : '.js'}';
294
- ${useTS ? `import type { Scene } from './index';` : ''}
295
-
296
- export default class ${sceneName}Scene ${useTS ? 'implements Scene' : ''} {
297
- ${useTS ? 'public name: string;' : ''}
298
- ${useTS ? 'public container: Container;' : ''}
299
- ${useTS ? 'private app: Application;' : ''}
300
- ${useTS ? 'private gameManager: GameManager;' : ''}
301
- ${useTS ? 'private entities: Map<string, Container> = new Map();' : ''}
302
-
303
- constructor(app${useTS ? ': Application' : ''}, gameManager${useTS ? ': GameManager' : ''}) {
304
- this.name = '${scene.name}';
305
- this.app = app;
306
- this.gameManager = gameManager;
307
- this.container = new Container();
308
- ${useTS ? '' : 'this.entities = new Map();'}
309
- }
310
-
311
- async init()${useTS ? ': Promise<void>' : ''} {
223
+ sceneIndex += `
224
+ export async function loadScene(
225
+ name${useTS ? ": string" : ""},
226
+ app${useTS ? ": Application" : ""},
227
+ gameManager${useTS ? ": GameManager" : ""}
228
+ )${useTS ? ": Promise<Scene | null>" : ""} {
229
+ const loader = scenes.get(name);
230
+ if (!loader) {
231
+ console.error(\`Scene "\${name}" not found\`);
232
+ return null;
233
+ }
234
+
235
+ const SceneClass = await loader();
236
+ const scene = new SceneClass(app, gameManager);
237
+ await scene.init();
238
+
239
+ app.stage.addChild(scene.container);
240
+ gameManager.setCurrentScene(scene);
241
+
242
+ return scene;
243
+ }
244
+
245
+ export { scenes };
312
246
  `;
313
- // Create entities
314
- for (const entity of scene.entities) {
315
- content += this.generateEntityCode(entity, project, useTS);
316
- }
317
- content += ` }
318
-
319
- update(delta${useTS ? ': number' : ''})${useTS ? ': void' : ''} {
320
- // Update logic for scene
321
- for (const [id, entity] of this.entities) {
322
- // Entity update logic
323
- }
324
- }
325
-
326
- destroy()${useTS ? ': void' : ''} {
327
- this.container.destroy({ children: true });
328
- this.entities.clear();
329
- }
330
- }
247
+ this.addTextFile(`src/scenes/index.${ext}`, sceneIndex);
248
+ for (const scene of project.scenes) {
249
+ this.exportScene(scene, project, useTS);
250
+ }
251
+ }
252
+ exportScene(scene, project, useTS) {
253
+ const ext = useTS ? "ts" : "js";
254
+ const sceneName = this.sanitizeName(scene.name);
255
+ let content = `import { Application, Container, Sprite, Assets } from 'pixi.js';
256
+ import { GameManager } from '../game/GameManager${useTS ? "" : ".js"}';
257
+ ${useTS ? `import type { Scene } from './index';` : ""}
258
+
259
+ export default class ${sceneName}Scene ${useTS ? "implements Scene" : ""} {
260
+ ${useTS ? "public name: string;" : ""}
261
+ ${useTS ? "public container: Container;" : ""}
262
+ ${useTS ? "private app: Application;" : ""}
263
+ ${useTS ? "private gameManager: GameManager;" : ""}
264
+ ${useTS ? "private entities: Map<string, Container> = new Map();" : ""}
265
+
266
+ constructor(app${useTS ? ": Application" : ""}, gameManager${useTS ? ": GameManager" : ""}) {
267
+ this.name = '${scene.name}';
268
+ this.app = app;
269
+ this.gameManager = gameManager;
270
+ this.container = new Container();
271
+ ${useTS ? "" : "this.entities = new Map();"}
272
+ }
273
+
274
+ async init()${useTS ? ": Promise<void>" : ""} {
331
275
  `;
332
- this.addTextFile(`src/scenes/${sceneName}.${ext}`, content);
276
+ for (const entity of scene.entities) {
277
+ content += this.generateEntityCode(entity, project, useTS);
333
278
  }
334
- generateEntityCode(entity, project, useTS) {
335
- let code = `
336
- // Entity: ${entity.name}
337
- {
338
- const entity = new Container();
339
- entity.position.set(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0});
340
- entity.rotation = ${entity.rotation ?? 0};
341
- entity.scale.set(${entity.scale?.x ?? 1}, ${entity.scale?.y ?? 1});
279
+ content += ` }
280
+
281
+ update(delta${useTS ? ": number" : ""})${useTS ? ": void" : ""} {
282
+ // Update logic for scene
283
+ for (const [id, entity] of this.entities) {
284
+ // Entity update logic
285
+ }
286
+ }
287
+
288
+ destroy()${useTS ? ": void" : ""} {
289
+ this.container.destroy({ children: true });
290
+ this.entities.clear();
291
+ }
292
+ }
342
293
  `;
343
- for (const component of entity.components) {
344
- switch (component.type) {
345
- case 'sprite': {
346
- const spriteId = component.properties?.spriteId;
347
- const asset = project.assets.find((a) => a.id === spriteId);
348
- if (asset) {
349
- code += `
350
- const sprite = Sprite.from('${asset.name}');
351
- sprite.anchor.set(0.5);
352
- entity.addChild(sprite);
294
+ this.addTextFile(`src/scenes/${sceneName}.${ext}`, content);
295
+ }
296
+ generateEntityCode(entity, project, useTS) {
297
+ let code = `
298
+ // Entity: ${entity.name}
299
+ {
300
+ const entity = new Container();
301
+ entity.position.set(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0});
302
+ entity.rotation = ${entity.rotation ?? 0};
303
+ entity.scale.set(${entity.scale?.x ?? 1}, ${entity.scale?.y ?? 1});
353
304
  `;
354
- }
355
- break;
356
- }
357
- case 'animated-sprite': {
358
- code += `
359
- // Animated sprite would need AnimatedSprite setup
360
- // const animSprite = new AnimatedSprite(textures);
305
+ for (const component of entity.components) {
306
+ switch (component.type) {
307
+ case "sprite": {
308
+ const spriteId = component.properties?.spriteId;
309
+ const asset = project.assets.find((a) => a.id === spriteId);
310
+ if (asset) {
311
+ code += `
312
+ const sprite = Sprite.from('${asset.name}');
313
+ sprite.anchor.set(0.5);
314
+ entity.addChild(sprite);
361
315
  `;
362
- break;
363
- }
364
- }
316
+ }
317
+ break;
365
318
  }
366
- code += `
367
- this.container.addChild(entity);
368
- this.entities.set('${entity.id}', entity);
369
- }
319
+ case "animated-sprite": {
320
+ code += `
321
+ // Animated sprite would need AnimatedSprite setup
322
+ // const animSprite = new AnimatedSprite(textures);
370
323
  `;
371
- // Process children
372
- if (entity.children) {
373
- for (const child of entity.children) {
374
- code += this.generateEntityCode(child, project, useTS);
375
- }
324
+ break;
376
325
  }
377
- return code;
326
+ }
378
327
  }
379
- async exportScripts(project, options, _useTS) {
380
- for (const script of project.scripts) {
381
- try {
382
- const ast = this.graphToAST.convert(script);
383
- const result = this.tsExporter.export(ast, {
384
- includeDebugComments: options.debug,
385
- });
386
- for (const file of result.files) {
387
- this.addTextFile(`src/scripts/${file.path}`, file.content);
388
- }
389
- }
390
- catch (error) {
391
- this.addWarning('SCRIPT_EXPORT_ERROR', `Failed to export script "${script.name}": ${error}`);
392
- }
393
- }
328
+ code += `
329
+ this.container.addChild(entity);
330
+ this.entities.set('${entity.id}', entity);
394
331
  }
395
- exportAssetManifest(project) {
396
- const bundles = [];
397
- // Group assets by type
398
- const spriteAssets = project.assets.filter((a) => a.type === 'sprite');
399
- const audioAssets = project.assets.filter((a) => a.type === 'audio');
400
- const fontAssets = project.assets.filter((a) => a.type === 'font');
401
- // Sprites bundle
402
- if (spriteAssets.length > 0) {
403
- bundles.push({
404
- name: 'sprites',
405
- assets: spriteAssets.map((a) => ({
406
- alias: a.name,
407
- src: `assets/sprites/${a.path}`,
408
- })),
409
- });
410
- }
411
- // Audio bundle
412
- if (audioAssets.length > 0) {
413
- bundles.push({
414
- name: 'audio',
415
- assets: audioAssets.map((a) => ({
416
- alias: a.name,
417
- src: `assets/audio/${a.path}`,
418
- })),
419
- });
420
- }
421
- // Fonts bundle
422
- if (fontAssets.length > 0) {
423
- bundles.push({
424
- name: 'fonts',
425
- assets: fontAssets.map((a) => ({
426
- alias: a.name,
427
- src: `assets/fonts/${a.path}`,
428
- })),
429
- });
430
- }
431
- const manifest = {
432
- bundles,
433
- };
434
- this.addTextFile('src/assets/manifest.ts', `export const assetManifest = ${JSON.stringify(manifest, null, 2)};`);
332
+ `;
333
+ if (entity.children) {
334
+ for (const child of entity.children) {
335
+ code += this.generateEntityCode(child, project, useTS);
336
+ }
435
337
  }
436
- exportBundlerConfig(project, bundler, useTS) {
437
- switch (bundler) {
438
- case 'vite':
439
- this.addTextFile('vite.config.ts', `import { defineConfig } from 'vite';
440
-
441
- export default defineConfig({
442
- base: './',
443
- build: {
444
- outDir: 'dist',
445
- assetsDir: 'assets',
446
- sourcemap: true,
447
- },
448
- server: {
449
- port: 3000,
450
- open: true,
451
- },
452
- });
453
- `);
454
- break;
455
- case 'webpack':
456
- this.addTextFile('webpack.config.js', `const path = require('path');
457
- const HtmlWebpackPlugin = require('html-webpack-plugin');
458
-
459
- module.exports = {
460
- entry: './src/main.${useTS ? 'ts' : 'js'}',
461
- output: {
462
- filename: 'bundle.js',
463
- path: path.resolve(__dirname, 'dist'),
464
- },
465
- resolve: {
466
- extensions: ['.ts', '.js'],
467
- },
468
- module: {
469
- rules: [
470
- {
471
- test: /\\.ts$/,
472
- use: 'ts-loader',
473
- exclude: /node_modules/,
474
- },
475
- ],
476
- },
477
- plugins: [
478
- new HtmlWebpackPlugin({
479
- template: 'index.html',
480
- }),
481
- ],
482
- devServer: {
483
- static: './dist',
484
- port: 3000,
485
- open: true,
486
- },
487
- };
488
- `);
489
- break;
338
+ return code;
339
+ }
340
+ async exportScripts(project, options, _useTS) {
341
+ for (const script of project.scripts) {
342
+ try {
343
+ const ast = this.graphToAST.convert(script);
344
+ const result = this.tsExporter.export(ast, {
345
+ includeDebugComments: options.debug
346
+ });
347
+ for (const file of result.files) {
348
+ this.addTextFile(`src/scripts/${file.path}`, file.content);
490
349
  }
350
+ } catch (error) {
351
+ this.addWarning(
352
+ "SCRIPT_EXPORT_ERROR",
353
+ `Failed to export script "${script.name}": ${error}`
354
+ );
355
+ }
491
356
  }
492
- exportPWAFiles(project) {
493
- // manifest.json
494
- const manifest = {
495
- name: project.name,
496
- short_name: project.name.slice(0, 12),
497
- description: project.description || '',
498
- start_url: '/',
499
- display: 'fullscreen',
500
- background_color: project.settings.backgroundColor,
501
- theme_color: project.settings.backgroundColor,
502
- icons: [
503
- { src: 'icon-192.png', sizes: '192x192', type: 'image/png' },
504
- { src: 'icon-512.png', sizes: '512x512', type: 'image/png' },
505
- ],
506
- };
507
- this.addTextFile('public/manifest.json', JSON.stringify(manifest, null, 2));
508
- // service-worker.js
509
- this.addTextFile('public/sw.js', `const CACHE_NAME = '${project.name}-v${project.version}';
510
- const urlsToCache = [
511
- '/',
512
- '/index.html',
513
- '/src/main.ts',
514
- ];
515
-
516
- self.addEventListener('install', (event) => {
517
- event.waitUntil(
518
- caches.open(CACHE_NAME)
519
- .then((cache) => cache.addAll(urlsToCache))
520
- );
521
- });
522
-
523
- self.addEventListener('fetch', (event) => {
524
- event.respondWith(
525
- caches.match(event.request)
526
- .then((response) => response || fetch(event.request))
527
- );
528
- });
529
- `);
357
+ }
358
+ exportAssetManifest(project) {
359
+ const bundles = [];
360
+ const spriteAssets = project.assets.filter((a) => a.type === "sprite");
361
+ const audioAssets = project.assets.filter((a) => a.type === "audio");
362
+ const fontAssets = project.assets.filter((a) => a.type === "font");
363
+ if (spriteAssets.length > 0) {
364
+ bundles.push({
365
+ name: "sprites",
366
+ assets: spriteAssets.map((a) => ({
367
+ alias: a.name,
368
+ src: `assets/sprites/${a.path}`
369
+ }))
370
+ });
530
371
  }
531
- exportUtilities(project, useTS) {
532
- const ext = useTS ? 'ts' : 'js';
533
- // GameManager
534
- const gameManager = `import { Application, Container } from 'pixi.js';
535
- ${useTS ? `import type { Scene } from '../scenes/index';` : ''}
536
-
537
- export class GameManager {
538
- ${useTS ? 'private app: Application;' : ''}
539
- ${useTS ? 'private currentScene: Scene | null = null;' : ''}
540
- ${useTS ? 'private entities: Map<string, Container> = new Map();' : ''}
541
- ${useTS ? 'private isPaused: boolean = false;' : ''}
542
-
543
- constructor(app${useTS ? ': Application' : ''}) {
544
- this.app = app;
545
- ${useTS
546
- ? ''
547
- : `
548
- this.currentScene = null;
549
- this.entities = new Map();
550
- this.isPaused = false;`}
551
- }
552
-
553
- setCurrentScene(scene${useTS ? ': Scene' : ''})${useTS ? ': void' : ''} {
554
- if (this.currentScene) {
555
- this.currentScene.destroy();
556
- this.app.stage.removeChild(this.currentScene.container);
557
- }
558
- this.currentScene = scene;
559
- }
560
-
561
- registerEntity(id${useTS ? ': string' : ''}, entity${useTS ? ': Container' : ''})${useTS ? ': void' : ''} {
562
- this.entities.set(id, entity);
563
- }
564
-
565
- getEntity(id${useTS ? ': string' : ''})${useTS ? ': Container | undefined' : ''} {
566
- return this.entities.get(id);
567
- }
568
-
569
- update(delta${useTS ? ': number' : ''})${useTS ? ': void' : ''} {
570
- if (this.isPaused) return;
571
-
572
- if (this.currentScene) {
573
- this.currentScene.update(delta);
574
- }
575
- }
576
-
577
- pause()${useTS ? ': void' : ''} {
578
- this.isPaused = true;
579
- }
580
-
581
- resume()${useTS ? ': void' : ''} {
582
- this.isPaused = false;
583
- }
584
-
585
- get paused()${useTS ? ': boolean' : ''} {
586
- return this.isPaused;
587
- }
588
- }
589
- `;
590
- this.addTextFile(`src/game/GameManager.${ext}`, gameManager);
591
- // Input manager
592
- const inputManager = `export class InputManager {
593
- ${useTS ? 'private keys: Set<string> = new Set();' : ''}
594
- ${useTS ? 'private keysJustPressed: Set<string> = new Set();' : ''}
595
- ${useTS ? 'private mousePosition: { x: number; y: number } = { x: 0, y: 0 };' : ''}
596
- ${useTS ? 'private mouseButtons: Set<number> = new Set();' : ''}
597
-
598
- constructor() {
599
- ${useTS
600
- ? ''
601
- : `
602
- this.keys = new Set();
603
- this.keysJustPressed = new Set();
604
- this.mousePosition = { x: 0, y: 0 };
605
- this.mouseButtons = new Set();`}
606
-
607
- window.addEventListener('keydown', this.onKeyDown.bind(this));
608
- window.addEventListener('keyup', this.onKeyUp.bind(this));
609
- window.addEventListener('mousemove', this.onMouseMove.bind(this));
610
- window.addEventListener('mousedown', this.onMouseDown.bind(this));
611
- window.addEventListener('mouseup', this.onMouseUp.bind(this));
612
- }
613
-
614
- private onKeyDown(e${useTS ? ': KeyboardEvent' : ''})${useTS ? ': void' : ''} {
615
- if (!this.keys.has(e.code)) {
616
- this.keysJustPressed.add(e.code);
617
- }
618
- this.keys.add(e.code);
619
- }
620
-
621
- private onKeyUp(e${useTS ? ': KeyboardEvent' : ''})${useTS ? ': void' : ''} {
622
- this.keys.delete(e.code);
623
- }
624
-
625
- private onMouseMove(e${useTS ? ': MouseEvent' : ''})${useTS ? ': void' : ''} {
626
- this.mousePosition.x = e.clientX;
627
- this.mousePosition.y = e.clientY;
628
- }
629
-
630
- private onMouseDown(e${useTS ? ': MouseEvent' : ''})${useTS ? ': void' : ''} {
631
- this.mouseButtons.add(e.button);
632
- }
633
-
634
- private onMouseUp(e${useTS ? ': MouseEvent' : ''})${useTS ? ': void' : ''} {
635
- this.mouseButtons.delete(e.button);
636
- }
637
-
638
- isKeyPressed(code${useTS ? ': string' : ''})${useTS ? ': boolean' : ''} {
639
- return this.keys.has(code);
640
- }
641
-
642
- isKeyJustPressed(code${useTS ? ': string' : ''})${useTS ? ': boolean' : ''} {
643
- const pressed = this.keysJustPressed.has(code);
644
- this.keysJustPressed.delete(code);
645
- return pressed;
646
- }
647
-
648
- isMouseButtonPressed(button${useTS ? ': number' : ''})${useTS ? ': boolean' : ''} {
649
- return this.mouseButtons.has(button);
650
- }
651
-
652
- getMousePosition()${useTS ? ': { x: number; y: number }' : ''} {
653
- return { ...this.mousePosition };
654
- }
655
-
656
- update()${useTS ? ': void' : ''} {
657
- this.keysJustPressed.clear();
658
- }
659
- }
660
-
661
- export const input = new InputManager();
662
- `;
663
- this.addTextFile(`src/game/InputManager.${ext}`, inputManager);
372
+ if (audioAssets.length > 0) {
373
+ bundles.push({
374
+ name: "audio",
375
+ assets: audioAssets.map((a) => ({
376
+ alias: a.name,
377
+ src: `assets/audio/${a.path}`
378
+ }))
379
+ });
380
+ }
381
+ if (fontAssets.length > 0) {
382
+ bundles.push({
383
+ name: "fonts",
384
+ assets: fontAssets.map((a) => ({
385
+ alias: a.name,
386
+ src: `assets/fonts/${a.path}`
387
+ }))
388
+ });
389
+ }
390
+ const manifest = {
391
+ bundles
392
+ };
393
+ this.addTextFile(
394
+ "src/assets/manifest.ts",
395
+ `export const assetManifest = ${JSON.stringify(manifest, null, 2)};`
396
+ );
397
+ }
398
+ exportBundlerConfig(project, bundler, useTS) {
399
+ switch (bundler) {
400
+ case "vite":
401
+ this.addTextFile(
402
+ "vite.config.ts",
403
+ `import { defineConfig } from 'vite';
404
+
405
+ export default defineConfig({
406
+ base: './',
407
+ build: {
408
+ outDir: 'dist',
409
+ assetsDir: 'assets',
410
+ sourcemap: true,
411
+ },
412
+ server: {
413
+ port: 3000,
414
+ open: true,
415
+ },
416
+ });
417
+ `
418
+ );
419
+ break;
420
+ case "webpack":
421
+ this.addTextFile(
422
+ "webpack.config.js",
423
+ `const path = require('path');
424
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
425
+
426
+ module.exports = {
427
+ entry: './src/main.${useTS ? "ts" : "js"}',
428
+ output: {
429
+ filename: 'bundle.js',
430
+ path: path.resolve(__dirname, 'dist'),
431
+ },
432
+ resolve: {
433
+ extensions: ['.ts', '.js'],
434
+ },
435
+ module: {
436
+ rules: [
437
+ {
438
+ test: /\\.ts$/,
439
+ use: 'ts-loader',
440
+ exclude: /node_modules/,
441
+ },
442
+ ],
443
+ },
444
+ plugins: [
445
+ new HtmlWebpackPlugin({
446
+ template: 'index.html',
447
+ }),
448
+ ],
449
+ devServer: {
450
+ static: './dist',
451
+ port: 3000,
452
+ open: true,
453
+ },
454
+ };
455
+ `
456
+ );
457
+ break;
664
458
  }
665
- exportTSConfig() {
666
- const tsconfig = {
667
- compilerOptions: {
668
- target: 'ES2020',
669
- useDefineForClassFields: true,
670
- module: 'ESNext',
671
- lib: ['ES2020', 'DOM', 'DOM.Iterable'],
672
- skipLibCheck: true,
673
- moduleResolution: 'bundler',
674
- allowImportingTsExtensions: true,
675
- resolveJsonModule: true,
676
- isolatedModules: true,
677
- noEmit: true,
678
- strict: true,
679
- noUnusedLocals: true,
680
- noUnusedParameters: true,
681
- noFallthroughCasesInSwitch: true,
682
- },
683
- include: ['src'],
684
- };
685
- this.addTextFile('tsconfig.json', JSON.stringify(tsconfig, null, 2));
459
+ }
460
+ exportPWAFiles(project) {
461
+ const manifest = {
462
+ name: project.name,
463
+ short_name: project.name.slice(0, 12),
464
+ description: project.description || "",
465
+ start_url: "/",
466
+ display: "fullscreen",
467
+ background_color: project.settings.backgroundColor,
468
+ theme_color: project.settings.backgroundColor,
469
+ icons: [
470
+ { src: "icon-192.png", sizes: "192x192", type: "image/png" },
471
+ { src: "icon-512.png", sizes: "512x512", type: "image/png" }
472
+ ]
473
+ };
474
+ this.addTextFile("public/manifest.json", JSON.stringify(manifest, null, 2));
475
+ this.addTextFile(
476
+ "public/sw.js",
477
+ `const CACHE_NAME = '${project.name}-v${project.version}';
478
+ const urlsToCache = [
479
+ '/',
480
+ '/index.html',
481
+ '/src/main.ts',
482
+ ];
483
+
484
+ self.addEventListener('install', (event) => {
485
+ event.waitUntil(
486
+ caches.open(CACHE_NAME)
487
+ .then((cache) => cache.addAll(urlsToCache))
488
+ );
489
+ });
490
+
491
+ self.addEventListener('fetch', (event) => {
492
+ event.respondWith(
493
+ caches.match(event.request)
494
+ .then((response) => response || fetch(event.request))
495
+ );
496
+ });
497
+ `
498
+ );
499
+ }
500
+ exportUtilities(project, useTS) {
501
+ const ext = useTS ? "ts" : "js";
502
+ const gameManager = `import { Application, Container } from 'pixi.js';
503
+ ${useTS ? `import type { Scene } from '../scenes/index';` : ""}
504
+
505
+ export class GameManager {
506
+ ${useTS ? "private app: Application;" : ""}
507
+ ${useTS ? "private currentScene: Scene | null = null;" : ""}
508
+ ${useTS ? "private entities: Map<string, Container> = new Map();" : ""}
509
+ ${useTS ? "private isPaused: boolean = false;" : ""}
510
+
511
+ constructor(app${useTS ? ": Application" : ""}) {
512
+ this.app = app;
513
+ ${useTS ? "" : `
514
+ this.currentScene = null;
515
+ this.entities = new Map();
516
+ this.isPaused = false;`}
517
+ }
518
+
519
+ setCurrentScene(scene${useTS ? ": Scene" : ""})${useTS ? ": void" : ""} {
520
+ if (this.currentScene) {
521
+ this.currentScene.destroy();
522
+ this.app.stage.removeChild(this.currentScene.container);
686
523
  }
687
- hexToNumber(hex) {
688
- return parseInt(hex.replace('#', ''), 16);
524
+ this.currentScene = scene;
525
+ }
526
+
527
+ registerEntity(id${useTS ? ": string" : ""}, entity${useTS ? ": Container" : ""})${useTS ? ": void" : ""} {
528
+ this.entities.set(id, entity);
529
+ }
530
+
531
+ getEntity(id${useTS ? ": string" : ""})${useTS ? ": Container | undefined" : ""} {
532
+ return this.entities.get(id);
533
+ }
534
+
535
+ update(delta${useTS ? ": number" : ""})${useTS ? ": void" : ""} {
536
+ if (this.isPaused) return;
537
+
538
+ if (this.currentScene) {
539
+ this.currentScene.update(delta);
689
540
  }
690
- sanitizeName(name) {
691
- return name.replace(/[^a-zA-Z0-9]/g, '');
541
+ }
542
+
543
+ pause()${useTS ? ": void" : ""} {
544
+ this.isPaused = true;
545
+ }
546
+
547
+ resume()${useTS ? ": void" : ""} {
548
+ this.isPaused = false;
549
+ }
550
+
551
+ get paused()${useTS ? ": boolean" : ""} {
552
+ return this.isPaused;
553
+ }
554
+ }
555
+ `;
556
+ this.addTextFile(`src/game/GameManager.${ext}`, gameManager);
557
+ const inputManager = `export class InputManager {
558
+ ${useTS ? "private keys: Set<string> = new Set();" : ""}
559
+ ${useTS ? "private keysJustPressed: Set<string> = new Set();" : ""}
560
+ ${useTS ? "private mousePosition: { x: number; y: number } = { x: 0, y: 0 };" : ""}
561
+ ${useTS ? "private mouseButtons: Set<number> = new Set();" : ""}
562
+
563
+ constructor() {
564
+ ${useTS ? "" : `
565
+ this.keys = new Set();
566
+ this.keysJustPressed = new Set();
567
+ this.mousePosition = { x: 0, y: 0 };
568
+ this.mouseButtons = new Set();`}
569
+
570
+ window.addEventListener('keydown', this.onKeyDown.bind(this));
571
+ window.addEventListener('keyup', this.onKeyUp.bind(this));
572
+ window.addEventListener('mousemove', this.onMouseMove.bind(this));
573
+ window.addEventListener('mousedown', this.onMouseDown.bind(this));
574
+ window.addEventListener('mouseup', this.onMouseUp.bind(this));
575
+ }
576
+
577
+ private onKeyDown(e${useTS ? ": KeyboardEvent" : ""})${useTS ? ": void" : ""} {
578
+ if (!this.keys.has(e.code)) {
579
+ this.keysJustPressed.add(e.code);
692
580
  }
581
+ this.keys.add(e.code);
582
+ }
583
+
584
+ private onKeyUp(e${useTS ? ": KeyboardEvent" : ""})${useTS ? ": void" : ""} {
585
+ this.keys.delete(e.code);
586
+ }
587
+
588
+ private onMouseMove(e${useTS ? ": MouseEvent" : ""})${useTS ? ": void" : ""} {
589
+ this.mousePosition.x = e.clientX;
590
+ this.mousePosition.y = e.clientY;
591
+ }
592
+
593
+ private onMouseDown(e${useTS ? ": MouseEvent" : ""})${useTS ? ": void" : ""} {
594
+ this.mouseButtons.add(e.button);
595
+ }
596
+
597
+ private onMouseUp(e${useTS ? ": MouseEvent" : ""})${useTS ? ": void" : ""} {
598
+ this.mouseButtons.delete(e.button);
599
+ }
600
+
601
+ isKeyPressed(code${useTS ? ": string" : ""})${useTS ? ": boolean" : ""} {
602
+ return this.keys.has(code);
603
+ }
604
+
605
+ isKeyJustPressed(code${useTS ? ": string" : ""})${useTS ? ": boolean" : ""} {
606
+ const pressed = this.keysJustPressed.has(code);
607
+ this.keysJustPressed.delete(code);
608
+ return pressed;
609
+ }
610
+
611
+ isMouseButtonPressed(button${useTS ? ": number" : ""})${useTS ? ": boolean" : ""} {
612
+ return this.mouseButtons.has(button);
613
+ }
614
+
615
+ getMousePosition()${useTS ? ": { x: number; y: number }" : ""} {
616
+ return { ...this.mousePosition };
617
+ }
618
+
619
+ update()${useTS ? ": void" : ""} {
620
+ this.keysJustPressed.clear();
621
+ }
622
+ }
623
+
624
+ export const input = new InputManager();
625
+ `;
626
+ this.addTextFile(`src/game/InputManager.${ext}`, inputManager);
627
+ }
628
+ exportTSConfig() {
629
+ const tsconfig = {
630
+ compilerOptions: {
631
+ target: "ES2020",
632
+ useDefineForClassFields: true,
633
+ module: "ESNext",
634
+ lib: ["ES2020", "DOM", "DOM.Iterable"],
635
+ skipLibCheck: true,
636
+ moduleResolution: "bundler",
637
+ allowImportingTsExtensions: true,
638
+ resolveJsonModule: true,
639
+ isolatedModules: true,
640
+ noEmit: true,
641
+ strict: true,
642
+ noUnusedLocals: true,
643
+ noUnusedParameters: true,
644
+ noFallthroughCasesInSwitch: true
645
+ },
646
+ include: ["src"]
647
+ };
648
+ this.addTextFile("tsconfig.json", JSON.stringify(tsconfig, null, 2));
649
+ }
650
+ hexToNumber(hex) {
651
+ return parseInt(hex.replace("#", ""), 16);
652
+ }
653
+ sanitizeName(name) {
654
+ return name.replace(/[^a-zA-Z0-9]/g, "");
655
+ }
693
656
  }
694
- /* ── Phaser Exporter ──────────────────────────────────────────── */
695
657
  class PhaserExporter extends PlatformExporter {
696
- constructor() {
697
- super(...arguments);
698
- this.platformId = 'phaser';
699
- this.platformInfo = {
700
- id: 'phaser',
701
- name: 'Phaser',
702
- description: 'Desktop and mobile HTML5 game framework',
703
- website: 'https://phaser.io',
704
- features: ['2d-rendering', 'physics-2d', 'audio', 'tilemaps', 'particles', 'animation'],
705
- supportedAssets: ['sprite', 'tileset', 'audio', 'font', 'script', 'animation', 'tilemap'],
706
- exportFormats: ['.html', '.js', '.ts'],
707
- };
708
- this.tsExporter = new TypeScriptExporter();
709
- this.graphToAST = new GraphToAST();
658
+ constructor() {
659
+ super(...arguments);
660
+ this.platformId = "phaser";
661
+ this.platformInfo = {
662
+ id: "phaser",
663
+ name: "Phaser",
664
+ description: "Desktop and mobile HTML5 game framework",
665
+ website: "https://phaser.io",
666
+ features: ["2d-rendering", "physics-2d", "audio", "tilemaps", "particles", "animation"],
667
+ supportedAssets: ["sprite", "tileset", "audio", "font", "script", "animation", "tilemap"],
668
+ exportFormats: [".html", ".js", ".ts"]
669
+ };
670
+ this.tsExporter = new TypeScriptExporter();
671
+ this.graphToAST = new GraphToAST();
672
+ }
673
+ async doExport(project, options) {
674
+ const web = options.platformOptions;
675
+ const useTS = web?.typescript !== false;
676
+ const bundler = web?.bundler || "vite";
677
+ this.exportPackageJson(project, web);
678
+ this.exportIndexHtml(project);
679
+ this.exportMainGame(project, options, useTS);
680
+ this.exportScenes(project, options, useTS);
681
+ await this.exportScripts(project, options, useTS);
682
+ if (bundler !== "none") {
683
+ this.exportBundlerConfig(bundler, useTS);
710
684
  }
711
- async doExport(project, options) {
712
- const web = options.platformOptions;
713
- const useTS = web?.typescript !== false;
714
- const bundler = web?.bundler || 'vite';
715
- // 1. Generate package.json
716
- this.exportPackageJson(project, web);
717
- // 2. Generate HTML entry
718
- this.exportIndexHtml(project);
719
- // 3. Generate main game config
720
- this.exportMainGame(project, options, useTS);
721
- // 4. Export scenes
722
- this.exportScenes(project, options, useTS);
723
- // 5. Export scripts
724
- await this.exportScripts(project, options, useTS);
725
- // 6. Generate bundler config
726
- if (bundler !== 'none') {
727
- this.exportBundlerConfig(bundler, useTS);
728
- }
729
- // 7. Generate tsconfig if TypeScript
730
- if (useTS) {
731
- this.exportTSConfig();
732
- }
685
+ if (useTS) {
686
+ this.exportTSConfig();
733
687
  }
734
- exportPackageJson(project, web) {
735
- const useTS = web?.typescript !== false;
736
- const bundler = web?.bundler || 'vite';
737
- const phaserVersion = web?.frameworkVersion || '^3.70.0';
738
- const packageJson = {
739
- name: project.name.toLowerCase().replace(/\s+/g, '-'),
740
- version: project.version,
741
- type: 'module',
742
- scripts: {
743
- dev: bundler === 'vite' ? 'vite' : 'webpack serve',
744
- build: bundler === 'vite' ? 'vite build' : 'webpack',
745
- },
746
- dependencies: {
747
- phaser: phaserVersion,
748
- },
749
- devDependencies: {
750
- ...(useTS ? { typescript: '^5.0.0' } : {}),
751
- ...(bundler === 'vite' ? { vite: '^5.0.0' } : {}),
752
- },
753
- };
754
- this.addTextFile('package.json', JSON.stringify(packageJson, null, 2));
688
+ }
689
+ exportPackageJson(project, web) {
690
+ const useTS = web?.typescript !== false;
691
+ const bundler = web?.bundler || "vite";
692
+ const phaserVersion = web?.frameworkVersion || "^3.70.0";
693
+ const packageJson = {
694
+ name: project.name.toLowerCase().replace(/\s+/g, "-"),
695
+ version: project.version,
696
+ type: "module",
697
+ scripts: {
698
+ dev: bundler === "vite" ? "vite" : "webpack serve",
699
+ build: bundler === "vite" ? "vite build" : "webpack"
700
+ },
701
+ dependencies: {
702
+ phaser: phaserVersion
703
+ },
704
+ devDependencies: {
705
+ ...useTS ? { typescript: "^5.0.0" } : {},
706
+ ...bundler === "vite" ? { vite: "^5.0.0" } : {}
707
+ }
708
+ };
709
+ this.addTextFile("package.json", JSON.stringify(packageJson, null, 2));
710
+ }
711
+ exportIndexHtml(project) {
712
+ const html = `<!DOCTYPE html>
713
+ <html lang="en">
714
+ <head>
715
+ <meta charset="UTF-8">
716
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
717
+ <title>${project.name}</title>
718
+ <style>
719
+ * { margin: 0; padding: 0; }
720
+ body {
721
+ background: ${project.settings.backgroundColor};
722
+ display: flex;
723
+ justify-content: center;
724
+ align-items: center;
725
+ min-height: 100vh;
755
726
  }
756
- exportIndexHtml(project) {
757
- const html = `<!DOCTYPE html>
758
- <html lang="en">
759
- <head>
760
- <meta charset="UTF-8">
761
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
762
- <title>${project.name}</title>
763
- <style>
764
- * { margin: 0; padding: 0; }
765
- body {
766
- background: ${project.settings.backgroundColor};
767
- display: flex;
768
- justify-content: center;
769
- align-items: center;
770
- min-height: 100vh;
771
- }
772
- canvas {
773
- ${project.settings.rendering?.pixelArt ? 'image-rendering: pixelated;' : ''}
774
- }
775
- </style>
776
- </head>
777
- <body>
778
- <script type="module" src="/src/main.ts"></script>
779
- </body>
780
- </html>`;
781
- this.addTextFile('index.html', html);
727
+ canvas {
728
+ ${project.settings.rendering?.pixelArt ? "image-rendering: pixelated;" : ""}
782
729
  }
783
- exportMainGame(project, options, useTS) {
784
- const ext = useTS ? 'ts' : 'js';
785
- const { width, height } = project.settings.resolution;
786
- const pixelArt = project.settings.rendering?.pixelArt;
787
- const hasPhysics = project.settings.physics?.enabled;
788
- let sceneImports = '';
789
- let sceneList = '';
790
- for (const scene of project.scenes) {
791
- const sceneName = this.sanitizeName(scene.name);
792
- sceneImports += `import { ${sceneName}Scene } from './scenes/${sceneName}${useTS ? '' : '.js'}';\n`;
793
- sceneList += `${sceneName}Scene, `;
794
- }
795
- const main = `import Phaser from 'phaser';
796
- ${sceneImports}
797
-
798
- const config${useTS ? ': Phaser.Types.Core.GameConfig' : ''} = {
799
- type: Phaser.AUTO,
800
- width: ${width},
801
- height: ${height},
802
- backgroundColor: '${project.settings.backgroundColor}',
803
- parent: 'game-container',
804
- ${pixelArt
805
- ? `
806
- pixelArt: true,
807
- roundPixels: true,`
808
- : ''}
809
- ${hasPhysics
810
- ? `
811
- physics: {
812
- default: 'arcade',
813
- arcade: {
814
- gravity: { x: ${project.settings.physics?.gravity.x ?? 0}, y: ${project.settings.physics?.gravity.y ?? 300} },
815
- debug: ${options.debug || false}
816
- }
817
- },`
818
- : ''}
819
- scene: [${sceneList}],
820
- scale: {
821
- mode: Phaser.Scale.FIT,
822
- autoCenter: Phaser.Scale.CENTER_BOTH,
823
- },
824
- };
825
-
826
- const game = new Phaser.Game(config);
730
+ </style>
731
+ </head>
732
+ <body>
733
+ <script type="module" src="/src/main.ts"><\/script>
734
+ </body>
735
+ </html>`;
736
+ this.addTextFile("index.html", html);
737
+ }
738
+ exportMainGame(project, options, useTS) {
739
+ const ext = useTS ? "ts" : "js";
740
+ const { width, height } = project.settings.resolution;
741
+ const pixelArt = project.settings.rendering?.pixelArt;
742
+ const hasPhysics = project.settings.physics?.enabled;
743
+ let sceneImports = "";
744
+ let sceneList = "";
745
+ for (const scene of project.scenes) {
746
+ const sceneName = this.sanitizeName(scene.name);
747
+ sceneImports += `import { ${sceneName}Scene } from './scenes/${sceneName}${useTS ? "" : ".js"}';
827
748
  `;
828
- this.addTextFile(`src/main.${ext}`, main);
749
+ sceneList += `${sceneName}Scene, `;
829
750
  }
830
- exportScenes(project, options, useTS) {
831
- for (const scene of project.scenes) {
832
- this.exportScene(scene, project, useTS);
833
- }
751
+ const main = `import Phaser from 'phaser';
752
+ ${sceneImports}
753
+
754
+ const config${useTS ? ": Phaser.Types.Core.GameConfig" : ""} = {
755
+ type: Phaser.AUTO,
756
+ width: ${width},
757
+ height: ${height},
758
+ backgroundColor: '${project.settings.backgroundColor}',
759
+ parent: 'game-container',
760
+ ${pixelArt ? `
761
+ pixelArt: true,
762
+ roundPixels: true,` : ""}
763
+ ${hasPhysics ? `
764
+ physics: {
765
+ default: 'arcade',
766
+ arcade: {
767
+ gravity: { x: ${project.settings.physics?.gravity.x ?? 0}, y: ${project.settings.physics?.gravity.y ?? 300} },
768
+ debug: ${options.debug || false}
834
769
  }
835
- exportScene(scene, project, useTS) {
836
- const ext = useTS ? 'ts' : 'js';
837
- const sceneName = this.sanitizeName(scene.name);
838
- let content = `import Phaser from 'phaser';
839
-
840
- export class ${sceneName}Scene extends Phaser.Scene {
841
- constructor() {
842
- super({ key: '${scene.name}' });
843
- }
844
-
845
- preload()${useTS ? ': void' : ''} {
770
+ },` : ""}
771
+ scene: [${sceneList}],
772
+ scale: {
773
+ mode: Phaser.Scale.FIT,
774
+ autoCenter: Phaser.Scale.CENTER_BOTH,
775
+ },
776
+ };
777
+
778
+ const game = new Phaser.Game(config);
846
779
  `;
847
- // Preload assets used in this scene
848
- const usedAssets = this.getUsedAssets(scene, project);
849
- for (const asset of usedAssets) {
850
- switch (asset.type) {
851
- case 'sprite':
852
- content += ` this.load.image('${asset.name}', 'assets/sprites/${asset.path}');\n`;
853
- break;
854
- case 'audio':
855
- content += ` this.load.audio('${asset.name}', 'assets/audio/${asset.path}');\n`;
856
- break;
857
- case 'tileset':
858
- content += ` this.load.image('${asset.name}', 'assets/tilesets/${asset.path}');\n`;
859
- break;
860
- }
861
- }
862
- content += ` }
863
-
864
- create()${useTS ? ': void' : ''} {
780
+ this.addTextFile(`src/main.${ext}`, main);
781
+ }
782
+ exportScenes(project, options, useTS) {
783
+ for (const scene of project.scenes) {
784
+ this.exportScene(scene, project, useTS);
785
+ }
786
+ }
787
+ exportScene(scene, project, useTS) {
788
+ const ext = useTS ? "ts" : "js";
789
+ const sceneName = this.sanitizeName(scene.name);
790
+ let content = `import Phaser from 'phaser';
791
+
792
+ export class ${sceneName}Scene extends Phaser.Scene {
793
+ constructor() {
794
+ super({ key: '${scene.name}' });
795
+ }
796
+
797
+ preload()${useTS ? ": void" : ""} {
865
798
  `;
866
- // Create entities
867
- for (const entity of scene.entities) {
868
- content += this.generateEntityCode(entity, project, useTS);
869
- }
870
- // Create tilemaps
871
- for (const tilemap of scene.tilemaps ?? []) {
872
- content += this.generateTilemapCode(tilemap, project);
873
- }
874
- content += ` }
875
-
876
- update(time${useTS ? ': number' : ''}, delta${useTS ? ': number' : ''})${useTS ? ': void' : ''} {
877
- // Update logic
878
- }
879
- }
799
+ const usedAssets = this.getUsedAssets(scene, project);
800
+ for (const asset of usedAssets) {
801
+ switch (asset.type) {
802
+ case "sprite":
803
+ content += ` this.load.image('${asset.name}', 'assets/sprites/${asset.path}');
804
+ `;
805
+ break;
806
+ case "audio":
807
+ content += ` this.load.audio('${asset.name}', 'assets/audio/${asset.path}');
880
808
  `;
881
- this.addTextFile(`src/scenes/${sceneName}.${ext}`, content);
809
+ break;
810
+ case "tileset":
811
+ content += ` this.load.image('${asset.name}', 'assets/tilesets/${asset.path}');
812
+ `;
813
+ break;
814
+ }
882
815
  }
883
- generateEntityCode(entity, project, useTS) {
884
- let code = `
885
- // Entity: ${entity.name}
816
+ content += ` }
817
+
818
+ create()${useTS ? ": void" : ""} {
819
+ `;
820
+ for (const entity of scene.entities) {
821
+ content += this.generateEntityCode(entity, project, useTS);
822
+ }
823
+ for (const tilemap of scene.tilemaps ?? []) {
824
+ content += this.generateTilemapCode(tilemap, project);
825
+ }
826
+ content += ` }
827
+
828
+ update(time${useTS ? ": number" : ""}, delta${useTS ? ": number" : ""})${useTS ? ": void" : ""} {
829
+ // Update logic
830
+ }
831
+ }
832
+ `;
833
+ this.addTextFile(`src/scenes/${sceneName}.${ext}`, content);
834
+ }
835
+ generateEntityCode(entity, project, useTS) {
836
+ let code = `
837
+ // Entity: ${entity.name}
838
+ `;
839
+ for (const component of entity.components) {
840
+ switch (component.type) {
841
+ case "sprite": {
842
+ const spriteId = component.properties?.spriteId;
843
+ const asset = project.assets.find((a) => a.id === spriteId);
844
+ if (asset) {
845
+ const hasPhysics = entity.components.some(
846
+ (c) => c.type === "rigidbody-2d" || c.type === "box-collider-2d" || c.type === "circle-collider-2d"
847
+ );
848
+ if (hasPhysics) {
849
+ code += ` const ${this.varName(entity.name)} = this.physics.add.sprite(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${asset.name}');
850
+ `;
851
+ } else {
852
+ code += ` const ${this.varName(entity.name)} = this.add.sprite(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${asset.name}');
886
853
  `;
887
- for (const component of entity.components) {
888
- switch (component.type) {
889
- case 'sprite': {
890
- const spriteId = component.properties?.spriteId;
891
- const asset = project.assets.find((a) => a.id === spriteId);
892
- if (asset) {
893
- const hasPhysics = entity.components.some((c) => c.type === 'rigidbody-2d' ||
894
- c.type === 'box-collider-2d' ||
895
- c.type === 'circle-collider-2d');
896
- if (hasPhysics) {
897
- code += ` const ${this.varName(entity.name)} = this.physics.add.sprite(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${asset.name}');\n`;
898
- }
899
- else {
900
- code += ` const ${this.varName(entity.name)} = this.add.sprite(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${asset.name}');\n`;
901
- }
902
- code += ` ${this.varName(entity.name)}.setScale(${entity.scale?.x ?? 1}, ${entity.scale?.y ?? 1});\n`;
903
- code += ` ${this.varName(entity.name)}.setRotation(${entity.rotation ?? 0});\n`;
904
- }
905
- break;
906
- }
907
- case 'ui-text': {
908
- code += ` const ${this.varName(entity.name)} = this.add.text(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${component.properties?.text || ''}', {
909
- fontSize: '${component.properties?.fontSize || 32}px',
910
- color: '${component.properties?.color || '#ffffff'}',
911
- });\n`;
912
- break;
913
- }
914
- case 'particle-system': {
915
- code += ` const ${this.varName(entity.name)}Particles = this.add.particles(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0});\n`;
916
- break;
917
- }
918
- case 'audio-source': {
919
- const clipId = component.properties?.clipId;
920
- const clip = project.assets.find((a) => a.id === clipId);
921
- if (clip && component.properties?.playOnAwake) {
922
- code += ` this.sound.play('${clip.name}', { loop: ${component.properties?.loop || false}, volume: ${component.properties?.volume || 1} });\n`;
923
- }
924
- break;
925
- }
926
854
  }
855
+ code += ` ${this.varName(entity.name)}.setScale(${entity.scale?.x ?? 1}, ${entity.scale?.y ?? 1});
856
+ `;
857
+ code += ` ${this.varName(entity.name)}.setRotation(${entity.rotation ?? 0});
858
+ `;
859
+ }
860
+ break;
927
861
  }
928
- // Process children
929
- if (entity.children) {
930
- for (const child of entity.children) {
931
- code += this.generateEntityCode(child, project, useTS);
932
- }
862
+ case "ui-text": {
863
+ code += ` const ${this.varName(entity.name)} = this.add.text(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0}, '${component.properties?.text || ""}', {
864
+ fontSize: '${component.properties?.fontSize || 32}px',
865
+ color: '${component.properties?.color || "#ffffff"}',
866
+ });
867
+ `;
868
+ break;
933
869
  }
934
- return code;
935
- }
936
- generateTilemapCode(tilemap, project) {
937
- const tilesetAsset = project.assets.find((a) => a.id === tilemap.tilesetId);
938
- if (!tilesetAsset) {
939
- return '';
870
+ case "particle-system": {
871
+ code += ` const ${this.varName(entity.name)}Particles = this.add.particles(${entity.position?.x ?? 0}, ${entity.position?.y ?? 0});
872
+ `;
873
+ break;
940
874
  }
941
- return `
942
- // Tilemap: ${tilemap.name}
943
- const ${this.varName(tilemap.name)}Map = this.make.tilemap({
944
- width: ${tilemap.width},
945
- height: ${tilemap.height},
946
- tileWidth: ${tilemap.tileSize},
947
- tileHeight: ${tilemap.tileSize}
948
- });
949
- const ${this.varName(tilemap.name)}Tileset = ${this.varName(tilemap.name)}Map.addTilesetImage('${tilesetAsset.name}');
875
+ case "audio-source": {
876
+ const clipId = component.properties?.clipId;
877
+ const clip = project.assets.find((a) => a.id === clipId);
878
+ if (clip && component.properties?.playOnAwake) {
879
+ code += ` this.sound.play('${clip.name}', { loop: ${component.properties?.loop || false}, volume: ${component.properties?.volume || 1} });
950
880
  `;
951
- }
952
- getUsedAssets(scene, project) {
953
- const assetIds = new Set();
954
- const collectFromEntity = (entity) => {
955
- for (const component of entity.components) {
956
- if (component.properties?.spriteId) {
957
- assetIds.add(component.properties.spriteId);
958
- }
959
- if (component.properties?.clipId) {
960
- assetIds.add(component.properties.clipId);
961
- }
962
- }
963
- if (entity.children) {
964
- entity.children.forEach(collectFromEntity);
965
- }
966
- };
967
- scene.entities.forEach(collectFromEntity);
968
- (scene.tilemaps ?? []).forEach((tm) => assetIds.add(tm.tilesetId));
969
- return project.assets.filter((a) => assetIds.has(a.id));
970
- }
971
- async exportScripts(project, options, _useTS) {
972
- for (const script of project.scripts) {
973
- try {
974
- const ast = this.graphToAST.convert(script);
975
- const result = this.tsExporter.export(ast, {
976
- includeDebugComments: options.debug,
977
- });
978
- for (const file of result.files) {
979
- this.addTextFile(`src/scripts/${file.path}`, file.content);
980
- }
981
- }
982
- catch (error) {
983
- this.addWarning('SCRIPT_EXPORT_ERROR', `Failed to export script "${script.name}": ${error}`);
984
- }
881
+ }
882
+ break;
985
883
  }
884
+ }
986
885
  }
987
- exportBundlerConfig(bundler, _useTS) {
988
- if (bundler === 'vite') {
989
- this.addTextFile('vite.config.ts', `import { defineConfig } from 'vite';
990
-
991
- export default defineConfig({
992
- base: './',
993
- build: {
994
- outDir: 'dist',
995
- },
996
- });
997
- `);
998
- }
886
+ if (entity.children) {
887
+ for (const child of entity.children) {
888
+ code += this.generateEntityCode(child, project, useTS);
889
+ }
999
890
  }
1000
- exportTSConfig() {
1001
- const tsconfig = {
1002
- compilerOptions: {
1003
- target: 'ES2020',
1004
- module: 'ESNext',
1005
- moduleResolution: 'bundler',
1006
- strict: true,
1007
- noEmit: true,
1008
- skipLibCheck: true,
1009
- lib: ['ES2020', 'DOM'],
1010
- },
1011
- include: ['src'],
1012
- };
1013
- this.addTextFile('tsconfig.json', JSON.stringify(tsconfig, null, 2));
891
+ return code;
892
+ }
893
+ generateTilemapCode(tilemap, project) {
894
+ const tilesetAsset = project.assets.find((a) => a.id === tilemap.tilesetId);
895
+ if (!tilesetAsset) {
896
+ return "";
1014
897
  }
1015
- sanitizeName(name) {
1016
- return name.replace(/[^a-zA-Z0-9]/g, '');
898
+ return `
899
+ // Tilemap: ${tilemap.name}
900
+ const ${this.varName(tilemap.name)}Map = this.make.tilemap({
901
+ width: ${tilemap.width},
902
+ height: ${tilemap.height},
903
+ tileWidth: ${tilemap.tileSize},
904
+ tileHeight: ${tilemap.tileSize}
905
+ });
906
+ const ${this.varName(tilemap.name)}Tileset = ${this.varName(tilemap.name)}Map.addTilesetImage('${tilesetAsset.name}');
907
+ `;
908
+ }
909
+ getUsedAssets(scene, project) {
910
+ const assetIds = /* @__PURE__ */ new Set();
911
+ const collectFromEntity = (entity) => {
912
+ for (const component of entity.components) {
913
+ if (component.properties?.spriteId) {
914
+ assetIds.add(component.properties.spriteId);
915
+ }
916
+ if (component.properties?.clipId) {
917
+ assetIds.add(component.properties.clipId);
918
+ }
919
+ }
920
+ if (entity.children) {
921
+ entity.children.forEach(collectFromEntity);
922
+ }
923
+ };
924
+ scene.entities.forEach(collectFromEntity);
925
+ (scene.tilemaps ?? []).forEach((tm) => assetIds.add(tm.tilesetId));
926
+ return project.assets.filter((a) => assetIds.has(a.id));
927
+ }
928
+ async exportScripts(project, options, _useTS) {
929
+ for (const script of project.scripts) {
930
+ try {
931
+ const ast = this.graphToAST.convert(script);
932
+ const result = this.tsExporter.export(ast, {
933
+ includeDebugComments: options.debug
934
+ });
935
+ for (const file of result.files) {
936
+ this.addTextFile(`src/scripts/${file.path}`, file.content);
937
+ }
938
+ } catch (error) {
939
+ this.addWarning(
940
+ "SCRIPT_EXPORT_ERROR",
941
+ `Failed to export script "${script.name}": ${error}`
942
+ );
943
+ }
1017
944
  }
1018
- varName(name) {
1019
- const sanitized = this.sanitizeName(name);
1020
- return sanitized.charAt(0).toLowerCase() + sanitized.slice(1);
945
+ }
946
+ exportBundlerConfig(bundler, _useTS) {
947
+ if (bundler === "vite") {
948
+ this.addTextFile(
949
+ "vite.config.ts",
950
+ `import { defineConfig } from 'vite';
951
+
952
+ export default defineConfig({
953
+ base: './',
954
+ build: {
955
+ outDir: 'dist',
956
+ },
957
+ });
958
+ `
959
+ );
1021
960
  }
961
+ }
962
+ exportTSConfig() {
963
+ const tsconfig = {
964
+ compilerOptions: {
965
+ target: "ES2020",
966
+ module: "ESNext",
967
+ moduleResolution: "bundler",
968
+ strict: true,
969
+ noEmit: true,
970
+ skipLibCheck: true,
971
+ lib: ["ES2020", "DOM"]
972
+ },
973
+ include: ["src"]
974
+ };
975
+ this.addTextFile("tsconfig.json", JSON.stringify(tsconfig, null, 2));
976
+ }
977
+ sanitizeName(name) {
978
+ return name.replace(/[^a-zA-Z0-9]/g, "");
979
+ }
980
+ varName(name) {
981
+ const sanitized = this.sanitizeName(name);
982
+ return sanitized.charAt(0).toLowerCase() + sanitized.slice(1);
983
+ }
1022
984
  }
1023
-
1024
- export { PhaserExporter, PixiJSExporter };
985
+ export {
986
+ PhaserExporter,
987
+ PixiJSExporter
988
+ };