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