@tscircuit/core 0.0.972 → 0.0.974

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
@@ -16,7 +16,7 @@ import { CopperPourPipelineSolver } from '@tscircuit/copper-pour-solver';
16
16
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
17
17
  import { GraphicsObject } from 'graphics-debug';
18
18
 
19
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
19
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SchematicPrimitiveRender", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
20
20
  type RenderPhase = (typeof orderedRenderPhases)[number];
21
21
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
22
22
  type RenderPhaseStates = Record<RenderPhase, {
@@ -1495,6 +1495,10 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
1495
1495
  source_board_id: string | null;
1496
1496
  _drcChecksComplete: boolean;
1497
1497
  _connectedSchematicPortPairs: Set<string>;
1498
+ _panelPositionOffset: {
1499
+ x: number;
1500
+ y: number;
1501
+ } | null;
1498
1502
  get isSubcircuit(): boolean;
1499
1503
  get isGroup(): boolean;
1500
1504
  get config(): {
@@ -2908,6 +2912,7 @@ declare class Board extends Group<typeof boardProps> implements BoardI, Subcircu
2908
2912
  */
2909
2913
  get allLayers(): readonly ["top"] | readonly ["top", "bottom", "inner1", "inner2"] | readonly ["top", "bottom"];
2910
2914
  _getSubcircuitLayerCount(): number;
2915
+ _computePcbGlobalTransformBeforeLayout(): Matrix;
2911
2916
  _getBoardCalcVariables(): Record<string, number>;
2912
2917
  doInitialPcbBoardAutoSize(): void;
2913
2918
  updatePcbBoardAutoSize(): void;
@@ -4038,6 +4043,9 @@ declare class Panel extends Group<typeof panelProps> {
4038
4043
  get isGroup(): boolean;
4039
4044
  get isSubcircuit(): boolean;
4040
4045
  add(component: PrimitiveComponent): void;
4046
+ _cachedGridWidth: number;
4047
+ _cachedGridHeight: number;
4048
+ doInitialPanelBoardLayout(): void;
4041
4049
  doInitialPanelLayout(): void;
4042
4050
  runRenderCycle(): void;
4043
4051
  doInitialPcbComponentRender(): void;
package/dist/index.js CHANGED
@@ -139,6 +139,7 @@ var orderedRenderPhases = [
139
139
  "SchematicLayout",
140
140
  "SchematicTraceRender",
141
141
  "SchematicReplaceNetLabelsWithSymbols",
142
+ "PanelBoardLayout",
142
143
  "PcbComponentRender",
143
144
  "PcbPrimitiveRender",
144
145
  "PcbFootprintLayout",
@@ -178,8 +179,7 @@ var asyncPhaseDependencies = {
178
179
  SilkscreenOverlapAdjustment: ["PcbFootprintStringRender"],
179
180
  CadModelRender: ["PcbFootprintStringRender"],
180
181
  PartsEngineRender: ["PcbFootprintStringRender"],
181
- PcbComponentAnchorAlignment: ["PcbFootprintStringRender"],
182
- PanelLayout: ["PcbFootprintStringRender"]
182
+ PcbComponentAnchorAlignment: ["PcbFootprintStringRender"]
183
183
  };
184
184
  var globalRenderCounter = 0;
185
185
  var Renderable = class _Renderable {
@@ -9542,6 +9542,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
9542
9542
  doInitialPartsEngineRender() {
9543
9543
  if (this.props.doNotPlace) return;
9544
9544
  if (this.getInheritedProperty("bomDisabled")) return;
9545
+ if (this.getInheritedProperty("partsEngineDisabled")) return;
9545
9546
  const partsEngine = this.getInheritedProperty("partsEngine");
9546
9547
  if (!partsEngine) return;
9547
9548
  const { db } = this.root;
@@ -9583,6 +9584,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
9583
9584
  updatePartsEngineRender() {
9584
9585
  if (this.props.doNotPlace) return;
9585
9586
  if (this.getInheritedProperty("bomDisabled")) return;
9587
+ if (this.getInheritedProperty("partsEngineDisabled")) return;
9586
9588
  const { db } = this.root;
9587
9589
  const source_component = db.source_component.get(this.source_component_id);
9588
9590
  if (!source_component) return;
@@ -16166,6 +16168,7 @@ import {
16166
16168
  checkPinMustBeConnected
16167
16169
  } from "@tscircuit/checks";
16168
16170
  import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
16171
+ import { compose as compose6, translate as translate7 } from "transformation-matrix";
16169
16172
  var MIN_EFFECTIVE_BORDER_RADIUS_MM = 0.01;
16170
16173
  var getRoundedRectOutline = (width, height, radius) => {
16171
16174
  const w2 = width / 2;
@@ -16226,6 +16229,7 @@ var Board = class extends Group6 {
16226
16229
  source_board_id = null;
16227
16230
  _drcChecksComplete = false;
16228
16231
  _connectedSchematicPortPairs = /* @__PURE__ */ new Set();
16232
+ _panelPositionOffset = null;
16229
16233
  get isSubcircuit() {
16230
16234
  return true;
16231
16235
  }
@@ -16257,6 +16261,16 @@ var Board = class extends Group6 {
16257
16261
  _getSubcircuitLayerCount() {
16258
16262
  return this._parsedProps.layers ?? 2;
16259
16263
  }
16264
+ _computePcbGlobalTransformBeforeLayout() {
16265
+ if (this._panelPositionOffset) {
16266
+ const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
16267
+ return compose6(
16268
+ parentTransform,
16269
+ translate7(this._panelPositionOffset.x, this._panelPositionOffset.y)
16270
+ );
16271
+ }
16272
+ return super._computePcbGlobalTransformBeforeLayout();
16273
+ }
16260
16274
  _getBoardCalcVariables() {
16261
16275
  const { _parsedProps: props } = this;
16262
16276
  const isAutoSized = (props.width == null || props.height == null) && !props.outline;
@@ -16466,6 +16480,18 @@ var Board = class extends Group6 {
16466
16480
  props.borderRadius
16467
16481
  );
16468
16482
  }
16483
+ let outlineTranslation = { x: 0, y: 0 };
16484
+ if (outline && outline.length > 0 && this._panelPositionOffset) {
16485
+ const outlineBounds = getBoundsFromPoints4(outline);
16486
+ if (outlineBounds) {
16487
+ const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
16488
+ const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
16489
+ outlineTranslation = {
16490
+ x: center.x - outlineCenterX,
16491
+ y: center.y - outlineCenterY
16492
+ };
16493
+ }
16494
+ }
16469
16495
  const pcb_board = db.pcb_board.insert({
16470
16496
  source_board_id: this.source_board_id,
16471
16497
  center,
@@ -16474,8 +16500,8 @@ var Board = class extends Group6 {
16474
16500
  width: computedWidth,
16475
16501
  height: computedHeight,
16476
16502
  outline: outline?.map((point2) => ({
16477
- x: point2.x + (props.outlineOffsetX ?? 0),
16478
- y: point2.y + (props.outlineOffsetY ?? 0)
16503
+ x: point2.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
16504
+ y: point2.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
16479
16505
  })),
16480
16506
  material: props.material
16481
16507
  });
@@ -16559,25 +16585,6 @@ var Board = class extends Group6 {
16559
16585
  if (Math.abs(deltaX) < 1e-6 && Math.abs(deltaY) < 1e-6) {
16560
16586
  return;
16561
16587
  }
16562
- for (const child of this.getDescendants()) {
16563
- if (child.isPcbPrimitive && "_moveCircuitJsonElements" in child && typeof child._moveCircuitJsonElements === "function") {
16564
- child._moveCircuitJsonElements({ deltaX, deltaY });
16565
- }
16566
- if (child instanceof Group6) {
16567
- const groupChild = child;
16568
- const pcbGroup = db.pcb_group.get(groupChild.pcb_group_id || "");
16569
- if (!pcbGroup) continue;
16570
- if (pcbGroup.center) {
16571
- if (!groupChild.pcb_group_id) continue;
16572
- db.pcb_group.update(groupChild.pcb_group_id, {
16573
- center: {
16574
- x: pcbGroup.center.x + deltaX,
16575
- y: pcbGroup.center.y + deltaY
16576
- }
16577
- });
16578
- }
16579
- }
16580
- }
16581
16588
  if (this.pcb_board_id) {
16582
16589
  db.pcb_board.update(this.pcb_board_id, { center: position });
16583
16590
  if (pcbBoard?.outline) {
@@ -16604,7 +16611,7 @@ var Board = class extends Group6 {
16604
16611
 
16605
16612
  // lib/components/normal-components/Panel.ts
16606
16613
  import { panelProps } from "@tscircuit/props";
16607
- import { distance as distance10 } from "circuit-json";
16614
+ import { distance as distance11 } from "circuit-json";
16608
16615
 
16609
16616
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
16610
16617
  import * as Flatten from "@flatten-js/core";
@@ -16789,7 +16796,38 @@ function generatePanelTabsAndMouseBites(boards, options) {
16789
16796
  }
16790
16797
 
16791
16798
  // lib/utils/panels/pack-boards-into-grid.ts
16799
+ import { distance as distance10 } from "circuit-json";
16800
+
16801
+ // lib/utils/panels/get-board-dimensions-from-props.ts
16802
+ import { getBoundsFromPoints as getBoundsFromPoints5 } from "@tscircuit/math-utils";
16792
16803
  import { distance as distance9 } from "circuit-json";
16804
+ var getBoardDimensionsFromProps = (board) => {
16805
+ const props = board._parsedProps;
16806
+ let width = props.width != null ? distance9.parse(props.width) : void 0;
16807
+ let height = props.height != null ? distance9.parse(props.height) : void 0;
16808
+ if ((width === void 0 || height === void 0) && props.outline?.length) {
16809
+ const outlineBounds = getBoundsFromPoints5(props.outline);
16810
+ if (outlineBounds) {
16811
+ width ??= outlineBounds.maxX - outlineBounds.minX;
16812
+ height ??= outlineBounds.maxY - outlineBounds.minY;
16813
+ }
16814
+ }
16815
+ if ((width === void 0 || height === void 0) && props.circuitJson?.length) {
16816
+ const pcbBoardFromJson = props.circuitJson.find(
16817
+ (elm) => elm.type === "pcb_board"
16818
+ );
16819
+ if (pcbBoardFromJson) {
16820
+ width ??= pcbBoardFromJson.width;
16821
+ height ??= pcbBoardFromJson.height;
16822
+ }
16823
+ }
16824
+ return {
16825
+ width: width ?? 0,
16826
+ height: height ?? 0
16827
+ };
16828
+ };
16829
+
16830
+ // lib/utils/panels/pack-boards-into-grid.ts
16793
16831
  var packBoardsIntoGrid = ({
16794
16832
  boards,
16795
16833
  db,
@@ -16800,11 +16838,24 @@ var packBoardsIntoGrid = ({
16800
16838
  boardGap
16801
16839
  }) => {
16802
16840
  const boardsWithDims = boards.map((board) => {
16803
- const pcbBoard = db.pcb_board.get(board.pcb_board_id);
16804
- if (!pcbBoard || pcbBoard.width === void 0 || pcbBoard.height === void 0) {
16841
+ let width;
16842
+ let height;
16843
+ if (db && board.pcb_board_id) {
16844
+ const pcbBoard = db.pcb_board.get(board.pcb_board_id);
16845
+ if (pcbBoard?.width !== void 0 && pcbBoard?.height !== void 0) {
16846
+ width = pcbBoard.width;
16847
+ height = pcbBoard.height;
16848
+ }
16849
+ }
16850
+ if (width === void 0 || height === void 0) {
16851
+ const propsDims = getBoardDimensionsFromProps(board);
16852
+ width = propsDims.width;
16853
+ height = propsDims.height;
16854
+ }
16855
+ if (width === 0 && height === 0) {
16805
16856
  return null;
16806
16857
  }
16807
- return { board, width: pcbBoard.width, height: pcbBoard.height };
16858
+ return { board, width, height };
16808
16859
  }).filter((b) => b !== null);
16809
16860
  if (boardsWithDims.length === 0) {
16810
16861
  return {
@@ -16820,17 +16871,17 @@ var packBoardsIntoGrid = ({
16820
16871
  const colWidths = Array(cols).fill(0);
16821
16872
  const rowHeights = Array(rows).fill(0);
16822
16873
  boardsWithDims.forEach((b, i) => {
16823
- const col2 = i % cols;
16824
- const row2 = Math.floor(i / cols);
16825
- if (row2 < rowHeights.length && b.height > rowHeights[row2]) {
16826
- rowHeights[row2] = b.height;
16874
+ const colIdx = i % cols;
16875
+ const rowIdx = Math.floor(i / cols);
16876
+ if (rowIdx < rowHeights.length && b.height > rowHeights[rowIdx]) {
16877
+ rowHeights[rowIdx] = b.height;
16827
16878
  }
16828
- if (col2 < colWidths.length && b.width > colWidths[col2]) {
16829
- colWidths[col2] = b.width;
16879
+ if (colIdx < colWidths.length && b.width > colWidths[colIdx]) {
16880
+ colWidths[colIdx] = b.width;
16830
16881
  }
16831
16882
  });
16832
- const minCellWidth = cellWidth ? distance9.parse(cellWidth) : 0;
16833
- const minCellHeight = cellHeight ? distance9.parse(cellHeight) : 0;
16883
+ const minCellWidth = cellWidth ? distance10.parse(cellWidth) : 0;
16884
+ const minCellHeight = cellHeight ? distance10.parse(cellHeight) : 0;
16834
16885
  for (let i = 0; i < colWidths.length; i++) {
16835
16886
  colWidths[i] = Math.max(colWidths[i], minCellWidth);
16836
16887
  }
@@ -16851,15 +16902,15 @@ var packBoardsIntoGrid = ({
16851
16902
  }
16852
16903
  const positions = [];
16853
16904
  boardsWithDims.forEach((b, i) => {
16854
- const col2 = i % cols;
16855
- const row2 = Math.floor(i / cols);
16856
- if (row2 >= rowYOffsets.length || col2 >= colXOffsets.length) return;
16857
- const cellX = colXOffsets[col2];
16858
- const cellY = rowYOffsets[row2];
16859
- const cellWidth2 = colWidths[col2];
16860
- const cellHeight2 = rowHeights[row2];
16861
- const boardX = cellX + cellWidth2 / 2;
16862
- const boardY = cellY + cellHeight2 / 2;
16905
+ const colIdx = i % cols;
16906
+ const rowIdx = Math.floor(i / cols);
16907
+ if (rowIdx >= rowYOffsets.length || colIdx >= colXOffsets.length) return;
16908
+ const cellX = colXOffsets[colIdx];
16909
+ const cellY = rowYOffsets[rowIdx];
16910
+ const currentCellWidth = colWidths[colIdx];
16911
+ const currentCellHeight = rowHeights[rowIdx];
16912
+ const boardX = cellX + currentCellWidth / 2;
16913
+ const boardY = cellY + currentCellHeight / 2;
16863
16914
  positions.push({
16864
16915
  board: b.board,
16865
16916
  pos: { x: boardX, y: boardY }
@@ -16890,48 +16941,55 @@ var Panel = class extends Group6 {
16890
16941
  }
16891
16942
  super.add(component);
16892
16943
  }
16944
+ _cachedGridWidth = 0;
16945
+ _cachedGridHeight = 0;
16946
+ doInitialPanelBoardLayout() {
16947
+ if (this.root?.pcbDisabled) return;
16948
+ const layoutMode = this._parsedProps.layoutMode ?? "none";
16949
+ if (layoutMode !== "grid") return;
16950
+ const childBoardInstances = this.children.filter(
16951
+ (c) => c instanceof Board
16952
+ );
16953
+ const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
16954
+ const boardGap = this._parsedProps.boardGap ?? tabWidth;
16955
+ const { positions, gridWidth, gridHeight } = packBoardsIntoGrid({
16956
+ boards: childBoardInstances,
16957
+ row: this._parsedProps.row,
16958
+ col: this._parsedProps.col,
16959
+ cellWidth: this._parsedProps.cellWidth,
16960
+ cellHeight: this._parsedProps.cellHeight,
16961
+ boardGap
16962
+ });
16963
+ this._cachedGridWidth = gridWidth;
16964
+ this._cachedGridHeight = gridHeight;
16965
+ for (const { board, pos } of positions) {
16966
+ board._panelPositionOffset = pos;
16967
+ }
16968
+ }
16893
16969
  doInitialPanelLayout() {
16894
16970
  if (this.root?.pcbDisabled) return;
16895
16971
  const { db } = this.root;
16896
16972
  const childBoardInstances = this.children.filter(
16897
16973
  (c) => c instanceof Board
16898
16974
  );
16899
- const hasAnyPositionedBoards = childBoardInstances.some(
16900
- (b) => b.props.pcbX !== void 0 || b.props.pcbY !== void 0
16901
- );
16902
- const unpositionedBoards = childBoardInstances.filter(
16903
- (b) => b.props.pcbX === void 0 && b.props.pcbY === void 0
16904
- );
16905
- if (unpositionedBoards.length > 0 && !hasAnyPositionedBoards) {
16906
- const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
16907
- const boardGap = this._parsedProps.boardGap ?? tabWidth;
16908
- const { positions, gridWidth, gridHeight } = packBoardsIntoGrid({
16909
- boards: unpositionedBoards,
16910
- db,
16911
- row: this._parsedProps.row,
16912
- col: this._parsedProps.col,
16913
- cellWidth: this._parsedProps.cellWidth,
16914
- cellHeight: this._parsedProps.cellHeight,
16915
- boardGap
16916
- });
16917
- const panelGlobalPos = this._getGlobalPcbPositionBeforeLayout();
16918
- for (const { board, pos } of positions) {
16919
- const absoluteX = panelGlobalPos.x + pos.x;
16920
- const absoluteY = panelGlobalPos.y + pos.y;
16921
- board._repositionOnPcb({ x: absoluteX, y: absoluteY });
16975
+ const layoutMode = this._parsedProps.layoutMode ?? "none";
16976
+ if (layoutMode === "grid") {
16977
+ for (const board of childBoardInstances) {
16978
+ if (!board.pcb_board_id || !board._panelPositionOffset) continue;
16922
16979
  db.pcb_board.update(board.pcb_board_id, {
16923
- center: { x: absoluteX, y: absoluteY },
16924
16980
  position_mode: "relative_to_panel_anchor",
16925
- display_offset_x: `${pos.x}mm`,
16926
- display_offset_y: `${pos.y}mm`
16981
+ display_offset_x: `${board._panelPositionOffset.x}mm`,
16982
+ display_offset_y: `${board._panelPositionOffset.y}mm`
16927
16983
  });
16928
16984
  }
16929
16985
  const hasExplicitWidth = this._parsedProps.width !== void 0;
16930
16986
  const hasExplicitHeight = this._parsedProps.height !== void 0;
16987
+ const gridWidth = this._cachedGridWidth;
16988
+ const gridHeight = this._cachedGridHeight;
16931
16989
  if (hasExplicitWidth && hasExplicitHeight) {
16932
16990
  db.pcb_panel.update(this.pcb_panel_id, {
16933
- width: distance10.parse(this._parsedProps.width),
16934
- height: distance10.parse(this._parsedProps.height)
16991
+ width: distance11.parse(this._parsedProps.width),
16992
+ height: distance11.parse(this._parsedProps.height)
16935
16993
  });
16936
16994
  } else if (gridWidth > 0 || gridHeight > 0) {
16937
16995
  const {
@@ -16941,20 +16999,20 @@ var Panel = class extends Group6 {
16941
16999
  edgePaddingTop: edgePaddingTopProp,
16942
17000
  edgePaddingBottom: edgePaddingBottomProp
16943
17001
  } = this._parsedProps;
16944
- const edgePadding = distance10.parse(edgePaddingProp ?? 5);
16945
- const edgePaddingLeft = distance10.parse(
17002
+ const edgePadding = distance11.parse(edgePaddingProp ?? 5);
17003
+ const edgePaddingLeft = distance11.parse(
16946
17004
  edgePaddingLeftProp ?? edgePadding
16947
17005
  );
16948
- const edgePaddingRight = distance10.parse(
17006
+ const edgePaddingRight = distance11.parse(
16949
17007
  edgePaddingRightProp ?? edgePadding
16950
17008
  );
16951
- const edgePaddingTop = distance10.parse(edgePaddingTopProp ?? edgePadding);
16952
- const edgePaddingBottom = distance10.parse(
17009
+ const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
17010
+ const edgePaddingBottom = distance11.parse(
16953
17011
  edgePaddingBottomProp ?? edgePadding
16954
17012
  );
16955
17013
  db.pcb_panel.update(this.pcb_panel_id, {
16956
- width: hasExplicitWidth ? distance10.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
16957
- height: hasExplicitHeight ? distance10.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
17014
+ width: hasExplicitWidth ? distance11.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
17015
+ height: hasExplicitHeight ? distance11.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
16958
17016
  });
16959
17017
  }
16960
17018
  } else {
@@ -17010,8 +17068,8 @@ var Panel = class extends Group6 {
17010
17068
  const { db } = this.root;
17011
17069
  const props = this._parsedProps;
17012
17070
  const inserted = db.pcb_panel.insert({
17013
- width: props.width !== void 0 ? distance10.parse(props.width) : 0,
17014
- height: props.height !== void 0 ? distance10.parse(props.height) : 0,
17071
+ width: props.width !== void 0 ? distance11.parse(props.width) : 0,
17072
+ height: props.height !== void 0 ? distance11.parse(props.height) : 0,
17015
17073
  center: this._getGlobalPcbPositionBeforeLayout(),
17016
17074
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17017
17075
  });
@@ -17024,8 +17082,8 @@ var Panel = class extends Group6 {
17024
17082
  const props = this._parsedProps;
17025
17083
  const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
17026
17084
  db.pcb_panel.update(this.pcb_panel_id, {
17027
- width: props.width !== void 0 ? distance10.parse(props.width) : currentPanel?.width,
17028
- height: props.height !== void 0 ? distance10.parse(props.height) : currentPanel?.height,
17085
+ width: props.width !== void 0 ? distance11.parse(props.width) : currentPanel?.width,
17086
+ height: props.height !== void 0 ? distance11.parse(props.height) : currentPanel?.height,
17029
17087
  center: this._getGlobalPcbPositionBeforeLayout(),
17030
17088
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17031
17089
  });
@@ -17776,7 +17834,7 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17776
17834
  if (this.root?.pcbDisabled) return;
17777
17835
  const { db } = this.root;
17778
17836
  const { _parsedProps: props } = this;
17779
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17837
+ const position = this._getGlobalPcbPositionBeforeLayout();
17780
17838
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
17781
17839
  const layer = maybeFlipLayer(props.layer ?? "top");
17782
17840
  if (layer !== "top" && layer !== "bottom") {
@@ -17792,8 +17850,8 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17792
17850
  layer,
17793
17851
  color: props.color,
17794
17852
  center: {
17795
- x: pcbX,
17796
- y: pcbY
17853
+ x: position.x,
17854
+ y: position.y
17797
17855
  },
17798
17856
  width: props.width,
17799
17857
  height: props.height,
@@ -17925,14 +17983,14 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
17925
17983
  if (this.root?.pcbDisabled) return;
17926
17984
  const { db } = this.root;
17927
17985
  const { _parsedProps: props } = this;
17928
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17986
+ const position = this._getGlobalPcbPositionBeforeLayout();
17929
17987
  const container = this.getPrimitiveContainer();
17930
17988
  const subcircuit = this.getSubcircuit();
17931
17989
  const pcb_fabrication_note_text = db.pcb_fabrication_note_text.insert({
17932
17990
  anchor_alignment: props.anchorAlignment,
17933
17991
  anchor_position: {
17934
- x: pcbX,
17935
- y: pcbY
17992
+ x: position.x,
17993
+ y: position.y
17936
17994
  },
17937
17995
  font: props.font ?? "tscircuit2024",
17938
17996
  font_size: props.fontSize ?? 1,
@@ -18556,7 +18614,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18556
18614
  if (this.root?.pcbDisabled) return;
18557
18615
  const { db } = this.root;
18558
18616
  this._matchConnection();
18559
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18617
+ const position = this._getGlobalPcbPositionBeforeLayout();
18560
18618
  const group = this.parent?.getGroup();
18561
18619
  const subcircuit = this.getSubcircuit();
18562
18620
  if (!group || !group.pcb_group_id) return;
@@ -18566,16 +18624,21 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18566
18624
  source_port_id: this.matchedPort?.source_port_id ?? void 0,
18567
18625
  source_trace_id: this.matchedPort ? this._getSourceTraceIdForPort(this.matchedPort) : void 0,
18568
18626
  source_net_id: this.matchedNet ? this.matchedNet.source_net_id : this.matchedPort ? this._getSourceNetIdForPort(this.matchedPort) : void 0,
18569
- x: pcbX,
18570
- y: pcbY
18627
+ x: position.x,
18628
+ y: position.y
18571
18629
  });
18572
18630
  this.pcb_breakout_point_id = pcb_breakout_point.pcb_breakout_point_id;
18573
18631
  }
18574
18632
  _getPcbCircuitJsonBounds() {
18575
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18633
+ const position = this._getGlobalPcbPositionBeforeLayout();
18576
18634
  return {
18577
- center: { x: pcbX, y: pcbY },
18578
- bounds: { left: pcbX, top: pcbY, right: pcbX, bottom: pcbY },
18635
+ center: { x: position.x, y: position.y },
18636
+ bounds: {
18637
+ left: position.x,
18638
+ top: position.y,
18639
+ right: position.x,
18640
+ bottom: position.y
18641
+ },
18579
18642
  width: 0,
18580
18643
  height: 0
18581
18644
  };
@@ -18613,7 +18676,7 @@ import { netLabelProps } from "@tscircuit/props";
18613
18676
  import {
18614
18677
  applyToPoint as applyToPoint17,
18615
18678
  identity as identity4,
18616
- translate as translate7
18679
+ translate as translate8
18617
18680
  } from "transformation-matrix";
18618
18681
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
18619
18682
  var NetLabel = class extends PrimitiveComponent2 {
@@ -18666,7 +18729,7 @@ var NetLabel = class extends PrimitiveComponent2 {
18666
18729
  this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
18667
18730
  { x: 0, y: 0 }
18668
18731
  );
18669
- return translate7(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18732
+ return translate8(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18670
18733
  }
18671
18734
  }
18672
18735
  return super.computeSchematicPropsTransform();
@@ -18822,7 +18885,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18822
18885
  if (this.root?.pcbDisabled) return;
18823
18886
  const { db } = this.root;
18824
18887
  const { _parsedProps: props } = this;
18825
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18888
+ const position = this._getGlobalPcbPositionBeforeLayout();
18826
18889
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
18827
18890
  const layer = maybeFlipLayer(props.layer ?? "top");
18828
18891
  if (layer !== "top" && layer !== "bottom") {
@@ -18830,15 +18893,14 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18830
18893
  `Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`
18831
18894
  );
18832
18895
  }
18833
- const transform = this._computePcbGlobalTransformBeforeLayout();
18834
18896
  const subcircuit = this.getSubcircuit();
18835
18897
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18836
18898
  const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
18837
18899
  pcb_component_id,
18838
18900
  layer,
18839
18901
  center: {
18840
- x: pcbX,
18841
- y: pcbY
18902
+ x: position.x,
18903
+ y: position.y
18842
18904
  },
18843
18905
  radius: props.radius,
18844
18906
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -18958,6 +19020,7 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18958
19020
 
18959
19021
  // lib/components/primitive-components/SilkscreenLine.ts
18960
19022
  import { silkscreenLineProps } from "@tscircuit/props";
19023
+ import { applyToPoint as applyToPoint18 } from "transformation-matrix";
18961
19024
  var SilkscreenLine = class extends PrimitiveComponent2 {
18962
19025
  pcb_silkscreen_line_id = null;
18963
19026
  isPcbPrimitive = true;
@@ -18979,14 +19042,17 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
18979
19042
  );
18980
19043
  }
18981
19044
  const subcircuit = this.getSubcircuit();
19045
+ const transform = this._computePcbGlobalTransformBeforeLayout();
19046
+ const p1 = applyToPoint18(transform, { x: props.x1, y: props.y1 });
19047
+ const p2 = applyToPoint18(transform, { x: props.x2, y: props.y2 });
18982
19048
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18983
19049
  const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
18984
19050
  pcb_component_id,
18985
19051
  layer,
18986
- x1: props.x1,
18987
- y1: props.y1,
18988
- x2: props.x2,
18989
- y2: props.y2,
19052
+ x1: p1.x,
19053
+ y1: p1.y,
19054
+ x2: p2.x,
19055
+ y2: p2.y,
18990
19056
  stroke_width: props.strokeWidth ?? 0.1,
18991
19057
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18992
19058
  pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
@@ -19020,7 +19086,7 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
19020
19086
 
19021
19087
  // lib/components/primitive-components/Fiducial.ts
19022
19088
  import "zod";
19023
- import { distance as distance11 } from "circuit-json";
19089
+ import { distance as distance12 } from "circuit-json";
19024
19090
  import { fiducialProps } from "@tscircuit/props";
19025
19091
  var Fiducial = class extends PrimitiveComponent2 {
19026
19092
  pcb_smtpad_id = null;
@@ -19045,15 +19111,15 @@ var Fiducial = class extends PrimitiveComponent2 {
19045
19111
  shape: "circle",
19046
19112
  x: position.x,
19047
19113
  y: position.y,
19048
- radius: distance11.parse(props.padDiameter) / 2,
19049
- soldermask_margin: props.soldermaskPullback ? distance11.parse(props.soldermaskPullback) : distance11.parse(props.padDiameter) / 2,
19114
+ radius: distance12.parse(props.padDiameter) / 2,
19115
+ soldermask_margin: props.soldermaskPullback ? distance12.parse(props.soldermaskPullback) : distance12.parse(props.padDiameter) / 2,
19050
19116
  is_covered_with_solder_mask: true
19051
19117
  });
19052
19118
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
19053
19119
  }
19054
19120
  getPcbSize() {
19055
19121
  const { _parsedProps: props } = this;
19056
- const d = distance11.parse(props.padDiameter);
19122
+ const d = distance12.parse(props.padDiameter);
19057
19123
  return { width: d, height: d };
19058
19124
  }
19059
19125
  _setPositionFromLayout(newCenter) {
@@ -20834,7 +20900,7 @@ import { identity as identity5 } from "transformation-matrix";
20834
20900
  var package_default = {
20835
20901
  name: "@tscircuit/core",
20836
20902
  type: "module",
20837
- version: "0.0.971",
20903
+ version: "0.0.973",
20838
20904
  types: "dist/index.d.ts",
20839
20905
  main: "dist/index.js",
20840
20906
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.972",
4
+ "version": "0.0.974",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",