microboard-temp 0.5.78 → 0.5.79

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.
@@ -36934,11 +36934,42 @@ function reconstructPath(node2) {
36934
36934
  }
36935
36935
  return path2.reverse();
36936
36936
  }
36937
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36938
+ const hookPoints = [];
36939
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36940
+ const midY = (startPoint.y + endPoint.y) / 2;
36941
+ hookPoints.push(new Point(startPoint.x, midY));
36942
+ hookPoints.push(new Point(endPoint.x, midY));
36943
+ return hookPoints;
36944
+ }
36945
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36946
+ const midY = (startPoint.y + endPoint.y) / 2;
36947
+ hookPoints.push(new Point(startPoint.x, midY));
36948
+ hookPoints.push(new Point(endPoint.x, midY));
36949
+ return hookPoints;
36950
+ }
36951
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36952
+ const midX = (startPoint.x + endPoint.x) / 2;
36953
+ hookPoints.push(new Point(midX, startPoint.y));
36954
+ hookPoints.push(new Point(midX, endPoint.y));
36955
+ return hookPoints;
36956
+ }
36957
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36958
+ const midX = (startPoint.x + endPoint.x) / 2;
36959
+ hookPoints.push(new Point(midX, startPoint.y));
36960
+ hookPoints.push(new Point(midX, endPoint.y));
36961
+ return hookPoints;
36962
+ }
36963
+ return hookPoints;
36964
+ }
36937
36965
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36938
36966
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
36939
36967
  const startPoint = newStart || start;
36940
36968
  const endPoint = newEnd || end;
36941
- const points = [startPoint, ...toVisitPoints, endPoint];
36969
+ const startDir = getPointerDirection(start);
36970
+ const endDir = getPointerDirection(end);
36971
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36972
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36942
36973
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36943
36974
  return {
36944
36975
  lines: getLines(pathPoints),
package/dist/cjs/index.js CHANGED
@@ -36934,11 +36934,42 @@ function reconstructPath(node2) {
36934
36934
  }
36935
36935
  return path2.reverse();
36936
36936
  }
36937
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36938
+ const hookPoints = [];
36939
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36940
+ const midY = (startPoint.y + endPoint.y) / 2;
36941
+ hookPoints.push(new Point(startPoint.x, midY));
36942
+ hookPoints.push(new Point(endPoint.x, midY));
36943
+ return hookPoints;
36944
+ }
36945
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36946
+ const midY = (startPoint.y + endPoint.y) / 2;
36947
+ hookPoints.push(new Point(startPoint.x, midY));
36948
+ hookPoints.push(new Point(endPoint.x, midY));
36949
+ return hookPoints;
36950
+ }
36951
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36952
+ const midX = (startPoint.x + endPoint.x) / 2;
36953
+ hookPoints.push(new Point(midX, startPoint.y));
36954
+ hookPoints.push(new Point(midX, endPoint.y));
36955
+ return hookPoints;
36956
+ }
36957
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36958
+ const midX = (startPoint.x + endPoint.x) / 2;
36959
+ hookPoints.push(new Point(midX, startPoint.y));
36960
+ hookPoints.push(new Point(midX, endPoint.y));
36961
+ return hookPoints;
36962
+ }
36963
+ return hookPoints;
36964
+ }
36937
36965
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36938
36966
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
36939
36967
  const startPoint = newStart || start;
36940
36968
  const endPoint = newEnd || end;
36941
- const points = [startPoint, ...toVisitPoints, endPoint];
36969
+ const startDir = getPointerDirection(start);
36970
+ const endDir = getPointerDirection(end);
36971
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36972
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36942
36973
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36943
36974
  return {
36944
36975
  lines: getLines(pathPoints),
package/dist/cjs/node.js CHANGED
@@ -39407,11 +39407,42 @@ function reconstructPath(node2) {
39407
39407
  }
39408
39408
  return path2.reverse();
39409
39409
  }
39410
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39411
+ const hookPoints = [];
39412
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39413
+ const midY = (startPoint.y + endPoint.y) / 2;
39414
+ hookPoints.push(new Point(startPoint.x, midY));
39415
+ hookPoints.push(new Point(endPoint.x, midY));
39416
+ return hookPoints;
39417
+ }
39418
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
39419
+ const midY = (startPoint.y + endPoint.y) / 2;
39420
+ hookPoints.push(new Point(startPoint.x, midY));
39421
+ hookPoints.push(new Point(endPoint.x, midY));
39422
+ return hookPoints;
39423
+ }
39424
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
39425
+ const midX = (startPoint.x + endPoint.x) / 2;
39426
+ hookPoints.push(new Point(midX, startPoint.y));
39427
+ hookPoints.push(new Point(midX, endPoint.y));
39428
+ return hookPoints;
39429
+ }
39430
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
39431
+ const midX = (startPoint.x + endPoint.x) / 2;
39432
+ hookPoints.push(new Point(midX, startPoint.y));
39433
+ hookPoints.push(new Point(midX, endPoint.y));
39434
+ return hookPoints;
39435
+ }
39436
+ return hookPoints;
39437
+ }
39410
39438
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39411
39439
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
39412
39440
  const startPoint = newStart || start;
39413
39441
  const endPoint = newEnd || end;
39414
- const points = [startPoint, ...toVisitPoints, endPoint];
39442
+ const startDir = getPointerDirection(start);
39443
+ const endDir = getPointerDirection(end);
39444
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
39445
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
39415
39446
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
39416
39447
  return {
39417
39448
  lines: getLines(pathPoints),
@@ -36779,11 +36779,42 @@ function reconstructPath(node2) {
36779
36779
  }
36780
36780
  return path2.reverse();
36781
36781
  }
36782
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36783
+ const hookPoints = [];
36784
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36785
+ const midY = (startPoint.y + endPoint.y) / 2;
36786
+ hookPoints.push(new Point(startPoint.x, midY));
36787
+ hookPoints.push(new Point(endPoint.x, midY));
36788
+ return hookPoints;
36789
+ }
36790
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36791
+ const midY = (startPoint.y + endPoint.y) / 2;
36792
+ hookPoints.push(new Point(startPoint.x, midY));
36793
+ hookPoints.push(new Point(endPoint.x, midY));
36794
+ return hookPoints;
36795
+ }
36796
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36797
+ const midX = (startPoint.x + endPoint.x) / 2;
36798
+ hookPoints.push(new Point(midX, startPoint.y));
36799
+ hookPoints.push(new Point(midX, endPoint.y));
36800
+ return hookPoints;
36801
+ }
36802
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36803
+ const midX = (startPoint.x + endPoint.x) / 2;
36804
+ hookPoints.push(new Point(midX, startPoint.y));
36805
+ hookPoints.push(new Point(midX, endPoint.y));
36806
+ return hookPoints;
36807
+ }
36808
+ return hookPoints;
36809
+ }
36782
36810
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36783
36811
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
36784
36812
  const startPoint = newStart || start;
36785
36813
  const endPoint = newEnd || end;
36786
- const points = [startPoint, ...toVisitPoints, endPoint];
36814
+ const startDir = getPointerDirection(start);
36815
+ const endDir = getPointerDirection(end);
36816
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36817
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36787
36818
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36788
36819
  return {
36789
36820
  lines: getLines(pathPoints),
package/dist/esm/index.js CHANGED
@@ -36772,11 +36772,42 @@ function reconstructPath(node2) {
36772
36772
  }
36773
36773
  return path2.reverse();
36774
36774
  }
36775
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36776
+ const hookPoints = [];
36777
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36778
+ const midY = (startPoint.y + endPoint.y) / 2;
36779
+ hookPoints.push(new Point(startPoint.x, midY));
36780
+ hookPoints.push(new Point(endPoint.x, midY));
36781
+ return hookPoints;
36782
+ }
36783
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
36784
+ const midY = (startPoint.y + endPoint.y) / 2;
36785
+ hookPoints.push(new Point(startPoint.x, midY));
36786
+ hookPoints.push(new Point(endPoint.x, midY));
36787
+ return hookPoints;
36788
+ }
36789
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
36790
+ const midX = (startPoint.x + endPoint.x) / 2;
36791
+ hookPoints.push(new Point(midX, startPoint.y));
36792
+ hookPoints.push(new Point(midX, endPoint.y));
36793
+ return hookPoints;
36794
+ }
36795
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
36796
+ const midX = (startPoint.x + endPoint.x) / 2;
36797
+ hookPoints.push(new Point(midX, startPoint.y));
36798
+ hookPoints.push(new Point(midX, endPoint.y));
36799
+ return hookPoints;
36800
+ }
36801
+ return hookPoints;
36802
+ }
36775
36803
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36776
36804
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
36777
36805
  const startPoint = newStart || start;
36778
36806
  const endPoint = newEnd || end;
36779
- const points = [startPoint, ...toVisitPoints, endPoint];
36807
+ const startDir = getPointerDirection(start);
36808
+ const endDir = getPointerDirection(end);
36809
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
36810
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
36780
36811
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
36781
36812
  return {
36782
36813
  lines: getLines(pathPoints),
package/dist/esm/node.js CHANGED
@@ -39240,11 +39240,42 @@ function reconstructPath(node2) {
39240
39240
  }
39241
39241
  return path2.reverse();
39242
39242
  }
39243
+ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39244
+ const hookPoints = [];
39245
+ if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39246
+ const midY = (startPoint.y + endPoint.y) / 2;
39247
+ hookPoints.push(new Point(startPoint.x, midY));
39248
+ hookPoints.push(new Point(endPoint.x, midY));
39249
+ return hookPoints;
39250
+ }
39251
+ if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
39252
+ const midY = (startPoint.y + endPoint.y) / 2;
39253
+ hookPoints.push(new Point(startPoint.x, midY));
39254
+ hookPoints.push(new Point(endPoint.x, midY));
39255
+ return hookPoints;
39256
+ }
39257
+ if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
39258
+ const midX = (startPoint.x + endPoint.x) / 2;
39259
+ hookPoints.push(new Point(midX, startPoint.y));
39260
+ hookPoints.push(new Point(midX, endPoint.y));
39261
+ return hookPoints;
39262
+ }
39263
+ if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
39264
+ const midX = (startPoint.x + endPoint.x) / 2;
39265
+ hookPoints.push(new Point(midX, startPoint.y));
39266
+ hookPoints.push(new Point(midX, endPoint.y));
39267
+ return hookPoints;
39268
+ }
39269
+ return hookPoints;
39270
+ }
39243
39271
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39244
39272
  const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
39245
39273
  const startPoint = newStart || start;
39246
39274
  const endPoint = newEnd || end;
39247
- const points = [startPoint, ...toVisitPoints, endPoint];
39275
+ const startDir = getPointerDirection(start);
39276
+ const endDir = getPointerDirection(end);
39277
+ const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
39278
+ const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
39248
39279
  const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
39249
39280
  return {
39250
39281
  lines: getLines(pathPoints),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.78",
3
+ "version": "0.5.79",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",