@tscircuit/schematic-trace-solver 0.0.175 → 0.0.177
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 +3 -0
- package/dist/index.js +570 -17
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +5 -1
- package/lib/solvers/MspConnectionPairSolver/getGroundConnectionPolicy.ts +13 -0
- package/lib/solvers/SameNetJunctionAlignmentSolver/SameNetJunctionAlignmentSolver.ts +2 -0
- package/lib/solvers/SameNetJunctionAlignmentSolver/alignSameNetJunctions.ts +748 -15
- package/lib/solvers/SameNetJunctionAlignmentSolver/findNearestSharedPinExitRail.ts +140 -0
- package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +3 -5
- package/package.json +1 -1
- package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.test.ts +9 -0
- package/tests/bug-reports/bug-report-20260707T230831Z/__snapshots__/bug-report-20260707T230831Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260717T042845Z/__snapshots__/bug-report-20260717T042845Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260730T061837Z/bug-report-20260730T061837Z.test.ts +8 -4
- package/tests/bug-reports/bug-report-20260804T171919Z/__snapshots__/bug-report-20260804T171919Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260805T061316Z/__snapshots__/bug-report-20260805T061316Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260806T061548Z/__snapshots__/bug-report-20260806T061548Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260825T045913Z/__snapshots__/bug-report-20260825T045913Z.snap.svg +2 -2
- package/tests/bug-reports/bug-report-20260826T072956Z/__snapshots__/bug-report-20260826T072956Z.snap.svg +6 -6
- package/tests/bug-reports/bug-report-20260901T134241Z/__snapshots__/bug-report-20260901T134241Z.snap.svg +7 -7
- package/tests/bug-reports/bug-report-20260901T134241Z/bug-report-20260901T134241Z.test.ts +48 -0
- package/tests/examples/__snapshots__/example51.snap.svg +2 -2
- package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +10 -10
- package/tests/repros/__snapshots__/board1096-usb-label-overlap-iteration.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-bq25895-cross-net-trace-overlap.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-core-ground-inline-label-fallback.snap.svg +10 -10
- package/tests/repros/__snapshots__/repro-example35-minimize-trace-crossing.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-isolated-rs485-isow7841.snap.svg +18 -18
- package/tests/repros/__snapshots__/repro-pga300-redundant-ground-traces.snap.svg +18 -18
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +10 -10
- package/tests/repros/__snapshots__/repro-powerbank-3v-system-power.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-smartwatch-power-sheet.snap.svg +451 -0
- package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-tida-01389-hbridge.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro161-power-section-autolayout.snap.svg +2 -2
- package/tests/repros/__snapshots__/repro48-555-timer-vcc-rail-label.snap.svg +2 -2
- package/tests/repros/assets/repro-smartwatch-power-sheet.input.json +1112 -0
- package/tests/repros/repro-isolated-rs485-isow7841.test.ts +4 -1
- package/tests/repros/repro-powerbank-3v-system-power.test.ts +24 -0
- package/tests/repros/repro-smartwatch-power-sheet.test.ts +27 -0
- package/tests/repros/repro-tida-01389-hbridge.test.ts +24 -0
- package/tests/solvers/MspConnectionPairSolver/ground-direct-connection-groups.test.ts +11 -0
- package/tests/solvers/SameNetJunctionAlignmentSolver/parallel-load-rails.test.ts +1 -0
|
@@ -27,8 +27,11 @@ test("repro isolated RS-485 ISOW7841 schematic traces", () => {
|
|
|
27
27
|
0,
|
|
28
28
|
)
|
|
29
29
|
expect(solver.sameNetJunctionAlignmentSolver?.stats.collapsedCycleCount).toBe(
|
|
30
|
-
|
|
30
|
+
1,
|
|
31
31
|
)
|
|
32
|
+
expect(
|
|
33
|
+
solver.sameNetJunctionAlignmentSolver?.stats.alignedJunctionCount,
|
|
34
|
+
).toBeGreaterThan(0)
|
|
32
35
|
const dPLabel =
|
|
33
36
|
solver.sameNetJunctionAlignmentSolver?.outputNetLabelPlacements.find(
|
|
34
37
|
(label) => label.netId === "D_P",
|
|
@@ -13,5 +13,29 @@ test("repro PowerBank 3 V System Power schematic", () => {
|
|
|
13
13
|
)
|
|
14
14
|
solver.solve()
|
|
15
15
|
|
|
16
|
+
const alignedTraces = solver.sameNetJunctionAlignmentSolver!.outputTraces
|
|
17
|
+
const pathFromPin = (traceId: string, pinId: string) => {
|
|
18
|
+
const trace = alignedTraces.find((item) => item.mspPairId === traceId)!
|
|
19
|
+
return trace.pins[0]!.pinId === pinId
|
|
20
|
+
? trace.tracePath
|
|
21
|
+
: [...trace.tracePath].reverse()
|
|
22
|
+
}
|
|
23
|
+
for (const [sharedPinId, firstTraceId, secondTraceId] of [
|
|
24
|
+
[
|
|
25
|
+
"schematic_port_379",
|
|
26
|
+
"schematic_port_393-schematic_port_379",
|
|
27
|
+
"schematic_port_391-schematic_port_379",
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"schematic_port_372",
|
|
31
|
+
"schematic_port_372-schematic_port_369",
|
|
32
|
+
"schematic_port_374-schematic_port_372",
|
|
33
|
+
],
|
|
34
|
+
]) {
|
|
35
|
+
const firstPath = pathFromPin(firstTraceId, sharedPinId)
|
|
36
|
+
const secondPath = pathFromPin(secondTraceId, sharedPinId)
|
|
37
|
+
expect(firstPath[1]!.y).toBeCloseTo(secondPath[1]!.y, 6)
|
|
38
|
+
}
|
|
39
|
+
|
|
16
40
|
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
17
41
|
})
|
|
@@ -0,0 +1,27 @@
|
|
|
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 inputProblem from "./assets/repro-smartwatch-power-sheet.input.json"
|
|
6
|
+
|
|
7
|
+
test("smartwatch power sheet", () => {
|
|
8
|
+
const solver = new SchematicTracePipelineSolver(
|
|
9
|
+
inputProblem as unknown as InputProblem,
|
|
10
|
+
{
|
|
11
|
+
hideRatsNet: true,
|
|
12
|
+
},
|
|
13
|
+
)
|
|
14
|
+
solver.solve()
|
|
15
|
+
|
|
16
|
+
const connectorGroundPinIds = new Set([
|
|
17
|
+
"schematic_port_0",
|
|
18
|
+
"schematic_port_11",
|
|
19
|
+
])
|
|
20
|
+
const connectorGroundLabels = solver
|
|
21
|
+
.netLabelToTraceSolver!.getOutput()
|
|
22
|
+
.netLabelPlacements.filter((label) =>
|
|
23
|
+
label.pinIds.some((pinId) => connectorGroundPinIds.has(pinId)),
|
|
24
|
+
)
|
|
25
|
+
expect(connectorGroundLabels).toHaveLength(1)
|
|
26
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
27
|
+
})
|
|
@@ -40,5 +40,29 @@ test("repro: enclosing rectangle collapses into two smaller loops", () => {
|
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
expect(solver.solved).toBe(true)
|
|
43
|
+
const alignedTraces = solver.sameNetJunctionAlignmentSolver!.outputTraces
|
|
44
|
+
const leftBridge = alignedTraces.find(
|
|
45
|
+
(trace) => trace.mspPairId === "schematic_port_c18_1-schematic_port_c17_1",
|
|
46
|
+
)!
|
|
47
|
+
const leftUpperRail = alignedTraces.find(
|
|
48
|
+
(trace) =>
|
|
49
|
+
trace.mspPairId === "schematic_port_q1b_source-schematic_port_c17_1",
|
|
50
|
+
)!
|
|
51
|
+
const rightBridge = alignedTraces.find(
|
|
52
|
+
(trace) => trace.mspPairId === "schematic_port_c18_2-schematic_port_c17_2",
|
|
53
|
+
)!
|
|
54
|
+
const rightLowerRail = alignedTraces.find(
|
|
55
|
+
(trace) =>
|
|
56
|
+
trace.mspPairId === "schematic_port_q2b_drain-schematic_port_c18_2",
|
|
57
|
+
)!
|
|
58
|
+
expect(leftBridge.tracePath[1]!.x).toBeCloseTo(
|
|
59
|
+
leftUpperRail.tracePath[0]!.x,
|
|
60
|
+
6,
|
|
61
|
+
)
|
|
62
|
+
expect(rightBridge.tracePath[1]!.x).toBeCloseTo(
|
|
63
|
+
rightLowerRail.tracePath[0]!.x,
|
|
64
|
+
6,
|
|
65
|
+
)
|
|
66
|
+
|
|
43
67
|
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
44
68
|
})
|
|
@@ -56,6 +56,17 @@ test("marked ground nets retain explicit islands even with identical netIds", ()
|
|
|
56
56
|
)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
+
test("unwired same-component ground pins share a local connection", () => {
|
|
60
|
+
const inputProblem = createInput()
|
|
61
|
+
inputProblem.chips[4]!.pins.push({ pinId: "F", x: 2.2, y: 0.1 })
|
|
62
|
+
inputProblem.netConnections[0]!.pinIds.push("F")
|
|
63
|
+
|
|
64
|
+
const solver = new MspConnectionPairSolver({ inputProblem })
|
|
65
|
+
solver.solve()
|
|
66
|
+
|
|
67
|
+
expect(pairKeys(solver)).toEqual(["A-B", "C-D", "E-F"])
|
|
68
|
+
})
|
|
69
|
+
|
|
59
70
|
test.each([false, undefined])(
|
|
60
71
|
"isGround=%s preserves automatic net routing",
|
|
61
72
|
(isGround) => {
|