@cardenelabs/cdl 0.21.0 → 0.21.1

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/react.cjs CHANGED
@@ -1756,8 +1756,12 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
1756
1756
  for (const { p } of ordered) {
1757
1757
  const axis = p.axis;
1758
1758
  if (!pathShiftIsSafe(e.id, axis, p.sign, amount)) continue;
1759
+ const \u52D5\u304B\u3057\u305F\u5F8C = measurePathLabelGapSegs(
1760
+ simulateShiftedSegments(e, axis === "x" ? p.sign * amount : 0, axis === "y" ? p.sign * amount : 0),
1761
+ label
1762
+ );
1759
1763
  out.push({ target: { kind: "edge-path", id: e.id }, axis, sign: p.sign, amount });
1760
- \u7DDA\u3092\u52D5\u304B\u305B\u305F = true;
1764
+ \u7DDA\u3092\u52D5\u304B\u305B\u305F = \u52D5\u304B\u3057\u305F\u5F8C > gap;
1761
1765
  break;
1762
1766
  }
1763
1767
  if (!\u7DDA\u3092\u52D5\u304B\u305B\u305F) {
@@ -1780,16 +1784,49 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
1780
1784
  if (\u8FD1\u3044\u70B9) {
1781
1785
  const dx = \u82AF.x - \u8FD1\u3044\u70B9.x;
1782
1786
  const dy = \u82AF.y - \u8FD1\u3044\u70B9.y;
1783
- const axis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
1784
- const \u5411\u304D = axis === "x" ? dx : dy;
1785
- const sign = \u5411\u304D >= 0 ? 1 : -1;
1786
- out.push({
1787
- target: { kind: "label", id: label.id },
1788
- axis,
1789
- sign,
1790
- amount: pathLabelClearance - gap + NEAR_MISS_MARGIN,
1791
- chain: false
1787
+ const \u91CF = pathLabelClearance - gap + NEAR_MISS_MARGIN;
1788
+ const \u5019\u88DC = Math.abs(dx) >= Math.abs(dy) ? [
1789
+ { axis: "x", sign: dx >= 0 ? 1 : -1 },
1790
+ { axis: "y", sign: dy >= 0 ? 1 : -1 }
1791
+ ] : [
1792
+ { axis: "y", sign: dy >= 0 ? 1 : -1 },
1793
+ { axis: "x", sign: dx >= 0 ? 1 : -1 }
1794
+ ];
1795
+ const \u52D5\u304B\u3057\u305F\u7BB1 = (axis, sign) => ({
1796
+ ...label,
1797
+ x: label.x + (axis === "x" ? sign * \u91CF : 0),
1798
+ y: label.y + (axis === "y" ? sign * \u91CF : 0)
1792
1799
  });
1800
+ const \u7DDA\u3054\u3068\u306E\u8DDD\u96E2 = (\u7BB1) => {
1801
+ const \u51FA = /* @__PURE__ */ new Map();
1802
+ for (const \u4ED6 of edges) {
1803
+ if (\u4ED6.id === label.id) continue;
1804
+ const segs2 = segmentsExcludingOwnPath(shiftedSegments(\u4ED6.id, \u4ED6.d), ownSegsOf(label.id));
1805
+ if (segs2.length === 0) continue;
1806
+ \u51FA.set(\u4ED6.id, measurePathLabelGapSegs(segs2, \u7BB1));
1807
+ }
1808
+ return \u51FA;
1809
+ };
1810
+ const \u3044\u307E\u306E\u8DDD\u96E2 = \u7DDA\u3054\u3068\u306E\u8DDD\u96E2(label);
1811
+ const \u60AA\u304F\u3059\u308B = (\u7BB1) => {
1812
+ const \u5F8C = \u7DDA\u3054\u3068\u306E\u8DDD\u96E2(\u7BB1);
1813
+ for (const [id, \u524D\u306E\u5024] of \u3044\u307E\u306E\u8DDD\u96E2) {
1814
+ const \u5F8C\u306E\u5024 = \u5F8C.get(id) ?? Infinity;
1815
+ if (\u5F8C\u306E\u5024 < Math.min(\u524D\u306E\u5024, pathLabelClearance)) return true;
1816
+ }
1817
+ return false;
1818
+ };
1819
+ for (const \u5019 of \u5019\u88DC) {
1820
+ if (\u60AA\u304F\u3059\u308B(\u52D5\u304B\u3057\u305F\u7BB1(\u5019.axis, \u5019.sign))) continue;
1821
+ out.push({
1822
+ target: { kind: "label", id: label.id },
1823
+ axis: \u5019.axis,
1824
+ sign: \u5019.sign,
1825
+ amount: \u91CF,
1826
+ chain: false
1827
+ });
1828
+ break;
1829
+ }
1793
1830
  }
1794
1831
  }
1795
1832
  }