@tscircuit/capacity-autorouter 0.0.96 → 0.0.98

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 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
@@ -15782,7 +15782,8 @@ var CapacityMeshEdgeSolver = class extends BaseSolver {
15782
15782
  `availableZ: ${node.availableZ.join(",")}`,
15783
15783
  `target? ${node._containsTarget ?? false}`,
15784
15784
  `obs? ${node._containsObstacle ?? false}`
15785
- ].join("\n")
15785
+ ].join("\n"),
15786
+ layer: `z${node.availableZ.join(",")}`
15786
15787
  };
15787
15788
  }),
15788
15789
  circles: []
@@ -15807,7 +15808,11 @@ var CapacityMeshEdgeSolver = class extends BaseSolver {
15807
15808
  x: node2.center.x + lowestZ2 * node2.width * 0.05,
15808
15809
  y: node2.center.y - lowestZ2 * node2.width * 0.05
15809
15810
  };
15811
+ const availableZ = Array.from(
15812
+ /* @__PURE__ */ new Set([...node1.availableZ, ...node2.availableZ])
15813
+ ).sort();
15810
15814
  graphics.lines.push({
15815
+ layer: `z${availableZ.join(",")}`,
15811
15816
  points: [nodeCenter1Adj, nodeCenter2Adj],
15812
15817
  strokeDash: node1.availableZ.join(",") === node2.availableZ.join(",") ? void 0 : "10 5"
15813
15818
  });
@@ -15868,6 +15873,8 @@ var DeadEndSolver = class extends BaseSolver {
15868
15873
  leaves;
15869
15874
  leavesIndex;
15870
15875
  adjacencyList;
15876
+ /** Only used for visualization, dynamically instantiated if necessary */
15877
+ nodeMap;
15871
15878
  // Store the nodes and edges just for visualization purposes
15872
15879
  nodes;
15873
15880
  edges;
@@ -15914,19 +15921,43 @@ var DeadEndSolver = class extends BaseSolver {
15914
15921
  }
15915
15922
  }
15916
15923
  visualize() {
15924
+ if (!this.nodeMap) {
15925
+ this.nodeMap = /* @__PURE__ */ new Map();
15926
+ for (const node of this.nodes) {
15927
+ this.nodeMap.set(node.capacityMeshNodeId, node);
15928
+ }
15929
+ }
15917
15930
  const graphics = {
15918
15931
  lines: [],
15919
15932
  points: [],
15920
- rects: [],
15933
+ rects: this.nodes.map((node) => {
15934
+ const lowestZ = Math.min(...node.availableZ);
15935
+ return {
15936
+ width: Math.max(node.width - 2, node.width * 0.8),
15937
+ height: Math.max(node.height - 2, node.height * 0.8),
15938
+ center: {
15939
+ x: node.center.x + lowestZ * node.width * 0.05,
15940
+ y: node.center.y - lowestZ * node.width * 0.05
15941
+ },
15942
+ fill: node._containsObstacle ? "rgba(255,0,0,0.1)" : {
15943
+ "0,1": "rgba(0,0,0,0.1)",
15944
+ "0": "rgba(0,200,200, 0.1)",
15945
+ "1": "rgba(0,0,200, 0.1)"
15946
+ }[node.availableZ.join(",")] ?? "rgba(0,200,200,0.1)",
15947
+ label: [
15948
+ node.capacityMeshNodeId,
15949
+ `availableZ: ${node.availableZ.join(",")}`,
15950
+ `target? ${node._containsTarget ?? false}`,
15951
+ `obs? ${node._containsObstacle ?? false}`
15952
+ ].join("\n"),
15953
+ layer: `z${node.availableZ.join(",")}`
15954
+ };
15955
+ }),
15921
15956
  circles: []
15922
15957
  };
15923
15958
  for (const edge of this.edges) {
15924
- if (!edge.nodeIds.some((nodeId) => this.removedNodeIds.has(nodeId))) {
15925
- continue;
15926
- }
15927
- const [node1, node2] = edge.nodeIds.map((nodeId) => {
15928
- return this.nodes.find((node) => node.capacityMeshNodeId === nodeId);
15929
- });
15959
+ const node1 = this.nodeMap.get(edge.nodeIds[0]);
15960
+ const node2 = this.nodeMap.get(edge.nodeIds[1]);
15930
15961
  if (node1?.center && node2?.center) {
15931
15962
  const lowestZ1 = Math.min(...node1.availableZ);
15932
15963
  const lowestZ2 = Math.min(...node2.availableZ);
@@ -15938,9 +15969,16 @@ var DeadEndSolver = class extends BaseSolver {
15938
15969
  x: node2.center.x + lowestZ2 * node2.width * 0.05,
15939
15970
  y: node2.center.y - lowestZ2 * node2.width * 0.05
15940
15971
  };
15972
+ const availableZ = Array.from(
15973
+ /* @__PURE__ */ new Set([...node1.availableZ, ...node2.availableZ])
15974
+ ).sort();
15941
15975
  graphics.lines.push({
15942
- strokeColor: "black",
15943
- points: [nodeCenter1Adj, nodeCenter2Adj]
15976
+ layer: `z${availableZ.join(",")}`,
15977
+ points: [nodeCenter1Adj, nodeCenter2Adj],
15978
+ strokeDash: node1.availableZ.join(",") === node2.availableZ.join(",") ? void 0 : "10 5",
15979
+ strokeColor: edge.nodeIds.some(
15980
+ (nodeId) => this.removedNodeIds.has(nodeId)
15981
+ ) ? safeTransparentize("black", 0.9) : void 0
15944
15982
  });
15945
15983
  }
15946
15984
  }