@tscircuit/core 0.0.2182 → 0.0.2183

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.
Files changed (2) hide show
  1. package/dist/index.js +77 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -126475,6 +126475,41 @@ var alignSameNetRails = ({
126475
126475
  alignedTraceCount: alignedTraceIds.size
126476
126476
  };
126477
126477
  };
126478
+ var extendBranchesToTrimmedJunctions = ({
126479
+ originalTrace,
126480
+ updatedTrace,
126481
+ traces
126482
+ }) => {
126483
+ const simplifiedPath = simplifyPath(originalTrace.tracePath);
126484
+ const extendedTraces = [];
126485
+ for (const trace of traces) {
126486
+ if (trace.mspPairId === originalTrace.mspPairId || trace.globalConnNetId !== originalTrace.globalConnNetId) {
126487
+ extendedTraces.push(trace);
126488
+ continue;
126489
+ }
126490
+ const tracePath = [...trace.tracePath];
126491
+ for (const endpointIndex of [0, tracePath.length - 1]) {
126492
+ const endpoint = tracePath[endpointIndex];
126493
+ if (!tracePathContainsPoint(originalTrace.tracePath, endpoint) || tracePathContainsPoint(simplifiedPath, endpoint) || tracePathContainsPoint(updatedTrace.tracePath, endpoint)) {
126494
+ continue;
126495
+ }
126496
+ const junction = projectPointToPath(endpoint, updatedTrace.tracePath);
126497
+ let neighbor = tracePath[endpointIndex - 1];
126498
+ if (endpointIndex === 0) neighbor = tracePath[1];
126499
+ if (!junction || !neighbor || !isAxisAlignedSegment(neighbor, junction) || trace.pins.some(
126500
+ (pin) => pin.x === endpoint.x && pin.y === endpoint.y
126501
+ ) || !originalTrace.tracePath.slice(1).some((end, index2) => {
126502
+ const segment4 = [originalTrace.tracePath[index2], end];
126503
+ return tracePathContainsPoint(segment4, endpoint) && tracePathContainsPoint(segment4, junction);
126504
+ })) {
126505
+ return null;
126506
+ }
126507
+ tracePath[endpointIndex] = junction;
126508
+ }
126509
+ extendedTraces.push({ ...trace, tracePath });
126510
+ }
126511
+ return extendedTraces;
126512
+ };
126478
126513
  var findAllLShapedTurns = (tracePath) => {
126479
126514
  const lShapes = [];
126480
126515
  if (tracePath.length < 3) {
@@ -127577,6 +127612,15 @@ var TraceCleanupSolver = class extends BaseSolver10 {
127577
127612
  traces: allTraces
127578
127613
  });
127579
127614
  }
127615
+ const extendedTraces = extendBranchesToTrimmedJunctions({
127616
+ originalTrace,
127617
+ updatedTrace,
127618
+ traces: allTraces
127619
+ });
127620
+ if (!extendedTraces) return;
127621
+ this.tracesMap = new Map(
127622
+ extendedTraces.map((trace) => [trace.mspPairId, trace])
127623
+ );
127580
127624
  this.tracesMap.set(targetMspConnectionPairId, updatedTrace);
127581
127625
  this.outputTraces = Array.from(this.tracesMap.values());
127582
127626
  }
@@ -130659,6 +130703,7 @@ var getSimplifiedRailConnectorCandidates = (params) => {
130659
130703
  if (label.orientation !== "y+" && label.orientation !== "y-") return [];
130660
130704
  const direction = label.orientation === "y+" ? 1 : -1;
130661
130705
  const candidates = [];
130706
+ const shortenedCandidates = [];
130662
130707
  const attachments = getRemovableRailLabelConnectors({
130663
130708
  ...params,
130664
130709
  rails: traces
@@ -130688,10 +130733,33 @@ var getSimplifiedRailConnectorCandidates = (params) => {
130688
130733
  reroutedTracePath
130689
130734
  });
130690
130735
  }
130736
+ if (!traceCrossesBoundsInterior(
130737
+ getRectBounds(label.center, label.width, label.height),
130738
+ { [connector.mspPairId]: connector }
130739
+ ))
130740
+ continue;
130741
+ const reversed = getDistance2(path[0], label.anchorPoint) <= EPS9;
130742
+ const sourceToLabel = reversed ? [...path].reverse() : path;
130743
+ for (let index2 = 1; index2 < sourceToLabel.length - 1; index2++) {
130744
+ const previous = sourceToLabel[index2 - 1];
130745
+ const anchorPoint = sourceToLabel[index2];
130746
+ if (Math.abs(previous.x - anchorPoint.x) > EPS9 || (anchorPoint.y - previous.y) * direction <= EPS9)
130747
+ continue;
130748
+ const retainedPath = sourceToLabel.slice(0, index2 + 1);
130749
+ shortenedCandidates.push({
130750
+ anchorPoint,
130751
+ traceId: connector.mspPairId,
130752
+ distance: getDistance2(anchorPoint, label.anchorPoint),
130753
+ pinAligned: true,
130754
+ reroutedTracePath: reversed ? retainedPath.reverse() : retainedPath
130755
+ });
130756
+ }
130691
130757
  }
130692
- return candidates.sort(
130693
- (a2, b2) => getPathLength4(a2.reroutedTracePath) - getPathLength4(b2.reroutedTracePath) || countTurns(a2.reroutedTracePath) - countTurns(b2.reroutedTracePath)
130694
- );
130758
+ const byPathLength = (a2, b2) => getPathLength4(a2.reroutedTracePath) - getPathLength4(b2.reroutedTracePath) || countTurns(a2.reroutedTracePath) - countTurns(b2.reroutedTracePath);
130759
+ return [
130760
+ ...candidates.sort(byPathLength),
130761
+ ...shortenedCandidates.sort(byPathLength)
130762
+ ];
130695
130763
  };
130696
130764
  var LABEL_TRACE_CLEARANCE3 = 0.1;
130697
130765
  var RailNetLabelCornerPlacementSolver = class extends BaseSolver10 {
@@ -131231,7 +131299,10 @@ var RailNetLabelCornerPlacementSolver = class extends BaseSolver10 {
131231
131299
  }
131232
131300
  getTraceLinesForLabel(label) {
131233
131301
  return this.traces.filter(
131234
- (trace) => isTraceLine(trace) && this.isTraceForLabel(trace, label)
131302
+ // Generated connectors inherit pin IDs, but are not pin-to-pin rails.
131303
+ // Their labels can move only with the connector geometry and the
131304
+ // attachment checks in getSimplifiedRailConnectorCandidates.
131305
+ (trace) => !this.netLabelConnectorTraceIds.has(trace.mspPairId) && isTraceLine(trace) && this.isTraceForLabel(trace, label)
131235
131306
  );
131236
131307
  }
131237
131308
  isTraceForLabel(trace, label) {
@@ -150464,7 +150535,7 @@ var RoutingPhasePreparationError = class extends Error {
150464
150535
  var package_default = {
150465
150536
  name: "@tscircuit/core",
150466
150537
  type: "module",
150467
- version: "0.0.2181",
150538
+ version: "0.0.2182",
150468
150539
  types: "dist/index.d.ts",
150469
150540
  main: "dist/index.js",
150470
150541
  module: "dist/index.js",
@@ -150525,7 +150596,7 @@ var package_default = {
150525
150596
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
150526
150597
  "@tscircuit/props": "^0.0.705",
150527
150598
  "@tscircuit/schematic-match-adapt": "^0.0.18",
150528
- "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.230.tgz",
150599
+ "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.236.tgz",
150529
150600
  "@tscircuit/solver-utils": "^0.0.16",
150530
150601
  "@tscircuit/soup-util": "^0.0.41",
150531
150602
  "@tscircuit/via-stitch-solver": "github:tscircuit/via-stitch-solver#64f2ac7781b795bdc0d74ba411988e60767fa653",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.2182",
4
+ "version": "0.0.2183",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
63
63
  "@tscircuit/props": "^0.0.705",
64
64
  "@tscircuit/schematic-match-adapt": "^0.0.18",
65
- "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.230.tgz",
65
+ "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.236.tgz",
66
66
  "@tscircuit/solver-utils": "^0.0.16",
67
67
  "@tscircuit/soup-util": "^0.0.41",
68
68
  "@tscircuit/via-stitch-solver": "github:tscircuit/via-stitch-solver#64f2ac7781b795bdc0d74ba411988e60767fa653",