@tscircuit/schematic-trace-solver 0.0.174 → 0.0.176

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 (63) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +759 -91
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +5 -1
  4. package/lib/solvers/InlineNetLabelSolver/InlineNetLabelSolver.ts +16 -1
  5. package/lib/solvers/InlineNetLabelSolver/restoreReroutesAroundSupersededLabels.ts +174 -0
  6. package/lib/solvers/NetLabelToTraceSolver/NetLabelToTraceSolver.ts +2 -30
  7. package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +2 -0
  8. package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +748 -15
  9. package/lib/solvers/SameNetJunctionAlignmentSolver/findNearestSharedPinExitRail.ts +140 -0
  10. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +12 -5
  11. package/lib/utils/doesPathCoincideWithTraces.ts +17 -4
  12. package/lib/utils/pathIntersectsRenderedLabel.ts +33 -0
  13. package/package.json +1 -1
  14. package/site/bug-reports/bug-report-20260901T055358Z.page.tsx +4 -0
  15. package/site/bug-reports/bug-report-20260901T064117Z.page.tsx +4 -0
  16. package/site/bug-reports/bug-report-20260901T134241Z.page.tsx +4 -0
  17. package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +2 -2
  18. package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.test.ts +9 -0
  19. package/tests/bug-reports/bug-report-20260707T230831Z/__snapshots__/bug-report-20260707T230831Z.snap.svg +2 -2
  20. package/tests/bug-reports/bug-report-20260717T042845Z/__snapshots__/bug-report-20260717T042845Z.snap.svg +2 -2
  21. package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +2 -2
  22. package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +2 -2
  23. package/tests/bug-reports/bug-report-20260730T061837Z/bug-report-20260730T061837Z.test.ts +8 -4
  24. package/tests/bug-reports/bug-report-20260804T171919Z/__snapshots__/bug-report-20260804T171919Z.snap.svg +2 -2
  25. package/tests/bug-reports/bug-report-20260805T061316Z/__snapshots__/bug-report-20260805T061316Z.snap.svg +2 -2
  26. package/tests/bug-reports/bug-report-20260806T061548Z/__snapshots__/bug-report-20260806T061548Z.snap.svg +2 -2
  27. package/tests/bug-reports/bug-report-20260825T045913Z/__snapshots__/bug-report-20260825T045913Z.snap.svg +2 -2
  28. package/tests/bug-reports/bug-report-20260826T072956Z/__snapshots__/bug-report-20260826T072956Z.snap.svg +6 -6
  29. package/tests/bug-reports/bug-report-20260901T055358Z/__snapshots__/bug-report-20260901T055358Z.snap.svg +676 -0
  30. package/tests/bug-reports/bug-report-20260901T055358Z/bug-report-20260901T055358Z.json +2467 -0
  31. package/tests/bug-reports/bug-report-20260901T055358Z/bug-report-20260901T055358Z.test.ts +59 -0
  32. package/tests/bug-reports/bug-report-20260901T064117Z/__snapshots__/bug-report-20260901T064117Z.snap.svg +134 -0
  33. package/tests/bug-reports/bug-report-20260901T064117Z/bug-report-20260901T064117Z.json +215 -0
  34. package/tests/bug-reports/bug-report-20260901T064117Z/bug-report-20260901T064117Z.test.ts +12 -0
  35. package/tests/bug-reports/bug-report-20260901T134241Z/__snapshots__/bug-report-20260901T134241Z.snap.svg +115 -0
  36. package/tests/bug-reports/bug-report-20260901T134241Z/bug-report-20260901T134241Z.json +359 -0
  37. package/tests/bug-reports/bug-report-20260901T134241Z/bug-report-20260901T134241Z.test.ts +60 -0
  38. package/tests/examples/__snapshots__/example51.snap.svg +2 -2
  39. package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +10 -10
  40. package/tests/repros/__snapshots__/board1096-usb-label-overlap-iteration.snap.svg +2 -2
  41. package/tests/repros/__snapshots__/repro-bq25895-cross-net-trace-overlap.snap.svg +2 -2
  42. package/tests/repros/__snapshots__/repro-core-ground-inline-label-fallback.snap.svg +10 -10
  43. package/tests/repros/__snapshots__/repro-example35-minimize-trace-crossing.snap.svg +2 -2
  44. package/tests/repros/__snapshots__/repro-isolated-rs485-isow7841.snap.svg +18 -18
  45. package/tests/repros/__snapshots__/repro-pga300-redundant-ground-traces.snap.svg +18 -18
  46. package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +10 -10
  47. package/tests/repros/__snapshots__/repro-powerbank-3v-system-power.snap.svg +2 -2
  48. package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +2 -2
  49. package/tests/repros/__snapshots__/repro-tida-01389-hbridge.snap.svg +2 -2
  50. package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +2 -2
  51. package/tests/repros/__snapshots__/repro-trellis-core-gnd-net-label-overlap.snap.svg +134 -0
  52. package/tests/repros/__snapshots__/repro-wireless-mouse-charger-section.snap.svg +164 -0
  53. package/tests/repros/__snapshots__/repro161-power-section-autolayout.snap.svg +2 -2
  54. package/tests/repros/__snapshots__/repro48-555-timer-vcc-rail-label.snap.svg +2 -2
  55. package/tests/repros/assets/repro-trellis-core-gnd-net-label-overlap.input.json +178 -0
  56. package/tests/repros/assets/repro-wireless-mouse-charger-section.input.json +591 -0
  57. package/tests/repros/repro-isolated-rs485-isow7841.test.ts +4 -1
  58. package/tests/repros/repro-powerbank-3v-system-power.test.ts +24 -0
  59. package/tests/repros/repro-tida-01389-hbridge.test.ts +24 -0
  60. package/tests/repros/repro-trellis-core-gnd-net-label-overlap.test.ts +73 -0
  61. package/tests/repros/repro-wireless-mouse-charger-section.test.ts +16 -0
  62. package/tests/solvers/InlineNetLabelSolver/restore-reroutes-around-superseded-labels.test.ts +186 -0
  63. package/tests/solvers/SameNetJunctionAlignmentSolver/parallel-load-rails.test.ts +1 -0
@@ -0,0 +1,359 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": -0.1399999999999999,
7
+ "y": 2.24
8
+ },
9
+ "width": 4.4,
10
+ "height": 3,
11
+ "pins": [
12
+ {
13
+ "pinId": "schematic_port_0",
14
+ "displayName": "VIN",
15
+ "x": -2.3400000000000003,
16
+ "y": 2.9400000000000004
17
+ },
18
+ {
19
+ "pinId": "schematic_port_1",
20
+ "displayName": "NC",
21
+ "x": -2.3400000000000003,
22
+ "y": 1.5400000000000003
23
+ },
24
+ {
25
+ "pinId": "schematic_port_2",
26
+ "displayName": "GND_3",
27
+ "x": 2.0600000000000005,
28
+ "y": 1.9400000000000002
29
+ },
30
+ {
31
+ "pinId": "schematic_port_3",
32
+ "displayName": "GND_4",
33
+ "x": 2.0600000000000005,
34
+ "y": 1.7400000000000002
35
+ },
36
+ {
37
+ "pinId": "schematic_port_4",
38
+ "displayName": "VOUT",
39
+ "x": 2.0600000000000005,
40
+ "y": 2.74
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ "chipId": "schematic_component_1",
46
+ "center": {
47
+ "x": -0.1399999999999999,
48
+ "y": -2.24
49
+ },
50
+ "width": 4.4,
51
+ "height": 3,
52
+ "pins": [
53
+ {
54
+ "pinId": "schematic_port_5",
55
+ "displayName": "VIN",
56
+ "x": -2.3400000000000003,
57
+ "y": -1.5400000000000003
58
+ },
59
+ {
60
+ "pinId": "schematic_port_6",
61
+ "displayName": "NC",
62
+ "x": -2.3400000000000003,
63
+ "y": -2.9400000000000004
64
+ },
65
+ {
66
+ "pinId": "schematic_port_7",
67
+ "displayName": "GND_3",
68
+ "x": 2.0600000000000005,
69
+ "y": -2.54
70
+ },
71
+ {
72
+ "pinId": "schematic_port_8",
73
+ "displayName": "GND_4",
74
+ "x": 2.0600000000000005,
75
+ "y": -2.74
76
+ },
77
+ {
78
+ "pinId": "schematic_port_9",
79
+ "displayName": "VOUT",
80
+ "x": 2.0600000000000005,
81
+ "y": -1.7400000000000002
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "chipId": "schematic_component_2",
87
+ "center": {
88
+ "x": -2.8075,
89
+ "y": 2.24
90
+ },
91
+ "width": 1.1650000000000005,
92
+ "height": 0.7600000000000009,
93
+ "pins": [
94
+ {
95
+ "pinId": "schematic_port_10",
96
+ "displayName": "anode",
97
+ "x": -2.94,
98
+ "y": 2.6200000000000006,
99
+ "_facingDirection": "y+"
100
+ },
101
+ {
102
+ "pinId": "schematic_port_11",
103
+ "displayName": "cathode",
104
+ "x": -2.94,
105
+ "y": 1.8599999999999999,
106
+ "_facingDirection": "y-"
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ "chipId": "schematic_component_3",
112
+ "center": {
113
+ "x": 3.0725,
114
+ "y": 2.24
115
+ },
116
+ "width": 1.1650000000000005,
117
+ "height": 0.7600000000000009,
118
+ "pins": [
119
+ {
120
+ "pinId": "schematic_port_12",
121
+ "displayName": "anode",
122
+ "x": 2.94,
123
+ "y": 2.6200000000000006,
124
+ "_facingDirection": "y+"
125
+ },
126
+ {
127
+ "pinId": "schematic_port_13",
128
+ "displayName": "cathode",
129
+ "x": 2.94,
130
+ "y": 1.8599999999999999,
131
+ "_facingDirection": "y-"
132
+ }
133
+ ]
134
+ },
135
+ {
136
+ "chipId": "schematic_component_4",
137
+ "center": {
138
+ "x": -2.8075,
139
+ "y": -2.24
140
+ },
141
+ "width": 1.1650000000000005,
142
+ "height": 0.7600000000000009,
143
+ "pins": [
144
+ {
145
+ "pinId": "schematic_port_14",
146
+ "displayName": "anode",
147
+ "x": -2.94,
148
+ "y": -1.8599999999999999,
149
+ "_facingDirection": "y+"
150
+ },
151
+ {
152
+ "pinId": "schematic_port_15",
153
+ "displayName": "cathode",
154
+ "x": -2.94,
155
+ "y": -2.6200000000000006,
156
+ "_facingDirection": "y-"
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "chipId": "schematic_component_5",
162
+ "center": {
163
+ "x": 3.0725,
164
+ "y": -2.24
165
+ },
166
+ "width": 1.1650000000000005,
167
+ "height": 0.7600000000000009,
168
+ "pins": [
169
+ {
170
+ "pinId": "schematic_port_16",
171
+ "displayName": "anode",
172
+ "x": 2.94,
173
+ "y": -1.8599999999999999,
174
+ "_facingDirection": "y+"
175
+ },
176
+ {
177
+ "pinId": "schematic_port_17",
178
+ "displayName": "cathode",
179
+ "x": 2.94,
180
+ "y": -2.6200000000000006,
181
+ "_facingDirection": "y-"
182
+ }
183
+ ]
184
+ }
185
+ ],
186
+ "directConnections": [
187
+ {
188
+ "netId": "C11.pin1 to U4.VIN",
189
+ "pinIds": [
190
+ "schematic_port_10",
191
+ "schematic_port_0"
192
+ ]
193
+ },
194
+ {
195
+ "netId": "U4.VIN to U5.VIN",
196
+ "pinIds": [
197
+ "schematic_port_0",
198
+ "schematic_port_5"
199
+ ]
200
+ },
201
+ {
202
+ "netId": "U5.VIN to C13.pin1",
203
+ "pinIds": [
204
+ "schematic_port_5",
205
+ "schematic_port_14"
206
+ ]
207
+ },
208
+ {
209
+ "netId": "U4.VOUT to C12.pin1",
210
+ "pinIds": [
211
+ "schematic_port_4",
212
+ "schematic_port_12"
213
+ ]
214
+ },
215
+ {
216
+ "netId": "U5.VOUT to C14.pin1",
217
+ "pinIds": [
218
+ "schematic_port_9",
219
+ "schematic_port_16"
220
+ ]
221
+ },
222
+ {
223
+ "netId": "U4.GND_3 to U4.GND_4",
224
+ "pinIds": [
225
+ "schematic_port_2",
226
+ "schematic_port_3"
227
+ ]
228
+ },
229
+ {
230
+ "netId": "U4.GND_3 to C12.pin2",
231
+ "pinIds": [
232
+ "schematic_port_2",
233
+ "schematic_port_13"
234
+ ]
235
+ },
236
+ {
237
+ "netId": "U5.GND_3 to U5.GND_4",
238
+ "pinIds": [
239
+ "schematic_port_7",
240
+ "schematic_port_8"
241
+ ]
242
+ },
243
+ {
244
+ "netId": "U5.GND_3 to C14.pin2",
245
+ "pinIds": [
246
+ "schematic_port_7",
247
+ "schematic_port_17"
248
+ ]
249
+ }
250
+ ],
251
+ "netConnections": [
252
+ {
253
+ "netId": "PWR",
254
+ "isGround": false,
255
+ "netLabelWidth": 0.42,
256
+ "netLabelHeight": 0.48,
257
+ "pinIds": [
258
+ "schematic_port_0",
259
+ "schematic_port_5",
260
+ "schematic_port_10",
261
+ "schematic_port_14"
262
+ ]
263
+ },
264
+ {
265
+ "netId": "GND",
266
+ "isGround": true,
267
+ "netLabelWidth": 0.42,
268
+ "netLabelHeight": 0.48,
269
+ "pinIds": [
270
+ "schematic_port_2",
271
+ "schematic_port_3",
272
+ "schematic_port_7",
273
+ "schematic_port_8",
274
+ "schematic_port_11",
275
+ "schematic_port_13",
276
+ "schematic_port_15",
277
+ "schematic_port_17"
278
+ ]
279
+ },
280
+ {
281
+ "netId": "V3_3",
282
+ "isGround": false,
283
+ "netLabelWidth": 0.42,
284
+ "netLabelHeight": 0.6,
285
+ "pinIds": [
286
+ "schematic_port_4",
287
+ "schematic_port_12"
288
+ ]
289
+ },
290
+ {
291
+ "netId": "V5",
292
+ "isGround": false,
293
+ "netLabelWidth": 0.42,
294
+ "netLabelHeight": 0.36,
295
+ "pinIds": [
296
+ "schematic_port_9",
297
+ "schematic_port_16"
298
+ ]
299
+ }
300
+ ],
301
+ "textBoxes": [
302
+ {
303
+ "chipId": "schematic_component_0",
304
+ "center": {
305
+ "x": -0.98,
306
+ "y": 0.6100000000000002
307
+ },
308
+ "width": 1.92,
309
+ "height": 0.17999999999999994,
310
+ "text": "TPS7B6933QDBVRQ1"
311
+ },
312
+ {
313
+ "chipId": "schematic_component_0",
314
+ "center": {
315
+ "x": -1.8199999999999998,
316
+ "y": 3.8550000000000004
317
+ },
318
+ "width": 0.3600000000000001,
319
+ "height": 0.24999999999999956,
320
+ "text": "U4"
321
+ },
322
+ {
323
+ "chipId": "schematic_component_1",
324
+ "center": {
325
+ "x": -0.98,
326
+ "y": -3.87
327
+ },
328
+ "width": 1.92,
329
+ "height": 0.17999999999999972,
330
+ "text": "TPS7B6950QDBVRQ1"
331
+ },
332
+ {
333
+ "chipId": "schematic_component_1",
334
+ "center": {
335
+ "x": -1.8199999999999998,
336
+ "y": -0.6250000000000002
337
+ },
338
+ "width": 0.3600000000000001,
339
+ "height": 0.25,
340
+ "text": "U5"
341
+ }
342
+ ],
343
+ "availableNetLabelOrientations": {
344
+ "GND": [
345
+ "y-"
346
+ ],
347
+ "PWR": [
348
+ "y+"
349
+ ],
350
+ "V3_3": [
351
+ "y+"
352
+ ],
353
+ "V5": [
354
+ "y+"
355
+ ]
356
+ },
357
+ "maxMspPairDistance": 20,
358
+ "_hideRatsNet": false
359
+ }
@@ -0,0 +1,60 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import inputProblem from "./bug-report-20260901T134241Z.json"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("bug-report-20260901T134241Z", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem as any)
8
+
9
+ solver.solve()
10
+
11
+ const alignedTraces = solver.sameNetJunctionAlignmentSolver!.outputTraces
12
+ for (const [sharedPinId, adjacentPinId, targetPinId] of [
13
+ ["schematic_port_2", "schematic_port_3", "schematic_port_13"],
14
+ ["schematic_port_7", "schematic_port_8", "schematic_port_17"],
15
+ ]) {
16
+ const sharedPin = solver.inputProblem.chips
17
+ .flatMap((chip) => chip.pins)
18
+ .find((pin) => pin.pinId === sharedPinId)!
19
+ const adjacentPin = solver.inputProblem.chips
20
+ .flatMap((chip) => chip.pins)
21
+ .find((pin) => pin.pinId === adjacentPinId)!
22
+ const trace = alignedTraces.find(
23
+ (trace) =>
24
+ trace.pinIds.includes(sharedPinId) &&
25
+ trace.pinIds.includes(targetPinId),
26
+ )!
27
+ const pathFromShared =
28
+ trace.pins[0]!.pinId === sharedPinId
29
+ ? trace.tracePath
30
+ : [...trace.tracePath].reverse()
31
+
32
+ expect(pathFromShared[1]!.x).toBeCloseTo(pathFromShared[2]!.x, 6)
33
+ expect(pathFromShared[2]!.y).toBeCloseTo(adjacentPin.y, 6)
34
+ expect(pathFromShared[3]!.y).toBeCloseTo(adjacentPin.y, 6)
35
+ expect(pathFromShared[0]).toEqual({ x: sharedPin.x, y: sharedPin.y })
36
+ }
37
+
38
+ const lowerSupplyPin = solver.inputProblem.chips
39
+ .flatMap((chip) => chip.pins)
40
+ .find((pin) => pin.pinId === "schematic_port_5")!
41
+ const upperSupplyPin = solver.inputProblem.chips
42
+ .flatMap((chip) => chip.pins)
43
+ .find((pin) => pin.pinId === "schematic_port_0")!
44
+ const supplyBus = alignedTraces.find(
45
+ (trace) =>
46
+ trace.pinIds.includes("schematic_port_14") &&
47
+ trace.pinIds.includes("schematic_port_10"),
48
+ )!
49
+ const lowerToUpperSupplyPath =
50
+ supplyBus.pins[0]!.pinId === "schematic_port_14"
51
+ ? supplyBus.tracePath
52
+ : [...supplyBus.tracePath].reverse()
53
+
54
+ expect(lowerToUpperSupplyPath[1]!.y).toBeCloseTo(lowerSupplyPin.y, 6)
55
+ expect(lowerToUpperSupplyPath[2]!.y).toBeCloseTo(lowerSupplyPin.y, 6)
56
+ expect(lowerToUpperSupplyPath[3]!.y).toBeCloseTo(upperSupplyPin.y, 6)
57
+ expect(lowerToUpperSupplyPath[4]!.y).toBeCloseTo(upperSupplyPin.y, 6)
58
+
59
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
60
+ })