@tscircuit/capacity-autorouter 0.0.37 → 0.0.39
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/dist/index.d.ts +3 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -503,6 +503,7 @@ type FutureConnection = {
|
|
|
503
503
|
points: {
|
|
504
504
|
x: number;
|
|
505
505
|
y: number;
|
|
506
|
+
z: number;
|
|
506
507
|
}[];
|
|
507
508
|
};
|
|
508
509
|
declare class SingleHighDensityRouteSolver extends BaseSolver {
|
|
@@ -619,9 +620,10 @@ declare class IntraNodeRouteSolver extends BaseSolver {
|
|
|
619
620
|
failedSubSolvers: SingleHighDensityRouteSolver[];
|
|
620
621
|
hyperParameters: Partial<HighDensityHyperParameters>;
|
|
621
622
|
minDistBetweenEnteringPoints: number;
|
|
622
|
-
|
|
623
|
+
activeSubSolver: SingleHighDensityRouteSolver | null;
|
|
623
624
|
connMap?: ConnectivityMap;
|
|
624
625
|
get failedSolvers(): SingleHighDensityRouteSolver[];
|
|
626
|
+
get activeSolver(): SingleHighDensityRouteSolver | null;
|
|
625
627
|
constructor(params: {
|
|
626
628
|
nodeWithPortPoints: NodeWithPortPoints;
|
|
627
629
|
colorMap?: Record<string, string>;
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var combineVisualizations = (...visualizations) => {
|
|
|
7
7
|
rects: []
|
|
8
8
|
};
|
|
9
9
|
visualizations.forEach((viz, i) => {
|
|
10
|
+
if (!viz) return;
|
|
10
11
|
if (viz.lines) {
|
|
11
12
|
combined.lines = [
|
|
12
13
|
...combined.lines || [],
|
|
@@ -2320,7 +2321,7 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
|
|
|
2320
2321
|
goalDist,
|
|
2321
2322
|
currentNode.z === this.B.z
|
|
2322
2323
|
);
|
|
2323
|
-
if (goalDist <= this.cellStep && currentNode.z === this.B.z) {
|
|
2324
|
+
if (goalDist <= this.cellStep * Math.SQRT2 && currentNode.z === this.B.z) {
|
|
2324
2325
|
this.solved = true;
|
|
2325
2326
|
this.setSolvedPath(currentNode);
|
|
2326
2327
|
}
|
|
@@ -2453,7 +2454,7 @@ var SingleHighDensityRouteSolver6_VertHorzLayer_FutureCost = class extends Singl
|
|
|
2453
2454
|
let closestPoint = null;
|
|
2454
2455
|
for (const futureConnection of this.futureConnections) {
|
|
2455
2456
|
for (const point of futureConnection.points) {
|
|
2456
|
-
const dist = distance(node, point);
|
|
2457
|
+
const dist = distance(node, point) + (node.z !== point.z ? this.viaPenaltyDistance : 0);
|
|
2457
2458
|
if (dist < minDist) {
|
|
2458
2459
|
minDist = dist;
|
|
2459
2460
|
closestPoint = point;
|
|
@@ -2567,6 +2568,9 @@ var getMinDistBetweenEnteringPoints = (node) => {
|
|
|
2567
2568
|
const points = node.portPoints;
|
|
2568
2569
|
for (let i = 0; i < points.length; i++) {
|
|
2569
2570
|
for (let j = i + 1; j < points.length; j++) {
|
|
2571
|
+
if (points[i].z !== points[j].z) {
|
|
2572
|
+
continue;
|
|
2573
|
+
}
|
|
2570
2574
|
const p1 = points[i];
|
|
2571
2575
|
const p2 = points[j];
|
|
2572
2576
|
const dist = Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2);
|
|
@@ -2586,12 +2590,16 @@ var IntraNodeRouteSolver = class extends BaseSolver {
|
|
|
2586
2590
|
failedSubSolvers;
|
|
2587
2591
|
hyperParameters;
|
|
2588
2592
|
minDistBetweenEnteringPoints;
|
|
2589
|
-
|
|
2593
|
+
activeSubSolver = null;
|
|
2590
2594
|
connMap;
|
|
2591
2595
|
// Legacy compat
|
|
2592
2596
|
get failedSolvers() {
|
|
2593
2597
|
return this.failedSubSolvers;
|
|
2594
2598
|
}
|
|
2599
|
+
// Legacy compat
|
|
2600
|
+
get activeSolver() {
|
|
2601
|
+
return this.activeSubSolver;
|
|
2602
|
+
}
|
|
2595
2603
|
constructor(params) {
|
|
2596
2604
|
const { nodeWithPortPoints, colorMap } = params;
|
|
2597
2605
|
super();
|
|
@@ -2650,18 +2658,18 @@ var IntraNodeRouteSolver = class extends BaseSolver {
|
|
|
2650
2658
|
// this.unsolvedConnections = []
|
|
2651
2659
|
// }
|
|
2652
2660
|
computeProgress() {
|
|
2653
|
-
return (this.solvedRoutes.length + (this.
|
|
2661
|
+
return (this.solvedRoutes.length + (this.activeSubSolver?.progress || 0)) / this.totalConnections;
|
|
2654
2662
|
}
|
|
2655
2663
|
_step() {
|
|
2656
|
-
if (this.
|
|
2657
|
-
this.
|
|
2664
|
+
if (this.activeSubSolver) {
|
|
2665
|
+
this.activeSubSolver.step();
|
|
2658
2666
|
this.progress = this.computeProgress();
|
|
2659
|
-
if (this.
|
|
2660
|
-
this.solvedRoutes.push(this.
|
|
2661
|
-
this.
|
|
2662
|
-
} else if (this.
|
|
2663
|
-
this.failedSubSolvers.push(this.
|
|
2664
|
-
this.
|
|
2667
|
+
if (this.activeSubSolver.solved) {
|
|
2668
|
+
this.solvedRoutes.push(this.activeSubSolver.solvedPath);
|
|
2669
|
+
this.activeSubSolver = null;
|
|
2670
|
+
} else if (this.activeSubSolver.failed) {
|
|
2671
|
+
this.failedSubSolvers.push(this.activeSubSolver);
|
|
2672
|
+
this.activeSubSolver = null;
|
|
2665
2673
|
this.error = this.failedSubSolvers.map((s) => s.error).join("\n");
|
|
2666
2674
|
this.failed = true;
|
|
2667
2675
|
}
|
|
@@ -2683,7 +2691,7 @@ var IntraNodeRouteSolver = class extends BaseSolver {
|
|
|
2683
2691
|
}
|
|
2684
2692
|
}
|
|
2685
2693
|
const { connectionName, points } = unsolvedConnection;
|
|
2686
|
-
this.
|
|
2694
|
+
this.activeSubSolver = new SingleHighDensityRouteSolver6_VertHorzLayer_FutureCost({
|
|
2687
2695
|
connectionName,
|
|
2688
2696
|
minDistBetweenEnteringPoints: this.minDistBetweenEnteringPoints,
|
|
2689
2697
|
bounds: getBoundsFromNodeWithPortPoints(this.nodeWithPortPoints),
|