zombie-mermaid 1.7.0 → 2.0.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 (109) hide show
  1. package/README.md +16 -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 +2210 -1482
  7. package/dist/ascii.js.map +1 -1
  8. package/dist/cli.js +5590 -3887
  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 +3490 -2378
  14. package/dist/index.js.map +1 -1
  15. package/dist/mcp.cjs +2581 -432
  16. package/dist/mcp.cjs.map +1 -1
  17. package/dist/mcp.js +2581 -432
  18. package/dist/mcp.js.map +1 -1
  19. package/package.json +9 -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-render.test.ts +464 -3
  47. package/src/__tests__/cli-test-helpers.ts +5 -0
  48. package/src/__tests__/cli.test.ts +464 -4
  49. package/src/__tests__/color-utils.test.ts +186 -0
  50. package/src/__tests__/direction-override.test.ts +397 -0
  51. package/src/__tests__/interactivity-config.test.ts +34 -9
  52. package/src/__tests__/monospace-metrics.test.ts +74 -0
  53. package/src/__tests__/resolve-colors.test.ts +446 -0
  54. package/src/__tests__/sequence-integration.test.ts +94 -0
  55. package/src/__tests__/sequence-layout.test.ts +220 -0
  56. package/src/__tests__/sequence-parser.test.ts +287 -0
  57. package/src/__tests__/svg-csp-style-options.test.ts +427 -0
  58. package/src/__tests__/testdata/ascii/cls_all_relationships.txt +11 -9
  59. package/src/__tests__/testdata/ascii/subgraph_direction_override.txt +27 -17
  60. package/src/__tests__/testdata/unicode/cls_all_relationships.txt +11 -9
  61. package/src/__tests__/text-metrics.test.ts +211 -57
  62. package/src/__tests__/xychart-ascii.test.ts +49 -0
  63. package/src/ascii/ansi.ts +24 -37
  64. package/src/ascii/canvas.ts +31 -6
  65. package/src/ascii/class-diagram.ts +914 -84
  66. package/src/ascii/converter.ts +37 -4
  67. package/src/ascii/coords.ts +7 -3
  68. package/src/ascii/draw-boxes.ts +5 -5
  69. package/src/ascii/draw-subgraphs.ts +18 -3
  70. package/src/ascii/draw.ts +16 -2
  71. package/src/ascii/edge-bundling.ts +56 -0
  72. package/src/ascii/edge-routing.ts +87 -23
  73. package/src/ascii/er-diagram.ts +257 -27
  74. package/src/ascii/grid-occupancy.ts +1 -1
  75. package/src/ascii/grid.ts +87 -4
  76. package/src/ascii/hyperlinks.ts +248 -0
  77. package/src/ascii/index.ts +51 -3
  78. package/src/ascii/pathfinder.ts +4 -2
  79. package/src/ascii/sequence.ts +322 -29
  80. package/src/ascii/xychart.ts +36 -12
  81. package/src/class/layout.ts +114 -11
  82. package/src/class/parser.ts +215 -56
  83. package/src/class/renderer.ts +149 -29
  84. package/src/class/types.ts +42 -2
  85. package/src/cli/html-viewer-client-source.ts +13 -0
  86. package/src/cli/html-viewer-client.js +292 -0
  87. package/src/cli/html-viewer.ts +174 -0
  88. package/src/cli/parse-args.ts +220 -8
  89. package/src/cli/render.ts +203 -19
  90. package/src/cli.ts +40 -8
  91. package/src/color-utils.ts +205 -0
  92. package/src/direction-override.ts +44 -0
  93. package/src/er/renderer.ts +8 -1
  94. package/src/index.ts +90 -15
  95. package/src/layout-engine/from-elk.ts +1 -43
  96. package/src/layout-engine/to-elk.ts +33 -6
  97. package/src/parser.ts +11 -57
  98. package/src/renderer.ts +32 -35
  99. package/src/resolve-colors.ts +339 -0
  100. package/src/sequence/box-color.ts +85 -0
  101. package/src/sequence/layout.ts +170 -35
  102. package/src/sequence/parser.ts +200 -8
  103. package/src/sequence/renderer.ts +84 -2
  104. package/src/sequence/types.ts +80 -0
  105. package/src/style-directives.ts +214 -0
  106. package/src/text-metrics.ts +186 -3
  107. package/src/theme.ts +100 -53
  108. package/src/types.ts +123 -3
  109. package/src/xychart/renderer.ts +12 -3
package/README.md CHANGED
@@ -129,13 +129,27 @@ 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
133
139
  cat diagram.mmd | zombie-mermaid render --ascii # Read from stdin
134
140
  zombie-mermaid themes # List built-in theme names
135
141
  zombie-mermaid --help # Show all options
136
142
  ```
137
143
 
138
- `--theme <name>` applies a built-in theme (from `themes`) to either output mode.
144
+ `--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).
145
+ `--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)).
146
+ `--hyperlinks` (with `--ascii`) turns `click` hrefs into OSC 8 terminal
147
+ hyperlinks — off by default, since terminal and pager support varies (see
148
+ [ASCII terminal hyperlinks](docs/diagrams.md#ascii-terminal-hyperlinks)).
149
+
150
+ **Output rules.** `-o` is the destination for the run's _file_ output — SVG or HTML when `--svg`/`--html` is given, otherwise the ASCII rendering — and `-o -` sends it to stdout instead. A recognised extension (`.svg`, `.html`/`.htm`, `.txt`) 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` with no `-o` writes `<input stem>.svg`/`.html` beside the input (stdin input has no name to derive from, so it must pass `-o`). `--svg` and `--html` cannot both be set — run the command twice for both. ASCII always prints to the terminal when SVG/HTML 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`.**
151
+
152
+ **`--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.
139
153
 
140
154
  ---
141
155