@cardenelabs/dragon 0.15.0 → 0.17.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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { CdlDiagram, NodeKind, Tone, EdgeStyle, LaidDiagram } from '@cardenelabs/cdl';
1
+ import { CdlDiagram, NodeKind, Tone, EdgeStyle, EdgeHead, EdgeHeadFill, ClassRelationType, SequenceMessageKind, EdgeReveal, LaidDiagram } from '@cardenelabs/cdl';
2
2
  export { CdlDiagram } from '@cardenelabs/cdl';
3
3
 
4
4
  /**
@@ -58,7 +58,7 @@ type V05ParseResult = {
58
58
  * 書くと、項目を足した時に案内か一覧のどちらかが取り残される (実際に `states` / `values` が
59
59
  * 一覧に 1 件も無い状態で放置されていた)。
60
60
  */
61
- declare const TOP_LEVEL_KEYS: readonly ["title", "type", "actors", "flow", "states", "values", "animation", "viewport", "lanes", "groups", "eyebrow", "axes", "readouts", "inputs", "formulas", "events", "scrolls"];
61
+ declare const TOP_LEVEL_KEYS: readonly ["title", "type", "actors", "flow", "states", "values", "animation", "viewport", "lanes", "groups", "eyebrow", "axes", "readouts", "inputs", "formulas", "events", "scrolls", "bands", "reveal"];
62
62
  /** 受け付ける図種。 記法一覧はここを見る。 */
63
63
  declare const PRESET_TYPES: ReadonlySet<PresetType>;
64
64
  /**
@@ -269,7 +269,7 @@ type DslEventBinding = {
269
269
  handlerId: string;
270
270
  pos: Position;
271
271
  };
272
- type PresetType = "sequence" | "flow" | "swimlane" | "er" | "state" | "topology" | "solidity" | "gantt" | "class" | "pie" | "bar" | "line" | "funnel" | "tree" | "journey" | "quadrant" | "c4" | "mind";
272
+ type PresetType = "sequence" | "flow" | "swimlane" | "er" | "state" | "topology" | "solidity" | "gantt" | "class" | "pie" | "bar" | "line" | "gauge" | "radial" | "stat" | "waffle" | "stacked" | "funnel" | "tree" | "journey" | "quadrant" | "c4" | "mind";
273
273
  type Position = {
274
274
  line: number;
275
275
  column?: number;
@@ -336,6 +336,20 @@ type DslDocument = {
336
336
  /** v0.5+ 拡張 ... viewport / lanes / groups */
337
337
  viewport?: DslViewport;
338
338
  lanes?: Record<string, DslLane>;
339
+ /**
340
+ * 動いている間の帯 (#1466)。 順序図だけが読む。
341
+ *
342
+ * 書かなければ面ごとに「最初に関わった段から最後まで」 の 1 本。 途中で手が空く面を
343
+ * 分けたい図だけ書く = どこで手が空くかは言づての並びからは決まらない。
344
+ */
345
+ bands?: DslBand[];
346
+ /**
347
+ * 矢印をいつ出すか (`reveal:`、 #1470)。
348
+ *
349
+ * 既定 (`phase`) は「段が名指しする矢印は、その段が来るまで描かない」。 `all` と書くと
350
+ * 段に関わらず最初から全部描く。 描き手の `CdlDiagram.edgeReveal` にそのまま渡る。
351
+ */
352
+ reveal?: EdgeReveal;
339
353
  groups?: Record<string, DslGroup>;
340
354
  /**
341
355
  * 値を見せる部品 (`readouts:`、 #1374)。 割合の輪や数え上げを図の脇に出す。
@@ -407,7 +421,25 @@ type DslActor = {
407
421
  subtitle?: string;
408
422
  eyebrow?: string;
409
423
  value?: string;
424
+ /**
425
+ * 前の時点の値 (#1450)。
426
+ *
427
+ * 内訳の変化を帯で示す図 (`type: stacked`) が 2 本目の帯として描き、値 1 つを大きく示す図
428
+ * (`type: stat`) が差として出す。 書かない図は 1 本のまま (従来と同じ)。
429
+ *
430
+ * **3 時点以上は持たない**。 描画側が 2 時点で設計されており (`cdl#551`)、足すなら欄の形ごと
431
+ * 決め直すことになる。
432
+ */
433
+ previous?: string;
410
434
  rows?: string[];
435
+ /**
436
+ * 行頭の印 (#1466)。 `rows` と同じ並びで、空文字はその行に印を付けない。
437
+ *
438
+ * **語の意味は図の種類が決める**。 ER は `pk` / `fk` / `opt`、状態遷移は
439
+ * `entry` / `exit` / `do` / `internal`。 印の 2 軸 (形 × 塗り) は共通だが、その軸が
440
+ * 何を指すかは種類ごとに違う。
441
+ */
442
+ marks?: string[];
411
443
  /**
412
444
  * 箱の中に描く図形 (`shape:`、 #1374)。 水位や角度を状態で動かせる。
413
445
  *
@@ -593,6 +625,35 @@ type DslStep = {
593
625
  dashOffsetBind?: string;
594
626
  /** 矢印がどの辺から出るか (#1385)。 書かなければ描画側が自動で選ぶ */
595
627
  side?: "top" | "right" | "bottom" | "left";
628
+ /**
629
+ * 矢印の先の形 (#1462)。 書かなければ従来どおり塗った三角。
630
+ *
631
+ * 4 図の設計は **端の形で関係の種類を示す** = 三角 (継ぐ) / 菱 (持つ) /
632
+ * 開いた矢 (使う) / 鳥の足 (多)。 書けないと 4 種とも同じ三角になり、
633
+ * 線の種類 (実線 / 点線) だけで 6 種の関係を区別することになる。
634
+ *
635
+ * 受ける語は描画側の `EDGE_HEADS` から導く = 描画側が増やせば書けるようになる。
636
+ */
637
+ head?: EdgeHead;
638
+ /** 出どころ側の端の形 (#1466)。 ER は端ごとに違う個数を示すので両端に要る */
639
+ tailHead?: EdgeHead;
640
+ /** 端の印の塗り (#1466)。 白抜きの菱が「持つ」、塗った菱が「抱える」 */
641
+ headFill?: EdgeHeadFill;
642
+ /** 出どころ側の印の塗り (#1466) */
643
+ tailHeadFill?: EdgeHeadFill;
644
+ /**
645
+ * クラス図の関係の種類 (#1466)。 書くと線と端の形と塗りと付く側がまとめて決まる。
646
+ *
647
+ * 4 つを個別に書かせないのは、組合せが 6 通りしか無く、1 つでも書き違えると読み手に
648
+ * 別の意味で伝わるため (菱を逆に置くと持ち主が入れ替わる)。
649
+ */
650
+ relation?: ClassRelationType;
651
+ /**
652
+ * 言づての種類 (#1466)。 順序図で線と矢の形がまとめて決まる。
653
+ *
654
+ * `kind` にしないのは、箱の種類 (`DslActor.kind`) と同じ語が別の意味を持つため。
655
+ */
656
+ msgKind?: SequenceMessageKind;
596
657
  labelOffsetX?: number;
597
658
  labelOffsetY?: number;
598
659
  /** true で説明文を矢印の線の上に重ねる。 分岐図の条件ラベル用。 */
@@ -707,6 +768,12 @@ type DslValue = {
707
768
  durationMs: number;
708
769
  });
709
770
  /** ステップ (phase) */
771
+ /** 動いている間の帯 (#1466)。 順序図で、面がいつ動いているかを段の番号で持つ */
772
+ type DslBand = {
773
+ actor: string;
774
+ from: number;
775
+ to: number;
776
+ };
710
777
  type DslPhase = {
711
778
  name: string;
712
779
  durationMs: number;
@@ -727,6 +794,20 @@ type DslPhase = {
727
794
  * 相手の名前は書かせない = 対象の 8 図種はいずれも図全体を 1 箱で描くため相手が決まる。
728
795
  */
729
796
  draw?: string;
797
+ /**
798
+ * 描き終えるまでに段の何割を使うか (#1441)。
799
+ *
800
+ * `draw: line 0.4` のように語の後ろに書く。 0 より大きく 1 以下。
801
+ * 書かなければ段の終わりに描き終わる (従来どおり)。
802
+ *
803
+ * **段の長さと描く速さを切り離すための欄**。 伸び具合は段の進みそのものなので、
804
+ * これが無いと「線はゆっくり引きたいが値の移りは短くしたい」 が書けず、描く速さのために
805
+ * 段の長さを動かすことになる。 段の長さを動かすと同じ段の `tween` まで遅くなる。
806
+ *
807
+ * **`draw` と同じ行に書かせる**。 別の項目にすると「割合だけ書いて `draw` が無い段」 が
808
+ * 書けてしまい、何も起きない指定になる。 同じ行なら書けない。
809
+ */
810
+ drawRatio?: number;
730
811
  /**
731
812
  * `draw` を書いた行 (#1312)。 知らせの行番号に使う。
732
813
  *
@@ -812,7 +893,7 @@ interface CompileToCdlOpts {
812
893
  }
813
894
  /** 図は出せるが書いた通りにならなかった、 という知らせ。 */
814
895
  type CompileNotice = {
815
- kind: "relative-position-ignored" | "focus-target-missing" | "state-override-rejected" | "external-paint-dropped" | "part-not-drawn" | "scale-reserved" | "chart-value-unreadable" | "chart-edge-dropped" | "value-shadows-state" | "value-unresolved" | "value-duplicate" | "flow-actor-missing" | "value-trigger-unresolved" | "flow-self-loop" | "lane-not-honored" | "lane-declared-empty" | "eyebrow-not-honored" | "flow-endpoint-not-honored" | "draw-not-honored" | "draw-target-mismatch" | "formula-unresolved" | "event-target-missing";
896
+ kind: "relative-position-ignored" | "focus-target-missing" | "state-override-rejected" | "external-paint-dropped" | "part-not-drawn" | "scale-reserved" | "chart-value-unreadable" | "chart-edge-dropped" | "value-shadows-state" | "value-unresolved" | "value-duplicate" | "flow-actor-missing" | "value-trigger-unresolved" | "lane-not-honored" | "lane-declared-empty" | "eyebrow-not-honored" | "flow-endpoint-not-honored" | "draw-not-honored" | "draw-target-mismatch" | "formula-unresolved" | "event-target-missing" | "actor-kind-not-honored" | "sub-node-not-found" | "message-option-not-honored";
816
897
  /** 対象の名前。 光らせる相手なら書かれた指定そのまま */
817
898
  actor: string;
818
899
  /** 書かれていた行 */
@@ -983,6 +1064,19 @@ declare function partVisualSize(part: CdlDiagram, targetW?: number, targetH?: nu
983
1064
  w: number;
984
1065
  h: number;
985
1066
  };
1067
+ /**
1068
+ * 既存の図が縦に何段ぶんを占めるかの目安 (#1481)。
1069
+ *
1070
+ * **箱の数では数えない**。 数で数えると、図を丸ごと 1 つの箱で描く種別が 1 段に潰れる。
1071
+ * 順序図は `#1466` で 1 枚の板になり、高さ 432 の箱 1 つになった = 1 段 (280) と見積もられ、
1072
+ * その下に置いたパーツが板に 31px 重なっていた (実測)。
1073
+ *
1074
+ * 大きさを自分で持つ箱は、その高さから段数を出す。 持たない箱は今までどおり 1 段と数えるので、
1075
+ * 高さを書かない図の並び方は変わらない。
1076
+ */
1077
+ declare function partsBaseRows(nodes: ReadonlyArray<{
1078
+ h?: number;
1079
+ }>): number;
986
1080
  /**
987
1081
  * 位置を書かなかったパーツを格子に並べた時の、 矩形の中心。
988
1082
  *
@@ -993,9 +1087,9 @@ declare function partVisualSize(part: CdlDiagram, targetW?: number, targetH?: nu
993
1087
  * 隣と重なる (実測 = 400 の次に 200 を置くと 280 重なった)。 段の高さも段内の最大高で揃える。
994
1088
  * 縦は自分の高さの半分だけ段の上端から下げて、 段内で上端を揃える。
995
1089
  *
996
- * @param baseNodeCount パーツ以外の箱の数。 既存の図の下から並べ始めるために使う
1090
+ * @param baseRows 既存の図が占める段数の目安 (`partsBaseRows`)。 図の下から並べ始めるために使う
997
1091
  */
998
- declare function partsGridCenters(baseNodeCount: number, items: ReadonlyArray<{
1092
+ declare function partsGridCenters(baseRows: number, items: ReadonlyArray<{
999
1093
  id: string;
1000
1094
  w: number;
1001
1095
  h: number;
@@ -1472,6 +1566,14 @@ interface DragonJson {
1472
1566
  label?: string;
1473
1567
  lanes: string[];
1474
1568
  }>;
1569
+ /** 順序図で面が動いている間の帯 (#1466)。 記法の最上位 `bands:` と同じ */
1570
+ bands?: {
1571
+ actor: string;
1572
+ from: number;
1573
+ to: number;
1574
+ }[];
1575
+ /** 矢印をいつ出すか (#1470)。 記法の最上位 `reveal:` と同じ */
1576
+ reveal?: EdgeReveal;
1475
1577
  }
1476
1578
  interface JsonActor {
1477
1579
  name: string;
@@ -1511,6 +1613,13 @@ interface JsonActor {
1511
1613
  subtitle?: string;
1512
1614
  eyebrow?: string;
1513
1615
  value?: string;
1616
+ /**
1617
+ * 前の時点の値 (#1450)。 記法の `{ value: "320", previous: "280" }` と同じ。
1618
+ *
1619
+ * 内訳の変化を帯で示す図 (`type: stacked`) が 2 本目の帯として描き、
1620
+ * 値 1 つを大きく示す図 (`type: stat`) が差として出す。 書かない図は 1 本のまま。
1621
+ */
1622
+ previous?: string;
1514
1623
  rows?: string[];
1515
1624
  lane?: string;
1516
1625
  stack?: number;
@@ -1586,6 +1695,8 @@ interface JsonActor {
1586
1695
  * 読めない項目名として知らせる)。
1587
1696
  */
1588
1697
  scale?: number;
1698
+ /** 行頭の印 (#1466)。 行と対で読む。 語の意味は図の種類が決める */
1699
+ marks?: string[];
1589
1700
  }
1590
1701
  /** 2 軸で仕分ける図の軸の名前 (#1294)。 記法の `axes:` と同じ形 */
1591
1702
  interface JsonAxes {
@@ -1612,6 +1723,21 @@ interface JsonStep {
1612
1723
  sub?: string;
1613
1724
  /** 矢印がどの辺から出るか (#1385)。 記法の `side:` と同じ */
1614
1725
  side?: "top" | "right" | "bottom" | "left";
1726
+ /**
1727
+ * 矢印の先の形 (#1462)。 記法の `{ head: triangle }` と同じ。
1728
+ *
1729
+ * 三角 (継ぐ) / 菱 (持つ) / 開いた矢 (使う) / 鳥の足 (多)。
1730
+ * 書かなければ従来どおり塗った三角になる。
1731
+ */
1732
+ head?: EdgeHead;
1733
+ /** 出どころ側の端の形と、両端の塗り (#1466)。 記法の `{ tailHead: diamond }` 等と同じ */
1734
+ tailHead?: EdgeHead;
1735
+ headFill?: EdgeHeadFill;
1736
+ tailHeadFill?: EdgeHeadFill;
1737
+ /** クラス図の関係の語 (#1466)。 書くと端の形 / 塗り / 線種がまとめて決まる */
1738
+ relation?: ClassRelationType;
1739
+ /** 順序図の言づての種類 (#1466)。 `call` / `return` / `fire` */
1740
+ kind?: SequenceMessageKind;
1615
1741
  /**
1616
1742
  * 矢印の色 (#1304)。 記法の `(成功)` と同じく別名 (`成功` / `neutral` 等) も受ける。
1617
1743
  *
@@ -1655,6 +1781,13 @@ interface JsonPhase {
1655
1781
  * 受ける 8 語は `DRAW_WORDS` が持つ。 語と同じ図種で、その段の間に図が起点から現れる。
1656
1782
  */
1657
1783
  draw?: string;
1784
+ /**
1785
+ * 描き終えるまでに段の何割を使うか (#1441)。 記法の `draw: line 0.4` の後半と同じ。
1786
+ *
1787
+ * 0 より大きく 1 以下。 書かなければ段の終わりに描き終わる。 `draw` が無い段に書いても
1788
+ * 何も起きない (描く相手が決まらないため、写す時に外す)。
1789
+ */
1790
+ drawRatio?: number;
1658
1791
  /**
1659
1792
  * 段の中で値を動かす (#1186)。 記法の `tween: name 100 -> 90` と同じ。
1660
1793
  *
@@ -1825,6 +1958,10 @@ declare const diagramJsonSchema: {
1825
1958
  type: string;
1826
1959
  description: string;
1827
1960
  };
1961
+ previous: {
1962
+ type: string;
1963
+ description: string;
1964
+ };
1828
1965
  rows: {
1829
1966
  type: string;
1830
1967
  items: {
@@ -1832,6 +1969,13 @@ declare const diagramJsonSchema: {
1832
1969
  };
1833
1970
  description: string;
1834
1971
  };
1972
+ marks: {
1973
+ type: string;
1974
+ items: {
1975
+ type: string;
1976
+ };
1977
+ description: string;
1978
+ };
1835
1979
  lane: {
1836
1980
  type: string;
1837
1981
  description: string;
@@ -2116,6 +2260,36 @@ declare const diagramJsonSchema: {
2116
2260
  enum: string[];
2117
2261
  description: string;
2118
2262
  };
2263
+ head: {
2264
+ type: string;
2265
+ enum: string[];
2266
+ description: string;
2267
+ };
2268
+ tailHead: {
2269
+ type: string;
2270
+ enum: string[];
2271
+ description: string;
2272
+ };
2273
+ headFill: {
2274
+ type: string;
2275
+ enum: string[];
2276
+ description: string;
2277
+ };
2278
+ tailHeadFill: {
2279
+ type: string;
2280
+ enum: string[];
2281
+ description: string;
2282
+ };
2283
+ relation: {
2284
+ type: string;
2285
+ enum: string[];
2286
+ description: string;
2287
+ };
2288
+ kind: {
2289
+ type: string;
2290
+ enum: string[];
2291
+ description: string;
2292
+ };
2119
2293
  labelOffsetX: {
2120
2294
  type: string;
2121
2295
  description: string;
@@ -2232,6 +2406,12 @@ declare const diagramJsonSchema: {
2232
2406
  enum: string[];
2233
2407
  description: string;
2234
2408
  };
2409
+ drawRatio: {
2410
+ type: string;
2411
+ exclusiveMinimum: number;
2412
+ maximum: number;
2413
+ description: string;
2414
+ };
2235
2415
  tween: {
2236
2416
  type: string;
2237
2417
  description: string;
@@ -2874,6 +3054,36 @@ declare const diagramJsonSchema: {
2874
3054
  pattern: string;
2875
3055
  };
2876
3056
  };
3057
+ reveal: {
3058
+ type: string;
3059
+ enum: string[];
3060
+ description: string;
3061
+ };
3062
+ bands: {
3063
+ type: string;
3064
+ description: string;
3065
+ items: {
3066
+ type: string;
3067
+ required: string[];
3068
+ additionalProperties: boolean;
3069
+ properties: {
3070
+ actor: {
3071
+ type: string;
3072
+ description: string;
3073
+ };
3074
+ from: {
3075
+ type: string;
3076
+ minimum: number;
3077
+ description: string;
3078
+ };
3079
+ to: {
3080
+ type: string;
3081
+ minimum: number;
3082
+ description: string;
3083
+ };
3084
+ };
3085
+ };
3086
+ };
2877
3087
  events: {
2878
3088
  type: string;
2879
3089
  description: string;
@@ -2998,4 +3208,4 @@ interface CompileOpts {
2998
3208
  */
2999
3209
  declare function textDslToDiagram(src: string, opts?: CompileOpts): CdlDiagram;
3000
3210
 
3001
- export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PHASE_ITEM_WORDS, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };
3211
+ export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, DRAW_TARGETS, DRAW_WORDS, type DiagramBoundingBox, type DragonJson, type DslActor, type DslAnimate, type DslDocument, type DslError, type DslGroup, type DslLane, type DslPhase, type DslSet, type DslState, type DslStep, type DslTween, type DslValue, type DslViewport, type FocusEntry, type InputSize, JSONを分解する, type JsonActor, type JsonActorNodeOverride, type JsonAxes, type JsonDslError, type JsonPhase, type JsonStep, type LayoutMode, type LayoutPos, type LintIssue, type LintReport, type LintSeverity, MAX_INPUT_BYTES, MAX_INPUT_ELEMENTS, MAX_PART_SCALE, NODE_KIND_ALIAS, NODE_KIND_VALID, PHASE_ITEM_WORDS, PRESET_TYPES, type PresetType, RELATIVE_GAP_DEFAULT, type RelativeDirection, type RelativePos, TONE_ALIAS, TOP_LEVEL_KEYS, autoFix, compileToCdl, computeDiagramBoundingBox, countBytes, countDiagramElements, countDocElements, describeOversize, describeOversizeSource, diagramJsonSchema, isColorValue, jsonToDiagram, lintDiagram, measureActorBoxes, normalizePartScale, orderByDependency, parseFocusEntry, parseRelativePos, parseTextDsl, parseTextDslV05, partBoxInFrame, partDrawsInDiagram, partIsMeasurable, partRenderSize, partScaleFactor, partTargetScale, partTargetSize, partVisualSize, partsBaseRows, partsGridCenters, pointsOutside, rectsOverlap, resolveRelativePos, stripExternalPaint, stripQuotes, textDslToDiagram, validateDragonJson, writeActorPosition, type トークン, type トークンの種類, 区間に広げる, 記法を分解する };