symbiote-ui 0.3.0-alpha.4
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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/canvas/AutoLayout.js +731 -0
- package/canvas/Breadcrumb/Breadcrumb.css.js +75 -0
- package/canvas/Breadcrumb/Breadcrumb.js +96 -0
- package/canvas/Breadcrumb/Breadcrumb.tpl.js +7 -0
- package/canvas/CanvasConnectionRenderer.js +971 -0
- package/canvas/CanvasGraph/CanvasGraph.css.js +29 -0
- package/canvas/CanvasGraph/CanvasGraph.js +1697 -0
- package/canvas/CanvasGraph/CanvasGraphDrawState.js +280 -0
- package/canvas/CanvasGraph/CanvasGraphGeometry.js +194 -0
- package/canvas/CanvasViewport.js +550 -0
- package/canvas/ConnectionRenderer.js +1283 -0
- package/canvas/FlowSimulator.js +326 -0
- package/canvas/ForceLayout.js +226 -0
- package/canvas/ForceWorker.js +1303 -0
- package/canvas/FrameManager.js +223 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.css.js +136 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.js +129 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.tpl.js +12 -0
- package/canvas/GraphTabs/GraphTabs.css.js +101 -0
- package/canvas/GraphTabs/GraphTabs.js +189 -0
- package/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/canvas/LODManager.js +88 -0
- package/canvas/Minimap/Minimap.css.js +73 -0
- package/canvas/Minimap/Minimap.js +210 -0
- package/canvas/Minimap/Minimap.tpl.js +7 -0
- package/canvas/NodeCanvas/NodeCanvas.css.js +398 -0
- package/canvas/NodeCanvas/NodeCanvas.js +1499 -0
- package/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/canvas/NodeSearch/NodeSearch.js +140 -0
- package/canvas/NodeSearch/NodeSearch.tpl.js +25 -0
- package/canvas/NodeViewManager.js +748 -0
- package/canvas/PcbRouteDiagnostics.js +463 -0
- package/canvas/PcbRouter.js +1127 -0
- package/canvas/PinExpansion.js +134 -0
- package/canvas/PseudoConnection.js +84 -0
- package/canvas/SelectionSync.js +163 -0
- package/canvas/SubgraphManager.js +203 -0
- package/canvas/SubgraphRouter.js +452 -0
- package/canvas/ViewportActions.js +473 -0
- package/canvas/graph-explorer.js +339 -0
- package/canvas/graph-layout.js +148 -0
- package/canvas/graph-model.js +68 -0
- package/canvas/html-in-canvas.js +202 -0
- package/canvas/project-graph-builder.js +440 -0
- package/canvas/project-graph-model.js +183 -0
- package/chat/ChatComposer/ChatComposer.css.js +652 -0
- package/chat/ChatComposer/ChatComposer.js +304 -0
- package/chat/ChatList/ChatList.css.js +102 -0
- package/chat/ChatList/ChatList.js +99 -0
- package/chat/ChatList/ChatList.tpl.js +20 -0
- package/chat/ChatListItem/ChatListItem.css.js +117 -0
- package/chat/ChatListItem/ChatListItem.js +32 -0
- package/chat/ChatListItem/ChatListItem.tpl.js +17 -0
- package/chat/ChatMessageItem/ChatMessageItem.css.js +628 -0
- package/chat/ChatMessageItem/ChatMessageItem.js +156 -0
- package/chat/ChatSidebar/ChatSidebar.css.js +150 -0
- package/chat/ChatSidebar/ChatSidebar.js +230 -0
- package/chat/ChatSidebar/ChatSidebar.tpl.js +18 -0
- package/chat/ChatSidebar/constants.js +11 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.css.js +445 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.js +304 -0
- package/chat/ChatTranscript/ChatTranscript.css.js +90 -0
- package/chat/ChatTranscript/ChatTranscript.js +244 -0
- package/chat/chat-context.js +123 -0
- package/chat/message-model.js +156 -0
- package/cli.js +20 -0
- package/control/Button/Button.css.js +93 -0
- package/control/Button/Button.js +78 -0
- package/control/Button/Button.tpl.js +3 -0
- package/control/Field/Field.css.js +91 -0
- package/control/Field/Field.js +17 -0
- package/control/Field/Field.tpl.js +3 -0
- package/core/Connection.js +47 -0
- package/core/Editor.js +449 -0
- package/core/Frame.js +33 -0
- package/core/GraphMermaid.js +348 -0
- package/core/GraphText.js +228 -0
- package/core/Node.js +145 -0
- package/core/Portal.js +106 -0
- package/core/Socket.js +187 -0
- package/core/SubgraphNode.js +121 -0
- package/core/base-path.js +55 -0
- package/core/dom-utils.js +14 -0
- package/core/index.js +18 -0
- package/core/local-cache.js +26 -0
- package/core/state-sync.js +227 -0
- package/custom-elements.json +6380 -0
- package/discover.js +240 -0
- package/display/Badge/Badge.css.js +44 -0
- package/display/Badge/Badge.js +17 -0
- package/display/Badge/Badge.tpl.js +3 -0
- package/display/Banner/Banner.css.js +61 -0
- package/display/Banner/Banner.js +17 -0
- package/display/Banner/Banner.tpl.js +3 -0
- package/display/CodeBlock/CodeBlock.css.js +194 -0
- package/display/CodeBlock/CodeBlock.js +220 -0
- package/display/CodeBlock/CodeBlock.tpl.js +11 -0
- package/display/DataTable/DataTable.css.js +101 -0
- package/display/DataTable/DataTable.js +136 -0
- package/display/DataTable/DataTable.tpl.js +13 -0
- package/display/EmptyState/EmptyState.css.js +33 -0
- package/display/EmptyState/EmptyState.js +17 -0
- package/display/EmptyState/EmptyState.tpl.js +3 -0
- package/display/EventFeed/EventFeed.css.js +145 -0
- package/display/EventFeed/EventFeed.js +64 -0
- package/display/EventFeed/EventFeed.tpl.js +14 -0
- package/display/EventFeed/EventFeedItem.js +116 -0
- package/display/EventFeed/EventFeedItem.tpl.js +22 -0
- package/display/LoadingOverlay/LoadingOverlay.css.js +91 -0
- package/display/LoadingOverlay/LoadingOverlay.js +48 -0
- package/display/LoadingOverlay/LoadingOverlay.tpl.js +12 -0
- package/display/Metric/Metric.css.js +60 -0
- package/display/Metric/Metric.js +17 -0
- package/display/Metric/Metric.tpl.js +6 -0
- package/display/OutputGraphPreview/OutputGraphPreview.css.js +122 -0
- package/display/OutputGraphPreview/OutputGraphPreview.js +89 -0
- package/display/OutputGraphPreview/OutputGraphPreview.tpl.js +13 -0
- package/display/OutputListPreview/OutputListPreview.css.js +109 -0
- package/display/OutputListPreview/OutputListPreview.js +77 -0
- package/display/OutputListPreview/OutputListPreview.tpl.js +13 -0
- package/display/SourceEditor/SourceEditor.css.js +39 -0
- package/display/SourceEditor/SourceEditor.js +129 -0
- package/display/SourceEditor/SourceEditor.tpl.js +10 -0
- package/display/SourceViewer/SourceViewer.css.js +80 -0
- package/display/SourceViewer/SourceViewer.js +418 -0
- package/display/SourceViewer/SourceViewer.tpl.js +17 -0
- package/display/StatusRibbon/StatusRibbon.css.js +73 -0
- package/display/StatusRibbon/StatusRibbon.js +87 -0
- package/display/StatusRibbon/StatusRibbon.tpl.js +7 -0
- package/display/event-feed-adapter.js +72 -0
- package/display/format-utils.js +29 -0
- package/display/highlight.js +659 -0
- package/display/icons.js +37 -0
- package/display/markdown-formatter.js +60 -0
- package/display/network-approval-page.js +487 -0
- package/display/output-preview.js +261 -0
- package/effects/CellBg/CellBg.css.js +33 -0
- package/effects/CellBg/CellBg.js +410 -0
- package/effects/CellBg/CellBg.tpl.js +5 -0
- package/graph/canvas-adapter.js +223 -0
- package/graph/graph-algorithms.js +31 -0
- package/graph/index.js +46 -0
- package/graph/model.js +176 -0
- package/graph/project-graph-build.js +66 -0
- package/graph/project-graph-metadata.js +253 -0
- package/graph/project-package.js +128 -0
- package/graph/project-runtime.js +116 -0
- package/graph/project-transaction.js +284 -0
- package/graph/skeleton-utils.js +84 -0
- package/graph/theme-contract.js +36 -0
- package/graph/transaction-parser.js +56 -0
- package/icons/MaterialSymbols.js +69 -0
- package/icons/material-symbols-outlined-400.ttf +0 -0
- package/icons/material-symbols.css +24 -0
- package/index.js +95 -0
- package/inspector/InspectorPanel/InspectorPanel.css.js +375 -0
- package/inspector/InspectorPanel/InspectorPanel.js +368 -0
- package/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/inspector/TemplatePreview/TemplatePreview.js +145 -0
- package/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/interactions/ConnectFlow.js +304 -0
- package/interactions/Drag.js +104 -0
- package/interactions/Selector.js +133 -0
- package/interactions/SnapGrid.js +66 -0
- package/interactions/Zoom.js +139 -0
- package/layout/ActionZone/ActionZone.css.js +88 -0
- package/layout/ActionZone/ActionZone.js +261 -0
- package/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/layout/CrossLayoutPortalBridge/CrossLayoutPortalBridge.js +255 -0
- package/layout/Layout/Layout.css.js +91 -0
- package/layout/Layout/Layout.js +637 -0
- package/layout/Layout/Layout.tpl.js +27 -0
- package/layout/LayoutNode/LayoutNode.css.js +302 -0
- package/layout/LayoutNode/LayoutNode.js +509 -0
- package/layout/LayoutNode/LayoutNode.tpl.js +39 -0
- package/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/layout/LayoutRouter/LayoutRouter.js +274 -0
- package/layout/LayoutRouter/SectionRegistry.js +135 -0
- package/layout/LayoutRouter/routerSync.js +250 -0
- package/layout/LayoutSidebar/LayoutSidebar.css.js +411 -0
- package/layout/LayoutSidebar/LayoutSidebar.js +368 -0
- package/layout/LayoutSidebar/LayoutSidebar.tpl.js +26 -0
- package/layout/LayoutSidebar/SidebarSection.css.js +20 -0
- package/layout/LayoutSidebar/SidebarSection.js +184 -0
- package/layout/LayoutSidebar/SidebarSection.tpl.js +22 -0
- package/layout/LayoutTree.js +373 -0
- package/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/layout/PanelMenu/PanelMenu.js +95 -0
- package/layout/PanelMenu/PanelMenu.tpl.js +17 -0
- package/layout/ProjectTabs/ProjectTabs.css.js +188 -0
- package/layout/ProjectTabs/ProjectTabs.js +77 -0
- package/layout/ProjectTabs/ProjectTabs.tpl.js +15 -0
- package/layout/index.js +40 -0
- package/list/ListDetailShell/ListDetailShell.css.js +128 -0
- package/list/ListDetailShell/ListDetailShell.js +72 -0
- package/list/ListDetailShell/ListDetailShell.tpl.js +36 -0
- package/list/ListItem/ListItem.css.js +111 -0
- package/list/ListItem/ListItem.js +66 -0
- package/list/ListItem/ListItem.tpl.js +18 -0
- package/locale/index.js +503 -0
- package/manifest/component-registry.js +2446 -0
- package/manifest/graph-schema.js +285 -0
- package/manifest/index.js +6 -0
- package/manifest/project-schema-catalog.js +246 -0
- package/manifest/rule-catalog.js +201 -0
- package/manifest/theme-catalog.js +2149 -0
- package/manifest/ui-schema-catalog.js +334 -0
- package/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/menu/ContextMenu/ContextMenu.js +82 -0
- package/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/navigation/QuickOpen/QuickOpen.css.js +92 -0
- package/navigation/QuickOpen/QuickOpen.js +185 -0
- package/navigation/QuickOpen/QuickOpen.tpl.js +15 -0
- package/navigation/quick-open-utils.js +101 -0
- package/node/CtrlItem/CtrlItem.css.js +41 -0
- package/node/CtrlItem/CtrlItem.js +24 -0
- package/node/CtrlItem/CtrlItem.tpl.js +17 -0
- package/node/GraphFrame/GraphFrame.css.js +66 -0
- package/node/GraphFrame/GraphFrame.js +32 -0
- package/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/node/GraphNode/GraphNode.css.js +815 -0
- package/node/GraphNode/GraphNode.js +173 -0
- package/node/GraphNode/GraphNode.tpl.js +33 -0
- package/node/NodeCallout/NodeCallout.css.js +91 -0
- package/node/NodeCallout/NodeCallout.js +281 -0
- package/node/NodeCallout/NodeCallout.tpl.js +8 -0
- package/node/NodeSocket/NodeSocket.css.js +68 -0
- package/node/NodeSocket/NodeSocket.js +26 -0
- package/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/node/PortItem/PortItem.css.js +93 -0
- package/node/PortItem/PortItem.js +87 -0
- package/node/PortItem/PortItem.tpl.js +10 -0
- package/package.json +165 -0
- package/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/palette/PaletteBrowser/PaletteBrowser.js +152 -0
- package/palette/PaletteBrowser/PaletteBrowser.tpl.js +23 -0
- package/plugins/History.js +408 -0
- package/plugins/Readonly.js +60 -0
- package/rules/symbiote-3x.json +170 -0
- package/schemas/component-descriptor-v1.json +91 -0
- package/schemas/component-descriptor-v2.json +145 -0
- package/schemas/graph-model-v1.json +179 -0
- package/schemas/graph-v1.json +91 -0
- package/schemas/project-package-v1.json +102 -0
- package/schemas/project-transaction-v1.json +114 -0
- package/schemas/runtime-ui-v1.json +80 -0
- package/schemas/theme-rule-block-v1.json +73 -0
- package/shapes/CircleShape.js +79 -0
- package/shapes/CommentShape.js +35 -0
- package/shapes/DiamondShape.js +130 -0
- package/shapes/NodeShape.js +79 -0
- package/shapes/PillShape.js +91 -0
- package/shapes/RectShape.js +84 -0
- package/shapes/SVGShape.js +525 -0
- package/shapes/index.js +63 -0
- package/surface/Card/Card.css.js +57 -0
- package/surface/Card/Card.js +17 -0
- package/surface/Card/Card.tpl.js +3 -0
- package/themes/Palette.js +30 -0
- package/themes/Skin.js +113 -0
- package/themes/Theme.js +82 -0
- package/themes/carbon.js +135 -0
- package/themes/dark.js +140 -0
- package/themes/default-dark.js +714 -0
- package/themes/default-provider.css +635 -0
- package/themes/default-provider.js +718 -0
- package/themes/ebook.js +136 -0
- package/themes/grey.js +137 -0
- package/themes/light.js +139 -0
- package/themes/neon.js +138 -0
- package/themes/pcb.js +273 -0
- package/themes/synthwave.js +138 -0
- package/tokens/base.json +29 -0
- package/tokens/themes/carbon.json +11 -0
- package/tokens/themes/dark.json +12 -0
- package/tokens/themes/default-dark.json +1543 -0
- package/tokens/themes/default-provider.json +1543 -0
- package/tokens/themes/ebook.json +11 -0
- package/tokens/themes/grey.json +11 -0
- package/tokens/themes/light.json +12 -0
- package/tokens/themes/neon.json +11 -0
- package/tokens/themes/pcb.json +11 -0
- package/tokens/themes/synthwave.json +11 -0
- package/toolbar/QuickToolbar/QuickToolbar.css.js +152 -0
- package/toolbar/QuickToolbar/QuickToolbar.js +529 -0
- package/toolbar/QuickToolbar/QuickToolbar.tpl.js +34 -0
- package/tree/TreePanel/TreePanel.css.js +112 -0
- package/tree/TreePanel/TreePanel.js +147 -0
- package/tree/TreePanel/TreePanel.tpl.js +18 -0
- package/tree/TreeView/TreeView.css.js +122 -0
- package/tree/TreeView/TreeView.js +365 -0
- package/tree/TreeView/TreeView.tpl.js +10 -0
- package/ui/dialogs.js +221 -0
- package/ui/host-adapters.js +114 -0
- package/ui/index.js +660 -0
- package/ui/locale.js +50 -0
- package/ui/overlay-stack.js +89 -0
- package/ui/shared-styles.js +26 -0
- package/webmcp.js +37 -0
- package/xr/deep-graph.js +646 -0
- package/xr/emulation.js +198 -0
- package/xr/gesture.js +228 -0
- package/xr/html-canvas-renderer.js +472 -0
- package/xr/index.js +15 -0
- package/xr/layout-projection.js +1046 -0
- package/xr/panel-frame.js +128 -0
- package/xr/panel-host.js +267 -0
- package/xr/pointer.js +258 -0
- package/xr/scene-controller.js +242 -0
- package/xr/spatial-scene.js +212 -0
- package/xr/theme-bridge.js +105 -0
- package/xr/three-webxr-adapter.js +3439 -0
- package/xr/webgl-layer-renderer.js +419 -0
- package/xr/webxr.js +679 -0
- package/xr/workbench.js +516 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
export class SubgraphRouter {
|
|
3
|
+
#canvas = null;
|
|
4
|
+
#config = {};
|
|
5
|
+
#isAutoRouting = false;
|
|
6
|
+
#canvasDepth = 0;
|
|
7
|
+
#listeners = [];
|
|
8
|
+
#destroyed = false;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {HTMLElement} canvas - NodeCanvas instance
|
|
12
|
+
* @param {Object} config - Configuration options
|
|
13
|
+
* @param {String} [config.hashPrefix='graph'] - URL hash routing prefix
|
|
14
|
+
* @param {Map} [config.fileMap] - Map of file paths to node IDs
|
|
15
|
+
* @param {Map} [config.dirNodeMap] - Map of directory paths to node IDs
|
|
16
|
+
* @param {Map} [config.symbolMap] - Map of symbol IDs to { name, file }
|
|
17
|
+
* @param {Set} [config.drillableFiles] - Set of file paths that contain symbol subgraphs
|
|
18
|
+
* @param {Function} [config.onNavigate] - Callback after successful navigation
|
|
19
|
+
*/
|
|
20
|
+
constructor(canvas, config = {}) {
|
|
21
|
+
this.#canvas = canvas;
|
|
22
|
+
this.updateConfig(config);
|
|
23
|
+
this.#bindListeners();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
updateConfig(config = {}) {
|
|
27
|
+
this.#config = {
|
|
28
|
+
hashPrefix: 'graph',
|
|
29
|
+
fileMap: new Map(),
|
|
30
|
+
dirNodeMap: new Map(),
|
|
31
|
+
symbolMap: new Map(),
|
|
32
|
+
drillableFiles: new Set(),
|
|
33
|
+
onNavigate: () => {},
|
|
34
|
+
...this.#config,
|
|
35
|
+
...config,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Internal router depth tracker
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
get depth() {
|
|
44
|
+
return this.#canvasDepth;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Prevent hash rewriting during automatic routing across layers
|
|
49
|
+
*/
|
|
50
|
+
#runAutoRouting(fn) {
|
|
51
|
+
this.#isAutoRouting = true;
|
|
52
|
+
fn();
|
|
53
|
+
this.#isAutoRouting = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#bindListeners() {
|
|
57
|
+
let handleEnter = (e) => {
|
|
58
|
+
this.#canvasDepth++;
|
|
59
|
+
if (this.#isAutoRouting) return;
|
|
60
|
+
|
|
61
|
+
let nodeId = e.detail?.nodeId;
|
|
62
|
+
if (!nodeId) return;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let path = null;
|
|
66
|
+
for (const [key, id] of this.#config.dirNodeMap.entries()) {
|
|
67
|
+
if (id === nodeId) {
|
|
68
|
+
path = key;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!path) {
|
|
73
|
+
for (const [key, id] of this.#config.fileMap.entries()) {
|
|
74
|
+
if (id === nodeId) {
|
|
75
|
+
path = key;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (path) {
|
|
82
|
+
let hash = window.location.hash;
|
|
83
|
+
let [, queryStr] = hash.split('?');
|
|
84
|
+
let params = new URLSearchParams(queryStr || '');
|
|
85
|
+
|
|
86
|
+
params.set('in', '1');
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if (!params.has('symbol') || !this.#config.drillableFiles.has(path)) {
|
|
90
|
+
params.delete('symbol');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let newQuery = params.toString();
|
|
94
|
+
history.replaceState(null, '', `#${this.#config.hashPrefix}/${path}?${newQuery}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
let handleExit = (e) => {
|
|
99
|
+
let level = e.detail?.level;
|
|
100
|
+
this.#canvasDepth = typeof level === 'number' ? level : Math.max(0, this.#canvasDepth - 1);
|
|
101
|
+
if (this.#isAutoRouting) return;
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
let hashPath = window.location.hash
|
|
105
|
+
.replace(`#${this.#config.hashPrefix}/`, '')
|
|
106
|
+
.split('?')[0]
|
|
107
|
+
.split('&')[0];
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
let exitedDirPath = hashPath;
|
|
111
|
+
if (this.#config.fileMap?.has(hashPath)) {
|
|
112
|
+
let parts = hashPath.split('/');
|
|
113
|
+
parts.pop();
|
|
114
|
+
exitedDirPath = parts.join('/') + '/';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (exitedDirPath && !this.#config.dirNodeMap?.has(exitedDirPath)) {
|
|
118
|
+
let segments = exitedDirPath.replace(/\/$/, '').split('/');
|
|
119
|
+
while (segments.length > 0) {
|
|
120
|
+
let candidate = segments.join('/') + '/';
|
|
121
|
+
if (this.#config.dirNodeMap?.has(candidate)) {
|
|
122
|
+
exitedDirPath = candidate;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
segments.pop();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let updateUrl = (newPath, setIn = false, setFocus = null) => {
|
|
130
|
+
let hash = window.location.hash;
|
|
131
|
+
let [, queryStr] = hash.split('?');
|
|
132
|
+
let params = new URLSearchParams(queryStr || '');
|
|
133
|
+
|
|
134
|
+
let newBase = `#${this.#config.hashPrefix}`;
|
|
135
|
+
if (newPath) newBase += `/${newPath}`;
|
|
136
|
+
|
|
137
|
+
if (setIn) params.set('in', '1');
|
|
138
|
+
else params.delete('in');
|
|
139
|
+
|
|
140
|
+
if (setFocus) params.set('focus', setFocus);
|
|
141
|
+
else params.delete('focus');
|
|
142
|
+
|
|
143
|
+
params.delete('symbol');
|
|
144
|
+
|
|
145
|
+
let newQuery = params.toString();
|
|
146
|
+
let newHash = newQuery ? `${newBase}?${newQuery}` : newBase;
|
|
147
|
+
history.replaceState(null, '', newHash);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (this.#canvasDepth > 0) {
|
|
151
|
+
|
|
152
|
+
if (this.#config.dirNodeMap?.has(exitedDirPath)) {
|
|
153
|
+
updateUrl(exitedDirPath, true, null);
|
|
154
|
+
} else if (exitedDirPath) {
|
|
155
|
+
updateUrl(exitedDirPath, false, null);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
|
|
159
|
+
if (exitedDirPath) {
|
|
160
|
+
updateUrl(null, false, exitedDirPath);
|
|
161
|
+
} else {
|
|
162
|
+
updateUrl(null, false, null);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if (exitedDirPath) {
|
|
168
|
+
requestAnimationFrame(() => {
|
|
169
|
+
let nodeId =
|
|
170
|
+
this.#config.dirNodeMap?.get(exitedDirPath) || this.#config.fileMap?.get(exitedDirPath);
|
|
171
|
+
if (nodeId && this.#canvas.flyToNode) {
|
|
172
|
+
this.#canvas.flyToNode(nodeId, { zoom: 0.8 });
|
|
173
|
+
} else if (this.#canvas.fitView) {
|
|
174
|
+
this.#canvas.fitView();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
} else if (this.#canvas.fitView) {
|
|
178
|
+
requestAnimationFrame(() => this.#canvas.fitView());
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
this.#canvas.addEventListener('subgraph-enter', handleEnter);
|
|
183
|
+
this.#canvas.addEventListener('subgraph-exit', handleExit);
|
|
184
|
+
|
|
185
|
+
this.#listeners.push(
|
|
186
|
+
{ name: 'subgraph-enter', fn: handleEnter },
|
|
187
|
+
{ name: 'subgraph-exit', fn: handleExit }
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Reads URL hash and triggers initial drill down + focus sequence.
|
|
193
|
+
*
|
|
194
|
+
* Universal URL semantics:
|
|
195
|
+
* - `#graph` → root, fit view
|
|
196
|
+
* - `#graph?focus=src/analysis/` → root, fly to analysis node
|
|
197
|
+
* - `#graph/src/analysis/?in=1` → drill into analysis
|
|
198
|
+
* - `#graph/src/analysis/?in=1&focus=file.js` → drill into analysis, focus file.js
|
|
199
|
+
* - `#graph/src/analysis/file.js?in=1` → drill into analysis, drill into file
|
|
200
|
+
* - `#graph/src/analysis/file.js?in=1&symbol=name` → drill into file, focus symbol
|
|
201
|
+
* - `#graph/src/analysis/` → root, fly to analysis node
|
|
202
|
+
*
|
|
203
|
+
* @param {NodeEditor} editor
|
|
204
|
+
*/
|
|
205
|
+
restoreFromHash(editor) {
|
|
206
|
+
if (this.#destroyed || !this.#canvas) return;
|
|
207
|
+
|
|
208
|
+
let hash = window.location.hash;
|
|
209
|
+
let prefix = `#${this.#config.hashPrefix}`;
|
|
210
|
+
if (!hash.startsWith(prefix)) return;
|
|
211
|
+
|
|
212
|
+
let afterPrefix = hash.slice(prefix.length);
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
let qIdx = afterPrefix.indexOf('?');
|
|
216
|
+
let pathPart = qIdx >= 0 ? afterPrefix.slice(0, qIdx) : afterPrefix;
|
|
217
|
+
let queryStr = qIdx >= 0 ? afterPrefix.slice(qIdx + 1) : '';
|
|
218
|
+
let params = new URLSearchParams(queryStr);
|
|
219
|
+
|
|
220
|
+
let drillPath = pathPart.replace(/^\//, '');
|
|
221
|
+
let hasDrillFlag = params.get('in') === '1';
|
|
222
|
+
let focusParam = params.get('focus');
|
|
223
|
+
let symbolParam = params.get('symbol');
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if (!drillPath && !focusParam && !hasDrillFlag && !symbolParam) {
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
this.#isAutoRouting = true;
|
|
230
|
+
let safetyCounter = 10;
|
|
231
|
+
let doPopStep = () => {
|
|
232
|
+
if (this.#canvasDepth <= 0 || safetyCounter-- <= 0) {
|
|
233
|
+
this.#isAutoRouting = false;
|
|
234
|
+
this.#canvas.fitView?.();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let onExit = () => {
|
|
239
|
+
this.#canvas.removeEventListener('subgraph-exit', onExit);
|
|
240
|
+
|
|
241
|
+
requestAnimationFrame(doPopStep);
|
|
242
|
+
};
|
|
243
|
+
this.#canvas.addEventListener('subgraph-exit', onExit);
|
|
244
|
+
this.#canvas.drillUp?.();
|
|
245
|
+
};
|
|
246
|
+
doPopStep();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
if (!drillPath && focusParam) {
|
|
252
|
+
this.navigateTo(decodeURIComponent(focusParam), 0, false);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
if (drillPath && hasDrillFlag) {
|
|
258
|
+
let drilled = this.#restoreDrillDown(drillPath, editor, true);
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if (drilled && focusParam) {
|
|
262
|
+
let fullFocusPath = drillPath + decodeURIComponent(focusParam);
|
|
263
|
+
requestAnimationFrame(() => {
|
|
264
|
+
this.navigateTo(fullFocusPath, 0, false);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if (drilled && symbolParam) {
|
|
270
|
+
requestAnimationFrame(() => {
|
|
271
|
+
this.restoreSymbolFocus(drillPath);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
if (drillPath) {
|
|
279
|
+
this.navigateTo(drillPath, 0, false);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
#restoreDrillDown(targetPath, editor, autoDrill = false) {
|
|
284
|
+
if (!this.#canvas) return false;
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
for (const node of editor.getNodes()) {
|
|
288
|
+
if (!node._isSubgraph) continue;
|
|
289
|
+
let nodePath = node.params?.path;
|
|
290
|
+
if (!nodePath) continue;
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
if (nodePath === targetPath) {
|
|
294
|
+
if (autoDrill) {
|
|
295
|
+
this.#runAutoRouting(() => {
|
|
296
|
+
this.#canvas.drillDown(node.id);
|
|
297
|
+
});
|
|
298
|
+
if (this.#canvas.fitView) {
|
|
299
|
+
requestAnimationFrame(() => this.#canvas.fitView());
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
|
|
303
|
+
this.#canvas.flyToNode?.(node.id, { zoom: 0.8 }) || this.#canvas.selectNode?.(node.id);
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
if (targetPath.startsWith(nodePath)) {
|
|
310
|
+
this.#runAutoRouting(() => {
|
|
311
|
+
this.#canvas.drillDown(node.id);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
requestAnimationFrame(() => {
|
|
315
|
+
this.navigateTo(targetPath, 0, autoDrill);
|
|
316
|
+
});
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Restore visual symbol focus from &symbol= URL parameter.
|
|
326
|
+
* Called after autoDrill into a file subgraph to select the target function/class node.
|
|
327
|
+
* @param {string} filePath - the file we drilled into
|
|
328
|
+
*/
|
|
329
|
+
restoreSymbolFocus(filePath) {
|
|
330
|
+
let hashParts = window.location.hash.split('&symbol=');
|
|
331
|
+
if (hashParts.length < 2) return;
|
|
332
|
+
let symbolName = decodeURIComponent(hashParts[1].split('&')[0]);
|
|
333
|
+
if (!symbolName || !this.#config.symbolMap) return;
|
|
334
|
+
|
|
335
|
+
for (const [nodeId, params] of this.#config.symbolMap) {
|
|
336
|
+
if (params.name === symbolName && params.file === filePath) {
|
|
337
|
+
this.#canvas?.selectNode(nodeId);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Focus viewport on a specific node by path
|
|
345
|
+
* @param {string} targetPath - e.g. 'src/core/event-bus.js'
|
|
346
|
+
* @param {number} depth - Internal recursion depth limit
|
|
347
|
+
* @param {boolean} autoDrill - Attempt to drill into target if it is a Subgraph
|
|
348
|
+
* @returns {boolean} true if node found and focused
|
|
349
|
+
*/
|
|
350
|
+
navigateTo(targetPath, depth = 0, autoDrill = false) {
|
|
351
|
+
if (this.#destroyed || !this.#canvas || !this.#config.fileMap || depth > 5) return false;
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
let targetId = null;
|
|
355
|
+
let isFile = true;
|
|
356
|
+
if (this.#config.fileMap.has(targetPath)) {
|
|
357
|
+
targetId = this.#config.fileMap.get(targetPath);
|
|
358
|
+
} else if (this.#config.dirNodeMap && this.#config.dirNodeMap.has(targetPath)) {
|
|
359
|
+
targetId = this.#config.dirNodeMap.get(targetPath);
|
|
360
|
+
isFile = false;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (!targetId) return false;
|
|
364
|
+
|
|
365
|
+
let positions =
|
|
366
|
+
typeof this.#canvas.getPositions === 'function' ? this.#canvas.getPositions() : {};
|
|
367
|
+
let pos = positions[targetId];
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
if (!pos && typeof this.#canvas.drillDown === 'function') {
|
|
371
|
+
if (this.#config.dirNodeMap) {
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
let searchPath = targetPath;
|
|
375
|
+
if (isFile) {
|
|
376
|
+
|
|
377
|
+
let parts = targetPath.split('/');
|
|
378
|
+
parts.pop();
|
|
379
|
+
searchPath = parts.join('/') + '/';
|
|
380
|
+
if (searchPath === '/') searchPath = './';
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
let segments = searchPath.replace(/\/$/, '').split('/');
|
|
385
|
+
while (segments.length > 0) {
|
|
386
|
+
let candidateDir = segments.join('/') + '/';
|
|
387
|
+
let dirId = this.#config.dirNodeMap.get(candidateDir);
|
|
388
|
+
if (dirId && positions[dirId]) {
|
|
389
|
+
|
|
390
|
+
this.#runAutoRouting(() => {
|
|
391
|
+
this.#canvas.drillDown(dirId);
|
|
392
|
+
});
|
|
393
|
+
requestAnimationFrame(() => this.navigateTo(targetPath, depth + 1, autoDrill));
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
segments.pop();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
let rootId = this.#config.dirNodeMap.get('./');
|
|
400
|
+
if (rootId && positions[rootId]) {
|
|
401
|
+
this.#runAutoRouting(() => {
|
|
402
|
+
this.#canvas.drillDown(rootId);
|
|
403
|
+
});
|
|
404
|
+
requestAnimationFrame(() => this.navigateTo(targetPath, depth + 1, autoDrill));
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
if (this.#canvasDepth > 0) {
|
|
410
|
+
this.#runAutoRouting(() => {
|
|
411
|
+
this.#canvas.drillUp?.();
|
|
412
|
+
});
|
|
413
|
+
requestAnimationFrame(() => this.navigateTo(targetPath, depth + 1, autoDrill));
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
if (autoDrill && isFile && this.#config.drillableFiles?.has(targetPath)) {
|
|
422
|
+
this.#runAutoRouting(() => {
|
|
423
|
+
this.#canvas.drillDown?.(targetId);
|
|
424
|
+
});
|
|
425
|
+
requestAnimationFrame(() => {
|
|
426
|
+
if (this.#canvas.fitView) this.#canvas.fitView();
|
|
427
|
+
|
|
428
|
+
this.restoreSymbolFocus(targetPath);
|
|
429
|
+
});
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
if (this.#canvas.flyToNode) {
|
|
435
|
+
this.#canvas.flyToNode(targetId, { zoom: 0.8 });
|
|
436
|
+
} else {
|
|
437
|
+
|
|
438
|
+
this.#canvas.selectNode?.(targetId);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.#config.onNavigate(targetPath);
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
destroy() {
|
|
446
|
+
this.#destroyed = true;
|
|
447
|
+
for (const listener of this.#listeners) {
|
|
448
|
+
this.#canvas.removeEventListener(listener.name, listener.fn);
|
|
449
|
+
}
|
|
450
|
+
this.#listeners = [];
|
|
451
|
+
}
|
|
452
|
+
}
|