@cardenelabs/dragon 0.8.0 → 0.10.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
@@ -439,6 +439,25 @@ type DslPhase = {
439
439
  sets?: DslSet[];
440
440
  body?: string;
441
441
  badge?: string;
442
+ /**
443
+ * その段で起点から描くもの (#1312 / #1314 / #1318)。
444
+ *
445
+ * 受ける語は `line` / `bar` / `pie` / `journey` / `mind` / `tree` / `gantt` / `funnel`。
446
+ * 語と同じ図種で、その段の間に線・棒・扇・枝・帯・段が各図の起点から現れる。
447
+ *
448
+ * **最上位ではなく段に置く**。 記法は動き (`tween` / `set` / `focus` / `badge`) を段に、
449
+ * 静的な性質 (`eyebrow` / `axes`) を最上位に書く分け方を既に持つ。 起点から描くのは動き。
450
+ *
451
+ * 相手の名前は書かせない = 対象の 8 図種はいずれも図全体を 1 箱で描くため相手が決まる。
452
+ */
453
+ draw?: string;
454
+ /**
455
+ * `draw` を書いた行 (#1312)。 知らせの行番号に使う。
456
+ *
457
+ * 段の `pos` は `- step:` の行を指すため、そこを使うと「段の 3 行目に書いた `draw` が
458
+ * 効かない」 を段の先頭行として知らせることになる。
459
+ */
460
+ drawPos?: Position;
442
461
  pos: Position;
443
462
  };
444
463
  /** state lerp (遷移) */
@@ -517,7 +536,7 @@ interface CompileToCdlOpts {
517
536
  }
518
537
  /** 図は出せるが書いた通りにならなかった、 という知らせ。 */
519
538
  type CompileNotice = {
520
- 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";
539
+ 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";
521
540
  /** 対象の名前。 光らせる相手なら書かれた指定そのまま */
522
541
  actor: string;
523
542
  /** 書かれていた行 */
@@ -791,6 +810,33 @@ declare function parseTextDslV05(src: string): V05ParseResult;
791
810
  * 画面側も同じ関数を使う (#1028) = 別々に持つと、片方だけが読める本文ができる。
792
811
  */
793
812
  declare function stripQuotes(s: string): string;
813
+ /**
814
+ * `draw:` に書ける語と、その語が効く図種 (#1312 / #1314)。
815
+ *
816
+ * **語と図種の対応をここ 1 箇所で持つ**。 受ける語の一覧 (`DRAW_WORDS`) も、組み立て側が見る
817
+ * 図種の一覧 (`DRAWABLE_DOC_TYPES`) も、この表から導く。 3 つを別々に並べると、語を足した時に
818
+ * どれかが古いまま残る (#1310 / #1304 で 3 度直した形)。
819
+ *
820
+ * | 語 | 図種 | 起点 |
821
+ * |---|---|---|
822
+ * | `line` | `line` | 左端から右へ線が伸びる |
823
+ * | `bar` | `bar` | 横軸から上へ棒が伸びる |
824
+ * | `pie` | `pie` | 12 時から時計回りに扇が開く |
825
+ * | `journey` | `journey` | 左端から右へ気持ちの線が伸びる |
826
+ * | `mind` | `mind` | 中心から外へ枝が伸びる |
827
+ * | `tree` | `tree` | 根から下へ枝が伸びる |
828
+ * | `gantt` | `gantt` | 各帯の始端から右へ帯が伸びる |
829
+ * | `funnel` | `funnel` | 上端から順に段が積まれる |
830
+ *
831
+ * `quadrant` は入れない。 4 つの区画に項目を置く図で **項目に順序が無く**、起点を決められない
832
+ * (順番を書いた順で決めると、動きが図の意味を持たない)。
833
+ *
834
+ * いまは語と図種が同じ綴りだが、**同じものとして扱わない**。 語は書き手が書く名前で、
835
+ * 図種は `type:` が取る値。 片方だけ別名を足したくなった時に、対応が表に残っている形にする。
836
+ */
837
+ declare const DRAW_TARGETS: ReadonlyMap<string, PresetType>;
838
+ /** `draw:` に書ける語。 表から導く (#1314) */
839
+ declare const DRAW_WORDS: ReadonlySet<string>;
794
840
 
795
841
  /**
796
842
  * Text DSL i18n キーワード一覧
@@ -994,6 +1040,45 @@ type StrippedPaint = {
994
1040
  */
995
1041
  declare function stripExternalPaint(diagram: unknown): StrippedPaint[];
996
1042
 
1043
+ /** 分解した部分の種類 (#1310) */
1044
+ type トークンの種類 = "項目名" | "説明文" | "矢印" | "色名" | "値の参照" | "注記";
1045
+ /** 分解した部分 1 つ。 位置は本文の先頭からの文字数 (`slice` にそのまま渡せる) */
1046
+ type トークン = {
1047
+ 種類: トークンの種類;
1048
+ 開始: number;
1049
+ 終わり: number;
1050
+ /** `色名` の時だけ入る、解決後の色の名前。 画面はこれで「その色」 を引く */
1051
+ 色?: Tone;
1052
+ };
1053
+ /**
1054
+ * 記法を分解する (#1310)。
1055
+ *
1056
+ * 行ごとに見る。 記法は行単位で意味が決まるため、行をまたぐ状態を持たない。
1057
+ */
1058
+ declare function 記法を分解する(src: string): トークン[];
1059
+ /**
1060
+ * JSON を分解する (#1310)。
1061
+ *
1062
+ * 記法と違い鍵は英語で、記法の語彙は出ない。 したがって **鍵 / 文字列 / 数を汎用の色で塗る**。
1063
+ *
1064
+ * 例外は `tone` と `color` の値で、こちらは記法と同じ語彙を持つため色名として扱う。
1065
+ * 同じ `"success"` が入口によって別の色になる状態を作らないため。
1066
+ */
1067
+ declare function JSONを分解する(src: string): トークン[];
1068
+ /**
1069
+ * 分解した並びを、本文を覆う区間の列に広げる (#1310)。
1070
+ *
1071
+ * 分解器は色が付く部分だけを返すため、間の文字が抜ける。 画面はそのまま並べると本文が
1072
+ * 欠けるので、**色の付かない部分も種類なしの区間として挟む**。
1073
+ *
1074
+ * 返す区間は本文を過不足なく覆う (連結すると元の本文に戻る)。
1075
+ */
1076
+ declare function 区間に広げる(src: string, tokens: トークン[]): Array<{
1077
+ 文字: string;
1078
+ 種類?: トークンの種類;
1079
+ 色?: Tone;
1080
+ }>;
1081
+
997
1082
  /**
998
1083
  * 図を組み立てる前に、 大きすぎる入力を止める (#1005)。
999
1084
  *
@@ -1121,6 +1206,15 @@ interface DragonJson {
1121
1206
  * 組み立て側が知らせを出す。 そちらは `actors[].eyebrow` に書く。
1122
1207
  */
1123
1208
  eyebrow?: string;
1209
+ /**
1210
+ * 2 軸で仕分ける図 (`type: quadrant`) の軸の名前 (#1294)。 記法の `axes:` と同じ。
1211
+ *
1212
+ * 書かないと「小さい / 大きい」 のままになり、何を判断する図か読めない。 区画の名前
1213
+ * (`右上` 等) は軸の名前から決まる。
1214
+ *
1215
+ * 他の図種には軸が無いため、書かれていたら組み立て側が知らせる。
1216
+ */
1217
+ axes?: JsonAxes;
1124
1218
  /** 登場人物 (必須): 文字列 or { name, kind, ... } object */
1125
1219
  actors: (string | JsonActor)[];
1126
1220
  /** flow step 配列 (必須): { from, to, label, ... } */
@@ -1172,11 +1266,6 @@ interface DragonJson {
1172
1266
  label?: string;
1173
1267
  lanes: string[];
1174
1268
  }>;
1175
- /**
1176
- * canvas pivot (CAR-1693 Phase 1) diagram-level layout mode。 "auto" (default) は catalog 100+
1177
- * backward compat、 "manual" は Phase 4 で drag → pos: 保存の完全 manual mode として使う予定。
1178
- */
1179
- layout?: LayoutMode;
1180
1269
  }
1181
1270
  interface JsonActor {
1182
1271
  name: string;
@@ -1206,15 +1295,96 @@ interface JsonActor {
1206
1295
  * LLM JSON DSL では nested 明示 = `{ "state": { "v": 50 } }` が natural、 human 側の
1207
1296
  * inline 拡散 pattern (`- arc1: { kind: arc-gauge, v: 50 }`) とは記述形式が分岐する
1208
1297
  * (spec § 2.3 分岐設計、 human = YAML 手書き最適 / LLM = JSON structured 最適)。
1298
+ *
1299
+ * 見本でない箱に書くと誤りとして返す (#1294)。 記法側は読めない項目名として行番号付きで
1300
+ * 知らせるため、黙って捨てると入口によって扱いが変わる。
1209
1301
  */
1210
1302
  state?: Record<string, number | string | boolean>;
1303
+ /**
1304
+ * 箱の色 (#1294)。 記法の `tone:` と同じ。
1305
+ *
1306
+ * 色の名前と別名 (`成功` / `success` 等) を受ける。 見本 (parts) では色ではなく状態の
1307
+ * 上書きとして意味を持つため、記法と同じく見本の箱には効かない。
1308
+ */
1309
+ tone?: Tone | (string & {});
1310
+ /**
1311
+ * 色番号または色の名前 (#1294)。 記法の `色:` / `color:` と同じ。
1312
+ *
1313
+ * `#` で始まる値は色番号として `colorHex` に入り、見本の絵の色を変える。 それ以外は
1314
+ * 色の名前として読む (記法の `splitColorValue` と同じ振り分け)。
1315
+ */
1316
+ color?: string;
1317
+ /**
1318
+ * 工程の並び (`type: gantt`) で、その工程の担当 (#1294)。 記法の `owner:` と同じ。
1319
+ */
1320
+ owner?: string;
1321
+ /**
1322
+ * 工程の並び (`type: gantt`) で、その工程が終わる時期 (#1294)。 記法の `end:` と同じ。
1323
+ *
1324
+ * 値は他の工程が書いた時期のどれかに一致させる。 一致しない値は始まりと同じ位置に落ちる
1325
+ * (記法側と同じ扱い)。
1326
+ */
1327
+ end?: string;
1328
+ /**
1329
+ * 体験の道筋 (`type: journey`) で、その段階が起きる場所 (#1294)。 記法の `touchpoint:` と同じ。
1330
+ */
1331
+ touchpoint?: string;
1332
+ /**
1333
+ * 体験の道筋 (`type: journey`) で、その段階の改善の余地 (#1294)。 記法の `opportunity:` と同じ。
1334
+ */
1335
+ opportunity?: string;
1336
+ /**
1337
+ * 箱を置く絶対座標と大きさ (#1294)。 記法の `posX:` / `posY:` / `posW:` / `posH:` と同じ。
1338
+ *
1339
+ * `pos` (ずらし幅) とは別物。 こちらは auto layout を使わずに位置そのものを決める。
1340
+ */
1341
+ posX?: number;
1342
+ posY?: number;
1343
+ posW?: number;
1344
+ posH?: number;
1345
+ /**
1346
+ * 箱の中の要素ごとに位置と大きさを固定する (#1294)。 記法の `nodes:` と同じ。
1347
+ *
1348
+ * key は箱が作る要素の名前 (`header` / `footer` / `spacer` / `s0` 等)。
1349
+ */
1350
+ nodes?: Record<string, JsonActorNodeOverride>;
1351
+ /**
1352
+ * 見本を何倍で描くか (#1294)。 記法の `scale:` / `倍率:` と同じ。
1353
+ *
1354
+ * 見本 (parts) にしか効かない。 見本でない箱に書くと誤りとして返す (記法側も同じく
1355
+ * 読めない項目名として知らせる)。
1356
+ */
1357
+ scale?: number;
1358
+ }
1359
+ /** 2 軸で仕分ける図の軸の名前 (#1294)。 記法の `axes:` と同じ形 */
1360
+ interface JsonAxes {
1361
+ x?: {
1362
+ left?: string;
1363
+ right?: string;
1364
+ };
1365
+ y?: {
1366
+ bottom?: string;
1367
+ top?: string;
1368
+ };
1369
+ }
1370
+ /** 箱の中の要素 1 つ分の位置と大きさ (#1294)。 記法の `nodes: { header: { ... } }` と同じ */
1371
+ interface JsonActorNodeOverride {
1372
+ posX?: number;
1373
+ posY?: number;
1374
+ posW?: number;
1375
+ posH?: number;
1211
1376
  }
1212
1377
  interface JsonStep {
1213
1378
  from: string;
1214
1379
  to: string;
1215
1380
  label: string;
1216
1381
  sub?: string;
1217
- tone?: Tone;
1382
+ /**
1383
+ * 矢印の色 (#1304)。 記法の `(成功)` と同じく別名 (`成功` / `neutral` 等) も受ける。
1384
+ *
1385
+ * `string & {}` は箱の `tone` と同じ idiom = 正規の色名を補完に出しつつ別名も通す。
1386
+ */
1387
+ tone?: Tone | (string & {});
1218
1388
  style?: EdgeStyle;
1219
1389
  guard?: string;
1220
1390
  cardinality?: string;
@@ -1239,6 +1409,12 @@ interface JsonPhase {
1239
1409
  body?: string;
1240
1410
  /** badge label */
1241
1411
  badge?: string;
1412
+ /**
1413
+ * その段で起点から描くもの (#1312 / #1314 / #1318)。 記法の `draw:` と同じ。
1414
+ *
1415
+ * 受ける 8 語は `DRAW_WORDS` が持つ。 語と同じ図種で、その段の間に図が起点から現れる。
1416
+ */
1417
+ draw?: string;
1242
1418
  /**
1243
1419
  * 段の中で値を動かす (#1186)。 記法の `tween: name 100 -> 90` と同じ。
1244
1420
  *
@@ -1341,6 +1517,37 @@ declare const diagramJsonSchema: {
1341
1517
  type: string;
1342
1518
  description: string;
1343
1519
  };
1520
+ axes: {
1521
+ type: string;
1522
+ additionalProperties: boolean;
1523
+ description: string;
1524
+ properties: {
1525
+ x: {
1526
+ type: string;
1527
+ additionalProperties: boolean;
1528
+ properties: {
1529
+ left: {
1530
+ type: string;
1531
+ };
1532
+ right: {
1533
+ type: string;
1534
+ };
1535
+ };
1536
+ };
1537
+ y: {
1538
+ type: string;
1539
+ additionalProperties: boolean;
1540
+ properties: {
1541
+ bottom: {
1542
+ type: string;
1543
+ };
1544
+ top: {
1545
+ type: string;
1546
+ };
1547
+ };
1548
+ };
1549
+ };
1550
+ };
1344
1551
  actors: {
1345
1552
  type: string;
1346
1553
  minItems: number;
@@ -1402,6 +1609,101 @@ declare const diagramJsonSchema: {
1402
1609
  type: string;
1403
1610
  description: string;
1404
1611
  };
1612
+ state: {
1613
+ type: string;
1614
+ description: string;
1615
+ additionalProperties: {
1616
+ type: string[];
1617
+ };
1618
+ };
1619
+ tone: {
1620
+ type: string;
1621
+ description: string;
1622
+ enum: string[];
1623
+ };
1624
+ color: {
1625
+ type: string;
1626
+ description: string;
1627
+ anyOf: ({
1628
+ enum: string[];
1629
+ pattern?: undefined;
1630
+ } | {
1631
+ pattern: string;
1632
+ enum?: undefined;
1633
+ })[];
1634
+ };
1635
+ owner: {
1636
+ type: string;
1637
+ description: string;
1638
+ };
1639
+ end: {
1640
+ type: string;
1641
+ description: string;
1642
+ };
1643
+ touchpoint: {
1644
+ type: string;
1645
+ description: string;
1646
+ };
1647
+ opportunity: {
1648
+ type: string;
1649
+ description: string;
1650
+ };
1651
+ posX: {
1652
+ type: string;
1653
+ description: string;
1654
+ };
1655
+ posY: {
1656
+ type: string;
1657
+ description: string;
1658
+ };
1659
+ posW: {
1660
+ type: string;
1661
+ description: string;
1662
+ };
1663
+ posH: {
1664
+ type: string;
1665
+ description: string;
1666
+ };
1667
+ nodes: {
1668
+ type: string;
1669
+ description: string;
1670
+ additionalProperties: {
1671
+ type: string;
1672
+ additionalProperties: boolean;
1673
+ properties: {
1674
+ posX: {
1675
+ type: string;
1676
+ };
1677
+ posY: {
1678
+ type: string;
1679
+ };
1680
+ posW: {
1681
+ type: string;
1682
+ };
1683
+ posH: {
1684
+ type: string;
1685
+ };
1686
+ };
1687
+ };
1688
+ };
1689
+ scale: {
1690
+ type: string;
1691
+ description: string;
1692
+ };
1693
+ pos: {
1694
+ type: string;
1695
+ additionalProperties: boolean;
1696
+ description: string;
1697
+ required: string[];
1698
+ properties: {
1699
+ x: {
1700
+ type: string;
1701
+ };
1702
+ y: {
1703
+ type: string;
1704
+ };
1705
+ };
1706
+ };
1405
1707
  };
1406
1708
  description?: undefined;
1407
1709
  })[];
@@ -1461,6 +1763,20 @@ declare const diagramJsonSchema: {
1461
1763
  type: string;
1462
1764
  description: string;
1463
1765
  };
1766
+ pos: {
1767
+ type: string;
1768
+ additionalProperties: boolean;
1769
+ description: string;
1770
+ required: string[];
1771
+ properties: {
1772
+ x: {
1773
+ type: string;
1774
+ };
1775
+ y: {
1776
+ type: string;
1777
+ };
1778
+ };
1779
+ };
1464
1780
  };
1465
1781
  };
1466
1782
  };
@@ -1528,6 +1844,11 @@ declare const diagramJsonSchema: {
1528
1844
  type: string;
1529
1845
  description: string;
1530
1846
  };
1847
+ draw: {
1848
+ type: string;
1849
+ enum: string[];
1850
+ description: string;
1851
+ };
1531
1852
  tween: {
1532
1853
  type: string;
1533
1854
  description: string;
@@ -1589,6 +1910,10 @@ declare const diagramJsonSchema: {
1589
1910
  type: string;
1590
1911
  minimum: number;
1591
1912
  };
1913
+ scale: {
1914
+ type: string;
1915
+ description: string;
1916
+ };
1592
1917
  };
1593
1918
  };
1594
1919
  lanes: {
@@ -1614,6 +1939,20 @@ declare const diagramJsonSchema: {
1614
1939
  lifeline: {
1615
1940
  type: string;
1616
1941
  };
1942
+ pos: {
1943
+ type: string;
1944
+ additionalProperties: boolean;
1945
+ description: string;
1946
+ required: string[];
1947
+ properties: {
1948
+ x: {
1949
+ type: string;
1950
+ };
1951
+ y: {
1952
+ type: string;
1953
+ };
1954
+ };
1955
+ };
1617
1956
  };
1618
1957
  };
1619
1958
  };
@@ -1685,4 +2024,4 @@ interface CompileOpts {
1685
2024
  */
1686
2025
  declare function textDslToDiagram(src: string, opts?: CompileOpts): CdlDiagram;
1687
2026
 
1688
- export { type AnchorBox, type CompileNotice, type CompileOpts, DIAGRAM_BOUNDARY_PADDING, 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, type JsonActor, 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, 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 };
2027
+ 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, 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 トークンの種類, 区間に広げる, 記法を分解する };