project-graph-mcp 2.3.1 → 2.4.0

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 (226) 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/index.js +0 -103
  148. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +0 -361
  149. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +0 -332
  150. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +0 -96
  151. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +0 -104
  152. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +0 -133
  153. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +0 -33
  154. package/vendor/symbiote-node/interactions/ConnectFlow.js +0 -307
  155. package/vendor/symbiote-node/interactions/Drag.js +0 -102
  156. package/vendor/symbiote-node/interactions/Selector.js +0 -132
  157. package/vendor/symbiote-node/interactions/SnapGrid.js +0 -65
  158. package/vendor/symbiote-node/interactions/Zoom.js +0 -140
  159. package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +0 -88
  160. package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +0 -254
  161. package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +0 -11
  162. package/vendor/symbiote-node/layout/Layout/Layout.css.js +0 -88
  163. package/vendor/symbiote-node/layout/Layout/Layout.js +0 -622
  164. package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +0 -25
  165. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +0 -293
  166. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +0 -467
  167. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +0 -33
  168. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +0 -46
  169. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +0 -102
  170. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +0 -6
  171. package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +0 -156
  172. package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +0 -250
  173. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +0 -379
  174. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +0 -263
  175. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +0 -20
  176. package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +0 -183
  177. package/vendor/symbiote-node/layout/LayoutTree.js +0 -246
  178. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +0 -43
  179. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +0 -89
  180. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +0 -14
  181. package/vendor/symbiote-node/layout/index.js +0 -16
  182. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +0 -61
  183. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +0 -79
  184. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +0 -19
  185. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +0 -41
  186. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +0 -24
  187. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +0 -16
  188. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +0 -65
  189. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +0 -29
  190. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +0 -13
  191. package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +0 -683
  192. package/vendor/symbiote-node/node/GraphNode/GraphNode.js +0 -92
  193. package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +0 -17
  194. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +0 -25
  195. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +0 -7
  196. package/vendor/symbiote-node/node/PortItem/PortItem.css.js +0 -90
  197. package/vendor/symbiote-node/node/PortItem/PortItem.js +0 -87
  198. package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +0 -10
  199. package/vendor/symbiote-node/package.json +0 -59
  200. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +0 -143
  201. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +0 -131
  202. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +0 -16
  203. package/vendor/symbiote-node/plugins/History.js +0 -384
  204. package/vendor/symbiote-node/plugins/Readonly.js +0 -59
  205. package/vendor/symbiote-node/shapes/CircleShape.js +0 -80
  206. package/vendor/symbiote-node/shapes/CommentShape.js +0 -35
  207. package/vendor/symbiote-node/shapes/DiamondShape.js +0 -115
  208. package/vendor/symbiote-node/shapes/NodeShape.js +0 -80
  209. package/vendor/symbiote-node/shapes/PillShape.js +0 -91
  210. package/vendor/symbiote-node/shapes/RectShape.js +0 -72
  211. package/vendor/symbiote-node/shapes/SVGShape.js +0 -494
  212. package/vendor/symbiote-node/shapes/index.js +0 -53
  213. package/vendor/symbiote-node/themes/Palette.js +0 -32
  214. package/vendor/symbiote-node/themes/Skin.js +0 -113
  215. package/vendor/symbiote-node/themes/Theme.js +0 -84
  216. package/vendor/symbiote-node/themes/carbon.js +0 -137
  217. package/vendor/symbiote-node/themes/dark.js +0 -137
  218. package/vendor/symbiote-node/themes/ebook.js +0 -138
  219. package/vendor/symbiote-node/themes/grey.js +0 -137
  220. package/vendor/symbiote-node/themes/light.js +0 -137
  221. package/vendor/symbiote-node/themes/neon.js +0 -138
  222. package/vendor/symbiote-node/themes/pcb.js +0 -273
  223. package/vendor/symbiote-node/themes/synthwave.js +0 -137
  224. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +0 -86
  225. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +0 -128
  226. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.tpl.js +0 -29
@@ -1,446 +0,0 @@
1
- /**
2
- * ViewportActions — context menu, keyboard shortcuts, viewport utilities
3
- *
4
- * Handles right-click menus (canvas/node/connection),
5
- * keyboard shortcuts (Delete, Ctrl+A, Escape),
6
- * fitView, selectAll, deleteSelected, and socket highlighting.
7
- * Extracted from NodeCanvas to reduce complexity.
8
- *
9
- * @module symbiote-node/canvas/ViewportActions
10
- */
11
-
12
- export class ViewportActions {
13
-
14
- /** @type {import('../core/Editor.js').NodeEditor} */
15
- #editor;
16
-
17
- /** @type {import('../interactions/Selector.js').Selector} */
18
- #selector;
19
-
20
- /** @type {Map<string, HTMLElement>} */
21
- #nodeViews;
22
-
23
- /** @type {boolean} */
24
- #readonly = false;
25
-
26
- /** @type {Array|null} - clipboard for copy/paste */
27
- #clipboard = null;
28
-
29
- /** @type {import('./NodeCanvas/NodeCanvas.js').NodeCanvas} */
30
- #canvas;
31
-
32
- /**
33
- * @param {object} config
34
- * @param {import('../core/Editor.js').NodeEditor} config.editor
35
- * @param {import('../interactions/Selector.js').Selector} config.selector
36
- * @param {Map<string, HTMLElement>} config.nodeViews
37
- * @param {import('./NodeCanvas/NodeCanvas.js').NodeCanvas} config.canvas
38
- */
39
- constructor({ editor, selector, nodeViews, canvas }) {
40
- this.#editor = editor;
41
- this.#selector = selector;
42
- this.#nodeViews = nodeViews;
43
- this.#canvas = canvas;
44
- }
45
-
46
- /** @param {boolean} readonly */
47
- setReadonly(readonly) {
48
- this.#readonly = readonly;
49
- }
50
-
51
- /**
52
- * Keyboard handler — bind to container
53
- * @param {KeyboardEvent} e
54
- */
55
- handleKeydown = (e) => {
56
- if (this.#readonly) return;
57
-
58
- if (e.key === 'Delete' || e.key === 'Backspace') {
59
- e.preventDefault();
60
- this.deleteSelected();
61
- }
62
-
63
- if (e.key === 'a' && (e.ctrlKey || e.metaKey)) {
64
- e.preventDefault();
65
- this.selectAll();
66
- }
67
-
68
- if (e.key === 'Escape') {
69
- this.#selector.unselectAll();
70
- }
71
-
72
- // Copy selected nodes
73
- if (e.key === 'c' && (e.ctrlKey || e.metaKey)) {
74
- e.preventDefault();
75
- this.#copySelected();
76
- }
77
-
78
- // Paste nodes
79
- if (e.key === 'v' && (e.ctrlKey || e.metaKey)) {
80
- e.preventDefault();
81
- this.#pasteNodes();
82
- }
83
-
84
- // Align horizontal
85
- if (e.key === 'h' && (e.ctrlKey || e.metaKey) && e.shiftKey) {
86
- e.preventDefault();
87
- this.alignSelectedHorizontal();
88
- }
89
-
90
- // Align vertical
91
- if (e.key === 'j' && (e.ctrlKey || e.metaKey) && e.shiftKey) {
92
- e.preventDefault();
93
- this.alignSelectedVertical();
94
- }
95
- };
96
-
97
- /** Select all nodes */
98
- selectAll() {
99
- for (const [id] of this.#nodeViews) {
100
- this.#selector.selectNode(id, true);
101
- }
102
- }
103
-
104
- /** Delete all selected nodes and connections */
105
- deleteSelected() {
106
- if (!this.#editor || this.#readonly) return;
107
-
108
- for (const connId of this.#selector.getSelectedConnections()) {
109
- this.#editor.removeConnection(connId);
110
- }
111
-
112
- for (const nodeId of this.#selector.getSelectedNodes()) {
113
- this.#editor.removeNode(nodeId);
114
- }
115
-
116
- this.#selector.unselectAll();
117
- }
118
-
119
- /** Delete a single node */
120
- deleteNode(nodeId) {
121
- if (!this.#editor || this.#readonly) return;
122
- this.#editor.removeNode(nodeId);
123
- }
124
-
125
- /** Emit clone event for a node */
126
- cloneNode(nodeId) {
127
- if (!this.#editor || this.#readonly) return;
128
- this.#editor.emit('contextclone', { nodeId });
129
- }
130
-
131
- /**
132
- * Generic toggle: flip a boolean on node, sync DOM attribute, emit event
133
- * @param {string} nodeId
134
- * @param {string} prop - node property name (e.g. 'collapsed', 'muted')
135
- * @param {string} attr - DOM attribute name (e.g. 'data-collapsed', 'data-muted')
136
- * @param {string} eventName - editor event (e.g. 'nodecollapse', 'nodemute')
137
- */
138
- #toggleNodeState(nodeId, prop, attr, eventName) {
139
- if (!this.#editor) return;
140
- const node = this.#editor.getNode(nodeId);
141
- if (!node) return;
142
- node[prop] = !node[prop];
143
- const el = this.#nodeViews.get(nodeId);
144
- if (el) {
145
- node[prop] ? el.setAttribute(attr, '') : el.removeAttribute(attr);
146
- }
147
- this.#editor.emit(eventName, { nodeId, [prop]: node[prop] });
148
- }
149
-
150
- /** @param {string} nodeId */
151
- collapseNode(nodeId) { this.#toggleNodeState(nodeId, 'collapsed', 'data-collapsed', 'nodecollapse'); }
152
-
153
- /** @param {string} nodeId */
154
- muteNode(nodeId) { this.#toggleNodeState(nodeId, 'muted', 'data-muted', 'nodemute'); }
155
-
156
- /** Delete a single connection */
157
- deleteConnection(connId) {
158
- if (!this.#editor || this.#readonly) return;
159
- this.#editor.removeConnection(connId);
160
- }
161
-
162
- /**
163
- * Show context menu based on click target
164
- * @param {MouseEvent} e
165
- * @param {HTMLElement} contextMenuEl - context-menu component
166
- * @param {HTMLElement} container - canvas container for coordinate calc
167
- * @param {{ panX: number, panY: number, zoom: number }} transform
168
- */
169
- showContextMenu(e, contextMenuEl, container, transform) {
170
- if (this.#readonly) return;
171
- e.preventDefault();
172
-
173
- const target = e.target.closest('graph-node');
174
- const connTarget = e.target.closest('.sn-conn-path');
175
- if (!contextMenuEl) return;
176
-
177
- const rect = container.getBoundingClientRect();
178
- const menuX = e.clientX - rect.left;
179
- const menuY = e.clientY - rect.top;
180
-
181
- if (target) {
182
- const nodeId = target.getAttribute('node-id');
183
- contextMenuEl.show(menuX, menuY, [
184
- { label: 'Delete Node', icon: 'delete', action: () => this.deleteNode(nodeId) },
185
- { label: 'Clone Node', icon: 'content_copy', action: () => this.cloneNode(nodeId) },
186
- { label: 'Select All', icon: 'select_all', action: () => this.selectAll() },
187
- ]);
188
- } else if (connTarget) {
189
- const connId = connTarget.getAttribute('data-conn-id');
190
- contextMenuEl.show(menuX, menuY, [
191
- { label: 'Delete Connection', icon: 'link_off', action: () => this.deleteConnection(connId) },
192
- ]);
193
- } else {
194
- const graphX = (e.clientX - rect.left - transform.panX) / transform.zoom;
195
- const graphY = (e.clientY - rect.top - transform.panY) / transform.zoom;
196
- contextMenuEl.show(menuX, menuY, [
197
- { label: 'Add Node', icon: 'add_box', action: () => this.#editor?.emit('contextadd', { x: graphX, y: graphY }) },
198
- { label: 'Add Comment', icon: 'sticky_note_2', action: () => this.#editor?.emit('contextaddcomment', { x: graphX, y: graphY }) },
199
- { label: 'Add Frame', icon: 'dashboard', action: () => this.#editor?.emit('contextaddframe', { x: graphX, y: graphY }) },
200
- { label: 'Paste', icon: 'content_paste', action: () => this.#pasteNodes(graphX, graphY) },
201
- { label: 'Select All', icon: 'select_all', action: () => this.selectAll() },
202
- { label: 'Fit View', icon: 'fit_screen', action: () => this.#canvas?.fitView() },
203
- { label: 'Auto Layout', icon: 'auto_fix_high', action: () => this.#editor?.emit('autolayout') },
204
- ]);
205
- }
206
- }
207
-
208
-
209
-
210
- /**
211
- * Highlight sockets compatible with picked socket
212
- * @param {object} socketData
213
- * @param {HTMLElement} nodesLayer
214
- */
215
- highlightCompatibleSockets(socketData, nodesLayer) {
216
- const node = this.#editor.getNode(socketData.nodeId);
217
- if (!node) return;
218
-
219
- const isOutput = socketData.side === 'output';
220
- const pickedPort = isOutput ? node.outputs[socketData.key] : node.inputs[socketData.key];
221
- if (!pickedPort) return;
222
-
223
- const pickedSocket = pickedPort.socket;
224
-
225
- for (const [nodeId, el] of this.#nodeViews) {
226
- if (nodeId === socketData.nodeId) continue;
227
- const targetNode = this.#editor.getNode(nodeId);
228
- if (!targetNode) continue;
229
-
230
- const ports = isOutput ? targetNode.inputs : targetNode.outputs;
231
- for (const [key, port] of Object.entries(ports)) {
232
- const sockets = el.querySelectorAll(`.sn-socket[data-key="${key}"]`);
233
- for (const sock of sockets) {
234
- if (pickedSocket.isCompatibleWith(port.socket)) {
235
- sock.setAttribute('data-compatible', '');
236
- } else {
237
- sock.setAttribute('data-incompatible', '');
238
- }
239
- }
240
- }
241
-
242
- const sameSidePorts = isOutput ? targetNode.outputs : targetNode.inputs;
243
- for (const [key] of Object.entries(sameSidePorts)) {
244
- const sockets = el.querySelectorAll(`.sn-socket[data-key="${key}"]`);
245
- for (const sock of sockets) {
246
- sock.setAttribute('data-incompatible', '');
247
- }
248
- }
249
- }
250
- }
251
-
252
- /**
253
- * Clear all socket highlights
254
- * @param {HTMLElement} nodesLayer
255
- */
256
- clearSocketHighlights(nodesLayer) {
257
- const all = nodesLayer.querySelectorAll('.sn-socket[data-compatible], .sn-socket[data-incompatible]');
258
- for (const sock of all) {
259
- sock.removeAttribute('data-compatible');
260
- sock.removeAttribute('data-incompatible');
261
- }
262
- }
263
-
264
- /**
265
- * Show port hints: highlight compatible ports on nearest side
266
- * @param {number} worldX - Cursor X in graph coordinates
267
- * @param {number} worldY - Cursor Y in graph coordinates
268
- * @param {object} socketData - Picked socket data
269
- * @returns {Set<string>}
270
- */
271
- updatePortHints(worldX, worldY, socketData) {
272
- const compatibleIds = this.getCompatibleNodeIds(socketData);
273
-
274
- for (const [nodeId, el] of this.#nodeViews) {
275
- if (compatibleIds.has(nodeId)) {
276
- const nodePos = el._position;
277
- const nodeW = el.offsetWidth || 180;
278
- const nodeCenterX = nodePos ? nodePos.x + nodeW / 2 : 0;
279
- el.setAttribute('data-port-hint', worldX < nodeCenterX ? 'left' : 'right');
280
- } else {
281
- el.removeAttribute('data-port-hint');
282
- }
283
- }
284
-
285
- return compatibleIds;
286
- }
287
-
288
- /**
289
- * Get set of node IDs with compatible ports (no teleportation)
290
- * @param {object} socketData - Picked socket data
291
- * @returns {Set<string>}
292
- */
293
- getCompatibleNodeIds(socketData) {
294
- const pickedNode = this.#editor.getNode(socketData.nodeId);
295
- if (!pickedNode) return new Set();
296
-
297
- const isOutput = socketData.side === 'output';
298
- const pickedPort = isOutput ? pickedNode.outputs[socketData.key] : pickedNode.inputs[socketData.key];
299
- if (!pickedPort) return new Set();
300
-
301
- const pickedSocket = pickedPort.socket;
302
- const compatibleIds = new Set();
303
-
304
- for (const [nodeId] of this.#nodeViews) {
305
- if (nodeId === socketData.nodeId) continue;
306
- const targetNode = this.#editor.getNode(nodeId);
307
- if (!targetNode) continue;
308
-
309
- const ports = isOutput ? targetNode.inputs : targetNode.outputs;
310
- for (const [, port] of Object.entries(ports)) {
311
- if (pickedSocket.isCompatibleWith(port.socket)) {
312
- compatibleIds.add(nodeId);
313
- break;
314
- }
315
- }
316
- }
317
-
318
- return compatibleIds;
319
- }
320
-
321
- /**
322
- * Clear all port hints
323
- */
324
- clearPortHints() {
325
- for (const [, el] of this.#nodeViews) {
326
- el.removeAttribute('data-port-hint');
327
- }
328
- }
329
-
330
- /**
331
- * Handle connection dropped in empty space
332
- * @param {number} x
333
- * @param {number} y
334
- * @param {object} socketData
335
- */
336
- handleDropEmpty(x, y, socketData) {
337
- const node = this.#editor.getNode(socketData.nodeId);
338
- if (!node) return;
339
-
340
- const isOutput = socketData.side === 'output';
341
- const port = isOutput ? node.outputs[socketData.key] : node.inputs[socketData.key];
342
- const socketType = port?.socket?.type || 'any';
343
-
344
- this.#editor.emit('dropinempty', {
345
- x, y,
346
- sourceNodeId: socketData.nodeId,
347
- sourceKey: socketData.key,
348
- sourceSide: socketData.side,
349
- socketType,
350
- });
351
- }
352
-
353
- // --- Copy/Paste ---
354
-
355
- #copySelected() {
356
- const selected = this.#selector.getSelectedNodes();
357
- if (selected.length === 0) return;
358
-
359
- this.#clipboard = selected.map(nodeId => {
360
- const node = this.#editor.getNode(nodeId);
361
- const el = this.#nodeViews.get(nodeId);
362
- if (!node) return null;
363
- return {
364
- label: node.label,
365
- type: node.type,
366
- category: node.category,
367
- shape: node.shape,
368
- params: { ...node.params },
369
- position: el?._position ? { ...el._position } : { x: 0, y: 0 },
370
- };
371
- }).filter(Boolean);
372
- }
373
-
374
- /**
375
- * Paste copied nodes at optional position
376
- * @param {number} [x]
377
- * @param {number} [y]
378
- */
379
- #pasteNodes(x, y) {
380
- if (!this.#clipboard || this.#clipboard.length === 0) return;
381
-
382
- const offset = 30;
383
- for (const data of this.#clipboard) {
384
- const posX = x != null ? x : data.position.x + offset;
385
- const posY = y != null ? y : data.position.y + offset;
386
- this.#editor.emit('contextclone', {
387
- label: data.label,
388
- type: data.type,
389
- category: data.category,
390
- shape: data.shape,
391
- x: posX,
392
- y: posY,
393
- });
394
- }
395
- }
396
-
397
- // --- Align Tools ---
398
-
399
- /** Align selected nodes horizontally (same Y) */
400
- alignSelectedHorizontal() {
401
- const selected = this.#selector.getSelectedNodes();
402
- if (selected.length < 2) return;
403
-
404
- let totalY = 0;
405
- for (const nodeId of selected) {
406
- const el = this.#nodeViews.get(nodeId);
407
- totalY += el?._position?.y || 0;
408
- }
409
- const avgY = totalY / selected.length;
410
-
411
- for (const nodeId of selected) {
412
- const el = this.#nodeViews.get(nodeId);
413
- if (el?._position) {
414
- this.#editor.emit('nodemovetopos', {
415
- nodeId,
416
- x: el._position.x,
417
- y: avgY,
418
- });
419
- }
420
- }
421
- }
422
-
423
- /** Align selected nodes vertically (same X) */
424
- alignSelectedVertical() {
425
- const selected = this.#selector.getSelectedNodes();
426
- if (selected.length < 2) return;
427
-
428
- let totalX = 0;
429
- for (const nodeId of selected) {
430
- const el = this.#nodeViews.get(nodeId);
431
- totalX += el?._position?.x || 0;
432
- }
433
- const avgX = totalX / selected.length;
434
-
435
- for (const nodeId of selected) {
436
- const el = this.#nodeViews.get(nodeId);
437
- if (el?._position) {
438
- this.#editor.emit('nodemovetopos', {
439
- nodeId,
440
- x: avgX,
441
- y: el._position.y,
442
- });
443
- }
444
- }
445
- }
446
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Connection — link between two node ports
3
- *
4
- * Uses symbiote-node naming: from/out/to/in
5
- * Adds connection ID for selection/history support.
6
- *
7
- * @module symbiote-node/core/Connection
8
- */
9
-
10
- import { uid } from './Socket.js';
11
-
12
- export class Connection {
13
- /**
14
- * @param {import('./Node.js').Node} sourceNode - Source node
15
- * @param {string} sourceOutput - Output port key
16
- * @param {import('./Node.js').Node} targetNode - Target node
17
- * @param {string} targetInput - Input port key
18
- */
19
- constructor(sourceNode, sourceOutput, targetNode, targetInput) {
20
- if (!sourceNode.outputs[sourceOutput]) {
21
- throw new Error(`source node doesn't have output '${sourceOutput}'`);
22
- }
23
- if (!targetNode.inputs[targetInput]) {
24
- throw new Error(`target node doesn't have input '${targetInput}'`);
25
- }
26
-
27
- /** @type {string} */
28
- this.id = uid('conn');
29
-
30
- /** @type {string} - Source node ID (symbiote-node: 'from') */
31
- this.from = sourceNode.id;
32
-
33
- /** @type {string} - Source output key (symbiote-node: 'out') */
34
- this.out = sourceOutput;
35
-
36
- /** @type {string} - Target node ID (symbiote-node: 'to') */
37
- this.to = targetNode.id;
38
-
39
- /** @type {string} - Target input key (symbiote-node: 'in') */
40
- this.in = targetInput;
41
-
42
- /** @type {boolean} */
43
- this.selected = false;
44
- }
45
- }