@yh-ui/flow 0.1.21
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/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/Flow.d.vue.ts +306 -0
- package/dist/Flow.vue +959 -0
- package/dist/Flow.vue.d.ts +306 -0
- package/dist/__tests__/ai-workflow.ssr.test.cjs +352 -0
- package/dist/__tests__/ai-workflow.ssr.test.d.ts +1 -0
- package/dist/__tests__/ai-workflow.ssr.test.mjs +283 -0
- package/dist/__tests__/ai-workflow.test.cjs +109 -0
- package/dist/__tests__/ai-workflow.test.d.ts +1 -0
- package/dist/__tests__/ai-workflow.test.mjs +112 -0
- package/dist/__tests__/bpmn.ssr.test.cjs +278 -0
- package/dist/__tests__/bpmn.ssr.test.d.ts +1 -0
- package/dist/__tests__/bpmn.ssr.test.mjs +237 -0
- package/dist/__tests__/bpmn.test.cjs +103 -0
- package/dist/__tests__/bpmn.test.d.ts +1 -0
- package/dist/__tests__/bpmn.test.mjs +106 -0
- package/dist/__tests__/custom-types.test.cjs +300 -0
- package/dist/__tests__/custom-types.test.d.ts +1 -0
- package/dist/__tests__/custom-types.test.mjs +248 -0
- package/dist/__tests__/edge.test.cjs +56 -0
- package/dist/__tests__/edge.test.d.ts +1 -0
- package/dist/__tests__/edge.test.mjs +69 -0
- package/dist/__tests__/event-bus.test.cjs +80 -0
- package/dist/__tests__/event-bus.test.d.ts +1 -0
- package/dist/__tests__/event-bus.test.mjs +51 -0
- package/dist/__tests__/flow.ssr.test.cjs +156 -0
- package/dist/__tests__/flow.ssr.test.d.ts +1 -0
- package/dist/__tests__/flow.ssr.test.mjs +112 -0
- package/dist/__tests__/geometry.test.cjs +191 -0
- package/dist/__tests__/geometry.test.d.ts +1 -0
- package/dist/__tests__/geometry.test.mjs +105 -0
- package/dist/__tests__/graph.test.cjs +115 -0
- package/dist/__tests__/graph.test.d.ts +1 -0
- package/dist/__tests__/graph.test.mjs +85 -0
- package/dist/__tests__/history-plugin.test.cjs +191 -0
- package/dist/__tests__/history-plugin.test.d.ts +1 -0
- package/dist/__tests__/history-plugin.test.mjs +161 -0
- package/dist/__tests__/history.test.cjs +81 -0
- package/dist/__tests__/history.test.d.ts +1 -0
- package/dist/__tests__/history.test.mjs +43 -0
- package/dist/__tests__/layout.test.cjs +213 -0
- package/dist/__tests__/layout.test.d.ts +1 -0
- package/dist/__tests__/layout.test.mjs +170 -0
- package/dist/__tests__/node-edit-panel.ssr.test.cjs +168 -0
- package/dist/__tests__/node-edit-panel.ssr.test.d.ts +1 -0
- package/dist/__tests__/node-edit-panel.ssr.test.mjs +118 -0
- package/dist/__tests__/node-group-plugin.test.cjs +235 -0
- package/dist/__tests__/node-group-plugin.test.d.ts +1 -0
- package/dist/__tests__/node-group-plugin.test.mjs +187 -0
- package/dist/__tests__/node-handles.test.cjs +340 -0
- package/dist/__tests__/node-handles.test.d.ts +1 -0
- package/dist/__tests__/node-handles.test.mjs +230 -0
- package/dist/__tests__/plugin.test.cjs +151 -0
- package/dist/__tests__/plugin.test.d.ts +1 -0
- package/dist/__tests__/plugin.test.mjs +116 -0
- package/dist/__tests__/transform.test.cjs +58 -0
- package/dist/__tests__/transform.test.d.ts +1 -0
- package/dist/__tests__/transform.test.mjs +38 -0
- package/dist/__tests__/useAlignment.test.cjs +91 -0
- package/dist/__tests__/useAlignment.test.d.ts +1 -0
- package/dist/__tests__/useAlignment.test.mjs +52 -0
- package/dist/__tests__/useEdges.test.cjs +117 -0
- package/dist/__tests__/useEdges.test.d.ts +1 -0
- package/dist/__tests__/useEdges.test.mjs +80 -0
- package/dist/__tests__/useKeyboard.test.cjs +88 -0
- package/dist/__tests__/useKeyboard.test.d.ts +1 -0
- package/dist/__tests__/useKeyboard.test.mjs +56 -0
- package/dist/__tests__/useNodes.test.cjs +150 -0
- package/dist/__tests__/useNodes.test.d.ts +1 -0
- package/dist/__tests__/useNodes.test.mjs +80 -0
- package/dist/__tests__/useSelection.test.cjs +112 -0
- package/dist/__tests__/useSelection.test.d.ts +1 -0
- package/dist/__tests__/useSelection.test.mjs +76 -0
- package/dist/__tests__/useViewport.test.cjs +171 -0
- package/dist/__tests__/useViewport.test.d.ts +1 -0
- package/dist/__tests__/useViewport.test.mjs +82 -0
- package/dist/__tests__/utils/ssr.cjs +124 -0
- package/dist/__tests__/utils/ssr.d.ts +33 -0
- package/dist/__tests__/utils/ssr.mjs +129 -0
- package/dist/__tests__/validation.test.cjs +95 -0
- package/dist/__tests__/validation.test.d.ts +1 -0
- package/dist/__tests__/validation.test.mjs +36 -0
- package/dist/components/AiNodeEditPanel.d.vue.ts +13 -0
- package/dist/components/AiNodeEditPanel.vue +413 -0
- package/dist/components/AiNodeEditPanel.vue.d.ts +13 -0
- package/dist/components/EdgeEditPanel.d.vue.ts +14 -0
- package/dist/components/EdgeEditPanel.vue +205 -0
- package/dist/components/EdgeEditPanel.vue.d.ts +14 -0
- package/dist/components/NodeEditPanel.d.vue.ts +13 -0
- package/dist/components/NodeEditPanel.vue +214 -0
- package/dist/components/NodeEditPanel.vue.d.ts +13 -0
- package/dist/components/edges/BaseEdge.d.vue.ts +23 -0
- package/dist/components/edges/BaseEdge.vue +55 -0
- package/dist/components/edges/BaseEdge.vue.d.ts +23 -0
- package/dist/components/edges/BezierEdge.d.vue.ts +22 -0
- package/dist/components/edges/BezierEdge.vue +57 -0
- package/dist/components/edges/BezierEdge.vue.d.ts +22 -0
- package/dist/components/edges/DataFlowEdge.d.vue.ts +41 -0
- package/dist/components/edges/DataFlowEdge.vue +211 -0
- package/dist/components/edges/DataFlowEdge.vue.d.ts +41 -0
- package/dist/components/edges/SmoothEdge.d.vue.ts +22 -0
- package/dist/components/edges/SmoothEdge.vue +53 -0
- package/dist/components/edges/SmoothEdge.vue.d.ts +22 -0
- package/dist/components/edges/StepEdge.d.vue.ts +22 -0
- package/dist/components/edges/StepEdge.vue +42 -0
- package/dist/components/edges/StepEdge.vue.d.ts +22 -0
- package/dist/components/edges/index.cjs +41 -0
- package/dist/components/edges/index.d.ts +5 -0
- package/dist/components/edges/index.mjs +5 -0
- package/dist/components/nodes/BaseNode.d.vue.ts +25 -0
- package/dist/components/nodes/BaseNode.vue +93 -0
- package/dist/components/nodes/BaseNode.vue.d.ts +25 -0
- package/dist/components/nodes/CustomNode.d.vue.ts +36 -0
- package/dist/components/nodes/CustomNode.vue +44 -0
- package/dist/components/nodes/CustomNode.vue.d.ts +36 -0
- package/dist/components/nodes/DatabaseNode.d.vue.ts +19 -0
- package/dist/components/nodes/DatabaseNode.vue +62 -0
- package/dist/components/nodes/DatabaseNode.vue.d.ts +19 -0
- package/dist/components/nodes/DiamondNode.d.vue.ts +19 -0
- package/dist/components/nodes/DiamondNode.vue +62 -0
- package/dist/components/nodes/DiamondNode.vue.d.ts +19 -0
- package/dist/components/nodes/GroupNode.d.vue.ts +31 -0
- package/dist/components/nodes/GroupNode.vue +48 -0
- package/dist/components/nodes/GroupNode.vue.d.ts +31 -0
- package/dist/components/nodes/InputNode.d.vue.ts +23 -0
- package/dist/components/nodes/InputNode.vue +63 -0
- package/dist/components/nodes/InputNode.vue.d.ts +23 -0
- package/dist/components/nodes/NodeResizer.d.vue.ts +27 -0
- package/dist/components/nodes/NodeResizer.vue +89 -0
- package/dist/components/nodes/NodeResizer.vue.d.ts +27 -0
- package/dist/components/nodes/NodeToolbar.d.vue.ts +32 -0
- package/dist/components/nodes/NodeToolbar.vue +101 -0
- package/dist/components/nodes/NodeToolbar.vue.d.ts +32 -0
- package/dist/components/nodes/OutputNode.d.vue.ts +21 -0
- package/dist/components/nodes/OutputNode.vue +53 -0
- package/dist/components/nodes/OutputNode.vue.d.ts +21 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.d.vue.ts +20 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.vue.d.ts +20 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.vue +65 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.vue +47 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.vue +64 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.vue +61 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.vue +47 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/index.cjs +109 -0
- package/dist/components/nodes/ai-workflow/index.d.ts +23 -0
- package/dist/components/nodes/ai-workflow/index.mjs +37 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.vue +50 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.vue +55 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.vue +50 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnTask.vue +54 -0
- package/dist/components/nodes/bpmn/BpmnTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.vue +55 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/index.cjs +109 -0
- package/dist/components/nodes/bpmn/index.d.ts +23 -0
- package/dist/components/nodes/bpmn/index.mjs +37 -0
- package/dist/components/nodes/index.cjs +246 -0
- package/dist/components/nodes/index.d.ts +13 -0
- package/dist/components/nodes/index.mjs +44 -0
- package/dist/core/FlowContext.cjs +21 -0
- package/dist/core/FlowContext.d.ts +10 -0
- package/dist/core/FlowContext.mjs +13 -0
- package/dist/core/index.cjs +104 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.mjs +9 -0
- package/dist/core/useAlignment.cjs +81 -0
- package/dist/core/useAlignment.d.ts +33 -0
- package/dist/core/useAlignment.mjs +71 -0
- package/dist/core/useEdges.cjs +132 -0
- package/dist/core/useEdges.d.ts +29 -0
- package/dist/core/useEdges.mjs +89 -0
- package/dist/core/useFlow.cjs +40 -0
- package/dist/core/useFlow.d.ts +31 -0
- package/dist/core/useFlow.mjs +32 -0
- package/dist/core/useHistory.cjs +63 -0
- package/dist/core/useHistory.d.ts +15 -0
- package/dist/core/useHistory.mjs +54 -0
- package/dist/core/useKeyboard.cjs +54 -0
- package/dist/core/useKeyboard.d.ts +18 -0
- package/dist/core/useKeyboard.mjs +45 -0
- package/dist/core/useNodeDistribution.cjs +171 -0
- package/dist/core/useNodeDistribution.d.ts +12 -0
- package/dist/core/useNodeDistribution.mjs +145 -0
- package/dist/core/useNodes.cjs +146 -0
- package/dist/core/useNodes.d.ts +26 -0
- package/dist/core/useNodes.mjs +101 -0
- package/dist/core/useSelection.cjs +83 -0
- package/dist/core/useSelection.d.ts +18 -0
- package/dist/core/useSelection.mjs +53 -0
- package/dist/core/useViewport.cjs +157 -0
- package/dist/core/useViewport.d.ts +65 -0
- package/dist/core/useViewport.mjs +125 -0
- package/dist/flow.cjs +240 -0
- package/dist/flow.d.ts +276 -0
- package/dist/flow.mjs +230 -0
- package/dist/index.cjs +378 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.mjs +50 -0
- package/dist/plugins/index.cjs +96 -0
- package/dist/plugins/index.d.ts +34 -0
- package/dist/plugins/index.mjs +47 -0
- package/dist/plugins/plugin.cjs +117 -0
- package/dist/plugins/plugin.d.ts +72 -0
- package/dist/plugins/plugin.mjs +110 -0
- package/dist/plugins/plugins/controls.cjs +38 -0
- package/dist/plugins/plugins/controls.d.ts +12 -0
- package/dist/plugins/plugins/controls.mjs +28 -0
- package/dist/plugins/plugins/export.cjs +102 -0
- package/dist/plugins/plugins/export.d.ts +12 -0
- package/dist/plugins/plugins/export.mjs +89 -0
- package/dist/plugins/plugins/grid.cjs +36 -0
- package/dist/plugins/plugins/grid.d.ts +11 -0
- package/dist/plugins/plugins/grid.mjs +26 -0
- package/dist/plugins/plugins/history.cjs +140 -0
- package/dist/plugins/plugins/history.d.ts +53 -0
- package/dist/plugins/plugins/history.mjs +132 -0
- package/dist/plugins/plugins/index.cjs +104 -0
- package/dist/plugins/plugins/index.d.ts +9 -0
- package/dist/plugins/plugins/index.mjs +9 -0
- package/dist/plugins/plugins/keyboard.cjs +27 -0
- package/dist/plugins/plugins/keyboard.d.ts +10 -0
- package/dist/plugins/plugins/keyboard.mjs +18 -0
- package/dist/plugins/plugins/layout.cjs +275 -0
- package/dist/plugins/plugins/layout.d.ts +34 -0
- package/dist/plugins/plugins/layout.mjs +246 -0
- package/dist/plugins/plugins/minimap.cjs +60 -0
- package/dist/plugins/plugins/minimap.d.ts +25 -0
- package/dist/plugins/plugins/minimap.mjs +50 -0
- package/dist/plugins/plugins/node-group.cjs +209 -0
- package/dist/plugins/plugins/node-group.d.ts +26 -0
- package/dist/plugins/plugins/node-group.mjs +178 -0
- package/dist/plugins/plugins/snap.cjs +36 -0
- package/dist/plugins/plugins/snap.d.ts +12 -0
- package/dist/plugins/plugins/snap.mjs +26 -0
- package/dist/renderer/AlignmentLines.d.vue.ts +5 -0
- package/dist/renderer/AlignmentLines.vue +113 -0
- package/dist/renderer/AlignmentLines.vue.d.ts +5 -0
- package/dist/renderer/Background.d.vue.ts +7 -0
- package/dist/renderer/Background.vue +86 -0
- package/dist/renderer/Background.vue.d.ts +7 -0
- package/dist/renderer/Controls.d.vue.ts +13 -0
- package/dist/renderer/Controls.vue +82 -0
- package/dist/renderer/Controls.vue.d.ts +13 -0
- package/dist/renderer/EdgeHandlesRenderer.d.vue.ts +11 -0
- package/dist/renderer/EdgeHandlesRenderer.vue +75 -0
- package/dist/renderer/EdgeHandlesRenderer.vue.d.ts +11 -0
- package/dist/renderer/EdgeRenderer.d.vue.ts +39 -0
- package/dist/renderer/EdgeRenderer.vue +204 -0
- package/dist/renderer/EdgeRenderer.vue.d.ts +39 -0
- package/dist/renderer/FlowBackground.d.vue.ts +11 -0
- package/dist/renderer/FlowBackground.vue +82 -0
- package/dist/renderer/FlowBackground.vue.d.ts +11 -0
- package/dist/renderer/Minimap.d.vue.ts +30 -0
- package/dist/renderer/Minimap.vue +290 -0
- package/dist/renderer/Minimap.vue.d.ts +30 -0
- package/dist/renderer/NodeRenderer.d.vue.ts +56 -0
- package/dist/renderer/NodeRenderer.vue +328 -0
- package/dist/renderer/NodeRenderer.vue.d.ts +56 -0
- package/dist/renderer/SelectionBox.d.vue.ts +11 -0
- package/dist/renderer/SelectionBox.vue +28 -0
- package/dist/renderer/SelectionBox.vue.d.ts +11 -0
- package/dist/types/edge.cjs +13 -0
- package/dist/types/edge.d.ts +65 -0
- package/dist/types/edge.mjs +6 -0
- package/dist/types/events.cjs +1 -0
- package/dist/types/events.d.ts +115 -0
- package/dist/types/events.mjs +0 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.ts +366 -0
- package/dist/types/index.mjs +0 -0
- package/dist/types/node.cjs +9 -0
- package/dist/types/node.d.ts +90 -0
- package/dist/types/node.mjs +3 -0
- package/dist/types/viewport.cjs +42 -0
- package/dist/types/viewport.d.ts +62 -0
- package/dist/types/viewport.mjs +36 -0
- package/dist/utils/bpmn-engine.cjs +390 -0
- package/dist/utils/bpmn-engine.d.ts +164 -0
- package/dist/utils/bpmn-engine.mjs +378 -0
- package/dist/utils/bpmn.cjs +492 -0
- package/dist/utils/bpmn.d.ts +53 -0
- package/dist/utils/bpmn.mjs +430 -0
- package/dist/utils/collaboration.cjs +537 -0
- package/dist/utils/collaboration.d.ts +189 -0
- package/dist/utils/collaboration.mjs +521 -0
- package/dist/utils/custom-types.cjs +138 -0
- package/dist/utils/custom-types.d.ts +78 -0
- package/dist/utils/custom-types.mjs +108 -0
- package/dist/utils/edge.cjs +235 -0
- package/dist/utils/edge.d.ts +79 -0
- package/dist/utils/edge.mjs +172 -0
- package/dist/utils/event-bus.cjs +91 -0
- package/dist/utils/event-bus.d.ts +39 -0
- package/dist/utils/event-bus.mjs +82 -0
- package/dist/utils/geometry.cjs +178 -0
- package/dist/utils/geometry.d.ts +186 -0
- package/dist/utils/geometry.mjs +144 -0
- package/dist/utils/graph.cjs +158 -0
- package/dist/utils/graph.d.ts +40 -0
- package/dist/utils/graph.mjs +147 -0
- package/dist/utils/index.cjs +137 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/performance.cjs +94 -0
- package/dist/utils/performance.d.ts +18 -0
- package/dist/utils/performance.mjs +82 -0
- package/dist/utils/screenshot.cjs +87 -0
- package/dist/utils/screenshot.d.ts +22 -0
- package/dist/utils/screenshot.mjs +66 -0
- package/dist/utils/theme.cjs +228 -0
- package/dist/utils/theme.d.ts +92 -0
- package/dist/utils/theme.mjs +217 -0
- package/dist/utils/transform.cjs +76 -0
- package/dist/utils/transform.d.ts +45 -0
- package/dist/utils/transform.mjs +57 -0
- package/dist/utils/validation.cjs +107 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.mjs +85 -0
- package/package.json +61 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
const BPMN_NS = "http://www.omg.org/spec/BPMN/20100524/MODEL";
|
|
2
|
+
const BPMN_DI_NS = "http://www.omg.org/spec/BPMN/20100524/DI";
|
|
3
|
+
const BPMN_DC_NS = "http://www.omg.org/spec/BPMN/20100524/DC";
|
|
4
|
+
const NODE_TYPE_TO_BPMN = {
|
|
5
|
+
"bpmn-start": "startEvent",
|
|
6
|
+
"bpmn-end": "endEvent",
|
|
7
|
+
"bpmn-task": "task",
|
|
8
|
+
"bpmn-service-task": "serviceTask",
|
|
9
|
+
"bpmn-user-task": "userTask",
|
|
10
|
+
"bpmn-exclusive-gateway": "exclusiveGateway",
|
|
11
|
+
"bpmn-parallel-gateway": "parallelGateway",
|
|
12
|
+
"bpmn-inclusive-gateway": "inclusiveGateway"
|
|
13
|
+
};
|
|
14
|
+
const BPMN_TO_NODE_TYPE = {
|
|
15
|
+
startEvent: "bpmn-start",
|
|
16
|
+
endEvent: "bpmn-end",
|
|
17
|
+
task: "bpmn-task",
|
|
18
|
+
serviceTask: "bpmn-service-task",
|
|
19
|
+
userTask: "bpmn-user-task",
|
|
20
|
+
exclusiveGateway: "bpmn-exclusive-gateway",
|
|
21
|
+
parallelGateway: "bpmn-parallel-gateway",
|
|
22
|
+
inclusiveGateway: "bpmn-inclusive-gateway"
|
|
23
|
+
};
|
|
24
|
+
const GATEWAY_DIRECTION = {
|
|
25
|
+
"bpmn-exclusive-gateway": "diverging",
|
|
26
|
+
"bpmn-parallel-gateway": "diverging",
|
|
27
|
+
"bpmn-inclusive-gateway": "diverging"
|
|
28
|
+
};
|
|
29
|
+
export function flowToBpmnXml(nodes, edges, options = {}) {
|
|
30
|
+
const {
|
|
31
|
+
processId = "Process_" + Date.now(),
|
|
32
|
+
processName = "Flow Process",
|
|
33
|
+
includeDi = true,
|
|
34
|
+
defaultNodeWidth = 100,
|
|
35
|
+
defaultNodeHeight = 80
|
|
36
|
+
} = options;
|
|
37
|
+
const diBounds = [];
|
|
38
|
+
const diEdges = [];
|
|
39
|
+
const bpmnElements = [];
|
|
40
|
+
for (const node of nodes) {
|
|
41
|
+
const bpmnType = NODE_TYPE_TO_BPMN[node.type];
|
|
42
|
+
if (!bpmnType) continue;
|
|
43
|
+
const nodeWidth = node.width || defaultNodeWidth;
|
|
44
|
+
const nodeHeight = node.height || defaultNodeHeight;
|
|
45
|
+
let attributes = `id="${node.id}"`;
|
|
46
|
+
const label = node.data?.name || node.data?.label || node.id;
|
|
47
|
+
if (label) {
|
|
48
|
+
attributes += ` name="${label}"`;
|
|
49
|
+
}
|
|
50
|
+
if (bpmnType.includes("Gateway")) {
|
|
51
|
+
const direction = GATEWAY_DIRECTION[node.type] || "diverging";
|
|
52
|
+
attributes += ` gatewayDirection="${direction}"`;
|
|
53
|
+
}
|
|
54
|
+
if (bpmnType === "serviceTask") {
|
|
55
|
+
attributes += ` implementation="delegateExpression"`;
|
|
56
|
+
if (node.data?.implementation) {
|
|
57
|
+
attributes += ` delegateExpression="${node.data.implementation}"`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (bpmnType === "userTask") {
|
|
61
|
+
if (node.data?.assignee) {
|
|
62
|
+
attributes += ` assignee="${node.data.assignee}"`;
|
|
63
|
+
}
|
|
64
|
+
if (node.data?.candidateUsers) {
|
|
65
|
+
attributes += ` candidateUsers="${node.data.candidateUsers}"`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
bpmnElements.push(` <bpmn:${bpmnType} ${attributes}/>`);
|
|
69
|
+
if (includeDi) {
|
|
70
|
+
diBounds.push({
|
|
71
|
+
id: `${node.id}_gui`,
|
|
72
|
+
x: node.position.x,
|
|
73
|
+
y: node.position.y,
|
|
74
|
+
width: nodeWidth,
|
|
75
|
+
height: nodeHeight
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const edge of edges) {
|
|
80
|
+
let attributes = `id="${edge.id}"`;
|
|
81
|
+
if (edge.source && edge.target) {
|
|
82
|
+
attributes += ` sourceRef="${edge.source}" targetRef="${edge.target}"`;
|
|
83
|
+
}
|
|
84
|
+
if (edge.type && edge.type !== "default") {
|
|
85
|
+
const edgeType = edge.type.replace("Edge", "").toLowerCase();
|
|
86
|
+
if (["smooth", "step", "bezier"].includes(edgeType)) {
|
|
87
|
+
attributes += ` messageVisibleKind="signal"`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (edge.data?.conditionExpression) {
|
|
91
|
+
bpmnElements.push(
|
|
92
|
+
` <bpmn:sequenceFlow id="${edge.id}" sourceRef="${edge.source}" targetRef="${edge.target}">
|
|
93
|
+
<bpmn:conditionExpression xsi:type="tFormalExpression" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">${edge.data.conditionExpression}</bpmn:conditionExpression>
|
|
94
|
+
</bpmn:sequenceFlow>`
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
bpmnElements.push(` <bpmn:sequenceFlow ${attributes}/>`);
|
|
98
|
+
}
|
|
99
|
+
if (includeDi) {
|
|
100
|
+
diEdges.push({
|
|
101
|
+
id: `${edge.id}_di`,
|
|
102
|
+
sourceRef: edge.source || "",
|
|
103
|
+
targetRef: edge.target || ""
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
let xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
108
|
+
<bpmn:definitions xmlns:bpmn="${BPMN_NS}" xmlns:bpmndi="${BPMN_DI_NS}" xmlns:dc="${BPMN_DC_NS}" xmlns:di="${BPMN_DI_NS}" id="definitions_${processId}" targetNamespace="http://bpmn.io/schema/bpmn">
|
|
109
|
+
<bpmn:process id="${processId}" name="${processName}" isExecutable="false">
|
|
110
|
+
${bpmnElements.join("\n")}
|
|
111
|
+
</bpmn:process>`;
|
|
112
|
+
if (includeDi) {
|
|
113
|
+
xml += `
|
|
114
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
115
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="${processId}">`;
|
|
116
|
+
for (const bound of diBounds) {
|
|
117
|
+
xml += `
|
|
118
|
+
<bpmndi:BPMNShape id="${bound.id}" bpmnElement="${bound.id.replace("_gui", "")}">
|
|
119
|
+
<dc:Bounds x="${bound.x}" y="${bound.y}" width="${bound.width}" height="${bound.height}"/>
|
|
120
|
+
</bpmndi:BPMNShape>`;
|
|
121
|
+
}
|
|
122
|
+
for (const edge of diEdges) {
|
|
123
|
+
xml += `
|
|
124
|
+
<bpmndi:BPMNEdge id="${edge.id}_di" bpmnElement="${edge.id}"/>`;
|
|
125
|
+
}
|
|
126
|
+
xml += `
|
|
127
|
+
</bpmndi:BPMNPlane>
|
|
128
|
+
</bpmndi:BPMNDiagram>`;
|
|
129
|
+
}
|
|
130
|
+
xml += `
|
|
131
|
+
</bpmn:definitions>`;
|
|
132
|
+
return { xml, processId };
|
|
133
|
+
}
|
|
134
|
+
export function bpmnXmlToFlow(xml, options = {}) {
|
|
135
|
+
const { defaultPosition = { x: 100, y: 100 }, nodeSpacing = 150 } = options;
|
|
136
|
+
const nodes = [];
|
|
137
|
+
const edges = [];
|
|
138
|
+
const parser = new DOMParser();
|
|
139
|
+
const doc = parser.parseFromString(xml, "text/xml");
|
|
140
|
+
const parseError = doc.querySelector("parsererror");
|
|
141
|
+
if (parseError) {
|
|
142
|
+
throw new Error(`BPMN XML \u89E3\u6790\u5931\u8D25: ${parseError.textContent}`);
|
|
143
|
+
}
|
|
144
|
+
const process = doc.querySelector("bpmn\\:process, process");
|
|
145
|
+
const processId = process?.getAttribute("id") || "";
|
|
146
|
+
const processName = process?.getAttribute("name") || "";
|
|
147
|
+
const diShapes = /* @__PURE__ */ new Map();
|
|
148
|
+
const bpmnShapes = Array.from(doc.querySelectorAll("bpmndi\\:BPMNShape, BPMNShape"));
|
|
149
|
+
for (const shape of bpmnShapes) {
|
|
150
|
+
const bpmnElement = shape.getAttribute("bpmnElement");
|
|
151
|
+
const bounds = shape.querySelector("dc\\:Bounds, Bounds");
|
|
152
|
+
if (bpmnElement && bounds) {
|
|
153
|
+
diShapes.set(bpmnElement, {
|
|
154
|
+
x: parseFloat(bounds.getAttribute("x") || "0"),
|
|
155
|
+
y: parseFloat(bounds.getAttribute("y") || "0"),
|
|
156
|
+
width: parseFloat(bounds.getAttribute("width") || "100"),
|
|
157
|
+
height: parseFloat(bounds.getAttribute("height") || "80")
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const findBpmnElements = (root) => {
|
|
162
|
+
const tags = [
|
|
163
|
+
"startEvent",
|
|
164
|
+
"endEvent",
|
|
165
|
+
"task",
|
|
166
|
+
"serviceTask",
|
|
167
|
+
"userTask",
|
|
168
|
+
"exclusiveGateway",
|
|
169
|
+
"parallelGateway",
|
|
170
|
+
"inclusiveGateway"
|
|
171
|
+
];
|
|
172
|
+
const elements = [];
|
|
173
|
+
tags.forEach((tag) => {
|
|
174
|
+
const perTagElements = [];
|
|
175
|
+
perTagElements.push(...Array.from(root.getElementsByTagNameNS(BPMN_NS, tag)));
|
|
176
|
+
perTagElements.push(...Array.from(root.getElementsByTagName(tag)).filter((el) => !el.prefix));
|
|
177
|
+
if (perTagElements.length === 0) {
|
|
178
|
+
perTagElements.push(...Array.from(root.querySelectorAll(`[localName="${tag}"]`)));
|
|
179
|
+
}
|
|
180
|
+
elements.push(...perTagElements);
|
|
181
|
+
});
|
|
182
|
+
return elements;
|
|
183
|
+
};
|
|
184
|
+
const bpmnElements = findBpmnElements(doc);
|
|
185
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
186
|
+
let maxY = defaultPosition.y;
|
|
187
|
+
for (const element of bpmnElements) {
|
|
188
|
+
const id = element.getAttribute("id");
|
|
189
|
+
const name = element.getAttribute("name") || "";
|
|
190
|
+
const localName = element.localName;
|
|
191
|
+
const nodeType = BPMN_TO_NODE_TYPE[localName];
|
|
192
|
+
if (!nodeType || !id) continue;
|
|
193
|
+
const di = diShapes.get(id);
|
|
194
|
+
const position = di ? { x: di.x, y: di.y } : { x: defaultPosition.x, y: defaultPosition.y + maxY };
|
|
195
|
+
const width = di?.width || 100;
|
|
196
|
+
const height = di?.height || 80;
|
|
197
|
+
const data = { label: name || id };
|
|
198
|
+
if (localName === "userTask") {
|
|
199
|
+
data.assignee = element.getAttribute("assignee") || "";
|
|
200
|
+
data.candidateUsers = element.getAttribute("candidateUsers") || "";
|
|
201
|
+
}
|
|
202
|
+
if (localName === "serviceTask") {
|
|
203
|
+
data.implementation = element.getAttribute("delegateExpression") || "";
|
|
204
|
+
}
|
|
205
|
+
const node = {
|
|
206
|
+
id,
|
|
207
|
+
type: nodeType,
|
|
208
|
+
position,
|
|
209
|
+
data,
|
|
210
|
+
width,
|
|
211
|
+
height,
|
|
212
|
+
selected: false,
|
|
213
|
+
dragging: false
|
|
214
|
+
};
|
|
215
|
+
nodes.push(node);
|
|
216
|
+
nodeMap.set(id, {
|
|
217
|
+
x: position.x,
|
|
218
|
+
y: position.y,
|
|
219
|
+
width,
|
|
220
|
+
height,
|
|
221
|
+
outgoing: []
|
|
222
|
+
});
|
|
223
|
+
maxY += nodeSpacing;
|
|
224
|
+
}
|
|
225
|
+
const sequenceFlows = [
|
|
226
|
+
...Array.from(doc.getElementsByTagNameNS(BPMN_NS, "sequenceFlow")),
|
|
227
|
+
...Array.from(doc.getElementsByTagName("sequenceFlow")).filter((el) => !el.prefix)
|
|
228
|
+
];
|
|
229
|
+
for (const flow of sequenceFlows) {
|
|
230
|
+
const id = flow.getAttribute("id");
|
|
231
|
+
const sourceRef = flow.getAttribute("sourceRef");
|
|
232
|
+
const targetRef = flow.getAttribute("targetRef");
|
|
233
|
+
if (!id || !sourceRef || !targetRef) continue;
|
|
234
|
+
const conditionExpr = flow.querySelector("bpmn\\:conditionExpression, conditionExpression");
|
|
235
|
+
const conditionText = conditionExpr?.textContent?.trim();
|
|
236
|
+
const sourceNode = nodeMap.get(sourceRef);
|
|
237
|
+
if (sourceNode) {
|
|
238
|
+
sourceNode.outgoing.push(id);
|
|
239
|
+
}
|
|
240
|
+
const edge = {
|
|
241
|
+
id,
|
|
242
|
+
source: sourceRef,
|
|
243
|
+
target: targetRef,
|
|
244
|
+
type: "smoothstep",
|
|
245
|
+
animated: false,
|
|
246
|
+
selected: false,
|
|
247
|
+
data: conditionText ? { conditionExpression: conditionText } : {}
|
|
248
|
+
};
|
|
249
|
+
edges.push(edge);
|
|
250
|
+
}
|
|
251
|
+
if (diShapes.size === 0) {
|
|
252
|
+
applySimpleLayout(nodes, edges, nodeSpacing);
|
|
253
|
+
}
|
|
254
|
+
return { nodes, edges, processId, processName };
|
|
255
|
+
}
|
|
256
|
+
function applySimpleLayout(nodes, edges, spacing) {
|
|
257
|
+
const inDegree = /* @__PURE__ */ new Map();
|
|
258
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const node of nodes) {
|
|
260
|
+
inDegree.set(node.id, 0);
|
|
261
|
+
adjacency.set(node.id, []);
|
|
262
|
+
}
|
|
263
|
+
for (const edge of edges) {
|
|
264
|
+
if (edge.source && edge.target) {
|
|
265
|
+
const current = inDegree.get(edge.target) || 0;
|
|
266
|
+
inDegree.set(edge.target, current + 1);
|
|
267
|
+
const outgoing = adjacency.get(edge.source) || [];
|
|
268
|
+
outgoing.push(edge.target);
|
|
269
|
+
adjacency.set(edge.source, outgoing);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const queue = [];
|
|
273
|
+
for (const [nodeId, degree] of inDegree) {
|
|
274
|
+
if (degree === 0) queue.push(nodeId);
|
|
275
|
+
}
|
|
276
|
+
const levels = /* @__PURE__ */ new Map();
|
|
277
|
+
const visited = /* @__PURE__ */ new Set();
|
|
278
|
+
let level = 0;
|
|
279
|
+
while (queue.length > 0) {
|
|
280
|
+
const levelSize = queue.length;
|
|
281
|
+
for (let i = 0; i < levelSize; i++) {
|
|
282
|
+
const nodeId = queue.shift();
|
|
283
|
+
if (visited.has(nodeId)) continue;
|
|
284
|
+
visited.add(nodeId);
|
|
285
|
+
levels.set(nodeId, level);
|
|
286
|
+
const outgoing = adjacency.get(nodeId) || [];
|
|
287
|
+
for (const targetId of outgoing) {
|
|
288
|
+
if (!visited.has(targetId)) {
|
|
289
|
+
queue.push(targetId);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
level++;
|
|
294
|
+
}
|
|
295
|
+
for (const node of nodes) {
|
|
296
|
+
if (!levels.has(node.id)) {
|
|
297
|
+
levels.set(node.id, level);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const levelNodes = /* @__PURE__ */ new Map();
|
|
301
|
+
for (const node of nodes) {
|
|
302
|
+
const l = levels.get(node.id) || 0;
|
|
303
|
+
const nodesAtLevel = levelNodes.get(l) || [];
|
|
304
|
+
nodesAtLevel.push(node);
|
|
305
|
+
levelNodes.set(l, nodesAtLevel);
|
|
306
|
+
}
|
|
307
|
+
for (const [l, nodesAtLevel] of levelNodes) {
|
|
308
|
+
nodesAtLevel.forEach((node, index) => {
|
|
309
|
+
node.position = {
|
|
310
|
+
x: 100 + l * 250,
|
|
311
|
+
y: 100 + index * spacing
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
export function validateBpmnXml(xml) {
|
|
317
|
+
try {
|
|
318
|
+
const parser = new DOMParser();
|
|
319
|
+
const doc = parser.parseFromString(xml, "text/xml");
|
|
320
|
+
const parseError = doc.querySelector("parsererror");
|
|
321
|
+
if (parseError) {
|
|
322
|
+
return { valid: false, error: "XML \u683C\u5F0F\u9519\u8BEF" };
|
|
323
|
+
}
|
|
324
|
+
const definitions = doc.querySelector("bpmn\\:definitions, definitions");
|
|
325
|
+
if (!definitions) {
|
|
326
|
+
return { valid: false, error: "\u7F3A\u5C11 BPMN definitions \u6839\u5143\u7D20" };
|
|
327
|
+
}
|
|
328
|
+
const process = doc.querySelector("bpmn\\:process, process");
|
|
329
|
+
if (!process) {
|
|
330
|
+
return { valid: false, error: "\u7F3A\u5C11 BPMN process \u5143\u7D20" };
|
|
331
|
+
}
|
|
332
|
+
return { valid: true };
|
|
333
|
+
} catch (e) {
|
|
334
|
+
return { valid: false, error: e instanceof Error ? e.message : "\u672A\u77E5\u9519\u8BEF" };
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
export function generateSampleBpmnXml() {
|
|
338
|
+
const sampleNodes = [
|
|
339
|
+
{
|
|
340
|
+
id: "start",
|
|
341
|
+
type: "bpmn-start",
|
|
342
|
+
position: { x: 100, y: 200 },
|
|
343
|
+
data: { label: "\u5F00\u59CB", name: "\u5F00\u59CB" },
|
|
344
|
+
width: 40,
|
|
345
|
+
height: 40,
|
|
346
|
+
selected: false,
|
|
347
|
+
dragging: false
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
id: "task1",
|
|
351
|
+
type: "bpmn-user-task",
|
|
352
|
+
position: { x: 250, y: 180 },
|
|
353
|
+
data: { label: "\u5BA1\u6279\u4EFB\u52A1", name: "\u5BA1\u6279\u4EFB\u52A1", assignee: "admin" },
|
|
354
|
+
width: 120,
|
|
355
|
+
height: 80,
|
|
356
|
+
selected: false,
|
|
357
|
+
dragging: false
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
id: "gateway",
|
|
361
|
+
type: "bpmn-exclusive-gateway",
|
|
362
|
+
position: { x: 450, y: 200 },
|
|
363
|
+
data: { label: "\u662F\u5426\u901A\u8FC7", name: "\u662F\u5426\u901A\u8FC7" },
|
|
364
|
+
width: 50,
|
|
365
|
+
height: 50,
|
|
366
|
+
selected: false,
|
|
367
|
+
dragging: false
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
id: "task2",
|
|
371
|
+
type: "bpmn-service-task",
|
|
372
|
+
position: { x: 600, y: 100 },
|
|
373
|
+
data: { label: "\u5904\u7406\u4E1A\u52A1", name: "\u5904\u7406\u4E1A\u52A1", implementation: "${myService}" },
|
|
374
|
+
width: 120,
|
|
375
|
+
height: 80,
|
|
376
|
+
selected: false,
|
|
377
|
+
dragging: false
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
id: "end",
|
|
381
|
+
type: "bpmn-end",
|
|
382
|
+
position: { x: 800, y: 200 },
|
|
383
|
+
data: { label: "\u7ED3\u675F", name: "\u7ED3\u675F" },
|
|
384
|
+
width: 40,
|
|
385
|
+
height: 40,
|
|
386
|
+
selected: false,
|
|
387
|
+
dragging: false
|
|
388
|
+
}
|
|
389
|
+
];
|
|
390
|
+
const sampleEdges = [
|
|
391
|
+
{
|
|
392
|
+
id: "e1",
|
|
393
|
+
source: "start",
|
|
394
|
+
target: "task1",
|
|
395
|
+
type: "smoothstep",
|
|
396
|
+
selected: false,
|
|
397
|
+
animated: false
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
id: "e2",
|
|
401
|
+
source: "task1",
|
|
402
|
+
target: "gateway",
|
|
403
|
+
type: "smoothstep",
|
|
404
|
+
selected: false,
|
|
405
|
+
animated: false
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
id: "e3",
|
|
409
|
+
source: "gateway",
|
|
410
|
+
target: "task2",
|
|
411
|
+
type: "smoothstep",
|
|
412
|
+
selected: false,
|
|
413
|
+
animated: false,
|
|
414
|
+
data: { conditionExpression: "${approved == true}" }
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "e4",
|
|
418
|
+
source: "gateway",
|
|
419
|
+
target: "end",
|
|
420
|
+
type: "smoothstep",
|
|
421
|
+
selected: false,
|
|
422
|
+
animated: false
|
|
423
|
+
},
|
|
424
|
+
{ id: "e5", source: "task2", target: "end", type: "smooth", selected: false, animated: false }
|
|
425
|
+
];
|
|
426
|
+
return flowToBpmnXml(sampleNodes, sampleEdges, {
|
|
427
|
+
processId: "SampleProcess",
|
|
428
|
+
processName: "\u793A\u4F8B\u6D41\u7A0B"
|
|
429
|
+
}).xml;
|
|
430
|
+
}
|