@cardenelabs/dragon 0.20.0 → 0.22.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.cjs +13 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +13 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardenelabs/dragon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Dragon — Mermaid 感覚で animated SVG を生成する Text DSL。 cdl engine を内部利用。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "cardene777",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"prepublishOnly": "pnpm run typecheck && pnpm run test && pnpm run build"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@cardenelabs/cdl": "^0.
|
|
60
|
+
"@cardenelabs/cdl": "^0.29.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.0.0",
|
package/src/compile.ts
CHANGED
|
@@ -4269,7 +4269,7 @@ function 終わる位置(
|
|
|
4269
4269
|
}
|
|
4270
4270
|
|
|
4271
4271
|
function compileGantt(doc: DslDocument): CdlDiagram {
|
|
4272
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
4272
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "gantt" });
|
|
4273
4273
|
const CHART_W = 720;
|
|
4274
4274
|
b.lane("gantt", { width: CHART_W });
|
|
4275
4275
|
|
|
@@ -4406,7 +4406,8 @@ function compileClass(doc: DslDocument): CdlDiagram {
|
|
|
4406
4406
|
*/
|
|
4407
4407
|
const b = classDiagram({ id: slugify(doc.title), topic: doc.title });
|
|
4408
4408
|
// 登場人物が 0 人なら枠も作らない。 先に作ると中身の無い枠が 1 つ残る (#1096)
|
|
4409
|
-
if (doc.actors.length === 0)
|
|
4409
|
+
if (doc.actors.length === 0)
|
|
4410
|
+
return diagram(slugify(doc.title), { topic: doc.title, type: "class" }).build();
|
|
4410
4411
|
|
|
4411
4412
|
/*
|
|
4412
4413
|
* 縦列は `lane:` の順、段は `stack:` で決まる (#1466)。
|
|
@@ -4564,7 +4565,7 @@ function compileValueChart(
|
|
|
4564
4565
|
| "chart-stacked-bar",
|
|
4565
4566
|
onNotice?: (notice: CompileNotice) => void,
|
|
4566
4567
|
): CdlDiagram {
|
|
4567
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
4568
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "chart" });
|
|
4568
4569
|
const CHART_W = 640;
|
|
4569
4570
|
// **高さは型で違い、 格子に載せる**。 描画側 (`cdl` の `chart()` preset) は `pie` を 320、
|
|
4570
4571
|
// 棒と折れ線を 360 とした上で **16 の倍数へ切り上げる** (360 は 16 で割り切れないので 368)。
|
|
@@ -4906,7 +4907,7 @@ function 語の状態を図の語へ直す(diagram: CdlDiagram): void {
|
|
|
4906
4907
|
}
|
|
4907
4908
|
|
|
4908
4909
|
function compileFunnel(doc: DslDocument, onNotice?: (n: CompileNotice) => void): CdlDiagram {
|
|
4909
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
4910
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "funnel" });
|
|
4910
4911
|
const { w: W, h: H } = 図表の大きさ.funnel;
|
|
4911
4912
|
b.lane("chart", { width: W + 64 });
|
|
4912
4913
|
const data: NonNullable<CdlDiagram["nodes"][number]["funnelData"]> = [];
|
|
@@ -5033,7 +5034,7 @@ function 矢印から親を決める(
|
|
|
5033
5034
|
}
|
|
5034
5035
|
|
|
5035
5036
|
function compileTree(doc: DslDocument, onNotice?: (n: CompileNotice) => void): CdlDiagram {
|
|
5036
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
5037
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "tree" });
|
|
5037
5038
|
const { w: W, h: H } = 図表の大きさ.tree;
|
|
5038
5039
|
b.lane("chart", { width: W + 64 });
|
|
5039
5040
|
// **同じ slug になる名前を先に見る**。 違う名前が同じ id に潰れると、 自分を親にしたと
|
|
@@ -5142,7 +5143,7 @@ function reportChartFieldsNotHonored(
|
|
|
5142
5143
|
}
|
|
5143
5144
|
|
|
5144
5145
|
function compileJourney(doc: DslDocument, onNotice?: (n: CompileNotice) => void): CdlDiagram {
|
|
5145
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
5146
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "journey" });
|
|
5146
5147
|
const { w: W, h: H } = 図表の大きさ.journey;
|
|
5147
5148
|
b.lane("chart", { width: W + 64 });
|
|
5148
5149
|
const data: NonNullable<CdlDiagram["nodes"][number]["journeyData"]> = [];
|
|
@@ -5256,7 +5257,7 @@ function reportAxesNotHonored(doc: DslDocument, onNotice?: (n: CompileNotice) =>
|
|
|
5256
5257
|
}
|
|
5257
5258
|
|
|
5258
5259
|
function compileQuadrant(doc: DslDocument, onNotice?: (n: CompileNotice) => void): CdlDiagram {
|
|
5259
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
5260
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "quadrant" });
|
|
5260
5261
|
const { w: W, h: H } = 図表の大きさ.quadrant;
|
|
5261
5262
|
b.lane("chart", { width: W + 64 });
|
|
5262
5263
|
const items: NonNullable<CdlDiagram["nodes"][number]["quadrantData"]>["items"] = [];
|
|
@@ -5355,7 +5356,7 @@ function 段を読み取る(subtitle: string | undefined): { 段: number; 説明
|
|
|
5355
5356
|
* flow ... actor 間の関係を edge で表現。
|
|
5356
5357
|
*/
|
|
5357
5358
|
function compileC4(doc: DslDocument): CdlDiagram {
|
|
5358
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
5359
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "infrastructure" });
|
|
5359
5360
|
const LANE_W = 400;
|
|
5360
5361
|
const LANE_GAP = 80;
|
|
5361
5362
|
const 段の名前: Record<number, string> = { 1: "System Context", 2: "Container", 3: "Component" };
|
|
@@ -5716,7 +5717,7 @@ function 放射に出す文字(a: DslActor): { title: string; subtitle?: string
|
|
|
5716
5717
|
}
|
|
5717
5718
|
|
|
5718
5719
|
function compileMind(doc: DslDocument, onNotice?: (n: CompileNotice) => void): CdlDiagram {
|
|
5719
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
5720
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: "mindmap" });
|
|
5720
5721
|
const { w: W, h: H } = 図表の大きさ.mind;
|
|
5721
5722
|
|
|
5722
5723
|
const 伝える = (kind: CompileNotice["kind"], 名: string, message: string, line = 0): void => {
|
|
@@ -6315,7 +6316,7 @@ function compileFlow(doc: DslDocument): CdlDiagram {
|
|
|
6315
6316
|
// 通すと中身の無い枠が残る (実測 = `title` と `type` だけの本文で枠 `flow` が空)。
|
|
6316
6317
|
// 枠を持たない図として返す = `swimlane` / `c4` が 0 人で枠 0 になるのと揃う
|
|
6317
6318
|
if (doc.actors.length === 0) {
|
|
6318
|
-
return diagram(slugify(doc.title), { topic: doc.title }).build();
|
|
6319
|
+
return diagram(slugify(doc.title), { topic: doc.title, type: "flow" }).build();
|
|
6319
6320
|
}
|
|
6320
6321
|
// flow preset は actors を順に step として配置、 step 間に edge auto
|
|
6321
6322
|
const flowBuilder = flow({
|
|
@@ -6544,7 +6545,7 @@ function compileTopology(doc: DslDocument): CdlDiagram {
|
|
|
6544
6545
|
// 登場人物が 0 人なら枠も作らない。 描画側の `topology()` は枠を必ず 1 つ作るため、 そのまま
|
|
6545
6546
|
// 通すと中身の無い枠が残る (#1096)
|
|
6546
6547
|
if (doc.actors.length === 0) {
|
|
6547
|
-
return diagram(slugify(doc.title), { topic: doc.title }).build();
|
|
6548
|
+
return diagram(slugify(doc.title), { topic: doc.title, type: "topology" }).build();
|
|
6548
6549
|
}
|
|
6549
6550
|
// topology preset ... actors を 1 つの group 内 container として配置
|
|
6550
6551
|
// v0.3 で「group」 ブロックを追加して複数 group 対応検討
|
|
@@ -6720,8 +6721,8 @@ function 書いた縦列に置く(kind: PresetType, doc: DslDocument): boolean {
|
|
|
6720
6721
|
}
|
|
6721
6722
|
|
|
6722
6723
|
function compileGenericWithAnimate(doc: DslDocument, opts: GenericOpts): CdlDiagram {
|
|
6723
|
-
const b = diagram(slugify(doc.title), { topic: doc.title });
|
|
6724
6724
|
const { kind, laneWidth } = opts;
|
|
6725
|
+
const b = diagram(slugify(doc.title), { topic: doc.title, type: kind });
|
|
6725
6726
|
|
|
6726
6727
|
// lane / node 配置 ... preset kind に応じて切替
|
|
6727
6728
|
const actorToNodeId = new Map<string, string>();
|