pele-animate 0.12.0 → 0.14.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.
Files changed (66) hide show
  1. package/README.md +28 -40
  2. package/THIRD-PARTY-NOTICES.md +28 -0
  3. package/docs/accessibility.md +20 -0
  4. package/docs/agents.md +63 -0
  5. package/docs/api.md +49 -0
  6. package/docs/compatibility.md +33 -0
  7. package/docs/contributing.md +24 -0
  8. package/docs/custom-icons.md +39 -0
  9. package/docs/diagram-types.md +43 -0
  10. package/docs/faq.md +30 -0
  11. package/docs/getting-started.md +66 -0
  12. package/docs/how-it-works.md +44 -0
  13. package/docs/icons.md +82 -0
  14. package/docs/migrating.md +58 -0
  15. package/docs/recipes.md +80 -0
  16. package/docs/security.md +19 -0
  17. package/docs/step-order.md +75 -0
  18. package/docs/theming.md +48 -0
  19. package/glyphs.js +10 -13
  20. package/package.json +12 -8
  21. package/preset-doverunner.js +23 -13
  22. package/skills/diagram-step-order/SKILL.md +43 -0
  23. package/skills/diagram-step-order/steps.js +15 -0
  24. package/skills/pele-animate/SKILL.md +131 -0
  25. package/skills/pele-animate/references/categories.md +42 -0
  26. package/skills/pele-animate/verify.js +14 -0
  27. package/tabler/animals.js +23 -0
  28. package/tabler/arrows.js +338 -0
  29. package/tabler/badges.js +27 -0
  30. package/tabler/buildings.js +100 -0
  31. package/tabler/charts.js +44 -0
  32. package/tabler/communication.js +126 -0
  33. package/tabler/computers.js +49 -0
  34. package/tabler/currencies.js +81 -0
  35. package/tabler/database.js +47 -0
  36. package/tabler/design.js +355 -0
  37. package/tabler/development.js +68 -0
  38. package/tabler/devices.js +368 -0
  39. package/tabler/document.js +214 -0
  40. package/tabler/e-commerce.js +160 -0
  41. package/tabler/electrical.js +24 -0
  42. package/tabler/extensions.js +18 -0
  43. package/tabler/food.js +101 -0
  44. package/tabler/games.js +53 -0
  45. package/tabler/gestures.js +22 -0
  46. package/tabler/health.js +92 -0
  47. package/tabler/laundry.js +45 -0
  48. package/tabler/logic.js +13 -0
  49. package/tabler/map.js +268 -0
  50. package/tabler/math.js +93 -0
  51. package/tabler/media.js +165 -0
  52. package/tabler/mood.js +57 -0
  53. package/tabler/nature.js +55 -0
  54. package/tabler/photography.js +57 -0
  55. package/tabler/shapes.js +192 -0
  56. package/tabler/sport.js +81 -0
  57. package/tabler/symbols.js +42 -0
  58. package/tabler/system.js +789 -0
  59. package/tabler/text.js +199 -0
  60. package/tabler/vehicles.js +95 -0
  61. package/tabler/version-control.js +21 -0
  62. package/tabler/weather.js +66 -0
  63. package/types/glyphs.d.ts +13 -0
  64. package/types/index.d.ts +33 -0
  65. package/types/preset-doverunner.d.ts +1 -0
  66. package/types/tabler-pack.d.ts +2 -0
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # pele-animate
2
2
 
3
- Animated, illustrated SVG scenes from plain Mermaid code. A small post-processor for
4
- [Pele](https://github.com/obsidianmd/pele) (MIT), which renders the Mermaid; this adds the motion and the pictures.
3
+ Mermaid diagrams that explain themselves one step at a time, with icons. You choose the order things appear in, readers
4
+ step through it, and nodes can carry icons. A small post-processor for [Pele](https://github.com/obsidianmd/pele) (MIT),
5
+ which renders the Mermaid; this adds the step order, the playback and the icons. It is not a theme package.
5
6
  Unofficial add-on; not affiliated with or endorsed by the Pele or Obsidian teams.
6
7
  The source stays valid Mermaid, so GitHub or Obsidian still show a normal diagram.
7
8
 
8
9
  - Nodes appear in order (BFS from the sources, or pinned with a `%% pa:` comment), edges draw in, labels fade in.
9
10
  - Hover or focus: tokens travel the edges in sequence. The intro plays once on scroll-in. Click (or Enter) enters step mode: previous / play-pause / next buttons, with Space (play/pause), ←/→ (step) and Esc (leave).
10
- - `@{ icon: "name" }` nodes become illustrations from a glyph pack. Unknown names fall back to a plain Pele box.
11
+ - `@{ icon: "name" }` nodes become illustrations from a glyph pack. Unknown names get a neutral rounded-square glyph.
11
12
  - Sequence diagrams: participant boxes in a row get the tallest height (Pele sizes each to its own text). Group and box titles are bold.
12
13
  - Idle state is the finished picture; `prefers-reduced-motion` turns the motion off. Light and dark themes.
13
14
 
@@ -43,9 +44,9 @@ sequenceDiagram
43
44
  | Pele | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/p2.png" width="560" alt="Sequence diagram rendered by Pele"> |
44
45
  | pele-animate | <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a2.gif" width="560" alt="Animated sequence diagram: messages appear in order, tokens travel"> |
45
46
 
46
- With glyphs (`@{ icon }` nodes, `%% pa: 1=P 2=O 3=D` pins the order):
47
+ With icons (`@{ icon }` nodes from the Tabler `computers` pack, `%% pa: 1=C 2=L 3=S` pins the order):
47
48
 
48
- <img src="https://raw.githubusercontent.com/dkdev24/pele-animate/main/examples/a3.gif" width="560" alt="Animated scene with illustrated Player, OTT service and DRM server">
49
+ <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">
49
50
 
50
51
  ## Install
51
52
 
@@ -59,7 +60,7 @@ npm i pele-animate pele
59
60
  import { mount } from 'pele';
60
61
  import { watch } from 'pele-animate';
61
62
  import { icons } from 'pele-animate/glyphs';
62
- import 'pele-animate/preset-doverunner'; // optional extra glyphs
63
+ import 'pele-animate/tabler/computers'; // one Tabler icon category; import as many as you need
63
64
  import 'pele-animate/style.css';
64
65
 
65
66
  for (const el of document.querySelectorAll('pre.mermaid')) {
@@ -73,45 +74,32 @@ Mermaid source:
73
74
 
74
75
  ```mermaid
75
76
  flowchart LR
76
- %% pa: 1=P 2=O 3=D
77
- P@{ icon: "player", form: "square", h: 88, label: "Player" }
78
- O@{ icon: "server", form: "square", h: 88, label: "OTT service" }
79
- D@{ icon: "key", form: "square", h: 88, label: "DRM server" }
80
- P <-->|auth token| O
81
- P <-->|token / license| D
77
+ %% pa: 1=C 2=L 3=S
78
+ C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
79
+ L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
80
+ S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
81
+ C <-->|route| L
82
+ L <-->|forward| S
82
83
  ```
83
84
 
84
- `form: "square", h: 88` makes a large frameless glyph; leave both out for a small icon in a frame.
85
- `%% pa: 1=P 2=O 3=D` pins nodes to steps (optional). `X>Y` pins the edge from X to Y, so an edge between nodes that are
86
- already visible can have its own step: `%% pa: 1=A,B 2=C,B>C 3=C>B`. Pin the nodes first; an edge pinned before its target appears lands early.
87
- Sequence diagrams animate actors, then messages in order.
85
+ `%% pa: 1=C 2=L 3=S` pins the order (optional). `form: "square", h: 88` makes a large frameless icon.
88
86
 
89
- ## API
87
+ ## Documentation
90
88
 
91
- | Export | |
92
- |---|---|
93
- | `watch(container, source?)` | Animate the SVG inside `container` (and every re-render of it); adds the scene panel and step mode (click / Enter); pass `{ controls: false }` as a third argument for click-to-replay instead |
94
- | `animate(svg, { hover, source })` | Animate one SVG; you handle re-renders |
95
- | `replay(svg)` | Play the intro again |
96
- | `parseOrder(source)` | Read the `%% pa:` pins: `Map(nodeId or 'X>Y' -> level)` |
97
- | `svg.paSteps` | Set by `animate()`: one array per step, each item `[element, parts that animate in]`. Step mode uses it; read it to check the order |
98
- | `registerGlyphs(pack, strokeWidth = 1.1)` (`/glyphs`) | Add glyphs: `{ name: '<inner markup of a 24x24 svg>' }`; colors via `--pa-solid` / `--pa-light` |
99
- | `icons` (`/glyphs`) | Pele `icons` resolver |
100
-
101
- Generic glyphs: `player`, `server`, `key`, `document`, `shield`, `phone`, `cloud`. `preset-doverunner`: `package`, `token`, `lock`,
102
- `database`, `video`, `media`, `encoder`, `storage`, `plugin`, `variants`, `watermark`, `bits-a`, `bits-b`.
103
-
104
- ## Theme
89
+ Everything is in [`docs/`](docs/getting-started.md), and ships inside the npm package:
105
90
 
106
- `watch()` adds class `pa-scene` to the container. Override `--pa-bg`, `--pa-solid`, `--pa-light` or any `--pele-*`
107
- variable on it; defaults are `:where()` rules, so your stylesheet wins.
108
-
109
- ## Limits
91
+ | | |
92
+ |---|---|
93
+ | [Getting started](docs/getting-started.md) · [How it works](docs/how-it-works.md) · [Diagram types](docs/diagram-types.md) | The basics |
94
+ | [Icons](docs/icons.md) · [Custom icons](docs/custom-icons.md) · [Step order](docs/step-order.md) · [Theming](docs/theming.md) · [Recipes](docs/recipes.md) | Guides (Vite, Astro, SvelteKit, Nuxt, React) |
95
+ | [API](docs/api.md) · [Compatibility](docs/compatibility.md) · [Accessibility](docs/accessibility.md) · [Security](docs/security.md) | Reference |
96
+ | [Migrating](docs/migrating.md) · [For coding agents](docs/agents.md) · [FAQ](docs/faq.md) · [Contributing](docs/contributing.md) | Everything else |
110
97
 
111
- - Relies on Pele's SVG structure (`.pele-node`, `.pele-edge`, `data-id`); `pele` is a peer dependency pinned to `^1.7.0`.
112
- - Flowcharts and sequence diagrams only. No types yet.
113
- - Glyph art is square-boxed; wide art is drawn as a wide glyph inside the square.
98
+ **Coding agents:** the package includes a skill, `skills/pele-animate/`, that wires the library into a project and checks the
99
+ result in a browser. See [For coding agents](docs/agents.md).
114
100
 
115
- ## Changelog
101
+ ## Credits and license
116
102
 
117
- See [CHANGELOG.md](CHANGELOG.md).
103
+ MIT. Built on [Pele](https://github.com/obsidianmd/pele) by kepano (MIT); this is an unofficial add-on, not affiliated with or
104
+ endorsed by the Pele or Obsidian teams. The Tabler icon packs come from [Tabler Icons](https://github.com/tabler/tabler-icons)
105
+ (MIT, Paweł Kuna); see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). See also [CHANGELOG.md](CHANGELOG.md).
@@ -0,0 +1,28 @@
1
+ # Third-party notices
2
+
3
+ ## Tabler Icons
4
+
5
+ The `tabler/*.js` glyph packs are generated from [Tabler Icons](https://github.com/tabler/tabler-icons) 3.49.0 (outline set)
6
+ by `scripts/build-tabler.mjs`. Icon names and categories are Tabler's own.
7
+
8
+ MIT License
9
+
10
+ Copyright (c) 2020-2026 Paweł Kuna
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: Accessibility
3
+ description: What pele-animate does for keyboard users and reduced motion, and what has not been audited.
4
+ order: 11
5
+ section: Reference
6
+ ---
7
+
8
+ # Accessibility
9
+
10
+ What is in place:
11
+
12
+ - **Reduced motion.** `prefers-reduced-motion: reduce` turns off the intro and the tokens. The finished diagram shows.
13
+ - **Keyboard.** The diagram container is focusable (`tabindex="0"`). Enter or Space starts step mode; then Space plays or pauses, ← and → step, and Esc leaves.
14
+ - **Step controls.** The bar has `role="toolbar"` with an accessible name, and its buttons have labels. Previous and next use
15
+ `aria-disabled` at the ends.
16
+ - **Focus outline.** A visible focus ring uses the `--pa-solid` color.
17
+
18
+ What has **not** been checked: a pass with a screen reader, and contrast ratios of custom palettes. Treat the diagram as an
19
+ illustration and keep the key information in the surrounding text as well, as with any diagram. The text of the Mermaid
20
+ source is not a substitute for a description.
package/docs/agents.md ADDED
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: For coding agents
3
+ description: How a coding agent should use pele-animate in a project, and how to verify the result.
4
+ order: 14
5
+ section: Reference
6
+ ---
7
+
8
+ # For coding agents
9
+
10
+ If you are an AI coding agent adding pele-animate to a project, use the skill that ships with the package. It carries the rules
11
+ below in an order that works.
12
+
13
+ ## Install the skill
14
+
15
+ The skill is in the npm package, so after `npm i pele-animate` it is at `node_modules/pele-animate/skills/pele-animate/SKILL.md`.
16
+ For Claude Code, copy it where skills live:
17
+
18
+ ```sh
19
+ mkdir -p .claude/skills
20
+ cp -r node_modules/pele-animate/skills/pele-animate .claude/skills/
21
+ ```
22
+
23
+ Or clone just the skill folder from [GitHub](https://github.com/dkdev24/pele-animate/tree/main/skills/pele-animate) (it has `SKILL.md`, `verify.js` and `references/`).
24
+
25
+ A second skill, `diagram-step-order`, reviews a page's diagrams so the step order matches the text around them.
26
+
27
+ No skill support? Paste this into your instructions file:
28
+
29
+ ```md
30
+ ## Diagrams (pele-animate)
31
+ - Animated Mermaid diagrams use `pele` + `pele-animate`; mount on the client only (see node_modules/pele-animate/docs or the README).
32
+ - Icon names must exist: read node_modules/pele-animate/tabler/<category>.js. Never invent names. Unknown names render a plain square.
33
+ - Order with `%% pa: 1=A 2=B,C`; check svg.paSteps in a browser.
34
+ - Verify by rendering the page and confirming no unexpected rounded-square icons.
35
+ ```
36
+
37
+ ## Rules
38
+
39
+ 1. **Client only.** Never import `pele` or `pele-animate` in server code. Use the framework's mounted hook ([recipes](./recipes.md)).
40
+ 2. **Never invent icon names.** Look them up in `node_modules/pele-animate/tabler/<category>.js` (object keys) and import that category.
41
+ An unknown name does not fail; it renders a rounded square, so a made-up name is a silent bug.
42
+ 3. **Import three things:** `pele-animate/glyphs` (`icons`), the icon pack modules you use, and `pele-animate/style.css`.
43
+ 4. **Pin the order** with `%% pa:` when the default is wrong ([step order](./step-order.md)). Do not rename node ids after pinning.
44
+ 5. **Verify in a browser**, not by reading the code.
45
+
46
+ ## Verify
47
+
48
+ Render the page in a headless browser (Playwright, or any CLI browser) and run this in the page:
49
+
50
+ ```js
51
+ (() => {
52
+ const svgs = [...document.querySelectorAll('.pa-scene svg.pele')];
53
+ const icons = [...document.querySelectorAll('.pa-scene svg.pele-icon[data-icon]')];
54
+ return {
55
+ diagrams: svgs.length,
56
+ steps: svgs.map((s) => s.paSteps?.length ?? 0),
57
+ emptyIcons: icons.filter((i) => !i.innerHTML.trim()).map((i) => i.dataset.icon),
58
+ };
59
+ })()
60
+ ```
61
+
62
+ Expect `diagrams` equal to the number you added, every `steps` entry above 0, and `emptyIcons` empty. A name that was not registered renders
63
+ a rounded square instead of nothing, so also compare the icon names in your Mermaid with the pack source.
package/docs/api.md ADDED
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: API reference
3
+ description: Every export of pele-animate, with types.
4
+ order: 9
5
+ section: Reference
6
+ ---
7
+
8
+ # API reference
9
+
10
+ TypeScript types ship with the package (`types/`).
11
+
12
+ ## `pele-animate`
13
+
14
+ | Export | Signature | Description |
15
+ |---|---|---|
16
+ | `watch` | `watch(container: HTMLElement, source?: string, options?: { controls?: boolean }): 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. `controls: false` keeps click-to-replay instead of step mode. |
17
+ | `animate` | `animate(svg: SVGSVGElement, options?: { hover?: Element; source?: string }): void` | Animates one rendered svg. `source` is read for `%% pa:` pins. Sets `svg.paSteps`. |
18
+ | `replay` | `replay(svg: SVGSVGElement \| null \| undefined): void` | Plays the intro again. |
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. |
20
+
21
+ `svg.paSteps` (type `PaStep[]`, where `PaStep = Array<[element: Element, parts: Element[]]>`) is set by `animate()`: one array per
22
+ step.
23
+
24
+ ## `pele-animate/glyphs`
25
+
26
+ | Export | Signature | Description |
27
+ |---|---|---|
28
+ | `icons` | `icons(name: string): string` | Pele's `icons` resolver. Unknown names return a neutral rounded square. |
29
+ | `registerGlyphs` | `registerGlyphs(pack: Record<string, string>, strokeWidth?: number): void` | Adds glyphs: `{ name: '<inner markup of a 24x24 svg>' }`. Default stroke width 1.1. |
30
+ | `registerTabler` | `registerTabler(pack: Record<string, string>, strokeWidth?: number): void` | Adds outline icons whose stroke width follows `--pa-stroke` (fallback `strokeWidth`, default 1.5). |
31
+ | `S`, `L`, `W` | `string` | Theme color expressions for glyph markup: solid, light, white. |
32
+
33
+ ## `pele-animate/tabler/<category>`
34
+
35
+ Importing a module registers that category's icons. It also exports `pack: Record<string, string>` (name to inner markup).
36
+ Categories are listed in [icons](./icons.md).
37
+
38
+ ## `pele-animate/preset-doverunner`
39
+
40
+ Importing it registers the 20 `doverunner-*` glyphs. No exports.
41
+
42
+ ## `pele-animate/style.css`
43
+
44
+ The scene frame, motion and step controls. Import it once.
45
+
46
+ ## Classes you may see
47
+
48
+ `pa-scene` (container), `pa-ready` (an animated svg), `pa-in` and `pa-done` (intro states), `pa-stepping` (step mode), `pa-controls`
49
+ (the button bar). These are internal and may change; prefer the CSS variables in [theming](./theming.md) over targeting them.
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: Compatibility
3
+ description: Versions of Pele, browsers, and the parts of Pele's markup pele-animate depends on.
4
+ order: 10
5
+ section: Reference
6
+ ---
7
+
8
+ # Compatibility
9
+
10
+ | | Supported |
11
+ |---|---|
12
+ | Pele | `^1.7.0` (peer dependency). Tested with 1.7 (the docs site), 1.8 and 1.9. |
13
+ | Diagram types | Flowcharts and sequence diagrams ([diagram types](./diagram-types.md)) |
14
+ | Browsers | Current browsers with the Web Animations API, `IntersectionObserver` and `matchMedia` (Chrome, Edge, Firefox, Safari). Without `IntersectionObserver` the intro plays at once. |
15
+ | Module format | ESM only |
16
+ | Server rendering | Not applicable: mount on the client ([recipes](./recipes.md)) |
17
+
18
+ ## What pele-animate depends on in Pele
19
+
20
+ pele-animate reads the SVG Pele produces. It selects on these class names and attributes:
21
+
22
+ `.pele-node`, `.pele-edge`, `.pele-edge-label`, `.pele-marker`, `.pele-cluster-label`, `.pele-icon`, `.pele-lifeline`,
23
+ `.pele-actor-participant`, and the `data-id` attribute.
24
+
25
+ Pele has not promised these are stable across releases (the question is open upstream). That is why Pele is a peer dependency:
26
+ upgrade it deliberately, and re-check your diagrams afterwards. The repository's tests render every documentation example,
27
+ which catches parse errors but not visual changes.
28
+
29
+ ## Known limits
30
+
31
+ - Sequence-diagram participants ignore `@{ icon }`.
32
+ - Step mode is browser-tested on flowcharts only.
33
+ - Glyph art is square-boxed; wide art is drawn as a wide shape inside the square.
@@ -0,0 +1,24 @@
1
+ ---
2
+ title: Contributing
3
+ description: Set up the repository, run the checks, and regenerate the Tabler packs.
4
+ order: 15
5
+ section: Reference
6
+ ---
7
+
8
+ # Contributing
9
+
10
+ ```sh
11
+ git clone https://github.com/dkdev24/pele-animate
12
+ cd pele-animate
13
+ pnpm install
14
+ pnpm test # renders every Mermaid example in the docs and README with Pele, and checks icon names
15
+ pnpm build # builds the site (a placeholder until the site lands)
16
+ ```
17
+
18
+ - The package is plain ESM at the repository root: no build step. The site lives in `site/`.
19
+ - Docs are the Markdown files in `docs/`. A fenced block marked `mermaid` must render, and every `@{ icon }` name in it must exist.
20
+ - Tabler packs are generated: `node scripts/build-tabler.mjs <path to a tabler-icons checkout>` rewrites `tabler/*.js`. Do not edit those
21
+ files by hand. The Tabler version is recorded in each file header and in `THIRD-PARTY-NOTICES.md`.
22
+ - Add an entry to `CHANGELOG.md` for any user-visible change. Breaking changes also get a section in `docs/migrating.md`.
23
+ - Versioning stays on `0.x`.
24
+ - Keep example diagrams generic (clients, APIs, databases).
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Custom icons
3
+ description: Register your own glyphs with registerGlyphs.
4
+ order: 5
5
+ section: Guides
6
+ ---
7
+
8
+ # Custom icons
9
+
10
+ Register your own icons with `registerGlyphs`:
11
+
12
+ ```js
13
+ import { registerGlyphs, S, L } from 'pele-animate/glyphs';
14
+
15
+ registerGlyphs({
16
+ 'my-box': `<rect x="4" y="6" width="16" height="12" rx="2" fill="${L}" stroke="${S}"/>`,
17
+ });
18
+ ```
19
+
20
+ Then use `icon: "my-box"` in your Mermaid.
21
+
22
+ ## The contract
23
+
24
+ - A glyph is the **inner markup** of a 24 by 24 SVG: shapes only, no `<svg>` wrapper. Draw inside the 24 by 24 box.
25
+ - Colors: use `S` (solid) and `L` (light), which are the CSS variables `--pa-solid` and `--pa-light` with fallbacks, plus
26
+ `W` for white. Then the glyph follows light and dark themes (see [theming](./theming.md)).
27
+ - `registerGlyphs(pack, strokeWidth = 1.1)` wraps each glyph in a group with that stroke width. Pele draws icons at stroke
28
+ width 2, which looks heavy on a large icon, so glyphs get a thinner one.
29
+ - Line icons that should respond to `--pa-stroke` (as the Tabler packs do) can use `registerTabler(pack, strokeWidth = 1.5)`
30
+ instead. It sets fill none, round caps and joins, and the stroke color for you.
31
+
32
+ ## Names
33
+
34
+ Registering a name that already exists replaces it. Choose a prefix for your own pack (`acme-box`) so your names never clash
35
+ with Tabler's plain names.
36
+
37
+ ## Safety
38
+
39
+ Glyph markup is inserted into the page as SVG. Only register markup you trust. See [security](./security.md).
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: Diagram types
3
+ description: Which Mermaid diagrams pele-animate animates, and what each one does.
4
+ order: 3
5
+ section: Start
6
+ ---
7
+
8
+ # Diagram types
9
+
10
+ pele-animate supports **flowcharts** and **sequence diagrams**. Pele renders other diagram types too, but they are outside what
11
+ pele-animate is built for.
12
+
13
+ ## Flowcharts
14
+
15
+ Nodes appear in step order, edges draw from their source node, and edge labels fade in. Groups (`subgraph`) and their titles
16
+ are kept. Icon nodes (`@{ icon }`) work here; see [icons](./icons.md).
17
+
18
+ ```mermaid live
19
+ flowchart LR
20
+ A[Client] --> B{Cached?}
21
+ B -->|yes| C[Serve]
22
+ B -->|no| D[Fetch] --> C
23
+ ```
24
+
25
+ ## Sequence diagrams
26
+
27
+ Actors appear first, then the messages in order. Participant boxes in a row get the same height, and group titles are bold.
28
+
29
+ ```mermaid live
30
+ sequenceDiagram
31
+ Client->>API: request
32
+ API->>Database: query
33
+ Database-->>API: rows
34
+ API-->>Client: response
35
+ ```
36
+
37
+ **Limit:** Pele ignores `@{ icon }` on sequence participants (the box shows its id), so icons apply to flowcharts only.
38
+
39
+ ## Everything else
40
+
41
+ Other Mermaid types (class, state, ER, gantt, pie and the rest) render through Pele as usual. pele-animate is not designed for
42
+ them and its behavior on them is untested, so use plain Pele for those. Step mode has been checked in a browser on
43
+ flowcharts only; sequence diagrams have not been checked the same way yet.
package/docs/faq.md ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: FAQ
3
+ description: Common questions about pele-animate, Pele, and licenses.
4
+ order: 16
5
+ section: Reference
6
+ ---
7
+
8
+ # FAQ
9
+
10
+ **Is this part of Pele?** No. It is an unofficial add-on, not affiliated with or endorsed by the Pele or Obsidian teams. Pele does the
11
+ layout and drawing; pele-animate adds step order, step-by-step playback and icons on top.
12
+
13
+ **Why not just use Pele?** Pele alone draws a static diagram. Use it directly if that is enough. pele-animate is for diagrams
14
+ you want to explain in order.
15
+
16
+ **Is it a theme?** No. It does not offer visual styles beyond a simple scene frame and light/dark colors you can override.
17
+
18
+ **Why not Mermaid.js?** Pele is much smaller and renders synchronously. pele-animate is built on Pele, so it follows that choice.
19
+
20
+ **Does it work with server rendering?** Mount it on the client ([recipes](./recipes.md)). Static site generators are fine.
21
+
22
+ **How big is it?** The core (`pele-animate.js` plus CSS) is about 20 KB unminified. Icon packs are separate modules, so you only
23
+ ship the categories you import (the largest, `system`, is about 199 KB unminified).
24
+
25
+ **Which diagrams does it support?** Flowcharts and sequence diagrams ([diagram types](./diagram-types.md)).
26
+
27
+ **Can I use my own icons?** Yes ([custom icons](./custom-icons.md)).
28
+
29
+ **Licenses.** pele-animate is MIT. Pele is MIT. The Tabler icon packs are from Tabler Icons (MIT, Paweł Kuna); see
30
+ `THIRD-PARTY-NOTICES.md`.
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: Getting started
3
+ description: Install pele-animate and render your first step-by-step Mermaid diagram.
4
+ order: 1
5
+ section: Start
6
+ ---
7
+
8
+ # Getting started
9
+
10
+ pele-animate makes a [Pele](https://pele.run) diagram explain itself one step at a time. You choose the order things appear
11
+ in, readers step through it with buttons or the keyboard, and any node can carry an icon from a large set. It is an
12
+ unofficial add-on for Pele and does not change how Pele lays out or draws diagrams.
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm i pele-animate pele
18
+ ```
19
+
20
+ `pele` is a peer dependency (`^1.7.0`). Both run in the browser: they need the DOM, so mount them on the client (see
21
+ [recipes](./recipes.md) for frameworks).
22
+
23
+ ## First diagram
24
+
25
+ Put the Mermaid source in an element, then mount it with Pele and hand it to `watch()`:
26
+
27
+ ```js
28
+ import { mount } from 'pele';
29
+ import { watch } from 'pele-animate';
30
+ import { icons } from 'pele-animate/glyphs';
31
+ import 'pele-animate/tabler/computers'; // icons: one Tabler category, import as many as you need
32
+ import 'pele-animate/style.css';
33
+
34
+ const el = document.querySelector('pre.mermaid');
35
+ const src = el.textContent;
36
+ mount(el, src, { icons }); // Pele draws the SVG
37
+ watch(el, src); // pele-animate animates it, and re-applies when Pele re-lays-out on resize
38
+ ```
39
+
40
+ The Mermaid source:
41
+
42
+ ```mermaid live
43
+ flowchart LR
44
+ %% pa: 1=C 2=L 3=S
45
+ C@{ icon: "http-get", form: "square", h: 88, label: "Request" }
46
+ L@{ icon: "load-balancer", form: "square", h: 88, label: "Load balancer" }
47
+ S@{ icon: "cloud-computing", form: "square", h: 88, label: "Cloud service" }
48
+ C <-->|route| L
49
+ L <-->|forward| S
50
+ ```
51
+
52
+ What you get:
53
+
54
+ - The intro plays once when the diagram scrolls into view: nodes appear in order, edges draw in, labels fade in.
55
+ - Hover or focus: small tokens travel along the edges.
56
+ - Click, or focus and press Enter: **step mode**. Previous, play/pause and next buttons appear, and Space, ←, → and Esc work.
57
+ - With `prefers-reduced-motion`, the motion is off and the finished picture shows.
58
+
59
+ 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).
60
+
61
+ ## Next
62
+
63
+ - Pick icons: [icons](./icons.md).
64
+ - Control the order: [step order](./step-order.md).
65
+ - Match your site's colors: [theming](./theming.md).
66
+ - Upgrading from 0.12: [migrating](./migrating.md).
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: How it works
3
+ description: What Pele does, what pele-animate adds, and the three kinds of motion.
4
+ order: 2
5
+ section: Start
6
+ ---
7
+
8
+ # How it works
9
+
10
+ Two layers, one diagram:
11
+
12
+ 1. **Pele** parses the Mermaid, lays the diagram out and returns an SVG. That is all Pele's job; pele-animate does not
13
+ touch layout, sizing or syntax.
14
+ 2. **pele-animate** reads that SVG after Pele draws it, works out the order things should appear in, and adds the motion,
15
+ the step playback and the icons. The Mermaid source stays valid Mermaid, so GitHub or Obsidian still show a normal diagram.
16
+
17
+ ## The calls
18
+
19
+ - `mount(el, src, { icons })` is Pele's. The `icons` option is how glyphs get in (see [icons](./icons.md)).
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
+ it, and re-applies after Pele re-draws on resize. The intro is skipped on those re-draws once it has played.
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
+
25
+ ## The three kinds of motion
26
+
27
+ | Motion | When | Notes |
28
+ |---|---|---|
29
+ | **Intro** | Once, when the diagram is 30% in view | Nodes appear by step, each edge draws from its source, labels fade in. A long diagram squeezes its steps so the intro stays near 3 seconds. |
30
+ | **Tokens** | While hovering or focusing the diagram | Small dots travel along the edges in sequence. |
31
+ | **Step mode** | Click, or Enter | You move through the same steps one at a time. See [step order](./step-order.md). |
32
+
33
+ The resting state is always the finished picture. Everything honors `prefers-reduced-motion`.
34
+
35
+ ## Where the order comes from
36
+
37
+ Order is a list of **steps**. By default, a flowchart's steps are the breadth-first levels from the nodes that nothing points to;
38
+ a sequence diagram's steps are its actors, then its messages in order. A `%% pa:` comment overrides that. After
39
+ `animate()` runs, `svg.paSteps` holds one array per step, which is also what step mode uses.
40
+
41
+ ## What it depends on in Pele
42
+
43
+ pele-animate selects on class names in Pele's SVG (`.pele-node`, `.pele-edge`, and a few others) and on the `data-id` attribute.
44
+ Pele is a peer dependency so you control its version. See [compatibility](./compatibility.md).
package/docs/icons.md ADDED
@@ -0,0 +1,82 @@
1
+ ---
2
+ title: Icons
3
+ description: Use icons on flowchart nodes, pick names from 4,000+ Tabler icons, and control stroke width.
4
+ order: 4
5
+ section: Guides
6
+ ---
7
+
8
+ # Icons
9
+
10
+ A flowchart node becomes an illustrated node with Mermaid's own `@{ }` syntax:
11
+
12
+ ```mermaid live
13
+ flowchart LR
14
+ A@{ icon: "device-desktop", form: "square", h: 88, label: "Laptop" }
15
+ B@{ icon: "server", form: "square", h: 88, label: "Server" }
16
+ A --> B
17
+ ```
18
+
19
+ Both names are in the Tabler `devices` category, so this needs `import 'pele-animate/tabler/devices'`.
20
+
21
+ - `icon` is the glyph name. `label` is the caption.
22
+ - `form: "square", h: 88` makes a large frameless icon. Leave both out for a small icon inside a frame.
23
+ - Unknown names get a neutral rounded square, never a blank slot. Pele ships no icons of its own, so every name must come
24
+ from a pack you import.
25
+
26
+ ## Packs
27
+
28
+ Icons come from packs. Importing a pack module registers its icons.
29
+
30
+ | Pack | Import | Contents |
31
+ |---|---|---|
32
+ | **Tabler categories** | `pele-animate/tabler/<category>` | 4,368 outline icons in 36 categories, from [Tabler Icons](https://github.com/tabler/tabler-icons) 3.49.0 (MIT) |
33
+ | **doverunner-\*** (optional) | `pele-animate/preset-doverunner` | 20 filled, two-tone illustrations named `doverunner-<name>` (see below) |
34
+ | **Your own** | `registerGlyphs()` | See [custom icons](./custom-icons.md) |
35
+
36
+ Pass the resolver to Pele: `mount(el, src, { icons })` with `import { icons } from 'pele-animate/glyphs'`.
37
+
38
+ ### Tabler categories
39
+
40
+ Import only the categories you use; each is its own module (the largest, `system`, is about 199 KB).
41
+
42
+ | Category | Icons | Category | Icons | Category | Icons |
43
+ |---|---|---|---|---|---|
44
+ | system | 784 | map | 263 | food | 96 |
45
+ | devices | 363 | document | 209 | buildings | 95 |
46
+ | design | 350 | text | 194 | vehicles | 90 |
47
+ | arrows | 333 | shapes | 187 | math | 88 |
48
+ | media | 160 | e-commerce | 155 | health | 87 |
49
+ | communication | 121 | sport | 76 | currencies | 76 |
50
+ | development | 63 | weather | 61 | photography | 52 |
51
+ | mood | 52 | nature | 50 | games | 48 |
52
+ | computers | 44 | database | 42 | laundry | 40 |
53
+ | charts | 39 | symbols | 37 | badges | 22 |
54
+ | electrical | 19 | animals | 18 | gestures | 17 |
55
+ | version-control | 16 | extensions | 13 | logic | 8 |
56
+
57
+ Brand, Letters, Numbers, Zodiac and Gender are not included. Counts are for Tabler 3.49.0.
58
+
59
+ ### Finding a name
60
+
61
+ Do not guess names. Look them up:
62
+
63
+ - Tabler's own site, [tabler.io/icons](https://tabler.io/icons), lists names and categories (use the outline style).
64
+ - In your project: `node_modules/pele-animate/tabler/<category>.js` lists every name in that category as an object key.
65
+ - Names that exist in more than one place are not a problem: Tabler names are plain (`server`, `lock`), `doverunner-*` names are prefixed.
66
+
67
+ ## Stroke width
68
+
69
+ Tabler icons are line icons drawn to work at any stroke width. Set the CSS variable `--pa-stroke` on the container:
70
+
71
+ ```css
72
+ .pa-scene { --pa-stroke: 1; }
73
+ ```
74
+
75
+ The default is `1.5`. Tabler draws at 2. The `doverunner-*` glyphs have a fixed stroke width.
76
+
77
+ ## The optional doverunner-* pack
78
+
79
+ `pele-animate/preset-doverunner` ships 20 filled, two-tone glyphs in the style of the DoveRunner Lab product cards, named
80
+ `doverunner-<name>`: `player`, `server`, `key`, `document`, `shield`, `phone`, `cloud`, `package`, `token`, `lock`,
81
+ `database`, `video`, `media`, `encoder`, `storage`, `plugin`, `variants`, `watermark`, `bits-a`, `bits-b`. Import it only
82
+ if you want that look; nothing else needs it.