@html-graph/html-graph 0.0.58 → 0.0.60
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 +0 -3
- package/dist/main.d.ts +22 -93
- package/dist/main.js +246 -306
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -161,12 +161,6 @@ class ee {
|
|
|
161
161
|
constructor(e) {
|
|
162
162
|
this.graphStore = e;
|
|
163
163
|
}
|
|
164
|
-
getAllNodeIds() {
|
|
165
|
-
return this.graphStore.getAllNodeIds();
|
|
166
|
-
}
|
|
167
|
-
getAllPortIds() {
|
|
168
|
-
return this.graphStore.getAllPortIds();
|
|
169
|
-
}
|
|
170
164
|
getNode(e) {
|
|
171
165
|
const t = this.graphStore.getNode(e);
|
|
172
166
|
return t === void 0 ? null : {
|
|
@@ -177,8 +171,8 @@ class ee {
|
|
|
177
171
|
priority: t.priority
|
|
178
172
|
};
|
|
179
173
|
}
|
|
180
|
-
|
|
181
|
-
return this.graphStore.
|
|
174
|
+
getAllNodeIds() {
|
|
175
|
+
return this.graphStore.getAllNodeIds();
|
|
182
176
|
}
|
|
183
177
|
getPort(e) {
|
|
184
178
|
const t = this.graphStore.getPort(e);
|
|
@@ -188,6 +182,12 @@ class ee {
|
|
|
188
182
|
direction: t.direction
|
|
189
183
|
};
|
|
190
184
|
}
|
|
185
|
+
getAllPortIds() {
|
|
186
|
+
return this.graphStore.getAllPortIds();
|
|
187
|
+
}
|
|
188
|
+
getNodePortIds(e) {
|
|
189
|
+
return this.graphStore.getNodePortIds(e);
|
|
190
|
+
}
|
|
191
191
|
getPortNodeId(e) {
|
|
192
192
|
return this.graphStore.getPortNodeId(e) ?? null;
|
|
193
193
|
}
|
|
@@ -198,12 +198,6 @@ class ee {
|
|
|
198
198
|
const t = this.graphStore.getEdge(e);
|
|
199
199
|
return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
|
|
200
200
|
}
|
|
201
|
-
getPortAdjacentEdgeIds(e) {
|
|
202
|
-
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
203
|
-
}
|
|
204
|
-
getNodeAdjacentEdgeIds(e) {
|
|
205
|
-
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
206
|
-
}
|
|
207
201
|
getPortIncomingEdgeIds(e) {
|
|
208
202
|
return this.graphStore.getPortIncomingEdgeIds(e);
|
|
209
203
|
}
|
|
@@ -213,6 +207,9 @@ class ee {
|
|
|
213
207
|
getPortCycleEdgeIds(e) {
|
|
214
208
|
return this.graphStore.getPortCycleEdgeIds(e);
|
|
215
209
|
}
|
|
210
|
+
getPortAdjacentEdgeIds(e) {
|
|
211
|
+
return this.graphStore.getPortAdjacentEdgeIds(e);
|
|
212
|
+
}
|
|
216
213
|
getNodeIncomingEdgeIds(e) {
|
|
217
214
|
return this.graphStore.getNodeIncomingEdgeIds(e);
|
|
218
215
|
}
|
|
@@ -222,6 +219,9 @@ class ee {
|
|
|
222
219
|
getNodeCycleEdgeIds(e) {
|
|
223
220
|
return this.graphStore.getNodeCycleEdgeIds(e);
|
|
224
221
|
}
|
|
222
|
+
getNodeAdjacentEdgeIds(e) {
|
|
223
|
+
return this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
224
|
+
}
|
|
225
225
|
}
|
|
226
226
|
const l = {
|
|
227
227
|
x: 0,
|
|
@@ -229,14 +229,14 @@ const l = {
|
|
|
229
229
|
}, p = (r, e, t) => ({
|
|
230
230
|
x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
|
|
231
231
|
y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
|
|
232
|
-
}),
|
|
232
|
+
}), f = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), x = (r, e, t, s) => {
|
|
233
233
|
const i = [
|
|
234
234
|
l,
|
|
235
235
|
{ x: t, y: s },
|
|
236
236
|
{ x: t, y: -s }
|
|
237
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
238
|
return `${n} ${h} ${c}`;
|
|
239
|
-
},
|
|
239
|
+
}, D = (r, e) => {
|
|
240
240
|
const t = [];
|
|
241
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
242
|
const s = r.length - 1;
|
|
@@ -248,40 +248,40 @@ const l = {
|
|
|
248
248
|
const j = r[c + 1];
|
|
249
249
|
o = j.x - h.x, i = j.y - h.y, n = Math.sqrt(o * o + i * i);
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
c > 0 && t.push(`L ${
|
|
253
|
-
`C ${h.x} ${h.y} ${h.x} ${h.y} ${
|
|
251
|
+
const P = Math.min((v ? e : 0) / n, c < s - 1 ? 0.5 : 1), M = v ? { x: h.x + o * P, y: h.y + i * P } : h, T = Math.min((v ? e : 0) / w, c > 1 ? 0.5 : 1), W = v ? { x: h.x + d * T, y: h.y + u * T } : h;
|
|
252
|
+
c > 0 && t.push(`L ${W.x} ${W.y}`), v && t.push(
|
|
253
|
+
`C ${h.x} ${h.y} ${h.x} ${h.y} ${M.x} ${M.y}`
|
|
254
254
|
);
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
return t.join(" ");
|
|
258
|
-
},
|
|
258
|
+
}, N = () => {
|
|
259
259
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
260
260
|
return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
|
|
261
261
|
}, $ = () => {
|
|
262
262
|
const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
263
263
|
return r.style.transformOrigin = "50% 50%", r;
|
|
264
|
-
},
|
|
264
|
+
}, L = (r, e) => {
|
|
265
265
|
const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
266
266
|
return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
|
|
267
|
-
},
|
|
267
|
+
}, E = (r) => {
|
|
268
268
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
269
269
|
return e.setAttribute("fill", r), e;
|
|
270
270
|
};
|
|
271
271
|
class te {
|
|
272
272
|
constructor(e, t, s, o, i, n, h) {
|
|
273
|
-
a(this, "svg",
|
|
273
|
+
a(this, "svg", N());
|
|
274
274
|
a(this, "group", $());
|
|
275
275
|
a(this, "line");
|
|
276
276
|
a(this, "sourceArrow", null);
|
|
277
277
|
a(this, "targetArrow", null);
|
|
278
|
-
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line =
|
|
278
|
+
this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
279
279
|
}
|
|
280
280
|
update(e, t, s, o, i) {
|
|
281
281
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
282
|
-
const n =
|
|
282
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
|
|
283
283
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
284
|
-
const d =
|
|
284
|
+
const d = x(
|
|
285
285
|
n,
|
|
286
286
|
l,
|
|
287
287
|
this.arrowLength,
|
|
@@ -290,7 +290,7 @@ class te {
|
|
|
290
290
|
this.sourceArrow.setAttribute("d", d);
|
|
291
291
|
}
|
|
292
292
|
if (this.targetArrow) {
|
|
293
|
-
const d =
|
|
293
|
+
const d = x(
|
|
294
294
|
h,
|
|
295
295
|
e,
|
|
296
296
|
-this.arrowLength,
|
|
@@ -320,18 +320,18 @@ class te {
|
|
|
320
320
|
}
|
|
321
321
|
class re {
|
|
322
322
|
constructor(e, t, s, o, i, n, h, c) {
|
|
323
|
-
a(this, "svg",
|
|
323
|
+
a(this, "svg", N());
|
|
324
324
|
a(this, "group", $());
|
|
325
325
|
a(this, "line");
|
|
326
326
|
a(this, "sourceArrow", null);
|
|
327
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 =
|
|
328
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
329
329
|
}
|
|
330
330
|
update(e, t, s, o, i) {
|
|
331
331
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
332
|
-
const n =
|
|
332
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
|
|
333
333
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
334
|
-
const d =
|
|
334
|
+
const d = x(
|
|
335
335
|
n,
|
|
336
336
|
l,
|
|
337
337
|
this.arrowLength,
|
|
@@ -340,7 +340,7 @@ class re {
|
|
|
340
340
|
this.sourceArrow.setAttribute("d", d);
|
|
341
341
|
}
|
|
342
342
|
if (this.targetArrow) {
|
|
343
|
-
const d =
|
|
343
|
+
const d = x(
|
|
344
344
|
h,
|
|
345
345
|
e,
|
|
346
346
|
-this.arrowLength,
|
|
@@ -351,23 +351,23 @@ class re {
|
|
|
351
351
|
}
|
|
352
352
|
createLinePath(e, t, s) {
|
|
353
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
|
|
354
|
+
return D([o, h, c, i], this.roundness);
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
class se {
|
|
358
358
|
constructor(e, t, s, o, i, n, h, c) {
|
|
359
|
-
a(this, "svg",
|
|
359
|
+
a(this, "svg", N());
|
|
360
360
|
a(this, "group", $());
|
|
361
361
|
a(this, "line");
|
|
362
362
|
a(this, "sourceArrow", null);
|
|
363
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 =
|
|
364
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
365
365
|
}
|
|
366
366
|
update(e, t, s, o, i) {
|
|
367
367
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
368
|
-
const n =
|
|
368
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t);
|
|
369
369
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
370
|
-
const d =
|
|
370
|
+
const d = x(
|
|
371
371
|
n,
|
|
372
372
|
l,
|
|
373
373
|
this.arrowLength,
|
|
@@ -376,7 +376,7 @@ class se {
|
|
|
376
376
|
this.sourceArrow.setAttribute("d", d);
|
|
377
377
|
}
|
|
378
378
|
if (this.targetArrow) {
|
|
379
|
-
const d =
|
|
379
|
+
const d = x(
|
|
380
380
|
h,
|
|
381
381
|
e,
|
|
382
382
|
-this.arrowLength,
|
|
@@ -386,27 +386,27 @@ class se {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
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 },
|
|
390
|
-
return
|
|
391
|
-
[i, d, y, v,
|
|
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 }, S = { x: o > 0 ? e.x - w : e.x + h, y: u.y }, P = { x: S.x, y: m };
|
|
390
|
+
return D(
|
|
391
|
+
[i, d, y, v, P, S, u, n],
|
|
392
392
|
this.roundness
|
|
393
393
|
);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
class oe {
|
|
397
397
|
constructor(e, t, s, o, i, n, h, c) {
|
|
398
|
-
a(this, "svg",
|
|
398
|
+
a(this, "svg", N());
|
|
399
399
|
a(this, "group", $());
|
|
400
400
|
a(this, "line");
|
|
401
401
|
a(this, "sourceArrow", null);
|
|
402
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 =
|
|
403
|
+
this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
404
404
|
}
|
|
405
405
|
update(e, t, s, o, i) {
|
|
406
406
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
407
|
-
const n =
|
|
407
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, s);
|
|
408
408
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
409
|
-
const d =
|
|
409
|
+
const d = x(
|
|
410
410
|
n,
|
|
411
411
|
l,
|
|
412
412
|
this.arrowLength,
|
|
@@ -415,7 +415,7 @@ class oe {
|
|
|
415
415
|
this.sourceArrow.setAttribute("d", d);
|
|
416
416
|
}
|
|
417
417
|
if (this.targetArrow) {
|
|
418
|
-
const d =
|
|
418
|
+
const d = x(
|
|
419
419
|
h,
|
|
420
420
|
e,
|
|
421
421
|
-this.arrowLength,
|
|
@@ -425,28 +425,27 @@ class oe {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
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 },
|
|
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 }, S = {
|
|
429
429
|
x: u.x,
|
|
430
430
|
y: o > 0 ? e.y - w : e.y + h
|
|
431
|
-
},
|
|
432
|
-
return
|
|
433
|
-
[i, d, y, v,
|
|
431
|
+
}, P = { x: m, y: S.y };
|
|
432
|
+
return D(
|
|
433
|
+
[i, d, y, v, P, S, u, n],
|
|
434
434
|
this.roundness
|
|
435
435
|
);
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
class ie {
|
|
439
439
|
constructor(e, t, s, o, i, n, h) {
|
|
440
|
-
a(this, "svg",
|
|
441
|
-
a(this, "group", $());
|
|
440
|
+
a(this, "svg", N());
|
|
442
441
|
a(this, "line");
|
|
443
442
|
a(this, "arrow", null);
|
|
444
|
-
this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.
|
|
443
|
+
this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
|
|
445
444
|
}
|
|
446
445
|
update(e, t, s, o) {
|
|
447
|
-
const i =
|
|
446
|
+
const i = f(o, t, s), n = this.createLinePath(i);
|
|
448
447
|
if (this.line.setAttribute("d", n), this.arrow) {
|
|
449
|
-
const h =
|
|
448
|
+
const h = x(
|
|
450
449
|
i,
|
|
451
450
|
l,
|
|
452
451
|
this.arrowLength,
|
|
@@ -471,13 +470,12 @@ class ie {
|
|
|
471
470
|
}
|
|
472
471
|
class B {
|
|
473
472
|
constructor(e, t, s, o, i, n, h, c) {
|
|
474
|
-
a(this, "svg",
|
|
475
|
-
a(this, "group", $());
|
|
473
|
+
a(this, "svg", N());
|
|
476
474
|
a(this, "line");
|
|
477
475
|
a(this, "arrow", null);
|
|
478
476
|
a(this, "roundness");
|
|
479
477
|
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.
|
|
478
|
+
this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = h, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
|
|
481
479
|
const d = this.minPortOffset, u = this.side, w = this.arrowLength + d, m = w + 2 * u;
|
|
482
480
|
this.linePoints = [
|
|
483
481
|
{ x: this.arrowLength, y: l.y },
|
|
@@ -491,9 +489,9 @@ class B {
|
|
|
491
489
|
];
|
|
492
490
|
}
|
|
493
491
|
update(e, t, s, o) {
|
|
494
|
-
const i =
|
|
492
|
+
const i = f(o, t, s), n = this.createLinePath(i);
|
|
495
493
|
if (this.line.setAttribute("d", n), this.arrow) {
|
|
496
|
-
const h =
|
|
494
|
+
const h = x(
|
|
497
495
|
i,
|
|
498
496
|
l,
|
|
499
497
|
this.arrowLength,
|
|
@@ -506,25 +504,25 @@ class B {
|
|
|
506
504
|
const t = this.linePoints.map(
|
|
507
505
|
(o) => p(o, e, l)
|
|
508
506
|
), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
|
|
509
|
-
return `${this.arrow ? "" : s}${
|
|
507
|
+
return `${this.arrow ? "" : s}${D(t, this.roundness)}`;
|
|
510
508
|
}
|
|
511
509
|
}
|
|
512
|
-
class
|
|
513
|
-
constructor(e, t, s, o, i, n, h, c, d
|
|
514
|
-
a(this, "svg",
|
|
510
|
+
class ne {
|
|
511
|
+
constructor(e, t, s, o, i, n, h, c, d) {
|
|
512
|
+
a(this, "svg", N());
|
|
515
513
|
a(this, "group", $());
|
|
516
514
|
a(this, "line");
|
|
517
515
|
a(this, "sourceArrow", null);
|
|
518
516
|
a(this, "targetArrow", null);
|
|
519
517
|
a(this, "detourX");
|
|
520
518
|
a(this, "detourY");
|
|
521
|
-
this.
|
|
519
|
+
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 = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
522
520
|
}
|
|
523
521
|
update(e, t, s, o, i) {
|
|
524
522
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
525
|
-
const n =
|
|
523
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
|
|
526
524
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
527
|
-
const d =
|
|
525
|
+
const d = x(
|
|
528
526
|
n,
|
|
529
527
|
l,
|
|
530
528
|
this.arrowLength,
|
|
@@ -533,7 +531,7 @@ class G {
|
|
|
533
531
|
this.sourceArrow.setAttribute("d", d);
|
|
534
532
|
}
|
|
535
533
|
if (this.targetArrow) {
|
|
536
|
-
const d =
|
|
534
|
+
const d = x(
|
|
537
535
|
h,
|
|
538
536
|
e,
|
|
539
537
|
-this.arrowLength,
|
|
@@ -543,38 +541,58 @@ class G {
|
|
|
543
541
|
}
|
|
544
542
|
}
|
|
545
543
|
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
|
|
544
|
+
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(
|
|
547
545
|
{ x: c, y: l.y },
|
|
548
546
|
t,
|
|
549
547
|
l
|
|
550
|
-
),
|
|
548
|
+
), m = {
|
|
549
|
+
x: w.x + d,
|
|
550
|
+
y: w.y + u
|
|
551
|
+
}, y = p(
|
|
551
552
|
{ x: e.x - c, y: e.y },
|
|
552
553
|
s,
|
|
553
554
|
e
|
|
554
|
-
), v = {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
555
|
+
), v = {
|
|
556
|
+
x: y.x + d,
|
|
557
|
+
y: y.y + u
|
|
558
|
+
}, S = { x: (m.x + v.x) / 2, y: (m.y + v.y) / 2 }, P = {
|
|
559
|
+
x: w.x + this.curvature * t.x,
|
|
560
|
+
y: w.y + this.curvature * t.y
|
|
561
|
+
}, M = {
|
|
562
|
+
x: y.x - this.curvature * s.x,
|
|
563
|
+
y: y.y - this.curvature * s.y
|
|
564
|
+
}, b = {
|
|
565
|
+
x: w.x + d,
|
|
566
|
+
y: w.y + u
|
|
567
|
+
}, T = {
|
|
568
|
+
x: y.x + d,
|
|
569
|
+
y: y.y + u
|
|
570
|
+
};
|
|
571
|
+
return [
|
|
572
|
+
`M ${n.x} ${n.y}`,
|
|
573
|
+
`L ${w.x} ${w.y}`,
|
|
574
|
+
`C ${P.x} ${P.y} ${b.x} ${b.y} ${S.x} ${S.y}`,
|
|
575
|
+
`C ${T.x} ${T.y} ${M.x} ${M.y} ${y.x} ${y.y}`,
|
|
576
|
+
`L ${h.x} ${h.y}`
|
|
577
|
+
].join(" ");
|
|
559
578
|
}
|
|
560
579
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
a(this, "svg", T());
|
|
580
|
+
class G {
|
|
581
|
+
constructor(e, t, s, o, i, n, h, c, d, u) {
|
|
582
|
+
a(this, "svg", N());
|
|
565
583
|
a(this, "group", $());
|
|
566
584
|
a(this, "line");
|
|
567
585
|
a(this, "sourceArrow", null);
|
|
568
586
|
a(this, "targetArrow", null);
|
|
569
587
|
a(this, "detourX");
|
|
570
588
|
a(this, "detourY");
|
|
571
|
-
this.
|
|
589
|
+
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 = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
|
|
572
590
|
}
|
|
573
591
|
update(e, t, s, o, i) {
|
|
574
592
|
this.group.style.transform = `scale(${t}, ${s})`;
|
|
575
|
-
const n =
|
|
593
|
+
const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
|
|
576
594
|
if (this.line.setAttribute("d", c), this.sourceArrow) {
|
|
577
|
-
const d =
|
|
595
|
+
const d = x(
|
|
578
596
|
n,
|
|
579
597
|
l,
|
|
580
598
|
this.arrowLength,
|
|
@@ -583,7 +601,7 @@ class ne {
|
|
|
583
601
|
this.sourceArrow.setAttribute("d", d);
|
|
584
602
|
}
|
|
585
603
|
if (this.targetArrow) {
|
|
586
|
-
const d =
|
|
604
|
+
const d = x(
|
|
587
605
|
h,
|
|
588
606
|
e,
|
|
589
607
|
-this.arrowLength,
|
|
@@ -593,43 +611,23 @@ class ne {
|
|
|
593
611
|
}
|
|
594
612
|
}
|
|
595
613
|
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
|
|
614
|
+
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(
|
|
597
615
|
{ x: c, y: l.y },
|
|
598
616
|
t,
|
|
599
617
|
l
|
|
600
|
-
), m = {
|
|
601
|
-
x: w.x + d,
|
|
602
|
-
y: w.y + u
|
|
603
|
-
}, y = p(
|
|
618
|
+
), u = this.detourX * o, w = this.detourY * i, m = { x: d.x + u, y: d.y + w }, y = p(
|
|
604
619
|
{ x: e.x - c, y: e.y },
|
|
605
620
|
s,
|
|
606
621
|
e
|
|
607
|
-
), v = {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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(" ");
|
|
622
|
+
), v = { x: y.x + u, y: y.y + w };
|
|
623
|
+
return D(
|
|
624
|
+
[n, d, m, v, y, h],
|
|
625
|
+
this.roundness
|
|
626
|
+
);
|
|
630
627
|
}
|
|
631
628
|
}
|
|
632
|
-
|
|
629
|
+
var A = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(A || {});
|
|
630
|
+
const ae = (r) => (e) => e === A.PortCycle ? new ie(
|
|
633
631
|
r.color,
|
|
634
632
|
r.width,
|
|
635
633
|
r.arrowLength,
|
|
@@ -637,7 +635,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
637
635
|
r.hasSourceArrow || r.hasTargetArrow,
|
|
638
636
|
r.cycleRadius,
|
|
639
637
|
r.smallCycleRadius
|
|
640
|
-
) : e ===
|
|
638
|
+
) : e === A.NodeCycle ? new ne(
|
|
641
639
|
r.color,
|
|
642
640
|
r.width,
|
|
643
641
|
r.curvature,
|
|
@@ -655,7 +653,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
655
653
|
r.arrowWidth,
|
|
656
654
|
r.hasSourceArrow,
|
|
657
655
|
r.hasTargetArrow
|
|
658
|
-
), he = (r) => (e) => e ===
|
|
656
|
+
), he = (r) => (e) => e === A.PortCycle ? new B(
|
|
659
657
|
r.color,
|
|
660
658
|
r.width,
|
|
661
659
|
r.arrowLength,
|
|
@@ -664,7 +662,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
664
662
|
r.cycleSquareSide,
|
|
665
663
|
r.arrowOffset,
|
|
666
664
|
r.roundness
|
|
667
|
-
) : e ===
|
|
665
|
+
) : e === A.NodeCycle ? new G(
|
|
668
666
|
r.color,
|
|
669
667
|
r.width,
|
|
670
668
|
r.arrowLength,
|
|
@@ -684,7 +682,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
684
682
|
r.hasSourceArrow,
|
|
685
683
|
r.hasTargetArrow,
|
|
686
684
|
r.roundness
|
|
687
|
-
), ce = (r) => (e) => e ===
|
|
685
|
+
), ce = (r) => (e) => e === A.PortCycle ? new B(
|
|
688
686
|
r.color,
|
|
689
687
|
r.width,
|
|
690
688
|
r.arrowLength,
|
|
@@ -693,7 +691,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
693
691
|
r.cycleSquareSide,
|
|
694
692
|
r.arrowOffset,
|
|
695
693
|
r.roundness
|
|
696
|
-
) : e ===
|
|
694
|
+
) : e === A.NodeCycle ? new G(
|
|
697
695
|
r.color,
|
|
698
696
|
r.width,
|
|
699
697
|
r.arrowLength,
|
|
@@ -704,7 +702,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
704
702
|
r.roundness,
|
|
705
703
|
r.detourDistance,
|
|
706
704
|
r.detourDirection
|
|
707
|
-
) : new
|
|
705
|
+
) : new oe(
|
|
708
706
|
r.color,
|
|
709
707
|
r.width,
|
|
710
708
|
r.arrowLength,
|
|
@@ -713,7 +711,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
713
711
|
r.hasSourceArrow,
|
|
714
712
|
r.hasTargetArrow,
|
|
715
713
|
r.roundness
|
|
716
|
-
), de = (r) => (e) => e ===
|
|
714
|
+
), de = (r) => (e) => e === A.PortCycle ? new B(
|
|
717
715
|
r.color,
|
|
718
716
|
r.width,
|
|
719
717
|
r.arrowLength,
|
|
@@ -722,7 +720,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
722
720
|
r.cycleSquareSide,
|
|
723
721
|
r.arrowOffset,
|
|
724
722
|
r.roundness
|
|
725
|
-
) : e ===
|
|
723
|
+
) : e === A.NodeCycle ? new G(
|
|
726
724
|
r.color,
|
|
727
725
|
r.width,
|
|
728
726
|
r.arrowLength,
|
|
@@ -733,7 +731,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
733
731
|
r.roundness,
|
|
734
732
|
r.detourDistance,
|
|
735
733
|
r.detourDirection
|
|
736
|
-
) : new
|
|
734
|
+
) : new se(
|
|
737
735
|
r.color,
|
|
738
736
|
r.width,
|
|
739
737
|
r.arrowLength,
|
|
@@ -743,7 +741,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
|
|
|
743
741
|
r.hasTargetArrow,
|
|
744
742
|
r.roundness
|
|
745
743
|
);
|
|
746
|
-
class
|
|
744
|
+
class F {
|
|
747
745
|
constructor(e) {
|
|
748
746
|
a(this, "counter", 0);
|
|
749
747
|
this.checkExists = e;
|
|
@@ -759,7 +757,7 @@ class W {
|
|
|
759
757
|
this.counter = 0;
|
|
760
758
|
}
|
|
761
759
|
}
|
|
762
|
-
class
|
|
760
|
+
class C extends Error {
|
|
763
761
|
constructor() {
|
|
764
762
|
super(...arguments);
|
|
765
763
|
a(this, "name", "HtmlGraphError");
|
|
@@ -767,20 +765,20 @@ class f extends Error {
|
|
|
767
765
|
}
|
|
768
766
|
class le {
|
|
769
767
|
constructor(e, t, s, o, i, n, h, c) {
|
|
770
|
-
a(this, "nodeIdGenerator", new
|
|
768
|
+
a(this, "nodeIdGenerator", new F(
|
|
771
769
|
(e) => this.graphStore.getNode(e) !== void 0
|
|
772
770
|
));
|
|
773
|
-
a(this, "portIdGenerator", new
|
|
771
|
+
a(this, "portIdGenerator", new F(
|
|
774
772
|
(e) => this.graphStore.getPort(e) !== void 0
|
|
775
773
|
));
|
|
776
|
-
a(this, "edgeIdGenerator", new
|
|
774
|
+
a(this, "edgeIdGenerator", new F(
|
|
777
775
|
(e) => this.graphStore.getEdge(e) !== void 0
|
|
778
776
|
));
|
|
779
777
|
this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = o, this.defaultPortsCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
|
|
780
778
|
}
|
|
781
779
|
addNode(e, t, s, o, i, n, h) {
|
|
782
780
|
if (e = this.nodeIdGenerator.create(e), this.graphStore.getNode(e) !== void 0)
|
|
783
|
-
throw new
|
|
781
|
+
throw new C("failed to add node with existing id");
|
|
784
782
|
this.graphStore.addNode(
|
|
785
783
|
e,
|
|
786
784
|
t,
|
|
@@ -801,21 +799,21 @@ class le {
|
|
|
801
799
|
updateNode(e, t, s, o, i) {
|
|
802
800
|
const n = this.graphStore.getNode(e);
|
|
803
801
|
if (n === void 0)
|
|
804
|
-
throw new
|
|
802
|
+
throw new C("failed to update nonexisting node");
|
|
805
803
|
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
804
|
}
|
|
807
805
|
removeNode(e) {
|
|
808
806
|
if (this.graphStore.getNode(e) === void 0)
|
|
809
|
-
throw new
|
|
807
|
+
throw new C("failed to remove nonexisting node");
|
|
810
808
|
(this.graphStore.getNodePortIds(e) ?? []).forEach((t) => {
|
|
811
809
|
this.unmarkPort(t);
|
|
812
810
|
}), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
|
|
813
811
|
}
|
|
814
812
|
markPort(e, t, s, o, i) {
|
|
815
813
|
if (e = this.portIdGenerator.create(e), this.graphStore.getNode(s) === void 0)
|
|
816
|
-
throw new
|
|
814
|
+
throw new C("failed to set port on nonexisting node");
|
|
817
815
|
if (this.graphStore.getPort(e) !== void 0)
|
|
818
|
-
throw new
|
|
816
|
+
throw new C("failed to add port with existing id");
|
|
819
817
|
this.graphStore.addPort(
|
|
820
818
|
e,
|
|
821
819
|
t,
|
|
@@ -827,23 +825,23 @@ class le {
|
|
|
827
825
|
updatePort(e, t, s) {
|
|
828
826
|
const o = this.graphStore.getPort(e);
|
|
829
827
|
if (o === void 0)
|
|
830
|
-
throw new
|
|
828
|
+
throw new C("failed to unset nonexisting port");
|
|
831
829
|
o.direction = t ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(e);
|
|
832
830
|
}
|
|
833
831
|
unmarkPort(e) {
|
|
834
832
|
if (this.graphStore.getPort(e) === void 0)
|
|
835
|
-
throw new
|
|
833
|
+
throw new C("failed to unset nonexisting port");
|
|
836
834
|
this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
|
|
837
835
|
this.removeEdge(t);
|
|
838
836
|
}), this.graphStore.removePort(e);
|
|
839
837
|
}
|
|
840
838
|
addEdge(e, t, s, o, i) {
|
|
841
839
|
if (e = this.edgeIdGenerator.create(e), this.graphStore.getPort(t) === void 0)
|
|
842
|
-
throw new
|
|
840
|
+
throw new C("failed to add edge from nonexisting port");
|
|
843
841
|
if (this.graphStore.getPort(s) === void 0)
|
|
844
|
-
throw new
|
|
842
|
+
throw new C("failed to add edge to nonexisting port");
|
|
845
843
|
if (this.graphStore.getEdge(e) !== void 0)
|
|
846
|
-
throw new
|
|
844
|
+
throw new C("failed to add edge with existing id");
|
|
847
845
|
const n = this.resolveEdgeType(t, s);
|
|
848
846
|
this.graphStore.addEdge(
|
|
849
847
|
e,
|
|
@@ -856,7 +854,7 @@ class le {
|
|
|
856
854
|
updateEdge(e, t, s) {
|
|
857
855
|
const o = this.graphStore.getEdge(e);
|
|
858
856
|
if (o === void 0)
|
|
859
|
-
throw new
|
|
857
|
+
throw new C("failed to update nonexisting edge");
|
|
860
858
|
if (t !== void 0) {
|
|
861
859
|
const i = this.resolveEdgeType(o.from, o.to);
|
|
862
860
|
o.shape = t(i), this.htmlController.updateEdgeShape(e);
|
|
@@ -865,7 +863,7 @@ class le {
|
|
|
865
863
|
}
|
|
866
864
|
removeEdge(e) {
|
|
867
865
|
if (this.graphStore.getEdge(e) === void 0)
|
|
868
|
-
throw new
|
|
866
|
+
throw new C("failed to remove nonexisting edge");
|
|
869
867
|
this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
|
|
870
868
|
}
|
|
871
869
|
patchViewportMatrix(e, t, s) {
|
|
@@ -888,25 +886,22 @@ class le {
|
|
|
888
886
|
}
|
|
889
887
|
resolveEdgeType(e, t) {
|
|
890
888
|
if (e === t)
|
|
891
|
-
return
|
|
889
|
+
return A.PortCycle;
|
|
892
890
|
const s = this.graphStore.getPortNodeId(e), o = this.graphStore.getPortNodeId(t);
|
|
893
|
-
return s === o ?
|
|
891
|
+
return s === o ? A.NodeCycle : A.Regular;
|
|
894
892
|
}
|
|
895
893
|
}
|
|
896
894
|
const ue = () => {
|
|
897
895
|
const r = document.createElement("div");
|
|
898
896
|
return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
|
|
899
897
|
}, ge = () => {
|
|
900
|
-
const r = document.createElement("canvas");
|
|
901
|
-
return r.style.position = "absolute", r.style.inset = "0", r;
|
|
902
|
-
}, we = () => {
|
|
903
898
|
const r = document.createElement("div");
|
|
904
899
|
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
|
|
905
|
-
},
|
|
900
|
+
}, we = () => {
|
|
906
901
|
const r = document.createElement("div");
|
|
907
902
|
return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
|
|
908
903
|
};
|
|
909
|
-
class
|
|
904
|
+
class ye {
|
|
910
905
|
constructor() {
|
|
911
906
|
a(this, "keyMap", /* @__PURE__ */ new Map());
|
|
912
907
|
a(this, "valueMap", /* @__PURE__ */ new Map());
|
|
@@ -937,65 +932,57 @@ class me {
|
|
|
937
932
|
this.keyMap.clear(), this.valueMap.clear();
|
|
938
933
|
}
|
|
939
934
|
}
|
|
940
|
-
class
|
|
935
|
+
class me {
|
|
941
936
|
constructor(e, t, s, o) {
|
|
942
937
|
a(this, "canvasWrapper", null);
|
|
943
938
|
a(this, "host", ue());
|
|
944
|
-
a(this, "
|
|
945
|
-
a(this, "
|
|
946
|
-
a(this, "canvasCtx");
|
|
947
|
-
a(this, "canvasResizeObserver");
|
|
948
|
-
a(this, "nodesResizeObserver");
|
|
939
|
+
a(this, "container", ge());
|
|
940
|
+
a(this, "nodeWrappersResizeObserver");
|
|
949
941
|
a(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
|
|
950
|
-
a(this, "nodeIdToWrapperElementMap", new
|
|
942
|
+
a(this, "nodeIdToWrapperElementMap", new ye());
|
|
951
943
|
a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
|
|
952
|
-
this.
|
|
953
|
-
const i = this.canvas.getContext("2d");
|
|
954
|
-
if (i === null)
|
|
955
|
-
throw new f("unable to get canvas context");
|
|
956
|
-
this.canvasCtx = i, this.host.appendChild(this.canvas), this.host.appendChild(this.container), this.canvasResizeObserver = this.createHostResizeObserver(), this.nodesResizeObserver = this.createNodesResizeObserver();
|
|
957
|
-
}
|
|
958
|
-
clear() {
|
|
959
|
-
this.edgeIdToElementMap.forEach((e, t) => {
|
|
960
|
-
this.detachEdge(t);
|
|
961
|
-
}), this.nodeIdToWrapperElementMap.forEach((e, t) => {
|
|
962
|
-
this.detachNode(t);
|
|
963
|
-
});
|
|
944
|
+
this.nodeResizeObserverFactory = e, this.getBoundingClientRect = t, this.graphStore = s, this.viewportTransformer = o, this.host.appendChild(this.container), this.nodeWrappersResizeObserver = this.createNodesResizeObserver();
|
|
964
945
|
}
|
|
965
946
|
attach(e) {
|
|
966
|
-
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host)
|
|
947
|
+
this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
|
|
967
948
|
}
|
|
968
949
|
detach() {
|
|
969
|
-
this.canvasWrapper !== null && (this.
|
|
970
|
-
}
|
|
971
|
-
destroy() {
|
|
972
|
-
this.canvasResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.container), this.clear(), this.detach();
|
|
950
|
+
this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
|
|
973
951
|
}
|
|
974
952
|
applyTransform() {
|
|
975
|
-
this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
|
|
976
953
|
const e = this.viewportTransformer.getContentMatrix();
|
|
977
954
|
this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
|
|
978
955
|
}
|
|
979
956
|
attachNode(e) {
|
|
980
|
-
const t = this.graphStore.getNode(e), s =
|
|
981
|
-
s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.
|
|
957
|
+
const t = this.graphStore.getNode(e), s = we();
|
|
958
|
+
s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoordinatesInternal(e), this.updateNodePriority(e), this.nodeWrappersResizeObserver.observe(s), s.style.visibility = "visible";
|
|
982
959
|
}
|
|
983
960
|
detachNode(e) {
|
|
984
961
|
const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
|
|
985
|
-
this.
|
|
962
|
+
this.nodeWrappersResizeObserver.unobserve(s), s.removeChild(t.element), this.container.removeChild(s), this.nodeElementToIdMap.delete(t.element), this.nodeIdToWrapperElementMap.deleteByKey(e);
|
|
986
963
|
}
|
|
987
964
|
attachEdge(e) {
|
|
988
965
|
const t = this.graphStore.getEdge(e);
|
|
989
|
-
this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.
|
|
966
|
+
this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
|
|
990
967
|
}
|
|
991
968
|
detachEdge(e) {
|
|
992
969
|
const t = this.graphStore.getEdge(e);
|
|
993
970
|
this.container.removeChild(t.shape.svg), this.edgeIdToElementMap.delete(e);
|
|
994
971
|
}
|
|
972
|
+
clear() {
|
|
973
|
+
this.edgeIdToElementMap.forEach((e, t) => {
|
|
974
|
+
this.detachEdge(t);
|
|
975
|
+
}), this.nodeIdToWrapperElementMap.forEach((e, t) => {
|
|
976
|
+
this.detachNode(t);
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
destroy() {
|
|
980
|
+
this.nodeWrappersResizeObserver.disconnect(), this.host.removeChild(this.container), this.clear(), this.detach();
|
|
981
|
+
}
|
|
995
982
|
updateNodeCoordinates(e) {
|
|
996
983
|
const t = this.graphStore.getNodeAdjacentEdgeIds(e);
|
|
997
|
-
this.
|
|
998
|
-
this.
|
|
984
|
+
this.updateNodeCoordinatesInternal(e), t.forEach((s) => {
|
|
985
|
+
this.updateEdgeCoordinates(s);
|
|
999
986
|
});
|
|
1000
987
|
}
|
|
1001
988
|
updateNodePriority(e) {
|
|
@@ -1006,7 +993,7 @@ class pe {
|
|
|
1006
993
|
const t = this.edgeIdToElementMap.get(e);
|
|
1007
994
|
this.container.removeChild(t);
|
|
1008
995
|
const s = this.graphStore.getEdge(e);
|
|
1009
|
-
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.
|
|
996
|
+
this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
|
|
1010
997
|
}
|
|
1011
998
|
updateEdgePriority(e) {
|
|
1012
999
|
const t = this.graphStore.getEdge(e);
|
|
@@ -1014,34 +1001,25 @@ class pe {
|
|
|
1014
1001
|
}
|
|
1015
1002
|
updatePortEdges(e) {
|
|
1016
1003
|
this.graphStore.getPortAdjacentEdgeIds(e).forEach((s) => {
|
|
1017
|
-
this.
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1020
|
-
createHostResizeObserver() {
|
|
1021
|
-
return new ResizeObserver(() => {
|
|
1022
|
-
this.updateCanvasDimensions(), this.applyTransform();
|
|
1004
|
+
this.updateEdgeCoordinates(s);
|
|
1023
1005
|
});
|
|
1024
1006
|
}
|
|
1025
1007
|
createNodesResizeObserver() {
|
|
1026
|
-
return
|
|
1008
|
+
return this.nodeResizeObserverFactory((e) => {
|
|
1027
1009
|
e.forEach((t) => {
|
|
1028
1010
|
const s = t.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
|
|
1029
|
-
this.
|
|
1030
|
-
this.
|
|
1011
|
+
this.updateNodeCoordinatesInternal(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
|
|
1012
|
+
this.updateEdgeCoordinates(n);
|
|
1031
1013
|
});
|
|
1032
1014
|
});
|
|
1033
1015
|
});
|
|
1034
1016
|
}
|
|
1035
|
-
|
|
1036
|
-
const { width:
|
|
1037
|
-
|
|
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})`;
|
|
1017
|
+
updateNodeCoordinatesInternal(e) {
|
|
1018
|
+
const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = this.getBoundingClientRect.call(t), 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;
|
|
1019
|
+
t.style.transform = `translate(${d}px, ${u}px)`;
|
|
1042
1020
|
}
|
|
1043
|
-
|
|
1044
|
-
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = s.element
|
|
1021
|
+
updateEdgeCoordinates(e) {
|
|
1022
|
+
const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = this.getBoundingClientRect.call(s.element), n = this.getBoundingClientRect.call(o.element), h = this.getBoundingClientRect.call(this.host), c = this.viewportTransformer.getViewportMatrix(), d = {
|
|
1045
1023
|
x: c.scale * (i.left - h.left) + c.dx,
|
|
1046
1024
|
y: c.scale * (i.top - h.top) + c.dy
|
|
1047
1025
|
}, u = {
|
|
@@ -1059,85 +1037,49 @@ class pe {
|
|
|
1059
1037
|
}, v = {
|
|
1060
1038
|
x: u.x + m.x,
|
|
1061
1039
|
y: u.y + m.y
|
|
1062
|
-
},
|
|
1063
|
-
t.shape.svg.style.width = `${
|
|
1064
|
-
const
|
|
1040
|
+
}, S = Math.min(y.x, v.x), P = Math.min(y.y, v.y), M = Math.abs(v.x - y.x), b = Math.abs(v.y - y.y);
|
|
1041
|
+
t.shape.svg.style.width = `${M}px`, t.shape.svg.style.height = `${b}px`, t.shape.svg.style.transform = `translate(${S}px, ${P}px)`;
|
|
1042
|
+
const T = y.x <= v.x ? 1 : -1, W = y.y <= v.y ? 1 : -1;
|
|
1065
1043
|
t.shape.update(
|
|
1066
|
-
{ x:
|
|
1067
|
-
|
|
1068
|
-
|
|
1044
|
+
{ x: M, y: b },
|
|
1045
|
+
T,
|
|
1046
|
+
W,
|
|
1069
1047
|
s.direction,
|
|
1070
1048
|
o.direction
|
|
1071
1049
|
);
|
|
1072
1050
|
}
|
|
1073
1051
|
}
|
|
1074
|
-
class
|
|
1075
|
-
constructor(e, t, s, o, i, n) {
|
|
1052
|
+
class pe {
|
|
1053
|
+
constructor(e, t, s, o, i, n, h) {
|
|
1076
1054
|
a(this, "publicViewportTransformer");
|
|
1077
1055
|
a(this, "publicGraphStore");
|
|
1078
1056
|
a(this, "canvasController");
|
|
1079
|
-
const
|
|
1080
|
-
this.publicGraphStore = new ee(
|
|
1081
|
-
|
|
1057
|
+
const c = new Q(), d = new q();
|
|
1058
|
+
this.publicGraphStore = new ee(d), this.publicViewportTransformer = new Z(
|
|
1059
|
+
c
|
|
1082
1060
|
);
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1061
|
+
const u = new me(
|
|
1062
|
+
e,
|
|
1063
|
+
t,
|
|
1064
|
+
d,
|
|
1065
|
+
c
|
|
1088
1066
|
);
|
|
1089
1067
|
this.canvasController = new le(
|
|
1090
|
-
c,
|
|
1091
1068
|
d,
|
|
1092
|
-
|
|
1093
|
-
|
|
1069
|
+
u,
|
|
1070
|
+
c,
|
|
1094
1071
|
s,
|
|
1095
1072
|
o,
|
|
1096
1073
|
i,
|
|
1097
|
-
n
|
|
1074
|
+
n,
|
|
1075
|
+
h
|
|
1098
1076
|
);
|
|
1099
1077
|
}
|
|
1100
1078
|
}
|
|
1101
1079
|
const H = (r, e) => ({
|
|
1102
1080
|
x: r / 2,
|
|
1103
1081
|
y: e / 2
|
|
1104
|
-
}),
|
|
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)
|
|
1109
|
-
return;
|
|
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(
|
|
1117
|
-
i,
|
|
1118
|
-
n,
|
|
1119
|
-
r,
|
|
1120
|
-
e,
|
|
1121
|
-
t,
|
|
1122
|
-
s,
|
|
1123
|
-
o
|
|
1124
|
-
);
|
|
1125
|
-
}, Ce = (r) => {
|
|
1126
|
-
switch (r == null ? void 0 : r.type) {
|
|
1127
|
-
case "custom":
|
|
1128
|
-
return r.drawingFn;
|
|
1129
|
-
case "dots":
|
|
1130
|
-
return Ee(
|
|
1131
|
-
r.dotColor ?? "#d8d8d8",
|
|
1132
|
-
r.dotGap ?? 25,
|
|
1133
|
-
r.dotRadius ?? 1.5,
|
|
1134
|
-
r.color ?? "#ffffff",
|
|
1135
|
-
r.limit ?? 1e4
|
|
1136
|
-
);
|
|
1137
|
-
default:
|
|
1138
|
-
return fe();
|
|
1139
|
-
}
|
|
1140
|
-
}, g = {
|
|
1082
|
+
}), g = {
|
|
1141
1083
|
edgeColor: "#5c5c5c",
|
|
1142
1084
|
edgeWidth: 1,
|
|
1143
1085
|
edgeArrowLength: 15,
|
|
@@ -1151,7 +1093,7 @@ const H = (r, e) => ({
|
|
|
1151
1093
|
detourDirection: -Math.PI / 2,
|
|
1152
1094
|
smallCycleSize: 15,
|
|
1153
1095
|
curvature: 90
|
|
1154
|
-
},
|
|
1096
|
+
}, k = (r) => {
|
|
1155
1097
|
switch (r == null ? void 0 : r.type) {
|
|
1156
1098
|
case "custom":
|
|
1157
1099
|
return r.factory;
|
|
@@ -1170,7 +1112,7 @@ const H = (r, e) => ({
|
|
|
1170
1112
|
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1171
1113
|
});
|
|
1172
1114
|
case "horizontal":
|
|
1173
|
-
return
|
|
1115
|
+
return de({
|
|
1174
1116
|
color: r.color ?? g.edgeColor,
|
|
1175
1117
|
width: r.width ?? g.edgeWidth,
|
|
1176
1118
|
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
@@ -1184,7 +1126,7 @@ const H = (r, e) => ({
|
|
|
1184
1126
|
detourDirection: r.detourDirection ?? g.detourDirection
|
|
1185
1127
|
});
|
|
1186
1128
|
case "vertical":
|
|
1187
|
-
return
|
|
1129
|
+
return ce({
|
|
1188
1130
|
color: r.color ?? g.edgeColor,
|
|
1189
1131
|
width: r.width ?? g.edgeWidth,
|
|
1190
1132
|
arrowLength: r.arrowLength ?? g.edgeArrowLength,
|
|
@@ -1212,29 +1154,24 @@ const H = (r, e) => ({
|
|
|
1212
1154
|
curvature: r.curvature ?? g.curvature
|
|
1213
1155
|
});
|
|
1214
1156
|
}
|
|
1215
|
-
},
|
|
1157
|
+
}, z = (r) => () => r, U = z(0), R = () => {
|
|
1216
1158
|
let r = 0;
|
|
1217
1159
|
return () => r++;
|
|
1218
|
-
},
|
|
1160
|
+
}, ve = (r, e) => {
|
|
1219
1161
|
const t = [
|
|
1220
1162
|
U,
|
|
1221
1163
|
U
|
|
1222
1164
|
];
|
|
1223
|
-
r === "incremental" && (t[0] =
|
|
1224
|
-
const s =
|
|
1225
|
-
return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] =
|
|
1226
|
-
},
|
|
1165
|
+
r === "incremental" && (t[0] = R()), e === "incremental" && (t[1] = R());
|
|
1166
|
+
const s = R();
|
|
1167
|
+
return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] = z(r)), typeof e == "number" && (t[1] = z(e)), typeof r == "function" && (t[0] = r), typeof e == "function" && (t[1] = e), t;
|
|
1168
|
+
}, fe = (r) => {
|
|
1227
1169
|
var s, o, i, n, h, c;
|
|
1228
|
-
const [e, t] =
|
|
1170
|
+
const [e, t] = ve(
|
|
1229
1171
|
(s = r.nodes) == null ? void 0 : s.priority,
|
|
1230
1172
|
(o = r.edges) == null ? void 0 : o.priority
|
|
1231
1173
|
);
|
|
1232
1174
|
return {
|
|
1233
|
-
background: {
|
|
1234
|
-
drawingFn: Ce(
|
|
1235
|
-
r.background ?? { type: "none" }
|
|
1236
|
-
)
|
|
1237
|
-
},
|
|
1238
1175
|
nodes: {
|
|
1239
1176
|
centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? H,
|
|
1240
1177
|
priorityFn: e
|
|
@@ -1244,21 +1181,23 @@ const H = (r, e) => ({
|
|
|
1244
1181
|
direction: ((h = r.ports) == null ? void 0 : h.direction) ?? 0
|
|
1245
1182
|
},
|
|
1246
1183
|
edges: {
|
|
1247
|
-
shapeFactory:
|
|
1184
|
+
shapeFactory: k(((c = r.edges) == null ? void 0 : c.shape) ?? {}),
|
|
1248
1185
|
priorityFn: t
|
|
1249
1186
|
}
|
|
1250
1187
|
};
|
|
1251
1188
|
};
|
|
1252
|
-
class
|
|
1189
|
+
class xe {
|
|
1253
1190
|
constructor(e) {
|
|
1254
1191
|
a(this, "transformation");
|
|
1255
1192
|
a(this, "model");
|
|
1256
1193
|
a(this, "di");
|
|
1257
1194
|
a(this, "edgeShapeFactory");
|
|
1195
|
+
a(this, "nodeResizeObserverFactory", (e) => new window.ResizeObserver(e));
|
|
1258
1196
|
this.apiOptions = e;
|
|
1259
|
-
const t =
|
|
1260
|
-
this.di = new
|
|
1261
|
-
|
|
1197
|
+
const t = fe(this.apiOptions ?? {});
|
|
1198
|
+
this.di = new pe(
|
|
1199
|
+
this.nodeResizeObserverFactory,
|
|
1200
|
+
Element.prototype.getBoundingClientRect,
|
|
1262
1201
|
t.nodes.centerFn,
|
|
1263
1202
|
t.ports.centerFn,
|
|
1264
1203
|
t.ports.direction,
|
|
@@ -1309,7 +1248,7 @@ class Pe {
|
|
|
1309
1248
|
return this.di.canvasController.unmarkPort(e), this;
|
|
1310
1249
|
}
|
|
1311
1250
|
addEdge(e) {
|
|
1312
|
-
const t = e.shape !== void 0 ?
|
|
1251
|
+
const t = e.shape !== void 0 ? k(e.shape) : this.edgeShapeFactory;
|
|
1313
1252
|
return this.di.canvasController.addEdge(
|
|
1314
1253
|
e.id,
|
|
1315
1254
|
e.from,
|
|
@@ -1319,7 +1258,7 @@ class Pe {
|
|
|
1319
1258
|
), this;
|
|
1320
1259
|
}
|
|
1321
1260
|
updateEdge(e, t) {
|
|
1322
|
-
const s = t.shape !== void 0 ?
|
|
1261
|
+
const s = t.shape !== void 0 ? k(t.shape) : void 0;
|
|
1323
1262
|
return this.di.canvasController.updateEdge(e, s, t.priority), this;
|
|
1324
1263
|
}
|
|
1325
1264
|
removeEdge(e) {
|
|
@@ -1355,10 +1294,10 @@ class Pe {
|
|
|
1355
1294
|
const O = (r, e, t) => {
|
|
1356
1295
|
const { x: s, y: o, width: i, height: n } = r.getBoundingClientRect();
|
|
1357
1296
|
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,
|
|
1297
|
+
}, V = (r, e, t) => e >= 0 && e < r.innerWidth && t >= 0 && t <= r.innerHeight, I = (r, e) => {
|
|
1359
1298
|
e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
|
|
1360
1299
|
};
|
|
1361
|
-
class
|
|
1300
|
+
class Ee {
|
|
1362
1301
|
constructor(e, t) {
|
|
1363
1302
|
a(this, "model");
|
|
1364
1303
|
a(this, "transformation");
|
|
@@ -1367,7 +1306,7 @@ class Me {
|
|
|
1367
1306
|
a(this, "grabbedNodeId", null);
|
|
1368
1307
|
a(this, "onNodeDrag");
|
|
1369
1308
|
a(this, "onBeforeNodeDrag");
|
|
1370
|
-
a(this, "nodeIdGenerator", new
|
|
1309
|
+
a(this, "nodeIdGenerator", new F(
|
|
1371
1310
|
(e) => this.nodes.has(e)
|
|
1372
1311
|
));
|
|
1373
1312
|
a(this, "element", null);
|
|
@@ -1434,7 +1373,7 @@ class Me {
|
|
|
1434
1373
|
element: e.element,
|
|
1435
1374
|
x: n.x,
|
|
1436
1375
|
y: n.y
|
|
1437
|
-
}) && (i.stopImmediatePropagation(), this.grabbedNodeId = t,
|
|
1376
|
+
}) && (i.stopImmediatePropagation(), this.grabbedNodeId = t, I(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
|
|
1438
1377
|
}, o = (i) => {
|
|
1439
1378
|
const n = this.model.getNode(t);
|
|
1440
1379
|
this.onBeforeNodeDrag({
|
|
@@ -1500,7 +1439,7 @@ class Me {
|
|
|
1500
1439
|
dragNode(e, t, s) {
|
|
1501
1440
|
const o = this.model.getNode(e);
|
|
1502
1441
|
if (o === null)
|
|
1503
|
-
throw new
|
|
1442
|
+
throw new C("failed to drag nonexisting node");
|
|
1504
1443
|
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
1444
|
this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
|
|
1506
1445
|
nodeId: e,
|
|
@@ -1523,7 +1462,7 @@ class Me {
|
|
|
1523
1462
|
});
|
|
1524
1463
|
}
|
|
1525
1464
|
cancelMouseDrag() {
|
|
1526
|
-
this.grabbedNodeId = null, this.element !== null &&
|
|
1465
|
+
this.grabbedNodeId = null, this.element !== null && I(this.element, null), this.removeMouseDragListeners();
|
|
1527
1466
|
}
|
|
1528
1467
|
removeMouseDragListeners() {
|
|
1529
1468
|
this.window.removeEventListener("mouseup", this.onCanvasMouseUp), this.window.removeEventListener("mousemove", this.onCanvasMouseMove);
|
|
@@ -1535,11 +1474,11 @@ class Me {
|
|
|
1535
1474
|
this.window.removeEventListener("touchmove", this.onCanvasTouchMove), this.window.removeEventListener("touchend", this.onCanvasTouchEnd), this.window.removeEventListener("touchcancel", this.onCanvasTouchEnd);
|
|
1536
1475
|
}
|
|
1537
1476
|
}
|
|
1538
|
-
const
|
|
1539
|
-
},
|
|
1477
|
+
const Ce = () => {
|
|
1478
|
+
}, Ae = (r, e) => e, Se = (r, e) => {
|
|
1540
1479
|
const t = e !== null ? 1 / e : null, s = r !== null ? 1 / r : null;
|
|
1541
1480
|
return (o, i) => s !== null && i.scale > s && i.scale > o.scale || t !== null && i.scale < t && i.scale < o.scale ? o : i;
|
|
1542
|
-
},
|
|
1481
|
+
}, Pe = (r, e, t, s) => (o, i, n, h) => {
|
|
1543
1482
|
let c = i.dx, d = i.dy;
|
|
1544
1483
|
r !== null && c < r && c < o.dx && (c = o.dx);
|
|
1545
1484
|
const u = n * o.scale;
|
|
@@ -1549,12 +1488,12 @@ const Ne = () => {
|
|
|
1549
1488
|
}, K = (r) => {
|
|
1550
1489
|
switch (r.type) {
|
|
1551
1490
|
case "scale-limit":
|
|
1552
|
-
return
|
|
1491
|
+
return Se(
|
|
1553
1492
|
r.minContentScale ?? null,
|
|
1554
1493
|
r.maxContentScale ?? null
|
|
1555
1494
|
);
|
|
1556
1495
|
case "shift-limit":
|
|
1557
|
-
return
|
|
1496
|
+
return Pe(
|
|
1558
1497
|
r.minX ?? null,
|
|
1559
1498
|
r.maxX ?? null,
|
|
1560
1499
|
r.minY ?? null,
|
|
@@ -1563,11 +1502,11 @@ const Ne = () => {
|
|
|
1563
1502
|
default:
|
|
1564
1503
|
return r.preprocessorFn;
|
|
1565
1504
|
}
|
|
1566
|
-
},
|
|
1505
|
+
}, Me = (r) => (e, t, s, o) => r.reduce(
|
|
1567
1506
|
(i, n) => n(e, i, s, o),
|
|
1568
1507
|
t
|
|
1569
1508
|
);
|
|
1570
|
-
class
|
|
1509
|
+
class Ne {
|
|
1571
1510
|
constructor(e, t) {
|
|
1572
1511
|
a(this, "model");
|
|
1573
1512
|
a(this, "transformation");
|
|
@@ -1580,7 +1519,7 @@ class De {
|
|
|
1580
1519
|
a(this, "wheelSensitivity");
|
|
1581
1520
|
a(this, "window", window);
|
|
1582
1521
|
a(this, "onMouseDown", () => {
|
|
1583
|
-
this.element !== null && (
|
|
1522
|
+
this.element !== null && (I(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
|
|
1584
1523
|
});
|
|
1585
1524
|
a(this, "onMouseMove", (e) => {
|
|
1586
1525
|
if (!this.isShiftable || this.element === null)
|
|
@@ -1635,20 +1574,20 @@ class De {
|
|
|
1635
1574
|
t,
|
|
1636
1575
|
s
|
|
1637
1576
|
);
|
|
1638
|
-
this.canvas.patchViewportMatrix(o), this.onTransformFinished(
|
|
1577
|
+
this.canvas.patchViewportMatrix(o), this.onTransformFinished();
|
|
1639
1578
|
}
|
|
1640
1579
|
}));
|
|
1641
1580
|
a(this, "shiftCursor");
|
|
1642
1581
|
var i, n, h, c, d, u, w, m;
|
|
1643
1582
|
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
1583
|
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) ??
|
|
1584
|
+
this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((w = t == null ? void 0 : t.events) == null ? void 0 : w.onTransformFinished) ?? Ce;
|
|
1646
1585
|
const o = t == null ? void 0 : t.transformPreprocessor;
|
|
1647
|
-
o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor =
|
|
1586
|
+
o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = Me(
|
|
1648
1587
|
o.map(
|
|
1649
1588
|
(y) => K(y)
|
|
1650
1589
|
)
|
|
1651
|
-
) : this.transformPreprocessor = K(o) : this.transformPreprocessor =
|
|
1590
|
+
) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Ae, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
|
|
1652
1591
|
}
|
|
1653
1592
|
addNode(e) {
|
|
1654
1593
|
return this.canvas.addNode(e), this;
|
|
@@ -1727,7 +1666,7 @@ class De {
|
|
|
1727
1666
|
i,
|
|
1728
1667
|
n
|
|
1729
1668
|
);
|
|
1730
|
-
this.canvas.patchViewportMatrix(h), this.onTransformFinished(
|
|
1669
|
+
this.canvas.patchViewportMatrix(h), this.onTransformFinished();
|
|
1731
1670
|
}
|
|
1732
1671
|
}
|
|
1733
1672
|
scaleViewport(e, t, s) {
|
|
@@ -1743,10 +1682,10 @@ class De {
|
|
|
1743
1682
|
n,
|
|
1744
1683
|
h
|
|
1745
1684
|
);
|
|
1746
|
-
this.canvas.patchViewportMatrix(c), this.onTransformFinished(
|
|
1685
|
+
this.canvas.patchViewportMatrix(c), this.onTransformFinished();
|
|
1747
1686
|
}
|
|
1748
1687
|
stopMouseDrag() {
|
|
1749
|
-
this.element !== null &&
|
|
1688
|
+
this.element !== null && I(this.element, null), this.removeMouseDragListeners();
|
|
1750
1689
|
}
|
|
1751
1690
|
removeMouseDragListeners() {
|
|
1752
1691
|
this.window.removeEventListener("mousemove", this.onMouseMove), this.window.removeEventListener("mouseup", this.onMouseUp);
|
|
@@ -1758,7 +1697,7 @@ class De {
|
|
|
1758
1697
|
this.window.removeEventListener("touchmove", this.onTouchMove), this.window.removeEventListener("touchend", this.onTouchEnd), this.window.removeEventListener("touchcancel", this.onTouchEnd);
|
|
1759
1698
|
}
|
|
1760
1699
|
}
|
|
1761
|
-
class
|
|
1700
|
+
class Te {
|
|
1762
1701
|
constructor() {
|
|
1763
1702
|
a(this, "coreOptions");
|
|
1764
1703
|
a(this, "dragOptions");
|
|
@@ -1776,26 +1715,27 @@ class We {
|
|
|
1776
1715
|
return this.isTransformable = !0, this.transformOptions = e, this;
|
|
1777
1716
|
}
|
|
1778
1717
|
build() {
|
|
1779
|
-
let e = new
|
|
1780
|
-
return this.isDraggable && (e = new
|
|
1718
|
+
let e = new xe(this.coreOptions);
|
|
1719
|
+
return this.isDraggable && (e = new Ee(e, this.dragOptions)), this.isTransformable && (e = new Ne(e, this.transformOptions)), e;
|
|
1781
1720
|
}
|
|
1782
1721
|
}
|
|
1783
1722
|
export {
|
|
1784
1723
|
te as BezierEdgeShape,
|
|
1785
|
-
|
|
1724
|
+
xe as CanvasCore,
|
|
1786
1725
|
ie as CycleCircleEdgeShape,
|
|
1787
1726
|
B as CycleSquareEdgeShape,
|
|
1727
|
+
ne as DetourBezierEdgeShape,
|
|
1788
1728
|
G as DetourStraightEdgeShape,
|
|
1789
|
-
|
|
1729
|
+
A as EdgeType,
|
|
1790
1730
|
se as HorizontalEdgeShape,
|
|
1791
|
-
|
|
1792
|
-
|
|
1731
|
+
Te as HtmlGraphBuilder,
|
|
1732
|
+
C as HtmlGraphError,
|
|
1793
1733
|
re as StraightEdgeShape,
|
|
1794
|
-
|
|
1795
|
-
|
|
1734
|
+
Ee as UserDraggableNodesCanvas,
|
|
1735
|
+
Ne as UserTransformableCanvas,
|
|
1796
1736
|
oe as VerticalEdgeShape,
|
|
1797
1737
|
ae as createBezierEdgeShapeFactory,
|
|
1798
|
-
|
|
1738
|
+
de as createHorizontalEdgeShapeFactory,
|
|
1799
1739
|
he as createStraightEdgeShareFactory,
|
|
1800
|
-
|
|
1740
|
+
ce as createVerticalEdgeShapeFactory
|
|
1801
1741
|
};
|