@cardenelabs/cdl 0.28.0 → 0.30.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/CHANGELOG.md CHANGED
@@ -5,6 +5,87 @@ CDL (Chainome Diagram Language) の主要変更履歴。
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.30.0] - 2026-09-05
9
+
10
+ ### Fixed
11
+
12
+ - **出入りする線の根元が重ならなくなった** (#649)
13
+
14
+ 同じ節の同じ辺に 1 本入って 1 本出る時、相手が違うと 2 本の根元が重なったまま残っていた。
15
+ 色の違う線どうしでは後から描いた色が前の色を隠し、関係の群を色で読み分けられなかった。
16
+
17
+ 同じ辺に 2 本以上が付く形は 4 通りあり、3 通りは既に担当がいた。
18
+ 入る × 入るは `fanIncomingEndpoints` (#611)、出る × 出るは `fan-origin-single-point` 軸が担当し、後者は意図して重ねる。
19
+ 同じ 2 節を往復する対は `SYMMETRIC_PAIR_SHIFT` (`CAR-541`) が担当していた。
20
+ 相手の違う入る × 出るだけ担当がいなかった。
21
+
22
+ `fanIncomingEndpoints` が、同じ辺から出る線を数に入れるようにした。
23
+ 出る線が中央を占め、入る線は来た向きの外側へ寄る。
24
+
25
+ **重なっている時だけ動かす**。
26
+ 変更前も変更後も 24px 以上重なっていない線は触らない。
27
+ 動かすとまっすぐな線に折れが増えるため。
28
+
29
+ 終点をずらす助走を、最後の区間いっぱいまで伸ばせるようにした。
30
+ 変更前の 40px しか戻らない形では重なりが 40px ぶんしか減らなかったが、変更後は最後の区間全体を使える。
31
+
32
+ 助走は長い方から順に試す。
33
+ 長い助走で交差が増えるなら 40px で試し、どちらも増えるなら元のままにする。
34
+
35
+ 消費側の `dragon` の見本帳 12 クラス、14 関係では、色の違う線の重なりが変更前の 5 件から変更後の 2 件に減った。
36
+ 残る 2 件は `fan-origin-single-point` が意図して重ねている出る × 出る。
37
+
38
+ - **同じ辺から出る線が長く重ならなくなった** (#651)
39
+
40
+ 同じ節の同じ辺から 2 本以上が出る時、起点が 1 点に収束するため出だしが重なる。
41
+ 折れる位置が遠いと、その手前まで完全に重なったままになる。
42
+
43
+ 消費側の `dragon` の見本帳では 137px 重なっていた。
44
+ 色の違う線どうしでは後から描いた色が前の色を隠す。
45
+
46
+ 折れる位置は `detourStub` が「端点と、進行方向で最初に当たる箱の中間」に置いている (#418)。
47
+ 1 本しか出ない辺ではこの規則が正しく、2 本以上出る辺でだけ共有区間を長くしていた。
48
+
49
+ 経路が確定した後に、**一番長い 1 本を残して残りの最初の折れを手前へ引く** ようにした。
50
+ 引く先は `EDGE_STUB_OUT` と角の丸め半径の和で、まっすぐ走る部分がちょうど `EDGE_STUB_OUT` になる。
51
+
52
+ 引いた結果、箱に当たる線と、交差が増える線は元のままにする。
53
+
54
+ 重なりは変更前の 137px から変更後の 40px になった。
55
+ この 40px は 2 つの規約が要求している分で、これ以上は縮められない。
56
+ `fan-origin-single-point` 軸が起点を 1 点に収束させ、`EDGE_STUB_OUT` が起点から 40px 以上の直進を求めるため。
57
+
58
+ 1 本しか出ない辺の折れる位置は変えていない。
59
+
60
+ ## [0.29.0] - 2026-09-04
61
+
62
+ ### Added
63
+
64
+ - **図の種類を絵の根に出すようにした** (#645)
65
+
66
+ これまで絵の根に出ていたのは `data-cdl-stage` と `data-cdl-scale` と `data-cdl-palette` の
67
+ 3 つだけで、図の種類が出ていなかった。 そのため消費側が図の種類で描き分けられない。
68
+
69
+ 実際に困った例は、消費側の dragon でクラス図の関係の線だけを太くしようとした時。
70
+ 線の規則は `[data-cdl-role="edge-line"]` 1 つしかなく、直すと ER 図 ・ 状態遷移図 ・
71
+ 流れ図 ・ 並び図 の線まで同時に太くなる。
72
+
73
+ `data-cdl-palette` では選び分けられない = クラス図と ER 図がどちらも `kinari` を出すため。
74
+
75
+ `palette` (#1553) と同じ形にした = **cdl は名前だけを出し、見た目は消費側が決める**。
76
+ 値を engine に持たせると、消費側が表現を変えるたびに engine の release が要る。
77
+
78
+ 種類名は組み立て器の名前をそのまま小文字で使う。 例外は 4 件。
79
+
80
+ | 組み立て器 | 種類名 | なぜ |
81
+ |---|---|---|
82
+ | `classDiagram` | `class` | 消費側の記法が `class` を使う |
83
+ | `userJourney` | `journey` | 同上 |
84
+ | `mindMap` | `mindmap` | 大文字小文字を混ぜない |
85
+ | `stateMachine` と `stateMachine2` | どちらも `state` | 後者は入れ子と動作を足した拡張で、図の種類としては同じ |
86
+
87
+ 組み立て器を通さず `diagram()` を直に呼んだ図と、空文字を渡した図には属性を出さない。
88
+
8
89
  ## [0.28.0] - 2026-09-04
9
90
 
10
91
  ### Changed
@@ -1411,7 +1492,9 @@ Initial OSS release.
1411
1492
  使わない = annotated tag を push しても GitHub Release は作られず、 Release を作っていない版で
1412
1493
  行き止まりになる。
1413
1494
 
1414
- [Unreleased]: https://github.com/cardene777/cdl/compare/v0.28.0...HEAD
1495
+ [Unreleased]: https://github.com/cardene777/cdl/compare/v0.30.0...HEAD
1496
+ [0.30.0]: https://github.com/cardene777/cdl/compare/v0.29.0...v0.30.0
1497
+ [0.29.0]: https://github.com/cardene777/cdl/compare/v0.28.0...v0.29.0
1415
1498
  [0.28.0]: https://github.com/cardene777/cdl/compare/v0.27.0...v0.28.0
1416
1499
  [0.27.0]: https://github.com/cardene777/cdl/compare/v0.26.0...v0.27.0
1417
1500
  [0.26.0]: https://github.com/cardene777/cdl/compare/v0.25.0...v0.26.0
package/dist/index.cjs CHANGED
@@ -11486,6 +11486,8 @@ function diagram(id, options) {
11486
11486
  ...options.structuredData === "exclude" ? { structuredData: "exclude" } : {},
11487
11487
  // 配色の名前は素通しする。 空文字の遮断は `layout` が持つ (後段が必ず通るため)
11488
11488
  ...options.palette !== void 0 ? { palette: options.palette } : {},
11489
+ // 種類の名前も同じ経路で渡し、空文字の扱いを `layout` の 1 箇所に揃える
11490
+ ...options.type !== void 0 ? { type: options.type } : {},
11489
11491
  // inputs / formulas / scrollTriggers / eventBindings は空なら省略 (static diagram の JSON 形状維持)
11490
11492
  ...inputs.length > 0 ? { inputs: [...inputs] } : {},
11491
11493
  ...formulas.length > 0 ? { formulas: [...formulas] } : {},
@@ -19673,16 +19675,112 @@ function separateSharedStraightRuns(edges, nodes) {
19673
19675
  e.d = verticesToPath(verts.get(e.id));
19674
19676
  }
19675
19677
  }
19678
+ function pullOutgoingFirstCorner(edges, nodes) {
19679
+ if (edges.length < 2) return;
19680
+ const \u675F = /* @__PURE__ */ new Map();
19681
+ const \u540C\u3058\u7D44\u306E\u6570 = /* @__PURE__ */ new Map();
19682
+ for (const e of edges) {
19683
+ const key = `${e.from}::${e.fromSide}`;
19684
+ const list = \u675F.get(key) ?? [];
19685
+ list.push(e);
19686
+ \u675F.set(key, list);
19687
+ const pair = `${e.from}->${e.to}`;
19688
+ \u540C\u3058\u7D44\u306E\u6570.set(pair, (\u540C\u3058\u7D44\u306E\u6570.get(pair) ?? 0) + 1);
19689
+ }
19690
+ let \u672D\u3092\u65E7\u7D4C\u8DEF\u3078\u8FFD\u5F93\u6E08\u307F = false;
19691
+ for (const list of \u675F.values()) {
19692
+ if (list.length < 2) continue;
19693
+ const \u4E26\u3073 = list.flatMap((e) => {
19694
+ const pts = pathVertices(e.d);
19695
+ if (!pts || pts.length < 2) return [];
19696
+ return [{ e, pts, \u6700\u521D\u306E\u9577\u3055: Math.hypot(pts[1].x - pts[0].x, pts[1].y - pts[0].y) }];
19697
+ }).sort((a, b) => b.\u6700\u521D\u306E\u9577\u3055 - a.\u6700\u521D\u306E\u9577\u3055);
19698
+ for (const { e, pts, \u6700\u521D\u306E\u9577\u3055 } of \u4E26\u3073.slice(1)) {
19699
+ if ((\u540C\u3058\u7D44\u306E\u6570.get(`${e.from}->${e.to}`) ?? 0) > 1) continue;
19700
+ if (pts.length < 3 || \u6700\u521D\u306E\u9577\u3055 <= EDGE_STUB_OUT + VERTICAL_DETOUR_CORNER) continue;
19701
+ const \u6A2A = e.fromSide === "left" || e.fromSide === "right";
19702
+ if (!runIsAligned(pts, 0, \u6A2A ? 1 : 0)) continue;
19703
+ const \u79FB\u52D5\u91CF = \u6700\u521D\u306E\u9577\u3055 - (EDGE_STUB_OUT + VERTICAL_DETOUR_CORNER);
19704
+ const ux = (pts[1].x - pts[0].x) / \u6700\u521D\u306E\u9577\u3055;
19705
+ const uy = (pts[1].y - pts[0].y) / \u6700\u521D\u306E\u9577\u3055;
19706
+ const \u8A66\u3057 = pts.map(
19707
+ (p, i) => i === 1 || i === 2 ? { x: p.x - ux * \u79FB\u52D5\u91CF, y: p.y - uy * \u79FB\u52D5\u91CF } : p
19708
+ );
19709
+ const \u8A66\u3057D = verticesToPath(\u8A66\u3057);
19710
+ const \u8A66\u3057\u533A\u9593 = flattenPathSegments(extractPathSegments(\u8A66\u3057D));
19711
+ if (nodes.some(
19712
+ (n) => n.id !== e.from && n.id !== e.to && segmentsCrossRect(\u8A66\u3057\u533A\u9593, nodeRect(n))
19713
+ )) {
19714
+ continue;
19715
+ }
19716
+ const \u524D = e.d;
19717
+ const \u524D\u306E\u4EA4\u5DEE = countEdgeCrossings(edges).count;
19718
+ e.d = \u8A66\u3057D;
19719
+ if (countEdgeCrossings(edges).count > \u524D\u306E\u4EA4\u5DEE) {
19720
+ e.d = \u524D;
19721
+ continue;
19722
+ }
19723
+ e.d = \u524D;
19724
+ if (!\u672D\u3092\u65E7\u7D4C\u8DEF\u3078\u8FFD\u5F93\u6E08\u307F) {
19725
+ slideLabelsAlongOwnPath(edges, nodes);
19726
+ \u672D\u3092\u65E7\u7D4C\u8DEF\u3078\u8FFD\u5F93\u6E08\u307F = true;
19727
+ }
19728
+ const labelBox = computeLabelBBoxWorld(e);
19729
+ const label = { x: labelBox.x + labelBox.w / 2, y: labelBox.y + labelBox.h / 2 };
19730
+ const \u7DDA\u5206\u307E\u3067\u306E\u8DDD\u96E22 = (a, b) => {
19731
+ const dx = b.x - a.x;
19732
+ const dy = b.y - a.y;
19733
+ const len2 = dx * dx + dy * dy;
19734
+ const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((label.x - a.x) * dx + (label.y - a.y) * dy) / len2));
19735
+ return (label.x - (a.x + dx * t)) ** 2 + (label.y - (a.y + dy * t)) ** 2;
19736
+ };
19737
+ const \u52D5\u304F\u533A\u9593\u3078\u306E\u8DDD\u96E2 = \u7DDA\u5206\u307E\u3067\u306E\u8DDD\u96E22(pts[1], pts[2]);
19738
+ const label\u3082\u52D5\u304B\u3059 = pts.slice(0, -1).every((p, i) => \u7DDA\u5206\u307E\u3067\u306E\u8DDD\u96E22(p, pts[i + 1]) >= \u52D5\u304F\u533A\u9593\u3078\u306E\u8DDD\u96E2 - 1e-6);
19739
+ e.d = \u8A66\u3057D;
19740
+ if (label\u3082\u52D5\u304B\u3059) {
19741
+ e.labelX -= ux * \u79FB\u52D5\u91CF;
19742
+ e.labelY -= uy * \u79FB\u52D5\u91CF;
19743
+ }
19744
+ }
19745
+ }
19746
+ }
19676
19747
  var ENDPOINT_FAN_STEP = 56;
19677
19748
  var ENDPOINT_FAN_MIN = 20;
19678
19749
  var ENDPOINT_FAN_RUNUP = 40;
19750
+ var MIXED_ROOT_OVERLAP_MIN = 24;
19679
19751
  function fanIncomingEndpoints(edges, nodes) {
19680
19752
  if (edges.length < 2) return;
19681
19753
  const nmap = new Map(nodes.map((n) => [n.id, n]));
19754
+ const \u5E73\u5766\u306A\u533A\u9593 = new Map(edges.map((e) => [e.id, flattenPathSegments(extractPathSegments(e.d))]));
19755
+ const \u8EF8\u306B\u5E73\u884C\u306A\u91CD\u306A\u308A\u9577\u3055 = (\u4E00\u65B9, \u4ED6\u65B9) => {
19756
+ let \u5408\u8A08 = 0;
19757
+ for (const a of \u5E73\u5766\u306A\u533A\u9593.get(\u4E00\u65B9.id) ?? []) {
19758
+ const a\u306F\u6C34\u5E73 = Math.abs(a.y2 - a.y1) <= 1;
19759
+ const a\u306F\u5782\u76F4 = Math.abs(a.x2 - a.x1) <= 1;
19760
+ for (const b of \u5E73\u5766\u306A\u533A\u9593.get(\u4ED6\u65B9.id) ?? []) {
19761
+ const b\u306F\u6C34\u5E73 = Math.abs(b.y2 - b.y1) <= 1;
19762
+ const b\u306F\u5782\u76F4 = Math.abs(b.x2 - b.x1) <= 1;
19763
+ if (a\u306F\u6C34\u5E73 && b\u306F\u6C34\u5E73 && Math.abs(a.y1 - b.y1) <= 1) {
19764
+ \u5408\u8A08 += Math.max(0, Math.min(Math.max(a.x1, a.x2), Math.max(b.x1, b.x2)) - Math.max(Math.min(a.x1, a.x2), Math.min(b.x1, b.x2)));
19765
+ }
19766
+ if (a\u306F\u5782\u76F4 && b\u306F\u5782\u76F4 && Math.abs(a.x1 - b.x1) <= 1) {
19767
+ \u5408\u8A08 += Math.max(0, Math.min(Math.max(a.y1, a.y2), Math.max(b.y1, b.y2)) - Math.max(Math.min(a.y1, a.y2), Math.min(b.y1, b.y2)));
19768
+ }
19769
+ }
19770
+ }
19771
+ return \u5408\u8A08;
19772
+ };
19682
19773
  const \u540C\u3058\u7D44\u306E\u6570 = /* @__PURE__ */ new Map();
19683
19774
  for (const e of edges) \u540C\u3058\u7D44\u306E\u6570.set(`${e.from}->${e.to}`, (\u540C\u3058\u7D44\u306E\u6570.get(`${e.from}->${e.to}`) ?? 0) + 1);
19684
19775
  const \u675F = /* @__PURE__ */ new Map();
19776
+ const \u51FA\u308B\u7DDA = /* @__PURE__ */ new Map();
19685
19777
  for (const e of edges) {
19778
+ if (nmap.has(e.from)) {
19779
+ const key2 = `${e.from}::${e.fromSide}`;
19780
+ const list2 = \u51FA\u308B\u7DDA.get(key2) ?? [];
19781
+ list2.push(e);
19782
+ \u51FA\u308B\u7DDA.set(key2, list2);
19783
+ }
19686
19784
  if (!nmap.has(e.to)) continue;
19687
19785
  if ((\u540C\u3058\u7D44\u306E\u6570.get(`${e.from}->${e.to}`) ?? 0) > 1) continue;
19688
19786
  const key = `${e.to}::${e.toSide}`;
@@ -19690,27 +19788,48 @@ function fanIncomingEndpoints(edges, nodes) {
19690
19788
  list.push(e);
19691
19789
  \u675F.set(key, list);
19692
19790
  }
19693
- for (const [, list] of \u675F) {
19694
- if (list.length < 2) continue;
19791
+ for (const [key, list] of \u675F) {
19792
+ const \u4E2D\u592E\u304C\u585E\u304C\u3063\u3066\u3044\u308B = (\u51FA\u308B\u7DDA.get(key) ?? []).some(
19793
+ (\u51FA\u7DDA) => list.some(
19794
+ (\u5165\u7DDA) => !(\u5165\u7DDA.from === \u51FA\u7DDA.to && \u5165\u7DDA.to === \u51FA\u7DDA.from) && \u8EF8\u306B\u5E73\u884C\u306A\u91CD\u306A\u308A\u9577\u3055(\u5165\u7DDA, \u51FA\u7DDA) >= MIXED_ROOT_OVERLAP_MIN
19795
+ )
19796
+ );
19797
+ if (list.length < 2 && !\u4E2D\u592E\u304C\u585E\u304C\u3063\u3066\u3044\u308B) continue;
19695
19798
  const n = nmap.get(list[0].to);
19696
19799
  const \u6A2A = list[0].toSide === "left" || list[0].toSide === "right";
19697
19800
  const \u8FBA\u306E\u9577\u3055 = \u6A2A ? n.h : n.w;
19698
19801
  const \u4F7F\u3048\u308B\u5E452 = \u8FBA\u306E\u9577\u3055 - 2 * ARROW_ENDPOINT_CENTER_TOL;
19699
19802
  if (\u4F7F\u3048\u308B\u5E452 <= 0) continue;
19700
- const \u9593\u9694 = Math.min(ENDPOINT_FAN_STEP, \u4F7F\u3048\u308B\u5E452 / (list.length - 1));
19803
+ const \u5E2D\u306E\u9593 = \u4E2D\u592E\u304C\u585E\u304C\u3063\u3066\u3044\u308B ? list.length : list.length - 1;
19804
+ const \u9593\u9694 = Math.min(ENDPOINT_FAN_STEP, \u4F7F\u3048\u308B\u5E452 / \u5E2D\u306E\u9593);
19701
19805
  if (\u9593\u9694 < ENDPOINT_FAN_MIN) continue;
19702
- const \u4E26\u3073 = list.map((e) => ({ e, \u6DF1\u3055: \u8FBA\u304B\u3089\u96E2\u308C\u305F\u5074\u306E\u4F4D\u7F6E(e, \u6A2A) ?? 0 })).sort((a, b) => a.\u6DF1\u3055 - b.\u6DF1\u3055 || (a.e.id < b.e.id ? -1 : 1));
19806
+ const \u8FBA\u306E\u4E2D\u5FC3 = \u6A2A ? n.cy : n.cx;
19807
+ const \u4E26\u3073 = list.map((e) => {
19808
+ const \u533A\u9593 = extractPathSegments(e.d);
19809
+ const last = \u533A\u9593[\u533A\u9593.length - 1];
19810
+ const \u9577\u3044\u52A9\u8D70 = last === void 0 ? 0 : Math.hypot(last.x2 - last.x1, last.y2 - last.y1);
19811
+ const \u4E2D\u5FC3\u3092\u88DC\u3046 = \u4E2D\u592E\u304C\u585E\u304C\u3063\u3066\u3044\u308B || list.length === 2;
19812
+ const \u6DF1\u3055 = \u8FBA\u304B\u3089\u96E2\u308C\u305F\u5074\u306E\u4F4D\u7F6E(e, \u6A2A) ?? (\u4E2D\u5FC3\u3092\u88DC\u3046 ? \u8FBA\u306E\u4E2D\u5FC3 : 0);
19813
+ return { e, \u9577\u3044\u52A9\u8D70, \u6DF1\u3055 };
19814
+ }).sort((a, b) => a.\u6DF1\u3055 - b.\u6DF1\u3055 || (a.e.id < b.e.id ? -1 : 1));
19703
19815
  const \u4E2D\u5FC3 = (\u4E26\u3073.length - 1) * \u9593\u9694 / 2;
19816
+ let \u8CA0\u5074\u306E\u5E2D = 0;
19817
+ let \u6B63\u5074\u306E\u5E2D = 0;
19704
19818
  for (let k = 0; k < \u4E26\u3073.length; k++) {
19705
- const d = k * \u9593\u9694 - \u4E2D\u5FC3;
19819
+ const d = \u4E2D\u592E\u304C\u585E\u304C\u3063\u3066\u3044\u308B ? \u4E26\u3073[k].\u6DF1\u3055 < \u8FBA\u306E\u4E2D\u5FC3 ? -(++\u8CA0\u5074\u306E\u5E2D * \u9593\u9694) : ++\u6B63\u5074\u306E\u5E2D * \u9593\u9694 : k * \u9593\u9694 - \u4E2D\u5FC3;
19706
19820
  if (Math.abs(d) < 1e-3) continue;
19707
19821
  const e = \u4E26\u3073[k].e;
19708
- const \u5DEE\u66FF = \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \u6A2A, d, nodes);
19709
- if (\u5DEE\u66FF === null) continue;
19710
19822
  const \u524D = e.d;
19711
19823
  const \u524D\u306E\u4EA4\u5DEE = countEdgeCrossings(edges).count;
19712
- e.d = \u5DEE\u66FF;
19713
- if (countEdgeCrossings(edges).count > \u524D\u306E\u4EA4\u5DEE) e.d = \u524D;
19824
+ const \u9577\u3044\u52A9\u8D70 = \u4E26\u3073[k].\u9577\u3044\u52A9\u8D70;
19825
+ for (const \u52A9\u8D70 of [\u9577\u3044\u52A9\u8D70, ENDPOINT_FAN_RUNUP]) {
19826
+ e.d = \u524D;
19827
+ const \u5DEE\u66FF = \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \u6A2A, d, \u52A9\u8D70, nodes);
19828
+ if (\u5DEE\u66FF === null) continue;
19829
+ e.d = \u5DEE\u66FF;
19830
+ if (countEdgeCrossings(edges).count <= \u524D\u306E\u4EA4\u5DEE) break;
19831
+ e.d = \u524D;
19832
+ }
19714
19833
  }
19715
19834
  }
19716
19835
  }
@@ -19723,7 +19842,7 @@ function \u8FBA\u304B\u3089\u96E2\u308C\u305F\u5074\u306E\u4F4D\u7F6E(e, \u6A2A)
19723
19842
  }
19724
19843
  return null;
19725
19844
  }
19726
- function \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \u6A2A, d, nodes) {
19845
+ function \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \u6A2A, d, \u52A9\u8D70, nodes) {
19727
19846
  if ((e.d.match(/M/g) ?? []).length !== 1) return null;
19728
19847
  const segs = extractPathSegments(e.d);
19729
19848
  if (segs.length === 0) return null;
@@ -19736,7 +19855,8 @@ function \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \
19736
19855
  if (\u9577\u3055 < ENDPOINT_FAN_RUNUP + 1) return null;
19737
19856
  const ux = (last.x1 - last.x2) / \u9577\u3055;
19738
19857
  const uy = (last.y1 - last.y2) / \u9577\u3055;
19739
- const \u6298\u308C1 = { x: last.x2 + ux * ENDPOINT_FAN_RUNUP, y: last.y2 + uy * ENDPOINT_FAN_RUNUP };
19858
+ const \u4E38\u3081\u305F\u52A9\u8D70 = Math.min(\u52A9\u8D70, \u9577\u3055);
19859
+ const \u6298\u308C1 = { x: last.x2 + ux * \u4E38\u3081\u305F\u52A9\u8D70, y: last.y2 + uy * \u4E38\u3081\u305F\u52A9\u8D70 };
19740
19860
  const \u6298\u308C2 = \u6A2A ? { x: \u6298\u308C1.x, y: \u6298\u308C1.y + d } : { x: \u6298\u308C1.x + d, y: \u6298\u308C1.y };
19741
19861
  const \u7D42\u70B9 = \u6A2A ? { x: last.x2, y: last.y2 + d } : { x: last.x2 + d, y: last.y2 };
19742
19862
  const \u65B0\u533A\u9593 = [
@@ -19758,7 +19878,8 @@ function \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \
19758
19878
  }
19759
19879
  parts.push(`L ${s.x2} ${s.y2}`);
19760
19880
  }
19761
- parts.push(`L ${round1(\u6298\u308C1.x)} ${round1(\u6298\u308C1.y)}`);
19881
+ const \u6298\u308C1\u306F\u76F4\u524D\u306E\u6298\u308C = Math.abs(\u6298\u308C1.x - last.x1) <= 0.5 && Math.abs(\u6298\u308C1.y - last.y1) <= 0.5;
19882
+ if (!\u6298\u308C1\u306F\u76F4\u524D\u306E\u6298\u308C) parts.push(`L ${round1(\u6298\u308C1.x)} ${round1(\u6298\u308C1.y)}`);
19762
19883
  parts.push(`L ${round1(\u6298\u308C2.x)} ${round1(\u6298\u308C2.y)}`);
19763
19884
  parts.push(`L ${round1(\u7D42\u70B9.x)} ${round1(\u7D42\u70B9.y)}`);
19764
19885
  return parts.join(" ");
@@ -20241,6 +20362,7 @@ function layout(diag) {
20241
20362
  diag.edges.filter((e) => e.posX1 !== void 0 && e.posY1 !== void 0 && e.posX2 !== void 0 && e.posY2 !== void 0).map((e) => e.id)
20242
20363
  );
20243
20364
  bowSharedStraightPaths(edges, nodesFinal, positionedEdgeIds);
20365
+ pullOutgoingFirstCorner(edges, nodesFinal);
20244
20366
  fanIncomingEndpoints(edges, nodesFinal);
20245
20367
  separateSharedStraightRuns(edges, nodesFinal);
20246
20368
  hopEdgeCrossings(edges);
@@ -20282,6 +20404,8 @@ function layout(diag) {
20282
20404
  // **遮断はここだけに置く**。 描画は必ず組み立てを通り、組み立て API も `er` も
20283
20405
  // 素通しにしてある。 上流にも置くと、どの入力でも通らない分岐が残る
20284
20406
  ...diag.palette ? { palette: diag.palette } : {},
20407
+ // 種類も配色と同じく空の目印を出さない。 遮断をここに揃えると手書きの図にも効く
20408
+ ...diag.type ? { type: diag.type } : {},
20285
20409
  bboxes,
20286
20410
  collisions,
20287
20411
  nearCollisions,
@@ -29701,6 +29825,7 @@ function CdlStage({
29701
29825
  "data-cdl-stage": "",
29702
29826
  "data-cdl-scale": diagramScale === 1 ? void 0 : diagramScale,
29703
29827
  "data-cdl-palette": laid.palette,
29828
+ "data-cdl-type": laid.type,
29704
29829
  children: [
29705
29830
  /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
29706
29831
  Object.entries(TONE).flatMap(
@@ -30370,7 +30495,7 @@ function fitRowsWidth(boxW, rows) {
30370
30495
  }
30371
30496
  function swimlane(preset) {
30372
30497
  const w = preset.laneWidth ?? 400;
30373
- const b = diagram(preset.id, { topic: preset.topic });
30498
+ const b = diagram(preset.id, { topic: preset.topic, type: "swimlane" });
30374
30499
  const labelToId = /* @__PURE__ */ new Map();
30375
30500
  const idsInOrder = [];
30376
30501
  for (const label of preset.lanes) {
@@ -30390,7 +30515,7 @@ function swimlane(preset) {
30390
30515
  }
30391
30516
  function flow(preset) {
30392
30517
  const w = preset.laneWidth ?? 400;
30393
- const b = diagram(preset.id, { topic: preset.topic });
30518
+ const b = diagram(preset.id, { topic: preset.topic, type: "flow" });
30394
30519
  b.lane("flow", { width: w, ...preset.laneLabel ? { label: preset.laneLabel } : {} });
30395
30520
  const tone = preset.defaultTone ?? "accent";
30396
30521
  const style = preset.defaultStyle ?? "dotted-flow";
@@ -30451,7 +30576,7 @@ var SEQUENCE_MESSAGE_LOOK = {
30451
30576
  };
30452
30577
  function sequence(preset) {
30453
30578
  const tone = preset.defaultTone ?? "accent";
30454
- const b = diagram(preset.id, { topic: preset.topic });
30579
+ const b = diagram(preset.id, { topic: preset.topic, type: "sequence" });
30455
30580
  const \u9762\u3005 = preset.actors.map(
30456
30581
  (a) => typeof a === "string" ? { name: a } : { name: a.name, ...a.subtitle ? { subtitle: a.subtitle } : {} }
30457
30582
  );
@@ -30506,7 +30631,7 @@ function topology(preset) {
30506
30631
  const groupW = preset.groupWidth ?? 460;
30507
30632
  const tone = preset.defaultTone ?? "accent";
30508
30633
  const style = preset.defaultStyle ?? "solid";
30509
- const b = diagram(preset.id, { topic: preset.topic });
30634
+ const b = diagram(preset.id, { topic: preset.topic, type: "topology" });
30510
30635
  const groupOrder = [];
30511
30636
  const groupStackCount = /* @__PURE__ */ new Map();
30512
30637
  const phaseActivate = [];
@@ -30575,7 +30700,7 @@ function er(preset) {
30575
30700
  const entityW = resolveStorageBoxW(preset.entityWidth, "er", "entityWidth");
30576
30701
  const tone = preset.defaultTone ?? "info";
30577
30702
  const \u7E1E\u3092\u6577\u304F = preset.rowStripe ?? true;
30578
- const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette });
30703
+ const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette, type: "er" });
30579
30704
  const entities = [];
30580
30705
  const phaseActivate = [];
30581
30706
  let relIdx = 0;
@@ -30661,7 +30786,7 @@ var FSM_ACTION_MARK = {
30661
30786
  function stateMachine(preset) {
30662
30787
  const stateW = resolveStateW(preset.stateWidth, "stateMachine");
30663
30788
  const tone = preset.defaultTone ?? "accent";
30664
- const b = diagram(preset.id, { topic: preset.topic });
30789
+ const b = diagram(preset.id, { topic: preset.topic, type: "state" });
30665
30790
  const phaseActivate = [];
30666
30791
  const stateOrder = /* @__PURE__ */ new Map();
30667
30792
  const \u72B6\u614B = [];
@@ -30773,7 +30898,7 @@ function infrastructure(preset) {
30773
30898
  const laneW = preset.laneWidth ?? 380;
30774
30899
  const tone = preset.defaultTone ?? "accent";
30775
30900
  const style = preset.defaultStyle ?? "solid";
30776
- const b = diagram(preset.id, { topic: preset.topic });
30901
+ const b = diagram(preset.id, { topic: preset.topic, type: "infrastructure" });
30777
30902
  const colLaneIds = /* @__PURE__ */ new Map();
30778
30903
  const phaseActivate = [];
30779
30904
  let connIdx = 0;
@@ -30854,7 +30979,7 @@ function classDiagram(preset) {
30854
30979
  const classW = resolveStorageBoxW(preset.classWidth, "classDiagram", "classWidth");
30855
30980
  const \u56F3\u306E\u65E2\u5B9A = preset.defaultTone;
30856
30981
  const \u7E1E\u3092\u6577\u304F = preset.rowStripe ?? true;
30857
- const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette });
30982
+ const b = diagram(preset.id, { topic: preset.topic, palette: preset.palette, type: "class" });
30858
30983
  const classes = [];
30859
30984
  const phaseActivate = [];
30860
30985
  const \u7BB1 = [];
@@ -30941,7 +31066,7 @@ function classDiagram(preset) {
30941
31066
  function tree(preset) {
30942
31067
  const canvasW = preset.nodeWidth ? preset.nodeWidth * 2 : 720;
30943
31068
  const canvasH = 480;
30944
- const b = diagram(preset.id, { topic: preset.topic });
31069
+ const b = diagram(preset.id, { topic: preset.topic, type: "tree" });
30945
31070
  const treeNodes = [];
30946
31071
  const api = {
30947
31072
  node(n) {
@@ -30979,7 +31104,7 @@ function tree(preset) {
30979
31104
  function userJourney(preset) {
30980
31105
  const canvasW = preset.stepWidth ? preset.stepWidth * 2 : 720;
30981
31106
  const canvasH = 480;
30982
- const b = diagram(preset.id, { topic: preset.topic });
31107
+ const b = diagram(preset.id, { topic: preset.topic, type: "journey" });
30983
31108
  const steps = [];
30984
31109
  const api = {
30985
31110
  step(s) {
@@ -31018,7 +31143,7 @@ function userJourney(preset) {
31018
31143
  function mindMap(preset) {
31019
31144
  const canvasW = preset.branchWidth ? preset.branchWidth * 2 : 720;
31020
31145
  const canvasH = 480;
31021
- const b = diagram(preset.id, { topic: preset.topic });
31146
+ const b = diagram(preset.id, { topic: preset.topic, type: "mindmap" });
31022
31147
  const branches = [];
31023
31148
  const api = {
31024
31149
  branch(br) {
@@ -31062,7 +31187,7 @@ function mindMap(preset) {
31062
31187
  function funnel(preset) {
31063
31188
  const canvasW = toGridSize(preset.stageWidth ?? 560);
31064
31189
  const canvasH = 480;
31065
- const b = diagram(preset.id, { topic: preset.topic });
31190
+ const b = diagram(preset.id, { topic: preset.topic, type: "funnel" });
31066
31191
  const stages = [];
31067
31192
  const api = {
31068
31193
  stage(s) {
@@ -31100,7 +31225,7 @@ function funnel(preset) {
31100
31225
  function quadrant(preset) {
31101
31226
  const canvasW = 640;
31102
31227
  const canvasH = 480;
31103
- const b = diagram(preset.id, { topic: preset.topic });
31228
+ const b = diagram(preset.id, { topic: preset.topic, type: "quadrant" });
31104
31229
  const items = [];
31105
31230
  const api = {
31106
31231
  item(it) {
@@ -31151,7 +31276,7 @@ function chart(preset) {
31151
31276
  const canvasH = toGridSize(
31152
31277
  preset.type === "pie" || preset.type === "gauge" || preset.type === "radial" || preset.type === "stat" || preset.type === "waffle" || preset.type === "stacked-bar" ? 320 : 360
31153
31278
  );
31154
- const b = diagram(preset.id, { topic: preset.topic });
31279
+ const b = diagram(preset.id, { topic: preset.topic, type: "chart" });
31155
31280
  const data = [];
31156
31281
  const kindMap = {
31157
31282
  line: "chart-line",
@@ -31200,7 +31325,7 @@ function gantt(preset) {
31200
31325
  const canvasW = preset.laneWidth ? preset.laneWidth * 2 : 720;
31201
31326
  const canvasH = 360;
31202
31327
  const tone = preset.defaultTone ?? "teal";
31203
- const b = diagram(preset.id, { topic: preset.topic });
31328
+ const b = diagram(preset.id, { topic: preset.topic, type: "gantt" });
31204
31329
  const tasks = [];
31205
31330
  const api = {
31206
31331
  task(t) {
@@ -31266,7 +31391,7 @@ var SHAPE_EYEBROW = {
31266
31391
  function flowchart(preset) {
31267
31392
  const laneW = preset.laneWidth ?? 380;
31268
31393
  const tone = preset.defaultTone ?? "accent";
31269
- const b = diagram(preset.id, { topic: preset.topic });
31394
+ const b = diagram(preset.id, { topic: preset.topic, type: "flowchart" });
31270
31395
  const laneToId = /* @__PURE__ */ new Map();
31271
31396
  const laneStackCount = /* @__PURE__ */ new Map();
31272
31397
  for (const label of preset.lanes) {
@@ -31327,7 +31452,7 @@ var NET_KIND_MAP = {
31327
31452
  function network(preset) {
31328
31453
  const laneW = preset.laneWidth ?? 320;
31329
31454
  const tone = preset.defaultTone ?? "info";
31330
- const b = diagram(preset.id, { topic: preset.topic });
31455
+ const b = diagram(preset.id, { topic: preset.topic, type: "network" });
31331
31456
  const colLaneIds = /* @__PURE__ */ new Map();
31332
31457
  const phaseActivate = [];
31333
31458
  let edgeIdx = 0;
@@ -31377,7 +31502,7 @@ function stateMachine2(preset) {
31377
31502
  const stateW = resolveStateW(preset.stateWidth, "stateMachine2");
31378
31503
  const laneW = boxLaneW(stateW);
31379
31504
  const tone = preset.defaultTone ?? "accent";
31380
- const b = diagram(preset.id, { topic: preset.topic });
31505
+ const b = diagram(preset.id, { topic: preset.topic, type: "state" });
31381
31506
  const stateOrder = /* @__PURE__ */ new Map();
31382
31507
  const phaseActivate = [];
31383
31508
  let transIdx = 0;