project-graph-mcp 2.2.4 → 2.3.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.
- package/ARCHITECTURE.md +81 -0
- package/CHANGELOG.md +57 -0
- package/README.md +9 -4
- package/package.json +6 -13
- package/src/compact/expand.js +2 -4
- package/src/core/graph-builder.js +2 -2
- package/src/core/parser.js +2 -2
- package/src/network/server.js +1 -2
- package/src/network/web-server.js +4 -1
- package/vendor/symbiote-node/CHANGELOG.md +31 -0
- package/vendor/symbiote-node/LICENSE +21 -0
- package/vendor/symbiote-node/README.md +206 -0
- package/vendor/symbiote-node/canvas/AutoLayout.js +725 -0
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.css.js +73 -0
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.js +93 -0
- package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.tpl.js +9 -0
- package/vendor/symbiote-node/canvas/CanvasConnectionRenderer.js +962 -0
- package/vendor/symbiote-node/canvas/ConnectionRenderer.js +1468 -0
- package/vendor/symbiote-node/canvas/FlowSimulator.js +323 -0
- package/vendor/symbiote-node/canvas/ForceLayout.js +189 -0
- package/vendor/symbiote-node/canvas/ForceWorker.js +1325 -0
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.css.js +97 -0
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.js +176 -0
- package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/vendor/symbiote-node/canvas/LODManager.js +88 -0
- package/vendor/symbiote-node/canvas/Minimap/Minimap.css.js +71 -0
- package/vendor/symbiote-node/canvas/Minimap/Minimap.js +207 -0
- package/vendor/symbiote-node/canvas/Minimap/Minimap.tpl.js +9 -0
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.css.js +261 -0
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.js +1840 -0
- package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.js +132 -0
- package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.tpl.js +21 -0
- package/vendor/symbiote-node/canvas/NodeViewManager.js +584 -0
- package/vendor/symbiote-node/canvas/PinExpansion.js +131 -0
- package/vendor/symbiote-node/canvas/PseudoConnection.js +80 -0
- package/vendor/symbiote-node/canvas/SubgraphManager.js +201 -0
- package/vendor/symbiote-node/canvas/SubgraphRouter.js +443 -0
- package/vendor/symbiote-node/canvas/ViewportActions.js +446 -0
- package/vendor/symbiote-node/core/Connection.js +45 -0
- package/vendor/symbiote-node/core/Editor.js +451 -0
- package/vendor/symbiote-node/core/Frame.js +31 -0
- package/vendor/symbiote-node/core/GraphMermaid.js +348 -0
- package/vendor/symbiote-node/core/GraphText.js +210 -0
- package/vendor/symbiote-node/core/Node.js +143 -0
- package/vendor/symbiote-node/core/Portal.js +104 -0
- package/vendor/symbiote-node/core/Socket.js +185 -0
- package/vendor/symbiote-node/core/SubgraphNode.js +125 -0
- package/vendor/symbiote-node/index.js +103 -0
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +361 -0
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +332 -0
- package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +133 -0
- package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/vendor/symbiote-node/interactions/ConnectFlow.js +307 -0
- package/vendor/symbiote-node/interactions/Drag.js +102 -0
- package/vendor/symbiote-node/interactions/Selector.js +132 -0
- package/vendor/symbiote-node/interactions/SnapGrid.js +65 -0
- package/vendor/symbiote-node/interactions/Zoom.js +140 -0
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +88 -0
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +254 -0
- package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/vendor/symbiote-node/layout/Layout/Layout.css.js +88 -0
- package/vendor/symbiote-node/layout/Layout/Layout.js +622 -0
- package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +25 -0
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +293 -0
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +467 -0
- package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +33 -0
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +156 -0
- package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +250 -0
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +379 -0
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +263 -0
- package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +20 -0
- package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +183 -0
- package/vendor/symbiote-node/layout/LayoutTree.js +246 -0
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +89 -0
- package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +14 -0
- package/vendor/symbiote-node/layout/index.js +16 -0
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +79 -0
- package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +41 -0
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +24 -0
- package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +16 -0
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +65 -0
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +29 -0
- package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +683 -0
- package/vendor/symbiote-node/node/GraphNode/GraphNode.js +92 -0
- package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +17 -0
- package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +25 -0
- package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/vendor/symbiote-node/node/PortItem/PortItem.css.js +90 -0
- package/vendor/symbiote-node/node/PortItem/PortItem.js +87 -0
- package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +10 -0
- package/vendor/symbiote-node/package.json +59 -0
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +131 -0
- package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +16 -0
- package/vendor/symbiote-node/plugins/History.js +384 -0
- package/vendor/symbiote-node/plugins/Readonly.js +59 -0
- package/vendor/symbiote-node/shapes/CircleShape.js +80 -0
- package/vendor/symbiote-node/shapes/CommentShape.js +35 -0
- package/vendor/symbiote-node/shapes/DiamondShape.js +115 -0
- package/vendor/symbiote-node/shapes/NodeShape.js +80 -0
- package/vendor/symbiote-node/shapes/PillShape.js +91 -0
- package/vendor/symbiote-node/shapes/RectShape.js +72 -0
- package/vendor/symbiote-node/shapes/SVGShape.js +494 -0
- package/vendor/symbiote-node/shapes/index.js +53 -0
- package/vendor/symbiote-node/themes/Palette.js +32 -0
- package/vendor/symbiote-node/themes/Skin.js +113 -0
- package/vendor/symbiote-node/themes/Theme.js +84 -0
- package/vendor/symbiote-node/themes/carbon.js +137 -0
- package/vendor/symbiote-node/themes/dark.js +137 -0
- package/vendor/symbiote-node/themes/ebook.js +138 -0
- package/vendor/symbiote-node/themes/grey.js +137 -0
- package/vendor/symbiote-node/themes/light.js +137 -0
- package/vendor/symbiote-node/themes/neon.js +138 -0
- package/vendor/symbiote-node/themes/pcb.js +273 -0
- package/vendor/symbiote-node/themes/synthwave.js +137 -0
- package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +86 -0
- package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +128 -0
- package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.tpl.js +29 -0
- package/web/app.js +6 -5
- package/web/components/canvas-graph.js +1666 -0
- package/web/components/event-feed/CodeWidget.js +32 -0
- package/web/components/event-feed/EventWidget.js +97 -0
- package/web/components/event-feed/ListWidget.js +57 -0
- package/web/components/event-feed/MiniGraphWidget.js +69 -0
- package/web/dashboard.js +1 -1
- package/web/index.html +4 -0
- package/web/panels/ActionBoard/ActionBoard.js +1 -1
- package/web/panels/SettingsPanel/SettingsPanel.tpl.js +1 -1
- package/web/panels/code-viewer.js +50 -15
- package/web/panels/dep-graph.js +2712 -7
- package/web/panels/file-tree.js +5 -2
- package/web/panels/live-monitor.js +75 -3
- package/web/style.css +33 -0
- package/docs/img/explorer-compact.jpg +0 -0
- package/docs/img/explorer-expanded.jpg +0 -0
- package/src/.contextignore +0 -22
- package/src/.project-graph-cache.json +0 -1
- package/src/compact/.project-graph-cache.json +0 -1
- package/web/.project-graph-cache.json +0 -1
- package/web/panels/SettingsPanel/.project-graph-cache.json +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag handler — pointer-based drag with zoom compensation
|
|
3
|
+
*
|
|
4
|
+
* Adapted from Rete.js area-plugin/drag.ts (86 LOC).
|
|
5
|
+
* Handles both canvas panning and node dragging.
|
|
6
|
+
*
|
|
7
|
+
* @module symbiote-node/interactions/Drag
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class Drag {
|
|
11
|
+
/** @type {{ x: number, y: number }|null} */
|
|
12
|
+
#pointerStart = null;
|
|
13
|
+
|
|
14
|
+
/** @type {{ x: number, y: number }|null} */
|
|
15
|
+
#startPosition = null;
|
|
16
|
+
|
|
17
|
+
/** @type {function|null} */
|
|
18
|
+
#onTranslate = null;
|
|
19
|
+
|
|
20
|
+
/** @type {function|null} */
|
|
21
|
+
#onStart = null;
|
|
22
|
+
|
|
23
|
+
/** @type {function|null} */
|
|
24
|
+
#onDrop = null;
|
|
25
|
+
|
|
26
|
+
/** @type {function} */
|
|
27
|
+
#getZoom = () => 1;
|
|
28
|
+
|
|
29
|
+
/** @type {function} */
|
|
30
|
+
#getPosition = () => ({ x: 0, y: 0 });
|
|
31
|
+
|
|
32
|
+
/** @type {HTMLElement|null} */
|
|
33
|
+
#element = null;
|
|
34
|
+
|
|
35
|
+
/** @type {function|null} - optional hit-test before starting drag */
|
|
36
|
+
#shouldStart = null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initialize drag handler on element
|
|
40
|
+
* @param {HTMLElement} element - Element to attach drag to
|
|
41
|
+
* @param {object} config
|
|
42
|
+
* @param {function} config.getPosition - Returns current {x, y}
|
|
43
|
+
* @param {function} config.getZoom - Returns current zoom level
|
|
44
|
+
* @param {object} callbacks
|
|
45
|
+
* @param {function} callbacks.onStart - Called on drag start
|
|
46
|
+
* @param {function} callbacks.onTranslate - Called with (x, y) during drag
|
|
47
|
+
* @param {function} callbacks.onDrop - Called on drag end
|
|
48
|
+
*/
|
|
49
|
+
initialize(element, config, callbacks) {
|
|
50
|
+
this.#element = element;
|
|
51
|
+
this.#getPosition = config.getPosition;
|
|
52
|
+
this.#getZoom = config.getZoom;
|
|
53
|
+
this.#onStart = callbacks.onStart || null;
|
|
54
|
+
this.#onTranslate = callbacks.onTranslate;
|
|
55
|
+
this.#onDrop = callbacks.onDrop || null;
|
|
56
|
+
this.#shouldStart = callbacks.shouldStart || null;
|
|
57
|
+
|
|
58
|
+
element.style.touchAction = 'none';
|
|
59
|
+
element.addEventListener('pointerdown', this.#down);
|
|
60
|
+
window.addEventListener('pointermove', this.#move);
|
|
61
|
+
window.addEventListener('pointerup', this.#up);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#down = (e) => {
|
|
65
|
+
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
|
66
|
+
// Skip if event originates from a socket (ConnectFlow handles those)
|
|
67
|
+
if (e.target.closest && e.target.closest('.sn-socket')) return;
|
|
68
|
+
// Optional hit-test: allow caller to reject drag (e.g. SVG perimeter check)
|
|
69
|
+
if (this.#shouldStart && !this.#shouldStart(e)) return;
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
this.#pointerStart = { x: e.pageX, y: e.pageY };
|
|
72
|
+
this.#startPosition = { ...this.#getPosition() };
|
|
73
|
+
if (this.#onStart) this.#onStart(e);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
#move = (e) => {
|
|
77
|
+
if (!this.#pointerStart || !this.#startPosition) return;
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
const dx = e.pageX - this.#pointerStart.x;
|
|
80
|
+
const dy = e.pageY - this.#pointerStart.y;
|
|
81
|
+
const zoom = this.#getZoom();
|
|
82
|
+
const x = this.#startPosition.x + dx / zoom;
|
|
83
|
+
const y = this.#startPosition.y + dy / zoom;
|
|
84
|
+
if (this.#onTranslate) this.#onTranslate(x, y, e);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
#up = (e) => {
|
|
88
|
+
if (!this.#pointerStart) return;
|
|
89
|
+
this.#pointerStart = null;
|
|
90
|
+
this.#startPosition = null;
|
|
91
|
+
if (this.#onDrop) this.#onDrop(e);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** Cleanup event listeners */
|
|
95
|
+
destroy() {
|
|
96
|
+
if (this.#element) {
|
|
97
|
+
this.#element.removeEventListener('pointerdown', this.#down);
|
|
98
|
+
}
|
|
99
|
+
window.removeEventListener('pointermove', this.#move);
|
|
100
|
+
window.removeEventListener('pointerup', this.#up);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selector — multi-select manager for nodes and connections
|
|
3
|
+
*
|
|
4
|
+
* Handles single select, Ctrl/Meta+click accumulation,
|
|
5
|
+
* canvas deselect, and group translate of selected nodes.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from Rete.js selectable extension (208 LOC).
|
|
8
|
+
* @module symbiote-node/interactions/Selector
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** @type {number} Minimum pointer movement to consider a drag (pixels) */
|
|
12
|
+
const TWITCH_THRESHOLD = 4;
|
|
13
|
+
|
|
14
|
+
export class Selector {
|
|
15
|
+
|
|
16
|
+
/** @type {Set<string>} */
|
|
17
|
+
#selectedNodes = new Set();
|
|
18
|
+
|
|
19
|
+
/** @type {Set<string>} */
|
|
20
|
+
#selectedConnections = new Set();
|
|
21
|
+
|
|
22
|
+
/** @type {function|null} */
|
|
23
|
+
#onChange = null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {object} config
|
|
27
|
+
* @param {function} config.onChange - Called when selection changes: (nodes: Set, connections: Set)
|
|
28
|
+
*/
|
|
29
|
+
constructor(config = {}) {
|
|
30
|
+
this.#onChange = config.onChange || null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Select a node (single or accumulate with Ctrl/Meta)
|
|
35
|
+
* @param {string} nodeId
|
|
36
|
+
* @param {boolean} accumulate - Ctrl/Meta held
|
|
37
|
+
*/
|
|
38
|
+
selectNode(nodeId, accumulate = false) {
|
|
39
|
+
if (!accumulate) {
|
|
40
|
+
this.#selectedNodes.clear();
|
|
41
|
+
this.#selectedConnections.clear();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.#selectedNodes.has(nodeId) && accumulate) {
|
|
45
|
+
this.#selectedNodes.delete(nodeId);
|
|
46
|
+
} else {
|
|
47
|
+
this.#selectedNodes.add(nodeId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
this.#notify();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Select a connection
|
|
55
|
+
* @param {string} connId
|
|
56
|
+
* @param {boolean} accumulate
|
|
57
|
+
*/
|
|
58
|
+
selectConnection(connId, accumulate = false) {
|
|
59
|
+
if (!accumulate) {
|
|
60
|
+
this.#selectedNodes.clear();
|
|
61
|
+
this.#selectedConnections.clear();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (this.#selectedConnections.has(connId) && accumulate) {
|
|
65
|
+
this.#selectedConnections.delete(connId);
|
|
66
|
+
} else {
|
|
67
|
+
this.#selectedConnections.add(connId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.#notify();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Deselect everything
|
|
75
|
+
*/
|
|
76
|
+
unselectAll() {
|
|
77
|
+
if (this.#selectedNodes.size === 0 && this.#selectedConnections.size === 0) return;
|
|
78
|
+
this.#selectedNodes.clear();
|
|
79
|
+
this.#selectedConnections.clear();
|
|
80
|
+
this.#notify();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} nodeId
|
|
85
|
+
* @returns {boolean}
|
|
86
|
+
*/
|
|
87
|
+
isNodeSelected(nodeId) {
|
|
88
|
+
return this.#selectedNodes.has(nodeId);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {string} connId
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
isConnectionSelected(connId) {
|
|
96
|
+
return this.#selectedConnections.has(connId);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get all selected node IDs
|
|
101
|
+
* @returns {Set<string>}
|
|
102
|
+
*/
|
|
103
|
+
getSelectedNodes() {
|
|
104
|
+
return this.#selectedNodes;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get all selected connection IDs
|
|
109
|
+
* @returns {Set<string>}
|
|
110
|
+
*/
|
|
111
|
+
getSelectedConnections() {
|
|
112
|
+
return this.#selectedConnections;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Check if pointer was a twitch (< 4px movement)
|
|
117
|
+
* @param {{ x: number, y: number }} start
|
|
118
|
+
* @param {{ x: number, y: number }} end
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
static isTwitch(start, end) {
|
|
122
|
+
const dx = Math.abs(end.x - start.x);
|
|
123
|
+
const dy = Math.abs(end.y - start.y);
|
|
124
|
+
return dx < TWITCH_THRESHOLD && dy < TWITCH_THRESHOLD;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#notify() {
|
|
128
|
+
if (this.#onChange) {
|
|
129
|
+
this.#onChange(this.#selectedNodes, this.#selectedConnections);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SnapGrid — grid snapping for node positions
|
|
3
|
+
*
|
|
4
|
+
* Rounds coordinates to nearest grid cell.
|
|
5
|
+
* Supports dynamic (during drag) and static (on drop) modes.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from Rete.js snap grid (62 LOC).
|
|
8
|
+
* @module symbiote-node/interactions/SnapGrid
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export class SnapGrid {
|
|
12
|
+
|
|
13
|
+
/** @type {number} */
|
|
14
|
+
#size;
|
|
15
|
+
|
|
16
|
+
/** @type {boolean} */
|
|
17
|
+
#dynamic;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} config
|
|
21
|
+
* @param {number} [config.size=16] - Grid cell size in pixels
|
|
22
|
+
* @param {boolean} [config.dynamic=true] - Snap during drag (true) or only on drop (false)
|
|
23
|
+
*/
|
|
24
|
+
constructor(config = {}) {
|
|
25
|
+
this.#size = config.size || 16;
|
|
26
|
+
this.#dynamic = config.dynamic !== false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Snap coordinates to nearest grid cell
|
|
31
|
+
* @param {number} x
|
|
32
|
+
* @param {number} y
|
|
33
|
+
* @returns {{ x: number, y: number }}
|
|
34
|
+
*/
|
|
35
|
+
snap(x, y) {
|
|
36
|
+
return {
|
|
37
|
+
x: Math.round(x / this.#size) * this.#size,
|
|
38
|
+
y: Math.round(y / this.#size) * this.#size,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Whether to snap during drag or only on drop
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
get isDynamic() {
|
|
47
|
+
return this.#dynamic;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get grid size
|
|
52
|
+
* @returns {number}
|
|
53
|
+
*/
|
|
54
|
+
get size() {
|
|
55
|
+
return this.#size;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Update grid size
|
|
60
|
+
* @param {number} size
|
|
61
|
+
*/
|
|
62
|
+
setSize(size) {
|
|
63
|
+
this.#size = size;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zoom handler — wheel, touch pinch, and double-click zoom
|
|
3
|
+
*
|
|
4
|
+
* Adapted from Rete.js area-plugin/zoom.ts (123 LOC).
|
|
5
|
+
* Handles zoom relative to cursor/pinch center.
|
|
6
|
+
*
|
|
7
|
+
* @module symbiote-node/interactions/Zoom
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class Zoom {
|
|
11
|
+
/** @type {PointerEvent[]} */
|
|
12
|
+
#pointers = [];
|
|
13
|
+
|
|
14
|
+
/** @type {{ cx: number, cy: number, distance: number }|null} */
|
|
15
|
+
#previous = null;
|
|
16
|
+
|
|
17
|
+
/** @type {HTMLElement|null} */
|
|
18
|
+
#container = null;
|
|
19
|
+
|
|
20
|
+
/** @type {HTMLElement|null} */
|
|
21
|
+
#content = null;
|
|
22
|
+
|
|
23
|
+
/** @type {function|null} */
|
|
24
|
+
#onZoom = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {number} [intensity=0.1] - Zoom sensitivity
|
|
28
|
+
*/
|
|
29
|
+
constructor(intensity = 0.1) {
|
|
30
|
+
/** @type {number} */
|
|
31
|
+
this.intensity = intensity;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Initialize zoom handler
|
|
36
|
+
* @param {HTMLElement} container - Outer container
|
|
37
|
+
* @param {HTMLElement} content - Inner content element (for getBoundingClientRect)
|
|
38
|
+
* @param {function} onZoom - Callback: (delta, ox, oy, source)
|
|
39
|
+
* @param {function} [getTransform] - Optional callback returning {x, y} to avoid getBoundingClientRect layout thrashing
|
|
40
|
+
*/
|
|
41
|
+
initialize(container, content, onZoom, getTransform = null) {
|
|
42
|
+
this.#container = container;
|
|
43
|
+
this.#content = content;
|
|
44
|
+
this.#onZoom = onZoom;
|
|
45
|
+
this.getTransform = getTransform;
|
|
46
|
+
|
|
47
|
+
container.addEventListener('wheel', this.#wheel, { passive: false });
|
|
48
|
+
container.addEventListener('pointerdown', this.#down);
|
|
49
|
+
container.addEventListener('dblclick', this.#dblclick);
|
|
50
|
+
window.addEventListener('pointermove', this.#move);
|
|
51
|
+
window.addEventListener('pointerup', this.#up);
|
|
52
|
+
window.addEventListener('pointercancel', this.#up);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#getRect() {
|
|
56
|
+
if (this.getTransform) {
|
|
57
|
+
const c = this.#container.getBoundingClientRect();
|
|
58
|
+
const t = this.getTransform();
|
|
59
|
+
return { left: c.left + t.x, top: c.top + t.y };
|
|
60
|
+
}
|
|
61
|
+
return this.#content.getBoundingClientRect();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#wheel = (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const rect = this.#getRect();
|
|
67
|
+
// Normalize delta: trackpads send small frequent deltas, mice send large ones
|
|
68
|
+
const absDelta = Math.min(Math.abs(e.deltaY), 10) / 10;
|
|
69
|
+
const sign = e.deltaY < 0 ? 1 : -1;
|
|
70
|
+
const delta = sign * this.intensity * absDelta;
|
|
71
|
+
const ox = (rect.left - e.clientX) * delta;
|
|
72
|
+
const oy = (rect.top - e.clientY) * delta;
|
|
73
|
+
this.#onZoom(delta, ox, oy, 'wheel');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
#dblclick = (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
const rect = this.#getRect();
|
|
79
|
+
const delta = 4 * this.intensity;
|
|
80
|
+
const ox = (rect.left - e.clientX) * delta;
|
|
81
|
+
const oy = (rect.top - e.clientY) * delta;
|
|
82
|
+
this.#onZoom(delta, ox, oy, 'dblclick');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
#down = (e) => {
|
|
86
|
+
this.#pointers.push(e);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
#move = (e) => {
|
|
90
|
+
this.#pointers = this.#pointers.map(p =>
|
|
91
|
+
p.pointerId === e.pointerId ? e : p
|
|
92
|
+
);
|
|
93
|
+
if (this.#pointers.length < 2) return;
|
|
94
|
+
|
|
95
|
+
const [p1, p2] = this.#pointers;
|
|
96
|
+
const distance = Math.sqrt(
|
|
97
|
+
(p1.clientX - p2.clientX) ** 2 + (p1.clientY - p2.clientY) ** 2
|
|
98
|
+
);
|
|
99
|
+
const cx = (p1.clientX + p2.clientX) / 2;
|
|
100
|
+
const cy = (p1.clientY + p2.clientY) / 2;
|
|
101
|
+
|
|
102
|
+
if (this.#previous && this.#previous.distance > 0) {
|
|
103
|
+
const rect = this.#getRect();
|
|
104
|
+
const delta = distance / this.#previous.distance - 1;
|
|
105
|
+
const ox = (rect.left - cx) * delta;
|
|
106
|
+
const oy = (rect.top - cy) * delta;
|
|
107
|
+
this.#onZoom(
|
|
108
|
+
delta,
|
|
109
|
+
ox - (this.#previous.cx - cx),
|
|
110
|
+
oy - (this.#previous.cy - cy),
|
|
111
|
+
'touch'
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
this.#previous = { cx, cy, distance };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
#up = (e) => {
|
|
118
|
+
this.#previous = null;
|
|
119
|
+
this.#pointers = this.#pointers.filter(p => p.pointerId !== e.pointerId);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether a multi-touch zoom is in progress
|
|
124
|
+
* @returns {boolean}
|
|
125
|
+
*/
|
|
126
|
+
isTranslating() {
|
|
127
|
+
return this.#pointers.length >= 2;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Cleanup event listeners */
|
|
131
|
+
destroy() {
|
|
132
|
+
if (!this.#container) return;
|
|
133
|
+
this.#container.removeEventListener('wheel', this.#wheel);
|
|
134
|
+
this.#container.removeEventListener('pointerdown', this.#down);
|
|
135
|
+
this.#container.removeEventListener('dblclick', this.#dblclick);
|
|
136
|
+
window.removeEventListener('pointermove', this.#move);
|
|
137
|
+
window.removeEventListener('pointerup', this.#up);
|
|
138
|
+
window.removeEventListener('pointercancel', this.#up);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ActionZone styles
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from '@symbiotejs/symbiote';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Size of the triangular zone (px)
|
|
9
|
+
*/
|
|
10
|
+
export const ZONE_SIZE = 16;
|
|
11
|
+
|
|
12
|
+
export const styles = css`
|
|
13
|
+
action-zone {
|
|
14
|
+
position: absolute;
|
|
15
|
+
width: ${ZONE_SIZE}px;
|
|
16
|
+
height: ${ZONE_SIZE}px;
|
|
17
|
+
z-index: 100;
|
|
18
|
+
cursor: crosshair;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.15s ease;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
opacity: 1 !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[dragging] {
|
|
30
|
+
opacity: 1 !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Corner positioning */
|
|
34
|
+
&[corner="tl"] {
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[corner="tr"] {
|
|
40
|
+
top: 0;
|
|
41
|
+
right: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[corner="bl"] {
|
|
45
|
+
bottom: 0;
|
|
46
|
+
left: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&[corner="br"] {
|
|
50
|
+
bottom: 0;
|
|
51
|
+
right: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.zone-icon {
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
color: var(--layout-highlight, #888);
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Rotate triangle based on corner */
|
|
62
|
+
&[corner="tl"] .zone-icon {
|
|
63
|
+
transform: rotate(0deg);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&[corner="tr"] .zone-icon {
|
|
67
|
+
transform: rotate(90deg);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&[corner="br"] .zone-icon {
|
|
71
|
+
transform: rotate(180deg);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&[corner="bl"] .zone-icon {
|
|
75
|
+
transform: rotate(270deg);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&[dragging] .zone-icon {
|
|
79
|
+
color: var(--layout-highlight, #aaa);
|
|
80
|
+
opacity: 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Parent hover rule */
|
|
85
|
+
layout-node[node-type="panel"]:hover action-zone {
|
|
86
|
+
opacity: 0.5;
|
|
87
|
+
}
|
|
88
|
+
`;
|