@tscircuit/schematic-trace-solver 0.0.26 → 0.0.28

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 (34) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +114 -4
  3. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver.ts +11 -0
  4. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/SchematicTraceSingleLineSolver.ts +40 -1
  5. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/getRestrictedCenterLines.ts +139 -0
  6. package/package.json +1 -1
  7. package/site/SchematicTracePipelineSolver/SchematicTracePipelineSolver01.page.tsx +143 -0
  8. package/site/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver01.page.tsx +574 -0
  9. package/site/examples/example11.page.tsx +1 -1
  10. package/site/examples/example12.page.tsx +1 -1
  11. package/site/examples/example13.page.tsx +219 -0
  12. package/site/examples/example14.page.tsx +210 -0
  13. package/tests/examples/__snapshots__/example01.snap.svg +4 -4
  14. package/tests/examples/__snapshots__/example02.snap.svg +4 -4
  15. package/tests/examples/__snapshots__/example03.snap.svg +68 -68
  16. package/tests/examples/__snapshots__/example04.snap.svg +12 -12
  17. package/tests/examples/__snapshots__/example05.snap.svg +1 -1
  18. package/tests/examples/__snapshots__/example06.snap.svg +11 -11
  19. package/tests/examples/__snapshots__/example07.snap.svg +48 -48
  20. package/tests/examples/__snapshots__/example08.snap.svg +25 -25
  21. package/tests/examples/__snapshots__/example09.snap.svg +131 -131
  22. package/tests/examples/__snapshots__/example10.snap.svg +26 -26
  23. package/tests/examples/__snapshots__/example11.snap.svg +162 -0
  24. package/tests/examples/__snapshots__/example12.snap.svg +145 -0
  25. package/tests/examples/__snapshots__/example13.snap.svg +322 -0
  26. package/tests/examples/__snapshots__/example14.snap.svg +213 -0
  27. package/tests/examples/__snapshots__/example15.snap.svg +235 -0
  28. package/tests/examples/example11.test.tsx +12 -0
  29. package/tests/examples/example12.test.tsx +12 -0
  30. package/tests/examples/example13.test.tsx +12 -0
  31. package/tests/examples/example14.test.tsx +12 -0
  32. package/tests/examples/example15.test.tsx +187 -0
  33. package/tests/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver01.test.ts +13 -0
  34. package/tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_repro03.test.ts +0 -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="211.29957848579102" cy="266.28437168733643" 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="211.29957848579102" cy="342.38151179694313" 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="461.9725106115543" cy="259.56991814825346" 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="461.9725106115543" cy="277.47512758580797" 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="461.9725106115543" cy="295.38033702336253" 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="461.9725106115543" cy="313.28554646091703" 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="461.9725106115543" cy="331.1907558984716" 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="461.9725106115543" cy="349.0959653360261" 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="129.39607886784347" cy="254.98535194000064" 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="129.44502275784095" cy="353.6805315442789" 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="494.0287509383446" cy="98.19193067205222" 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="493.97982495355666" cy="196.90168511681264" 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="179.24333815900067" 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="179.29226414378866" cy="501.29024555523955" 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="494.0287509383446" 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="493.97982495355666" cy="501.29024555523955" 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="170.34782867681724" cy="237.0801425024461" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
69
+ </g>
70
+ <g>
71
+ <circle data-type="point" data-label="" data-x="1.7580660749999977" data-y="2.5025814000000004" cx="494.0287509383446" cy="80.28672123449769" 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="129.44502275784095" cy="371.58574098183345" 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="493.97982495355666" cy="228.23580163253305" 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="493.97982495355666" cy="483.385036117685" 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="129.39607886784347,254.98535194000064 211.29957848579102,266.28437168733643" 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="129.44502275784095,353.6805315442789 211.29957848579102,342.38151179694313" 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="493.97982495355666,196.90168511681264 461.9725106115543,259.56991814825346" 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="493.97982495355666,501.29024555523955 179.29226414378866,501.29024555523955" 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="211.29957848579102,266.28437168733643 461.9725106115543,331.1907558984716" 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="211.29957848579102,266.28437168733643 461.9725106115543,349.0959653360261" 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="211.29957848579102,266.28437168733643 129.39607886784347,254.98535194000064" 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="211.29957848579102,266.28437168733643 494.0287509383446,98.19193067205222" 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="461.9725106115543,331.1907558984716 461.9725106115543,349.0959653360261" 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="461.9725106115543,331.1907558984716 129.39607886784347,254.98535194000064" 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="461.9725106115543,331.1907558984716 494.0287509383446,98.19193067205222" 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="461.9725106115543,349.0959653360261 129.39607886784347,254.98535194000064" 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="461.9725106115543,349.0959653360261 494.0287509383446,98.19193067205222" 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="129.39607886784347,254.98535194000064 494.0287509383446,98.19193067205222" 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="211.29957848579102,342.38151179694313 129.44502275784095,353.6805315442789" 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="461.9725106115543,259.56991814825346 493.97982495355666,196.90168511681264" 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="211.29957848579102,266.28437168733643 170.34782867681724,266.28437168733643 170.34782867681724,237.0801425024461 129.39607886784347,237.0801425024461 129.39607886784347,254.98535194000064" fill="none" stroke="purple" stroke-width="1" />
132
+ </g>
133
+ <g>
134
+ <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="461.9725106115543,349.0959653360261 479.8777200491088,349.0959653360261 479.8777200491088,331.1907558984716 461.9725106115543,331.1907558984716" fill="none" stroke="purple" stroke-width="1" />
135
+ </g>
136
+ <g>
137
+ <polyline data-points="1.7580660749999977,2.3025814000000002 1.7580660749999977,2.5025814000000004 1.5790330374999988,2.5025814000000004 1.5790330374999988,-0.3 1.4,-0.3" data-type="line" data-label="" points="494.0287509383446,98.19193067205222 494.0287509383446,80.28672123449769 478.0006307749495,80.28672123449769 478.0006307749495,331.1907558984716 461.9725106115543,331.1907558984716" 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="129.44502275784095,353.6805315442789 129.44502275784095,371.58574098183345 170.37230062181598,371.58574098183345 170.37230062181598,342.38151179694313 211.29957848579102,342.38151179694313" 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="493.97982495355666,196.90168511681264 493.97982495355666,259.56991814825346 461.9725106115543,259.56991814825346" 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="493.97982495355666,501.29024555523955 493.97982495355666,483.385036117685 179.29226414378866,483.385036117685 179.29226414378866,501.29024555523955" 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="211.29957848579102" y="241.66470871069896" width="250.67293212576328" height="125.33646606288164" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.011169933571428573" />
150
+ </g>
151
+ <g>
152
+ <rect data-type="rect" data-label="schematic_component_1" data-x="-2.3145833" data-y="0" x="105.73345381194562" y="254.98535194000064" width="47.37419400179317" height="98.69517960427825" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.011169933571428573" />
153
+ </g>
154
+ <g>
155
+ <rect data-type="rect" data-label="schematic_component_2" data-x="1.7577928249999983" data-y="1.7512907000000002" x="479.87772004910886" y="98.19193067205222" width="28.25313579368361" height="98.70975444476042" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.011169933571428573" />
156
+ </g>
157
+ <g>
158
+ <rect data-type="rect" data-label="schematic_component_3" data-x="-1.7577928249999983" data-y="-2.7512907" x="165.14123325455287" y="501.29024555523955" width="28.253135793683583" height="98.70975444476045" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.011169933571428573" />
159
+ </g>
160
+ <g>
161
+ <rect data-type="rect" data-label="schematic_component_4" data-x="1.7577928249999983" data-y="-2.7512907" x="479.87772004910886" y="501.29024555523955" width="28.25313579368361" height="98.70975444476045" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.011169933571428573" />
162
+ </g>
163
+ <g>
164
+ <rect data-type="rect" data-label="" data-x="-1.8574283249999997" data-y="0.9762093000000004" x="161.39522395803996" y="196.79342126794842" width="17.905209437554532" height="40.28672123449769" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.011169933571428573" />
165
+ </g>
166
+ <g>
167
+ <rect data-type="rect" data-label="" data-x="1.7580660749999977" data-y="2.7275814000000005" x="485.07614621956736" y="40" width="17.90520943755456" height="40.28672123449769" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.011169933571428573" />
168
+ </g>
169
+ <g>
170
+ <rect data-type="rect" data-label="" data-x="-2.31430995" data-y="-0.9762093000000004" x="120.4924180390637" y="371.58574098183345" width="17.905209437554532" height="40.28672123449769" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.011169933571428573" />
171
+ </g>
172
+ <g>
173
+ <rect data-type="rect" data-label="" data-x="1.982519574999999" data-y="0.85" x="493.97982495355666" y="219.2831969137558" width="40.28672123449769" height="17.905209437554532" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.011169933571428573" />
174
+ </g>
175
+ <g>
176
+ <rect data-type="rect" data-label="" data-x="1.982519574999999" data-y="-2" x="493.97982495355666" y="474.43243139890774" width="40.28672123449769" height="17.90520943755456" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.011169933571428573" />
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": 89.52604718777262,
207
+ "c": 0,
208
+ "e": 336.63604454867266,
209
+ "b": 0,
210
+ "d": -89.52604718777262,
211
+ "f": 304.3329417421398
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,12 @@
1
+ import { test, expect } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import { inputProblem } from "site/examples/example11.page"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("example11", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem)
8
+
9
+ solver.solve()
10
+
11
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
12
+ })
@@ -0,0 +1,12 @@
1
+ import { test, expect } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import { inputProblem } from "site/examples/example12.page"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("example12", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem)
8
+
9
+ solver.solve()
10
+
11
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
12
+ })
@@ -0,0 +1,12 @@
1
+ import { test, expect } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import { inputProblem } from "site/examples/example13.page"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("example13", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem)
8
+
9
+ solver.solve()
10
+
11
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
12
+ })
@@ -0,0 +1,12 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import { inputProblem } from "site/examples/example14.page"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test.skip("example14 - should fail with net label placement collision error", () => {
7
+ const solver = new SchematicTracePipelineSolver(inputProblem)
8
+
9
+ solver.solve()
10
+
11
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
12
+ })
@@ -0,0 +1,187 @@
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
+ },
167
+ {
168
+ netId: "GND",
169
+ pinIds: ["U3.4", "C20.2"],
170
+ },
171
+ {
172
+ netId: "FLASH_N_CS",
173
+ pinIds: ["U3.1", "R11.2"],
174
+ },
175
+ ],
176
+ availableNetLabelOrientations: {
177
+ V3_3: ["y+"],
178
+ GND: ["y-"],
179
+ },
180
+ maxMspPairDistance: 5,
181
+ } as InputProblem
182
+
183
+ test("example14", () => {
184
+ const solver = new SchematicTracePipelineSolver(inputProblem)
185
+ solver.solve()
186
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
187
+ })
@@ -0,0 +1,13 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SingleNetLabelPlacementSolver } from "lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver"
3
+ import { input } from "site/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver01.page"
4
+ import "tests/fixtures/matcher"
5
+
6
+ test("SingleNetLabelPlacementSolver01 issue reproduction (should pass)", () => {
7
+ const solver = new SingleNetLabelPlacementSolver(input as any)
8
+
9
+ solver.solve()
10
+
11
+ // TODO: Fix the test
12
+ // expect(solver.solved).toBe(true)
13
+ })