@tscircuit/schematic-trace-solver 0.0.163 → 0.0.164

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.js CHANGED
@@ -1507,13 +1507,17 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver {
1507
1507
  excludeRectsForSegment: (segIndex2) => {
1508
1508
  const lastSegIndex2 = path.length - 2;
1509
1509
  const excludedRects = /* @__PURE__ */ new Set();
1510
- if (segIndex2 === 0 || segIndex2 === lastSegIndex2) {
1510
+ const segmentStart = path[segIndex2];
1511
+ const segmentEnd = path[segIndex2 + 1];
1512
+ const oppositeTerminalPin = segIndex2 === 0 ? PB : segIndex2 === lastSegIndex2 ? PA : null;
1513
+ if (oppositeTerminalPin) {
1511
1514
  for (const textObstacle of this.textObstacles) {
1512
- excludedRects.add(textObstacle);
1515
+ const textBounds = getTextBoxBounds(textObstacle.textBox);
1516
+ if (textObstacle.textBox.chipId !== oppositeTerminalPin.chipId || !segmentIntersectsRect(segmentStart, segmentEnd, textBounds)) {
1517
+ excludedRects.add(textObstacle);
1518
+ }
1513
1519
  }
1514
1520
  }
1515
- const segmentStart = path[segIndex2];
1516
- const segmentEnd = path[segIndex2 + 1];
1517
1521
  const endpointEpsilon = 1e-9;
1518
1522
  const segmentTouchesPin = (pin) => [segmentStart, segmentEnd].some(
1519
1523
  (point) => Math.abs(point.x - pin.x) <= endpointEpsilon && Math.abs(point.y - pin.y) <= endpointEpsilon
@@ -325,15 +325,26 @@ export class SchematicTraceSingleLineSolver2 extends BaseSolver {
325
325
  excludeRectsForSegment: (segIndex) => {
326
326
  const lastSegIndex = path.length - 2
327
327
  const excludedRects = new Set<ObstacleRect>()
328
+ const segmentStart = path[segIndex]!
329
+ const segmentEnd = path[segIndex + 1]!
328
330
 
329
- if (segIndex === 0 || segIndex === lastSegIndex) {
331
+ const oppositeTerminalPin =
332
+ segIndex === 0 ? PB : segIndex === lastSegIndex ? PA : null
333
+ if (oppositeTerminalPin) {
330
334
  for (const textObstacle of this.textObstacles) {
331
- excludedRects.add(textObstacle)
335
+ // Preserve the existing terminal-segment clearance exception, but
336
+ // do not let a segment that wraps around the opposite endpoint cut
337
+ // through that component's actual text.
338
+ const textBounds = getTextBoxBounds(textObstacle.textBox)
339
+ if (
340
+ textObstacle.textBox.chipId !== oppositeTerminalPin.chipId ||
341
+ !segmentIntersectsRect(segmentStart, segmentEnd, textBounds)
342
+ ) {
343
+ excludedRects.add(textObstacle)
344
+ }
332
345
  }
333
346
  }
334
347
 
335
- const segmentStart = path[segIndex]!
336
- const segmentEnd = path[segIndex + 1]!
337
348
  const endpointEpsilon = 1e-9
338
349
  const segmentTouchesPin = (pin: MspConnectionPair["pins"][number]) =>
339
350
  [segmentStart, segmentEnd].some(
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/tscircuit/schematic-trace-solver.git"
6
6
  },
7
7
  "main": "dist/index.js",
8
- "version": "0.0.163",
8
+ "version": "0.0.164",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "start": "cosmos",