@cardenelabs/dragon 0.8.0 → 0.9.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.ts CHANGED
@@ -439,6 +439,25 @@ type DslPhase = {
439
439
  sets?: DslSet[];
440
440
  body?: string;
441
441
  badge?: string;
442
+ /**
443
+ * その段で左の起点から描くもの (`draw: line`、 #1312)。
444
+ *
445
+ * 受ける語は今のところ `line` だけ。 折れ線 (`type: line`) の図で、その段の間に線が
446
+ * 左端から右へ伸び、点と値の数字は線の先が届いた時に現れる。
447
+ *
448
+ * **最上位ではなく段に置く**。 記法は動き (`tween` / `set` / `focus` / `badge`) を段に、
449
+ * 静的な性質 (`eyebrow` / `axes`) を最上位に書く分け方を既に持つ。 線が伸びるのは動き。
450
+ *
451
+ * 相手の名前は書かせない = 折れ線は図全体を 1 箱で描くため相手が 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,25 @@ 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
+ *
826
+ * いまは語と図種が同じ綴りだが、**同じものとして扱わない**。 語は書き手が書く名前で、
827
+ * 図種は `type:` が取る値。 片方だけ別名を足したくなった時に、対応が表に残っている形にする。
828
+ */
829
+ declare const DRAW_TARGETS: ReadonlyMap<string, PresetType>;
830
+ /** `draw:` に書ける語。 表から導く (#1314) */
831
+ declare const DRAW_WORDS: ReadonlySet<string>;
794
832
 
795
833
  /**
796
834
  * Text DSL i18n キーワード一覧
@@ -994,6 +1032,45 @@ type StrippedPaint = {
994
1032
  */
995
1033
  declare function stripExternalPaint(diagram: unknown): StrippedPaint[];
996
1034
 
1035
+ /** 分解した部分の種類 (#1310) */
1036
+ type トークンの種類 = "項目名" | "説明文" | "矢印" | "色名" | "値の参照" | "注記";
1037
+ /** 分解した部分 1 つ。 位置は本文の先頭からの文字数 (`slice` にそのまま渡せる) */
1038
+ type トークン = {
1039
+ 種類: トークンの種類;
1040
+ 開始: number;
1041
+ 終わり: number;
1042
+ /** `色名` の時だけ入る、解決後の色の名前。 画面はこれで「その色」 を引く */
1043
+ 色?: Tone;
1044
+ };
1045
+ /**
1046
+ * 記法を分解する (#1310)。
1047
+ *
1048
+ * 行ごとに見る。 記法は行単位で意味が決まるため、行をまたぐ状態を持たない。
1049
+ */
1050
+ declare function 記法を分解する(src: string): トークン[];
1051
+ /**
1052
+ * JSON を分解する (#1310)。
1053
+ *
1054
+ * 記法と違い鍵は英語で、記法の語彙は出ない。 したがって **鍵 / 文字列 / 数を汎用の色で塗る**。
1055
+ *
1056
+ * 例外は `tone` と `color` の値で、こちらは記法と同じ語彙を持つため色名として扱う。
1057
+ * 同じ `"success"` が入口によって別の色になる状態を作らないため。
1058
+ */
1059
+ declare function JSONを分解する(src: string): トークン[];
1060
+ /**
1061
+ * 分解した並びを、本文を覆う区間の列に広げる (#1310)。
1062
+ *
1063
+ * 分解器は色が付く部分だけを返すため、間の文字が抜ける。 画面はそのまま並べると本文が
1064
+ * 欠けるので、**色の付かない部分も種類なしの区間として挟む**。
1065
+ *
1066
+ * 返す区間は本文を過不足なく覆う (連結すると元の本文に戻る)。
1067
+ */
1068
+ declare function 区間に広げる(src: string, tokens: トークン[]): Array<{
1069
+ 文字: string;
1070
+ 種類?: トークンの種類;
1071
+ 色?: Tone;
1072
+ }>;
1073
+
997
1074
  /**
998
1075
  * 図を組み立てる前に、 大きすぎる入力を止める (#1005)。
999
1076
  *
@@ -1121,6 +1198,15 @@ interface DragonJson {
1121
1198
  * 組み立て側が知らせを出す。 そちらは `actors[].eyebrow` に書く。
1122
1199
  */
1123
1200
  eyebrow?: string;
1201
+ /**
1202
+ * 2 軸で仕分ける図 (`type: quadrant`) の軸の名前 (#1294)。 記法の `axes:` と同じ。
1203
+ *
1204
+ * 書かないと「小さい / 大きい」 のままになり、何を判断する図か読めない。 区画の名前
1205
+ * (`右上` 等) は軸の名前から決まる。
1206
+ *
1207
+ * 他の図種には軸が無いため、書かれていたら組み立て側が知らせる。
1208
+ */
1209
+ axes?: JsonAxes;
1124
1210
  /** 登場人物 (必須): 文字列 or { name, kind, ... } object */
1125
1211
  actors: (string | JsonActor)[];
1126
1212
  /** flow step 配列 (必須): { from, to, label, ... } */
@@ -1172,11 +1258,6 @@ interface DragonJson {
1172
1258
  label?: string;
1173
1259
  lanes: string[];
1174
1260
  }>;
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
1261
  }
1181
1262
  interface JsonActor {
1182
1263
  name: string;
@@ -1206,15 +1287,96 @@ interface JsonActor {
1206
1287
  * LLM JSON DSL では nested 明示 = `{ "state": { "v": 50 } }` が natural、 human 側の
1207
1288
  * inline 拡散 pattern (`- arc1: { kind: arc-gauge, v: 50 }`) とは記述形式が分岐する
1208
1289
  * (spec § 2.3 分岐設計、 human = YAML 手書き最適 / LLM = JSON structured 最適)。
1290
+ *
1291
+ * 見本でない箱に書くと誤りとして返す (#1294)。 記法側は読めない項目名として行番号付きで
1292
+ * 知らせるため、黙って捨てると入口によって扱いが変わる。
1209
1293
  */
1210
1294
  state?: Record<string, number | string | boolean>;
1295
+ /**
1296
+ * 箱の色 (#1294)。 記法の `tone:` と同じ。
1297
+ *
1298
+ * 色の名前と別名 (`成功` / `success` 等) を受ける。 見本 (parts) では色ではなく状態の
1299
+ * 上書きとして意味を持つため、記法と同じく見本の箱には効かない。
1300
+ */
1301
+ tone?: Tone | (string & {});
1302
+ /**
1303
+ * 色番号または色の名前 (#1294)。 記法の `色:` / `color:` と同じ。
1304
+ *
1305
+ * `#` で始まる値は色番号として `colorHex` に入り、見本の絵の色を変える。 それ以外は
1306
+ * 色の名前として読む (記法の `splitColorValue` と同じ振り分け)。
1307
+ */
1308
+ color?: string;
1309
+ /**
1310
+ * 工程の並び (`type: gantt`) で、その工程の担当 (#1294)。 記法の `owner:` と同じ。
1311
+ */
1312
+ owner?: string;
1313
+ /**
1314
+ * 工程の並び (`type: gantt`) で、その工程が終わる時期 (#1294)。 記法の `end:` と同じ。
1315
+ *
1316
+ * 値は他の工程が書いた時期のどれかに一致させる。 一致しない値は始まりと同じ位置に落ちる
1317
+ * (記法側と同じ扱い)。
1318
+ */
1319
+ end?: string;
1320
+ /**
1321
+ * 体験の道筋 (`type: journey`) で、その段階が起きる場所 (#1294)。 記法の `touchpoint:` と同じ。
1322
+ */
1323
+ touchpoint?: string;
1324
+ /**
1325
+ * 体験の道筋 (`type: journey`) で、その段階の改善の余地 (#1294)。 記法の `opportunity:` と同じ。
1326
+ */
1327
+ opportunity?: string;
1328
+ /**
1329
+ * 箱を置く絶対座標と大きさ (#1294)。 記法の `posX:` / `posY:` / `posW:` / `posH:` と同じ。
1330
+ *
1331
+ * `pos` (ずらし幅) とは別物。 こちらは auto layout を使わずに位置そのものを決める。
1332
+ */
1333
+ posX?: number;
1334
+ posY?: number;
1335
+ posW?: number;
1336
+ posH?: number;
1337
+ /**
1338
+ * 箱の中の要素ごとに位置と大きさを固定する (#1294)。 記法の `nodes:` と同じ。
1339
+ *
1340
+ * key は箱が作る要素の名前 (`header` / `footer` / `spacer` / `s0` 等)。
1341
+ */
1342
+ nodes?: Record<string, JsonActorNodeOverride>;
1343
+ /**
1344
+ * 見本を何倍で描くか (#1294)。 記法の `scale:` / `倍率:` と同じ。
1345
+ *
1346
+ * 見本 (parts) にしか効かない。 見本でない箱に書くと誤りとして返す (記法側も同じく
1347
+ * 読めない項目名として知らせる)。
1348
+ */
1349
+ scale?: number;
1350
+ }
1351
+ /** 2 軸で仕分ける図の軸の名前 (#1294)。 記法の `axes:` と同じ形 */
1352
+ interface JsonAxes {
1353
+ x?: {
1354
+ left?: string;
1355
+ right?: string;
1356
+ };
1357
+ y?: {
1358
+ bottom?: string;
1359
+ top?: string;
1360
+ };
1361
+ }
1362
+ /** 箱の中の要素 1 つ分の位置と大きさ (#1294)。 記法の `nodes: { header: { ... } }` と同じ */
1363
+ interface JsonActorNodeOverride {
1364
+ posX?: number;
1365
+ posY?: number;
1366
+ posW?: number;
1367
+ posH?: number;
1211
1368
  }
1212
1369
  interface JsonStep {
1213
1370
  from: string;
1214
1371
  to: string;
1215
1372
  label: string;
1216
1373
  sub?: string;
1217
- tone?: Tone;
1374
+ /**
1375
+ * 矢印の色 (#1304)。 記法の `(成功)` と同じく別名 (`成功` / `neutral` 等) も受ける。
1376
+ *
1377
+ * `string & {}` は箱の `tone` と同じ idiom = 正規の色名を補完に出しつつ別名も通す。
1378
+ */
1379
+ tone?: Tone | (string & {});
1218
1380
  style?: EdgeStyle;
1219
1381
  guard?: string;
1220
1382
  cardinality?: string;
@@ -1239,6 +1401,13 @@ interface JsonPhase {
1239
1401
  body?: string;
1240
1402
  /** badge label */
1241
1403
  badge?: string;
1404
+ /**
1405
+ * その段で左の起点から描くもの (#1312)。 記法の `draw: line` と同じ。
1406
+ *
1407
+ * 受ける語は `line` だけ (`DRAW_WORDS`)。 折れ線の図で、その段の間に線が左端から
1408
+ * 右へ伸びる。
1409
+ */
1410
+ draw?: string;
1242
1411
  /**
1243
1412
  * 段の中で値を動かす (#1186)。 記法の `tween: name 100 -> 90` と同じ。
1244
1413
  *
@@ -1341,6 +1510,37 @@ declare const diagramJsonSchema: {
1341
1510
  type: string;
1342
1511
  description: string;
1343
1512
  };
1513
+ axes: {
1514
+ type: string;
1515
+ additionalProperties: boolean;
1516
+ description: string;
1517
+ properties: {
1518
+ x: {
1519
+ type: string;
1520
+ additionalProperties: boolean;
1521
+ properties: {
1522
+ left: {
1523
+ type: string;
1524
+ };
1525
+ right: {
1526
+ type: string;
1527
+ };
1528
+ };
1529
+ };
1530
+ y: {
1531
+ type: string;
1532
+ additionalProperties: boolean;
1533
+ properties: {
1534
+ bottom: {
1535
+ type: string;
1536
+ };
1537
+ top: {
1538
+ type: string;
1539
+ };
1540
+ };
1541
+ };
1542
+ };
1543
+ };
1344
1544
  actors: {
1345
1545
  type: string;
1346
1546
  minItems: number;
@@ -1402,6 +1602,101 @@ declare const diagramJsonSchema: {
1402
1602
  type: string;
1403
1603
  description: string;
1404
1604
  };
1605
+ state: {
1606
+ type: string;
1607
+ description: string;
1608
+ additionalProperties: {
1609
+ type: string[];
1610
+ };
1611
+ };
1612
+ tone: {
1613
+ type: string;
1614
+ description: string;
1615
+ enum: string[];
1616
+ };
1617
+ color: {
1618
+ type: string;
1619
+ description: string;
1620
+ anyOf: ({
1621
+ enum: string[];
1622
+ pattern?: undefined;
1623
+ } | {
1624
+ pattern: string;
1625
+ enum?: undefined;
1626
+ })[];
1627
+ };
1628
+ owner: {
1629
+ type: string;
1630
+ description: string;
1631
+ };
1632
+ end: {
1633
+ type: string;
1634
+ description: string;
1635
+ };
1636
+ touchpoint: {
1637
+ type: string;
1638
+ description: string;
1639
+ };
1640
+ opportunity: {
1641
+ type: string;
1642
+ description: string;
1643
+ };
1644
+ posX: {
1645
+ type: string;
1646
+ description: string;
1647
+ };
1648
+ posY: {
1649
+ type: string;
1650
+ description: string;
1651
+ };
1652
+ posW: {
1653
+ type: string;
1654
+ description: string;
1655
+ };
1656
+ posH: {
1657
+ type: string;
1658
+ description: string;
1659
+ };
1660
+ nodes: {
1661
+ type: string;
1662
+ description: string;
1663
+ additionalProperties: {
1664
+ type: string;
1665
+ additionalProperties: boolean;
1666
+ properties: {
1667
+ posX: {
1668
+ type: string;
1669
+ };
1670
+ posY: {
1671
+ type: string;
1672
+ };
1673
+ posW: {
1674
+ type: string;
1675
+ };
1676
+ posH: {
1677
+ type: string;
1678
+ };
1679
+ };
1680
+ };
1681
+ };
1682
+ scale: {
1683
+ type: string;
1684
+ description: string;
1685
+ };
1686
+ pos: {
1687
+ type: string;
1688
+ additionalProperties: boolean;
1689
+ description: string;
1690
+ required: string[];
1691
+ properties: {
1692
+ x: {
1693
+ type: string;
1694
+ };
1695
+ y: {
1696
+ type: string;
1697
+ };
1698
+ };
1699
+ };
1405
1700
  };
1406
1701
  description?: undefined;
1407
1702
  })[];
@@ -1461,6 +1756,20 @@ declare const diagramJsonSchema: {
1461
1756
  type: string;
1462
1757
  description: string;
1463
1758
  };
1759
+ pos: {
1760
+ type: string;
1761
+ additionalProperties: boolean;
1762
+ description: string;
1763
+ required: string[];
1764
+ properties: {
1765
+ x: {
1766
+ type: string;
1767
+ };
1768
+ y: {
1769
+ type: string;
1770
+ };
1771
+ };
1772
+ };
1464
1773
  };
1465
1774
  };
1466
1775
  };
@@ -1528,6 +1837,11 @@ declare const diagramJsonSchema: {
1528
1837
  type: string;
1529
1838
  description: string;
1530
1839
  };
1840
+ draw: {
1841
+ type: string;
1842
+ enum: string[];
1843
+ description: string;
1844
+ };
1531
1845
  tween: {
1532
1846
  type: string;
1533
1847
  description: string;
@@ -1589,6 +1903,10 @@ declare const diagramJsonSchema: {
1589
1903
  type: string;
1590
1904
  minimum: number;
1591
1905
  };
1906
+ scale: {
1907
+ type: string;
1908
+ description: string;
1909
+ };
1592
1910
  };
1593
1911
  };
1594
1912
  lanes: {
@@ -1614,6 +1932,20 @@ declare const diagramJsonSchema: {
1614
1932
  lifeline: {
1615
1933
  type: string;
1616
1934
  };
1935
+ pos: {
1936
+ type: string;
1937
+ additionalProperties: boolean;
1938
+ description: string;
1939
+ required: string[];
1940
+ properties: {
1941
+ x: {
1942
+ type: string;
1943
+ };
1944
+ y: {
1945
+ type: string;
1946
+ };
1947
+ };
1948
+ };
1617
1949
  };
1618
1950
  };
1619
1951
  };
@@ -1685,4 +2017,4 @@ interface CompileOpts {
1685
2017
  */
1686
2018
  declare function textDslToDiagram(src: string, opts?: CompileOpts): CdlDiagram;
1687
2019
 
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 };
2020
+ 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 トークンの種類, 区間に広げる, 記法を分解する };