@tscircuit/core 0.0.971 → 0.0.973

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 {
@@ -16166,6 +16166,7 @@ import {
16166
16166
  checkPinMustBeConnected
16167
16167
  } from "@tscircuit/checks";
16168
16168
  import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
16169
+ import { compose as compose6, translate as translate7 } from "transformation-matrix";
16169
16170
  var MIN_EFFECTIVE_BORDER_RADIUS_MM = 0.01;
16170
16171
  var getRoundedRectOutline = (width, height, radius) => {
16171
16172
  const w2 = width / 2;
@@ -16226,6 +16227,7 @@ var Board = class extends Group6 {
16226
16227
  source_board_id = null;
16227
16228
  _drcChecksComplete = false;
16228
16229
  _connectedSchematicPortPairs = /* @__PURE__ */ new Set();
16230
+ _panelPositionOffset = null;
16229
16231
  get isSubcircuit() {
16230
16232
  return true;
16231
16233
  }
@@ -16257,6 +16259,16 @@ var Board = class extends Group6 {
16257
16259
  _getSubcircuitLayerCount() {
16258
16260
  return this._parsedProps.layers ?? 2;
16259
16261
  }
16262
+ _computePcbGlobalTransformBeforeLayout() {
16263
+ if (this._panelPositionOffset) {
16264
+ const parentTransform = this.parent?._computePcbGlobalTransformBeforeLayout?.() ?? { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
16265
+ return compose6(
16266
+ parentTransform,
16267
+ translate7(this._panelPositionOffset.x, this._panelPositionOffset.y)
16268
+ );
16269
+ }
16270
+ return super._computePcbGlobalTransformBeforeLayout();
16271
+ }
16260
16272
  _getBoardCalcVariables() {
16261
16273
  const { _parsedProps: props } = this;
16262
16274
  const isAutoSized = (props.width == null || props.height == null) && !props.outline;
@@ -16466,6 +16478,18 @@ var Board = class extends Group6 {
16466
16478
  props.borderRadius
16467
16479
  );
16468
16480
  }
16481
+ let outlineTranslation = { x: 0, y: 0 };
16482
+ if (outline && outline.length > 0 && this._panelPositionOffset) {
16483
+ const outlineBounds = getBoundsFromPoints4(outline);
16484
+ if (outlineBounds) {
16485
+ const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
16486
+ const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
16487
+ outlineTranslation = {
16488
+ x: center.x - outlineCenterX,
16489
+ y: center.y - outlineCenterY
16490
+ };
16491
+ }
16492
+ }
16469
16493
  const pcb_board = db.pcb_board.insert({
16470
16494
  source_board_id: this.source_board_id,
16471
16495
  center,
@@ -16474,8 +16498,8 @@ var Board = class extends Group6 {
16474
16498
  width: computedWidth,
16475
16499
  height: computedHeight,
16476
16500
  outline: outline?.map((point2) => ({
16477
- x: point2.x + (props.outlineOffsetX ?? 0),
16478
- y: point2.y + (props.outlineOffsetY ?? 0)
16501
+ x: point2.x + (props.outlineOffsetX ?? 0) + outlineTranslation.x,
16502
+ y: point2.y + (props.outlineOffsetY ?? 0) + outlineTranslation.y
16479
16503
  })),
16480
16504
  material: props.material
16481
16505
  });
@@ -16559,26 +16583,6 @@ var Board = class extends Group6 {
16559
16583
  if (Math.abs(deltaX) < 1e-6 && Math.abs(deltaY) < 1e-6) {
16560
16584
  return;
16561
16585
  }
16562
- for (const child of this.children) {
16563
- if (child instanceof NormalComponent3) {
16564
- let childOldCenter;
16565
- if (child.pcb_component_id) {
16566
- const comp = db.pcb_component.get(child.pcb_component_id);
16567
- if (comp) childOldCenter = comp.center;
16568
- } else if (child instanceof Group6 && child.pcb_group_id) {
16569
- const group = db.pcb_group.get(child.pcb_group_id);
16570
- if (group) childOldCenter = group.center;
16571
- }
16572
- if (childOldCenter) {
16573
- child._repositionOnPcb({
16574
- x: childOldCenter.x + deltaX,
16575
- y: childOldCenter.y + deltaY
16576
- });
16577
- }
16578
- } else if (child.isPcbPrimitive && "_moveCircuitJsonElements" in child && typeof child._moveCircuitJsonElements === "function") {
16579
- child._moveCircuitJsonElements({ deltaX, deltaY });
16580
- }
16581
- }
16582
16586
  if (this.pcb_board_id) {
16583
16587
  db.pcb_board.update(this.pcb_board_id, { center: position });
16584
16588
  if (pcbBoard?.outline) {
@@ -16605,7 +16609,7 @@ var Board = class extends Group6 {
16605
16609
 
16606
16610
  // lib/components/normal-components/Panel.ts
16607
16611
  import { panelProps } from "@tscircuit/props";
16608
- import { distance as distance10 } from "circuit-json";
16612
+ import { distance as distance11 } from "circuit-json";
16609
16613
 
16610
16614
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
16611
16615
  import * as Flatten from "@flatten-js/core";
@@ -16790,7 +16794,38 @@ function generatePanelTabsAndMouseBites(boards, options) {
16790
16794
  }
16791
16795
 
16792
16796
  // lib/utils/panels/pack-boards-into-grid.ts
16797
+ import { distance as distance10 } from "circuit-json";
16798
+
16799
+ // lib/utils/panels/get-board-dimensions-from-props.ts
16800
+ import { getBoundsFromPoints as getBoundsFromPoints5 } from "@tscircuit/math-utils";
16793
16801
  import { distance as distance9 } from "circuit-json";
16802
+ var getBoardDimensionsFromProps = (board) => {
16803
+ const props = board._parsedProps;
16804
+ let width = props.width != null ? distance9.parse(props.width) : void 0;
16805
+ let height = props.height != null ? distance9.parse(props.height) : void 0;
16806
+ if ((width === void 0 || height === void 0) && props.outline?.length) {
16807
+ const outlineBounds = getBoundsFromPoints5(props.outline);
16808
+ if (outlineBounds) {
16809
+ width ??= outlineBounds.maxX - outlineBounds.minX;
16810
+ height ??= outlineBounds.maxY - outlineBounds.minY;
16811
+ }
16812
+ }
16813
+ if ((width === void 0 || height === void 0) && props.circuitJson?.length) {
16814
+ const pcbBoardFromJson = props.circuitJson.find(
16815
+ (elm) => elm.type === "pcb_board"
16816
+ );
16817
+ if (pcbBoardFromJson) {
16818
+ width ??= pcbBoardFromJson.width;
16819
+ height ??= pcbBoardFromJson.height;
16820
+ }
16821
+ }
16822
+ return {
16823
+ width: width ?? 0,
16824
+ height: height ?? 0
16825
+ };
16826
+ };
16827
+
16828
+ // lib/utils/panels/pack-boards-into-grid.ts
16794
16829
  var packBoardsIntoGrid = ({
16795
16830
  boards,
16796
16831
  db,
@@ -16801,11 +16836,24 @@ var packBoardsIntoGrid = ({
16801
16836
  boardGap
16802
16837
  }) => {
16803
16838
  const boardsWithDims = boards.map((board) => {
16804
- const pcbBoard = db.pcb_board.get(board.pcb_board_id);
16805
- if (!pcbBoard || pcbBoard.width === void 0 || pcbBoard.height === void 0) {
16839
+ let width;
16840
+ let height;
16841
+ if (db && board.pcb_board_id) {
16842
+ const pcbBoard = db.pcb_board.get(board.pcb_board_id);
16843
+ if (pcbBoard?.width !== void 0 && pcbBoard?.height !== void 0) {
16844
+ width = pcbBoard.width;
16845
+ height = pcbBoard.height;
16846
+ }
16847
+ }
16848
+ if (width === void 0 || height === void 0) {
16849
+ const propsDims = getBoardDimensionsFromProps(board);
16850
+ width = propsDims.width;
16851
+ height = propsDims.height;
16852
+ }
16853
+ if (width === 0 && height === 0) {
16806
16854
  return null;
16807
16855
  }
16808
- return { board, width: pcbBoard.width, height: pcbBoard.height };
16856
+ return { board, width, height };
16809
16857
  }).filter((b) => b !== null);
16810
16858
  if (boardsWithDims.length === 0) {
16811
16859
  return {
@@ -16821,17 +16869,17 @@ var packBoardsIntoGrid = ({
16821
16869
  const colWidths = Array(cols).fill(0);
16822
16870
  const rowHeights = Array(rows).fill(0);
16823
16871
  boardsWithDims.forEach((b, i) => {
16824
- const col2 = i % cols;
16825
- const row2 = Math.floor(i / cols);
16826
- if (row2 < rowHeights.length && b.height > rowHeights[row2]) {
16827
- rowHeights[row2] = b.height;
16872
+ const colIdx = i % cols;
16873
+ const rowIdx = Math.floor(i / cols);
16874
+ if (rowIdx < rowHeights.length && b.height > rowHeights[rowIdx]) {
16875
+ rowHeights[rowIdx] = b.height;
16828
16876
  }
16829
- if (col2 < colWidths.length && b.width > colWidths[col2]) {
16830
- colWidths[col2] = b.width;
16877
+ if (colIdx < colWidths.length && b.width > colWidths[colIdx]) {
16878
+ colWidths[colIdx] = b.width;
16831
16879
  }
16832
16880
  });
16833
- const minCellWidth = cellWidth ? distance9.parse(cellWidth) : 0;
16834
- const minCellHeight = cellHeight ? distance9.parse(cellHeight) : 0;
16881
+ const minCellWidth = cellWidth ? distance10.parse(cellWidth) : 0;
16882
+ const minCellHeight = cellHeight ? distance10.parse(cellHeight) : 0;
16835
16883
  for (let i = 0; i < colWidths.length; i++) {
16836
16884
  colWidths[i] = Math.max(colWidths[i], minCellWidth);
16837
16885
  }
@@ -16852,15 +16900,15 @@ var packBoardsIntoGrid = ({
16852
16900
  }
16853
16901
  const positions = [];
16854
16902
  boardsWithDims.forEach((b, i) => {
16855
- const col2 = i % cols;
16856
- const row2 = Math.floor(i / cols);
16857
- if (row2 >= rowYOffsets.length || col2 >= colXOffsets.length) return;
16858
- const cellX = colXOffsets[col2];
16859
- const cellY = rowYOffsets[row2];
16860
- const cellWidth2 = colWidths[col2];
16861
- const cellHeight2 = rowHeights[row2];
16862
- const boardX = cellX + cellWidth2 / 2;
16863
- const boardY = cellY + cellHeight2 / 2;
16903
+ const colIdx = i % cols;
16904
+ const rowIdx = Math.floor(i / cols);
16905
+ if (rowIdx >= rowYOffsets.length || colIdx >= colXOffsets.length) return;
16906
+ const cellX = colXOffsets[colIdx];
16907
+ const cellY = rowYOffsets[rowIdx];
16908
+ const currentCellWidth = colWidths[colIdx];
16909
+ const currentCellHeight = rowHeights[rowIdx];
16910
+ const boardX = cellX + currentCellWidth / 2;
16911
+ const boardY = cellY + currentCellHeight / 2;
16864
16912
  positions.push({
16865
16913
  board: b.board,
16866
16914
  pos: { x: boardX, y: boardY }
@@ -16891,48 +16939,55 @@ var Panel = class extends Group6 {
16891
16939
  }
16892
16940
  super.add(component);
16893
16941
  }
16942
+ _cachedGridWidth = 0;
16943
+ _cachedGridHeight = 0;
16944
+ doInitialPanelBoardLayout() {
16945
+ if (this.root?.pcbDisabled) return;
16946
+ const layoutMode = this._parsedProps.layoutMode ?? "none";
16947
+ if (layoutMode !== "grid") return;
16948
+ const childBoardInstances = this.children.filter(
16949
+ (c) => c instanceof Board
16950
+ );
16951
+ const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
16952
+ const boardGap = this._parsedProps.boardGap ?? tabWidth;
16953
+ const { positions, gridWidth, gridHeight } = packBoardsIntoGrid({
16954
+ boards: childBoardInstances,
16955
+ row: this._parsedProps.row,
16956
+ col: this._parsedProps.col,
16957
+ cellWidth: this._parsedProps.cellWidth,
16958
+ cellHeight: this._parsedProps.cellHeight,
16959
+ boardGap
16960
+ });
16961
+ this._cachedGridWidth = gridWidth;
16962
+ this._cachedGridHeight = gridHeight;
16963
+ for (const { board, pos } of positions) {
16964
+ board._panelPositionOffset = pos;
16965
+ }
16966
+ }
16894
16967
  doInitialPanelLayout() {
16895
16968
  if (this.root?.pcbDisabled) return;
16896
16969
  const { db } = this.root;
16897
16970
  const childBoardInstances = this.children.filter(
16898
16971
  (c) => c instanceof Board
16899
16972
  );
16900
- const hasAnyPositionedBoards = childBoardInstances.some(
16901
- (b) => b.props.pcbX !== void 0 || b.props.pcbY !== void 0
16902
- );
16903
- const unpositionedBoards = childBoardInstances.filter(
16904
- (b) => b.props.pcbX === void 0 && b.props.pcbY === void 0
16905
- );
16906
- if (unpositionedBoards.length > 0 && !hasAnyPositionedBoards) {
16907
- const tabWidth = this._parsedProps.tabWidth ?? DEFAULT_TAB_WIDTH;
16908
- const boardGap = this._parsedProps.boardGap ?? tabWidth;
16909
- const { positions, gridWidth, gridHeight } = packBoardsIntoGrid({
16910
- boards: unpositionedBoards,
16911
- db,
16912
- row: this._parsedProps.row,
16913
- col: this._parsedProps.col,
16914
- cellWidth: this._parsedProps.cellWidth,
16915
- cellHeight: this._parsedProps.cellHeight,
16916
- boardGap
16917
- });
16918
- const panelGlobalPos = this._getGlobalPcbPositionBeforeLayout();
16919
- for (const { board, pos } of positions) {
16920
- const absoluteX = panelGlobalPos.x + pos.x;
16921
- const absoluteY = panelGlobalPos.y + pos.y;
16922
- board._repositionOnPcb({ x: absoluteX, y: absoluteY });
16973
+ const layoutMode = this._parsedProps.layoutMode ?? "none";
16974
+ if (layoutMode === "grid") {
16975
+ for (const board of childBoardInstances) {
16976
+ if (!board.pcb_board_id || !board._panelPositionOffset) continue;
16923
16977
  db.pcb_board.update(board.pcb_board_id, {
16924
- center: { x: absoluteX, y: absoluteY },
16925
16978
  position_mode: "relative_to_panel_anchor",
16926
- display_offset_x: `${pos.x}mm`,
16927
- display_offset_y: `${pos.y}mm`
16979
+ display_offset_x: `${board._panelPositionOffset.x}mm`,
16980
+ display_offset_y: `${board._panelPositionOffset.y}mm`
16928
16981
  });
16929
16982
  }
16930
16983
  const hasExplicitWidth = this._parsedProps.width !== void 0;
16931
16984
  const hasExplicitHeight = this._parsedProps.height !== void 0;
16985
+ const gridWidth = this._cachedGridWidth;
16986
+ const gridHeight = this._cachedGridHeight;
16932
16987
  if (hasExplicitWidth && hasExplicitHeight) {
16933
16988
  db.pcb_panel.update(this.pcb_panel_id, {
16934
- width: distance10.parse(this._parsedProps.width),
16935
- height: distance10.parse(this._parsedProps.height)
16989
+ width: distance11.parse(this._parsedProps.width),
16990
+ height: distance11.parse(this._parsedProps.height)
16936
16991
  });
16937
16992
  } else if (gridWidth > 0 || gridHeight > 0) {
16938
16993
  const {
@@ -16942,20 +16997,20 @@ var Panel = class extends Group6 {
16942
16997
  edgePaddingTop: edgePaddingTopProp,
16943
16998
  edgePaddingBottom: edgePaddingBottomProp
16944
16999
  } = this._parsedProps;
16945
- const edgePadding = distance10.parse(edgePaddingProp ?? 5);
16946
- const edgePaddingLeft = distance10.parse(
17000
+ const edgePadding = distance11.parse(edgePaddingProp ?? 5);
17001
+ const edgePaddingLeft = distance11.parse(
16947
17002
  edgePaddingLeftProp ?? edgePadding
16948
17003
  );
16949
- const edgePaddingRight = distance10.parse(
17004
+ const edgePaddingRight = distance11.parse(
16950
17005
  edgePaddingRightProp ?? edgePadding
16951
17006
  );
16952
- const edgePaddingTop = distance10.parse(edgePaddingTopProp ?? edgePadding);
16953
- const edgePaddingBottom = distance10.parse(
17007
+ const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
17008
+ const edgePaddingBottom = distance11.parse(
16954
17009
  edgePaddingBottomProp ?? edgePadding
16955
17010
  );
16956
17011
  db.pcb_panel.update(this.pcb_panel_id, {
16957
- width: hasExplicitWidth ? distance10.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
16958
- height: hasExplicitHeight ? distance10.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
17012
+ width: hasExplicitWidth ? distance11.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
17013
+ height: hasExplicitHeight ? distance11.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
16959
17014
  });
16960
17015
  }
16961
17016
  } else {
@@ -17011,8 +17066,8 @@ var Panel = class extends Group6 {
17011
17066
  const { db } = this.root;
17012
17067
  const props = this._parsedProps;
17013
17068
  const inserted = db.pcb_panel.insert({
17014
- width: props.width !== void 0 ? distance10.parse(props.width) : 0,
17015
- height: props.height !== void 0 ? distance10.parse(props.height) : 0,
17069
+ width: props.width !== void 0 ? distance11.parse(props.width) : 0,
17070
+ height: props.height !== void 0 ? distance11.parse(props.height) : 0,
17016
17071
  center: this._getGlobalPcbPositionBeforeLayout(),
17017
17072
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17018
17073
  });
@@ -17025,8 +17080,8 @@ var Panel = class extends Group6 {
17025
17080
  const props = this._parsedProps;
17026
17081
  const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
17027
17082
  db.pcb_panel.update(this.pcb_panel_id, {
17028
- width: props.width !== void 0 ? distance10.parse(props.width) : currentPanel?.width,
17029
- height: props.height !== void 0 ? distance10.parse(props.height) : currentPanel?.height,
17083
+ width: props.width !== void 0 ? distance11.parse(props.width) : currentPanel?.width,
17084
+ height: props.height !== void 0 ? distance11.parse(props.height) : currentPanel?.height,
17030
17085
  center: this._getGlobalPcbPositionBeforeLayout(),
17031
17086
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17032
17087
  });
@@ -17777,7 +17832,7 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17777
17832
  if (this.root?.pcbDisabled) return;
17778
17833
  const { db } = this.root;
17779
17834
  const { _parsedProps: props } = this;
17780
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17835
+ const position = this._getGlobalPcbPositionBeforeLayout();
17781
17836
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
17782
17837
  const layer = maybeFlipLayer(props.layer ?? "top");
17783
17838
  if (layer !== "top" && layer !== "bottom") {
@@ -17793,8 +17848,8 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17793
17848
  layer,
17794
17849
  color: props.color,
17795
17850
  center: {
17796
- x: pcbX,
17797
- y: pcbY
17851
+ x: position.x,
17852
+ y: position.y
17798
17853
  },
17799
17854
  width: props.width,
17800
17855
  height: props.height,
@@ -17926,14 +17981,14 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
17926
17981
  if (this.root?.pcbDisabled) return;
17927
17982
  const { db } = this.root;
17928
17983
  const { _parsedProps: props } = this;
17929
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17984
+ const position = this._getGlobalPcbPositionBeforeLayout();
17930
17985
  const container = this.getPrimitiveContainer();
17931
17986
  const subcircuit = this.getSubcircuit();
17932
17987
  const pcb_fabrication_note_text = db.pcb_fabrication_note_text.insert({
17933
17988
  anchor_alignment: props.anchorAlignment,
17934
17989
  anchor_position: {
17935
- x: pcbX,
17936
- y: pcbY
17990
+ x: position.x,
17991
+ y: position.y
17937
17992
  },
17938
17993
  font: props.font ?? "tscircuit2024",
17939
17994
  font_size: props.fontSize ?? 1,
@@ -18557,7 +18612,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18557
18612
  if (this.root?.pcbDisabled) return;
18558
18613
  const { db } = this.root;
18559
18614
  this._matchConnection();
18560
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18615
+ const position = this._getGlobalPcbPositionBeforeLayout();
18561
18616
  const group = this.parent?.getGroup();
18562
18617
  const subcircuit = this.getSubcircuit();
18563
18618
  if (!group || !group.pcb_group_id) return;
@@ -18567,16 +18622,21 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18567
18622
  source_port_id: this.matchedPort?.source_port_id ?? void 0,
18568
18623
  source_trace_id: this.matchedPort ? this._getSourceTraceIdForPort(this.matchedPort) : void 0,
18569
18624
  source_net_id: this.matchedNet ? this.matchedNet.source_net_id : this.matchedPort ? this._getSourceNetIdForPort(this.matchedPort) : void 0,
18570
- x: pcbX,
18571
- y: pcbY
18625
+ x: position.x,
18626
+ y: position.y
18572
18627
  });
18573
18628
  this.pcb_breakout_point_id = pcb_breakout_point.pcb_breakout_point_id;
18574
18629
  }
18575
18630
  _getPcbCircuitJsonBounds() {
18576
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18631
+ const position = this._getGlobalPcbPositionBeforeLayout();
18577
18632
  return {
18578
- center: { x: pcbX, y: pcbY },
18579
- bounds: { left: pcbX, top: pcbY, right: pcbX, bottom: pcbY },
18633
+ center: { x: position.x, y: position.y },
18634
+ bounds: {
18635
+ left: position.x,
18636
+ top: position.y,
18637
+ right: position.x,
18638
+ bottom: position.y
18639
+ },
18580
18640
  width: 0,
18581
18641
  height: 0
18582
18642
  };
@@ -18614,7 +18674,7 @@ import { netLabelProps } from "@tscircuit/props";
18614
18674
  import {
18615
18675
  applyToPoint as applyToPoint17,
18616
18676
  identity as identity4,
18617
- translate as translate7
18677
+ translate as translate8
18618
18678
  } from "transformation-matrix";
18619
18679
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
18620
18680
  var NetLabel = class extends PrimitiveComponent2 {
@@ -18667,7 +18727,7 @@ var NetLabel = class extends PrimitiveComponent2 {
18667
18727
  this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
18668
18728
  { x: 0, y: 0 }
18669
18729
  );
18670
- return translate7(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18730
+ return translate8(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18671
18731
  }
18672
18732
  }
18673
18733
  return super.computeSchematicPropsTransform();
@@ -18823,7 +18883,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18823
18883
  if (this.root?.pcbDisabled) return;
18824
18884
  const { db } = this.root;
18825
18885
  const { _parsedProps: props } = this;
18826
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18886
+ const position = this._getGlobalPcbPositionBeforeLayout();
18827
18887
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
18828
18888
  const layer = maybeFlipLayer(props.layer ?? "top");
18829
18889
  if (layer !== "top" && layer !== "bottom") {
@@ -18831,15 +18891,14 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18831
18891
  `Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`
18832
18892
  );
18833
18893
  }
18834
- const transform = this._computePcbGlobalTransformBeforeLayout();
18835
18894
  const subcircuit = this.getSubcircuit();
18836
18895
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18837
18896
  const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
18838
18897
  pcb_component_id,
18839
18898
  layer,
18840
18899
  center: {
18841
- x: pcbX,
18842
- y: pcbY
18900
+ x: position.x,
18901
+ y: position.y
18843
18902
  },
18844
18903
  radius: props.radius,
18845
18904
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -18959,6 +19018,7 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18959
19018
 
18960
19019
  // lib/components/primitive-components/SilkscreenLine.ts
18961
19020
  import { silkscreenLineProps } from "@tscircuit/props";
19021
+ import { applyToPoint as applyToPoint18 } from "transformation-matrix";
18962
19022
  var SilkscreenLine = class extends PrimitiveComponent2 {
18963
19023
  pcb_silkscreen_line_id = null;
18964
19024
  isPcbPrimitive = true;
@@ -18980,14 +19040,17 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
18980
19040
  );
18981
19041
  }
18982
19042
  const subcircuit = this.getSubcircuit();
19043
+ const transform = this._computePcbGlobalTransformBeforeLayout();
19044
+ const p1 = applyToPoint18(transform, { x: props.x1, y: props.y1 });
19045
+ const p2 = applyToPoint18(transform, { x: props.x2, y: props.y2 });
18983
19046
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18984
19047
  const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
18985
19048
  pcb_component_id,
18986
19049
  layer,
18987
- x1: props.x1,
18988
- y1: props.y1,
18989
- x2: props.x2,
18990
- y2: props.y2,
19050
+ x1: p1.x,
19051
+ y1: p1.y,
19052
+ x2: p2.x,
19053
+ y2: p2.y,
18991
19054
  stroke_width: props.strokeWidth ?? 0.1,
18992
19055
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18993
19056
  pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
@@ -19021,7 +19084,7 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
19021
19084
 
19022
19085
  // lib/components/primitive-components/Fiducial.ts
19023
19086
  import "zod";
19024
- import { distance as distance11 } from "circuit-json";
19087
+ import { distance as distance12 } from "circuit-json";
19025
19088
  import { fiducialProps } from "@tscircuit/props";
19026
19089
  var Fiducial = class extends PrimitiveComponent2 {
19027
19090
  pcb_smtpad_id = null;
@@ -19046,15 +19109,15 @@ var Fiducial = class extends PrimitiveComponent2 {
19046
19109
  shape: "circle",
19047
19110
  x: position.x,
19048
19111
  y: position.y,
19049
- radius: distance11.parse(props.padDiameter) / 2,
19050
- soldermask_margin: props.soldermaskPullback ? distance11.parse(props.soldermaskPullback) : distance11.parse(props.padDiameter) / 2,
19112
+ radius: distance12.parse(props.padDiameter) / 2,
19113
+ soldermask_margin: props.soldermaskPullback ? distance12.parse(props.soldermaskPullback) : distance12.parse(props.padDiameter) / 2,
19051
19114
  is_covered_with_solder_mask: true
19052
19115
  });
19053
19116
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
19054
19117
  }
19055
19118
  getPcbSize() {
19056
19119
  const { _parsedProps: props } = this;
19057
- const d = distance11.parse(props.padDiameter);
19120
+ const d = distance12.parse(props.padDiameter);
19058
19121
  return { width: d, height: d };
19059
19122
  }
19060
19123
  _setPositionFromLayout(newCenter) {
@@ -20835,7 +20898,7 @@ import { identity as identity5 } from "transformation-matrix";
20835
20898
  var package_default = {
20836
20899
  name: "@tscircuit/core",
20837
20900
  type: "module",
20838
- version: "0.0.970",
20901
+ version: "0.0.972",
20839
20902
  types: "dist/index.d.ts",
20840
20903
  main: "dist/index.js",
20841
20904
  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.971",
4
+ "version": "0.0.973",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",