@cardenelabs/cdl 0.64.0 → 0.65.0

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.js CHANGED
@@ -12555,6 +12555,25 @@ var ARROW_ENDPOINT_CENTER_TOL = 8;
12555
12555
  var ROW_GAP_VARIANCE_TOL = 40;
12556
12556
  var COLUMN_GAP_VARIANCE_TOL = 40;
12557
12557
  var LANE_BORDER_CLEARANCE_TOL = 2;
12558
+ function laneVerticalRange(lane, nodes) {
12559
+ const pinnedWithHeight = lane.posX !== void 0 && lane.posY !== void 0 && lane.posH !== void 0;
12560
+ if (!lane.contain && !pinnedWithHeight) return void 0;
12561
+ let top = lane.y;
12562
+ let bottom = lane.y + lane.height;
12563
+ for (const n of nodes) {
12564
+ if (n.lane !== lane.id) continue;
12565
+ top = Math.min(top, n.cy - n.h / 2);
12566
+ bottom = Math.max(bottom, n.cy + n.h / 2);
12567
+ }
12568
+ return { top, bottom };
12569
+ }
12570
+ function rectCrossesLaneBorder(rect, lane, range) {
12571
+ if (range !== void 0 && (rect.y + rect.h <= range.top || rect.y >= range.bottom)) return void 0;
12572
+ const crosses = (lineX) => rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
12573
+ if (crosses(lane.x)) return "left";
12574
+ if (crosses(lane.x + lane.width)) return "right";
12575
+ return void 0;
12576
+ }
12558
12577
  var NEAR_COLLISION_POLICY = {
12559
12578
  "node|node": 70,
12560
12579
  "node|edge-label": 32,
@@ -18146,6 +18165,7 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
18146
18165
  }
18147
18166
  }
18148
18167
  {
18168
+ const rangeByLane = new Map(laid.lanes.map((lane) => [lane.id, laneVerticalRange(lane, laid.nodes)]));
18149
18169
  for (const e of laid.edges) {
18150
18170
  if (!hasRenderedLabel(e)) continue;
18151
18171
  const fromNode = nodeById.get(e.from);
@@ -18154,21 +18174,14 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
18154
18174
  const allowedLanes = /* @__PURE__ */ new Set();
18155
18175
  if (fromNode) allowedLanes.add(fromNode.lane);
18156
18176
  if (toNode) allowedLanes.add(toNode.lane);
18157
- const boxW = computeLabelBoxW(e.label, e.sub);
18158
- const anchor = e.labelAnchor;
18159
- const boxLeftX = anchor === "start" ? 0 : anchor === "end" ? -boxW : -boxW / 2;
18160
- const bx = e.labelX + boxLeftX;
18161
- const bxRight = bx + boxW;
18177
+ const box = computeLabelBBoxWorld(e);
18162
18178
  for (const lane of laid.lanes) {
18163
18179
  if (allowedLanes.has(lane.id)) continue;
18164
- const laneLeft = lane.x;
18165
- const laneRight = lane.x + lane.width;
18166
- const crossesLeft = bx < laneLeft - LANE_BORDER_CLEARANCE_TOL && bxRight > laneLeft + LANE_BORDER_CLEARANCE_TOL;
18167
- const crossesRight = bx < laneRight - LANE_BORDER_CLEARANCE_TOL && bxRight > laneRight + LANE_BORDER_CLEARANCE_TOL;
18168
- if (crossesLeft || crossesRight) {
18180
+ const side = rectCrossesLaneBorder(box, lane, rangeByLane.get(lane.id));
18181
+ if (side !== void 0) {
18169
18182
  push(
18170
18183
  "lane-border-clearance",
18171
- `edge "${e.id}" label bbox (${bx.toFixed(0)}..${bxRight.toFixed(0)}) \u304C\u975E\u767A\u7740 lane "${lane.id}" (${laneLeft.toFixed(0)}..${laneRight.toFixed(0)}) \u306E ${crossesLeft ? "\u5DE6" : "\u53F3"} border \u3092\u8CAB\u901A`
18184
+ `edge "${e.id}" label bbox (${box.x.toFixed(0)}..${(box.x + box.w).toFixed(0)}) \u304C\u975E\u767A\u7740 lane "${lane.id}" (${lane.x.toFixed(0)}..${(lane.x + lane.width).toFixed(0)}) \u306E ${side === "left" ? "\u5DE6" : "\u53F3"} border \u3092\u8CAB\u901A`
18172
18185
  );
18173
18186
  break;
18174
18187
  }
@@ -18742,6 +18755,9 @@ var VERTICAL_DETOUR_CORNER = 14;
18742
18755
  function verticalCornerDir(from, to) {
18743
18756
  return to < from ? -1 : 1;
18744
18757
  }
18758
+ function cornerRadiusFor(\u534A\u5F84, ...\u8D70\u308A) {
18759
+ return Math.min(\u534A\u5F84, ...\u8D70\u308A.map((v) => Math.abs(v)));
18760
+ }
18745
18761
  var VERTICAL_DETOUR_EXIT = 45;
18746
18762
  function nearestBoxDistance(anchorX, dir, verticalTop, verticalBottom, boxes) {
18747
18763
  let nearest = Infinity;
@@ -18791,6 +18807,7 @@ function layoutEdges(diag, nodes, lanes = []) {
18791
18807
  const labelMarginExtra = (diag.viewport?.labelMargin ?? diag.viewport?.gap ?? DEFAULT_LABEL_MARGIN) - DEFAULT_LABEL_MARGIN;
18792
18808
  const nmap = new Map(nodes.map((n) => [n.id, n]));
18793
18809
  const lmap = new Map(lanes.map((l) => [l.id, l]));
18810
+ const laneRangeById = new Map(lanes.map((l) => [l.id, laneVerticalRange(l, nodes)]));
18794
18811
  const positionedEdges = [];
18795
18812
  const autoEdges = [];
18796
18813
  const selfLoopEdges = [];
@@ -19015,7 +19032,7 @@ function layoutEdges(diag, nodes, lanes = []) {
19015
19032
  nodes.filter((n) => n.id === c.from || n.id === c.to).map((n) => n.lane)
19016
19033
  );
19017
19034
  return lanes.some(
19018
- (l) => !endpointLanes.has(l.id) && (crossesVerticalLine(pill, l.x) || crossesVerticalLine(pill, l.x + l.width))
19035
+ (l) => !endpointLanes.has(l.id) && rectCrossesLaneBorder(pill, l, laneRangeById.get(l.id)) !== void 0
19019
19036
  );
19020
19037
  };
19021
19038
  const assignDetourSides = () => {
@@ -19235,7 +19252,7 @@ function layoutEdges(diag, nodes, lanes = []) {
19235
19252
  );
19236
19253
  const crossesLaneBorder = lanes.some((l) => {
19237
19254
  if (endpointLanes.has(l.id)) return false;
19238
- return crossesVerticalLine(alt, l.x) || crossesVerticalLine(alt, l.x + l.width);
19255
+ return rectCrossesLaneBorder(alt, l, laneRangeById.get(l.id)) !== void 0;
19239
19256
  });
19240
19257
  if (crossesLaneBorder) continue;
19241
19258
  r.baseLabelX = r.labelAltX;
@@ -19526,9 +19543,6 @@ function segmentsBBox2(segs) {
19526
19543
  }
19527
19544
  return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
19528
19545
  }
19529
- function crossesVerticalLine(rect, lineX) {
19530
- return rect.x < lineX - LANE_BORDER_CLEARANCE_TOL && rect.x + rect.w > lineX + LANE_BORDER_CLEARANCE_TOL;
19531
- }
19532
19546
  function distributeBySides(list) {
19533
19547
  const from = list[0].from;
19534
19548
  const tol = 20;
@@ -19751,6 +19765,7 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
19751
19765
  iter++;
19752
19766
  }
19753
19767
  }
19768
+ const lCorner = cornerRadiusFor(corner, (B.y - A.y) / 2, midX2 - A.x, B.x - midX2);
19754
19769
  let verticalMidY = (A.y + B.y) / 2;
19755
19770
  if (labelHalfW > 0) {
19756
19771
  const labelBoxH = 36;
@@ -19788,10 +19803,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
19788
19803
  }
19789
19804
  }
19790
19805
  if (edge?.overlay) {
19791
- const exitEndX = midX2 - xDir * corner;
19792
- const enterStartX = midX2 + xDir * corner;
19793
- const midStartY = A.y + yDir * corner;
19794
- const midEndY = B.y - yDir * corner;
19806
+ const exitEndX = midX2 - xDir * lCorner;
19807
+ const enterStartX = midX2 + xDir * lCorner;
19808
+ const midStartY = A.y + yDir * lCorner;
19809
+ const midEndY = B.y - yDir * lCorner;
19795
19810
  const segments = [
19796
19811
  { len: Math.abs(exitEndX - A.x), midXVal: (A.x + exitEndX) / 2, midYVal: A.y },
19797
19812
  { len: Math.abs(midEndY - midStartY), midXVal: midX2, midYVal: (midStartY + midEndY) / 2 },
@@ -19800,10 +19815,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
19800
19815
  const longest = segments.reduce((a, b) => b.len > a.len ? b : a);
19801
19816
  return {
19802
19817
  d: `M ${A.x} ${A.y}
19803
- L ${midX2 - xDir * corner} ${A.y}
19804
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
19805
- L ${midX2} ${B.y - yDir * corner}
19806
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
19818
+ L ${midX2 - xDir * lCorner} ${A.y}
19819
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
19820
+ L ${midX2} ${B.y - yDir * lCorner}
19821
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
19807
19822
  L ${B.x} ${B.y}`,
19808
19823
  labelX: longest.midXVal,
19809
19824
  labelY: longest.midYVal,
@@ -19812,10 +19827,10 @@ function routePath(from, to, fromSide, toSide, obstacles = [], detourSide, _from
19812
19827
  }
19813
19828
  return {
19814
19829
  d: `M ${A.x} ${A.y}
19815
- L ${midX2 - xDir * corner} ${A.y}
19816
- Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * corner}
19817
- L ${midX2} ${B.y - yDir * corner}
19818
- Q ${midX2} ${B.y}, ${midX2 + xDir * corner} ${B.y}
19830
+ L ${midX2 - xDir * lCorner} ${A.y}
19831
+ Q ${midX2} ${A.y}, ${midX2} ${A.y + yDir * lCorner}
19832
+ L ${midX2} ${B.y - yDir * lCorner}
19833
+ Q ${midX2} ${B.y}, ${midX2 + xDir * lCorner} ${B.y}
19819
19834
  L ${B.x} ${B.y}`,
19820
19835
  labelX: midX2,
19821
19836
  labelY: verticalMidY,