calculate-packing 0.0.62 → 0.0.64

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
@@ -70,6 +70,11 @@ interface PackInput {
70
70
  minGap: number;
71
71
  packOrderStrategy: "largest_to_smallest";
72
72
  packPlacementStrategy: PackPlacementStrategy;
73
+ weightedConnections?: Array<{
74
+ padIds: string[];
75
+ weight: number;
76
+ ignoreWeakConnections?: boolean;
77
+ }>;
73
78
  disconnectedPackDirection?: "left" | "right" | "up" | "down" | "nearest_to_center";
74
79
  packFirst?: ComponentId[];
75
80
  }
@@ -393,6 +398,7 @@ declare class OutlineSegmentCandidatePointSolver extends BaseSolver$1 {
393
398
  x: number;
394
399
  y: number;
395
400
  }>;
401
+ weightedConnections?: PackInput["weightedConnections"];
396
402
  optimalPosition?: Point$2;
397
403
  irlsSolver?: MultiOffsetIrlsSolver;
398
404
  twoPhaseIrlsSolver?: TwoPhaseIrlsSolver;
@@ -413,6 +419,7 @@ declare class OutlineSegmentCandidatePointSolver extends BaseSolver$1 {
413
419
  x: number;
414
420
  y: number;
415
421
  }>;
422
+ weightedConnections?: PackInput["weightedConnections"];
416
423
  });
417
424
  getConstructorParams(): ConstructorParameters<typeof OutlineSegmentCandidatePointSolver>[0];
418
425
  _getOutlineBoundsWithMargin(params?: {
@@ -483,6 +490,7 @@ declare class SingleComponentPackSolver extends BaseSolver$1 {
483
490
  x: number;
484
491
  y: number;
485
492
  }>;
493
+ weightedConnections?: PackInput["weightedConnections"];
486
494
  currentPhase: Phase;
487
495
  outlines: Segment[][];
488
496
  queuedOutlineSegments: QueuedOutlineSegment[];
@@ -507,6 +515,7 @@ declare class SingleComponentPackSolver extends BaseSolver$1 {
507
515
  x: number;
508
516
  y: number;
509
517
  }>;
518
+ weightedConnections?: PackInput["weightedConnections"];
510
519
  });
511
520
  _setup(): void;
512
521
  _step(): void;
@@ -532,6 +541,11 @@ declare class SingleComponentPackSolver extends BaseSolver$1 {
532
541
  x: number;
533
542
  y: number;
534
543
  }[] | undefined;
544
+ weightedConnections: {
545
+ padIds: string[];
546
+ weight: number;
547
+ ignoreWeakConnections?: boolean;
548
+ }[] | undefined;
535
549
  };
536
550
  }
537
551
 
package/dist/index.js CHANGED
@@ -1007,6 +1007,16 @@ var TwoPhaseIrlsSolver = class extends BaseSolver {
1007
1007
  }
1008
1008
  };
1009
1009
 
1010
+ // lib/utils/isStrongConnection.ts
1011
+ function isStrongConnection(pad1Id, pad2Id, weightedConnections) {
1012
+ if (!weightedConnections || weightedConnections.length === 0) {
1013
+ return true;
1014
+ }
1015
+ return weightedConnections.some(
1016
+ (wc) => wc.padIds.includes(pad1Id) && wc.padIds.includes(pad2Id)
1017
+ );
1018
+ }
1019
+
1010
1020
  // lib/testing/createColorMapFromStrings.ts
1011
1021
  var createColorMapFromStrings = (strings) => {
1012
1022
  const colorMap = {};
@@ -1431,6 +1441,7 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
1431
1441
  viableBounds;
1432
1442
  globalBounds;
1433
1443
  boundaryOutline;
1444
+ weightedConnections;
1434
1445
  optimalPosition;
1435
1446
  irlsSolver;
1436
1447
  twoPhaseIrlsSolver;
@@ -1449,6 +1460,7 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
1449
1460
  this.obstacles = params.obstacles ?? [];
1450
1461
  this.globalBounds = params.globalBounds;
1451
1462
  this.boundaryOutline = params.boundaryOutline;
1463
+ this.weightedConnections = params.weightedConnections;
1452
1464
  }
1453
1465
  getConstructorParams() {
1454
1466
  return {
@@ -1461,7 +1473,8 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
1461
1473
  componentToPack: this.componentToPack,
1462
1474
  obstacles: this.obstacles,
1463
1475
  globalBounds: this.globalBounds,
1464
- boundaryOutline: this.boundaryOutline
1476
+ boundaryOutline: this.boundaryOutline,
1477
+ weightedConnections: this.weightedConnections
1465
1478
  };
1466
1479
  }
1467
1480
  _getOutlineBoundsWithMargin(params = {}) {
@@ -1652,6 +1665,13 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
1652
1665
  for (const packedComponent of this.packedComponents) {
1653
1666
  for (const packedPad of packedComponent.pads) {
1654
1667
  if (packedPad.networkId === pad.networkId) {
1668
+ if (!isStrongConnection(
1669
+ pad.padId,
1670
+ packedPad.padId,
1671
+ this.weightedConnections
1672
+ )) {
1673
+ continue;
1674
+ }
1655
1675
  targetPoints.push({
1656
1676
  ...packedPad.absoluteCenter,
1657
1677
  networkId: packedPad.networkId
@@ -1931,11 +1951,17 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver3 {
1931
1951
  for (const packedComponent of this.packedComponents) {
1932
1952
  for (const packedPad of packedComponent.pads) {
1933
1953
  if (packedPad.networkId === pad.networkId) {
1954
+ const isStrong = isStrongConnection(
1955
+ pad.padId,
1956
+ packedPad.padId,
1957
+ this.weightedConnections
1958
+ );
1934
1959
  graphics.lines.push({
1935
1960
  points: [padPos, packedPad.absoluteCenter],
1936
1961
  strokeColor: pad.networkId === "VCC" ? "#FF6B6B" : "#4ECDC4",
1937
- strokeDash: [2, 2],
1938
- label: `${pad.networkId} connection`
1962
+ // Solid line for strong connections, dashed for weak
1963
+ strokeDash: isStrong ? void 0 : "4 2",
1964
+ label: `${pad.networkId} ${isStrong ? "strong" : "weak"}`
1939
1965
  });
1940
1966
  }
1941
1967
  }
@@ -2044,9 +2070,18 @@ var getGraphicsFromPackOutput = (packOutput) => {
2044
2070
  );
2045
2071
  for (let i = 0; i < padsOnNet.length; i++) {
2046
2072
  for (let j = i + 1; j < padsOnNet.length; j++) {
2073
+ const pad1 = padsOnNet[i];
2074
+ const pad2 = padsOnNet[j];
2075
+ const isStrong = isStrongConnection(
2076
+ pad1.padId,
2077
+ pad2.padId,
2078
+ packOutput.weightedConnections
2079
+ );
2047
2080
  lines.push({
2048
- points: [padsOnNet[i].absoluteCenter, padsOnNet[j].absoluteCenter],
2049
- strokeColor: colorMap[netId]
2081
+ points: [pad1.absoluteCenter, pad2.absoluteCenter],
2082
+ strokeColor: colorMap[netId],
2083
+ // Dashed line for weak connections, solid for strong
2084
+ strokeDash: isStrong ? void 0 : "4 2"
2050
2085
  });
2051
2086
  }
2052
2087
  }
@@ -2105,6 +2140,7 @@ var SingleComponentPackSolver = class extends BaseSolver4 {
2105
2140
  minGap;
2106
2141
  obstacles;
2107
2142
  boundaryOutline;
2143
+ weightedConnections;
2108
2144
  // Phase management
2109
2145
  currentPhase = "outline";
2110
2146
  outlines = [];
@@ -2126,6 +2162,7 @@ var SingleComponentPackSolver = class extends BaseSolver4 {
2126
2162
  this.obstacles = params.obstacles ?? [];
2127
2163
  this.bounds = params.bounds;
2128
2164
  this.boundaryOutline = params.boundaryOutline;
2165
+ this.weightedConnections = params.weightedConnections;
2129
2166
  }
2130
2167
  _setup() {
2131
2168
  super._setup();
@@ -2389,7 +2426,8 @@ var SingleComponentPackSolver = class extends BaseSolver4 {
2389
2426
  componentToPack: this.componentToPack,
2390
2427
  obstacles: this.obstacles,
2391
2428
  globalBounds: this.bounds,
2392
- boundaryOutline: this.boundaryOutline
2429
+ boundaryOutline: this.boundaryOutline,
2430
+ weightedConnections: this.weightedConnections
2393
2431
  });
2394
2432
  this.activeSubSolver.setup();
2395
2433
  break;
@@ -2421,6 +2459,13 @@ var SingleComponentPackSolver = class extends BaseSolver4 {
2421
2459
  for (const packedComponent of this.packedComponents) {
2422
2460
  for (const packedPad of packedComponent.pads) {
2423
2461
  if (packedPad.networkId === pad.networkId) {
2462
+ if (!isStrongConnection(
2463
+ pad.padId,
2464
+ packedPad.padId,
2465
+ this.weightedConnections
2466
+ )) {
2467
+ continue;
2468
+ }
2424
2469
  const dx = pad.absoluteCenter.x - packedPad.absoluteCenter.x;
2425
2470
  const dy = pad.absoluteCenter.y - packedPad.absoluteCenter.y;
2426
2471
  const dist = Math.sqrt(dx * dx + dy * dy);
@@ -2622,7 +2667,8 @@ gap_distance=${candidate.gapDistance}`,
2622
2667
  minGap: this.minGap,
2623
2668
  obstacles: this.obstacles,
2624
2669
  bounds: this.bounds,
2625
- boundaryOutline: this.boundaryOutline
2670
+ boundaryOutline: this.boundaryOutline,
2671
+ weightedConnections: this.weightedConnections
2626
2672
  };
2627
2673
  }
2628
2674
  };
@@ -2749,7 +2795,8 @@ var PackSolver2 = class extends BaseSolver5 {
2749
2795
  minGap: this.packInput.minGap,
2750
2796
  obstacles,
2751
2797
  bounds: this.packInput.bounds,
2752
- boundaryOutline: this.packInput.boundaryOutline
2798
+ boundaryOutline: this.packInput.boundaryOutline,
2799
+ weightedConnections: this.packInput.weightedConnections
2753
2800
  });
2754
2801
  fallbackSolver.solve();
2755
2802
  const result = fallbackSolver.getResult();
@@ -2786,7 +2833,8 @@ var PackSolver2 = class extends BaseSolver5 {
2786
2833
  minGap: this.packInput.minGap,
2787
2834
  obstacles: this.packInput.obstacles ?? [],
2788
2835
  bounds: this.packInput.bounds,
2789
- boundaryOutline: this.packInput.boundaryOutline
2836
+ boundaryOutline: this.packInput.boundaryOutline,
2837
+ weightedConnections: this.packInput.weightedConnections
2790
2838
  });
2791
2839
  this.activeSubSolver.setup();
2792
2840
  }
@@ -2827,7 +2875,8 @@ var PackSolver2 = class extends BaseSolver5 {
2827
2875
  lines: [],
2828
2876
  rects: [],
2829
2877
  circles: [],
2830
- texts: []
2878
+ texts: [],
2879
+ arrows: []
2831
2880
  };
2832
2881
  if (this.packInput.obstacles && this.packInput.obstacles.length > 0) {
2833
2882
  for (const obstacle of this.packInput.obstacles) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "calculate-packing",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.62",
5
+ "version": "0.0.64",
6
6
  "description": "Calculate a packing layout with support for different strategy configurations",
7
7
  "scripts": {
8
8
  "start": "cosmos",
@@ -30,7 +30,7 @@
30
30
  "bun-match-svg": "^0.0.12",
31
31
  "circuit-json": "^0.0.309",
32
32
  "framer-motion": "^12.23.12",
33
- "graphics-debug": "^0.0.62",
33
+ "graphics-debug": "^0.0.70",
34
34
  "react": "^19.1.0",
35
35
  "react-cosmos": "^7.0.0",
36
36
  "react-cosmos-plugin-vite": "^7.0.0",