@tscircuit/schematic-trace-solver 0.0.159 → 0.0.161

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 (71) hide show
  1. package/dist/index.d.ts +43 -9
  2. package/dist/index.js +807 -115
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +210 -6
  4. package/lib/solvers/InlineNetLabelSolver/InlineNetLabelSolver.ts +536 -94
  5. package/lib/solvers/InlineNetLabelSolver/pushAnchoredNetLabelsAwayFromInlineLabels.ts +9 -7
  6. package/lib/solvers/InlineNetLabelSolver/pushInlineTerminalLabelsAwayFromAnchoredLabels.ts +295 -0
  7. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +7 -35
  8. package/lib/solvers/SchematicTraceLinesSolver/getTraceConnectedPinComponents.ts +60 -0
  9. package/lib/solvers/TraceCleanupSolver/sameNetRailAlignment/getFixedLabelCoordinate.ts +44 -13
  10. package/lib/types/InputProblem.ts +5 -4
  11. package/package.json +1 -1
  12. package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +1 -1
  13. package/tests/bug-reports/bug-report-20260728T144234Z/__snapshots__/bug-report-20260728T144234Z.snap.svg +1 -1
  14. package/tests/bug-reports/bug-report-20260728T225606Z/__snapshots__/bug-report-20260728T225606Z.snap.svg +79 -79
  15. package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +85 -85
  16. package/tests/bug-reports/bug-report-20260731T052229Z/__snapshots__/bug-report-20260731T052229Z.snap.svg +1 -1
  17. package/tests/bug-reports/bug-report-20260804T095800Z/__snapshots__/bug-report-20260804T095800Z.snap.svg +163 -163
  18. package/tests/bug-reports/bug-report-20260804T171919Z/__snapshots__/bug-report-20260804T171919Z.snap.svg +547 -547
  19. package/tests/bug-reports/bug-report-20260804T225912Z/__snapshots__/bug-report-20260804T225912Z.snap.svg +13 -13
  20. package/tests/bug-reports/bug-report-20260805T061316Z/__snapshots__/bug-report-20260805T061316Z.snap.svg +267 -267
  21. package/tests/bug-reports/bug-report-20260806T061548Z/__snapshots__/bug-report-20260806T061548Z.snap.svg +267 -267
  22. package/tests/bug-reports/bug-report-20260806T093501Z/__snapshots__/bug-report-20260806T093501Z.snap.svg +109 -109
  23. package/tests/bug-reports/bug-report-20260811T075142Z/__snapshots__/bug-report-20260811T075142Z.snap.svg +1 -1
  24. package/tests/bug-reports/bug-report-20260815T073240Z/__snapshots__/bug-report-20260815T073240Z.snap.svg +49 -49
  25. package/tests/bug-reports/bug-report-20260819T091818Z/__snapshots__/bug-report-20260819T091818Z.snap.svg +1 -1
  26. package/tests/bug-reports/bug-report-20260825T045913Z/__snapshots__/bug-report-20260825T045913Z.snap.svg +103 -103
  27. package/tests/bug-reports/bug-report-20260825T103621Z/__snapshots__/bug-report-20260825T103621Z.snap.svg +103 -103
  28. package/tests/bug-reports/bug-report-20260826T072956Z/__snapshots__/bug-report-20260826T072956Z.snap.svg +600 -792
  29. package/tests/bug-reports/bug-report-20260826T072956Z/bug-report-20260826T072956Z.test.ts +66 -1
  30. package/tests/examples/__snapshots__/example51.snap.svg +568 -568
  31. package/tests/fixtures/convertSolverOutputToCircuitJson.test.ts +16 -1
  32. package/tests/fixtures/convertSolverOutputToCircuitJson.ts +23 -12
  33. package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +736 -736
  34. package/tests/repros/__snapshots__/board-15984-same-net-junction.snap.svg +79 -79
  35. package/tests/repros/__snapshots__/board1096-usb-label-overlap-iteration.snap.svg +127 -127
  36. package/tests/repros/__snapshots__/repro-bluetooth-controller-ground-decoupling-groups.snap.svg +106 -0
  37. package/tests/repros/__snapshots__/repro-board-589-regulator-section.snap.svg +31 -31
  38. package/tests/repros/__snapshots__/repro-board-648-esp12f-section.snap.svg +121 -121
  39. package/tests/repros/__snapshots__/repro-bq25895-cross-net-trace-overlap.snap.svg +43 -43
  40. package/tests/repros/__snapshots__/repro-core-555-power-cross-net-overlap.snap.svg +19 -19
  41. package/tests/repros/__snapshots__/repro-core-ground-inline-label-fallback.snap.svg +277 -0
  42. package/tests/repros/__snapshots__/repro-core-subcircuit-missing-ground.snap.svg +19 -19
  43. package/tests/repros/__snapshots__/repro-core-tb67s579ftg-inline-label-routing.snap.svg +7 -7
  44. package/tests/repros/__snapshots__/repro-dc-power-isolated-routing.snap.svg +37 -37
  45. package/tests/repros/__snapshots__/repro-hdc2080-ground-label-alignment.snap.svg +137 -0
  46. package/tests/repros/__snapshots__/repro-nrf52810-clock-routing.snap.svg +61 -61
  47. package/tests/repros/__snapshots__/repro-pga300-redundant-ground-traces.snap.svg +115 -115
  48. package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +743 -743
  49. package/tests/repros/__snapshots__/repro-rp2040-usb-cc2-ground-overlap.snap.svg +43 -43
  50. package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +1 -1
  51. package/tests/repros/__snapshots__/repro-tida010076-j4-ground-bus.snap.svg +17 -17
  52. package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +1131 -1131
  53. package/tests/repros/__snapshots__/repro-type-c-16pin-self-connection.snap.svg +7 -7
  54. package/tests/repros/__snapshots__/repro-type-c-16pin-to-resistor.snap.svg +7 -7
  55. package/tests/repros/__snapshots__/repro-usb-power-vbus-label-detour.snap.svg +666 -666
  56. package/tests/repros/__snapshots__/repro161-power-section-autolayout.snap.svg +73 -73
  57. package/tests/repros/__snapshots__/repro48-555-timer-vcc-rail-label.snap.svg +73 -73
  58. package/tests/repros/assets/repro-bluetooth-controller-ground-decoupling-groups.input.json +214 -0
  59. package/tests/repros/assets/repro-core-ground-inline-label-fallback.input.json +863 -0
  60. package/tests/repros/repro-bluetooth-controller-ground-decoupling-groups.test.ts +18 -0
  61. package/tests/repros/repro-core-ground-inline-label-fallback.test.ts +34 -0
  62. package/tests/repros/repro-hdc2080-ground-label-alignment.test.ts +239 -0
  63. package/tests/repros/repro-tida010076-j4-ground-bus.test.ts +14 -10
  64. package/tests/repros/repro-tida010076-page02.test.ts +2 -2
  65. package/tests/repros/repro-usb-power-vbus-label-detour.test.ts +14 -0
  66. package/tests/solvers/InlineNetLabelSolver/__snapshots__/inline-net-label02.snap.svg +1 -1
  67. package/tests/solvers/InlineNetLabelSolver/multi-pin-connected-components.test.ts +252 -0
  68. package/tests/solvers/InlineNetLabelSolver/opposite-side-placement.test.ts +71 -0
  69. package/tests/solvers/InlineNetLabelSolver/push-anchored-net-labels-away.test.ts +8 -2
  70. package/tests/solvers/InlineNetLabelSolver/push-inline-terminal-labels-away.test.ts +91 -0
  71. package/tests/solvers/InlineNetLabelSolver/two-pin-terminal-stubs-atomic.test.ts +7 -1
package/dist/index.d.ts CHANGED
@@ -152,10 +152,11 @@ interface InputNetConnection {
152
152
  anchoredNetLabelWidth?: number;
153
153
  netLabelHeight?: number;
154
154
  /**
155
- * When true, a named one- or two-pin net may use inline labels. A single-pin
156
- * net gets an outward stub. A routed two-pin net gets one label along its
157
- * trace; when that route is intentionally skipped, both endpoints get
158
- * outward stubs. Nets with more than two pins retain anchored labels.
155
+ * When true, a named net may use inline labels. Each routed connected
156
+ * component gets a label along its representative trace, while each
157
+ * disconnected endpoint gets an outward inline-label stub. Conversion is
158
+ * atomic for the whole net so inline and anchored representations are not
159
+ * mixed when any label cannot be placed.
159
160
  */
160
161
  allowInlineNetLabel?: boolean;
161
162
  /** Extent of the inline text along the generated trace stub. */
@@ -905,6 +906,9 @@ declare class AvailableNetOrientationSolver extends BaseSolver {
905
906
  private shouldCheckTraceClearanceForLabel;
906
907
  private hasRoutedLabelOnSameNet;
907
908
  private isOutwardHorizontalFallback;
909
+ private canPlaceVerticalLabelOnHostRail;
910
+ private getTextBlockedMultiPinRailTraces;
911
+ private findValidNearbyRailCandidate;
908
912
  private hasPortOnlyLabelOnSameNet;
909
913
  private hasOppositeVerticalRailOnSameChipSide;
910
914
  private getSingleChipSideForNetConnection;
@@ -1282,11 +1286,16 @@ interface InlineNetLabelOutput {
1282
1286
  netLabelPlacements: NetLabelPlacement[];
1283
1287
  inlineNetLabelPlacements: InlineNetLabelPlacement[];
1284
1288
  }
1285
- type InlineEligibleConnection = InputDirectConnection | InputNetConnection;
1289
+ type QueuedInlineConnection = {
1290
+ kind: "direct_connection";
1291
+ connection: InputDirectConnection;
1292
+ } | {
1293
+ kind: "net_connection";
1294
+ connection: InputNetConnection;
1295
+ };
1286
1296
  /**
1287
1297
  * Places "inline net labels" - net names drawn alongside the trace they belong
1288
- * to - for one- or two-pin connections that opted in via
1289
- * `allowInlineNetLabel`.
1298
+ * to - for connections that opted in via `allowInlineNetLabel`.
1290
1299
  *
1291
1300
  * Any regular (anchored) net label placement for the same net is dropped, so a
1292
1301
  * net is never labeled twice.
@@ -1296,14 +1305,38 @@ declare class InlineNetLabelSolver extends BaseSolver {
1296
1305
  traces: SolvedTracePath[];
1297
1306
  inputNetLabelPlacements: NetLabelPlacement[];
1298
1307
  inlineNetLabelPlacements: InlineNetLabelPlacement[];
1299
- /** Eligible one- or two-pin connections still waiting to be processed. */
1300
- queuedConnections: InlineEligibleConnection[];
1308
+ /** Eligible connections still waiting to be processed. */
1309
+ queuedConnections: QueuedInlineConnection[];
1301
1310
  private tracesByPinPairKey;
1311
+ private globalConnMap;
1312
+ private supersededTraceIdsByGlobalConnNetId;
1302
1313
  private hasAlignedPortOnlyStubs;
1303
1314
  private postProcessedOutput?;
1304
1315
  constructor(input: InlineNetLabelSolverInput);
1305
1316
  getConstructorParams(): [InlineNetLabelSolverInput];
1306
1317
  _step(): void;
1318
+ /**
1319
+ * Plans all opted-in multi-pin nets together. Short routed components can
1320
+ * mutually block the outward endpoint stubs that replace them, so tentative
1321
+ * replacements are ignored as obstacles only while their owning net still
1322
+ * converts successfully. Failed conversions retain both their traces and
1323
+ * their conventional labels, and the remaining conversions are retried.
1324
+ */
1325
+ private computeNetConnectionInlineConversions;
1326
+ /**
1327
+ * Splits an input net into the connected components created by its solved
1328
+ * traces. This intentionally does not depend on anchored-label placement:
1329
+ * a group whose anchored label failed still has the same routing topology.
1330
+ */
1331
+ private getNetConnectionComponents;
1332
+ private getGlobalConnNetId;
1333
+ /**
1334
+ * Converts every conventional label representation for an opted-in named
1335
+ * net. Routed connected components become labels on their representative
1336
+ * trace; disconnected pins become outward terminal stubs. The conversion is
1337
+ * atomic so one blocked candidate cannot leave mixed label styles on a net.
1338
+ */
1339
+ private computeNetConnectionInlinePlacements;
1307
1340
  /**
1308
1341
  * Converts one conventional endpoint placement into an inline label on a
1309
1342
  * generated outward stub. The stub follows the pin's true facing direction;
@@ -1330,6 +1363,7 @@ declare class InlineNetLabelSolver extends BaseSolver {
1330
1363
  */
1331
1364
  private getSupersededNetLabelKeys;
1332
1365
  private getOutputTraces;
1366
+ private getInlineGlobalsOverlappingAnchoredLabels;
1333
1367
  private buildPostProcessedOutput;
1334
1368
  getOutput(): {
1335
1369
  traces: SolvedTracePath[];