@tscircuit/core 0.0.96 → 0.0.97

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 +31 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2080,38 +2080,38 @@ var NormalComponent = class extends PrimitiveComponent {
2080
2080
  const { db } = this.root;
2081
2081
  const { boardThickness = 0 } = this.root?._getBoard() ?? {};
2082
2082
  const cadModel = this._parsedProps.cadModel;
2083
- if (cadModel) {
2084
- const bounds = this._getPcbCircuitJsonBounds();
2085
- const pcb_component = db.pcb_component.get(this.pcb_component_id);
2086
- if (typeof cadModel === "string") {
2087
- throw new Error("String cadModel not yet implemented");
2088
- }
2089
- const rotationOffset = rotation3.parse({
2090
- x: 0,
2091
- y: 0,
2092
- z: typeof cadModel.rotationOffset === "number" ? cadModel.rotationOffset : 0,
2093
- ...typeof cadModel.rotationOffset === "object" ? cadModel.rotationOffset ?? {} : {}
2094
- });
2095
- const cad_model = db.cad_component.insert({
2096
- // TODO z maybe depends on layer
2097
- position: {
2098
- x: bounds.center.x,
2099
- y: bounds.center.y,
2100
- z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
2101
- },
2102
- rotation: {
2103
- x: rotationOffset.x,
2104
- y: (this.props.layer === "top" ? 0 : 180) + rotationOffset.y,
2105
- z: (pcb_component?.rotation ?? 0) + (this.props.layer === "bottom" ? 180 : 0) + rotationOffset.z
2106
- },
2107
- pcb_component_id: this.pcb_component_id,
2108
- source_component_id: this.source_component_id,
2109
- model_stl_url: "stlUrl" in cadModel ? cadModel.stlUrl : void 0,
2110
- model_obj_url: "objUrl" in cadModel ? cadModel.objUrl : void 0,
2111
- model_jscad: "jscad" in cadModel ? cadModel.jscad : void 0,
2112
- footprinter_string: typeof this.props.footprint === "string" && !cadModel ? this.props.footprint : void 0
2113
- });
2083
+ if (!this.pcb_component_id) return;
2084
+ if (!cadModel && !this.props.footprint) return;
2085
+ const bounds = this._getPcbCircuitJsonBounds();
2086
+ const pcb_component = db.pcb_component.get(this.pcb_component_id);
2087
+ if (typeof cadModel === "string") {
2088
+ throw new Error("String cadModel not yet implemented");
2114
2089
  }
2090
+ const rotationOffset = rotation3.parse({
2091
+ x: 0,
2092
+ y: 0,
2093
+ z: typeof cadModel?.rotationOffset === "number" ? cadModel.rotationOffset : 0,
2094
+ ...typeof cadModel?.rotationOffset === "object" ? cadModel.rotationOffset ?? {} : {}
2095
+ });
2096
+ const cad_model = db.cad_component.insert({
2097
+ // TODO z maybe depends on layer
2098
+ position: {
2099
+ x: bounds.center.x,
2100
+ y: bounds.center.y,
2101
+ z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
2102
+ },
2103
+ rotation: {
2104
+ x: rotationOffset.x,
2105
+ y: (this.props.layer === "top" ? 0 : 180) + rotationOffset.y,
2106
+ z: (pcb_component?.rotation ?? 0) + (this.props.layer === "bottom" ? 180 : 0) + rotationOffset.z
2107
+ },
2108
+ pcb_component_id: this.pcb_component_id,
2109
+ source_component_id: this.source_component_id,
2110
+ model_stl_url: "stlUrl" in (cadModel ?? {}) ? cadModel.stlUrl : void 0,
2111
+ model_obj_url: "objUrl" in (cadModel ?? {}) ? cadModel.objUrl : void 0,
2112
+ model_jscad: "jscad" in (cadModel ?? {}) ? cadModel.jscad : void 0,
2113
+ footprinter_string: typeof this.props.footprint === "string" && !cadModel ? this.props.footprint : void 0
2114
+ });
2115
2115
  }
2116
2116
  };
2117
2117
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.96",
4
+ "version": "0.0.97",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",