@flyingrobots/bijou 1.1.0 → 1.2.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/core/components/dag-edges.d.ts +78 -0
- package/dist/core/components/dag-edges.d.ts.map +1 -0
- package/dist/core/components/dag-edges.js +127 -0
- package/dist/core/components/dag-edges.js.map +1 -0
- package/dist/core/components/dag-layout.d.ts +37 -0
- package/dist/core/components/dag-layout.d.ts.map +1 -0
- package/dist/core/components/dag-layout.js +172 -0
- package/dist/core/components/dag-layout.js.map +1 -0
- package/dist/core/components/dag-render.d.ts +51 -0
- package/dist/core/components/dag-render.d.ts.map +1 -0
- package/dist/core/components/dag-render.js +440 -0
- package/dist/core/components/dag-render.js.map +1 -0
- package/dist/core/components/dag.d.ts.map +1 -1
- package/dist/core/components/dag.js +3 -648
- package/dist/core/components/dag.js.map +1 -1
- package/dist/core/components/markdown-parse.d.ts +69 -0
- package/dist/core/components/markdown-parse.d.ts.map +1 -0
- package/dist/core/components/markdown-parse.js +272 -0
- package/dist/core/components/markdown-parse.js.map +1 -0
- package/dist/core/components/markdown-render.d.ts +20 -0
- package/dist/core/components/markdown-render.d.ts.map +1 -0
- package/dist/core/components/markdown-render.js +135 -0
- package/dist/core/components/markdown-render.js.map +1 -0
- package/dist/core/components/markdown.d.ts.map +1 -1
- package/dist/core/components/markdown.js +6 -371
- package/dist/core/components/markdown.js.map +1 -1
- package/dist/core/forms/filter-interactive.d.ts +66 -0
- package/dist/core/forms/filter-interactive.d.ts.map +1 -0
- package/dist/core/forms/filter-interactive.js +241 -0
- package/dist/core/forms/filter-interactive.js.map +1 -0
- package/dist/core/forms/filter.d.ts +2 -32
- package/dist/core/forms/filter.d.ts.map +1 -1
- package/dist/core/forms/filter.js +2 -167
- package/dist/core/forms/filter.js.map +1 -1
- package/dist/core/forms/textarea-editor.d.ts +39 -0
- package/dist/core/forms/textarea-editor.d.ts.map +1 -0
- package/dist/core/forms/textarea-editor.js +210 -0
- package/dist/core/forms/textarea-editor.js.map +1 -0
- package/dist/core/forms/textarea.d.ts +2 -19
- package/dist/core/forms/textarea.d.ts.map +1 -1
- package/dist/core/forms/textarea.js +2 -195
- package/dist/core/forms/textarea.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge routing primitives for the DAG renderer.
|
|
3
|
+
*
|
|
4
|
+
* Self-contained module with zero dag-* imports.
|
|
5
|
+
* Provides the mutable grid used to route edges between node positions
|
|
6
|
+
* and the junction-character lookup table.
|
|
7
|
+
*/
|
|
8
|
+
/** Cardinal direction for edge routing through grid cells. */
|
|
9
|
+
export type Dir = 'U' | 'D' | 'L' | 'R';
|
|
10
|
+
/**
|
|
11
|
+
* Mutable grid state used during edge routing.
|
|
12
|
+
*
|
|
13
|
+
* Each cell tracks which cardinal directions edges pass through it,
|
|
14
|
+
* and `arrows` records the encoded positions of arrowheads.
|
|
15
|
+
*/
|
|
16
|
+
export interface GridState {
|
|
17
|
+
/** 2D array of direction sets, one per grid cell. */
|
|
18
|
+
dirs: Set<Dir>[][];
|
|
19
|
+
/** Encoded arrowhead positions. Use `decodeArrowPos()` to extract row/col. */
|
|
20
|
+
arrows: Set<number>;
|
|
21
|
+
/** Number of rows in the grid. */
|
|
22
|
+
rows: number;
|
|
23
|
+
/** Number of columns in the grid. */
|
|
24
|
+
cols: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Encode a grid (row, col) pair into a single number for Set membership.
|
|
28
|
+
*
|
|
29
|
+
* Uses bitwise encoding `(row << 16) | col`, supporting up to 65535 rows and cols.
|
|
30
|
+
*
|
|
31
|
+
* @param row - Grid row index.
|
|
32
|
+
* @param col - Grid column index.
|
|
33
|
+
* @returns The encoded position as a single number.
|
|
34
|
+
*/
|
|
35
|
+
export declare function encodeArrowPos(row: number, col: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Decode an encoded arrow position back into row and col.
|
|
38
|
+
*
|
|
39
|
+
* @param encoded - Value produced by `encodeArrowPos()`.
|
|
40
|
+
* @returns Object with `row` and `col` fields.
|
|
41
|
+
*/
|
|
42
|
+
export declare function decodeArrowPos(encoded: number): {
|
|
43
|
+
row: number;
|
|
44
|
+
col: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Select the Unicode box-drawing character for a cell based on its edge directions.
|
|
48
|
+
*
|
|
49
|
+
* @param dirs - Set of cardinal directions passing through this cell.
|
|
50
|
+
* @returns The appropriate box-drawing character, or `' '` (space) for an empty
|
|
51
|
+
* direction set (no edge traffic through this cell).
|
|
52
|
+
*/
|
|
53
|
+
export declare function junctionChar(dirs: Set<Dir>): string;
|
|
54
|
+
/**
|
|
55
|
+
* Allocate an empty edge-routing grid.
|
|
56
|
+
*
|
|
57
|
+
* @param rows - Number of rows in the grid.
|
|
58
|
+
* @param cols - Number of columns in the grid.
|
|
59
|
+
* @returns A fresh `GridState` with empty direction sets for every cell.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createGrid(rows: number, cols: number): GridState;
|
|
62
|
+
/**
|
|
63
|
+
* Route a single edge through the grid between two node positions.
|
|
64
|
+
*
|
|
65
|
+
* Draws a vertical segment from the source, an optional horizontal jog
|
|
66
|
+
* if the columns differ, then a vertical segment down to the target.
|
|
67
|
+
* Records an arrowhead position just above the destination node.
|
|
68
|
+
*
|
|
69
|
+
* @param g - The grid state to mutate.
|
|
70
|
+
* @param fromCol - Column index of the source node.
|
|
71
|
+
* @param fromLayer - Layer index of the source node.
|
|
72
|
+
* @param toCol - Column index of the destination node.
|
|
73
|
+
* @param toLayer - Layer index of the destination node.
|
|
74
|
+
* @param RS - Row stride (number of grid rows per layer).
|
|
75
|
+
* @param colCenter - Function mapping a column index to its center grid column.
|
|
76
|
+
*/
|
|
77
|
+
export declare function markEdge(g: GridState, fromCol: number, fromLayer: number, toCol: number, toLayer: number, RS: number, colCenter: (c: number) => number): void;
|
|
78
|
+
//# sourceMappingURL=d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-0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge routing primitives for the DAG renderer.
|
|
3
|
+
*
|
|
4
|
+
* Self-contained module with zero dag-* imports.
|
|
5
|
+
* Provides the mutable grid used to route edges between node positions
|
|
6
|
+
* and the junction-character lookup table.
|
|
7
|
+
*/
|
|
8
|
+
// ── Arrow Position Encoding ───────────────────────────────────────
|
|
9
|
+
/**
|
|
10
|
+
* Encode a grid (row, col) pair into a single number for Set membership.
|
|
11
|
+
*
|
|
12
|
+
* Uses bitwise encoding `(row << 16) | col`, supporting up to 65535 rows and cols.
|
|
13
|
+
*
|
|
14
|
+
* @param row - Grid row index.
|
|
15
|
+
* @param col - Grid column index.
|
|
16
|
+
* @returns The encoded position as a single number.
|
|
17
|
+
*/
|
|
18
|
+
export function encodeArrowPos(row, col) {
|
|
19
|
+
return (row << 16) | col;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decode an encoded arrow position back into row and col.
|
|
23
|
+
*
|
|
24
|
+
* @param encoded - Value produced by `encodeArrowPos()`.
|
|
25
|
+
* @returns Object with `row` and `col` fields.
|
|
26
|
+
*/
|
|
27
|
+
export function decodeArrowPos(encoded) {
|
|
28
|
+
return { row: encoded >>> 16, col: encoded & 0xFFFF };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Lookup table mapping sorted direction-set keys to Unicode box-drawing characters.
|
|
32
|
+
* For example, `'DR'` maps to `\u250c` (top-left corner).
|
|
33
|
+
*/
|
|
34
|
+
const JUNCTION = {
|
|
35
|
+
'D': '\u2502', 'U': '\u2502', 'DU': '\u2502',
|
|
36
|
+
'L': '\u2500', 'R': '\u2500', 'LR': '\u2500',
|
|
37
|
+
'DR': '\u250c', 'DL': '\u2510', 'RU': '\u2514', 'LU': '\u2518',
|
|
38
|
+
'DRU': '\u251c', 'DLU': '\u2524', 'DLR': '\u252c', 'LRU': '\u2534',
|
|
39
|
+
'DLRU': '\u253c',
|
|
40
|
+
};
|
|
41
|
+
// ── Functions ──────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Select the Unicode box-drawing character for a cell based on its edge directions.
|
|
44
|
+
*
|
|
45
|
+
* @param dirs - Set of cardinal directions passing through this cell.
|
|
46
|
+
* @returns The appropriate box-drawing character, or `' '` (space) for an empty
|
|
47
|
+
* direction set (no edge traffic through this cell).
|
|
48
|
+
*/
|
|
49
|
+
export function junctionChar(dirs) {
|
|
50
|
+
if (dirs.size === 0)
|
|
51
|
+
return ' ';
|
|
52
|
+
// Alphabetical sort of D,L,R,U matches JUNCTION table keys
|
|
53
|
+
const key = [...dirs].sort().join('');
|
|
54
|
+
return JUNCTION[key] ?? '\u253c';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Allocate an empty edge-routing grid.
|
|
58
|
+
*
|
|
59
|
+
* @param rows - Number of rows in the grid.
|
|
60
|
+
* @param cols - Number of columns in the grid.
|
|
61
|
+
* @returns A fresh `GridState` with empty direction sets for every cell.
|
|
62
|
+
*/
|
|
63
|
+
export function createGrid(rows, cols) {
|
|
64
|
+
const dirs = [];
|
|
65
|
+
for (let r = 0; r < rows; r++) {
|
|
66
|
+
const row = [];
|
|
67
|
+
for (let c = 0; c < cols; c++) {
|
|
68
|
+
row.push(new Set());
|
|
69
|
+
}
|
|
70
|
+
dirs.push(row);
|
|
71
|
+
}
|
|
72
|
+
return { dirs, arrows: new Set(), rows, cols };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add direction markers to a single grid cell. Bounds-checked.
|
|
76
|
+
*
|
|
77
|
+
* @param g - The grid state to mutate.
|
|
78
|
+
* @param r - Row index.
|
|
79
|
+
* @param c - Column index.
|
|
80
|
+
* @param ds - One or more directions to mark in this cell.
|
|
81
|
+
*/
|
|
82
|
+
function markDir(g, r, c, ...ds) {
|
|
83
|
+
if (r >= 0 && r < g.rows && c >= 0 && c < g.cols) {
|
|
84
|
+
const cell = g.dirs[r][c];
|
|
85
|
+
for (const d of ds)
|
|
86
|
+
cell.add(d);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Route a single edge through the grid between two node positions.
|
|
91
|
+
*
|
|
92
|
+
* Draws a vertical segment from the source, an optional horizontal jog
|
|
93
|
+
* if the columns differ, then a vertical segment down to the target.
|
|
94
|
+
* Records an arrowhead position just above the destination node.
|
|
95
|
+
*
|
|
96
|
+
* @param g - The grid state to mutate.
|
|
97
|
+
* @param fromCol - Column index of the source node.
|
|
98
|
+
* @param fromLayer - Layer index of the source node.
|
|
99
|
+
* @param toCol - Column index of the destination node.
|
|
100
|
+
* @param toLayer - Layer index of the destination node.
|
|
101
|
+
* @param RS - Row stride (number of grid rows per layer).
|
|
102
|
+
* @param colCenter - Function mapping a column index to its center grid column.
|
|
103
|
+
*/
|
|
104
|
+
export function markEdge(g, fromCol, fromLayer, toCol, toLayer, RS, colCenter) {
|
|
105
|
+
const srcC = colCenter(fromCol);
|
|
106
|
+
const dstC = colCenter(toCol);
|
|
107
|
+
const sRow = fromLayer * RS + 3;
|
|
108
|
+
const dRow = toLayer * RS - 1; // one row above dest box
|
|
109
|
+
const mid = sRow + 1;
|
|
110
|
+
if (srcC === dstC) {
|
|
111
|
+
for (let r = sRow; r < dRow; r++)
|
|
112
|
+
markDir(g, r, srcC, 'D', 'U');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
markDir(g, sRow, srcC, 'D', 'U');
|
|
116
|
+
markDir(g, mid, srcC, srcC < dstC ? 'R' : 'L', 'U');
|
|
117
|
+
const minC = Math.min(srcC, dstC);
|
|
118
|
+
const maxC = Math.max(srcC, dstC);
|
|
119
|
+
for (let c = minC + 1; c < maxC; c++)
|
|
120
|
+
markDir(g, mid, c, 'L', 'R');
|
|
121
|
+
markDir(g, mid, dstC, srcC < dstC ? 'L' : 'R', 'D');
|
|
122
|
+
for (let r = mid + 1; r < dRow; r++)
|
|
123
|
+
markDir(g, r, dstC, 'D', 'U');
|
|
124
|
+
}
|
|
125
|
+
g.arrows.add(encodeArrowPos(dRow, dstC));
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=dag-edges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-edges.js","sourceRoot":"","sources":["../../../src/core/components/dag-edges.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,qEAAqE;AAErE;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,GAAW;IACrD,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,QAAQ,GAA2B;IACvC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAC5C,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAC5C,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAC9D,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ;IAClE,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,sEAAsE;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAChC,2DAA2D;IAC3D,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;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E,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sugiyama-style layer assignment and column ordering for the DAG renderer.
|
|
3
|
+
*
|
|
4
|
+
* Imports only `DagNode` as a type from `dag.ts` (type-only, erased at runtime).
|
|
5
|
+
*/
|
|
6
|
+
import type { DagNode } from './dag.js';
|
|
7
|
+
/**
|
|
8
|
+
* Assign each node to a layer using longest-path layer assignment.
|
|
9
|
+
*
|
|
10
|
+
* Performs Kahn's topological sort to detect cycles, then assigns each
|
|
11
|
+
* node to the layer one past its deepest parent. Root nodes (in-degree 0)
|
|
12
|
+
* are placed on layer 0.
|
|
13
|
+
*
|
|
14
|
+
* @param nodes - The graph nodes to lay out.
|
|
15
|
+
* @returns Map from node ID to its zero-based layer index.
|
|
16
|
+
* @throws If the graph contains a cycle.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assignLayers(nodes: DagNode[]): Map<string, number>;
|
|
19
|
+
/**
|
|
20
|
+
* Group node IDs into layer arrays indexed by layer number.
|
|
21
|
+
*
|
|
22
|
+
* @param nodes - All graph nodes.
|
|
23
|
+
* @param layerMap - Map from node ID to layer index (from `assignLayers`).
|
|
24
|
+
* @returns Array of layers, where each layer is an array of node IDs.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildLayerArrays(nodes: DagNode[], layerMap: Map<string, number>): string[][];
|
|
27
|
+
/**
|
|
28
|
+
* Reorder nodes within each layer to minimize edge crossings.
|
|
29
|
+
*
|
|
30
|
+
* Uses the barycenter heuristic with one top-down pass followed by
|
|
31
|
+
* one bottom-up pass. Mutates the `layers` arrays in place.
|
|
32
|
+
*
|
|
33
|
+
* @param layers - Layer arrays from `buildLayerArrays`, mutated in place.
|
|
34
|
+
* @param nodes - All graph nodes (used to build adjacency maps).
|
|
35
|
+
*/
|
|
36
|
+
export declare function orderColumns(layers: string[][], nodes: DagNode[]): void;
|
|
37
|
+
//# sourceMappingURL=dag-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-layout.d.ts","sourceRoot":"","sources":["../../../src/core/components/dag-layout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAmElE;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EAAE,EAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,EAAE,EAAE,CAWZ;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAyDvE"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sugiyama-style layer assignment and column ordering for the DAG renderer.
|
|
3
|
+
*
|
|
4
|
+
* Imports only `DagNode` as a type from `dag.ts` (type-only, erased at runtime).
|
|
5
|
+
*/
|
|
6
|
+
// ── Layer Assignment ───────────────────────────────────────────────
|
|
7
|
+
/**
|
|
8
|
+
* Assign each node to a layer using longest-path layer assignment.
|
|
9
|
+
*
|
|
10
|
+
* Performs Kahn's topological sort to detect cycles, then assigns each
|
|
11
|
+
* node to the layer one past its deepest parent. Root nodes (in-degree 0)
|
|
12
|
+
* are placed on layer 0.
|
|
13
|
+
*
|
|
14
|
+
* @param nodes - The graph nodes to lay out.
|
|
15
|
+
* @returns Map from node ID to its zero-based layer index.
|
|
16
|
+
* @throws If the graph contains a cycle.
|
|
17
|
+
*/
|
|
18
|
+
export function assignLayers(nodes) {
|
|
19
|
+
const nodeIds = new Set();
|
|
20
|
+
for (const n of nodes) {
|
|
21
|
+
if (nodeIds.has(n.id)) {
|
|
22
|
+
throw new Error(`[bijou] dag(): duplicate node id "${n.id}"`);
|
|
23
|
+
}
|
|
24
|
+
nodeIds.add(n.id);
|
|
25
|
+
}
|
|
26
|
+
const children = new Map();
|
|
27
|
+
const parents = new Map();
|
|
28
|
+
const inDegree = new Map();
|
|
29
|
+
for (const n of nodes) {
|
|
30
|
+
// Filter edges to only include targets that exist in the graph
|
|
31
|
+
children.set(n.id, (n.edges ?? []).filter(e => nodeIds.has(e)));
|
|
32
|
+
inDegree.set(n.id, 0);
|
|
33
|
+
if (!parents.has(n.id))
|
|
34
|
+
parents.set(n.id, []);
|
|
35
|
+
}
|
|
36
|
+
for (const n of nodes) {
|
|
37
|
+
for (const childId of children.get(n.id) ?? []) {
|
|
38
|
+
if (!parents.has(childId))
|
|
39
|
+
parents.set(childId, []);
|
|
40
|
+
parents.get(childId).push(n.id);
|
|
41
|
+
inDegree.set(childId, (inDegree.get(childId) ?? 0) + 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Kahn's topological sort
|
|
45
|
+
const queue = [];
|
|
46
|
+
for (const [id, deg] of inDegree) {
|
|
47
|
+
if (deg === 0)
|
|
48
|
+
queue.push(id);
|
|
49
|
+
}
|
|
50
|
+
// Kahn's algorithm: in-degree tracking guarantees each node is queued exactly
|
|
51
|
+
// once (when its in-degree reaches 0), so no visited set is needed.
|
|
52
|
+
const topoOrder = [];
|
|
53
|
+
while (queue.length > 0) {
|
|
54
|
+
const id = queue.shift();
|
|
55
|
+
topoOrder.push(id);
|
|
56
|
+
for (const childId of children.get(id) ?? []) {
|
|
57
|
+
const newDeg = (inDegree.get(childId) ?? 1) - 1;
|
|
58
|
+
inDegree.set(childId, newDeg);
|
|
59
|
+
if (newDeg === 0)
|
|
60
|
+
queue.push(childId);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (topoOrder.length !== nodes.length) {
|
|
64
|
+
throw new Error('[bijou] dag(): cycle detected in graph');
|
|
65
|
+
}
|
|
66
|
+
// Longest-path layer assignment
|
|
67
|
+
const layerMap = new Map();
|
|
68
|
+
for (const id of topoOrder) {
|
|
69
|
+
const pars = parents.get(id) ?? [];
|
|
70
|
+
if (pars.length === 0) {
|
|
71
|
+
layerMap.set(id, 0);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
let maxParent = 0;
|
|
75
|
+
for (const p of pars) {
|
|
76
|
+
maxParent = Math.max(maxParent, layerMap.get(p) ?? 0);
|
|
77
|
+
}
|
|
78
|
+
layerMap.set(id, maxParent + 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return layerMap;
|
|
82
|
+
}
|
|
83
|
+
// ── Column Ordering ────────────────────────────────────────────────
|
|
84
|
+
/**
|
|
85
|
+
* Group node IDs into layer arrays indexed by layer number.
|
|
86
|
+
*
|
|
87
|
+
* @param nodes - All graph nodes.
|
|
88
|
+
* @param layerMap - Map from node ID to layer index (from `assignLayers`).
|
|
89
|
+
* @returns Array of layers, where each layer is an array of node IDs.
|
|
90
|
+
*/
|
|
91
|
+
export function buildLayerArrays(nodes, layerMap) {
|
|
92
|
+
let maxLayer = 0;
|
|
93
|
+
for (const v of layerMap.values()) {
|
|
94
|
+
if (v > maxLayer)
|
|
95
|
+
maxLayer = v;
|
|
96
|
+
}
|
|
97
|
+
const layers = Array.from({ length: maxLayer + 1 }, () => []);
|
|
98
|
+
for (const n of nodes) {
|
|
99
|
+
const l = layerMap.get(n.id);
|
|
100
|
+
if (l !== undefined)
|
|
101
|
+
layers[l].push(n.id);
|
|
102
|
+
}
|
|
103
|
+
return layers;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Reorder nodes within each layer to minimize edge crossings.
|
|
107
|
+
*
|
|
108
|
+
* Uses the barycenter heuristic with one top-down pass followed by
|
|
109
|
+
* one bottom-up pass. Mutates the `layers` arrays in place.
|
|
110
|
+
*
|
|
111
|
+
* @param layers - Layer arrays from `buildLayerArrays`, mutated in place.
|
|
112
|
+
* @param nodes - All graph nodes (used to build adjacency maps).
|
|
113
|
+
*/
|
|
114
|
+
export function orderColumns(layers, nodes) {
|
|
115
|
+
const childrenMap = new Map();
|
|
116
|
+
const parentsMap = new Map();
|
|
117
|
+
for (const n of nodes) {
|
|
118
|
+
childrenMap.set(n.id, n.edges ?? []);
|
|
119
|
+
if (!parentsMap.has(n.id))
|
|
120
|
+
parentsMap.set(n.id, []);
|
|
121
|
+
}
|
|
122
|
+
for (const n of nodes) {
|
|
123
|
+
for (const c of n.edges ?? []) {
|
|
124
|
+
if (!parentsMap.has(c))
|
|
125
|
+
parentsMap.set(c, []);
|
|
126
|
+
parentsMap.get(c).push(n.id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Top-down pass
|
|
130
|
+
for (let l = 1; l < layers.length; l++) {
|
|
131
|
+
const prevLayer = layers[l - 1];
|
|
132
|
+
const curLayer = layers[l];
|
|
133
|
+
const prevIndex = new Map();
|
|
134
|
+
for (let i = 0; i < prevLayer.length; i++) {
|
|
135
|
+
prevIndex.set(prevLayer[i], i);
|
|
136
|
+
}
|
|
137
|
+
const bary = new Map();
|
|
138
|
+
for (const id of curLayer) {
|
|
139
|
+
const pars = (parentsMap.get(id) ?? []).filter(p => prevIndex.has(p));
|
|
140
|
+
if (pars.length === 0) {
|
|
141
|
+
bary.set(id, Infinity);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const avg = pars.reduce((s, p) => s + (prevIndex.get(p) ?? 0), 0) / pars.length;
|
|
145
|
+
bary.set(id, avg);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
curLayer.sort((a, b) => (bary.get(a) ?? Infinity) - (bary.get(b) ?? Infinity));
|
|
149
|
+
}
|
|
150
|
+
// Bottom-up pass
|
|
151
|
+
for (let l = layers.length - 2; l >= 0; l--) {
|
|
152
|
+
const nextLayer = layers[l + 1];
|
|
153
|
+
const curLayer = layers[l];
|
|
154
|
+
const nextIndex = new Map();
|
|
155
|
+
for (let i = 0; i < nextLayer.length; i++) {
|
|
156
|
+
nextIndex.set(nextLayer[i], i);
|
|
157
|
+
}
|
|
158
|
+
const bary = new Map();
|
|
159
|
+
for (const id of curLayer) {
|
|
160
|
+
const chlds = (childrenMap.get(id) ?? []).filter(c => nextIndex.has(c));
|
|
161
|
+
if (chlds.length === 0) {
|
|
162
|
+
bary.set(id, Infinity);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const avg = chlds.reduce((s, c) => s + (nextIndex.get(c) ?? 0), 0) / chlds.length;
|
|
166
|
+
bary.set(id, avg);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
curLayer.sort((a, b) => (bary.get(a) ?? Infinity) - (bary.get(b) ?? Infinity));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=dag-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-layout.js","sourceRoot":"","sources":["../../../src/core/components/dag-layout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,sEAAsE;AAEtE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC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,CAAC;QAClC,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;QACvC,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACxE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;gBAClF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering functions for the DAG component.
|
|
3
|
+
*
|
|
4
|
+
* Handles node box construction, interactive layout rendering with ANSI styling,
|
|
5
|
+
* pipe-mode plain text output, and accessible structured text output.
|
|
6
|
+
*
|
|
7
|
+
* Imports types from `dag.ts` (type-only, erased at runtime).
|
|
8
|
+
* Imports layout functions from `dag-layout.ts` and edge primitives from `dag-edges.ts`.
|
|
9
|
+
*/
|
|
10
|
+
import type { BijouContext } from '../../ports/context.js';
|
|
11
|
+
import type { DagNode, DagOptions, DagNodePosition } from './dag.js';
|
|
12
|
+
/**
|
|
13
|
+
* Render the full interactive (styled) DAG layout.
|
|
14
|
+
*
|
|
15
|
+
* Performs the complete layout pipeline: layer assignment, column ordering,
|
|
16
|
+
* edge routing, node box rendering, highlight/selection styling, and ANSI
|
|
17
|
+
* serialization into a final string.
|
|
18
|
+
*
|
|
19
|
+
* @param nodes - The graph nodes to render.
|
|
20
|
+
* @param options - Rendering options (tokens, selection, sizing).
|
|
21
|
+
* @param ctx - The resolved bijou context.
|
|
22
|
+
* @returns The rendered output string, node position map, and grid dimensions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderInteractiveLayout(nodes: DagNode[], options: DagOptions, ctx: BijouContext): {
|
|
25
|
+
output: string;
|
|
26
|
+
nodes: Map<string, DagNodePosition>;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Render the graph as plain text for piped (non-TTY) output.
|
|
32
|
+
*
|
|
33
|
+
* Produces one line per node in the format `Label -> Target1, Target2`
|
|
34
|
+
* with no ANSI styling or box-drawing characters.
|
|
35
|
+
*
|
|
36
|
+
* @param nodes - The graph nodes to render.
|
|
37
|
+
* @returns Plain text representation of the graph.
|
|
38
|
+
*/
|
|
39
|
+
export declare function renderPipe(nodes: DagNode[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Render the graph as structured accessible text.
|
|
42
|
+
*
|
|
43
|
+
* Produces a summary header ("Graph: N nodes, M edges") followed by
|
|
44
|
+
* layer-grouped node listings with edge descriptions.
|
|
45
|
+
*
|
|
46
|
+
* @param nodes - The graph nodes to render.
|
|
47
|
+
* @param layerMap - Map from node ID to layer index.
|
|
48
|
+
* @returns Accessible text representation of the graph.
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderAccessible(nodes: DagNode[], layerMap: Map<string, number>): string;
|
|
51
|
+
//# sourceMappingURL=dag-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dag-render.d.ts","sourceRoot":"","sources":["../../../src/core/components/dag-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA6JrE;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,YAAY,GAChB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA0PxF;AAID;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAiBnD;AAID;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CA8BxF"}
|