@oh-my-pi/pi-utils 16.0.6 → 16.0.8
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 +10 -0
- package/dist/types/mermaid-ascii.d.ts +1 -1
- package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
- package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
- package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
- package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
- package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
- package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
- package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
- package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
- package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
- package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
- package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
- package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
- package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
- package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
- package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
- package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
- package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
- package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
- package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +21 -0
- package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
- package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
- package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
- package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
- package/package.json +2 -3
- package/src/mermaid-ascii.ts +1 -1
- package/src/vendor/mermaid-ascii/NOTICE +33 -0
- package/src/vendor/mermaid-ascii/ascii/ansi.ts +409 -0
- package/src/vendor/mermaid-ascii/ascii/canvas.ts +476 -0
- package/src/vendor/mermaid-ascii/ascii/class-diagram.ts +699 -0
- package/src/vendor/mermaid-ascii/ascii/converter.ts +271 -0
- package/src/vendor/mermaid-ascii/ascii/draw.ts +1382 -0
- package/src/vendor/mermaid-ascii/ascii/edge-bundling.ts +328 -0
- package/src/vendor/mermaid-ascii/ascii/edge-routing.ts +297 -0
- package/src/vendor/mermaid-ascii/ascii/er-diagram.ts +441 -0
- package/src/vendor/mermaid-ascii/ascii/grid.ts +578 -0
- package/src/vendor/mermaid-ascii/ascii/index.ts +187 -0
- package/src/vendor/mermaid-ascii/ascii/multiline-utils.ts +78 -0
- package/src/vendor/mermaid-ascii/ascii/pathfinder.ts +215 -0
- package/src/vendor/mermaid-ascii/ascii/sequence.ts +460 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/circle.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/corners.ts +127 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/diamond.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/hexagon.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/index.ts +101 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rectangle.ts +175 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/rounded.ts +27 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/special.ts +296 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/stadium.ts +114 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/state.ts +192 -0
- package/src/vendor/mermaid-ascii/ascii/shapes/types.ts +73 -0
- package/src/vendor/mermaid-ascii/ascii/types.ts +273 -0
- package/src/vendor/mermaid-ascii/ascii/validate.ts +120 -0
- package/src/vendor/mermaid-ascii/ascii/xychart.ts +875 -0
- package/src/vendor/mermaid-ascii/class/parser.ts +290 -0
- package/src/vendor/mermaid-ascii/class/types.ts +121 -0
- package/src/vendor/mermaid-ascii/er/parser.ts +181 -0
- package/src/vendor/mermaid-ascii/er/types.ts +91 -0
- package/src/vendor/mermaid-ascii/index.ts +14 -0
- package/src/vendor/mermaid-ascii/multiline-utils.ts +30 -0
- package/src/vendor/mermaid-ascii/parser.ts +645 -0
- package/src/vendor/mermaid-ascii/sequence/parser.ts +207 -0
- package/src/vendor/mermaid-ascii/sequence/types.ts +146 -0
- package/src/vendor/mermaid-ascii/text-metrics.ts +71 -0
- package/src/vendor/mermaid-ascii/types.ts +164 -0
- package/src/vendor/mermaid-ascii/xychart/colors.ts +140 -0
- package/src/vendor/mermaid-ascii/xychart/parser.ts +115 -0
- package/src/vendor/mermaid-ascii/xychart/types.ts +150 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Rounded rectangle shape renderer.
|
|
4
|
+
* Uses rounded corner markers (╭╮╰╯) to indicate soft edges.
|
|
5
|
+
*
|
|
6
|
+
* Renders as:
|
|
7
|
+
* ╭─────────╮
|
|
8
|
+
* │ Label │
|
|
9
|
+
* ╰─────────╯
|
|
10
|
+
*/
|
|
11
|
+
export declare const roundedRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Subroutine shape renderer — double-bordered rectangle.
|
|
4
|
+
* Renders as:
|
|
5
|
+
* ┌┬─────────┬┐
|
|
6
|
+
* ││ Label ││
|
|
7
|
+
* └┴─────────┴┘
|
|
8
|
+
*/
|
|
9
|
+
export declare const subroutineRenderer: ShapeRenderer;
|
|
10
|
+
/**
|
|
11
|
+
* Double circle shape renderer.
|
|
12
|
+
* Uses double circle markers (◎) at corners.
|
|
13
|
+
*
|
|
14
|
+
* Renders as:
|
|
15
|
+
* ◎─────────◎
|
|
16
|
+
* │ Label │
|
|
17
|
+
* ◎─────────◎
|
|
18
|
+
*/
|
|
19
|
+
export declare const doublecircleRenderer: ShapeRenderer;
|
|
20
|
+
/**
|
|
21
|
+
* Cylinder shape renderer — database symbol.
|
|
22
|
+
* Renders as:
|
|
23
|
+
* ╭─────╮
|
|
24
|
+
* │─────│
|
|
25
|
+
* │ DB │
|
|
26
|
+
* │─────│
|
|
27
|
+
* ╰─────╯
|
|
28
|
+
*/
|
|
29
|
+
export declare const cylinderRenderer: ShapeRenderer;
|
|
30
|
+
/**
|
|
31
|
+
* Asymmetric (flag/banner) shape renderer.
|
|
32
|
+
* Uses arrow markers (▷) on left corners.
|
|
33
|
+
*
|
|
34
|
+
* Renders as:
|
|
35
|
+
* ▷─────────┐
|
|
36
|
+
* │ Label │
|
|
37
|
+
* ▷─────────┘
|
|
38
|
+
*/
|
|
39
|
+
export declare const asymmetricRenderer: ShapeRenderer;
|
|
40
|
+
/**
|
|
41
|
+
* Trapezoid shape renderer — wider at bottom.
|
|
42
|
+
* Uses slope markers (◸◹) on top corners.
|
|
43
|
+
*
|
|
44
|
+
* Renders as:
|
|
45
|
+
* ◸─────────◹
|
|
46
|
+
* │ Label │
|
|
47
|
+
* └─────────┘
|
|
48
|
+
*/
|
|
49
|
+
export declare const trapezoidRenderer: ShapeRenderer;
|
|
50
|
+
/**
|
|
51
|
+
* Trapezoid-alt shape renderer — wider at top.
|
|
52
|
+
* Uses slope markers (◺◿) on bottom corners.
|
|
53
|
+
*
|
|
54
|
+
* Renders as:
|
|
55
|
+
* ┌─────────┐
|
|
56
|
+
* │ Label │
|
|
57
|
+
* ◺─────────◿
|
|
58
|
+
*/
|
|
59
|
+
export declare const trapezoidAltRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Stadium (pill) shape renderer.
|
|
4
|
+
*
|
|
5
|
+
* Single-line: ( Label )
|
|
6
|
+
*
|
|
7
|
+
* Multi-line unicode:
|
|
8
|
+
* ╭──────────╮
|
|
9
|
+
* │ Label │
|
|
10
|
+
* ╰──────────╯
|
|
11
|
+
*
|
|
12
|
+
* Multi-line ASCII:
|
|
13
|
+
* (----------)
|
|
14
|
+
* ( Label )
|
|
15
|
+
* (----------)
|
|
16
|
+
*/
|
|
17
|
+
export declare const stadiumRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* State start pseudo-state renderer — filled circle in rounded box.
|
|
4
|
+
* Renders as:
|
|
5
|
+
* ╭───╮
|
|
6
|
+
* │ ● │ (Unicode)
|
|
7
|
+
* ╰───╯
|
|
8
|
+
*
|
|
9
|
+
* .---.
|
|
10
|
+
* | * | (ASCII)
|
|
11
|
+
* '---'
|
|
12
|
+
*
|
|
13
|
+
* This represents the UML initial pseudo-state.
|
|
14
|
+
*/
|
|
15
|
+
export declare const stateStartRenderer: ShapeRenderer;
|
|
16
|
+
/**
|
|
17
|
+
* State end pseudo-state renderer — bullseye in double-bordered box.
|
|
18
|
+
* Renders as:
|
|
19
|
+
* ╔═══╗
|
|
20
|
+
* ║ ◎ ║ (Unicode)
|
|
21
|
+
* ╚═══╝
|
|
22
|
+
*
|
|
23
|
+
* #===#
|
|
24
|
+
* # * # (ASCII)
|
|
25
|
+
* #===#
|
|
26
|
+
*
|
|
27
|
+
* This represents the UML final state. The double border distinguishes it
|
|
28
|
+
* from the start state's single rounded border.
|
|
29
|
+
*/
|
|
30
|
+
export declare const stateEndRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Canvas, DrawingCoord, Direction, AsciiNodeShape } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Dimensions calculated for a shape, used by layout and rendering.
|
|
4
|
+
*/
|
|
5
|
+
export interface ShapeDimensions {
|
|
6
|
+
/** Total width in characters including borders */
|
|
7
|
+
width: number;
|
|
8
|
+
/** Total height in characters including borders */
|
|
9
|
+
height: number;
|
|
10
|
+
/** Label area bounds (where text can be placed) */
|
|
11
|
+
labelArea: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
/** Grid column widths for the 3-column layout [left, center, right] */
|
|
18
|
+
gridColumns: [number, number, number];
|
|
19
|
+
/** Grid row heights for the 3-row layout [top, middle, bottom] */
|
|
20
|
+
gridRows: [number, number, number];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options passed to shape renderers.
|
|
24
|
+
*/
|
|
25
|
+
export interface ShapeRenderOptions {
|
|
26
|
+
/** Use ASCII chars (+,-,|) vs Unicode box-drawing (┌,─,│) */
|
|
27
|
+
useAscii: boolean;
|
|
28
|
+
/** Padding inside the shape */
|
|
29
|
+
padding: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Interface for pluggable shape renderers.
|
|
33
|
+
* Each shape type implements this interface.
|
|
34
|
+
*/
|
|
35
|
+
export interface ShapeRenderer {
|
|
36
|
+
/**
|
|
37
|
+
* Calculate dimensions for this shape given a label.
|
|
38
|
+
* Used during layout to determine node size.
|
|
39
|
+
*/
|
|
40
|
+
getDimensions(label: string, options: ShapeRenderOptions): ShapeDimensions;
|
|
41
|
+
/**
|
|
42
|
+
* Render the shape to a canvas.
|
|
43
|
+
* Returns a standalone canvas containing just the shape.
|
|
44
|
+
*/
|
|
45
|
+
render(label: string, dimensions: ShapeDimensions, options: ShapeRenderOptions): Canvas;
|
|
46
|
+
/**
|
|
47
|
+
* Get the edge attachment point for a given direction.
|
|
48
|
+
* Used by edge routing to determine where edges connect.
|
|
49
|
+
*/
|
|
50
|
+
getAttachmentPoint(dir: Direction, dimensions: ShapeDimensions, baseCoord: DrawingCoord): DrawingCoord;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Registry of shape renderers keyed by shape type.
|
|
54
|
+
*/
|
|
55
|
+
export type ShapeRegistry = Map<AsciiNodeShape, ShapeRenderer>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { NodeShape } from '../types';
|
|
2
|
+
export type { NodeShape };
|
|
3
|
+
/**
|
|
4
|
+
* Shape type for ASCII rendering — maps parser shapes to ASCII renderers.
|
|
5
|
+
* Most shapes from the parser are supported, with fallback to 'rectangle'.
|
|
6
|
+
*/
|
|
7
|
+
export type AsciiNodeShape = NodeShape;
|
|
8
|
+
/** Logical grid coordinate — nodes occupy 3x3 blocks on this grid. */
|
|
9
|
+
export interface GridCoord {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
/** Character-level coordinate on the 2D text canvas. */
|
|
14
|
+
export interface DrawingCoord {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Direction constants model positions on a node's 3x3 grid block.
|
|
20
|
+
* Each node occupies grid cells [x..x+2, y..y+2].
|
|
21
|
+
* Directions are offsets into that block, used for edge attachment points.
|
|
22
|
+
*
|
|
23
|
+
* (0,0) UL (1,0) Up (2,0) UR
|
|
24
|
+
* (0,1) Left (1,1) Mid (2,1) Right
|
|
25
|
+
* (0,2) LL (1,2) Down (2,2) LR
|
|
26
|
+
*/
|
|
27
|
+
export interface Direction {
|
|
28
|
+
readonly x: number;
|
|
29
|
+
readonly y: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const Up: Direction;
|
|
32
|
+
export declare const Down: Direction;
|
|
33
|
+
export declare const Left: Direction;
|
|
34
|
+
export declare const Right: Direction;
|
|
35
|
+
export declare const UpperRight: Direction;
|
|
36
|
+
export declare const UpperLeft: Direction;
|
|
37
|
+
export declare const LowerRight: Direction;
|
|
38
|
+
export declare const LowerLeft: Direction;
|
|
39
|
+
export declare const Middle: Direction;
|
|
40
|
+
/** All named directions for iteration. */
|
|
41
|
+
export declare const ALL_DIRECTIONS: readonly Direction[];
|
|
42
|
+
/**
|
|
43
|
+
* 2D text canvas — column-major (canvas[x][y]).
|
|
44
|
+
* Each cell holds a single character (or space).
|
|
45
|
+
*/
|
|
46
|
+
export type Canvas = string[][];
|
|
47
|
+
/** A node in the ASCII graph, positioned on the grid. */
|
|
48
|
+
export interface AsciiNode {
|
|
49
|
+
/** Unique identity key — the original node ID from the parser (e.g. "A", "B"). */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Human-readable label for rendering inside the box (e.g. "Web Server"). */
|
|
52
|
+
displayLabel: string;
|
|
53
|
+
/** Node shape from the parser (e.g. "rectangle", "diamond", "circle"). */
|
|
54
|
+
shape: AsciiNodeShape;
|
|
55
|
+
index: number;
|
|
56
|
+
gridCoord: GridCoord | null;
|
|
57
|
+
drawingCoord: DrawingCoord | null;
|
|
58
|
+
drawing: Canvas | null;
|
|
59
|
+
drawn: boolean;
|
|
60
|
+
styleClassName: string;
|
|
61
|
+
styleClass: AsciiStyleClass;
|
|
62
|
+
}
|
|
63
|
+
/** Style class for colored node text (ported from Go's classDef). */
|
|
64
|
+
export interface AsciiStyleClass {
|
|
65
|
+
name: string;
|
|
66
|
+
styles: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
/** Edge line style for ASCII rendering. */
|
|
69
|
+
export type AsciiEdgeStyle = 'solid' | 'dotted' | 'thick';
|
|
70
|
+
/** An edge in the ASCII graph, with a routed path. */
|
|
71
|
+
export interface AsciiEdge {
|
|
72
|
+
from: AsciiNode;
|
|
73
|
+
to: AsciiNode;
|
|
74
|
+
text: string;
|
|
75
|
+
path: GridCoord[];
|
|
76
|
+
labelLine: GridCoord[];
|
|
77
|
+
startDir: Direction;
|
|
78
|
+
endDir: Direction;
|
|
79
|
+
/** Line style: solid (default), dotted (-.->) or thick (==>) */
|
|
80
|
+
style: AsciiEdgeStyle;
|
|
81
|
+
/** Whether to render an arrowhead at the start (source end) of the edge */
|
|
82
|
+
hasArrowStart: boolean;
|
|
83
|
+
/** Whether to render an arrowhead at the end (target end) of the edge */
|
|
84
|
+
hasArrowEnd: boolean;
|
|
85
|
+
/** Bundle this edge belongs to (if any). Set during bundling analysis. */
|
|
86
|
+
bundle?: EdgeBundle;
|
|
87
|
+
/**
|
|
88
|
+
* For bundled edges: path from source/target to the junction point.
|
|
89
|
+
* The full visual path is: pathToJunction + bundle.sharedPath (for fan-in)
|
|
90
|
+
* or bundle.sharedPath + pathToJunction (for fan-out).
|
|
91
|
+
*/
|
|
92
|
+
pathToJunction?: GridCoord[];
|
|
93
|
+
}
|
|
94
|
+
/** A subgraph container with bounding box for rendering. */
|
|
95
|
+
export interface AsciiSubgraph {
|
|
96
|
+
name: string;
|
|
97
|
+
nodes: AsciiNode[];
|
|
98
|
+
parent: AsciiSubgraph | null;
|
|
99
|
+
children: AsciiSubgraph[];
|
|
100
|
+
minX: number;
|
|
101
|
+
minY: number;
|
|
102
|
+
maxX: number;
|
|
103
|
+
maxY: number;
|
|
104
|
+
/** Optional direction override for layout within this subgraph (LR or TD). */
|
|
105
|
+
direction?: 'LR' | 'TD';
|
|
106
|
+
}
|
|
107
|
+
/** Configuration for ASCII rendering. */
|
|
108
|
+
export interface AsciiConfig {
|
|
109
|
+
/** true = ASCII chars (+,-,|), false = Unicode box-drawing (┌,─,│). Default: false */
|
|
110
|
+
useAscii: boolean;
|
|
111
|
+
/** Horizontal spacing between nodes. Default: 5 */
|
|
112
|
+
paddingX: number;
|
|
113
|
+
/** Vertical spacing between nodes. Default: 5 */
|
|
114
|
+
paddingY: number;
|
|
115
|
+
/** Padding inside node boxes. Default: 1 */
|
|
116
|
+
boxBorderPadding: number;
|
|
117
|
+
/** Graph direction: "LR" or "TD". */
|
|
118
|
+
graphDirection: 'LR' | 'TD';
|
|
119
|
+
}
|
|
120
|
+
/** Full ASCII graph state used during layout and rendering. */
|
|
121
|
+
export interface AsciiGraph {
|
|
122
|
+
nodes: AsciiNode[];
|
|
123
|
+
edges: AsciiEdge[];
|
|
124
|
+
canvas: Canvas;
|
|
125
|
+
/** Role canvas — tracks the role of each character for colored output. */
|
|
126
|
+
roleCanvas: RoleCanvas;
|
|
127
|
+
/** Grid occupancy map — maps "x,y" keys to node references. */
|
|
128
|
+
grid: Map<string, AsciiNode>;
|
|
129
|
+
columnWidth: Map<number, number>;
|
|
130
|
+
rowHeight: Map<number, number>;
|
|
131
|
+
subgraphs: AsciiSubgraph[];
|
|
132
|
+
config: AsciiConfig;
|
|
133
|
+
/** Offset applied to all drawing coords to accommodate subgraph borders. */
|
|
134
|
+
offsetX: number;
|
|
135
|
+
offsetY: number;
|
|
136
|
+
/** Edge bundles for parallel link visualization. Set during bundling analysis. */
|
|
137
|
+
bundles: EdgeBundle[];
|
|
138
|
+
}
|
|
139
|
+
export declare function gridCoordEquals(a: GridCoord, b: GridCoord): boolean;
|
|
140
|
+
export declare function drawingCoordEquals(a: DrawingCoord, b: DrawingCoord): boolean;
|
|
141
|
+
/** Apply a direction offset to a grid coordinate (move into the 3x3 block). */
|
|
142
|
+
export declare function gridCoordDirection(c: GridCoord, dir: Direction): GridCoord;
|
|
143
|
+
/** Key for storing GridCoord in a Map. */
|
|
144
|
+
export declare function gridKey(c: GridCoord): string;
|
|
145
|
+
/** Default empty style class. */
|
|
146
|
+
export declare const EMPTY_STYLE: AsciiStyleClass;
|
|
147
|
+
/**
|
|
148
|
+
* Role of a character in the ASCII diagram, used for theming.
|
|
149
|
+
* Each role maps to a different color when colors are enabled.
|
|
150
|
+
*/
|
|
151
|
+
export type CharRole = 'text' | 'border' | 'line' | 'arrow' | 'corner' | 'junction';
|
|
152
|
+
/**
|
|
153
|
+
* Role canvas — parallel to Canvas, tracks the role of each character.
|
|
154
|
+
* Same column-major structure: roleCanvas[x][y] gives the role at (x, y).
|
|
155
|
+
* null means the character has no role (whitespace).
|
|
156
|
+
*/
|
|
157
|
+
export type RoleCanvas = (CharRole | null)[][];
|
|
158
|
+
/**
|
|
159
|
+
* Theme colors for ASCII output — hex color strings.
|
|
160
|
+
* Derived from the SVG theme system for visual consistency.
|
|
161
|
+
*/
|
|
162
|
+
export interface AsciiTheme {
|
|
163
|
+
/** Text color (node labels, edge labels) */
|
|
164
|
+
fg: string;
|
|
165
|
+
/** Box border color (node borders, subgraph borders) */
|
|
166
|
+
border: string;
|
|
167
|
+
/** Edge line color (paths between nodes) */
|
|
168
|
+
line: string;
|
|
169
|
+
/** Arrowhead color (▲▼◄► or ^v<>) */
|
|
170
|
+
arrow: string;
|
|
171
|
+
/** Theme accent color (optional, used by xycharts for series 0) */
|
|
172
|
+
accent?: string;
|
|
173
|
+
/** Background color (optional, used by xycharts for dark-mode-aware shading) */
|
|
174
|
+
bg?: string;
|
|
175
|
+
/** Corner character color (optional, defaults to line) */
|
|
176
|
+
corner?: string;
|
|
177
|
+
/** Junction character color (optional, defaults to border) */
|
|
178
|
+
junction?: string;
|
|
179
|
+
}
|
|
180
|
+
/** Color mode for output. */
|
|
181
|
+
export type ColorMode = 'none' | 'ansi16' | 'ansi256' | 'truecolor' | 'html';
|
|
182
|
+
/**
|
|
183
|
+
* Edge bundle — groups edges that share a common source or target.
|
|
184
|
+
* Used to visually merge parallel links before they reach the shared node.
|
|
185
|
+
*
|
|
186
|
+
* For fan-in (A & B --> C): multiple sources converge to one target.
|
|
187
|
+
* For fan-out (A --> B & C): one source diverges to multiple targets.
|
|
188
|
+
*/
|
|
189
|
+
export interface EdgeBundle {
|
|
190
|
+
/** Bundle type: fan-in = many→one, fan-out = one→many */
|
|
191
|
+
type: 'fan-in' | 'fan-out';
|
|
192
|
+
/** Edges in this bundle */
|
|
193
|
+
edges: AsciiEdge[];
|
|
194
|
+
/** The common node (target for fan-in, source for fan-out) */
|
|
195
|
+
sharedNode: AsciiNode;
|
|
196
|
+
/** The non-shared nodes (sources for fan-in, targets for fan-out) */
|
|
197
|
+
otherNodes: AsciiNode[];
|
|
198
|
+
/** Junction point where edges merge/split — set during routing */
|
|
199
|
+
junctionPoint: GridCoord | null;
|
|
200
|
+
/** Path from junction to shared node (drawn once for all edges) */
|
|
201
|
+
sharedPath: GridCoord[];
|
|
202
|
+
/** Direction when entering/exiting the junction */
|
|
203
|
+
junctionDir: Direction;
|
|
204
|
+
/** Direction when entering/exiting the shared node */
|
|
205
|
+
sharedNodeDir: Direction;
|
|
206
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASCII Rendering Validation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides validation functions for ASCII diagram output,
|
|
5
|
+
* including diagonal line detection to ensure orthogonal-only routing.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Characters that represent diagonal lines in ASCII and Unicode modes.
|
|
9
|
+
* These should never appear in properly rendered diagrams.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DIAGONAL_CHARS: {
|
|
12
|
+
readonly ascii: readonly ['/', '\\'];
|
|
13
|
+
readonly unicode: readonly ['╱', '╲'];
|
|
14
|
+
readonly all: readonly ['/', '\\', '╱', '╲'];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Position of a diagonal character in ASCII output.
|
|
18
|
+
*/
|
|
19
|
+
export interface DiagonalPosition {
|
|
20
|
+
line: number;
|
|
21
|
+
col: number;
|
|
22
|
+
char: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if ASCII output contains any diagonal line characters.
|
|
26
|
+
* Returns true if diagonals are found (which is an error condition).
|
|
27
|
+
*
|
|
28
|
+
* @param asciiOutput - The rendered ASCII diagram string
|
|
29
|
+
* @returns true if diagonal characters are present, false otherwise
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasDiagonalLines(asciiOutput: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Find all diagonal line character positions in ASCII output.
|
|
34
|
+
* Useful for debugging when diagonals are detected.
|
|
35
|
+
*
|
|
36
|
+
* Skips diagonal characters that appear inside node labels (between box borders).
|
|
37
|
+
* This prevents false positives from labels like "feature/auth" or "release/1.0".
|
|
38
|
+
*
|
|
39
|
+
* @param asciiOutput - The rendered ASCII diagram string
|
|
40
|
+
* @returns Array of positions where diagonal characters were found
|
|
41
|
+
*/
|
|
42
|
+
export declare function findDiagonalLines(asciiOutput: string): DiagonalPosition[];
|
|
43
|
+
/**
|
|
44
|
+
* Assert that ASCII output contains no diagonal lines.
|
|
45
|
+
* Throws an error with detailed position information if diagonals are found.
|
|
46
|
+
*
|
|
47
|
+
* @param asciiOutput - The rendered ASCII diagram string
|
|
48
|
+
* @param context - Optional context string for error message (e.g., diagram name)
|
|
49
|
+
* @throws Error if diagonal characters are present
|
|
50
|
+
*/
|
|
51
|
+
export declare function assertNoDiagonals(asciiOutput: string, context?: string): void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Parsed class diagram — logical structure from mermaid text */
|
|
2
|
+
export interface ClassDiagram {
|
|
3
|
+
/** All class definitions */
|
|
4
|
+
classes: ClassNode[];
|
|
5
|
+
/** Relationships between classes */
|
|
6
|
+
relationships: ClassRelationship[];
|
|
7
|
+
/** Optional namespace groupings */
|
|
8
|
+
namespaces: ClassNamespace[];
|
|
9
|
+
}
|
|
10
|
+
export interface ClassNode {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
/** Annotation like <<interface>>, <<abstract>>, <<service>>, <<enumeration>> */
|
|
14
|
+
annotation?: string;
|
|
15
|
+
/** Class attributes (fields/properties) */
|
|
16
|
+
attributes: ClassMember[];
|
|
17
|
+
/** Class methods (functions) */
|
|
18
|
+
methods: ClassMember[];
|
|
19
|
+
}
|
|
20
|
+
export interface ClassMember {
|
|
21
|
+
/** Visibility: + public, - private, # protected, ~ package */
|
|
22
|
+
visibility: '+' | '-' | '#' | '~' | '';
|
|
23
|
+
/** Member name */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Type annotation (e.g., "String", "int", "void") */
|
|
26
|
+
type?: string;
|
|
27
|
+
/** Whether the member is static (underlined in UML) */
|
|
28
|
+
isStatic?: boolean;
|
|
29
|
+
/** Whether the member is abstract (italic in UML) */
|
|
30
|
+
isAbstract?: boolean;
|
|
31
|
+
/** Whether the member is a method (renders with parentheses) */
|
|
32
|
+
isMethod?: boolean;
|
|
33
|
+
/** Method parameters (e.g., "data", "key, val") — only for methods */
|
|
34
|
+
params?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Relationship types following UML conventions */
|
|
37
|
+
export type RelationshipType = 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization';
|
|
38
|
+
export interface ClassRelationship {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
type: RelationshipType;
|
|
42
|
+
/**
|
|
43
|
+
* Which end of the relationship line has the UML marker (triangle, diamond, arrow).
|
|
44
|
+
* Determined by the arrow syntax direction:
|
|
45
|
+
* - Prefix markers like `<|--`, `*--`, `o--` → 'from' (marker on left/from side)
|
|
46
|
+
* - Suffix markers like `..|>`, `-->`, `..>`, `--*`, `--o` → 'to' (marker on right/to side)
|
|
47
|
+
*/
|
|
48
|
+
markerAt: 'from' | 'to';
|
|
49
|
+
/** Label on the relationship line */
|
|
50
|
+
label?: string;
|
|
51
|
+
/** Cardinality at the "from" end (e.g., "1", "*", "0..1") */
|
|
52
|
+
fromCardinality?: string;
|
|
53
|
+
/** Cardinality at the "to" end */
|
|
54
|
+
toCardinality?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ClassNamespace {
|
|
57
|
+
name: string;
|
|
58
|
+
classIds: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface PositionedClassDiagram {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
classes: PositionedClassNode[];
|
|
64
|
+
relationships: PositionedClassRelationship[];
|
|
65
|
+
}
|
|
66
|
+
export interface PositionedClassNode {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
annotation?: string;
|
|
70
|
+
attributes: ClassMember[];
|
|
71
|
+
methods: ClassMember[];
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
/** Height of the header section (name + annotation) */
|
|
77
|
+
headerHeight: number;
|
|
78
|
+
/** Height of the attributes section */
|
|
79
|
+
attrHeight: number;
|
|
80
|
+
/** Height of the methods section */
|
|
81
|
+
methodHeight: number;
|
|
82
|
+
}
|
|
83
|
+
export interface PositionedClassRelationship {
|
|
84
|
+
from: string;
|
|
85
|
+
to: string;
|
|
86
|
+
type: RelationshipType;
|
|
87
|
+
/** Which end of the line has the UML marker — propagated from ClassRelationship */
|
|
88
|
+
markerAt: 'from' | 'to';
|
|
89
|
+
label?: string;
|
|
90
|
+
fromCardinality?: string;
|
|
91
|
+
toCardinality?: string;
|
|
92
|
+
/** Path points from source to target */
|
|
93
|
+
points: Array<{
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
}>;
|
|
97
|
+
/** Dagre-computed label center position (avoids overlaps between nearby edges) */
|
|
98
|
+
labelPosition?: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Parsed ER diagram — logical structure from mermaid text */
|
|
2
|
+
export interface ErDiagram {
|
|
3
|
+
/** All entity definitions */
|
|
4
|
+
entities: ErEntity[];
|
|
5
|
+
/** Relationships between entities */
|
|
6
|
+
relationships: ErRelationship[];
|
|
7
|
+
}
|
|
8
|
+
export interface ErEntity {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Display name (same as id unless aliased) */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Entity attributes (columns) */
|
|
13
|
+
attributes: ErAttribute[];
|
|
14
|
+
}
|
|
15
|
+
export interface ErAttribute {
|
|
16
|
+
/** Data type (string, int, varchar, etc.) */
|
|
17
|
+
type: string;
|
|
18
|
+
/** Attribute name */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Key constraints: PK, FK, UK */
|
|
21
|
+
keys: Array<'PK' | 'FK' | 'UK'>;
|
|
22
|
+
/** Optional comment */
|
|
23
|
+
comment?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cardinality notation (crow's foot):
|
|
27
|
+
* 'one' || exactly one
|
|
28
|
+
* 'zero-one' |o zero or one
|
|
29
|
+
* 'many' }| one or more
|
|
30
|
+
* 'zero-many' o{ zero or more
|
|
31
|
+
*/
|
|
32
|
+
export type Cardinality = 'one' | 'zero-one' | 'many' | 'zero-many';
|
|
33
|
+
export interface ErRelationship {
|
|
34
|
+
entity1: string;
|
|
35
|
+
entity2: string;
|
|
36
|
+
/** Cardinality at entity1's end */
|
|
37
|
+
cardinality1: Cardinality;
|
|
38
|
+
/** Cardinality at entity2's end */
|
|
39
|
+
cardinality2: Cardinality;
|
|
40
|
+
/** Relationship verb/label (e.g., "places", "contains") */
|
|
41
|
+
label: string;
|
|
42
|
+
/** Whether the relationship is identifying (solid line) or non-identifying (dashed) */
|
|
43
|
+
identifying: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface PositionedErDiagram {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
entities: PositionedErEntity[];
|
|
49
|
+
relationships: PositionedErRelationship[];
|
|
50
|
+
}
|
|
51
|
+
export interface PositionedErEntity {
|
|
52
|
+
id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
attributes: ErAttribute[];
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
/** Height of the header row */
|
|
60
|
+
headerHeight: number;
|
|
61
|
+
/** Height per attribute row */
|
|
62
|
+
rowHeight: number;
|
|
63
|
+
}
|
|
64
|
+
export interface PositionedErRelationship {
|
|
65
|
+
entity1: string;
|
|
66
|
+
entity2: string;
|
|
67
|
+
cardinality1: Cardinality;
|
|
68
|
+
cardinality2: Cardinality;
|
|
69
|
+
label: string;
|
|
70
|
+
identifying: boolean;
|
|
71
|
+
/** Path points from entity1 to entity2 */
|
|
72
|
+
points: Array<{
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ascii/index';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize label text for terminal ASCII output: strip surrounding quotes,
|
|
3
|
+
* convert <br> tags and literal newline escapes to newlines, and reduce
|
|
4
|
+
* inline formatting (HTML bold/italic/underline/strike tags and the markdown
|
|
5
|
+
* bold, italic, and strikethrough markers) to plain text. The ASCII renderer
|
|
6
|
+
* has no styled spans, so preserving the markup would print raw tags and
|
|
7
|
+
* markers inside node boxes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeBrTags(label: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MermaidGraph } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse Mermaid text into a logical graph structure.
|
|
4
|
+
* Auto-detects diagram type (flowchart or state diagram).
|
|
5
|
+
* Throws on invalid/unsupported input.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseMermaid(text: string): MermaidGraph;
|