@tscircuit/capacity-autorouter 0.0.3 → 0.0.4

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
@@ -115,6 +115,11 @@ declare class CapacityMeshNodeSolver extends BaseSolver {
115
115
  finishedNodes: CapacityMeshNode[];
116
116
  nodeToOverlappingObstaclesMap: Map<CapacityMeshNodeId, Obstacle[]>;
117
117
  MAX_DEPTH: number;
118
+ targets: Array<{
119
+ x: number;
120
+ y: number;
121
+ connectionName: string;
122
+ }>;
118
123
  constructor(srj: SimpleRouteJson, opts?: CapacityMeshNodeSolverOptions);
119
124
  _nextNodeCounter: number;
120
125
  getNextNodeId(): string;
package/dist/index.js CHANGED
@@ -1092,17 +1092,24 @@ var CapacityMeshNodeSolver = class extends BaseSolver {
1092
1092
  width: maxWidthHeight,
1093
1093
  height: maxWidthHeight,
1094
1094
  layer: "top",
1095
- _depth: 0
1095
+ _depth: 0,
1096
+ _containsTarget: true,
1097
+ _containsObstacle: true,
1098
+ _completelyInsideObstacle: false
1096
1099
  }
1097
1100
  ];
1098
1101
  this.finishedNodes = [];
1099
1102
  this.nodeToOverlappingObstaclesMap = /* @__PURE__ */ new Map();
1103
+ this.targets = this.srj.connections.flatMap(
1104
+ (c) => c.pointsToConnect.map((p) => ({ ...p, connectionName: c.name }))
1105
+ );
1100
1106
  }
1101
1107
  unfinishedNodes;
1102
1108
  finishedNodes;
1103
1109
  nodeToOverlappingObstaclesMap;
1104
1110
  // targetObstacleMap: Record<string, { obstacle: Obstacle, node: CapacityMeshNode }>
1105
1111
  MAX_DEPTH = 4;
1112
+ targets;
1106
1113
  _nextNodeCounter = 0;
1107
1114
  getNextNodeId() {
1108
1115
  return `cn${this._nextNodeCounter++}`;
@@ -1112,10 +1119,7 @@ var CapacityMeshNodeSolver = class extends BaseSolver {
1112
1119
  }
1113
1120
  getTargetNameIfNodeContainsTarget(node) {
1114
1121
  const overlappingObstacles = this.getOverlappingObstacles(node);
1115
- const targets = this.srj.connections.flatMap(
1116
- (c) => c.pointsToConnect.map((p) => ({ ...p, connectionName: c.name }))
1117
- );
1118
- for (const target of targets) {
1122
+ for (const target of this.targets) {
1119
1123
  const targetObstacle = overlappingObstacles.find(
1120
1124
  (o) => isPointInRect(target, o)
1121
1125
  );
@@ -1232,9 +1236,9 @@ var CapacityMeshNodeSolver = class extends BaseSolver {
1232
1236
  _parent: parent
1233
1237
  };
1234
1238
  childNode._containsObstacle = this.doesNodeOverlapObstacle(childNode);
1239
+ childNode._targetConnectionName = this.getTargetNameIfNodeContainsTarget(childNode) ?? void 0;
1240
+ childNode._containsTarget = Boolean(childNode._targetConnectionName);
1235
1241
  if (childNode._containsObstacle) {
1236
- childNode._targetConnectionName = this.getTargetNameIfNodeContainsTarget(childNode) ?? void 0;
1237
- childNode._containsTarget = Boolean(childNode._targetConnectionName);
1238
1242
  childNode._completelyInsideObstacle = this.isNodeCompletelyInsideObstacle(childNode);
1239
1243
  }
1240
1244
  if (childNode._completelyInsideObstacle && !childNode._containsTarget)