@bpmnkit/core 0.0.27 → 0.1.0

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.
Files changed (47) hide show
  1. package/dist/bpmn/auto-layout.js +39 -126
  2. package/dist/bpmn/bpmn-builder.d.ts +30 -0
  3. package/dist/bpmn/bpmn-builder.js +343 -31
  4. package/dist/bpmn/di-check.d.ts +14 -0
  5. package/dist/bpmn/di-check.js +51 -0
  6. package/dist/bpmn/svg.js +14 -1
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +1 -0
  9. package/dist/layout/annotations.d.ts +27 -0
  10. package/dist/layout/annotations.js +251 -0
  11. package/dist/layout/grid/edge-labels.d.ts +8 -0
  12. package/dist/layout/grid/edge-labels.js +126 -0
  13. package/dist/layout/grid/flow-graph.d.ts +25 -0
  14. package/dist/layout/grid/flow-graph.js +99 -0
  15. package/dist/layout/grid/grid-engine.d.ts +4 -0
  16. package/dist/layout/grid/grid-engine.js +214 -0
  17. package/dist/layout/grid/grid-router.d.ts +36 -0
  18. package/dist/layout/grid/grid-router.js +190 -0
  19. package/dist/layout/grid/grid.d.ts +43 -0
  20. package/dist/layout/grid/grid.js +174 -0
  21. package/dist/layout/grid/walker.d.ts +11 -0
  22. package/dist/layout/grid/walker.js +126 -0
  23. package/dist/layout/index.d.ts +2 -5
  24. package/dist/layout/index.js +1 -4
  25. package/dist/layout/layout-engine.d.ts +5 -15
  26. package/dist/layout/layout-engine.js +8 -486
  27. package/dist/layout/types.js +4 -0
  28. package/dist/xml/xml-parser.js +5 -0
  29. package/package.json +1 -1
  30. package/dist/layout/astar.d.ts +0 -15
  31. package/dist/layout/astar.js +0 -191
  32. package/dist/layout/block-builder.d.ts +0 -37
  33. package/dist/layout/block-builder.js +0 -154
  34. package/dist/layout/block-layout.d.ts +0 -9
  35. package/dist/layout/block-layout.js +0 -163
  36. package/dist/layout/coordinates.d.ts +0 -85
  37. package/dist/layout/coordinates.js +0 -1392
  38. package/dist/layout/crossing.d.ts +0 -8
  39. package/dist/layout/crossing.js +0 -60
  40. package/dist/layout/graph.d.ts +0 -28
  41. package/dist/layout/graph.js +0 -126
  42. package/dist/layout/layers.d.ts +0 -13
  43. package/dist/layout/layers.js +0 -49
  44. package/dist/layout/routing.d.ts +0 -33
  45. package/dist/layout/routing.js +0 -622
  46. package/dist/layout/subprocess.d.ts +0 -14
  47. package/dist/layout/subprocess.js +0 -115
@@ -1,115 +0,0 @@
1
- import { layoutFlowNodes } from "./layout-engine.js";
2
- import { SUBPROCESS_PADDING } from "./types.js";
3
- const ADHOC_MAX_COLS = 4;
4
- const ADHOC_H_GAP = 50;
5
- const ADHOC_V_GAP = 80;
6
- /**
7
- * Rearrange disconnected adHocSubProcess tool nodes into a grid.
8
- * Nodes start at (0, 0) so the subprocess padding offset applies cleanly.
9
- */
10
- function applyAdHocGridLayout(nodes) {
11
- if (nodes.length === 0)
12
- return;
13
- const cols = Math.min(nodes.length, ADHOC_MAX_COLS);
14
- const cellW = nodes.reduce((max, n) => Math.max(max, n.bounds.width), 0);
15
- const cellH = nodes.reduce((max, n) => Math.max(max, n.bounds.height), 0);
16
- for (let i = 0; i < nodes.length; i++) {
17
- const col = i % cols;
18
- const row = Math.floor(i / cols);
19
- const n = nodes[i];
20
- if (!n)
21
- continue;
22
- const newX = col * (cellW + ADHOC_H_GAP) + Math.round((cellW - n.bounds.width) / 2);
23
- const newY = row * (cellH + ADHOC_V_GAP) + Math.round((cellH - n.bounds.height) / 2);
24
- const dx = newX - n.bounds.x;
25
- const dy = newY - n.bounds.y;
26
- n.bounds.x = newX;
27
- n.bounds.y = newY;
28
- if (n.labelBounds) {
29
- n.labelBounds.x += dx;
30
- n.labelBounds.y += dy;
31
- }
32
- }
33
- }
34
- /**
35
- * Check if a node type is a sub-process container.
36
- */
37
- export function isSubProcess(type) {
38
- return type === "subProcess" || type === "adHocSubProcess" || type === "eventSubProcess";
39
- }
40
- /**
41
- * Perform recursive layout for sub-process containers.
42
- * Lays out internal elements in local coordinates, then sizes the
43
- * sub-process to fit its content with padding, and translates internal
44
- * elements into the parent coordinate space.
45
- */
46
- export function layoutSubProcesses(layoutNodes, nodeIndex) {
47
- const childResults = [];
48
- for (const layoutNode of layoutNodes) {
49
- const bpmnNode = nodeIndex.get(layoutNode.id);
50
- if (!bpmnNode || !isSubProcess(bpmnNode.type))
51
- continue;
52
- const subProcess = bpmnNode;
53
- if (!subProcess.flowElements || subProcess.flowElements.length === 0)
54
- continue;
55
- const childResult = layoutFlowNodes(subProcess.flowElements, subProcess.sequenceFlows ?? []);
56
- // For adHocSubProcess with no sequence flows, rearrange into a compact grid
57
- // instead of a single long horizontal row.
58
- if (bpmnNode.type === "adHocSubProcess" &&
59
- (subProcess.sequenceFlows?.length ?? 0) === 0 &&
60
- childResult.nodes.length > 0) {
61
- applyAdHocGridLayout(childResult.nodes);
62
- }
63
- if (childResult.nodes.length === 0)
64
- continue;
65
- // Compute bounding box of child elements
66
- let minX = Number.POSITIVE_INFINITY;
67
- let minY = Number.POSITIVE_INFINITY;
68
- let maxX = Number.NEGATIVE_INFINITY;
69
- let maxY = Number.NEGATIVE_INFINITY;
70
- for (const child of childResult.nodes) {
71
- minX = Math.min(minX, child.bounds.x);
72
- minY = Math.min(minY, child.bounds.y);
73
- maxX = Math.max(maxX, child.bounds.x + child.bounds.width);
74
- maxY = Math.max(maxY, child.bounds.y + child.bounds.height);
75
- }
76
- const contentWidth = maxX - minX;
77
- const contentHeight = maxY - minY;
78
- // Size the sub-process to fit content with padding
79
- const originalCenterY = layoutNode.bounds.y + layoutNode.bounds.height / 2;
80
- layoutNode.bounds.width = contentWidth + SUBPROCESS_PADDING * 2;
81
- layoutNode.bounds.height = contentHeight + SUBPROCESS_PADDING * 2;
82
- layoutNode.isExpanded = true;
83
- // Re-center vertically on the original baseline position
84
- layoutNode.bounds.y = originalCenterY - layoutNode.bounds.height / 2;
85
- // Translate child coordinates into parent space
86
- const offsetX = layoutNode.bounds.x + SUBPROCESS_PADDING - minX;
87
- const offsetY = layoutNode.bounds.y + SUBPROCESS_PADDING - minY;
88
- for (const child of childResult.nodes) {
89
- child.bounds.x += offsetX;
90
- child.bounds.y += offsetY;
91
- if (child.labelBounds) {
92
- child.labelBounds.x += offsetX;
93
- child.labelBounds.y += offsetY;
94
- }
95
- }
96
- for (const edge of childResult.edges) {
97
- for (const wp of edge.waypoints) {
98
- wp.x += offsetX;
99
- wp.y += offsetY;
100
- }
101
- if (edge.labelBounds) {
102
- edge.labelBounds.x += offsetX;
103
- edge.labelBounds.y += offsetY;
104
- }
105
- }
106
- childResults.push({
107
- parentId: layoutNode.id,
108
- result: childResult,
109
- parentX: layoutNode.bounds.x,
110
- parentY: layoutNode.bounds.y,
111
- });
112
- }
113
- return childResults;
114
- }
115
- //# sourceMappingURL=subprocess.js.map