@tscircuit/core 0.0.587 → 0.0.589

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
@@ -271,6 +271,7 @@ interface ISubcircuit extends PrimitiveComponent {
271
271
  _shouldUseTraceByTraceRouting(): boolean;
272
272
  _parsedProps: z.infer<typeof subcircuitGroupProps>;
273
273
  _getAutorouterConfig(): AutorouterConfig;
274
+ _getSubcircuitLayerCount(): number;
274
275
  subcircuit_id: string | null;
275
276
  }
276
277
 
@@ -1095,6 +1096,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1095
1096
  maxY: number;
1096
1097
  };
1097
1098
  _getAutorouterConfig(): AutorouterConfig;
1099
+ _getSubcircuitLayerCount(): number;
1098
1100
  /**
1099
1101
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
1100
1102
  * order. It's the most deterministic way to autoroute, because a new trace
@@ -2003,7 +2005,8 @@ declare class Board extends Group<typeof boardProps> {
2003
2005
  /**
2004
2006
  * Get all available layers for the board
2005
2007
  */
2006
- get allLayers(): string[];
2008
+ get allLayers(): readonly ["top", "bottom", "inner1", "inner2"] | readonly ["top", "bottom"];
2009
+ _getSubcircuitLayerCount(): number;
2007
2010
  doInitialPcbBoardAutoSize(): void;
2008
2011
  /**
2009
2012
  * Update the board information silkscreen text if platform config is set and
package/dist/index.js CHANGED
@@ -4100,7 +4100,7 @@ var getMaxLengthFromConnectedCapacitors = (ports, { db }) => {
4100
4100
  return sourceComponent.max_decoupling_trace_length;
4101
4101
  }
4102
4102
  return null;
4103
- }).filter((length2) => length2 !== null);
4103
+ }).filter((length4) => length4 !== null);
4104
4104
  if (capacitorMaxLengths.length === 0) return void 0;
4105
4105
  return Math.min(...capacitorMaxLengths);
4106
4106
  };
@@ -5505,7 +5505,7 @@ function Trace_doInitialPcbTraceRender(trace) {
5505
5505
  ]
5506
5506
  }
5507
5507
  ],
5508
- layerCount: 2,
5508
+ layerCount: trace.getSubcircuit()._getSubcircuitLayerCount(),
5509
5509
  bounds: {
5510
5510
  minX: Math.min(a.x, b.x) - BOUNDS_MARGIN,
5511
5511
  maxX: Math.max(a.x, b.x) + BOUNDS_MARGIN,
@@ -7500,7 +7500,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
7500
7500
  connections: allConns,
7501
7501
  // TODO add traces so that we don't run into things routed by another
7502
7502
  // subcircuit
7503
- layerCount: 2,
7503
+ layerCount: board?.num_layers ?? 2,
7504
7504
  minTraceWidth
7505
7505
  },
7506
7506
  connMap
@@ -7801,6 +7801,7 @@ function Group_doInitialSourceAddConnectivityMapKey(group) {
7801
7801
  }
7802
7802
 
7803
7803
  // lib/components/primitive-components/Group/Group_doInitialSchematicLayoutGrid.ts
7804
+ import { length } from "circuit-json";
7804
7805
  function Group_doInitialSchematicLayoutGrid(group) {
7805
7806
  const { db } = group.root;
7806
7807
  const props = group._parsedProps;
@@ -7850,9 +7851,15 @@ function Group_doInitialSchematicLayoutGrid(group) {
7850
7851
  if (typeof gridGapOption === "number") {
7851
7852
  gridGapX = gridGapOption;
7852
7853
  gridGapY = gridGapOption;
7854
+ } else if (typeof gridGapOption === "string") {
7855
+ const parsed = length.parse(gridGapOption);
7856
+ gridGapX = parsed;
7857
+ gridGapY = parsed;
7853
7858
  } else if (typeof gridGapOption === "object" && gridGapOption !== null) {
7854
- gridGapX = gridGapOption.x;
7855
- gridGapY = gridGapOption.y;
7859
+ const xRaw = gridGapOption.x;
7860
+ const yRaw = gridGapOption.y;
7861
+ gridGapX = typeof xRaw === "number" ? xRaw : length.parse(xRaw ?? "0mm");
7862
+ gridGapY = typeof yRaw === "number" ? yRaw : length.parse(yRaw ?? "0mm");
7856
7863
  } else {
7857
7864
  gridGapX = 1;
7858
7865
  gridGapY = 1;
@@ -7920,6 +7927,7 @@ import {
7920
7927
  transformPCBElements,
7921
7928
  getPrimaryId
7922
7929
  } from "@tscircuit/circuit-json-util";
7930
+ import { length as length2 } from "circuit-json";
7923
7931
  function Group_doInitialPcbLayoutGrid(group) {
7924
7932
  const { db } = group.root;
7925
7933
  const props = group._parsedProps;
@@ -7968,9 +7976,15 @@ function Group_doInitialPcbLayoutGrid(group) {
7968
7976
  if (typeof gridGapOption === "number") {
7969
7977
  gridGapX = gridGapOption;
7970
7978
  gridGapY = gridGapOption;
7979
+ } else if (typeof gridGapOption === "string") {
7980
+ const parsed = length2.parse(gridGapOption);
7981
+ gridGapX = parsed;
7982
+ gridGapY = parsed;
7971
7983
  } else if (typeof gridGapOption === "object" && gridGapOption !== null) {
7972
- gridGapX = gridGapOption.x;
7973
- gridGapY = gridGapOption.y;
7984
+ const xRaw = gridGapOption.x;
7985
+ const yRaw = gridGapOption.y;
7986
+ gridGapX = typeof xRaw === "number" ? xRaw : length2.parse(xRaw ?? "0mm");
7987
+ gridGapY = typeof yRaw === "number" ? yRaw : length2.parse(yRaw ?? "0mm");
7974
7988
  } else {
7975
7989
  gridGapX = 1;
7976
7990
  gridGapY = 1;
@@ -8080,7 +8094,7 @@ import {
8080
8094
  convertPackOutputToPackInput,
8081
8095
  getGraphicsFromPackOutput
8082
8096
  } from "calculate-packing";
8083
- import { length } from "circuit-json";
8097
+ import { length as length3 } from "circuit-json";
8084
8098
  import { transformPCBElements as transformPCBElements2 } from "@tscircuit/circuit-json-util";
8085
8099
  import { translate as translate6, rotate as rotate2, compose as compose4 } from "transformation-matrix";
8086
8100
  import Debug6 from "debug";
@@ -8092,7 +8106,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
8092
8106
  const subtreeCircuitJson = buildSubtree2(db.toArray(), {
8093
8107
  source_group_id: group.source_group_id
8094
8108
  });
8095
- const gapMm = length.parse(gap ?? "0mm");
8109
+ const gapMm = length3.parse(gap ?? "0mm");
8096
8110
  const packInput = {
8097
8111
  ...convertPackOutputToPackInput(
8098
8112
  convertCircuitJsonToPackOutput(subtreeCircuitJson)
@@ -8802,6 +8816,10 @@ var Group = class extends NormalComponent {
8802
8816
  const autorouter = this._parsedProps.autorouter || this.getInheritedProperty("autorouter");
8803
8817
  return getPresetAutoroutingConfig(autorouter);
8804
8818
  }
8819
+ _getSubcircuitLayerCount() {
8820
+ const layers = this.getInheritedProperty("layers");
8821
+ return typeof layers === "number" ? layers : 2;
8822
+ }
8805
8823
  /**
8806
8824
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
8807
8825
  * order. It's the most deterministic way to autoroute, because a new trace
@@ -8891,7 +8909,14 @@ var Board = class extends Group {
8891
8909
  * Get all available layers for the board
8892
8910
  */
8893
8911
  get allLayers() {
8894
- return ["top", "bottom", "inner1", "inner2"];
8912
+ const layerCount = this._parsedProps.layers ?? 2;
8913
+ if (layerCount === 4) {
8914
+ return ["top", "bottom", "inner1", "inner2"];
8915
+ }
8916
+ return ["top", "bottom"];
8917
+ }
8918
+ _getSubcircuitLayerCount() {
8919
+ return this._parsedProps.layers ?? 2;
8895
8920
  }
8896
8921
  doInitialPcbBoardAutoSize() {
8897
8922
  if (this.root?.pcbDisabled) return;
@@ -11170,7 +11195,7 @@ import { identity as identity5 } from "transformation-matrix";
11170
11195
  var package_default = {
11171
11196
  name: "@tscircuit/core",
11172
11197
  type: "module",
11173
- version: "0.0.586",
11198
+ version: "0.0.588",
11174
11199
  types: "dist/index.d.ts",
11175
11200
  main: "dist/index.js",
11176
11201
  module: "dist/index.js",
@@ -11196,7 +11221,7 @@ var package_default = {
11196
11221
  "@tscircuit/capacity-autorouter": "^0.0.100",
11197
11222
  "@tscircuit/checks": "^0.0.56",
11198
11223
  "@tscircuit/circuit-json-flex": "^0.0.1",
11199
- "@tscircuit/circuit-json-util": "^0.0.54",
11224
+ "@tscircuit/circuit-json-util": "^0.0.57",
11200
11225
  "@tscircuit/footprinter": "^0.0.204",
11201
11226
  "@tscircuit/import-snippet": "^0.0.4",
11202
11227
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.587",
4
+ "version": "0.0.589",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "@tscircuit/capacity-autorouter": "^0.0.100",
28
28
  "@tscircuit/checks": "^0.0.56",
29
29
  "@tscircuit/circuit-json-flex": "^0.0.1",
30
- "@tscircuit/circuit-json-util": "^0.0.54",
30
+ "@tscircuit/circuit-json-util": "^0.0.57",
31
31
  "@tscircuit/footprinter": "^0.0.204",
32
32
  "@tscircuit/import-snippet": "^0.0.4",
33
33
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",