@tscircuit/core 0.0.95 → 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.
package/dist/index.d.ts CHANGED
@@ -611,6 +611,7 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
611
611
  x: number;
612
612
  y: number;
613
613
  }): void;
614
+ _hasMatchedPcbPrimitive(): boolean;
614
615
  }
615
616
 
616
617
  type ReactSubtree = {
package/dist/index.js CHANGED
@@ -984,6 +984,9 @@ var Port = class extends PrimitiveComponent {
984
984
  y: newCenter.y
985
985
  });
986
986
  }
987
+ _hasMatchedPcbPrimitive() {
988
+ return this.matchedComponents.some((c) => c.isPcbPrimitive);
989
+ }
987
990
  };
988
991
 
989
992
  // lib/components/base-components/NormalComponent.ts
@@ -2077,38 +2080,38 @@ var NormalComponent = class extends PrimitiveComponent {
2077
2080
  const { db } = this.root;
2078
2081
  const { boardThickness = 0 } = this.root?._getBoard() ?? {};
2079
2082
  const cadModel = this._parsedProps.cadModel;
2080
- if (cadModel) {
2081
- const bounds = this._getPcbCircuitJsonBounds();
2082
- const pcb_component = db.pcb_component.get(this.pcb_component_id);
2083
- if (typeof cadModel === "string") {
2084
- throw new Error("String cadModel not yet implemented");
2085
- }
2086
- const rotationOffset = rotation3.parse({
2087
- x: 0,
2088
- y: 0,
2089
- z: typeof cadModel.rotationOffset === "number" ? cadModel.rotationOffset : 0,
2090
- ...typeof cadModel.rotationOffset === "object" ? cadModel.rotationOffset ?? {} : {}
2091
- });
2092
- const cad_model = db.cad_component.insert({
2093
- // TODO z maybe depends on layer
2094
- position: {
2095
- x: bounds.center.x,
2096
- y: bounds.center.y,
2097
- z: this.props.layer === "bottom" ? -boardThickness / 2 : boardThickness / 2
2098
- },
2099
- rotation: {
2100
- x: rotationOffset.x,
2101
- y: (this.props.layer === "top" ? 0 : 180) + rotationOffset.y,
2102
- z: (pcb_component?.rotation ?? 0) + (this.props.layer === "bottom" ? 180 : 0) + rotationOffset.z
2103
- },
2104
- pcb_component_id: this.pcb_component_id,
2105
- source_component_id: this.source_component_id,
2106
- model_stl_url: "stlUrl" in cadModel ? cadModel.stlUrl : void 0,
2107
- model_obj_url: "objUrl" in cadModel ? cadModel.objUrl : void 0,
2108
- model_jscad: "jscad" in cadModel ? cadModel.jscad : void 0,
2109
- footprinter_string: typeof this.props.footprint === "string" && !cadModel ? this.props.footprint : void 0
2110
- });
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");
2111
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
+ });
2112
2115
  }
2113
2116
  };
2114
2117
 
@@ -2598,6 +2601,23 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
2598
2601
  const { allPortsFound, ports } = this._findConnectedPorts();
2599
2602
  const portsConnectedOnPcbViaNet = [];
2600
2603
  if (!allPortsFound) return;
2604
+ const portsWithoutMatchedPcbPrimitive = [];
2605
+ for (const port of ports) {
2606
+ if (!port._hasMatchedPcbPrimitive()) {
2607
+ portsWithoutMatchedPcbPrimitive.push(port);
2608
+ }
2609
+ }
2610
+ if (portsWithoutMatchedPcbPrimitive.length > 0) {
2611
+ db.pcb_trace_error.insert({
2612
+ error_type: "pcb_trace_error",
2613
+ source_trace_id: this.source_trace_id,
2614
+ message: `Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${portsWithoutMatchedPcbPrimitive.map((p) => p.getString()).join(", ")}`,
2615
+ pcb_trace_id: this.pcb_trace_id,
2616
+ pcb_component_ids: [],
2617
+ pcb_port_ids: portsWithoutMatchedPcbPrimitive.map((p) => p.pcb_port_id).filter(Boolean)
2618
+ });
2619
+ return;
2620
+ }
2601
2621
  const nets = this._findConnectedNets().netsWithSelectors;
2602
2622
  if (ports.length === 0 && nets.length === 2) {
2603
2623
  this.renderError(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.95",
4
+ "version": "0.0.97",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",