@tscircuit/schematic-trace-solver 0.0.114 → 0.0.116

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 +22 -9
  2. package/dist/index.js +248 -3
  3. package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +71 -0
  4. package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +223 -0
  5. package/lib/solvers/SameNetJunctionAlignmentSolver/pathIntersectsAnyNetLabel.ts +22 -0
  6. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +9 -9
  7. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/rect.ts +25 -9
  8. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +17 -0
  9. package/package.json +2 -2
  10. package/site/bug-reports/bug-report-20260730T061837Z.page.tsx +4 -0
  11. package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +1 -1
  12. package/tests/bug-reports/bug-report-20260728T144234Z/__snapshots__/bug-report-20260728T144234Z.snap.svg +1 -1
  13. package/tests/bug-reports/bug-report-20260728T144234Z/bug-report-20260728T144234Z.test.ts +6 -0
  14. package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +123 -0
  15. package/tests/bug-reports/bug-report-20260730T061837Z/bug-report-20260730T061837Z.json +614 -0
  16. package/tests/bug-reports/bug-report-20260730T061837Z/bug-report-20260730T061837Z.test.ts +34 -0
  17. package/tests/repros/__snapshots__/board-15984-same-net-junction.snap.svg +110 -0
  18. package/tests/repros/__snapshots__/repro-type-c-16pin-self-connection.snap.svg +54 -0
  19. package/tests/repros/__snapshots__/repro-type-c-16pin-to-resistor.snap.svg +56 -0
  20. package/tests/repros/__snapshots__/repro48-555-timer-vcc-rail-label.snap.svg +87 -0
  21. package/tests/repros/assets/board-15984-schematic-trace-input.json +518 -0
  22. package/tests/repros/assets/repro48-555-timer-vcc-rail-label.input.json +276 -0
  23. package/tests/repros/board-15984-same-net-junction.test.ts +30 -0
  24. package/tests/repros/repro-type-c-16pin-self-connection.test.ts +97 -0
  25. package/tests/repros/repro-type-c-16pin-to-resistor.test.ts +120 -0
  26. package/tests/repros/repro48-555-timer-vcc-rail-label.test.ts +23 -0
  27. package/tests/solvers/SchematicTraceSingleLineSolver2/text-box-obstacle-gap.test.ts +43 -0
@@ -0,0 +1,614 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 1.38,
7
+ "y": 0
8
+ },
9
+ "width": 2.3,
10
+ "height": 3.2,
11
+ "pins": [
12
+ {
13
+ "pinId": "schematic_port_0",
14
+ "x": 0.22999999999999998,
15
+ "y": 1.4000000000000001
16
+ },
17
+ {
18
+ "pinId": "schematic_port_1",
19
+ "x": 0.22999999999999998,
20
+ "y": 1.2000000000000002
21
+ },
22
+ {
23
+ "pinId": "schematic_port_2",
24
+ "x": 0.22999999999999998,
25
+ "y": 1
26
+ },
27
+ {
28
+ "pinId": "schematic_port_3",
29
+ "x": 0.22999999999999998,
30
+ "y": 0.8
31
+ },
32
+ {
33
+ "pinId": "schematic_port_4",
34
+ "x": 0.22999999999999998,
35
+ "y": 0.6000000000000001
36
+ },
37
+ {
38
+ "pinId": "schematic_port_5",
39
+ "x": 0.22999999999999998,
40
+ "y": 0.40000000000000013
41
+ },
42
+ {
43
+ "pinId": "schematic_port_6",
44
+ "x": 0.22999999999999998,
45
+ "y": 0.20000000000000018
46
+ },
47
+ {
48
+ "pinId": "schematic_port_7",
49
+ "x": 0.22999999999999998,
50
+ "y": 2.220446049250313e-16
51
+ },
52
+ {
53
+ "pinId": "schematic_port_8",
54
+ "x": 0.22999999999999998,
55
+ "y": -0.19999999999999973
56
+ },
57
+ {
58
+ "pinId": "schematic_port_9",
59
+ "x": 0.22999999999999998,
60
+ "y": -0.3999999999999997
61
+ },
62
+ {
63
+ "pinId": "schematic_port_10",
64
+ "x": 0.22999999999999998,
65
+ "y": -0.5999999999999996
66
+ },
67
+ {
68
+ "pinId": "schematic_port_11",
69
+ "x": 0.22999999999999998,
70
+ "y": -0.7999999999999996
71
+ },
72
+ {
73
+ "pinId": "schematic_port_12",
74
+ "x": 0.22999999999999998,
75
+ "y": -0.9999999999999998
76
+ },
77
+ {
78
+ "pinId": "schematic_port_13",
79
+ "x": 0.22999999999999998,
80
+ "y": -1.2
81
+ },
82
+ {
83
+ "pinId": "schematic_port_14",
84
+ "x": 0.22999999999999998,
85
+ "y": -1.4000000000000001
86
+ },
87
+ {
88
+ "pinId": "schematic_port_15",
89
+ "x": 2.53,
90
+ "y": -1.3
91
+ },
92
+ {
93
+ "pinId": "schematic_port_16",
94
+ "x": 2.53,
95
+ "y": -1.1
96
+ },
97
+ {
98
+ "pinId": "schematic_port_17",
99
+ "x": 2.53,
100
+ "y": -0.9
101
+ },
102
+ {
103
+ "pinId": "schematic_port_18",
104
+ "x": 2.53,
105
+ "y": -0.7
106
+ },
107
+ {
108
+ "pinId": "schematic_port_19",
109
+ "x": 2.53,
110
+ "y": -0.5
111
+ },
112
+ {
113
+ "pinId": "schematic_port_20",
114
+ "x": 2.53,
115
+ "y": -0.30000000000000004
116
+ },
117
+ {
118
+ "pinId": "schematic_port_21",
119
+ "x": 2.53,
120
+ "y": -0.10000000000000009
121
+ },
122
+ {
123
+ "pinId": "schematic_port_22",
124
+ "x": 2.53,
125
+ "y": 0.09999999999999987
126
+ },
127
+ {
128
+ "pinId": "schematic_port_23",
129
+ "x": 2.53,
130
+ "y": 0.2999999999999998
131
+ },
132
+ {
133
+ "pinId": "schematic_port_24",
134
+ "x": 2.53,
135
+ "y": 0.4999999999999998
136
+ },
137
+ {
138
+ "pinId": "schematic_port_25",
139
+ "x": 2.53,
140
+ "y": 0.6999999999999997
141
+ },
142
+ {
143
+ "pinId": "schematic_port_26",
144
+ "x": 2.53,
145
+ "y": 0.8999999999999997
146
+ },
147
+ {
148
+ "pinId": "schematic_port_27",
149
+ "x": 2.53,
150
+ "y": 1.0999999999999999
151
+ },
152
+ {
153
+ "pinId": "schematic_port_28",
154
+ "x": 2.53,
155
+ "y": 1.3
156
+ }
157
+ ],
158
+ "sectionId": "USB to UART"
159
+ },
160
+ {
161
+ "chipId": "schematic_component_1",
162
+ "center": {
163
+ "x": -5.924999999999999,
164
+ "y": -0.010000000000000231
165
+ },
166
+ "width": 1.04,
167
+ "height": 0.76,
168
+ "pins": [
169
+ {
170
+ "pinId": "schematic_port_29",
171
+ "x": -6.119999999999999,
172
+ "y": 0.3699999999999998,
173
+ "_facingDirection": "y+"
174
+ },
175
+ {
176
+ "pinId": "schematic_port_30",
177
+ "x": -6.119999999999999,
178
+ "y": -0.39000000000000024,
179
+ "_facingDirection": "y-"
180
+ }
181
+ ],
182
+ "sectionId": "USB to UART"
183
+ },
184
+ {
185
+ "chipId": "schematic_component_2",
186
+ "center": {
187
+ "x": -4.744999999999999,
188
+ "y": -0.010000000000000231
189
+ },
190
+ "width": 0.9200000000000008,
191
+ "height": 0.76,
192
+ "pins": [
193
+ {
194
+ "pinId": "schematic_port_31",
195
+ "x": -4.879999999999999,
196
+ "y": 0.3699999999999998,
197
+ "_facingDirection": "y+"
198
+ },
199
+ {
200
+ "pinId": "schematic_port_32",
201
+ "x": -4.879999999999999,
202
+ "y": -0.39000000000000024,
203
+ "_facingDirection": "y-"
204
+ }
205
+ ],
206
+ "sectionId": "USB to UART"
207
+ },
208
+ {
209
+ "chipId": "schematic_component_3",
210
+ "center": {
211
+ "x": -3.3749999999999996,
212
+ "y": -0.010000000000000231
213
+ },
214
+ "width": 0.7800000000000002,
215
+ "height": 0.76,
216
+ "pins": [
217
+ {
218
+ "pinId": "schematic_port_33",
219
+ "x": -3.4399999999999995,
220
+ "y": -0.39000000000000024,
221
+ "_facingDirection": "y-"
222
+ },
223
+ {
224
+ "pinId": "schematic_port_34",
225
+ "x": -3.4399999999999995,
226
+ "y": 0.3699999999999998,
227
+ "_facingDirection": "y+"
228
+ }
229
+ ],
230
+ "sectionId": "USB to UART"
231
+ },
232
+ {
233
+ "chipId": "schematic_component_4",
234
+ "center": {
235
+ "x": -0.4824999999999998,
236
+ "y": 0.2999999999999998
237
+ },
238
+ "width": 1.2049999999999998,
239
+ "height": 0.6000000000000001,
240
+ "pins": [
241
+ {
242
+ "pinId": "schematic_port_35",
243
+ "x": -0.7599999999999998,
244
+ "y": -2.220446049250313e-16,
245
+ "_facingDirection": "y-"
246
+ },
247
+ {
248
+ "pinId": "schematic_port_36",
249
+ "x": -0.7599999999999998,
250
+ "y": 0.5999999999999999,
251
+ "_facingDirection": "y+"
252
+ }
253
+ ],
254
+ "sectionId": "USB to UART"
255
+ },
256
+ {
257
+ "chipId": "schematic_component_5",
258
+ "center": {
259
+ "x": -1.4724999999999997,
260
+ "y": -1
261
+ },
262
+ "width": 1.205,
263
+ "height": 0.6000000000000001,
264
+ "pins": [
265
+ {
266
+ "pinId": "schematic_port_37",
267
+ "x": -1.7499999999999996,
268
+ "y": -0.7,
269
+ "_facingDirection": "y+"
270
+ },
271
+ {
272
+ "pinId": "schematic_port_38",
273
+ "x": -1.7499999999999996,
274
+ "y": -1.3,
275
+ "_facingDirection": "y-"
276
+ }
277
+ ],
278
+ "sectionId": "USB to UART"
279
+ },
280
+ {
281
+ "chipId": "schematic_component_6",
282
+ "center": {
283
+ "x": -2.07,
284
+ "y": 0.2900000000000001
285
+ },
286
+ "width": 0.6000000000000001,
287
+ "height": 0.68,
288
+ "pins": [
289
+ {
290
+ "pinId": "schematic_port_39",
291
+ "x": -2.37,
292
+ "y": 0.29000000000000004
293
+ },
294
+ {
295
+ "pinId": "schematic_port_40",
296
+ "x": -1.7699999999999998,
297
+ "y": 0.29000000000000004
298
+ }
299
+ ],
300
+ "sectionId": "USB to UART"
301
+ },
302
+ {
303
+ "chipId": "schematic_component_7",
304
+ "center": {
305
+ "x": 3.53,
306
+ "y": 0.7000000000000011
307
+ },
308
+ "width": 0.5999999999999996,
309
+ "height": 0.6800000000000002,
310
+ "pins": [
311
+ {
312
+ "pinId": "schematic_port_41",
313
+ "x": 3.8299999999999996,
314
+ "y": 0.7000000000000011,
315
+ "_facingDirection": "x+"
316
+ },
317
+ {
318
+ "pinId": "schematic_port_42",
319
+ "x": 3.23,
320
+ "y": 0.7000000000000011,
321
+ "_facingDirection": "x-"
322
+ }
323
+ ],
324
+ "sectionId": "USB to UART"
325
+ },
326
+ {
327
+ "chipId": "schematic_component_8",
328
+ "center": {
329
+ "x": 3.6174999999999997,
330
+ "y": -0.5899999999999981
331
+ },
332
+ "width": 0.8450000000000006,
333
+ "height": 0.6000000000000001,
334
+ "pins": [
335
+ {
336
+ "pinId": "schematic_port_43",
337
+ "x": 3.5199999999999996,
338
+ "y": -0.8899999999999981,
339
+ "_facingDirection": "y-"
340
+ },
341
+ {
342
+ "pinId": "schematic_port_44",
343
+ "x": 3.5199999999999996,
344
+ "y": -0.28999999999999804,
345
+ "_facingDirection": "y+"
346
+ }
347
+ ],
348
+ "sectionId": "USB to UART"
349
+ },
350
+ {
351
+ "chipId": "schematic_component_9",
352
+ "center": {
353
+ "x": 6.0649999999999995,
354
+ "y": 0.6000000000000014
355
+ },
356
+ "width": 2,
357
+ "height": 0.7999999999999999,
358
+ "pins": [
359
+ {
360
+ "pinId": "schematic_port_45",
361
+ "x": 5.0649999999999995,
362
+ "y": 0.8000000000000014
363
+ },
364
+ {
365
+ "pinId": "schematic_port_46",
366
+ "x": 5.0649999999999995,
367
+ "y": 0.6000000000000014
368
+ },
369
+ {
370
+ "pinId": "schematic_port_47",
371
+ "x": 5.0649999999999995,
372
+ "y": 0.4000000000000014
373
+ },
374
+ {
375
+ "pinId": "schematic_port_48",
376
+ "x": 7.0649999999999995,
377
+ "y": 0.4000000000000014
378
+ },
379
+ {
380
+ "pinId": "schematic_port_49",
381
+ "x": 7.0649999999999995,
382
+ "y": 0.6000000000000014
383
+ },
384
+ {
385
+ "pinId": "schematic_port_50",
386
+ "x": 7.0649999999999995,
387
+ "y": 0.8000000000000014
388
+ }
389
+ ],
390
+ "sectionId": "USB to UART"
391
+ }
392
+ ],
393
+ "directConnections": [
394
+ {
395
+ "netId": ".U6 > .TXD to .R8 > .pin2",
396
+ "pinIds": [
397
+ "schematic_port_25",
398
+ "schematic_port_42"
399
+ ]
400
+ },
401
+ {
402
+ "netId": ".U6 > .RXD to .R9 > .pin2",
403
+ "pinIds": [
404
+ "schematic_port_24",
405
+ "schematic_port_44"
406
+ ]
407
+ },
408
+ {
409
+ "netId": ".U6 > .VDD to .C8 > .pin2",
410
+ "pinIds": [
411
+ "schematic_port_5",
412
+ "schematic_port_34"
413
+ ]
414
+ },
415
+ {
416
+ "netId": ".R5 > .pin1 to .R6 > .pin1",
417
+ "pinIds": [
418
+ "schematic_port_35",
419
+ "schematic_port_37"
420
+ ]
421
+ },
422
+ {
423
+ "netId": ".R5 > .pin1 to .U6 > .VBUS",
424
+ "pinIds": [
425
+ "schematic_port_35",
426
+ "schematic_port_7"
427
+ ]
428
+ },
429
+ {
430
+ "netId": ".R7 > .pin1 to .U6 > .VDD",
431
+ "pinIds": [
432
+ "schematic_port_39",
433
+ "schematic_port_5"
434
+ ]
435
+ },
436
+ {
437
+ "netId": ".R7 > .pin2 to .U6 > .RSTb",
438
+ "pinIds": [
439
+ "schematic_port_40",
440
+ "schematic_port_8"
441
+ ]
442
+ }
443
+ ],
444
+ "netConnections": [
445
+ {
446
+ "netId": "GND",
447
+ "netLabelWidth": 0.42,
448
+ "netLabelHeight": 0.48,
449
+ "pinIds": [
450
+ "schematic_port_2",
451
+ "schematic_port_28",
452
+ "schematic_port_30",
453
+ "schematic_port_32",
454
+ "schematic_port_33",
455
+ "schematic_port_38"
456
+ ]
457
+ },
458
+ {
459
+ "netId": "DP",
460
+ "netLabelWidth": 0.36,
461
+ "pinIds": [
462
+ "schematic_port_3"
463
+ ]
464
+ },
465
+ {
466
+ "netId": "DM",
467
+ "netLabelWidth": 0.36,
468
+ "pinIds": [
469
+ "schematic_port_4"
470
+ ]
471
+ },
472
+ {
473
+ "netId": "VBUS",
474
+ "netLabelWidth": 0.42,
475
+ "netLabelHeight": 0.6,
476
+ "pinIds": [
477
+ "schematic_port_6",
478
+ "schematic_port_29",
479
+ "schematic_port_31",
480
+ "schematic_port_36"
481
+ ]
482
+ },
483
+ {
484
+ "netId": "RTS",
485
+ "netLabelWidth": 0.48,
486
+ "pinIds": [
487
+ "schematic_port_23",
488
+ "schematic_port_45",
489
+ "schematic_port_49"
490
+ ]
491
+ },
492
+ {
493
+ "netId": "DTR",
494
+ "netLabelWidth": 0.48,
495
+ "pinIds": [
496
+ "schematic_port_27",
497
+ "schematic_port_46",
498
+ "schematic_port_48"
499
+ ]
500
+ },
501
+ {
502
+ "netId": "RX",
503
+ "netLabelWidth": 0.36,
504
+ "pinIds": [
505
+ "schematic_port_41"
506
+ ]
507
+ },
508
+ {
509
+ "netId": "TX",
510
+ "netLabelWidth": 0.36,
511
+ "pinIds": [
512
+ "schematic_port_43"
513
+ ]
514
+ },
515
+ {
516
+ "netId": "IO0",
517
+ "netLabelWidth": 0.48,
518
+ "pinIds": [
519
+ "schematic_port_47"
520
+ ]
521
+ },
522
+ {
523
+ "netId": "EN",
524
+ "netLabelWidth": 0.36,
525
+ "pinIds": [
526
+ "schematic_port_50"
527
+ ]
528
+ }
529
+ ],
530
+ "textBoxes": [
531
+ {
532
+ "chipId": "schematic_component_0",
533
+ "center": {
534
+ "x": 1.7699999999999998,
535
+ "y": -1.73
536
+ },
537
+ "width": 2.28,
538
+ "height": 0.18000000000000016,
539
+ "text": "CP2102N_A02_GQFN28R"
540
+ },
541
+ {
542
+ "chipId": "schematic_component_0",
543
+ "center": {
544
+ "x": 0.7499999999999999,
545
+ "y": 1.7150000000000003
546
+ },
547
+ "width": 0.3600000000000001,
548
+ "height": 0.2500000000000002,
549
+ "text": "U6"
550
+ },
551
+ {
552
+ "chipId": "schematic_component_9",
553
+ "center": {
554
+ "x": 6.185,
555
+ "y": 0.0700000000000014
556
+ },
557
+ "width": 1.4399999999999995,
558
+ "height": 0.18,
559
+ "text": "DDC114TU_7_F"
560
+ },
561
+ {
562
+ "chipId": "schematic_component_9",
563
+ "center": {
564
+ "x": 5.585,
565
+ "y": 1.1150000000000015
566
+ },
567
+ "width": 0.35999999999999943,
568
+ "height": 0.2500000000000002,
569
+ "text": "U7"
570
+ }
571
+ ],
572
+ "availableNetLabelOrientations": {
573
+ "DP": [
574
+ "x-",
575
+ "x+"
576
+ ],
577
+ "DM": [
578
+ "x-",
579
+ "x+"
580
+ ],
581
+ "VBUS": [
582
+ "y+"
583
+ ],
584
+ "GND": [
585
+ "y-"
586
+ ],
587
+ "RX": [
588
+ "x-",
589
+ "x+"
590
+ ],
591
+ "TX": [
592
+ "x-",
593
+ "x+"
594
+ ],
595
+ "RTS": [
596
+ "x-",
597
+ "x+"
598
+ ],
599
+ "DTR": [
600
+ "x-",
601
+ "x+"
602
+ ],
603
+ "IO0": [
604
+ "x-",
605
+ "x+"
606
+ ],
607
+ "EN": [
608
+ "x-",
609
+ "x+"
610
+ ]
611
+ },
612
+ "maxMspPairDistance": 8,
613
+ "_hideRatsNet": false
614
+ }
@@ -0,0 +1,34 @@
1
+ import { expect, test } from "bun:test"
2
+ import { pathIntersectsAnyNetLabel } from "lib/solvers/SameNetJunctionAlignmentSolver/pathIntersectsAnyNetLabel"
3
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
4
+ import inputProblem from "./bug-report-20260730T061837Z.json"
5
+ import "tests/fixtures/matcher"
6
+
7
+ test("bug-report-20260730T061837Z", () => {
8
+ const solver = new SchematicTracePipelineSolver(inputProblem as any)
9
+
10
+ solver.solve()
11
+
12
+ const traces = solver.sameNetJunctionAlignmentSolver!.getOutput().traces
13
+ const vddBranch = traces.find(
14
+ (trace) => trace.mspPairId === "schematic_port_39-schematic_port_34",
15
+ )!
16
+ const vbusBranch = traces.find(
17
+ (trace) => trace.mspPairId === "schematic_port_31-schematic_port_29",
18
+ )!
19
+
20
+ expect(vddBranch.tracePath).toContainEqual({
21
+ x: -2.905,
22
+ y: 0.57,
23
+ })
24
+ expect(
25
+ pathIntersectsAnyNetLabel({
26
+ path: vddBranch.tracePath,
27
+ netLabelPlacements:
28
+ solver.sameNetJunctionAlignmentSolver!.getOutput().netLabelPlacements,
29
+ }),
30
+ ).toBe(false)
31
+ expect(vbusBranch.tracePath[1]!.y).toBeCloseTo(0.9)
32
+ expect(vbusBranch.tracePath[2]!.y).toBeCloseTo(0.9)
33
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
34
+ })