@tscircuit/schematic-trace-solver 0.0.137 → 0.0.141

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 (21) hide show
  1. package/.github/workflows/bun-pver-release.yml +7 -3
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.js +304 -36
  4. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex.ts +182 -0
  5. package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +67 -25
  6. package/lib/solvers/AvailableNetOrientationSolver/constants.ts +2 -0
  7. package/lib/solvers/Example28Solver/labelMovement.ts +71 -0
  8. package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +12 -4
  9. package/lib/solvers/TraceOverlapShiftSolver/TraceOverlapShiftSolver.ts +60 -4
  10. package/package.json +5 -1
  11. package/tests/bug-reports/bug-report-20260819T091818Z/__snapshots__/bug-report-20260819T091818Z.snap.svg +237 -0
  12. package/tests/bug-reports/bug-report-20260819T091818Z/bug-report-20260819T091818Z.json +1052 -0
  13. package/tests/bug-reports/bug-report-20260819T091818Z/bug-report-20260819T091818Z.test.ts +33 -0
  14. package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +542 -0
  15. package/tests/repros/__snapshots__/repro-board-648-esp12f-section.snap.svg +124 -0
  16. package/tests/repros/assets/board-1273-trace-overlap-cycle.input.json +3519 -0
  17. package/tests/repros/assets/repro-board-648-esp12f-section.input.json +537 -0
  18. package/tests/repros/board-1273-trace-overlap-cycle.test.ts +30 -0
  19. package/tests/repros/repro-board-648-esp12f-section.test.ts +13 -0
  20. package/tests/repros/repro161-power-section-autolayout.test.ts +7 -0
  21. package/tests/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex.test.ts +122 -0
@@ -0,0 +1,122 @@
1
+ import { expect, test } from "bun:test"
2
+ import { AvailableNetOrientationObstacleIndex } from "lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationObstacleIndex"
3
+ import { ChipObstacleSpatialIndex } from "lib/data-structures/ChipObstacleSpatialIndex"
4
+ import type { NetLabelPlacement } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
5
+ import type { SolvedTracePath } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver"
6
+
7
+ const netLabelPlacements: NetLabelPlacement[] = [
8
+ {
9
+ globalConnNetId: "net-1",
10
+ mspConnectionPairIds: ["trace-1"],
11
+ pinIds: ["pin-1", "pin-2"],
12
+ orientation: "x+",
13
+ anchorPoint: { x: 0, y: 0 },
14
+ center: { x: 1, y: 0 },
15
+ width: 2,
16
+ height: 1,
17
+ },
18
+ {
19
+ globalConnNetId: "net-2",
20
+ mspConnectionPairIds: [],
21
+ pinIds: ["pin-3"],
22
+ orientation: "x-",
23
+ anchorPoint: { x: 11, y: 10 },
24
+ center: { x: 10, y: 10 },
25
+ width: 2,
26
+ height: 1,
27
+ },
28
+ ]
29
+
30
+ const traces: SolvedTracePath[] = [
31
+ {
32
+ mspPairId: "trace-1",
33
+ dcConnNetId: "net-1",
34
+ globalConnNetId: "net-1",
35
+ pins: [
36
+ { pinId: "pin-1", chipId: "chip-1", x: -2, y: 3 },
37
+ { pinId: "pin-2", chipId: "chip-2", x: 2, y: 3 },
38
+ ],
39
+ tracePath: [
40
+ { x: -2, y: 3 },
41
+ { x: 2, y: 3 },
42
+ ],
43
+ mspConnectionPairIds: ["trace-1"],
44
+ pinIds: ["pin-1", "pin-2"],
45
+ },
46
+ ]
47
+
48
+ const chipObstacleSpatialIndex = new ChipObstacleSpatialIndex([
49
+ {
50
+ chipId: "chip-obstacle",
51
+ center: { x: 0, y: 3 },
52
+ width: 1,
53
+ height: 1,
54
+ pins: [],
55
+ },
56
+ ])
57
+
58
+ test("queries only nearby net labels and trace segments", () => {
59
+ const obstacleIndex = new AvailableNetOrientationObstacleIndex({
60
+ chipObstacleSpatialIndex,
61
+ netLabelPlacements,
62
+ traces,
63
+ })
64
+
65
+ expect(
66
+ obstacleIndex.getLabelIndicesInBounds({
67
+ minX: -0.1,
68
+ minY: -0.1,
69
+ maxX: 0.1,
70
+ maxY: 0.1,
71
+ }),
72
+ ).toEqual([0])
73
+ expect(
74
+ obstacleIndex.getTraceSegmentsInBounds({
75
+ minX: -0.1,
76
+ minY: 2.9,
77
+ maxX: 0.1,
78
+ maxY: 3.1,
79
+ }),
80
+ ).toHaveLength(1)
81
+ expect(
82
+ obstacleIndex.getTraceSegmentsInBounds({
83
+ minX: -0.1,
84
+ minY: 9.9,
85
+ maxX: 0.1,
86
+ maxY: 10.1,
87
+ }),
88
+ ).toHaveLength(0)
89
+ expect(obstacleIndex.doesTracePathCrossChip(traces[0]!.tracePath)).toBe(true)
90
+ expect(
91
+ obstacleIndex.getLabelIndicesNearTracePath([
92
+ { x: 2 + 5e-10, y: -1 },
93
+ { x: 2 + 5e-10, y: 1 },
94
+ ]),
95
+ ).toEqual([0])
96
+ })
97
+
98
+ test("rebuilds after a net label moves", () => {
99
+ const obstacleIndex = new AvailableNetOrientationObstacleIndex({
100
+ chipObstacleSpatialIndex,
101
+ netLabelPlacements,
102
+ traces,
103
+ })
104
+ const movedNetLabelPlacements = [
105
+ { ...netLabelPlacements[0]!, center: { x: 20, y: 20 } },
106
+ netLabelPlacements[1]!,
107
+ ]
108
+
109
+ obstacleIndex.rebuild({
110
+ netLabelPlacements: movedNetLabelPlacements,
111
+ traces,
112
+ })
113
+
114
+ expect(
115
+ obstacleIndex.getLabelIndicesInBounds({
116
+ minX: -0.1,
117
+ minY: -0.1,
118
+ maxX: 0.1,
119
+ maxY: 0.1,
120
+ }),
121
+ ).toHaveLength(0)
122
+ })