wechen-agent-editor-v1 1.3.2 → 1.3.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/README.md +130 -14
- package/dist/WechenAgentEditor.d.ts +11 -1
- package/dist/WechenAgentEditor.d.ts.map +1 -1
- package/dist/WechenAgentEditorContext.d.ts +8 -0
- package/dist/WechenAgentEditorContext.d.ts.map +1 -1
- package/dist/flow/deleteGuard.d.ts +24 -7
- package/dist/flow/deleteGuard.d.ts.map +1 -1
- package/dist/flow/flowOperationEvents.d.ts +37 -0
- package/dist/flow/flowOperationEvents.d.ts.map +1 -0
- package/dist/flow/nodeMoveGate.d.ts +11 -0
- package/dist/flow/nodeMoveGate.d.ts.map +1 -0
- package/dist/flow/nodeShellPatch.d.ts +14 -0
- package/dist/flow/nodeShellPatch.d.ts.map +1 -0
- package/dist/flow/selectionToolbar/SelectionToolbar.d.ts.map +1 -1
- package/dist/flowTypes.d.ts +36 -0
- package/dist/flowTypes.d.ts.map +1 -1
- package/dist/hostEditorConfig.d.ts +1 -0
- package/dist/hostEditorConfig.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10441 -10105
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
**包名**:以 `package.json` 的 `name` 为准(`wechen-agent-editor-v1`)。安装与 `import` 均使用该名称。
|
|
6
6
|
|
|
7
|
+
**当前发布版本**:**1.3.2**(变更见 [CHANGELOG.md](CHANGELOG.md))。发版前自检见文末 [维护者:发版](#维护者发版)。
|
|
8
|
+
|
|
7
9
|
> **宿主集成必读**:本包 **`dependencies` 为空**,运行时能力全部来自 **peerDependencies**。除 `npm install wechen-agent-editor-v1` 外,须在**业务工程根目录**一并安装 **`react` / `react-dom` / `antd` / `@xyflow/react` / `dagre` / `monaco-editor` / `@monaco-editor/react`**(见下文 [安装](#安装))。缺任一项会导致画布空白、连线失效、自动排版失败或 Monaco 无法加载。
|
|
8
10
|
|
|
11
|
+
**文档导航**:[能力地图](docs/CAPABILITY-MAP.md)(props / ref / 图操作 / 数据)· [集成阶梯 L0–L3](docs/HOST-INTEGRATION-LADDER.md) · [工程基线](docs/ENGINEERING-BASELINE.md) · Playground 默认 [`?tab=overview`](playground/README.md)
|
|
12
|
+
|
|
9
13
|
## 快速开始
|
|
10
14
|
|
|
11
15
|
### 60 秒最小集成(L0)
|
|
@@ -148,7 +152,10 @@ const flow = importBackendWorkflowToFlow(dtoFromApi);
|
|
|
148
152
|
// <WechenAgentEditor initialFlow={flow} />
|
|
149
153
|
```
|
|
150
154
|
|
|
151
|
-
本仓库 **playground**
|
|
155
|
+
本仓库 **playground** 提供对照:
|
|
156
|
+
|
|
157
|
+
- **`npm run dev`**:文档站(侧栏能力 Tab + **仓库文档** `?tab=repo-docs` + 分栏独立滚动;默认 `?tab=overview`),见 [playground/README.md](playground/README.md)。
|
|
158
|
+
- **`npm run dev:minimal`**:仅最小宿主集成(对照上文「60 秒最小集成」)。
|
|
152
159
|
|
|
153
160
|
### 编辑器与 Agent 运行时
|
|
154
161
|
|
|
@@ -160,7 +167,7 @@ WechenAgentEditor(编排) → onSave / exportBackendWorkflowJson → 宿主
|
|
|
160
167
|
|
|
161
168
|
- **`onTestRun` / `ref.testRun()`**:仅触发宿主回调,具体执行由宿主实现。
|
|
162
169
|
- **`validateWechenAgentFlow(flow)`**:纯函数图校验(默认不阻断保存);可在 `onBeforeSave` 内返回 `false` 拦截。
|
|
163
|
-
- **ref 增删改查**:`getSnapshot` / **`getFlow` / `getInitialFlow
|
|
170
|
+
- **ref 增删改查**:`getSnapshot` / **`getFlow` / `getInitialFlow`** / **`getNode` / `getEdge`** / **`replaceFlow` / `setInitialFlow`** / **`patchNodeData`(`node.data`)** / **`patchNode` / `setNodePosition`(坐标与壳层)** / **`setTitle`** / `removeNode` / **`duplicateNode`** / **`removeEdge` / `deleteEdge`** / 路径与布局 ref 等(见 `WechenAgentEditorRef`、Playground **`?tab=ref-api`**)。
|
|
164
171
|
- **连线路径(自由折线)**:选中边后浮动条「添加拐点」;仅 **中间拐点** 可拖拽(任意角度线段),首尾随节点桩固定;**水平/垂直线段** 可整条平移(鼠标移到线段上,光标变为 ↔ 或 ↕);`Delete` 在顶点选中时删点。`normalizeWechenAgentFlowJson` 会清除无效 `path` 并回到 `auto`。
|
|
165
172
|
- **选中浮动操作条**:单选节点时显示 **删除 / 复制**;单选边时显示 **删除**、**添加/删除拐点**、手动边 **恢复自动路径**。与边上 **路径顶点手柄**(几何编辑)分工;浮动条锚点在路径外侧,避免压住连线与节点。`readOnly` / `readingMode` / 多选时不显示。可选 **`renderSelectionToolbar`** 扩展。
|
|
166
173
|
- **布局相关 ref**(`readOnly` / `readingMode` 下均为 no-op):
|
|
@@ -235,6 +242,8 @@ npm install wechen-agent-editor-v1 react react-dom antd @xyflow/react dagre mona
|
|
|
235
242
|
|
|
236
243
|
自 **1.2.3** 起 **`@xyflow/react`**、**`dagre`** 由 **peer** 提供(不再随本包内嵌)。自 **1.0.x** 起 **`react` / `antd` / `monaco-*`** 即为 peer。升级自内嵌 Flow 的旧版时,请务必在宿主根目录 **新增** `@xyflow/react` 与 `dagre` 依赖。
|
|
237
244
|
|
|
245
|
+
自 **1.3.2** 起推荐用 **`onFlowOperation`** 统一图操作策略(替代仅覆盖删除的 `onBeforeRemove*`);**peer 清单无变化**,从 **1.3.0** 升级通常只需 bump 版本并回归构建与画布烟测。
|
|
246
|
+
|
|
238
247
|
**不要**再依赖本包 tarball 内自带的 `@xyflow/react`(历史 `bundledDependencies` 已移除)。宿主与编辑器 **必须** `npm ls @xyflow/react` 仅一棵有效树。
|
|
239
248
|
|
|
240
249
|
安装后建议自检:
|
|
@@ -266,7 +275,7 @@ npm 7+ 会校验整棵依赖树的 peer。冲突常来自宿主已有包,未
|
|
|
266
275
|
"monaco-editor": "^0.45.0",
|
|
267
276
|
"react": "^18.3.0",
|
|
268
277
|
"react-dom": "^18.3.0",
|
|
269
|
-
"wechen-agent-editor-v1": "^1.3.
|
|
278
|
+
"wechen-agent-editor-v1": "^1.3.2"
|
|
270
279
|
}
|
|
271
280
|
}
|
|
272
281
|
```
|
|
@@ -451,7 +460,9 @@ validateLocaleMessagesCompleteness(enPack);
|
|
|
451
460
|
- **`readOnly`**:禁止对图的增删改(组件库拖入、连线、删除键、拖动节点、选中浮动条、`ref.removeNode` / `patchNodeData` 等),仍可使用平移/缩放查看,**可点选节点/边** 在右侧只读查看配置。**`readOnly`** 与 **`readingMode`** 会出现在 **`renderConfigPanel` / `renderNodeConfig`** 的入参中。
|
|
452
461
|
- **`readingMode`**:**仅展示中间流程画布**(隐藏顶栏与左右栏),并**禁用选中**与一切改图,适合文档内嵌、大屏预览等纯展示场景(隐含只读)。根节点会附加 **`wechen-agent-editor--reading`**。
|
|
453
462
|
|
|
454
|
-
### 删除守卫(`onBeforeRemoveNode` / `onBeforeRemoveEdge
|
|
463
|
+
### 删除守卫(`onBeforeRemoveNode` / `onBeforeRemoveEdge`)— **@deprecated**
|
|
464
|
+
|
|
465
|
+
> **新集成请用** 下文 **[图操作事件(`onFlowOperation`)](#图操作事件onflowoperation)**。本 API 仅覆盖删除;与 `onFlowOperation` 同时传入时 **事件优先**。迁移见 [docs/CAPABILITY-MAP.md](docs/CAPABILITY-MAP.md)。
|
|
455
466
|
|
|
456
467
|
在可编辑模式下,可通过回调 **按节点/边粒度** 决定是否允许删除。同步返回 **`false`** 时取消该次删除(**Backspace** 与 **`ref.removeNode` / `ref.removeEdge`** 均生效)。**`readOnly` / `readingMode`** 下不调用回调。删除节点时 **级联移除** 的关联边 **不会** 逐条触发 `onBeforeRemoveEdge`。
|
|
457
468
|
|
|
@@ -469,6 +480,39 @@ validateLocaleMessagesCompleteness(enPack);
|
|
|
469
480
|
|
|
470
481
|
L1 工厂同样支持:`buildWechenAgentEditorProps({ onBeforeRemoveNode: ... })`。
|
|
471
482
|
|
|
483
|
+
### 图操作事件(`onFlowOperation`)
|
|
484
|
+
|
|
485
|
+
在可编辑模式下,**删/复制/新增/连线/patch/路径重置** 等改图操作在应用前会派发 **`WechenFlowOperationEvent`**。宿主在 **`onFlowOperation`** 中按 **`event.kind`**(如 `node.remove`、`node.duplicate`、`edge.add`)与 **`event.node` / `event.edge`** 返回 **`false`** 即可取消该次操作(键盘、浮动条、ref 路径一致)。**`onFlowOperation` 对 `node.remove` / `edge.remove` 优先于** `onBeforeRemoveNode` / `onBeforeRemoveEdge`。**`readOnly` / `readingMode`** 下不调用。
|
|
486
|
+
|
|
487
|
+
拒绝 **`node.remove`** 时,编辑器会 **原子取消** 该次删节点操作:节点保留,且 **不会** 因该次键盘/ref 删除而连带移除关联边(级联删边 **不** 单独派发 `edge.remove`)。宿主 **只需** 拦截 `node.remove` / `node.duplicate` 等,**不必** 为级联边再返回 `edge.remove: false`。显式选中边后删除仍走 **`edge.remove`** 门控。
|
|
488
|
+
|
|
489
|
+
| `kind`(节选) | 含义 |
|
|
490
|
+
|----------------|------|
|
|
491
|
+
| `node.remove` | 删除节点 |
|
|
492
|
+
| `node.duplicate` | 复制节点 |
|
|
493
|
+
| `node.add` | 新增节点(拖库、ref) |
|
|
494
|
+
| `node.patch` | 补丁 `node.data` |
|
|
495
|
+
| `edge.remove` | 删除边 |
|
|
496
|
+
| `edge.add` | 新建连线 |
|
|
497
|
+
| `edge.reconnect` | 重连连线 |
|
|
498
|
+
| `edge.patch` | 补丁边 |
|
|
499
|
+
| `edge.path.reset` | 恢复自动路径 |
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
<WechenAgentEditor
|
|
503
|
+
onFlowOperation={(event) => {
|
|
504
|
+
if (event.node?.type === "pill") {
|
|
505
|
+
if (event.kind === "node.remove" || event.kind === "node.duplicate") {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return true;
|
|
510
|
+
}}
|
|
511
|
+
/>
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
Playground:`?tab=flow-operation-policy`。L1:`buildWechenAgentEditorProps({ onFlowOperation: ... })`。
|
|
515
|
+
|
|
472
516
|
### 顶底感应区连线(默认,上进下出)
|
|
473
517
|
|
|
474
518
|
内置 **`pill` / `card` / `mainAgent`** 在未使用 **`renderFlowNode`**、且未启用下文 **legacy `flowHandles`** 时,采用 **顶 / 底** 周界窄条:**输入池 = 顶边**(`target`)、**输出池 = 底边**(`source`),符合 Agent **自上而下** 阅读;多条入/出边沿顶/底边按邻居 **水平坐标** 分列槽位;**整条感应条**均可拖拽拉出连线(十字光标),几何锚点仍在 **条带中心** stub。新建连接桩:**`in-new-top-{nodeId}`**(顶)、**`out-new-bottom-{nodeId}`**(底)。透明 **`Handle`**、无固定圆点桩 UI。新边 **`sourceHandle` / `targetHandle`** 仍为 **`out-${edgeId}`** / **`in-${edgeId}`**;**`normalizeWechenAgentFlowJson`** 归一化旧桩 id。新建连线写入 **`edge.data.wechenSourceAttachSide` / `wechenTargetAttachSide`**(默认 **底→顶**)。旧图 **`left`/`right`** 锚边在加载/同步时迁移为 **`top`/`bottom`**。**`ConnectionMode.Strict`**、**`isValidConnection`**(禁自环)。默认边 **平滑阶梯 + 终点箭头**(箭头在 **target** 端)。与 **`autoLayoutNodes` / `relayoutEdges`**、底边扇出 **共干** 路径配合。
|
|
@@ -531,7 +575,7 @@ const libraryGroups = [
|
|
|
531
575
|
- **数据合并**:节点 `data` 的更新遵循导出的 **`mergeNodeData`**(对象深度合并,数组在补丁中出现时整段替换)。详见下文 **[`patchNode` 与 `patchNodeData`](#patchnode-与-patchnodedata)**。
|
|
532
576
|
- **自定义右侧面板**:可选 **`renderConfigPanel`**(节点与连线统一入口)或 **`renderNodeConfig`**;同时存在时以 `renderConfigPanel` 为准(返回 `undefined` 时回退内置)。
|
|
533
577
|
|
|
534
|
-
### `
|
|
578
|
+
### `patchNodeData` 与配置区 `ctx.patchNode`
|
|
535
579
|
|
|
536
580
|
二者语义一致:把 **`patch` 深度合并进 `node.data`**(内部为 **`mergeNodeData`**)。区别仅在于 **是否由调用方传入节点 id**(右栏已选中节点时,id 由编辑器绑定)。
|
|
537
581
|
|
|
@@ -539,10 +583,46 @@ const libraryGroups = [
|
|
|
539
583
|
|-----|------|----------|
|
|
540
584
|
| **`ctx.patchNode`** | `(patch) => void` | **`renderConfigPanel`** 选中节点时;**勿传 `node.id`**,当前节点已固定 |
|
|
541
585
|
| **`ctx.editorRef`** | `RefObject<WechenAgentEditorRef \| null>` | **`renderConfigPanel`** 节点/边共有;内部 API,**无需** 宿主挂 `ref`,在事件内读 `current` |
|
|
542
|
-
| **`ref.patchNodeData`** | `(nodeId, patch) => void` |
|
|
586
|
+
| **`ref.patchNodeData`** | `(nodeId, patch) => void` | 命令式改 **`node.data`**(按钮、自动化、跨节点批量) |
|
|
543
587
|
|
|
544
588
|
**`patch` 的顶层键 = `node.data` 的键**,不是整颗 React Flow `Node`(不含 `id` / `type` / `position` / `measured` 等)。
|
|
545
589
|
|
|
590
|
+
### ref:节点坐标与壳层(`patchNode` / `setNodePosition`)
|
|
591
|
+
|
|
592
|
+
| API | 作用 |
|
|
593
|
+
|-----|------|
|
|
594
|
+
| **`ref.getNode(id)`** / **`ref.getEdge(id)`** | 按 id 读取当前实体(浅拷贝) |
|
|
595
|
+
| **`ref.setNodePosition(id, { x, y })`** | 只改 **`node.position`**(等同 `patchNode(id, { position })`) |
|
|
596
|
+
| **`ref.patchNode(id, patch)`** | 改 **`position` / `type` / `width` / `height`**;**勿** 用来写 `data` |
|
|
597
|
+
| **`ref.setTitle(title)`** | 只改标题,不替换整图 |
|
|
598
|
+
|
|
599
|
+
**对称读写示例**(无需 `replaceFlow` 整图替换坐标):
|
|
600
|
+
|
|
601
|
+
```tsx
|
|
602
|
+
const flow = editorRef.current?.getFlow();
|
|
603
|
+
const n = flow?.nodes.find((x) => x.id === "my-node");
|
|
604
|
+
if (n) {
|
|
605
|
+
editorRef.current?.setNodePosition("my-node", { x: n.position.x + 80, y: n.position.y });
|
|
606
|
+
}
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
程序化改坐标会经 **`onFlowOperation`** 的 **`node.patch`**(`source: ref`);与 **`patchNodeData`** 的 data 补丁区分。
|
|
610
|
+
|
|
611
|
+
### ref 实例 vs 包导出(常见误找)
|
|
612
|
+
|
|
613
|
+
下列能力 **不在** `editorRef.current` 上,需从包 **直接 import**(完整对照见 [docs/EDITOR-REF-API-MATRIX.md](docs/EDITOR-REF-API-MATRIX.md)):
|
|
614
|
+
|
|
615
|
+
| 需求 | 用法 |
|
|
616
|
+
|------|------|
|
|
617
|
+
| 后端 DTO 导出/导入 | `exportBackendWorkflowJson` / `importBackendWorkflowToFlow` → 再 `ref.replaceFlow` |
|
|
618
|
+
| 图合法性校验 | `validateWechenAgentFlow(ref.getFlow())` |
|
|
619
|
+
| 克隆/解析 JSON | `cloneWechenAgentFlow` / `parseWechenAgentFlowJson` |
|
|
620
|
+
| 边端点交换补丁 | `swapWechenFlowEdgeEndpoints` → `ref.patchEdge` |
|
|
621
|
+
| 画布 **重连** | `ref.reconnectEdge(edgeId, connection)`(同 UI `onReconnect`) |
|
|
622
|
+
| 拖动 **门控** | `onFlowOperation` **`node.move`**(拖放结束;拒绝则回滚坐标) |
|
|
623
|
+
| 聚焦节点 | `ref.centerOnNode(nodeId)` |
|
|
624
|
+
| 校验当前图 | `ref.validateFlow()` |
|
|
625
|
+
|
|
546
626
|
```
|
|
547
627
|
node = { id, type, position, data: { label, config, … } }
|
|
548
628
|
▲
|
|
@@ -709,6 +789,8 @@ Playground **`renderConfigPanel`** Tab 中 `card` / 边配置演示了该流程
|
|
|
709
789
|
| 烟测 | 拖入节点、连线、`readOnly` / `readingMode`、保存或 `getSnapshot`;边路径添加拐点/拖顶点 |
|
|
710
790
|
| ref 增图 | `ref.addNodeFromLibrary` / `ref.connect` 与拖放、连线行为一致 |
|
|
711
791
|
| DTO 往返 | `exportBackendWorkflowJson` → `importBackendWorkflowToFlow` → `replaceFlow`;`condition`/`api`/`script` 经 `data.backendNodeType` |
|
|
792
|
+
| 图操作门控 | **`onFlowOperation`**:拒 `node.remove` 时节点与级联边均保留(Playground `?tab=flow-operation-policy`) |
|
|
793
|
+
| ref 坐标回写 | **`getFlow` 读 position** → **`setNodePosition` 写 position**(`?tab=ref-api`) |
|
|
712
794
|
| 图校验 | `validateWechenAgentFlow`;可选 `onBeforeSave` 拦截 |
|
|
713
795
|
|
|
714
796
|
---
|
|
@@ -721,9 +803,16 @@ npm install --prefix playground
|
|
|
721
803
|
npm run dev # Playground 文档站(分 Tab 演示;ref 全表见 ?tab=ref-api,见 playground/README.md)
|
|
722
804
|
npm run dev:minimal # 仅最小宿主集成(对照 README「快速开始」)
|
|
723
805
|
npm run baseline # 工程基线:测试数、最大 LOC、dist 体积(见 docs/ENGINEERING-BASELINE.md)
|
|
806
|
+
npm test # Vitest(含 flowOperation / deleteGuard 表驱动与 editorGateSmoke)
|
|
807
|
+
npm run typecheck
|
|
808
|
+
npm run check:docs # 文档覆盖 WARN(onFlowOperation kind ↔ README)
|
|
809
|
+
npm run release:prep # 发版门禁:test + build + pack:check + playground build + baseline
|
|
810
|
+
npm run verify:change # 可选:test + typecheck + audit:white-screen(见 docs/ENGINEERING-BASELINE.md)
|
|
724
811
|
```
|
|
725
812
|
|
|
726
|
-
|
|
813
|
+
**门控冒烟**(无 DOM):`src/flow/editorGateSmoke.test.ts` — 验证 `onFlowOperation` 拒删 pill 时级联边过滤;已包含在 `npm test` / `release:prep`。
|
|
814
|
+
|
|
815
|
+
浏览器地址以终端输出为准(默认 `http://localhost:5173`)。文档站默认 **`?tab=overview`**。
|
|
727
816
|
|
|
728
817
|
---
|
|
729
818
|
|
|
@@ -733,24 +822,51 @@ npm run baseline # 工程基线:测试数、最大 LOC、dist 体积
|
|
|
733
822
|
|
|
734
823
|
| 版本 | 宿主需注意 |
|
|
735
824
|
|------|------------|
|
|
825
|
+
| **1.3.2** | **`onFlowOperation`** 统一图操作门控;拒 `node.remove` 时级联边原子保留;legacy 边/只读/配置区白屏加固;**peer 同 1.3.0** |
|
|
736
826
|
| **1.3.0** | 自由折线路径编辑、选中浮动条、路径 ref;**peer 要求同 1.2.3** |
|
|
737
827
|
| **1.2.3** | **Breaking(集成)**:`@xyflow/react`、`dagre` 改为 peer,须宿主显式安装 |
|
|
738
828
|
| **1.1.x** | `buildWechenAgentEditorProps`、后端 DTO、删除守卫等 |
|
|
739
829
|
|
|
740
830
|
完整变更见 **`CHANGELOG.md`**。
|
|
741
831
|
|
|
742
|
-
###
|
|
832
|
+
### 发版清单(1.3.2)
|
|
833
|
+
|
|
834
|
+
1. **版本号**:确认根目录 `package.json` **`version`** 为 **`1.3.2`**(npm 以该字段为准;README / CHANGELOG 已对齐)。
|
|
835
|
+
2. **依赖与锁文件**:`npm install`;若改过 `playground/`,执行 `npm install --prefix playground`。
|
|
836
|
+
3. **门禁**(推荐一条命令):
|
|
837
|
+
|
|
838
|
+
```bash
|
|
839
|
+
npm run release:prep
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
等价分步:`npm test` → `npm run build` → `npm run pack:check` → `npm --prefix playground run build` → `npm run baseline`(基线摘要)。可选加强:`npm run verify:change`(含 `audit:white-screen`)、`npm run check:docs`。
|
|
843
|
+
|
|
844
|
+
日志写入 **`.release-check.log`**(`release:prep` 脚本)。
|
|
743
845
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
846
|
+
4. **登录 registry**:`npm whoami`(`registry.npmjs.org`);国内镜像发版用 **`npm run release:cn`**(勿与 npmjs 混用同一 token 流程 unless intentional)。
|
|
847
|
+
5. **发布**:
|
|
848
|
+
|
|
849
|
+
```bash
|
|
850
|
+
npm run release
|
|
851
|
+
# 或:npm publish --access public --registry=https://registry.npmjs.org/
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
6. **发后验证**:
|
|
748
855
|
|
|
749
856
|
```bash
|
|
750
857
|
npm view wechen-agent-editor-v1 version
|
|
751
|
-
npm pack --dry-run #
|
|
858
|
+
npm pack --dry-run # tarball 应仅含 dist/、LICENSE(见 package.json files)
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
7. **空目录烟测**(将 `<version>` 换为 `package.json` 中的版本):
|
|
862
|
+
|
|
863
|
+
```bash
|
|
864
|
+
mkdir /tmp/wechen-smoke && cd /tmp/wechen-smoke
|
|
865
|
+
npm init -y
|
|
866
|
+
npm install wechen-agent-editor-v1@<version> react react-dom antd @xyflow/react dagre monaco-editor @monaco-editor/react
|
|
867
|
+
node -e "import('wechen-agent-editor-v1').then(m => console.log('ok', typeof m.WechenAgentEditor))"
|
|
752
868
|
```
|
|
753
869
|
|
|
754
|
-
|
|
870
|
+
8. **Git 标签(建议)**:`git tag v1.3.2 && git push origin v1.3.2`(按团队规范)。
|
|
755
871
|
|
|
756
872
|
发版前可将 `repository` / `bugs` / `homepage` 中的占位 URL 换成真实仓库地址(私有仓库可仅在内部文档记录,见「集成排错」说明)。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { ComponentLibraryGroup, WechenAgentComponentLibraryList } from './config/componentLibraryConfig';
|
|
3
3
|
import { WechenAgentRenderSelectionToolbarFn, WechenSelectionToolbarSlot } from './flow/selectionToolbar/SelectionToolbar';
|
|
4
|
-
import { WechenAgentEditorRef, WechenAgentFlowJson, WechenAgentHeaderActionsRenderContext, WechenAgentHeaderLeadingRenderContext, WechenAgentSnapshot, WechenBeforeRemoveEdgeFn, WechenBeforeRemoveNodeFn, WechenBeforeSaveFn } from './flowTypes';
|
|
4
|
+
import { WechenAgentEditorRef, WechenAgentFlowJson, WechenAgentHeaderActionsRenderContext, WechenAgentHeaderLeadingRenderContext, WechenAgentSnapshot, WechenBeforeRemoveEdgeFn, WechenBeforeRemoveNodeFn, WechenBeforeSaveFn, WechenOnFlowOperationFn } from './flowTypes';
|
|
5
5
|
import { WechenAgentRenderFlowNodeFn } from './WechenAgentEditorContext';
|
|
6
6
|
import { WechenAgentRenderNodeConfigFn } from './panels/NodeConfigPanel';
|
|
7
7
|
import { WechenAgentRenderConfigPanelFn } from './wechenAgentConfigPanel';
|
|
@@ -71,11 +71,15 @@ export interface WechenAgentEditorProps {
|
|
|
71
71
|
* 删除节点前回调;同步返回 **`false`** 时取消该次删除(键盘 Backspace 与 `ref.removeNode` 均生效)。
|
|
72
72
|
* 删除节点时 **级联移除** 的关联边 **不会** 逐条触发 `onBeforeRemoveEdge`。
|
|
73
73
|
* `readOnly` / `readingMode` 下 **不调用** 本回调。
|
|
74
|
+
*
|
|
75
|
+
* @deprecated 请改用 **`onFlowOperation`**(`kind: "node.remove"`)。见 README 与 `docs/CAPABILITY-MAP.md`。
|
|
74
76
|
*/
|
|
75
77
|
onBeforeRemoveNode?: WechenBeforeRemoveNodeFn;
|
|
76
78
|
/**
|
|
77
79
|
* 删除边前回调;同步返回 **`false`** 时取消该次删除(键盘与 `ref.removeEdge` 均生效)。
|
|
78
80
|
* `readOnly` / `readingMode` 下 **不调用** 本回调。
|
|
81
|
+
*
|
|
82
|
+
* @deprecated 请改用 **`onFlowOperation`**(`kind: "edge.remove"`)。见 README 与 `docs/CAPABILITY-MAP.md`。
|
|
79
83
|
*/
|
|
80
84
|
onBeforeRemoveEdge?: WechenBeforeRemoveEdgeFn;
|
|
81
85
|
/**
|
|
@@ -83,6 +87,12 @@ export interface WechenAgentEditorProps {
|
|
|
83
87
|
* `readOnly` / `readingMode` 下 **不调用**。
|
|
84
88
|
*/
|
|
85
89
|
onBeforeSave?: WechenBeforeSaveFn;
|
|
90
|
+
/**
|
|
91
|
+
* 图操作统一门控:删/复制/新增/连线/patch 等改图前派发事件;返回 **`false`** 取消。
|
|
92
|
+
* 对 `node.remove` / `edge.remove` **优先于** `onBeforeRemoveNode` / `onBeforeRemoveEdge`。
|
|
93
|
+
* `readOnly` / `readingMode` 下 **不调用**。
|
|
94
|
+
*/
|
|
95
|
+
onFlowOperation?: WechenOnFlowOperationFn;
|
|
86
96
|
/**
|
|
87
97
|
* 为真时禁止对图的增删改(拖入、连线、删除键、拖动节点等);仍允许平移/缩放。
|
|
88
98
|
* 标志会传入 `renderConfigPanel` / `renderNodeConfig` 便于禁用表单。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WechenAgentEditor.d.ts","sourceRoot":"","sources":["../src/WechenAgentEditor.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAcjE,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAChC,MAAM,iCAAiC,CAAC;AAYzC,OAAO,KAAK,EACV,mCAAmC,EACnC,0BAA0B,EAC3B,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"WechenAgentEditor.d.ts","sourceRoot":"","sources":["../src/WechenAgentEditor.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAcjE,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAChC,MAAM,iCAAiC,CAAC;AAYzC,OAAO,KAAK,EACV,mCAAmC,EACnC,0BAA0B,EAC3B,MAAM,0CAA0C,CAAC;AAmDlD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,qCAAqC,EACrC,qCAAqC,EACrC,mBAAmB,EAEnB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAElB,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAK/E,OAAO,KAAK,EACV,+BAA+B,EAC/B,kCAAkC,EACnC,MAAM,8BAA8B,CAAC;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E,kBAAkB,CAAC;IAClC;;;;OAIG;IACH,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,+BAA+B,CAAC;IACjD,kEAAkE;IAClE,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,GAAG,wBAAwB,CAAC;CACtD;AAED,YAAY,EACV,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,8BAA8B,CAAC;AAo8CtC,eAAO,MAAM,iBAAiB,yHAiG7B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeProps } from '@xyflow/react';
|
|
2
2
|
import { ReactNode, RefObject } from 'react';
|
|
3
3
|
import { WechenAgentEditorRef } from './flowTypes';
|
|
4
|
+
import { WechenFlowOperationKind } from './flow/flowOperationEvents';
|
|
4
5
|
import { WechenAgentRenderSelectionToolbarFn, WechenSelectionToolbarSlot } from './flow/selectionToolbar/SelectionToolbar';
|
|
5
6
|
export type WechenAgentRenderFlowNodeContext = {
|
|
6
7
|
/** 当前节点是否被画布选中(与 NodeProps.selected 一致) */
|
|
@@ -21,6 +22,11 @@ export type WechenAgentRenderFlowNodeContext = {
|
|
|
21
22
|
*/
|
|
22
23
|
/** `props.type` 为落盘 `node.type`(= `item.type`),非 `item.key` */
|
|
23
24
|
export type WechenAgentRenderFlowNodeFn = (props: NodeProps, context: WechenAgentRenderFlowNodeContext) => ReactNode;
|
|
25
|
+
export type CanPerformFlowOperationFn = (kind: WechenFlowOperationKind, partial: {
|
|
26
|
+
source: import('./flow/flowOperationEvents').WechenFlowOperationSource;
|
|
27
|
+
node?: import('@xyflow/react').Node;
|
|
28
|
+
edge?: import('@xyflow/react').Edge;
|
|
29
|
+
}) => boolean;
|
|
24
30
|
export interface WechenAgentEditorRenderContextValue {
|
|
25
31
|
/** 自定义节点内容区;未设置时使用内置默认字段块 */
|
|
26
32
|
renderFlowNode?: WechenAgentRenderFlowNodeFn;
|
|
@@ -32,6 +38,8 @@ export interface WechenAgentEditorRenderContextValue {
|
|
|
32
38
|
canvasEditable: boolean;
|
|
33
39
|
/** 编辑器命令式 ref,供默认节点调用宿主 `renderFlowNode` 时传入 context */
|
|
34
40
|
editorRef: RefObject<WechenAgentEditorRef | null>;
|
|
41
|
+
/** 预判某操作是否允许(与 `onFlowOperation` 策略一致) */
|
|
42
|
+
canPerformFlowOperation?: CanPerformFlowOperationFn;
|
|
35
43
|
}
|
|
36
44
|
export declare const WechenAgentEditorRenderContext: import('react').Context<WechenAgentEditorRenderContextValue | null>;
|
|
37
45
|
export declare function useWechenAgentEditorRender(): WechenAgentEditorRenderContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WechenAgentEditorContext.d.ts","sourceRoot":"","sources":["../src/WechenAgentEditorContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EACV,mCAAmC,EACnC,0BAA0B,EAC3B,MAAM,0CAA0C,CAAC;AAElD,MAAM,MAAM,gCAAgC,GAAG;IAC7C,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,oCAAoC;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uCAAuC;IACvC,cAAc,C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C;AAEF;;;;GAIG;AACH,+DAA+D;AAC/D,MAAM,MAAM,2BAA2B,GAAG,CACxC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,gCAAgC,KACtC,SAAS,CAAC;AAEf,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE;IACP,MAAM,EAAE,OAAO,4BAA4B,EAAE,yBAAyB,CAAC;IACvE,IAAI,CAAC,EAAE,OAAO,eAAe,EAAE,IAAI,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,eAAe,EAAE,IAAI,CAAC;CACrC,KACE,OAAO,CAAC;AAEb,MAAM,WAAW,mCAAmC;IAClD,6BAA6B;IAC7B,cAAc,CAAC,EAAE,2BAA2B,CAAC;IAC7C,qCAAqC;IACrC,sBAAsB,CAAC,EAAE,mCAAmC,CAAC;IAC7D,oCAAoC;IACpC,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;IAClD,iCAAiC;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,SAAS,EAAE,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAClD,0CAA0C;IAC1C,uBAAuB,CAAC,EAAE,yBAAyB,CAAC;CACrD;AAED,eAAO,MAAM,8BAA8B,qEACsB,CAAC;AASlE,wBAAgB,0BAA0B,IAAI,mCAAmC,CAEhF"}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { Edge, EdgeChange, Node, NodeChange } from '@xyflow/react';
|
|
2
2
|
import { WechenBeforeRemoveEdgeFn, WechenBeforeRemoveNodeFn } from '../flowTypes';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { buildFlowOperationEvent, FlowOperationGateContext, WechenFlowOperationSource } from './flowOperationEvents';
|
|
4
|
+
/** 选中态与「本批已拒 node.remove」——用于级联 edge.remove 过滤 */
|
|
5
|
+
export type DeleteGuardCascadeContext = {
|
|
6
|
+
nodes: ReadonlyArray<Node>;
|
|
7
|
+
selectedNodeId?: string | null;
|
|
8
|
+
selectedEdgeId?: string | null;
|
|
9
|
+
/** 同一次 `onNodesChange` 批内被拒绝的 node id(RF 先节点后边时) */
|
|
10
|
+
deniedNodeRemoveIds?: ReadonlySet<string>;
|
|
11
|
+
};
|
|
12
|
+
/** 从节点变更批中收集将被 `node.remove` 守卫拒绝的 id */
|
|
13
|
+
export declare function collectDeniedNodeRemoveIds(changes: NodeChange[], nodes: ReadonlyArray<Node>, gate?: FlowOperationGateContext | WechenBeforeRemoveNodeFn): Set<string>;
|
|
14
|
+
/**
|
|
15
|
+
* 级联删边:因删除节点而连带移除的边,不单独走 edge.remove。
|
|
16
|
+
* 当端点 node.remove 被拒绝且边非显式删除目标时,应丢弃该 edge remove 变更。
|
|
17
|
+
*/
|
|
18
|
+
export declare function isCascadeEdgeRemoveBlocked(edge: Edge, nodes: ReadonlyArray<Node>, gate: FlowOperationGateContext, cascade: DeleteGuardCascadeContext, source?: WechenFlowOperationSource): boolean;
|
|
19
|
+
/** 是否允许删除指定节点(无回调或节点不存在时按 allow 处理)。 */
|
|
20
|
+
export declare function canRemoveNode(nodeId: string, nodes: ReadonlyArray<Node>, gate?: FlowOperationGateContext | WechenBeforeRemoveNodeFn, source?: WechenFlowOperationSource): boolean;
|
|
5
21
|
/** 是否允许删除指定边。 */
|
|
6
|
-
export declare function canRemoveEdge(edgeId: string, edges: ReadonlyArray<Edge>,
|
|
7
|
-
/** 过滤 `onNodesChange` 中被守卫拒绝的 `remove`
|
|
8
|
-
export declare function filterRemoveNodeChanges(changes: NodeChange[], nodes: ReadonlyArray<Node>,
|
|
9
|
-
/** 过滤 `onEdgesChange` 中被守卫拒绝的 `remove`
|
|
10
|
-
export declare function filterRemoveEdgeChanges(changes: EdgeChange[], edges: ReadonlyArray<Edge>,
|
|
22
|
+
export declare function canRemoveEdge(edgeId: string, edges: ReadonlyArray<Edge>, gate?: FlowOperationGateContext | WechenBeforeRemoveEdgeFn, source?: WechenFlowOperationSource): boolean;
|
|
23
|
+
/** 过滤 `onNodesChange` 中被守卫拒绝的 `remove` 项。 */
|
|
24
|
+
export declare function filterRemoveNodeChanges(changes: NodeChange[], nodes: ReadonlyArray<Node>, gate?: FlowOperationGateContext | WechenBeforeRemoveNodeFn): NodeChange[];
|
|
25
|
+
/** 过滤 `onEdgesChange` 中被守卫拒绝的 `remove` 项(含级联删边)。 */
|
|
26
|
+
export declare function filterRemoveEdgeChanges(changes: EdgeChange[], edges: ReadonlyArray<Edge>, gate?: FlowOperationGateContext | WechenBeforeRemoveEdgeFn, cascade?: DeleteGuardCascadeContext): EdgeChange[];
|
|
27
|
+
export { buildFlowOperationEvent };
|
|
11
28
|
//# sourceMappingURL=deleteGuard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteGuard.d.ts","sourceRoot":"","sources":["../../src/flow/deleteGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"deleteGuard.d.ts","sourceRoot":"","sources":["../../src/flow/deleteGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EACL,uBAAuB,EAEvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAoC/B,kDAAkD;AAClD,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAA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BAAwB,EAC1D,OAAO,CAAC,EAAE,yBAAyB,GAClC,UAAU,EAAE,CA4Bd;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Connection, Edge, Node } from '@xyflow/react';
|
|
2
|
+
import { WechenAgentSnapshot, WechenBeforeRemoveEdgeFn, WechenBeforeRemoveNodeFn, WechenDeleteGuardResult } from '../flowTypes';
|
|
3
|
+
/** 稳定操作类型,供宿主 `switch (event.kind)` */
|
|
4
|
+
export type WechenFlowOperationKind = "node.remove" | "node.duplicate" | "node.add" | "node.patch" | "node.move" | "edge.remove" | "edge.add" | "edge.reconnect" | "edge.patch" | "edge.path.reset" | "edge.path.insertVertex" | "edge.path.removeVertex";
|
|
5
|
+
/** 登记的门控 kind(文档覆盖检查用) */
|
|
6
|
+
export declare const WECHEN_FLOW_OPERATION_KINDS: readonly ["node.remove", "node.duplicate", "node.add", "node.patch", "node.move", "edge.remove", "edge.add", "edge.reconnect", "edge.patch", "edge.path.reset", "edge.path.insertVertex", "edge.path.removeVertex"];
|
|
7
|
+
export type WechenFlowOperationSource = "keyboard" | "ref" | "selectionToolbar" | "libraryDrop" | "connect" | "reconnect" | "drag" | "configPanel" | "header";
|
|
8
|
+
export interface WechenFlowOperationEvent {
|
|
9
|
+
kind: WechenFlowOperationKind;
|
|
10
|
+
source: WechenFlowOperationSource;
|
|
11
|
+
nodes: ReadonlyArray<Node>;
|
|
12
|
+
edges: ReadonlyArray<Edge>;
|
|
13
|
+
node?: Node;
|
|
14
|
+
edge?: Edge;
|
|
15
|
+
patch?: Record<string, unknown>;
|
|
16
|
+
connection?: Connection;
|
|
17
|
+
snapshot?: WechenAgentSnapshot;
|
|
18
|
+
}
|
|
19
|
+
/** 同步返回 `false` 取消操作 */
|
|
20
|
+
export type WechenOnFlowOperationFn = (event: WechenFlowOperationEvent) => WechenDeleteGuardResult;
|
|
21
|
+
export interface FlowOperationGateContext {
|
|
22
|
+
effectiveReadOnly?: boolean;
|
|
23
|
+
nodes: ReadonlyArray<Node>;
|
|
24
|
+
edges: ReadonlyArray<Edge>;
|
|
25
|
+
onFlowOperation?: WechenOnFlowOperationFn;
|
|
26
|
+
onBeforeRemoveNode?: WechenBeforeRemoveNodeFn;
|
|
27
|
+
onBeforeRemoveEdge?: WechenBeforeRemoveEdgeFn;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 是否允许执行该图操作。`effectiveReadOnly` 为真时 **SHALL** 由调用方早退且不调用本函数。
|
|
31
|
+
* `onFlowOperation` 优先于 legacy `onBeforeRemove*`(仅 `node.remove` / `edge.remove`)。
|
|
32
|
+
*/
|
|
33
|
+
export declare function isFlowOperationAllowed(event: WechenFlowOperationEvent, ctx: FlowOperationGateContext): boolean;
|
|
34
|
+
/** UI 预判:与 `isFlowOperationAllowed` 相同策略,不修改 state */
|
|
35
|
+
export declare function canPerformFlowOperation(kind: WechenFlowOperationKind, partial: Omit<WechenFlowOperationEvent, "kind" | "nodes" | "edges">, ctx: FlowOperationGateContext): boolean;
|
|
36
|
+
export declare function buildFlowOperationEvent(kind: WechenFlowOperationKind, source: WechenFlowOperationSource, ctx: FlowOperationGateContext, payload?: Omit<WechenFlowOperationEvent, "kind" | "source" | "nodes" | "edges">): WechenFlowOperationEvent;
|
|
37
|
+
//# sourceMappingURL=flowOperationEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowOperationEvents.d.ts","sourceRoot":"","sources":["../../src/flow/flowOperationEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AAEtB,uCAAuC;AACvC,MAAM,MAAM,uBAAuB,GAC/B,aAAa,GACb,gBAAgB,GAChB,UAAU,G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;AACtD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,EACnE,GAAG,EAAE,wBAAwB,GAC5B,OAAO,CAaT;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,yBAAyB,EACjC,GAAG,EAAE,wBAAwB,EAC7B,OAAO,GAAE,IAAI,CACX,wBAAwB,EACxB,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CACjC,GACL,wBAAwB,CAQ1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
import { FlowOperationGateContext } from './flowOperationEvents';
|
|
3
|
+
/** 拖动结束时是否允许落位;`false` 时调用方应回滚至 `previousPosition` */
|
|
4
|
+
export declare function canMoveNodeAfterDrag(nodeId: string, previousPosition: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}, nextPosition: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}, nodes: ReadonlyArray<Node>, gate: FlowOperationGateContext): boolean;
|
|
11
|
+
//# sourceMappingURL=nodeMoveGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeMoveGate.d.ts","sourceRoot":"","sources":["../../src/flow/nodeMoveGate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B,sDAAsD;AACtD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAC1C,YAAY,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACtC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,EAC1B,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAuBT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from '@xyflow/react';
|
|
2
|
+
/** `WechenAgentEditorRef.patchNode` / `setNodePosition` 允许的节点顶层字段(不含 `data`) */
|
|
3
|
+
export interface WechenNodeShellPatch {
|
|
4
|
+
position?: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
type?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
}
|
|
12
|
+
/** 将壳层补丁合并进节点(纯函数,供 ref 与单测使用) */
|
|
13
|
+
export declare function mergeNodeShellPatch(node: Node, patch: WechenNodeShellPatch): Node;
|
|
14
|
+
//# sourceMappingURL=nodeShellPatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeShellPatch.d.ts","sourceRoot":"","sources":["../../src/flow/nodeShellPatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,kCAAkC;AAClC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAgBjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbar.d.ts","sourceRoot":"","sources":["../../../src/flow/selectionToolbar/SelectionToolbar.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI5D,OAAO,wBAAwB,CAAC;AAEhC,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,MAAM,6BAA6B,GACrC;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE;QAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;CACxC,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE;QAAE,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAEN,MAAM,MAAM,mCAAmC,GAAG,CAChD,GAAG,EAAE,6BAA6B,KAC/B,SAAS,CAAC;AAEf,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhE,UAAU,qBAAqB;IAC7B,IAAI,EAAE,0BAA0B,CAAC;IACjC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"SelectionToolbar.d.ts","sourceRoot":"","sources":["../../../src/flow/selectionToolbar/SelectionToolbar.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EA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itViewOptions, Node, Viewport, ViewportHelperFunctionOptions } from '@xyflow/react';
|
|
3
3
|
import { WechenAgentNodeAutoLayoutOptions } from './flow/autoLayoutNodes';
|
|
4
|
+
import { WechenNodeShellPatch } from './flow/nodeShellPatch';
|
|
5
|
+
import { WechenFlowValidationResult, ValidateWechenAgentFlowOptions } from './flow/flowValidation';
|
|
4
6
|
import { FlowHandlesConfig } from './config/flowHandleTypes';
|
|
5
7
|
export type { WechenAgentLayoutStrategy, WechenAgentNodeAutoLayoutDirection, WechenAgentNodeAutoLayoutOptions, WechenAgentNodeAutoLayoutPreset, } from './flow/autoLayoutNodes';
|
|
6
8
|
/** 删除守卫回调返回值:`false` 拒绝;`true` / `undefined` / `void` 允许。 */
|
|
@@ -20,6 +22,9 @@ export type WechenBeforeRemoveEdgeFn = (edge: Edge) => WechenDeleteGuardResult;
|
|
|
20
22
|
* `readOnly` / `readingMode` 下 **不调用** 本回调。
|
|
21
23
|
*/
|
|
22
24
|
export type WechenBeforeSaveFn = (snapshot: WechenAgentSnapshot) => WechenDeleteGuardResult;
|
|
25
|
+
export type { WechenFlowOperationKind, WechenFlowOperationSource, WechenFlowOperationEvent, WechenOnFlowOperationFn, } from './flow/flowOperationEvents';
|
|
26
|
+
export type { WechenNodeShellPatch } from './flow/nodeShellPatch';
|
|
27
|
+
export type { WechenFlowValidationResult, ValidateWechenAgentFlowOptions, } from './flow/flowValidation';
|
|
23
28
|
/** `ref.addNodeFromLibrary` 入参 */
|
|
24
29
|
export interface WechenAddNodeFromLibraryOptions {
|
|
25
30
|
groupKey: string;
|
|
@@ -131,6 +136,10 @@ export interface WechenAgentEditorRef {
|
|
|
131
136
|
getInitialFlow(): WechenAgentFlowJson;
|
|
132
137
|
getNodes(): Node[];
|
|
133
138
|
getEdges(): Edge[];
|
|
139
|
+
/** 按 id 返回当前节点浅拷贝;不存在时 `null`(请勿原地修改返回值) */
|
|
140
|
+
getNode(nodeId: string): Node | null;
|
|
141
|
+
/** 按 id 返回当前边浅拷贝;不存在时 `null` */
|
|
142
|
+
getEdge(edgeId: string): Edge | null;
|
|
134
143
|
/** 等同点击「保存」:调用 `onSave`(若已传入) */
|
|
135
144
|
save(): void;
|
|
136
145
|
/** 等同「测试运行」:调用 `onTestRun`(若已传入) */
|
|
@@ -144,6 +153,21 @@ export interface WechenAgentEditorRef {
|
|
|
144
153
|
* - **更多示例与反例**:README「[patchNode 与 patchNodeData](README.md#patchnode-与-patchnodedata)」;`renderConfigPanel` 内 **`ctx.patchNode(patch)`** 签名相同且 **勿传 nodeId**。
|
|
145
154
|
*/
|
|
146
155
|
patchNodeData(nodeId: string, patch: Record<string, unknown>): void;
|
|
156
|
+
/**
|
|
157
|
+
* 更新节点 **壳层** 字段(`position` / `type` / `width` / `height`),**不** 合并 `node.data`。
|
|
158
|
+
* 业务字段请用 **`patchNodeData`**。经 **`onFlowOperation`** 的 **`node.patch`** 门控(`source: ref`)。
|
|
159
|
+
*/
|
|
160
|
+
patchNode(nodeId: string, patch: WechenNodeShellPatch): void;
|
|
161
|
+
/** 等同 **`patchNode(nodeId, { position })`** */
|
|
162
|
+
setNodePosition(nodeId: string, position: {
|
|
163
|
+
x: number;
|
|
164
|
+
y: number;
|
|
165
|
+
}): void;
|
|
166
|
+
/**
|
|
167
|
+
* 设置解析标题(参与 **`getTitle()`** / **`getSnapshot().title`**),**不** 替换 nodes/edges。
|
|
168
|
+
* 若宿主传入 **`title` prop**,prop **优先** 于 ref 写入的标题。
|
|
169
|
+
*/
|
|
170
|
+
setTitle(title: string): void;
|
|
147
171
|
/**
|
|
148
172
|
* 将 `patch` **浅合并**到边对象(`animated`、`label` 等顶层字段),与右侧连线配置 / `renderConfigPanel` 的 `patchEdge` 一致。
|
|
149
173
|
* 若 `patch` 含 **`data`**,则与现有 **`edge.data` 合并**:对 **`patch.data` 中值为 `undefined` 的键** 从结果中 **删除**;其余键 **覆盖写入**。颠倒执行顺序请用 **`swapWechenFlowEdgeEndpoints`** 生成补丁(交换 `source`/`target` 等),**不要**再持久化 **`wechenFlowDirection: 'reverse'`**。
|
|
@@ -231,6 +255,18 @@ export interface WechenAgentEditorRef {
|
|
|
231
255
|
addEdge(connection: Connection): Edge | null;
|
|
232
256
|
/** `addEdge` 的便捷封装 */
|
|
233
257
|
connect(options: WechenConnectOptions): Edge | null;
|
|
258
|
+
/**
|
|
259
|
+
* 重连连线端点(与画布拖桩 `onReconnect` 一致)。非法或门控拒绝时返回 `false`。
|
|
260
|
+
*/
|
|
261
|
+
reconnectEdge(edgeId: string, connection: Connection): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* 将视口聚焦到单节点(封装 `fitView({ nodes: [{ id }] })`)。
|
|
264
|
+
*/
|
|
265
|
+
centerOnNode(nodeId: string, options?: FitViewOptions): Promise<boolean>;
|
|
266
|
+
/**
|
|
267
|
+
* 对当前画布执行 {@link validateWechenAgentFlow}(纯函数校验的 ref 便捷封装)。
|
|
268
|
+
*/
|
|
269
|
+
validateFlow(options?: ValidateWechenAgentFlowOptions): WechenFlowValidationResult;
|
|
234
270
|
/**
|
|
235
271
|
* 复制节点(新 id、位置偏移,不复制关联边)。`readOnly` / `readingMode` 下返回 `undefined`。
|
|
236
272
|
* 成功时新节点选中、原节点取消选中。
|
package/dist/flowTypes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowTypes.d.ts","sourceRoot":"","sources":["../src/flowTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,UAAU,EACV,IAAI,EACJ,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"flowTypes.d.ts","sourceRoot":"","sources":["../src/flowTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,E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MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IACnE,iCAAiC;IACjC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;CACxE"}
|
|
@@ -33,6 +33,7 @@ export interface WechenHostEditorConfig {
|
|
|
33
33
|
onBeforeRemoveNode?: WechenAgentEditorProps["onBeforeRemoveNode"];
|
|
34
34
|
onBeforeRemoveEdge?: WechenAgentEditorProps["onBeforeRemoveEdge"];
|
|
35
35
|
onBeforeSave?: WechenAgentEditorProps["onBeforeSave"];
|
|
36
|
+
onFlowOperation?: WechenAgentEditorProps["onFlowOperation"];
|
|
36
37
|
/**
|
|
37
38
|
* 完整覆盖左侧组件库。与 {@link library} 二选一:**本字段优先**;
|
|
38
39
|
* 设置后忽略 `library`。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostEditorConfig.d.ts","sourceRoot":"","sources":["../src/hostEditorConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,qBAAqB,EAAwB,MAAM,iCAAiC,CAAC;AAEnG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,sCAAsC;AACtC,MAAM,MAAM,uBAAuB,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,uBAAuB,CAAC;IAChC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,0BAA0B,EAAE,CAAC;CAC5C;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAA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