# @plantuml/core

The [PlantUML](https://plantuml.com/) diagram engine, compiled to JavaScript
with [TeaVM](https://github.com/konsoletyper/teavm). It renders UML and many
other diagrams **entirely in the browser** -- no server, no Java, no Graphviz
binary required.

This package is generated from the official PlantUML build (issue
[#2715](https://github.com/plantuml/plantuml/issues/2715)).

## Install

```sh
npm install @plantuml/core
```

Or import straight from a CDN:

```html
<script src="https://unpkg.com/@plantuml/core@1.2026.6/viz-global.js"></script>
<script type="module">
  import { render } from "https://unpkg.com/@plantuml/core@1.2026.6/plantuml.js";
  render("@startuml\nAlice -> Bob : Hello\n@enduml".split("\n"), "out");
</script>
<div id="out"></div>
```

## API

The public surface is two functions exported from the `plantuml.js`
ES2015 module. `viz-global.js` (the Graphviz layout engine) must be loaded
as a classic script beforehand.

- `render(lines, targetId)` -- render into the DOM element with that `id`.
  `lines` is an `Array<string>`.
- `render(lines, targetId, { dark: true })` -- same, in dark mode.
- `renderToString(lines, onSuccess, onError)` -- deliver the SVG as a string
  to `onSuccess(svg)`; errors go to `onError(message)`.

Rendering is asynchronous: `render()` returns immediately and writes the SVG
into the target element later. See
[GITHUB_INTEGRATION.md](./GITHUB_INTEGRATION.md) for details and a full
GitHub-style integration example.

## What's included

- `plantuml.js` -- the engine
- `viz-global.js` -- Graphviz / Viz.js layout engine (required)
- demo pages: `index.html` (playground), `index-basic.html`,
  `index-basic-dark.html`, `index-collection.html`, and two GitHub
  integration proofs of concept

Heavy optional sprite libraries (IBM, tupadr3, material, AWS...) are **not**
bundled here to keep the package small; load them from the project site if
you need them.

## License

[MIT](https://opensource.org/license/mit/).

**Versions ≥ 1.2026.6 are MIT-licensed; earlier versions are
GPL-3.0-or-later.** npm only displays the license of the latest version,
so if you are pinned to an older release, check the license of that
specific version.
