zombie-mermaid 1.7.0 → 2.1.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 (111) hide show
  1. package/README.md +19 -2
  2. package/dist/ascii.cjs +7 -7
  3. package/dist/ascii.cjs.map +1 -1
  4. package/dist/ascii.d.cts +32 -0
  5. package/dist/ascii.d.ts +32 -0
  6. package/dist/ascii.js +2208 -1487
  7. package/dist/ascii.js.map +1 -1
  8. package/dist/cli.js +6223 -4448
  9. package/dist/index.cjs +55 -54
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +180 -5
  12. package/dist/index.d.ts +180 -5
  13. package/dist/index.js +3488 -2383
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp.cjs +2581 -439
  16. package/dist/mcp.cjs.map +1 -1
  17. package/dist/mcp.js +2581 -439
  18. package/dist/mcp.js.map +1 -1
  19. package/package.json +12 -3
  20. package/src/__tests__/ascii-ansi.test.ts +15 -0
  21. package/src/__tests__/ascii-class-column-width-488-489.test.ts +639 -0
  22. package/src/__tests__/ascii-class-detour-label-routing-487.test.ts +114 -0
  23. package/src/__tests__/ascii-class-label-box-collision.test.ts +60 -0
  24. package/src/__tests__/ascii-class-label-territory-row-awareness.test.ts +57 -0
  25. package/src/__tests__/ascii-class-reciprocal-relationships-448.test.ts +84 -0
  26. package/src/__tests__/ascii-edge-bundling-rank-violation-454.test.ts +72 -0
  27. package/src/__tests__/ascii-edge-label-diagonal-fallback-418.test.ts +95 -0
  28. package/src/__tests__/ascii-er-corner-glyphs.test.ts +15 -6
  29. package/src/__tests__/ascii-er-relationship-overwrite.test.ts +24 -19
  30. package/src/__tests__/ascii-er-unrelated-stem-separation-411.test.ts +98 -0
  31. package/src/__tests__/ascii-hyperlinks.test.ts +361 -0
  32. package/src/__tests__/ascii-label-line-terminal-fallback.test.ts +168 -0
  33. package/src/__tests__/ascii-nested-subgraph-sibling-order-444.test.ts +105 -0
  34. package/src/__tests__/ascii-sequence-box-group.test.ts +159 -0
  35. package/src/__tests__/ascii-sequence-create-destroy.test.ts +114 -0
  36. package/src/__tests__/ascii-sequence-form-invariants.test.ts +7 -6
  37. package/src/__tests__/ascii-sequence-mermaid-parity.test.ts +21 -0
  38. package/src/__tests__/ascii-subgraph-direction-honored-445.test.ts +90 -0
  39. package/src/__tests__/box-color.test.ts +80 -0
  40. package/src/__tests__/class-arrow-directions.test.ts +105 -13
  41. package/src/__tests__/class-click-interactions.test.ts +34 -9
  42. package/src/__tests__/class-notes.test.ts +317 -0
  43. package/src/__tests__/class-parser.test.ts +87 -1
  44. package/src/__tests__/class-styling.test.ts +481 -0
  45. package/src/__tests__/cli-e2e.test.ts +62 -0
  46. package/src/__tests__/cli-png.test.ts +35 -0
  47. package/src/__tests__/cli-render.test.ts +584 -3
  48. package/src/__tests__/cli-test-helpers.ts +28 -5
  49. package/src/__tests__/cli.test.ts +582 -4
  50. package/src/__tests__/color-utils.test.ts +186 -0
  51. package/src/__tests__/direction-override.test.ts +397 -0
  52. package/src/__tests__/interactivity-config.test.ts +34 -9
  53. package/src/__tests__/monospace-metrics.test.ts +74 -0
  54. package/src/__tests__/resolve-colors.test.ts +446 -0
  55. package/src/__tests__/sequence-integration.test.ts +94 -0
  56. package/src/__tests__/sequence-layout.test.ts +220 -0
  57. package/src/__tests__/sequence-parser.test.ts +287 -0
  58. package/src/__tests__/svg-csp-style-options.test.ts +427 -0
  59. package/src/__tests__/testdata/ascii/cls_all_relationships.txt +11 -9
  60. package/src/__tests__/testdata/ascii/subgraph_direction_override.txt +27 -17
  61. package/src/__tests__/testdata/unicode/cls_all_relationships.txt +11 -9
  62. package/src/__tests__/text-metrics.test.ts +211 -57
  63. package/src/__tests__/xychart-ascii.test.ts +49 -0
  64. package/src/ascii/ansi.ts +24 -37
  65. package/src/ascii/canvas.ts +31 -6
  66. package/src/ascii/class-diagram.ts +913 -95
  67. package/src/ascii/converter.ts +37 -4
  68. package/src/ascii/coords.ts +7 -3
  69. package/src/ascii/draw-boxes.ts +5 -5
  70. package/src/ascii/draw-subgraphs.ts +18 -3
  71. package/src/ascii/draw.ts +16 -2
  72. package/src/ascii/edge-bundling.ts +56 -0
  73. package/src/ascii/edge-routing.ts +87 -23
  74. package/src/ascii/er-diagram.ts +257 -27
  75. package/src/ascii/grid-occupancy.ts +1 -1
  76. package/src/ascii/grid.ts +87 -4
  77. package/src/ascii/hyperlinks.ts +248 -0
  78. package/src/ascii/index.ts +51 -3
  79. package/src/ascii/pathfinder.ts +4 -2
  80. package/src/ascii/sequence.ts +322 -29
  81. package/src/ascii/xychart.ts +36 -12
  82. package/src/class/layout.ts +114 -11
  83. package/src/class/parser.ts +215 -56
  84. package/src/class/renderer.ts +149 -29
  85. package/src/class/types.ts +42 -2
  86. package/src/cli/html-viewer-client-source.ts +13 -0
  87. package/src/cli/html-viewer-client.js +292 -0
  88. package/src/cli/html-viewer.ts +174 -0
  89. package/src/cli/parse-args.ts +283 -8
  90. package/src/cli/png.ts +38 -0
  91. package/src/cli/render.ts +227 -20
  92. package/src/cli.ts +50 -8
  93. package/src/color-utils.ts +205 -0
  94. package/src/direction-override.ts +44 -0
  95. package/src/er/renderer.ts +8 -1
  96. package/src/index.ts +90 -15
  97. package/src/layout-engine/from-elk.ts +1 -43
  98. package/src/layout-engine/to-elk.ts +33 -6
  99. package/src/parser.ts +11 -57
  100. package/src/renderer.ts +32 -35
  101. package/src/resolve-colors.ts +339 -0
  102. package/src/sequence/box-color.ts +85 -0
  103. package/src/sequence/layout.ts +170 -35
  104. package/src/sequence/parser.ts +200 -8
  105. package/src/sequence/renderer.ts +84 -2
  106. package/src/sequence/types.ts +80 -0
  107. package/src/style-directives.ts +214 -0
  108. package/src/text-metrics.ts +186 -3
  109. package/src/theme.ts +100 -53
  110. package/src/types.ts +123 -3
  111. package/src/xychart/renderer.ts +12 -3
package/README.md CHANGED
@@ -129,13 +129,30 @@ Installing the package also exposes a `zombie-mermaid` binary:
129
129
 
130
130
  ```bash
131
131
  zombie-mermaid render diagram.mmd --ascii # Print ASCII/Unicode to terminal
132
- zombie-mermaid render diagram.mmd --svg -o out.svg # Render to an SVG file
132
+ zombie-mermaid render diagram.mmd --svg # Render to diagram.svg (name from the input)
133
+ zombie-mermaid render diagram.mmd --svg -o out.svg # Render to a named SVG file
134
+ zombie-mermaid render diagram.mmd --svg -o out.svg --resolve-colors # …with concrete colors, for resvg/Inkscape/etc.
135
+ zombie-mermaid render diagram.mmd -o out.svg # Same — the format is inferred from .svg
136
+ zombie-mermaid render diagram.mmd --svg -o - | pbcopy # Write the SVG to stdout
137
+ zombie-mermaid render diagram.mmd --ascii -o out.txt # Write the ASCII rendering to a file
138
+ zombie-mermaid render diagram.mmd --html # Self-contained pan/zoom HTML viewer
139
+ zombie-mermaid render diagram.mmd --png # Rasterize to diagram.png
133
140
  cat diagram.mmd | zombie-mermaid render --ascii # Read from stdin
134
141
  zombie-mermaid themes # List built-in theme names
135
142
  zombie-mermaid --help # Show all options
136
143
  ```
137
144
 
138
- `--theme <name>` applies a built-in theme (from `themes`) to either output mode.
145
+ `--theme <name>` applies a built-in theme (from `themes`) to either output mode. `--resolve-colors` replaces the CSS `var()`/`color-mix()` theming in SVG output with computed colors so rasterizers that don't evaluate CSS (resvg, librsvg, Inkscape) render the theme instead of black — see [docs/theming.md](docs/theming.md#resolved-colors-for-rasterizers).
146
+ `--direction <dir>` (`TD`, `TB`, `BT`, `LR`, or `RL`) overrides the diagram's layout direction in either output mode without editing the source — flowchart, state, and ER diagrams; a nested subgraph's own `direction` still applies on top of it. The same override is available to library callers as the `direction` render option (see [API Reference](docs/api-reference.md)).
147
+ `--hyperlinks` (with `--ascii`) turns `click` hrefs into OSC 8 terminal
148
+ hyperlinks — off by default, since terminal and pager support varies (see
149
+ [ASCII terminal hyperlinks](docs/diagrams.md#ascii-terminal-hyperlinks)).
150
+
151
+ **Output rules.** `-o` is the destination for the run's _file_ output — SVG, HTML, or PNG when `--svg`/`--html`/`--png` is given, otherwise the ASCII rendering — and `-o -` sends it to stdout instead. A recognised extension (`.svg`, `.html`/`.htm`, `.txt`, `.png`) picks the format on its own, so the flag can be dropped; an extension that contradicts an explicit flag (`--svg -o out.txt`) is an error, while unrecognised ones are simply used as given. `--svg`/`--html`/`--png` with no `-o` writes `<input stem>.svg`/`.html`/`.png` beside the input (stdin input has no name to derive from, so it must pass `-o`). Only one of `--svg`/`--html`/`--png` can be set at a time — run the command twice for more than one. ASCII always prints to the terminal when one of them is also requested (`--ascii --svg -o out.svg`), and never carries ANSI colour codes when written to a file. **An existing output file is never overwritten unless you pass `--force`/`-f`.**
152
+
153
+ **`--html`** wraps the rendered SVG in a self-contained pan/zoom viewer — one file, no server, no network — with drag/scroll pan, ctrl/cmd+scroll and pinch to zoom, fit/1:1 buttons, a light/dark toggle that follows `prefers-color-scheme`, and keyboard controls. It opens straight from disk and survives being emailed as a single attachment. This is the one place in the project that ships client-side JavaScript, and deliberately so — see [`docs/decisions/no-script-interactivity.md`](docs/decisions/no-script-interactivity.md): the library's own SVG output stays permanently script-free, and this viewer is a separate CLI artifact wrapping that output, never part of it.
154
+
155
+ **`--png`** rasterizes the diagram for anywhere SVG isn't accepted — issue trackers, Slack, docs tools, email — at the SVG's own pixel dimensions (1:1, no scaling). It always resolves CSS colors first, automatically, the same substitution `--resolve-colors` does for `--svg` — a rasterizer can't evaluate `var()`/`color-mix()`, so skipping this would render the whole theme black. Rasterization is via [`@resvg/resvg-js`](https://github.com/thx/resvg-js), listed as an `optionalDependency`: a normal install pulls its native binary like any other dependency, but a platform it has no prebuilt binary for, or an install run with `--no-optional`, simply skips it — `--png` then fails with a clear error telling you how to install it explicitly, rather than breaking the rest of the CLI.
139
156
 
140
157
  ---
141
158