@tscircuit/checks 0.0.183 → 0.0.184

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
@@ -153,3 +153,10 @@ export const pcb_trace_error = z
153
153
  export type PCBTraceErrorInput = z.input<typeof pcb_trace_error>
154
154
  export type PCBTraceError = z.infer<typeof pcb_trace_error>
155
155
  ```
156
+
157
+
158
+ ### checkSameNameNetsAreConnected
159
+
160
+ Checks whether source nets with exactly the same nonblank name belong to one electrical network, including across subcircuits. Returns one `source_confusing_net_name_warning` per ambiguous name with the affected `source_net_ids`. Connectivity follows source traces, shared ports, and both forms of internal component pin connections; a shared name or scoped connectivity key alone does not connect nets.
161
+
162
+ Included in `runAllNetlistChecks` and `runAllChecks`. This checks logical source connectivity; PCB routing continuity remains a separate check.
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, SourceComponentMisconfiguredError, 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, SourceConfusingNetNameWarning } from 'circuit-json';
3
3
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
4
4
 
5
5
  declare function checkEachPcbPortConnectedToPcbTraces(circuitJson: AnyCircuitElement[]): PcbPortNotConnectedError[];
@@ -192,7 +192,7 @@ declare function runAllNetlistChecks(circuitJson: AnyCircuitElement[]): Promise<
192
192
  source_component_id: string;
193
193
  source_port_id: string;
194
194
  subcircuit_id?: string;
195
- } | circuit_json.SourceComponentMisconfiguredError)[]>;
195
+ } | circuit_json.SourceComponentMisconfiguredError | circuit_json.SourceConfusingNetNameWarning)[]>;
196
196
  declare function runAllSchematicChecks(circuitJson: AnyCircuitElement[]): Promise<circuit_json.SchematicComponentStylingWarning[]>;
197
197
  declare function runAllPinSpecificationChecks(circuitJson: AnyCircuitElement[]): Promise<(circuit_json.SourceComponentPinsUnderspecifiedWarning | circuit_json.SourceNoPowerPinDefinedWarning | circuit_json.SourceNoGroundPinDefinedWarning)[]>;
198
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)[]>;
@@ -204,7 +204,7 @@ declare function runAllChecks(circuitJson: AnyCircuitElement[]): Promise<(circui
204
204
  source_component_id: string;
205
205
  source_port_id: string;
206
206
  subcircuit_id?: string;
207
- } | circuit_json.SourceComponentMisconfiguredError | 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.SourceConfusingNetNameWarning | circuit_json.PcbConnectorNotInAccessibleOrientationWarning | circuit_json.PcbCourtyardOverlapError)[]>;
208
208
 
209
209
  declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElement[]): PcbConnectorNotInAccessibleOrientationWarning[];
210
210
 
@@ -215,4 +215,7 @@ declare function checkConnectorAccessibleOrientation(circuitJson: AnyCircuitElem
215
215
  */
216
216
  declare function checkTestPointAccessibility(circuitJson: AnyCircuitElement[]): PcbPlacementError[];
217
217
 
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 };
218
+ /** Warn once per name when its source nets belong to multiple electrical islands. */
219
+ declare function checkSameNameNetsAreConnected(circuitJson: AnyCircuitElement[]): SourceConfusingNetNameWarning[];
220
+
221
+ export { NetManager, checkAllPinsInComponentAreUnderspecified, checkConnectorAccessibleOrientation, checkCopperToBoardEdgeClearance, checkDifferentNetViaSpacing, checkEachPcbPortConnectedToPcbTraces, checkEachPcbTraceNonOverlapping, checkNoGroundPinDefined, checkNoPowerPinDefined, checkPadPadClearance, checkPadTraceClearance, checkPcbComponentOverCutout, checkPcbComponentOverlap, checkPcbComponentsMissingCourtyard, checkPcbComponentsOutOfBoard, checkPcbCopperOverKeepout, checkPcbTraceLengths, checkPcbTraceViaCounts, checkPcbTracesOutOfBoard, checkPinMustBeConnected, checkSameNameNetsAreConnected, 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
@@ -4359,6 +4359,66 @@ function checkSchematicComponentPortsOutsideBody(circuitJson) {
4359
4359
  return warnings;
4360
4360
  }
4361
4361
 
4362
+ // lib/check-same-name-nets-are-connected.ts
4363
+ function checkSameNameNetsAreConnected(circuitJson) {
4364
+ const parents = /* @__PURE__ */ new Map();
4365
+ const find = (id) => {
4366
+ let root = id;
4367
+ while (parents.has(root) && parents.get(root) !== root) {
4368
+ root = parents.get(root);
4369
+ }
4370
+ while (parents.has(id) && parents.get(id) !== root) {
4371
+ const next = parents.get(id);
4372
+ parents.set(id, root);
4373
+ id = next;
4374
+ }
4375
+ return root;
4376
+ };
4377
+ const connect = (ids) => {
4378
+ if (ids.length < 2) return;
4379
+ const root = find(ids[0]);
4380
+ for (const id of ids.slice(1)) parents.set(find(id), root);
4381
+ };
4382
+ const netsByName = /* @__PURE__ */ new Map();
4383
+ for (const element of circuitJson) {
4384
+ if (element.type === "source_net" && element.name.trim()) {
4385
+ const nets = netsByName.get(element.name) ?? [];
4386
+ nets.push(element);
4387
+ netsByName.set(element.name, nets);
4388
+ }
4389
+ if (element.type === "source_trace") {
4390
+ connect([
4391
+ ...element.connected_source_net_ids.map((id) => `net:${id}`),
4392
+ ...element.connected_source_port_ids.map((id) => `port:${id}`)
4393
+ ]);
4394
+ }
4395
+ if (element.type === "source_component_internal_connection") {
4396
+ connect(element.source_port_ids.map((id) => `port:${id}`));
4397
+ }
4398
+ if (element.type === "source_component") {
4399
+ for (const ids of element.internally_connected_source_port_ids ?? []) {
4400
+ connect(ids.map((id) => `port:${id}`));
4401
+ }
4402
+ }
4403
+ }
4404
+ const warnings = [];
4405
+ for (const [name, nets] of netsByName) {
4406
+ const islands = new Set(nets.map((net) => find(`net:${net.source_net_id}`)));
4407
+ if (islands.size < 2) continue;
4408
+ const ids = nets.map((net) => net.source_net_id).sort();
4409
+ warnings.push({
4410
+ type: "source_confusing_net_name_warning",
4411
+ source_confusing_net_name_warning_id: `source_confusing_net_name_warning_${ids[0]}`,
4412
+ warning_type: "source_confusing_net_name_warning",
4413
+ message: `Nets named "${name}" are not all connected (${islands.size} separate electrical networks). Connect them or use distinct names to avoid confusion.`,
4414
+ source_net_ids: ids,
4415
+ net_name: name,
4416
+ ...nets.every((net) => net.subcircuit_id === nets[0].subcircuit_id) ? { subcircuit_id: nets[0].subcircuit_id } : {}
4417
+ });
4418
+ }
4419
+ return warnings;
4420
+ }
4421
+
4362
4422
  // lib/check-connector-accessible-orientation.ts
4363
4423
  import { getBoardBounds } from "@tscircuit/circuit-json-util";
4364
4424
  function getFacingDirectionFromInsertionDirection(component) {
@@ -4645,6 +4705,7 @@ async function runAllPlacementChecks(circuitJson) {
4645
4705
  async function runAllNetlistChecks(circuitJson) {
4646
4706
  return [
4647
4707
  ...checkPinMustBeConnected(circuitJson),
4708
+ ...checkSameNameNetsAreConnected(circuitJson),
4648
4709
  ...checkTwoTerminalSwitchContactsOnDifferentNets(circuitJson)
4649
4710
  ];
4650
4711
  }
@@ -4708,6 +4769,7 @@ export {
4708
4769
  checkPcbTraceViaCounts,
4709
4770
  checkPcbTracesOutOfBoard,
4710
4771
  checkPinMustBeConnected,
4772
+ checkSameNameNetsAreConnected,
4711
4773
  checkSameNetViaSpacing,
4712
4774
  checkSchematicComponentExcessiveVerticalPadding,
4713
4775
  checkSchematicComponentMissingReferenceDesignatorText,