@tscircuit/schematic-trace-solver 0.0.129 → 0.0.131
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 +7 -0
- package/dist/index.js +219 -13
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +290 -12
- package/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +23 -2
- package/package.json +1 -1
- package/site/bug-reports/bug-report-20260811T075142Z.page.tsx +4 -0
- package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +34 -22
- package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +5 -3
- package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +305 -303
- package/tests/bug-reports/bug-report-20260804T095800Z/__snapshots__/bug-report-20260804T095800Z.snap.svg +5 -3
- package/tests/bug-reports/bug-report-20260811T075142Z/__snapshots__/bug-report-20260811T075142Z.snap.svg +74 -0
- package/tests/bug-reports/bug-report-20260811T075142Z/bug-report-20260811T075142Z.json +194 -0
- package/tests/bug-reports/bug-report-20260811T075142Z/bug-report-20260811T075142Z.test.ts +131 -0
- package/tests/examples/__snapshots__/example10.snap.svg +20 -16
- package/tests/examples/__snapshots__/example31.snap.svg +8 -6
- package/tests/examples/__snapshots__/example33.snap.svg +32 -30
- package/tests/examples/__snapshots__/example46.snap.svg +5 -3
- package/tests/examples/__snapshots__/example48.snap.svg +25 -23
- package/tests/examples/__snapshots__/example50.snap.svg +32 -30
- package/tests/repros/__snapshots__/repro-atmega328p-fault-pullup.snap.svg +48 -46
- package/tests/repros/__snapshots__/repro-board-589-regulator-section.snap.svg +69 -0
- package/tests/repros/__snapshots__/repro-bq24074-battery-charger.snap.svg +7 -5
- package/tests/repros/__snapshots__/repro-missing-trace-netlabel.snap.svg +24 -18
- package/tests/repros/__snapshots__/repro-usb-power-vbus-label-detour.snap.svg +467 -0
- package/tests/repros/__snapshots__/repro51-overlap-junction-crossing.snap.svg +25 -23
- package/tests/repros/__snapshots__/small-variant-resistor-facing-direction.snap.svg +46 -44
- package/tests/repros/assets/repro-board-589-regulator-section.input.json +270 -0
- package/tests/repros/assets/repro-usb-power-vbus-label-detour.input.json +2382 -0
- package/tests/repros/repro-board-589-regulator-section.test.ts +16 -0
- package/tests/repros/repro-max-msp-pair-distance-fallback.test.ts +45 -0
- package/tests/repros/repro-missing-trace-netlabel.test.ts +9 -11
- package/tests/repros/repro-usb-power-vbus-label-detour.test.ts +16 -0
- package/tests/repros/rotated-components-rail-label.test.ts +5 -11
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import inputProblemJson from "./assets/repro-board-589-regulator-section.input.json"
|
|
6
|
+
|
|
7
|
+
test("board 589 regulator section trace routing", () => {
|
|
8
|
+
const inputProblem: InputProblem = JSON.parse(
|
|
9
|
+
JSON.stringify(inputProblemJson),
|
|
10
|
+
)
|
|
11
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
12
|
+
|
|
13
|
+
solver.solve()
|
|
14
|
+
|
|
15
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
16
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
3
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
4
|
+
|
|
5
|
+
const inputProblem: InputProblem = {
|
|
6
|
+
chips: [
|
|
7
|
+
{
|
|
8
|
+
chipId: "U1",
|
|
9
|
+
center: { x: -3, y: 0 },
|
|
10
|
+
width: 1,
|
|
11
|
+
height: 1,
|
|
12
|
+
pins: [{ pinId: "U1.1", x: -2.5, y: 0, _facingDirection: "x+" }],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
chipId: "U2",
|
|
16
|
+
center: { x: 3, y: 0 },
|
|
17
|
+
width: 1,
|
|
18
|
+
height: 1,
|
|
19
|
+
pins: [{ pinId: "U2.1", x: 2.5, y: 0, _facingDirection: "x-" }],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
directConnections: [],
|
|
23
|
+
netConnections: [
|
|
24
|
+
{
|
|
25
|
+
netId: "SIGNAL",
|
|
26
|
+
pinIds: ["U1.1", "U2.1"],
|
|
27
|
+
netLabelWidth: 0.72,
|
|
28
|
+
netLabelHeight: 0.42,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
availableNetLabelOrientations: {
|
|
32
|
+
SIGNAL: ["x+", "x-"],
|
|
33
|
+
},
|
|
34
|
+
maxMspPairDistance: 2,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
test("named connections beyond maxMspPairDistance fall back to net labels", () => {
|
|
38
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
39
|
+
|
|
40
|
+
solver.solve()
|
|
41
|
+
|
|
42
|
+
const labels =
|
|
43
|
+
solver.netLabelNetLabelCollisionSolver!.getOutput().netLabelPlacements
|
|
44
|
+
expect(labels).toHaveLength(2)
|
|
45
|
+
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect, test } from "bun:test"
|
|
2
|
-
import { getTraceCorners } from "lib/solvers/RailNetLabelCornerPlacementSolver/geometry"
|
|
3
2
|
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
4
3
|
import inputProblem from "./assets/repro-missing-trace-netlabel.input.json"
|
|
5
4
|
import "tests/fixtures/matcher"
|
|
@@ -11,16 +10,15 @@ test("repro148 missing trace becomes net labels", () => {
|
|
|
11
10
|
|
|
12
11
|
solver.solve()
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
(label) => label.netId === "
|
|
17
|
-
)!
|
|
18
|
-
const powerTrace = output.traces.find((trace) =>
|
|
19
|
-
powerLabel.mspConnectionPairIds.includes(trace.mspPairId),
|
|
20
|
-
)!
|
|
21
|
-
|
|
22
|
-
expect(getTraceCorners(powerTrace.tracePath)).toContainEqual(
|
|
23
|
-
powerLabel.anchorPoint,
|
|
13
|
+
const finalOutput = solver.sameNetJunctionAlignmentSolver!.getOutput()
|
|
14
|
+
const resetLabels = finalOutput.netLabelPlacements.filter(
|
|
15
|
+
(label) => label.netId === "RESET",
|
|
24
16
|
)
|
|
17
|
+
|
|
18
|
+
expect(solver.longDistancePairSolver!.getOutput().newTraces).toHaveLength(0)
|
|
19
|
+
expect(resetLabels.map((label) => label.pinIds)).toEqual([
|
|
20
|
+
["R3.2"],
|
|
21
|
+
["SW2.1"],
|
|
22
|
+
])
|
|
25
23
|
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
26
24
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import inputProblemJson from "./assets/repro-usb-power-vbus-label-detour.input.json"
|
|
6
|
+
|
|
7
|
+
test("reproduces the usb power vbus label detour", () => {
|
|
8
|
+
const inputProblem: InputProblem = JSON.parse(
|
|
9
|
+
JSON.stringify(inputProblemJson),
|
|
10
|
+
)
|
|
11
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
12
|
+
|
|
13
|
+
solver.solve()
|
|
14
|
+
|
|
15
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
16
|
+
})
|
|
@@ -48,21 +48,15 @@ const inputProblem: InputProblem = {
|
|
|
48
48
|
maxMspPairDistance: 0.1,
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
test("rotated component rail
|
|
51
|
+
test("rotated component rail labels replace over-distance traces", () => {
|
|
52
52
|
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
53
53
|
solver.solve()
|
|
54
54
|
|
|
55
|
-
const traces = solver.netLabelTraceCollisionSolver!.getOutput().traces
|
|
56
55
|
const labels =
|
|
57
56
|
solver.netLabelNetLabelCollisionSolver!.getOutput().netLabelPlacements
|
|
58
|
-
const
|
|
57
|
+
const gndLabels = labels.filter((label) => label.netId === "GND")
|
|
59
58
|
|
|
60
|
-
expect(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
),
|
|
64
|
-
).toBe(false)
|
|
65
|
-
expect(gndLabel?.orientation).toBe("y-")
|
|
66
|
-
expect(gndLabel?.anchorPoint.x).toBeCloseTo(10.72)
|
|
67
|
-
expect(gndLabel?.anchorPoint.y).toBeCloseTo(0)
|
|
59
|
+
expect(solver.longDistancePairSolver!.getOutput().newTraces).toHaveLength(0)
|
|
60
|
+
expect(gndLabels.map((label) => label.pinIds)).toEqual([["D1.2"], ["D2.2"]])
|
|
61
|
+
expect(gndLabels.every((label) => label.orientation === "y-")).toBe(true)
|
|
68
62
|
})
|