@tscircuit/core 0.0.287 → 0.0.288

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 +15 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4029,9 +4029,21 @@ var Board = class extends Group {
4029
4029
  if (this.root?.pcbDisabled) return;
4030
4030
  const { db } = this.root;
4031
4031
  const { _parsedProps: props } = this;
4032
- if (!props.width || !props.height) {
4032
+ if (!props.outline && (!props.width || !props.height)) {
4033
4033
  throw new Error("Board width and height or an outline are required");
4034
4034
  }
4035
+ let computedWidth = props.width;
4036
+ let computedHeight = props.height;
4037
+ if (props.outline) {
4038
+ const xValues = props.outline.map((point) => point.x);
4039
+ const yValues = props.outline.map((point) => point.y);
4040
+ const minX = Math.min(...xValues);
4041
+ const maxX = Math.max(...xValues);
4042
+ const minY = Math.min(...yValues);
4043
+ const maxY = Math.max(...yValues);
4044
+ computedWidth = maxX - minX;
4045
+ computedHeight = maxY - minY;
4046
+ }
4035
4047
  const pcb_board = db.pcb_board.insert({
4036
4048
  center: {
4037
4049
  x: (props.pcbX ?? 0) + (props.outlineOffsetX ?? 0),
@@ -4039,8 +4051,8 @@ var Board = class extends Group {
4039
4051
  },
4040
4052
  thickness: this.boardThickness,
4041
4053
  num_layers: this.allLayers.length,
4042
- width: props.width,
4043
- height: props.height,
4054
+ width: computedWidth,
4055
+ height: computedHeight,
4044
4056
  outline: props.outline?.map((point) => ({
4045
4057
  x: point.x + (props.outlineOffsetX ?? 0),
4046
4058
  y: point.y + (props.outlineOffsetY ?? 0)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.287",
4
+ "version": "0.0.288",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",