@tscircuit/schematic-trace-solver 0.0.89 → 0.0.91
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.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +94 -7
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +116 -5
- package/lib/solvers/SchematicTracePipelineSolver/correctPinsInsideChip.ts +19 -0
- package/lib/testing/PipelineStageDebugRunner.ts +21 -4
- package/package.json +1 -1
- package/site/bug-reports/bug-report-20260707T230831Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260708T053736Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260708T055430Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260708T095725Z.page.tsx +4 -0
- package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +22 -22
- package/tests/bug-reports/bug-report-20260707T020342Z/__snapshots__/bug-report-20260707T020342Z.snap.svg +20 -22
- package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +3 -3
- package/tests/bug-reports/bug-report-20260707T141421Z/__snapshots__/bug-report-20260707T141421Z.snap.svg +70 -72
- package/tests/bug-reports/bug-report-20260707T230831Z/__snapshots__/bug-report-20260707T230831Z.snap.svg +94 -0
- package/tests/bug-reports/bug-report-20260707T230831Z/bug-report-20260707T230831Z.json +347 -0
- package/tests/bug-reports/bug-report-20260707T230831Z/bug-report-20260707T230831Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260708T053736Z/__snapshots__/bug-report-20260708T053736Z.snap.svg +52 -0
- package/tests/bug-reports/bug-report-20260708T053736Z/bug-report-20260708T053736Z.json +59 -0
- package/tests/bug-reports/bug-report-20260708T053736Z/bug-report-20260708T053736Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260708T055430Z/__snapshots__/bug-report-20260708T055430Z.snap.svg +88 -0
- package/tests/bug-reports/bug-report-20260708T055430Z/bug-report-20260708T055430Z.json +263 -0
- package/tests/bug-reports/bug-report-20260708T055430Z/bug-report-20260708T055430Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260708T095725Z/__snapshots__/bug-report-20260708T095725Z.snap.svg +87 -0
- package/tests/bug-reports/bug-report-20260708T095725Z/bug-report-20260708T095725Z.json +277 -0
- package/tests/bug-reports/bug-report-20260708T095725Z/bug-report-20260708T095725Z.test.ts +12 -0
- package/tests/examples/__snapshots__/example42.snap.svg +1 -1
- package/tests/repros/__snapshots__/small-variant-resistor-facing-direction.snap.svg +86 -0
- package/tests/repros/assets/small-variant-resistor-facing-direction.input.json +297 -0
- package/tests/repros/small-variant-resistor-facing-direction.test.ts +35 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chips": [
|
|
3
|
+
{
|
|
4
|
+
"chipId": "schematic_component_0",
|
|
5
|
+
"center": {
|
|
6
|
+
"x": 10,
|
|
7
|
+
"y": 14
|
|
8
|
+
},
|
|
9
|
+
"width": 2.1999999999999993,
|
|
10
|
+
"height": 3.3999999999999986,
|
|
11
|
+
"pins": [
|
|
12
|
+
{
|
|
13
|
+
"pinId": "U_MCU.1",
|
|
14
|
+
"x": 8.9,
|
|
15
|
+
"y": 15.5,
|
|
16
|
+
"_facingDirection": "x-"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"pinId": "U_MCU.2",
|
|
20
|
+
"x": 8.9,
|
|
21
|
+
"y": 15.3,
|
|
22
|
+
"_facingDirection": "x-"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"pinId": "U_MCU.3",
|
|
26
|
+
"x": 8.9,
|
|
27
|
+
"y": 15.1,
|
|
28
|
+
"_facingDirection": "x-"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"pinId": "U_MCU.4",
|
|
32
|
+
"x": 8.9,
|
|
33
|
+
"y": 14.9,
|
|
34
|
+
"_facingDirection": "x-"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"pinId": "U_MCU.5",
|
|
38
|
+
"x": 8.9,
|
|
39
|
+
"y": 14.7,
|
|
40
|
+
"_facingDirection": "x-"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"pinId": "U_MCU.6",
|
|
44
|
+
"x": 8.9,
|
|
45
|
+
"y": 14.5,
|
|
46
|
+
"_facingDirection": "x-"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"pinId": "U_MCU.7",
|
|
50
|
+
"x": 8.9,
|
|
51
|
+
"y": 14.3,
|
|
52
|
+
"_facingDirection": "x-"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"pinId": "U_MCU.8",
|
|
56
|
+
"x": 8.9,
|
|
57
|
+
"y": 14.1,
|
|
58
|
+
"_facingDirection": "x-"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"pinId": "U_MCU.9",
|
|
62
|
+
"x": 8.9,
|
|
63
|
+
"y": 13.9,
|
|
64
|
+
"_facingDirection": "x-"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pinId": "U_MCU.10",
|
|
68
|
+
"x": 8.9,
|
|
69
|
+
"y": 13.700000000000001,
|
|
70
|
+
"_facingDirection": "x-"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"pinId": "U_MCU.11",
|
|
74
|
+
"x": 8.9,
|
|
75
|
+
"y": 13.5,
|
|
76
|
+
"_facingDirection": "x-"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"pinId": "U_MCU.12",
|
|
80
|
+
"x": 8.9,
|
|
81
|
+
"y": 13.3,
|
|
82
|
+
"_facingDirection": "x-"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"pinId": "U_MCU.13",
|
|
86
|
+
"x": 8.9,
|
|
87
|
+
"y": 13.1,
|
|
88
|
+
"_facingDirection": "x-"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"pinId": "U_MCU.14",
|
|
92
|
+
"x": 8.9,
|
|
93
|
+
"y": 12.9,
|
|
94
|
+
"_facingDirection": "x-"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"pinId": "U_MCU.15",
|
|
98
|
+
"x": 8.9,
|
|
99
|
+
"y": 12.7,
|
|
100
|
+
"_facingDirection": "x-"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"pinId": "U_MCU.16",
|
|
104
|
+
"x": 8.9,
|
|
105
|
+
"y": 12.5,
|
|
106
|
+
"_facingDirection": "x-"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"pinId": "U_MCU.17",
|
|
110
|
+
"x": 11.1,
|
|
111
|
+
"y": 12.5,
|
|
112
|
+
"_facingDirection": "x+"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"pinId": "U_MCU.18",
|
|
116
|
+
"x": 11.1,
|
|
117
|
+
"y": 12.7,
|
|
118
|
+
"_facingDirection": "x+"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"pinId": "U_MCU.19",
|
|
122
|
+
"x": 11.1,
|
|
123
|
+
"y": 12.9,
|
|
124
|
+
"_facingDirection": "x+"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"pinId": "U_MCU.20",
|
|
128
|
+
"x": 11.1,
|
|
129
|
+
"y": 13.1,
|
|
130
|
+
"_facingDirection": "x+"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"pinId": "U_MCU.21",
|
|
134
|
+
"x": 11.1,
|
|
135
|
+
"y": 13.3,
|
|
136
|
+
"_facingDirection": "x+"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"pinId": "U_MCU.22",
|
|
140
|
+
"x": 11.1,
|
|
141
|
+
"y": 13.5,
|
|
142
|
+
"_facingDirection": "x+"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"pinId": "U_MCU.23",
|
|
146
|
+
"x": 11.1,
|
|
147
|
+
"y": 13.7,
|
|
148
|
+
"_facingDirection": "x+"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"pinId": "U_MCU.24",
|
|
152
|
+
"x": 11.1,
|
|
153
|
+
"y": 13.9,
|
|
154
|
+
"_facingDirection": "x+"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"pinId": "U_MCU.25",
|
|
158
|
+
"x": 11.1,
|
|
159
|
+
"y": 14.1,
|
|
160
|
+
"_facingDirection": "x+"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"pinId": "U_MCU.26",
|
|
164
|
+
"x": 11.1,
|
|
165
|
+
"y": 14.299999999999999,
|
|
166
|
+
"_facingDirection": "x+"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"pinId": "U_MCU.27",
|
|
170
|
+
"x": 11.1,
|
|
171
|
+
"y": 14.5,
|
|
172
|
+
"_facingDirection": "x+"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"pinId": "U_MCU.28",
|
|
176
|
+
"x": 11.1,
|
|
177
|
+
"y": 14.7,
|
|
178
|
+
"_facingDirection": "x+"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"pinId": "U_MCU.29",
|
|
182
|
+
"x": 11.1,
|
|
183
|
+
"y": 14.9,
|
|
184
|
+
"_facingDirection": "x+"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"pinId": "U_MCU.30",
|
|
188
|
+
"x": 11.1,
|
|
189
|
+
"y": 15.1,
|
|
190
|
+
"_facingDirection": "x+"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"pinId": "U_MCU.31",
|
|
194
|
+
"x": 11.1,
|
|
195
|
+
"y": 15.3,
|
|
196
|
+
"_facingDirection": "x+"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"pinId": "U_MCU.32",
|
|
200
|
+
"x": 11.1,
|
|
201
|
+
"y": 15.5,
|
|
202
|
+
"_facingDirection": "x+"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"chipId": "schematic_component_1",
|
|
208
|
+
"center": {
|
|
209
|
+
"x": 14,
|
|
210
|
+
"y": 10
|
|
211
|
+
},
|
|
212
|
+
"width": 1.6799999999999997,
|
|
213
|
+
"height": 0.6799999999999997,
|
|
214
|
+
"pins": [
|
|
215
|
+
{
|
|
216
|
+
"pinId": "R_FAULT_PULLUP.1",
|
|
217
|
+
"x": 13.7,
|
|
218
|
+
"y": 10,
|
|
219
|
+
"_facingDirection": "x-"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"pinId": "R_FAULT_PULLUP.2",
|
|
223
|
+
"x": 14.3,
|
|
224
|
+
"y": 10,
|
|
225
|
+
"_facingDirection": "x+"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"directConnections": [],
|
|
231
|
+
"netConnections": [
|
|
232
|
+
{
|
|
233
|
+
"netId": "GND",
|
|
234
|
+
"pinIds": [
|
|
235
|
+
"U_MCU.3",
|
|
236
|
+
"U_MCU.5",
|
|
237
|
+
"U_MCU.21"
|
|
238
|
+
],
|
|
239
|
+
"netLabelWidth": 0.42,
|
|
240
|
+
"netLabelHeight": 0.48
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"netId": "VCC_3V3",
|
|
244
|
+
"pinIds": [
|
|
245
|
+
"U_MCU.4",
|
|
246
|
+
"U_MCU.6",
|
|
247
|
+
"U_MCU.18",
|
|
248
|
+
"R_FAULT_PULLUP.1"
|
|
249
|
+
],
|
|
250
|
+
"netLabelWidth": 0.42,
|
|
251
|
+
"netLabelHeight": 0.96
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"netId": "FAULT",
|
|
255
|
+
"pinIds": [
|
|
256
|
+
"U_MCU.32",
|
|
257
|
+
"R_FAULT_PULLUP.2"
|
|
258
|
+
],
|
|
259
|
+
"netLabelWidth": 0.72
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"textBoxes": [
|
|
263
|
+
{
|
|
264
|
+
"chipId": "schematic_component_0",
|
|
265
|
+
"center": {
|
|
266
|
+
"x": 10.080000000000002,
|
|
267
|
+
"y": 12.17
|
|
268
|
+
},
|
|
269
|
+
"width": 1.5600000000000005,
|
|
270
|
+
"height": 0.17999999999999972,
|
|
271
|
+
"text": "ATMEGA328P_AU"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"chipId": "schematic_component_0",
|
|
275
|
+
"center": {
|
|
276
|
+
"x": 9.600000000000001,
|
|
277
|
+
"y": 15.815
|
|
278
|
+
},
|
|
279
|
+
"width": 0.7200000000000006,
|
|
280
|
+
"height": 0.25,
|
|
281
|
+
"text": "U_MCU"
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
"availableNetLabelOrientations": {
|
|
285
|
+
"VCC_3V3": [
|
|
286
|
+
"y+"
|
|
287
|
+
],
|
|
288
|
+
"GND": [
|
|
289
|
+
"y-"
|
|
290
|
+
],
|
|
291
|
+
"FAULT": [
|
|
292
|
+
"x-",
|
|
293
|
+
"x+"
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
"maxMspPairDistance": 2.4
|
|
297
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import inputProblem from "./assets/small-variant-resistor-facing-direction.input.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
// Regression for a small-variant resistor (R_FAULT_PULLUP) whose wide
|
|
7
|
+
// reference-designator text inflates its chip box, so its two ports sit *inside*
|
|
8
|
+
// the box rather than on an edge.
|
|
9
|
+
//
|
|
10
|
+
// The input supplies each port's facing direction (as @tscircuit/core does from
|
|
11
|
+
// the schematic symbol). The solver must snap such inside-pins to the box edge
|
|
12
|
+
// ALONG that facing (correctPinsInsideChips) instead of guessing the nearest
|
|
13
|
+
// edge — which, for a horizontal resistor whose ref text widened the box, is the
|
|
14
|
+
// bottom edge, wrongly making both terminals face "y-" and routing downward.
|
|
15
|
+
test("small-variant resistor with facing directions routes from the sides", () => {
|
|
16
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
17
|
+
|
|
18
|
+
solver.solve()
|
|
19
|
+
|
|
20
|
+
const resistor = solver.inputProblem.chips.find(
|
|
21
|
+
(c) => c.chipId === "schematic_component_1",
|
|
22
|
+
)!
|
|
23
|
+
// Terminals keep their symbol-provided facing instead of being re-detected as
|
|
24
|
+
// facing down, and are snapped to the left/right edges of the inflated box.
|
|
25
|
+
expect(resistor.pins.map((p) => p._facingDirection).sort()).toEqual([
|
|
26
|
+
"x+",
|
|
27
|
+
"x-",
|
|
28
|
+
])
|
|
29
|
+
const left = resistor.pins.find((p) => p._facingDirection === "x-")!
|
|
30
|
+
const right = resistor.pins.find((p) => p._facingDirection === "x+")!
|
|
31
|
+
expect(left.x).toBeCloseTo(resistor.center.x - resistor.width / 2)
|
|
32
|
+
expect(right.x).toBeCloseTo(resistor.center.x + resistor.width / 2)
|
|
33
|
+
|
|
34
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
35
|
+
})
|