@tscircuit/core 0.0.468 → 0.0.470

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 +49 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1661,6 +1661,16 @@ var SmtPad = class extends PrimitiveComponent2 {
1661
1661
  if (props.shape === "rect") {
1662
1662
  return { width: props.width, height: props.height };
1663
1663
  }
1664
+ if (props.shape === "polygon") {
1665
+ const points = props.points;
1666
+ const xs = points.map((p) => p.x);
1667
+ const ys = points.map((p) => p.y);
1668
+ const minX = Math.min(...xs);
1669
+ const maxX = Math.max(...xs);
1670
+ const minY = Math.min(...ys);
1671
+ const maxY = Math.max(...ys);
1672
+ return { width: maxX - minX, height: maxY - minY };
1673
+ }
1664
1674
  throw new Error(
1665
1675
  `getPcbSize for shape "${props.shape}" not implemented for ${this.componentName}`
1666
1676
  );
@@ -1704,7 +1714,6 @@ var SmtPad = class extends PrimitiveComponent2 {
1704
1714
  // port likely isn't matched
1705
1715
  layer: maybeFlipLayer(props.layer ?? "top"),
1706
1716
  shape: "circle",
1707
- // @ts-ignore: no idea why this is triggering
1708
1717
  radius: props.radius,
1709
1718
  port_hints: props.portHints.map((ph) => ph.toString()),
1710
1719
  x: position.x,
@@ -1714,7 +1723,6 @@ var SmtPad = class extends PrimitiveComponent2 {
1714
1723
  db.pcb_solder_paste.insert({
1715
1724
  layer: pcb_smtpad.layer,
1716
1725
  shape: "circle",
1717
- // @ts-ignore: no idea why this is triggering
1718
1726
  radius: pcb_smtpad.radius * 0.7,
1719
1727
  x: pcb_smtpad.x,
1720
1728
  y: pcb_smtpad.y,
@@ -1754,7 +1762,6 @@ var SmtPad = class extends PrimitiveComponent2 {
1754
1762
  db.pcb_solder_paste.insert({
1755
1763
  layer: maybeFlipLayer(props.layer ?? "top"),
1756
1764
  shape: "rect",
1757
- // @ts-ignore: no idea why this is triggering
1758
1765
  width: pcb_smtpad.width * 0.7,
1759
1766
  height: pcb_smtpad.height * 0.7,
1760
1767
  x: pcb_smtpad.x,
@@ -1768,7 +1775,6 @@ var SmtPad = class extends PrimitiveComponent2 {
1768
1775
  db.pcb_solder_paste.insert({
1769
1776
  layer: maybeFlipLayer(props.layer ?? "top"),
1770
1777
  shape: "rotated_rect",
1771
- // @ts-ignore: no idea why this is triggering
1772
1778
  width: pcb_smtpad.width * 0.7,
1773
1779
  height: pcb_smtpad.height * 0.7,
1774
1780
  x: pcb_smtpad.x,
@@ -1779,6 +1785,21 @@ var SmtPad = class extends PrimitiveComponent2 {
1779
1785
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
1780
1786
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
1781
1787
  });
1788
+ } else if (props.shape === "polygon") {
1789
+ pcb_smtpad = db.pcb_smtpad.insert({
1790
+ pcb_component_id,
1791
+ pcb_port_id: this.matchedPort?.pcb_port_id,
1792
+ // port likely isn't matched
1793
+ layer: maybeFlipLayer(props.layer ?? "top"),
1794
+ shape: "polygon",
1795
+ points: props.points.map((p) => ({
1796
+ x: p.x + position.x,
1797
+ y: p.y + position.y
1798
+ })),
1799
+ port_hints: props.portHints.map((ph) => ph.toString()),
1800
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
1801
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
1802
+ });
1782
1803
  }
1783
1804
  if (pcb_smtpad) {
1784
1805
  this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
@@ -1840,6 +1861,26 @@ var SmtPad = class extends PrimitiveComponent2 {
1840
1861
  height: smtpad.radius * 2
1841
1862
  };
1842
1863
  }
1864
+ if (smtpad.shape === "polygon") {
1865
+ const points = smtpad.points;
1866
+ const xs = points.map((p) => p.x);
1867
+ const ys = points.map((p) => p.y);
1868
+ const minX = Math.min(...xs);
1869
+ const maxX = Math.max(...xs);
1870
+ const minY = Math.min(...ys);
1871
+ const maxY = Math.max(...ys);
1872
+ return {
1873
+ center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
1874
+ bounds: {
1875
+ left: minX,
1876
+ top: maxY,
1877
+ right: maxX,
1878
+ bottom: minY
1879
+ },
1880
+ width: maxX - minX,
1881
+ height: maxY - minY
1882
+ };
1883
+ }
1843
1884
  throw new Error(
1844
1885
  `circuitJson bounds calculation not implemented for shape "${smtpad.shape}"`
1845
1886
  );
@@ -9733,8 +9774,9 @@ var SchematicBox = class extends PrimitiveComponent2 {
9733
9774
  } else if (hasFixedSize) {
9734
9775
  width = props.width;
9735
9776
  height = props.height;
9736
- centerX = typeof props.schX === "number" ? props.schX : 0;
9737
- centerY = typeof props.schY === "number" ? props.schY : 0;
9777
+ const center = this._getGlobalSchematicPositionBeforeLayout();
9778
+ centerX = center.x;
9779
+ centerY = center.y;
9738
9780
  x = centerX - width / 2;
9739
9781
  y = centerY - height / 2;
9740
9782
  } else {
@@ -9796,7 +9838,7 @@ import { identity as identity4 } from "transformation-matrix";
9796
9838
  var package_default = {
9797
9839
  name: "@tscircuit/core",
9798
9840
  type: "module",
9799
- version: "0.0.467",
9841
+ version: "0.0.469",
9800
9842
  types: "dist/index.d.ts",
9801
9843
  main: "dist/index.js",
9802
9844
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.468",
4
+ "version": "0.0.470",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",