@tscircuit/schematic-trace-solver 0.0.133 → 0.0.135
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 +1 -0
- package/dist/index.js +226 -129
- package/lib/solvers/LongDistancePairSolver/LongDistancePairSolver.ts +140 -6
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/OverlapAvoidanceStepSolver.ts +7 -1
- package/package.json +1 -1
- package/site/bug-reports/bug-report-20260815T073240Z.page.tsx +4 -0
- package/tests/bug-reports/bug-report-20260815T073240Z/__snapshots__/bug-report-20260815T073240Z.snap.svg +79 -0
- package/tests/bug-reports/bug-report-20260815T073240Z/bug-report-20260815T073240Z.json +314 -0
- package/tests/bug-reports/bug-report-20260815T073240Z/bug-report-20260815T073240Z.test.ts +12 -0
- package/tests/repros/__snapshots__/board1096-usb-label-overlap-iteration.snap.svg +133 -0
- package/tests/repros/__snapshots__/repro-type-c-vbus-led-ground-label.snap.svg +66 -0
- package/tests/repros/board1096-usb-label-overlap-iteration.json +663 -0
- package/tests/repros/board1096-usb-label-overlap-iteration.test.ts +16 -0
- package/tests/repros/repro-type-c-vbus-led-ground-label.test.ts +149 -0
|
@@ -0,0 +1,149 @@
|
|
|
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 connectorPins = [
|
|
7
|
+
"VBUS1",
|
|
8
|
+
"VBUS2",
|
|
9
|
+
"CC1",
|
|
10
|
+
"CC2",
|
|
11
|
+
"DP1",
|
|
12
|
+
"DP2",
|
|
13
|
+
"DM1",
|
|
14
|
+
"DM2",
|
|
15
|
+
"SBU1",
|
|
16
|
+
"SBU2",
|
|
17
|
+
"GND1",
|
|
18
|
+
"GND2",
|
|
19
|
+
].map((name, index) => ({
|
|
20
|
+
pinId: `J1.${name}`,
|
|
21
|
+
x: -1.7,
|
|
22
|
+
y: 1.65 - index * 0.3,
|
|
23
|
+
_facingDirection: "x+" as const,
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
// Reproduces a TYPE-C-31-M-12 connector with its two VBUS pins joined to a
|
|
27
|
+
// resistor/LED chain while the LED cathode shares the connector's GND net.
|
|
28
|
+
// The distant GND endpoints should be represented by separate net labels.
|
|
29
|
+
const inputProblem: InputProblem = {
|
|
30
|
+
chips: [
|
|
31
|
+
{
|
|
32
|
+
chipId: "J1",
|
|
33
|
+
center: { x: -3, y: 0 },
|
|
34
|
+
width: 2.6,
|
|
35
|
+
height: 4,
|
|
36
|
+
pins: connectorPins,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
chipId: "R1",
|
|
40
|
+
center: { x: 0, y: 1.5 },
|
|
41
|
+
width: 0.8,
|
|
42
|
+
height: 0.5,
|
|
43
|
+
pins: [
|
|
44
|
+
{
|
|
45
|
+
pinId: "R1.1",
|
|
46
|
+
x: -0.4,
|
|
47
|
+
y: 1.5,
|
|
48
|
+
_facingDirection: "x-",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
pinId: "R1.2",
|
|
52
|
+
x: 0.4,
|
|
53
|
+
y: 1.5,
|
|
54
|
+
_facingDirection: "x+",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
chipId: "D1",
|
|
60
|
+
center: { x: 3, y: 1.5 },
|
|
61
|
+
width: 1,
|
|
62
|
+
height: 0.8,
|
|
63
|
+
pins: [
|
|
64
|
+
{
|
|
65
|
+
pinId: "D1.1",
|
|
66
|
+
x: 2.5,
|
|
67
|
+
y: 1.5,
|
|
68
|
+
_facingDirection: "x-",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
pinId: "D1.2",
|
|
72
|
+
x: 3.5,
|
|
73
|
+
y: 1.5,
|
|
74
|
+
_facingDirection: "x+",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
directConnections: [
|
|
80
|
+
{
|
|
81
|
+
netId: "VBUS_LED",
|
|
82
|
+
pinIds: ["R1.2", "D1.1"],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
netConnections: [
|
|
86
|
+
{
|
|
87
|
+
netId: "VBUS",
|
|
88
|
+
pinIds: ["J1.VBUS1", "J1.VBUS2", "R1.1"],
|
|
89
|
+
netLabelWidth: 0.48,
|
|
90
|
+
netLabelHeight: 0.48,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
netId: "J1_GND1",
|
|
94
|
+
pinIds: ["J1.GND1", "J1.GND2", "D1.2"],
|
|
95
|
+
netLabelWidth: 0.78,
|
|
96
|
+
netLabelHeight: 0.48,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
textBoxes: [
|
|
100
|
+
{
|
|
101
|
+
chipId: "J1",
|
|
102
|
+
center: { x: -3, y: 2.3 },
|
|
103
|
+
width: 1.6,
|
|
104
|
+
height: 0.2,
|
|
105
|
+
text: "J1 TYPE-C-31-M-12",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
chipId: "R1",
|
|
109
|
+
center: { x: 0, y: 1.95 },
|
|
110
|
+
width: 0.4,
|
|
111
|
+
height: 0.2,
|
|
112
|
+
text: "R1 1kΩ",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
chipId: "D1",
|
|
116
|
+
center: { x: 3, y: 2.15 },
|
|
117
|
+
width: 0.5,
|
|
118
|
+
height: 0.2,
|
|
119
|
+
text: "D1 white",
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
availableNetLabelOrientations: {
|
|
123
|
+
VBUS: ["x+", "y+"],
|
|
124
|
+
J1_GND1: ["y-", "x+"],
|
|
125
|
+
},
|
|
126
|
+
maxMspPairDistance: 2.4,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
test("routes TYPE-C-31-M-12 VBUS through an LED with shared GND labels", () => {
|
|
130
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
131
|
+
|
|
132
|
+
solver.solve()
|
|
133
|
+
|
|
134
|
+
const output = solver.netLabelNetLabelCollisionSolver!.getOutput()
|
|
135
|
+
const gndLabels = output.netLabelPlacements.filter(
|
|
136
|
+
(label) => label.netId === "J1_GND1",
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
const recoveredGroundTrace =
|
|
140
|
+
solver.longDistancePairSolver!.solvedLongDistanceTraces.find(
|
|
141
|
+
(trace) =>
|
|
142
|
+
trace.pinIds.includes("D1.2") &&
|
|
143
|
+
trace.pinIds.some((pinId) => pinId.startsWith("J1.GND")),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
expect(recoveredGroundTrace).toBeDefined()
|
|
147
|
+
expect(gndLabels).toHaveLength(1)
|
|
148
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
149
|
+
})
|