microboard-temp 0.5.97 → 0.5.99

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.
@@ -36682,6 +36682,7 @@ function getDirection(from, to) {
36682
36682
  return null;
36683
36683
  }
36684
36684
  function isChangingDirection(current, neighbor, newStart, newEnd) {
36685
+ const TURN_PENALTY = 50;
36685
36686
  const dirMap = {
36686
36687
  top: "vertical",
36687
36688
  bottom: "vertical",
@@ -36693,13 +36694,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
36693
36694
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
36694
36695
  const endDir = dirMap[getPointerDirection(newEnd)];
36695
36696
  if (goingDirection && endDir !== goingDirection) {
36696
- return 1 + isChangingDirection(current, neighbor, newStart);
36697
+ return TURN_PENALTY;
36697
36698
  }
36698
36699
  }
36699
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
36700
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
36701
+ return TURN_PENALTY;
36702
+ }
36703
+ return 0;
36700
36704
  }
36701
36705
  function heuristic(start, end) {
36702
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
36706
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
36703
36707
  }
36704
36708
  function getNeighbors(node2, grid, obstacles) {
36705
36709
  const neighbors = [];
@@ -36827,9 +36831,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
36827
36831
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
36828
36832
  continue;
36829
36833
  }
36830
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
36834
+ const TURN_PENALTY = 500;
36835
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
36836
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
36831
36837
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
36832
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
36838
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
36833
36839
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
36834
36840
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
36835
36841
  if (existingNodeInOpenSet) {
package/dist/cjs/index.js CHANGED
@@ -36682,6 +36682,7 @@ function getDirection(from, to) {
36682
36682
  return null;
36683
36683
  }
36684
36684
  function isChangingDirection(current, neighbor, newStart, newEnd) {
36685
+ const TURN_PENALTY = 50;
36685
36686
  const dirMap = {
36686
36687
  top: "vertical",
36687
36688
  bottom: "vertical",
@@ -36693,13 +36694,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
36693
36694
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
36694
36695
  const endDir = dirMap[getPointerDirection(newEnd)];
36695
36696
  if (goingDirection && endDir !== goingDirection) {
36696
- return 1 + isChangingDirection(current, neighbor, newStart);
36697
+ return TURN_PENALTY;
36697
36698
  }
36698
36699
  }
36699
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
36700
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
36701
+ return TURN_PENALTY;
36702
+ }
36703
+ return 0;
36700
36704
  }
36701
36705
  function heuristic(start, end) {
36702
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
36706
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
36703
36707
  }
36704
36708
  function getNeighbors(node2, grid, obstacles) {
36705
36709
  const neighbors = [];
@@ -36827,9 +36831,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
36827
36831
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
36828
36832
  continue;
36829
36833
  }
36830
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
36834
+ const TURN_PENALTY = 500;
36835
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
36836
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
36831
36837
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
36832
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
36838
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
36833
36839
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
36834
36840
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
36835
36841
  if (existingNodeInOpenSet) {
package/dist/cjs/node.js CHANGED
@@ -39155,6 +39155,7 @@ function getDirection(from, to) {
39155
39155
  return null;
39156
39156
  }
39157
39157
  function isChangingDirection(current, neighbor, newStart, newEnd) {
39158
+ const TURN_PENALTY = 50;
39158
39159
  const dirMap = {
39159
39160
  top: "vertical",
39160
39161
  bottom: "vertical",
@@ -39166,13 +39167,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
39166
39167
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
39167
39168
  const endDir = dirMap[getPointerDirection(newEnd)];
39168
39169
  if (goingDirection && endDir !== goingDirection) {
39169
- return 1 + isChangingDirection(current, neighbor, newStart);
39170
+ return TURN_PENALTY;
39170
39171
  }
39171
39172
  }
39172
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
39173
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
39174
+ return TURN_PENALTY;
39175
+ }
39176
+ return 0;
39173
39177
  }
39174
39178
  function heuristic(start, end) {
39175
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
39179
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
39176
39180
  }
39177
39181
  function getNeighbors(node2, grid, obstacles) {
39178
39182
  const neighbors = [];
@@ -39300,9 +39304,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
39300
39304
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
39301
39305
  continue;
39302
39306
  }
39303
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
39307
+ const TURN_PENALTY = 500;
39308
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
39309
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
39304
39310
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
39305
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
39311
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
39306
39312
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
39307
39313
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
39308
39314
  if (existingNodeInOpenSet) {
@@ -36527,6 +36527,7 @@ function getDirection(from, to) {
36527
36527
  return null;
36528
36528
  }
36529
36529
  function isChangingDirection(current, neighbor, newStart, newEnd) {
36530
+ const TURN_PENALTY = 50;
36530
36531
  const dirMap = {
36531
36532
  top: "vertical",
36532
36533
  bottom: "vertical",
@@ -36538,13 +36539,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
36538
36539
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
36539
36540
  const endDir = dirMap[getPointerDirection(newEnd)];
36540
36541
  if (goingDirection && endDir !== goingDirection) {
36541
- return 1 + isChangingDirection(current, neighbor, newStart);
36542
+ return TURN_PENALTY;
36542
36543
  }
36543
36544
  }
36544
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
36545
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
36546
+ return TURN_PENALTY;
36547
+ }
36548
+ return 0;
36545
36549
  }
36546
36550
  function heuristic(start, end) {
36547
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
36551
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
36548
36552
  }
36549
36553
  function getNeighbors(node2, grid, obstacles) {
36550
36554
  const neighbors = [];
@@ -36672,9 +36676,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
36672
36676
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
36673
36677
  continue;
36674
36678
  }
36675
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
36679
+ const TURN_PENALTY = 500;
36680
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
36681
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
36676
36682
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
36677
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
36683
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
36678
36684
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
36679
36685
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
36680
36686
  if (existingNodeInOpenSet) {
package/dist/esm/index.js CHANGED
@@ -36520,6 +36520,7 @@ function getDirection(from, to) {
36520
36520
  return null;
36521
36521
  }
36522
36522
  function isChangingDirection(current, neighbor, newStart, newEnd) {
36523
+ const TURN_PENALTY = 50;
36523
36524
  const dirMap = {
36524
36525
  top: "vertical",
36525
36526
  bottom: "vertical",
@@ -36531,13 +36532,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
36531
36532
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
36532
36533
  const endDir = dirMap[getPointerDirection(newEnd)];
36533
36534
  if (goingDirection && endDir !== goingDirection) {
36534
- return 1 + isChangingDirection(current, neighbor, newStart);
36535
+ return TURN_PENALTY;
36535
36536
  }
36536
36537
  }
36537
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
36538
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
36539
+ return TURN_PENALTY;
36540
+ }
36541
+ return 0;
36538
36542
  }
36539
36543
  function heuristic(start, end) {
36540
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
36544
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
36541
36545
  }
36542
36546
  function getNeighbors(node2, grid, obstacles) {
36543
36547
  const neighbors = [];
@@ -36665,9 +36669,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
36665
36669
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
36666
36670
  continue;
36667
36671
  }
36668
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
36672
+ const TURN_PENALTY = 500;
36673
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
36674
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
36669
36675
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
36670
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
36676
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
36671
36677
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
36672
36678
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
36673
36679
  if (existingNodeInOpenSet) {
package/dist/esm/node.js CHANGED
@@ -38988,6 +38988,7 @@ function getDirection(from, to) {
38988
38988
  return null;
38989
38989
  }
38990
38990
  function isChangingDirection(current, neighbor, newStart, newEnd) {
38991
+ const TURN_PENALTY = 50;
38991
38992
  const dirMap = {
38992
38993
  top: "vertical",
38993
38994
  bottom: "vertical",
@@ -38999,13 +39000,16 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
38999
39000
  if (newEnd && neighbor.point.barelyEqual(newEnd)) {
39000
39001
  const endDir = dirMap[getPointerDirection(newEnd)];
39001
39002
  if (goingDirection && endDir !== goingDirection) {
39002
- return 1 + isChangingDirection(current, neighbor, newStart);
39003
+ return TURN_PENALTY;
39003
39004
  }
39004
39005
  }
39005
- return comingDirection && goingDirection && comingDirection !== goingDirection ? 1 : 0;
39006
+ if (comingDirection && goingDirection && comingDirection !== goingDirection) {
39007
+ return TURN_PENALTY;
39008
+ }
39009
+ return 0;
39006
39010
  }
39007
39011
  function heuristic(start, end) {
39008
- return Math.abs(start.xGrid - end.xGrid) + Math.abs(start.yGrid - end.yGrid);
39012
+ return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
39009
39013
  }
39010
39014
  function getNeighbors(node2, grid, obstacles) {
39011
39015
  const neighbors = [];
@@ -39133,9 +39137,11 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
39133
39137
  if (closedSet.has(neighborKey) || existingPath.has(neighborKey) && !neighbor.point.barelyEqual(end)) {
39134
39138
  continue;
39135
39139
  }
39136
- const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
39140
+ const TURN_PENALTY = 500;
39141
+ const extraCost = isChangingDirection(current, neighbor, newStart, newEnd) ? TURN_PENALTY : 0;
39142
+ const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
39137
39143
  const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
39138
- const tentativeCost = current.costSoFar + 1 + pathOverlapCost;
39144
+ const tentativeCost = current.costSoFar + movementCost + pathOverlapCost;
39139
39145
  let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
39140
39146
  if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
39141
39147
  if (existingNodeInOpenSet) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.97",
3
+ "version": "0.5.99",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",