@finos/legend-extension-dsl-diagram 0.1.0 → 1.0.2

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/DSLDiagram_Extension.d.ts +0 -5
  3. package/lib/DSLDiagram_Extension.d.ts.map +1 -1
  4. package/lib/DSLDiagram_Extension.js +0 -12
  5. package/lib/DSLDiagram_Extension.js.map +1 -1
  6. package/lib/DiagramRenderer.d.ts.map +1 -1
  7. package/lib/DiagramRenderer.js +76 -50
  8. package/lib/DiagramRenderer.js.map +1 -1
  9. package/lib/components/studio/ClassDiagramPreview.js +1 -1
  10. package/lib/components/studio/ClassDiagramPreview.js.map +1 -1
  11. package/lib/components/studio/{DSLDiagram_StudioPlugin.d.ts → DSLDiagram_LegendStudioPlugin.d.ts} +5 -5
  12. package/lib/components/studio/DSLDiagram_LegendStudioPlugin.d.ts.map +1 -0
  13. package/lib/components/studio/{DSLDiagram_StudioPlugin.js → DSLDiagram_LegendStudioPlugin.js} +4 -4
  14. package/lib/components/studio/DSLDiagram_LegendStudioPlugin.js.map +1 -0
  15. package/lib/components/studio/{DSLDiagram_StudioPlugin_Extension.d.ts → DSLDiagram_LegendStudioPlugin_Extension.d.ts} +3 -3
  16. package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.d.ts.map +1 -0
  17. package/lib/components/studio/{DSLDiagram_StudioPlugin_Extension.js → DSLDiagram_LegendStudioPlugin_Extension.js} +1 -1
  18. package/lib/components/studio/DSLDiagram_LegendStudioPlugin_Extension.js.map +1 -0
  19. package/lib/components/studio/DiagramEditor.js +36 -36
  20. package/lib/components/studio/DiagramEditor.js.map +1 -1
  21. package/lib/index.css +1 -1
  22. package/lib/index.css.map +1 -1
  23. package/lib/index.d.ts +2 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +2 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.d.ts.map +1 -1
  28. package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.js +3 -0
  29. package/lib/models/metamodels/pure/packageableElements/diagram/RelationshipView.js.map +1 -1
  30. package/lib/stores/studio/DiagramEditorState.d.ts.map +1 -1
  31. package/lib/stores/studio/DiagramEditorState.js +3 -3
  32. package/lib/stores/studio/DiagramEditorState.js.map +1 -1
  33. package/package.json +15 -16
  34. package/src/DSLDiagram_Extension.ts +0 -15
  35. package/src/DiagramRenderer.ts +94 -73
  36. package/src/components/studio/{DSLDiagram_StudioPlugin.tsx → DSLDiagram_LegendStudioPlugin.tsx} +7 -7
  37. package/src/components/studio/{DSLDiagram_StudioPlugin_Extension.tsx → DSLDiagram_LegendStudioPlugin_Extension.tsx} +3 -3
  38. package/src/components/studio/DiagramEditor.tsx +2 -2
  39. package/src/index.ts +3 -1
  40. package/src/models/metamodels/pure/packageableElements/diagram/RelationshipView.ts +24 -14
  41. package/src/stores/studio/DiagramEditorState.ts +3 -7
  42. package/tsconfig.json +3 -2
  43. package/tsconfig.package.json +1 -0
  44. package/lib/components/studio/DSLDiagram_StudioPlugin.d.ts.map +0 -1
  45. package/lib/components/studio/DSLDiagram_StudioPlugin.js.map +0 -1
  46. package/lib/components/studio/DSLDiagram_StudioPlugin_Extension.d.ts.map +0 -1
  47. package/lib/components/studio/DSLDiagram_StudioPlugin_Extension.js.map +0 -1
@@ -33,20 +33,24 @@ export const manageInsidePointsDynamically = (
33
33
  from: ClassView,
34
34
  to: ClassView,
35
35
  ): Point[] => {
36
+ if (!path.length) {
37
+ return [];
38
+ }
39
+
36
40
  let start = 0;
37
- let startPoint = path[start];
41
+ let startPoint = path[start] as Point;
38
42
 
39
43
  while (start < path.length - 1 && from.contains(startPoint.x, startPoint.y)) {
40
44
  start++;
41
- startPoint = path[start];
45
+ startPoint = path[start] as Point;
42
46
  }
43
47
 
44
48
  let end = path.length - 1;
45
- let endPoint = path[end];
49
+ let endPoint = path[end] as Point;
46
50
 
47
51
  while (end > 0 && to.contains(endPoint.x, endPoint.y)) {
48
52
  end--;
49
- endPoint = path[end];
53
+ endPoint = path[end] as Point;
50
54
  }
51
55
 
52
56
  return path.slice(start - 1, end + 2);
@@ -123,25 +127,31 @@ export class RelationshipView implements Hashable {
123
127
  // if it does we will update the offset
124
128
  if (newPath[0] !== fullPath[0]) {
125
129
  const center = this.from.classView.value.center();
126
- this.from.setOffsetX(newPath[0].x - center.x);
127
- this.from.setOffsetY(newPath[0].y - center.y);
130
+ this.from.setOffsetX((newPath[0] as Point).x - center.x);
131
+ this.from.setOffsetY((newPath[0] as Point).y - center.y);
128
132
  }
129
133
 
130
134
  if (newPath[newPath.length - 1] !== fullPath[fullPath.length - 1]) {
131
135
  const center = this.to.classView.value.center();
132
- this.to.setOffsetX(newPath[newPath.length - 1].x - center.x);
133
- this.to.setOffsetY(newPath[newPath.length - 1].y - center.y);
136
+ this.to.setOffsetX((newPath[newPath.length - 1] as Point).x - center.x);
137
+ this.to.setOffsetY((newPath[newPath.length - 1] as Point).y - center.y);
134
138
  }
135
139
 
136
140
  // find the point which can be flattened due to its wide angle
137
141
  const result = [];
138
142
  for (let i = 0; i < newPath.length - 2; i++) {
139
- const v1 = Vector.fromPoints(newPath[i + 1], newPath[i]).norm();
140
- const v2 = Vector.fromPoints(newPath[i + 1], newPath[i + 2]).norm();
143
+ const v1 = Vector.fromPoints(
144
+ newPath[i + 1] as Point,
145
+ newPath[i] as Point,
146
+ ).norm();
147
+ const v2 = Vector.fromPoints(
148
+ newPath[i + 1] as Point,
149
+ newPath[i + 2] as Point,
150
+ ).norm();
141
151
  const dot = v1.dotProduct(v2);
142
152
  const angle = (Math.acos(dot) * 180) / Math.PI;
143
153
  if (Math.abs(angle - 180) > 5) {
144
- result.push(newPath[i + 1]);
154
+ result.push(newPath[i + 1] as Point);
145
155
  }
146
156
  }
147
157
  // here's where we will modify the path, i.e. swallow inside points if we have to
@@ -173,8 +183,8 @@ export class RelationshipView implements Hashable {
173
183
  let point;
174
184
 
175
185
  for (let i = 0; i < fullPath.length - 1; i++) {
176
- const a = fullPath[i];
177
- const b = fullPath[i + 1];
186
+ const a = fullPath[i] as Point;
187
+ const b = fullPath[i + 1] as Point;
178
188
  const n = new Vector(a.x, a.y).normal(new Vector(b.x, b.y)).norm();
179
189
  const v = Vector.fromPoints(a, new Point(x, y));
180
190
 
@@ -191,7 +201,7 @@ export class RelationshipView implements Hashable {
191
201
  }
192
202
 
193
203
  if (i < fullPath.length - 2) {
194
- newPath.push(fullPath[i + 1]);
204
+ newPath.push(fullPath[i + 1] as Point);
195
205
  }
196
206
  }
197
207
  if (point && allowChange) {
@@ -22,7 +22,7 @@ import {
22
22
  } from '@finos/legend-shared';
23
23
  import type { DiagramRenderer } from '../../DiagramRenderer';
24
24
  import { DIAGRAM_INTERACTION_MODE } from '../../DiagramRenderer';
25
- import { PanelDisplayState } from '@finos/legend-art';
25
+ import { HotkeyConfiguration, PanelDisplayState } from '@finos/legend-art';
26
26
  import type {
27
27
  PackageableElement,
28
28
  AbstractProperty,
@@ -37,11 +37,7 @@ import {
37
37
  PropertyExplicitReference,
38
38
  } from '@finos/legend-graph';
39
39
  import type { EditorStore } from '@finos/legend-studio';
40
- import {
41
- ClassEditorState,
42
- EditorHotkey,
43
- ElementEditorState,
44
- } from '@finos/legend-studio';
40
+ import { ClassEditorState, ElementEditorState } from '@finos/legend-studio';
45
41
  import type { ClassView } from '../../models/metamodels/pure/packageableElements/diagram/ClassView';
46
42
  import type { Point } from '../../models/metamodels/pure/packageableElements/diagram/geometry/Point';
47
43
  import { Diagram } from '../../models/metamodels/pure/packageableElements/diagram/Diagram';
@@ -441,7 +437,7 @@ export class DiagramEditorState extends ElementEditorState {
441
437
  DIAGRAM_EDITOR_HOTKEY.EJECT_PROPERTY,
442
438
  ].forEach((key) => {
443
439
  this.editorStore.addHotKey(
444
- new EditorHotkey(
440
+ new HotkeyConfiguration(
445
441
  key,
446
442
  [DIAGRAM_EDITOR_HOTKEY_MAP[key]],
447
443
  this.createDiagramHotKeyAction((event?: KeyboardEvent) => {
package/tsconfig.json CHANGED
@@ -22,6 +22,7 @@
22
22
  "allowSyntheticDefaultImports": true,
23
23
  "strict": true,
24
24
  "noImplicitOverride": true,
25
+ "noUncheckedIndexedAccess": true,
25
26
  "exactOptionalPropertyTypes": true,
26
27
  "forceConsistentCasingInFileNames": true,
27
28
  "outDir": "./lib",
@@ -74,8 +75,8 @@
74
75
  "./src/models/protocols/pure/v1/transformation/pureProtocol/V1_DSLDiagram_ProtocolHelper.ts",
75
76
  "./src/stores/studio/DiagramEditorState.ts",
76
77
  "./src/components/studio/ClassDiagramPreview.tsx",
77
- "./src/components/studio/DSLDiagram_StudioPlugin.tsx",
78
- "./src/components/studio/DSLDiagram_StudioPlugin_Extension.tsx",
78
+ "./src/components/studio/DSLDiagram_LegendStudioPlugin.tsx",
79
+ "./src/components/studio/DSLDiagram_LegendStudioPlugin_Extension.tsx",
79
80
  "./src/components/studio/DiagramEditor.tsx"
80
81
  ],
81
82
  "include": [
@@ -22,6 +22,7 @@
22
22
  "allowSyntheticDefaultImports": true,
23
23
  "strict": true,
24
24
  "noImplicitOverride": true,
25
+ "noUncheckedIndexedAccess": true,
25
26
  "exactOptionalPropertyTypes": true,
26
27
  "forceConsistentCasingInFileNames": true,
27
28
  "outDir": "./lib",
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSLDiagram_StudioPlugin.d.ts","sourceRoot":"","sources":["../../../src/components/studio/DSLDiagram_StudioPlugin.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAG1B,yBAAyB,EACzB,iBAAiB,EACjB,mCAAmC,EACnC,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAE1B,6BAA6B,EAC7B,6BAA6B,EAC7B,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,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CACE,WAAwB,EACxB,OAA2B,EACK,EAAE;gBAClC,IAAI,OAAO,YAAY,OAAO,EAAE;oBAC9B,OAAO,IAAI,kBAAkB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;iBACrD;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,4CAA4C;QAC1C,OAAO;YACL,CAAC,OAA2B,EAAsB,EAAE;gBAClD,IAAI,OAAO,YAAY,OAAO,EAAE;oBAC9B,OAAO,yCAAyC,CAAC;iBAClD;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,iCAAiC;QAC/B,OAAO,CAAC,yCAAyC,CAAC,CAAC;IACrD,CAAC;IAED,sCAAsC;QACpC,OAAO;YACL,CAAC,WAAwB,EAAE,OAA2B,EAAQ,EAAE;gBAC9D,oCAAoC;gBACpC,IAAI,WAAW,CAAC,kBAAkB,YAAY,kBAAkB,EAAE;oBAChE,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBAClD;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IAED,sCAAsC;QACpC,OAAO;YACL,CAAC,WAAwB,EAAE,OAA2B,EAAQ,EAAE;gBAC9D,oCAAoC;gBACpC,IAAI,WAAW,CAAC,kBAAkB,YAAY,kBAAkB,EAAE;oBAChE,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBAClD;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSLDiagram_StudioPlugin_Extension.d.ts","sourceRoot":"","sources":["../../../src/components/studio/DSLDiagram_StudioPlugin_Extension.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oEAAoE,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,oBAAY,6CAA6C,GAAG;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,CACR,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,SAAS,GAAG,SAAS,KAC7B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,iCACf,SAAQ,0BAA0B;IAClC;;OAEG;IACH,sDAAsD,CAAC,IAAI,6CAA6C,EAAE,CAAC;CAC5G"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSLDiagram_StudioPlugin_Extension.js","sourceRoot":"","sources":["../../../src/components/studio/DSLDiagram_StudioPlugin_Extension.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}