@diagrammo/dgmo 0.8.11 → 0.8.13

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.
Files changed (68) hide show
  1. package/dist/cli.cjs +115 -719
  2. package/dist/index.cjs +196 -53
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +2 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +194 -54
  7. package/dist/index.js.map +1 -1
  8. package/docs/guide/chart-arc.md +71 -0
  9. package/docs/guide/chart-area.md +73 -0
  10. package/docs/guide/chart-bar-stacked.md +61 -0
  11. package/docs/guide/chart-bar.md +62 -0
  12. package/docs/guide/chart-boxes-and-lines.md +243 -0
  13. package/docs/guide/chart-c4.md +300 -0
  14. package/docs/guide/chart-chord.md +43 -0
  15. package/docs/guide/chart-class.md +204 -0
  16. package/docs/guide/chart-doughnut.md +38 -0
  17. package/docs/guide/chart-er.md +218 -0
  18. package/docs/guide/chart-flowchart.md +102 -0
  19. package/docs/guide/chart-function.md +56 -0
  20. package/docs/guide/chart-funnel.md +38 -0
  21. package/docs/guide/chart-gantt.md +368 -0
  22. package/docs/guide/chart-heatmap.md +41 -0
  23. package/docs/guide/chart-infra.md +694 -0
  24. package/docs/guide/chart-kanban.md +156 -0
  25. package/docs/guide/chart-line.md +79 -0
  26. package/docs/guide/chart-multi-line.md +84 -0
  27. package/docs/guide/chart-org.md +209 -0
  28. package/docs/guide/chart-pie.md +39 -0
  29. package/docs/guide/chart-polar-area.md +38 -0
  30. package/docs/guide/chart-quadrant.md +69 -0
  31. package/docs/guide/chart-radar.md +38 -0
  32. package/docs/guide/chart-sankey.md +103 -0
  33. package/docs/guide/chart-scatter.md +94 -0
  34. package/docs/guide/chart-sequence.md +332 -0
  35. package/docs/guide/chart-sitemap.md +248 -0
  36. package/docs/guide/chart-slope.md +56 -0
  37. package/docs/guide/chart-state.md +171 -0
  38. package/docs/guide/chart-timeline.md +229 -0
  39. package/docs/guide/chart-venn.md +81 -0
  40. package/docs/guide/chart-wordcloud.md +66 -0
  41. package/docs/guide/colors.md +283 -0
  42. package/docs/guide/index.md +55 -0
  43. package/docs/guide/keyboard-shortcuts.md +49 -0
  44. package/docs/guide/registry.json +51 -0
  45. package/gallery/fixtures/boxes-and-lines.dgmo +4 -6
  46. package/gallery/fixtures/er.dgmo +36 -0
  47. package/gallery/fixtures/kanban.dgmo +27 -0
  48. package/package.json +1 -1
  49. package/src/boxes-and-lines/parser.ts +2 -0
  50. package/src/boxes-and-lines/renderer.ts +12 -4
  51. package/src/c4/parser.ts +5 -1
  52. package/src/completion.ts +17 -2
  53. package/src/d3.ts +140 -71
  54. package/src/echarts.ts +1 -1
  55. package/src/er/parser.ts +5 -1
  56. package/src/gantt/parser.ts +8 -0
  57. package/src/gantt/renderer.ts +6 -7
  58. package/src/gantt/types.ts +1 -0
  59. package/src/infra/parser.ts +4 -0
  60. package/src/kanban/parser.ts +4 -1
  61. package/src/kanban/renderer.ts +1 -1
  62. package/src/org/parser.ts +3 -0
  63. package/src/sequence/parser.ts +2 -0
  64. package/src/sequence/renderer.ts +8 -6
  65. package/src/sharing.ts +18 -9
  66. package/src/sitemap/parser.ts +2 -0
  67. package/src/utils/legend-layout.ts +7 -3
  68. package/src/utils/tag-groups.ts +64 -0
@@ -0,0 +1,103 @@
1
+ # Sankey Diagram
2
+
3
+ ```dgmo
4
+ sankey Rum Supply Chain of the Caribbean
5
+
6
+ Sugar Plantations(green)
7
+ Tortuga Distillery(orange) 3000
8
+ Nassau Distillery(orange) 2500
9
+ Kingston Distillery(orange) 2000
10
+
11
+ Tortuga Distillery
12
+ Pirate Taverns(red) 2000
13
+ Ship Provisions(teal) 1000
14
+
15
+ Nassau Distillery
16
+ Pirate Taverns 1500
17
+ Black Market(purple) 1000
18
+
19
+ Kingston Distillery
20
+ Royal Navy(blue) 1200
21
+ Pirate Taverns 800
22
+
23
+ Pirate Taverns
24
+ Crew Morale 3500
25
+ Bar Fights 800 (red)
26
+
27
+ Ship Provisions -> Long Voyages 1000
28
+ ```
29
+
30
+ ## Syntax
31
+
32
+ ### Arrow syntax
33
+
34
+ ```
35
+ sankey Chart Title
36
+
37
+ Source -> Target value
38
+ ```
39
+
40
+ ### Indentation syntax
41
+
42
+ ```
43
+ sankey
44
+
45
+ Source
46
+ Target A 300
47
+ Target B 200
48
+
49
+ Target A
50
+ Sub-target 150
51
+ ```
52
+
53
+ Indent targets under a bare source label. Both syntaxes can be mixed in the same diagram.
54
+
55
+ ## Color Annotations
56
+
57
+ ### Node colors
58
+
59
+ Add `(color)` after a node name to color that node:
60
+
61
+ ```
62
+ Revenue(green)
63
+ Costs(red) 600
64
+ Profit(blue) 400
65
+
66
+ // or with arrows
67
+ Revenue(green) -> Costs(red) 600
68
+ ```
69
+
70
+ Uncolored nodes use the palette's default series colors.
71
+
72
+ ### Link colors
73
+
74
+ Add `(color)` after the value to color a specific link:
75
+
76
+ ```
77
+ Revenue
78
+ Costs 600 (orange)
79
+
80
+ // or with arrows
81
+ Revenue -> Costs 600 (orange)
82
+ ```
83
+
84
+ Uncolored links use a gradient between their source and target node colors.
85
+
86
+ ## Metadata Keys
87
+
88
+ | Key | Description | Required |
89
+ | ------- | ------------------------------------- | -------- |
90
+ | `chart` | Must be `sankey` | Yes |
91
+ | `title` | Chart title displayed above the chart | No |
92
+
93
+ ## Data Format
94
+
95
+ Each data line defines a flow from source to target with a numeric value:
96
+
97
+ ```
98
+ Sugar Plantations -> Distillery 3000
99
+ Distillery -> Taverns 2000
100
+ Distillery -> Ship Provisions 1000
101
+ ```
102
+
103
+ Nodes are created automatically from the source and target names. The same node can appear as both a source and a target to create multi-level flows.
@@ -0,0 +1,94 @@
1
+ # Scatter Plot
2
+
3
+ ```dgmo
4
+ scatter Cannon Range vs Powder Charge
5
+ x-label Powder (lbs)
6
+ y-label Range (yards)
7
+
8
+ // label: x, y
9
+ Long Tom: 12, 1800
10
+ Demi-Culverin: 8, 1200
11
+ Carronade: 4, 400
12
+ Swivel Gun: 2, 250
13
+ Nine-Pounder: 6, 900
14
+ Eighteen-Pounder: 10, 1500
15
+ Basilisk: 14, 2000
16
+ Falconet: 3, 350
17
+ Minion: 5, 700
18
+ Saker: 7, 1050
19
+ ```
20
+
21
+ ## Syntax
22
+
23
+ ```
24
+ scatter Chart Title
25
+ x-label X Axis Label
26
+ y-label Y Axis Label
27
+ no-labels
28
+ size-label Size Legend Label
29
+
30
+ // label: x, y
31
+ Point Name: x, y
32
+
33
+ // or with size (bubble chart)
34
+ // label: x, y, size
35
+ Point Name: x, y, size
36
+ ```
37
+
38
+ ## Metadata Keys
39
+
40
+ | Key | Description | Required |
41
+ | ------------ | ---------------------------------------------------------- | -------- |
42
+ | `chart` | Must be `scatter` | Yes |
43
+ | `title` | Chart title displayed above the chart | No |
44
+ | `x-label` | Label for the X axis | No |
45
+ | `y-label` | Label for the Y axis | No |
46
+ | `no-labels` | Hide point labels (labels are on by default) | No |
47
+ | `size-label` | Label for the size dimension (shown in legend for bubbles) | No |
48
+
49
+ ## Data Format
50
+
51
+ Each data line provides X and Y values, with an optional third value for bubble size:
52
+
53
+ ```
54
+ // 2D scatter
55
+ Point A: 12, 1800
56
+ Point B: 8, 1200
57
+
58
+ // 3D bubble
59
+ Point A: 85, 90, 80
60
+ Point B: 45, 55, 35
61
+ ```
62
+
63
+ ## Category Groups
64
+
65
+ Use `[Category Name](color)` headers to group points into colored categories:
66
+
67
+ ```
68
+ [English Pirates](red)
69
+ Blackbeard: 85, 90, 80
70
+ Calico Jack: 45, 55, 35
71
+
72
+ [French Buccaneers](blue)
73
+ L'Olonnais: 70, 80, 60
74
+ ```
75
+
76
+ ## Variants
77
+
78
+ ### Bubble Chart
79
+
80
+ Add a third value per data point and use `sizelabel` to label the size dimension:
81
+
82
+ ```dgmo
83
+ scatter Pirate Fleets of the Caribbean
84
+ size-label Crew
85
+
86
+ [English Pirates](red)
87
+ Blackbeard: 85, 90, 80
88
+ Calico Jack: 45, 55, 35
89
+ Anne Bonny: 50, 70, 30
90
+
91
+ [French Buccaneers](blue)
92
+ L'Olonnais: 70, 80, 60
93
+ Pierre le Grand: 30, 45, 25
94
+ ```
@@ -0,0 +1,332 @@
1
+ # Sequence Diagram
2
+
3
+ ```dgmo
4
+ sequence Treasure Hunt App
5
+
6
+ User -Search nearby loot-> WebApp
7
+ WebApp -GET /treasures?nearby-> TreasureAPI | c: Search
8
+ note
9
+ - check location
10
+ - use compass
11
+ - http://example.com
12
+ TreasureAPI -Find within 5nm-> MapDB | c: Search
13
+ MapDB -3 results-> TreasureAPI
14
+ TreasureAPI -locations-> WebApp
15
+ WebApp -Show treasure map-> User
16
+ ```
17
+
18
+ Notice that `User` renders as a stick figure, `OrderDB` as a cylinder, `WebApp` as a monitor, and `PaymentGateway` as a hexagon — all inferred automatically from the names. No declarations needed.
19
+
20
+ ## Overview
21
+
22
+ The sequence diagram uses an **inference-driven** syntax. Just write messages between participants and Diagrammo automatically:
23
+
24
+ - **Creates participants** from their first mention — no declarations needed
25
+ - **Infers participant shapes** from naming conventions — `User` gets a stick figure, `OrderDB` gets a cylinder, `API` gets a rounded box
26
+ - **Tracks activation bars** from call stacks
27
+
28
+ No `end` keywords are needed — blocks are scoped by indentation.
29
+
30
+ ## Syntax
31
+
32
+ ```
33
+ sequence Diagram Title
34
+ no-activations
35
+
36
+ == Section Label ==
37
+
38
+ A -message-> B
39
+ A ~async message~> B
40
+
41
+ if condition
42
+ A -message-> B
43
+ else
44
+ A -alternative-> C
45
+
46
+ loop description
47
+ A -retry-> B
48
+ ```
49
+
50
+ ## Settings
51
+
52
+ | Key | Description | Default |
53
+ | ---------------- | --------------------------------------- | -------- |
54
+ | `chart` | `sequence` (inferred from `->` content) | Optional |
55
+ | `title` | Diagram title | None |
56
+ | `no-activations` | Hide activation bars (on by default) | off |
57
+ | `active-tag` | Tag group to activate on load | None |
58
+ | `collapse-notes` | Collapse notes by default | off |
59
+
60
+ ## Participants
61
+
62
+ ### Automatic Type Inference
63
+
64
+ Participants are created automatically when first mentioned in a message. Their shape is inferred from the name — just use descriptive names and Diagrammo does the rest:
65
+
66
+ ```
67
+ User -createOrder-> OrderService
68
+ OrderService -save-> OrderDB
69
+ OrderService -cache result-> Redis
70
+ OrderService ~publish event~> EventBus
71
+ ```
72
+
73
+ This creates five participants, each with a different shape — no declarations needed.
74
+
75
+ The inference rules are checked in priority order (first match wins):
76
+
77
+ | Type | Shape | Naming Patterns |
78
+ | ------------ | ------------------- | ---------------------------------------------------------------------------------------------------- |
79
+ | `actor` | Stick figure | `User`, `Customer`, `Client`, `Admin`, `Guest`, `Visitor`, `Operator` |
80
+ | `database` | Cylinder | Names ending in `DB`; `Database`, `Store`, `Storage`, `Repo`, `Postgres`, `MySQL`, `Mongo`, `Dynamo` |
81
+ | `cache` | Dashed cylinder | `Cache`, `Redis`, `Memcache` |
82
+ | `queue` | Horizontal cylinder | `Queue`, `Kafka`, `RabbitMQ`, `EventBus`, `SQS`, `SNS`, `PubSub`, `Topic`, `Stream` |
83
+ | `networking` | Hexagon | `Gateway`, `Proxy`, `CDN`, `LoadBalancer`, `Firewall`, `DNS`, `Ingress` |
84
+ | `frontend` | Monitor | `WebApp`, `Dashboard`, `MobileApp`, `Browser`, `CLI`, `Terminal` |
85
+ | `service` | Rounded rectangle | `Service`, `API`, `Lambda`, `Handler`, `Controller`, `Processor`, `Worker` |
86
+ | `external` | Dashed rectangle | `External`, `ThirdParty`, `Vendor` |
87
+ | `default` | Rectangle | Anything unrecognized |
88
+
89
+ Names like `Router`, `Scheduler`, `Controller`, `Handler`, `Worker`, etc. are treated as services (not actors), even though they end in `-er`.
90
+
91
+ ### Explicit Declarations (Optional)
92
+
93
+ You only need explicit declarations when you want to **override** the inferred type, set a **display alias**, or control **position**:
94
+
95
+ ```
96
+ // Override type when the name doesn't match conventions
97
+ Stripe is an external
98
+
99
+ // Set a display alias for a cleaner label
100
+ PaymentGW is a networking aka "Payment Gateway"
101
+
102
+ // Control left-to-right ordering
103
+ OrderDB position -1
104
+ ```
105
+
106
+ Position `0` is leftmost, `-1` is rightmost. Unpositioned participants appear in first-mention order.
107
+
108
+ ## Messages
109
+
110
+ ### Call Arrows
111
+
112
+ A solid arrow from one participant to another:
113
+
114
+ ```
115
+ User -login-> API
116
+ ```
117
+
118
+ ### Return Arrows
119
+
120
+ Return arrows are generated automatically from the call stack. When A calls B, a dashed return arrow from B back to A appears once B's work is done:
121
+
122
+ ```
123
+ User -login-> API
124
+ API -query-> UserDB
125
+ // Auto-return: UserDB → API (dashed)
126
+ // Auto-return: API → User (dashed)
127
+ ```
128
+
129
+ ### Async / Fire-and-Forget
130
+
131
+ No return arrow, no activation on the target — use the `~` arrow:
132
+
133
+ ```
134
+ API ~sendWelcomeEmail~> EmailService
135
+ API ~logEvent~> LogService
136
+ ```
137
+
138
+ ### Self-Calls
139
+
140
+ A participant calling itself renders as a loopback arrow:
141
+
142
+ ```
143
+ OrderService -validate-> OrderService
144
+ ```
145
+
146
+ ## Blocks
147
+
148
+ Blocks use **indentation** for scoping — no `end` keyword needed.
149
+
150
+ ### If / Else
151
+
152
+ ```
153
+ if user authenticated
154
+ API -getOrders-> OrderService
155
+ OrderService -query-> OrderDB
156
+ else
157
+ API -401 Unauthorized-> User
158
+ ```
159
+
160
+ Renders as a dashed frame with an `if` label and an optional `else` divider.
161
+
162
+ ### Loop
163
+
164
+ ```
165
+ loop retry up to 3 times
166
+ OrderService -request-> ExternalAPI
167
+ ```
168
+
169
+ ### Parallel
170
+
171
+ ```
172
+ parallel send notifications
173
+ API ~email~> EmailService
174
+ API ~text~> SMSService
175
+ ```
176
+
177
+ Blocks can nest inside each other. Unindent to end a block.
178
+
179
+ ## Notes
180
+
181
+ Add context between messages with `note`:
182
+
183
+ ```
184
+ User -POST /login-> API
185
+ note Validates credentials against LDAP
186
+ API -query-> UserDB
187
+ ```
188
+
189
+ The note appears between the two surrounding messages.
190
+
191
+ ## Sections
192
+
193
+ Full-width horizontal dividers to organize phases:
194
+
195
+ ```
196
+ == Authentication ==
197
+
198
+ User -login-> API
199
+
200
+ == Data Fetch ==
201
+
202
+ API -query-> OrderDB
203
+
204
+ == Response ==
205
+
206
+ API -results-> User
207
+ ```
208
+
209
+ ## Groups
210
+
211
+ Organize participants into labeled boxes in the header:
212
+
213
+ ```
214
+ [Backend]
215
+ OrderService
216
+ PaymentService
217
+ OrderDB
218
+
219
+ [Frontend]
220
+ WebApp
221
+ MobileApp
222
+ ```
223
+
224
+ - `[Name]` declares a named group
225
+ - Indented names belong to the group
226
+ - Grouped participants stay adjacent in the layout
227
+ - Groups can carry tag metadata: `[Backend | team: Product]`
228
+
229
+ ## Activation Bars
230
+
231
+ Thin vertical rectangles on lifelines show when a participant has an active call. They are computed automatically from the call stack:
232
+
233
+ - Appear from call arrow to auto-generated return
234
+ - Nested calls show overlapping bars
235
+ - Self-calls show offset overlapping bars
236
+ - Disabled with `no-activations`
237
+
238
+ ## Comments
239
+
240
+ ```
241
+ // This is a comment
242
+ // Use // for all comments
243
+ ```
244
+
245
+ Lines starting with `//` are ignored by the parser.
246
+
247
+ ## Tags
248
+
249
+ Tags add color-coded metadata dimensions to sequence diagrams. Define a tag group, list its values with colors, then attach values to participants, messages, and groups with pipe metadata.
250
+
251
+ ### Defining Tag Groups
252
+
253
+ ```
254
+ tag Concern alias c
255
+ Caching(blue)
256
+ Auth(green)
257
+ BusinessLogic(purple) default
258
+ ```
259
+
260
+ - `tag Name` declares a tag group; `alias x` adds a shorthand
261
+ - Each entry: `Value(color)` — named color for that value
262
+ - `default` on an entry applies it to untagged elements when the group is active
263
+
264
+ ### Attaching Tags
265
+
266
+ Use `| key: value` after participant declarations, message lines, or group headers:
267
+
268
+ ```
269
+ API is a service | concern: Caching, team: Platform
270
+ User -login-> API | concern: Auth
271
+ [Backend | concern: BusinessLogic]
272
+ OrderAPI
273
+ DB
274
+ ```
275
+
276
+ - Multiple tags: `| key1: val1, key2: val2`
277
+ - Aliases work: `| c: Caching` (if `alias c` was declared)
278
+
279
+ ### Tag Resolution
280
+
281
+ When a tag group is active, colors are resolved in priority order:
282
+
283
+ 1. Explicit metadata on the element
284
+ 2. Group propagation (participant inherits from its group)
285
+ 3. Receiver inheritance (all incoming tagged messages agree on the same value)
286
+ 4. `default` entry value
287
+ 5. Neutral (no color)
288
+
289
+ ### Legend
290
+
291
+ A legend is rendered automatically above participants when tag groups exist. The active group expands to show colored entry dots. In the desktop app, click a group pill to activate it — participants and messages recolor to show that dimension.
292
+
293
+ Set `active-tag GroupName` in settings to activate a group on load.
294
+
295
+ ## Complete Example
296
+
297
+ ```dgmo
298
+ sequence E-Commerce Checkout
299
+
300
+ tag Layer alias l
301
+ Frontend(teal)
302
+ Backend(blue)
303
+ Storage(purple)
304
+
305
+ [Backend]
306
+ OrderService
307
+ PaymentGateway
308
+ OrderDB
309
+
310
+ == Browse & Select ==
311
+
312
+ User -Add items to cart-> WebApp
313
+ WebApp -validateCart-> OrderService
314
+
315
+ == Payment ==
316
+
317
+ User -Submit payment-> WebApp
318
+ WebApp -createOrder-> OrderService
319
+ OrderService -charge(amount)-> PaymentGateway
320
+
321
+ if payment successful
322
+ OrderService -saveOrder-> OrderDB
323
+ OrderService ~sendReceipt~> EmailService
324
+ WebApp -Order confirmed-> User
325
+ else
326
+ WebApp -Payment declined-> User
327
+
328
+ == Cleanup ==
329
+
330
+ loop expire stale carts
331
+ OrderService -purgeExpired-> OrderDB
332
+ ```