@cardenelabs/cdl 0.15.0 → 0.16.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 +27 -1
- package/dist/index.cjs +10 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/presets.ts +35 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardenelabs/cdl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cardene777",
|
package/src/presets.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { diagram } from "./builder";
|
|
|
2
2
|
import type { DiagramBuilder } from "./builder";
|
|
3
3
|
import { LANE_PAD_MIN, NODE_SIZE } from "./layout/tokens";
|
|
4
4
|
import { requiredRowsWidth } from "./kinds/row-align";
|
|
5
|
-
import type { NodeKind, Tone, EdgeStyle, JourneyEmotion, QuadrantKey, BoundNumber } from "./types";
|
|
5
|
+
import type { NodeKind, Tone, EdgeStyle, EdgeHead, JourneyEmotion, QuadrantKey, BoundNumber } from "./types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 状態を読む書き方 (`{名前}`)。
|
|
@@ -984,6 +984,32 @@ export function infrastructure(preset: InfrastructurePreset): InfrastructureBuil
|
|
|
984
984
|
|
|
985
985
|
export type ClassRelationType = "extends" | "implements" | "uses" | "aggregates" | "composes";
|
|
986
986
|
|
|
987
|
+
/**
|
|
988
|
+
* 関係の種類ごとの端の形 (cdl#574)。
|
|
989
|
+
*
|
|
990
|
+
* `#560` で足した端の形は「関係の種類を示す」 ためのもので、この preset が第一の使い手。
|
|
991
|
+
* 表にしないと 5 種とも同じ塗った三角になり、線の種類と語だけで区別することになる。
|
|
992
|
+
*
|
|
993
|
+
* | 種類 | 形 | 意味 |
|
|
994
|
+
* |---|---|---|
|
|
995
|
+
* | `extends` / `implements` | 三角 | 継ぐ |
|
|
996
|
+
* | `aggregates` / `composes` | 菱 | 持つ |
|
|
997
|
+
* | `uses` | 開いた矢 | 使う |
|
|
998
|
+
*
|
|
999
|
+
* **`extends` と `implements` が同じ形になるのは意図**。 UML では線の種類 (実線 / 破線) で
|
|
1000
|
+
* 分ける決まりで、端の形は「継ぐ」 を表す 1 種しかない。 `aggregates` と `composes` も同様に
|
|
1001
|
+
* 塗りの有無で分けるので、端の形は同じ菱になる。
|
|
1002
|
+
*
|
|
1003
|
+
* `Record<ClassRelationType, EdgeHead>` なので、種類を足すと形も要る。
|
|
1004
|
+
*/
|
|
1005
|
+
export const CLASS_RELATION_HEAD: Record<ClassRelationType, EdgeHead> = {
|
|
1006
|
+
extends: "triangle",
|
|
1007
|
+
implements: "triangle",
|
|
1008
|
+
uses: "open",
|
|
1009
|
+
aggregates: "diamond",
|
|
1010
|
+
composes: "diamond",
|
|
1011
|
+
};
|
|
1012
|
+
|
|
987
1013
|
export type UmlClass = {
|
|
988
1014
|
id: string;
|
|
989
1015
|
title: string;
|
|
@@ -1004,6 +1030,12 @@ export type UmlRelation = {
|
|
|
1004
1030
|
/** 多重度 (例 "1..*" / "0..1") */
|
|
1005
1031
|
cardinality?: string;
|
|
1006
1032
|
tone?: Tone;
|
|
1033
|
+
/**
|
|
1034
|
+
* 矢印の先の形 (cdl#574)。 書かなければ種類から決まる (`CLASS_RELATION_HEAD`)。
|
|
1035
|
+
*
|
|
1036
|
+
* **書いた形が勝つ**。 表と違う形にしたい関係だけを個別に書ける。
|
|
1037
|
+
*/
|
|
1038
|
+
head?: EdgeHead;
|
|
1007
1039
|
};
|
|
1008
1040
|
|
|
1009
1041
|
export type ClassDiagramPreset = {
|
|
@@ -1087,6 +1119,8 @@ export function classDiagram(preset: ClassDiagramPreset): ClassDiagramBuilder {
|
|
|
1087
1119
|
...(sub ? { sub } : {}),
|
|
1088
1120
|
tone: r.tone ?? tone,
|
|
1089
1121
|
style: "solid",
|
|
1122
|
+
// 関係の種類から端の形を決める (cdl#574)。 書いた形が勝つ
|
|
1123
|
+
head: r.head ?? CLASS_RELATION_HEAD[r.type],
|
|
1090
1124
|
// CAR-531 SSOT ... 旧実装は `labelOffsetY: currentIdx % 2 === 0 ? -60 : 60` で
|
|
1091
1125
|
// 複数 relation label の path 沿い集中を強制分散していた。 CAR-430 で導入した
|
|
1092
1126
|
// engine 側 fan offset (FAN_STEP 40 world) が同 from / to 群を自動分散する現在、
|