@tscircuit/core 0.0.972 → 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,25 +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.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
16586
  if (this.pcb_board_id) {
16582
16587
  db.pcb_board.update(this.pcb_board_id, { center: position });
16583
16588
  if (pcbBoard?.outline) {
@@ -16604,7 +16609,7 @@ var Board = class extends Group6 {
16604
16609
 
16605
16610
  // lib/components/normal-components/Panel.ts
16606
16611
  import { panelProps } from "@tscircuit/props";
16607
- import { distance as distance10 } from "circuit-json";
16612
+ import { distance as distance11 } from "circuit-json";
16608
16613
 
16609
16614
  // lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
16610
16615
  import * as Flatten from "@flatten-js/core";
@@ -16789,7 +16794,38 @@ function generatePanelTabsAndMouseBites(boards, options) {
16789
16794
  }
16790
16795
 
16791
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";
16792
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
16793
16829
  var packBoardsIntoGrid = ({
16794
16830
  boards,
16795
16831
  db,
@@ -16800,11 +16836,24 @@ var packBoardsIntoGrid = ({
16800
16836
  boardGap
16801
16837
  }) => {
16802
16838
  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) {
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) {
16805
16854
  return null;
16806
16855
  }
16807
- return { board, width: pcbBoard.width, height: pcbBoard.height };
16856
+ return { board, width, height };
16808
16857
  }).filter((b) => b !== null);
16809
16858
  if (boardsWithDims.length === 0) {
16810
16859
  return {
@@ -16820,17 +16869,17 @@ var packBoardsIntoGrid = ({
16820
16869
  const colWidths = Array(cols).fill(0);
16821
16870
  const rowHeights = Array(rows).fill(0);
16822
16871
  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;
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;
16827
16876
  }
16828
- if (col2 < colWidths.length && b.width > colWidths[col2]) {
16829
- colWidths[col2] = b.width;
16877
+ if (colIdx < colWidths.length && b.width > colWidths[colIdx]) {
16878
+ colWidths[colIdx] = b.width;
16830
16879
  }
16831
16880
  });
16832
- const minCellWidth = cellWidth ? distance9.parse(cellWidth) : 0;
16833
- const minCellHeight = cellHeight ? distance9.parse(cellHeight) : 0;
16881
+ const minCellWidth = cellWidth ? distance10.parse(cellWidth) : 0;
16882
+ const minCellHeight = cellHeight ? distance10.parse(cellHeight) : 0;
16834
16883
  for (let i = 0; i < colWidths.length; i++) {
16835
16884
  colWidths[i] = Math.max(colWidths[i], minCellWidth);
16836
16885
  }
@@ -16851,15 +16900,15 @@ var packBoardsIntoGrid = ({
16851
16900
  }
16852
16901
  const positions = [];
16853
16902
  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;
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;
16863
16912
  positions.push({
16864
16913
  board: b.board,
16865
16914
  pos: { x: boardX, y: boardY }
@@ -16890,48 +16939,55 @@ var Panel = class extends Group6 {
16890
16939
  }
16891
16940
  super.add(component);
16892
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
+ }
16893
16967
  doInitialPanelLayout() {
16894
16968
  if (this.root?.pcbDisabled) return;
16895
16969
  const { db } = this.root;
16896
16970
  const childBoardInstances = this.children.filter(
16897
16971
  (c) => c instanceof Board
16898
16972
  );
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 });
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;
16922
16977
  db.pcb_board.update(board.pcb_board_id, {
16923
- center: { x: absoluteX, y: absoluteY },
16924
16978
  position_mode: "relative_to_panel_anchor",
16925
- display_offset_x: `${pos.x}mm`,
16926
- display_offset_y: `${pos.y}mm`
16979
+ display_offset_x: `${board._panelPositionOffset.x}mm`,
16980
+ display_offset_y: `${board._panelPositionOffset.y}mm`
16927
16981
  });
16928
16982
  }
16929
16983
  const hasExplicitWidth = this._parsedProps.width !== void 0;
16930
16984
  const hasExplicitHeight = this._parsedProps.height !== void 0;
16985
+ const gridWidth = this._cachedGridWidth;
16986
+ const gridHeight = this._cachedGridHeight;
16931
16987
  if (hasExplicitWidth && hasExplicitHeight) {
16932
16988
  db.pcb_panel.update(this.pcb_panel_id, {
16933
- width: distance10.parse(this._parsedProps.width),
16934
- height: distance10.parse(this._parsedProps.height)
16989
+ width: distance11.parse(this._parsedProps.width),
16990
+ height: distance11.parse(this._parsedProps.height)
16935
16991
  });
16936
16992
  } else if (gridWidth > 0 || gridHeight > 0) {
16937
16993
  const {
@@ -16941,20 +16997,20 @@ var Panel = class extends Group6 {
16941
16997
  edgePaddingTop: edgePaddingTopProp,
16942
16998
  edgePaddingBottom: edgePaddingBottomProp
16943
16999
  } = this._parsedProps;
16944
- const edgePadding = distance10.parse(edgePaddingProp ?? 5);
16945
- const edgePaddingLeft = distance10.parse(
17000
+ const edgePadding = distance11.parse(edgePaddingProp ?? 5);
17001
+ const edgePaddingLeft = distance11.parse(
16946
17002
  edgePaddingLeftProp ?? edgePadding
16947
17003
  );
16948
- const edgePaddingRight = distance10.parse(
17004
+ const edgePaddingRight = distance11.parse(
16949
17005
  edgePaddingRightProp ?? edgePadding
16950
17006
  );
16951
- const edgePaddingTop = distance10.parse(edgePaddingTopProp ?? edgePadding);
16952
- const edgePaddingBottom = distance10.parse(
17007
+ const edgePaddingTop = distance11.parse(edgePaddingTopProp ?? edgePadding);
17008
+ const edgePaddingBottom = distance11.parse(
16953
17009
  edgePaddingBottomProp ?? edgePadding
16954
17010
  );
16955
17011
  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
17012
+ width: hasExplicitWidth ? distance11.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
17013
+ height: hasExplicitHeight ? distance11.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
16958
17014
  });
16959
17015
  }
16960
17016
  } else {
@@ -17010,8 +17066,8 @@ var Panel = class extends Group6 {
17010
17066
  const { db } = this.root;
17011
17067
  const props = this._parsedProps;
17012
17068
  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,
17069
+ width: props.width !== void 0 ? distance11.parse(props.width) : 0,
17070
+ height: props.height !== void 0 ? distance11.parse(props.height) : 0,
17015
17071
  center: this._getGlobalPcbPositionBeforeLayout(),
17016
17072
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17017
17073
  });
@@ -17024,8 +17080,8 @@ var Panel = class extends Group6 {
17024
17080
  const props = this._parsedProps;
17025
17081
  const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
17026
17082
  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,
17083
+ width: props.width !== void 0 ? distance11.parse(props.width) : currentPanel?.width,
17084
+ height: props.height !== void 0 ? distance11.parse(props.height) : currentPanel?.height,
17029
17085
  center: this._getGlobalPcbPositionBeforeLayout(),
17030
17086
  covered_with_solder_mask: !(props.noSolderMask ?? false)
17031
17087
  });
@@ -17776,7 +17832,7 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17776
17832
  if (this.root?.pcbDisabled) return;
17777
17833
  const { db } = this.root;
17778
17834
  const { _parsedProps: props } = this;
17779
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17835
+ const position = this._getGlobalPcbPositionBeforeLayout();
17780
17836
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
17781
17837
  const layer = maybeFlipLayer(props.layer ?? "top");
17782
17838
  if (layer !== "top" && layer !== "bottom") {
@@ -17792,8 +17848,8 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
17792
17848
  layer,
17793
17849
  color: props.color,
17794
17850
  center: {
17795
- x: pcbX,
17796
- y: pcbY
17851
+ x: position.x,
17852
+ y: position.y
17797
17853
  },
17798
17854
  width: props.width,
17799
17855
  height: props.height,
@@ -17925,14 +17981,14 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
17925
17981
  if (this.root?.pcbDisabled) return;
17926
17982
  const { db } = this.root;
17927
17983
  const { _parsedProps: props } = this;
17928
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
17984
+ const position = this._getGlobalPcbPositionBeforeLayout();
17929
17985
  const container = this.getPrimitiveContainer();
17930
17986
  const subcircuit = this.getSubcircuit();
17931
17987
  const pcb_fabrication_note_text = db.pcb_fabrication_note_text.insert({
17932
17988
  anchor_alignment: props.anchorAlignment,
17933
17989
  anchor_position: {
17934
- x: pcbX,
17935
- y: pcbY
17990
+ x: position.x,
17991
+ y: position.y
17936
17992
  },
17937
17993
  font: props.font ?? "tscircuit2024",
17938
17994
  font_size: props.fontSize ?? 1,
@@ -18556,7 +18612,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18556
18612
  if (this.root?.pcbDisabled) return;
18557
18613
  const { db } = this.root;
18558
18614
  this._matchConnection();
18559
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18615
+ const position = this._getGlobalPcbPositionBeforeLayout();
18560
18616
  const group = this.parent?.getGroup();
18561
18617
  const subcircuit = this.getSubcircuit();
18562
18618
  if (!group || !group.pcb_group_id) return;
@@ -18566,16 +18622,21 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
18566
18622
  source_port_id: this.matchedPort?.source_port_id ?? void 0,
18567
18623
  source_trace_id: this.matchedPort ? this._getSourceTraceIdForPort(this.matchedPort) : void 0,
18568
18624
  source_net_id: this.matchedNet ? this.matchedNet.source_net_id : this.matchedPort ? this._getSourceNetIdForPort(this.matchedPort) : void 0,
18569
- x: pcbX,
18570
- y: pcbY
18625
+ x: position.x,
18626
+ y: position.y
18571
18627
  });
18572
18628
  this.pcb_breakout_point_id = pcb_breakout_point.pcb_breakout_point_id;
18573
18629
  }
18574
18630
  _getPcbCircuitJsonBounds() {
18575
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18631
+ const position = this._getGlobalPcbPositionBeforeLayout();
18576
18632
  return {
18577
- center: { x: pcbX, y: pcbY },
18578
- 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
+ },
18579
18640
  width: 0,
18580
18641
  height: 0
18581
18642
  };
@@ -18613,7 +18674,7 @@ import { netLabelProps } from "@tscircuit/props";
18613
18674
  import {
18614
18675
  applyToPoint as applyToPoint17,
18615
18676
  identity as identity4,
18616
- translate as translate7
18677
+ translate as translate8
18617
18678
  } from "transformation-matrix";
18618
18679
  import { calculateElbow as calculateElbow2 } from "calculate-elbow";
18619
18680
  var NetLabel = class extends PrimitiveComponent2 {
@@ -18666,7 +18727,7 @@ var NetLabel = class extends PrimitiveComponent2 {
18666
18727
  this.parent?.computeSchematicGlobalTransform?.() ?? identity4(),
18667
18728
  { x: 0, y: 0 }
18668
18729
  );
18669
- return translate7(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18730
+ return translate8(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
18670
18731
  }
18671
18732
  }
18672
18733
  return super.computeSchematicPropsTransform();
@@ -18822,7 +18883,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18822
18883
  if (this.root?.pcbDisabled) return;
18823
18884
  const { db } = this.root;
18824
18885
  const { _parsedProps: props } = this;
18825
- const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
18886
+ const position = this._getGlobalPcbPositionBeforeLayout();
18826
18887
  const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
18827
18888
  const layer = maybeFlipLayer(props.layer ?? "top");
18828
18889
  if (layer !== "top" && layer !== "bottom") {
@@ -18830,15 +18891,14 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
18830
18891
  `Invalid layer "${layer}" for SilkscreenCircle. Must be "top" or "bottom".`
18831
18892
  );
18832
18893
  }
18833
- const transform = this._computePcbGlobalTransformBeforeLayout();
18834
18894
  const subcircuit = this.getSubcircuit();
18835
18895
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18836
18896
  const pcb_silkscreen_circle = db.pcb_silkscreen_circle.insert({
18837
18897
  pcb_component_id,
18838
18898
  layer,
18839
18899
  center: {
18840
- x: pcbX,
18841
- y: pcbY
18900
+ x: position.x,
18901
+ y: position.y
18842
18902
  },
18843
18903
  radius: props.radius,
18844
18904
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -18958,6 +19018,7 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
18958
19018
 
18959
19019
  // lib/components/primitive-components/SilkscreenLine.ts
18960
19020
  import { silkscreenLineProps } from "@tscircuit/props";
19021
+ import { applyToPoint as applyToPoint18 } from "transformation-matrix";
18961
19022
  var SilkscreenLine = class extends PrimitiveComponent2 {
18962
19023
  pcb_silkscreen_line_id = null;
18963
19024
  isPcbPrimitive = true;
@@ -18979,14 +19040,17 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
18979
19040
  );
18980
19041
  }
18981
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 });
18982
19046
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
18983
19047
  const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
18984
19048
  pcb_component_id,
18985
19049
  layer,
18986
- x1: props.x1,
18987
- y1: props.y1,
18988
- x2: props.x2,
18989
- y2: props.y2,
19050
+ x1: p1.x,
19051
+ y1: p1.y,
19052
+ x2: p2.x,
19053
+ y2: p2.y,
18990
19054
  stroke_width: props.strokeWidth ?? 0.1,
18991
19055
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
18992
19056
  pcb_group_id: subcircuit?.getGroup()?.pcb_group_id ?? void 0
@@ -19020,7 +19084,7 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
19020
19084
 
19021
19085
  // lib/components/primitive-components/Fiducial.ts
19022
19086
  import "zod";
19023
- import { distance as distance11 } from "circuit-json";
19087
+ import { distance as distance12 } from "circuit-json";
19024
19088
  import { fiducialProps } from "@tscircuit/props";
19025
19089
  var Fiducial = class extends PrimitiveComponent2 {
19026
19090
  pcb_smtpad_id = null;
@@ -19045,15 +19109,15 @@ var Fiducial = class extends PrimitiveComponent2 {
19045
19109
  shape: "circle",
19046
19110
  x: position.x,
19047
19111
  y: position.y,
19048
- radius: distance11.parse(props.padDiameter) / 2,
19049
- 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,
19050
19114
  is_covered_with_solder_mask: true
19051
19115
  });
19052
19116
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
19053
19117
  }
19054
19118
  getPcbSize() {
19055
19119
  const { _parsedProps: props } = this;
19056
- const d = distance11.parse(props.padDiameter);
19120
+ const d = distance12.parse(props.padDiameter);
19057
19121
  return { width: d, height: d };
19058
19122
  }
19059
19123
  _setPositionFromLayout(newCenter) {
@@ -20834,7 +20898,7 @@ import { identity as identity5 } from "transformation-matrix";
20834
20898
  var package_default = {
20835
20899
  name: "@tscircuit/core",
20836
20900
  type: "module",
20837
- version: "0.0.971",
20901
+ version: "0.0.972",
20838
20902
  types: "dist/index.d.ts",
20839
20903
  main: "dist/index.js",
20840
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.972",
4
+ "version": "0.0.973",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",