vue3-network-graph 0.1.0 → 0.1.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/README.en.md CHANGED
@@ -10,7 +10,10 @@ A network topology component built with **Vue 3 + SVG** — no third-party chart
10
10
  - **Edge merging**: more than 6 edges between the same pair (`MAX_BUNDLE`) collapse into one line with a count badge; clicking a merged line selects the whole group — `edge-select` returns the representative with a `bundleEdges` array (all edges in the group), and `selection-change` lists every edge of the group
11
11
  - **Nodes**: 2D / 2.5D icons, breathing status ring, text nodes, custom icon slot `#node-icon`
12
12
  - **Interaction**: node dragging (**group drag for multi-selections**), drag-to-resize node boxes, **infinite canvas panning**, wheel zoom, node/edge selection, **Ctrl+click multi-select**, **Ctrl+left-drag marquee select**, flow animation (dashed light + particles)
13
+ - **Large-graph performance**: viewport culling (only on-screen elements render) + decorative effects auto-degrade above size budgets + edge geometry caching; nodes take hit priority over dense overlapping edges — thousand-node graphs stay smooth to pan and drag
13
14
  - **Coordinates**: `clientToSvg` (mouse → SVG) and `svgToClient` (SVG → screen), callable from outside via template ref
15
+ - **Appearance config**: canvas background radial gradient (inner/outer colors, custom stops), grid (color / step / opacity) and selection colors — all through `config`
16
+ - **Data sync**: in-component ↔ external two-way sync — deep-watched props (array replacement and in-place edits), edits published via events / v-model, `setData()` for full external replacement
14
17
  - **Extras**: group dashed frames, grid background, 10 node states
15
18
 
16
19
  ## Install
@@ -81,14 +84,50 @@ const topoRef = ref(null);
81
84
  | Select a node / edge | Left click | Clicking an already-selected item deselects it; clicking blank canvas clears the whole selection |
82
85
  | Multi-select (click) | Ctrl (⌘ on macOS) + click | Adds/removes nodes and edges to/from the selection — mixed node+edge selections supported |
83
86
  | Multi-select (marquee) | Ctrl (⌘ on macOS) + left-drag | Draws a rectangle on the blank canvas; **every node intersecting it** joins the selection (union semantics; nodes only) |
84
- | Drag one node | Drag a node | Requires `editable` and `config.nodeDraggable !== false`; dragging an unselected node selects it first |
87
+ | Drag one node | Drag anywhere on the node area | Requires `editable` and `config.nodeDraggable !== false`; the whole node area (box + label strip, icon-label gap included) is a hit area; dragging an unselected node selects it first |
85
88
  | Drag many nodes | Drag any **already-selected** node | The whole selection moves together — identical deltas; the selection survives the drag |
86
89
  | Pan (infinite) | Left-drag on blank canvas, or middle-drag anywhere | No bounds at all; content and grid move together; selection untouched |
87
90
  | Zoom | Wheel | Zooms around the mouse position (0.2x–5x) |
88
91
  | Resize a node | Drag one of the 8 handles on a single-selected node | Requires `editable`, `config.nodeResizable !== false` |
89
92
  | Create an edge | Drag a node handle onto another node | Requires `config.showNodeHandles: true` |
90
93
 
91
- > Left-button “click” vs “drag” on the blank canvas is separated by a small threshold (4px pan / 3px marquee / 3px node drag): below it the gesture still counts as a click (clears or toggles the selection); above it the drag takes over. A stray click dispatched by the browser right after a drag gesture is suppressed, so selections are never changed accidentally.
94
+ > Left-button “click” vs “drag” on the blank canvas is separated by a small threshold (4px pan / 3px marquee / 3px node drag): below it the gesture still counts as a click (clears or toggles the selection); above it the drag takes over. A stray click dispatched by the browser right after a drag gesture is suppressed, so selections are never changed accidentally. The whole node area (box + label strip) is a hit area: click and drag work anywhere inside it, including the gap between icon and label.
95
+
96
+ ## Performance with large graphs
97
+
98
+ The component ships automatic, large-graph-oriented rendering and cost controls. At the bundled demo scale (≤128 edges) the look is unchanged.
99
+
100
+ ### Viewport culling (automatic)
101
+
102
+ Only nodes/edges intersecting the current viewport (plus a small margin) are rendered — off-screen elements never enter the DOM, and the set updates as you pan/zoom. Per-frame cost drops from "whole graph" to "what is on screen". All interactions (marquee, hit tests, dragging, selection) run on the underlying data and are unaffected.
103
+
104
+ ### Decorative effects auto-degrade (overridable)
105
+
106
+ Flow/particle animations, glow filters and breathing rings are the most expensive SVG features; they switch off above size budgets:
107
+
108
+ | Effect | Auto-off threshold (default) | Override |
109
+ |---|---|---|
110
+ | Flow + particle animation | edges > 200 | `motionFx: true/false` or `fxMotionMaxEdges: n` |
111
+ | Edge glow filter | edges > 500 | `glowFx: true/false` or `fxGlowMaxEdges: n` |
112
+ | Node breathing ring | nodes > 300 | `breatheFx: true/false` or `fxBreatheMaxNodes: n` |
113
+
114
+ - Master switch `config.fx`: `false` = everything off (cheapest) / `true` = everything on / unset = automatic; per-feature overrides win over the master switch.
115
+ - Typical use: a "performance mode" toggle = `config.fx = false`.
116
+
117
+ ### Hit priority in dense graphs
118
+
119
+ The edge hit layer sits *below* the node layer: wherever an edge and a node overlap, clicks/drags act on the **node**; edges stay clickable wherever no node covers them. Nodes remain selectable and draggable no matter how dense the wiring gets.
120
+
121
+ ### Benchmark tooling (`perf/`)
122
+
123
+ ```bash
124
+ npm run dev # open http://localhost:5173/perf/stress.html?nodes=800&edges=1100
125
+ node perf/bench.mjs --label=baseline # headless-Chrome benchmark: idle / pan / node-drag / zoom
126
+ ```
127
+
128
+ - `perf/stress.html`: parameterized stress canvas (`?nodes=800&edges=1100&fx=on|off`) with a live HUD (rendered nodes, element count, fps).
129
+ - `perf/bench.mjs`: CDP-driven benchmark producing JSON (frame intervals, longtasks, CPU metrics), comparable with `perf/results-*.json`.
130
+ - 800/1100 reference: first frame under 1s (measured 0.3–0.5s), idle 60fps, worst pan/drag frame ≈0.1s (before optimization: first frame 23.6s, worst pan frame 18.0s, initial DOM elements 26,002 → ~3,000) — measure on your own machine for exact figures.
92
131
 
93
132
  ## Props
94
133
 
@@ -118,11 +157,20 @@ const topoRef = ref(null);
118
157
  | `enableMarquee` | `Boolean` | `true` | **Ctrl + left-drag marquee selection** |
119
158
  | `showGrid` | `Boolean` | `true` | Grid background (set `false` to hide) |
120
159
  | `gridColor` | `String` | `#1a2240` | Grid line color |
160
+ | `gridStep` | `Number` | `40` | Grid cell size in px at 1x zoom (scales with zoom) |
161
+ | `gridOpacity` | `Number` | `0.5` | Grid overlay opacity (0–1) |
162
+ | `radialGradient` | `Object` | see notes | Canvas background radial gradient: `{ startColor, endColor }` or `{ cx, cy, r, stops: [...] }`; default `#0f1729 → #060a14` |
121
163
  | `showCenterPoint` | `Boolean` | `false` | Canvas center crosshair |
122
164
  | `showEdgeTextBg` | `Boolean` | `false` | Edge label plates |
123
165
  | `edgeTextBgColor` | `String` | `#0a0e1a` | Plate color |
124
166
  | `showNodeHandles` | `Boolean` | `false` | Node handles (four small circles for drag-to-connect) |
167
+ | `showStatusDot` | `Boolean` | `true` | Status dot at each node's top-right corner (**shown by default**; set `false` to hide all) |
125
168
  | `watchDataChanges` | `Boolean` | `false` | In-component data change tracking (debounced 300ms → `data-change`) |
169
+ | `fx` | `Boolean` | auto | Master switch for decorative effects: `false` = all off (cheapest) / `true` = all on / unset = automatic (see "Performance with large graphs") |
170
+ | `motionFx` / `glowFx` / `breatheFx` | `Boolean` | auto | Per-feature overrides: flow+particles / edge glow / breathing rings |
171
+ | `fxMotionMaxEdges` | `Number` | `200` | Edge-count threshold above which flow+particle animation turns off |
172
+ | `fxGlowMaxEdges` | `Number` | `500` | Edge-count threshold above which edge glow turns off |
173
+ | `fxBreatheMaxNodes` | `Number` | `300` | Node-count threshold above which breathing rings turn off |
126
174
 
127
175
  ## Events
128
176
 
@@ -157,6 +205,7 @@ Edge labels accept a plain string or `{ text, rotation, fontSize, color }`.
157
205
  |---|---|
158
206
  | `getData()` | Pull the latest data on demand (deep copy): returns `{ nodes, edges }` including all in-component edits (drag positions, resized dimensions, handle-created edges). Call it anytime — independent of `watchDataChanges` — and mutate the result safely |
159
207
  | `resetDataBaseline()` | Re-arms data change tracking: snapshots the current data as the new baseline |
208
+ | `setData(data?)` | Full replace from outside (load a new graph / restore a snapshot): clears in-component bookkeeping (locally created edges, removal tombstones, field patches) and re-arms change tracking; pass `{ nodes }` to have them published via `update:nodes`, omit it to re-sync from current props; update your own `edges` array in the same operation; returns a deep copy of the new data |
160
209
  | `removeSelected()` | Delete the current selection: removing a node also **cascades to every connected edge**; syncs via `update:nodes` / `edge-remove`; returns `{ nodes, edges }` deep copies of what was deleted |
161
210
  | `addNodes(nodes)` | Append nodes: missing `id`s auto-generated, existing ids skipped; syncs via `update:nodes`; returns deep copies |
162
211
  | `addEdges(edges)` | Append edges: requires `from`/`to`, missing `id`s auto-generated, duplicates skipped; emits `edge-create`; returns deep copies |
@@ -171,6 +220,7 @@ const topoRef = ref(null);
171
220
  // --- data methods ---
172
221
  topoRef.value.resetDataBaseline();
173
222
  const { nodes, edges } = topoRef.value.getData();
223
+ topoRef.value.setData({ nodes: nextNodes }); // full swap: update your nodes / edges first, then clear in-component bookkeeping
174
224
  const removed = topoRef.value.removeSelected();
175
225
  topoRef.value.addNodes([{ label: "New node", x: 0, y: 0 }]);
176
226
  topoRef.value.addEdges([{ from: "a", to: "b" }]);
@@ -192,6 +242,8 @@ menu.style.top = `${y}px`;
192
242
 
193
243
  `data-change` cadence: the baseline only moves when you call `resetDataBaseline()`; every change between resets is reported against the same baseline, and writing the returned data back into the component does not cause trigger loops.
194
244
 
245
+ **Data sync in short**: `props.nodes` / `props.edges` are deep-synced — array replacement or in-place edits both flow in; in-component edits (drag / resize / add / update / remove) are published via `update:nodes`, `edge-create`, `edge-update` and `edge-remove`. Writing the component's own output back does not cause loops or rebuild churn. To load a whole new dataset, update your `nodes` / `edges` first, then call `setData()` to clear any in-component leftovers.
246
+
195
247
  > TypeScript users: `import type { TopologyInstance } from "vue3-network-graph"` gives you a component instance type with all the exposed methods (`getData` / `clientToSvg` / …).
196
248
 
197
249
  ### Coordinates & Conversion
package/README.md CHANGED
@@ -10,7 +10,10 @@
10
10
  - **多线合并**:同一对节点连线数超过 6 条(`MAX_BUNDLE`)自动合并为 1 条 + 数量角标;点击合并线会选中整组,`edge-select` 返回代表线并附带 `bundleEdges`(组内全部连线数据),`selection-change` 的 `edges` 包含组内全部连线
11
11
  - **节点**:2D / 2.5D 图标、状态呼吸灯、文本节点、自定义图标插槽 `#node-icon`
12
12
  - **交互**:节点拖拽(**多选整体拖动**)、拖拽控制点调整节点尺寸、**画布无限平移**、滚轮缩放、节点/连线点击选中、**Ctrl+点击多选**、**Ctrl+左键框选节点**、流向动画(虚线流光 + 粒子)
13
+ - **大图性能**:视口裁剪(只渲染视口内元素)+ 装饰动效按规模自动降级 + 边几何缓存;密集连线重叠处**节点优先**响应,千级节点可流畅平移 / 拖拽
13
14
  - **坐标能力**:组件外可调用 `clientToSvg`(鼠标坐标 → SVG 坐标)与 `svgToClient`(SVG 坐标 → 屏幕坐标)
15
+ - **外观配置**:背景径向渐变(内外圈颜色 / 自定义 stops)、网格(颜色 / 间距 / 透明度)、选中描边与连线颜色,全部经 `config` 控制
16
+ - **数据同步**:组件内外双向同步——props 深度监听(替换数组 / 就地修改均可)、改动经事件与 v-model 实时外发、`setData()` 支持组件外全量替换
14
17
  - **其他**:分组虚线框、网格背景、状态色体系(10 种节点状态)
15
18
 
16
19
  ## 安装
@@ -81,14 +84,50 @@ const topoRef = ref(null);
81
84
  | 选中节点 / 连线 | 左键单击 | 重复点击已选中项取消选中;点击空白处清空全部选中 |
82
85
  | 多选(点选) | Ctrl(macOS ⌘)+ 单击 | 将节点 / 连线加入或移出选中集合,支持节点与连线混合多选 |
83
86
  | 多选(框选) | Ctrl(macOS ⌘)+ 左键拖动 | 在空白画布拉出矩形选框,**与选框相交的节点**并入当前选中(并集语义;仅节点参与框选) |
84
- | 拖动单个节点 | 按住节点拖动 | 需 `editable` 开启且 `config.nodeDraggable !== false`;拖动未选中的节点会先选中它 |
87
+ | 拖动单个节点 | 按住节点区域任意处拖动 | 需 `editable` 开启且 `config.nodeDraggable !== false`;节点盒及文字区(含图标-文字间隙)整体可命中;拖动未选中的节点会先选中它 |
85
88
  | 拖动多个节点 | 拖动任一**已选中**节点 | 选中集合整体移动,所有节点位移一致;松开后选中状态保留 |
86
89
  | 画布平移(无限) | 空白处按住左键拖动;或任意位置按住**中键**拖动 | 平移无边界限制;内容与网格一起移动;不改变选中状态 |
87
90
  | 缩放 | 滚轮 | 以鼠标位置为中心缩放(0.2x–5x) |
88
91
  | 调整节点尺寸 | 选中**单个**节点后拖动 8 个控制点 | 需 `editable` 且 `config.nodeResizable !== false` |
89
92
  | 拖拽创建连线 | 从节点手柄拖到目标节点 | 需 `config.showNodeHandles: true` |
90
93
 
91
- > 左键在空白处的「点击」与「拖动」按小阈值区分(平移 4px / 框选 3px / 节点拖动 3px):小于阈值仍视为点击(清空或切换选中),超过阈值才进入拖动。拖拽手势结束后产生的“余波点击”会被组件抑制,不会误改选中状态。
94
+ > 左键在空白处的「点击」与「拖动」按小阈值区分(平移 4px / 框选 3px / 节点拖动 3px):小于阈值仍视为点击(清空或切换选中),超过阈值才进入拖动。拖拽手势结束后产生的“余波点击”会被组件抑制,不会误改选中状态。节点及其文字所在的完整区域为命中区域——盒内任意位置、图标与文字之间的空隙均可点击 / 拖动。
95
+
96
+ ## 性能与大数据量
97
+
98
+ 组件内置面向大图的渲染与开销控制,默认自动生效;演示数据(≤ 128 条连线)下与旧版视觉一致。
99
+
100
+ ### 视口裁剪(自动)
101
+
102
+ 只渲染与当前视口相交(含适量外扩边距)的节点与连线,视口外元素不进入 DOM;平移 / 缩放时自动增减。大图拖拽、平移开销由「画布总规模」降为「视口内规模」;框选 / 点击 / 拖拽等交互全部基于数据,不受裁剪影响。
103
+
104
+ ### 装饰动效自动降级(可覆盖)
105
+
106
+ 流光 / 粒子动画、发光滤镜与呼吸灯是 SVG 中开销最大的效果,超过规模阈值自动关闭:
107
+
108
+ | 动效 | 自动关闭阈值(默认) | 覆盖配置 |
109
+ |---|---|---|
110
+ | 流光 + 粒子动画 | 连线数 > 200 | `motionFx: true/false` 或 `fxMotionMaxEdges: n` |
111
+ | 连线发光滤镜 | 连线数 > 500 | `glowFx: true/false` 或 `fxGlowMaxEdges: n` |
112
+ | 节点呼吸灯 | 节点数 > 300 | `breatheFx: true/false` 或 `fxBreatheMaxNodes: n` |
113
+
114
+ - 总开关 `config.fx`:`false` 全关(最省性能)/ `true` 全开 / 不设 = 自动;单项覆盖优先于总开关。
115
+ - 典型用法:「性能模式」按钮 = `config.fx = false`。
116
+
117
+ ### 交互优先级(密集图形)
118
+
119
+ 连线点击感应层位于节点层下方:节点与连线重叠处,点击 / 拖动作用于**节点**;连线在未被遮挡处正常点击。保证密集图形下节点始终可选中、可拖动。
120
+
121
+ ### 性能基准工具(`perf/`)
122
+
123
+ ```bash
124
+ npm run dev # 打开 http://localhost:5173/perf/stress.html?nodes=800&edges=1100
125
+ node perf/bench.mjs --label=baseline # 无头 Chrome 自动基准:静置 / 平移 / 拖拽 / 缩放
126
+ ```
127
+
128
+ - `perf/stress.html`:参数化压力画布(`?nodes=800&edges=1100&fx=on|off`),HUD 实时显示渲染节点数、元素数与 fps。
129
+ - `perf/bench.mjs`:CDP 自动跑四场景并输出 JSON(帧间隔、longtask、CPU 指标),可与 `perf/results-*.json` 对比。
130
+ - 800/1100 参考:优化后首帧 1 秒以内(实测 0.3–0.5s)、静置 60fps、平移 / 拖拽单帧最慢 ≈0.1s(优化前首帧 23.6s、平移单帧最慢 18.0s、初始 DOM 元素 26,002 → 约 3,000)——具体以本机实测为准。
92
131
 
93
132
  ## Props
94
133
 
@@ -118,11 +157,20 @@ const topoRef = ref(null);
118
157
  | `enableMarquee` | `Boolean` | `true` | **Ctrl + 左键框选开关** |
119
158
  | `showGrid` | `Boolean` | `true` | 网格背景(设 `false` 关闭) |
120
159
  | `gridColor` | `String` | `#1a2240` | 网格线颜色 |
160
+ | `gridStep` | `Number` | `40` | 网格间距(1x 缩放下的 px,随缩放联动) |
161
+ | `gridOpacity` | `Number` | `0.5` | 网格叠层透明度(0–1) |
162
+ | `radialGradient` | `Object` | 见说明 | 画布背景径向渐变:`{ startColor, endColor }` 或 `{ cx, cy, r, stops: [...] }`;默认 `#0f1729 → #060a14` |
121
163
  | `showCenterPoint` | `Boolean` | `false` | 画布中心十字标记 |
122
164
  | `showEdgeTextBg` | `Boolean` | `false` | 连线文字底牌 |
123
165
  | `edgeTextBgColor` | `String` | `#0a0e1a` | 连线文字底牌颜色 |
124
166
  | `showNodeHandles` | `Boolean` | `false` | 节点手柄(开启后节点上下左右出现四个小圆圈,拖到另一节点松开自动连线) |
167
+ | `showStatusDot` | `Boolean` | `true` | 节点右上角状态圆点开关(**默认展示**,设 `false` 隐藏全部) |
125
168
  | `watchDataChanges` | `Boolean` | `false` | 组件内数据变动检测(拖拽、尺寸调整、手柄连线、删除等,防抖 300ms 后触发 `data-change`) |
169
+ | `fx` | `Boolean` | 自动 | 装饰动效总开关:`false` 全关(最省性能)/ `true` 全开 / 不设按规模自动(见「性能与大数据量」) |
170
+ | `motionFx` / `glowFx` / `breatheFx` | `Boolean` | 自动 | 单项覆盖:流光+粒子动画 / 连线发光 / 呼吸灯 |
171
+ | `fxMotionMaxEdges` | `Number` | `200` | 流光+粒子动画自动关闭的连线数阈值 |
172
+ | `fxGlowMaxEdges` | `Number` | `500` | 连线发光自动关闭的连线数阈值 |
173
+ | `fxBreatheMaxNodes` | `Number` | `300` | 呼吸灯自动关闭的节点数阈值 |
126
174
 
127
175
  ## Events
128
176
 
@@ -157,6 +205,7 @@ const topoRef = ref(null);
157
205
  |---|---|
158
206
  | `getData()` | 主动获取当前最新数据(深拷贝):返回 `{ nodes, edges }`,包含组件内全部本地改动(拖拽位置、尺寸调整、手柄新建连线等);随时可调,与 `watchDataChanges` 开关无关,修改返回值不影响组件内部状态 |
159
207
  | `resetDataBaseline()` | 重置数据变动检测基线:以调用时的数据为新基线,之后继续监听相对新基线的变动并通过 `data-change` 返回 |
208
+ | `setData(data?)` | 组件外全量替换数据集(加载新图谱 / 恢复快照):清除组件内痕迹(本地新建连线、删除记录、字段补丁)并重置变动基线;传 `{ nodes }` 时节点经 `update:nodes` 回写父级,不传则从当前 props 重新同步;连线请同步更新你的 `edges` 数组;返回替换后的全量深拷贝 |
160
209
  | `removeSelected()` | 删除当前选中的节点与连线:删节点时**级联删除所有与该节点相连的连线**;节点经 `update:nodes`(v-model)同步,被删连线经 `edge-remove` 事件抛出;返回 `{ nodes, edges }`(被删数据深拷贝) |
161
210
  | `addNodes(nodes)` | 添加节点(数组或单个):缺少 `id` 自动生成 uuid,已存在 `id` 跳过(改用 `updateNodes`);经 `update:nodes` 同步;返回新增节点深拷贝 |
162
211
  | `addEdges(edges)` | 添加连线(数组或单个):要求 `from` / `to`,缺少 `id` 自动生成 uuid,重复 `id` 跳过;立即渲染并经 `edge-create` 事件抛出;返回新增连线深拷贝 |
@@ -171,6 +220,7 @@ const topoRef = ref(null);
171
220
  // —— 数据方法 ——
172
221
  topoRef.value.resetDataBaseline(); // 保存完当前数据后,重置监听基线
173
222
  const { nodes, edges } = topoRef.value.getData(); // 组件外随时主动取数(保存 / 上报前)
223
+ topoRef.value.setData({ nodes: nextNodes }); // 外部换一整套数据:先更新你自己的 nodes / edges,再清理组件内痕迹
174
224
  const removed = topoRef.value.removeSelected(); // 删除选中(删节点级联删除相连线)
175
225
  topoRef.value.addNodes([{ label: "新节点", x: 0, y: 0 }]);
176
226
  topoRef.value.addEdges([{ from: "a", to: "b" }]);
@@ -192,6 +242,8 @@ menu.style.top = `${y}px`;
192
242
 
193
243
  `data-change` 的触发节奏:基线只在你调用 `resetDataBaseline()` 时移动;两次重置之间的所有变动(可多次)都会以相对同一基线的摘要返回,父组件把返回数据回写到组件不会引起循环触发。
194
244
 
245
+ **数据同步说明**:`props.nodes` / `props.edges` 为深度同步——父级整体替换数组、或就地修改字段,组件内都会跟随更新;组件内的拖拽 / 尺寸 / 增删改也会经 `update:nodes`、`edge-create`、`edge-update`、`edge-remove` 即时外发。父级把组件发出的数据原样写回不会造成循环或重复重建。加载一整套新数据时,先更新你的 `nodes` / `edges`,再调用 `setData()` 清理组件内残留状态。
246
+
195
247
  > TypeScript 用户:`import type { TopologyInstance } from "vue3-network-graph"`,可获得包含 `getData` / `clientToSvg` 等全部暴露方法的组件实例类型。
196
248
 
197
249
  ### 坐标系与坐标转换说明
package/dist/index.d.ts CHANGED
@@ -63,6 +63,28 @@ export interface TopologyGroup {
63
63
  [key: string]: unknown;
64
64
  }
65
65
 
66
+ export interface TopologyRadialGradientStop {
67
+ /** e.g. "0%", "60%" */
68
+ offset?: string;
69
+ color: string;
70
+ /** 0-1 */
71
+ opacity?: number;
72
+ }
73
+
74
+ export interface TopologyRadialGradientConfig {
75
+ cx?: string;
76
+ cy?: string;
77
+ r?: string;
78
+ /** Inner circle color (offset 0%) */
79
+ startColor?: string;
80
+ /** Outer edge color (offset 100%) */
81
+ endColor?: string;
82
+ startOpacity?: number;
83
+ endOpacity?: number;
84
+ /** Full stop list — takes precedence over start/end colors when non-empty */
85
+ stops?: TopologyRadialGradientStop[];
86
+ }
87
+
66
88
  export interface TopologyConfig {
67
89
  selectedBorderColor?: string;
68
90
  selectedLineColor?: string;
@@ -73,10 +95,18 @@ export interface TopologyConfig {
73
95
  enableMarquee?: boolean;
74
96
  showGrid?: boolean;
75
97
  gridColor?: string;
98
+ /** Grid cell size in px at 1x zoom (default 40); scales with zoom */
99
+ gridStep?: number;
100
+ /** Grid overlay opacity 0-1 (default 0.5) */
101
+ gridOpacity?: number;
102
+ /** Canvas background radial gradient (colors + optional geometry / stops) */
103
+ radialGradient?: TopologyRadialGradientConfig;
76
104
  showCenterPoint?: boolean;
77
105
  showEdgeTextBg?: boolean;
78
106
  edgeTextBgColor?: string;
79
107
  showNodeHandles?: boolean;
108
+ /** Status dot at each node's top-right corner (shown by default) */
109
+ showStatusDot?: boolean;
80
110
  watchDataChanges?: boolean;
81
111
  }
82
112
 
@@ -119,6 +149,16 @@ export interface TopologyExposed {
119
149
  getData(): TopologyData;
120
150
  /** Snapshot the current data as the new change-tracking baseline. */
121
151
  resetDataBaseline(): void;
152
+ /**
153
+ * Replace the whole dataset from outside (restore a snapshot / load a new
154
+ * graph): clears in-component bookkeeping (locally created edges, removal
155
+ * tombstones, field patches), clears the selection and re-arms change
156
+ * tracking. Pass `{ nodes }` to have the component adopt & publish them
157
+ * (keeps a v-model parent in sync); omit it to re-sync from current props.
158
+ * Edges always render from the parent's `edges` array — update that array
159
+ * as part of the same operation. Returns a deep copy of the new data.
160
+ */
161
+ setData(data?: { nodes?: TopologyNode[] }): TopologyData;
122
162
  /** Remove the current selection; node deletion cascades to its edges. */
123
163
  removeSelected(): TopologyData;
124
164
  /** Append nodes (missing ids are auto-generated; existing ids skipped). */