@tscircuit/schematic-trace-solver 0.0.136 → 0.0.140

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/.github/workflows/bun-pver-release.yml +7 -3
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +333 -45
  4. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex.ts +182 -0
  5. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +67 -25
  6. package/lib/solvers/AvailableNetOrientationSolver/constants.ts +2 -0
  7. package/lib/solvers/Example28Solver/labelMovement.ts +71 -0
  8. package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +5 -2
  9. package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +93 -14
  10. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +12 -4
  11. package/package.json +5 -1
  12. package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +4 -4
  13. package/tests/bug-reports/bug-report-20260721T221026Z/bug-report-20260721T221026Z.test.ts +11 -0
  14. package/tests/bug-reports/bug-report-20260815T073240Z/__snapshots__/bug-report-20260815T073240Z.snap.svg +3 -3
  15. package/tests/bug-reports/bug-report-20260815T073240Z/bug-report-20260815T073240Z.test.ts +39 -0
  16. package/tests/bug-reports/bug-report-20260819T091818Z/__snapshots__/bug-report-20260819T091818Z.snap.svg +237 -0
  17. package/tests/bug-reports/bug-report-20260819T091818Z/bug-report-20260819T091818Z.json +1052 -0
  18. package/tests/bug-reports/bug-report-20260819T091818Z/bug-report-20260819T091818Z.test.ts +33 -0
  19. package/tests/repros/__snapshots__/repro-board-589-regulator-section.snap.svg +4 -4
  20. package/tests/repros/__snapshots__/repro-board-648-esp12f-section.snap.svg +124 -0
  21. package/tests/repros/assets/repro-board-648-esp12f-section.input.json +537 -0
  22. package/tests/repros/repro-board-589-regulator-section.test.ts +23 -1
  23. package/tests/repros/repro-board-648-esp12f-section.test.ts +13 -0
  24. package/tests/repros/repro161-power-section-autolayout.test.ts +7 -0
  25. package/tests/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex.test.ts +122 -0
@@ -0,0 +1,537 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_9",
5
+ "center": {
6
+ "x": 11.035000000000002,
7
+ "y": -5.0189106999999975
8
+ },
9
+ "width": 2.1999999999999993,
10
+ "height": 2.4000000000000004,
11
+ "pins": [
12
+ {
13
+ "pinId": "schematic_port_35",
14
+ "x": 9.935000000000002,
15
+ "y": -4.0189106999999975
16
+ },
17
+ {
18
+ "pinId": "schematic_port_36",
19
+ "x": 9.935000000000002,
20
+ "y": -4.218910699999998
21
+ },
22
+ {
23
+ "pinId": "schematic_port_37",
24
+ "x": 9.935000000000002,
25
+ "y": -4.418910699999998
26
+ },
27
+ {
28
+ "pinId": "schematic_port_38",
29
+ "x": 9.935000000000002,
30
+ "y": -4.618910699999998
31
+ },
32
+ {
33
+ "pinId": "schematic_port_39",
34
+ "x": 9.935000000000002,
35
+ "y": -4.818910699999997
36
+ },
37
+ {
38
+ "pinId": "schematic_port_40",
39
+ "x": 9.935000000000002,
40
+ "y": -5.0189106999999975
41
+ },
42
+ {
43
+ "pinId": "schematic_port_41",
44
+ "x": 9.935000000000002,
45
+ "y": -5.218910699999998
46
+ },
47
+ {
48
+ "pinId": "schematic_port_42",
49
+ "x": 9.935000000000002,
50
+ "y": -5.418910699999998
51
+ },
52
+ {
53
+ "pinId": "schematic_port_43",
54
+ "x": 9.935000000000002,
55
+ "y": -5.618910699999997
56
+ },
57
+ {
58
+ "pinId": "schematic_port_44",
59
+ "x": 9.935000000000002,
60
+ "y": -5.818910699999997
61
+ },
62
+ {
63
+ "pinId": "schematic_port_45",
64
+ "x": 9.935000000000002,
65
+ "y": -6.0189106999999975
66
+ },
67
+ {
68
+ "pinId": "schematic_port_46",
69
+ "x": 12.135000000000002,
70
+ "y": -6.0189106999999975
71
+ },
72
+ {
73
+ "pinId": "schematic_port_47",
74
+ "x": 12.135000000000002,
75
+ "y": -5.818910699999997
76
+ },
77
+ {
78
+ "pinId": "schematic_port_48",
79
+ "x": 12.135000000000002,
80
+ "y": -5.618910699999997
81
+ },
82
+ {
83
+ "pinId": "schematic_port_49",
84
+ "x": 12.135000000000002,
85
+ "y": -5.418910699999997
86
+ },
87
+ {
88
+ "pinId": "schematic_port_50",
89
+ "x": 12.135000000000002,
90
+ "y": -5.218910699999998
91
+ },
92
+ {
93
+ "pinId": "schematic_port_51",
94
+ "x": 12.135000000000002,
95
+ "y": -5.0189106999999975
96
+ },
97
+ {
98
+ "pinId": "schematic_port_52",
99
+ "x": 12.135000000000002,
100
+ "y": -4.818910699999997
101
+ },
102
+ {
103
+ "pinId": "schematic_port_53",
104
+ "x": 12.135000000000002,
105
+ "y": -4.618910699999997
106
+ },
107
+ {
108
+ "pinId": "schematic_port_54",
109
+ "x": 12.135000000000002,
110
+ "y": -4.418910699999998
111
+ },
112
+ {
113
+ "pinId": "schematic_port_55",
114
+ "x": 12.135000000000002,
115
+ "y": -4.218910699999998
116
+ },
117
+ {
118
+ "pinId": "schematic_port_56",
119
+ "x": 12.135000000000002,
120
+ "y": -4.0189106999999975
121
+ }
122
+ ],
123
+ "sectionId": "esp12f_power_and_boot"
124
+ },
125
+ {
126
+ "chipId": "schematic_component_10",
127
+ "center": {
128
+ "x": 7.610000000000001,
129
+ "y": -5.918910699999998
130
+ },
131
+ "width": 0.9200000000000008,
132
+ "height": 0.7599999999999998,
133
+ "pins": [
134
+ {
135
+ "pinId": "schematic_port_57",
136
+ "x": 7.475000000000001,
137
+ "y": -5.538910699999998,
138
+ "_facingDirection": "y+"
139
+ },
140
+ {
141
+ "pinId": "schematic_port_58",
142
+ "x": 7.475000000000001,
143
+ "y": -6.298910699999998,
144
+ "_facingDirection": "y-"
145
+ }
146
+ ],
147
+ "sectionId": "esp12f_power_and_boot"
148
+ },
149
+ {
150
+ "chipId": "schematic_component_11",
151
+ "center": {
152
+ "x": 8.910000000000002,
153
+ "y": -5.918910699999998
154
+ },
155
+ "width": 1.0399999999999991,
156
+ "height": 0.7599999999999998,
157
+ "pins": [
158
+ {
159
+ "pinId": "schematic_port_59",
160
+ "x": 8.715000000000002,
161
+ "y": -5.538910699999998,
162
+ "_facingDirection": "y+"
163
+ },
164
+ {
165
+ "pinId": "schematic_port_60",
166
+ "x": 8.715000000000002,
167
+ "y": -6.298910699999998,
168
+ "_facingDirection": "y-"
169
+ }
170
+ ],
171
+ "sectionId": "esp12f_power_and_boot"
172
+ },
173
+ {
174
+ "chipId": "schematic_component_12",
175
+ "center": {
176
+ "x": 8.547500000000003,
177
+ "y": -3.708910699999998
178
+ },
179
+ "width": 0.9649999999999999,
180
+ "height": 0.5999999999999996,
181
+ "pins": [
182
+ {
183
+ "pinId": "schematic_port_61",
184
+ "x": 8.390000000000002,
185
+ "y": -3.408910699999998,
186
+ "_facingDirection": "y+"
187
+ },
188
+ {
189
+ "pinId": "schematic_port_62",
190
+ "x": 8.390000000000002,
191
+ "y": -4.008910699999998,
192
+ "_facingDirection": "y-"
193
+ }
194
+ ],
195
+ "sectionId": "esp12f_power_and_boot"
196
+ },
197
+ {
198
+ "chipId": "schematic_component_13",
199
+ "center": {
200
+ "x": 9.300000000000002,
201
+ "y": -1.8989106999999983
202
+ },
203
+ "width": 0.9649999999999999,
204
+ "height": 0.5999999999999999,
205
+ "pins": [
206
+ {
207
+ "pinId": "schematic_port_63",
208
+ "x": 9.142500000000002,
209
+ "y": -1.5989106999999985,
210
+ "_facingDirection": "y+"
211
+ },
212
+ {
213
+ "pinId": "schematic_port_64",
214
+ "x": 9.142500000000002,
215
+ "y": -2.198910699999998,
216
+ "_facingDirection": "y-"
217
+ }
218
+ ],
219
+ "sectionId": "esp12f_power_and_boot"
220
+ },
221
+ {
222
+ "chipId": "schematic_component_14",
223
+ "center": {
224
+ "x": 9.740000000000002,
225
+ "y": -8.123910699999996
226
+ },
227
+ "width": 0.9649999999999999,
228
+ "height": 0.6000000000000014,
229
+ "pins": [
230
+ {
231
+ "pinId": "schematic_port_65",
232
+ "x": 9.582500000000001,
233
+ "y": -7.823910699999995
234
+ },
235
+ {
236
+ "pinId": "schematic_port_66",
237
+ "x": 9.582500000000001,
238
+ "y": -8.423910699999997
239
+ }
240
+ ],
241
+ "sectionId": "esp12f_power_and_boot"
242
+ },
243
+ {
244
+ "chipId": "schematic_component_15",
245
+ "center": {
246
+ "x": 7.860000000000001,
247
+ "y": -7.328910699999997
248
+ },
249
+ "width": 0.9649999999999999,
250
+ "height": 0.5999999999999996,
251
+ "pins": [
252
+ {
253
+ "pinId": "schematic_port_67",
254
+ "x": 7.7025000000000015,
255
+ "y": -7.028910699999997,
256
+ "_facingDirection": "y+"
257
+ },
258
+ {
259
+ "pinId": "schematic_port_68",
260
+ "x": 7.7025000000000015,
261
+ "y": -7.628910699999997,
262
+ "_facingDirection": "y-"
263
+ }
264
+ ],
265
+ "sectionId": "esp12f_power_and_boot"
266
+ },
267
+ {
268
+ "chipId": "schematic_component_16",
269
+ "center": {
270
+ "x": 11.620000000000003,
271
+ "y": -8.123910699999996
272
+ },
273
+ "width": 0.9649999999999999,
274
+ "height": 0.6000000000000014,
275
+ "pins": [
276
+ {
277
+ "pinId": "schematic_port_69",
278
+ "x": 11.462500000000002,
279
+ "y": -7.823910699999995
280
+ },
281
+ {
282
+ "pinId": "schematic_port_70",
283
+ "x": 11.462500000000002,
284
+ "y": -8.423910699999997
285
+ }
286
+ ],
287
+ "sectionId": "esp12f_power_and_boot"
288
+ },
289
+ {
290
+ "chipId": "schematic_component_17",
291
+ "center": {
292
+ "x": 11.157500000000002,
293
+ "y": -1.8594553499999984
294
+ },
295
+ "width": 0.9400000000000013,
296
+ "height": 0.7189106999999988,
297
+ "pins": [
298
+ {
299
+ "pinId": "schematic_port_71",
300
+ "x": 10.687500000000002,
301
+ "y": -1.9094553499999982,
302
+ "_facingDirection": "x-"
303
+ },
304
+ {
305
+ "pinId": "schematic_port_72",
306
+ "x": 11.627500000000003,
307
+ "y": -1.9094553499999982,
308
+ "_facingDirection": "x+"
309
+ }
310
+ ],
311
+ "sectionId": "esp12f_power_and_boot"
312
+ },
313
+ {
314
+ "chipId": "schematic_component_18",
315
+ "center": {
316
+ "x": 13.815000000000001,
317
+ "y": -7.171410699999997
318
+ },
319
+ "width": 0.9400000000000013,
320
+ "height": 0.7189106999999986,
321
+ "pins": [
322
+ {
323
+ "pinId": "schematic_port_73",
324
+ "x": 13.345,
325
+ "y": -7.221410699999997,
326
+ "_facingDirection": "x-"
327
+ },
328
+ {
329
+ "pinId": "schematic_port_74",
330
+ "x": 14.285000000000002,
331
+ "y": -7.221410699999997,
332
+ "_facingDirection": "x+"
333
+ }
334
+ ],
335
+ "sectionId": "esp12f_power_and_boot"
336
+ }
337
+ ],
338
+ "directConnections": [],
339
+ "netConnections": [
340
+ {
341
+ "netId": "GND",
342
+ "netLabelWidth": 0.42,
343
+ "netLabelHeight": 0.48,
344
+ "pinIds": [
345
+ "schematic_port_43",
346
+ "schematic_port_58",
347
+ "schematic_port_60",
348
+ "schematic_port_70"
349
+ ]
350
+ },
351
+ {
352
+ "netId": "V3_3",
353
+ "netLabelWidth": 0.42,
354
+ "netLabelHeight": 0.6,
355
+ "pinIds": [
356
+ "schematic_port_42",
357
+ "schematic_port_57",
358
+ "schematic_port_59",
359
+ "schematic_port_61",
360
+ "schematic_port_63",
361
+ "schematic_port_65",
362
+ "schematic_port_67"
363
+ ]
364
+ },
365
+ {
366
+ "netId": "ESP_RST",
367
+ "netLabelWidth": 0.96,
368
+ "pinIds": [
369
+ "schematic_port_35",
370
+ "schematic_port_64",
371
+ "schematic_port_71"
372
+ ]
373
+ },
374
+ {
375
+ "netId": "ESP_EN",
376
+ "netLabelWidth": 0.84,
377
+ "pinIds": [
378
+ "schematic_port_37",
379
+ "schematic_port_62"
380
+ ]
381
+ },
382
+ {
383
+ "netId": "RGB_BLUE_PWM",
384
+ "netLabelWidth": 1.56,
385
+ "pinIds": [
386
+ "schematic_port_39"
387
+ ]
388
+ },
389
+ {
390
+ "netId": "RGB_RED_PWM",
391
+ "netLabelWidth": 1.44,
392
+ "pinIds": [
393
+ "schematic_port_40"
394
+ ]
395
+ },
396
+ {
397
+ "netId": "RGB_GREEN_PWM",
398
+ "netLabelWidth": 1.68,
399
+ "pinIds": [
400
+ "schematic_port_41"
401
+ ]
402
+ },
403
+ {
404
+ "netId": "ESP_GPIO15",
405
+ "netLabelWidth": 1.32,
406
+ "pinIds": [
407
+ "schematic_port_44",
408
+ "schematic_port_69"
409
+ ]
410
+ },
411
+ {
412
+ "netId": "ESP_GPIO2",
413
+ "netLabelWidth": 1.2,
414
+ "pinIds": [
415
+ "schematic_port_45",
416
+ "schematic_port_68"
417
+ ]
418
+ },
419
+ {
420
+ "netId": "ESP_GPIO0",
421
+ "netLabelWidth": 1.2,
422
+ "pinIds": [
423
+ "schematic_port_46",
424
+ "schematic_port_66",
425
+ "schematic_port_73"
426
+ ]
427
+ },
428
+ {
429
+ "netId": "I2C_SDA",
430
+ "netLabelWidth": 0.96,
431
+ "pinIds": [
432
+ "schematic_port_47"
433
+ ]
434
+ },
435
+ {
436
+ "netId": "I2C_SCL",
437
+ "netLabelWidth": 0.96,
438
+ "pinIds": [
439
+ "schematic_port_48"
440
+ ]
441
+ },
442
+ {
443
+ "netId": "ESP_RX",
444
+ "netLabelWidth": 0.84,
445
+ "pinIds": [
446
+ "schematic_port_49"
447
+ ]
448
+ },
449
+ {
450
+ "netId": "ESP_TX",
451
+ "netLabelWidth": 0.84,
452
+ "pinIds": [
453
+ "schematic_port_50"
454
+ ]
455
+ }
456
+ ],
457
+ "textBoxes": [
458
+ {
459
+ "chipId": "schematic_component_9",
460
+ "center": {
461
+ "x": 11.475000000000001,
462
+ "y": -6.348910699999998
463
+ },
464
+ "width": 2.2799999999999994,
465
+ "height": 0.17999999999999972,
466
+ "text": "ESP_12F_ESP8266MOD_"
467
+ },
468
+ {
469
+ "chipId": "schematic_component_9",
470
+ "center": {
471
+ "x": 10.755000000000003,
472
+ "y": -3.703910699999997
473
+ },
474
+ "width": 0.9600000000000009,
475
+ "height": 0.24999999999999956,
476
+ "text": "ESP-12F"
477
+ }
478
+ ],
479
+ "availableNetLabelOrientations": {
480
+ "GND": [
481
+ "y-"
482
+ ],
483
+ "V3_3": [
484
+ "y+"
485
+ ],
486
+ "ESP_EN": [
487
+ "x-",
488
+ "x+"
489
+ ],
490
+ "ESP_RST": [
491
+ "x-",
492
+ "x+"
493
+ ],
494
+ "ESP_GPIO0": [
495
+ "x-",
496
+ "x+"
497
+ ],
498
+ "ESP_GPIO2": [
499
+ "x-",
500
+ "x+"
501
+ ],
502
+ "ESP_GPIO15": [
503
+ "x-",
504
+ "x+"
505
+ ],
506
+ "ESP_RX": [
507
+ "x-",
508
+ "x+"
509
+ ],
510
+ "ESP_TX": [
511
+ "x-",
512
+ "x+"
513
+ ],
514
+ "RGB_RED_PWM": [
515
+ "x-",
516
+ "x+"
517
+ ],
518
+ "RGB_GREEN_PWM": [
519
+ "x-",
520
+ "x+"
521
+ ],
522
+ "RGB_BLUE_PWM": [
523
+ "x-",
524
+ "x+"
525
+ ],
526
+ "I2C_SDA": [
527
+ "x-",
528
+ "x+"
529
+ ],
530
+ "I2C_SCL": [
531
+ "x-",
532
+ "x+"
533
+ ]
534
+ },
535
+ "maxMspPairDistance": 2.4,
536
+ "_hideRatsNet": false
537
+ }
@@ -5,7 +5,8 @@ import type { InputProblem } from "lib/types/InputProblem"
5
5
  import "tests/fixtures/matcher"
6
6
  import inputProblemJson from "./assets/repro-board-589-regulator-section.input.json"
7
7
 
8
- const EXPECTED_ALIGNED_JUNCTION_COUNT = 1
8
+ const EXPECTED_ALIGNED_JUNCTION_COUNT = 2
9
+ const REGULATOR_OUTPUT_TRACE_ID = "schematic_port_31-schematic_port_26"
9
10
 
10
11
  test("board 589 regulator section trace routing", () => {
11
12
  const inputProblem: InputProblem = JSON.parse(
@@ -22,6 +23,9 @@ test("board 589 regulator section trace routing", () => {
22
23
  const labeledTrace = junctionOutput.traces.find((trace) =>
23
24
  v3V3Label.mspConnectionPairIds.includes(trace.mspPairId),
24
25
  )!
26
+ const regulatorOutputTrace = junctionOutput.traces.find(
27
+ (trace) => trace.mspPairId === REGULATOR_OUTPUT_TRACE_ID,
28
+ )!
25
29
 
26
30
  expect(
27
31
  solver.sameNetJunctionAlignmentSolver!.stats.alignedJunctionCount,
@@ -29,5 +33,23 @@ test("board 589 regulator section trace routing", () => {
29
33
  expect(
30
34
  tracePathContainsPoint(labeledTrace.tracePath, v3V3Label.anchorPoint),
31
35
  ).toBe(true)
36
+ expect(
37
+ regulatorOutputTrace.tracePath.some(
38
+ (point, index) =>
39
+ point.y === v3V3Label.anchorPoint.y &&
40
+ regulatorOutputTrace.tracePath[index + 1]?.y ===
41
+ v3V3Label.anchorPoint.y,
42
+ ),
43
+ ).toBe(true)
44
+ for (const trace of [labeledTrace, regulatorOutputTrace]) {
45
+ expect(
46
+ trace.tracePath.every(
47
+ (point, index, path) =>
48
+ index === 0 ||
49
+ point.x === path[index - 1]!.x ||
50
+ point.y === path[index - 1]!.y,
51
+ ),
52
+ ).toBe(true)
53
+ }
32
54
  expect(solver).toMatchSolverSnapshot(import.meta.path)
33
55
  })
@@ -0,0 +1,13 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import type { InputProblem } from "lib/types/InputProblem"
4
+ import "tests/fixtures/matcher"
5
+ import inputProblem from "./assets/repro-board-648-esp12f-section.input.json"
6
+
7
+ test("board 648 ESP-12F power and boot section", () => {
8
+ const solver = new SchematicTracePipelineSolver(inputProblem as InputProblem)
9
+
10
+ solver.solve()
11
+
12
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
13
+ })
@@ -1,4 +1,5 @@
1
1
  import { expect, test } from "bun:test"
2
+ import { MAX_RECORDED_CANDIDATES } from "lib/solvers/AvailableNetOrientationSolver/constants"
2
3
  import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
4
  import type { InputProblem } from "lib/types/InputProblem"
4
5
  import "tests/fixtures/matcher"
@@ -30,5 +31,11 @@ test("core repro161 power section trace routing", () => {
30
31
  for (const railY of horizontalRailYs) {
31
32
  expect(railY).toBeCloseTo(EXPECTED_V3V3_RAIL_Y)
32
33
  }
34
+ expect(
35
+ solver.availableNetOrientationSolver!.stats.candidateEvaluations,
36
+ ).toBeGreaterThan(MAX_RECORDED_CANDIDATES)
37
+ expect(
38
+ solver.availableNetOrientationSolver!.stats.maxRecordedCandidates,
39
+ ).toBe(MAX_RECORDED_CANDIDATES)
33
40
  expect(solver).toMatchSolverSnapshot(import.meta.path)
34
41
  })