pele-animate 0.16.0 → 0.16.1

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.
@@ -7,16 +7,38 @@ section: Start
7
7
 
8
8
  # Diagram types
9
9
 
10
- pele-animate supports **flowcharts**, **sequence diagrams**, **architecture diagrams** and **state diagrams** and **C4 context diagrams** and **block diagrams**, **class diagrams**, **ER diagrams**, **timelines**, **user journeys**, **git graphs** and **Gantt charts**. Pele renders other diagram types too, but they are outside what
11
- pele-animate is built for.
10
+ pele-animate animates these Mermaid diagram types. Each one plays an intro when it scrolls into view and, on click, steps through its
11
+ items with previous / play / next controls.
12
+
13
+ | Type | Each step reveals | Pins, icons | Remarks |
14
+ |---|---|---|---|
15
+ | [Flowchart](#flowcharts)<br>`flowchart` | Nodes level by level, edges from their source | Pins and icons | The fullest support: groups, edge labels, large icon nodes. |
16
+ | [Sequence diagram](#sequence-diagrams)<br>`sequenceDiagram` | Actors, then one message at a time | Neither | The order is the source order; reordering messages changes what the diagram says. |
17
+ | [Architecture](#architecture-diagrams)<br>`architecture-beta` | Services level by level, edges from their source | Pins and icons | Icons are written `(name)` and are small and fixed in size. |
18
+ | [State diagram](#state-diagrams)<br>`stateDiagram-v2` | States and transitions from the start marker | Pins | Markers are `root_start` and `root_end`. Composite states are untested. |
19
+ | [C4 context](#c4-context-diagrams)<br>`C4Context` | People and systems, then relationships | Pins | Only `C4Context` is checked. Keep `Rel` labels short. |
20
+ | [Block diagram](#block-diagrams)<br>`block-beta` | Blocks and arrows from their source | Pins | Put linked blocks in the same row or column. |
21
+ | [Class diagram](#class-diagrams)<br>`classDiagram` | Classes and relationships, from the class written first | Pins | `A <\|-- B` reveals `A`, then `B`. |
22
+ | [ER diagram](#er-diagrams)<br>`erDiagram` | Entities and relationships, from the entity written first | Pins | Same written-order rule as class diagrams. |
23
+ | [Timeline](#timelines-journeys-git-graphs-and-gantt-charts)<br>`timeline` | One time period with its events | Neither | Section headers stay visible. |
24
+ | [User journey](#timelines-journeys-git-graphs-and-gantt-charts)<br>`journey` | One task, its face and the line joining it to the last | Neither | |
25
+ | [Git graph](#timelines-journeys-git-graphs-and-gantt-charts)<br>`gitGraph` | One commit with its edge; a branch with its first commit | Neither | Cherry-picks and tags are untested. |
26
+ | [Gantt chart](#timelines-journeys-git-graphs-and-gantt-charts)<br>`gantt` | One task, top to bottom | Neither | `todayMarker` and parallel tasks are untested. |
27
+
28
+ Pins are `%% pa:` comments; see [step order](./step-order.md). Types without pins use their source order. Icons are set up in
29
+ [icons](./icons.md). Pele renders the other Mermaid types too (pie, quadrant, radar and the rest), but pele-animate is not built
30
+ for them; see [Everything else](#everything-else).
12
31
 
13
32
  ## Flowcharts
14
33
 
15
34
  Nodes appear in step order, edges draw from their source node, and edge labels fade in. Groups (`subgraph`) and their titles
16
35
  are kept. Icon nodes (`@{ icon }`) work here; see [icons](./icons.md).
17
36
 
37
+ The pins below put "Serve" (the cache hit) before "Fetch", then draw the `Fetch` to `Serve` edge as its own last step. Without them, `Serve` and `Fetch` would appear together.
38
+
18
39
  ```mermaid live
19
40
  flowchart LR
41
+ %% pa: 1=A 2=B 3=C 4=D 5=D>C
20
42
  A[Client] --> B{Cached?}
21
43
  B -->|yes| C[Serve]
22
44
  B -->|no| D[Fetch] --> C
@@ -24,11 +46,13 @@ flowchart LR
24
46
 
25
47
  ## Sequence diagrams
26
48
 
27
- Actors appear first, then the messages in order. Participant boxes in a row get the same height, and group titles are bold.
49
+ Actors appear first, then one step per message in source order, so a cache miss reads as five short steps. Participant boxes in a row get the same height, and group titles are bold.
28
50
 
29
51
  ```mermaid live
30
52
  sequenceDiagram
31
53
  Client->>API: request
54
+ API->>Cache: lookup
55
+ Cache-->>API: miss
32
56
  API->>Database: query
33
57
  Database-->>API: rows
34
58
  API-->>Client: response
@@ -40,19 +64,26 @@ sequenceDiagram
40
64
 
41
65
  `architecture-beta`: services in groups, joined by edges. Services appear in step order like flowchart nodes, groups stay visible,
42
66
  and `%% pa:` pins work the same way. The icon in parentheses is looked up in your icon packs, so Tabler names and `doverunner-*`
43
- names work (import the packs as for [icons](./icons.md)).
67
+ names work (import the packs as for [icons](./icons.md)). The pins here follow a request: the user, the CDN, the API, the cache and database together, then the queue and worker.
44
68
 
45
69
  ```mermaid-icons live
46
70
  architecture-beta
71
+ %% pa: 1=user 2=cdn 3=api 4=cache,db 5=queue 6=worker
47
72
  group edge(cloud)[Edge]
48
73
  group core(cloud)[Core]
49
74
  service user(device-desktop)[User]
50
75
  service cdn(cloud-computing)[CDN] in edge
51
76
  service api(server)[API] in core
77
+ service cache(bolt)[Cache] in core
52
78
  service db(database)[Database] in core
79
+ service queue(mail)[Queue] in core
80
+ service worker(settings)[Worker] in core
53
81
  user:R --> L:cdn
54
82
  cdn:R --> L:api
55
- api:R --> L:db
83
+ api:T --> B:cache
84
+ api:B --> T:db
85
+ api:R --> L:queue
86
+ queue:R --> L:worker
56
87
  ```
57
88
 
58
89
  Icons here are small and fixed in size; `form` and `h` apply to flowcharts only. Edges are read from their written direction
@@ -65,33 +96,41 @@ start and end markers are nodes too, with the ids `root_start` and `root_end`, s
65
96
 
66
97
  ```mermaid live
67
98
  stateDiagram-v2
68
- %% pa: 1=root_start 2=Idle 3=Running 4=Paused 5=root_end
99
+ %% pa: 1=root_start 2=Idle 3=Loading 4=Playing 5=Paused 6=Error 7=root_end
69
100
  [*] --> Idle
70
- Idle --> Running: start
71
- Running --> Paused: pause
72
- Paused --> Running: resume
73
- Running --> [*]: done
101
+ Idle --> Loading: play
102
+ Loading --> Playing: ready
103
+ Playing --> Paused: pause
104
+ Paused --> Playing: resume
105
+ Loading --> Error: fail
106
+ Error --> Idle: retry
107
+ Playing --> [*]: stop
74
108
  ```
75
109
 
76
- Without pins the order is breadth-first from the start marker, which shows `Paused` and the end marker together. Pele gives
110
+ The pins give each state its own step, in the order a viewer meets them. Without pins the order is breadth-first from the start marker, which shows states at the same distance together (here `Playing` and `Error`). Pele gives
77
111
  state edges no readable ids, so pele-animate finds each transition's ends from where its path starts and stops. Composite
78
112
  states and forks are untested. State diagrams take no icons.
79
113
 
80
114
  ## C4 context diagrams
81
115
 
82
116
  `C4Context`: people and systems appear in step order and each `Rel` draws from its source, with its label. Pins use the ids you
83
- give `Person(...)` and `System(...)`; an edge pin is `3=app>drm`.
117
+ give `Person(...)` and `System(...)`; an edge pin is `3=app>drm`. The example adds the DRM service, CDN and analytics one at a time, then the operator who reads the analytics.
84
118
 
85
119
  ```mermaid live
86
120
  C4Context
87
- %% pa: 1=viewer 2=app 3=drm,cdn
121
+ %% pa: 1=viewer 2=app 3=drm 4=cdn 5=analytics 6=admin
88
122
  Person(viewer, "Viewer", "Watches video")
89
123
  System(app, "Player app", "Plays protected video")
90
124
  System_Ext(drm, "DRM service", "Issues licenses")
91
- System(cdn, "CDN", "Delivers segments")
92
- Rel(viewer, app, "uses")
125
+ System_Ext(cdn, "CDN", "Delivers segments")
126
+ System(analytics, "Analytics", "Tracks playback")
127
+ Person(admin, "Operator", "Reviews usage")
128
+ Rel(viewer, app, "watches")
93
129
  Rel(app, drm, "license")
94
130
  Rel(app, cdn, "segments")
131
+ Rel(app, analytics, "events")
132
+ Rel(admin, analytics, "reviews")
133
+ UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
95
134
  ```
96
135
 
97
136
  Pele lays C4 diagrams out in rows, so a long label between two boxes in the same row can leave no room for the arrowhead:
@@ -103,12 +142,14 @@ keep `Rel` labels short. Only `C4Context` has been checked; the other C4 types a
103
142
 
104
143
  ```mermaid live
105
144
  block-beta
106
- columns 3
107
- %% pa: 1=client 2=server 3=db
108
- client["Client"] space server["Server"]
109
- space space db[("Database")]
110
- client --> server
111
- server --> db
145
+ columns 4
146
+ %% pa: 1=src 2=enc 3=pkg 4=cdn 5=store
147
+ src["Source"] enc["Encode"] pkg["Package"] cdn["CDN"]
148
+ space space store[("Storage")] space
149
+ src --> enc
150
+ enc --> pkg
151
+ pkg --> cdn
152
+ pkg --> store
112
153
  ```
113
154
 
114
155
  Pele routes arrows between blocks in straight lines or short bends, so place linked blocks in the same row or column; a diagonal
@@ -116,30 +157,35 @@ neighbour can give a bent arrow that runs along another one. Block diagrams take
116
157
 
117
158
  ## Class diagrams
118
159
 
119
- `classDiagram`: classes appear in step order, relationships draw from the class written first. `Animal <|-- Dog` reveals `Animal`
120
- and then `Dog`, whichever way the arrowhead points. Pins use the class names.
160
+ `classDiagram`: classes appear in step order, relationships draw from the class written first. `Media <|-- Video` reveals `Media`
161
+ and then `Video`, whichever way the arrowhead points. Pins use the class names; the example shows the base class, its subtypes, then the classes that use them.
121
162
 
122
163
  ```mermaid live
123
164
  classDiagram
124
- %% pa: 1=Animal 2=Dog,Cat 3=Owner
125
- Animal <|-- Dog
126
- Animal <|-- Cat
127
- Dog --> Owner : has
128
- Animal : +name
129
- Dog : +bark()
165
+ %% pa: 1=Media 2=Video,Audio 3=Player 4=License 5=Session
166
+ Media <|-- Video
167
+ Media <|-- Audio
168
+ Player --> Media : plays
169
+ Player --> License : needs
170
+ License --> Session : opens
171
+ Media : +id
172
+ Media : +title
173
+ Player : +play()
174
+ License : +expiry
130
175
  ```
131
176
 
132
177
  ## ER diagrams
133
178
 
134
179
  `erDiagram`: entities appear in step order, relationships draw from the entity written first (`CUSTOMER ||--o{ ORDER` reveals
135
- `CUSTOMER`, then `ORDER`).
180
+ `CUSTOMER`, then `ORDER`). The example reads from the customer down to the supplier.
136
181
 
137
182
  ```mermaid live
138
183
  erDiagram
139
- %% pa: 1=CUSTOMER 2=ORDER 3=LINE,PRODUCT
184
+ %% pa: 1=CUSTOMER 2=ORDER 3=LINE 4=PRODUCT 5=SUPPLIER
140
185
  CUSTOMER ||--o{ ORDER : places
141
186
  ORDER ||--|{ LINE : contains
142
- PRODUCT ||--o{ LINE : in
187
+ LINE }o--|| PRODUCT : lists
188
+ PRODUCT }o--|| SUPPLIER : "supplied by"
143
189
  ```
144
190
 
145
191
  Neither takes icons.
@@ -149,28 +195,34 @@ Neither takes icons.
149
195
  These have no edges to follow, so each steps through its items in reading order and `%% pa:` pins do nothing (as for sequence
150
196
  diagrams). Section headers, axes, grids and legends stay visible.
151
197
 
152
- - **`timeline`:** one step per time period, with its events.
198
+ - **`timeline`:** one step per time period, with its events. List periods in time order.
153
199
 
154
200
  ```mermaid live
155
201
  timeline
156
- title History
157
- section Early
158
- 2002 : Launch : Beta
159
- 2004 : Growth
160
- section Late
161
- 2010 : Scale
202
+ title Product history
203
+ section Build
204
+ 2019 : Prototype
205
+ 2020 : Private beta : First customers
206
+ section Grow
207
+ 2021 : Public launch
208
+ 2023 : Mobile apps : Offline mode
209
+ 2025 : Global rollout
162
210
  ```
163
211
 
164
212
  - **`journey`:** one step per task: the task, its face, and the line segment that joins it to the task before.
165
213
 
166
214
  ```mermaid live
167
215
  journey
168
- title My day
169
- section Work
170
- Make tea: 5: Me, Bob
171
- Do work: 3: Me
172
- section Home
173
- Relax: 4: Me
216
+ title Watching a protected video
217
+ section Find
218
+ Open the app: 5: Viewer
219
+ Pick a title: 4: Viewer
220
+ section Play
221
+ Wait for the license: 2: Viewer, App
222
+ Playback starts: 5: Viewer
223
+ section Finish
224
+ Resume later: 4: Viewer
225
+ Rate the title: 3: Viewer
174
226
  ```
175
227
 
176
228
  - **`gitGraph`:** one step per commit in the order written, with the edge that ends on it. A branch's label and lane appear with
@@ -178,24 +230,31 @@ journey
178
230
 
179
231
  ```mermaid live
180
232
  gitGraph
181
- commit id: "a"
182
- branch dev
183
- commit id: "b"
233
+ commit id: "init"
234
+ branch feature
235
+ commit id: "api"
236
+ commit id: "ui"
184
237
  checkout main
185
- commit id: "c"
186
- merge dev id: "m"
238
+ commit id: "fix"
239
+ merge feature id: "m"
240
+ branch release
241
+ commit id: "v1"
187
242
  ```
188
243
 
189
- - **`gantt`:** one step per task, top to bottom.
244
+ - **`gantt`:** one step per task, top to bottom: write tasks in the order you want them to appear.
190
245
 
191
246
  ```mermaid live
192
247
  gantt
193
248
  dateFormat YYYY-MM-DD
249
+ section Plan
250
+ Scope :a1, 2024-01-01, 3d
251
+ Design :after a1, 4d
194
252
  section Build
195
- Design :a1, 2024-01-01, 3d
196
- Code :after a1, 4d
253
+ Code :b1, 2024-01-08, 8d
254
+ Review :after b1, 2d
197
255
  section Ship
198
- Test :2024-01-08, 2d
256
+ Test :2024-01-18, 4d
257
+ Release :2024-01-22, 1d
199
258
  ```
200
259
 
201
260
  None of these take icons. Only these small examples have been checked in a browser; long diagrams, `todayMarker`, tags, cherry-picks and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pele-animate",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Step-by-step animated Mermaid diagrams with icons: an unofficial add-on for the Pele renderer.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/pele-animate.js CHANGED
@@ -127,12 +127,15 @@ function sequentialSteps(svg) {
127
127
  if (svg.classList.contains('pele-timeline')) return all('.pele-period').map((p) => [p]);
128
128
  if (svg.classList.contains('pele-gantt')) return all('.pele-task').map((t) => [t]);
129
129
  if (svg.classList.contains('pele-journey')) {
130
- const tasks = all('.pele-task'), faces = all('.pele-face');
131
- const line = svg.querySelector('path.pele-edge');
130
+ // Wide: tasks, faces and one polyline are separate. Narrow (vertical list): each step holds its face, edges join the steps.
131
+ const tasks = all('.pele-task, .pele-journey-step');
132
+ const faces = all('.pele-face').filter((f) => !f.closest('.pele-node'));
132
133
  // The satisfaction line is one polyline `M x,yL x,y...`: split it so each segment arrives with its task.
133
134
  const segs = [];
134
- if (line && /^M[-\d.,]+(L[-\d.,]+)+$/.test(line.getAttribute('d'))) {
135
- const p = line.getAttribute('d').slice(1).split('L');
135
+ for (const line of all('path.pele-edge')) {
136
+ const d = line.getAttribute('d');
137
+ if (!/^M[-\d.,]+(L[-\d.,]+)+$/.test(d)) { segs.push(line); continue; }
138
+ const p = d.slice(1).split('L');
136
139
  for (let i = 1; i < p.length; i++) {
137
140
  const seg = line.cloneNode();
138
141
  seg.setAttribute('d', `M${p[i - 1]}L${p[i]}`);