VS Code extension that previews Archify diagrams from their JSON sources (live, as you type) and opens rendered Archify HTML in a viewer tab. Bundles the Archify 3.0.1 renderer and runs it on VS Code's Node runtime. Adds validation diagnostics, JSON schema help, source-link navigation, export saving, render-to-file and open-in-browser commands. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
/** Serialize computed layout for dry-run / inspect (#9). */
|
|
|
|
export function componentBox(c) {
|
|
return {
|
|
id: c.id,
|
|
type: c.type,
|
|
label: c.label,
|
|
x: Math.round(c.x),
|
|
y: Math.round(c.y),
|
|
width: c.width,
|
|
height: c.height,
|
|
...(Number.isInteger(c.row) ? { row: c.row } : {}),
|
|
...(Number.isInteger(c.col) ? { col: c.col } : {}),
|
|
...(Array.isArray(c.pos) ? { pos: c.pos.map(Math.round) } : {}),
|
|
};
|
|
}
|
|
|
|
export function boundaryBox(b) {
|
|
return {
|
|
kind: b.kind,
|
|
label: b.label,
|
|
x: Math.round(b.x),
|
|
y: Math.round(b.y),
|
|
width: Math.round(b.width),
|
|
height: Math.round(b.height),
|
|
wraps: b.wraps,
|
|
};
|
|
}
|
|
|
|
export function connectionPath(conn, routed, labelAt) {
|
|
return {
|
|
from: conn.from,
|
|
to: conn.to,
|
|
label: conn.label ?? null,
|
|
variant: conn.variant ?? 'default',
|
|
route: conn.route ?? 'auto',
|
|
// These points are repair inputs: rounding a fractional port makes a
|
|
// reused waypoint diagonal relative to the actual endpoint.
|
|
points: routed.points.map(([x, y]) => [x, y]),
|
|
...(labelAt ? { labelAt: labelAt.map(Math.round) } : {}),
|
|
};
|
|
}
|