@tscircuit/core 0.0.191 → 0.0.193

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
@@ -4,7 +4,7 @@ import React, { ReactElement } from 'react';
4
4
  import * as zod from 'zod';
5
5
  import { z, ZodType } from 'zod';
6
6
  import { symbols, SchSymbol, BaseSymbolName } from 'schematic-symbols';
7
- import { PcbTraceError, PcbPlacementError, LayerRef, AnyCircuitElement, AnySourceComponent, RouteHintPoint } from 'circuit-json';
7
+ import { PcbTraceError, PcbPlacementError, LayerRef, AnyCircuitElement, AnySourceComponent, PcbTrace, RouteHintPoint } from 'circuit-json';
8
8
  import { Matrix } from 'transformation-matrix';
9
9
  import { SoupUtilObjects } from '@tscircuit/soup-util';
10
10
  import * as _tscircuit_layout from '@tscircuit/layout';
@@ -860,7 +860,8 @@ interface SimpleRouteJson {
860
860
 
861
861
  declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps> extends NormalComponent<Props> implements ISubcircuit {
862
862
  _asyncAutoroutingResult: {
863
- output_simple_route_json: SimpleRouteJson;
863
+ output_simple_route_json?: SimpleRouteJson;
864
+ output_pcb_traces?: PcbTrace[];
864
865
  } | null;
865
866
  get config(): {
866
867
  zodProps: Props;
@@ -871,6 +872,8 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
871
872
  doInitialSourceAddConnectivityMapKey(): void;
872
873
  doInitialPcbTraceRender(): void;
873
874
  updatePcbTraceRender(): void;
875
+ _updatePcbTraceRenderFromSimpleRouteJson(): void;
876
+ _updatePcbTraceRenderFromPcbTraces(): void;
874
877
  doInitialSchematicLayout(): void;
875
878
  /**
876
879
  * Trace-by-trace autorouting is where each trace routes itself in a well-known
@@ -916,6 +919,20 @@ declare class Board extends Group<typeof boardProps> {
916
919
  defaultTraceWidth: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
917
920
  minTraceWidth: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
918
921
  partsEngine: z.ZodOptional<z.ZodType<_tscircuit_props.PartsEngine, z.ZodTypeDef, _tscircuit_props.PartsEngine>>;
922
+ pcbRouteCache: z.ZodOptional<z.ZodType<_tscircuit_props.PcbRouteCache, z.ZodTypeDef, _tscircuit_props.PcbRouteCache>>;
923
+ autorouter: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
924
+ serverUrl: z.ZodOptional<z.ZodString>;
925
+ inputFormat: z.ZodOptional<z.ZodEnum<["simplified", "circuit-json"]>>;
926
+ cache: z.ZodOptional<z.ZodType<_tscircuit_props.PcbRouteCache, z.ZodTypeDef, _tscircuit_props.PcbRouteCache>>;
927
+ }, "strip", z.ZodTypeAny, {
928
+ serverUrl?: string | undefined;
929
+ inputFormat?: "simplified" | "circuit-json" | undefined;
930
+ cache?: _tscircuit_props.PcbRouteCache | undefined;
931
+ }, {
932
+ serverUrl?: string | undefined;
933
+ inputFormat?: "simplified" | "circuit-json" | undefined;
934
+ cache?: _tscircuit_props.PcbRouteCache | undefined;
935
+ }>, z.ZodLiteral<"auto">, z.ZodLiteral<"auto-local">, z.ZodLiteral<"auto-cloud">]>>;
919
936
  }>, {
920
937
  width: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
921
938
  height: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
@@ -947,6 +964,12 @@ declare class Board extends Group<typeof boardProps> {
947
964
  routingDisabled?: boolean | undefined;
948
965
  defaultTraceWidth?: number | undefined;
949
966
  minTraceWidth?: number | undefined;
967
+ pcbRouteCache?: _tscircuit_props.PcbRouteCache | undefined;
968
+ autorouter?: "auto" | "auto-local" | "auto-cloud" | {
969
+ serverUrl?: string | undefined;
970
+ inputFormat?: "simplified" | "circuit-json" | undefined;
971
+ cache?: _tscircuit_props.PcbRouteCache | undefined;
972
+ } | undefined;
950
973
  schAutoLayoutEnabled?: boolean | undefined;
951
974
  partsEngine?: _tscircuit_props.PartsEngine | undefined;
952
975
  outline?: {
@@ -973,6 +996,12 @@ declare class Board extends Group<typeof boardProps> {
973
996
  routingDisabled?: boolean | undefined;
974
997
  defaultTraceWidth?: string | number | undefined;
975
998
  minTraceWidth?: string | number | undefined;
999
+ pcbRouteCache?: _tscircuit_props.PcbRouteCache | undefined;
1000
+ autorouter?: "auto" | "auto-local" | "auto-cloud" | {
1001
+ serverUrl?: string | undefined;
1002
+ inputFormat?: "simplified" | "circuit-json" | undefined;
1003
+ cache?: _tscircuit_props.PcbRouteCache | undefined;
1004
+ } | undefined;
976
1005
  schAutoLayoutEnabled?: boolean | undefined;
977
1006
  partsEngine?: _tscircuit_props.PartsEngine | undefined;
978
1007
  outline?: {
package/dist/index.js CHANGED
@@ -131,10 +131,7 @@ var Renderable = class {
131
131
  });
132
132
  }
133
133
  }).catch((error) => {
134
- console.error(
135
- `Async effect error in ${this._currentRenderPhase}:`,
136
- error
137
- );
134
+ console.error(`Async effect error in ${asyncEffect.phase}:`, error);
138
135
  asyncEffect.complete = true;
139
136
  if ("root" in this && this.root) {
140
137
  ;
@@ -3221,8 +3218,63 @@ var TraceHint = class extends PrimitiveComponent {
3221
3218
 
3222
3219
  // lib/components/primitive-components/Group/Group.ts
3223
3220
  import * as SAL from "@tscircuit/schematic-autolayout";
3224
- import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
3221
+ import "@tscircuit/infgrid-ijump-astar";
3225
3222
  import { ConnectivityMap } from "circuit-json-to-connectivity-map";
3223
+
3224
+ // lib/utils/autorouting/getSimpleRouteJsonFromTracesAndDb.ts
3225
+ import { getObstaclesFromSoup } from "@tscircuit/infgrid-ijump-astar";
3226
+ var getSimpleRouteJsonFromTracesAndDb = ({
3227
+ db,
3228
+ traces,
3229
+ minTraceWidth = 0.1
3230
+ }) => {
3231
+ const obstacles = getObstaclesFromSoup([
3232
+ ...db.pcb_component.list(),
3233
+ ...db.pcb_smtpad.list(),
3234
+ ...db.pcb_plated_hole.list()
3235
+ ]);
3236
+ const allPoints = obstacles.flatMap((o) => [
3237
+ {
3238
+ x: o.center.x - o.width / 2,
3239
+ y: o.center.y - o.height / 2
3240
+ },
3241
+ {
3242
+ x: o.center.x + o.width / 2,
3243
+ y: o.center.y + o.height / 2
3244
+ }
3245
+ ]);
3246
+ const bounds = {
3247
+ minX: Math.min(...allPoints.map((p) => p.x)) - 1,
3248
+ maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
3249
+ minY: Math.min(...allPoints.map((p) => p.y)) - 1,
3250
+ maxY: Math.max(...allPoints.map((p) => p.y)) + 1
3251
+ };
3252
+ const connections = traces.map((trace) => {
3253
+ const connectedPorts = trace._findConnectedPorts();
3254
+ if (!connectedPorts.allPortsFound || connectedPorts.ports.length < 2)
3255
+ return null;
3256
+ return {
3257
+ name: trace.source_trace_id ?? "",
3258
+ pointsToConnect: connectedPorts.ports.map((port) => {
3259
+ const pos = port._getGlobalPcbPositionBeforeLayout();
3260
+ return {
3261
+ x: pos.x,
3262
+ y: pos.y,
3263
+ layer: port.getAvailablePcbLayers()[0] ?? "top"
3264
+ };
3265
+ })
3266
+ };
3267
+ }).filter((c) => c !== null);
3268
+ return {
3269
+ bounds,
3270
+ obstacles: [],
3271
+ connections,
3272
+ layerCount: 2,
3273
+ minTraceWidth
3274
+ };
3275
+ };
3276
+
3277
+ // lib/components/primitive-components/Group/Group.ts
3226
3278
  var Group = class extends NormalComponent {
3227
3279
  _asyncAutoroutingResult = null;
3228
3280
  get config() {
@@ -3250,50 +3302,11 @@ var Group = class extends NormalComponent {
3250
3302
  _getSimpleRouteJsonFromPcbTraces() {
3251
3303
  const traces = this.selectAll("trace");
3252
3304
  const { db } = this.root;
3253
- const obstacles = getObstaclesFromSoup([
3254
- ...db.pcb_component.list(),
3255
- ...db.pcb_smtpad.list(),
3256
- ...db.pcb_plated_hole.list()
3257
- ]);
3258
- const allPoints = obstacles.flatMap((o) => [
3259
- {
3260
- x: o.center.x - o.width / 2,
3261
- y: o.center.y - o.height / 2
3262
- },
3263
- {
3264
- x: o.center.x + o.width / 2,
3265
- y: o.center.y + o.height / 2
3266
- }
3267
- ]);
3268
- const bounds = {
3269
- minX: Math.min(...allPoints.map((p) => p.x)) - 1,
3270
- maxX: Math.max(...allPoints.map((p) => p.x)) + 1,
3271
- minY: Math.min(...allPoints.map((p) => p.y)) - 1,
3272
- maxY: Math.max(...allPoints.map((p) => p.y)) + 1
3273
- };
3274
- const connections = traces.map((trace) => {
3275
- const connectedPorts = trace._findConnectedPorts();
3276
- if (!connectedPorts.allPortsFound || connectedPorts.ports.length < 2)
3277
- return null;
3278
- return {
3279
- name: trace.source_trace_id ?? "",
3280
- pointsToConnect: connectedPorts.ports.map((port) => {
3281
- const pos = port._getGlobalPcbPositionBeforeLayout();
3282
- return {
3283
- x: pos.x,
3284
- y: pos.y,
3285
- layer: port.getAvailablePcbLayers()[0] ?? "top"
3286
- };
3287
- })
3288
- };
3289
- }).filter((c) => c !== null);
3290
- return {
3291
- bounds,
3292
- obstacles: [],
3293
- connections,
3294
- layerCount: 2,
3305
+ return getSimpleRouteJsonFromTracesAndDb({
3306
+ db,
3307
+ traces,
3295
3308
  minTraceWidth: this._parsedProps.minTraceWidth ?? 0.1
3296
- };
3309
+ });
3297
3310
  }
3298
3311
  doInitialSourceAddConnectivityMapKey() {
3299
3312
  if (!this.isSubcircuit) return;
@@ -3326,18 +3339,38 @@ var Group = class extends NormalComponent {
3326
3339
  }
3327
3340
  doInitialPcbTraceRender() {
3328
3341
  if (this._shouldUseTraceByTraceRouting()) return;
3329
- if (this.props.autorouter?.serverUrl) {
3342
+ let serverUrl = this.props.autorouter?.serverUrl;
3343
+ if (this.props.autorouter === "auto-cloud") {
3344
+ serverUrl = "https://registry-api.tscircuit.com/autorouting/solve";
3345
+ }
3346
+ if (serverUrl) {
3330
3347
  this._queueAsyncEffect(async () => {
3331
- const { autorouting_result } = await fetch(
3332
- this.props.autorouter.serverUrl,
3333
- {
3348
+ if (this.props.autorouter?.inputFormat === "simplified") {
3349
+ const { autorouting_result: autorouting_result2 } = await fetch(serverUrl, {
3334
3350
  method: "POST",
3335
3351
  body: JSON.stringify({
3336
3352
  input_simple_route_json: this._getSimpleRouteJsonFromPcbTraces()
3337
- })
3353
+ }),
3354
+ headers: {
3355
+ "Content-Type": "application/json"
3356
+ }
3357
+ }).then((r) => r.json());
3358
+ this._asyncAutoroutingResult = autorouting_result2;
3359
+ this._markDirty("PcbTraceRender");
3360
+ }
3361
+ const arRes = await fetch(serverUrl, {
3362
+ method: "POST",
3363
+ body: JSON.stringify({
3364
+ // TODO filter such that we're only using this subcircuit's
3365
+ // components
3366
+ input_circuit_json: this.root.db.toArray()
3367
+ }),
3368
+ headers: {
3369
+ "Content-Type": "application/json"
3338
3370
  }
3339
- ).then((r) => r.json());
3340
- const { output_simple_route_json } = autorouting_result;
3371
+ });
3372
+ const resultText = await arRes.text();
3373
+ const { autorouting_result } = JSON.parse(resultText);
3341
3374
  this._asyncAutoroutingResult = autorouting_result;
3342
3375
  this._markDirty("PcbTraceRender");
3343
3376
  });
@@ -3346,6 +3379,17 @@ var Group = class extends NormalComponent {
3346
3379
  updatePcbTraceRender() {
3347
3380
  if (!this._asyncAutoroutingResult) return;
3348
3381
  if (this._shouldUseTraceByTraceRouting()) return;
3382
+ const { db } = this.root;
3383
+ if (this._asyncAutoroutingResult.output_simple_route_json) {
3384
+ this._updatePcbTraceRenderFromSimpleRouteJson();
3385
+ return;
3386
+ }
3387
+ if (this._asyncAutoroutingResult.output_pcb_traces) {
3388
+ this._updatePcbTraceRenderFromPcbTraces();
3389
+ return;
3390
+ }
3391
+ }
3392
+ _updatePcbTraceRenderFromSimpleRouteJson() {
3349
3393
  const { db } = this.root;
3350
3394
  const { traces: routedTraces } = this._asyncAutoroutingResult.output_simple_route_json;
3351
3395
  if (!routedTraces) return;
@@ -3357,6 +3401,14 @@ var Group = class extends NormalComponent {
3357
3401
  });
3358
3402
  }
3359
3403
  }
3404
+ _updatePcbTraceRenderFromPcbTraces() {
3405
+ const { output_pcb_traces } = this._asyncAutoroutingResult;
3406
+ if (!output_pcb_traces) return;
3407
+ const { db } = this.root;
3408
+ for (const pcb_trace of output_pcb_traces) {
3409
+ db.pcb_trace.insert(pcb_trace);
3410
+ }
3411
+ }
3360
3412
  doInitialSchematicLayout() {
3361
3413
  if (!this.isSubcircuit) return;
3362
3414
  const props = this._parsedProps;
@@ -3461,7 +3513,7 @@ var FTYPE = stringProxy;
3461
3513
  // lib/components/primitive-components/Trace/Trace.ts
3462
3514
  import {
3463
3515
  MultilayerIjump,
3464
- getObstaclesFromSoup as getObstaclesFromSoup2
3516
+ getObstaclesFromSoup as getObstaclesFromSoup3
3465
3517
  } from "@tscircuit/infgrid-ijump-astar";
3466
3518
  import { traceProps } from "@tscircuit/props";
3467
3519
  import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
@@ -3566,6 +3618,20 @@ var findPossibleTraceLayerCombinations = (hints, layer_path = []) => {
3566
3618
  return candidates;
3567
3619
  };
3568
3620
 
3621
+ // lib/utils/autorouting/getDominantDirection.ts
3622
+ function getDominantDirection(edge) {
3623
+ const delta = {
3624
+ x: edge.to.x - edge.from.x,
3625
+ y: edge.to.y - edge.from.y
3626
+ };
3627
+ const absX = Math.abs(delta.x);
3628
+ const absY = Math.abs(delta.y);
3629
+ if (absX > absY) {
3630
+ return delta.x > 0 ? "right" : "left";
3631
+ }
3632
+ return delta.y > 0 ? "down" : "up";
3633
+ }
3634
+
3569
3635
  // lib/utils/autorouting/mergeRoutes.ts
3570
3636
  function pdist(a, b) {
3571
3637
  return Math.hypot(a.x - b.x, a.y - b.y);
@@ -3645,31 +3711,15 @@ function getClosest(point, candidates) {
3645
3711
  return closest;
3646
3712
  }
3647
3713
 
3648
- // lib/utils/try-now.ts
3649
- function tryNow(fn) {
3650
- try {
3651
- return [fn(), null];
3652
- } catch (e) {
3653
- return [null, e];
3654
- }
3655
- }
3656
-
3657
- // lib/components/primitive-components/Trace/Trace.ts
3658
- import "zod";
3659
-
3660
- // lib/utils/autorouting/getDominantDirection.ts
3661
- function getDominantDirection(edge) {
3662
- const delta = {
3663
- x: edge.to.x - edge.from.x,
3664
- y: edge.to.y - edge.from.y
3665
- };
3666
- const absX = Math.abs(delta.x);
3667
- const absY = Math.abs(delta.y);
3668
- if (absX > absY) {
3669
- return delta.x > 0 ? "right" : "left";
3670
- }
3671
- return delta.y > 0 ? "down" : "up";
3672
- }
3714
+ // lib/utils/schematic/getEnteringEdgeFromDirection.ts
3715
+ var getEnteringEdgeFromDirection = (direction) => {
3716
+ return {
3717
+ up: "bottom",
3718
+ down: "top",
3719
+ left: "right",
3720
+ right: "left"
3721
+ }[direction] ?? null;
3722
+ };
3673
3723
 
3674
3724
  // lib/utils/schematic/getStubEdges.ts
3675
3725
  import { distance } from "@tscircuit/math-utils";
@@ -3723,11 +3773,20 @@ var getStubEdges = ({
3723
3773
  return edges;
3724
3774
  };
3725
3775
 
3776
+ // lib/utils/try-now.ts
3777
+ function tryNow(fn) {
3778
+ try {
3779
+ return [fn(), null];
3780
+ } catch (e) {
3781
+ return [null, e];
3782
+ }
3783
+ }
3784
+
3726
3785
  // lib/components/primitive-components/Trace/Trace.ts
3727
- import "@tscircuit/math-utils";
3786
+ import "zod";
3728
3787
 
3729
- // lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
3730
- import { doesLineIntersectLine } from "@tscircuit/math-utils";
3788
+ // lib/components/primitive-components/Trace/create-schematic-trace-crossing-segments.ts
3789
+ import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
3731
3790
 
3732
3791
  // lib/components/primitive-components/Trace/get-other-schematic-traces.ts
3733
3792
  var getOtherSchematicTraces = ({
@@ -3758,49 +3817,7 @@ var getOtherSchematicTraces = ({
3758
3817
  return traces;
3759
3818
  };
3760
3819
 
3761
- // lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
3762
- var pushEdgesOfSchematicTraceToPreventOverlap = ({
3763
- edges,
3764
- db,
3765
- source_trace_id
3766
- }) => {
3767
- const mySourceTrace = db.source_trace.get(source_trace_id);
3768
- const otherEdges = getOtherSchematicTraces({
3769
- db,
3770
- source_trace_id,
3771
- differentNetOnly: true
3772
- }).flatMap((t) => t.edges);
3773
- const edgeOrientation = (edge) => {
3774
- const { from, to } = edge;
3775
- return from.x === to.x ? "vertical" : "horizontal";
3776
- };
3777
- for (const mySegment of edges) {
3778
- const mySegmentOrientation = edgeOrientation(mySegment);
3779
- const findOverlappingParallelSegment = () => otherEdges.find(
3780
- (otherEdge) => edgeOrientation(otherEdge) === mySegmentOrientation && doesLineIntersectLine(
3781
- [mySegment.from, mySegment.to],
3782
- [otherEdge.from, otherEdge.to],
3783
- {
3784
- lineThickness: 0.05
3785
- }
3786
- )
3787
- );
3788
- let overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3789
- while (overlappingParallelSegmentFromOtherTrace) {
3790
- if (mySegmentOrientation === "horizontal") {
3791
- mySegment.from.y += 0.1;
3792
- mySegment.to.y += 0.1;
3793
- } else {
3794
- mySegment.from.x += 0.1;
3795
- mySegment.to.x += 0.1;
3796
- }
3797
- overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3798
- }
3799
- }
3800
- };
3801
-
3802
3820
  // lib/components/primitive-components/Trace/create-schematic-trace-crossing-segments.ts
3803
- import { distance as distance2, doesLineIntersectLine as doesLineIntersectLine2 } from "@tscircuit/math-utils";
3804
3821
  import { getUnitVectorFromPointAToB } from "@tscircuit/math-utils";
3805
3822
  var createSchematicTraceCrossingSegments = ({
3806
3823
  edges,
@@ -3819,7 +3836,7 @@ var createSchematicTraceCrossingSegments = ({
3819
3836
  for (const otherEdge of otherEdges) {
3820
3837
  const otherOrientation = otherEdge.from.x === otherEdge.to.x ? "vertical" : "horizontal";
3821
3838
  if (edgeOrientation === otherOrientation) continue;
3822
- const hasIntersection = doesLineIntersectLine2(
3839
+ const hasIntersection = doesLineIntersectLine(
3823
3840
  [edge.from, edge.to],
3824
3841
  [otherEdge.from, otherEdge.to],
3825
3842
  { lineThickness: 0.01 }
@@ -3914,14 +3931,46 @@ var createSchematicTraceJunctions = ({
3914
3931
  });
3915
3932
  };
3916
3933
 
3917
- // lib/utils/schematic/getEnteringEdgeFromDirection.ts
3918
- var getEnteringEdgeFromDirection = (direction) => {
3919
- return {
3920
- up: "bottom",
3921
- down: "top",
3922
- left: "right",
3923
- right: "left"
3924
- }[direction] ?? null;
3934
+ // lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
3935
+ import { doesLineIntersectLine as doesLineIntersectLine2 } from "@tscircuit/math-utils";
3936
+ var pushEdgesOfSchematicTraceToPreventOverlap = ({
3937
+ edges,
3938
+ db,
3939
+ source_trace_id
3940
+ }) => {
3941
+ const mySourceTrace = db.source_trace.get(source_trace_id);
3942
+ const otherEdges = getOtherSchematicTraces({
3943
+ db,
3944
+ source_trace_id,
3945
+ differentNetOnly: true
3946
+ }).flatMap((t) => t.edges);
3947
+ const edgeOrientation = (edge) => {
3948
+ const { from, to } = edge;
3949
+ return from.x === to.x ? "vertical" : "horizontal";
3950
+ };
3951
+ for (const mySegment of edges) {
3952
+ const mySegmentOrientation = edgeOrientation(mySegment);
3953
+ const findOverlappingParallelSegment = () => otherEdges.find(
3954
+ (otherEdge) => edgeOrientation(otherEdge) === mySegmentOrientation && doesLineIntersectLine2(
3955
+ [mySegment.from, mySegment.to],
3956
+ [otherEdge.from, otherEdge.to],
3957
+ {
3958
+ lineThickness: 0.05
3959
+ }
3960
+ )
3961
+ );
3962
+ let overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3963
+ while (overlappingParallelSegmentFromOtherTrace) {
3964
+ if (mySegmentOrientation === "horizontal") {
3965
+ mySegment.from.y += 0.1;
3966
+ mySegment.to.y += 0.1;
3967
+ } else {
3968
+ mySegment.from.x += 0.1;
3969
+ mySegment.to.x += 0.1;
3970
+ }
3971
+ overlappingParallelSegmentFromOtherTrace = findOverlappingParallelSegment();
3972
+ }
3973
+ }
3925
3974
  };
3926
3975
 
3927
3976
  // lib/components/primitive-components/Trace/Trace.ts
@@ -4076,11 +4125,21 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4076
4125
  doInitialPcbTraceRender() {
4077
4126
  const { db } = this.root;
4078
4127
  const { _parsedProps: props, parent } = this;
4128
+ const subcircuit = this.getSubcircuit();
4079
4129
  if (!parent) throw new Error("Trace has no parent");
4080
- if (this.getSubcircuit()._parsedProps.routingDisabled) {
4130
+ if (subcircuit._parsedProps.routingDisabled) {
4131
+ return;
4132
+ }
4133
+ const cachedRoute = subcircuit._parsedProps.pcbRouteCache?.pcbTraces;
4134
+ if (cachedRoute) {
4135
+ const pcb_trace2 = db.pcb_trace.insert({
4136
+ route: cachedRoute.flatMap((trace) => trace.route),
4137
+ source_trace_id: this.source_trace_id
4138
+ });
4139
+ this.pcb_trace_id = pcb_trace2.pcb_trace_id;
4081
4140
  return;
4082
4141
  }
4083
- if (!this.getSubcircuit()._shouldUseTraceByTraceRouting()) {
4142
+ if (!subcircuit._shouldUseTraceByTraceRouting()) {
4084
4143
  return;
4085
4144
  }
4086
4145
  const { allPortsFound, ports } = this._findConnectedPorts();
@@ -4179,7 +4238,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
4179
4238
  this.root.db.toArray()
4180
4239
  );
4181
4240
  const [obstacles, errGettingObstacles] = tryNow(
4182
- () => getObstaclesFromSoup2(this.root.db.toArray())
4241
+ () => getObstaclesFromSoup3(this.root.db.toArray())
4183
4242
  // Remove as any when autorouting-dataset gets updated
4184
4243
  );
4185
4244
  if (errGettingObstacles) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.191",
4
+ "version": "0.0.193",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "@tscircuit/footprinter": "^0.0.77",
41
41
  "@tscircuit/infgrid-ijump-astar": "^0.0.24",
42
42
  "@tscircuit/math-utils": "^0.0.5",
43
- "@tscircuit/props": "^0.0.99",
43
+ "@tscircuit/props": "^0.0.102",
44
44
  "@tscircuit/schematic-autolayout": "^0.0.6",
45
45
  "@tscircuit/soup-util": "^0.0.40",
46
46
  "circuit-json": "^0.0.104",