@tscircuit/schematic-trace-solver 0.0.33 → 0.0.35

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.js +36 -4
  2. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +25 -4
  3. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +19 -0
  4. package/package.json +2 -2
  5. package/site/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2_01-example17.page.tsx +324 -0
  6. package/site/examples/example15-rp2040-caps.page.tsx +623 -0
  7. package/site/examples/example16-core-repro51.page.tsx +107 -0
  8. package/site/examples/example17-straight-line-trace.page.tsx +165 -0
  9. package/site/examples/example18.page.tsx +181 -0
  10. package/site/examples/example19.page.tsx +169 -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 +797 -71
  14. package/tests/examples/__snapshots__/example16.snap.svg +40 -86
  15. package/tests/examples/__snapshots__/example17.snap.svg +187 -0
  16. package/tests/examples/__snapshots__/example18.snap.svg +235 -0
  17. package/tests/examples/__snapshots__/example19.snap.svg +195 -0
  18. package/tests/examples/example15.test.tsx +524 -82
  19. package/tests/examples/example16.test.tsx +56 -118
  20. package/tests/examples/example17.test.tsx +171 -0
  21. package/tests/examples/example18.test.tsx +187 -0
  22. package/tests/examples/example19.test.tsx +175 -0
  23. package/tests/fixtures/matcher.ts +17 -15
  24. package/tests/fixtures/preload.ts +1 -0
  25. package/tests/solvers/SchematicTraceSingleLineSolver/SchematicTraceSingleLineSolver_repro01.test.ts +1 -1
  26. package/tests/solvers/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.test.ts +323 -0
  27. package/tests/solvers/SchematicTraceSingleLineSolver2/__snapshots__/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.snap.svg +160 -0
@@ -0,0 +1,160 @@
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="U1.1
5
+ x-" data-x="-1.15" data-y="0.30000000000000004" cx="167.5392670157068" cy="351.8848167539267" r="3" fill="hsl(319, 100%, 50%, 0.8)" />
6
+ </g>
7
+ <g>
8
+ <circle data-type="point" data-label="U1.2
9
+ x-" data-x="-1.15" data-y="0.10000000000000003" cx="167.5392670157068" cy="366.5445026178011" r="3" fill="hsl(320, 100%, 50%, 0.8)" />
10
+ </g>
11
+ <g>
12
+ <circle data-type="point" data-label="U1.3
13
+ x-" data-x="-1.15" data-y="-0.09999999999999998" cx="167.5392670157068" cy="381.2041884816754" r="3" fill="hsl(321, 100%, 50%, 0.8)" />
14
+ </g>
15
+ <g>
16
+ <circle data-type="point" data-label="U1.4
17
+ x-" data-x="-1.15" data-y="-0.30000000000000004" cx="167.5392670157068" cy="395.86387434554973" r="3" fill="hsl(322, 100%, 50%, 0.8)" />
18
+ </g>
19
+ <g>
20
+ <circle data-type="point" data-label="U1.5
21
+ x+" data-x="1.15" data-y="-0.30000000000000004" cx="336.1256544502618" cy="395.86387434554973" r="3" fill="hsl(323, 100%, 50%, 0.8)" />
22
+ </g>
23
+ <g>
24
+ <circle data-type="point" data-label="U1.6
25
+ x+" data-x="1.15" data-y="-0.10000000000000003" cx="336.1256544502618" cy="381.2041884816754" r="3" fill="hsl(324, 100%, 50%, 0.8)" />
26
+ </g>
27
+ <g>
28
+ <circle data-type="point" data-label="U1.7
29
+ x+" data-x="1.15" data-y="0.09999999999999998" cx="336.1256544502618" cy="366.5445026178011" r="3" fill="hsl(325, 100%, 50%, 0.8)" />
30
+ </g>
31
+ <g>
32
+ <circle data-type="point" data-label="U1.8
33
+ x+" data-x="1.15" data-y="0.30000000000000004" cx="336.1256544502618" cy="351.8848167539267" r="3" fill="hsl(326, 100%, 50%, 0.8)" />
34
+ </g>
35
+ <g>
36
+ <circle data-type="point" data-label="D1.1
37
+ y-" data-x="-1.1500000000000004" data-y="1.15" cx="167.5392670157068" cy="289.58115183246076" r="3" fill="hsl(32, 100%, 50%, 0.8)" />
38
+ </g>
39
+ <g>
40
+ <circle data-type="point" data-label="D1.2
41
+ y+" data-x="-1.1500000000000004" data-y="2.1900000000000004" cx="167.5392670157068" cy="213.35078534031413" r="3" fill="hsl(33, 100%, 50%, 0.8)" />
42
+ </g>
43
+ <g>
44
+ <circle data-type="point" data-label="D2.1
45
+ x+" data-x="-1.85" data-y="0.10000000000000002" cx="116.2303664921466" cy="366.5445026178011" r="3" fill="hsl(273, 100%, 50%, 0.8)" />
46
+ </g>
47
+ <g>
48
+ <circle data-type="point" data-label="D2.2
49
+ x-" data-x="-2.89" data-y="0.10000000000000016" cx="40" cy="366.544502617801" r="3" fill="hsl(274, 100%, 50%, 0.8)" />
50
+ </g>
51
+ <g>
52
+ <circle data-type="point" data-label="C1.1
53
+ x-" data-x="1.8499999999999996" data-y="-0.3000000000000007" cx="387.43455497382195" cy="395.8638743455498" r="3" fill="hsl(121, 100%, 50%, 0.8)" />
54
+ </g>
55
+ <g>
56
+ <circle data-type="point" data-label="C1.2
57
+ x+" data-x="2.95" data-y="-0.3000000000000007" cx="468.0628272251309" cy="395.8638743455498" r="3" fill="hsl(122, 100%, 50%, 0.8)" />
58
+ </g>
59
+ <g>
60
+ <circle data-type="point" data-label="C2.1
61
+ x-" data-x="3.6500000000000004" data-y="-0.3000000000000007" cx="519.3717277486911" cy="395.8638743455498" r="3" fill="hsl(2, 100%, 50%, 0.8)" />
62
+ </g>
63
+ <g>
64
+ <circle data-type="point" data-label="C2.2
65
+ x+" data-x="4.75" data-y="-0.3000000000000007" cx="600" cy="395.8638743455498" r="3" fill="hsl(3, 100%, 50%, 0.8)" />
66
+ </g>
67
+ <g>
68
+ <polyline data-points="1.15,-0.30000000000000004 1.8499999999999996,-0.3000000000000007" data-type="line" data-label="" points="336.1256544502618,395.86387434554973 387.43455497382195,395.8638743455498" fill="none" stroke="hsl(160, 100%, 50%, 0.1)" stroke-width="1" />
69
+ </g>
70
+ <g>
71
+ <polyline data-points="2.95,-0.3000000000000007 3.6500000000000004,-0.3000000000000007" data-type="line" data-label="" points="468.0628272251309,395.8638743455498 519.3717277486911,395.8638743455498" fill="none" stroke="hsl(48, 100%, 50%, 0.1)" stroke-width="1" />
72
+ </g>
73
+ <g>
74
+ <polyline data-points="-1.15,0.30000000000000004 -1.1500000000000004,1.15" data-type="line" data-label="" points="167.5392670157068,351.8848167539267 167.5392670157068,289.58115183246076" fill="none" stroke="hsl(280, 100%, 50%, 0.1)" stroke-width="1" />
75
+ </g>
76
+ <g>
77
+ <polyline data-points="-1.15,0.10000000000000003 -1.85,0.10000000000000002" data-type="line" data-label="" points="167.5392670157068,366.5445026178011 116.2303664921466,366.5445026178011" fill="none" stroke="hsl(48, 100%, 50%, 0.1)" stroke-width="1" />
78
+ </g>
79
+ <g>
80
+ <polyline data-points="-1.15,0.30000000000000004 -1.3499999999999999,0.30000000000000004 -1.3499999999999999,0.7250000000000001 -1.1500000000000004,0.7250000000000001 -1.1500000000000004,1.15" data-type="line" data-label="" points="167.5392670157068,351.8848167539267 152.87958115183247,351.8848167539267 152.87958115183247,320.73298429319374 167.5392670157068,320.73298429319374 167.5392670157068,289.58115183246076" fill="none" stroke="red" stroke-width="1" stroke-dasharray="4 4" />
81
+ </g>
82
+ <g>
83
+ <polyline data-points="-1.15,0.30000000000000004 -1.1500000000000004,1.15" data-type="line" data-label="" points="167.5392670157068,351.8848167539267 167.5392670157068,289.58115183246076" fill="none" stroke="blue" stroke-width="1" stroke-dasharray="5 5" />
84
+ </g>
85
+ <g>
86
+ <polyline data-points="-1.15,0.30000000000000004 -1.3499999999999999,0.30000000000000004 -1.3499999999999999,0.7250000000000001 -1.1500000000000004,0.7250000000000001 -1.1500000000000004,1.15" data-type="line" data-label="" points="167.5392670157068,351.8848167539267 152.87958115183247,351.8848167539267 152.87958115183247,320.73298429319374 167.5392670157068,320.73298429319374 167.5392670157068,289.58115183246076" fill="none" stroke="green" stroke-width="1" />
87
+ </g>
88
+ <g>
89
+ <rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="167.5392670157068" y="337.22513089005236" width="168.58638743455498" height="73.29842931937173" fill="hsl(24, 100%, 50%, 0.1)" stroke="black" stroke-width="0.013642857142857144" />
90
+ </g>
91
+ <g>
92
+ <rect data-type="rect" data-label="schematic_component_1" data-x="-1.1500000000000004" data-y="1.6700000000000002" x="129.42408376963348" y="213.35078534031413" width="76.2303664921466" height="76.23036649214663" fill="hsl(24, 100%, 50%, 0.1)" stroke="black" stroke-width="0.013642857142857144" />
93
+ </g>
94
+ <g>
95
+ <rect data-type="rect" data-label="schematic_component_2" data-x="-2.37" data-y="0.10000000000000009" x="40" y="346.75392670157066" width="76.2303664921466" height="39.58115183246076" fill="hsl(24, 100%, 50%, 0.1)" stroke="black" stroke-width="0.013642857142857144" />
96
+ </g>
97
+ <g>
98
+ <rect data-type="rect" data-label="schematic_component_3" data-x="2.4" data-y="-0.3000000000000007" x="387.43455497382195" y="365.07853403141365" width="80.62827225130894" height="61.57068062827227" fill="hsl(24, 100%, 50%, 0.1)" stroke="black" stroke-width="0.013642857142857144" />
99
+ </g>
100
+ <g>
101
+ <rect data-type="rect" data-label="schematic_component_4" data-x="4.2" data-y="-0.3000000000000007" x="519.3717277486911" y="365.07853403141365" width="80.62827225130889" height="61.57068062827227" fill="hsl(24, 100%, 50%, 0.1)" stroke="black" stroke-width="0.013642857142857144" />
102
+ </g>
103
+ <g id="crosshair" style="display: none">
104
+ <line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
105
+ <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>
106
+ </g>
107
+ <script>
108
+ <![CDATA[
109
+ document.currentScript.parentElement.addEventListener('mousemove', (e) => {
110
+ const svg = e.currentTarget;
111
+ const rect = svg.getBoundingClientRect();
112
+ const x = e.clientX - rect.left;
113
+ const y = e.clientY - rect.top;
114
+ const crosshair = svg.getElementById('crosshair');
115
+ const h = svg.getElementById('crosshair-h');
116
+ const v = svg.getElementById('crosshair-v');
117
+ const coords = svg.getElementById('coordinates');
118
+
119
+ crosshair.style.display = 'block';
120
+ h.setAttribute('x1', '0');
121
+ h.setAttribute('x2', '640');
122
+ h.setAttribute('y1', y);
123
+ h.setAttribute('y2', y);
124
+ v.setAttribute('x1', x);
125
+ v.setAttribute('x2', x);
126
+ v.setAttribute('y1', '0');
127
+ v.setAttribute('y2', '640');
128
+
129
+ // Calculate real coordinates using inverse transformation
130
+ const matrix = {
131
+ "a": 73.29842931937172,
132
+ "c": 0,
133
+ "e": 251.8324607329843,
134
+ "b": 0,
135
+ "d": -73.29842931937172,
136
+ "f": 373.8743455497382
137
+ };
138
+ // Manually invert and apply the affine transform
139
+ // Since we only use translate and scale, we can directly compute:
140
+ // x' = (x - tx) / sx
141
+ // y' = (y - ty) / sy
142
+ const sx = matrix.a;
143
+ const sy = matrix.d;
144
+ const tx = matrix.e;
145
+ const ty = matrix.f;
146
+ const realPoint = {
147
+ x: (x - tx) / sx,
148
+ y: (y - ty) / sy // Flip y back since we used negative scale
149
+ }
150
+
151
+ coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
152
+ coords.setAttribute('x', (x + 5).toString());
153
+ coords.setAttribute('y', (y - 5).toString());
154
+ });
155
+ document.currentScript.parentElement.addEventListener('mouseleave', () => {
156
+ document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
157
+ });
158
+ ]]>
159
+ </script>
160
+ </svg>