project-graph-mcp 2.3.2 → 2.4.1

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 (279) hide show
  1. package/package.json +3 -2
  2. package/src/analysis/analysis-cache.ctx +9 -0
  3. package/src/analysis/analysis-cache.js +1 -1
  4. package/src/analysis/complexity.ctx +6 -0
  5. package/src/analysis/complexity.js +1 -1
  6. package/src/analysis/custom-rules.ctx +14 -0
  7. package/src/analysis/custom-rules.js +1 -1
  8. package/src/analysis/db-analysis.ctx +7 -0
  9. package/src/analysis/db-analysis.js +1 -1
  10. package/src/analysis/dead-code.ctx +6 -0
  11. package/src/analysis/dead-code.js +1 -1
  12. package/src/analysis/full-analysis.ctx +9 -0
  13. package/src/analysis/full-analysis.js +1 -1
  14. package/src/analysis/jsdoc-checker.ctx +10 -0
  15. package/src/analysis/jsdoc-checker.js +1 -1
  16. package/src/analysis/jsdoc-generator.ctx +9 -0
  17. package/src/analysis/jsdoc-generator.js +1 -1
  18. package/src/analysis/large-files.ctx +6 -0
  19. package/src/analysis/large-files.js +1 -1
  20. package/src/analysis/outdated-patterns.ctx +7 -0
  21. package/src/analysis/outdated-patterns.js +1 -1
  22. package/src/analysis/similar-functions.ctx +6 -0
  23. package/src/analysis/similar-functions.js +1 -1
  24. package/src/analysis/test-annotations.ctx +11 -0
  25. package/src/analysis/test-annotations.js +1 -1
  26. package/src/analysis/type-checker.ctx +6 -0
  27. package/src/analysis/type-checker.js +1 -1
  28. package/src/analysis/undocumented.ctx +8 -0
  29. package/src/analysis/undocumented.js +1 -1
  30. package/src/cli/cli-handlers.ctx +7 -0
  31. package/src/cli/cli-handlers.js +1 -1
  32. package/src/cli/cli.ctx +6 -0
  33. package/src/cli/cli.js +1 -1
  34. package/src/compact/ai-context.ctx +6 -0
  35. package/src/compact/ai-context.js +1 -1
  36. package/src/compact/compact-migrate.ctx +8 -0
  37. package/src/compact/compact-migrate.js +1 -1
  38. package/src/compact/compact.ctx +11 -0
  39. package/src/compact/compact.js +1 -1
  40. package/src/compact/compress.ctx +7 -0
  41. package/src/compact/compress.js +1 -1
  42. package/src/compact/ctx-resolver.ctx +2 -0
  43. package/src/compact/ctx-resolver.js +1 -1
  44. package/src/compact/ctx-to-jsdoc.ctx +11 -0
  45. package/src/compact/ctx-to-jsdoc.js +1 -1
  46. package/src/compact/doc-dialect.ctx +11 -0
  47. package/src/compact/doc-dialect.js +2 -2
  48. package/src/compact/expand.ctx +14 -0
  49. package/src/compact/expand.js +1 -1
  50. package/src/compact/framework-references.ctx +7 -0
  51. package/src/compact/framework-references.js +1 -1
  52. package/src/compact/instructions.ctx +6 -0
  53. package/src/compact/instructions.js +1 -1
  54. package/src/compact/jsdoc-builder.ctx +4 -0
  55. package/src/compact/jsdoc-builder.js +1 -1
  56. package/src/compact/mode-config.ctx +8 -0
  57. package/src/compact/mode-config.js +1 -1
  58. package/src/compact/split-declarations.ctx +6 -0
  59. package/src/compact/split-declarations.js +1 -1
  60. package/src/compact/validate-pipeline.ctx +12 -0
  61. package/src/compact/validate-pipeline.js +1 -1
  62. package/src/core/event-bus.ctx +9 -0
  63. package/src/core/event-bus.js +1 -1
  64. package/src/core/file-walker.ctx +1 -0
  65. package/src/core/file-walker.js +1 -1
  66. package/src/core/filters.ctx +12 -0
  67. package/src/core/filters.js +1 -1
  68. package/src/core/graph-builder.ctx +7 -0
  69. package/src/core/graph-builder.js +1 -1
  70. package/src/core/parser.ctx +12 -0
  71. package/src/core/parser.js +1 -1
  72. package/src/core/utils.ctx +1 -0
  73. package/src/core/utils.js +1 -1
  74. package/src/core/workspace.ctx +7 -0
  75. package/src/core/workspace.js +1 -1
  76. package/src/lang/lang-go.ctx +8 -0
  77. package/src/lang/lang-go.js +1 -1
  78. package/src/lang/lang-python.ctx +5 -0
  79. package/src/lang/lang-python.js +1 -1
  80. package/src/lang/lang-sql.ctx +10 -0
  81. package/src/lang/lang-sql.js +1 -1
  82. package/src/lang/lang-typescript.ctx +6 -0
  83. package/src/lang/lang-typescript.js +1 -1
  84. package/src/lang/lang-utils.ctx +5 -0
  85. package/src/lang/lang-utils.js +1 -1
  86. package/src/mcp/mcp-server.ctx +6 -0
  87. package/src/mcp/mcp-server.js +1 -1
  88. package/src/mcp/tool-defs.ctx +2 -0
  89. package/src/mcp/tool-defs.js +1 -1
  90. package/src/mcp/tools.ctx +13 -0
  91. package/src/mcp/tools.js +1 -1
  92. package/src/network/backend-lifecycle.ctx +10 -0
  93. package/src/network/backend-lifecycle.js +1 -1
  94. package/src/network/backend.ctx +5 -0
  95. package/src/network/backend.js +1 -1
  96. package/src/network/local-gateway.ctx +9 -0
  97. package/src/network/local-gateway.js +1 -1
  98. package/src/network/mdns.ctx +6 -0
  99. package/src/network/mdns.js +1 -1
  100. package/src/network/server.ctx +2 -0
  101. package/src/network/server.js +2 -2
  102. package/src/network/web-server.ctx +17 -0
  103. package/src/network/web-server.js +2 -2
  104. package/web/follow-controller.js +94 -25
  105. package/web/panels/dep-graph.js +207 -21
  106. package/project-graph-mcp-2.3.0.tgz +0 -0
  107. package/vendor/symbiote-node/CHANGELOG.md +0 -31
  108. package/vendor/symbiote-node/LICENSE +0 -21
  109. package/vendor/symbiote-node/README.md +0 -206
  110. package/vendor/symbiote-node/canvas/AutoLayout.js +0 -725
  111. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.css.js +0 -73
  112. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.js +0 -93
  113. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.tpl.js +0 -9
  114. package/vendor/symbiote-node/canvas/CanvasConnectionRenderer.js +0 -962
  115. package/vendor/symbiote-node/canvas/ConnectionRenderer.js +0 -1468
  116. package/vendor/symbiote-node/canvas/FlowSimulator.js +0 -323
  117. package/vendor/symbiote-node/canvas/ForceLayout.js +0 -189
  118. package/vendor/symbiote-node/canvas/ForceWorker.js +0 -1325
  119. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.css.js +0 -97
  120. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.js +0 -176
  121. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.tpl.js +0 -12
  122. package/vendor/symbiote-node/canvas/LODManager.js +0 -88
  123. package/vendor/symbiote-node/canvas/Minimap/Minimap.css.js +0 -71
  124. package/vendor/symbiote-node/canvas/Minimap/Minimap.js +0 -207
  125. package/vendor/symbiote-node/canvas/Minimap/Minimap.tpl.js +0 -9
  126. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.css.js +0 -261
  127. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.js +0 -1840
  128. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.tpl.js +0 -22
  129. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.css.js +0 -97
  130. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.js +0 -132
  131. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.tpl.js +0 -21
  132. package/vendor/symbiote-node/canvas/NodeViewManager.js +0 -584
  133. package/vendor/symbiote-node/canvas/PinExpansion.js +0 -131
  134. package/vendor/symbiote-node/canvas/PseudoConnection.js +0 -80
  135. package/vendor/symbiote-node/canvas/SubgraphManager.js +0 -201
  136. package/vendor/symbiote-node/canvas/SubgraphRouter.js +0 -443
  137. package/vendor/symbiote-node/canvas/ViewportActions.js +0 -446
  138. package/vendor/symbiote-node/core/Connection.js +0 -45
  139. package/vendor/symbiote-node/core/Editor.js +0 -451
  140. package/vendor/symbiote-node/core/Frame.js +0 -31
  141. package/vendor/symbiote-node/core/GraphMermaid.js +0 -348
  142. package/vendor/symbiote-node/core/GraphText.js +0 -210
  143. package/vendor/symbiote-node/core/Node.js +0 -143
  144. package/vendor/symbiote-node/core/Portal.js +0 -104
  145. package/vendor/symbiote-node/core/Socket.js +0 -185
  146. package/vendor/symbiote-node/core/SubgraphNode.js +0 -125
  147. package/vendor/symbiote-node/engine/AgentUICommands.js +0 -100
  148. package/vendor/symbiote-node/engine/Executor.js +0 -371
  149. package/vendor/symbiote-node/engine/Graph.js +0 -314
  150. package/vendor/symbiote-node/engine/GraphServer.js +0 -353
  151. package/vendor/symbiote-node/engine/HandlerLoader.js +0 -145
  152. package/vendor/symbiote-node/engine/History.js +0 -83
  153. package/vendor/symbiote-node/engine/Lifecycle.js +0 -118
  154. package/vendor/symbiote-node/engine/Persistence.js +0 -84
  155. package/vendor/symbiote-node/engine/Registry.js +0 -264
  156. package/vendor/symbiote-node/engine/SocketTypes.js +0 -79
  157. package/vendor/symbiote-node/engine/cli.js +0 -404
  158. package/vendor/symbiote-node/engine/index.js +0 -56
  159. package/vendor/symbiote-node/engine/nanoid.js +0 -28
  160. package/vendor/symbiote-node/engine/package.json +0 -26
  161. package/vendor/symbiote-node/engine/packs/ai/beat-detect.handler.js +0 -215
  162. package/vendor/symbiote-node/engine/packs/ai/content-adapt.handler.js +0 -238
  163. package/vendor/symbiote-node/engine/packs/ai/face-detect.handler.js +0 -287
  164. package/vendor/symbiote-node/engine/packs/ai/grok-generate.handler.js +0 -565
  165. package/vendor/symbiote-node/engine/packs/ai/kling-lipsync.handler.js +0 -414
  166. package/vendor/symbiote-node/engine/packs/ai/lesson-generate.handler.js +0 -343
  167. package/vendor/symbiote-node/engine/packs/ai/opencode.handler.js +0 -164
  168. package/vendor/symbiote-node/engine/packs/ai/replicate-lipsync.handler.js +0 -341
  169. package/vendor/symbiote-node/engine/packs/ai/tts.handler.js +0 -241
  170. package/vendor/symbiote-node/engine/packs/ai/whisper.handler.js +0 -191
  171. package/vendor/symbiote-node/engine/packs/data/db-query.handler.js +0 -67
  172. package/vendor/symbiote-node/engine/packs/data/news-accumulate.handler.js +0 -281
  173. package/vendor/symbiote-node/engine/packs/data/personas.handler.js +0 -160
  174. package/vendor/symbiote-node/engine/packs/data/prompt-loader.handler.js +0 -193
  175. package/vendor/symbiote-node/engine/packs/data/roles.handler.js +0 -216
  176. package/vendor/symbiote-node/engine/packs/data/rss-feed.handler.js +0 -244
  177. package/vendor/symbiote-node/engine/packs/debug/inject.handler.js +0 -52
  178. package/vendor/symbiote-node/engine/packs/flow/agent.handler.js +0 -73
  179. package/vendor/symbiote-node/engine/packs/flow/if.handler.js +0 -107
  180. package/vendor/symbiote-node/engine/packs/flow/loop.handler.js +0 -58
  181. package/vendor/symbiote-node/engine/packs/flow/merge.handler.js +0 -60
  182. package/vendor/symbiote-node/engine/packs/flow/retry.handler.js +0 -65
  183. package/vendor/symbiote-node/engine/packs/flow/switch.handler.js +0 -64
  184. package/vendor/symbiote-node/engine/packs/flow/wait-all.handler.js +0 -39
  185. package/vendor/symbiote-node/engine/packs/io/http-request.handler.js +0 -82
  186. package/vendor/symbiote-node/engine/packs/io/read-file.handler.js +0 -60
  187. package/vendor/symbiote-node/engine/packs/io/write-file.handler.js +0 -63
  188. package/vendor/symbiote-node/engine/packs/transform/anchor-match.handler.js +0 -494
  189. package/vendor/symbiote-node/engine/packs/transform/effects-skeleton.handler.js +0 -417
  190. package/vendor/symbiote-node/engine/packs/transform/json-parse.handler.js +0 -43
  191. package/vendor/symbiote-node/engine/packs/transform/lipsync-select.handler.js +0 -339
  192. package/vendor/symbiote-node/engine/packs/transform/riopla-adapt.handler.js +0 -432
  193. package/vendor/symbiote-node/engine/packs/transform/set.handler.js +0 -57
  194. package/vendor/symbiote-node/engine/packs/transform/template-builder.handler.js +0 -134
  195. package/vendor/symbiote-node/engine/packs/transform/template.handler.js +0 -79
  196. package/vendor/symbiote-node/engine/packs/transform/timeline-build.handler.js +0 -399
  197. package/vendor/symbiote-node/engine/packs/util/delay.handler.js +0 -39
  198. package/vendor/symbiote-node/engine/packs/util/log.handler.js +0 -44
  199. package/vendor/symbiote-node/engine/packs/video-pack.js +0 -323
  200. package/vendor/symbiote-node/index.js +0 -103
  201. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +0 -361
  202. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +0 -332
  203. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +0 -96
  204. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +0 -104
  205. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +0 -133
  206. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +0 -33
  207. package/vendor/symbiote-node/interactions/ConnectFlow.js +0 -307
  208. package/vendor/symbiote-node/interactions/Drag.js +0 -102
  209. package/vendor/symbiote-node/interactions/Selector.js +0 -132
  210. package/vendor/symbiote-node/interactions/SnapGrid.js +0 -65
  211. package/vendor/symbiote-node/interactions/Zoom.js +0 -140
  212. package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +0 -88
  213. package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +0 -254
  214. package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +0 -11
  215. package/vendor/symbiote-node/layout/Layout/Layout.css.js +0 -88
  216. package/vendor/symbiote-node/layout/Layout/Layout.js +0 -622
  217. package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +0 -25
  218. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +0 -293
  219. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +0 -467
  220. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +0 -33
  221. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +0 -46
  222. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +0 -102
  223. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +0 -6
  224. package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +0 -156
  225. package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +0 -250
  226. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +0 -379
  227. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +0 -263
  228. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +0 -20
  229. package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +0 -183
  230. package/vendor/symbiote-node/layout/LayoutTree.js +0 -246
  231. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +0 -43
  232. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +0 -89
  233. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +0 -14
  234. package/vendor/symbiote-node/layout/index.js +0 -16
  235. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +0 -61
  236. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +0 -79
  237. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +0 -19
  238. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +0 -41
  239. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +0 -24
  240. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +0 -16
  241. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +0 -65
  242. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +0 -29
  243. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +0 -13
  244. package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +0 -683
  245. package/vendor/symbiote-node/node/GraphNode/GraphNode.js +0 -92
  246. package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +0 -17
  247. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +0 -25
  248. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +0 -7
  249. package/vendor/symbiote-node/node/PortItem/PortItem.css.js +0 -90
  250. package/vendor/symbiote-node/node/PortItem/PortItem.js +0 -87
  251. package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +0 -10
  252. package/vendor/symbiote-node/package.json +0 -59
  253. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +0 -143
  254. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +0 -131
  255. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +0 -16
  256. package/vendor/symbiote-node/plugins/History.js +0 -384
  257. package/vendor/symbiote-node/plugins/Readonly.js +0 -59
  258. package/vendor/symbiote-node/shapes/CircleShape.js +0 -80
  259. package/vendor/symbiote-node/shapes/CommentShape.js +0 -35
  260. package/vendor/symbiote-node/shapes/DiamondShape.js +0 -115
  261. package/vendor/symbiote-node/shapes/NodeShape.js +0 -80
  262. package/vendor/symbiote-node/shapes/PillShape.js +0 -91
  263. package/vendor/symbiote-node/shapes/RectShape.js +0 -72
  264. package/vendor/symbiote-node/shapes/SVGShape.js +0 -494
  265. package/vendor/symbiote-node/shapes/index.js +0 -53
  266. package/vendor/symbiote-node/themes/Palette.js +0 -32
  267. package/vendor/symbiote-node/themes/Skin.js +0 -113
  268. package/vendor/symbiote-node/themes/Theme.js +0 -84
  269. package/vendor/symbiote-node/themes/carbon.js +0 -137
  270. package/vendor/symbiote-node/themes/dark.js +0 -137
  271. package/vendor/symbiote-node/themes/ebook.js +0 -138
  272. package/vendor/symbiote-node/themes/grey.js +0 -137
  273. package/vendor/symbiote-node/themes/light.js +0 -137
  274. package/vendor/symbiote-node/themes/neon.js +0 -138
  275. package/vendor/symbiote-node/themes/pcb.js +0 -273
  276. package/vendor/symbiote-node/themes/synthwave.js +0 -137
  277. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +0 -86
  278. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +0 -128
  279. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.tpl.js +0 -29
@@ -1,323 +0,0 @@
1
- /**
2
- * FlowSimulator — sequential data flow animation
3
- *
4
- * Performs topological traversal of the node graph and animates
5
- * nodes and connections step-by-step (like n8n execution).
6
- *
7
- * @module symbiote-node/canvas/FlowSimulator
8
- */
9
-
10
- /**
11
- * @typedef {Object} FlowSimulatorConfig
12
- * @property {import('../core/Editor.js').NodeEditor} editor
13
- * @property {Object} canvas - NodeCanvas instance (for setFlowing, node views)
14
- */
15
-
16
- export class FlowSimulator {
17
-
18
- /** @type {import('../core/Editor.js').NodeEditor} */
19
- #editor;
20
-
21
- /** @type {Object} */
22
- #canvas;
23
-
24
- /** @type {boolean} */
25
- #running = false;
26
-
27
- /** @type {AbortController|null} */
28
- #abort = null;
29
-
30
- /** @type {number} ms per node step */
31
- speed = 800;
32
-
33
- /** @type {boolean} follow active node with camera */
34
- followActive = false;
35
-
36
- /** @type {boolean} temporarily paused by manual interaction */
37
- #followPaused = false;
38
-
39
- /** @type {number|null} */
40
- #followResumeTimer = null;
41
-
42
- /** @type {number} ms before follow resumes after manual interaction */
43
- followResumDelay = 3000;
44
-
45
- /** Bound handler for manualviewport event */
46
- #handleManualViewport = () => {
47
- if (!this.followActive || !this.#running) return;
48
- this.#followPaused = true;
49
- if (this.#followResumeTimer) clearTimeout(this.#followResumeTimer);
50
- this.#followResumeTimer = setTimeout(() => {
51
- this.#followPaused = false;
52
- this.#followResumeTimer = null;
53
- }, this.followResumDelay);
54
- };
55
-
56
- /**
57
- * @param {import('../core/Editor.js').NodeEditor} editor
58
- * @param {Object} canvas - NodeCanvas instance
59
- */
60
- constructor(editor, canvas) {
61
- this.#editor = editor;
62
- this.#canvas = canvas;
63
- }
64
-
65
- /** @returns {boolean} */
66
- get running() {
67
- return this.#running;
68
- }
69
-
70
- /**
71
- * Run sequential flow animation
72
- * @returns {Promise<void>}
73
- */
74
- async run() {
75
- if (this.#running) return;
76
- this.#running = true;
77
- this.#abort = new AbortController();
78
- this.#followPaused = false;
79
- this.#canvas.addEventListener('manualviewport', this.#handleManualViewport);
80
-
81
- const order = this.#topologicalSort();
82
- const connections = this.#editor.getConnections();
83
- this.#editor.emit('flowstart', { nodes: order });
84
-
85
- try {
86
- for (const nodeId of order) {
87
- if (this.#abort.signal.aborted) break;
88
-
89
- // Mark node as processing
90
- this.#setNodeState(nodeId, 'processing');
91
- this.#editor.emit('nodeprocessing', { nodeId });
92
-
93
- // Smooth pan to active node
94
- if (this.followActive && !this.#followPaused) {
95
- this.#canvas.panToNode?.(nodeId);
96
- }
97
-
98
- // Run inner flow for subgraph nodes
99
- const node = this.#editor.getNode(nodeId);
100
- if (node?._isSubgraph && node.innerEditor) {
101
- await this.#runInnerFlow(nodeId, node);
102
- } else {
103
- await this.#wait(this.speed);
104
- }
105
- if (this.#abort.signal.aborted) break;
106
-
107
- // Mark node as completed
108
- this.#setNodeState(nodeId, 'completed');
109
- this.#editor.emit('nodecompleted', { nodeId });
110
-
111
- // Animate outgoing connections
112
- const outgoing = connections.filter((c) => c.from === nodeId);
113
- for (const conn of outgoing) {
114
- this.#canvas.setFlowing(conn.id, true);
115
- }
116
-
117
- await this.#wait(this.speed * 0.5);
118
- if (this.#abort.signal.aborted) break;
119
-
120
- // Stop flowing
121
- for (const conn of outgoing) {
122
- this.#canvas.setFlowing(conn.id, false);
123
- }
124
- }
125
-
126
- // Emit completion
127
- if (!this.#abort.signal.aborted) {
128
- this.#editor.emit('flowcomplete', {});
129
- }
130
- } finally {
131
- this.#running = false;
132
- this.#abort = null;
133
- this.#canvas.removeEventListener('manualviewport', this.#handleManualViewport);
134
- }
135
- }
136
-
137
- /** Stop animation and clear all states */
138
- stop() {
139
- if (this.#abort) this.#abort.abort();
140
- this.#running = false;
141
- this.#canvas.removeEventListener('manualviewport', this.#handleManualViewport);
142
- if (this.#followResumeTimer) {
143
- clearTimeout(this.#followResumeTimer);
144
- this.#followResumeTimer = null;
145
- }
146
- this.#followPaused = false;
147
-
148
- // Clear all node states
149
- for (const node of this.#editor.getNodes()) {
150
- this.#clearNodeState(node.id);
151
- }
152
-
153
- // Clear all flowing
154
- this.#canvas.setAllFlowing(false);
155
- }
156
-
157
- /**
158
- * Topological sort — Kahn's algorithm
159
- * Returns node IDs ordered from sources to sinks
160
- * @returns {string[]}
161
- */
162
- #topologicalSort() {
163
- const nodes = this.#editor.getNodes();
164
- const connections = this.#editor.getConnections();
165
-
166
- // Collect only nodes that participate in connections
167
- /** @type {Set<string>} */
168
- const connectedIds = new Set();
169
- for (const conn of connections) {
170
- connectedIds.add(conn.from);
171
- connectedIds.add(conn.to);
172
- }
173
-
174
- // Build adjacency + in-degree for connected nodes only
175
- /** @type {Map<string, string[]>} */
176
- const adj = new Map();
177
- /** @type {Map<string, number>} */
178
- const inDeg = new Map();
179
-
180
- for (const node of nodes) {
181
- if (!connectedIds.has(node.id)) continue;
182
- adj.set(node.id, []);
183
- inDeg.set(node.id, 0);
184
- }
185
-
186
- for (const conn of connections) {
187
- adj.get(conn.from)?.push(conn.to);
188
- inDeg.set(conn.to, (inDeg.get(conn.to) || 0) + 1);
189
- }
190
-
191
- // Start from nodes with no incoming connections
192
- /** @type {string[]} */
193
- const queue = [];
194
- for (const [id, deg] of inDeg) {
195
- if (deg === 0) queue.push(id);
196
- }
197
-
198
- /** @type {string[]} */
199
- const result = [];
200
- while (queue.length > 0) {
201
- const id = queue.shift();
202
- result.push(id);
203
- for (const next of adj.get(id) || []) {
204
- const newDeg = (inDeg.get(next) || 1) - 1;
205
- inDeg.set(next, newDeg);
206
- if (newDeg === 0) queue.push(next);
207
- }
208
- }
209
-
210
- return result;
211
- }
212
-
213
- /**
214
- * Animate inner nodes of a subgraph sequentially in its preview canvas
215
- * @param {string} nodeId - Parent subgraph node ID
216
- * @param {import('../core/SubgraphNode.js').SubgraphNode} node
217
- */
218
- async #runInnerFlow(nodeId, node) {
219
- const el = this.#canvas._getNodeView?.(nodeId);
220
- if (!el) {
221
- await this.#wait(this.speed);
222
- return;
223
- }
224
-
225
- const innerEditor = node.innerEditor;
226
- const innerNodes = innerEditor.getNodes();
227
- const innerConns = innerEditor.getConnections();
228
-
229
- if (innerNodes.length === 0) {
230
- await this.#wait(this.speed);
231
- return;
232
- }
233
-
234
- // Topological sort of inner nodes
235
- const adj = new Map();
236
- const inDeg = new Map();
237
- for (const n of innerNodes) {
238
- adj.set(n.id, []);
239
- inDeg.set(n.id, 0);
240
- }
241
- for (const conn of innerConns) {
242
- adj.get(conn.from)?.push(conn.to);
243
- inDeg.set(conn.to, (inDeg.get(conn.to) || 0) + 1);
244
- }
245
- const queue = [];
246
- for (const [id, deg] of inDeg) {
247
- if (deg === 0) queue.push(id);
248
- }
249
- const innerOrder = [];
250
- while (queue.length > 0) {
251
- const id = queue.shift();
252
- innerOrder.push(id);
253
- for (const next of adj.get(id) || []) {
254
- const newDeg = (inDeg.get(next) || 1) - 1;
255
- inDeg.set(next, newDeg);
256
- if (newDeg === 0) queue.push(next);
257
- }
258
- }
259
-
260
- // Distribute speed across inner nodes
261
- const stepTime = this.speed / Math.max(innerOrder.length, 1);
262
- el._innerFlowStates = {};
263
-
264
- for (const innerId of innerOrder) {
265
- if (this.#abort.signal.aborted) break;
266
-
267
- el._innerFlowStates[innerId] = 'processing';
268
- el._redrawPreview?.();
269
-
270
- await this.#wait(stepTime * 0.6);
271
- if (this.#abort.signal.aborted) break;
272
-
273
- el._innerFlowStates[innerId] = 'completed';
274
- el._redrawPreview?.();
275
-
276
- await this.#wait(stepTime * 0.4);
277
- }
278
- }
279
-
280
- /**
281
- * Set visual state on a node element
282
- * @param {string} nodeId
283
- * @param {'processing'|'completed'} state
284
- */
285
- #setNodeState(nodeId, state) {
286
- const el = this.#canvas._getNodeView?.(nodeId);
287
- if (!el) return;
288
- el.removeAttribute('data-processing');
289
- el.removeAttribute('data-completed');
290
- el.setAttribute(`data-${state}`, '');
291
- }
292
-
293
- /**
294
- * Clear visual state from a node element
295
- * @param {string} nodeId
296
- */
297
- #clearNodeState(nodeId) {
298
- const el = this.#canvas._getNodeView?.(nodeId);
299
- if (!el) return;
300
- el.removeAttribute('data-processing');
301
- el.removeAttribute('data-completed');
302
- // Clear inner flow states for subgraph nodes
303
- if (el._innerFlowStates) {
304
- el._innerFlowStates = {};
305
- el._redrawPreview?.();
306
- }
307
- }
308
-
309
- /**
310
- * Cancellable delay
311
- * @param {number} ms
312
- * @returns {Promise<void>}
313
- */
314
- #wait(ms) {
315
- return new Promise((resolve) => {
316
- const timer = setTimeout(resolve, ms);
317
- this.#abort?.signal.addEventListener('abort', () => {
318
- clearTimeout(timer);
319
- resolve();
320
- }, { once: true });
321
- });
322
- }
323
- }
@@ -1,189 +0,0 @@
1
- /**
2
- * ForceLayout — Main-thread wrapper for the ForceWorker.
3
- *
4
- * Manages Web Worker lifecycle and streams position updates
5
- * to the canvas via requestAnimationFrame batching.
6
- *
7
- * Usage:
8
- * const force = new ForceLayout(canvas);
9
- * force.start({ nodes, edges, groups, options });
10
- * force.onTick = (positions) => { ... };
11
- * force.stop();
12
- *
13
- * @module symbiote-node/canvas/ForceLayout
14
- */
15
-
16
- export class ForceLayout {
17
- /** @type {Worker|null} */
18
- #worker = null;
19
-
20
- /** @type {boolean} */
21
- #running = false;
22
-
23
- /** @type {boolean} */
24
- #paused = false;
25
-
26
- /** @type {object|null} */
27
- #latestPositions = null;
28
-
29
- /** @type {number|null} */
30
- #rafId = null;
31
-
32
- /** @type {string[]|null} Node ID order for unpacking Float32Array */
33
- #nodeIds = null;
34
-
35
- /** @type {Function|null} */
36
- onTick = null;
37
-
38
- /** @type {Function|null} */
39
- onDone = null;
40
-
41
- /**
42
- * @param {string} workerUrl - URL to ForceWorker.js
43
- */
44
- constructor(workerUrl) {
45
- this._workerUrl = workerUrl;
46
- }
47
-
48
- /**
49
- * Start force simulation.
50
- * @param {object} data
51
- * @param {Array<{id: string, x?: number, y?: number, mass?: number, group?: string}>} data.nodes
52
- * @param {Array<{from: string, to: string, strength?: number}>} data.edges
53
- * @param {Object<string, string[]>} [data.groups] - { groupId: [nodeId, ...] }
54
- * @param {object} [data.options] - Override simulation parameters (mode: 'converge'|'continuous')
55
- */
56
- start(data) {
57
- this.stop();
58
-
59
- this.#worker = new Worker(this._workerUrl);
60
- this.#running = true;
61
- this.#paused = false;
62
- this.#nodeIds = null;
63
-
64
- this.#worker.onmessage = (e) => {
65
- const msg = e.data;
66
-
67
- // Continuous mode: receive node ID order once for Float32Array unpacking
68
- if (msg.type === 'nodeIds') {
69
- this.#nodeIds = msg.ids;
70
- return;
71
- }
72
-
73
- if (msg.type === 'tick') {
74
- // Unpack Float32Array if present (continuous mode)
75
- if (msg.packed && this.#nodeIds) {
76
- const buf = new Float32Array(msg.packed);
77
- const positions = {};
78
- for (let i = 0; i < this.#nodeIds.length; i++) {
79
- positions[this.#nodeIds[i]] = {
80
- x: Math.round(buf[i * 2]),
81
- y: Math.round(buf[i * 2 + 1]),
82
- };
83
- }
84
- this.#latestPositions = positions;
85
- } else {
86
- // Converge mode: positions as plain object
87
- this.#latestPositions = msg.positions;
88
- }
89
- this.#scheduleRender();
90
- }
91
-
92
- if (msg.type === 'done') {
93
- this.#latestPositions = msg.positions;
94
- this.#flushRender();
95
- this.#running = false;
96
- this.#paused = false;
97
- this.onDone?.(msg.positions, msg.iteration);
98
- this.#cleanup();
99
- }
100
- };
101
-
102
- this.#worker.onerror = (err) => {
103
- console.error('[ForceLayout] Worker error:', err);
104
- this.#running = false;
105
- this.#paused = false;
106
- this.#cleanup();
107
- };
108
-
109
- this.#worker.postMessage({ type: 'init', ...data });
110
- }
111
-
112
- /** Stop simulation and terminate Worker. */
113
- stop() {
114
- if (this.#worker) {
115
- this.#worker.postMessage({ type: 'stop' });
116
- }
117
- this.#cleanup();
118
- }
119
-
120
- /** Pause simulation (continuous mode). Worker stays alive. */
121
- pause() {
122
- if (!this.#worker || !this.#running || this.#paused) return;
123
- this.#paused = true;
124
- this.#worker.postMessage({ type: 'pause' });
125
- }
126
-
127
- /** Resume simulation (continuous mode). Gentle reheat. */
128
- resume() {
129
- if (!this.#worker || !this.#running || !this.#paused) return;
130
- this.#paused = false;
131
- this.#worker.postMessage({ type: 'resume' });
132
- }
133
-
134
- /**
135
- * Pin a node at a fixed position (for drag interactions).
136
- * In continuous mode, triggers local reheat.
137
- * @param {string} id
138
- * @param {number} x
139
- * @param {number} y
140
- */
141
- pin(id, x, y) {
142
- if (!this.#worker || !this.#running) return;
143
- this.#worker.postMessage({ type: 'pin', id, x, y });
144
- }
145
-
146
- /**
147
- * Release a pinned node.
148
- * @param {string} id
149
- */
150
- unpin(id) {
151
- if (!this.#worker || !this.#running) return;
152
- this.#worker.postMessage({ type: 'unpin', id });
153
- }
154
-
155
- /** @returns {boolean} */
156
- get running() { return this.#running; }
157
-
158
- /** @returns {boolean} */
159
- get paused() { return this.#paused; }
160
-
161
- #scheduleRender() {
162
- if (this.#rafId !== null) return;
163
- this.#rafId = requestAnimationFrame(() => {
164
- this.#rafId = null;
165
- this.#flushRender();
166
- });
167
- }
168
-
169
- #flushRender() {
170
- if (this.#latestPositions) {
171
- this.onTick?.(this.#latestPositions);
172
- this.#latestPositions = null;
173
- }
174
- }
175
-
176
- #cleanup() {
177
- if (this.#rafId !== null) {
178
- cancelAnimationFrame(this.#rafId);
179
- this.#rafId = null;
180
- }
181
- if (this.#worker) {
182
- this.#worker.terminate();
183
- this.#worker = null;
184
- }
185
- this.#running = false;
186
- this.#paused = false;
187
- this.#nodeIds = null;
188
- }
189
- }