@tscircuit/checks 0.0.178 → 0.0.179

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
@@ -15,6 +15,7 @@ and output an array of arrays for any issues found.
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
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. |
18
+ | [`checkSchematicComponentMissingReferenceDesignatorText`](./lib/check-schematic-component-missing-reference-designator-text.ts) | Returns a `schematic_component_styling_warning` with `styling_issue_type: "missing_reference_designator_text"` when a schematic component has no attached text matching its reference designator or display-name override. |
18
19
  | [`checkSchematicComponentPortsOutsideBody`](./lib/check-schematic-component-ports-outside-body.ts) | Returns a `schematic_component_styling_warning` with `styling_issue_type: "ports_outside_body"` when pins fall beyond the body edge they enter, with an actionable minimum `schHeight` or `schWidth`. |
19
20
  | [`checkDifferentNetViaSpacing`](./lib/check-different-net-via-spacing.ts) | Returns `pcb_via_clearance_error` if vias on different nets are too close together. |
20
21
  | [`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. |
@@ -39,7 +40,7 @@ and output an array of arrays for any issues found.
39
40
  | [`runAllPlacementChecks`](./lib/run-all-checks.ts) | Runs placement checks (`checkCopperToBoardEdgeClearance`, `checkPcbComponentsOutOfBoard`, `checkPcbCopperOverKeepout`, `checkPcbComponentOverlap`, `checkPadPadClearance`, `checkCourtyardOverlap`, `checkConnectorAccessibleOrientation`, and `checkTestPointAccessibility`). |
40
41
  | [`runAllNetlistChecks`](./lib/run-all-checks.ts) | Runs netlist connectivity checks (currently `checkPinMustBeConnected`). |
41
42
  | [`runAllPinSpecificationChecks`](./lib/run-all-checks.ts) | Runs pin specification checks (e.g. `checkAllPinsInComponentAreUnderspecified`, `checkNoPowerPinDefined`, and `checkNoGroundPinDefined`). |
42
- | [`runAllSchematicChecks`](./lib/run-all-checks.ts) | Runs schematic-layout checks (currently `checkSchematicComponentExcessiveVerticalPadding`). |
43
+ | [`runAllSchematicChecks`](./lib/run-all-checks.ts) | Runs schematic-layout checks (`checkSchematicComponentExcessiveVerticalPadding`, `checkSchematicComponentMissingReferenceDesignatorText`, and `checkSchematicComponentPortsOutsideBody`). |
43
44
  | [`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. |
44
45
  | [`runAllChecks`](./lib/run-all-checks.ts) | Runs placement, schematic, netlist, pin specification, and routing checks and returns a combined list of issues. |
45
46
 
package/dist/index.d.ts CHANGED
@@ -168,6 +168,12 @@ declare function checkNoGroundPinDefined(circuitJson: AnyCircuitElement[]): Sour
168
168
  */
169
169
  declare function checkSchematicComponentExcessiveVerticalPadding(circuitJson: AnyCircuitElement[]): SchematicComponentStylingWarning[];
170
170
 
171
+ /**
172
+ * Warns when a schematic component does not have attached text displaying its
173
+ * reference designator (or the component's display-name override).
174
+ */
175
+ declare function checkSchematicComponentMissingReferenceDesignatorText(circuitJson: AnyCircuitElement[]): SchematicComponentStylingWarning[];
176
+
171
177
  /**
172
178
  * Warns when a box-style component's pins are positioned beyond the body edge
173
179
  * they enter. Left/right pins are checked against the body's vertical span,
@@ -207,4 +213,4 @@ declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElem
207
213
  */
208
214
  declare function checkTestPointAccessibility(circuitJson: AnyCircuitElement[]): PcbPlacementError[];
209
215
 
210
- export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsMissingCourtyard, checkPcbComponentsOutOfBoard, checkPcbCopperOverKeepout, checkPcbTraceLengths, checkPcbTraceViaCounts, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNetViaSpacing, checkSchematicComponentExcessiveVerticalPadding, checkSchematicComponentPortsOutsideBody, checkSourceTracesHavePcbTraces, checkSourceTracesMatchPcbTraceThickness, checkTestPointAccessibility, checkTracesAreContiguous, checkViaPadClearance, checkViaTraceClearance, checkViasInPads, checkViasOffBoard, dedupePcbDrcErrors, runAllChecks, runAllNetlistChecks, runAllPinSpecificationChecks, runAllPlacementChecks, runAllRoutingChecks, runAllSchematicChecks };
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 };
package/dist/index.js CHANGED
@@ -4120,6 +4120,85 @@ function checkSchematicComponentExcessiveVerticalPadding(circuitJson) {
4120
4120
  return warnings;
4121
4121
  }
4122
4122
 
4123
+ // lib/check-schematic-component-missing-reference-designator-text.ts
4124
+ var isFallbackReferenceDesignator = (name) => /^unnamed_[a-z0-9_-]+\d+$/i.test(name);
4125
+ var isTextWithinComponentBounds = (schematicText, schematicComponent) => {
4126
+ const { center, size } = schematicComponent;
4127
+ const tolerance = 1e-9;
4128
+ return schematicText.position.x >= center.x - size.width / 2 - tolerance && schematicText.position.x <= center.x + size.width / 2 + tolerance && schematicText.position.y >= center.y - size.height / 2 - tolerance && schematicText.position.y <= center.y + size.height / 2 + tolerance;
4129
+ };
4130
+ function checkSchematicComponentMissingReferenceDesignatorText(circuitJson) {
4131
+ const schematicComponents = circuitJson.filter(
4132
+ (element) => element.type === "schematic_component"
4133
+ );
4134
+ const sourceComponents = circuitJson.filter(
4135
+ (element) => element.type === "source_component"
4136
+ );
4137
+ const schematicTexts = circuitJson.filter(
4138
+ (element) => element.type === "schematic_text"
4139
+ );
4140
+ const sourceComponentById = new Map(
4141
+ sourceComponents.map((component) => [
4142
+ component.source_component_id,
4143
+ component
4144
+ ])
4145
+ );
4146
+ const textBySchematicComponentId = /* @__PURE__ */ new Map();
4147
+ const customSymbolTexts = [];
4148
+ for (const schematicText of schematicTexts) {
4149
+ if (!schematicText.schematic_component_id) {
4150
+ if (schematicText.schematic_symbol_id) {
4151
+ customSymbolTexts.push(schematicText);
4152
+ }
4153
+ continue;
4154
+ }
4155
+ const componentTexts = textBySchematicComponentId.get(schematicText.schematic_component_id) ?? /* @__PURE__ */ new Set();
4156
+ componentTexts.add(schematicText.text.trim());
4157
+ textBySchematicComponentId.set(
4158
+ schematicText.schematic_component_id,
4159
+ componentTexts
4160
+ );
4161
+ }
4162
+ const warnings = [];
4163
+ for (const schematicComponent of schematicComponents) {
4164
+ if (!schematicComponent.source_component_id) continue;
4165
+ const sourceComponent = sourceComponentById.get(
4166
+ schematicComponent.source_component_id
4167
+ );
4168
+ if (!sourceComponent) continue;
4169
+ const referenceDesignators = new Set(
4170
+ [sourceComponent.name, sourceComponent.display_name].map((name) => name?.trim()).filter((name) => Boolean(name))
4171
+ );
4172
+ const nonFallbackReferenceDesignator = [...referenceDesignators].find(
4173
+ (referenceDesignator) => !isFallbackReferenceDesignator(referenceDesignator)
4174
+ );
4175
+ const componentTexts = textBySchematicComponentId.get(
4176
+ schematicComponent.schematic_component_id
4177
+ );
4178
+ const hasReferenceDesignatorText = [...referenceDesignators].some(
4179
+ (referenceDesignator) => componentTexts?.has(referenceDesignator)
4180
+ ) || customSymbolTexts.some(
4181
+ (schematicText) => referenceDesignators.has(schematicText.text.trim()) && isTextWithinComponentBounds(schematicText, schematicComponent)
4182
+ );
4183
+ if (nonFallbackReferenceDesignator && hasReferenceDesignatorText) {
4184
+ continue;
4185
+ }
4186
+ const readableComponentName = nonFallbackReferenceDesignator ?? "Schematic component";
4187
+ warnings.push({
4188
+ type: "schematic_component_styling_warning",
4189
+ schematic_component_styling_warning_id: `schematic_component_styling_warning_${schematicComponent.schematic_component_id}_missing_reference_designator_text`,
4190
+ warning_type: "schematic_component_styling_warning",
4191
+ message: `${readableComponentName} is missing schematic reference designator text. For a custom symbol, add name="{REFDES}" inside the symbol.`,
4192
+ schematic_component_id: schematicComponent.schematic_component_id,
4193
+ styling_issue_type: "missing_reference_designator_text",
4194
+ source_component_id: schematicComponent.source_component_id,
4195
+ schematic_sheet_id: schematicComponent.schematic_sheet_id,
4196
+ subcircuit_id: schematicComponent.subcircuit_id
4197
+ });
4198
+ }
4199
+ return warnings;
4200
+ }
4201
+
4123
4202
  // lib/check-schematic-component-ports-outside-body.ts
4124
4203
  var FLOATING_POINT_TOLERANCE2 = 1e-9;
4125
4204
  var getPortLabel = (port) => port.display_pin_label ?? `pin ${port.pin_number}`;
@@ -4509,6 +4588,7 @@ async function runAllNetlistChecks(circuitJson) {
4509
4588
  async function runAllSchematicChecks(circuitJson) {
4510
4589
  return [
4511
4590
  ...checkSchematicComponentExcessiveVerticalPadding(circuitJson),
4591
+ ...checkSchematicComponentMissingReferenceDesignatorText(circuitJson),
4512
4592
  ...checkSchematicComponentPortsOutsideBody(circuitJson)
4513
4593
  ];
4514
4594
  }
@@ -4567,6 +4647,7 @@ export {
4567
4647
  checkPinMustBeConnected,
4568
4648
  checkSameNetViaSpacing,
4569
4649
  checkSchematicComponentExcessiveVerticalPadding,
4650
+ checkSchematicComponentMissingReferenceDesignatorText,
4570
4651
  checkSchematicComponentPortsOutsideBody,
4571
4652
  checkSourceTracesHavePcbTraces,
4572
4653
  checkSourceTracesMatchPcbTraceThickness,