@tscircuit/core 0.0.1386 → 0.0.1388

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
@@ -239,9 +239,9 @@ interface IIsolatedCircuit {
239
239
  interface IRootCircuit extends IIsolatedCircuit {
240
240
  }
241
241
 
242
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "ResolveFootprintPinLabels", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicSheetRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbAutoplaceBreakoutPoints", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
242
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "ResolveFootprintPinLabels", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "CheckRefDesConvention", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicSheetRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbAutoplaceBreakoutPoints", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
243
243
  type RenderPhase = (typeof orderedRenderPhases)[number];
244
- declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "ResolveFootprintPinLabels" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicSheetRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbAutoplaceBreakoutPoints" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
244
+ declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "ResolveFootprintPinLabels" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "CheckRefDesConvention" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicSheetRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbAutoplaceBreakoutPoints" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
245
245
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
246
246
  type RenderPhaseStates = Record<RenderPhase, {
247
247
  initialized: boolean;
@@ -2211,6 +2211,8 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
2211
2211
  get portMap(): PortMap<PortNames>;
2212
2212
  getInstanceForReactElement(element: ReactElement): NormalComponent | null;
2213
2213
  doInitialSourceRender(): void;
2214
+ getRefDesPrefixes(): string[] | undefined;
2215
+ doInitialCheckRefDesConvention(): void;
2214
2216
  /**
2215
2217
  * After ports have their source_port_id assigned, create
2216
2218
  * source_component_internal_connection records so that the connectivity
@@ -29514,6 +29516,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
29514
29516
  };
29515
29517
  initPorts(): void;
29516
29518
  doInitialSourceRender(): void;
29519
+ getRefDesPrefixes(): string[];
29517
29520
  get pos(): Port;
29518
29521
  get anode(): Port;
29519
29522
  get neg(): Port;
package/dist/index.js CHANGED
@@ -337,6 +337,7 @@ var orderedRenderPhases = [
337
337
  "SourceGroupRender",
338
338
  "AssignNameToUnnamedComponents",
339
339
  "SourceRender",
340
+ "CheckRefDesConvention",
340
341
  "SourceComponentPropertyValidation",
341
342
  "SourceParentAttachment",
342
343
  "PortMatching",
@@ -11952,6 +11953,63 @@ var Footprint = class extends PrimitiveComponent2 {
11952
11953
  }
11953
11954
  };
11954
11955
 
11956
+ // lib/components/base-components/NormalComponent/NormalComponent_doInitialCheckRefDesConvention.ts
11957
+ var defaultExpectedPrefixesByFtype = {
11958
+ simple_ammeter: ["A"],
11959
+ simple_battery: ["B", "BT"],
11960
+ simple_capacitor: ["C"],
11961
+ simple_chip: ["U", "IC"],
11962
+ simple_connector: ["J", "P", "CONN"],
11963
+ simple_crystal: ["Y", "X"],
11964
+ simple_current_source: ["I", "IS"],
11965
+ simple_diode: ["D"],
11966
+ simple_fuse: ["F"],
11967
+ simple_inductor: ["L", "FB"],
11968
+ simple_interconnect: ["ICN"],
11969
+ simple_led: ["D", "LED"],
11970
+ simple_mosfet: ["Q"],
11971
+ simple_op_amp: ["U", "IC"],
11972
+ simple_pin_header: ["J", "P", "JP"],
11973
+ simple_pinout: ["J", "P"],
11974
+ simple_potentiometer: ["RV", "RP"],
11975
+ simple_power_source: ["B", "BT", "V", "VS"],
11976
+ simple_push_button: ["SW", "S"],
11977
+ simple_resistor: ["R"],
11978
+ simple_resonator: ["Y", "X"],
11979
+ simple_switch: ["SW", "S"],
11980
+ simple_test_point: ["TP"],
11981
+ simple_transistor: ["Q"],
11982
+ simple_voltage_probe: ["VP"],
11983
+ simple_voltage_source: ["V", "VS"]
11984
+ };
11985
+ var getDefaultExpectedRefDesPrefixesForFtype = (ftype) => {
11986
+ if (!ftype) return void 0;
11987
+ return defaultExpectedPrefixesByFtype[ftype];
11988
+ };
11989
+ var getRefDesPrefix = (refDes) => refDes.match(/^[A-Za-z]+/)?.[0]?.toUpperCase();
11990
+ var NormalComponent_doInitialCheckRefDesConvention = (component) => {
11991
+ const { db } = component.root;
11992
+ if (!component.source_component_id) return;
11993
+ const sourceComponent = db.source_component.get(component.source_component_id);
11994
+ if (!sourceComponent?.name || !sourceComponent.ftype) return;
11995
+ const expectedPrefixes = component.getRefDesPrefixes();
11996
+ if (!expectedPrefixes || expectedPrefixes.length === 0) return;
11997
+ const actualPrefix = getRefDesPrefix(sourceComponent.name);
11998
+ if (actualPrefix && expectedPrefixes.includes(actualPrefix)) return;
11999
+ const expectedPrefixMessage = expectedPrefixes.length === 1 ? expectedPrefixes[0] : `one of ${expectedPrefixes.join(", ")}`;
12000
+ db.insert({
12001
+ type: "source_refdes_convention_warning",
12002
+ warning_type: "source_refdes_convention_warning",
12003
+ message: `Component ${sourceComponent.name} has ftype="${sourceComponent.ftype}" but reference designator should start with ${expectedPrefixMessage}`,
12004
+ source_component_id: sourceComponent.source_component_id,
12005
+ refdes: sourceComponent.name,
12006
+ source_component_ftype: sourceComponent.ftype,
12007
+ expected_prefixes: expectedPrefixes,
12008
+ actual_prefix: actualPrefix,
12009
+ subcircuit_id: sourceComponent.subcircuit_id
12010
+ });
12011
+ };
12012
+
11955
12013
  // lib/components/base-components/NormalComponent/NormalComponent__getMinimumFlexContainerSize.ts
11956
12014
  import { getBoundsFromPoints as getBoundsFromPoints2 } from "@tscircuit/math-utils";
11957
12015
  var NormalComponent__getMinimumFlexContainerSize = (component) => {
@@ -13370,6 +13428,12 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
13370
13428
  });
13371
13429
  this.source_component_id = source_component.source_component_id;
13372
13430
  }
13431
+ getRefDesPrefixes() {
13432
+ return getDefaultExpectedRefDesPrefixesForFtype(this.config.sourceFtype);
13433
+ }
13434
+ doInitialCheckRefDesConvention() {
13435
+ NormalComponent_doInitialCheckRefDesConvention(this);
13436
+ }
13373
13437
  /**
13374
13438
  * After ports have their source_port_id assigned, create
13375
13439
  * source_component_internal_connection records so that the connectivity
@@ -15103,6 +15167,9 @@ var Diode = class extends NormalComponent3 {
15103
15167
  });
15104
15168
  this.source_component_id = source_component.source_component_id;
15105
15169
  }
15170
+ getRefDesPrefixes() {
15171
+ return ["D"];
15172
+ }
15106
15173
  get pos() {
15107
15174
  return this.portMap.pos;
15108
15175
  }
@@ -25075,7 +25142,7 @@ import { identity as identity5 } from "transformation-matrix";
25075
25142
  var package_default = {
25076
25143
  name: "@tscircuit/core",
25077
25144
  type: "module",
25078
- version: "0.0.1385",
25145
+ version: "0.0.1387",
25079
25146
  types: "dist/index.d.ts",
25080
25147
  main: "dist/index.js",
25081
25148
  module: "dist/index.js",
@@ -25109,7 +25176,7 @@ var package_default = {
25109
25176
  "@tscircuit/alphabet": "0.0.25",
25110
25177
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
25111
25178
  "@tscircuit/capacity-autorouter": "^0.0.625",
25112
- "@tscircuit/checks": "0.0.140",
25179
+ "@tscircuit/checks": "0.0.141",
25113
25180
  "@tscircuit/circuit-json-util": "^0.0.97",
25114
25181
  "@tscircuit/common": "^0.0.20",
25115
25182
  "@tscircuit/copper-pour-solver": "0.0.35",
@@ -25138,7 +25205,7 @@ var package_default = {
25138
25205
  "bun-match-svg": "0.0.12",
25139
25206
  "calculate-elbow": "^0.0.12",
25140
25207
  "chokidar-cli": "^3.0.0",
25141
- "circuit-json": "^0.0.445",
25208
+ "circuit-json": "^0.0.446",
25142
25209
  "circuit-json-to-bpc": "^0.0.13",
25143
25210
  "circuit-json-to-connectivity-map": "^0.0.23",
25144
25211
  "circuit-json-to-gltf": "^0.0.105",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1386",
4
+ "version": "0.0.1388",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "@tscircuit/alphabet": "0.0.25",
36
36
  "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
37
37
  "@tscircuit/capacity-autorouter": "^0.0.625",
38
- "@tscircuit/checks": "0.0.140",
38
+ "@tscircuit/checks": "0.0.141",
39
39
  "@tscircuit/circuit-json-util": "^0.0.97",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "0.0.35",
@@ -64,7 +64,7 @@
64
64
  "bun-match-svg": "0.0.12",
65
65
  "calculate-elbow": "^0.0.12",
66
66
  "chokidar-cli": "^3.0.0",
67
- "circuit-json": "^0.0.445",
67
+ "circuit-json": "^0.0.446",
68
68
  "circuit-json-to-bpc": "^0.0.13",
69
69
  "circuit-json-to-connectivity-map": "^0.0.23",
70
70
  "circuit-json-to-gltf": "^0.0.105",