@tscircuit/schematic-trace-solver 0.0.34 → 0.0.36

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 (21) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +51 -11
  3. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +13 -0
  4. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver.ts +11 -1
  5. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/geometry.ts +13 -3
  6. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/solvePortOnlyPin.ts +10 -2
  7. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +19 -0
  8. package/lib/types/InputProblem.ts +1 -0
  9. package/package.json +2 -2
  10. package/site/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2_01-example17.page.tsx +324 -0
  11. package/tests/examples/__snapshots__/example02.snap.svg +5 -8
  12. package/tests/examples/__snapshots__/example04.snap.svg +15 -12
  13. package/tests/examples/__snapshots__/example15.snap.svg +5 -8
  14. package/tests/examples/__snapshots__/example17.snap.svg +13 -16
  15. package/tests/examples/__snapshots__/example20.snap.svg +235 -0
  16. package/tests/examples/example20.test.tsx +190 -0
  17. package/tests/fixtures/matcher.ts +17 -15
  18. package/tests/fixtures/preload.ts +1 -0
  19. package/tests/solvers/SchematicTraceSingleLineSolver/SchematicTraceSingleLineSolver_repro01.test.ts +1 -1
  20. package/tests/solvers/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.test.ts +323 -0
  21. package/tests/solvers/SchematicTraceSingleLineSolver2/__snapshots__/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.snap.svg +160 -0
@@ -0,0 +1,235 @@
1
+ <svg width="640" height="640" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="100%" height="100%" fill="white" />
3
+ <g>
4
+ <circle data-type="point" data-label="U3.8
5
+ x-" data-x="-1.4" data-y="0.42500000000000004" cx="220.08485425212754" cy="293.25559941049465" r="3" fill="hsl(88, 100%, 50%, 0.8)" />
6
+ </g>
7
+ <g>
8
+ <circle data-type="point" data-label="U3.4
9
+ x-" data-x="-1.4" data-y="-0.42500000000000004" cx="220.08485425212754" cy="363.20249325997025" r="3" fill="hsl(84, 100%, 50%, 0.8)" />
10
+ </g>
11
+ <g>
12
+ <circle data-type="point" data-label="U3.1
13
+ x+" data-x="1.4" data-y="0.5" cx="450.49815163863525" cy="287.08381465907036" r="3" fill="hsl(81, 100%, 50%, 0.8)" />
14
+ </g>
15
+ <g>
16
+ <circle data-type="point" data-label="U3.6
17
+ x+" data-x="1.4" data-y="0.30000000000000004" cx="450.49815163863525" cy="303.5419073295352" r="3" fill="hsl(86, 100%, 50%, 0.8)" />
18
+ </g>
19
+ <g>
20
+ <circle data-type="point" data-label="U3.5
21
+ x+" data-x="1.4" data-y="0.10000000000000009" cx="450.49815163863525" cy="320" r="3" fill="hsl(85, 100%, 50%, 0.8)" />
22
+ </g>
23
+ <g>
24
+ <circle data-type="point" data-label="U3.2
25
+ x+" data-x="1.4" data-y="-0.09999999999999998" cx="450.49815163863525" cy="336.45809267046485" r="3" fill="hsl(82, 100%, 50%, 0.8)" />
26
+ </g>
27
+ <g>
28
+ <circle data-type="point" data-label="U3.3
29
+ x+" data-x="1.4" data-y="-0.3" cx="450.49815163863525" cy="352.9161853409297" r="3" fill="hsl(83, 100%, 50%, 0.8)" />
30
+ </g>
31
+ <g>
32
+ <circle data-type="point" data-label="U3.7
33
+ x+" data-x="1.4" data-y="-0.5" cx="450.49815163863525" cy="369.37427801139455" r="3" fill="hsl(87, 100%, 50%, 0.8)" />
34
+ </g>
35
+ <g>
36
+ <circle data-type="point" data-label="C20.1
37
+ y+" data-x="-2.3148566499999994" data-y="0.5512093000000002" cx="144.8008766226725" cy="282.86977763412216" r="3" fill="hsl(140, 100%, 50%, 0.8)" />
38
+ </g>
39
+ <g>
40
+ <circle data-type="point" data-label="C20.2
41
+ y-" data-x="-2.31430995" data-y="-0.5512093000000002" cx="144.84586481898717" cy="373.58831503634275" r="3" fill="hsl(141, 100%, 50%, 0.8)" />
42
+ </g>
43
+ <g>
44
+ <circle data-type="point" data-label="R11.1
45
+ y+" data-x="1.7580660749999977" data-y="2.3025814000000002" cx="479.96357486113317" cy="138.7485560227891" r="3" fill="hsl(125, 100%, 50%, 0.8)" />
46
+ </g>
47
+ <g>
48
+ <circle data-type="point" data-label="R11.2
49
+ y-" data-x="1.757519574999999" data-y="1.2" cx="479.91860312291124" cy="229.4804903124434" r="3" fill="hsl(126, 100%, 50%, 0.8)" />
50
+ </g>
51
+ <g>
52
+ <circle data-type="point" data-label="R12.1
53
+ y-" data-x="-1.7580660749999977" data-y="-3.3025814000000002" cx="190.61943102962965" cy="600" r="3" fill="hsl(6, 100%, 50%, 0.8)" />
54
+ </g>
55
+ <g>
56
+ <circle data-type="point" data-label="R12.2
57
+ y+" data-x="-1.757519574999999" data-y="-2.2" cx="190.66440276785158" cy="509.2680657103457" r="3" fill="hsl(7, 100%, 50%, 0.8)" />
58
+ </g>
59
+ <g>
60
+ <circle data-type="point" data-label="R13.1
61
+ y-" data-x="1.7580660749999977" data-y="-3.3025814000000002" cx="479.96357486113317" cy="600" r="3" fill="hsl(247, 100%, 50%, 0.8)" />
62
+ </g>
63
+ <g>
64
+ <circle data-type="point" data-label="R13.2
65
+ y+" data-x="1.757519574999999" data-y="-2.2" cx="479.91860312291124" cy="509.2680657103457" r="3" fill="hsl(248, 100%, 50%, 0.8)" />
66
+ </g>
67
+ <g>
68
+ <circle data-type="point" data-label="" data-x="-1.8574283249999997" data-y="0.7512093000000004" cx="182.44286543740003" cy="266.4116849636573" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
69
+ </g>
70
+ <g>
71
+ <circle data-type="point" data-label="" data-x="1.5790330374999988" data-y="2.5025814000000004" cx="465.23086324988424" cy="122.29046335232425" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
72
+ </g>
73
+ <g>
74
+ <circle data-type="point" data-label="" data-x="-2.31430995" data-y="-0.7512093000000004" cx="144.84586481898717" cy="390.0464077068076" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
75
+ </g>
76
+ <g>
77
+ <circle data-type="point" data-label="" data-x="1.757519574999999" data-y="0.85" cx="479.91860312291124" cy="258.2821524857569" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
78
+ </g>
79
+ <g>
80
+ <circle data-type="point" data-label="" data-x="1.757519574999999" data-y="-2" cx="479.91860312291124" cy="492.80997303988084" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
81
+ </g>
82
+ <g>
83
+ <polyline data-points="-2.3148566499999994,0.5512093000000002 -1.4,0.42500000000000004" data-type="line" data-label="" points="144.8008766226725,282.86977763412216 220.08485425212754,293.25559941049465" fill="none" stroke="hsl(256, 100%, 50%, 0.8)" stroke-width="1" />
84
+ </g>
85
+ <g>
86
+ <polyline data-points="-2.31430995,-0.5512093000000002 -1.4,-0.42500000000000004" data-type="line" data-label="" points="144.84586481898717,373.58831503634275 220.08485425212754,363.20249325997025" fill="none" stroke="hsl(256, 100%, 50%, 0.8)" stroke-width="1" />
87
+ </g>
88
+ <g>
89
+ <polyline data-points="1.757519574999999,1.2 1.4,0.5" data-type="line" data-label="" points="479.91860312291124,229.4804903124434 450.49815163863525,287.08381465907036" fill="none" stroke="hsl(144, 100%, 50%, 0.8)" stroke-width="1" />
90
+ </g>
91
+ <g>
92
+ <polyline data-points="1.757519574999999,-2.2 -1.757519574999999,-2.2" data-type="line" data-label="" points="479.91860312291124,509.2680657103457 190.66440276785158,509.2680657103457" fill="none" stroke="hsl(144, 100%, 50%, 0.8)" stroke-width="1" />
93
+ </g>
94
+ <g>
95
+ <polyline data-points="-1.4,0.42500000000000004 1.4,-0.3" data-type="line" data-label="" points="220.08485425212754,293.25559941049465 450.49815163863525,352.9161853409297" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
96
+ </g>
97
+ <g>
98
+ <polyline data-points="-1.4,0.42500000000000004 1.4,-0.5" data-type="line" data-label="" points="220.08485425212754,293.25559941049465 450.49815163863525,369.37427801139455" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
99
+ </g>
100
+ <g>
101
+ <polyline data-points="-1.4,0.42500000000000004 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="220.08485425212754,293.25559941049465 144.8008766226725,282.86977763412216" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
102
+ </g>
103
+ <g>
104
+ <polyline data-points="-1.4,0.42500000000000004 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="220.08485425212754,293.25559941049465 479.96357486113317,138.7485560227891" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
105
+ </g>
106
+ <g>
107
+ <polyline data-points="1.4,-0.3 1.4,-0.5" data-type="line" data-label="" points="450.49815163863525,352.9161853409297 450.49815163863525,369.37427801139455" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
108
+ </g>
109
+ <g>
110
+ <polyline data-points="1.4,-0.3 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="450.49815163863525,352.9161853409297 144.8008766226725,282.86977763412216" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
111
+ </g>
112
+ <g>
113
+ <polyline data-points="1.4,-0.3 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="450.49815163863525,352.9161853409297 479.96357486113317,138.7485560227891" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
114
+ </g>
115
+ <g>
116
+ <polyline data-points="1.4,-0.5 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="450.49815163863525,369.37427801139455 144.8008766226725,282.86977763412216" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
117
+ </g>
118
+ <g>
119
+ <polyline data-points="1.4,-0.5 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="450.49815163863525,369.37427801139455 479.96357486113317,138.7485560227891" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
120
+ </g>
121
+ <g>
122
+ <polyline data-points="-2.3148566499999994,0.5512093000000002 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="144.8008766226725,282.86977763412216 479.96357486113317,138.7485560227891" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
123
+ </g>
124
+ <g>
125
+ <polyline data-points="-1.4,-0.42500000000000004 -2.31430995,-0.5512093000000002" data-type="line" data-label="" points="220.08485425212754,363.20249325997025 144.84586481898717,373.58831503634275" fill="none" stroke="hsl(157, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
126
+ </g>
127
+ <g>
128
+ <polyline data-points="1.4,0.5 1.757519574999999,1.2" data-type="line" data-label="" points="450.49815163863525,287.08381465907036 479.91860312291124,229.4804903124434" fill="none" stroke="hsl(304, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
129
+ </g>
130
+ <g>
131
+ <polyline data-points="-1.4,0.42500000000000004 -1.8574283249999997,0.42500000000000004 -1.8574283249999997,0.7512093000000004 -2.3148566499999994,0.7512093000000004 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="220.08485425212754,293.25559941049465 182.44286543740003,293.25559941049465 182.44286543740003,266.4116849636573 144.8008766226725,266.4116849636573 144.8008766226725,282.86977763412216" fill="none" stroke="purple" stroke-width="1" />
132
+ </g>
133
+ <g>
134
+ <polyline data-points="1.4,-0.3 1.5790330374999988,-0.3 1.5790330374999988,2.5025814000000004 1.7580660749999977,2.5025814000000004 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="450.49815163863525,352.9161853409297 465.23086324988424,352.9161853409297 465.23086324988424,122.29046335232425 479.96357486113317,122.29046335232425 479.96357486113317,138.7485560227891" fill="none" stroke="purple" stroke-width="1" />
135
+ </g>
136
+ <g>
137
+ <polyline data-points="1.4,-0.5 1.5999999999999999,-0.5 1.5999999999999999,-0.3 1.4,-0.3" data-type="line" data-label="" points="450.49815163863525,369.37427801139455 466.9562443091001,369.37427801139455 466.9562443091001,352.9161853409297 450.49815163863525,352.9161853409297" fill="none" stroke="purple" stroke-width="1" />
138
+ </g>
139
+ <g>
140
+ <polyline data-points="-2.31430995,-0.5512093000000002 -2.31430995,-0.7512093000000004 -1.857154975,-0.7512093000000004 -1.857154975,-0.42500000000000004 -1.4,-0.42500000000000004" data-type="line" data-label="" points="144.84586481898717,373.58831503634275 144.84586481898717,390.0464077068076 182.46535953555735,390.0464077068076 182.46535953555735,363.20249325997025 220.08485425212754,363.20249325997025" fill="none" stroke="purple" stroke-width="1" />
141
+ </g>
142
+ <g>
143
+ <polyline data-points="1.757519574999999,1.2 1.757519574999999,0.5 1.4,0.5" data-type="line" data-label="" points="479.91860312291124,229.4804903124434 479.91860312291124,287.08381465907036 450.49815163863525,287.08381465907036" fill="none" stroke="purple" stroke-width="1" />
144
+ </g>
145
+ <g>
146
+ <polyline data-points="1.757519574999999,-2.2 1.757519574999999,-2 -1.757519574999999,-2 -1.757519574999999,-2.2" data-type="line" data-label="" points="479.91860312291124,509.2680657103457 479.91860312291124,492.80997303988084 190.66440276785158,492.80997303988084 190.66440276785158,509.2680657103457" fill="none" stroke="purple" stroke-width="1" />
147
+ </g>
148
+ <g>
149
+ <rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="220.08485425212754" y="270.6257219886055" width="230.4132973865077" height="115.2066486932539" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.012152076428571431" />
150
+ </g>
151
+ <g>
152
+ <rect data-type="rect" data-label="schematic_component_1" data-x="-2.3145833" data-y="0" x="123.05068836854284" y="282.86977763412216" width="43.545364704573984" height="90.71853740222059" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.012152076428571431" />
153
+ </g>
154
+ <g>
155
+ <rect data-type="rect" data-label="schematic_component_2" data-x="1.7577928249999983" data-y="1.7512907000000002" x="466.95624430910016" y="138.7485560227891" width="25.96968936584409" height="90.7319342896543" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.012152076428571431" />
156
+ </g>
157
+ <g>
158
+ <rect data-type="rect" data-label="schematic_component_3" data-x="-1.7577928249999983" data-y="-2.7512907" x="177.65707221581857" y="509.2680657103457" width="25.96968936584412" height="90.7319342896543" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.012152076428571431" />
159
+ </g>
160
+ <g>
161
+ <rect data-type="rect" data-label="schematic_component_4" data-x="1.7577928249999983" data-y="-2.7512907" x="466.95624430910016" y="509.2680657103457" width="25.96968936584409" height="90.7319342896543" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.012152076428571431" />
162
+ </g>
163
+ <g>
164
+ <rect data-type="rect" data-label="" data-x="-1.8574283249999997" data-y="1.2512093000000004" x="174.2138191021676" y="184.1212216113331" width="16.45809267046485" height="82.2904633523242" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.012152076428571431" />
165
+ </g>
166
+ <g>
167
+ <rect data-type="rect" data-label="" data-x="1.5790330374999988" data-y="3.0025814000000004" x="457.0018169146518" y="40.00000000000006" width="16.45809267046485" height="82.2904633523242" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.012152076428571431" />
168
+ </g>
169
+ <g>
170
+ <rect data-type="rect" data-label="" data-x="-2.31430995" data-y="-1.1512093000000005" x="136.61681848375474" y="390.0464077068076" width="16.45809267046485" height="65.83237068185935" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.012152076428571431" />
171
+ </g>
172
+ <g>
173
+ <rect data-type="rect" data-label="" data-x="1.807519574999999" data-y="0.85" x="479.91860312291124" y="250.05310615052446" width="8.229046335232397" height="16.45809267046485" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.012152076428571431" />
174
+ </g>
175
+ <g>
176
+ <rect data-type="rect" data-label="" data-x="1.982519574999999" data-y="-2" x="479.91860312291124" y="484.5809267046484" width="37.0307085085459" height="16.458092670464907" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.012152076428571431" />
177
+ </g>
178
+ <g id="crosshair" style="display: none">
179
+ <line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
180
+ <line id="crosshair-v" x1="0" x2="640" stroke="#666" stroke-width="0.5" /><text id="coordinates" font-family="monospace" font-size="12" fill="#666"></text>
181
+ </g>
182
+ <script>
183
+ <![CDATA[
184
+ document.currentScript.parentElement.addEventListener('mousemove', (e) => {
185
+ const svg = e.currentTarget;
186
+ const rect = svg.getBoundingClientRect();
187
+ const x = e.clientX - rect.left;
188
+ const y = e.clientY - rect.top;
189
+ const crosshair = svg.getElementById('crosshair');
190
+ const h = svg.getElementById('crosshair-h');
191
+ const v = svg.getElementById('crosshair-v');
192
+ const coords = svg.getElementById('coordinates');
193
+
194
+ crosshair.style.display = 'block';
195
+ h.setAttribute('x1', '0');
196
+ h.setAttribute('x2', '640');
197
+ h.setAttribute('y1', y);
198
+ h.setAttribute('y2', y);
199
+ v.setAttribute('x1', x);
200
+ v.setAttribute('x2', x);
201
+ v.setAttribute('y1', '0');
202
+ v.setAttribute('y2', '640');
203
+
204
+ // Calculate real coordinates using inverse transformation
205
+ const matrix = {
206
+ "a": 82.2904633523242,
207
+ "c": 0,
208
+ "e": 335.2915029453814,
209
+ "b": 0,
210
+ "d": -82.2904633523242,
211
+ "f": 328.22904633523245
212
+ };
213
+ // Manually invert and apply the affine transform
214
+ // Since we only use translate and scale, we can directly compute:
215
+ // x' = (x - tx) / sx
216
+ // y' = (y - ty) / sy
217
+ const sx = matrix.a;
218
+ const sy = matrix.d;
219
+ const tx = matrix.e;
220
+ const ty = matrix.f;
221
+ const realPoint = {
222
+ x: (x - tx) / sx,
223
+ y: (y - ty) / sy // Flip y back since we used negative scale
224
+ }
225
+
226
+ coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
227
+ coords.setAttribute('x', (x + 5).toString());
228
+ coords.setAttribute('y', (y - 5).toString());
229
+ });
230
+ document.currentScript.parentElement.addEventListener('mouseleave', () => {
231
+ document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
232
+ });
233
+ ]]>
234
+ </script>
235
+ </svg>
@@ -0,0 +1,190 @@
1
+ import { expect } from "bun:test"
2
+ import { test } from "bun:test"
3
+ import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
4
+ import "tests/fixtures/matcher"
5
+
6
+ const inputProblem = {
7
+ chips: [
8
+ {
9
+ chipId: "schematic_component_0",
10
+ center: {
11
+ x: 0,
12
+ y: 0,
13
+ },
14
+ width: 2,
15
+ height: 1.4,
16
+ pins: [
17
+ {
18
+ pinId: "U3.8",
19
+ x: -1.4,
20
+ y: 0.42500000000000004,
21
+ },
22
+ {
23
+ pinId: "U3.4",
24
+ x: -1.4,
25
+ y: -0.42500000000000004,
26
+ },
27
+ {
28
+ pinId: "U3.1",
29
+ x: 1.4,
30
+ y: 0.5,
31
+ },
32
+ {
33
+ pinId: "U3.6",
34
+ x: 1.4,
35
+ y: 0.30000000000000004,
36
+ },
37
+ {
38
+ pinId: "U3.5",
39
+ x: 1.4,
40
+ y: 0.10000000000000009,
41
+ },
42
+ {
43
+ pinId: "U3.2",
44
+ x: 1.4,
45
+ y: -0.09999999999999998,
46
+ },
47
+ {
48
+ pinId: "U3.3",
49
+ x: 1.4,
50
+ y: -0.3,
51
+ },
52
+ {
53
+ pinId: "U3.7",
54
+ x: 1.4,
55
+ y: -0.5,
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ chipId: "schematic_component_1",
61
+ center: {
62
+ x: -2.3145833,
63
+ y: 0,
64
+ },
65
+ width: 0.5291665999999999,
66
+ height: 1.0583333000000001,
67
+ pins: [
68
+ {
69
+ pinId: "C20.1",
70
+ x: -2.3148566499999994,
71
+ y: 0.5512093000000002,
72
+ },
73
+ {
74
+ pinId: "C20.2",
75
+ x: -2.31430995,
76
+ y: -0.5512093000000002,
77
+ },
78
+ ],
79
+ },
80
+ {
81
+ chipId: "schematic_component_2",
82
+ center: {
83
+ x: 1.7577928249999983,
84
+ y: 1.7512907000000002,
85
+ },
86
+ width: 0.3155856499999966,
87
+ height: 1.0583332999999997,
88
+ pins: [
89
+ {
90
+ pinId: "R11.1",
91
+ x: 1.7580660749999977,
92
+ y: 2.3025814000000002,
93
+ },
94
+ {
95
+ pinId: "R11.2",
96
+ x: 1.757519574999999,
97
+ y: 1.2,
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ chipId: "schematic_component_3",
103
+ center: {
104
+ x: -1.7577928249999983,
105
+ y: -2.7512907000000002,
106
+ },
107
+ width: 0.3155856499999966,
108
+ height: 1.0583332999999997,
109
+ pins: [
110
+ {
111
+ pinId: "R12.1",
112
+ x: -1.7580660749999977,
113
+ y: -3.3025814000000002,
114
+ },
115
+ {
116
+ pinId: "R12.2",
117
+ x: -1.757519574999999,
118
+ y: -2.2,
119
+ },
120
+ ],
121
+ },
122
+ {
123
+ chipId: "schematic_component_4",
124
+ center: {
125
+ x: 1.7577928249999983,
126
+ y: -2.7512907000000002,
127
+ },
128
+ width: 0.3155856499999966,
129
+ height: 1.0583332999999997,
130
+ pins: [
131
+ {
132
+ pinId: "R13.1",
133
+ x: 1.7580660749999977,
134
+ y: -3.3025814000000002,
135
+ },
136
+ {
137
+ pinId: "R13.2",
138
+ x: 1.757519574999999,
139
+ y: -2.2,
140
+ },
141
+ ],
142
+ },
143
+ ],
144
+ directConnections: [
145
+ {
146
+ pinIds: ["C20.1", "U3.8"],
147
+ netId: "capacitor.C20 > port.pin1 to .U3 > .VDD",
148
+ },
149
+ {
150
+ pinIds: ["C20.2", "U3.4"],
151
+ netId: "capacitor.C20 > port.pin2 to .U3 > .GND",
152
+ },
153
+ {
154
+ pinIds: ["R11.2", "U3.1"],
155
+ netId: "resistor.R11 > port.pin2 to .U3 > .N_CS",
156
+ },
157
+ {
158
+ pinIds: ["R13.2", "R12.2"],
159
+ netId: "resistor.R11 > port.pin1 to resistor.R12 > port.pin1",
160
+ },
161
+ ],
162
+ netConnections: [
163
+ {
164
+ netId: "V3_3",
165
+ pinIds: ["U3.8", "U3.3", "U3.7", "C20.1", "R11.1"],
166
+ netLabelWidth: 1,
167
+ },
168
+ {
169
+ netId: "GND",
170
+ pinIds: ["U3.4", "C20.2"],
171
+ netLabelWidth: 0.8,
172
+ },
173
+ {
174
+ netId: "FLASH_N_CS",
175
+ pinIds: ["U3.1", "R11.2"],
176
+ netLabelWidth: 0.1,
177
+ },
178
+ ],
179
+ availableNetLabelOrientations: {
180
+ V3_3: ["y+"],
181
+ GND: ["y-"],
182
+ },
183
+ maxMspPairDistance: 5,
184
+ } as InputProblem
185
+
186
+ test("example20", () => {
187
+ const solver = new SchematicTracePipelineSolver(inputProblem)
188
+ solver.solve()
189
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
190
+ })
@@ -25,21 +25,23 @@ async function toMatchSolverSnapshot(
25
25
  return Math.max(acc, elm.step ?? 0)
26
26
  }, 0)
27
27
 
28
- graphicsObject.points = graphicsObject.points?.filter(
29
- (p) => p.step === lastStep,
30
- )
31
- graphicsObject.lines = graphicsObject.lines?.filter(
32
- (l) => l.step === lastStep,
33
- )
34
- graphicsObject.rects = graphicsObject.rects?.filter(
35
- (r) => r.step === lastStep,
36
- )
37
- graphicsObject.circles = graphicsObject.circles?.filter(
38
- (c) => c.step === lastStep,
39
- )
40
- graphicsObject.texts = graphicsObject.texts?.filter(
41
- (t) => t.step === lastStep,
42
- )
28
+ if (lastStep !== 0) {
29
+ graphicsObject.points = graphicsObject.points?.filter(
30
+ (p) => p.step === lastStep,
31
+ )
32
+ graphicsObject.lines = graphicsObject.lines?.filter(
33
+ (l) => l.step === lastStep,
34
+ )
35
+ graphicsObject.rects = graphicsObject.rects?.filter(
36
+ (r) => r.step === lastStep,
37
+ )
38
+ graphicsObject.circles = graphicsObject.circles?.filter(
39
+ (c) => c.step === lastStep,
40
+ )
41
+ graphicsObject.texts = graphicsObject.texts?.filter(
42
+ (t) => t.step === lastStep,
43
+ )
44
+ }
43
45
 
44
46
  const svg = getSvgFromGraphicsObject(graphicsObject, {
45
47
  backgroundColor: "white",
@@ -1 +1,2 @@
1
1
  import "bun-match-svg"
2
+ import "tests/fixtures/matcher"
@@ -2,7 +2,7 @@ import { test, expect } from "bun:test"
2
2
  import input from "./SchematicTraceSingleLineSolver_repro01.json"
3
3
  import { SchematicTraceSingleLineSolver } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/SchematicTraceSingleLineSolver"
4
4
 
5
- test("SchematicTraceSingleLineSolver_repro01", () => {
5
+ test.skip("SchematicTraceSingleLineSolver_repro01", () => {
6
6
  const solver = new SchematicTraceSingleLineSolver(input as any)
7
7
  solver.solve()
8
8