@tscircuit/checks 0.0.160 → 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/README.md CHANGED
@@ -14,6 +14,7 @@ and output an array of arrays for any issues found.
14
14
  | [`checkAllPinsInComponentAreUnderspecified`](./lib/check-all-pins-in-component-are-underspecified.ts) | Returns `source_component_pins_underspecified_warning` when every pin on a chip lacks pin attributes. |
15
15
  | [`checkNoPowerPinDefined`](./lib/check-no-power-pin-defined.ts) | Returns `source_no_power_pin_defined_warning` when a chip has no pin with `requires_power=true`. |
16
16
  | [`checkNoGroundPinDefined`](./lib/check-no-ground-pin-defined.ts) | Returns `source_no_ground_pin_defined_warning` when a chip has no pin with `requires_ground=true`. |
17
+ | [`checkSchematicComponentExcessiveVerticalPadding`](./lib/check-schematic-component-excessive-vertical-padding.ts) | Returns a `schematic_component_styling_warning` with `styling_issue_type: "excessive_top_padding"` or `"excessive_bottom_padding"` when a box-style component has more than three pin spacings of empty space above or below its left/right pins. |
17
18
  | [`checkDifferentNetViaSpacing`](./lib/check-different-net-via-spacing.ts) | Returns `pcb_via_clearance_error` if vias on different nets are too close together. |
18
19
  | [`checkEachPcbPortConnectedToPcbTraces`](./lib/check-each-pcb-port-connected-to-pcb-trace.ts) | Returns `pcb_trace_error` if any `source_port` is not connected to its corresponding PCB traces. |
19
20
  | [`checkEachPcbTraceNonOverlapping`](./lib/check-each-pcb-trace-non-overlapping/check-each-pcb-trace-non-overlapping.ts) | Returns `pcb_trace_error` when `pcb_trace` segments physically overlap incompatible geometry on the same layer. Pad/via near-misses are reported by the typed clearance checks instead. |
@@ -36,8 +37,9 @@ and output an array of arrays for any issues found.
36
37
  | [`runAllPlacementChecks`](./lib/run-all-checks.ts) | Runs placement checks (`checkCopperToBoardEdgeClearance`, `checkPcbComponentsOutOfBoard`, `checkPcbComponentOverlap`, `checkPadPadClearance`, `checkCourtyardOverlap`, `checkConnectorAccessibleOrientation`, and `checkTestPointAccessibility`). |
37
38
  | [`runAllNetlistChecks`](./lib/run-all-checks.ts) | Runs netlist connectivity checks (currently `checkPinMustBeConnected`). |
38
39
  | [`runAllPinSpecificationChecks`](./lib/run-all-checks.ts) | Runs pin specification checks (e.g. `checkAllPinsInComponentAreUnderspecified`, `checkNoPowerPinDefined`, and `checkNoGroundPinDefined`). |
40
+ | [`runAllSchematicChecks`](./lib/run-all-checks.ts) | Runs schematic-layout checks (currently `checkSchematicComponentExcessiveVerticalPadding`). |
39
41
  | [`runAllRoutingChecks`](./lib/run-all-checks.ts) | Runs all routing checks currently enabled (`checkEachPcbPortConnectedToPcbTraces`, `checkSourceTracesHavePcbTraces`, `checkEachPcbTraceNonOverlapping`, `checkPadTraceClearance`, `checkViaTraceClearance`, same/different net via spacing, and `checkPcbTracesOutOfBoard`). Trace-obstacle pairs are classified before aggregation, so each pair produces one overlap or clearance diagnostic, never both. |
40
- | [`runAllChecks`](./lib/run-all-checks.ts) | Runs placement, netlist, pin specification, and routing checks and returns a combined list of issues. |
42
+ | [`runAllChecks`](./lib/run-all-checks.ts) | Runs placement, schematic, netlist, pin specification, and routing checks and returns a combined list of issues. |
41
43
 
42
44
  ## Implementation Details
43
45
 
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, PcbTraceTooLongWarning, PcbPadPadClearanceError, PcbPadTraceClearanceError, PcbViaTraceClearanceError, SourceComponentPinsUnderspecifiedWarning, SourceNoPowerPinDefinedWarning, SourceNoGroundPinDefinedWarning, PcbConnectorNotInAccessibleOrientationWarning } from 'circuit-json';
2
+ import { AnyCircuitElement, PcbPortNotConnectedError, PcbTraceError, PcbPlacementError, PcbComponentOutsideBoardError, PcbViaClearanceError, PcbTraceWarning, PcbTraceMissingError, PcbFootprintOverlapError, PcbTraceTooLongWarning, PcbPadPadClearanceError, PcbPadTraceClearanceError, PcbViaTraceClearanceError, 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[];
@@ -152,6 +152,13 @@ declare function checkNoPowerPinDefined(circuitJson: AnyCircuitElement[]): Sourc
152
152
  */
153
153
  declare function checkNoGroundPinDefined(circuitJson: AnyCircuitElement[]): SourceNoGroundPinDefinedWarning[];
154
154
 
155
+ /**
156
+ * Warns when the left/right pins of a box-style schematic component leave
157
+ * excessive empty space above or below their vertical span. This commonly
158
+ * happens when an unnecessarily large schematic height is set on a component.
159
+ */
160
+ declare function checkSchematicComponentExcessiveVerticalPadding(circuitJson: AnyCircuitElement[]): SchematicComponentStylingWarning[];
161
+
155
162
  declare function runAllPlacementChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.PcbPlacementError | circuit_json.PcbComponentOutsideBoardError | circuit_json.PcbFootprintOverlapError | circuit_json.PcbPadPadClearanceError | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
156
163
  declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<{
157
164
  type: "source_pin_must_be_connected_error";
@@ -162,6 +169,7 @@ declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<
162
169
  source_port_id: string;
163
170
  subcircuit_id?: string;
164
171
  }[]>;
172
+ declare function runAllSchematicChecks(circuitJson: AnyCircuitElement[]): Promise<circuit_json.SchematicComponentStylingWarning[]>;
165
173
  declare function runAllPinSpecificationChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning)[]>;
166
174
  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)[]>;
167
175
  declare function runAllChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.PcbPortNotConnectedError | circuit_json.PcbTraceError | circuit_json.PcbPlacementError | circuit_json.PcbComponentOutsideBoardError | circuit_json.PcbViaClearanceError | circuit_json.PcbTraceMissingError | circuit_json.PcbFootprintOverlapError | circuit_json.PcbTraceTooLongWarning | circuit_json.PcbPadPadClearanceError | circuit_json.PcbPadTraceClearanceError | circuit_json.PcbViaTraceClearanceError | {
@@ -172,7 +180,7 @@ declare function runAllChecks(circuitJson: AnyCircuitElement[]): Promise<(circui
172
180
  source_component_id: string;
173
181
  source_port_id: string;
174
182
  subcircuit_id?: string;
175
- } | circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
183
+ } | circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning | circuit_json.SchematicComponentStylingWarning | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
176
184
 
177
185
  declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElement[]): PcbConnectorNotInAccessibleOrientationWarning[];
178
186
 
@@ -183,4 +191,4 @@ declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElem
183
191
  */
184
192
  declare function checkTestPointAccessibility(circuitJson: AnyCircuitElement[]): PcbPlacementError[];
185
193
 
186
- export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsOutOfBoard, checkPcbTraceLengths, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNetViaSpacing, checkSourceTracesHavePcbTraces, checkSourceTracesMatchPcbTraceThickness, checkTestPointAccessibility, checkTracesAreContiguous, checkViaPadClearance, checkViaTraceClearance, checkViasInPads, checkViasOffBoard, dedupePcbDrcErrors, runAllChecks, runAllNetlistChecks, runAllPinSpecificationChecks, runAllPlacementChecks, runAllRoutingChecks };
194
+ export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsOutOfBoard, checkPcbTraceLengths, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNetViaSpacing, checkSchematicComponentExcessiveVerticalPadding, checkSourceTracesHavePcbTraces, checkSourceTracesMatchPcbTraceThickness, checkTestPointAccessibility, checkTracesAreContiguous, checkViaPadClearance, checkViaTraceClearance, checkViasInPads, checkViasOffBoard, dedupePcbDrcErrors, runAllChecks, runAllNetlistChecks, runAllPinSpecificationChecks, runAllPlacementChecks, runAllRoutingChecks, runAllSchematicChecks };
package/dist/index.js CHANGED
@@ -3557,6 +3557,77 @@ function checkNoGroundPinDefined(circuitJson) {
3557
3557
  return warnings;
3558
3558
  }
3559
3559
 
3560
+ // lib/check-schematic-component-excessive-vertical-padding.ts
3561
+ var DEFAULT_PIN_SPACING = 0.2;
3562
+ var MAX_VERTICAL_PADDING_IN_PIN_SPACINGS = 3;
3563
+ var FLOATING_POINT_TOLERANCE = 1e-9;
3564
+ function checkSchematicComponentExcessiveVerticalPadding(circuitJson) {
3565
+ const schematicComponents = circuitJson.filter(
3566
+ (element) => element.type === "schematic_component"
3567
+ );
3568
+ const schematicPorts = circuitJson.filter(
3569
+ (element) => element.type === "schematic_port"
3570
+ );
3571
+ const sourceComponents = circuitJson.filter(
3572
+ (element) => element.type === "source_component"
3573
+ );
3574
+ const sourceComponentById = new Map(
3575
+ sourceComponents.map((component) => [
3576
+ component.source_component_id,
3577
+ component
3578
+ ])
3579
+ );
3580
+ const portsByComponentId = /* @__PURE__ */ new Map();
3581
+ for (const port of schematicPorts) {
3582
+ if (!port.schematic_component_id) continue;
3583
+ const componentPorts = portsByComponentId.get(port.schematic_component_id) ?? [];
3584
+ componentPorts.push(port);
3585
+ portsByComponentId.set(port.schematic_component_id, componentPorts);
3586
+ }
3587
+ const warnings = [];
3588
+ for (const component of schematicComponents) {
3589
+ if (!component.is_box_with_pins || component.size.height <= 0) continue;
3590
+ const sidePorts = (portsByComponentId.get(component.schematic_component_id) ?? []).filter(
3591
+ (port) => port.side_of_component === "left" || port.side_of_component === "right"
3592
+ );
3593
+ if (sidePorts.length < 2) continue;
3594
+ const pinYs = sidePorts.map((port) => port.center.y);
3595
+ const highestPinY = Math.max(...pinYs);
3596
+ const lowestPinY = Math.min(...pinYs);
3597
+ const componentTopY = component.center.y + component.size.height / 2;
3598
+ const componentBottomY = component.center.y - component.size.height / 2;
3599
+ const pinSpacing = component.pin_spacing ?? DEFAULT_PIN_SPACING;
3600
+ const maximumPadding = pinSpacing * MAX_VERTICAL_PADDING_IN_PIN_SPACINGS;
3601
+ const paddingBySide = {
3602
+ top: componentTopY - highestPinY,
3603
+ bottom: lowestPinY - componentBottomY
3604
+ };
3605
+ const sourceComponent = component.source_component_id ? sourceComponentById.get(component.source_component_id) : void 0;
3606
+ const componentName = sourceComponent?.name ?? component.schematic_component_id;
3607
+ for (const side of ["top", "bottom"]) {
3608
+ const padding = paddingBySide[side];
3609
+ if (padding <= maximumPadding + FLOATING_POINT_TOLERANCE || padding <= 0) {
3610
+ continue;
3611
+ }
3612
+ const relativePosition = side === "top" ? "above" : "below";
3613
+ const stylingIssueType = `excessive_${side}_padding`;
3614
+ warnings.push({
3615
+ type: "schematic_component_styling_warning",
3616
+ schematic_component_styling_warning_id: `schematic_component_styling_warning_${component.schematic_component_id}_${stylingIssueType}`,
3617
+ warning_type: "schematic_component_styling_warning",
3618
+ message: `${componentName} has excessive empty space ${relativePosition} its pins (${padding.toFixed(2)}mm, more than ${MAX_VERTICAL_PADDING_IN_PIN_SPACINGS} pin spacings)`,
3619
+ schematic_component_id: component.schematic_component_id,
3620
+ styling_issue_type: stylingIssueType,
3621
+ schematic_port_ids: sidePorts.map((port) => port.schematic_port_id),
3622
+ source_component_id: component.source_component_id,
3623
+ schematic_sheet_id: component.schematic_sheet_id,
3624
+ subcircuit_id: component.subcircuit_id
3625
+ });
3626
+ }
3627
+ }
3628
+ return warnings;
3629
+ }
3630
+
3560
3631
  // lib/check-connector-accessible-orientation.ts
3561
3632
  import { getBoardBounds } from "@tscircuit/circuit-json-util";
3562
3633
  function getFacingDirectionFromInsertionDirection(component) {
@@ -3841,6 +3912,9 @@ async function runAllPlacementChecks(circuitJson) {
3841
3912
  async function runAllNetlistChecks(circuitJson) {
3842
3913
  return [...checkPinMustBeConnected(circuitJson)];
3843
3914
  }
3915
+ async function runAllSchematicChecks(circuitJson) {
3916
+ return checkSchematicComponentExcessiveVerticalPadding(circuitJson);
3917
+ }
3844
3918
  async function runAllPinSpecificationChecks(circuitJson) {
3845
3919
  return [
3846
3920
  ...checkAllPinsInComponentAreUnderspecified(circuitJson),
@@ -3866,6 +3940,7 @@ async function runAllRoutingChecks(circuitJson) {
3866
3940
  async function runAllChecks(circuitJson) {
3867
3941
  return [
3868
3942
  ...await runAllPlacementChecks(circuitJson),
3943
+ ...await runAllSchematicChecks(circuitJson),
3869
3944
  ...await runAllNetlistChecks(circuitJson),
3870
3945
  ...await runAllPinSpecificationChecks(circuitJson),
3871
3946
  ...await runAllRoutingChecks(circuitJson)
@@ -3890,6 +3965,7 @@ export {
3890
3965
  checkPcbTracesOutOfBoard,
3891
3966
  checkPinMustBeConnected,
3892
3967
  checkSameNetViaSpacing,
3968
+ checkSchematicComponentExcessiveVerticalPadding,
3893
3969
  checkSourceTracesHavePcbTraces,
3894
3970
  checkSourceTracesMatchPcbTraceThickness,
3895
3971
  checkTestPointAccessibility,
@@ -3903,6 +3979,7 @@ export {
3903
3979
  runAllNetlistChecks,
3904
3980
  runAllPinSpecificationChecks,
3905
3981
  runAllPlacementChecks,
3906
- runAllRoutingChecks
3982
+ runAllRoutingChecks,
3983
+ runAllSchematicChecks
3907
3984
  };
3908
3985
  //# sourceMappingURL=index.js.map