@html-graph/html-graph 1.2.0 → 2.0.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/README.md +14 -7
- package/dist/{main.js → html-graph.js} +1117 -1217
- package/dist/html-graph.umd.cjs +1 -0
- package/dist/main.d.ts +65 -365
- package/package.json +1 -1
- package/dist/main.umd.cjs +0 -1
|
@@ -1,108 +1,399 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (t, e,
|
|
4
|
-
|
|
1
|
+
var oe = Object.defineProperty;
|
|
2
|
+
var re = (t, e, o) => e in t ? oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
|
|
3
|
+
var i = (t, e, o) => re(t, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
class ie {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
i(this, "viewport");
|
|
7
|
+
i(this, "graph");
|
|
8
|
+
i(this, "internalTransformation");
|
|
9
|
+
i(this, "internalModel");
|
|
10
|
+
i(this, "graphStoreController");
|
|
11
|
+
i(this, "htmlView");
|
|
12
|
+
i(this, "onAfterNodeAdded", (e) => {
|
|
13
|
+
this.htmlView.attachNode(e);
|
|
14
|
+
});
|
|
15
|
+
i(this, "onAfterEdgeAdded", (e) => {
|
|
16
|
+
this.htmlView.attachEdge(e);
|
|
17
|
+
});
|
|
18
|
+
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
19
|
+
this.htmlView.updateEdgeShape(e);
|
|
20
|
+
});
|
|
21
|
+
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
22
|
+
this.htmlView.updateEdgePriority(e);
|
|
23
|
+
});
|
|
24
|
+
i(this, "onAfterEdgeUpdated", (e) => {
|
|
25
|
+
this.htmlView.renderEdge(e);
|
|
26
|
+
});
|
|
27
|
+
i(this, "onAfterPortUpdated", (e) => {
|
|
28
|
+
this.internalModel.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
29
|
+
this.htmlView.renderEdge(r);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
33
|
+
this.htmlView.updateNodePriority(e);
|
|
34
|
+
});
|
|
35
|
+
i(this, "onAfterNodeUpdated", (e) => {
|
|
36
|
+
this.htmlView.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
37
|
+
this.htmlView.renderEdge(r);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
41
|
+
this.htmlView.detachEdge(e);
|
|
42
|
+
});
|
|
43
|
+
i(this, "onBeforeNodeRemoved", (e) => {
|
|
44
|
+
this.htmlView.detachNode(e);
|
|
45
|
+
});
|
|
46
|
+
this.graph = e.graph, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.viewport = e.viewport, this.htmlView = e.htmlView, this.graphStoreController = e.graphStoreController, this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
47
|
+
this.onAfterEdgeShapeUpdated
|
|
48
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
49
|
+
this.onAfterEdgePriorityUpdated
|
|
50
|
+
), this.graphStoreController.onAfterEdgeUpdated.subscribe(
|
|
51
|
+
this.onAfterEdgeUpdated
|
|
52
|
+
), this.graphStoreController.onAfterPortUpdated.subscribe(
|
|
53
|
+
this.onAfterPortUpdated
|
|
54
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.subscribe(
|
|
55
|
+
this.onAfterNodePriorityUpdated
|
|
56
|
+
), this.graphStoreController.onAfterNodeUpdated.subscribe(
|
|
57
|
+
this.onAfterNodeUpdated
|
|
58
|
+
), this.graphStoreController.onBeforeEdgeRemoved.subscribe(
|
|
59
|
+
this.onBeforeEdgeRemoved
|
|
60
|
+
), this.graphStoreController.onBeforeNodeRemoved.subscribe(
|
|
61
|
+
this.onBeforeNodeRemoved
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
attach(e) {
|
|
65
|
+
return this.htmlView.attach(e), this;
|
|
66
|
+
}
|
|
67
|
+
detach() {
|
|
68
|
+
return this.htmlView.detach(), this;
|
|
69
|
+
}
|
|
70
|
+
addNode(e) {
|
|
71
|
+
return this.graphStoreController.addNode(e), this;
|
|
72
|
+
}
|
|
73
|
+
updateNode(e, o) {
|
|
74
|
+
return this.graphStoreController.updateNode(e, o ?? {}), this;
|
|
75
|
+
}
|
|
76
|
+
removeNode(e) {
|
|
77
|
+
return this.graphStoreController.removeNode(e), this;
|
|
78
|
+
}
|
|
79
|
+
addEdge(e) {
|
|
80
|
+
return this.graphStoreController.addEdge(e), this;
|
|
81
|
+
}
|
|
82
|
+
updateEdge(e, o) {
|
|
83
|
+
return this.graphStoreController.updateEdge(e, o ?? {}), this;
|
|
84
|
+
}
|
|
85
|
+
removeEdge(e) {
|
|
86
|
+
return this.graphStoreController.removeEdge(e), this;
|
|
87
|
+
}
|
|
88
|
+
markPort(e) {
|
|
89
|
+
return this.graphStoreController.markPort(e), this;
|
|
90
|
+
}
|
|
91
|
+
updatePort(e, o) {
|
|
92
|
+
return this.graphStoreController.updatePort(e, o ?? {}), this;
|
|
93
|
+
}
|
|
94
|
+
unmarkPort(e) {
|
|
95
|
+
return this.graphStoreController.unmarkPort(e), this;
|
|
96
|
+
}
|
|
97
|
+
patchViewportMatrix(e) {
|
|
98
|
+
return this.internalTransformation.patchViewportMatrix(e), this;
|
|
99
|
+
}
|
|
100
|
+
patchContentMatrix(e) {
|
|
101
|
+
return this.internalTransformation.patchContentMatrix(e), this;
|
|
102
|
+
}
|
|
103
|
+
clear() {
|
|
104
|
+
return this.htmlView.clear(), this.graphStoreController.clear(), this;
|
|
105
|
+
}
|
|
106
|
+
destroy() {
|
|
107
|
+
this.htmlView.destroy(), this.graphStoreController.clear(), this.graphStoreController.onAfterNodeAdded.unsubscribe(
|
|
108
|
+
this.onAfterNodeAdded
|
|
109
|
+
), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
|
|
110
|
+
this.onAfterEdgeAdded
|
|
111
|
+
), this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(
|
|
112
|
+
this.onAfterEdgeShapeUpdated
|
|
113
|
+
), this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(
|
|
114
|
+
this.onAfterEdgePriorityUpdated
|
|
115
|
+
), this.graphStoreController.onAfterEdgeUpdated.unsubscribe(
|
|
116
|
+
this.onAfterEdgeUpdated
|
|
117
|
+
), this.graphStoreController.onAfterPortUpdated.unsubscribe(
|
|
118
|
+
this.onAfterPortUpdated
|
|
119
|
+
), this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(
|
|
120
|
+
this.onAfterNodePriorityUpdated
|
|
121
|
+
), this.graphStoreController.onAfterNodeUpdated.unsubscribe(
|
|
122
|
+
this.onAfterNodeUpdated
|
|
123
|
+
), this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(
|
|
124
|
+
this.onBeforeEdgeRemoved
|
|
125
|
+
), this.graphStoreController.onBeforeNodeRemoved.unsubscribe(
|
|
126
|
+
this.onBeforeNodeRemoved
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
class L {
|
|
131
|
+
constructor(e) {
|
|
132
|
+
i(this, "counter", 0);
|
|
133
|
+
this.checkExists = e;
|
|
134
|
+
}
|
|
135
|
+
create(e) {
|
|
136
|
+
if (e !== void 0)
|
|
137
|
+
return e;
|
|
138
|
+
for (; this.checkExists(this.counter); )
|
|
139
|
+
this.counter++;
|
|
140
|
+
return this.counter;
|
|
141
|
+
}
|
|
142
|
+
reset() {
|
|
143
|
+
this.counter = 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
class E extends Error {
|
|
147
|
+
constructor() {
|
|
148
|
+
super(...arguments);
|
|
149
|
+
i(this, "name", "HtmlGraphError");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
class q {
|
|
153
|
+
constructor() {
|
|
154
|
+
i(this, "callbacks", /* @__PURE__ */ new Set());
|
|
155
|
+
}
|
|
156
|
+
subscribe(e) {
|
|
157
|
+
this.callbacks.add(e);
|
|
158
|
+
}
|
|
159
|
+
unsubscribe(e) {
|
|
160
|
+
this.callbacks.delete(e);
|
|
161
|
+
}
|
|
162
|
+
emit(e) {
|
|
163
|
+
this.callbacks.forEach((o) => {
|
|
164
|
+
o(e);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const p = () => {
|
|
169
|
+
const t = new q();
|
|
170
|
+
return [t, t];
|
|
171
|
+
};
|
|
172
|
+
class se {
|
|
173
|
+
constructor(e, o) {
|
|
174
|
+
i(this, "nodeIdGenerator", new L(
|
|
175
|
+
(e) => this.graphStore.getNode(e) !== void 0
|
|
176
|
+
));
|
|
177
|
+
i(this, "portIdGenerator", new L(
|
|
178
|
+
(e) => this.graphStore.getPort(e) !== void 0
|
|
179
|
+
));
|
|
180
|
+
i(this, "edgeIdGenerator", new L(
|
|
181
|
+
(e) => this.graphStore.getEdge(e) !== void 0
|
|
182
|
+
));
|
|
183
|
+
i(this, "onAfterNodeAdded");
|
|
184
|
+
i(this, "onAfterNodeAddedEmitter");
|
|
185
|
+
i(this, "onAfterEdgeAdded");
|
|
186
|
+
i(this, "onAfterEdgeAddedEmitter");
|
|
187
|
+
i(this, "onAfterEdgeShapeUpdated");
|
|
188
|
+
i(this, "onAfterEdgeShapeUpdatedEmitter");
|
|
189
|
+
i(this, "onAfterEdgePriorityUpdated");
|
|
190
|
+
i(this, "onAfterEdgePriorityUpdatedEmitter");
|
|
191
|
+
i(this, "onAfterEdgeUpdated");
|
|
192
|
+
i(this, "onAfterEdgeUpdatedEmitter");
|
|
193
|
+
i(this, "onAfterPortUpdated");
|
|
194
|
+
i(this, "onAfterPortUpdatedEmitter");
|
|
195
|
+
i(this, "onAfterNodePriorityUpdated");
|
|
196
|
+
i(this, "onAfterNodePriorityUpdatedEmitter");
|
|
197
|
+
i(this, "onAfterNodeUpdated");
|
|
198
|
+
i(this, "onAfterNodeUpdatedEmitter");
|
|
199
|
+
i(this, "onBeforeEdgeRemoved");
|
|
200
|
+
i(this, "onBeforeEdgeRemovedEmitter");
|
|
201
|
+
i(this, "onBeforeNodeRemoved");
|
|
202
|
+
i(this, "onBeforeNodeRemovedEmitter");
|
|
203
|
+
this.graphStore = e, this.options = o, [this.onAfterNodeAddedEmitter, this.onAfterNodeAdded] = p(), [this.onAfterEdgeAddedEmitter, this.onAfterEdgeAdded] = p(), [this.onAfterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = p(), [this.onAfterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = p(), [this.onAfterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = p(), [this.onAfterPortUpdatedEmitter, this.onAfterPortUpdated] = p(), [this.onAfterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = p(), [this.onAfterNodeUpdatedEmitter, this.onAfterNodeUpdated] = p(), [this.onBeforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = p(), [this.onBeforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = p();
|
|
204
|
+
}
|
|
205
|
+
addNode(e) {
|
|
206
|
+
const o = this.nodeIdGenerator.create(e.id);
|
|
207
|
+
if (this.graphStore.getNode(o) !== void 0)
|
|
208
|
+
throw new E("failed to add node with existing id");
|
|
209
|
+
this.graphStore.addNode({
|
|
210
|
+
nodeId: o,
|
|
211
|
+
element: e.element,
|
|
212
|
+
x: e.x,
|
|
213
|
+
y: e.y,
|
|
214
|
+
centerFn: e.centerFn ?? this.options.nodes.centerFn,
|
|
215
|
+
priority: e.priority ?? this.options.nodes.priorityFn()
|
|
216
|
+
}), this.onAfterNodeAddedEmitter.emit(o), Array.from(e.ports ?? []).forEach((r) => {
|
|
217
|
+
this.markPort({
|
|
218
|
+
id: r.id,
|
|
219
|
+
element: r.element,
|
|
220
|
+
nodeId: o,
|
|
221
|
+
direction: r.direction
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
markPort(e) {
|
|
226
|
+
const o = this.portIdGenerator.create(e.id);
|
|
227
|
+
if (this.graphStore.getPort(o) !== void 0)
|
|
228
|
+
throw new E("failed to add port with existing id");
|
|
229
|
+
if (this.graphStore.getNode(e.nodeId) === void 0)
|
|
230
|
+
throw new E("failed to set port on nonexisting node");
|
|
231
|
+
this.graphStore.addPort({
|
|
232
|
+
portId: o,
|
|
233
|
+
element: e.element,
|
|
234
|
+
nodeId: e.nodeId,
|
|
235
|
+
direction: e.direction ?? this.options.ports.direction
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
addEdge(e) {
|
|
239
|
+
const o = this.edgeIdGenerator.create(e.id);
|
|
240
|
+
if (this.graphStore.getEdge(o) !== void 0)
|
|
241
|
+
throw new E("failed to add edge with existing id");
|
|
242
|
+
if (this.graphStore.getPort(e.from) === void 0)
|
|
243
|
+
throw new E("failed to add edge from nonexisting port");
|
|
244
|
+
if (this.graphStore.getPort(e.to) === void 0)
|
|
245
|
+
throw new E("failed to add edge to nonexisting port");
|
|
246
|
+
this.graphStore.addEdge({
|
|
247
|
+
edgeId: o,
|
|
248
|
+
from: e.from,
|
|
249
|
+
to: e.to,
|
|
250
|
+
shape: e.shape ?? this.options.edges.shapeFactory(),
|
|
251
|
+
priority: e.priority ?? this.options.edges.priorityFn()
|
|
252
|
+
}), this.onAfterEdgeAddedEmitter.emit(o);
|
|
253
|
+
}
|
|
254
|
+
updateEdge(e, o) {
|
|
255
|
+
const r = this.graphStore.getEdge(e);
|
|
256
|
+
if (r === void 0)
|
|
257
|
+
throw new E("failed to update nonexisting edge");
|
|
258
|
+
o.shape !== void 0 && (r.shape = o.shape, this.onAfterEdgeShapeUpdatedEmitter.emit(e)), o.from !== void 0 && this.graphStore.updateEdgeFrom(e, o.from), o.to !== void 0 && this.graphStore.updateEdgeTo(e, o.to), this.onAfterEdgeUpdatedEmitter.emit(e), o.priority !== void 0 && (r.priority = o.priority, this.onAfterEdgePriorityUpdatedEmitter.emit(e));
|
|
259
|
+
}
|
|
260
|
+
updatePort(e, o) {
|
|
261
|
+
const r = this.graphStore.getPort(e);
|
|
262
|
+
if (r === void 0)
|
|
263
|
+
throw new E("failed to unset nonexisting port");
|
|
264
|
+
r.direction = o.direction ?? r.direction, this.onAfterPortUpdatedEmitter.emit(e);
|
|
265
|
+
}
|
|
266
|
+
updateNode(e, o) {
|
|
267
|
+
const r = this.graphStore.getNode(e);
|
|
268
|
+
if (r === void 0)
|
|
269
|
+
throw new E("failed to update nonexisting node");
|
|
270
|
+
r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = o.centerFn ?? r.centerFn, this.onAfterNodeUpdatedEmitter.emit(e), o.priority !== void 0 && (r.priority = o.priority, this.onAfterNodePriorityUpdatedEmitter.emit(e));
|
|
271
|
+
}
|
|
272
|
+
removeEdge(e) {
|
|
273
|
+
if (this.graphStore.getEdge(e) === void 0)
|
|
274
|
+
throw new E("failed to remove nonexisting edge");
|
|
275
|
+
this.onBeforeEdgeRemovedEmitter.emit(e), this.graphStore.removeEdge(e);
|
|
276
|
+
}
|
|
277
|
+
unmarkPort(e) {
|
|
278
|
+
if (this.graphStore.getPort(e) === void 0)
|
|
279
|
+
throw new E("failed to unset nonexisting port");
|
|
280
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
281
|
+
this.removeEdge(o);
|
|
282
|
+
}), this.graphStore.removePort(e);
|
|
283
|
+
}
|
|
284
|
+
removeNode(e) {
|
|
285
|
+
if (this.graphStore.getNode(e) === void 0)
|
|
286
|
+
throw new E("failed to remove nonexisting node");
|
|
287
|
+
this.graphStore.getNodePortIds(e).forEach((o) => {
|
|
288
|
+
this.unmarkPort(o);
|
|
289
|
+
}), this.onBeforeNodeRemovedEmitter.emit(e), this.graphStore.removeNode(e);
|
|
290
|
+
}
|
|
291
|
+
clear() {
|
|
292
|
+
this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const ne = (t, e) => ({
|
|
5
296
|
x: t / 2,
|
|
6
297
|
y: e / 2
|
|
7
|
-
}), v = (t, e,
|
|
8
|
-
x: e.x * t.x - e.y * t.y + ((1 - e.x) *
|
|
9
|
-
y: e.y * t.x + e.x * t.y + ((1 - e.x) *
|
|
10
|
-
}),
|
|
298
|
+
}), v = (t, e, o) => ({
|
|
299
|
+
x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
|
|
300
|
+
y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
|
|
301
|
+
}), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
|
|
11
302
|
x: 0,
|
|
12
303
|
y: 0
|
|
13
|
-
},
|
|
304
|
+
}, m = (t, e, o, r) => {
|
|
14
305
|
const d = [
|
|
15
306
|
w,
|
|
16
|
-
{ x:
|
|
17
|
-
{ x:
|
|
18
|
-
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })),
|
|
19
|
-
return `${
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
if (t.length > 0 &&
|
|
23
|
-
const
|
|
24
|
-
let
|
|
307
|
+
{ x: o, y: r },
|
|
308
|
+
{ x: o, y: -r }
|
|
309
|
+
].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), s = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
|
|
310
|
+
return `${s} ${h} ${c}`;
|
|
311
|
+
}, D = (t, e) => {
|
|
312
|
+
const o = [];
|
|
313
|
+
if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
|
|
314
|
+
const r = t.length - 1;
|
|
315
|
+
let n = 0, d = 0, s = 0;
|
|
25
316
|
t.forEach((h, c) => {
|
|
26
317
|
let a = 0, l = 0, g = 0;
|
|
27
|
-
const f = c > 0, x = c <
|
|
28
|
-
if (f && (a = -
|
|
29
|
-
const
|
|
30
|
-
|
|
318
|
+
const f = c > 0, x = c < r, y = f && x;
|
|
319
|
+
if (f && (a = -n, l = -d, g = s), x) {
|
|
320
|
+
const C = t[c + 1];
|
|
321
|
+
n = C.x - h.x, d = C.y - h.y, s = Math.sqrt(n * n + d * d);
|
|
31
322
|
}
|
|
32
|
-
const
|
|
33
|
-
c > 0 &&
|
|
323
|
+
const A = s !== 0 ? Math.min((y ? e : 0) / s, c < r - 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + n * A, y: h.y + d * A } : h, V = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, b = y ? { x: h.x + a * V, y: h.y + l * V } : h;
|
|
324
|
+
c > 0 && o.push(`L ${b.x} ${b.y}`), y && o.push(
|
|
34
325
|
`C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
|
|
35
326
|
);
|
|
36
327
|
});
|
|
37
328
|
}
|
|
38
|
-
return
|
|
39
|
-
},
|
|
329
|
+
return o.join(" ");
|
|
330
|
+
}, F = () => {
|
|
40
331
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
41
332
|
return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
|
|
42
|
-
},
|
|
333
|
+
}, U = () => {
|
|
43
334
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
44
335
|
return t.style.transformOrigin = "50% 50%", t;
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
},
|
|
336
|
+
}, B = (t, e) => {
|
|
337
|
+
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
338
|
+
return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
|
|
339
|
+
}, M = (t) => {
|
|
49
340
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
50
341
|
return e.setAttribute("fill", t), e;
|
|
51
|
-
},
|
|
52
|
-
const
|
|
342
|
+
}, k = (t, e) => {
|
|
343
|
+
const o = {
|
|
53
344
|
x: t.x + t.width / 2,
|
|
54
345
|
y: t.y + t.height / 2
|
|
55
|
-
},
|
|
346
|
+
}, r = {
|
|
56
347
|
x: e.x + e.width / 2,
|
|
57
348
|
y: e.y + e.height / 2
|
|
58
|
-
},
|
|
349
|
+
}, n = Math.min(o.x, r.x), d = Math.min(o.y, r.y), s = Math.abs(r.x - o.x), h = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
|
|
59
350
|
return {
|
|
60
|
-
x:
|
|
351
|
+
x: n,
|
|
61
352
|
y: d,
|
|
62
|
-
width:
|
|
353
|
+
width: s,
|
|
63
354
|
height: h,
|
|
64
355
|
flipX: c,
|
|
65
356
|
flipY: a
|
|
66
357
|
};
|
|
67
|
-
},
|
|
358
|
+
}, he = (t) => {
|
|
68
359
|
const e = v(
|
|
69
360
|
{ x: t.arrowLength, y: w.y },
|
|
70
361
|
t.fromVect,
|
|
71
362
|
w
|
|
72
|
-
),
|
|
363
|
+
), o = v(
|
|
73
364
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
74
365
|
t.toVect,
|
|
75
366
|
t.to
|
|
76
|
-
),
|
|
367
|
+
), r = {
|
|
77
368
|
x: e.x + t.fromVect.x * t.curvature,
|
|
78
369
|
y: e.y + t.fromVect.y * t.curvature
|
|
79
|
-
},
|
|
80
|
-
x:
|
|
81
|
-
y:
|
|
82
|
-
}, d = `M ${e.x} ${e.y} C ${
|
|
83
|
-
return `${
|
|
84
|
-
},
|
|
370
|
+
}, n = {
|
|
371
|
+
x: o.x - t.toVect.x * t.curvature,
|
|
372
|
+
y: o.y - t.toVect.y * t.curvature
|
|
373
|
+
}, d = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`, s = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
|
|
374
|
+
return `${s}${d}${h}`;
|
|
375
|
+
}, de = (t) => {
|
|
85
376
|
const e = t.hasSourceArrow ? v(
|
|
86
377
|
{ x: t.arrowLength, y: w.y },
|
|
87
378
|
t.fromVect,
|
|
88
379
|
w
|
|
89
|
-
) : w,
|
|
380
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
90
381
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
91
382
|
t.toVect,
|
|
92
383
|
t.to
|
|
93
|
-
) : t.to,
|
|
94
|
-
{ x:
|
|
384
|
+
) : t.to, r = t.arrowLength, n = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, s = n * t.flipX, h = d * t.flipY, c = v(
|
|
385
|
+
{ x: r, y: w.y },
|
|
95
386
|
t.fromVect,
|
|
96
387
|
w
|
|
97
388
|
), a = {
|
|
98
|
-
x: c.x +
|
|
389
|
+
x: c.x + s,
|
|
99
390
|
y: c.y + h
|
|
100
391
|
}, l = v(
|
|
101
|
-
{ x: t.to.x -
|
|
392
|
+
{ x: t.to.x - r, y: t.to.y },
|
|
102
393
|
t.toVect,
|
|
103
394
|
t.to
|
|
104
395
|
), g = {
|
|
105
|
-
x: l.x +
|
|
396
|
+
x: l.x + s,
|
|
106
397
|
y: l.y + h
|
|
107
398
|
}, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, x = {
|
|
108
399
|
x: c.x + t.curvature * t.fromVect.x,
|
|
@@ -110,122 +401,122 @@ const q = (t, e) => ({
|
|
|
110
401
|
}, y = {
|
|
111
402
|
x: l.x - t.curvature * t.toVect.x,
|
|
112
403
|
y: l.y - t.curvature * t.toVect.y
|
|
113
|
-
},
|
|
114
|
-
x: c.x +
|
|
404
|
+
}, S = {
|
|
405
|
+
x: c.x + s,
|
|
115
406
|
y: c.y + h
|
|
116
|
-
},
|
|
117
|
-
x: l.x +
|
|
407
|
+
}, A = {
|
|
408
|
+
x: l.x + s,
|
|
118
409
|
y: l.y + h
|
|
119
410
|
};
|
|
120
411
|
return [
|
|
121
412
|
`M ${e.x} ${e.y}`,
|
|
122
413
|
`L ${c.x} ${c.y}`,
|
|
123
|
-
`C ${x.x} ${x.y} ${
|
|
124
|
-
`C ${
|
|
125
|
-
`L ${
|
|
414
|
+
`C ${x.x} ${x.y} ${S.x} ${S.y} ${f.x} ${f.y}`,
|
|
415
|
+
`C ${A.x} ${A.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
|
|
416
|
+
`L ${o.x} ${o.y}`
|
|
126
417
|
].join(" ");
|
|
127
|
-
},
|
|
418
|
+
}, ce = (t) => {
|
|
128
419
|
const e = t.hasSourceArrow ? v(
|
|
129
420
|
{ x: t.arrowLength, y: w.y },
|
|
130
421
|
t.fromVect,
|
|
131
422
|
w
|
|
132
|
-
) : w,
|
|
423
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
133
424
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
134
425
|
t.toVect,
|
|
135
426
|
t.to
|
|
136
|
-
) : t.to,
|
|
137
|
-
{ x: t.to.x -
|
|
427
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
|
|
428
|
+
{ x: t.to.x - n, y: t.to.y },
|
|
138
429
|
t.toVect,
|
|
139
430
|
t.to
|
|
140
|
-
), h = Math.max((d.x +
|
|
141
|
-
x: t.flipX > 0 ? t.to.x - h : t.to.x +
|
|
142
|
-
y:
|
|
431
|
+
), h = Math.max((d.x + s.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -r, y: d.y }, l = { x: a.x, y: c }, g = {
|
|
432
|
+
x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
|
|
433
|
+
y: s.y
|
|
143
434
|
}, f = { x: g.x, y: c };
|
|
144
|
-
return
|
|
145
|
-
[e, d, a, l, f, g,
|
|
435
|
+
return D(
|
|
436
|
+
[e, d, a, l, f, g, s, o],
|
|
146
437
|
t.roundness
|
|
147
438
|
);
|
|
148
|
-
},
|
|
439
|
+
}, X = (t) => {
|
|
149
440
|
const e = t.hasSourceArrow ? v(
|
|
150
441
|
{ x: t.arrowLength, y: w.y },
|
|
151
442
|
t.fromVect,
|
|
152
443
|
w
|
|
153
|
-
) : w,
|
|
444
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
154
445
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
155
446
|
t.toVect,
|
|
156
447
|
t.to
|
|
157
|
-
) : t.to,
|
|
158
|
-
{ x:
|
|
448
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = v(
|
|
449
|
+
{ x: r, y: w.y },
|
|
159
450
|
t.fromVect,
|
|
160
451
|
w
|
|
161
|
-
), d = Math.cos(t.detourDirection) * t.detourDistance,
|
|
162
|
-
{ x: t.to.x -
|
|
452
|
+
), d = Math.cos(t.detourDirection) * t.detourDistance, s = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = s * t.flipY, a = { x: n.x + h, y: n.y + c }, l = v(
|
|
453
|
+
{ x: t.to.x - r, y: t.to.y },
|
|
163
454
|
t.toVect,
|
|
164
455
|
t.to
|
|
165
456
|
), g = { x: l.x + h, y: l.y + c };
|
|
166
|
-
return
|
|
167
|
-
[e,
|
|
457
|
+
return D(
|
|
458
|
+
[e, n, a, g, l, o],
|
|
168
459
|
t.roundness
|
|
169
460
|
);
|
|
170
|
-
},
|
|
461
|
+
}, ae = (t) => {
|
|
171
462
|
const e = t.hasSourceArrow ? v(
|
|
172
463
|
{ x: t.arrowLength, y: w.y },
|
|
173
464
|
t.fromVect,
|
|
174
465
|
w
|
|
175
|
-
) : w,
|
|
466
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
176
467
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
177
468
|
t.toVect,
|
|
178
469
|
t.to
|
|
179
|
-
) : t.to,
|
|
180
|
-
{ x: t.to.x -
|
|
470
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = v({ x: r, y: w.y }, t.fromVect, w), d = v(
|
|
471
|
+
{ x: t.to.x - r, y: t.to.y },
|
|
181
472
|
t.toVect,
|
|
182
473
|
t.to
|
|
183
474
|
);
|
|
184
|
-
return
|
|
185
|
-
},
|
|
475
|
+
return D([e, n, d, o], t.roundness);
|
|
476
|
+
}, le = (t) => {
|
|
186
477
|
const e = t.hasSourceArrow ? v(
|
|
187
478
|
{ x: t.arrowLength, y: w.y },
|
|
188
479
|
t.fromVect,
|
|
189
480
|
w
|
|
190
|
-
) : w,
|
|
481
|
+
) : w, o = t.hasTargetArrow ? v(
|
|
191
482
|
{ x: t.to.x - t.arrowLength, y: t.to.y },
|
|
192
483
|
t.toVect,
|
|
193
484
|
t.to
|
|
194
|
-
) : t.to,
|
|
195
|
-
{ x: t.to.x -
|
|
485
|
+
) : t.to, r = t.arrowLength + t.arrowOffset, n = r - t.roundness, d = v({ x: n, y: w.y }, t.fromVect, w), s = v(
|
|
486
|
+
{ x: t.to.x - n, y: t.to.y },
|
|
196
487
|
t.toVect,
|
|
197
488
|
t.to
|
|
198
|
-
), h = Math.max((d.y +
|
|
199
|
-
x:
|
|
200
|
-
y: t.flipY > 0 ? t.to.y - h : t.to.y +
|
|
489
|
+
), h = Math.max((d.y + s.y) / 2, r), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -r }, l = { x: c, y: a.y }, g = {
|
|
490
|
+
x: s.x,
|
|
491
|
+
y: t.flipY > 0 ? t.to.y - h : t.to.y + r
|
|
201
492
|
}, f = { x: c, y: g.y };
|
|
202
|
-
return
|
|
203
|
-
[e, d, a, l, f, g,
|
|
493
|
+
return D(
|
|
494
|
+
[e, d, a, l, f, g, s, o],
|
|
204
495
|
t.roundness
|
|
205
496
|
);
|
|
206
497
|
}, H = (t) => {
|
|
207
|
-
const e = t.arrowOffset,
|
|
498
|
+
const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, n = r + 2 * o, s = [
|
|
208
499
|
{ x: t.arrowLength, y: w.y },
|
|
209
|
-
{ x:
|
|
210
|
-
{ x:
|
|
211
|
-
{ x:
|
|
212
|
-
{ x:
|
|
213
|
-
{ x:
|
|
214
|
-
{ x:
|
|
500
|
+
{ x: r, y: w.y },
|
|
501
|
+
{ x: r, y: t.side },
|
|
502
|
+
{ x: n, y: t.side },
|
|
503
|
+
{ x: n, y: -t.side },
|
|
504
|
+
{ x: r, y: -t.side },
|
|
505
|
+
{ x: r, y: w.y },
|
|
215
506
|
{ x: t.arrowLength, y: w.y }
|
|
216
507
|
].map(
|
|
217
508
|
(c) => v(c, t.fromVect, w)
|
|
218
|
-
), h = `M ${w.x} ${w.y} L ${
|
|
219
|
-
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${
|
|
220
|
-
},
|
|
221
|
-
const e = t.smallRadius,
|
|
509
|
+
), h = `M ${w.x} ${w.y} L ${s[0].x} ${s[0].y} `;
|
|
510
|
+
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${D(s, t.roundness)}`;
|
|
511
|
+
}, ge = (t) => {
|
|
512
|
+
const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), n = e + o, d = t.arrowLength + r * (1 - o / n), s = e * o / n, c = [
|
|
222
513
|
{ x: t.arrowLength, y: w.y },
|
|
223
|
-
{ x: d, y:
|
|
224
|
-
{ x: d, y: -
|
|
514
|
+
{ x: d, y: s },
|
|
515
|
+
{ x: d, y: -s }
|
|
225
516
|
].map((g) => v(g, t.fromVect, w)), a = [
|
|
226
517
|
`M ${c[0].x} ${c[0].y}`,
|
|
227
518
|
`A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
|
|
228
|
-
`A ${
|
|
519
|
+
`A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
|
|
229
520
|
`A ${e} ${e} 0 0 1 ${c[0].x} ${c[0].y}`
|
|
230
521
|
].join(" "), l = `M 0 0 L ${c[0].x} ${c[0].y} `;
|
|
231
522
|
return `${t.hasSourceArrow || t.hasTargetArrow ? "" : l}${a}`;
|
|
@@ -246,10 +537,10 @@ const q = (t, e) => ({
|
|
|
246
537
|
smallCycleRadius: 15,
|
|
247
538
|
curvature: 90
|
|
248
539
|
});
|
|
249
|
-
class
|
|
540
|
+
class ue {
|
|
250
541
|
constructor(e) {
|
|
251
|
-
i(this, "svg",
|
|
252
|
-
i(this, "group",
|
|
542
|
+
i(this, "svg", F());
|
|
543
|
+
i(this, "group", U());
|
|
253
544
|
i(this, "line");
|
|
254
545
|
i(this, "sourceArrow", null);
|
|
255
546
|
i(this, "targetArrow", null);
|
|
@@ -263,36 +554,36 @@ class O {
|
|
|
263
554
|
i(this, "hasSourceArrow");
|
|
264
555
|
i(this, "hasTargetArrow");
|
|
265
556
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
266
|
-
const
|
|
267
|
-
this.svg.appendChild(this.group), this.line =
|
|
557
|
+
const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
|
|
558
|
+
this.svg.appendChild(this.group), this.line = B(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
|
|
268
559
|
}
|
|
269
560
|
render(e) {
|
|
270
|
-
const { x:
|
|
561
|
+
const { x: o, y: r, width: n, height: d, flipX: s, flipY: h } = k(
|
|
271
562
|
e.from,
|
|
272
563
|
e.to
|
|
273
564
|
);
|
|
274
|
-
this.svg.style.transform = `translate(${
|
|
275
|
-
const c =
|
|
565
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
566
|
+
const c = T(
|
|
276
567
|
e.from.direction,
|
|
277
|
-
|
|
568
|
+
s,
|
|
278
569
|
h
|
|
279
|
-
), a =
|
|
280
|
-
x:
|
|
570
|
+
), a = T(e.to.direction, s, h), l = {
|
|
571
|
+
x: n,
|
|
281
572
|
y: d
|
|
282
573
|
};
|
|
283
574
|
let g, f = a, x = -this.arrowLength;
|
|
284
|
-
if (e.from.portId === e.to.portId ? (g =
|
|
575
|
+
if (e.from.portId === e.to.portId ? (g = ge({
|
|
285
576
|
fromVect: c,
|
|
286
577
|
radius: this.portCycleRadius,
|
|
287
578
|
smallRadius: this.portCycleSmallRadius,
|
|
288
579
|
arrowLength: this.arrowLength,
|
|
289
580
|
hasSourceArrow: this.hasSourceArrow,
|
|
290
581
|
hasTargetArrow: this.hasTargetArrow
|
|
291
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
582
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = de({
|
|
292
583
|
to: l,
|
|
293
584
|
fromVect: c,
|
|
294
585
|
toVect: a,
|
|
295
|
-
flipX:
|
|
586
|
+
flipX: s,
|
|
296
587
|
flipY: h,
|
|
297
588
|
arrowLength: this.arrowLength,
|
|
298
589
|
detourDirection: this.detourDirection,
|
|
@@ -300,7 +591,7 @@ class O {
|
|
|
300
591
|
curvature: this.curvature,
|
|
301
592
|
hasSourceArrow: this.hasSourceArrow,
|
|
302
593
|
hasTargetArrow: this.hasTargetArrow
|
|
303
|
-
}) : g =
|
|
594
|
+
}) : g = he({
|
|
304
595
|
to: l,
|
|
305
596
|
fromVect: c,
|
|
306
597
|
toVect: a,
|
|
@@ -309,7 +600,7 @@ class O {
|
|
|
309
600
|
hasSourceArrow: this.hasSourceArrow,
|
|
310
601
|
hasTargetArrow: this.hasTargetArrow
|
|
311
602
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
312
|
-
const y =
|
|
603
|
+
const y = m(
|
|
313
604
|
c,
|
|
314
605
|
w,
|
|
315
606
|
this.arrowLength,
|
|
@@ -318,7 +609,7 @@ class O {
|
|
|
318
609
|
this.sourceArrow.setAttribute("d", y);
|
|
319
610
|
}
|
|
320
611
|
if (this.targetArrow) {
|
|
321
|
-
const y =
|
|
612
|
+
const y = m(
|
|
322
613
|
f,
|
|
323
614
|
l,
|
|
324
615
|
x,
|
|
@@ -328,10 +619,10 @@ class O {
|
|
|
328
619
|
}
|
|
329
620
|
}
|
|
330
621
|
}
|
|
331
|
-
class
|
|
622
|
+
class we {
|
|
332
623
|
constructor(e) {
|
|
333
|
-
i(this, "svg",
|
|
334
|
-
i(this, "group",
|
|
624
|
+
i(this, "svg", F());
|
|
625
|
+
i(this, "group", U());
|
|
335
626
|
i(this, "line");
|
|
336
627
|
i(this, "sourceArrow", null);
|
|
337
628
|
i(this, "targetArrow", null);
|
|
@@ -345,27 +636,27 @@ class ee {
|
|
|
345
636
|
i(this, "hasSourceArrow");
|
|
346
637
|
i(this, "hasTargetArrow");
|
|
347
638
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
348
|
-
const
|
|
639
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
349
640
|
this.roundness = Math.min(
|
|
350
|
-
|
|
641
|
+
o,
|
|
351
642
|
this.arrowOffset,
|
|
352
643
|
this.cycleSquareSide / 2
|
|
353
644
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
354
|
-
const
|
|
355
|
-
this.svg.appendChild(this.group), this.line =
|
|
645
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
646
|
+
this.svg.appendChild(this.group), this.line = B(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
356
647
|
}
|
|
357
648
|
render(e) {
|
|
358
|
-
const { x:
|
|
649
|
+
const { x: o, y: r, width: n, height: d, flipX: s, flipY: h } = k(
|
|
359
650
|
e.from,
|
|
360
651
|
e.to
|
|
361
652
|
);
|
|
362
|
-
this.svg.style.transform = `translate(${
|
|
363
|
-
const c =
|
|
653
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
654
|
+
const c = T(
|
|
364
655
|
e.from.direction,
|
|
365
|
-
|
|
656
|
+
s,
|
|
366
657
|
h
|
|
367
|
-
), a =
|
|
368
|
-
x:
|
|
658
|
+
), a = T(e.to.direction, s, h), l = {
|
|
659
|
+
x: n,
|
|
369
660
|
y: d
|
|
370
661
|
};
|
|
371
662
|
let g, f = a, x = -this.arrowLength;
|
|
@@ -377,11 +668,11 @@ class ee {
|
|
|
377
668
|
roundness: this.roundness,
|
|
378
669
|
hasSourceArrow: this.hasSourceArrow,
|
|
379
670
|
hasTargetArrow: this.hasTargetArrow
|
|
380
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
671
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
|
|
381
672
|
to: l,
|
|
382
673
|
fromVect: c,
|
|
383
674
|
toVect: a,
|
|
384
|
-
flipX:
|
|
675
|
+
flipX: s,
|
|
385
676
|
flipY: h,
|
|
386
677
|
arrowLength: this.arrowLength,
|
|
387
678
|
arrowOffset: this.arrowOffset,
|
|
@@ -390,18 +681,18 @@ class ee {
|
|
|
390
681
|
detourDistance: this.detourDistance,
|
|
391
682
|
hasSourceArrow: this.hasSourceArrow,
|
|
392
683
|
hasTargetArrow: this.hasTargetArrow
|
|
393
|
-
}) : g =
|
|
684
|
+
}) : g = ce({
|
|
394
685
|
to: l,
|
|
395
686
|
fromVect: c,
|
|
396
687
|
toVect: a,
|
|
397
|
-
flipX:
|
|
688
|
+
flipX: s,
|
|
398
689
|
arrowLength: this.arrowLength,
|
|
399
690
|
arrowOffset: this.arrowOffset,
|
|
400
691
|
roundness: this.roundness,
|
|
401
692
|
hasSourceArrow: this.hasSourceArrow,
|
|
402
693
|
hasTargetArrow: this.hasTargetArrow
|
|
403
694
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
404
|
-
const y =
|
|
695
|
+
const y = m(
|
|
405
696
|
c,
|
|
406
697
|
w,
|
|
407
698
|
this.arrowLength,
|
|
@@ -410,7 +701,7 @@ class ee {
|
|
|
410
701
|
this.sourceArrow.setAttribute("d", y);
|
|
411
702
|
}
|
|
412
703
|
if (this.targetArrow) {
|
|
413
|
-
const y =
|
|
704
|
+
const y = m(
|
|
414
705
|
f,
|
|
415
706
|
l,
|
|
416
707
|
x,
|
|
@@ -420,10 +711,10 @@ class ee {
|
|
|
420
711
|
}
|
|
421
712
|
}
|
|
422
713
|
}
|
|
423
|
-
class
|
|
714
|
+
class fe {
|
|
424
715
|
constructor(e) {
|
|
425
|
-
i(this, "svg",
|
|
426
|
-
i(this, "group",
|
|
716
|
+
i(this, "svg", F());
|
|
717
|
+
i(this, "group", U());
|
|
427
718
|
i(this, "line");
|
|
428
719
|
i(this, "sourceArrow", null);
|
|
429
720
|
i(this, "targetArrow", null);
|
|
@@ -437,27 +728,27 @@ class te {
|
|
|
437
728
|
i(this, "hasSourceArrow");
|
|
438
729
|
i(this, "hasTargetArrow");
|
|
439
730
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
440
|
-
const
|
|
731
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
441
732
|
this.roundness = Math.min(
|
|
442
|
-
|
|
733
|
+
o,
|
|
443
734
|
this.arrowOffset,
|
|
444
735
|
this.cycleSquareSide / 2
|
|
445
736
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
446
|
-
const
|
|
447
|
-
this.svg.appendChild(this.group), this.line =
|
|
737
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
738
|
+
this.svg.appendChild(this.group), this.line = B(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
448
739
|
}
|
|
449
740
|
render(e) {
|
|
450
|
-
const { x:
|
|
741
|
+
const { x: o, y: r, width: n, height: d, flipX: s, flipY: h } = k(
|
|
451
742
|
e.from,
|
|
452
743
|
e.to
|
|
453
744
|
);
|
|
454
|
-
this.svg.style.transform = `translate(${
|
|
455
|
-
const c =
|
|
745
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
746
|
+
const c = T(
|
|
456
747
|
e.from.direction,
|
|
457
|
-
|
|
748
|
+
s,
|
|
458
749
|
h
|
|
459
|
-
), a =
|
|
460
|
-
x:
|
|
750
|
+
), a = T(e.to.direction, s, h), l = {
|
|
751
|
+
x: n,
|
|
461
752
|
y: d
|
|
462
753
|
};
|
|
463
754
|
let g, f = a, x = -this.arrowLength;
|
|
@@ -469,11 +760,11 @@ class te {
|
|
|
469
760
|
roundness: this.roundness,
|
|
470
761
|
hasSourceArrow: this.hasSourceArrow,
|
|
471
762
|
hasTargetArrow: this.hasTargetArrow
|
|
472
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
763
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
|
|
473
764
|
to: l,
|
|
474
765
|
fromVect: c,
|
|
475
766
|
toVect: a,
|
|
476
|
-
flipX:
|
|
767
|
+
flipX: s,
|
|
477
768
|
flipY: h,
|
|
478
769
|
arrowLength: this.arrowLength,
|
|
479
770
|
arrowOffset: this.arrowOffset,
|
|
@@ -482,7 +773,7 @@ class te {
|
|
|
482
773
|
detourDistance: this.detourDistance,
|
|
483
774
|
hasSourceArrow: this.hasSourceArrow,
|
|
484
775
|
hasTargetArrow: this.hasTargetArrow
|
|
485
|
-
}) : g =
|
|
776
|
+
}) : g = ae({
|
|
486
777
|
to: l,
|
|
487
778
|
fromVect: c,
|
|
488
779
|
toVect: a,
|
|
@@ -492,7 +783,7 @@ class te {
|
|
|
492
783
|
hasSourceArrow: this.hasSourceArrow,
|
|
493
784
|
hasTargetArrow: this.hasTargetArrow
|
|
494
785
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
495
|
-
const y =
|
|
786
|
+
const y = m(
|
|
496
787
|
c,
|
|
497
788
|
w,
|
|
498
789
|
this.arrowLength,
|
|
@@ -501,7 +792,7 @@ class te {
|
|
|
501
792
|
this.sourceArrow.setAttribute("d", y);
|
|
502
793
|
}
|
|
503
794
|
if (this.targetArrow) {
|
|
504
|
-
const y =
|
|
795
|
+
const y = m(
|
|
505
796
|
f,
|
|
506
797
|
l,
|
|
507
798
|
x,
|
|
@@ -511,10 +802,10 @@ class te {
|
|
|
511
802
|
}
|
|
512
803
|
}
|
|
513
804
|
}
|
|
514
|
-
class
|
|
805
|
+
class ye {
|
|
515
806
|
constructor(e) {
|
|
516
|
-
i(this, "svg",
|
|
517
|
-
i(this, "group",
|
|
807
|
+
i(this, "svg", F());
|
|
808
|
+
i(this, "group", U());
|
|
518
809
|
i(this, "line");
|
|
519
810
|
i(this, "sourceArrow", null);
|
|
520
811
|
i(this, "targetArrow", null);
|
|
@@ -528,27 +819,27 @@ class re {
|
|
|
528
819
|
i(this, "hasSourceArrow");
|
|
529
820
|
i(this, "hasTargetArrow");
|
|
530
821
|
this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
|
|
531
|
-
const
|
|
822
|
+
const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
|
|
532
823
|
this.roundness = Math.min(
|
|
533
|
-
|
|
824
|
+
o,
|
|
534
825
|
this.arrowOffset,
|
|
535
826
|
this.cycleSquareSide / 2
|
|
536
827
|
), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
|
|
537
|
-
const
|
|
538
|
-
this.svg.appendChild(this.group), this.line =
|
|
828
|
+
const r = (e == null ? void 0 : e.color) ?? u.color, n = (e == null ? void 0 : e.width) ?? u.width;
|
|
829
|
+
this.svg.appendChild(this.group), this.line = B(r, n), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
|
|
539
830
|
}
|
|
540
831
|
render(e) {
|
|
541
|
-
const { x:
|
|
832
|
+
const { x: o, y: r, width: n, height: d, flipX: s, flipY: h } = k(
|
|
542
833
|
e.from,
|
|
543
834
|
e.to
|
|
544
835
|
);
|
|
545
|
-
this.svg.style.transform = `translate(${
|
|
546
|
-
const c =
|
|
836
|
+
this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${s}, ${h})`;
|
|
837
|
+
const c = T(
|
|
547
838
|
e.from.direction,
|
|
548
|
-
|
|
839
|
+
s,
|
|
549
840
|
h
|
|
550
|
-
), a =
|
|
551
|
-
x:
|
|
841
|
+
), a = T(e.to.direction, s, h), l = {
|
|
842
|
+
x: n,
|
|
552
843
|
y: d
|
|
553
844
|
};
|
|
554
845
|
let g, f = a, x = -this.arrowLength;
|
|
@@ -560,11 +851,11 @@ class re {
|
|
|
560
851
|
roundness: this.roundness,
|
|
561
852
|
hasSourceArrow: this.hasSourceArrow,
|
|
562
853
|
hasTargetArrow: this.hasTargetArrow
|
|
563
|
-
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g =
|
|
854
|
+
}), f = c, x = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = X({
|
|
564
855
|
to: l,
|
|
565
856
|
fromVect: c,
|
|
566
857
|
toVect: a,
|
|
567
|
-
flipX:
|
|
858
|
+
flipX: s,
|
|
568
859
|
flipY: h,
|
|
569
860
|
arrowLength: this.arrowLength,
|
|
570
861
|
arrowOffset: this.arrowOffset,
|
|
@@ -573,7 +864,7 @@ class re {
|
|
|
573
864
|
detourDistance: this.detourDistance,
|
|
574
865
|
hasSourceArrow: this.hasSourceArrow,
|
|
575
866
|
hasTargetArrow: this.hasTargetArrow
|
|
576
|
-
}) : g =
|
|
867
|
+
}) : g = le({
|
|
577
868
|
to: l,
|
|
578
869
|
fromVect: c,
|
|
579
870
|
toVect: a,
|
|
@@ -584,7 +875,7 @@ class re {
|
|
|
584
875
|
hasSourceArrow: this.hasSourceArrow,
|
|
585
876
|
hasTargetArrow: this.hasTargetArrow
|
|
586
877
|
}), this.line.setAttribute("d", g), this.sourceArrow) {
|
|
587
|
-
const y =
|
|
878
|
+
const y = m(
|
|
588
879
|
c,
|
|
589
880
|
w,
|
|
590
881
|
this.arrowLength,
|
|
@@ -593,7 +884,7 @@ class re {
|
|
|
593
884
|
this.sourceArrow.setAttribute("d", y);
|
|
594
885
|
}
|
|
595
886
|
if (this.targetArrow) {
|
|
596
|
-
const y =
|
|
887
|
+
const y = m(
|
|
597
888
|
f,
|
|
598
889
|
l,
|
|
599
890
|
x,
|
|
@@ -603,12 +894,12 @@ class re {
|
|
|
603
894
|
}
|
|
604
895
|
}
|
|
605
896
|
}
|
|
606
|
-
const
|
|
897
|
+
const ve = (t) => {
|
|
607
898
|
if (typeof t == "function")
|
|
608
899
|
return t;
|
|
609
900
|
switch (t == null ? void 0 : t.type) {
|
|
610
901
|
case "straight":
|
|
611
|
-
return () => new
|
|
902
|
+
return () => new fe({
|
|
612
903
|
color: t.color,
|
|
613
904
|
width: t.width,
|
|
614
905
|
arrowLength: t.arrowLength,
|
|
@@ -622,7 +913,7 @@ const ye = (t) => {
|
|
|
622
913
|
detourDirection: t.detourDirection
|
|
623
914
|
});
|
|
624
915
|
case "horizontal":
|
|
625
|
-
return () => new
|
|
916
|
+
return () => new we({
|
|
626
917
|
color: t.color,
|
|
627
918
|
width: t.width,
|
|
628
919
|
arrowLength: t.arrowLength,
|
|
@@ -636,7 +927,7 @@ const ye = (t) => {
|
|
|
636
927
|
detourDirection: t.detourDirection
|
|
637
928
|
});
|
|
638
929
|
case "vertical":
|
|
639
|
-
return () => new
|
|
930
|
+
return () => new ye({
|
|
640
931
|
color: t.color,
|
|
641
932
|
width: t.width,
|
|
642
933
|
arrowLength: t.arrowLength,
|
|
@@ -650,7 +941,7 @@ const ye = (t) => {
|
|
|
650
941
|
detourDirection: t.detourDirection
|
|
651
942
|
});
|
|
652
943
|
default:
|
|
653
|
-
return () => new
|
|
944
|
+
return () => new ue({
|
|
654
945
|
color: t.color,
|
|
655
946
|
width: t.width,
|
|
656
947
|
arrowLength: t.arrowLength,
|
|
@@ -664,41 +955,153 @@ const ye = (t) => {
|
|
|
664
955
|
detourDirection: t.detourDirection
|
|
665
956
|
});
|
|
666
957
|
}
|
|
667
|
-
},
|
|
958
|
+
}, Y = (t) => () => t, J = Y(0), xe = () => {
|
|
668
959
|
let t = 0;
|
|
669
960
|
return () => t++;
|
|
670
|
-
},
|
|
671
|
-
let
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
edgesPriorityFn: o
|
|
961
|
+
}, Ee = (t, e) => {
|
|
962
|
+
let o = J, r = J;
|
|
963
|
+
const n = xe();
|
|
964
|
+
return t === "incremental" && (o = n), e === "incremental" && (r = n), typeof t == "number" && (o = Y(t)), typeof e == "number" && (r = Y(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
|
|
965
|
+
nodesPriorityFn: o,
|
|
966
|
+
edgesPriorityFn: r
|
|
677
967
|
};
|
|
678
|
-
},
|
|
679
|
-
var
|
|
680
|
-
const e =
|
|
681
|
-
(
|
|
682
|
-
(
|
|
968
|
+
}, Ae = (t) => {
|
|
969
|
+
var o, r, n, d, s;
|
|
970
|
+
const e = Ee(
|
|
971
|
+
(o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
|
|
972
|
+
(r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
|
|
683
973
|
);
|
|
684
974
|
return {
|
|
685
975
|
nodes: {
|
|
686
|
-
centerFn: ((
|
|
976
|
+
centerFn: ((n = t == null ? void 0 : t.nodes) == null ? void 0 : n.centerFn) ?? ne,
|
|
687
977
|
priorityFn: e.nodesPriorityFn
|
|
688
978
|
},
|
|
689
979
|
ports: {
|
|
690
980
|
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
691
981
|
},
|
|
692
982
|
edges: {
|
|
693
|
-
shapeFactory:
|
|
983
|
+
shapeFactory: ve(((s = t == null ? void 0 : t.edges) == null ? void 0 : s.shape) ?? {}),
|
|
694
984
|
priorityFn: e.edgesPriorityFn
|
|
695
985
|
}
|
|
696
986
|
};
|
|
987
|
+
}, Q = (t) => ({
|
|
988
|
+
scale: 1 / t.scale,
|
|
989
|
+
x: -t.x / t.scale,
|
|
990
|
+
y: -t.y / t.scale
|
|
991
|
+
}), Z = {
|
|
992
|
+
scale: 1,
|
|
993
|
+
x: 0,
|
|
994
|
+
y: 0
|
|
697
995
|
};
|
|
698
|
-
class
|
|
996
|
+
class pe {
|
|
699
997
|
constructor() {
|
|
700
|
-
i(this, "
|
|
701
|
-
i(this, "
|
|
998
|
+
i(this, "viewportMatrix", Z);
|
|
999
|
+
i(this, "contentMatrix", Z);
|
|
1000
|
+
i(this, "emitter");
|
|
1001
|
+
i(this, "onAfterUpdate");
|
|
1002
|
+
[this.emitter, this.onAfterUpdate] = p();
|
|
1003
|
+
}
|
|
1004
|
+
getViewportMatrix() {
|
|
1005
|
+
return this.viewportMatrix;
|
|
1006
|
+
}
|
|
1007
|
+
getContentMatrix() {
|
|
1008
|
+
return this.contentMatrix;
|
|
1009
|
+
}
|
|
1010
|
+
patchViewportMatrix(e) {
|
|
1011
|
+
this.viewportMatrix = {
|
|
1012
|
+
scale: e.scale ?? this.viewportMatrix.scale,
|
|
1013
|
+
x: e.x ?? this.viewportMatrix.x,
|
|
1014
|
+
y: e.y ?? this.viewportMatrix.y
|
|
1015
|
+
}, this.contentMatrix = Q(this.viewportMatrix), this.emitter.emit();
|
|
1016
|
+
}
|
|
1017
|
+
patchContentMatrix(e) {
|
|
1018
|
+
this.contentMatrix = {
|
|
1019
|
+
scale: e.scale ?? this.contentMatrix.scale,
|
|
1020
|
+
x: e.x ?? this.contentMatrix.x,
|
|
1021
|
+
y: e.y ?? this.contentMatrix.y
|
|
1022
|
+
}, this.viewportMatrix = Q(this.contentMatrix), this.emitter.emit();
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
class Se {
|
|
1026
|
+
constructor(e) {
|
|
1027
|
+
this.transformer = e;
|
|
1028
|
+
}
|
|
1029
|
+
getViewportMatrix() {
|
|
1030
|
+
return { ...this.transformer.getViewportMatrix() };
|
|
1031
|
+
}
|
|
1032
|
+
getContentMatrix() {
|
|
1033
|
+
return { ...this.transformer.getContentMatrix() };
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
class Ne {
|
|
1037
|
+
constructor(e) {
|
|
1038
|
+
this.graphStore = e;
|
|
1039
|
+
}
|
|
1040
|
+
getNode(e) {
|
|
1041
|
+
const o = this.graphStore.getNode(e);
|
|
1042
|
+
return o === void 0 ? null : {
|
|
1043
|
+
element: o.element,
|
|
1044
|
+
x: o.x,
|
|
1045
|
+
y: o.y,
|
|
1046
|
+
centerFn: o.centerFn,
|
|
1047
|
+
priority: o.priority
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
getAllNodeIds() {
|
|
1051
|
+
return this.graphStore.getAllNodeIds();
|
|
1052
|
+
}
|
|
1053
|
+
getPort(e) {
|
|
1054
|
+
const o = this.graphStore.getPort(e);
|
|
1055
|
+
return o === void 0 ? null : {
|
|
1056
|
+
element: o.element,
|
|
1057
|
+
direction: o.direction
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
getAllPortIds() {
|
|
1061
|
+
return this.graphStore.getAllPortIds();
|
|
1062
|
+
}
|
|
1063
|
+
getNodePortIds(e) {
|
|
1064
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodePortIds(e);
|
|
1065
|
+
}
|
|
1066
|
+
getPortNodeId(e) {
|
|
1067
|
+
return this.graphStore.getPortNodeId(e) ?? null;
|
|
1068
|
+
}
|
|
1069
|
+
getAllEdgeIds() {
|
|
1070
|
+
return this.graphStore.getAllEdgeIds();
|
|
1071
|
+
}
|
|
1072
|
+
getEdge(e) {
|
|
1073
|
+
const o = this.graphStore.getEdge(e);
|
|
1074
|
+
return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
|
|
1075
|
+
}
|
|
1076
|
+
getPortIncomingEdgeIds(e) {
|
|
1077
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
|
|
1078
|
+
}
|
|
1079
|
+
getPortOutcomingEdgeIds(e) {
|
|
1080
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
|
|
1081
|
+
}
|
|
1082
|
+
getPortCycleEdgeIds(e) {
|
|
1083
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
|
|
1084
|
+
}
|
|
1085
|
+
getPortAdjacentEdgeIds(e) {
|
|
1086
|
+
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
|
|
1087
|
+
}
|
|
1088
|
+
getNodeIncomingEdgeIds(e) {
|
|
1089
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
|
|
1090
|
+
}
|
|
1091
|
+
getNodeOutcomingEdgeIds(e) {
|
|
1092
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
1093
|
+
}
|
|
1094
|
+
getNodeCycleEdgeIds(e) {
|
|
1095
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
|
|
1096
|
+
}
|
|
1097
|
+
getNodeAdjacentEdgeIds(e) {
|
|
1098
|
+
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
class Te {
|
|
1102
|
+
constructor() {
|
|
1103
|
+
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1104
|
+
i(this, "ports", /* @__PURE__ */ new Map());
|
|
702
1105
|
i(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
703
1106
|
i(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
704
1107
|
i(this, "edges", /* @__PURE__ */ new Map());
|
|
@@ -737,16 +1140,16 @@ class oe {
|
|
|
737
1140
|
return Array.from(this.ports.keys());
|
|
738
1141
|
}
|
|
739
1142
|
getNodePortIds(e) {
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
return Array.from(
|
|
1143
|
+
const o = this.nodePorts.get(e);
|
|
1144
|
+
if (o !== void 0)
|
|
1145
|
+
return Array.from(o.keys());
|
|
743
1146
|
}
|
|
744
1147
|
getPortNodeId(e) {
|
|
745
1148
|
return this.portNodeId.get(e);
|
|
746
1149
|
}
|
|
747
1150
|
removePort(e) {
|
|
748
|
-
const
|
|
749
|
-
this.portNodeId.delete(e), this.nodePorts.get(
|
|
1151
|
+
const o = this.portNodeId.get(e);
|
|
1152
|
+
this.portNodeId.delete(e), this.nodePorts.get(o).delete(e), this.ports.delete(e);
|
|
750
1153
|
}
|
|
751
1154
|
addEdge(e) {
|
|
752
1155
|
this.edges.set(e.edgeId, {
|
|
@@ -756,24 +1159,24 @@ class oe {
|
|
|
756
1159
|
priority: e.priority
|
|
757
1160
|
}), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.edgeId), this.incommingEdges.get(e.to).add(e.edgeId)) : this.cycleEdges.get(e.from).add(e.edgeId);
|
|
758
1161
|
}
|
|
759
|
-
updateEdgeFrom(e,
|
|
760
|
-
const
|
|
1162
|
+
updateEdgeFrom(e, o) {
|
|
1163
|
+
const r = this.edges.get(e);
|
|
761
1164
|
this.removeEdge(e), this.addEdge({
|
|
762
1165
|
edgeId: e,
|
|
763
|
-
from:
|
|
764
|
-
to:
|
|
765
|
-
shape:
|
|
766
|
-
priority:
|
|
1166
|
+
from: o,
|
|
1167
|
+
to: r.to,
|
|
1168
|
+
shape: r.shape,
|
|
1169
|
+
priority: r.priority
|
|
767
1170
|
});
|
|
768
1171
|
}
|
|
769
|
-
updateEdgeTo(e,
|
|
770
|
-
const
|
|
1172
|
+
updateEdgeTo(e, o) {
|
|
1173
|
+
const r = this.edges.get(e);
|
|
771
1174
|
this.removeEdge(e), this.addEdge({
|
|
772
1175
|
edgeId: e,
|
|
773
|
-
from:
|
|
774
|
-
to:
|
|
775
|
-
shape:
|
|
776
|
-
priority:
|
|
1176
|
+
from: r.from,
|
|
1177
|
+
to: o,
|
|
1178
|
+
shape: r.shape,
|
|
1179
|
+
priority: r.priority
|
|
777
1180
|
});
|
|
778
1181
|
}
|
|
779
1182
|
getAllEdgeIds() {
|
|
@@ -783,8 +1186,8 @@ class oe {
|
|
|
783
1186
|
return this.edges.get(e);
|
|
784
1187
|
}
|
|
785
1188
|
removeEdge(e) {
|
|
786
|
-
const
|
|
787
|
-
this.cycleEdges.get(
|
|
1189
|
+
const o = this.edges.get(e), r = o.from, n = o.to;
|
|
1190
|
+
this.cycleEdges.get(r).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
|
|
788
1191
|
}
|
|
789
1192
|
clear() {
|
|
790
1193
|
this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.nodes.clear();
|
|
@@ -806,25 +1209,25 @@ class oe {
|
|
|
806
1209
|
];
|
|
807
1210
|
}
|
|
808
1211
|
getNodeIncomingEdgeIds(e) {
|
|
809
|
-
const
|
|
810
|
-
let
|
|
811
|
-
return
|
|
812
|
-
|
|
813
|
-
}),
|
|
1212
|
+
const o = Array.from(this.nodePorts.get(e).keys());
|
|
1213
|
+
let r = [];
|
|
1214
|
+
return o.forEach((n) => {
|
|
1215
|
+
r = [...r, ...this.getPortIncomingEdgeIds(n)];
|
|
1216
|
+
}), r;
|
|
814
1217
|
}
|
|
815
1218
|
getNodeOutcomingEdgeIds(e) {
|
|
816
|
-
const
|
|
817
|
-
let
|
|
818
|
-
return
|
|
819
|
-
|
|
820
|
-
}),
|
|
1219
|
+
const o = Array.from(this.nodePorts.get(e).keys());
|
|
1220
|
+
let r = [];
|
|
1221
|
+
return o.forEach((n) => {
|
|
1222
|
+
r = [...r, ...this.getPortOutcomingEdgeIds(n)];
|
|
1223
|
+
}), r;
|
|
821
1224
|
}
|
|
822
1225
|
getNodeCycleEdgeIds(e) {
|
|
823
|
-
const
|
|
824
|
-
let
|
|
825
|
-
return
|
|
826
|
-
|
|
827
|
-
}),
|
|
1226
|
+
const o = Array.from(this.nodePorts.get(e).keys());
|
|
1227
|
+
let r = [];
|
|
1228
|
+
return o.forEach((n) => {
|
|
1229
|
+
r = [...r, ...this.getPortCycleEdgeIds(n)];
|
|
1230
|
+
}), r;
|
|
828
1231
|
}
|
|
829
1232
|
getNodeAdjacentEdgeIds(e) {
|
|
830
1233
|
return [
|
|
@@ -834,96 +1237,42 @@ class oe {
|
|
|
834
1237
|
];
|
|
835
1238
|
}
|
|
836
1239
|
}
|
|
837
|
-
class
|
|
838
|
-
constructor() {
|
|
839
|
-
i(this, "
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
this
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
this.
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
r(e);
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
const S = () => {
|
|
854
|
-
const t = new Ae();
|
|
855
|
-
return [t, t];
|
|
856
|
-
}, J = (t) => ({
|
|
857
|
-
scale: 1 / t.scale,
|
|
858
|
-
x: -t.x / t.scale,
|
|
859
|
-
y: -t.y / t.scale
|
|
860
|
-
}), Q = {
|
|
861
|
-
scale: 1,
|
|
862
|
-
x: 0,
|
|
863
|
-
y: 0
|
|
864
|
-
};
|
|
865
|
-
class ie {
|
|
866
|
-
constructor() {
|
|
867
|
-
i(this, "viewportMatrix", Q);
|
|
868
|
-
i(this, "contentMatrix", Q);
|
|
869
|
-
i(this, "emitter");
|
|
870
|
-
i(this, "onAfterUpdate");
|
|
871
|
-
[this.emitter, this.onAfterUpdate] = S();
|
|
872
|
-
}
|
|
873
|
-
getViewportMatrix() {
|
|
874
|
-
return this.viewportMatrix;
|
|
875
|
-
}
|
|
876
|
-
getContentMatrix() {
|
|
877
|
-
return this.contentMatrix;
|
|
878
|
-
}
|
|
879
|
-
patchViewportMatrix(e) {
|
|
880
|
-
this.viewportMatrix = {
|
|
881
|
-
scale: e.scale ?? this.viewportMatrix.scale,
|
|
882
|
-
x: e.x ?? this.viewportMatrix.x,
|
|
883
|
-
y: e.y ?? this.viewportMatrix.y
|
|
884
|
-
}, this.contentMatrix = J(this.viewportMatrix), this.emitter.emit();
|
|
885
|
-
}
|
|
886
|
-
patchContentMatrix(e) {
|
|
887
|
-
this.contentMatrix = {
|
|
888
|
-
scale: e.scale ?? this.contentMatrix.scale,
|
|
889
|
-
x: e.x ?? this.contentMatrix.x,
|
|
890
|
-
y: e.y ?? this.contentMatrix.y
|
|
891
|
-
}, this.viewportMatrix = J(this.contentMatrix), this.emitter.emit();
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
class ne {
|
|
895
|
-
constructor(e) {
|
|
896
|
-
this.transformer = e;
|
|
897
|
-
}
|
|
898
|
-
getViewportMatrix() {
|
|
899
|
-
return { ...this.transformer.getViewportMatrix() };
|
|
900
|
-
}
|
|
901
|
-
getContentMatrix() {
|
|
902
|
-
return { ...this.transformer.getContentMatrix() };
|
|
1240
|
+
class me {
|
|
1241
|
+
constructor(e, o) {
|
|
1242
|
+
i(this, "viewport");
|
|
1243
|
+
i(this, "graph");
|
|
1244
|
+
i(this, "viewportTransformer");
|
|
1245
|
+
i(this, "graphStore");
|
|
1246
|
+
i(this, "htmlView");
|
|
1247
|
+
i(this, "graphStoreController");
|
|
1248
|
+
this.graphStore = new Te(), this.graph = new Ne(this.graphStore), this.viewportTransformer = new pe(), this.viewport = new Se(this.viewportTransformer), this.htmlView = o(this.graphStore, this.viewportTransformer), this.graphStoreController = new se(
|
|
1249
|
+
this.graphStore,
|
|
1250
|
+
Ae(e)
|
|
1251
|
+
);
|
|
903
1252
|
}
|
|
904
1253
|
}
|
|
905
|
-
const
|
|
1254
|
+
const Me = () => {
|
|
906
1255
|
const t = document.createElement("div");
|
|
907
1256
|
return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
|
|
908
|
-
},
|
|
1257
|
+
}, Pe = () => {
|
|
909
1258
|
const t = document.createElement("div");
|
|
910
1259
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
|
|
911
|
-
},
|
|
1260
|
+
}, Ve = () => {
|
|
912
1261
|
const t = document.createElement("div");
|
|
913
1262
|
return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
|
|
914
1263
|
};
|
|
915
|
-
class
|
|
916
|
-
constructor(e,
|
|
1264
|
+
class ee {
|
|
1265
|
+
constructor(e, o) {
|
|
917
1266
|
i(this, "canvasWrapper", null);
|
|
918
|
-
i(this, "host",
|
|
919
|
-
i(this, "container",
|
|
1267
|
+
i(this, "host", Me());
|
|
1268
|
+
i(this, "container", Pe());
|
|
920
1269
|
i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
|
|
921
1270
|
i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
922
1271
|
i(this, "applyTransform", () => {
|
|
923
1272
|
const e = this.viewportTransformer.getContentMatrix();
|
|
924
1273
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
|
|
925
1274
|
});
|
|
926
|
-
this.graphStore = e, this.viewportTransformer =
|
|
1275
|
+
this.graphStore = e, this.viewportTransformer = o, this.host.appendChild(this.container), this.viewportTransformer.onAfterUpdate.subscribe(this.applyTransform);
|
|
927
1276
|
}
|
|
928
1277
|
attach(e) {
|
|
929
1278
|
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
|
|
@@ -932,80 +1281,80 @@ class K {
|
|
|
932
1281
|
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
933
1282
|
}
|
|
934
1283
|
attachNode(e) {
|
|
935
|
-
const
|
|
936
|
-
|
|
1284
|
+
const o = this.graphStore.getNode(e), r = Ve();
|
|
1285
|
+
r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodeCoordinates(e), this.updateNodePriority(e), r.style.visibility = "visible";
|
|
937
1286
|
}
|
|
938
1287
|
detachNode(e) {
|
|
939
|
-
const
|
|
940
|
-
|
|
1288
|
+
const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
|
|
1289
|
+
r.removeChild(o.element), this.container.removeChild(r), this.nodeIdToWrapperElementMap.delete(e);
|
|
941
1290
|
}
|
|
942
1291
|
attachEdge(e) {
|
|
943
|
-
const
|
|
944
|
-
this.edgeIdToElementMap.set(e,
|
|
1292
|
+
const o = this.graphStore.getEdge(e);
|
|
1293
|
+
this.edgeIdToElementMap.set(e, o.shape.svg), this.container.appendChild(o.shape.svg), this.renderEdge(e), this.updateEdgePriority(e);
|
|
945
1294
|
}
|
|
946
1295
|
detachEdge(e) {
|
|
947
|
-
const
|
|
948
|
-
this.container.removeChild(
|
|
1296
|
+
const o = this.graphStore.getEdge(e);
|
|
1297
|
+
this.container.removeChild(o.shape.svg), this.edgeIdToElementMap.delete(e);
|
|
949
1298
|
}
|
|
950
1299
|
clear() {
|
|
951
|
-
this.edgeIdToElementMap.forEach((e,
|
|
952
|
-
this.detachEdge(
|
|
953
|
-
}), this.nodeIdToWrapperElementMap.forEach((e,
|
|
954
|
-
this.detachNode(
|
|
1300
|
+
this.edgeIdToElementMap.forEach((e, o) => {
|
|
1301
|
+
this.detachEdge(o);
|
|
1302
|
+
}), this.nodeIdToWrapperElementMap.forEach((e, o) => {
|
|
1303
|
+
this.detachNode(o);
|
|
955
1304
|
});
|
|
956
1305
|
}
|
|
957
1306
|
destroy() {
|
|
958
1307
|
this.clear(), this.detach(), this.viewportTransformer.onAfterUpdate.unsubscribe(this.applyTransform), this.host.removeChild(this.container);
|
|
959
1308
|
}
|
|
960
1309
|
updateNodeCoordinates(e) {
|
|
961
|
-
const
|
|
962
|
-
|
|
1310
|
+
const o = this.nodeIdToWrapperElementMap.get(e), r = this.graphStore.getNode(e), { width: n, height: d } = r.element.getBoundingClientRect(), s = this.viewportTransformer.getViewportMatrix().scale, h = r.centerFn(n, d), c = r.x - s * h.x, a = r.y - s * h.y;
|
|
1311
|
+
o.style.transform = `translate(${c}px, ${a}px)`;
|
|
963
1312
|
}
|
|
964
1313
|
updateNodePriority(e) {
|
|
965
|
-
const
|
|
966
|
-
|
|
1314
|
+
const o = this.graphStore.getNode(e), r = this.nodeIdToWrapperElementMap.get(e);
|
|
1315
|
+
r.style.zIndex = `${o.priority}`;
|
|
967
1316
|
}
|
|
968
1317
|
updateEdgeShape(e) {
|
|
969
|
-
const
|
|
970
|
-
this.container.removeChild(
|
|
971
|
-
const
|
|
972
|
-
this.edgeIdToElementMap.set(e,
|
|
1318
|
+
const o = this.edgeIdToElementMap.get(e);
|
|
1319
|
+
this.container.removeChild(o);
|
|
1320
|
+
const r = this.graphStore.getEdge(e);
|
|
1321
|
+
this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
|
|
973
1322
|
}
|
|
974
1323
|
renderEdge(e) {
|
|
975
|
-
const
|
|
1324
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), n = this.graphStore.getPort(o.to), d = r.element.getBoundingClientRect(), s = n.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), a = {
|
|
976
1325
|
x: c.scale * (d.left - h.left) + c.x,
|
|
977
1326
|
y: c.scale * (d.top - h.top) + c.y
|
|
978
1327
|
}, l = {
|
|
979
|
-
x: c.scale * (
|
|
980
|
-
y: c.scale * (
|
|
1328
|
+
x: c.scale * (s.left - h.left) + c.x,
|
|
1329
|
+
y: c.scale * (s.top - h.top) + c.y
|
|
981
1330
|
}, g = {
|
|
982
1331
|
x: a.x,
|
|
983
1332
|
y: a.y,
|
|
984
1333
|
width: d.width * c.scale,
|
|
985
1334
|
height: d.height * c.scale,
|
|
986
|
-
direction:
|
|
987
|
-
portId:
|
|
988
|
-
nodeId: this.graphStore.getPortNodeId(
|
|
1335
|
+
direction: r.direction,
|
|
1336
|
+
portId: o.from,
|
|
1337
|
+
nodeId: this.graphStore.getPortNodeId(o.from)
|
|
989
1338
|
}, f = {
|
|
990
1339
|
x: l.x,
|
|
991
1340
|
y: l.y,
|
|
992
|
-
width:
|
|
993
|
-
height:
|
|
994
|
-
direction:
|
|
995
|
-
portId:
|
|
996
|
-
nodeId: this.graphStore.getPortNodeId(
|
|
1341
|
+
width: s.width * c.scale,
|
|
1342
|
+
height: s.height * c.scale,
|
|
1343
|
+
direction: n.direction,
|
|
1344
|
+
portId: o.to,
|
|
1345
|
+
nodeId: this.graphStore.getPortNodeId(o.to)
|
|
997
1346
|
};
|
|
998
|
-
|
|
1347
|
+
o.shape.render({
|
|
999
1348
|
from: g,
|
|
1000
1349
|
to: f
|
|
1001
1350
|
});
|
|
1002
1351
|
}
|
|
1003
1352
|
updateEdgePriority(e) {
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1353
|
+
const o = this.graphStore.getEdge(e);
|
|
1354
|
+
o.shape.svg.style.zIndex = `${o.priority}`;
|
|
1006
1355
|
}
|
|
1007
1356
|
}
|
|
1008
|
-
class
|
|
1357
|
+
class be {
|
|
1009
1358
|
constructor(e) {
|
|
1010
1359
|
i(this, "xFrom", 1 / 0);
|
|
1011
1360
|
i(this, "yFrom", 1 / 0);
|
|
@@ -1014,704 +1363,129 @@ class Ne {
|
|
|
1014
1363
|
this.graphStore = e;
|
|
1015
1364
|
}
|
|
1016
1365
|
setRenderingBox(e) {
|
|
1017
|
-
this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
|
|
1018
|
-
}
|
|
1019
|
-
hasNode(e) {
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1022
|
-
}
|
|
1023
|
-
hasEdge(e) {
|
|
1024
|
-
const
|
|
1025
|
-
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
class
|
|
1029
|
-
constructor(e,
|
|
1030
|
-
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
1031
|
-
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
1032
|
-
i(this, "renderingBox");
|
|
1033
|
-
i(this, "updateViewport", (e) => {
|
|
1034
|
-
this.renderingBox.setRenderingBox(e);
|
|
1035
|
-
const
|
|
1036
|
-
this.graphStore.getAllNodeIds().forEach((
|
|
1037
|
-
const h = this.renderingBox.hasNode(
|
|
1038
|
-
h && !c ?
|
|
1039
|
-
}), this.graphStore.getAllEdgeIds().forEach((
|
|
1040
|
-
const h = this.renderingBox.hasEdge(
|
|
1041
|
-
h && (this.renderingBox.hasNode(l) || (
|
|
1042
|
-
}), d.forEach((
|
|
1043
|
-
this.handleDetachEdge(
|
|
1044
|
-
}),
|
|
1045
|
-
this.handleDetachNode(
|
|
1046
|
-
}),
|
|
1047
|
-
this.handleAttachNode(
|
|
1048
|
-
}),
|
|
1049
|
-
this.handleAttachEdge(
|
|
1050
|
-
});
|
|
1051
|
-
});
|
|
1052
|
-
this.htmlView = e, this.graphStore = r, this.trigger = o, this.renderingBox = new Ne(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
1053
|
-
}
|
|
1054
|
-
attach(e) {
|
|
1055
|
-
this.htmlView.attach(e);
|
|
1056
|
-
}
|
|
1057
|
-
detach() {
|
|
1058
|
-
this.htmlView.detach();
|
|
1059
|
-
}
|
|
1060
|
-
attachNode(e) {
|
|
1061
|
-
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
1062
|
-
}
|
|
1063
|
-
detachNode(e) {
|
|
1064
|
-
this.attachedNodes.has(e) && this.handleDetachNode(e);
|
|
1065
|
-
}
|
|
1066
|
-
attachEdge(e) {
|
|
1067
|
-
this.renderingBox.hasEdge(e) && this.attachSingleEdge(e);
|
|
1068
|
-
}
|
|
1069
|
-
detachEdge(e) {
|
|
1070
|
-
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
1071
|
-
}
|
|
1072
|
-
updateNodeCoordinates(e) {
|
|
1073
|
-
this.attachedNodes.has(e) ? this.htmlView.updateNodeCoordinates(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((r) => {
|
|
1074
|
-
this.attachSingleEdge(r);
|
|
1075
|
-
}));
|
|
1076
|
-
}
|
|
1077
|
-
updateNodePriority(e) {
|
|
1078
|
-
this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
|
|
1079
|
-
}
|
|
1080
|
-
updateEdgeShape(e) {
|
|
1081
|
-
this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
|
|
1082
|
-
}
|
|
1083
|
-
renderEdge(e) {
|
|
1084
|
-
this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
|
|
1085
|
-
}
|
|
1086
|
-
updateEdgePriority(e) {
|
|
1087
|
-
this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
|
|
1088
|
-
}
|
|
1089
|
-
clear() {
|
|
1090
|
-
this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
|
|
1091
|
-
}
|
|
1092
|
-
destroy() {
|
|
1093
|
-
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
1094
|
-
}
|
|
1095
|
-
attachSingleEdge(e) {
|
|
1096
|
-
const r = this.graphStore.getEdge(e), o = this.graphStore.getPortNodeId(r.from), s = this.graphStore.getPortNodeId(r.to);
|
|
1097
|
-
this.attachedNodes.has(o) || this.handleAttachNode(o), this.attachedNodes.has(s) || this.handleAttachNode(s), this.handleAttachEdge(e);
|
|
1098
|
-
}
|
|
1099
|
-
handleAttachNode(e) {
|
|
1100
|
-
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
1101
|
-
}
|
|
1102
|
-
handleDetachNode(e) {
|
|
1103
|
-
this.htmlView.detachNode(e), this.attachedNodes.delete(e);
|
|
1104
|
-
}
|
|
1105
|
-
handleAttachEdge(e) {
|
|
1106
|
-
this.attachedEdges.add(e), this.htmlView.attachEdge(e);
|
|
1107
|
-
}
|
|
1108
|
-
handleDetachEdge(e) {
|
|
1109
|
-
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
class L {
|
|
1113
|
-
constructor(e) {
|
|
1114
|
-
i(this, "counter", 0);
|
|
1115
|
-
this.checkExists = e;
|
|
1116
|
-
}
|
|
1117
|
-
create(e) {
|
|
1118
|
-
if (e !== void 0)
|
|
1119
|
-
return e;
|
|
1120
|
-
for (; this.checkExists(this.counter); )
|
|
1121
|
-
this.counter++;
|
|
1122
|
-
return this.counter;
|
|
1123
|
-
}
|
|
1124
|
-
reset() {
|
|
1125
|
-
this.counter = 0;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
class A extends Error {
|
|
1129
|
-
constructor() {
|
|
1130
|
-
super(...arguments);
|
|
1131
|
-
i(this, "name", "HtmlGraphError");
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
class se {
|
|
1135
|
-
constructor(e, r) {
|
|
1136
|
-
i(this, "nodeIdGenerator", new L(
|
|
1137
|
-
(e) => this.graphStore.getNode(e) !== void 0
|
|
1138
|
-
));
|
|
1139
|
-
i(this, "portIdGenerator", new L(
|
|
1140
|
-
(e) => this.graphStore.getPort(e) !== void 0
|
|
1141
|
-
));
|
|
1142
|
-
i(this, "edgeIdGenerator", new L(
|
|
1143
|
-
(e) => this.graphStore.getEdge(e) !== void 0
|
|
1144
|
-
));
|
|
1145
|
-
i(this, "onAfterNodeAdded");
|
|
1146
|
-
i(this, "onAfterNodeAddedEmitter");
|
|
1147
|
-
i(this, "onAfterEdgeAdded");
|
|
1148
|
-
i(this, "onAfterEdgeAddedEmitter");
|
|
1149
|
-
i(this, "onAfterEdgeShapeUpdated");
|
|
1150
|
-
i(this, "onAfterEdgeShapeUpdatedEmitter");
|
|
1151
|
-
i(this, "onAfterEdgePriorityUpdated");
|
|
1152
|
-
i(this, "onAfterEdgePriorityUpdatedEmitter");
|
|
1153
|
-
i(this, "onAfterEdgeUpdated");
|
|
1154
|
-
i(this, "onAfterEdgeUpdatedEmitter");
|
|
1155
|
-
i(this, "onAfterPortUpdated");
|
|
1156
|
-
i(this, "onAfterPortUpdatedEmitter");
|
|
1157
|
-
i(this, "onAfterNodePriorityUpdated");
|
|
1158
|
-
i(this, "onAfterNodePriorityUpdatedEmitter");
|
|
1159
|
-
i(this, "onAfterNodeUpdated");
|
|
1160
|
-
i(this, "onAfterNodeUpdatedEmitter");
|
|
1161
|
-
i(this, "onBeforeEdgeRemoved");
|
|
1162
|
-
i(this, "onBeforeEdgeRemovedEmitter");
|
|
1163
|
-
i(this, "onBeforeNodeRemoved");
|
|
1164
|
-
i(this, "onBeforeNodeRemovedEmitter");
|
|
1165
|
-
this.graphStore = e, this.options = r, [this.onAfterNodeAddedEmitter, this.onAfterNodeAdded] = S(), [this.onAfterEdgeAddedEmitter, this.onAfterEdgeAdded] = S(), [this.onAfterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = S(), [this.onAfterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = S(), [this.onAfterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = S(), [this.onAfterPortUpdatedEmitter, this.onAfterPortUpdated] = S(), [this.onAfterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = S(), [this.onAfterNodeUpdatedEmitter, this.onAfterNodeUpdated] = S(), [this.onBeforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = S(), [this.onBeforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = S();
|
|
1166
|
-
}
|
|
1167
|
-
addNode(e) {
|
|
1168
|
-
const r = this.nodeIdGenerator.create(e.id);
|
|
1169
|
-
if (this.graphStore.getNode(r) !== void 0)
|
|
1170
|
-
throw new A("failed to add node with existing id");
|
|
1171
|
-
this.graphStore.addNode({
|
|
1172
|
-
nodeId: r,
|
|
1173
|
-
element: e.element,
|
|
1174
|
-
x: e.x,
|
|
1175
|
-
y: e.y,
|
|
1176
|
-
centerFn: e.centerFn ?? this.options.nodes.centerFn,
|
|
1177
|
-
priority: e.priority ?? this.options.nodes.priorityFn()
|
|
1178
|
-
}), this.onAfterNodeAddedEmitter.emit(r), Array.from(e.ports ?? []).forEach((o) => {
|
|
1179
|
-
this.markPort({
|
|
1180
|
-
id: o.id,
|
|
1181
|
-
element: o.element,
|
|
1182
|
-
nodeId: r,
|
|
1183
|
-
direction: o.direction
|
|
1184
|
-
});
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
markPort(e) {
|
|
1188
|
-
const r = this.portIdGenerator.create(e.id);
|
|
1189
|
-
if (this.graphStore.getPort(r) !== void 0)
|
|
1190
|
-
throw new A("failed to add port with existing id");
|
|
1191
|
-
if (this.graphStore.getNode(e.nodeId) === void 0)
|
|
1192
|
-
throw new A("failed to set port on nonexisting node");
|
|
1193
|
-
this.graphStore.addPort({
|
|
1194
|
-
portId: r,
|
|
1195
|
-
element: e.element,
|
|
1196
|
-
nodeId: e.nodeId,
|
|
1197
|
-
direction: e.direction ?? this.options.ports.direction
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1200
|
-
addEdge(e) {
|
|
1201
|
-
const r = this.edgeIdGenerator.create(e.id);
|
|
1202
|
-
if (this.graphStore.getEdge(r) !== void 0)
|
|
1203
|
-
throw new A("failed to add edge with existing id");
|
|
1204
|
-
if (this.graphStore.getPort(e.from) === void 0)
|
|
1205
|
-
throw new A("failed to add edge from nonexisting port");
|
|
1206
|
-
if (this.graphStore.getPort(e.to) === void 0)
|
|
1207
|
-
throw new A("failed to add edge to nonexisting port");
|
|
1208
|
-
this.graphStore.addEdge({
|
|
1209
|
-
edgeId: r,
|
|
1210
|
-
from: e.from,
|
|
1211
|
-
to: e.to,
|
|
1212
|
-
shape: e.shape ?? this.options.edges.shapeFactory(),
|
|
1213
|
-
priority: e.priority ?? this.options.edges.priorityFn()
|
|
1214
|
-
}), this.onAfterEdgeAddedEmitter.emit(r);
|
|
1215
|
-
}
|
|
1216
|
-
updateEdge(e, r) {
|
|
1217
|
-
const o = this.graphStore.getEdge(e);
|
|
1218
|
-
if (o === void 0)
|
|
1219
|
-
throw new A("failed to update nonexisting edge");
|
|
1220
|
-
r.shape !== void 0 && (o.shape = r.shape, this.onAfterEdgeShapeUpdatedEmitter.emit(e)), r.from !== void 0 && this.graphStore.updateEdgeFrom(e, r.from), r.to !== void 0 && this.graphStore.updateEdgeTo(e, r.to), this.onAfterEdgeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterEdgePriorityUpdatedEmitter.emit(e));
|
|
1221
|
-
}
|
|
1222
|
-
updatePort(e, r) {
|
|
1223
|
-
const o = this.graphStore.getPort(e);
|
|
1224
|
-
if (o === void 0)
|
|
1225
|
-
throw new A("failed to unset nonexisting port");
|
|
1226
|
-
o.direction = r.direction ?? o.direction, this.onAfterPortUpdatedEmitter.emit(e);
|
|
1227
|
-
}
|
|
1228
|
-
updateNode(e, r) {
|
|
1229
|
-
const o = this.graphStore.getNode(e);
|
|
1230
|
-
if (o === void 0)
|
|
1231
|
-
throw new A("failed to update nonexisting node");
|
|
1232
|
-
o.x = (r == null ? void 0 : r.x) ?? o.x, o.y = (r == null ? void 0 : r.y) ?? o.y, o.centerFn = r.centerFn ?? o.centerFn, this.onAfterNodeUpdatedEmitter.emit(e), r.priority !== void 0 && (o.priority = r.priority, this.onAfterNodePriorityUpdatedEmitter.emit(e));
|
|
1233
|
-
}
|
|
1234
|
-
removeEdge(e) {
|
|
1235
|
-
if (this.graphStore.getEdge(e) === void 0)
|
|
1236
|
-
throw new A("failed to remove nonexisting edge");
|
|
1237
|
-
this.onBeforeEdgeRemovedEmitter.emit(e), this.graphStore.removeEdge(e);
|
|
1238
|
-
}
|
|
1239
|
-
unmarkPort(e) {
|
|
1240
|
-
if (this.graphStore.getPort(e) === void 0)
|
|
1241
|
-
throw new A("failed to unset nonexisting port");
|
|
1242
|
-
this.graphStore.getPortAdjacentEdgeIds(e).forEach((r) => {
|
|
1243
|
-
this.removeEdge(r);
|
|
1244
|
-
}), this.graphStore.removePort(e);
|
|
1245
|
-
}
|
|
1246
|
-
removeNode(e) {
|
|
1247
|
-
if (this.graphStore.getNode(e) === void 0)
|
|
1248
|
-
throw new A("failed to remove nonexisting node");
|
|
1249
|
-
this.graphStore.getNodePortIds(e).forEach((r) => {
|
|
1250
|
-
this.unmarkPort(r);
|
|
1251
|
-
}), this.onBeforeNodeRemovedEmitter.emit(e), this.graphStore.removeNode(e);
|
|
1252
|
-
}
|
|
1253
|
-
clear() {
|
|
1254
|
-
this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
class he {
|
|
1258
|
-
constructor(e) {
|
|
1259
|
-
this.graphStore = e;
|
|
1260
|
-
}
|
|
1261
|
-
getNode(e) {
|
|
1262
|
-
const r = this.graphStore.getNode(e);
|
|
1263
|
-
return r === void 0 ? null : {
|
|
1264
|
-
element: r.element,
|
|
1265
|
-
x: r.x,
|
|
1266
|
-
y: r.y,
|
|
1267
|
-
centerFn: r.centerFn,
|
|
1268
|
-
priority: r.priority
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
getAllNodeIds() {
|
|
1272
|
-
return this.graphStore.getAllNodeIds();
|
|
1273
|
-
}
|
|
1274
|
-
getPort(e) {
|
|
1275
|
-
const r = this.graphStore.getPort(e);
|
|
1276
|
-
return r === void 0 ? null : {
|
|
1277
|
-
element: r.element,
|
|
1278
|
-
direction: r.direction
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
getAllPortIds() {
|
|
1282
|
-
return this.graphStore.getAllPortIds();
|
|
1283
|
-
}
|
|
1284
|
-
getNodePortIds(e) {
|
|
1285
|
-
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodePortIds(e);
|
|
1286
|
-
}
|
|
1287
|
-
getPortNodeId(e) {
|
|
1288
|
-
return this.graphStore.getPortNodeId(e) ?? null;
|
|
1289
|
-
}
|
|
1290
|
-
getAllEdgeIds() {
|
|
1291
|
-
return this.graphStore.getAllEdgeIds();
|
|
1292
|
-
}
|
|
1293
|
-
getEdge(e) {
|
|
1294
|
-
const r = this.graphStore.getEdge(e);
|
|
1295
|
-
return r === void 0 ? null : { from: r.from, to: r.to, priority: r.priority };
|
|
1296
|
-
}
|
|
1297
|
-
getPortIncomingEdgeIds(e) {
|
|
1298
|
-
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
|
|
1299
|
-
}
|
|
1300
|
-
getPortOutcomingEdgeIds(e) {
|
|
1301
|
-
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutcomingEdgeIds(e);
|
|
1302
|
-
}
|
|
1303
|
-
getPortCycleEdgeIds(e) {
|
|
1304
|
-
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
|
|
1305
|
-
}
|
|
1306
|
-
getPortAdjacentEdgeIds(e) {
|
|
1307
|
-
return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
|
|
1308
|
-
}
|
|
1309
|
-
getNodeIncomingEdgeIds(e) {
|
|
1310
|
-
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
|
|
1311
|
-
}
|
|
1312
|
-
getNodeOutcomingEdgeIds(e) {
|
|
1313
|
-
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
1314
|
-
}
|
|
1315
|
-
getNodeCycleEdgeIds(e) {
|
|
1316
|
-
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
|
|
1317
|
-
}
|
|
1318
|
-
getNodeAdjacentEdgeIds(e) {
|
|
1319
|
-
return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
class Ge {
|
|
1323
|
-
constructor(e) {
|
|
1324
|
-
i(this, "transformation");
|
|
1325
|
-
i(this, "model");
|
|
1326
|
-
i(this, "internalTransformation");
|
|
1327
|
-
i(this, "internalModel");
|
|
1328
|
-
i(this, "graphStoreController");
|
|
1329
|
-
i(this, "htmlView");
|
|
1330
|
-
i(this, "onAfterNodeAdded", (e) => {
|
|
1331
|
-
this.htmlView.attachNode(e);
|
|
1332
|
-
});
|
|
1333
|
-
i(this, "onAfterEdgeAdded", (e) => {
|
|
1334
|
-
this.htmlView.attachEdge(e);
|
|
1335
|
-
});
|
|
1336
|
-
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1337
|
-
this.htmlView.updateEdgeShape(e);
|
|
1338
|
-
});
|
|
1339
|
-
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1340
|
-
this.htmlView.updateEdgePriority(e);
|
|
1341
|
-
});
|
|
1342
|
-
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1343
|
-
this.htmlView.renderEdge(e);
|
|
1344
|
-
});
|
|
1345
|
-
i(this, "onAfterPortUpdated", (e) => {
|
|
1346
|
-
this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1347
|
-
this.htmlView.renderEdge(o);
|
|
1348
|
-
});
|
|
1349
|
-
});
|
|
1350
|
-
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1351
|
-
this.htmlView.updateNodePriority(e);
|
|
1352
|
-
});
|
|
1353
|
-
i(this, "onAfterNodeUpdated", (e) => {
|
|
1354
|
-
this.htmlView.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1355
|
-
this.htmlView.renderEdge(o);
|
|
1356
|
-
});
|
|
1357
|
-
});
|
|
1358
|
-
i(this, "onBeforeEdgeRemoved", (e) => {
|
|
1359
|
-
this.htmlView.detachEdge(e);
|
|
1360
|
-
});
|
|
1361
|
-
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1362
|
-
this.htmlView.detachNode(e);
|
|
1363
|
-
});
|
|
1364
|
-
this.internalModel = new oe(), this.model = new he(this.internalModel), this.internalTransformation = new ie(), this.transformation = new ne(
|
|
1365
|
-
this.internalTransformation
|
|
1366
|
-
), this.htmlView = new K(
|
|
1367
|
-
this.internalModel,
|
|
1368
|
-
this.internalTransformation
|
|
1369
|
-
), this.graphStoreController = new se(
|
|
1370
|
-
this.internalModel,
|
|
1371
|
-
xe(e)
|
|
1372
|
-
), this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1373
|
-
this.onAfterEdgeShapeUpdated
|
|
1374
|
-
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
1375
|
-
this.onAfterEdgePriorityUpdated
|
|
1376
|
-
), this.graphStoreController.onAfterEdgeUpdated.subscribe(
|
|
1377
|
-
this.onAfterEdgeUpdated
|
|
1378
|
-
), this.graphStoreController.onAfterPortUpdated.subscribe(
|
|
1379
|
-
this.onAfterPortUpdated
|
|
1380
|
-
), this.graphStoreController.onAfterNodePriorityUpdated.subscribe(
|
|
1381
|
-
this.onAfterNodePriorityUpdated
|
|
1382
|
-
), this.graphStoreController.onAfterNodeUpdated.subscribe(
|
|
1383
|
-
this.onAfterNodeUpdated
|
|
1384
|
-
), this.graphStoreController.onBeforeEdgeRemoved.subscribe(
|
|
1385
|
-
this.onBeforeEdgeRemoved
|
|
1386
|
-
), this.graphStoreController.onBeforeNodeRemoved.subscribe(
|
|
1387
|
-
this.onBeforeNodeRemoved
|
|
1388
|
-
);
|
|
1389
|
-
}
|
|
1390
|
-
attach(e) {
|
|
1391
|
-
return this.htmlView.attach(e), this;
|
|
1392
|
-
}
|
|
1393
|
-
detach() {
|
|
1394
|
-
return this.htmlView.detach(), this;
|
|
1395
|
-
}
|
|
1396
|
-
addNode(e) {
|
|
1397
|
-
return this.graphStoreController.addNode(e), this;
|
|
1398
|
-
}
|
|
1399
|
-
updateNode(e, r) {
|
|
1400
|
-
return this.graphStoreController.updateNode(e, r ?? {}), this;
|
|
1401
|
-
}
|
|
1402
|
-
removeNode(e) {
|
|
1403
|
-
return this.graphStoreController.removeNode(e), this;
|
|
1404
|
-
}
|
|
1405
|
-
addEdge(e) {
|
|
1406
|
-
return this.graphStoreController.addEdge(e), this;
|
|
1407
|
-
}
|
|
1408
|
-
updateEdge(e, r) {
|
|
1409
|
-
return this.graphStoreController.updateEdge(e, r ?? {}), this;
|
|
1410
|
-
}
|
|
1411
|
-
removeEdge(e) {
|
|
1412
|
-
return this.graphStoreController.removeEdge(e), this;
|
|
1413
|
-
}
|
|
1414
|
-
markPort(e) {
|
|
1415
|
-
return this.graphStoreController.markPort(e), this;
|
|
1416
|
-
}
|
|
1417
|
-
updatePort(e, r) {
|
|
1418
|
-
return this.graphStoreController.updatePort(e, r ?? {}), this;
|
|
1419
|
-
}
|
|
1420
|
-
unmarkPort(e) {
|
|
1421
|
-
return this.graphStoreController.unmarkPort(e), this;
|
|
1422
|
-
}
|
|
1423
|
-
patchViewportMatrix(e) {
|
|
1424
|
-
return this.internalTransformation.patchViewportMatrix(e), this;
|
|
1425
|
-
}
|
|
1426
|
-
patchContentMatrix(e) {
|
|
1427
|
-
return this.internalTransformation.patchContentMatrix(e), this;
|
|
1428
|
-
}
|
|
1429
|
-
clear() {
|
|
1430
|
-
return this.htmlView.clear(), this.graphStoreController.clear(), this;
|
|
1431
|
-
}
|
|
1432
|
-
destroy() {
|
|
1433
|
-
this.htmlView.destroy(), this.graphStoreController.clear(), this.graphStoreController.onAfterNodeAdded.unsubscribe(
|
|
1434
|
-
this.onAfterNodeAdded
|
|
1435
|
-
), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
|
|
1436
|
-
this.onAfterEdgeAdded
|
|
1437
|
-
), this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1438
|
-
this.onAfterEdgeShapeUpdated
|
|
1439
|
-
), this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1440
|
-
this.onAfterEdgePriorityUpdated
|
|
1441
|
-
), this.graphStoreController.onAfterEdgeUpdated.unsubscribe(
|
|
1442
|
-
this.onAfterEdgeUpdated
|
|
1443
|
-
), this.graphStoreController.onAfterPortUpdated.unsubscribe(
|
|
1444
|
-
this.onAfterPortUpdated
|
|
1445
|
-
), this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(
|
|
1446
|
-
this.onAfterNodePriorityUpdated
|
|
1447
|
-
), this.graphStoreController.onAfterNodeUpdated.unsubscribe(
|
|
1448
|
-
this.onAfterNodeUpdated
|
|
1449
|
-
), this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(
|
|
1450
|
-
this.onBeforeEdgeRemoved
|
|
1451
|
-
), this.graphStoreController.onBeforeNodeRemoved.unsubscribe(
|
|
1452
|
-
this.onBeforeNodeRemoved
|
|
1453
|
-
);
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
class Te {
|
|
1457
|
-
constructor(e) {
|
|
1458
|
-
i(this, "transformation");
|
|
1459
|
-
i(this, "model");
|
|
1460
|
-
i(this, "internalTransformation");
|
|
1461
|
-
i(this, "internalModel");
|
|
1462
|
-
i(this, "graphStoreController");
|
|
1463
|
-
i(this, "htmlView");
|
|
1464
|
-
i(this, "onAfterNodeAdded", (e) => {
|
|
1465
|
-
this.htmlView.attachNode(e);
|
|
1466
|
-
});
|
|
1467
|
-
i(this, "onAfterEdgeAdded", (e) => {
|
|
1468
|
-
this.htmlView.attachEdge(e);
|
|
1469
|
-
});
|
|
1470
|
-
i(this, "onAfterEdgeShapeUpdated", (e) => {
|
|
1471
|
-
this.htmlView.updateEdgeShape(e);
|
|
1472
|
-
});
|
|
1473
|
-
i(this, "onAfterEdgePriorityUpdated", (e) => {
|
|
1474
|
-
this.htmlView.updateEdgePriority(e);
|
|
1475
|
-
});
|
|
1476
|
-
i(this, "onAfterEdgeUpdated", (e) => {
|
|
1477
|
-
this.htmlView.renderEdge(e);
|
|
1478
|
-
});
|
|
1479
|
-
i(this, "onAfterPortUpdated", (e) => {
|
|
1480
|
-
this.internalModel.getPortAdjacentEdgeIds(e).forEach((o) => {
|
|
1481
|
-
this.htmlView.renderEdge(o);
|
|
1482
|
-
});
|
|
1483
|
-
});
|
|
1484
|
-
i(this, "onAfterNodePriorityUpdated", (e) => {
|
|
1485
|
-
this.htmlView.updateNodePriority(e);
|
|
1486
|
-
});
|
|
1487
|
-
i(this, "onAfterNodeUpdated", (e) => {
|
|
1488
|
-
this.htmlView.updateNodeCoordinates(e), this.internalModel.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1489
|
-
this.htmlView.renderEdge(o);
|
|
1366
|
+
this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
|
|
1367
|
+
}
|
|
1368
|
+
hasNode(e) {
|
|
1369
|
+
const o = this.graphStore.getNode(e);
|
|
1370
|
+
return o.x >= this.xFrom && o.x <= this.xTo && o.y >= this.yFrom && o.y <= this.yTo;
|
|
1371
|
+
}
|
|
1372
|
+
hasEdge(e) {
|
|
1373
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPortNodeId(o.from), n = this.graphStore.getPortNodeId(o.to), d = this.graphStore.getNode(r), s = this.graphStore.getNode(n), h = Math.min(d.x, s.x), c = Math.max(d.x, s.x), a = Math.min(d.y, s.y), l = Math.max(d.y, s.y);
|
|
1374
|
+
return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
class Ce {
|
|
1378
|
+
constructor(e, o, r) {
|
|
1379
|
+
i(this, "attachedNodes", /* @__PURE__ */ new Set());
|
|
1380
|
+
i(this, "attachedEdges", /* @__PURE__ */ new Set());
|
|
1381
|
+
i(this, "renderingBox");
|
|
1382
|
+
i(this, "updateViewport", (e) => {
|
|
1383
|
+
this.renderingBox.setRenderingBox(e);
|
|
1384
|
+
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
1385
|
+
this.graphStore.getAllNodeIds().forEach((s) => {
|
|
1386
|
+
const h = this.renderingBox.hasNode(s), c = this.attachedNodes.has(s);
|
|
1387
|
+
h && !c ? o.add(s) : !h && c && r.add(s);
|
|
1388
|
+
}), this.graphStore.getAllEdgeIds().forEach((s) => {
|
|
1389
|
+
const h = this.renderingBox.hasEdge(s), c = this.attachedEdges.has(s), a = this.graphStore.getEdge(s), l = this.graphStore.getPortNodeId(a.from), g = this.graphStore.getPortNodeId(a.to);
|
|
1390
|
+
h && (this.renderingBox.hasNode(l) || (o.add(l), r.delete(l)), this.renderingBox.hasNode(g) || (o.add(g), r.delete(g))), h && !c ? n.add(s) : !h && c && d.add(s);
|
|
1391
|
+
}), d.forEach((s) => {
|
|
1392
|
+
this.handleDetachEdge(s);
|
|
1393
|
+
}), r.forEach((s) => {
|
|
1394
|
+
this.handleDetachNode(s);
|
|
1395
|
+
}), o.forEach((s) => {
|
|
1396
|
+
this.attachedNodes.has(s) || this.handleAttachNode(s);
|
|
1397
|
+
}), n.forEach((s) => {
|
|
1398
|
+
this.handleAttachEdge(s);
|
|
1490
1399
|
});
|
|
1491
1400
|
});
|
|
1492
|
-
|
|
1493
|
-
this.htmlView.detachEdge(e);
|
|
1494
|
-
});
|
|
1495
|
-
i(this, "onBeforeNodeRemoved", (e) => {
|
|
1496
|
-
this.htmlView.detachNode(e);
|
|
1497
|
-
});
|
|
1498
|
-
this.model = e.publicGraphStore, this.internalModel = e.graphStore, this.internalTransformation = e.viewportTransformer, this.transformation = e.publicViewportTransformer, this.htmlView = e.htmlView, this.graphStoreController = e.graphStoreController, this.graphStoreController.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStoreController.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStoreController.onAfterEdgeShapeUpdated.subscribe(
|
|
1499
|
-
this.onAfterEdgeShapeUpdated
|
|
1500
|
-
), this.graphStoreController.onAfterEdgePriorityUpdated.subscribe(
|
|
1501
|
-
this.onAfterEdgePriorityUpdated
|
|
1502
|
-
), this.graphStoreController.onAfterEdgeUpdated.subscribe(
|
|
1503
|
-
this.onAfterEdgeUpdated
|
|
1504
|
-
), this.graphStoreController.onAfterPortUpdated.subscribe(
|
|
1505
|
-
this.onAfterPortUpdated
|
|
1506
|
-
), this.graphStoreController.onAfterNodePriorityUpdated.subscribe(
|
|
1507
|
-
this.onAfterNodePriorityUpdated
|
|
1508
|
-
), this.graphStoreController.onAfterNodeUpdated.subscribe(
|
|
1509
|
-
this.onAfterNodeUpdated
|
|
1510
|
-
), this.graphStoreController.onBeforeEdgeRemoved.subscribe(
|
|
1511
|
-
this.onBeforeEdgeRemoved
|
|
1512
|
-
), this.graphStoreController.onBeforeNodeRemoved.subscribe(
|
|
1513
|
-
this.onBeforeNodeRemoved
|
|
1514
|
-
);
|
|
1401
|
+
this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new be(this.graphStore), this.trigger.subscribe(this.updateViewport);
|
|
1515
1402
|
}
|
|
1516
1403
|
attach(e) {
|
|
1517
|
-
|
|
1404
|
+
this.htmlView.attach(e);
|
|
1518
1405
|
}
|
|
1519
1406
|
detach() {
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
addNode(e) {
|
|
1523
|
-
return this.graphStoreController.addNode(e), this;
|
|
1524
|
-
}
|
|
1525
|
-
updateNode(e, r) {
|
|
1526
|
-
return this.graphStoreController.updateNode(e, r ?? {}), this;
|
|
1407
|
+
this.htmlView.detach();
|
|
1527
1408
|
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1409
|
+
attachNode(e) {
|
|
1410
|
+
this.renderingBox.hasNode(e) && this.handleAttachNode(e);
|
|
1530
1411
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1412
|
+
detachNode(e) {
|
|
1413
|
+
this.attachedNodes.has(e) && this.handleDetachNode(e);
|
|
1533
1414
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1415
|
+
attachEdge(e) {
|
|
1416
|
+
this.renderingBox.hasEdge(e) && this.attachEdgeEntities(e);
|
|
1536
1417
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1418
|
+
detachEdge(e) {
|
|
1419
|
+
this.attachedEdges.has(e) && this.handleDetachEdge(e);
|
|
1539
1420
|
}
|
|
1540
|
-
|
|
1541
|
-
|
|
1421
|
+
updateNodeCoordinates(e) {
|
|
1422
|
+
this.attachedNodes.has(e) ? this.htmlView.updateNodeCoordinates(e) : this.renderingBox.hasNode(e) && (this.handleAttachNode(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1423
|
+
this.attachEdgeEntities(o);
|
|
1424
|
+
}));
|
|
1542
1425
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1426
|
+
updateNodePriority(e) {
|
|
1427
|
+
this.attachedNodes.has(e) && this.htmlView.updateNodePriority(e);
|
|
1545
1428
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1429
|
+
updateEdgeShape(e) {
|
|
1430
|
+
this.attachedEdges.has(e) && this.htmlView.updateEdgeShape(e);
|
|
1548
1431
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1432
|
+
renderEdge(e) {
|
|
1433
|
+
this.attachedEdges.has(e) && this.htmlView.renderEdge(e);
|
|
1551
1434
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1435
|
+
updateEdgePriority(e) {
|
|
1436
|
+
this.attachedEdges.has(e) && this.htmlView.updateEdgePriority(e);
|
|
1554
1437
|
}
|
|
1555
1438
|
clear() {
|
|
1556
|
-
|
|
1439
|
+
this.htmlView.clear(), this.attachedNodes.clear(), this.attachedEdges.clear();
|
|
1557
1440
|
}
|
|
1558
1441
|
destroy() {
|
|
1559
|
-
this.
|
|
1560
|
-
this.onAfterNodeAdded
|
|
1561
|
-
), this.graphStoreController.onAfterEdgeAdded.unsubscribe(
|
|
1562
|
-
this.onAfterEdgeAdded
|
|
1563
|
-
), this.graphStoreController.onAfterEdgeShapeUpdated.unsubscribe(
|
|
1564
|
-
this.onAfterEdgeShapeUpdated
|
|
1565
|
-
), this.graphStoreController.onAfterEdgePriorityUpdated.unsubscribe(
|
|
1566
|
-
this.onAfterEdgePriorityUpdated
|
|
1567
|
-
), this.graphStoreController.onAfterEdgeUpdated.unsubscribe(
|
|
1568
|
-
this.onAfterEdgeUpdated
|
|
1569
|
-
), this.graphStoreController.onAfterPortUpdated.unsubscribe(
|
|
1570
|
-
this.onAfterPortUpdated
|
|
1571
|
-
), this.graphStoreController.onAfterNodePriorityUpdated.unsubscribe(
|
|
1572
|
-
this.onAfterNodePriorityUpdated
|
|
1573
|
-
), this.graphStoreController.onAfterNodeUpdated.unsubscribe(
|
|
1574
|
-
this.onAfterNodeUpdated
|
|
1575
|
-
), this.graphStoreController.onBeforeEdgeRemoved.unsubscribe(
|
|
1576
|
-
this.onBeforeEdgeRemoved
|
|
1577
|
-
), this.graphStoreController.onBeforeNodeRemoved.unsubscribe(
|
|
1578
|
-
this.onBeforeNodeRemoved
|
|
1579
|
-
);
|
|
1442
|
+
this.clear(), this.htmlView.destroy(), this.trigger.unsubscribe(this.updateViewport);
|
|
1580
1443
|
}
|
|
1581
|
-
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
return t;
|
|
1585
|
-
switch (t == null ? void 0 : t.type) {
|
|
1586
|
-
case "straight":
|
|
1587
|
-
return () => new te({
|
|
1588
|
-
color: t.color,
|
|
1589
|
-
width: t.width,
|
|
1590
|
-
arrowLength: t.arrowLength,
|
|
1591
|
-
arrowWidth: t.arrowWidth,
|
|
1592
|
-
arrowOffset: t.arrowOffset,
|
|
1593
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
1594
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
1595
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
1596
|
-
roundness: t.roundness,
|
|
1597
|
-
detourDistance: t.detourDistance,
|
|
1598
|
-
detourDirection: t.detourDirection
|
|
1599
|
-
});
|
|
1600
|
-
case "horizontal":
|
|
1601
|
-
return () => new ee({
|
|
1602
|
-
color: t.color,
|
|
1603
|
-
width: t.width,
|
|
1604
|
-
arrowLength: t.arrowLength,
|
|
1605
|
-
arrowWidth: t.arrowWidth,
|
|
1606
|
-
arrowOffset: t.arrowOffset,
|
|
1607
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
1608
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
1609
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
1610
|
-
roundness: t.roundness,
|
|
1611
|
-
detourDistance: t.detourDistance,
|
|
1612
|
-
detourDirection: t.detourDirection
|
|
1613
|
-
});
|
|
1614
|
-
case "vertical":
|
|
1615
|
-
return () => new re({
|
|
1616
|
-
color: t.color,
|
|
1617
|
-
width: t.width,
|
|
1618
|
-
arrowLength: t.arrowLength,
|
|
1619
|
-
arrowWidth: t.arrowWidth,
|
|
1620
|
-
arrowOffset: t.arrowOffset,
|
|
1621
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
1622
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
1623
|
-
cycleSquareSide: t.cycleSquareSide,
|
|
1624
|
-
roundness: t.roundness,
|
|
1625
|
-
detourDistance: t.detourDistance,
|
|
1626
|
-
detourDirection: t.detourDirection
|
|
1627
|
-
});
|
|
1628
|
-
default:
|
|
1629
|
-
return () => new O({
|
|
1630
|
-
color: t.color,
|
|
1631
|
-
width: t.width,
|
|
1632
|
-
arrowLength: t.arrowLength,
|
|
1633
|
-
arrowWidth: t.arrowWidth,
|
|
1634
|
-
hasSourceArrow: t.hasSourceArrow,
|
|
1635
|
-
hasTargetArrow: t.hasTargetArrow,
|
|
1636
|
-
cycleRadius: t.cycleRadius,
|
|
1637
|
-
smallCycleRadius: t.smallCycleRadius,
|
|
1638
|
-
curvature: t.curvature,
|
|
1639
|
-
detourDistance: t.detourDistance,
|
|
1640
|
-
detourDirection: t.detourDirection
|
|
1641
|
-
});
|
|
1444
|
+
attachEdgeEntities(e) {
|
|
1445
|
+
const o = this.graphStore.getEdge(e), r = this.graphStore.getPortNodeId(o.from), n = this.graphStore.getPortNodeId(o.to);
|
|
1446
|
+
this.attachedNodes.has(r) || this.handleAttachNode(r), this.attachedNodes.has(n) || this.handleAttachNode(n), this.handleAttachEdge(e);
|
|
1642
1447
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
(r = t == null ? void 0 : t.nodes) == null ? void 0 : r.priority,
|
|
1655
|
-
(o = t == null ? void 0 : t.edges) == null ? void 0 : o.priority
|
|
1656
|
-
);
|
|
1657
|
-
return {
|
|
1658
|
-
nodes: {
|
|
1659
|
-
centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? q,
|
|
1660
|
-
priorityFn: e.nodesPriorityFn
|
|
1661
|
-
},
|
|
1662
|
-
ports: {
|
|
1663
|
-
direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
|
|
1664
|
-
},
|
|
1665
|
-
edges: {
|
|
1666
|
-
shapeFactory: be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
|
|
1667
|
-
priorityFn: e.edgesPriorityFn
|
|
1668
|
-
}
|
|
1669
|
-
};
|
|
1670
|
-
};
|
|
1671
|
-
class Me {
|
|
1672
|
-
constructor(e, r) {
|
|
1673
|
-
i(this, "publicViewportTransformer");
|
|
1674
|
-
i(this, "publicGraphStore");
|
|
1675
|
-
i(this, "viewportTransformer");
|
|
1676
|
-
i(this, "graphStore");
|
|
1677
|
-
i(this, "htmlView");
|
|
1678
|
-
i(this, "graphStoreController");
|
|
1679
|
-
this.graphStore = new oe(), this.publicGraphStore = new he(this.graphStore), this.viewportTransformer = new ie(), this.publicViewportTransformer = new ne(
|
|
1680
|
-
this.viewportTransformer
|
|
1681
|
-
), this.htmlView = r(this.graphStore, this.viewportTransformer), this.graphStoreController = new se(
|
|
1682
|
-
this.graphStore,
|
|
1683
|
-
Pe(e)
|
|
1684
|
-
);
|
|
1448
|
+
handleAttachNode(e) {
|
|
1449
|
+
this.attachedNodes.add(e), this.htmlView.attachNode(e);
|
|
1450
|
+
}
|
|
1451
|
+
handleDetachNode(e) {
|
|
1452
|
+
this.htmlView.detachNode(e), this.attachedNodes.delete(e);
|
|
1453
|
+
}
|
|
1454
|
+
handleAttachEdge(e) {
|
|
1455
|
+
this.attachedEdges.add(e), this.htmlView.attachEdge(e);
|
|
1456
|
+
}
|
|
1457
|
+
handleDetachEdge(e) {
|
|
1458
|
+
this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
|
|
1685
1459
|
}
|
|
1686
1460
|
}
|
|
1687
|
-
const
|
|
1688
|
-
new
|
|
1461
|
+
const Le = (t, e) => new ee(t, e), De = (t) => (e, o) => new Ce(
|
|
1462
|
+
new ee(e, o),
|
|
1689
1463
|
e,
|
|
1690
1464
|
t
|
|
1691
|
-
),
|
|
1692
|
-
const { x:
|
|
1693
|
-
return e >=
|
|
1694
|
-
},
|
|
1465
|
+
), I = (t, e, o) => {
|
|
1466
|
+
const { x: r, y: n, width: d, height: s } = t.getBoundingClientRect();
|
|
1467
|
+
return e >= r && e <= r + d && o >= n && o <= n + s;
|
|
1468
|
+
}, W = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, R = (t, e) => {
|
|
1695
1469
|
e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
|
|
1696
|
-
},
|
|
1697
|
-
var g, f, x, y,
|
|
1470
|
+
}, $e = (t) => {
|
|
1471
|
+
var g, f, x, y, S, A;
|
|
1698
1472
|
const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
|
|
1699
|
-
}),
|
|
1700
|
-
}),
|
|
1473
|
+
}), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
|
|
1474
|
+
}), n = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, s = d !== void 0 ? d : "grab", h = (S = t == null ? void 0 : t.mouse) == null ? void 0 : S.mouseDownEventVerifier, c = h !== void 0 ? h : (N) => N.button === 0, a = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseUpEventVerifier;
|
|
1701
1475
|
return {
|
|
1702
|
-
freezePriority:
|
|
1703
|
-
dragCursor:
|
|
1476
|
+
freezePriority: n,
|
|
1477
|
+
dragCursor: s,
|
|
1704
1478
|
mouseDownEventVerifier: c,
|
|
1705
1479
|
mouseUpEventVerifier: a !== void 0 ? a : (N) => N.button === 0,
|
|
1706
1480
|
onNodeDrag: e,
|
|
1707
|
-
onBeforeNodeDrag:
|
|
1708
|
-
onNodeDragFinished:
|
|
1481
|
+
onBeforeNodeDrag: o,
|
|
1482
|
+
onNodeDragFinished: r
|
|
1709
1483
|
};
|
|
1710
1484
|
};
|
|
1711
|
-
class
|
|
1712
|
-
constructor(e,
|
|
1713
|
-
i(this, "
|
|
1714
|
-
i(this, "
|
|
1485
|
+
class Ie {
|
|
1486
|
+
constructor(e, o) {
|
|
1487
|
+
i(this, "graph");
|
|
1488
|
+
i(this, "viewport");
|
|
1715
1489
|
i(this, "maxNodePriority", 0);
|
|
1716
1490
|
i(this, "nodes", /* @__PURE__ */ new Map());
|
|
1717
1491
|
i(this, "grabbedNodeId", null);
|
|
@@ -1720,7 +1494,7 @@ class $e {
|
|
|
1720
1494
|
));
|
|
1721
1495
|
i(this, "element", null);
|
|
1722
1496
|
i(this, "onWindowMouseMove", (e) => {
|
|
1723
|
-
if (this.element !== null && (!
|
|
1497
|
+
if (this.element !== null && (!I(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY))) {
|
|
1724
1498
|
this.cancelMouseDrag();
|
|
1725
1499
|
return;
|
|
1726
1500
|
}
|
|
@@ -1732,14 +1506,14 @@ class $e {
|
|
|
1732
1506
|
i(this, "onWindowTouchMove", (e) => {
|
|
1733
1507
|
if (e.touches.length !== 1)
|
|
1734
1508
|
return;
|
|
1735
|
-
const
|
|
1736
|
-
if (this.element !== null && (!
|
|
1509
|
+
const o = e.touches[0];
|
|
1510
|
+
if (this.element !== null && (!I(this.element, o.clientX, o.clientY) || !W(this.window, o.clientX, o.clientY))) {
|
|
1737
1511
|
this.cancelTouchDrag();
|
|
1738
1512
|
return;
|
|
1739
1513
|
}
|
|
1740
1514
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1741
|
-
const
|
|
1742
|
-
this.dragNode(this.grabbedNodeId,
|
|
1515
|
+
const r = o.clientX - this.previousTouchCoords.x, n = o.clientY - this.previousTouchCoords.y;
|
|
1516
|
+
this.dragNode(this.grabbedNodeId, r, n), this.previousTouchCoords = {
|
|
1743
1517
|
x: e.touches[0].clientX,
|
|
1744
1518
|
y: e.touches[0].clientY
|
|
1745
1519
|
};
|
|
@@ -1751,7 +1525,7 @@ class $e {
|
|
|
1751
1525
|
i(this, "previousTouchCoords", null);
|
|
1752
1526
|
i(this, "window", window);
|
|
1753
1527
|
i(this, "options");
|
|
1754
|
-
this.canvas = e, this.
|
|
1528
|
+
this.canvas = e, this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.options = $e(o ?? {});
|
|
1755
1529
|
}
|
|
1756
1530
|
attach(e) {
|
|
1757
1531
|
return this.detach(), this.element = e, this.canvas.attach(this.element), this;
|
|
@@ -1760,51 +1534,51 @@ class $e {
|
|
|
1760
1534
|
return this.canvas.detach(), this.element !== null && (this.element = null), this;
|
|
1761
1535
|
}
|
|
1762
1536
|
addNode(e) {
|
|
1763
|
-
const
|
|
1764
|
-
this.canvas.addNode({ ...e, id:
|
|
1765
|
-
const
|
|
1537
|
+
const o = this.nodeIdGenerator.create(e.id);
|
|
1538
|
+
this.canvas.addNode({ ...e, id: o }), this.updateMaxNodePriority(o);
|
|
1539
|
+
const r = (d) => {
|
|
1766
1540
|
if (this.element === null || !this.options.mouseDownEventVerifier(d))
|
|
1767
1541
|
return;
|
|
1768
|
-
const
|
|
1542
|
+
const s = this.graph.getNode(o);
|
|
1769
1543
|
this.options.onBeforeNodeDrag({
|
|
1770
|
-
nodeId:
|
|
1544
|
+
nodeId: o,
|
|
1771
1545
|
element: e.element,
|
|
1772
|
-
x:
|
|
1773
|
-
y:
|
|
1774
|
-
}) && (d.stopImmediatePropagation(), this.grabbedNodeId =
|
|
1775
|
-
},
|
|
1546
|
+
x: s.x,
|
|
1547
|
+
y: s.y
|
|
1548
|
+
}) && (d.stopImmediatePropagation(), this.grabbedNodeId = o, R(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
|
|
1549
|
+
}, n = (d) => {
|
|
1776
1550
|
if (d.touches.length !== 1)
|
|
1777
1551
|
return;
|
|
1778
1552
|
d.stopImmediatePropagation(), this.previousTouchCoords = {
|
|
1779
1553
|
x: d.touches[0].clientX,
|
|
1780
1554
|
y: d.touches[0].clientY
|
|
1781
1555
|
};
|
|
1782
|
-
const
|
|
1556
|
+
const s = this.graph.getNode(o);
|
|
1783
1557
|
this.options.onBeforeNodeDrag({
|
|
1784
|
-
nodeId:
|
|
1558
|
+
nodeId: o,
|
|
1785
1559
|
element: e.element,
|
|
1786
|
-
x:
|
|
1787
|
-
y:
|
|
1788
|
-
}) && (this.grabbedNodeId =
|
|
1560
|
+
x: s.x,
|
|
1561
|
+
y: s.y
|
|
1562
|
+
}) && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
|
|
1789
1563
|
};
|
|
1790
|
-
return this.nodes.set(
|
|
1564
|
+
return this.nodes.set(o, {
|
|
1791
1565
|
element: e.element,
|
|
1792
|
-
onMouseDown:
|
|
1793
|
-
onTouchStart:
|
|
1794
|
-
}), e.element.addEventListener("mousedown",
|
|
1566
|
+
onMouseDown: r,
|
|
1567
|
+
onTouchStart: n
|
|
1568
|
+
}), e.element.addEventListener("mousedown", r), e.element.addEventListener("touchstart", n), this;
|
|
1795
1569
|
}
|
|
1796
|
-
updateNode(e,
|
|
1797
|
-
return this.canvas.updateNode(e,
|
|
1570
|
+
updateNode(e, o) {
|
|
1571
|
+
return this.canvas.updateNode(e, o), this.updateMaxNodePriority(e), this;
|
|
1798
1572
|
}
|
|
1799
1573
|
removeNode(e) {
|
|
1800
|
-
const
|
|
1801
|
-
return
|
|
1574
|
+
const o = this.nodes.get(e);
|
|
1575
|
+
return o !== void 0 && (o.element.removeEventListener("mousedown", o.onMouseDown), o.element.removeEventListener("touchstart", o.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e), this;
|
|
1802
1576
|
}
|
|
1803
1577
|
markPort(e) {
|
|
1804
1578
|
return this.canvas.markPort(e), this;
|
|
1805
1579
|
}
|
|
1806
|
-
updatePort(e,
|
|
1807
|
-
return this.canvas.updatePort(e,
|
|
1580
|
+
updatePort(e, o) {
|
|
1581
|
+
return this.canvas.updatePort(e, o), this;
|
|
1808
1582
|
}
|
|
1809
1583
|
unmarkPort(e) {
|
|
1810
1584
|
return this.canvas.unmarkPort(e), this;
|
|
@@ -1812,8 +1586,8 @@ class $e {
|
|
|
1812
1586
|
addEdge(e) {
|
|
1813
1587
|
return this.canvas.addEdge(e), this;
|
|
1814
1588
|
}
|
|
1815
|
-
updateEdge(e,
|
|
1816
|
-
return this.canvas.updateEdge(e,
|
|
1589
|
+
updateEdge(e, o) {
|
|
1590
|
+
return this.canvas.updateEdge(e, o), this;
|
|
1817
1591
|
}
|
|
1818
1592
|
removeEdge(e) {
|
|
1819
1593
|
return this.canvas.removeEdge(e), this;
|
|
@@ -1832,46 +1606,46 @@ class $e {
|
|
|
1832
1606
|
destroy() {
|
|
1833
1607
|
this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1834
1608
|
}
|
|
1835
|
-
dragNode(e,
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1609
|
+
dragNode(e, o, r) {
|
|
1610
|
+
const n = this.graph.getNode(e);
|
|
1611
|
+
if (n === null)
|
|
1838
1612
|
return;
|
|
1839
|
-
const d = this.canvas.
|
|
1613
|
+
const d = this.canvas.viewport.getContentMatrix(), s = d.scale * n.x + d.x, h = d.scale * n.y + d.y, c = s + o, a = h + r, l = this.canvas.viewport.getViewportMatrix(), g = l.scale * c + l.x, f = l.scale * a + l.y;
|
|
1840
1614
|
this.canvas.updateNode(e, { x: g, y: f }), this.options.onNodeDrag({
|
|
1841
1615
|
nodeId: e,
|
|
1842
|
-
element:
|
|
1616
|
+
element: n.element,
|
|
1843
1617
|
x: g,
|
|
1844
1618
|
y: f
|
|
1845
1619
|
});
|
|
1846
1620
|
}
|
|
1847
1621
|
updateMaxNodePriority(e) {
|
|
1848
|
-
const
|
|
1849
|
-
this.maxNodePriority = Math.max(this.maxNodePriority,
|
|
1622
|
+
const o = this.graph.getNode(e).priority;
|
|
1623
|
+
this.maxNodePriority = Math.max(this.maxNodePriority, o);
|
|
1850
1624
|
}
|
|
1851
1625
|
moveNodeOnTop(e) {
|
|
1852
1626
|
if (this.options.freezePriority)
|
|
1853
1627
|
return;
|
|
1854
1628
|
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
1855
|
-
const
|
|
1856
|
-
this.
|
|
1857
|
-
this.updateEdge(
|
|
1629
|
+
const o = this.maxNodePriority - 1;
|
|
1630
|
+
this.graph.getNodeAdjacentEdgeIds(e).forEach((n) => {
|
|
1631
|
+
this.updateEdge(n, { priority: o });
|
|
1858
1632
|
});
|
|
1859
1633
|
}
|
|
1860
1634
|
cancelMouseDrag() {
|
|
1861
|
-
const e = this.
|
|
1635
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1862
1636
|
e !== null && this.options.onNodeDragFinished({
|
|
1863
1637
|
nodeId: this.grabbedNodeId,
|
|
1864
1638
|
element: e.element,
|
|
1865
1639
|
x: e.x,
|
|
1866
1640
|
y: e.y
|
|
1867
|
-
}), this.grabbedNodeId = null, this.element !== null &&
|
|
1641
|
+
}), this.grabbedNodeId = null, this.element !== null && R(this.element, null), this.removeMouseDragListeners();
|
|
1868
1642
|
}
|
|
1869
1643
|
removeMouseDragListeners() {
|
|
1870
1644
|
this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
|
|
1871
1645
|
}
|
|
1872
1646
|
cancelTouchDrag() {
|
|
1873
1647
|
this.previousTouchCoords = null;
|
|
1874
|
-
const e = this.
|
|
1648
|
+
const e = this.graph.getNode(this.grabbedNodeId);
|
|
1875
1649
|
e !== null && this.options.onNodeDragFinished({
|
|
1876
1650
|
nodeId: this.grabbedNodeId,
|
|
1877
1651
|
element: e.element,
|
|
@@ -1883,30 +1657,30 @@ class $e {
|
|
|
1883
1657
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
1884
1658
|
}
|
|
1885
1659
|
}
|
|
1886
|
-
const
|
|
1887
|
-
const e = t.minX !== null ? t.minX : -1 / 0,
|
|
1660
|
+
const We = (t) => {
|
|
1661
|
+
const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, n = t.maxY !== null ? t.maxY : 1 / 0;
|
|
1888
1662
|
return (d) => {
|
|
1889
|
-
let
|
|
1890
|
-
|
|
1891
|
-
const c = d.canvasWidth * d.prevTransform.scale, a =
|
|
1892
|
-
|
|
1893
|
-
const l = d.canvasHeight * d.prevTransform.scale, g =
|
|
1894
|
-
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x:
|
|
1663
|
+
let s = d.nextTransform.x, h = d.nextTransform.y;
|
|
1664
|
+
s < e && s < d.prevTransform.x && (s = Math.min(d.prevTransform.x, e));
|
|
1665
|
+
const c = d.canvasWidth * d.prevTransform.scale, a = o - c;
|
|
1666
|
+
s > a && s > d.prevTransform.x && (s = Math.max(d.prevTransform.x, a)), h < r && h < d.prevTransform.y && (h = Math.min(d.prevTransform.y, r));
|
|
1667
|
+
const l = d.canvasHeight * d.prevTransform.scale, g = n - l;
|
|
1668
|
+
return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: s, y: h };
|
|
1895
1669
|
};
|
|
1896
|
-
},
|
|
1897
|
-
const e = t.maxContentScale,
|
|
1670
|
+
}, Re = (t) => {
|
|
1671
|
+
const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, n = o !== null ? 1 / o : 1 / 0;
|
|
1898
1672
|
return (d) => {
|
|
1899
|
-
const
|
|
1673
|
+
const s = d.prevTransform, h = d.nextTransform;
|
|
1900
1674
|
let c = h.scale, a = h.x, l = h.y;
|
|
1901
|
-
if (h.scale >
|
|
1902
|
-
c = Math.max(
|
|
1903
|
-
const g = (c -
|
|
1904
|
-
a =
|
|
1675
|
+
if (h.scale > n && h.scale > s.scale) {
|
|
1676
|
+
c = Math.max(s.scale, n), a = s.x, l = s.y;
|
|
1677
|
+
const g = (c - s.scale) / (h.scale - s.scale);
|
|
1678
|
+
a = s.x + (h.x - s.x) * g, l = s.y + (h.y - s.y) * g;
|
|
1905
1679
|
}
|
|
1906
|
-
if (h.scale <
|
|
1907
|
-
c = Math.min(
|
|
1908
|
-
const g = (c -
|
|
1909
|
-
a =
|
|
1680
|
+
if (h.scale < r && h.scale < s.scale) {
|
|
1681
|
+
c = Math.min(s.scale, r), a = s.x, l = s.y;
|
|
1682
|
+
const g = (c - s.scale) / (h.scale - s.scale);
|
|
1683
|
+
a = s.x + (h.x - s.x) * g, l = s.y + (h.y - s.y) * g;
|
|
1910
1684
|
}
|
|
1911
1685
|
return {
|
|
1912
1686
|
scale: c,
|
|
@@ -1914,101 +1688,107 @@ const Ue = (t) => {
|
|
|
1914
1688
|
y: l
|
|
1915
1689
|
};
|
|
1916
1690
|
};
|
|
1917
|
-
},
|
|
1918
|
-
(
|
|
1691
|
+
}, Fe = (t) => (e) => t.reduce(
|
|
1692
|
+
(o, r) => r({
|
|
1919
1693
|
prevTransform: e.prevTransform,
|
|
1920
|
-
nextTransform:
|
|
1694
|
+
nextTransform: o,
|
|
1921
1695
|
canvasWidth: e.canvasWidth,
|
|
1922
1696
|
canvasHeight: e.canvasHeight
|
|
1923
1697
|
}),
|
|
1924
1698
|
e.nextTransform
|
|
1925
|
-
),
|
|
1699
|
+
), O = (t) => {
|
|
1926
1700
|
if (typeof t == "function")
|
|
1927
1701
|
return t;
|
|
1928
1702
|
switch (t.type) {
|
|
1929
1703
|
case "scale-limit":
|
|
1930
|
-
return
|
|
1704
|
+
return Re({
|
|
1931
1705
|
minContentScale: t.minContentScale ?? 0,
|
|
1932
1706
|
maxContentScale: t.maxContentScale ?? 1 / 0
|
|
1933
1707
|
});
|
|
1934
1708
|
case "shift-limit":
|
|
1935
|
-
return
|
|
1709
|
+
return We({
|
|
1936
1710
|
minX: t.minX ?? -1 / 0,
|
|
1937
1711
|
maxX: t.maxX ?? 1 / 0,
|
|
1938
1712
|
minY: t.minY ?? -1 / 0,
|
|
1939
1713
|
maxY: t.maxY ?? 1 / 0
|
|
1940
1714
|
});
|
|
1941
1715
|
}
|
|
1942
|
-
},
|
|
1943
|
-
var y,
|
|
1944
|
-
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity,
|
|
1945
|
-
let
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
(
|
|
1716
|
+
}, Ue = (t) => {
|
|
1717
|
+
var y, S, A, N, z, V, b, C, j, G, K, _;
|
|
1718
|
+
const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
|
|
1719
|
+
let n;
|
|
1720
|
+
r !== void 0 ? Array.isArray(r) ? n = Fe(
|
|
1721
|
+
r.map(
|
|
1722
|
+
(P) => O(P)
|
|
1949
1723
|
)
|
|
1950
|
-
) :
|
|
1951
|
-
const d = ((
|
|
1724
|
+
) : n = O(r) : n = (P) => P.nextTransform;
|
|
1725
|
+
const d = ((S = t == null ? void 0 : t.shift) == null ? void 0 : S.cursor) !== void 0 ? t.shift.cursor : "grab", s = ((A = t == null ? void 0 : t.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
|
|
1952
1726
|
}), h = ((N = t == null ? void 0 : t.events) == null ? void 0 : N.onTransformChange) ?? (() => {
|
|
1953
|
-
}), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (
|
|
1727
|
+
}), c = (z = t == null ? void 0 : t.shift) == null ? void 0 : z.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (V = t == null ? void 0 : t.shift) == null ? void 0 : V.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (b = t == null ? void 0 : t.scale) == null ? void 0 : b.mouseWheelEventVerifier, x = f !== void 0 ? f : () => !0;
|
|
1954
1728
|
return {
|
|
1955
|
-
wheelSensitivity:
|
|
1956
|
-
onTransformStarted: ((
|
|
1729
|
+
wheelSensitivity: o,
|
|
1730
|
+
onTransformStarted: ((C = t == null ? void 0 : t.events) == null ? void 0 : C.onTransformStarted) ?? (() => {
|
|
1957
1731
|
}),
|
|
1958
|
-
onTransformFinished: ((
|
|
1732
|
+
onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
|
|
1959
1733
|
}),
|
|
1960
|
-
onBeforeTransformChange:
|
|
1734
|
+
onBeforeTransformChange: s,
|
|
1961
1735
|
onTransformChange: h,
|
|
1962
|
-
transformPreprocessor:
|
|
1736
|
+
transformPreprocessor: n,
|
|
1963
1737
|
shiftCursor: d,
|
|
1964
1738
|
mouseDownEventVerifier: a,
|
|
1965
1739
|
mouseUpEventVerifier: g,
|
|
1966
|
-
mouseWheelEventVerifier: x
|
|
1740
|
+
mouseWheelEventVerifier: x,
|
|
1741
|
+
scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
|
|
1742
|
+
onResizeTransformStarted: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformStarted) ?? (() => {
|
|
1743
|
+
}),
|
|
1744
|
+
onResizeTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformFinished) ?? (() => {
|
|
1745
|
+
})
|
|
1967
1746
|
};
|
|
1968
|
-
},
|
|
1969
|
-
const e = [],
|
|
1970
|
-
for (let h = 0; h <
|
|
1747
|
+
}, $ = (t) => {
|
|
1748
|
+
const e = [], o = t.touches.length;
|
|
1749
|
+
for (let h = 0; h < o; h++)
|
|
1971
1750
|
e.push([t.touches[h].clientX, t.touches[h].clientY]);
|
|
1972
|
-
const
|
|
1751
|
+
const r = e.reduce(
|
|
1973
1752
|
(h, c) => [h[0] + c[0], h[1] + c[1]],
|
|
1974
1753
|
[0, 0]
|
|
1975
|
-
),
|
|
1754
|
+
), n = [r[0] / o, r[1] / o], s = e.map((h) => [h[0] - n[0], h[1] - n[1]]).reduce(
|
|
1976
1755
|
(h, c) => h + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
|
|
1977
1756
|
0
|
|
1978
1757
|
);
|
|
1979
1758
|
return {
|
|
1980
|
-
x:
|
|
1981
|
-
y:
|
|
1982
|
-
scale:
|
|
1983
|
-
touchesCnt:
|
|
1759
|
+
x: n[0],
|
|
1760
|
+
y: n[1],
|
|
1761
|
+
scale: s / o,
|
|
1762
|
+
touchesCnt: o,
|
|
1984
1763
|
touches: e
|
|
1985
1764
|
};
|
|
1986
|
-
},
|
|
1765
|
+
}, Be = (t, e, o) => ({
|
|
1987
1766
|
scale: t.scale,
|
|
1988
1767
|
x: t.x + t.scale * e,
|
|
1989
|
-
y: t.y + t.scale *
|
|
1990
|
-
}),
|
|
1768
|
+
y: t.y + t.scale * o
|
|
1769
|
+
}), ke = (t, e, o, r) => ({
|
|
1991
1770
|
scale: t.scale * e,
|
|
1992
|
-
x: t.scale * (1 - e) *
|
|
1993
|
-
y: t.scale * (1 - e) *
|
|
1771
|
+
x: t.scale * (1 - e) * o + t.x,
|
|
1772
|
+
y: t.scale * (1 - e) * r + t.y
|
|
1994
1773
|
});
|
|
1995
|
-
class
|
|
1996
|
-
constructor(e,
|
|
1997
|
-
i(this, "
|
|
1998
|
-
i(this, "
|
|
1774
|
+
class te {
|
|
1775
|
+
constructor(e, o) {
|
|
1776
|
+
i(this, "graph");
|
|
1777
|
+
i(this, "viewport");
|
|
1999
1778
|
i(this, "element", null);
|
|
2000
1779
|
i(this, "prevTouches", null);
|
|
2001
1780
|
i(this, "window", window);
|
|
1781
|
+
i(this, "wheelFinishTimer", null);
|
|
2002
1782
|
i(this, "onMouseDown", (e) => {
|
|
2003
|
-
this.element === null || !this.options.mouseDownEventVerifier(e) || (
|
|
1783
|
+
this.element === null || !this.options.mouseDownEventVerifier(e) || (R(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
|
|
2004
1784
|
});
|
|
2005
1785
|
i(this, "onWindowMouseMove", (e) => {
|
|
2006
|
-
if (this.element === null || !
|
|
1786
|
+
if (this.element === null || !I(this.element, e.clientX, e.clientY) || !W(this.window, e.clientX, e.clientY)) {
|
|
2007
1787
|
this.stopMouseDrag();
|
|
2008
1788
|
return;
|
|
2009
1789
|
}
|
|
2010
|
-
const
|
|
2011
|
-
this.moveViewport(this.element,
|
|
1790
|
+
const o = -e.movementX, r = -e.movementY;
|
|
1791
|
+
this.moveViewport(this.element, o, r);
|
|
2012
1792
|
});
|
|
2013
1793
|
i(this, "onWindowMouseUp", (e) => {
|
|
2014
1794
|
this.element === null || !this.options.mouseUpEventVerifier(e) || this.stopMouseDrag();
|
|
@@ -2016,48 +1796,54 @@ class ke {
|
|
|
2016
1796
|
i(this, "onWheelScroll", (e) => {
|
|
2017
1797
|
if (!this.options.mouseWheelEventVerifier(e))
|
|
2018
1798
|
return;
|
|
2019
|
-
e.preventDefault()
|
|
2020
|
-
const { left:
|
|
2021
|
-
this.scaleViewport(this.element, h,
|
|
1799
|
+
e.preventDefault();
|
|
1800
|
+
const { left: o, top: r } = this.element.getBoundingClientRect(), n = e.clientX - o, d = e.clientY - r, h = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
|
|
1801
|
+
this.wheelFinishTimer === null && this.options.onTransformStarted(), this.scaleViewport(this.element, h, n, d), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
|
|
1802
|
+
this.options.onTransformFinished(), this.wheelFinishTimer = null;
|
|
1803
|
+
}, this.options.scaleWheelFinishTimeout);
|
|
2022
1804
|
});
|
|
2023
1805
|
i(this, "onTouchStart", (e) => {
|
|
2024
|
-
|
|
1806
|
+
if (this.prevTouches !== null) {
|
|
1807
|
+
this.prevTouches = $(e);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
this.prevTouches = $(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
|
|
2025
1811
|
});
|
|
2026
1812
|
i(this, "onWindowTouchMove", (e) => {
|
|
2027
|
-
const
|
|
2028
|
-
if (
|
|
1813
|
+
const o = this.element;
|
|
1814
|
+
if (o === null)
|
|
2029
1815
|
return;
|
|
2030
|
-
const
|
|
2031
|
-
if (!
|
|
2032
|
-
(d) =>
|
|
1816
|
+
const r = $(e);
|
|
1817
|
+
if (!r.touches.every(
|
|
1818
|
+
(d) => I(o, d[0], d[1]) && W(this.window, d[0], d[1])
|
|
2033
1819
|
)) {
|
|
2034
1820
|
this.stopTouchDrag();
|
|
2035
1821
|
return;
|
|
2036
1822
|
}
|
|
2037
|
-
if ((
|
|
2038
|
-
|
|
2039
|
-
-(
|
|
2040
|
-
-(
|
|
2041
|
-
),
|
|
2042
|
-
const { left: d, top:
|
|
2043
|
-
this.scaleViewport(
|
|
1823
|
+
if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
|
|
1824
|
+
o,
|
|
1825
|
+
-(r.x - this.prevTouches.x),
|
|
1826
|
+
-(r.y - this.prevTouches.y)
|
|
1827
|
+
), r.touchesCnt === 2) {
|
|
1828
|
+
const { left: d, top: s } = o.getBoundingClientRect(), h = this.prevTouches.x - d, c = this.prevTouches.y - s, l = 1 / (r.scale / this.prevTouches.scale);
|
|
1829
|
+
this.scaleViewport(o, l, h, c);
|
|
2044
1830
|
}
|
|
2045
|
-
this.prevTouches =
|
|
1831
|
+
this.prevTouches = r;
|
|
2046
1832
|
});
|
|
2047
1833
|
i(this, "onWindowTouchFinish", (e) => {
|
|
2048
|
-
e.touches.length > 0 ? this.prevTouches =
|
|
1834
|
+
e.touches.length > 0 ? this.prevTouches = $(e) : this.stopTouchDrag();
|
|
2049
1835
|
});
|
|
2050
1836
|
i(this, "observer", new ResizeObserver(() => {
|
|
2051
|
-
const e = this.canvas.
|
|
1837
|
+
const e = this.canvas.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
|
|
2052
1838
|
prevTransform: e,
|
|
2053
1839
|
nextTransform: e,
|
|
2054
|
-
canvasWidth:
|
|
2055
|
-
canvasHeight:
|
|
1840
|
+
canvasWidth: o,
|
|
1841
|
+
canvasHeight: r
|
|
2056
1842
|
});
|
|
2057
|
-
this.canvas.patchViewportMatrix(
|
|
1843
|
+
this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(n), this.options.onResizeTransformFinished();
|
|
2058
1844
|
}));
|
|
2059
1845
|
i(this, "options");
|
|
2060
|
-
this.canvas = e, this.options =
|
|
1846
|
+
this.canvas = e, this.options = Ue(o), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
|
|
2061
1847
|
}
|
|
2062
1848
|
attach(e) {
|
|
2063
1849
|
return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
@@ -2068,8 +1854,8 @@ class ke {
|
|
|
2068
1854
|
addNode(e) {
|
|
2069
1855
|
return this.canvas.addNode(e), this;
|
|
2070
1856
|
}
|
|
2071
|
-
updateNode(e,
|
|
2072
|
-
return this.canvas.updateNode(e,
|
|
1857
|
+
updateNode(e, o) {
|
|
1858
|
+
return this.canvas.updateNode(e, o), this;
|
|
2073
1859
|
}
|
|
2074
1860
|
removeNode(e) {
|
|
2075
1861
|
return this.canvas.removeNode(e), this;
|
|
@@ -2077,8 +1863,8 @@ class ke {
|
|
|
2077
1863
|
markPort(e) {
|
|
2078
1864
|
return this.canvas.markPort(e), this;
|
|
2079
1865
|
}
|
|
2080
|
-
updatePort(e,
|
|
2081
|
-
return this.canvas.updatePort(e,
|
|
1866
|
+
updatePort(e, o) {
|
|
1867
|
+
return this.canvas.updatePort(e, o), this;
|
|
2082
1868
|
}
|
|
2083
1869
|
unmarkPort(e) {
|
|
2084
1870
|
return this.canvas.unmarkPort(e), this;
|
|
@@ -2086,8 +1872,8 @@ class ke {
|
|
|
2086
1872
|
addEdge(e) {
|
|
2087
1873
|
return this.canvas.addEdge(e), this;
|
|
2088
1874
|
}
|
|
2089
|
-
updateEdge(e,
|
|
2090
|
-
return this.canvas.updateEdge(e,
|
|
1875
|
+
updateEdge(e, o) {
|
|
1876
|
+
return this.canvas.updateEdge(e, o), this;
|
|
2091
1877
|
}
|
|
2092
1878
|
removeEdge(e) {
|
|
2093
1879
|
return this.canvas.removeEdge(e), this;
|
|
@@ -2104,28 +1890,26 @@ class ke {
|
|
|
2104
1890
|
destroy() {
|
|
2105
1891
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
2106
1892
|
}
|
|
2107
|
-
moveViewport(e,
|
|
2108
|
-
this.options.
|
|
2109
|
-
|
|
2110
|
-
prevTransform: s,
|
|
1893
|
+
moveViewport(e, o, r) {
|
|
1894
|
+
const n = this.viewport.getViewportMatrix(), d = Be(n, o, r), { width: s, height: h } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
|
|
1895
|
+
prevTransform: n,
|
|
2111
1896
|
nextTransform: d,
|
|
2112
|
-
canvasWidth:
|
|
1897
|
+
canvasWidth: s,
|
|
2113
1898
|
canvasHeight: h
|
|
2114
1899
|
});
|
|
2115
|
-
this.
|
|
1900
|
+
this.performTransform(c);
|
|
2116
1901
|
}
|
|
2117
|
-
scaleViewport(e,
|
|
2118
|
-
this.options.
|
|
2119
|
-
const d = this.canvas.transformation.getViewportMatrix(), n = Be(d, r, o, s), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
1902
|
+
scaleViewport(e, o, r, n) {
|
|
1903
|
+
const d = this.canvas.viewport.getViewportMatrix(), s = ke(d, o, r, n), { width: h, height: c } = e.getBoundingClientRect(), a = this.options.transformPreprocessor({
|
|
2120
1904
|
prevTransform: d,
|
|
2121
|
-
nextTransform:
|
|
1905
|
+
nextTransform: s,
|
|
2122
1906
|
canvasWidth: h,
|
|
2123
1907
|
canvasHeight: c
|
|
2124
1908
|
});
|
|
2125
|
-
this.
|
|
1909
|
+
this.performTransform(a);
|
|
2126
1910
|
}
|
|
2127
1911
|
stopMouseDrag() {
|
|
2128
|
-
this.element !== null &&
|
|
1912
|
+
this.element !== null && R(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
|
|
2129
1913
|
}
|
|
2130
1914
|
removeMouseDragListeners() {
|
|
2131
1915
|
this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
|
|
@@ -2136,14 +1920,17 @@ class ke {
|
|
|
2136
1920
|
removeTouchDragListeners() {
|
|
2137
1921
|
this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
|
|
2138
1922
|
}
|
|
1923
|
+
performTransform(e) {
|
|
1924
|
+
this.options.onBeforeTransformChange(), this.canvas.patchViewportMatrix(e), this.options.onTransformChange();
|
|
1925
|
+
}
|
|
2139
1926
|
}
|
|
2140
|
-
class
|
|
1927
|
+
class ze {
|
|
2141
1928
|
constructor() {
|
|
2142
1929
|
i(this, "keyMap", /* @__PURE__ */ new Map());
|
|
2143
1930
|
i(this, "valueMap", /* @__PURE__ */ new Map());
|
|
2144
1931
|
}
|
|
2145
|
-
set(e,
|
|
2146
|
-
this.keyMap.set(e,
|
|
1932
|
+
set(e, o) {
|
|
1933
|
+
this.keyMap.set(e, o), this.valueMap.set(o, e);
|
|
2147
1934
|
}
|
|
2148
1935
|
hasKey(e) {
|
|
2149
1936
|
return this.keyMap.has(e);
|
|
@@ -2158,37 +1945,38 @@ class Ye {
|
|
|
2158
1945
|
return this.valueMap.get(e);
|
|
2159
1946
|
}
|
|
2160
1947
|
deleteByKey(e) {
|
|
2161
|
-
const
|
|
2162
|
-
|
|
1948
|
+
const o = this.keyMap.get(e);
|
|
1949
|
+
o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(e);
|
|
2163
1950
|
}
|
|
2164
1951
|
deleteByValue(e) {
|
|
2165
|
-
const
|
|
2166
|
-
|
|
1952
|
+
const o = this.valueMap.get(e);
|
|
1953
|
+
o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(e);
|
|
2167
1954
|
}
|
|
2168
1955
|
forEach(e) {
|
|
2169
|
-
this.keyMap.forEach((
|
|
2170
|
-
e(
|
|
1956
|
+
this.keyMap.forEach((o, r) => {
|
|
1957
|
+
e(o, r);
|
|
2171
1958
|
});
|
|
2172
1959
|
}
|
|
2173
1960
|
clear() {
|
|
2174
1961
|
this.keyMap.clear(), this.valueMap.clear();
|
|
2175
1962
|
}
|
|
2176
1963
|
}
|
|
2177
|
-
class
|
|
1964
|
+
class Ye {
|
|
2178
1965
|
constructor(e) {
|
|
2179
|
-
i(this, "
|
|
2180
|
-
i(this, "
|
|
2181
|
-
i(this, "nodes", new
|
|
1966
|
+
i(this, "viewport");
|
|
1967
|
+
i(this, "graph");
|
|
1968
|
+
i(this, "nodes", new ze());
|
|
2182
1969
|
i(this, "nodeIdGenerator", new L(
|
|
2183
1970
|
(e) => this.nodes.hasKey(e)
|
|
2184
1971
|
));
|
|
2185
1972
|
i(this, "nodesResizeObserver");
|
|
2186
|
-
this
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
1973
|
+
i(this, "window", window);
|
|
1974
|
+
this.canvas = e, this.nodesResizeObserver = new this.window.ResizeObserver((o) => {
|
|
1975
|
+
o.forEach((r) => {
|
|
1976
|
+
const n = r.target;
|
|
1977
|
+
this.handleNodeResize(n);
|
|
2190
1978
|
});
|
|
2191
|
-
}), this.
|
|
1979
|
+
}), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph;
|
|
2192
1980
|
}
|
|
2193
1981
|
attach(e) {
|
|
2194
1982
|
return this.canvas.attach(e), this;
|
|
@@ -2197,25 +1985,25 @@ class Xe {
|
|
|
2197
1985
|
return this.canvas.detach(), this;
|
|
2198
1986
|
}
|
|
2199
1987
|
addNode(e) {
|
|
2200
|
-
const
|
|
1988
|
+
const o = this.nodeIdGenerator.create(e.id);
|
|
2201
1989
|
return this.canvas.addNode({
|
|
2202
1990
|
...e,
|
|
2203
|
-
id:
|
|
2204
|
-
}), this.nodes.set(
|
|
1991
|
+
id: o
|
|
1992
|
+
}), this.nodes.set(o, e.element), this.nodesResizeObserver.observe(e.element), this;
|
|
2205
1993
|
}
|
|
2206
|
-
updateNode(e,
|
|
2207
|
-
return this.canvas.updateNode(e,
|
|
1994
|
+
updateNode(e, o) {
|
|
1995
|
+
return this.canvas.updateNode(e, o), this;
|
|
2208
1996
|
}
|
|
2209
1997
|
removeNode(e) {
|
|
2210
1998
|
this.canvas.removeNode(e);
|
|
2211
|
-
const
|
|
2212
|
-
return this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(
|
|
1999
|
+
const o = this.nodes.getByKey(e);
|
|
2000
|
+
return this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(o), this;
|
|
2213
2001
|
}
|
|
2214
2002
|
markPort(e) {
|
|
2215
2003
|
return this.canvas.markPort(e), this;
|
|
2216
2004
|
}
|
|
2217
|
-
updatePort(e,
|
|
2218
|
-
return this.canvas.updatePort(e,
|
|
2005
|
+
updatePort(e, o) {
|
|
2006
|
+
return this.canvas.updatePort(e, o), this;
|
|
2219
2007
|
}
|
|
2220
2008
|
unmarkPort(e) {
|
|
2221
2009
|
return this.canvas.unmarkPort(e), this;
|
|
@@ -2223,8 +2011,8 @@ class Xe {
|
|
|
2223
2011
|
addEdge(e) {
|
|
2224
2012
|
return this.canvas.addEdge(e), this;
|
|
2225
2013
|
}
|
|
2226
|
-
updateEdge(e,
|
|
2227
|
-
return this.canvas.updateEdge(e,
|
|
2014
|
+
updateEdge(e, o) {
|
|
2015
|
+
return this.canvas.updateEdge(e, o), this;
|
|
2228
2016
|
}
|
|
2229
2017
|
removeEdge(e) {
|
|
2230
2018
|
return this.canvas.removeEdge(e), this;
|
|
@@ -2242,21 +2030,133 @@ class Xe {
|
|
|
2242
2030
|
this.clear(), this.canvas.destroy();
|
|
2243
2031
|
}
|
|
2244
2032
|
handleNodeResize(e) {
|
|
2245
|
-
const
|
|
2246
|
-
this.canvas.updateNode(
|
|
2247
|
-
this.canvas.updateEdge(
|
|
2033
|
+
const o = this.nodes.getByValue(e);
|
|
2034
|
+
this.canvas.updateNode(o), this.graph.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
2035
|
+
this.canvas.updateEdge(n);
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
class Xe {
|
|
2040
|
+
constructor(e, o, r, n) {
|
|
2041
|
+
i(this, "graph");
|
|
2042
|
+
i(this, "viewport");
|
|
2043
|
+
i(this, "canvas");
|
|
2044
|
+
i(this, "element", null);
|
|
2045
|
+
i(this, "canvasResizeObserver");
|
|
2046
|
+
i(this, "window", window);
|
|
2047
|
+
i(this, "nodeHorizontal");
|
|
2048
|
+
i(this, "nodeVertical");
|
|
2049
|
+
i(this, "viewportWidth", 0);
|
|
2050
|
+
i(this, "viewportHeight", 0);
|
|
2051
|
+
i(this, "viewportMatrix");
|
|
2052
|
+
i(this, "loadedArea", {
|
|
2053
|
+
xFrom: 1 / 0,
|
|
2054
|
+
xTo: 1 / 0,
|
|
2055
|
+
yFrom: 1 / 0,
|
|
2056
|
+
yTo: 1 / 0
|
|
2057
|
+
});
|
|
2058
|
+
i(this, "updateLoadedArea", (e) => {
|
|
2059
|
+
this.loadedArea = {
|
|
2060
|
+
xFrom: e.x,
|
|
2061
|
+
xTo: e.x + e.width,
|
|
2062
|
+
yFrom: e.y,
|
|
2063
|
+
yTo: e.y + e.height
|
|
2064
|
+
};
|
|
2065
|
+
});
|
|
2066
|
+
var c, a;
|
|
2067
|
+
this.trigger = o, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((l) => {
|
|
2068
|
+
const g = l[0];
|
|
2069
|
+
this.viewportWidth = g.contentRect.width, this.viewportHeight = g.contentRect.height, this.scheduleLoadAreaAroundViewport();
|
|
2070
|
+
});
|
|
2071
|
+
const d = ((c = r == null ? void 0 : r.events) == null ? void 0 : c.onTransformFinished) ?? (() => {
|
|
2072
|
+
}), s = ((a = r == null ? void 0 : r.events) == null ? void 0 : a.onTransformChange) ?? (() => {
|
|
2073
|
+
}), h = {
|
|
2074
|
+
...r,
|
|
2075
|
+
events: {
|
|
2076
|
+
...r == null ? void 0 : r.events,
|
|
2077
|
+
onTransformChange: () => {
|
|
2078
|
+
const l = this.viewportMatrix;
|
|
2079
|
+
this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), l.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), s();
|
|
2080
|
+
},
|
|
2081
|
+
onTransformFinished: () => {
|
|
2082
|
+
this.scheduleLoadAreaAroundViewport(), d();
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
this.canvas = new te(
|
|
2087
|
+
e,
|
|
2088
|
+
h
|
|
2089
|
+
), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.viewport = this.canvas.viewport, this.graph = this.canvas.graph, this.trigger.subscribe(this.updateLoadedArea);
|
|
2090
|
+
}
|
|
2091
|
+
attach(e) {
|
|
2092
|
+
return this.detach(), this.element = e, this.canvasResizeObserver.observe(this.element), this.canvas.attach(e), this;
|
|
2093
|
+
}
|
|
2094
|
+
detach() {
|
|
2095
|
+
return this.element !== null && (this.canvasResizeObserver.unobserve(this.element), this.element = null, this.viewportWidth = 0, this.viewportHeight = 0), this.canvas.detach(), this;
|
|
2096
|
+
}
|
|
2097
|
+
addNode(e) {
|
|
2098
|
+
return this.canvas.addNode(e), this;
|
|
2099
|
+
}
|
|
2100
|
+
updateNode(e, o) {
|
|
2101
|
+
return this.canvas.updateNode(e, o), this;
|
|
2102
|
+
}
|
|
2103
|
+
removeNode(e) {
|
|
2104
|
+
return this.canvas.removeNode(e), this;
|
|
2105
|
+
}
|
|
2106
|
+
markPort(e) {
|
|
2107
|
+
return this.canvas.markPort(e), this;
|
|
2108
|
+
}
|
|
2109
|
+
updatePort(e, o) {
|
|
2110
|
+
return this.canvas.updatePort(e, o), this;
|
|
2111
|
+
}
|
|
2112
|
+
unmarkPort(e) {
|
|
2113
|
+
return this.canvas.unmarkPort(e), this;
|
|
2114
|
+
}
|
|
2115
|
+
addEdge(e) {
|
|
2116
|
+
return this.canvas.addEdge(e), this;
|
|
2117
|
+
}
|
|
2118
|
+
updateEdge(e, o) {
|
|
2119
|
+
return this.canvas.updateEdge(e, o), this;
|
|
2120
|
+
}
|
|
2121
|
+
removeEdge(e) {
|
|
2122
|
+
return this.canvas.removeEdge(e), this;
|
|
2123
|
+
}
|
|
2124
|
+
patchViewportMatrix(e) {
|
|
2125
|
+
return this.canvas.patchViewportMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport(), this;
|
|
2126
|
+
}
|
|
2127
|
+
patchContentMatrix(e) {
|
|
2128
|
+
return this.canvas.patchContentMatrix(e), this.viewportMatrix = this.canvas.viewport.getViewportMatrix(), this.loadAreaAroundViewport(), this;
|
|
2129
|
+
}
|
|
2130
|
+
clear() {
|
|
2131
|
+
return this.canvas.clear(), this;
|
|
2132
|
+
}
|
|
2133
|
+
destroy() {
|
|
2134
|
+
this.trigger.unsubscribe(this.updateLoadedArea), this.canvas.destroy();
|
|
2135
|
+
}
|
|
2136
|
+
scheduleLoadAreaAroundViewport() {
|
|
2137
|
+
setTimeout(() => {
|
|
2138
|
+
this.loadAreaAroundViewport();
|
|
2248
2139
|
});
|
|
2249
2140
|
}
|
|
2141
|
+
scheduleEnsureViewportAreaLoaded() {
|
|
2142
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - this.nodeHorizontal, n = this.viewportMatrix.y - this.nodeVertical, d = this.viewportMatrix.x + e + this.nodeHorizontal, s = this.viewportMatrix.y + o + this.nodeVertical;
|
|
2143
|
+
this.loadedArea.xFrom < r && this.loadedArea.xTo > d && this.loadedArea.yFrom < n && this.loadedArea.yTo > s || this.scheduleLoadAreaAroundViewport();
|
|
2144
|
+
}
|
|
2145
|
+
loadAreaAroundViewport() {
|
|
2146
|
+
const e = this.viewportWidth * this.viewportMatrix.scale, o = this.viewportHeight * this.viewportMatrix.scale, r = this.viewportMatrix.x - e - this.nodeHorizontal, n = this.viewportMatrix.y - o - this.nodeVertical, d = 3 * e + 2 * this.nodeHorizontal, s = 3 * o + 2 * this.nodeVertical;
|
|
2147
|
+
this.trigger.emit({ x: r, y: n, width: d, height: s });
|
|
2148
|
+
}
|
|
2250
2149
|
}
|
|
2251
2150
|
class je {
|
|
2252
2151
|
constructor() {
|
|
2253
2152
|
i(this, "coreOptions", {});
|
|
2254
2153
|
i(this, "dragOptions");
|
|
2255
2154
|
i(this, "transformOptions");
|
|
2155
|
+
i(this, "virtualScrollOptions");
|
|
2256
2156
|
i(this, "hasDraggableNode", !1);
|
|
2257
2157
|
i(this, "hasTransformableViewport", !1);
|
|
2258
2158
|
i(this, "hasResizeReactiveNodes", !1);
|
|
2259
|
-
i(this, "boxRenderingTrigger"
|
|
2159
|
+
i(this, "boxRenderingTrigger");
|
|
2260
2160
|
}
|
|
2261
2161
|
/**
|
|
2262
2162
|
* specifies options for fundamental aspects of visualization
|
|
@@ -2267,58 +2167,58 @@ class je {
|
|
|
2267
2167
|
/**
|
|
2268
2168
|
* enables nodes draggable bu user
|
|
2269
2169
|
*/
|
|
2270
|
-
|
|
2170
|
+
enableUserDraggableNodes(e) {
|
|
2271
2171
|
return this.hasDraggableNode = !0, this.dragOptions = e, this;
|
|
2272
2172
|
}
|
|
2273
|
-
/**
|
|
2274
|
-
* @deprecated
|
|
2275
|
-
* use setUserTransformableViewport instead
|
|
2276
|
-
*/
|
|
2277
|
-
setUserTransformableCanvas(e) {
|
|
2278
|
-
return this.setUserTransformableViewport(e);
|
|
2279
|
-
}
|
|
2280
2173
|
/**
|
|
2281
2174
|
* enables viewport transformable by user
|
|
2282
2175
|
*/
|
|
2283
|
-
|
|
2176
|
+
enableUserTransformableViewport(e) {
|
|
2284
2177
|
return this.hasTransformableViewport = !0, this.transformOptions = e, this;
|
|
2285
2178
|
}
|
|
2286
2179
|
/**
|
|
2287
2180
|
* enables automatic edges update on node resize
|
|
2288
2181
|
*/
|
|
2289
|
-
|
|
2182
|
+
enableResizeReactiveNodes() {
|
|
2290
2183
|
return this.hasResizeReactiveNodes = !0, this;
|
|
2291
2184
|
}
|
|
2292
2185
|
/**
|
|
2293
2186
|
* sets emitter for rendering graph inside bounded area
|
|
2294
2187
|
*/
|
|
2295
|
-
|
|
2188
|
+
enableBoxAreaRendering(e) {
|
|
2296
2189
|
return this.boxRenderingTrigger = e, this;
|
|
2297
2190
|
}
|
|
2191
|
+
enableVirtualScroll(e) {
|
|
2192
|
+
return this.virtualScrollOptions = e, this;
|
|
2193
|
+
}
|
|
2298
2194
|
/**
|
|
2299
2195
|
* builds final canvas
|
|
2300
2196
|
*/
|
|
2301
2197
|
build() {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2198
|
+
let e = this.boxRenderingTrigger;
|
|
2199
|
+
this.virtualScrollOptions !== void 0 && e === void 0 && (e = new q());
|
|
2200
|
+
const o = e !== void 0 ? De(e) : Le, r = new me(this.coreOptions, o);
|
|
2201
|
+
let n = new ie(r);
|
|
2202
|
+
return this.hasResizeReactiveNodes && (n = new Ye(n)), this.hasDraggableNode && (n = new Ie(n, this.dragOptions)), this.virtualScrollOptions !== void 0 ? n = new Xe(
|
|
2203
|
+
n,
|
|
2204
|
+
e,
|
|
2205
|
+
this.transformOptions,
|
|
2206
|
+
this.virtualScrollOptions
|
|
2207
|
+
) : this.hasTransformableViewport && (n = new te(
|
|
2208
|
+
n,
|
|
2306
2209
|
this.transformOptions
|
|
2307
|
-
)),
|
|
2210
|
+
)), this.reset(), n;
|
|
2211
|
+
}
|
|
2212
|
+
reset() {
|
|
2213
|
+
this.coreOptions = {}, this.dragOptions = void 0, this.transformOptions = void 0, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
|
|
2308
2214
|
}
|
|
2309
2215
|
}
|
|
2310
2216
|
export {
|
|
2311
|
-
|
|
2217
|
+
ue as BezierEdgeShape,
|
|
2312
2218
|
je as CanvasBuilder,
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
Xe as ResizeReactiveNodesCanvas,
|
|
2319
|
-
te as StraightEdgeShape,
|
|
2320
|
-
$e as UserDraggableNodesCanvas,
|
|
2321
|
-
ke as UserTransformableCanvas,
|
|
2322
|
-
ke as UserTransformableViewportCanvas,
|
|
2323
|
-
re as VerticalEdgeShape
|
|
2219
|
+
q as EventSubject,
|
|
2220
|
+
we as HorizontalEdgeShape,
|
|
2221
|
+
E as HtmlGraphError,
|
|
2222
|
+
fe as StraightEdgeShape,
|
|
2223
|
+
ye as VerticalEdgeShape
|
|
2324
2224
|
};
|