@tscircuit/schematic-trace-solver 0.0.162 → 0.0.164
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 +2 -1
- package/dist/index.js +21 -6
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +21 -3
- package/lib/solvers/AvailableNetOrientationSolver/types.ts +1 -0
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +15 -4
- package/package.json +1 -1
- package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +166 -166
- package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +26 -26
- package/tests/repros/__snapshots__/repro-isolated-rs485-isow7841.snap.svg +308 -0
- package/tests/repros/__snapshots__/repro-normal-net-label-branch-from-junction.snap.svg +93 -0
- package/tests/repros/__snapshots__/repro-pmp11282-endpoint-trace-through-component-text.snap.svg +76 -0
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +131 -113
- package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +1681 -1690
- package/tests/repros/assets/repro-isolated-rs485-isow7841.input.json +1992 -0
- package/tests/repros/repro-isolated-rs485-isow7841.test.ts +21 -0
- package/tests/repros/repro-normal-net-label-branch-from-junction.test.ts +73 -0
- package/tests/repros/repro-pmp11282-endpoint-trace-through-component-text.test.ts +82 -0
- package/tests/repros/repro-pmp11282-isolated-dcdc.test.ts +5 -5
|
@@ -0,0 +1,21 @@
|
|
|
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-isolated-rs485-isow7841.input.json"
|
|
6
|
+
|
|
7
|
+
test("repro isolated RS-485 ISOW7841 schematic traces", () => {
|
|
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.solved).toBe(true)
|
|
16
|
+
expect(solver.schematicTraceLinesSolver?.solvedTracePaths).toHaveLength(50)
|
|
17
|
+
expect(solver.schematicTraceLinesSolver?.failedConnectionPairs).toHaveLength(
|
|
18
|
+
0,
|
|
19
|
+
)
|
|
20
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
21
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
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: "R8",
|
|
10
|
+
center: { x: -7, y: -19 },
|
|
11
|
+
width: 0.6,
|
|
12
|
+
height: 0.65,
|
|
13
|
+
pins: [
|
|
14
|
+
{ pinId: "R8.pin1", x: -7.3, y: -19, _facingDirection: "x-" },
|
|
15
|
+
{ pinId: "R8.pin2", x: -6.7, y: -19, _facingDirection: "x+" },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
chipId: "R7",
|
|
20
|
+
center: { x: -5, y: -19 },
|
|
21
|
+
width: 0.6,
|
|
22
|
+
height: 0.65,
|
|
23
|
+
pins: [
|
|
24
|
+
{ pinId: "R7.pin1", x: -5.3, y: -19, _facingDirection: "x-" },
|
|
25
|
+
{ pinId: "R7.pin2", x: -4.7, y: -19, _facingDirection: "x+" },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
directConnections: [],
|
|
30
|
+
netConnections: [
|
|
31
|
+
{
|
|
32
|
+
netId: "V3V3",
|
|
33
|
+
netLabelText: "V3V3",
|
|
34
|
+
pinIds: ["R8.pin2", "R7.pin2"],
|
|
35
|
+
netLabelWidth: 0.48,
|
|
36
|
+
netLabelHeight: 0.42,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
netId: "U1_IO22",
|
|
40
|
+
netLabelText: "U1_IO22",
|
|
41
|
+
pinIds: ["R8.pin1"],
|
|
42
|
+
netLabelWidth: 0.84,
|
|
43
|
+
netLabelHeight: 0.42,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
netId: "U1_IO21",
|
|
47
|
+
netLabelText: "U1_IO21",
|
|
48
|
+
pinIds: ["R7.pin1"],
|
|
49
|
+
netLabelWidth: 1,
|
|
50
|
+
netLabelHeight: 0.42,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
availableNetLabelOrientations: {
|
|
54
|
+
V3V3: ["y+"],
|
|
55
|
+
U1_IO22: ["x-"],
|
|
56
|
+
U1_IO21: ["x-"],
|
|
57
|
+
},
|
|
58
|
+
maxMspPairDistance: 2.4,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
test("repro: V3V3 net-label branch does not start at the R8 edge", () => {
|
|
62
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
63
|
+
|
|
64
|
+
solver.solve()
|
|
65
|
+
|
|
66
|
+
expect(
|
|
67
|
+
solver.netLabelNetLabelCollisionSolver!.getOutput().netLabelPlacements,
|
|
68
|
+
).not.toHaveLength(0)
|
|
69
|
+
expect(
|
|
70
|
+
solver.inlineNetLabelSolver!.getOutput().inlineNetLabelPlacements,
|
|
71
|
+
).toHaveLength(0)
|
|
72
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
73
|
+
})
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import { isPathCollidingWithObstacles } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
|
|
3
|
+
import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
|
|
4
|
+
import type { InputProblem } from "lib/types/InputProblem"
|
|
5
|
+
import { getTextBoxBounds } from "lib/utils/textBoxBounds"
|
|
6
|
+
import "tests/fixtures/matcher"
|
|
7
|
+
|
|
8
|
+
// Reduced from the PMP11282 reproduction. U503.pin2 and TP502.pin1 are the
|
|
9
|
+
// original schematic_port_238 and schematic_port_273 endpoints.
|
|
10
|
+
const inputProblem: InputProblem = {
|
|
11
|
+
chips: [
|
|
12
|
+
{
|
|
13
|
+
chipId: "U503",
|
|
14
|
+
center: { x: -2.7375, y: -1.6425 },
|
|
15
|
+
width: 2.1,
|
|
16
|
+
height: 0.6,
|
|
17
|
+
pins: [
|
|
18
|
+
{ pinId: "U503.pin1", x: -3.7875, y: -1.5425 },
|
|
19
|
+
{ pinId: "U503.pin2", x: -3.7875, y: -1.7425 },
|
|
20
|
+
{ pinId: "U503.pin3", x: -1.6875, y: -1.7425 },
|
|
21
|
+
{ pinId: "U503.pin4", x: -1.6875, y: -1.5425 },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
chipId: "TP502",
|
|
26
|
+
center: { x: 0.17175, y: -2.0075 },
|
|
27
|
+
width: 0.9625,
|
|
28
|
+
height: 0.2,
|
|
29
|
+
pins: [{ pinId: "TP502.pin1", x: -0.3095, y: -2.0075 }],
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
directConnections: [
|
|
33
|
+
{
|
|
34
|
+
netId: "TP502.pin1 to U503.pin2",
|
|
35
|
+
pinIds: ["TP502.pin1", "U503.pin2"],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
netConnections: [],
|
|
39
|
+
textBoxes: [
|
|
40
|
+
{
|
|
41
|
+
chipId: "U503",
|
|
42
|
+
center: { x: -2.6675, y: -2.0725 },
|
|
43
|
+
width: 1.44,
|
|
44
|
+
height: 0.18,
|
|
45
|
+
text: "PC817X4NSZ0F",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
chipId: "U503",
|
|
49
|
+
center: { x: -3.1475, y: -1.2275 },
|
|
50
|
+
width: 0.6,
|
|
51
|
+
height: 0.25,
|
|
52
|
+
text: "U503",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
availableNetLabelOrientations: {},
|
|
56
|
+
maxMspPairDistance: 100,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
test("PMP11282 endpoint trace avoids U503 component text", () => {
|
|
60
|
+
const solver = new SchematicTracePipelineSolver(inputProblem, {
|
|
61
|
+
hideRatsNet: true,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
solver.solve()
|
|
65
|
+
|
|
66
|
+
const trace = solver.schematicTraceLinesSolver!.solvedTracePaths.find(
|
|
67
|
+
(candidate) =>
|
|
68
|
+
candidate.pinIds.includes("U503.pin2") &&
|
|
69
|
+
candidate.pinIds.includes("TP502.pin1"),
|
|
70
|
+
)
|
|
71
|
+
const componentTextBox = inputProblem.textBoxes!.find(
|
|
72
|
+
(textBox) => textBox.text === "PC817X4NSZ0F",
|
|
73
|
+
)!
|
|
74
|
+
|
|
75
|
+
expect(trace).toBeDefined()
|
|
76
|
+
expect(
|
|
77
|
+
isPathCollidingWithObstacles(trace!.tracePath, [
|
|
78
|
+
getTextBoxBounds(componentTextBox),
|
|
79
|
+
]),
|
|
80
|
+
).toBe(false)
|
|
81
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
82
|
+
})
|
|
@@ -35,8 +35,8 @@ test("repro PMP11282 isolated DC/DC traces and endpoint net labels", () => {
|
|
|
35
35
|
expect(defaultPipeline.error).toBe(
|
|
36
36
|
"SchematicTraceLinesSolver ran out of iterations",
|
|
37
37
|
)
|
|
38
|
-
expect(defaultTraceSolver.solvedTracePaths).toHaveLength(
|
|
39
|
-
expect(defaultTraceSolver.failedConnectionPairs).toHaveLength(
|
|
38
|
+
expect(defaultTraceSolver.solvedTracePaths).toHaveLength(70)
|
|
39
|
+
expect(defaultTraceSolver.failedConnectionPairs).toHaveLength(37)
|
|
40
40
|
expect(defaultTraceSolver.queuedConnectionPairs).toHaveLength(95)
|
|
41
41
|
|
|
42
42
|
// Let the same unmodified production pipeline reach its downstream stages
|
|
@@ -64,11 +64,11 @@ test("repro PMP11282 isolated DC/DC traces and endpoint net labels", () => {
|
|
|
64
64
|
expect(diagnosticPipeline.failed).toBe(false)
|
|
65
65
|
expect(
|
|
66
66
|
diagnosticPipeline.schematicTraceLinesSolver!.solvedTracePaths,
|
|
67
|
-
).toHaveLength(
|
|
67
|
+
).toHaveLength(143)
|
|
68
68
|
expect(
|
|
69
69
|
diagnosticPipeline.schematicTraceLinesSolver!.failedConnectionPairs,
|
|
70
|
-
).toHaveLength(
|
|
71
|
-
expect(finalOutput.netLabelPlacements).toHaveLength(
|
|
70
|
+
).toHaveLength(60)
|
|
71
|
+
expect(finalOutput.netLabelPlacements).toHaveLength(108)
|
|
72
72
|
expect(endpointPairLabels).toHaveLength(80)
|
|
73
73
|
expect(endpointPairNetIds.size).toBe(62)
|
|
74
74
|
expect(endpointPairNetIds).toContain("U500.pin8 to C501.pin1")
|