@tscircuit/core 0.0.1270 → 0.0.1272

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,7 +1,7 @@
1
1
  import * as circuit_json from 'circuit-json';
2
2
  import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, PcbTrace as PcbTrace$1, PcbVia as PcbVia$1, PcbTraceRoutePoint, AnySourceComponent, PcbComponent, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, traceProps, netProps, AutorouterProp, AutoroutingPhaseProps, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSectionProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, traceProps, netProps, AutorouterProp, AutoroutingPhaseProps, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, drcCheckProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSectionProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  export { kicadFootprintStrings } from '@tscircuit/props';
6
6
  import * as react from 'react';
7
7
  import react__default, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
@@ -71239,6 +71239,33 @@ declare class Constraint extends PrimitiveComponent<typeof constraintProps> {
71239
71239
  };
71240
71240
  }
71241
71241
 
71242
+ declare class DrcCheck extends PrimitiveComponent<typeof drcCheckProps> {
71243
+ get config(): {
71244
+ componentName: string;
71245
+ zodProps: z.ZodObject<{
71246
+ name: z.ZodOptional<z.ZodString>;
71247
+ checkFn: z.ZodType<_tscircuit_props.CustomDrcCheckFn, z.ZodTypeDef, _tscircuit_props.CustomDrcCheckFn>;
71248
+ }, "strip", z.ZodTypeAny, {
71249
+ checkFn: _tscircuit_props.CustomDrcCheckFn;
71250
+ name?: string | undefined;
71251
+ }, {
71252
+ checkFn: _tscircuit_props.CustomDrcCheckFn;
71253
+ name?: string | undefined;
71254
+ }>;
71255
+ };
71256
+ constructor(props: z.input<typeof drcCheckProps>);
71257
+ runCustomDrcCheck(circuitJson: AnyCircuitElement[]): Promise<AnyCircuitElement[]>;
71258
+ private createCustomDrcCheckContext;
71259
+ private selectCustomDrcElement;
71260
+ private selectAllCustomDrcElements;
71261
+ private wrapSelectionResult;
71262
+ private createCircuitJsonDiagnostic;
71263
+ private isConnected;
71264
+ private getResistanceBetween;
71265
+ private getConnectivityKeys;
71266
+ private getCircuitJsonElementConnectivityKeys;
71267
+ }
71268
+
71242
71269
  declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhaseProps> {
71243
71270
  get config(): {
71244
71271
  componentName: string;
@@ -153679,6 +153706,7 @@ interface TscircuitElements {
153679
153706
  fuse: _tscircuit_props.FuseProps;
153680
153707
  led: _tscircuit_props.LedProps;
153681
153708
  board: _tscircuit_props.BoardProps;
153709
+ drccheck: _tscircuit_props.DrcCheckProps;
153682
153710
  mountedboard: _tscircuit_props.MountedBoardProps;
153683
153711
  panel: _tscircuit_props.PanelProps;
153684
153712
  subpanel: _tscircuit_props.SubpanelProps;
@@ -153779,4 +153807,4 @@ declare module "react/jsx-runtime" {
153779
153807
  }
153780
153808
  }
153781
153809
 
153782
- export { AnalogSimulation, type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, AutoroutingPhase, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Connector, Constraint, CopperPour, CopperText, CourtyardCircle, CourtyardOutline, CourtyardRect, Crystal, CurrentSource, Cutout, type DebugLogOutputEvent, Diode, FabricationNoteDimension, FabricationNotePath, FabricationNoteRect, FabricationNoteText, Breakout as Fanout, BreakoutPoint as FanoutPoint, Fiducial, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IIsolatedCircuit, type IRenderable, type IRootCircuit, Inductor, Interconnect, IsolatedCircuit, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, MountedBoard, Net, NetLabel, NormalComponent, type Obstacle, OpAmp, type PackingEndEvent, type PackingErrorEvent, type PackingStartEvent, Panel, PcbNoteDimension, PcbNoteLine, PcbNotePath, PcbNoteRect, PcbNoteText, PcbTrace, PcbVia, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SOLVERS, SchematicArc, SchematicBox, SchematicCell, SchematicCircle, SchematicLine, SchematicPath, SchematicRect, SchematicRow, SchematicSection, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, type SolverName, type SolverStartedEvent, Subcircuit, Subpanel, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageProbe, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, renderPhaseIndexMap, resolveStaticFileImport, sel, unrouteCircuitJson, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
153810
+ export { AnalogSimulation, type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, AutoroutingPhase, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Connector, Constraint, CopperPour, CopperText, CourtyardCircle, CourtyardOutline, CourtyardRect, Crystal, CurrentSource, Cutout, type DebugLogOutputEvent, Diode, DrcCheck, FabricationNoteDimension, FabricationNotePath, FabricationNoteRect, FabricationNoteText, Breakout as Fanout, BreakoutPoint as FanoutPoint, Fiducial, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IIsolatedCircuit, type IRenderable, type IRootCircuit, Inductor, Interconnect, IsolatedCircuit, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, MountedBoard, Net, NetLabel, NormalComponent, type Obstacle, OpAmp, type PackingEndEvent, type PackingErrorEvent, type PackingStartEvent, Panel, PcbNoteDimension, PcbNoteLine, PcbNotePath, PcbNoteRect, PcbNoteText, PcbTrace, PcbVia, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SOLVERS, SchematicArc, SchematicBox, SchematicCell, SchematicCircle, SchematicLine, SchematicPath, SchematicRect, SchematicRow, SchematicSection, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, type SolverName, type SolverStartedEvent, Subcircuit, Subpanel, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageProbe, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, renderPhaseIndexMap, resolveStaticFileImport, sel, unrouteCircuitJson, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ __export(components_exports, {
28
28
  CurrentSource: () => CurrentSource,
29
29
  Cutout: () => Cutout,
30
30
  Diode: () => Diode,
31
+ DrcCheck: () => DrcCheck,
31
32
  FabricationNoteDimension: () => FabricationNoteDimension,
32
33
  FabricationNotePath: () => FabricationNotePath,
33
34
  FabricationNoteRect: () => FabricationNoteRect,
@@ -1076,6 +1077,13 @@ var cssSelectPrimitiveComponentAdapter = {
1076
1077
  const value = node._parsedProps[name];
1077
1078
  return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
1078
1079
  }
1080
+ const matchingParsedPropName = Object.keys(node._parsedProps ?? {}).find(
1081
+ (propName) => propName.toLowerCase() === name
1082
+ );
1083
+ if (matchingParsedPropName) {
1084
+ const value = node._parsedProps[matchingParsedPropName];
1085
+ return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
1086
+ }
1079
1087
  if (name in node) {
1080
1088
  const value = node[name];
1081
1089
  return typeof value === "string" ? value : value !== null && value !== void 0 ? String(value) : null;
@@ -1098,6 +1106,11 @@ var cssSelectPrimitiveComponentAdapter = {
1098
1106
  if (node._parsedProps && name in node._parsedProps) {
1099
1107
  return true;
1100
1108
  }
1109
+ if (Object.keys(node._parsedProps ?? {}).some(
1110
+ (propName) => propName.toLowerCase() === name
1111
+ )) {
1112
+ return true;
1113
+ }
1101
1114
  if (name in node) {
1102
1115
  return true;
1103
1116
  }
@@ -18685,7 +18698,7 @@ function Group_doInitialSourceAddConnectivityMapKey(group) {
18685
18698
  if (!trace.source_trace_id) continue;
18686
18699
  const connNetId = connMap.getNetConnectedToId(trace.source_trace_id);
18687
18700
  if (!connNetId) continue;
18688
- trace.subcircuit_connectivity_map_key = `${subcircuitName ?? `unnamedsubcircuit${group._renderId}`}_${connNetId}`;
18701
+ trace.subcircuit_connectivity_map_key = `${subcircuitName ?? `unnamedsubcircuit${group.subcircuit_id ?? group.source_group_id ?? group._renderId}`}_${connNetId}`;
18689
18702
  db.source_trace.update(trace.source_trace_id, {
18690
18703
  subcircuit_connectivity_map_key: trace.subcircuit_connectivity_map_key
18691
18704
  });
@@ -18704,7 +18717,7 @@ function Group_doInitialSourceAddConnectivityMapKey(group) {
18704
18717
  for (const portId of allSourcePortIds) {
18705
18718
  const connNetId = connMap.getNetConnectedToId(portId);
18706
18719
  if (!connNetId) continue;
18707
- const connectivityMapKey = `${subcircuitName ?? `unnamedsubcircuit${group._renderId}`}_${connNetId}`;
18720
+ const connectivityMapKey = `${subcircuitName ?? `unnamedsubcircuit${group.subcircuit_id ?? group.source_group_id ?? group._renderId}`}_${connNetId}`;
18708
18721
  db.source_port.update(portId, {
18709
18722
  subcircuit_connectivity_map_key: connectivityMapKey
18710
18723
  });
@@ -18726,7 +18739,7 @@ function Group_doInitialSourceAddConnectivityMapKey(group) {
18726
18739
  for (const netId of allSourceNetIds) {
18727
18740
  const connNetId = connMap.getNetConnectedToId(netId);
18728
18741
  if (!connNetId) continue;
18729
- const connectivityMapKey = `${subcircuitName ?? `unnamedsubcircuit${group._renderId}`}_${connNetId}`;
18742
+ const connectivityMapKey = `${subcircuitName ?? `unnamedsubcircuit${group.subcircuit_id ?? group.source_group_id ?? group._renderId}`}_${connNetId}`;
18730
18743
  db.source_net.update(netId, {
18731
18744
  subcircuit_connectivity_map_key: connectivityMapKey
18732
18745
  });
@@ -21540,6 +21553,248 @@ var inflateCircuitJson = (target, circuitJson, children) => {
21540
21553
  inflateStandalonePcbPrimitives(inflationCtx);
21541
21554
  };
21542
21555
 
21556
+ // lib/components/primitive-components/DrcCheck.ts
21557
+ import {
21558
+ drcCheckProps
21559
+ } from "@tscircuit/props";
21560
+ import { any_circuit_element } from "circuit-json";
21561
+ var isSelectionResultPort = (connectable) => {
21562
+ if (!connectable || typeof connectable !== "object") return false;
21563
+ const maybePort = connectable;
21564
+ return typeof maybePort.getSourcePort === "function";
21565
+ };
21566
+ var isSelectionResultNet = (connectable) => {
21567
+ if (!connectable || typeof connectable !== "object") return false;
21568
+ const maybeNet = connectable;
21569
+ return typeof maybeNet.getSourceNet === "function";
21570
+ };
21571
+ var isSelectionResultComponent = (connectable) => {
21572
+ if (!connectable || typeof connectable !== "object") return false;
21573
+ const maybeComponent = connectable;
21574
+ return typeof maybeComponent.getPorts === "function";
21575
+ };
21576
+ var isCircuitJsonElement = (connectable) => {
21577
+ if (!connectable || typeof connectable !== "object") return false;
21578
+ const maybeCircuitJsonElement = connectable;
21579
+ return typeof maybeCircuitJsonElement.type === "string";
21580
+ };
21581
+ var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
21582
+ var SelectionResultPortImpl = class {
21583
+ constructor(port) {
21584
+ this.port = port;
21585
+ }
21586
+ port;
21587
+ getPcbPort() {
21588
+ const pcbPortId = this.port.pcb_port_id;
21589
+ if (!pcbPortId) return null;
21590
+ return this.port.root?.db.pcb_port.get(pcbPortId) ?? null;
21591
+ }
21592
+ getSourcePort() {
21593
+ const sourcePortId = this.port.source_port_id;
21594
+ if (!sourcePortId) return null;
21595
+ return this.port.root?.db.source_port.get(sourcePortId) ?? null;
21596
+ }
21597
+ };
21598
+ var SelectionResultNetImpl = class {
21599
+ constructor(net) {
21600
+ this.net = net;
21601
+ }
21602
+ net;
21603
+ getSourceNet() {
21604
+ const sourceNetId = this.net.source_net_id;
21605
+ if (!sourceNetId) return null;
21606
+ return this.net.root?.db.source_net.get(sourceNetId) ?? null;
21607
+ }
21608
+ };
21609
+ var SelectionResultComponentImpl = class {
21610
+ constructor(component) {
21611
+ this.component = component;
21612
+ }
21613
+ component;
21614
+ getPort(name) {
21615
+ const port = this.component.selectOne(`port.${name}`, { type: "port" }) ?? this.component.selectOne(`.${name}`, { type: "port" });
21616
+ if (!port) return null;
21617
+ return new SelectionResultPortImpl(port);
21618
+ }
21619
+ getPorts() {
21620
+ return this.component.selectAll("port").map((port) => new SelectionResultPortImpl(port));
21621
+ }
21622
+ getPcbComponent() {
21623
+ const pcbComponentId = this.component.pcb_component_id;
21624
+ if (!pcbComponentId) return null;
21625
+ return this.component.root?.db.pcb_component.get(pcbComponentId) ?? null;
21626
+ }
21627
+ getSourceComponent() {
21628
+ const sourceComponentId = this.component.source_component_id;
21629
+ if (!sourceComponentId) return null;
21630
+ return this.component.root?.db.source_component.get(sourceComponentId) ?? null;
21631
+ }
21632
+ };
21633
+ var DrcCheck = class extends PrimitiveComponent2 {
21634
+ get config() {
21635
+ return {
21636
+ componentName: "DrcCheck",
21637
+ zodProps: drcCheckProps
21638
+ };
21639
+ }
21640
+ constructor(props) {
21641
+ super(props);
21642
+ }
21643
+ async runCustomDrcCheck(circuitJson) {
21644
+ const result = await this._parsedProps.checkFn(
21645
+ this.createCustomDrcCheckContext(circuitJson)
21646
+ );
21647
+ let diagnostics = [];
21648
+ if (Array.isArray(result)) {
21649
+ diagnostics = result;
21650
+ } else if (result) {
21651
+ diagnostics = [result];
21652
+ }
21653
+ return diagnostics.map(
21654
+ (diagnostic, index) => this.createCircuitJsonDiagnostic(diagnostic, index)
21655
+ ).filter((diagnostic) => !!diagnostic);
21656
+ }
21657
+ createCustomDrcCheckContext(circuitJson) {
21658
+ return {
21659
+ select: this.selectCustomDrcElement.bind(
21660
+ this
21661
+ ),
21662
+ selectAll: this.selectAllCustomDrcElements.bind(
21663
+ this
21664
+ ),
21665
+ isConnected: (a, b) => this.isConnected(a, b, circuitJson),
21666
+ isPulledUp: (a) => this.isConnected(a, "net.VCC", circuitJson) || this.isConnected(a, "net.VDD", circuitJson) || this.getResistanceBetween(a, "net.VCC", circuitJson) !== null || this.getResistanceBetween(a, "net.VDD", circuitJson) !== null,
21667
+ isPulledDown: (a) => this.isConnected(a, "net.GND", circuitJson) || this.getResistanceBetween(a, "net.GND", circuitJson) !== null,
21668
+ getResistanceBetween: (a, b) => this.getResistanceBetween(a, b, circuitJson)
21669
+ };
21670
+ }
21671
+ selectCustomDrcElement(selector) {
21672
+ return this.wrapSelectionResult(this.getSubcircuit().selectOne(selector));
21673
+ }
21674
+ selectAllCustomDrcElements(selector) {
21675
+ const selectionResults = [];
21676
+ for (const component of this.getSubcircuit().selectAll(selector)) {
21677
+ const selectionResult = this.wrapSelectionResult(component);
21678
+ if (selectionResult) selectionResults.push(selectionResult);
21679
+ }
21680
+ return selectionResults;
21681
+ }
21682
+ wrapSelectionResult(component) {
21683
+ if (!component) return null;
21684
+ if (component instanceof Port) return new SelectionResultPortImpl(component);
21685
+ if (component instanceof Net) return new SelectionResultNetImpl(component);
21686
+ return new SelectionResultComponentImpl(component);
21687
+ }
21688
+ createCircuitJsonDiagnostic(diagnostic, index) {
21689
+ const diagnosticRecord = diagnostic;
21690
+ let diagnosticType = "source_component_misconfigured_error";
21691
+ if (typeof diagnosticRecord.error_type === "string") {
21692
+ diagnosticType = diagnosticRecord.error_type;
21693
+ } else if (typeof diagnosticRecord.warning_type === "string") {
21694
+ diagnosticType = diagnosticRecord.warning_type;
21695
+ }
21696
+ const diagnosticWithCircuitJsonDefaults = {
21697
+ ...diagnostic
21698
+ };
21699
+ if (typeof diagnosticRecord.type === "string") {
21700
+ diagnosticWithCircuitJsonDefaults.type = diagnosticRecord.type;
21701
+ } else {
21702
+ diagnosticWithCircuitJsonDefaults.type = diagnosticType;
21703
+ }
21704
+ if (typeof diagnosticRecord.warning_type !== "string") {
21705
+ if (typeof diagnosticRecord.error_type === "string") {
21706
+ diagnosticWithCircuitJsonDefaults.error_type = diagnosticRecord.error_type;
21707
+ } else {
21708
+ diagnosticWithCircuitJsonDefaults.error_type = diagnosticType;
21709
+ }
21710
+ }
21711
+ const diagnosticIdField = `${diagnosticType}_id`;
21712
+ if (diagnosticRecord[diagnosticIdField]) {
21713
+ diagnosticWithCircuitJsonDefaults[diagnosticIdField] = diagnosticRecord[diagnosticIdField];
21714
+ } else {
21715
+ diagnosticWithCircuitJsonDefaults[diagnosticIdField] = `${diagnosticType}_${this._renderId}_${index}`;
21716
+ }
21717
+ return any_circuit_element.parse(diagnosticWithCircuitJsonDefaults);
21718
+ }
21719
+ isConnected(a, b, circuitJson) {
21720
+ const aKeys = this.getConnectivityKeys(a, circuitJson);
21721
+ const bKeys = this.getConnectivityKeys(b, circuitJson);
21722
+ return aKeys.some((key) => bKeys.includes(key));
21723
+ }
21724
+ getResistanceBetween(a, b, circuitJson) {
21725
+ if (this.isConnected(a, b, circuitJson)) return 0;
21726
+ const aKeys = this.getConnectivityKeys(a, circuitJson);
21727
+ const bKeys = this.getConnectivityKeys(b, circuitJson);
21728
+ if (aKeys.length === 0 || bKeys.length === 0) return null;
21729
+ const sourceResistors = circuitJson.filter(
21730
+ (elm) => elm.type === "source_component" && elm.ftype === "simple_resistor"
21731
+ );
21732
+ const root = this.root;
21733
+ if (!root) return null;
21734
+ for (const resistor of sourceResistors) {
21735
+ const resistorPorts = root.db.source_port.list({
21736
+ source_component_id: resistor.source_component_id
21737
+ });
21738
+ if (resistorPorts.length !== 2) continue;
21739
+ const resistorKeys = resistorPorts.map(
21740
+ (port) => port.subcircuit_connectivity_map_key
21741
+ );
21742
+ const connectsA = resistorKeys.some((key) => key && aKeys.includes(key));
21743
+ const connectsB = resistorKeys.some((key) => key && bKeys.includes(key));
21744
+ if (connectsA && connectsB) return resistor.resistance;
21745
+ }
21746
+ return null;
21747
+ }
21748
+ getConnectivityKeys(connectable, circuitJson) {
21749
+ if (!connectable) return [];
21750
+ if (typeof connectable === "string") {
21751
+ const selected = this.selectCustomDrcElement(connectable);
21752
+ if (selected) return this.getConnectivityKeys(selected, circuitJson);
21753
+ return [];
21754
+ }
21755
+ if (isSelectionResultPort(connectable)) {
21756
+ return [
21757
+ connectable.getSourcePort()?.subcircuit_connectivity_map_key
21758
+ ].filter(isNonEmptyString);
21759
+ }
21760
+ if (isSelectionResultNet(connectable)) {
21761
+ return [
21762
+ connectable.getSourceNet()?.subcircuit_connectivity_map_key
21763
+ ].filter(isNonEmptyString);
21764
+ }
21765
+ if (isSelectionResultComponent(connectable)) {
21766
+ return connectable.getPorts().flatMap((port) => this.getConnectivityKeys(port, circuitJson));
21767
+ }
21768
+ if (isCircuitJsonElement(connectable)) {
21769
+ return this.getCircuitJsonElementConnectivityKeys(
21770
+ connectable,
21771
+ circuitJson
21772
+ );
21773
+ }
21774
+ return [];
21775
+ }
21776
+ getCircuitJsonElementConnectivityKeys(element, circuitJson) {
21777
+ if (!element) return [];
21778
+ if (element.type === "source_port") {
21779
+ return [element.subcircuit_connectivity_map_key].filter(isNonEmptyString);
21780
+ }
21781
+ if (element.type === "source_net") {
21782
+ return [element.subcircuit_connectivity_map_key].filter(isNonEmptyString);
21783
+ }
21784
+ if (element.type === "pcb_port") {
21785
+ return this.getConnectivityKeys(element.source_port_id, circuitJson);
21786
+ }
21787
+ if (element.type === "source_component") {
21788
+ const root = this.root;
21789
+ if (!root) return [];
21790
+ return root.db.source_port.list({
21791
+ source_component_id: element.source_component_id
21792
+ }).map((port) => port.subcircuit_connectivity_map_key).filter(isNonEmptyString);
21793
+ }
21794
+ return [];
21795
+ }
21796
+ };
21797
+
21543
21798
  // lib/IsolatedCircuit.ts
21544
21799
  import { su as su5 } from "@tscircuit/circuit-json-util";
21545
21800
  import Debug14 from "debug";
@@ -21550,7 +21805,7 @@ import { identity as identity5 } from "transformation-matrix";
21550
21805
  var package_default = {
21551
21806
  name: "@tscircuit/core",
21552
21807
  type: "module",
21553
- version: "0.0.1269",
21808
+ version: "0.0.1271",
21554
21809
  types: "dist/index.d.ts",
21555
21810
  main: "dist/index.js",
21556
21811
  module: "dist/index.js",
@@ -21597,7 +21852,7 @@ var package_default = {
21597
21852
  "@tscircuit/math-utils": "^0.0.36",
21598
21853
  "@tscircuit/miniflex": "^0.0.4",
21599
21854
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
21600
- "@tscircuit/props": "^0.0.536",
21855
+ "@tscircuit/props": "^0.0.538",
21601
21856
  "@tscircuit/schematic-match-adapt": "^0.0.16",
21602
21857
  "@tscircuit/schematic-trace-solver": "^0.0.60",
21603
21858
  "@tscircuit/solver-utils": "^0.0.3",
@@ -21611,7 +21866,7 @@ var package_default = {
21611
21866
  "bun-match-svg": "0.0.12",
21612
21867
  "calculate-elbow": "^0.0.12",
21613
21868
  "chokidar-cli": "^3.0.0",
21614
- "circuit-json": "^0.0.425",
21869
+ "circuit-json": "^0.0.429",
21615
21870
  "circuit-json-to-bpc": "^0.0.13",
21616
21871
  "circuit-json-to-connectivity-map": "^0.0.23",
21617
21872
  "circuit-json-to-gltf": "^0.0.102",
@@ -22537,6 +22792,11 @@ var Board = class extends Group5 {
22537
22792
  runAllPinSpecificationChecks(circuitJson)
22538
22793
  );
22539
22794
  }
22795
+ if (!drcChecksDisabled) {
22796
+ for (const drcCheck of this.selectAll("drccheck")) {
22797
+ checksToRun.push(drcCheck.runCustomDrcCheck(circuitJson));
22798
+ }
22799
+ }
22540
22800
  const checkResults = await Promise.all(checksToRun);
22541
22801
  db.insertAll(checkResults.flat());
22542
22802
  };
@@ -28076,6 +28336,7 @@ export {
28076
28336
  CurrentSource,
28077
28337
  Cutout,
28078
28338
  Diode,
28339
+ DrcCheck,
28079
28340
  FabricationNoteDimension,
28080
28341
  FabricationNotePath,
28081
28342
  FabricationNoteRect,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1270",
4
+ "version": "0.0.1272",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -48,7 +48,7 @@
48
48
  "@tscircuit/math-utils": "^0.0.36",
49
49
  "@tscircuit/miniflex": "^0.0.4",
50
50
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
51
- "@tscircuit/props": "^0.0.536",
51
+ "@tscircuit/props": "^0.0.538",
52
52
  "@tscircuit/schematic-match-adapt": "^0.0.16",
53
53
  "@tscircuit/schematic-trace-solver": "^0.0.60",
54
54
  "@tscircuit/solver-utils": "^0.0.3",
@@ -62,7 +62,7 @@
62
62
  "bun-match-svg": "0.0.12",
63
63
  "calculate-elbow": "^0.0.12",
64
64
  "chokidar-cli": "^3.0.0",
65
- "circuit-json": "^0.0.425",
65
+ "circuit-json": "^0.0.429",
66
66
  "circuit-json-to-bpc": "^0.0.13",
67
67
  "circuit-json-to-connectivity-map": "^0.0.23",
68
68
  "circuit-json-to-gltf": "^0.0.102",