microboard-temp 0.5.87 → 0.5.89

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.
@@ -36895,7 +36895,6 @@ function reducePoints(points) {
36895
36895
  return result;
36896
36896
  }
36897
36897
  function getLines(pathPoints) {
36898
- const lines = [];
36899
36898
  if (pathPoints.length < 2) {
36900
36899
  return [];
36901
36900
  }
@@ -36903,24 +36902,15 @@ function getLines(pathPoints) {
36903
36902
  if (reducedPoints.length < 2) {
36904
36903
  return [];
36905
36904
  }
36905
+ const lines = [];
36906
36906
  let startPoint = reducedPoints[0];
36907
- for (let i = 1;i < reducedPoints.length; i += 1) {
36908
- const prevPoint = reducedPoints[i - 1];
36909
- const currPoint = reducedPoints[i];
36907
+ for (let i = 1;i < reducedPoints.length; i++) {
36908
+ const currentPoint = reducedPoints[i];
36910
36909
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
36911
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
36912
- lines.push(new Line(startPoint, currPoint));
36913
- startPoint = currPoint;
36914
- }
36915
- }
36916
- if (lines.length === 0 && reducedPoints.length > 1) {
36917
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
36918
- } else if (lines.length > 0) {
36919
- const lastLine = lines[lines.length - 1];
36920
- const lastPointInLines = lastLine.getEndPoint();
36921
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
36922
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
36923
- lines.push(new Line(lastPointInLines, lastPointInReduced));
36910
+ const direction = getDirection(startPoint, currentPoint);
36911
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
36912
+ lines.push(new Line(startPoint, currentPoint));
36913
+ startPoint = currentPoint;
36924
36914
  }
36925
36915
  }
36926
36916
  return lines;
@@ -36934,35 +36924,29 @@ function reconstructPath(node2) {
36934
36924
  }
36935
36925
  return path2.reverse();
36936
36926
  }
36937
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
36938
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
36939
- }
36940
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
36941
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
36942
- }
36943
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
36944
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36927
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36928
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36945
36929
  const midY = (startPoint.y + endPoint.y) / 2;
36946
36930
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36947
36931
  }
36948
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36932
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36949
36933
  const midY = (startPoint.y + endPoint.y) / 2;
36950
36934
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36951
36935
  }
36952
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36936
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36953
36937
  const midX = (startPoint.x + endPoint.x) / 2;
36954
36938
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36955
36939
  }
36956
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36940
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36957
36941
  const midX = (startPoint.x + endPoint.x) / 2;
36958
36942
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36959
36943
  }
36960
36944
  const dx = endPoint.x - startPoint.x;
36961
36945
  const dy = endPoint.y - startPoint.y;
36962
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36963
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36964
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36965
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36946
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
36947
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
36948
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
36949
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
36966
36950
  if (startConflictX || endConflictY) {
36967
36951
  return [new Point(startPoint.x, endPoint.y)];
36968
36952
  }
@@ -36977,10 +36961,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36977
36961
  const endPoint = newEnd || end;
36978
36962
  const startDir = getPointerDirection(start);
36979
36963
  const endDir = getPointerDirection(end);
36980
- let hookWaypoints = [];
36981
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
36982
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
36983
- }
36964
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36984
36965
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36985
36966
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36986
36967
  return {
package/dist/cjs/index.js CHANGED
@@ -36895,7 +36895,6 @@ function reducePoints(points) {
36895
36895
  return result;
36896
36896
  }
36897
36897
  function getLines(pathPoints) {
36898
- const lines = [];
36899
36898
  if (pathPoints.length < 2) {
36900
36899
  return [];
36901
36900
  }
@@ -36903,24 +36902,15 @@ function getLines(pathPoints) {
36903
36902
  if (reducedPoints.length < 2) {
36904
36903
  return [];
36905
36904
  }
36905
+ const lines = [];
36906
36906
  let startPoint = reducedPoints[0];
36907
- for (let i = 1;i < reducedPoints.length; i += 1) {
36908
- const prevPoint = reducedPoints[i - 1];
36909
- const currPoint = reducedPoints[i];
36907
+ for (let i = 1;i < reducedPoints.length; i++) {
36908
+ const currentPoint = reducedPoints[i];
36910
36909
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
36911
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
36912
- lines.push(new Line(startPoint, currPoint));
36913
- startPoint = currPoint;
36914
- }
36915
- }
36916
- if (lines.length === 0 && reducedPoints.length > 1) {
36917
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
36918
- } else if (lines.length > 0) {
36919
- const lastLine = lines[lines.length - 1];
36920
- const lastPointInLines = lastLine.getEndPoint();
36921
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
36922
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
36923
- lines.push(new Line(lastPointInLines, lastPointInReduced));
36910
+ const direction = getDirection(startPoint, currentPoint);
36911
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
36912
+ lines.push(new Line(startPoint, currentPoint));
36913
+ startPoint = currentPoint;
36924
36914
  }
36925
36915
  }
36926
36916
  return lines;
@@ -36934,35 +36924,29 @@ function reconstructPath(node2) {
36934
36924
  }
36935
36925
  return path2.reverse();
36936
36926
  }
36937
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
36938
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
36939
- }
36940
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
36941
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
36942
- }
36943
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
36944
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36927
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36928
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36945
36929
  const midY = (startPoint.y + endPoint.y) / 2;
36946
36930
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36947
36931
  }
36948
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36932
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36949
36933
  const midY = (startPoint.y + endPoint.y) / 2;
36950
36934
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36951
36935
  }
36952
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36936
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36953
36937
  const midX = (startPoint.x + endPoint.x) / 2;
36954
36938
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36955
36939
  }
36956
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36940
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36957
36941
  const midX = (startPoint.x + endPoint.x) / 2;
36958
36942
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36959
36943
  }
36960
36944
  const dx = endPoint.x - startPoint.x;
36961
36945
  const dy = endPoint.y - startPoint.y;
36962
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36963
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36964
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36965
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36946
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
36947
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
36948
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
36949
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
36966
36950
  if (startConflictX || endConflictY) {
36967
36951
  return [new Point(startPoint.x, endPoint.y)];
36968
36952
  }
@@ -36977,10 +36961,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36977
36961
  const endPoint = newEnd || end;
36978
36962
  const startDir = getPointerDirection(start);
36979
36963
  const endDir = getPointerDirection(end);
36980
- let hookWaypoints = [];
36981
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
36982
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
36983
- }
36964
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36984
36965
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36985
36966
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36986
36967
  return {
package/dist/cjs/node.js CHANGED
@@ -39368,7 +39368,6 @@ function reducePoints(points) {
39368
39368
  return result;
39369
39369
  }
39370
39370
  function getLines(pathPoints) {
39371
- const lines = [];
39372
39371
  if (pathPoints.length < 2) {
39373
39372
  return [];
39374
39373
  }
@@ -39376,24 +39375,15 @@ function getLines(pathPoints) {
39376
39375
  if (reducedPoints.length < 2) {
39377
39376
  return [];
39378
39377
  }
39378
+ const lines = [];
39379
39379
  let startPoint = reducedPoints[0];
39380
- for (let i = 1;i < reducedPoints.length; i += 1) {
39381
- const prevPoint = reducedPoints[i - 1];
39382
- const currPoint = reducedPoints[i];
39380
+ for (let i = 1;i < reducedPoints.length; i++) {
39381
+ const currentPoint = reducedPoints[i];
39383
39382
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
39384
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
39385
- lines.push(new Line(startPoint, currPoint));
39386
- startPoint = currPoint;
39387
- }
39388
- }
39389
- if (lines.length === 0 && reducedPoints.length > 1) {
39390
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
39391
- } else if (lines.length > 0) {
39392
- const lastLine = lines[lines.length - 1];
39393
- const lastPointInLines = lastLine.getEndPoint();
39394
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
39395
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
39396
- lines.push(new Line(lastPointInLines, lastPointInReduced));
39383
+ const direction = getDirection(startPoint, currentPoint);
39384
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
39385
+ lines.push(new Line(startPoint, currentPoint));
39386
+ startPoint = currentPoint;
39397
39387
  }
39398
39388
  }
39399
39389
  return lines;
@@ -39407,35 +39397,29 @@ function reconstructPath(node2) {
39407
39397
  }
39408
39398
  return path2.reverse();
39409
39399
  }
39410
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
39411
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
39412
- }
39413
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
39414
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
39415
- }
39416
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
39417
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39400
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39401
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39418
39402
  const midY = (startPoint.y + endPoint.y) / 2;
39419
39403
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
39420
39404
  }
39421
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39405
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
39422
39406
  const midY = (startPoint.y + endPoint.y) / 2;
39423
39407
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
39424
39408
  }
39425
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39409
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
39426
39410
  const midX = (startPoint.x + endPoint.x) / 2;
39427
39411
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
39428
39412
  }
39429
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39413
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
39430
39414
  const midX = (startPoint.x + endPoint.x) / 2;
39431
39415
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
39432
39416
  }
39433
39417
  const dx = endPoint.x - startPoint.x;
39434
39418
  const dy = endPoint.y - startPoint.y;
39435
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39436
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39437
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39438
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39419
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
39420
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
39421
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
39422
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
39439
39423
  if (startConflictX || endConflictY) {
39440
39424
  return [new Point(startPoint.x, endPoint.y)];
39441
39425
  }
@@ -39450,10 +39434,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39450
39434
  const endPoint = newEnd || end;
39451
39435
  const startDir = getPointerDirection(start);
39452
39436
  const endDir = getPointerDirection(end);
39453
- let hookWaypoints = [];
39454
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
39455
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
39456
- }
39437
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
39457
39438
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
39458
39439
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
39459
39440
  return {
@@ -36740,7 +36740,6 @@ function reducePoints(points) {
36740
36740
  return result;
36741
36741
  }
36742
36742
  function getLines(pathPoints) {
36743
- const lines = [];
36744
36743
  if (pathPoints.length < 2) {
36745
36744
  return [];
36746
36745
  }
@@ -36748,24 +36747,15 @@ function getLines(pathPoints) {
36748
36747
  if (reducedPoints.length < 2) {
36749
36748
  return [];
36750
36749
  }
36750
+ const lines = [];
36751
36751
  let startPoint = reducedPoints[0];
36752
- for (let i = 1;i < reducedPoints.length; i += 1) {
36753
- const prevPoint = reducedPoints[i - 1];
36754
- const currPoint = reducedPoints[i];
36752
+ for (let i = 1;i < reducedPoints.length; i++) {
36753
+ const currentPoint = reducedPoints[i];
36755
36754
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
36756
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
36757
- lines.push(new Line(startPoint, currPoint));
36758
- startPoint = currPoint;
36759
- }
36760
- }
36761
- if (lines.length === 0 && reducedPoints.length > 1) {
36762
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
36763
- } else if (lines.length > 0) {
36764
- const lastLine = lines[lines.length - 1];
36765
- const lastPointInLines = lastLine.getEndPoint();
36766
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
36767
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
36768
- lines.push(new Line(lastPointInLines, lastPointInReduced));
36755
+ const direction = getDirection(startPoint, currentPoint);
36756
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
36757
+ lines.push(new Line(startPoint, currentPoint));
36758
+ startPoint = currentPoint;
36769
36759
  }
36770
36760
  }
36771
36761
  return lines;
@@ -36779,35 +36769,29 @@ function reconstructPath(node2) {
36779
36769
  }
36780
36770
  return path2.reverse();
36781
36771
  }
36782
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
36783
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
36784
- }
36785
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
36786
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
36787
- }
36788
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
36789
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36772
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36773
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36790
36774
  const midY = (startPoint.y + endPoint.y) / 2;
36791
36775
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36792
36776
  }
36793
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36777
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36794
36778
  const midY = (startPoint.y + endPoint.y) / 2;
36795
36779
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36796
36780
  }
36797
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36781
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36798
36782
  const midX = (startPoint.x + endPoint.x) / 2;
36799
36783
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36800
36784
  }
36801
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36785
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36802
36786
  const midX = (startPoint.x + endPoint.x) / 2;
36803
36787
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36804
36788
  }
36805
36789
  const dx = endPoint.x - startPoint.x;
36806
36790
  const dy = endPoint.y - startPoint.y;
36807
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36808
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36809
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36810
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36791
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
36792
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
36793
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
36794
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
36811
36795
  if (startConflictX || endConflictY) {
36812
36796
  return [new Point(startPoint.x, endPoint.y)];
36813
36797
  }
@@ -36822,10 +36806,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36822
36806
  const endPoint = newEnd || end;
36823
36807
  const startDir = getPointerDirection(start);
36824
36808
  const endDir = getPointerDirection(end);
36825
- let hookWaypoints = [];
36826
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
36827
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
36828
- }
36809
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36829
36810
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36830
36811
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36831
36812
  return {
package/dist/esm/index.js CHANGED
@@ -36733,7 +36733,6 @@ function reducePoints(points) {
36733
36733
  return result;
36734
36734
  }
36735
36735
  function getLines(pathPoints) {
36736
- const lines = [];
36737
36736
  if (pathPoints.length < 2) {
36738
36737
  return [];
36739
36738
  }
@@ -36741,24 +36740,15 @@ function getLines(pathPoints) {
36741
36740
  if (reducedPoints.length < 2) {
36742
36741
  return [];
36743
36742
  }
36743
+ const lines = [];
36744
36744
  let startPoint = reducedPoints[0];
36745
- for (let i = 1;i < reducedPoints.length; i += 1) {
36746
- const prevPoint = reducedPoints[i - 1];
36747
- const currPoint = reducedPoints[i];
36745
+ for (let i = 1;i < reducedPoints.length; i++) {
36746
+ const currentPoint = reducedPoints[i];
36748
36747
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
36749
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
36750
- lines.push(new Line(startPoint, currPoint));
36751
- startPoint = currPoint;
36752
- }
36753
- }
36754
- if (lines.length === 0 && reducedPoints.length > 1) {
36755
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
36756
- } else if (lines.length > 0) {
36757
- const lastLine = lines[lines.length - 1];
36758
- const lastPointInLines = lastLine.getEndPoint();
36759
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
36760
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
36761
- lines.push(new Line(lastPointInLines, lastPointInReduced));
36748
+ const direction = getDirection(startPoint, currentPoint);
36749
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
36750
+ lines.push(new Line(startPoint, currentPoint));
36751
+ startPoint = currentPoint;
36762
36752
  }
36763
36753
  }
36764
36754
  return lines;
@@ -36772,35 +36762,29 @@ function reconstructPath(node2) {
36772
36762
  }
36773
36763
  return path2.reverse();
36774
36764
  }
36775
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
36776
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
36777
- }
36778
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
36779
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
36780
- }
36781
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
36782
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36765
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36766
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36783
36767
  const midY = (startPoint.y + endPoint.y) / 2;
36784
36768
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36785
36769
  }
36786
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36770
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36787
36771
  const midY = (startPoint.y + endPoint.y) / 2;
36788
36772
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
36789
36773
  }
36790
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36774
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36791
36775
  const midX = (startPoint.x + endPoint.x) / 2;
36792
36776
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36793
36777
  }
36794
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
36778
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36795
36779
  const midX = (startPoint.x + endPoint.x) / 2;
36796
36780
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
36797
36781
  }
36798
36782
  const dx = endPoint.x - startPoint.x;
36799
36783
  const dy = endPoint.y - startPoint.y;
36800
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36801
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36802
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36803
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
36784
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
36785
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
36786
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
36787
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
36804
36788
  if (startConflictX || endConflictY) {
36805
36789
  return [new Point(startPoint.x, endPoint.y)];
36806
36790
  }
@@ -36815,10 +36799,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36815
36799
  const endPoint = newEnd || end;
36816
36800
  const startDir = getPointerDirection(start);
36817
36801
  const endDir = getPointerDirection(end);
36818
- let hookWaypoints = [];
36819
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
36820
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
36821
- }
36802
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36822
36803
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36823
36804
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36824
36805
  return {
package/dist/esm/node.js CHANGED
@@ -39201,7 +39201,6 @@ function reducePoints(points) {
39201
39201
  return result;
39202
39202
  }
39203
39203
  function getLines(pathPoints) {
39204
- const lines = [];
39205
39204
  if (pathPoints.length < 2) {
39206
39205
  return [];
39207
39206
  }
@@ -39209,24 +39208,15 @@ function getLines(pathPoints) {
39209
39208
  if (reducedPoints.length < 2) {
39210
39209
  return [];
39211
39210
  }
39211
+ const lines = [];
39212
39212
  let startPoint = reducedPoints[0];
39213
- for (let i = 1;i < reducedPoints.length; i += 1) {
39214
- const prevPoint = reducedPoints[i - 1];
39215
- const currPoint = reducedPoints[i];
39213
+ for (let i = 1;i < reducedPoints.length; i++) {
39214
+ const currentPoint = reducedPoints[i];
39216
39215
  const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
39217
- if (!nextPoint || prevPoint.x !== nextPoint.x && prevPoint.y !== nextPoint.y) {
39218
- lines.push(new Line(startPoint, currPoint));
39219
- startPoint = currPoint;
39220
- }
39221
- }
39222
- if (lines.length === 0 && reducedPoints.length > 1) {
39223
- lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
39224
- } else if (lines.length > 0) {
39225
- const lastLine = lines[lines.length - 1];
39226
- const lastPointInLines = lastLine.getEndPoint();
39227
- const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
39228
- if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
39229
- lines.push(new Line(lastPointInLines, lastPointInReduced));
39216
+ const direction = getDirection(startPoint, currentPoint);
39217
+ if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
39218
+ lines.push(new Line(startPoint, currentPoint));
39219
+ startPoint = currentPoint;
39230
39220
  }
39231
39221
  }
39232
39222
  return lines;
@@ -39240,35 +39230,29 @@ function reconstructPath(node2) {
39240
39230
  }
39241
39231
  return path2.reverse();
39242
39232
  }
39243
- function haveVerticalIntersection(firstMbr, secondMbr, offset = 0) {
39244
- return firstMbr.top >= secondMbr.bottom - offset && secondMbr.top >= firstMbr.bottom - offset;
39245
- }
39246
- function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
39247
- return firstMbr.right >= secondMbr.left - offset && secondMbr.right >= firstMbr.left - offset;
39248
- }
39249
- function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
39250
- if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39233
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39234
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39251
39235
  const midY = (startPoint.y + endPoint.y) / 2;
39252
39236
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
39253
39237
  }
39254
- if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39238
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
39255
39239
  const midY = (startPoint.y + endPoint.y) / 2;
39256
39240
  return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
39257
39241
  }
39258
- if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39242
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
39259
39243
  const midX = (startPoint.x + endPoint.x) / 2;
39260
39244
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
39261
39245
  }
39262
- if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
39246
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
39263
39247
  const midX = (startPoint.x + endPoint.x) / 2;
39264
39248
  return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
39265
39249
  }
39266
39250
  const dx = endPoint.x - startPoint.x;
39267
39251
  const dy = endPoint.y - startPoint.y;
39268
- const startConflictX = (startDir === "right" && dx < 0 || startDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39269
- const startConflictY = (startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39270
- const endConflictX = (endDir === "right" && dx < 0 || endDir === "left" && dx > 0) && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39271
- const endConflictY = (endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0) && !haveHorizontalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2);
39252
+ const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
39253
+ const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
39254
+ const endConflictX = endDir === "right" && dx < 0 || endDir === "left" && dx > 0;
39255
+ const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
39272
39256
  if (startConflictX || endConflictY) {
39273
39257
  return [new Point(startPoint.x, endPoint.y)];
39274
39258
  }
@@ -39283,10 +39267,7 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39283
39267
  const endPoint = newEnd || end;
39284
39268
  const startDir = getPointerDirection(start);
39285
39269
  const endDir = getPointerDirection(end);
39286
- let hookWaypoints = [];
39287
- if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
39288
- hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
39289
- }
39270
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
39290
39271
  const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
39291
39272
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
39292
39273
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.87",
3
+ "version": "0.5.89",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",