@tscircuit/schematic-trace-solver 0.0.172 → 0.0.174
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 +32 -0
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +12 -1
- package/lib/solvers/SameNetJunctionAlignmentSolver/placeGroundRailLabelsAtOuterEnd.ts +49 -0
- package/package.json +1 -1
- package/site/bug-reports/bug-report-20260831T133233Z.page.tsx +4 -0
- package/tests/bug-reports/bug-report-20260721T221026Z/__snapshots__/bug-report-20260721T221026Z.snap.svg +18 -18
- package/tests/bug-reports/bug-report-20260831T133233Z/__snapshots__/bug-report-20260831T133233Z.snap.svg +85 -0
- package/tests/bug-reports/bug-report-20260831T133233Z/bug-report-20260831T133233Z.json +172 -0
- package/tests/bug-reports/bug-report-20260831T133233Z/bug-report-20260831T133233Z.test.ts +25 -0
- package/tests/repros/__snapshots__/repro-bq40z60-current-sense.snap.svg +94 -0
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +10 -10
- package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +87 -87
- package/tests/repros/__snapshots__/repro-tida-01389-hbridge.snap.svg +47 -153
- package/tests/repros/__snapshots__/repro-tida010076-j4-ground-bus.snap.svg +1 -8
- package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +1625 -1681
- package/tests/repros/__snapshots__/repro-tmp1075-ground-label-overlap.snap.svg +3 -3
- package/tests/repros/assets/repro-bq40z60-current-sense.input.json +158 -0
- package/tests/repros/assets/repro-tida-01389-hbridge.input.json +67 -657
- package/tests/repros/assets/repro-tida010076-page02.input.json +2 -0
- package/tests/repros/repro-bq40z60-current-sense.test.ts +18 -0
- package/tests/repros/repro-tida-01389-hbridge.test.ts +27 -6
- package/tests/repros/repro-tida010076-j4-ground-bus.test.ts +1 -0
- package/tests/repros/repro-tmp1075-ground-label-overlap.test.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -9902,6 +9902,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9902
9902
|
if (this.obstacleIndex.doesTracePathCrossChip(connectorTrace)) {
|
|
9903
9903
|
return "chip-collision";
|
|
9904
9904
|
}
|
|
9905
|
+
for (const textBox of this.inputProblem.textBoxes ?? []) {
|
|
9906
|
+
if (tracePathIntersectsBounds(connectorTrace, getTextBoxBounds(textBox))) {
|
|
9907
|
+
return "text-collision";
|
|
9908
|
+
}
|
|
9909
|
+
}
|
|
9905
9910
|
for (const i of this.obstacleIndex.getLabelIndicesNearTracePath(
|
|
9906
9911
|
connectorTrace
|
|
9907
9912
|
)) {
|
|
@@ -13307,6 +13312,33 @@ var placeGroundRailLabelsAtOuterEnd = ({
|
|
|
13307
13312
|
}
|
|
13308
13313
|
}
|
|
13309
13314
|
}
|
|
13315
|
+
for (let index = 0; index < output.length; index++) {
|
|
13316
|
+
const label = output[index];
|
|
13317
|
+
if (label.orientation !== "y-") continue;
|
|
13318
|
+
const connection = inputProblem.netConnections.find(
|
|
13319
|
+
(candidate) => candidate.isGround && candidate.netId === label.netId && candidate.pinIds.length > 2
|
|
13320
|
+
);
|
|
13321
|
+
if (!connection) continue;
|
|
13322
|
+
const anchorPoint = traces.filter((trace) => trace.globalConnNetId === label.globalConnNetId).flatMap((trace) => trace.tracePath).filter(
|
|
13323
|
+
(point) => nearlyEqual(point.x, label.anchorPoint.x) && point.y < label.anchorPoint.y
|
|
13324
|
+
).sort((a, b) => a.y - b.y)[0];
|
|
13325
|
+
if (!anchorPoint) continue;
|
|
13326
|
+
const center = getCenterFromAnchor(
|
|
13327
|
+
anchorPoint,
|
|
13328
|
+
label.orientation,
|
|
13329
|
+
label.width,
|
|
13330
|
+
label.height
|
|
13331
|
+
);
|
|
13332
|
+
const bounds = getRectBounds(center, label.width, label.height);
|
|
13333
|
+
if (obstacles.some((obstacle) => rectsOverlap(bounds, obstacle)) || traceCrossesBoundsInterior(bounds, traceMap) || output.some(
|
|
13334
|
+
(other, otherIndex) => otherIndex !== index && rectsOverlap(
|
|
13335
|
+
bounds,
|
|
13336
|
+
getRectBounds(other.center, other.width, other.height)
|
|
13337
|
+
)
|
|
13338
|
+
))
|
|
13339
|
+
continue;
|
|
13340
|
+
output[index] = { ...label, anchorPoint, center };
|
|
13341
|
+
}
|
|
13310
13342
|
return output;
|
|
13311
13343
|
};
|
|
13312
13344
|
|
|
@@ -18,7 +18,10 @@ import type {
|
|
|
18
18
|
} from "lib/types/InputProblem"
|
|
19
19
|
import { dir, type FacingDirection } from "lib/utils/dir"
|
|
20
20
|
import { getNetLabelWidthForConnection } from "lib/utils/getNetLabelWidthForConnection"
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
getTextBoxBounds,
|
|
23
|
+
rectIntersectsAnyTextBox,
|
|
24
|
+
} from "lib/utils/textBoxBounds"
|
|
22
25
|
import {
|
|
23
26
|
EPS,
|
|
24
27
|
LABEL_SEARCH_STEP,
|
|
@@ -1476,6 +1479,14 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1476
1479
|
return "chip-collision"
|
|
1477
1480
|
}
|
|
1478
1481
|
|
|
1482
|
+
for (const textBox of this.inputProblem.textBoxes ?? []) {
|
|
1483
|
+
if (
|
|
1484
|
+
tracePathIntersectsBounds(connectorTrace, getTextBoxBounds(textBox))
|
|
1485
|
+
) {
|
|
1486
|
+
return "text-collision"
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1479
1490
|
for (const i of this.obstacleIndex.getLabelIndicesNearTracePath(
|
|
1480
1491
|
connectorTrace,
|
|
1481
1492
|
)) {
|
|
@@ -118,5 +118,54 @@ export const placeGroundRailLabelsAtOuterEnd = ({
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
for (let index = 0; index < output.length; index++) {
|
|
123
|
+
const label = output[index]!
|
|
124
|
+
if (label.orientation !== "y-") continue
|
|
125
|
+
// Use producer metadata so ground aliases do not require name matching.
|
|
126
|
+
const connection = inputProblem.netConnections.find(
|
|
127
|
+
(candidate) =>
|
|
128
|
+
candidate.isGround &&
|
|
129
|
+
candidate.netId === label.netId &&
|
|
130
|
+
candidate.pinIds.length > 2,
|
|
131
|
+
)
|
|
132
|
+
if (!connection) continue
|
|
133
|
+
|
|
134
|
+
// Reuse the lowest point on the existing column without changing the trace.
|
|
135
|
+
const anchorPoint = traces
|
|
136
|
+
.filter((trace) => trace.globalConnNetId === label.globalConnNetId)
|
|
137
|
+
.flatMap((trace) => trace.tracePath)
|
|
138
|
+
.filter(
|
|
139
|
+
(point) =>
|
|
140
|
+
nearlyEqual(point.x, label.anchorPoint.x) &&
|
|
141
|
+
point.y < label.anchorPoint.y,
|
|
142
|
+
)
|
|
143
|
+
.sort((a, b) => a.y - b.y)[0]
|
|
144
|
+
if (!anchorPoint) continue
|
|
145
|
+
|
|
146
|
+
const center = getCenterFromAnchor(
|
|
147
|
+
anchorPoint,
|
|
148
|
+
label.orientation,
|
|
149
|
+
label.width,
|
|
150
|
+
label.height,
|
|
151
|
+
)
|
|
152
|
+
const bounds = getRectBounds(center, label.width, label.height)
|
|
153
|
+
// Keep the original anchor when the ground symbol would collide.
|
|
154
|
+
if (
|
|
155
|
+
obstacles.some((obstacle) => rectsOverlap(bounds, obstacle)) ||
|
|
156
|
+
traceCrossesBoundsInterior(bounds, traceMap) ||
|
|
157
|
+
output.some(
|
|
158
|
+
(other, otherIndex) =>
|
|
159
|
+
otherIndex !== index &&
|
|
160
|
+
rectsOverlap(
|
|
161
|
+
bounds,
|
|
162
|
+
getRectBounds(other.center, other.width, other.height),
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
continue
|
|
167
|
+
|
|
168
|
+
output[index] = { ...label, anchorPoint, center }
|
|
169
|
+
}
|
|
121
170
|
return output
|
|
122
171
|
}
|
package/package.json
CHANGED