-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathindex.ts
More file actions
105 lines (98 loc) · 2.75 KB
/
Copy pathindex.ts
File metadata and controls
105 lines (98 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { createLayout } from '../geometry/index.js';
import { analyzeSemantics } from './steps/analyzeSemantics.js';
import { extractElements } from './steps/extractElements.js';
import { layoutChildScopes } from './steps/layoutChildScopes.js';
import { placeArtifacts } from './steps/placeArtifacts.js';
import { placeEventSubProcesses } from './steps/placeEventSubProcesses.js';
import { placeExpandedChildren } from './steps/placeExpandedChildren.js';
import { placeFlowNodes } from './steps/placeFlowNodes.js';
import { placeGroups } from './steps/placeGroups.js';
import { routeSequenceFlows } from './steps/routeSequenceFlows.js';
import { validateScope } from './steps/validateScope.js';
import type {
BpmnElement,
ProcessLayoutContext,
ProcessLayoutOptions,
ProcessLayoutResult,
ProcessLayoutStep
} from '../Types.js';
type ProcessLayoutContextOptions =
& Pick<ProcessLayoutOptions, 'layoutScope'>
& Partial<Omit<ProcessLayoutOptions, 'layoutScope'>>;
const PROCESS_LAYOUT_STEPS: readonly ProcessLayoutStep[] = Object.freeze([
extractElements,
layoutChildScopes,
validateScope,
analyzeSemantics,
placeFlowNodes,
placeExpandedChildren,
routeSequenceFlows,
placeEventSubProcesses,
placeArtifacts,
placeGroups
]);
/**
* Lay out one process or sub-process through its fixed lifecycle.
*/
export function layoutProcessScope(
scope: BpmnElement,
options: Partial<ProcessLayoutOptions> = {}
): ProcessLayoutResult {
const layoutScope = (
childScope: BpmnElement,
childOptions: Partial<ProcessLayoutOptions> = {}
) => {
return layoutProcessScope(childScope, childOptions);
};
const context = createProcessLayoutContext(scope, {
...options,
layoutScope
});
const completed = PROCESS_LAYOUT_STEPS.reduce((current, runStep) => {
return runStep(current);
}, context);
return {
layout: completed.layout,
warnings: completed.warnings
};
}
export { getParticipantContainerBounds } from './placement/ParticipantBounds.js';
function createProcessLayoutContext(
scope: BpmnElement,
{
expandedIds = new Set<string>(),
participantProcess = false,
messageFlowEndpointDirections = new Map<BpmnElement, Set<string>>(),
layoutScope
}: ProcessLayoutContextOptions
): ProcessLayoutContext {
return {
scope,
options: {
expandedIds,
participantProcess,
messageFlowEndpointDirections,
layoutScope
},
elements: {
groups: [],
sequenceFlows: [],
associations: []
},
graph: {
nodes: [],
edges: [],
boundaryEdges: []
},
semantics: {
policy: null,
ranks: null
},
placement: {
records: [],
recordsByElement: new Map()
},
layout: createLayout(scope),
warnings: []
};
}