@tscircuit/capacity-autorouter 0.0.96 → 0.0.97
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 +2 -0
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1751,6 +1751,8 @@ declare class DeadEndSolver extends BaseSolver {
|
|
|
1751
1751
|
private leaves;
|
|
1752
1752
|
private leavesIndex;
|
|
1753
1753
|
private adjacencyList;
|
|
1754
|
+
/** Only used for visualization, dynamically instantiated if necessary */
|
|
1755
|
+
nodeMap?: Map<CapacityMeshNodeId, CapacityMeshNode>;
|
|
1754
1756
|
private nodes;
|
|
1755
1757
|
private edges;
|
|
1756
1758
|
constructor({ nodes, edges, }: {
|
package/dist/index.js
CHANGED
|
@@ -15868,6 +15868,8 @@ var DeadEndSolver = class extends BaseSolver {
|
|
|
15868
15868
|
leaves;
|
|
15869
15869
|
leavesIndex;
|
|
15870
15870
|
adjacencyList;
|
|
15871
|
+
/** Only used for visualization, dynamically instantiated if necessary */
|
|
15872
|
+
nodeMap;
|
|
15871
15873
|
// Store the nodes and edges just for visualization purposes
|
|
15872
15874
|
nodes;
|
|
15873
15875
|
edges;
|
|
@@ -15914,19 +15916,42 @@ var DeadEndSolver = class extends BaseSolver {
|
|
|
15914
15916
|
}
|
|
15915
15917
|
}
|
|
15916
15918
|
visualize() {
|
|
15919
|
+
if (!this.nodeMap) {
|
|
15920
|
+
this.nodeMap = /* @__PURE__ */ new Map();
|
|
15921
|
+
for (const node of this.nodes) {
|
|
15922
|
+
this.nodeMap.set(node.capacityMeshNodeId, node);
|
|
15923
|
+
}
|
|
15924
|
+
}
|
|
15917
15925
|
const graphics = {
|
|
15918
15926
|
lines: [],
|
|
15919
15927
|
points: [],
|
|
15920
|
-
rects:
|
|
15928
|
+
rects: this.nodes.map((node) => {
|
|
15929
|
+
const lowestZ = Math.min(...node.availableZ);
|
|
15930
|
+
return {
|
|
15931
|
+
width: Math.max(node.width - 2, node.width * 0.8),
|
|
15932
|
+
height: Math.max(node.height - 2, node.height * 0.8),
|
|
15933
|
+
center: {
|
|
15934
|
+
x: node.center.x + lowestZ * node.width * 0.05,
|
|
15935
|
+
y: node.center.y - lowestZ * node.width * 0.05
|
|
15936
|
+
},
|
|
15937
|
+
fill: node._containsObstacle ? "rgba(255,0,0,0.1)" : {
|
|
15938
|
+
"0,1": "rgba(0,0,0,0.1)",
|
|
15939
|
+
"0": "rgba(0,200,200, 0.1)",
|
|
15940
|
+
"1": "rgba(0,0,200, 0.1)"
|
|
15941
|
+
}[node.availableZ.join(",")] ?? "rgba(0,200,200,0.1)",
|
|
15942
|
+
label: [
|
|
15943
|
+
node.capacityMeshNodeId,
|
|
15944
|
+
`availableZ: ${node.availableZ.join(",")}`,
|
|
15945
|
+
`target? ${node._containsTarget ?? false}`,
|
|
15946
|
+
`obs? ${node._containsObstacle ?? false}`
|
|
15947
|
+
].join("\n")
|
|
15948
|
+
};
|
|
15949
|
+
}),
|
|
15921
15950
|
circles: []
|
|
15922
15951
|
};
|
|
15923
15952
|
for (const edge of this.edges) {
|
|
15924
|
-
|
|
15925
|
-
|
|
15926
|
-
}
|
|
15927
|
-
const [node1, node2] = edge.nodeIds.map((nodeId) => {
|
|
15928
|
-
return this.nodes.find((node) => node.capacityMeshNodeId === nodeId);
|
|
15929
|
-
});
|
|
15953
|
+
const node1 = this.nodeMap.get(edge.nodeIds[0]);
|
|
15954
|
+
const node2 = this.nodeMap.get(edge.nodeIds[1]);
|
|
15930
15955
|
if (node1?.center && node2?.center) {
|
|
15931
15956
|
const lowestZ1 = Math.min(...node1.availableZ);
|
|
15932
15957
|
const lowestZ2 = Math.min(...node2.availableZ);
|
|
@@ -15939,8 +15964,11 @@ var DeadEndSolver = class extends BaseSolver {
|
|
|
15939
15964
|
y: node2.center.y - lowestZ2 * node2.width * 0.05
|
|
15940
15965
|
};
|
|
15941
15966
|
graphics.lines.push({
|
|
15942
|
-
|
|
15943
|
-
|
|
15967
|
+
points: [nodeCenter1Adj, nodeCenter2Adj],
|
|
15968
|
+
strokeDash: node1.availableZ.join(",") === node2.availableZ.join(",") ? void 0 : "10 5",
|
|
15969
|
+
strokeColor: edge.nodeIds.some(
|
|
15970
|
+
(nodeId) => this.removedNodeIds.has(nodeId)
|
|
15971
|
+
) ? safeTransparentize("black", 0.9) : void 0
|
|
15944
15972
|
});
|
|
15945
15973
|
}
|
|
15946
15974
|
}
|