@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/README.md +8 -4
- package/dist/index.cjs +6378 -5214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +340 -8
- package/dist/index.d.ts +340 -8
- package/dist/index.js +6374 -5215
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +65 -1
- package/src/index.ts +26 -15
- package/src/json-parser.ts +928 -99
- package/src/schemas/diagram.json +368 -44
- package/src/tokenize.ts +289 -0
- package/src/types.ts +19 -0
- package/src/v05/parser.ts +670 -138
package/src/schemas/diagram.json
CHANGED
|
@@ -14,13 +14,63 @@
|
|
|
14
14
|
},
|
|
15
15
|
"type": {
|
|
16
16
|
"type": "string",
|
|
17
|
-
"enum": [
|
|
17
|
+
"enum": [
|
|
18
|
+
"sequence",
|
|
19
|
+
"flow",
|
|
20
|
+
"swimlane",
|
|
21
|
+
"er",
|
|
22
|
+
"state",
|
|
23
|
+
"topology",
|
|
24
|
+
"solidity",
|
|
25
|
+
"gantt",
|
|
26
|
+
"class",
|
|
27
|
+
"pie",
|
|
28
|
+
"bar",
|
|
29
|
+
"line",
|
|
30
|
+
"funnel",
|
|
31
|
+
"tree",
|
|
32
|
+
"journey",
|
|
33
|
+
"quadrant",
|
|
34
|
+
"c4",
|
|
35
|
+
"mind"
|
|
36
|
+
],
|
|
18
37
|
"description": "図の種類。 型ごとに actors の書き方が違う。 [関係を描く] sequence (時系列の呼び出し) / flow (処理の流れ) / swimlane (責務ごとの流れ) / er (DB の schema) / state (状態の遷移) / topology (network) / solidity (contract) / class (UML の class) / c4 (architecture) / mind (発想の枝分かれ) は actors に名前を並べ flow に矢印を書く。 [値を描く] pie (割合) / bar (棒の高さ) / line (線の高さ、 書いた順に並ぶ) は actors に `- 名前: \"45\"` の形で数を書く。 funnel (段ごとに減る数) も同じ形。 [語を描く] journey (体験の起伏) は `- 登録: \"不満\"` の形で 最高 / 満足 / 普通 / 不満 / 怒り のどれかを書く。 quadrant (2 軸の仕分け) は `- 重複削除: \"左上\"` の形で 左上 / 右上 / 左下 / 右下 のどれかを書く。 [時期を描く] gantt (工程の並び) は `- 設計: \"1月\"` の形で始まりの時期を書き、 flow の矢印で前後関係を書く。 [親子を描く] tree (親子の入れ子) は actors に名前を並べ flow の矢印で親子を書く (矢印の先が子)"
|
|
19
38
|
},
|
|
20
39
|
"eyebrow": {
|
|
21
40
|
"type": "string",
|
|
22
41
|
"description": "図表の箱の上に出す小見出し (省略可)。 効くのは図全体を 1 箱にする型 (pie / bar / line / funnel / tree / journey / quadrant / mind / gantt) だけ。 箱ごとに分かれる型では相手が決まらないため、 actors[].eyebrow に書く"
|
|
23
42
|
},
|
|
43
|
+
"axes": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "quadrant の x / y 軸の端に表示する名前。 記法の axes と同じ。",
|
|
47
|
+
"properties": {
|
|
48
|
+
"x": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"properties": {
|
|
52
|
+
"left": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
},
|
|
55
|
+
"right": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"y": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"properties": {
|
|
64
|
+
"bottom": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"top": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
24
74
|
"actors": {
|
|
25
75
|
"type": "array",
|
|
26
76
|
"minItems": 1,
|
|
@@ -36,19 +86,147 @@
|
|
|
36
86
|
"required": ["name"],
|
|
37
87
|
"additionalProperties": false,
|
|
38
88
|
"properties": {
|
|
39
|
-
"name": {
|
|
89
|
+
"name": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"minLength": 1,
|
|
92
|
+
"description": "actor 名 (flow の from / to で参照される)"
|
|
93
|
+
},
|
|
40
94
|
"kind": {
|
|
41
95
|
"type": "string",
|
|
42
96
|
"description": "node kind。 shape-* を指定して 49 shape 中から選ぶ。 例: 'shape-wallet' / 'shape-smart-contract' / 'shape-cloud' / 'shape-file' / 'actor' (default) / 'function' / 'storage' / 'event' 等"
|
|
43
97
|
},
|
|
44
|
-
"subtitle": {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
98
|
+
"subtitle": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"description": "node 下部の補足テキスト"
|
|
101
|
+
},
|
|
102
|
+
"eyebrow": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "node 上部の分類ラベル (accent 色)"
|
|
105
|
+
},
|
|
106
|
+
"value": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "actor 数値表示 (kind: actor 用)"
|
|
109
|
+
},
|
|
110
|
+
"rows": {
|
|
111
|
+
"type": "array",
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"description": "storage 内の column 列 (kind: storage 用)"
|
|
116
|
+
},
|
|
117
|
+
"lane": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"description": "swimlane / topology で属する lane id"
|
|
120
|
+
},
|
|
121
|
+
"stack": {
|
|
122
|
+
"type": "integer",
|
|
123
|
+
"minimum": 0,
|
|
124
|
+
"description": "lane 内の縦位置 (0-based)"
|
|
125
|
+
},
|
|
126
|
+
"initial": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "state 開始点 (kind: state 用)"
|
|
129
|
+
},
|
|
130
|
+
"final": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"description": "state 終了点 (kind: state 用)"
|
|
133
|
+
},
|
|
134
|
+
"state": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"description": "parts の状態の上書き。 kind に parts identifier を指定した時だけ使える。",
|
|
137
|
+
"additionalProperties": {
|
|
138
|
+
"type": ["number", "string", "boolean"]
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"tone": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"description": "箱の色調。 success / warning 等の別名も使える。",
|
|
144
|
+
"enum": ["accent", "teal", "success", "error", "warning", "info", "成功", "失敗", "警告", "情報", "中立", "neutral"]
|
|
145
|
+
},
|
|
146
|
+
"color": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"description": "箱の色名、または # で始まる parts の色番号。",
|
|
149
|
+
"anyOf": [
|
|
150
|
+
{
|
|
151
|
+
"enum": ["accent", "teal", "success", "error", "warning", "info", "成功", "失敗", "警告", "情報", "中立", "neutral"]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"owner": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "gantt の工程の担当。"
|
|
161
|
+
},
|
|
162
|
+
"end": {
|
|
163
|
+
"type": "string",
|
|
164
|
+
"description": "gantt の工程が終わる時期。"
|
|
165
|
+
},
|
|
166
|
+
"touchpoint": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"description": "journey の段階が起きる場所。"
|
|
169
|
+
},
|
|
170
|
+
"opportunity": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"description": "journey の段階の改善の余地。"
|
|
173
|
+
},
|
|
174
|
+
"posX": {
|
|
175
|
+
"type": "number",
|
|
176
|
+
"description": "箱の絶対 x 座標。"
|
|
177
|
+
},
|
|
178
|
+
"posY": {
|
|
179
|
+
"type": "number",
|
|
180
|
+
"description": "箱の絶対 y 座標。"
|
|
181
|
+
},
|
|
182
|
+
"posW": {
|
|
183
|
+
"type": "number",
|
|
184
|
+
"description": "箱の幅。"
|
|
185
|
+
},
|
|
186
|
+
"posH": {
|
|
187
|
+
"type": "number",
|
|
188
|
+
"description": "箱の高さ。"
|
|
189
|
+
},
|
|
190
|
+
"nodes": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"description": "箱の中の要素ごとの位置と大きさ。 key は header / footer / s0 等の要素名。",
|
|
193
|
+
"additionalProperties": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"additionalProperties": false,
|
|
196
|
+
"properties": {
|
|
197
|
+
"posX": {
|
|
198
|
+
"type": "number"
|
|
199
|
+
},
|
|
200
|
+
"posY": {
|
|
201
|
+
"type": "number"
|
|
202
|
+
},
|
|
203
|
+
"posW": {
|
|
204
|
+
"type": "number"
|
|
205
|
+
},
|
|
206
|
+
"posH": {
|
|
207
|
+
"type": "number"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"scale": {
|
|
213
|
+
"type": "number",
|
|
214
|
+
"description": "parts の描画倍率。 kind に parts identifier を指定した時だけ使える。"
|
|
215
|
+
},
|
|
216
|
+
"pos": {
|
|
217
|
+
"type": "object",
|
|
218
|
+
"additionalProperties": false,
|
|
219
|
+
"description": "auto layout の結果からずらす幅 (dx, dy)。 絶対座標は posX / posY で書く。",
|
|
220
|
+
"required": ["x", "y"],
|
|
221
|
+
"properties": {
|
|
222
|
+
"x": {
|
|
223
|
+
"type": "number"
|
|
224
|
+
},
|
|
225
|
+
"y": {
|
|
226
|
+
"type": "number"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
52
230
|
}
|
|
53
231
|
}
|
|
54
232
|
]
|
|
@@ -62,17 +240,66 @@
|
|
|
62
240
|
"required": ["from", "to", "label"],
|
|
63
241
|
"additionalProperties": false,
|
|
64
242
|
"properties": {
|
|
65
|
-
"from": {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
243
|
+
"from": {
|
|
244
|
+
"type": "string",
|
|
245
|
+
"description": "起点 actor 名"
|
|
246
|
+
},
|
|
247
|
+
"to": {
|
|
248
|
+
"type": "string",
|
|
249
|
+
"description": "終点 actor 名"
|
|
250
|
+
},
|
|
251
|
+
"label": {
|
|
252
|
+
"type": "string",
|
|
253
|
+
"description": "矢印上のラベル (関数呼出し名 / メッセージ等)"
|
|
254
|
+
},
|
|
255
|
+
"sub": {
|
|
256
|
+
"type": "string",
|
|
257
|
+
"description": "ラベル下の補足"
|
|
258
|
+
},
|
|
259
|
+
"tone": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"enum": ["accent", "teal", "success", "error", "warning", "info", "成功", "失敗", "警告", "情報", "中立", "neutral"],
|
|
262
|
+
"description": "矢印の色調。 success / 成功 等の別名も使える。"
|
|
263
|
+
},
|
|
264
|
+
"style": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"enum": ["solid", "dotted-flow"],
|
|
267
|
+
"description": "矢印の線種"
|
|
268
|
+
},
|
|
269
|
+
"guard": {
|
|
270
|
+
"type": "string",
|
|
271
|
+
"description": "state 遷移の条件 (kind: state 用)"
|
|
272
|
+
},
|
|
273
|
+
"cardinality": {
|
|
274
|
+
"type": "string",
|
|
275
|
+
"description": "ER の多重度 (1..N 等、 kind: er 用)"
|
|
276
|
+
},
|
|
277
|
+
"labelOffsetX": {
|
|
278
|
+
"type": "number",
|
|
279
|
+
"description": "ラベル位置 x 調整"
|
|
280
|
+
},
|
|
281
|
+
"labelOffsetY": {
|
|
282
|
+
"type": "number",
|
|
283
|
+
"description": "ラベル位置 y 調整"
|
|
284
|
+
},
|
|
285
|
+
"overlay": {
|
|
286
|
+
"type": "boolean",
|
|
287
|
+
"description": "true で説明文を矢印の線の上に重ねる (分岐図の条件ラベル用)"
|
|
288
|
+
},
|
|
289
|
+
"pos": {
|
|
290
|
+
"type": "object",
|
|
291
|
+
"additionalProperties": false,
|
|
292
|
+
"description": "矢印の説明文をずらす幅 (dx, dy)。",
|
|
293
|
+
"required": ["x", "y"],
|
|
294
|
+
"properties": {
|
|
295
|
+
"x": {
|
|
296
|
+
"type": "number"
|
|
297
|
+
},
|
|
298
|
+
"y": {
|
|
299
|
+
"type": "number"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
76
303
|
}
|
|
77
304
|
}
|
|
78
305
|
},
|
|
@@ -86,7 +313,12 @@
|
|
|
86
313
|
"description": "初期値。 数か文字列。 名前は英字か _ で始め、 英数字と _ だけを使う"
|
|
87
314
|
}
|
|
88
315
|
},
|
|
89
|
-
"examples": [
|
|
316
|
+
"examples": [
|
|
317
|
+
{
|
|
318
|
+
"inflow": 0,
|
|
319
|
+
"done": 0
|
|
320
|
+
}
|
|
321
|
+
]
|
|
90
322
|
},
|
|
91
323
|
"values": {
|
|
92
324
|
"type": "object",
|
|
@@ -99,7 +331,12 @@
|
|
|
99
331
|
"description": "式。 例 `{inflow} - {done}`"
|
|
100
332
|
}
|
|
101
333
|
},
|
|
102
|
-
"examples": [
|
|
334
|
+
"examples": [
|
|
335
|
+
{
|
|
336
|
+
"waiting": "{inflow} - {done}",
|
|
337
|
+
"busy": "{waiting} > 80"
|
|
338
|
+
}
|
|
339
|
+
]
|
|
103
340
|
},
|
|
104
341
|
"animation": {
|
|
105
342
|
"type": "array",
|
|
@@ -109,11 +346,36 @@
|
|
|
109
346
|
"required": ["step"],
|
|
110
347
|
"additionalProperties": false,
|
|
111
348
|
"properties": {
|
|
112
|
-
"step": {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
349
|
+
"step": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"minLength": 1,
|
|
352
|
+
"description": "phase 名"
|
|
353
|
+
},
|
|
354
|
+
"duration": {
|
|
355
|
+
"type": "number",
|
|
356
|
+
"minimum": 0.1,
|
|
357
|
+
"description": "phase 時間 (秒、 default 1.4)"
|
|
358
|
+
},
|
|
359
|
+
"focus": {
|
|
360
|
+
"type": "array",
|
|
361
|
+
"items": {
|
|
362
|
+
"type": "string"
|
|
363
|
+
},
|
|
364
|
+
"description": "この phase で active 化する actor 名 or edge 'A -> B' の配列"
|
|
365
|
+
},
|
|
366
|
+
"body": {
|
|
367
|
+
"type": "string",
|
|
368
|
+
"description": "phase 説明文"
|
|
369
|
+
},
|
|
370
|
+
"badge": {
|
|
371
|
+
"type": "string",
|
|
372
|
+
"description": "phase 中に表示する badge label"
|
|
373
|
+
},
|
|
374
|
+
"draw": {
|
|
375
|
+
"type": "string",
|
|
376
|
+
"enum": ["line", "bar", "pie"],
|
|
377
|
+
"description": "この phase で起点から描くもの。 語は図種と揃える。 line = 折れ線が左端から右へ伸びる / bar = 棒が横軸から上へ伸びる / pie = 扇が 12 時から時計回りに開く"
|
|
378
|
+
},
|
|
117
379
|
"tween": {
|
|
118
380
|
"type": "object",
|
|
119
381
|
"description": "この phase で補間する状態。 状態名 -> [開始値, 終了値]。 名前は英字か _ で始め、 英数字と _ だけを使う",
|
|
@@ -121,7 +383,9 @@
|
|
|
121
383
|
"patternProperties": {
|
|
122
384
|
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
|
|
123
385
|
"type": "array",
|
|
124
|
-
"items": {
|
|
386
|
+
"items": {
|
|
387
|
+
"type": "number"
|
|
388
|
+
},
|
|
125
389
|
"minItems": 2,
|
|
126
390
|
"maxItems": 2
|
|
127
391
|
}
|
|
@@ -132,7 +396,9 @@
|
|
|
132
396
|
"description": "この phase の切替で差し替える状態。 状態名 -> 値。 名前は英字か _ で始め、 英数字と _ だけを使う",
|
|
133
397
|
"additionalProperties": false,
|
|
134
398
|
"patternProperties": {
|
|
135
|
-
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
|
|
399
|
+
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
|
|
400
|
+
"type": ["number", "string"]
|
|
401
|
+
}
|
|
136
402
|
}
|
|
137
403
|
}
|
|
138
404
|
}
|
|
@@ -143,13 +409,38 @@
|
|
|
143
409
|
"description": "全体 canvas サイズ + gap の調整。 optional。",
|
|
144
410
|
"additionalProperties": false,
|
|
145
411
|
"properties": {
|
|
146
|
-
"width": {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
412
|
+
"width": {
|
|
413
|
+
"type": "number",
|
|
414
|
+
"minimum": 100
|
|
415
|
+
},
|
|
416
|
+
"height": {
|
|
417
|
+
"type": "number",
|
|
418
|
+
"minimum": 100
|
|
419
|
+
},
|
|
420
|
+
"laneWidth": {
|
|
421
|
+
"type": "number",
|
|
422
|
+
"minimum": 100
|
|
423
|
+
},
|
|
424
|
+
"gap": {
|
|
425
|
+
"type": "number",
|
|
426
|
+
"minimum": 0
|
|
427
|
+
},
|
|
428
|
+
"laneGap": {
|
|
429
|
+
"type": "number",
|
|
430
|
+
"minimum": 0
|
|
431
|
+
},
|
|
432
|
+
"nodeGap": {
|
|
433
|
+
"type": "number",
|
|
434
|
+
"minimum": 0
|
|
435
|
+
},
|
|
436
|
+
"labelMargin": {
|
|
437
|
+
"type": "number",
|
|
438
|
+
"minimum": 0
|
|
439
|
+
},
|
|
440
|
+
"scale": {
|
|
441
|
+
"type": "number",
|
|
442
|
+
"description": "図全体の倍率 (既定 1)。 箱 / 文字 / 線 / 間隔がすべて等比で変わる。"
|
|
443
|
+
}
|
|
153
444
|
}
|
|
154
445
|
},
|
|
155
446
|
"lanes": {
|
|
@@ -159,11 +450,36 @@
|
|
|
159
450
|
"type": "object",
|
|
160
451
|
"additionalProperties": false,
|
|
161
452
|
"properties": {
|
|
162
|
-
"x": {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
-
|
|
453
|
+
"x": {
|
|
454
|
+
"type": "number"
|
|
455
|
+
},
|
|
456
|
+
"width": {
|
|
457
|
+
"type": "number",
|
|
458
|
+
"minimum": 50
|
|
459
|
+
},
|
|
460
|
+
"label": {
|
|
461
|
+
"type": "string"
|
|
462
|
+
},
|
|
463
|
+
"contain": {
|
|
464
|
+
"type": "boolean"
|
|
465
|
+
},
|
|
466
|
+
"lifeline": {
|
|
467
|
+
"type": "boolean"
|
|
468
|
+
},
|
|
469
|
+
"pos": {
|
|
470
|
+
"type": "object",
|
|
471
|
+
"additionalProperties": false,
|
|
472
|
+
"description": "縦列をずらす幅 (dx, dy)。",
|
|
473
|
+
"required": ["x", "y"],
|
|
474
|
+
"properties": {
|
|
475
|
+
"x": {
|
|
476
|
+
"type": "number"
|
|
477
|
+
},
|
|
478
|
+
"y": {
|
|
479
|
+
"type": "number"
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
167
483
|
}
|
|
168
484
|
}
|
|
169
485
|
},
|
|
@@ -175,8 +491,16 @@
|
|
|
175
491
|
"required": ["lanes"],
|
|
176
492
|
"additionalProperties": false,
|
|
177
493
|
"properties": {
|
|
178
|
-
"label": {
|
|
179
|
-
|
|
494
|
+
"label": {
|
|
495
|
+
"type": "string"
|
|
496
|
+
},
|
|
497
|
+
"lanes": {
|
|
498
|
+
"type": "array",
|
|
499
|
+
"items": {
|
|
500
|
+
"type": "string"
|
|
501
|
+
},
|
|
502
|
+
"minItems": 1
|
|
503
|
+
}
|
|
180
504
|
}
|
|
181
505
|
}
|
|
182
506
|
}
|