@tscircuit/core 0.0.1226 → 0.0.1227

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,7 +1,7 @@
1
1
  import * as circuit_json from 'circuit-json';
2
2
  import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, PcbTraceRoutePoint, AnySourceComponent, PcbComponent, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, traceProps, netProps, AutorouterProp, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSectionProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, traceProps, netProps, AutorouterProp, AutoroutingPhaseProps, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, resistorProps, constraintProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, fiducialProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSectionProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  export { kicadFootprintStrings } from '@tscircuit/props';
6
6
  import * as react from 'react';
7
7
  import react__default, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
@@ -12,7 +12,7 @@ import { symbols, SchSymbol, BaseSymbolName } from 'schematic-symbols';
12
12
  import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
13
13
  import { Matrix } from 'transformation-matrix';
14
14
  import { PackSolver2 } from 'calculate-packing';
15
- import { AutoroutingPipelineSolver, AssignableAutoroutingPipeline2, AssignableAutoroutingPipeline3, AutoroutingPipeline1_OriginalUnravel, AutoroutingPipelineSolver3_HgPortPointPathing, AutoroutingPipelineSolver5 } from '@tscircuit/capacity-autorouter';
15
+ import { AutoroutingPipelineSolver, AssignableAutoroutingPipeline2, AssignableAutoroutingPipeline3, AutoroutingPipeline1_OriginalUnravel, AutoroutingPipelineSolver3_HgPortPointPathing, AutoroutingPipelineSolver5, SimplifiedPcbTrace as SimplifiedPcbTrace$1, SimpleRouteJson as SimpleRouteJson$1 } from '@tscircuit/capacity-autorouter';
16
16
  import { CopperPourPipelineSolver } from '@tscircuit/copper-pour-solver';
17
17
  import { Bounds } from '@tscircuit/math-utils';
18
18
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
@@ -31,7 +31,7 @@ declare const SOLVERS: {
31
31
  };
32
32
  type SolverName = keyof typeof SOLVERS;
33
33
 
34
- type SimplifiedPcbTrace = {
34
+ type SimplifiedPcbTrace = Omit<SimplifiedPcbTrace$1, "connection_name" | "route"> & {
35
35
  type: "pcb_trace";
36
36
  pcb_trace_id: string;
37
37
  connection_name?: string;
@@ -61,6 +61,19 @@ type SimplifiedPcbTrace = {
61
61
  };
62
62
  footprint: "0603" | "1206" | "1206x4_pair";
63
63
  layer: string;
64
+ } | {
65
+ route_type: "through_obstacle";
66
+ start: {
67
+ x: number;
68
+ y: number;
69
+ };
70
+ end: {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ from_layer: string;
75
+ to_layer: string;
76
+ width: number;
64
77
  }>;
65
78
  };
66
79
  type Obstacle = {
@@ -80,21 +93,32 @@ type Obstacle = {
80
93
  netIsAssignable?: boolean;
81
94
  offBoardConnectsTo?: string[];
82
95
  };
83
- interface SimpleRouteConnection {
96
+ type SimpleRouteConnection = {
84
97
  name: string;
85
98
  source_trace_id?: string;
99
+ rootConnectionName?: string;
100
+ mergedConnectionNames?: string[];
101
+ isOffBoard?: boolean;
102
+ netConnectionName?: string;
86
103
  nominalTraceWidth?: number;
104
+ /** @deprecated Use `nominalTraceWidth` instead. */
87
105
  width?: number;
88
106
  pointsToConnect: Array<{
89
107
  x: number;
90
108
  y: number;
91
109
  layer: string;
110
+ layers?: string[];
92
111
  pointId?: string;
93
112
  pcb_port_id?: string;
113
+ terminalVia?: {
114
+ toLayer: string;
115
+ viaDiameter?: number;
116
+ };
94
117
  }>;
118
+ /** @deprecated DO NOT USE **/
95
119
  externallyConnectedPointIds?: string[][];
96
- }
97
- interface SimpleRouteJson {
120
+ };
121
+ type SimpleRouteJson = Omit<SimpleRouteJson$1, "connections" | "traces" | "obstacles" | "bounds" | "outline" | "allowJumpers" | "availableJumperTypes"> & {
98
122
  layerCount: number;
99
123
  minTraceWidth: number;
100
124
  nominalTraceWidth?: number;
@@ -104,10 +128,11 @@ interface SimpleRouteJson {
104
128
  minViaPadDiameter?: number;
105
129
  min_via_hole_diameter?: number;
106
130
  min_via_pad_diameter?: number;
131
+ defaultObstacleMargin?: number;
107
132
  minTraceToPadEdgeClearance?: number;
108
133
  minViaEdgeToPadEdgeClearance?: number;
109
134
  obstacles: Obstacle[];
110
- connections: Array<SimpleRouteConnection>;
135
+ connections: SimpleRouteConnection[];
111
136
  bounds: {
112
137
  minX: number;
113
138
  maxX: number;
@@ -119,9 +144,20 @@ interface SimpleRouteJson {
119
144
  y: number;
120
145
  }>;
121
146
  traces?: SimplifiedPcbTrace[];
147
+ jumpers?: Array<{
148
+ jumper_footprint: "0603" | "1206x4";
149
+ center: {
150
+ x: number;
151
+ y: number;
152
+ };
153
+ orientation: "horizontal" | "vertical";
154
+ width: number;
155
+ height: number;
156
+ pads: Obstacle[];
157
+ }>;
122
158
  allowJumpers?: boolean;
123
159
  availableJumperTypes?: Array<"1206x4" | "0603">;
124
- }
160
+ };
125
161
 
126
162
  type RootCircuitEventName = "asyncEffect:start" | "asyncEffect:end" | "renderable:renderLifecycle:anyEvent" | `renderable:renderLifecycle:${RenderPhase}:start` | `renderable:renderLifecycle:${RenderPhase}:end` | `board:renderPhaseStarted` | "external:evalError" | "autorouting:start" | "autorouting:end" | "autorouting:error" | "autorouting:progress" | "packing:start" | "packing:end" | "packing:error" | "solver:started" | "renderComplete" | "debug:logOutput";
127
163
  interface AutoroutingStartEvent {
@@ -1342,6 +1378,8 @@ declare class Net extends PrimitiveComponent<typeof netProps> {
1342
1378
  interface RoutingPhasePlan {
1343
1379
  routingPhaseIndex: number | null;
1344
1380
  autorouter?: AutorouterProp;
1381
+ reroute?: boolean;
1382
+ region?: AutoroutingPhaseProps["region"];
1345
1383
  nets: Net[];
1346
1384
  traces: Trace[];
1347
1385
  }
@@ -71184,6 +71222,7 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71184
71222
  autorouter: zod.ZodOptional<zod.ZodType<_tscircuit_props.AutorouterProp, zod.ZodTypeDef, _tscircuit_props.AutorouterProp>>;
71185
71223
  phaseIndex: zod.ZodOptional<zod.ZodNumber>;
71186
71224
  region: zod.ZodOptional<zod.ZodObject<{
71225
+ shape: zod.ZodOptional<zod.ZodLiteral<"rect">>;
71187
71226
  minX: zod.ZodNumber;
71188
71227
  maxX: zod.ZodNumber;
71189
71228
  minY: zod.ZodNumber;
@@ -71193,11 +71232,13 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71193
71232
  maxX: number;
71194
71233
  minY: number;
71195
71234
  maxY: number;
71235
+ shape?: "rect" | undefined;
71196
71236
  }, {
71197
71237
  minX: number;
71198
71238
  maxX: number;
71199
71239
  minY: number;
71200
71240
  maxY: number;
71241
+ shape?: "rect" | undefined;
71201
71242
  }>>;
71202
71243
  reroute: zod.ZodOptional<zod.ZodBoolean>;
71203
71244
  }, "strip", zod.ZodTypeAny, {
@@ -71209,6 +71250,7 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71209
71250
  maxX: number;
71210
71251
  minY: number;
71211
71252
  maxY: number;
71253
+ shape?: "rect" | undefined;
71212
71254
  } | undefined;
71213
71255
  reroute?: boolean | undefined;
71214
71256
  }, {
@@ -71220,6 +71262,7 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71220
71262
  maxX: number;
71221
71263
  minY: number;
71222
71264
  maxY: number;
71265
+ shape?: "rect" | undefined;
71223
71266
  } | undefined;
71224
71267
  reroute?: boolean | undefined;
71225
71268
  }>, {
@@ -71231,6 +71274,7 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71231
71274
  maxX: number;
71232
71275
  minY: number;
71233
71276
  maxY: number;
71277
+ shape?: "rect" | undefined;
71234
71278
  } | undefined;
71235
71279
  reroute?: boolean | undefined;
71236
71280
  }, {
@@ -71242,6 +71286,7 @@ declare class AutoroutingPhase extends PrimitiveComponent<typeof autoroutingPhas
71242
71286
  maxX: number;
71243
71287
  minY: number;
71244
71288
  maxY: number;
71289
+ shape?: "rect" | undefined;
71245
71290
  } | undefined;
71246
71291
  reroute?: boolean | undefined;
71247
71292
  }>;
package/dist/index.js CHANGED
@@ -13226,7 +13226,11 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
13226
13226
  }
13227
13227
 
13228
13228
  // lib/components/primitive-components/Group/Group.ts
13229
- import { convertSrjToGraphicsObject } from "@tscircuit/capacity-autorouter";
13229
+ import {
13230
+ convertSrjToGraphicsObject,
13231
+ getRerouteSimpleRouteJson,
13232
+ reconnectReroutedSimpleRouteJsonRegion
13233
+ } from "@tscircuit/capacity-autorouter";
13230
13234
  import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
13231
13235
  import {
13232
13236
  groupProps
@@ -18247,12 +18251,24 @@ function getAutoroutersByPhaseIndex(group) {
18247
18251
  }
18248
18252
  return autoroutersByPhaseIndex;
18249
18253
  }
18254
+ function getAutoroutingPhasePropsByPhaseIndex(group) {
18255
+ const autoroutingPhases = group.selectAll(
18256
+ "autoroutingphase"
18257
+ );
18258
+ const propsByPhaseIndex = /* @__PURE__ */ new Map();
18259
+ for (const autoroutingPhase of autoroutingPhases) {
18260
+ const props = autoroutingPhase._parsedProps;
18261
+ propsByPhaseIndex.set(props.phaseIndex ?? null, props);
18262
+ }
18263
+ return propsByPhaseIndex;
18264
+ }
18250
18265
  function Group_getRoutingPhasePlans(group) {
18251
18266
  const traces = group.selectAll("trace");
18252
18267
  const nets = group.selectAll("net");
18253
18268
  if (traces.length === 0 && nets.length === 0) return [];
18254
18269
  const plansByPhaseIndex = /* @__PURE__ */ new Map();
18255
18270
  const autoroutersByPhaseIndex = getAutoroutersByPhaseIndex(group);
18271
+ const phasePropsByPhaseIndex = getAutoroutingPhasePropsByPhaseIndex(group);
18256
18272
  for (const net of nets) {
18257
18273
  const routingPhaseIndex = getNetRoutingPhaseIndex(net);
18258
18274
  getOrCreateRoutingPhasePlan(plansByPhaseIndex, routingPhaseIndex).nets.push(
@@ -18266,11 +18282,19 @@ function Group_getRoutingPhasePlans(group) {
18266
18282
  routingPhaseIndex
18267
18283
  ).traces.push(trace);
18268
18284
  }
18285
+ for (const [phaseIndex, phaseProps] of phasePropsByPhaseIndex) {
18286
+ if (phaseProps.reroute) {
18287
+ getOrCreateRoutingPhasePlan(plansByPhaseIndex, phaseIndex);
18288
+ }
18289
+ }
18269
18290
  const plans = Array.from(plansByPhaseIndex.values()).sort(
18270
18291
  compareRoutingPhasePlans
18271
18292
  );
18272
18293
  for (const plan of plans) {
18273
18294
  plan.autorouter = autoroutersByPhaseIndex.get(plan.routingPhaseIndex);
18295
+ const phaseProps = phasePropsByPhaseIndex.get(plan.routingPhaseIndex);
18296
+ plan.reroute = phaseProps?.reroute;
18297
+ plan.region = phaseProps?.region;
18274
18298
  }
18275
18299
  return plans;
18276
18300
  }
@@ -18302,10 +18326,12 @@ function getSegmentLayer(start, end) {
18302
18326
  }
18303
18327
  function getRoutePointX(point6) {
18304
18328
  if (isJumperPoint(point6)) return null;
18329
+ if (point6.route_type === "through_obstacle") return null;
18305
18330
  return point6.x;
18306
18331
  }
18307
18332
  function getRoutePointY(point6) {
18308
18333
  if (isJumperPoint(point6)) return null;
18334
+ if (point6.route_type === "through_obstacle") return null;
18309
18335
  return point6.y;
18310
18336
  }
18311
18337
  function createWireObstacle(start, end, connectedTo, obstacleIndex) {
@@ -19239,7 +19265,22 @@ var Group6 = class extends NormalComponent3 {
19239
19265
  for (const routingPhasePlan of routingPhasePlans) {
19240
19266
  const phaseAutorouterConfig = routingPhasePlan.autorouter ? getPresetAutoroutingConfig(routingPhasePlan.autorouter) : autorouterConfig;
19241
19267
  let simpleRouteJson = baseSimpleRouteJson;
19242
- if (hasPhasedAutorouting) {
19268
+ const isReroutePhase = Boolean(
19269
+ routingPhasePlan.reroute && routingPhasePlan.region
19270
+ );
19271
+ const rerouteOriginalSrj = isReroutePhase ? {
19272
+ ...baseSimpleRouteJson,
19273
+ traces: outputTraces
19274
+ } : null;
19275
+ if (isReroutePhase && rerouteOriginalSrj) {
19276
+ simpleRouteJson = getRerouteSimpleRouteJson(
19277
+ rerouteOriginalSrj,
19278
+ {
19279
+ shape: "rect",
19280
+ ...routingPhasePlan.region
19281
+ }
19282
+ );
19283
+ } else if (hasPhasedAutorouting) {
19243
19284
  simpleRouteJson = Group_filterSimpleRouteJsonForPhase(
19244
19285
  baseSimpleRouteJson,
19245
19286
  routingPhasePlan
@@ -19339,7 +19380,22 @@ var Group6 = class extends NormalComponent3 {
19339
19380
  if (solver?.getOutputJumpers) {
19340
19381
  outputJumpers.push(...solver.getOutputJumpers() || []);
19341
19382
  }
19342
- outputTraces.push(...traces);
19383
+ if (isReroutePhase && rerouteOriginalSrj) {
19384
+ const reconnectedSrj = reconnectReroutedSimpleRouteJsonRegion(
19385
+ rerouteOriginalSrj,
19386
+ {
19387
+ ...simpleRouteJson,
19388
+ traces: [...simpleRouteJson.traces ?? [], ...traces]
19389
+ }
19390
+ );
19391
+ outputTraces.splice(
19392
+ 0,
19393
+ outputTraces.length,
19394
+ ...reconnectedSrj.traces ?? []
19395
+ );
19396
+ } else {
19397
+ outputTraces.push(...traces);
19398
+ }
19343
19399
  } catch (error) {
19344
19400
  const { db: db2 } = this.root;
19345
19401
  db2.pcb_autorouting_error.insert({
@@ -20554,7 +20610,7 @@ import { identity as identity5 } from "transformation-matrix";
20554
20610
  var package_default = {
20555
20611
  name: "@tscircuit/core",
20556
20612
  type: "module",
20557
- version: "0.0.1225",
20613
+ version: "0.0.1226",
20558
20614
  types: "dist/index.d.ts",
20559
20615
  main: "dist/index.js",
20560
20616
  module: "dist/index.js",
@@ -20586,7 +20642,7 @@ var package_default = {
20586
20642
  "@biomejs/biome": "^1.8.3",
20587
20643
  "@resvg/resvg-js": "^2.6.2",
20588
20644
  "@tscircuit/alphabet": "0.0.25",
20589
- "@tscircuit/capacity-autorouter": "^0.0.500",
20645
+ "@tscircuit/capacity-autorouter": "^0.0.502",
20590
20646
  "@tscircuit/checks": "0.0.126",
20591
20647
  "@tscircuit/circuit-json-util": "^0.0.94",
20592
20648
  "@tscircuit/common": "^0.0.20",
@@ -20600,7 +20656,7 @@ var package_default = {
20600
20656
  "@tscircuit/math-utils": "^0.0.36",
20601
20657
  "@tscircuit/miniflex": "^0.0.4",
20602
20658
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
20603
- "@tscircuit/props": "^0.0.524",
20659
+ "@tscircuit/props": "^0.0.525",
20604
20660
  "@tscircuit/schematic-match-adapt": "^0.0.16",
20605
20661
  "@tscircuit/schematic-trace-solver": "^0.0.55",
20606
20662
  "@tscircuit/solver-utils": "^0.0.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1226",
4
+ "version": "0.0.1227",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "@biomejs/biome": "^1.8.3",
34
34
  "@resvg/resvg-js": "^2.6.2",
35
35
  "@tscircuit/alphabet": "0.0.25",
36
- "@tscircuit/capacity-autorouter": "^0.0.500",
36
+ "@tscircuit/capacity-autorouter": "^0.0.502",
37
37
  "@tscircuit/checks": "0.0.126",
38
38
  "@tscircuit/circuit-json-util": "^0.0.94",
39
39
  "@tscircuit/common": "^0.0.20",
@@ -47,7 +47,7 @@
47
47
  "@tscircuit/math-utils": "^0.0.36",
48
48
  "@tscircuit/miniflex": "^0.0.4",
49
49
  "@tscircuit/ngspice-spice-engine": "^0.0.8",
50
- "@tscircuit/props": "^0.0.524",
50
+ "@tscircuit/props": "^0.0.525",
51
51
  "@tscircuit/schematic-match-adapt": "^0.0.16",
52
52
  "@tscircuit/schematic-trace-solver": "^0.0.55",
53
53
  "@tscircuit/solver-utils": "^0.0.3",