@tscircuit/core 0.0.716 → 0.0.718

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 +89 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -10180,11 +10180,29 @@ var Group_doInitialPcbLayoutPack = (group) => {
10180
10180
  } = props;
10181
10181
  const gap = pcbPackGap ?? pcbGap ?? gapProp;
10182
10182
  const gapMm = length4.parse(gap ?? DEFAULT_MIN_GAP);
10183
+ const chipMarginsMap = {};
10184
+ const collectMargins = (comp) => {
10185
+ if (comp?.pcb_component_id && comp?._parsedProps) {
10186
+ const props2 = comp._parsedProps;
10187
+ const left = length4.parse(props2.pcbMarginLeft ?? props2.pcbMarginX ?? 0);
10188
+ const right = length4.parse(props2.pcbMarginRight ?? props2.pcbMarginX ?? 0);
10189
+ const top = length4.parse(props2.pcbMarginTop ?? props2.pcbMarginY ?? 0);
10190
+ const bottom = length4.parse(
10191
+ props2.pcbMarginBottom ?? props2.pcbMarginY ?? 0
10192
+ );
10193
+ if (left || right || top || bottom) {
10194
+ chipMarginsMap[comp.pcb_component_id] = { left, right, top, bottom };
10195
+ }
10196
+ }
10197
+ if (comp?.children) comp.children.forEach(collectMargins);
10198
+ };
10199
+ collectMargins(group);
10183
10200
  const packInput = {
10184
10201
  ...convertPackOutputToPackInput(
10185
10202
  convertCircuitJsonToPackOutput(db.toArray(), {
10186
10203
  source_group_id: group.source_group_id,
10187
- shouldAddInnerObstacles: true
10204
+ shouldAddInnerObstacles: true,
10205
+ chipMarginsMap
10188
10206
  })
10189
10207
  ),
10190
10208
  // @ts-expect-error we're missing some pack order strategies
@@ -11974,6 +11992,48 @@ import {
11974
11992
  checkEachPcbPortConnectedToPcbTraces,
11975
11993
  checkEachPcbTraceNonOverlapping
11976
11994
  } from "@tscircuit/checks";
11995
+ var getRoundedRectOutline = (width, height, radius) => {
11996
+ const r = Math.min(radius, width / 2, height / 2);
11997
+ const segments = Math.max(1, Math.ceil(Math.PI / 2 * r));
11998
+ const step = Math.PI / 2 / segments;
11999
+ const w2 = width / 2;
12000
+ const h2 = height / 2;
12001
+ const outline = [];
12002
+ outline.push({ x: -w2 + r, y: -h2 });
12003
+ outline.push({ x: w2 - r, y: -h2 });
12004
+ for (let i = 1; i <= segments; i++) {
12005
+ const theta = -Math.PI / 2 + i * step;
12006
+ outline.push({
12007
+ x: w2 - r + r * Math.cos(theta),
12008
+ y: -h2 + r + r * Math.sin(theta)
12009
+ });
12010
+ }
12011
+ outline.push({ x: w2, y: h2 - r });
12012
+ for (let i = 1; i <= segments; i++) {
12013
+ const theta = 0 + i * step;
12014
+ outline.push({
12015
+ x: w2 - r + r * Math.cos(theta),
12016
+ y: h2 - r + r * Math.sin(theta)
12017
+ });
12018
+ }
12019
+ outline.push({ x: -w2 + r, y: h2 });
12020
+ for (let i = 1; i <= segments; i++) {
12021
+ const theta = Math.PI / 2 + i * step;
12022
+ outline.push({
12023
+ x: -w2 + r + r * Math.cos(theta),
12024
+ y: h2 - r + r * Math.sin(theta)
12025
+ });
12026
+ }
12027
+ outline.push({ x: -w2, y: -h2 + r });
12028
+ for (let i = 1; i <= segments; i++) {
12029
+ const theta = Math.PI + i * step;
12030
+ outline.push({
12031
+ x: -w2 + r + r * Math.cos(theta),
12032
+ y: -h2 + r + r * Math.sin(theta)
12033
+ });
12034
+ }
12035
+ return outline;
12036
+ };
11977
12037
  var Board = class extends Group6 {
11978
12038
  pcb_board_id = null;
11979
12039
  _drcChecksComplete = false;
@@ -12049,11 +12109,26 @@ var Board = class extends Group6 {
12049
12109
  };
12050
12110
  const finalWidth = props.width ?? computedWidth;
12051
12111
  const finalHeight = props.height ?? computedHeight;
12052
- db.pcb_board.update(this.pcb_board_id, {
12112
+ let outline = props.outline;
12113
+ if (!outline && props.borderRadius != null && finalWidth > 0 && finalHeight > 0) {
12114
+ outline = getRoundedRectOutline(
12115
+ finalWidth,
12116
+ finalHeight,
12117
+ props.borderRadius
12118
+ );
12119
+ }
12120
+ const update = {
12053
12121
  width: finalWidth,
12054
12122
  height: finalHeight,
12055
12123
  center
12056
- });
12124
+ };
12125
+ if (outline) {
12126
+ update.outline = outline.map((point) => ({
12127
+ x: point.x + (props.outlineOffsetX ?? 0),
12128
+ y: point.y + (props.outlineOffsetY ?? 0)
12129
+ }));
12130
+ }
12131
+ db.pcb_board.update(this.pcb_board_id, update);
12057
12132
  }
12058
12133
  // Recompute autosize after child components update (e.g., async footprints)
12059
12134
  updatePcbBoardAutoSize() {
@@ -12115,13 +12190,21 @@ var Board = class extends Group6 {
12115
12190
  y: (minY + maxY) / 2 + (props.outlineOffsetY ?? 0)
12116
12191
  };
12117
12192
  }
12193
+ let outline = props.outline;
12194
+ if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
12195
+ outline = getRoundedRectOutline(
12196
+ computedWidth,
12197
+ computedHeight,
12198
+ props.borderRadius
12199
+ );
12200
+ }
12118
12201
  const pcb_board = db.pcb_board.insert({
12119
12202
  center,
12120
12203
  thickness: this.boardThickness,
12121
12204
  num_layers: this.allLayers.length,
12122
12205
  width: computedWidth,
12123
12206
  height: computedHeight,
12124
- outline: props.outline?.map((point) => ({
12207
+ outline: outline?.map((point) => ({
12125
12208
  x: point.x + (props.outlineOffsetX ?? 0),
12126
12209
  y: point.y + (props.outlineOffsetY ?? 0)
12127
12210
  })),
@@ -14711,7 +14794,7 @@ import { identity as identity6 } from "transformation-matrix";
14711
14794
  var package_default = {
14712
14795
  name: "@tscircuit/core",
14713
14796
  type: "module",
14714
- version: "0.0.715",
14797
+ version: "0.0.717",
14715
14798
  types: "dist/index.d.ts",
14716
14799
  main: "dist/index.js",
14717
14800
  module: "dist/index.js",
@@ -14806,7 +14889,7 @@ var package_default = {
14806
14889
  dependencies: {
14807
14890
  "@flatten-js/core": "^1.6.2",
14808
14891
  "@lume/kiwi": "^0.4.3",
14809
- "calculate-packing": "0.0.33",
14892
+ "calculate-packing": "0.0.34",
14810
14893
  "css-select": "5.1.0",
14811
14894
  "format-si-unit": "^0.0.3",
14812
14895
  nanoid: "^5.0.7",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.716",
4
+ "version": "0.0.718",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {
97
97
  "@flatten-js/core": "^1.6.2",
98
98
  "@lume/kiwi": "^0.4.3",
99
- "calculate-packing": "0.0.33",
99
+ "calculate-packing": "0.0.34",
100
100
  "css-select": "5.1.0",
101
101
  "format-si-unit": "^0.0.3",
102
102
  "nanoid": "^5.0.7",