pele-animate 0.16.1 → 0.17.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 +7 -5
- package/docs/api.md +1 -2
- package/docs/contributing.md +1 -0
- package/docs/diagram-types.md +20 -20
- package/docs/getting-started.md +7 -5
- package/docs/how-it-works.md +0 -1
- package/docs/icons.md +2 -2
- package/docs/migrating.md +4 -0
- package/docs/step-order.md +4 -4
- package/package.json +57 -15
- package/pele-animate.js +16 -25
- package/skills/pele-animate/SKILL.md +6 -4
- package/types/index.d.ts +1 -9
- package/types/preset-doverunner.d.ts +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ step through it, and nodes can carry icons. A small post-processor for [Pele](ht
|
|
|
9
9
|
which renders the Mermaid; this adds the step order, the playback and the icons. It is not a theme package.
|
|
10
10
|
Unofficial add-on; not affiliated with or endorsed by the Pele or Obsidian teams.
|
|
11
11
|
|
|
12
|
-
**[Website](https://pele-animate.
|
|
12
|
+
**[Website](https://pele-animate.danielkimdev.com/) · [Docs](docs/getting-started.md) · [npm](https://www.npmjs.com/package/pele-animate) · [Changelog](CHANGELOG.md)**
|
|
13
13
|
|
|
14
14
|
<img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a3.gif" width="560" alt="Animated scene with Tabler icons: a request, a load balancer and a cloud service">
|
|
15
15
|
|
|
@@ -51,15 +51,17 @@ Mermaid source:
|
|
|
51
51
|
|
|
52
52
|
```mermaid-icons
|
|
53
53
|
flowchart LR
|
|
54
|
-
%% pa: 1=C 2=L 3=S
|
|
54
|
+
%% pa: 1=C 2=C>L 3=L>S 4=S>L 5=L>C
|
|
55
55
|
C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
|
|
56
56
|
L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
|
|
57
57
|
S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
|
|
58
|
-
C
|
|
59
|
-
L
|
|
58
|
+
C -->|request| L
|
|
59
|
+
L -->|forward| S
|
|
60
|
+
S -->|response| L
|
|
61
|
+
L -->|reply| C
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
`%% pa: 1=C 2=L 3=S` pins the order (optional). `form: "square", h: 88` makes a large frameless icon.
|
|
64
|
+
`%% pa: 1=C 2=C>L 3=L>S 4=S>L 5=L>C` pins the order: the request first, then each leg of the round trip (optional). `form: "square", h: 88` makes a large frameless icon.
|
|
63
65
|
|
|
64
66
|
## Documentation
|
|
65
67
|
|
package/docs/api.md
CHANGED
|
@@ -13,10 +13,9 @@ TypeScript types ship with the package (`types/`).
|
|
|
13
13
|
|
|
14
14
|
| Export | Signature | Description |
|
|
15
15
|
|---|---|---|
|
|
16
|
-
| `watch` | `watch(container: HTMLElement, source?: string
|
|
16
|
+
| `watch` | `watch(container: HTMLElement, source?: string): void` | Marks the container as a scene (`pa-scene`), animates each SVG Pele renders into it and re-applies after Pele re-lays-out on resize. |
|
|
17
17
|
| `prepare` | `prepare(source?: string): string` | Returns the Mermaid source with icon-node labels padded so Pele lays out a box at least as wide as the icon (`h`). Pass its result to `mount()` and the original source to `watch()`. Without it, a label shorter than the icon puts edge ends and arrowheads under the icon. |
|
|
18
18
|
| `animate` | `animate(svg: SVGSVGElement, options?: { hover?: Element; source?: string }): void` | Animates one rendered svg. `source` is read for `%% pa:` pins. Sets `svg.paSteps`. |
|
|
19
|
-
| `replay` | `replay(svg: SVGSVGElement \| null \| undefined): void` | Plays the intro again. |
|
|
20
19
|
| `parseOrder` | `parseOrder(source?: string): Map<string, number>` | Parses the `%% pa:` comment: node id, or `'X>Y'` for an edge, to a 0-based step. |
|
|
21
20
|
|
|
22
21
|
`svg.paSteps` (type `PaStep[]`, where `PaStep = Array<[element: Element, parts: Element[]]>`) is set by `animate()`: one array per
|
package/docs/contributing.md
CHANGED
|
@@ -18,6 +18,7 @@ pnpm build # builds the site (a placeholder until the site lands)
|
|
|
18
18
|
- The package is plain ESM at the repository root: no build step. The site lives in `site/`.
|
|
19
19
|
- Docs are the Markdown files in `docs/`. A fenced block marked `mermaid` must render, and every `@{ icon }` name in it must exist.
|
|
20
20
|
- Fence convention: ```` ```mermaid live ```` is a diagram GitHub can also draw; the site animates it. A diagram with `@{ icon }` nodes uses ```` ```mermaid-icons live ````, because GitHub's Mermaid cannot draw icons (it shows "?" boxes), so GitHub shows the source text and the site animates it.
|
|
21
|
+
- Every `live` fence carries a title after the word `live`: `title="Flowchart: cache hit or miss"`. The playground's examples menu shows it (grouped by page), so write "Type: what it shows".
|
|
21
22
|
- Tabler packs are generated: `node scripts/build-tabler.mjs <path to a tabler-icons checkout>` rewrites `tabler/*.js`. Do not edit those
|
|
22
23
|
files by hand. The Tabler version is recorded in each file header and in `THIRD-PARTY-NOTICES.md`.
|
|
23
24
|
- Add an entry to `CHANGELOG.md` for any user-visible change. Breaking changes also get a section in `docs/migrating.md`.
|
package/docs/diagram-types.md
CHANGED
|
@@ -36,7 +36,7 @@ are kept. Icon nodes (`@{ icon }`) work here; see [icons](./icons.md).
|
|
|
36
36
|
|
|
37
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
38
|
|
|
39
|
-
```mermaid live
|
|
39
|
+
```mermaid live title="Flowchart: cache hit or miss, with pins and an edge pin"
|
|
40
40
|
flowchart LR
|
|
41
41
|
%% pa: 1=A 2=B 3=C 4=D 5=D>C
|
|
42
42
|
A[Client] --> B{Cached?}
|
|
@@ -48,7 +48,7 @@ flowchart LR
|
|
|
48
48
|
|
|
49
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.
|
|
50
50
|
|
|
51
|
-
```mermaid live
|
|
51
|
+
```mermaid live title="Sequence: API request with a cache miss"
|
|
52
52
|
sequenceDiagram
|
|
53
53
|
Client->>API: request
|
|
54
54
|
API->>Cache: lookup
|
|
@@ -64,11 +64,11 @@ sequenceDiagram
|
|
|
64
64
|
|
|
65
65
|
`architecture-beta`: services in groups, joined by edges. Services appear in step order like flowchart nodes, groups stay visible,
|
|
66
66
|
and `%% pa:` pins work the same way. The icon in parentheses is looked up in your icon packs, so Tabler names and `doverunner-*`
|
|
67
|
-
names work (import the packs as for [icons](./icons.md)). The pins
|
|
67
|
+
names work (import the packs as for [icons](./icons.md)). The pins show the services first (the request path, then what sits behind the API), then trace the request one edge at a time with edge pins (`3=user>cdn`).
|
|
68
68
|
|
|
69
|
-
```mermaid-icons live
|
|
69
|
+
```mermaid-icons live title="Architecture: request path through CDN, API, cache, database and worker"
|
|
70
70
|
architecture-beta
|
|
71
|
-
%% pa: 1=user 2=
|
|
71
|
+
%% pa: 1=user,cdn,api 2=cache,db,queue,worker 3=user>cdn 4=cdn>api 5=api>cache 6=api>db 7=api>queue 8=queue>worker
|
|
72
72
|
group edge(cloud)[Edge]
|
|
73
73
|
group core(cloud)[Core]
|
|
74
74
|
service user(device-desktop)[User]
|
|
@@ -94,9 +94,9 @@ Icons here are small and fixed in size; `form` and `h` apply to flowcharts only.
|
|
|
94
94
|
`stateDiagram-v2`: states appear in step order, transitions draw from their source state, and transition labels fade in. The
|
|
95
95
|
start and end markers are nodes too, with the ids `root_start` and `root_end`, so pins can name them.
|
|
96
96
|
|
|
97
|
-
```mermaid live
|
|
97
|
+
```mermaid live title="State: media player with loading, error and retry"
|
|
98
98
|
stateDiagram-v2
|
|
99
|
-
%% pa: 1=root_start 2=Idle 3=Loading 4=Playing 5=Paused 6=Error 7=root_end
|
|
99
|
+
%% pa: 1=root_start 2=Idle 3=Loading 4=Playing 5=Paused 6=Error 7=Error>Idle 8=root_end
|
|
100
100
|
[*] --> Idle
|
|
101
101
|
Idle --> Loading: play
|
|
102
102
|
Loading --> Playing: ready
|
|
@@ -107,18 +107,18 @@ stateDiagram-v2
|
|
|
107
107
|
Playing --> [*]: stop
|
|
108
108
|
```
|
|
109
109
|
|
|
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
|
|
110
|
+
The pins give each state its own step, in the order a viewer meets them, and the `retry` transition (`Error>Idle`) its own step after `Error` is on screen. 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
|
|
111
111
|
state edges no readable ids, so pele-animate finds each transition's ends from where its path starts and stops. Composite
|
|
112
112
|
states and forks are untested. State diagrams take no icons.
|
|
113
113
|
|
|
114
114
|
## C4 context diagrams
|
|
115
115
|
|
|
116
116
|
`C4Context`: people and systems appear in step order and each `Rel` draws from its source, with its label. Pins use the ids you
|
|
117
|
-
give `Person(...)` and `System(...)`; an edge pin is `3=app>drm`. The example
|
|
117
|
+
give `Person(...)` and `System(...)`; an edge pin is `3=app>drm`. The example puts the landscape on screen first, then draws the relationships one at a time, then adds analytics and the operator who reads it.
|
|
118
118
|
|
|
119
|
-
```mermaid live
|
|
119
|
+
```mermaid live title="C4 context: player app and the systems around it"
|
|
120
120
|
C4Context
|
|
121
|
-
%% pa: 1=viewer 2=app 3=drm 4=cdn 5=analytics 6=admin
|
|
121
|
+
%% pa: 1=viewer,app,drm,cdn 2=viewer>app 3=app>drm 4=app>cdn 5=analytics,admin 6=app>analytics 7=admin>analytics
|
|
122
122
|
Person(viewer, "Viewer", "Watches video")
|
|
123
123
|
System(app, "Player app", "Plays protected video")
|
|
124
124
|
System_Ext(drm, "DRM service", "Issues licenses")
|
|
@@ -140,7 +140,7 @@ keep `Rel` labels short. Only `C4Context` has been checked; the other C4 types a
|
|
|
140
140
|
|
|
141
141
|
`block-beta`: blocks appear in step order and each arrow draws from its source block. Pins use the block ids.
|
|
142
142
|
|
|
143
|
-
```mermaid live
|
|
143
|
+
```mermaid live title="Block: video pipeline with a storage branch"
|
|
144
144
|
block-beta
|
|
145
145
|
columns 4
|
|
146
146
|
%% pa: 1=src 2=enc 3=pkg 4=cdn 5=store
|
|
@@ -158,11 +158,11 @@ neighbour can give a bent arrow that runs along another one. Block diagrams take
|
|
|
158
158
|
## Class diagrams
|
|
159
159
|
|
|
160
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.
|
|
161
|
+
and then `Video`, whichever way the arrowhead points. Pins use the class names; the example shows the base class, its subtypes, the inheritance arrows as their own step, then the classes that use them. An edge pin may name the ends in either order, so `Video>Media` follows the arrow while the source says `Media <|-- Video`.
|
|
162
162
|
|
|
163
|
-
```mermaid live
|
|
163
|
+
```mermaid live title="Class: media types, player and license"
|
|
164
164
|
classDiagram
|
|
165
|
-
%% pa: 1=Media 2=Video,Audio 3=
|
|
165
|
+
%% pa: 1=Media 2=Video,Audio 3=Video>Media,Audio>Media 4=Player 5=License 6=Session
|
|
166
166
|
Media <|-- Video
|
|
167
167
|
Media <|-- Audio
|
|
168
168
|
Player --> Media : plays
|
|
@@ -179,7 +179,7 @@ classDiagram
|
|
|
179
179
|
`erDiagram`: entities appear in step order, relationships draw from the entity written first (`CUSTOMER ||--o{ ORDER` reveals
|
|
180
180
|
`CUSTOMER`, then `ORDER`). The example reads from the customer down to the supplier.
|
|
181
181
|
|
|
182
|
-
```mermaid live
|
|
182
|
+
```mermaid live title="ER: customer orders and product suppliers"
|
|
183
183
|
erDiagram
|
|
184
184
|
%% pa: 1=CUSTOMER 2=ORDER 3=LINE 4=PRODUCT 5=SUPPLIER
|
|
185
185
|
CUSTOMER ||--o{ ORDER : places
|
|
@@ -197,7 +197,7 @@ diagrams). Section headers, axes, grids and legends stay visible.
|
|
|
197
197
|
|
|
198
198
|
- **`timeline`:** one step per time period, with its events. List periods in time order.
|
|
199
199
|
|
|
200
|
-
```mermaid live
|
|
200
|
+
```mermaid live title="Timeline: product history in two phases"
|
|
201
201
|
timeline
|
|
202
202
|
title Product history
|
|
203
203
|
section Build
|
|
@@ -211,7 +211,7 @@ timeline
|
|
|
211
211
|
|
|
212
212
|
- **`journey`:** one step per task: the task, its face, and the line segment that joins it to the task before.
|
|
213
213
|
|
|
214
|
-
```mermaid live
|
|
214
|
+
```mermaid live title="User journey: watching a protected video"
|
|
215
215
|
journey
|
|
216
216
|
title Watching a protected video
|
|
217
217
|
section Find
|
|
@@ -228,7 +228,7 @@ journey
|
|
|
228
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
|
|
229
229
|
its first commit.
|
|
230
230
|
|
|
231
|
-
```mermaid live
|
|
231
|
+
```mermaid live title="Git graph: feature branch, merge and release"
|
|
232
232
|
gitGraph
|
|
233
233
|
commit id: "init"
|
|
234
234
|
branch feature
|
|
@@ -243,7 +243,7 @@ gitGraph
|
|
|
243
243
|
|
|
244
244
|
- **`gantt`:** one step per task, top to bottom: write tasks in the order you want them to appear.
|
|
245
245
|
|
|
246
|
-
```mermaid live
|
|
246
|
+
```mermaid live title="Gantt: plan, build and ship"
|
|
247
247
|
gantt
|
|
248
248
|
dateFormat YYYY-MM-DD
|
|
249
249
|
section Plan
|
package/docs/getting-started.md
CHANGED
|
@@ -43,14 +43,16 @@ watch(el, src); // pele-animate animates it, and re-applies when Pele
|
|
|
43
43
|
|
|
44
44
|
The Mermaid source:
|
|
45
45
|
|
|
46
|
-
```mermaid-icons live
|
|
46
|
+
```mermaid-icons live title="Icons: request, load balancer and cloud service"
|
|
47
47
|
flowchart LR
|
|
48
|
-
%% pa: 1=C 2=L 3=S
|
|
48
|
+
%% pa: 1=C 2=C>L 3=L>S 4=S>L 5=L>C
|
|
49
49
|
C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
|
|
50
50
|
L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
|
|
51
51
|
S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
|
|
52
|
-
C
|
|
53
|
-
L
|
|
52
|
+
C -->|request| L
|
|
53
|
+
L -->|forward| S
|
|
54
|
+
S -->|response| L
|
|
55
|
+
L -->|reply| C
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
What you get:
|
|
@@ -60,7 +62,7 @@ What you get:
|
|
|
60
62
|
- Click, or focus and press Enter: **step mode**. Previous, play/pause and next buttons appear, and Space, ←, → and Esc work.
|
|
61
63
|
- With `prefers-reduced-motion`, the motion is off and the finished picture shows.
|
|
62
64
|
|
|
63
|
-
The `%% pa: 1=C 2=L 3=S` comment pins the order. Without it, the order follows the edges. See [step order](./step-order.md).
|
|
65
|
+
The `%% pa: 1=C 2=C>L 3=L>S 4=S>L 5=L>C` comment pins the order: the request first, then each leg of the round trip. Without it, the order follows the edges. See [step order](./step-order.md).
|
|
64
66
|
|
|
65
67
|
## Next
|
|
66
68
|
|
package/docs/how-it-works.md
CHANGED
|
@@ -20,7 +20,6 @@ Two layers, one diagram:
|
|
|
20
20
|
- `watch(el, src)` is pele-animate's. It marks the container as a scene (class `pa-scene`), animates each SVG Pele renders into
|
|
21
21
|
it, and re-applies after Pele re-draws on resize. The intro is skipped on those re-draws once it has played.
|
|
22
22
|
- `animate(svg, { source })` does one SVG. Use it if you render with Pele yourself and do not want `watch()`.
|
|
23
|
-
- `replay(svg)` plays the intro again.
|
|
24
23
|
|
|
25
24
|
## The three kinds of motion
|
|
26
25
|
|
package/docs/icons.md
CHANGED
|
@@ -9,7 +9,7 @@ section: Guides
|
|
|
9
9
|
|
|
10
10
|
A flowchart node becomes an illustrated node with Mermaid's own `@{ }` syntax:
|
|
11
11
|
|
|
12
|
-
```mermaid-icons live
|
|
12
|
+
```mermaid-icons live title="Icons: laptop sending a request to a server"
|
|
13
13
|
flowchart LR
|
|
14
14
|
A@{ icon: "device-desktop", form: "square", h: 88, label: "Laptop" }
|
|
15
15
|
B@{ icon: "server", form: "square", h: 88, label: "Server" }
|
|
@@ -61,7 +61,7 @@ Brand, Letters, Numbers, Zodiac and Gender are not included. Counts are for Tabl
|
|
|
61
61
|
|
|
62
62
|
Do not guess names. Look them up:
|
|
63
63
|
|
|
64
|
-
- The [icon browser](https://pele-animate.
|
|
64
|
+
- The [icon browser](https://pele-animate.danielkimdev.com/icons/) searches names and tags and copies a ready snippet; the same list is [icons.json](https://pele-animate.danielkimdev.com/icons.json).
|
|
65
65
|
- Tabler's own site, [tabler.io/icons](https://tabler.io/icons), lists names and categories (use the outline style).
|
|
66
66
|
- In your project: `node_modules/pele-animate/tabler/<category>.js` lists every name in that category as an object key.
|
|
67
67
|
- Names that exist in more than one place are not a problem: Tabler names are plain (`server`, `lock`), `doverunner-*` names are prefixed.
|
package/docs/migrating.md
CHANGED
|
@@ -9,6 +9,10 @@ section: Reference
|
|
|
9
9
|
|
|
10
10
|
pele-animate stays on `0.x`: a minor release may break things. Pin a range such as `^0.13.0` and bump it deliberately.
|
|
11
11
|
|
|
12
|
+
## 0.16 to 0.17
|
|
13
|
+
|
|
14
|
+
`replay(svg)` and `watch(el, src, { controls: false })` are removed. A click or Enter on a diagram always enters step mode. To restart the intro yourself, remove the `pa-in` and `pa-done` classes from the svg, force a reflow, and add `pa-in` again.
|
|
15
|
+
|
|
12
16
|
## 0.12 to 0.13
|
|
13
17
|
|
|
14
18
|
Two breaking changes.
|
package/docs/step-order.md
CHANGED
|
@@ -26,7 +26,7 @@ them. By default, the order follows the edges. A `%% pa:` comment lets you set i
|
|
|
26
26
|
|
|
27
27
|
Add one comment line anywhere in the source:
|
|
28
28
|
|
|
29
|
-
```mermaid live
|
|
29
|
+
```mermaid live title="Pins: request, validate, respond with a shortcut"
|
|
30
30
|
flowchart LR
|
|
31
31
|
%% pa: 1=A 2=B 3=C
|
|
32
32
|
A[Request] --> B[Validate] --> C[Respond]
|
|
@@ -40,7 +40,7 @@ level.
|
|
|
40
40
|
|
|
41
41
|
`X>Y` pins the edge from X to Y to its own step, so an edge between two nodes that are already visible can be a step:
|
|
42
42
|
|
|
43
|
-
```mermaid live
|
|
43
|
+
```mermaid live title="Edge pins: a reply as its own step"
|
|
44
44
|
flowchart LR
|
|
45
45
|
%% pa: 1=A,B 2=C 3=A>B
|
|
46
46
|
A[Client] --> B[Server]
|
|
@@ -51,7 +51,9 @@ flowchart LR
|
|
|
51
51
|
Rules that avoid surprises:
|
|
52
52
|
|
|
53
53
|
- **Pin the nodes first.** An edge pinned before its target appears lands early.
|
|
54
|
+
- Edge pins work in every diagram type that has edges, not only flowcharts.
|
|
54
55
|
- A two-way edge (`A <--> B`) is pinned in the direction you wrote it first (`A>B`).
|
|
56
|
+
- The ends may be named in either order (`Video>Media` or `Media>Video`), unless the diagram also has the opposite edge: then the order picks which of the two is meant.
|
|
55
57
|
- Do not rename node ids after pinning: pins match ids.
|
|
56
58
|
- Translated pages keep the same ids, so copy the `%% pa:` line across languages after checking the ids match.
|
|
57
59
|
|
|
@@ -66,8 +68,6 @@ Click the diagram, or focus it and press Enter or Space. A small bar appears wit
|
|
|
66
68
|
| ← | Previous step |
|
|
67
69
|
| Esc | Leave step mode |
|
|
68
70
|
|
|
69
|
-
Pass `{ controls: false }` as the third argument of `watch()` to turn step mode off; a click then just replays the intro.
|
|
70
|
-
|
|
71
71
|
## Checking your order
|
|
72
72
|
|
|
73
73
|
After `animate()` runs, `svg.paSteps` is one array per step. Print what each step shows:
|
package/package.json
CHANGED
|
@@ -1,26 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pele-animate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
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",
|
|
7
7
|
"homepage": "https://github.com/dkdev24/pele-animate#readme",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
11
|
"author": "Daniel Kim",
|
|
12
|
-
"repository": {
|
|
13
|
-
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/dkdev24/pele-animate.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mermaid",
|
|
18
|
+
"pele",
|
|
19
|
+
"svg",
|
|
20
|
+
"diagram",
|
|
21
|
+
"animation"
|
|
22
|
+
],
|
|
14
23
|
"types": "./types/index.d.ts",
|
|
15
24
|
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./types/index.d.ts",
|
|
27
|
+
"default": "./pele-animate.js"
|
|
28
|
+
},
|
|
29
|
+
"./glyphs": {
|
|
30
|
+
"types": "./types/glyphs.d.ts",
|
|
31
|
+
"default": "./glyphs.js"
|
|
32
|
+
},
|
|
33
|
+
"./preset-doverunner": "./preset-doverunner.js",
|
|
19
34
|
"./style.css": "./pele-animate.css",
|
|
20
|
-
"./tabler/*": {
|
|
35
|
+
"./tabler/*": {
|
|
36
|
+
"types": "./types/tabler-pack.d.ts",
|
|
37
|
+
"default": "./tabler/*.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"pele-animate.js",
|
|
42
|
+
"pele-animate.css",
|
|
43
|
+
"glyphs.js",
|
|
44
|
+
"preset-doverunner.js",
|
|
45
|
+
"tabler",
|
|
46
|
+
"types",
|
|
47
|
+
"docs",
|
|
48
|
+
"skills",
|
|
49
|
+
"THIRD-PARTY-NOTICES.md",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
],
|
|
53
|
+
"sideEffects": [
|
|
54
|
+
"*.css",
|
|
55
|
+
"./preset-doverunner.js",
|
|
56
|
+
"./tabler/*.js"
|
|
57
|
+
],
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"pele": "^1.7.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"pele": "^1.7.0"
|
|
21
63
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
64
|
+
"scripts": {
|
|
65
|
+
"test": "node scripts/check-docs.mjs",
|
|
66
|
+
"build": "pnpm -r --filter ./site build"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/pele-animate.js
CHANGED
|
@@ -219,13 +219,17 @@ export function animate(svg, { hover = svg, source = '' } = {}) {
|
|
|
219
219
|
return geoEndpoints(e, boxes);
|
|
220
220
|
});
|
|
221
221
|
const level = bfs(ids, pairs.filter(Boolean), parseOrder(source));
|
|
222
|
+
// An edge pin may name the ends in either order (`Video>Media` for `Media <|-- Video`, or either end of an undirected edge),
|
|
223
|
+
// unless the diagram also has the opposite edge, where the order picks which of the two is meant.
|
|
224
|
+
const real = new Set(pairs.filter(Boolean).map(([a, b]) => `${a}>${b}`));
|
|
225
|
+
const pinOf = (s, d) => level.get(`${s}>${d}`) ?? (real.has(`${d}>${s}`) ? undefined : level.get(`${d}>${s}`));
|
|
222
226
|
const u = Math.min(UNIT, MAX_INTRO / (Math.max(0, ...level.values()) + 1));
|
|
223
227
|
const k = u / UNIT;
|
|
224
228
|
nodes.forEach((n) => { set(n, level.get(n.dataset.id) * u); step.set(n, level.get(n.dataset.id)); });
|
|
225
229
|
// Start after the source is up, but never so early that the arrow lands before its target appears (pinned steps).
|
|
226
230
|
edges.forEach((e, i) => {
|
|
227
231
|
const [s, d] = pairs[i] ?? [];
|
|
228
|
-
const pin =
|
|
232
|
+
const pin = pinOf(s, d); // edge pinned to a step: starts with that step, once its source is up
|
|
229
233
|
step.set(e, pin ?? Math.max(level.get(s) ?? 0, level.get(d) ?? 0));
|
|
230
234
|
times.set(e, pin !== undefined
|
|
231
235
|
? Math.max(pin * u, (level.get(s) ?? 0) * u + 0.3 * k)
|
|
@@ -315,8 +319,8 @@ function leaveStep(svg) {
|
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
// mount() re-renders on container resize; re-animate each new <svg>, skipping the intro once it has played.
|
|
318
|
-
// Click (or Enter/Space) enters step mode: previous | play/pause | next, Space, ←/→, Esc to leave.
|
|
319
|
-
export function watch(container, source = ''
|
|
322
|
+
// Click (or Enter/Space) enters step mode: previous | play/pause | next, Space, ←/→, Esc to leave.
|
|
323
|
+
export function watch(container, source = '') {
|
|
320
324
|
let played = false;
|
|
321
325
|
let k = -1; // current step; -1 = not in step mode
|
|
322
326
|
let timer = 0;
|
|
@@ -397,27 +401,14 @@ export function watch(container, source = '', { controls = true } = {}) {
|
|
|
397
401
|
new MutationObserver(run).observe(container, { childList: true });
|
|
398
402
|
container.classList.add('pa-scene');
|
|
399
403
|
container.tabIndex = 0;
|
|
400
|
-
container.title ||=
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (k < 0) return (key === 'Enter' || key === ' ') && (e.preventDefault(), enter());
|
|
410
|
-
const act = { ' ': toggle, ArrowRight: () => manual(k + 1), ArrowLeft: () => manual(k - 1), Escape: exit }[key];
|
|
411
|
-
if (act) { e.preventDefault(); act(); }
|
|
412
|
-
});
|
|
413
|
-
}
|
|
404
|
+
container.title ||= 'Click to step through';
|
|
405
|
+
container.addEventListener('click', () => k < 0 && enter());
|
|
406
|
+
container.addEventListener('keydown', (e) => {
|
|
407
|
+
const key = e.key;
|
|
408
|
+
if (e.target.closest('button') && (key === 'Enter' || key === ' ')) return; // native button activation
|
|
409
|
+
if (k < 0) return (key === 'Enter' || key === ' ') && (e.preventDefault(), enter());
|
|
410
|
+
const act = { ' ': toggle, ArrowRight: () => manual(k + 1), ArrowLeft: () => manual(k - 1), Escape: exit }[key];
|
|
411
|
+
if (act) { e.preventDefault(); act(); }
|
|
412
|
+
});
|
|
414
413
|
run();
|
|
415
414
|
}
|
|
416
|
-
|
|
417
|
-
// Play the intro again (removing pa-in/pa-done restarts the CSS animations).
|
|
418
|
-
export function replay(svg) {
|
|
419
|
-
if (!svg || reduced()) return;
|
|
420
|
-
svg.classList.remove('pa-in', 'pa-done');
|
|
421
|
-
void svg.getBoundingClientRect();
|
|
422
|
-
svg.classList.add('pa-in');
|
|
423
|
-
}
|
|
@@ -60,12 +60,14 @@ Icon nodes use Mermaid's own syntax:
|
|
|
60
60
|
|
|
61
61
|
```mermaid-icons
|
|
62
62
|
flowchart LR
|
|
63
|
-
%% pa: 1=C 2=L 3=S
|
|
63
|
+
%% pa: 1=C 2=C>L 3=L>S 4=S>L 5=L>C
|
|
64
64
|
C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
|
|
65
65
|
L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
|
|
66
66
|
S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
|
|
67
|
-
C
|
|
68
|
-
L
|
|
67
|
+
C -->|request| L
|
|
68
|
+
L -->|forward| S
|
|
69
|
+
S -->|response| L
|
|
70
|
+
L -->|reply| C
|
|
69
71
|
```
|
|
70
72
|
|
|
71
73
|
- `form: "square", h: 88` = large frameless icon. Leave both out for a small icon in a frame.
|
|
@@ -99,7 +101,7 @@ Default order follows the edges. Override with one comment line anywhere in the
|
|
|
99
101
|
- `%% pa: 1=A,B 2=C 3=A>B` : `X>Y` pins the edge from X to Y to its own step. **Pin the nodes first.** A two-way edge
|
|
100
102
|
(`A <--> B`) is pinned in the direction you wrote first.
|
|
101
103
|
|
|
102
|
-
Click or Enter on a diagram starts step mode (prev / play / next; Space, ←, →, Esc).
|
|
104
|
+
Click or Enter on a diagram starts step mode (prev / play / next; Space, ←, →, Esc).
|
|
103
105
|
To review the order of existing diagrams against the page text, use the `diagram-step-order` skill.
|
|
104
106
|
|
|
105
107
|
## 5. Theme
|
package/types/index.d.ts
CHANGED
|
@@ -5,11 +5,6 @@ export interface AnimateOptions {
|
|
|
5
5
|
source?: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface WatchOptions {
|
|
9
|
-
/** `false` keeps the old click-to-replay instead of step mode. Default `true`. */
|
|
10
|
-
controls?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
/** One step: the elements that appear and, for each, the parts that pop in. */
|
|
14
9
|
export type PaStep = Array<[element: Element, parts: Element[]]>;
|
|
15
10
|
|
|
@@ -29,7 +24,4 @@ export function animate(svg: SVGSVGElement, options?: AnimateOptions): void;
|
|
|
29
24
|
/** Animate every svg Pele renders into `container`, re-applying after Pele re-lays-out on resize. */
|
|
30
25
|
/** Pad icon-node labels narrower than `h` so Pele's layout box is at least as wide as the drawn icon. Use as `mount(el, prepare(src), { icons })`; pass the original `src` to `watch()`. */
|
|
31
26
|
export function prepare(source?: string): string;
|
|
32
|
-
export function watch(container: HTMLElement, source?: string
|
|
33
|
-
|
|
34
|
-
/** Play the intro again. */
|
|
35
|
-
export function replay(svg: SVGSVGElement | null | undefined): void;
|
|
27
|
+
export function watch(container: HTMLElement, source?: string): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|