microboard-temp 0.5.92 → 0.5.94

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.
@@ -36924,20 +36924,6 @@ function reconstructPath(node2) {
36924
36924
  }
36925
36925
  return path2.reverse();
36926
36926
  }
36927
- function findClosestPointInGrid(point5, grid) {
36928
- let closestPoint = grid[0][0];
36929
- let minDistance = Infinity;
36930
- for (const row2 of grid) {
36931
- for (const gridPoint of row2) {
36932
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36933
- if (distance < minDistance) {
36934
- minDistance = distance;
36935
- closestPoint = gridPoint;
36936
- }
36937
- }
36938
- }
36939
- return closestPoint;
36940
- }
36941
36927
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36942
36928
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36943
36929
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36981,8 +36967,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36981
36967
  }
36982
36968
  return [];
36983
36969
  }
36970
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36971
+ let closestPoint = null;
36972
+ let minDistance = Infinity;
36973
+ for (const row2 of grid) {
36974
+ for (const gridPoint of row2) {
36975
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36976
+ if (isPointValid) {
36977
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36978
+ if (distance < minDistance) {
36979
+ minDistance = distance;
36980
+ closestPoint = gridPoint;
36981
+ }
36982
+ }
36983
+ }
36984
+ }
36985
+ return closestPoint;
36986
+ }
36984
36987
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36985
- const tempGridInfo = createGrid(start, end);
36988
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
36986
36989
  const startPoint = tempGridInfo.newStart || start;
36987
36990
  const endPoint = tempGridInfo.newEnd || end;
36988
36991
  const startDir = getPointerDirection(start);
@@ -36992,15 +36995,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36992
36995
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36993
36996
  const finalStart = newStart || start;
36994
36997
  const finalEnd = newEnd || end;
36995
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36996
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36998
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
36999
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
37000
+ if (snappedAndValidatedPoints.length < 2) {
37001
+ return { lines: [], newStart, newEnd };
37002
+ }
37003
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
36997
37004
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36998
37005
  acc.push(p3);
36999
37006
  }
37000
37007
  return acc;
37001
37008
  }, []);
37002
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
37003
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
37009
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
37004
37010
  return {
37005
37011
  lines: getLines(pathPoints),
37006
37012
  newStart,
package/dist/cjs/index.js CHANGED
@@ -36924,20 +36924,6 @@ function reconstructPath(node2) {
36924
36924
  }
36925
36925
  return path2.reverse();
36926
36926
  }
36927
- function findClosestPointInGrid(point5, grid) {
36928
- let closestPoint = grid[0][0];
36929
- let minDistance = Infinity;
36930
- for (const row2 of grid) {
36931
- for (const gridPoint of row2) {
36932
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36933
- if (distance < minDistance) {
36934
- minDistance = distance;
36935
- closestPoint = gridPoint;
36936
- }
36937
- }
36938
- }
36939
- return closestPoint;
36940
- }
36941
36927
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36942
36928
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36943
36929
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36981,8 +36967,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36981
36967
  }
36982
36968
  return [];
36983
36969
  }
36970
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36971
+ let closestPoint = null;
36972
+ let minDistance = Infinity;
36973
+ for (const row2 of grid) {
36974
+ for (const gridPoint of row2) {
36975
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36976
+ if (isPointValid) {
36977
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36978
+ if (distance < minDistance) {
36979
+ minDistance = distance;
36980
+ closestPoint = gridPoint;
36981
+ }
36982
+ }
36983
+ }
36984
+ }
36985
+ return closestPoint;
36986
+ }
36984
36987
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36985
- const tempGridInfo = createGrid(start, end);
36988
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
36986
36989
  const startPoint = tempGridInfo.newStart || start;
36987
36990
  const endPoint = tempGridInfo.newEnd || end;
36988
36991
  const startDir = getPointerDirection(start);
@@ -36992,15 +36995,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36992
36995
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36993
36996
  const finalStart = newStart || start;
36994
36997
  const finalEnd = newEnd || end;
36995
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36996
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36998
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
36999
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
37000
+ if (snappedAndValidatedPoints.length < 2) {
37001
+ return { lines: [], newStart, newEnd };
37002
+ }
37003
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
36997
37004
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36998
37005
  acc.push(p3);
36999
37006
  }
37000
37007
  return acc;
37001
37008
  }, []);
37002
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
37003
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
37009
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
37004
37010
  return {
37005
37011
  lines: getLines(pathPoints),
37006
37012
  newStart,
package/dist/cjs/node.js CHANGED
@@ -39397,20 +39397,6 @@ function reconstructPath(node2) {
39397
39397
  }
39398
39398
  return path2.reverse();
39399
39399
  }
39400
- function findClosestPointInGrid(point5, grid) {
39401
- let closestPoint = grid[0][0];
39402
- let minDistance = Infinity;
39403
- for (const row2 of grid) {
39404
- for (const gridPoint of row2) {
39405
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39406
- if (distance < minDistance) {
39407
- minDistance = distance;
39408
- closestPoint = gridPoint;
39409
- }
39410
- }
39411
- }
39412
- return closestPoint;
39413
- }
39414
39400
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39415
39401
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39416
39402
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -39454,8 +39440,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39454
39440
  }
39455
39441
  return [];
39456
39442
  }
39443
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
39444
+ let closestPoint = null;
39445
+ let minDistance = Infinity;
39446
+ for (const row2 of grid) {
39447
+ for (const gridPoint of row2) {
39448
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
39449
+ if (isPointValid) {
39450
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39451
+ if (distance < minDistance) {
39452
+ minDistance = distance;
39453
+ closestPoint = gridPoint;
39454
+ }
39455
+ }
39456
+ }
39457
+ }
39458
+ return closestPoint;
39459
+ }
39457
39460
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39458
- const tempGridInfo = createGrid(start, end);
39461
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
39459
39462
  const startPoint = tempGridInfo.newStart || start;
39460
39463
  const endPoint = tempGridInfo.newEnd || end;
39461
39464
  const startDir = getPointerDirection(start);
@@ -39465,15 +39468,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39465
39468
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
39466
39469
  const finalStart = newStart || start;
39467
39470
  const finalEnd = newEnd || end;
39468
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
39469
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
39471
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
39472
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
39473
+ if (snappedAndValidatedPoints.length < 2) {
39474
+ return { lines: [], newStart, newEnd };
39475
+ }
39476
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
39470
39477
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
39471
39478
  acc.push(p3);
39472
39479
  }
39473
39480
  return acc;
39474
39481
  }, []);
39475
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
39476
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
39482
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
39477
39483
  return {
39478
39484
  lines: getLines(pathPoints),
39479
39485
  newStart,
@@ -36769,20 +36769,6 @@ function reconstructPath(node2) {
36769
36769
  }
36770
36770
  return path2.reverse();
36771
36771
  }
36772
- function findClosestPointInGrid(point5, grid) {
36773
- let closestPoint = grid[0][0];
36774
- let minDistance = Infinity;
36775
- for (const row2 of grid) {
36776
- for (const gridPoint of row2) {
36777
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36778
- if (distance < minDistance) {
36779
- minDistance = distance;
36780
- closestPoint = gridPoint;
36781
- }
36782
- }
36783
- }
36784
- return closestPoint;
36785
- }
36786
36772
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36787
36773
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36788
36774
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36826,8 +36812,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36826
36812
  }
36827
36813
  return [];
36828
36814
  }
36815
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36816
+ let closestPoint = null;
36817
+ let minDistance = Infinity;
36818
+ for (const row2 of grid) {
36819
+ for (const gridPoint of row2) {
36820
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36821
+ if (isPointValid) {
36822
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36823
+ if (distance < minDistance) {
36824
+ minDistance = distance;
36825
+ closestPoint = gridPoint;
36826
+ }
36827
+ }
36828
+ }
36829
+ }
36830
+ return closestPoint;
36831
+ }
36829
36832
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36830
- const tempGridInfo = createGrid(start, end);
36833
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
36831
36834
  const startPoint = tempGridInfo.newStart || start;
36832
36835
  const endPoint = tempGridInfo.newEnd || end;
36833
36836
  const startDir = getPointerDirection(start);
@@ -36837,15 +36840,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36837
36840
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36838
36841
  const finalStart = newStart || start;
36839
36842
  const finalEnd = newEnd || end;
36840
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36841
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36843
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
36844
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
36845
+ if (snappedAndValidatedPoints.length < 2) {
36846
+ return { lines: [], newStart, newEnd };
36847
+ }
36848
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
36842
36849
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36843
36850
  acc.push(p3);
36844
36851
  }
36845
36852
  return acc;
36846
36853
  }, []);
36847
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
36848
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
36854
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
36849
36855
  return {
36850
36856
  lines: getLines(pathPoints),
36851
36857
  newStart,
package/dist/esm/index.js CHANGED
@@ -36762,20 +36762,6 @@ function reconstructPath(node2) {
36762
36762
  }
36763
36763
  return path2.reverse();
36764
36764
  }
36765
- function findClosestPointInGrid(point5, grid) {
36766
- let closestPoint = grid[0][0];
36767
- let minDistance = Infinity;
36768
- for (const row2 of grid) {
36769
- for (const gridPoint of row2) {
36770
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36771
- if (distance < minDistance) {
36772
- minDistance = distance;
36773
- closestPoint = gridPoint;
36774
- }
36775
- }
36776
- }
36777
- return closestPoint;
36778
- }
36779
36765
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36780
36766
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36781
36767
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36819,8 +36805,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36819
36805
  }
36820
36806
  return [];
36821
36807
  }
36808
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36809
+ let closestPoint = null;
36810
+ let minDistance = Infinity;
36811
+ for (const row2 of grid) {
36812
+ for (const gridPoint of row2) {
36813
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36814
+ if (isPointValid) {
36815
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36816
+ if (distance < minDistance) {
36817
+ minDistance = distance;
36818
+ closestPoint = gridPoint;
36819
+ }
36820
+ }
36821
+ }
36822
+ }
36823
+ return closestPoint;
36824
+ }
36822
36825
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36823
- const tempGridInfo = createGrid(start, end);
36826
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
36824
36827
  const startPoint = tempGridInfo.newStart || start;
36825
36828
  const endPoint = tempGridInfo.newEnd || end;
36826
36829
  const startDir = getPointerDirection(start);
@@ -36830,15 +36833,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36830
36833
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36831
36834
  const finalStart = newStart || start;
36832
36835
  const finalEnd = newEnd || end;
36833
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36834
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36836
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
36837
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
36838
+ if (snappedAndValidatedPoints.length < 2) {
36839
+ return { lines: [], newStart, newEnd };
36840
+ }
36841
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
36835
36842
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36836
36843
  acc.push(p3);
36837
36844
  }
36838
36845
  return acc;
36839
36846
  }, []);
36840
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
36841
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
36847
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
36842
36848
  return {
36843
36849
  lines: getLines(pathPoints),
36844
36850
  newStart,
package/dist/esm/node.js CHANGED
@@ -39230,20 +39230,6 @@ function reconstructPath(node2) {
39230
39230
  }
39231
39231
  return path2.reverse();
39232
39232
  }
39233
- function findClosestPointInGrid(point5, grid) {
39234
- let closestPoint = grid[0][0];
39235
- let minDistance = Infinity;
39236
- for (const row2 of grid) {
39237
- for (const gridPoint of row2) {
39238
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39239
- if (distance < minDistance) {
39240
- minDistance = distance;
39241
- closestPoint = gridPoint;
39242
- }
39243
- }
39244
- }
39245
- return closestPoint;
39246
- }
39247
39233
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39248
39234
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39249
39235
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -39287,8 +39273,25 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39287
39273
  }
39288
39274
  return [];
39289
39275
  }
39276
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
39277
+ let closestPoint = null;
39278
+ let minDistance = Infinity;
39279
+ for (const row2 of grid) {
39280
+ for (const gridPoint of row2) {
39281
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
39282
+ if (isPointValid) {
39283
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39284
+ if (distance < minDistance) {
39285
+ minDistance = distance;
39286
+ closestPoint = gridPoint;
39287
+ }
39288
+ }
39289
+ }
39290
+ }
39291
+ return closestPoint;
39292
+ }
39290
39293
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39291
- const tempGridInfo = createGrid(start, end);
39294
+ const tempGridInfo = createGrid(start, end, toVisitPoints);
39292
39295
  const startPoint = tempGridInfo.newStart || start;
39293
39296
  const endPoint = tempGridInfo.newEnd || end;
39294
39297
  const startDir = getPointerDirection(start);
@@ -39298,15 +39301,18 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39298
39301
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
39299
39302
  const finalStart = newStart || start;
39300
39303
  const finalEnd = newEnd || end;
39301
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
39302
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
39304
+ const pointsToSnap = [finalStart, ...allWaypoints, finalEnd];
39305
+ const snappedAndValidatedPoints = pointsToSnap.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
39306
+ if (snappedAndValidatedPoints.length < 2) {
39307
+ return { lines: [], newStart, newEnd };
39308
+ }
39309
+ const uniquePoints = snappedAndValidatedPoints.reduce((acc, p3) => {
39303
39310
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
39304
39311
  acc.push(p3);
39305
39312
  }
39306
39313
  return acc;
39307
39314
  }, []);
39308
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
39309
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
39315
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
39310
39316
  return {
39311
39317
  lines: getLines(pathPoints),
39312
39318
  newStart,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.92",
3
+ "version": "0.5.94",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",