@cardenelabs/dragon 0.46.0 → 0.46.3
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.ja.md +331 -0
- package/README.md +200 -188
- package/dist/cli.cjs +61 -15
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +61 -15
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +57 -12
- package/dist/export.cjs.map +1 -1
- package/dist/export.js +57 -12
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +54 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -8
- package/dist/index.js.map +1 -1
- package/dist/light/index.cjs +52 -6
- package/dist/light/index.cjs.map +1 -1
- package/dist/light/index.js +52 -6
- package/dist/light/index.js.map +1 -1
- package/dist/node.cjs +90 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +90 -3
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +2 -2
- package/src/field-messages.ts +4 -0
- package/src/messages.ts +10 -3
- package/src/nearest.ts +37 -0
- package/src/parser.ts +1 -1
- package/src/schema.ts +21 -3
package/README.md
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
# @cardenelabs/dragon
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Animated diagrams that people write in a plain notation and AI writes as JSON.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[日本語](https://github.com/cardene777/dragon/blob/main/packages/dragon/README.ja.md)
|
|
6
|
+
|
|
7
|
+
dragon draws a diagram that plays step by step from a short text file.
|
|
8
|
+
The catalog, with every kind of diagram and an editor that plays what you type, is at <https://cardene777.github.io/dragon/>.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
6
11
|
|
|
7
12
|
```sh
|
|
8
13
|
npm install @cardenelabs/dragon
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
今までの記法 (日本語の鍵の YAML と JSON)、`textDslToDiagram` と `jsonToDiagram` を含む入口、`@cardenelabs/cdl` へ渡して描く仕組みは [#2983](https://github.com/cardene777/dragon/issues/2983) で消した。
|
|
13
|
-
作り直しで決めたことは [#2982](https://github.com/cardene777/dragon/issues/2982) にまとめている。
|
|
16
|
+
The package has four parts.
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
| Part | What it is |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Source | JSON with a shared skeleton and fields for each kind of diagram. It carries a format version, and older versions are converted when read |
|
|
21
|
+
| Notation | The dragon notation, where the first English word of each line decides its kind (the section below). It converts to and from JSON, and names and text can be in any language ([notation guide](https://github.com/cardene777/dragon/blob/main/packages/dragon/examples/quick-start.en.md)) |
|
|
22
|
+
| Renderer | Draws the source on a page and plays it one step at a time. It draws sequence, architecture, state, git, time, and tree diagrams |
|
|
23
|
+
| Export | The `dragon export` command writes MP4, GIF, HTML, and PNG from the same source |
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
## A first diagram
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
```dragon
|
|
28
|
+
sequence Ask to sign in
|
|
29
|
+
|
|
30
|
+
box browser as User's browser [note: operated by the user, color: slate]
|
|
31
|
+
box app as App [note: asks for sign-in, color: blue]
|
|
32
|
+
|
|
33
|
+
step Press sign in
|
|
34
|
+
say The user presses the app's sign-in button.
|
|
35
|
+
browser -> app: GET /login
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Paste it into the editor on the catalog to watch it play, or put it on your own page as the next section shows.
|
|
27
39
|
|
|
28
|
-
##
|
|
40
|
+
## Put it on a page
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
Import the font entry `@cardenelabs/dragon/fonts` once on the page, and pass the source read from the notation to `mountDiagram`.
|
|
31
43
|
|
|
32
44
|
```ts
|
|
33
45
|
import "@cardenelabs/dragon/fonts";
|
|
@@ -42,22 +54,22 @@ if (host === null) throw new Error("#figure not found");
|
|
|
42
54
|
const player = mountDiagram(host, parsed.diagram);
|
|
43
55
|
```
|
|
44
56
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
The font entry only loads the CSS for the two bundled fonts (Noto Sans JP and JetBrains Mono) and exports nothing.
|
|
58
|
+
Diagrams are laid out with character widths measured from the bundled fonts, so without it they are drawn in the device's fonts and text can overflow its labels.
|
|
59
|
+
A bundler (such as Vite) carries the CSS and font files to the page.
|
|
60
|
+
The entry does not read Node's built-in modules, so it also works with bundlers such as Next.js Turbopack.
|
|
61
|
+
`migrateFile`, which moves a source file to the current format version, comes from the Node-only entry `@cardenelabs/dragon/node`.
|
|
50
62
|
|
|
51
|
-
`
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
`still: true`
|
|
55
|
-
`
|
|
56
|
-
|
|
63
|
+
Use the `player` returned by `mountDiagram` to move through the steps (`next`, `prev`, `play`, `pause`, `destroy`).
|
|
64
|
+
The third argument takes settings (`PlayerOptions`), such as the palette and a function called when the step changes.
|
|
65
|
+
To place a diagram stopped on a still of one step, pass the step number (from 0) as `pausedAt`, and to play it once and stop on the last step, pass `playOnce: true`.
|
|
66
|
+
`still: true` stops on the last step, shows every step's line labels and box actions as strongly as the last step's, and does not move, so readers who do not play the diagram still see the whole flow in one picture.
|
|
67
|
+
`renderDiagram` also takes `still`.
|
|
68
|
+
Without any of these, the diagram plays every step on a loop from the moment it is placed.
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
Choose colors by name with `palette`, and pass color variable names and values in `colors` to override only those colors for the current `theme`.
|
|
71
|
+
The keys are the names the palette has (`bg`, `surf`, `ink`, `line`, `c-green`, `t-green`, and so on; the type is `ColorName`), and the colors you leave out keep the palette's values.
|
|
72
|
+
The placed diagram, the overview shown while following, and the buttons and step bar all use the same colors, and `renderDiagram` takes the same `colors`.
|
|
61
73
|
|
|
62
74
|
```ts
|
|
63
75
|
mountDiagram(host, parsed.diagram, {
|
|
@@ -66,13 +78,13 @@ mountDiagram(host, parsed.diagram, {
|
|
|
66
78
|
});
|
|
67
79
|
```
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
A name the palette does not have, or a value that cannot be read as a color (one that contains `;`, `"`, `<`, and so on), is refused with that name and nothing is drawn.
|
|
70
82
|
|
|
71
|
-
##
|
|
83
|
+
## Load diagram kinds on demand
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
To keep what a page loads first small, import from `@cardenelabs/dragon/light`.
|
|
86
|
+
It exports the same functions as the default entry, but leaves out the renderers for `git`, `lineup`, `state`, `time`, and `tree` and loads them when you await `loadKind`.
|
|
87
|
+
After that, the same functions as the default entry draw the same diagram without waiting.
|
|
76
88
|
|
|
77
89
|
```ts
|
|
78
90
|
import { loadKind, mountDiagram, parseNotation } from "@cardenelabs/dragon/light";
|
|
@@ -84,234 +96,234 @@ if (parsed.ok) {
|
|
|
84
96
|
}
|
|
85
97
|
```
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
`sequence`
|
|
90
|
-
|
|
99
|
+
Drawing a kind that has not been loaded stops with an error that names the kind.
|
|
100
|
+
If loading fails, `loadKind` rejects, and the next call loads it again.
|
|
101
|
+
`sequence` and `architecture` are there from the start, so they draw without calling `loadKind`.
|
|
102
|
+
Mixing it with the default entry on one page puts every kind's renderer on the page.
|
|
91
103
|
|
|
92
|
-
##
|
|
104
|
+
## Notation
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
Every line follows these four rules.
|
|
95
107
|
|
|
96
|
-
1.
|
|
97
|
-
2.
|
|
98
|
-
3.
|
|
99
|
-
4.
|
|
108
|
+
1. The first English word of a line decides its kind. Only arrow lines start with a box id
|
|
109
|
+
2. A colon separates a key from its value, and attributes go inside `[ ]`, separated by `,`
|
|
110
|
+
3. Names and text with spaces go at the end of the line or before `[`. Wrap only values that contain `,` or `]` and names that contain `[` in `"`
|
|
111
|
+
4. The only nesting is `group … end`. A step runs until the next `step`, and indentation is for reading. Only the lines that continue a `say` must be indented deeper than `say`
|
|
100
112
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
The words that start a line are `sequence` `architecture` `state` `git` `time` `tree` `group` `end` `box` `branch` `scale` `period` `row` `point` `zoom` `strip` `step` `say` `code` `source` `commit` `mark` `span` `leaf` `node` `act` `note` `set`, and a line is written as `id -> id`.
|
|
114
|
+
A destination in the `link` attribute of a box line makes that box a link in the drawn diagram.
|
|
115
|
+
A `source <name> [url: <URL>]` line inside a step is a source of that step; a step can have any number, and they are listed as links in the step list that screen readers read.
|
|
116
|
+
A destination or source URL is a path that starts with `/`, or a URL that starts with `http://` or `https://`.
|
|
105
117
|
|
|
106
118
|
```dragon
|
|
107
|
-
architecture
|
|
119
|
+
architecture Send orders to the warehouse
|
|
108
120
|
|
|
109
|
-
group
|
|
110
|
-
box
|
|
121
|
+
group shop as Shop [note: takes orders, color: blue, icon: cart]
|
|
122
|
+
box intake as Intake [note: takes the order, icon: app]
|
|
111
123
|
end
|
|
112
124
|
|
|
113
|
-
group
|
|
114
|
-
box
|
|
125
|
+
group warehouse as Warehouse [note: ships the goods, color: green, icon: box]
|
|
126
|
+
box shipping as Shipping [note: ships the goods, icon: truck]
|
|
115
127
|
end
|
|
116
128
|
|
|
117
|
-
step
|
|
129
|
+
step Pass to shipping
|
|
118
130
|
say
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
Intake bundles two order numbers and passes them to shipping.
|
|
132
|
+
Shipping sends the goods in the order the numbers arrive.
|
|
133
|
+
intake -> shipping: OK to ship [tag: "#42, #43"]
|
|
122
134
|
```
|
|
123
135
|
|
|
124
|
-
`parseNotation`
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
136
|
+
`parseNotation` turns the notation into the source JSON, and `printNotation` turns the source JSON back into the notation.
|
|
137
|
+
Error messages are in the language you pass, as in `parseNotation(text, { lang: "en" })`, and are in Japanese when you pass none.
|
|
138
|
+
The old form of the notation (starting with `時系列図` or `構成図`) is not read, and stops with an error that shows the new form of that line.
|
|
139
|
+
The table from the old form to the new one is in [`CHANGELOG.md`](https://github.com/cardene777/dragon/blob/main/CHANGELOG.md).
|
|
128
140
|
|
|
129
|
-
###
|
|
141
|
+
### State diagram
|
|
130
142
|
|
|
131
|
-
`state`
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
Starting with `state` makes a state diagram that follows one thing moving between states step by step. Each box is a state, and each line is a move from one state to another.
|
|
144
|
+
Write `start` on the sending side for a line out of the start mark, and `finish` on the receiving side for a line into the end mark.
|
|
145
|
+
Lines written before the first `step` are paths the diagram could take but does not this time, drawn dotted.
|
|
134
146
|
|
|
135
147
|
```dragon
|
|
136
|
-
state
|
|
148
|
+
state States of an order until it arrives
|
|
137
149
|
|
|
138
|
-
box
|
|
139
|
-
box
|
|
140
|
-
box
|
|
141
|
-
box
|
|
150
|
+
box awaiting as Awaiting payment [note: Waits for funds, color: amber, icon: clock]
|
|
151
|
+
box shipped as Shipped [note: With the carrier, color: violet, icon: truck]
|
|
152
|
+
box delivered as Delivered [note: Handed over, color: green, icon: check]
|
|
153
|
+
box cancelled as Cancelled [note: Payment returned, color: rose, icon: x]
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
awaiting -> cancelled: Cancel
|
|
156
|
+
cancelled -> finish
|
|
145
157
|
|
|
146
|
-
step
|
|
147
|
-
say
|
|
148
|
-
start ->
|
|
158
|
+
step Place the order
|
|
159
|
+
say Confirming the order starts it at Awaiting payment.
|
|
160
|
+
start -> awaiting: Place order [tag: #1042]
|
|
149
161
|
|
|
150
|
-
step
|
|
151
|
-
say
|
|
152
|
-
|
|
162
|
+
step Ship
|
|
163
|
+
say Once the payment clears, the goods go out and the order moves to Shipped.
|
|
164
|
+
awaiting -> shipped: Ship [tag: #1042]
|
|
153
165
|
|
|
154
|
-
step
|
|
155
|
-
say
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
step Arrive
|
|
167
|
+
say The goods arrive, the order moves to Delivered, and it closes.
|
|
168
|
+
shipped -> delivered: Receive [tag: #1042]
|
|
169
|
+
delivered -> finish: Close the order [tag: #1042]
|
|
158
170
|
```
|
|
159
171
|
|
|
160
|
-
###
|
|
172
|
+
### Git graph
|
|
161
173
|
|
|
162
|
-
`git`
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
Starting with `git` makes a git graph that follows commits stacking on branches until they are merged, step by step. Declare branches on `branch` lines from the top, and each branch gets its own band.
|
|
175
|
+
Inside a step, `commit <id> on <branch>` adds a commit to the tip of the branch, `copy <source>` makes a replayed commit, and `merge <branch>` makes a merge commit. `hash` and `note` put a hash and a short note beside the circle.
|
|
176
|
+
`<branch> from <commit>` cuts a branch, and `<ref> -> <commit>` moves a branch ref or `HEAD` without making a commit. A commit that no ref can reach any more turns into a dotted circle.
|
|
165
177
|
|
|
166
178
|
```dragon
|
|
167
|
-
git fix
|
|
179
|
+
git Merge fix with a merge commit and replay feature
|
|
168
180
|
|
|
169
|
-
branch main [note:
|
|
170
|
-
branch feature [note:
|
|
171
|
-
branch fix [note:
|
|
181
|
+
branch main [note: Target]
|
|
182
|
+
branch feature [note: Work branch]
|
|
183
|
+
branch fix [note: Fix branch]
|
|
172
184
|
|
|
173
|
-
step
|
|
174
|
-
say
|
|
175
|
-
commit A on main [hash: 3fa0c19, note:
|
|
185
|
+
step Cut branches
|
|
186
|
+
say Cut fix and feature from A on main, and add a commit to each.
|
|
187
|
+
commit A on main [hash: 3fa0c19, note: First shape]
|
|
176
188
|
fix from A
|
|
177
|
-
commit F on fix [hash: 9b2e4d1, note:
|
|
189
|
+
commit F on fix [hash: 9b2e4d1, note: Fix a typo]
|
|
178
190
|
feature from A
|
|
179
|
-
commit C on feature [hash: c41d0e5, note:
|
|
191
|
+
commit C on feature [hash: c41d0e5, note: Add search]
|
|
180
192
|
|
|
181
|
-
step
|
|
182
|
-
say fix
|
|
183
|
-
commit M on main merge fix [hash: 7d3a5e2, note: fix
|
|
193
|
+
step Merge commit
|
|
194
|
+
say Merge fix into main with merge commit M. M has two parents, A and F.
|
|
195
|
+
commit M on main merge fix [hash: 7d3a5e2, note: Merge fix]
|
|
184
196
|
|
|
185
|
-
step
|
|
186
|
-
say HEAD
|
|
197
|
+
step Replay
|
|
198
|
+
say Move HEAD to M to detach it, and copy C onto M as C'.
|
|
187
199
|
HEAD -> M
|
|
188
|
-
commit C' on main copy C [hash: a90c6b4, note:
|
|
200
|
+
commit C' on main copy C [hash: a90c6b4, note: Add search]
|
|
189
201
|
|
|
190
|
-
step
|
|
191
|
-
say feature
|
|
202
|
+
step Fast-forward
|
|
203
|
+
say Move feature to C', and move main up to C' too. The old C can no longer be reached from any branch.
|
|
192
204
|
feature -> C'
|
|
193
205
|
main -> C'
|
|
194
206
|
```
|
|
195
207
|
|
|
196
|
-
###
|
|
208
|
+
### Time diagram
|
|
197
209
|
|
|
198
|
-
`time`
|
|
199
|
-
|
|
200
|
-
|
|
210
|
+
Starting with `time` makes a time diagram that follows, step by step, which tick each event happens on along evenly spaced time. `scale <unit> <length> <count>` declares the ticks, `period` the periods, `row` a row of marks, `point` a point below the axis, and `zoom <range>` the ticks to zoom in on in the top band.
|
|
211
|
+
Inside a step, `now -> <tick>` moves the needle. The needle moves one tick at a fixed speed, and the marks of the ticks it passes appear as it goes. `mark` changes the color of marks, and `span` puts a bracket under the axis or a frame around the rows.
|
|
212
|
+
`[meter: <ratio>]` on a strip field makes a meter that fills with the needle up to the ratio written with `set`.
|
|
201
213
|
|
|
202
214
|
```dragon
|
|
203
|
-
time
|
|
215
|
+
time How a block becomes final
|
|
204
216
|
|
|
205
217
|
scale slot 12s 64
|
|
206
218
|
period epoch 32
|
|
207
|
-
row
|
|
219
|
+
row block [color: blue, empty: 5]
|
|
208
220
|
point C0 at 0
|
|
209
221
|
point C1 at 32
|
|
210
222
|
zoom 0-1
|
|
211
223
|
|
|
212
|
-
box
|
|
213
|
-
box
|
|
224
|
+
box proposer [color: blue, icon: user]
|
|
225
|
+
box block [color: blue, icon: box]
|
|
214
226
|
|
|
215
|
-
strip
|
|
227
|
+
strip Finality: Elapsed, Votes this epoch [meter: 2/3]
|
|
216
228
|
|
|
217
|
-
step
|
|
218
|
-
say slot
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
step Propose blocks
|
|
230
|
+
say In each slot one proposer is chosen and proposes one block. The top band zooms in on the first 2 slots.
|
|
231
|
+
proposer -> block [at: 0]
|
|
232
|
+
proposer -> block [at: 1]
|
|
221
233
|
now -> 1
|
|
222
|
-
set
|
|
234
|
+
set Elapsed: 24 s
|
|
223
235
|
|
|
224
|
-
step
|
|
225
|
-
say 32
|
|
226
|
-
note C0:
|
|
227
|
-
span 0-31: 1 epoch = 6.4
|
|
236
|
+
step Collect one epoch of votes
|
|
237
|
+
say 32 slots make one epoch. A block mark appears on each slot the needle passes, and a slot whose proposer did not answer gets an empty mark.
|
|
238
|
+
note C0: Proposed [color: blue]
|
|
239
|
+
span 0-31: 1 epoch = 6.4 min [color: slate]
|
|
228
240
|
now -> 31
|
|
229
|
-
set
|
|
230
|
-
set
|
|
241
|
+
set Elapsed: 6 min 24 s
|
|
242
|
+
set Votes this epoch: 97%
|
|
231
243
|
|
|
232
|
-
step
|
|
233
|
-
say C0
|
|
234
|
-
note C0:
|
|
235
|
-
note C1:
|
|
244
|
+
step Move to the next epoch
|
|
245
|
+
say Votes for C0 passed 2/3 of the total, so C0 is justified. In the next epoch, votes gather on C1.
|
|
246
|
+
note C0: Justified [color: violet]
|
|
247
|
+
note C1: Proposed [color: blue]
|
|
236
248
|
now -> 63
|
|
237
|
-
set
|
|
238
|
-
set
|
|
239
|
-
|
|
240
|
-
step C0
|
|
241
|
-
say C1
|
|
242
|
-
C0 -> C1: 2/3
|
|
243
|
-
note C1:
|
|
244
|
-
note C0:
|
|
245
|
-
mark
|
|
246
|
-
span 0-31:
|
|
249
|
+
set Elapsed: 12 min 48 s
|
|
250
|
+
set Votes this epoch: 97%
|
|
251
|
+
|
|
252
|
+
step C0 becomes final
|
|
253
|
+
say Once C1 is justified too, the earlier of the two justified in a row, C0, becomes final. A final block cannot be undone.
|
|
254
|
+
C0 -> C1: over 2/3 [carry: none]
|
|
255
|
+
note C1: Justified [color: violet]
|
|
256
|
+
note C0: Final [color: green]
|
|
257
|
+
mark block 0-31 [color: green]
|
|
258
|
+
span 0-31: Final, cannot be undone [shape: box, color: rose]
|
|
247
259
|
```
|
|
248
260
|
|
|
249
|
-
###
|
|
261
|
+
### Tree diagram
|
|
250
262
|
|
|
251
|
-
`tree`
|
|
252
|
-
|
|
253
|
-
|
|
263
|
+
Starting with `tree` makes a tree diagram that follows, step by step, how leaf values fold up into their parents until one root remains. Inside a step, `leaf <id> [hash: <value>]` writes a leaf and `node <id> of <child>, <child> [hash: <value>]` writes a parent, and each box appears in the step that writes it.
|
|
264
|
+
Leaves line up from the left in written order, a parent sits above the middle of its children, and the box that no parent takes becomes the root.
|
|
265
|
+
A carrier on a line between a parent and a child runs along the tree line, and the tree line keeps that color once passed. From the step a carrier first runs on a tree line, only the boxes that send or receive carriers are drawn strongly.
|
|
254
266
|
|
|
255
267
|
```dragon
|
|
256
|
-
tree
|
|
257
|
-
|
|
258
|
-
step
|
|
259
|
-
say 4
|
|
260
|
-
leaf
|
|
261
|
-
leaf
|
|
262
|
-
leaf
|
|
263
|
-
leaf
|
|
264
|
-
|
|
265
|
-
step
|
|
266
|
-
say
|
|
267
|
-
node
|
|
268
|
-
node
|
|
269
|
-
|
|
270
|
-
step
|
|
271
|
-
say
|
|
272
|
-
node
|
|
273
|
-
|
|
274
|
-
step
|
|
275
|
-
say
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
268
|
+
tree Proving a transaction is included
|
|
269
|
+
|
|
270
|
+
step Hash each transaction
|
|
271
|
+
say Compute a value from each of the 4 transactions. These values become the leaves.
|
|
272
|
+
leaf tx1 [hash: 3fa0]
|
|
273
|
+
leaf tx2 [hash: 8b04]
|
|
274
|
+
leaf tx3 [hash: c41d]
|
|
275
|
+
leaf tx4 [hash: e5f8]
|
|
276
|
+
|
|
277
|
+
step Pair them up
|
|
278
|
+
say Join neighbouring values two at a time and hash again. Two parents appear.
|
|
279
|
+
node 1to2 of tx1, tx2 [hash: 7a21]
|
|
280
|
+
node 3to4 of tx3, tx4 [hash: b9e4]
|
|
281
|
+
|
|
282
|
+
step The root appears
|
|
283
|
+
say Joining the last two gives one root that sums up every transaction.
|
|
284
|
+
node root of 1to2, 3to4 [hash: e71c]
|
|
285
|
+
|
|
286
|
+
step Climb from tx3 to the root
|
|
287
|
+
say Take the neighbouring value at each level and climb. The root comes out without reading tx1 or tx2.
|
|
288
|
+
tx3 -> 3to4 [tag: c41d]
|
|
289
|
+
tx4 -> 3to4 [tag: e5f8]
|
|
290
|
+
3to4 -> root [tag: b9e4]
|
|
291
|
+
1to2 -> root [tag: 7a21]
|
|
280
292
|
```
|
|
281
293
|
|
|
282
|
-
##
|
|
294
|
+
## Export
|
|
283
295
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
296
|
+
Export uses a headless Chromium and captures the same drawing as the page one frame at a time, with the clock stopped.
|
|
297
|
+
The captured frames are packed into MP4 and GIF inside the same Chromium, so ffmpeg is not needed.
|
|
298
|
+
Install `playwright-core`, which runs Chromium, only when you use export.
|
|
287
299
|
|
|
288
300
|
```sh
|
|
289
301
|
pnpm add -D playwright-core
|
|
290
302
|
pnpm exec playwright-core install chromium
|
|
291
303
|
```
|
|
292
304
|
|
|
293
|
-
|
|
305
|
+
Pass the source JSON (`.json`) or the notation (`.dragon`) and it writes four files with the same name.
|
|
294
306
|
|
|
295
307
|
```sh
|
|
296
308
|
dragon export ccip.json --out out
|
|
297
309
|
```
|
|
298
310
|
|
|
299
|
-
|
|
|
311
|
+
| Option | Meaning |
|
|
300
312
|
|---|---|
|
|
301
|
-
| `--out <dir>` |
|
|
302
|
-
| `--width <px>` |
|
|
303
|
-
| `--palette
|
|
304
|
-
| `--theme
|
|
305
|
-
| `--lang
|
|
306
|
-
| `--fps
|
|
307
|
-
| `--gif-fps
|
|
308
|
-
| `--format
|
|
309
|
-
|
|
310
|
-
PNG
|
|
311
|
-
|
|
312
|
-
HTML
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
##
|
|
313
|
+
| `--out <dir>` | Where to write. Created if missing (default: the current dir) |
|
|
314
|
+
| `--width <px>` | Frame width. Picks the view (`fixed` / `follow`) and sets the window width for `follow` |
|
|
315
|
+
| `--palette <name>` | Colors (`clear` / `paper` / `night`, default `paper`) |
|
|
316
|
+
| `--theme <mode>` | `light` or `dark` |
|
|
317
|
+
| `--lang <lang>` | Language of the text in the diagram (overview labels, the names read in HTML, and the message when it cannot draw) and of the command's usage and error messages (`ja` or `en`). Defaults to `ja` for both notation files and source JSON |
|
|
318
|
+
| `--fps <n>` | Frames per second of the MP4 (default 30) |
|
|
319
|
+
| `--gif-fps <n>` | Frames per second of the GIF (default 10) |
|
|
320
|
+
| `--format <formats>` | The formats to write, separated by `,` (default `mp4,gif,html,png`) |
|
|
321
|
+
|
|
322
|
+
The PNG is a still of the last step in the `fixed` view.
|
|
323
|
+
When text overlaps in some step, the export still finishes and prints each overlap on its own line to standard error, with the step and the text (with `--lang en`, for example `Step 5: Step number 1 and step number 5 overlap`). The exit code stays 0.
|
|
324
|
+
The HTML is a single file with fonts cut down to the characters the diagram draws, and it fetches nothing from outside.
|
|
325
|
+
To call it from Node, use `exportDiagram` from `@cardenelabs/dragon/export`.
|
|
326
|
+
|
|
327
|
+
## License
|
|
316
328
|
|
|
317
329
|
MIT
|