package.dist.chunks.mermaid.esm.chunk-S2G4O3TG.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mermaid Show documentation
Show all versions of mermaid Show documentation
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
import {
__name as __name2
} from "./chunk-U4JKYEUK.mjs";
import {
__name
} from "./chunk-DLQEHMXD.mjs";
// ../parser/dist/mermaid-parser.core.mjs
var parsers = {};
var initializers = {
info: /* @__PURE__ */ __name2(async () => {
const { createInfoServices: createInfoServices2 } = await import("./info-46DW6VJ7-K4IRANUI.mjs");
const parser = createInfoServices2().Info.parser.LangiumParser;
parsers.info = parser;
}, "info"),
packet: /* @__PURE__ */ __name2(async () => {
const { createPacketServices: createPacketServices2 } = await import("./packet-W2GHVCYJ-YAW3KRUJ.mjs");
const parser = createPacketServices2().Packet.parser.LangiumParser;
parsers.packet = parser;
}, "packet"),
pie: /* @__PURE__ */ __name2(async () => {
const { createPieServices: createPieServices2 } = await import("./pie-BEWT4RHE-X256G432.mjs");
const parser = createPieServices2().Pie.parser.LangiumParser;
parsers.pie = parser;
}, "pie"),
architecture: /* @__PURE__ */ __name2(async () => {
const { createArchitectureServices: createArchitectureServices2 } = await import("./architecture-I3QFYML2-UU763MPG.mjs");
const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
parsers.architecture = parser;
}, "architecture"),
gitGraph: /* @__PURE__ */ __name2(async () => {
const { createGitGraphServices: createGitGraphServices2 } = await import("./gitGraph-YCYPL57B-RWHQZFFZ.mjs");
const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
parsers.gitGraph = parser;
}, "gitGraph")
};
async function parse(diagramType, text) {
const initializer = initializers[diagramType];
if (!initializer) {
throw new Error(`Unknown diagram type: ${diagramType}`);
}
if (!parsers[diagramType]) {
await initializer();
}
const parser = parsers[diagramType];
const result = parser.parse(text);
if (result.lexerErrors.length > 0 || result.parserErrors.length > 0) {
throw new MermaidParseError(result);
}
return result.value;
}
__name(parse, "parse");
__name2(parse, "parse");
var MermaidParseError = class extends Error {
static {
__name(this, "MermaidParseError");
}
constructor(result) {
const lexerErrors = result.lexerErrors.map((err) => err.message).join("\n");
const parserErrors = result.parserErrors.map((err) => err.message).join("\n");
super(`Parsing failed: ${lexerErrors} ${parserErrors}`);
this.result = result;
}
static {
__name2(this, "MermaidParseError");
}
};
export {
parse
};