@draftably/mermaid 0.0.0-stage → 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 +67 -2
- package/dist/LICENSE +21 -0
- package/dist/cdn/font-data-tnqJ-kTK-CF1yb2a5.mjs +30 -0
- package/dist/cdn/index-DRFxGmQq.mjs +7781 -0
- package/dist/cdn/mermaid-facade-BoLWBerE.mjs +289 -0
- package/dist/cdn/mermaid-importer-SlRnjUhj.mjs +3753 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-IVovOQE9.js +3753 -0
- package/dist/mermaid.esm.min.mjs +13 -0
- package/dist/mermaid.js +117 -0
- package/dist/types/packages/mermaid/src/index.d.ts +59 -0
- 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 +162 -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 +277 -0
- package/package.json +36 -3
|
@@ -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
|
+
};
|