@oh-my-pi/pi-utils 16.0.7 → 16.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.0.8] - 2026-06-18
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Mermaid diagrams are now rendered to ASCII by a first-party vendored renderer (`src/vendor/mermaid-ascii`, derived from the MIT-licensed `beautiful-mermaid`, ASCII pipeline only) with terminal display width measured via `Bun.stringWidth` (grapheme-aware, correct for wide/East-Asian glyphs and emoji). Inline label formatting (HTML formatting tags and markdown emphasis) is now reduced to plain text instead of printed raw.
|
|
10
|
+
|
|
11
|
+
### Removed
|
|
12
|
+
|
|
13
|
+
- Removed the external `beautiful-mermaid` dependency (and its transitive `elkjs`, ~3.13MB) in favor of the vendored ASCII renderer.
|
|
14
|
+
|
|
5
15
|
## [16.0.3] - 2026-06-16
|
|
6
16
|
|
|
7
17
|
### Added
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AsciiRenderOptions } from "
|
|
1
|
+
import { type AsciiRenderOptions } from "./vendor/mermaid-ascii";
|
|
2
2
|
export type { AsciiRenderOptions as MermaidAsciiRenderOptions };
|
|
3
3
|
export declare function renderMermaidAscii(source: string, options?: AsciiRenderOptions): string;
|
|
4
4
|
export declare function renderMermaidAsciiSafe(source: string, options?: AsciiRenderOptions): string | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CharRole, AsciiTheme, ColorMode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default ASCII theme derived from the SVG renderer's color palette.
|
|
4
|
+
* Uses the same mixing ratios to maintain visual consistency.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_ASCII_THEME: AsciiTheme;
|
|
7
|
+
/**
|
|
8
|
+
* Detect the best color mode for the current environment.
|
|
9
|
+
*
|
|
10
|
+
* Terminal detection order:
|
|
11
|
+
* 1. COLORTERM=truecolor or COLORTERM=24bit → truecolor
|
|
12
|
+
* 2. TERM contains "256color" → ansi256
|
|
13
|
+
* 3. TERM is set and not "dumb" → ansi16
|
|
14
|
+
*
|
|
15
|
+
* Browser: returns 'html' (uses <span> tags with inline styles).
|
|
16
|
+
* Unknown/piped: returns 'none'.
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectColorMode(): ColorMode;
|
|
19
|
+
/**
|
|
20
|
+
* Generate the ANSI escape sequence for a role color.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAnsiColor(role: CharRole, theme: AsciiTheme, mode: ColorMode): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the ANSI reset sequence.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAnsiReset(mode: ColorMode): string;
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a character with ANSI color codes based on its role.
|
|
29
|
+
*/
|
|
30
|
+
export declare function colorizeChar(char: string, role: CharRole | null, theme: AsciiTheme, mode: ColorMode): string;
|
|
31
|
+
/**
|
|
32
|
+
* Colorize an entire line efficiently by grouping consecutive same-role characters.
|
|
33
|
+
* This reduces the number of escape sequences (ANSI) or span tags (HTML) in the output.
|
|
34
|
+
*/
|
|
35
|
+
export declare function colorizeLine(chars: string[], roles: (CharRole | null)[], theme: AsciiTheme, mode: ColorMode): string;
|
|
36
|
+
/**
|
|
37
|
+
* Colorize a text string with a direct hex color.
|
|
38
|
+
* Used by renderers that need per-cell color control (e.g. multi-series xychart).
|
|
39
|
+
* Handles all output modes: ANSI (16/256/truecolor) and HTML.
|
|
40
|
+
*/
|
|
41
|
+
export declare function colorizeText(text: string, hex: string, mode: ColorMode): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Canvas, DrawingCoord, RoleCanvas, CharRole, AsciiTheme, ColorMode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a blank canvas filled with spaces.
|
|
4
|
+
* Dimensions are inclusive: mkCanvas(3, 2) creates a 4x3 grid (indices 0..3, 0..2).
|
|
5
|
+
*/
|
|
6
|
+
export declare function mkCanvas(x: number, y: number): Canvas;
|
|
7
|
+
/** Create a blank canvas with the same dimensions as the given canvas. */
|
|
8
|
+
export declare function copyCanvas(source: Canvas): Canvas;
|
|
9
|
+
/**
|
|
10
|
+
* Create a blank role canvas filled with nulls.
|
|
11
|
+
* Same dimensions as mkCanvas — column-major, roleCanvas[x][y].
|
|
12
|
+
*/
|
|
13
|
+
export declare function mkRoleCanvas(x: number, y: number): RoleCanvas;
|
|
14
|
+
/** Create a blank role canvas with the same dimensions as the given role canvas. */
|
|
15
|
+
export declare function copyRoleCanvas(source: RoleCanvas): RoleCanvas;
|
|
16
|
+
/**
|
|
17
|
+
* Grow the role canvas to fit at least (newX, newY), preserving existing roles.
|
|
18
|
+
* Mutates the role canvas in place and returns it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function increaseRoleCanvasSize(roleCanvas: RoleCanvas, newX: number, newY: number): RoleCanvas;
|
|
21
|
+
/**
|
|
22
|
+
* Set a role at a specific coordinate.
|
|
23
|
+
* Expands the role canvas if necessary.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setRole(roleCanvas: RoleCanvas, x: number, y: number, role: CharRole): void;
|
|
26
|
+
/**
|
|
27
|
+
* Merge role canvases — same logic as mergeCanvases but for roles.
|
|
28
|
+
* Non-null roles in overlays overwrite null roles in base.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergeRoleCanvases(base: RoleCanvas, offset: DrawingCoord, ...overlays: RoleCanvas[]): RoleCanvas;
|
|
31
|
+
/** Returns [maxX, maxY] — the highest valid indices in each dimension. */
|
|
32
|
+
export declare function getCanvasSize(canvas: Canvas): [number, number];
|
|
33
|
+
/**
|
|
34
|
+
* Grow the canvas to fit at least (newX, newY), preserving existing content.
|
|
35
|
+
* Mutates the canvas in place and returns it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function increaseSize(canvas: Canvas, newX: number, newY: number): Canvas;
|
|
38
|
+
export declare function isJunctionChar(c: string): boolean;
|
|
39
|
+
export declare function mergeJunctions(c1: string, c2: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Merge overlay canvases onto a base canvas at the given offset.
|
|
42
|
+
* Non-space characters in overlays overwrite the base.
|
|
43
|
+
* When both characters are Unicode junction chars, they're merged intelligently.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mergeCanvases(base: Canvas, offset: DrawingCoord, useAscii: boolean, ...overlays: Canvas[]): Canvas;
|
|
46
|
+
/** Options for converting canvas to string with optional coloring. */
|
|
47
|
+
export interface CanvasToStringOptions {
|
|
48
|
+
/** Role canvas for applying colors. If not provided, output is plain text. */
|
|
49
|
+
roleCanvas?: RoleCanvas;
|
|
50
|
+
/** Color mode for terminal output. Default: 'none' */
|
|
51
|
+
colorMode?: ColorMode;
|
|
52
|
+
/** Theme colors for ASCII output. Uses default theme if not provided. */
|
|
53
|
+
theme?: AsciiTheme;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Convert the canvas to a multi-line string (row by row, left to right).
|
|
57
|
+
* Optionally applies ANSI color codes based on character roles.
|
|
58
|
+
*/
|
|
59
|
+
export declare function canvasToString(canvas: Canvas, options?: CanvasToStringOptions): string;
|
|
60
|
+
/**
|
|
61
|
+
* Flip the canvas vertically (mirror across the horizontal center).
|
|
62
|
+
* Reverses row order within each column and remaps directional characters
|
|
63
|
+
* (arrows, corners, junctions) so they point the correct way after flip.
|
|
64
|
+
*
|
|
65
|
+
* Used to transform a TD-rendered canvas into BT output.
|
|
66
|
+
* Mutates the canvas in place and returns it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function flipCanvasVertically(canvas: Canvas): Canvas;
|
|
69
|
+
/**
|
|
70
|
+
* Flip the role canvas vertically to match flipCanvasVertically.
|
|
71
|
+
* Mutates the role canvas in place and returns it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function flipRoleCanvasVertically(roleCanvas: RoleCanvas): RoleCanvas;
|
|
74
|
+
/**
|
|
75
|
+
* Draw text string onto the canvas starting at the given coordinate.
|
|
76
|
+
* By default, preserves existing non-space characters (labels don't overwrite each other).
|
|
77
|
+
* Set forceOverwrite=true to always overwrite (for box content).
|
|
78
|
+
*/
|
|
79
|
+
export declare function drawText(canvas: Canvas, start: DrawingCoord, text: string, forceOverwrite?: boolean): void;
|
|
80
|
+
/**
|
|
81
|
+
* Set the canvas size to fit all grid columns and rows.
|
|
82
|
+
* Called after layout to ensure the canvas covers the full drawing area.
|
|
83
|
+
*/
|
|
84
|
+
export declare function setCanvasSizeToGrid(canvas: Canvas, columnWidth: Map<number, number>, rowHeight: Map<number, number>): void;
|
|
85
|
+
/**
|
|
86
|
+
* Set the role canvas size to match the grid dimensions.
|
|
87
|
+
* Should be called alongside setCanvasSizeToGrid.
|
|
88
|
+
*/
|
|
89
|
+
export declare function setRoleCanvasSizeToGrid(roleCanvas: RoleCanvas, columnWidth: Map<number, number>, rowHeight: Map<number, number>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsciiConfig, AsciiTheme, ColorMode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Render a Mermaid class diagram to ASCII/Unicode text.
|
|
4
|
+
*
|
|
5
|
+
* Pipeline: parse → build boxes → level-based layout → draw boxes → draw relationships → string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderClassAscii(text: string, config: AsciiConfig, colorMode?: ColorMode, theme?: AsciiTheme): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MermaidGraph } from '../types';
|
|
2
|
+
import type { AsciiGraph, AsciiConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a parsed MermaidGraph into an AsciiGraph ready for grid layout.
|
|
5
|
+
*
|
|
6
|
+
* Key mappings:
|
|
7
|
+
* - MermaidGraph.nodes (Map) → ordered AsciiNode[] preserving insertion order
|
|
8
|
+
* - MermaidGraph.edges → AsciiEdge[] with resolved node references
|
|
9
|
+
* - MermaidGraph.subgraphs → AsciiSubgraph[] with parent/child tree
|
|
10
|
+
* - Node labels are used as display names (not raw IDs)
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertToAsciiGraph(parsed: MermaidGraph, config: AsciiConfig): AsciiGraph;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Canvas, DrawingCoord, AsciiGraph, AsciiNode, AsciiEdge, AsciiSubgraph, AsciiEdgeStyle } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Draw a node using its shape type.
|
|
4
|
+
* Returns a standalone canvas containing the rendered shape.
|
|
5
|
+
*
|
|
6
|
+
* For basic shapes (rectangle, rounded), uses grid-determined dimensions
|
|
7
|
+
* to ensure consistent sizing across nodes in the same column.
|
|
8
|
+
* For special shapes (diamond, circle, state pseudo-states, etc.),
|
|
9
|
+
* uses shape-specific dimension calculation but centers the content
|
|
10
|
+
* within the grid cell dimensions to ensure proper vertical alignment.
|
|
11
|
+
*/
|
|
12
|
+
export declare function drawNode(node: AsciiNode, graph: AsciiGraph): Canvas;
|
|
13
|
+
/**
|
|
14
|
+
* Draw a node box with centered label text.
|
|
15
|
+
* Returns a standalone canvas containing just the box.
|
|
16
|
+
* Box size is determined by the grid column/row sizes for the node's position.
|
|
17
|
+
*/
|
|
18
|
+
export declare function drawBox(node: AsciiNode, graph: AsciiGraph): Canvas;
|
|
19
|
+
/**
|
|
20
|
+
* Draw a multi-section box with horizontal dividers between sections.
|
|
21
|
+
* Used by class diagrams (header | attributes | methods) and ER diagrams (header | attributes).
|
|
22
|
+
* Each section is an array of text lines to render left-aligned with padding.
|
|
23
|
+
*
|
|
24
|
+
* @param sections - Array of sections, each section is an array of text lines
|
|
25
|
+
* @param useAscii - true for ASCII chars, false for Unicode box-drawing
|
|
26
|
+
* @param padding - horizontal padding inside the box (default 1)
|
|
27
|
+
* @returns A standalone Canvas containing the multi-section box
|
|
28
|
+
*/
|
|
29
|
+
export declare function drawMultiBox(sections: string[][], useAscii: boolean, padding?: number): Canvas;
|
|
30
|
+
/**
|
|
31
|
+
* Draw a line between two drawing coordinates using orthogonal Manhattan routing.
|
|
32
|
+
* Returns the list of coordinates that were drawn on.
|
|
33
|
+
* offsetFrom/offsetTo control how many cells to skip at the start/end.
|
|
34
|
+
*
|
|
35
|
+
* All lines use 90° bends only - no diagonal lines are produced.
|
|
36
|
+
* For diagonal directions, uses horizontal-first routing (draws horizontal
|
|
37
|
+
* segment, then vertical segment).
|
|
38
|
+
*/
|
|
39
|
+
export declare function drawLine(canvas: Canvas, from: DrawingCoord, to: DrawingCoord, offsetFrom: number, offsetTo: number, useAscii: boolean, style?: AsciiEdgeStyle): DrawingCoord[];
|
|
40
|
+
/**
|
|
41
|
+
* Draw a complete arrow (edge) between two nodes.
|
|
42
|
+
* Returns 6 separate canvases for layered compositing:
|
|
43
|
+
* [path, boxStart, arrowHeadEnd, arrowHeadStart, corners, label]
|
|
44
|
+
*
|
|
45
|
+
* Supports bidirectional arrows via edge.hasArrowStart and edge.hasArrowEnd.
|
|
46
|
+
*/
|
|
47
|
+
export declare function drawArrow(graph: AsciiGraph, edge: AsciiEdge): [Canvas, Canvas, Canvas, Canvas, Canvas, Canvas];
|
|
48
|
+
/** Draw a subgraph border rectangle. */
|
|
49
|
+
export declare function drawSubgraphBox(sg: AsciiSubgraph, graph: AsciiGraph): Canvas;
|
|
50
|
+
/** Draw a subgraph label centered in its header area. Supports multi-line labels. */
|
|
51
|
+
export declare function drawSubgraphLabel(sg: AsciiSubgraph, graph: AsciiGraph): [Canvas, DrawingCoord];
|
|
52
|
+
/**
|
|
53
|
+
* Main draw function — renders the entire graph onto the canvas.
|
|
54
|
+
* Drawing order matters for correct layering:
|
|
55
|
+
* 1. Subgraph borders (bottom layer)
|
|
56
|
+
* 2. Node boxes
|
|
57
|
+
* 3. Edge paths (lines)
|
|
58
|
+
* 4. Edge corners
|
|
59
|
+
* 5. Arrowheads
|
|
60
|
+
* 6. Box-start junctions
|
|
61
|
+
* 7. Edge labels
|
|
62
|
+
* 8. Subgraph labels (top layer)
|
|
63
|
+
*
|
|
64
|
+
* Also fills the roleCanvas with character roles for colored output.
|
|
65
|
+
*/
|
|
66
|
+
export declare function drawGraph(graph: AsciiGraph): Canvas;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AsciiGraph, EdgeBundle, GridCoord } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Analyze graph edges and create bundles for parallel links.
|
|
4
|
+
*
|
|
5
|
+
* Groups edges by:
|
|
6
|
+
* - Fan-in: Multiple edges sharing the same target (A & B --> C)
|
|
7
|
+
* - Fan-out: Multiple edges sharing the same source (A --> B & C)
|
|
8
|
+
*
|
|
9
|
+
* Only creates bundles when:
|
|
10
|
+
* - Graph direction is TD (top-down) - LR routing handles merging naturally
|
|
11
|
+
* - 2+ edges share the endpoint
|
|
12
|
+
* - All edges have the same style (solid/dotted/thick)
|
|
13
|
+
* - None of the edges have labels (labels would overlap at junction)
|
|
14
|
+
* - Edges are not self-loops
|
|
15
|
+
*
|
|
16
|
+
* @returns Array of bundles. Each edge can belong to at most one bundle.
|
|
17
|
+
*/
|
|
18
|
+
export declare function analyzeEdgeBundles(graph: AsciiGraph): EdgeBundle[];
|
|
19
|
+
/**
|
|
20
|
+
* Calculate the optimal junction point for a bundle.
|
|
21
|
+
*
|
|
22
|
+
* For fan-in (A & B --> C):
|
|
23
|
+
* - Junction is placed between the sources and the target
|
|
24
|
+
* - In TD: above the target, horizontally centered between sources
|
|
25
|
+
* - In LR: left of the target, vertically centered between sources
|
|
26
|
+
*
|
|
27
|
+
* For fan-out (A --> B & C):
|
|
28
|
+
* - Junction is placed between the source and the targets
|
|
29
|
+
* - In TD: below the source, horizontally centered between targets
|
|
30
|
+
* - In LR: right of the source, vertically centered between targets
|
|
31
|
+
*/
|
|
32
|
+
export declare function calculateJunctionPoint(graph: AsciiGraph, bundle: EdgeBundle): GridCoord;
|
|
33
|
+
/**
|
|
34
|
+
* Route all edges in a bundle through the junction point.
|
|
35
|
+
*
|
|
36
|
+
* For fan-in bundles:
|
|
37
|
+
* 1. Route each source → junction (stored in edge.pathToJunction)
|
|
38
|
+
* 2. Route junction → target (stored in bundle.sharedPath)
|
|
39
|
+
*
|
|
40
|
+
* For fan-out bundles:
|
|
41
|
+
* 1. Route source → junction (stored in bundle.sharedPath)
|
|
42
|
+
* 2. Route junction → each target (stored in edge.pathToJunction)
|
|
43
|
+
*/
|
|
44
|
+
export declare function routeBundledEdges(graph: AsciiGraph, bundle: EdgeBundle): void;
|
|
45
|
+
/**
|
|
46
|
+
* Process all bundles in a graph: calculate junction points and route edges.
|
|
47
|
+
*/
|
|
48
|
+
export declare function processBundles(graph: AsciiGraph): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Direction, AsciiEdge, AsciiGraph } from './types';
|
|
2
|
+
export declare function getOpposite(d: Direction): Direction;
|
|
3
|
+
/** Compare directions by value (not reference). */
|
|
4
|
+
export declare function dirEquals(a: Direction, b: Direction): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Determine 8-way direction from one coordinate to another.
|
|
7
|
+
* Uses the coordinate difference to pick one of 8 cardinal/ordinal directions.
|
|
8
|
+
*/
|
|
9
|
+
export declare function determineDirection(from: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}, to: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}): Direction;
|
|
16
|
+
/**
|
|
17
|
+
* Determine preferred and alternative start/end directions for an edge.
|
|
18
|
+
* Returns [preferredStart, preferredEnd, alternativeStart, alternativeEnd].
|
|
19
|
+
*
|
|
20
|
+
* The edge routing tries both pairs and picks the shorter path.
|
|
21
|
+
* Direction selection depends on relative node positions and graph direction (LR vs TD).
|
|
22
|
+
*/
|
|
23
|
+
export declare function determineStartAndEndDir(edge: AsciiEdge, graphDirection: string): [Direction, Direction, Direction, Direction];
|
|
24
|
+
/**
|
|
25
|
+
* Determine the path for an edge by trying two candidate routes (preferred + alternative)
|
|
26
|
+
* and picking the shorter one. Sets edge.path, edge.startDir, edge.endDir.
|
|
27
|
+
*
|
|
28
|
+
* When both A* paths fail (common for edges crossing subgraph boundaries), falls back
|
|
29
|
+
* to a direct path using the start/end points. This ensures edges always have a path
|
|
30
|
+
* for arrowhead rendering.
|
|
31
|
+
*
|
|
32
|
+
* Uses the effective direction for edge routing, respecting subgraph direction overrides
|
|
33
|
+
* when both source and target are in the same subgraph.
|
|
34
|
+
*/
|
|
35
|
+
export declare function determinePath(graph: AsciiGraph, edge: AsciiEdge): void;
|
|
36
|
+
/**
|
|
37
|
+
* Find the best line segment in an edge's path to place a label on.
|
|
38
|
+
* Prefers vertical segments for TD/BT graphs and horizontal for LR/RL to avoid
|
|
39
|
+
* label collisions when multiple edges share initial segments.
|
|
40
|
+
* Falls back to the widest segment if none are suitable.
|
|
41
|
+
* Also increases the column width at the label position to fit the text.
|
|
42
|
+
*/
|
|
43
|
+
export declare function determineLabelLine(graph: AsciiGraph, edge: AsciiEdge): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsciiConfig, AsciiTheme, ColorMode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Render a Mermaid ER diagram to ASCII/Unicode text.
|
|
4
|
+
*
|
|
5
|
+
* Pipeline: parse → build boxes → component-aware layout → draw boxes → draw relationships → string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderErAscii(text: string, config: AsciiConfig, colorMode?: ColorMode, theme?: AsciiTheme): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { GridCoord, DrawingCoord, Direction, AsciiGraph, AsciiNode, AsciiSubgraph } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a grid coordinate to a drawing (character) coordinate.
|
|
4
|
+
* Sums column widths up to the target column, and row heights up to the target row,
|
|
5
|
+
* then centers within the cell.
|
|
6
|
+
*/
|
|
7
|
+
export declare function gridToDrawingCoord(graph: AsciiGraph, c: GridCoord, dir?: Direction): DrawingCoord;
|
|
8
|
+
/** Convert a path of grid coords to drawing coords. */
|
|
9
|
+
export declare function lineToDrawing(graph: AsciiGraph, line: GridCoord[]): DrawingCoord[];
|
|
10
|
+
/**
|
|
11
|
+
* Reserve a 3x3 block in the grid for a node.
|
|
12
|
+
* If the requested position is occupied, recursively shift by 4 grid units
|
|
13
|
+
* (in the perpendicular direction based on effective direction) until a free spot is found.
|
|
14
|
+
*
|
|
15
|
+
* @param effectiveDir - Optional direction override. If not provided, uses the node's
|
|
16
|
+
* effective direction (subgraph direction if in a subgraph with override,
|
|
17
|
+
* otherwise graph direction).
|
|
18
|
+
*/
|
|
19
|
+
export declare function reserveSpotInGrid(graph: AsciiGraph, node: AsciiNode, requested: GridCoord, effectiveDir?: 'LR' | 'TD'): GridCoord;
|
|
20
|
+
/**
|
|
21
|
+
* Set column widths and row heights for a node's 3x3 grid block.
|
|
22
|
+
* Each node occupies 3 columns (border, content, border) and 3 rows.
|
|
23
|
+
* Uses shape-aware dimensions to properly size non-rectangular shapes.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setColumnWidth(graph: AsciiGraph, node: AsciiNode): void;
|
|
26
|
+
/** Ensure grid has width/height entries for all cells along an edge path. */
|
|
27
|
+
export declare function increaseGridSizeForPath(graph: AsciiGraph, path: GridCoord[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get the innermost subgraph that directly contains this node.
|
|
30
|
+
* Returns null if node is not in any subgraph.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getNodeSubgraph(graph: AsciiGraph, node: AsciiNode): AsciiSubgraph | null;
|
|
33
|
+
/**
|
|
34
|
+
* Get the effective direction for a node's layout.
|
|
35
|
+
* Returns the subgraph's direction override if the node is in a subgraph with one,
|
|
36
|
+
* otherwise returns the graph-level direction.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getEffectiveDirection(graph: AsciiGraph, node: AsciiNode): 'LR' | 'TD';
|
|
39
|
+
export declare function calculateSubgraphBoundingBoxes(graph: AsciiGraph): void;
|
|
40
|
+
/**
|
|
41
|
+
* Offset all drawing coordinates so subgraph borders don't go negative.
|
|
42
|
+
* If any subgraph has negative min coordinates, shift everything positive.
|
|
43
|
+
*/
|
|
44
|
+
export declare function offsetDrawingForSubgraphs(graph: AsciiGraph): void;
|
|
45
|
+
/**
|
|
46
|
+
* createMapping performs the full grid layout:
|
|
47
|
+
* 1. Place root nodes on the grid
|
|
48
|
+
* 2. Place child nodes level by level
|
|
49
|
+
* 3. Compute column widths and row heights
|
|
50
|
+
* 4. Run A* pathfinding for all edges
|
|
51
|
+
* 5. Determine label placement
|
|
52
|
+
* 6. Convert grid coords → drawing coords
|
|
53
|
+
* 7. Generate node box drawings
|
|
54
|
+
* 8. Calculate subgraph bounding boxes
|
|
55
|
+
*/
|
|
56
|
+
export declare function createMapping(graph: AsciiGraph): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { detectColorMode, DEFAULT_ASCII_THEME } from './ansi';
|
|
2
|
+
import type { AsciiTheme, ColorMode } from './types';
|
|
3
|
+
import type { Direction } from '../types';
|
|
4
|
+
export type { AsciiTheme, ColorMode };
|
|
5
|
+
export { DEFAULT_ASCII_THEME, detectColorMode };
|
|
6
|
+
export interface AsciiRenderOptions {
|
|
7
|
+
/** true = ASCII chars (+,-,|,>), false = Unicode box-drawing (┌,─,│,►). Default: false */
|
|
8
|
+
useAscii?: boolean;
|
|
9
|
+
/** Horizontal spacing between nodes. Default: 5 */
|
|
10
|
+
paddingX?: number;
|
|
11
|
+
/** Vertical spacing between nodes. Default: 5 */
|
|
12
|
+
paddingY?: number;
|
|
13
|
+
/** Padding inside node boxes. Default: 1 */
|
|
14
|
+
boxBorderPadding?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Force the layout direction, overriding the direction parsed from the
|
|
17
|
+
* diagram source. Applies to the flowchart + state-diagram grid pipeline
|
|
18
|
+
* (sequence/class/ER/xychart renderers ignore it). Useful for re-fitting a
|
|
19
|
+
* wide `LR` graph into a narrow viewport by laying it out top-down.
|
|
20
|
+
* Default: undefined (use the source's own direction).
|
|
21
|
+
*/
|
|
22
|
+
direction?: Direction;
|
|
23
|
+
/**
|
|
24
|
+
* Color mode for output.
|
|
25
|
+
* - 'none': No colors (plain text)
|
|
26
|
+
* - 'auto': Auto-detect (terminal ANSI capabilities, or HTML in browsers)
|
|
27
|
+
* - 'ansi16': 16-color ANSI
|
|
28
|
+
* - 'ansi256': 256-color xterm
|
|
29
|
+
* - 'truecolor': 24-bit RGB
|
|
30
|
+
* - 'html': HTML <span> tags with inline color styles (for browser rendering)
|
|
31
|
+
* Default: 'auto'
|
|
32
|
+
*/
|
|
33
|
+
colorMode?: ColorMode | 'auto';
|
|
34
|
+
/** Theme colors for ASCII output. Uses default theme if not provided. */
|
|
35
|
+
theme?: Partial<AsciiTheme>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Render Mermaid diagram text to an ASCII/Unicode string.
|
|
39
|
+
*
|
|
40
|
+
* Synchronous — no async layout engine needed (unlike the SVG renderer).
|
|
41
|
+
* Auto-detects diagram type from the header line and dispatches to
|
|
42
|
+
* the appropriate renderer.
|
|
43
|
+
*
|
|
44
|
+
* @param text - Mermaid source text (any supported diagram type)
|
|
45
|
+
* @param options - Rendering options
|
|
46
|
+
* @returns Multi-line ASCII/Unicode string
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const result = renderMermaidAscii(`
|
|
51
|
+
* graph LR
|
|
52
|
+
* A --> B --> C
|
|
53
|
+
* `, { useAscii: true })
|
|
54
|
+
*
|
|
55
|
+
* // Output:
|
|
56
|
+
* // +---+ +---+ +---+
|
|
57
|
+
* // | | | | | |
|
|
58
|
+
* // | A |---->| B |---->| C |
|
|
59
|
+
* // | | | | | |
|
|
60
|
+
* // +---+ +---+ +---+
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function renderMermaidASCII(text: string, options?: AsciiRenderOptions): string;
|
|
64
|
+
/** Lowercase alias kept as the public name used by the pi-utils wrapper. */
|
|
65
|
+
export declare const renderMermaidAscii: typeof renderMermaidASCII;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Canvas } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Split a label into lines.
|
|
4
|
+
* Labels are already normalized by parsers (br tags → \n).
|
|
5
|
+
*/
|
|
6
|
+
export declare function splitLines(label: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Get the maximum line width for sizing calculations.
|
|
9
|
+
* Used to determine column widths for multi-line labels.
|
|
10
|
+
*/
|
|
11
|
+
export declare function maxLineWidth(label: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Get the number of lines for height calculations.
|
|
14
|
+
* Used to determine row heights for multi-line labels.
|
|
15
|
+
*/
|
|
16
|
+
export declare function lineCount(label: string): number;
|
|
17
|
+
/**
|
|
18
|
+
* Draw multi-line text centered at (cx, cy).
|
|
19
|
+
* Expands vertically from the center point.
|
|
20
|
+
* Each line is horizontally centered independently.
|
|
21
|
+
*/
|
|
22
|
+
export declare function drawMultilineTextCentered(canvas: Canvas, label: string, cx: number, cy: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Draw multi-line text left-aligned starting at (x, y).
|
|
25
|
+
* Each subsequent line is placed one row below.
|
|
26
|
+
*/
|
|
27
|
+
export declare function drawMultilineTextLeft(canvas: Canvas, label: string, x: number, y: number): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GridCoord, AsciiNode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Manhattan distance with a +1 penalty when both dx and dy are non-zero.
|
|
4
|
+
* This encourages the pathfinder to prefer straight lines and minimize corners.
|
|
5
|
+
*/
|
|
6
|
+
export declare function heuristic(a: GridCoord, b: GridCoord): number;
|
|
7
|
+
/**
|
|
8
|
+
* Find a path from `from` to `to` on the grid using A*.
|
|
9
|
+
* Returns the path as an array of GridCoords, or null if no path exists.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPath(grid: Map<string, AsciiNode>, from: GridCoord, to: GridCoord): GridCoord[] | null;
|
|
12
|
+
/**
|
|
13
|
+
* Simplify a path by removing intermediate waypoints on straight segments.
|
|
14
|
+
* E.g., [(0,0), (1,0), (2,0), (2,1)] becomes [(0,0), (2,0), (2,1)].
|
|
15
|
+
* This reduces the number of line-drawing operations.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergePath(path: GridCoord[]): GridCoord[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AsciiConfig, AsciiTheme, ColorMode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Render a Mermaid sequence diagram to ASCII/Unicode text.
|
|
4
|
+
*
|
|
5
|
+
* Pipeline: parse → layout (columns + rows) → draw onto canvas → string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderSequenceAscii(text: string, config: AsciiConfig, colorMode?: ColorMode, theme?: AsciiTheme): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Circle shape renderer.
|
|
4
|
+
* Uses circle markers (◯) at corners to indicate circular shape semantics.
|
|
5
|
+
*
|
|
6
|
+
* Renders as:
|
|
7
|
+
* ◯─────────◯
|
|
8
|
+
* │ Label │
|
|
9
|
+
* ◯─────────◯
|
|
10
|
+
*/
|
|
11
|
+
export declare const circleRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AsciiNodeShape } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Corner characters for a shape in both Unicode and ASCII modes.
|
|
4
|
+
*/
|
|
5
|
+
export interface CornerChars {
|
|
6
|
+
/** Top-left corner */
|
|
7
|
+
tl: string;
|
|
8
|
+
/** Top-right corner */
|
|
9
|
+
tr: string;
|
|
10
|
+
/** Bottom-left corner */
|
|
11
|
+
bl: string;
|
|
12
|
+
/** Bottom-right corner */
|
|
13
|
+
br: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Shape corner configuration with both Unicode and ASCII variants.
|
|
17
|
+
*/
|
|
18
|
+
export interface ShapeCorners {
|
|
19
|
+
unicode: CornerChars;
|
|
20
|
+
ascii: CornerChars;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Corner character lookup table for all shape types.
|
|
24
|
+
*
|
|
25
|
+
* Design principles:
|
|
26
|
+
* - All shapes use orthogonal box structure (no diagonals)
|
|
27
|
+
* - Corner characters indicate shape semantics
|
|
28
|
+
* - ASCII fallbacks use available punctuation
|
|
29
|
+
*/
|
|
30
|
+
export declare const SHAPE_CORNERS: Record<AsciiNodeShape, ShapeCorners>;
|
|
31
|
+
/**
|
|
32
|
+
* Get corner characters for a shape type.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCorners(shape: AsciiNodeShape, useAscii: boolean): CornerChars;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Diamond shape renderer.
|
|
4
|
+
* Uses diamond markers (◇) at corners to indicate decision node semantics.
|
|
5
|
+
*
|
|
6
|
+
* Renders as:
|
|
7
|
+
* ◇─────────◇
|
|
8
|
+
* │ Label │
|
|
9
|
+
* ◇─────────◇
|
|
10
|
+
*/
|
|
11
|
+
export declare const diamondRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hexagon shape renderer.
|
|
4
|
+
* Uses hexagon markers (⬡) at corners to indicate process node semantics.
|
|
5
|
+
*
|
|
6
|
+
* Renders as:
|
|
7
|
+
* ⬡─────────⬡
|
|
8
|
+
* │ Label │
|
|
9
|
+
* ⬡─────────⬡
|
|
10
|
+
*/
|
|
11
|
+
export declare const hexagonRenderer: ShapeRenderer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AsciiNodeShape, Canvas, DrawingCoord, Direction } from '../types';
|
|
2
|
+
import type { ShapeRenderer, ShapeDimensions, ShapeRenderOptions, ShapeRegistry } from './types';
|
|
3
|
+
export type { ShapeRenderer, ShapeDimensions, ShapeRenderOptions, ShapeRegistry };
|
|
4
|
+
/**
|
|
5
|
+
* Global shape registry — maps shape types to their renderers.
|
|
6
|
+
* Rectangle is the default fallback for unregistered shapes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const shapeRegistry: ShapeRegistry;
|
|
9
|
+
/**
|
|
10
|
+
* Get the renderer for a shape type, falling back to rectangle.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getShapeRenderer(shape: AsciiNodeShape): ShapeRenderer;
|
|
13
|
+
/**
|
|
14
|
+
* Render a node shape to a canvas.
|
|
15
|
+
* This is the main entry point for shape rendering.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderShape(shape: AsciiNodeShape, label: string, options: ShapeRenderOptions): Canvas;
|
|
18
|
+
/**
|
|
19
|
+
* Get dimensions for a shape given a label.
|
|
20
|
+
* Used during layout to determine node size.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getShapeDimensions(shape: AsciiNodeShape, label: string, options: ShapeRenderOptions): ShapeDimensions;
|
|
23
|
+
/**
|
|
24
|
+
* Get edge attachment point for a shape.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getShapeAttachmentPoint(shape: AsciiNodeShape, dir: Direction, dimensions: ShapeDimensions, baseCoord: DrawingCoord): DrawingCoord;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Canvas, DrawingCoord, Direction } from '../types';
|
|
2
|
+
import type { ShapeRenderer, ShapeDimensions, ShapeRenderOptions } from './types';
|
|
3
|
+
import { type CornerChars } from './corners';
|
|
4
|
+
/**
|
|
5
|
+
* Calculate standard box dimensions for any rectangular shape.
|
|
6
|
+
* Used by rectangle, circle, diamond, hexagon, etc.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBoxDimensions(label: string, options: ShapeRenderOptions): ShapeDimensions;
|
|
9
|
+
/**
|
|
10
|
+
* Render a box with custom corner characters.
|
|
11
|
+
* This is the core rendering function used by all rectangular shapes.
|
|
12
|
+
*
|
|
13
|
+
* @param label - Text to display in the box
|
|
14
|
+
* @param dimensions - Pre-calculated dimensions
|
|
15
|
+
* @param corners - Corner characters (tl, tr, bl, br)
|
|
16
|
+
* @param useAscii - Whether to use ASCII or Unicode for lines
|
|
17
|
+
*/
|
|
18
|
+
export declare function renderBox(label: string, dimensions: ShapeDimensions, corners: CornerChars, useAscii: boolean): Canvas;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate edge attachment point for rectangular shapes.
|
|
21
|
+
* All box-based shapes use the same attachment logic.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBoxAttachmentPoint(dir: Direction, dimensions: ShapeDimensions, baseCoord: DrawingCoord): DrawingCoord;
|
|
24
|
+
/**
|
|
25
|
+
* Rectangle shape renderer — the default box shape.
|
|
26
|
+
* Renders as:
|
|
27
|
+
* ┌─────────┐
|
|
28
|
+
* │ Label │
|
|
29
|
+
* └─────────┘
|
|
30
|
+
*/
|
|
31
|
+
export declare const rectangleRenderer: ShapeRenderer;
|