@tscircuit/schematic-trace-solver 0.0.129 → 0.0.130

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.
Files changed (26) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +9 -0
  3. package/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +23 -2
  4. package/package.json +1 -1
  5. package/site/bug-reports/bug-report-20260811T075142Z.page.tsx +4 -0
  6. package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +34 -22
  7. package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +5 -3
  8. package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +305 -303
  9. package/tests/bug-reports/bug-report-20260804T095800Z/__snapshots__/bug-report-20260804T095800Z.snap.svg +5 -3
  10. package/tests/bug-reports/bug-report-20260811T075142Z/__snapshots__/bug-report-20260811T075142Z.snap.svg +74 -0
  11. package/tests/bug-reports/bug-report-20260811T075142Z/bug-report-20260811T075142Z.json +194 -0
  12. package/tests/bug-reports/bug-report-20260811T075142Z/bug-report-20260811T075142Z.test.ts +12 -0
  13. package/tests/examples/__snapshots__/example10.snap.svg +20 -16
  14. package/tests/examples/__snapshots__/example31.snap.svg +8 -6
  15. package/tests/examples/__snapshots__/example33.snap.svg +32 -30
  16. package/tests/examples/__snapshots__/example46.snap.svg +5 -3
  17. package/tests/examples/__snapshots__/example48.snap.svg +25 -23
  18. package/tests/examples/__snapshots__/example50.snap.svg +32 -30
  19. package/tests/repros/__snapshots__/repro-atmega328p-fault-pullup.snap.svg +48 -46
  20. package/tests/repros/__snapshots__/repro-bq24074-battery-charger.snap.svg +7 -5
  21. package/tests/repros/__snapshots__/repro-missing-trace-netlabel.snap.svg +24 -18
  22. package/tests/repros/__snapshots__/repro51-overlap-junction-crossing.snap.svg +25 -23
  23. package/tests/repros/__snapshots__/small-variant-resistor-facing-direction.snap.svg +46 -44
  24. package/tests/repros/repro-max-msp-pair-distance-fallback.test.ts +45 -0
  25. package/tests/repros/repro-missing-trace-netlabel.test.ts +9 -11
  26. package/tests/repros/rotated-components-rail-label.test.ts +5 -11
package/dist/index.d.ts CHANGED
@@ -621,6 +621,7 @@ declare class LongDistancePairSolver extends BaseSolver {
621
621
  private netConnMap;
622
622
  private newlyConnectedPinIds;
623
623
  private allSolvedTraces;
624
+ private maxMspPairDistance;
624
625
  constructor(params: {
625
626
  inputProblem: InputProblem;
626
627
  alreadySolvedTraces: SolvedTracePath[];
package/dist/index.js CHANGED
@@ -4618,6 +4618,7 @@ var NEAREST_NEIGHBOR_COUNT = 3;
4618
4618
  var distance3 = (p1, p2) => {
4619
4619
  return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
4620
4620
  };
4621
+ var manhattanDistance = (p1, p2) => Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
4621
4622
  var LongDistancePairSolver = class extends BaseSolver {
4622
4623
  constructor(params) {
4623
4624
  super();
@@ -4625,6 +4626,7 @@ var LongDistancePairSolver = class extends BaseSolver {
4625
4626
  const { inputProblem, primaryMspConnectionPairs, alreadySolvedTraces } = this.params;
4626
4627
  this.inputProblem = inputProblem;
4627
4628
  this.allSolvedTraces = [...alreadySolvedTraces];
4629
+ this.maxMspPairDistance = inputProblem.maxMspPairDistance ?? DEFAULT_MAX_MSP_PAIR_DISTANCE;
4628
4630
  const primaryConnectedPinIds = /* @__PURE__ */ new Set();
4629
4631
  for (const pair of primaryMspConnectionPairs) {
4630
4632
  primaryConnectedPinIds.add(pair.pins[0].pinId);
@@ -4660,6 +4662,12 @@ var LongDistancePairSolver = class extends BaseSolver {
4660
4662
  const neighbors = allPinIdsInNet.filter((otherPinId) => otherPinId !== unconnectedPinId).flatMap((otherPinId) => {
4661
4663
  const targetPin = pinMap.get(otherPinId);
4662
4664
  if (!targetPin) return [];
4665
+ const isNamedTwoPinConnection = inputProblem.netConnections.some(
4666
+ (connection) => connection.pinIds.length === 2 && connection.pinIds.includes(sourcePin.pinId) && connection.pinIds.includes(targetPin.pinId)
4667
+ );
4668
+ if (isNamedTwoPinConnection && manhattanDistance(sourcePin, targetPin) > this.maxMspPairDistance) {
4669
+ return [];
4670
+ }
4663
4671
  return [
4664
4672
  {
4665
4673
  pin: targetPin,
@@ -4694,6 +4702,7 @@ var LongDistancePairSolver = class extends BaseSolver {
4694
4702
  netConnMap;
4695
4703
  newlyConnectedPinIds = /* @__PURE__ */ new Set();
4696
4704
  allSolvedTraces = [];
4705
+ maxMspPairDistance;
4697
4706
  getConstructorParams() {
4698
4707
  return this.params;
4699
4708
  }
@@ -1,5 +1,8 @@
1
1
  import { getConnectivityMapsFromInputProblem } from "lib/solvers/MspConnectionPairSolver/getConnectivityMapFromInputProblem"
2
- import type { MspConnectionPair } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
2
+ import {
3
+ DEFAULT_MAX_MSP_PAIR_DISTANCE,
4
+ type MspConnectionPair,
5
+ } from "lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver"
3
6
  import type {
4
7
  InputProblem,
5
8
  InputPin,
@@ -8,10 +11,10 @@ import type {
8
11
  } from "lib/types/InputProblem"
9
12
  import { BaseSolver } from "../BaseSolver/BaseSolver"
10
13
  import { SchematicTraceSingleLineSolver2 } from "../SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2"
11
- import { doesTraceOverlapWithExistingTraces } from "lib/utils/does-trace-overlap-with-existing-traces"
12
14
  import { visualizeInputProblem } from "../SchematicTracePipelineSolver/visualizeInputProblem"
13
15
  import type { SolvedTracePath } from "../SchematicTraceLinesSolver/SchematicTraceLinesSolver"
14
16
  import type { ConnectivityMap } from "connectivity-map"
17
+ import { doesTraceOverlapWithExistingTraces } from "lib/utils/does-trace-overlap-with-existing-traces"
15
18
  import { arePinsInDifferentSchematicSections } from "../../utils/arePinsInDifferentSchematicSections"
16
19
  import { isLabeledPeripheralConnection } from "../MspConnectionPairSolver/isLabeledPeripheralConnection"
17
20
 
@@ -21,6 +24,9 @@ const distance = (p1: InputPin, p2: InputPin) => {
21
24
  return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2))
22
25
  }
23
26
 
27
+ const manhattanDistance = (p1: InputPin, p2: InputPin) =>
28
+ Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y)
29
+
24
30
  export class LongDistancePairSolver extends BaseSolver {
25
31
  public solvedLongDistanceTraces: SolvedTracePath[] = []
26
32
  private queuedCandidatePairs: Array<
@@ -37,6 +43,7 @@ export class LongDistancePairSolver extends BaseSolver {
37
43
  private netConnMap: ConnectivityMap
38
44
  private newlyConnectedPinIds = new Set<PinId>()
39
45
  private allSolvedTraces: SolvedTracePath[] = []
46
+ private maxMspPairDistance: number
40
47
 
41
48
  constructor(
42
49
  private params: {
@@ -53,6 +60,8 @@ export class LongDistancePairSolver extends BaseSolver {
53
60
 
54
61
  this.inputProblem = inputProblem
55
62
  this.allSolvedTraces = [...alreadySolvedTraces]
63
+ this.maxMspPairDistance =
64
+ inputProblem.maxMspPairDistance ?? DEFAULT_MAX_MSP_PAIR_DISTANCE
56
65
 
57
66
  // 1. Create initial maps and sets for efficient lookup
58
67
  const primaryConnectedPinIds = new Set<PinId>()
@@ -104,6 +113,18 @@ export class LongDistancePairSolver extends BaseSolver {
104
113
  .flatMap((otherPinId) => {
105
114
  const targetPin = pinMap.get(otherPinId)
106
115
  if (!targetPin) return [] // Gracefully handle missing pins
116
+ const isNamedTwoPinConnection = inputProblem.netConnections.some(
117
+ (connection) =>
118
+ connection.pinIds.length === 2 &&
119
+ connection.pinIds.includes(sourcePin.pinId) &&
120
+ connection.pinIds.includes(targetPin.pinId),
121
+ )
122
+ if (
123
+ isNamedTwoPinConnection &&
124
+ manhattanDistance(sourcePin, targetPin) > this.maxMspPairDistance
125
+ ) {
126
+ return []
127
+ }
107
128
  return [
108
129
  {
109
130
  pin: targetPin,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/schematic-trace-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.129",
4
+ "version": "0.0.130",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "start": "cosmos",
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260811T075142Z/bug-report-20260811T075142Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />