@tscircuit/core 0.0.2116 → 0.0.2118

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 +88 -25
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -102222,9 +102222,36 @@ var getAlignedSharedEndpointRailPath = ({
102222
102222
  if (donorPath.length < 3 || branchPath.length < 4) return null;
102223
102223
  const donorDepartureAxis = getSegmentAxis4(donorPath[0], donorPath[1]);
102224
102224
  const branchDepartureAxis = getSegmentAxis4(branchPath[0], branchPath[1]);
102225
- if (!donorDepartureAxis || donorDepartureAxis !== branchDepartureAxis) {
102225
+ if (!donorDepartureAxis || !branchDepartureAxis) {
102226
102226
  return null;
102227
102227
  }
102228
+ if (donorDepartureAxis !== branchDepartureAxis) {
102229
+ if (!nearlyEqual(donorPath[0].x, branchPath[0].x) || !nearlyEqual(donorPath[0].y, branchPath[0].y)) {
102230
+ return null;
102231
+ }
102232
+ const branchRailAxis2 = getSegmentAxis4(branchPath[1], branchPath[2]);
102233
+ const donorRailAxis2 = getSegmentAxis4(donorPath[1], donorPath[2]);
102234
+ if (branchRailAxis2 !== donorDepartureAxis || donorRailAxis2 !== branchDepartureAxis || getPinFacingAxis(sharedPin) !== branchDepartureAxis || !isCoordinateOnPinFacingSide({
102235
+ coordinate: branchPath[1][branchDepartureAxis],
102236
+ axis: branchDepartureAxis,
102237
+ pin: sharedPin
102238
+ })) {
102239
+ return null;
102240
+ }
102241
+ const donorDirection = donorPath[1][donorDepartureAxis] - donorPath[0][donorDepartureAxis];
102242
+ const branchDirection = branchPath[2][branchRailAxis2] - branchPath[1][branchRailAxis2];
102243
+ if (Math.sign(donorDirection) === Math.sign(branchDirection)) return null;
102244
+ const railCoordinateAxis2 = branchRailAxis2 === "x" ? "y" : "x";
102245
+ const candidateFromShared2 = simplifyPath([
102246
+ branchPath[0],
102247
+ {
102248
+ ...branchPath[2],
102249
+ [railCoordinateAxis2]: donorPath[0][railCoordinateAxis2]
102250
+ },
102251
+ ...branchPath.slice(3)
102252
+ ]);
102253
+ return branchTrace.pins[0].pinId === sharedPin.pinId ? candidateFromShared2 : candidateFromShared2.reverse();
102254
+ }
102228
102255
  const donorDeparture = donorPath[1][donorDepartureAxis] - donorPath[0][donorDepartureAxis];
102229
102256
  const branchDeparture = branchPath[1][branchDepartureAxis] - branchPath[0][branchDepartureAxis];
102230
102257
  if (Math.sign(donorDeparture) !== Math.sign(branchDeparture)) return null;
@@ -102546,6 +102573,48 @@ var getAlignedPerpendicularEndpointBusPath = ({
102546
102573
  ]);
102547
102574
  return branchStartsAtSharedPin ? candidate : candidate.reverse();
102548
102575
  };
102576
+ var traceCollidesWithObstacles = ({
102577
+ trace,
102578
+ obstacles
102579
+ }) => findFirstCollision(trace.tracePath, obstacles, {
102580
+ excludeRectsForSegment: (segmentIndex) => new Set(
102581
+ obstacles.filter(
102582
+ (obstacle) => obstacle.kind === "chip" && trace.pins.some(
102583
+ (pin) => obstacle.chipId === pin.chipId && [
102584
+ trace.tracePath[segmentIndex],
102585
+ trace.tracePath[segmentIndex + 1]
102586
+ ].some(
102587
+ (point6) => nearlyEqual(point6.x, pin.x) && nearlyEqual(point6.y, pin.y)
102588
+ )
102589
+ ) && segmentOverlapsRectBoundary(
102590
+ trace.tracePath[segmentIndex],
102591
+ trace.tracePath[segmentIndex + 1],
102592
+ obstacle
102593
+ )
102594
+ )
102595
+ )
102596
+ }) !== null;
102597
+ var getPathLengthInsideRect = ({
102598
+ path,
102599
+ rect
102600
+ }) => path.slice(1).reduce((length8, point6, index2) => {
102601
+ const previous = path[index2];
102602
+ if (nearlyEqual(previous.x, point6.x)) {
102603
+ if (previous.x < rect.minX || previous.x > rect.maxX) return length8;
102604
+ return length8 + Math.max(
102605
+ 0,
102606
+ Math.min(Math.max(previous.y, point6.y), rect.maxY) - Math.max(Math.min(previous.y, point6.y), rect.minY)
102607
+ );
102608
+ }
102609
+ if (nearlyEqual(previous.y, point6.y)) {
102610
+ if (previous.y < rect.minY || previous.y > rect.maxY) return length8;
102611
+ return length8 + Math.max(
102612
+ 0,
102613
+ Math.min(Math.max(previous.x, point6.x), rect.maxX) - Math.max(Math.min(previous.x, point6.x), rect.minX)
102614
+ );
102615
+ }
102616
+ return length8;
102617
+ }, 0);
102549
102618
  var candidateIsClear = ({
102550
102619
  candidateTrace,
102551
102620
  originalTrace,
@@ -102557,30 +102626,24 @@ var candidateIsClear = ({
102557
102626
  preserveExistingObstacleContact = false
102558
102627
  }) => {
102559
102628
  const obstacles = getObstacleRects(inputProblem);
102560
- if (!preserveExistingObstacleContact && isPathCollidingWithObstacles(candidateTrace.tracePath, obstacles))
102629
+ if (!preserveExistingObstacleContact && traceCollidesWithObstacles({ trace: candidateTrace, obstacles }))
102561
102630
  return false;
102562
- const pathLengthInsideRect = (path, rect) => path.slice(1).reduce((length8, point6, index2) => {
102563
- const previous = path[index2];
102564
- if (nearlyEqual(previous.x, point6.x)) {
102565
- if (previous.x < rect.minX || previous.x > rect.maxX) return length8;
102566
- return length8 + Math.max(
102567
- 0,
102568
- Math.min(Math.max(previous.y, point6.y), rect.maxY) - Math.max(Math.min(previous.y, point6.y), rect.minY)
102569
- );
102570
- }
102571
- if (nearlyEqual(previous.y, point6.y)) {
102572
- if (previous.y < rect.minY || previous.y > rect.maxY) return length8;
102573
- return length8 + Math.max(
102574
- 0,
102575
- Math.min(Math.max(previous.x, point6.x), rect.maxX) - Math.max(Math.min(previous.x, point6.x), rect.minX)
102576
- );
102577
- }
102578
- return length8;
102579
- }, 0);
102580
102631
  for (const obstacle of preserveExistingObstacleContact ? obstacles : []) {
102581
- if (!isPathCollidingWithObstacles(candidateTrace.tracePath, [obstacle]))
102632
+ if (!traceCollidesWithObstacles({
102633
+ trace: candidateTrace,
102634
+ obstacles: [obstacle]
102635
+ }))
102582
102636
  continue;
102583
- if (!isPathCollidingWithObstacles(originalTrace.tracePath, [obstacle]) || pathLengthInsideRect(candidateTrace.tracePath, obstacle) > pathLengthInsideRect(originalTrace.tracePath, obstacle) + 1e-6)
102637
+ if (!traceCollidesWithObstacles({
102638
+ trace: originalTrace,
102639
+ obstacles: [obstacle]
102640
+ }) || getPathLengthInsideRect({
102641
+ path: candidateTrace.tracePath,
102642
+ rect: obstacle
102643
+ }) > getPathLengthInsideRect({
102644
+ path: originalTrace.tracePath,
102645
+ rect: obstacle
102646
+ }) + 1e-6)
102584
102647
  return false;
102585
102648
  }
102586
102649
  const otherNetTraces = traces.filter(
@@ -118224,7 +118287,7 @@ function Group_getRoutingPhasePlans(group) {
118224
118287
  var package_default = {
118225
118288
  name: "@tscircuit/core",
118226
118289
  type: "module",
118227
- version: "0.0.2115",
118290
+ version: "0.0.2117",
118228
118291
  types: "dist/index.d.ts",
118229
118292
  main: "dist/index.js",
118230
118293
  module: "dist/index.js",
@@ -118262,7 +118325,7 @@ var package_default = {
118262
118325
  "@tscircuit/bus-lanes-solver": "https://jscdn.tscircuit.com/@tscircuit/bus-lanes-solver/0.0.21.tgz",
118263
118326
  "@tscircuit/cableprinter": "^0.0.6",
118264
118327
  "@tscircuit/capacity-autorouter": "^0.0.958",
118265
- "@tscircuit/checks": "^0.0.242",
118328
+ "@tscircuit/checks": "^0.0.243",
118266
118329
  "@tscircuit/circuit-json-util": "^0.0.119",
118267
118330
  "@tscircuit/common": "^0.0.20",
118268
118331
  "@tscircuit/copper-pour-solver": "^0.0.67",
@@ -118285,7 +118348,7 @@ var package_default = {
118285
118348
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
118286
118349
  "@tscircuit/props": "^0.0.697",
118287
118350
  "@tscircuit/schematic-match-adapt": "^0.0.18",
118288
- "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.228.tgz",
118351
+ "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.229.tgz",
118289
118352
  "@tscircuit/solver-utils": "^0.0.16",
118290
118353
  "@tscircuit/soup-util": "^0.0.41",
118291
118354
  "@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.2116",
4
+ "version": "0.0.2118",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "@tscircuit/bus-lanes-solver": "https://jscdn.tscircuit.com/@tscircuit/bus-lanes-solver/0.0.21.tgz",
40
40
  "@tscircuit/cableprinter": "^0.0.6",
41
41
  "@tscircuit/capacity-autorouter": "^0.0.958",
42
- "@tscircuit/checks": "^0.0.242",
42
+ "@tscircuit/checks": "^0.0.243",
43
43
  "@tscircuit/circuit-json-util": "^0.0.119",
44
44
  "@tscircuit/common": "^0.0.20",
45
45
  "@tscircuit/copper-pour-solver": "^0.0.67",
@@ -62,7 +62,7 @@
62
62
  "@tscircuit/ngspice-spice-engine": "^0.0.20",
63
63
  "@tscircuit/props": "^0.0.697",
64
64
  "@tscircuit/schematic-match-adapt": "^0.0.18",
65
- "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.228.tgz",
65
+ "@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.229.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",