@tscircuit/schematic-trace-solver 0.0.61 → 0.0.62
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 +65 -5
- package/dist/index.js +344 -0
- package/lib/solvers/NetLabelNetLabelCollisionSolver/NetLabelNetLabelCollisionSolver.ts +441 -0
- package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +15 -0
- package/package.json +1 -1
- package/site/examples/example39.page.tsx +4 -0
- package/site/examples/example40.page.tsx +4 -0
- package/site/examples/example41.page.tsx +4 -0
- package/tests/assets/example39.json +71 -0
- package/tests/assets/example40.json +157 -0
- package/tests/assets/example41.json +81 -0
- package/tests/examples/__snapshots__/example39.snap.svg +107 -0
- package/tests/examples/__snapshots__/example40.snap.svg +231 -0
- package/tests/examples/__snapshots__/example41.snap.svg +119 -0
- package/tests/examples/example39.test.ts +12 -0
- package/tests/examples/example40.test.ts +12 -0
- package/tests/examples/example41.test.ts +12 -0
|
@@ -0,0 +1,119 @@
|
|
|
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.24
|
|
5
|
+
x-" data-x="-7.65" data-y="-0.22999999999999998" cx="325.9574468085108" cy="308.0851063829787" r="3" fill="hsl(74, 100%, 50%, 0.8)" />
|
|
6
|
+
</g>
|
|
7
|
+
<g>
|
|
8
|
+
<circle data-type="point" data-label="U3.25
|
|
9
|
+
x-" data-x="-7.65" data-y="-0.43000000000000016" cx="325.9574468085108" cy="331.9148936170213" r="3" fill="hsl(75, 100%, 50%, 0.8)" />
|
|
10
|
+
</g>
|
|
11
|
+
<g>
|
|
12
|
+
<circle data-type="point" data-label="U3.26
|
|
13
|
+
x-" data-x="-7.65" data-y="-0.6300000000000001" cx="325.9574468085108" cy="355.74468085106383" r="3" fill="hsl(76, 100%, 50%, 0.8)" />
|
|
14
|
+
</g>
|
|
15
|
+
<g>
|
|
16
|
+
<circle data-type="point" data-label="R5.1
|
|
17
|
+
x-" data-x="-10.05" data-y="-0.4299999999999997" cx="40.00000000000023" cy="331.9148936170212" r="3" fill="hsl(110, 100%, 50%, 0.8)" />
|
|
18
|
+
</g>
|
|
19
|
+
<g>
|
|
20
|
+
<circle data-type="point" data-label="R5.2
|
|
21
|
+
x+" data-x="-8.95" data-y="-0.4299999999999997" cx="171.06382978723423" cy="331.9148936170212" r="3" fill="hsl(111, 100%, 50%, 0.8)" />
|
|
22
|
+
</g>
|
|
23
|
+
<g>
|
|
24
|
+
<circle data-type="point" data-label="anchorPoint
|
|
25
|
+
orientation: x-" data-x="-7.65" data-y="-0.22999999999999998" cx="325.9574468085108" cy="308.0851063829787" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
26
|
+
</g>
|
|
27
|
+
<g>
|
|
28
|
+
<circle data-type="point" data-label="anchorPoint
|
|
29
|
+
orientation: y+" data-x="-8.549999999999999" data-y="-0.4299999999999998" cx="218.72340425531945" cy="331.9148936170212" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
30
|
+
</g>
|
|
31
|
+
<g>
|
|
32
|
+
<circle data-type="point" data-label="anchorPoint
|
|
33
|
+
orientation: x-" data-x="-7.65" data-y="-0.6300000000000001" cx="325.9574468085108" cy="355.74468085106383" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
34
|
+
</g>
|
|
35
|
+
<g>
|
|
36
|
+
<polyline data-points="-7.65,-0.43000000000000016 -8.95,-0.4299999999999997" data-type="line" data-label="" points="325.9574468085108,331.9148936170213 171.06382978723423,331.9148936170212" fill="none" stroke="hsl(80, 100%, 50%, 0.8)" stroke-width="1" />
|
|
37
|
+
</g>
|
|
38
|
+
<g>
|
|
39
|
+
<polyline data-points="-7.65,-0.43000000000000016 -8.95,-0.4299999999999997" data-type="line" data-label="" points="325.9574468085108,331.9148936170213 171.06382978723423,331.9148936170212" fill="none" stroke="hsl(88, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
40
|
+
</g>
|
|
41
|
+
<g>
|
|
42
|
+
<polyline data-points="-7.65,-0.43000000000000016 -8.95,-0.4299999999999997" data-type="line" data-label="" points="325.9574468085108,331.9148936170213 171.06382978723423,331.9148936170212" fill="none" stroke="purple" stroke-width="1" />
|
|
43
|
+
</g>
|
|
44
|
+
<g>
|
|
45
|
+
<rect data-type="rect" data-label="schematic_component_0" data-x="-6.5" data-y="-0.33" x="325.9574468085108" y="230.63829787234044" width="274.04255319148933" height="178.7234042553191" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.008392857142857145" />
|
|
46
|
+
</g>
|
|
47
|
+
<g>
|
|
48
|
+
<rect data-type="rect" data-label="schematic_component_4" data-x="-9.5" data-y="-0.4299999999999997" x="40.00000000000023" y="308.7457455319149" width="131.063829787234" height="46.33829617021263" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.008392857142857145" />
|
|
49
|
+
</g>
|
|
50
|
+
<g>
|
|
51
|
+
<rect data-type="rect" data-label="netId: SWCLK
|
|
52
|
+
globalConnNetId: connectivity_net1" data-x="-8.011" data-y="-0.22999999999999998" x="240.0510638297876" y="296.17021276595744" width="85.78723404255311" height="23.829787234042556" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.008392857142857145" />
|
|
53
|
+
</g>
|
|
54
|
+
<g>
|
|
55
|
+
<rect data-type="rect" data-label="netId: SWD
|
|
56
|
+
globalConnNetId: connectivity_net0" data-x="-8.549999999999999" data-y="-0.18989999999999985" x="206.80851063829823" y="274.7114893617021" width="23.829787234042442" height="57.19148936170211" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.008392857142857145" />
|
|
57
|
+
</g>
|
|
58
|
+
<g>
|
|
59
|
+
<rect data-type="rect" data-label="netId: CLK
|
|
60
|
+
globalConnNetId: connectivity_net2" data-x="-8.011" data-y="-0.6300000000000001" x="240.0510638297876" y="343.82978723404256" width="85.78723404255311" height="23.829787234042556" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.008392857142857145" />
|
|
61
|
+
</g>
|
|
62
|
+
<g id="crosshair" style="display: none">
|
|
63
|
+
<line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
|
|
64
|
+
<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>
|
|
65
|
+
</g>
|
|
66
|
+
<script>
|
|
67
|
+
<![CDATA[
|
|
68
|
+
document.currentScript.parentElement.addEventListener('mousemove', (e) => {
|
|
69
|
+
const svg = e.currentTarget;
|
|
70
|
+
const rect = svg.getBoundingClientRect();
|
|
71
|
+
const x = e.clientX - rect.left;
|
|
72
|
+
const y = e.clientY - rect.top;
|
|
73
|
+
const crosshair = svg.getElementById('crosshair');
|
|
74
|
+
const h = svg.getElementById('crosshair-h');
|
|
75
|
+
const v = svg.getElementById('crosshair-v');
|
|
76
|
+
const coords = svg.getElementById('coordinates');
|
|
77
|
+
|
|
78
|
+
crosshair.style.display = 'block';
|
|
79
|
+
h.setAttribute('x1', '0');
|
|
80
|
+
h.setAttribute('x2', '640');
|
|
81
|
+
h.setAttribute('y1', y);
|
|
82
|
+
h.setAttribute('y2', y);
|
|
83
|
+
v.setAttribute('x1', x);
|
|
84
|
+
v.setAttribute('x2', x);
|
|
85
|
+
v.setAttribute('y1', '0');
|
|
86
|
+
v.setAttribute('y2', '640');
|
|
87
|
+
|
|
88
|
+
// Calculate real coordinates using inverse transformation
|
|
89
|
+
const matrix = {
|
|
90
|
+
"a": 119.14893617021274,
|
|
91
|
+
"c": 0,
|
|
92
|
+
"e": 1237.4468085106382,
|
|
93
|
+
"b": 0,
|
|
94
|
+
"d": -119.14893617021274,
|
|
95
|
+
"f": 280.6808510638298
|
|
96
|
+
};
|
|
97
|
+
// Manually invert and apply the affine transform
|
|
98
|
+
// Since we only use translate and scale, we can directly compute:
|
|
99
|
+
// x' = (x - tx) / sx
|
|
100
|
+
// y' = (y - ty) / sy
|
|
101
|
+
const sx = matrix.a;
|
|
102
|
+
const sy = matrix.d;
|
|
103
|
+
const tx = matrix.e;
|
|
104
|
+
const ty = matrix.f;
|
|
105
|
+
const realPoint = {
|
|
106
|
+
x: (x - tx) / sx,
|
|
107
|
+
y: (y - ty) / sy // Flip y back since we used negative scale
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
|
|
111
|
+
coords.setAttribute('x', (x + 5).toString());
|
|
112
|
+
coords.setAttribute('y', (y - 5).toString());
|
|
113
|
+
});
|
|
114
|
+
document.currentScript.parentElement.addEventListener('mouseleave', () => {
|
|
115
|
+
document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
|
|
116
|
+
});
|
|
117
|
+
]]>
|
|
118
|
+
</script>
|
|
119
|
+
</svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { test, expect } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import inputProblem from "../assets/example39.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
test("example38", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
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 "../assets/example40.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
test("example40", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
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 "../assets/example41.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
test("example41", () => {
|
|
7
|
+
const solver = new SchematicTracePipelineSolver(inputProblem as any)
|
|
8
|
+
|
|
9
|
+
solver.solve()
|
|
10
|
+
|
|
11
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
12
|
+
})
|