A deterministic MoonBit graph layout quality audit and regression library.
moon fmt
moon check --deny-warn
moon test --deny-warn
moon build --target js src/cmd/moonlayout
moon run src/cmd/moonlayout -- \
--input examples/pipeline.snapshot \
--report audit-report.json \
--svg audit.svgcanvas 900 600
node Client 120 260 44 44
node API 360 260 44 44
node DB 600 180 44 44
node Queue 600 340 44 44
edge Client API
edge API DB
edge API Queue--input <file> .snapshot 输入(缺省使用内置示例)
--report <file> JSON 审计报告
--svg <file> 带问题标注的 SVG
--max-overlaps <n> 允许的重叠节点对,默认 0
--max-crossings <n> 允许的边交叉数,默认 0
--max-out-of-bounds <n> 允许的越界节点数,默认 0
--min-edge-length <n> 最小曼哈顿边长,默认不限制
--max-edge-length <n> 最大曼哈顿边长,默认不限制let snapshot = @core.make_snapshot(
900,
600,
[
{ id: "Client", x: 120, y: 260, width: 44, height: 44 },
{ id: "API", x: 360, y: 260, width: 44, height: 44 },
],
[{ source: "Client", target: "API" }],
)
let report = @core.audit_snapshot(snapshot, @core.default_audit_config())
let json = @core.report_to_json(report)
let svg = @core.render_audit_svg(snapshot, report)moon fmt
moon check --deny-warn
moon test --deny-warn
moon info
moon build --target js src/cmd/moonlayout
node --test tests/cli.integration.test.mjs
moon run src/cmd/moonlayout -- --input examples/pipeline.snapshot --report audit-report.json --svg audit.svgpub(all) struct AuditConfig {
max_overlaps : Int
max_crossings : Int
max_out_of_bounds : Int
min_edge_length : Int
max_edge_length : Int
}pub(all) struct AuditReport {
nodes : Int
edges : Int
overlap_pairs : Int
duplicate_positions : Int
out_of_bounds : Int
edge_crossings : Int
invalid_edge_endpoints : Int
min_edge_length : Int
max_edge_length : Int
average_edge_length : Int
passed : Bool
fingerprint : String
violations : Array[Violation]
}pub(all) struct Edge {
source : String
target : String
}pub(all) struct LayoutSnapshot {
width : Int
height : Int
nodes : Array[PositionedNode]
edges : Array[Edge]
}pub(all) struct PositionedNode {
id : String
x : Int
y : Int
width : Int
height : Int
}pub(all) struct Violation {
kind : String
first : String
second : String
detail : String
}fn make_snapshot(width : Int, height : Int, nodes : Array[PositionedNode], edges : Array[Edge]) -> LayoutSnapshotInstall
Download zipA deterministic MoonBit graph layout quality audit and regression library.