@html-graph/html-graph 8.16.0 → 8.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2691,6 +2691,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2691
2691
  __publicField(this, "line");
2692
2692
  __publicField(this, "sourceArrow");
2693
2693
  __publicField(this, "targetArrow");
2694
+ // TODO: make private
2695
+ /**
2696
+ * @deprecated
2697
+ * do use shape.svg instead
2698
+ */
2694
2699
  __publicField(this, "handle", createEdgeGroup());
2695
2700
  __publicField(this, "onAfterRender");
2696
2701
  __publicField(this, "interactiveLine");
@@ -3304,11 +3309,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3304
3309
  }
3305
3310
  const target = event.currentTarget;
3306
3311
  const portId = this.canvas.graph.findPortIdsByElement(target)[0];
3307
- const accepted = this.params.onPortPointerDown(portId, {
3312
+ const dragAllowed = this.params.portDragAllowedVerifier(portId, {
3308
3313
  x: mouseEvent.clientX,
3309
3314
  y: mouseEvent.clientY
3310
3315
  });
3311
- if (!accepted) {
3316
+ if (!dragAllowed) {
3312
3317
  return;
3313
3318
  }
3314
3319
  event.stopPropagation();
@@ -3325,8 +3330,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3325
3330
  event.clientY
3326
3331
  );
3327
3332
  if (!isInside) {
3328
- this.params.onPointerMoveOutside();
3329
- this.stopMouseDrag();
3333
+ this.removeWindowMouseListeners();
3334
+ this.params.onPointerOutside();
3330
3335
  return;
3331
3336
  }
3332
3337
  this.params.onPointerMove({ x: event.clientX, y: event.clientY });
@@ -3335,8 +3340,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3335
3340
  if (!this.params.mouseUpEventVerifier(event)) {
3336
3341
  return;
3337
3342
  }
3343
+ this.removeWindowMouseListeners();
3338
3344
  this.params.onPointerUp({ x: event.clientX, y: event.clientY });
3339
- this.stopMouseDrag();
3340
3345
  });
3341
3346
  __publicField(this, "onPortTouchStart", (event) => {
3342
3347
  const touchEvent = event;
@@ -3346,11 +3351,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3346
3351
  const touch = touchEvent.touches[0];
3347
3352
  const target = event.currentTarget;
3348
3353
  const portId = this.canvas.graph.findPortIdsByElement(target)[0];
3349
- const accepted = this.params.onPortPointerDown(portId, {
3354
+ const dragAllowed = this.params.portDragAllowedVerifier(portId, {
3350
3355
  x: touch.clientX,
3351
3356
  y: touch.clientY
3352
3357
  });
3353
- if (!accepted) {
3358
+ if (!dragAllowed) {
3354
3359
  return;
3355
3360
  }
3356
3361
  event.stopPropagation();
@@ -3371,16 +3376,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3371
3376
  touch.clientY
3372
3377
  );
3373
3378
  if (!isInside) {
3374
- this.params.onPointerMoveOutside();
3375
- this.stopTouchDrag();
3379
+ this.removeWindowTouchListeners();
3380
+ this.params.onPointerOutside();
3376
3381
  return;
3377
3382
  }
3378
3383
  this.params.onPointerMove({ x: touch.clientX, y: touch.clientY });
3379
3384
  });
3380
3385
  __publicField(this, "onWindowTouchFinish", (event) => {
3386
+ this.removeWindowTouchListeners();
3381
3387
  const touch = event.changedTouches[0];
3382
3388
  this.params.onPointerUp({ x: touch.clientX, y: touch.clientY });
3383
- this.stopTouchDrag();
3384
3389
  });
3385
3390
  __publicField(this, "reset", () => {
3386
3391
  this.canvas.graph.getAllPortIds().forEach((portId) => {
@@ -3389,10 +3394,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3389
3394
  });
3390
3395
  });
3391
3396
  __publicField(this, "revert", () => {
3392
- this.params.onStopDrag();
3393
- this.reset();
3394
3397
  this.removeWindowMouseListeners();
3395
3398
  this.removeWindowTouchListeners();
3399
+ this.reset();
3396
3400
  });
3397
3401
  this.canvas = canvas;
3398
3402
  this.window = window2;
@@ -3418,14 +3422,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3418
3422
  element.removeEventListener("mousedown", this.onPortMouseDown);
3419
3423
  element.removeEventListener("touchstart", this.onPortTouchStart);
3420
3424
  }
3421
- stopMouseDrag() {
3422
- this.params.onStopDrag();
3423
- this.removeWindowMouseListeners();
3424
- }
3425
- stopTouchDrag() {
3426
- this.params.onStopDrag();
3427
- this.removeWindowTouchListeners();
3428
- }
3429
3425
  removeWindowMouseListeners() {
3430
3426
  this.window.removeEventListener("mousemove", this.onWindowMouseMove);
3431
3427
  this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -3436,47 +3432,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3436
3432
  this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
3437
3433
  }
3438
3434
  }
3439
- class LayoutApplier {
3440
- constructor(canvas, layoutAlgorithm, params) {
3441
- this.canvas = canvas;
3442
- this.layoutAlgorithm = layoutAlgorithm;
3443
- this.params = params;
3444
- }
3445
- apply() {
3446
- const coords = this.layoutAlgorithm.calculateCoordinates({
3447
- graph: this.canvas.graph,
3448
- viewport: this.canvas.viewport
3449
- });
3450
- this.params.onBeforeApplied();
3451
- coords.forEach((point, nodeId) => {
3452
- if (!this.params.staticNodeResolver(nodeId)) {
3453
- this.canvas.updateNode(nodeId, point);
3454
- }
3455
- });
3456
- this.params.onAfterApplied();
3457
- }
3458
- }
3459
- class AnimatedLayoutApplier {
3460
- constructor(canvas, layoutAlgorithm, params) {
3461
- this.canvas = canvas;
3462
- this.layoutAlgorithm = layoutAlgorithm;
3463
- this.params = params;
3464
- }
3465
- apply(dt) {
3466
- const coords = this.layoutAlgorithm.calculateNextCoordinates({
3467
- graph: this.canvas.graph,
3468
- viewport: this.canvas.viewport,
3469
- dt
3470
- });
3471
- this.params.onBeforeApplied();
3472
- coords.forEach((point, nodeId) => {
3473
- if (!this.params.staticNodeResolver(nodeId)) {
3474
- this.canvas.updateNode(nodeId, point);
3475
- }
3476
- });
3477
- this.params.onAfterApplied();
3478
- }
3479
- }
3480
3435
  class EventTagger {
3481
3436
  constructor() {
3482
3437
  __publicField(this, "field", "_htmlGraphTags");
@@ -4371,34 +4326,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4371
4326
  this.viewportStore,
4372
4327
  this.window
4373
4328
  );
4329
+ const draggablePortsParams = {
4330
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
4331
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
4332
+ portDragAllowedVerifier: (portId, cursor) => {
4333
+ const connectionType = this.params.connectionTypeResolver(portId);
4334
+ if (connectionType === null) {
4335
+ return false;
4336
+ }
4337
+ this.grabPort(portId, cursor, connectionType);
4338
+ return true;
4339
+ },
4340
+ onPointerMove: (cursor) => {
4341
+ this.moveDraggingPort(cursor);
4342
+ },
4343
+ onPointerUp: (cursor) => {
4344
+ this.tryCreateConnection(cursor);
4345
+ this.resetDragState();
4346
+ },
4347
+ onPointerOutside: () => {
4348
+ const staticPortId = this.staticPortId;
4349
+ const isTargetDragging = this.isTargetDragging;
4350
+ this.resetDragState();
4351
+ this.params.onEdgeCreationInterrupted({
4352
+ staticPortId,
4353
+ isDirect: isTargetDragging
4354
+ });
4355
+ }
4356
+ };
4374
4357
  DraggablePortsConfigurator.configure(
4375
4358
  this.canvas,
4376
4359
  this.window,
4377
4360
  this.pointInsideVerifier,
4378
- {
4379
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
4380
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
4381
- onStopDrag: () => {
4382
- this.resetDragState();
4383
- },
4384
- onPortPointerDown: (portId, cursor) => {
4385
- const connectionType = this.params.connectionTypeResolver(portId);
4386
- if (connectionType === null) {
4387
- return false;
4388
- }
4389
- this.grabPort(portId, cursor, connectionType);
4390
- return true;
4391
- },
4392
- onPointerMove: (cursor) => {
4393
- this.moveDraggingPort(cursor);
4394
- },
4395
- onPointerMoveOutside: () => {
4396
- this.handleEdgeCreationInterrupted();
4397
- },
4398
- onPointerUp: (cursor) => {
4399
- this.tryCreateConnection(cursor);
4400
- }
4401
- }
4361
+ draggablePortsParams
4402
4362
  );
4403
4363
  }
4404
4364
  static configure(canvas, overlayLayer, viewportStore, win, pointInsideVerifier, params) {
@@ -4454,15 +4414,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4454
4414
  tryCreateConnection(cursor) {
4455
4415
  const draggingPortId = findPortAtPoint(this.canvas.graph, cursor);
4456
4416
  if (draggingPortId === null) {
4457
- this.handleEdgeCreationInterrupted();
4417
+ this.params.onEdgeCreationInterrupted({
4418
+ staticPortId: this.staticPortId,
4419
+ isDirect: this.isTargetDragging
4420
+ });
4458
4421
  return;
4459
4422
  }
4460
4423
  const staticPortId = this.staticPortId;
4461
4424
  const sourceId = this.isTargetDragging ? staticPortId : draggingPortId;
4462
4425
  const targetId = this.isTargetDragging ? draggingPortId : staticPortId;
4463
4426
  const request = { from: sourceId, to: targetId };
4427
+ const connectionAllowed = this.params.connectionAllowedVerifier(request);
4464
4428
  const processedRequest = this.params.connectionPreprocessor(request);
4465
- if (processedRequest !== null) {
4429
+ if (connectionAllowed && processedRequest !== null) {
4466
4430
  this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated);
4467
4431
  this.canvas.addEdge(processedRequest);
4468
4432
  this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated);
@@ -4481,13 +4445,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4481
4445
  y: nodeContentCoords.y
4482
4446
  });
4483
4447
  }
4484
- handleEdgeCreationInterrupted() {
4485
- const staticPortId = this.staticPortId;
4486
- this.params.onEdgeCreationInterrupted({
4487
- staticPortId,
4488
- isDirect: this.isTargetDragging
4489
- });
4490
- }
4491
4448
  }
4492
4449
  class UserDraggableEdgesConfigurator {
4493
4450
  constructor(canvas, overlayLayer, viewportStore, window2, pointInsideVerifier, params) {
@@ -4509,38 +4466,36 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4509
4466
  this.viewportStore,
4510
4467
  this.window
4511
4468
  );
4469
+ const draggablePortsParams = {
4470
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
4471
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
4472
+ portDragAllowedVerifier: (portId, cursor) => {
4473
+ return this.tryStartEdgeDragging(portId, cursor);
4474
+ },
4475
+ onPointerMove: (cursor) => {
4476
+ this.moveDraggingPort(cursor);
4477
+ },
4478
+ onPointerUp: (cursor) => {
4479
+ this.tryCreateConnection(cursor);
4480
+ this.resetDragState();
4481
+ },
4482
+ onPointerOutside: () => {
4483
+ const edge = this.draggingEdgePayload;
4484
+ this.resetDragState();
4485
+ this.params.onEdgeReattachInterrupted({
4486
+ id: edge.id,
4487
+ from: edge.from,
4488
+ to: edge.to,
4489
+ shape: edge.shape,
4490
+ priority: edge.priority
4491
+ });
4492
+ }
4493
+ };
4512
4494
  DraggablePortsConfigurator.configure(
4513
4495
  this.canvas,
4514
4496
  this.window,
4515
4497
  this.pointInsideVerifier,
4516
- {
4517
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
4518
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
4519
- onStopDrag: () => {
4520
- this.resetDragState();
4521
- },
4522
- onPortPointerDown: (portId, cursor) => {
4523
- return this.tryStartEdgeDragging(portId, cursor);
4524
- },
4525
- onPointerMove: (cursor) => {
4526
- this.moveDraggingPort(cursor);
4527
- },
4528
- onPointerMoveOutside: () => {
4529
- const edge = this.draggingEdgePayload;
4530
- queueMicrotask(() => {
4531
- this.params.onEdgeReattachInterrupted({
4532
- id: edge.id,
4533
- from: edge.from,
4534
- to: edge.to,
4535
- shape: edge.shape,
4536
- priority: edge.priority
4537
- });
4538
- });
4539
- },
4540
- onPointerUp: (cursor) => {
4541
- this.tryCreateConnection(cursor);
4542
- }
4543
- }
4498
+ draggablePortsParams
4544
4499
  );
4545
4500
  }
4546
4501
  static configure(canvas, overlayLayer, viewportStore, win, pointInsideVerifier, params) {
@@ -4555,7 +4510,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4555
4510
  }
4556
4511
  tryStartEdgeDragging(portId, cursor) {
4557
4512
  const edgeId = this.params.draggingEdgeResolver(portId);
4558
- if (edgeId === null || !this.canvas.graph.hasEdge(edgeId)) {
4513
+ if (edgeId === null) {
4559
4514
  return false;
4560
4515
  }
4561
4516
  const edge = this.canvas.graph.getEdge(edgeId);
@@ -4644,8 +4599,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4644
4599
  shape: edge.shape,
4645
4600
  priority: edge.priority
4646
4601
  };
4602
+ const connectionAllowed = this.params.connectionAllowedVerifier({
4603
+ from,
4604
+ to
4605
+ });
4647
4606
  const processedRequest = this.params.connectionPreprocessor(request);
4648
- if (processedRequest !== null) {
4607
+ if (connectionAllowed && processedRequest !== null) {
4649
4608
  this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached);
4650
4609
  this.canvas.addEdge(processedRequest);
4651
4610
  this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
@@ -4721,6 +4680,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4721
4680
  this.defererFn(this.apply);
4722
4681
  }
4723
4682
  }
4683
+ class LayoutApplier {
4684
+ constructor(canvas, layoutAlgorithm, params) {
4685
+ this.canvas = canvas;
4686
+ this.layoutAlgorithm = layoutAlgorithm;
4687
+ this.params = params;
4688
+ }
4689
+ apply() {
4690
+ const coords = this.layoutAlgorithm.calculateCoordinates({
4691
+ graph: this.canvas.graph,
4692
+ viewport: this.canvas.viewport
4693
+ });
4694
+ this.params.onBeforeApplied();
4695
+ coords.forEach((point, nodeId) => {
4696
+ if (!this.params.staticNodeResolver(nodeId)) {
4697
+ this.canvas.updateNode(nodeId, point);
4698
+ }
4699
+ });
4700
+ this.params.onAfterApplied();
4701
+ }
4702
+ }
4724
4703
  class LayoutConfigurator {
4725
4704
  static configure(canvas, params) {
4726
4705
  const strategy = params.applyOn;
@@ -4766,6 +4745,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4766
4745
  this.win.requestAnimationFrame(this.step);
4767
4746
  }
4768
4747
  }
4748
+ class AnimatedLayoutApplier {
4749
+ constructor(canvas, layoutAlgorithm, params) {
4750
+ this.canvas = canvas;
4751
+ this.layoutAlgorithm = layoutAlgorithm;
4752
+ this.params = params;
4753
+ }
4754
+ apply(dt) {
4755
+ const coords = this.layoutAlgorithm.calculateNextCoordinates({
4756
+ graph: this.canvas.graph,
4757
+ viewport: this.canvas.viewport,
4758
+ dt
4759
+ });
4760
+ this.params.onBeforeApplied();
4761
+ coords.forEach((point, nodeId) => {
4762
+ if (!this.params.staticNodeResolver(nodeId)) {
4763
+ this.canvas.updateNode(nodeId, point);
4764
+ }
4765
+ });
4766
+ this.params.onAfterApplied();
4767
+ }
4768
+ }
4769
4769
  class AnimatedLayoutConfigurator {
4770
4770
  constructor(canvas, params, win) {
4771
4771
  __publicField(this, "applier");
@@ -4895,9 +4895,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4895
4895
  __publicField(this, "configurator");
4896
4896
  __publicField(this, "onCanvasSelected");
4897
4897
  __publicField(this, "selectionHandledTag", selectionHandled);
4898
- __publicField(this, "restore", () => {
4899
- this.configurator.disable(this.element);
4900
- });
4901
4898
  this.canvas = canvas;
4902
4899
  this.element = element;
4903
4900
  this.window = window2;
@@ -4919,7 +4916,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4919
4916
  }
4920
4917
  );
4921
4918
  this.configurator.enable(this.element);
4922
- this.canvas.onBeforeDestroy.subscribe(this.restore);
4919
+ this.canvas.onBeforeDestroy.subscribe(() => {
4920
+ this.configurator.disable(this.element);
4921
+ });
4923
4922
  }
4924
4923
  static configure(canvas, element, window2, pointInsideVerifier, eventTagger, params) {
4925
4924
  new UserSelectableCanvasConfigurator(
@@ -4972,22 +4971,38 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4972
4971
  this.element.removeChild(this.host);
4973
4972
  }
4974
4973
  }
4974
+ const forceDirectedDefaults = Object.freeze({
4975
+ seed: "HTMLGraph is awesome",
4976
+ maxTimeDeltaSec: 0.01,
4977
+ nodeCharge: 1e5,
4978
+ nodeMass: 1,
4979
+ edgeEquilibriumLength: 300,
4980
+ edgeStiffness: 1e3,
4981
+ dtSec: 0.01,
4982
+ maxIterations: 1e3,
4983
+ convergenceVelocity: 10,
4984
+ maxForce: 1e7,
4985
+ nodeForceCoefficient: 1,
4986
+ barnesHutAreaRadiusThreshold: 0.01,
4987
+ barnesHutTheta: 1
4988
+ });
4989
+ const selectionDefaults = Object.freeze({
4990
+ mouseDownEventVerifier: (event) => event.button === 0,
4991
+ mouseUpEventVerifier: (event) => event.button === 0,
4992
+ movementThreshold: 10
4993
+ });
4994
+ const noopFn = () => {
4995
+ };
4975
4996
  const createDraggableNodesParams = (config) => {
4976
4997
  var _a, _b, _c, _d, _e, _f;
4977
- const onNodeDragStarted = ((_a = config.events) == null ? void 0 : _a.onNodeDragStarted) ?? (() => {
4978
- });
4979
- const onNodeDrag = ((_b = config.events) == null ? void 0 : _b.onNodeDrag) ?? (() => {
4980
- });
4981
4998
  const nodeDragVerifier = config.nodeDragVerifier ?? (() => true);
4982
- const onNodeDragFinished = ((_c = config.events) == null ? void 0 : _c.onNodeDragFinished) ?? (() => {
4983
- });
4984
4999
  const moveOnTop = config.moveOnTop !== false;
4985
5000
  const moveEdgesOnTop = config.moveEdgesOnTop !== false && moveOnTop;
4986
- const cursor = (_d = config.mouse) == null ? void 0 : _d.dragCursor;
5001
+ const cursor = (_a = config.mouse) == null ? void 0 : _a.dragCursor;
4987
5002
  const dragCursor = cursor !== void 0 ? cursor : "grab";
4988
- const defaultMouseDownEventVerifier = (_e = config.mouse) == null ? void 0 : _e.mouseDownEventVerifier;
5003
+ const defaultMouseDownEventVerifier = (_b = config.mouse) == null ? void 0 : _b.mouseDownEventVerifier;
4989
5004
  const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
4990
- const defaultMouseUpEventVerifier = (_f = config.mouse) == null ? void 0 : _f.mouseUpEventVerifier;
5005
+ const defaultMouseUpEventVerifier = (_c = config.mouse) == null ? void 0 : _c.mouseUpEventVerifier;
4991
5006
  const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
4992
5007
  return {
4993
5008
  moveOnTop,
@@ -4996,10 +5011,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4996
5011
  gridSize: config.gridSize ?? null,
4997
5012
  mouseDownEventVerifier,
4998
5013
  mouseUpEventVerifier,
4999
- onNodeDragStarted,
5000
- onNodeDrag,
5014
+ onNodeDragStarted: ((_d = config.events) == null ? void 0 : _d.onNodeDragStarted) ?? noopFn,
5015
+ onNodeDrag: ((_e = config.events) == null ? void 0 : _e.onNodeDrag) ?? noopFn,
5001
5016
  nodeDragVerifier,
5002
- onNodeDragFinished
5017
+ onNodeDragFinished: ((_f = config.events) == null ? void 0 : _f.onNodeDragFinished) ?? noopFn
5003
5018
  };
5004
5019
  };
5005
5020
  const createShiftLimitTransformPreprocessor = (preprocessorParams) => {
@@ -5117,34 +5132,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5117
5132
  };
5118
5133
  }
5119
5134
  const shiftCursor = ((_b = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _b.cursor) !== void 0 ? transformConfig.shift.cursor : "grab";
5120
- const onBeforeTransformStarted = ((_c = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _c.onBeforeTransformChange) ?? (() => {
5121
- });
5122
- const onTransformFinished = ((_d = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _d.onTransformChange) ?? (() => {
5123
- });
5124
- const defaultMouseDownEventVerifier = (_e = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _e.mouseDownEventVerifier;
5135
+ const defaultMouseDownEventVerifier = (_c = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _c.mouseDownEventVerifier;
5125
5136
  const mouseDownEventVerifier = defaultMouseDownEventVerifier !== void 0 ? defaultMouseDownEventVerifier : (event) => event.button === 0;
5126
- const defaultMouseUpEventVerifier = (_f = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _f.mouseUpEventVerifier;
5137
+ const defaultMouseUpEventVerifier = (_d = transformConfig == null ? void 0 : transformConfig.shift) == null ? void 0 : _d.mouseUpEventVerifier;
5127
5138
  const mouseUpEventVerifier = defaultMouseUpEventVerifier !== void 0 ? defaultMouseUpEventVerifier : (event) => event.button === 0;
5128
- const defaultMouseWheelEventVerifier = (_g = transformConfig == null ? void 0 : transformConfig.scale) == null ? void 0 : _g.mouseWheelEventVerifier;
5139
+ const defaultMouseWheelEventVerifier = (_e = transformConfig == null ? void 0 : transformConfig.scale) == null ? void 0 : _e.mouseWheelEventVerifier;
5129
5140
  const mouseWheelEventVerifier = defaultMouseWheelEventVerifier !== void 0 ? defaultMouseWheelEventVerifier : () => true;
5130
5141
  return {
5131
5142
  wheelSensitivity,
5132
- onTransformStarted: ((_h = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _h.onTransformStarted) ?? (() => {
5133
- }),
5134
- onTransformFinished: ((_i = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _i.onTransformFinished) ?? (() => {
5135
- }),
5136
- onBeforeTransformChange: onBeforeTransformStarted,
5137
- onTransformChange: onTransformFinished,
5143
+ onTransformStarted: ((_f = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _f.onTransformStarted) ?? noopFn,
5144
+ onTransformFinished: ((_g = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _g.onTransformFinished) ?? noopFn,
5145
+ onBeforeTransformChange: ((_h = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _h.onBeforeTransformChange) ?? noopFn,
5146
+ onTransformChange: ((_i = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _i.onTransformChange) ?? noopFn,
5138
5147
  transformPreprocessor,
5139
5148
  shiftCursor,
5140
5149
  mouseDownEventVerifier,
5141
5150
  mouseUpEventVerifier,
5142
5151
  mouseWheelEventVerifier,
5143
5152
  scaleWheelFinishTimeout: ((_j = transformConfig == null ? void 0 : transformConfig.scale) == null ? void 0 : _j.wheelFinishTimeout) ?? 500,
5144
- onResizeTransformStarted: ((_k = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _k.onResizeTransformStarted) ?? (() => {
5145
- }),
5146
- onResizeTransformFinished: ((_l = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _l.onResizeTransformFinished) ?? (() => {
5147
- })
5153
+ onResizeTransformStarted: ((_k = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _k.onResizeTransformStarted) ?? noopFn,
5154
+ onResizeTransformFinished: ((_l = transformConfig == null ? void 0 : transformConfig.events) == null ? void 0 : _l.onResizeTransformFinished) ?? noopFn
5148
5155
  };
5149
5156
  };
5150
5157
  const createContent = (radius, color) => {
@@ -5252,34 +5259,35 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5252
5259
  });
5253
5260
  }
5254
5261
  };
5262
+ const defaults$3 = Object.freeze({
5263
+ connectionTypeResolver: () => "direct",
5264
+ connectionPreprocessor: (request) => request,
5265
+ connectionAllowedVerifier: () => true,
5266
+ mouseEventVerifier: (event) => event.button === 0
5267
+ });
5255
5268
  const createConnectablePortsParams = (config, defaultEdgeShapeFactory, defaultDragPortDirection) => {
5256
5269
  var _a, _b, _c;
5257
- const defaultConnectionTypeResolver = () => "direct";
5258
- const defaultConnectionPreprocessor = (request) => request;
5259
- const defaultMouseEventVerifier = (event) => event.button === 0;
5260
- const defaultOnAfterEdgeCreated = () => {
5261
- };
5262
- const defaultOnAfterEdgeConnectionPrevented = () => {
5263
- };
5264
- const defaultOnAfterEdgeConnectionInterrupted = () => {
5265
- };
5266
5270
  return {
5267
- connectionTypeResolver: config.connectionTypeResolver ?? defaultConnectionTypeResolver,
5268
- connectionPreprocessor: config.connectionPreprocessor ?? defaultConnectionPreprocessor,
5269
- mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaultMouseEventVerifier,
5270
- mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaultMouseEventVerifier,
5271
- onAfterEdgeCreated: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeCreated) ?? defaultOnAfterEdgeCreated,
5272
- onEdgeCreationInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeCreationInterrupted) ?? defaultOnAfterEdgeConnectionInterrupted,
5273
- onEdgeCreationPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeCreationPrevented) ?? defaultOnAfterEdgeConnectionPrevented,
5271
+ connectionTypeResolver: config.connectionTypeResolver ?? defaults$3.connectionTypeResolver,
5272
+ connectionPreprocessor: config.connectionPreprocessor ?? defaults$3.connectionPreprocessor,
5273
+ connectionAllowedVerifier: config.connectionAllowedVerifier ?? defaults$3.connectionAllowedVerifier,
5274
+ mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$3.mouseEventVerifier,
5275
+ mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$3.mouseEventVerifier,
5276
+ onAfterEdgeCreated: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeCreated) ?? noopFn,
5277
+ onEdgeCreationInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeCreationInterrupted) ?? noopFn,
5278
+ onEdgeCreationPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeCreationPrevented) ?? noopFn,
5274
5279
  dragPortDirection: config.dragPortDirection ?? defaultDragPortDirection,
5275
5280
  edgeShapeFactory: config.edgeShape !== void 0 ? resolveEdgeShapeFactory(config.edgeShape) : defaultEdgeShapeFactory
5276
5281
  };
5277
5282
  };
5283
+ const defaults$2 = Object.freeze({
5284
+ connectionAllowedVerifier: () => true,
5285
+ connectionPreprocessor: (request) => request,
5286
+ mouseDownEventVerifier: (event) => event.button === 0 && event.ctrlKey,
5287
+ mouseUpEventVerifier: (event) => event.button === 0
5288
+ });
5278
5289
  const createDraggableEdgeParams = (config, graph) => {
5279
5290
  var _a, _b, _c;
5280
- const defaultConnectionPreprocessor = (request) => request;
5281
- const defaultMouseDownEventVerifier = (event) => event.button === 0 && event.ctrlKey;
5282
- const defaultMouseUpEventVerifier = (event) => event.button === 0;
5283
5291
  const defaultDraggingEdgeResolver = (portId) => {
5284
5292
  const edgeIds = graph.getPortAdjacentEdgeIds(portId);
5285
5293
  if (edgeIds.length > 0) {
@@ -5288,21 +5296,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5288
5296
  return null;
5289
5297
  }
5290
5298
  };
5291
- const defaultOnAfterEdgeReattached = () => {
5292
- };
5293
- const defaultOnAfterEdgeReattachPrevented = () => {
5294
- };
5295
- const defaultOnAfterEdgeReattachInterrupted = () => {
5296
- };
5297
5299
  return {
5298
- connectionPreprocessor: config.connectionPreprocessor ?? defaultConnectionPreprocessor,
5299
- mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaultMouseDownEventVerifier,
5300
- mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaultMouseUpEventVerifier,
5300
+ connectionPreprocessor: config.connectionPreprocessor ?? defaults$2.connectionPreprocessor,
5301
+ connectionAllowedVerifier: config.connectionAllowedVerifier ?? defaults$2.connectionAllowedVerifier,
5302
+ mouseDownEventVerifier: config.mouseDownEventVerifier ?? defaults$2.mouseDownEventVerifier,
5303
+ mouseUpEventVerifier: config.mouseUpEventVerifier ?? defaults$2.mouseUpEventVerifier,
5301
5304
  draggingEdgeResolver: config.draggingEdgeResolver ?? defaultDraggingEdgeResolver,
5302
5305
  draggingEdgeShapeFactory: config.draggingEdgeShape !== void 0 ? resolveEdgeShapeFactory(config.draggingEdgeShape) : null,
5303
- onAfterEdgeReattached: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeReattached) ?? defaultOnAfterEdgeReattached,
5304
- onEdgeReattachInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeReattachInterrupted) ?? defaultOnAfterEdgeReattachInterrupted,
5305
- onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ?? defaultOnAfterEdgeReattachPrevented
5306
+ onAfterEdgeReattached: ((_a = config.events) == null ? void 0 : _a.onAfterEdgeReattached) ?? noopFn,
5307
+ onEdgeReattachInterrupted: ((_b = config.events) == null ? void 0 : _b.onEdgeReattachInterrupted) ?? noopFn,
5308
+ onEdgeReattachPrevented: ((_c = config.events) == null ? void 0 : _c.onEdgeReattachPrevented) ?? noopFn
5306
5309
  };
5307
5310
  };
5308
5311
  const createVirtualScrollParams = (config) => {
@@ -5314,10 +5317,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5314
5317
  const createVirtualScrollHtmlViewParams = (config) => {
5315
5318
  var _a, _b;
5316
5319
  return {
5317
- onAfterNodeDetached: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onAfterNodeDetached) ?? (() => {
5318
- }),
5319
- onBeforeNodeAttached: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onBeforeNodeAttached) ?? (() => {
5320
- })
5320
+ onAfterNodeDetached: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onAfterNodeDetached) ?? noopFn,
5321
+ onBeforeNodeAttached: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onBeforeNodeAttached) ?? noopFn
5321
5322
  };
5322
5323
  };
5323
5324
  class CanvasBuilderError extends Error {
@@ -6328,26 +6329,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6328
6329
  return (t >>> 0) / 4294967296;
6329
6330
  };
6330
6331
  };
6331
- const forceDirectedDefaults = Object.freeze({
6332
- seed: "HTMLGraph is awesome",
6333
- maxTimeDeltaSec: 0.01,
6334
- nodeCharge: 1e5,
6335
- nodeMass: 1,
6336
- edgeEquilibriumLength: 300,
6337
- edgeStiffness: 1e3,
6338
- dtSec: 0.01,
6339
- maxIterations: 1e3,
6340
- convergenceVelocity: 10,
6341
- maxForce: 1e7,
6342
- nodeForceCoefficient: 1,
6343
- barnesHutAreaRadiusThreshold: 0.01,
6344
- barnesHutTheta: 1
6345
- });
6346
- const selectionDefaults = Object.freeze({
6347
- mouseDownEventVerifier: (event) => event.button === 0,
6348
- mouseUpEventVerifier: (event) => event.button === 0,
6349
- movementThreshold: 10
6350
- });
6351
6332
  const resolveAnimatedLayoutAlgorithm = (config) => {
6352
6333
  var _a, _b;
6353
6334
  switch (config == null ? void 0 : config.type) {
@@ -6374,11 +6355,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6374
6355
  }
6375
6356
  };
6376
6357
  const defaults$1 = {
6377
- staticNodeResolver: () => false,
6378
- onBeforeApplied: () => {
6379
- },
6380
- onAfterApplied: () => {
6381
- }
6358
+ staticNodeResolver: () => false
6382
6359
  };
6383
6360
  const createAnimatedLayoutParams = (config) => {
6384
6361
  var _a, _b;
@@ -6386,8 +6363,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6386
6363
  return {
6387
6364
  algorithm,
6388
6365
  staticNodeResolver: (config == null ? void 0 : config.staticNodeResolver) ?? defaults$1.staticNodeResolver,
6389
- onBeforeApplied: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onBeforeApplied) ?? defaults$1.onBeforeApplied,
6390
- onAfterApplied: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onAfterApplied) ?? defaults$1.onAfterApplied
6366
+ onBeforeApplied: ((_a = config == null ? void 0 : config.events) == null ? void 0 : _a.onBeforeApplied) ?? noopFn,
6367
+ onAfterApplied: ((_b = config == null ? void 0 : config.events) == null ? void 0 : _b.onAfterApplied) ?? noopFn
6391
6368
  };
6392
6369
  };
6393
6370
  const resolveLayoutApplyOn = (applyOn) => {
@@ -6410,10 +6387,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6410
6387
  };
6411
6388
  const defaults = Object.freeze({
6412
6389
  staticNodeResolver: () => false,
6413
- onBeforeApplied: () => {
6414
- },
6415
- onAfterApplied: () => {
6416
- },
6417
6390
  hierarchicalLayout: {
6418
6391
  layerWidth: 300,
6419
6392
  layerSpace: 300
@@ -6620,8 +6593,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6620
6593
  algorithm: resolveLayoutAlgorithm(config.algorithm),
6621
6594
  applyOn: resolveLayoutApplyOn(config.applyOn),
6622
6595
  staticNodeResolver: config.staticNodeResolver ?? defaults.staticNodeResolver,
6623
- onBeforeApplied: ((_a = config.events) == null ? void 0 : _a.onBeforeApplied) ?? defaults.onBeforeApplied,
6624
- onAfterApplied: ((_b = config.events) == null ? void 0 : _b.onAfterApplied) ?? defaults.onAfterApplied
6596
+ onBeforeApplied: ((_a = config.events) == null ? void 0 : _a.onBeforeApplied) ?? noopFn,
6597
+ onAfterApplied: ((_b = config.events) == null ? void 0 : _b.onAfterApplied) ?? noopFn
6625
6598
  };
6626
6599
  };
6627
6600
  const patchAnimatedLayoutDraggableNodesParams = (params, staticNodes) => {
@@ -7002,9 +6975,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7002
6975
  LayoutConfigurator.configure(canvas, layoutParams);
7003
6976
  }
7004
6977
  if (this.hasAnimatedLayout) {
7005
- let config = createAnimatedLayoutParams(
7006
- this.animatedLayoutConfig
7007
- );
6978
+ let config = createAnimatedLayoutParams(this.animatedLayoutConfig);
7008
6979
  if (this.hasDraggableNodes) {
7009
6980
  subscribeAnimatedLayoutStaticNodesUpdate(
7010
6981
  canvas,
@@ -7017,11 +6988,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
7017
6988
  }
7018
6989
  AnimatedLayoutConfigurator.configure(canvas, config, this.window);
7019
6990
  }
7020
- const onBeforeDestroy = () => {
6991
+ canvas.onBeforeDestroy.subscribe(() => {
7021
6992
  layers.destroy();
7022
- canvas.onBeforeDestroy.unsubscribe(onBeforeDestroy);
7023
- };
7024
- canvas.onBeforeDestroy.subscribe(onBeforeDestroy);
6993
+ });
7025
6994
  return canvas;
7026
6995
  }
7027
6996
  createHtmlView(host, graphStore, viewportStore) {