@tscircuit/schematic-trace-solver 0.0.57 → 0.0.61

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 (29) hide show
  1. package/dist/index.d.ts +15 -1
  2. package/dist/index.js +367 -136
  3. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +150 -14
  4. package/lib/solvers/AvailableNetOrientationSolver/geometry.ts +1 -1
  5. package/lib/solvers/AvailableNetOrientationSolver/types.ts +1 -1
  6. package/lib/solvers/Example28Solver/reroute.ts +137 -17
  7. package/lib/solvers/Example28Solver/types.ts +1 -0
  8. package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +32 -10
  9. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +17 -5
  10. package/lib/solvers/TraceCleanupSolver/is4PointRectangle.ts +7 -2
  11. package/lib/types/InputProblem.ts +1 -0
  12. package/package.json +1 -1
  13. package/site/examples/example35.page.tsx +4 -0
  14. package/site/examples/example36.page.tsx +4 -0
  15. package/site/examples/example37.page.tsx +4 -0
  16. package/site/examples/example38.page.tsx +4 -0
  17. package/tests/assets/example35.json +127 -0
  18. package/tests/assets/example36.json +124 -0
  19. package/tests/assets/example37.json +173 -0
  20. package/tests/assets/example38.json +32 -0
  21. package/tests/examples/__snapshots__/example04.snap.svg +16 -17
  22. package/tests/examples/__snapshots__/example35.snap.svg +177 -0
  23. package/tests/examples/__snapshots__/example36.snap.svg +160 -0
  24. package/tests/examples/__snapshots__/example37.snap.svg +320 -0
  25. package/tests/examples/__snapshots__/example38.snap.svg +77 -0
  26. package/tests/examples/example35.test.ts +12 -0
  27. package/tests/examples/example36.test.ts +12 -0
  28. package/tests/examples/example37.test.ts +12 -0
  29. package/tests/examples/example38.test.ts +12 -0
@@ -0,0 +1,127 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 0,
7
+ "y": 0
8
+ },
9
+ "width": 1.3,
10
+ "height": 1,
11
+ "pins": [
12
+ {
13
+ "pinId": "U1.1",
14
+ "x": -1.05,
15
+ "y": 0.30000000000000004
16
+ },
17
+ {
18
+ "pinId": "U1.2",
19
+ "x": -1.05,
20
+ "y": 0.10000000000000003
21
+ },
22
+ {
23
+ "pinId": "U1.3",
24
+ "x": -1.05,
25
+ "y": -0.09999999999999998
26
+ },
27
+ {
28
+ "pinId": "U1.4",
29
+ "x": -1.05,
30
+ "y": -0.30000000000000004
31
+ },
32
+ {
33
+ "pinId": "U1.5",
34
+ "x": 1.05,
35
+ "y": -0.30000000000000004
36
+ },
37
+ {
38
+ "pinId": "U1.6",
39
+ "x": 1.05,
40
+ "y": -0.10000000000000003
41
+ },
42
+ {
43
+ "pinId": "U1.7",
44
+ "x": 1.05,
45
+ "y": 0.09999999999999998
46
+ },
47
+ {
48
+ "pinId": "U1.8",
49
+ "x": 1.05,
50
+ "y": 0.30000000000000004
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "chipId": "schematic_component_1",
56
+ "center": {
57
+ "x": 2,
58
+ "y": 2
59
+ },
60
+ "width": 1.3,
61
+ "height": 1,
62
+ "pins": [
63
+ {
64
+ "pinId": "U2.1",
65
+ "x": 0.95,
66
+ "y": 2.3
67
+ },
68
+ {
69
+ "pinId": "U2.2",
70
+ "x": 0.95,
71
+ "y": 2.1
72
+ },
73
+ {
74
+ "pinId": "U2.3",
75
+ "x": 0.95,
76
+ "y": 1.9
77
+ },
78
+ {
79
+ "pinId": "U2.4",
80
+ "x": 0.95,
81
+ "y": 1.7
82
+ },
83
+ {
84
+ "pinId": "U2.5",
85
+ "x": 3.05,
86
+ "y": 1.7
87
+ },
88
+ {
89
+ "pinId": "U2.6",
90
+ "x": 3.05,
91
+ "y": 1.9
92
+ },
93
+ {
94
+ "pinId": "U2.7",
95
+ "x": 3.05,
96
+ "y": 2.1
97
+ },
98
+ {
99
+ "pinId": "U2.8",
100
+ "x": 3.05,
101
+ "y": 2.3
102
+ }
103
+ ]
104
+ }
105
+ ],
106
+ "directConnections": [
107
+ {
108
+ "pinIds": ["U1.7", "U2.7"],
109
+ "netId": "U1.IO3 to U2.IO3"
110
+ },
111
+ {
112
+ "pinIds": ["U1.6", "U2.8"],
113
+ "netId": "U1.CLK to U2.VCC"
114
+ }
115
+ ],
116
+ "netConnections": [
117
+ {
118
+ "netId": "VCC",
119
+ "pinIds": ["U1.5", "U1.8"],
120
+ "netLabelWidth": 0.48
121
+ }
122
+ ],
123
+ "availableNetLabelOrientations": {
124
+ "VCC": ["y+"]
125
+ },
126
+ "maxMspPairDistance": 2.4
127
+ }
@@ -0,0 +1,124 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 0,
7
+ "y": 0
8
+ },
9
+ "width": 1.3,
10
+ "height": 1,
11
+ "pins": [
12
+ {
13
+ "pinId": "U1.1",
14
+ "x": -1.05,
15
+ "y": 0.30000000000000004
16
+ },
17
+ {
18
+ "pinId": "U1.2",
19
+ "x": -1.05,
20
+ "y": 0.10000000000000003
21
+ },
22
+ {
23
+ "pinId": "U1.3",
24
+ "x": -1.05,
25
+ "y": -0.09999999999999998
26
+ },
27
+ {
28
+ "pinId": "U1.4",
29
+ "x": -1.05,
30
+ "y": -0.30000000000000004
31
+ },
32
+ {
33
+ "pinId": "U1.5",
34
+ "x": 1.05,
35
+ "y": -0.30000000000000004
36
+ },
37
+ {
38
+ "pinId": "U1.6",
39
+ "x": 1.05,
40
+ "y": -0.10000000000000003
41
+ },
42
+ {
43
+ "pinId": "U1.7",
44
+ "x": 1.05,
45
+ "y": 0.09999999999999998
46
+ },
47
+ {
48
+ "pinId": "U1.8",
49
+ "x": 1.05,
50
+ "y": 0.30000000000000004
51
+ }
52
+ ]
53
+ },
54
+ {
55
+ "chipId": "schematic_component_1",
56
+ "center": {
57
+ "x": 2,
58
+ "y": 2
59
+ },
60
+ "width": 1.3,
61
+ "height": 1,
62
+ "pins": [
63
+ {
64
+ "pinId": "U2.1",
65
+ "x": 0.95,
66
+ "y": 2.3
67
+ },
68
+ {
69
+ "pinId": "U2.2",
70
+ "x": 0.95,
71
+ "y": 2.1
72
+ },
73
+ {
74
+ "pinId": "U2.3",
75
+ "x": 0.95,
76
+ "y": 1.9
77
+ },
78
+ {
79
+ "pinId": "U2.4",
80
+ "x": 0.95,
81
+ "y": 1.7
82
+ },
83
+ {
84
+ "pinId": "U2.5",
85
+ "x": 3.05,
86
+ "y": 1.7
87
+ },
88
+ {
89
+ "pinId": "U2.6",
90
+ "x": 3.05,
91
+ "y": 1.9
92
+ },
93
+ {
94
+ "pinId": "U2.7",
95
+ "x": 3.05,
96
+ "y": 2.1
97
+ },
98
+ {
99
+ "pinId": "U2.8",
100
+ "x": 3.05,
101
+ "y": 2.3
102
+ }
103
+ ]
104
+ }
105
+ ],
106
+ "directConnections": [
107
+ {
108
+ "pinIds": ["U1.6", "U2.8"],
109
+ "netId": "U1.CLK to U2.VCC",
110
+ "netLabelWidth": 1
111
+ }
112
+ ],
113
+ "netConnections": [
114
+ {
115
+ "netId": "VCC",
116
+ "pinIds": ["U1.5", "U1.8"],
117
+ "netLabelWidth": 0.48
118
+ }
119
+ ],
120
+ "availableNetLabelOrientations": {
121
+ "VCC": ["y+"]
122
+ },
123
+ "maxMspPairDistance": 2.4
124
+ }
@@ -0,0 +1,173 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": -3.69,
7
+ "y": 1.7
8
+ },
9
+ "width": 1.1,
10
+ "height": 0.388910699999999,
11
+ "pins": [
12
+ {
13
+ "pinId": "R1.1",
14
+ "x": -4.24,
15
+ "y": 1.7
16
+ },
17
+ {
18
+ "pinId": "R1.2",
19
+ "x": -3.14,
20
+ "y": 1.7
21
+ }
22
+ ]
23
+ },
24
+ {
25
+ "chipId": "schematic_component_1",
26
+ "center": {
27
+ "x": -6.19,
28
+ "y": 0.3
29
+ },
30
+ "width": 1.1,
31
+ "height": 0.84,
32
+ "pins": [
33
+ {
34
+ "pinId": "C1.1",
35
+ "x": -6.74,
36
+ "y": 0.3
37
+ },
38
+ {
39
+ "pinId": "C1.2",
40
+ "x": -5.640000000000001,
41
+ "y": 0.3
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ "chipId": "schematic_component_2",
47
+ "center": {
48
+ "x": 0,
49
+ "y": 0
50
+ },
51
+ "width": 0.4,
52
+ "height": 1,
53
+ "pins": [
54
+ {
55
+ "pinId": "U1.1",
56
+ "x": -0.6000000000000001,
57
+ "y": 0.30000000000000004
58
+ },
59
+ {
60
+ "pinId": "U1.2",
61
+ "x": -0.6000000000000001,
62
+ "y": 0.10000000000000003
63
+ },
64
+ {
65
+ "pinId": "U1.3",
66
+ "x": -0.6000000000000001,
67
+ "y": -0.09999999999999998
68
+ },
69
+ {
70
+ "pinId": "U1.4",
71
+ "x": -0.6000000000000001,
72
+ "y": -0.30000000000000004
73
+ },
74
+ {
75
+ "pinId": "U1.5",
76
+ "x": 0.6000000000000001,
77
+ "y": -0.30000000000000004
78
+ },
79
+ {
80
+ "pinId": "U1.6",
81
+ "x": 0.6000000000000001,
82
+ "y": -0.10000000000000003
83
+ },
84
+ {
85
+ "pinId": "U1.7",
86
+ "x": 0.6000000000000001,
87
+ "y": 0.09999999999999998
88
+ },
89
+ {
90
+ "pinId": "U1.8",
91
+ "x": 0.6000000000000001,
92
+ "y": 0.30000000000000004
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ "chipId": "schematic_component_3",
98
+ "center": {
99
+ "x": -2.92,
100
+ "y": -0.4
101
+ },
102
+ "width": 0.4,
103
+ "height": 1,
104
+ "pins": [
105
+ {
106
+ "pinId": "U2.1",
107
+ "x": -3.52,
108
+ "y": -0.09999999999999998
109
+ },
110
+ {
111
+ "pinId": "U2.2",
112
+ "x": -3.52,
113
+ "y": -0.3
114
+ },
115
+ {
116
+ "pinId": "U2.3",
117
+ "x": -3.52,
118
+ "y": -0.5
119
+ },
120
+ {
121
+ "pinId": "U2.4",
122
+ "x": -3.52,
123
+ "y": -0.7000000000000001
124
+ },
125
+ {
126
+ "pinId": "U2.5",
127
+ "x": -2.32,
128
+ "y": -0.7000000000000001
129
+ },
130
+ {
131
+ "pinId": "U2.6",
132
+ "x": -2.32,
133
+ "y": -0.5
134
+ },
135
+ {
136
+ "pinId": "U2.7",
137
+ "x": -2.32,
138
+ "y": -0.30000000000000004
139
+ },
140
+ {
141
+ "pinId": "U2.8",
142
+ "x": -2.32,
143
+ "y": -0.09999999999999998
144
+ }
145
+ ]
146
+ }
147
+ ],
148
+ "directConnections": [
149
+ {
150
+ "pinIds": ["C1.1", "R1.1"],
151
+ "netId": ".C1 > .pin1 to R1.pin1"
152
+ },
153
+ {
154
+ "pinIds": ["U1.1", "C1.2"],
155
+ "netId": ".U1 > .pin1 to C1.pin2"
156
+ },
157
+ {
158
+ "pinIds": ["U1.2", "R1.2"],
159
+ "netId": ".U1 > .pin2 to R1.pin2"
160
+ },
161
+ {
162
+ "pinIds": ["U2.1", "U1.3"],
163
+ "netId": ".U2 > .pin1 to U1.pin3"
164
+ },
165
+ {
166
+ "pinIds": ["U2.2", "U1.4"],
167
+ "netId": ".U2 > .pin2 to U1.pin4"
168
+ }
169
+ ],
170
+ "netConnections": [],
171
+ "availableNetLabelOrientations": {},
172
+ "maxMspPairDistance": 2.4
173
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "chips": [
3
+ {
4
+ "chipId": "schematic_component_0",
5
+ "center": {
6
+ "x": 0,
7
+ "y": 0
8
+ },
9
+ "width": 0.2,
10
+ "height": 0.325,
11
+ "pins": [
12
+ {
13
+ "pinId": "TP1.1",
14
+ "x": -1.2246467991473533e-17,
15
+ "y": 0.2
16
+ }
17
+ ]
18
+ }
19
+ ],
20
+ "directConnections": [],
21
+ "netConnections": [
22
+ {
23
+ "netId": "GND",
24
+ "pinIds": ["TP1.1"],
25
+ "netLabelWidth": 0.48
26
+ }
27
+ ],
28
+ "availableNetLabelOrientations": {
29
+ "GND": ["y-"]
30
+ },
31
+ "maxMspPairDistance": 2.4
32
+ }
@@ -2,39 +2,38 @@
2
2
  <rect width="100%" height="100%" fill="white" />
3
3
  <g>
4
4
  <circle data-type="point" data-label="Q1.1
5
- y+" data-x="0.30397715550000004" data-y="0.5800832909999993" cx="402.5477478715151" cy="162.47313199841204" r="3" fill="hsl(315, 100%, 50%, 0.8)" />
5
+ y+" data-x="0.30397715550000004" data-y="0.5800832909999993" cx="386.41696544795997" cy="192.03773223990865" r="3" fill="hsl(315, 100%, 50%, 0.8)" />
6
6
  </g>
7
7
  <g>
8
8
  <circle data-type="point" data-label="Q1.2
9
- y-" data-x="0.31067575550000137" data-y="-0.5800832909999993" cx="404.36681333050564" cy="477.52686800158796" r="3" fill="hsl(316, 100%, 50%, 0.8)" />
9
+ y-" data-x="0.31067575550000137" data-y="-0.5800832909999993" cx="388.6751471623335" cy="583.1443755831586" r="3" fill="hsl(316, 100%, 50%, 0.8)" />
10
10
  </g>
11
11
  <g>
12
12
  <circle data-type="point" data-label="Q1.3
13
- x-" data-x="-0.4467558855000001" data-y="-0.10250625000000019" cx="198.67939570751895" cy="347.8364999709806" r="3" fill="hsl(317, 100%, 50%, 0.8)" />
13
+ x-" data-x="-0.4467558855000001" data-y="-0.10250625000000019" cx="133.33548191977735" cy="422.1471909191105" r="3" fill="hsl(317, 100%, 50%, 0.8)" />
14
14
  </g>
15
15
  <g>
16
- <circle data-type="point" data-label="anchorPoint
17
- orientation: y+" data-x="0.30397715550000004" data-y="0.5800832909999993" cx="402.5477478715151" cy="162.47313199841204" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
16
+ <circle data-type="point" data-label="" data-x="0.30397715550000004" data-y="0.5800832909999993" cx="386.41696544795997" cy="192.03773223990865" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
18
17
  </g>
19
18
  <g>
20
- <circle data-type="point" data-label="anchorPoint
21
- orientation: y-" data-x="0.31067575550000137" data-y="-0.5800832909999993" cx="404.36681333050564" cy="477.52686800158796" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
19
+ <circle data-type="point" data-label="" data-x="0.5606757555000014" data-y="-0.5290832909999993" cx="472.95326924654" cy="565.9516386779806" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
22
20
  </g>
23
21
  <g>
24
- <polyline data-points="0.30397715550000004,0.5800832909999993 0.31067575550000137,-0.5800832909999993" data-type="line" data-label="" points="402.5477478715151,162.47313199841204 404.36681333050564,477.52686800158796" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
22
+ <polyline data-points="0.30397715550000004,0.5800832909999993 0.31067575550000137,-0.5800832909999993" data-type="line" data-label="" points="386.41696544795997,192.03773223990865 388.6751471623335,583.1443755831586" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
25
23
  </g>
26
24
  <g>
27
- <rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="198.67939570751895" y="162.47313199841204" width="242.6412085849621" height="315.0537360031759" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.003682440324999998" />
25
+ <polyline data-points="0.31067575550000137,-0.5800832909999993 0.31067575550000137,-0.6300832909999994 0.5606757555000014,-0.6300832909999994 0.5606757555000014,-0.5290832909999993" data-type="line" data-label="" points="388.6751471623335,583.1443755831586 388.6751471623335,600 472.95326924654,600 472.95326924654,565.9516386779806" fill="none" stroke="purple" stroke-width="1" />
26
+ </g>
27
+ <g>
28
+ <rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="133.33548191977735" y="192.03773223990865" width="301.2139764800545" height="391.10664334324997" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.0029663688964285694" />
28
29
  </g>
29
30
  <g>
30
31
  <rect data-type="rect" data-label="netId: V3_3
31
- globalConnNetId: connectivity_net0
32
- available orientations: y+" data-x="0.30397715550000004" data-y="0.8060832909999993" x="375.3918427720889" y="40" width="54.311810198852356" height="122.20157294741779" fill="#ef444466" stroke="#ef4444" stroke-width="0.003682440324999998" />
32
+ globalConnNetId: connectivity_net0" data-x="0.30397715550000004" data-y="0.8060832909999993" x="352.7057166142773" y="40" width="67.42249766736523" height="151.70061975157182" fill="#ef444466" stroke="#ef4444" stroke-width="0.0029663688964285694" />
33
33
  </g>
34
34
  <g>
35
35
  <rect data-type="rect" data-label="netId: V3_3
36
- globalConnNetId: connectivity_net0
37
- available orientations: y+" data-x="0.31067575550000137" data-y="-0.8060832909999993" x="377.2109082310795" y="477.7984270525822" width="54.3118101988523" height="122.20157294741779" fill="#ef444466" stroke="#ef4444" stroke-width="0.003682440324999998" />
36
+ globalConnNetId: connectivity_net0" data-x="0.5606757555000014" data-y="-0.3040832909999993" x="439.2420204128574" y="414.25101892640873" width="67.42249766736518" height="151.70061975157182" fill="#ef444466" stroke="#ef4444" stroke-width="0.0029663688964285694" />
38
37
  </g>
39
38
  <g id="crosshair" style="display: none">
40
39
  <line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
@@ -64,12 +63,12 @@ available orientations: y+" data-x="0.31067575550000137" data-y="-0.806083290999
64
63
 
65
64
  // Calculate real coordinates using inverse transformation
66
65
  const matrix = {
67
- "a": 271.55905099426167,
66
+ "a": 337.1124883368262,
68
67
  "c": 0,
69
- "e": 320,
68
+ "e": 283.9424701598046,
70
69
  "b": 0,
71
- "d": -271.55905099426167,
72
- "f": 320
70
+ "d": -337.1124883368262,
71
+ "f": 387.59105391153366
73
72
  };
74
73
  // Manually invert and apply the affine transform
75
74
  // Since we only use translate and scale, we can directly compute: