@finos/legend-extension-dsl-diagram 7.1.48 → 7.1.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/lib/DiagramRenderer.d.ts +6 -1
  2. package/lib/DiagramRenderer.d.ts.map +1 -1
  3. package/lib/DiagramRenderer.js +44 -27
  4. package/lib/DiagramRenderer.js.map +1 -1
  5. package/lib/application/studio/DSL_Diagram_LegendStudioTesting.d.ts +2 -1
  6. package/lib/application/studio/DSL_Diagram_LegendStudioTesting.d.ts.map +1 -1
  7. package/lib/application/studio/DSL_Diagram_LegendStudioTesting.js +1 -0
  8. package/lib/application/studio/DSL_Diagram_LegendStudioTesting.js.map +1 -1
  9. package/lib/components/studio/DiagramEditor.d.ts.map +1 -1
  10. package/lib/components/studio/DiagramEditor.js +2 -1
  11. package/lib/components/studio/DiagramEditor.js.map +1 -1
  12. package/lib/graph/helpers/DSL_Diagram_Helper.d.ts.map +1 -1
  13. package/lib/graph/helpers/DSL_Diagram_Helper.js +5 -3
  14. package/lib/graph/helpers/DSL_Diagram_Helper.js.map +1 -1
  15. package/lib/graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_RelationshipView.d.ts.map +1 -1
  16. package/lib/graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_RelationshipView.js +5 -5
  17. package/lib/graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_RelationshipView.js.map +1 -1
  18. package/lib/graphManager/protocol/pure/DSL_Diagram_PureProtocolProcessorPlugin.js +1 -1
  19. package/lib/graphManager/protocol/pure/DSL_Diagram_PureProtocolProcessorPlugin.js.map +1 -1
  20. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSL_Diagram_GraphBuilderHelper.d.ts +1 -1
  21. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSL_Diagram_GraphBuilderHelper.d.ts.map +1 -1
  22. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSL_Diagram_GraphBuilderHelper.js +20 -4
  23. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSL_Diagram_GraphBuilderHelper.js.map +1 -1
  24. package/lib/index.css +1 -1
  25. package/lib/package.json +1 -1
  26. package/package.json +8 -8
  27. package/src/DiagramRenderer.ts +100 -36
  28. package/src/application/studio/DSL_Diagram_LegendStudioTesting.ts +1 -0
  29. package/src/components/studio/DiagramEditor.tsx +2 -0
  30. package/src/graph/helpers/DSL_Diagram_Helper.ts +11 -3
  31. package/src/graph/metamodel/pure/packageableElements/diagram/DSL_Diagram_RelationshipView.ts +5 -5
  32. package/src/graphManager/protocol/pure/DSL_Diagram_PureProtocolProcessorPlugin.ts +1 -1
  33. package/src/graphManager/protocol/pure/v1/transformation/pureGraph/V1_DSL_Diagram_GraphBuilderHelper.ts +19 -2
@@ -929,6 +929,20 @@ export class DiagramRenderer {
929
929
  );
930
930
  }
931
931
 
932
+ /**
933
+ * Mouse events' coordinate x,y are relative to the viewport, not the canvas element
934
+ * so we need to calculate them relative to the canvas element
935
+ */
936
+ resolveMouseEventCoordinate(e: MouseEvent): Point {
937
+ if (e.target instanceof HTMLElement) {
938
+ const targetEl = getElementPosition(e.target);
939
+ return new Point(targetEl.x + e.offsetX, targetEl.y + e.offsetY);
940
+ }
941
+ // NOTE: this is a fallback, should not happen
942
+ // since all mouse events shoud target the canvas element
943
+ return new Point(e.x, e.y);
944
+ }
945
+
932
946
  eventCoordinateToCanvasCoordinate(point: Point): Point {
933
947
  return new Point(
934
948
  point.x - this.divPosition.x + this.div.scrollLeft,
@@ -987,8 +1001,14 @@ export class DiagramRenderer {
987
1001
  const box = this.drawLinePropertyText(
988
1002
  // NOTE: by the way we compute the full path, it would guarantee
989
1003
  // to always have at least 2 points
990
- fullPath[fullPath.length - 2] as Point,
991
- fullPath[fullPath.length - 1] as Point,
1004
+ guaranteeNonNullable(
1005
+ fullPath[fullPath.length - 2],
1006
+ 'Diagram path expected to have at least 2 points',
1007
+ ),
1008
+ guaranteeNonNullable(
1009
+ fullPath[fullPath.length - 1],
1010
+ 'Diagram path expected to have at least 2 points',
1011
+ ),
992
1012
  relationshipView.to.classView.value,
993
1013
  relationshipView.property.value,
994
1014
  false,
@@ -1039,19 +1059,14 @@ export class DiagramRenderer {
1039
1059
  // NOTE: we cap the minimum zoom level to avoid negative zoom
1040
1060
  newZoomLevel = Math.max(newZoomLevel, MIN_ZOOM_LEVEL);
1041
1061
 
1042
- const canvasZoomCenterPosition = this.canvasCoordinateToModelCoordinate(
1043
- this.eventCoordinateToCanvasCoordinate(point),
1044
- );
1045
1062
  const currentZoomLevel = this.zoom;
1046
1063
  this.setZoomLevel(newZoomLevel);
1047
1064
 
1048
1065
  this.screenOffset = new Point(
1049
- ((canvasZoomCenterPosition.x - this.canvasCenter.x) *
1050
- (currentZoomLevel - newZoomLevel) +
1066
+ ((point.x - this.canvasCenter.x) * (currentZoomLevel - newZoomLevel) +
1051
1067
  this.screenOffset.x * currentZoomLevel) /
1052
1068
  newZoomLevel,
1053
- ((canvasZoomCenterPosition.y - this.canvasCenter.y) *
1054
- (currentZoomLevel - newZoomLevel) +
1069
+ ((point.y - this.canvasCenter.y) * (currentZoomLevel - newZoomLevel) +
1055
1070
  this.screenOffset.y * currentZoomLevel) /
1056
1071
  newZoomLevel,
1057
1072
  );
@@ -1060,7 +1075,7 @@ export class DiagramRenderer {
1060
1075
  this.drawAll();
1061
1076
  }
1062
1077
 
1063
- zoomPoint(zoomLevel: number, zoomPoint: Point): void {
1078
+ private zoomPoint(zoomLevel: number, zoomPoint: Point): void {
1064
1079
  this.executeZoom(zoomLevel, zoomPoint);
1065
1080
  }
1066
1081
 
@@ -2068,8 +2083,14 @@ export class DiagramRenderer {
2068
2083
  this.drawLinePropertyText(
2069
2084
  // NOTE: by the way we compute the full path, it would guarantee
2070
2085
  // to always have at least 2 points
2071
- fullPath[fullPath.length - 2] as Point,
2072
- fullPath[fullPath.length - 1] as Point,
2086
+ guaranteeNonNullable(
2087
+ fullPath[fullPath.length - 2],
2088
+ 'Diagram path expected to have at least 2 points',
2089
+ ),
2090
+ guaranteeNonNullable(
2091
+ fullPath[fullPath.length - 1],
2092
+ 'Diagram path expected to have at least 2 points',
2093
+ ),
2073
2094
  propertyView.to.classView.value,
2074
2095
  toProperty,
2075
2096
  false,
@@ -2240,10 +2261,22 @@ export class DiagramRenderer {
2240
2261
  );
2241
2262
  // NOTE: by the way we compute the full path, it would guarantee
2242
2263
  // to always have at least 2 points
2243
- const startX = (fullPath[fullPath.length - 2] as Point).x;
2244
- const startY = (fullPath[fullPath.length - 2] as Point).y;
2245
- const endX = (fullPath[fullPath.length - 1] as Point).x;
2246
- const endY = (fullPath[fullPath.length - 1] as Point).y;
2264
+ const startX = guaranteeNonNullable(
2265
+ fullPath[fullPath.length - 2],
2266
+ 'Diagram path expected to have at least 2 points',
2267
+ ).x;
2268
+ const startY = guaranteeNonNullable(
2269
+ fullPath[fullPath.length - 2],
2270
+ 'Diagram path expected to have at least 2 points',
2271
+ ).y;
2272
+ const endX = guaranteeNonNullable(
2273
+ fullPath[fullPath.length - 1],
2274
+ 'Diagram path expected to have at least 2 points',
2275
+ ).x;
2276
+ const endY = guaranteeNonNullable(
2277
+ fullPath[fullPath.length - 1],
2278
+ 'Diagram path expected to have at least 2 points',
2279
+ ).y;
2247
2280
  let resultX = 0;
2248
2281
  let resultY = 0;
2249
2282
  if (endY > startY) {
@@ -2841,6 +2874,8 @@ export class DiagramRenderer {
2841
2874
  }
2842
2875
 
2843
2876
  mouseup(e: MouseEvent): void {
2877
+ const mouseEventCoordinate = this.resolveMouseEventCoordinate(e);
2878
+
2844
2879
  if (!this.isReadOnly) {
2845
2880
  switch (this.interactionMode) {
2846
2881
  case DIAGRAM_INTERACTION_MODE.LAYOUT: {
@@ -2858,7 +2893,7 @@ export class DiagramRenderer {
2858
2893
  case DIAGRAM_INTERACTION_MODE.ADD_CLASS: {
2859
2894
  const eventPointInModelCoordinate =
2860
2895
  this.canvasCoordinateToModelCoordinate(
2861
- this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y)),
2896
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
2862
2897
  );
2863
2898
  this.onAddClassViewClick(eventPointInModelCoordinate);
2864
2899
  this.changeMode(
@@ -2889,7 +2924,12 @@ export class DiagramRenderer {
2889
2924
  ),
2890
2925
  );
2891
2926
  }
2892
- this.zoomPoint(nextZoomLevel / 100, new Point(e.x, e.y));
2927
+ this.zoomPoint(
2928
+ nextZoomLevel / 100,
2929
+ this.canvasCoordinateToModelCoordinate(
2930
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
2931
+ ),
2932
+ );
2893
2933
  break;
2894
2934
  }
2895
2935
  case DIAGRAM_INTERACTION_MODE.ZOOM_OUT: {
@@ -2911,7 +2951,12 @@ export class DiagramRenderer {
2911
2951
  ),
2912
2952
  );
2913
2953
  }
2914
- this.zoomPoint(nextZoomLevel / 100, new Point(e.x, e.y));
2954
+ this.zoomPoint(
2955
+ nextZoomLevel / 100,
2956
+ this.canvasCoordinateToModelCoordinate(
2957
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
2958
+ ),
2959
+ );
2915
2960
  break;
2916
2961
  }
2917
2962
  case DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP: {
@@ -2922,7 +2967,7 @@ export class DiagramRenderer {
2922
2967
  ) {
2923
2968
  const eventPointInModelCoordinate =
2924
2969
  this.canvasCoordinateToModelCoordinate(
2925
- this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y)),
2970
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
2926
2971
  );
2927
2972
  for (let i = this.diagram.classViews.length - 1; i >= 0; i--) {
2928
2973
  const targetClassView = this.diagram.classViews[i] as ClassView;
@@ -2995,6 +3040,8 @@ export class DiagramRenderer {
2995
3040
  }
2996
3041
 
2997
3042
  mousedblclick(e: MouseEvent): void {
3043
+ const mouseEventCoordinate = this.resolveMouseEventCoordinate(e);
3044
+
2998
3045
  if (
2999
3046
  [
3000
3047
  DIAGRAM_INTERACTION_MODE.ADD_RELATIONSHIP,
@@ -3007,7 +3054,7 @@ export class DiagramRenderer {
3007
3054
  }
3008
3055
 
3009
3056
  const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(
3010
- this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y)),
3057
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
3011
3058
  );
3012
3059
 
3013
3060
  // Check double click on class property
@@ -3066,6 +3113,8 @@ export class DiagramRenderer {
3066
3113
  }
3067
3114
 
3068
3115
  mousedown(e: MouseEvent): void {
3116
+ const mouseEventCoordinate = this.resolveMouseEventCoordinate(e);
3117
+
3069
3118
  this.setSelectionStart(undefined);
3070
3119
  this.setSelectedClassCorner(undefined);
3071
3120
  this.setSelectedPropertyOrAssociation(undefined);
@@ -3075,9 +3124,8 @@ export class DiagramRenderer {
3075
3124
  this.selectedPoint = undefined;
3076
3125
  this.startClassView = undefined;
3077
3126
 
3078
- const eventPointInCanvasCoordinate = this.eventCoordinateToCanvasCoordinate(
3079
- new Point(e.x, e.y),
3080
- );
3127
+ const eventPointInCanvasCoordinate =
3128
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate);
3081
3129
  const eventPointInModelCoordinate = this.canvasCoordinateToModelCoordinate(
3082
3130
  eventPointInCanvasCoordinate,
3083
3131
  );
@@ -3088,7 +3136,7 @@ export class DiagramRenderer {
3088
3136
 
3089
3137
  switch (this.interactionMode) {
3090
3138
  case DIAGRAM_INTERACTION_MODE.PAN: {
3091
- this.positionBeforeLastMove = new Point(e.x, e.y);
3139
+ this.positionBeforeLastMove = mouseEventCoordinate;
3092
3140
  return;
3093
3141
  }
3094
3142
  case DIAGRAM_INTERACTION_MODE.LAYOUT: {
@@ -3275,13 +3323,13 @@ export class DiagramRenderer {
3275
3323
  // middle click
3276
3324
  else if (e.button === 1) {
3277
3325
  this.setMiddleClick(true);
3278
- this.positionBeforeLastMove = new Point(e.x, e.y);
3326
+ this.positionBeforeLastMove = mouseEventCoordinate;
3279
3327
  return;
3280
3328
  }
3281
3329
  // right click
3282
3330
  else if (e.button === 2) {
3283
3331
  this.setRightClick(true);
3284
- this.positionBeforeLastMove = new Point(e.x, e.y);
3332
+ this.positionBeforeLastMove = mouseEventCoordinate;
3285
3333
  if (this.mouseOverClassView) {
3286
3334
  this.onClassViewRightClick(
3287
3335
  this.mouseOverClassView,
@@ -3296,6 +3344,8 @@ export class DiagramRenderer {
3296
3344
  }
3297
3345
 
3298
3346
  mousewheel(e: WheelEvent): void {
3347
+ const mouseEventCoordinate = this.resolveMouseEventCoordinate(e);
3348
+
3299
3349
  // no scrolling to be done since we want to convert scroll into zoom
3300
3350
  e.preventDefault();
3301
3351
  e.stopImmediatePropagation();
@@ -3306,11 +3356,17 @@ export class DiagramRenderer {
3306
3356
  }
3307
3357
  // scroll down to zoom in and up to zoom out
3308
3358
  const newZoomLevel = this.zoom - (e.deltaY / 120) * 0.05;
3309
- this.executeZoom(newZoomLevel, new Point(e.x, e.y));
3359
+ this.executeZoom(
3360
+ newZoomLevel,
3361
+ this.canvasCoordinateToModelCoordinate(
3362
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate),
3363
+ ),
3364
+ );
3310
3365
  }
3311
3366
 
3312
3367
  mousemove(e: MouseEvent): void {
3313
- this.cursorPosition = new Point(e.x, e.y);
3368
+ const mouseEventCoordinate = this.resolveMouseEventCoordinate(e);
3369
+ this.cursorPosition = mouseEventCoordinate;
3314
3370
 
3315
3371
  // Pan/Move
3316
3372
  if (
@@ -3319,15 +3375,17 @@ export class DiagramRenderer {
3319
3375
  (this.leftClick && this.interactionMode === DIAGRAM_INTERACTION_MODE.PAN)
3320
3376
  ) {
3321
3377
  this.screenOffset = new Point(
3322
- this.screenOffset.x + (e.x - this.positionBeforeLastMove.x) / this.zoom,
3323
- this.screenOffset.y + (e.y - this.positionBeforeLastMove.y) / this.zoom,
3378
+ this.screenOffset.x +
3379
+ (mouseEventCoordinate.x - this.positionBeforeLastMove.x) / this.zoom,
3380
+ this.screenOffset.y +
3381
+ (mouseEventCoordinate.y - this.positionBeforeLastMove.y) / this.zoom,
3324
3382
  );
3325
- this.positionBeforeLastMove = new Point(e.x, e.y);
3383
+ this.positionBeforeLastMove = mouseEventCoordinate;
3326
3384
  this.clearScreen();
3327
3385
  this.drawAll();
3328
3386
  } else if (this.leftClick) {
3329
3387
  const eventPointInCanvasCoordinate =
3330
- this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y));
3388
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate);
3331
3389
  const eventPointInModelCoordinate =
3332
3390
  this.canvasCoordinateToModelCoordinate(eventPointInCanvasCoordinate);
3333
3391
 
@@ -3509,7 +3567,7 @@ export class DiagramRenderer {
3509
3567
  this.drawScreen();
3510
3568
 
3511
3569
  const eventPointInCanvasCoordinate =
3512
- this.eventCoordinateToCanvasCoordinate(new Point(e.x, e.y));
3570
+ this.eventCoordinateToCanvasCoordinate(mouseEventCoordinate);
3513
3571
  const eventPointInModelCoordinate =
3514
3572
  this.canvasCoordinateToModelCoordinate(eventPointInCanvasCoordinate);
3515
3573
 
@@ -3639,8 +3697,14 @@ export class DiagramRenderer {
3639
3697
  const propertyInfoBox = this.drawLinePropertyText(
3640
3698
  // NOTE: by the way we compute the full path, it would guarantee
3641
3699
  // to always have at least 2 points
3642
- fullPath[fullPath.length - 2] as Point,
3643
- fullPath[fullPath.length - 1] as Point,
3700
+ guaranteeNonNullable(
3701
+ fullPath[fullPath.length - 2],
3702
+ 'Diagram path expected to have at least 2 points',
3703
+ ),
3704
+ guaranteeNonNullable(
3705
+ fullPath[fullPath.length - 1],
3706
+ 'Diagram path expected to have at least 2 points',
3707
+ ),
3644
3708
  propertyHolderView.to.classView.value,
3645
3709
  propertyHolderView.property.value,
3646
3710
  false,
@@ -16,4 +16,5 @@
16
16
 
17
17
  export enum DSL_DIAGRAM_TEST_ID {
18
18
  CLASS_DIAGRAM_PREVIEW = 'class-diagram-preview',
19
+ DIAGRAM_EDITOR = 'diagram-editor',
19
20
  }
@@ -117,6 +117,7 @@ import {
117
117
  classView_setHideTaggedValues,
118
118
  } from '../../stores/studio/DSL_Diagram_GraphModifierHelper.js';
119
119
  import { DSL_DIAGRAM_LEGEND_STUDIO_APPLICATION_NAVIGATION_CONTEXT_KEY } from '../../application/studio/DSL_Diagram_LegendStudioApplicationNavigationContext.js';
120
+ import { DSL_DIAGRAM_TEST_ID } from '../../application/studio/DSL_Diagram_LegendStudioTesting.js';
120
121
 
121
122
  const DiagramEditorContextMenu = observer(
122
123
  forwardRef<
@@ -1251,6 +1252,7 @@ const DiagramEditorDiagramCanvas = observer(
1251
1252
  'diagram-canvas diagram-editor__canvas',
1252
1253
  diagramEditorState.diagramCursorClass,
1253
1254
  )}
1255
+ data-testid={DSL_DIAGRAM_TEST_ID.DIAGRAM_EDITOR}
1254
1256
  tabIndex={0}
1255
1257
  />
1256
1258
  );
@@ -21,7 +21,7 @@ import {
21
21
  Class,
22
22
  getAllOwnClassProperties,
23
23
  } from '@finos/legend-graph';
24
- import { deleteEntry } from '@finos/legend-shared';
24
+ import { deleteEntry, guaranteeNonNullable } from '@finos/legend-shared';
25
25
  import type { ClassView } from '../metamodel/pure/packageableElements/diagram/DSL_Diagram_ClassView.js';
26
26
  import type { Diagram } from '../metamodel/pure/packageableElements/diagram/DSL_Diagram_Diagram.js';
27
27
  import { PositionedRectangle } from '../metamodel/pure/packageableElements/diagram/geometry/DSL_Diagram_PositionedRectangle.js';
@@ -146,8 +146,16 @@ export const _relationshipView_simplifyPath = (
146
146
  // if it does we will update the offset
147
147
  if (newPath[0] !== fullPath[0]) {
148
148
  const center = relationshipView.from.classView.value.center();
149
- relationshipView.from._offsetX = (newPath[0] as Point).x - center.x;
150
- relationshipView.from._offsetY = (newPath[0] as Point).y - center.y;
149
+ relationshipView.from._offsetX =
150
+ guaranteeNonNullable(
151
+ newPath[0],
152
+ 'Diagram path expected to have at least 2 points',
153
+ ).x - center.x;
154
+ relationshipView.from._offsetY =
155
+ guaranteeNonNullable(
156
+ newPath[0],
157
+ 'Diagram path expected to have at least 2 points',
158
+ ).y - center.y;
151
159
  }
152
160
 
153
161
  if (newPath[newPath.length - 1] !== fullPath[fullPath.length - 1]) {
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { hashArray, type Hashable } from '@finos/legend-shared';
17
+ import { hashArray, type Hashable, assertTrue } from '@finos/legend-shared';
18
18
  import { RelationshipViewEnd } from './DSL_Diagram_RelationshipViewEnd.js';
19
19
  import { Point } from './geometry/DSL_Diagram_Point.js';
20
20
  import type { ClassView } from './DSL_Diagram_ClassView.js';
@@ -98,9 +98,7 @@ export class RelationshipView implements Hashable {
98
98
  from: ClassView,
99
99
  to: ClassView,
100
100
  ): Point[] => {
101
- if (!path.length) {
102
- return [];
103
- }
101
+ assertTrue(Boolean(path.length), 'Path requires at least 1 point');
104
102
 
105
103
  let start = 0;
106
104
  let startPoint = path[start] as Point;
@@ -125,7 +123,9 @@ export class RelationshipView implements Hashable {
125
123
  }
126
124
 
127
125
  // NOTE: slice upper bound is exclusive, hence the +2 instead of +1
128
- return path.slice(start - 1, end + 2);
126
+ const newPath = path.slice(start - 1, end + 2);
127
+ // In the event we have trimmed all paths, we will return start and end point to ensure the path still contains 2 points
128
+ return newPath.length < 2 ? [startPoint, endPoint] : newPath;
129
129
  };
130
130
 
131
131
  // TODO: to be simplified out of metamodel
@@ -98,7 +98,7 @@ export class DSL_Diagram_PureProtocolProcessorPlugin extends PureProtocolProcess
98
98
  );
99
99
  element.generalizationViews = elementProtocol.generalizationViews.map(
100
100
  (generalizationView) =>
101
- V1_buildGeneralizationView(generalizationView, element),
101
+ V1_buildGeneralizationView(generalizationView, element, context),
102
102
  );
103
103
  },
104
104
  }),
@@ -20,6 +20,8 @@ import type {
20
20
  V1_GraphBuilderContext,
21
21
  } from '@finos/legend-graph';
22
22
  import {
23
+ LogEvent,
24
+ assertErrorThrown,
23
25
  assertNonEmptyString,
24
26
  assertNonNullable,
25
27
  guaranteeNonNullable,
@@ -118,13 +120,21 @@ export const V1_buildPropertyView = (
118
120
  targetClassView,
119
121
  );
120
122
  view.path = propertyView.line.points.map((point) => buildPoint(point));
121
- _relationshipView_simplifyPath(view); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
123
+ // transform the line because we store only 2 end points that are inside points and we will calculate the offset
124
+ try {
125
+ _relationshipView_simplifyPath(view);
126
+ } catch (error) {
127
+ // NOTE: this is an optimization to simplify the path, so we should not break graph building if this fails
128
+ assertErrorThrown(error);
129
+ context.logService.warn(LogEvent.create(error.message));
130
+ }
122
131
  return view;
123
132
  };
124
133
 
125
134
  export const V1_buildGeneralizationView = (
126
135
  generalizationView: V1_GeneralizationView,
127
136
  diagram: Diagram,
137
+ context: V1_GraphBuilderContext,
128
138
  ): GeneralizationView => {
129
139
  assertNonNullable(
130
140
  generalizationView.line,
@@ -144,7 +154,14 @@ export const V1_buildGeneralizationView = (
144
154
  targetClassView,
145
155
  );
146
156
  view.path = generalizationView.line.points.map((point) => buildPoint(point));
147
- _relationshipView_simplifyPath(view); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
157
+ // transform the line because we store only 2 end points that are inside points and we will calculate the offset
158
+ try {
159
+ _relationshipView_simplifyPath(view);
160
+ } catch (error) {
161
+ // NOTE: this is an optimization to simplify the path, so we should not break graph building if this fails
162
+ assertErrorThrown(error);
163
+ context.logService.warn(LogEvent.create(error.message));
164
+ }
148
165
  return view;
149
166
  };
150
167