ts-graphviz
Version:
Graphviz library for TypeScript
56 lines (55 loc) • 1.47 kB
JavaScript
import { registerDefault as l } from "@ts-graphviz/core";
export * from "@ts-graphviz/core";
import { RootModelsContext as d, createModelsContext as y } from "@ts-graphviz/common";
export * from "@ts-graphviz/common";
import { parse as h, toModel as m, fromModel as g, stringify as b } from "@ts-graphviz/ast";
const j = new Proxy(
Object.freeze({}),
{
get: (r, t) => t
}
);
function A(r, t) {
const e = h(r, t?.parse);
if (Array.isArray(e) || e.type === "Attribute" || e.type === "AttributeList" || e.type === "Comment" || e.type === "NodeRef" || e.type === "NodeRefGroup" || e.type === "Literal")
throw new Error();
return m(e, t?.convert);
}
function f(r, t) {
return (...e) => {
const a = r ? this.Digraph : this.Graph, p = e.find((o) => typeof o == "string"), u = e.find(
(o) => typeof o == "object"
), c = e.find(
(o) => typeof o == "function"
), i = new a(p, t, u);
return i.with(this), typeof c == "function" && c(i), i;
};
}
function n(r, t = d) {
return Object.freeze({
digraph: f.call(t, !0, r),
graph: f.call(t, !1, r)
});
}
const s = n(!1), C = s.digraph, D = s.graph, z = n(!0);
function G(r) {
const t = y(r);
return Object.freeze({
...n(!1, t),
strict: n(!0, t)
});
}
function O(r, t) {
const e = g(r, t?.convert);
return b(e, t?.print);
}
l();
export {
j as attribute,
C as digraph,
A as fromDot,
D as graph,
z as strict,
O as toDot,
G as withContext
};