@draftably/markdown 0.1.0 → 0.2.1
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 +34 -65
- package/dist/chunks/{core-DPjuIyPG.js → core-D4HpamVq.js} +19 -13
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-D9i_Vfxl.js +4066 -0
- package/dist/markdown-it.js +86 -85
- package/dist/mermaid.js +93 -0
- package/dist/remark.js +46 -46
- package/dist/types/{core.d.ts → packages/markdown/src/core.d.ts} +11 -0
- package/dist/types/packages/markdown/src/mermaid.d.ts +8 -0
- package/dist/types/{remark.d.ts → packages/markdown/src/remark.d.ts} +1 -1
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +175 -0
- package/dist/types/src/dsl/corridors.d.ts +38 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/types.d.ts +286 -0
- package/package.json +9 -7
- /package/dist/types/{client-validation.d.ts → packages/markdown/src/client-validation.d.ts} +0 -0
- /package/dist/types/{client.d.ts → packages/markdown/src/client.d.ts} +0 -0
- /package/dist/types/{files.d.ts → packages/markdown/src/files.d.ts} +0 -0
- /package/dist/types/{index.d.ts → packages/markdown/src/index.d.ts} +0 -0
- /package/dist/types/{markdown-it-helpers.d.ts → packages/markdown/src/markdown-it-helpers.d.ts} +0 -0
- /package/dist/types/{markdown-it.d.ts → packages/markdown/src/markdown-it.d.ts} +0 -0
- /package/dist/types/{metadata.d.ts → packages/markdown/src/metadata.d.ts} +0 -0
- /package/dist/types/{source.d.ts → packages/markdown/src/source.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,73 +1,42 @@
|
|
|
1
1
|
# `@draftably/markdown`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It
|
|
5
|
-
|
|
3
|
+
Turn `draft` code fences, and optionally `mermaid` fences, into static SVG images when your site
|
|
4
|
+
builds. It has a remark plugin (Unified, MDX, Astro, Docusaurus) and a markdown-it plugin. Readers
|
|
5
|
+
load no Draftably JavaScript.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
The host must provide `emitAsset`. It receives final SVG bytes and returns the
|
|
11
|
-
public URL. Use a durable content-addressed store with your page cache. Re-emit
|
|
12
|
-
the asset on a warm Markdown transform, and retain asset references with cached
|
|
13
|
-
pages. The host owns base paths, publication, cleanup, and watcher integration.
|
|
14
|
-
|
|
15
|
-
For Node builds, `@draftably/markdown/files` provides a filesystem store for
|
|
16
|
-
content-addressed SVG and interactive JSON assets:
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
import { createFileAssets } from '@draftably/markdown/files';
|
|
20
|
-
|
|
21
|
-
const assets = createFileAssets({ directory: '.cache/diagrams', publicPath: '/docs/diagrams/' });
|
|
22
|
-
const options = { emitAsset: assets.emitAsset };
|
|
23
|
-
// Add `assets.emitInit` to the optional interactive bridge.
|
|
24
|
-
await assets.copyTo('dist/diagrams');
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @draftably/markdown
|
|
25
9
|
```
|
|
26
10
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
references.
|
|
30
|
-
|
|
31
|
-
Use `src="./diagram.draft"` only with `sources.rootDir` and a Markdown file path.
|
|
32
|
-
The resolver rejects remote and absolute paths, non-`.draft` files, and symlink
|
|
33
|
-
escapes. It reports missing paths as dependencies and the nearest existing
|
|
34
|
-
in-root directory as `watchPath`, so the host can detect when a file appears.
|
|
35
|
-
|
|
36
|
-
Supported fence keys are `id`, `alt`, `caption`, `src`, `mode`, and `state`.
|
|
37
|
-
Unknown, repeated, malformed, or control-containing values fail the build.
|
|
38
|
-
Captions and alternatives are plain text. The adapter does not evaluate HTML
|
|
39
|
-
or JSX. Inline SVG is not available.
|
|
11
|
+
For a standalone Markdown build, install `markdown-it`, then use the async adapter and write its
|
|
12
|
+
HTML:
|
|
40
13
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`adapter.render(md, source, env)` to parse, prepare, and render one document. The
|
|
45
|
-
adapter also exposes `prepare(tokens, env)` for hosts that need custom rendering.
|
|
46
|
-
Prepared state stays local to each token tree, so separate documents can prepare
|
|
47
|
-
at the same time.
|
|
48
|
-
|
|
49
|
-
## Optional interactive mode
|
|
50
|
-
|
|
51
|
-
`mode="interactive"` requires a host `interactive` bridge. The bridge emits a
|
|
52
|
-
versioned JSON asset and names the client module. This mode publishes the
|
|
53
|
-
diagram source in that JSON asset by design. Keep the JSON and SVG references
|
|
54
|
-
with the page cache.
|
|
55
|
-
|
|
56
|
-
The host can load `@draftably/markdown/client` after hydration and call
|
|
57
|
-
`enhanceDrafts(root, { policies })`. The client validates same-origin URLs and
|
|
58
|
-
bounded JSON before it mounts `@draftably/runtime/viewer`. It hides the static
|
|
59
|
-
image only after the viewer commits an update. On failure or destroy, the
|
|
60
|
-
fallback image stays or becomes visible.
|
|
61
|
-
|
|
62
|
-
The host owns module loading and teardown. Static adapter entry points do not
|
|
63
|
-
import the client or viewer. Use interactive mode only when public source is
|
|
64
|
-
acceptable.
|
|
14
|
+
```sh
|
|
15
|
+
pnpm add @draftably/markdown markdown-it
|
|
16
|
+
```
|
|
65
17
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
18
|
+
````js
|
|
19
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
20
|
+
import MarkdownIt from 'markdown-it';
|
|
21
|
+
import { createMarkdownItDraft } from '@draftably/markdown/markdown-it';
|
|
22
|
+
import { createFileAssets } from '@draftably/markdown/files';
|
|
70
23
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
24
|
+
const assets = createFileAssets({ directory: 'dist/diagrams', publicPath: '/diagrams/' });
|
|
25
|
+
const adapter = createMarkdownItDraft({ emitAsset: assets.emitAsset });
|
|
26
|
+
const md = new MarkdownIt().use(adapter.plugin);
|
|
27
|
+
const source = '```draft\ndiagram "API" version=1\nnode api "API"\n```';
|
|
28
|
+
const { html } = await adapter.render(md, source);
|
|
29
|
+
await mkdir('dist', { recursive: true });
|
|
30
|
+
await writeFile('dist/index.html', html);
|
|
31
|
+
````
|
|
32
|
+
|
|
33
|
+
Run it as an `.mjs` file. This writes `dist/index.html` and the referenced SVG under
|
|
34
|
+
`dist/diagrams/`. For `src` includes, errors, Mermaid fences, caching and interactive mode, use the
|
|
35
|
+
[Markdown guide](https://draftably.dev/docs/markdown).
|
|
36
|
+
|
|
37
|
+
## Docs
|
|
38
|
+
|
|
39
|
+
- [Markdown](https://draftably.dev/docs/markdown): a first build, fence options, includes,
|
|
40
|
+
Mermaid fences and interactive mode
|
|
41
|
+
- [Documentation sites](https://draftably.dev/docs/documentation-sites): complete Astro Starlight,
|
|
42
|
+
Docusaurus and VitePress setups, including development serving and build output
|
|
@@ -44,6 +44,11 @@ async function Q(e, t, r) {
|
|
|
44
44
|
if (h.byteLength > 1e6) throw new Error("Included .draft file exceeds 1 MB.");
|
|
45
45
|
return { source: new TextDecoder("utf-8", { fatal: !0 }).decode(h), path: n };
|
|
46
46
|
}
|
|
47
|
+
async function se(e, t, r) {
|
|
48
|
+
if (r.mermaid !== "convert") return { source: null, diagnostics: [] };
|
|
49
|
+
const { convertMermaid: s } = await import("../mermaid.js");
|
|
50
|
+
return s(e, t);
|
|
51
|
+
}
|
|
47
52
|
function z(e, t, r, s) {
|
|
48
53
|
return {
|
|
49
54
|
code: e,
|
|
@@ -73,7 +78,7 @@ function X(e) {
|
|
|
73
78
|
function P(e, t, r) {
|
|
74
79
|
return Object.assign(new Error(t), { diagnostic: z(e, t, r) });
|
|
75
80
|
}
|
|
76
|
-
function
|
|
81
|
+
function ce(e) {
|
|
77
82
|
return !!e && typeof e == "object" && "noPlaceholder" in e;
|
|
78
83
|
}
|
|
79
84
|
function F(e) {
|
|
@@ -96,7 +101,7 @@ function te(e, t) {
|
|
|
96
101
|
fonts: "embed"
|
|
97
102
|
});
|
|
98
103
|
}
|
|
99
|
-
async function
|
|
104
|
+
async function le(e, t, r, s, g, n) {
|
|
100
105
|
const p = [];
|
|
101
106
|
F(n.render?.signal);
|
|
102
107
|
let h = e, m = s.path, f, y = !1;
|
|
@@ -217,11 +222,11 @@ async function ce(e, t, r, s, g, n) {
|
|
|
217
222
|
}, b && (v.set(b, w), v.size > ee && v.delete(v.keys().next().value));
|
|
218
223
|
}
|
|
219
224
|
p.push(...L(w.diagnostics)), F(n.render?.signal);
|
|
220
|
-
const
|
|
225
|
+
const S = new TextEncoder().encode(w.svg), T = `draft-${M(S)}.svg`;
|
|
221
226
|
let d;
|
|
222
227
|
try {
|
|
223
228
|
d = await n.emitAsset(
|
|
224
|
-
{ fileName:
|
|
229
|
+
{ fileName: T, mediaType: "image/svg+xml", bytes: S },
|
|
225
230
|
{ document: s, fenceIndex: g }
|
|
226
231
|
);
|
|
227
232
|
} catch (i) {
|
|
@@ -229,20 +234,20 @@ async function ce(e, t, r, s, g, n) {
|
|
|
229
234
|
}
|
|
230
235
|
if (!d || typeof d.url != "string")
|
|
231
236
|
throw c(new TypeError("Asset emitter must return a URL string."));
|
|
232
|
-
let
|
|
237
|
+
let O;
|
|
233
238
|
try {
|
|
234
|
-
|
|
239
|
+
O = new URL(d.url, "https://draftably.invalid");
|
|
235
240
|
} catch {
|
|
236
241
|
throw c(new Error("Asset emitter returned an invalid URL."));
|
|
237
242
|
}
|
|
238
|
-
if (!d.url || d.url.charCodeAt(0) <= 32 || x(d.url) || !["https:", "http:"].includes(
|
|
243
|
+
if (!d.url || d.url.charCodeAt(0) <= 32 || x(d.url) || !["https:", "http:"].includes(O.protocol))
|
|
239
244
|
throw c(new Error("Asset emitter returned an unsafe URL."));
|
|
240
245
|
const U = t.alt?.trim() || w.title, _ = {
|
|
241
246
|
type: "image",
|
|
242
247
|
url: d.url,
|
|
243
248
|
alt: U,
|
|
244
249
|
data: { hProperties: { width: Math.ceil(w.width), height: Math.ceil(w.height) } }
|
|
245
|
-
}, B = { fileName:
|
|
250
|
+
}, B = { fileName: T, url: d.url }, R = [];
|
|
246
251
|
let j;
|
|
247
252
|
const E = [_];
|
|
248
253
|
if (t.mode === "interactive") {
|
|
@@ -277,7 +282,7 @@ async function ce(e, t, r, s, g, n) {
|
|
|
277
282
|
throw c(new Error("Initialization emitter returned an invalid asset."));
|
|
278
283
|
if (!i.clientModuleUrl || i.clientModuleUrl.charCodeAt(0) <= 32 || x(i.clientModuleUrl) || !["https:", "http:"].includes(C.protocol))
|
|
279
284
|
throw c(new Error("clientModuleUrl is unsafe."));
|
|
280
|
-
|
|
285
|
+
R.push({ fileName: o.fileName, url: o.url }), j = i.clientModuleUrl, E.push({
|
|
281
286
|
type: "div",
|
|
282
287
|
data: {
|
|
283
288
|
hName: "div",
|
|
@@ -306,12 +311,13 @@ async function ce(e, t, r, s, g, n) {
|
|
|
306
311
|
type: "paragraph",
|
|
307
312
|
...t.id ? { data: { hProperties: { id: t.id } } } : {},
|
|
308
313
|
children: E
|
|
309
|
-
}, asset: B, extraAssets:
|
|
314
|
+
}, asset: B, extraAssets: R, clientModule: j, diagnostics: p, dependency: f };
|
|
310
315
|
}
|
|
311
316
|
export {
|
|
312
|
-
|
|
317
|
+
z as a,
|
|
318
|
+
ce as b,
|
|
313
319
|
c as h,
|
|
314
320
|
X as i,
|
|
315
|
-
|
|
316
|
-
|
|
321
|
+
se as m,
|
|
322
|
+
le as p
|
|
317
323
|
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
const E = "12.2.0";
|
|
2
|
+
const l = (t) => {
|
|
3
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
4
|
+
throw new Error("Expected a Mermaid data object.");
|
|
5
|
+
return t;
|
|
6
|
+
}, a = (t, s) => {
|
|
7
|
+
if (typeof t == "string") return t;
|
|
8
|
+
if (t == null && s !== void 0) return s;
|
|
9
|
+
throw new Error("Expected a Mermaid string.");
|
|
10
|
+
}, m = (t) => {
|
|
11
|
+
if (t == null) return [];
|
|
12
|
+
if (!Array.isArray(t) || t.some((s) => typeof s != "string"))
|
|
13
|
+
throw new Error("Expected a Mermaid string array.");
|
|
14
|
+
return [...t];
|
|
15
|
+
}, i = (t) => t == null ? void 0 : a(t), y = (t) => {
|
|
16
|
+
if (!Array.isArray(t)) throw new Error("Expected a Mermaid array.");
|
|
17
|
+
return t;
|
|
18
|
+
}, x = (t) => {
|
|
19
|
+
if (!(t instanceof Map)) throw new Error("Expected a Mermaid Map.");
|
|
20
|
+
return [...t.values()];
|
|
21
|
+
}, b = (t) => {
|
|
22
|
+
if (t != null) {
|
|
23
|
+
if (typeof t != "number" || !Number.isFinite(t))
|
|
24
|
+
throw new Error("Expected finite number.");
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function w(t) {
|
|
29
|
+
return t.replace(/fl°°(\d+)¶ß/g, "&#$1;").replace(/fl°([A-Za-z]\w*)¶ß/g, "&$1;");
|
|
30
|
+
}
|
|
31
|
+
function P(t) {
|
|
32
|
+
return (s) => {
|
|
33
|
+
const g = t.createElement("template");
|
|
34
|
+
return g.innerHTML = w(s).replace(/<br\s*\/?>/gi, `
|
|
35
|
+
`), g.content.textContent ?? "";
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function R(t) {
|
|
39
|
+
if (new TextEncoder().encode(t).length > 1e5)
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
code: "IMPORT_INPUT_LIMIT",
|
|
43
|
+
severity: "error",
|
|
44
|
+
message: "Mermaid input exceeds 100000 UTF-8 bytes."
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const s = t.replace(/^\uFEFF/, "").replace(/\r\n?/g, `
|
|
48
|
+
`);
|
|
49
|
+
if (/^\s*---(?:\n|$)/.test(s) || /%%\s*\{/.test(s))
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
code: "MERMAID_CONFIGURATION_UNSUPPORTED",
|
|
53
|
+
severity: "error",
|
|
54
|
+
message: "This importer does not apply Mermaid frontmatter or directives. Remove the configuration block and import the diagram text."
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
if ([...s].some((o) => {
|
|
58
|
+
const d = o.charCodeAt(0);
|
|
59
|
+
return d < 32 && ![9, 10, 13].includes(d);
|
|
60
|
+
}))
|
|
61
|
+
return [
|
|
62
|
+
{
|
|
63
|
+
code: "IMPORT_CONTROL_CHARACTER",
|
|
64
|
+
severity: "error",
|
|
65
|
+
message: "Input contains unsupported control characters."
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
const g = s.split(`
|
|
69
|
+
`).find((o) => o.trim() && !o.trimStart().startsWith("%%")) ?? "";
|
|
70
|
+
if (!/^\s*(?:flowchart|graph|sequenceDiagram)\b/.test(g))
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
code: "MERMAID_FAMILY_UNSUPPORTED",
|
|
74
|
+
severity: "error",
|
|
75
|
+
message: "This adapter supports Mermaid flowcharts and sequence diagrams only. Class, ER, state, chart and other families require separate semantic adapters."
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
const f = [];
|
|
79
|
+
for (const [o, d] of s.split(`
|
|
80
|
+
`).entries())
|
|
81
|
+
/(?:^|;)\s*click\s/.test(d) && f.push({
|
|
82
|
+
code: "MERMAID_INTERACTION_IGNORED",
|
|
83
|
+
severity: "warning",
|
|
84
|
+
message: "Mermaid click links and callbacks are data only; no interactions are installed.",
|
|
85
|
+
line: o + 1,
|
|
86
|
+
locationKind: "source"
|
|
87
|
+
});
|
|
88
|
+
return f;
|
|
89
|
+
}
|
|
90
|
+
function S(t, s) {
|
|
91
|
+
const g = new Map(
|
|
92
|
+
Object.entries(l(t.LINETYPE)).map(([n, r]) => [r, n])
|
|
93
|
+
), f = new Map(
|
|
94
|
+
Object.entries(l(t.PLACEMENT)).map(([n, r]) => [r, n])
|
|
95
|
+
), o = y(s("getBoxes")), d = s("getActors");
|
|
96
|
+
if (!(d instanceof Map)) throw new Error("Expected a Mermaid Map.");
|
|
97
|
+
const p = (n) => new Set(s(n) instanceof Map ? s(n).keys() : []);
|
|
98
|
+
return {
|
|
99
|
+
format: "mermaid",
|
|
100
|
+
family: "sequence",
|
|
101
|
+
parserVersion: E,
|
|
102
|
+
title: i(s("getDiagramTitle")) || void 0,
|
|
103
|
+
actors: m(s("getActorKeys")).map((n) => {
|
|
104
|
+
const r = l(d.get(n));
|
|
105
|
+
return {
|
|
106
|
+
id: n,
|
|
107
|
+
name: a(r.description, a(r.name, n)),
|
|
108
|
+
type: a(r.type, "participant"),
|
|
109
|
+
box: r.box ? o.indexOf(r.box) : void 0,
|
|
110
|
+
links: Object.keys(l(r.links ?? {}))
|
|
111
|
+
};
|
|
112
|
+
}),
|
|
113
|
+
boxes: o.map((n) => {
|
|
114
|
+
const r = l(n);
|
|
115
|
+
return { name: i(r.name), fill: i(r.fill) };
|
|
116
|
+
}),
|
|
117
|
+
events: y(s("getMessages")).map((n) => {
|
|
118
|
+
const r = l(n), u = f.get(r.placement);
|
|
119
|
+
return {
|
|
120
|
+
kind: g.get(r.type) ?? "UNKNOWN",
|
|
121
|
+
from: i(r.from),
|
|
122
|
+
to: i(r.to),
|
|
123
|
+
// `autonumber` stores its numbering object here.
|
|
124
|
+
text: typeof r.message == "string" ? r.message : "",
|
|
125
|
+
...r.placement == null ? {} : {
|
|
126
|
+
placement: u === "LEFTOF" ? "left" : u === "RIGHTOF" ? "right" : "over"
|
|
127
|
+
},
|
|
128
|
+
central: !!r.centralConnection
|
|
129
|
+
};
|
|
130
|
+
}),
|
|
131
|
+
created: [...p("getCreatedActors")].map(String),
|
|
132
|
+
destroyed: [...p("getDestroyedActors")].map(String)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function D(t) {
|
|
136
|
+
let s = Promise.resolve();
|
|
137
|
+
return (g) => {
|
|
138
|
+
const f = s.then(async () => {
|
|
139
|
+
const o = R(g);
|
|
140
|
+
if (o.some((p) => p.severity === "error")) return { ok: !1, diagnostics: o };
|
|
141
|
+
let d = "load";
|
|
142
|
+
try {
|
|
143
|
+
const p = await t();
|
|
144
|
+
p.initialize({
|
|
145
|
+
startOnLoad: !1,
|
|
146
|
+
securityLevel: "strict",
|
|
147
|
+
htmlLabels: !1,
|
|
148
|
+
maxTextSize: 1e5,
|
|
149
|
+
maxEdges: 3e3,
|
|
150
|
+
suppressErrorRendering: !0
|
|
151
|
+
}), d = "parse";
|
|
152
|
+
const n = await p.mermaidAPI.getDiagramFromText(g.replace(/^\uFEFF/, ""));
|
|
153
|
+
if (!["flowchart", "flowchart-v2", "sequence"].includes(n.type))
|
|
154
|
+
return {
|
|
155
|
+
ok: !1,
|
|
156
|
+
diagnostics: [
|
|
157
|
+
...o,
|
|
158
|
+
{
|
|
159
|
+
code: "MERMAID_FAMILY_UNSUPPORTED",
|
|
160
|
+
severity: "error",
|
|
161
|
+
message: `Parser selected unsupported diagram family ${n.type}.`
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
};
|
|
165
|
+
d = "snapshot";
|
|
166
|
+
const r = l(n.db), u = (c) => {
|
|
167
|
+
if (typeof r[c] != "function")
|
|
168
|
+
throw new Error(`Mermaid ${E} boundary missing ${c}().`);
|
|
169
|
+
return r[c].call(r);
|
|
170
|
+
};
|
|
171
|
+
if (n.type === "sequence") {
|
|
172
|
+
const c = S(r, u);
|
|
173
|
+
return c.actors.length > 1e3 || c.events.length > 3e3 ? {
|
|
174
|
+
ok: !1,
|
|
175
|
+
diagnostics: [
|
|
176
|
+
...o,
|
|
177
|
+
{
|
|
178
|
+
code: "IMPORT_GRAPH_LIMIT",
|
|
179
|
+
severity: "error",
|
|
180
|
+
message: "Parsed sequence exceeds the import entity or event limit."
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
} : { ok: !0, diagnostics: o, snapshot: c };
|
|
184
|
+
}
|
|
185
|
+
const M = u("getEdges"), h = x(u("getVertices")).map((c) => {
|
|
186
|
+
const e = l(c);
|
|
187
|
+
return {
|
|
188
|
+
id: a(e.id),
|
|
189
|
+
text: a(e.text, a(e.id)),
|
|
190
|
+
type: i(e.type),
|
|
191
|
+
labelType: a(e.labelType, "text"),
|
|
192
|
+
classes: m(e.classes),
|
|
193
|
+
styles: m(e.styles),
|
|
194
|
+
link: i(e.link),
|
|
195
|
+
icon: i(e.icon),
|
|
196
|
+
img: i(e.img),
|
|
197
|
+
props: e.props == null ? void 0 : structuredClone(l(e.props))
|
|
198
|
+
};
|
|
199
|
+
}), T = y(M).map((c) => {
|
|
200
|
+
const e = l(c);
|
|
201
|
+
return {
|
|
202
|
+
start: a(e.start),
|
|
203
|
+
end: a(e.end),
|
|
204
|
+
text: a(e.text, ""),
|
|
205
|
+
type: i(e.type),
|
|
206
|
+
stroke: i(e.stroke),
|
|
207
|
+
id: i(e.id),
|
|
208
|
+
isUserDefinedId: e.isUserDefinedId === !0,
|
|
209
|
+
labelType: a(e.labelType, "text"),
|
|
210
|
+
classes: m(e.classes),
|
|
211
|
+
style: m(e.style),
|
|
212
|
+
length: b(e.length),
|
|
213
|
+
interpolate: i(e.interpolate),
|
|
214
|
+
animate: e.animate === !0,
|
|
215
|
+
animation: i(e.animation)
|
|
216
|
+
};
|
|
217
|
+
}), A = y(u("getSubGraphs")).map((c) => {
|
|
218
|
+
const e = l(c);
|
|
219
|
+
return {
|
|
220
|
+
id: a(e.id),
|
|
221
|
+
title: a(e.title, ""),
|
|
222
|
+
nodes: m(e.nodes),
|
|
223
|
+
dir: i(e.dir),
|
|
224
|
+
labelType: a(e.labelType, "text"),
|
|
225
|
+
classes: m(e.classes),
|
|
226
|
+
metadata: e.metadata == null ? void 0 : structuredClone(l(e.metadata))
|
|
227
|
+
};
|
|
228
|
+
}), _ = x(u("getClasses")).map((c) => {
|
|
229
|
+
const e = l(c);
|
|
230
|
+
return { id: a(e.id), styles: m(e.styles), textStyles: m(e.textStyles) };
|
|
231
|
+
});
|
|
232
|
+
if (h.length + A.length > 1e3 || T.length > 3e3)
|
|
233
|
+
return {
|
|
234
|
+
ok: !1,
|
|
235
|
+
diagnostics: [
|
|
236
|
+
...o,
|
|
237
|
+
{
|
|
238
|
+
code: "IMPORT_GRAPH_LIMIT",
|
|
239
|
+
severity: "error",
|
|
240
|
+
message: "Parsed graph exceeds the import entity or edge limit."
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
};
|
|
244
|
+
const I = M;
|
|
245
|
+
return {
|
|
246
|
+
ok: !0,
|
|
247
|
+
diagnostics: o,
|
|
248
|
+
snapshot: {
|
|
249
|
+
format: "mermaid",
|
|
250
|
+
family: "flowchart",
|
|
251
|
+
parserVersion: E,
|
|
252
|
+
direction: a(u("getDirection"), "TB"),
|
|
253
|
+
vertices: h,
|
|
254
|
+
edges: T,
|
|
255
|
+
groups: A,
|
|
256
|
+
classes: _,
|
|
257
|
+
defaultEdgeStyle: m(I.defaultStyle),
|
|
258
|
+
defaultEdgeInterpolate: i(I.defaultInterpolate)
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
} catch (p) {
|
|
262
|
+
const n = p, r = n.hash?.loc;
|
|
263
|
+
return {
|
|
264
|
+
ok: !1,
|
|
265
|
+
diagnostics: [
|
|
266
|
+
...o,
|
|
267
|
+
{
|
|
268
|
+
code: d === "parse" ? "MERMAID_PARSE_ERROR" : "MERMAID_ADAPTER_MISMATCH",
|
|
269
|
+
severity: "error",
|
|
270
|
+
message: n.message ?? String(p),
|
|
271
|
+
line: r?.first_line,
|
|
272
|
+
column: r?.first_column == null ? void 0 : r.first_column + 1,
|
|
273
|
+
locationKind: r ? "parser-relative" : void 0
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
return s = f.catch(() => {
|
|
280
|
+
}), f;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
E as MERMAID_VERSION,
|
|
285
|
+
D as createMermaidFlowParser,
|
|
286
|
+
P as makePlainLabel,
|
|
287
|
+
R as preflightMermaidFlow,
|
|
288
|
+
w as restoreEntitySpelling
|
|
289
|
+
};
|