@cardenelabs/dragon 0.34.0 → 0.35.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/README.md +39 -720
- package/dist/cli.cjs +4529 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +4523 -0
- package/dist/cli.js.map +1 -0
- package/dist/export.cjs +3912 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +36 -0
- package/dist/export.d.ts +36 -0
- package/dist/export.js +3907 -0
- package/dist/export.js.map +1 -0
- package/dist/fonts.cjs +7 -0
- package/dist/fonts.cjs.map +1 -0
- package/dist/fonts.js +4 -0
- package/dist/fonts.js.map +1 -0
- package/dist/index.cjs +4105 -20356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -5522
- package/dist/index.d.ts +227 -5522
- package/dist/index.js +4091 -20283
- package/dist/index.js.map +1 -1
- package/dist/player.global.js +2 -0
- package/dist/schema-BBWfniwH.d.cts +112 -0
- package/dist/schema-BBWfniwH.d.ts +112 -0
- package/package.json +39 -24
- package/src/cli.ts +237 -0
- package/src/export/capture.ts +277 -0
- package/src/export/fonts.ts +68 -0
- package/src/export/html.ts +32 -0
- package/src/export/index.ts +146 -0
- package/src/field-messages.ts +104 -0
- package/src/figure-text.ts +42 -0
- package/src/index.ts +30 -283
- package/src/layout/architecture.ts +381 -0
- package/src/layout/measure.ts +21 -0
- package/src/layout/scene.ts +353 -0
- package/src/layout/sequence.ts +189 -0
- package/src/load-fonts.ts +8 -0
- package/src/look/fonts.ts +33 -0
- package/src/look/palettes.json +209 -0
- package/src/look/values.ts +155 -0
- package/src/markdown.ts +35 -0
- package/src/messages.ts +122 -0
- package/src/parser.ts +342 -310
- package/src/player-global.ts +4 -0
- package/src/player.ts +271 -0
- package/src/printer.ts +76 -0
- package/src/render/icons.ts +41 -0
- package/src/render/motion.ts +106 -0
- package/src/render/parts.ts +279 -0
- package/src/render/svg.ts +341 -0
- package/src/schema.ts +161 -16
- package/src/schemas/diagram.schema.json +150 -0
- package/src/schemas/validate-diagram.d.ts +12 -0
- package/src/schemas/validate-diagram.js +8 -0
- package/src/timeline.ts +166 -0
- package/src/tokenize.ts +20 -281
- package/src/version.ts +55 -0
- package/src/view.ts +16 -0
- package/src/words.ts +79 -0
- package/examples/quick-start.md +0 -142
- package/src/canvas-bounds.ts +0 -52
- package/src/color.ts +0 -197
- package/src/compile/actor-ids.ts +0 -297
- package/src/compile/actor-option-notice.ts +0 -379
- package/src/compile/actors.ts +0 -103
- package/src/compile/c4.ts +0 -74
- package/src/compile/chain.ts +0 -93
- package/src/compile/chart-fields.ts +0 -193
- package/src/compile/deep-rewrite.ts +0 -30
- package/src/compile/derived-source.ts +0 -18
- package/src/compile/direction.ts +0 -102
- package/src/compile/edge-option-notice.ts +0 -112
- package/src/compile/er-relation.ts +0 -200
- package/src/compile/flow.ts +0 -54
- package/src/compile/flowchart.ts +0 -344
- package/src/compile/funnel.ts +0 -87
- package/src/compile/gantt.ts +0 -337
- package/src/compile/generic.ts +0 -696
- package/src/compile/hierarchy.ts +0 -92
- package/src/compile/journey.ts +0 -93
- package/src/compile/kinds.ts +0 -139
- package/src/compile/lanes.ts +0 -138
- package/src/compile/metro.ts +0 -271
- package/src/compile/mind.ts +0 -393
- package/src/compile/node-title.ts +0 -24
- package/src/compile/notice.ts +0 -141
- package/src/compile/order.ts +0 -57
- package/src/compile/parts-lookup.ts +0 -17
- package/src/compile/parts.ts +0 -2709
- package/src/compile/placement-apply.ts +0 -689
- package/src/compile/placement.ts +0 -15
- package/src/compile/quadrant.ts +0 -265
- package/src/compile/record.ts +0 -75
- package/src/compile/row-marks.ts +0 -128
- package/src/compile/rows.ts +0 -40
- package/src/compile/sequence.ts +0 -305
- package/src/compile/slug.ts +0 -37
- package/src/compile/stages.ts +0 -247
- package/src/compile/subtitle.ts +0 -35
- package/src/compile/swimlane-marks.ts +0 -87
- package/src/compile/swimlane.ts +0 -82
- package/src/compile/timeline.ts +0 -213
- package/src/compile/topology.ts +0 -44
- package/src/compile/tree.ts +0 -69
- package/src/compile/value-chart.ts +0 -337
- package/src/compile/values.ts +0 -432
- package/src/compile/word-state.ts +0 -82
- package/src/compile.ts +0 -3168
- package/src/focus.ts +0 -46
- package/src/input-size.ts +0 -181
- package/src/json-line-map.ts +0 -30
- package/src/json-parser.ts +0 -4306
- package/src/keywords.ts +0 -417
- package/src/near-name.ts +0 -42
- package/src/notation-lint.ts +0 -342
- package/src/relative-pos.ts +0 -251
- package/src/schemas/diagram.json +0 -3088
- package/src/types.ts +0 -1009
- package/src/v05/index.ts +0 -9
- package/src/v05/input-table.generated.ts +0 -138
- package/src/v05/parser-types.ts +0 -32
- package/src/v05/parser.ts +0 -6668
- package/src/v05/readout-table.generated.ts +0 -1088
- package/src/v05/removed-syntax.ts +0 -115
- package/src/value-syntax.ts +0 -313
- package/src/write-position.ts +0 -270
package/src/compile/hierarchy.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { DslActor, DslDocument } from "../types";
|
|
2
|
-
import { 箱の題 } from "./node-title";
|
|
3
|
-
import { slugify } from "./slug";
|
|
4
|
-
/**
|
|
5
|
-
* 親子の木を扱う小道具 (#2030 で `compile.ts` から移した)。
|
|
6
|
-
*
|
|
7
|
-
* `type: tree` と `type: mind` の 2 図種が使う。 同じ本文を書いた時に、図種を変えただけで
|
|
8
|
-
* 親子の解釈が変わらないようにするため、規則を 1 箇所に置く。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 矢印から親子を決める (#1251)。
|
|
13
|
-
*
|
|
14
|
-
* 矢印の先が子で、 どこからも指されない名前が根になる。
|
|
15
|
-
*
|
|
16
|
-
* **黙って上書きしない**。 同じ子に 2 本来たら後勝ちで消えるし、 書いていない名前を指した
|
|
17
|
-
* 矢印は無い親を作る。 どちらも図が静かに変わるので伝える。
|
|
18
|
-
*
|
|
19
|
-
* 親を辿って自分に戻る形は木にならないため、 その枝を切って伝える。
|
|
20
|
-
*/
|
|
21
|
-
export function 矢印から親を決める(
|
|
22
|
-
doc: DslDocument,
|
|
23
|
-
図種: "tree" | "mind",
|
|
24
|
-
名前: ReadonlySet<string>,
|
|
25
|
-
伝える: (名: string, message: string, line?: number) => void,
|
|
26
|
-
): Map<string, string> {
|
|
27
|
-
const 親 = new Map<string, string>();
|
|
28
|
-
for (const f of doc.flow) {
|
|
29
|
-
const 子 = slugify(f.to);
|
|
30
|
-
const 親名 = slugify(f.from);
|
|
31
|
-
if (!名前.has(親名)) {
|
|
32
|
-
伝える(
|
|
33
|
-
f.from,
|
|
34
|
-
`type: ${図種} で書いていない名前を親にしています: ${f.from} -> ${f.to}`,
|
|
35
|
-
f.pos?.line ?? 0,
|
|
36
|
-
);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
// 子の側も見る。 書いていない名前への矢印は、 黙って捨てると図から関係が消える
|
|
40
|
-
if (!名前.has(子)) {
|
|
41
|
-
伝える(
|
|
42
|
-
f.to,
|
|
43
|
-
`type: ${図種} で書いていない名前を子にしています: ${f.from} -> ${f.to}`,
|
|
44
|
-
f.pos?.line ?? 0,
|
|
45
|
-
);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (子 === 親名) {
|
|
49
|
-
伝える(f.to, `type: ${図種} で自分を親にしています: ${f.to}`, f.pos?.line ?? 0);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const 既存 = 親.get(子);
|
|
53
|
-
if (既存 !== undefined && 既存 !== 親名) {
|
|
54
|
-
伝える(
|
|
55
|
-
f.to,
|
|
56
|
-
`type: ${図種} で ${f.to} に親が 2 つあります (後の ${f.from} は使いません)`,
|
|
57
|
-
f.pos?.line ?? 0,
|
|
58
|
-
);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
親.set(子, 親名);
|
|
62
|
-
}
|
|
63
|
-
// 親を辿って自分に戻る形は木にならない。 その枝を切って伝える
|
|
64
|
-
for (const 子 of [...親.keys()]) {
|
|
65
|
-
const 見た = new Set<string>([子]);
|
|
66
|
-
let p2 = 親.get(子);
|
|
67
|
-
while (p2 !== undefined) {
|
|
68
|
-
if (見た.has(p2)) {
|
|
69
|
-
伝える(子, `type: ${図種} で親を辿ると輪になります (${子} の親を外しました)`);
|
|
70
|
-
親.delete(子);
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
見た.add(p2);
|
|
74
|
-
p2 = 親.get(p2);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return 親;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 放射と木の箱に出す名前と補足 (#1332)。
|
|
82
|
-
*
|
|
83
|
-
* **連結しない**。 描画側は名前と補足を別々に受け取れば箱の中で 2 行に積む。 1 つの文字列に
|
|
84
|
-
* すると 1 行に全部入り、箱幅を超えて末尾が切られる (実測 = 箱 120px に対し文字 163px)。
|
|
85
|
-
*
|
|
86
|
-
* `subtitle` と `value` の両方が書かれた場合は空白で繋いで 1 つの補足にする。 描画側の
|
|
87
|
-
* 補足は 1 行なので、2 つを別々の行にはできない。
|
|
88
|
-
*/
|
|
89
|
-
export function 放射に出す文字(a: DslActor): { title: string; subtitle?: string } {
|
|
90
|
-
const 続き = [a.subtitle, a.value].map((x) => x?.trim()).filter((x): x is string => !!x);
|
|
91
|
-
return { title: 箱の題(a), ...(続き.length > 0 ? { subtitle: 続き.join(" ") } : {}) };
|
|
92
|
-
}
|
package/src/compile/journey.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { diagram } from "@cardenelabs/cdl";
|
|
2
|
-
import type { CdlDiagram } from "@cardenelabs/cdl";
|
|
3
|
-
import type { DslActor, DslDocument } from "../types";
|
|
4
|
-
import { 図表の大きさ, 図表の大きさを読む, 語の欄から参照できる名前 } from "./chart-fields";
|
|
5
|
-
import { 箱の題 } from "./node-title";
|
|
6
|
-
import type { CompileNotice } from "./notice";
|
|
7
|
-
import { slugify } from "./slug";
|
|
8
|
-
import { 図の小見出し } from "./subtitle";
|
|
9
|
-
import { 気持ち } from "./word-state";
|
|
10
|
-
/**
|
|
11
|
-
* ユーザージャーニー (`type: journey`) の組み立て (#1154)。 描画側に 1 つの箱で渡す。
|
|
12
|
-
*
|
|
13
|
-
* 登場人物ごとに **気持ち** を読む (`- 登録: "不満"`)。 使える語は `気持ち` が持つ。
|
|
14
|
-
*/
|
|
15
|
-
export function compileJourney(
|
|
16
|
-
doc: DslDocument,
|
|
17
|
-
onNotice?: (n: CompileNotice) => void,
|
|
18
|
-
): CdlDiagram {
|
|
19
|
-
const b = diagram(slugify(doc.title), { topic: doc.title, type: "journey" });
|
|
20
|
-
const { w: W, h: H } = 図表の大きさを読む(doc, 図表の大きさ.journey);
|
|
21
|
-
b.lane("chart", { width: W + 64 });
|
|
22
|
-
const data: NonNullable<CdlDiagram["nodes"][number]["journeyData"]> = [];
|
|
23
|
-
const 読めない: string[] = [];
|
|
24
|
-
const 参照できる = 語の欄から参照できる名前(doc, 気持ち);
|
|
25
|
-
for (const a of doc.actors) {
|
|
26
|
-
const 語 = (a.value ?? a.subtitle ?? "").trim();
|
|
27
|
-
// 状態を読む欄はそのまま渡す。 指す先の語は `語の状態を図の語へ直す` が図の語に直す
|
|
28
|
-
const 参照 = 語.match(/^\{(\w+)\}$/);
|
|
29
|
-
if (参照) {
|
|
30
|
-
if (!参照できる.has(参照[1]!)) {
|
|
31
|
-
読めない.push(a.name);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
data.push({ id: slugify(a.name), title: 箱の題(a), emotion: 語, ...道筋の欄(a) });
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const e = 気持ち.get(語);
|
|
38
|
-
if (e === undefined) {
|
|
39
|
-
読めない.push(a.name);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
data.push({ id: slugify(a.name), title: 箱の題(a), emotion: e, ...道筋の欄(a) });
|
|
43
|
-
}
|
|
44
|
-
if (読めない.length > 0) {
|
|
45
|
-
const m = `type: journey で気持ちを読めない項目があります (道筋に載せません): ${読めない.join(", ")}。 \`- 登録: "不満"\` の形で、 ${[...気持ち.keys()].join(" / ")} のどれかを書いてください`;
|
|
46
|
-
onNotice?.({ kind: "chart-value-unreadable", actor: 読めない[0]!, line: 0, message: m });
|
|
47
|
-
if (typeof console !== "undefined" && console.warn) console.warn(`[dragon] ${m}`);
|
|
48
|
-
}
|
|
49
|
-
// 矢印は描けない。 書かれていたら伝える (黙って捨てると「書いたのに効かない」 が残る)
|
|
50
|
-
if (doc.flow.length > 0) {
|
|
51
|
-
const m2 = `type: journey では矢印を描けません (${doc.flow.length} 本を無視しました)。 関係を描くなら type: flow を使ってください`;
|
|
52
|
-
onNotice?.({
|
|
53
|
-
kind: "chart-edge-dropped",
|
|
54
|
-
actor: doc.flow[0]?.from ?? "",
|
|
55
|
-
line: doc.flow[0]?.pos?.line ?? 0,
|
|
56
|
-
message: m2,
|
|
57
|
-
});
|
|
58
|
-
if (typeof console !== "undefined" && console.warn) console.warn(`[dragon] ${m2}`);
|
|
59
|
-
}
|
|
60
|
-
b.node(`${slugify(doc.title) || "journey"}-chart`, {
|
|
61
|
-
lane: "chart",
|
|
62
|
-
stack: 0,
|
|
63
|
-
kind: "journey-map",
|
|
64
|
-
title: doc.title,
|
|
65
|
-
...図の小見出し(doc),
|
|
66
|
-
w: W,
|
|
67
|
-
h: H,
|
|
68
|
-
journeyData: data,
|
|
69
|
-
...(doc.journeyForm !== undefined ? { journeyForm: doc.journeyForm } : {}),
|
|
70
|
-
...(doc.journeyLineForm !== undefined ? { journeyLineForm: doc.journeyLineForm } : {}),
|
|
71
|
-
...(doc.journeyLabels !== undefined ? { journeyLabels: doc.journeyLabels } : {}),
|
|
72
|
-
...(doc.journeySize !== undefined ? { journeySize: doc.journeySize } : {}),
|
|
73
|
-
});
|
|
74
|
-
return b.build();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* ユーザージャーニーの段に添える欄 (#1251)。
|
|
79
|
-
*
|
|
80
|
-
* 書かなければ項目ごと落とす = `undefined` を明示して渡すと、 組立て側が「空を書いた」 と
|
|
81
|
-
* 区別できなくなる (`図の小見出し` と同じ理由)。
|
|
82
|
-
*/
|
|
83
|
-
function 道筋の欄(a: DslActor): {
|
|
84
|
-
touchpoint?: string;
|
|
85
|
-
opportunity?: string;
|
|
86
|
-
opportunityPosition?: DslActor["opportunityPosition"];
|
|
87
|
-
} {
|
|
88
|
-
return {
|
|
89
|
-
...(a.touchpoint !== undefined ? { touchpoint: a.touchpoint } : {}),
|
|
90
|
-
...(a.opportunity !== undefined ? { opportunity: a.opportunity } : {}),
|
|
91
|
-
...(a.opportunityPosition !== undefined ? { opportunityPosition: a.opportunityPosition } : {}),
|
|
92
|
-
};
|
|
93
|
-
}
|
package/src/compile/kinds.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { NodeKind } from "@cardenelabs/cdl";
|
|
2
|
-
|
|
3
|
-
import { DSL_ONLY_KINDS } from "../v05/parser";
|
|
4
|
-
import type { PresetType } from "../types";
|
|
5
|
-
/**
|
|
6
|
-
* 記法に書く種類を描画側の種類へ読み替える (#2030 で `compile.ts` から移した)。
|
|
7
|
-
*
|
|
8
|
-
* 記法は描画側に無い種類 (`entity` / `state` 等) を受け付けるため、渡す前に読み替える。
|
|
9
|
-
* 読み替えずに渡すと描画側が大きさを引けず、図の組み立てが落ちる。
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 記法だけが持つ種類を、描画できる種類へ読み替える (#1420)。
|
|
14
|
-
*
|
|
15
|
-
* 記法は `entity` / `state` のような **描画側に無い種類** を受け付ける
|
|
16
|
-
* (`v05/parser.ts` の `DSL_ONLY_KINDS`)。 図種ごとの役割分け (ER 図の実体など) に使うためで、
|
|
17
|
-
* 記法としては正しい。
|
|
18
|
-
*
|
|
19
|
-
* **そのまま描画側へ渡すと図の組み立てが落ちる**。 描画側は知らない種類の大きさを引けず、
|
|
20
|
-
* `Cannot read properties of undefined (reading 'h')` で止まる (実測)。
|
|
21
|
-
*
|
|
22
|
-
* `er` は組み立ての中で別の種類に置き換えていたが、`flow` / `swimlane` / `state` /
|
|
23
|
-
* `topology` は `a.kind` をそのまま渡していた。 記法が受ける値で図が出ない状態だったので、
|
|
24
|
-
* 渡す手前で必ず通す。
|
|
25
|
-
*
|
|
26
|
-
* ## 読み替え先
|
|
27
|
-
*
|
|
28
|
-
* | 種類 | 読み替え先 | なぜ |
|
|
29
|
-
* |---|---|---|
|
|
30
|
-
* | `entity` | `storage` | 表を持つ = ER 図の実体 |
|
|
31
|
-
* | `state` | `card` | 状態は札で表す |
|
|
32
|
-
* | `loop` | `card` | 繰り返しは札で表す。 分かれ道の図では形に読み替わるのでここを通らない (#2523) |
|
|
33
|
-
*
|
|
34
|
-
* **表は `DSL_ONLY_KINDS` を鍵にして書く**。 種類を足した時に読み替え先が無いと
|
|
35
|
-
* 型検査が落ちるので、足し忘れが残らない。
|
|
36
|
-
*/
|
|
37
|
-
export const 記法だけの種類の読み替え: Readonly<Record<(typeof DSL_ONLY_KINDS)[number], NodeKind>> =
|
|
38
|
-
{
|
|
39
|
-
entity: "storage",
|
|
40
|
-
state: "card",
|
|
41
|
-
loop: "card",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/** 描画側へ渡せる種類にする。 記法だけの種類はここで読み替わる (#1420) */
|
|
45
|
-
export function 描ける種別(kind: string | undefined): NodeKind {
|
|
46
|
-
if (kind === undefined) return "actor";
|
|
47
|
-
const 読み替え先 = (記法だけの種類の読み替え as Record<string, NodeKind | undefined>)[kind];
|
|
48
|
-
return 読み替え先 ?? (kind as NodeKind);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 図種ごとの図の作り (#1219 / #1220)。
|
|
53
|
-
*
|
|
54
|
-
* 2 つの判断がここから決まる。 解決できない矢印を中央で落とすか (#1219) と、 名前が同じ id に
|
|
55
|
-
* 潰れる登場人物を作り替えるか (#1220)。 どちらも **登場人物の名前が箱や枠の id になる図種**
|
|
56
|
-
* でだけ要る。
|
|
57
|
-
*
|
|
58
|
-
* `#1209` は動きを書いた 2 経路だけを塞いだ。 残る経路では **知らせは出るのに図まで壊れる**
|
|
59
|
-
* 状態だった (実測 = 8 図種が `compile` の `unknown-ref` で落ちる)。
|
|
60
|
-
*
|
|
61
|
-
* | 作り | 解決できない矢印 | 同じ id に潰れる名前 |
|
|
62
|
-
* |---|---|---|
|
|
63
|
-
* | 登場人物ごとに箱 | 中央で落とす | 名前を作り替えて id を分ける |
|
|
64
|
-
* | 図全体を 1 箱 | 図種に任せる | 触らない |
|
|
65
|
-
*
|
|
66
|
-
* **1 箱で描く図種を中央で落とさない**。 これらは矢印そのものを描かず、 書かれた本数を数えて
|
|
67
|
-
* 独自の知らせを出す (`chart-edge-dropped` / 木の親子の知らせ)。 中央で外すと本数が変わり、
|
|
68
|
-
* 全部が解決できない図では知らせごと消える。 同じ id に潰れる名前も、 中身を payload が
|
|
69
|
-
* 持つため箱の id にならず、 木と放射は独自の知らせを出す。
|
|
70
|
-
*
|
|
71
|
-
* `Record<PresetType, ...>` にしてあるので、 図種を足した時にどちらかを決めないと型検査が
|
|
72
|
-
* 落ちる (`rules/quality.md § 多層 SSOT 経路の全 registration 保証` と同じ形)。
|
|
73
|
-
*/
|
|
74
|
-
export const 図種の作り: Record<PresetType, "登場人物ごとに箱" | "図全体を 1 箱"> = {
|
|
75
|
-
// 矢印の端と登場人物の名前が、 そのまま箱や枠の id になる
|
|
76
|
-
sequence: "登場人物ごとに箱",
|
|
77
|
-
flow: "登場人物ごとに箱",
|
|
78
|
-
flowchart: "登場人物ごとに箱",
|
|
79
|
-
swimlane: "登場人物ごとに箱",
|
|
80
|
-
record: "登場人物ごとに箱",
|
|
81
|
-
topology: "登場人物ごとに箱",
|
|
82
|
-
c4: "登場人物ごとに箱",
|
|
83
|
-
// 中身は payload が持ち、 図そのものは 1 箱。 矢印は描かず本数を数えて知らせる
|
|
84
|
-
gantt: "図全体を 1 箱",
|
|
85
|
-
chart: "図全体を 1 箱",
|
|
86
|
-
funnel: "図全体を 1 箱",
|
|
87
|
-
tree: "図全体を 1 箱",
|
|
88
|
-
journey: "図全体を 1 箱",
|
|
89
|
-
quadrant: "図全体を 1 箱",
|
|
90
|
-
mind: "図全体を 1 箱",
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 図全体を 1 つの箱で描く種別。
|
|
95
|
-
*
|
|
96
|
-
* これらは中身 (扇 / 帯 / 枝) を payload で受け取り、 1 node で図全体を描く。 登場人物ごとの箱を
|
|
97
|
-
* 持たないので、 段の `focus:` で名前を指しても引く先が無い。 `injectPhasesFallback` が
|
|
98
|
-
* この一覧を使って「実在する名前ならその箱を光らせる」 に読み替える (#1076 / #1077)。
|
|
99
|
-
*
|
|
100
|
-
* `mind-map` は一時期 **記法から到達しなかった** (`#1174`)。 この種別を作っていたのは
|
|
101
|
-
* `compileRadial` だけで `#1170` で消え、 記法の `type: mind` は `card` を 3 列に並べる
|
|
102
|
-
* 別実装だった。
|
|
103
|
-
*
|
|
104
|
-
* それでも一覧に残すのは、 ここが「1 箱で図全体を描く種別」 という **性質の一覧** だから。
|
|
105
|
-
* `mind-map` は engine 側でその性質を持ち続けており、 記法が到達しないのは当時の
|
|
106
|
-
* `compileMind` の実装によるものだった。 `#1177` で `compileMind` を `mind-map` に寄せたため、
|
|
107
|
-
* **今は記法からも到達する** (一覧へ戻す作業が要らなかったのはこのため)。
|
|
108
|
-
*
|
|
109
|
-
* ## 図表の種別は 1 つ残らず載せる (#1668)
|
|
110
|
-
*
|
|
111
|
-
* 弧と帯で量を表す 3 種 (`chart-gauge` / `chart-radial` / `chart-stacked-bar`) と、
|
|
112
|
-
* 値 1 つを大きく示す 2 種 (`chart-stat` / `chart-waffle`) が抜けていた。 5 種とも中身を
|
|
113
|
-
* payload で受け取って 1 箱で描く = この一覧が言う性質をそのまま持つ。
|
|
114
|
-
*
|
|
115
|
-
* 抜けている間、段の `draw:` を書いても指す先が引けず **書けるのに動かない** 状態になる
|
|
116
|
-
* (`draw` の解決は「1 箱で描く箱がちょうど 1 つ」 を条件にしている)。 `focus:` で登場人物の
|
|
117
|
-
* 名前を書いた時に何も光らないのも同じ穴で、載せると図の箱が光るようになる。
|
|
118
|
-
*/
|
|
119
|
-
export const SINGLE_BOX_KINDS: ReadonlySet<string> = new Set([
|
|
120
|
-
"chart-pie",
|
|
121
|
-
"chart-line",
|
|
122
|
-
"chart-bar",
|
|
123
|
-
"gantt-timeline",
|
|
124
|
-
"mind-map",
|
|
125
|
-
"funnel-stages",
|
|
126
|
-
"quadrant-matrix",
|
|
127
|
-
"tree-hierarchy",
|
|
128
|
-
"journey-map",
|
|
129
|
-
// 2 時点を直線でつなぐ図も 1 箱で全体を描く (#1647)
|
|
130
|
-
"chart-slope",
|
|
131
|
-
// 弧と帯で量を表す 3 種も 1 箱で全体を描く (#1668)
|
|
132
|
-
"chart-gauge",
|
|
133
|
-
"chart-radial",
|
|
134
|
-
"chart-stacked-bar",
|
|
135
|
-
// 値 1 つを大きく示す図と、1 個 = 1% の印を埋める図も同じ (#1668)。
|
|
136
|
-
// 段の `draw:` は受けない (描画側が起点から描く動きを持たない) が、性質は同じなので載せる
|
|
137
|
-
"chart-stat",
|
|
138
|
-
"chart-waffle",
|
|
139
|
-
]);
|
package/src/compile/lanes.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { DslDocument, PresetType } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* 箱に書いた縦列の扱い (#2030 で `compile.ts` から移した)。
|
|
4
|
-
*
|
|
5
|
-
* 縦列を書ける図種と、書いた縦列をそのまま使うかの判定。
|
|
6
|
-
*
|
|
7
|
-
* **葉に置く** = 図種ごとの file と、`compile.ts` に残る「書いたのに効かない」 の知らせの
|
|
8
|
-
* 両方が呼ぶ。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 縦列を選べる図種 (#1263)。
|
|
13
|
-
*
|
|
14
|
-
* 縦列を **箱を並べるための入れ物** として使う図種だけを許す。 順序図は
|
|
15
|
-
* 縦列がそのまま生命線として描かれる骨格なので許さない (#1248 の判断はこちらに当たる)。
|
|
16
|
-
*
|
|
17
|
-
* `er` は「1 縦列 1 箱」 が図の読み方そのもの (表が横に並ぶ) なので、2 つの箱を同じ縦列へ
|
|
18
|
-
* 入れられる形にはしない。
|
|
19
|
-
*
|
|
20
|
-
* 状態遷移図は外した (#1466)。設計が格子に置く形になり、
|
|
21
|
-
* 「箱の 1 つの辺には関係を 1 本まで」 を守るには 1 つの縦列に複数の箱が要る。
|
|
22
|
-
* 「1 縦列 1 箱」 が読み方だった前提はここで崩れている。
|
|
23
|
-
*/
|
|
24
|
-
export const 縦列を選べる図種: ReadonlySet<PresetType> = new Set<PresetType>([
|
|
25
|
-
"flow",
|
|
26
|
-
"topology",
|
|
27
|
-
"swimlane",
|
|
28
|
-
/*
|
|
29
|
-
* 分かれ道の図 (#2513)。
|
|
30
|
-
*
|
|
31
|
-
* この図種は **縦列が役割で、箱はその中に置く**。 1 人の役割の中に複数の箱が並ぶ形
|
|
32
|
-
* (申請を出す / 直して出し直す) が図の読み方そのものなので、書いた縦列をそのまま使う。
|
|
33
|
-
*/
|
|
34
|
-
"flowchart",
|
|
35
|
-
/*
|
|
36
|
-
* 行を持つ図 (#1571 / #2782)。
|
|
37
|
-
*
|
|
38
|
-
* 畳む前の表の図は、組み立て器が実体 1 つにつき帯を 1 本作り必ず段 0 に置いていた =
|
|
39
|
-
* 表が横 1 列にしか並ばない。 関係を 4 本持つ実体があると、どう並べ替えても 2 本は隣を
|
|
40
|
-
* 飛び越す (意匠帳 `docs/design/er/note.md` § 記法の制約 が 4 通りを実測しており、
|
|
41
|
-
* 1 列は縦横比 7.0 / 最長の線 4068、格子は 3.5 / 836)。
|
|
42
|
-
*/
|
|
43
|
-
"record",
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 書いた縦列に箱を置く形か (#1263)。
|
|
48
|
-
*
|
|
49
|
-
* **全ての箱が縦列を書いた時だけ** この形にする。 一部だけ書いた形は、書かなかった箱の
|
|
50
|
-
* 行き先を決める規則が要る (既定の縦列に集める / 自分の縦列を作る) が、どちらも
|
|
51
|
-
* 書いた人の意図と一致する保証が無い。 混ざった形は `reportLaneMixed` が知らせる。
|
|
52
|
-
*
|
|
53
|
-
* 数える箱は `縦列の判定に数える箱` が決める (#2372)。
|
|
54
|
-
*/
|
|
55
|
-
export function 書いた縦列に置く(kind: PresetType, doc: DslDocument): boolean {
|
|
56
|
-
if (!縦列を選べる図種.has(kind)) return false;
|
|
57
|
-
const 対象 = 縦列の判定に数える箱(doc);
|
|
58
|
-
return 対象.length > 0 && 対象.every((a) => a.lane !== undefined);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 縦列の判定で数える箱 (#2372)。
|
|
63
|
-
*
|
|
64
|
-
* **見本 (`parts`) は縦列を書いた時だけ数える**。 見本の縦列は張替え先の指定で、
|
|
65
|
-
* 箱を並べる話ではない = 書いていない見本を数に入れると、普通の箱が全部書いた図まで
|
|
66
|
-
* 「一部だけ書いた」 に倒れる。
|
|
67
|
-
*
|
|
68
|
-
* 逆に見本を **常に** 外すと、箱が全部見本の図で対象が 0 件になり
|
|
69
|
-
* 「全ての箱が縦列を書いた」 が成立しない。 結果は 3 つ重なる =
|
|
70
|
-
* 書いた縦列に箱が入らない / 宣言した縦列が空のまま残る / 誤って「どの箱も入らない」 と知らせる
|
|
71
|
-
* (実測 = カタログの見本 19 枚で知らせが 38 件)。
|
|
72
|
-
*
|
|
73
|
-
* 見本が混ざった図では普通の箱が対象になって成立し、**見本も一緒に書いた縦列へ入っていた**
|
|
74
|
-
* = 見本を縦列へ入れられないわけではなく、数え方だけが割れていた。
|
|
75
|
-
*
|
|
76
|
-
* **置く側と知らせる側で同じ数え方を使う**。 別々に数えると、見本だけの図で
|
|
77
|
-
* 「一部だけ書いた」 形が知らせずに落ちる。
|
|
78
|
-
*/
|
|
79
|
-
export function 縦列の判定に数える箱(doc: DslDocument): DslDocument["actors"] {
|
|
80
|
-
const 見本が縦列を書いた = doc.actors.some((a) => a.partId !== undefined && a.lane !== undefined);
|
|
81
|
-
return 見本が縦列を書いた ? doc.actors : doc.actors.filter((a) => a.partId === undefined);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 縦列ごとに箱の段を決める (#1394 / #2396)。
|
|
86
|
-
*
|
|
87
|
-
* 段は **書いた番号をそのまま持つ**。 書き順で 0 から詰め直すと、`stack: 1` と書いた箱が
|
|
88
|
-
* 0 へ落ちる = 決定木のように「同じ高さに並ばない」 ことが図の意味そのものになる形では、
|
|
89
|
-
* 詰めた瞬間に別の図になる (実測 = 3 段の木の根が 1 段目へ上がった)。
|
|
90
|
-
*
|
|
91
|
-
* 書かなかった箱は、その縦列で **空いている一番小さい段** に置く。 単に数え上げると
|
|
92
|
-
* 書いた番号と重なり、2 つの箱が同じ段に載る。
|
|
93
|
-
*
|
|
94
|
-
* **箱を並べる図種すべてが同じ決め方を使う** (#2396)。かつてのクラス図だけこの決め方を持たず、
|
|
95
|
-
* 段を書かない箱を全て 0 に残していた。 同じ縦列に箱を 2 つ置くと配置の計算が
|
|
96
|
-
* 「同じ場所に 2 つある」 として投げ、図が 1 枚も描けない (実測 = 24 図種で落ちるのは
|
|
97
|
-
* class 専用経路だけ)。
|
|
98
|
-
*
|
|
99
|
-
* @param actors 記法から読んだ箱を書いた順に並べたもの
|
|
100
|
-
* @param 縦列を引く 箱を同じ段の集合へ分ける鍵。 省略時は `lane` を使う
|
|
101
|
-
* @returns 段を持つ箱だけの表。 縦列も段も書かない箱は入らない (呼出側が既定に任せる)
|
|
102
|
-
*/
|
|
103
|
-
export function 縦列ごとの段を決める(
|
|
104
|
-
actors: DslDocument["actors"],
|
|
105
|
-
縦列を引く: (actor: DslDocument["actors"][number]) => string | undefined = (actor) =>
|
|
106
|
-
actor.lane,
|
|
107
|
-
): ReadonlyMap<DslDocument["actors"][number], number> {
|
|
108
|
-
const 埋まった段 = new Map<string, Set<number>>();
|
|
109
|
-
const 埋める = (lid: string, stack: number): void => {
|
|
110
|
-
const 集合 = 埋まった段.get(lid) ?? new Set<number>();
|
|
111
|
-
集合.add(stack);
|
|
112
|
-
埋まった段.set(lid, 集合);
|
|
113
|
-
};
|
|
114
|
-
// 書いた番号を先に全て埋める = 書き順が後の箱の番号とも重ならない
|
|
115
|
-
for (const a of actors) {
|
|
116
|
-
const 縦列 = 縦列を引く(a);
|
|
117
|
-
if (縦列 !== undefined && a.stack !== undefined) 埋める(縦列, a.stack);
|
|
118
|
-
}
|
|
119
|
-
const 決めた = new Map<DslDocument["actors"][number], number>();
|
|
120
|
-
for (const a of actors) {
|
|
121
|
-
const 縦列 = 縦列を引く(a);
|
|
122
|
-
if (縦列 === undefined) {
|
|
123
|
-
// 縦列を書かない箱は縦列の中の段を持たない。 段だけ書いた箱はその番号を渡す
|
|
124
|
-
if (a.stack !== undefined) 決めた.set(a, a.stack);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (a.stack !== undefined) {
|
|
128
|
-
決めた.set(a, a.stack);
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
let stack = 0;
|
|
132
|
-
const 集合 = 埋まった段.get(縦列);
|
|
133
|
-
while (集合?.has(stack)) stack += 1;
|
|
134
|
-
埋める(縦列, stack);
|
|
135
|
-
決めた.set(a, stack);
|
|
136
|
-
}
|
|
137
|
-
return 決めた;
|
|
138
|
-
}
|