@tscircuit/schematic-trace-solver 0.0.158 → 0.0.160

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 (27) hide show
  1. package/dist/index.d.ts +41 -9
  2. package/dist/index.js +762 -110
  3. package/lib/solvers/InlineNetLabelSolver/InlineNetLabelSolver.ts +536 -94
  4. package/lib/solvers/InlineNetLabelSolver/pushAnchoredNetLabelsAwayFromInlineLabels.ts +9 -7
  5. package/lib/solvers/InlineNetLabelSolver/pushInlineTerminalLabelsAwayFromAnchoredLabels.ts +295 -0
  6. package/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +15 -8
  7. package/lib/solvers/MspConnectionPairSolver/MspConnectionPairSolver.ts +5 -0
  8. package/lib/solvers/MspConnectionPairSolver/getGroundConnectionPolicy.ts +83 -0
  9. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +7 -35
  10. package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +6 -1
  11. package/lib/solvers/SameNetJunctionAlignmentSolver/placeGroundRailLabelsAtOuterEnd.ts +122 -0
  12. package/lib/solvers/SchematicTraceLinesSolver/getTraceConnectedPinComponents.ts +60 -0
  13. package/lib/types/InputProblem.ts +5 -4
  14. package/package.json +1 -1
  15. package/tests/bug-reports/bug-report-20260826T072956Z/__snapshots__/bug-report-20260826T072956Z.snap.svg +600 -783
  16. package/tests/bug-reports/bug-report-20260826T072956Z/bug-report-20260826T072956Z.test.ts +66 -1
  17. package/tests/fixtures/parallel-ground-rail.ts +53 -0
  18. package/tests/repros/__snapshots__/repro-mspm0l1306-capacitor-symmetry.snap.svg +34 -16
  19. package/tests/repros/repro-mspm0l1306-capacitor-symmetry.test.ts +40 -7
  20. package/tests/repros/repro-usb-power-vbus-label-detour.test.ts +14 -0
  21. package/tests/solvers/InlineNetLabelSolver/multi-pin-connected-components.test.ts +252 -0
  22. package/tests/solvers/InlineNetLabelSolver/opposite-side-placement.test.ts +71 -0
  23. package/tests/solvers/InlineNetLabelSolver/push-anchored-net-labels-away.test.ts +8 -2
  24. package/tests/solvers/InlineNetLabelSolver/push-inline-terminal-labels-away.test.ts +91 -0
  25. package/tests/solvers/InlineNetLabelSolver/two-pin-terminal-stubs-atomic.test.ts +7 -1
  26. package/tests/solvers/MspConnectionPairSolver/local-ground-branches.test.ts +105 -0
  27. package/tests/solvers/SameNetJunctionAlignmentSolver/ground-rail-label.test.ts +188 -0
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. */
@@ -202,6 +203,7 @@ declare class MspConnectionPairSolver extends BaseSolver {
202
203
  }>;
203
204
  userNetIdByPinId: Record<string, string | undefined>;
204
205
  directConnectionPinPairKeys: Set<string>;
206
+ private canRouteGroundPair;
205
207
  constructor({ inputProblem }: {
206
208
  inputProblem: InputProblem;
207
209
  });
@@ -1281,11 +1283,16 @@ interface InlineNetLabelOutput {
1281
1283
  netLabelPlacements: NetLabelPlacement[];
1282
1284
  inlineNetLabelPlacements: InlineNetLabelPlacement[];
1283
1285
  }
1284
- type InlineEligibleConnection = InputDirectConnection | InputNetConnection;
1286
+ type QueuedInlineConnection = {
1287
+ kind: "direct_connection";
1288
+ connection: InputDirectConnection;
1289
+ } | {
1290
+ kind: "net_connection";
1291
+ connection: InputNetConnection;
1292
+ };
1285
1293
  /**
1286
1294
  * Places "inline net labels" - net names drawn alongside the trace they belong
1287
- * to - for one- or two-pin connections that opted in via
1288
- * `allowInlineNetLabel`.
1295
+ * to - for connections that opted in via `allowInlineNetLabel`.
1289
1296
  *
1290
1297
  * Any regular (anchored) net label placement for the same net is dropped, so a
1291
1298
  * net is never labeled twice.
@@ -1295,14 +1302,38 @@ declare class InlineNetLabelSolver extends BaseSolver {
1295
1302
  traces: SolvedTracePath[];
1296
1303
  inputNetLabelPlacements: NetLabelPlacement[];
1297
1304
  inlineNetLabelPlacements: InlineNetLabelPlacement[];
1298
- /** Eligible one- or two-pin connections still waiting to be processed. */
1299
- queuedConnections: InlineEligibleConnection[];
1305
+ /** Eligible connections still waiting to be processed. */
1306
+ queuedConnections: QueuedInlineConnection[];
1300
1307
  private tracesByPinPairKey;
1308
+ private globalConnMap;
1309
+ private supersededTraceIdsByGlobalConnNetId;
1301
1310
  private hasAlignedPortOnlyStubs;
1302
1311
  private postProcessedOutput?;
1303
1312
  constructor(input: InlineNetLabelSolverInput);
1304
1313
  getConstructorParams(): [InlineNetLabelSolverInput];
1305
1314
  _step(): void;
1315
+ /**
1316
+ * Plans all opted-in multi-pin nets together. Short routed components can
1317
+ * mutually block the outward endpoint stubs that replace them, so tentative
1318
+ * replacements are ignored as obstacles only while their owning net still
1319
+ * converts successfully. Failed conversions retain both their traces and
1320
+ * their conventional labels, and the remaining conversions are retried.
1321
+ */
1322
+ private computeNetConnectionInlineConversions;
1323
+ /**
1324
+ * Splits an input net into the connected components created by its solved
1325
+ * traces. This intentionally does not depend on anchored-label placement:
1326
+ * a group whose anchored label failed still has the same routing topology.
1327
+ */
1328
+ private getNetConnectionComponents;
1329
+ private getGlobalConnNetId;
1330
+ /**
1331
+ * Converts every conventional label representation for an opted-in named
1332
+ * net. Routed connected components become labels on their representative
1333
+ * trace; disconnected pins become outward terminal stubs. The conversion is
1334
+ * atomic so one blocked candidate cannot leave mixed label styles on a net.
1335
+ */
1336
+ private computeNetConnectionInlinePlacements;
1306
1337
  /**
1307
1338
  * Converts one conventional endpoint placement into an inline label on a
1308
1339
  * generated outward stub. The stub follows the pin's true facing direction;
@@ -1329,6 +1360,7 @@ declare class InlineNetLabelSolver extends BaseSolver {
1329
1360
  */
1330
1361
  private getSupersededNetLabelKeys;
1331
1362
  private getOutputTraces;
1363
+ private getInlineGlobalsOverlappingAnchoredLabels;
1332
1364
  private buildPostProcessedOutput;
1333
1365
  getOutput(): {
1334
1366
  traces: SolvedTracePath[];