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,384 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* History — undo/redo action stack for NodeEditor
|
|
3
|
-
*
|
|
4
|
-
* Records editor actions (addNode, removeNode, move, connect, disconnect)
|
|
5
|
-
* and provides undo()/redo() with Ctrl+Z / Ctrl+Shift+Z keyboard bindings.
|
|
6
|
-
* Plugin pattern: attach to editor via history.listen(editor).
|
|
7
|
-
*
|
|
8
|
-
* @module symbiote-node/plugins/History
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {object} HistoryAction
|
|
13
|
-
* @property {'addNode'|'removeNode'|'moveNode'|'addConnection'|'removeConnection'|'addFrame'|'removeFrame'} type
|
|
14
|
-
* @property {object} data - Serialized action data for undo/redo
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const MAX_STACK = 200;
|
|
18
|
-
|
|
19
|
-
export class History {
|
|
20
|
-
|
|
21
|
-
/** @type {HistoryAction[]} */
|
|
22
|
-
#undoStack = [];
|
|
23
|
-
|
|
24
|
-
/** @type {HistoryAction[]} */
|
|
25
|
-
#redoStack = [];
|
|
26
|
-
|
|
27
|
-
/** @type {import('../core/Editor.js').NodeEditor|null} */
|
|
28
|
-
#editor = null;
|
|
29
|
-
|
|
30
|
-
/** @type {function|null} */
|
|
31
|
-
#getCanvas = null;
|
|
32
|
-
|
|
33
|
-
/** @type {boolean} - prevent recording actions triggered by undo/redo itself */
|
|
34
|
-
#isApplying = false;
|
|
35
|
-
|
|
36
|
-
/** @type {function[]} - unsubscribe functions */
|
|
37
|
-
#unsubs = [];
|
|
38
|
-
|
|
39
|
-
/** @type {object} - injected class constructors */
|
|
40
|
-
#classes = {};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Attach history tracking to an editor
|
|
44
|
-
* @param {import('../core/Editor.js').NodeEditor} editor
|
|
45
|
-
* @param {object} [options]
|
|
46
|
-
* @param {function} [options.getCanvas] - returns canvas element for position tracking
|
|
47
|
-
* @param {object} [options.classes] - class constructors: { Node, Connection, Frame, Socket, Input, Output, InputControl }
|
|
48
|
-
*/
|
|
49
|
-
listen(editor, options = {}) {
|
|
50
|
-
this.#editor = editor;
|
|
51
|
-
this.#getCanvas = options.getCanvas || null;
|
|
52
|
-
this.#classes = options.classes || {};
|
|
53
|
-
|
|
54
|
-
// Track node additions
|
|
55
|
-
this.#unsubs.push(editor.on('nodecreated', (node) => {
|
|
56
|
-
if (this.#isApplying) return;
|
|
57
|
-
const canvas = this.#getCanvas?.();
|
|
58
|
-
const pos = canvas ? this.#getNodePosition(canvas, node.id) : [0, 0];
|
|
59
|
-
this.#push({
|
|
60
|
-
type: 'addNode',
|
|
61
|
-
data: { node: this.#serializeNode(node), position: pos },
|
|
62
|
-
});
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
// Track node removals
|
|
66
|
-
this.#unsubs.push(editor.on('noderemove', (node) => {
|
|
67
|
-
if (this.#isApplying) return;
|
|
68
|
-
const canvas = this.#getCanvas?.();
|
|
69
|
-
const pos = canvas ? this.#getNodePosition(canvas, node.id) : [0, 0];
|
|
70
|
-
// Capture connections that will be removed with this node
|
|
71
|
-
const conns = editor.getNodeConnections(node.id).map(c => this.#serializeConnection(c));
|
|
72
|
-
this.#push({
|
|
73
|
-
type: 'removeNode',
|
|
74
|
-
data: { node: this.#serializeNode(node), position: pos, connections: conns },
|
|
75
|
-
});
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
// Track node moves
|
|
79
|
-
this.#unsubs.push(editor.on('nodepicked', (node) => {
|
|
80
|
-
if (this.#isApplying) return;
|
|
81
|
-
const canvas = this.#getCanvas?.();
|
|
82
|
-
if (!canvas) return;
|
|
83
|
-
const pos = this.#getNodePosition(canvas, node.id);
|
|
84
|
-
node._historyStartPos = pos;
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
this.#unsubs.push(editor.on('nodedragged', ({ id }) => {
|
|
88
|
-
if (this.#isApplying) return;
|
|
89
|
-
const node = editor.getNode(id);
|
|
90
|
-
if (!node?._historyStartPos) return;
|
|
91
|
-
const canvas = this.#getCanvas?.();
|
|
92
|
-
const endPos = canvas ? this.#getNodePosition(canvas, id) : [0, 0];
|
|
93
|
-
const startPos = node._historyStartPos;
|
|
94
|
-
// Only record if position actually changed
|
|
95
|
-
if (startPos[0] !== endPos[0] || startPos[1] !== endPos[1]) {
|
|
96
|
-
this.#push({
|
|
97
|
-
type: 'moveNode',
|
|
98
|
-
data: { nodeId: id, from: startPos, to: endPos },
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
delete node._historyStartPos;
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
// Track connections
|
|
105
|
-
this.#unsubs.push(editor.on('connectioncreated', (conn) => {
|
|
106
|
-
if (this.#isApplying) return;
|
|
107
|
-
this.#push({
|
|
108
|
-
type: 'addConnection',
|
|
109
|
-
data: { connection: this.#serializeConnection(conn) },
|
|
110
|
-
});
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
this.#unsubs.push(editor.on('connectionremove', (conn) => {
|
|
114
|
-
if (this.#isApplying) return;
|
|
115
|
-
this.#push({
|
|
116
|
-
type: 'removeConnection',
|
|
117
|
-
data: { connection: this.#serializeConnection(conn) },
|
|
118
|
-
});
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
// Track frames
|
|
122
|
-
this.#unsubs.push(editor.on('framecreated', (frame) => {
|
|
123
|
-
if (this.#isApplying) return;
|
|
124
|
-
this.#push({
|
|
125
|
-
type: 'addFrame',
|
|
126
|
-
data: { frame: { ...frame } },
|
|
127
|
-
});
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
this.#unsubs.push(editor.on('frameremove', (frame) => {
|
|
131
|
-
if (this.#isApplying) return;
|
|
132
|
-
this.#push({
|
|
133
|
-
type: 'removeFrame',
|
|
134
|
-
data: { frame: { ...frame } },
|
|
135
|
-
});
|
|
136
|
-
}));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Bind Ctrl+Z / Ctrl+Shift+Z keyboard shortcuts
|
|
141
|
-
* @param {HTMLElement} target - element to listen for keydown
|
|
142
|
-
*/
|
|
143
|
-
bindKeyboard(target) {
|
|
144
|
-
const handler = (e) => {
|
|
145
|
-
if ((e.ctrlKey || e.metaKey) && e.key === 'z') {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
if (e.shiftKey) this.redo();
|
|
148
|
-
else this.undo();
|
|
149
|
-
}
|
|
150
|
-
if ((e.ctrlKey || e.metaKey) && e.key === 'y') {
|
|
151
|
-
e.preventDefault();
|
|
152
|
-
this.redo();
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
target.addEventListener('keydown', handler);
|
|
156
|
-
this.#unsubs.push(() => target.removeEventListener('keydown', handler));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** Undo last action */
|
|
160
|
-
undo() {
|
|
161
|
-
const action = this.#undoStack.pop();
|
|
162
|
-
if (!action) return;
|
|
163
|
-
this.#isApplying = true;
|
|
164
|
-
try {
|
|
165
|
-
this.#applyReverse(action);
|
|
166
|
-
this.#redoStack.push(action);
|
|
167
|
-
} finally {
|
|
168
|
-
this.#isApplying = false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** Redo last undone action */
|
|
173
|
-
redo() {
|
|
174
|
-
const action = this.#redoStack.pop();
|
|
175
|
-
if (!action) return;
|
|
176
|
-
this.#isApplying = true;
|
|
177
|
-
try {
|
|
178
|
-
this.#applyForward(action);
|
|
179
|
-
this.#undoStack.push(action);
|
|
180
|
-
} finally {
|
|
181
|
-
this.#isApplying = false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** @returns {number} */
|
|
186
|
-
get undoCount() { return this.#undoStack.length; }
|
|
187
|
-
|
|
188
|
-
/** @returns {number} */
|
|
189
|
-
get redoCount() { return this.#redoStack.length; }
|
|
190
|
-
|
|
191
|
-
/** Clear all history */
|
|
192
|
-
clear() {
|
|
193
|
-
this.#undoStack = [];
|
|
194
|
-
this.#redoStack = [];
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** Destroy and unsubscribe */
|
|
198
|
-
destroy() {
|
|
199
|
-
for (const unsub of this.#unsubs) {
|
|
200
|
-
if (typeof unsub === 'function') unsub();
|
|
201
|
-
}
|
|
202
|
-
this.#unsubs = [];
|
|
203
|
-
this.clear();
|
|
204
|
-
this.#editor = null;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// --- Private ---
|
|
208
|
-
|
|
209
|
-
#push(action) {
|
|
210
|
-
this.#undoStack.push(action);
|
|
211
|
-
if (this.#undoStack.length > MAX_STACK) this.#undoStack.shift();
|
|
212
|
-
this.#redoStack = []; // new action invalidates redo
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
#applyReverse(action) {
|
|
216
|
-
const editor = this.#editor;
|
|
217
|
-
const canvas = this.#getCanvas?.();
|
|
218
|
-
if (!editor) return;
|
|
219
|
-
|
|
220
|
-
switch (action.type) {
|
|
221
|
-
case 'addNode':
|
|
222
|
-
editor.removeNode(action.data.node.id);
|
|
223
|
-
break;
|
|
224
|
-
|
|
225
|
-
case 'removeNode': {
|
|
226
|
-
const { node: nodeData, position, connections } = action.data;
|
|
227
|
-
const restoredNode = this.#deserializeNode(nodeData);
|
|
228
|
-
editor.addNode(restoredNode);
|
|
229
|
-
if (canvas && position) {
|
|
230
|
-
canvas.setNodePosition(restoredNode.id, position[0], position[1]);
|
|
231
|
-
}
|
|
232
|
-
// Restore connections
|
|
233
|
-
for (const connData of connections) {
|
|
234
|
-
const { Connection } = this.#classes;
|
|
235
|
-
const conn = new Connection(connData.from, connData.out, connData.to, connData.in);
|
|
236
|
-
conn.id = connData.id;
|
|
237
|
-
try { editor.addConnection(conn); } catch { /* node may not exist */ }
|
|
238
|
-
}
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
case 'moveNode':
|
|
243
|
-
if (canvas) {
|
|
244
|
-
canvas.setNodePosition(action.data.nodeId, action.data.from[0], action.data.from[1]);
|
|
245
|
-
}
|
|
246
|
-
break;
|
|
247
|
-
|
|
248
|
-
case 'addConnection':
|
|
249
|
-
editor.removeConnection(action.data.connection.id);
|
|
250
|
-
break;
|
|
251
|
-
|
|
252
|
-
case 'removeConnection': {
|
|
253
|
-
const connData = action.data.connection;
|
|
254
|
-
const { Connection } = this.#classes;
|
|
255
|
-
const conn = new Connection(connData.from, connData.out, connData.to, connData.in);
|
|
256
|
-
conn.id = connData.id;
|
|
257
|
-
try { editor.addConnection(conn); } catch { /* already exists */ }
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
case 'addFrame':
|
|
262
|
-
editor.removeFrame(action.data.frame.id);
|
|
263
|
-
break;
|
|
264
|
-
|
|
265
|
-
case 'removeFrame': {
|
|
266
|
-
const { Frame } = this.#classes;
|
|
267
|
-
const frame = new Frame(action.data.frame.label, action.data.frame);
|
|
268
|
-
frame.id = action.data.frame.id;
|
|
269
|
-
editor.addFrame(frame);
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
#applyForward(action) {
|
|
276
|
-
const editor = this.#editor;
|
|
277
|
-
const canvas = this.#getCanvas?.();
|
|
278
|
-
if (!editor) return;
|
|
279
|
-
|
|
280
|
-
switch (action.type) {
|
|
281
|
-
case 'addNode': {
|
|
282
|
-
const restoredNode = this.#deserializeNode(action.data.node);
|
|
283
|
-
editor.addNode(restoredNode);
|
|
284
|
-
if (canvas && action.data.position) {
|
|
285
|
-
canvas.setNodePosition(restoredNode.id, action.data.position[0], action.data.position[1]);
|
|
286
|
-
}
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
case 'removeNode':
|
|
291
|
-
editor.removeNode(action.data.node.id);
|
|
292
|
-
break;
|
|
293
|
-
|
|
294
|
-
case 'moveNode':
|
|
295
|
-
if (canvas) {
|
|
296
|
-
canvas.setNodePosition(action.data.nodeId, action.data.to[0], action.data.to[1]);
|
|
297
|
-
}
|
|
298
|
-
break;
|
|
299
|
-
|
|
300
|
-
case 'addConnection': {
|
|
301
|
-
const connData = action.data.connection;
|
|
302
|
-
const { Connection } = this.#classes;
|
|
303
|
-
const conn = new Connection(connData.from, connData.out, connData.to, connData.in);
|
|
304
|
-
conn.id = connData.id;
|
|
305
|
-
try { editor.addConnection(conn); } catch { /* already exists */ }
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
case 'removeConnection':
|
|
310
|
-
editor.removeConnection(action.data.connection.id);
|
|
311
|
-
break;
|
|
312
|
-
|
|
313
|
-
case 'addFrame': {
|
|
314
|
-
const { Frame } = this.#classes;
|
|
315
|
-
const frame = new Frame(action.data.frame.label, action.data.frame);
|
|
316
|
-
frame.id = action.data.frame.id;
|
|
317
|
-
editor.addFrame(frame);
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
case 'removeFrame':
|
|
322
|
-
editor.removeFrame(action.data.frame.id);
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
#serializeNode(node) {
|
|
328
|
-
return {
|
|
329
|
-
id: node.id,
|
|
330
|
-
label: node.label,
|
|
331
|
-
type: node.type,
|
|
332
|
-
category: node.category,
|
|
333
|
-
shape: node.shape,
|
|
334
|
-
params: { ...node.params },
|
|
335
|
-
inputs: Object.fromEntries(Object.entries(node.inputs).map(([k, v]) => [k, {
|
|
336
|
-
socket: v.socket ? { type: v.socket.type, color: v.socket.color } : null,
|
|
337
|
-
label: v.label,
|
|
338
|
-
}])),
|
|
339
|
-
outputs: Object.fromEntries(Object.entries(node.outputs).map(([k, v]) => [k, {
|
|
340
|
-
socket: v.socket ? { type: v.socket.type, color: v.socket.color } : null,
|
|
341
|
-
label: v.label,
|
|
342
|
-
}])),
|
|
343
|
-
controls: Object.fromEntries(Object.entries(node.controls).map(([k, v]) => [k, {
|
|
344
|
-
label: v.label,
|
|
345
|
-
value: v.value,
|
|
346
|
-
type: v.type,
|
|
347
|
-
}])),
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
#serializeConnection(conn) {
|
|
352
|
-
return { id: conn.id, from: conn.from, out: conn.out, to: conn.to, in: conn.in };
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
#deserializeNode(data) {
|
|
356
|
-
const { Node, Socket, Input, Output, InputControl } = this.#classes;
|
|
357
|
-
const node = new Node(data.label, {
|
|
358
|
-
type: data.type,
|
|
359
|
-
category: data.category,
|
|
360
|
-
shape: data.shape,
|
|
361
|
-
});
|
|
362
|
-
node.id = data.id;
|
|
363
|
-
node.params = { ...data.params };
|
|
364
|
-
|
|
365
|
-
for (const [key, inp] of Object.entries(data.inputs)) {
|
|
366
|
-
const socket = inp.socket ? new Socket(inp.socket.type, { color: inp.socket.color }) : new Socket('any');
|
|
367
|
-
node.addInput(key, new Input(socket, inp.label));
|
|
368
|
-
}
|
|
369
|
-
for (const [key, out] of Object.entries(data.outputs)) {
|
|
370
|
-
const socket = out.socket ? new Socket(out.socket.type, { color: out.socket.color }) : new Socket('any');
|
|
371
|
-
node.addOutput(key, new Output(socket, out.label));
|
|
372
|
-
}
|
|
373
|
-
for (const [key, ctrl] of Object.entries(data.controls)) {
|
|
374
|
-
node.addControl(key, new InputControl(ctrl.type || 'text', { label: ctrl.label, initial: ctrl.value }));
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return node;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
#getNodePosition(canvas, nodeId) {
|
|
381
|
-
const positions = canvas.getPositions();
|
|
382
|
-
return positions[nodeId] || [0, 0];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Readonly — toggle readonly mode for node editor
|
|
3
|
-
*
|
|
4
|
-
* When enabled, blocks node creation, deletion, connection
|
|
5
|
-
* creation/removal, and node dragging.
|
|
6
|
-
*
|
|
7
|
-
* Adapted from Rete.js readonly plugin (63 LOC).
|
|
8
|
-
* @module symbiote-node/plugins/Readonly
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export class Readonly {
|
|
12
|
-
|
|
13
|
-
/** @type {boolean} */
|
|
14
|
-
#enabled = false;
|
|
15
|
-
|
|
16
|
-
/** @type {import('../core/Editor.js').NodeEditor|null} */
|
|
17
|
-
#editor = null;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {import('../core/Editor.js').NodeEditor} editor
|
|
21
|
-
*/
|
|
22
|
-
constructor(editor) {
|
|
23
|
-
this.#editor = editor;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Enable readonly mode */
|
|
27
|
-
enable() {
|
|
28
|
-
this.#enabled = true;
|
|
29
|
-
this.#editor.emit('readonlychanged', true);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Disable readonly mode */
|
|
33
|
-
disable() {
|
|
34
|
-
this.#enabled = false;
|
|
35
|
-
this.#editor.emit('readonlychanged', false);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Toggle readonly mode */
|
|
39
|
-
toggle() {
|
|
40
|
-
this.#enabled ? this.disable() : this.enable();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Whether readonly is currently enabled
|
|
45
|
-
* @returns {boolean}
|
|
46
|
-
*/
|
|
47
|
-
get isEnabled() {
|
|
48
|
-
return this.#enabled;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Guard check — throws if readonly
|
|
53
|
-
* Use before mutation operations
|
|
54
|
-
* @returns {boolean} true if operation should be blocked
|
|
55
|
-
*/
|
|
56
|
-
shouldBlock() {
|
|
57
|
-
return this.#enabled;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CircleShape — circular hub node
|
|
3
|
-
*
|
|
4
|
-
* Sockets distributed around the perimeter of a circle.
|
|
5
|
-
* Inputs on left semicircle, outputs on right semicircle.
|
|
6
|
-
*
|
|
7
|
-
* @module symbiote-node/shapes/CircleShape
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { NodeShape } from './NodeShape.js';
|
|
11
|
-
|
|
12
|
-
export class CircleShape extends NodeShape {
|
|
13
|
-
name = 'circle';
|
|
14
|
-
|
|
15
|
-
getSocketPosition(side, index, total, { width, height }) {
|
|
16
|
-
const r = Math.min(width, height) / 2;
|
|
17
|
-
const cx = width / 2;
|
|
18
|
-
const cy = height / 2;
|
|
19
|
-
|
|
20
|
-
// Inputs: left semicircle (90° to 270°), top to bottom
|
|
21
|
-
// Outputs: right semicircle (-90° to 90°), top to bottom
|
|
22
|
-
const arcSpan = Math.PI * 0.8; // 144 degrees
|
|
23
|
-
const centerAngle = side === 'input' ? Math.PI : 0;
|
|
24
|
-
const startAngle = centerAngle - arcSpan / 2;
|
|
25
|
-
const step = total > 1 ? arcSpan / (total - 1) : 0;
|
|
26
|
-
const angle = startAngle + step * index;
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
x: cx + r * Math.cos(angle),
|
|
30
|
-
y: cy + r * Math.sin(angle),
|
|
31
|
-
angle: (angle * 180) / Math.PI,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get pin position on a specific side of the circle.
|
|
37
|
-
* Pins follow an arc in the corresponding quadrant.
|
|
38
|
-
*
|
|
39
|
-
* @param {'top'|'right'|'bottom'|'left'} side
|
|
40
|
-
* @param {number} t - position along the side (0..1)
|
|
41
|
-
* @param {{ width: number, height: number }} size
|
|
42
|
-
* @returns {{ x: number, y: number, angle: number }}
|
|
43
|
-
*/
|
|
44
|
-
getSidePosition(side, t, size) {
|
|
45
|
-
const r = Math.min(size.width, size.height) / 2;
|
|
46
|
-
const cx = size.width / 2;
|
|
47
|
-
const cy = size.height / 2;
|
|
48
|
-
|
|
49
|
-
// Each side spans a 90° arc centered on the cardinal direction
|
|
50
|
-
const CENTERS = { right: 0, bottom: Math.PI / 2, left: Math.PI, top: -Math.PI / 2 };
|
|
51
|
-
const ARC = Math.PI * 0.8; // 144° arc to avoid exact corners
|
|
52
|
-
const MARGIN = 0.2;
|
|
53
|
-
const effectiveT = MARGIN + t * (1 - 2 * MARGIN);
|
|
54
|
-
|
|
55
|
-
const center = CENTERS[side];
|
|
56
|
-
const a = center - ARC / 2 + ARC * effectiveT;
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
x: cx + r * Math.cos(a),
|
|
60
|
-
y: cy + r * Math.sin(a),
|
|
61
|
-
angle: (a * 180) / Math.PI,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
getBorderRadius() {
|
|
66
|
-
return '50%';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get hasHeader() {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get hasControls() {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getMinSize() {
|
|
78
|
-
return { minWidth: 80, minHeight: 80 };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CommentShape — wide annotation banner node
|
|
3
|
-
*
|
|
4
|
-
* No sockets, no header, no controls.
|
|
5
|
-
* Just text content with semi-transparent background.
|
|
6
|
-
* Used for annotations and documentation on the canvas.
|
|
7
|
-
*
|
|
8
|
-
* @module symbiote-node/shapes/CommentShape
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { NodeShape } from './NodeShape.js';
|
|
12
|
-
|
|
13
|
-
export class CommentShape extends NodeShape {
|
|
14
|
-
name = 'comment';
|
|
15
|
-
|
|
16
|
-
getSocketPosition() {
|
|
17
|
-
return { x: 0, y: 0, angle: 0 };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getBorderRadius() {
|
|
21
|
-
return 'var(--sn-comment-radius, 6px)';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get hasHeader() {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get hasControls() {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getMinSize() {
|
|
33
|
-
return { minWidth: 200, minHeight: 40 };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DiamondShape — condition/decision rhombus node
|
|
3
|
-
*
|
|
4
|
-
* Input at top vertex, outputs distributed along bottom edges.
|
|
5
|
-
* Classic if/else, switch/case pattern.
|
|
6
|
-
*
|
|
7
|
-
* @module symbiote-node/shapes/DiamondShape
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { NodeShape } from './NodeShape.js';
|
|
11
|
-
|
|
12
|
-
export class DiamondShape extends NodeShape {
|
|
13
|
-
name = 'diamond';
|
|
14
|
-
|
|
15
|
-
getSocketPosition(side, index, total, { width, height }) {
|
|
16
|
-
const cx = width / 2;
|
|
17
|
-
const cy = height / 2;
|
|
18
|
-
|
|
19
|
-
if (side === 'input') {
|
|
20
|
-
// Inputs distributed along top edges
|
|
21
|
-
if (total === 1) {
|
|
22
|
-
return { x: cx, y: 0, angle: 270 };
|
|
23
|
-
}
|
|
24
|
-
// Multiple inputs: spread along top-left and top-right edges
|
|
25
|
-
const t = (index + 1) / (total + 1);
|
|
26
|
-
return {
|
|
27
|
-
x: cx * (1 - t),
|
|
28
|
-
y: cy * t,
|
|
29
|
-
angle: 225 + 90 * (index / (total - 1)),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Outputs along bottom edges
|
|
34
|
-
if (total === 1) {
|
|
35
|
-
return { x: cx, y: height, angle: 90 };
|
|
36
|
-
}
|
|
37
|
-
if (total === 2) {
|
|
38
|
-
// True: bottom-left, False: bottom-right
|
|
39
|
-
return index === 0
|
|
40
|
-
? { x: cx * 0.35, y: cy + cy * 0.65, angle: 225 }
|
|
41
|
-
: { x: width - cx * 0.35, y: cy + cy * 0.65, angle: 315 };
|
|
42
|
-
}
|
|
43
|
-
// 3+ outputs: spread along bottom edges
|
|
44
|
-
const t = (index + 1) / (total + 1);
|
|
45
|
-
return {
|
|
46
|
-
x: t < 0.5 ? cx * (1 - 2 * t) : cx + cx * (2 * t - 1),
|
|
47
|
-
y: t < 0.5 ? cy + cy * 2 * t : cy + cy * (2 - 2 * t),
|
|
48
|
-
angle: 135 + 90 * (index / (total - 1)),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Get pin position on a specific side of the diamond.
|
|
54
|
-
* Each side maps to two diagonal edges meeting at that cardinal vertex.
|
|
55
|
-
*
|
|
56
|
-
* @param {'top'|'right'|'bottom'|'left'} side
|
|
57
|
-
* @param {number} t - position along the side (0..1)
|
|
58
|
-
* @param {{ width: number, height: number }} size
|
|
59
|
-
* @returns {{ x: number, y: number, angle: number }}
|
|
60
|
-
*/
|
|
61
|
-
getSidePosition(side, t, size) {
|
|
62
|
-
const cx = size.width / 2;
|
|
63
|
-
const cy = size.height / 2;
|
|
64
|
-
const NORMALS = { top: -90, right: 0, bottom: 90, left: 180 };
|
|
65
|
-
const MARGIN = 0.2;
|
|
66
|
-
const effectiveT = MARGIN + t * (1 - 2 * MARGIN);
|
|
67
|
-
|
|
68
|
-
// Diamond vertices: top(cx,0), right(w,cy), bottom(cx,h), left(0,cy)
|
|
69
|
-
// Each "side" spans two edges meeting at the cardinal vertex
|
|
70
|
-
const vertices = {
|
|
71
|
-
top: [{ x: 0, y: cy }, { x: cx, y: 0 }, { x: size.width, y: cy }],
|
|
72
|
-
right: [{ x: cx, y: 0 }, { x: size.width, y: cy }, { x: cx, y: size.height }],
|
|
73
|
-
bottom: [{ x: 0, y: cy }, { x: cx, y: size.height }, { x: size.width, y: cy }],
|
|
74
|
-
left: [{ x: cx, y: 0 }, { x: 0, y: cy }, { x: cx, y: size.height }],
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const [p0, p1, p2] = vertices[side];
|
|
78
|
-
|
|
79
|
-
// effectiveT spans from p0 → p1 → p2 (two edges)
|
|
80
|
-
let x, y;
|
|
81
|
-
if (effectiveT <= 0.5) {
|
|
82
|
-
const segT = effectiveT * 2;
|
|
83
|
-
x = p0.x + (p1.x - p0.x) * segT;
|
|
84
|
-
y = p0.y + (p1.y - p0.y) * segT;
|
|
85
|
-
} else {
|
|
86
|
-
const segT = (effectiveT - 0.5) * 2;
|
|
87
|
-
x = p1.x + (p2.x - p1.x) * segT;
|
|
88
|
-
y = p1.y + (p2.y - p1.y) * segT;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { x, y, angle: NORMALS[side] };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
getBorderRadius() {
|
|
95
|
-
return '0';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getClipPath({ width, height }) {
|
|
99
|
-
const cx = width / 2;
|
|
100
|
-
const cy = height / 2;
|
|
101
|
-
return `polygon(${cx}px 0, ${width}px ${cy}px, ${cx}px ${height}px, 0 ${cy}px)`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
get hasHeader() {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
get hasControls() {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
getMinSize() {
|
|
113
|
-
return { minWidth: 100, minHeight: 100 };
|
|
114
|
-
}
|
|
115
|
-
}
|