@cardenelabs/cdl 0.52.0 → 0.53.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
@@ -20530,6 +20530,87 @@ function requiredRowsWidth(rows, kind) {
20530
20530
  return Math.ceil(kind === "storage" ? storage : generic);
20531
20531
  }
20532
20532
 
20533
+ // src/layout/head-label.ts
20534
+ var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
20535
+ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
20536
+ var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
20537
+ var \u7BB1\u306E\u9AD8\u3055 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
20538
+ var BASELINE_RATIO = 0.8;
20539
+ var \u4E21\u7AEF\u306E\u5B57\u306E\u9593 = \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 * 2;
20540
+ function \u7AEF\u306E\u5B57\u306B\u8981\u308B\u7DDA\u306E\u9577\u3055(edge) {
20541
+ const \u4E00\u3064\u5206 = \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 + \u7BB1\u306E\u9AD8\u3055;
20542
+ const \u6570 = [edge.headLabel, edge.tailLabel].filter((t) => t?.trim()).length;
20543
+ if (\u6570 === 0) return 0;
20544
+ if (\u6570 === 1) return \u4E00\u3064\u5206;
20545
+ return \u4E00\u3064\u5206 * 2 + \u4E21\u7AEF\u306E\u5B57\u306E\u9593;
20546
+ }
20547
+ function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
20548
+ for (const p of \u5019\u88DC) {
20549
+ if (!p) continue;
20550
+ const dx = end.x - p.x;
20551
+ const dy = end.y - p.y;
20552
+ const len = Math.hypot(dx, dy);
20553
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
20554
+ }
20555
+ return null;
20556
+ }
20557
+ function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
20558
+ const segs = extractPathSegments(d);
20559
+ if (segs.length === 0) return null;
20560
+ if (\u7AEF === "head") {
20561
+ const last = segs[segs.length - 1];
20562
+ const end2 = { x: last.x2, y: last.y2 };
20563
+ const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
20564
+ return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
20565
+ }
20566
+ const first = segs[0];
20567
+ const end = { x: first.x1, y: first.y1 };
20568
+ const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
20569
+ return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
20570
+ }
20571
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
20572
+ const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
20573
+ if (!text) return null;
20574
+ const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
20575
+ if (!\u5411\u304D) return null;
20576
+ const { end, ux, uy } = \u5411\u304D;
20577
+ const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
20578
+ const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
20579
+ const w = measureTextWidth(text, {
20580
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
20581
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
20582
+ fontFamily: "mono"
20583
+ });
20584
+ const h = \u7BB1\u306E\u9AD8\u3055;
20585
+ const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
20586
+ let anchor;
20587
+ let box;
20588
+ if (Math.abs(ux) >= Math.abs(uy)) {
20589
+ const \u53F3\u3078\u9032\u3080 = ux > 0;
20590
+ const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
20591
+ anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
20592
+ box = {
20593
+ x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
20594
+ y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
20595
+ w,
20596
+ h
20597
+ };
20598
+ } else {
20599
+ const \u4E0B\u3078\u9032\u3080 = uy > 0;
20600
+ const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
20601
+ anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
20602
+ box = {
20603
+ x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
20604
+ y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
20605
+ w,
20606
+ h
20607
+ };
20608
+ }
20609
+ const x = anchor === "start" ? box.x : box.x + box.w;
20610
+ const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
20611
+ return { x, y, anchor, box };
20612
+ }
20613
+
20533
20614
  // src/layout/nodes.ts
20534
20615
  function autoStorageHeight(n, defaultH) {
20535
20616
  if (n.kind !== "storage") return n.h ?? defaultH;
@@ -20551,7 +20632,7 @@ function autoRowsWidth(n, defaultW) {
20551
20632
  const required = requiredRowsWidth(n.rows, n.kind);
20552
20633
  return Math.max(defaultW, required);
20553
20634
  }
20554
- function \u7BB1\u306E\u9AD8\u3055(n, \u65E2\u5B9Ah) {
20635
+ function \u7BB1\u306E\u9AD8\u30552(n, \u65E2\u5B9Ah) {
20555
20636
  if (n.h != null) return n.h;
20556
20637
  if (n.kind === "storage") return autoStorageHeight(n, \u65E2\u5B9Ah);
20557
20638
  return \u4E2D\u8EAB\u304B\u3089\u51FA\u3059\u9AD8\u3055(n.kind, \u65E2\u5B9Ah, {
@@ -20565,8 +20646,8 @@ function requiredStackGapForEdgeLabels(diag, allStacks) {
20565
20646
  const byId = new Map(diag.nodes.map((n) => [n.id, n]));
20566
20647
  const rankOf = new Map(allStacks.map((stack, i) => [stack, i]));
20567
20648
  const pillHsByGap = /* @__PURE__ */ new Map();
20649
+ let \u7AEF\u306E\u5B57\u306E\u8981\u6C42 = 0;
20568
20650
  for (const e of diag.edges) {
20569
- if (!hasRenderedLabel(e)) continue;
20570
20651
  const from = byId.get(e.from);
20571
20652
  const to = byId.get(e.to);
20572
20653
  if (!from || !to) continue;
@@ -20575,10 +20656,12 @@ function requiredStackGapForEdgeLabels(diag, allStacks) {
20575
20656
  const toRank = rankOf.get(to.stack);
20576
20657
  if (fromRank === void 0 || toRank === void 0) continue;
20577
20658
  if (Math.abs(fromRank - toRank) !== 1) continue;
20659
+ \u7AEF\u306E\u5B57\u306E\u8981\u6C42 = Math.max(\u7AEF\u306E\u5B57\u306E\u8981\u6C42, \u7AEF\u306E\u5B57\u306B\u8981\u308B\u7DDA\u306E\u9577\u3055(e));
20660
+ if (!hasRenderedLabel(e)) continue;
20578
20661
  const key = `${from.lane}::${Math.min(fromRank, toRank)}`;
20579
20662
  pillHsByGap.set(key, [...pillHsByGap.get(key) ?? [], labelPillH(e.sub)]);
20580
20663
  }
20581
- let required = 0;
20664
+ let required = \u7AEF\u306E\u5B57\u306E\u8981\u6C42;
20582
20665
  for (const pillHs of pillHsByGap.values()) {
20583
20666
  required = Math.max(required, requiredVerticalLabelGap(pillHs));
20584
20667
  }
@@ -20590,7 +20673,7 @@ function layoutNodes(diag, lanes) {
20590
20673
  const rowH = /* @__PURE__ */ new Map();
20591
20674
  for (const stack of allStacks) {
20592
20675
  const nodesAtStack = diag.nodes.filter((n) => n.stack === stack);
20593
- const h = Math.max(...nodesAtStack.map((n) => \u7BB1\u306E\u9AD8\u3055(n, NODE_SIZE[n.kind].h)));
20676
+ const h = Math.max(...nodesAtStack.map((n) => \u7BB1\u306E\u9AD8\u30552(n, NODE_SIZE[n.kind].h)));
20594
20677
  rowH.set(stack, h);
20595
20678
  }
20596
20679
  const rowCy = /* @__PURE__ */ new Map();
@@ -20644,7 +20727,7 @@ function layoutNodes(diag, lanes) {
20644
20727
  const \u6BB5\u306E\u82AF = rowCy.get(n.stack);
20645
20728
  const \u6BB5\u306E\u9AD8\u3055 = rowH.get(n.stack);
20646
20729
  const \u81EA\u524D\u306E\u9AD8\u3055 = n.rowMarks !== void 0;
20647
- const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\u3055(n, size.h) : \u6BB5\u306E\u9AD8\u3055);
20730
+ const h = n.h ?? (\u81EA\u524D\u306E\u9AD8\u3055 ? \u7BB1\u306E\u9AD8\u30552(n, size.h) : \u6BB5\u306E\u9AD8\u3055);
20648
20731
  const cy = \u6BB5\u306E\u82AF;
20649
20732
  const w = autoRowsWidth(n, size.w);
20650
20733
  out.push({
@@ -22933,79 +23016,6 @@ function \u7B49\u5E45\u306E\u5B57(text, fontSize) {
22933
23016
  });
22934
23017
  return out;
22935
23018
  }
22936
-
22937
- // src/layout/head-label.ts
22938
- var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
22939
- var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
22940
- var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
22941
- var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
22942
- var BASELINE_RATIO = 0.8;
22943
- function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
22944
- for (const p of \u5019\u88DC) {
22945
- if (!p) continue;
22946
- const dx = end.x - p.x;
22947
- const dy = end.y - p.y;
22948
- const len = Math.hypot(dx, dy);
22949
- if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
22950
- }
22951
- return null;
22952
- }
22953
- function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
22954
- const segs = extractPathSegments(d);
22955
- if (segs.length === 0) return null;
22956
- if (\u7AEF === "head") {
22957
- const last = segs[segs.length - 1];
22958
- const end2 = { x: last.x2, y: last.y2 };
22959
- const \u5019\u88DC2 = segs.slice().reverse().flatMap((s) => [s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0, { x: s.x1, y: s.y1 }]);
22960
- return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
22961
- }
22962
- const first = segs[0];
22963
- const end = { x: first.x1, y: first.y1 };
22964
- const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
22965
- return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
22966
- }
22967
- function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
22968
- const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
22969
- if (!text) return null;
22970
- const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
22971
- if (!\u5411\u304D) return null;
22972
- const { end, ux, uy } = \u5411\u304D;
22973
- const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
22974
- const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
22975
- const w = measureTextWidth(text, {
22976
- fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
22977
- fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
22978
- fontFamily: "mono"
22979
- });
22980
- const h = \u7BB1\u306E\u9AD8\u30552;
22981
- const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
22982
- let anchor;
22983
- let box;
22984
- if (Math.abs(ux) >= Math.abs(uy)) {
22985
- const \u53F3\u3078\u9032\u3080 = ux > 0;
22986
- const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
22987
- anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
22988
- box = {
22989
- x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
22990
- y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
22991
- w,
22992
- h
22993
- };
22994
- } else {
22995
- const \u4E0B\u3078\u9032\u3080 = uy > 0;
22996
- const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
22997
- anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
22998
- box = {
22999
- x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
23000
- y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
23001
- w,
23002
- h
23003
- };
23004
- }
23005
- const x = anchor === "start" ? box.x : box.x + box.w;
23006
- const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
23007
- return { x, y, anchor, box };
23008
- }
23009
23019
  function defaultEdgeWidth(active) {
23010
23020
  return active ? 2.5 : 1.25;
23011
23021
  }