@cardenelabs/cdl 0.49.0 → 0.51.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/react.cjs CHANGED
@@ -2776,10 +2776,10 @@ function \u66F8\u8A18\u7D20\u306B\u5206\u3051\u308B(text) {
2776
2776
  if (typeof \u533A\u5207\u308A !== "function") return [...text];
2777
2777
  return [...new \u533A\u5207\u308A(void 0, { granularity: "grapheme" }).segment(text)].map((g) => g.segment);
2778
2778
  }
2779
- function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30552) {
2779
+ function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30553) {
2780
2780
  const \u5019\u88DC = \u884C.filter((r, i) => i === 0 || r.text.trim() !== "");
2781
2781
  if (\u5019\u88DC.length === 0) return [];
2782
- const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30552 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2782
+ const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30553 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2783
2783
  const \u9AD8\u3055 = (rs) => rs.reduce((a, r) => a + r.fontSize * \u884C\u9001\u308A\u306E\u6BD4, 0);
2784
2784
  const \u6B8B\u3059 = [...\u5019\u88DC];
2785
2785
  while (\u6B8B\u3059.length > 1 && \u9AD8\u3055(\u6B8B\u3059) > \u4F7F\u3048\u308B\u9AD8\u3055) \u6B8B\u3059.pop();
@@ -3834,7 +3834,7 @@ function \u30D9\u30B8\u30A8\u306E\u7D2F\u7A4D\u5272\u5408(\u70B9, \u5236\u5FA1\u
3834
3834
  function \u7BB1\u306E\u6587\u5B57({
3835
3835
  \u884C,
3836
3836
  x,
3837
- \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30552,
3837
+ \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30553,
3838
3838
  fill,
3839
3839
  \u540D\u524D\u306E\u592A\u3055
3840
3840
  }) {
@@ -3843,7 +3843,7 @@ function \u7BB1\u306E\u6587\u5B57({
3843
3843
  {
3844
3844
  "data-cdl-role": r.\u5F79\u5272 === "subtitle" ? "tree-node-subtitle" : void 0,
3845
3845
  x,
3846
- y: \u7BB1\u306E\u9AD8\u30552 / 2 + r.dy,
3846
+ y: \u7BB1\u306E\u9AD8\u30553 / 2 + r.dy,
3847
3847
  fontSize: r.fontSize,
3848
3848
  fontWeight: r.\u5F79\u5272 === "title" ? \u540D\u524D\u306E\u592A\u3055 : 500,
3849
3849
  textAnchor: "middle",
@@ -10403,6 +10403,84 @@ function edgeHeadPaint(head, fill, color) {
10403
10403
  }
10404
10404
  return { fill: color, stroke: "none" };
10405
10405
  }
10406
+ var \u89D2\u62EC\u5F27\u306E\u9699\u9593 = 0.08;
10407
+ function \u7B49\u5E45\u306E\u5B57(text, fontSize) {
10408
+ if (typeof text !== "string" || !text.includes("[]")) return text;
10409
+ const \u584A = text.split("[]");
10410
+ const out = [];
10411
+ \u584A.forEach((s, i) => {
10412
+ if (i > 0) out.push("[", react.createElement("tspan", { key: i, dx: fontSize * \u89D2\u62EC\u5F27\u306E\u9699\u9593 }, "]"));
10413
+ if (s !== "") out.push(s);
10414
+ });
10415
+ return out;
10416
+ }
10417
+
10418
+ // src/layout/head-label.ts
10419
+ var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
10420
+ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
10421
+ var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
10422
+ var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
10423
+ var BASELINE_RATIO = 0.8;
10424
+ function \u6700\u5F8C\u306E\u5411\u304D(d) {
10425
+ const segs = extractPathSegments(d);
10426
+ const last = segs[segs.length - 1];
10427
+ if (!last) return null;
10428
+ const end = { x: last.x2, y: last.y2 };
10429
+ for (let i = segs.length - 1; i >= 0; i--) {
10430
+ const s = segs[i];
10431
+ const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
10432
+ for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
10433
+ if (!p) continue;
10434
+ const dx = end.x - p.x;
10435
+ const dy = end.y - p.y;
10436
+ const len = Math.hypot(dx, dy);
10437
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
10438
+ }
10439
+ }
10440
+ return null;
10441
+ }
10442
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge) {
10443
+ const text = edge.headLabel?.trim();
10444
+ if (!text) return null;
10445
+ const \u5411\u304D = \u6700\u5F8C\u306E\u5411\u304D(edge.d);
10446
+ if (!\u5411\u304D) return null;
10447
+ const { end, ux, uy } = \u5411\u304D;
10448
+ const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10449
+ const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10450
+ const w = measureTextWidth(text, {
10451
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10452
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10453
+ fontFamily: "mono"
10454
+ });
10455
+ const h = \u7BB1\u306E\u9AD8\u30552;
10456
+ const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
10457
+ let anchor;
10458
+ let box;
10459
+ if (Math.abs(ux) >= Math.abs(uy)) {
10460
+ const \u53F3\u3078\u9032\u3080 = ux > 0;
10461
+ const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
10462
+ anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
10463
+ box = {
10464
+ x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
10465
+ y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
10466
+ w,
10467
+ h
10468
+ };
10469
+ } else {
10470
+ const \u4E0B\u3078\u9032\u3080 = uy > 0;
10471
+ const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
10472
+ anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
10473
+ box = {
10474
+ x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
10475
+ y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
10476
+ w,
10477
+ h
10478
+ };
10479
+ }
10480
+ const x = anchor === "start" ? box.x : box.x + box.w;
10481
+ const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
10482
+ return { x, y, anchor, box };
10483
+ }
10406
10484
  function defaultEdgeWidth(active) {
10407
10485
  return active ? 2.5 : 1.25;
10408
10486
  }
@@ -10658,13 +10736,40 @@ function CdlEdgeLabelView({
10658
10736
  fill: active ? color : "var(--cdl-text-dim, #5a6270)",
10659
10737
  opacity: labelTextOpacity("sub"),
10660
10738
  style: { fontFamily: fontFamilyAttr("sub") },
10661
- children: edge.sub
10739
+ children: \u7B49\u5E45\u306E\u5B57(edge.sub, EDGE_LABEL_TEXT.sub.fontSize)
10662
10740
  }
10663
10741
  )
10664
10742
  ]
10665
10743
  }
10666
10744
  );
10667
10745
  }
10746
+ function CdlEdgeHeadLabelView({
10747
+ edge,
10748
+ active
10749
+ }) {
10750
+ const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
10751
+ if (!\u7F6E\u304D\u5834\u6240) return null;
10752
+ const color = edgeColor(edge);
10753
+ return /* @__PURE__ */ jsxRuntime.jsx(
10754
+ "text",
10755
+ {
10756
+ "data-cdl-role": "edge-end-label",
10757
+ "data-cdl-edge-end-label-for": edge.id,
10758
+ x: \u7F6E\u304D\u5834\u6240.x,
10759
+ y: \u7F6E\u304D\u5834\u6240.y,
10760
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10761
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10762
+ textAnchor: \u7F6E\u304D\u5834\u6240.anchor,
10763
+ fill: active ? color : "var(--cdl-text-dim, #5a6270)",
10764
+ stroke: "var(--cdl-label-bg, #ffffff)",
10765
+ strokeWidth: 4,
10766
+ strokeLinejoin: "round",
10767
+ paintOrder: "stroke",
10768
+ style: { fontFamily: fontFamilyAttr("sub") },
10769
+ children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
10770
+ }
10771
+ );
10772
+ }
10668
10773
 
10669
10774
  // src/kinds/node-tone.ts
10670
10775
  function nodeAccent(node, fallback) {
@@ -10738,7 +10843,7 @@ function ActorNode({ node, active, value }) {
10738
10843
  textAnchor: "end",
10739
10844
  fill: "var(--cdl-text, #1a1f2a)",
10740
10845
  style: { fontFamily: "'JetBrains Mono', monospace" },
10741
- children: value
10846
+ children: \u7B49\u5E45\u306E\u5B57(value, 42)
10742
10847
  }
10743
10848
  )
10744
10849
  ] });
@@ -10911,7 +11016,7 @@ function SequenceBoardNode({
10911
11016
  textAnchor: "middle",
10912
11017
  fill: "var(--cdl-text, #1a1f2a)",
10913
11018
  style: { fontFamily: "'JetBrains Mono', monospace" },
10914
- children: a.name
11019
+ children: \u7B49\u5E45\u306E\u5B57(a.name, SEQ_NAME)
10915
11020
  }
10916
11021
  ),
10917
11022
  a.subtitle && /* @__PURE__ */ jsxRuntime.jsx(
@@ -11101,7 +11206,7 @@ function EventNode({
11101
11206
  fill: "var(--cdl-text, #1a1f2a)",
11102
11207
  textAnchor: \u540D\u524D.anchor,
11103
11208
  style: { fontFamily: "'JetBrains Mono', monospace" },
11104
- children: node.title
11209
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11105
11210
  }
11106
11211
  ),
11107
11212
  node.subtitle && /* @__PURE__ */ jsxRuntime.jsx(
@@ -11112,7 +11217,7 @@ function EventNode({
11112
11217
  fontSize: 21,
11113
11218
  fill: "var(--cdl-text-dim, #5a6270)",
11114
11219
  style: { fontFamily: "'JetBrains Mono', monospace" },
11115
- children: node.subtitle
11220
+ children: \u7B49\u5E45\u306E\u5B57(node.subtitle, 21)
11116
11221
  }
11117
11222
  )
11118
11223
  ] })
@@ -11161,7 +11266,7 @@ function FunctionNode({ node, active }) {
11161
11266
  fill: "var(--cdl-text, #1a1f2a)",
11162
11267
  textAnchor: \u540D\u524D.anchor,
11163
11268
  style: { fontFamily: "'JetBrains Mono', monospace" },
11164
- children: node.title
11269
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11165
11270
  }
11166
11271
  ),
11167
11272
  node.subtitle && /* @__PURE__ */ jsxRuntime.jsx("text", { x: 26, y: 126 - \u305A\u3089\u3057, fontSize: 20, fill: "var(--cdl-text-dim, #5a6270)", children: node.subtitle })
@@ -11274,7 +11379,7 @@ function StorageNode({
11274
11379
  fill: "var(--cdl-text, #1a1f2a)",
11275
11380
  textAnchor: \u540D\u524D.anchor,
11276
11381
  style: { fontFamily: "'JetBrains Mono', monospace" },
11277
- children: node.title
11382
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11278
11383
  }
11279
11384
  ),
11280
11385
  rows.length > 0 && !\u5370\u3067\u5206\u3051\u308B && /* @__PURE__ */ jsxRuntime.jsx(
@@ -11335,7 +11440,7 @@ function StorageNode({
11335
11440
  fontWeight: \u5370\u3067\u5206\u3051\u308B ? 500 : 600,
11336
11441
  fill: "var(--cdl-text, #1a1f2a)",
11337
11442
  style: { fontFamily: "'JetBrains Mono', monospace" },
11338
- children: s.left
11443
+ children: \u7B49\u5E45\u306E\u5B57(s.left, 26)
11339
11444
  }
11340
11445
  ),
11341
11446
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -11349,7 +11454,7 @@ function StorageNode({
11349
11454
  textAnchor: \u5370\u3067\u5206\u3051\u308B ? "end" : "start",
11350
11455
  fill: \u5370\u3067\u5206\u3051\u308B ? "var(--cdl-text-dim, #5a6270)" : highlightRows ? accent : "var(--cdl-text, #1a1f2a)",
11351
11456
  style: { fontFamily: "'JetBrains Mono', monospace" },
11352
- children: s.right
11457
+ children: \u7B49\u5E45\u306E\u5B57(s.right, \u5370\u3067\u5206\u3051\u308B ? ROW_TYPE_FONT : 26)
11353
11458
  }
11354
11459
  )
11355
11460
  ] }, idx);
@@ -11623,8 +11728,8 @@ function GenericNode({
11623
11728
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: style.icon, fill: style.eyebrowColor, opacity: 0.7, transform: "scale(1)" })
11624
11729
  ] }),
11625
11730
  node.eyebrow && /* @__PURE__ */ jsxRuntime.jsx("text", { x: textX, y: eyebrowY, fontSize: 17, fontWeight: 700, letterSpacing: 1.5, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : style.eyebrowColor, textAnchor, dominantBaseline, children: node.eyebrow }),
11626
- /* @__PURE__ */ jsxRuntime.jsx("text", { "data-cdl-role": "node-label", x: textX, y: titleY, fontSize: 20, fontWeight: 700, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text, #1a1f2a)", textAnchor, dominantBaseline, style: node.kind === "function" || node.kind === "api" ? { fontFamily: "'JetBrains Mono', monospace" } : void 0, children: node.title }),
11627
- node.subtitle && /* @__PURE__ */ jsxRuntime.jsx("text", { x: textX, y: subtitleY, fontSize: 17, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text-dim, #5a6270)", textAnchor, dominantBaseline, style: { fontFamily: "'JetBrains Mono', monospace" }, children: node.subtitle }),
11731
+ /* @__PURE__ */ jsxRuntime.jsx("text", { "data-cdl-role": "node-label", x: textX, y: titleY, fontSize: 20, fontWeight: 700, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text, #1a1f2a)", textAnchor, dominantBaseline, style: node.kind === "function" || node.kind === "api" ? { fontFamily: "'JetBrains Mono', monospace" } : void 0, children: node.kind === "function" || node.kind === "api" ? \u7B49\u5E45\u306E\u5B57(node.title, 20) : node.title }),
11732
+ node.subtitle && /* @__PURE__ */ jsxRuntime.jsx("text", { x: textX, y: subtitleY, fontSize: 17, fill: paint.onSolid ? "var(--cdl-node-fill, #ffffff)" : "var(--cdl-text-dim, #5a6270)", textAnchor, dominantBaseline, style: { fontFamily: "'JetBrains Mono', monospace" }, children: \u7B49\u5E45\u306E\u5B57(node.subtitle, 17) }),
11628
11733
  resolvedValue && /* @__PURE__ */ jsxRuntime.jsx(
11629
11734
  "text",
11630
11735
  {
@@ -11635,7 +11740,7 @@ function GenericNode({
11635
11740
  textAnchor: "end",
11636
11741
  fill: "var(--cdl-text, #1a1f2a)",
11637
11742
  style: { fontFamily: "'JetBrains Mono', monospace" },
11638
- children: resolvedValue
11743
+ children: \u7B49\u5E45\u306E\u5B57(resolvedValue, 32)
11639
11744
  }
11640
11745
  ),
11641
11746
  node.rows && node.rows.length > 0 && (() => {
@@ -11660,7 +11765,7 @@ function GenericNode({
11660
11765
  textAnchor: "start",
11661
11766
  fill: "var(--cdl-text, #1a1f2a)",
11662
11767
  style: { fontFamily: "'JetBrains Mono', monospace" },
11663
- children: s.right
11768
+ children: \u7B49\u5E45\u306E\u5B57(s.right, 21)
11664
11769
  }
11665
11770
  )
11666
11771
  ] }, i)) });
@@ -18946,6 +19051,14 @@ function CdlStage({
18946
19051
  },
18947
19052
  `label-${edge.id}`
18948
19053
  )),
19054
+ laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).map((edge) => /* @__PURE__ */ jsxRuntime.jsx(
19055
+ CdlEdgeHeadLabelView,
19056
+ {
19057
+ edge,
19058
+ active: activeSet.has(edge.id)
19059
+ },
19060
+ `head-label-${edge.id}`
19061
+ )),
18949
19062
  debug && /* @__PURE__ */ jsxRuntime.jsxs("g", { pointerEvents: "none", children: [
18950
19063
  laid.bboxes.map((bbox, idx) => {
18951
19064
  const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";