@tscircuit/core 0.0.715 → 0.0.717

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
@@ -17498,6 +17498,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
17498
17498
  holeShape: zod.ZodOptional<zod.ZodLiteral<"circle">>;
17499
17499
  padShape: zod.ZodOptional<zod.ZodLiteral<"rect">>;
17500
17500
  portHints: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, "many">>;
17501
+ pcbHoleOffsetX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
17502
+ pcbHoleOffsetY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
17501
17503
  }, "strip", zod.ZodTypeAny, {
17502
17504
  shape: "circular_hole_with_rect_pad";
17503
17505
  holeDiameter: number;
@@ -17519,6 +17521,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
17519
17521
  portHints?: (string | number)[] | undefined;
17520
17522
  holeShape?: "circle" | undefined;
17521
17523
  padShape?: "rect" | undefined;
17524
+ pcbHoleOffsetX?: number | undefined;
17525
+ pcbHoleOffsetY?: number | undefined;
17522
17526
  }, {
17523
17527
  shape: "circular_hole_with_rect_pad";
17524
17528
  holeDiameter: string | number;
@@ -17540,6 +17544,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
17540
17544
  portHints?: (string | number)[] | undefined;
17541
17545
  holeShape?: "circle" | undefined;
17542
17546
  padShape?: "rect" | undefined;
17547
+ pcbHoleOffsetX?: string | number | undefined;
17548
+ pcbHoleOffsetY?: string | number | undefined;
17543
17549
  }>, zod.ZodObject<Omit<{
17544
17550
  pcbX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
17545
17551
  pcbY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -17702,6 +17708,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
17702
17708
  portHints?: (string | number)[] | undefined;
17703
17709
  holeShape?: "circle" | undefined;
17704
17710
  padShape?: "rect" | undefined;
17711
+ pcbHoleOffsetX?: number | undefined;
17712
+ pcbHoleOffsetY?: number | undefined;
17705
17713
  } | {
17706
17714
  shape: "pill_hole_with_rect_pad";
17707
17715
  holeWidth: number;
@@ -17809,6 +17817,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
17809
17817
  portHints?: (string | number)[] | undefined;
17810
17818
  holeShape?: "circle" | undefined;
17811
17819
  padShape?: "rect" | undefined;
17820
+ pcbHoleOffsetX?: string | number | undefined;
17821
+ pcbHoleOffsetY?: string | number | undefined;
17812
17822
  } | {
17813
17823
  shape: "pill_hole_with_rect_pad";
17814
17824
  holeWidth: string | number;
package/dist/index.js CHANGED
@@ -2382,7 +2382,9 @@ var PlatedHole = class extends PrimitiveComponent2 {
2382
2382
  y: position.y,
2383
2383
  layers: ["top", "bottom"],
2384
2384
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
2385
- pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
2385
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0,
2386
+ hole_offset_x: props.pcbHoleOffsetX ?? 0,
2387
+ hole_offset_y: props.pcbHoleOffsetY ?? 0
2386
2388
  });
2387
2389
  this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id;
2388
2390
  } else if (props.shape === "pill_hole_with_rect_pad") {
@@ -2826,7 +2828,9 @@ var createComponentsFromCircuitJson = ({
2826
2828
  holeDiameter: elm.hole_diameter,
2827
2829
  rectPadHeight: elm.rect_pad_height,
2828
2830
  rectPadWidth: elm.rect_pad_width,
2829
- portHints: elm.port_hints
2831
+ portHints: elm.port_hints,
2832
+ pcbHoleOffsetX: elm.hole_offset_x,
2833
+ pcbHoleOffsetY: elm.hole_offset_y
2830
2834
  })
2831
2835
  );
2832
2836
  }
@@ -11970,6 +11974,48 @@ import {
11970
11974
  checkEachPcbPortConnectedToPcbTraces,
11971
11975
  checkEachPcbTraceNonOverlapping
11972
11976
  } from "@tscircuit/checks";
11977
+ var getRoundedRectOutline = (width, height, radius) => {
11978
+ const r = Math.min(radius, width / 2, height / 2);
11979
+ const segments = Math.max(1, Math.ceil(Math.PI / 2 * r));
11980
+ const step = Math.PI / 2 / segments;
11981
+ const w2 = width / 2;
11982
+ const h2 = height / 2;
11983
+ const outline = [];
11984
+ outline.push({ x: -w2 + r, y: -h2 });
11985
+ outline.push({ x: w2 - r, y: -h2 });
11986
+ for (let i = 1; i <= segments; i++) {
11987
+ const theta = -Math.PI / 2 + i * step;
11988
+ outline.push({
11989
+ x: w2 - r + r * Math.cos(theta),
11990
+ y: -h2 + r + r * Math.sin(theta)
11991
+ });
11992
+ }
11993
+ outline.push({ x: w2, y: h2 - r });
11994
+ for (let i = 1; i <= segments; i++) {
11995
+ const theta = 0 + i * step;
11996
+ outline.push({
11997
+ x: w2 - r + r * Math.cos(theta),
11998
+ y: h2 - r + r * Math.sin(theta)
11999
+ });
12000
+ }
12001
+ outline.push({ x: -w2 + r, y: h2 });
12002
+ for (let i = 1; i <= segments; i++) {
12003
+ const theta = Math.PI / 2 + i * step;
12004
+ outline.push({
12005
+ x: -w2 + r + r * Math.cos(theta),
12006
+ y: h2 - r + r * Math.sin(theta)
12007
+ });
12008
+ }
12009
+ outline.push({ x: -w2, y: -h2 + r });
12010
+ for (let i = 1; i <= segments; i++) {
12011
+ const theta = Math.PI + i * step;
12012
+ outline.push({
12013
+ x: -w2 + r + r * Math.cos(theta),
12014
+ y: -h2 + r + r * Math.sin(theta)
12015
+ });
12016
+ }
12017
+ return outline;
12018
+ };
11973
12019
  var Board = class extends Group6 {
11974
12020
  pcb_board_id = null;
11975
12021
  _drcChecksComplete = false;
@@ -12045,11 +12091,26 @@ var Board = class extends Group6 {
12045
12091
  };
12046
12092
  const finalWidth = props.width ?? computedWidth;
12047
12093
  const finalHeight = props.height ?? computedHeight;
12048
- db.pcb_board.update(this.pcb_board_id, {
12094
+ let outline = props.outline;
12095
+ if (!outline && props.borderRadius != null && finalWidth > 0 && finalHeight > 0) {
12096
+ outline = getRoundedRectOutline(
12097
+ finalWidth,
12098
+ finalHeight,
12099
+ props.borderRadius
12100
+ );
12101
+ }
12102
+ const update = {
12049
12103
  width: finalWidth,
12050
12104
  height: finalHeight,
12051
12105
  center
12052
- });
12106
+ };
12107
+ if (outline) {
12108
+ update.outline = outline.map((point) => ({
12109
+ x: point.x + (props.outlineOffsetX ?? 0),
12110
+ y: point.y + (props.outlineOffsetY ?? 0)
12111
+ }));
12112
+ }
12113
+ db.pcb_board.update(this.pcb_board_id, update);
12053
12114
  }
12054
12115
  // Recompute autosize after child components update (e.g., async footprints)
12055
12116
  updatePcbBoardAutoSize() {
@@ -12111,13 +12172,21 @@ var Board = class extends Group6 {
12111
12172
  y: (minY + maxY) / 2 + (props.outlineOffsetY ?? 0)
12112
12173
  };
12113
12174
  }
12175
+ let outline = props.outline;
12176
+ if (!outline && props.borderRadius != null && computedWidth > 0 && computedHeight > 0) {
12177
+ outline = getRoundedRectOutline(
12178
+ computedWidth,
12179
+ computedHeight,
12180
+ props.borderRadius
12181
+ );
12182
+ }
12114
12183
  const pcb_board = db.pcb_board.insert({
12115
12184
  center,
12116
12185
  thickness: this.boardThickness,
12117
12186
  num_layers: this.allLayers.length,
12118
12187
  width: computedWidth,
12119
12188
  height: computedHeight,
12120
- outline: props.outline?.map((point) => ({
12189
+ outline: outline?.map((point) => ({
12121
12190
  x: point.x + (props.outlineOffsetX ?? 0),
12122
12191
  y: point.y + (props.outlineOffsetY ?? 0)
12123
12192
  })),
@@ -14707,7 +14776,7 @@ import { identity as identity6 } from "transformation-matrix";
14707
14776
  var package_default = {
14708
14777
  name: "@tscircuit/core",
14709
14778
  type: "module",
14710
- version: "0.0.714",
14779
+ version: "0.0.716",
14711
14780
  types: "dist/index.d.ts",
14712
14781
  main: "dist/index.js",
14713
14782
  module: "dist/index.js",
@@ -14746,7 +14815,7 @@ var package_default = {
14746
14815
  "@tscircuit/matchpack": "^0.0.16",
14747
14816
  "@tscircuit/math-utils": "^0.0.21",
14748
14817
  "@tscircuit/miniflex": "^0.0.4",
14749
- "@tscircuit/props": "0.0.313",
14818
+ "@tscircuit/props": "0.0.315",
14750
14819
  "@tscircuit/schematic-autolayout": "^0.0.6",
14751
14820
  "@tscircuit/schematic-match-adapt": "^0.0.16",
14752
14821
  "@tscircuit/schematic-trace-solver": "^0.0.36",
@@ -14760,11 +14829,11 @@ var package_default = {
14760
14829
  "bun-match-svg": "0.0.12",
14761
14830
  "calculate-elbow": "^0.0.12",
14762
14831
  "chokidar-cli": "^3.0.0",
14763
- "circuit-json": "^0.0.249",
14832
+ "circuit-json": "^0.0.250",
14764
14833
  "circuit-json-to-bpc": "^0.0.13",
14765
14834
  "circuit-json-to-connectivity-map": "^0.0.22",
14766
14835
  "circuit-json-to-simple-3d": "^0.0.6",
14767
- "circuit-to-svg": "^0.0.185",
14836
+ "circuit-to-svg": "^0.0.189",
14768
14837
  concurrently: "^9.1.2",
14769
14838
  "connectivity-map": "^1.0.0",
14770
14839
  debug: "^4.3.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.715",
4
+ "version": "0.0.717",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "@tscircuit/matchpack": "^0.0.16",
41
41
  "@tscircuit/math-utils": "^0.0.21",
42
42
  "@tscircuit/miniflex": "^0.0.4",
43
- "@tscircuit/props": "0.0.313",
43
+ "@tscircuit/props": "0.0.315",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.6",
45
45
  "@tscircuit/schematic-match-adapt": "^0.0.16",
46
46
  "@tscircuit/schematic-trace-solver": "^0.0.36",
@@ -54,11 +54,11 @@
54
54
  "bun-match-svg": "0.0.12",
55
55
  "calculate-elbow": "^0.0.12",
56
56
  "chokidar-cli": "^3.0.0",
57
- "circuit-json": "^0.0.249",
57
+ "circuit-json": "^0.0.250",
58
58
  "circuit-json-to-bpc": "^0.0.13",
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-simple-3d": "^0.0.6",
61
- "circuit-to-svg": "^0.0.185",
61
+ "circuit-to-svg": "^0.0.189",
62
62
  "concurrently": "^9.1.2",
63
63
  "connectivity-map": "^1.0.0",
64
64
  "debug": "^4.3.6",