callman-core 1.28.1 → 1.29.0
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/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/outputSchemas.d.ts +3 -0
- package/dist/ai/outputSchemas.d.ts.map +1 -1
- package/dist/ai/outputSchemas.js +1 -0
- package/dist/ai/outputSchemas.js.map +1 -1
- package/dist/ai/parse/diagram.d.ts.map +1 -1
- package/dist/ai/parse/diagram.js +6 -3
- package/dist/ai/parse/diagram.js.map +1 -1
- package/dist/ai/prompts/diagram.d.ts +7 -3
- package/dist/ai/prompts/diagram.d.ts.map +1 -1
- package/dist/ai/prompts/diagram.js +44 -5
- package/dist/ai/prompts/diagram.js.map +1 -1
- package/dist/ai/types.d.ts +6 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/diagram/bpmn/derive.d.ts +74 -0
- package/dist/diagram/bpmn/derive.d.ts.map +1 -0
- package/dist/diagram/bpmn/derive.js +392 -0
- package/dist/diagram/bpmn/derive.js.map +1 -0
- package/dist/diagram/bpmn/index.d.ts +7 -0
- package/dist/diagram/bpmn/index.d.ts.map +1 -0
- package/dist/diagram/bpmn/index.js +12 -0
- package/dist/diagram/bpmn/index.js.map +1 -0
- package/dist/diagram/bpmn/patch.d.ts +14 -0
- package/dist/diagram/bpmn/patch.d.ts.map +1 -0
- package/dist/diagram/bpmn/patch.js +770 -0
- package/dist/diagram/bpmn/patch.js.map +1 -0
- package/dist/diagram/bpmn/place.d.ts +4 -0
- package/dist/diagram/bpmn/place.d.ts.map +1 -0
- package/dist/diagram/bpmn/place.js +65 -0
- package/dist/diagram/bpmn/place.js.map +1 -0
- package/dist/diagram/bpmn/serialize.d.ts +12 -0
- package/dist/diagram/bpmn/serialize.d.ts.map +1 -0
- package/dist/diagram/bpmn/serialize.js +292 -0
- package/dist/diagram/bpmn/serialize.js.map +1 -0
- package/dist/diagram/bpmn/types.d.ts +42 -0
- package/dist/diagram/bpmn/types.d.ts.map +1 -0
- package/dist/diagram/bpmn/types.js +84 -0
- package/dist/diagram/bpmn/types.js.map +1 -0
- package/dist/diagram/bpmn/xml.d.ts +60 -0
- package/dist/diagram/bpmn/xml.d.ts.map +1 -0
- package/dist/diagram/bpmn/xml.js +342 -0
- package/dist/diagram/bpmn/xml.js.map +1 -0
- package/dist/diagram/elkGraph.d.ts +1 -3
- package/dist/diagram/elkGraph.d.ts.map +1 -1
- package/dist/diagram/elkGraph.js +1 -0
- package/dist/diagram/elkGraph.js.map +1 -1
- package/dist/diagram/fixtures.d.ts +10 -0
- package/dist/diagram/fixtures.d.ts.map +1 -0
- package/dist/diagram/fixtures.js +113 -0
- package/dist/diagram/fixtures.js.map +1 -0
- package/dist/diagram/geometry.d.ts +27 -0
- package/dist/diagram/geometry.d.ts.map +1 -0
- package/dist/diagram/geometry.js +122 -0
- package/dist/diagram/geometry.js.map +1 -0
- package/dist/diagram/history.d.ts +36 -0
- package/dist/diagram/history.d.ts.map +1 -0
- package/dist/diagram/history.js +54 -0
- package/dist/diagram/history.js.map +1 -0
- package/dist/diagram/ids.d.ts +5 -0
- package/dist/diagram/ids.d.ts.map +1 -0
- package/dist/diagram/ids.js +52 -0
- package/dist/diagram/ids.js.map +1 -0
- package/dist/diagram/index.d.ts +14 -2
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.js +20 -8
- package/dist/diagram/index.js.map +1 -1
- package/dist/diagram/layout.d.ts +107 -0
- package/dist/diagram/layout.d.ts.map +1 -0
- package/dist/diagram/layout.js +356 -0
- package/dist/diagram/layout.js.map +1 -0
- package/dist/diagram/mermaid/derive.d.ts +55 -0
- package/dist/diagram/mermaid/derive.d.ts.map +1 -0
- package/dist/diagram/mermaid/derive.js +343 -0
- package/dist/diagram/mermaid/derive.js.map +1 -0
- package/dist/diagram/mermaid/index.d.ts +8 -0
- package/dist/diagram/mermaid/index.d.ts.map +1 -0
- package/dist/diagram/mermaid/index.js +24 -0
- package/dist/diagram/mermaid/index.js.map +1 -0
- package/dist/diagram/mermaid/parse.d.ts +96 -0
- package/dist/diagram/mermaid/parse.d.ts.map +1 -0
- package/dist/diagram/mermaid/parse.js +672 -0
- package/dist/diagram/mermaid/parse.js.map +1 -0
- package/dist/diagram/mermaid/patch.d.ts +16 -0
- package/dist/diagram/mermaid/patch.d.ts.map +1 -0
- package/dist/diagram/mermaid/patch.js +463 -0
- package/dist/diagram/mermaid/patch.js.map +1 -0
- package/dist/diagram/mermaid/serialize.d.ts +14 -0
- package/dist/diagram/mermaid/serialize.d.ts.map +1 -0
- package/dist/diagram/mermaid/serialize.js +125 -0
- package/dist/diagram/mermaid/serialize.js.map +1 -0
- package/dist/diagram/mermaid/shapes.d.ts +11 -0
- package/dist/diagram/mermaid/shapes.d.ts.map +1 -0
- package/dist/diagram/mermaid/shapes.js +320 -0
- package/dist/diagram/mermaid/shapes.js.map +1 -0
- package/dist/diagram/migrations.d.ts +1 -0
- package/dist/diagram/migrations.d.ts.map +1 -1
- package/dist/diagram/migrations.js +7 -2
- package/dist/diagram/migrations.js.map +1 -1
- package/dist/diagram/normalize.d.ts +9 -1
- package/dist/diagram/normalize.d.ts.map +1 -1
- package/dist/diagram/normalize.js +194 -0
- package/dist/diagram/normalize.js.map +1 -1
- package/dist/diagram/ops.d.ts +146 -0
- package/dist/diagram/ops.d.ts.map +1 -0
- package/dist/diagram/ops.js +823 -0
- package/dist/diagram/ops.js.map +1 -0
- package/dist/diagram/opsReference.d.ts +3 -0
- package/dist/diagram/opsReference.d.ts.map +1 -0
- package/dist/diagram/opsReference.js +51 -0
- package/dist/diagram/opsReference.js.map +1 -0
- package/dist/diagram/patchInput.d.ts +193 -0
- package/dist/diagram/patchInput.d.ts.map +1 -0
- package/dist/diagram/patchInput.js +621 -0
- package/dist/diagram/patchInput.js.map +1 -0
- package/dist/diagram/routing/batch.d.ts +45 -0
- package/dist/diagram/routing/batch.d.ts.map +1 -0
- package/dist/diagram/routing/batch.js +136 -0
- package/dist/diagram/routing/batch.js.map +1 -0
- package/dist/diagram/routing/curves.d.ts +7 -0
- package/dist/diagram/routing/curves.d.ts.map +1 -0
- package/dist/diagram/routing/curves.js +120 -0
- package/dist/diagram/routing/curves.js.map +1 -0
- package/dist/diagram/routing/grid.d.ts +15 -0
- package/dist/diagram/routing/grid.d.ts.map +1 -0
- package/dist/diagram/routing/grid.js +245 -0
- package/dist/diagram/routing/grid.js.map +1 -0
- package/dist/diagram/routing/index.d.ts +10 -0
- package/dist/diagram/routing/index.d.ts.map +1 -0
- package/dist/diagram/routing/index.js +10 -0
- package/dist/diagram/routing/index.js.map +1 -0
- package/dist/diagram/routing/legacy.d.ts +6 -0
- package/dist/diagram/routing/legacy.d.ts.map +1 -0
- package/dist/diagram/routing/legacy.js +27 -0
- package/dist/diagram/routing/legacy.js.map +1 -0
- package/dist/diagram/routing/nudge.d.ts +4 -0
- package/dist/diagram/routing/nudge.d.ts.map +1 -0
- package/dist/diagram/routing/nudge.js +96 -0
- package/dist/diagram/routing/nudge.js.map +1 -0
- package/dist/diagram/routing/orthogonal.d.ts +6 -0
- package/dist/diagram/routing/orthogonal.d.ts.map +1 -0
- package/dist/diagram/routing/orthogonal.js +56 -0
- package/dist/diagram/routing/orthogonal.js.map +1 -0
- package/dist/diagram/routing/path.d.ts +16 -0
- package/dist/diagram/routing/path.d.ts.map +1 -0
- package/dist/diagram/routing/path.js +128 -0
- package/dist/diagram/routing/path.js.map +1 -0
- package/dist/diagram/routing/sides.d.ts +22 -0
- package/dist/diagram/routing/sides.d.ts.map +1 -0
- package/dist/diagram/routing/sides.js +74 -0
- package/dist/diagram/routing/sides.js.map +1 -0
- package/dist/diagram/routing/types.d.ts +46 -0
- package/dist/diagram/routing/types.d.ts.map +1 -0
- package/dist/diagram/routing/types.js +11 -0
- package/dist/diagram/routing/types.js.map +1 -0
- package/dist/diagram/schema.d.ts +70 -37
- package/dist/diagram/schema.d.ts.map +1 -1
- package/dist/diagram/schema.js +62 -8
- package/dist/diagram/schema.js.map +1 -1
- package/dist/diagram/styleInput.d.ts +41 -0
- package/dist/diagram/styleInput.d.ts.map +1 -0
- package/dist/diagram/styleInput.js +105 -0
- package/dist/diagram/styleInput.js.map +1 -0
- package/dist/diagram/views.d.ts +9 -0
- package/dist/diagram/views.d.ts.map +1 -0
- package/dist/diagram/views.js +42 -0
- package/dist/diagram/views.js.map +1 -0
- package/dist-cjs/ai/index.js.map +1 -1
- package/dist-cjs/ai/outputSchemas.js +1 -0
- package/dist-cjs/ai/outputSchemas.js.map +1 -1
- package/dist-cjs/ai/parse/diagram.js +6 -3
- package/dist-cjs/ai/parse/diagram.js.map +1 -1
- package/dist-cjs/ai/prompts/diagram.js +44 -5
- package/dist-cjs/ai/prompts/diagram.js.map +1 -1
- package/dist-cjs/diagram/bpmn/derive.js +398 -0
- package/dist-cjs/diagram/bpmn/derive.js.map +1 -0
- package/dist-cjs/diagram/bpmn/index.js +31 -0
- package/dist-cjs/diagram/bpmn/index.js.map +1 -0
- package/dist-cjs/diagram/bpmn/patch.js +774 -0
- package/dist-cjs/diagram/bpmn/patch.js.map +1 -0
- package/dist-cjs/diagram/bpmn/place.js +69 -0
- package/dist-cjs/diagram/bpmn/place.js.map +1 -0
- package/dist-cjs/diagram/bpmn/serialize.js +299 -0
- package/dist-cjs/diagram/bpmn/serialize.js.map +1 -0
- package/dist-cjs/diagram/bpmn/types.js +99 -0
- package/dist-cjs/diagram/bpmn/types.js.map +1 -0
- package/dist-cjs/diagram/bpmn/xml.js +367 -0
- package/dist-cjs/diagram/bpmn/xml.js.map +1 -0
- package/dist-cjs/diagram/elkGraph.js +1 -0
- package/dist-cjs/diagram/elkGraph.js.map +1 -1
- package/dist-cjs/diagram/fixtures.js +117 -0
- package/dist-cjs/diagram/fixtures.js.map +1 -0
- package/dist-cjs/diagram/geometry.js +143 -0
- package/dist-cjs/diagram/geometry.js.map +1 -0
- package/dist-cjs/diagram/history.js +65 -0
- package/dist-cjs/diagram/history.js.map +1 -0
- package/dist-cjs/diagram/ids.js +58 -0
- package/dist-cjs/diagram/ids.js.map +1 -0
- package/dist-cjs/diagram/index.js +23 -8
- package/dist-cjs/diagram/index.js.map +1 -1
- package/dist-cjs/diagram/layout.js +364 -0
- package/dist-cjs/diagram/layout.js.map +1 -0
- package/dist-cjs/diagram/mermaid/derive.js +353 -0
- package/dist-cjs/diagram/mermaid/derive.js.map +1 -0
- package/dist-cjs/diagram/mermaid/index.js +44 -0
- package/dist-cjs/diagram/mermaid/index.js.map +1 -0
- package/dist-cjs/diagram/mermaid/parse.js +681 -0
- package/dist-cjs/diagram/mermaid/parse.js.map +1 -0
- package/dist-cjs/diagram/mermaid/patch.js +468 -0
- package/dist-cjs/diagram/mermaid/patch.js.map +1 -0
- package/dist-cjs/diagram/mermaid/serialize.js +133 -0
- package/dist-cjs/diagram/mermaid/serialize.js.map +1 -0
- package/dist-cjs/diagram/mermaid/shapes.js +327 -0
- package/dist-cjs/diagram/mermaid/shapes.js.map +1 -0
- package/dist-cjs/diagram/migrations.js +9 -3
- package/dist-cjs/diagram/migrations.js.map +1 -1
- package/dist-cjs/diagram/normalize.js +198 -1
- package/dist-cjs/diagram/normalize.js.map +1 -1
- package/dist-cjs/diagram/ops.js +829 -0
- package/dist-cjs/diagram/ops.js.map +1 -0
- package/dist-cjs/diagram/opsReference.js +55 -0
- package/dist-cjs/diagram/opsReference.js.map +1 -0
- package/dist-cjs/diagram/patchInput.js +636 -0
- package/dist-cjs/diagram/patchInput.js.map +1 -0
- package/dist-cjs/diagram/routing/batch.js +142 -0
- package/dist-cjs/diagram/routing/batch.js.map +1 -0
- package/dist-cjs/diagram/routing/curves.js +127 -0
- package/dist-cjs/diagram/routing/curves.js.map +1 -0
- package/dist-cjs/diagram/routing/grid.js +250 -0
- package/dist-cjs/diagram/routing/grid.js.map +1 -0
- package/dist-cjs/diagram/routing/index.js +29 -0
- package/dist-cjs/diagram/routing/index.js.map +1 -0
- package/dist-cjs/diagram/routing/legacy.js +32 -0
- package/dist-cjs/diagram/routing/legacy.js.map +1 -0
- package/dist-cjs/diagram/routing/nudge.js +100 -0
- package/dist-cjs/diagram/routing/nudge.js.map +1 -0
- package/dist-cjs/diagram/routing/orthogonal.js +62 -0
- package/dist-cjs/diagram/routing/orthogonal.js.map +1 -0
- package/dist-cjs/diagram/routing/path.js +137 -0
- package/dist-cjs/diagram/routing/path.js.map +1 -0
- package/dist-cjs/diagram/routing/sides.js +82 -0
- package/dist-cjs/diagram/routing/sides.js.map +1 -0
- package/dist-cjs/diagram/routing/types.js +15 -0
- package/dist-cjs/diagram/routing/types.js.map +1 -0
- package/dist-cjs/diagram/schema.js +64 -9
- package/dist-cjs/diagram/schema.js.map +1 -1
- package/dist-cjs/diagram/styleInput.js +113 -0
- package/dist-cjs/diagram/styleInput.js.map +1 -0
- package/dist-cjs/diagram/views.js +46 -0
- package/dist-cjs/diagram/views.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const fmt = (n) => (Number.isInteger(n) ? String(n) : n.toFixed(2).replace(/\.?0+$/, ""));
|
|
2
|
+
// Orthogonal polylines get rounded corners of `radius` (clamped to half the
|
|
3
|
+
// shorter adjacent segment); straight polylines are sharp; curved paths use
|
|
4
|
+
// their cubic segments.
|
|
5
|
+
export const svgPathFromRoute = (route, radius = 8) => {
|
|
6
|
+
const { points } = route;
|
|
7
|
+
if (points.length === 0)
|
|
8
|
+
return "";
|
|
9
|
+
if (route.kind === "curved" && route.curves) {
|
|
10
|
+
let d = `M ${fmt(points[0].x)} ${fmt(points[0].y)}`;
|
|
11
|
+
for (const [c1, c2, end] of route.curves) {
|
|
12
|
+
d += ` C ${fmt(c1.x)} ${fmt(c1.y)} ${fmt(c2.x)} ${fmt(c2.y)} ${fmt(end.x)} ${fmt(end.y)}`;
|
|
13
|
+
}
|
|
14
|
+
return d;
|
|
15
|
+
}
|
|
16
|
+
if (route.kind !== "orthogonal" || radius <= 0 || points.length < 3) {
|
|
17
|
+
return points.map((p, i) => `${i === 0 ? "M" : "L"} ${fmt(p.x)} ${fmt(p.y)}`).join(" ");
|
|
18
|
+
}
|
|
19
|
+
let d = `M ${fmt(points[0].x)} ${fmt(points[0].y)}`;
|
|
20
|
+
for (let i = 1; i < points.length - 1; i += 1) {
|
|
21
|
+
const prev = points[i - 1];
|
|
22
|
+
const corner = points[i];
|
|
23
|
+
const next = points[i + 1];
|
|
24
|
+
const inLen = Math.hypot(corner.x - prev.x, corner.y - prev.y);
|
|
25
|
+
const outLen = Math.hypot(next.x - corner.x, next.y - corner.y);
|
|
26
|
+
const r = Math.min(radius, inLen / 2, outLen / 2);
|
|
27
|
+
if (r <= 0.01) {
|
|
28
|
+
d += ` L ${fmt(corner.x)} ${fmt(corner.y)}`;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const a = { x: corner.x - ((corner.x - prev.x) / inLen) * r, y: corner.y - ((corner.y - prev.y) / inLen) * r };
|
|
32
|
+
const b = { x: corner.x + ((next.x - corner.x) / outLen) * r, y: corner.y + ((next.y - corner.y) / outLen) * r };
|
|
33
|
+
d += ` L ${fmt(a.x)} ${fmt(a.y)} Q ${fmt(corner.x)} ${fmt(corner.y)} ${fmt(b.x)} ${fmt(b.y)}`;
|
|
34
|
+
}
|
|
35
|
+
const last = points[points.length - 1];
|
|
36
|
+
d += ` L ${fmt(last.x)} ${fmt(last.y)}`;
|
|
37
|
+
return d;
|
|
38
|
+
};
|
|
39
|
+
const cubicAt = (p0, c1, c2, p1, t) => {
|
|
40
|
+
const mt = 1 - t;
|
|
41
|
+
return {
|
|
42
|
+
x: mt * mt * mt * p0.x + 3 * mt * mt * t * c1.x + 3 * mt * t * t * c2.x + t * t * t * p1.x,
|
|
43
|
+
y: mt * mt * mt * p0.y + 3 * mt * mt * t * c1.y + 3 * mt * t * t * c2.y + t * t * t * p1.y,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// Polyline approximation used for lengths and sampling (curves flattened).
|
|
47
|
+
export const flattenRoute = (route, steps = 12) => {
|
|
48
|
+
if (route.kind !== "curved" || !route.curves)
|
|
49
|
+
return route.points;
|
|
50
|
+
const out = [route.points[0]];
|
|
51
|
+
let from = route.points[0];
|
|
52
|
+
for (const [c1, c2, end] of route.curves) {
|
|
53
|
+
for (let i = 1; i <= steps; i += 1)
|
|
54
|
+
out.push(cubicAt(from, c1, c2, end, i / steps));
|
|
55
|
+
from = end;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
};
|
|
59
|
+
export const routeLength = (route) => {
|
|
60
|
+
const pts = flattenRoute(route);
|
|
61
|
+
let length = 0;
|
|
62
|
+
for (let i = 1; i < pts.length; i += 1)
|
|
63
|
+
length += Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
|
|
64
|
+
return length;
|
|
65
|
+
};
|
|
66
|
+
// Point at fraction `t` (0..1) of the path length, plus the tangent angle in
|
|
67
|
+
// radians — where an edge label or toolbar sits.
|
|
68
|
+
export const pointAlongRoute = (route, t) => {
|
|
69
|
+
const pts = flattenRoute(route);
|
|
70
|
+
if (pts.length === 0)
|
|
71
|
+
return { point: { x: 0, y: 0 }, angle: 0 };
|
|
72
|
+
if (pts.length === 1)
|
|
73
|
+
return { point: pts[0], angle: 0 };
|
|
74
|
+
const total = routeLength(route);
|
|
75
|
+
let remaining = Math.min(1, Math.max(0, t)) * total;
|
|
76
|
+
for (let i = 1; i < pts.length; i += 1) {
|
|
77
|
+
const a = pts[i - 1];
|
|
78
|
+
const b = pts[i];
|
|
79
|
+
const segment = Math.hypot(b.x - a.x, b.y - a.y);
|
|
80
|
+
if (remaining <= segment || i === pts.length - 1) {
|
|
81
|
+
const k = segment === 0 ? 0 : remaining / segment;
|
|
82
|
+
return { point: { x: a.x + (b.x - a.x) * k, y: a.y + (b.y - a.y) * k }, angle: Math.atan2(b.y - a.y, b.x - a.x) };
|
|
83
|
+
}
|
|
84
|
+
remaining -= segment;
|
|
85
|
+
}
|
|
86
|
+
const last = pts[pts.length - 1];
|
|
87
|
+
return { point: last, angle: 0 };
|
|
88
|
+
};
|
|
89
|
+
// The fraction along the path nearest to `point` — dragging a label.
|
|
90
|
+
export const nearestFraction = (route, point) => {
|
|
91
|
+
const pts = flattenRoute(route);
|
|
92
|
+
const total = routeLength(route);
|
|
93
|
+
if (total === 0 || pts.length < 2)
|
|
94
|
+
return 0.5;
|
|
95
|
+
let best = 0;
|
|
96
|
+
let bestDistance = Infinity;
|
|
97
|
+
let walked = 0;
|
|
98
|
+
for (let i = 1; i < pts.length; i += 1) {
|
|
99
|
+
const a = pts[i - 1];
|
|
100
|
+
const b = pts[i];
|
|
101
|
+
const dx = b.x - a.x;
|
|
102
|
+
const dy = b.y - a.y;
|
|
103
|
+
const segment = Math.hypot(dx, dy);
|
|
104
|
+
const k = segment === 0 ? 0 : Math.min(1, Math.max(0, ((point.x - a.x) * dx + (point.y - a.y) * dy) / (segment * segment)));
|
|
105
|
+
const px = a.x + dx * k;
|
|
106
|
+
const py = a.y + dy * k;
|
|
107
|
+
const distance = Math.hypot(point.x - px, point.y - py);
|
|
108
|
+
if (distance < bestDistance) {
|
|
109
|
+
bestDistance = distance;
|
|
110
|
+
best = (walked + segment * k) / total;
|
|
111
|
+
}
|
|
112
|
+
walked += segment;
|
|
113
|
+
}
|
|
114
|
+
return best;
|
|
115
|
+
};
|
|
116
|
+
// Midpoints of the interior segments of an orthogonal route — where the
|
|
117
|
+
// canvas shows drag handles that create manual bends.
|
|
118
|
+
export const segmentMidpoints = (route) => {
|
|
119
|
+
const out = [];
|
|
120
|
+
const pts = route.points;
|
|
121
|
+
for (let i = 1; i < pts.length - 2; i += 1) {
|
|
122
|
+
const a = pts[i];
|
|
123
|
+
const b = pts[i + 1];
|
|
124
|
+
out.push({ index: i, point: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, horizontal: Math.abs(a.y - b.y) < 1e-6 });
|
|
125
|
+
}
|
|
126
|
+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;QACjB,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Rect } from "../geometry.js";
|
|
2
|
+
import type { Point } from "../schema.js";
|
|
3
|
+
import type { Side, Terminal } from "./types.js";
|
|
4
|
+
export interface Sides {
|
|
5
|
+
source: Side;
|
|
6
|
+
target: Side;
|
|
7
|
+
}
|
|
8
|
+
export declare const chooseSides: (source: Rect, target: Rect, fixed?: {
|
|
9
|
+
source?: Side;
|
|
10
|
+
target?: Side;
|
|
11
|
+
}, previous?: {
|
|
12
|
+
source?: Side;
|
|
13
|
+
target?: Side;
|
|
14
|
+
}) => Sides;
|
|
15
|
+
export declare const sidesFor: (source: Terminal, target: Terminal, previous?: {
|
|
16
|
+
source?: Side;
|
|
17
|
+
target?: Side;
|
|
18
|
+
}) => Sides;
|
|
19
|
+
export declare const sideVector: (side: Side) => Point;
|
|
20
|
+
export declare const attachPoint: (terminal: Terminal, side: Side) => Point;
|
|
21
|
+
export declare const boundaryToward: (rect: Rect, toward: Point) => Point;
|
|
22
|
+
//# sourceMappingURL=sides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sides.d.ts","sourceRoot":"","sources":["../../../src/diagram/routing/sides.ts"],"names":[],"mappings":"AAKA,OAAO,EAA4B,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;CACd;AAaD,eAAO,MAAM,WAAW,GACtB,QAAQ,IAAI,EACZ,QAAQ,IAAI,EACZ,QAAO;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CAAO,EAC5C,WAAW;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,KAC1C,KAuBF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,EAAE,WAAW;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,KAAG,KACZ,CAAC;AAEhG,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,KAAG,KAYvC,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,UAAU,QAAQ,EAAE,MAAM,IAAI,KAAG,KAA4D,CAAC;AAI1H,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,EAAE,QAAQ,KAAK,KAAG,KAS1D,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Which side of each node a FLOATING edge leaves from / arrives at. draw.io's
|
|
2
|
+
// rule: the pair of facing sides along the axis with the larger gap; when
|
|
3
|
+
// the rectangles overlap on both axes, the sides the centre vector points
|
|
4
|
+
// through. A previous choice is kept while the gaps are nearly equal so a
|
|
5
|
+
// node dragged along the diagonal does not flip its edges every frame.
|
|
6
|
+
import { rectCenter, sideMidpoint } from "../geometry.js";
|
|
7
|
+
const HYSTERESIS = 24;
|
|
8
|
+
const sideToward = (from, to) => {
|
|
9
|
+
const center = rectCenter(from);
|
|
10
|
+
const dx = to.x - center.x;
|
|
11
|
+
const dy = to.y - center.y;
|
|
12
|
+
// Compare against the rectangle's aspect so wide nodes prefer left/right.
|
|
13
|
+
if (Math.abs(dx) * from.height >= Math.abs(dy) * from.width)
|
|
14
|
+
return dx >= 0 ? "right" : "left";
|
|
15
|
+
return dy >= 0 ? "bottom" : "top";
|
|
16
|
+
};
|
|
17
|
+
export const chooseSides = (source, target, fixed = {}, previous) => {
|
|
18
|
+
if (fixed.source && fixed.target)
|
|
19
|
+
return { source: fixed.source, target: fixed.target };
|
|
20
|
+
if (fixed.source)
|
|
21
|
+
return { source: fixed.source, target: sideToward(target, sideMidpoint(source, fixed.source)) };
|
|
22
|
+
if (fixed.target)
|
|
23
|
+
return { source: sideToward(source, sideMidpoint(target, fixed.target)), target: fixed.target };
|
|
24
|
+
const gapX = Math.max(target.x - (source.x + source.width), source.x - (target.x + target.width));
|
|
25
|
+
const gapY = Math.max(target.y - (source.y + source.height), source.y - (target.y + target.height));
|
|
26
|
+
const sc = rectCenter(source);
|
|
27
|
+
const tc = rectCenter(target);
|
|
28
|
+
let horizontal;
|
|
29
|
+
if (previous?.source && previous.target && Math.abs(gapX - gapY) < HYSTERESIS) {
|
|
30
|
+
horizontal = previous.source === "left" || previous.source === "right";
|
|
31
|
+
}
|
|
32
|
+
else if (gapX < 0 && gapY < 0) {
|
|
33
|
+
// Overlapping on both axes: go by the centre vector.
|
|
34
|
+
horizontal = Math.abs(tc.x - sc.x) >= Math.abs(tc.y - sc.y);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
horizontal = gapX >= gapY;
|
|
38
|
+
}
|
|
39
|
+
if (horizontal) {
|
|
40
|
+
return tc.x >= sc.x ? { source: "right", target: "left" } : { source: "left", target: "right" };
|
|
41
|
+
}
|
|
42
|
+
return tc.y >= sc.y ? { source: "bottom", target: "top" } : { source: "top", target: "bottom" };
|
|
43
|
+
};
|
|
44
|
+
export const sidesFor = (source, target, previous) => chooseSides(source.rect, target.rect, { source: source.side, target: target.side }, previous);
|
|
45
|
+
export const sideVector = (side) => {
|
|
46
|
+
switch (side) {
|
|
47
|
+
case "top":
|
|
48
|
+
return { x: 0, y: -1 };
|
|
49
|
+
case "bottom":
|
|
50
|
+
return { x: 0, y: 1 };
|
|
51
|
+
case "left":
|
|
52
|
+
return { x: -1, y: 0 };
|
|
53
|
+
case "right":
|
|
54
|
+
default:
|
|
55
|
+
return { x: 1, y: 0 };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// The point on the boundary where a terminal attaches: the explicit point
|
|
59
|
+
// when given (legacy anchors, free ends), else the side's midpoint.
|
|
60
|
+
export const attachPoint = (terminal, side) => terminal.point ?? sideMidpoint(terminal.rect, side);
|
|
61
|
+
// Where the straight line from the rectangle's centre toward `toward` leaves
|
|
62
|
+
// the rectangle — used by straight and curved edges so they meet the outline.
|
|
63
|
+
export const boundaryToward = (rect, toward) => {
|
|
64
|
+
const c = rectCenter(rect);
|
|
65
|
+
const dx = toward.x - c.x;
|
|
66
|
+
const dy = toward.y - c.y;
|
|
67
|
+
if (dx === 0 && dy === 0)
|
|
68
|
+
return { x: c.x, y: rect.y };
|
|
69
|
+
const hw = rect.width / 2;
|
|
70
|
+
const hh = rect.height / 2;
|
|
71
|
+
const scale = Math.min(hw / Math.max(Math.abs(dx), 1e-9), hh / Math.max(Math.abs(dy), 1e-9));
|
|
72
|
+
return { x: c.x + dx * scale, y: c.y + dy * scale };
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=sides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sides.js","sourceRoot":"","sources":["../../../src/diagram/routing/sides.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,uEAAuE;AACvE,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
|
+
import type { Rect } from "../geometry.js";
|
|
2
|
+
import type { DiagramRouting, HandleSide, Point } from "../schema.js";
|
|
3
|
+
export type { Rect } from "../geometry.js";
|
|
4
|
+
export type Side = HandleSide;
|
|
5
|
+
export interface Terminal {
|
|
6
|
+
rect: Rect;
|
|
7
|
+
side?: Side;
|
|
8
|
+
point?: Point;
|
|
9
|
+
}
|
|
10
|
+
export interface RoutedPath {
|
|
11
|
+
points: Point[];
|
|
12
|
+
kind: "orthogonal" | "straight" | "curved";
|
|
13
|
+
sourceSide: Side;
|
|
14
|
+
targetSide: Side;
|
|
15
|
+
curves?: Array<[Point, Point, Point]>;
|
|
16
|
+
via: "orthogonal" | "smart" | "smart-fallback" | "straight" | "curved" | "waypoints" | "legacy";
|
|
17
|
+
}
|
|
18
|
+
export interface RouteOptions {
|
|
19
|
+
margin?: number;
|
|
20
|
+
cornerRadius?: number;
|
|
21
|
+
bendPenalty?: number;
|
|
22
|
+
hugPenalty?: number;
|
|
23
|
+
nudgeGap?: number;
|
|
24
|
+
regionPad?: number;
|
|
25
|
+
smartObstacleLimit?: number;
|
|
26
|
+
previous?: {
|
|
27
|
+
source?: Side;
|
|
28
|
+
target?: Side;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ResolvedRouteOptions {
|
|
32
|
+
margin: number;
|
|
33
|
+
cornerRadius: number;
|
|
34
|
+
bendPenalty: number;
|
|
35
|
+
hugPenalty: number;
|
|
36
|
+
nudgeGap: number;
|
|
37
|
+
regionPad: number;
|
|
38
|
+
smartObstacleLimit: number;
|
|
39
|
+
previous?: {
|
|
40
|
+
source?: Side;
|
|
41
|
+
target?: Side;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export declare const resolveRouteOptions: (options?: RouteOptions) => ResolvedRouteOptions;
|
|
45
|
+
export type { DiagramRouting, Point };
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.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C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,IAAI,CAAA;KAAE,CAAC;CAC7C;AAED,eAAO,MAAM,mBAAmB,GAAI,UAAS,YAAiB,KAAG,oBAS/D,CAAC;AAEH,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const resolveRouteOptions = (options = {}) => ({
|
|
2
|
+
margin: options.margin ?? 24,
|
|
3
|
+
cornerRadius: options.cornerRadius ?? 8,
|
|
4
|
+
bendPenalty: options.bendPenalty ?? 30,
|
|
5
|
+
hugPenalty: options.hugPenalty ?? 6,
|
|
6
|
+
nudgeGap: options.nudgeGap ?? 6,
|
|
7
|
+
regionPad: options.regionPad ?? 200,
|
|
8
|
+
smartObstacleLimit: options.smartObstacleLimit ?? 60,
|
|
9
|
+
previous: options.previous,
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/diagram/routing/types.ts"],"names":[],"mappings":"AA+DA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAwB,EAAE,EAAwB,EAAE,CAAC,CAAC;IACxF,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;IAC5B,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC;IACvC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;IACtC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,GAAG;IACnC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;IACpD,QAAQ,EAAE,OAAO,CAAC,QAAQ;CAC3B,CAAC,CAAC"}
|
package/dist/diagram/schema.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export declare const SCHEMA_VERSION: 1;
|
|
2
|
-
export type DiagramRouting = "orthogonal" | "straight" | "curved";
|
|
2
|
+
export type DiagramRouting = "orthogonal" | "straight" | "curved" | "smart";
|
|
3
|
+
export declare const DIAGRAM_ROUTINGS: readonly DiagramRouting[];
|
|
3
4
|
export type ArrowType = "none" | "classic" | "classicThin" | "open" | "block" | "diamond" | "oval";
|
|
5
|
+
export declare const ARROW_TYPES: readonly ArrowType[];
|
|
6
|
+
export type HandleSide = "top" | "right" | "bottom" | "left";
|
|
7
|
+
export declare const HANDLE_SIDES: readonly HandleSide[];
|
|
8
|
+
export declare const isHandleSide: (value: unknown) => value is HandleSide;
|
|
9
|
+
export interface Point {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Size {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}
|
|
4
17
|
export type TokenRef = {
|
|
5
18
|
token: string;
|
|
6
19
|
} | {
|
|
@@ -24,59 +37,55 @@ export interface DiagramStyle {
|
|
|
24
37
|
shadow?: boolean;
|
|
25
38
|
opacity?: number;
|
|
26
39
|
}
|
|
40
|
+
export interface LegacyAnchor {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
dx?: number;
|
|
44
|
+
dy?: number;
|
|
45
|
+
perimeter?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface DiagramCallmanBinding {
|
|
48
|
+
kind: "request" | "scenario" | "connection" | "environment" | "mock" | "kafkaTopic";
|
|
49
|
+
id: string;
|
|
50
|
+
workspaceId?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
}
|
|
27
53
|
export interface DiagramNode {
|
|
28
54
|
id: string;
|
|
29
55
|
type: string;
|
|
30
|
-
position:
|
|
31
|
-
|
|
32
|
-
y: number;
|
|
33
|
-
};
|
|
34
|
-
size: {
|
|
35
|
-
width: number;
|
|
36
|
-
height: number;
|
|
37
|
-
};
|
|
56
|
+
position: Point;
|
|
57
|
+
size: Size;
|
|
38
58
|
label?: string;
|
|
39
59
|
rotation?: number;
|
|
40
60
|
style?: DiagramStyle;
|
|
41
|
-
data?: Record<string, unknown
|
|
61
|
+
data?: Record<string, unknown> & {
|
|
62
|
+
callman?: DiagramCallmanBinding;
|
|
63
|
+
};
|
|
42
64
|
parentId?: string;
|
|
43
|
-
z?: number;
|
|
44
65
|
hidden?: boolean;
|
|
45
66
|
locked?: boolean;
|
|
67
|
+
collapsed?: boolean;
|
|
68
|
+
collapsedSize?: Size;
|
|
69
|
+
/** @deprecated never read or written — array order IS the z-order. Stripped by normalizeDocument. */
|
|
70
|
+
z?: number;
|
|
46
71
|
}
|
|
47
72
|
export interface DiagramEdge {
|
|
48
73
|
id: string;
|
|
49
74
|
source?: string;
|
|
50
75
|
target?: string;
|
|
51
|
-
sourcePoint?:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
y: number;
|
|
58
|
-
};
|
|
59
|
-
sourceAnchor?: {
|
|
60
|
-
x: number;
|
|
61
|
-
y: number;
|
|
62
|
-
dx?: number;
|
|
63
|
-
dy?: number;
|
|
64
|
-
perimeter?: boolean;
|
|
65
|
-
};
|
|
66
|
-
targetAnchor?: {
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
dx?: number;
|
|
70
|
-
dy?: number;
|
|
71
|
-
perimeter?: boolean;
|
|
72
|
-
};
|
|
76
|
+
sourcePoint?: Point;
|
|
77
|
+
targetPoint?: Point;
|
|
78
|
+
sourceAnchor?: LegacyAnchor;
|
|
79
|
+
targetAnchor?: LegacyAnchor;
|
|
80
|
+
sourceHandle?: HandleSide;
|
|
81
|
+
targetHandle?: HandleSide;
|
|
73
82
|
label?: string;
|
|
83
|
+
labelPosition?: number;
|
|
84
|
+
labelOffset?: Point;
|
|
74
85
|
routing?: DiagramRouting;
|
|
75
86
|
style?: DiagramStyle;
|
|
76
|
-
waypoints?:
|
|
77
|
-
|
|
78
|
-
y: number;
|
|
79
|
-
}>;
|
|
87
|
+
waypoints?: Point[];
|
|
88
|
+
data?: Record<string, unknown>;
|
|
80
89
|
markerStart?: ArrowType;
|
|
81
90
|
markerEnd?: ArrowType;
|
|
82
91
|
}
|
|
@@ -85,10 +94,33 @@ export interface DiagramMeta {
|
|
|
85
94
|
createdAt: string;
|
|
86
95
|
updatedAt: string;
|
|
87
96
|
appVersion?: string;
|
|
97
|
+
revision?: number;
|
|
88
98
|
}
|
|
99
|
+
export type LayoutAlgorithm = "layered" | "tree" | "organic" | "radial" | "force";
|
|
100
|
+
export type LayoutDirection = "DOWN" | "RIGHT" | "UP" | "LEFT";
|
|
101
|
+
export declare const LAYOUT_DIRECTIONS: readonly LayoutDirection[];
|
|
89
102
|
export interface DiagramCanvasState {
|
|
90
103
|
background?: "grid" | "dots" | "blank";
|
|
91
104
|
gridSize?: number;
|
|
105
|
+
viewport?: {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
zoom: number;
|
|
109
|
+
};
|
|
110
|
+
layout?: {
|
|
111
|
+
algorithm: LayoutAlgorithm;
|
|
112
|
+
direction: LayoutDirection;
|
|
113
|
+
};
|
|
114
|
+
defaultRouting?: DiagramRouting;
|
|
115
|
+
}
|
|
116
|
+
export type DiagramSourceFormat = "mermaid" | "bpmn";
|
|
117
|
+
export interface DiagramSource {
|
|
118
|
+
format: DiagramSourceFormat;
|
|
119
|
+
text: string;
|
|
120
|
+
diagramType: string;
|
|
121
|
+
grammar?: string;
|
|
122
|
+
hash?: string;
|
|
123
|
+
valid?: boolean;
|
|
92
124
|
}
|
|
93
125
|
export interface DiagramDocument {
|
|
94
126
|
schemaVersion: number;
|
|
@@ -97,6 +129,7 @@ export interface DiagramDocument {
|
|
|
97
129
|
canvas?: DiagramCanvasState;
|
|
98
130
|
nodes: DiagramNode[];
|
|
99
131
|
edges: DiagramEdge[];
|
|
132
|
+
source?: DiagramSource;
|
|
100
133
|
}
|
|
101
134
|
export declare const nowIso: () => string;
|
|
102
135
|
export declare const genId: (prefix?: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/diagram/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/diagram/schema.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AAMzC,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC5E,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAAkD,CAAC;AAEzG,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACnG,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAA2E,CAAC;AAIxH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC7D,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAuC,CAAC;AACtF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,UAC2B,CAAC;AAEnF,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM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AC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAG5B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAID,eAAO,MAAM,MAAM,QAAO,MAAkC,CAAC;AAiB7D,eAAO,MAAM,KAAK,GAAI,eAAa,KAAG,MAKrC,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,cAA0B,KAAG,eAUhE,CAAC;AAIF,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE;CAK7B;AAsED,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAuBzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,eAIrD,CAAC"}
|
package/dist/diagram/schema.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
// The diagram DSL — the single source of truth for a diagram. A plain,
|
|
2
|
-
// versioned, git-diffable JSON model that is independent of any renderer
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// versioned, git-diffable JSON model that is independent of any renderer.
|
|
3
|
+
// AI generation, the MCP server, DB persistence and the desktop editor all
|
|
4
|
+
// produce/consume exactly this shape, and every EDIT — from the canvas, from
|
|
5
|
+
// an AI reply, from an MCP tool — is an operation on it (see ops.ts).
|
|
6
|
+
//
|
|
7
|
+
// Versioning policy: `schemaVersion` stays 1 while the shape only GROWS
|
|
8
|
+
// (optional fields). Every reader ignores keys it does not know, so a newer
|
|
9
|
+
// document still opens in an older host; a breaking change bumps the version
|
|
10
|
+
// and registers a step in migrations.ts. The additive fields of the rebuilt
|
|
11
|
+
// studio are marked "(1.29)" below.
|
|
5
12
|
//
|
|
6
|
-
// Moved here from the desktop so every host validates with ONE validator.
|
|
7
13
|
// zod is intentionally NOT used: the hand validator keeps the module
|
|
8
14
|
// dependency-free and CSP-safe (it runs in the Electron renderer).
|
|
9
15
|
export const SCHEMA_VERSION = 1;
|
|
16
|
+
export const DIAGRAM_ROUTINGS = ["orthogonal", "straight", "curved", "smart"];
|
|
17
|
+
export const ARROW_TYPES = ["none", "classic", "classicThin", "open", "block", "diamond", "oval"];
|
|
18
|
+
export const HANDLE_SIDES = ["top", "right", "bottom", "left"];
|
|
19
|
+
export const isHandleSide = (value) => typeof value === "string" && HANDLE_SIDES.includes(value);
|
|
20
|
+
export const LAYOUT_DIRECTIONS = ["DOWN", "RIGHT", "UP", "LEFT"];
|
|
10
21
|
// --- id + time helpers -----------------------------------------------------
|
|
11
22
|
export const nowIso = () => new Date().toISOString();
|
|
12
23
|
const randomBytes = (length) => {
|
|
@@ -55,6 +66,8 @@ export class DiagramValidationError extends Error {
|
|
|
55
66
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
56
67
|
const isNum = (v) => typeof v === "number" && Number.isFinite(v);
|
|
57
68
|
const isStr = (v) => typeof v === "string";
|
|
69
|
+
const isPoint = (v) => isObject(v) && isNum(v.x) && isNum(v.y);
|
|
70
|
+
const isSize = (v) => isObject(v) && isNum(v.width) && isNum(v.height);
|
|
58
71
|
const validateNode = (n, i, errors) => {
|
|
59
72
|
if (!isObject(n))
|
|
60
73
|
return void errors.push(`nodes[${i}] is not an object`);
|
|
@@ -62,12 +75,15 @@ const validateNode = (n, i, errors) => {
|
|
|
62
75
|
errors.push(`nodes[${i}].id must be a string`);
|
|
63
76
|
if (!isStr(n.type))
|
|
64
77
|
errors.push(`nodes[${i}].type must be a string`);
|
|
65
|
-
if (!
|
|
78
|
+
if (!isPoint(n.position))
|
|
66
79
|
errors.push(`nodes[${i}].position must be { x:number, y:number }`);
|
|
67
|
-
if (!
|
|
80
|
+
if (!isSize(n.size))
|
|
68
81
|
errors.push(`nodes[${i}].size must be { width:number, height:number }`);
|
|
82
|
+
if (n.collapsedSize !== undefined && !isSize(n.collapsedSize))
|
|
83
|
+
errors.push(`nodes[${i}].collapsedSize must be { width:number, height:number }`);
|
|
84
|
+
if (n.parentId !== undefined && !isStr(n.parentId))
|
|
85
|
+
errors.push(`nodes[${i}].parentId must be a string`);
|
|
69
86
|
};
|
|
70
|
-
const isPoint = (v) => isObject(v) && isNum(v.x) && isNum(v.y);
|
|
71
87
|
const validateEdge = (e, i, ids, errors) => {
|
|
72
88
|
if (!isObject(e))
|
|
73
89
|
return void errors.push(`edges[${i}] is not an object`);
|
|
@@ -93,6 +109,42 @@ const validateEdge = (e, i, ids, errors) => {
|
|
|
93
109
|
else if (!isPoint(e.targetPoint)) {
|
|
94
110
|
errors.push(`edges[${i}] needs a target id or a targetPoint { x, y }`);
|
|
95
111
|
}
|
|
112
|
+
if (e.sourceHandle !== undefined && !isHandleSide(e.sourceHandle))
|
|
113
|
+
errors.push(`edges[${i}].sourceHandle must be one of ${HANDLE_SIDES.join(", ")}`);
|
|
114
|
+
if (e.targetHandle !== undefined && !isHandleSide(e.targetHandle))
|
|
115
|
+
errors.push(`edges[${i}].targetHandle must be one of ${HANDLE_SIDES.join(", ")}`);
|
|
116
|
+
if (e.routing !== undefined && !DIAGRAM_ROUTINGS.includes(e.routing))
|
|
117
|
+
errors.push(`edges[${i}].routing must be one of ${DIAGRAM_ROUTINGS.join(", ")}`);
|
|
118
|
+
if (e.labelPosition !== undefined && !isNum(e.labelPosition))
|
|
119
|
+
errors.push(`edges[${i}].labelPosition must be a number`);
|
|
120
|
+
if (e.labelOffset !== undefined && !isPoint(e.labelOffset))
|
|
121
|
+
errors.push(`edges[${i}].labelOffset must be { x:number, y:number }`);
|
|
122
|
+
if (e.waypoints !== undefined && (!Array.isArray(e.waypoints) || !e.waypoints.every(isPoint)))
|
|
123
|
+
errors.push(`edges[${i}].waypoints must be an array of { x:number, y:number }`);
|
|
124
|
+
};
|
|
125
|
+
const validateCanvas = (c, errors) => {
|
|
126
|
+
if (c === undefined)
|
|
127
|
+
return;
|
|
128
|
+
if (!isObject(c))
|
|
129
|
+
return void errors.push("canvas must be an object");
|
|
130
|
+
if (c.viewport !== undefined && !(isObject(c.viewport) && isNum(c.viewport.x) && isNum(c.viewport.y) && isNum(c.viewport.zoom)))
|
|
131
|
+
errors.push("canvas.viewport must be { x, y, zoom } numbers");
|
|
132
|
+
if (c.defaultRouting !== undefined && !DIAGRAM_ROUTINGS.includes(c.defaultRouting))
|
|
133
|
+
errors.push(`canvas.defaultRouting must be one of ${DIAGRAM_ROUTINGS.join(", ")}`);
|
|
134
|
+
if (c.layout !== undefined && !(isObject(c.layout) && isStr(c.layout.algorithm) && isStr(c.layout.direction)))
|
|
135
|
+
errors.push("canvas.layout must be { algorithm, direction }");
|
|
136
|
+
};
|
|
137
|
+
const validateSource = (s, errors) => {
|
|
138
|
+
if (s === undefined)
|
|
139
|
+
return;
|
|
140
|
+
if (!isObject(s))
|
|
141
|
+
return void errors.push("source must be an object");
|
|
142
|
+
if (s.format !== "mermaid" && s.format !== "bpmn")
|
|
143
|
+
errors.push('source.format must be "mermaid" or "bpmn"');
|
|
144
|
+
if (!isStr(s.text))
|
|
145
|
+
errors.push("source.text must be a string");
|
|
146
|
+
if (!isStr(s.diagramType))
|
|
147
|
+
errors.push("source.diagramType must be a string");
|
|
96
148
|
};
|
|
97
149
|
export const safeParseDiagramDocument = (input) => {
|
|
98
150
|
const errors = [];
|
|
@@ -113,7 +165,7 @@ export const safeParseDiagramDocument = (input) => {
|
|
|
113
165
|
const nodes = input.nodes;
|
|
114
166
|
const edges = input.edges;
|
|
115
167
|
nodes.forEach((n, i) => validateNode(n, i, errors));
|
|
116
|
-
// Valid edge terminals = node ids + edge ids (edges may connect to edges).
|
|
168
|
+
// Valid edge terminals = node ids + edge ids (legacy edges may connect to edges).
|
|
117
169
|
const terminalIds = new Set();
|
|
118
170
|
for (const n of nodes)
|
|
119
171
|
if (isObject(n) && isStr(n.id))
|
|
@@ -122,6 +174,8 @@ export const safeParseDiagramDocument = (input) => {
|
|
|
122
174
|
if (isObject(e) && isStr(e.id))
|
|
123
175
|
terminalIds.add(e.id);
|
|
124
176
|
edges.forEach((e, i) => validateEdge(e, i, terminalIds, errors));
|
|
177
|
+
validateCanvas(input.canvas, errors);
|
|
178
|
+
validateSource(input.source, errors);
|
|
125
179
|
if (errors.length)
|
|
126
180
|
return { ok: false, errors };
|
|
127
181
|
return { ok: true, document: input };
|