@cristianormazabal/triton-core 0.1.17 → 0.1.19
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/diagrams/mermaid/architecture/gridPlacer.d.ts +36 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.js +153 -0
- package/dist/diagrams/mermaid/architecture/gridPlacer.js.map +1 -0
- package/dist/diagrams/{triton → mermaid}/architecture/index.d.ts +1 -1
- package/dist/diagrams/mermaid/architecture/index.d.ts.map +1 -0
- package/dist/diagrams/{triton → mermaid}/architecture/index.js +2 -2
- package/dist/diagrams/mermaid/architecture/index.js.map +1 -0
- package/dist/diagrams/mermaid/architecture/ir.d.ts +55 -0
- package/dist/diagrams/mermaid/architecture/ir.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/ir.js.map +1 -0
- package/dist/diagrams/mermaid/architecture/layout.d.ts +27 -0
- package/dist/diagrams/mermaid/architecture/layout.d.ts.map +1 -0
- package/dist/diagrams/mermaid/architecture/layout.js +352 -0
- package/dist/diagrams/mermaid/architecture/layout.js.map +1 -0
- package/dist/diagrams/triton/ds/hashmap/hashmap.d.ts +9 -9
- package/dist/diagrams/triton/ds/hashmap/hashmap.d.ts.map +1 -1
- package/dist/diagrams/triton/ds/hashmap/hashmap.js +126 -28
- package/dist/diagrams/triton/ds/hashmap/hashmap.js.map +1 -1
- package/dist/frontend/index.js +1 -1
- package/dist/frontend/index.js.map +1 -1
- package/dist/index.js +933 -170
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/diagrams/triton/architecture/index.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/index.js.map +0 -1
- package/dist/diagrams/triton/architecture/ir.d.ts +0 -29
- package/dist/diagrams/triton/architecture/ir.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/ir.js.map +0 -1
- package/dist/diagrams/triton/architecture/layout.d.ts +0 -11
- package/dist/diagrams/triton/architecture/layout.d.ts.map +0 -1
- package/dist/diagrams/triton/architecture/layout.js +0 -124
- package/dist/diagrams/triton/architecture/layout.js.map +0 -1
- /package/dist/diagrams/{triton → mermaid}/architecture/ir.js +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file diagrams/architecture/gridPlacer.ts — Directional grid placement for
|
|
3
|
+
* architecture-beta diagrams.
|
|
4
|
+
*
|
|
5
|
+
* Implements BFS-based constraint-propagation as per Mermaid's architectureDb.ts
|
|
6
|
+
* (packages/mermaid/src/diagrams/architecture/architectureDb.ts:217–275).
|
|
7
|
+
*
|
|
8
|
+
* Side annotations on edges are PLACEMENT constraints, not just port hints:
|
|
9
|
+
* db:L -- R:server → server is one column WEST of db
|
|
10
|
+
* disk1:T -- B:svc → disk1 is one row SOUTH of svc
|
|
11
|
+
*
|
|
12
|
+
* The BFS produces integer (col, row) coordinates (0-indexed, left-to-right,
|
|
13
|
+
* top-to-bottom). Callers scale to pixels.
|
|
14
|
+
*/
|
|
15
|
+
export interface GridPlacerResult {
|
|
16
|
+
/** Grid column (0-indexed, left-to-right). */
|
|
17
|
+
readonly col: number;
|
|
18
|
+
/** Grid row (0-indexed, top-to-bottom). */
|
|
19
|
+
readonly row: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Compute integer grid-cell positions from directional edge constraints.
|
|
23
|
+
*
|
|
24
|
+
* @param nodes All services and junctions (any object with an `id`).
|
|
25
|
+
* @param edges All edges with `from`, `fromSide`, `to`, `toSide`.
|
|
26
|
+
* @returns Map from node ID to {col, row} (0-indexed, non-negative).
|
|
27
|
+
*/
|
|
28
|
+
export declare function directionalGridPlacer(nodes: ReadonlyArray<{
|
|
29
|
+
readonly id: string;
|
|
30
|
+
}>, edges: ReadonlyArray<{
|
|
31
|
+
readonly from: string;
|
|
32
|
+
readonly fromSide: string;
|
|
33
|
+
readonly to: string;
|
|
34
|
+
readonly toSide: string;
|
|
35
|
+
}>): Map<string, GridPlacerResult>;
|
|
36
|
+
//# sourceMappingURL=gridPlacer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gridPlacer.d.ts","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/gridPlacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAwCD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAG,aAAa,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9C,KAAK,EAAG,aAAa,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAM,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAQ,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAI,MAAM,CAAC;CAC3B,CAAC,GACD,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAuG/B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file diagrams/architecture/gridPlacer.ts — Directional grid placement for
|
|
3
|
+
* architecture-beta diagrams.
|
|
4
|
+
*
|
|
5
|
+
* Implements BFS-based constraint-propagation as per Mermaid's architectureDb.ts
|
|
6
|
+
* (packages/mermaid/src/diagrams/architecture/architectureDb.ts:217–275).
|
|
7
|
+
*
|
|
8
|
+
* Side annotations on edges are PLACEMENT constraints, not just port hints:
|
|
9
|
+
* db:L -- R:server → server is one column WEST of db
|
|
10
|
+
* disk1:T -- B:svc → disk1 is one row SOUTH of svc
|
|
11
|
+
*
|
|
12
|
+
* The BFS produces integer (col, row) coordinates (0-indexed, left-to-right,
|
|
13
|
+
* top-to-bottom). Callers scale to pixels.
|
|
14
|
+
*/
|
|
15
|
+
// ─── Direction-pair delta table ───────────────────────────────────────────────
|
|
16
|
+
//
|
|
17
|
+
// For each direction pair (fromSide + toSide), this gives (Δcol, Δrow) to
|
|
18
|
+
// apply to the CURRENT node's position to get the NEIGHBOR node's position.
|
|
19
|
+
//
|
|
20
|
+
// Derivation:
|
|
21
|
+
// L side → neighbor is west (Δcol = -1)
|
|
22
|
+
// R side → neighbor is east (Δcol = +1)
|
|
23
|
+
// T side → neighbor is north (Δrow = -1) [rows increase downward]
|
|
24
|
+
// B side → neighbor is south (Δrow = +1)
|
|
25
|
+
//
|
|
26
|
+
// Axis-aligned pairs combine the from-side's offset:
|
|
27
|
+
// RL: (+1, 0) — curr's right exits east, neighbor is east
|
|
28
|
+
// LR: (-1, 0) — curr's left exits west, neighbor is west
|
|
29
|
+
// BT: (0, +1) — curr's bottom exits south, neighbor is south
|
|
30
|
+
// TB: (0, -1) — curr's top exits north, neighbor is north
|
|
31
|
+
//
|
|
32
|
+
// Diagonal pairs combine both axes independently:
|
|
33
|
+
// LT: (-1, -1) RT: (+1, -1) LB: (-1, +1) RB: (+1, +1)
|
|
34
|
+
// TL: (-1, -1) TR: (+1, -1) BL: (-1, +1) BR: (+1, +1)
|
|
35
|
+
//
|
|
36
|
+
const DELTA = {
|
|
37
|
+
LR: [-1, 0],
|
|
38
|
+
RL: [+1, 0],
|
|
39
|
+
TB: [0, -1],
|
|
40
|
+
BT: [0, +1],
|
|
41
|
+
LT: [-1, -1],
|
|
42
|
+
LB: [-1, +1],
|
|
43
|
+
RT: [+1, -1],
|
|
44
|
+
RB: [+1, +1],
|
|
45
|
+
TL: [-1, -1],
|
|
46
|
+
TR: [+1, -1],
|
|
47
|
+
BL: [-1, +1],
|
|
48
|
+
BR: [+1, +1],
|
|
49
|
+
};
|
|
50
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
51
|
+
/**
|
|
52
|
+
* Compute integer grid-cell positions from directional edge constraints.
|
|
53
|
+
*
|
|
54
|
+
* @param nodes All services and junctions (any object with an `id`).
|
|
55
|
+
* @param edges All edges with `from`, `fromSide`, `to`, `toSide`.
|
|
56
|
+
* @returns Map from node ID to {col, row} (0-indexed, non-negative).
|
|
57
|
+
*/
|
|
58
|
+
export function directionalGridPlacer(nodes, edges) {
|
|
59
|
+
if (nodes.length === 0)
|
|
60
|
+
return new Map();
|
|
61
|
+
// ── 1. Build bidirectional adjacency list ──────────────────────────────────
|
|
62
|
+
// adjList[nodeId][dirPair] = neighborId
|
|
63
|
+
const adjList = new Map();
|
|
64
|
+
for (const n of nodes)
|
|
65
|
+
adjList.set(n.id, new Map());
|
|
66
|
+
for (const e of edges) {
|
|
67
|
+
const fs = e.fromSide.toUpperCase();
|
|
68
|
+
const ts = e.toSide.toUpperCase();
|
|
69
|
+
const fwd = fs + ts;
|
|
70
|
+
const rev = ts + fs;
|
|
71
|
+
const fromAdj = adjList.get(e.from);
|
|
72
|
+
const toAdj = adjList.get(e.to);
|
|
73
|
+
if (!fromAdj || !toAdj)
|
|
74
|
+
continue; // unknown node — skip
|
|
75
|
+
// Contradiction detection: same pair pointing to a DIFFERENT neighbor.
|
|
76
|
+
if (fromAdj.has(fwd) && fromAdj.get(fwd) !== e.to) {
|
|
77
|
+
console.warn(`[gridPlacer] Contradictory constraint on "${e.from}" direction ${fwd} — first-wins`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
fromAdj.set(fwd, e.to);
|
|
81
|
+
}
|
|
82
|
+
if (toAdj.has(rev) && toAdj.get(rev) !== e.from) {
|
|
83
|
+
console.warn(`[gridPlacer] Contradictory constraint on "${e.to}" direction ${rev} — first-wins`);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
toAdj.set(rev, e.from);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// ── 2. BFS ─────────────────────────────────────────────────────────────────
|
|
90
|
+
const position = new Map();
|
|
91
|
+
/** Reverse map for collision detection: "col,row" → nodeId */
|
|
92
|
+
const occupied = new Map();
|
|
93
|
+
function bfs(seed, seedCol, seedRow) {
|
|
94
|
+
position.set(seed, { col: seedCol, row: seedRow });
|
|
95
|
+
occupied.set(`${seedCol},${seedRow}`, seed);
|
|
96
|
+
const queue = [seed];
|
|
97
|
+
while (queue.length > 0) {
|
|
98
|
+
const curr = queue.shift();
|
|
99
|
+
const currPos = position.get(curr);
|
|
100
|
+
const adj = adjList.get(curr);
|
|
101
|
+
if (!adj)
|
|
102
|
+
continue;
|
|
103
|
+
for (const [pair, neighbor] of adj) {
|
|
104
|
+
if (position.has(neighbor))
|
|
105
|
+
continue; // already placed (cycle or revisit)
|
|
106
|
+
const d = DELTA[pair];
|
|
107
|
+
if (!d)
|
|
108
|
+
continue; // unrecognised pair — skip
|
|
109
|
+
let col = currPos.col + d[0];
|
|
110
|
+
let row = currPos.row + d[1];
|
|
111
|
+
// Collision: bump to the next free row in the same column.
|
|
112
|
+
const key = `${col},${row}`;
|
|
113
|
+
if (occupied.has(key) && occupied.get(key) !== neighbor) {
|
|
114
|
+
console.warn(`[gridPlacer] Cell collision at (${col},${row}), bumping "${neighbor}"`);
|
|
115
|
+
let bump = row + 1;
|
|
116
|
+
while (occupied.has(`${col},${bump}`))
|
|
117
|
+
bump++;
|
|
118
|
+
row = bump;
|
|
119
|
+
}
|
|
120
|
+
position.set(neighbor, { col, row });
|
|
121
|
+
occupied.set(`${col},${row}`, neighbor);
|
|
122
|
+
queue.push(neighbor);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Seed: prefer a node that has at least one edge, for a more centred layout.
|
|
127
|
+
const connected = new Set([...edges.map(e => e.from), ...edges.map(e => e.to)]);
|
|
128
|
+
const seed = nodes.find(n => connected.has(n.id)) ?? nodes[0];
|
|
129
|
+
bfs(seed.id, 0, 0);
|
|
130
|
+
// ── 3. Handle disconnected components ─────────────────────────────────────
|
|
131
|
+
for (const n of nodes) {
|
|
132
|
+
if (!position.has(n.id)) {
|
|
133
|
+
const maxCol = position.size > 0
|
|
134
|
+
? Math.max(...[...position.values()].map(p => p.col)) + 2
|
|
135
|
+
: 0;
|
|
136
|
+
bfs(n.id, maxCol, 0);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// ── 4. Nodes with NO edges at all → fall back: single row ─────────────────
|
|
140
|
+
if (position.size === 0) {
|
|
141
|
+
nodes.forEach((n, i) => position.set(n.id, { col: i, row: 0 }));
|
|
142
|
+
}
|
|
143
|
+
// ── 5. Normalise to non-negative ───────────────────────────────────────────
|
|
144
|
+
const vals = [...position.values()];
|
|
145
|
+
const minCol = Math.min(...vals.map(p => p.col));
|
|
146
|
+
const minRow = Math.min(...vals.map(p => p.row));
|
|
147
|
+
const result = new Map();
|
|
148
|
+
for (const [id, pos] of position) {
|
|
149
|
+
result.set(id, { col: pos.col - minCol, row: pos.row - minRow });
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=gridPlacer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gridPlacer.js","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/gridPlacer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,iFAAiF;AACjF,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,EAAE;AACF,cAAc;AACd,2CAA2C;AAC3C,2CAA2C;AAC3C,qEAAqE;AACrE,2CAA2C;AAC3C,EAAE;AACF,qDAAqD;AACrD,6DAA6D;AAC7D,4DAA4D;AAC5D,gEAAgE;AAChE,6DAA6D;AAC7D,EAAE;AACF,kDAAkD;AAClD,2DAA2D;AAC3D,2DAA2D;AAC3D,EAAE;AACF,MAAM,KAAK,GAAwD;IACjE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAG,CAAC,CAAC;IACZ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAG,CAAC,CA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AAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,6EAA6E;IAC7E,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,8EAA8E;IAC9E,MAAM,IAAI,GAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,MAAM,MAAM,GAAI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,MAAM,GAAI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;IACnD,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DiagramModule } from '../../../contracts/index.js';
|
|
2
2
|
import type { ArchitectureDocument } from './ir.js';
|
|
3
|
-
export type { ArchitectureDocument, ArchService, ArchGroup, ArchEdge } from './ir.js';
|
|
3
|
+
export type { ArchitectureDocument, ArchService, ArchGroup, ArchJunction, ArchEdge, ArchAlign } from './ir.js';
|
|
4
4
|
export declare const architecture: DiagramModule<ArchitectureDocument>;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,6BAA6B,CAAC;AAC9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKpD,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/G,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,oBAAoB,CAY5D,CAAC"}
|
|
@@ -7,8 +7,8 @@ export const architecture = {
|
|
|
7
7
|
parseYaml(input) {
|
|
8
8
|
return JSON.parse(input);
|
|
9
9
|
},
|
|
10
|
-
layout(ir, theme) {
|
|
11
|
-
return layoutArchitecture(ir, theme);
|
|
10
|
+
layout(ir, theme, options) {
|
|
11
|
+
return layoutArchitecture(ir, theme, options);
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAItC,MAAM,CAAC,MAAM,YAAY,GAAwC;IAC/D,YAAY,CAAC,KAAa;QACxB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAyB,CAAC;IACrD,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAyB,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,EAAwB,EAAE,KAAoB,EAAE,OAAuB;QAC5E,OAAO,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { BaseIR } from '../../../contracts/index.js';
|
|
2
|
+
export interface ArchService {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly icon: string;
|
|
6
|
+
readonly group?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ArchGroup {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly icon: string;
|
|
12
|
+
/** ID of the enclosing group when this group is nested inside another. */
|
|
13
|
+
readonly parent?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A junction is a 4-way edge split node — no icon or label. */
|
|
16
|
+
export interface ArchJunction {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
/** ID of the enclosing group, if any. */
|
|
19
|
+
readonly group?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ArchEdge {
|
|
22
|
+
readonly from: string;
|
|
23
|
+
readonly fromSide: string;
|
|
24
|
+
/** True when the `{group}` modifier is present on the from endpoint. */
|
|
25
|
+
readonly fromGroup: boolean;
|
|
26
|
+
readonly to: string;
|
|
27
|
+
readonly toSide: string;
|
|
28
|
+
/** True when the `{group}` modifier is present on the to endpoint. */
|
|
29
|
+
readonly toGroup: boolean;
|
|
30
|
+
/** Arrow points left (towards from): `<--` or `<-->`. */
|
|
31
|
+
readonly arrowLeft: boolean;
|
|
32
|
+
/** Arrow points right (towards to): `-->` or `<-->`. */
|
|
33
|
+
readonly arrowRight: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ArchAlign {
|
|
36
|
+
readonly axis: 'row' | 'column';
|
|
37
|
+
readonly members: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
export interface ArchitectureDocument extends BaseIR {
|
|
40
|
+
readonly metadata: {
|
|
41
|
+
readonly title?: string;
|
|
42
|
+
readonly theme?: string;
|
|
43
|
+
readonly [key: string]: string | undefined;
|
|
44
|
+
};
|
|
45
|
+
readonly groups: readonly ArchGroup[];
|
|
46
|
+
readonly services: readonly ArchService[];
|
|
47
|
+
readonly junctions: readonly ArchJunction[];
|
|
48
|
+
readonly edges: readonly ArchEdge[];
|
|
49
|
+
/**
|
|
50
|
+
* Alignment hints for layout — axis (row/column) + member IDs.
|
|
51
|
+
* TODO(Brian/Phase B): honour these as layout constraints in layoutArchitecture().
|
|
52
|
+
*/
|
|
53
|
+
readonly aligns: readonly ArchAlign[];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/ir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC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ture/ir.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file diagrams/architecture/layout.ts — Cloud architecture diagram.
|
|
3
|
+
*
|
|
4
|
+
* Phase C implementation — replaces Sugiyama layered layout with a
|
|
5
|
+
* direction-constrained BFS grid placer that honours L/R/T/B side semantics.
|
|
6
|
+
* All other rendering features from Phase B remain unchanged.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* 1. Directional grid placement — BFS from directional edge constraints
|
|
10
|
+
* 2. Junctions — small 4-way split nodes; edges enter/leave on any side.
|
|
11
|
+
* 3. Arrowheads — driven by arrowLeft / arrowRight; axis-aligned markers.
|
|
12
|
+
* 4. {group} edges — port sits on the enclosing group boundary, not the service box.
|
|
13
|
+
* 5. Align — row/column constraints applied as post-grid position nudges.
|
|
14
|
+
* 6. Nested groups — parent groups visually contain child groups.
|
|
15
|
+
* 7. Iconify icons — prefix:name tokens resolved through LayoutOptions.icons;
|
|
16
|
+
* unresolvable tokens fall back to the built-in glyph.
|
|
17
|
+
*
|
|
18
|
+
* Deviations / limitations (disclosed):
|
|
19
|
+
* - Align constraints are applied as a post-BFS median-snap. Edge directions
|
|
20
|
+
* take precedence; align is a fixup for disconnected nodes or user overrides.
|
|
21
|
+
* - Iconify resolution requires the host to supply LayoutOptions.icons.
|
|
22
|
+
*/
|
|
23
|
+
import type { ArchitectureDocument } from './ir.js';
|
|
24
|
+
import type { LayoutResult, LayoutOptions } from '../../../contracts/index.js';
|
|
25
|
+
import type { ResolvedTheme } from '../../../contracts/index.js';
|
|
26
|
+
export declare function layoutArchitecture(ir: ArchitectureDocument, theme: ResolvedTheme, options?: LayoutOptions): LayoutResult;
|
|
27
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../../../src/diagrams/mermaid/architecture/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAa,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAuB,YAAY,EAAuB,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACzH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAsDjE,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,oBAAoB,EACxB,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA2Pd"}
|