{# README template — DO NOT edit README.md directly. Rendered to ../README.md by docs/scripts/build-docs.mjs. Variables provided to the template: - pkg : package.json contents - diagrams : array of { id, title, doc, image, puml, svg, png } - moduleDocs : array of { name, body } for non-diagram doc blocks - imagesFormat : "png" or "svg" - testCount : number of test cases discovered - fileTree : ASCII file tree (string) #} # {{ pkg.name | replace("@grethel-labs/", "") }} [![npm](https://img.shields.io/npm/v/{{ pkg.name }}.svg?label=latest)](https://www.npmjs.com/package/{{ pkg.name }}) [![downloads](https://img.shields.io/npm/dm/{{ pkg.name }}.svg)](https://www.npmjs.com/package/{{ pkg.name }}) [![ci](https://github.com/grethel-labs/excaliplant/actions/workflows/ci.yml/badge.svg)](https://github.com/grethel-labs/excaliplant/actions/workflows/ci.yml) [![node](https://img.shields.io/node/v/{{ pkg.name }}.svg)](https://nodejs.org) [![license](https://img.shields.io/npm/l/{{ pkg.name }}.svg)](./LICENSE) > {{ pkg.description }}  ·  **v{{ pkg.version }}**  ·  {{ testCount }} tests  ·  {{ pkg.license }} `{{ pkg.name }}` takes PlantUML source, runs it through a plugin-based parser, lays it out with [ELK](https://github.com/kieler/elkjs), and emits a `.excalidraw` JSON document — opening cleanly in any Excalidraw front-end. Optional helpers convert the result to SVG or PNG so the same pipeline can also produce static documentation artefacts. {%- for d in diagrams -%} {%- if loop.index0 < 2 %} {%- endif -%} {%- endfor %}
{{ d.title }}
{{ d.title }} — rendered by {{ pkg.name | replace("@grethel-labs/", "") }} itself
> ⚠️ This README is generated. Edit > [`docs/README.template.md.njk`](./docs/README.template.md.njk) and > run `npm run build:docs`. > **AI-generated project notice:** This repository, including source code, > documentation, comments, and generated artefacts, was created almost entirely > with AI assistance. The maintainer does not adopt every generated sentence, > implementation detail, or artefact as a personal statement, endorsement, or > guarantee. Review everything carefully and use the code at your own risk; the > MIT License warranty disclaimer applies. --- ## How to use ### Install ```sh npm install {{ pkg.name }} ``` `@resvg/resvg-js` is pulled in as a runtime dependency so the SVG and PNG export paths work out of the box. ### Render PlantUML to an Excalidraw document ```js import { renderPlantUml } from "{{ pkg.name }}"; const excalidraw = await renderPlantUml(plantumlText, { sourceLabel: "demo" }); // → write `excalidraw` to disk as .excalidraw, or hand it to an // Excalidraw embed. ``` ### Render to SVG / PNG The result of `renderPlantUml(...)` is a thenable — you can `await` it to get the Excalidraw JSON, or chain `.toSvg()` / `.toPng()` on it to get the rasterised diagram in a single line. Both outputs keep the hand-drawn Excalidraw look (strokes are produced via `roughjs`, the same library Excalidraw uses internally). ```js import { renderPlantUml } from "{{ pkg.name }}"; const svg = await renderPlantUml(plantumlText).toSvg(); const png = await renderPlantUml(plantumlText).toPng({ width: 4800 }); ``` The lower-level helpers are still exported if you need them: ```js import { renderPlantUml, excalidrawJsonToCanvasSvg, svgToPng, } from "{{ pkg.name }}"; const doc = await renderPlantUml(plantumlText); const svg = excalidrawJsonToCanvasSvg(doc, { width: 1200 }); const png = svgToPng(svg, { width: 4800 }); // 4× SVG width ``` Lower-level entry points are also exported: | Export | Purpose | | ------------------------------- | ------------------------------------------------ | | `parsePlantUml(text)` | PlantUML → `Diagram` model | | `layoutDiagram(diagram)` | Sizing + ELK layout + edge routing | | `exportDiagram(diagram)` | Diagram → Excalidraw JSON | | `excalidrawToSvg(doc)` | Excalidraw JSON → tightly-cropped SVG | | `excalidrawJsonToCanvasSvg(…)` | …same, letter-boxed onto a fixed-aspect canvas | | `svgToPng(svg)` | Rasterise SVG to PNG (`@resvg/resvg-js`) | The complete list of exported symbols, with parameter tables and return types, lives in [`docs/API.md`](./docs/API.md). It is regenerated from JSDoc on every `npm run build:docs` run. ### Sequence diagram coverage Sequence diagrams support participants (`participant`, `actor`, `boundary`, `control`, `entity`, `database`, `collections`, `queue`), quoted aliases in both `Name as Alias` and `Alias as "Name"` forms, message arrows including async/reply/reverse/bidirectional variants, notes, participant `box ... end box` groups, `ref over` references, dividers (`== label ==`), delays (`... label ...`), spacers (`|||` / `||45||`), `autonumber` start/stop/resume, lifecycle controls (`create`, `activate`, `deactivate`, `destroy`) and inline message lifecycle suffixes (`++`, `--`, `**`, `!!`). Combined fragments render for `opt`, `loop`, `alt`/`else`, `par`/`and`, `break`, `critical`/`option`, and `group`/`option` blocks. A small sequence `skinparam` subset maps directly to output colours in block or compact form: `ArrowColor`, `ParticipantBackgroundColor`, `ParticipantBorderColor`, and `LifeLineBorderColor`; supported CSS-like `