package.dist.chunks.mermaid.esm.chunk-CZNOFAJR.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 {
insertCluster,
insertEdge,
insertEdgeLabel,
insertNode,
labelHelper,
markers_default,
positionEdgeLabel
} from "./chunk-TPF7GGO3.mjs";
import {
interpolateToCurve
} from "./chunk-5GOTHXGK.mjs";
import {
common_default,
getConfig,
log
} from "./chunk-ZT3Z3A3D.mjs";
import {
__name
} from "./chunk-DLQEHMXD.mjs";
// src/internals.ts
var internalHelpers = {
common: common_default,
getConfig,
insertCluster,
insertEdge,
insertEdgeLabel,
insertMarkers: markers_default,
insertNode,
interpolateToCurve,
labelHelper,
log,
positionEdgeLabel
};
// src/rendering-util/render.ts
var layoutAlgorithms = {};
var registerLayoutLoaders = /* @__PURE__ */ __name((loaders) => {
for (const loader of loaders) {
layoutAlgorithms[loader.name] = loader;
}
}, "registerLayoutLoaders");
var registerDefaultLayoutLoaders = /* @__PURE__ */ __name(() => {
registerLayoutLoaders([
{
name: "dagre",
loader: /* @__PURE__ */ __name(async () => await import("./dagre-XTQZZUF6.mjs"), "loader")
}
]);
}, "registerDefaultLayoutLoaders");
registerDefaultLayoutLoaders();
var render = /* @__PURE__ */ __name(async (data4Layout, svg) => {
if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {
throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);
}
const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];
const layoutRenderer = await layoutDefinition.loader();
return layoutRenderer.render(data4Layout, svg, internalHelpers, {
algorithm: layoutDefinition.algorithm
});
}, "render");
var getRegisteredLayoutAlgorithm = /* @__PURE__ */ __name((algorithm = "", { fallback = "dagre" } = {}) => {
if (algorithm in layoutAlgorithms) {
return algorithm;
}
if (fallback in layoutAlgorithms) {
log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);
return fallback;
}
throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);
}, "getRegisteredLayoutAlgorithm");
export {
registerLayoutLoaders,
render,
getRegisteredLayoutAlgorithm
};