@nice2dev/game-engine 1.3.14 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (434) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,1068 +1,970 @@
1
- 'use strict';
2
-
3
- /**
4
- * @file GodotImport.ts
5
- * @description Godot Engine Project Import for Nice2Dev Game Engine
6
- * PRO-1.9.1: Godot Project Import
7
- *
8
- * Features:
9
- * - .tscn (text scene) parsing
10
- * - .scn (binary scene) detection
11
- * - .tres resource parsing
12
- * - GDScript parser and AST extraction
13
- * - Node tree reconstruction
14
- * - Signal/connection mapping
15
- */
16
- // ============================================================
17
- // TSCN Parser
18
- // ============================================================
19
- /**
20
- * Parses Godot's text scene format (.tscn)
21
- */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
22
3
  function parseGodotScene(content) {
23
- const lines = content.split('\n');
24
- const scene = {
25
- header: { loadSteps: 0, format: 3 },
26
- extResources: [],
27
- subResources: [],
28
- rootNode: null,
29
- connections: [],
30
- editable: [],
31
- };
32
- let currentSection = 'header';
33
- let currentNode = null;
34
- const nodeMap = new Map();
35
- let currentSubResource = null;
36
- let multiLineValue = '';
37
- let multiLineKey = '';
38
- let inMultiLine = false;
39
- for (let i = 0; i < lines.length; i++) {
40
- let line = lines[i];
41
- // Handle multi-line values (strings, arrays, etc.)
42
- if (inMultiLine) {
43
- multiLineValue += '\n' + line;
44
- if (line.includes(']') || (line.includes('"') && line.trim().endsWith('"'))) {
45
- if (currentNode) {
46
- currentNode.properties[multiLineKey] = parseGodotValue(multiLineValue);
47
- }
48
- else if (currentSubResource) {
49
- currentSubResource.properties[multiLineKey] = parseGodotValue(multiLineValue);
50
- }
51
- inMultiLine = false;
52
- multiLineValue = '';
53
- multiLineKey = '';
54
- }
55
- continue;
56
- }
57
- line = line.trim();
58
- if (!line || line.startsWith(';')) {
59
- continue;
60
- }
61
- // Section headers
62
- if (line.startsWith('[')) {
63
- const sectionMatch = line.match(/^\[(\w+)(?:\s+(.+))?\]$/);
64
- if (sectionMatch) {
65
- const sectionType = sectionMatch[1];
66
- const sectionParams = sectionMatch[2] || '';
67
- switch (sectionType) {
68
- case 'gd_scene':
69
- currentSection = 'header';
70
- scene.header = parseGodotSceneHeader(sectionParams);
71
- break;
72
- case 'ext_resource':
73
- currentSection = 'ext_resource';
74
- scene.extResources.push(parseExtResource(sectionParams));
75
- break;
76
- case 'sub_resource':
77
- currentSection = 'sub_resource';
78
- currentSubResource = parseSubResourceHeader(sectionParams);
79
- scene.subResources.push(currentSubResource);
80
- break;
81
- case 'node':
82
- currentSection = 'node';
83
- currentNode = parseNodeHeader(sectionParams);
84
- if (!currentNode.parent) {
85
- // Root node
86
- scene.rootNode = currentNode;
87
- nodeMap.set('.', currentNode);
88
- }
89
- else {
90
- // Find parent and add as child
91
- const parentPath = currentNode.parent;
92
- const parentNode = nodeMap.get(parentPath);
93
- if (parentNode) {
94
- parentNode.children.push(currentNode);
95
- }
96
- // Calculate this node's path
97
- const nodePath = parentPath === '.' ? currentNode.name : `${parentPath}/${currentNode.name}`;
98
- nodeMap.set(nodePath, currentNode);
99
- }
100
- break;
101
- case 'connection':
102
- currentSection = 'connection';
103
- scene.connections.push(parseConnectionHeader(sectionParams));
104
- break;
105
- case 'editable': {
106
- currentSection = 'editable';
107
- const pathMatch = sectionParams.match(/path="([^"]+)"/);
108
- if (pathMatch) {
109
- scene.editable.push(pathMatch[1]);
110
- }
111
- break;
112
- }
113
- }
114
- continue;
115
- }
116
- }
117
- // Property assignment
118
- if (line.includes('=')) {
119
- const eqIndex = line.indexOf('=');
120
- const key = line.substring(0, eqIndex).trim();
121
- const valueStr = line.substring(eqIndex + 1).trim();
122
- // Check for multi-line value start
123
- if ((valueStr.startsWith('[') && !valueStr.includes(']')) ||
124
- (valueStr.startsWith('"') && !valueStr.endsWith('"') && valueStr.length > 1)) {
125
- inMultiLine = true;
126
- multiLineKey = key;
127
- multiLineValue = valueStr;
128
- continue;
129
- }
130
- const value = parseGodotValue(valueStr);
131
- if (currentSection === 'node' && currentNode) {
132
- currentNode.properties[key] = value;
4
+ const lines = content.split("\n");
5
+ const scene = {
6
+ header: { loadSteps: 0, format: 3 },
7
+ extResources: [],
8
+ subResources: [],
9
+ rootNode: null,
10
+ connections: [],
11
+ editable: []
12
+ };
13
+ let currentSection = "header";
14
+ let currentNode = null;
15
+ const nodeMap = /* @__PURE__ */ new Map();
16
+ let currentSubResource = null;
17
+ let multiLineValue = "";
18
+ let multiLineKey = "";
19
+ let inMultiLine = false;
20
+ for (let i = 0; i < lines.length; i++) {
21
+ let line = lines[i];
22
+ if (inMultiLine) {
23
+ multiLineValue += "\n" + line;
24
+ if (line.includes("]") || line.includes('"') && line.trim().endsWith('"')) {
25
+ if (currentNode) {
26
+ currentNode.properties[multiLineKey] = parseGodotValue(multiLineValue);
27
+ } else if (currentSubResource) {
28
+ currentSubResource.properties[multiLineKey] = parseGodotValue(multiLineValue);
29
+ }
30
+ inMultiLine = false;
31
+ multiLineValue = "";
32
+ multiLineKey = "";
33
+ }
34
+ continue;
35
+ }
36
+ line = line.trim();
37
+ if (!line || line.startsWith(";")) {
38
+ continue;
39
+ }
40
+ if (line.startsWith("[")) {
41
+ const sectionMatch = line.match(/^\[(\w+)(?:\s+(.+))?\]$/);
42
+ if (sectionMatch) {
43
+ const sectionType = sectionMatch[1];
44
+ const sectionParams = sectionMatch[2] || "";
45
+ switch (sectionType) {
46
+ case "gd_scene":
47
+ currentSection = "header";
48
+ scene.header = parseGodotSceneHeader(sectionParams);
49
+ break;
50
+ case "ext_resource":
51
+ currentSection = "ext_resource";
52
+ scene.extResources.push(parseExtResource(sectionParams));
53
+ break;
54
+ case "sub_resource":
55
+ currentSection = "sub_resource";
56
+ currentSubResource = parseSubResourceHeader(sectionParams);
57
+ scene.subResources.push(currentSubResource);
58
+ break;
59
+ case "node":
60
+ currentSection = "node";
61
+ currentNode = parseNodeHeader(sectionParams);
62
+ if (!currentNode.parent) {
63
+ scene.rootNode = currentNode;
64
+ nodeMap.set(".", currentNode);
65
+ } else {
66
+ const parentPath = currentNode.parent;
67
+ const parentNode = nodeMap.get(parentPath);
68
+ if (parentNode) {
69
+ parentNode.children.push(currentNode);
70
+ }
71
+ const nodePath = parentPath === "." ? currentNode.name : `${parentPath}/${currentNode.name}`;
72
+ nodeMap.set(nodePath, currentNode);
133
73
  }
134
- else if (currentSection === 'sub_resource' && currentSubResource) {
135
- currentSubResource.properties[key] = value;
74
+ break;
75
+ case "connection":
76
+ currentSection = "connection";
77
+ scene.connections.push(parseConnectionHeader(sectionParams));
78
+ break;
79
+ case "editable": {
80
+ currentSection = "editable";
81
+ const pathMatch = sectionParams.match(/path="([^"]+)"/);
82
+ if (pathMatch) {
83
+ scene.editable.push(pathMatch[1]);
136
84
  }
137
- }
138
- }
139
- return scene;
85
+ break;
86
+ }
87
+ }
88
+ continue;
89
+ }
90
+ }
91
+ if (line.includes("=")) {
92
+ const eqIndex = line.indexOf("=");
93
+ const key = line.substring(0, eqIndex).trim();
94
+ const valueStr = line.substring(eqIndex + 1).trim();
95
+ if (valueStr.startsWith("[") && !valueStr.includes("]") || valueStr.startsWith('"') && !valueStr.endsWith('"') && valueStr.length > 1) {
96
+ inMultiLine = true;
97
+ multiLineKey = key;
98
+ multiLineValue = valueStr;
99
+ continue;
100
+ }
101
+ const value = parseGodotValue(valueStr);
102
+ if (currentSection === "node" && currentNode) {
103
+ currentNode.properties[key] = value;
104
+ } else if (currentSection === "sub_resource" && currentSubResource) {
105
+ currentSubResource.properties[key] = value;
106
+ }
107
+ }
108
+ }
109
+ return scene;
140
110
  }
141
111
  function parseGodotSceneHeader(params) {
142
- const header = { loadSteps: 0, format: 3 };
143
- const loadStepsMatch = params.match(/load_steps=(\d+)/);
144
- if (loadStepsMatch) {
145
- header.loadSteps = parseInt(loadStepsMatch[1], 10);
146
- }
147
- const formatMatch = params.match(/format=(\d+)/);
148
- if (formatMatch) {
149
- header.format = parseInt(formatMatch[1], 10);
150
- }
151
- const uidMatch = params.match(/uid="([^"]+)"/);
152
- if (uidMatch) {
153
- header.uid = uidMatch[1];
154
- }
155
- const typeMatch = params.match(/type="([^"]+)"/);
156
- if (typeMatch) {
157
- header.type = typeMatch[1];
158
- }
159
- return header;
112
+ const header = { loadSteps: 0, format: 3 };
113
+ const loadStepsMatch = params.match(/load_steps=(\d+)/);
114
+ if (loadStepsMatch) {
115
+ header.loadSteps = parseInt(loadStepsMatch[1], 10);
116
+ }
117
+ const formatMatch = params.match(/format=(\d+)/);
118
+ if (formatMatch) {
119
+ header.format = parseInt(formatMatch[1], 10);
120
+ }
121
+ const uidMatch = params.match(/uid="([^"]+)"/);
122
+ if (uidMatch) {
123
+ header.uid = uidMatch[1];
124
+ }
125
+ const typeMatch = params.match(/type="([^"]+)"/);
126
+ if (typeMatch) {
127
+ header.type = typeMatch[1];
128
+ }
129
+ return header;
160
130
  }
161
131
  function parseExtResource(params) {
162
- const resource = { id: '', type: '', path: '' };
163
- const typeMatch = params.match(/type="([^"]+)"/);
164
- if (typeMatch) {
165
- resource.type = typeMatch[1];
166
- }
167
- const pathMatch = params.match(/path="([^"]+)"/);
168
- if (pathMatch) {
169
- resource.path = pathMatch[1];
170
- }
171
- const idMatch = params.match(/id="?([^"\s]+)"?/);
172
- if (idMatch) {
173
- resource.id = idMatch[1];
174
- }
175
- const uidMatch = params.match(/uid="([^"]+)"/);
176
- if (uidMatch) {
177
- resource.uid = uidMatch[1];
178
- }
179
- return resource;
132
+ const resource = { id: "", type: "", path: "" };
133
+ const typeMatch = params.match(/type="([^"]+)"/);
134
+ if (typeMatch) {
135
+ resource.type = typeMatch[1];
136
+ }
137
+ const pathMatch = params.match(/path="([^"]+)"/);
138
+ if (pathMatch) {
139
+ resource.path = pathMatch[1];
140
+ }
141
+ const idMatch = params.match(/id="?([^"\s]+)"?/);
142
+ if (idMatch) {
143
+ resource.id = idMatch[1];
144
+ }
145
+ const uidMatch = params.match(/uid="([^"]+)"/);
146
+ if (uidMatch) {
147
+ resource.uid = uidMatch[1];
148
+ }
149
+ return resource;
180
150
  }
181
151
  function parseSubResourceHeader(params) {
182
- const resource = { id: '', type: '', properties: {} };
183
- const typeMatch = params.match(/type="([^"]+)"/);
184
- if (typeMatch) {
185
- resource.type = typeMatch[1];
186
- }
187
- const idMatch = params.match(/id="?([^"\s]+)"?/);
188
- if (idMatch) {
189
- resource.id = idMatch[1];
190
- }
191
- return resource;
152
+ const resource = { id: "", type: "", properties: {} };
153
+ const typeMatch = params.match(/type="([^"]+)"/);
154
+ if (typeMatch) {
155
+ resource.type = typeMatch[1];
156
+ }
157
+ const idMatch = params.match(/id="?([^"\s]+)"?/);
158
+ if (idMatch) {
159
+ resource.id = idMatch[1];
160
+ }
161
+ return resource;
192
162
  }
193
163
  function parseNodeHeader(params) {
194
- const node = {
195
- name: '',
196
- type: 'Node',
197
- properties: {},
198
- children: [],
199
- };
200
- const nameMatch = params.match(/name="([^"]+)"/);
201
- if (nameMatch) {
202
- node.name = nameMatch[1];
203
- }
204
- const typeMatch = params.match(/type="([^"]+)"/);
205
- if (typeMatch) {
206
- node.type = typeMatch[1];
207
- }
208
- const parentMatch = params.match(/parent="([^"]+)"/);
209
- if (parentMatch) {
210
- node.parent = parentMatch[1];
211
- }
212
- const instanceMatch = params.match(/instance=ExtResource\(\s*"?([^")]+)"?\s*\)/);
213
- if (instanceMatch) {
214
- node.instance = instanceMatch[1];
215
- }
216
- const groupsMatch = params.match(/groups=\[([^\]]+)\]/);
217
- if (groupsMatch) {
218
- node.groups = groupsMatch[1].split(',').map((g) => g.trim().replace(/"/g, ''));
219
- }
220
- const indexMatch = params.match(/index="?(\d+)"?/);
221
- if (indexMatch) {
222
- node.index = parseInt(indexMatch[1], 10);
223
- }
224
- return node;
164
+ const node = {
165
+ name: "",
166
+ type: "Node",
167
+ properties: {},
168
+ children: []
169
+ };
170
+ const nameMatch = params.match(/name="([^"]+)"/);
171
+ if (nameMatch) {
172
+ node.name = nameMatch[1];
173
+ }
174
+ const typeMatch = params.match(/type="([^"]+)"/);
175
+ if (typeMatch) {
176
+ node.type = typeMatch[1];
177
+ }
178
+ const parentMatch = params.match(/parent="([^"]+)"/);
179
+ if (parentMatch) {
180
+ node.parent = parentMatch[1];
181
+ }
182
+ const instanceMatch = params.match(/instance=ExtResource\(\s*"?([^")]+)"?\s*\)/);
183
+ if (instanceMatch) {
184
+ node.instance = instanceMatch[1];
185
+ }
186
+ const groupsMatch = params.match(/groups=\[([^\]]+)\]/);
187
+ if (groupsMatch) {
188
+ node.groups = groupsMatch[1].split(",").map((g) => g.trim().replace(/"/g, ""));
189
+ }
190
+ const indexMatch = params.match(/index="?(\d+)"?/);
191
+ if (indexMatch) {
192
+ node.index = parseInt(indexMatch[1], 10);
193
+ }
194
+ return node;
225
195
  }
226
196
  function parseConnectionHeader(params) {
227
- const connection = {
228
- signal: '',
229
- from: '',
230
- to: '',
231
- method: '',
232
- };
233
- const signalMatch = params.match(/signal="([^"]+)"/);
234
- if (signalMatch) {
235
- connection.signal = signalMatch[1];
236
- }
237
- const fromMatch = params.match(/from="([^"]+)"/);
238
- if (fromMatch) {
239
- connection.from = fromMatch[1];
240
- }
241
- const toMatch = params.match(/to="([^"]+)"/);
242
- if (toMatch) {
243
- connection.to = toMatch[1];
244
- }
245
- const methodMatch = params.match(/method="([^"]+)"/);
246
- if (methodMatch) {
247
- connection.method = methodMatch[1];
248
- }
249
- const flagsMatch = params.match(/flags=(\d+)/);
250
- if (flagsMatch) {
251
- connection.flags = parseInt(flagsMatch[1], 10);
252
- }
253
- return connection;
197
+ const connection = {
198
+ signal: "",
199
+ from: "",
200
+ to: "",
201
+ method: ""
202
+ };
203
+ const signalMatch = params.match(/signal="([^"]+)"/);
204
+ if (signalMatch) {
205
+ connection.signal = signalMatch[1];
206
+ }
207
+ const fromMatch = params.match(/from="([^"]+)"/);
208
+ if (fromMatch) {
209
+ connection.from = fromMatch[1];
210
+ }
211
+ const toMatch = params.match(/to="([^"]+)"/);
212
+ if (toMatch) {
213
+ connection.to = toMatch[1];
214
+ }
215
+ const methodMatch = params.match(/method="([^"]+)"/);
216
+ if (methodMatch) {
217
+ connection.method = methodMatch[1];
218
+ }
219
+ const flagsMatch = params.match(/flags=(\d+)/);
220
+ if (flagsMatch) {
221
+ connection.flags = parseInt(flagsMatch[1], 10);
222
+ }
223
+ return connection;
254
224
  }
255
225
  function parseGodotValue(valueStr) {
256
- valueStr = valueStr.trim();
257
- // null
258
- if (valueStr === 'null') {
259
- return null;
260
- }
261
- // Boolean
262
- if (valueStr === 'true') {
263
- return true;
264
- }
265
- if (valueStr === 'false') {
266
- return false;
267
- }
268
- // Integer
269
- if (/^-?\d+$/.test(valueStr)) {
270
- return parseInt(valueStr, 10);
271
- }
272
- // Float
273
- if (/^-?\d+\.\d+$/.test(valueStr)) {
274
- return parseFloat(valueStr);
275
- }
276
- // String
277
- if (valueStr.startsWith('"') && valueStr.endsWith('"')) {
278
- return valueStr.slice(1, -1);
279
- }
280
- // Vector2
281
- const vec2Match = valueStr.match(/^Vector2\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/);
282
- if (vec2Match) {
283
- return { x: parseFloat(vec2Match[1]), y: parseFloat(vec2Match[2]) };
284
- }
285
- // Vector2i
286
- const vec2iMatch = valueStr.match(/^Vector2i\(\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/);
287
- if (vec2iMatch) {
288
- return { x: parseInt(vec2iMatch[1], 10), y: parseInt(vec2iMatch[2], 10) };
289
- }
290
- // Vector3
291
- const vec3Match = valueStr.match(/^Vector3\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/);
292
- if (vec3Match) {
293
- return {
294
- x: parseFloat(vec3Match[1]),
295
- y: parseFloat(vec3Match[2]),
296
- z: parseFloat(vec3Match[3]),
297
- };
298
- }
299
- // Vector3i
300
- const vec3iMatch = valueStr.match(/^Vector3i\(\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/);
301
- if (vec3iMatch) {
302
- return {
303
- x: parseInt(vec3iMatch[1], 10),
304
- y: parseInt(vec3iMatch[2], 10),
305
- z: parseInt(vec3iMatch[3], 10),
306
- };
307
- }
308
- // Color
309
- const colorMatch = valueStr.match(/^Color\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/);
310
- if (colorMatch) {
311
- return {
312
- r: parseFloat(colorMatch[1]),
313
- g: parseFloat(colorMatch[2]),
314
- b: parseFloat(colorMatch[3]),
315
- a: colorMatch[4] ? parseFloat(colorMatch[4]) : 1,
316
- };
317
- }
318
- // Rect2
319
- const rect2Match = valueStr.match(/^Rect2\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/);
320
- if (rect2Match) {
321
- return {
322
- x: parseFloat(rect2Match[1]),
323
- y: parseFloat(rect2Match[2]),
324
- width: parseFloat(rect2Match[3]),
325
- height: parseFloat(rect2Match[4]),
326
- };
327
- }
328
- // Transform2D
329
- const transform2dMatch = valueStr.match(/^Transform2D\(\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*\)$/);
330
- if (transform2dMatch) {
331
- return {
332
- type: 'Transform2D',
333
- x: { x: parseFloat(transform2dMatch[1]), y: parseFloat(transform2dMatch[2]) },
334
- y: { x: parseFloat(transform2dMatch[3]), y: parseFloat(transform2dMatch[4]) },
335
- origin: { x: parseFloat(transform2dMatch[5]), y: parseFloat(transform2dMatch[6]) },
336
- };
337
- }
338
- // Transform3D
339
- const transform3dMatch = valueStr.match(/^Transform3D\(([^)]+)\)$/);
340
- if (transform3dMatch) {
341
- const values = transform3dMatch[1].split(',').map((v) => parseFloat(v.trim()));
342
- if (values.length === 12) {
343
- return {
344
- type: 'Transform3D',
345
- basis: {
346
- x: { x: values[0], y: values[1], z: values[2] },
347
- y: { x: values[3], y: values[4], z: values[5] },
348
- z: { x: values[6], y: values[7], z: values[8] },
349
- },
350
- origin: { x: values[9], y: values[10], z: values[11] },
351
- };
352
- }
353
- }
354
- // NodePath
355
- const nodePathMatch = valueStr.match(/^NodePath\("([^"]*)"\)$/);
356
- if (nodePathMatch) {
357
- return { type: 'NodePath', path: nodePathMatch[1] };
358
- }
359
- // ExtResource reference
360
- const extResMatch = valueStr.match(/^ExtResource\(\s*"?([^")]+)"?\s*\)$/);
361
- if (extResMatch) {
362
- return { type: 'ExtResource', id: extResMatch[1] };
363
- }
364
- // SubResource reference
365
- const subResMatch = valueStr.match(/^SubResource\(\s*"?([^")]+)"?\s*\)$/);
366
- if (subResMatch) {
367
- return { type: 'SubResource', id: subResMatch[1] };
368
- }
369
- // Array
370
- if (valueStr.startsWith('[') && valueStr.endsWith(']')) {
371
- const inner = valueStr.slice(1, -1).trim();
372
- if (!inner) {
373
- return [];
374
- }
375
- // Simple split for basic arrays (doesn't handle nested structures well)
376
- return inner.split(/,(?![^(]*\))/).map((v) => parseGodotValue(v.trim()));
377
- }
378
- // Dictionary
379
- if (valueStr.startsWith('{') && valueStr.endsWith('}')) {
380
- // Simple dict parsing
381
- const inner = valueStr.slice(1, -1).trim();
382
- if (!inner) {
383
- return {};
384
- }
385
- const dict = {};
386
- // Match key: value pairs
387
- const pairRegex = /"([^"]+)":\s*([^,}]+)/g;
388
- let match;
389
- while ((match = pairRegex.exec(inner)) !== null) {
390
- dict[match[1]] = parseGodotValue(match[2].trim());
391
- }
392
- return dict;
393
- }
394
- // PackedStringArray
395
- const packedStrMatch = valueStr.match(/^PackedStringArray\(\s*([^)]*)\s*\)$/);
396
- if (packedStrMatch) {
397
- const inner = packedStrMatch[1].trim();
398
- if (!inner) {
399
- return [];
400
- }
401
- return inner.split(',').map((s) => s.trim().replace(/^"|"$/g, ''));
402
- }
403
- // PackedVector2Array
404
- const packedVec2Match = valueStr.match(/^PackedVector2Array\(\s*([^)]*)\s*\)$/);
405
- if (packedVec2Match) {
406
- const inner = packedVec2Match[1].trim();
407
- if (!inner) {
408
- return [];
409
- }
410
- const nums = inner.split(',').map((n) => parseFloat(n.trim()));
411
- const vectors = [];
412
- for (let i = 0; i < nums.length; i += 2) {
413
- vectors.push({ x: nums[i], y: nums[i + 1] });
414
- }
415
- return vectors;
416
- }
417
- // Return as-is for unknown types
418
- return valueStr;
226
+ valueStr = valueStr.trim();
227
+ if (valueStr === "null") {
228
+ return null;
229
+ }
230
+ if (valueStr === "true") {
231
+ return true;
232
+ }
233
+ if (valueStr === "false") {
234
+ return false;
235
+ }
236
+ if (/^-?\d+$/.test(valueStr)) {
237
+ return parseInt(valueStr, 10);
238
+ }
239
+ if (/^-?\d+\.\d+$/.test(valueStr)) {
240
+ return parseFloat(valueStr);
241
+ }
242
+ if (valueStr.startsWith('"') && valueStr.endsWith('"')) {
243
+ return valueStr.slice(1, -1);
244
+ }
245
+ const vec2Match = valueStr.match(/^Vector2\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/);
246
+ if (vec2Match) {
247
+ return { x: parseFloat(vec2Match[1]), y: parseFloat(vec2Match[2]) };
248
+ }
249
+ const vec2iMatch = valueStr.match(/^Vector2i\(\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/);
250
+ if (vec2iMatch) {
251
+ return { x: parseInt(vec2iMatch[1], 10), y: parseInt(vec2iMatch[2], 10) };
252
+ }
253
+ const vec3Match = valueStr.match(
254
+ /^Vector3\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)$/
255
+ );
256
+ if (vec3Match) {
257
+ return {
258
+ x: parseFloat(vec3Match[1]),
259
+ y: parseFloat(vec3Match[2]),
260
+ z: parseFloat(vec3Match[3])
261
+ };
262
+ }
263
+ const vec3iMatch = valueStr.match(/^Vector3i\(\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/);
264
+ if (vec3iMatch) {
265
+ return {
266
+ x: parseInt(vec3iMatch[1], 10),
267
+ y: parseInt(vec3iMatch[2], 10),
268
+ z: parseInt(vec3iMatch[3], 10)
269
+ };
270
+ }
271
+ const colorMatch = valueStr.match(
272
+ /^Color\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/
273
+ );
274
+ if (colorMatch) {
275
+ return {
276
+ r: parseFloat(colorMatch[1]),
277
+ g: parseFloat(colorMatch[2]),
278
+ b: parseFloat(colorMatch[3]),
279
+ a: colorMatch[4] ? parseFloat(colorMatch[4]) : 1
280
+ };
281
+ }
282
+ const rect2Match = valueStr.match(
283
+ /^Rect2\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/
284
+ );
285
+ if (rect2Match) {
286
+ return {
287
+ x: parseFloat(rect2Match[1]),
288
+ y: parseFloat(rect2Match[2]),
289
+ width: parseFloat(rect2Match[3]),
290
+ height: parseFloat(rect2Match[4])
291
+ };
292
+ }
293
+ const transform2dMatch = valueStr.match(
294
+ /^Transform2D\(\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*,\s*([\d.e+-]+)\s*\)$/
295
+ );
296
+ if (transform2dMatch) {
297
+ return {
298
+ type: "Transform2D",
299
+ x: { x: parseFloat(transform2dMatch[1]), y: parseFloat(transform2dMatch[2]) },
300
+ y: { x: parseFloat(transform2dMatch[3]), y: parseFloat(transform2dMatch[4]) },
301
+ origin: { x: parseFloat(transform2dMatch[5]), y: parseFloat(transform2dMatch[6]) }
302
+ };
303
+ }
304
+ const transform3dMatch = valueStr.match(/^Transform3D\(([^)]+)\)$/);
305
+ if (transform3dMatch) {
306
+ const values = transform3dMatch[1].split(",").map((v) => parseFloat(v.trim()));
307
+ if (values.length === 12) {
308
+ return {
309
+ type: "Transform3D",
310
+ basis: {
311
+ x: { x: values[0], y: values[1], z: values[2] },
312
+ y: { x: values[3], y: values[4], z: values[5] },
313
+ z: { x: values[6], y: values[7], z: values[8] }
314
+ },
315
+ origin: { x: values[9], y: values[10], z: values[11] }
316
+ };
317
+ }
318
+ }
319
+ const nodePathMatch = valueStr.match(/^NodePath\("([^"]*)"\)$/);
320
+ if (nodePathMatch) {
321
+ return { type: "NodePath", path: nodePathMatch[1] };
322
+ }
323
+ const extResMatch = valueStr.match(/^ExtResource\(\s*"?([^")]+)"?\s*\)$/);
324
+ if (extResMatch) {
325
+ return { type: "ExtResource", id: extResMatch[1] };
326
+ }
327
+ const subResMatch = valueStr.match(/^SubResource\(\s*"?([^")]+)"?\s*\)$/);
328
+ if (subResMatch) {
329
+ return { type: "SubResource", id: subResMatch[1] };
330
+ }
331
+ if (valueStr.startsWith("[") && valueStr.endsWith("]")) {
332
+ const inner = valueStr.slice(1, -1).trim();
333
+ if (!inner) {
334
+ return [];
335
+ }
336
+ return inner.split(/,(?![^(]*\))/).map((v) => parseGodotValue(v.trim()));
337
+ }
338
+ if (valueStr.startsWith("{") && valueStr.endsWith("}")) {
339
+ const inner = valueStr.slice(1, -1).trim();
340
+ if (!inner) {
341
+ return {};
342
+ }
343
+ const dict = {};
344
+ const pairRegex = /"([^"]+)":\s*([^,}]+)/g;
345
+ let match;
346
+ while ((match = pairRegex.exec(inner)) !== null) {
347
+ dict[match[1]] = parseGodotValue(match[2].trim());
348
+ }
349
+ return dict;
350
+ }
351
+ const packedStrMatch = valueStr.match(/^PackedStringArray\(\s*([^)]*)\s*\)$/);
352
+ if (packedStrMatch) {
353
+ const inner = packedStrMatch[1].trim();
354
+ if (!inner) {
355
+ return [];
356
+ }
357
+ return inner.split(",").map((s) => s.trim().replace(/^"|"$/g, ""));
358
+ }
359
+ const packedVec2Match = valueStr.match(/^PackedVector2Array\(\s*([^)]*)\s*\)$/);
360
+ if (packedVec2Match) {
361
+ const inner = packedVec2Match[1].trim();
362
+ if (!inner) {
363
+ return [];
364
+ }
365
+ const nums = inner.split(",").map((n) => parseFloat(n.trim()));
366
+ const vectors = [];
367
+ for (let i = 0; i < nums.length; i += 2) {
368
+ vectors.push({ x: nums[i], y: nums[i + 1] });
369
+ }
370
+ return vectors;
371
+ }
372
+ return valueStr;
419
373
  }
420
- // ============================================================
421
- // TRES Resource Parser
422
- // ============================================================
423
- /**
424
- * Parses Godot's text resource format (.tres)
425
- */
426
374
  function parseGodotResource(content) {
427
- const lines = content.split('\n');
428
- const resource = {
429
- header: { type: '', format: 3 },
430
- extResources: [],
431
- subResources: [],
432
- resource: { type: '', properties: {} },
433
- };
434
- let currentSection = 'header';
435
- let currentSubResource = null;
436
- for (let line of lines) {
437
- line = line.trim();
438
- if (!line || line.startsWith(';')) {
439
- continue;
440
- }
441
- // Section headers
442
- if (line.startsWith('[')) {
443
- const sectionMatch = line.match(/^\[(\w+)(?:\s+(.+))?\]$/);
444
- if (sectionMatch) {
445
- const sectionType = sectionMatch[1];
446
- const sectionParams = sectionMatch[2] || '';
447
- switch (sectionType) {
448
- case 'gd_resource':
449
- currentSection = 'header';
450
- resource.header = parseResourceHeader(sectionParams);
451
- break;
452
- case 'ext_resource':
453
- currentSection = 'ext_resource';
454
- resource.extResources.push(parseExtResource(sectionParams));
455
- break;
456
- case 'sub_resource':
457
- currentSection = 'sub_resource';
458
- currentSubResource = parseSubResourceHeader(sectionParams);
459
- resource.subResources.push(currentSubResource);
460
- break;
461
- case 'resource':
462
- currentSection = 'resource';
463
- break;
464
- }
465
- continue;
466
- }
467
- }
468
- // Property assignment
469
- if (line.includes('=')) {
470
- const eqIndex = line.indexOf('=');
471
- const key = line.substring(0, eqIndex).trim();
472
- const valueStr = line.substring(eqIndex + 1).trim();
473
- const value = parseGodotValue(valueStr);
474
- if (currentSection === 'resource') {
475
- resource.resource.properties[key] = value;
476
- }
477
- else if (currentSection === 'sub_resource' && currentSubResource) {
478
- currentSubResource.properties[key] = value;
479
- }
480
- }
481
- }
482
- resource.resource.type = resource.header.type;
483
- return resource;
375
+ const lines = content.split("\n");
376
+ const resource = {
377
+ header: { type: "", format: 3 },
378
+ extResources: [],
379
+ subResources: [],
380
+ resource: { type: "", properties: {} }
381
+ };
382
+ let currentSection = "header";
383
+ let currentSubResource = null;
384
+ for (let line of lines) {
385
+ line = line.trim();
386
+ if (!line || line.startsWith(";")) {
387
+ continue;
388
+ }
389
+ if (line.startsWith("[")) {
390
+ const sectionMatch = line.match(/^\[(\w+)(?:\s+(.+))?\]$/);
391
+ if (sectionMatch) {
392
+ const sectionType = sectionMatch[1];
393
+ const sectionParams = sectionMatch[2] || "";
394
+ switch (sectionType) {
395
+ case "gd_resource":
396
+ currentSection = "header";
397
+ resource.header = parseResourceHeader(sectionParams);
398
+ break;
399
+ case "ext_resource":
400
+ currentSection = "ext_resource";
401
+ resource.extResources.push(parseExtResource(sectionParams));
402
+ break;
403
+ case "sub_resource":
404
+ currentSection = "sub_resource";
405
+ currentSubResource = parseSubResourceHeader(sectionParams);
406
+ resource.subResources.push(currentSubResource);
407
+ break;
408
+ case "resource":
409
+ currentSection = "resource";
410
+ break;
411
+ }
412
+ continue;
413
+ }
414
+ }
415
+ if (line.includes("=")) {
416
+ const eqIndex = line.indexOf("=");
417
+ const key = line.substring(0, eqIndex).trim();
418
+ const valueStr = line.substring(eqIndex + 1).trim();
419
+ const value = parseGodotValue(valueStr);
420
+ if (currentSection === "resource") {
421
+ resource.resource.properties[key] = value;
422
+ } else if (currentSection === "sub_resource" && currentSubResource) {
423
+ currentSubResource.properties[key] = value;
424
+ }
425
+ }
426
+ }
427
+ resource.resource.type = resource.header.type;
428
+ return resource;
484
429
  }
485
430
  function parseResourceHeader(params) {
486
- const header = { type: '', format: 3 };
487
- const typeMatch = params.match(/type="([^"]+)"/);
488
- if (typeMatch) {
489
- header.type = typeMatch[1];
490
- }
491
- const loadStepsMatch = params.match(/load_steps=(\d+)/);
492
- if (loadStepsMatch) {
493
- header.loadSteps = parseInt(loadStepsMatch[1], 10);
494
- }
495
- const formatMatch = params.match(/format=(\d+)/);
496
- if (formatMatch) {
497
- header.format = parseInt(formatMatch[1], 10);
498
- }
499
- const uidMatch = params.match(/uid="([^"]+)"/);
500
- if (uidMatch) {
501
- header.uid = uidMatch[1];
502
- }
503
- return header;
431
+ const header = { type: "", format: 3 };
432
+ const typeMatch = params.match(/type="([^"]+)"/);
433
+ if (typeMatch) {
434
+ header.type = typeMatch[1];
435
+ }
436
+ const loadStepsMatch = params.match(/load_steps=(\d+)/);
437
+ if (loadStepsMatch) {
438
+ header.loadSteps = parseInt(loadStepsMatch[1], 10);
439
+ }
440
+ const formatMatch = params.match(/format=(\d+)/);
441
+ if (formatMatch) {
442
+ header.format = parseInt(formatMatch[1], 10);
443
+ }
444
+ const uidMatch = params.match(/uid="([^"]+)"/);
445
+ if (uidMatch) {
446
+ header.uid = uidMatch[1];
447
+ }
448
+ return header;
504
449
  }
505
- // ============================================================
506
- // GDScript Parser
507
- // ============================================================
508
- /**
509
- * Parses GDScript files and extracts structure
510
- */
511
- function parseGDScript(content, filePath = '') {
512
- const script = {
513
- path: filePath,
514
- extends: 'Node',
515
- isToolScript: false,
450
+ function parseGDScript(content, filePath = "") {
451
+ const script = {
452
+ path: filePath,
453
+ extends: "Node",
454
+ isToolScript: false,
455
+ signals: [],
456
+ enums: [],
457
+ constants: [],
458
+ exportVars: [],
459
+ onreadyVars: [],
460
+ variables: [],
461
+ functions: [],
462
+ innerClasses: [],
463
+ staticFunctions: [],
464
+ annotations: []
465
+ };
466
+ const lines = content.split("\n");
467
+ let currentFunction = null;
468
+ let functionIndent = 0;
469
+ let currentEnum = null;
470
+ let enumIndent = 0;
471
+ let pendingDocComment;
472
+ let pendingAnnotations = [];
473
+ for (let i = 0; i < lines.length; i++) {
474
+ const line = lines[i];
475
+ const trimmed = line.trim();
476
+ const indent = line.length - line.trimStart().length;
477
+ if (!trimmed) {
478
+ continue;
479
+ }
480
+ if (trimmed.startsWith("##")) {
481
+ pendingDocComment = (pendingDocComment || "") + trimmed.substring(2).trim() + "\n";
482
+ continue;
483
+ }
484
+ if (trimmed.startsWith("#")) {
485
+ continue;
486
+ }
487
+ if (currentFunction && indent > functionIndent) {
488
+ currentFunction.body += line + "\n";
489
+ continue;
490
+ } else if (currentFunction && indent <= functionIndent) {
491
+ currentFunction = null;
492
+ }
493
+ if (currentEnum && indent > enumIndent) {
494
+ const enumValMatch = trimmed.match(/^(\w+)(?:\s*=\s*(-?\d+))?,?$/);
495
+ if (enumValMatch) {
496
+ const name = enumValMatch[1];
497
+ const value = enumValMatch[2] ? parseInt(enumValMatch[2], 10) : Object.keys(currentEnum.values).length;
498
+ currentEnum.values[name] = value;
499
+ }
500
+ continue;
501
+ } else if (currentEnum && indent <= enumIndent) {
502
+ currentEnum = null;
503
+ }
504
+ if (trimmed === "@tool") {
505
+ script.isToolScript = true;
506
+ continue;
507
+ }
508
+ if (trimmed.startsWith("@")) {
509
+ const annotationMatch = trimmed.match(/^@(\w+)(?:\(([^)]*)\))?/);
510
+ if (annotationMatch) {
511
+ const annotation = { name: annotationMatch[1] };
512
+ if (annotationMatch[2]) {
513
+ annotation.arguments = annotationMatch[2].split(",").map((a) => a.trim());
514
+ }
515
+ pendingAnnotations.push(annotation);
516
+ if (annotation.name === "icon" && annotation.arguments?.[0]) {
517
+ script.iconPath = annotation.arguments[0].replace(/"/g, "");
518
+ }
519
+ }
520
+ continue;
521
+ }
522
+ const classNameMatch = trimmed.match(/^class_name\s+(\w+)/);
523
+ if (classNameMatch) {
524
+ script.className = classNameMatch[1];
525
+ script.classNameToken = classNameMatch[1];
526
+ continue;
527
+ }
528
+ const extendsMatch = trimmed.match(/^extends\s+(.+)$/);
529
+ if (extendsMatch) {
530
+ script.extends = extendsMatch[1].trim();
531
+ continue;
532
+ }
533
+ const signalMatch = trimmed.match(/^signal\s+(\w+)(?:\(([^)]*)\))?/);
534
+ if (signalMatch) {
535
+ const sig = {
536
+ name: signalMatch[1],
537
+ parameters: [],
538
+ documentation: pendingDocComment?.trim()
539
+ };
540
+ if (signalMatch[2]) {
541
+ sig.parameters = parseGDScriptParameters(signalMatch[2]);
542
+ }
543
+ script.signals.push(sig);
544
+ pendingDocComment = void 0;
545
+ continue;
546
+ }
547
+ const enumMatch = trimmed.match(/^enum\s+(\w+)\s*{?/);
548
+ if (enumMatch) {
549
+ currentEnum = {
550
+ name: enumMatch[1],
551
+ values: {},
552
+ documentation: pendingDocComment?.trim()
553
+ };
554
+ enumIndent = indent;
555
+ const inlineMatch = trimmed.match(/^enum\s+\w+\s*{([^}]+)}/);
556
+ if (inlineMatch) {
557
+ const entries = inlineMatch[1].split(",");
558
+ let nextVal = 0;
559
+ for (const entry of entries) {
560
+ const valMatch = entry.trim().match(/^(\w+)(?:\s*=\s*(-?\d+))?$/);
561
+ if (valMatch) {
562
+ const val = valMatch[2] ? parseInt(valMatch[2], 10) : nextVal;
563
+ currentEnum.values[valMatch[1]] = val;
564
+ nextVal = val + 1;
565
+ }
566
+ }
567
+ script.enums.push(currentEnum);
568
+ currentEnum = null;
569
+ } else {
570
+ script.enums.push(currentEnum);
571
+ }
572
+ pendingDocComment = void 0;
573
+ continue;
574
+ }
575
+ const constMatch = trimmed.match(/^const\s+(\w+)(?:\s*:\s*(\w+))?\s*=\s*(.+)$/);
576
+ if (constMatch) {
577
+ script.constants.push({
578
+ name: constMatch[1],
579
+ type: constMatch[2],
580
+ value: constMatch[3],
581
+ documentation: pendingDocComment?.trim()
582
+ });
583
+ pendingDocComment = void 0;
584
+ continue;
585
+ }
586
+ if (trimmed.startsWith("@export")) {
587
+ const exportAnnotations = [trimmed];
588
+ let j = i + 1;
589
+ while (j < lines.length && lines[j].trim().startsWith("@export")) {
590
+ exportAnnotations.push(lines[j].trim());
591
+ j++;
592
+ }
593
+ if (j < lines.length) {
594
+ const varLine = lines[j].trim();
595
+ const varMatch2 = varLine.match(/^var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
596
+ if (varMatch2) {
597
+ script.exportVars.push({
598
+ name: varMatch2[1],
599
+ type: varMatch2[2],
600
+ default: varMatch2[3],
601
+ exportAnnotations,
602
+ documentation: pendingDocComment?.trim()
603
+ });
604
+ i = j;
605
+ pendingDocComment = void 0;
606
+ pendingAnnotations = [];
607
+ }
608
+ }
609
+ continue;
610
+ }
611
+ const onreadyMatch = trimmed.match(/^@onready\s+var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
612
+ if (onreadyMatch) {
613
+ script.onreadyVars.push({
614
+ name: onreadyMatch[1],
615
+ type: onreadyMatch[2],
616
+ default: onreadyMatch[3],
617
+ documentation: pendingDocComment?.trim()
618
+ });
619
+ pendingDocComment = void 0;
620
+ continue;
621
+ }
622
+ const varMatch = trimmed.match(
623
+ /^var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?(?:\s*:\s*(?:get\s*=\s*(\w+))?(?:\s*,?\s*set\s*=\s*(\w+))?)?$/
624
+ );
625
+ if (varMatch) {
626
+ const variable = {
627
+ name: varMatch[1],
628
+ type: varMatch[2],
629
+ default: varMatch[3],
630
+ documentation: pendingDocComment?.trim()
631
+ };
632
+ if (varMatch[4] || varMatch[5]) {
633
+ variable.setget = {
634
+ getter: varMatch[4],
635
+ setter: varMatch[5]
636
+ };
637
+ }
638
+ script.variables.push(variable);
639
+ pendingDocComment = void 0;
640
+ continue;
641
+ }
642
+ const funcMatch = trimmed.match(
643
+ /^(?:(static)\s+)?func\s+(\w+)\(([^)]*)\)(?:\s*->\s*(\w+))?(?:\s*:\s*)?$/
644
+ );
645
+ if (funcMatch) {
646
+ currentFunction = {
647
+ name: funcMatch[2],
648
+ parameters: parseGDScriptParameters(funcMatch[3]),
649
+ returnType: funcMatch[4],
650
+ isVirtual: funcMatch[2].startsWith("_"),
651
+ isStatic: !!funcMatch[1],
652
+ isCoroutine: false,
653
+ body: "",
654
+ documentation: pendingDocComment?.trim()
655
+ };
656
+ functionIndent = indent;
657
+ if (currentFunction.isStatic) {
658
+ script.staticFunctions.push(currentFunction);
659
+ } else {
660
+ script.functions.push(currentFunction);
661
+ }
662
+ pendingDocComment = void 0;
663
+ continue;
664
+ }
665
+ const classMatch = trimmed.match(/^class\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s*:\s*)?$/);
666
+ if (classMatch) {
667
+ script.innerClasses.push({
668
+ name: classMatch[1],
669
+ extends: classMatch[2],
516
670
  signals: [],
517
- enums: [],
518
- constants: [],
519
- exportVars: [],
520
- onreadyVars: [],
521
671
  variables: [],
522
- functions: [],
523
- innerClasses: [],
524
- staticFunctions: [],
525
- annotations: [],
672
+ functions: []
673
+ });
674
+ pendingDocComment = void 0;
675
+ continue;
676
+ }
677
+ pendingDocComment = void 0;
678
+ pendingAnnotations = [];
679
+ }
680
+ return script;
681
+ }
682
+ function parseGDScriptParameters(paramString) {
683
+ if (!paramString.trim()) {
684
+ return [];
685
+ }
686
+ const params = [];
687
+ const parts = paramString.split(",");
688
+ for (const part of parts) {
689
+ const trimmed = part.trim();
690
+ const paramMatch = trimmed.match(/^(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
691
+ if (paramMatch) {
692
+ params.push({
693
+ name: paramMatch[1],
694
+ type: paramMatch[2],
695
+ default: paramMatch[3]
696
+ });
697
+ }
698
+ }
699
+ return params;
700
+ }
701
+ class GodotProjectImporter {
702
+ constructor(callbacks) {
703
+ this.projectPath = "";
704
+ this.config = null;
705
+ this.scenes = /* @__PURE__ */ new Map();
706
+ this.resources = /* @__PURE__ */ new Map();
707
+ this.scripts = /* @__PURE__ */ new Map();
708
+ this.callbacks = {};
709
+ if (callbacks) {
710
+ this.callbacks = callbacks;
711
+ }
712
+ }
713
+ /**
714
+ * Parses project.godot configuration file
715
+ */
716
+ parseProjectConfig(content) {
717
+ const config = {
718
+ configVersion: 5,
719
+ name: "Untitled",
720
+ features: [],
721
+ autoloads: {},
722
+ inputMap: {},
723
+ layers: { layer2d: {}, layer3d: {} }
526
724
  };
527
- const lines = content.split('\n');
528
- let currentFunction = null;
529
- let functionIndent = 0;
530
- let currentEnum = null;
531
- let enumIndent = 0;
532
- let pendingDocComment;
533
- let pendingAnnotations = [];
534
- for (let i = 0; i < lines.length; i++) {
535
- const line = lines[i];
536
- const trimmed = line.trim();
537
- const indent = line.length - line.trimStart().length;
538
- // Skip empty lines and comments (but capture doc comments)
539
- if (!trimmed) {
540
- continue;
541
- }
542
- if (trimmed.startsWith('##')) {
543
- pendingDocComment = (pendingDocComment || '') + trimmed.substring(2).trim() + '\n';
544
- continue;
545
- }
546
- if (trimmed.startsWith('#')) {
547
- continue;
548
- }
549
- // Handle being inside function body
550
- if (currentFunction && indent > functionIndent) {
551
- currentFunction.body += line + '\n';
552
- continue;
553
- }
554
- else if (currentFunction && indent <= functionIndent) {
555
- currentFunction = null;
556
- }
557
- // Handle being inside enum
558
- if (currentEnum && indent > enumIndent) {
559
- // Parse enum value
560
- const enumValMatch = trimmed.match(/^(\w+)(?:\s*=\s*(-?\d+))?,?$/);
561
- if (enumValMatch) {
562
- const name = enumValMatch[1];
563
- const value = enumValMatch[2]
564
- ? parseInt(enumValMatch[2], 10)
565
- : Object.keys(currentEnum.values).length;
566
- currentEnum.values[name] = value;
725
+ let currentSection = "";
726
+ const lines = content.split("\n");
727
+ for (let line of lines) {
728
+ line = line.trim();
729
+ if (!line || line.startsWith(";")) {
730
+ continue;
731
+ }
732
+ if (line.startsWith("[")) {
733
+ const match = line.match(/^\[(.+)\]$/);
734
+ if (match) {
735
+ currentSection = match[1];
736
+ }
737
+ continue;
738
+ }
739
+ if (line.includes("=")) {
740
+ const eqIndex = line.indexOf("=");
741
+ const key = line.substring(0, eqIndex).trim();
742
+ const valueStr = line.substring(eqIndex + 1).trim();
743
+ const value = parseGodotValue(valueStr);
744
+ switch (currentSection) {
745
+ case "":
746
+ if (key === "config_version") {
747
+ config.configVersion = value;
567
748
  }
568
- continue;
569
- }
570
- else if (currentEnum && indent <= enumIndent) {
571
- currentEnum = null;
572
- }
573
- // @tool annotation
574
- if (trimmed === '@tool') {
575
- script.isToolScript = true;
576
- continue;
577
- }
578
- // Annotations
579
- if (trimmed.startsWith('@')) {
580
- const annotationMatch = trimmed.match(/^@(\w+)(?:\(([^)]*)\))?/);
581
- if (annotationMatch) {
582
- const annotation = { name: annotationMatch[1] };
583
- if (annotationMatch[2]) {
584
- annotation.arguments = annotationMatch[2].split(',').map((a) => a.trim());
585
- }
586
- pendingAnnotations.push(annotation);
587
- // Handle @icon specifically
588
- if (annotation.name === 'icon' && annotation.arguments?.[0]) {
589
- script.iconPath = annotation.arguments[0].replace(/"/g, '');
590
- }
749
+ break;
750
+ case "application":
751
+ if (key === "config/name") {
752
+ config.name = value;
591
753
  }
592
- continue;
593
- }
594
- // class_name
595
- const classNameMatch = trimmed.match(/^class_name\s+(\w+)/);
596
- if (classNameMatch) {
597
- script.className = classNameMatch[1];
598
- script.classNameToken = classNameMatch[1];
599
- continue;
600
- }
601
- // extends
602
- const extendsMatch = trimmed.match(/^extends\s+(.+)$/);
603
- if (extendsMatch) {
604
- script.extends = extendsMatch[1].trim();
605
- continue;
606
- }
607
- // signal
608
- const signalMatch = trimmed.match(/^signal\s+(\w+)(?:\(([^)]*)\))?/);
609
- if (signalMatch) {
610
- const sig = {
611
- name: signalMatch[1],
612
- parameters: [],
613
- documentation: pendingDocComment?.trim(),
614
- };
615
- if (signalMatch[2]) {
616
- sig.parameters = parseGDScriptParameters(signalMatch[2]);
754
+ if (key === "config/features") {
755
+ config.features = value;
617
756
  }
618
- script.signals.push(sig);
619
- pendingDocComment = undefined;
620
- continue;
621
- }
622
- // enum
623
- const enumMatch = trimmed.match(/^enum\s+(\w+)\s*{?/);
624
- if (enumMatch) {
625
- currentEnum = {
626
- name: enumMatch[1],
627
- values: {},
628
- documentation: pendingDocComment?.trim(),
629
- };
630
- enumIndent = indent;
631
- // Check for single-line enum
632
- const inlineMatch = trimmed.match(/^enum\s+\w+\s*{([^}]+)}/);
633
- if (inlineMatch) {
634
- const entries = inlineMatch[1].split(',');
635
- let nextVal = 0;
636
- for (const entry of entries) {
637
- const valMatch = entry.trim().match(/^(\w+)(?:\s*=\s*(-?\d+))?$/);
638
- if (valMatch) {
639
- const val = valMatch[2] ? parseInt(valMatch[2], 10) : nextVal;
640
- currentEnum.values[valMatch[1]] = val;
641
- nextVal = val + 1;
642
- }
643
- }
644
- script.enums.push(currentEnum);
645
- currentEnum = null;
757
+ if (key === "config/icon") {
758
+ config.icon = value;
646
759
  }
647
- else {
648
- script.enums.push(currentEnum);
760
+ if (key === "run/main_scene") {
761
+ config.mainScene = value;
649
762
  }
650
- pendingDocComment = undefined;
651
- continue;
652
- }
653
- // const
654
- const constMatch = trimmed.match(/^const\s+(\w+)(?:\s*:\s*(\w+))?\s*=\s*(.+)$/);
655
- if (constMatch) {
656
- script.constants.push({
657
- name: constMatch[1],
658
- type: constMatch[2],
659
- value: constMatch[3],
660
- documentation: pendingDocComment?.trim(),
661
- });
662
- pendingDocComment = undefined;
663
- continue;
664
- }
665
- // @export var
666
- if (trimmed.startsWith('@export')) {
667
- // This is an export annotation, the var should follow
668
- const exportAnnotations = [trimmed];
669
- // Look for subsequent export annotations or the var line
670
- let j = i + 1;
671
- while (j < lines.length && lines[j].trim().startsWith('@export')) {
672
- exportAnnotations.push(lines[j].trim());
673
- j++;
763
+ break;
764
+ case "autoload": {
765
+ const autoloadMatch = key.match(/^(.+)$/);
766
+ if (autoloadMatch) {
767
+ const autoloadPath = value.replace(/^\*/, "");
768
+ config.autoloads[autoloadMatch[1]] = autoloadPath;
674
769
  }
675
- if (j < lines.length) {
676
- const varLine = lines[j].trim();
677
- const varMatch = varLine.match(/^var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
678
- if (varMatch) {
679
- script.exportVars.push({
680
- name: varMatch[1],
681
- type: varMatch[2],
682
- default: varMatch[3],
683
- exportAnnotations: exportAnnotations,
684
- documentation: pendingDocComment?.trim(),
685
- });
686
- i = j; // Skip to after the var line
687
- pendingDocComment = undefined;
688
- pendingAnnotations = [];
689
- }
770
+ break;
771
+ }
772
+ case "input": {
773
+ const inputMatch = key.match(/^(.+)$/);
774
+ if (inputMatch) {
775
+ const inputValue = value;
776
+ config.inputMap[inputMatch[1]] = {
777
+ deadzone: inputValue.deadzone ?? 0.5,
778
+ events: inputValue.events ?? []
779
+ };
690
780
  }
691
- continue;
692
- }
693
- // @onready var
694
- const onreadyMatch = trimmed.match(/^@onready\s+var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
695
- if (onreadyMatch) {
696
- script.onreadyVars.push({
697
- name: onreadyMatch[1],
698
- type: onreadyMatch[2],
699
- default: onreadyMatch[3],
700
- documentation: pendingDocComment?.trim(),
701
- });
702
- pendingDocComment = undefined;
703
- continue;
704
- }
705
- // Regular var
706
- const varMatch = trimmed.match(/^var\s+(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?(?:\s*:\s*(?:get\s*=\s*(\w+))?(?:\s*,?\s*set\s*=\s*(\w+))?)?$/);
707
- if (varMatch) {
708
- const variable = {
709
- name: varMatch[1],
710
- type: varMatch[2],
711
- default: varMatch[3],
712
- documentation: pendingDocComment?.trim(),
713
- };
714
- if (varMatch[4] || varMatch[5]) {
715
- variable.setget = {
716
- getter: varMatch[4],
717
- setter: varMatch[5],
718
- };
781
+ break;
782
+ }
783
+ case "layer_names":
784
+ if (key.startsWith("2d_physics/layer_")) {
785
+ const layerNum = parseInt(key.split("_").pop(), 10);
786
+ config.layers.layer2d[value] = layerNum;
719
787
  }
720
- script.variables.push(variable);
721
- pendingDocComment = undefined;
722
- continue;
723
- }
724
- // Function
725
- const funcMatch = trimmed.match(/^(?:(static)\s+)?func\s+(\w+)\(([^)]*)\)(?:\s*->\s*(\w+))?(?:\s*:\s*)?$/);
726
- if (funcMatch) {
727
- currentFunction = {
728
- name: funcMatch[2],
729
- parameters: parseGDScriptParameters(funcMatch[3]),
730
- returnType: funcMatch[4],
731
- isVirtual: funcMatch[2].startsWith('_'),
732
- isStatic: !!funcMatch[1],
733
- isCoroutine: false,
734
- body: '',
735
- documentation: pendingDocComment?.trim(),
736
- };
737
- functionIndent = indent;
738
- if (currentFunction.isStatic) {
739
- script.staticFunctions.push(currentFunction);
788
+ if (key.startsWith("3d_physics/layer_")) {
789
+ const layerNum = parseInt(key.split("_").pop(), 10);
790
+ config.layers.layer3d[value] = layerNum;
740
791
  }
741
- else {
742
- script.functions.push(currentFunction);
743
- }
744
- pendingDocComment = undefined;
745
- continue;
746
- }
747
- // Inner class
748
- const classMatch = trimmed.match(/^class\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s*:\s*)?$/);
749
- if (classMatch) {
750
- script.innerClasses.push({
751
- name: classMatch[1],
752
- extends: classMatch[2],
753
- signals: [],
754
- variables: [],
755
- functions: [],
756
- });
757
- pendingDocComment = undefined;
758
- continue;
759
- }
760
- pendingDocComment = undefined;
761
- pendingAnnotations = [];
762
- }
792
+ break;
793
+ }
794
+ }
795
+ }
796
+ this.config = config;
797
+ return config;
798
+ }
799
+ /**
800
+ * Imports a scene file and all its dependencies
801
+ */
802
+ async importScene(content, filePath) {
803
+ const scene = parseGodotScene(content);
804
+ this.scenes.set(filePath, scene);
805
+ this.callbacks.onSceneParsed?.(scene);
806
+ return this.convertSceneToImported(scene, filePath);
807
+ }
808
+ /**
809
+ * Imports a resource file
810
+ */
811
+ async importResource(content, filePath) {
812
+ const resource = parseGodotResource(content);
813
+ this.resources.set(filePath, resource);
814
+ this.callbacks.onResourceParsed?.(resource);
815
+ return resource;
816
+ }
817
+ /**
818
+ * Imports a GDScript file
819
+ */
820
+ async importScript(content, filePath) {
821
+ const script = parseGDScript(content, filePath);
822
+ this.scripts.set(filePath, script);
823
+ this.callbacks.onScriptParsed?.(script);
763
824
  return script;
825
+ }
826
+ convertSceneToImported(scene, filePath) {
827
+ const imported = {
828
+ name: filePath.split("/").pop()?.replace(".tscn", "") ?? "Scene",
829
+ path: filePath,
830
+ nodes: [],
831
+ rootNode: null,
832
+ connections: scene.connections,
833
+ resources: /* @__PURE__ */ new Map()
834
+ };
835
+ for (const extRes of scene.extResources) {
836
+ imported.resources.set(String(extRes.id), extRes);
837
+ }
838
+ if (scene.rootNode) {
839
+ imported.rootNode = this.convertNode(scene.rootNode, imported.resources);
840
+ imported.nodes = this.flattenNodes(imported.rootNode);
841
+ }
842
+ return imported;
843
+ }
844
+ convertNode(node, resources, parentId) {
845
+ const id = parentId ? `${parentId}/${node.name}` : node.name;
846
+ const imported = {
847
+ id,
848
+ name: node.name,
849
+ type: node.type,
850
+ parentId,
851
+ properties: { ...node.properties },
852
+ children: [],
853
+ groups: node.groups ?? []
854
+ };
855
+ if (node.properties.position) {
856
+ imported.position = node.properties.position;
857
+ }
858
+ if (node.properties.global_position) {
859
+ imported.position = node.properties.global_position;
860
+ }
861
+ if (node.properties.rotation) {
862
+ imported.rotation = node.properties.rotation;
863
+ }
864
+ if (node.properties.scale) {
865
+ imported.scale = node.properties.scale;
866
+ }
867
+ if (node.properties.transform) {
868
+ const t = node.properties.transform;
869
+ imported.position = t.origin;
870
+ }
871
+ if (node.script) {
872
+ const scriptRes = resources.get(String(node.script));
873
+ if (scriptRes) {
874
+ const cachedScript = this.scripts.get(scriptRes.path);
875
+ if (cachedScript) {
876
+ imported.script = cachedScript;
877
+ }
878
+ }
879
+ }
880
+ for (const child of node.children) {
881
+ imported.children.push(this.convertNode(child, resources, id));
882
+ }
883
+ return imported;
884
+ }
885
+ flattenNodes(node) {
886
+ const nodes = [node];
887
+ for (const child of node.children) {
888
+ nodes.push(...this.flattenNodes(child));
889
+ }
890
+ return nodes;
891
+ }
892
+ /**
893
+ * Gets all imported data
894
+ */
895
+ getImportedData() {
896
+ return {
897
+ config: this.config,
898
+ scenes: this.scenes,
899
+ resources: this.resources,
900
+ scripts: this.scripts
901
+ };
902
+ }
903
+ setCallbacks(callbacks) {
904
+ this.callbacks = { ...this.callbacks, ...callbacks };
905
+ }
764
906
  }
765
- function parseGDScriptParameters(paramString) {
766
- if (!paramString.trim()) {
767
- return [];
768
- }
769
- const params = [];
770
- const parts = paramString.split(',');
771
- for (const part of parts) {
772
- const trimmed = part.trim();
773
- const paramMatch = trimmed.match(/^(\w+)(?:\s*:\s*(\w+))?(?:\s*=\s*(.+))?$/);
774
- if (paramMatch) {
775
- params.push({
776
- name: paramMatch[1],
777
- type: paramMatch[2],
778
- default: paramMatch[3],
779
- });
780
- }
781
- }
782
- return params;
783
- }
784
- class GodotProjectImporter {
785
- constructor(callbacks) {
786
- this.projectPath = '';
787
- this.config = null;
788
- this.scenes = new Map();
789
- this.resources = new Map();
790
- this.scripts = new Map();
791
- this.callbacks = {};
792
- if (callbacks) {
793
- this.callbacks = callbacks;
794
- }
795
- }
796
- /**
797
- * Parses project.godot configuration file
798
- */
799
- parseProjectConfig(content) {
800
- const config = {
801
- configVersion: 5,
802
- name: 'Untitled',
803
- features: [],
804
- autoloads: {},
805
- inputMap: {},
806
- layers: { layer2d: {}, layer3d: {} },
807
- };
808
- let currentSection = '';
809
- const lines = content.split('\n');
810
- for (let line of lines) {
811
- line = line.trim();
812
- if (!line || line.startsWith(';')) {
813
- continue;
814
- }
815
- // Section header
816
- if (line.startsWith('[')) {
817
- const match = line.match(/^\[(.+)\]$/);
818
- if (match) {
819
- currentSection = match[1];
820
- }
821
- continue;
822
- }
823
- // Key-value pair
824
- if (line.includes('=')) {
825
- const eqIndex = line.indexOf('=');
826
- const key = line.substring(0, eqIndex).trim();
827
- const valueStr = line.substring(eqIndex + 1).trim();
828
- const value = parseGodotValue(valueStr);
829
- switch (currentSection) {
830
- case '':
831
- if (key === 'config_version') {
832
- config.configVersion = value;
833
- }
834
- break;
835
- case 'application':
836
- if (key === 'config/name') {
837
- config.name = value;
838
- }
839
- if (key === 'config/features') {
840
- config.features = value;
841
- }
842
- if (key === 'config/icon') {
843
- config.icon = value;
844
- }
845
- if (key === 'run/main_scene') {
846
- config.mainScene = value;
847
- }
848
- break;
849
- case 'autoload': {
850
- const autoloadMatch = key.match(/^(.+)$/);
851
- if (autoloadMatch) {
852
- const autoloadPath = value.replace(/^\*/, '');
853
- config.autoloads[autoloadMatch[1]] = autoloadPath;
854
- }
855
- break;
856
- }
857
- case 'input': {
858
- const inputMatch = key.match(/^(.+)$/);
859
- if (inputMatch) {
860
- const inputValue = value;
861
- config.inputMap[inputMatch[1]] = {
862
- deadzone: inputValue.deadzone ?? 0.5,
863
- events: inputValue.events ?? [],
864
- };
865
- }
866
- break;
867
- }
868
- case 'layer_names':
869
- if (key.startsWith('2d_physics/layer_')) {
870
- const layerNum = parseInt(key.split('_').pop(), 10);
871
- config.layers.layer2d[value] = layerNum;
872
- }
873
- if (key.startsWith('3d_physics/layer_')) {
874
- const layerNum = parseInt(key.split('_').pop(), 10);
875
- config.layers.layer3d[value] = layerNum;
876
- }
877
- break;
878
- }
879
- }
880
- }
881
- this.config = config;
882
- return config;
883
- }
884
- /**
885
- * Imports a scene file and all its dependencies
886
- */
887
- async importScene(content, filePath) {
888
- const scene = parseGodotScene(content);
889
- this.scenes.set(filePath, scene);
890
- this.callbacks.onSceneParsed?.(scene);
891
- return this.convertSceneToImported(scene, filePath);
892
- }
893
- /**
894
- * Imports a resource file
895
- */
896
- async importResource(content, filePath) {
897
- const resource = parseGodotResource(content);
898
- this.resources.set(filePath, resource);
899
- this.callbacks.onResourceParsed?.(resource);
900
- return resource;
901
- }
902
- /**
903
- * Imports a GDScript file
904
- */
905
- async importScript(content, filePath) {
906
- const script = parseGDScript(content, filePath);
907
- this.scripts.set(filePath, script);
908
- this.callbacks.onScriptParsed?.(script);
909
- return script;
910
- }
911
- convertSceneToImported(scene, filePath) {
912
- const imported = {
913
- name: filePath.split('/').pop()?.replace('.tscn', '') ?? 'Scene',
914
- path: filePath,
915
- nodes: [],
916
- rootNode: null,
917
- connections: scene.connections,
918
- resources: new Map(),
919
- };
920
- // Build resource map
921
- for (const extRes of scene.extResources) {
922
- imported.resources.set(String(extRes.id), extRes);
923
- }
924
- // Convert nodes
925
- if (scene.rootNode) {
926
- imported.rootNode = this.convertNode(scene.rootNode, imported.resources);
927
- imported.nodes = this.flattenNodes(imported.rootNode);
928
- }
929
- return imported;
930
- }
931
- convertNode(node, resources, parentId) {
932
- const id = parentId ? `${parentId}/${node.name}` : node.name;
933
- const imported = {
934
- id,
935
- name: node.name,
936
- type: node.type,
937
- parentId,
938
- properties: { ...node.properties },
939
- children: [],
940
- groups: node.groups ?? [],
941
- };
942
- // Extract position/rotation/scale from properties
943
- if (node.properties.position) {
944
- imported.position = node.properties.position;
945
- }
946
- if (node.properties.global_position) {
947
- imported.position = node.properties.global_position;
948
- }
949
- if (node.properties.rotation) {
950
- imported.rotation = node.properties.rotation;
951
- }
952
- if (node.properties.scale) {
953
- imported.scale = node.properties.scale;
954
- }
955
- // 3D transforms
956
- if (node.properties.transform) {
957
- const t = node.properties.transform;
958
- imported.position = t.origin;
959
- }
960
- // Resolve script reference
961
- if (node.script) {
962
- const scriptRes = resources.get(String(node.script));
963
- if (scriptRes) {
964
- const cachedScript = this.scripts.get(scriptRes.path);
965
- if (cachedScript) {
966
- imported.script = cachedScript;
967
- }
968
- }
969
- }
970
- // Convert children
971
- for (const child of node.children) {
972
- imported.children.push(this.convertNode(child, resources, id));
973
- }
974
- return imported;
975
- }
976
- flattenNodes(node) {
977
- const nodes = [node];
978
- for (const child of node.children) {
979
- nodes.push(...this.flattenNodes(child));
980
- }
981
- return nodes;
982
- }
983
- /**
984
- * Gets all imported data
985
- */
986
- getImportedData() {
987
- return {
988
- config: this.config,
989
- scenes: this.scenes,
990
- resources: this.resources,
991
- scripts: this.scripts,
992
- };
993
- }
994
- setCallbacks(callbacks) {
995
- this.callbacks = { ...this.callbacks, ...callbacks };
996
- }
997
- }
998
- // ============================================================
999
- // Node Type Mapping
1000
- // ============================================================
1001
907
  const GODOT_NODE_MAPPING = {
1002
- // 2D Nodes
1003
- Node2D: 'Entity2D',
1004
- Sprite2D: 'Sprite',
1005
- AnimatedSprite2D: 'AnimatedSprite',
1006
- Camera2D: 'Camera2D',
1007
- CharacterBody2D: 'KinematicBody2D',
1008
- RigidBody2D: 'RigidBody2D',
1009
- StaticBody2D: 'StaticBody2D',
1010
- Area2D: 'Area2D',
1011
- CollisionShape2D: 'CollisionShape2D',
1012
- TileMap: 'TileMap',
1013
- TileMapLayer: 'TileMapLayer',
1014
- GPUParticles2D: 'ParticleEmitter2D',
1015
- CPUParticles2D: 'ParticleEmitter2D',
1016
- NavigationAgent2D: 'NavigationAgent2D',
1017
- AudioStreamPlayer2D: 'AudioSource2D',
1018
- // 3D Nodes
1019
- Node3D: 'Entity3D',
1020
- MeshInstance3D: 'MeshRenderer',
1021
- Camera3D: 'Camera3D',
1022
- CharacterBody3D: 'KinematicBody3D',
1023
- RigidBody3D: 'RigidBody3D',
1024
- StaticBody3D: 'StaticBody3D',
1025
- Area3D: 'Area3D',
1026
- CollisionShape3D: 'CollisionShape3D',
1027
- DirectionalLight3D: 'DirectionalLight',
1028
- OmniLight3D: 'PointLight',
1029
- SpotLight3D: 'SpotLight',
1030
- GPUParticles3D: 'ParticleEmitter3D',
1031
- CPUParticles3D: 'ParticleEmitter3D',
1032
- NavigationAgent3D: 'NavigationAgent3D',
1033
- AudioStreamPlayer3D: 'AudioSource3D',
1034
- WorldEnvironment: 'Environment',
1035
- // Audio
1036
- AudioStreamPlayer: 'AudioSource',
1037
- // Animation
1038
- AnimationPlayer: 'AnimationPlayer',
1039
- AnimationTree: 'AnimationTree',
1040
- // UI
1041
- Control: 'UIElement',
1042
- Button: 'UIButton',
1043
- Label: 'UILabel',
1044
- TextureRect: 'UIImage',
1045
- Panel: 'UIPanel',
1046
- VBoxContainer: 'UIVBox',
1047
- HBoxContainer: 'UIHBox',
1048
- GridContainer: 'UIGrid',
1049
- LineEdit: 'UIInput',
1050
- TextEdit: 'UITextArea',
1051
- ProgressBar: 'UIProgressBar',
1052
- Slider: 'UISlider',
1053
- TabContainer: 'UITabs',
1054
- CanvasLayer: 'UILayer',
1055
- // Other
1056
- Timer: 'Timer',
1057
- Node: 'Entity',
908
+ // 2D Nodes
909
+ Node2D: "Entity2D",
910
+ Sprite2D: "Sprite",
911
+ AnimatedSprite2D: "AnimatedSprite",
912
+ Camera2D: "Camera2D",
913
+ CharacterBody2D: "KinematicBody2D",
914
+ RigidBody2D: "RigidBody2D",
915
+ StaticBody2D: "StaticBody2D",
916
+ Area2D: "Area2D",
917
+ CollisionShape2D: "CollisionShape2D",
918
+ TileMap: "TileMap",
919
+ TileMapLayer: "TileMapLayer",
920
+ GPUParticles2D: "ParticleEmitter2D",
921
+ CPUParticles2D: "ParticleEmitter2D",
922
+ NavigationAgent2D: "NavigationAgent2D",
923
+ AudioStreamPlayer2D: "AudioSource2D",
924
+ // 3D Nodes
925
+ Node3D: "Entity3D",
926
+ MeshInstance3D: "MeshRenderer",
927
+ Camera3D: "Camera3D",
928
+ CharacterBody3D: "KinematicBody3D",
929
+ RigidBody3D: "RigidBody3D",
930
+ StaticBody3D: "StaticBody3D",
931
+ Area3D: "Area3D",
932
+ CollisionShape3D: "CollisionShape3D",
933
+ DirectionalLight3D: "DirectionalLight",
934
+ OmniLight3D: "PointLight",
935
+ SpotLight3D: "SpotLight",
936
+ GPUParticles3D: "ParticleEmitter3D",
937
+ CPUParticles3D: "ParticleEmitter3D",
938
+ NavigationAgent3D: "NavigationAgent3D",
939
+ AudioStreamPlayer3D: "AudioSource3D",
940
+ WorldEnvironment: "Environment",
941
+ // Audio
942
+ AudioStreamPlayer: "AudioSource",
943
+ // Animation
944
+ AnimationPlayer: "AnimationPlayer",
945
+ AnimationTree: "AnimationTree",
946
+ // UI
947
+ Control: "UIElement",
948
+ Button: "UIButton",
949
+ Label: "UILabel",
950
+ TextureRect: "UIImage",
951
+ Panel: "UIPanel",
952
+ VBoxContainer: "UIVBox",
953
+ HBoxContainer: "UIHBox",
954
+ GridContainer: "UIGrid",
955
+ LineEdit: "UIInput",
956
+ TextEdit: "UITextArea",
957
+ ProgressBar: "UIProgressBar",
958
+ Slider: "UISlider",
959
+ TabContainer: "UITabs",
960
+ CanvasLayer: "UILayer",
961
+ // Other
962
+ Timer: "Timer",
963
+ Node: "Entity"
1058
964
  };
1059
- // ============================================================
1060
- // Factory Functions
1061
- // ============================================================
1062
965
  function createGodotProjectImporter(callbacks) {
1063
- return new GodotProjectImporter(callbacks);
966
+ return new GodotProjectImporter(callbacks);
1064
967
  }
1065
-
1066
968
  exports.GODOT_NODE_MAPPING = GODOT_NODE_MAPPING;
1067
969
  exports.GodotProjectImporter = GodotProjectImporter;
1068
970
  exports.createGodotProjectImporter = createGodotProjectImporter;