@tscircuit/core 0.0.1159 → 0.0.1160

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
@@ -88167,6 +88167,9 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
88167
88167
  private _tryFetchPartCircuitJson;
88168
88168
  private _fetchStandardConnectorCircuitJson;
88169
88169
  private _addConnectorFootprintFromCircuitJson;
88170
+ private _getUsbCCanonicalLabelToPinNumberMap;
88171
+ _getSchematicPortArrangement(): SchematicPortArrangement | null;
88172
+ _getSchematicBoxDimensions(): SchematicBoxDimensions | null;
88170
88173
  get config(): {
88171
88174
  componentName: string;
88172
88175
  zodProps: zod.ZodObject<{
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ __export(components_exports, {
99
99
  import { fp } from "@tscircuit/footprinter";
100
100
  import { normalizeDegrees } from "@tscircuit/math-utils";
101
101
  import {
102
- distance as distance7,
102
+ distance as distance8,
103
103
  pcb_component_invalid_layer_error,
104
104
  pcb_manual_edit_conflict_warning,
105
105
  point3 as point32,
@@ -9540,21 +9540,28 @@ var getAllDimensionsForSchematicBox = (params) => {
9540
9540
  };
9541
9541
 
9542
9542
  // lib/utils/schematic/getNumericSchPinStyle.ts
9543
+ import { distance as distance6 } from "circuit-json";
9543
9544
  var getNumericSchPinStyle = (pinStyles, pinLabels) => {
9544
9545
  if (!pinStyles) return void 0;
9545
9546
  const numericPinStyles = {};
9546
9547
  for (const [pinNameOrLabel, pinStyle] of Object.entries(pinStyles)) {
9547
9548
  const pinNumber = parsePinNumberFromLabelsOrThrow(pinNameOrLabel, pinLabels);
9548
- const pinStyleWithSideFirst = {
9549
- leftMargin: pinStyle.marginLeft ?? pinStyle.leftMargin,
9550
- rightMargin: pinStyle.marginRight ?? pinStyle.rightMargin,
9551
- topMargin: pinStyle.marginTop ?? pinStyle.topMargin,
9552
- bottomMargin: pinStyle.marginBottom ?? pinStyle.bottomMargin
9553
- };
9554
- numericPinStyles[`pin${pinNumber}`] = {
9555
- ...numericPinStyles[`pin${pinNumber}`],
9556
- ...pinStyleWithSideFirst
9557
- };
9549
+ const leftMargin = pinStyle.marginLeft ?? pinStyle.leftMargin;
9550
+ const rightMargin = pinStyle.marginRight ?? pinStyle.rightMargin;
9551
+ const topMargin = pinStyle.marginTop ?? pinStyle.topMargin;
9552
+ const bottomMargin = pinStyle.marginBottom ?? pinStyle.bottomMargin;
9553
+ const existingStyle = numericPinStyles[`pin${pinNumber}`] ?? {};
9554
+ const nextStyle = { ...existingStyle };
9555
+ if (leftMargin !== void 0)
9556
+ nextStyle.leftMargin = distance6.parse(leftMargin);
9557
+ if (rightMargin !== void 0) {
9558
+ nextStyle.rightMargin = distance6.parse(rightMargin);
9559
+ }
9560
+ if (topMargin !== void 0) nextStyle.topMargin = distance6.parse(topMargin);
9561
+ if (bottomMargin !== void 0) {
9562
+ nextStyle.bottomMargin = distance6.parse(bottomMargin);
9563
+ }
9564
+ numericPinStyles[`pin${pinNumber}`] = nextStyle;
9558
9565
  }
9559
9566
  return numericPinStyles;
9560
9567
  };
@@ -9583,7 +9590,7 @@ var CadAssembly = class extends PrimitiveComponent2 {
9583
9590
  // lib/components/primitive-components/CadModel.ts
9584
9591
  import { cadmodelProps, point3 } from "@tscircuit/props";
9585
9592
  import { z as z8 } from "zod";
9586
- import { distance as distance6 } from "circuit-json";
9593
+ import { distance as distance7 } from "circuit-json";
9587
9594
  import { decomposeTSR as decomposeTSR7 } from "transformation-matrix";
9588
9595
 
9589
9596
  // lib/components/base-components/NormalComponent/utils/getFileExtension.ts
@@ -9664,7 +9671,7 @@ var CadModel = class extends PrimitiveComponent2 {
9664
9671
  z: props.pcbZ ?? 0,
9665
9672
  ...typeof props.positionOffset === "object" ? props.positionOffset : {}
9666
9673
  });
9667
- const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ? distance6.parse(props.zOffsetFromSurface) : 0;
9674
+ const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ? distance7.parse(props.zOffsetFromSurface) : 0;
9668
9675
  const layer = parent.props.layer === "bottom" ? "bottom" : "top";
9669
9676
  const ext = props.modelUrl ? getFileExtension(props.modelUrl) : void 0;
9670
9677
  const modelUrlWithoutExtFragment = props.modelUrl?.replace(/#ext=\w+$/, "");
@@ -11604,7 +11611,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
11604
11611
  z: 0,
11605
11612
  ...typeof cadModel?.positionOffset === "object" ? cadModel.positionOffset : {}
11606
11613
  });
11607
- const zOffsetFromSurface = cadModel && typeof cadModel === "object" && "zOffsetFromSurface" in cadModel ? cadModel.zOffsetFromSurface !== void 0 ? distance7.parse(
11614
+ const zOffsetFromSurface = cadModel && typeof cadModel === "object" && "zOffsetFromSurface" in cadModel ? cadModel.zOffsetFromSurface !== void 0 ? distance8.parse(
11608
11615
  cadModel.zOffsetFromSurface
11609
11616
  ) : 0 : 0;
11610
11617
  const computedLayer = this.props.layer === "bottom" ? "bottom" : "top";
@@ -12559,7 +12566,7 @@ import {
12559
12566
  groupProps
12560
12567
  } from "@tscircuit/props";
12561
12568
  import {
12562
- distance as distance8
12569
+ distance as distance9
12563
12570
  } from "circuit-json";
12564
12571
  import Debug13 from "debug";
12565
12572
 
@@ -17736,8 +17743,8 @@ var Group6 = class extends NormalComponent3 {
17736
17743
  const groupProps2 = props;
17737
17744
  const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
17738
17745
  const numericOutline = hasOutline ? groupProps2.outline.map((point6) => ({
17739
- x: distance8.parse(point6.x),
17740
- y: distance8.parse(point6.y)
17746
+ x: distance9.parse(point6.x),
17747
+ y: distance9.parse(point6.y)
17741
17748
  })) : void 0;
17742
17749
  const ctx = this.props;
17743
17750
  const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
@@ -17775,8 +17782,8 @@ var Group6 = class extends NormalComponent3 {
17775
17782
  const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
17776
17783
  if (hasOutline) {
17777
17784
  const numericOutline = props.outline.map((point6) => ({
17778
- x: distance8.parse(point6.x),
17779
- y: distance8.parse(point6.y)
17785
+ x: distance9.parse(point6.x),
17786
+ y: distance9.parse(point6.y)
17780
17787
  }));
17781
17788
  const outlineBounds = getBoundsFromPoints4(numericOutline);
17782
17789
  if (!outlineBounds) return;
@@ -19315,7 +19322,7 @@ import { identity as identity5 } from "transformation-matrix";
19315
19322
  var package_default = {
19316
19323
  name: "@tscircuit/core",
19317
19324
  type: "module",
19318
- version: "0.0.1158",
19325
+ version: "0.0.1159",
19319
19326
  types: "dist/index.d.ts",
19320
19327
  main: "dist/index.js",
19321
19328
  module: "dist/index.js",
@@ -20467,11 +20474,11 @@ var MountedBoard = class extends Subcircuit {
20467
20474
 
20468
20475
  // lib/components/normal-components/Panel.ts
20469
20476
  import { panelProps } from "@tscircuit/props";
20470
- import { distance as distance12 } from "circuit-json";
20477
+ import { distance as distance13 } from "circuit-json";
20471
20478
 
20472
20479
  // lib/components/normal-components/Subpanel.ts
20473
20480
  import { subpanelProps } from "@tscircuit/props";
20474
- import { distance as distance11 } from "circuit-json";
20481
+ import { distance as distance12 } from "circuit-json";
20475
20482
  import { compose as compose8, identity as identity6, translate as translate8 } from "transformation-matrix";
20476
20483
 
20477
20484
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
@@ -20684,15 +20691,15 @@ function generatePanelTabsAndMouseBites(boards, options) {
20684
20691
  }
20685
20692
 
20686
20693
  // lib/utils/panels/pack-into-grid.ts
20687
- import { distance as distance10 } from "circuit-json";
20694
+ import { distance as distance11 } from "circuit-json";
20688
20695
 
20689
20696
  // lib/utils/panels/get-board-dimensions-from-props.ts
20690
20697
  import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
20691
- import { distance as distance9 } from "circuit-json";
20698
+ import { distance as distance10 } from "circuit-json";
20692
20699
  var getBoardDimensionsFromProps = (board) => {
20693
20700
  const props = board._parsedProps;
20694
- let width = props.width != null ? distance9.parse(props.width) : void 0;
20695
- let height = props.height != null ? distance9.parse(props.height) : void 0;
20701
+ let width = props.width != null ? distance10.parse(props.width) : void 0;
20702
+ let height = props.height != null ? distance10.parse(props.height) : void 0;
20696
20703
  if ((width === void 0 || height === void 0) && props.outline?.length) {
20697
20704
  const outlineBounds = getBoundsFromPoints6(props.outline);
20698
20705
  if (outlineBounds) {
@@ -20736,8 +20743,8 @@ function packIntoGrid({
20736
20743
  }
20737
20744
  let cols;
20738
20745
  let rows;
20739
- const minCellWidth = cellWidth ? distance10.parse(cellWidth) : 0;
20740
- const minCellHeight = cellHeight ? distance10.parse(cellHeight) : 0;
20746
+ const minCellWidth = cellWidth ? distance11.parse(cellWidth) : 0;
20747
+ const minCellHeight = cellHeight ? distance11.parse(cellHeight) : 0;
20741
20748
  if (col !== void 0) {
20742
20749
  cols = col;
20743
20750
  rows = row ?? Math.ceil(itemsWithDims.length / cols);
@@ -20836,8 +20843,8 @@ function getItemDimensions(item, db) {
20836
20843
  const props = subpanel._parsedProps;
20837
20844
  if (props.width !== void 0 && props.height !== void 0) {
20838
20845
  return {
20839
- width: distance10.parse(props.width),
20840
- height: distance10.parse(props.height)
20846
+ width: distance11.parse(props.width),
20847
+ height: distance11.parse(props.height)
20841
20848
  };
20842
20849
  }
20843
20850
  const directBoards = subpanel._getDirectBoardChildren();
@@ -20864,7 +20871,7 @@ function getItemDimensions(item, db) {
20864
20871
  return getBoardDimensionsFromProps(directBoards[0]);
20865
20872
  }
20866
20873
  if (subpanel._cachedGridWidth > 0 && subpanel._cachedGridHeight > 0) {
20867
- const edgePadding = distance10.parse(props.edgePadding ?? 5);
20874
+ const edgePadding = distance11.parse(props.edgePadding ?? 5);
20868
20875
  return {
20869
20876
  width: subpanel._cachedGridWidth + edgePadding * 2,
20870
20877
  height: subpanel._cachedGridHeight + edgePadding * 2
@@ -21011,17 +21018,17 @@ var Subpanel = class _Subpanel extends Group6 {
21011
21018
  edgePaddingTop: edgePaddingTopProp,
21012
21019
  edgePaddingBottom: edgePaddingBottomProp
21013
21020
  } = this._parsedProps;
21014
- const edgePadding = distance11.parse(edgePaddingProp ?? 5);
21015
- const edgePaddingLeft = distance11.parse(edgePaddingLeftProp ?? edgePadding);
21016
- const edgePaddingRight = distance11.parse(
21021
+ const edgePadding = distance12.parse(edgePaddingProp ?? 5);
21022
+ const edgePaddingLeft = distance12.parse(edgePaddingLeftProp ?? edgePadding);
21023
+ const edgePaddingRight = distance12.parse(
21017
21024
  edgePaddingRightProp ?? edgePadding
21018
21025
  );
21019
- const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
21020
- const edgePaddingBottom = distance11.parse(
21026
+ const edgePaddingTop = distance12.parse(edgePaddingTopProp ?? edgePadding);
21027
+ const edgePaddingBottom = distance12.parse(
21021
21028
  edgePaddingBottomProp ?? edgePadding
21022
21029
  );
21023
- const panelWidth = distance11.parse(this._parsedProps.width);
21024
- const panelHeight = distance11.parse(this._parsedProps.height);
21030
+ const panelWidth = distance12.parse(this._parsedProps.width);
21031
+ const panelHeight = distance12.parse(this._parsedProps.height);
21025
21032
  availablePanelWidth = panelWidth - edgePaddingLeft - edgePaddingRight;
21026
21033
  availablePanelHeight = panelHeight - edgePaddingTop - edgePaddingBottom;
21027
21034
  }
@@ -21096,8 +21103,8 @@ var Subpanel = class _Subpanel extends Group6 {
21096
21103
  if (!this.pcb_group_id) return;
21097
21104
  if (hasExplicitWidth && hasExplicitHeight) {
21098
21105
  db.pcb_group.update(this.pcb_group_id, {
21099
- width: distance11.parse(this._parsedProps.width),
21100
- height: distance11.parse(this._parsedProps.height)
21106
+ width: distance12.parse(this._parsedProps.width),
21107
+ height: distance12.parse(this._parsedProps.height)
21101
21108
  });
21102
21109
  } else if (gridWidth > 0 || gridHeight > 0) {
21103
21110
  const {
@@ -21107,18 +21114,18 @@ var Subpanel = class _Subpanel extends Group6 {
21107
21114
  edgePaddingTop: edgePaddingTopProp,
21108
21115
  edgePaddingBottom: edgePaddingBottomProp
21109
21116
  } = this._parsedProps;
21110
- const edgePadding = distance11.parse(edgePaddingProp ?? 5);
21111
- const edgePaddingLeft = distance11.parse(edgePaddingLeftProp ?? edgePadding);
21112
- const edgePaddingRight = distance11.parse(
21117
+ const edgePadding = distance12.parse(edgePaddingProp ?? 5);
21118
+ const edgePaddingLeft = distance12.parse(edgePaddingLeftProp ?? edgePadding);
21119
+ const edgePaddingRight = distance12.parse(
21113
21120
  edgePaddingRightProp ?? edgePadding
21114
21121
  );
21115
- const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
21116
- const edgePaddingBottom = distance11.parse(
21122
+ const edgePaddingTop = distance12.parse(edgePaddingTopProp ?? edgePadding);
21123
+ const edgePaddingBottom = distance12.parse(
21117
21124
  edgePaddingBottomProp ?? edgePadding
21118
21125
  );
21119
21126
  db.pcb_group.update(this.pcb_group_id, {
21120
- width: hasExplicitWidth ? distance11.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
21121
- height: hasExplicitHeight ? distance11.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
21127
+ width: hasExplicitWidth ? distance12.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
21128
+ height: hasExplicitHeight ? distance12.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
21122
21129
  });
21123
21130
  }
21124
21131
  }
@@ -21192,8 +21199,8 @@ var Panel = class extends Subpanel {
21192
21199
  const { db } = this.root;
21193
21200
  const props = this._parsedProps;
21194
21201
  const inserted = db.pcb_panel.insert({
21195
- width: props.width !== void 0 ? distance12.parse(props.width) : 0,
21196
- height: props.height !== void 0 ? distance12.parse(props.height) : 0,
21202
+ width: props.width !== void 0 ? distance13.parse(props.width) : 0,
21203
+ height: props.height !== void 0 ? distance13.parse(props.height) : 0,
21197
21204
  thickness: 1.6,
21198
21205
  center: this._getGlobalPcbPositionBeforeLayout(),
21199
21206
  covered_with_solder_mask: !(props.noSolderMask ?? false)
@@ -21212,8 +21219,8 @@ var Panel = class extends Subpanel {
21212
21219
  if (!this.pcb_panel_id) return;
21213
21220
  if (hasExplicitWidth && hasExplicitHeight) {
21214
21221
  db.pcb_panel.update(this.pcb_panel_id, {
21215
- width: distance12.parse(this._parsedProps.width),
21216
- height: distance12.parse(this._parsedProps.height)
21222
+ width: distance13.parse(this._parsedProps.width),
21223
+ height: distance13.parse(this._parsedProps.height)
21217
21224
  });
21218
21225
  } else if (gridWidth > 0 || gridHeight > 0) {
21219
21226
  const {
@@ -21223,18 +21230,18 @@ var Panel = class extends Subpanel {
21223
21230
  edgePaddingTop: edgePaddingTopProp,
21224
21231
  edgePaddingBottom: edgePaddingBottomProp
21225
21232
  } = this._parsedProps;
21226
- const edgePadding = distance12.parse(edgePaddingProp ?? 5);
21227
- const edgePaddingLeft = distance12.parse(edgePaddingLeftProp ?? edgePadding);
21228
- const edgePaddingRight = distance12.parse(
21233
+ const edgePadding = distance13.parse(edgePaddingProp ?? 5);
21234
+ const edgePaddingLeft = distance13.parse(edgePaddingLeftProp ?? edgePadding);
21235
+ const edgePaddingRight = distance13.parse(
21229
21236
  edgePaddingRightProp ?? edgePadding
21230
21237
  );
21231
- const edgePaddingTop = distance12.parse(edgePaddingTopProp ?? edgePadding);
21232
- const edgePaddingBottom = distance12.parse(
21238
+ const edgePaddingTop = distance13.parse(edgePaddingTopProp ?? edgePadding);
21239
+ const edgePaddingBottom = distance13.parse(
21233
21240
  edgePaddingBottomProp ?? edgePadding
21234
21241
  );
21235
21242
  db.pcb_panel.update(this.pcb_panel_id, {
21236
- width: hasExplicitWidth ? distance12.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
21237
- height: hasExplicitHeight ? distance12.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
21243
+ width: hasExplicitWidth ? distance13.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
21244
+ height: hasExplicitHeight ? distance13.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
21238
21245
  });
21239
21246
  }
21240
21247
  }
@@ -21245,8 +21252,8 @@ var Panel = class extends Subpanel {
21245
21252
  const props = this._parsedProps;
21246
21253
  const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
21247
21254
  db.pcb_panel.update(this.pcb_panel_id, {
21248
- width: props.width !== void 0 ? distance12.parse(props.width) : currentPanel?.width,
21249
- height: props.height !== void 0 ? distance12.parse(props.height) : currentPanel?.height,
21255
+ width: props.width !== void 0 ? distance13.parse(props.width) : currentPanel?.width,
21256
+ height: props.height !== void 0 ? distance13.parse(props.height) : currentPanel?.height,
21250
21257
  center: this._getGlobalPcbPositionBeforeLayout(),
21251
21258
  covered_with_solder_mask: !(props.noSolderMask ?? false)
21252
21259
  });
@@ -22585,7 +22592,7 @@ var NetLabel = class extends PrimitiveComponent2 {
22585
22592
 
22586
22593
  // lib/components/primitive-components/Fiducial.ts
22587
22594
  import "zod";
22588
- import { distance as distance13 } from "circuit-json";
22595
+ import { distance as distance14 } from "circuit-json";
22589
22596
  import { fiducialProps } from "@tscircuit/props";
22590
22597
  var Fiducial = class extends PrimitiveComponent2 {
22591
22598
  pcb_smtpad_id = null;
@@ -22610,15 +22617,15 @@ var Fiducial = class extends PrimitiveComponent2 {
22610
22617
  shape: "circle",
22611
22618
  x: position.x,
22612
22619
  y: position.y,
22613
- radius: distance13.parse(props.padDiameter) / 2,
22614
- soldermask_margin: props.soldermaskPullback ? distance13.parse(props.soldermaskPullback) : distance13.parse(props.padDiameter) / 2,
22620
+ radius: distance14.parse(props.padDiameter) / 2,
22621
+ soldermask_margin: props.soldermaskPullback ? distance14.parse(props.soldermaskPullback) : distance14.parse(props.padDiameter) / 2,
22615
22622
  is_covered_with_solder_mask: true
22616
22623
  });
22617
22624
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
22618
22625
  }
22619
22626
  getPcbSize() {
22620
22627
  const { _parsedProps: props } = this;
22621
- const d = distance13.parse(props.padDiameter);
22628
+ const d = distance14.parse(props.padDiameter);
22622
22629
  return { width: d, height: d };
22623
22630
  }
22624
22631
  _setPositionFromLayout(newCenter) {
@@ -23224,6 +23231,8 @@ var extractCadModelFromCircuitJson = (circuitJson) => {
23224
23231
  import { symbols as symbols4 } from "schematic-symbols";
23225
23232
 
23226
23233
  // lib/components/normal-components/Connector_insertInnerSymbolInSchematicBox.ts
23234
+ var INNER_SYMBOL_SCALE_FACTOR = 0.5;
23235
+ var INNER_SYMBOL_LEFT_SHIFT_FACTOR = 0.15;
23227
23236
  function insertInnerSymbolInSchematicBox(connector, symbol) {
23228
23237
  if (!connector.schematic_component_id || !connector.root) return;
23229
23238
  const { db } = connector.root;
@@ -23232,9 +23241,8 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
23232
23241
  );
23233
23242
  if (!schematicComponent) return;
23234
23243
  if (schematicComponent.symbol_name) return;
23235
- const innerScaleFactor = 0.5;
23236
- const targetWidth = schematicComponent.size.width * innerScaleFactor;
23237
- const targetHeight = schematicComponent.size.height * innerScaleFactor;
23244
+ const targetWidth = schematicComponent.size.width * INNER_SYMBOL_SCALE_FACTOR;
23245
+ const targetHeight = schematicComponent.size.height * INNER_SYMBOL_SCALE_FACTOR;
23238
23246
  const scaleFactor = Math.min(
23239
23247
  targetWidth / symbol.size.width,
23240
23248
  targetHeight / symbol.size.height
@@ -23243,8 +23251,9 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
23243
23251
  const subcircuit_id = connector.getSubcircuit()?.subcircuit_id ?? void 0;
23244
23252
  const center = schematicComponent.center;
23245
23253
  const symbolCenter = symbol.center;
23254
+ const centerOffsetX = -schematicComponent.size.width * INNER_SYMBOL_LEFT_SHIFT_FACTOR;
23246
23255
  const transformPoint = (point6) => ({
23247
- x: center.x + (point6.x - symbolCenter.x) * scaleFactor,
23256
+ x: center.x + centerOffsetX + (point6.x - symbolCenter.x) * scaleFactor,
23248
23257
  y: center.y + (point6.y - symbolCenter.y) * scaleFactor
23249
23258
  });
23250
23259
  for (const primitive of symbol.primitives) {
@@ -23303,6 +23312,42 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
23303
23312
  }
23304
23313
 
23305
23314
  // lib/components/normal-components/Connector.ts
23315
+ var USB_C_SIGNAL_LABELS_IN_ORDER = [
23316
+ "VBUS1",
23317
+ "VBUS2",
23318
+ "CC1",
23319
+ "CC2",
23320
+ "DP1",
23321
+ "DP2",
23322
+ "DM1",
23323
+ "DM2",
23324
+ "SBU1",
23325
+ "SBU2",
23326
+ "GND1",
23327
+ "GND2"
23328
+ ];
23329
+ var USB_C_SHELL_LABELS_IN_ORDER = [
23330
+ "SHELL1",
23331
+ "SHELL2",
23332
+ "SHELL3",
23333
+ "SHELL4"
23334
+ ];
23335
+ var USB_C_CANONICAL_LABELS_IN_ORDER = [
23336
+ ...USB_C_SIGNAL_LABELS_IN_ORDER,
23337
+ ...USB_C_SHELL_LABELS_IN_ORDER
23338
+ ];
23339
+ var USB_C_CANONICAL_LABELS = /* @__PURE__ */ new Set([
23340
+ ...USB_C_CANONICAL_LABELS_IN_ORDER
23341
+ ]);
23342
+ var USB_C_DEFAULT_SCH_PIN_STYLE_BY_LABEL = [
23343
+ // Group spacing on right side
23344
+ ["CC1", { marginTop: 0.15 }],
23345
+ ["DP1", { marginTop: 0.15 }],
23346
+ ["SBU1", { marginTop: 0.15 }],
23347
+ ["GND1", { marginTop: 0.15 }],
23348
+ // Bottom-side label spacing uses horizontal margins.
23349
+ ["SHELL4", { marginRight: 0.15 }]
23350
+ ];
23306
23351
  var Connector = class extends Chip {
23307
23352
  _getConnectorProps() {
23308
23353
  return this._parsedProps;
@@ -23382,6 +23427,93 @@ var Connector = class extends Chip {
23382
23427
  this.addAll(fpComponents);
23383
23428
  this._markDirty("InitializePortsFromChildren");
23384
23429
  }
23430
+ _getUsbCCanonicalLabelToPinNumberMap() {
23431
+ const labelToPinNumber = /* @__PURE__ */ new Map();
23432
+ const ports = this.selectAll("port");
23433
+ for (const port of ports) {
23434
+ const pinNumber = port.props.pinNumber;
23435
+ if (typeof pinNumber !== "number") continue;
23436
+ for (const alias of port.getNameAndAliases()) {
23437
+ const normalizedAlias = alias.trim().toUpperCase();
23438
+ if (!USB_C_CANONICAL_LABELS.has(normalizedAlias)) continue;
23439
+ const label = normalizedAlias;
23440
+ if (!labelToPinNumber.has(label)) {
23441
+ labelToPinNumber.set(label, pinNumber);
23442
+ }
23443
+ }
23444
+ }
23445
+ return labelToPinNumber;
23446
+ }
23447
+ _getSchematicPortArrangement() {
23448
+ const arrangement = super._getSchematicPortArrangement();
23449
+ if (arrangement && Object.keys(arrangement).length > 0) return arrangement;
23450
+ if (this._getConnectorProps().standard !== "usb_c") return arrangement;
23451
+ const labelToPinNumber = this._getUsbCCanonicalLabelToPinNumberMap();
23452
+ const rightPins = USB_C_SIGNAL_LABELS_IN_ORDER.map(
23453
+ (label) => labelToPinNumber.get(label)
23454
+ ).filter((pin) => typeof pin === "number");
23455
+ const bottomPins = USB_C_SHELL_LABELS_IN_ORDER.map(
23456
+ (label) => labelToPinNumber.get(label)
23457
+ ).filter((pin) => typeof pin === "number");
23458
+ if (rightPins.length === 0 && bottomPins.length === 0) return arrangement;
23459
+ const canonicalArrangement = {};
23460
+ if (rightPins.length > 0) {
23461
+ canonicalArrangement.rightSide = {
23462
+ pins: rightPins,
23463
+ direction: "top-to-bottom"
23464
+ };
23465
+ }
23466
+ if (bottomPins.length > 0) {
23467
+ canonicalArrangement.bottomSide = {
23468
+ pins: bottomPins,
23469
+ direction: "left-to-right"
23470
+ };
23471
+ }
23472
+ return canonicalArrangement;
23473
+ }
23474
+ _getSchematicBoxDimensions() {
23475
+ if (this._getConnectorProps().standard !== "usb_c") {
23476
+ return super._getSchematicBoxDimensions();
23477
+ }
23478
+ if (this.getSchematicSymbol()) return null;
23479
+ if (!this.config.shouldRenderAsSchematicBox) return null;
23480
+ const { _parsedProps: props } = this;
23481
+ const pinCount = this._getPinCount();
23482
+ const pinSpacing = props.schPinSpacing ?? 0.2;
23483
+ const pinLabelsFromPorts = this._getPinLabelsFromPorts();
23484
+ const allPinLabels = {
23485
+ ...pinLabelsFromPorts
23486
+ };
23487
+ if (props.pinLabels) {
23488
+ for (const [k, v] of Object.entries(props.pinLabels)) {
23489
+ if (typeof v === "string") allPinLabels[k] = v;
23490
+ }
23491
+ }
23492
+ const labelToPinNumber = this._getUsbCCanonicalLabelToPinNumberMap();
23493
+ const resolvedDefaultSchPinStyle = {};
23494
+ for (const [label, style] of USB_C_DEFAULT_SCH_PIN_STYLE_BY_LABEL) {
23495
+ const pinNumber = labelToPinNumber.get(label);
23496
+ if (typeof pinNumber !== "number") continue;
23497
+ resolvedDefaultSchPinStyle[`pin${pinNumber}`] = style;
23498
+ }
23499
+ const mergedSchPinStyle = {
23500
+ ...resolvedDefaultSchPinStyle,
23501
+ ...props.schPinStyle ?? {}
23502
+ };
23503
+ const schPortArrangement = this._getSchematicPortArrangement();
23504
+ return getAllDimensionsForSchematicBox({
23505
+ schWidth: props.schWidth,
23506
+ schHeight: props.schHeight,
23507
+ schPinSpacing: pinSpacing,
23508
+ numericSchPinStyle: getNumericSchPinStyle(
23509
+ mergedSchPinStyle,
23510
+ allPinLabels
23511
+ ),
23512
+ pinCount,
23513
+ schPortArrangement: schPortArrangement ?? void 0,
23514
+ pinLabels: allPinLabels
23515
+ });
23516
+ }
23385
23517
  get config() {
23386
23518
  return {
23387
23519
  componentName: "Connector",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1159",
4
+ "version": "0.0.1160",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",