@tscircuit/checks 0.0.182 → 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 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
@@ -3914,6 +3914,51 @@ function checkPinMustBeConnected(circuitJson) {
3914
3914
  return errors;
3915
3915
  }
3916
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
+
3917
3962
  // lib/check-all-pins-in-component-are-underspecified.ts
3918
3963
  import { cju as cju7 } from "@tscircuit/circuit-json-util";
3919
3964
  var PIN_ATTRIBUTE_KEYS = [
@@ -4598,7 +4643,10 @@ async function runAllPlacementChecks(circuitJson) {
4598
4643
  ];
4599
4644
  }
4600
4645
  async function runAllNetlistChecks(circuitJson) {
4601
- return [...checkPinMustBeConnected(circuitJson)];
4646
+ return [
4647
+ ...checkPinMustBeConnected(circuitJson),
4648
+ ...checkTwoTerminalSwitchContactsOnDifferentNets(circuitJson)
4649
+ ];
4602
4650
  }
4603
4651
  async function runAllSchematicChecks(circuitJson) {
4604
4652
  return [
@@ -4668,6 +4716,7 @@ export {
4668
4716
  checkSourceTracesMatchPcbTraceThickness,
4669
4717
  checkTestPointAccessibility,
4670
4718
  checkTracesAreContiguous,
4719
+ checkTwoTerminalSwitchContactsOnDifferentNets,
4671
4720
  checkViaPadClearance,
4672
4721
  checkViaTraceClearance,
4673
4722
  checkViasInPads,