@tscircuit/core 0.0.307 → 0.0.308

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
@@ -1,5 +1,5 @@
1
1
  import * as _tscircuit_props from '@tscircuit/props';
2
- import { subcircuitGroupProps, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, CapacitorProps, ChipProps, ResistorProps, ManualEditEvent, manual_edits_file } from '@tscircuit/props';
2
+ import { subcircuitGroupProps, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, AutorouterConfig, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, CapacitorProps, ChipProps, ResistorProps, ManualEditEvent, manual_edits_file } from '@tscircuit/props';
3
3
  import React, { ReactElement } from 'react';
4
4
  export { createElement } from 'react';
5
5
  import * as zod from 'zod';
@@ -965,6 +965,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
965
965
  doInitialSourceAddConnectivityMapKey(): void;
966
966
  _areChildSubcircuitsRouted(): boolean;
967
967
  _shouldRouteAsync(): boolean;
968
+ _hasTracesToRoute(): boolean;
968
969
  _runEffectMakeHttpAutoroutingRequest(): Promise<void>;
969
970
  _startAsyncAutorouting(): void;
970
971
  doInitialPcbTraceRender(): void;
@@ -972,6 +973,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
972
973
  _updatePcbTraceRenderFromSimpleRouteJson(): void;
973
974
  _updatePcbTraceRenderFromPcbTraces(): void;
974
975
  doInitialSchematicLayout(): void;
976
+ _getAutorouterConfig(): AutorouterConfig;
975
977
  /**
976
978
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
977
979
  * order. It's the most deterministic way to autoroute, because a new trace
@@ -1190,18 +1192,24 @@ declare class Board extends Group<typeof boardProps> {
1190
1192
  serverMode: z.ZodOptional<z.ZodEnum<["job", "solve-endpoint"]>>;
1191
1193
  serverCacheEnabled: z.ZodOptional<z.ZodBoolean>;
1192
1194
  cache: z.ZodOptional<z.ZodType<_tscircuit_props.PcbRouteCache, z.ZodTypeDef, _tscircuit_props.PcbRouteCache>>;
1195
+ groupMode: z.ZodOptional<z.ZodEnum<["sequential-trace", "subcircuit"]>>;
1196
+ local: z.ZodOptional<z.ZodBoolean>;
1193
1197
  }, "strip", z.ZodTypeAny, {
1194
1198
  serverUrl?: string | undefined;
1195
1199
  inputFormat?: "simplified" | "circuit-json" | undefined;
1196
1200
  serverMode?: "job" | "solve-endpoint" | undefined;
1197
1201
  serverCacheEnabled?: boolean | undefined;
1198
1202
  cache?: _tscircuit_props.PcbRouteCache | undefined;
1203
+ groupMode?: "sequential-trace" | "subcircuit" | undefined;
1204
+ local?: boolean | undefined;
1199
1205
  }, {
1200
1206
  serverUrl?: string | undefined;
1201
1207
  inputFormat?: "simplified" | "circuit-json" | undefined;
1202
1208
  serverMode?: "job" | "solve-endpoint" | undefined;
1203
1209
  serverCacheEnabled?: boolean | undefined;
1204
1210
  cache?: _tscircuit_props.PcbRouteCache | undefined;
1211
+ groupMode?: "sequential-trace" | "subcircuit" | undefined;
1212
+ local?: boolean | undefined;
1205
1213
  }>, z.ZodLiteral<"sequential-trace">, z.ZodLiteral<"subcircuit">, z.ZodLiteral<"auto">, z.ZodLiteral<"auto-local">, z.ZodLiteral<"auto-cloud">]>>;
1206
1214
  }>, {
1207
1215
  width: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
@@ -1269,6 +1277,8 @@ declare class Board extends Group<typeof boardProps> {
1269
1277
  serverMode?: "job" | "solve-endpoint" | undefined;
1270
1278
  serverCacheEnabled?: boolean | undefined;
1271
1279
  cache?: _tscircuit_props.PcbRouteCache | undefined;
1280
+ groupMode?: "sequential-trace" | "subcircuit" | undefined;
1281
+ local?: boolean | undefined;
1272
1282
  } | undefined;
1273
1283
  schAutoLayoutEnabled?: boolean | undefined;
1274
1284
  schTraceAutoLabelEnabled?: boolean | undefined;
@@ -1336,6 +1346,8 @@ declare class Board extends Group<typeof boardProps> {
1336
1346
  serverMode?: "job" | "solve-endpoint" | undefined;
1337
1347
  serverCacheEnabled?: boolean | undefined;
1338
1348
  cache?: _tscircuit_props.PcbRouteCache | undefined;
1349
+ groupMode?: "sequential-trace" | "subcircuit" | undefined;
1350
+ local?: boolean | undefined;
1339
1351
  } | undefined;
1340
1352
  schAutoLayoutEnabled?: boolean | undefined;
1341
1353
  schTraceAutoLabelEnabled?: boolean | undefined;
package/dist/index.js CHANGED
@@ -3810,25 +3810,23 @@ var Group = class extends NormalComponent {
3810
3810
  return true;
3811
3811
  }
3812
3812
  _shouldRouteAsync() {
3813
- const props = this._parsedProps;
3814
- if (props.autorouter === "auto-local") return true;
3815
- if (props.autorouter === "auto-cloud") return true;
3816
- if (props.autorouter === "sequential-trace") return false;
3817
- if (typeof props.autorouter === "object") return true;
3818
- return false;
3813
+ const autorouter = this._getAutorouterConfig();
3814
+ if (autorouter.local) return false;
3815
+ if (autorouter.groupMode === "sequential-trace") return false;
3816
+ return true;
3817
+ }
3818
+ _hasTracesToRoute() {
3819
+ const debug4 = Debug5("tscircuit:core:_hasTracesToRoute");
3820
+ const traces = this.selectAll("trace");
3821
+ debug4(`[${this.getString()}] has ${traces.length} traces to route`);
3822
+ return traces.length > 0;
3819
3823
  }
3820
3824
  async _runEffectMakeHttpAutoroutingRequest() {
3821
3825
  const debug4 = Debug5("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
3822
3826
  const props = this._parsedProps;
3823
- const autorouterPropObj = typeof props.autorouter === "object" ? props.autorouter : {};
3824
- const autoroutingOptions = {
3825
- ...autorouterPropObj,
3826
- serverUrl: autorouterPropObj.serverUrl ?? "https://registry-api.tscircuit.com",
3827
- serverMode: autorouterPropObj.serverMode ?? "job",
3828
- serverCacheEnabled: autorouterPropObj.serverCacheEnabled ?? false
3829
- };
3830
- const serverUrl = autoroutingOptions.serverUrl;
3831
- const serverMode = autoroutingOptions.serverMode;
3827
+ const autorouterConfig = this._getAutorouterConfig();
3828
+ const serverUrl = autorouterConfig.serverUrl;
3829
+ const serverMode = autorouterConfig.serverMode;
3832
3830
  const fetchWithDebug = (url, options) => {
3833
3831
  debug4("fetching", url);
3834
3832
  return fetch(url, options);
@@ -3880,7 +3878,7 @@ var Group = class extends NormalComponent {
3880
3878
  autostart: true,
3881
3879
  display_name: this.root?.name,
3882
3880
  subcircuit_id: this.subcircuit_id,
3883
- server_cache_enabled: autoroutingOptions.serverCacheEnabled
3881
+ server_cache_enabled: autorouterConfig.serverCacheEnabled
3884
3882
  }),
3885
3883
  headers: { "Content-Type": "application/json" }
3886
3884
  }
@@ -3928,6 +3926,7 @@ var Group = class extends NormalComponent {
3928
3926
  }
3929
3927
  doInitialPcbTraceRender() {
3930
3928
  const debug4 = Debug5("tscircuit:core:doInitialPcbTraceRender");
3929
+ if (!this.isSubcircuit) return;
3931
3930
  if (this.root?.pcbDisabled) return;
3932
3931
  if (this._shouldUseTraceByTraceRouting()) return;
3933
3932
  if (!this._areChildSubcircuitsRouted()) {
@@ -3939,11 +3938,13 @@ var Group = class extends NormalComponent {
3939
3938
  debug4(
3940
3939
  `[${this.getString()}] no child subcircuits to wait for, initiating async routing`
3941
3940
  );
3941
+ if (!this._hasTracesToRoute()) return;
3942
3942
  this._startAsyncAutorouting();
3943
3943
  }
3944
3944
  updatePcbTraceRender() {
3945
3945
  const debug4 = Debug5("tscircuit:core:updatePcbTraceRender");
3946
- if (this._shouldRouteAsync() && !this._hasStartedAsyncAutorouting) {
3946
+ if (!this.isSubcircuit) return;
3947
+ if (this._shouldRouteAsync() && this._hasTracesToRoute() && !this._hasStartedAsyncAutorouting) {
3947
3948
  if (this._areChildSubcircuitsRouted()) {
3948
3949
  debug4(
3949
3950
  `[${this.getString()}] child subcircuits are now routed, starting async autorouting`
@@ -4010,6 +4011,34 @@ var Group = class extends NormalComponent {
4010
4011
  const laidOutScene = SAL.ascendingCentralLrBug1(scene);
4011
4012
  SAL.mutateSoupForScene(db.toArray(), laidOutScene);
4012
4013
  }
4014
+ _getAutorouterConfig() {
4015
+ const defaults = {
4016
+ serverUrl: "https://registry-api.tscircuit.com",
4017
+ serverMode: "job",
4018
+ serverCacheEnabled: false
4019
+ };
4020
+ const autorouter = this._parsedProps.autorouter ?? this.getInheritedProperty("autorouter");
4021
+ if (typeof autorouter === "object") {
4022
+ return {
4023
+ local: !(autorouter.serverUrl || autorouter.serverMode || autorouter.serverCacheEnabled),
4024
+ ...defaults,
4025
+ ...autorouter
4026
+ };
4027
+ }
4028
+ if (autorouter === "auto-local")
4029
+ return {
4030
+ local: true
4031
+ };
4032
+ if (autorouter === "sequential-trace")
4033
+ return {
4034
+ local: true,
4035
+ groupMode: "sequential-trace"
4036
+ };
4037
+ return {
4038
+ local: true,
4039
+ groupMode: "sequential-trace"
4040
+ };
4041
+ }
4013
4042
  /**
4014
4043
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
4015
4044
  * order. It's the most deterministic way to autoroute, because a new trace
@@ -4019,11 +4048,8 @@ var Group = class extends NormalComponent {
4019
4048
  * or if using a "fullview" or "rip and replace" autorouting mode
4020
4049
  */
4021
4050
  _shouldUseTraceByTraceRouting() {
4022
- const autorouter = this._parsedProps.autorouter ?? this.getInheritedProperty("autorouter");
4023
- if (autorouter === "auto-local") return true;
4024
- if (autorouter === "sequential-trace") return true;
4025
- if (autorouter) return false;
4026
- return true;
4051
+ const autorouter = this._getAutorouterConfig();
4052
+ return autorouter.groupMode === "sequential-trace";
4027
4053
  }
4028
4054
  };
4029
4055
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.307",
4
+ "version": "0.0.308",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "@tscircuit/footprinter": "^0.0.97",
55
55
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
56
56
  "@tscircuit/math-utils": "^0.0.9",
57
- "@tscircuit/props": "^0.0.142",
57
+ "@tscircuit/props": "^0.0.144",
58
58
  "@tscircuit/schematic-autolayout": "^0.0.6",
59
59
  "@tscircuit/soup-util": "^0.0.41",
60
60
  "circuit-json": "^0.0.136",