@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.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.cjs';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BoBEyCu-.cjs';
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'react';
2
- export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-C53-PeJZ.js';
2
+ export { q as CdlDiagramView, m as CdlDiagramViewProps } from './render-BoBEyCu-.js';
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useMemo, useEffect, useSyncExternalStore, useRef, useCallback, useState, useLayoutEffect, useId } from 'react';
1
+ import { useMemo, useEffect, useSyncExternalStore, useRef, useCallback, useState, useLayoutEffect, useId, createElement } from 'react';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
3
 
4
4
  // src/render.tsx
@@ -2774,10 +2774,10 @@ function \u66F8\u8A18\u7D20\u306B\u5206\u3051\u308B(text) {
2774
2774
  if (typeof \u533A\u5207\u308A !== "function") return [...text];
2775
2775
  return [...new \u533A\u5207\u308A(void 0, { granularity: "grapheme" }).segment(text)].map((g) => g.segment);
2776
2776
  }
2777
- function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30552) {
2777
+ function \u7BB1\u306B\u7A4D\u3080(\u884C, \u7BB1\u306E\u5E45, \u7BB1\u306E\u9AD8\u30553) {
2778
2778
  const \u5019\u88DC = \u884C.filter((r, i) => i === 0 || r.text.trim() !== "");
2779
2779
  if (\u5019\u88DC.length === 0) return [];
2780
- const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30552 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2780
+ const \u4F7F\u3048\u308B\u9AD8\u3055 = \u7BB1\u306E\u9AD8\u30553 - \u4E0A\u4E0B\u306E\u4F59\u767D * 2;
2781
2781
  const \u9AD8\u3055 = (rs) => rs.reduce((a, r) => a + r.fontSize * \u884C\u9001\u308A\u306E\u6BD4, 0);
2782
2782
  const \u6B8B\u3059 = [...\u5019\u88DC];
2783
2783
  while (\u6B8B\u3059.length > 1 && \u9AD8\u3055(\u6B8B\u3059) > \u4F7F\u3048\u308B\u9AD8\u3055) \u6B8B\u3059.pop();
@@ -3832,7 +3832,7 @@ function \u30D9\u30B8\u30A8\u306E\u7D2F\u7A4D\u5272\u5408(\u70B9, \u5236\u5FA1\u
3832
3832
  function \u7BB1\u306E\u6587\u5B57({
3833
3833
  \u884C,
3834
3834
  x,
3835
- \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30552,
3835
+ \u7BB1\u306E\u9AD8\u3055: \u7BB1\u306E\u9AD8\u30553,
3836
3836
  fill,
3837
3837
  \u540D\u524D\u306E\u592A\u3055
3838
3838
  }) {
@@ -3841,7 +3841,7 @@ function \u7BB1\u306E\u6587\u5B57({
3841
3841
  {
3842
3842
  "data-cdl-role": r.\u5F79\u5272 === "subtitle" ? "tree-node-subtitle" : void 0,
3843
3843
  x,
3844
- y: \u7BB1\u306E\u9AD8\u30552 / 2 + r.dy,
3844
+ y: \u7BB1\u306E\u9AD8\u30553 / 2 + r.dy,
3845
3845
  fontSize: r.fontSize,
3846
3846
  fontWeight: r.\u5F79\u5272 === "title" ? \u540D\u524D\u306E\u592A\u3055 : 500,
3847
3847
  textAnchor: "middle",
@@ -10401,6 +10401,84 @@ function edgeHeadPaint(head, fill, color) {
10401
10401
  }
10402
10402
  return { fill: color, stroke: "none" };
10403
10403
  }
10404
+ var \u89D2\u62EC\u5F27\u306E\u9699\u9593 = 0.08;
10405
+ function \u7B49\u5E45\u306E\u5B57(text, fontSize) {
10406
+ if (typeof text !== "string" || !text.includes("[]")) return text;
10407
+ const \u584A = text.split("[]");
10408
+ const out = [];
10409
+ \u584A.forEach((s, i) => {
10410
+ if (i > 0) out.push("[", createElement("tspan", { key: i, dx: fontSize * \u89D2\u62EC\u5F27\u306E\u9699\u9593 }, "]"));
10411
+ if (s !== "") out.push(s);
10412
+ });
10413
+ return out;
10414
+ }
10415
+
10416
+ // src/layout/head-label.ts
10417
+ var \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2 = 22;
10418
+ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
10419
+ var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
10420
+ var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
10421
+ var BASELINE_RATIO = 0.8;
10422
+ function \u6700\u5F8C\u306E\u5411\u304D(d) {
10423
+ const segs = extractPathSegments(d);
10424
+ const last = segs[segs.length - 1];
10425
+ if (!last) return null;
10426
+ const end = { x: last.x2, y: last.y2 };
10427
+ for (let i = segs.length - 1; i >= 0; i--) {
10428
+ const s = segs[i];
10429
+ const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
10430
+ for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
10431
+ if (!p) continue;
10432
+ const dx = end.x - p.x;
10433
+ const dy = end.y - p.y;
10434
+ const len = Math.hypot(dx, dy);
10435
+ if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
10436
+ }
10437
+ }
10438
+ return null;
10439
+ }
10440
+ function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge) {
10441
+ const text = edge.headLabel?.trim();
10442
+ if (!text) return null;
10443
+ const \u5411\u304D = \u6700\u5F8C\u306E\u5411\u304D(edge.d);
10444
+ if (!\u5411\u304D) return null;
10445
+ const { end, ux, uy } = \u5411\u304D;
10446
+ const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10447
+ const by = end.y - uy * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
10448
+ const w = measureTextWidth(text, {
10449
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10450
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10451
+ fontFamily: "mono"
10452
+ });
10453
+ const h = \u7BB1\u306E\u9AD8\u30552;
10454
+ const \u672D = hasRenderedLabel(edge) && edge.labelX !== void 0 && edge.labelY !== void 0 ? { x: edge.labelX, y: edge.labelY } : null;
10455
+ let anchor;
10456
+ let box;
10457
+ if (Math.abs(ux) >= Math.abs(uy)) {
10458
+ const \u53F3\u3078\u9032\u3080 = ux > 0;
10459
+ const \u4E0A\u306B\u7F6E\u304F = \u672D !== null && \u672D.y > by;
10460
+ anchor = \u53F3\u3078\u9032\u3080 ? "end" : "start";
10461
+ box = {
10462
+ x: \u53F3\u3078\u9032\u3080 ? bx - w : bx,
10463
+ y: \u4E0A\u306B\u7F6E\u304F ? by - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - h : by + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593,
10464
+ w,
10465
+ h
10466
+ };
10467
+ } else {
10468
+ const \u4E0B\u3078\u9032\u3080 = uy > 0;
10469
+ const \u53F3\u306B\u7F6E\u304F = \u672D !== null && \u672D.x < bx;
10470
+ anchor = \u53F3\u306B\u7F6E\u304F ? "start" : "end";
10471
+ box = {
10472
+ x: \u53F3\u306B\u7F6E\u304F ? bx + \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 : bx - \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 - w,
10473
+ y: \u4E0B\u3078\u9032\u3080 ? by - h : by,
10474
+ w,
10475
+ h
10476
+ };
10477
+ }
10478
+ const x = anchor === "start" ? box.x : box.x + box.w;
10479
+ const y = box.y + (h - \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055) / 2 + \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * BASELINE_RATIO;
10480
+ return { x, y, anchor, box };
10481
+ }
10404
10482
  function defaultEdgeWidth(active) {
10405
10483
  return active ? 2.5 : 1.25;
10406
10484
  }
@@ -10656,13 +10734,40 @@ function CdlEdgeLabelView({
10656
10734
  fill: active ? color : "var(--cdl-text-dim, #5a6270)",
10657
10735
  opacity: labelTextOpacity("sub"),
10658
10736
  style: { fontFamily: fontFamilyAttr("sub") },
10659
- children: edge.sub
10737
+ children: \u7B49\u5E45\u306E\u5B57(edge.sub, EDGE_LABEL_TEXT.sub.fontSize)
10660
10738
  }
10661
10739
  )
10662
10740
  ]
10663
10741
  }
10664
10742
  );
10665
10743
  }
10744
+ function CdlEdgeHeadLabelView({
10745
+ edge,
10746
+ active
10747
+ }) {
10748
+ const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
10749
+ if (!\u7F6E\u304D\u5834\u6240) return null;
10750
+ const color = edgeColor(edge);
10751
+ return /* @__PURE__ */ jsx(
10752
+ "text",
10753
+ {
10754
+ "data-cdl-role": "edge-end-label",
10755
+ "data-cdl-edge-end-label-for": edge.id,
10756
+ x: \u7F6E\u304D\u5834\u6240.x,
10757
+ y: \u7F6E\u304D\u5834\u6240.y,
10758
+ fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
10759
+ fontWeight: EDGE_LABEL_TEXT.sub.fontWeight,
10760
+ textAnchor: \u7F6E\u304D\u5834\u6240.anchor,
10761
+ fill: active ? color : "var(--cdl-text-dim, #5a6270)",
10762
+ stroke: "var(--cdl-label-bg, #ffffff)",
10763
+ strokeWidth: 4,
10764
+ strokeLinejoin: "round",
10765
+ paintOrder: "stroke",
10766
+ style: { fontFamily: fontFamilyAttr("sub") },
10767
+ children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
10768
+ }
10769
+ );
10770
+ }
10666
10771
 
10667
10772
  // src/kinds/node-tone.ts
10668
10773
  function nodeAccent(node, fallback) {
@@ -10736,7 +10841,7 @@ function ActorNode({ node, active, value }) {
10736
10841
  textAnchor: "end",
10737
10842
  fill: "var(--cdl-text, #1a1f2a)",
10738
10843
  style: { fontFamily: "'JetBrains Mono', monospace" },
10739
- children: value
10844
+ children: \u7B49\u5E45\u306E\u5B57(value, 42)
10740
10845
  }
10741
10846
  )
10742
10847
  ] });
@@ -10909,7 +11014,7 @@ function SequenceBoardNode({
10909
11014
  textAnchor: "middle",
10910
11015
  fill: "var(--cdl-text, #1a1f2a)",
10911
11016
  style: { fontFamily: "'JetBrains Mono', monospace" },
10912
- children: a.name
11017
+ children: \u7B49\u5E45\u306E\u5B57(a.name, SEQ_NAME)
10913
11018
  }
10914
11019
  ),
10915
11020
  a.subtitle && /* @__PURE__ */ jsx(
@@ -11099,7 +11204,7 @@ function EventNode({
11099
11204
  fill: "var(--cdl-text, #1a1f2a)",
11100
11205
  textAnchor: \u540D\u524D.anchor,
11101
11206
  style: { fontFamily: "'JetBrains Mono', monospace" },
11102
- children: node.title
11207
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11103
11208
  }
11104
11209
  ),
11105
11210
  node.subtitle && /* @__PURE__ */ jsx(
@@ -11110,7 +11215,7 @@ function EventNode({
11110
11215
  fontSize: 21,
11111
11216
  fill: "var(--cdl-text-dim, #5a6270)",
11112
11217
  style: { fontFamily: "'JetBrains Mono', monospace" },
11113
- children: node.subtitle
11218
+ children: \u7B49\u5E45\u306E\u5B57(node.subtitle, 21)
11114
11219
  }
11115
11220
  )
11116
11221
  ] })
@@ -11159,7 +11264,7 @@ function FunctionNode({ node, active }) {
11159
11264
  fill: "var(--cdl-text, #1a1f2a)",
11160
11265
  textAnchor: \u540D\u524D.anchor,
11161
11266
  style: { fontFamily: "'JetBrains Mono', monospace" },
11162
- children: node.title
11267
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11163
11268
  }
11164
11269
  ),
11165
11270
  node.subtitle && /* @__PURE__ */ jsx("text", { x: 26, y: 126 - \u305A\u3089\u3057, fontSize: 20, fill: "var(--cdl-text-dim, #5a6270)", children: node.subtitle })
@@ -11272,7 +11377,7 @@ function StorageNode({
11272
11377
  fill: "var(--cdl-text, #1a1f2a)",
11273
11378
  textAnchor: \u540D\u524D.anchor,
11274
11379
  style: { fontFamily: "'JetBrains Mono', monospace" },
11275
- children: node.title
11380
+ children: \u7B49\u5E45\u306E\u5B57(node.title, \u540D\u524D.size)
11276
11381
  }
11277
11382
  ),
11278
11383
  rows.length > 0 && !\u5370\u3067\u5206\u3051\u308B && /* @__PURE__ */ jsx(
@@ -11333,7 +11438,7 @@ function StorageNode({
11333
11438
  fontWeight: \u5370\u3067\u5206\u3051\u308B ? 500 : 600,
11334
11439
  fill: "var(--cdl-text, #1a1f2a)",
11335
11440
  style: { fontFamily: "'JetBrains Mono', monospace" },
11336
- children: s.left
11441
+ children: \u7B49\u5E45\u306E\u5B57(s.left, 26)
11337
11442
  }
11338
11443
  ),
11339
11444
  /* @__PURE__ */ jsx(
@@ -11347,7 +11452,7 @@ function StorageNode({
11347
11452
  textAnchor: \u5370\u3067\u5206\u3051\u308B ? "end" : "start",
11348
11453
  fill: \u5370\u3067\u5206\u3051\u308B ? "var(--cdl-text-dim, #5a6270)" : highlightRows ? accent : "var(--cdl-text, #1a1f2a)",
11349
11454
  style: { fontFamily: "'JetBrains Mono', monospace" },
11350
- children: s.right
11455
+ children: \u7B49\u5E45\u306E\u5B57(s.right, \u5370\u3067\u5206\u3051\u308B ? ROW_TYPE_FONT : 26)
11351
11456
  }
11352
11457
  )
11353
11458
  ] }, idx);
@@ -11621,8 +11726,8 @@ function GenericNode({
11621
11726
  /* @__PURE__ */ jsx("path", { d: style.icon, fill: style.eyebrowColor, opacity: 0.7, transform: "scale(1)" })
11622
11727
  ] }),
11623
11728
  node.eyebrow && /* @__PURE__ */ 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 }),
11624
- /* @__PURE__ */ 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 }),
11625
- node.subtitle && /* @__PURE__ */ 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 }),
11729
+ /* @__PURE__ */ 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 }),
11730
+ node.subtitle && /* @__PURE__ */ 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) }),
11626
11731
  resolvedValue && /* @__PURE__ */ jsx(
11627
11732
  "text",
11628
11733
  {
@@ -11633,7 +11738,7 @@ function GenericNode({
11633
11738
  textAnchor: "end",
11634
11739
  fill: "var(--cdl-text, #1a1f2a)",
11635
11740
  style: { fontFamily: "'JetBrains Mono', monospace" },
11636
- children: resolvedValue
11741
+ children: \u7B49\u5E45\u306E\u5B57(resolvedValue, 32)
11637
11742
  }
11638
11743
  ),
11639
11744
  node.rows && node.rows.length > 0 && (() => {
@@ -11658,7 +11763,7 @@ function GenericNode({
11658
11763
  textAnchor: "start",
11659
11764
  fill: "var(--cdl-text, #1a1f2a)",
11660
11765
  style: { fontFamily: "'JetBrains Mono', monospace" },
11661
- children: s.right
11766
+ children: \u7B49\u5E45\u306E\u5B57(s.right, 21)
11662
11767
  }
11663
11768
  )
11664
11769
  ] }, i)) });
@@ -18944,6 +19049,14 @@ function CdlStage({
18944
19049
  },
18945
19050
  `label-${edge.id}`
18946
19051
  )),
19052
+ laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).map((edge) => /* @__PURE__ */ jsx(
19053
+ CdlEdgeHeadLabelView,
19054
+ {
19055
+ edge,
19056
+ active: activeSet.has(edge.id)
19057
+ },
19058
+ `head-label-${edge.id}`
19059
+ )),
18947
19060
  debug && /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
18948
19061
  laid.bboxes.map((bbox, idx) => {
18949
19062
  const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";