@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,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var plan_exports = {};
|
|
26
|
+
__export(plan_exports, {
|
|
27
|
+
arrowHead: () => arrowHead,
|
|
28
|
+
graphEdgeId: () => graphEdgeId,
|
|
29
|
+
planGraphLayout: () => planGraphLayout,
|
|
30
|
+
usableEdges: () => usableEdges
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plan_exports);
|
|
33
|
+
var import_edgeRoute = require("../edges/edgeRoute.native.js");
|
|
34
|
+
var import_edgePath = require("../edges/edgePath.native.js");
|
|
35
|
+
var import_edgeStyle = require("../edges/edgeStyle.native.js");
|
|
36
|
+
var import_dagre = require("../layout/dagre.native.js");
|
|
37
|
+
var import_xyPaths = require("../react-flow/xyPaths.native.js");
|
|
38
|
+
var sides = {
|
|
39
|
+
LR: {
|
|
40
|
+
out: import_xyPaths.Position.Right,
|
|
41
|
+
in: import_xyPaths.Position.Left
|
|
42
|
+
},
|
|
43
|
+
TB: {
|
|
44
|
+
out: import_xyPaths.Position.Bottom,
|
|
45
|
+
in: import_xyPaths.Position.Top
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var inward = {
|
|
49
|
+
[import_xyPaths.Position.Left]: {
|
|
50
|
+
x: 1,
|
|
51
|
+
y: 0
|
|
52
|
+
},
|
|
53
|
+
[import_xyPaths.Position.Right]: {
|
|
54
|
+
x: -1,
|
|
55
|
+
y: 0
|
|
56
|
+
},
|
|
57
|
+
[import_xyPaths.Position.Top]: {
|
|
58
|
+
x: 0,
|
|
59
|
+
y: 1
|
|
60
|
+
},
|
|
61
|
+
[import_xyPaths.Position.Bottom]: {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: -1
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function graphEdgeId(edge) {
|
|
67
|
+
var _edge_id;
|
|
68
|
+
return (_edge_id = edge.id) !== null && _edge_id !== void 0 ? _edge_id : `${edge.source}
|
|
69
|
+
${edge.target}`;
|
|
70
|
+
}
|
|
71
|
+
function usableEdges(nodes, edges) {
|
|
72
|
+
var known = new Set(nodes.map(function (node) {
|
|
73
|
+
return node.id;
|
|
74
|
+
}));
|
|
75
|
+
var seen = /* @__PURE__ */new Set();
|
|
76
|
+
var kept = [];
|
|
77
|
+
var _iteratorNormalCompletion = true,
|
|
78
|
+
_didIteratorError = false,
|
|
79
|
+
_iteratorError = void 0;
|
|
80
|
+
try {
|
|
81
|
+
for (var _iterator = edges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
82
|
+
var edge = _step.value;
|
|
83
|
+
if (edge.source === edge.target || !known.has(edge.source) || !known.has(edge.target)) continue;
|
|
84
|
+
var id = graphEdgeId(edge);
|
|
85
|
+
if (seen.has(id)) continue;
|
|
86
|
+
seen.add(id);
|
|
87
|
+
kept.push(edge);
|
|
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 kept;
|
|
104
|
+
}
|
|
105
|
+
function placeNodes(input, edges) {
|
|
106
|
+
var _input_wrapWidth;
|
|
107
|
+
var placed = /* @__PURE__ */new Map();
|
|
108
|
+
if (input.positions) {
|
|
109
|
+
var _input_positions_node_id;
|
|
110
|
+
var _iteratorNormalCompletion = true,
|
|
111
|
+
_didIteratorError = false,
|
|
112
|
+
_iteratorError = void 0;
|
|
113
|
+
try {
|
|
114
|
+
for (var _iterator = input.nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
115
|
+
var node = _step.value;
|
|
116
|
+
placed.set(node.id, (_input_positions_node_id = input.positions[node.id]) !== null && _input_positions_node_id !== void 0 ? _input_positions_node_id : {
|
|
117
|
+
x: 0,
|
|
118
|
+
y: 0
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
} catch (err) {
|
|
122
|
+
_didIteratorError = true;
|
|
123
|
+
_iteratorError = err;
|
|
124
|
+
} finally {
|
|
125
|
+
try {
|
|
126
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
127
|
+
_iterator.return();
|
|
128
|
+
}
|
|
129
|
+
} finally {
|
|
130
|
+
if (_didIteratorError) {
|
|
131
|
+
throw _iteratorError;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return placed;
|
|
136
|
+
}
|
|
137
|
+
var linked = new Set(edges.flatMap(function (edge) {
|
|
138
|
+
return [edge.source, edge.target];
|
|
139
|
+
}));
|
|
140
|
+
var graphNodes = input.nodes.filter(function (node3) {
|
|
141
|
+
return linked.has(node3.id);
|
|
142
|
+
});
|
|
143
|
+
var isolated = input.nodes.filter(function (node3) {
|
|
144
|
+
return !linked.has(node3.id);
|
|
145
|
+
});
|
|
146
|
+
var dagWidth = 0;
|
|
147
|
+
var dagHeight = 0;
|
|
148
|
+
if (graphNodes.length > 0) {
|
|
149
|
+
var result = (0, import_dagre.layoutWithDagre)({
|
|
150
|
+
nodes: graphNodes.map(function (node3) {
|
|
151
|
+
return {
|
|
152
|
+
...node3,
|
|
153
|
+
position: {
|
|
154
|
+
x: 0,
|
|
155
|
+
y: 0
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}),
|
|
159
|
+
edges: edges.map(function (edge) {
|
|
160
|
+
return {
|
|
161
|
+
id: graphEdgeId(edge),
|
|
162
|
+
source: edge.source,
|
|
163
|
+
target: edge.target
|
|
164
|
+
};
|
|
165
|
+
}),
|
|
166
|
+
options: {
|
|
167
|
+
direction: input.direction,
|
|
168
|
+
nodeSpacing: input.nodeSpacing,
|
|
169
|
+
rankSpacing: input.rankSpacing
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var _iteratorNormalCompletion1 = true,
|
|
173
|
+
_didIteratorError1 = false,
|
|
174
|
+
_iteratorError1 = void 0;
|
|
175
|
+
try {
|
|
176
|
+
for (var _iterator1 = graphNodes[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
177
|
+
var node1 = _step1.value;
|
|
178
|
+
var _result_positions_node_id;
|
|
179
|
+
var at = (_result_positions_node_id = result.positions[node1.id]) !== null && _result_positions_node_id !== void 0 ? _result_positions_node_id : {
|
|
180
|
+
x: 0,
|
|
181
|
+
y: 0
|
|
182
|
+
};
|
|
183
|
+
placed.set(node1.id, at);
|
|
184
|
+
dagWidth = Math.max(dagWidth, at.x + node1.width);
|
|
185
|
+
dagHeight = Math.max(dagHeight, at.y + node1.height);
|
|
186
|
+
}
|
|
187
|
+
} catch (err) {
|
|
188
|
+
_didIteratorError1 = true;
|
|
189
|
+
_iteratorError1 = err;
|
|
190
|
+
} finally {
|
|
191
|
+
try {
|
|
192
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
193
|
+
_iterator1.return();
|
|
194
|
+
}
|
|
195
|
+
} finally {
|
|
196
|
+
if (_didIteratorError1) {
|
|
197
|
+
throw _iteratorError1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
var wrap = Math.max(dagWidth, (_input_wrapWidth = input.wrapWidth) !== null && _input_wrapWidth !== void 0 ? _input_wrapWidth : 0, ...isolated.map(function (node3) {
|
|
203
|
+
return node3.width;
|
|
204
|
+
}));
|
|
205
|
+
var x = 0;
|
|
206
|
+
var y = graphNodes.length > 0 ? dagHeight + input.rankSpacing : 0;
|
|
207
|
+
var rowHeight = 0;
|
|
208
|
+
var _iteratorNormalCompletion2 = true,
|
|
209
|
+
_didIteratorError2 = false,
|
|
210
|
+
_iteratorError2 = void 0;
|
|
211
|
+
try {
|
|
212
|
+
for (var _iterator2 = isolated[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
213
|
+
var node2 = _step2.value;
|
|
214
|
+
if (x > 0 && x + node2.width > wrap) {
|
|
215
|
+
x = 0;
|
|
216
|
+
y += rowHeight + input.nodeSpacing;
|
|
217
|
+
rowHeight = 0;
|
|
218
|
+
}
|
|
219
|
+
placed.set(node2.id, {
|
|
220
|
+
x,
|
|
221
|
+
y
|
|
222
|
+
});
|
|
223
|
+
x += node2.width + input.nodeSpacing;
|
|
224
|
+
rowHeight = Math.max(rowHeight, node2.height);
|
|
225
|
+
}
|
|
226
|
+
} catch (err) {
|
|
227
|
+
_didIteratorError2 = true;
|
|
228
|
+
_iteratorError2 = err;
|
|
229
|
+
} finally {
|
|
230
|
+
try {
|
|
231
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
232
|
+
_iterator2.return();
|
|
233
|
+
}
|
|
234
|
+
} finally {
|
|
235
|
+
if (_didIteratorError2) {
|
|
236
|
+
throw _iteratorError2;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return placed;
|
|
241
|
+
}
|
|
242
|
+
function anchor(node, side) {
|
|
243
|
+
switch (side) {
|
|
244
|
+
case import_xyPaths.Position.Left:
|
|
245
|
+
return {
|
|
246
|
+
x: node.x,
|
|
247
|
+
y: node.y + node.height / 2
|
|
248
|
+
};
|
|
249
|
+
case import_xyPaths.Position.Right:
|
|
250
|
+
return {
|
|
251
|
+
x: node.x + node.width,
|
|
252
|
+
y: node.y + node.height / 2
|
|
253
|
+
};
|
|
254
|
+
case import_xyPaths.Position.Top:
|
|
255
|
+
return {
|
|
256
|
+
x: node.x + node.width / 2,
|
|
257
|
+
y: node.y
|
|
258
|
+
};
|
|
259
|
+
default:
|
|
260
|
+
return {
|
|
261
|
+
x: node.x + node.width / 2,
|
|
262
|
+
y: node.y + node.height
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function round(value) {
|
|
267
|
+
return Math.round(value * 100) / 100;
|
|
268
|
+
}
|
|
269
|
+
function arrowHead(tip, side, strokeWidth) {
|
|
270
|
+
var into = inward[side];
|
|
271
|
+
var length = strokeWidth * 4;
|
|
272
|
+
var half = strokeWidth * 3 / 2;
|
|
273
|
+
var base = {
|
|
274
|
+
x: tip.x - into.x * length,
|
|
275
|
+
y: tip.y - into.y * length
|
|
276
|
+
};
|
|
277
|
+
var across = {
|
|
278
|
+
x: -into.y,
|
|
279
|
+
y: into.x
|
|
280
|
+
};
|
|
281
|
+
var a = {
|
|
282
|
+
x: base.x + across.x * half,
|
|
283
|
+
y: base.y + across.y * half
|
|
284
|
+
};
|
|
285
|
+
var b = {
|
|
286
|
+
x: base.x - across.x * half,
|
|
287
|
+
y: base.y - across.y * half
|
|
288
|
+
};
|
|
289
|
+
return `M ${round(tip.x)} ${round(tip.y)} L ${round(a.x)} ${round(a.y)} L ${round(b.x)} ${round(b.y)} Z`;
|
|
290
|
+
}
|
|
291
|
+
function planGraphLayout(input) {
|
|
292
|
+
var edges = usableEdges(input.nodes, input.edges);
|
|
293
|
+
var placed = placeNodes(input, edges);
|
|
294
|
+
var {
|
|
295
|
+
margin
|
|
296
|
+
} = input;
|
|
297
|
+
var nodes = input.nodes.map(function (node) {
|
|
298
|
+
var _placed_get;
|
|
299
|
+
var at = (_placed_get = placed.get(node.id)) !== null && _placed_get !== void 0 ? _placed_get : {
|
|
300
|
+
x: 0,
|
|
301
|
+
y: 0
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
...node,
|
|
305
|
+
x: round(at.x + margin),
|
|
306
|
+
y: round(at.y + margin)
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
var byId = new Map(nodes.map(function (node) {
|
|
310
|
+
return [node.id, node];
|
|
311
|
+
}));
|
|
312
|
+
var boxes = nodes.map(function (node) {
|
|
313
|
+
return {
|
|
314
|
+
id: node.id,
|
|
315
|
+
x: node.x,
|
|
316
|
+
y: node.y,
|
|
317
|
+
width: node.width,
|
|
318
|
+
height: node.height
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
var side = sides[input.direction];
|
|
322
|
+
var planned = edges.map(function (edge) {
|
|
323
|
+
var _edge_kind, _edge_emphasis;
|
|
324
|
+
var source = byId.get(edge.source);
|
|
325
|
+
var target = byId.get(edge.target);
|
|
326
|
+
var from = anchor(source, side.out);
|
|
327
|
+
var tip = anchor(target, side.in);
|
|
328
|
+
var style = (0, import_edgeStyle.resolveEdgeStyle)({
|
|
329
|
+
kind: (_edge_kind = edge.kind) !== null && _edge_kind !== void 0 ? _edge_kind : "flow",
|
|
330
|
+
borderWidth: "small",
|
|
331
|
+
animation: "none"
|
|
332
|
+
});
|
|
333
|
+
var geometry = {
|
|
334
|
+
sourceX: from.x,
|
|
335
|
+
sourceY: from.y,
|
|
336
|
+
targetX: tip.x,
|
|
337
|
+
targetY: tip.y,
|
|
338
|
+
sourcePosition: side.out,
|
|
339
|
+
targetPosition: side.in
|
|
340
|
+
};
|
|
341
|
+
var [d] = (0, import_edgePath.buildEdgePath)(style.path, geometry, {
|
|
342
|
+
boxes,
|
|
343
|
+
clearance: import_edgeRoute.edgeClearance
|
|
344
|
+
});
|
|
345
|
+
return {
|
|
346
|
+
id: graphEdgeId(edge),
|
|
347
|
+
source: edge.source,
|
|
348
|
+
target: edge.target,
|
|
349
|
+
d,
|
|
350
|
+
head: arrowHead(tip, side.in, input.strokeWidth * (edge.emphasis ? 2 : 1)),
|
|
351
|
+
tip,
|
|
352
|
+
stroke: edge.emphasis ? "$accentColor" : style.stroke,
|
|
353
|
+
...(style.strokeDasharray ? {
|
|
354
|
+
dash: style.strokeDasharray
|
|
355
|
+
} : {}),
|
|
356
|
+
emphasis: (_edge_emphasis = edge.emphasis) !== null && _edge_emphasis !== void 0 ? _edge_emphasis : false
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
var width = nodes.reduce(function (most, node) {
|
|
360
|
+
return Math.max(most, node.x + node.width);
|
|
361
|
+
}, 0) + margin;
|
|
362
|
+
var height = nodes.reduce(function (most, node) {
|
|
363
|
+
return Math.max(most, node.y + node.height);
|
|
364
|
+
}, 0) + margin;
|
|
365
|
+
return {
|
|
366
|
+
width: round(width),
|
|
367
|
+
height: round(height),
|
|
368
|
+
nodes,
|
|
369
|
+
edges: planned
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
//# sourceMappingURL=plan.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","plan_exports","__export","arrowHead","graphEdgeId","planGraphLayout","usableEdges","module","exports","import_edgeRoute","require","import_edgePath","import_edgeStyle","import_dagre","import_xyPaths","sides","LR","out","Position","Right","in","Left","TB","Bottom","Top","inward","x","y","edge","_edge_id","id","source","target","nodes","edges","known","Set","map","node","seen","kept","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","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","layoutWithDagre","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":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAZ,YAA8B,CAAAK,YAAA;AAC9B,IAAAQ,gBAAA,GAA8BC,OAAA;AAE9B,IAAAC,eAAA,GAAAD,OAAiC;AACjC,IAAAE,gBAAgC,GAAAF,OAAA;AAEhC,IAAAG,YAAA,GAAAH,OAAyB;AAsDzB,IAAAI,cAAyF,GAAAJ,OAAA;AAAA,IACvFK,KAAM;EACNC,EAAA,EAAI;IACNC,GAAA,EAAAH,cAAA,CAAAI,QAAA,CAAAC,KAAA;IAEAC,EAAM,EAAAN,cAA+B,CAAAI,QAAA,CAAAG;EACnC,CAAC;EACDC,EAAC;IACAL,GAAA,EAAAH,cAAA,CAAAI,QAAY,CAAGK,MAAK;IACpBH,EAAA,EAAAN,cAAA,CAAAI,QAAS,CAAAM;EACZ;AAEO;AACL,IAAAC,MAAO;EAA8B,CAAAX,cAAW,CAAAI,QAAA,CAAAG,IAAA;IAClDK,CAAA;IAEOC,CAAA;EAIL;EACA,CAAAb,cAAa,CAAAI,QAAA,CAAAC,KAAA,GAAI;IACjBO,CAAA,GAAM;IACNC,CAAA;EACE;EACA,CAAAb,cAAW,CAAAI,QAAA,CAAYM,GAAA,GAAI;IAC3BE,CAAA,GAAI;IACJC,CAAA;EACA;EACF,CAAAb,cAAA,CAAAI,QA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A,cAAAA,yBAAA;UACb3D,CAAA;UACAC,CAAA,EAAM;QACN;QACA+B,MAAQ,CAAAI,GAAA,CAAKsB,KAAA,CAAAtD,EAAA,EAAAwD,EAAW;QACxBjB,QAAU,GAAAkB,IAAA,CAAAC,GAAA,CAAAnB,QAAoB,EAAAiB,EAAA,CAAM5D,CAAA,GAAA0D,KAAM,CAAAK,KAAA;QAC1CnB,SAAU,GAAAiB,IAAK,CAAAC,GAAA,CAAAlB,SAAY,EAAAgB,EAAA,CAAA3D,CAAA,GAAAyD,KAAA,CAAAM,MAAA;MAC7B;IACD,SAAArC,GAAA;MACD2B,kBAAoB,OAAQ;MAC5BC,eAAe,GAAM5B,GAAA;IACrB,UAAS;MACX","ignoreList":[]}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var viewMath_exports = {};
|
|
24
|
+
__export(viewMath_exports, {
|
|
25
|
+
clampOffset: () => clampOffset,
|
|
26
|
+
clampView: () => clampView,
|
|
27
|
+
dotArea: () => dotArea,
|
|
28
|
+
dotPath: () => dotPath,
|
|
29
|
+
dotPhase: () => dotPhase,
|
|
30
|
+
dotPitch: () => dotPitch,
|
|
31
|
+
fittedView: () => fittedView,
|
|
32
|
+
graphZoom: () => graphZoom,
|
|
33
|
+
keyedView: () => keyedView,
|
|
34
|
+
leastScale: () => leastScale,
|
|
35
|
+
sameArea: () => sameArea,
|
|
36
|
+
toggledView: () => toggledView,
|
|
37
|
+
zoomAt: () => zoomAt
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(viewMath_exports);
|
|
40
|
+
const graphZoom = {
|
|
41
|
+
floor: 0.1,
|
|
42
|
+
step: 1.25,
|
|
43
|
+
settleMs: 220
|
|
44
|
+
};
|
|
45
|
+
function leastScale(content, viewport) {
|
|
46
|
+
"worklet";
|
|
47
|
+
|
|
48
|
+
if (content.width <= 0 || content.height <= 0 || viewport.width <= 0 || viewport.height <= 0) return 1;
|
|
49
|
+
const fit = Math.min(viewport.width / content.width, viewport.height / content.height);
|
|
50
|
+
return Math.min(1, Math.max(graphZoom.floor, fit));
|
|
51
|
+
}
|
|
52
|
+
function clampOffset(offset, content, viewport) {
|
|
53
|
+
"worklet";
|
|
54
|
+
|
|
55
|
+
if (content <= viewport) return (viewport - content) / 2;
|
|
56
|
+
return Math.min(0, Math.max(viewport - content, offset));
|
|
57
|
+
}
|
|
58
|
+
function clampView(view, content, viewport) {
|
|
59
|
+
"worklet";
|
|
60
|
+
|
|
61
|
+
const scale = Math.min(1, Math.max(leastScale(content, viewport), view.scale));
|
|
62
|
+
return {
|
|
63
|
+
scale,
|
|
64
|
+
x: clampOffset(view.x, content.width * scale, viewport.width),
|
|
65
|
+
y: clampOffset(view.y, content.height * scale, viewport.height)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function zoomAt(view, scale, focal, content, viewport) {
|
|
69
|
+
"worklet";
|
|
70
|
+
|
|
71
|
+
const next = Math.min(1, Math.max(leastScale(content, viewport), scale));
|
|
72
|
+
const ratio = next / view.scale;
|
|
73
|
+
return clampView({
|
|
74
|
+
scale: next,
|
|
75
|
+
x: focal.x - (focal.x - view.x) * ratio,
|
|
76
|
+
y: focal.y - (focal.y - view.y) * ratio
|
|
77
|
+
}, content, viewport);
|
|
78
|
+
}
|
|
79
|
+
function fittedView(content, viewport) {
|
|
80
|
+
"worklet";
|
|
81
|
+
|
|
82
|
+
return clampView({
|
|
83
|
+
scale: leastScale(content, viewport),
|
|
84
|
+
x: 0,
|
|
85
|
+
y: 0
|
|
86
|
+
}, content, viewport);
|
|
87
|
+
}
|
|
88
|
+
function toggledView(view, at, content, viewport) {
|
|
89
|
+
"worklet";
|
|
90
|
+
|
|
91
|
+
const least = leastScale(content, viewport);
|
|
92
|
+
return view.scale < 1 - 1e-3 ? zoomAt(view, 1, at, content, viewport) : zoomAt(view, least, at, content, viewport);
|
|
93
|
+
}
|
|
94
|
+
function keyedView(key, view, content, viewport) {
|
|
95
|
+
const centre = {
|
|
96
|
+
x: viewport.width / 2,
|
|
97
|
+
y: viewport.height / 2
|
|
98
|
+
};
|
|
99
|
+
if (key === "+" || key === "=") return zoomAt(view, view.scale * graphZoom.step, centre, content, viewport);
|
|
100
|
+
if (key === "-" || key === "_") return zoomAt(view, view.scale / graphZoom.step, centre, content, viewport);
|
|
101
|
+
if (key === "0") return zoomAt(view, 1, centre, content, viewport);
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
function dotPitch(pitch, scale) {
|
|
105
|
+
"worklet";
|
|
106
|
+
|
|
107
|
+
let spaced = pitch;
|
|
108
|
+
while (spaced * scale < pitch / 2) spaced *= 2;
|
|
109
|
+
return spaced;
|
|
110
|
+
}
|
|
111
|
+
function dotPhase(offset, scale, pitch, spaced) {
|
|
112
|
+
"worklet";
|
|
113
|
+
|
|
114
|
+
const step = spaced * scale;
|
|
115
|
+
const start = offset + pitch / 2 * scale;
|
|
116
|
+
return (start % step + step) % step - step;
|
|
117
|
+
}
|
|
118
|
+
function reachOf(offset, view, total, chunk) {
|
|
119
|
+
const start = Math.max(0, Math.floor(offset / chunk) * chunk - chunk);
|
|
120
|
+
return [start, Math.max(0, Math.min(view + chunk * 3, total - start))];
|
|
121
|
+
}
|
|
122
|
+
function dotArea(offset, viewport, canvas, chunk) {
|
|
123
|
+
const [x, width] = reachOf(offset.x, viewport.width, canvas.width, chunk);
|
|
124
|
+
const [y, height] = reachOf(offset.y, viewport.height, canvas.height, chunk);
|
|
125
|
+
return {
|
|
126
|
+
x,
|
|
127
|
+
y,
|
|
128
|
+
width,
|
|
129
|
+
height
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function dotPath(area, pitch) {
|
|
133
|
+
const runs = [];
|
|
134
|
+
const first = start => Math.ceil((start - pitch / 2) / pitch) * pitch + pitch / 2 - start;
|
|
135
|
+
for (let y = first(area.y); y < area.height; y += pitch) {
|
|
136
|
+
for (let x = first(area.x); x < area.width; x += pitch) runs.push(`M${x} ${y}h0.01`);
|
|
137
|
+
}
|
|
138
|
+
return runs.join("");
|
|
139
|
+
}
|
|
140
|
+
function sameArea(a, b) {
|
|
141
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
142
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var viewMath_exports = {};
|
|
26
|
+
__export(viewMath_exports, {
|
|
27
|
+
clampOffset: () => clampOffset,
|
|
28
|
+
clampView: () => clampView,
|
|
29
|
+
dotArea: () => dotArea,
|
|
30
|
+
dotPath: () => dotPath,
|
|
31
|
+
dotPhase: () => dotPhase,
|
|
32
|
+
dotPitch: () => dotPitch,
|
|
33
|
+
fittedView: () => fittedView,
|
|
34
|
+
graphZoom: () => graphZoom,
|
|
35
|
+
keyedView: () => keyedView,
|
|
36
|
+
leastScale: () => leastScale,
|
|
37
|
+
sameArea: () => sameArea,
|
|
38
|
+
toggledView: () => toggledView,
|
|
39
|
+
zoomAt: () => zoomAt
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(viewMath_exports);
|
|
42
|
+
var graphZoom = {
|
|
43
|
+
floor: 0.1,
|
|
44
|
+
step: 1.25,
|
|
45
|
+
settleMs: 220
|
|
46
|
+
};
|
|
47
|
+
function leastScale(content, viewport) {
|
|
48
|
+
"worklet";
|
|
49
|
+
|
|
50
|
+
if (content.width <= 0 || content.height <= 0 || viewport.width <= 0 || viewport.height <= 0) return 1;
|
|
51
|
+
var fit = Math.min(viewport.width / content.width, viewport.height / content.height);
|
|
52
|
+
return Math.min(1, Math.max(graphZoom.floor, fit));
|
|
53
|
+
}
|
|
54
|
+
function clampOffset(offset, content, viewport) {
|
|
55
|
+
"worklet";
|
|
56
|
+
|
|
57
|
+
if (content <= viewport) return (viewport - content) / 2;
|
|
58
|
+
return Math.min(0, Math.max(viewport - content, offset));
|
|
59
|
+
}
|
|
60
|
+
function clampView(view, content, viewport) {
|
|
61
|
+
"worklet";
|
|
62
|
+
|
|
63
|
+
var scale = Math.min(1, Math.max(leastScale(content, viewport), view.scale));
|
|
64
|
+
return {
|
|
65
|
+
scale,
|
|
66
|
+
x: clampOffset(view.x, content.width * scale, viewport.width),
|
|
67
|
+
y: clampOffset(view.y, content.height * scale, viewport.height)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function zoomAt(view, scale, focal, content, viewport) {
|
|
71
|
+
"worklet";
|
|
72
|
+
|
|
73
|
+
var next = Math.min(1, Math.max(leastScale(content, viewport), scale));
|
|
74
|
+
var ratio = next / view.scale;
|
|
75
|
+
return clampView({
|
|
76
|
+
scale: next,
|
|
77
|
+
x: focal.x - (focal.x - view.x) * ratio,
|
|
78
|
+
y: focal.y - (focal.y - view.y) * ratio
|
|
79
|
+
}, content, viewport);
|
|
80
|
+
}
|
|
81
|
+
function fittedView(content, viewport) {
|
|
82
|
+
"worklet";
|
|
83
|
+
|
|
84
|
+
return clampView({
|
|
85
|
+
scale: leastScale(content, viewport),
|
|
86
|
+
x: 0,
|
|
87
|
+
y: 0
|
|
88
|
+
}, content, viewport);
|
|
89
|
+
}
|
|
90
|
+
function toggledView(view, at, content, viewport) {
|
|
91
|
+
"worklet";
|
|
92
|
+
|
|
93
|
+
var least = leastScale(content, viewport);
|
|
94
|
+
return view.scale < 1 - 1e-3 ? zoomAt(view, 1, at, content, viewport) : zoomAt(view, least, at, content, viewport);
|
|
95
|
+
}
|
|
96
|
+
function keyedView(key, view, content, viewport) {
|
|
97
|
+
var centre = {
|
|
98
|
+
x: viewport.width / 2,
|
|
99
|
+
y: viewport.height / 2
|
|
100
|
+
};
|
|
101
|
+
if (key === "+" || key === "=") return zoomAt(view, view.scale * graphZoom.step, centre, content, viewport);
|
|
102
|
+
if (key === "-" || key === "_") return zoomAt(view, view.scale / graphZoom.step, centre, content, viewport);
|
|
103
|
+
if (key === "0") return zoomAt(view, 1, centre, content, viewport);
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
function dotPitch(pitch, scale) {
|
|
107
|
+
"worklet";
|
|
108
|
+
|
|
109
|
+
var spaced = pitch;
|
|
110
|
+
while (spaced * scale < pitch / 2) spaced *= 2;
|
|
111
|
+
return spaced;
|
|
112
|
+
}
|
|
113
|
+
function dotPhase(offset, scale, pitch, spaced) {
|
|
114
|
+
"worklet";
|
|
115
|
+
|
|
116
|
+
var step = spaced * scale;
|
|
117
|
+
var start = offset + pitch / 2 * scale;
|
|
118
|
+
return (start % step + step) % step - step;
|
|
119
|
+
}
|
|
120
|
+
function reachOf(offset, view, total, chunk) {
|
|
121
|
+
var start = Math.max(0, Math.floor(offset / chunk) * chunk - chunk);
|
|
122
|
+
return [start, Math.max(0, Math.min(view + chunk * 3, total - start))];
|
|
123
|
+
}
|
|
124
|
+
function dotArea(offset, viewport, canvas, chunk) {
|
|
125
|
+
var [x, width] = reachOf(offset.x, viewport.width, canvas.width, chunk);
|
|
126
|
+
var [y, height] = reachOf(offset.y, viewport.height, canvas.height, chunk);
|
|
127
|
+
return {
|
|
128
|
+
x,
|
|
129
|
+
y,
|
|
130
|
+
width,
|
|
131
|
+
height
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function dotPath(area, pitch) {
|
|
135
|
+
var runs = [];
|
|
136
|
+
var first = function first2(start) {
|
|
137
|
+
return Math.ceil((start - pitch / 2) / pitch) * pitch + pitch / 2 - start;
|
|
138
|
+
};
|
|
139
|
+
for (var y = first(area.y); y < area.height; y += pitch) {
|
|
140
|
+
for (var x = first(area.x); x < area.width; x += pitch) runs.push(`M${x} ${y}h0.01`);
|
|
141
|
+
}
|
|
142
|
+
return runs.join("");
|
|
143
|
+
}
|
|
144
|
+
function sameArea(a, b) {
|
|
145
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=viewMath.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","viewMath_exports","__export","clampOffset","clampView","dotArea","dotPath","dotPhase","dotPitch","fittedView","graphZoom","keyedView","leastScale","sameArea","toggledView","zoomAt","module","exports","floor","step","settleMs","content","viewport","width","height","fit","Math","min","max","offset","view","scale","x","y","focal","next","ratio","at","least","key","centre","pitch","spaced","start","reachOf","total","chunk","canvas","area","runs"],"sources":["../../../src/graphLayout/viewMath.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,gBAAA;AAAAC,QAAA,CAAAD,gBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,OAAA,EAAAA,CAAA,KAAAA,OAAA;EAAAC,OAAA,EAAAA,CAAA,KAAAA,OAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,MAAA,EAAAA,CAAA,KAAAA;AAAA;AAwBOC,MAAM,CAAAC,OAAA,GAAArB,YAAY,CAAAK,gBAAA;AAAA,IACvBS,SAAO;EACPQ,KAAA,EAAM;EACNC,IAAA,MAAU;EACZC,QAAA;AAEO;AACL,SAAAR,WAAAS,OAAA,EAAAC,QAAA;EACA,SAAI;;EACF,IAAAD,OAA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