@html-graph/html-graph 0.0.57 → 0.0.58
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 +2 -2
- package/dist/main.d.ts +16 -9
- package/dist/main.js +1213 -1224
- package/dist/main.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
5
|
-
scale: 1 /
|
|
6
|
-
dx: -
|
|
7
|
-
dy: -
|
|
8
|
-
}),
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var J = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var a = (r, e, t) => J(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const Y = (r) => ({
|
|
5
|
+
scale: 1 / r.scale,
|
|
6
|
+
dx: -r.dx / r.scale,
|
|
7
|
+
dy: -r.dy / r.scale
|
|
8
|
+
}), X = {
|
|
9
9
|
scale: 1,
|
|
10
10
|
dx: 0,
|
|
11
11
|
dy: 0
|
|
12
12
|
};
|
|
13
|
-
class
|
|
13
|
+
class Q {
|
|
14
14
|
constructor() {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
a(this, "viewportMatrix", X);
|
|
16
|
+
a(this, "contentMatrix", X);
|
|
17
17
|
}
|
|
18
18
|
getViewportMatrix() {
|
|
19
19
|
return this.viewportMatrix;
|
|
@@ -21,24 +21,24 @@ class rt {
|
|
|
21
21
|
getContentMatrix() {
|
|
22
22
|
return this.contentMatrix;
|
|
23
23
|
}
|
|
24
|
-
patchViewportMatrix(
|
|
24
|
+
patchViewportMatrix(e, t, s) {
|
|
25
25
|
this.viewportMatrix = {
|
|
26
|
-
scale:
|
|
27
|
-
dx:
|
|
26
|
+
scale: e ?? this.viewportMatrix.scale,
|
|
27
|
+
dx: t ?? this.viewportMatrix.dx,
|
|
28
28
|
dy: s ?? this.viewportMatrix.dy
|
|
29
|
-
}, this.contentMatrix =
|
|
29
|
+
}, this.contentMatrix = Y(this.viewportMatrix);
|
|
30
30
|
}
|
|
31
|
-
patchContentMatrix(
|
|
31
|
+
patchContentMatrix(e, t, s) {
|
|
32
32
|
this.contentMatrix = {
|
|
33
|
-
scale:
|
|
34
|
-
dx:
|
|
33
|
+
scale: e ?? this.contentMatrix.scale,
|
|
34
|
+
dx: t ?? this.contentMatrix.dx,
|
|
35
35
|
dy: s ?? this.contentMatrix.dy
|
|
36
|
-
}, this.viewportMatrix =
|
|
36
|
+
}, this.viewportMatrix = Y(this.contentMatrix);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
class
|
|
40
|
-
constructor(
|
|
41
|
-
this.transformer =
|
|
39
|
+
class Z {
|
|
40
|
+
constructor(e) {
|
|
41
|
+
this.transformer = e;
|
|
42
42
|
}
|
|
43
43
|
getViewportMatrix() {
|
|
44
44
|
return { ...this.transformer.getViewportMatrix() };
|
|
@@ -47,119 +47,119 @@ class st {
|
|
|
47
47
|
return { ...this.transformer.getContentMatrix() };
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
class
|
|
50
|
+
class q {
|
|
51
51
|
constructor() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
addNode(
|
|
62
|
-
this.nodes.set(
|
|
52
|
+
a(this, "nodes", /* @__PURE__ */ new Map());
|
|
53
|
+
a(this, "ports", /* @__PURE__ */ new Map());
|
|
54
|
+
a(this, "nodePorts", /* @__PURE__ */ new Map());
|
|
55
|
+
a(this, "portNodeId", /* @__PURE__ */ new Map());
|
|
56
|
+
a(this, "edges", /* @__PURE__ */ new Map());
|
|
57
|
+
a(this, "incommingEdges", /* @__PURE__ */ new Map());
|
|
58
|
+
a(this, "outcommingEdges", /* @__PURE__ */ new Map());
|
|
59
|
+
a(this, "cycleEdges", /* @__PURE__ */ new Map());
|
|
60
|
+
}
|
|
61
|
+
addNode(e, t, s, o, i, n) {
|
|
62
|
+
this.nodes.set(e, { element: t, x: s, y: o, centerFn: i, priority: n }), this.nodePorts.set(e, /* @__PURE__ */ new Map());
|
|
63
63
|
}
|
|
64
64
|
getAllNodeIds() {
|
|
65
65
|
return Array.from(this.nodes.keys());
|
|
66
66
|
}
|
|
67
|
-
getNode(
|
|
68
|
-
return this.nodes.get(
|
|
67
|
+
getNode(e) {
|
|
68
|
+
return this.nodes.get(e);
|
|
69
69
|
}
|
|
70
|
-
removeNode(
|
|
71
|
-
this.nodes.delete(
|
|
70
|
+
removeNode(e) {
|
|
71
|
+
this.nodes.delete(e), this.nodePorts.delete(e);
|
|
72
72
|
}
|
|
73
|
-
addPort(
|
|
74
|
-
this.ports.set(
|
|
73
|
+
addPort(e, t, s, o, i) {
|
|
74
|
+
this.ports.set(e, { element: t, centerFn: o, direction: i }), this.cycleEdges.set(e, /* @__PURE__ */ new Set()), this.incommingEdges.set(e, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e, /* @__PURE__ */ new Set()), this.portNodeId.set(e, s), this.nodePorts.get(s).set(e, t);
|
|
75
75
|
}
|
|
76
|
-
getPort(
|
|
77
|
-
return this.ports.get(
|
|
76
|
+
getPort(e) {
|
|
77
|
+
return this.ports.get(e);
|
|
78
78
|
}
|
|
79
79
|
getAllPortIds() {
|
|
80
80
|
return Array.from(this.ports.keys());
|
|
81
81
|
}
|
|
82
|
-
getNodePortIds(
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
return Array.from(
|
|
82
|
+
getNodePortIds(e) {
|
|
83
|
+
const t = this.nodePorts.get(e);
|
|
84
|
+
if (t !== void 0)
|
|
85
|
+
return Array.from(t.keys());
|
|
86
86
|
}
|
|
87
|
-
getPortNodeId(
|
|
88
|
-
return this.portNodeId.get(
|
|
87
|
+
getPortNodeId(e) {
|
|
88
|
+
return this.portNodeId.get(e);
|
|
89
89
|
}
|
|
90
|
-
removePort(
|
|
91
|
-
const
|
|
92
|
-
this.portNodeId.delete(
|
|
90
|
+
removePort(e) {
|
|
91
|
+
const t = this.portNodeId.get(e);
|
|
92
|
+
this.portNodeId.delete(e), this.nodePorts.get(t).delete(e), this.ports.delete(e);
|
|
93
93
|
}
|
|
94
|
-
addEdge(
|
|
95
|
-
this.edges.set(
|
|
96
|
-
from:
|
|
94
|
+
addEdge(e, t, s, o, i) {
|
|
95
|
+
this.edges.set(e, {
|
|
96
|
+
from: t,
|
|
97
97
|
to: s,
|
|
98
98
|
shape: o,
|
|
99
99
|
priority: i
|
|
100
|
-
}),
|
|
100
|
+
}), t !== s ? (this.outcommingEdges.get(t).add(e), this.incommingEdges.get(s).add(e)) : this.cycleEdges.get(t).add(e);
|
|
101
101
|
}
|
|
102
102
|
getAllEdgeIds() {
|
|
103
103
|
return Array.from(this.edges.keys());
|
|
104
104
|
}
|
|
105
|
-
getEdge(
|
|
106
|
-
return this.edges.get(
|
|
105
|
+
getEdge(e) {
|
|
106
|
+
return this.edges.get(e);
|
|
107
107
|
}
|
|
108
|
-
removeEdge(
|
|
109
|
-
const
|
|
110
|
-
this.cycleEdges.get(s).delete(
|
|
108
|
+
removeEdge(e) {
|
|
109
|
+
const t = this.edges.get(e), s = t.from, o = t.to;
|
|
110
|
+
this.cycleEdges.get(s).delete(e), this.cycleEdges.get(o).delete(e), this.incommingEdges.get(s).delete(e), this.incommingEdges.get(o).delete(e), this.outcommingEdges.get(s).delete(e), this.outcommingEdges.get(o).delete(e), this.edges.delete(e);
|
|
111
111
|
}
|
|
112
112
|
clear() {
|
|
113
113
|
this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
|
|
114
114
|
}
|
|
115
|
-
getPortIncomingEdgeIds(
|
|
116
|
-
return Array.from(this.incommingEdges.get(
|
|
115
|
+
getPortIncomingEdgeIds(e) {
|
|
116
|
+
return Array.from(this.incommingEdges.get(e));
|
|
117
117
|
}
|
|
118
|
-
getPortOutcomingEdgeIds(
|
|
119
|
-
return Array.from(this.outcommingEdges.get(
|
|
118
|
+
getPortOutcomingEdgeIds(e) {
|
|
119
|
+
return Array.from(this.outcommingEdges.get(e));
|
|
120
120
|
}
|
|
121
|
-
getPortCycleEdgeIds(
|
|
122
|
-
return Array.from(this.cycleEdges.get(
|
|
121
|
+
getPortCycleEdgeIds(e) {
|
|
122
|
+
return Array.from(this.cycleEdges.get(e));
|
|
123
123
|
}
|
|
124
|
-
getPortAdjacentEdgeIds(
|
|
124
|
+
getPortAdjacentEdgeIds(e) {
|
|
125
125
|
return [
|
|
126
|
-
...this.getPortIncomingEdgeIds(
|
|
127
|
-
...this.getPortOutcomingEdgeIds(
|
|
128
|
-
...this.getPortCycleEdgeIds(
|
|
126
|
+
...this.getPortIncomingEdgeIds(e),
|
|
127
|
+
...this.getPortOutcomingEdgeIds(e),
|
|
128
|
+
...this.getPortCycleEdgeIds(e)
|
|
129
129
|
];
|
|
130
130
|
}
|
|
131
|
-
getNodeIncomingEdgeIds(
|
|
132
|
-
const
|
|
131
|
+
getNodeIncomingEdgeIds(e) {
|
|
132
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
133
133
|
let s = [];
|
|
134
|
-
return
|
|
134
|
+
return t.forEach((o) => {
|
|
135
135
|
s = [...s, ...this.getPortIncomingEdgeIds(o)];
|
|
136
136
|
}), s;
|
|
137
137
|
}
|
|
138
|
-
getNodeOutcomingEdgeIds(
|
|
139
|
-
const
|
|
138
|
+
getNodeOutcomingEdgeIds(e) {
|
|
139
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
140
140
|
let s = [];
|
|
141
|
-
return
|
|
141
|
+
return t.forEach((o) => {
|
|
142
142
|
s = [...s, ...this.getPortOutcomingEdgeIds(o)];
|
|
143
143
|
}), s;
|
|
144
144
|
}
|
|
145
|
-
getNodeCycleEdgeIds(
|
|
146
|
-
const
|
|
145
|
+
getNodeCycleEdgeIds(e) {
|
|
146
|
+
const t = Array.from(this.nodePorts.get(e).keys());
|
|
147
147
|
let s = [];
|
|
148
|
-
return
|
|
148
|
+
return t.forEach((o) => {
|
|
149
149
|
s = [...s, ...this.getPortCycleEdgeIds(o)];
|
|
150
150
|
}), s;
|
|
151
151
|
}
|
|
152
|
-
getNodeAdjacentEdgeIds(
|
|
152
|
+
getNodeAdjacentEdgeIds(e) {
|
|
153
153
|
return [
|
|
154
|
-
...this.getNodeIncomingEdgeIds(
|
|
155
|
-
...this.getNodeOutcomingEdgeIds(
|
|
156
|
-
...this.getNodeCycleEdgeIds(
|
|
154
|
+
...this.getNodeIncomingEdgeIds(e),
|
|
155
|
+
...this.getNodeOutcomingEdgeIds(e),
|
|
156
|
+
...this.getNodeCycleEdgeIds(e)
|
|
157
157
|
];
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
class
|
|
161
|
-
constructor(
|
|
162
|
-
this.graphStore =
|
|
160
|
+
class ee {
|
|
161
|
+
constructor(e) {
|
|
162
|
+
this.graphStore = e;
|
|
163
163
|
}
|
|
164
164
|
getAllNodeIds() {
|
|
165
165
|
return this.graphStore.getAllNodeIds();
|
|
@@ -167,621 +167,590 @@ class it {
|
|
|
167
167
|
getAllPortIds() {
|
|
168
168
|
return this.graphStore.getAllPortIds();
|
|
169
169
|
}
|
|
170
|
-
getNode(
|
|
171
|
-
const
|
|
172
|
-
return
|
|
173
|
-
element:
|
|
174
|
-
x:
|
|
175
|
-
y:
|
|
176
|
-
centerFn:
|
|
177
|
-
priority:
|
|
170
|
+
getNode(e) {
|
|
171
|
+
const t = this.graphStore.getNode(e);
|
|
172
|
+
return t === void 0 ? null : {
|
|
173
|
+
element: t.element,
|
|
174
|
+
x: t.x,
|
|
175
|
+
y: t.y,
|
|
176
|
+
centerFn: t.centerFn,
|
|
177
|
+
priority: t.priority
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
getNodePortIds(
|
|
181
|
-
return this.graphStore.getNodePortIds(
|
|
180
|
+
getNodePortIds(e) {
|
|
181
|
+
return this.graphStore.getNodePortIds(e);
|
|
182
182
|
}
|
|
183
|
-
getPort(
|
|
184
|
-
const
|
|
185
|
-
return
|
|
186
|
-
element:
|
|
187
|
-
centerFn:
|
|
188
|
-
direction:
|
|
183
|
+
getPort(e) {
|
|
184
|
+
const t = this.graphStore.getPort(e);
|
|
185
|
+
return t === void 0 ? null : {
|
|
186
|
+
element: t.element,
|
|
187
|
+
centerFn: t.centerFn,
|
|
188
|
+
direction: t.direction
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
getPortNodeId(
|
|
192
|
-
return this.graphStore.getPortNodeId(
|
|
191
|
+
getPortNodeId(e) {
|
|
192
|
+
return this.graphStore.getPortNodeId(e) ?? null;
|
|
193
193
|
}
|
|
194
194
|
getAllEdgeIds() {
|
|
195
195
|
return this.graphStore.getAllEdgeIds();
|
|
196
196
|
}
|
|
197
|
-
getEdge(
|
|
198
|
-
const
|
|
199
|
-
return
|
|
197
|
+
getEdge(e) {
|
|
198
|
+
const t = this.graphStore.getEdge(e);
|
|
199
|
+
return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
|
|
200
200
|
}
|
|
201
|
-
getPortAdjacentEdgeIds(
|
|
202
|
-
return this.graphStore.getPortAdjacentEdgeIds(
|
|
201
|
+
getPortAdjacentEdgeIds(e) {
|
|
202
|
+
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
203
203
|
}
|
|
204
|
-
getNodeAdjacentEdgeIds(
|
|
205
|
-
return this.graphStore.getNodeAdjacentEdgeIds(
|
|
204
|
+
getNodeAdjacentEdgeIds(e) {
|
|
205
|
+
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
206
206
|
}
|
|
207
|
-
getPortIncomingEdgeIds(
|
|
208
|
-
return this.graphStore.getPortIncomingEdgeIds(
|
|
207
|
+
getPortIncomingEdgeIds(e) {
|
|
208
|
+
return this.graphStore.getPortIncomingEdgeIds(e);
|
|
209
209
|
}
|
|
210
|
-
getPortOutcomingEdgeIds(
|
|
211
|
-
return this.graphStore.getPortOutcomingEdgeIds(
|
|
210
|
+
getPortOutcomingEdgeIds(e) {
|
|
211
|
+
return this.graphStore.getPortOutcomingEdgeIds(e);
|
|
212
212
|
}
|
|
213
|
-
getPortCycleEdgeIds(
|
|
214
|
-
return this.graphStore.getPortCycleEdgeIds(
|
|
213
|
+
getPortCycleEdgeIds(e) {
|
|
214
|
+
return this.graphStore.getPortCycleEdgeIds(e);
|
|
215
215
|
}
|
|
216
|
-
getNodeIncomingEdgeIds(
|
|
217
|
-
return this.graphStore.getNodeIncomingEdgeIds(
|
|
216
|
+
getNodeIncomingEdgeIds(e) {
|
|
217
|
+
return this.graphStore.getNodeIncomingEdgeIds(e);
|
|
218
218
|
}
|
|
219
|
-
getNodeOutcomingEdgeIds(
|
|
220
|
-
return this.graphStore.getNodeOutcomingEdgeIds(
|
|
219
|
+
getNodeOutcomingEdgeIds(e) {
|
|
220
|
+
return this.graphStore.getNodeOutcomingEdgeIds(e);
|
|
221
221
|
}
|
|
222
|
-
getNodeCycleEdgeIds(
|
|
223
|
-
return this.graphStore.getNodeCycleEdgeIds(
|
|
222
|
+
getNodeCycleEdgeIds(e) {
|
|
223
|
+
return this.graphStore.getNodeCycleEdgeIds(e);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
x:
|
|
231
|
-
y:
|
|
232
|
-
}),
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
{ x:
|
|
236
|
-
{ x:
|
|
237
|
-
].map((
|
|
238
|
-
return `${
|
|
239
|
-
},
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const s =
|
|
243
|
-
let o = 0, i = 0,
|
|
244
|
-
|
|
245
|
-
let d = 0,
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
o =
|
|
226
|
+
const l = {
|
|
227
|
+
x: 0,
|
|
228
|
+
y: 0
|
|
229
|
+
}, p = (r, e, t) => ({
|
|
230
|
+
x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
|
|
231
|
+
y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
|
|
232
|
+
}), x = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), E = (r, e, t, s) => {
|
|
233
|
+
const i = [
|
|
234
|
+
l,
|
|
235
|
+
{ x: t, y: s },
|
|
236
|
+
{ x: t, y: -s }
|
|
237
|
+
].map((d) => p(d, r, l)).map((d) => ({ x: d.x + e.x, y: d.y + e.y })), n = `M ${i[0].x} ${i[0].y}`, h = `L ${i[1].x} ${i[1].y}`, c = `L ${i[2].x} ${i[2].y}`;
|
|
238
|
+
return `${n} ${h} ${c}`;
|
|
239
|
+
}, F = (r, e) => {
|
|
240
|
+
const t = [];
|
|
241
|
+
if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
|
|
242
|
+
const s = r.length - 1;
|
|
243
|
+
let o = 0, i = 0, n = 0;
|
|
244
|
+
r.forEach((h, c) => {
|
|
245
|
+
let d = 0, u = 0, w = 0;
|
|
246
|
+
const m = c > 0, y = c < s, v = m && y;
|
|
247
|
+
if (m && (d = -o, u = -i, w = n), y) {
|
|
248
|
+
const j = r[c + 1];
|
|
249
|
+
o = j.x - h.x, i = j.y - h.y, n = Math.sqrt(o * o + i * i);
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
`C ${
|
|
251
|
+
const S = Math.min((v ? e : 0) / n, c < s - 1 ? 0.5 : 1), N = v ? { x: h.x + o * S, y: h.y + i * S } : h, M = Math.min((v ? e : 0) / w, c > 1 ? 0.5 : 1), b = v ? { x: h.x + d * M, y: h.y + u * M } : h;
|
|
252
|
+
c > 0 && t.push(`L ${b.x} ${b.y}`), v && t.push(
|
|
253
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
|
|
254
254
|
);
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
-
return
|
|
258
|
-
},
|
|
259
|
-
const
|
|
260
|
-
return
|
|
261
|
-
},
|
|
262
|
-
const
|
|
263
|
-
return
|
|
264
|
-
},
|
|
265
|
-
const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
266
|
-
return r.setAttribute("stroke", e), r.setAttribute("stroke-width", `${t}`), r.setAttribute("fill", "none"), r;
|
|
267
|
-
}, b = (e) => {
|
|
257
|
+
return t.join(" ");
|
|
258
|
+
}, T = () => {
|
|
259
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
260
|
+
return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
|
|
261
|
+
}, $ = () => {
|
|
262
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
263
|
+
return r.style.transformOrigin = "50% 50%", r;
|
|
264
|
+
}, D = (r, e) => {
|
|
268
265
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
269
|
-
return t.setAttribute("
|
|
266
|
+
return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
|
|
267
|
+
}, C = (r) => {
|
|
268
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
269
|
+
return e.setAttribute("fill", r), e;
|
|
270
270
|
};
|
|
271
|
-
class
|
|
272
|
-
constructor(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line =
|
|
279
|
-
}
|
|
280
|
-
update(
|
|
281
|
-
this.
|
|
282
|
-
const
|
|
283
|
-
this.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}), p = E(
|
|
288
|
-
{ x: s - this.arrowLength, y: o },
|
|
289
|
-
w,
|
|
290
|
-
{
|
|
291
|
-
x: s,
|
|
292
|
-
y: o
|
|
293
|
-
}
|
|
294
|
-
), f = {
|
|
295
|
-
x: v.x + u.x * this.curvature,
|
|
296
|
-
y: v.y + u.y * this.curvature
|
|
297
|
-
}, m = {
|
|
298
|
-
x: p.x - w.x * this.curvature,
|
|
299
|
-
y: p.y - w.y * this.curvature
|
|
300
|
-
}, x = `M ${v.x} ${v.y} C ${f.x} ${f.y}, ${m.x} ${m.y}, ${p.x} ${p.y}`, y = this.sourceArrow ? "" : `M 0 0 L ${v.x} ${v.y} `, C = this.targetArrow ? "" : ` M ${p.x} ${p.y} L ${s} ${o}`, A = `${y}${x}${C}`;
|
|
301
|
-
if (this.line.setAttribute("d", A), this.sourceArrow) {
|
|
302
|
-
const M = N(
|
|
303
|
-
u,
|
|
304
|
-
0,
|
|
305
|
-
0,
|
|
271
|
+
class te {
|
|
272
|
+
constructor(e, t, s, o, i, n, h) {
|
|
273
|
+
a(this, "svg", T());
|
|
274
|
+
a(this, "group", $());
|
|
275
|
+
a(this, "line");
|
|
276
|
+
a(this, "sourceArrow", null);
|
|
277
|
+
a(this, "targetArrow", null);
|
|
278
|
+
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
279
|
+
}
|
|
280
|
+
update(e, t, s, o, i) {
|
|
281
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
282
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h);
|
|
283
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
284
|
+
const d = E(
|
|
285
|
+
n,
|
|
286
|
+
l,
|
|
306
287
|
this.arrowLength,
|
|
307
288
|
this.arrowWidth
|
|
308
289
|
);
|
|
309
|
-
this.sourceArrow.setAttribute("d",
|
|
290
|
+
this.sourceArrow.setAttribute("d", d);
|
|
310
291
|
}
|
|
311
292
|
if (this.targetArrow) {
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
o,
|
|
293
|
+
const d = E(
|
|
294
|
+
h,
|
|
295
|
+
e,
|
|
316
296
|
-this.arrowLength,
|
|
317
297
|
this.arrowWidth
|
|
318
298
|
);
|
|
319
|
-
this.targetArrow.setAttribute("d",
|
|
299
|
+
this.targetArrow.setAttribute("d", d);
|
|
320
300
|
}
|
|
321
301
|
}
|
|
302
|
+
createLinePath(e, t, s) {
|
|
303
|
+
const o = p(
|
|
304
|
+
{ x: this.arrowLength, y: l.y },
|
|
305
|
+
t,
|
|
306
|
+
l
|
|
307
|
+
), i = p(
|
|
308
|
+
{ x: e.x - this.arrowLength, y: e.y },
|
|
309
|
+
s,
|
|
310
|
+
e
|
|
311
|
+
), n = {
|
|
312
|
+
x: o.x + t.x * this.curvature,
|
|
313
|
+
y: o.y + t.y * this.curvature
|
|
314
|
+
}, h = {
|
|
315
|
+
x: i.x - s.x * this.curvature,
|
|
316
|
+
y: i.y - s.y * this.curvature
|
|
317
|
+
}, c = `M ${o.x} ${o.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${o.x} ${o.y} `, u = this.targetArrow ? "" : ` M ${i.x} ${i.y} L ${e.x} ${e.y}`;
|
|
318
|
+
return `${d}${c}${u}`;
|
|
319
|
+
}
|
|
322
320
|
}
|
|
323
|
-
class
|
|
324
|
-
constructor(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness =
|
|
331
|
-
}
|
|
332
|
-
update(
|
|
333
|
-
this.
|
|
334
|
-
const
|
|
335
|
-
this.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
|
|
340
|
-
x: s,
|
|
341
|
-
y: o
|
|
342
|
-
}) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = E({ x: f, y: 0 }, u, { x: 0, y: 0 }), x = E({ x: s - f, y: o }, w, {
|
|
343
|
-
x: s,
|
|
344
|
-
y: o
|
|
345
|
-
}), y = k([v, m, x, p], this.roundness);
|
|
346
|
-
if (this.line.setAttribute("d", y), this.sourceArrow) {
|
|
347
|
-
const C = N(
|
|
348
|
-
u,
|
|
349
|
-
0,
|
|
350
|
-
0,
|
|
321
|
+
class re {
|
|
322
|
+
constructor(e, t, s, o, i, n, h, c) {
|
|
323
|
+
a(this, "svg", T());
|
|
324
|
+
a(this, "group", $());
|
|
325
|
+
a(this, "line");
|
|
326
|
+
a(this, "sourceArrow", null);
|
|
327
|
+
a(this, "targetArrow", null);
|
|
328
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
329
|
+
}
|
|
330
|
+
update(e, t, s, o, i) {
|
|
331
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
332
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h);
|
|
333
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
334
|
+
const d = E(
|
|
335
|
+
n,
|
|
336
|
+
l,
|
|
351
337
|
this.arrowLength,
|
|
352
338
|
this.arrowWidth
|
|
353
339
|
);
|
|
354
|
-
this.sourceArrow.setAttribute("d",
|
|
340
|
+
this.sourceArrow.setAttribute("d", d);
|
|
355
341
|
}
|
|
356
342
|
if (this.targetArrow) {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
o,
|
|
343
|
+
const d = E(
|
|
344
|
+
h,
|
|
345
|
+
e,
|
|
361
346
|
-this.arrowLength,
|
|
362
347
|
this.arrowWidth
|
|
363
348
|
);
|
|
364
|
-
this.targetArrow.setAttribute("d",
|
|
349
|
+
this.targetArrow.setAttribute("d", d);
|
|
365
350
|
}
|
|
366
351
|
}
|
|
352
|
+
createLinePath(e, t, s) {
|
|
353
|
+
const o = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, n = this.arrowLength + this.arrowOffset, h = p({ x: n, y: l.y }, t, l), c = p({ x: e.x - n, y: e.y }, s, e);
|
|
354
|
+
return F([o, h, c, i], this.roundness);
|
|
355
|
+
}
|
|
367
356
|
}
|
|
368
|
-
class
|
|
369
|
-
constructor(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness =
|
|
376
|
-
}
|
|
377
|
-
update(
|
|
378
|
-
this.
|
|
379
|
-
const
|
|
380
|
-
this.
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
|
|
385
|
-
x: s,
|
|
386
|
-
y: o
|
|
387
|
-
}) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = f - this.roundness, x = E({ x: m, y: 0 }, u, { x: 0, y: 0 }), y = E({ x: s - m, y: o }, w, {
|
|
388
|
-
x: s,
|
|
389
|
-
y: o
|
|
390
|
-
}), C = Math.max((x.x + y.x) / 2, f), A = o / 2, M = { x: d > 0 ? C : -f, y: x.y }, F = { x: M.x, y: A }, D = { x: d > 0 ? s - C : s + f, y: y.y }, W = { x: D.x, y: A }, Y = k(
|
|
391
|
-
[v, x, M, F, W, D, y, p],
|
|
392
|
-
this.roundness
|
|
393
|
-
);
|
|
394
|
-
if (this.line.setAttribute("d", Y), this.sourceArrow) {
|
|
395
|
-
const $ = N(
|
|
396
|
-
u,
|
|
397
|
-
0,
|
|
398
|
-
0,
|
|
357
|
+
class se {
|
|
358
|
+
constructor(e, t, s, o, i, n, h, c) {
|
|
359
|
+
a(this, "svg", T());
|
|
360
|
+
a(this, "group", $());
|
|
361
|
+
a(this, "line");
|
|
362
|
+
a(this, "sourceArrow", null);
|
|
363
|
+
a(this, "targetArrow", null);
|
|
364
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
365
|
+
}
|
|
366
|
+
update(e, t, s, o, i) {
|
|
367
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
368
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t);
|
|
369
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
370
|
+
const d = E(
|
|
371
|
+
n,
|
|
372
|
+
l,
|
|
399
373
|
this.arrowLength,
|
|
400
374
|
this.arrowWidth
|
|
401
375
|
);
|
|
402
|
-
this.sourceArrow.setAttribute("d",
|
|
376
|
+
this.sourceArrow.setAttribute("d", d);
|
|
403
377
|
}
|
|
404
378
|
if (this.targetArrow) {
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
o,
|
|
379
|
+
const d = E(
|
|
380
|
+
h,
|
|
381
|
+
e,
|
|
409
382
|
-this.arrowLength,
|
|
410
383
|
this.arrowWidth
|
|
411
384
|
);
|
|
412
|
-
this.targetArrow.setAttribute("d",
|
|
385
|
+
this.targetArrow.setAttribute("d", d);
|
|
413
386
|
}
|
|
414
387
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
n(this, "group", O());
|
|
420
|
-
n(this, "line");
|
|
421
|
-
n(this, "sourceArrow", null);
|
|
422
|
-
n(this, "targetArrow", null);
|
|
423
|
-
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg.appendChild(this.group), this.line = R(t, r), this.group.appendChild(this.line), h && (this.sourceArrow = b(t), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = b(t), this.group.appendChild(this.targetArrow));
|
|
424
|
-
}
|
|
425
|
-
update(t, r, s, o, i, h) {
|
|
426
|
-
this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`, this.svg.style.transform = `translate(${t}px, ${r}px)`;
|
|
427
|
-
const c = L(i), a = L(h), d = c.x <= a.x ? 1 : -1, l = c.y <= a.y ? 1 : -1;
|
|
428
|
-
this.group.style.transform = `scale(${d}, ${l})`;
|
|
429
|
-
const u = P(i.direction, d, l), w = P(h.direction, d, l), v = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, u, {
|
|
430
|
-
x: 0,
|
|
431
|
-
y: 0
|
|
432
|
-
}) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
|
|
433
|
-
x: s,
|
|
434
|
-
y: o
|
|
435
|
-
}) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = f - this.roundness, x = E({ x: m, y: 0 }, u, { x: 0, y: 0 }), y = E({ x: s - m, y: o }, w, {
|
|
436
|
-
x: s,
|
|
437
|
-
y: o
|
|
438
|
-
}), C = Math.max((x.y + y.y) / 2, f), A = s / 2, M = { x: x.x, y: l > 0 ? C : -f }, F = { x: A, y: M.y }, D = {
|
|
439
|
-
x: y.x,
|
|
440
|
-
y: l > 0 ? o - C : o + f
|
|
441
|
-
}, W = { x: A, y: D.y }, Y = k(
|
|
442
|
-
[v, x, M, F, W, D, y, p],
|
|
388
|
+
createLinePath(e, t, s, o) {
|
|
389
|
+
const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), u = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.x + u.x) / 2, h), m = e.y / 2, y = { x: o > 0 ? w : -h, y: d.y }, v = { x: y.x, y: m }, A = { x: o > 0 ? e.x - w : e.x + h, y: u.y }, S = { x: A.x, y: m };
|
|
390
|
+
return F(
|
|
391
|
+
[i, d, y, v, S, A, u, n],
|
|
443
392
|
this.roundness
|
|
444
393
|
);
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class oe {
|
|
397
|
+
constructor(e, t, s, o, i, n, h, c) {
|
|
398
|
+
a(this, "svg", T());
|
|
399
|
+
a(this, "group", $());
|
|
400
|
+
a(this, "line");
|
|
401
|
+
a(this, "sourceArrow", null);
|
|
402
|
+
a(this, "targetArrow", null);
|
|
403
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
404
|
+
}
|
|
405
|
+
update(e, t, s, o, i) {
|
|
406
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
407
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, s);
|
|
408
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
409
|
+
const d = E(
|
|
410
|
+
n,
|
|
411
|
+
l,
|
|
450
412
|
this.arrowLength,
|
|
451
413
|
this.arrowWidth
|
|
452
414
|
);
|
|
453
|
-
this.sourceArrow.setAttribute("d",
|
|
415
|
+
this.sourceArrow.setAttribute("d", d);
|
|
454
416
|
}
|
|
455
417
|
if (this.targetArrow) {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
o,
|
|
418
|
+
const d = E(
|
|
419
|
+
h,
|
|
420
|
+
e,
|
|
460
421
|
-this.arrowLength,
|
|
461
422
|
this.arrowWidth
|
|
462
423
|
);
|
|
463
|
-
this.targetArrow.setAttribute("d",
|
|
424
|
+
this.targetArrow.setAttribute("d", d);
|
|
464
425
|
}
|
|
465
426
|
}
|
|
427
|
+
createLinePath(e, t, s, o) {
|
|
428
|
+
const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), u = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.y + u.y) / 2, h), m = e.x / 2, y = { x: d.x, y: o > 0 ? w : -h }, v = { x: m, y: y.y }, A = {
|
|
429
|
+
x: u.x,
|
|
430
|
+
y: o > 0 ? e.y - w : e.y + h
|
|
431
|
+
}, S = { x: m, y: A.y };
|
|
432
|
+
return F(
|
|
433
|
+
[i, d, y, v, S, A, u, n],
|
|
434
|
+
this.roundness
|
|
435
|
+
);
|
|
436
|
+
}
|
|
466
437
|
}
|
|
467
|
-
class
|
|
468
|
-
constructor(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.arrowLength = s, this.arrowWidth = o, this.radius =
|
|
474
|
-
}
|
|
475
|
-
update(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
].map(
|
|
482
|
-
(y) => E(y, h, { x: 0, y: 0 })
|
|
483
|
-
), f = [
|
|
484
|
-
`M ${p[0].x} ${p[0].y}`,
|
|
485
|
-
`A ${c} ${c} 0 0 1 ${p[1].x} ${p[1].y}`,
|
|
486
|
-
`A ${a} ${a} 0 1 0 ${p[2].x} ${p[2].y}`,
|
|
487
|
-
`A ${c} ${c} 0 0 1 ${p[0].x} ${p[0].y}`
|
|
488
|
-
].join(" "), m = `M 0 0 L ${p[0].x} ${p[0].y} `, x = `${this.arrow !== null ? "" : m}${f}`;
|
|
489
|
-
if (this.line.setAttribute("d", x), this.arrow) {
|
|
490
|
-
const y = N(
|
|
491
|
-
h,
|
|
492
|
-
0,
|
|
493
|
-
0,
|
|
438
|
+
class ie {
|
|
439
|
+
constructor(e, t, s, o, i, n, h) {
|
|
440
|
+
a(this, "svg", T());
|
|
441
|
+
a(this, "group", $());
|
|
442
|
+
a(this, "line");
|
|
443
|
+
a(this, "arrow", null);
|
|
444
|
+
this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), i && (this.arrow = C(e), this.group.appendChild(this.arrow));
|
|
445
|
+
}
|
|
446
|
+
update(e, t, s, o) {
|
|
447
|
+
const i = x(o, t, s), n = this.createLinePath(i);
|
|
448
|
+
if (this.line.setAttribute("d", n), this.arrow) {
|
|
449
|
+
const h = E(
|
|
450
|
+
i,
|
|
451
|
+
l,
|
|
494
452
|
this.arrowLength,
|
|
495
453
|
this.arrowWidth
|
|
496
454
|
);
|
|
497
|
-
this.arrow.setAttribute("d",
|
|
455
|
+
this.arrow.setAttribute("d", h);
|
|
498
456
|
}
|
|
499
457
|
}
|
|
458
|
+
createLinePath(e) {
|
|
459
|
+
const t = this.smallRadius, s = this.radius, o = Math.sqrt(t * t + s * s), i = t + s, n = this.arrowLength + o * (1 - s / i), h = t * s / i, d = [
|
|
460
|
+
{ x: this.arrowLength, y: l.y },
|
|
461
|
+
{ x: n, y: h },
|
|
462
|
+
{ x: n, y: -h }
|
|
463
|
+
].map((m) => p(m, e, l)), u = [
|
|
464
|
+
`M ${d[0].x} ${d[0].y}`,
|
|
465
|
+
`A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
|
|
466
|
+
`A ${s} ${s} 0 1 0 ${d[2].x} ${d[2].y}`,
|
|
467
|
+
`A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
|
|
468
|
+
].join(" "), w = `M 0 0 L ${d[0].x} ${d[0].y} `;
|
|
469
|
+
return `${this.arrow !== null ? "" : w}${u}`;
|
|
470
|
+
}
|
|
500
471
|
}
|
|
501
|
-
class
|
|
502
|
-
constructor(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
this.arrowLength = s, this.arrowWidth = o, this.side =
|
|
510
|
-
const d = this.minPortOffset,
|
|
511
|
-
|
|
512
|
-
{ x: this.arrowLength, y:
|
|
513
|
-
{ x:
|
|
514
|
-
{ x:
|
|
515
|
-
{ x:
|
|
516
|
-
{ x:
|
|
517
|
-
{ x:
|
|
518
|
-
{ x:
|
|
519
|
-
{ x: this.arrowLength, y:
|
|
472
|
+
class B {
|
|
473
|
+
constructor(e, t, s, o, i, n, h, c) {
|
|
474
|
+
a(this, "svg", T());
|
|
475
|
+
a(this, "group", $());
|
|
476
|
+
a(this, "line");
|
|
477
|
+
a(this, "arrow", null);
|
|
478
|
+
a(this, "roundness");
|
|
479
|
+
a(this, "linePoints");
|
|
480
|
+
this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = h, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), i && (this.arrow = C(e), this.group.appendChild(this.arrow));
|
|
481
|
+
const d = this.minPortOffset, u = this.side, w = this.arrowLength + d, m = w + 2 * u;
|
|
482
|
+
this.linePoints = [
|
|
483
|
+
{ x: this.arrowLength, y: l.y },
|
|
484
|
+
{ x: w, y: l.y },
|
|
485
|
+
{ x: w, y: this.side },
|
|
486
|
+
{ x: m, y: this.side },
|
|
487
|
+
{ x: m, y: -this.side },
|
|
488
|
+
{ x: w, y: -this.side },
|
|
489
|
+
{ x: w, y: l.y },
|
|
490
|
+
{ x: this.arrowLength, y: l.y }
|
|
520
491
|
];
|
|
521
492
|
}
|
|
522
|
-
update(
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const l = N(
|
|
529
|
-
h,
|
|
530
|
-
0,
|
|
531
|
-
0,
|
|
493
|
+
update(e, t, s, o) {
|
|
494
|
+
const i = x(o, t, s), n = this.createLinePath(i);
|
|
495
|
+
if (this.line.setAttribute("d", n), this.arrow) {
|
|
496
|
+
const h = E(
|
|
497
|
+
i,
|
|
498
|
+
l,
|
|
532
499
|
this.arrowLength,
|
|
533
500
|
this.arrowWidth
|
|
534
501
|
);
|
|
535
|
-
this.arrow.setAttribute("d",
|
|
502
|
+
this.arrow.setAttribute("d", h);
|
|
536
503
|
}
|
|
537
504
|
}
|
|
505
|
+
createLinePath(e) {
|
|
506
|
+
const t = this.linePoints.map(
|
|
507
|
+
(o) => p(o, e, l)
|
|
508
|
+
), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
|
|
509
|
+
return `${this.arrow ? "" : s}${F(t, this.roundness)}`;
|
|
510
|
+
}
|
|
538
511
|
}
|
|
539
|
-
class
|
|
540
|
-
constructor(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness =
|
|
549
|
-
}
|
|
550
|
-
update(
|
|
551
|
-
this.
|
|
552
|
-
const
|
|
553
|
-
this.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
|
|
558
|
-
x: s,
|
|
559
|
-
y: o
|
|
560
|
-
}) : { x: s, y: o }, f = this.arrowLength + this.arrowOffset, m = E({ x: f, y: 0 }, u, {
|
|
561
|
-
x: 0,
|
|
562
|
-
y: 0
|
|
563
|
-
}), x = { x: m.x + this.detourX, y: m.y + this.detourY }, y = E(
|
|
564
|
-
{ x: s - f, y: o },
|
|
565
|
-
w,
|
|
566
|
-
{
|
|
567
|
-
x: s,
|
|
568
|
-
y: o
|
|
569
|
-
}
|
|
570
|
-
), C = { x: y.x + this.detourX, y: y.y + this.detourY }, A = k(
|
|
571
|
-
[v, m, x, C, y, p],
|
|
572
|
-
this.roundness
|
|
573
|
-
);
|
|
574
|
-
if (this.line.setAttribute("d", A), this.sourceArrow) {
|
|
575
|
-
const M = N(
|
|
576
|
-
u,
|
|
577
|
-
0,
|
|
578
|
-
0,
|
|
512
|
+
class G {
|
|
513
|
+
constructor(e, t, s, o, i, n, h, c, d, u) {
|
|
514
|
+
a(this, "svg", T());
|
|
515
|
+
a(this, "group", $());
|
|
516
|
+
a(this, "line");
|
|
517
|
+
a(this, "sourceArrow", null);
|
|
518
|
+
a(this, "targetArrow", null);
|
|
519
|
+
a(this, "detourX");
|
|
520
|
+
a(this, "detourY");
|
|
521
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.detourX = Math.cos(u) * d, this.detourY = Math.sin(u) * d, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
522
|
+
}
|
|
523
|
+
update(e, t, s, o, i) {
|
|
524
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
525
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t, s);
|
|
526
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
527
|
+
const d = E(
|
|
528
|
+
n,
|
|
529
|
+
l,
|
|
579
530
|
this.arrowLength,
|
|
580
531
|
this.arrowWidth
|
|
581
532
|
);
|
|
582
|
-
this.sourceArrow.setAttribute("d",
|
|
533
|
+
this.sourceArrow.setAttribute("d", d);
|
|
583
534
|
}
|
|
584
535
|
if (this.targetArrow) {
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
o,
|
|
536
|
+
const d = E(
|
|
537
|
+
h,
|
|
538
|
+
e,
|
|
589
539
|
-this.arrowLength,
|
|
590
540
|
this.arrowWidth
|
|
591
541
|
);
|
|
592
|
-
this.targetArrow.setAttribute("d",
|
|
542
|
+
this.targetArrow.setAttribute("d", d);
|
|
593
543
|
}
|
|
594
544
|
}
|
|
545
|
+
createLinePath(e, t, s, o, i) {
|
|
546
|
+
const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength + this.arrowOffset, d = p(
|
|
547
|
+
{ x: c, y: l.y },
|
|
548
|
+
t,
|
|
549
|
+
l
|
|
550
|
+
), u = this.detourX * o, w = this.detourY * i, m = { x: d.x + u, y: d.y + w }, y = p(
|
|
551
|
+
{ x: e.x - c, y: e.y },
|
|
552
|
+
s,
|
|
553
|
+
e
|
|
554
|
+
), v = { x: y.x + u, y: y.y + w };
|
|
555
|
+
return F(
|
|
556
|
+
[n, d, m, v, y, h],
|
|
557
|
+
this.roundness
|
|
558
|
+
);
|
|
559
|
+
}
|
|
595
560
|
}
|
|
596
|
-
var
|
|
597
|
-
class
|
|
598
|
-
constructor(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) *
|
|
607
|
-
}
|
|
608
|
-
update(
|
|
609
|
-
this.
|
|
610
|
-
const
|
|
611
|
-
this.
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}) : { x: 0, y: 0 }, p = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, w, {
|
|
616
|
-
x: s,
|
|
617
|
-
y: o
|
|
618
|
-
}) : { x: s, y: o }, f = this.arrowLength, m = E({ x: f, y: 0 }, u, {
|
|
619
|
-
x: 0,
|
|
620
|
-
y: 0
|
|
621
|
-
}), x = { x: m.x + this.detourX, y: m.y + this.detourY }, y = E(
|
|
622
|
-
{ x: s - f, y: o },
|
|
623
|
-
w,
|
|
624
|
-
{
|
|
625
|
-
x: s,
|
|
626
|
-
y: o
|
|
627
|
-
}
|
|
628
|
-
), C = { x: y.x + this.detourX, y: y.y + this.detourY }, A = { x: (x.x + C.x) / 2, y: (x.y + C.y) / 2 }, M = {
|
|
629
|
-
x: m.x - this.curvature * Math.cos(i.direction),
|
|
630
|
-
y: m.y - this.curvature * Math.sin(i.direction)
|
|
631
|
-
}, F = {
|
|
632
|
-
x: y.x + this.curvature * Math.cos(h.direction),
|
|
633
|
-
y: y.y + this.curvature * Math.sin(h.direction)
|
|
634
|
-
}, D = { x: m.x + this.detourX, y: m.y + this.detourY }, W = { x: y.x + this.detourX, y: y.y + this.detourY }, Y = [
|
|
635
|
-
`M ${v.x} ${v.y}`,
|
|
636
|
-
`L ${m.x} ${m.y}`,
|
|
637
|
-
`C ${M.x} ${M.y} ${D.x} ${D.y} ${A.x} ${A.y}`,
|
|
638
|
-
`C ${W.x} ${W.y} ${F.x} ${F.y} ${y.x} ${y.y}`,
|
|
639
|
-
`L ${p.x} ${p.y}`
|
|
640
|
-
].join(" ");
|
|
641
|
-
if (this.line.setAttribute("d", Y), this.sourceArrow) {
|
|
642
|
-
const $ = N(
|
|
643
|
-
u,
|
|
644
|
-
0,
|
|
645
|
-
0,
|
|
561
|
+
var P = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(P || {});
|
|
562
|
+
class ne {
|
|
563
|
+
constructor(e, t, s, o, i, n, h, c, d) {
|
|
564
|
+
a(this, "svg", T());
|
|
565
|
+
a(this, "group", $());
|
|
566
|
+
a(this, "line");
|
|
567
|
+
a(this, "sourceArrow", null);
|
|
568
|
+
a(this, "targetArrow", null);
|
|
569
|
+
a(this, "detourX");
|
|
570
|
+
a(this, "detourY");
|
|
571
|
+
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) * c, this.detourY = Math.sin(d) * c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
|
|
572
|
+
}
|
|
573
|
+
update(e, t, s, o, i) {
|
|
574
|
+
this.group.style.transform = `scale(${t}, ${s})`;
|
|
575
|
+
const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t, s);
|
|
576
|
+
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
577
|
+
const d = E(
|
|
578
|
+
n,
|
|
579
|
+
l,
|
|
646
580
|
this.arrowLength,
|
|
647
581
|
this.arrowWidth
|
|
648
582
|
);
|
|
649
|
-
this.sourceArrow.setAttribute("d",
|
|
583
|
+
this.sourceArrow.setAttribute("d", d);
|
|
650
584
|
}
|
|
651
585
|
if (this.targetArrow) {
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
o,
|
|
586
|
+
const d = E(
|
|
587
|
+
h,
|
|
588
|
+
e,
|
|
656
589
|
-this.arrowLength,
|
|
657
590
|
this.arrowWidth
|
|
658
591
|
);
|
|
659
|
-
this.targetArrow.setAttribute("d",
|
|
592
|
+
this.targetArrow.setAttribute("d", d);
|
|
660
593
|
}
|
|
661
594
|
}
|
|
595
|
+
createLinePath(e, t, s, o, i) {
|
|
596
|
+
const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength, d = this.detourX * o, u = this.detourY * i, w = p(
|
|
597
|
+
{ x: c, y: l.y },
|
|
598
|
+
t,
|
|
599
|
+
l
|
|
600
|
+
), m = {
|
|
601
|
+
x: w.x + d,
|
|
602
|
+
y: w.y + u
|
|
603
|
+
}, y = p(
|
|
604
|
+
{ x: e.x - c, y: e.y },
|
|
605
|
+
s,
|
|
606
|
+
e
|
|
607
|
+
), v = {
|
|
608
|
+
x: y.x + d,
|
|
609
|
+
y: y.y + u
|
|
610
|
+
}, A = { x: (m.x + v.x) / 2, y: (m.y + v.y) / 2 }, S = {
|
|
611
|
+
x: w.x + this.curvature * t.x,
|
|
612
|
+
y: w.y + this.curvature * t.y
|
|
613
|
+
}, N = {
|
|
614
|
+
x: y.x - this.curvature * s.x,
|
|
615
|
+
y: y.y - this.curvature * s.y
|
|
616
|
+
}, L = {
|
|
617
|
+
x: w.x + d,
|
|
618
|
+
y: w.y + u
|
|
619
|
+
}, M = {
|
|
620
|
+
x: y.x + d,
|
|
621
|
+
y: y.y + u
|
|
622
|
+
};
|
|
623
|
+
return [
|
|
624
|
+
`M ${n.x} ${n.y}`,
|
|
625
|
+
`L ${w.x} ${w.y}`,
|
|
626
|
+
`C ${S.x} ${S.y} ${L.x} ${L.y} ${A.x} ${A.y}`,
|
|
627
|
+
`C ${M.x} ${M.y} ${N.x} ${N.y} ${y.x} ${y.y}`,
|
|
628
|
+
`L ${h.x} ${h.y}`
|
|
629
|
+
].join(" ");
|
|
630
|
+
}
|
|
662
631
|
}
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
) :
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
) : new
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
),
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
) :
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
) : new
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
),
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
) :
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
) : new
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
),
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
) :
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
) : new
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
632
|
+
const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
633
|
+
r.color,
|
|
634
|
+
r.width,
|
|
635
|
+
r.arrowLength,
|
|
636
|
+
r.arrowWidth,
|
|
637
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
638
|
+
r.cycleRadius,
|
|
639
|
+
r.smallCycleRadius
|
|
640
|
+
) : e === P.NodeCycle ? new ne(
|
|
641
|
+
r.color,
|
|
642
|
+
r.width,
|
|
643
|
+
r.curvature,
|
|
644
|
+
r.arrowLength,
|
|
645
|
+
r.arrowWidth,
|
|
646
|
+
r.hasSourceArrow,
|
|
647
|
+
r.hasTargetArrow,
|
|
648
|
+
r.detourDistance,
|
|
649
|
+
r.detourDirection
|
|
650
|
+
) : new te(
|
|
651
|
+
r.color,
|
|
652
|
+
r.width,
|
|
653
|
+
r.curvature,
|
|
654
|
+
r.arrowLength,
|
|
655
|
+
r.arrowWidth,
|
|
656
|
+
r.hasSourceArrow,
|
|
657
|
+
r.hasTargetArrow
|
|
658
|
+
), he = (r) => (e) => e === P.PortCycle ? new B(
|
|
659
|
+
r.color,
|
|
660
|
+
r.width,
|
|
661
|
+
r.arrowLength,
|
|
662
|
+
r.arrowWidth,
|
|
663
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
664
|
+
r.cycleSquareSide,
|
|
665
|
+
r.arrowOffset,
|
|
666
|
+
r.roundness
|
|
667
|
+
) : e === P.NodeCycle ? new G(
|
|
668
|
+
r.color,
|
|
669
|
+
r.width,
|
|
670
|
+
r.arrowLength,
|
|
671
|
+
r.arrowWidth,
|
|
672
|
+
r.arrowOffset,
|
|
673
|
+
r.hasSourceArrow,
|
|
674
|
+
r.hasTargetArrow,
|
|
675
|
+
r.roundness,
|
|
676
|
+
r.detourDistance,
|
|
677
|
+
r.detourDirection
|
|
678
|
+
) : new re(
|
|
679
|
+
r.color,
|
|
680
|
+
r.width,
|
|
681
|
+
r.arrowLength,
|
|
682
|
+
r.arrowWidth,
|
|
683
|
+
r.arrowOffset,
|
|
684
|
+
r.hasSourceArrow,
|
|
685
|
+
r.hasTargetArrow,
|
|
686
|
+
r.roundness
|
|
687
|
+
), ce = (r) => (e) => e === P.PortCycle ? new B(
|
|
688
|
+
r.color,
|
|
689
|
+
r.width,
|
|
690
|
+
r.arrowLength,
|
|
691
|
+
r.arrowWidth,
|
|
692
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
693
|
+
r.cycleSquareSide,
|
|
694
|
+
r.arrowOffset,
|
|
695
|
+
r.roundness
|
|
696
|
+
) : e === P.NodeCycle ? new G(
|
|
697
|
+
r.color,
|
|
698
|
+
r.width,
|
|
699
|
+
r.arrowLength,
|
|
700
|
+
r.arrowWidth,
|
|
701
|
+
r.arrowOffset,
|
|
702
|
+
r.hasSourceArrow,
|
|
703
|
+
r.hasTargetArrow,
|
|
704
|
+
r.roundness,
|
|
705
|
+
r.detourDistance,
|
|
706
|
+
r.detourDirection
|
|
707
|
+
) : new se(
|
|
708
|
+
r.color,
|
|
709
|
+
r.width,
|
|
710
|
+
r.arrowLength,
|
|
711
|
+
r.arrowWidth,
|
|
712
|
+
r.arrowOffset,
|
|
713
|
+
r.hasSourceArrow,
|
|
714
|
+
r.hasTargetArrow,
|
|
715
|
+
r.roundness
|
|
716
|
+
), de = (r) => (e) => e === P.PortCycle ? new B(
|
|
717
|
+
r.color,
|
|
718
|
+
r.width,
|
|
719
|
+
r.arrowLength,
|
|
720
|
+
r.arrowWidth,
|
|
721
|
+
r.hasSourceArrow || r.hasTargetArrow,
|
|
722
|
+
r.cycleSquareSide,
|
|
723
|
+
r.arrowOffset,
|
|
724
|
+
r.roundness
|
|
725
|
+
) : e === P.NodeCycle ? new G(
|
|
726
|
+
r.color,
|
|
727
|
+
r.width,
|
|
728
|
+
r.arrowLength,
|
|
729
|
+
r.arrowWidth,
|
|
730
|
+
r.arrowOffset,
|
|
731
|
+
r.hasSourceArrow,
|
|
732
|
+
r.hasTargetArrow,
|
|
733
|
+
r.roundness,
|
|
734
|
+
r.detourDistance,
|
|
735
|
+
r.detourDirection
|
|
736
|
+
) : new oe(
|
|
737
|
+
r.color,
|
|
738
|
+
r.width,
|
|
739
|
+
r.arrowLength,
|
|
740
|
+
r.arrowWidth,
|
|
741
|
+
r.arrowOffset,
|
|
742
|
+
r.hasSourceArrow,
|
|
743
|
+
r.hasTargetArrow,
|
|
744
|
+
r.roundness
|
|
776
745
|
);
|
|
777
|
-
class
|
|
778
|
-
constructor(
|
|
779
|
-
|
|
780
|
-
this.checkExists =
|
|
781
|
-
}
|
|
782
|
-
create(
|
|
783
|
-
if (
|
|
784
|
-
return
|
|
746
|
+
class W {
|
|
747
|
+
constructor(e) {
|
|
748
|
+
a(this, "counter", 0);
|
|
749
|
+
this.checkExists = e;
|
|
750
|
+
}
|
|
751
|
+
create(e) {
|
|
752
|
+
if (e !== void 0)
|
|
753
|
+
return e;
|
|
785
754
|
for (; this.checkExists(this.counter); )
|
|
786
755
|
this.counter++;
|
|
787
756
|
return this.counter;
|
|
@@ -790,123 +759,123 @@ class X {
|
|
|
790
759
|
this.counter = 0;
|
|
791
760
|
}
|
|
792
761
|
}
|
|
793
|
-
class
|
|
762
|
+
class f extends Error {
|
|
794
763
|
constructor() {
|
|
795
764
|
super(...arguments);
|
|
796
|
-
|
|
765
|
+
a(this, "name", "HtmlGraphError");
|
|
797
766
|
}
|
|
798
767
|
}
|
|
799
|
-
class
|
|
800
|
-
constructor(
|
|
801
|
-
|
|
802
|
-
(
|
|
768
|
+
class le {
|
|
769
|
+
constructor(e, t, s, o, i, n, h, c) {
|
|
770
|
+
a(this, "nodeIdGenerator", new W(
|
|
771
|
+
(e) => this.graphStore.getNode(e) !== void 0
|
|
803
772
|
));
|
|
804
|
-
|
|
805
|
-
(
|
|
773
|
+
a(this, "portIdGenerator", new W(
|
|
774
|
+
(e) => this.graphStore.getPort(e) !== void 0
|
|
806
775
|
));
|
|
807
|
-
|
|
808
|
-
(
|
|
776
|
+
a(this, "edgeIdGenerator", new W(
|
|
777
|
+
(e) => this.graphStore.getEdge(e) !== void 0
|
|
809
778
|
));
|
|
810
|
-
this.graphStore =
|
|
779
|
+
this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = o, this.defaultPortsCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
|
|
811
780
|
}
|
|
812
|
-
addNode(
|
|
813
|
-
if (
|
|
814
|
-
throw new
|
|
781
|
+
addNode(e, t, s, o, i, n, h) {
|
|
782
|
+
if (e = this.nodeIdGenerator.create(e), this.graphStore.getNode(e) !== void 0)
|
|
783
|
+
throw new f("failed to add node with existing id");
|
|
815
784
|
this.graphStore.addNode(
|
|
785
|
+
e,
|
|
816
786
|
t,
|
|
817
|
-
r,
|
|
818
787
|
s,
|
|
819
788
|
o,
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
), this.htmlController.attachNode(
|
|
789
|
+
n ?? this.defaultNodesCenterFn,
|
|
790
|
+
h ?? this.defaultNodesPriorityFn()
|
|
791
|
+
), this.htmlController.attachNode(e), Array.from(i ?? []).forEach((c) => {
|
|
823
792
|
this.markPort(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
793
|
+
c.id,
|
|
794
|
+
c.element,
|
|
795
|
+
e,
|
|
796
|
+
c.centerFn ?? this.defaultPortsCenterFn,
|
|
797
|
+
c.direction ?? this.defaultPortsDirection
|
|
829
798
|
);
|
|
830
799
|
});
|
|
831
800
|
}
|
|
832
|
-
updateNode(
|
|
833
|
-
const
|
|
834
|
-
if (
|
|
835
|
-
throw new
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
removeNode(
|
|
839
|
-
if (this.graphStore.getNode(
|
|
840
|
-
throw new
|
|
841
|
-
(this.graphStore.getNodePortIds(
|
|
842
|
-
this.unmarkPort(
|
|
843
|
-
}), this.htmlController.detachNode(
|
|
844
|
-
}
|
|
845
|
-
markPort(
|
|
846
|
-
if (
|
|
847
|
-
throw new
|
|
848
|
-
if (this.graphStore.getPort(
|
|
849
|
-
throw new
|
|
801
|
+
updateNode(e, t, s, o, i) {
|
|
802
|
+
const n = this.graphStore.getNode(e);
|
|
803
|
+
if (n === void 0)
|
|
804
|
+
throw new f("failed to update nonexisting node");
|
|
805
|
+
n.x = t ?? n.x, n.y = s ?? n.y, n.centerFn = i ?? n.centerFn, this.htmlController.updateNodeCoordinates(e), o !== void 0 && (n.priority = o, this.htmlController.updateNodePriority(e));
|
|
806
|
+
}
|
|
807
|
+
removeNode(e) {
|
|
808
|
+
if (this.graphStore.getNode(e) === void 0)
|
|
809
|
+
throw new f("failed to remove nonexisting node");
|
|
810
|
+
(this.graphStore.getNodePortIds(e) ?? []).forEach((t) => {
|
|
811
|
+
this.unmarkPort(t);
|
|
812
|
+
}), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
|
|
813
|
+
}
|
|
814
|
+
markPort(e, t, s, o, i) {
|
|
815
|
+
if (e = this.portIdGenerator.create(e), this.graphStore.getNode(s) === void 0)
|
|
816
|
+
throw new f("failed to set port on nonexisting node");
|
|
817
|
+
if (this.graphStore.getPort(e) !== void 0)
|
|
818
|
+
throw new f("failed to add port with existing id");
|
|
850
819
|
this.graphStore.addPort(
|
|
820
|
+
e,
|
|
851
821
|
t,
|
|
852
|
-
r,
|
|
853
822
|
s,
|
|
854
823
|
o ?? this.defaultPortsCenterFn,
|
|
855
824
|
i ?? this.defaultPortsDirection
|
|
856
825
|
);
|
|
857
826
|
}
|
|
858
|
-
updatePort(
|
|
859
|
-
const o = this.graphStore.getPort(
|
|
827
|
+
updatePort(e, t, s) {
|
|
828
|
+
const o = this.graphStore.getPort(e);
|
|
860
829
|
if (o === void 0)
|
|
861
|
-
throw new
|
|
862
|
-
o.direction =
|
|
863
|
-
}
|
|
864
|
-
unmarkPort(
|
|
865
|
-
if (this.graphStore.getPort(
|
|
866
|
-
throw new
|
|
867
|
-
this.graphStore.getPortAdjacentEdgeIds(
|
|
868
|
-
this.removeEdge(
|
|
869
|
-
}), this.graphStore.removePort(
|
|
870
|
-
}
|
|
871
|
-
addEdge(
|
|
872
|
-
if (
|
|
873
|
-
throw new
|
|
830
|
+
throw new f("failed to unset nonexisting port");
|
|
831
|
+
o.direction = t ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(e);
|
|
832
|
+
}
|
|
833
|
+
unmarkPort(e) {
|
|
834
|
+
if (this.graphStore.getPort(e) === void 0)
|
|
835
|
+
throw new f("failed to unset nonexisting port");
|
|
836
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
837
|
+
this.removeEdge(t);
|
|
838
|
+
}), this.graphStore.removePort(e);
|
|
839
|
+
}
|
|
840
|
+
addEdge(e, t, s, o, i) {
|
|
841
|
+
if (e = this.edgeIdGenerator.create(e), this.graphStore.getPort(t) === void 0)
|
|
842
|
+
throw new f("failed to add edge from nonexisting port");
|
|
874
843
|
if (this.graphStore.getPort(s) === void 0)
|
|
875
|
-
throw new
|
|
876
|
-
if (this.graphStore.getEdge(
|
|
877
|
-
throw new
|
|
878
|
-
const
|
|
844
|
+
throw new f("failed to add edge to nonexisting port");
|
|
845
|
+
if (this.graphStore.getEdge(e) !== void 0)
|
|
846
|
+
throw new f("failed to add edge with existing id");
|
|
847
|
+
const n = this.resolveEdgeType(t, s);
|
|
879
848
|
this.graphStore.addEdge(
|
|
849
|
+
e,
|
|
880
850
|
t,
|
|
881
|
-
r,
|
|
882
851
|
s,
|
|
883
|
-
o(
|
|
852
|
+
o(n),
|
|
884
853
|
i ?? this.defaultEdgesPriorityFn()
|
|
885
|
-
), this.htmlController.attachEdge(
|
|
854
|
+
), this.htmlController.attachEdge(e);
|
|
886
855
|
}
|
|
887
|
-
updateEdge(
|
|
888
|
-
const o = this.graphStore.getEdge(
|
|
856
|
+
updateEdge(e, t, s) {
|
|
857
|
+
const o = this.graphStore.getEdge(e);
|
|
889
858
|
if (o === void 0)
|
|
890
|
-
throw new
|
|
891
|
-
if (
|
|
859
|
+
throw new f("failed to update nonexisting edge");
|
|
860
|
+
if (t !== void 0) {
|
|
892
861
|
const i = this.resolveEdgeType(o.from, o.to);
|
|
893
|
-
o.shape =
|
|
862
|
+
o.shape = t(i), this.htmlController.updateEdgeShape(e);
|
|
894
863
|
}
|
|
895
|
-
s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(
|
|
864
|
+
s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(e));
|
|
896
865
|
}
|
|
897
|
-
removeEdge(
|
|
898
|
-
if (this.graphStore.getEdge(
|
|
899
|
-
throw new
|
|
900
|
-
this.htmlController.detachEdge(
|
|
866
|
+
removeEdge(e) {
|
|
867
|
+
if (this.graphStore.getEdge(e) === void 0)
|
|
868
|
+
throw new f("failed to remove nonexisting edge");
|
|
869
|
+
this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
|
|
901
870
|
}
|
|
902
|
-
patchViewportMatrix(
|
|
903
|
-
this.viewportTransformer.patchViewportMatrix(
|
|
871
|
+
patchViewportMatrix(e, t, s) {
|
|
872
|
+
this.viewportTransformer.patchViewportMatrix(e, t, s), this.htmlController.applyTransform();
|
|
904
873
|
}
|
|
905
|
-
patchContentMatrix(
|
|
906
|
-
this.viewportTransformer.patchContentMatrix(
|
|
874
|
+
patchContentMatrix(e, t, s) {
|
|
875
|
+
this.viewportTransformer.patchContentMatrix(e, t, s), this.htmlController.applyTransform();
|
|
907
876
|
}
|
|
908
|
-
attach(
|
|
909
|
-
this.htmlController.attach(
|
|
877
|
+
attach(e) {
|
|
878
|
+
this.htmlController.attach(e);
|
|
910
879
|
}
|
|
911
880
|
detach() {
|
|
912
881
|
this.htmlController.detach();
|
|
@@ -917,84 +886,84 @@ class yt {
|
|
|
917
886
|
destroy() {
|
|
918
887
|
this.htmlController.destroy();
|
|
919
888
|
}
|
|
920
|
-
resolveEdgeType(
|
|
921
|
-
if (
|
|
922
|
-
return
|
|
923
|
-
const s = this.graphStore.getPortNodeId(
|
|
924
|
-
return s === o ?
|
|
889
|
+
resolveEdgeType(e, t) {
|
|
890
|
+
if (e === t)
|
|
891
|
+
return P.PortCycle;
|
|
892
|
+
const s = this.graphStore.getPortNodeId(e), o = this.graphStore.getPortNodeId(t);
|
|
893
|
+
return s === o ? P.NodeCycle : P.Regular;
|
|
925
894
|
}
|
|
926
895
|
}
|
|
927
|
-
const
|
|
928
|
-
const
|
|
929
|
-
return
|
|
930
|
-
},
|
|
931
|
-
const
|
|
932
|
-
return
|
|
933
|
-
},
|
|
934
|
-
const
|
|
935
|
-
return
|
|
936
|
-
},
|
|
937
|
-
const
|
|
938
|
-
return
|
|
896
|
+
const ue = () => {
|
|
897
|
+
const r = document.createElement("div");
|
|
898
|
+
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
|
|
899
|
+
}, ge = () => {
|
|
900
|
+
const r = document.createElement("canvas");
|
|
901
|
+
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
902
|
+
}, we = () => {
|
|
903
|
+
const r = document.createElement("div");
|
|
904
|
+
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
|
|
905
|
+
}, ye = () => {
|
|
906
|
+
const r = document.createElement("div");
|
|
907
|
+
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
|
|
939
908
|
};
|
|
940
|
-
class
|
|
909
|
+
class me {
|
|
941
910
|
constructor() {
|
|
942
|
-
|
|
943
|
-
|
|
911
|
+
a(this, "keyMap", /* @__PURE__ */ new Map());
|
|
912
|
+
a(this, "valueMap", /* @__PURE__ */ new Map());
|
|
944
913
|
}
|
|
945
|
-
set(
|
|
946
|
-
this.keyMap.set(
|
|
914
|
+
set(e, t) {
|
|
915
|
+
this.keyMap.set(e, t), this.valueMap.set(t, e);
|
|
947
916
|
}
|
|
948
|
-
getByKey(
|
|
949
|
-
return this.keyMap.get(
|
|
917
|
+
getByKey(e) {
|
|
918
|
+
return this.keyMap.get(e);
|
|
950
919
|
}
|
|
951
|
-
getByValue(
|
|
952
|
-
return this.valueMap.get(
|
|
920
|
+
getByValue(e) {
|
|
921
|
+
return this.valueMap.get(e);
|
|
953
922
|
}
|
|
954
|
-
deleteByKey(
|
|
955
|
-
const
|
|
956
|
-
|
|
923
|
+
deleteByKey(e) {
|
|
924
|
+
const t = this.keyMap.get(e);
|
|
925
|
+
t !== void 0 && this.valueMap.delete(t), this.keyMap.delete(e);
|
|
957
926
|
}
|
|
958
|
-
deleteByValue(
|
|
959
|
-
const
|
|
960
|
-
|
|
927
|
+
deleteByValue(e) {
|
|
928
|
+
const t = this.valueMap.get(e);
|
|
929
|
+
t !== void 0 && this.keyMap.delete(t), this.valueMap.delete(e);
|
|
961
930
|
}
|
|
962
|
-
forEach(
|
|
963
|
-
this.keyMap.forEach((
|
|
964
|
-
t
|
|
931
|
+
forEach(e) {
|
|
932
|
+
this.keyMap.forEach((t, s) => {
|
|
933
|
+
e(t, s);
|
|
965
934
|
});
|
|
966
935
|
}
|
|
967
936
|
clear() {
|
|
968
937
|
this.keyMap.clear(), this.valueMap.clear();
|
|
969
938
|
}
|
|
970
939
|
}
|
|
971
|
-
class
|
|
972
|
-
constructor(
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
this.graphStore =
|
|
940
|
+
class pe {
|
|
941
|
+
constructor(e, t, s, o) {
|
|
942
|
+
a(this, "canvasWrapper", null);
|
|
943
|
+
a(this, "host", ue());
|
|
944
|
+
a(this, "canvas", ge());
|
|
945
|
+
a(this, "container", we());
|
|
946
|
+
a(this, "canvasCtx");
|
|
947
|
+
a(this, "canvasResizeObserver");
|
|
948
|
+
a(this, "nodesResizeObserver");
|
|
949
|
+
a(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
|
|
950
|
+
a(this, "nodeIdToWrapperElementMap", new me());
|
|
951
|
+
a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
952
|
+
this.graphStore = e, this.viewportTransformer = t, this.publicViewportTransformer = s, this.backgroundDrawingFn = o;
|
|
984
953
|
const i = this.canvas.getContext("2d");
|
|
985
954
|
if (i === null)
|
|
986
|
-
throw new
|
|
955
|
+
throw new f("unable to get canvas context");
|
|
987
956
|
this.canvasCtx = i, this.host.appendChild(this.canvas), this.host.appendChild(this.container), this.canvasResizeObserver = this.createHostResizeObserver(), this.nodesResizeObserver = this.createNodesResizeObserver();
|
|
988
957
|
}
|
|
989
958
|
clear() {
|
|
990
|
-
this.edgeIdToElementMap.forEach((
|
|
991
|
-
this.detachEdge(
|
|
992
|
-
}), this.nodeIdToWrapperElementMap.forEach((
|
|
993
|
-
this.detachNode(
|
|
959
|
+
this.edgeIdToElementMap.forEach((e, t) => {
|
|
960
|
+
this.detachEdge(t);
|
|
961
|
+
}), this.nodeIdToWrapperElementMap.forEach((e, t) => {
|
|
962
|
+
this.detachNode(t);
|
|
994
963
|
});
|
|
995
964
|
}
|
|
996
|
-
attach(
|
|
997
|
-
this.detach(), this.canvasWrapper =
|
|
965
|
+
attach(e) {
|
|
966
|
+
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.canvasResizeObserver.observe(this.canvasWrapper);
|
|
998
967
|
}
|
|
999
968
|
detach() {
|
|
1000
969
|
this.canvasWrapper !== null && (this.canvasResizeObserver.unobserve(this.canvasWrapper), this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
@@ -1004,47 +973,47 @@ class Et {
|
|
|
1004
973
|
}
|
|
1005
974
|
applyTransform() {
|
|
1006
975
|
this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
|
|
1007
|
-
const
|
|
1008
|
-
this.container.style.transform = `matrix(${
|
|
976
|
+
const e = this.viewportTransformer.getContentMatrix();
|
|
977
|
+
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
|
|
1009
978
|
}
|
|
1010
|
-
attachNode(
|
|
1011
|
-
const
|
|
1012
|
-
s.appendChild(
|
|
979
|
+
attachNode(e) {
|
|
980
|
+
const t = this.graphStore.getNode(e), s = ye();
|
|
981
|
+
s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoords(e), this.updateNodePriority(e), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
|
|
1013
982
|
}
|
|
1014
|
-
detachNode(
|
|
1015
|
-
const
|
|
1016
|
-
this.nodesResizeObserver.unobserve(s), s.removeChild(
|
|
983
|
+
detachNode(e) {
|
|
984
|
+
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
|
|
985
|
+
this.nodesResizeObserver.unobserve(s), s.removeChild(t.element), this.container.removeChild(s), this.nodeElementToIdMap.delete(t.element), this.nodeIdToWrapperElementMap.deleteByKey(e);
|
|
1017
986
|
}
|
|
1018
|
-
attachEdge(
|
|
1019
|
-
const
|
|
1020
|
-
this.edgeIdToElementMap.set(
|
|
987
|
+
attachEdge(e) {
|
|
988
|
+
const t = this.graphStore.getEdge(e);
|
|
989
|
+
this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdgeCoords(e), this.updateEdgePriority(e);
|
|
1021
990
|
}
|
|
1022
|
-
detachEdge(
|
|
1023
|
-
const
|
|
1024
|
-
this.container.removeChild(
|
|
991
|
+
detachEdge(e) {
|
|
992
|
+
const t = this.graphStore.getEdge(e);
|
|
993
|
+
this.container.removeChild(t.shape.svg), this.edgeIdToElementMap.delete(e);
|
|
1025
994
|
}
|
|
1026
|
-
updateNodeCoordinates(
|
|
1027
|
-
const
|
|
1028
|
-
this.updateNodeCoords(
|
|
995
|
+
updateNodeCoordinates(e) {
|
|
996
|
+
const t = this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
997
|
+
this.updateNodeCoords(e), t.forEach((s) => {
|
|
1029
998
|
this.updateEdgeCoords(s);
|
|
1030
999
|
});
|
|
1031
1000
|
}
|
|
1032
|
-
updateNodePriority(
|
|
1033
|
-
const
|
|
1034
|
-
s.style.zIndex = `${
|
|
1001
|
+
updateNodePriority(e) {
|
|
1002
|
+
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
|
|
1003
|
+
s.style.zIndex = `${t.priority}`;
|
|
1035
1004
|
}
|
|
1036
|
-
updateEdgeShape(
|
|
1037
|
-
const
|
|
1038
|
-
this.container.removeChild(
|
|
1039
|
-
const s = this.graphStore.getEdge(
|
|
1040
|
-
this.edgeIdToElementMap.set(
|
|
1005
|
+
updateEdgeShape(e) {
|
|
1006
|
+
const t = this.edgeIdToElementMap.get(e);
|
|
1007
|
+
this.container.removeChild(t);
|
|
1008
|
+
const s = this.graphStore.getEdge(e);
|
|
1009
|
+
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoords(e), this.updateEdgePriority(e);
|
|
1041
1010
|
}
|
|
1042
|
-
updateEdgePriority(
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1011
|
+
updateEdgePriority(e) {
|
|
1012
|
+
const t = this.graphStore.getEdge(e);
|
|
1013
|
+
t.shape.svg.style.zIndex = `${t.priority}`;
|
|
1045
1014
|
}
|
|
1046
|
-
updatePortEdges(
|
|
1047
|
-
this.graphStore.getPortAdjacentEdgeIds(
|
|
1015
|
+
updatePortEdges(e) {
|
|
1016
|
+
this.graphStore.getPortAdjacentEdgeIds(e).forEach((s) => {
|
|
1048
1017
|
this.updateEdgeCoords(s);
|
|
1049
1018
|
});
|
|
1050
1019
|
}
|
|
@@ -1054,99 +1023,119 @@ class Et {
|
|
|
1054
1023
|
});
|
|
1055
1024
|
}
|
|
1056
1025
|
createNodesResizeObserver() {
|
|
1057
|
-
return new ResizeObserver((
|
|
1058
|
-
|
|
1059
|
-
const s =
|
|
1060
|
-
this.updateNodeCoords(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((
|
|
1061
|
-
this.updateEdgeCoords(
|
|
1026
|
+
return new ResizeObserver((e) => {
|
|
1027
|
+
e.forEach((t) => {
|
|
1028
|
+
const s = t.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
|
|
1029
|
+
this.updateNodeCoords(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
1030
|
+
this.updateEdgeCoords(n);
|
|
1062
1031
|
});
|
|
1063
1032
|
});
|
|
1064
1033
|
});
|
|
1065
1034
|
}
|
|
1066
1035
|
updateCanvasDimensions() {
|
|
1067
|
-
const { width:
|
|
1068
|
-
this.canvas.width =
|
|
1069
|
-
}
|
|
1070
|
-
updateNodeCoords(
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
}
|
|
1074
|
-
updateEdgeCoords(
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1036
|
+
const { width: e, height: t } = this.host.getBoundingClientRect();
|
|
1037
|
+
this.canvas.width = e, this.canvas.height = t;
|
|
1038
|
+
}
|
|
1039
|
+
updateNodeCoords(e) {
|
|
1040
|
+
const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = t.getBoundingClientRect(), i = this.viewportTransformer.getViewportMatrix().scale, n = this.graphStore.getNode(e), { x: h, y: c } = n.centerFn(s, o), d = n.x - i * h, u = n.y - i * c;
|
|
1041
|
+
t.style.transform = `matrix(1, 0, 0, 1, ${d}, ${u})`;
|
|
1042
|
+
}
|
|
1043
|
+
updateEdgeCoords(e) {
|
|
1044
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = s.element.getBoundingClientRect(), n = o.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), d = {
|
|
1045
|
+
x: c.scale * (i.left - h.left) + c.dx,
|
|
1046
|
+
y: c.scale * (i.top - h.top) + c.dy
|
|
1047
|
+
}, u = {
|
|
1048
|
+
x: c.scale * (n.left - h.left) + c.dx,
|
|
1049
|
+
y: c.scale * (n.top - h.top) + c.dy
|
|
1050
|
+
}, w = s.centerFn(
|
|
1051
|
+
i.width * c.scale,
|
|
1052
|
+
i.height * c.scale
|
|
1053
|
+
), m = o.centerFn(
|
|
1054
|
+
n.width * c.scale,
|
|
1055
|
+
n.height * c.scale
|
|
1056
|
+
), y = {
|
|
1057
|
+
x: d.x + w.x,
|
|
1058
|
+
y: d.y + w.y
|
|
1059
|
+
}, v = {
|
|
1060
|
+
x: u.x + m.x,
|
|
1061
|
+
y: u.y + m.y
|
|
1062
|
+
}, A = Math.min(y.x, v.x), S = Math.min(y.y, v.y), N = Math.abs(v.x - y.x), L = Math.abs(v.y - y.y);
|
|
1063
|
+
t.shape.svg.style.width = `${N}px`, t.shape.svg.style.height = `${L}px`, t.shape.svg.style.transform = `translate(${A}px, ${S}px)`;
|
|
1064
|
+
const M = y.x <= v.x ? 1 : -1, b = y.y <= v.y ? 1 : -1;
|
|
1065
|
+
t.shape.update(
|
|
1066
|
+
{ x: N, y: L },
|
|
1067
|
+
M,
|
|
1068
|
+
b,
|
|
1069
|
+
s.direction,
|
|
1070
|
+
o.direction
|
|
1071
|
+
);
|
|
1083
1072
|
}
|
|
1084
1073
|
}
|
|
1085
|
-
class
|
|
1086
|
-
constructor(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
this.publicGraphStore = new
|
|
1092
|
-
|
|
1074
|
+
class ve {
|
|
1075
|
+
constructor(e, t, s, o, i, n) {
|
|
1076
|
+
a(this, "publicViewportTransformer");
|
|
1077
|
+
a(this, "publicGraphStore");
|
|
1078
|
+
a(this, "canvasController");
|
|
1079
|
+
const h = new Q(), c = new q();
|
|
1080
|
+
this.publicGraphStore = new ee(c), this.publicViewportTransformer = new Z(
|
|
1081
|
+
h
|
|
1093
1082
|
);
|
|
1094
|
-
const d = new
|
|
1095
|
-
a,
|
|
1083
|
+
const d = new pe(
|
|
1096
1084
|
c,
|
|
1085
|
+
h,
|
|
1097
1086
|
this.publicViewportTransformer,
|
|
1098
|
-
|
|
1087
|
+
e
|
|
1099
1088
|
);
|
|
1100
|
-
this.canvasController = new
|
|
1101
|
-
a,
|
|
1102
|
-
d,
|
|
1089
|
+
this.canvasController = new le(
|
|
1103
1090
|
c,
|
|
1104
|
-
|
|
1091
|
+
d,
|
|
1092
|
+
h,
|
|
1093
|
+
t,
|
|
1105
1094
|
s,
|
|
1106
1095
|
o,
|
|
1107
1096
|
i,
|
|
1108
|
-
|
|
1097
|
+
n
|
|
1109
1098
|
);
|
|
1110
1099
|
}
|
|
1111
1100
|
}
|
|
1112
|
-
const
|
|
1113
|
-
x:
|
|
1114
|
-
y:
|
|
1115
|
-
}),
|
|
1116
|
-
},
|
|
1117
|
-
|
|
1118
|
-
const
|
|
1119
|
-
if (d *
|
|
1101
|
+
const H = (r, e) => ({
|
|
1102
|
+
x: r / 2,
|
|
1103
|
+
y: e / 2
|
|
1104
|
+
}), fe = () => () => {
|
|
1105
|
+
}, xe = (r, e, t, s, o, i, n) => {
|
|
1106
|
+
r.clearRect(0, 0, r.canvas.width, r.canvas.height), r.fillStyle = i, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
|
|
1107
|
+
const h = e.getContentMatrix(), c = s * h.scale, d = r.canvas.width / c, u = r.canvas.height / c;
|
|
1108
|
+
if (d * u > n)
|
|
1120
1109
|
return;
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
for (let
|
|
1124
|
-
for (let
|
|
1125
|
-
|
|
1126
|
-
},
|
|
1127
|
-
|
|
1110
|
+
const w = h.dx - Math.floor(h.dx / c) * c, m = h.dy - Math.floor(h.dy / c) * c, y = o * h.scale, v = 2 * Math.PI, A = w - c, S = m - c, N = r.canvas.width + w, L = r.canvas.height + m;
|
|
1111
|
+
r.fillStyle = t;
|
|
1112
|
+
for (let M = A; M <= N; M += c)
|
|
1113
|
+
for (let b = S; b <= L; b += c)
|
|
1114
|
+
r.beginPath(), r.arc(M, b, y, 0, v), r.closePath(), r.fill();
|
|
1115
|
+
}, Ee = (r, e, t, s, o) => (i, n) => {
|
|
1116
|
+
xe(
|
|
1128
1117
|
i,
|
|
1129
|
-
|
|
1118
|
+
n,
|
|
1119
|
+
r,
|
|
1130
1120
|
e,
|
|
1131
1121
|
t,
|
|
1132
|
-
r,
|
|
1133
1122
|
s,
|
|
1134
1123
|
o
|
|
1135
1124
|
);
|
|
1136
|
-
},
|
|
1137
|
-
switch (
|
|
1125
|
+
}, Ce = (r) => {
|
|
1126
|
+
switch (r == null ? void 0 : r.type) {
|
|
1138
1127
|
case "custom":
|
|
1139
|
-
return
|
|
1128
|
+
return r.drawingFn;
|
|
1140
1129
|
case "dots":
|
|
1141
|
-
return
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1130
|
+
return Ee(
|
|
1131
|
+
r.dotColor ?? "#d8d8d8",
|
|
1132
|
+
r.dotGap ?? 25,
|
|
1133
|
+
r.dotRadius ?? 1.5,
|
|
1134
|
+
r.color ?? "#ffffff",
|
|
1135
|
+
r.limit ?? 1e4
|
|
1147
1136
|
);
|
|
1148
1137
|
default:
|
|
1149
|
-
return
|
|
1138
|
+
return fe();
|
|
1150
1139
|
}
|
|
1151
1140
|
}, g = {
|
|
1152
1141
|
edgeColor: "#5c5c5c",
|
|
@@ -1162,199 +1151,199 @@ const Q = (e, t) => ({
|
|
|
1162
1151
|
detourDirection: -Math.PI / 2,
|
|
1163
1152
|
smallCycleSize: 15,
|
|
1164
1153
|
curvature: 90
|
|
1165
|
-
},
|
|
1166
|
-
switch (
|
|
1154
|
+
}, z = (r) => {
|
|
1155
|
+
switch (r == null ? void 0 : r.type) {
|
|
1167
1156
|
case "custom":
|
|
1168
|
-
return
|
|
1157
|
+
return r.factory;
|
|
1169
1158
|
case "straight":
|
|
1170
|
-
return
|
|
1171
|
-
color:
|
|
1172
|
-
width:
|
|
1173
|
-
arrowLength:
|
|
1174
|
-
arrowWidth:
|
|
1175
|
-
arrowOffset:
|
|
1176
|
-
hasSourceArrow:
|
|
1177
|
-
hasTargetArrow:
|
|
1178
|
-
cycleSquareSide:
|
|
1179
|
-
roundness:
|
|
1180
|
-
detourDistance:
|
|
1181
|
-
detourDirection:
|
|
1159
|
+
return he({
|
|
1160
|
+
color: r.color ?? g.edgeColor,
|
|
1161
|
+
width: r.width ?? g.edgeWidth,
|
|
1162
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
1163
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
1164
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
1165
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
1166
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
1167
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
1168
|
+
roundness: r.roundness ?? g.roundness,
|
|
1169
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1170
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1182
1171
|
});
|
|
1183
1172
|
case "horizontal":
|
|
1184
|
-
return
|
|
1185
|
-
color:
|
|
1186
|
-
width:
|
|
1187
|
-
arrowLength:
|
|
1188
|
-
arrowWidth:
|
|
1189
|
-
arrowOffset:
|
|
1190
|
-
hasSourceArrow:
|
|
1191
|
-
hasTargetArrow:
|
|
1192
|
-
cycleSquareSide:
|
|
1193
|
-
roundness:
|
|
1194
|
-
detourDistance:
|
|
1195
|
-
detourDirection:
|
|
1173
|
+
return ce({
|
|
1174
|
+
color: r.color ?? g.edgeColor,
|
|
1175
|
+
width: r.width ?? g.edgeWidth,
|
|
1176
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
1177
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
1178
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
1179
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
1180
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
1181
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
1182
|
+
roundness: r.roundness ?? g.roundness,
|
|
1183
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1184
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1196
1185
|
});
|
|
1197
1186
|
case "vertical":
|
|
1198
|
-
return
|
|
1199
|
-
color:
|
|
1200
|
-
width:
|
|
1201
|
-
arrowLength:
|
|
1202
|
-
arrowWidth:
|
|
1203
|
-
arrowOffset:
|
|
1204
|
-
hasSourceArrow:
|
|
1205
|
-
hasTargetArrow:
|
|
1206
|
-
cycleSquareSide:
|
|
1207
|
-
roundness:
|
|
1208
|
-
detourDistance:
|
|
1209
|
-
detourDirection:
|
|
1187
|
+
return de({
|
|
1188
|
+
color: r.color ?? g.edgeColor,
|
|
1189
|
+
width: r.width ?? g.edgeWidth,
|
|
1190
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
1191
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
1192
|
+
arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
|
|
1193
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
1194
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
1195
|
+
cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
|
|
1196
|
+
roundness: r.roundness ?? g.roundness,
|
|
1197
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1198
|
+
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1210
1199
|
});
|
|
1211
1200
|
default:
|
|
1212
|
-
return
|
|
1213
|
-
color:
|
|
1214
|
-
width:
|
|
1215
|
-
arrowLength:
|
|
1216
|
-
arrowWidth:
|
|
1217
|
-
hasSourceArrow:
|
|
1218
|
-
hasTargetArrow:
|
|
1219
|
-
cycleRadius:
|
|
1220
|
-
detourDistance:
|
|
1221
|
-
detourDirection:
|
|
1222
|
-
smallCycleRadius:
|
|
1223
|
-
curvature:
|
|
1201
|
+
return ae({
|
|
1202
|
+
color: r.color ?? g.edgeColor,
|
|
1203
|
+
width: r.width ?? g.edgeWidth,
|
|
1204
|
+
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
1205
|
+
arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
|
|
1206
|
+
hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
|
|
1207
|
+
hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
|
|
1208
|
+
cycleRadius: r.cycleRadius ?? g.cycleSize,
|
|
1209
|
+
detourDistance: r.detourDistance ?? g.detourDistance,
|
|
1210
|
+
detourDirection: r.detourDirection ?? g.detourDirection,
|
|
1211
|
+
smallCycleRadius: r.smallCycleRadius ?? g.smallCycleSize,
|
|
1212
|
+
curvature: r.curvature ?? g.curvature
|
|
1224
1213
|
});
|
|
1225
1214
|
}
|
|
1226
|
-
},
|
|
1227
|
-
let
|
|
1228
|
-
return () =>
|
|
1229
|
-
},
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1215
|
+
}, I = (r) => () => r, U = I(0), k = () => {
|
|
1216
|
+
let r = 0;
|
|
1217
|
+
return () => r++;
|
|
1218
|
+
}, Ae = (r, e) => {
|
|
1219
|
+
const t = [
|
|
1220
|
+
U,
|
|
1221
|
+
U
|
|
1233
1222
|
];
|
|
1234
|
-
|
|
1235
|
-
const s =
|
|
1236
|
-
return
|
|
1237
|
-
},
|
|
1238
|
-
var s, o, i, h, c
|
|
1239
|
-
const [
|
|
1240
|
-
(s =
|
|
1241
|
-
(o =
|
|
1223
|
+
r === "incremental" && (t[0] = k()), e === "incremental" && (t[1] = k());
|
|
1224
|
+
const s = k();
|
|
1225
|
+
return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] = I(r)), typeof e == "number" && (t[1] = I(e)), typeof r == "function" && (t[0] = r), typeof e == "function" && (t[1] = e), t;
|
|
1226
|
+
}, Se = (r) => {
|
|
1227
|
+
var s, o, i, n, h, c;
|
|
1228
|
+
const [e, t] = Ae(
|
|
1229
|
+
(s = r.nodes) == null ? void 0 : s.priority,
|
|
1230
|
+
(o = r.edges) == null ? void 0 : o.priority
|
|
1242
1231
|
);
|
|
1243
1232
|
return {
|
|
1244
1233
|
background: {
|
|
1245
|
-
drawingFn:
|
|
1246
|
-
|
|
1234
|
+
drawingFn: Ce(
|
|
1235
|
+
r.background ?? { type: "none" }
|
|
1247
1236
|
)
|
|
1248
1237
|
},
|
|
1249
1238
|
nodes: {
|
|
1250
|
-
centerFn: ((i =
|
|
1251
|
-
priorityFn:
|
|
1239
|
+
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? H,
|
|
1240
|
+
priorityFn: e
|
|
1252
1241
|
},
|
|
1253
1242
|
ports: {
|
|
1254
|
-
centerFn: ((
|
|
1255
|
-
direction: ((
|
|
1243
|
+
centerFn: ((n = r.ports) == null ? void 0 : n.centerFn) ?? H,
|
|
1244
|
+
direction: ((h = r.ports) == null ? void 0 : h.direction) ?? 0
|
|
1256
1245
|
},
|
|
1257
1246
|
edges: {
|
|
1258
|
-
shapeFactory:
|
|
1259
|
-
priorityFn:
|
|
1247
|
+
shapeFactory: z(((c = r.edges) == null ? void 0 : c.shape) ?? {}),
|
|
1248
|
+
priorityFn: t
|
|
1260
1249
|
}
|
|
1261
1250
|
};
|
|
1262
1251
|
};
|
|
1263
|
-
class
|
|
1264
|
-
constructor(
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
this.apiOptions =
|
|
1270
|
-
const
|
|
1271
|
-
this.di = new
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
), this.transformation = this.di.publicViewportTransformer, this.model = this.di.publicGraphStore, this.edgeShapeFactory =
|
|
1279
|
-
}
|
|
1280
|
-
addNode(
|
|
1252
|
+
class Pe {
|
|
1253
|
+
constructor(e) {
|
|
1254
|
+
a(this, "transformation");
|
|
1255
|
+
a(this, "model");
|
|
1256
|
+
a(this, "di");
|
|
1257
|
+
a(this, "edgeShapeFactory");
|
|
1258
|
+
this.apiOptions = e;
|
|
1259
|
+
const t = Se(this.apiOptions ?? {});
|
|
1260
|
+
this.di = new ve(
|
|
1261
|
+
t.background.drawingFn,
|
|
1262
|
+
t.nodes.centerFn,
|
|
1263
|
+
t.ports.centerFn,
|
|
1264
|
+
t.ports.direction,
|
|
1265
|
+
t.nodes.priorityFn,
|
|
1266
|
+
t.edges.priorityFn
|
|
1267
|
+
), this.transformation = this.di.publicViewportTransformer, this.model = this.di.publicGraphStore, this.edgeShapeFactory = t.edges.shapeFactory;
|
|
1268
|
+
}
|
|
1269
|
+
addNode(e) {
|
|
1281
1270
|
return this.di.canvasController.addNode(
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1271
|
+
e.id,
|
|
1272
|
+
e.element,
|
|
1273
|
+
e.x,
|
|
1274
|
+
e.y,
|
|
1275
|
+
e.ports,
|
|
1276
|
+
e.centerFn,
|
|
1277
|
+
e.priority
|
|
1289
1278
|
), this;
|
|
1290
1279
|
}
|
|
1291
|
-
updateNode(
|
|
1280
|
+
updateNode(e, t) {
|
|
1292
1281
|
return this.di.canvasController.updateNode(
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1282
|
+
e,
|
|
1283
|
+
t.x,
|
|
1284
|
+
t.y,
|
|
1285
|
+
t.priority,
|
|
1286
|
+
t.centerFn
|
|
1298
1287
|
), this;
|
|
1299
1288
|
}
|
|
1300
|
-
removeNode(
|
|
1301
|
-
return this.di.canvasController.removeNode(
|
|
1289
|
+
removeNode(e) {
|
|
1290
|
+
return this.di.canvasController.removeNode(e), this;
|
|
1302
1291
|
}
|
|
1303
|
-
markPort(
|
|
1292
|
+
markPort(e) {
|
|
1304
1293
|
return this.di.canvasController.markPort(
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1294
|
+
e.id,
|
|
1295
|
+
e.element,
|
|
1296
|
+
e.nodeId,
|
|
1297
|
+
e.centerFn,
|
|
1298
|
+
e.direction
|
|
1310
1299
|
), this;
|
|
1311
1300
|
}
|
|
1312
|
-
updatePort(
|
|
1301
|
+
updatePort(e, t) {
|
|
1313
1302
|
return this.di.canvasController.updatePort(
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1303
|
+
e,
|
|
1304
|
+
t == null ? void 0 : t.direction,
|
|
1305
|
+
t == null ? void 0 : t.centerFn
|
|
1317
1306
|
), this;
|
|
1318
1307
|
}
|
|
1319
|
-
unmarkPort(
|
|
1320
|
-
return this.di.canvasController.unmarkPort(
|
|
1308
|
+
unmarkPort(e) {
|
|
1309
|
+
return this.di.canvasController.unmarkPort(e), this;
|
|
1321
1310
|
}
|
|
1322
|
-
addEdge(
|
|
1323
|
-
const
|
|
1311
|
+
addEdge(e) {
|
|
1312
|
+
const t = e.shape !== void 0 ? z(e.shape) : this.edgeShapeFactory;
|
|
1324
1313
|
return this.di.canvasController.addEdge(
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1314
|
+
e.id,
|
|
1315
|
+
e.from,
|
|
1316
|
+
e.to,
|
|
1317
|
+
t,
|
|
1318
|
+
e.priority
|
|
1330
1319
|
), this;
|
|
1331
1320
|
}
|
|
1332
|
-
updateEdge(
|
|
1333
|
-
const s =
|
|
1334
|
-
return this.di.canvasController.updateEdge(
|
|
1321
|
+
updateEdge(e, t) {
|
|
1322
|
+
const s = t.shape !== void 0 ? z(t.shape) : void 0;
|
|
1323
|
+
return this.di.canvasController.updateEdge(e, s, t.priority), this;
|
|
1335
1324
|
}
|
|
1336
|
-
removeEdge(
|
|
1337
|
-
return this.di.canvasController.removeEdge(
|
|
1325
|
+
removeEdge(e) {
|
|
1326
|
+
return this.di.canvasController.removeEdge(e), this;
|
|
1338
1327
|
}
|
|
1339
|
-
patchViewportMatrix(
|
|
1328
|
+
patchViewportMatrix(e) {
|
|
1340
1329
|
return this.di.canvasController.patchViewportMatrix(
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1330
|
+
e.scale ?? null,
|
|
1331
|
+
e.dx ?? null,
|
|
1332
|
+
e.dy ?? null
|
|
1344
1333
|
), this;
|
|
1345
1334
|
}
|
|
1346
|
-
patchContentMatrix(
|
|
1335
|
+
patchContentMatrix(e) {
|
|
1347
1336
|
return this.di.canvasController.patchContentMatrix(
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1337
|
+
e.scale ?? null,
|
|
1338
|
+
e.dx ?? null,
|
|
1339
|
+
e.dy ?? null
|
|
1351
1340
|
), this;
|
|
1352
1341
|
}
|
|
1353
1342
|
clear() {
|
|
1354
1343
|
return this.di.canvasController.clear(), this;
|
|
1355
1344
|
}
|
|
1356
|
-
attach(
|
|
1357
|
-
return this.di.canvasController.attach(
|
|
1345
|
+
attach(e) {
|
|
1346
|
+
return this.di.canvasController.attach(e), this;
|
|
1358
1347
|
}
|
|
1359
1348
|
detach() {
|
|
1360
1349
|
return this.di.canvasController.detach(), this;
|
|
@@ -1363,178 +1352,178 @@ class Lt {
|
|
|
1363
1352
|
this.di.canvasController.destroy();
|
|
1364
1353
|
}
|
|
1365
1354
|
}
|
|
1366
|
-
const
|
|
1367
|
-
const { x: s, y: o, width: i, height:
|
|
1368
|
-
return
|
|
1369
|
-
},
|
|
1370
|
-
|
|
1355
|
+
const O = (r, e, t) => {
|
|
1356
|
+
const { x: s, y: o, width: i, height: n } = r.getBoundingClientRect();
|
|
1357
|
+
return e >= s && e < s + i && t >= o && t <= o + n;
|
|
1358
|
+
}, V = (r, e, t) => e >= 0 && e < r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e) => {
|
|
1359
|
+
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
1371
1360
|
};
|
|
1372
|
-
class
|
|
1373
|
-
constructor(
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
(
|
|
1361
|
+
class Me {
|
|
1362
|
+
constructor(e, t) {
|
|
1363
|
+
a(this, "model");
|
|
1364
|
+
a(this, "transformation");
|
|
1365
|
+
a(this, "maxNodePriority", 0);
|
|
1366
|
+
a(this, "nodes", /* @__PURE__ */ new Map());
|
|
1367
|
+
a(this, "grabbedNodeId", null);
|
|
1368
|
+
a(this, "onNodeDrag");
|
|
1369
|
+
a(this, "onBeforeNodeDrag");
|
|
1370
|
+
a(this, "nodeIdGenerator", new W(
|
|
1371
|
+
(e) => this.nodes.has(e)
|
|
1383
1372
|
));
|
|
1384
|
-
|
|
1385
|
-
|
|
1373
|
+
a(this, "element", null);
|
|
1374
|
+
a(this, "onCanvasMouseUp", () => {
|
|
1386
1375
|
this.cancelMouseDrag();
|
|
1387
1376
|
});
|
|
1388
|
-
|
|
1389
|
-
if (this.element !== null && (!
|
|
1377
|
+
a(this, "onCanvasMouseMove", (e) => {
|
|
1378
|
+
if (this.element !== null && (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY))) {
|
|
1390
1379
|
this.cancelMouseDrag();
|
|
1391
1380
|
return;
|
|
1392
1381
|
}
|
|
1393
|
-
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId,
|
|
1382
|
+
this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
|
|
1394
1383
|
});
|
|
1395
|
-
|
|
1384
|
+
a(this, "onCanvasTouchStart", (e) => {
|
|
1396
1385
|
this.previousTouchCoords = [
|
|
1397
|
-
|
|
1398
|
-
|
|
1386
|
+
e.touches[0].clientX,
|
|
1387
|
+
e.touches[0].clientY
|
|
1399
1388
|
];
|
|
1400
1389
|
});
|
|
1401
|
-
|
|
1402
|
-
if (
|
|
1403
|
-
const
|
|
1404
|
-
if (this.element !== null && (!
|
|
1390
|
+
a(this, "onCanvasTouchMove", (e) => {
|
|
1391
|
+
if (e.touches.length === 1) {
|
|
1392
|
+
const t = e.touches[0];
|
|
1393
|
+
if (this.element !== null && (!O(this.element, t.clientX, t.clientY) || !V(this.window, t.clientX, t.clientY))) {
|
|
1405
1394
|
this.cancelTouchDrag();
|
|
1406
1395
|
return;
|
|
1407
1396
|
}
|
|
1408
1397
|
if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
|
|
1409
|
-
|
|
1410
|
-
const s =
|
|
1398
|
+
e.stopImmediatePropagation();
|
|
1399
|
+
const s = t.clientX - this.previousTouchCoords[0], o = t.clientY - this.previousTouchCoords[1];
|
|
1411
1400
|
this.dragNode(this.grabbedNodeId, s, o), this.previousTouchCoords = [
|
|
1412
|
-
|
|
1413
|
-
|
|
1401
|
+
e.touches[0].clientX,
|
|
1402
|
+
e.touches[0].clientY
|
|
1414
1403
|
];
|
|
1415
1404
|
}
|
|
1416
1405
|
}
|
|
1417
1406
|
});
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1407
|
+
a(this, "onCanvasTouchEnd", (e) => {
|
|
1408
|
+
e.touches.length > 0 ? this.previousTouchCoords = [
|
|
1409
|
+
e.touches[0].clientX,
|
|
1410
|
+
e.touches[0].clientY
|
|
1422
1411
|
] : this.cancelTouchDrag();
|
|
1423
1412
|
});
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
var i,
|
|
1429
|
-
this.canvas =
|
|
1413
|
+
a(this, "previousTouchCoords", null);
|
|
1414
|
+
a(this, "freezePriority");
|
|
1415
|
+
a(this, "window", window);
|
|
1416
|
+
a(this, "dragCursor");
|
|
1417
|
+
var i, n;
|
|
1418
|
+
this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model;
|
|
1430
1419
|
const s = () => {
|
|
1431
1420
|
};
|
|
1432
|
-
this.onNodeDrag = ((i =
|
|
1421
|
+
this.onNodeDrag = ((i = t == null ? void 0 : t.events) == null ? void 0 : i.onNodeDrag) ?? s;
|
|
1433
1422
|
const o = () => !0;
|
|
1434
|
-
this.onBeforeNodeDrag = ((
|
|
1423
|
+
this.onBeforeNodeDrag = ((n = t == null ? void 0 : t.events) == null ? void 0 : n.onBeforeNodeDrag) ?? o, this.freezePriority = (t == null ? void 0 : t.grabPriorityStrategy) === "freeze", this.dragCursor = (t == null ? void 0 : t.dragCursor) !== void 0 ? t.dragCursor : "grab";
|
|
1435
1424
|
}
|
|
1436
|
-
addNode(
|
|
1437
|
-
const
|
|
1438
|
-
this.canvas.addNode({ ...
|
|
1425
|
+
addNode(e) {
|
|
1426
|
+
const t = this.nodeIdGenerator.create(e.id);
|
|
1427
|
+
this.canvas.addNode({ ...e, id: t }), this.updateMaxNodePriority(t);
|
|
1439
1428
|
const s = (i) => {
|
|
1440
1429
|
if (this.element === null)
|
|
1441
1430
|
return;
|
|
1442
|
-
const
|
|
1431
|
+
const n = this.model.getNode(t);
|
|
1443
1432
|
this.onBeforeNodeDrag({
|
|
1444
|
-
nodeId:
|
|
1445
|
-
element:
|
|
1446
|
-
x:
|
|
1447
|
-
y:
|
|
1448
|
-
}) && (i.stopImmediatePropagation(), this.grabbedNodeId =
|
|
1433
|
+
nodeId: t,
|
|
1434
|
+
element: e.element,
|
|
1435
|
+
x: n.x,
|
|
1436
|
+
y: n.y
|
|
1437
|
+
}) && (i.stopImmediatePropagation(), this.grabbedNodeId = t, R(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
|
|
1449
1438
|
}, o = (i) => {
|
|
1450
|
-
const
|
|
1439
|
+
const n = this.model.getNode(t);
|
|
1451
1440
|
this.onBeforeNodeDrag({
|
|
1452
|
-
nodeId:
|
|
1453
|
-
element:
|
|
1454
|
-
x:
|
|
1455
|
-
y:
|
|
1456
|
-
}) && i.touches.length === 1 && (this.grabbedNodeId =
|
|
1441
|
+
nodeId: t,
|
|
1442
|
+
element: e.element,
|
|
1443
|
+
x: n.x,
|
|
1444
|
+
y: n.y
|
|
1445
|
+
}) && i.touches.length === 1 && (this.grabbedNodeId = t, this.moveNodeOnTop(t), this.window.addEventListener("touchmove", this.onCanvasTouchMove), this.window.addEventListener("touchend", this.onCanvasTouchEnd), this.window.addEventListener("touchcancel", this.onCanvasTouchEnd));
|
|
1457
1446
|
};
|
|
1458
|
-
return this.nodes.set(
|
|
1459
|
-
element:
|
|
1447
|
+
return this.nodes.set(t, {
|
|
1448
|
+
element: e.element,
|
|
1460
1449
|
onMouseDown: s,
|
|
1461
1450
|
onTouchStart: o
|
|
1462
|
-
}),
|
|
1451
|
+
}), e.element.addEventListener("mousedown", s), e.element.addEventListener("touchstart", o), this;
|
|
1463
1452
|
}
|
|
1464
|
-
updateNode(
|
|
1465
|
-
return this.canvas.updateNode(
|
|
1453
|
+
updateNode(e, t) {
|
|
1454
|
+
return this.canvas.updateNode(e, t), this.updateMaxNodePriority(e), this;
|
|
1466
1455
|
}
|
|
1467
|
-
removeNode(
|
|
1468
|
-
const
|
|
1469
|
-
return
|
|
1456
|
+
removeNode(e) {
|
|
1457
|
+
const t = this.nodes.get(e);
|
|
1458
|
+
return t !== void 0 && (t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart)), this.canvas.removeNode(e), this.nodes.delete(e), this;
|
|
1470
1459
|
}
|
|
1471
|
-
markPort(
|
|
1472
|
-
return this.canvas.markPort(
|
|
1460
|
+
markPort(e) {
|
|
1461
|
+
return this.canvas.markPort(e), this;
|
|
1473
1462
|
}
|
|
1474
|
-
updatePort(
|
|
1475
|
-
return this.canvas.updatePort(
|
|
1463
|
+
updatePort(e, t) {
|
|
1464
|
+
return this.canvas.updatePort(e, t), this;
|
|
1476
1465
|
}
|
|
1477
|
-
unmarkPort(
|
|
1478
|
-
return this.canvas.unmarkPort(
|
|
1466
|
+
unmarkPort(e) {
|
|
1467
|
+
return this.canvas.unmarkPort(e), this;
|
|
1479
1468
|
}
|
|
1480
|
-
addEdge(
|
|
1481
|
-
return this.canvas.addEdge(
|
|
1469
|
+
addEdge(e) {
|
|
1470
|
+
return this.canvas.addEdge(e), this;
|
|
1482
1471
|
}
|
|
1483
|
-
updateEdge(
|
|
1484
|
-
return this.canvas.updateEdge(
|
|
1472
|
+
updateEdge(e, t) {
|
|
1473
|
+
return this.canvas.updateEdge(e, t), this;
|
|
1485
1474
|
}
|
|
1486
|
-
removeEdge(
|
|
1487
|
-
return this.canvas.removeEdge(
|
|
1475
|
+
removeEdge(e) {
|
|
1476
|
+
return this.canvas.removeEdge(e), this;
|
|
1488
1477
|
}
|
|
1489
|
-
patchViewportMatrix(
|
|
1490
|
-
return this.canvas.patchViewportMatrix(
|
|
1478
|
+
patchViewportMatrix(e) {
|
|
1479
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1491
1480
|
}
|
|
1492
|
-
patchContentMatrix(
|
|
1493
|
-
return this.canvas.patchContentMatrix(
|
|
1481
|
+
patchContentMatrix(e) {
|
|
1482
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1494
1483
|
}
|
|
1495
1484
|
clear() {
|
|
1496
|
-
return this.canvas.clear(), this.nodes.forEach((
|
|
1497
|
-
|
|
1485
|
+
return this.canvas.clear(), this.nodes.forEach((e) => {
|
|
1486
|
+
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
1498
1487
|
}), this.nodes.clear(), this.maxNodePriority = 0, this;
|
|
1499
1488
|
}
|
|
1500
|
-
attach(
|
|
1501
|
-
return this.detach(), this.element =
|
|
1489
|
+
attach(e) {
|
|
1490
|
+
return this.detach(), this.element = e, this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.canvas.attach(this.element), this;
|
|
1502
1491
|
}
|
|
1503
1492
|
detach() {
|
|
1504
1493
|
return this.canvas.detach(), this.element !== null && (this.element.removeEventListener("touchstart", this.onCanvasTouchStart), this.element = null), this;
|
|
1505
1494
|
}
|
|
1506
1495
|
destroy() {
|
|
1507
|
-
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.nodes.forEach((
|
|
1508
|
-
|
|
1496
|
+
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.nodes.forEach((e) => {
|
|
1497
|
+
e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
|
|
1509
1498
|
}), this.nodes.clear(), this.canvas.destroy();
|
|
1510
1499
|
}
|
|
1511
|
-
dragNode(
|
|
1512
|
-
const o = this.model.getNode(
|
|
1500
|
+
dragNode(e, t, s) {
|
|
1501
|
+
const o = this.model.getNode(e);
|
|
1513
1502
|
if (o === null)
|
|
1514
|
-
throw new
|
|
1515
|
-
const i = this.canvas.transformation.getContentMatrix(),
|
|
1516
|
-
this.canvas.updateNode(
|
|
1517
|
-
nodeId:
|
|
1503
|
+
throw new f("failed to drag nonexisting node");
|
|
1504
|
+
const i = this.canvas.transformation.getContentMatrix(), n = i.scale * o.x + i.dx, h = i.scale * o.y + i.dy, c = n + t, d = h + s, u = this.canvas.transformation.getViewportMatrix(), w = u.scale * c + u.dx, m = u.scale * d + u.dy;
|
|
1505
|
+
this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
|
|
1506
|
+
nodeId: e,
|
|
1518
1507
|
element: o.element,
|
|
1519
1508
|
x: o.x,
|
|
1520
1509
|
y: o.y
|
|
1521
1510
|
});
|
|
1522
1511
|
}
|
|
1523
|
-
updateMaxNodePriority(
|
|
1524
|
-
const
|
|
1525
|
-
this.maxNodePriority = Math.max(this.maxNodePriority,
|
|
1512
|
+
updateMaxNodePriority(e) {
|
|
1513
|
+
const t = this.model.getNode(e).priority;
|
|
1514
|
+
this.maxNodePriority = Math.max(this.maxNodePriority, t);
|
|
1526
1515
|
}
|
|
1527
|
-
moveNodeOnTop(
|
|
1516
|
+
moveNodeOnTop(e) {
|
|
1528
1517
|
if (this.freezePriority)
|
|
1529
1518
|
return;
|
|
1530
|
-
this.maxNodePriority += 2, this.updateNode(
|
|
1531
|
-
const
|
|
1532
|
-
this.model.getNodeAdjacentEdgeIds(
|
|
1533
|
-
this.updateEdge(o, { priority:
|
|
1519
|
+
this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
|
|
1520
|
+
const t = this.maxNodePriority - 1;
|
|
1521
|
+
this.model.getNodeAdjacentEdgeIds(e).forEach((o) => {
|
|
1522
|
+
this.updateEdge(o, { priority: t });
|
|
1534
1523
|
});
|
|
1535
1524
|
}
|
|
1536
1525
|
cancelMouseDrag() {
|
|
1537
|
-
this.grabbedNodeId = null, this.element !== null &&
|
|
1526
|
+
this.grabbedNodeId = null, this.element !== null && R(this.element, null), this.removeMouseDragListeners();
|
|
1538
1527
|
}
|
|
1539
1528
|
removeMouseDragListeners() {
|
|
1540
1529
|
this.window.removeEventListener("mouseup", this.onCanvasMouseUp), this.window.removeEventListener("mousemove", this.onCanvasMouseMove);
|
|
@@ -1546,159 +1535,159 @@ class $t {
|
|
|
1546
1535
|
this.window.removeEventListener("touchmove", this.onCanvasTouchMove), this.window.removeEventListener("touchend", this.onCanvasTouchEnd), this.window.removeEventListener("touchcancel", this.onCanvasTouchEnd);
|
|
1547
1536
|
}
|
|
1548
1537
|
}
|
|
1549
|
-
const
|
|
1550
|
-
},
|
|
1551
|
-
const
|
|
1552
|
-
return (o, i) => s !== null && i.scale > s && i.scale > o.scale ||
|
|
1553
|
-
},
|
|
1554
|
-
let
|
|
1555
|
-
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
const
|
|
1559
|
-
return s !== null && d > s -
|
|
1560
|
-
},
|
|
1561
|
-
switch (
|
|
1538
|
+
const Ne = () => {
|
|
1539
|
+
}, Le = (r, e) => e, be = (r, e) => {
|
|
1540
|
+
const t = e !== null ? 1 / e : null, s = r !== null ? 1 / r : null;
|
|
1541
|
+
return (o, i) => s !== null && i.scale > s && i.scale > o.scale || t !== null && i.scale < t && i.scale < o.scale ? o : i;
|
|
1542
|
+
}, Te = (r, e, t, s) => (o, i, n, h) => {
|
|
1543
|
+
let c = i.dx, d = i.dy;
|
|
1544
|
+
r !== null && c < r && c < o.dx && (c = o.dx);
|
|
1545
|
+
const u = n * o.scale;
|
|
1546
|
+
e !== null && c > e - u && c > o.dx && (c = o.dx), t !== null && d < t && d < o.dy && (d = o.dy);
|
|
1547
|
+
const w = h * o.scale;
|
|
1548
|
+
return s !== null && d > s - w && d > o.dy && (d = o.dy), { scale: i.scale, dx: c, dy: d };
|
|
1549
|
+
}, K = (r) => {
|
|
1550
|
+
switch (r.type) {
|
|
1562
1551
|
case "scale-limit":
|
|
1563
|
-
return
|
|
1564
|
-
|
|
1565
|
-
|
|
1552
|
+
return be(
|
|
1553
|
+
r.minContentScale ?? null,
|
|
1554
|
+
r.maxContentScale ?? null
|
|
1566
1555
|
);
|
|
1567
1556
|
case "shift-limit":
|
|
1568
|
-
return
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1557
|
+
return Te(
|
|
1558
|
+
r.minX ?? null,
|
|
1559
|
+
r.maxX ?? null,
|
|
1560
|
+
r.minY ?? null,
|
|
1561
|
+
r.maxY ?? null
|
|
1573
1562
|
);
|
|
1574
1563
|
default:
|
|
1575
|
-
return
|
|
1564
|
+
return r.preprocessorFn;
|
|
1576
1565
|
}
|
|
1577
|
-
},
|
|
1578
|
-
(i,
|
|
1579
|
-
|
|
1566
|
+
}, $e = (r) => (e, t, s, o) => r.reduce(
|
|
1567
|
+
(i, n) => n(e, i, s, o),
|
|
1568
|
+
t
|
|
1580
1569
|
);
|
|
1581
|
-
class
|
|
1582
|
-
constructor(
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
this.element !== null && (
|
|
1570
|
+
class De {
|
|
1571
|
+
constructor(e, t) {
|
|
1572
|
+
a(this, "model");
|
|
1573
|
+
a(this, "transformation");
|
|
1574
|
+
a(this, "element", null);
|
|
1575
|
+
a(this, "prevTouches", null);
|
|
1576
|
+
a(this, "onTransformFinished");
|
|
1577
|
+
a(this, "transformPreprocessor");
|
|
1578
|
+
a(this, "isScalable");
|
|
1579
|
+
a(this, "isShiftable");
|
|
1580
|
+
a(this, "wheelSensitivity");
|
|
1581
|
+
a(this, "window", window);
|
|
1582
|
+
a(this, "onMouseDown", () => {
|
|
1583
|
+
this.element !== null && (R(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
|
|
1595
1584
|
});
|
|
1596
|
-
|
|
1585
|
+
a(this, "onMouseMove", (e) => {
|
|
1597
1586
|
if (!this.isShiftable || this.element === null)
|
|
1598
1587
|
return;
|
|
1599
|
-
if (!
|
|
1588
|
+
if (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY)) {
|
|
1600
1589
|
this.stopMouseDrag();
|
|
1601
1590
|
return;
|
|
1602
1591
|
}
|
|
1603
|
-
const
|
|
1604
|
-
this.moveViewport(
|
|
1592
|
+
const t = -e.movementX, s = -e.movementY;
|
|
1593
|
+
this.moveViewport(t, s);
|
|
1605
1594
|
});
|
|
1606
|
-
|
|
1595
|
+
a(this, "onMouseUp", () => {
|
|
1607
1596
|
this.stopMouseDrag();
|
|
1608
1597
|
});
|
|
1609
|
-
|
|
1598
|
+
a(this, "onWheelScroll", (e) => {
|
|
1610
1599
|
if (this.element === null || this.isScalable === !1)
|
|
1611
1600
|
return;
|
|
1612
|
-
|
|
1613
|
-
const { left:
|
|
1614
|
-
this.scaleViewport(
|
|
1601
|
+
e.preventDefault();
|
|
1602
|
+
const { left: t, top: s } = this.element.getBoundingClientRect(), o = e.clientX - t, i = e.clientY - s, h = 1 / (e.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
|
|
1603
|
+
this.scaleViewport(h, o, i);
|
|
1615
1604
|
});
|
|
1616
|
-
|
|
1617
|
-
this.prevTouches = this.getAverageTouch(
|
|
1605
|
+
a(this, "onTouchStart", (e) => {
|
|
1606
|
+
this.prevTouches = this.getAverageTouch(e), this.window.addEventListener("touchmove", this.onTouchMove), this.window.addEventListener("touchend", this.onTouchEnd), this.window.addEventListener("touchcancel", this.onTouchEnd);
|
|
1618
1607
|
});
|
|
1619
|
-
|
|
1608
|
+
a(this, "onTouchMove", (e) => {
|
|
1620
1609
|
if (this.prevTouches === null || !this.isShiftable || this.element === null)
|
|
1621
1610
|
return;
|
|
1622
|
-
const
|
|
1623
|
-
if (!
|
|
1624
|
-
(o) =>
|
|
1611
|
+
const t = this.getAverageTouch(e);
|
|
1612
|
+
if (!t.touches.every(
|
|
1613
|
+
(o) => O(this.element, o[0], o[1]) && V(this.window, o[0], o[1])
|
|
1625
1614
|
)) {
|
|
1626
1615
|
this.stopTouchDrag();
|
|
1627
1616
|
return;
|
|
1628
1617
|
}
|
|
1629
|
-
if ((
|
|
1630
|
-
-(
|
|
1631
|
-
-(
|
|
1632
|
-
),
|
|
1633
|
-
const { left: o, top: i } = this.element.getBoundingClientRect(),
|
|
1634
|
-
this.scaleViewport(d,
|
|
1618
|
+
if ((t.touchesCnt === 1 || t.touchesCnt === 2) && this.moveViewport(
|
|
1619
|
+
-(t.x - this.prevTouches.x),
|
|
1620
|
+
-(t.y - this.prevTouches.y)
|
|
1621
|
+
), t.touchesCnt === 2 && this.isScalable) {
|
|
1622
|
+
const { left: o, top: i } = this.element.getBoundingClientRect(), n = this.prevTouches.x - o, h = this.prevTouches.y - i, d = 1 / (t.scale / this.prevTouches.scale);
|
|
1623
|
+
this.scaleViewport(d, n, h);
|
|
1635
1624
|
}
|
|
1636
|
-
this.prevTouches =
|
|
1625
|
+
this.prevTouches = t;
|
|
1637
1626
|
});
|
|
1638
|
-
|
|
1639
|
-
|
|
1627
|
+
a(this, "onTouchEnd", (e) => {
|
|
1628
|
+
e.touches.length > 0 ? this.prevTouches = this.getAverageTouch(e) : this.stopTouchDrag();
|
|
1640
1629
|
});
|
|
1641
|
-
|
|
1630
|
+
a(this, "observer", new ResizeObserver(() => {
|
|
1642
1631
|
if (this.element !== null) {
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1632
|
+
const e = this.canvas.transformation.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), o = this.transformPreprocessor(
|
|
1633
|
+
e,
|
|
1634
|
+
e,
|
|
1645
1635
|
t,
|
|
1646
|
-
r,
|
|
1647
1636
|
s
|
|
1648
1637
|
);
|
|
1649
1638
|
this.canvas.patchViewportMatrix(o), this.onTransformFinished(o);
|
|
1650
1639
|
}
|
|
1651
1640
|
}));
|
|
1652
|
-
|
|
1653
|
-
var i, h, c,
|
|
1654
|
-
this.canvas =
|
|
1655
|
-
const s = (
|
|
1656
|
-
this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((
|
|
1657
|
-
const o =
|
|
1658
|
-
o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor =
|
|
1641
|
+
a(this, "shiftCursor");
|
|
1642
|
+
var i, n, h, c, d, u, w, m;
|
|
1643
|
+
this.canvas = e, this.options = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.isScalable = ((n = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : n.enabled) !== !1, this.isShiftable = ((c = (h = this.options) == null ? void 0 : h.shift) == null ? void 0 : c.enabled) !== !1;
|
|
1644
|
+
const s = (u = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : u.wheelSensitivity;
|
|
1645
|
+
this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((w = t == null ? void 0 : t.events) == null ? void 0 : w.onTransformFinished) ?? Ne;
|
|
1646
|
+
const o = t == null ? void 0 : t.transformPreprocessor;
|
|
1647
|
+
o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = $e(
|
|
1659
1648
|
o.map(
|
|
1660
|
-
(
|
|
1649
|
+
(y) => K(y)
|
|
1661
1650
|
)
|
|
1662
|
-
) : this.transformPreprocessor =
|
|
1651
|
+
) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Le, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
|
|
1663
1652
|
}
|
|
1664
|
-
addNode(
|
|
1665
|
-
return this.canvas.addNode(
|
|
1653
|
+
addNode(e) {
|
|
1654
|
+
return this.canvas.addNode(e), this;
|
|
1666
1655
|
}
|
|
1667
|
-
updateNode(
|
|
1668
|
-
return this.canvas.updateNode(
|
|
1656
|
+
updateNode(e, t) {
|
|
1657
|
+
return this.canvas.updateNode(e, t), this;
|
|
1669
1658
|
}
|
|
1670
|
-
removeNode(
|
|
1671
|
-
return this.canvas.removeNode(
|
|
1659
|
+
removeNode(e) {
|
|
1660
|
+
return this.canvas.removeNode(e), this;
|
|
1672
1661
|
}
|
|
1673
|
-
markPort(
|
|
1674
|
-
return this.canvas.markPort(
|
|
1662
|
+
markPort(e) {
|
|
1663
|
+
return this.canvas.markPort(e), this;
|
|
1675
1664
|
}
|
|
1676
|
-
updatePort(
|
|
1677
|
-
return this.canvas.updatePort(
|
|
1665
|
+
updatePort(e, t) {
|
|
1666
|
+
return this.canvas.updatePort(e, t), this;
|
|
1678
1667
|
}
|
|
1679
|
-
unmarkPort(
|
|
1680
|
-
return this.canvas.unmarkPort(
|
|
1668
|
+
unmarkPort(e) {
|
|
1669
|
+
return this.canvas.unmarkPort(e), this;
|
|
1681
1670
|
}
|
|
1682
|
-
addEdge(
|
|
1683
|
-
return this.canvas.addEdge(
|
|
1671
|
+
addEdge(e) {
|
|
1672
|
+
return this.canvas.addEdge(e), this;
|
|
1684
1673
|
}
|
|
1685
|
-
updateEdge(
|
|
1686
|
-
return this.canvas.updateEdge(
|
|
1674
|
+
updateEdge(e, t) {
|
|
1675
|
+
return this.canvas.updateEdge(e, t), this;
|
|
1687
1676
|
}
|
|
1688
|
-
removeEdge(
|
|
1689
|
-
return this.canvas.removeEdge(
|
|
1677
|
+
removeEdge(e) {
|
|
1678
|
+
return this.canvas.removeEdge(e), this;
|
|
1690
1679
|
}
|
|
1691
|
-
patchViewportMatrix(
|
|
1692
|
-
return this.canvas.patchViewportMatrix(
|
|
1680
|
+
patchViewportMatrix(e) {
|
|
1681
|
+
return this.canvas.patchViewportMatrix(e), this;
|
|
1693
1682
|
}
|
|
1694
|
-
patchContentMatrix(
|
|
1695
|
-
return this.canvas.patchContentMatrix(
|
|
1683
|
+
patchContentMatrix(e) {
|
|
1684
|
+
return this.canvas.patchContentMatrix(e), this;
|
|
1696
1685
|
}
|
|
1697
1686
|
clear() {
|
|
1698
1687
|
return this.canvas.clear(), this;
|
|
1699
1688
|
}
|
|
1700
|
-
attach(
|
|
1701
|
-
return this.detach(), this.element =
|
|
1689
|
+
attach(e) {
|
|
1690
|
+
return this.detach(), this.element = e, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
|
|
1702
1691
|
}
|
|
1703
1692
|
detach() {
|
|
1704
1693
|
return 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), this;
|
|
@@ -1706,58 +1695,58 @@ class Rt {
|
|
|
1706
1695
|
destroy() {
|
|
1707
1696
|
this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
|
|
1708
1697
|
}
|
|
1709
|
-
getAverageTouch(
|
|
1710
|
-
const
|
|
1711
|
-
for (let
|
|
1712
|
-
|
|
1713
|
-
const o =
|
|
1714
|
-
(
|
|
1698
|
+
getAverageTouch(e) {
|
|
1699
|
+
const t = [], s = e.touches.length;
|
|
1700
|
+
for (let c = 0; c < s; c++)
|
|
1701
|
+
t.push([e.touches[c].clientX, e.touches[c].clientY]);
|
|
1702
|
+
const o = t.reduce(
|
|
1703
|
+
(c, d) => [c[0] + d[0], c[1] + d[1]],
|
|
1715
1704
|
[0, 0]
|
|
1716
|
-
), i = [o[0] / s, o[1] / s],
|
|
1717
|
-
(
|
|
1705
|
+
), i = [o[0] / s, o[1] / s], h = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
|
|
1706
|
+
(c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
|
|
1718
1707
|
0
|
|
1719
1708
|
);
|
|
1720
1709
|
return {
|
|
1721
1710
|
x: i[0],
|
|
1722
1711
|
y: i[1],
|
|
1723
|
-
scale:
|
|
1712
|
+
scale: h / s,
|
|
1724
1713
|
touchesCnt: s,
|
|
1725
|
-
touches:
|
|
1714
|
+
touches: t
|
|
1726
1715
|
};
|
|
1727
1716
|
}
|
|
1728
|
-
moveViewport(
|
|
1717
|
+
moveViewport(e, t) {
|
|
1729
1718
|
const s = this.transformation.getViewportMatrix(), o = {
|
|
1730
1719
|
scale: s.scale,
|
|
1731
|
-
dx: s.dx + s.scale *
|
|
1732
|
-
dy: s.dy + s.scale *
|
|
1720
|
+
dx: s.dx + s.scale * e,
|
|
1721
|
+
dy: s.dy + s.scale * t
|
|
1733
1722
|
};
|
|
1734
1723
|
if (this.element !== null) {
|
|
1735
|
-
const { width: i, height:
|
|
1724
|
+
const { width: i, height: n } = this.element.getBoundingClientRect(), h = this.transformPreprocessor(
|
|
1736
1725
|
s,
|
|
1737
1726
|
o,
|
|
1738
1727
|
i,
|
|
1739
|
-
|
|
1728
|
+
n
|
|
1740
1729
|
);
|
|
1741
|
-
this.canvas.patchViewportMatrix(
|
|
1730
|
+
this.canvas.patchViewportMatrix(h), this.onTransformFinished(h);
|
|
1742
1731
|
}
|
|
1743
1732
|
}
|
|
1744
|
-
scaleViewport(
|
|
1733
|
+
scaleViewport(e, t, s) {
|
|
1745
1734
|
if (this.element === null)
|
|
1746
1735
|
return;
|
|
1747
1736
|
const o = this.canvas.transformation.getViewportMatrix(), i = {
|
|
1748
|
-
scale: o.scale *
|
|
1749
|
-
dx: o.scale * (1 -
|
|
1750
|
-
dy: o.scale * (1 -
|
|
1751
|
-
}, { width:
|
|
1737
|
+
scale: o.scale * e,
|
|
1738
|
+
dx: o.scale * (1 - e) * t + o.dx,
|
|
1739
|
+
dy: o.scale * (1 - e) * s + o.dy
|
|
1740
|
+
}, { width: n, height: h } = this.element.getBoundingClientRect(), c = this.transformPreprocessor(
|
|
1752
1741
|
o,
|
|
1753
1742
|
i,
|
|
1754
|
-
|
|
1755
|
-
|
|
1743
|
+
n,
|
|
1744
|
+
h
|
|
1756
1745
|
);
|
|
1757
|
-
this.canvas.patchViewportMatrix(
|
|
1746
|
+
this.canvas.patchViewportMatrix(c), this.onTransformFinished(c);
|
|
1758
1747
|
}
|
|
1759
1748
|
stopMouseDrag() {
|
|
1760
|
-
this.element !== null &&
|
|
1749
|
+
this.element !== null && R(this.element, null), this.removeMouseDragListeners();
|
|
1761
1750
|
}
|
|
1762
1751
|
removeMouseDragListeners() {
|
|
1763
1752
|
this.window.removeEventListener("mousemove", this.onMouseMove), this.window.removeEventListener("mouseup", this.onMouseUp);
|
|
@@ -1769,44 +1758,44 @@ class Rt {
|
|
|
1769
1758
|
this.window.removeEventListener("touchmove", this.onTouchMove), this.window.removeEventListener("touchend", this.onTouchEnd), this.window.removeEventListener("touchcancel", this.onTouchEnd);
|
|
1770
1759
|
}
|
|
1771
1760
|
}
|
|
1772
|
-
class
|
|
1761
|
+
class We {
|
|
1773
1762
|
constructor() {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1763
|
+
a(this, "coreOptions");
|
|
1764
|
+
a(this, "dragOptions");
|
|
1765
|
+
a(this, "transformOptions");
|
|
1766
|
+
a(this, "isDraggable", !1);
|
|
1767
|
+
a(this, "isTransformable", !1);
|
|
1779
1768
|
}
|
|
1780
|
-
setOptions(
|
|
1781
|
-
return this.coreOptions =
|
|
1769
|
+
setOptions(e) {
|
|
1770
|
+
return this.coreOptions = e, this;
|
|
1782
1771
|
}
|
|
1783
|
-
setUserDraggableNodes(
|
|
1784
|
-
return this.isDraggable = !0, this.dragOptions =
|
|
1772
|
+
setUserDraggableNodes(e) {
|
|
1773
|
+
return this.isDraggable = !0, this.dragOptions = e, this;
|
|
1785
1774
|
}
|
|
1786
|
-
setUserTransformableCanvas(
|
|
1787
|
-
return this.isTransformable = !0, this.transformOptions =
|
|
1775
|
+
setUserTransformableCanvas(e) {
|
|
1776
|
+
return this.isTransformable = !0, this.transformOptions = e, this;
|
|
1788
1777
|
}
|
|
1789
1778
|
build() {
|
|
1790
|
-
let
|
|
1791
|
-
return this.isDraggable && (
|
|
1779
|
+
let e = new Pe(this.coreOptions);
|
|
1780
|
+
return this.isDraggable && (e = new Me(e, this.dragOptions)), this.isTransformable && (e = new De(e, this.transformOptions)), e;
|
|
1792
1781
|
}
|
|
1793
1782
|
}
|
|
1794
1783
|
export {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1784
|
+
te as BezierEdgeShape,
|
|
1785
|
+
Pe as CanvasCore,
|
|
1786
|
+
ie as CycleCircleEdgeShape,
|
|
1787
|
+
B as CycleSquareEdgeShape,
|
|
1788
|
+
G as DetourStraightEdgeShape,
|
|
1789
|
+
P as EdgeType,
|
|
1790
|
+
se as HorizontalEdgeShape,
|
|
1791
|
+
We as HtmlGraphBuilder,
|
|
1792
|
+
f as HtmlGraphError,
|
|
1793
|
+
re as StraightEdgeShape,
|
|
1794
|
+
Me as UserDraggableNodesCanvas,
|
|
1795
|
+
De as UserTransformableCanvas,
|
|
1796
|
+
oe as VerticalEdgeShape,
|
|
1797
|
+
ae as createBezierEdgeShapeFactory,
|
|
1798
|
+
ce as createHorizontalEdgeShapeFactory,
|
|
1799
|
+
he as createStraightEdgeShareFactory,
|
|
1800
|
+
de as createVerticalEdgeShapeFactory
|
|
1812
1801
|
};
|