@senad-d/drawme 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -1
- package/README.md +32 -16
- package/assets/references/diagram-types.md +1 -1
- package/assets/references/style-presets.md +94 -0
- package/assets/references/xml-authoring.md +84 -6
- package/docs/reference.md +89 -9
- package/example/README.md +37 -0
- package/example/drawme-architecture.drawio +62 -0
- package/example/drawme-how-it-works.drawio +79 -122
- package/example/drawme-installation-guide.drawio +63 -97
- package/example/drawme-validation-decision-tree.drawio +74 -69
- package/example/event-driven-orders.drawio +119 -0
- package/package.json +7 -7
- package/src/animate.ts +177 -0
- package/src/animation.ts +637 -0
- package/src/drawio.ts +130 -34
- package/src/fitcanvas.ts +1 -1
- package/src/index.ts +119 -16
- package/src/motion.ts +839 -0
- package/src/storyboard.ts +161 -0
- package/src/svgexport.ts +124 -0
- package/src/validate.ts +162 -7
- package/src/workflow.ts +7 -5
- package/example/drawme-extension-waterfall-overview.drawio +0 -72
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storyboard: renders a motion timeline as a grid of static frames on one
|
|
3
|
+
* draw.io page, one tile per sequential step, so motion order and visibility
|
|
4
|
+
* can be reviewed in a single PNG. Each tile is a copy of the page with cell
|
|
5
|
+
* opacity set to its state after that step; highlight and travel steps show
|
|
6
|
+
* their accent color on the stroke.
|
|
7
|
+
*/
|
|
8
|
+
import { XMLSerializer } from "@xmldom/xmldom";
|
|
9
|
+
import { type DomEl, attr, elemChildren, firstByTag } from "./dom";
|
|
10
|
+
import { contentBounds, collectCellsWithIds, pyFloat } from "./geometry";
|
|
11
|
+
import { shiftCell } from "./fitcanvas";
|
|
12
|
+
import { type MotionFrame, isDarkBackground } from "./motion";
|
|
13
|
+
|
|
14
|
+
export const MAX_STORYBOARD_FRAMES = 12;
|
|
15
|
+
const GAP = 80;
|
|
16
|
+
const CAPTION_HEIGHT = 56;
|
|
17
|
+
|
|
18
|
+
interface PageEntry {
|
|
19
|
+
id: string;
|
|
20
|
+
element: DomEl;
|
|
21
|
+
cell: DomEl;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function escapeXml(value: string): string {
|
|
25
|
+
return value
|
|
26
|
+
.replaceAll("&", "&")
|
|
27
|
+
.replaceAll("<", "<")
|
|
28
|
+
.replaceAll(">", ">")
|
|
29
|
+
.replaceAll('"', """);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function setStyle(style: string, values: Record<string, string>): string {
|
|
33
|
+
const items = style.split(";").filter((item) => item.trim() !== "");
|
|
34
|
+
for (const [key, value] of Object.entries(values)) {
|
|
35
|
+
const index = items.findIndex((item) => item.split("=")[0].trim() === key);
|
|
36
|
+
if (index >= 0) items[index] = `${key}=${value}`;
|
|
37
|
+
else items.push(`${key}=${value}`);
|
|
38
|
+
}
|
|
39
|
+
return `${items.join(";")};`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Evenly sample at most MAX_STORYBOARD_FRAMES frames, always keeping the first and last. */
|
|
43
|
+
export function sampleFrames(frames: MotionFrame[]): MotionFrame[] {
|
|
44
|
+
if (frames.length <= MAX_STORYBOARD_FRAMES) return frames;
|
|
45
|
+
const last = frames.length - 1;
|
|
46
|
+
const picks = new Set<number>();
|
|
47
|
+
for (let i = 0; i < MAX_STORYBOARD_FRAMES; i++) picks.add(Math.round((i * last) / (MAX_STORYBOARD_FRAMES - 1)));
|
|
48
|
+
return [...picks].map((index) => frames[index]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function pageSize(model: DomEl): { width: number; height: number } {
|
|
52
|
+
const width = pyFloat(attr(model, "pageWidth") ?? "");
|
|
53
|
+
const height = pyFloat(attr(model, "pageHeight") ?? "");
|
|
54
|
+
if (width !== undefined && height !== undefined && width > 0 && height > 0 && Number.isFinite(width + height)) {
|
|
55
|
+
return { width, height };
|
|
56
|
+
}
|
|
57
|
+
const { cells, ids } = collectCellsWithIds(firstByTag(model, "root"));
|
|
58
|
+
const bounds = contentBounds(cells, ids);
|
|
59
|
+
return { width: Math.ceil((bounds?.maxX ?? 800) + 40), height: Math.ceil((bounds?.maxY ?? 600) + 40) };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function pageEntries(model: DomEl): PageEntry[] {
|
|
63
|
+
const root = firstByTag(model, "root");
|
|
64
|
+
const entries: PageEntry[] = [];
|
|
65
|
+
for (const element of root ? elemChildren(root) : []) {
|
|
66
|
+
const cell = element.tagName === "mxCell" ? element : firstByTag(element, "mxCell");
|
|
67
|
+
const id = attr(element, "id");
|
|
68
|
+
if (cell && id !== null) entries.push({ id, element, cell });
|
|
69
|
+
}
|
|
70
|
+
return entries;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Opacity a cell shows in a frame: its own value times every container ancestor's (SVG groups nest). */
|
|
74
|
+
function effectiveOpacity(id: string, frame: MotionFrame, parents: Map<string, string | null>): number {
|
|
75
|
+
let opacity = 1;
|
|
76
|
+
let current: string | null | undefined = id;
|
|
77
|
+
const seen = new Set<string>();
|
|
78
|
+
while (current && !seen.has(current)) {
|
|
79
|
+
seen.add(current);
|
|
80
|
+
opacity *= frame.opacity.get(current) ?? 1;
|
|
81
|
+
current = parents.get(current);
|
|
82
|
+
}
|
|
83
|
+
return opacity;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function storyboardCell(entry: PageEntry, prefix: string, layers: Set<string>, ox: number, oy: number): DomEl {
|
|
87
|
+
const element = (entry.element as unknown as { cloneNode(deep: boolean): DomEl }).cloneNode(true);
|
|
88
|
+
const cell = element.tagName === "mxCell" ? element : firstByTag(element, "mxCell")!;
|
|
89
|
+
element.setAttribute("id", `${prefix}${entry.id}`);
|
|
90
|
+
const parent = attr(cell, "parent");
|
|
91
|
+
const topLevel = parent === null || layers.has(parent);
|
|
92
|
+
cell.setAttribute("parent", topLevel ? "1" : `${prefix}${parent}`);
|
|
93
|
+
for (const end of ["source", "target"]) {
|
|
94
|
+
const ref = attr(cell, end);
|
|
95
|
+
if (ref !== null) cell.setAttribute(end, `${prefix}${ref}`);
|
|
96
|
+
}
|
|
97
|
+
if (topLevel) shiftCell(cell, ox, oy);
|
|
98
|
+
return element;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function applyFrameStyle(element: DomEl, id: string, frame: MotionFrame, parents: Map<string, string | null>): void {
|
|
102
|
+
const cell = element.tagName === "mxCell" ? element : firstByTag(element, "mxCell")!;
|
|
103
|
+
const updates: Record<string, string> = {};
|
|
104
|
+
const opacity = effectiveOpacity(id, frame, parents);
|
|
105
|
+
if (opacity < 1) {
|
|
106
|
+
const percent = String(Math.round(opacity * 100));
|
|
107
|
+
Object.assign(updates, { opacity: percent, textOpacity: percent });
|
|
108
|
+
}
|
|
109
|
+
const accent = frame.accent.get(id);
|
|
110
|
+
if (accent) Object.assign(updates, { strokeColor: accent, strokeWidth: "3" });
|
|
111
|
+
if (Object.keys(updates).length > 0) cell.setAttribute("style", setStyle(attr(cell, "style") ?? "", updates));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Build a one-page `.drawio` document that lays out the frames as a captioned grid. */
|
|
115
|
+
export function buildStoryboard(model: DomEl, frames: MotionFrame[]): string {
|
|
116
|
+
if (frames.length === 0) throw new Error("motion has no visual steps to storyboard");
|
|
117
|
+
const { width, height } = pageSize(model);
|
|
118
|
+
const entries = pageEntries(model);
|
|
119
|
+
const parents = new Map(entries.map((entry) => [entry.id, attr(entry.cell, "parent")]));
|
|
120
|
+
const layers = new Set(entries.filter((entry) => attr(entry.cell, "parent") === "0").map((entry) => entry.id));
|
|
121
|
+
const columns = Math.min(frames.length, width >= height ? 2 : 3);
|
|
122
|
+
const rows = Math.ceil(frames.length / columns);
|
|
123
|
+
const tileHeight = CAPTION_HEIGHT + height;
|
|
124
|
+
const serializer = new XMLSerializer();
|
|
125
|
+
const parts: string[] = [];
|
|
126
|
+
const dark = isDarkBackground(attr(model, "background"));
|
|
127
|
+
const captionColor = dark ? "#CBD5E1" : "#334155";
|
|
128
|
+
const frameColor = dark ? "#334155" : "#CBD5E1";
|
|
129
|
+
|
|
130
|
+
frames.forEach((frame, index) => {
|
|
131
|
+
const prefix = `f${index + 1}-`;
|
|
132
|
+
const ox = GAP + (index % columns) * (width + GAP);
|
|
133
|
+
const oy = GAP + Math.floor(index / columns) * (tileHeight + GAP);
|
|
134
|
+
const seconds = (frame.time / 1000).toFixed(1);
|
|
135
|
+
const caption = `${index + 1} · ${seconds}s · ${frame.label}`;
|
|
136
|
+
parts.push(
|
|
137
|
+
`<mxCell id="${prefix}frame" value="" style="rounded=1;absoluteArcSize=1;arcSize=16;fillColor=none;strokeColor=${frameColor};dashed=1;" vertex="1" parent="1"><mxGeometry x="${ox}" y="${oy + CAPTION_HEIGHT}" width="${width}" height="${height}" as="geometry"/></mxCell>`,
|
|
138
|
+
`<mxCell id="${prefix}caption" value="${escapeXml(caption)}" style="text;html=1;align=left;verticalAlign=middle;whiteSpace=wrap;fontSize=22;fontStyle=1;fontColor=${captionColor};" vertex="1" parent="1"><mxGeometry x="${ox}" y="${oy}" width="${width}" height="${CAPTION_HEIGHT - 8}" as="geometry"/></mxCell>`,
|
|
139
|
+
);
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
if (entry.id === "0" || layers.has(entry.id)) continue;
|
|
142
|
+
const element = storyboardCell(entry, prefix, layers, ox, oy + CAPTION_HEIGHT);
|
|
143
|
+
applyFrameStyle(element, entry.id, frame, parents);
|
|
144
|
+
parts.push(serializer.serializeToString(element as never));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const pageWidth = GAP + columns * (width + GAP);
|
|
149
|
+
const pageHeight = GAP + rows * (tileHeight + GAP);
|
|
150
|
+
const background = attr(model, "background");
|
|
151
|
+
const backgroundAttr = background ? ` background="${escapeXml(background)}"` : "";
|
|
152
|
+
return [
|
|
153
|
+
'<mxfile host="drawme">',
|
|
154
|
+
'<diagram name="Storyboard">',
|
|
155
|
+
`<mxGraphModel grid="0" page="1" pageScale="1" pageWidth="${pageWidth}" pageHeight="${pageHeight}"${backgroundAttr}>`,
|
|
156
|
+
'<root><mxCell id="0"/><mxCell id="1" parent="0"/>',
|
|
157
|
+
...parts,
|
|
158
|
+
"</root></mxGraphModel></diagram></mxfile>",
|
|
159
|
+
"",
|
|
160
|
+
].join("\n");
|
|
161
|
+
}
|
package/src/svgexport.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* draw.io SVG post-processing: an even outer margin, and authored colors.
|
|
3
|
+
*
|
|
4
|
+
* Pin draw.io SVG exports to their authored colors. draw.io wraps every color
|
|
5
|
+
* in CSS `light-dark(authored, generated-dark)` and declares
|
|
6
|
+
* `color-scheme: light dark`, so a viewer in dark mode sees an automatically
|
|
7
|
+
* inverted diagram that no longer matches the PNG/PDF output or the chosen
|
|
8
|
+
* theme. Resolving each `light-dark()` to its first argument makes every
|
|
9
|
+
* export show the same colors in every viewer.
|
|
10
|
+
*/
|
|
11
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
12
|
+
import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
|
|
13
|
+
import { type DomEl, TEXT_NODE, attr, elemChildren } from "./dom";
|
|
14
|
+
|
|
15
|
+
const FUNCTION = "light-dark(";
|
|
16
|
+
const CDATA_NODE = 4;
|
|
17
|
+
|
|
18
|
+
/** Replace every `light-dark(a, b)` in a CSS string with `a`, honoring nested parentheses. */
|
|
19
|
+
export function resolveLightDark(css: string): string {
|
|
20
|
+
let result = "";
|
|
21
|
+
let index = 0;
|
|
22
|
+
for (;;) {
|
|
23
|
+
const start = css.indexOf(FUNCTION, index);
|
|
24
|
+
if (start < 0) return result + css.slice(index);
|
|
25
|
+
const { depth, comma, cursor } = findFunctionEnd(css, start + FUNCTION.length);
|
|
26
|
+
if (depth !== 0) return result + css.slice(index);
|
|
27
|
+
const end = cursor - 1;
|
|
28
|
+
const first = css.slice(start + FUNCTION.length, comma < 0 ? end : comma).trim();
|
|
29
|
+
result += css.slice(index, start) + resolveLightDark(first);
|
|
30
|
+
index = cursor;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function findFunctionEnd(css: string, start: number): { depth: number; comma: number; cursor: number } {
|
|
35
|
+
let depth = 1;
|
|
36
|
+
let comma = -1;
|
|
37
|
+
let cursor = start;
|
|
38
|
+
for (; cursor < css.length && depth > 0; cursor++) {
|
|
39
|
+
const char = css[cursor];
|
|
40
|
+
if (char === "(") depth++;
|
|
41
|
+
else if (char === ")") depth--;
|
|
42
|
+
else if (char === "," && depth === 1 && comma < 0) comma = cursor;
|
|
43
|
+
}
|
|
44
|
+
return { depth, comma, cursor };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function pinColorScheme(style: string): string {
|
|
48
|
+
return style.replace(/color-scheme\s*:\s*[^;]*/g, "color-scheme: light");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function walk(root: DomEl): DomEl[] {
|
|
52
|
+
const elements: DomEl[] = [root];
|
|
53
|
+
for (const child of elemChildren(root)) elements.push(...walk(child));
|
|
54
|
+
return elements;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Return the SVG with all adaptive colors resolved to the authored ones. */
|
|
58
|
+
export function pinAuthoredColors(svg: string): string {
|
|
59
|
+
if (!svg.includes(FUNCTION) && !/color-scheme\s*:\s*light\s+dark/.test(svg)) return svg;
|
|
60
|
+
const doc = new DOMParser().parseFromString(svg, "image/svg+xml");
|
|
61
|
+
const root = doc.documentElement as unknown as DomEl | null;
|
|
62
|
+
if (root?.tagName !== "svg") throw new Error("draw.io output is not valid SVG");
|
|
63
|
+
for (const element of walk(root)) {
|
|
64
|
+
const style = attr(element, "style");
|
|
65
|
+
if (style !== null) element.setAttribute("style", pinColorScheme(resolveLightDark(style)));
|
|
66
|
+
if (element.tagName === "style") pinStyleText(element);
|
|
67
|
+
}
|
|
68
|
+
return new XMLSerializer().serializeToString(doc);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function pinStyleText(element: DomEl): void {
|
|
72
|
+
for (const node of Array.from(element.childNodes) as (DomEl & { data?: string })[]) {
|
|
73
|
+
if ((node.nodeType === TEXT_NODE || node.nodeType === CDATA_NODE) && node.data) {
|
|
74
|
+
node.data = resolveLightDark(node.data);
|
|
75
|
+
node.nodeValue = node.data;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function dimension(value: string | null): number | undefined {
|
|
81
|
+
const parsed = Number.parseFloat(value ?? "");
|
|
82
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Add an even outer margin to a borderless draw.io SVG: grow the canvas by
|
|
87
|
+
* `margin` on every side and shift the drawing (everything except `defs` and the
|
|
88
|
+
* full-size background rect) into the middle.
|
|
89
|
+
*/
|
|
90
|
+
export function padSvg(svg: string, margin: number): string {
|
|
91
|
+
if (margin <= 0 || Number.isNaN(margin)) return svg;
|
|
92
|
+
const doc = new DOMParser().parseFromString(svg, "image/svg+xml");
|
|
93
|
+
const root = doc.documentElement as unknown as DomEl | null;
|
|
94
|
+
if (root?.tagName !== "svg") throw new Error("draw.io output is not valid SVG");
|
|
95
|
+
const box = (attr(root, "viewBox") ?? "").trim().split(/[\s,]+/).map(Number);
|
|
96
|
+
const width = box.length === 4 && box.every(Number.isFinite) ? box[2] : dimension(attr(root, "width"));
|
|
97
|
+
const height = box.length === 4 && box.every(Number.isFinite) ? box[3] : dimension(attr(root, "height"));
|
|
98
|
+
if (width === undefined || height === undefined) throw new Error("SVG has no measurable size to pad");
|
|
99
|
+
const [minX, minY] = box.length === 4 && box.every(Number.isFinite) ? box : [0, 0];
|
|
100
|
+
|
|
101
|
+
const node = root as unknown as { appendChild(child: unknown): void };
|
|
102
|
+
const group = doc.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
103
|
+
group.setAttribute("transform", `translate(${margin - minX},${margin - minY})`);
|
|
104
|
+
group.setAttribute("data-drawme-margin", String(margin)); // NOSONAR: xmldom XML elements have no browser dataset API.
|
|
105
|
+
for (const child of elemChildren(root)) {
|
|
106
|
+
const background = child.tagName === "rect" && attr(child, "width") === "100%" && attr(child, "height") === "100%";
|
|
107
|
+
if (child.tagName === "defs" || child.tagName === "style" || background) continue;
|
|
108
|
+
group.appendChild(child as never);
|
|
109
|
+
}
|
|
110
|
+
node.appendChild(group);
|
|
111
|
+
const newWidth = Math.round((width + 2 * margin) * 100) / 100;
|
|
112
|
+
const newHeight = Math.round((height + 2 * margin) * 100) / 100;
|
|
113
|
+
root.setAttribute("viewBox", `0 0 ${newWidth} ${newHeight}`);
|
|
114
|
+
root.setAttribute("width", `${newWidth}px`);
|
|
115
|
+
root.setAttribute("height", `${newHeight}px`);
|
|
116
|
+
return new XMLSerializer().serializeToString(doc);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Finish an exported SVG file in place: even margin, then authored colors. */
|
|
120
|
+
export async function finishSvgFile(path: string, margin: number): Promise<void> {
|
|
121
|
+
const svg = await readFile(path, "utf8");
|
|
122
|
+
const finished = pinAuthoredColors(padSvg(svg, margin));
|
|
123
|
+
if (finished !== svg) await writeFile(path, finished, "utf8");
|
|
124
|
+
}
|
package/src/validate.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { readFile } from "node:fs/promises";
|
|
8
8
|
import { DOMParser } from "@xmldom/xmldom";
|
|
9
9
|
import { type DomEl, attr, childrenByTag, directText, firstByTag } from "./dom";
|
|
10
|
+
import { analyzeAnimationPage } from "./animation";
|
|
11
|
+
import { analyzeStoredMotion } from "./motion";
|
|
10
12
|
import {
|
|
11
13
|
type ById,
|
|
12
14
|
type ContentBounds,
|
|
@@ -639,16 +641,23 @@ function labelOffset(cell: DomEl): Point | null {
|
|
|
639
641
|
return [x, y];
|
|
640
642
|
}
|
|
641
643
|
|
|
644
|
+
/** Where an inline edge label is anchored along its route, as a 0..1 fraction (geometry x runs -1..1). */
|
|
645
|
+
function labelFraction(edge: DomEl): number {
|
|
646
|
+
const geometry = firstByTag(edge, "mxGeometry");
|
|
647
|
+
const along = geometry ? pyFloat(attr(geometry, "x") ?? "0") : 0;
|
|
648
|
+
return along !== undefined && Number.isFinite(along) ? Math.min(1, Math.max(0, (along + 1) / 2)) : 0.5;
|
|
649
|
+
}
|
|
650
|
+
|
|
642
651
|
/** Estimated box of an edge's inline label, centered on its explicit route like draw.io renders it. */
|
|
643
652
|
function inlineEdgeLabelRect(edge: DomEl, ids: ById): Rect | null {
|
|
653
|
+
const route = labelText(edge) ? edgeRoute(edge, ids) : null;
|
|
654
|
+
return route ? labelBox(edge, route) : null;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Estimated label box for an edge along a given route. */
|
|
658
|
+
function labelBox(edge: DomEl, route: Point[]): Rect {
|
|
644
659
|
const label = labelText(edge);
|
|
645
|
-
|
|
646
|
-
const route = edgeRoute(edge, ids);
|
|
647
|
-
if (!route) return null;
|
|
648
|
-
const geometry = firstByTag(edge, "mxGeometry");
|
|
649
|
-
const along = geometry ? pyFloat(attr(geometry, "x") ?? "0") : 0;
|
|
650
|
-
const fraction = along !== undefined && Number.isFinite(along) ? Math.min(1, Math.max(0, (along + 1) / 2)) : 0.5;
|
|
651
|
-
const [centerX, centerY] = routePointAt(route, fraction);
|
|
660
|
+
const [centerX, centerY] = routePointAt(route, labelFraction(edge));
|
|
652
661
|
const [offsetX, offsetY] = labelOffset(edge) ?? [0, 0];
|
|
653
662
|
const fontSize = styleNum(attr(edge, "style"), "fontSize") ?? DEFAULT_FONT_SIZE;
|
|
654
663
|
const lines = label.split("\n");
|
|
@@ -685,6 +694,135 @@ function labelOverlapWarnings(cells: DomEl[], ids: ById, parents: Set<string | n
|
|
|
685
694
|
return warnings;
|
|
686
695
|
}
|
|
687
696
|
|
|
697
|
+
/** Drop waypoints on a straight run and sub-2px jogs (not real bends), keeping the route's shape. */
|
|
698
|
+
function straightenRoute(points: Point[]): Point[] {
|
|
699
|
+
const near = (a: number, b: number): boolean => Math.abs(a - b) < 2;
|
|
700
|
+
const within = (value: number, a: number, b: number): boolean =>
|
|
701
|
+
Math.min(a, b) - 2 <= value && value <= Math.max(a, b) + 2;
|
|
702
|
+
const result: Point[] = [points[0]];
|
|
703
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
704
|
+
const previous = result.at(-1)!;
|
|
705
|
+
const [point, next] = [points[i], points[i + 1]];
|
|
706
|
+
const jog = near(point[0], previous[0]) && near(point[1], previous[1]);
|
|
707
|
+
const between = within(point[0], previous[0], next[0]) && within(point[1], previous[1], next[1]);
|
|
708
|
+
const run =
|
|
709
|
+
between &&
|
|
710
|
+
((near(previous[1], point[1]) && near(point[1], next[1])) ||
|
|
711
|
+
(near(previous[0], point[0]) && near(point[0], next[0])) ||
|
|
712
|
+
orient(previous, point, next) === 0);
|
|
713
|
+
if (!jog && !run) result.push(point);
|
|
714
|
+
}
|
|
715
|
+
result.push(points.at(-1)!);
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** True for a horizontal or vertical segment, the only kind whose rendered path is known for orthogonal routing. */
|
|
720
|
+
function axisAligned(a: Point, b: Point): boolean {
|
|
721
|
+
return Math.abs(a[0] - b[0]) < 2 || Math.abs(a[1] - b[1]) < 2;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function isOrthogonal(edge: DomEl): boolean {
|
|
725
|
+
const style = attr(edge, "style") ?? "";
|
|
726
|
+
return /(?:^|;)edgeStyle=(?:orthogonalEdgeStyle|elbowEdgeStyle)(?:;|$)/.test(style);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Rebuild the corners draw.io adds to a diagonal first or last segment of an
|
|
731
|
+
* orthogonal edge: it leaves a top/bottom exit vertically and a left/right exit
|
|
732
|
+
* horizontally, and mirrors that at the entry. Returns null when a diagonal
|
|
733
|
+
* remains whose rendered path cannot be inferred.
|
|
734
|
+
*/
|
|
735
|
+
function orthogonalRoute(edge: DomEl, route: Point[]): Point[] | null {
|
|
736
|
+
if (!isOrthogonal(edge)) return route;
|
|
737
|
+
const style = attr(edge, "style");
|
|
738
|
+
const side = (x: string, y: string): "vertical" | "horizontal" | null => {
|
|
739
|
+
const fy = styleNum(style, y);
|
|
740
|
+
const fx = styleNum(style, x);
|
|
741
|
+
if (fy === 0 || fy === 1) return "vertical";
|
|
742
|
+
if (fx === 0 || fx === 1) return "horizontal";
|
|
743
|
+
return null;
|
|
744
|
+
};
|
|
745
|
+
const points = [...route];
|
|
746
|
+
const last = points.length - 1;
|
|
747
|
+
if (!axisAligned(points[last - 1], points[last])) {
|
|
748
|
+
const entry = side("entryX", "entryY");
|
|
749
|
+
const [prev, end] = [points[last - 1], points[last]];
|
|
750
|
+
if (entry === "horizontal") points.splice(last, 0, [prev[0], end[1]]);
|
|
751
|
+
else if (entry === "vertical") points.splice(last, 0, [end[0], prev[1]]);
|
|
752
|
+
}
|
|
753
|
+
if (!axisAligned(points[0], points[1])) {
|
|
754
|
+
const exit = side("exitX", "exitY");
|
|
755
|
+
const [start, next] = [points[0], points[1]];
|
|
756
|
+
if (exit === "vertical") points.splice(1, 0, [start[0], next[1]]);
|
|
757
|
+
else if (exit === "horizontal") points.splice(1, 0, [next[0], start[1]]);
|
|
758
|
+
}
|
|
759
|
+
return points.slice(1).every((point, i) => axisAligned(points[i], point)) ? points : null;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/** Index of the route segment that holds the point at `fraction` of the route's length. */
|
|
763
|
+
function anchorSegment(points: Point[], fraction: number): number {
|
|
764
|
+
const lengths = points.slice(1).map((point, i) => Math.hypot(point[0] - points[i][0], point[1] - points[i][1]));
|
|
765
|
+
let remaining = lengths.reduce((sum, length) => sum + length, 0) * fraction;
|
|
766
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
767
|
+
if (remaining <= lengths[i]) return i;
|
|
768
|
+
remaining -= lengths[i];
|
|
769
|
+
}
|
|
770
|
+
return Math.max(0, lengths.length - 1);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Inline labels whose estimated box lands on a bend or another segment of
|
|
775
|
+
* their own connector (typically after an offset pushes them sideways), or on
|
|
776
|
+
* another explicitly routed connector. A background color cannot fix these:
|
|
777
|
+
* the line visibly runs into the text.
|
|
778
|
+
*/
|
|
779
|
+
function labelRouteWarnings(cells: DomEl[], ids: ById): string[] {
|
|
780
|
+
const routes: [string | null, Point[]][] = [];
|
|
781
|
+
for (const cell of cells) {
|
|
782
|
+
const route = visibleEdgeRoute(cell, ids);
|
|
783
|
+
if (route) routes.push([attr(cell, "id"), route]);
|
|
784
|
+
}
|
|
785
|
+
const warnings: string[] = [];
|
|
786
|
+
for (const cell of cells) {
|
|
787
|
+
const route = labelText(cell) ? visibleEdgeRoute(cell, ids) : null;
|
|
788
|
+
if (!route) continue;
|
|
789
|
+
const box = labelBox(cell, route);
|
|
790
|
+
if (hasInvalidNumber(box)) continue;
|
|
791
|
+
const id = attr(cell, "id");
|
|
792
|
+
warnings.push(...labelRouteIntersections(id, route, box, labelFraction(cell), routes));
|
|
793
|
+
}
|
|
794
|
+
return warnings;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function visibleEdgeRoute(cell: DomEl, ids: ById): Point[] | null {
|
|
798
|
+
if (cell.getAttribute("edge") !== "1" || !isVisible(cell, ids)) return null;
|
|
799
|
+
const explicit = edgeRoute(cell, ids);
|
|
800
|
+
return explicit ? orthogonalRoute(cell, straightenRoute(explicit)) : null;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
function labelRouteIntersections(
|
|
804
|
+
id: string | null,
|
|
805
|
+
route: Point[],
|
|
806
|
+
box: Rect,
|
|
807
|
+
fraction: number,
|
|
808
|
+
routes: [string | null, Point[]][],
|
|
809
|
+
): string[] {
|
|
810
|
+
const warnings: string[] = [];
|
|
811
|
+
const anchor = anchorSegment(route, fraction);
|
|
812
|
+
const hitsOwnRoute = route.slice(1).some((point, i) => i !== anchor && routeHitsRect([route[i], point], box));
|
|
813
|
+
if (hitsOwnRoute) {
|
|
814
|
+
warnings.push(
|
|
815
|
+
`edge label ${repr(id)} likely sits on a bend or another segment of its own connector; move it along the edge (geometry x) or change its offset so the text clears every segment`,
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
for (const [otherId, otherRoute] of routes) {
|
|
819
|
+
if (otherId !== id && routeHitsRect(otherRoute, box)) {
|
|
820
|
+
warnings.push(`edge label ${repr(id)} likely overlaps edge ${repr(otherId)}`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return warnings;
|
|
824
|
+
}
|
|
825
|
+
|
|
688
826
|
function labelOnLineWarning(cell: DomEl): string | null {
|
|
689
827
|
if (cell.getAttribute("edge") !== "1" || !labelText(cell)) return null;
|
|
690
828
|
if ((attr(cell, "style") ?? "").includes("labelBackgroundColor=")) return null;
|
|
@@ -765,7 +903,23 @@ function checkPage(diagram: DomEl): [string[], string[], string[]] {
|
|
|
765
903
|
const errors: string[] = [];
|
|
766
904
|
const warnings: string[] = [];
|
|
767
905
|
const observations: string[] = [];
|
|
906
|
+
const motion = analyzeStoredMotion(model);
|
|
768
907
|
const ids = buildIds(cells, errors);
|
|
908
|
+
const animation = analyzeAnimationPage(diagram);
|
|
909
|
+
errors.push(...animation.errors);
|
|
910
|
+
warnings.push(...animation.warnings);
|
|
911
|
+
observations.push(...animation.observations);
|
|
912
|
+
if (motion) {
|
|
913
|
+
errors.push(...motion.errors);
|
|
914
|
+
if (motion.compiled) {
|
|
915
|
+
observations.push(
|
|
916
|
+
`stored motion has ${motion.spec!.steps.length} step(s) lasting ${Math.round(motion.compiled.sequenceMs)}ms; export it with drawio_animate`,
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
if (animation.sequence?.enabled) {
|
|
920
|
+
errors.push("page has both stored motion and an enabled native page animation; keep only one timeline");
|
|
921
|
+
}
|
|
922
|
+
}
|
|
769
923
|
const parents = new Set<string | null>();
|
|
770
924
|
for (const cell of cells) parents.add(attr(cell, "parent"));
|
|
771
925
|
|
|
@@ -774,6 +928,7 @@ function checkPage(diagram: DomEl): [string[], string[], string[]] {
|
|
|
774
928
|
...overlapWarnings(cells, ids, parents),
|
|
775
929
|
...geometryWarnings(cells, ids, parents),
|
|
776
930
|
...labelOverlapWarnings(cells, ids, parents),
|
|
931
|
+
...labelRouteWarnings(cells, ids),
|
|
777
932
|
...containmentWarnings(cells, ids),
|
|
778
933
|
...readabilityWarnings(cells),
|
|
779
934
|
);
|
package/src/workflow.ts
CHANGED
|
@@ -17,6 +17,7 @@ export const AUTOMATIC_CORRECTION_LIMIT = 8;
|
|
|
17
17
|
export interface WorkflowReferences {
|
|
18
18
|
diagramTypes: string | null;
|
|
19
19
|
xmlAuthoring: string | null;
|
|
20
|
+
stylePresets: string | null;
|
|
20
21
|
/** Only provided when the CLI supports Mermaid conversion (v30+). */
|
|
21
22
|
mermaidAuthoring: string | null;
|
|
22
23
|
}
|
|
@@ -76,22 +77,22 @@ export function drawmeWorkflow(description: string, refDir: string, cli: DrawioI
|
|
|
76
77
|
"Produce a `.drawio` file and export it, following the workflow below. For anything that touches the draw.io CLI, use the DrawMe tools — do NOT shell out to `drawio` yourself. The references at the end of this message are already loaded: do not re-read those files.",
|
|
77
78
|
"",
|
|
78
79
|
cliStatus(cli),
|
|
79
|
-
"2. **Plan** — choose the diagram type, shapes, relationships, and layout direction (LR or TB). Plan generous spacing (200–350px between shapes) and do NOT fix page dimensions up front: the canvas is fitted to the finished content later with `drawio_fit_canvas`. For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), follow the diagram-types reference below." +
|
|
80
|
+
"2. **Plan** — choose the diagram type, shapes, relationships, and layout direction (LR or TB). Plan generous spacing (200–350px between shapes) and do NOT fix page dimensions up front: the canvas is fitted to the finished content later with `drawio_fit_canvas`. For a specific type (ERD, UML class, sequence, C4, architecture, ML/DL, flowchart, SysML, BPMN, network, swimlane), follow the diagram-types reference below. Pick one style preset from the style presets reference below: Light unless the user explicitly asks for a dark theme or for multiple colors (Dark, Multi-color, or both). Never choose Dark or Multi-color on your own. Set the theme's page background and use its colors, edge styles, and typography for every cell; take only structural style keys from the diagram-types reference, not its colors. If the request asks for movement, plan an animated SVG: a `drawio_animate` motion story (entrances, connector draw-ins, travelling dots, highlights, dimming) following the preset reference's motion design section, persistent connector flow for continuous direction, or both; use a portable page sequence only when draw.io's own viewer must play the animation. Also plan a static PNG fallback unless the user explicitly asks for SVG only." +
|
|
80
81
|
mermaidPlanning,
|
|
81
|
-
"3. **Author** — for hand-written XML, follow the XML authoring reference below. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Space elements generously rather than packing them, then run `drawio_fit_canvas` after authoring — and again after any Mermaid conversion or layout — so the page wraps the content with a comfortable margin. Treat every write, edit, Mermaid conversion, layout, and canvas-fit result as a source edit.",
|
|
82
|
-
"4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.",
|
|
82
|
+
"3. **Author** — for hand-written XML, follow the XML authoring reference below. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For animation, author the complete static diagram first and add motion afterwards with `drawio_animate`; do not hand-write page animation JSON for effects it covers. Connector flow stays in edge styles. Never hide a cell with `visible=0` when the animation needs to reveal it. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Space elements generously rather than packing them, then run `drawio_fit_canvas` after authoring — and again after any Mermaid conversion or layout — so the page wraps the content with a comfortable margin. Treat every write, edit, Mermaid conversion, layout, and canvas-fit result as a source edit.",
|
|
83
|
+
"4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export. For animated SVG, unsupported page effects are blocking rather than acceptable because final animation verification will reject them.",
|
|
83
84
|
"5. **Visual review — three focused passes, then a holistic confirmation** — run this once authoring and validation are clean. Export previews with `drawio_export` mode `\"preview\"`; every preview renders a single page, so for a multi-page file, export one preview per page with `pageIndex` and review every page (page-suffixed names, e.g. `<name>.review-p2-fit.png`). The result text states whether the preview image is attached; follow the matching path:",
|
|
84
85
|
" - **Image attached** — run the four passes below in order. Do not start the next pass until every finding of the current one is verified **fixed** in a fresh render or explicitly accepted with a reason. For each pass: export its preview, write a structured critique that hunts for defects — do not summarize or admire the diagram — answer the pass's questions explicitly (a bare \"yes\" is not an answer; point at the evidence in the image), and record findings in one numbered ledger kept for the rest of the run: `F1, F2, …: pass / severity / affected cell ids / what is visibly wrong and where in the image / planned fix` (pick fixes from the defect→fix recipes in the XML authoring reference). The critique's job is to narrow every problem down to specific cells so the fix step can be surgical.",
|
|
85
86
|
" 1. **Pass 1 — fit and sizing** (`<name>.review-fit.png`) answers: does the diagram fit its page, and does the canvas or any element need resizing? Hunt: content touching or crossing a page edge; one outer margin visibly thinner than the others; large empty regions or a page far larger than its content; elements too small for their labels — text touching or crossing its own shape border, clipped or mid-word truncated; a smallest label you cannot comfortably read at full-diagram scale (tighten the canvas with `drawio_fit_canvas`, split content across pages, or simplify the layout — never judge what you cannot read, and never treat \"too small to tell\" as a pass).",
|
|
86
87
|
" 2. **Pass 2 — element placement** (`<name>.review-layout.png`) answers: is every element positioned correctly, and is there a visibly better arrangement? Hunt: shapes whose borders touch or overlap; two labels touching or overlapping each other; label text lying on top of any line or unrelated shape; rows/columns that drift out of alignment; uneven gaps between peers; children poking out of their container or crowding its title; related elements far apart while unrelated ones sit adjacent. Improve, not only repair: if moving an element would shorten edges, remove crossings, or make the arrangement symmetric, record that as a finding too.",
|
|
87
88
|
" 3. **Pass 3 — connections** (`<name>.review-connectors.png`) answers: is every connection correct, cleanly routed, symmetric where the layout is symmetric, and anchored to the middle of the element side it faces wherever possible? Trace every edge from source to target and check it against the plan — right source, right target, right direction, right label. Hunt: an endpoint floating off its shape or plunging deep into it; an edge entering at an odd corner when a side-center anchor is available (pin `exitX`/`exitY`/`entryX`/`entryY` to the facing side's center, spreading evenly only when several edges share one side); mirrored branches routed asymmetrically; an arrowhead hidden by a shape or crushed into a bend; an edge passing through a shape it does not connect; parallel edges stacked on top of each other; an edge label sitting on its line so the text is struck through, or closer than about half a text-height to any line; crossings a reroute through a free corridor would remove.",
|
|
88
89
|
" Heed `drawio_validate` anchor warnings literally: re-pin an exit or entry to the suggested facing side before adding waypoints. Treat predicted route-through observations as focused preview-review hints, not proof of draw.io's rendered route; add waypoints or move a shape only when the preview confirms the obstruction.",
|
|
89
|
-
" 4. **Pass 4 — typography, semantics, and regression** (`<name>.review.png`) is the holistic confirmation. Read every label word for word — a label you cannot fully read is itself a finding; check text contrast against fills; confirm every requested component and relationship is present, pointing the right way, with the right label; check hierarchy, grouping, and that legend entries match the colors actually used; apply the type's `Review:` checklist from the diagram-types reference; and re-check passes 1–3 for regressions. Retain this image (every page, for a multi-page file) for the final report.",
|
|
90
|
+
" 4. **Pass 4 — typography, semantics, and regression** (`<name>.review.png`) is the holistic confirmation. Read every label word for word — a label you cannot fully read is itself a finding; check text contrast against fills; confirm every requested component and relationship is present, pointing the right way, with the right label; check hierarchy, grouping, and that legend entries match the colors actually used; apply the type's `Review:` checklist from the diagram-types reference; and re-check passes 1–3 for regressions. For animation, cross-check the sequence order, cell ids, durations, direction, loop setting, and reduced-motion/static fallback structurally; the PNG preview is intentionally static and must not be presented as temporal playback proof. Review the motion itself on the `drawio_animate` storyboard after this pass. Retain this image (every page, for a multi-page file) for the final report.",
|
|
90
91
|
" - **Image NOT attached** — the current model cannot view images. Skip the visual passes: do not describe or judge renders; review structurally instead by cross-checking `drawio_validate` findings and a `drawio_explain` read-back against the user's request. Keep the latest `<name>.review.png` on disk so the user can view it, and state plainly in the summary that rendered inspection was skipped.",
|
|
91
92
|
"6. **Fix and verify before the next pass** — resolve a pass's findings with targeted source edits: after each edit, validate, then re-export the same pass preview (for a multi-page file, the page the finding is on). The superseded preview file is deleted from disk, but its image is still visible earlier in this conversation: compare the new image against it at each addressed finding's location and record a verdict — **fixed** (the defect is gone in the new render), **not fixed** (still visible), or **regressed** (the edit introduced a new defect; log it as a new numbered finding). Never mark a finding fixed because the XML changed — only because the new image shows it fixed. When elements overlap, are cramped, clipped, or short on margin, never shrink or squeeze elements to fit the page — move them apart, then run `drawio_fit_canvas` to enlarge the canvas around them. A pass is complete only when all of its findings are fixed or explicitly accepted, and every pass must be complete before final export. If the correction limit is reached mid-pass, finish the remaining passes as inspection-only and report their findings as unresolved. Each successful preview export automatically removes the previous preview file for the same source, so only the latest review image remains.",
|
|
92
93
|
`7. **Correction limit** — pass inspection previews (the first preview of each pass) do not count against the limit. Across the whole review, allow at most ${AUTOMATIC_CORRECTION_LIMIT} correction retries; one retry is one targeted source-edit → \`drawio_validate\` → replacement-preview cycle, whatever its verdict. Count retries explicitly. If the limit is reached with a finding unresolved, stop automatic editing, keep the best validated state, and continue to final export — name the unresolved finding, its pass, and its last verdict plainly in the final report instead of looping or waiting for input.`,
|
|
93
94
|
"8. **No human gate** — the run is fully autonomous: once started, never pause to ask for approval, confirmation, or feedback. When pass 4 is clean (or the correction limit was reached), proceed directly to final export. If the user interrupts with feedback mid-run, append it to the ledger as new numbered findings: targeted edit, validate, before/after confirmation on the relevant pass preview, a fresh pass-4 holistic preview, then continue to export.",
|
|
94
|
-
"9. **Final export** — immediately after pass 4 is clean (or the correction limit was reached), call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). A final export
|
|
95
|
+
"9. **Final export** — immediately after pass 4 is clean (or the correction limit was reached), call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). When motion was requested, the primary deliverable is a `drawio_animate` call with the planned steps. Check its storyboard frame by frame against the planned story; when a frame shows the wrong order or visibility, fix the steps and call it again (each call counts as one correction retry). For a page whose only motion is connector flow or a native page sequence, call `drawio_export` with `animated: true` and `format: \"svg\"` instead. Read the result and report animation as successful only when it says `Animation verified`. Also export the planned static PNG fallback unless the user requested SVG only. Animated mode never supports preview, PNG, PDF, or JPG. A final export renders a single page: for a multi-page file, export each page with `pageIndex` and a distinct `output` per page and format. The first successful final export removes the one remaining latest preview for the same source; do not delete previews yourself or report it as a retained output. Report the `.drawio` source and every final path, whether animation verification passed, retained reviewed warnings, any unresolved finding from the correction limit, and cleanup warnings. Offer `drawio_open` for fine-tuning afterwards.",
|
|
95
96
|
"",
|
|
96
97
|
"Failure handling: several DrawMe tools report failures as a text result beginning with `Export failed`, `Layout failed`, `Mermaid conversion failed`, `Fit canvas failed`, `Explain failed`, or `Open failed` rather than a tool error — always read the result text and treat those as failures. If export fails, read `" +
|
|
97
98
|
refDir +
|
|
@@ -103,6 +104,7 @@ export function drawmeWorkflow(description: string, refDir: string, cli: DrawioI
|
|
|
103
104
|
"",
|
|
104
105
|
...referenceSection("diagram types", `${refDir}/diagram-types.md`, refs.diagramTypes),
|
|
105
106
|
...referenceSection("XML authoring", `${refDir}/xml-authoring.md`, refs.xmlAuthoring),
|
|
107
|
+
...referenceSection("style presets", `${refDir}/style-presets.md`, refs.stylePresets),
|
|
106
108
|
...(refs.mermaidAuthoring !== null || cli.supportsMermaid
|
|
107
109
|
? referenceSection("Mermaid authoring", `${refDir}/mermaid-authoring.md`, refs.mermaidAuthoring)
|
|
108
110
|
: []),
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<mxfile host="drawio" version="31.1.5">
|
|
3
|
-
<diagram id="drawme-waterfall" name="High-level overview">
|
|
4
|
-
<mxGraphModel dx="1640" dy="1040" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1620" pageHeight="1040" math="0" shadow="0">
|
|
5
|
-
<root>
|
|
6
|
-
<mxCell id="0"/>
|
|
7
|
-
<mxCell id="1" parent="0"/>
|
|
8
|
-
|
|
9
|
-
<mxCell id="title" value="DrawMe Pi Extension" style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;fontSize=30;fontStyle=1;fontColor=#173B67;strokeColor=none;fillColor=none;spacing=0;" vertex="1" parent="1">
|
|
10
|
-
<mxGeometry x="40" y="40" width="900" height="40" as="geometry"/>
|
|
11
|
-
</mxCell>
|
|
12
|
-
<mxCell id="subtitle" value="High-level waterfall overview | request → governed authoring → editable deliverables" style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;fontSize=16;fontColor=#52657A;strokeColor=none;fillColor=none;spacing=0;" vertex="1" parent="1">
|
|
13
|
-
<mxGeometry x="40" y="90" width="980" height="30" as="geometry"/>
|
|
14
|
-
</mxCell>
|
|
15
|
-
<mxCell id="cli-badge" value="draw.io CLI 31.1.5 | v30+ features active" style="rounded=1;arcSize=24;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#23623B;fillColor=#E8F6EC;strokeColor=#3A9D5D;strokeWidth=1;spacing=8;" vertex="1" parent="1">
|
|
16
|
-
<mxGeometry x="1280" y="50" width="300" height="40" as="geometry"/>
|
|
17
|
-
</mxCell>
|
|
18
|
-
|
|
19
|
-
<mxCell id="stage-01" value="<b><font style="font-size:18px">01</font> Request</b><br><font color="#40566F">Natural-language intent arrives through <b>/drawme</b> in the Pi agent.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#173B67;fillColor=#EAF2FF;strokeColor=#4C78C2;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
20
|
-
<mxGeometry x="40" y="170" width="280" height="110" as="geometry"/>
|
|
21
|
-
</mxCell>
|
|
22
|
-
<mxCell id="stage-02" value="<b><font style="font-size:18px">02</font> Guided orchestration</b><br><font color="#40566F"><b>workflow.ts</b> injects the nine-step autonomous process.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#173B67;fillColor=#EAF2FF;strokeColor=#4C78C2;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
23
|
-
<mxGeometry x="250" y="290" width="280" height="110" as="geometry"/>
|
|
24
|
-
</mxCell>
|
|
25
|
-
<mxCell id="stage-03" value="<b><font style="font-size:18px">03</font> Author editable source</b><br><font color="#6B4A21">Uncompressed XML or Mermaid; exact shape search and optional ELK layout.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#7A4515;fillColor=#FFF1E6;strokeColor=#E67E22;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
26
|
-
<mxGeometry x="460" y="410" width="280" height="110" as="geometry"/>
|
|
27
|
-
</mxCell>
|
|
28
|
-
<mxCell id="stage-04" value="<b><font style="font-size:18px">04</font> Validate every revision</b><br><font color="#66551D"><b>validate.ts</b> blocks broken IDs, bad geometry, unsafe routes and anchors, overlaps, and label collisions.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#66500E;fillColor=#FFF8DD;strokeColor=#C89B1D;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
29
|
-
<mxGeometry x="670" y="530" width="280" height="110" as="geometry"/>
|
|
30
|
-
</mxCell>
|
|
31
|
-
<mxCell id="stage-05" value="<b><font style="font-size:18px">05</font> Preview, critique, refine</b><br><font color="#66551D">Four gated review passes; targeted fixes are revalidated (max 8 corrections).</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#66500E;fillColor=#FFF8DD;strokeColor=#C89B1D;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
32
|
-
<mxGeometry x="880" y="650" width="280" height="110" as="geometry"/>
|
|
33
|
-
</mxCell>
|
|
34
|
-
<mxCell id="stage-06" value="<b><font style="font-size:18px">06</font> Holistic confirmation</b><br><font color="#66551D">The latest holistic preview is re-checked across all categories; the run continues straight to final export.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#66500E;fillColor=#FFF8DD;strokeColor=#C89B1D;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
35
|
-
<mxGeometry x="1090" y="770" width="280" height="110" as="geometry"/>
|
|
36
|
-
</mxCell>
|
|
37
|
-
<mxCell id="stage-07" value="<b><font style="font-size:18px">07</font> Export deliverables</b><br><font color="#2B5D3C"><b>drawio.ts</b> invokes the local CLI → .drawio source plus PNG / SVG / PDF / JPG; XML embedded where supported.</font>" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=14;fontColor=#23623B;fillColor=#E8F6EC;strokeColor=#3A9D5D;strokeWidth=2;spacing=14;shadow=1;" vertex="1" parent="1">
|
|
38
|
-
<mxGeometry x="1300" y="890" width="280" height="110" as="geometry"/>
|
|
39
|
-
</mxCell>
|
|
40
|
-
|
|
41
|
-
<mxCell id="edge-01-02" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-01" target="stage-02">
|
|
42
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="355" y="258"/></Array></mxGeometry>
|
|
43
|
-
</mxCell>
|
|
44
|
-
<mxCell id="edge-02-03" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-02" target="stage-03">
|
|
45
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="565" y="378"/></Array></mxGeometry>
|
|
46
|
-
</mxCell>
|
|
47
|
-
<mxCell id="edge-03-04" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-03" target="stage-04">
|
|
48
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="775" y="498"/></Array></mxGeometry>
|
|
49
|
-
</mxCell>
|
|
50
|
-
<mxCell id="edge-04-05" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-04" target="stage-05">
|
|
51
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="985" y="618"/></Array></mxGeometry>
|
|
52
|
-
</mxCell>
|
|
53
|
-
<mxCell id="edge-05-06" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-05" target="stage-06">
|
|
54
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1195" y="738"/></Array></mxGeometry>
|
|
55
|
-
</mxCell>
|
|
56
|
-
<mxCell id="edge-06-07" value="" style="edgeStyle=none;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;endSize=10;strokeColor=#60738A;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="stage-06" target="stage-07">
|
|
57
|
-
<mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="1405" y="858"/></Array></mxGeometry>
|
|
58
|
-
</mxCell>
|
|
59
|
-
|
|
60
|
-
<mxCell id="surface-note" value="<b><font style="font-size:17px">Extension surface</font></b><br><br><b>3 commands</b> /drawme · /drawme-check · /drawme-export<br><b>9 model tools</b> check · export · validate · fit · shapes · Mermaid · layout · explain · open<br><b>Pure TypeScript</b> validation · canvas fit · shape search · explanation<br><b>CLI adapter</b> render · convert · layout · open · PNG repair" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=top;fontSize=13;fontColor=#34495E;fillColor=#F7F9FC;strokeColor=#A9B7C6;strokeWidth=1;spacing=16;shadow=0;" vertex="1" parent="1">
|
|
61
|
-
<mxGeometry x="40" y="450" width="400" height="220" as="geometry"/>
|
|
62
|
-
</mxCell>
|
|
63
|
-
<mxCell id="legend" value="<b>Color key</b><br><font color="#4C78C2">■</font> Interface and control <font color="#E67E22">■</font> Authoring<br><font color="#C89B1D">■</font> Quality and confirmation <font color="#3A9D5D">■</font> Deliverable" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=13;fontColor=#34495E;fillColor=#FFFFFF;strokeColor=#C8D1DC;strokeWidth=1;spacing=14;" vertex="1" parent="1">
|
|
64
|
-
<mxGeometry x="40" y="710" width="420" height="100" as="geometry"/>
|
|
65
|
-
</mxCell>
|
|
66
|
-
<mxCell id="trust-note" value="<b>Trust boundary</b><br>Pi may use the configured model; diagram files, structural validation, the shape index, and draw.io CLI execution remain on the local machine." style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;fontSize=13;fontColor=#44546A;fillColor=#F4F6F8;strokeColor=#8996A5;strokeWidth=1;dashed=1;dashPattern=6 4;spacing=14;" vertex="1" parent="1">
|
|
67
|
-
<mxGeometry x="40" y="850" width="720" height="100" as="geometry"/>
|
|
68
|
-
</mxCell>
|
|
69
|
-
</root>
|
|
70
|
-
</mxGraphModel>
|
|
71
|
-
</diagram>
|
|
72
|
-
</mxfile>
|