@tscircuit/schematic-trace-solver 0.0.152 → 0.0.154

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 (25) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +84 -27
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +7 -0
  4. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +1 -0
  5. package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +81 -8
  6. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +1 -1
  7. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +1 -0
  8. package/lib/types/InputProblem.ts +5 -5
  9. package/lib/utils/getNetLabelWidthForConnection.ts +9 -10
  10. package/package.json +1 -1
  11. package/site/bug-reports/bug-report-20260825T103621Z.page.tsx +4 -0
  12. package/tests/assets/example51.json +159 -32
  13. package/tests/bug-reports/bug-report-20260825T103621Z/__snapshots__/bug-report-20260825T103621Z.snap.svg +452 -0
  14. package/tests/bug-reports/bug-report-20260825T103621Z/bug-report-20260825T103621Z.json +1696 -0
  15. package/tests/bug-reports/bug-report-20260825T103621Z/bug-report-20260825T103621Z.test.ts +12 -0
  16. package/tests/examples/__snapshots__/example51.snap.svg +485 -473
  17. package/tests/examples/example51.test.ts +3 -1
  18. package/tests/repros/__snapshots__/repro-core-tb67s579ftg-inline-label-routing.snap.svg +8 -8
  19. package/tests/repros/__snapshots__/repro-pga300-c6-trace-alignment.snap.svg +88 -0
  20. package/tests/repros/assets/repro-core-tb67s579ftg-inline-label-routing.input.json +33 -33
  21. package/tests/repros/assets/repro-pga300-c6-trace-alignment.input.json +97 -0
  22. package/tests/repros/repro-core-tb67s579ftg-inline-label-routing.test.ts +3 -2
  23. package/tests/repros/repro-pga300-c6-trace-alignment.test.ts +36 -0
  24. package/tests/solvers/InlineNetLabelSolver/{fallback-net-label-width.test.ts → anchored-net-label-width.test.ts} +34 -11
  25. /package/tests/solvers/InlineNetLabelSolver/__snapshots__/{fallback-net-label-width.snap.svg → anchored-net-label-width.snap.svg} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
+ import { NET_LABEL_HORIZONTAL_WIDTH } from "lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/geometry"
2
3
  import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
4
  import type {
4
5
  InputDirectConnection,
@@ -9,7 +10,7 @@ import "tests/fixtures/matcher"
9
10
  const inlineConnection = (
10
11
  netId: string,
11
12
  pinIds: [string, string],
12
- fallbackNetLabelWidth: number,
13
+ anchoredNetLabelWidth: number,
13
14
  inlineNetLabelWidth: number,
14
15
  netLabelText?: string,
15
16
  ): InputDirectConnection => ({
@@ -17,7 +18,7 @@ const inlineConnection = (
17
18
  netLabelText,
18
19
  pinIds,
19
20
  allowInlineNetLabel: true,
20
- fallbackNetLabelWidth,
21
+ anchoredNetLabelWidth,
21
22
  inlineNetLabelWidth,
22
23
  inlineNetLabelHeight: 0.12,
23
24
  })
@@ -88,10 +89,18 @@ const routedInputProblem: InputProblem = {
88
89
  maxMspPairDistance: 20,
89
90
  }
90
91
 
91
- test("fallback label width does not split routable inline connections", () => {
92
+ test("anchored label width does not split routable inline connections", () => {
92
93
  const solver = new SchematicTracePipelineSolver(routedInputProblem)
94
+ const inputWithoutAnchoredWidths = structuredClone(routedInputProblem)
95
+ for (const connection of inputWithoutAnchoredWidths.directConnections) {
96
+ delete connection.anchoredNetLabelWidth
97
+ }
98
+ const solverWithoutAnchoredWidths = new SchematicTracePipelineSolver(
99
+ inputWithoutAnchoredWidths,
100
+ )
93
101
 
94
102
  solver.solve()
103
+ solverWithoutAnchoredWidths.solve()
95
104
 
96
105
  expect(solver.schematicTraceLinesSolver!.solvedTracePaths).toHaveLength(5)
97
106
  expect(solver.schematicTraceLinesSolver!.failedConnectionPairs).toHaveLength(
@@ -106,6 +115,20 @@ test("fallback label width does not split routable inline connections", () => {
106
115
  (placement) => placement.stubTracePath === undefined,
107
116
  ),
108
117
  ).toBe(true)
118
+ expect(
119
+ solver.netLabelPlacementSolver!.netLabelPlacements.every(
120
+ (placement) =>
121
+ Math.max(placement.width, placement.height) ===
122
+ NET_LABEL_HORIZONTAL_WIDTH,
123
+ ),
124
+ ).toBe(true)
125
+ expect(
126
+ output.traces.map(({ mspPairId, tracePath }) => ({ mspPairId, tracePath })),
127
+ ).toEqual(
128
+ solverWithoutAnchoredWidths
129
+ .inlineNetLabelSolver!.getOutput()
130
+ .traces.map(({ mspPairId, tracePath }) => ({ mspPairId, tracePath })),
131
+ )
109
132
  expect(
110
133
  output.inlineNetLabelPlacements.find(
111
134
  (placement) => placement.netId === "OUT_A_P",
@@ -115,7 +138,7 @@ test("fallback label width does not split routable inline connections", () => {
115
138
  expect(solver).toMatchSolverSnapshot(import.meta.path)
116
139
  })
117
140
 
118
- test("fallback label width sizes anchored labels when routing is skipped", () => {
141
+ test("anchored label width sizes anchored labels when routing is skipped", () => {
119
142
  const inputProblem: InputProblem = {
120
143
  chips: [
121
144
  {
@@ -133,18 +156,18 @@ test("fallback label width sizes anchored labels when routing is skipped", () =>
133
156
  pins: [{ pinId: "U2.1", x: 2.5, y: 0, _facingDirection: "x-" }],
134
157
  },
135
158
  ],
136
- directConnections: [
159
+ directConnections: [],
160
+ netConnections: [
137
161
  {
138
162
  netId: "SIGNAL",
139
163
  netLabelText: "User-facing signal",
140
164
  pinIds: ["U1.1", "U2.1"],
141
165
  allowInlineNetLabel: true,
142
- fallbackNetLabelWidth: 0.96,
166
+ anchoredNetLabelWidth: 0.96,
143
167
  inlineNetLabelWidth: 0.64,
144
168
  inlineNetLabelHeight: 0.12,
145
169
  },
146
170
  ],
147
- netConnections: [],
148
171
  availableNetLabelOrientations: {},
149
172
  maxMspPairDistance: 1,
150
173
  }
@@ -152,10 +175,10 @@ test("fallback label width sizes anchored labels when routing is skipped", () =>
152
175
  const solver = new SchematicTracePipelineSolver(inputProblem)
153
176
  solver.solve()
154
177
 
155
- const [fallbackPlacement] = solver.netLabelPlacementSolver!.netLabelPlacements
156
- expect(fallbackPlacement).toBeDefined()
157
- expect(Math.max(fallbackPlacement!.width, fallbackPlacement!.height)).toBe(
178
+ const [anchoredPlacement] = solver.netLabelPlacementSolver!.netLabelPlacements
179
+ expect(anchoredPlacement).toBeDefined()
180
+ expect(Math.max(anchoredPlacement!.width, anchoredPlacement!.height)).toBe(
158
181
  0.96,
159
182
  )
160
- expect(fallbackPlacement!.netLabelText).toBe("User-facing signal")
183
+ expect(anchoredPlacement!.netLabelText).toBe("User-facing signal")
161
184
  })