@tscircuit/schematic-trace-solver 0.0.75 → 0.0.77

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.
@@ -0,0 +1,88 @@
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.3
5
+ x+" data-x="1.05" data-y="-0.1" cx="398.5365853658536" cy="313.1707317073171" r="3" fill="hsl(321, 100%, 50%, 0.8)" />
6
+ </g>
7
+ <g>
8
+ <circle data-type="point" data-label="U1.4
9
+ x+" data-x="1.05" data-y="0.1" cx="398.5365853658536" cy="279.0243902439025" r="3" fill="hsl(322, 100%, 50%, 0.8)" />
10
+ </g>
11
+ <g>
12
+ <circle data-type="point" data-label="anchorPoint
13
+ orientation: y-" data-x="1.25" data-y="-0.1" cx="432.68292682926824" cy="313.1707317073171" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
14
+ </g>
15
+ <g>
16
+ <polyline data-points="1.05,-0.1 1.05,0.1" data-type="line" data-label="" points="398.5365853658536,313.1707317073171 398.5365853658536,279.0243902439025" fill="none" stroke="hsl(157, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
17
+ </g>
18
+ <g>
19
+ <polyline data-points="1.05,-0.1 1.25,-0.1 1.25,0.1 1.05,0.1" data-type="line" data-label="" points="398.5365853658536,313.1707317073171 432.68292682926824,313.1707317073171 432.68292682926824,279.0243902439025 398.5365853658536,279.0243902439025" fill="none" stroke="purple" stroke-width="1" />
20
+ </g>
21
+ <g>
22
+ <rect data-type="rect" data-label="U1" data-x="0" data-y="0" x="40" y="244.87804878048783" width="358.5365853658536" height="102.43902439024387" fill="hsl(164, 100%, 50%, 0.8)" stroke="black" stroke-width="0.005857142857142858" />
23
+ </g>
24
+ <g>
25
+ <rect data-type="rect" data-label="SOMETHING_THAT_IS_LONG" data-x="0.79" data-y="-0.43" x="108.29268292682927" y="354.1463414634147" width="491.7073170731707" height="30.73170731707313" fill="rgba(160, 0, 220, 0.14)" stroke="black" stroke-width="0.005857142857142858" />
26
+ </g>
27
+ <g>
28
+ <rect data-type="rect" data-label="netId: GND
29
+ globalConnNetId: connectivity_net0" data-x="1.25" data-y="-0.33999999999999997" x="415.60975609756093" y="313.1707317073171" width="34.14634146341467" height="81.95121951219511" fill="#00000066" stroke="#000000" stroke-width="0.005857142857142858" />
30
+ </g>
31
+ <g id="crosshair" style="display: none">
32
+ <line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
33
+ <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>
34
+ </g>
35
+ <script>
36
+ <![CDATA[
37
+ document.currentScript.parentElement.addEventListener('mousemove', (e) => {
38
+ const svg = e.currentTarget;
39
+ const rect = svg.getBoundingClientRect();
40
+ const x = e.clientX - rect.left;
41
+ const y = e.clientY - rect.top;
42
+ const crosshair = svg.getElementById('crosshair');
43
+ const h = svg.getElementById('crosshair-h');
44
+ const v = svg.getElementById('crosshair-v');
45
+ const coords = svg.getElementById('coordinates');
46
+
47
+ crosshair.style.display = 'block';
48
+ h.setAttribute('x1', '0');
49
+ h.setAttribute('x2', '640');
50
+ h.setAttribute('y1', y);
51
+ h.setAttribute('y2', y);
52
+ v.setAttribute('x1', x);
53
+ v.setAttribute('x2', x);
54
+ v.setAttribute('y1', '0');
55
+ v.setAttribute('y2', '640');
56
+
57
+ // Calculate real coordinates using inverse transformation
58
+ const matrix = {
59
+ "a": 170.73170731707316,
60
+ "c": 0,
61
+ "e": 219.2682926829268,
62
+ "b": 0,
63
+ "d": -170.73170731707316,
64
+ "f": 296.0975609756098
65
+ };
66
+ // Manually invert and apply the affine transform
67
+ // Since we only use translate and scale, we can directly compute:
68
+ // x' = (x - tx) / sx
69
+ // y' = (y - ty) / sy
70
+ const sx = matrix.a;
71
+ const sy = matrix.d;
72
+ const tx = matrix.e;
73
+ const ty = matrix.f;
74
+ const realPoint = {
75
+ x: (x - tx) / sx,
76
+ y: (y - ty) / sy // Flip y back since we used negative scale
77
+ }
78
+
79
+ coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
80
+ coords.setAttribute('x', (x + 5).toString());
81
+ coords.setAttribute('y', (y - 5).toString());
82
+ });
83
+ document.currentScript.parentElement.addEventListener('mouseleave', () => {
84
+ document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
85
+ });
86
+ ]]>
87
+ </script>
88
+ </svg>
@@ -0,0 +1,57 @@
1
+ import { expect, test } from "bun:test"
2
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
3
+ import type { InputProblem } from "lib/types/InputProblem"
4
+ import "tests/fixtures/matcher"
5
+
6
+ const inputProblem: InputProblem = {
7
+ chips: [
8
+ {
9
+ chipId: "U1",
10
+ center: { x: 0, y: 0 },
11
+ width: 1.3,
12
+ height: 0.6,
13
+ pins: [
14
+ { pinId: "U1.3", x: 1.05, y: -0.1 },
15
+ { pinId: "U1.4", x: 1.05, y: 0.1 },
16
+ ],
17
+ },
18
+ ],
19
+ directConnections: [],
20
+ netConnections: [
21
+ {
22
+ netId: "GND",
23
+ pinIds: ["U1.3", "U1.4"],
24
+ netLabelWidth: 0.48,
25
+ },
26
+ ],
27
+ textBoxes: [
28
+ {
29
+ chipId: "U1",
30
+ center: { x: 0.79, y: -0.43 },
31
+ width: 2.88,
32
+ height: 0.18,
33
+ text: "SOMETHING_THAT_IS_LONG",
34
+ },
35
+ ],
36
+ availableNetLabelOrientations: {
37
+ GND: ["y-"],
38
+ },
39
+ maxMspPairDistance: 2.4,
40
+ }
41
+
42
+ test("repro142 manufacturer text overlaps GND net label", () => {
43
+ const solver = new SchematicTracePipelineSolver(inputProblem)
44
+ solver.solve()
45
+
46
+ const output = solver.netLabelNetLabelCollisionSolver!.getOutput()
47
+ const gndLabels = output.netLabelPlacements.filter(
48
+ (label) => label.netId === "GND",
49
+ )
50
+
51
+ expect(gndLabels).toHaveLength(1)
52
+ expect(solver.netLabelTraceCollisionSolver!.getOutput().traces).toHaveLength(
53
+ 1,
54
+ )
55
+
56
+ expect(solver).toMatchSolverSnapshot(import.meta.path)
57
+ })