@tscircuit/core 0.0.801 → 0.0.803

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 +78 -21
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1907,8 +1907,11 @@ var SmtPad = class extends PrimitiveComponent2 {
1907
1907
  const rotationTolerance = 0.01;
1908
1908
  const isAxisAligned = Math.abs(normalizedRotationDegrees) < rotationTolerance || Math.abs(normalizedRotationDegrees - 180) < rotationTolerance || Math.abs(normalizedRotationDegrees - 360) < rotationTolerance;
1909
1909
  const isRotated90Degrees = Math.abs(normalizedRotationDegrees - 90) < rotationTolerance || Math.abs(normalizedRotationDegrees - 270) < rotationTolerance;
1910
- const finalRotationDegrees = Math.abs(normalizedRotationDegrees - 360) < rotationTolerance ? 0 : normalizedRotationDegrees;
1911
- const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
1910
+ let finalRotationDegrees = Math.abs(normalizedRotationDegrees - 360) < rotationTolerance ? 0 : normalizedRotationDegrees;
1911
+ const { maybeFlipLayer, isFlipped } = this._getPcbPrimitiveFlippedHelpers();
1912
+ if (isFlipped) {
1913
+ finalRotationDegrees = (360 - finalRotationDegrees + 360) % 360;
1914
+ }
1912
1915
  let pcb_smtpad = null;
1913
1916
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
1914
1917
  if (props.shape === "circle") {
@@ -6825,6 +6828,7 @@ var Trace3 = class extends PrimitiveComponent2 {
6825
6828
  };
6826
6829
 
6827
6830
  // lib/components/base-components/NormalComponent/NormalComponent__getMinimumFlexContainerSize.ts
6831
+ import { getBoundsFromPoints } from "@tscircuit/math-utils";
6828
6832
  var NormalComponent__getMinimumFlexContainerSize = (component) => {
6829
6833
  const { db } = component.root;
6830
6834
  if (component.pcb_component_id) {
@@ -6840,6 +6844,14 @@ var NormalComponent__getMinimumFlexContainerSize = (component) => {
6840
6844
  component.pcb_group_id
6841
6845
  );
6842
6846
  if (!pcbGroup) return null;
6847
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
6848
+ const bounds = getBoundsFromPoints(pcbGroup.outline);
6849
+ if (!bounds) return null;
6850
+ return {
6851
+ width: bounds.maxX - bounds.minX,
6852
+ height: bounds.maxY - bounds.minY
6853
+ };
6854
+ }
6843
6855
  return {
6844
6856
  width: pcbGroup.width ?? 0,
6845
6857
  height: pcbGroup.height ?? 0
@@ -8702,7 +8714,9 @@ var CapacityMeshAutorouter = class {
8702
8714
  };
8703
8715
 
8704
8716
  // lib/components/primitive-components/Group/Group.ts
8705
- import "circuit-json";
8717
+ import {
8718
+ distance as distance5
8719
+ } from "circuit-json";
8706
8720
  import Debug12 from "debug";
8707
8721
  import "zod";
8708
8722
 
@@ -9345,6 +9359,9 @@ var normalizePinLabels = (inputPinLabels) => {
9345
9359
  return result;
9346
9360
  };
9347
9361
 
9362
+ // lib/components/primitive-components/Group/Group.ts
9363
+ import { getBoundsFromPoints as getBoundsFromPoints3 } from "@tscircuit/math-utils";
9364
+
9348
9365
  // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutMatchAdapt.ts
9349
9366
  import { convertCircuitJsonToBpc } from "circuit-json-to-bpc";
9350
9367
  import { getGraphicsForBpcGraph, layoutSchematicGraphVariants } from "bpc-graph";
@@ -12454,6 +12471,7 @@ ${spiceString}`);
12454
12471
  }
12455
12472
 
12456
12473
  // lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
12474
+ import { getBoundsFromPoints as getBoundsFromPoints2 } from "@tscircuit/math-utils";
12457
12475
  function Group_doInitialPcbComponentAnchorAlignment(group) {
12458
12476
  if (group.root?.pcbDisabled) return;
12459
12477
  if (!group.pcb_group_id) return;
@@ -12465,7 +12483,16 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
12465
12483
  const { db } = group.root;
12466
12484
  const pcbGroup = db.pcb_group.get(group.pcb_group_id);
12467
12485
  if (!pcbGroup) return;
12468
- const { width, height, center } = pcbGroup;
12486
+ let width = pcbGroup.width;
12487
+ let height = pcbGroup.height;
12488
+ const { center } = pcbGroup;
12489
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
12490
+ const bounds2 = getBoundsFromPoints2(pcbGroup.outline);
12491
+ if (bounds2) {
12492
+ width = bounds2.maxX - bounds2.minX;
12493
+ height = bounds2.maxY - bounds2.minY;
12494
+ }
12495
+ }
12469
12496
  if (!width || !height) return;
12470
12497
  const bounds = {
12471
12498
  left: center.x - width / 2,
@@ -12531,6 +12558,10 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
12531
12558
  center: newCenter
12532
12559
  });
12533
12560
  }
12561
+ db.pcb_group.update(group.pcb_group_id, {
12562
+ anchor_position: targetPosition,
12563
+ anchor_alignment: pcbPositionAnchor
12564
+ });
12534
12565
  }
12535
12566
 
12536
12567
  // lib/components/primitive-components/Group/Group.ts
@@ -12589,13 +12620,18 @@ var Group6 = class extends NormalComponent3 {
12589
12620
  if (this.root?.pcbDisabled) return;
12590
12621
  const { db } = this.root;
12591
12622
  const { _parsedProps: props } = this;
12623
+ const groupProps2 = props;
12624
+ const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
12625
+ const numericOutline = hasOutline ? groupProps2.outline.map((point) => ({
12626
+ x: distance5.parse(point.x),
12627
+ y: distance5.parse(point.y)
12628
+ })) : void 0;
12592
12629
  const pcb_group = db.pcb_group.insert({
12593
12630
  is_subcircuit: this.isSubcircuit,
12594
12631
  subcircuit_id: this.subcircuit_id ?? this.getSubcircuit()?.subcircuit_id,
12595
12632
  name: this.name,
12596
12633
  center: this._getGlobalPcbPositionBeforeLayout(),
12597
- width: 0,
12598
- height: 0,
12634
+ ...hasOutline ? { outline: numericOutline } : { width: 0, height: 0 },
12599
12635
  pcb_component_ids: [],
12600
12636
  source_group_id: this.source_group_id,
12601
12637
  autorouter_configuration: props.autorouter ? {
@@ -12613,8 +12649,28 @@ var Group6 = class extends NormalComponent3 {
12613
12649
  if (this.root?.pcbDisabled) return;
12614
12650
  const { db } = this.root;
12615
12651
  const props = this._parsedProps;
12616
- const bounds = getBoundsOfPcbComponents(this.children);
12652
+ const hasOutline = props.outline && props.outline.length > 0;
12617
12653
  if (this.pcb_group_id) {
12654
+ const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
12655
+ if (hasOutline) {
12656
+ const numericOutline = props.outline.map((point) => ({
12657
+ x: distance5.parse(point.x),
12658
+ y: distance5.parse(point.y)
12659
+ }));
12660
+ const outlineBounds = getBoundsFromPoints3(numericOutline);
12661
+ if (!outlineBounds) return;
12662
+ const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
12663
+ const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
12664
+ const center2 = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
12665
+ x: centerX2,
12666
+ y: centerY2
12667
+ } : { x: centerX2, y: centerY2 };
12668
+ db.pcb_group.update(this.pcb_group_id, {
12669
+ center: center2
12670
+ });
12671
+ return;
12672
+ }
12673
+ const bounds = getBoundsOfPcbComponents(this.children);
12618
12674
  let width = bounds.width;
12619
12675
  let height = bounds.height;
12620
12676
  let centerX = (bounds.minX + bounds.maxX) / 2;
@@ -12626,24 +12682,15 @@ var Group6 = class extends NormalComponent3 {
12626
12682
  centerX += (padRight - padLeft) / 2;
12627
12683
  centerY += (padTop - padBottom) / 2;
12628
12684
  }
12629
- const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
12630
12685
  const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
12631
12686
  x: centerX,
12632
12687
  y: centerY
12633
12688
  } : { x: centerX, y: centerY };
12634
- const updateData = {
12689
+ db.pcb_group.update(this.pcb_group_id, {
12635
12690
  width: Number(props.width ?? width),
12636
12691
  height: Number(props.height ?? height),
12637
12692
  center
12638
- };
12639
- const pcbPositionAnchor = props.pcbPositionAnchor;
12640
- if (pcbPositionAnchor && hasExplicitPositioning) {
12641
- const pcbX = this._parsedProps.pcbX ?? 0;
12642
- const pcbY = this._parsedProps.pcbY ?? 0;
12643
- updateData.anchor_position = { x: pcbX, y: pcbY };
12644
- updateData.anchor_alignment = pcbPositionAnchor;
12645
- }
12646
- db.pcb_group.update(this.pcb_group_id, updateData);
12693
+ });
12647
12694
  }
12648
12695
  }
12649
12696
  unnamedElementCounter = {};
@@ -13331,6 +13378,7 @@ import {
13331
13378
  checkSameNetViaSpacing,
13332
13379
  checkPcbComponentOverlap
13333
13380
  } from "@tscircuit/checks";
13381
+ import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
13334
13382
  var getRoundedRectOutline = (width, height, radius) => {
13335
13383
  const r = Math.min(radius, width / 2, height / 2);
13336
13384
  const maxArcLengthPerSegment = 0.1;
@@ -13442,7 +13490,16 @@ var Board = class extends Group6 {
13442
13490
  updateBounds(pcbComponent.center, pcbComponent.width, pcbComponent.height);
13443
13491
  }
13444
13492
  for (const pcbGroup of allPcbGroups) {
13445
- updateBounds(pcbGroup.center, pcbGroup.width ?? 0, pcbGroup.height ?? 0);
13493
+ let width = pcbGroup.width ?? 0;
13494
+ let height = pcbGroup.height ?? 0;
13495
+ if (pcbGroup.outline && pcbGroup.outline.length > 0) {
13496
+ const bounds = getBoundsFromPoints4(pcbGroup.outline);
13497
+ if (bounds) {
13498
+ width = bounds.maxX - bounds.minX;
13499
+ height = bounds.maxY - bounds.minY;
13500
+ }
13501
+ }
13502
+ updateBounds(pcbGroup.center, width, height);
13446
13503
  }
13447
13504
  if (props.boardAnchorPosition) {
13448
13505
  const { x, y } = props.boardAnchorPosition;
@@ -17053,7 +17110,7 @@ import { identity as identity6 } from "transformation-matrix";
17053
17110
  var package_default = {
17054
17111
  name: "@tscircuit/core",
17055
17112
  type: "module",
17056
- version: "0.0.800",
17113
+ version: "0.0.802",
17057
17114
  types: "dist/index.d.ts",
17058
17115
  main: "dist/index.js",
17059
17116
  module: "dist/index.js",
@@ -17091,7 +17148,7 @@ var package_default = {
17091
17148
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
17092
17149
  "@tscircuit/log-soup": "^1.0.2",
17093
17150
  "@tscircuit/matchpack": "^0.0.16",
17094
- "@tscircuit/math-utils": "^0.0.28",
17151
+ "@tscircuit/math-utils": "^0.0.29",
17095
17152
  "@tscircuit/miniflex": "^0.0.4",
17096
17153
  "@tscircuit/props": "0.0.369",
17097
17154
  "@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.801",
4
+ "version": "0.0.803",
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",