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.
- package/package.json +3 -2
- package/src/analysis/analysis-cache.ctx +9 -0
- package/src/analysis/analysis-cache.js +1 -1
- package/src/analysis/complexity.ctx +6 -0
- package/src/analysis/complexity.js +1 -1
- package/src/analysis/custom-rules.ctx +14 -0
- package/src/analysis/custom-rules.js +1 -1
- package/src/analysis/db-analysis.ctx +7 -0
- package/src/analysis/db-analysis.js +1 -1
- package/src/analysis/dead-code.ctx +6 -0
- package/src/analysis/dead-code.js +1 -1
- package/src/analysis/full-analysis.ctx +9 -0
- package/src/analysis/full-analysis.js +1 -1
- package/src/analysis/jsdoc-checker.ctx +10 -0
- package/src/analysis/jsdoc-checker.js +1 -1
- package/src/analysis/jsdoc-generator.ctx +9 -0
- package/src/analysis/jsdoc-generator.js +1 -1
- package/src/analysis/large-files.ctx +6 -0
- package/src/analysis/large-files.js +1 -1
- package/src/analysis/outdated-patterns.ctx +7 -0
- package/src/analysis/outdated-patterns.js +1 -1
- package/src/analysis/similar-functions.ctx +6 -0
- package/src/analysis/similar-functions.js +1 -1
- package/src/analysis/test-annotations.ctx +11 -0
- package/src/analysis/test-annotations.js +1 -1
- package/src/analysis/type-checker.ctx +6 -0
- package/src/analysis/type-checker.js +1 -1
- package/src/analysis/undocumented.ctx +8 -0
- package/src/analysis/undocumented.js +1 -1
- package/src/cli/cli-handlers.ctx +7 -0
- package/src/cli/cli-handlers.js +1 -1
- package/src/cli/cli.ctx +6 -0
- package/src/cli/cli.js +1 -1
- package/src/compact/ai-context.ctx +6 -0
- package/src/compact/ai-context.js +1 -1
- package/src/compact/compact-migrate.ctx +8 -0
- package/src/compact/compact-migrate.js +1 -1
- package/src/compact/compact.ctx +11 -0
- package/src/compact/compact.js +1 -1
- package/src/compact/compress.ctx +7 -0
- package/src/compact/compress.js +1 -1
- package/src/compact/ctx-resolver.ctx +2 -0
- package/src/compact/ctx-resolver.js +1 -1
- package/src/compact/ctx-to-jsdoc.ctx +11 -0
- package/src/compact/ctx-to-jsdoc.js +1 -1
- package/src/compact/doc-dialect.ctx +11 -0
- package/src/compact/doc-dialect.js +2 -2
- package/src/compact/expand.ctx +14 -0
- package/src/compact/expand.js +1 -1
- package/src/compact/framework-references.ctx +7 -0
- package/src/compact/framework-references.js +1 -1
- package/src/compact/instructions.ctx +6 -0
- package/src/compact/instructions.js +1 -1
- package/src/compact/jsdoc-builder.ctx +4 -0
- package/src/compact/jsdoc-builder.js +1 -1
- package/src/compact/mode-config.ctx +8 -0
- package/src/compact/mode-config.js +1 -1
- package/src/compact/split-declarations.ctx +6 -0
- package/src/compact/split-declarations.js +1 -1
- package/src/compact/validate-pipeline.ctx +12 -0
- package/src/compact/validate-pipeline.js +1 -1
- package/src/core/event-bus.ctx +9 -0
- package/src/core/event-bus.js +1 -1
- package/src/core/file-walker.ctx +1 -0
- package/src/core/file-walker.js +1 -1
- package/src/core/filters.ctx +12 -0
- package/src/core/filters.js +1 -1
- package/src/core/graph-builder.ctx +7 -0
- package/src/core/graph-builder.js +1 -1
- package/src/core/parser.ctx +12 -0
- package/src/core/parser.js +1 -1
- package/src/core/utils.ctx +1 -0
- package/src/core/utils.js +1 -1
- package/src/core/workspace.ctx +7 -0
- package/src/core/workspace.js +1 -1
- package/src/lang/lang-go.ctx +8 -0
- package/src/lang/lang-go.js +1 -1
- package/src/lang/lang-python.ctx +5 -0
- package/src/lang/lang-python.js +1 -1
- package/src/lang/lang-sql.ctx +10 -0
- package/src/lang/lang-sql.js +1 -1
- package/src/lang/lang-typescript.ctx +6 -0
- package/src/lang/lang-typescript.js +1 -1
- package/src/lang/lang-utils.ctx +5 -0
- package/src/lang/lang-utils.js +1 -1
- package/src/mcp/mcp-server.ctx +6 -0
- package/src/mcp/mcp-server.js +1 -1
- package/src/mcp/tool-defs.ctx +2 -0
- package/src/mcp/tool-defs.js +1 -1
- package/src/mcp/tools.ctx +13 -0
- package/src/mcp/tools.js +1 -1
- package/src/network/backend-lifecycle.ctx +10 -0
- package/src/network/backend-lifecycle.js +1 -1
- package/src/network/backend.ctx +5 -0
- package/src/network/backend.js +1 -1
- package/src/network/local-gateway.ctx +9 -0
- package/src/network/local-gateway.js +1 -1
- package/src/network/mdns.ctx +6 -0
- package/src/network/mdns.js +1 -1
- package/src/network/server.ctx +2 -0
- package/src/network/server.js +2 -2
- package/src/network/web-server.ctx +17 -0
- package/src/network/web-server.js +2 -2
- package/web/follow-controller.js +94 -25
- package/web/panels/dep-graph.js +207 -21
- package/project-graph-mcp-2.3.0.tgz +0 -0
- package/vendor/symbiote-node/CHANGELOG.md +0 -31
- package/vendor/symbiote-node/LICENSE +0 -21
- package/vendor/symbiote-node/README.md +0 -206
- package/vendor/symbiote-node/canvas/AutoLayout.js +0 -725
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.css.js +0 -73
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.js +0 -93
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.tpl.js +0 -9
- package/vendor/symbiote-node/canvas/CanvasConnectionRenderer.js +0 -962
- package/vendor/symbiote-node/canvas/ConnectionRenderer.js +0 -1468
- package/vendor/symbiote-node/canvas/FlowSimulator.js +0 -323
- package/vendor/symbiote-node/canvas/ForceLayout.js +0 -189
- package/vendor/symbiote-node/canvas/ForceWorker.js +0 -1325
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.css.js +0 -97
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.js +0 -176
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.tpl.js +0 -12
- package/vendor/symbiote-node/canvas/LODManager.js +0 -88
- package/vendor/symbiote-node/canvas/Minimap/Minimap.css.js +0 -71
- package/vendor/symbiote-node/canvas/Minimap/Minimap.js +0 -207
- package/vendor/symbiote-node/canvas/Minimap/Minimap.tpl.js +0 -9
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.css.js +0 -261
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.js +0 -1840
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.tpl.js +0 -22
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.css.js +0 -97
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.js +0 -132
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.tpl.js +0 -21
- package/vendor/symbiote-node/canvas/NodeViewManager.js +0 -584
- package/vendor/symbiote-node/canvas/PinExpansion.js +0 -131
- package/vendor/symbiote-node/canvas/PseudoConnection.js +0 -80
- package/vendor/symbiote-node/canvas/SubgraphManager.js +0 -201
- package/vendor/symbiote-node/canvas/SubgraphRouter.js +0 -443
- package/vendor/symbiote-node/canvas/ViewportActions.js +0 -446
- package/vendor/symbiote-node/core/Connection.js +0 -45
- package/vendor/symbiote-node/core/Editor.js +0 -451
- package/vendor/symbiote-node/core/Frame.js +0 -31
- package/vendor/symbiote-node/core/GraphMermaid.js +0 -348
- package/vendor/symbiote-node/core/GraphText.js +0 -210
- package/vendor/symbiote-node/core/Node.js +0 -143
- package/vendor/symbiote-node/core/Portal.js +0 -104
- package/vendor/symbiote-node/core/Socket.js +0 -185
- package/vendor/symbiote-node/core/SubgraphNode.js +0 -125
- package/vendor/symbiote-node/engine/AgentUICommands.js +0 -100
- package/vendor/symbiote-node/engine/Executor.js +0 -371
- package/vendor/symbiote-node/engine/Graph.js +0 -314
- package/vendor/symbiote-node/engine/GraphServer.js +0 -353
- package/vendor/symbiote-node/engine/HandlerLoader.js +0 -145
- package/vendor/symbiote-node/engine/History.js +0 -83
- package/vendor/symbiote-node/engine/Lifecycle.js +0 -118
- package/vendor/symbiote-node/engine/Persistence.js +0 -84
- package/vendor/symbiote-node/engine/Registry.js +0 -264
- package/vendor/symbiote-node/engine/SocketTypes.js +0 -79
- package/vendor/symbiote-node/engine/cli.js +0 -404
- package/vendor/symbiote-node/engine/index.js +0 -56
- package/vendor/symbiote-node/engine/nanoid.js +0 -28
- package/vendor/symbiote-node/engine/package.json +0 -26
- package/vendor/symbiote-node/engine/packs/ai/beat-detect.handler.js +0 -215
- package/vendor/symbiote-node/engine/packs/ai/content-adapt.handler.js +0 -238
- package/vendor/symbiote-node/engine/packs/ai/face-detect.handler.js +0 -287
- package/vendor/symbiote-node/engine/packs/ai/grok-generate.handler.js +0 -565
- package/vendor/symbiote-node/engine/packs/ai/kling-lipsync.handler.js +0 -414
- package/vendor/symbiote-node/engine/packs/ai/lesson-generate.handler.js +0 -343
- package/vendor/symbiote-node/engine/packs/ai/opencode.handler.js +0 -164
- package/vendor/symbiote-node/engine/packs/ai/replicate-lipsync.handler.js +0 -341
- package/vendor/symbiote-node/engine/packs/ai/tts.handler.js +0 -241
- package/vendor/symbiote-node/engine/packs/ai/whisper.handler.js +0 -191
- package/vendor/symbiote-node/engine/packs/data/db-query.handler.js +0 -67
- package/vendor/symbiote-node/engine/packs/data/news-accumulate.handler.js +0 -281
- package/vendor/symbiote-node/engine/packs/data/personas.handler.js +0 -160
- package/vendor/symbiote-node/engine/packs/data/prompt-loader.handler.js +0 -193
- package/vendor/symbiote-node/engine/packs/data/roles.handler.js +0 -216
- package/vendor/symbiote-node/engine/packs/data/rss-feed.handler.js +0 -244
- package/vendor/symbiote-node/engine/packs/debug/inject.handler.js +0 -52
- package/vendor/symbiote-node/engine/packs/flow/agent.handler.js +0 -73
- package/vendor/symbiote-node/engine/packs/flow/if.handler.js +0 -107
- package/vendor/symbiote-node/engine/packs/flow/loop.handler.js +0 -58
- package/vendor/symbiote-node/engine/packs/flow/merge.handler.js +0 -60
- package/vendor/symbiote-node/engine/packs/flow/retry.handler.js +0 -65
- package/vendor/symbiote-node/engine/packs/flow/switch.handler.js +0 -64
- package/vendor/symbiote-node/engine/packs/flow/wait-all.handler.js +0 -39
- package/vendor/symbiote-node/engine/packs/io/http-request.handler.js +0 -82
- package/vendor/symbiote-node/engine/packs/io/read-file.handler.js +0 -60
- package/vendor/symbiote-node/engine/packs/io/write-file.handler.js +0 -63
- package/vendor/symbiote-node/engine/packs/transform/anchor-match.handler.js +0 -494
- package/vendor/symbiote-node/engine/packs/transform/effects-skeleton.handler.js +0 -417
- package/vendor/symbiote-node/engine/packs/transform/json-parse.handler.js +0 -43
- package/vendor/symbiote-node/engine/packs/transform/lipsync-select.handler.js +0 -339
- package/vendor/symbiote-node/engine/packs/transform/riopla-adapt.handler.js +0 -432
- package/vendor/symbiote-node/engine/packs/transform/set.handler.js +0 -57
- package/vendor/symbiote-node/engine/packs/transform/template-builder.handler.js +0 -134
- package/vendor/symbiote-node/engine/packs/transform/template.handler.js +0 -79
- package/vendor/symbiote-node/engine/packs/transform/timeline-build.handler.js +0 -399
- package/vendor/symbiote-node/engine/packs/util/delay.handler.js +0 -39
- package/vendor/symbiote-node/engine/packs/util/log.handler.js +0 -44
- package/vendor/symbiote-node/engine/packs/video-pack.js +0 -323
- package/vendor/symbiote-node/index.js +0 -103
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +0 -361
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +0 -332
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +0 -96
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +0 -104
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +0 -133
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +0 -33
- package/vendor/symbiote-node/interactions/ConnectFlow.js +0 -307
- package/vendor/symbiote-node/interactions/Drag.js +0 -102
- package/vendor/symbiote-node/interactions/Selector.js +0 -132
- package/vendor/symbiote-node/interactions/SnapGrid.js +0 -65
- package/vendor/symbiote-node/interactions/Zoom.js +0 -140
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +0 -88
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +0 -254
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +0 -11
- package/vendor/symbiote-node/layout/Layout/Layout.css.js +0 -88
- package/vendor/symbiote-node/layout/Layout/Layout.js +0 -622
- package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +0 -25
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +0 -293
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +0 -467
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +0 -33
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +0 -46
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +0 -102
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +0 -6
- package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +0 -156
- package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +0 -250
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +0 -379
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +0 -263
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +0 -20
- package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +0 -183
- package/vendor/symbiote-node/layout/LayoutTree.js +0 -246
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +0 -43
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +0 -89
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +0 -14
- package/vendor/symbiote-node/layout/index.js +0 -16
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +0 -61
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +0 -79
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +0 -19
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +0 -41
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +0 -24
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +0 -16
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +0 -65
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +0 -29
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +0 -13
- package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +0 -683
- package/vendor/symbiote-node/node/GraphNode/GraphNode.js +0 -92
- package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +0 -17
- package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +0 -25
- package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +0 -7
- package/vendor/symbiote-node/node/PortItem/PortItem.css.js +0 -90
- package/vendor/symbiote-node/node/PortItem/PortItem.js +0 -87
- package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +0 -10
- package/vendor/symbiote-node/package.json +0 -59
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +0 -143
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +0 -131
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +0 -16
- package/vendor/symbiote-node/plugins/History.js +0 -384
- package/vendor/symbiote-node/plugins/Readonly.js +0 -59
- package/vendor/symbiote-node/shapes/CircleShape.js +0 -80
- package/vendor/symbiote-node/shapes/CommentShape.js +0 -35
- package/vendor/symbiote-node/shapes/DiamondShape.js +0 -115
- package/vendor/symbiote-node/shapes/NodeShape.js +0 -80
- package/vendor/symbiote-node/shapes/PillShape.js +0 -91
- package/vendor/symbiote-node/shapes/RectShape.js +0 -72
- package/vendor/symbiote-node/shapes/SVGShape.js +0 -494
- package/vendor/symbiote-node/shapes/index.js +0 -53
- package/vendor/symbiote-node/themes/Palette.js +0 -32
- package/vendor/symbiote-node/themes/Skin.js +0 -113
- package/vendor/symbiote-node/themes/Theme.js +0 -84
- package/vendor/symbiote-node/themes/carbon.js +0 -137
- package/vendor/symbiote-node/themes/dark.js +0 -137
- package/vendor/symbiote-node/themes/ebook.js +0 -138
- package/vendor/symbiote-node/themes/grey.js +0 -137
- package/vendor/symbiote-node/themes/light.js +0 -137
- package/vendor/symbiote-node/themes/neon.js +0 -138
- package/vendor/symbiote-node/themes/pcb.js +0 -273
- package/vendor/symbiote-node/themes/synthwave.js +0 -137
- package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +0 -86
- package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +0 -128
- 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
|
-
}
|