@tscircuit/checks 0.0.181 → 0.0.183
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 +7 -5
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as circuit_json from 'circuit-json';
|
|
2
|
-
import { AnyCircuitElement, PcbPortNotConnectedError, PcbTraceError, PcbPlacementError, PcbComponentOutsideBoardError, PcbViaClearanceError, PcbTraceWarning, PcbTraceMissingError, PcbFootprintOverlapError, PcbComponentMissingCourtyardWarning, PcbTraceTooLongWarning, PcbPadPadClearanceError, PcbPadTraceClearanceError, PcbViaTraceClearanceError, SourceComponentPinsUnderspecifiedWarning, SourceNoPowerPinDefinedWarning, SourceNoGroundPinDefinedWarning, SchematicComponentStylingWarning, PcbConnectorNotInAccessibleOrientationWarning } from 'circuit-json';
|
|
2
|
+
import { AnyCircuitElement, PcbPortNotConnectedError, PcbTraceError, PcbPlacementError, PcbComponentOutsideBoardError, PcbViaClearanceError, PcbTraceWarning, PcbTraceMissingError, PcbFootprintOverlapError, PcbComponentMissingCourtyardWarning, PcbTraceTooLongWarning, PcbPadPadClearanceError, PcbPadTraceClearanceError, PcbViaTraceClearanceError, SourceComponentMisconfiguredError, SourceComponentPinsUnderspecifiedWarning, SourceNoPowerPinDefinedWarning, SourceNoGroundPinDefinedWarning, SchematicComponentStylingWarning, PcbConnectorNotInAccessibleOrientationWarning } from 'circuit-json';
|
|
3
3
|
import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
|
|
4
4
|
|
|
5
5
|
declare function checkEachPcbPortConnectedToPcbTraces(circuitJson: AnyCircuitElement[]): PcbPortNotConnectedError[];
|
|
@@ -142,6 +142,8 @@ type SourcePinMustBeConnectedError = {
|
|
|
142
142
|
*/
|
|
143
143
|
declare function checkPinMustBeConnected(circuitJson: AnyCircuitElement[]): SourcePinMustBeConnectedError[];
|
|
144
144
|
|
|
145
|
+
declare function checkTwoTerminalSwitchContactsOnDifferentNets(circuitJson: AnyCircuitElement[]): SourceComponentMisconfiguredError[];
|
|
146
|
+
|
|
145
147
|
/**
|
|
146
148
|
* Check that each component with ports has at least one pin attribute
|
|
147
149
|
* specified across its ports. Returns a warning when all pins are
|
|
@@ -182,7 +184,7 @@ declare function checkSchematicComponentMissingReferenceDesignatorText(circuitJs
|
|
|
182
184
|
declare function checkSchematicComponentPortsOutsideBody(circuitJson: AnyCircuitElement[]): SchematicComponentStylingWarning[];
|
|
183
185
|
|
|
184
186
|
declare function runAllPlacementChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.PcbPlacementError | circuit_json.PcbComponentOutsideBoardError | circuit_json.PcbFootprintOverlapError | circuit_json.PcbComponentMissingCourtyardWarning | circuit_json.PcbPadPadClearanceError | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
|
|
185
|
-
declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<{
|
|
187
|
+
declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<({
|
|
186
188
|
type: "source_pin_must_be_connected_error";
|
|
187
189
|
source_pin_must_be_connected_error_id: string;
|
|
188
190
|
error_type: "source_pin_must_be_connected_error";
|
|
@@ -190,7 +192,7 @@ declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<
|
|
|
190
192
|
source_component_id: string;
|
|
191
193
|
source_port_id: string;
|
|
192
194
|
subcircuit_id?: string;
|
|
193
|
-
}[]>;
|
|
195
|
+
} | circuit_json.SourceComponentMisconfiguredError)[]>;
|
|
194
196
|
declare function runAllSchematicChecks(circuitJson: AnyCircuitElement[]): Promise<circuit_json.SchematicComponentStylingWarning[]>;
|
|
195
197
|
declare function runAllPinSpecificationChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning)[]>;
|
|
196
198
|
declare function runAllRoutingChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.PcbPortNotConnectedError | circuit_json.PcbTraceError | circuit_json.PcbViaClearanceError | circuit_json.PcbTraceMissingError | circuit_json.PcbTraceTooLongWarning | circuit_json.PcbPadPadClearanceError | circuit_json.PcbPadTraceClearanceError | circuit_json.PcbViaTraceClearanceError)[]>;
|
|
@@ -202,7 +204,7 @@ declare function runAllChecks(circuitJson: AnyCircuitElement[]): Promise<(circui
|
|
|
202
204
|
source_component_id: string;
|
|
203
205
|
source_port_id: string;
|
|
204
206
|
subcircuit_id?: string;
|
|
205
|
-
} | circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning | circuit_json.SchematicComponentStylingWarning | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
|
|
207
|
+
} | circuit_json.SourceComponentMisconfiguredError | circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning | circuit_json.SchematicComponentStylingWarning | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
|
|
206
208
|
|
|
207
209
|
declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElement[]): PcbConnectorNotInAccessibleOrientationWarning[];
|
|
208
210
|
|
|
@@ -213,4 +215,4 @@ declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElem
|
|
|
213
215
|
*/
|
|
214
216
|
declare function checkTestPointAccessibility(circuitJson: AnyCircuitElement[]): PcbPlacementError[];
|
|
215
217
|
|
|
216
|
-
export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsMissingCourtyard, checkPcbComponentsOutOfBoard, checkPcbCopperOverKeepout, checkPcbTraceLengths, checkPcbTraceViaCounts, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNetViaSpacing, checkSchematicComponentExcessiveVerticalPadding, checkSchematicComponentMissingReferenceDesignatorText, checkSchematicComponentPortsOutsideBody, checkSourceTracesHavePcbTraces, checkSourceTracesMatchPcbTraceThickness, checkTestPointAccessibility, checkTracesAreContiguous, checkViaPadClearance, checkViaTraceClearance, checkViasInPads, checkViasOffBoard, dedupePcbDrcErrors, runAllChecks, runAllNetlistChecks, runAllPinSpecificationChecks, runAllPlacementChecks, runAllRoutingChecks, runAllSchematicChecks };
|
|
218
|
+
export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsMissingCourtyard, checkPcbComponentsOutOfBoard, checkPcbCopperOverKeepout, checkPcbTraceLengths, checkPcbTraceViaCounts, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNetViaSpacing, checkSchematicComponentExcessiveVerticalPadding, checkSchematicComponentMissingReferenceDesignatorText, checkSchematicComponentPortsOutsideBody, checkSourceTracesHavePcbTraces, checkSourceTracesMatchPcbTraceThickness, checkTestPointAccessibility, checkTracesAreContiguous, checkTwoTerminalSwitchContactsOnDifferentNets, checkViaPadClearance, checkViaTraceClearance, checkViasInPads, checkViasOffBoard, dedupePcbDrcErrors, runAllChecks, runAllNetlistChecks, runAllPinSpecificationChecks, runAllPlacementChecks, runAllRoutingChecks, runAllSchematicChecks };
|
package/dist/index.js
CHANGED
|
@@ -607,6 +607,14 @@ var getBoardDrcValue = (board, key) => board?.[key];
|
|
|
607
607
|
// lib/check-pad-clearance/common.ts
|
|
608
608
|
var getPadBounds = (pad) => {
|
|
609
609
|
if (pad.type === "pcb_keepout") {
|
|
610
|
+
if (pad.shape === "outline") {
|
|
611
|
+
return {
|
|
612
|
+
minX: Math.min(...pad.outline.map((point) => point.x)),
|
|
613
|
+
minY: Math.min(...pad.outline.map((point) => point.y)),
|
|
614
|
+
maxX: Math.max(...pad.outline.map((point) => point.x)),
|
|
615
|
+
maxY: Math.max(...pad.outline.map((point) => point.y))
|
|
616
|
+
};
|
|
617
|
+
}
|
|
610
618
|
if (pad.shape === "circle") {
|
|
611
619
|
return {
|
|
612
620
|
minX: pad.center.x - pad.radius,
|
|
@@ -625,7 +633,7 @@ var getPadBounds = (pad) => {
|
|
|
625
633
|
return getBoundsOfPcbElements2([pad]);
|
|
626
634
|
};
|
|
627
635
|
var getPadCenter = (pad) => {
|
|
628
|
-
if (pad.type === "pcb_keepout") return pad.center;
|
|
636
|
+
if (pad.type === "pcb_keepout" && pad.shape !== "outline") return pad.center;
|
|
629
637
|
const bounds = getPadBounds(pad);
|
|
630
638
|
return midpoint(
|
|
631
639
|
{ x: bounds.minX, y: bounds.minY },
|
|
@@ -650,6 +658,12 @@ var getCircleShape = (pad) => {
|
|
|
650
658
|
};
|
|
651
659
|
var getPolygonShape = (pad) => {
|
|
652
660
|
if (pad.type === "pcb_keepout") {
|
|
661
|
+
if (pad.shape === "outline") {
|
|
662
|
+
return {
|
|
663
|
+
kind: "polygon",
|
|
664
|
+
points: pad.outline
|
|
665
|
+
};
|
|
666
|
+
}
|
|
653
667
|
if (pad.shape !== "rect") {
|
|
654
668
|
throw new Error(`Expected rectangular keepout, got ${pad.shape}`);
|
|
655
669
|
}
|
|
@@ -2378,6 +2392,7 @@ function checkPcbComponentOverCutout(circuitJson) {
|
|
|
2378
2392
|
height: component.height
|
|
2379
2393
|
});
|
|
2380
2394
|
for (const { cutout, polygon: cutoutPolygon } of cutoutPolygons) {
|
|
2395
|
+
if (cutout.pcb_component_id === component.pcb_component_id) continue;
|
|
2381
2396
|
if (!doPolygonsOverlap(componentPolygon, cutoutPolygon)) continue;
|
|
2382
2397
|
const componentName = getReadableNameForComponent(
|
|
2383
2398
|
circuitJson,
|
|
@@ -3899,6 +3914,51 @@ function checkPinMustBeConnected(circuitJson) {
|
|
|
3899
3914
|
return errors;
|
|
3900
3915
|
}
|
|
3901
3916
|
|
|
3917
|
+
// lib/check-two-terminal-switch-contacts-on-different-nets.ts
|
|
3918
|
+
import {
|
|
3919
|
+
source_component_misconfigured_error
|
|
3920
|
+
} from "circuit-json";
|
|
3921
|
+
function checkTwoTerminalSwitchContactsOnDifferentNets(circuitJson) {
|
|
3922
|
+
const switchingComponents = circuitJson.filter(
|
|
3923
|
+
(element) => element.type === "source_component" && (element.ftype === "simple_push_button" || element.ftype === "simple_switch")
|
|
3924
|
+
);
|
|
3925
|
+
const sourcePorts = circuitJson.filter(
|
|
3926
|
+
(element) => element.type === "source_port"
|
|
3927
|
+
);
|
|
3928
|
+
const schematicPorts = circuitJson.filter(
|
|
3929
|
+
(element) => element.type === "schematic_port"
|
|
3930
|
+
);
|
|
3931
|
+
const errors = [];
|
|
3932
|
+
for (const switchingComponent of switchingComponents) {
|
|
3933
|
+
const schematicContactSourcePorts = schematicPorts.flatMap(
|
|
3934
|
+
(schematicPort) => {
|
|
3935
|
+
const sourcePort = sourcePorts.find(
|
|
3936
|
+
(sourcePort2) => sourcePort2.source_port_id === schematicPort.source_port_id && sourcePort2.source_component_id === switchingComponent.source_component_id
|
|
3937
|
+
);
|
|
3938
|
+
if (!sourcePort) return [];
|
|
3939
|
+
return [sourcePort];
|
|
3940
|
+
}
|
|
3941
|
+
);
|
|
3942
|
+
if (schematicContactSourcePorts.length !== 2) continue;
|
|
3943
|
+
const firstContactConnectivityKey = schematicContactSourcePorts[0].subcircuit_connectivity_map_key;
|
|
3944
|
+
const secondContactConnectivityKey = schematicContactSourcePorts[1].subcircuit_connectivity_map_key;
|
|
3945
|
+
if (!firstContactConnectivityKey) continue;
|
|
3946
|
+
if (firstContactConnectivityKey !== secondContactConnectivityKey) continue;
|
|
3947
|
+
errors.push(
|
|
3948
|
+
source_component_misconfigured_error.parse({
|
|
3949
|
+
type: "source_component_misconfigured_error",
|
|
3950
|
+
message: `Switch ${switchingComponent.name} has both schematic contacts connected to the same net. Check internallyConnectedPins and the footprint pin mapping.`,
|
|
3951
|
+
source_component_ids: [switchingComponent.source_component_id],
|
|
3952
|
+
source_port_ids: schematicContactSourcePorts.map(
|
|
3953
|
+
(sourcePort) => sourcePort.source_port_id
|
|
3954
|
+
),
|
|
3955
|
+
is_fatal: true
|
|
3956
|
+
})
|
|
3957
|
+
);
|
|
3958
|
+
}
|
|
3959
|
+
return errors;
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3902
3962
|
// lib/check-all-pins-in-component-are-underspecified.ts
|
|
3903
3963
|
import { cju as cju7 } from "@tscircuit/circuit-json-util";
|
|
3904
3964
|
var PIN_ATTRIBUTE_KEYS = [
|
|
@@ -4583,7 +4643,10 @@ async function runAllPlacementChecks(circuitJson) {
|
|
|
4583
4643
|
];
|
|
4584
4644
|
}
|
|
4585
4645
|
async function runAllNetlistChecks(circuitJson) {
|
|
4586
|
-
return [
|
|
4646
|
+
return [
|
|
4647
|
+
...checkPinMustBeConnected(circuitJson),
|
|
4648
|
+
...checkTwoTerminalSwitchContactsOnDifferentNets(circuitJson)
|
|
4649
|
+
];
|
|
4587
4650
|
}
|
|
4588
4651
|
async function runAllSchematicChecks(circuitJson) {
|
|
4589
4652
|
return [
|
|
@@ -4653,6 +4716,7 @@ export {
|
|
|
4653
4716
|
checkSourceTracesMatchPcbTraceThickness,
|
|
4654
4717
|
checkTestPointAccessibility,
|
|
4655
4718
|
checkTracesAreContiguous,
|
|
4719
|
+
checkTwoTerminalSwitchContactsOnDifferentNets,
|
|
4656
4720
|
checkViaPadClearance,
|
|
4657
4721
|
checkViaTraceClearance,
|
|
4658
4722
|
checkViasInPads,
|