@tscircuit/core 0.0.471 → 0.0.473

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 +27 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -546,8 +546,7 @@ var PrimitiveComponent2 = class extends Renderable {
546
546
  * components share the same names) unless you explicitly break out some ports
547
547
  */
548
548
  get isSubcircuit() {
549
- return Boolean(this.props.subcircuit) || // Implied opaque group for top-level group
550
- this.lowercaseComponentName === "group" && this?.parent?.isRoot;
549
+ return Boolean(this.props.subcircuit) || this.lowercaseComponentName === "group" && this?.parent?.isRoot;
551
550
  }
552
551
  get isGroup() {
553
552
  return this.lowercaseComponentName === "group";
@@ -5903,6 +5902,18 @@ import "@tscircuit/schematic-autolayout";
5903
5902
 
5904
5903
  // lib/utils/autorouting/CapacityMeshAutorouter.ts
5905
5904
  import { CapacityMeshSolver } from "@tscircuit/capacity-autorouter";
5905
+
5906
+ // lib/errors/AutorouterError.ts
5907
+ import packageJson from "@tscircuit/capacity-autorouter/package.json";
5908
+ var autorouterVersion = packageJson.version ?? "unknown";
5909
+ var AutorouterError = class extends Error {
5910
+ constructor(message) {
5911
+ super(`${message} (capacity-autorouter@${autorouterVersion})`);
5912
+ this.name = "AutorouterError";
5913
+ }
5914
+ };
5915
+
5916
+ // lib/utils/autorouting/CapacityMeshAutorouter.ts
5906
5917
  var CapacityMeshAutorouter = class {
5907
5918
  input;
5908
5919
  isRouting = false;
@@ -5945,7 +5956,7 @@ var CapacityMeshAutorouter = class {
5945
5956
  if (this.solver.failed) {
5946
5957
  this.emitEvent({
5947
5958
  type: "error",
5948
- error: new Error(this.solver.error || "Routing failed")
5959
+ error: new AutorouterError(this.solver.error || "Routing failed")
5949
5960
  });
5950
5961
  } else {
5951
5962
  this.emitEvent({
@@ -5987,7 +5998,7 @@ var CapacityMeshAutorouter = class {
5987
5998
  } catch (error) {
5988
5999
  this.emitEvent({
5989
6000
  type: "error",
5990
- error: error instanceof Error ? error : new Error(String(error))
6001
+ error: error instanceof Error ? new AutorouterError(error.message) : new AutorouterError(String(error))
5991
6002
  });
5992
6003
  this.isRouting = false;
5993
6004
  }
@@ -6043,7 +6054,7 @@ var CapacityMeshAutorouter = class {
6043
6054
  solveSync() {
6044
6055
  this.solver.solve();
6045
6056
  if (this.solver.failed) {
6046
- throw new Error(this.solver.error || "Routing failed");
6057
+ throw new AutorouterError(this.solver.error || "Routing failed");
6047
6058
  }
6048
6059
  return this.solver.getOutputSimpleRouteJson().traces || [];
6049
6060
  }
@@ -7382,12 +7393,15 @@ var Group = class extends NormalComponent {
7382
7393
  break;
7383
7394
  }
7384
7395
  if (job.has_error) {
7396
+ const err = new AutorouterError(
7397
+ `Autorouting job failed: ${JSON.stringify(job.error)}`
7398
+ );
7385
7399
  db.pcb_autorouting_error.insert({
7386
7400
  pcb_error_id: autorouting_job.autorouting_job_id,
7387
7401
  error_type: "pcb_autorouting_error",
7388
- message: job.error?.message ?? JSON.stringify(job.error)
7402
+ message: err.message
7389
7403
  });
7390
- throw new Error(`Autorouting job failed: ${JSON.stringify(job.error)}`);
7404
+ throw err;
7391
7405
  }
7392
7406
  await new Promise((resolve) => setTimeout(resolve, 100));
7393
7407
  }
@@ -9838,7 +9852,7 @@ import { identity as identity4 } from "transformation-matrix";
9838
9852
  var package_default = {
9839
9853
  name: "@tscircuit/core",
9840
9854
  type: "module",
9841
- version: "0.0.470",
9855
+ version: "0.0.472",
9842
9856
  types: "dist/index.d.ts",
9843
9857
  main: "dist/index.js",
9844
9858
  module: "dist/index.js",
@@ -9979,23 +9993,17 @@ var RootCircuit = class {
9979
9993
  }
9980
9994
  _guessRootComponent() {
9981
9995
  if (this.firstChild) return;
9982
- if (this.children.length === 1) {
9983
- this.firstChild = this.children[0];
9984
- return;
9985
- }
9986
9996
  if (this.children.length === 0) {
9987
9997
  throw new Error(
9988
9998
  "Not able to guess root component: RootCircuit has no children (use circuit.add(...))"
9989
9999
  );
9990
10000
  }
9991
- if (this.children.length > 0) {
9992
- const board = this.children.find((c) => c.componentName === "Board") ?? null;
9993
- if (board) {
9994
- this.firstChild = board;
9995
- return;
9996
- }
10001
+ if (this.children.length === 1 && this.children[0].isGroup) {
10002
+ this.firstChild = this.children[0];
10003
+ return;
9997
10004
  }
9998
- const group = new Group({ subcircuit: false });
10005
+ const group = new Group({ subcircuit: true });
10006
+ group.parent = this;
9999
10007
  group.addAll(this.children);
10000
10008
  this.children = [group];
10001
10009
  this.firstChild = group;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.471",
4
+ "version": "0.0.473",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",