@reqlan/analytical 0.6.2 → 0.6.3

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 CHANGED
@@ -30,6 +30,12 @@ npm install @reqlan/analytical
30
30
 
31
31
  ## Changelog
32
32
 
33
+ ### 0.6.3
34
+
35
+ #### Patch Changes
36
+
37
+ - 674da15: fix image in readme, update site copy, add graph navigator to landing.
38
+
33
39
  ### 0.6.2
34
40
 
35
41
  #### Patch Changes
@@ -800,15 +800,35 @@ function wireGraph(root) {
800
800
  if (userViewport && !force) return;
801
801
  const bounds = contentBounds();
802
802
  const pad = 56;
803
- view = {
804
- x: bounds.minX - pad,
805
- y: bounds.minY - pad,
806
- w: Math.max(360, bounds.maxX - bounds.minX + pad * 2),
807
- h: Math.max(360, bounds.maxY - bounds.minY + pad * 2)
808
- };
803
+ let x = bounds.minX - pad;
804
+ let y = bounds.minY - pad;
805
+ let w = Math.max(360, bounds.maxX - bounds.minX + pad * 2);
806
+ let h = Math.max(360, bounds.maxY - bounds.minY + pad * 2);
807
+ // Match canvas aspect so uniform scale fills without squashing (SVG viewBox meet).
808
+ const canvasAspect = cssWidth / Math.max(1, cssHeight);
809
+ const viewAspect = w / h;
810
+ if (viewAspect < canvasAspect) {
811
+ const widened = h * canvasAspect;
812
+ x -= (widened - w) / 2;
813
+ w = widened;
814
+ } else if (viewAspect > canvasAspect) {
815
+ const heightened = w / canvasAspect;
816
+ y -= (heightened - h) / 2;
817
+ h = heightened;
818
+ }
819
+ view = { x, y, w, h };
809
820
  userViewport = false;
810
821
  }
811
822
 
823
+ function viewportTransform() {
824
+ const scale = Math.min(cssWidth / Math.max(1, view.w), cssHeight / Math.max(1, view.h));
825
+ return {
826
+ scale,
827
+ offsetX: (cssWidth - view.w * scale) / 2,
828
+ offsetY: (cssHeight - view.h * scale) / 2
829
+ };
830
+ }
831
+
812
832
  function wrapLines(text, maxWidth, font) {
813
833
  if (!text) return [];
814
834
  ctx.font = font;
@@ -871,13 +891,13 @@ function wireGraph(root) {
871
891
  ctx.fillStyle = '#14100e';
872
892
  ctx.fillRect(0, 0, cssWidth, cssHeight);
873
893
 
874
- const sx = cssWidth / view.w;
875
- const sy = cssHeight / view.h;
894
+ const { scale, offsetX, offsetY } = viewportTransform();
876
895
  ctx.save();
877
- ctx.translate(-view.x * sx, -view.y * sy);
878
- ctx.scale(sx, sy);
896
+ ctx.translate(offsetX, offsetY);
897
+ ctx.scale(scale, scale);
898
+ ctx.translate(-view.x, -view.y);
879
899
 
880
- ctx.lineWidth = 1.1 / Math.max(sx, sy);
900
+ ctx.lineWidth = 1.1 / scale;
881
901
  ctx.strokeStyle = 'rgba(61,47,40,0.85)';
882
902
  ctx.globalAlpha = 0.85;
883
903
  for (const edge of simEdges) {
@@ -909,7 +929,7 @@ function wireGraph(root) {
909
929
  ctx.arc(pos.x, pos.y, r, 0, Math.PI * 2);
910
930
  ctx.fillStyle = nodeFill(node);
911
931
  ctx.fill();
912
- ctx.lineWidth = (isSubject ? 2.2 : hover ? 2 : 1.15) / Math.max(sx, sy);
932
+ ctx.lineWidth = (isSubject ? 2.2 : hover ? 2 : 1.15) / scale;
913
933
  ctx.strokeStyle = nodeStroke(node, hover);
914
934
  ctx.stroke();
915
935
 
@@ -926,7 +946,7 @@ function wireGraph(root) {
926
946
  ctx.fillStyle = isSubject ? '#0bbefb' : '#ebe4de';
927
947
  ctx.font = nameFont;
928
948
  for (const line of nameLines) {
929
- ctx.lineWidth = 3 / Math.max(sx, sy);
949
+ ctx.lineWidth = 3 / scale;
930
950
  ctx.strokeStyle = '#14100e';
931
951
  ctx.strokeText(line, pos.x, ty);
932
952
  ctx.fillText(line, pos.x, ty);
@@ -1053,9 +1073,13 @@ function wireGraph(root) {
1053
1073
 
1054
1074
  function clientToGraph(event) {
1055
1075
  const rect = canvas.getBoundingClientRect();
1056
- const x = view.x + ((event.clientX - rect.left) / rect.width) * view.w;
1057
- const y = view.y + ((event.clientY - rect.top) / rect.height) * view.h;
1058
- return { x, y };
1076
+ const { scale, offsetX, offsetY } = viewportTransform();
1077
+ const cssX = ((event.clientX - rect.left) / rect.width) * cssWidth;
1078
+ const cssY = ((event.clientY - rect.top) / rect.height) * cssHeight;
1079
+ return {
1080
+ x: view.x + (cssX - offsetX) / scale,
1081
+ y: view.y + (cssY - offsetY) / scale
1082
+ };
1059
1083
  }
1060
1084
 
1061
1085
  function wireViewport(target) {
@@ -1104,8 +1128,9 @@ function wireGraph(root) {
1104
1128
  }
1105
1129
  if (panMode && panOrigin) {
1106
1130
  const rect = target.getBoundingClientRect();
1107
- const dx = ((event.clientX - panOrigin.x) / rect.width) * view.w;
1108
- const dy = ((event.clientY - panOrigin.y) / rect.height) * view.h;
1131
+ const { scale } = viewportTransform();
1132
+ const dx = ((event.clientX - panOrigin.x) / rect.width) * cssWidth / scale;
1133
+ const dy = ((event.clientY - panOrigin.y) / rect.height) * cssHeight / scale;
1109
1134
  view.x = panOrigin.viewX - dx;
1110
1135
  view.y = panOrigin.viewY - dy;
1111
1136
  userViewport = true;
@@ -1 +1 @@
1
- {"version":3,"file":"html-export-assets.js","sourceRoot":"","sources":["../../src/export/html-export-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,2FAA2F;AAC3F,SAAS,sBAAsB;IAC3B,OAAO,YAAY,CAAC,IAAI,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;SAC5E,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reqlan/analytical",
3
3
  "description": "Shared requirement graph index and analysers for reqlan",
4
- "version": "0.6.2",
4
+ "version": "0.6.3",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
7
7
  "repository": {