@tscircuit/core 0.0.77 → 0.0.79

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
@@ -17,6 +17,12 @@ declare class Circuit {
17
17
  _hasRenderedAtleastOnce: boolean;
18
18
  constructor();
19
19
  add(componentOrElm: PrimitiveComponent | ReactElement): void;
20
+ /**
21
+ * Get the main board for this Circuit.
22
+ */
23
+ _getBoard(): PrimitiveComponent & {
24
+ boardThickness: number;
25
+ };
20
26
  _guessRootComponent(): void;
21
27
  render(): void;
22
28
  getSoup(): AnySoupElement[];
@@ -707,6 +713,7 @@ declare class Board extends Group<typeof boardProps> {
707
713
  }[] | undefined;
708
714
  }>;
709
715
  };
716
+ get boardThickness(): number;
710
717
  doInitialPcbComponentRender(): void;
711
718
  removePcbComponentRender(): void;
712
719
  _computePcbGlobalTransformBeforeLayout(): Matrix;
@@ -3096,6 +3103,20 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
3096
3103
  doInitialSourceRender(): void;
3097
3104
  doInitialSchematicComponentRender(): void;
3098
3105
  doInitialPcbComponentRender(): void;
3106
+ _getPcbCircuitJsonBounds(): {
3107
+ center: {
3108
+ x: number;
3109
+ y: number;
3110
+ };
3111
+ bounds: {
3112
+ left: number;
3113
+ top: number;
3114
+ right: number;
3115
+ bottom: number;
3116
+ };
3117
+ width: number;
3118
+ height: number;
3119
+ };
3099
3120
  }
3100
3121
 
3101
3122
  declare class Jumper<PinLabels extends string = never> extends NormalComponent<typeof jumperProps, PinLabels> {
package/dist/index.js CHANGED
@@ -1984,6 +1984,7 @@ var NormalComponent = class extends PrimitiveComponent {
1984
1984
  }
1985
1985
  doInitialCadModelRender() {
1986
1986
  const { db } = this.root;
1987
+ const { boardThickness = 0 } = this.root?._getBoard() ?? {};
1987
1988
  const { _parsedProps: props } = this;
1988
1989
  if (props.cadModel) {
1989
1990
  const bounds = this._getPcbCircuitJsonBounds();
@@ -1993,14 +1994,17 @@ var NormalComponent = class extends PrimitiveComponent {
1993
1994
  }
1994
1995
  const cad_model = db.cad_component.insert({
1995
1996
  // TODO z maybe depends on layer
1996
- position: { x: bounds.center.x, y: bounds.center.y, z: 0 },
1997
+ position: {
1998
+ x: bounds.center.x,
1999
+ y: bounds.center.y,
2000
+ z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
2001
+ },
1997
2002
  pcb_component_id: this.pcb_component_id,
1998
2003
  source_component_id: this.source_component_id,
1999
2004
  model_stl_url: "stlUrl" in cadModel ? cadModel.stlUrl : void 0,
2000
2005
  model_obj_url: "objUrl" in cadModel ? cadModel.objUrl : void 0,
2001
- model_jscad: "jscad" in cadModel ? cadModel.jscad : void 0
2002
- // TODO
2003
- // footprinter_string:
2006
+ model_jscad: "jscad" in cadModel ? cadModel.jscad : void 0,
2007
+ footprinter_string: typeof this.props.footprint === "string" && !cadModel ? this.props.footprint : void 0
2004
2008
  });
2005
2009
  }
2006
2010
  }
@@ -2107,6 +2111,10 @@ var Board = class extends Group {
2107
2111
  zodProps: boardProps
2108
2112
  };
2109
2113
  }
2114
+ get boardThickness() {
2115
+ const { _parsedProps: props } = this;
2116
+ return 1.4;
2117
+ }
2110
2118
  doInitialPcbComponentRender() {
2111
2119
  const { db } = this.root;
2112
2120
  const { _parsedProps: props } = this;
@@ -3228,6 +3236,22 @@ var Chip = class extends NormalComponent {
3228
3236
  });
3229
3237
  this.pcb_component_id = pcb_component.pcb_component_id;
3230
3238
  }
3239
+ _getPcbCircuitJsonBounds() {
3240
+ const { db } = this.root;
3241
+ if (!this.pcb_component_id) return super._getPcbCircuitJsonBounds();
3242
+ const pcb_component = db.pcb_component.get(this.pcb_component_id);
3243
+ return {
3244
+ center: { x: pcb_component.center.x, y: pcb_component.center.y },
3245
+ bounds: {
3246
+ left: pcb_component.center.x - pcb_component.width / 2,
3247
+ top: pcb_component.center.y - pcb_component.height / 2,
3248
+ right: pcb_component.center.x + pcb_component.width / 2,
3249
+ bottom: pcb_component.center.y + pcb_component.height / 2
3250
+ },
3251
+ width: pcb_component.width,
3252
+ height: pcb_component.height
3253
+ };
3254
+ }
3231
3255
  };
3232
3256
 
3233
3257
  // lib/components/normal-components/Jumper.ts
@@ -3504,7 +3528,7 @@ var FabricationNotePath = class extends PrimitiveComponent {
3504
3528
  }
3505
3529
  };
3506
3530
 
3507
- // lib/Project.ts
3531
+ // lib/Circuit.ts
3508
3532
  import { su } from "@tscircuit/soup-util";
3509
3533
  import { isValidElement as isValidElement2 } from "react";
3510
3534
  import { identity as identity5 } from "transformation-matrix";
@@ -3529,6 +3553,14 @@ var Circuit = class {
3529
3553
  }
3530
3554
  this.children.push(component);
3531
3555
  }
3556
+ /**
3557
+ * Get the main board for this Circuit.
3558
+ */
3559
+ _getBoard() {
3560
+ return this.children.find(
3561
+ (c) => c.componentName === "Board"
3562
+ );
3563
+ }
3532
3564
  _guessRootComponent() {
3533
3565
  if (this.firstChild) return;
3534
3566
  if (this.children.length === 1) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.77",
4
+ "version": "0.0.79",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",