@tscircuit/schematic-trace-solver 0.0.76 → 0.0.78

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 (25) hide show
  1. package/.github/ISSUE_TEMPLATE/json-bug-report.yml +24 -0
  2. package/.github/scripts/import-json-bug-report.ts +483 -0
  3. package/.github/workflows/json-bug-report.yml +154 -0
  4. package/dist/index.d.ts +32 -10
  5. package/dist/index.js +226 -74
  6. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +4 -0
  7. package/lib/solvers/AvailableNetOrientationSolver/types.ts +1 -0
  8. package/lib/solvers/NetLabelNetLabelCollisionSolver/NetLabelNetLabelCollisionSolver.ts +6 -0
  9. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver.ts +21 -1
  10. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/SingleNetLabelPlacementSolver_visualize.ts +9 -3
  11. package/lib/solvers/NetLabelPlacementSolver/SingleNetLabelPlacementSolver/solvePortOnlyPin.ts +27 -2
  12. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver.ts +1 -0
  13. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +121 -30
  14. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions.ts +10 -10
  15. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/mid.ts +5 -8
  16. package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/rect.ts +31 -6
  17. package/lib/solvers/SchematicTracePipelineSolver/visualizeInputProblem.ts +11 -0
  18. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/TraceAnchoredNetLabelOverlapSolver.ts +3 -0
  19. package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/types.ts +1 -0
  20. package/lib/solvers/VccNetLabelCornerPlacementSolver/VccNetLabelCornerPlacementSolver.ts +3 -0
  21. package/lib/solvers/VccNetLabelCornerPlacementSolver/types.ts +1 -0
  22. package/lib/utils/textBoxBounds.ts +40 -0
  23. package/package.json +1 -1
  24. package/tests/repros/__snapshots__/manufacturePartNumber-text-box.snap.svg +88 -0
  25. package/tests/repros/manufacturePartNumber-text-box.test.ts +57 -0
@@ -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="359.5652173913043" cy="313.9130434782609" 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="359.5652173913043" cy="283.47826086956525" 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="2.5300000000000002" data-y="-0.1" cx="584.7826086956521" cy="313.9130434782609" 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="359.5652173913043,313.9130434782609 359.5652173913043,283.47826086956525" 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 2.5300000000000002,-0.1 2.5300000000000002,0.1 1.05,0.1" data-type="line" data-label="" points="359.5652173913043,313.9130434782609 584.7826086956521,313.9130434782609 584.7826086956521,283.47826086956525 359.5652173913043,283.47826086956525" 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.00000000000006" y="253.0434782608696" width="319.56521739130426" height="91.30434782608691" fill="hsl(164, 100%, 50%, 0.8)" stroke="black" stroke-width="0.006571428571428573" />
23
+ </g>
24
+ <g>
25
+ <rect data-type="rect" data-label="SOMETHING_THAT_IS_LONG" data-x="0.79" data-y="-0.43" x="100.86956521739135" y="350.4347826086956" width="438.26086956521726" height="27.39130434782612" fill="rgba(160, 0, 220, 0.14)" stroke="black" stroke-width="0.006571428571428573" />
26
+ </g>
27
+ <g>
28
+ <rect data-type="rect" data-label="netId: GND
29
+ globalConnNetId: connectivity_net0" data-x="2.5300000000000002" data-y="-0.33999999999999997" x="569.5652173913043" y="313.9130434782609" width="30.43478260869574" height="73.04347826086956" fill="#00000066" stroke="#000000" stroke-width="0.006571428571428573" />
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": 152.17391304347822,
60
+ "c": 0,
61
+ "e": 199.7826086956522,
62
+ "b": 0,
63
+ "d": -152.17391304347822,
64
+ "f": 298.69565217391306
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
+ })