@danielsimonjr/sciengjs 0.1.1 → 0.2.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 +18 -3
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/assets/licenses/MIT-viz-js.txt +21 -0
- package/dist/graph/backend-png.d.ts +5 -0
- package/dist/graph/backend-png.js +20 -2
- package/dist/graph/backend-png.js.map +1 -1
- package/dist/mermaid/backend-png.d.ts +6 -0
- package/dist/mermaid/backend-png.js +13 -0
- package/dist/mermaid/backend-png.js.map +1 -0
- package/dist/mermaid/backend-svg.d.ts +3 -0
- package/dist/mermaid/backend-svg.js +8 -0
- package/dist/mermaid/backend-svg.js.map +1 -0
- package/dist/mermaid/class.d.ts +37 -0
- package/dist/mermaid/class.js +190 -0
- package/dist/mermaid/class.js.map +1 -0
- package/dist/mermaid/common.d.ts +43 -0
- package/dist/mermaid/common.js +112 -0
- package/dist/mermaid/common.js.map +1 -0
- package/dist/mermaid/index.d.ts +10 -0
- package/dist/mermaid/index.js +11 -0
- package/dist/mermaid/index.js.map +1 -0
- package/dist/mermaid/render.d.ts +10 -0
- package/dist/mermaid/render.js +24 -0
- package/dist/mermaid/render.js.map +1 -0
- package/dist/mermaid/sequence-layout.d.ts +6 -0
- package/dist/mermaid/sequence-layout.js +268 -0
- package/dist/mermaid/sequence-layout.js.map +1 -0
- package/dist/mermaid/sequence.d.ts +62 -0
- package/dist/mermaid/sequence.js +199 -0
- package/dist/mermaid/sequence.js.map +1 -0
- package/dist/mermaid/state.d.ts +24 -0
- package/dist/mermaid/state.js +132 -0
- package/dist/mermaid/state.js.map +1 -0
- package/dist/pairs.js +2 -2
- package/dist/pairs.js.map +1 -1
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -10,14 +10,16 @@ sciengjs turns diagram source into images on your own machine. It sends no sourc
|
|
|
10
10
|
|
|
11
11
|
## What this release does
|
|
12
12
|
|
|
13
|
-
Release 0.
|
|
13
|
+
Release 0.2.0 holds two input types: **Graphviz DOT** and **Mermaid** (class, state and sequence diagrams).
|
|
14
14
|
|
|
15
15
|
| Input | Output | Engine |
|
|
16
16
|
|---|---|---|
|
|
17
17
|
| DOT | SVG | Graphviz 16.1.0, compiled to WASM (`@viz-js/viz`) |
|
|
18
18
|
| DOT | PNG | Graphviz, then resvg compiled to WASM (`@resvg/resvg-wasm`), with a bundled font |
|
|
19
|
+
| Mermaid (class, state, sequence) | SVG | The engine's own parsers and layouts. Class and state diagrams go through Graphviz. |
|
|
20
|
+
| Mermaid (class, state, sequence) | PNG | The same SVG, then resvg compiled to WASM (`@resvg/resvg-wasm`), with a bundled font |
|
|
19
21
|
|
|
20
|
-
- **No network.** The DOT
|
|
22
|
+
- **No network.** The DOT and Mermaid paths make no network request.
|
|
21
23
|
- **Unsafe attributes are removed.** The engine removes each `image` and `stylesheet` attribute before the layout and gives a warning for each one. A DOT file cannot make the engine or a browser fetch a file or a URL. A `URL` attribute stays as a link in the SVG.
|
|
22
24
|
- **The same text on every machine.** PNG text uses the bundled Liberation Serif font, not the fonts of the host. The engine gives a warning when the drawing asks for bold, italic or a character that the font does not have.
|
|
23
25
|
- **Limits.** Each render has a time limit, a source size limit and a heap limit. A PNG has a pixel limit of 1024 MB.
|
|
@@ -137,6 +139,19 @@ const png = await svgToPng(svg, { scale: 1, maxMemoryMb: 512 });
|
|
|
137
139
|
|
|
138
140
|
A subpath call runs in the calling thread, without the worker and its limits. Use `render` for input that you do not trust.
|
|
139
141
|
|
|
142
|
+
## Mermaid
|
|
143
|
+
|
|
144
|
+
The `mermaid` input draws class, state and sequence diagrams without a browser. A line outside the grammar rejects the render with `E_INPUT`, and the message names the line. Set `lenient` to `true` to skip such a line and get a warning instead.
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
import { render } from "@danielsimonjr/sciengjs";
|
|
148
|
+
|
|
149
|
+
const source = "sequenceDiagram\nAlice->>Bob: Hello Bob\nBob-->>Alice: Hi Alice";
|
|
150
|
+
const { bytes, warnings } = await render({ type: "mermaid", source, format: "svg" }, {});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Other Mermaid diagram types reject with `E_UNSUPPORTED`.
|
|
154
|
+
|
|
140
155
|
## Roadmap
|
|
141
156
|
|
|
142
157
|
The [build plan](docs/superpowers/plans/2026-11-01-scieng-engine-build.md) gives the order of the increments. Each increment adds one input type, its tests and one release. The [design](docs/superpowers/specs/2026-11-01-scieng-engine-design.md) gives the API, the stages, the security controls and the licence of each engine.
|
|
@@ -144,7 +159,7 @@ The [build plan](docs/superpowers/plans/2026-11-01-scieng-engine-build.md) gives
|
|
|
144
159
|
| Input type | Stage | Status |
|
|
145
160
|
|---|---|---|
|
|
146
161
|
| DOT | graph, raster | released in 0.1.0 |
|
|
147
|
-
| Mermaid | mermaid, browser | planned |
|
|
162
|
+
| Mermaid | graph, mermaid, browser | class, state and sequence: released in 0.2.0; other types: planned |
|
|
148
163
|
| LaTeX math | math (MathJax) | planned |
|
|
149
164
|
| TikZ, circuitikz, LaTeX | tex (an own WASM build of `tex.web`) | trial builds pass |
|
|
150
165
|
| Plots | plot | planned |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -26,7 +26,7 @@ Version: each row gives the version that the engine pins.
|
|
|
26
26
|
|
|
27
27
|
### Graphviz (EPL-2.0)
|
|
28
28
|
|
|
29
|
-
The Eclipse Public License 2.0 applies to Graphviz. The wrapper `@viz-js/viz
|
|
29
|
+
The Eclipse Public License 2.0 applies to Graphviz. The MIT licence applies to the wrapper `@viz-js/viz`. The package does not ship a Graphviz licence file. The licence text of Graphviz is in `assets/licenses/EPL-2.0.txt`. The MIT licence text of the wrapper is in `assets/licenses/MIT-viz-js.txt`, copied from the tag `release-viz-3.31.0` of the source repository https://github.com/mdaines/viz-js. The npm package does not ship this file.
|
|
30
30
|
|
|
31
31
|
### OpenCascade (LGPL-2.1)
|
|
32
32
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Michael Daines
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -3,3 +3,8 @@ import type { BackendOutput, WorkerJob } from "../worker/protocol.ts";
|
|
|
3
3
|
export declare function render(request: WorkerJob["request"]): Promise<BackendOutput>;
|
|
4
4
|
/** Renders dot to png with the bundled font at the given path. The path is a parameter so that a test can name a missing or invalid bundled font. */
|
|
5
5
|
export declare function renderPng(request: WorkerJob["request"], bundledFontPath: string): Promise<BackendOutput>;
|
|
6
|
+
/**
|
|
7
|
+
* Rasterizes one SVG document to PNG at scale 1. The font follows render: the rasterFont setting when set,
|
|
8
|
+
* else the bundled font in the assets folder. The Mermaid PNG backend uses this function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function svgDocumentToPng(svg: string, request: WorkerJob["request"]): Promise<BackendOutput>;
|
|
@@ -21,6 +21,11 @@ function readFont(path, bundled) {
|
|
|
21
21
|
}
|
|
22
22
|
return bytes;
|
|
23
23
|
}
|
|
24
|
+
/** Reads the font of a render: the rasterFont setting when set, else the bundled font at the given path. */
|
|
25
|
+
function fontOf(settings, bundledFontPath) {
|
|
26
|
+
const rasterFont = settings.rasterFont;
|
|
27
|
+
return readFont(rasterFont ?? bundledFontPath, rasterFont === undefined);
|
|
28
|
+
}
|
|
24
29
|
/** Renders dot to png: the SVG of the graph, then the PNG of that SVG at the option scale. The bundled font comes from the assets folder named in the settings. */
|
|
25
30
|
export async function render(request) {
|
|
26
31
|
return renderPng(request, bundledFontPathIn(request.settings.assetsUrl));
|
|
@@ -43,8 +48,7 @@ export async function renderPng(request, bundledFontPath) {
|
|
|
43
48
|
throw new RenderError("E_INPUT", "option scale must be a finite number greater than 0");
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
const
|
|
47
|
-
const font = readFont(rasterFont ?? bundledFontPath, rasterFont === undefined);
|
|
51
|
+
const font = fontOf(request.settings, bundledFontPath);
|
|
48
52
|
const dot = await dotToSvg(dotSourceText(request.source));
|
|
49
53
|
const bytes = await svgToPng(dot.svg, {
|
|
50
54
|
scale,
|
|
@@ -54,4 +58,18 @@ export async function renderPng(request, bundledFontPath) {
|
|
|
54
58
|
});
|
|
55
59
|
return { bytes, warnings: [...dot.warnings, ...rasterWarnings(dot.svg, font)] };
|
|
56
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Rasterizes one SVG document to PNG at scale 1. The font follows render: the rasterFont setting when set,
|
|
63
|
+
* else the bundled font in the assets folder. The Mermaid PNG backend uses this function.
|
|
64
|
+
*/
|
|
65
|
+
export async function svgDocumentToPng(svg, request) {
|
|
66
|
+
const font = fontOf(request.settings, bundledFontPathIn(request.settings.assetsUrl));
|
|
67
|
+
const bytes = await svgToPng(svg, {
|
|
68
|
+
scale: 1,
|
|
69
|
+
maxMemoryMb: request.settings.maxMemoryMb,
|
|
70
|
+
font,
|
|
71
|
+
assetsUrl: request.settings.assetsUrl,
|
|
72
|
+
});
|
|
73
|
+
return { bytes, warnings: rasterWarnings(svg, font) };
|
|
74
|
+
}
|
|
57
75
|
//# sourceMappingURL=backend-png.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-png.js","sourceRoot":"","sources":["../../src/graph/backend-png.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,SAAS,QAAQ,CAAC,IAAY,EAAE,OAAgB;IAC9C,IAAI,KAAa,CAAC;IAClB,IAAI,CAAC;QACH,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,OAAO;YACX,CAAC,CAAC,IAAI,WAAW,CAAC,iBAAiB,EAAE,sCAAsC,GAAG,IAAI,CAAC;YACnF,CAAC,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,6BAA6B,GAAG,IAAI,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,OAAO;YACX,CAAC,CAAC,IAAI,WAAW,CAAC,iBAAiB,EAAE,yCAAyC,GAAG,IAAI,CAAC;YACtF,CAAC,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F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,OAA6B;IAC/E,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE;QAChC,KAAK,EAAE,CAAC;QACR,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW;QACzC,IAAI;QACJ,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS;KACtC,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BackendOutput, WorkerJob } from "../worker/protocol.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Renders one Mermaid source to PNG: the SVG of the diagram, then the PNG of that SVG.
|
|
4
|
+
* The worker calls this function for the mermaid:png pair.
|
|
5
|
+
*/
|
|
6
|
+
export declare function render(request: WorkerJob["request"]): Promise<BackendOutput>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { svgDocumentToPng } from "../graph/backend-png.js";
|
|
2
|
+
import { sourceText } from "./common.js";
|
|
3
|
+
import { renderMermaidSvg } from "./render.js";
|
|
4
|
+
/**
|
|
5
|
+
* Renders one Mermaid source to PNG: the SVG of the diagram, then the PNG of that SVG.
|
|
6
|
+
* The worker calls this function for the mermaid:png pair.
|
|
7
|
+
*/
|
|
8
|
+
export async function render(request) {
|
|
9
|
+
const svg = await renderMermaidSvg(sourceText(request.source), request.options);
|
|
10
|
+
const png = await svgDocumentToPng(svg.svg, request);
|
|
11
|
+
return { bytes: png.bytes, warnings: [...svg.warnings, ...(png.warnings ?? [])] };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=backend-png.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-png.js","sourceRoot":"","sources":["../../src/mermaid/backend-png.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6B;IACxD,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { sourceText } from "./common.js";
|
|
2
|
+
import { renderMermaidSvg } from "./render.js";
|
|
3
|
+
/** Renders one Mermaid source to SVG. The worker calls this function for the mermaid:svg pair. */
|
|
4
|
+
export async function render(request) {
|
|
5
|
+
const result = await renderMermaidSvg(sourceText(request.source), request.options);
|
|
6
|
+
return { bytes: new TextEncoder().encode(result.svg), warnings: result.warnings };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=backend-svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-svg.js","sourceRoot":"","sources":["../../src/mermaid/backend-svg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6B;IACxD,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnF,OAAO,EAAE,KAAK,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Source } from "./common.ts";
|
|
2
|
+
/** The shape at one end of a class relation: none, an open arrow, a triangle, or a diamond that is filled or open. */
|
|
3
|
+
export type Marker = "none" | "arrow" | "triangle" | "diamond" | "filled-diamond";
|
|
4
|
+
/** The line style of a class relation and the marker at each end. The tail is the end at the first class. */
|
|
5
|
+
export interface ClassArrow {
|
|
6
|
+
dashed: boolean;
|
|
7
|
+
tail: Marker;
|
|
8
|
+
head: Marker;
|
|
9
|
+
}
|
|
10
|
+
/** One class of the diagram: its name, its generic parameter, its members and the line that declares it. */
|
|
11
|
+
export interface ClassDef {
|
|
12
|
+
name: string;
|
|
13
|
+
generic: string | undefined;
|
|
14
|
+
members: string[];
|
|
15
|
+
line: number;
|
|
16
|
+
}
|
|
17
|
+
/** One relation between two classes. It holds the arrow, the cardinality at each end, the label and the source line. */
|
|
18
|
+
export interface ClassRelation {
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
token: string;
|
|
22
|
+
arrow: ClassArrow;
|
|
23
|
+
fromCardinality: string | undefined;
|
|
24
|
+
toCardinality: string | undefined;
|
|
25
|
+
label: string | undefined;
|
|
26
|
+
line: number;
|
|
27
|
+
}
|
|
28
|
+
/** A parsed class diagram: its direction, its classes and its relations. */
|
|
29
|
+
export interface ClassModel {
|
|
30
|
+
direction: "TB" | "BT" | "LR" | "RL";
|
|
31
|
+
classes: ClassDef[];
|
|
32
|
+
relations: ClassRelation[];
|
|
33
|
+
}
|
|
34
|
+
/** Parses the content lines of a class diagram. A line outside the grammar rejects with E_INPUT. In lenient mode the line is skipped and a warning names it. */
|
|
35
|
+
export declare function parseClassDiagram(src: Source): ClassModel;
|
|
36
|
+
/** Builds the DOT source of a parsed class diagram. Each class is a record node. */
|
|
37
|
+
export declare function classToDot(model: ClassModel): string;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { inputError, outside, xmlSafe } from "./common.js";
|
|
2
|
+
const ARROW_SPECS = [
|
|
3
|
+
["<|--", { dashed: false, tail: "triangle", head: "none" }],
|
|
4
|
+
["*--", { dashed: false, tail: "filled-diamond", head: "none" }],
|
|
5
|
+
["o--", { dashed: false, tail: "diamond", head: "none" }],
|
|
6
|
+
["<--", { dashed: false, tail: "arrow", head: "none" }],
|
|
7
|
+
["<|..", { dashed: true, tail: "triangle", head: "none" }],
|
|
8
|
+
["<..", { dashed: true, tail: "arrow", head: "none" }],
|
|
9
|
+
["--|>", { dashed: false, tail: "none", head: "triangle" }],
|
|
10
|
+
["--*", { dashed: false, tail: "none", head: "filled-diamond" }],
|
|
11
|
+
["--o", { dashed: false, tail: "none", head: "diamond" }],
|
|
12
|
+
["-->", { dashed: false, tail: "none", head: "arrow" }],
|
|
13
|
+
["..|>", { dashed: true, tail: "none", head: "triangle" }],
|
|
14
|
+
["..>", { dashed: true, tail: "none", head: "arrow" }],
|
|
15
|
+
["--", { dashed: false, tail: "none", head: "none" }],
|
|
16
|
+
["..", { dashed: true, tail: "none", head: "none" }],
|
|
17
|
+
];
|
|
18
|
+
const ARROW_TABLE = new Map(ARROW_SPECS);
|
|
19
|
+
const ARROW_PATTERN = [...ARROW_SPECS]
|
|
20
|
+
.sort((left, right) => right[0].length - left[0].length)
|
|
21
|
+
.map(([token]) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
22
|
+
.join("|");
|
|
23
|
+
const IDENT_SOURCE = "[A-Za-z_][A-Za-z0-9_]*";
|
|
24
|
+
const RELATION_PATTERN = new RegExp(`^(${IDENT_SOURCE}) +(?:"([^"]*)" )?(${ARROW_PATTERN}) +(?:"([^"]*)" )?(${IDENT_SOURCE})(?: *: *(.+))?$`);
|
|
25
|
+
const MEMBER_PATTERN = /^([A-Za-z_][A-Za-z0-9_]*) *:(.*)$/;
|
|
26
|
+
const CLASS_PATTERN = /^class ([A-Za-z_][A-Za-z0-9_]*)(?:~([A-Za-z0-9_ ,]+)~)?( *\{)?$/;
|
|
27
|
+
const DIRECTION_PATTERN = /^direction (TB|BT|LR|RL)$/;
|
|
28
|
+
/** Parses the content lines of a class diagram. A line outside the grammar rejects with E_INPUT. In lenient mode the line is skipped and a warning names it. */
|
|
29
|
+
export function parseClassDiagram(src) {
|
|
30
|
+
let direction = "TB";
|
|
31
|
+
let sawDirection = false;
|
|
32
|
+
const classes = [];
|
|
33
|
+
const relations = [];
|
|
34
|
+
const byName = new Map();
|
|
35
|
+
let open;
|
|
36
|
+
const ensureClass = (name, line) => {
|
|
37
|
+
const existing = byName.get(name);
|
|
38
|
+
if (existing !== undefined) {
|
|
39
|
+
return existing;
|
|
40
|
+
}
|
|
41
|
+
const created = { name, generic: undefined, members: [], line };
|
|
42
|
+
byName.set(name, created);
|
|
43
|
+
classes.push(created);
|
|
44
|
+
return created;
|
|
45
|
+
};
|
|
46
|
+
const lines = src.lines;
|
|
47
|
+
for (const line of lines) {
|
|
48
|
+
const text = line.text;
|
|
49
|
+
if (open !== undefined) {
|
|
50
|
+
if (text === "}") {
|
|
51
|
+
open = undefined;
|
|
52
|
+
}
|
|
53
|
+
else if (text.includes("{") || text.includes("}")) {
|
|
54
|
+
outside(src, line.number, text, "a brace inside a class body is outside the supported grammar");
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
byName.get(open.name).members.push(text.trim());
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const relation = RELATION_PATTERN.exec(text);
|
|
62
|
+
if (relation !== null) {
|
|
63
|
+
const from = relation[1];
|
|
64
|
+
const to = relation[5];
|
|
65
|
+
const token = relation[3];
|
|
66
|
+
const arrow = ARROW_TABLE.get(token);
|
|
67
|
+
const rawLabel = relation[6];
|
|
68
|
+
relations.push({
|
|
69
|
+
from,
|
|
70
|
+
to,
|
|
71
|
+
token,
|
|
72
|
+
arrow: { dashed: arrow.dashed, tail: arrow.tail, head: arrow.head },
|
|
73
|
+
fromCardinality: relation[2],
|
|
74
|
+
toCardinality: relation[4],
|
|
75
|
+
label: rawLabel === undefined ? undefined : rawLabel.trim(),
|
|
76
|
+
line: line.number,
|
|
77
|
+
});
|
|
78
|
+
ensureClass(from, line.number);
|
|
79
|
+
ensureClass(to, line.number);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const member = MEMBER_PATTERN.exec(text);
|
|
83
|
+
if (member !== null) {
|
|
84
|
+
const memberText = member[2].trim();
|
|
85
|
+
if (memberText !== "") {
|
|
86
|
+
ensureClass(member[1], line.number).members.push(memberText);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const declaration = CLASS_PATTERN.exec(text);
|
|
91
|
+
if (declaration !== null) {
|
|
92
|
+
const name = declaration[1];
|
|
93
|
+
const generic = declaration[2];
|
|
94
|
+
const existing = byName.get(name);
|
|
95
|
+
if (existing === undefined) {
|
|
96
|
+
const created = { name, generic, members: [], line: line.number };
|
|
97
|
+
byName.set(name, created);
|
|
98
|
+
classes.push(created);
|
|
99
|
+
}
|
|
100
|
+
else if (generic !== undefined) {
|
|
101
|
+
existing.generic = generic;
|
|
102
|
+
}
|
|
103
|
+
if (declaration[3] !== undefined) {
|
|
104
|
+
open = { name, line: line.number };
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const directionLine = DIRECTION_PATTERN.exec(text);
|
|
109
|
+
if (directionLine !== null) {
|
|
110
|
+
if (sawDirection) {
|
|
111
|
+
outside(src, line.number, text, "a second direction line is outside the supported grammar");
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const value = directionLine[1];
|
|
115
|
+
if (value === "TB" || value === "BT" || value === "LR" || value === "RL") {
|
|
116
|
+
direction = value;
|
|
117
|
+
sawDirection = true;
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
outside(src, line.number, text, "a construct is outside the supported grammar");
|
|
122
|
+
}
|
|
123
|
+
if (open !== undefined) {
|
|
124
|
+
if (src.lenient) {
|
|
125
|
+
src.warnings.push(`line ${open.line}: the body of class ${open.name} is not closed by a line with }; its members run to the end of the source`);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw inputError(open.line, `the body of class ${open.name} is not closed by a line with }`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (classes.length === 0 && relations.length === 0) {
|
|
132
|
+
throw inputError(src.headerLine, "the diagram holds no class or relation");
|
|
133
|
+
}
|
|
134
|
+
return { direction, classes, relations };
|
|
135
|
+
}
|
|
136
|
+
const DOT_MARKERS = {
|
|
137
|
+
none: "none",
|
|
138
|
+
arrow: "normal",
|
|
139
|
+
triangle: "empty",
|
|
140
|
+
diamond: "odiamond",
|
|
141
|
+
"filled-diamond": "diamond",
|
|
142
|
+
};
|
|
143
|
+
function escapeDot(text) {
|
|
144
|
+
return xmlSafe(text).replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
145
|
+
}
|
|
146
|
+
function escapeRecord(text) {
|
|
147
|
+
return xmlSafe(text).replace(/\\/g, "\\\\").replace(/[{}|<>"]/g, "\\$&");
|
|
148
|
+
}
|
|
149
|
+
function memberDisplay(text) {
|
|
150
|
+
return escapeRecord(text.replace(/~([^~]*)~/g, "<$1>"));
|
|
151
|
+
}
|
|
152
|
+
/** Builds the DOT source of a parsed class diagram. Each class is a record node. */
|
|
153
|
+
export function classToDot(model) {
|
|
154
|
+
const out = [];
|
|
155
|
+
out.push("digraph classDiagram {");
|
|
156
|
+
out.push(` rankdir=${model.direction};`);
|
|
157
|
+
out.push(" node [shape=record];");
|
|
158
|
+
for (const cls of model.classes) {
|
|
159
|
+
const display = cls.generic === undefined ? cls.name : `${cls.name}<${cls.generic}>`;
|
|
160
|
+
const label = cls.members.length === 0
|
|
161
|
+
? escapeRecord(display)
|
|
162
|
+
: `${escapeRecord(display)}|${cls.members.map((member) => `${memberDisplay(member)}\\l`).join("")}`;
|
|
163
|
+
out.push(` "${escapeDot(cls.name)}" [label="{${label}}"];`);
|
|
164
|
+
}
|
|
165
|
+
for (const rel of model.relations) {
|
|
166
|
+
const attrs = [];
|
|
167
|
+
if (rel.arrow.dashed) {
|
|
168
|
+
attrs.push("style=dashed");
|
|
169
|
+
}
|
|
170
|
+
if (rel.arrow.tail === "none" && rel.arrow.head === "none") {
|
|
171
|
+
attrs.push("dir=none");
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
attrs.push("dir=both", `arrowtail=${DOT_MARKERS[rel.arrow.tail]}`, `arrowhead=${DOT_MARKERS[rel.arrow.head]}`);
|
|
175
|
+
}
|
|
176
|
+
if (rel.fromCardinality !== undefined) {
|
|
177
|
+
attrs.push(`taillabel="${escapeDot(rel.fromCardinality)}"`);
|
|
178
|
+
}
|
|
179
|
+
if (rel.toCardinality !== undefined) {
|
|
180
|
+
attrs.push(`headlabel="${escapeDot(rel.toCardinality)}"`);
|
|
181
|
+
}
|
|
182
|
+
if (rel.label !== undefined) {
|
|
183
|
+
attrs.push(`label="${escapeDot(rel.label)}"`);
|
|
184
|
+
}
|
|
185
|
+
out.push(` "${escapeDot(rel.from)}" -> "${escapeDot(rel.to)}" [${attrs.join(", ")}];`);
|
|
186
|
+
}
|
|
187
|
+
out.push("}");
|
|
188
|
+
return out.join("\n") + "\n";
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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C,GAAG,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RenderError } from "../errors.ts";
|
|
2
|
+
/** The three Mermaid diagram kinds that the native layouts draw. */
|
|
3
|
+
export type DiagramKind = "class" | "state" | "sequence";
|
|
4
|
+
/** One content line of a source: its one-based number and its trimmed text. */
|
|
5
|
+
export interface ContentLine {
|
|
6
|
+
readonly number: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
/** The lenient flag and the warnings that a parse shares. A skipped construct adds a warning. */
|
|
10
|
+
export interface Context {
|
|
11
|
+
readonly lenient: boolean;
|
|
12
|
+
readonly warnings: string[];
|
|
13
|
+
}
|
|
14
|
+
/** A source after the header. Comments, blank lines and skipped constructs are absent from `lines`. */
|
|
15
|
+
export interface Source extends Context {
|
|
16
|
+
readonly kind: DiagramKind;
|
|
17
|
+
readonly headerLine: number;
|
|
18
|
+
readonly lines: ContentLine[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads the option `lenient` and checks the other keys. A key outside `lenient` and `extra` rejects with E_INPUT.
|
|
22
|
+
* An undefined value counts as an absent key.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readLenient(options: Record<string, unknown>, extra: readonly string[]): boolean;
|
|
25
|
+
/** The text of a request. The source is text for every Mermaid request, and a byte source is read as UTF-8. */
|
|
26
|
+
export declare function sourceText(source: string | Uint8Array): string;
|
|
27
|
+
/**
|
|
28
|
+
* Replaces each code point that XML 1.0 forbids with U+FFFD.
|
|
29
|
+
* Valid text, including surrogate pairs, stays unchanged.
|
|
30
|
+
*/
|
|
31
|
+
export declare function xmlSafe(text: string): string;
|
|
32
|
+
/** An input error that names its source line. */
|
|
33
|
+
export declare function inputError(line: number, message: string): RenderError;
|
|
34
|
+
/**
|
|
35
|
+
* Handles a construct that the grammar does not accept. Without lenient it rejects with E_INPUT on its line.
|
|
36
|
+
* With lenient it records a warning on its line and returns, so that the caller can skip the construct.
|
|
37
|
+
*/
|
|
38
|
+
export declare function outside(ctx: Context, line: number, text: string, why: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Prepares a source. It reads the options, removes blank lines, comment lines, directives and front matter,
|
|
41
|
+
* and reads the header. A whole Mermaid type that the native layouts do not draw rejects with E_UNSUPPORTED.
|
|
42
|
+
*/
|
|
43
|
+
export declare function prepare(source: string, options: Record<string, unknown>, extra?: readonly string[]): Source;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { RenderError } from "../errors.js";
|
|
2
|
+
const HEADERS = new Map([
|
|
3
|
+
["classDiagram", "class"],
|
|
4
|
+
["classDiagram-v2", "class"],
|
|
5
|
+
["stateDiagram-v2", "state"],
|
|
6
|
+
["sequenceDiagram", "sequence"],
|
|
7
|
+
]);
|
|
8
|
+
/** Mermaid types that the native layouts do not draw. They need the browser stage, which this release does not build. */
|
|
9
|
+
const OTHER_TYPES = new Set([
|
|
10
|
+
"flowchart", "graph", "stateDiagram", "erDiagram", "gantt", "pie", "journey", "gitGraph", "mindmap",
|
|
11
|
+
"timeline", "quadrantChart", "requirementDiagram", "C4Context", "C4Container", "C4Component",
|
|
12
|
+
"C4Dynamic", "C4Deployment", "sankey-beta", "xychart-beta", "block-beta", "packet-beta", "kanban",
|
|
13
|
+
"architecture-beta", "zenuml",
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* Reads the option `lenient` and checks the other keys. A key outside `lenient` and `extra` rejects with E_INPUT.
|
|
17
|
+
* An undefined value counts as an absent key.
|
|
18
|
+
*/
|
|
19
|
+
export function readLenient(options, extra) {
|
|
20
|
+
let lenient = false;
|
|
21
|
+
for (const [key, value] of Object.entries(options)) {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
continue;
|
|
24
|
+
if (key === "lenient") {
|
|
25
|
+
if (typeof value !== "boolean") {
|
|
26
|
+
throw new RenderError("E_INPUT", "option lenient must be true or false");
|
|
27
|
+
}
|
|
28
|
+
lenient = value;
|
|
29
|
+
}
|
|
30
|
+
else if (!extra.includes(key)) {
|
|
31
|
+
throw new RenderError("E_INPUT", `mermaid takes no option ${key}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lenient;
|
|
35
|
+
}
|
|
36
|
+
/** The text of a request. The source is text for every Mermaid request, and a byte source is read as UTF-8. */
|
|
37
|
+
export function sourceText(source) {
|
|
38
|
+
return typeof source === "string" ? source : new TextDecoder().decode(source);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Replaces each code point that XML 1.0 forbids with U+FFFD.
|
|
42
|
+
* Valid text, including surrogate pairs, stays unchanged.
|
|
43
|
+
*/
|
|
44
|
+
export function xmlSafe(text) {
|
|
45
|
+
return text.replace(/[^\u{9}\u{A}\u{D}\u{20}-\u{D7FF}\u{E000}-\u{FFFD}\u{10000}-\u{10FFFF}]/gu, "\u{FFFD}");
|
|
46
|
+
}
|
|
47
|
+
/** An input error that names its source line. */
|
|
48
|
+
export function inputError(line, message) {
|
|
49
|
+
return new RenderError("E_INPUT", `line ${line}: ${message}`, { line });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Handles a construct that the grammar does not accept. Without lenient it rejects with E_INPUT on its line.
|
|
53
|
+
* With lenient it records a warning on its line and returns, so that the caller can skip the construct.
|
|
54
|
+
*/
|
|
55
|
+
export function outside(ctx, line, text, why) {
|
|
56
|
+
if (!ctx.lenient) {
|
|
57
|
+
throw inputError(line, `${why}: "${text}"`);
|
|
58
|
+
}
|
|
59
|
+
ctx.warnings.push(`line ${line}: skipped the unsupported construct "${text}"`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Prepares a source. It reads the options, removes blank lines, comment lines, directives and front matter,
|
|
63
|
+
* and reads the header. A whole Mermaid type that the native layouts do not draw rejects with E_UNSUPPORTED.
|
|
64
|
+
*/
|
|
65
|
+
export function prepare(source, options, extra = []) {
|
|
66
|
+
const ctx = { lenient: readLenient(options, extra), warnings: [] };
|
|
67
|
+
const raw = source.split(/\r?\n/);
|
|
68
|
+
const content = [];
|
|
69
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
70
|
+
const number = index + 1;
|
|
71
|
+
const text = (raw[index] ?? "").trim();
|
|
72
|
+
if (text === "")
|
|
73
|
+
continue;
|
|
74
|
+
if (content.length === 0 && text === "---") {
|
|
75
|
+
const close = raw.findIndex((line, at) => at > index && line.trim() === "---");
|
|
76
|
+
if (close < 0) {
|
|
77
|
+
throw inputError(number, "the front matter is not closed by a line of three dashes");
|
|
78
|
+
}
|
|
79
|
+
outside(ctx, number, text, "the front matter is outside the supported grammar");
|
|
80
|
+
index = close;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (text.startsWith("%%{")) {
|
|
84
|
+
outside(ctx, number, text, "a directive is outside the supported grammar");
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (text.startsWith("%%"))
|
|
88
|
+
continue;
|
|
89
|
+
if (xmlSafe(text) !== text) {
|
|
90
|
+
ctx.warnings.push(`line ${number}: each character outside the XML 1.0 range is shown as U+FFFD`);
|
|
91
|
+
}
|
|
92
|
+
content.push({ number, text });
|
|
93
|
+
}
|
|
94
|
+
const head = content[0];
|
|
95
|
+
if (head === undefined) {
|
|
96
|
+
throw new RenderError("E_INPUT", "the source names no Mermaid diagram type");
|
|
97
|
+
}
|
|
98
|
+
const word = head.text.split(/\s+/)[0] ?? "";
|
|
99
|
+
const kind = HEADERS.get(head.text);
|
|
100
|
+
if (kind !== undefined) {
|
|
101
|
+
return { kind, headerLine: head.number, lines: content.slice(1), lenient: ctx.lenient, warnings: ctx.warnings };
|
|
102
|
+
}
|
|
103
|
+
if (OTHER_TYPES.has(word)) {
|
|
104
|
+
throw new RenderError("E_UNSUPPORTED", `line ${head.number}: ${word} diagrams need the browser stage, which this release does not build; ` +
|
|
105
|
+
"the native layouts draw classDiagram, stateDiagram-v2 and sequenceDiagram", { line: head.number });
|
|
106
|
+
}
|
|
107
|
+
if (HEADERS.has(word)) {
|
|
108
|
+
throw inputError(head.number, `the header ${word} takes no other text on its line`);
|
|
109
|
+
}
|
|
110
|
+
throw inputError(head.number, `"${head.text}" does not name a Mermaid diagram type that this release draws`);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/mermaid/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwB3C,MAAM,OAAO,GAAqC,IAAI,GAAG,CAAC;IACxD,CAAC,cAAc,EAAE,OAAO,CAAC;IACzB,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC5B,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC5B,CAAC,iBAAiB,EAAE,UAAU,CAAC;CAChC,CAAC,CAAC;AAEH,yHAAyH;AACzH,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC;IAC/C,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS;IACnG,UAAU,EAAE,eAAe,EAAE,oBAAoB,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAC5F,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ;IACjG,mBAAmB,EAAE,QAAQ;CAC9B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgC,EAAE,KAAwB;IACpF,IAAI,O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EAAuE;YACjG,2EAA2E,EAC7E,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CACtB,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,IAAI,kCAAkC,CAAC,CAAC;IACtF,CAAC;IACD,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,gEAAgE,CAAC,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public surface of the Mermaid native layouts. It holds the header and option reader, the parsers,
|
|
3
|
+
* the DOT builders, the sequence layout and the SVG render.
|
|
4
|
+
*/
|
|
5
|
+
export { prepare, type Source } from "./common.ts";
|
|
6
|
+
export { parseClassDiagram, classToDot, type ClassModel, type ClassDef, type ClassRelation, type ClassArrow, type Marker, } from "./class.ts";
|
|
7
|
+
export { parseStateDiagram, stateToDot, type StateModel, type StateDef, type StateTransition } from "./state.ts";
|
|
8
|
+
export { parseSequenceDiagram, type SequenceModel, type SeqEvent, type Participant, type MessageEvent, type NoteEvent, type ActivateEvent, type DeactivateEvent, type Branch, type BlockEvent, } from "./sequence.ts";
|
|
9
|
+
export { layoutSequence } from "./sequence-layout.ts";
|
|
10
|
+
export { renderMermaidSvg, type MermaidSvg } from "./render.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public surface of the Mermaid native layouts. It holds the header and option reader, the parsers,
|
|
3
|
+
* the DOT builders, the sequence layout and the SVG render.
|
|
4
|
+
*/
|
|
5
|
+
export { prepare } from "./common.js";
|
|
6
|
+
export { parseClassDiagram, classToDot, } from "./class.js";
|
|
7
|
+
export { parseStateDiagram, stateToDot } from "./state.js";
|
|
8
|
+
export { parseSequenceDiagram, } from "./sequence.js";
|
|
9
|
+
export { layoutSequence } from "./sequence-layout.js";
|
|
10
|
+
export { renderMermaidSvg } from "./render.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mermaid/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,UAAU,GAMX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAwD,MAAM,YAAY,CAAC;AACjH,OAAO,EACL,oBAAoB,GAUrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC"}
|