@tscircuit/core 0.0.802 → 0.0.804

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.
Files changed (2) hide show
  1. package/dist/index.js +75 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1949,6 +1949,7 @@ var SmtPad = class extends PrimitiveComponent2 {
1949
1949
  shape: "rect",
1950
1950
  width: isRotated90Degrees ? props.height : props.width,
1951
1951
  height: isRotated90Degrees ? props.width : props.height,
1952
+ corner_radius: props.cornerRadius ?? 0,
1952
1953
  port_hints: props.portHints.map((ph) => ph.toString()),
1953
1954
  is_covered_with_solder_mask: isCoveredWithSolderMask,
1954
1955
  x: position.x,
@@ -1961,6 +1962,7 @@ var SmtPad = class extends PrimitiveComponent2 {
1961
1962
  shape: "rotated_rect",
1962
1963
  width: props.width,
1963
1964
  height: props.height,
1965
+ corner_radius: props.cornerRadius ?? 0,
1964
1966
  x: position.x,
1965
1967
  y: position.y,
1966
1968
  ccw_rotation: finalRotationDegrees,
@@ -6828,6 +6830,7 @@ var Trace3 = class extends PrimitiveComponent2 {
6828
6830
  };
6829
6831
 
6830
6832
  // lib/components/base-components/NormalComponent/NormalComponent__getMinimumFlexContainerSize.ts
6833
+ import { getBoundsFromPoints } from "@tscircuit/math-utils";
6831
6834
  var NormalComponent__getMinimumFlexContainerSize = (component) => {
6832
6835
  const { db } = component.root;
6833
6836
  if (component.pcb_component_id) {
@@ -6843,6 +6846,14 @@ var NormalComponent__getMinimumFlexContainerSize = (component) => {
6843
6846
  component.pcb_group_id
6844
6847
  );
6845
6848
  if (!pcbGroup) return null;
6849
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
6850
+ const bounds = getBoundsFromPoints(pcbGroup.outline);
6851
+ if (!bounds) return null;
6852
+ return {
6853
+ width: bounds.maxX - bounds.minX,
6854
+ height: bounds.maxY - bounds.minY
6855
+ };
6856
+ }
6846
6857
  return {
6847
6858
  width: pcbGroup.width ?? 0,
6848
6859
  height: pcbGroup.height ?? 0
@@ -8705,7 +8716,9 @@ var CapacityMeshAutorouter = class {
8705
8716
  };
8706
8717
 
8707
8718
  // lib/components/primitive-components/Group/Group.ts
8708
- import "circuit-json";
8719
+ import {
8720
+ distance as distance5
8721
+ } from "circuit-json";
8709
8722
  import Debug12 from "debug";
8710
8723
  import "zod";
8711
8724
 
@@ -9348,6 +9361,9 @@ var normalizePinLabels = (inputPinLabels) => {
9348
9361
  return result;
9349
9362
  };
9350
9363
 
9364
+ // lib/components/primitive-components/Group/Group.ts
9365
+ import { getBoundsFromPoints as getBoundsFromPoints3 } from "@tscircuit/math-utils";
9366
+
9351
9367
  // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
9352
9368
  import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
9353
9369
  import { getGraphicsForBpcGraph, layoutSchematicGraphVariants } from "bpc-graph";
@@ -12457,6 +12473,7 @@ ${spiceString}`);
12457
12473
  }
12458
12474
 
12459
12475
  // lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
12476
+ import { getBoundsFromPoints as getBoundsFromPoints2 } from "@tscircuit/math-utils";
12460
12477
  function Group_doInitialPcbComponentAnchorAlignment(group) {
12461
12478
  if (group.root?.pcbDisabled) return;
12462
12479
  if (!group.pcb_group_id) return;
@@ -12468,7 +12485,16 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
12468
12485
  const { db } = group.root;
12469
12486
  const pcbGroup = db.pcb_group.get(group.pcb_group_id);
12470
12487
  if (!pcbGroup) return;
12471
- const { width, height, center } = pcbGroup;
12488
+ let width = pcbGroup.width;
12489
+ let height = pcbGroup.height;
12490
+ const { center } = pcbGroup;
12491
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
12492
+ const bounds2 = getBoundsFromPoints2(pcbGroup.outline);
12493
+ if (bounds2) {
12494
+ width = bounds2.maxX - bounds2.minX;
12495
+ height = bounds2.maxY - bounds2.minY;
12496
+ }
12497
+ }
12472
12498
  if (!width || !height) return;
12473
12499
  const bounds = {
12474
12500
  left: center.x - width / 2,
@@ -12534,6 +12560,10 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
12534
12560
  center: newCenter
12535
12561
  });
12536
12562
  }
12563
+ db.pcb_group.update(group.pcb_group_id, {
12564
+ anchor_position: targetPosition,
12565
+ anchor_alignment: pcbPositionAnchor
12566
+ });
12537
12567
  }
12538
12568
 
12539
12569
  // lib/components/primitive-components/Group/Group.ts
@@ -12592,13 +12622,18 @@ var Group6 = class extends NormalComponent3 {
12592
12622
  if (this.root?.pcbDisabled) return;
12593
12623
  const { db } = this.root;
12594
12624
  const { _parsedProps: props } = this;
12625
+ const groupProps2 = props;
12626
+ const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
12627
+ const numericOutline = hasOutline ? groupProps2.outline.map((point) => ({
12628
+ x: distance5.parse(point.x),
12629
+ y: distance5.parse(point.y)
12630
+ })) : void 0;
12595
12631
  const pcb_group = db.pcb_group.insert({
12596
12632
  is_subcircuit: this.isSubcircuit,
12597
12633
  subcircuit_id: this.subcircuit_id ?? this.getSubcircuit()?.subcircuit_id,
12598
12634
  name: this.name,
12599
12635
  center: this._getGlobalPcbPositionBeforeLayout(),
12600
- width: 0,
12601
- height: 0,
12636
+ ...hasOutline ? { outline: numericOutline } : { width: 0, height: 0 },
12602
12637
  pcb_component_ids: [],
12603
12638
  source_group_id: this.source_group_id,
12604
12639
  autorouter_configuration: props.autorouter ? {
@@ -12616,8 +12651,28 @@ var Group6 = class extends NormalComponent3 {
12616
12651
  if (this.root?.pcbDisabled) return;
12617
12652
  const { db } = this.root;
12618
12653
  const props = this._parsedProps;
12619
- const bounds = getBoundsOfPcbComponents(this.children);
12654
+ const hasOutline = props.outline && props.outline.length > 0;
12620
12655
  if (this.pcb_group_id) {
12656
+ const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
12657
+ if (hasOutline) {
12658
+ const numericOutline = props.outline.map((point) => ({
12659
+ x: distance5.parse(point.x),
12660
+ y: distance5.parse(point.y)
12661
+ }));
12662
+ const outlineBounds = getBoundsFromPoints3(numericOutline);
12663
+ if (!outlineBounds) return;
12664
+ const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
12665
+ const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
12666
+ const center2 = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
12667
+ x: centerX2,
12668
+ y: centerY2
12669
+ } : { x: centerX2, y: centerY2 };
12670
+ db.pcb_group.update(this.pcb_group_id, {
12671
+ center: center2
12672
+ });
12673
+ return;
12674
+ }
12675
+ const bounds = getBoundsOfPcbComponents(this.children);
12621
12676
  let width = bounds.width;
12622
12677
  let height = bounds.height;
12623
12678
  let centerX = (bounds.minX + bounds.maxX) / 2;
@@ -12629,24 +12684,15 @@ var Group6 = class extends NormalComponent3 {
12629
12684
  centerX += (padRight - padLeft) / 2;
12630
12685
  centerY += (padTop - padBottom) / 2;
12631
12686
  }
12632
- const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
12633
12687
  const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
12634
12688
  x: centerX,
12635
12689
  y: centerY
12636
12690
  } : { x: centerX, y: centerY };
12637
- const updateData = {
12691
+ db.pcb_group.update(this.pcb_group_id, {
12638
12692
  width: Number(props.width ?? width),
12639
12693
  height: Number(props.height ?? height),
12640
12694
  center
12641
- };
12642
- const pcbPositionAnchor = props.pcbPositionAnchor;
12643
- if (pcbPositionAnchor && hasExplicitPositioning) {
12644
- const pcbX = this._parsedProps.pcbX ?? 0;
12645
- const pcbY = this._parsedProps.pcbY ?? 0;
12646
- updateData.anchor_position = { x: pcbX, y: pcbY };
12647
- updateData.anchor_alignment = pcbPositionAnchor;
12648
- }
12649
- db.pcb_group.update(this.pcb_group_id, updateData);
12695
+ });
12650
12696
  }
12651
12697
  }
12652
12698
  unnamedElementCounter = {};
@@ -13334,6 +13380,7 @@ import {
13334
13380
  checkSameNetViaSpacing,
13335
13381
  checkPcbComponentOverlap
13336
13382
  } from "@tscircuit/checks";
13383
+ import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
13337
13384
  var getRoundedRectOutline = (width, height, radius) => {
13338
13385
  const r = Math.min(radius, width / 2, height / 2);
13339
13386
  const maxArcLengthPerSegment = 0.1;
@@ -13445,7 +13492,16 @@ var Board = class extends Group6 {
13445
13492
  updateBounds(pcbComponent.center, pcbComponent.width, pcbComponent.height);
13446
13493
  }
13447
13494
  for (const pcbGroup of allPcbGroups) {
13448
- updateBounds(pcbGroup.center, pcbGroup.width ?? 0, pcbGroup.height ?? 0);
13495
+ let width = pcbGroup.width ?? 0;
13496
+ let height = pcbGroup.height ?? 0;
13497
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
13498
+ const bounds = getBoundsFromPoints4(pcbGroup.outline);
13499
+ if (bounds) {
13500
+ width = bounds.maxX - bounds.minX;
13501
+ height = bounds.maxY - bounds.minY;
13502
+ }
13503
+ }
13504
+ updateBounds(pcbGroup.center, width, height);
13449
13505
  }
13450
13506
  if (props.boardAnchorPosition) {
13451
13507
  const { x, y } = props.boardAnchorPosition;
@@ -17056,7 +17112,7 @@ import { identity as identity6 } from "transformation-matrix";
17056
17112
  var package_default = {
17057
17113
  name: "@tscircuit/core",
17058
17114
  type: "module",
17059
- version: "0.0.801",
17115
+ version: "0.0.803",
17060
17116
  types: "dist/index.d.ts",
17061
17117
  main: "dist/index.js",
17062
17118
  module: "dist/index.js",
@@ -17094,7 +17150,7 @@ var package_default = {
17094
17150
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
17095
17151
  "@tscircuit/log-soup": "^1.0.2",
17096
17152
  "@tscircuit/matchpack": "^0.0.16",
17097
- "@tscircuit/math-utils": "^0.0.28",
17153
+ "@tscircuit/math-utils": "^0.0.29",
17098
17154
  "@tscircuit/miniflex": "^0.0.4",
17099
17155
  "@tscircuit/props": "0.0.369",
17100
17156
  "@tscircuit/schematic-autolayout": "^0.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.802",
4
+ "version": "0.0.804",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
40
40
  "@tscircuit/log-soup": "^1.0.2",
41
41
  "@tscircuit/matchpack": "^0.0.16",
42
- "@tscircuit/math-utils": "^0.0.28",
42
+ "@tscircuit/math-utils": "^0.0.29",
43
43
  "@tscircuit/miniflex": "^0.0.4",
44
44
  "@tscircuit/props": "0.0.369",
45
45
  "@tscircuit/schematic-autolayout": "^0.0.6",