@tscircuit/schematic-trace-solver 0.0.159 → 0.0.161
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 +43 -9
- package/dist/index.js +807 -115
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +210 -6
- package/lib/solvers/InlineNetLabelSolver/InlineNetLabelSolver.ts +536 -94
- package/lib/solvers/InlineNetLabelSolver/pushAnchoredNetLabelsAwayFromInlineLabels.ts +9 -7
- package/lib/solvers/InlineNetLabelSolver/pushInlineTerminalLabelsAwayFromAnchoredLabels.ts +295 -0
- package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +7 -35
- package/lib/solvers/SchematicTraceLinesSolver/getTraceConnectedPinComponents.ts +60 -0
- package/lib/solvers/TraceCleanupSolver/sameNetRailAlignment/getFixedLabelCoordinate.ts +44 -13
- package/lib/types/InputProblem.ts +5 -4
- package/package.json +1 -1
- package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260728T144234Z/__snapshots__/bug-report-20260728T144234Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260728T225606Z/__snapshots__/bug-report-20260728T225606Z.snap.svg +79 -79
- package/tests/bug-reports/bug-report-20260730T061837Z/__snapshots__/bug-report-20260730T061837Z.snap.svg +85 -85
- package/tests/bug-reports/bug-report-20260731T052229Z/__snapshots__/bug-report-20260731T052229Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260804T095800Z/__snapshots__/bug-report-20260804T095800Z.snap.svg +163 -163
- package/tests/bug-reports/bug-report-20260804T171919Z/__snapshots__/bug-report-20260804T171919Z.snap.svg +547 -547
- package/tests/bug-reports/bug-report-20260804T225912Z/__snapshots__/bug-report-20260804T225912Z.snap.svg +13 -13
- package/tests/bug-reports/bug-report-20260805T061316Z/__snapshots__/bug-report-20260805T061316Z.snap.svg +267 -267
- package/tests/bug-reports/bug-report-20260806T061548Z/__snapshots__/bug-report-20260806T061548Z.snap.svg +267 -267
- package/tests/bug-reports/bug-report-20260806T093501Z/__snapshots__/bug-report-20260806T093501Z.snap.svg +109 -109
- package/tests/bug-reports/bug-report-20260811T075142Z/__snapshots__/bug-report-20260811T075142Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260815T073240Z/__snapshots__/bug-report-20260815T073240Z.snap.svg +49 -49
- package/tests/bug-reports/bug-report-20260819T091818Z/__snapshots__/bug-report-20260819T091818Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260825T045913Z/__snapshots__/bug-report-20260825T045913Z.snap.svg +103 -103
- package/tests/bug-reports/bug-report-20260825T103621Z/__snapshots__/bug-report-20260825T103621Z.snap.svg +103 -103
- package/tests/bug-reports/bug-report-20260826T072956Z/__snapshots__/bug-report-20260826T072956Z.snap.svg +600 -792
- package/tests/bug-reports/bug-report-20260826T072956Z/bug-report-20260826T072956Z.test.ts +66 -1
- package/tests/examples/__snapshots__/example51.snap.svg +568 -568
- package/tests/fixtures/convertSolverOutputToCircuitJson.test.ts +16 -1
- package/tests/fixtures/convertSolverOutputToCircuitJson.ts +23 -12
- package/tests/repros/__snapshots__/board-1273-trace-overlap-cycle.snap.svg +736 -736
- package/tests/repros/__snapshots__/board-15984-same-net-junction.snap.svg +79 -79
- package/tests/repros/__snapshots__/board1096-usb-label-overlap-iteration.snap.svg +127 -127
- package/tests/repros/__snapshots__/repro-bluetooth-controller-ground-decoupling-groups.snap.svg +106 -0
- package/tests/repros/__snapshots__/repro-board-589-regulator-section.snap.svg +31 -31
- package/tests/repros/__snapshots__/repro-board-648-esp12f-section.snap.svg +121 -121
- package/tests/repros/__snapshots__/repro-bq25895-cross-net-trace-overlap.snap.svg +43 -43
- package/tests/repros/__snapshots__/repro-core-555-power-cross-net-overlap.snap.svg +19 -19
- package/tests/repros/__snapshots__/repro-core-ground-inline-label-fallback.snap.svg +277 -0
- package/tests/repros/__snapshots__/repro-core-subcircuit-missing-ground.snap.svg +19 -19
- package/tests/repros/__snapshots__/repro-core-tb67s579ftg-inline-label-routing.snap.svg +7 -7
- package/tests/repros/__snapshots__/repro-dc-power-isolated-routing.snap.svg +37 -37
- package/tests/repros/__snapshots__/repro-hdc2080-ground-label-alignment.snap.svg +137 -0
- package/tests/repros/__snapshots__/repro-nrf52810-clock-routing.snap.svg +61 -61
- package/tests/repros/__snapshots__/repro-pga300-redundant-ground-traces.snap.svg +115 -115
- package/tests/repros/__snapshots__/repro-pmp11282-isolated-dcdc.snap.svg +743 -743
- package/tests/repros/__snapshots__/repro-rp2040-usb-cc2-ground-overlap.snap.svg +43 -43
- package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +1 -1
- package/tests/repros/__snapshots__/repro-tida010076-j4-ground-bus.snap.svg +17 -17
- package/tests/repros/__snapshots__/repro-tida010076-page02.snap.svg +1131 -1131
- package/tests/repros/__snapshots__/repro-type-c-16pin-self-connection.snap.svg +7 -7
- package/tests/repros/__snapshots__/repro-type-c-16pin-to-resistor.snap.svg +7 -7
- package/tests/repros/__snapshots__/repro-usb-power-vbus-label-detour.snap.svg +666 -666
- package/tests/repros/__snapshots__/repro161-power-section-autolayout.snap.svg +73 -73
- package/tests/repros/__snapshots__/repro48-555-timer-vcc-rail-label.snap.svg +73 -73
- package/tests/repros/assets/repro-bluetooth-controller-ground-decoupling-groups.input.json +214 -0
- package/tests/repros/assets/repro-core-ground-inline-label-fallback.input.json +863 -0
- package/tests/repros/repro-bluetooth-controller-ground-decoupling-groups.test.ts +18 -0
- package/tests/repros/repro-core-ground-inline-label-fallback.test.ts +34 -0
- package/tests/repros/repro-hdc2080-ground-label-alignment.test.ts +239 -0
- package/tests/repros/repro-tida010076-j4-ground-bus.test.ts +14 -10
- package/tests/repros/repro-tida010076-page02.test.ts +2 -2
- package/tests/repros/repro-usb-power-vbus-label-detour.test.ts +14 -0
- package/tests/solvers/InlineNetLabelSolver/__snapshots__/inline-net-label02.snap.svg +1 -1
- package/tests/solvers/InlineNetLabelSolver/multi-pin-connected-components.test.ts +252 -0
- package/tests/solvers/InlineNetLabelSolver/opposite-side-placement.test.ts +71 -0
- package/tests/solvers/InlineNetLabelSolver/push-anchored-net-labels-away.test.ts +8 -2
- package/tests/solvers/InlineNetLabelSolver/push-inline-terminal-labels-away.test.ts +91 -0
- package/tests/solvers/InlineNetLabelSolver/two-pin-terminal-stubs-atomic.test.ts +7 -1
|
@@ -72,6 +72,12 @@ const inputProblem: InputProblem = {
|
|
|
72
72
|
y: 0,
|
|
73
73
|
_facingDirection: "x+",
|
|
74
74
|
},
|
|
75
|
+
{
|
|
76
|
+
pinId: "schematic_port_hidden",
|
|
77
|
+
x: 6,
|
|
78
|
+
y: 0.5,
|
|
79
|
+
_facingDirection: "y+",
|
|
80
|
+
},
|
|
75
81
|
],
|
|
76
82
|
},
|
|
77
83
|
],
|
|
@@ -167,6 +173,11 @@ test("solver snapshot Circuit JSON is semantic and omits the rats nest", () => {
|
|
|
167
173
|
expect(
|
|
168
174
|
circuitJson.filter((element) => element.type === "schematic_component"),
|
|
169
175
|
).toHaveLength(4)
|
|
176
|
+
expect(
|
|
177
|
+
circuitJson
|
|
178
|
+
.filter((element) => element.type === "source_component")
|
|
179
|
+
.map((component) => component.name),
|
|
180
|
+
).toEqual(["U1", "C1", "LED1", ""])
|
|
170
181
|
const genericBoxComponent = circuitJson.find(
|
|
171
182
|
(element) =>
|
|
172
183
|
element.type === "schematic_component" &&
|
|
@@ -237,7 +248,7 @@ test("solver snapshot Circuit JSON is semantic and omits the rats nest", () => {
|
|
|
237
248
|
element.source_component_id === "source_component_3",
|
|
238
249
|
)
|
|
239
250
|
.map((sourcePort) => sourcePort.name),
|
|
240
|
-
).toEqual(["VIN", "VOUT"])
|
|
251
|
+
).toEqual(["VIN", "VOUT", ""])
|
|
241
252
|
|
|
242
253
|
const capacitorPorts = circuitJson
|
|
243
254
|
.filter(
|
|
@@ -278,5 +289,9 @@ test("solver snapshot Circuit JSON is semantic and omits the rats nest", () => {
|
|
|
278
289
|
expect(svg).toContain('data-circuit-json-type="schematic_component"')
|
|
279
290
|
expect(svg).toContain('data-circuit-json-type="schematic_trace"')
|
|
280
291
|
expect(svg).toContain('data-circuit-json-type="schematic_net_label"')
|
|
292
|
+
expect(svg).toContain(">U1</text>")
|
|
293
|
+
expect(svg).toContain(">VCC</text>")
|
|
294
|
+
expect(svg).not.toContain(">schematic_component_3</text>")
|
|
295
|
+
expect(svg).not.toContain(">schematic_port_hidden</text>")
|
|
281
296
|
expect(svg).not.toContain("schematic_port_opaque")
|
|
282
297
|
})
|
|
@@ -184,18 +184,29 @@ const getSnapshotData = (solver: BaseSolver) => {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
const isOpaqueSchematicId = (id: string) =>
|
|
188
|
+
/^(?:schematic|source)_(?:component|port)(?:_|$)/.test(id)
|
|
189
|
+
|
|
187
190
|
const getRefdes = (chip: InputChip) => {
|
|
188
|
-
const pinPrefixes =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const pinPrefixes = chip.pins
|
|
192
|
+
.map((pin) => {
|
|
193
|
+
const separatorIndex = pin.pinId.indexOf(".")
|
|
194
|
+
return separatorIndex > 0 ? pin.pinId.slice(0, separatorIndex) : undefined
|
|
195
|
+
})
|
|
196
|
+
.filter((prefix): prefix is string => Boolean(prefix))
|
|
197
|
+
const uniquePinPrefixes = new Set(pinPrefixes)
|
|
198
|
+
if (pinPrefixes.length === chip.pins.length && uniquePinPrefixes.size === 1) {
|
|
199
|
+
const inferredRefdes = pinPrefixes[0]!
|
|
200
|
+
if (!isOpaqueSchematicId(inferredRefdes)) return inferredRefdes
|
|
201
|
+
}
|
|
202
|
+
if (!isOpaqueSchematicId(chip.chipId)) return chip.chipId
|
|
203
|
+
return ""
|
|
195
204
|
}
|
|
196
205
|
|
|
197
|
-
const getPinLabel = (pinId: string) =>
|
|
198
|
-
|
|
206
|
+
const getPinLabel = (pinId: string) => {
|
|
207
|
+
if (isOpaqueSchematicId(pinId)) return undefined
|
|
208
|
+
return pinId.includes(".") ? pinId.slice(pinId.indexOf(".") + 1) : pinId
|
|
209
|
+
}
|
|
199
210
|
|
|
200
211
|
const getPinDisplayName = (pin: InputPin) => {
|
|
201
212
|
if (pin.displayName !== undefined) return pin.displayName || undefined
|
|
@@ -204,7 +215,7 @@ const getPinDisplayName = (pin: InputPin) => {
|
|
|
204
215
|
|
|
205
216
|
const getPinNumber = (pin: InputPin) => {
|
|
206
217
|
const idLabel = getPinLabel(pin.pinId)
|
|
207
|
-
if (/^\d+$/.test(idLabel)) return Number(idLabel)
|
|
218
|
+
if (idLabel && /^\d+$/.test(idLabel)) return Number(idLabel)
|
|
208
219
|
return pin.displayName && /^\d+$/.test(pin.displayName)
|
|
209
220
|
? Number(pin.displayName)
|
|
210
221
|
: undefined
|
|
@@ -827,7 +838,7 @@ export const convertSolverOutputToCircuitJson = (
|
|
|
827
838
|
symbol_name: symbolName,
|
|
828
839
|
} satisfies SchematicComponent)
|
|
829
840
|
|
|
830
|
-
if (!symbolName) {
|
|
841
|
+
if (!symbolName && refdes) {
|
|
831
842
|
circuitJson.push({
|
|
832
843
|
type: "schematic_text",
|
|
833
844
|
schematic_text_id: `schematic_component_label_${chipIndex}`,
|
|
@@ -874,7 +885,7 @@ export const convertSolverOutputToCircuitJson = (
|
|
|
874
885
|
type: "source_port",
|
|
875
886
|
source_port_id: sourcePortId,
|
|
876
887
|
source_component_id: sourceComponentId,
|
|
877
|
-
name: pinDisplayName ??
|
|
888
|
+
name: pinDisplayName ?? "",
|
|
878
889
|
pin_number: pinNumber,
|
|
879
890
|
} satisfies SourcePort)
|
|
880
891
|
|