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