@multiplatform.one/node-graph 9.0.10 → 9.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.
- package/dist/cjs/graphLayout/GraphDots.cjs +60 -0
- package/dist/cjs/graphLayout/GraphDots.native.js +66 -0
- package/dist/cjs/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphLayout.cjs +153 -0
- package/dist/cjs/graphLayout/GraphLayout.native.js +163 -0
- package/dist/cjs/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphSvg.cjs +68 -0
- package/dist/cjs/graphLayout/GraphSvg.native.js +73 -0
- package/dist/cjs/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/cjs/graphLayout/GraphViewport.cjs +263 -0
- package/dist/cjs/graphLayout/GraphViewport.native.js +279 -0
- package/dist/cjs/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/cjs/graphLayout/index.cjs +51 -0
- package/dist/cjs/graphLayout/index.native.js +54 -0
- package/dist/cjs/graphLayout/index.native.js.map +1 -0
- package/dist/cjs/graphLayout/ogden.fixture.cjs +30 -0
- package/dist/cjs/graphLayout/ogden.fixture.native.js +33 -0
- package/dist/cjs/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/cjs/graphLayout/plan.cjs +263 -0
- package/dist/cjs/graphLayout/plan.native.js +372 -0
- package/dist/cjs/graphLayout/plan.native.js.map +1 -0
- package/dist/cjs/graphLayout/viewMath.cjs +142 -0
- package/dist/cjs/graphLayout/viewMath.native.js +147 -0
- package/dist/cjs/graphLayout/viewMath.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphDots.mjs +35 -0
- package/dist/esm/graphLayout/GraphDots.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphDots.native.js +38 -0
- package/dist/esm/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphLayout.mjs +127 -0
- package/dist/esm/graphLayout/GraphLayout.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphLayout.native.js +134 -0
- package/dist/esm/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphSvg.mjs +42 -0
- package/dist/esm/graphLayout/GraphSvg.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphSvg.native.js +44 -0
- package/dist/esm/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/esm/graphLayout/GraphViewport.mjs +238 -0
- package/dist/esm/graphLayout/GraphViewport.mjs.map +1 -0
- package/dist/esm/graphLayout/GraphViewport.native.js +251 -0
- package/dist/esm/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/esm/graphLayout/index.mjs +7 -0
- package/dist/esm/graphLayout/index.mjs.map +1 -0
- package/dist/esm/graphLayout/index.native.js +7 -0
- package/dist/esm/graphLayout/index.native.js.map +1 -0
- package/dist/esm/graphLayout/ogden.fixture.mjs +4 -0
- package/dist/esm/graphLayout/ogden.fixture.mjs.map +1 -0
- package/dist/esm/graphLayout/ogden.fixture.native.js +4 -0
- package/dist/esm/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/esm/graphLayout/plan.mjs +235 -0
- package/dist/esm/graphLayout/plan.mjs.map +1 -0
- package/dist/esm/graphLayout/plan.native.js +341 -0
- package/dist/esm/graphLayout/plan.native.js.map +1 -0
- package/dist/esm/graphLayout/viewMath.mjs +105 -0
- package/dist/esm/graphLayout/viewMath.mjs.map +1 -0
- package/dist/esm/graphLayout/viewMath.native.js +107 -0
- package/dist/esm/graphLayout/viewMath.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphDots.mjs +35 -0
- package/dist/jsx/graphLayout/GraphDots.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphDots.native.js +66 -0
- package/dist/jsx/graphLayout/GraphDots.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphLayout.mjs +127 -0
- package/dist/jsx/graphLayout/GraphLayout.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphLayout.native.js +163 -0
- package/dist/jsx/graphLayout/GraphLayout.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphSvg.mjs +42 -0
- package/dist/jsx/graphLayout/GraphSvg.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphSvg.native.js +73 -0
- package/dist/jsx/graphLayout/GraphSvg.native.js.map +1 -0
- package/dist/jsx/graphLayout/GraphViewport.mjs +238 -0
- package/dist/jsx/graphLayout/GraphViewport.mjs.map +1 -0
- package/dist/jsx/graphLayout/GraphViewport.native.js +279 -0
- package/dist/jsx/graphLayout/GraphViewport.native.js.map +1 -0
- package/dist/jsx/graphLayout/index.mjs +7 -0
- package/dist/jsx/graphLayout/index.mjs.map +1 -0
- package/dist/jsx/graphLayout/index.native.js +54 -0
- package/dist/jsx/graphLayout/index.native.js.map +1 -0
- package/dist/jsx/graphLayout/ogden.fixture.mjs +4 -0
- package/dist/jsx/graphLayout/ogden.fixture.mjs.map +1 -0
- package/dist/jsx/graphLayout/ogden.fixture.native.js +33 -0
- package/dist/jsx/graphLayout/ogden.fixture.native.js.map +1 -0
- package/dist/jsx/graphLayout/plan.mjs +235 -0
- package/dist/jsx/graphLayout/plan.mjs.map +1 -0
- package/dist/jsx/graphLayout/plan.native.js +372 -0
- package/dist/jsx/graphLayout/plan.native.js.map +1 -0
- package/dist/jsx/graphLayout/viewMath.mjs +105 -0
- package/dist/jsx/graphLayout/viewMath.mjs.map +1 -0
- package/dist/jsx/graphLayout/viewMath.native.js +147 -0
- package/dist/jsx/graphLayout/viewMath.native.js.map +1 -0
- package/graph-layout.ts +1 -0
- package/package.json +21 -6
- package/src/graphLayout/GraphDots.tsx +32 -0
- package/src/graphLayout/GraphLayout.stories.tsx +86 -0
- package/src/graphLayout/GraphLayout.tsx +152 -0
- package/src/graphLayout/GraphSvg.native.tsx +31 -0
- package/src/graphLayout/GraphSvg.tsx +45 -0
- package/src/graphLayout/GraphViewport.native.tsx +231 -0
- package/src/graphLayout/GraphViewport.tsx +246 -0
- package/src/graphLayout/index.ts +31 -0
- package/src/graphLayout/ogden.fixture.ts +120 -0
- package/src/graphLayout/plan.spec.ts +202 -0
- package/src/graphLayout/plan.ts +223 -0
- package/src/graphLayout/purity.spec.ts +67 -0
- package/src/graphLayout/viewMath.spec.ts +185 -0
- package/src/graphLayout/viewMath.ts +151 -0
- package/types/graphLayout/GraphDots.d.ts +9 -0
- package/types/graphLayout/GraphDots.d.ts.map +1 -0
- package/types/graphLayout/GraphLayout.d.ts +22 -0
- package/types/graphLayout/GraphLayout.d.ts.map +1 -0
- package/types/graphLayout/GraphSvg.d.ts +17 -0
- package/types/graphLayout/GraphSvg.d.ts.map +1 -0
- package/types/graphLayout/GraphSvg.native.d.ts +5 -0
- package/types/graphLayout/GraphSvg.native.d.ts.map +1 -0
- package/types/graphLayout/GraphViewport.d.ts +11 -0
- package/types/graphLayout/GraphViewport.d.ts.map +1 -0
- package/types/graphLayout/GraphViewport.native.d.ts +4 -0
- package/types/graphLayout/GraphViewport.native.d.ts.map +1 -0
- package/types/graphLayout/index.d.ts +11 -0
- package/types/graphLayout/index.d.ts.map +1 -0
- package/types/graphLayout/ogden.fixture.d.ts +3 -0
- package/types/graphLayout/ogden.fixture.d.ts.map +1 -0
- package/types/graphLayout/plan.d.ts +52 -0
- package/types/graphLayout/plan.d.ts.map +1 -0
- package/types/graphLayout/viewMath.d.ts +47 -0
- package/types/graphLayout/viewMath.d.ts.map +1 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { edgeClearance } from "../edges/edgeRoute.mjs";
|
|
2
|
+
import { buildEdgePath } from "../edges/edgePath.mjs";
|
|
3
|
+
import { resolveEdgeStyle } from "../edges/edgeStyle.mjs";
|
|
4
|
+
import { layoutWithDagre } from "../layout/dagre.mjs";
|
|
5
|
+
import { Position } from "../react-flow/xyPaths.mjs";
|
|
6
|
+
const sides = {
|
|
7
|
+
LR: {
|
|
8
|
+
out: Position.Right,
|
|
9
|
+
in: Position.Left
|
|
10
|
+
},
|
|
11
|
+
TB: {
|
|
12
|
+
out: Position.Bottom,
|
|
13
|
+
in: Position.Top
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const inward = {
|
|
17
|
+
[Position.Left]: {
|
|
18
|
+
x: 1,
|
|
19
|
+
y: 0
|
|
20
|
+
},
|
|
21
|
+
[Position.Right]: {
|
|
22
|
+
x: -1,
|
|
23
|
+
y: 0
|
|
24
|
+
},
|
|
25
|
+
[Position.Top]: {
|
|
26
|
+
x: 0,
|
|
27
|
+
y: 1
|
|
28
|
+
},
|
|
29
|
+
[Position.Bottom]: {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: -1
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function graphEdgeId(edge) {
|
|
35
|
+
return edge.id ?? `${edge.source}
|
|
36
|
+
${edge.target}`;
|
|
37
|
+
}
|
|
38
|
+
function usableEdges(nodes, edges) {
|
|
39
|
+
const known = new Set(nodes.map(node => node.id));
|
|
40
|
+
const seen = /* @__PURE__ */new Set();
|
|
41
|
+
const kept = [];
|
|
42
|
+
for (const edge of edges) {
|
|
43
|
+
if (edge.source === edge.target || !known.has(edge.source) || !known.has(edge.target)) continue;
|
|
44
|
+
const id = graphEdgeId(edge);
|
|
45
|
+
if (seen.has(id)) continue;
|
|
46
|
+
seen.add(id);
|
|
47
|
+
kept.push(edge);
|
|
48
|
+
}
|
|
49
|
+
return kept;
|
|
50
|
+
}
|
|
51
|
+
function placeNodes(input, edges) {
|
|
52
|
+
const placed = /* @__PURE__ */new Map();
|
|
53
|
+
if (input.positions) {
|
|
54
|
+
for (const node of input.nodes) placed.set(node.id, input.positions[node.id] ?? {
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
});
|
|
58
|
+
return placed;
|
|
59
|
+
}
|
|
60
|
+
const linked = new Set(edges.flatMap(edge => [edge.source, edge.target]));
|
|
61
|
+
const graphNodes = input.nodes.filter(node => linked.has(node.id));
|
|
62
|
+
const isolated = input.nodes.filter(node => !linked.has(node.id));
|
|
63
|
+
let dagWidth = 0;
|
|
64
|
+
let dagHeight = 0;
|
|
65
|
+
if (graphNodes.length > 0) {
|
|
66
|
+
const result = layoutWithDagre({
|
|
67
|
+
nodes: graphNodes.map(node => ({
|
|
68
|
+
...node,
|
|
69
|
+
position: {
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0
|
|
72
|
+
}
|
|
73
|
+
})),
|
|
74
|
+
edges: edges.map(edge => ({
|
|
75
|
+
id: graphEdgeId(edge),
|
|
76
|
+
source: edge.source,
|
|
77
|
+
target: edge.target
|
|
78
|
+
})),
|
|
79
|
+
options: {
|
|
80
|
+
direction: input.direction,
|
|
81
|
+
nodeSpacing: input.nodeSpacing,
|
|
82
|
+
rankSpacing: input.rankSpacing
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
for (const node of graphNodes) {
|
|
86
|
+
const at = result.positions[node.id] ?? {
|
|
87
|
+
x: 0,
|
|
88
|
+
y: 0
|
|
89
|
+
};
|
|
90
|
+
placed.set(node.id, at);
|
|
91
|
+
dagWidth = Math.max(dagWidth, at.x + node.width);
|
|
92
|
+
dagHeight = Math.max(dagHeight, at.y + node.height);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const wrap = Math.max(dagWidth, input.wrapWidth ?? 0, ...isolated.map(node => node.width));
|
|
96
|
+
let x = 0;
|
|
97
|
+
let y = graphNodes.length > 0 ? dagHeight + input.rankSpacing : 0;
|
|
98
|
+
let rowHeight = 0;
|
|
99
|
+
for (const node of isolated) {
|
|
100
|
+
if (x > 0 && x + node.width > wrap) {
|
|
101
|
+
x = 0;
|
|
102
|
+
y += rowHeight + input.nodeSpacing;
|
|
103
|
+
rowHeight = 0;
|
|
104
|
+
}
|
|
105
|
+
placed.set(node.id, {
|
|
106
|
+
x,
|
|
107
|
+
y
|
|
108
|
+
});
|
|
109
|
+
x += node.width + input.nodeSpacing;
|
|
110
|
+
rowHeight = Math.max(rowHeight, node.height);
|
|
111
|
+
}
|
|
112
|
+
return placed;
|
|
113
|
+
}
|
|
114
|
+
function anchor(node, side) {
|
|
115
|
+
switch (side) {
|
|
116
|
+
case Position.Left:
|
|
117
|
+
return {
|
|
118
|
+
x: node.x,
|
|
119
|
+
y: node.y + node.height / 2
|
|
120
|
+
};
|
|
121
|
+
case Position.Right:
|
|
122
|
+
return {
|
|
123
|
+
x: node.x + node.width,
|
|
124
|
+
y: node.y + node.height / 2
|
|
125
|
+
};
|
|
126
|
+
case Position.Top:
|
|
127
|
+
return {
|
|
128
|
+
x: node.x + node.width / 2,
|
|
129
|
+
y: node.y
|
|
130
|
+
};
|
|
131
|
+
default:
|
|
132
|
+
return {
|
|
133
|
+
x: node.x + node.width / 2,
|
|
134
|
+
y: node.y + node.height
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function round(value) {
|
|
139
|
+
return Math.round(value * 100) / 100;
|
|
140
|
+
}
|
|
141
|
+
function arrowHead(tip, side, strokeWidth) {
|
|
142
|
+
const into = inward[side];
|
|
143
|
+
const length = strokeWidth * 4;
|
|
144
|
+
const half = strokeWidth * 3 / 2;
|
|
145
|
+
const base = {
|
|
146
|
+
x: tip.x - into.x * length,
|
|
147
|
+
y: tip.y - into.y * length
|
|
148
|
+
};
|
|
149
|
+
const across = {
|
|
150
|
+
x: -into.y,
|
|
151
|
+
y: into.x
|
|
152
|
+
};
|
|
153
|
+
const a = {
|
|
154
|
+
x: base.x + across.x * half,
|
|
155
|
+
y: base.y + across.y * half
|
|
156
|
+
};
|
|
157
|
+
const b = {
|
|
158
|
+
x: base.x - across.x * half,
|
|
159
|
+
y: base.y - across.y * half
|
|
160
|
+
};
|
|
161
|
+
return `M ${round(tip.x)} ${round(tip.y)} L ${round(a.x)} ${round(a.y)} L ${round(b.x)} ${round(b.y)} Z`;
|
|
162
|
+
}
|
|
163
|
+
function planGraphLayout(input) {
|
|
164
|
+
const edges = usableEdges(input.nodes, input.edges);
|
|
165
|
+
const placed = placeNodes(input, edges);
|
|
166
|
+
const {
|
|
167
|
+
margin
|
|
168
|
+
} = input;
|
|
169
|
+
const nodes = input.nodes.map(node => {
|
|
170
|
+
const at = placed.get(node.id) ?? {
|
|
171
|
+
x: 0,
|
|
172
|
+
y: 0
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
...node,
|
|
176
|
+
x: round(at.x + margin),
|
|
177
|
+
y: round(at.y + margin)
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
const byId = new Map(nodes.map(node => [node.id, node]));
|
|
181
|
+
const boxes = nodes.map(node => ({
|
|
182
|
+
id: node.id,
|
|
183
|
+
x: node.x,
|
|
184
|
+
y: node.y,
|
|
185
|
+
width: node.width,
|
|
186
|
+
height: node.height
|
|
187
|
+
}));
|
|
188
|
+
const side = sides[input.direction];
|
|
189
|
+
const planned = edges.map(edge => {
|
|
190
|
+
const source = byId.get(edge.source);
|
|
191
|
+
const target = byId.get(edge.target);
|
|
192
|
+
const from = anchor(source, side.out);
|
|
193
|
+
const tip = anchor(target, side.in);
|
|
194
|
+
const style = resolveEdgeStyle({
|
|
195
|
+
kind: edge.kind ?? "flow",
|
|
196
|
+
borderWidth: "small",
|
|
197
|
+
animation: "none"
|
|
198
|
+
});
|
|
199
|
+
const geometry = {
|
|
200
|
+
sourceX: from.x,
|
|
201
|
+
sourceY: from.y,
|
|
202
|
+
targetX: tip.x,
|
|
203
|
+
targetY: tip.y,
|
|
204
|
+
sourcePosition: side.out,
|
|
205
|
+
targetPosition: side.in
|
|
206
|
+
};
|
|
207
|
+
const [d] = buildEdgePath(style.path, geometry, {
|
|
208
|
+
boxes,
|
|
209
|
+
clearance: edgeClearance
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
id: graphEdgeId(edge),
|
|
213
|
+
source: edge.source,
|
|
214
|
+
target: edge.target,
|
|
215
|
+
d,
|
|
216
|
+
head: arrowHead(tip, side.in, input.strokeWidth * (edge.emphasis ? 2 : 1)),
|
|
217
|
+
tip,
|
|
218
|
+
stroke: edge.emphasis ? "$accentColor" : style.stroke,
|
|
219
|
+
...(style.strokeDasharray ? {
|
|
220
|
+
dash: style.strokeDasharray
|
|
221
|
+
} : {}),
|
|
222
|
+
emphasis: edge.emphasis ?? false
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
const width = nodes.reduce((most, node) => Math.max(most, node.x + node.width), 0) + margin;
|
|
226
|
+
const height = nodes.reduce((most, node) => Math.max(most, node.y + node.height), 0) + margin;
|
|
227
|
+
return {
|
|
228
|
+
width: round(width),
|
|
229
|
+
height: round(height),
|
|
230
|
+
nodes,
|
|
231
|
+
edges: planned
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
export { arrowHead, graphEdgeId, planGraphLayout, usableEdges };
|
|
235
|
+
//# sourceMappingURL=plan.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["edgeClearance","buildEdgePath","resolveEdgeStyle","layoutWithDagre","Position","sides","LR","out","Right","in","Left","TB","Bottom","Top","inward","x","y","graphEdgeId","edge","id","source","target","usableEdges","nodes","edges","known","Set","map","node","seen","kept","has","add","push","placeNodes","input","placed","Map","positions","set","linked","flatMap","graphNodes","filter","isolated","dagWidth","dagHeight","length","result","position","options","direction","nodeSpacing","rankSpacing","at","Math","max","width","height","wrap","wrapWidth","rowHeight","anchor","side","round","value","arrowHead","tip","strokeWidth","into","half","base","across","a","b","planGraphLayout","margin","get","byId","boxes","planned","from","style","kind","borderWidth","animation","geometry","sourceX","sourceY","targetX","targetY","sourcePosition","targetPosition","d","path","clearance","head","emphasis","stroke","strokeDasharray","dash","reduce","most"],"sources":["../../../src/graphLayout/plan.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,aAAA,QAAqB;AAC9B,SAASC,aAAA,QAAqB;AAE9B,SAASC,gBAAA,QAAwB;AACjC,SAASC,eAAA,QAAuB;AAEhC,SAASC,QAAA,QAAgB;AAsDzB,MAAMC,KAAA,GAAmF;EACvFC,EAAA,EAA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CAAC;MAC/DF,QAAA,EAAU/E,IAAA,CAAK+E,QAAA,IAAY;IAC7B;EACF,CAAC;EACD,MAAMxC,KAAA,GAAQlC,KAAA,CAAM8E,MAAA,CAAO,CAACC,IAAA,EAAM1E,IAAA,KAAS2B,IAAA,CAAKC,GAAA,CAAI8C,IAAA,EAAM1E,IAAA,CAAKb,CAAA,GAAIa,IAAA,CAAK6B,KAAK,GAAG,CAAC,IAAImB,MAAA;EACrF,MAAMlB,MAAA,GAASnC,KAAA,CAAM8E,MAAA,CAAO,CAACC,IAAA,EAAM1E,IAAA,KAAS2B,IAAA,CAAKC,GAAA,CAAI8C,IAAA,EAAM1E,IAAA,CAAKZ,CAAA,GAAIY,IAAA,CAAK8B,MAAM,GAAG,CAAC,IAAIkB,MAAA;EACvF,OAAO;IAAEnB,KAAA,EAAOO,KAAA,CAAMP,KAAK;IAAGC,MAAA,EAAQM,KAAA,CAAMN,MAAM;IAAGnC,KAAA;IAAOC,KAAA,EAAOwD;EAAQ;AAC7E","ignoreList":[]}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { edgeClearance } from "../edges/edgeRoute.native.js";
|
|
2
|
+
import { buildEdgePath } from "../edges/edgePath.native.js";
|
|
3
|
+
import { resolveEdgeStyle } from "../edges/edgeStyle.native.js";
|
|
4
|
+
import { layoutWithDagre } from "../layout/dagre.native.js";
|
|
5
|
+
import { Position } from "../react-flow/xyPaths.native.js";
|
|
6
|
+
var sides = {
|
|
7
|
+
LR: {
|
|
8
|
+
out: Position.Right,
|
|
9
|
+
in: Position.Left
|
|
10
|
+
},
|
|
11
|
+
TB: {
|
|
12
|
+
out: Position.Bottom,
|
|
13
|
+
in: Position.Top
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var inward = {
|
|
17
|
+
[Position.Left]: {
|
|
18
|
+
x: 1,
|
|
19
|
+
y: 0
|
|
20
|
+
},
|
|
21
|
+
[Position.Right]: {
|
|
22
|
+
x: -1,
|
|
23
|
+
y: 0
|
|
24
|
+
},
|
|
25
|
+
[Position.Top]: {
|
|
26
|
+
x: 0,
|
|
27
|
+
y: 1
|
|
28
|
+
},
|
|
29
|
+
[Position.Bottom]: {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: -1
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function graphEdgeId(edge) {
|
|
35
|
+
var _edge_id;
|
|
36
|
+
return (_edge_id = edge.id) !== null && _edge_id !== void 0 ? _edge_id : `${edge.source}
|
|
37
|
+
${edge.target}`;
|
|
38
|
+
}
|
|
39
|
+
function usableEdges(nodes, edges) {
|
|
40
|
+
var known = new Set(nodes.map(function (node) {
|
|
41
|
+
return node.id;
|
|
42
|
+
}));
|
|
43
|
+
var seen = /* @__PURE__ */new Set();
|
|
44
|
+
var kept = [];
|
|
45
|
+
var _iteratorNormalCompletion = true,
|
|
46
|
+
_didIteratorError = false,
|
|
47
|
+
_iteratorError = void 0;
|
|
48
|
+
try {
|
|
49
|
+
for (var _iterator = edges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
50
|
+
var edge = _step.value;
|
|
51
|
+
if (edge.source === edge.target || !known.has(edge.source) || !known.has(edge.target)) continue;
|
|
52
|
+
var id = graphEdgeId(edge);
|
|
53
|
+
if (seen.has(id)) continue;
|
|
54
|
+
seen.add(id);
|
|
55
|
+
kept.push(edge);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_didIteratorError = true;
|
|
59
|
+
_iteratorError = err;
|
|
60
|
+
} finally {
|
|
61
|
+
try {
|
|
62
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
63
|
+
_iterator.return();
|
|
64
|
+
}
|
|
65
|
+
} finally {
|
|
66
|
+
if (_didIteratorError) {
|
|
67
|
+
throw _iteratorError;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return kept;
|
|
72
|
+
}
|
|
73
|
+
function placeNodes(input, edges) {
|
|
74
|
+
var _input_wrapWidth;
|
|
75
|
+
var placed = /* @__PURE__ */new Map();
|
|
76
|
+
if (input.positions) {
|
|
77
|
+
var _input_positions_node_id;
|
|
78
|
+
var _iteratorNormalCompletion = true,
|
|
79
|
+
_didIteratorError = false,
|
|
80
|
+
_iteratorError = void 0;
|
|
81
|
+
try {
|
|
82
|
+
for (var _iterator = input.nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
83
|
+
var node = _step.value;
|
|
84
|
+
placed.set(node.id, (_input_positions_node_id = input.positions[node.id]) !== null && _input_positions_node_id !== void 0 ? _input_positions_node_id : {
|
|
85
|
+
x: 0,
|
|
86
|
+
y: 0
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
_didIteratorError = true;
|
|
91
|
+
_iteratorError = err;
|
|
92
|
+
} finally {
|
|
93
|
+
try {
|
|
94
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
95
|
+
_iterator.return();
|
|
96
|
+
}
|
|
97
|
+
} finally {
|
|
98
|
+
if (_didIteratorError) {
|
|
99
|
+
throw _iteratorError;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return placed;
|
|
104
|
+
}
|
|
105
|
+
var linked = new Set(edges.flatMap(function (edge) {
|
|
106
|
+
return [edge.source, edge.target];
|
|
107
|
+
}));
|
|
108
|
+
var graphNodes = input.nodes.filter(function (node3) {
|
|
109
|
+
return linked.has(node3.id);
|
|
110
|
+
});
|
|
111
|
+
var isolated = input.nodes.filter(function (node3) {
|
|
112
|
+
return !linked.has(node3.id);
|
|
113
|
+
});
|
|
114
|
+
var dagWidth = 0;
|
|
115
|
+
var dagHeight = 0;
|
|
116
|
+
if (graphNodes.length > 0) {
|
|
117
|
+
var result = layoutWithDagre({
|
|
118
|
+
nodes: graphNodes.map(function (node3) {
|
|
119
|
+
return {
|
|
120
|
+
...node3,
|
|
121
|
+
position: {
|
|
122
|
+
x: 0,
|
|
123
|
+
y: 0
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}),
|
|
127
|
+
edges: edges.map(function (edge) {
|
|
128
|
+
return {
|
|
129
|
+
id: graphEdgeId(edge),
|
|
130
|
+
source: edge.source,
|
|
131
|
+
target: edge.target
|
|
132
|
+
};
|
|
133
|
+
}),
|
|
134
|
+
options: {
|
|
135
|
+
direction: input.direction,
|
|
136
|
+
nodeSpacing: input.nodeSpacing,
|
|
137
|
+
rankSpacing: input.rankSpacing
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var _iteratorNormalCompletion1 = true,
|
|
141
|
+
_didIteratorError1 = false,
|
|
142
|
+
_iteratorError1 = void 0;
|
|
143
|
+
try {
|
|
144
|
+
for (var _iterator1 = graphNodes[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
145
|
+
var node1 = _step1.value;
|
|
146
|
+
var _result_positions_node_id;
|
|
147
|
+
var at = (_result_positions_node_id = result.positions[node1.id]) !== null && _result_positions_node_id !== void 0 ? _result_positions_node_id : {
|
|
148
|
+
x: 0,
|
|
149
|
+
y: 0
|
|
150
|
+
};
|
|
151
|
+
placed.set(node1.id, at);
|
|
152
|
+
dagWidth = Math.max(dagWidth, at.x + node1.width);
|
|
153
|
+
dagHeight = Math.max(dagHeight, at.y + node1.height);
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
_didIteratorError1 = true;
|
|
157
|
+
_iteratorError1 = err;
|
|
158
|
+
} finally {
|
|
159
|
+
try {
|
|
160
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
161
|
+
_iterator1.return();
|
|
162
|
+
}
|
|
163
|
+
} finally {
|
|
164
|
+
if (_didIteratorError1) {
|
|
165
|
+
throw _iteratorError1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
var wrap = Math.max(dagWidth, (_input_wrapWidth = input.wrapWidth) !== null && _input_wrapWidth !== void 0 ? _input_wrapWidth : 0, ...isolated.map(function (node3) {
|
|
171
|
+
return node3.width;
|
|
172
|
+
}));
|
|
173
|
+
var x = 0;
|
|
174
|
+
var y = graphNodes.length > 0 ? dagHeight + input.rankSpacing : 0;
|
|
175
|
+
var rowHeight = 0;
|
|
176
|
+
var _iteratorNormalCompletion2 = true,
|
|
177
|
+
_didIteratorError2 = false,
|
|
178
|
+
_iteratorError2 = void 0;
|
|
179
|
+
try {
|
|
180
|
+
for (var _iterator2 = isolated[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
181
|
+
var node2 = _step2.value;
|
|
182
|
+
if (x > 0 && x + node2.width > wrap) {
|
|
183
|
+
x = 0;
|
|
184
|
+
y += rowHeight + input.nodeSpacing;
|
|
185
|
+
rowHeight = 0;
|
|
186
|
+
}
|
|
187
|
+
placed.set(node2.id, {
|
|
188
|
+
x,
|
|
189
|
+
y
|
|
190
|
+
});
|
|
191
|
+
x += node2.width + input.nodeSpacing;
|
|
192
|
+
rowHeight = Math.max(rowHeight, node2.height);
|
|
193
|
+
}
|
|
194
|
+
} catch (err) {
|
|
195
|
+
_didIteratorError2 = true;
|
|
196
|
+
_iteratorError2 = err;
|
|
197
|
+
} finally {
|
|
198
|
+
try {
|
|
199
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
200
|
+
_iterator2.return();
|
|
201
|
+
}
|
|
202
|
+
} finally {
|
|
203
|
+
if (_didIteratorError2) {
|
|
204
|
+
throw _iteratorError2;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return placed;
|
|
209
|
+
}
|
|
210
|
+
function anchor(node, side) {
|
|
211
|
+
switch (side) {
|
|
212
|
+
case Position.Left:
|
|
213
|
+
return {
|
|
214
|
+
x: node.x,
|
|
215
|
+
y: node.y + node.height / 2
|
|
216
|
+
};
|
|
217
|
+
case Position.Right:
|
|
218
|
+
return {
|
|
219
|
+
x: node.x + node.width,
|
|
220
|
+
y: node.y + node.height / 2
|
|
221
|
+
};
|
|
222
|
+
case Position.Top:
|
|
223
|
+
return {
|
|
224
|
+
x: node.x + node.width / 2,
|
|
225
|
+
y: node.y
|
|
226
|
+
};
|
|
227
|
+
default:
|
|
228
|
+
return {
|
|
229
|
+
x: node.x + node.width / 2,
|
|
230
|
+
y: node.y + node.height
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function round(value) {
|
|
235
|
+
return Math.round(value * 100) / 100;
|
|
236
|
+
}
|
|
237
|
+
function arrowHead(tip, side, strokeWidth) {
|
|
238
|
+
var into = inward[side];
|
|
239
|
+
var length = strokeWidth * 4;
|
|
240
|
+
var half = strokeWidth * 3 / 2;
|
|
241
|
+
var base = {
|
|
242
|
+
x: tip.x - into.x * length,
|
|
243
|
+
y: tip.y - into.y * length
|
|
244
|
+
};
|
|
245
|
+
var across = {
|
|
246
|
+
x: -into.y,
|
|
247
|
+
y: into.x
|
|
248
|
+
};
|
|
249
|
+
var a = {
|
|
250
|
+
x: base.x + across.x * half,
|
|
251
|
+
y: base.y + across.y * half
|
|
252
|
+
};
|
|
253
|
+
var b = {
|
|
254
|
+
x: base.x - across.x * half,
|
|
255
|
+
y: base.y - across.y * half
|
|
256
|
+
};
|
|
257
|
+
return `M ${round(tip.x)} ${round(tip.y)} L ${round(a.x)} ${round(a.y)} L ${round(b.x)} ${round(b.y)} Z`;
|
|
258
|
+
}
|
|
259
|
+
function planGraphLayout(input) {
|
|
260
|
+
var edges = usableEdges(input.nodes, input.edges);
|
|
261
|
+
var placed = placeNodes(input, edges);
|
|
262
|
+
var {
|
|
263
|
+
margin
|
|
264
|
+
} = input;
|
|
265
|
+
var nodes = input.nodes.map(function (node) {
|
|
266
|
+
var _placed_get;
|
|
267
|
+
var at = (_placed_get = placed.get(node.id)) !== null && _placed_get !== void 0 ? _placed_get : {
|
|
268
|
+
x: 0,
|
|
269
|
+
y: 0
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
...node,
|
|
273
|
+
x: round(at.x + margin),
|
|
274
|
+
y: round(at.y + margin)
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
var byId = new Map(nodes.map(function (node) {
|
|
278
|
+
return [node.id, node];
|
|
279
|
+
}));
|
|
280
|
+
var boxes = nodes.map(function (node) {
|
|
281
|
+
return {
|
|
282
|
+
id: node.id,
|
|
283
|
+
x: node.x,
|
|
284
|
+
y: node.y,
|
|
285
|
+
width: node.width,
|
|
286
|
+
height: node.height
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
var side = sides[input.direction];
|
|
290
|
+
var planned = edges.map(function (edge) {
|
|
291
|
+
var _edge_kind, _edge_emphasis;
|
|
292
|
+
var source = byId.get(edge.source);
|
|
293
|
+
var target = byId.get(edge.target);
|
|
294
|
+
var from = anchor(source, side.out);
|
|
295
|
+
var tip = anchor(target, side.in);
|
|
296
|
+
var style = resolveEdgeStyle({
|
|
297
|
+
kind: (_edge_kind = edge.kind) !== null && _edge_kind !== void 0 ? _edge_kind : "flow",
|
|
298
|
+
borderWidth: "small",
|
|
299
|
+
animation: "none"
|
|
300
|
+
});
|
|
301
|
+
var geometry = {
|
|
302
|
+
sourceX: from.x,
|
|
303
|
+
sourceY: from.y,
|
|
304
|
+
targetX: tip.x,
|
|
305
|
+
targetY: tip.y,
|
|
306
|
+
sourcePosition: side.out,
|
|
307
|
+
targetPosition: side.in
|
|
308
|
+
};
|
|
309
|
+
var [d] = buildEdgePath(style.path, geometry, {
|
|
310
|
+
boxes,
|
|
311
|
+
clearance: edgeClearance
|
|
312
|
+
});
|
|
313
|
+
return {
|
|
314
|
+
id: graphEdgeId(edge),
|
|
315
|
+
source: edge.source,
|
|
316
|
+
target: edge.target,
|
|
317
|
+
d,
|
|
318
|
+
head: arrowHead(tip, side.in, input.strokeWidth * (edge.emphasis ? 2 : 1)),
|
|
319
|
+
tip,
|
|
320
|
+
stroke: edge.emphasis ? "$accentColor" : style.stroke,
|
|
321
|
+
...(style.strokeDasharray ? {
|
|
322
|
+
dash: style.strokeDasharray
|
|
323
|
+
} : {}),
|
|
324
|
+
emphasis: (_edge_emphasis = edge.emphasis) !== null && _edge_emphasis !== void 0 ? _edge_emphasis : false
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
var width = nodes.reduce(function (most, node) {
|
|
328
|
+
return Math.max(most, node.x + node.width);
|
|
329
|
+
}, 0) + margin;
|
|
330
|
+
var height = nodes.reduce(function (most, node) {
|
|
331
|
+
return Math.max(most, node.y + node.height);
|
|
332
|
+
}, 0) + margin;
|
|
333
|
+
return {
|
|
334
|
+
width: round(width),
|
|
335
|
+
height: round(height),
|
|
336
|
+
nodes,
|
|
337
|
+
edges: planned
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
export { arrowHead, graphEdgeId, planGraphLayout, usableEdges };
|
|
341
|
+
//# sourceMappingURL=plan.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["edgeClearance","buildEdgePath","resolveEdgeStyle","layoutWithDagre","Position","sides","LR","out","Right","in","Left","TB","Bottom","Top","inward","x","y","graphEdgeId","edge","_edge_id","id","source","target","usableEdges","nodes","edges","known","Set","map","node","seen","kept","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","value","has","add","push","err","return","placeNodes","input","_input_wrapWidth","placed","Map","positions","_input_positions_node_id","set","linked","flatMap","graphNodes","filter","node3","isolated","dagWidth","dagHeight","length","result","position","options","direction","nodeSpacing","rankSpacing","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_iterator1","_step1","node1","_result_positions_node_id","at","Math","max","width","height"],"sources":["../../../src/graphLayout/plan.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,aA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