@cardenelabs/cdl 0.51.0 → 0.52.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 +15 -1
- package/dist/index.cjs +44 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +44 -30
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +41 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +41 -30
- package/dist/react.js.map +1 -1
- package/dist/{render-BoBEyCu-.d.cts → render-C0PJ2weJ.d.cts} +6 -0
- package/dist/{render-BoBEyCu-.d.ts → render-C0PJ2weJ.d.ts} +6 -0
- package/package.json +1 -1
- package/src/builder.ts +6 -0
- package/src/layout/head-label.ts +56 -36
- package/src/presets.ts +3 -0
- package/src/render/edges.tsx +8 -5
- package/src/render/stage.tsx +13 -10
- package/src/types.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ CDL (Chainome Diagram Language) の主要変更履歴。
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.52.0] - 2026-09-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **クラス図の関係の出どころ側の端にも多重度を出せるようにした** (#825)
|
|
13
|
+
|
|
14
|
+
UML は関係の両端に多重度を書く (例 = 管理者 `1` が注文 `1..*` を持つ)。 組み立て器は多重度を
|
|
15
|
+
1 つ (`cardinality` = 行き先の端) しか受け取れず、出どころの端の数を書く口が無かった。
|
|
16
|
+
|
|
17
|
+
クラス図の組み立て器に `tailCardinality` を足した。 線に「出どころの端に添える字」 の欄 `tailLabel` を
|
|
18
|
+
足し (`headLabel` と対)、置き場所は行き先の端と同じ計算で決める。 出どころの端での向きは、線の
|
|
19
|
+
最初の区間を逆にたどって取る (曲線なら始点の接線)。
|
|
20
|
+
|
|
8
21
|
## [0.51.0] - 2026-09-11
|
|
9
22
|
|
|
10
23
|
### Changed
|
|
@@ -2435,7 +2448,8 @@ Initial OSS release.
|
|
|
2435
2448
|
使わない = annotated tag を push しても GitHub Release は作られず、 Release を作っていない版で
|
|
2436
2449
|
行き止まりになる。
|
|
2437
2450
|
|
|
2438
|
-
[Unreleased]: https://github.com/cardene777/cdl/compare/v0.
|
|
2451
|
+
[Unreleased]: https://github.com/cardene777/cdl/compare/v0.52.0...HEAD
|
|
2452
|
+
[0.52.0]: https://github.com/cardene777/cdl/compare/v0.51.0...v0.52.0
|
|
2439
2453
|
[0.51.0]: https://github.com/cardene777/cdl/compare/v0.50.0...v0.51.0
|
|
2440
2454
|
[0.50.0]: https://github.com/cardene777/cdl/compare/v0.49.0...v0.50.0
|
|
2441
2455
|
[0.49.0]: https://github.com/cardene777/cdl/compare/v0.48.0...v0.49.0
|
package/dist/index.cjs
CHANGED
|
@@ -9502,6 +9502,7 @@ function diagram(id, options) {
|
|
|
9502
9502
|
guard: opts.guard,
|
|
9503
9503
|
cardinality: opts.cardinality,
|
|
9504
9504
|
headLabel: opts.headLabel,
|
|
9505
|
+
tailLabel: opts.tailLabel,
|
|
9505
9506
|
labelOffsetX: opts.labelOffsetX,
|
|
9506
9507
|
labelOffsetY: opts.labelOffsetY,
|
|
9507
9508
|
routing: opts.routing,
|
|
@@ -9629,6 +9630,7 @@ function diagram(id, options) {
|
|
|
9629
9630
|
guard: d.guard,
|
|
9630
9631
|
cardinality: d.cardinality,
|
|
9631
9632
|
headLabel: d.headLabel,
|
|
9633
|
+
tailLabel: d.tailLabel,
|
|
9632
9634
|
labelOffsetX: d.labelOffsetX,
|
|
9633
9635
|
labelOffsetY: d.labelOffsetY,
|
|
9634
9636
|
routing: d.routing,
|
|
@@ -22940,28 +22942,34 @@ var \u7AEF\u306E\u5B57\u3068\u7DDA\u306E\u9699\u9593 = 8;
|
|
|
22940
22942
|
var \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 = EDGE_LABEL_TEXT.sub.fontSize;
|
|
22941
22943
|
var \u7BB1\u306E\u9AD8\u30552 = Math.round(\u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055 * 1.2);
|
|
22942
22944
|
var BASELINE_RATIO = 0.8;
|
|
22943
|
-
function \
|
|
22944
|
-
const
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
const \u5236\u5FA1\u70B9 = s.cmd === "Q" ? s.ctrl?.[0] : s.cmd === "C" ? s.ctrl?.[1] : void 0;
|
|
22951
|
-
for (const p of [\u5236\u5FA1\u70B9, { x: s.x1, y: s.y1 }]) {
|
|
22952
|
-
if (!p) continue;
|
|
22953
|
-
const dx = end.x - p.x;
|
|
22954
|
-
const dy = end.y - p.y;
|
|
22955
|
-
const len = Math.hypot(dx, dy);
|
|
22956
|
-
if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
|
|
22957
|
-
}
|
|
22945
|
+
function \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC) {
|
|
22946
|
+
for (const p of \u5019\u88DC) {
|
|
22947
|
+
if (!p) continue;
|
|
22948
|
+
const dx = end.x - p.x;
|
|
22949
|
+
const dy = end.y - p.y;
|
|
22950
|
+
const len = Math.hypot(dx, dy);
|
|
22951
|
+
if (len > 1e-6) return { end, ux: dx / len, uy: dy / len };
|
|
22958
22952
|
}
|
|
22959
22953
|
return null;
|
|
22960
22954
|
}
|
|
22961
|
-
function \u7AEF\u306E\
|
|
22962
|
-
const
|
|
22955
|
+
function \u7AEF\u3067\u306E\u5411\u304D(d, \u7AEF) {
|
|
22956
|
+
const segs = extractPathSegments(d);
|
|
22957
|
+
if (segs.length === 0) return null;
|
|
22958
|
+
if (\u7AEF === "head") {
|
|
22959
|
+
const last = segs[segs.length - 1];
|
|
22960
|
+
const end2 = { x: last.x2, y: last.y2 };
|
|
22961
|
+
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 }]);
|
|
22962
|
+
return \u5411\u304D\u3092\u53D6\u308B(end2, \u5019\u88DC2);
|
|
22963
|
+
}
|
|
22964
|
+
const first = segs[0];
|
|
22965
|
+
const end = { x: first.x1, y: first.y1 };
|
|
22966
|
+
const \u5019\u88DC = segs.flatMap((s) => [...s.ctrl ?? [], { x: s.x2, y: s.y2 }]);
|
|
22967
|
+
return \u5411\u304D\u3092\u53D6\u308B(end, \u5019\u88DC);
|
|
22968
|
+
}
|
|
22969
|
+
function \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF = "head") {
|
|
22970
|
+
const text = (\u7AEF === "head" ? edge.headLabel : edge.tailLabel)?.trim();
|
|
22963
22971
|
if (!text) return null;
|
|
22964
|
-
const \u5411\u304D = \
|
|
22972
|
+
const \u5411\u304D = \u7AEF\u3067\u306E\u5411\u304D(edge.d, \u7AEF);
|
|
22965
22973
|
if (!\u5411\u304D) return null;
|
|
22966
22974
|
const { end, ux, uy } = \u5411\u304D;
|
|
22967
22975
|
const bx = end.x - ux * \u7AEF\u306E\u5B57\u3092\u623B\u3059\u8DDD\u96E2;
|
|
@@ -23262,11 +23270,12 @@ function CdlEdgeLabelView({
|
|
|
23262
23270
|
}
|
|
23263
23271
|
);
|
|
23264
23272
|
}
|
|
23265
|
-
function
|
|
23273
|
+
function CdlEdgeEndLabelView({
|
|
23266
23274
|
edge,
|
|
23267
|
-
active
|
|
23275
|
+
active,
|
|
23276
|
+
\u7AEF
|
|
23268
23277
|
}) {
|
|
23269
|
-
const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge);
|
|
23278
|
+
const \u7F6E\u304D\u5834\u6240 = \u7AEF\u306E\u5B57\u3092\u7F6E\u304F(edge, \u7AEF);
|
|
23270
23279
|
if (!\u7F6E\u304D\u5834\u6240) return null;
|
|
23271
23280
|
const color = edgeColor(edge);
|
|
23272
23281
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -23274,6 +23283,7 @@ function CdlEdgeHeadLabelView({
|
|
|
23274
23283
|
{
|
|
23275
23284
|
"data-cdl-role": "edge-end-label",
|
|
23276
23285
|
"data-cdl-edge-end-label-for": edge.id,
|
|
23286
|
+
"data-cdl-edge-end": \u7AEF,
|
|
23277
23287
|
x: \u7F6E\u304D\u5834\u6240.x,
|
|
23278
23288
|
y: \u7F6E\u304D\u5834\u6240.y,
|
|
23279
23289
|
fontSize: \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055,
|
|
@@ -23285,7 +23295,7 @@ function CdlEdgeHeadLabelView({
|
|
|
23285
23295
|
strokeLinejoin: "round",
|
|
23286
23296
|
paintOrder: "stroke",
|
|
23287
23297
|
style: { fontFamily: fontFamilyAttr("sub") },
|
|
23288
|
-
children: \u7B49\u5E45\u306E\u5B57(edge.headLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
|
|
23298
|
+
children: \u7B49\u5E45\u306E\u5B57(\u7AEF === "head" ? edge.headLabel : edge.tailLabel, \u7AEF\u306E\u5B57\u306E\u5927\u304D\u3055)
|
|
23289
23299
|
}
|
|
23290
23300
|
);
|
|
23291
23301
|
}
|
|
@@ -31573,14 +31583,17 @@ function CdlStage({
|
|
|
31573
31583
|
},
|
|
31574
31584
|
`label-${edge.id}`
|
|
31575
31585
|
)),
|
|
31576
|
-
laid.edges.filter((edge) => edge.headLabel && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
|
|
31582
|
-
|
|
31583
|
-
|
|
31586
|
+
laid.edges.filter((edge) => (edge.headLabel || edge.tailLabel) && \u77E2\u5370\u306E\u51FA\u756A.\u51FA\u308B\u304B(edge.id)).flatMap(
|
|
31587
|
+
(edge) => ["head", "tail"].map((\u7AEF) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
31588
|
+
CdlEdgeEndLabelView,
|
|
31589
|
+
{
|
|
31590
|
+
edge,
|
|
31591
|
+
active: activeSet.has(edge.id),
|
|
31592
|
+
\u7AEF
|
|
31593
|
+
},
|
|
31594
|
+
`${\u7AEF}-label-${edge.id}`
|
|
31595
|
+
))
|
|
31596
|
+
),
|
|
31584
31597
|
debug && /* @__PURE__ */ jsxRuntime.jsxs("g", { pointerEvents: "none", children: [
|
|
31585
31598
|
laid.bboxes.map((bbox, idx) => {
|
|
31586
31599
|
const color = bbox.kind === "node" ? "#3b82f6" : bbox.kind === "lane-label" ? "#a855f7" : bbox.kind === "edge-label" ? "#10b981" : "#f59e0b";
|
|
@@ -32628,6 +32641,7 @@ function classDiagram(preset) {
|
|
|
32628
32641
|
// 多重度は行き先の端に添える (#821)。 札の下の行に入れると語と続けて読まれ
|
|
32629
32642
|
// (英字の頃は「HAS 1..*」 が「HAS1」)、 どちらの端の数かも読めない
|
|
32630
32643
|
...r.cardinality ? { headLabel: r.cardinality } : {},
|
|
32644
|
+
...r.tailCardinality ? { tailLabel: r.tailCardinality } : {},
|
|
32631
32645
|
tone: r.tone ?? \u56F3\u306E\u65E2\u5B9A ?? CLASS_RELATION_TONE[r.type],
|
|
32632
32646
|
// 関係の種類から線と端の形を決める (cdl#574 / #578)。 書いた値が勝つ
|
|
32633
32647
|
style: r.style ?? \u898B\u305F\u76EE.style,
|