@chengchenccc/tui 0.1.1-rc.1
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/autocomplete.d.ts +56 -0
- package/dist/autocomplete.d.ts.map +1 -0
- package/dist/autocomplete.js +647 -0
- package/dist/components/box.d.ts +22 -0
- package/dist/components/box.d.ts.map +1 -0
- package/dist/components/box.js +103 -0
- package/dist/components/card.d.ts +33 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +49 -0
- package/dist/components/editor.d.ts +257 -0
- package/dist/components/editor.d.ts.map +1 -0
- package/dist/components/editor.js +1980 -0
- package/dist/components/input.d.ts +37 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +389 -0
- package/dist/components/loader.d.ts +33 -0
- package/dist/components/loader.d.ts.map +1 -0
- package/dist/components/loader.js +100 -0
- package/dist/components/markdown.d.ts +108 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +847 -0
- package/dist/components/markdown.test.d.ts +2 -0
- package/dist/components/markdown.test.d.ts.map +1 -0
- package/dist/components/markdown.test.js +81 -0
- package/dist/components/output-block.d.ts +44 -0
- package/dist/components/output-block.d.ts.map +1 -0
- package/dist/components/output-block.js +131 -0
- package/dist/components/select-list.d.ts +50 -0
- package/dist/components/select-list.d.ts.map +1 -0
- package/dist/components/select-list.js +166 -0
- package/dist/components/spacer.d.ts +12 -0
- package/dist/components/spacer.d.ts.map +1 -0
- package/dist/components/spacer.js +22 -0
- package/dist/components/statusline.d.ts +30 -0
- package/dist/components/statusline.d.ts.map +1 -0
- package/dist/components/statusline.js +46 -0
- package/dist/components/text.d.ts +19 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/text.js +90 -0
- package/dist/components/truncated-text.d.ts +13 -0
- package/dist/components/truncated-text.d.ts.map +1 -0
- package/dist/components/truncated-text.js +50 -0
- package/dist/editor-component.d.ts +39 -0
- package/dist/editor-component.d.ts.map +1 -0
- package/dist/editor-component.js +1 -0
- package/dist/fuzzy.d.ts +16 -0
- package/dist/fuzzy.d.ts.map +1 -0
- package/dist/fuzzy.js +109 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/keybindings.d.ts +193 -0
- package/dist/keybindings.d.ts.map +1 -0
- package/dist/keybindings.js +191 -0
- package/dist/keys.d.ts +184 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +1191 -0
- package/dist/kill-ring.d.ts +28 -0
- package/dist/kill-ring.d.ts.map +1 -0
- package/dist/kill-ring.js +43 -0
- package/dist/mermaid.d.ts +23 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +77 -0
- package/dist/mouse.d.ts +40 -0
- package/dist/mouse.d.ts.map +1 -0
- package/dist/mouse.js +39 -0
- package/dist/mouse.test.d.ts +2 -0
- package/dist/mouse.test.d.ts.map +1 -0
- package/dist/mouse.test.js +36 -0
- package/dist/native-modifiers.d.ts +3 -0
- package/dist/native-modifiers.d.ts.map +1 -0
- package/dist/native-modifiers.js +52 -0
- package/dist/stdin-buffer.d.ts +50 -0
- package/dist/stdin-buffer.d.ts.map +1 -0
- package/dist/stdin-buffer.js +360 -0
- package/dist/terminal-colors.d.ts +10 -0
- package/dist/terminal-colors.d.ts.map +1 -0
- package/dist/terminal-colors.js +58 -0
- package/dist/terminal-image.d.ts +90 -0
- package/dist/terminal-image.d.ts.map +1 -0
- package/dist/terminal-image.js +375 -0
- package/dist/terminal.d.ts +110 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +432 -0
- package/dist/tui-scrollback.test.d.ts +2 -0
- package/dist/tui-scrollback.test.d.ts.map +1 -0
- package/dist/tui-scrollback.test.js +51 -0
- package/dist/tui.d.ts +330 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +1568 -0
- package/dist/undo-stack.d.ts +17 -0
- package/dist/undo-stack.d.ts.map +1 -0
- package/dist/undo-stack.js +24 -0
- package/dist/utils.d.ts +85 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1066 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.d.ts +42 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/ansi.js +361 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.d.ts +90 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/canvas.js +414 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/class-diagram.js +623 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.d.ts +13 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/converter.js +233 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.d.ts +67 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/draw.js +1313 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +49 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-bundling.js +289 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.d.ts +44 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/edge-routing.js +302 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/er-diagram.js +380 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.d.ts +57 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/grid.js +516 -0
- package/dist/vendor/mermaid-ascii/ascii/index.d.ts +66 -0
- package/dist/vendor/mermaid-ascii/ascii/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/index.js +133 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +28 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/multiline-utils.js +60 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.d.ts +18 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/pathfinder.js +224 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/sequence.js +416 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/circle.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +35 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/corners.js +91 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/diamond.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/hexagon.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.d.ts +27 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/index.js +66 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +32 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rectangle.js +149 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +12 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/rounded.js +22 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.d.ts +60 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/special.js +253 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +18 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/stadium.js +103 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.d.ts +31 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/state.js +167 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.d.ts +56 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/shapes/types.js +4 -0
- package/dist/vendor/mermaid-ascii/ascii/types.d.ts +207 -0
- package/dist/vendor/mermaid-ascii/ascii/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/types.js +39 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.d.ts +52 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/validate.js +97 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.d.ts +3 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/ascii/xychart.js +719 -0
- package/dist/vendor/mermaid-ascii/class/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/class/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/class/parser.js +265 -0
- package/dist/vendor/mermaid-ascii/class/types.d.ts +103 -0
- package/dist/vendor/mermaid-ascii/class/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/class/types.js +7 -0
- package/dist/vendor/mermaid-ascii/er/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/er/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/er/parser.js +162 -0
- package/dist/vendor/mermaid-ascii/er/types.d.ts +77 -0
- package/dist/vendor/mermaid-ascii/er/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/er/types.js +7 -0
- package/dist/vendor/mermaid-ascii/index.d.ts +2 -0
- package/dist/vendor/mermaid-ascii/index.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/index.js +13 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.d.ts +10 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/multiline-utils.js +29 -0
- package/dist/vendor/mermaid-ascii/parser.d.ts +8 -0
- package/dist/vendor/mermaid-ascii/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/parser.js +558 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/sequence/parser.js +182 -0
- package/dist/vendor/mermaid-ascii/sequence/types.d.ts +131 -0
- package/dist/vendor/mermaid-ascii/sequence/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/sequence/types.js +7 -0
- package/dist/vendor/mermaid-ascii/text-metrics.d.ts +24 -0
- package/dist/vendor/mermaid-ascii/text-metrics.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/text-metrics.js +69 -0
- package/dist/vendor/mermaid-ascii/types.d.ts +115 -0
- package/dist/vendor/mermaid-ascii/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/types.js +4 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.d.ts +26 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/colors.js +145 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.d.ts +7 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/parser.js +105 -0
- package/dist/vendor/mermaid-ascii/xychart/types.d.ts +146 -0
- package/dist/vendor/mermaid-ascii/xychart/types.d.ts.map +1 -0
- package/dist/vendor/mermaid-ascii/xychart/types.js +8 -0
- package/dist/virtual-terminal.d.ts +80 -0
- package/dist/virtual-terminal.d.ts.map +1 -0
- package/dist/virtual-terminal.js +284 -0
- package/dist/word-navigation.d.ts +25 -0
- package/dist/word-navigation.d.ts.map +1 -0
- package/dist/word-navigation.js +97 -0
- package/package.json +38 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Stadium (pill) shape renderer — special parentheses-based rendering
|
|
3
|
+
// ============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Stadium has unique rendering: single-line is inline `(Label)`, multi-line
|
|
6
|
+
// uses parentheses or rounded corners. This differs from other shapes that
|
|
7
|
+
// use corner decorators with box lines.
|
|
8
|
+
import { mkCanvas } from "../canvas.js";
|
|
9
|
+
import { splitLines } from "../multiline-utils.js";
|
|
10
|
+
import { getBoxAttachmentPoint } from "./rectangle.js";
|
|
11
|
+
import { displayWidth, toCells } from "../../text-metrics.js";
|
|
12
|
+
/**
|
|
13
|
+
* Stadium (pill) shape renderer.
|
|
14
|
+
*
|
|
15
|
+
* Single-line: ( Label )
|
|
16
|
+
*
|
|
17
|
+
* Multi-line unicode:
|
|
18
|
+
* ╭──────────╮
|
|
19
|
+
* │ Label │
|
|
20
|
+
* ╰──────────╯
|
|
21
|
+
*
|
|
22
|
+
* Multi-line ASCII:
|
|
23
|
+
* (----------)
|
|
24
|
+
* ( Label )
|
|
25
|
+
* (----------)
|
|
26
|
+
*/
|
|
27
|
+
export const stadiumRenderer = {
|
|
28
|
+
getDimensions(label, options) {
|
|
29
|
+
const lines = splitLines(label);
|
|
30
|
+
const maxLineWidth = Math.max(...lines.map(l => displayWidth(l)), 0);
|
|
31
|
+
const lineCount = lines.length;
|
|
32
|
+
const innerWidth = 2 * options.padding + maxLineWidth;
|
|
33
|
+
const width = innerWidth + 4; // Extra for rounded ends
|
|
34
|
+
const innerHeight = lineCount + 2 * options.padding;
|
|
35
|
+
const height = Math.max(innerHeight + 2, 3);
|
|
36
|
+
return {
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
labelArea: {
|
|
40
|
+
x: 2 + options.padding,
|
|
41
|
+
y: 1 + options.padding,
|
|
42
|
+
width: maxLineWidth,
|
|
43
|
+
height: lineCount,
|
|
44
|
+
},
|
|
45
|
+
gridColumns: [2, innerWidth, 2],
|
|
46
|
+
gridRows: [1, innerHeight, 1],
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
render(label, dimensions, options) {
|
|
50
|
+
const { width, height } = dimensions;
|
|
51
|
+
const canvas = mkCanvas(width - 1, height - 1);
|
|
52
|
+
const centerY = Math.floor(height / 2);
|
|
53
|
+
const hChar = options.useAscii ? '-' : '─';
|
|
54
|
+
if (height === 3) {
|
|
55
|
+
// Single row pill: ( Label )
|
|
56
|
+
canvas[0][centerY] = '(';
|
|
57
|
+
canvas[width - 1][centerY] = ')';
|
|
58
|
+
}
|
|
59
|
+
else if (!options.useAscii) {
|
|
60
|
+
// Multi-row stadium with rounded corners (unicode)
|
|
61
|
+
canvas[0][0] = '╭';
|
|
62
|
+
for (let x = 1; x < width - 1; x++)
|
|
63
|
+
canvas[x][0] = hChar;
|
|
64
|
+
canvas[width - 1][0] = '╮';
|
|
65
|
+
for (let y = 1; y < height - 1; y++) {
|
|
66
|
+
canvas[0][y] = '│';
|
|
67
|
+
canvas[width - 1][y] = '│';
|
|
68
|
+
}
|
|
69
|
+
canvas[0][height - 1] = '╰';
|
|
70
|
+
for (let x = 1; x < width - 1; x++)
|
|
71
|
+
canvas[x][height - 1] = hChar;
|
|
72
|
+
canvas[width - 1][height - 1] = '╯';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Multi-row stadium ASCII — parentheses on all sides
|
|
76
|
+
for (let y = 0; y < height; y++) {
|
|
77
|
+
canvas[0][y] = '(';
|
|
78
|
+
canvas[width - 1][y] = ')';
|
|
79
|
+
}
|
|
80
|
+
for (let x = 1; x < width - 1; x++) {
|
|
81
|
+
canvas[x][0] = hChar;
|
|
82
|
+
canvas[x][height - 1] = hChar;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Center the label
|
|
86
|
+
const lines = splitLines(label);
|
|
87
|
+
const startY = centerY - Math.floor((lines.length - 1) / 2);
|
|
88
|
+
for (let i = 0; i < lines.length; i++) {
|
|
89
|
+
const line = lines[i];
|
|
90
|
+
const cells = toCells(line);
|
|
91
|
+
const textX = Math.floor(width / 2) - Math.floor(cells.length / 2);
|
|
92
|
+
for (let j = 0; j < cells.length; j++) {
|
|
93
|
+
const x = textX + j;
|
|
94
|
+
const y = startY + i;
|
|
95
|
+
if (x > 0 && x < width - 1 && y >= 0 && y < height) {
|
|
96
|
+
canvas[x][y] = cells[j];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return canvas;
|
|
101
|
+
},
|
|
102
|
+
getAttachmentPoint: getBoxAttachmentPoint,
|
|
103
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ShapeRenderer } from './types.ts';
|
|
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;
|
|
31
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../src/vendor/mermaid-ascii/ascii/shapes/state.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAuC,MAAM,YAAY,CAAA;AAGpF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,EAAE,aA4EhC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,EAAE,aA4E9B,CAAA"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// State pseudo-state renderers — UML start and end states
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { Up, Down, Left, Right } from "../types.js";
|
|
5
|
+
import { mkCanvas } from "../canvas.js";
|
|
6
|
+
import { dirEquals } from "../edge-routing.js";
|
|
7
|
+
/**
|
|
8
|
+
* State start pseudo-state renderer — filled circle in rounded box.
|
|
9
|
+
* Renders as:
|
|
10
|
+
* ╭───╮
|
|
11
|
+
* │ ● │ (Unicode)
|
|
12
|
+
* ╰───╯
|
|
13
|
+
*
|
|
14
|
+
* .---.
|
|
15
|
+
* | * | (ASCII)
|
|
16
|
+
* '---'
|
|
17
|
+
*
|
|
18
|
+
* This represents the UML initial pseudo-state.
|
|
19
|
+
*/
|
|
20
|
+
export const stateStartRenderer = {
|
|
21
|
+
getDimensions(_label, _options) {
|
|
22
|
+
// Start state is a 5x3 rounded box with centered symbol
|
|
23
|
+
const width = 5;
|
|
24
|
+
const height = 3;
|
|
25
|
+
return {
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
labelArea: { x: 2, y: 1, width: 1, height: 1 },
|
|
29
|
+
gridColumns: [1, 3, 1],
|
|
30
|
+
gridRows: [1, 1, 1],
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
render(_label, dimensions, options) {
|
|
34
|
+
const { width, height } = dimensions;
|
|
35
|
+
const canvas = mkCanvas(width - 1, height - 1);
|
|
36
|
+
const centerX = Math.floor(width / 2); // = 2
|
|
37
|
+
if (!options.useAscii) {
|
|
38
|
+
// Unicode rounded box with filled circle: ╭───╮ │ ● │ ╰───╯
|
|
39
|
+
canvas[0][0] = '╭';
|
|
40
|
+
canvas[1][0] = '─';
|
|
41
|
+
canvas[2][0] = '─';
|
|
42
|
+
canvas[3][0] = '─';
|
|
43
|
+
canvas[4][0] = '╮';
|
|
44
|
+
canvas[0][1] = '│';
|
|
45
|
+
canvas[centerX][1] = '●';
|
|
46
|
+
canvas[4][1] = '│';
|
|
47
|
+
canvas[0][2] = '╰';
|
|
48
|
+
canvas[1][2] = '─';
|
|
49
|
+
canvas[2][2] = '─';
|
|
50
|
+
canvas[3][2] = '─';
|
|
51
|
+
canvas[4][2] = '╯';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// ASCII rounded box: .---. | * | '---'
|
|
55
|
+
canvas[0][0] = '.';
|
|
56
|
+
canvas[1][0] = '-';
|
|
57
|
+
canvas[2][0] = '-';
|
|
58
|
+
canvas[3][0] = '-';
|
|
59
|
+
canvas[4][0] = '.';
|
|
60
|
+
canvas[0][1] = '|';
|
|
61
|
+
canvas[centerX][1] = '*';
|
|
62
|
+
canvas[4][1] = '|';
|
|
63
|
+
canvas[0][2] = '\'';
|
|
64
|
+
canvas[1][2] = '-';
|
|
65
|
+
canvas[2][2] = '-';
|
|
66
|
+
canvas[3][2] = '-';
|
|
67
|
+
canvas[4][2] = '\'';
|
|
68
|
+
}
|
|
69
|
+
return canvas;
|
|
70
|
+
},
|
|
71
|
+
getAttachmentPoint(dir, dimensions, baseCoord) {
|
|
72
|
+
const { width, height } = dimensions;
|
|
73
|
+
const centerX = baseCoord.x + Math.floor(width / 2);
|
|
74
|
+
const centerY = baseCoord.y + Math.floor(height / 2);
|
|
75
|
+
if (dirEquals(dir, Up))
|
|
76
|
+
return { x: centerX, y: baseCoord.y };
|
|
77
|
+
if (dirEquals(dir, Down))
|
|
78
|
+
return { x: centerX, y: baseCoord.y + height - 1 };
|
|
79
|
+
if (dirEquals(dir, Left))
|
|
80
|
+
return { x: baseCoord.x, y: centerY };
|
|
81
|
+
if (dirEquals(dir, Right))
|
|
82
|
+
return { x: baseCoord.x + width - 1, y: centerY };
|
|
83
|
+
// All diagonals and middle point to center
|
|
84
|
+
return { x: centerX, y: centerY };
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* State end pseudo-state renderer — bullseye in double-bordered box.
|
|
89
|
+
* Renders as:
|
|
90
|
+
* ╔═══╗
|
|
91
|
+
* ║ ◎ ║ (Unicode)
|
|
92
|
+
* ╚═══╝
|
|
93
|
+
*
|
|
94
|
+
* #===#
|
|
95
|
+
* # * # (ASCII)
|
|
96
|
+
* #===#
|
|
97
|
+
*
|
|
98
|
+
* This represents the UML final state. The double border distinguishes it
|
|
99
|
+
* from the start state's single rounded border.
|
|
100
|
+
*/
|
|
101
|
+
export const stateEndRenderer = {
|
|
102
|
+
getDimensions(_label, _options) {
|
|
103
|
+
// End state is a 5x3 double-bordered box with centered symbol
|
|
104
|
+
const width = 5;
|
|
105
|
+
const height = 3;
|
|
106
|
+
return {
|
|
107
|
+
width,
|
|
108
|
+
height,
|
|
109
|
+
labelArea: { x: 2, y: 1, width: 1, height: 1 },
|
|
110
|
+
gridColumns: [1, 3, 1],
|
|
111
|
+
gridRows: [1, 1, 1],
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
render(_label, dimensions, options) {
|
|
115
|
+
const { width, height } = dimensions;
|
|
116
|
+
const canvas = mkCanvas(width - 1, height - 1);
|
|
117
|
+
const centerX = Math.floor(width / 2); // = 2
|
|
118
|
+
if (!options.useAscii) {
|
|
119
|
+
// Unicode double-bordered box with bullseye: ╔═══╗ ║ ◎ ║ ╚═══╝
|
|
120
|
+
canvas[0][0] = '╔';
|
|
121
|
+
canvas[1][0] = '═';
|
|
122
|
+
canvas[2][0] = '═';
|
|
123
|
+
canvas[3][0] = '═';
|
|
124
|
+
canvas[4][0] = '╗';
|
|
125
|
+
canvas[0][1] = '║';
|
|
126
|
+
canvas[centerX][1] = '◎';
|
|
127
|
+
canvas[4][1] = '║';
|
|
128
|
+
canvas[0][2] = '╚';
|
|
129
|
+
canvas[1][2] = '═';
|
|
130
|
+
canvas[2][2] = '═';
|
|
131
|
+
canvas[3][2] = '═';
|
|
132
|
+
canvas[4][2] = '╝';
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// ASCII double-bordered box: #===# # * # #===#
|
|
136
|
+
canvas[0][0] = '#';
|
|
137
|
+
canvas[1][0] = '=';
|
|
138
|
+
canvas[2][0] = '=';
|
|
139
|
+
canvas[3][0] = '=';
|
|
140
|
+
canvas[4][0] = '#';
|
|
141
|
+
canvas[0][1] = '#';
|
|
142
|
+
canvas[centerX][1] = '*';
|
|
143
|
+
canvas[4][1] = '#';
|
|
144
|
+
canvas[0][2] = '#';
|
|
145
|
+
canvas[1][2] = '=';
|
|
146
|
+
canvas[2][2] = '=';
|
|
147
|
+
canvas[3][2] = '=';
|
|
148
|
+
canvas[4][2] = '#';
|
|
149
|
+
}
|
|
150
|
+
return canvas;
|
|
151
|
+
},
|
|
152
|
+
getAttachmentPoint(dir, dimensions, baseCoord) {
|
|
153
|
+
const { width, height } = dimensions;
|
|
154
|
+
const centerX = baseCoord.x + Math.floor(width / 2);
|
|
155
|
+
const centerY = baseCoord.y + Math.floor(height / 2);
|
|
156
|
+
if (dirEquals(dir, Up))
|
|
157
|
+
return { x: centerX, y: baseCoord.y };
|
|
158
|
+
if (dirEquals(dir, Down))
|
|
159
|
+
return { x: centerX, y: baseCoord.y + height - 1 };
|
|
160
|
+
if (dirEquals(dir, Left))
|
|
161
|
+
return { x: baseCoord.x, y: centerY };
|
|
162
|
+
if (dirEquals(dir, Right))
|
|
163
|
+
return { x: baseCoord.x + width - 1, y: centerY };
|
|
164
|
+
// All diagonals and middle point to center
|
|
165
|
+
return { x: centerX, y: centerY };
|
|
166
|
+
},
|
|
167
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Canvas, DrawingCoord, Direction, AsciiNodeShape } from '../types.ts';
|
|
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>;
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/vendor/mermaid-ascii/ascii/shapes/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EA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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
|
+
}
|
|
207
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/vendor/mermaid-ascii/ascii/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG5C,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAA;AAEtC,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,EAAE,EAAE,SAAkC,CAAA;AACnD,eAAO,MAAM,IAAI,EAAE,SAAgC,CAAA;AACnD,eAAO,MAAM,IAAI,EAAE,SAAgC,CAAA;AACnD,eAAO,MAAM,KAAK,EAAE,SAA+B,CAAA;AACnD,eAAO,MAAM,UAAU,EAAE,SAA0B,CAAA;AACnD,eAAO,MAAM,SAAS,EAAE,SAA2B,CAAA;AACnD,eAAO,MAAM,UAAU,EAAE,SAA0B,CAAA;AACnD,eAAO,MAAM,SAAS,EAAE,SAA2B,CAAA;AACnD,eAAO,MAAM,MAAM,EAAE,SAA8B,CAAA;AAEnD,0CAA0C;AAC1C,eAAO,MAAM,cAAc,EAAE,SAAS,SAAS,EAE9C,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;AAE/B,yDAAyD;AACzD,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,IAAI,EAA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rE,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB,kEAAkE;IAClE,aAAa,EAAE,SAAS,GAAG,IAAI,CAAA;IAC/B,mEAAmE;IACnE,UAAU,EAAE,SAAS,EAAE,CAAA;IACvB,mDAAmD;IACnD,WAAW,EAAE,SAAS,CAAA;IACtB,sDAAsD;IACtD,aAAa,EAAE,SAAS,CAAA;CACzB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// ASCII renderer — type definitions
|
|
3
|
+
//
|
|
4
|
+
// Ported from AlexanderGrooff/mermaid-ascii (Go).
|
|
5
|
+
// These types model the grid-based coordinate system, 2D text canvas,
|
|
6
|
+
// and graph structures used by the ASCII/Unicode renderer.
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export const Up = { x: 1, y: 0 };
|
|
9
|
+
export const Down = { x: 1, y: 2 };
|
|
10
|
+
export const Left = { x: 0, y: 1 };
|
|
11
|
+
export const Right = { x: 2, y: 1 };
|
|
12
|
+
export const UpperRight = { x: 2, y: 0 };
|
|
13
|
+
export const UpperLeft = { x: 0, y: 0 };
|
|
14
|
+
export const LowerRight = { x: 2, y: 2 };
|
|
15
|
+
export const LowerLeft = { x: 0, y: 2 };
|
|
16
|
+
export const Middle = { x: 1, y: 1 };
|
|
17
|
+
/** All named directions for iteration. */
|
|
18
|
+
export const ALL_DIRECTIONS = [
|
|
19
|
+
Up, Down, Left, Right, UpperRight, UpperLeft, LowerRight, LowerLeft, Middle,
|
|
20
|
+
];
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Coordinate helpers
|
|
23
|
+
// ============================================================================
|
|
24
|
+
export function gridCoordEquals(a, b) {
|
|
25
|
+
return a.x === b.x && a.y === b.y;
|
|
26
|
+
}
|
|
27
|
+
export function drawingCoordEquals(a, b) {
|
|
28
|
+
return a.x === b.x && a.y === b.y;
|
|
29
|
+
}
|
|
30
|
+
/** Apply a direction offset to a grid coordinate (move into the 3x3 block). */
|
|
31
|
+
export function gridCoordDirection(c, dir) {
|
|
32
|
+
return { x: c.x + dir.x, y: c.y + dir.y };
|
|
33
|
+
}
|
|
34
|
+
/** Key for storing GridCoord in a Map. */
|
|
35
|
+
export function gridKey(c) {
|
|
36
|
+
return `${c.x},${c.y}`;
|
|
37
|
+
}
|
|
38
|
+
/** Default empty style class. */
|
|
39
|
+
export const EMPTY_STYLE = { name: '', styles: {} };
|
|
@@ -0,0 +1,52 @@
|
|
|
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;
|
|
52
|
+
//# sourceMappingURL=validate.d.ts.map
|