@nice2dev/game-engine 0.1.0 → 1.0.3

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 (294) hide show
  1. package/CHANGELOG.md +193 -1
  2. package/dist/cjs/ai/BehaviorTree.js +1215 -0
  3. package/dist/cjs/ai/BehaviorTree.js.map +1 -0
  4. package/dist/cjs/ai/StateMachine.js +783 -0
  5. package/dist/cjs/ai/StateMachine.js.map +1 -0
  6. package/dist/cjs/audio/AudioBridge.js +454 -0
  7. package/dist/cjs/audio/AudioBridge.js.map +1 -0
  8. package/dist/cjs/devtools/GameplayAnalytics.js +651 -0
  9. package/dist/cjs/devtools/GameplayAnalytics.js.map +1 -0
  10. package/dist/cjs/dialogue/DialogueSystem.js +1023 -0
  11. package/dist/cjs/dialogue/DialogueSystem.js.map +1 -0
  12. package/dist/cjs/editor/NiceGameEditor.js +569 -71
  13. package/dist/cjs/editor/NiceGameEditor.js.map +1 -1
  14. package/dist/cjs/editor/ShaderGraph.js +1616 -0
  15. package/dist/cjs/editor/ShaderGraph.js.map +1 -0
  16. package/dist/cjs/editor/TimelineEditor.js +819 -0
  17. package/dist/cjs/editor/TimelineEditor.js.map +1 -0
  18. package/dist/cjs/engine/SaveSystemV2.js +494 -0
  19. package/dist/cjs/engine/SaveSystemV2.js.map +1 -0
  20. package/dist/cjs/export/GodotExporter.js +1102 -0
  21. package/dist/cjs/export/GodotExporter.js.map +1 -0
  22. package/dist/cjs/export/PlatformExporter.js +236 -0
  23. package/dist/cjs/export/PlatformExporter.js.map +1 -0
  24. package/dist/cjs/export/ThreeJSExporter.js +1116 -0
  25. package/dist/cjs/export/ThreeJSExporter.js.map +1 -0
  26. package/dist/cjs/export/UnityExporter.js +1193 -0
  27. package/dist/cjs/export/UnityExporter.js.map +1 -0
  28. package/dist/cjs/export/WebExporter.js +1036 -0
  29. package/dist/cjs/export/WebExporter.js.map +1 -0
  30. package/dist/cjs/export/index.js +58 -0
  31. package/dist/cjs/export/index.js.map +1 -0
  32. package/dist/cjs/i18n/useTranslation.js +11 -11
  33. package/dist/cjs/import/AsepriteImporter.js +761 -0
  34. package/dist/cjs/import/AsepriteImporter.js.map +1 -0
  35. package/dist/cjs/import/DragonBonesImporter.js +499 -0
  36. package/dist/cjs/import/DragonBonesImporter.js.map +1 -0
  37. package/dist/cjs/import/GameMakerImporter.js +559 -0
  38. package/dist/cjs/import/GameMakerImporter.js.map +1 -0
  39. package/dist/cjs/import/GodotSceneImporter.js +824 -0
  40. package/dist/cjs/import/GodotSceneImporter.js.map +1 -0
  41. package/dist/cjs/import/LDtkImporter.js +481 -0
  42. package/dist/cjs/import/LDtkImporter.js.map +1 -0
  43. package/dist/cjs/import/Live2DImporter.js +553 -0
  44. package/dist/cjs/import/Live2DImporter.js.map +1 -0
  45. package/dist/cjs/import/NdgFormat.js +499 -0
  46. package/dist/cjs/import/NdgFormat.js.map +1 -0
  47. package/dist/cjs/import/OgmoImporter.js +529 -0
  48. package/dist/cjs/import/OgmoImporter.js.map +1 -0
  49. package/dist/cjs/import/RPGMakerImporter.js +520 -0
  50. package/dist/cjs/import/RPGMakerImporter.js.map +1 -0
  51. package/dist/cjs/import/SceneImporter.js +449 -0
  52. package/dist/cjs/import/SceneImporter.js.map +1 -0
  53. package/dist/cjs/import/SpineImporter.js +583 -0
  54. package/dist/cjs/import/SpineImporter.js.map +1 -0
  55. package/dist/cjs/import/SpriterImporter.js +652 -0
  56. package/dist/cjs/import/SpriterImporter.js.map +1 -0
  57. package/dist/cjs/import/TiledMapImporter.js +859 -0
  58. package/dist/cjs/import/TiledMapImporter.js.map +1 -0
  59. package/dist/cjs/import/UnitySceneImporter.js +732 -0
  60. package/dist/cjs/import/UnitySceneImporter.js.map +1 -0
  61. package/dist/cjs/import/index.js +305 -0
  62. package/dist/cjs/import/index.js.map +1 -0
  63. package/dist/cjs/index.js +291 -1
  64. package/dist/cjs/index.js.map +1 -1
  65. package/dist/cjs/input/GamepadNavigation.js +21 -21
  66. package/dist/cjs/input/useGamepads.js +6 -6
  67. package/dist/cjs/integration/IconSprite.js +281 -0
  68. package/dist/cjs/integration/IconSprite.js.map +1 -0
  69. package/dist/cjs/inventory/InventorySystem.js +930 -0
  70. package/dist/cjs/inventory/InventorySystem.js.map +1 -0
  71. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js.map +1 -1
  72. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js.map +1 -1
  73. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js.map +1 -1
  74. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js.map +1 -1
  75. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js.map +1 -1
  76. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js.map +1 -1
  77. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js.map +1 -1
  78. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js.map +1 -1
  79. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js.map +1 -1
  80. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js.map +1 -1
  81. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js.map +1 -1
  82. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js.map +1 -1
  83. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js.map +1 -1
  84. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js.map +1 -1
  85. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js.map +1 -1
  86. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js.map +1 -1
  87. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js.map +1 -1
  88. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js.map +1 -1
  89. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js.map +1 -1
  90. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js.map +1 -1
  91. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js.map +1 -1
  92. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js.map +1 -1
  93. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js.map +1 -1
  94. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js.map +1 -1
  95. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js.map +1 -1
  96. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js.map +1 -1
  97. package/dist/cjs/quest/QuestSystem.js +924 -0
  98. package/dist/cjs/quest/QuestSystem.js.map +1 -0
  99. package/dist/cjs/rendering/WebGPURenderPipeline.js +658 -0
  100. package/dist/cjs/rendering/WebGPURenderPipeline.js.map +1 -0
  101. package/dist/cjs/scripting/GraphToAST.js +567 -0
  102. package/dist/cjs/scripting/GraphToAST.js.map +1 -0
  103. package/dist/cjs/scripting/LanguageExporter.js +321 -0
  104. package/dist/cjs/scripting/LanguageExporter.js.map +1 -0
  105. package/dist/cjs/scripting/ScriptAST.js +67 -0
  106. package/dist/cjs/scripting/ScriptAST.js.map +1 -0
  107. package/dist/cjs/scripting/VisualScripting2.js +1140 -0
  108. package/dist/cjs/scripting/VisualScripting2.js.map +1 -0
  109. package/dist/cjs/scripting/exporters/CSharpExporter.js +503 -0
  110. package/dist/cjs/scripting/exporters/CSharpExporter.js.map +1 -0
  111. package/dist/cjs/scripting/exporters/GDScriptExporter.js +452 -0
  112. package/dist/cjs/scripting/exporters/GDScriptExporter.js.map +1 -0
  113. package/dist/cjs/scripting/exporters/LuaExporter.js +457 -0
  114. package/dist/cjs/scripting/exporters/LuaExporter.js.map +1 -0
  115. package/dist/cjs/scripting/exporters/PythonExporter.js +565 -0
  116. package/dist/cjs/scripting/exporters/PythonExporter.js.map +1 -0
  117. package/dist/cjs/scripting/exporters/RustExporter.js +525 -0
  118. package/dist/cjs/scripting/exporters/RustExporter.js.map +1 -0
  119. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +570 -0
  120. package/dist/cjs/scripting/exporters/TypeScriptExporter.js.map +1 -0
  121. package/dist/cjs/systems/ParticleSystem2.js +1478 -0
  122. package/dist/cjs/systems/ParticleSystem2.js.map +1 -0
  123. package/dist/cjs/xr/ARVR.js.map +1 -1
  124. package/dist/esm/ai/BehaviorTree.js +1186 -0
  125. package/dist/esm/ai/BehaviorTree.js.map +1 -0
  126. package/dist/esm/ai/StateMachine.js +767 -0
  127. package/dist/esm/ai/StateMachine.js.map +1 -0
  128. package/dist/esm/audio/AudioBridge.js +446 -0
  129. package/dist/esm/audio/AudioBridge.js.map +1 -0
  130. package/dist/esm/devtools/GameplayAnalytics.js +639 -0
  131. package/dist/esm/devtools/GameplayAnalytics.js.map +1 -0
  132. package/dist/esm/dialogue/DialogueSystem.js +1008 -0
  133. package/dist/esm/dialogue/DialogueSystem.js.map +1 -0
  134. package/dist/esm/editor/NiceGameEditor.js +556 -58
  135. package/dist/esm/editor/NiceGameEditor.js.map +1 -1
  136. package/dist/esm/editor/ShaderGraph.js +1606 -0
  137. package/dist/esm/editor/ShaderGraph.js.map +1 -0
  138. package/dist/esm/editor/TimelineEditor.js +800 -0
  139. package/dist/esm/editor/TimelineEditor.js.map +1 -0
  140. package/dist/esm/engine/SaveSystemV2.js +487 -0
  141. package/dist/esm/engine/SaveSystemV2.js.map +1 -0
  142. package/dist/esm/export/GodotExporter.js +1100 -0
  143. package/dist/esm/export/GodotExporter.js.map +1 -0
  144. package/dist/esm/export/PlatformExporter.js +230 -0
  145. package/dist/esm/export/PlatformExporter.js.map +1 -0
  146. package/dist/esm/export/ThreeJSExporter.js +1114 -0
  147. package/dist/esm/export/ThreeJSExporter.js.map +1 -0
  148. package/dist/esm/export/UnityExporter.js +1191 -0
  149. package/dist/esm/export/UnityExporter.js.map +1 -0
  150. package/dist/esm/export/WebExporter.js +1033 -0
  151. package/dist/esm/export/WebExporter.js.map +1 -0
  152. package/dist/esm/export/index.js +44 -0
  153. package/dist/esm/export/index.js.map +1 -0
  154. package/dist/esm/import/AsepriteImporter.js +759 -0
  155. package/dist/esm/import/AsepriteImporter.js.map +1 -0
  156. package/dist/esm/import/DragonBonesImporter.js +496 -0
  157. package/dist/esm/import/DragonBonesImporter.js.map +1 -0
  158. package/dist/esm/import/GameMakerImporter.js +556 -0
  159. package/dist/esm/import/GameMakerImporter.js.map +1 -0
  160. package/dist/esm/import/GodotSceneImporter.js +822 -0
  161. package/dist/esm/import/GodotSceneImporter.js.map +1 -0
  162. package/dist/esm/import/LDtkImporter.js +479 -0
  163. package/dist/esm/import/LDtkImporter.js.map +1 -0
  164. package/dist/esm/import/Live2DImporter.js +550 -0
  165. package/dist/esm/import/Live2DImporter.js.map +1 -0
  166. package/dist/esm/import/NdgFormat.js +490 -0
  167. package/dist/esm/import/NdgFormat.js.map +1 -0
  168. package/dist/esm/import/OgmoImporter.js +526 -0
  169. package/dist/esm/import/OgmoImporter.js.map +1 -0
  170. package/dist/esm/import/RPGMakerImporter.js +517 -0
  171. package/dist/esm/import/RPGMakerImporter.js.map +1 -0
  172. package/dist/esm/import/SceneImporter.js +441 -0
  173. package/dist/esm/import/SceneImporter.js.map +1 -0
  174. package/dist/esm/import/SpineImporter.js +580 -0
  175. package/dist/esm/import/SpineImporter.js.map +1 -0
  176. package/dist/esm/import/SpriterImporter.js +649 -0
  177. package/dist/esm/import/SpriterImporter.js.map +1 -0
  178. package/dist/esm/import/TiledMapImporter.js +857 -0
  179. package/dist/esm/import/TiledMapImporter.js.map +1 -0
  180. package/dist/esm/import/UnitySceneImporter.js +730 -0
  181. package/dist/esm/import/UnitySceneImporter.js.map +1 -0
  182. package/dist/esm/import/index.js +279 -0
  183. package/dist/esm/import/index.js.map +1 -0
  184. package/dist/esm/index.js +47 -3
  185. package/dist/esm/index.js.map +1 -1
  186. package/dist/esm/integration/IconSprite.js +266 -0
  187. package/dist/esm/integration/IconSprite.js.map +1 -0
  188. package/dist/esm/inventory/InventorySystem.js +924 -0
  189. package/dist/esm/inventory/InventorySystem.js.map +1 -0
  190. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js.map +1 -1
  191. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js.map +1 -1
  192. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js.map +1 -1
  193. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js.map +1 -1
  194. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js.map +1 -1
  195. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js.map +1 -1
  196. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js.map +1 -1
  197. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js.map +1 -1
  198. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js.map +1 -1
  199. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js.map +1 -1
  200. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js.map +1 -1
  201. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js.map +1 -1
  202. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js.map +1 -1
  203. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js.map +1 -1
  204. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js.map +1 -1
  205. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js.map +1 -1
  206. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js.map +1 -1
  207. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js.map +1 -1
  208. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js.map +1 -1
  209. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js.map +1 -1
  210. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js.map +1 -1
  211. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js.map +1 -1
  212. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js.map +1 -1
  213. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js.map +1 -1
  214. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js.map +1 -1
  215. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js.map +1 -1
  216. package/dist/esm/quest/QuestSystem.js +916 -0
  217. package/dist/esm/quest/QuestSystem.js.map +1 -0
  218. package/dist/esm/rendering/WebGPURenderPipeline.js +642 -0
  219. package/dist/esm/rendering/WebGPURenderPipeline.js.map +1 -0
  220. package/dist/esm/scripting/GraphToAST.js +564 -0
  221. package/dist/esm/scripting/GraphToAST.js.map +1 -0
  222. package/dist/esm/scripting/LanguageExporter.js +311 -0
  223. package/dist/esm/scripting/LanguageExporter.js.map +1 -0
  224. package/dist/esm/scripting/ScriptAST.js +52 -0
  225. package/dist/esm/scripting/ScriptAST.js.map +1 -0
  226. package/dist/esm/scripting/VisualScripting2.js +1130 -0
  227. package/dist/esm/scripting/VisualScripting2.js.map +1 -0
  228. package/dist/esm/scripting/exporters/CSharpExporter.js +501 -0
  229. package/dist/esm/scripting/exporters/CSharpExporter.js.map +1 -0
  230. package/dist/esm/scripting/exporters/GDScriptExporter.js +450 -0
  231. package/dist/esm/scripting/exporters/GDScriptExporter.js.map +1 -0
  232. package/dist/esm/scripting/exporters/LuaExporter.js +455 -0
  233. package/dist/esm/scripting/exporters/LuaExporter.js.map +1 -0
  234. package/dist/esm/scripting/exporters/PythonExporter.js +563 -0
  235. package/dist/esm/scripting/exporters/PythonExporter.js.map +1 -0
  236. package/dist/esm/scripting/exporters/RustExporter.js +523 -0
  237. package/dist/esm/scripting/exporters/RustExporter.js.map +1 -0
  238. package/dist/esm/scripting/exporters/TypeScriptExporter.js +568 -0
  239. package/dist/esm/scripting/exporters/TypeScriptExporter.js.map +1 -0
  240. package/dist/esm/systems/ParticleSystem2.js +1471 -0
  241. package/dist/esm/systems/ParticleSystem2.js.map +1 -0
  242. package/dist/esm/xr/ARVR.js.map +1 -1
  243. package/dist/types/__tests__/setup.d.ts +1 -1
  244. package/dist/types/ai/BehaviorTree.d.ts +375 -0
  245. package/dist/types/ai/StateMachine.d.ts +296 -0
  246. package/dist/types/audio/AudioBridge.d.ts +199 -0
  247. package/dist/types/devtools/GameplayAnalytics.d.ts +279 -0
  248. package/dist/types/dialogue/DialogueSystem.d.ts +326 -0
  249. package/dist/types/dialogue/index.d.ts +2 -0
  250. package/dist/types/editor/NiceGameEditor.d.ts +12 -1
  251. package/dist/types/editor/ShaderGraph.d.ts +207 -0
  252. package/dist/types/editor/TimelineEditor.d.ts +393 -0
  253. package/dist/types/engine/SaveSystemV2.d.ts +155 -0
  254. package/dist/types/export/GodotExporter.d.ts +56 -0
  255. package/dist/types/export/PlatformExporter.d.ts +201 -0
  256. package/dist/types/export/ThreeJSExporter.d.ts +40 -0
  257. package/dist/types/export/UnityExporter.d.ts +69 -0
  258. package/dist/types/export/WebExporter.d.ts +58 -0
  259. package/dist/types/export/index.d.ts +19 -0
  260. package/dist/types/import/AsepriteImporter.d.ts +46 -0
  261. package/dist/types/import/DragonBonesImporter.d.ts +331 -0
  262. package/dist/types/import/GameMakerImporter.d.ts +375 -0
  263. package/dist/types/import/GodotSceneImporter.d.ts +34 -0
  264. package/dist/types/import/LDtkImporter.d.ts +177 -0
  265. package/dist/types/import/Live2DImporter.d.ts +237 -0
  266. package/dist/types/import/NdgFormat.d.ts +387 -0
  267. package/dist/types/import/OgmoImporter.d.ts +237 -0
  268. package/dist/types/import/RPGMakerImporter.d.ts +186 -0
  269. package/dist/types/import/SceneImporter.d.ts +276 -0
  270. package/dist/types/import/SpineImporter.d.ts +372 -0
  271. package/dist/types/import/SpriterImporter.d.ts +230 -0
  272. package/dist/types/import/TiledMapImporter.d.ts +57 -0
  273. package/dist/types/import/UnitySceneImporter.d.ts +87 -0
  274. package/dist/types/import/index.d.ts +59 -0
  275. package/dist/types/index.d.ts +46 -18
  276. package/dist/types/integration/IconSprite.d.ts +196 -0
  277. package/dist/types/inventory/InventorySystem.d.ts +336 -0
  278. package/dist/types/performance/WebGPUCompute.d.ts +0 -10
  279. package/dist/types/quest/QuestSystem.d.ts +287 -0
  280. package/dist/types/rendering/WebGPURenderPipeline.d.ts +255 -0
  281. package/dist/types/scripting/GraphToAST.d.ts +55 -0
  282. package/dist/types/scripting/LanguageExporter.d.ts +136 -0
  283. package/dist/types/scripting/ScriptAST.d.ts +312 -0
  284. package/dist/types/scripting/VisualScripting2.d.ts +353 -0
  285. package/dist/types/scripting/exporters/CSharpExporter.d.ts +44 -0
  286. package/dist/types/scripting/exporters/GDScriptExporter.d.ts +46 -0
  287. package/dist/types/scripting/exporters/LuaExporter.d.ts +46 -0
  288. package/dist/types/scripting/exporters/PythonExporter.d.ts +49 -0
  289. package/dist/types/scripting/exporters/RustExporter.d.ts +46 -0
  290. package/dist/types/scripting/exporters/TypeScriptExporter.d.ts +48 -0
  291. package/dist/types/scripting/exporters/index.d.ts +8 -0
  292. package/dist/types/scripting/index.d.ts +11 -0
  293. package/dist/types/systems/ParticleSystem2.d.ts +646 -0
  294. package/package.json +7 -1
@@ -0,0 +1,1130 @@
1
+ /**
2
+ * @file VisualScripting2.ts
3
+ * @description Visual Scripting 2.0 — Node-based Scripting System with Debugger
4
+ * PRO-1.4: Professional Editor Features
5
+ *
6
+ * Features:
7
+ * - Node-based visual programming (like Unreal Blueprints)
8
+ * - Real-time debugger with breakpoints
9
+ * - Step-by-step execution
10
+ * - Watch expressions
11
+ * - Variable inspection
12
+ * - Call stack visualization
13
+ * - Live preview in editor
14
+ */
15
+ /** Type color mapping for visual identification */
16
+ const VS_TYPE_COLORS = {
17
+ flow: '#ffffff',
18
+ bool: '#dc2626', // Red
19
+ int: '#22d3ee', // Cyan
20
+ float: '#10b981', // Green
21
+ string: '#f472b6', // Pink
22
+ vec2: '#fbbf24', // Yellow
23
+ vec3: '#fbbf24', // Yellow
24
+ color: '#c084fc', // Purple
25
+ entity: '#3b82f6', // Blue
26
+ component: '#8b5cf6', // Violet
27
+ asset: '#f97316', // Orange
28
+ array: '#6b7280', // Gray
29
+ map: '#6b7280', // Gray
30
+ struct: '#14b8a6', // Teal
31
+ object: '#6b7280', // Gray
32
+ enum: '#84cc16', // Lime
33
+ delegate: '#ef4444', // Red
34
+ wildcard: '#a3a3a3', // Neutral
35
+ };
36
+ // ============================================================
37
+ // Visual Scripting Debugger
38
+ // ============================================================
39
+ class VSDebugger {
40
+ constructor() {
41
+ this.eventListeners = new Map();
42
+ this.session = this.createSession();
43
+ }
44
+ createSession() {
45
+ return {
46
+ state: 'stopped',
47
+ currentNode: null,
48
+ currentGraph: null,
49
+ callStack: [],
50
+ breakpoints: new Map(),
51
+ watches: [],
52
+ history: [],
53
+ historyIndex: -1,
54
+ profiling: {
55
+ enabled: false,
56
+ nodeExecutionTimes: new Map(),
57
+ totalFrameTime: 0,
58
+ frameCount: 0,
59
+ },
60
+ };
61
+ }
62
+ // ─── Session Control ─────────────────────────────
63
+ start() {
64
+ this.session.state = 'running';
65
+ this.emit('graph-started', {});
66
+ }
67
+ pause() {
68
+ this.session.state = 'paused';
69
+ }
70
+ resume() {
71
+ if (this.session.state === 'paused') {
72
+ this.session.state = 'running';
73
+ }
74
+ }
75
+ stop() {
76
+ this.session = this.createSession();
77
+ this.emit('graph-completed', {});
78
+ }
79
+ getState() {
80
+ return this.session.state;
81
+ }
82
+ // ─── Stepping ────────────────────────────────────
83
+ stepOver() {
84
+ this.session.state = 'stepping';
85
+ // Implementation would execute current node and stop at next
86
+ }
87
+ stepInto() {
88
+ this.session.state = 'stepping';
89
+ // Implementation would step into function/macro
90
+ }
91
+ stepOut() {
92
+ this.session.state = 'stepping';
93
+ // Implementation would step out of current function
94
+ }
95
+ stepBack() {
96
+ if (this.session.historyIndex > 0) {
97
+ this.session.historyIndex--;
98
+ const snapshot = this.session.history[this.session.historyIndex];
99
+ this.session.currentNode = snapshot.nodeId;
100
+ // Restore state from snapshot
101
+ }
102
+ }
103
+ // ─── Breakpoints ─────────────────────────────────
104
+ addBreakpoint(nodeId, options) {
105
+ const bp = {
106
+ id: `bp_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
107
+ nodeId,
108
+ enabled: true,
109
+ ...options,
110
+ };
111
+ this.session.breakpoints.set(bp.id, bp);
112
+ return bp;
113
+ }
114
+ removeBreakpoint(breakpointId) {
115
+ this.session.breakpoints.delete(breakpointId);
116
+ }
117
+ toggleBreakpoint(nodeId) {
118
+ // Find existing breakpoint on this node
119
+ for (const bp of this.session.breakpoints.values()) {
120
+ if (bp.nodeId === nodeId) {
121
+ this.removeBreakpoint(bp.id);
122
+ return null;
123
+ }
124
+ }
125
+ return this.addBreakpoint(nodeId);
126
+ }
127
+ setBreakpointCondition(breakpointId, condition) {
128
+ const bp = this.session.breakpoints.get(breakpointId);
129
+ if (bp) {
130
+ bp.condition = condition;
131
+ }
132
+ }
133
+ enableBreakpoint(breakpointId, enabled) {
134
+ const bp = this.session.breakpoints.get(breakpointId);
135
+ if (bp) {
136
+ bp.enabled = enabled;
137
+ }
138
+ }
139
+ getBreakpoints() {
140
+ return Array.from(this.session.breakpoints.values());
141
+ }
142
+ // ─── Watch Expressions ───────────────────────────
143
+ addWatch(expression) {
144
+ const watch = {
145
+ id: `watch_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
146
+ expression,
147
+ value: undefined,
148
+ type: 'wildcard',
149
+ };
150
+ this.session.watches.push(watch);
151
+ return watch;
152
+ }
153
+ removeWatch(watchId) {
154
+ const idx = this.session.watches.findIndex((w) => w.id === watchId);
155
+ if (idx >= 0) {
156
+ this.session.watches.splice(idx, 1);
157
+ }
158
+ }
159
+ updateWatches(context) {
160
+ for (const watch of this.session.watches) {
161
+ try {
162
+ watch.value = this.evaluateExpression(watch.expression, context);
163
+ watch.error = undefined;
164
+ }
165
+ catch (err) {
166
+ watch.error = String(err);
167
+ }
168
+ }
169
+ }
170
+ getWatches() {
171
+ return [...this.session.watches];
172
+ }
173
+ // ─── Call Stack ──────────────────────────────────
174
+ pushStack(frame) {
175
+ this.session.callStack.push(frame);
176
+ }
177
+ popStack() {
178
+ return this.session.callStack.pop();
179
+ }
180
+ getCallStack() {
181
+ return [...this.session.callStack];
182
+ }
183
+ getCurrentFrame() {
184
+ return this.session.callStack[this.session.callStack.length - 1] || null;
185
+ }
186
+ // ─── History/Snapshots ───────────────────────────
187
+ recordSnapshot(snapshot) {
188
+ // Limit history size
189
+ const MAX_HISTORY = 1000;
190
+ if (this.session.history.length >= MAX_HISTORY) {
191
+ this.session.history.shift();
192
+ }
193
+ this.session.history.push(snapshot);
194
+ this.session.historyIndex = this.session.history.length - 1;
195
+ }
196
+ getHistory() {
197
+ return [...this.session.history];
198
+ }
199
+ // ─── Profiling ───────────────────────────────────
200
+ enableProfiling(enabled) {
201
+ this.session.profiling.enabled = enabled;
202
+ if (!enabled) {
203
+ this.session.profiling.nodeExecutionTimes.clear();
204
+ this.session.profiling.totalFrameTime = 0;
205
+ this.session.profiling.frameCount = 0;
206
+ }
207
+ }
208
+ recordNodeTime(nodeId, timeMs) {
209
+ if (!this.session.profiling.enabled)
210
+ return;
211
+ let times = this.session.profiling.nodeExecutionTimes.get(nodeId);
212
+ if (!times) {
213
+ times = [];
214
+ this.session.profiling.nodeExecutionTimes.set(nodeId, times);
215
+ }
216
+ times.push(timeMs);
217
+ // Keep last 100 samples
218
+ if (times.length > 100) {
219
+ times.shift();
220
+ }
221
+ }
222
+ getNodeAverageTime(nodeId) {
223
+ const times = this.session.profiling.nodeExecutionTimes.get(nodeId);
224
+ if (!times || times.length === 0)
225
+ return 0;
226
+ return times.reduce((a, b) => a + b, 0) / times.length;
227
+ }
228
+ getProfilingData() {
229
+ return { ...this.session.profiling };
230
+ }
231
+ // ─── Expression Evaluation ───────────────────────
232
+ evaluateExpression(expr, context) {
233
+ // Safe expression evaluator (no eval!)
234
+ // Parse simple expressions like: entity.transform.position.x
235
+ // Or: variables.health > 50
236
+ const parts = expr.split('.');
237
+ let value = undefined;
238
+ if (parts[0] === 'entity' && context.entityId) {
239
+ // Entity property access
240
+ if (parts[1]) {
241
+ const component = context.getComponent(context.entityId, parts[1]);
242
+ if (component && parts[2]) {
243
+ value = this.getNestedValue(component, parts.slice(2));
244
+ }
245
+ else {
246
+ value = component;
247
+ }
248
+ }
249
+ }
250
+ else if (parts[0] === 'variables') {
251
+ // Variable access
252
+ if (parts[1]) {
253
+ value = context.variables.get(parts[1]);
254
+ }
255
+ }
256
+ else if (parts[0] === 'globals') {
257
+ if (parts[1]) {
258
+ value = context.globals.get(parts[1]);
259
+ }
260
+ }
261
+ else if (parts[0] === 'dt') {
262
+ value = context.dt;
263
+ }
264
+ else if (parts[0] === 'time') {
265
+ value = context.time;
266
+ }
267
+ return value;
268
+ }
269
+ getNestedValue(obj, path) {
270
+ let current = obj;
271
+ for (const key of path) {
272
+ if (current && typeof current === 'object' && key in current) {
273
+ current = current[key];
274
+ }
275
+ else {
276
+ return undefined;
277
+ }
278
+ }
279
+ return current;
280
+ }
281
+ // ─── Event System ────────────────────────────────
282
+ on(event, listener) {
283
+ let listeners = this.eventListeners.get(event);
284
+ if (!listeners) {
285
+ listeners = [];
286
+ this.eventListeners.set(event, listeners);
287
+ }
288
+ listeners.push(listener);
289
+ }
290
+ off(event, listener) {
291
+ const listeners = this.eventListeners.get(event);
292
+ if (listeners) {
293
+ const idx = listeners.indexOf(listener);
294
+ if (idx >= 0) {
295
+ listeners.splice(idx, 1);
296
+ }
297
+ }
298
+ }
299
+ emit(type, data) {
300
+ const event = {
301
+ type,
302
+ timestamp: Date.now(),
303
+ data,
304
+ };
305
+ const listeners = this.eventListeners.get(type);
306
+ if (listeners) {
307
+ for (const listener of listeners) {
308
+ listener(event);
309
+ }
310
+ }
311
+ }
312
+ // ─── Node Execution Hook ─────────────────────────
313
+ onNodeStartExecution(nodeId, inputs) {
314
+ // Check breakpoints
315
+ for (const bp of this.session.breakpoints.values()) {
316
+ if (bp.nodeId === nodeId && bp.enabled) {
317
+ // Check condition if set
318
+ if (bp.condition) ;
319
+ // Check hit count
320
+ if (bp.hitCount !== undefined) {
321
+ bp.hitCount--;
322
+ if (bp.hitCount > 0)
323
+ continue;
324
+ }
325
+ // Log message instead of breaking?
326
+ if (bp.logMessage) {
327
+ console.log(`[VS Breakpoint] ${bp.logMessage}`);
328
+ continue;
329
+ }
330
+ // Hit breakpoint!
331
+ this.session.state = 'paused';
332
+ this.session.currentNode = nodeId;
333
+ this.emit('breakpoint-hit', { nodeId, breakpoint: bp });
334
+ // Remove temporary breakpoint
335
+ if (bp.temporary) {
336
+ this.removeBreakpoint(bp.id);
337
+ }
338
+ return false; // Pause execution
339
+ }
340
+ }
341
+ // Record for history
342
+ this.recordSnapshot({
343
+ timestamp: Date.now(),
344
+ nodeId,
345
+ inputs,
346
+ outputs: {},
347
+ variables: new Map(),
348
+ });
349
+ return true; // Continue execution
350
+ }
351
+ onNodeCompleteExecution(nodeId, outputs, timeMs) {
352
+ // Update last snapshot with outputs
353
+ if (this.session.history.length > 0) {
354
+ const lastSnapshot = this.session.history[this.session.history.length - 1];
355
+ if (lastSnapshot.nodeId === nodeId) {
356
+ lastSnapshot.outputs = outputs;
357
+ }
358
+ }
359
+ // Record profiling
360
+ this.recordNodeTime(nodeId, timeMs);
361
+ // Emit event
362
+ this.emit('node-executed', { nodeId, outputs, timeMs });
363
+ // Step mode handling
364
+ if (this.session.state === 'stepping') {
365
+ this.session.state = 'paused';
366
+ this.emit('step-completed', { nodeId });
367
+ }
368
+ }
369
+ }
370
+ // ============================================================
371
+ // Enhanced Graph Executor with Debugging
372
+ // ============================================================
373
+ class VSGraphExecutor {
374
+ constructor(debuggerInstance) {
375
+ this.nodeLibrary = new Map();
376
+ this.executionQueue = [];
377
+ this.debugger = debuggerInstance || new VSDebugger();
378
+ }
379
+ // ─── Node Registration ───────────────────────────
380
+ registerNode(definition) {
381
+ this.nodeLibrary.set(definition.type, definition);
382
+ }
383
+ registerNodes(definitions) {
384
+ for (const def of definitions) {
385
+ this.registerNode(def);
386
+ }
387
+ }
388
+ getNodeDefinition(type) {
389
+ return this.nodeLibrary.get(type);
390
+ }
391
+ getAllNodeDefinitions() {
392
+ return Array.from(this.nodeLibrary.values());
393
+ }
394
+ searchNodes(query) {
395
+ const q = query.toLowerCase();
396
+ return this.getAllNodeDefinitions().filter((def) => {
397
+ var _a;
398
+ return def.name.toLowerCase().includes(q) ||
399
+ def.type.toLowerCase().includes(q) ||
400
+ def.description.toLowerCase().includes(q) ||
401
+ ((_a = def.keywords) === null || _a === void 0 ? void 0 : _a.some((k) => k.toLowerCase().includes(q)));
402
+ });
403
+ }
404
+ // ─── Execution ───────────────────────────────────
405
+ execute(graph, entryType, context) {
406
+ this.debugger.start();
407
+ // Find entry nodes
408
+ const entryNodes = graph.nodes.filter((n) => n.type === entryType && !n.disabled);
409
+ for (const entryNode of entryNodes) {
410
+ this.executeNode(graph, entryNode, context);
411
+ }
412
+ }
413
+ executeNode(graph, node, context) {
414
+ if (node.disabled)
415
+ return;
416
+ const definition = this.nodeLibrary.get(node.type);
417
+ if (!definition) {
418
+ context.log('error', `Unknown node type: ${node.type}`);
419
+ return;
420
+ }
421
+ // Gather inputs from connections
422
+ const inputs = { ...node.inputs };
423
+ for (const conn of graph.connections) {
424
+ if (conn.toNode === node.id) {
425
+ const sourceNode = graph.nodes.find((n) => n.id === conn.fromNode);
426
+ if (sourceNode) {
427
+ inputs[conn.toPort] = sourceNode.outputs[conn.fromPort];
428
+ }
429
+ }
430
+ }
431
+ // Apply default values for unconnected inputs
432
+ for (const port of definition.ports) {
433
+ if (port.direction === 'input' && inputs[port.id] === undefined) {
434
+ inputs[port.id] = port.defaultValue;
435
+ }
436
+ }
437
+ // Debug hook - before execution
438
+ if (!this.debugger.onNodeStartExecution(node.id, inputs)) {
439
+ // Debugger paused execution
440
+ this.executionQueue.push({ graph, nodeId: node.id, context });
441
+ return;
442
+ }
443
+ // Track flow outputs
444
+ const triggeredFlows = [];
445
+ const originalTrigger = context.triggerFlow;
446
+ context.triggerFlow = (portId) => {
447
+ triggeredFlows.push(portId);
448
+ };
449
+ // Execute node
450
+ const startTime = performance.now();
451
+ let outputs = {};
452
+ try {
453
+ const result = definition.execute(inputs, context);
454
+ if (result && !(result instanceof Promise)) {
455
+ outputs = result;
456
+ }
457
+ else if (result instanceof Promise) {
458
+ // Handle async nodes
459
+ result
460
+ .then((asyncOutputs) => {
461
+ node.outputs = asyncOutputs;
462
+ this.followFlowConnections(graph, node, triggeredFlows, context);
463
+ })
464
+ .catch((err) => {
465
+ context.log('error', `Node ${node.id} error: ${err}`);
466
+ });
467
+ return;
468
+ }
469
+ }
470
+ catch (err) {
471
+ context.log('error', `Node ${node.id} error: ${err}`);
472
+ }
473
+ const executionTime = performance.now() - startTime;
474
+ // Store outputs
475
+ node.outputs = outputs;
476
+ // Restore trigger function
477
+ context.triggerFlow = originalTrigger;
478
+ // Debug hook - after execution
479
+ this.debugger.onNodeCompleteExecution(node.id, outputs, executionTime);
480
+ // Follow flow connections
481
+ this.followFlowConnections(graph, node, triggeredFlows, context);
482
+ }
483
+ followFlowConnections(graph, node, triggeredFlows, context) {
484
+ for (const flowPort of triggeredFlows) {
485
+ const flowConnections = graph.connections.filter((c) => c.fromNode === node.id && c.fromPort === flowPort);
486
+ for (const conn of flowConnections) {
487
+ const nextNode = graph.nodes.find((n) => n.id === conn.toNode);
488
+ if (nextNode) {
489
+ this.executeNode(graph, nextNode, context);
490
+ }
491
+ }
492
+ }
493
+ }
494
+ // ─── Debugging ───────────────────────────────────
495
+ getDebugger() {
496
+ return this.debugger;
497
+ }
498
+ resumeExecution() {
499
+ this.debugger.resume();
500
+ // Process queued executions
501
+ while (this.executionQueue.length > 0 && this.debugger.getState() === 'running') {
502
+ const queued = this.executionQueue.shift();
503
+ const node = queued.graph.nodes.find((n) => n.id === queued.nodeId);
504
+ if (node) {
505
+ this.executeNode(queued.graph, node, queued.context);
506
+ }
507
+ }
508
+ }
509
+ }
510
+ // ============================================================
511
+ // Built-in Node Definitions
512
+ // ============================================================
513
+ function createBuiltInNodes() {
514
+ return [
515
+ // ─── Events ────────────────────────────────────
516
+ {
517
+ type: 'event_start',
518
+ name: 'On Start',
519
+ category: 'event',
520
+ description: 'Fires once when the scene starts',
521
+ icon: 'play',
522
+ color: '#dc2626',
523
+ ports: [{ id: 'exec', name: '', direction: 'output', type: 'flow' }],
524
+ execute: (_inputs, ctx) => {
525
+ ctx.triggerFlow('exec');
526
+ },
527
+ },
528
+ {
529
+ type: 'event_update',
530
+ name: 'On Update',
531
+ category: 'event',
532
+ description: 'Fires every frame',
533
+ icon: 'refresh',
534
+ color: '#dc2626',
535
+ ports: [
536
+ { id: 'exec', name: '', direction: 'output', type: 'flow' },
537
+ { id: 'delta', name: 'Delta Time', direction: 'output', type: 'float' },
538
+ ],
539
+ execute: (_inputs, ctx) => {
540
+ ctx.triggerFlow('exec');
541
+ return { delta: ctx.dt };
542
+ },
543
+ },
544
+ {
545
+ type: 'event_input',
546
+ name: 'On Input',
547
+ category: 'event',
548
+ description: 'Fires when input action is triggered',
549
+ icon: 'keyboard',
550
+ color: '#dc2626',
551
+ ports: [
552
+ { id: 'action', name: 'Action', direction: 'input', type: 'string' },
553
+ { id: 'pressed', name: 'Pressed', direction: 'output', type: 'flow' },
554
+ { id: 'released', name: 'Released', direction: 'output', type: 'flow' },
555
+ { id: 'held', name: 'Held', direction: 'output', type: 'flow' },
556
+ ],
557
+ execute: () => { },
558
+ },
559
+ // ─── Flow Control ──────────────────────────────
560
+ {
561
+ type: 'branch',
562
+ name: 'Branch',
563
+ category: 'flow',
564
+ description: 'Branch execution based on condition',
565
+ icon: 'git-branch',
566
+ color: '#f97316',
567
+ ports: [
568
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
569
+ {
570
+ id: 'condition',
571
+ name: 'Condition',
572
+ direction: 'input',
573
+ type: 'bool',
574
+ defaultValue: false,
575
+ },
576
+ { id: 'true', name: 'True', direction: 'output', type: 'flow' },
577
+ { id: 'false', name: 'False', direction: 'output', type: 'flow' },
578
+ ],
579
+ execute: (inputs, ctx) => {
580
+ ctx.triggerFlow(inputs.condition ? 'true' : 'false');
581
+ },
582
+ },
583
+ {
584
+ type: 'sequence',
585
+ name: 'Sequence',
586
+ category: 'flow',
587
+ description: 'Execute outputs in sequence',
588
+ icon: 'list',
589
+ color: '#f97316',
590
+ ports: [
591
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
592
+ { id: 'then_0', name: 'Then 0', direction: 'output', type: 'flow' },
593
+ { id: 'then_1', name: 'Then 1', direction: 'output', type: 'flow' },
594
+ { id: 'then_2', name: 'Then 2', direction: 'output', type: 'flow' },
595
+ ],
596
+ execute: (_inputs, ctx) => {
597
+ ctx.triggerFlow('then_0');
598
+ ctx.triggerFlow('then_1');
599
+ ctx.triggerFlow('then_2');
600
+ },
601
+ },
602
+ {
603
+ type: 'for_loop',
604
+ name: 'For Loop',
605
+ category: 'flow',
606
+ description: 'Loop from start to end',
607
+ icon: 'repeat',
608
+ color: '#f97316',
609
+ latent: true,
610
+ ports: [
611
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
612
+ { id: 'start', name: 'Start', direction: 'input', type: 'int', defaultValue: 0 },
613
+ { id: 'end', name: 'End', direction: 'input', type: 'int', defaultValue: 10 },
614
+ { id: 'body', name: 'Loop Body', direction: 'output', type: 'flow' },
615
+ { id: 'index', name: 'Index', direction: 'output', type: 'int' },
616
+ { id: 'completed', name: 'Completed', direction: 'output', type: 'flow' },
617
+ ],
618
+ execute: (inputs, ctx) => {
619
+ const start = inputs.start;
620
+ const end = inputs.end;
621
+ for (let i = start; i < end; i++) {
622
+ ctx.triggerFlow('body');
623
+ }
624
+ ctx.triggerFlow('completed');
625
+ return { index: end - 1 };
626
+ },
627
+ },
628
+ {
629
+ type: 'while_loop',
630
+ name: 'While Loop',
631
+ category: 'flow',
632
+ description: 'Loop while condition is true',
633
+ icon: 'repeat',
634
+ color: '#f97316',
635
+ latent: true,
636
+ ports: [
637
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
638
+ { id: 'condition', name: 'Condition', direction: 'input', type: 'bool' },
639
+ { id: 'body', name: 'Loop Body', direction: 'output', type: 'flow' },
640
+ { id: 'completed', name: 'Completed', direction: 'output', type: 'flow' },
641
+ ],
642
+ execute: (inputs, ctx) => {
643
+ let iterations = 0;
644
+ const MAX_ITERATIONS = 10000;
645
+ while (inputs.condition && iterations < MAX_ITERATIONS) {
646
+ ctx.triggerFlow('body');
647
+ iterations++;
648
+ }
649
+ ctx.triggerFlow('completed');
650
+ },
651
+ },
652
+ // ─── Math Operations ───────────────────────────
653
+ {
654
+ type: 'math_add',
655
+ name: 'Add',
656
+ category: 'math',
657
+ description: 'Add two numbers',
658
+ icon: 'plus',
659
+ color: '#22c55e',
660
+ pure: true,
661
+ compact: true,
662
+ ports: [
663
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 0 },
664
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 0 },
665
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
666
+ ],
667
+ execute: (inputs) => ({ result: inputs.a + inputs.b }),
668
+ },
669
+ {
670
+ type: 'math_subtract',
671
+ name: 'Subtract',
672
+ category: 'math',
673
+ description: 'Subtract two numbers',
674
+ icon: 'minus',
675
+ color: '#22c55e',
676
+ pure: true,
677
+ compact: true,
678
+ ports: [
679
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 0 },
680
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 0 },
681
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
682
+ ],
683
+ execute: (inputs) => ({ result: inputs.a - inputs.b }),
684
+ },
685
+ {
686
+ type: 'math_multiply',
687
+ name: 'Multiply',
688
+ category: 'math',
689
+ description: 'Multiply two numbers',
690
+ icon: 'x',
691
+ color: '#22c55e',
692
+ pure: true,
693
+ compact: true,
694
+ ports: [
695
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 1 },
696
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 1 },
697
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
698
+ ],
699
+ execute: (inputs) => ({ result: inputs.a * inputs.b }),
700
+ },
701
+ {
702
+ type: 'math_divide',
703
+ name: 'Divide',
704
+ category: 'math',
705
+ description: 'Divide two numbers',
706
+ icon: 'divide',
707
+ color: '#22c55e',
708
+ pure: true,
709
+ compact: true,
710
+ ports: [
711
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 1 },
712
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 1 },
713
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
714
+ ],
715
+ execute: (inputs) => ({
716
+ result: inputs.b !== 0 ? inputs.a / inputs.b : 0,
717
+ }),
718
+ },
719
+ {
720
+ type: 'math_clamp',
721
+ name: 'Clamp',
722
+ category: 'math',
723
+ description: 'Clamp value between min and max',
724
+ icon: 'sliders',
725
+ color: '#22c55e',
726
+ pure: true,
727
+ ports: [
728
+ { id: 'value', name: 'Value', direction: 'input', type: 'float', defaultValue: 0 },
729
+ { id: 'min', name: 'Min', direction: 'input', type: 'float', defaultValue: 0 },
730
+ { id: 'max', name: 'Max', direction: 'input', type: 'float', defaultValue: 1 },
731
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
732
+ ],
733
+ execute: (inputs) => ({
734
+ result: Math.min(Math.max(inputs.value, inputs.min), inputs.max),
735
+ }),
736
+ },
737
+ {
738
+ type: 'math_lerp',
739
+ name: 'Lerp',
740
+ category: 'math',
741
+ description: 'Linear interpolation between two values',
742
+ icon: 'trending-up',
743
+ color: '#22c55e',
744
+ pure: true,
745
+ ports: [
746
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 0 },
747
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 1 },
748
+ { id: 't', name: 'Alpha', direction: 'input', type: 'float', defaultValue: 0.5 },
749
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
750
+ ],
751
+ execute: (inputs) => ({
752
+ result: inputs.a +
753
+ (inputs.b - inputs.a) * inputs.t,
754
+ }),
755
+ },
756
+ {
757
+ type: 'math_random',
758
+ name: 'Random',
759
+ category: 'math',
760
+ description: 'Generate random number',
761
+ icon: 'shuffle',
762
+ color: '#22c55e',
763
+ pure: true,
764
+ ports: [
765
+ { id: 'min', name: 'Min', direction: 'input', type: 'float', defaultValue: 0 },
766
+ { id: 'max', name: 'Max', direction: 'input', type: 'float', defaultValue: 1 },
767
+ { id: 'result', name: 'Result', direction: 'output', type: 'float' },
768
+ ],
769
+ execute: (inputs) => ({
770
+ result: inputs.min +
771
+ Math.random() * (inputs.max - inputs.min),
772
+ }),
773
+ },
774
+ // ─── Logic Operations ──────────────────────────
775
+ {
776
+ type: 'logic_and',
777
+ name: 'AND',
778
+ category: 'logic',
779
+ description: 'Logical AND',
780
+ icon: 'check-square',
781
+ color: '#ef4444',
782
+ pure: true,
783
+ compact: true,
784
+ ports: [
785
+ { id: 'a', name: 'A', direction: 'input', type: 'bool', defaultValue: false },
786
+ { id: 'b', name: 'B', direction: 'input', type: 'bool', defaultValue: false },
787
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
788
+ ],
789
+ execute: (inputs) => ({ result: inputs.a && inputs.b }),
790
+ },
791
+ {
792
+ type: 'logic_or',
793
+ name: 'OR',
794
+ category: 'logic',
795
+ description: 'Logical OR',
796
+ icon: 'box',
797
+ color: '#ef4444',
798
+ pure: true,
799
+ compact: true,
800
+ ports: [
801
+ { id: 'a', name: 'A', direction: 'input', type: 'bool', defaultValue: false },
802
+ { id: 'b', name: 'B', direction: 'input', type: 'bool', defaultValue: false },
803
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
804
+ ],
805
+ execute: (inputs) => ({ result: inputs.a || inputs.b }),
806
+ },
807
+ {
808
+ type: 'logic_not',
809
+ name: 'NOT',
810
+ category: 'logic',
811
+ description: 'Logical NOT',
812
+ icon: 'x-circle',
813
+ color: '#ef4444',
814
+ pure: true,
815
+ compact: true,
816
+ ports: [
817
+ { id: 'value', name: 'Value', direction: 'input', type: 'bool', defaultValue: false },
818
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
819
+ ],
820
+ execute: (inputs) => ({ result: !inputs.value }),
821
+ },
822
+ {
823
+ type: 'compare_equal',
824
+ name: 'Equal',
825
+ category: 'logic',
826
+ description: 'Check if two values are equal',
827
+ icon: 'equal',
828
+ color: '#ef4444',
829
+ pure: true,
830
+ compact: true,
831
+ ports: [
832
+ { id: 'a', name: 'A', direction: 'input', type: 'wildcard' },
833
+ { id: 'b', name: 'B', direction: 'input', type: 'wildcard' },
834
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
835
+ ],
836
+ execute: (inputs) => ({ result: inputs.a === inputs.b }),
837
+ },
838
+ {
839
+ type: 'compare_greater',
840
+ name: 'Greater Than',
841
+ category: 'logic',
842
+ description: 'Check if A > B',
843
+ icon: 'chevron-right',
844
+ color: '#ef4444',
845
+ pure: true,
846
+ compact: true,
847
+ ports: [
848
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 0 },
849
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 0 },
850
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
851
+ ],
852
+ execute: (inputs) => ({ result: inputs.a > inputs.b }),
853
+ },
854
+ {
855
+ type: 'compare_less',
856
+ name: 'Less Than',
857
+ category: 'logic',
858
+ description: 'Check if A < B',
859
+ icon: 'chevron-left',
860
+ color: '#ef4444',
861
+ pure: true,
862
+ compact: true,
863
+ ports: [
864
+ { id: 'a', name: 'A', direction: 'input', type: 'float', defaultValue: 0 },
865
+ { id: 'b', name: 'B', direction: 'input', type: 'float', defaultValue: 0 },
866
+ { id: 'result', name: 'Result', direction: 'output', type: 'bool' },
867
+ ],
868
+ execute: (inputs) => ({ result: inputs.a < inputs.b }),
869
+ },
870
+ // ─── Entity Operations ─────────────────────────
871
+ {
872
+ type: 'get_self',
873
+ name: 'Get Self',
874
+ category: 'entity',
875
+ description: 'Get reference to the owning entity',
876
+ icon: 'user',
877
+ color: '#3b82f6',
878
+ pure: true,
879
+ ports: [{ id: 'entity', name: 'Entity', direction: 'output', type: 'entity' }],
880
+ execute: (_inputs, ctx) => ({ entity: ctx.entityId }),
881
+ },
882
+ {
883
+ type: 'spawn_entity',
884
+ name: 'Spawn Entity',
885
+ category: 'entity',
886
+ description: 'Spawn a new entity from prefab',
887
+ icon: 'plus-circle',
888
+ color: '#3b82f6',
889
+ ports: [
890
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
891
+ { id: 'prefab', name: 'Prefab', direction: 'input', type: 'asset' },
892
+ {
893
+ id: 'position',
894
+ name: 'Position',
895
+ direction: 'input',
896
+ type: 'vec2',
897
+ defaultValue: { x: 0, y: 0 },
898
+ },
899
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
900
+ { id: 'spawned', name: 'Spawned', direction: 'output', type: 'entity' },
901
+ ],
902
+ execute: (inputs, ctx) => {
903
+ const entity = ctx.spawnEntity(inputs.prefab, inputs.position);
904
+ ctx.triggerFlow('then');
905
+ return { spawned: entity };
906
+ },
907
+ },
908
+ {
909
+ type: 'destroy_entity',
910
+ name: 'Destroy Entity',
911
+ category: 'entity',
912
+ description: 'Destroy an entity',
913
+ icon: 'trash',
914
+ color: '#3b82f6',
915
+ ports: [
916
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
917
+ { id: 'entity', name: 'Entity', direction: 'input', type: 'entity' },
918
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
919
+ ],
920
+ execute: (inputs, ctx) => {
921
+ ctx.destroyEntity(inputs.entity);
922
+ ctx.triggerFlow('then');
923
+ },
924
+ },
925
+ // ─── Transform Operations ──────────────────────
926
+ {
927
+ type: 'get_position',
928
+ name: 'Get Position',
929
+ category: 'transform',
930
+ description: 'Get entity position',
931
+ icon: 'map-pin',
932
+ color: '#fbbf24',
933
+ pure: true,
934
+ ports: [
935
+ { id: 'entity', name: 'Entity', direction: 'input', type: 'entity' },
936
+ { id: 'position', name: 'Position', direction: 'output', type: 'vec2' },
937
+ ],
938
+ execute: (inputs, ctx) => {
939
+ const transform = ctx.getComponent(inputs.entity, 'Transform');
940
+ return { position: (transform === null || transform === void 0 ? void 0 : transform.position) || { x: 0, y: 0 } };
941
+ },
942
+ },
943
+ {
944
+ type: 'set_position',
945
+ name: 'Set Position',
946
+ category: 'transform',
947
+ description: 'Set entity position',
948
+ icon: 'move',
949
+ color: '#fbbf24',
950
+ ports: [
951
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
952
+ { id: 'entity', name: 'Entity', direction: 'input', type: 'entity' },
953
+ {
954
+ id: 'position',
955
+ name: 'Position',
956
+ direction: 'input',
957
+ type: 'vec2',
958
+ defaultValue: { x: 0, y: 0 },
959
+ },
960
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
961
+ ],
962
+ execute: (inputs, ctx) => {
963
+ ctx.setComponent(inputs.entity, 'Transform', { position: inputs.position });
964
+ ctx.triggerFlow('then');
965
+ },
966
+ },
967
+ {
968
+ type: 'translate',
969
+ name: 'Translate',
970
+ category: 'transform',
971
+ description: 'Move entity by offset',
972
+ icon: 'arrows-move',
973
+ color: '#fbbf24',
974
+ ports: [
975
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
976
+ { id: 'entity', name: 'Entity', direction: 'input', type: 'entity' },
977
+ {
978
+ id: 'offset',
979
+ name: 'Offset',
980
+ direction: 'input',
981
+ type: 'vec2',
982
+ defaultValue: { x: 0, y: 0 },
983
+ },
984
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
985
+ ],
986
+ execute: (inputs, ctx) => {
987
+ const transform = ctx.getComponent(inputs.entity, 'Transform');
988
+ if (transform) {
989
+ const offset = inputs.offset;
990
+ ctx.setComponent(inputs.entity, 'Transform', {
991
+ position: {
992
+ x: transform.position.x + offset.x,
993
+ y: transform.position.y + offset.y,
994
+ },
995
+ });
996
+ }
997
+ ctx.triggerFlow('then');
998
+ },
999
+ },
1000
+ // ─── Debug Operations ──────────────────────────
1001
+ {
1002
+ type: 'print',
1003
+ name: 'Print',
1004
+ category: 'debug',
1005
+ description: 'Print message to screen',
1006
+ icon: 'message-square',
1007
+ color: '#6b7280',
1008
+ ports: [
1009
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
1010
+ {
1011
+ id: 'message',
1012
+ name: 'Message',
1013
+ direction: 'input',
1014
+ type: 'string',
1015
+ defaultValue: 'Hello!',
1016
+ },
1017
+ { id: 'duration', name: 'Duration', direction: 'input', type: 'float', defaultValue: 2 },
1018
+ { id: 'color', name: 'Color', direction: 'input', type: 'color', defaultValue: '#ffffff' },
1019
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
1020
+ ],
1021
+ execute: (inputs, ctx) => {
1022
+ ctx.print(inputs.message, inputs.duration, inputs.color);
1023
+ ctx.triggerFlow('then');
1024
+ },
1025
+ },
1026
+ {
1027
+ type: 'log',
1028
+ name: 'Log',
1029
+ category: 'debug',
1030
+ description: 'Log message to console',
1031
+ icon: 'terminal',
1032
+ color: '#6b7280',
1033
+ ports: [
1034
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
1035
+ { id: 'message', name: 'Message', direction: 'input', type: 'string' },
1036
+ {
1037
+ id: 'level',
1038
+ name: 'Level',
1039
+ direction: 'input',
1040
+ type: 'enum',
1041
+ enumDef: 'LogLevel',
1042
+ defaultValue: 'info',
1043
+ },
1044
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
1045
+ ],
1046
+ execute: (inputs, ctx) => {
1047
+ ctx.log(inputs.level, inputs.message);
1048
+ ctx.triggerFlow('then');
1049
+ },
1050
+ },
1051
+ // ─── Variable Operations ───────────────────────
1052
+ {
1053
+ type: 'get_variable',
1054
+ name: 'Get Variable',
1055
+ category: 'variable',
1056
+ description: 'Get variable value',
1057
+ icon: 'download',
1058
+ color: '#8b5cf6',
1059
+ pure: true,
1060
+ ports: [
1061
+ { id: 'name', name: 'Name', direction: 'input', type: 'string' },
1062
+ { id: 'value', name: 'Value', direction: 'output', type: 'wildcard' },
1063
+ ],
1064
+ execute: (inputs, ctx) => ({ value: ctx.variables.get(inputs.name) }),
1065
+ },
1066
+ {
1067
+ type: 'set_variable',
1068
+ name: 'Set Variable',
1069
+ category: 'variable',
1070
+ description: 'Set variable value',
1071
+ icon: 'upload',
1072
+ color: '#8b5cf6',
1073
+ ports: [
1074
+ { id: 'exec', name: '', direction: 'input', type: 'flow' },
1075
+ { id: 'name', name: 'Name', direction: 'input', type: 'string' },
1076
+ { id: 'value', name: 'Value', direction: 'input', type: 'wildcard' },
1077
+ { id: 'then', name: '', direction: 'output', type: 'flow' },
1078
+ ],
1079
+ execute: (inputs, ctx) => {
1080
+ ctx.variables.set(inputs.name, inputs.value);
1081
+ ctx.triggerFlow('then');
1082
+ },
1083
+ },
1084
+ ];
1085
+ }
1086
+ // ============================================================
1087
+ // Factory Functions
1088
+ // ============================================================
1089
+ function createVSGraph(name) {
1090
+ return {
1091
+ id: `graph_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1092
+ name,
1093
+ nodes: [],
1094
+ connections: [],
1095
+ variables: [],
1096
+ functions: [],
1097
+ macros: [],
1098
+ parameters: [],
1099
+ graphType: 'blueprint',
1100
+ };
1101
+ }
1102
+ function createVSNode(type, position) {
1103
+ return {
1104
+ id: `node_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1105
+ type,
1106
+ position,
1107
+ inputs: {},
1108
+ outputs: {},
1109
+ };
1110
+ }
1111
+ function createVSConnection(fromNode, fromPort, toNode, toPort) {
1112
+ return {
1113
+ id: `conn_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1114
+ fromNode,
1115
+ fromPort,
1116
+ toNode,
1117
+ toPort,
1118
+ };
1119
+ }
1120
+ function createVSDebugger() {
1121
+ return new VSDebugger();
1122
+ }
1123
+ function createVSExecutor(debuggerInstance) {
1124
+ const executor = new VSGraphExecutor(debuggerInstance);
1125
+ executor.registerNodes(createBuiltInNodes());
1126
+ return executor;
1127
+ }
1128
+
1129
+ export { VSDebugger, VSGraphExecutor, VS_TYPE_COLORS, createBuiltInNodes, createVSConnection, createVSDebugger, createVSExecutor, createVSGraph, createVSNode };
1130
+ //# sourceMappingURL=VisualScripting2.js.map