@tscircuit/core 0.0.1283 → 0.0.1285

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
@@ -2315,6 +2315,8 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
2315
2315
  _asyncAutoroutingResult: {
2316
2316
  output_simple_route_json?: SimpleRouteJson;
2317
2317
  output_pcb_traces?: (PcbTrace$1 | PcbVia$1)[];
2318
+ pcb_trace_ids_to_be_replaced?: string[];
2319
+ input_simple_route_json?: SimpleRouteJson;
2318
2320
  output_jumpers?: Array<{
2319
2321
  jumper_footprint: string;
2320
2322
  center: {
@@ -73223,6 +73225,7 @@ declare class BaseBreakoutPoint<TProps extends ZodType = typeof baseBreakoutPoin
73223
73225
  pcb_breakout_point_id: string | null;
73224
73226
  matchedPort: Port | null;
73225
73227
  matchedNet: Net | null;
73228
+ matchedSourceTraceId: string | null;
73226
73229
  isPcbPrimitive: boolean;
73227
73230
  _getSourceTraceIdForPort(port: Port): string | undefined;
73228
73231
  _getSourceNetIdForPort(port: Port): string | undefined;
package/dist/index.js CHANGED
@@ -14572,7 +14572,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
14572
14572
  };
14573
14573
  }
14574
14574
  const routedTraceIds = new Set(
14575
- db.pcb_trace.list().map((t) => t.source_trace_id).filter((id) => Boolean(id))
14575
+ db.pcb_trace.list().filter((t) => !subcircuit_id || t.subcircuit_id === subcircuit_id).map((t) => t.source_trace_id).filter((id) => Boolean(id))
14576
14576
  );
14577
14577
  const sourcePortIdToBreakoutPoint = /* @__PURE__ */ new Map();
14578
14578
  for (const bp of breakoutPoints) {
@@ -14705,6 +14705,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
14705
14705
  if (bp.subcircuit_id === subcircuit_id) {
14706
14706
  connectionsFromBreakoutPoints.push({
14707
14707
  name: bpSourcePortId,
14708
+ source_trace_id: bp.source_trace_id,
14708
14709
  pointsToConnect: [portPt, pt]
14709
14710
  });
14710
14711
  continue;
@@ -19477,11 +19478,12 @@ function addPossibleReplacementSourceTraceId(sourceTraceIds, value) {
19477
19478
  }
19478
19479
  function deleteExistingPcbTracesReplacedBy({
19479
19480
  group,
19480
- outputPcbTraces
19481
+ outputPcbTraces,
19482
+ pcbTraceIdsToReplace = []
19481
19483
  }) {
19482
19484
  const db = group.root?.db;
19483
19485
  if (!db) return;
19484
- const replacementPcbTraceIds = /* @__PURE__ */ new Set();
19486
+ const replacementPcbTraceIds = new Set(pcbTraceIdsToReplace);
19485
19487
  const replacementSourceTraceIds = /* @__PURE__ */ new Set();
19486
19488
  for (const trace of outputPcbTraces) {
19487
19489
  if (trace.type !== "pcb_trace") continue;
@@ -19505,7 +19507,7 @@ function deleteExistingPcbTracesReplacedBy({
19505
19507
  }
19506
19508
  const tracesToDelete = getExistingPcbTracesForReroute(group).filter(
19507
19509
  (trace) => replacementPcbTraceIds.has(trace.pcb_trace_id) || Boolean(
19508
- trace.source_trace_id && replacementSourceTraceIds.has(trace.source_trace_id)
19510
+ trace.source_trace_id && trace.subcircuit_id === group.subcircuit_id && replacementSourceTraceIds.has(trace.source_trace_id)
19509
19511
  )
19510
19512
  );
19511
19513
  if (tracesToDelete.length === 0) return;
@@ -20157,6 +20159,7 @@ var Group5 = class extends NormalComponent3 {
20157
20159
  const hasPhasedAutorouting = Group_hasPhasedAutorouting(routingPhasePlans);
20158
20160
  const outputTraces = [];
20159
20161
  const outputJumpers = [];
20162
+ const pcbTraceIdsToDelete = /* @__PURE__ */ new Set();
20160
20163
  const existingRerouteSeedTraces = getExistingSimplifiedPcbTracesForReroute(this);
20161
20164
  const traceMatchesRoutingPhase = (trace, routingPhasePlan) => {
20162
20165
  const connectionName = trace.connection_name ?? trace.pcb_trace_id;
@@ -20329,6 +20332,11 @@ var Group5 = class extends NormalComponent3 {
20329
20332
  outputJumpers.push(...solver.getOutputJumpers() || []);
20330
20333
  }
20331
20334
  if (isRegionReroutePhase && rerouteOriginalSrj) {
20335
+ for (const trace of rerouteOriginalSrj.traces ?? []) {
20336
+ if (trace.type === "pcb_trace") {
20337
+ pcbTraceIdsToDelete.add(trace.pcb_trace_id);
20338
+ }
20339
+ }
20332
20340
  const reconnectedSrj = reconnectReroutedSimpleRouteJsonRegion(
20333
20341
  rerouteOriginalSrj,
20334
20342
  {
@@ -20375,7 +20383,9 @@ var Group5 = class extends NormalComponent3 {
20375
20383
  }
20376
20384
  this._asyncAutoroutingResult = {
20377
20385
  output_pcb_traces: outputTraces,
20378
- output_jumpers: outputJumpers
20386
+ output_jumpers: outputJumpers,
20387
+ pcb_trace_ids_to_be_replaced: [...pcbTraceIdsToDelete],
20388
+ input_simple_route_json: baseSimpleRouteJson
20379
20389
  };
20380
20390
  this._markDirty("PcbTraceRender");
20381
20391
  }
@@ -20474,7 +20484,12 @@ var Group5 = class extends NormalComponent3 {
20474
20484
  }
20475
20485
  }
20476
20486
  _updatePcbTraceRenderFromPcbTraces() {
20477
- const { output_pcb_traces, output_jumpers } = this._asyncAutoroutingResult;
20487
+ const {
20488
+ output_pcb_traces,
20489
+ output_jumpers,
20490
+ pcb_trace_ids_to_be_replaced,
20491
+ input_simple_route_json
20492
+ } = this._asyncAutoroutingResult;
20478
20493
  if (!output_pcb_traces) return;
20479
20494
  const { db } = this.root;
20480
20495
  const pcbStyle = this.getInheritedMergedProperty("pcbStyle");
@@ -20491,12 +20506,26 @@ var Group5 = class extends NormalComponent3 {
20491
20506
  }
20492
20507
  deleteExistingPcbTracesReplacedBy({
20493
20508
  group: this,
20494
- outputPcbTraces: output_pcb_traces
20495
- });
20509
+ outputPcbTraces: output_pcb_traces,
20510
+ pcbTraceIdsToReplace: pcb_trace_ids_to_be_replaced
20511
+ });
20512
+ const sourceTraceIdByConnectionName = /* @__PURE__ */ new Map();
20513
+ for (const connection of input_simple_route_json?.connections ?? []) {
20514
+ if (connection.source_trace_id) {
20515
+ sourceTraceIdByConnectionName.set(
20516
+ connection.name,
20517
+ connection.source_trace_id
20518
+ );
20519
+ }
20520
+ }
20496
20521
  for (const pcb_trace of output_pcb_traces) {
20497
20522
  if (pcb_trace.type !== "pcb_trace") continue;
20523
+ const inputConnectionSourceTraceId = sourceTraceIdByConnectionName.get(
20524
+ pcb_trace.connection_name
20525
+ );
20498
20526
  const possibleSourceTraceIds = [
20499
20527
  ...getSourceTraceIdsFromRerouteName(pcb_trace.source_trace_id),
20528
+ ...inputConnectionSourceTraceId ? [inputConnectionSourceTraceId] : [],
20500
20529
  ...getSourceTraceIdsFromRerouteName(pcb_trace.connection_name),
20501
20530
  ...getSourceTraceIdsFromRerouteName(
20502
20531
  pcb_trace.rootConnectionName
@@ -20515,7 +20544,7 @@ var Group5 = class extends NormalComponent3 {
20515
20544
  } else {
20516
20545
  delete pcb_trace.source_trace_id;
20517
20546
  }
20518
- pcb_trace.subcircuit_id ??= (sourceTraceId ? db.source_trace.get(sourceTraceId)?.subcircuit_id ?? db.source_net.get(sourceTraceId)?.subcircuit_id : void 0) ?? this.subcircuit_id;
20547
+ pcb_trace.subcircuit_id ??= this.subcircuit_id;
20519
20548
  const cjRoute = pcb_trace.route.map((point6) => {
20520
20549
  if (point6.route_type !== "through_obstacle") return point6;
20521
20550
  return {
@@ -21867,7 +21896,7 @@ import { identity as identity5 } from "transformation-matrix";
21867
21896
  var package_default = {
21868
21897
  name: "@tscircuit/core",
21869
21898
  type: "module",
21870
- version: "0.0.1282",
21899
+ version: "0.0.1284",
21871
21900
  types: "dist/index.d.ts",
21872
21901
  main: "dist/index.js",
21873
21902
  module: "dist/index.js",
@@ -21979,7 +22008,7 @@ var package_default = {
21979
22008
  dependencies: {
21980
22009
  "@flatten-js/core": "^1.6.2",
21981
22010
  "@lume/kiwi": "^0.4.3",
21982
- "calculate-cell-boundaries": "^0.0.1",
22011
+ "calculate-cell-boundaries": "^0.0.8",
21983
22012
  "calculate-packing": "0.0.73",
21984
22013
  "css-select": "5.1.0",
21985
22014
  "format-si-unit": "^0.0.3",
@@ -25604,6 +25633,7 @@ var BaseBreakoutPoint = class extends PrimitiveComponent2 {
25604
25633
  pcb_breakout_point_id = null;
25605
25634
  matchedPort = null;
25606
25635
  matchedNet = null;
25636
+ matchedSourceTraceId = null;
25607
25637
  isPcbPrimitive = true;
25608
25638
  _getSourceTraceIdForPort(port) {
25609
25639
  const { db } = this.root;
@@ -25627,7 +25657,7 @@ var BaseBreakoutPoint = class extends PrimitiveComponent2 {
25627
25657
  pcb_group_id: group.pcb_group_id,
25628
25658
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
25629
25659
  source_port_id: this.matchedPort?.source_port_id ?? void 0,
25630
- source_trace_id: this.matchedPort ? this._getSourceTraceIdForPort(this.matchedPort) : void 0,
25660
+ source_trace_id: this.matchedPort ? this.matchedSourceTraceId ?? this._getSourceTraceIdForPort(this.matchedPort) : void 0,
25631
25661
  source_net_id: this.matchedNet ? this.matchedNet.source_net_id : this.matchedPort ? this._getSourceNetIdForPort(this.matchedPort) : void 0,
25632
25662
  x: position.x,
25633
25663
  y: position.y
@@ -25651,10 +25681,14 @@ var BaseBreakoutPoint = class extends PrimitiveComponent2 {
25651
25681
  _setPositionFromLayout(newCenter) {
25652
25682
  const { db } = this.root;
25653
25683
  if (!this.pcb_breakout_point_id) return;
25654
- db.pcb_breakout_point.update(this.pcb_breakout_point_id, {
25684
+ const updatedProperties = {
25655
25685
  x: newCenter.x,
25656
25686
  y: newCenter.y
25657
- });
25687
+ };
25688
+ if (this.matchedSourceTraceId) {
25689
+ updatedProperties.source_trace_id = this.matchedSourceTraceId;
25690
+ }
25691
+ db.pcb_breakout_point.update(this.pcb_breakout_point_id, updatedProperties);
25658
25692
  }
25659
25693
  _moveCircuitJsonElements({
25660
25694
  deltaX,
@@ -25859,6 +25893,7 @@ var Breakout = class extends Group5 {
25859
25893
  autoPlacedPorts.add(port);
25860
25894
  const breakoutPoint = new AutoplacedBreakoutPoint({});
25861
25895
  breakoutPoint.matchedPort = port;
25896
+ breakoutPoint.matchedSourceTraceId = trace.source_trace_id;
25862
25897
  this.add(breakoutPoint);
25863
25898
  }
25864
25899
  }
@@ -25878,6 +25913,7 @@ var Breakout = class extends Group5 {
25878
25913
  (child) => child.matchedPort?.source_port_id === solvedPoint.sourcePortId
25879
25914
  );
25880
25915
  if (matchingBreakoutPoint) {
25916
+ matchingBreakoutPoint.matchedSourceTraceId = solvedPoint.sourceTraceId;
25881
25917
  matchingBreakoutPoint._setPositionFromLayout({
25882
25918
  x: solvedPoint.x,
25883
25919
  y: solvedPoint.y
@@ -28433,8 +28469,14 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
28433
28469
  if (sectionData.length === 0) return;
28434
28470
  const allCells = sectionData.map((s) => s.cell);
28435
28471
  const outer = computeBoundsFromCellContents(allCells);
28472
+ const CELL_MARGIN = 1;
28436
28473
  const dividers = calculateCellBoundaries(
28437
- sectionData.map((s) => s.rawBounds)
28474
+ sectionData.map((s) => ({
28475
+ minX: s.rawBounds.minX - CELL_MARGIN,
28476
+ maxX: s.rawBounds.maxX + CELL_MARGIN,
28477
+ minY: s.rawBounds.minY - CELL_MARGIN,
28478
+ maxY: s.rawBounds.maxY + CELL_MARGIN
28479
+ }))
28438
28480
  );
28439
28481
  for (const line of dividers) {
28440
28482
  db.schematic_line.insert({
@@ -28453,10 +28495,10 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
28453
28495
  const vDividers = dividers.filter(
28454
28496
  (l) => Math.abs(l.start.x - l.end.x) < TOL3
28455
28497
  );
28456
- for (const { section, cell, rawBounds } of sectionData) {
28498
+ for (const { section, rawBounds } of sectionData) {
28457
28499
  const { displayName, sectionTitleFontSize } = section._parsedProps;
28458
28500
  if (!displayName) continue;
28459
- const dividersAbove = hDividers.map((l) => l.start.y).filter((y) => y > cell.minY);
28501
+ const dividersAbove = hDividers.map((l) => l.start.y).filter((y) => y > rawBounds.maxY);
28460
28502
  const topBoundary = dividersAbove.length > 0 ? Math.min(...dividersAbove) : outer.maxY;
28461
28503
  const dividersToLeft = vDividers.map((l) => l.start.x).filter((x) => x < rawBounds.minX);
28462
28504
  const leftBoundary = dividersToLeft.length > 0 ? Math.max(...dividersToLeft) : outer.minX;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1283",
4
+ "version": "0.0.1285",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -113,7 +113,7 @@
113
113
  "dependencies": {
114
114
  "@flatten-js/core": "^1.6.2",
115
115
  "@lume/kiwi": "^0.4.3",
116
- "calculate-cell-boundaries": "^0.0.1",
116
+ "calculate-cell-boundaries": "^0.0.8",
117
117
  "calculate-packing": "0.0.73",
118
118
  "css-select": "5.1.0",
119
119
  "format-si-unit": "^0.0.3",