@tscircuit/schematic-trace-solver 0.0.192 → 0.0.194
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.js +15 -5
- package/lib/solvers/UnroutedTraceRecoverySolver/UnroutedTraceRecoverySolver.ts +14 -3
- package/package.json +1 -1
- package/site/SchematicTracePipelineSolver/repro-core-vertical-passive-ground-label-overlap.page.tsx +4 -0
- package/site/SchematicTracePipelineSolver/repro173-boost-drv8711-ground-label-overlap.page.tsx +7 -0
- package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260724T175257Z/__snapshots__/bug-report-20260724T175257Z.snap.svg +35 -35
- package/tests/examples/__snapshots__/example08.snap.svg +29 -29
- package/tests/examples/__snapshots__/example32.snap.svg +2 -2
- package/tests/examples/__snapshots__/example46.snap.svg +12 -21
- package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-core-vertical-passive-ground-label-overlap.snap.svg +135 -0
- package/tests/repros/__snapshots__/repro-esp12f-section.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-ina237-current-monitor.snap.svg +17 -17
- package/tests/repros/__snapshots__/repro-manual-placement-detour.snap.svg +249 -0
- package/tests/repros/__snapshots__/repro-netlabel-overlap-trace.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +89 -98
- package/tests/repros/__snapshots__/repro173-boost-drv8711-ground-label-overlap.snap.svg +307 -0
- package/tests/repros/__snapshots__/rtc-imu-microsd-section.snap.svg +286 -0
- package/tests/repros/assets/repro-core-vertical-passive-ground-label-overlap.input.json +353 -0
- package/tests/repros/assets/repro173-boost-drv8711-ground-label-overlap.input.json +865 -0
- package/tests/repros/assets/rtc-imu-microsd-section.input.json +894 -0
- package/tests/repros/repro-core-vertical-passive-ground-label-overlap.test.ts +39 -0
- package/tests/repros/repro-manual-placement-detour.input.json +853 -0
- package/tests/repros/repro-manual-placement-detour.test.ts +39 -0
- package/tests/repros/repro-pmp11282-isolated-dcdc.test.ts +10 -3
- package/tests/repros/repro173-boost-drv8711-ground-label-overlap.test.ts +41 -0
- package/tests/repros/rtc-imu-microsd-section.test.ts +28 -0
- package/tests/solvers/UnroutedTraceRecoverySolver/local-elbow-obstacles.test.ts +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import { findFirstCollision } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
|
|
4
|
+
import { getObstacleRects } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/rect"
|
|
5
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
6
|
+
import "tests/fixtures/matcher"
|
|
7
|
+
import inputJson from "./repro-manual-placement-detour.input.json"
|
|
8
|
+
|
|
9
|
+
// Captured from core/tests/components/primitive-components/schematic-section-manual-placement-5.test.tsx.
|
|
10
|
+
// R2 pin1 and C3 pin1 face upward, with C3 obstructing the initial U-shaped route.
|
|
11
|
+
test("routes R2 to C3 locally in manually placed schematic sections", async () => {
|
|
12
|
+
const inputProblem: InputProblem = JSON.parse(JSON.stringify(inputJson))
|
|
13
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
14
|
+
solver.solve()
|
|
15
|
+
|
|
16
|
+
const trace = solver
|
|
17
|
+
.netLabelToTraceSolver!.getOutput()
|
|
18
|
+
.traces.find(
|
|
19
|
+
(trace) =>
|
|
20
|
+
trace.pinIds.includes("schematic_port_31") &&
|
|
21
|
+
trace.pinIds.includes("schematic_port_29"),
|
|
22
|
+
)!
|
|
23
|
+
let routeLength = 0
|
|
24
|
+
for (let pointIndex = 1; pointIndex < trace.tracePath.length; pointIndex++) {
|
|
25
|
+
const previousPoint = trace.tracePath[pointIndex - 1]!
|
|
26
|
+
const point = trace.tracePath[pointIndex]!
|
|
27
|
+
routeLength +=
|
|
28
|
+
Math.abs(point.x - previousPoint.x) + Math.abs(point.y - previousPoint.y)
|
|
29
|
+
}
|
|
30
|
+
expect(solver.solved).toBe(true)
|
|
31
|
+
expect(
|
|
32
|
+
findFirstCollision(trace.tracePath, getObstacleRects(inputProblem)),
|
|
33
|
+
).toBeNull()
|
|
34
|
+
expect(routeLength).toBeCloseTo(3.06)
|
|
35
|
+
expect(Math.min(...trace.tracePath.map((point) => point.x))).toBeGreaterThan(
|
|
36
|
+
-3.5,
|
|
37
|
+
)
|
|
38
|
+
await expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
39
|
+
})
|
|
@@ -68,9 +68,16 @@ test("repro PMP11282 isolated DC/DC traces and endpoint net labels", () => {
|
|
|
68
68
|
expect(
|
|
69
69
|
diagnosticPipeline.schematicTraceLinesSolver!.failedConnectionPairs,
|
|
70
70
|
).toHaveLength(60)
|
|
71
|
-
expect(finalOutput.netLabelPlacements).toHaveLength(
|
|
72
|
-
expect(endpointPairLabels).toHaveLength(
|
|
73
|
-
expect(endpointPairNetIds.size).toBe(
|
|
71
|
+
expect(finalOutput.netLabelPlacements).toHaveLength(107)
|
|
72
|
+
expect(endpointPairLabels).toHaveLength(79)
|
|
73
|
+
expect(endpointPairNetIds.size).toBe(61)
|
|
74
|
+
expect(
|
|
75
|
+
finalOutput.traces.some(
|
|
76
|
+
(trace) =>
|
|
77
|
+
trace.pinIds.includes("schematic_port_20") &&
|
|
78
|
+
trace.pinIds.includes("schematic_port_34"),
|
|
79
|
+
),
|
|
80
|
+
).toBe(true)
|
|
74
81
|
expect(endpointPairNetIds).toContain("U500.pin8 to C501.pin1")
|
|
75
82
|
expect(endpointPairNetIds).toContain("L500.pin1 to L500.pin2")
|
|
76
83
|
expect(diagnosticPipeline).toMatchSolverSnapshot(import.meta.path)
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { pathIntersectsRenderedLabel } from "lib/utils/pathIntersectsRenderedLabel"
|
|
5
|
+
import "tests/fixtures/matcher"
|
|
6
|
+
import inputProblem from "./assets/repro173-boost-drv8711-ground-label-overlap.input.json"
|
|
7
|
+
|
|
8
|
+
// Power stage solver input captured via solver:started from core's
|
|
9
|
+
// tests/repros/repro173-boost-drv8711-cross-sheet-netlabel-overlap.test.tsx
|
|
10
|
+
// at 2ad5cd0a, after https://github.com/tscircuit/core/pull/3794.
|
|
11
|
+
// Only symbolName and netLabelText were added for readable snapshots; routing
|
|
12
|
+
// geometry, pin order, and all eight cross-sheet U1 gate-drive labels are intact.
|
|
13
|
+
// The controller sheet is solved independently, so its input is not needed.
|
|
14
|
+
test("repro173 BOOST-DRV8711 ground trace overlaps the R1 GND label", async () => {
|
|
15
|
+
const solver = new SchematicTracePipelineSolver(
|
|
16
|
+
inputProblem as unknown as InputProblem,
|
|
17
|
+
{ hideRatsNet: true },
|
|
18
|
+
)
|
|
19
|
+
solver.solve()
|
|
20
|
+
|
|
21
|
+
expect(solver.solved).toBe(true)
|
|
22
|
+
|
|
23
|
+
const { traces, netLabelPlacements } =
|
|
24
|
+
solver.netLabelToTraceSolver!.getOutput()
|
|
25
|
+
const r1GroundLabel = netLabelPlacements.find(
|
|
26
|
+
(label) =>
|
|
27
|
+
label.netId === "GND" && label.pinIds.includes("schematic_port_83"),
|
|
28
|
+
)!
|
|
29
|
+
const c1ToR2GroundTrace = traces.find(
|
|
30
|
+
(trace) =>
|
|
31
|
+
trace.pinIds.includes("schematic_port_78") &&
|
|
32
|
+
trace.pinIds.includes("schematic_port_85"),
|
|
33
|
+
)!
|
|
34
|
+
|
|
35
|
+
// Current bug: the C1-to-R2 ground rail crosses the rendered GND label below
|
|
36
|
+
// R1. Record the observed failure; update this assertion and snapshot when fixed.
|
|
37
|
+
expect(
|
|
38
|
+
pathIntersectsRenderedLabel(c1ToR2GroundTrace.tracePath, r1GroundLabel),
|
|
39
|
+
).toBe(true)
|
|
40
|
+
await expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
41
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import inputProblem from "./assets/rtc-imu-microsd-section.input.json"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
6
|
+
import { getPathLength } from "lib/solvers/Example28Solver/geometry"
|
|
7
|
+
|
|
8
|
+
test("RTC IMU microSD section trace routing", () => {
|
|
9
|
+
const problem: InputProblem = JSON.parse(JSON.stringify(inputProblem))
|
|
10
|
+
const solver = new SchematicTracePipelineSolver(problem)
|
|
11
|
+
solver.solve()
|
|
12
|
+
const recoveredTrace = solver
|
|
13
|
+
.unroutedTraceRecoverySolver!.getOutput()
|
|
14
|
+
.newTraces.find(
|
|
15
|
+
(trace) =>
|
|
16
|
+
trace.pinIds.includes("schematic_port_53") &&
|
|
17
|
+
trace.pinIds.includes("schematic_port_32"),
|
|
18
|
+
)!
|
|
19
|
+
expect(recoveredTrace).toBeDefined()
|
|
20
|
+
expect(getPathLength(recoveredTrace.tracePath)).toBeLessThan(4)
|
|
21
|
+
expect(recoveredTrace.tracePath[0]).toMatchObject(recoveredTrace.pins[0])
|
|
22
|
+
expect(recoveredTrace.tracePath.at(-1)).toMatchObject(recoveredTrace.pins[1])
|
|
23
|
+
const finalTrace = solver
|
|
24
|
+
.inlineNetLabelSolver!.getOutput()
|
|
25
|
+
.traces.find((trace) => trace.mspPairId === recoveredTrace.mspPairId)!
|
|
26
|
+
expect(getPathLength(finalTrace.tracePath)).toBeLessThan(3.5)
|
|
27
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
28
|
+
})
|
|
@@ -67,7 +67,7 @@ test.each(["chip", "text", "trace"] as const)(
|
|
|
67
67
|
expect(recovery.solved).toBe(true)
|
|
68
68
|
expect(recovery.solvedUnroutedTraces).toHaveLength(1)
|
|
69
69
|
const recoveredPath = recovery.solvedUnroutedTraces[0]!.tracePath
|
|
70
|
-
expect(getPathLength(recoveredPath)).
|
|
70
|
+
expect(getPathLength(recoveredPath)).toBeCloseTo(0.8)
|
|
71
71
|
expect(findFirstCollision(recoveredPath, [blockingBounds])).toBeNull()
|
|
72
72
|
expect(countPathIntersections(recoveredPath, blockingPath)).toBe(0)
|
|
73
73
|
},
|