zombie-mermaid 1.4.0 → 1.6.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 +71 -15
- package/dist/ascii.cjs +8012 -0
- package/dist/ascii.cjs.map +1 -0
- package/dist/ascii.d.cts +1 -0
- package/dist/ascii.d.ts +1 -0
- package/dist/ascii.js +7981 -0
- package/dist/ascii.js.map +1 -0
- package/dist/cli.js +1423 -320
- package/dist/index-ZirmSoos.d.cts +178 -0
- package/dist/index-ZirmSoos.d.ts +178 -0
- package/dist/index.cjs +1248 -536
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +149 -150
- package/dist/index.d.ts +149 -150
- package/dist/index.js +1249 -538
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +13100 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +14 -0
- package/dist/mcp.d.ts +14 -0
- package/dist/mcp.js +13059 -0
- package/dist/mcp.js.map +1 -0
- package/package.json +46 -6
- package/src/__tests__/ascii-class-padding.test.ts +104 -0
- package/src/__tests__/ascii-combining-mark-width.test.ts +70 -0
- package/src/__tests__/ascii-coords-overlay.test.ts +64 -0
- package/src/__tests__/ascii-display-width-unit.test.ts +154 -0
- package/src/__tests__/ascii-draw-bundles.test.ts +198 -0
- package/src/__tests__/ascii-edge-cross-style-overlap.test.ts +212 -0
- package/src/__tests__/ascii-emoji-cluster-width.test.ts +101 -0
- package/src/__tests__/ascii-er-jog-stray-line.test.ts +82 -0
- package/src/__tests__/ascii-er-padding.test.ts +114 -0
- package/src/__tests__/ascii-er-relationship-label-corruption-350.test.ts +458 -0
- package/src/__tests__/ascii-er-relationship-overwrite.test.ts +303 -0
- package/src/__tests__/ascii-multibox-cjk-width.test.ts +1 -1
- package/src/__tests__/ascii-padding-edge-cases.test.ts +154 -0
- package/src/__tests__/ascii-sequence-mermaid-parity.test.ts +198 -0
- package/src/__tests__/ascii-sequence-padding.test.ts +119 -0
- package/src/__tests__/ascii-subgraph-later-edgeless-301.test.ts +273 -0
- package/src/__tests__/class-click-interactions.test.ts +210 -0
- package/src/__tests__/class-integration.test.ts +36 -0
- package/src/__tests__/cli-mcp-dispatch.test.ts +68 -0
- package/src/__tests__/cli-mcp.test.ts +44 -0
- package/src/__tests__/cli-render.test.ts +79 -0
- package/src/__tests__/cli-test-helpers.ts +4 -0
- package/src/__tests__/cli-web-dispatch.test.ts +62 -0
- package/src/__tests__/cli-web.test.ts +203 -0
- package/src/__tests__/cli.test.ts +152 -1
- package/src/__tests__/click-directive.test.ts +63 -0
- package/src/__tests__/edge-cell-styles.test.ts +177 -0
- package/src/__tests__/elk-adapter-utils.test.ts +166 -0
- package/src/__tests__/elk-layout-cache.test.ts +217 -0
- package/src/__tests__/er-click-unsupported.test.ts +72 -0
- package/src/__tests__/grid-occupancy.test.ts +160 -0
- package/src/__tests__/helpers/terminal-display-width.ts +41 -13
- package/src/__tests__/interactivity-config.test.ts +140 -4
- package/src/__tests__/interactivity-option.test.ts +173 -0
- package/src/__tests__/mcp-render-ascii-tool.test.ts +94 -0
- package/src/__tests__/mcp-render-svg-theme-guard.test.ts +27 -0
- package/src/__tests__/mcp-render-svg-tool.test.ts +116 -0
- package/src/__tests__/mcp-server.test.ts +104 -0
- package/src/__tests__/package-info.test.ts +51 -0
- package/src/__tests__/sequence-integration.test.ts +69 -0
- package/src/__tests__/sequence-layout.test.ts +25 -0
- package/src/__tests__/sequence-parser.test.ts +123 -0
- package/src/__tests__/svg-accessible-name-conformance.test.ts +256 -0
- package/src/__tests__/svg-accessible-name.test.ts +392 -0
- package/src/__tests__/testdata/ascii/cls_annotation.txt +18 -18
- package/src/__tests__/testdata/ascii/cls_basic.txt +9 -9
- package/src/__tests__/testdata/ascii/cls_inheritance.txt +15 -15
- package/src/__tests__/testdata/ascii/cls_methods.txt +12 -12
- package/src/__tests__/testdata/unicode/cls_annotation.txt +18 -18
- package/src/__tests__/testdata/unicode/cls_basic.txt +9 -9
- package/src/__tests__/testdata/unicode/cls_inheritance.txt +15 -15
- package/src/__tests__/testdata/unicode/cls_methods.txt +12 -12
- package/src/__tests__/text-metrics.test.ts +21 -0
- package/src/ascii/class-diagram.ts +18 -22
- package/src/ascii/coords.ts +54 -0
- package/src/ascii/display-width.ts +112 -26
- package/src/ascii/draw-boxes.ts +9 -0
- package/src/ascii/draw-bundles.ts +104 -0
- package/src/ascii/draw.ts +19 -0
- package/src/ascii/edge-cell-styles.ts +81 -0
- package/src/ascii/er-diagram.ts +551 -60
- package/src/ascii/grid-occupancy.ts +98 -0
- package/src/ascii/grid.ts +265 -9
- package/src/ascii/index.ts +27 -8
- package/src/ascii/sequence.ts +89 -15
- package/src/ascii/types.ts +46 -0
- package/src/class/format.ts +15 -0
- package/src/class/layout.ts +11 -33
- package/src/class/parser.ts +9 -0
- package/src/class/renderer.ts +72 -17
- package/src/class/types.ts +7 -1
- package/src/cli/mcp.ts +36 -0
- package/src/cli/parse-args.ts +95 -3
- package/src/cli/render.ts +5 -0
- package/src/cli/web.ts +235 -0
- package/src/cli.ts +39 -16
- package/src/click-directive.ts +105 -0
- package/src/elk-instance.ts +110 -1
- package/src/er/layout.ts +4 -13
- package/src/er/renderer.ts +14 -12
- package/src/index.ts +75 -1
- package/src/layout-engine/elk-adapter-utils.ts +81 -0
- package/src/layout-engine/from-elk.ts +7 -30
- package/src/layout-engine/to-elk.ts +1 -1
- package/src/layout-engine.ts +1 -1
- package/src/mcp/index.ts +17 -0
- package/src/mcp/server.ts +75 -0
- package/src/mcp/tools/render-ascii.ts +99 -0
- package/src/mcp/tools/render-svg.ts +95 -0
- package/src/multiline-utils.ts +17 -0
- package/src/package-info.ts +30 -0
- package/src/parser.ts +55 -51
- package/src/renderer.ts +71 -57
- package/src/sequence/layout.ts +2 -0
- package/src/sequence/parser.ts +100 -58
- package/src/sequence/renderer.ts +61 -20
- package/src/sequence/types.ts +8 -0
- package/src/text-metrics.ts +26 -2
- package/src/theme.ts +104 -1
- package/src/types.ts +92 -1
- package/src/xychart/renderer.ts +13 -4
package/README.md
CHANGED
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
**Render Mermaid diagrams as beautiful SVGs or ASCII art**
|
|
6
6
|
|
|
7
|
-
Ultra-fast, fully themeable, zero DOM dependencies. A maintained fork of [`beautiful-mermaid`](https://github.com/lukilabs/beautiful-mermaid).
|
|
7
|
+
Ultra-fast, fully themeable, zero DOM dependencies. A maintained fork of [`beautiful-mermaid`](https://github.com/lukilabs/beautiful-mermaid) that refuses to die.
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
|
-
[
|
|
11
|
+
[](https://dfadler.github.io/zombie-mermaid/)
|
|
12
|
+
[](https://dfadler.github.io/zombie-mermaid/fork-fixes.html)
|
|
12
13
|
|
|
13
14
|
[](https://www.npmjs.com/package/zombie-mermaid)
|
|
15
|
+
[](https://github.com/dfadler/zombie-mermaid/actions/workflows/ci.yml)
|
|
16
|
+
[](https://codecov.io/gh/dfadler/zombie-mermaid)
|
|
17
|
+
[](#bundle-size)
|
|
18
|
+
[](https://socket.dev/npm/package/zombie-mermaid)
|
|
14
19
|
[](LICENSE)
|
|
15
20
|
|
|
16
21
|
</div>
|
|
@@ -19,11 +24,13 @@ Ultra-fast, fully themeable, zero DOM dependencies. A maintained fork of [`beaut
|
|
|
19
24
|
|
|
20
25
|
## Why This Fork Exists
|
|
21
26
|
|
|
22
|
-
`beautiful-mermaid` is a genuinely good library —
|
|
27
|
+
`beautiful-mermaid` is a genuinely good library — fast, beautiful, and works everywhere from rich UIs to plain terminals. But upstream development has stalled: dozens of [pull requests](https://github.com/lukilabs/beautiful-mermaid/pulls) sit open, some for over half a year, and nothing has merged in months — by most definitions, it's dead. I maintain `zombie-mermaid` as the fork that won't stay buried: pulling in upstream fixes, giving PRs stuck in the upstream queue a home, and actually shipping releases. Craft and Craft Agents aren't part of this project's process going forward; this is an independently maintained continuation.
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
This isn't just a claim — see **[what this fork fixes](https://dfadler.github.io/zombie-mermaid/fork-fixes.html)** for an evidence-based before/after showcase: every bug listed there is rendered by the actual pre-fix and post-fix code, not described from memory.
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
It's still MIT-licensed, still built on the same foundation, and still credits the original authors — including the ASCII rendering engine's origins — in [Attribution](#attribution) below.
|
|
32
|
+
|
|
33
|
+
## The Problem With Default Mermaid Rendering
|
|
27
34
|
|
|
28
35
|
Diagrams are essential for AI-assisted programming. When you're working with an AI coding assistant, being able to visualize data flows, state machines, and system architecture—directly in your terminal or chat interface—makes complex concepts instantly graspable.
|
|
29
36
|
|
|
@@ -34,9 +41,15 @@ Diagrams are essential for AI-assisted programming. When you're working with an
|
|
|
34
41
|
- **No terminal output** — Can't render to ASCII for CLI tools
|
|
35
42
|
- **Heavy dependencies** — Pulls in a lot of code for simple diagrams
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
### Bundle Size
|
|
38
45
|
|
|
39
|
-
The
|
|
46
|
+
The **Bundle Size** badge above tracks the gzipped size of `zombie-mermaid`'s
|
|
47
|
+
main entry point (`dist/index.js`) and updates automatically with every
|
|
48
|
+
release — the same badge/CI-tracked pattern already backing the coverage and
|
|
49
|
+
CI status badges. Need ASCII rendering only? `import { renderMermaidASCII }
|
|
50
|
+
from 'zombie-mermaid/ascii'` skips [ELK.js](https://github.com/kieler/elkjs),
|
|
51
|
+
the layout engine the SVG renderer depends on, for a substantially smaller
|
|
52
|
+
bundle.
|
|
40
53
|
|
|
41
54
|
## Features
|
|
42
55
|
|
|
@@ -49,6 +62,7 @@ The ASCII rendering engine is based on [mermaid-ascii](https://github.com/Alexan
|
|
|
49
62
|
- **Mono mode** — Beautiful diagrams from just 2 colors
|
|
50
63
|
- **Zero DOM dependencies** — Pure TypeScript, works everywhere
|
|
51
64
|
- **Ultra-fast** — Renders 100+ diagrams in under 500ms
|
|
65
|
+
- **Accessible SVG output, CI-enforced** — every diagram type always gets a `role`-correct, nameable root `<svg>`; see the [accessibility conformance statement](docs/accessibility.md) for exactly what's guaranteed
|
|
52
66
|
|
|
53
67
|
## Installation
|
|
54
68
|
|
|
@@ -95,6 +109,16 @@ const ascii = renderMermaidASCII(`graph LR; A --> B --> C`)
|
|
|
95
109
|
└───┘ └───┘ └───┘
|
|
96
110
|
```
|
|
97
111
|
|
|
112
|
+
ASCII-only consumers (a CLI, a terminal UI, a serverless function) can import
|
|
113
|
+
from `zombie-mermaid/ascii` instead of the package root. The root entry
|
|
114
|
+
statically pulls in `elkjs` for the SVG layout engine — over 1.4MB minified —
|
|
115
|
+
even if you never call `renderMermaidSVG`. The `/ascii` subpath never imports
|
|
116
|
+
it:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { renderMermaidASCII } from 'zombie-mermaid/ascii'
|
|
120
|
+
```
|
|
121
|
+
|
|
98
122
|
Using this from React? See [React Integration](docs/react-integration.md) for a zero-flash `useMemo()` pattern.
|
|
99
123
|
|
|
100
124
|
---
|
|
@@ -115,9 +139,43 @@ zombie-mermaid --help # Show all options
|
|
|
115
139
|
|
|
116
140
|
---
|
|
117
141
|
|
|
142
|
+
## MCP Server
|
|
143
|
+
|
|
144
|
+
> 🧪 **Experimental — shipped to gauge interest, not a finished or best-effort implementation.** This is a first cut covering the common case; the tool surface may change based on feedback. Try it and [open an issue](https://github.com/dfadler/zombie-mermaid/issues/new) with what you'd want from it.
|
|
145
|
+
|
|
146
|
+
`zombie-mermaid mcp` starts a [Model Context Protocol](https://modelcontextprotocol.io/) server on stdio, exposing the library's rendering as two tools: `render_mermaid_svg` and `render_mermaid_ascii`. Point an MCP client (Claude Desktop, Claude Code, or anything else that speaks MCP) at it to render Mermaid diagrams directly in a conversation, without shelling out to the CLI or importing the library.
|
|
147
|
+
|
|
148
|
+
Example Claude Desktop / Claude Code MCP server config:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"zombie-mermaid": {
|
|
154
|
+
"command": "npx",
|
|
155
|
+
"args": ["-y", "zombie-mermaid", "mcp"]
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Both tools accept a `diagram` string plus a handful of rendering options (`theme`, `transparent`, `font` for SVG; `useAscii`, `paddingX`/`paddingY`/`boxBorderPadding` for ASCII) — see each tool's `inputSchema` for the full, current list. Invalid Mermaid syntax comes back as a normal tool error (`isError: true`) rather than crashing the connection.
|
|
162
|
+
|
|
163
|
+
To embed the server in your own process instead of running it as a subcommand, import `zombie-mermaid/mcp` and connect it to any [MCP `Transport`](https://modelcontextprotocol.io/) yourself:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { createMcpServer } from 'zombie-mermaid/mcp'
|
|
167
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
168
|
+
|
|
169
|
+
const server = createMcpServer()
|
|
170
|
+
await server.connect(new StdioServerTransport())
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
118
175
|
## Docs
|
|
119
176
|
|
|
120
177
|
- [Guides](docs/guides/) — task-oriented walkthroughs: [browsing the samples](docs/guides/samples.md), [choosing a theme](docs/guides/theming.md)
|
|
178
|
+
- [Accessibility](docs/accessibility.md) — conformance statement: what's guaranteed (and CI-enforced), what's implemented but unverified by automation, and what isn't covered
|
|
121
179
|
- [Theming](docs/theming.md) — the two-color foundation, enriched mode, built-in themes, custom themes, Shiki compatibility
|
|
122
180
|
- [Supported Diagrams](docs/diagrams.md) — syntax for every diagram type, XY chart styling, and ASCII rendering options
|
|
123
181
|
- [React Integration](docs/react-integration.md) — zero-flash rendering with `useMemo()`
|
|
@@ -130,7 +188,7 @@ More design write-ups and reference material live in [docs/](docs/).
|
|
|
130
188
|
|
|
131
189
|
## Attribution
|
|
132
190
|
|
|
133
|
-
The ASCII rendering engine is based on [mermaid-ascii](https://github.com/AlexanderGrooff/mermaid-ascii) by Alexander Grooff
|
|
191
|
+
The ASCII rendering engine is based on [mermaid-ascii](https://github.com/AlexanderGrooff/mermaid-ascii) by Alexander Grooff, ported from Go to TypeScript and extended with:
|
|
134
192
|
|
|
135
193
|
- Sequence diagram support
|
|
136
194
|
- Class diagram support
|
|
@@ -142,14 +200,12 @@ Thank you Alexander for the excellent foundation!
|
|
|
142
200
|
|
|
143
201
|
---
|
|
144
202
|
|
|
145
|
-
##
|
|
203
|
+
## Contributing
|
|
146
204
|
|
|
147
|
-
|
|
205
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, the test/lint workflow, and how changesets and releases work ([RELEASING.md](RELEASING.md)). Security issues should go through [SECURITY.md](SECURITY.md) instead of a public issue. Released versions are tracked in [CHANGELOG.md](CHANGELOG.md).
|
|
148
206
|
|
|
149
207
|
---
|
|
150
208
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Built with care by the team at [Craft](https://craft.do)
|
|
209
|
+
## License
|
|
154
210
|
|
|
155
|
-
|
|
211
|
+
MIT — see [LICENSE](LICENSE) for details.
|