@tscircuit/schematic-trace-solver 0.0.191 → 0.0.193

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 (49) hide show
  1. package/dist/index.js +21 -10
  2. package/lib/solvers/SameNetJunctionAlignmentSolver/collapseRedundantSharedEndpointStubs.ts +12 -6
  3. package/lib/solvers/UnroutedTraceRecoverySolver/UnroutedTraceRecoverySolver.ts +10 -2
  4. package/package.json +1 -1
  5. package/site/SchematicTracePipelineSolver/repro173-boost-drv8711-ground-label-overlap.page.tsx +7 -0
  6. package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +2 -2
  7. package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +2 -2
  8. package/tests/bug-reports/bug-report-20260724T175257Z/__snapshots__/bug-report-20260724T175257Z.snap.svg +2 -2
  9. package/tests/bug-reports/bug-report-20260728T144234Z/__snapshots__/bug-report-20260728T144234Z.snap.svg +2 -2
  10. package/tests/bug-reports/bug-report-20260804T171919Z/__snapshots__/bug-report-20260804T171919Z.snap.svg +2 -2
  11. package/tests/bug-reports/bug-report-20260815T073240Z/__snapshots__/bug-report-20260815T073240Z.snap.svg +2 -2
  12. package/tests/bug-reports/bug-report-20260901T055358Z/__snapshots__/bug-report-20260901T055358Z.snap.svg +2 -2
  13. package/tests/bug-reports/bug-report-20260907T083336Z/__snapshots__/bug-report-20260907T083336Z.snap.svg +2 -2
  14. package/tests/examples/__snapshots__/example08.snap.svg +29 -29
  15. package/tests/examples/__snapshots__/example13.snap.svg +2 -2
  16. package/tests/examples/__snapshots__/example15.snap.svg +2 -2
  17. package/tests/examples/__snapshots__/example32.snap.svg +2 -2
  18. package/tests/examples/__snapshots__/example46.snap.svg +12 -21
  19. package/tests/examples/__snapshots__/example51.snap.svg +2 -2
  20. package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +2 -2
  21. package/tests/repros/__snapshots__/board-15984-same-net-junction.snap.svg +2 -2
  22. package/tests/repros/__snapshots__/repro-bq25895-cross-net-trace-overlap.snap.svg +2 -2
  23. package/tests/repros/__snapshots__/repro-cc2340r5.snap.svg +2 -2
  24. package/tests/repros/__snapshots__/repro-esp12f-section.snap.svg +2 -2
  25. package/tests/repros/__snapshots__/repro-example35-minimize-trace-crossing.snap.svg +2 -2
  26. package/tests/repros/__snapshots__/repro-hub-usb-sheet.snap.svg +2 -2
  27. package/tests/repros/__snapshots__/repro-ina237-current-monitor.snap.svg +17 -17
  28. package/tests/repros/__snapshots__/repro-isolated-rs485-isow7841.snap.svg +2 -2
  29. package/tests/repros/__snapshots__/repro-netlabel-overlap-trace.snap.svg +2 -2
  30. package/tests/repros/__snapshots__/repro-pga300-redundant-ground-traces.snap.svg +2 -2
  31. package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +89 -98
  32. package/tests/repros/__snapshots__/repro-powerbank-3v-system-power.snap.svg +2 -2
  33. package/tests/repros/__snapshots__/repro-repeated-power-rail-junctions.snap.svg +2 -2
  34. package/tests/repros/__snapshots__/repro-rp2040-gamepad-trace-alignment.snap.svg +2 -2
  35. package/tests/repros/__snapshots__/repro-tida00553-j4-cell-divider.snap.svg +2 -2
  36. package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +2 -2
  37. package/tests/repros/__snapshots__/repro-type-c-vbus-led-ground-label.snap.svg +2 -2
  38. package/tests/repros/__snapshots__/repro-usb-power-vbus-label-detour.snap.svg +2 -2
  39. package/tests/repros/__snapshots__/repro130-bq27441-fuel-gauge-trace-through-c1.snap.svg +2 -2
  40. package/tests/repros/__snapshots__/repro161-power-section-autolayout.snap.svg +2 -2
  41. package/tests/repros/__snapshots__/repro173-boost-drv8711-ground-label-overlap.snap.svg +307 -0
  42. package/tests/repros/__snapshots__/rtc-imu-microsd-section.snap.svg +286 -0
  43. package/tests/repros/assets/repro173-boost-drv8711-ground-label-overlap.input.json +865 -0
  44. package/tests/repros/assets/rtc-imu-microsd-section.input.json +894 -0
  45. package/tests/repros/repro-pmp11282-isolated-dcdc.test.ts +10 -3
  46. package/tests/repros/repro173-boost-drv8711-ground-label-overlap.test.ts +41 -0
  47. package/tests/repros/rtc-imu-microsd-section.test.ts +28 -0
  48. package/tests/solvers/SameNetJunctionAlignmentSolver/collapse-redundant-shared-endpoint-stubs.test.ts +45 -0
  49. package/tests/solvers/UnroutedTraceRecoverySolver/local-elbow-obstacles.test.ts +1 -1
package/dist/index.js CHANGED
@@ -13084,11 +13084,19 @@ var getPinConnectionCandidates = ({
13084
13084
  const outerBounds = getOuterBounds(obstacles);
13085
13085
  const horizontalChannels = [
13086
13086
  outerBounds.minY - ROUTE_CLEARANCE,
13087
- outerBounds.maxY + ROUTE_CLEARANCE
13087
+ outerBounds.maxY + ROUTE_CLEARANCE,
13088
+ ...obstacles.flatMap((obstacle) => [
13089
+ obstacle.minY - ROUTE_CLEARANCE,
13090
+ obstacle.maxY + ROUTE_CLEARANCE
13091
+ ])
13088
13092
  ];
13089
13093
  const verticalChannels = [
13090
13094
  outerBounds.minX - ROUTE_CLEARANCE,
13091
- outerBounds.maxX + ROUTE_CLEARANCE
13095
+ outerBounds.maxX + ROUTE_CLEARANCE,
13096
+ ...obstacles.flatMap((obstacle) => [
13097
+ obstacle.minX - ROUTE_CLEARANCE,
13098
+ obstacle.maxX + ROUTE_CLEARANCE
13099
+ ])
13092
13100
  ];
13093
13101
  const candidates = [
13094
13102
  calculateElbow3(
@@ -13097,7 +13105,7 @@ var getPinConnectionCandidates = ({
13097
13105
  { overshoot: ROUTE_CLEARANCE }
13098
13106
  )
13099
13107
  ];
13100
- for (const channelY of horizontalChannels) {
13108
+ for (const channelY of new Set(horizontalChannels)) {
13101
13109
  candidates.push(
13102
13110
  removeConsecutiveDuplicatePoints([
13103
13111
  firstPin,
@@ -13109,7 +13117,7 @@ var getPinConnectionCandidates = ({
13109
13117
  ])
13110
13118
  );
13111
13119
  }
13112
- for (const channelX of verticalChannels) {
13120
+ for (const channelX of new Set(verticalChannels)) {
13113
13121
  candidates.push(
13114
13122
  removeConsecutiveDuplicatePoints([
13115
13123
  firstPin,
@@ -13613,8 +13621,10 @@ var getPathFromSharedPin = ({
13613
13621
  sharedPinId
13614
13622
  }) => {
13615
13623
  const tracePath = simplifyPath(trace.tracePath);
13616
- if (trace.pins[0]?.pinId === sharedPinId) return tracePath;
13617
- return tracePath.reverse();
13624
+ const sharedPin = trace.pins.find((pin) => pin.pinId === sharedPinId);
13625
+ if (!sharedPin) return null;
13626
+ const pathFromSharedPin = trace.pins[0]?.pinId === sharedPinId ? tracePath : tracePath.reverse();
13627
+ return pointsEqual2(pathFromSharedPin[0], sharedPin) ? pathFromSharedPin : null;
13618
13628
  };
13619
13629
  var traceCanLoseSharedPrefix = ({
13620
13630
  trace,
@@ -13655,9 +13665,10 @@ var collapseRedundantSharedEndpointStubs = ({
13655
13665
  }) => {
13656
13666
  const outputTraces = [...traces];
13657
13667
  for (let firstIndex = 0; firstIndex < outputTraces.length; firstIndex++) {
13658
- const firstTrace = outputTraces[firstIndex];
13659
- if (netLabelConnectorTraceIds.has(firstTrace.mspPairId)) continue;
13668
+ if (netLabelConnectorTraceIds.has(outputTraces[firstIndex].mspPairId))
13669
+ continue;
13660
13670
  for (let secondIndex = firstIndex + 1; secondIndex < outputTraces.length; secondIndex++) {
13671
+ const firstTrace = outputTraces[firstIndex];
13661
13672
  const secondTrace = outputTraces[secondIndex];
13662
13673
  if (netLabelConnectorTraceIds.has(secondTrace.mspPairId) || firstTrace.globalConnNetId !== secondTrace.globalConnNetId) {
13663
13674
  continue;
@@ -13675,6 +13686,7 @@ var collapseRedundantSharedEndpointStubs = ({
13675
13686
  trace: secondTrace,
13676
13687
  sharedPinId: sharedPin.pinId
13677
13688
  });
13689
+ if (!firstPath || !secondPath) continue;
13678
13690
  if (firstPath.length < 2 || secondPath.length < 2) continue;
13679
13691
  const departureAxis = getSegmentAxis3(firstPath[0], firstPath[1]);
13680
13692
  const secondDepartureAxis = getSegmentAxis3(secondPath[0], secondPath[1]);
@@ -13721,7 +13733,7 @@ var collapseRedundantSharedEndpointStubs = ({
13721
13733
  });
13722
13734
  if (!collapsedTrace2) continue;
13723
13735
  outputTraces[traceIndexToCollapse2] = collapsedTrace2;
13724
- break;
13736
+ continue;
13725
13737
  }
13726
13738
  if (firstPath.length < 3 || secondPath.length < 3) continue;
13727
13739
  if (!pointsEqual2(firstPath[1], secondPath[1])) continue;
@@ -13785,7 +13797,6 @@ var collapseRedundantSharedEndpointStubs = ({
13785
13797
  });
13786
13798
  if (!collapsedTrace) continue;
13787
13799
  outputTraces[traceIndexToCollapse] = collapsedTrace;
13788
- break;
13789
13800
  }
13790
13801
  }
13791
13802
  return outputTraces;
@@ -25,8 +25,13 @@ const getPathFromSharedPin = ({
25
25
  sharedPinId: PinId
26
26
  }) => {
27
27
  const tracePath = simplifyPath(trace.tracePath)
28
- if (trace.pins[0]?.pinId === sharedPinId) return tracePath
29
- return tracePath.reverse()
28
+ const sharedPin = trace.pins.find((pin) => pin.pinId === sharedPinId)
29
+ if (!sharedPin) return null
30
+ const pathFromSharedPin =
31
+ trace.pins[0]?.pinId === sharedPinId ? tracePath : tracePath.reverse()
32
+ return pointsEqual(pathFromSharedPin[0]!, sharedPin)
33
+ ? pathFromSharedPin
34
+ : null
30
35
  }
31
36
 
32
37
  const traceCanLoseSharedPrefix = ({
@@ -87,13 +92,14 @@ export const collapseRedundantSharedEndpointStubs = ({
87
92
  const outputTraces = [...traces]
88
93
 
89
94
  for (let firstIndex = 0; firstIndex < outputTraces.length; firstIndex++) {
90
- const firstTrace = outputTraces[firstIndex]!
91
- if (netLabelConnectorTraceIds.has(firstTrace.mspPairId)) continue
95
+ if (netLabelConnectorTraceIds.has(outputTraces[firstIndex]!.mspPairId))
96
+ continue
92
97
  for (
93
98
  let secondIndex = firstIndex + 1;
94
99
  secondIndex < outputTraces.length;
95
100
  secondIndex++
96
101
  ) {
102
+ const firstTrace = outputTraces[firstIndex]!
97
103
  const secondTrace = outputTraces[secondIndex]!
98
104
  if (
99
105
  netLabelConnectorTraceIds.has(secondTrace.mspPairId) ||
@@ -114,6 +120,7 @@ export const collapseRedundantSharedEndpointStubs = ({
114
120
  trace: secondTrace,
115
121
  sharedPinId: sharedPin.pinId,
116
122
  })
123
+ if (!firstPath || !secondPath) continue
117
124
  if (firstPath.length < 2 || secondPath.length < 2) continue
118
125
 
119
126
  const departureAxis = getSegmentAxis(firstPath[0]!, firstPath[1]!)
@@ -174,7 +181,7 @@ export const collapseRedundantSharedEndpointStubs = ({
174
181
  })
175
182
  if (!collapsedTrace) continue
176
183
  outputTraces[traceIndexToCollapse] = collapsedTrace
177
- break
184
+ continue
178
185
  }
179
186
  if (firstPath.length < 3 || secondPath.length < 3) continue
180
187
  if (!pointsEqual(firstPath[1]!, secondPath[1]!)) continue
@@ -259,7 +266,6 @@ export const collapseRedundantSharedEndpointStubs = ({
259
266
  })
260
267
  if (!collapsedTrace) continue
261
268
  outputTraces[traceIndexToCollapse] = collapsedTrace
262
- break
263
269
  }
264
270
  }
265
271
 
@@ -107,10 +107,18 @@ const getPinConnectionCandidates = ({
107
107
  const horizontalChannels = [
108
108
  outerBounds.minY - ROUTE_CLEARANCE,
109
109
  outerBounds.maxY + ROUTE_CLEARANCE,
110
+ ...obstacles.flatMap((obstacle) => [
111
+ obstacle.minY - ROUTE_CLEARANCE,
112
+ obstacle.maxY + ROUTE_CLEARANCE,
113
+ ]),
110
114
  ]
111
115
  const verticalChannels = [
112
116
  outerBounds.minX - ROUTE_CLEARANCE,
113
117
  outerBounds.maxX + ROUTE_CLEARANCE,
118
+ ...obstacles.flatMap((obstacle) => [
119
+ obstacle.minX - ROUTE_CLEARANCE,
120
+ obstacle.maxX + ROUTE_CLEARANCE,
121
+ ]),
114
122
  ]
115
123
  // Recovery uses actual text bounds, so try local elbows before the perimeter.
116
124
  const candidates: Point[][] = [
@@ -121,7 +129,7 @@ const getPinConnectionCandidates = ({
121
129
  ),
122
130
  ]
123
131
 
124
- for (const channelY of horizontalChannels) {
132
+ for (const channelY of new Set(horizontalChannels)) {
125
133
  candidates.push(
126
134
  removeConsecutiveDuplicatePoints([
127
135
  firstPin,
@@ -134,7 +142,7 @@ const getPinConnectionCandidates = ({
134
142
  )
135
143
  }
136
144
 
137
- for (const channelX of verticalChannels) {
145
+ for (const channelX of new Set(verticalChannels)) {
138
146
  candidates.push(
139
147
  removeConsecutiveDuplicatePoints([
140
148
  firstPin,
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.191",
8
+ "version": "0.0.193",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "start": "cosmos",
@@ -0,0 +1,7 @@
1
+ import type { InputProblem } from "lib/types/InputProblem"
2
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
3
+ import inputProblem from "../../tests/repros/assets/repro173-boost-drv8711-ground-label-overlap.input.json"
4
+
5
+ export default () => (
6
+ <PipelineDebugger inputProblem={inputProblem as unknown as InputProblem} />
7
+ )